@oxyhq/auth 2.0.4 → 2.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. package/dist/cjs/.tsbuildinfo +1 -1
  2. package/dist/cjs/WebOxyProvider.js +37 -0
  3. package/dist/cjs/hooks/mutations/index.js +5 -1
  4. package/dist/cjs/hooks/mutations/useAccountMutations.js +185 -43
  5. package/dist/cjs/hooks/mutations/useAppData.js +133 -0
  6. package/dist/cjs/hooks/queries/appDataQueryKeys.js +46 -0
  7. package/dist/cjs/hooks/queries/index.js +8 -1
  8. package/dist/cjs/hooks/queries/useAppData.js +87 -0
  9. package/dist/cjs/hooks/queryClient.js +136 -92
  10. package/dist/cjs/hooks/useFileDownloadUrl.js +12 -36
  11. package/dist/cjs/hooks/useSessionSocket.js +81 -94
  12. package/dist/cjs/index.js +8 -3
  13. package/dist/cjs/utils/sessionHelpers.js +3 -1
  14. package/dist/cjs/utils/storageHelpers.js +36 -10
  15. package/dist/esm/.tsbuildinfo +1 -1
  16. package/dist/esm/WebOxyProvider.js +38 -1
  17. package/dist/esm/hooks/mutations/index.js +2 -0
  18. package/dist/esm/hooks/mutations/useAccountMutations.js +186 -44
  19. package/dist/esm/hooks/mutations/useAppData.js +128 -0
  20. package/dist/esm/hooks/queries/appDataQueryKeys.js +42 -0
  21. package/dist/esm/hooks/queries/index.js +3 -0
  22. package/dist/esm/hooks/queries/useAppData.js +82 -0
  23. package/dist/esm/hooks/queryClient.js +132 -89
  24. package/dist/esm/hooks/useFileDownloadUrl.js +11 -34
  25. package/dist/esm/hooks/useSessionSocket.js +81 -94
  26. package/dist/esm/index.js +3 -3
  27. package/dist/esm/utils/sessionHelpers.js +3 -1
  28. package/dist/esm/utils/storageHelpers.js +36 -10
  29. package/dist/types/.tsbuildinfo +1 -1
  30. package/dist/types/WebOxyProvider.d.ts +1 -1
  31. package/dist/types/hooks/mutations/index.d.ts +1 -0
  32. package/dist/types/hooks/mutations/useAccountMutations.d.ts +153 -9
  33. package/dist/types/hooks/mutations/useAppData.d.ts +47 -0
  34. package/dist/types/hooks/queries/appDataQueryKeys.d.ts +24 -0
  35. package/dist/types/hooks/queries/index.d.ts +2 -0
  36. package/dist/types/hooks/queries/useAccountQueries.d.ts +11 -7
  37. package/dist/types/hooks/queries/useAppData.d.ts +46 -0
  38. package/dist/types/hooks/queries/useSecurityQueries.d.ts +2 -2
  39. package/dist/types/hooks/queries/useServicesQueries.d.ts +7 -5
  40. package/dist/types/hooks/queryClient.d.ts +24 -10
  41. package/dist/types/hooks/useAssets.d.ts +1 -1
  42. package/dist/types/hooks/useFileDownloadUrl.d.ts +2 -6
  43. package/dist/types/index.d.ts +3 -3
  44. package/dist/types/utils/sessionHelpers.d.ts +3 -1
  45. package/package.json +22 -3
  46. package/src/WebOxyProvider.tsx +39 -1
  47. package/src/hooks/mutations/index.ts +3 -0
  48. package/src/hooks/mutations/useAccountMutations.ts +230 -57
  49. package/src/hooks/mutations/useAppData.ts +167 -0
  50. package/src/hooks/queries/appDataQueryKeys.ts +53 -0
  51. package/src/hooks/queries/index.ts +4 -0
  52. package/src/hooks/queries/useAppData.ts +105 -0
  53. package/src/hooks/queryClient.ts +140 -83
  54. package/src/hooks/useFileDownloadUrl.ts +15 -39
  55. package/src/hooks/useSessionSocket.ts +123 -91
  56. package/src/index.ts +7 -1
  57. package/src/utils/sessionHelpers.ts +3 -1
  58. package/src/utils/storageHelpers.ts +49 -10
