@oxyhq/services 5.16.17 → 5.16.19
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/README.md +7 -8
- package/lib/commonjs/core/mixins/OxyServices.security.js +42 -0
- package/lib/commonjs/core/mixins/OxyServices.security.js.map +1 -1
- package/lib/commonjs/crypto/index.js +0 -7
- package/lib/commonjs/crypto/index.js.map +1 -1
- package/lib/commonjs/crypto/keyManager.js +2 -2
- package/lib/commonjs/crypto/polyfill.js +4 -4
- package/lib/commonjs/i18n/locales/en-US.json +1 -1
- package/lib/commonjs/index.js +0 -7
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/models/interfaces.js +2 -0
- package/lib/commonjs/models/interfaces.js.map +1 -1
- package/lib/commonjs/ui/components/FollowButton.js +19 -1
- package/lib/commonjs/ui/components/FollowButton.js.map +1 -1
- package/lib/commonjs/ui/components/GroupedItem.js +1 -27
- package/lib/commonjs/ui/components/GroupedItem.js.map +1 -1
- package/lib/commonjs/ui/components/Section.js +2 -1
- package/lib/commonjs/ui/components/Section.js.map +1 -1
- package/lib/commonjs/ui/components/SectionTitle.js +1 -2
- package/lib/commonjs/ui/components/SectionTitle.js.map +1 -1
- package/lib/commonjs/ui/components/fileManagement/FileViewer.js +3 -3
- package/lib/commonjs/ui/components/fileManagement/FileViewer.js.map +1 -1
- package/lib/commonjs/ui/context/OxyContext.js +61 -9
- package/lib/commonjs/ui/context/OxyContext.js.map +1 -1
- package/lib/commonjs/ui/context/hooks/useAuthOperations.js +65 -17
- package/lib/commonjs/ui/context/hooks/useAuthOperations.js.map +1 -1
- package/lib/commonjs/ui/context/hooks/useDeviceManagement.js +1 -1
- package/lib/commonjs/ui/context/hooks/useLanguageManagement.js +1 -1
- package/lib/commonjs/ui/context/hooks/useSessionManagement.js +3 -3
- package/lib/commonjs/ui/context/hooks/useStorage.js +2 -2
- package/lib/commonjs/ui/hooks/queries/useAccountQueries.js +1 -1
- package/lib/commonjs/ui/hooks/queries/useAccountQueries.js.map +1 -1
- package/lib/commonjs/ui/hooks/queries/useServicesQueries.js +1 -1
- package/lib/commonjs/ui/hooks/useIdentityMutations.js +4 -4
- package/lib/commonjs/ui/hooks/useIdentityMutations.js.map +1 -1
- package/lib/commonjs/ui/hooks/useSessionSocket.js +22 -7
- package/lib/commonjs/ui/hooks/useSessionSocket.js.map +1 -1
- package/lib/commonjs/ui/screens/AccountCenterScreen.js +13 -13
- package/lib/commonjs/ui/screens/AccountCenterScreen.js.map +1 -1
- package/lib/commonjs/ui/screens/AccountOverviewScreen.js +17 -17
- package/lib/commonjs/ui/screens/AccountOverviewScreen.js.map +1 -1
- package/lib/commonjs/ui/screens/AccountSettingsScreen.js +2 -2
- package/lib/commonjs/ui/screens/AccountSettingsScreen.js.map +1 -1
- package/lib/commonjs/ui/screens/AccountSwitcherScreen.js +10 -9
- package/lib/commonjs/ui/screens/AccountSwitcherScreen.js.map +1 -1
- package/lib/commonjs/ui/screens/AppInfoScreen.js +15 -15
- package/lib/commonjs/ui/screens/AppInfoScreen.js.map +1 -1
- package/lib/commonjs/ui/screens/FeedbackScreen.js +1 -1
- package/lib/commonjs/ui/screens/FeedbackScreen.js.map +1 -1
- package/lib/commonjs/ui/screens/FileManagementScreen.js +1 -1
- package/lib/commonjs/ui/screens/HelpSupportScreen.js +3 -3
- package/lib/commonjs/ui/screens/HelpSupportScreen.js.map +1 -1
- package/lib/commonjs/ui/screens/HistoryViewScreen.js +2 -2
- package/lib/commonjs/ui/screens/HistoryViewScreen.js.map +1 -1
- package/lib/commonjs/ui/screens/LanguageSelectorScreen.js +3 -1
- package/lib/commonjs/ui/screens/LanguageSelectorScreen.js.map +1 -1
- package/lib/commonjs/ui/screens/LegalDocumentsScreen.js +4 -4
- package/lib/commonjs/ui/screens/LegalDocumentsScreen.js.map +1 -1
- package/lib/commonjs/ui/screens/PaymentGatewayScreen.js +1 -1
- package/lib/commonjs/ui/screens/PaymentGatewayScreen.js.map +1 -1
- package/lib/commonjs/ui/screens/PremiumSubscriptionScreen.js +1 -2
- package/lib/commonjs/ui/screens/PremiumSubscriptionScreen.js.map +1 -1
- package/lib/commonjs/ui/screens/ProfileScreen.js +44 -16
- package/lib/commonjs/ui/screens/ProfileScreen.js.map +1 -1
- package/lib/commonjs/ui/screens/SavesCollectionsScreen.js.map +1 -1
- package/lib/commonjs/ui/screens/karma/KarmaAboutScreen.js +3 -1
- package/lib/commonjs/ui/screens/karma/KarmaAboutScreen.js.map +1 -1
- package/lib/commonjs/ui/screens/karma/KarmaCenterScreen.js +2 -2
- package/lib/commonjs/ui/screens/karma/KarmaCenterScreen.js.map +1 -1
- package/lib/commonjs/ui/screens/karma/KarmaRewardsScreen.js +8 -5
- package/lib/commonjs/ui/screens/karma/KarmaRewardsScreen.js.map +1 -1
- package/lib/commonjs/ui/utils/errorHandlers.js +49 -2
- package/lib/commonjs/ui/utils/errorHandlers.js.map +1 -1
- package/lib/commonjs/ui/utils/sessionHelpers.js +0 -2
- package/lib/commonjs/ui/utils/sessionHelpers.js.map +1 -1
- package/lib/commonjs/utils/languageUtils.js +11 -11
- package/lib/commonjs/utils/languageUtils.js.map +1 -1
- package/lib/module/core/mixins/OxyServices.security.js +42 -0
- package/lib/module/core/mixins/OxyServices.security.js.map +1 -1
- package/lib/module/crypto/index.js +2 -3
- package/lib/module/crypto/index.js.map +1 -1
- package/lib/module/crypto/keyManager.js +2 -2
- package/lib/module/crypto/polyfill.js +4 -4
- package/lib/module/i18n/locales/en-US.json +1 -1
- package/lib/module/index.js +1 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/models/interfaces.js +2 -0
- package/lib/module/models/interfaces.js.map +1 -1
- package/lib/module/ui/components/FollowButton.js +19 -1
- package/lib/module/ui/components/FollowButton.js.map +1 -1
- package/lib/module/ui/components/GroupedItem.js +1 -29
- package/lib/module/ui/components/GroupedItem.js.map +1 -1
- package/lib/module/ui/components/Section.js +2 -1
- package/lib/module/ui/components/Section.js.map +1 -1
- package/lib/module/ui/components/SectionTitle.js +1 -2
- package/lib/module/ui/components/SectionTitle.js.map +1 -1
- package/lib/module/ui/components/fileManagement/FileViewer.js +3 -3
- package/lib/module/ui/components/fileManagement/FileViewer.js.map +1 -1
- package/lib/module/ui/context/OxyContext.js +62 -10
- package/lib/module/ui/context/OxyContext.js.map +1 -1
- package/lib/module/ui/context/hooks/useAuthOperations.js +65 -18
- package/lib/module/ui/context/hooks/useAuthOperations.js.map +1 -1
- package/lib/module/ui/context/hooks/useDeviceManagement.js +1 -1
- package/lib/module/ui/context/hooks/useDeviceManagement.js.map +1 -1
- package/lib/module/ui/context/hooks/useLanguageManagement.js +1 -1
- package/lib/module/ui/context/hooks/useLanguageManagement.js.map +1 -1
- package/lib/module/ui/context/hooks/useSessionManagement.js +3 -3
- package/lib/module/ui/context/hooks/useSessionManagement.js.map +1 -1
- package/lib/module/ui/context/hooks/useStorage.js +2 -2
- package/lib/module/ui/context/hooks/useStorage.js.map +1 -1
- package/lib/module/ui/hooks/queries/useAccountQueries.js +1 -1
- package/lib/module/ui/hooks/queries/useAccountQueries.js.map +1 -1
- package/lib/module/ui/hooks/queries/useServicesQueries.js +1 -1
- package/lib/module/ui/hooks/queries/useServicesQueries.js.map +1 -1
- package/lib/module/ui/hooks/useIdentityMutations.js +4 -4
- package/lib/module/ui/hooks/useIdentityMutations.js.map +1 -1
- package/lib/module/ui/hooks/useSessionSocket.js +22 -7
- package/lib/module/ui/hooks/useSessionSocket.js.map +1 -1
- package/lib/module/ui/screens/AccountCenterScreen.js +13 -13
- package/lib/module/ui/screens/AccountCenterScreen.js.map +1 -1
- package/lib/module/ui/screens/AccountOverviewScreen.js +17 -17
- package/lib/module/ui/screens/AccountOverviewScreen.js.map +1 -1
- package/lib/module/ui/screens/AccountSettingsScreen.js +2 -2
- package/lib/module/ui/screens/AccountSettingsScreen.js.map +1 -1
- package/lib/module/ui/screens/AccountSwitcherScreen.js +11 -10
- package/lib/module/ui/screens/AccountSwitcherScreen.js.map +1 -1
- package/lib/module/ui/screens/AppInfoScreen.js +15 -15
- package/lib/module/ui/screens/AppInfoScreen.js.map +1 -1
- package/lib/module/ui/screens/FeedbackScreen.js +1 -1
- package/lib/module/ui/screens/FeedbackScreen.js.map +1 -1
- package/lib/module/ui/screens/FileManagementScreen.js +1 -1
- package/lib/module/ui/screens/HelpSupportScreen.js +3 -3
- package/lib/module/ui/screens/HelpSupportScreen.js.map +1 -1
- package/lib/module/ui/screens/HistoryViewScreen.js +2 -2
- package/lib/module/ui/screens/HistoryViewScreen.js.map +1 -1
- package/lib/module/ui/screens/LanguageSelectorScreen.js +4 -2
- package/lib/module/ui/screens/LanguageSelectorScreen.js.map +1 -1
- package/lib/module/ui/screens/LegalDocumentsScreen.js +4 -4
- package/lib/module/ui/screens/LegalDocumentsScreen.js.map +1 -1
- package/lib/module/ui/screens/PaymentGatewayScreen.js +1 -1
- package/lib/module/ui/screens/PaymentGatewayScreen.js.map +1 -1
- package/lib/module/ui/screens/PremiumSubscriptionScreen.js +1 -2
- package/lib/module/ui/screens/PremiumSubscriptionScreen.js.map +1 -1
- package/lib/module/ui/screens/ProfileScreen.js +44 -16
- package/lib/module/ui/screens/ProfileScreen.js.map +1 -1
- package/lib/module/ui/screens/SavesCollectionsScreen.js.map +1 -1
- package/lib/module/ui/screens/karma/KarmaAboutScreen.js +3 -1
- package/lib/module/ui/screens/karma/KarmaAboutScreen.js.map +1 -1
- package/lib/module/ui/screens/karma/KarmaCenterScreen.js +3 -3
- package/lib/module/ui/screens/karma/KarmaCenterScreen.js.map +1 -1
- package/lib/module/ui/screens/karma/KarmaRewardsScreen.js +9 -6
- package/lib/module/ui/screens/karma/KarmaRewardsScreen.js.map +1 -1
- package/lib/module/ui/utils/errorHandlers.js +46 -0
- package/lib/module/ui/utils/errorHandlers.js.map +1 -1
- package/lib/module/ui/utils/sessionHelpers.js +0 -2
- package/lib/module/ui/utils/sessionHelpers.js.map +1 -1
- package/lib/module/utils/languageUtils.js +11 -11
- package/lib/module/utils/languageUtils.js.map +1 -1
- package/lib/typescript/core/mixins/OxyServices.security.d.ts +12 -0
- package/lib/typescript/core/mixins/OxyServices.security.d.ts.map +1 -1
- package/lib/typescript/core/mixins/index.d.ts +2 -0
- package/lib/typescript/core/mixins/index.d.ts.map +1 -1
- package/lib/typescript/crypto/index.d.ts +1 -2
- package/lib/typescript/crypto/index.d.ts.map +1 -1
- package/lib/typescript/crypto/keyManager.d.ts +2 -2
- package/lib/typescript/crypto/polyfill.d.ts +2 -2
- package/lib/typescript/index.d.ts +2 -2
- package/lib/typescript/index.d.ts.map +1 -1
- package/lib/typescript/models/interfaces.d.ts +1 -1
- package/lib/typescript/models/interfaces.d.ts.map +1 -1
- package/lib/typescript/ui/components/FollowButton.d.ts.map +1 -1
- package/lib/typescript/ui/components/GroupedItem.d.ts.map +1 -1
- package/lib/typescript/ui/components/Section.d.ts.map +1 -1
- package/lib/typescript/ui/components/SectionTitle.d.ts.map +1 -1
- package/lib/typescript/ui/context/OxyContext.d.ts +6 -2
- package/lib/typescript/ui/context/OxyContext.d.ts.map +1 -1
- package/lib/typescript/ui/context/hooks/useAuthOperations.d.ts +8 -4
- package/lib/typescript/ui/context/hooks/useAuthOperations.d.ts.map +1 -1
- package/lib/typescript/ui/context/hooks/useLanguageManagement.d.ts +1 -1
- package/lib/typescript/ui/context/hooks/useLanguageManagement.d.ts.map +1 -1
- package/lib/typescript/ui/context/hooks/useSessionManagement.d.ts +1 -1
- package/lib/typescript/ui/context/hooks/useSessionManagement.d.ts.map +1 -1
- package/lib/typescript/ui/context/hooks/useStorage.d.ts +1 -1
- package/lib/typescript/ui/context/hooks/useStorage.d.ts.map +1 -1
- package/lib/typescript/ui/hooks/useIdentityMutations.d.ts +15 -3
- package/lib/typescript/ui/hooks/useIdentityMutations.d.ts.map +1 -1
- package/lib/typescript/ui/hooks/useSessionSocket.d.ts.map +1 -1
- package/lib/typescript/ui/screens/LanguageSelectorScreen.d.ts.map +1 -1
- package/lib/typescript/ui/screens/PremiumSubscriptionScreen.d.ts.map +1 -1
- package/lib/typescript/ui/screens/ProfileScreen.d.ts.map +1 -1
- package/lib/typescript/ui/screens/SavesCollectionsScreen.d.ts.map +1 -1
- package/lib/typescript/ui/screens/karma/KarmaAboutScreen.d.ts.map +1 -1
- package/lib/typescript/ui/screens/karma/KarmaRewardsScreen.d.ts.map +1 -1
- package/lib/typescript/ui/utils/errorHandlers.d.ts +5 -0
- package/lib/typescript/ui/utils/errorHandlers.d.ts.map +1 -1
- package/lib/typescript/ui/utils/sessionHelpers.d.ts.map +1 -1
- package/package.json +1 -2
- package/src/core/mixins/OxyServices.security.ts +44 -0
- package/src/crypto/index.ts +2 -6
- package/src/crypto/keyManager.ts +2 -2
- package/src/crypto/polyfill.ts +4 -4
- package/src/i18n/locales/en-US.json +1 -1
- package/src/index.ts +2 -4
- package/src/models/interfaces.ts +4 -0
- package/src/ui/components/FollowButton.tsx +19 -1
- package/src/ui/components/GroupedItem.tsx +1 -29
- package/src/ui/components/Section.tsx +1 -0
- package/src/ui/components/SectionTitle.tsx +0 -1
- package/src/ui/components/fileManagement/FileViewer.tsx +3 -3
- package/src/ui/context/OxyContext.tsx +53 -14
- package/src/ui/context/hooks/useAuthOperations.ts +83 -26
- package/src/ui/context/hooks/useDeviceManagement.ts +1 -1
- package/src/ui/context/hooks/useLanguageManagement.ts +2 -2
- package/src/ui/context/hooks/useSessionManagement.ts +3 -3
- package/src/ui/context/hooks/useStorage.ts +2 -2
- package/src/ui/hooks/queries/useAccountQueries.ts +1 -1
- package/src/ui/hooks/queries/useServicesQueries.ts +1 -1
- package/src/ui/hooks/useIdentityMutations.ts +6 -6
- package/src/ui/hooks/useSessionSocket.ts +8 -7
- package/src/ui/screens/AccountCenterScreen.tsx +13 -13
- package/src/ui/screens/AccountOverviewScreen.tsx +17 -17
- package/src/ui/screens/AccountSettingsScreen.tsx +2 -2
- package/src/ui/screens/AccountSwitcherScreen.tsx +8 -8
- package/src/ui/screens/AppInfoScreen.tsx +15 -15
- package/src/ui/screens/FeedbackScreen.tsx +1 -1
- package/src/ui/screens/FileManagementScreen.tsx +1 -1
- package/src/ui/screens/HelpSupportScreen.tsx +3 -3
- package/src/ui/screens/HistoryViewScreen.tsx +2 -2
- package/src/ui/screens/LanguageSelectorScreen.tsx +4 -1
- package/src/ui/screens/LegalDocumentsScreen.tsx +4 -4
- package/src/ui/screens/PaymentGatewayScreen.tsx +1 -1
- package/src/ui/screens/PremiumSubscriptionScreen.tsx +0 -1
- package/src/ui/screens/ProfileScreen.tsx +61 -22
- package/src/ui/screens/SavesCollectionsScreen.tsx +10 -1
- package/src/ui/screens/karma/KarmaAboutScreen.tsx +8 -1
- package/src/ui/screens/karma/KarmaCenterScreen.tsx +2 -2
- package/src/ui/screens/karma/KarmaRewardsScreen.tsx +9 -6
- package/src/ui/utils/errorHandlers.ts +58 -0
- package/src/ui/utils/sessionHelpers.ts +0 -2
- package/src/utils/languageUtils.ts +11 -11
- package/lib/commonjs/crypto/recoveryPhrase.js +0 -152
- package/lib/commonjs/crypto/recoveryPhrase.js.map +0 -1
- package/lib/commonjs/ui/context/utils/errorHandlers.js +0 -100
- package/lib/commonjs/ui/context/utils/errorHandlers.js.map +0 -1
- package/lib/commonjs/ui/context/utils/sessionHelpers.js +0 -103
- package/lib/commonjs/ui/context/utils/sessionHelpers.js.map +0 -1
- package/lib/commonjs/ui/context/utils/storageHelpers.js +0 -119
- package/lib/commonjs/ui/context/utils/storageHelpers.js.map +0 -1
- package/lib/module/crypto/recoveryPhrase.js +0 -147
- package/lib/module/crypto/recoveryPhrase.js.map +0 -1
- package/lib/module/ui/context/utils/errorHandlers.js +0 -93
- package/lib/module/ui/context/utils/errorHandlers.js.map +0 -1
- package/lib/module/ui/context/utils/sessionHelpers.js +0 -96
- package/lib/module/ui/context/utils/sessionHelpers.js.map +0 -1
- package/lib/module/ui/context/utils/storageHelpers.js +0 -111
- package/lib/module/ui/context/utils/storageHelpers.js.map +0 -1
- package/lib/typescript/crypto/recoveryPhrase.d.ts +0 -59
- package/lib/typescript/crypto/recoveryPhrase.d.ts.map +0 -1
- package/lib/typescript/ui/context/utils/errorHandlers.d.ts +0 -30
- package/lib/typescript/ui/context/utils/errorHandlers.d.ts.map +0 -1
- package/lib/typescript/ui/context/utils/sessionHelpers.d.ts +0 -59
- package/lib/typescript/ui/context/utils/sessionHelpers.d.ts.map +0 -1
- package/lib/typescript/ui/context/utils/storageHelpers.d.ts +0 -31
- package/lib/typescript/ui/context/utils/storageHelpers.d.ts.map +0 -1
- package/src/crypto/recoveryPhrase.ts +0 -166
- package/src/ui/context/utils/errorHandlers.ts +0 -146
- package/src/ui/context/utils/sessionHelpers.ts +0 -146
- package/src/ui/context/utils/storageHelpers.ts +0 -134
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Normalize backend session payloads into `ClientSession` objects.
|
|
5
|
-
*
|
|
6
|
-
* @param sessions - Raw session array returned from the API
|
|
7
|
-
* @param fallbackDeviceId - Device identifier to use when missing from payload
|
|
8
|
-
* @param fallbackUserId - User identifier to use when missing from payload
|
|
9
|
-
*/
|
|
10
|
-
export const mapSessionsToClient = (sessions, fallbackDeviceId, fallbackUserId) => {
|
|
11
|
-
const now = new Date();
|
|
12
|
-
return sessions.map(session => ({
|
|
13
|
-
sessionId: session.sessionId,
|
|
14
|
-
deviceId: session.deviceId || fallbackDeviceId || '',
|
|
15
|
-
expiresAt: session.expiresAt || new Date(now.getTime() + 7 * 24 * 60 * 60 * 1000).toISOString(),
|
|
16
|
-
lastActive: session.lastActive || now.toISOString(),
|
|
17
|
-
userId: session.user?.id || session.userId || (session.user?._id ? session.user._id.toString() : undefined) || fallbackUserId || '',
|
|
18
|
-
isCurrent: Boolean(session.isCurrent)
|
|
19
|
-
}));
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Fetch device sessions with fallback to the legacy session endpoint when needed.
|
|
24
|
-
*
|
|
25
|
-
* @param oxyServices - Oxy service instance
|
|
26
|
-
* @param sessionId - Session identifier to fetch
|
|
27
|
-
* @param options - Optional fallback options
|
|
28
|
-
*/
|
|
29
|
-
export const fetchSessionsWithFallback = async (oxyServices, sessionId, {
|
|
30
|
-
fallbackDeviceId,
|
|
31
|
-
fallbackUserId,
|
|
32
|
-
logger
|
|
33
|
-
} = {}) => {
|
|
34
|
-
try {
|
|
35
|
-
const deviceSessions = await oxyServices.getDeviceSessions(sessionId);
|
|
36
|
-
return mapSessionsToClient(deviceSessions, fallbackDeviceId, fallbackUserId);
|
|
37
|
-
} catch (error) {
|
|
38
|
-
if (__DEV__ && logger) {
|
|
39
|
-
logger('Failed to get device sessions, falling back to user sessions', error);
|
|
40
|
-
} else if (__DEV__) {
|
|
41
|
-
console.warn('Failed to get device sessions, falling back to user sessions:', error);
|
|
42
|
-
}
|
|
43
|
-
const userSessions = await oxyServices.getSessionsBySessionId(sessionId);
|
|
44
|
-
return mapSessionsToClient(userSessions, fallbackDeviceId, fallbackUserId);
|
|
45
|
-
}
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* Validate multiple sessions concurrently with configurable concurrency.
|
|
50
|
-
*
|
|
51
|
-
* @param oxyServices - Oxy service instance
|
|
52
|
-
* @param sessionIds - Session identifiers to validate
|
|
53
|
-
* @param options - Validation options
|
|
54
|
-
*/
|
|
55
|
-
export const validateSessionBatch = async (oxyServices, sessionIds, {
|
|
56
|
-
useHeaderValidation = true,
|
|
57
|
-
maxConcurrency = 5
|
|
58
|
-
} = {}) => {
|
|
59
|
-
if (!sessionIds.length) {
|
|
60
|
-
return [];
|
|
61
|
-
}
|
|
62
|
-
const uniqueSessionIds = Array.from(new Set(sessionIds));
|
|
63
|
-
const safeConcurrency = Math.max(1, Math.min(maxConcurrency, uniqueSessionIds.length));
|
|
64
|
-
const results = [];
|
|
65
|
-
let index = 0;
|
|
66
|
-
const worker = async () => {
|
|
67
|
-
while (index < uniqueSessionIds.length) {
|
|
68
|
-
const currentIndex = index;
|
|
69
|
-
index += 1;
|
|
70
|
-
const sessionId = uniqueSessionIds[currentIndex];
|
|
71
|
-
try {
|
|
72
|
-
const validation = await oxyServices.validateSession(sessionId, {
|
|
73
|
-
useHeaderValidation
|
|
74
|
-
});
|
|
75
|
-
const valid = Boolean(validation?.valid);
|
|
76
|
-
results.push({
|
|
77
|
-
sessionId,
|
|
78
|
-
valid,
|
|
79
|
-
user: validation?.user,
|
|
80
|
-
raw: validation
|
|
81
|
-
});
|
|
82
|
-
} catch (error) {
|
|
83
|
-
results.push({
|
|
84
|
-
sessionId,
|
|
85
|
-
valid: false,
|
|
86
|
-
error
|
|
87
|
-
});
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
};
|
|
91
|
-
await Promise.all(Array.from({
|
|
92
|
-
length: safeConcurrency
|
|
93
|
-
}, worker));
|
|
94
|
-
return results;
|
|
95
|
-
};
|
|
96
|
-
//# sourceMappingURL=sessionHelpers.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["mapSessionsToClient","sessions","fallbackDeviceId","fallbackUserId","now","Date","map","session","sessionId","deviceId","expiresAt","getTime","toISOString","lastActive","userId","user","id","_id","toString","undefined","isCurrent","Boolean","fetchSessionsWithFallback","oxyServices","logger","deviceSessions","getDeviceSessions","error","__DEV__","console","warn","userSessions","getSessionsBySessionId","validateSessionBatch","sessionIds","useHeaderValidation","maxConcurrency","length","uniqueSessionIds","Array","from","Set","safeConcurrency","Math","max","min","results","index","worker","currentIndex","validation","validateSession","valid","push","raw","Promise","all"],"sourceRoot":"../../../../../src","sources":["ui/context/utils/sessionHelpers.ts"],"mappings":";;AAiCA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMA,mBAAmB,GAAGA,CACjCC,QAAyB,EACzBC,gBAAyB,EACzBC,cAAuB,KACH;EACpB,MAAMC,GAAG,GAAG,IAAIC,IAAI,CAAC,CAAC;EAEtB,OAAOJ,QAA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,UAAU,EAAEnC,IAAI;UACtBuC,GAAG,EAAEJ;QACP,CAAC,CAAC;MACJ,CAAC,CAAC,OAAOvB,KAAK,EAAE;QACdmB,OAAO,CAACO,IAAI,CAAC;UACX7C,SAAS;UACT4C,KAAK,EAAE,KAAK;UACZzB;QACF,CAAC,CAAC;MACJ;IACF;EACF,CAAC;EAED,MAAM4B,OAAO,CAACC,GAAG,CAACjB,KAAK,CAACC,IAAI,CAAC;IAAEH,MAAM,EAAEK;EAAgB,CAAC,EAAEM,MAAM,CAAC,CAAC;EAElE,OAAOF,OAAO;AAChB,CAAC","ignoreList":[]}
|
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Create an in-memory storage implementation used as a safe fallback.
|
|
5
|
-
*/
|
|
6
|
-
const MEMORY_STORAGE = () => {
|
|
7
|
-
const store = new Map();
|
|
8
|
-
return {
|
|
9
|
-
async getItem(key) {
|
|
10
|
-
return store.has(key) ? store.get(key) : null;
|
|
11
|
-
},
|
|
12
|
-
async setItem(key, value) {
|
|
13
|
-
store.set(key, value);
|
|
14
|
-
},
|
|
15
|
-
async removeItem(key) {
|
|
16
|
-
store.delete(key);
|
|
17
|
-
},
|
|
18
|
-
async clear() {
|
|
19
|
-
store.clear();
|
|
20
|
-
}
|
|
21
|
-
};
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* Create a web storage implementation backed by `localStorage`.
|
|
26
|
-
* Falls back to in-memory storage when unavailable.
|
|
27
|
-
*/
|
|
28
|
-
const createWebStorage = () => {
|
|
29
|
-
if (typeof window === 'undefined' || typeof window.localStorage === 'undefined') {
|
|
30
|
-
return MEMORY_STORAGE();
|
|
31
|
-
}
|
|
32
|
-
return {
|
|
33
|
-
async getItem(key) {
|
|
34
|
-
try {
|
|
35
|
-
return window.localStorage.getItem(key);
|
|
36
|
-
} catch {
|
|
37
|
-
return null;
|
|
38
|
-
}
|
|
39
|
-
},
|
|
40
|
-
async setItem(key, value) {
|
|
41
|
-
try {
|
|
42
|
-
window.localStorage.setItem(key, value);
|
|
43
|
-
} catch {
|
|
44
|
-
// Ignore quota or access issues for now.
|
|
45
|
-
}
|
|
46
|
-
},
|
|
47
|
-
async removeItem(key) {
|
|
48
|
-
try {
|
|
49
|
-
window.localStorage.removeItem(key);
|
|
50
|
-
} catch {
|
|
51
|
-
// Ignore failures.
|
|
52
|
-
}
|
|
53
|
-
},
|
|
54
|
-
async clear() {
|
|
55
|
-
try {
|
|
56
|
-
window.localStorage.clear();
|
|
57
|
-
} catch {
|
|
58
|
-
// Ignore failures.
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
};
|
|
62
|
-
};
|
|
63
|
-
let asyncStorageInstance = null;
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* Lazily import React Native AsyncStorage implementation.
|
|
67
|
-
*/
|
|
68
|
-
const createNativeStorage = async () => {
|
|
69
|
-
if (asyncStorageInstance) {
|
|
70
|
-
return asyncStorageInstance;
|
|
71
|
-
}
|
|
72
|
-
try {
|
|
73
|
-
const asyncStorageModule = await import('@react-native-async-storage/async-storage');
|
|
74
|
-
asyncStorageInstance = asyncStorageModule.default;
|
|
75
|
-
return asyncStorageInstance;
|
|
76
|
-
} catch (error) {
|
|
77
|
-
if (__DEV__) {
|
|
78
|
-
console.error('Failed to import AsyncStorage:', error);
|
|
79
|
-
}
|
|
80
|
-
throw new Error('AsyncStorage is required in React Native environment');
|
|
81
|
-
}
|
|
82
|
-
};
|
|
83
|
-
|
|
84
|
-
/**
|
|
85
|
-
* Detect whether the current runtime is React Native.
|
|
86
|
-
*/
|
|
87
|
-
export const isReactNative = () => typeof navigator !== 'undefined' && navigator.product === 'ReactNative';
|
|
88
|
-
|
|
89
|
-
/**
|
|
90
|
-
* Create a platform-appropriate storage implementation.
|
|
91
|
-
* Defaults to in-memory storage when no platform storage is available.
|
|
92
|
-
*/
|
|
93
|
-
export const createPlatformStorage = async () => {
|
|
94
|
-
if (isReactNative()) {
|
|
95
|
-
return createNativeStorage();
|
|
96
|
-
}
|
|
97
|
-
return createWebStorage();
|
|
98
|
-
};
|
|
99
|
-
export const STORAGE_KEY_PREFIX = 'oxy_session';
|
|
100
|
-
|
|
101
|
-
/**
|
|
102
|
-
* Produce strongly typed storage key names for the supplied prefix.
|
|
103
|
-
*
|
|
104
|
-
* @param prefix - Storage key prefix
|
|
105
|
-
*/
|
|
106
|
-
export const getStorageKeys = (prefix = STORAGE_KEY_PREFIX) => ({
|
|
107
|
-
activeSessionId: `${prefix}_active_session_id`,
|
|
108
|
-
sessionIds: `${prefix}_session_ids`,
|
|
109
|
-
language: `${prefix}_language`
|
|
110
|
-
});
|
|
111
|
-
//# sourceMappingURL=storageHelpers.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["MEMORY_STORAGE","store","Map","getItem","key","has","get","setItem","value","set","removeItem","delete","clear","createWebStorage","window","localStorage","asyncStorageInstance","createNativeStorage","asyncStorageModule","default","error","__DEV__","console","Error","isReactNative","navigator","product","createPlatformStorage","STORAGE_KEY_PREFIX","getStorageKeys","prefix","activeSessionId","sessionIds","language"],"sourceRoot":"../../../../../src","sources":["ui/context/utils/storageHelpers.ts"],"mappings":";;AAiBA;AACA;AACA;AACA,MAAMA,cAAc,GAAGA,CAAA,KAAwB;EAC7C,MAAMC,KAAK,GAAG,IAAIC,GAAG,CAAiB,CAAC;EAEvC,OAAO;IACL,MAAMC,OAAOA,CAACC,GAAW,EAAE;MACzB,OAAOH,KAAK,CAACI,GAAG,CAACD,GAAG,CAAC,GAAGH,KAAK,CAACK,GAAG,CAACF,GAAG,CAAC,GAAI,IAAI;IAChD,CAAC;IACD,MAAMG,OAAOA,CAACH,GAAW,EAAEI,KAAa,EAAE;MACxCP,KAAK,CAACQ,GAAG,CAACL,GAAG,EAAEI,KAAK,CAAC;IACvB,CAAC;IACD,MAAME,UAAUA,CAACN,GAAW,EAAE;MAC5BH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B,GAAGE,kBAAkB,CAACC,OAAsC;IAChF,OAAOH,oBAAoB;EAC7B,CAAC,CAAC,OAAOI,KAAK,EAAE;IACd,IAAIC,OAAO,EAAE;MACXC,OAAO,CAACF,KAAK,CAAC,gCAAgC,EAAEA,KAAK,CAAC;IACxD;IACA,MAAM,IAAIG,KAAK,CAAC,sDAAsD,CAAC;EACzE;AACF,CAAC;;AAED;AACA;AACA;AACA,OAAO,MAAMC,aAAa,GAAGA,CAAA,KAC3B,OAAOC,SAAS,KAAK,WAAW,IAAIA,SAAS,CAACC,OAAO,KAAK,aAAa;;AAEzE;AACA;AACA;AACA;AACA,OAAO,MAAMC,qBAAqB,GAAG,MAAAA,CAAA,KAAuC;EAC1E,IAAIH,aAAa,CAAC,CAAC,EAAE;IACnB,OAAOP,mBAAmB,CAAC,CAAC;EAC9B;EAEA,OAAOJ,gBAAgB,CAAC,CAAC;AAC3B,CAAC;AAED,OAAO,MAAMe,kBAAkB,GAAG,aAAa;;AAE/C;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,cAAc,GAAGA,CAACC,MAAc,GAAGF,kBAAkB,MAA0B;EAC1FG,eAAe,EAAE,GAAGD,MAAM,oBAAoB;EAC9CE,UAAU,EAAE,GAAGF,MAAM,cAAc;EACnCG,QAAQ,EAAE,GAAGH,MAAM;AACrB,CAAC,CAAC","ignoreList":[]}
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Recovery Phrase Service - BIP39 Mnemonic Generation
|
|
3
|
-
*
|
|
4
|
-
* Handles generation and restoration of recovery phrases (mnemonic seeds)
|
|
5
|
-
* for backing up and restoring user identities.
|
|
6
|
-
*
|
|
7
|
-
* Note: This module requires the polyfill to be loaded first (done via crypto/index.ts)
|
|
8
|
-
*/
|
|
9
|
-
export interface RecoveryPhraseResult {
|
|
10
|
-
phrase: string;
|
|
11
|
-
words: string[];
|
|
12
|
-
publicKey: string;
|
|
13
|
-
}
|
|
14
|
-
export declare class RecoveryPhraseService {
|
|
15
|
-
/**
|
|
16
|
-
* Generate a new identity with a recovery phrase
|
|
17
|
-
* Returns the mnemonic phrase (should only be shown once to the user)
|
|
18
|
-
*/
|
|
19
|
-
static generateIdentityWithRecovery(): Promise<RecoveryPhraseResult>;
|
|
20
|
-
/**
|
|
21
|
-
* Generate a 24-word recovery phrase for higher security
|
|
22
|
-
*/
|
|
23
|
-
static generateIdentityWithRecovery24(): Promise<RecoveryPhraseResult>;
|
|
24
|
-
/**
|
|
25
|
-
* Restore an identity from a recovery phrase
|
|
26
|
-
*/
|
|
27
|
-
static restoreFromPhrase(phrase: string): Promise<string>;
|
|
28
|
-
/**
|
|
29
|
-
* Validate a recovery phrase without importing it
|
|
30
|
-
*/
|
|
31
|
-
static validatePhrase(phrase: string): boolean;
|
|
32
|
-
/**
|
|
33
|
-
* Get the word list for autocomplete/validation
|
|
34
|
-
*/
|
|
35
|
-
static getWordList(): string[];
|
|
36
|
-
/**
|
|
37
|
-
* Check if a word is valid in the BIP39 word list
|
|
38
|
-
*/
|
|
39
|
-
static isValidWord(word: string): boolean;
|
|
40
|
-
/**
|
|
41
|
-
* Get suggestions for a partial word
|
|
42
|
-
*/
|
|
43
|
-
static getSuggestions(partial: string, limit?: number): string[];
|
|
44
|
-
/**
|
|
45
|
-
* Derive the public key from a phrase without storing
|
|
46
|
-
* Useful for verification before importing
|
|
47
|
-
*/
|
|
48
|
-
static derivePublicKeyFromPhrase(phrase: string): Promise<string>;
|
|
49
|
-
/**
|
|
50
|
-
* Convert a phrase to its word array
|
|
51
|
-
*/
|
|
52
|
-
static phraseToWords(phrase: string): string[];
|
|
53
|
-
/**
|
|
54
|
-
* Convert a word array to a phrase string
|
|
55
|
-
*/
|
|
56
|
-
static wordsToPhrase(words: string[]): string;
|
|
57
|
-
}
|
|
58
|
-
export default RecoveryPhraseService;
|
|
59
|
-
//# sourceMappingURL=recoveryPhrase.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"recoveryPhrase.d.ts","sourceRoot":"","sources":["../../../src/crypto/recoveryPhrase.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAiBH,MAAM,WAAW,oBAAoB;IACnC,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,qBAAa,qBAAqB;IAChC;;;OAGG;WACU,4BAA4B,IAAI,OAAO,CAAC,oBAAoB,CAAC;IAsB1E;;OAEG;WACU,8BAA8B,IAAI,OAAO,CAAC,oBAAoB,CAAC;IAgB5E;;OAEG;WACU,iBAAiB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAmB/D;;OAEG;IACH,MAAM,CAAC,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO;IAK9C;;OAEG;IACH,MAAM,CAAC,WAAW,IAAI,MAAM,EAAE;IAI9B;;OAEG;IACH,MAAM,CAAC,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAIzC;;OAEG;IACH,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,GAAE,MAAU,GAAG,MAAM,EAAE;IAOnE;;;OAGG;WACU,yBAAyB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAcvE;;OAEG;IACH,MAAM,CAAC,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE;IAI9C;;OAEG;IACH,MAAM,CAAC,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM;CAG9C;AAED,eAAe,qBAAqB,CAAC"}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import type { ApiError } from '../../../models/interfaces';
|
|
2
|
-
export interface HandleAuthErrorOptions {
|
|
3
|
-
defaultMessage: string;
|
|
4
|
-
code: string;
|
|
5
|
-
status?: number;
|
|
6
|
-
onError?: (error: ApiError) => void;
|
|
7
|
-
setAuthError?: (message: string) => void;
|
|
8
|
-
logger?: (message: string, error?: unknown) => void;
|
|
9
|
-
}
|
|
10
|
-
/**
|
|
11
|
-
* Determine whether the error represents an invalid session condition.
|
|
12
|
-
* This centralizes 401 detection across different fetch clients.
|
|
13
|
-
*/
|
|
14
|
-
export declare const isInvalidSessionError: (error: unknown) => boolean;
|
|
15
|
-
/**
|
|
16
|
-
* Extract a consistent error message from unknown error shapes.
|
|
17
|
-
*
|
|
18
|
-
* @param error - The unknown error payload
|
|
19
|
-
* @param fallbackMessage - Message to return when no concrete message is available
|
|
20
|
-
*/
|
|
21
|
-
export declare const extractErrorMessage: (error: unknown, fallbackMessage?: string) => string;
|
|
22
|
-
/**
|
|
23
|
-
* Centralized error handler for auth-related operations.
|
|
24
|
-
*
|
|
25
|
-
* @param error - Unknown error object
|
|
26
|
-
* @param options - Error handling configuration
|
|
27
|
-
* @returns Resolved error message
|
|
28
|
-
*/
|
|
29
|
-
export declare const handleAuthError: (error: unknown, { defaultMessage, code, status, onError, setAuthError, logger, }: HandleAuthErrorOptions) => string;
|
|
30
|
-
//# sourceMappingURL=errorHandlers.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"errorHandlers.d.ts","sourceRoot":"","sources":["../../../../../src/ui/context/utils/errorHandlers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AAgB3D,MAAM,WAAW,sBAAsB;IACrC,cAAc,EAAE,MAAM,CAAC;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,QAAQ,KAAK,IAAI,CAAC;IACpC,YAAY,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IACzC,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,OAAO,KAAK,IAAI,CAAC;CACrD;AAkBD;;;GAGG;AACH,eAAO,MAAM,qBAAqB,GAAI,OAAO,OAAO,KAAG,OA4BtD,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB,GAC9B,OAAO,OAAO,EACd,wBAAoC,KACnC,MAuBF,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,eAAe,GAC1B,OAAO,OAAO,EACd,kEAOG,sBAAsB,KACxB,MAiBF,CAAC"}
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import type { OxyServices } from '../../../core';
|
|
2
|
-
import type { ClientSession } from '../../../models/session';
|
|
3
|
-
interface DeviceSession {
|
|
4
|
-
sessionId: string;
|
|
5
|
-
deviceId?: string;
|
|
6
|
-
deviceName?: string;
|
|
7
|
-
expiresAt?: string;
|
|
8
|
-
lastActive?: string;
|
|
9
|
-
user?: {
|
|
10
|
-
id?: string;
|
|
11
|
-
_id?: {
|
|
12
|
-
toString(): string;
|
|
13
|
-
};
|
|
14
|
-
};
|
|
15
|
-
userId?: string;
|
|
16
|
-
isCurrent?: boolean;
|
|
17
|
-
}
|
|
18
|
-
export interface FetchSessionsWithFallbackOptions {
|
|
19
|
-
fallbackDeviceId?: string;
|
|
20
|
-
fallbackUserId?: string;
|
|
21
|
-
logger?: (message: string, error?: unknown) => void;
|
|
22
|
-
}
|
|
23
|
-
export interface ValidateSessionBatchOptions {
|
|
24
|
-
useHeaderValidation?: boolean;
|
|
25
|
-
maxConcurrency?: number;
|
|
26
|
-
}
|
|
27
|
-
export interface SessionValidationResult {
|
|
28
|
-
sessionId: string;
|
|
29
|
-
valid: boolean;
|
|
30
|
-
user?: unknown;
|
|
31
|
-
raw?: unknown;
|
|
32
|
-
error?: unknown;
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* Normalize backend session payloads into `ClientSession` objects.
|
|
36
|
-
*
|
|
37
|
-
* @param sessions - Raw session array returned from the API
|
|
38
|
-
* @param fallbackDeviceId - Device identifier to use when missing from payload
|
|
39
|
-
* @param fallbackUserId - User identifier to use when missing from payload
|
|
40
|
-
*/
|
|
41
|
-
export declare const mapSessionsToClient: (sessions: DeviceSession[], fallbackDeviceId?: string, fallbackUserId?: string) => ClientSession[];
|
|
42
|
-
/**
|
|
43
|
-
* Fetch device sessions with fallback to the legacy session endpoint when needed.
|
|
44
|
-
*
|
|
45
|
-
* @param oxyServices - Oxy service instance
|
|
46
|
-
* @param sessionId - Session identifier to fetch
|
|
47
|
-
* @param options - Optional fallback options
|
|
48
|
-
*/
|
|
49
|
-
export declare const fetchSessionsWithFallback: (oxyServices: Pick<OxyServices, "getDeviceSessions" | "getSessionsBySessionId">, sessionId: string, { fallbackDeviceId, fallbackUserId, logger, }?: FetchSessionsWithFallbackOptions) => Promise<ClientSession[]>;
|
|
50
|
-
/**
|
|
51
|
-
* Validate multiple sessions concurrently with configurable concurrency.
|
|
52
|
-
*
|
|
53
|
-
* @param oxyServices - Oxy service instance
|
|
54
|
-
* @param sessionIds - Session identifiers to validate
|
|
55
|
-
* @param options - Validation options
|
|
56
|
-
*/
|
|
57
|
-
export declare const validateSessionBatch: (oxyServices: Pick<OxyServices, "validateSession">, sessionIds: string[], { useHeaderValidation, maxConcurrency }?: ValidateSessionBatchOptions) => Promise<SessionValidationResult[]>;
|
|
58
|
-
export {};
|
|
59
|
-
//# sourceMappingURL=sessionHelpers.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"sessionHelpers.d.ts","sourceRoot":"","sources":["../../../../../src/ui/context/utils/sessionHelpers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAE7D,UAAU,aAAa;IACrB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,E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AAoD,2BAAgC,KACnF,OAAO,CAAC,uBAAuB,EAAE,CAuCnC,CAAC"}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
export interface StorageInterface {
|
|
2
|
-
getItem: (key: string) => Promise<string | null>;
|
|
3
|
-
setItem: (key: string, value: string) => Promise<void>;
|
|
4
|
-
removeItem: (key: string) => Promise<void>;
|
|
5
|
-
clear: () => Promise<void>;
|
|
6
|
-
}
|
|
7
|
-
export interface SessionStorageKeys {
|
|
8
|
-
activeSessionId: string;
|
|
9
|
-
sessionIds: string;
|
|
10
|
-
language: string;
|
|
11
|
-
}
|
|
12
|
-
export interface CreateStorageOptions {
|
|
13
|
-
prefix?: string;
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* Detect whether the current runtime is React Native.
|
|
17
|
-
*/
|
|
18
|
-
export declare const isReactNative: () => boolean;
|
|
19
|
-
/**
|
|
20
|
-
* Create a platform-appropriate storage implementation.
|
|
21
|
-
* Defaults to in-memory storage when no platform storage is available.
|
|
22
|
-
*/
|
|
23
|
-
export declare const createPlatformStorage: () => Promise<StorageInterface>;
|
|
24
|
-
export declare const STORAGE_KEY_PREFIX = "oxy_session";
|
|
25
|
-
/**
|
|
26
|
-
* Produce strongly typed storage key names for the supplied prefix.
|
|
27
|
-
*
|
|
28
|
-
* @param prefix - Storage key prefix
|
|
29
|
-
*/
|
|
30
|
-
export declare const getStorageKeys: (prefix?: string) => SessionStorageKeys;
|
|
31
|
-
//# sourceMappingURL=storageHelpers.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"storageHelpers.d.ts","sourceRoot":"","sources":["../../../../../src/ui/context/utils/storageHelpers.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IACjD,OAAO,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACvD,UAAU,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAC3C,KAAK,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CAC5B;AAED,MAAM,WAAW,kBAAkB;IACjC,eAAe,EAAE,MAAM,CAAC;IACxB,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,oBAAoB;IACnC,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAuFD;;GAEG;AACH,eAAO,MAAM,aAAa,QAAO,OACwC,CAAC;AAE1E;;;GAGG;AACH,eAAO,MAAM,qBAAqB,QAAa,OAAO,CAAC,gBAAgB,CAMtE,CAAC;AAEF,eAAO,MAAM,kBAAkB,gBAAgB,CAAC;AAEhD;;;;GAIG;AACH,eAAO,MAAM,cAAc,GAAI,SAAQ,MAA2B,KAAG,kBAInE,CAAC"}
|
|
@@ -1,166 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Recovery Phrase Service - BIP39 Mnemonic Generation
|
|
3
|
-
*
|
|
4
|
-
* Handles generation and restoration of recovery phrases (mnemonic seeds)
|
|
5
|
-
* for backing up and restoring user identities.
|
|
6
|
-
*
|
|
7
|
-
* Note: This module requires the polyfill to be loaded first (done via crypto/index.ts)
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
import * as bip39 from 'bip39';
|
|
11
|
-
import { KeyManager } from './keyManager';
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Convert Uint8Array or array-like to hexadecimal string
|
|
15
|
-
* Works in both Node.js and React Native without depending on Buffer
|
|
16
|
-
*/
|
|
17
|
-
function toHex(data: Uint8Array | ArrayLike<number>): string {
|
|
18
|
-
// Convert to array of numbers if needed
|
|
19
|
-
const bytes = data instanceof Uint8Array ? data : new Uint8Array(data);
|
|
20
|
-
return Array.from(bytes)
|
|
21
|
-
.map(b => b.toString(16).padStart(2, '0'))
|
|
22
|
-
.join('');
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export interface RecoveryPhraseResult {
|
|
26
|
-
phrase: string;
|
|
27
|
-
words: string[];
|
|
28
|
-
publicKey: string;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export class RecoveryPhraseService {
|
|
32
|
-
/**
|
|
33
|
-
* Generate a new identity with a recovery phrase
|
|
34
|
-
* Returns the mnemonic phrase (should only be shown once to the user)
|
|
35
|
-
*/
|
|
36
|
-
static async generateIdentityWithRecovery(): Promise<RecoveryPhraseResult> {
|
|
37
|
-
// Generate 128-bit entropy for 12-word mnemonic
|
|
38
|
-
const mnemonic = bip39.generateMnemonic(128);
|
|
39
|
-
|
|
40
|
-
// Derive private key from mnemonic
|
|
41
|
-
// Using the seed directly as the private key (simplified approach)
|
|
42
|
-
const seed = await bip39.mnemonicToSeed(mnemonic);
|
|
43
|
-
|
|
44
|
-
// Use first 32 bytes of seed as private key
|
|
45
|
-
const seedSlice = seed.subarray ? seed.subarray(0, 32) : seed.slice(0, 32);
|
|
46
|
-
const privateKeyHex = toHex(seedSlice);
|
|
47
|
-
|
|
48
|
-
// Import the derived key pair
|
|
49
|
-
const publicKey = await KeyManager.importKeyPair(privateKeyHex);
|
|
50
|
-
|
|
51
|
-
return {
|
|
52
|
-
phrase: mnemonic,
|
|
53
|
-
words: mnemonic.split(' '),
|
|
54
|
-
publicKey,
|
|
55
|
-
};
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* Generate a 24-word recovery phrase for higher security
|
|
60
|
-
*/
|
|
61
|
-
static async generateIdentityWithRecovery24(): Promise<RecoveryPhraseResult> {
|
|
62
|
-
// Generate 256-bit entropy for 24-word mnemonic
|
|
63
|
-
const mnemonic = bip39.generateMnemonic(256);
|
|
64
|
-
|
|
65
|
-
const seed = await bip39.mnemonicToSeed(mnemonic);
|
|
66
|
-
const seedSlice = seed.subarray ? seed.subarray(0, 32) : seed.slice(0, 32);
|
|
67
|
-
const privateKeyHex = toHex(seedSlice);
|
|
68
|
-
const publicKey = await KeyManager.importKeyPair(privateKeyHex);
|
|
69
|
-
|
|
70
|
-
return {
|
|
71
|
-
phrase: mnemonic,
|
|
72
|
-
words: mnemonic.split(' '),
|
|
73
|
-
publicKey,
|
|
74
|
-
};
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
/**
|
|
78
|
-
* Restore an identity from a recovery phrase
|
|
79
|
-
*/
|
|
80
|
-
static async restoreFromPhrase(phrase: string): Promise<string> {
|
|
81
|
-
// Normalize and validate the phrase
|
|
82
|
-
const normalizedPhrase = phrase.trim().toLowerCase();
|
|
83
|
-
|
|
84
|
-
if (!bip39.validateMnemonic(normalizedPhrase)) {
|
|
85
|
-
throw new Error('Invalid recovery phrase. Please check the words and try again.');
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
// Derive the same private key from the mnemonic
|
|
89
|
-
const seed = await bip39.mnemonicToSeed(normalizedPhrase);
|
|
90
|
-
const seedSlice = seed.subarray ? seed.subarray(0, 32) : seed.slice(0, 32);
|
|
91
|
-
const privateKeyHex = toHex(seedSlice);
|
|
92
|
-
|
|
93
|
-
// Import and store the key pair
|
|
94
|
-
const publicKey = await KeyManager.importKeyPair(privateKeyHex);
|
|
95
|
-
|
|
96
|
-
return publicKey;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
/**
|
|
100
|
-
* Validate a recovery phrase without importing it
|
|
101
|
-
*/
|
|
102
|
-
static validatePhrase(phrase: string): boolean {
|
|
103
|
-
const normalizedPhrase = phrase.trim().toLowerCase();
|
|
104
|
-
return bip39.validateMnemonic(normalizedPhrase);
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
/**
|
|
108
|
-
* Get the word list for autocomplete/validation
|
|
109
|
-
*/
|
|
110
|
-
static getWordList(): string[] {
|
|
111
|
-
return bip39.wordlists.english;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
/**
|
|
115
|
-
* Check if a word is valid in the BIP39 word list
|
|
116
|
-
*/
|
|
117
|
-
static isValidWord(word: string): boolean {
|
|
118
|
-
return bip39.wordlists.english.includes(word.toLowerCase());
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
/**
|
|
122
|
-
* Get suggestions for a partial word
|
|
123
|
-
*/
|
|
124
|
-
static getSuggestions(partial: string, limit: number = 5): string[] {
|
|
125
|
-
const lowerPartial = partial.toLowerCase();
|
|
126
|
-
return bip39.wordlists.english
|
|
127
|
-
.filter((word: string) => word.startsWith(lowerPartial))
|
|
128
|
-
.slice(0, limit);
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
/**
|
|
132
|
-
* Derive the public key from a phrase without storing
|
|
133
|
-
* Useful for verification before importing
|
|
134
|
-
*/
|
|
135
|
-
static async derivePublicKeyFromPhrase(phrase: string): Promise<string> {
|
|
136
|
-
const normalizedPhrase = phrase.trim().toLowerCase();
|
|
137
|
-
|
|
138
|
-
if (!bip39.validateMnemonic(normalizedPhrase)) {
|
|
139
|
-
throw new Error('Invalid recovery phrase');
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
const seed = await bip39.mnemonicToSeed(normalizedPhrase);
|
|
143
|
-
const seedSlice = seed.subarray ? seed.subarray(0, 32) : seed.slice(0, 32);
|
|
144
|
-
const privateKeyHex = toHex(seedSlice);
|
|
145
|
-
|
|
146
|
-
return KeyManager.derivePublicKey(privateKeyHex);
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
/**
|
|
150
|
-
* Convert a phrase to its word array
|
|
151
|
-
*/
|
|
152
|
-
static phraseToWords(phrase: string): string[] {
|
|
153
|
-
return phrase.trim().toLowerCase().split(/\s+/);
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
/**
|
|
157
|
-
* Convert a word array to a phrase string
|
|
158
|
-
*/
|
|
159
|
-
static wordsToPhrase(words: string[]): string {
|
|
160
|
-
return words.map(w => w.toLowerCase().trim()).join(' ');
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
export default RecoveryPhraseService;
|
|
165
|
-
|
|
166
|
-
|