@oxyhq/auth 2.0.4 → 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 +81 -94
- package/dist/cjs/index.js +1 -2
- package/dist/cjs/utils/sessionHelpers.js +3 -1
- package/dist/cjs/utils/storageHelpers.js +36 -10
- 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 +81 -94
- package/dist/esm/index.js +1 -1
- package/dist/esm/utils/sessionHelpers.js +3 -1
- package/dist/esm/utils/storageHelpers.js +36 -10
- 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 +1 -1
- package/dist/types/utils/sessionHelpers.d.ts +3 -1
- package/package.json +22 -3
- 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 +123 -91
- package/src/index.ts +1 -1
- package/src/utils/sessionHelpers.ts +3 -1
- package/src/utils/storageHelpers.ts +49 -10
package/src/index.ts
CHANGED
|
@@ -104,7 +104,7 @@ export { useWebSSO, isWebBrowser } from './hooks/useWebSSO';
|
|
|
104
104
|
export { useSessionSocket } from './hooks/useSessionSocket';
|
|
105
105
|
export type { UseSessionSocketOptions } from './hooks/useSessionSocket';
|
|
106
106
|
export { useAssets, setOxyAssetInstance } from './hooks/useAssets';
|
|
107
|
-
export { useFileDownloadUrl
|
|
107
|
+
export { useFileDownloadUrl } from './hooks/useFileDownloadUrl';
|
|
108
108
|
export { useFollow, useFollowerCounts } from './hooks/useFollow';
|
|
109
109
|
export { useFileFiltering } from './hooks/useFileFiltering';
|
|
110
110
|
export type { ViewMode, SortBy, SortOrder } from './hooks/useFileFiltering';
|
|
@@ -68,7 +68,9 @@ export const mapSessionsToClient = (
|
|
|
68
68
|
};
|
|
69
69
|
|
|
70
70
|
/**
|
|
71
|
-
* Fetch device sessions
|
|
71
|
+
* Fetch device sessions, falling back to the per-user session endpoint
|
|
72
|
+
* if the device endpoint is unavailable (older API versions or disabled
|
|
73
|
+
* device-grouping feature flag).
|
|
72
74
|
*
|
|
73
75
|
* @param oxyServices - Oxy service instance
|
|
74
76
|
* @param sessionId - Session identifier to fetch
|
|
@@ -19,7 +19,8 @@ const MEMORY_STORAGE = (): StorageInterface => {
|
|
|
19
19
|
|
|
20
20
|
return {
|
|
21
21
|
async getItem(key: string) {
|
|
22
|
-
|
|
22
|
+
const value = store.get(key);
|
|
23
|
+
return value === undefined ? null : value;
|
|
23
24
|
},
|
|
24
25
|
async setItem(key: string, value: string) {
|
|
25
26
|
store.set(key, value);
|
|
@@ -46,29 +47,33 @@ const createWebStorage = (): StorageInterface => {
|
|
|
46
47
|
async getItem(key: string) {
|
|
47
48
|
try {
|
|
48
49
|
return window.localStorage.getItem(key);
|
|
49
|
-
} catch {
|
|
50
|
+
} catch (err) {
|
|
51
|
+
console.warn('[oxy.storage] localStorage.getItem failed:', err);
|
|
50
52
|
return null;
|
|
51
53
|
}
|
|
52
54
|
},
|
|
53
55
|
async setItem(key: string, value: string) {
|
|
54
56
|
try {
|
|
55
57
|
window.localStorage.setItem(key, value);
|
|
56
|
-
} catch {
|
|
57
|
-
//
|
|
58
|
+
} catch (err) {
|
|
59
|
+
// Quota exceeded or storage disabled (e.g., Safari private mode).
|
|
60
|
+
// Surface to logs so it is debuggable, but do not throw so callers
|
|
61
|
+
// can keep functioning with degraded persistence.
|
|
62
|
+
console.warn('[oxy.storage] localStorage.setItem failed:', err);
|
|
58
63
|
}
|
|
59
64
|
},
|
|
60
65
|
async removeItem(key: string) {
|
|
61
66
|
try {
|
|
62
67
|
window.localStorage.removeItem(key);
|
|
63
|
-
} catch {
|
|
64
|
-
|
|
68
|
+
} catch (err) {
|
|
69
|
+
console.warn('[oxy.storage] localStorage.removeItem failed:', err);
|
|
65
70
|
}
|
|
66
71
|
},
|
|
67
72
|
async clear() {
|
|
68
73
|
try {
|
|
69
74
|
window.localStorage.clear();
|
|
70
|
-
} catch {
|
|
71
|
-
|
|
75
|
+
} catch (err) {
|
|
76
|
+
console.warn('[oxy.storage] localStorage.clear failed:', err);
|
|
72
77
|
}
|
|
73
78
|
},
|
|
74
79
|
};
|
|
@@ -76,6 +81,31 @@ const createWebStorage = (): StorageInterface => {
|
|
|
76
81
|
|
|
77
82
|
let asyncStorageInstance: StorageInterface | null = null;
|
|
78
83
|
|
|
84
|
+
/**
|
|
85
|
+
* Structural type for the React Native AsyncStorage default export.
|
|
86
|
+
* Only includes the methods this SDK uses.
|
|
87
|
+
*/
|
|
88
|
+
interface AsyncStorageLike {
|
|
89
|
+
getItem: (key: string) => Promise<string | null>;
|
|
90
|
+
setItem: (key: string, value: string) => Promise<void>;
|
|
91
|
+
removeItem: (key: string) => Promise<void>;
|
|
92
|
+
clear: () => Promise<void>;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Type guard verifying that an imported value exposes the AsyncStorage API.
|
|
97
|
+
*/
|
|
98
|
+
const isAsyncStorageLike = (value: unknown): value is AsyncStorageLike => {
|
|
99
|
+
if (typeof value !== 'object' || value === null) return false;
|
|
100
|
+
const candidate = value as Record<string, unknown>;
|
|
101
|
+
return (
|
|
102
|
+
typeof candidate.getItem === 'function' &&
|
|
103
|
+
typeof candidate.setItem === 'function' &&
|
|
104
|
+
typeof candidate.removeItem === 'function' &&
|
|
105
|
+
typeof candidate.clear === 'function'
|
|
106
|
+
);
|
|
107
|
+
};
|
|
108
|
+
|
|
79
109
|
/**
|
|
80
110
|
* Lazily import React Native AsyncStorage implementation.
|
|
81
111
|
*/
|
|
@@ -87,8 +117,17 @@ const createNativeStorage = async (): Promise<StorageInterface> => {
|
|
|
87
117
|
try {
|
|
88
118
|
// Variable indirection prevents bundlers (Vite, webpack) from statically resolving this
|
|
89
119
|
const moduleName = '@react-native-async-storage/async-storage';
|
|
90
|
-
const asyncStorageModule = await import(moduleName);
|
|
91
|
-
|
|
120
|
+
const asyncStorageModule = (await import(moduleName)) as { default?: unknown };
|
|
121
|
+
const candidate = asyncStorageModule.default;
|
|
122
|
+
if (!isAsyncStorageLike(candidate)) {
|
|
123
|
+
throw new Error('AsyncStorage default export does not match expected API');
|
|
124
|
+
}
|
|
125
|
+
asyncStorageInstance = {
|
|
126
|
+
getItem: (key) => candidate.getItem(key),
|
|
127
|
+
setItem: (key, value) => candidate.setItem(key, value),
|
|
128
|
+
removeItem: (key) => candidate.removeItem(key),
|
|
129
|
+
clear: () => candidate.clear(),
|
|
130
|
+
};
|
|
92
131
|
return asyncStorageInstance;
|
|
93
132
|
} catch (error) {
|
|
94
133
|
if (process.env.NODE_ENV !== 'production') {
|