@@ -5,7 +5,8 @@ const MEMORY_STORAGE = () => {
5
5
  const store = new Map();
6
6
  return {
7
7
  async getItem(key) {
8
- return store.has(key) ? store.get(key) : null;
8
+ const value = store.get(key);
9
+ return value === undefined ? null : value;
9
10
  },
10
11
  async setItem(key, value) {
11
12
  store.set(key, value);
@@ -31,7 +32,8 @@ const createWebStorage = () => {
31
32
  try {
32
33
  return window.localStorage.getItem(key);
33
34
  }
34
- catch {
35
+ catch (err) {
36
+ console.warn('[oxy.storage] localStorage.getItem failed:', err);
35
37
  return null;
36
38
  }
37
39
  },
@@ -39,29 +41,44 @@ const createWebStorage = () => {
39
41
  try {
40
42
  window.localStorage.setItem(key, value);
41
43
  }
42
- catch {
43
- // Ignore quota or access issues for now.
44
+ catch (err) {
45
+ // Quota exceeded or storage disabled (e.g., Safari private mode).
46
+ // Surface to logs so it is debuggable, but do not throw so callers
47
+ // can keep functioning with degraded persistence.
48
+ console.warn('[oxy.storage] localStorage.setItem failed:', err);
44
49
  }
45
50
  },
46
51
  async removeItem(key) {
47
52
  try {
48
53
  window.localStorage.removeItem(key);
49
54
  }
50
- catch {
51
- // Ignore failures.
55
+ catch (err) {
56
+ console.warn('[oxy.storage] localStorage.removeItem failed:', err);
52
57
  }
53
58
  },
54
59
  async clear() {
55
60
  try {
56
61
  window.localStorage.clear();
57
62
  }
58
- catch {
59
- // Ignore failures.
63
+ catch (err) {
64
+ console.warn('[oxy.storage] localStorage.clear failed:', err);
60
65
  }
61
66
  },
62
67
  };
63
68
  };
64
69
  let asyncStorageInstance = null;
70
+ /**
71
+ * Type guard verifying that an imported value exposes the AsyncStorage API.
72
+ */
73
+ const isAsyncStorageLike = (value) => {
74
+ if (typeof value !== 'object' || value === null)
75
+ return false;
76
+ const candidate = value;
77
+ return (typeof candidate.getItem === 'function' &&
78
+ typeof candidate.setItem === 'function' &&
79
+ typeof candidate.removeItem === 'function' &&
80
+ typeof candidate.clear === 'function');
81
+ };
65
82
  /**
66
83
  * Lazily import React Native AsyncStorage implementation.
67
84
  */
@@ -72,8 +89,17 @@ const createNativeStorage = async () => {
72
89
  try {
73
90
  // Variable indirection prevents bundlers (Vite, webpack) from statically resolving this
74
91
  const moduleName = '@react-native-async-storage/async-storage';
75
- const asyncStorageModule = await import(moduleName);
76
- asyncStorageInstance = asyncStorageModule.default;
92
+ const asyncStorageModule = (await import(moduleName));
93
+ const candidate = asyncStorageModule.default;
94
+ if (!isAsyncStorageLike(candidate)) {
95
+ throw new Error('AsyncStorage default export does not match expected API');
96
+ }
97
+ asyncStorageInstance = {
98
+ getItem: (key) => candidate.getItem(key),
99
+ setItem: (key, value) => candidate.setItem(key, value),
100
+ removeItem: (key) => candidate.removeItem(key),
101
+ clear: () => candidate.clear(),
102
+ };
77
103
  return asyncStorageInstance;
78
104
  }
79
105
  catch (error) {