@oxyhq/services 5.16.40 → 5.16.41
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/adapters/expo/crypto.js +56 -0
- package/lib/commonjs/adapters/expo/crypto.js.map +1 -0
- package/lib/commonjs/adapters/expo/fetch.js +30 -0
- package/lib/commonjs/adapters/expo/fetch.js.map +1 -0
- package/lib/commonjs/adapters/expo/index.js +48 -0
- package/lib/commonjs/adapters/expo/index.js.map +1 -0
- package/lib/commonjs/adapters/expo/storage.js +201 -0
- package/lib/commonjs/adapters/expo/storage.js.map +1 -0
- package/lib/commonjs/adapters/index.js +41 -0
- package/lib/commonjs/adapters/index.js.map +1 -0
- package/lib/commonjs/adapters/node/crypto.js +40 -0
- package/lib/commonjs/adapters/node/crypto.js.map +1 -0
- package/lib/commonjs/adapters/node/fetch.js +62 -0
- package/lib/commonjs/adapters/node/fetch.js.map +1 -0
- package/lib/commonjs/adapters/node/index.js +34 -0
- package/lib/commonjs/adapters/node/index.js.map +1 -0
- package/lib/commonjs/adapters/node/storage.js +163 -0
- package/lib/commonjs/adapters/node/storage.js.map +1 -0
- package/lib/commonjs/core/identity-session/DeviceManager.js +237 -0
- package/lib/commonjs/core/identity-session/DeviceManager.js.map +1 -0
- package/lib/commonjs/core/identity-session/INTEGRATION_GUIDE.md +287 -0
- package/lib/commonjs/core/identity-session/IdentityManager.js +400 -0
- package/lib/commonjs/core/identity-session/IdentityManager.js.map +1 -0
- package/lib/commonjs/core/identity-session/IdentitySessionCore.js +394 -0
- package/lib/commonjs/core/identity-session/IdentitySessionCore.js.map +1 -0
- package/lib/commonjs/core/identity-session/RefreshManager.js +137 -0
- package/lib/commonjs/core/identity-session/RefreshManager.js.map +1 -0
- package/lib/commonjs/core/identity-session/SessionManager.js +427 -0
- package/lib/commonjs/core/identity-session/SessionManager.js.map +1 -0
- package/lib/commonjs/core/identity-session/createIdentitySessionCore.js +24 -0
- package/lib/commonjs/core/identity-session/createIdentitySessionCore.js.map +1 -0
- package/lib/commonjs/core/identity-session/errors.js +176 -0
- package/lib/commonjs/core/identity-session/errors.js.map +1 -0
- package/lib/commonjs/core/identity-session/index.js +80 -0
- package/lib/commonjs/core/identity-session/index.js.map +1 -0
- package/lib/commonjs/core/identity-session/types.js +2 -0
- package/lib/commonjs/core/identity-session/types.js.map +1 -0
- package/lib/commonjs/core/index.js +2 -21
- package/lib/commonjs/core/index.js.map +1 -1
- package/lib/commonjs/index.js +58 -8
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/models/interfaces.js +7 -0
- package/lib/commonjs/models/interfaces.js.map +1 -1
- package/lib/commonjs/ui/context/OxyContext.js +434 -820
- package/lib/commonjs/ui/context/OxyContext.js.map +1 -1
- package/lib/commonjs/ui/hooks/useAvatarPicker.js +52 -0
- package/lib/commonjs/ui/hooks/useAvatarPicker.js.map +1 -0
- package/lib/commonjs/ui/hooks/useIdentityTransfer.js +125 -0
- package/lib/commonjs/ui/hooks/useIdentityTransfer.js.map +1 -0
- package/lib/commonjs/ui/hooks/useTransferCodesPersistence.js +81 -0
- package/lib/commonjs/ui/hooks/useTransferCodesPersistence.js.map +1 -0
- package/lib/commonjs/ui/screens/AccountCenterScreen.js +7 -2
- package/lib/commonjs/ui/screens/AccountCenterScreen.js.map +1 -1
- package/lib/commonjs/ui/screens/AccountSettingsScreen.js +12 -5
- package/lib/commonjs/ui/screens/AccountSettingsScreen.js.map +1 -1
- package/lib/commonjs/ui/screens/AccountSwitcherScreen.js +2 -2
- package/lib/commonjs/ui/screens/AccountSwitcherScreen.js.map +1 -1
- package/lib/commonjs/ui/screens/ProfileScreen.js +6 -6
- package/lib/commonjs/ui/screens/ProfileScreen.js.map +1 -1
- package/lib/commonjs/ui/utils/sessionHelpers.js +7 -1
- package/lib/commonjs/ui/utils/sessionHelpers.js.map +1 -1
- package/lib/commonjs/utils/index.js +0 -7
- package/lib/commonjs/utils/index.js.map +1 -1
- package/lib/commonjs/utils/sessionUtils.js +8 -1
- package/lib/commonjs/utils/sessionUtils.js.map +1 -1
- package/lib/module/adapters/expo/crypto.js +51 -0
- package/lib/module/adapters/expo/crypto.js.map +1 -0
- package/lib/module/adapters/expo/fetch.js +26 -0
- package/lib/module/adapters/expo/fetch.js.map +1 -0
- package/lib/module/adapters/expo/index.js +45 -0
- package/lib/module/adapters/expo/index.js.map +1 -0
- package/lib/module/adapters/expo/storage.js +198 -0
- package/lib/module/adapters/expo/storage.js.map +1 -0
- package/lib/module/adapters/index.js +38 -0
- package/lib/module/adapters/index.js.map +1 -0
- package/lib/module/adapters/node/crypto.js +36 -0
- package/lib/module/adapters/node/crypto.js.map +1 -0
- package/lib/module/adapters/node/fetch.js +57 -0
- package/lib/module/adapters/node/fetch.js.map +1 -0
- package/lib/module/adapters/node/index.js +31 -0
- package/lib/module/adapters/node/index.js.map +1 -0
- package/lib/module/adapters/node/storage.js +159 -0
- package/lib/module/adapters/node/storage.js.map +1 -0
- package/lib/module/core/identity-session/DeviceManager.js +232 -0
- package/lib/module/core/identity-session/DeviceManager.js.map +1 -0
- package/lib/module/core/identity-session/INTEGRATION_GUIDE.md +287 -0
- package/lib/module/core/identity-session/IdentityManager.js +395 -0
- package/lib/module/core/identity-session/IdentityManager.js.map +1 -0
- package/lib/module/core/identity-session/IdentitySessionCore.js +390 -0
- package/lib/module/core/identity-session/IdentitySessionCore.js.map +1 -0
- package/lib/module/core/identity-session/RefreshManager.js +132 -0
- package/lib/module/core/identity-session/RefreshManager.js.map +1 -0
- package/lib/module/core/identity-session/SessionManager.js +422 -0
- package/lib/module/core/identity-session/SessionManager.js.map +1 -0
- package/lib/module/core/identity-session/createIdentitySessionCore.js +21 -0
- package/lib/module/core/identity-session/createIdentitySessionCore.js.map +1 -0
- package/lib/module/core/identity-session/errors.js +170 -0
- package/lib/module/core/identity-session/errors.js.map +1 -0
- package/lib/module/core/identity-session/index.js +17 -0
- package/lib/module/core/identity-session/index.js.map +1 -0
- package/lib/module/core/identity-session/types.js +2 -0
- package/lib/module/core/identity-session/types.js.map +1 -0
- package/lib/module/core/index.js +2 -3
- package/lib/module/core/index.js.map +1 -1
- package/lib/module/index.js +12 -2
- package/lib/module/index.js.map +1 -1
- package/lib/module/models/interfaces.js +7 -0
- package/lib/module/models/interfaces.js.map +1 -1
- package/lib/module/ui/context/OxyContext.js +436 -822
- package/lib/module/ui/context/OxyContext.js.map +1 -1
- package/lib/module/ui/hooks/useAvatarPicker.js +48 -0
- package/lib/module/ui/hooks/useAvatarPicker.js.map +1 -0
- package/lib/module/ui/hooks/useIdentityTransfer.js +121 -0
- package/lib/module/ui/hooks/useIdentityTransfer.js.map +1 -0
- package/lib/module/ui/hooks/useTransferCodesPersistence.js +77 -0
- package/lib/module/ui/hooks/useTransferCodesPersistence.js.map +1 -0
- package/lib/module/ui/screens/AccountCenterScreen.js +7 -2
- package/lib/module/ui/screens/AccountCenterScreen.js.map +1 -1
- package/lib/module/ui/screens/AccountSettingsScreen.js +12 -5
- package/lib/module/ui/screens/AccountSettingsScreen.js.map +1 -1
- package/lib/module/ui/screens/AccountSwitcherScreen.js +2 -2
- package/lib/module/ui/screens/AccountSwitcherScreen.js.map +1 -1
- package/lib/module/ui/screens/ProfileScreen.js +6 -6
- package/lib/module/ui/screens/ProfileScreen.js.map +1 -1
- package/lib/module/ui/utils/sessionHelpers.js +7 -1
- package/lib/module/ui/utils/sessionHelpers.js.map +1 -1
- package/lib/module/utils/index.js +2 -1
- package/lib/module/utils/index.js.map +1 -1
- package/lib/module/utils/sessionUtils.js +8 -1
- package/lib/module/utils/sessionUtils.js.map +1 -1
- package/lib/typescript/adapters/expo/crypto.d.ts +17 -0
- package/lib/typescript/adapters/expo/crypto.d.ts.map +1 -0
- package/lib/typescript/adapters/expo/fetch.d.ts +16 -0
- package/lib/typescript/adapters/expo/fetch.d.ts.map +1 -0
- package/lib/typescript/adapters/expo/index.d.ts +23 -0
- package/lib/typescript/adapters/expo/index.d.ts.map +1 -0
- package/lib/typescript/adapters/expo/storage.d.ts +23 -0
- package/lib/typescript/adapters/expo/storage.d.ts.map +1 -0
- package/lib/typescript/adapters/index.d.ts +13 -0
- package/lib/typescript/adapters/index.d.ts.map +1 -0
- package/lib/typescript/adapters/node/crypto.d.ts +17 -0
- package/lib/typescript/adapters/node/crypto.d.ts.map +1 -0
- package/lib/typescript/adapters/node/fetch.d.ts +16 -0
- package/lib/typescript/adapters/node/fetch.d.ts.map +1 -0
- package/lib/typescript/adapters/node/index.d.ts +23 -0
- package/lib/typescript/adapters/node/index.d.ts.map +1 -0
- package/lib/typescript/adapters/node/storage.d.ts +23 -0
- package/lib/typescript/adapters/node/storage.d.ts.map +1 -0
- package/lib/typescript/core/identity-session/DeviceManager.d.ts +64 -0
- package/lib/typescript/core/identity-session/DeviceManager.d.ts.map +1 -0
- package/lib/typescript/core/identity-session/IdentityManager.d.ts +88 -0
- package/lib/typescript/core/identity-session/IdentityManager.d.ts.map +1 -0
- package/lib/typescript/core/identity-session/IdentitySessionCore.d.ts +141 -0
- package/lib/typescript/core/identity-session/IdentitySessionCore.d.ts.map +1 -0
- package/lib/typescript/core/identity-session/RefreshManager.d.ts +36 -0
- package/lib/typescript/core/identity-session/RefreshManager.d.ts.map +1 -0
- package/lib/typescript/core/identity-session/SessionManager.d.ts +104 -0
- package/lib/typescript/core/identity-session/SessionManager.d.ts.map +1 -0
- package/lib/typescript/core/identity-session/createIdentitySessionCore.d.ts +11 -0
- package/lib/typescript/core/identity-session/createIdentitySessionCore.d.ts.map +1 -0
- package/lib/typescript/core/identity-session/errors.d.ts +63 -0
- package/lib/typescript/core/identity-session/errors.d.ts.map +1 -0
- package/lib/typescript/core/identity-session/index.d.ts +14 -0
- package/lib/typescript/core/identity-session/index.d.ts.map +1 -0
- package/lib/typescript/core/identity-session/types.d.ts +196 -0
- package/lib/typescript/core/identity-session/types.d.ts.map +1 -0
- package/lib/typescript/core/index.d.ts +1 -3
- package/lib/typescript/core/index.d.ts.map +1 -1
- package/lib/typescript/core/mixins/index.d.ts +2 -2
- package/lib/typescript/index.d.ts +3 -2
- package/lib/typescript/index.d.ts.map +1 -1
- package/lib/typescript/models/interfaces.d.ts +5 -36
- package/lib/typescript/models/interfaces.d.ts.map +1 -1
- package/lib/typescript/models/session.d.ts +3 -16
- package/lib/typescript/models/session.d.ts.map +1 -1
- package/lib/typescript/ui/context/OxyContext.d.ts +2 -25
- package/lib/typescript/ui/context/OxyContext.d.ts.map +1 -1
- package/lib/typescript/ui/hooks/mutations/useAccountMutations.d.ts +7 -8
- package/lib/typescript/ui/hooks/mutations/useAccountMutations.d.ts.map +1 -1
- package/lib/typescript/ui/hooks/mutations/useServicesMutations.d.ts +1 -1
- package/lib/typescript/ui/hooks/mutations/useServicesMutations.d.ts.map +1 -1
- package/lib/typescript/ui/hooks/queries/useAccountQueries.d.ts +5 -5
- package/lib/typescript/ui/hooks/queries/useAccountQueries.d.ts.map +1 -1
- package/lib/typescript/ui/hooks/useAvatarPicker.d.ts +18 -0
- package/lib/typescript/ui/hooks/useAvatarPicker.d.ts.map +1 -0
- package/lib/typescript/ui/hooks/useIdentityTransfer.d.ts +24 -0
- package/lib/typescript/ui/hooks/useIdentityTransfer.d.ts.map +1 -0
- package/lib/typescript/ui/hooks/useTransferCodesPersistence.d.ts +6 -0
- package/lib/typescript/ui/hooks/useTransferCodesPersistence.d.ts.map +1 -0
- package/lib/typescript/ui/screens/AccountCenterScreen.d.ts.map +1 -1
- package/lib/typescript/ui/screens/AccountSettingsScreen.d.ts.map +1 -1
- package/lib/typescript/ui/utils/sessionHelpers.d.ts +1 -0
- package/lib/typescript/ui/utils/sessionHelpers.d.ts.map +1 -1
- package/lib/typescript/utils/index.d.ts +0 -2
- package/lib/typescript/utils/index.d.ts.map +1 -1
- package/lib/typescript/utils/sessionUtils.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/adapters/expo/crypto.ts +55 -0
- package/src/adapters/expo/fetch.ts +28 -0
- package/src/adapters/expo/index.ts +51 -0
- package/src/adapters/expo/storage.ts +228 -0
- package/src/adapters/index.ts +40 -0
- package/src/adapters/node/crypto.ts +39 -0
- package/src/adapters/node/fetch.ts +59 -0
- package/src/adapters/node/index.ts +37 -0
- package/src/adapters/node/storage.ts +170 -0
- package/src/core/identity-session/DeviceManager.ts +273 -0
- package/src/core/identity-session/INTEGRATION_GUIDE.md +287 -0
- package/src/core/identity-session/IdentityManager.ts +474 -0
- package/src/core/identity-session/IdentitySessionCore.ts +464 -0
- package/src/core/identity-session/RefreshManager.ts +189 -0
- package/src/core/identity-session/SessionManager.ts +500 -0
- package/src/core/identity-session/createIdentitySessionCore.ts +19 -0
- package/src/core/identity-session/errors.ts +197 -0
- package/src/core/identity-session/index.ts +15 -0
- package/src/core/identity-session/types.ts +188 -0
- package/src/core/index.ts +3 -4
- package/src/index.ts +28 -3
- package/src/models/interfaces.ts +12 -39
- package/src/models/session.ts +6 -16
- package/src/ui/context/OxyContext.tsx +442 -871
- package/src/ui/hooks/auth/index.ts +1 -0
- package/src/ui/hooks/useAvatarPicker.ts +62 -0
- package/src/ui/hooks/useIdentityTransfer.ts +135 -0
- package/src/ui/hooks/useTransferCodesPersistence.ts +80 -0
- package/src/ui/screens/AccountCenterScreen.tsx +7 -2
- package/src/ui/screens/AccountSettingsScreen.tsx +15 -8
- package/src/ui/screens/AccountSwitcherScreen.tsx +2 -2
- package/src/ui/screens/ProfileScreen.tsx +10 -10
- package/src/ui/utils/sessionHelpers.ts +7 -0
- package/src/utils/index.ts +1 -2
- package/src/utils/sessionUtils.ts +8 -0
- package/lib/commonjs/ui/context/hooks/useAuthOperations.js +0 -732
- package/lib/commonjs/ui/context/hooks/useAuthOperations.js.map +0 -1
- package/lib/commonjs/ui/context/hooks/useDeviceManagement.js +0 -73
- package/lib/commonjs/ui/context/hooks/useDeviceManagement.js.map +0 -1
- package/lib/commonjs/ui/hooks/useDeviceManagement.js +0 -73
- package/lib/commonjs/ui/hooks/useDeviceManagement.js.map +0 -1
- package/lib/commonjs/ui/hooks/useSessionManagement.js +0 -281
- package/lib/commonjs/ui/hooks/useSessionManagement.js.map +0 -1
- package/lib/commonjs/utils/deviceManager.js +0 -177
- package/lib/commonjs/utils/deviceManager.js.map +0 -1
- package/lib/module/ui/context/hooks/useAuthOperations.js +0 -726
- package/lib/module/ui/context/hooks/useAuthOperations.js.map +0 -1
- package/lib/module/ui/context/hooks/useDeviceManagement.js +0 -68
- package/lib/module/ui/context/hooks/useDeviceManagement.js.map +0 -1
- package/lib/module/ui/hooks/useDeviceManagement.js +0 -68
- package/lib/module/ui/hooks/useDeviceManagement.js.map +0 -1
- package/lib/module/ui/hooks/useSessionManagement.js +0 -276
- package/lib/module/ui/hooks/useSessionManagement.js.map +0 -1
- package/lib/module/utils/deviceManager.js +0 -171
- package/lib/module/utils/deviceManager.js.map +0 -1
- package/lib/typescript/ui/context/hooks/useAuthOperations.d.ts +0 -59
- package/lib/typescript/ui/context/hooks/useAuthOperations.d.ts.map +0 -1
- package/lib/typescript/ui/context/hooks/useDeviceManagement.d.ts +0 -27
- package/lib/typescript/ui/context/hooks/useDeviceManagement.d.ts.map +0 -1
- package/lib/typescript/ui/hooks/useDeviceManagement.d.ts +0 -27
- package/lib/typescript/ui/hooks/useDeviceManagement.d.ts.map +0 -1
- package/lib/typescript/ui/hooks/useSessionManagement.d.ts +0 -41
- package/lib/typescript/ui/hooks/useSessionManagement.d.ts.map +0 -1
- package/lib/typescript/utils/deviceManager.d.ts +0 -66
- package/lib/typescript/utils/deviceManager.d.ts.map +0 -1
- package/src/ui/context/hooks/useAuthOperations.ts +0 -801
- package/src/ui/context/hooks/useDeviceManagement.ts +0 -108
- package/src/ui/hooks/useDeviceManagement.ts +0 -108
- package/src/ui/hooks/useSessionManagement.ts +0 -401
- package/src/utils/deviceManager.ts +0 -198
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Identity and Session Error Codes
|
|
3
|
+
*
|
|
4
|
+
* Aligned with backend error codes for consistency across the ecosystem
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
export const IdentitySessionErrorCodes = {
|
|
8
|
+
// Authentication errors
|
|
9
|
+
UNAUTHORIZED: 'UNAUTHORIZED',
|
|
10
|
+
FORBIDDEN: 'FORBIDDEN',
|
|
11
|
+
INVALID_TOKEN: 'INVALID_TOKEN',
|
|
12
|
+
MISSING_TOKEN: 'MISSING_TOKEN',
|
|
13
|
+
TOKEN_EXPIRED: 'TOKEN_EXPIRED',
|
|
14
|
+
TOKEN_NOT_YET_VALID: 'TOKEN_NOT_YET_VALID',
|
|
15
|
+
INVALID_SIGNATURE: 'INVALID_SIGNATURE',
|
|
16
|
+
MALFORMED_TOKEN: 'MALFORMED_TOKEN',
|
|
17
|
+
INVALID_SESSION: 'INVALID_SESSION',
|
|
18
|
+
|
|
19
|
+
// Identity errors
|
|
20
|
+
IDENTITY_NOT_FOUND: 'IDENTITY_NOT_FOUND',
|
|
21
|
+
IDENTITY_ALREADY_EXISTS: 'IDENTITY_ALREADY_EXISTS',
|
|
22
|
+
IDENTITY_NOT_AVAILABLE_ON_WEB: 'IDENTITY_NOT_AVAILABLE_ON_WEB',
|
|
23
|
+
IDENTITY_NOT_SYNCED: 'IDENTITY_NOT_SYNCED',
|
|
24
|
+
INVALID_PUBLIC_KEY: 'INVALID_PUBLIC_KEY',
|
|
25
|
+
INVALID_PRIVATE_KEY: 'INVALID_PRIVATE_KEY',
|
|
26
|
+
IDENTITY_CREATION_FAILED: 'IDENTITY_CREATION_FAILED',
|
|
27
|
+
IDENTITY_IMPORT_FAILED: 'IDENTITY_IMPORT_FAILED',
|
|
28
|
+
IDENTITY_DELETE_FAILED: 'IDENTITY_DELETE_FAILED',
|
|
29
|
+
BACKUP_DECRYPTION_FAILED: 'BACKUP_DECRYPTION_FAILED',
|
|
30
|
+
|
|
31
|
+
// Session errors
|
|
32
|
+
SESSION_NOT_FOUND: 'SESSION_NOT_FOUND',
|
|
33
|
+
SESSION_EXPIRED: 'SESSION_EXPIRED',
|
|
34
|
+
SESSION_INVALID: 'SESSION_INVALID',
|
|
35
|
+
SESSION_CREATION_FAILED: 'SESSION_CREATION_FAILED',
|
|
36
|
+
SESSION_REFRESH_FAILED: 'SESSION_REFRESH_FAILED',
|
|
37
|
+
|
|
38
|
+
// Device errors
|
|
39
|
+
DEVICE_NOT_FOUND: 'DEVICE_NOT_FOUND',
|
|
40
|
+
DEVICE_CREATION_FAILED: 'DEVICE_CREATION_FAILED',
|
|
41
|
+
|
|
42
|
+
// Validation errors
|
|
43
|
+
VALIDATION_ERROR: 'VALIDATION_ERROR',
|
|
44
|
+
BAD_REQUEST: 'BAD_REQUEST',
|
|
45
|
+
MISSING_PARAMETER: 'MISSING_PARAMETER',
|
|
46
|
+
INVALID_FORMAT: 'INVALID_FORMAT',
|
|
47
|
+
|
|
48
|
+
// Resource errors
|
|
49
|
+
NOT_FOUND: 'NOT_FOUND',
|
|
50
|
+
ALREADY_EXISTS: 'ALREADY_EXISTS',
|
|
51
|
+
CONFLICT: 'CONFLICT',
|
|
52
|
+
|
|
53
|
+
// Server errors
|
|
54
|
+
INTERNAL_ERROR: 'INTERNAL_ERROR',
|
|
55
|
+
SERVICE_UNAVAILABLE: 'SERVICE_UNAVAILABLE',
|
|
56
|
+
TIMEOUT: 'TIMEOUT',
|
|
57
|
+
|
|
58
|
+
// Network errors
|
|
59
|
+
NETWORK_ERROR: 'NETWORK_ERROR',
|
|
60
|
+
CONNECTION_FAILED: 'CONNECTION_FAILED',
|
|
61
|
+
|
|
62
|
+
// Storage errors
|
|
63
|
+
STORAGE_ERROR: 'STORAGE_ERROR',
|
|
64
|
+
STORAGE_NOT_AVAILABLE: 'STORAGE_NOT_AVAILABLE',
|
|
65
|
+
SECURE_STORAGE_NOT_AVAILABLE: 'SECURE_STORAGE_NOT_AVAILABLE',
|
|
66
|
+
|
|
67
|
+
// Unknown
|
|
68
|
+
UNKNOWN_ERROR: 'UNKNOWN_ERROR',
|
|
69
|
+
} as const;
|
|
70
|
+
|
|
71
|
+
export type IdentitySessionErrorCode = typeof IdentitySessionErrorCodes[keyof typeof IdentitySessionErrorCodes];
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* IdentitySessionError - Custom error class for identity and session operations
|
|
75
|
+
*/
|
|
76
|
+
export class IdentitySessionError extends Error {
|
|
77
|
+
public readonly code: IdentitySessionErrorCode;
|
|
78
|
+
public readonly statusCode: number;
|
|
79
|
+
|
|
80
|
+
constructor(
|
|
81
|
+
message: string,
|
|
82
|
+
code: IdentitySessionErrorCode = IdentitySessionErrorCodes.UNKNOWN_ERROR,
|
|
83
|
+
statusCode: number = 500
|
|
84
|
+
) {
|
|
85
|
+
super(message);
|
|
86
|
+
this.name = 'IdentitySessionError';
|
|
87
|
+
this.code = code;
|
|
88
|
+
this.statusCode = statusCode;
|
|
89
|
+
Object.setPrototypeOf(this, IdentitySessionError.prototype);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Create error from code
|
|
95
|
+
*/
|
|
96
|
+
export function createIdentitySessionError(
|
|
97
|
+
code: IdentitySessionErrorCode,
|
|
98
|
+
message?: string,
|
|
99
|
+
statusCode?: number
|
|
100
|
+
): IdentitySessionError {
|
|
101
|
+
const defaultMessages: Record<IdentitySessionErrorCode, string> = {
|
|
102
|
+
[IdentitySessionErrorCodes.UNAUTHORIZED]: 'Unauthorized',
|
|
103
|
+
[IdentitySessionErrorCodes.FORBIDDEN]: 'Forbidden',
|
|
104
|
+
[IdentitySessionErrorCodes.INVALID_TOKEN]: 'Invalid token',
|
|
105
|
+
[IdentitySessionErrorCodes.MISSING_TOKEN]: 'Missing token',
|
|
106
|
+
[IdentitySessionErrorCodes.TOKEN_EXPIRED]: 'Token has expired',
|
|
107
|
+
[IdentitySessionErrorCodes.TOKEN_NOT_YET_VALID]: 'Token not yet valid',
|
|
108
|
+
[IdentitySessionErrorCodes.INVALID_SIGNATURE]: 'Token signature is invalid',
|
|
109
|
+
[IdentitySessionErrorCodes.MALFORMED_TOKEN]: 'Token format is invalid',
|
|
110
|
+
[IdentitySessionErrorCodes.INVALID_SESSION]: 'Invalid session',
|
|
111
|
+
[IdentitySessionErrorCodes.IDENTITY_NOT_FOUND]: 'Identity not found',
|
|
112
|
+
[IdentitySessionErrorCodes.IDENTITY_ALREADY_EXISTS]: 'Identity already exists',
|
|
113
|
+
[IdentitySessionErrorCodes.IDENTITY_NOT_AVAILABLE_ON_WEB]: 'Identity operations are only available on native platforms',
|
|
114
|
+
[IdentitySessionErrorCodes.IDENTITY_NOT_SYNCED]: 'Identity not synced with server',
|
|
115
|
+
[IdentitySessionErrorCodes.INVALID_PUBLIC_KEY]: 'Invalid public key',
|
|
116
|
+
[IdentitySessionErrorCodes.INVALID_PRIVATE_KEY]: 'Invalid private key',
|
|
117
|
+
[IdentitySessionErrorCodes.IDENTITY_CREATION_FAILED]: 'Failed to create identity',
|
|
118
|
+
[IdentitySessionErrorCodes.IDENTITY_IMPORT_FAILED]: 'Failed to import identity',
|
|
119
|
+
[IdentitySessionErrorCodes.IDENTITY_DELETE_FAILED]: 'Failed to delete identity',
|
|
120
|
+
[IdentitySessionErrorCodes.BACKUP_DECRYPTION_FAILED]: 'Failed to decrypt backup',
|
|
121
|
+
[IdentitySessionErrorCodes.SESSION_NOT_FOUND]: 'Session not found',
|
|
122
|
+
[IdentitySessionErrorCodes.SESSION_EXPIRED]: 'Session expired',
|
|
123
|
+
[IdentitySessionErrorCodes.SESSION_INVALID]: 'Session invalid',
|
|
124
|
+
[IdentitySessionErrorCodes.SESSION_CREATION_FAILED]: 'Failed to create session',
|
|
125
|
+
[IdentitySessionErrorCodes.SESSION_REFRESH_FAILED]: 'Failed to refresh session',
|
|
126
|
+
[IdentitySessionErrorCodes.DEVICE_NOT_FOUND]: 'Device not found',
|
|
127
|
+
[IdentitySessionErrorCodes.DEVICE_CREATION_FAILED]: 'Failed to create device',
|
|
128
|
+
[IdentitySessionErrorCodes.VALIDATION_ERROR]: 'Validation error',
|
|
129
|
+
[IdentitySessionErrorCodes.BAD_REQUEST]: 'Bad request',
|
|
130
|
+
[IdentitySessionErrorCodes.MISSING_PARAMETER]: 'Missing required parameter',
|
|
131
|
+
[IdentitySessionErrorCodes.INVALID_FORMAT]: 'Invalid format',
|
|
132
|
+
[IdentitySessionErrorCodes.NOT_FOUND]: 'Resource not found',
|
|
133
|
+
[IdentitySessionErrorCodes.ALREADY_EXISTS]: 'Resource already exists',
|
|
134
|
+
[IdentitySessionErrorCodes.CONFLICT]: 'Conflict',
|
|
135
|
+
[IdentitySessionErrorCodes.INTERNAL_ERROR]: 'Internal server error',
|
|
136
|
+
[IdentitySessionErrorCodes.SERVICE_UNAVAILABLE]: 'Service unavailable',
|
|
137
|
+
[IdentitySessionErrorCodes.TIMEOUT]: 'Request timeout',
|
|
138
|
+
[IdentitySessionErrorCodes.NETWORK_ERROR]: 'Network error',
|
|
139
|
+
[IdentitySessionErrorCodes.CONNECTION_FAILED]: 'Connection failed',
|
|
140
|
+
[IdentitySessionErrorCodes.STORAGE_ERROR]: 'Storage error',
|
|
141
|
+
[IdentitySessionErrorCodes.STORAGE_NOT_AVAILABLE]: 'Storage not available',
|
|
142
|
+
[IdentitySessionErrorCodes.SECURE_STORAGE_NOT_AVAILABLE]: 'Secure storage not available',
|
|
143
|
+
[IdentitySessionErrorCodes.UNKNOWN_ERROR]: 'Unknown error',
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
const defaultStatusCodes: Record<IdentitySessionErrorCode, number> = {
|
|
147
|
+
[IdentitySessionErrorCodes.UNAUTHORIZED]: 401,
|
|
148
|
+
[IdentitySessionErrorCodes.FORBIDDEN]: 403,
|
|
149
|
+
[IdentitySessionErrorCodes.INVALID_TOKEN]: 401,
|
|
150
|
+
[IdentitySessionErrorCodes.MISSING_TOKEN]: 401,
|
|
151
|
+
[IdentitySessionErrorCodes.TOKEN_EXPIRED]: 401,
|
|
152
|
+
[IdentitySessionErrorCodes.TOKEN_NOT_YET_VALID]: 401,
|
|
153
|
+
[IdentitySessionErrorCodes.INVALID_SIGNATURE]: 401,
|
|
154
|
+
[IdentitySessionErrorCodes.MALFORMED_TOKEN]: 401,
|
|
155
|
+
[IdentitySessionErrorCodes.INVALID_SESSION]: 401,
|
|
156
|
+
[IdentitySessionErrorCodes.IDENTITY_NOT_FOUND]: 404,
|
|
157
|
+
[IdentitySessionErrorCodes.IDENTITY_ALREADY_EXISTS]: 409,
|
|
158
|
+
[IdentitySessionErrorCodes.IDENTITY_NOT_AVAILABLE_ON_WEB]: 400,
|
|
159
|
+
[IdentitySessionErrorCodes.IDENTITY_NOT_SYNCED]: 400,
|
|
160
|
+
[IdentitySessionErrorCodes.INVALID_PUBLIC_KEY]: 400,
|
|
161
|
+
[IdentitySessionErrorCodes.INVALID_PRIVATE_KEY]: 400,
|
|
162
|
+
[IdentitySessionErrorCodes.IDENTITY_CREATION_FAILED]: 500,
|
|
163
|
+
[IdentitySessionErrorCodes.IDENTITY_IMPORT_FAILED]: 500,
|
|
164
|
+
[IdentitySessionErrorCodes.IDENTITY_DELETE_FAILED]: 500,
|
|
165
|
+
[IdentitySessionErrorCodes.BACKUP_DECRYPTION_FAILED]: 400,
|
|
166
|
+
[IdentitySessionErrorCodes.SESSION_NOT_FOUND]: 404,
|
|
167
|
+
[IdentitySessionErrorCodes.SESSION_EXPIRED]: 401,
|
|
168
|
+
[IdentitySessionErrorCodes.SESSION_INVALID]: 401,
|
|
169
|
+
[IdentitySessionErrorCodes.SESSION_CREATION_FAILED]: 500,
|
|
170
|
+
[IdentitySessionErrorCodes.SESSION_REFRESH_FAILED]: 500,
|
|
171
|
+
[IdentitySessionErrorCodes.DEVICE_NOT_FOUND]: 404,
|
|
172
|
+
[IdentitySessionErrorCodes.DEVICE_CREATION_FAILED]: 500,
|
|
173
|
+
[IdentitySessionErrorCodes.VALIDATION_ERROR]: 400,
|
|
174
|
+
[IdentitySessionErrorCodes.BAD_REQUEST]: 400,
|
|
175
|
+
[IdentitySessionErrorCodes.MISSING_PARAMETER]: 400,
|
|
176
|
+
[IdentitySessionErrorCodes.INVALID_FORMAT]: 400,
|
|
177
|
+
[IdentitySessionErrorCodes.NOT_FOUND]: 404,
|
|
178
|
+
[IdentitySessionErrorCodes.ALREADY_EXISTS]: 409,
|
|
179
|
+
[IdentitySessionErrorCodes.CONFLICT]: 409,
|
|
180
|
+
[IdentitySessionErrorCodes.INTERNAL_ERROR]: 500,
|
|
181
|
+
[IdentitySessionErrorCodes.SERVICE_UNAVAILABLE]: 503,
|
|
182
|
+
[IdentitySessionErrorCodes.TIMEOUT]: 408,
|
|
183
|
+
[IdentitySessionErrorCodes.NETWORK_ERROR]: 503,
|
|
184
|
+
[IdentitySessionErrorCodes.CONNECTION_FAILED]: 503,
|
|
185
|
+
[IdentitySessionErrorCodes.STORAGE_ERROR]: 500,
|
|
186
|
+
[IdentitySessionErrorCodes.STORAGE_NOT_AVAILABLE]: 503,
|
|
187
|
+
[IdentitySessionErrorCodes.SECURE_STORAGE_NOT_AVAILABLE]: 503,
|
|
188
|
+
[IdentitySessionErrorCodes.UNKNOWN_ERROR]: 500,
|
|
189
|
+
};
|
|
190
|
+
|
|
191
|
+
return new IdentitySessionError(
|
|
192
|
+
message || defaultMessages[code],
|
|
193
|
+
code,
|
|
194
|
+
statusCode || defaultStatusCodes[code]
|
|
195
|
+
);
|
|
196
|
+
}
|
|
197
|
+
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Identity Session Core
|
|
3
|
+
*
|
|
4
|
+
* Main entry point for identity and session management
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
export { IdentitySessionCore } from './IdentitySessionCore';
|
|
8
|
+
export { IdentityManager } from './IdentityManager';
|
|
9
|
+
export { SessionManager } from './SessionManager';
|
|
10
|
+
export { DeviceManager } from './DeviceManager';
|
|
11
|
+
export { RefreshManager } from './RefreshManager';
|
|
12
|
+
export { createIdentitySessionCore } from './createIdentitySessionCore';
|
|
13
|
+
export * from './types';
|
|
14
|
+
export * from './errors';
|
|
15
|
+
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Core Identity and Session Types
|
|
3
|
+
*
|
|
4
|
+
* These types are aligned with backend models (IUser, ISession) to ensure
|
|
5
|
+
* consistency across the entire ecosystem.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Identity - Aligned with IUser from backend
|
|
10
|
+
* Represents a user's cryptographic identity
|
|
11
|
+
*/
|
|
12
|
+
export interface Identity {
|
|
13
|
+
id: string; // MongoDB ObjectId (24 hex chars) - PRIMARY IDENTIFIER
|
|
14
|
+
publicKey: string; // ECDSA secp256k1 public key (130 hex chars) - LOOKUP KEY
|
|
15
|
+
username?: string;
|
|
16
|
+
email?: string;
|
|
17
|
+
avatar?: string; // file id
|
|
18
|
+
verified?: boolean;
|
|
19
|
+
language?: string;
|
|
20
|
+
privacySettings?: {
|
|
21
|
+
isPrivateAccount?: boolean;
|
|
22
|
+
hideOnlineStatus?: boolean;
|
|
23
|
+
hideLastSeen?: boolean;
|
|
24
|
+
profileVisibility?: boolean;
|
|
25
|
+
loginAlerts?: boolean;
|
|
26
|
+
blockScreenshots?: boolean;
|
|
27
|
+
login?: boolean;
|
|
28
|
+
biometricLogin?: boolean;
|
|
29
|
+
showActivity?: boolean;
|
|
30
|
+
allowTagging?: boolean;
|
|
31
|
+
allowMentions?: boolean;
|
|
32
|
+
hideReadReceipts?: boolean;
|
|
33
|
+
allowDirectMessages?: boolean;
|
|
34
|
+
dataSharing?: boolean;
|
|
35
|
+
locationSharing?: boolean;
|
|
36
|
+
analyticsSharing?: boolean;
|
|
37
|
+
sensitiveContent?: boolean;
|
|
38
|
+
autoFilter?: boolean;
|
|
39
|
+
muteKeywords?: boolean;
|
|
40
|
+
[key: string]: unknown;
|
|
41
|
+
};
|
|
42
|
+
name?: {
|
|
43
|
+
first?: string;
|
|
44
|
+
last?: string;
|
|
45
|
+
full?: string; // virtual, not stored in DB
|
|
46
|
+
[key: string]: unknown;
|
|
47
|
+
};
|
|
48
|
+
bio?: string;
|
|
49
|
+
description?: string;
|
|
50
|
+
locations?: Array<{
|
|
51
|
+
id: string;
|
|
52
|
+
name: string;
|
|
53
|
+
label?: string;
|
|
54
|
+
type?: 'home' | 'work' | 'school' | 'other';
|
|
55
|
+
address?: {
|
|
56
|
+
street?: string;
|
|
57
|
+
streetNumber?: string;
|
|
58
|
+
streetDetails?: string;
|
|
59
|
+
postalCode?: string;
|
|
60
|
+
city?: string;
|
|
61
|
+
state?: string;
|
|
62
|
+
country?: string;
|
|
63
|
+
formattedAddress?: string;
|
|
64
|
+
};
|
|
65
|
+
coordinates?: {
|
|
66
|
+
lat: number;
|
|
67
|
+
lon: number;
|
|
68
|
+
};
|
|
69
|
+
metadata?: {
|
|
70
|
+
placeId?: string;
|
|
71
|
+
osmId?: string;
|
|
72
|
+
osmType?: string;
|
|
73
|
+
countryCode?: string;
|
|
74
|
+
timezone?: string;
|
|
75
|
+
};
|
|
76
|
+
createdAt?: string;
|
|
77
|
+
updatedAt?: string;
|
|
78
|
+
}>;
|
|
79
|
+
links?: string[];
|
|
80
|
+
linksMetadata?: Array<{
|
|
81
|
+
url: string;
|
|
82
|
+
title: string;
|
|
83
|
+
description: string;
|
|
84
|
+
image?: string;
|
|
85
|
+
}>;
|
|
86
|
+
_count?: {
|
|
87
|
+
followers?: number;
|
|
88
|
+
following?: number;
|
|
89
|
+
};
|
|
90
|
+
accountExpiresAfterInactivityDays?: number | null;
|
|
91
|
+
createdAt?: string;
|
|
92
|
+
updatedAt?: string;
|
|
93
|
+
[key: string]: unknown;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Session - Aligned with ISession from backend
|
|
98
|
+
* Represents an active user session
|
|
99
|
+
*/
|
|
100
|
+
export interface Session {
|
|
101
|
+
sessionId: string; // UUID
|
|
102
|
+
userId: string; // MongoDB ObjectId (never publicKey)
|
|
103
|
+
deviceId: string;
|
|
104
|
+
expiresAt: string; // ISO date string
|
|
105
|
+
lastActive: string; // ISO date string
|
|
106
|
+
deviceInfo: DeviceInfo;
|
|
107
|
+
isActive?: boolean;
|
|
108
|
+
accessToken?: string;
|
|
109
|
+
refreshToken?: string;
|
|
110
|
+
isCurrent?: boolean;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* DeviceInfo - Aligned with ISession.deviceInfo
|
|
115
|
+
*/
|
|
116
|
+
export interface DeviceInfo {
|
|
117
|
+
deviceName?: string;
|
|
118
|
+
deviceType: string; // mobile, desktop, tablet, etc.
|
|
119
|
+
platform: string; // ios, android, web, etc.
|
|
120
|
+
browser?: string;
|
|
121
|
+
os?: string;
|
|
122
|
+
lastActive: string; // ISO date string
|
|
123
|
+
ipAddress?: string;
|
|
124
|
+
userAgent?: string;
|
|
125
|
+
location?: string;
|
|
126
|
+
fingerprint?: string;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* Device - Represents device information
|
|
131
|
+
*/
|
|
132
|
+
export interface Device {
|
|
133
|
+
deviceId: string;
|
|
134
|
+
deviceName?: string;
|
|
135
|
+
deviceType: string;
|
|
136
|
+
platform: string;
|
|
137
|
+
browser?: string;
|
|
138
|
+
os?: string;
|
|
139
|
+
fingerprint?: string;
|
|
140
|
+
createdAt?: string;
|
|
141
|
+
updatedAt?: string;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* DeviceSession - Aligned with backend device session model
|
|
146
|
+
*/
|
|
147
|
+
export interface DeviceSession {
|
|
148
|
+
deviceId: string;
|
|
149
|
+
deviceName?: string;
|
|
150
|
+
deviceType: string;
|
|
151
|
+
platform: string;
|
|
152
|
+
browser?: string;
|
|
153
|
+
os?: string;
|
|
154
|
+
lastActive: string;
|
|
155
|
+
fingerprint?: string;
|
|
156
|
+
createdAt?: string;
|
|
157
|
+
updatedAt?: string;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* BackupData - Encrypted backup data for identity
|
|
162
|
+
*/
|
|
163
|
+
export interface BackupData {
|
|
164
|
+
encrypted: string; // Base64-encoded encrypted private key
|
|
165
|
+
salt: string; // Hex-encoded salt used for key derivation
|
|
166
|
+
iv: string; // Hex-encoded initialization vector
|
|
167
|
+
publicKey: string; // Public key associated with the encrypted private key
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* IdentitySessionEvent - Events emitted by the core
|
|
172
|
+
*/
|
|
173
|
+
export type IdentitySessionEvent =
|
|
174
|
+
| { type: 'identity:created'; identity: Identity }
|
|
175
|
+
| { type: 'identity:imported'; identity: Identity }
|
|
176
|
+
| { type: 'identity:deleted' }
|
|
177
|
+
| { type: 'identity:synced'; identity: Identity }
|
|
178
|
+
| { type: 'session:created'; session: Session }
|
|
179
|
+
| { type: 'session:refreshed'; session: Session }
|
|
180
|
+
| { type: 'session:invalidated'; sessionId: string }
|
|
181
|
+
| { type: 'session:all-invalidated' }
|
|
182
|
+
| { type: 'device:changed'; device: Device };
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
* Platform type
|
|
186
|
+
*/
|
|
187
|
+
export type Platform = 'native' | 'web' | 'node';
|
|
188
|
+
|
package/src/core/index.ts
CHANGED
|
@@ -10,12 +10,11 @@ export { OxyServices, OxyAuthenticationError, OxyAuthenticationTimeoutError } fr
|
|
|
10
10
|
export { OXY_CLOUD_URL, oxyClient } from './OxyServices';
|
|
11
11
|
|
|
12
12
|
// Re-export all models and types for convenience
|
|
13
|
+
// Note: DeviceSession is defined in models/interfaces, not re-exported from models/session to avoid conflicts
|
|
13
14
|
export * from '../models/interfaces';
|
|
14
|
-
export
|
|
15
|
+
export type { Session, DeviceInfo, Device } from '../models/session';
|
|
15
16
|
|
|
16
|
-
//
|
|
17
|
-
export { DeviceManager } from '../utils/deviceManager';
|
|
18
|
-
export type { DeviceFingerprint, StoredDeviceInfo } from '../utils/deviceManager';
|
|
17
|
+
// Device management - use IdentitySessionCore.getDeviceManager() instead
|
|
19
18
|
|
|
20
19
|
// Export language utilities
|
|
21
20
|
export {
|
package/src/index.ts
CHANGED
|
@@ -19,6 +19,32 @@ export {
|
|
|
19
19
|
// Core exports
|
|
20
20
|
export { OxyServices, OxyAuthenticationError, OxyAuthenticationTimeoutError } from './core';
|
|
21
21
|
export { OXY_CLOUD_URL, oxyClient } from './core';
|
|
22
|
+
|
|
23
|
+
// Identity Session Core exports
|
|
24
|
+
export {
|
|
25
|
+
IdentitySessionCore,
|
|
26
|
+
IdentityManager,
|
|
27
|
+
SessionManager,
|
|
28
|
+
RefreshManager,
|
|
29
|
+
createIdentitySessionCore,
|
|
30
|
+
} from './core/identity-session';
|
|
31
|
+
// Note: DeviceManager from core/identity-session conflicts with utils/deviceManager
|
|
32
|
+
// Use IdentitySessionCore.getDeviceManager() for core DeviceManager
|
|
33
|
+
export type {
|
|
34
|
+
Identity,
|
|
35
|
+
Session,
|
|
36
|
+
Device,
|
|
37
|
+
DeviceInfo,
|
|
38
|
+
BackupData,
|
|
39
|
+
IdentitySessionEvent,
|
|
40
|
+
Platform,
|
|
41
|
+
} from './core/identity-session/types';
|
|
42
|
+
// Note: DeviceSession type is exported from models/interfaces, use that instead
|
|
43
|
+
export {
|
|
44
|
+
IdentitySessionError,
|
|
45
|
+
IdentitySessionErrorCodes,
|
|
46
|
+
createIdentitySessionError,
|
|
47
|
+
} from './core/identity-session/errors';
|
|
22
48
|
export type {
|
|
23
49
|
KeyPair,
|
|
24
50
|
SignedMessage,
|
|
@@ -34,9 +60,7 @@ export {
|
|
|
34
60
|
// Streamlined provider with built-in bottom sheet
|
|
35
61
|
export { default as OxyProvider } from './ui/components/OxyProvider';
|
|
36
62
|
|
|
37
|
-
// Device management
|
|
38
|
-
export { DeviceManager } from './utils/deviceManager';
|
|
39
|
-
export type { DeviceFingerprint, StoredDeviceInfo } from './utils/deviceManager';
|
|
63
|
+
// Device management - use IdentitySessionCore.getDeviceManager() instead
|
|
40
64
|
|
|
41
65
|
// Language utilities
|
|
42
66
|
export {
|
|
@@ -139,6 +163,7 @@ export { useAssets, setOxyAssetInstance } from './ui/hooks/useAssets';
|
|
|
139
163
|
export { useFileDownloadUrl, setOxyFileUrlInstance } from './ui/hooks/useFileDownloadUrl';
|
|
140
164
|
export { useUsernameValidation, USERNAME_MIN_LENGTH, USERNAME_REGEX, USERNAME_FORMAT_ERROR, USERNAME_DEBOUNCE_MS } from './ui/hooks/auth';
|
|
141
165
|
export type { UsernameValidationResult } from './ui/hooks/auth';
|
|
166
|
+
// useIdentitySessionCore removed - use useOxy() hook instead which uses IdentitySessionCore internally
|
|
142
167
|
|
|
143
168
|
// UI hooks - Query hooks (TanStack Query)
|
|
144
169
|
export {
|
package/src/models/interfaces.ts
CHANGED
|
@@ -35,43 +35,16 @@ export interface OxyConfig {
|
|
|
35
35
|
* - Socket room names
|
|
36
36
|
* - API route parameters (unless explicitly doing publicKey lookup)
|
|
37
37
|
*/
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
};
|
|
49
|
-
name?: {
|
|
50
|
-
first?: string;
|
|
51
|
-
last?: string;
|
|
52
|
-
full?: string; // virtual, not stored in DB, returned by API
|
|
53
|
-
[key: string]: unknown;
|
|
54
|
-
};
|
|
55
|
-
bio?: string;
|
|
56
|
-
karma?: number;
|
|
57
|
-
location?: string;
|
|
58
|
-
website?: string;
|
|
59
|
-
createdAt?: string;
|
|
60
|
-
updatedAt?: string;
|
|
61
|
-
links?: Array<{
|
|
62
|
-
title?: string;
|
|
63
|
-
description?: string;
|
|
64
|
-
image?: string;
|
|
65
|
-
link: string;
|
|
66
|
-
}>;
|
|
67
|
-
// Social counts
|
|
68
|
-
_count?: {
|
|
69
|
-
followers?: number;
|
|
70
|
-
following?: number;
|
|
71
|
-
};
|
|
72
|
-
accountExpiresAfterInactivityDays?: number | null; // Days of inactivity before account expires (null = never expire)
|
|
73
|
-
[key: string]: unknown;
|
|
74
|
-
}
|
|
38
|
+
// Import Identity type for local use
|
|
39
|
+
import type { Identity } from '../core/identity-session/types';
|
|
40
|
+
|
|
41
|
+
// Re-export Identity as User (aligned with backend IUser)
|
|
42
|
+
export type User = Identity;
|
|
43
|
+
|
|
44
|
+
// Re-export other core types
|
|
45
|
+
export type { Identity, Session, DeviceInfo, Device, BackupData } from '../core/identity-session/types';
|
|
46
|
+
|
|
47
|
+
// Note: DeviceSession is defined locally below (different from core's DeviceSession which is device info)
|
|
75
48
|
|
|
76
49
|
export interface LoginResponse {
|
|
77
50
|
accessToken?: string;
|
|
@@ -105,7 +78,7 @@ export interface BlockedUser {
|
|
|
105
78
|
_id?: string;
|
|
106
79
|
blockedId: string | {
|
|
107
80
|
_id: string;
|
|
108
|
-
username
|
|
81
|
+
username?: string; // Optional username
|
|
109
82
|
avatar?: string;
|
|
110
83
|
};
|
|
111
84
|
userId: string;
|
|
@@ -119,7 +92,7 @@ export interface RestrictedUser {
|
|
|
119
92
|
_id?: string;
|
|
120
93
|
restrictedId: string | {
|
|
121
94
|
_id: string;
|
|
122
|
-
username
|
|
95
|
+
username?: string; // Optional username
|
|
123
96
|
avatar?: string;
|
|
124
97
|
};
|
|
125
98
|
userId: string;
|
package/src/models/session.ts
CHANGED
|
@@ -1,18 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
* - Used for session management and user identification
|
|
7
|
-
*/
|
|
8
|
-
export interface ClientSession {
|
|
9
|
-
sessionId: string;
|
|
10
|
-
deviceId: string;
|
|
11
|
-
expiresAt: string;
|
|
12
|
-
lastActive: string;
|
|
13
|
-
userId?: string; // MongoDB ObjectId - PRIMARY IDENTIFIER (never publicKey)
|
|
14
|
-
isCurrent?: boolean;
|
|
15
|
-
}
|
|
1
|
+
// Re-export Session from core (aligned with backend ISession)
|
|
2
|
+
export type { Session as ClientSession } from '../core/identity-session/types';
|
|
3
|
+
|
|
4
|
+
// Re-export other core types (excluding DeviceSession which is defined in models/interfaces)
|
|
5
|
+
export type { Session, DeviceInfo, Device } from '../core/identity-session/types';
|
|
16
6
|
|
|
17
7
|
export interface StorageKeys {
|
|
18
8
|
sessions: string; // Array of ClientSession objects
|
|
@@ -21,7 +11,7 @@ export interface StorageKeys {
|
|
|
21
11
|
|
|
22
12
|
export interface MinimalUserData {
|
|
23
13
|
id: string;
|
|
24
|
-
username
|
|
14
|
+
username?: string; // Optional username
|
|
25
15
|
avatar?: string; // file id
|
|
26
16
|
}
|
|
27
17
|
|