@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.
- package/dist/cjs/.tsbuildinfo +1 -1
- package/dist/cjs/WebOxyProvider.js +37 -0
- package/dist/cjs/hooks/mutations/useAccountMutations.js +185 -43
- package/dist/cjs/hooks/queryClient.js +136 -92
- package/dist/cjs/hooks/useFileDownloadUrl.js +12 -36
- package/dist/cjs/hooks/useSessionSocket.js +250 -115
- package/dist/cjs/index.js +13 -3
- package/dist/cjs/stores/accountStore.js +2 -2
- package/dist/cjs/utils/sessionHelpers.js +4 -2
- package/dist/cjs/utils/storageHelpers.js +37 -11
- package/dist/esm/.tsbuildinfo +1 -1
- package/dist/esm/WebOxyProvider.js +38 -1
- package/dist/esm/hooks/mutations/useAccountMutations.js +186 -44
- package/dist/esm/hooks/queryClient.js +132 -89
- package/dist/esm/hooks/useFileDownloadUrl.js +11 -34
- package/dist/esm/hooks/useSessionSocket.js +217 -112
- package/dist/esm/index.js +4 -1
- package/dist/esm/stores/accountStore.js +2 -2
- package/dist/esm/utils/sessionHelpers.js +4 -2
- package/dist/esm/utils/storageHelpers.js +37 -11
- package/dist/types/.tsbuildinfo +1 -1
- package/dist/types/WebOxyProvider.d.ts +1 -1
- package/dist/types/hooks/mutations/useAccountMutations.d.ts +153 -9
- package/dist/types/hooks/queries/useAccountQueries.d.ts +11 -7
- package/dist/types/hooks/queries/useSecurityQueries.d.ts +2 -2
- package/dist/types/hooks/queries/useServicesQueries.d.ts +7 -5
- package/dist/types/hooks/queryClient.d.ts +24 -10
- package/dist/types/hooks/useAssets.d.ts +1 -1
- package/dist/types/hooks/useFileDownloadUrl.d.ts +2 -6
- package/dist/types/index.d.ts +5 -1
- package/dist/types/utils/sessionHelpers.d.ts +3 -1
- package/package.json +29 -5
- package/src/WebOxyProvider.tsx +39 -1
- package/src/hooks/mutations/useAccountMutations.ts +230 -57
- package/src/hooks/queryClient.ts +140 -83
- package/src/hooks/useFileDownloadUrl.ts +15 -39
- package/src/hooks/useSessionSocket.ts +273 -112
- package/src/index.ts +13 -1
- package/src/stores/accountStore.ts +2 -2
- package/src/utils/sessionHelpers.ts +4 -2
- package/src/utils/storageHelpers.ts +50 -11
- 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
|
-
|
|
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
|
-
//
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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 (
|
|
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');
|