@oxyhq/auth 2.0.3 → 2.0.4
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/hooks/queryClient.js +3 -3
- package/dist/cjs/hooks/useSessionSocket.js +260 -112
- package/dist/cjs/index.js +13 -2
- package/dist/cjs/stores/accountStore.js +2 -2
- package/dist/cjs/utils/sessionHelpers.js +1 -1
- package/dist/cjs/utils/storageHelpers.js +1 -1
- package/dist/esm/.tsbuildinfo +1 -1
- package/dist/esm/hooks/queryClient.js +3 -3
- package/dist/esm/hooks/useSessionSocket.js +227 -109
- package/dist/esm/index.js +3 -0
- package/dist/esm/stores/accountStore.js +2 -2
- package/dist/esm/utils/sessionHelpers.js +1 -1
- package/dist/esm/utils/storageHelpers.js +1 -1
- package/dist/types/.tsbuildinfo +1 -1
- package/dist/types/index.d.ts +4 -0
- package/package.json +8 -3
- package/src/hooks/queryClient.ts +3 -3
- package/src/hooks/useSessionSocket.ts +238 -109
- package/src/index.ts +12 -0
- package/src/stores/accountStore.ts +2 -2
- package/src/utils/sessionHelpers.ts +1 -1
- package/src/utils/storageHelpers.ts +1 -1
- package/src/global.d.ts +0 -1
|
@@ -1,11 +1,40 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
5
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
36
|
exports.useSessionSocket = useSessionSocket;
|
|
7
37
|
const react_1 = require("react");
|
|
8
|
-
const socket_io_client_1 = __importDefault(require("socket.io-client"));
|
|
9
38
|
const sonner_1 = require("sonner");
|
|
10
39
|
const core_1 = require("@oxyhq/core");
|
|
11
40
|
const core_2 = require("@oxyhq/core");
|
|
@@ -14,6 +43,46 @@ const react_query_1 = require("@tanstack/react-query");
|
|
|
14
43
|
const useServicesQueries_1 = require("./queries/useServicesQueries");
|
|
15
44
|
const queryKeys_1 = require("./queries/queryKeys");
|
|
16
45
|
const debug = (0, core_2.createDebugLogger)('SessionSocket');
|
|
46
|
+
/** localStorage key used by AuthManager for persisting access tokens. */
|
|
47
|
+
const LS_ACCESS_TOKEN_KEY = 'oxy_access_token';
|
|
48
|
+
/** Delay before retrying socket connection after an auth failure (ms). */
|
|
49
|
+
const AUTH_RETRY_DELAY_MS = 2000;
|
|
50
|
+
/** Maximum number of consecutive auth-failure retries. */
|
|
51
|
+
const MAX_AUTH_RETRIES = 3;
|
|
52
|
+
/**
|
|
53
|
+
* Read the access token from localStorage directly.
|
|
54
|
+
* Used as a fallback when the in-memory token is empty (e.g., during a
|
|
55
|
+
* cross-tab token refresh race).
|
|
56
|
+
*/
|
|
57
|
+
function readTokenFromStorage() {
|
|
58
|
+
if (typeof window === 'undefined')
|
|
59
|
+
return null;
|
|
60
|
+
try {
|
|
61
|
+
return window.localStorage.getItem(LS_ACCESS_TOKEN_KEY);
|
|
62
|
+
}
|
|
63
|
+
catch {
|
|
64
|
+
return null;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
let _io = null;
|
|
68
|
+
let _ioLoadAttempted = false;
|
|
69
|
+
async function getSocketIO() {
|
|
70
|
+
if (_io)
|
|
71
|
+
return _io;
|
|
72
|
+
if (_ioLoadAttempted)
|
|
73
|
+
return null;
|
|
74
|
+
_ioLoadAttempted = true;
|
|
75
|
+
try {
|
|
76
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
77
|
+
const mod = await Promise.resolve().then(() => __importStar(require('socket.io-client')));
|
|
78
|
+
_io = (mod.io ?? mod.default);
|
|
79
|
+
return _io;
|
|
80
|
+
}
|
|
81
|
+
catch {
|
|
82
|
+
debug.warn('socket.io-client is not installed. useSessionSocket will be disabled. Install it with: bun add socket.io-client');
|
|
83
|
+
return null;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
17
86
|
function useSessionSocket(options) {
|
|
18
87
|
const { user, activeSessionId, oxyServices, signOut, clearSessionState } = (0, WebOxyProvider_1.useWebOxy)();
|
|
19
88
|
const queryClient = (0, react_query_1.useQueryClient)();
|
|
@@ -58,137 +127,216 @@ function useSessionSocket(options) {
|
|
|
58
127
|
socketRef.current.disconnect();
|
|
59
128
|
socketRef.current = null;
|
|
60
129
|
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
const
|
|
70
|
-
|
|
71
|
-
const handleConnect = () => {
|
|
72
|
-
debug.log('Socket connected:', socket.id);
|
|
130
|
+
let cancelled = false;
|
|
131
|
+
let authRetryCount = 0;
|
|
132
|
+
let authRetryTimer = null;
|
|
133
|
+
/**
|
|
134
|
+
* Resolve the best available access token.
|
|
135
|
+
* Prefers the in-memory token from OxyServices; falls back to
|
|
136
|
+
* localStorage which may have been updated by another tab.
|
|
137
|
+
*/
|
|
138
|
+
const resolveToken = () => {
|
|
139
|
+
return oxyServices.getAccessToken() || readTokenFromStorage();
|
|
73
140
|
};
|
|
74
|
-
|
|
75
|
-
(
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
const
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
}
|
|
93
|
-
else {
|
|
94
|
-
sonner_1.toast.info('You have been signed out remotely.');
|
|
95
|
-
}
|
|
96
|
-
try {
|
|
97
|
-
await clearSessionStateRef.current();
|
|
98
|
-
}
|
|
99
|
-
catch (error) {
|
|
100
|
-
if (__DEV__) {
|
|
101
|
-
core_1.logger.error('Failed to clear session state after session_removed', error instanceof Error ? error : new Error(String(error)), { component: 'useSessionSocket' });
|
|
141
|
+
getSocketIO().then((ioFn) => {
|
|
142
|
+
if (cancelled || !ioFn)
|
|
143
|
+
return;
|
|
144
|
+
// Connect with auth token; use callback so reconnections get a fresh token.
|
|
145
|
+
// If no token is available at all, we skip the initial connect and let
|
|
146
|
+
// the storage listener or retry logic connect when a token appears.
|
|
147
|
+
const token = resolveToken();
|
|
148
|
+
socketRef.current = ioFn(baseURL, {
|
|
149
|
+
transports: ['websocket'],
|
|
150
|
+
autoConnect: !!token, // don't auto-connect when there is no token
|
|
151
|
+
auth: (cb) => {
|
|
152
|
+
const resolved = resolveToken();
|
|
153
|
+
if (!resolved) {
|
|
154
|
+
// No token available -- disconnect gracefully instead of sending
|
|
155
|
+
// an empty string that the server will reject.
|
|
156
|
+
debug.warn('No access token available for socket auth; disconnecting.');
|
|
157
|
+
if (socketRef.current) {
|
|
158
|
+
socketRef.current.disconnect();
|
|
102
159
|
}
|
|
160
|
+
return;
|
|
103
161
|
}
|
|
162
|
+
cb({ token: resolved });
|
|
163
|
+
},
|
|
164
|
+
});
|
|
165
|
+
const socket = socketRef.current;
|
|
166
|
+
// Server auto-joins the user to `user:<userId>` room on connection
|
|
167
|
+
const handleConnect = () => {
|
|
168
|
+
debug.log('Socket connected:', socket.id);
|
|
169
|
+
// Successful connection resets the auth retry counter.
|
|
170
|
+
authRetryCount = 0;
|
|
171
|
+
};
|
|
172
|
+
/**
|
|
173
|
+
* Handle socket disconnection. When the disconnect reason indicates an
|
|
174
|
+
* auth failure (server rejected the token), schedule a short retry so
|
|
175
|
+
* that an in-progress token refresh can complete before the next attempt.
|
|
176
|
+
*/
|
|
177
|
+
const handleDisconnect = (reason) => {
|
|
178
|
+
debug.log('Socket disconnected:', reason);
|
|
179
|
+
// "io server disconnect" = server forcibly closed the connection (auth failure).
|
|
180
|
+
// "transport error" can also happen when the auth callback aborted.
|
|
181
|
+
if ((reason === 'io server disconnect' || reason === 'transport error') &&
|
|
182
|
+
authRetryCount < MAX_AUTH_RETRIES &&
|
|
183
|
+
!cancelled) {
|
|
184
|
+
authRetryCount++;
|
|
185
|
+
debug.log(`Auth-related disconnect; scheduling retry ${authRetryCount}/${MAX_AUTH_RETRIES} in ${AUTH_RETRY_DELAY_MS}ms`);
|
|
186
|
+
authRetryTimer = setTimeout(() => {
|
|
187
|
+
if (cancelled)
|
|
188
|
+
return;
|
|
189
|
+
const retryToken = resolveToken();
|
|
190
|
+
if (retryToken && socketRef.current) {
|
|
191
|
+
debug.log('Retrying socket connection with refreshed token');
|
|
192
|
+
socketRef.current.connect();
|
|
193
|
+
}
|
|
194
|
+
}, AUTH_RETRY_DELAY_MS);
|
|
104
195
|
}
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
196
|
+
};
|
|
197
|
+
const refreshSessions = () => {
|
|
198
|
+
(0, queryKeys_1.invalidateSessionQueries)(queryClientRef.current);
|
|
199
|
+
return Promise.resolve();
|
|
200
|
+
};
|
|
201
|
+
const handleSessionUpdate = async (data) => {
|
|
202
|
+
debug.log('Received session_update:', data);
|
|
203
|
+
const currentActiveSessionId = activeSessionIdRef.current;
|
|
204
|
+
const deviceId = currentDeviceIdRef.current;
|
|
205
|
+
// Handle different event types
|
|
206
|
+
if (data.type === 'session_removed') {
|
|
207
|
+
// Track removed session
|
|
208
|
+
if (data.sessionId && onSessionRemovedRef.current) {
|
|
209
|
+
onSessionRemovedRef.current(data.sessionId);
|
|
114
210
|
}
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
211
|
+
// If the removed sessionId matches the current activeSessionId, immediately clear state
|
|
212
|
+
if (data.sessionId === currentActiveSessionId) {
|
|
213
|
+
if (onRemoteSignOutRef.current) {
|
|
214
|
+
onRemoteSignOutRef.current();
|
|
215
|
+
}
|
|
216
|
+
else {
|
|
217
|
+
sonner_1.toast.info('You have been signed out remotely.');
|
|
218
|
+
}
|
|
219
|
+
try {
|
|
220
|
+
await clearSessionStateRef.current();
|
|
221
|
+
}
|
|
222
|
+
catch (error) {
|
|
223
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
224
|
+
core_1.logger.error('Failed to clear session state after session_removed', error instanceof Error ? error : new Error(String(error)), { component: 'useSessionSocket' });
|
|
225
|
+
}
|
|
226
|
+
}
|
|
120
227
|
}
|
|
121
228
|
else {
|
|
122
|
-
|
|
123
|
-
}
|
|
124
|
-
try {
|
|
125
|
-
await clearSessionStateRef.current();
|
|
126
|
-
}
|
|
127
|
-
catch (error) {
|
|
128
|
-
if (__DEV__) {
|
|
129
|
-
core_1.logger.error('Failed to clear session state after device_removed', error instanceof Error ? error : new Error(String(error)), { component: 'useSessionSocket' });
|
|
130
|
-
}
|
|
229
|
+
refreshSessions();
|
|
131
230
|
}
|
|
132
231
|
}
|
|
133
|
-
else {
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
if (data.sessionIds && onSessionRemovedRef.current) {
|
|
140
|
-
for (const sessionId of data.sessionIds) {
|
|
141
|
-
onSessionRemovedRef.current(sessionId);
|
|
232
|
+
else if (data.type === 'device_removed') {
|
|
233
|
+
// Track all removed sessions from this device
|
|
234
|
+
if (data.sessionIds && onSessionRemovedRef.current) {
|
|
235
|
+
for (const sessionId of data.sessionIds) {
|
|
236
|
+
onSessionRemovedRef.current(sessionId);
|
|
237
|
+
}
|
|
142
238
|
}
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
239
|
+
// If the removed deviceId matches the current device, immediately clear state
|
|
240
|
+
if (data.deviceId && data.deviceId === deviceId) {
|
|
241
|
+
if (onRemoteSignOutRef.current) {
|
|
242
|
+
onRemoteSignOutRef.current();
|
|
243
|
+
}
|
|
244
|
+
else {
|
|
245
|
+
sonner_1.toast.info('This device has been removed. You have been signed out.');
|
|
246
|
+
}
|
|
247
|
+
try {
|
|
248
|
+
await clearSessionStateRef.current();
|
|
249
|
+
}
|
|
250
|
+
catch (error) {
|
|
251
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
252
|
+
core_1.logger.error('Failed to clear session state after device_removed', error instanceof Error ? error : new Error(String(error)), { component: 'useSessionSocket' });
|
|
253
|
+
}
|
|
254
|
+
}
|
|
148
255
|
}
|
|
149
256
|
else {
|
|
150
|
-
|
|
257
|
+
refreshSessions();
|
|
151
258
|
}
|
|
152
|
-
|
|
153
|
-
|
|
259
|
+
}
|
|
260
|
+
else if (data.type === 'sessions_removed') {
|
|
261
|
+
// Track all removed sessions
|
|
262
|
+
if (data.sessionIds && onSessionRemovedRef.current) {
|
|
263
|
+
for (const sessionId of data.sessionIds) {
|
|
264
|
+
onSessionRemovedRef.current(sessionId);
|
|
265
|
+
}
|
|
154
266
|
}
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
267
|
+
// If the current activeSessionId is in the removed sessionIds list, immediately clear state
|
|
268
|
+
if (data.sessionIds && currentActiveSessionId && data.sessionIds.includes(currentActiveSessionId)) {
|
|
269
|
+
if (onRemoteSignOutRef.current) {
|
|
270
|
+
onRemoteSignOutRef.current();
|
|
271
|
+
}
|
|
272
|
+
else {
|
|
273
|
+
sonner_1.toast.info('You have been signed out remotely.');
|
|
274
|
+
}
|
|
275
|
+
try {
|
|
276
|
+
await clearSessionStateRef.current();
|
|
277
|
+
}
|
|
278
|
+
catch (error) {
|
|
279
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
280
|
+
core_1.logger.error('Failed to clear session state after sessions_removed', error instanceof Error ? error : new Error(String(error)), { component: 'useSessionSocket' });
|
|
281
|
+
}
|
|
158
282
|
}
|
|
159
283
|
}
|
|
284
|
+
else {
|
|
285
|
+
refreshSessions();
|
|
286
|
+
}
|
|
160
287
|
}
|
|
161
288
|
else {
|
|
289
|
+
// For other event types (e.g., session_created), refresh sessions
|
|
162
290
|
refreshSessions();
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
await clearSessionStateRef.current();
|
|
178
|
-
}
|
|
179
|
-
catch (error) {
|
|
180
|
-
debug.error('Failed to clear session state after session_update:', error);
|
|
291
|
+
// If the current session was logged out (legacy behavior), handle it specially
|
|
292
|
+
if (data.sessionId === currentActiveSessionId) {
|
|
293
|
+
if (onRemoteSignOutRef.current) {
|
|
294
|
+
onRemoteSignOutRef.current();
|
|
295
|
+
}
|
|
296
|
+
else {
|
|
297
|
+
sonner_1.toast.info('You have been signed out remotely.');
|
|
298
|
+
}
|
|
299
|
+
try {
|
|
300
|
+
await clearSessionStateRef.current();
|
|
301
|
+
}
|
|
302
|
+
catch (error) {
|
|
303
|
+
debug.error('Failed to clear session state after session_update:', error);
|
|
304
|
+
}
|
|
181
305
|
}
|
|
182
306
|
}
|
|
307
|
+
};
|
|
308
|
+
socket.on('connect', handleConnect);
|
|
309
|
+
socket.on('disconnect', handleDisconnect);
|
|
310
|
+
socket.on('session_update', handleSessionUpdate);
|
|
311
|
+
// Listen for cross-tab token updates via the Storage event.
|
|
312
|
+
// When another tab writes a fresh access token to localStorage,
|
|
313
|
+
// reconnect this tab's socket if it was disconnected.
|
|
314
|
+
const handleStorageEvent = (e) => {
|
|
315
|
+
if (e.key === LS_ACCESS_TOKEN_KEY && e.newValue && socketRef.current?.disconnected) {
|
|
316
|
+
debug.log('Cross-tab token update detected; reconnecting socket');
|
|
317
|
+
authRetryCount = 0; // reset retries since we got a fresh token
|
|
318
|
+
socketRef.current.connect();
|
|
319
|
+
}
|
|
320
|
+
};
|
|
321
|
+
if (typeof window !== 'undefined') {
|
|
322
|
+
window.addEventListener('storage', handleStorageEvent);
|
|
323
|
+
// Store the handler so cleanup can remove it
|
|
324
|
+
socket.__oxyStorageHandler = handleStorageEvent;
|
|
183
325
|
}
|
|
184
|
-
};
|
|
185
|
-
socket.on('connect', handleConnect);
|
|
186
|
-
socket.on('session_update', handleSessionUpdate);
|
|
326
|
+
});
|
|
187
327
|
return () => {
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
328
|
+
cancelled = true;
|
|
329
|
+
if (authRetryTimer) {
|
|
330
|
+
clearTimeout(authRetryTimer);
|
|
331
|
+
}
|
|
332
|
+
if (socketRef.current) {
|
|
333
|
+
// Remove cross-tab storage listener
|
|
334
|
+
if (typeof window !== 'undefined' && socketRef.current.__oxyStorageHandler) {
|
|
335
|
+
window.removeEventListener('storage', socketRef.current.__oxyStorageHandler);
|
|
336
|
+
}
|
|
337
|
+
socketRef.current.disconnect();
|
|
338
|
+
socketRef.current = null;
|
|
339
|
+
}
|
|
192
340
|
};
|
|
193
341
|
}, [userId, baseURL]); // Only depend on userId and baseURL - callbacks are in refs
|
|
194
342
|
}
|
package/dist/cjs/index.js
CHANGED
|
@@ -24,8 +24,8 @@
|
|
|
24
24
|
* ```
|
|
25
25
|
*/
|
|
26
26
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
|
-
exports.
|
|
28
|
-
exports.extractErrorMessage = exports.isTimeoutOrNetworkError = void 0;
|
|
27
|
+
exports.useAssets = exports.useSessionSocket = exports.isWebBrowser = exports.useWebSSO = exports.createGenericMutation = exports.createProfileMutation = exports.useRemoveDevice = exports.useUpdateDeviceName = exports.useLogoutAll = exports.useLogoutSession = exports.useSwitchSession = exports.useUploadFile = exports.useUpdatePrivacySettings = exports.useUpdateAccountSettings = exports.useUploadAvatar = exports.useUpdateProfile = exports.useRecentSecurityActivity = exports.useSecurityActivity = exports.useSecurityInfo = exports.useUserDevices = exports.useDeviceSessions = exports.useSession = exports.useSessions = exports.usePrivacySettings = exports.useUsersBySessions = exports.useUserByUsername = exports.useUserById = exports.useCurrentUser = exports.useUserProfiles = exports.useUserProfile = exports.useFollowStore = exports.useAccountLoadingSession = exports.useAccountError = exports.useAccountLoading = exports.useAccounts = exports.useAccountStore = exports.useIsAssetLinked = exports.useAssetUsageCount = exports.useAssetsByEntity = exports.useAssetsByApp = exports.useAssetErrors = exports.useAssetLoading = exports.useUploadProgress = exports.useAsset = exports.useAssetsStore = exports.useAssetStore = exports.useAuthStore = exports.useAuth = exports.useWebOxy = exports.WebOxyProvider = void 0;
|
|
28
|
+
exports.extractErrorMessage = exports.isTimeoutOrNetworkError = exports.isInvalidSessionError = exports.handleAuthError = exports.useFileFiltering = exports.useFollowerCounts = exports.useFollow = exports.setOxyFileUrlInstance = exports.useFileDownloadUrl = exports.setOxyAssetInstance = void 0;
|
|
29
29
|
// --- Provider & Hooks ---
|
|
30
30
|
var WebOxyProvider_1 = require("./WebOxyProvider");
|
|
31
31
|
Object.defineProperty(exports, "WebOxyProvider", { enumerable: true, get: function () { return WebOxyProvider_1.WebOxyProvider; } });
|
|
@@ -45,6 +45,14 @@ Object.defineProperty(exports, "useAssetsByApp", { enumerable: true, get: functi
|
|
|
45
45
|
Object.defineProperty(exports, "useAssetsByEntity", { enumerable: true, get: function () { return assetStore_1.useAssetsByEntity; } });
|
|
46
46
|
Object.defineProperty(exports, "useAssetUsageCount", { enumerable: true, get: function () { return assetStore_1.useAssetUsageCount; } });
|
|
47
47
|
Object.defineProperty(exports, "useIsAssetLinked", { enumerable: true, get: function () { return assetStore_1.useIsAssetLinked; } });
|
|
48
|
+
var accountStore_1 = require("./stores/accountStore");
|
|
49
|
+
Object.defineProperty(exports, "useAccountStore", { enumerable: true, get: function () { return accountStore_1.useAccountStore; } });
|
|
50
|
+
Object.defineProperty(exports, "useAccounts", { enumerable: true, get: function () { return accountStore_1.useAccounts; } });
|
|
51
|
+
Object.defineProperty(exports, "useAccountLoading", { enumerable: true, get: function () { return accountStore_1.useAccountLoading; } });
|
|
52
|
+
Object.defineProperty(exports, "useAccountError", { enumerable: true, get: function () { return accountStore_1.useAccountError; } });
|
|
53
|
+
Object.defineProperty(exports, "useAccountLoadingSession", { enumerable: true, get: function () { return accountStore_1.useAccountLoadingSession; } });
|
|
54
|
+
var followStore_1 = require("./stores/followStore");
|
|
55
|
+
Object.defineProperty(exports, "useFollowStore", { enumerable: true, get: function () { return followStore_1.useFollowStore; } });
|
|
48
56
|
// --- Query Hooks ---
|
|
49
57
|
var queries_1 = require("./hooks/queries");
|
|
50
58
|
Object.defineProperty(exports, "useUserProfile", { enumerable: true, get: function () { return queries_1.useUserProfile; } });
|
|
@@ -77,6 +85,9 @@ var mutationFactory_1 = require("./hooks/mutations/mutationFactory");
|
|
|
77
85
|
Object.defineProperty(exports, "createProfileMutation", { enumerable: true, get: function () { return mutationFactory_1.createProfileMutation; } });
|
|
78
86
|
Object.defineProperty(exports, "createGenericMutation", { enumerable: true, get: function () { return mutationFactory_1.createGenericMutation; } });
|
|
79
87
|
// --- Custom Hooks ---
|
|
88
|
+
var useWebSSO_1 = require("./hooks/useWebSSO");
|
|
89
|
+
Object.defineProperty(exports, "useWebSSO", { enumerable: true, get: function () { return useWebSSO_1.useWebSSO; } });
|
|
90
|
+
Object.defineProperty(exports, "isWebBrowser", { enumerable: true, get: function () { return useWebSSO_1.isWebBrowser; } });
|
|
80
91
|
var useSessionSocket_1 = require("./hooks/useSessionSocket");
|
|
81
92
|
Object.defineProperty(exports, "useSessionSocket", { enumerable: true, get: function () { return useSessionSocket_1.useSessionSocket; } });
|
|
82
93
|
var useAssets_1 = require("./hooks/useAssets");
|
|
@@ -164,7 +164,7 @@ exports.useAccountStore = (0, zustand_1.create)((set, get) => ({
|
|
|
164
164
|
}
|
|
165
165
|
catch (error) {
|
|
166
166
|
const errorMessage = error instanceof Error ? error.message : 'Failed to load accounts';
|
|
167
|
-
if (
|
|
167
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
168
168
|
console.error('AccountStore: Failed to load accounts:', error);
|
|
169
169
|
}
|
|
170
170
|
set({ error: errorMessage });
|
|
@@ -175,7 +175,7 @@ exports.useAccountStore = (0, zustand_1.create)((set, get) => ({
|
|
|
175
175
|
}
|
|
176
176
|
catch (error) {
|
|
177
177
|
const errorMessage = error instanceof Error ? error.message : 'Failed to load accounts';
|
|
178
|
-
if (
|
|
178
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
179
179
|
console.error('AccountStore: Failed to load accounts:', error);
|
|
180
180
|
}
|
|
181
181
|
set({ error: errorMessage, loading: false });
|
|
@@ -37,7 +37,7 @@ const fetchSessionsWithFallback = async (oxyServices, sessionId, { fallbackDevic
|
|
|
37
37
|
return (0, exports.mapSessionsToClient)(deviceSessions, fallbackDeviceId, fallbackUserId);
|
|
38
38
|
}
|
|
39
39
|
catch (error) {
|
|
40
|
-
if (
|
|
40
|
+
if (process.env.NODE_ENV !== 'production' && logger) {
|
|
41
41
|
logger('Failed to get device sessions, falling back to user sessions', error);
|
|
42
42
|
}
|
|
43
43
|
const userSessions = await oxyServices.getSessionsBySessionId(sessionId);
|
|
@@ -113,7 +113,7 @@ const createNativeStorage = async () => {
|
|
|
113
113
|
return asyncStorageInstance;
|
|
114
114
|
}
|
|
115
115
|
catch (error) {
|
|
116
|
-
if (
|
|
116
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
117
117
|
console.error('Failed to import AsyncStorage:', error);
|
|
118
118
|
}
|
|
119
119
|
throw new Error('AsyncStorage is required in React Native environment');
|