@oxyhq/services 5.17.7 → 5.17.9
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/lib/commonjs/crypto/index.js +0 -23
- package/lib/commonjs/crypto/index.js.map +1 -1
- package/lib/commonjs/index.js +0 -15
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/ui/components/Icon.js.map +1 -1
- package/lib/commonjs/ui/components/IconButton/utils.js.map +1 -1
- package/lib/commonjs/ui/components/TextField/Adornment/utils.js.map +1 -1
- package/lib/commonjs/ui/components/TextField/helpers.js.map +1 -1
- package/lib/commonjs/ui/components/TouchableRipple/utils.js.map +1 -1
- package/lib/commonjs/ui/components/Typography/AnimatedText.js.map +1 -1
- package/lib/commonjs/ui/context/OxyContext.js +37 -589
- package/lib/commonjs/ui/context/OxyContext.js.map +1 -1
- package/lib/commonjs/ui/context/OxyContextBase.js.map +1 -1
- package/lib/commonjs/ui/context/hooks/useAuthOperations.js +60 -425
- package/lib/commonjs/ui/context/hooks/useAuthOperations.js.map +1 -1
- package/lib/commonjs/ui/hooks/mutations/useAccountMutations.js +8 -112
- package/lib/commonjs/ui/hooks/mutations/useAccountMutations.js.map +1 -1
- package/lib/commonjs/ui/hooks/queries/useAccountQueries.js +2 -27
- package/lib/commonjs/ui/hooks/queries/useAccountQueries.js.map +1 -1
- package/lib/commonjs/ui/hooks/queries/useServicesQueries.js +2 -27
- package/lib/commonjs/ui/hooks/queries/useServicesQueries.js.map +1 -1
- package/lib/commonjs/ui/hooks/useSessionSocket.js +2 -88
- package/lib/commonjs/ui/hooks/useSessionSocket.js.map +1 -1
- package/lib/commonjs/ui/screens/OxyAuthScreen.js +0 -1
- package/lib/commonjs/ui/screens/OxyAuthScreen.js.map +1 -1
- package/lib/commonjs/ui/stores/authStore.js +52 -15
- package/lib/commonjs/ui/stores/authStore.js.map +1 -1
- package/lib/commonjs/ui/utils/avatarUtils.js +2 -32
- package/lib/commonjs/ui/utils/avatarUtils.js.map +1 -1
- package/lib/module/crypto/index.js +4 -6
- package/lib/module/crypto/index.js.map +1 -1
- package/lib/module/index.js +6 -3
- package/lib/module/index.js.map +1 -1
- package/lib/module/ui/components/Icon.js.map +1 -1
- package/lib/module/ui/components/IconButton/utils.js.map +1 -1
- package/lib/module/ui/components/TextField/Adornment/utils.js.map +1 -1
- package/lib/module/ui/components/TextField/helpers.js.map +1 -1
- package/lib/module/ui/components/TouchableRipple/utils.js.map +1 -1
- package/lib/module/ui/components/Typography/AnimatedText.js.map +1 -1
- package/lib/module/ui/context/OxyContext.js +35 -588
- package/lib/module/ui/context/OxyContext.js.map +1 -1
- package/lib/module/ui/context/OxyContextBase.js.map +1 -1
- package/lib/module/ui/context/hooks/useAuthOperations.js +60 -424
- package/lib/module/ui/context/hooks/useAuthOperations.js.map +1 -1
- package/lib/module/ui/hooks/mutations/useAccountMutations.js +8 -112
- package/lib/module/ui/hooks/mutations/useAccountMutations.js.map +1 -1
- package/lib/module/ui/hooks/queries/useAccountQueries.js +2 -27
- package/lib/module/ui/hooks/queries/useAccountQueries.js.map +1 -1
- package/lib/module/ui/hooks/queries/useServicesQueries.js +2 -27
- package/lib/module/ui/hooks/queries/useServicesQueries.js.map +1 -1
- package/lib/module/ui/hooks/useSessionSocket.js +2 -88
- package/lib/module/ui/hooks/useSessionSocket.js.map +1 -1
- package/lib/module/ui/screens/OxyAuthScreen.js +0 -1
- package/lib/module/ui/screens/OxyAuthScreen.js.map +1 -1
- package/lib/module/ui/stores/authStore.js +52 -15
- package/lib/module/ui/stores/authStore.js.map +1 -1
- package/lib/module/ui/utils/avatarUtils.js +2 -32
- package/lib/module/ui/utils/avatarUtils.js.map +1 -1
- package/lib/typescript/crypto/index.d.ts +2 -5
- package/lib/typescript/crypto/index.d.ts.map +1 -1
- package/lib/typescript/crypto/types.d.ts +6 -2
- package/lib/typescript/crypto/types.d.ts.map +1 -1
- package/lib/typescript/index.d.ts +4 -2
- package/lib/typescript/index.d.ts.map +1 -1
- package/lib/typescript/ui/components/IconButton/utils.d.ts +1 -1
- package/lib/typescript/ui/components/TextField/Adornment/utils.d.ts +1 -1
- package/lib/typescript/ui/components/TextField/Adornment/utils.d.ts.map +1 -1
- package/lib/typescript/ui/components/TextField/helpers.d.ts +6 -6
- package/lib/typescript/ui/components/types.d.ts +0 -4
- package/lib/typescript/ui/components/types.d.ts.map +1 -1
- package/lib/typescript/ui/context/OxyContext.d.ts.map +1 -1
- package/lib/typescript/ui/context/OxyContextBase.d.ts +2 -39
- package/lib/typescript/ui/context/OxyContextBase.d.ts.map +1 -1
- package/lib/typescript/ui/context/hooks/useAuthOperations.d.ts +10 -25
- package/lib/typescript/ui/context/hooks/useAuthOperations.d.ts.map +1 -1
- package/lib/typescript/ui/hooks/mutations/useAccountMutations.d.ts.map +1 -1
- package/lib/typescript/ui/hooks/queries/useAccountQueries.d.ts.map +1 -1
- package/lib/typescript/ui/hooks/queries/useServicesQueries.d.ts.map +1 -1
- package/lib/typescript/ui/hooks/useSessionSocket.d.ts +1 -14
- package/lib/typescript/ui/hooks/useSessionSocket.d.ts.map +1 -1
- package/lib/typescript/ui/stores/authStore.d.ts +27 -4
- package/lib/typescript/ui/stores/authStore.d.ts.map +1 -1
- package/lib/typescript/ui/utils/avatarUtils.d.ts +0 -2
- package/lib/typescript/ui/utils/avatarUtils.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/crypto/index.ts +3 -11
- package/src/crypto/types.ts +6 -2
- package/src/index.ts +6 -11
- package/src/ui/components/Icon.tsx +1 -1
- package/src/ui/components/IconButton/utils.ts +1 -1
- package/src/ui/components/TextField/Adornment/utils.ts +2 -2
- package/src/ui/components/TextField/helpers.tsx +8 -8
- package/src/ui/components/TouchableRipple/utils.ts +2 -2
- package/src/ui/components/Typography/AnimatedText.tsx +2 -2
- package/src/ui/components/types.tsx +0 -6
- package/src/ui/context/OxyContext.tsx +33 -637
- package/src/ui/context/OxyContextBase.tsx +5 -23
- package/src/ui/context/hooks/useAuthOperations.ts +84 -460
- package/src/ui/hooks/mutations/useAccountMutations.ts +12 -110
- package/src/ui/hooks/queries/useAccountQueries.ts +3 -27
- package/src/ui/hooks/queries/useServicesQueries.ts +3 -27
- package/src/ui/hooks/useSessionSocket.ts +2 -106
- package/src/ui/screens/OxyAuthScreen.tsx +1 -1
- package/src/ui/stores/authStore.ts +57 -18
- package/src/ui/utils/avatarUtils.ts +4 -36
- package/lib/commonjs/crypto/keyManager.js +0 -511
- package/lib/commonjs/crypto/keyManager.js.map +0 -1
- package/lib/commonjs/crypto/signatureService.js +0 -269
- package/lib/commonjs/crypto/signatureService.js.map +0 -1
- package/lib/module/crypto/keyManager.js +0 -508
- package/lib/module/crypto/keyManager.js.map +0 -1
- package/lib/module/crypto/signatureService.js +0 -266
- package/lib/module/crypto/signatureService.js.map +0 -1
- package/lib/typescript/crypto/keyManager.d.ts +0 -97
- package/lib/typescript/crypto/keyManager.d.ts.map +0 -1
- package/lib/typescript/crypto/signatureService.d.ts +0 -77
- package/lib/typescript/crypto/signatureService.d.ts.map +0 -1
- package/src/crypto/keyManager.ts +0 -545
- package/src/crypto/signatureService.ts +0 -301
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
4
|
-
import { Platform } from 'react-native';
|
|
5
4
|
import { OxyServices } from '../../core';
|
|
6
5
|
import { toast } from '../../lib/sonner';
|
|
7
6
|
import { useAuthStore } from '../stores/authStore';
|
|
@@ -18,7 +17,6 @@ import { showBottomSheet as globalShowBottomSheet } from '../navigation/bottomSh
|
|
|
18
17
|
import { useQueryClient, useQuery } from '@tanstack/react-query';
|
|
19
18
|
import { clearQueryCache } from '../hooks/queryClient';
|
|
20
19
|
import { queryKeys } from '../hooks/queries/queryKeys';
|
|
21
|
-
import { KeyManager } from '../../crypto';
|
|
22
20
|
import { translate } from '../../i18n';
|
|
23
21
|
import { updateAvatarVisibility, updateProfileWithAvatar } from '../utils/avatarUtils';
|
|
24
22
|
import { useAccountStore } from '../stores/accountStore';
|
|
@@ -56,30 +54,6 @@ const loadUseFollowHook = () => {
|
|
|
56
54
|
return cachedUseFollowHook;
|
|
57
55
|
}
|
|
58
56
|
};
|
|
59
|
-
|
|
60
|
-
// Shared storage key for identity cache - used by accounts app for instant routing
|
|
61
|
-
// Uses expo-secure-store for consistency with identity storage (KeyManager)
|
|
62
|
-
const IDENTITY_CACHE_KEY = 'oxy_identity_exists_cache';
|
|
63
|
-
|
|
64
|
-
// Helper to update identity cache in SecureStore
|
|
65
|
-
const updateIdentityCache = async exists => {
|
|
66
|
-
if (Platform.OS === 'web') return;
|
|
67
|
-
try {
|
|
68
|
-
const SecureStore = await import('expo-secure-store');
|
|
69
|
-
await SecureStore.setItemAsync(IDENTITY_CACHE_KEY, exists ? 'true' : 'false');
|
|
70
|
-
} catch {
|
|
71
|
-
// Silently fail - cache is just an optimization
|
|
72
|
-
}
|
|
73
|
-
};
|
|
74
|
-
const clearIdentityCache = async () => {
|
|
75
|
-
if (Platform.OS === 'web') return;
|
|
76
|
-
try {
|
|
77
|
-
const SecureStore = await import('expo-secure-store');
|
|
78
|
-
await SecureStore.deleteItemAsync(IDENTITY_CACHE_KEY);
|
|
79
|
-
} catch {
|
|
80
|
-
// Silently fail
|
|
81
|
-
}
|
|
82
|
-
};
|
|
83
57
|
export const OxyProvider = ({
|
|
84
58
|
children,
|
|
85
59
|
oxyServices: providedOxyServices,
|
|
@@ -103,28 +77,22 @@ export const OxyProvider = ({
|
|
|
103
77
|
const oxyServices = oxyServicesRef.current;
|
|
104
78
|
const {
|
|
105
79
|
isAuthenticated,
|
|
80
|
+
isOnline,
|
|
106
81
|
isLoading,
|
|
107
82
|
error,
|
|
83
|
+
setOnline,
|
|
108
84
|
loginSuccess,
|
|
109
85
|
loginFailure,
|
|
110
|
-
logoutStore
|
|
111
|
-
// Identity sync state and actions
|
|
112
|
-
isIdentitySyncedStore,
|
|
113
|
-
isSyncing,
|
|
114
|
-
setIdentitySynced,
|
|
115
|
-
setSyncing
|
|
86
|
+
logoutStore
|
|
116
87
|
} = useAuthStore(useShallow(state => ({
|
|
117
88
|
isAuthenticated: state.isAuthenticated,
|
|
89
|
+
isOnline: state.isOnline,
|
|
118
90
|
isLoading: state.isLoading,
|
|
119
91
|
error: state.error,
|
|
92
|
+
setOnline: state.setOnline,
|
|
120
93
|
loginSuccess: state.loginSuccess,
|
|
121
94
|
loginFailure: state.loginFailure,
|
|
122
|
-
logoutStore: state.logout
|
|
123
|
-
// Identity sync state and actions
|
|
124
|
-
isIdentitySyncedStore: state.isIdentitySynced,
|
|
125
|
-
isSyncing: state.isSyncing,
|
|
126
|
-
setIdentitySynced: state.setIdentitySynced,
|
|
127
|
-
setSyncing: state.setSyncing
|
|
95
|
+
logoutStore: state.logout
|
|
128
96
|
})));
|
|
129
97
|
const [tokenReady, setTokenReady] = useState(true);
|
|
130
98
|
const initializedRef = useRef(false);
|
|
@@ -146,49 +114,6 @@ export const OxyProvider = ({
|
|
|
146
114
|
onError,
|
|
147
115
|
logger
|
|
148
116
|
});
|
|
149
|
-
|
|
150
|
-
// Identity integrity check and auto-restore on startup
|
|
151
|
-
// Skip on web platform - identity storage is only available on native platforms
|
|
152
|
-
useEffect(() => {
|
|
153
|
-
if (!storage || !isStorageReady) return;
|
|
154
|
-
if (Platform.OS === 'web') return; // Identity operations are native-only
|
|
155
|
-
|
|
156
|
-
const checkAndRestoreIdentity = async () => {
|
|
157
|
-
try {
|
|
158
|
-
// Check if identity exists and verify integrity
|
|
159
|
-
const hasIdentity = await KeyManager.hasIdentity();
|
|
160
|
-
if (hasIdentity) {
|
|
161
|
-
const isValid = await KeyManager.verifyIdentityIntegrity();
|
|
162
|
-
if (!isValid) {
|
|
163
|
-
// Try to restore from backup
|
|
164
|
-
const restored = await KeyManager.restoreIdentityFromBackup();
|
|
165
|
-
if (__DEV__) {
|
|
166
|
-
logger(restored ? 'Identity restored from backup successfully' : 'Identity integrity check failed - user may need to restore from backup file');
|
|
167
|
-
}
|
|
168
|
-
} else {
|
|
169
|
-
// Identity is valid - ensure backup is up to date
|
|
170
|
-
await KeyManager.backupIdentity();
|
|
171
|
-
}
|
|
172
|
-
} else {
|
|
173
|
-
// No identity - try to restore from backup
|
|
174
|
-
const restored = await KeyManager.restoreIdentityFromBackup();
|
|
175
|
-
if (restored && __DEV__) {
|
|
176
|
-
logger('Identity restored from backup on startup');
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
} catch (error) {
|
|
180
|
-
if (__DEV__) {
|
|
181
|
-
logger('Error during identity integrity check', error);
|
|
182
|
-
}
|
|
183
|
-
// Don't block app startup - user can recover with backup file
|
|
184
|
-
}
|
|
185
|
-
};
|
|
186
|
-
checkAndRestoreIdentity();
|
|
187
|
-
}, [storage, isStorageReady, logger]);
|
|
188
|
-
|
|
189
|
-
// Offline queuing is now handled by TanStack Query mutations
|
|
190
|
-
// No need for custom offline queue
|
|
191
|
-
|
|
192
117
|
const {
|
|
193
118
|
currentLanguage,
|
|
194
119
|
metadata: currentLanguageMetadata,
|
|
@@ -253,15 +178,9 @@ export const OxyProvider = ({
|
|
|
253
178
|
});
|
|
254
179
|
const user = userData ?? null;
|
|
255
180
|
const {
|
|
256
|
-
|
|
257
|
-
importIdentity: importIdentityBase,
|
|
258
|
-
signIn,
|
|
181
|
+
completeSignIn,
|
|
259
182
|
logout,
|
|
260
|
-
logoutAll
|
|
261
|
-
hasIdentity,
|
|
262
|
-
getPublicKey,
|
|
263
|
-
isIdentitySynced,
|
|
264
|
-
syncIdentity: syncIdentityBase
|
|
183
|
+
logoutAll
|
|
265
184
|
} = useAuthOperations({
|
|
266
185
|
oxyServices,
|
|
267
186
|
storage,
|
|
@@ -279,41 +198,10 @@ export const OxyProvider = ({
|
|
|
279
198
|
loginFailure,
|
|
280
199
|
logoutStore,
|
|
281
200
|
setAuthState,
|
|
282
|
-
setIdentitySynced,
|
|
283
|
-
setSyncing,
|
|
284
201
|
logger
|
|
285
202
|
});
|
|
286
203
|
|
|
287
|
-
//
|
|
288
|
-
const syncIdentity = useCallback(() => syncIdentityBase(), [syncIdentityBase]);
|
|
289
|
-
|
|
290
|
-
// Wrapper for createIdentity to update identity cache
|
|
291
|
-
const wrappedCreateIdentity = useCallback(async () => {
|
|
292
|
-
const result = await createIdentity();
|
|
293
|
-
// Update cache for instant routing on next app launch
|
|
294
|
-
updateIdentityCache(true);
|
|
295
|
-
return result;
|
|
296
|
-
}, [createIdentity]);
|
|
297
|
-
|
|
298
|
-
// Wrapper for importIdentity to handle legacy calls and update cache
|
|
299
|
-
const importIdentity = useCallback(async (backupData, password) => {
|
|
300
|
-
// Handle legacy calls with single string argument (old recovery phrase signature)
|
|
301
|
-
if (typeof backupData === 'string') {
|
|
302
|
-
throw new Error('Recovery phrase import is no longer supported. Please use backup file import or QR code transfer instead.');
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
// Validate that password is provided
|
|
306
|
-
if (!password || typeof password !== 'string') {
|
|
307
|
-
throw new Error('Password is required for backup file import.');
|
|
308
|
-
}
|
|
309
|
-
const result = await importIdentityBase(backupData, password);
|
|
310
|
-
// Update cache for instant routing on next app launch
|
|
311
|
-
updateIdentityCache(true);
|
|
312
|
-
return result;
|
|
313
|
-
}, [importIdentityBase]);
|
|
314
|
-
|
|
315
|
-
// Clear all account data when identity is lost (for accounts app)
|
|
316
|
-
// In accounts app, identity = account, so losing identity means losing everything
|
|
204
|
+
// Clear all cached data and storage on logout
|
|
317
205
|
const clearAllAccountData = useCallback(async () => {
|
|
318
206
|
// Clear TanStack Query cache (in-memory)
|
|
319
207
|
queryClient.clear();
|
|
@@ -330,19 +218,6 @@ export const OxyProvider = ({
|
|
|
330
218
|
// Clear session state (sessions, activeSessionId, storage)
|
|
331
219
|
await clearSessionState();
|
|
332
220
|
|
|
333
|
-
// Clear identity sync state from storage
|
|
334
|
-
if (storage) {
|
|
335
|
-
try {
|
|
336
|
-
await storage.removeItem('oxy_identity_synced');
|
|
337
|
-
} catch (error) {
|
|
338
|
-
logger('Failed to clear identity sync state', error);
|
|
339
|
-
}
|
|
340
|
-
}
|
|
341
|
-
|
|
342
|
-
// Reset auth store identity sync state
|
|
343
|
-
useAuthStore.getState().setIdentitySynced(false);
|
|
344
|
-
useAuthStore.getState().setSyncing(false);
|
|
345
|
-
|
|
346
221
|
// Reset account store
|
|
347
222
|
useAccountStore.getState().reset();
|
|
348
223
|
|
|
@@ -350,165 +225,59 @@ export const OxyProvider = ({
|
|
|
350
225
|
oxyServices.clearCache();
|
|
351
226
|
}, [queryClient, storage, clearSessionState, logger, oxyServices]);
|
|
352
227
|
|
|
353
|
-
//
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
transferCodesRef.current.forEach((data, transferId) => {
|
|
357
|
-
if (data.state === 'pending') {
|
|
358
|
-
pending.push({
|
|
359
|
-
transferId,
|
|
360
|
-
data
|
|
361
|
-
});
|
|
362
|
-
}
|
|
363
|
-
});
|
|
364
|
-
return pending;
|
|
365
|
-
}, []);
|
|
366
|
-
const getActiveTransferId = useCallback(() => {
|
|
367
|
-
return activeTransferIdRef.current;
|
|
368
|
-
}, []);
|
|
369
|
-
|
|
370
|
-
// Delete identity and clear all account data
|
|
371
|
-
// In accounts app, deleting identity means losing the account completely
|
|
372
|
-
const deleteIdentityAndClearAccount = useCallback(async (skipBackup = false, force = false, userConfirmed = false) => {
|
|
373
|
-
// CRITICAL: Check for active transfers before deletion (unless force is true)
|
|
374
|
-
// This prevents accidental identity loss during transfer
|
|
375
|
-
if (!force) {
|
|
376
|
-
const pendingTransfers = getAllPendingTransfers();
|
|
377
|
-
if (pendingTransfers.length > 0) {
|
|
378
|
-
const activeTransferId = getActiveTransferId();
|
|
379
|
-
const hasActiveTransfer = activeTransferId && pendingTransfers.some(t => t.transferId === activeTransferId);
|
|
380
|
-
if (hasActiveTransfer) {
|
|
381
|
-
throw new Error('Cannot delete identity: An active identity transfer is in progress. ' + 'Please wait for the transfer to complete or cancel it first. ' + 'If you proceed, you may lose access to your identity permanently.');
|
|
382
|
-
}
|
|
383
|
-
}
|
|
384
|
-
}
|
|
385
|
-
|
|
386
|
-
// First, clear all account data
|
|
387
|
-
await clearAllAccountData();
|
|
388
|
-
|
|
389
|
-
// Then delete the identity keys
|
|
390
|
-
await KeyManager.deleteIdentity(skipBackup, force, userConfirmed);
|
|
391
|
-
|
|
392
|
-
// Clear identity cache for instant routing on next app launch
|
|
393
|
-
clearIdentityCache();
|
|
394
|
-
}, [clearAllAccountData, getAllPendingTransfers, getActiveTransferId]);
|
|
395
|
-
|
|
396
|
-
// Network reconnect sync - TanStack Query automatically retries mutations on reconnect
|
|
397
|
-
// We only need to sync identity if it's not synced
|
|
228
|
+
// Network state monitoring - updates authStore.isOnline
|
|
229
|
+
// When offline: isAuthenticated becomes false automatically
|
|
230
|
+
// When reconnect: isOnline set to true, allowing re-authentication
|
|
398
231
|
useEffect(() => {
|
|
399
232
|
if (!storage) return;
|
|
400
233
|
let wasOffline = false;
|
|
401
234
|
let checkTimeout = null;
|
|
402
|
-
let lastReconnectionLog = 0;
|
|
403
|
-
const RECONNECTION_LOG_DEBOUNCE_MS = 5000; // 5 seconds
|
|
404
|
-
|
|
405
|
-
// Circuit breaker and exponential backoff state
|
|
406
|
-
const stateRef = {
|
|
407
|
-
consecutiveFailures: 0,
|
|
408
|
-
currentInterval: 10000,
|
|
409
|
-
// Start with 10 seconds
|
|
410
|
-
baseInterval: 10000,
|
|
411
|
-
// Base interval in milliseconds
|
|
412
|
-
maxInterval: 60000,
|
|
413
|
-
// Maximum interval (60 seconds)
|
|
414
|
-
maxFailures: 5 // Circuit breaker threshold
|
|
415
|
-
};
|
|
416
235
|
const scheduleNextCheck = () => {
|
|
417
236
|
if (checkTimeout) {
|
|
418
237
|
clearTimeout(checkTimeout);
|
|
419
238
|
}
|
|
420
239
|
checkTimeout = setTimeout(() => {
|
|
421
|
-
|
|
422
|
-
},
|
|
240
|
+
checkNetworkStatus();
|
|
241
|
+
}, 30000); // Check every 30 seconds
|
|
423
242
|
};
|
|
424
|
-
const
|
|
243
|
+
const checkNetworkStatus = async () => {
|
|
425
244
|
try {
|
|
426
245
|
// Try a lightweight health check to see if we're online
|
|
427
|
-
await oxyServices.healthCheck()
|
|
428
|
-
wasOffline = true;
|
|
429
|
-
throw new Error('Health check failed');
|
|
430
|
-
});
|
|
431
|
-
|
|
432
|
-
// Health check succeeded - reset circuit breaker and backoff
|
|
433
|
-
if (stateRef.consecutiveFailures > 0) {
|
|
434
|
-
stateRef.consecutiveFailures = 0;
|
|
435
|
-
stateRef.currentInterval = stateRef.baseInterval;
|
|
436
|
-
}
|
|
246
|
+
await oxyServices.healthCheck();
|
|
437
247
|
|
|
438
|
-
// If we were offline and now we're online
|
|
248
|
+
// If we were offline and now we're online
|
|
439
249
|
if (wasOffline) {
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
if (timeSinceLastLog >= RECONNECTION_LOG_DEBOUNCE_MS) {
|
|
443
|
-
logger('Network reconnected, checking identity sync...');
|
|
444
|
-
lastReconnectionLog = now;
|
|
445
|
-
|
|
446
|
-
// Sync identity first (if not synced)
|
|
447
|
-
try {
|
|
448
|
-
const hasIdentityValue = await hasIdentity();
|
|
449
|
-
if (hasIdentityValue) {
|
|
450
|
-
// Check sync status directly - sync if not explicitly 'true'
|
|
451
|
-
// undefined = not synced yet, 'false' = explicitly not synced, 'true' = synced
|
|
452
|
-
const syncStatus = await storage.getItem('oxy_identity_synced');
|
|
453
|
-
if (syncStatus !== 'true') {
|
|
454
|
-
await syncIdentity();
|
|
455
|
-
}
|
|
456
|
-
}
|
|
457
|
-
} catch (syncError) {
|
|
458
|
-
// Skip sync silently if username is required (expected when offline onboarding)
|
|
459
|
-
if (syncError?.code === 'USERNAME_REQUIRED' || syncError?.message === 'USERNAME_REQUIRED') {
|
|
460
|
-
if (__DEV__) {
|
|
461
|
-
loggerUtil.debug('Sync skipped - username required', {
|
|
462
|
-
component: 'OxyContext',
|
|
463
|
-
method: 'checkNetworkAndSync'
|
|
464
|
-
}, syncError);
|
|
465
|
-
}
|
|
466
|
-
// Don't log or show error - username will be set later
|
|
467
|
-
} else if (!isTimeoutOrNetworkError(syncError)) {
|
|
468
|
-
// Only log unexpected errors - timeouts/network issues are expected when offline
|
|
469
|
-
logger('Error syncing identity on reconnect', syncError);
|
|
470
|
-
} else if (__DEV__) {
|
|
471
|
-
loggerUtil.debug('Identity sync timeout (expected when offline)', {
|
|
472
|
-
component: 'OxyContext',
|
|
473
|
-
method: 'checkNetworkAndSync'
|
|
474
|
-
}, syncError);
|
|
475
|
-
}
|
|
476
|
-
}
|
|
477
|
-
}
|
|
478
|
-
|
|
250
|
+
logger('Network reconnected - setting online state');
|
|
251
|
+
setOnline(true);
|
|
479
252
|
// TanStack Query will automatically retry pending mutations
|
|
480
|
-
//
|
|
253
|
+
// Session management will handle token refresh if needed
|
|
481
254
|
wasOffline = false;
|
|
255
|
+
} else {
|
|
256
|
+
// We're online and were already online
|
|
257
|
+
setOnline(true);
|
|
482
258
|
}
|
|
483
259
|
} catch (error) {
|
|
484
260
|
// Network check failed - we're offline
|
|
485
|
-
wasOffline
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
// Calculate new interval with exponential backoff, capped at maxInterval
|
|
491
|
-
const backoffMultiplier = Math.min(Math.pow(2, stateRef.consecutiveFailures - 1), stateRef.maxInterval / stateRef.baseInterval);
|
|
492
|
-
stateRef.currentInterval = Math.min(stateRef.baseInterval * backoffMultiplier, stateRef.maxInterval);
|
|
493
|
-
|
|
494
|
-
// If we hit the circuit breaker threshold, use max interval
|
|
495
|
-
if (stateRef.consecutiveFailures >= stateRef.maxFailures) {
|
|
496
|
-
stateRef.currentInterval = stateRef.maxInterval;
|
|
261
|
+
if (!wasOffline) {
|
|
262
|
+
if (__DEV__) {
|
|
263
|
+
logger('Network appears offline - suspending authentication');
|
|
264
|
+
}
|
|
265
|
+
setOnline(false); // This will set isAuthenticated to false
|
|
497
266
|
}
|
|
267
|
+
wasOffline = true;
|
|
498
268
|
} finally {
|
|
499
|
-
// Always schedule next check (will use updated interval)
|
|
500
269
|
scheduleNextCheck();
|
|
501
270
|
}
|
|
502
271
|
};
|
|
503
272
|
|
|
504
273
|
// Check immediately
|
|
505
|
-
|
|
274
|
+
checkNetworkStatus();
|
|
506
275
|
return () => {
|
|
507
276
|
if (checkTimeout) {
|
|
508
277
|
clearTimeout(checkTimeout);
|
|
509
278
|
}
|
|
510
279
|
};
|
|
511
|
-
}, [oxyServices, storage,
|
|
280
|
+
}, [oxyServices, storage, logger, setOnline]);
|
|
512
281
|
const {
|
|
513
282
|
getDeviceSessions,
|
|
514
283
|
logoutAllDeviceSessions,
|
|
@@ -617,171 +386,6 @@ export const OxyProvider = ({
|
|
|
617
386
|
|
|
618
387
|
// Get userId from JWT token (MongoDB ObjectId) for socket room matching
|
|
619
388
|
const userId = oxyServices.getCurrentUserId();
|
|
620
|
-
|
|
621
|
-
// Transfer code storage interface
|
|
622
|
-
|
|
623
|
-
// Store transfer codes in memory for verification (also persisted to storage)
|
|
624
|
-
// Map: transferId -> TransferCodeData
|
|
625
|
-
const transferCodesRef = useRef(new Map());
|
|
626
|
-
const activeTransferIdRef = useRef(null);
|
|
627
|
-
const TRANSFER_CODES_STORAGE_KEY = `${storageKeyPrefix}_transfer_codes`;
|
|
628
|
-
const ACTIVE_TRANSFER_STORAGE_KEY = `${storageKeyPrefix}_active_transfer_id`;
|
|
629
|
-
|
|
630
|
-
// Clear stale transfer codes on startup
|
|
631
|
-
// Transfers are ephemeral and should not persist across app restarts
|
|
632
|
-
useEffect(() => {
|
|
633
|
-
if (!storage || !isStorageReady) return;
|
|
634
|
-
const clearStaleTransfers = async () => {
|
|
635
|
-
try {
|
|
636
|
-
// Clear any stored transfer codes - they're only valid during active transfer sessions
|
|
637
|
-
await storage.removeItem(TRANSFER_CODES_STORAGE_KEY);
|
|
638
|
-
await storage.removeItem(ACTIVE_TRANSFER_STORAGE_KEY);
|
|
639
|
-
if (__DEV__) {
|
|
640
|
-
logger('Cleared stale transfer codes on startup');
|
|
641
|
-
}
|
|
642
|
-
} catch (error) {
|
|
643
|
-
if (__DEV__) {
|
|
644
|
-
logger('Failed to clear stale transfer codes', error);
|
|
645
|
-
}
|
|
646
|
-
}
|
|
647
|
-
};
|
|
648
|
-
clearStaleTransfers();
|
|
649
|
-
}, [storage, isStorageReady, logger, storageKeyPrefix]);
|
|
650
|
-
|
|
651
|
-
// Persist transfer codes to storage whenever they change
|
|
652
|
-
const persistTransferCodes = useCallback(async () => {
|
|
653
|
-
if (!storage) return;
|
|
654
|
-
try {
|
|
655
|
-
const codesToStore = {};
|
|
656
|
-
transferCodesRef.current.forEach((value, key) => {
|
|
657
|
-
codesToStore[key] = value;
|
|
658
|
-
});
|
|
659
|
-
await storage.setItem(TRANSFER_CODES_STORAGE_KEY, JSON.stringify(codesToStore));
|
|
660
|
-
} catch (error) {
|
|
661
|
-
if (__DEV__) {
|
|
662
|
-
logger('Failed to persist transfer codes', error);
|
|
663
|
-
}
|
|
664
|
-
}
|
|
665
|
-
}, [storage, logger]);
|
|
666
|
-
|
|
667
|
-
// Cleanup old transfer codes (older than 15 minutes)
|
|
668
|
-
useEffect(() => {
|
|
669
|
-
const cleanup = setInterval(async () => {
|
|
670
|
-
const now = Date.now();
|
|
671
|
-
const fifteenMinutes = 15 * 60 * 1000;
|
|
672
|
-
let needsPersist = false;
|
|
673
|
-
transferCodesRef.current.forEach((value, key) => {
|
|
674
|
-
if (now - value.timestamp > fifteenMinutes) {
|
|
675
|
-
transferCodesRef.current.delete(key);
|
|
676
|
-
needsPersist = true;
|
|
677
|
-
if (__DEV__) {
|
|
678
|
-
logger('Cleaned up expired transfer code', {
|
|
679
|
-
transferId: key
|
|
680
|
-
});
|
|
681
|
-
}
|
|
682
|
-
}
|
|
683
|
-
});
|
|
684
|
-
|
|
685
|
-
// Clear active transfer if it was deleted
|
|
686
|
-
if (activeTransferIdRef.current && !transferCodesRef.current.has(activeTransferIdRef.current)) {
|
|
687
|
-
activeTransferIdRef.current = null;
|
|
688
|
-
if (storage) {
|
|
689
|
-
try {
|
|
690
|
-
await storage.removeItem(ACTIVE_TRANSFER_STORAGE_KEY);
|
|
691
|
-
} catch (error) {
|
|
692
|
-
// Ignore storage errors
|
|
693
|
-
}
|
|
694
|
-
}
|
|
695
|
-
}
|
|
696
|
-
if (needsPersist) {
|
|
697
|
-
await persistTransferCodes();
|
|
698
|
-
}
|
|
699
|
-
}, 60000); // Check every minute
|
|
700
|
-
|
|
701
|
-
return () => clearInterval(cleanup);
|
|
702
|
-
}, [logger, persistTransferCodes, storage]);
|
|
703
|
-
|
|
704
|
-
// Transfer code management functions
|
|
705
|
-
const storeTransferCode = useCallback(async (transferId, code, sourceDeviceId, publicKey) => {
|
|
706
|
-
const transferData = {
|
|
707
|
-
code,
|
|
708
|
-
sourceDeviceId,
|
|
709
|
-
publicKey,
|
|
710
|
-
timestamp: Date.now(),
|
|
711
|
-
state: 'pending'
|
|
712
|
-
};
|
|
713
|
-
transferCodesRef.current.set(transferId, transferData);
|
|
714
|
-
activeTransferIdRef.current = transferId;
|
|
715
|
-
|
|
716
|
-
// Persist to storage
|
|
717
|
-
await persistTransferCodes();
|
|
718
|
-
if (storage) {
|
|
719
|
-
try {
|
|
720
|
-
await storage.setItem(ACTIVE_TRANSFER_STORAGE_KEY, transferId);
|
|
721
|
-
} catch (error) {
|
|
722
|
-
if (__DEV__) {
|
|
723
|
-
logger('Failed to persist active transfer ID', error);
|
|
724
|
-
}
|
|
725
|
-
}
|
|
726
|
-
}
|
|
727
|
-
if (__DEV__) {
|
|
728
|
-
logger('Stored transfer code', {
|
|
729
|
-
transferId,
|
|
730
|
-
sourceDeviceId,
|
|
731
|
-
publicKey: publicKey.substring(0, 16) + '...'
|
|
732
|
-
});
|
|
733
|
-
}
|
|
734
|
-
}, [logger, persistTransferCodes, storage]);
|
|
735
|
-
const getTransferCode = useCallback(transferId => {
|
|
736
|
-
return transferCodesRef.current.get(transferId) || null;
|
|
737
|
-
}, []);
|
|
738
|
-
const updateTransferState = useCallback(async (transferId, state) => {
|
|
739
|
-
const transferData = transferCodesRef.current.get(transferId);
|
|
740
|
-
if (transferData) {
|
|
741
|
-
transferData.state = state;
|
|
742
|
-
transferCodesRef.current.set(transferId, transferData);
|
|
743
|
-
|
|
744
|
-
// Clear active transfer if completed or failed
|
|
745
|
-
if (state === 'completed' || state === 'failed') {
|
|
746
|
-
if (activeTransferIdRef.current === transferId) {
|
|
747
|
-
activeTransferIdRef.current = null;
|
|
748
|
-
if (storage) {
|
|
749
|
-
try {
|
|
750
|
-
await storage.removeItem(ACTIVE_TRANSFER_STORAGE_KEY);
|
|
751
|
-
} catch (error) {
|
|
752
|
-
// Ignore storage errors
|
|
753
|
-
}
|
|
754
|
-
}
|
|
755
|
-
}
|
|
756
|
-
}
|
|
757
|
-
await persistTransferCodes();
|
|
758
|
-
if (__DEV__) {
|
|
759
|
-
logger('Updated transfer state', {
|
|
760
|
-
transferId,
|
|
761
|
-
state
|
|
762
|
-
});
|
|
763
|
-
}
|
|
764
|
-
}
|
|
765
|
-
}, [logger, persistTransferCodes, storage]);
|
|
766
|
-
const clearTransferCode = useCallback(async transferId => {
|
|
767
|
-
transferCodesRef.current.delete(transferId);
|
|
768
|
-
if (activeTransferIdRef.current === transferId) {
|
|
769
|
-
activeTransferIdRef.current = null;
|
|
770
|
-
if (storage) {
|
|
771
|
-
try {
|
|
772
|
-
await storage.removeItem(ACTIVE_TRANSFER_STORAGE_KEY);
|
|
773
|
-
} catch (error) {
|
|
774
|
-
// Ignore storage errors
|
|
775
|
-
}
|
|
776
|
-
}
|
|
777
|
-
}
|
|
778
|
-
await persistTransferCodes();
|
|
779
|
-
if (__DEV__) {
|
|
780
|
-
logger('Cleared transfer code', {
|
|
781
|
-
transferId
|
|
782
|
-
});
|
|
783
|
-
}
|
|
784
|
-
}, [logger, persistTransferCodes, storage]);
|
|
785
389
|
const refreshSessionsWithUser = useCallback(() => refreshSessions(userId || undefined), [refreshSessions, userId]);
|
|
786
390
|
const handleSessionRemoved = useCallback(sessionId => {
|
|
787
391
|
trackRemovedSession(sessionId);
|
|
@@ -790,143 +394,6 @@ export const OxyProvider = ({
|
|
|
790
394
|
toast.info('You have been signed out remotely.');
|
|
791
395
|
logout().catch(remoteError => logger('Failed to process remote sign out', remoteError));
|
|
792
396
|
}, [logger, logout]);
|
|
793
|
-
const handleIdentityTransferComplete = useCallback(async data => {
|
|
794
|
-
try {
|
|
795
|
-
logger('Received identity transfer complete notification', {
|
|
796
|
-
transferId: data.transferId,
|
|
797
|
-
sourceDeviceId: data.sourceDeviceId,
|
|
798
|
-
currentDeviceId,
|
|
799
|
-
hasActiveSession: activeSessionId !== null,
|
|
800
|
-
publicKey: data.publicKey.substring(0, 16) + '...'
|
|
801
|
-
});
|
|
802
|
-
const storedTransfer = getTransferCode(data.transferId);
|
|
803
|
-
if (!storedTransfer) {
|
|
804
|
-
logger('Transfer code not found for transferId', {
|
|
805
|
-
transferId: data.transferId
|
|
806
|
-
});
|
|
807
|
-
toast.error('Transfer verification failed: Code not found. Identity will not be deleted.');
|
|
808
|
-
return;
|
|
809
|
-
}
|
|
810
|
-
|
|
811
|
-
// Verify publicKey matches first (most important check)
|
|
812
|
-
const publicKeyMatches = data.publicKey === storedTransfer.publicKey;
|
|
813
|
-
if (!publicKeyMatches) {
|
|
814
|
-
logger('Public key mismatch for transfer', {
|
|
815
|
-
transferId: data.transferId,
|
|
816
|
-
receivedPublicKey: data.publicKey.substring(0, 16) + '...',
|
|
817
|
-
storedPublicKey: storedTransfer.publicKey.substring(0, 16) + '...'
|
|
818
|
-
});
|
|
819
|
-
toast.error('Transfer verification failed: Public key mismatch. Identity will not be deleted.');
|
|
820
|
-
return;
|
|
821
|
-
}
|
|
822
|
-
|
|
823
|
-
// Verify deviceId matches - very lenient since publicKey is the critical check
|
|
824
|
-
// If publicKey matches, we allow deletion even if deviceId doesn't match exactly
|
|
825
|
-
// This handles cases where deviceId might not be available or slightly different
|
|
826
|
-
const deviceIdMatches =
|
|
827
|
-
// Exact match
|
|
828
|
-
data.sourceDeviceId && data.sourceDeviceId === currentDeviceId ||
|
|
829
|
-
// Stored sourceDeviceId matches current deviceId
|
|
830
|
-
storedTransfer.sourceDeviceId && storedTransfer.sourceDeviceId === currentDeviceId;
|
|
831
|
-
|
|
832
|
-
// If publicKey matches, we're very lenient with deviceId - only warn but don't block
|
|
833
|
-
if (!deviceIdMatches && publicKeyMatches) {
|
|
834
|
-
logger('Device ID mismatch for transfer, but publicKey matches - proceeding with deletion', {
|
|
835
|
-
transferId: data.transferId,
|
|
836
|
-
receivedDeviceId: data.sourceDeviceId,
|
|
837
|
-
storedDeviceId: storedTransfer.sourceDeviceId,
|
|
838
|
-
currentDeviceId,
|
|
839
|
-
hasActiveSession: activeSessionId !== null
|
|
840
|
-
});
|
|
841
|
-
// Proceed with deletion - publicKey match is the critical verification
|
|
842
|
-
} else if (!deviceIdMatches && !publicKeyMatches) {
|
|
843
|
-
// Both don't match - this is suspicious, block deletion
|
|
844
|
-
logger('Device ID and publicKey mismatch for transfer', {
|
|
845
|
-
transferId: data.transferId,
|
|
846
|
-
receivedDeviceId: data.sourceDeviceId,
|
|
847
|
-
currentDeviceId
|
|
848
|
-
});
|
|
849
|
-
toast.error('Transfer verification failed: Device and key mismatch. Identity will not be deleted.');
|
|
850
|
-
return;
|
|
851
|
-
}
|
|
852
|
-
|
|
853
|
-
// Verify transfer code matches (if provided)
|
|
854
|
-
// Transfer code is optional - if not provided, we still proceed if publicKey matches
|
|
855
|
-
if (data.transferCode) {
|
|
856
|
-
const codeMatches = data.transferCode.toUpperCase() === storedTransfer.code.toUpperCase();
|
|
857
|
-
if (!codeMatches) {
|
|
858
|
-
logger('Transfer code mismatch, but publicKey matches - proceeding with deletion', {
|
|
859
|
-
transferId: data.transferId,
|
|
860
|
-
receivedCode: data.transferCode,
|
|
861
|
-
storedCode: storedTransfer.code.substring(0, 2) + '****'
|
|
862
|
-
});
|
|
863
|
-
// Don't block - publicKey match is sufficient, code mismatch might be due to user error
|
|
864
|
-
// Log warning but proceed
|
|
865
|
-
}
|
|
866
|
-
}
|
|
867
|
-
|
|
868
|
-
// Check if transfer is too old (safety timeout - 10 minutes)
|
|
869
|
-
const transferAge = Date.now() - storedTransfer.timestamp;
|
|
870
|
-
const tenMinutes = 10 * 60 * 1000;
|
|
871
|
-
if (transferAge > tenMinutes) {
|
|
872
|
-
logger('Transfer confirmation received too late', {
|
|
873
|
-
transferId: data.transferId,
|
|
874
|
-
age: transferAge,
|
|
875
|
-
ageMinutes: Math.round(transferAge / 60000)
|
|
876
|
-
});
|
|
877
|
-
toast.error('Transfer verification failed: Confirmation received too late. Identity will not be deleted.');
|
|
878
|
-
clearTransferCode(data.transferId);
|
|
879
|
-
return;
|
|
880
|
-
}
|
|
881
|
-
|
|
882
|
-
// NOTE: Target device verification already happened server-side when notifyTransferComplete was called
|
|
883
|
-
// The server verified that the target device is authenticated and has the matching public key
|
|
884
|
-
// Additional client-side verification is not necessary and would require source device authentication
|
|
885
|
-
// which may not be available. The existing checks (public key match, transfer code, device ID) are sufficient.
|
|
886
|
-
|
|
887
|
-
logger('All transfer verifications passed, deleting identity from source device', {
|
|
888
|
-
transferId: data.transferId,
|
|
889
|
-
sourceDeviceId: data.sourceDeviceId,
|
|
890
|
-
publicKey: data.publicKey.substring(0, 16) + '...'
|
|
891
|
-
});
|
|
892
|
-
try {
|
|
893
|
-
// Verify identity still exists before deletion (safety check)
|
|
894
|
-
const identityStillExists = await KeyManager.hasIdentity();
|
|
895
|
-
if (!identityStillExists) {
|
|
896
|
-
logger('Identity already deleted - skipping deletion', {
|
|
897
|
-
transferId: data.transferId
|
|
898
|
-
});
|
|
899
|
-
await updateTransferState(data.transferId, 'completed');
|
|
900
|
-
await clearTransferCode(data.transferId);
|
|
901
|
-
return;
|
|
902
|
-
}
|
|
903
|
-
await deleteIdentityAndClearAccount(false, false, true);
|
|
904
|
-
|
|
905
|
-
// Verify identity was actually deleted
|
|
906
|
-
const identityDeleted = !(await KeyManager.hasIdentity());
|
|
907
|
-
if (!identityDeleted) {
|
|
908
|
-
logger('Identity deletion failed - identity still exists', {
|
|
909
|
-
transferId: data.transferId
|
|
910
|
-
});
|
|
911
|
-
await updateTransferState(data.transferId, 'failed');
|
|
912
|
-
throw new Error('Identity deletion failed - identity still exists');
|
|
913
|
-
}
|
|
914
|
-
await updateTransferState(data.transferId, 'completed');
|
|
915
|
-
await clearTransferCode(data.transferId);
|
|
916
|
-
logger('Identity successfully deleted and transfer code cleared', {
|
|
917
|
-
transferId: data.transferId
|
|
918
|
-
});
|
|
919
|
-
toast.success('Identity successfully transferred and removed from this device');
|
|
920
|
-
} catch (deleteError) {
|
|
921
|
-
logger('Error during identity deletion', deleteError);
|
|
922
|
-
await updateTransferState(data.transferId, 'failed');
|
|
923
|
-
throw deleteError;
|
|
924
|
-
}
|
|
925
|
-
} catch (error) {
|
|
926
|
-
logger('Failed to delete identity after transfer', error);
|
|
927
|
-
toast.error(error?.message || 'Failed to remove identity from this device. Please try again manually from Security Settings.');
|
|
928
|
-
}
|
|
929
|
-
}, [deleteIdentityAndClearAccount, logger, getTransferCode, clearTransferCode, updateTransferState, currentDeviceId, activeSessionId, oxyServices]);
|
|
930
397
|
useSessionSocket({
|
|
931
398
|
userId,
|
|
932
399
|
activeSessionId,
|
|
@@ -936,10 +403,8 @@ export const OxyProvider = ({
|
|
|
936
403
|
clearSessionState,
|
|
937
404
|
baseURL: oxyServices.getBaseURL(),
|
|
938
405
|
getAccessToken: () => oxyServices.getAccessToken(),
|
|
939
|
-
getTransferCode: getTransferCode,
|
|
940
406
|
onRemoteSignOut: handleRemoteSignOut,
|
|
941
|
-
onSessionRemoved: handleSessionRemoved
|
|
942
|
-
onIdentityTransferComplete: handleIdentityTransferComplete
|
|
407
|
+
onSessionRemoved: handleSessionRemoved
|
|
943
408
|
});
|
|
944
409
|
const switchSessionForContext = useCallback(async sessionId => {
|
|
945
410
|
await switchSession(sessionId);
|
|
@@ -973,7 +438,6 @@ export const OxyProvider = ({
|
|
|
973
438
|
await updateProfileWithAvatar({
|
|
974
439
|
avatar: file.id
|
|
975
440
|
}, oxyServices, activeSessionId, queryClient, {
|
|
976
|
-
syncIdentity,
|
|
977
441
|
deviceId: currentDeviceId || undefined
|
|
978
442
|
});
|
|
979
443
|
toast.success(translate(currentLanguage, 'editProfile.toasts.avatarUpdated') || 'Avatar updated');
|
|
@@ -983,7 +447,7 @@ export const OxyProvider = ({
|
|
|
983
447
|
}
|
|
984
448
|
}
|
|
985
449
|
});
|
|
986
|
-
}, [oxyServices, currentLanguage, showBottomSheetForContext, activeSessionId, queryClient
|
|
450
|
+
}, [oxyServices, currentLanguage, showBottomSheetForContext, activeSessionId, queryClient]);
|
|
987
451
|
const contextValue = useMemo(() => ({
|
|
988
452
|
user,
|
|
989
453
|
sessions,
|
|
@@ -998,24 +462,7 @@ export const OxyProvider = ({
|
|
|
998
462
|
currentLanguageMetadata,
|
|
999
463
|
currentLanguageName,
|
|
1000
464
|
currentNativeLanguageName,
|
|
1001
|
-
|
|
1002
|
-
importIdentity,
|
|
1003
|
-
signIn,
|
|
1004
|
-
hasIdentity,
|
|
1005
|
-
getPublicKey,
|
|
1006
|
-
isIdentitySynced,
|
|
1007
|
-
syncIdentity,
|
|
1008
|
-
deleteIdentityAndClearAccount,
|
|
1009
|
-
storeTransferCode,
|
|
1010
|
-
getTransferCode,
|
|
1011
|
-
clearTransferCode,
|
|
1012
|
-
getAllPendingTransfers,
|
|
1013
|
-
getActiveTransferId,
|
|
1014
|
-
updateTransferState,
|
|
1015
|
-
identitySyncState: {
|
|
1016
|
-
isSynced: isIdentitySyncedStore ?? true,
|
|
1017
|
-
isSyncing: isSyncing ?? false
|
|
1018
|
-
},
|
|
465
|
+
completeSignIn,
|
|
1019
466
|
logout,
|
|
1020
467
|
logoutAll,
|
|
1021
468
|
switchSession: switchSessionForContext,
|
|
@@ -1031,7 +478,7 @@ export const OxyProvider = ({
|
|
|
1031
478
|
useFollow: useFollowHook,
|
|
1032
479
|
showBottomSheet: showBottomSheetForContext,
|
|
1033
480
|
openAvatarPicker
|
|
1034
|
-
}), [activeSessionId, currentDeviceId,
|
|
481
|
+
}), [activeSessionId, currentDeviceId, completeSignIn, currentLanguage, currentLanguageMetadata, currentLanguageName, currentNativeLanguageName, error, getDeviceSessions, isAuthenticated, isLoading, logout, logoutAll, logoutAllDeviceSessions, oxyServices, refreshSessionsWithUser, sessions, setLanguage, switchSessionForContext, tokenReady, isStorageReady, updateDeviceName, clearAllAccountData, useFollowHook, user, showBottomSheetForContext, openAvatarPicker]);
|
|
1035
482
|
return /*#__PURE__*/_jsx(OxyContext.Provider, {
|
|
1036
483
|
value: contextValue,
|
|
1037
484
|
children: children
|