@oxyhq/services 5.16.33 → 5.16.35
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 +26 -8
- 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/core/services/AuthService.js +156 -0
- package/lib/commonjs/core/services/AuthService.js.map +1 -0
- package/lib/commonjs/core/services/SessionService.js +1 -2
- package/lib/commonjs/core/services/SessionService.js.map +1 -1
- package/lib/commonjs/core/services/SessionTransportService.js +64 -0
- package/lib/commonjs/core/services/SessionTransportService.js.map +1 -0
- package/lib/commonjs/core/services/TokenService.js +9 -17
- package/lib/commonjs/core/services/TokenService.js.map +1 -1
- package/lib/commonjs/core/services/UserService.js +123 -0
- package/lib/commonjs/core/services/UserService.js.map +1 -0
- package/lib/commonjs/core/services/index.js +34 -0
- package/lib/commonjs/core/services/index.js.map +1 -0
- package/lib/commonjs/crypto/index.js.map +1 -1
- package/lib/commonjs/crypto/keyManager.js +3 -2
- package/lib/commonjs/crypto/keyManager.js.map +1 -1
- package/lib/commonjs/crypto/signatureService.js +28 -122
- package/lib/commonjs/crypto/signatureService.js.map +1 -1
- package/lib/commonjs/index.js +12 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/models/interfaces.js +11 -11
- package/lib/commonjs/models/interfaces.js.map +1 -1
- package/lib/commonjs/shared/crypto/messageBuilders.js +79 -0
- package/lib/commonjs/shared/crypto/messageBuilders.js.map +1 -0
- package/lib/commonjs/shared/crypto/platform.js +118 -0
- package/lib/commonjs/shared/crypto/platform.js.map +1 -0
- package/lib/commonjs/shared/crypto/signature.js +191 -0
- package/lib/commonjs/shared/crypto/signature.js.map +1 -0
- package/lib/commonjs/shared/index.js +94 -0
- package/lib/commonjs/shared/index.js.map +1 -0
- package/lib/commonjs/shared/models/index.js +2 -0
- package/lib/commonjs/shared/models/index.js.map +1 -0
- package/lib/commonjs/shared/transport/index.js +260 -0
- package/lib/commonjs/shared/transport/index.js.map +1 -0
- package/lib/commonjs/shared/utils/index.js +82 -0
- package/lib/commonjs/shared/utils/index.js.map +1 -0
- package/lib/commonjs/ui/context/OxyContext.js +4 -40
- package/lib/commonjs/ui/context/OxyContext.js.map +1 -1
- package/lib/commonjs/ui/context/hooks/useAuthOperations.js +23 -61
- 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/queries/useServicesQueries.js +4 -12
- package/lib/commonjs/ui/hooks/queries/useServicesQueries.js.map +1 -1
- package/lib/commonjs/ui/hooks/useLanguageManagement.js.map +1 -1
- package/lib/commonjs/ui/hooks/useSessionManagement.js +0 -8
- package/lib/commonjs/ui/hooks/useSessionManagement.js.map +1 -1
- package/lib/commonjs/ui/index.js +2 -0
- 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 +2 -11
- package/lib/commonjs/ui/screens/OxyAuthScreen.js.map +1 -1
- package/lib/commonjs/ui/utils/sessionHelpers.js +11 -26
- package/lib/commonjs/ui/utils/sessionHelpers.js.map +1 -1
- package/lib/commonjs/utils/sessionUtils.js +1 -8
- package/lib/commonjs/utils/sessionUtils.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/core/services/AuthService.js +151 -0
- package/lib/module/core/services/AuthService.js.map +1 -0
- package/lib/module/core/services/SessionService.js +1 -2
- package/lib/module/core/services/SessionService.js.map +1 -1
- package/lib/module/core/services/SessionTransportService.js +59 -0
- package/lib/module/core/services/SessionTransportService.js.map +1 -0
- package/lib/module/core/services/TokenService.js +9 -17
- package/lib/module/core/services/TokenService.js.map +1 -1
- package/lib/module/core/services/UserService.js +118 -0
- package/lib/module/core/services/UserService.js.map +1 -0
- package/lib/module/core/services/index.js +16 -0
- package/lib/module/core/services/index.js.map +1 -0
- package/lib/module/crypto/index.js +9 -0
- package/lib/module/crypto/index.js.map +1 -1
- package/lib/module/crypto/keyManager.js +3 -2
- package/lib/module/crypto/keyManager.js.map +1 -1
- package/lib/module/crypto/signatureService.js +26 -122
- package/lib/module/crypto/signatureService.js.map +1 -1
- package/lib/module/index.js +2 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/models/interfaces.js +11 -11
- package/lib/module/models/interfaces.js.map +1 -1
- package/lib/module/shared/crypto/messageBuilders.js +70 -0
- package/lib/module/shared/crypto/messageBuilders.js.map +1 -0
- package/lib/module/shared/crypto/platform.js +112 -0
- package/lib/module/shared/crypto/platform.js.map +1 -0
- package/lib/module/shared/crypto/signature.js +186 -0
- package/lib/module/shared/crypto/signature.js.map +1 -0
- package/lib/module/shared/index.js +30 -0
- package/lib/module/shared/index.js.map +1 -0
- package/lib/module/shared/models/index.js +2 -0
- package/lib/module/shared/models/index.js.map +1 -0
- package/lib/module/shared/transport/index.js +254 -0
- package/lib/module/shared/transport/index.js.map +1 -0
- package/lib/module/shared/utils/index.js +74 -0
- package/lib/module/shared/utils/index.js.map +1 -0
- package/lib/module/ui/context/OxyContext.js +4 -40
- package/lib/module/ui/context/OxyContext.js.map +1 -1
- package/lib/module/ui/context/hooks/useAuthOperations.js +23 -61
- 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/queries/useServicesQueries.js +5 -13
- package/lib/module/ui/hooks/queries/useServicesQueries.js.map +1 -1
- package/lib/module/ui/hooks/useLanguageManagement.js.map +1 -1
- package/lib/module/ui/hooks/useSessionManagement.js +0 -8
- package/lib/module/ui/hooks/useSessionManagement.js.map +1 -1
- package/lib/module/ui/index.js +1 -0
- 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 +2 -11
- package/lib/module/ui/screens/OxyAuthScreen.js.map +1 -1
- package/lib/module/ui/utils/sessionHelpers.js +11 -26
- package/lib/module/ui/utils/sessionHelpers.js.map +1 -1
- package/lib/module/utils/sessionUtils.js +1 -8
- package/lib/module/utils/sessionUtils.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 +2 -1
- 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/AuthService.d.ts +50 -0
- package/lib/typescript/core/services/AuthService.d.ts.map +1 -0
- package/lib/typescript/core/services/SessionService.d.ts +3 -5
- package/lib/typescript/core/services/SessionService.d.ts.map +1 -1
- package/lib/typescript/core/services/SessionTransportService.d.ts +31 -0
- package/lib/typescript/core/services/SessionTransportService.d.ts.map +1 -0
- package/lib/typescript/core/services/TokenService.d.ts +3 -8
- package/lib/typescript/core/services/TokenService.d.ts.map +1 -1
- package/lib/typescript/core/services/UserService.d.ts +39 -0
- package/lib/typescript/core/services/UserService.d.ts.map +1 -0
- package/lib/typescript/core/services/index.d.ts +13 -0
- package/lib/typescript/core/services/index.d.ts.map +1 -0
- package/lib/typescript/crypto/index.d.ts +9 -0
- package/lib/typescript/crypto/index.d.ts.map +1 -1
- package/lib/typescript/crypto/keyManager.d.ts.map +1 -1
- package/lib/typescript/crypto/signatureService.d.ts +10 -13
- package/lib/typescript/crypto/signatureService.d.ts.map +1 -1
- package/lib/typescript/index.d.ts +2 -1
- package/lib/typescript/index.d.ts.map +1 -1
- package/lib/typescript/models/interfaces.d.ts +15 -69
- package/lib/typescript/models/interfaces.d.ts.map +1 -1
- package/lib/typescript/models/session.d.ts +2 -4
- package/lib/typescript/models/session.d.ts.map +1 -1
- package/lib/typescript/shared/crypto/messageBuilders.d.ts +38 -0
- package/lib/typescript/shared/crypto/messageBuilders.d.ts.map +1 -0
- package/lib/typescript/shared/crypto/platform.d.ts +54 -0
- package/lib/typescript/shared/crypto/platform.d.ts.map +1 -0
- package/lib/typescript/shared/crypto/signature.d.ts +72 -0
- package/lib/typescript/shared/crypto/signature.d.ts.map +1 -0
- package/lib/typescript/shared/index.d.ts +20 -0
- package/lib/typescript/shared/index.d.ts.map +1 -0
- package/lib/typescript/shared/models/index.d.ts +163 -0
- package/lib/typescript/shared/models/index.d.ts.map +1 -0
- package/lib/typescript/shared/transport/index.d.ts +73 -0
- package/lib/typescript/shared/transport/index.d.ts.map +1 -0
- package/lib/typescript/shared/utils/index.d.ts +28 -0
- package/lib/typescript/shared/utils/index.d.ts.map +1 -0
- package/lib/typescript/ui/context/OxyContext.d.ts +2 -1
- package/lib/typescript/ui/context/OxyContext.d.ts.map +1 -1
- package/lib/typescript/ui/context/hooks/useAuthOperations.d.ts +2 -1
- package/lib/typescript/ui/context/hooks/useAuthOperations.d.ts.map +1 -1
- package/lib/typescript/ui/context/hooks/useLanguageManagement.d.ts +2 -1
- 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/queries/useServicesQueries.d.ts.map +1 -1
- package/lib/typescript/ui/hooks/useLanguageManagement.d.ts +2 -1
- package/lib/typescript/ui/hooks/useLanguageManagement.d.ts.map +1 -1
- package/lib/typescript/ui/hooks/useSessionManagement.d.ts +2 -1
- 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/lib/typescript/ui/utils/sessionHelpers.d.ts +2 -6
- package/lib/typescript/ui/utils/sessionHelpers.d.ts.map +1 -1
- package/lib/typescript/utils/sessionUtils.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/core/OxyServices.base.ts +2 -1
- package/src/core/mixins/OxyServices.auth.ts +1 -1
- package/src/core/mixins/OxyServices.user.ts +2 -1
- package/src/core/mixins/OxyServices.utility.ts +2 -1
- package/src/core/services/AuthService.ts +153 -0
- package/src/core/services/SessionService.ts +3 -5
- package/src/core/services/SessionTransportService.ts +69 -0
- package/src/core/services/TokenService.ts +10 -18
- package/src/core/services/UserService.ts +125 -0
- package/src/core/services/index.ts +14 -0
- package/src/crypto/index.ts +9 -0
- package/src/crypto/keyManager.ts +3 -2
- package/src/crypto/signatureService.ts +43 -142
- package/src/index.ts +3 -2
- package/src/models/interfaces.ts +21 -74
- package/src/models/session.ts +3 -5
- package/src/shared/crypto/messageBuilders.ts +89 -0
- package/src/shared/crypto/platform.ts +140 -0
- package/src/shared/crypto/signature.ts +235 -0
- package/src/shared/index.ts +28 -0
- package/src/shared/models/index.ts +173 -0
- package/src/shared/transport/index.ts +349 -0
- package/src/shared/utils/index.ts +73 -0
- package/src/ui/context/OxyContext.tsx +22 -57
- package/src/ui/context/hooks/useAuthOperations.ts +33 -65
- package/src/ui/context/hooks/useLanguageManagement.ts +2 -1
- package/src/ui/hooks/auth/index.ts +0 -2
- 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/queries/useServicesQueries.ts +3 -8
- package/src/ui/hooks/useLanguageManagement.ts +2 -1
- package/src/ui/hooks/useSessionManagement.ts +3 -9
- package/src/ui/index.ts +2 -1
- package/src/ui/screens/AccountSettingsScreen.tsx +6 -6
- package/src/ui/screens/AccountSwitcherScreen.tsx +1 -1
- package/src/ui/screens/OxyAuthScreen.tsx +2 -11
- 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/src/ui/utils/sessionHelpers.ts +15 -32
- package/src/utils/sessionUtils.ts +1 -8
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Platform Detection and Adapters
|
|
5
|
+
*
|
|
6
|
+
* Provides environment detection and platform-specific crypto adapters
|
|
7
|
+
* to support Node.js, React Native, and Web environments.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Platform types
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Platform detection utilities
|
|
16
|
+
*/
|
|
17
|
+
export const PlatformDetector = {
|
|
18
|
+
/**
|
|
19
|
+
* Detect current platform
|
|
20
|
+
*/
|
|
21
|
+
detect() {
|
|
22
|
+
if (typeof window === 'undefined' && typeof process !== 'undefined' && process.versions?.node) {
|
|
23
|
+
return 'node';
|
|
24
|
+
}
|
|
25
|
+
if (typeof navigator !== 'undefined' && navigator.product === 'ReactNative') {
|
|
26
|
+
return 'react-native';
|
|
27
|
+
}
|
|
28
|
+
return 'web';
|
|
29
|
+
},
|
|
30
|
+
/**
|
|
31
|
+
* Check if running in Node.js
|
|
32
|
+
*/
|
|
33
|
+
isNode() {
|
|
34
|
+
return this.detect() === 'node';
|
|
35
|
+
},
|
|
36
|
+
/**
|
|
37
|
+
* Check if running in React Native
|
|
38
|
+
*/
|
|
39
|
+
isReactNative() {
|
|
40
|
+
return this.detect() === 'react-native';
|
|
41
|
+
},
|
|
42
|
+
/**
|
|
43
|
+
* Check if running in Web browser
|
|
44
|
+
*/
|
|
45
|
+
isWeb() {
|
|
46
|
+
return this.detect() === 'web';
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Crypto adapter interface
|
|
52
|
+
* Platform-specific implementations must implement this interface
|
|
53
|
+
*/
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Get the appropriate crypto adapter for the current platform
|
|
57
|
+
*/
|
|
58
|
+
export async function getCryptoAdapter() {
|
|
59
|
+
const platform = PlatformDetector.detect();
|
|
60
|
+
if (platform === 'node') {
|
|
61
|
+
// eslint-disable-next-line @typescript-eslint/no-implied-eval
|
|
62
|
+
const getCrypto = new Function('return require("crypto")');
|
|
63
|
+
const crypto = getCrypto();
|
|
64
|
+
return {
|
|
65
|
+
async randomBytes(size) {
|
|
66
|
+
return new Uint8Array(crypto.randomBytes(size));
|
|
67
|
+
},
|
|
68
|
+
async sha256(message) {
|
|
69
|
+
return crypto.createHash('sha256').update(message).digest('hex');
|
|
70
|
+
},
|
|
71
|
+
sha256Sync(message) {
|
|
72
|
+
return crypto.createHash('sha256').update(message).digest('hex');
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
if (platform === 'react-native') {
|
|
77
|
+
// Lazy load expo-crypto (peer dependency)
|
|
78
|
+
try {
|
|
79
|
+
// @ts-ignore - expo-crypto is an optional peer dependency
|
|
80
|
+
const ExpoCrypto = await import('expo-crypto');
|
|
81
|
+
return {
|
|
82
|
+
async randomBytes(size) {
|
|
83
|
+
const bytes = await ExpoCrypto.getRandomBytesAsync(size);
|
|
84
|
+
return new Uint8Array(bytes);
|
|
85
|
+
},
|
|
86
|
+
async sha256(message) {
|
|
87
|
+
return ExpoCrypto.digestStringAsync(ExpoCrypto.CryptoDigestAlgorithm.SHA256, message);
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
} catch (error) {
|
|
91
|
+
throw new Error(`expo-crypto is required in React Native environment: ${error instanceof Error ? error.message : String(error)}`);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
// Web platform - use Web Crypto API
|
|
96
|
+
if (typeof window !== 'undefined' && window.crypto) {
|
|
97
|
+
return {
|
|
98
|
+
async randomBytes(size) {
|
|
99
|
+
return window.crypto.getRandomValues(new Uint8Array(size));
|
|
100
|
+
},
|
|
101
|
+
async sha256(message) {
|
|
102
|
+
const encoder = new TextEncoder();
|
|
103
|
+
const data = encoder.encode(message);
|
|
104
|
+
const hashBuffer = await window.crypto.subtle.digest('SHA-256', data);
|
|
105
|
+
const hashArray = Array.from(new Uint8Array(hashBuffer));
|
|
106
|
+
return hashArray.map(b => b.toString(16).padStart(2, '0')).join('');
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
throw new Error('No suitable crypto implementation found for current platform');
|
|
111
|
+
}
|
|
112
|
+
//# sourceMappingURL=platform.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["PlatformDetector","detect","window","process","versions","node","navigator","product","isNode","isReactNative","isWeb","getCryptoAdapter","platform","getCrypto","Function","crypto","randomBytes","size","Uint8Array","sha256","message","createHash","update","digest","sha256Sync","ExpoCrypto","bytes","getRandomBytesAsync","digestStringAsync","CryptoDigestAlgorithm","SHA256","error","Error","String","getRandomValues","encoder","TextEncoder","data","encode","hashBuffer","subtle","hashArray","Array","from","map","b","toString","padStart","join"],"sourceRoot":"../../../../src","sources":["shared/crypto/platform.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAGA;AACA;AACA;AACA,OAAO,MAAMA,gBAAgB,GAAG;EAC9B;AACF;AACA;EACEC,MAAMA,CAAA,EAAa;IACjB,IAAI,OAAOC,MAAM,KAAK,WAAW,IAAI,OAAOC,OAAO,KAAK,WAAW,IAAIA,OAAO,CAACC,QAAQ,EAAEC,IAAI,EAAE;MAC7F,OAAO,MAAM;IACf;IACA,IAAI,OAAOC,SAAS,KAAK,WAAW,IAAIA,SAAS,CAACC,OAAO,KAAK,aAAa,EAAE;MAC3E,OAAO,cAAc;IACvB;IACA,OAAO,KAAK;EACd,CAAC;EAED;AACF;AACA;EACEC,MAAMA,CAAA,EAAY;IAChB,OAAO,IAAI,CAACP,MAAM,CAAC,CAAC,KAAK,MAAM;EACjC,CAAC;EAED;AACF;AACA;EACEQ,aAAaA,CAAA,EAAY;IACvB,OAAO,IAAI,CAACR,MAAM,CAAC,CAAC,KAAK,cAAc;EACzC,CAAC;EAED;AACF;AACA;EACES,KAAKA,CAAA,EAAY;IACf,OAAO,IAAI,CAACT,MAAM,CAAC,CAAC,KAAK,KAAK;EAChC;AACF,CAAC;;AAED;AACA;AACA;AACA;;AAkBA;AACA;AACA;AACA,OAAO,eAAeU,gBAAgBA,CAAA,EAA2B;EAC/D,MAAMC,QAA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,CAACF,KAAK,CAAC,EAChH,CAAC;IACH;EACF;;EAEA;EACA,IAAI,OAAO7B,MAAM,KAAK,WAAW,IAAIA,MAAM,CAACa,MAAM,EAAE;IAClD,OAAO;MACL,MAAMC,WAAWA,CAACC,IAAY,EAAuB;QACnD,OAAOf,MAAM,CAACa,MAAM,CAACmB,eAAe,CAAC,IAAIhB,UAAU,CAACD,IAAI,CAAC,CAAC;MAC5D,CAAC;MACD,MAAME,MAAMA,CAACC,OAAe,EAAmB;QAC7C,MAAMe,OAAO,GAAG,IAAIC,WAAW,CAAC,CAAC;QACjC,MAAMC,IAAI,GAAGF,OAAO,CAACG,MAAM,CAAClB,OAAO,CAAC;QACpC,MAAMmB,UAAU,GAAG,MAAMrC,MAAM,CAACa,MAAM,CAACyB,MAAM,CAACjB,MAAM,CAAC,SAAS,EAAEc,IAAI,CAAC;QACrE,MAAMI,SAAS,GAAGC,KAAK,CAACC,IAAI,CAAC,IAAIzB,UAAU,CAACqB,UAAU,CAAC,CAAC;QACxD,OAAOE,SAAS,CAACG,GAAG,CAACC,CAAC,IAAIA,CAAC,CAACC,QAAQ,CAAC,EAAE,CAAC,CAACC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,CAACC,IAAI,CAAC,EAAE,CAAC;MACrE;IACF,CAAC;EACH;EAEA,MAAM,IAAIhB,KAAK,CAAC,8DAA8D,CAAC;AACjF","ignoreList":[]}
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Signature Verification Service
|
|
5
|
+
*
|
|
6
|
+
* Unified signature verification used by both backend (API) and SDK.
|
|
7
|
+
* Uses platform adapters for crypto operations while keeping message construction shared.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import { ec as EC } from 'elliptic';
|
|
11
|
+
import { getCryptoAdapter, PlatformDetector } from './platform';
|
|
12
|
+
import { buildAuthMessage, buildRegistrationMessage, buildRequestMessage, isTimestampFresh } from './messageBuilders';
|
|
13
|
+
const ec = new EC('secp256k1');
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Maximum age for signed messages (5 minutes)
|
|
17
|
+
*/
|
|
18
|
+
export const MAX_SIGNATURE_AGE_MS = 5 * 60 * 1000;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Challenge TTL (5 minutes)
|
|
22
|
+
*/
|
|
23
|
+
export const CHALLENGE_TTL_MS = 5 * 60 * 1000;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Signature Service
|
|
27
|
+
* Provides signature verification that works across all platforms
|
|
28
|
+
*/
|
|
29
|
+
export class SignatureService {
|
|
30
|
+
/**
|
|
31
|
+
* Verify an ECDSA signature
|
|
32
|
+
*
|
|
33
|
+
* @param message - The original message that was signed
|
|
34
|
+
* @param signature - The signature in DER format (hex encoded)
|
|
35
|
+
* @param publicKey - The public key (hex encoded, uncompressed)
|
|
36
|
+
* @returns true if the signature is valid
|
|
37
|
+
*/
|
|
38
|
+
static async verify(message, signature, publicKey) {
|
|
39
|
+
try {
|
|
40
|
+
const key = ec.keyFromPublic(publicKey, 'hex');
|
|
41
|
+
const adapter = await getCryptoAdapter();
|
|
42
|
+
const messageHash = await adapter.sha256(message);
|
|
43
|
+
return key.verify(messageHash, signature);
|
|
44
|
+
} catch {
|
|
45
|
+
return false;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Synchronous signature verification (Node.js only)
|
|
51
|
+
* Uses Node.js crypto module directly for hashing
|
|
52
|
+
*/
|
|
53
|
+
static verifySync(message, signature, publicKey) {
|
|
54
|
+
if (!PlatformDetector.isNode()) {
|
|
55
|
+
throw new Error('verifySync should only be used in Node.js. Use verify() in other environments.');
|
|
56
|
+
}
|
|
57
|
+
try {
|
|
58
|
+
// eslint-disable-next-line @typescript-eslint/no-implied-eval
|
|
59
|
+
const getCrypto = new Function('return require("crypto")');
|
|
60
|
+
const crypto = getCrypto();
|
|
61
|
+
const key = ec.keyFromPublic(publicKey, 'hex');
|
|
62
|
+
const messageHash = crypto.createHash('sha256').update(message).digest('hex');
|
|
63
|
+
return key.verify(messageHash, signature);
|
|
64
|
+
} catch {
|
|
65
|
+
return false;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Verify an authentication challenge response
|
|
71
|
+
*
|
|
72
|
+
* @param publicKey - The user's public key
|
|
73
|
+
* @param challenge - The original challenge string
|
|
74
|
+
* @param signature - The signature of the auth message
|
|
75
|
+
* @param timestamp - The timestamp when the signature was created
|
|
76
|
+
* @param maxAgeMs - Maximum age of the signature in milliseconds
|
|
77
|
+
* @returns true if the challenge response is valid
|
|
78
|
+
*/
|
|
79
|
+
static async verifyChallengeResponse(publicKey, challenge, signature, timestamp, maxAgeMs = CHALLENGE_TTL_MS) {
|
|
80
|
+
// Check timestamp freshness
|
|
81
|
+
if (!isTimestampFresh(timestamp, maxAgeMs)) {
|
|
82
|
+
return false;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// Build the canonical message
|
|
86
|
+
const message = buildAuthMessage(publicKey, challenge, timestamp);
|
|
87
|
+
|
|
88
|
+
// Verify the signature
|
|
89
|
+
return this.verify(message, signature, publicKey);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Synchronous challenge response verification (Node.js only)
|
|
94
|
+
*/
|
|
95
|
+
static verifyChallengeResponseSync(publicKey, challenge, signature, timestamp, maxAgeMs = CHALLENGE_TTL_MS) {
|
|
96
|
+
// Check timestamp freshness
|
|
97
|
+
if (!isTimestampFresh(timestamp, maxAgeMs)) {
|
|
98
|
+
return false;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
// Build the canonical message
|
|
102
|
+
const message = buildAuthMessage(publicKey, challenge, timestamp);
|
|
103
|
+
|
|
104
|
+
// Verify the signature
|
|
105
|
+
return this.verifySync(message, signature, publicKey);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Verify a registration signature
|
|
110
|
+
* Signature format: oxy:register:{publicKey}:{timestamp}
|
|
111
|
+
*/
|
|
112
|
+
static async verifyRegistrationSignature(publicKey, signature, timestamp, maxAgeMs = MAX_SIGNATURE_AGE_MS) {
|
|
113
|
+
// Check timestamp freshness
|
|
114
|
+
if (!isTimestampFresh(timestamp, maxAgeMs)) {
|
|
115
|
+
return false;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
// Build the canonical message
|
|
119
|
+
const message = buildRegistrationMessage(publicKey, timestamp);
|
|
120
|
+
|
|
121
|
+
// Verify the signature
|
|
122
|
+
return this.verify(message, signature, publicKey);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Synchronous registration signature verification (Node.js only)
|
|
127
|
+
*/
|
|
128
|
+
static verifyRegistrationSignatureSync(publicKey, signature, timestamp, maxAgeMs = MAX_SIGNATURE_AGE_MS) {
|
|
129
|
+
// Check timestamp freshness
|
|
130
|
+
if (!isTimestampFresh(timestamp, maxAgeMs)) {
|
|
131
|
+
return false;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
// Build the canonical message
|
|
135
|
+
const message = buildRegistrationMessage(publicKey, timestamp);
|
|
136
|
+
|
|
137
|
+
// Verify the signature
|
|
138
|
+
return this.verifySync(message, signature, publicKey);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* Verify a signed request
|
|
143
|
+
* Used for authenticated API operations
|
|
144
|
+
*/
|
|
145
|
+
static async verifyRequestSignature(publicKey, data, signature, timestamp, maxAgeMs = MAX_SIGNATURE_AGE_MS) {
|
|
146
|
+
// Check timestamp freshness
|
|
147
|
+
if (!isTimestampFresh(timestamp, maxAgeMs)) {
|
|
148
|
+
return false;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
// Build the canonical message
|
|
152
|
+
const message = buildRequestMessage(publicKey, timestamp, data);
|
|
153
|
+
|
|
154
|
+
// Verify the signature
|
|
155
|
+
return this.verify(message, signature, publicKey);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* Synchronous request signature verification (Node.js only)
|
|
160
|
+
*/
|
|
161
|
+
static verifyRequestSignatureSync(publicKey, data, signature, timestamp, maxAgeMs = MAX_SIGNATURE_AGE_MS) {
|
|
162
|
+
// Check timestamp freshness
|
|
163
|
+
if (!isTimestampFresh(timestamp, maxAgeMs)) {
|
|
164
|
+
return false;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
// Build the canonical message
|
|
168
|
+
const message = buildRequestMessage(publicKey, timestamp, data);
|
|
169
|
+
|
|
170
|
+
// Verify the signature
|
|
171
|
+
return this.verifySync(message, signature, publicKey);
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* Validate that a string is a valid public key
|
|
176
|
+
*/
|
|
177
|
+
static isValidPublicKey(publicKey) {
|
|
178
|
+
try {
|
|
179
|
+
ec.keyFromPublic(publicKey, 'hex');
|
|
180
|
+
return true;
|
|
181
|
+
} catch {
|
|
182
|
+
return false;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
//# sourceMappingURL=signature.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["ec","EC","getCryptoAdapter","PlatformDetector","buildAuthMessage","buildRegistrationMessage","buildRequestMessage","isTimestampFresh","MAX_SIGNATURE_AGE_MS","CHALLENGE_TTL_MS","SignatureService","verify","message","signature","publicKey","key","keyFromPublic","adapter","messageHash","sha256","verifySync","isNode","Error","getCrypto","Function","crypto","createHash","update","digest","verifyChallengeResponse","challenge","timestamp","maxAgeMs","verifyChallengeResponseSync","verifyRegistrationSignature","verifyRegistrationSignatureSync","verifyRequestSignature","data","verifyRequestSignatureSync","isValidPublicKey"],"sourceRoot":"../../../../src","sources":["shared/crypto/signature.ts"],"mappings":";;AAAA;AACA;A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B,oBAAoB,EAC9B;IACT;IACA,IAAI,CAACD,gBAAgB,CAACwB,SAAS,EAAEC,QAAQ,CAAC,EAAE;MAC1C,OAAO,KAAK;IACd;;IAEA;IACA,MAAMpB,OAAO,GAAGN,mBAAmB,CAACQ,SAAS,EAAEiB,SAAS,EAAEM,IAAI,CAAC;;IAE/D;IACA,OAAO,IAAI,CAACjB,UAAU,CAACR,OAAO,EAAEC,SAAS,EAAEC,SAAS,CAAC;EACvD;;EAEA;AACF;AACA;EACE,OAAOyB,gBAAgBA,CAACzB,SAAiB,EAAW;IAClD,IAAI;MACFd,EAAE,CAACgB,aAAa,CAACF,SAAS,EAAE,KAAK,CAAC;MAClC,OAAO,IAAI;IACb,CAAC,CAAC,MAAM;MACN,OAAO,KAAK;IACd;EACF;AACF","ignoreList":[]}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @oxyhq/shared
|
|
5
|
+
*
|
|
6
|
+
* Shared utilities, models, and crypto primitives for OxyHQ packages.
|
|
7
|
+
*
|
|
8
|
+
* This package provides:
|
|
9
|
+
* - Canonical data models (User, Session, ChallengePayload, etc.)
|
|
10
|
+
* - Unified signature verification across platforms
|
|
11
|
+
* - Platform-agnostic crypto adapters
|
|
12
|
+
* - Shared utility functions
|
|
13
|
+
* - Canonical message builders for signing
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
// Models
|
|
17
|
+
export * from './models/index';
|
|
18
|
+
|
|
19
|
+
// Crypto
|
|
20
|
+
export * from './crypto/signature';
|
|
21
|
+
export * from './crypto/messageBuilders';
|
|
22
|
+
export * from './crypto/platform';
|
|
23
|
+
export { getCryptoAdapter, PlatformDetector } from './crypto/platform';
|
|
24
|
+
|
|
25
|
+
// Utils
|
|
26
|
+
export * from './utils/index';
|
|
27
|
+
|
|
28
|
+
// Transport
|
|
29
|
+
export * from './transport/index';
|
|
30
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["getCryptoAdapter","PlatformDetector"],"sourceRoot":"../../../src","sources":["shared/index.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,cAAc,gBAAgB;;AAE9B;AACA,cAAc,oBAAoB;AAClC,cAAc,0BAA0B;AACxC,cAAc,mBAAmB;AACjC,SAASA,gBAAgB,EAAEC,gBAAgB,QAAQ,mBAAmB;;AAEtE;AACA,cAAc,eAAe;;AAE7B;AACA,cAAc,mBAAmB","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../../../src","sources":["shared/models/index.ts"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Transport Abstraction
|
|
5
|
+
*
|
|
6
|
+
* Unified transport layer for WebSocket, SSE, and polling.
|
|
7
|
+
* Provides automatic fallback and unified configuration.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Transport Interface
|
|
12
|
+
* All transport implementations must implement this
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Transport Factory
|
|
17
|
+
* Creates the appropriate transport based on availability and configuration
|
|
18
|
+
*/
|
|
19
|
+
export class TransportFactory {
|
|
20
|
+
/**
|
|
21
|
+
* Create a transport with automatic fallback
|
|
22
|
+
* Tries WebSocket first, then SSE, then polling
|
|
23
|
+
*/
|
|
24
|
+
static async create(config, callbacks) {
|
|
25
|
+
// Try WebSocket first (best for real-time)
|
|
26
|
+
if (await this.isWebSocketAvailable()) {
|
|
27
|
+
try {
|
|
28
|
+
return new WebSocketTransport(config, callbacks);
|
|
29
|
+
} catch (error) {
|
|
30
|
+
// Fall through to SSE
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// Try SSE second (good for one-way updates)
|
|
35
|
+
if (await this.isSSEAvailable()) {
|
|
36
|
+
try {
|
|
37
|
+
return new SSETransport(config, callbacks);
|
|
38
|
+
} catch (error) {
|
|
39
|
+
// Fall through to polling
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// Fall back to polling (always available)
|
|
44
|
+
return new PollingTransport(config, callbacks);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Check if WebSocket is available
|
|
49
|
+
*/
|
|
50
|
+
static async isWebSocketAvailable() {
|
|
51
|
+
// WebSocket is available in browsers and Node.js with socket.io-client
|
|
52
|
+
return typeof window !== 'undefined' || typeof process !== 'undefined';
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Check if SSE is available
|
|
57
|
+
*/
|
|
58
|
+
static async isSSEAvailable() {
|
|
59
|
+
// SSE is available in browsers via EventSource
|
|
60
|
+
// In Node.js, would need a polyfill or library
|
|
61
|
+
return typeof EventSource !== 'undefined' || typeof window !== 'undefined' && 'EventSource' in window;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* WebSocket Transport Implementation
|
|
67
|
+
* Uses socket.io-client for WebSocket connections
|
|
68
|
+
*/
|
|
69
|
+
class WebSocketTransport {
|
|
70
|
+
socket = null;
|
|
71
|
+
connected = false;
|
|
72
|
+
constructor(config, callbacks) {
|
|
73
|
+
this.config = config;
|
|
74
|
+
this.callbacks = callbacks;
|
|
75
|
+
}
|
|
76
|
+
async connect() {
|
|
77
|
+
// Dynamic import to avoid bundling socket.io-client if not needed
|
|
78
|
+
let io;
|
|
79
|
+
try {
|
|
80
|
+
io = (await import('socket.io-client')).default;
|
|
81
|
+
} catch (error) {
|
|
82
|
+
throw new Error('socket.io-client is required for WebSocket transport. Install it as a dependency.');
|
|
83
|
+
}
|
|
84
|
+
const url = this.config.namespace ? `${this.config.baseURL}/${this.config.namespace}` : this.config.baseURL;
|
|
85
|
+
const socketOptions = {
|
|
86
|
+
transports: ['websocket', 'polling'],
|
|
87
|
+
reconnection: true,
|
|
88
|
+
reconnectionAttempts: this.config.reconnectAttempts ?? 3,
|
|
89
|
+
reconnectionDelay: this.config.reconnectDelay ?? 1000
|
|
90
|
+
};
|
|
91
|
+
if (this.config.accessToken) {
|
|
92
|
+
socketOptions.auth = {
|
|
93
|
+
token: this.config.accessToken
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
this.socket = io(url, socketOptions);
|
|
97
|
+
this.socket.on('connect', () => {
|
|
98
|
+
this.connected = true;
|
|
99
|
+
if (this.config.sessionToken) {
|
|
100
|
+
this.socket.emit('join', this.config.sessionToken);
|
|
101
|
+
}
|
|
102
|
+
this.callbacks.onConnect?.();
|
|
103
|
+
});
|
|
104
|
+
this.socket.on('auth_update', payload => {
|
|
105
|
+
this.callbacks.onUpdate?.(payload);
|
|
106
|
+
});
|
|
107
|
+
this.socket.on('connect_error', error => {
|
|
108
|
+
this.callbacks.onError?.(error);
|
|
109
|
+
});
|
|
110
|
+
this.socket.on('disconnect', () => {
|
|
111
|
+
this.connected = false;
|
|
112
|
+
this.callbacks.onDisconnect?.();
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
disconnect() {
|
|
116
|
+
if (this.socket) {
|
|
117
|
+
this.socket.disconnect();
|
|
118
|
+
this.socket = null;
|
|
119
|
+
this.connected = false;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
isConnected() {
|
|
123
|
+
return this.connected && this.socket?.connected === true;
|
|
124
|
+
}
|
|
125
|
+
getType() {
|
|
126
|
+
return 'websocket';
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* SSE Transport Implementation
|
|
132
|
+
* Uses EventSource for Server-Sent Events
|
|
133
|
+
*/
|
|
134
|
+
class SSETransport {
|
|
135
|
+
eventSource = null;
|
|
136
|
+
connected = false;
|
|
137
|
+
constructor(config, callbacks) {
|
|
138
|
+
this.config = config;
|
|
139
|
+
this.callbacks = callbacks;
|
|
140
|
+
}
|
|
141
|
+
async connect() {
|
|
142
|
+
if (typeof EventSource === 'undefined') {
|
|
143
|
+
throw new Error('EventSource is not available in this environment');
|
|
144
|
+
}
|
|
145
|
+
const url = this.config.sessionToken ? `${this.config.baseURL}/auth/session/stream/${this.config.sessionToken}` : `${this.config.baseURL}/auth/session/stream`;
|
|
146
|
+
this.eventSource = new EventSource(url);
|
|
147
|
+
this.eventSource.onopen = () => {
|
|
148
|
+
this.connected = true;
|
|
149
|
+
this.callbacks.onConnect?.();
|
|
150
|
+
};
|
|
151
|
+
this.eventSource.onmessage = event => {
|
|
152
|
+
try {
|
|
153
|
+
const update = JSON.parse(event.data);
|
|
154
|
+
this.callbacks.onUpdate?.(update);
|
|
155
|
+
} catch (error) {
|
|
156
|
+
this.callbacks.onError?.(error);
|
|
157
|
+
}
|
|
158
|
+
};
|
|
159
|
+
this.eventSource.onerror = error => {
|
|
160
|
+
this.callbacks.onError?.(new Error('SSE connection error'));
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
disconnect() {
|
|
164
|
+
if (this.eventSource) {
|
|
165
|
+
this.eventSource.close();
|
|
166
|
+
this.eventSource = null;
|
|
167
|
+
this.connected = false;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
isConnected() {
|
|
171
|
+
return this.connected && this.eventSource?.readyState === EventSource.OPEN;
|
|
172
|
+
}
|
|
173
|
+
getType() {
|
|
174
|
+
return 'sse';
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* Polling Transport Implementation
|
|
180
|
+
* Uses HTTP polling as fallback
|
|
181
|
+
*/
|
|
182
|
+
class PollingTransport {
|
|
183
|
+
intervalId = null;
|
|
184
|
+
connected = false;
|
|
185
|
+
abortController = null;
|
|
186
|
+
constructor(config, callbacks) {
|
|
187
|
+
this.config = config;
|
|
188
|
+
this.callbacks = callbacks;
|
|
189
|
+
}
|
|
190
|
+
async connect() {
|
|
191
|
+
this.connected = true;
|
|
192
|
+
this.callbacks.onConnect?.();
|
|
193
|
+
const poll = async () => {
|
|
194
|
+
if (!this.config.sessionToken) {
|
|
195
|
+
return;
|
|
196
|
+
}
|
|
197
|
+
try {
|
|
198
|
+
this.abortController = new AbortController();
|
|
199
|
+
const response = await fetch(`${this.config.baseURL}/api/auth/session/status/${this.config.sessionToken}`, {
|
|
200
|
+
signal: this.abortController.signal,
|
|
201
|
+
headers: this.config.accessToken ? {
|
|
202
|
+
Authorization: `Bearer ${this.config.accessToken}`
|
|
203
|
+
} : {}
|
|
204
|
+
});
|
|
205
|
+
if (!response.ok) {
|
|
206
|
+
throw new Error(`Polling failed: ${response.statusText}`);
|
|
207
|
+
}
|
|
208
|
+
const data = await response.json();
|
|
209
|
+
if (data.authorized && data.sessionId) {
|
|
210
|
+
this.callbacks.onUpdate?.({
|
|
211
|
+
status: 'authorized',
|
|
212
|
+
sessionId: data.sessionId,
|
|
213
|
+
publicKey: data.publicKey
|
|
214
|
+
});
|
|
215
|
+
} else if (data.status === 'expired') {
|
|
216
|
+
this.callbacks.onUpdate?.({
|
|
217
|
+
status: 'expired'
|
|
218
|
+
});
|
|
219
|
+
} else if (data.status === 'cancelled') {
|
|
220
|
+
this.callbacks.onUpdate?.({
|
|
221
|
+
status: 'cancelled'
|
|
222
|
+
});
|
|
223
|
+
}
|
|
224
|
+
} catch (error) {
|
|
225
|
+
if (error instanceof Error && error.name !== 'AbortError') {
|
|
226
|
+
this.callbacks.onError?.(error);
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
};
|
|
230
|
+
|
|
231
|
+
// Poll immediately, then at intervals
|
|
232
|
+
await poll();
|
|
233
|
+
this.intervalId = setInterval(poll, this.config.pollingInterval ?? 3000);
|
|
234
|
+
}
|
|
235
|
+
disconnect() {
|
|
236
|
+
if (this.intervalId) {
|
|
237
|
+
clearInterval(this.intervalId);
|
|
238
|
+
this.intervalId = null;
|
|
239
|
+
}
|
|
240
|
+
if (this.abortController) {
|
|
241
|
+
this.abortController.abort();
|
|
242
|
+
this.abortController = null;
|
|
243
|
+
}
|
|
244
|
+
this.connected = false;
|
|
245
|
+
this.callbacks.onDisconnect?.();
|
|
246
|
+
}
|
|
247
|
+
isConnected() {
|
|
248
|
+
return this.connected && this.intervalId !== null;
|
|
249
|
+
}
|
|
250
|
+
getType() {
|
|
251
|
+
return 'polling';
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["TransportFactory","create","config","callbacks","isWebSocketAvailable","WebSocketTransport","error","isSSEAvailable","SSETransport","PollingTransport","window","process","EventSource","socket","connected","constructor","connect","io","default","Error","url","namespace","baseURL","socketOptions","transports","reconnection","reconnectionAttempts","reconnectAttempts","reconnectionDelay","reconnectDelay","accessToken","auth","token","on","sessionToken","emit","onConnect","payload","onUpdate","onError","onDisconnect","disconnect","isConnected","getType","eventSource","onopen","onmessage","event","update","JSON","parse","data","onerror","close","readyState","OPEN","intervalId","abortController","poll","AbortController","response","fetch","signal","headers","Authorization","ok","statusText","json","authorized","sessionId","status","publicKey","name","setInterval","pollingInterval","clearInterval","abort"],"sourceRoot":"../../../../src","sources":["shared/transport/index.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;;AA+BA;AACA;AACA;AACA;;AAuBA;AACA;AACA;AACA;AACA,OAAO,MAAMA,gBAAgB,CAAC;EAC5B;AACF;AACA;AACA;EACE,aAAaC,MAAMA,CACjBC,MAAuB,EACvBC,SAA6B,EACT;IACpB;IACA,IAAI,MAAM,IAAI,CAACC,oBAAoB,CAAC,CAAC,EAAE;MACrC,IAAI;QACF,OAAO,IAAIC,kBAAkB,CAACH,MAAM,EAAEC,SAAS,CAAC;MAClD,CAAC,CAAC,OAAOG,KAAK,EAAE;QACd;MA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