@oxyhq/services 5.16.35 → 5.16.36
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 +8 -26
- package/lib/commonjs/core/OxyServices.base.js.map +1 -1
- package/lib/commonjs/core/mixins/OxyServices.user.js.map +1 -1
- package/lib/commonjs/core/mixins/OxyServices.utility.js.map +1 -1
- package/lib/commonjs/crypto/README.md +142 -0
- package/lib/commonjs/crypto/core.js +147 -0
- package/lib/commonjs/crypto/core.js.map +1 -0
- package/lib/commonjs/crypto/index.js +16 -0
- package/lib/commonjs/crypto/index.js.map +1 -1
- package/lib/commonjs/crypto/keyManager.js +19 -22
- package/lib/commonjs/crypto/keyManager.js.map +1 -1
- package/lib/commonjs/crypto/signatureService.js +116 -28
- package/lib/commonjs/crypto/signatureService.js.map +1 -1
- package/lib/commonjs/index.js +0 -12
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/models/interfaces.js +10 -11
- package/lib/commonjs/models/interfaces.js.map +1 -1
- package/lib/commonjs/node/index.js +10 -1
- package/lib/commonjs/node/index.js.map +1 -1
- package/lib/commonjs/node/signatureService.js +107 -0
- package/lib/commonjs/node/signatureService.js.map +1 -0
- package/lib/commonjs/ui/context/OxyContext.js.map +1 -1
- package/lib/commonjs/ui/context/hooks/useAuthOperations.js.map +1 -1
- package/lib/commonjs/ui/context/hooks/useLanguageManagement.js.map +1 -1
- package/lib/commonjs/ui/hooks/useLanguageManagement.js.map +1 -1
- package/lib/commonjs/ui/hooks/useSessionManagement.js.map +1 -1
- package/lib/commonjs/ui/index.js +0 -2
- package/lib/commonjs/ui/index.js.map +1 -1
- package/lib/commonjs/ui/screens/AccountSettingsScreen.js.map +1 -1
- package/lib/commonjs/ui/screens/OxyAuthScreen.js +11 -2
- package/lib/commonjs/ui/screens/OxyAuthScreen.js.map +1 -1
- package/lib/module/core/OxyServices.base.js.map +1 -1
- package/lib/module/core/mixins/OxyServices.user.js.map +1 -1
- package/lib/module/core/mixins/OxyServices.utility.js.map +1 -1
- package/lib/module/crypto/README.md +142 -0
- package/lib/module/crypto/core.js +133 -0
- package/lib/module/crypto/core.js.map +1 -0
- package/lib/module/crypto/index.js +3 -9
- package/lib/module/crypto/index.js.map +1 -1
- package/lib/module/crypto/keyManager.js +19 -22
- package/lib/module/crypto/keyManager.js.map +1 -1
- package/lib/module/crypto/signatureService.js +113 -23
- package/lib/module/crypto/signatureService.js.map +1 -1
- package/lib/module/index.js +0 -2
- package/lib/module/index.js.map +1 -1
- package/lib/module/models/interfaces.js +10 -11
- package/lib/module/models/interfaces.js.map +1 -1
- package/lib/module/node/index.js +3 -0
- package/lib/module/node/index.js.map +1 -1
- package/lib/module/node/signatureService.js +101 -0
- package/lib/module/node/signatureService.js.map +1 -0
- package/lib/module/ui/context/OxyContext.js.map +1 -1
- package/lib/module/ui/context/hooks/useAuthOperations.js.map +1 -1
- package/lib/module/ui/context/hooks/useLanguageManagement.js.map +1 -1
- package/lib/module/ui/hooks/useLanguageManagement.js.map +1 -1
- package/lib/module/ui/hooks/useSessionManagement.js.map +1 -1
- package/lib/module/ui/index.js +0 -1
- package/lib/module/ui/index.js.map +1 -1
- package/lib/module/ui/screens/AccountSettingsScreen.js.map +1 -1
- package/lib/module/ui/screens/OxyAuthScreen.js +11 -2
- package/lib/module/ui/screens/OxyAuthScreen.js.map +1 -1
- package/lib/typescript/core/OxyServices.base.d.ts.map +1 -1
- package/lib/typescript/core/mixins/OxyServices.analytics.d.ts.map +1 -1
- package/lib/typescript/core/mixins/OxyServices.assets.d.ts.map +1 -1
- package/lib/typescript/core/mixins/OxyServices.auth.d.ts +1 -1
- package/lib/typescript/core/mixins/OxyServices.auth.d.ts.map +1 -1
- package/lib/typescript/core/mixins/OxyServices.developer.d.ts.map +1 -1
- package/lib/typescript/core/mixins/OxyServices.devices.d.ts.map +1 -1
- package/lib/typescript/core/mixins/OxyServices.karma.d.ts.map +1 -1
- package/lib/typescript/core/mixins/OxyServices.language.d.ts.map +1 -1
- package/lib/typescript/core/mixins/OxyServices.location.d.ts.map +1 -1
- package/lib/typescript/core/mixins/OxyServices.payment.d.ts.map +1 -1
- package/lib/typescript/core/mixins/OxyServices.privacy.d.ts.map +1 -1
- package/lib/typescript/core/mixins/OxyServices.security.d.ts.map +1 -1
- package/lib/typescript/core/mixins/OxyServices.user.d.ts +1 -2
- package/lib/typescript/core/mixins/OxyServices.user.d.ts.map +1 -1
- package/lib/typescript/core/mixins/OxyServices.utility.d.ts.map +1 -1
- package/lib/typescript/core/mixins/index.d.ts +13 -13
- package/lib/typescript/core/mixins/index.d.ts.map +1 -1
- package/lib/typescript/core/services/SessionService.d.ts +1 -1
- package/lib/typescript/core/services/SessionService.d.ts.map +1 -1
- package/lib/typescript/crypto/core.d.ts +56 -0
- package/lib/typescript/crypto/core.d.ts.map +1 -0
- package/lib/typescript/crypto/index.d.ts +1 -9
- package/lib/typescript/crypto/index.d.ts.map +1 -1
- package/lib/typescript/crypto/keyManager.d.ts +13 -1
- package/lib/typescript/crypto/keyManager.d.ts.map +1 -1
- package/lib/typescript/crypto/signatureService.d.ts +15 -9
- package/lib/typescript/crypto/signatureService.d.ts.map +1 -1
- package/lib/typescript/index.d.ts +1 -2
- package/lib/typescript/index.d.ts.map +1 -1
- package/lib/typescript/models/interfaces.d.ts +68 -15
- package/lib/typescript/models/interfaces.d.ts.map +1 -1
- package/lib/typescript/node/index.d.ts +1 -0
- package/lib/typescript/node/index.d.ts.map +1 -1
- package/lib/typescript/node/signatureService.d.ts +55 -0
- package/lib/typescript/node/signatureService.d.ts.map +1 -0
- package/lib/typescript/ui/context/OxyContext.d.ts +1 -2
- package/lib/typescript/ui/context/OxyContext.d.ts.map +1 -1
- package/lib/typescript/ui/context/hooks/useAuthOperations.d.ts +1 -2
- package/lib/typescript/ui/context/hooks/useAuthOperations.d.ts.map +1 -1
- package/lib/typescript/ui/context/hooks/useLanguageManagement.d.ts +1 -2
- package/lib/typescript/ui/context/hooks/useLanguageManagement.d.ts.map +1 -1
- package/lib/typescript/ui/hooks/mutations/useAccountMutations.d.ts +1 -1
- package/lib/typescript/ui/hooks/mutations/useAccountMutations.d.ts.map +1 -1
- package/lib/typescript/ui/hooks/queries/useAccountQueries.d.ts +1 -1
- package/lib/typescript/ui/hooks/queries/useAccountQueries.d.ts.map +1 -1
- package/lib/typescript/ui/hooks/useLanguageManagement.d.ts +1 -2
- package/lib/typescript/ui/hooks/useLanguageManagement.d.ts.map +1 -1
- package/lib/typescript/ui/hooks/useSessionManagement.d.ts +1 -2
- package/lib/typescript/ui/hooks/useSessionManagement.d.ts.map +1 -1
- package/lib/typescript/ui/index.d.ts +1 -1
- package/lib/typescript/ui/index.d.ts.map +1 -1
- package/lib/typescript/ui/screens/OxyAuthScreen.d.ts.map +1 -1
- package/lib/typescript/ui/stores/authStore.d.ts +1 -1
- package/lib/typescript/ui/stores/authStore.d.ts.map +1 -1
- package/lib/typescript/ui/utils/avatarUtils.d.ts +1 -1
- package/lib/typescript/ui/utils/avatarUtils.d.ts.map +1 -1
- package/package.json +6 -1
- package/src/core/OxyServices.base.ts +1 -2
- package/src/core/mixins/OxyServices.auth.ts +1 -1
- package/src/core/mixins/OxyServices.user.ts +1 -2
- package/src/core/mixins/OxyServices.utility.ts +1 -2
- package/src/core/services/SessionService.ts +1 -1
- package/src/crypto/README.md +142 -0
- package/src/crypto/__tests__/core.test.ts +203 -0
- package/src/crypto/core.ts +142 -0
- package/src/crypto/index.ts +3 -10
- package/src/crypto/keyManager.ts +25 -21
- package/src/crypto/signatureService.ts +137 -36
- package/src/index.ts +2 -3
- package/src/models/interfaces.ts +73 -21
- package/src/node/index.ts +3 -0
- package/src/node/signatureService.ts +126 -0
- package/src/ui/context/OxyContext.tsx +1 -2
- package/src/ui/context/hooks/useAuthOperations.ts +1 -2
- package/src/ui/context/hooks/useLanguageManagement.ts +1 -2
- package/src/ui/hooks/auth/index.ts +2 -0
- package/src/ui/hooks/mutations/useAccountMutations.ts +1 -1
- package/src/ui/hooks/mutations/useServicesMutations.ts +1 -1
- package/src/ui/hooks/queries/useAccountQueries.ts +1 -1
- package/src/ui/hooks/useLanguageManagement.ts +1 -2
- package/src/ui/hooks/useSessionManagement.ts +1 -2
- package/src/ui/index.ts +1 -2
- package/src/ui/screens/AccountSettingsScreen.tsx +6 -6
- package/src/ui/screens/AccountSwitcherScreen.tsx +1 -1
- package/src/ui/screens/OxyAuthScreen.tsx +11 -2
- package/src/ui/screens/ProfileScreen.tsx +1 -1
- package/src/ui/stores/authStore.ts +1 -1
- package/src/ui/types/navigation.ts +1 -1
- package/src/ui/utils/avatarUtils.ts +1 -1
- package/lib/commonjs/core/services/AuthService.js +0 -156
- package/lib/commonjs/core/services/AuthService.js.map +0 -1
- package/lib/commonjs/core/services/SessionTransportService.js +0 -64
- package/lib/commonjs/core/services/SessionTransportService.js.map +0 -1
- package/lib/commonjs/core/services/UserService.js +0 -123
- package/lib/commonjs/core/services/UserService.js.map +0 -1
- package/lib/commonjs/core/services/index.js +0 -34
- package/lib/commonjs/core/services/index.js.map +0 -1
- package/lib/commonjs/shared/crypto/messageBuilders.js +0 -79
- package/lib/commonjs/shared/crypto/messageBuilders.js.map +0 -1
- package/lib/commonjs/shared/crypto/platform.js +0 -118
- package/lib/commonjs/shared/crypto/platform.js.map +0 -1
- package/lib/commonjs/shared/crypto/signature.js +0 -191
- package/lib/commonjs/shared/crypto/signature.js.map +0 -1
- package/lib/commonjs/shared/index.js +0 -94
- package/lib/commonjs/shared/index.js.map +0 -1
- package/lib/commonjs/shared/models/index.js +0 -2
- package/lib/commonjs/shared/models/index.js.map +0 -1
- package/lib/commonjs/shared/transport/index.js +0 -260
- package/lib/commonjs/shared/transport/index.js.map +0 -1
- package/lib/commonjs/shared/utils/index.js +0 -82
- package/lib/commonjs/shared/utils/index.js.map +0 -1
- package/lib/module/core/services/AuthService.js +0 -151
- package/lib/module/core/services/AuthService.js.map +0 -1
- package/lib/module/core/services/SessionTransportService.js +0 -59
- package/lib/module/core/services/SessionTransportService.js.map +0 -1
- package/lib/module/core/services/UserService.js +0 -118
- package/lib/module/core/services/UserService.js.map +0 -1
- package/lib/module/core/services/index.js +0 -16
- package/lib/module/core/services/index.js.map +0 -1
- package/lib/module/shared/crypto/messageBuilders.js +0 -70
- package/lib/module/shared/crypto/messageBuilders.js.map +0 -1
- package/lib/module/shared/crypto/platform.js +0 -112
- package/lib/module/shared/crypto/platform.js.map +0 -1
- package/lib/module/shared/crypto/signature.js +0 -186
- package/lib/module/shared/crypto/signature.js.map +0 -1
- package/lib/module/shared/index.js +0 -30
- package/lib/module/shared/index.js.map +0 -1
- package/lib/module/shared/models/index.js +0 -2
- package/lib/module/shared/models/index.js.map +0 -1
- package/lib/module/shared/transport/index.js +0 -254
- package/lib/module/shared/transport/index.js.map +0 -1
- package/lib/module/shared/utils/index.js +0 -74
- package/lib/module/shared/utils/index.js.map +0 -1
- package/lib/typescript/core/services/AuthService.d.ts +0 -50
- package/lib/typescript/core/services/AuthService.d.ts.map +0 -1
- package/lib/typescript/core/services/SessionTransportService.d.ts +0 -31
- package/lib/typescript/core/services/SessionTransportService.d.ts.map +0 -1
- package/lib/typescript/core/services/UserService.d.ts +0 -39
- package/lib/typescript/core/services/UserService.d.ts.map +0 -1
- package/lib/typescript/core/services/index.d.ts +0 -13
- package/lib/typescript/core/services/index.d.ts.map +0 -1
- package/lib/typescript/shared/crypto/messageBuilders.d.ts +0 -38
- package/lib/typescript/shared/crypto/messageBuilders.d.ts.map +0 -1
- package/lib/typescript/shared/crypto/platform.d.ts +0 -54
- package/lib/typescript/shared/crypto/platform.d.ts.map +0 -1
- package/lib/typescript/shared/crypto/signature.d.ts +0 -72
- package/lib/typescript/shared/crypto/signature.d.ts.map +0 -1
- package/lib/typescript/shared/index.d.ts +0 -20
- package/lib/typescript/shared/index.d.ts.map +0 -1
- package/lib/typescript/shared/models/index.d.ts +0 -163
- package/lib/typescript/shared/models/index.d.ts.map +0 -1
- package/lib/typescript/shared/transport/index.d.ts +0 -73
- package/lib/typescript/shared/transport/index.d.ts.map +0 -1
- package/lib/typescript/shared/utils/index.d.ts +0 -28
- package/lib/typescript/shared/utils/index.d.ts.map +0 -1
- package/src/core/services/AuthService.ts +0 -153
- package/src/core/services/SessionTransportService.ts +0 -69
- package/src/core/services/UserService.ts +0 -125
- package/src/core/services/index.ts +0 -14
- package/src/shared/crypto/messageBuilders.ts +0 -89
- package/src/shared/crypto/platform.ts +0 -140
- package/src/shared/crypto/signature.ts +0 -235
- package/src/shared/index.ts +0 -28
- package/src/shared/models/index.ts +0 -173
- package/src/shared/transport/index.ts +0 -349
- package/src/shared/utils/index.ts +0 -73
|
@@ -28,7 +28,6 @@ import { useThemeColors } from '../styles';
|
|
|
28
28
|
import { useOxy } from '../context/OxyContext';
|
|
29
29
|
import QRCode from 'react-native-qrcode-svg';
|
|
30
30
|
import OxyLogo from '../components/OxyLogo';
|
|
31
|
-
import { generateSessionToken } from '../../shared';
|
|
32
31
|
|
|
33
32
|
// Deep link scheme for Oxy Accounts app
|
|
34
33
|
const OXY_ACCOUNTS_SCHEME = 'oxyaccounts://';
|
|
@@ -221,7 +220,7 @@ const OxyAuthScreen: React.FC<BaseScreenProps> = ({
|
|
|
221
220
|
|
|
222
221
|
try {
|
|
223
222
|
// Generate a unique session token for this auth request
|
|
224
|
-
const sessionToken =
|
|
223
|
+
const sessionToken = generateSessionToken();
|
|
225
224
|
const expiresAt = Date.now() + AUTH_SESSION_EXPIRY_MS;
|
|
226
225
|
|
|
227
226
|
// Register the auth session with the server
|
|
@@ -243,6 +242,16 @@ const OxyAuthScreen: React.FC<BaseScreenProps> = ({
|
|
|
243
242
|
}
|
|
244
243
|
}, [oxyServices, connectSocket]);
|
|
245
244
|
|
|
245
|
+
// Generate a random session token
|
|
246
|
+
const generateSessionToken = (): string => {
|
|
247
|
+
const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
|
|
248
|
+
let result = '';
|
|
249
|
+
for (let i = 0; i < 32; i++) {
|
|
250
|
+
result += chars.charAt(Math.floor(Math.random() * chars.length));
|
|
251
|
+
}
|
|
252
|
+
return result;
|
|
253
|
+
};
|
|
254
|
+
|
|
246
255
|
// Clean up on unmount
|
|
247
256
|
useEffect(() => {
|
|
248
257
|
return () => {
|
|
@@ -10,7 +10,7 @@ import { Ionicons } from '@expo/vector-icons';
|
|
|
10
10
|
import { useI18n } from '../hooks/useI18n';
|
|
11
11
|
import { useOxy } from '../context/OxyContext';
|
|
12
12
|
import { logger } from '../../utils/loggerUtils';
|
|
13
|
-
import type { User } from '../../
|
|
13
|
+
import type { User } from '../../models/interfaces';
|
|
14
14
|
import { extractErrorMessage } from '../utils/errorHandlers';
|
|
15
15
|
|
|
16
16
|
interface ProfileScreenProps extends BaseScreenProps {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { ReactNode, RefObject } from 'react';
|
|
2
2
|
import type { QueryClient } from '@tanstack/react-query';
|
|
3
3
|
import type { RouteName } from '../navigation/routes';
|
|
4
|
-
import type { User } from '../../
|
|
4
|
+
import type { User } from '../../models/interfaces';
|
|
5
5
|
import type { ClientSession } from '../../models/session';
|
|
6
6
|
|
|
7
7
|
// Re-export RouteName from routes for convenience
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { OxyServices } from '../../core';
|
|
2
|
-
import type { User } from '../../
|
|
2
|
+
import type { User } from '../../models/interfaces';
|
|
3
3
|
import { useAccountStore } from '../stores/accountStore';
|
|
4
4
|
import { useAuthStore } from '../stores/authStore';
|
|
5
5
|
import { QueryClient } from '@tanstack/react-query';
|
|
@@ -1,156 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.AuthService = void 0;
|
|
7
|
-
var _HttpService = require("../HttpService");
|
|
8
|
-
var _signatureService = require("../../crypto/signatureService");
|
|
9
|
-
/**
|
|
10
|
-
* Auth Service
|
|
11
|
-
*
|
|
12
|
-
* Handles authentication operations:
|
|
13
|
-
* - Challenge retrieval
|
|
14
|
-
* - Signing orchestration (delegated to Accounts/KeyManager)
|
|
15
|
-
* - Session verification
|
|
16
|
-
* - Access token retrieval
|
|
17
|
-
* - Registration
|
|
18
|
-
*/
|
|
19
|
-
|
|
20
|
-
class AuthService {
|
|
21
|
-
constructor(config) {
|
|
22
|
-
this.httpService = new _HttpService.HttpService(config);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Check if a public key is registered on the server
|
|
27
|
-
*/
|
|
28
|
-
async checkPublicKeyRegistered(publicKey) {
|
|
29
|
-
try {
|
|
30
|
-
return await this.httpService.request({
|
|
31
|
-
method: 'GET',
|
|
32
|
-
url: `/api/auth/check-publickey?publicKey=${encodeURIComponent(publicKey)}`,
|
|
33
|
-
cache: true,
|
|
34
|
-
cacheTTL: 2 * 60 * 1000
|
|
35
|
-
});
|
|
36
|
-
} catch (error) {
|
|
37
|
-
throw error;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* Request an authentication challenge
|
|
43
|
-
*/
|
|
44
|
-
async requestChallenge(publicKey) {
|
|
45
|
-
try {
|
|
46
|
-
return await this.httpService.request({
|
|
47
|
-
method: 'POST',
|
|
48
|
-
url: '/api/auth/challenge',
|
|
49
|
-
data: {
|
|
50
|
-
publicKey
|
|
51
|
-
},
|
|
52
|
-
cache: false
|
|
53
|
-
});
|
|
54
|
-
} catch (error) {
|
|
55
|
-
throw error;
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* Verify a challenge and authenticate (creates session)
|
|
61
|
-
* This orchestrates signing via SignatureService (which uses KeyManager)
|
|
62
|
-
*/
|
|
63
|
-
async verifyChallenge(challenge) {
|
|
64
|
-
try {
|
|
65
|
-
// Sign the challenge using SignatureService (requires private key)
|
|
66
|
-
const signedChallenge = await _signatureService.SignatureService.signChallenge(challenge);
|
|
67
|
-
|
|
68
|
-
// Verify challenge and get session
|
|
69
|
-
return await this.httpService.request({
|
|
70
|
-
method: 'POST',
|
|
71
|
-
url: '/api/auth/verify',
|
|
72
|
-
data: {
|
|
73
|
-
publicKey: signedChallenge.publicKey,
|
|
74
|
-
challenge: challenge,
|
|
75
|
-
signature: signedChallenge.challenge,
|
|
76
|
-
timestamp: signedChallenge.timestamp
|
|
77
|
-
},
|
|
78
|
-
cache: false
|
|
79
|
-
});
|
|
80
|
-
} catch (error) {
|
|
81
|
-
throw error;
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
/**
|
|
86
|
-
* Register a new identity with the server
|
|
87
|
-
*/
|
|
88
|
-
async register(publicKey, signature, timestamp, username, email) {
|
|
89
|
-
try {
|
|
90
|
-
return await this.httpService.request({
|
|
91
|
-
method: 'POST',
|
|
92
|
-
url: '/api/auth/register',
|
|
93
|
-
data: {
|
|
94
|
-
publicKey,
|
|
95
|
-
signature,
|
|
96
|
-
timestamp,
|
|
97
|
-
username,
|
|
98
|
-
email
|
|
99
|
-
},
|
|
100
|
-
cache: false
|
|
101
|
-
});
|
|
102
|
-
} catch (error) {
|
|
103
|
-
throw error;
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
/**
|
|
108
|
-
* Register using current identity (signs automatically)
|
|
109
|
-
*/
|
|
110
|
-
async registerCurrentIdentity(username, email) {
|
|
111
|
-
try {
|
|
112
|
-
const {
|
|
113
|
-
signature,
|
|
114
|
-
publicKey,
|
|
115
|
-
timestamp
|
|
116
|
-
} = await _signatureService.SignatureService.createRegistrationSignature();
|
|
117
|
-
return this.register(publicKey, signature, timestamp, username, email);
|
|
118
|
-
} catch (error) {
|
|
119
|
-
throw error;
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
/**
|
|
124
|
-
* Get user by public key
|
|
125
|
-
*/
|
|
126
|
-
async getUserByPublicKey(publicKey) {
|
|
127
|
-
try {
|
|
128
|
-
return await this.httpService.request({
|
|
129
|
-
method: 'GET',
|
|
130
|
-
url: `/api/auth/user/${encodeURIComponent(publicKey)}`,
|
|
131
|
-
cache: true,
|
|
132
|
-
cacheTTL: 2 * 60 * 1000
|
|
133
|
-
});
|
|
134
|
-
} catch (error) {
|
|
135
|
-
throw error;
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
/**
|
|
140
|
-
* Get user by session ID
|
|
141
|
-
*/
|
|
142
|
-
async getUserBySession(sessionId) {
|
|
143
|
-
try {
|
|
144
|
-
return await this.httpService.request({
|
|
145
|
-
method: 'GET',
|
|
146
|
-
url: `/api/auth/user/session/${encodeURIComponent(sessionId)}`,
|
|
147
|
-
cache: true,
|
|
148
|
-
cacheTTL: 2 * 60 * 1000
|
|
149
|
-
});
|
|
150
|
-
} catch (error) {
|
|
151
|
-
throw error;
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
exports.AuthService = AuthService;
|
|
156
|
-
//# sourceMappingURL=AuthService.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["_HttpService","require","_signatureService","AuthService","constructor","config","httpService","HttpService","checkPublicKeyRegistered","publicKey","request","method","url","encodeURIComponent","cache","cacheTTL","error","requestChallenge","data","verifyChallenge","challenge","signedChallenge","SignatureService","signChallenge","signature","timestamp","register","username","email","registerCurrentIdentity","createRegistrationSignature","getUserByPublicKey","getUserBySession","sessionId","exports"],"sourceRoot":"../../../../src","sources":["core/services/AuthService.ts"],"mappings":";;;;;;AAaA,IAAAA,YAAA,GAAAC,OAAA;AACA,IAAAC,iBAAA,GAAAD,OAAA;AAdA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAYO,MAAME,WAAW,CAAC;EAGvBC,WAAWA,CAACC,MAAiB,EAAE;IAC7B,IAAI,CAACC,WAAW,GAAG,IAAIC,wB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I;MACF,OAAO,MAAM,IAAI,CAAC3B,WAAW,CAACI,OAAO,CAAO;QAC1CC,MAAM,EAAE,KAAK;QACbC,GAAG,EAAE,0BAA0BC,kBAAkB,CAACoB,SAAS,CAAC,EAAE;QAC9DnB,KAAK,EAAE,IAAI;QACXC,QAAQ,EAAE,CAAC,GAAG,EAAE,GAAG;MACrB,CAAC,CAAC;IACJ,CAAC,CAAC,OAAOC,KAAK,EAAE;MACd,MAAMA,KAAK;IACb;EACF;AACF;AAACkB,OAAA,CAAA/B,WAAA,GAAAA,WAAA","ignoreList":[]}
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.SessionTransportService = void 0;
|
|
7
|
-
var _shared = require("../../shared");
|
|
8
|
-
/**
|
|
9
|
-
* Session Transport Service
|
|
10
|
-
*
|
|
11
|
-
* Uses shared transport abstraction for WebSocket/SSE/polling
|
|
12
|
-
* Provides unified interface for session status updates
|
|
13
|
-
*/
|
|
14
|
-
|
|
15
|
-
class SessionTransportService {
|
|
16
|
-
transport = null;
|
|
17
|
-
constructor(config) {
|
|
18
|
-
this.config = config;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Connect to session status updates
|
|
23
|
-
* Automatically chooses best available transport (WebSocket > SSE > Polling)
|
|
24
|
-
*/
|
|
25
|
-
async connect(sessionToken, callbacks) {
|
|
26
|
-
const transportConfig = {
|
|
27
|
-
baseURL: this.config.baseURL,
|
|
28
|
-
namespace: 'auth-session',
|
|
29
|
-
sessionToken,
|
|
30
|
-
pollingInterval: 3000,
|
|
31
|
-
// 3 seconds
|
|
32
|
-
reconnectAttempts: 3,
|
|
33
|
-
reconnectDelay: 1000
|
|
34
|
-
};
|
|
35
|
-
this.transport = await _shared.TransportFactory.create(transportConfig, callbacks);
|
|
36
|
-
await this.transport.connect();
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* Disconnect from session updates
|
|
41
|
-
*/
|
|
42
|
-
disconnect() {
|
|
43
|
-
if (this.transport) {
|
|
44
|
-
this.transport.disconnect();
|
|
45
|
-
this.transport = null;
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* Check if currently connected
|
|
51
|
-
*/
|
|
52
|
-
isConnected() {
|
|
53
|
-
return this.transport?.isConnected() ?? false;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* Get the transport type being used
|
|
58
|
-
*/
|
|
59
|
-
getTransportType() {
|
|
60
|
-
return this.transport?.getType() ?? 'none';
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
exports.SessionTransportService = SessionTransportService;
|
|
64
|
-
//# sourceMappingURL=SessionTransportService.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["_shared","require","SessionTransportService","transport","constructor","config","connect","sessionToken","callbacks","transportConfig","baseURL","namespace","pollingInterval","reconnectAttempts","reconnectDelay","TransportFactory","create","disconnect","isConnected","getTransportType","getType","exports"],"sourceRoot":"../../../../src","sources":["core/services/SessionTransportService.ts"],"mappings":";;;;;;AAQA,IAAAA,OAAA,GAAAC,OAAA;AARA;AACA;AACA;AACA;AACA;AACA;;AAUO,MAAMC,uBAAuB,CAAC;EAC3BC,SAAS,GAAQ,IAAI;EAG7BC,WAAWA,CAACC,MAAiB,EAAE;IAC7B,IAAI,CAACA,MAAM,GAAGA,MAAM;EACtB;;EAEA;AACF;AACA;AACA;EACE,MAAMC,OAAOA,CACXC,YAAoB,EACpBC,SAA6B,EACd;IACf,MAAMC,eAAgC,GAAG;MACvCC,OAAO,EAAE,IAAI,CAACL,MAAM,CAACK,OAAO;MAC5BC,SAAS,EAAE,cAAc;MACzBJ,YAAY;MACZK,eAAe,EAAE,IAAI;MAAE;MACvBC,iBAAiB,EAAE,CAAC;MACpBC,cAAc,EAAE;IAClB,CAAC;IAED,IAAI,CAACX,SAAS,GAAG,MAAMY,wBAAgB,CAACC,MAAM,CAACP,eAAe,EAAED,SAAS,CAAC;IAC1E,MAAM,IAAI,CAACL,SAAS,CAACG,OAAO,CAAC,CAAC;EAChC;;EAEA;AACF;AACA;EACEW,UAAUA,CAAA,EAAS;IACjB,IAAI,IAAI,CAACd,SAAS,EAAE;MAClB,IAAI,CAACA,SAAS,CAACc,UAAU,CAAC,CAAC;MAC3B,IAAI,CAACd,SAAS,GAAG,IAAI;IACvB;EACF;;EAEA;AACF;AACA;EACEe,WAAWA,CAAA,EAAY;IACrB,OAAO,IAAI,CAACf,SAAS,EAAEe,WAAW,CAAC,CAAC,IAAI,KAAK;EAC/C;;EAEA;AACF;AACA;EACEC,gBAAgBA,CAAA,EAAW;IACzB,OAAO,IAAI,CAAChB,SAAS,EAAEiB,OAAO,CAAC,CAAC,IAAI,MAAM;EAC5C;AACF;AAACC,OAAA,CAAAnB,uBAAA,GAAAA,uBAAA","ignoreList":[]}
|
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.UserService = void 0;
|
|
7
|
-
var _HttpService = require("../HttpService");
|
|
8
|
-
/**
|
|
9
|
-
* User Service
|
|
10
|
-
*
|
|
11
|
-
* Handles user profile operations (no key handling):
|
|
12
|
-
* - Profile fetch/update
|
|
13
|
-
* - Profile search
|
|
14
|
-
* - User recommendations
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
|
-
class UserService {
|
|
18
|
-
constructor(config) {
|
|
19
|
-
this.httpService = new _HttpService.HttpService(config);
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Get user profile by ID
|
|
24
|
-
*/
|
|
25
|
-
async getUserById(userId) {
|
|
26
|
-
try {
|
|
27
|
-
return await this.httpService.request({
|
|
28
|
-
method: 'GET',
|
|
29
|
-
url: `/api/profiles/${userId}`,
|
|
30
|
-
cache: true,
|
|
31
|
-
cacheTTL: 5 * 60 * 1000
|
|
32
|
-
});
|
|
33
|
-
} catch (error) {
|
|
34
|
-
throw error;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* Get profile by username
|
|
40
|
-
*/
|
|
41
|
-
async getProfileByUsername(username) {
|
|
42
|
-
try {
|
|
43
|
-
return await this.httpService.request({
|
|
44
|
-
method: 'GET',
|
|
45
|
-
url: `/api/profiles/username/${username}`,
|
|
46
|
-
cache: true,
|
|
47
|
-
cacheTTL: 5 * 60 * 1000
|
|
48
|
-
});
|
|
49
|
-
} catch (error) {
|
|
50
|
-
throw error;
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* Search user profiles
|
|
56
|
-
*/
|
|
57
|
-
async searchProfiles(query, pagination) {
|
|
58
|
-
try {
|
|
59
|
-
const params = new URLSearchParams();
|
|
60
|
-
params.set('query', query);
|
|
61
|
-
if (pagination?.limit) params.set('limit', pagination.limit.toString());
|
|
62
|
-
if (pagination?.offset) params.set('offset', pagination.offset.toString());
|
|
63
|
-
const response = await this.httpService.request({
|
|
64
|
-
method: 'GET',
|
|
65
|
-
url: `/api/profiles/search?${params.toString()}`,
|
|
66
|
-
cache: true,
|
|
67
|
-
cacheTTL: 2 * 60 * 1000
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
// Handle response format
|
|
71
|
-
if (Array.isArray(response)) {
|
|
72
|
-
const limit = pagination?.limit ?? response.length;
|
|
73
|
-
const paginationInfo = {
|
|
74
|
-
total: response.length,
|
|
75
|
-
limit,
|
|
76
|
-
offset: pagination?.offset ?? 0,
|
|
77
|
-
hasMore: limit > 0 && response.length === limit
|
|
78
|
-
};
|
|
79
|
-
return {
|
|
80
|
-
data: response,
|
|
81
|
-
pagination: paginationInfo
|
|
82
|
-
};
|
|
83
|
-
}
|
|
84
|
-
return response;
|
|
85
|
-
} catch (error) {
|
|
86
|
-
throw error;
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
/**
|
|
91
|
-
* Get profile recommendations
|
|
92
|
-
*/
|
|
93
|
-
async getProfileRecommendations() {
|
|
94
|
-
try {
|
|
95
|
-
return await this.httpService.request({
|
|
96
|
-
method: 'GET',
|
|
97
|
-
url: '/api/profiles/recommendations',
|
|
98
|
-
cache: true,
|
|
99
|
-
cacheTTL: 5 * 60 * 1000
|
|
100
|
-
});
|
|
101
|
-
} catch (error) {
|
|
102
|
-
throw error;
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
/**
|
|
107
|
-
* Update user profile
|
|
108
|
-
*/
|
|
109
|
-
async updateProfile(updates) {
|
|
110
|
-
try {
|
|
111
|
-
return await this.httpService.request({
|
|
112
|
-
method: 'PATCH',
|
|
113
|
-
url: '/api/profiles/me',
|
|
114
|
-
data: updates,
|
|
115
|
-
cache: false
|
|
116
|
-
});
|
|
117
|
-
} catch (error) {
|
|
118
|
-
throw error;
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
exports.UserService = UserService;
|
|
123
|
-
//# sourceMappingURL=UserService.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["_HttpService","require","UserService","constructor","config","httpService","HttpService","getUserById","userId","request","method","url","cache","cacheTTL","error","getProfileByUsername","username","searchProfiles","query","pagination","params","URLSearchParams","set","limit","toString","offset","response","Array","isArray","length","paginationInfo","total","hasMore","data","getProfileRecommendations","updateProfile","updates","exports"],"sourceRoot":"../../../../src","sources":["core/services/UserService.ts"],"mappings":";;;;;;AAWA,IAAAA,YAAA,GAAAC,OAAA;AAXA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAWO,MAAMC,WAAW,CAAC;EAGvBC,WAAWA,CAACC,MAAiB,EAA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,kBAAkB;QACvBsB,IAAI,EAAEG,OAAO;QACbxB,KAAK,EAAE;MACT,CAAC,CAAC;IACJ,CAAC,CAAC,OAAOE,KAAK,EAAE;MACd,MAAMA,KAAK;IACb;EACF;AACF;AAACuB,OAAA,CAAAnC,WAAA,GAAAA,WAAA","ignoreList":[]}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
Object.defineProperty(exports, "AuthService", {
|
|
7
|
-
enumerable: true,
|
|
8
|
-
get: function () {
|
|
9
|
-
return _AuthService.AuthService;
|
|
10
|
-
}
|
|
11
|
-
});
|
|
12
|
-
Object.defineProperty(exports, "UserService", {
|
|
13
|
-
enumerable: true,
|
|
14
|
-
get: function () {
|
|
15
|
-
return _UserService.UserService;
|
|
16
|
-
}
|
|
17
|
-
});
|
|
18
|
-
Object.defineProperty(exports, "sessionService", {
|
|
19
|
-
enumerable: true,
|
|
20
|
-
get: function () {
|
|
21
|
-
return _SessionService.sessionService;
|
|
22
|
-
}
|
|
23
|
-
});
|
|
24
|
-
Object.defineProperty(exports, "tokenService", {
|
|
25
|
-
enumerable: true,
|
|
26
|
-
get: function () {
|
|
27
|
-
return _TokenService.tokenService;
|
|
28
|
-
}
|
|
29
|
-
});
|
|
30
|
-
var _AuthService = require("./AuthService");
|
|
31
|
-
var _SessionService = require("./SessionService");
|
|
32
|
-
var _UserService = require("./UserService");
|
|
33
|
-
var _TokenService = require("./TokenService");
|
|
34
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["_AuthService","require","_SessionService","_UserService","_TokenService"],"sourceRoot":"../../../../src","sources":["core/services/index.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AASA,IAAAA,YAAA,GAAAC,OAAA;AACA,IAAAC,eAAA,GAAAD,OAAA;AACA,IAAAE,YAAA,GAAAF,OAAA;AACA,IAAAG,aAAA,GAAAH,OAAA","ignoreList":[]}
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.buildAuthChallengeResponse = buildAuthChallengeResponse;
|
|
7
|
-
exports.buildAuthMessage = buildAuthMessage;
|
|
8
|
-
exports.buildRegistrationMessage = buildRegistrationMessage;
|
|
9
|
-
exports.buildRequestMessage = buildRequestMessage;
|
|
10
|
-
exports.canonicalizeData = canonicalizeData;
|
|
11
|
-
exports.isTimestampFresh = isTimestampFresh;
|
|
12
|
-
/**
|
|
13
|
-
* Canonical Message Builders
|
|
14
|
-
*
|
|
15
|
-
* Creates standardized, canonical message formats for signing.
|
|
16
|
-
* These formats are used consistently across Accounts, Services SDK, and API.
|
|
17
|
-
*/
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Build authentication message for challenge-response
|
|
21
|
-
* Format: auth:{publicKey}:{challenge}:{timestamp}
|
|
22
|
-
*/
|
|
23
|
-
function buildAuthMessage(publicKey, challenge, timestamp) {
|
|
24
|
-
return `auth:${publicKey}:${challenge}:${timestamp}`;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Build registration message
|
|
29
|
-
* Format: oxy:register:{publicKey}:{timestamp}
|
|
30
|
-
*/
|
|
31
|
-
function buildRegistrationMessage(publicKey, timestamp) {
|
|
32
|
-
return `oxy:register:${publicKey}:${timestamp}`;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* Build request signing message
|
|
37
|
-
* Format: request:{publicKey}:{timestamp}:{canonicalData}
|
|
38
|
-
*/
|
|
39
|
-
function buildRequestMessage(publicKey, timestamp, data) {
|
|
40
|
-
// Create canonical string representation
|
|
41
|
-
const sortedKeys = Object.keys(data).sort();
|
|
42
|
-
const canonicalParts = sortedKeys.map(key => `${key}:${JSON.stringify(data[key])}`);
|
|
43
|
-
const canonicalString = canonicalParts.join('|');
|
|
44
|
-
return `request:${publicKey}:${timestamp}:${canonicalString}`;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* Create canonical data representation for signing
|
|
49
|
-
* Sorts keys and creates a consistent string representation
|
|
50
|
-
*/
|
|
51
|
-
function canonicalizeData(data) {
|
|
52
|
-
const sortedKeys = Object.keys(data).sort();
|
|
53
|
-
const canonicalParts = sortedKeys.map(key => `${key}:${JSON.stringify(data[key])}`);
|
|
54
|
-
return canonicalParts.join('|');
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* Build auth challenge response payload
|
|
59
|
-
* Helper to construct the signed challenge response
|
|
60
|
-
*/
|
|
61
|
-
function buildAuthChallengeResponse(publicKey, challenge, signature, timestamp) {
|
|
62
|
-
return {
|
|
63
|
-
challenge,
|
|
64
|
-
publicKey,
|
|
65
|
-
signature,
|
|
66
|
-
timestamp
|
|
67
|
-
};
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* Validate timestamp freshness
|
|
72
|
-
* Ensures signed messages are not too old
|
|
73
|
-
*/
|
|
74
|
-
function isTimestampFresh(timestamp, maxAgeMs = 5 * 60 * 1000 // 5 minutes default
|
|
75
|
-
) {
|
|
76
|
-
const now = Date.now();
|
|
77
|
-
return now - timestamp <= maxAgeMs && timestamp <= now;
|
|
78
|
-
}
|
|
79
|
-
//# sourceMappingURL=messageBuilders.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["buildAuthMessage","publicKey","challenge","timestamp","buildRegistrationMessage","buildRequestMessage","data","sortedKeys","Object","keys","sort","canonicalParts","map","key","JSON","stringify","canonicalString","join","canonicalizeData","buildAuthChallengeResponse","signature","isTimestampFresh","maxAgeMs","now","Date"],"sourceRoot":"../../../../src","sources":["shared/crypto/messageBuilders.ts"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SAAiB,EACjBjB,SAAiB,EACM;EACvB,OAAO;IACLD,SAAS;IACTD,SAAS;IACTmB,SAAS;IACTjB;EACF,CAAC;AACH;;AAEA;AACA;AACA;AACA;AACO,SAASkB,gBAAgBA,CAC9BlB,SAAiB,EACjBmB,QAAgB,GAAG,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC;AAAA,EACxB;EACT,MAAMC,GAAG,GAAGC,IAAI,CAACD,GAAG,CAAC,CAAC;EACtB,OAAQA,GAAG,GAAGpB,SAAS,IAAKmB,QAAQ,IAAInB,SAAS,IAAIoB,GAAG;AAC1D","ignoreList":[]}
|
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.PlatformDetector = void 0;
|
|
7
|
-
exports.getCryptoAdapter = getCryptoAdapter;
|
|
8
|
-
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
9
|
-
/**
|
|
10
|
-
* Platform Detection and Adapters
|
|
11
|
-
*
|
|
12
|
-
* Provides environment detection and platform-specific crypto adapters
|
|
13
|
-
* to support Node.js, React Native, and Web environments.
|
|
14
|
-
*/
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Platform types
|
|
18
|
-
*/
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Platform detection utilities
|
|
22
|
-
*/
|
|
23
|
-
const PlatformDetector = exports.PlatformDetector = {
|
|
24
|
-
/**
|
|
25
|
-
* Detect current platform
|
|
26
|
-
*/
|
|
27
|
-
detect() {
|
|
28
|
-
if (typeof window === 'undefined' && typeof process !== 'undefined' && process.versions?.node) {
|
|
29
|
-
return 'node';
|
|
30
|
-
}
|
|
31
|
-
if (typeof navigator !== 'undefined' && navigator.product === 'ReactNative') {
|
|
32
|
-
return 'react-native';
|
|
33
|
-
}
|
|
34
|
-
return 'web';
|
|
35
|
-
},
|
|
36
|
-
/**
|
|
37
|
-
* Check if running in Node.js
|
|
38
|
-
*/
|
|
39
|
-
isNode() {
|
|
40
|
-
return this.detect() === 'node';
|
|
41
|
-
},
|
|
42
|
-
/**
|
|
43
|
-
* Check if running in React Native
|
|
44
|
-
*/
|
|
45
|
-
isReactNative() {
|
|
46
|
-
return this.detect() === 'react-native';
|
|
47
|
-
},
|
|
48
|
-
/**
|
|
49
|
-
* Check if running in Web browser
|
|
50
|
-
*/
|
|
51
|
-
isWeb() {
|
|
52
|
-
return this.detect() === 'web';
|
|
53
|
-
}
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* Crypto adapter interface
|
|
58
|
-
* Platform-specific implementations must implement this interface
|
|
59
|
-
*/
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* Get the appropriate crypto adapter for the current platform
|
|
63
|
-
*/
|
|
64
|
-
async function getCryptoAdapter() {
|
|
65
|
-
const platform = PlatformDetector.detect();
|
|
66
|
-
if (platform === 'node') {
|
|
67
|
-
// eslint-disable-next-line @typescript-eslint/no-implied-eval
|
|
68
|
-
const getCrypto = new Function('return require("crypto")');
|
|
69
|
-
const crypto = getCrypto();
|
|
70
|
-
return {
|
|
71
|
-
async randomBytes(size) {
|
|
72
|
-
return new Uint8Array(crypto.randomBytes(size));
|
|
73
|
-
},
|
|
74
|
-
async sha256(message) {
|
|
75
|
-
return crypto.createHash('sha256').update(message).digest('hex');
|
|
76
|
-
},
|
|
77
|
-
sha256Sync(message) {
|
|
78
|
-
return crypto.createHash('sha256').update(message).digest('hex');
|
|
79
|
-
}
|
|
80
|
-
};
|
|
81
|
-
}
|
|
82
|
-
if (platform === 'react-native') {
|
|
83
|
-
// Lazy load expo-crypto (peer dependency)
|
|
84
|
-
try {
|
|
85
|
-
// @ts-ignore - expo-crypto is an optional peer dependency
|
|
86
|
-
const ExpoCrypto = await Promise.resolve().then(() => _interopRequireWildcard(require('expo-crypto')));
|
|
87
|
-
return {
|
|
88
|
-
async randomBytes(size) {
|
|
89
|
-
const bytes = await ExpoCrypto.getRandomBytesAsync(size);
|
|
90
|
-
return new Uint8Array(bytes);
|
|
91
|
-
},
|
|
92
|
-
async sha256(message) {
|
|
93
|
-
return ExpoCrypto.digestStringAsync(ExpoCrypto.CryptoDigestAlgorithm.SHA256, message);
|
|
94
|
-
}
|
|
95
|
-
};
|
|
96
|
-
} catch (error) {
|
|
97
|
-
throw new Error(`expo-crypto is required in React Native environment: ${error instanceof Error ? error.message : String(error)}`);
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
// Web platform - use Web Crypto API
|
|
102
|
-
if (typeof window !== 'undefined' && window.crypto) {
|
|
103
|
-
return {
|
|
104
|
-
async randomBytes(size) {
|
|
105
|
-
return window.crypto.getRandomValues(new Uint8Array(size));
|
|
106
|
-
},
|
|
107
|
-
async sha256(message) {
|
|
108
|
-
const encoder = new TextEncoder();
|
|
109
|
-
const data = encoder.encode(message);
|
|
110
|
-
const hashBuffer = await window.crypto.subtle.digest('SHA-256', data);
|
|
111
|
-
const hashArray = Array.from(new Uint8Array(hashBuffer));
|
|
112
|
-
return hashArray.map(b => b.toString(16).padStart(2, '0')).join('');
|
|
113
|
-
}
|
|
114
|
-
};
|
|
115
|
-
}
|
|
116
|
-
throw new Error('No suitable crypto implementation found for current platform');
|
|
117
|
-
}
|
|
118
|
-
//# sourceMappingURL=platform.js.map
|