@oxyhq/auth 2.0.3 → 2.0.5

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 (42) hide show
  1. package/dist/cjs/.tsbuildinfo +1 -1
  2. package/dist/cjs/WebOxyProvider.js +37 -0
  3. package/dist/cjs/hooks/mutations/useAccountMutations.js +185 -43
  4. package/dist/cjs/hooks/queryClient.js +136 -92
  5. package/dist/cjs/hooks/useFileDownloadUrl.js +12 -36
  6. package/dist/cjs/hooks/useSessionSocket.js +250 -115
  7. package/dist/cjs/index.js +13 -3
  8. package/dist/cjs/stores/accountStore.js +2 -2
  9. package/dist/cjs/utils/sessionHelpers.js +4 -2
  10. package/dist/cjs/utils/storageHelpers.js +37 -11
  11. package/dist/esm/.tsbuildinfo +1 -1
  12. package/dist/esm/WebOxyProvider.js +38 -1
  13. package/dist/esm/hooks/mutations/useAccountMutations.js +186 -44
  14. package/dist/esm/hooks/queryClient.js +132 -89
  15. package/dist/esm/hooks/useFileDownloadUrl.js +11 -34
  16. package/dist/esm/hooks/useSessionSocket.js +217 -112
  17. package/dist/esm/index.js +4 -1
  18. package/dist/esm/stores/accountStore.js +2 -2
  19. package/dist/esm/utils/sessionHelpers.js +4 -2
  20. package/dist/esm/utils/storageHelpers.js +37 -11
  21. package/dist/types/.tsbuildinfo +1 -1
  22. package/dist/types/WebOxyProvider.d.ts +1 -1
  23. package/dist/types/hooks/mutations/useAccountMutations.d.ts +153 -9
  24. package/dist/types/hooks/queries/useAccountQueries.d.ts +11 -7
  25. package/dist/types/hooks/queries/useSecurityQueries.d.ts +2 -2
  26. package/dist/types/hooks/queries/useServicesQueries.d.ts +7 -5
  27. package/dist/types/hooks/queryClient.d.ts +24 -10
  28. package/dist/types/hooks/useAssets.d.ts +1 -1
  29. package/dist/types/hooks/useFileDownloadUrl.d.ts +2 -6
  30. package/dist/types/index.d.ts +5 -1
  31. package/dist/types/utils/sessionHelpers.d.ts +3 -1
  32. package/package.json +29 -5
  33. package/src/WebOxyProvider.tsx +39 -1
  34. package/src/hooks/mutations/useAccountMutations.ts +230 -57
  35. package/src/hooks/queryClient.ts +140 -83
  36. package/src/hooks/useFileDownloadUrl.ts +15 -39
  37. package/src/hooks/useSessionSocket.ts +273 -112
  38. package/src/index.ts +13 -1
  39. package/src/stores/accountStore.ts +2 -2
  40. package/src/utils/sessionHelpers.ts +4 -2
  41. package/src/utils/storageHelpers.ts +50 -11
  42. package/src/global.d.ts +0 -1
@@ -41,7 +41,8 @@ const MEMORY_STORAGE = () => {
41
41
  const store = new Map();
42
42
  return {
43
43
  async getItem(key) {
44
- return store.has(key) ? store.get(key) : null;
44
+ const value = store.get(key);
45
+ return value === undefined ? null : value;
45
46
  },
46
47
  async setItem(key, value) {
47
48
  store.set(key, value);
@@ -67,7 +68,8 @@ const createWebStorage = () => {
67
68
  try {
68
69
  return window.localStorage.getItem(key);
69
70
  }
70
- catch {
71
+ catch (err) {
72
+ console.warn('[oxy.storage] localStorage.getItem failed:', err);
71
73
  return null;
72
74
  }
73
75
  },
@@ -75,29 +77,44 @@ const createWebStorage = () => {
75
77
  try {
76
78
  window.localStorage.setItem(key, value);
77
79
  }
78
- catch {
79
- // Ignore quota or access issues for now.
80
+ catch (err) {
81
+ // Quota exceeded or storage disabled (e.g., Safari private mode).
82
+ // Surface to logs so it is debuggable, but do not throw so callers
83
+ // can keep functioning with degraded persistence.
84
+ console.warn('[oxy.storage] localStorage.setItem failed:', err);
80
85
  }
81
86
  },
82
87
  async removeItem(key) {
83
88
  try {
84
89
  window.localStorage.removeItem(key);
85
90
  }
86
- catch {
87
- // Ignore failures.
91
+ catch (err) {
92
+ console.warn('[oxy.storage] localStorage.removeItem failed:', err);
88
93
  }
89
94
  },
90
95
  async clear() {
91
96
  try {
92
97
  window.localStorage.clear();
93
98
  }
94
- catch {
95
- // Ignore failures.
99
+ catch (err) {
100
+ console.warn('[oxy.storage] localStorage.clear failed:', err);
96
101
  }
97
102
  },
98
103
  };
99
104
  };
100
105
  let asyncStorageInstance = null;
106
+ /**
107
+ * Type guard verifying that an imported value exposes the AsyncStorage API.
108
+ */
109
+ const isAsyncStorageLike = (value) => {
110
+ if (typeof value !== 'object' || value === null)
111
+ return false;
112
+ const candidate = value;
113
+ return (typeof candidate.getItem === 'function' &&
114
+ typeof candidate.setItem === 'function' &&
115
+ typeof candidate.removeItem === 'function' &&
116
+ typeof candidate.clear === 'function');
117
+ };
101
118
  /**
102
119
  * Lazily import React Native AsyncStorage implementation.
103
120
  */
@@ -108,12 +125,21 @@ const createNativeStorage = async () => {
108
125
  try {
109
126
  // Variable indirection prevents bundlers (Vite, webpack) from statically resolving this
110
127
  const moduleName = '@react-native-async-storage/async-storage';
111
- const asyncStorageModule = await Promise.resolve(`${moduleName}`).then(s => __importStar(require(s)));
112
- asyncStorageInstance = asyncStorageModule.default;
128
+ const asyncStorageModule = (await Promise.resolve(`${moduleName}`).then(s => __importStar(require(s))));
129
+ const candidate = asyncStorageModule.default;
130
+ if (!isAsyncStorageLike(candidate)) {
131
+ throw new Error('AsyncStorage default export does not match expected API');
132
+ }
133
+ asyncStorageInstance = {
134
+ getItem: (key) => candidate.getItem(key),
135
+ setItem: (key, value) => candidate.setItem(key, value),
136
+ removeItem: (key) => candidate.removeItem(key),
137
+ clear: () => candidate.clear(),
138
+ };
113
139
  return asyncStorageInstance;
114
140
  }
115
141
  catch (error) {
116
- if (__DEV__) {
142
+ if (process.env.NODE_ENV !== 'production') {
117
143
  console.error('Failed to import AsyncStorage:', error);
118
144
  }
119
145
  throw new Error('AsyncStorage is required in React Native environment');