@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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["SECURITY_EVENT_SEVERITY_MAP","exports"],"sourceRoot":"../../../src","sources":["models/interfaces.ts"],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"names":["SECURITY_EVENT_SEVERITY_MAP","exports"],"sourceRoot":"../../../src","sources":["models/interfaces.ts"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAyBA;AACA;;AAyEA;AACA;;AAmEA;AACA;AACA;;AAmDA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAqGA;AACA;AACA;;AAqBA;AACA;AACA;;AAcA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACO,MAAMA,2BAA6E,GAAAC,OAAA,CAAAD,2BAAA,GAAG;EAC3F,SAAS,EAAE,KAAK;EAChB,UAAU,EAAE,KAAK;EACjB,iBAAiB,EAAE,KAAK;EACxB,eAAe,EAAE,QAAQ;EACzB,cAAc,EAAE,QAAQ;EACxB,gBAAgB,EAAE,QAAQ;EAC1B,2BAA2B,EAAE,QAAQ;EACrC,kBAAkB,EAAE,MAAM;EAC1B,sBAAsB,EAAE,MAAM;EAC9B,gBAAgB,EAAE,MAAM;EACxB,qBAAqB,EAAE;AACzB,CAAC;;AAED;AACA;AACA;;AAeA;AACA;AACA;;AAkBA;AACA","ignoreList":[]}
|
|
@@ -0,0 +1,79 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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"],"mappings":";;;;;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;;AAIA;AACA;AACA;AACA;AACO,SAASA,gBAAgBA,CAC9BC,SAAiB,EACjBC,SAAiB,EACjBC,SAAiB,EACT;EACR,OAAO,QAAQF,SAAS,IAAIC,SAAS,IAAIC,SAAS,EAAE;AACtD;;AAEA;AACA;AACA;AACA;AACO,SAASC,wBAAwBA,CACtCH,SAAiB,EACjBE,SAAiB,EACT;EACR,OAAO,gBAAgBF,SAAS,IAAIE,SAAS,EAAE;AACjD;;AAEA;AACA;AACA;AACA;AACO,SAASE,mBAAmBA,CACjCJ,SAAiB,EACjBE,SAAiB,EACjBG,IAA6B,EACrB;EACR;EACA,MAAMC,UAAU,GAAGC,MAAM,CAACC,IAAI,CAACH,IAAI,CAAC,CAACI,IAAI,CAAC,CAAC;EAC3C,MAAMC,cAAc,GAAGJ,UAAU,CAACK,GAAG,CAACC,GAAG,IAAI,GAAGA,GAAG,IAAIC,IAAI,CAACC,SAAS,CAACT,IAAI,CAACO,GAAG,CAAC,CAAC,EAAE,CAAC;EACnF,MAAMG,eAAe,GAAGL,cAAc,CAACM,IAAI,CAAC,GAAG,CAAC;EAEhD,OAAO,WAAWhB,SAAS,IAAIE,SAAS,IAAIa,eAAe,EAAE;AAC/D;;AAEA;AACA;AACA;AACA;AACO,SAASE,gBAAgBA,CAACZ,IAA6B,EAAU;EACtE,MAAMC,UAAU,GAAGC,MAAM,CAACC,IAAI,CAACH,IAAI,CAAC,CAACI,IAAI,CAAC,CAAC;EAC3C,MAAMC,cAAc,GAAGJ,UAAU,CAACK,GAAG,CAACC,GAAG,IAAI,GAAGA,GAAG,IAAIC,IAAI,CAACC,SAAS,CAACT,IAAI,CAACO,GAAG,CAAC,CAAC,EAAE,CAAC;EACnF,OAAOF,cAAc,CAACM,IAAI,CAAC,GAAG,CAAC;AACjC;;AAEA;AACA;AACA;AACA;AACO,SAASE,0BAA0BA,CACxClB,SAAiB,EACjBC,SAAiB,EACjBkB,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":[]}
|
|
@@ -0,0 +1,118 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["PlatformDetector","exports","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","Promise","resolve","then","_interopRequireWildcard","require","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;AACO,MAAMA,gBAAgB,GAAAC,OAAA,CAAAD,gBAAA,GAAG;EAC9B;AACF;AACA;EACEE,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,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,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,191 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.SignatureService = exports.MAX_SIGNATURE_AGE_MS = exports.CHALLENGE_TTL_MS = void 0;
|
|
7
|
+
var _elliptic = require("elliptic");
|
|
8
|
+
var _platform = require("./platform");
|
|
9
|
+
var _messageBuilders = require("./messageBuilders");
|
|
10
|
+
/**
|
|
11
|
+
* Signature Verification Service
|
|
12
|
+
*
|
|
13
|
+
* Unified signature verification used by both backend (API) and SDK.
|
|
14
|
+
* Uses platform adapters for crypto operations while keeping message construction shared.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
const ec = new _elliptic.ec('secp256k1');
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Maximum age for signed messages (5 minutes)
|
|
21
|
+
*/
|
|
22
|
+
const MAX_SIGNATURE_AGE_MS = exports.MAX_SIGNATURE_AGE_MS = 5 * 60 * 1000;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Challenge TTL (5 minutes)
|
|
26
|
+
*/
|
|
27
|
+
const CHALLENGE_TTL_MS = exports.CHALLENGE_TTL_MS = 5 * 60 * 1000;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Signature Service
|
|
31
|
+
* Provides signature verification that works across all platforms
|
|
32
|
+
*/
|
|
33
|
+
class SignatureService {
|
|
34
|
+
/**
|
|
35
|
+
* Verify an ECDSA signature
|
|
36
|
+
*
|
|
37
|
+
* @param message - The original message that was signed
|
|
38
|
+
* @param signature - The signature in DER format (hex encoded)
|
|
39
|
+
* @param publicKey - The public key (hex encoded, uncompressed)
|
|
40
|
+
* @returns true if the signature is valid
|
|
41
|
+
*/
|
|
42
|
+
static async verify(message, signature, publicKey) {
|
|
43
|
+
try {
|
|
44
|
+
const key = ec.keyFromPublic(publicKey, 'hex');
|
|
45
|
+
const adapter = await (0, _platform.getCryptoAdapter)();
|
|
46
|
+
const messageHash = await adapter.sha256(message);
|
|
47
|
+
return key.verify(messageHash, signature);
|
|
48
|
+
} catch {
|
|
49
|
+
return false;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Synchronous signature verification (Node.js only)
|
|
55
|
+
* Uses Node.js crypto module directly for hashing
|
|
56
|
+
*/
|
|
57
|
+
static verifySync(message, signature, publicKey) {
|
|
58
|
+
if (!_platform.PlatformDetector.isNode()) {
|
|
59
|
+
throw new Error('verifySync should only be used in Node.js. Use verify() in other environments.');
|
|
60
|
+
}
|
|
61
|
+
try {
|
|
62
|
+
// eslint-disable-next-line @typescript-eslint/no-implied-eval
|
|
63
|
+
const getCrypto = new Function('return require("crypto")');
|
|
64
|
+
const crypto = getCrypto();
|
|
65
|
+
const key = ec.keyFromPublic(publicKey, 'hex');
|
|
66
|
+
const messageHash = crypto.createHash('sha256').update(message).digest('hex');
|
|
67
|
+
return key.verify(messageHash, signature);
|
|
68
|
+
} catch {
|
|
69
|
+
return false;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Verify an authentication challenge response
|
|
75
|
+
*
|
|
76
|
+
* @param publicKey - The user's public key
|
|
77
|
+
* @param challenge - The original challenge string
|
|
78
|
+
* @param signature - The signature of the auth message
|
|
79
|
+
* @param timestamp - The timestamp when the signature was created
|
|
80
|
+
* @param maxAgeMs - Maximum age of the signature in milliseconds
|
|
81
|
+
* @returns true if the challenge response is valid
|
|
82
|
+
*/
|
|
83
|
+
static async verifyChallengeResponse(publicKey, challenge, signature, timestamp, maxAgeMs = CHALLENGE_TTL_MS) {
|
|
84
|
+
// Check timestamp freshness
|
|
85
|
+
if (!(0, _messageBuilders.isTimestampFresh)(timestamp, maxAgeMs)) {
|
|
86
|
+
return false;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// Build the canonical message
|
|
90
|
+
const message = (0, _messageBuilders.buildAuthMessage)(publicKey, challenge, timestamp);
|
|
91
|
+
|
|
92
|
+
// Verify the signature
|
|
93
|
+
return this.verify(message, signature, publicKey);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Synchronous challenge response verification (Node.js only)
|
|
98
|
+
*/
|
|
99
|
+
static verifyChallengeResponseSync(publicKey, challenge, signature, timestamp, maxAgeMs = CHALLENGE_TTL_MS) {
|
|
100
|
+
// Check timestamp freshness
|
|
101
|
+
if (!(0, _messageBuilders.isTimestampFresh)(timestamp, maxAgeMs)) {
|
|
102
|
+
return false;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// Build the canonical message
|
|
106
|
+
const message = (0, _messageBuilders.buildAuthMessage)(publicKey, challenge, timestamp);
|
|
107
|
+
|
|
108
|
+
// Verify the signature
|
|
109
|
+
return this.verifySync(message, signature, publicKey);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Verify a registration signature
|
|
114
|
+
* Signature format: oxy:register:{publicKey}:{timestamp}
|
|
115
|
+
*/
|
|
116
|
+
static async verifyRegistrationSignature(publicKey, signature, timestamp, maxAgeMs = MAX_SIGNATURE_AGE_MS) {
|
|
117
|
+
// Check timestamp freshness
|
|
118
|
+
if (!(0, _messageBuilders.isTimestampFresh)(timestamp, maxAgeMs)) {
|
|
119
|
+
return false;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
// Build the canonical message
|
|
123
|
+
const message = (0, _messageBuilders.buildRegistrationMessage)(publicKey, timestamp);
|
|
124
|
+
|
|
125
|
+
// Verify the signature
|
|
126
|
+
return this.verify(message, signature, publicKey);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* Synchronous registration signature verification (Node.js only)
|
|
131
|
+
*/
|
|
132
|
+
static verifyRegistrationSignatureSync(publicKey, signature, timestamp, maxAgeMs = MAX_SIGNATURE_AGE_MS) {
|
|
133
|
+
// Check timestamp freshness
|
|
134
|
+
if (!(0, _messageBuilders.isTimestampFresh)(timestamp, maxAgeMs)) {
|
|
135
|
+
return false;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
// Build the canonical message
|
|
139
|
+
const message = (0, _messageBuilders.buildRegistrationMessage)(publicKey, timestamp);
|
|
140
|
+
|
|
141
|
+
// Verify the signature
|
|
142
|
+
return this.verifySync(message, signature, publicKey);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* Verify a signed request
|
|
147
|
+
* Used for authenticated API operations
|
|
148
|
+
*/
|
|
149
|
+
static async verifyRequestSignature(publicKey, data, signature, timestamp, maxAgeMs = MAX_SIGNATURE_AGE_MS) {
|
|
150
|
+
// Check timestamp freshness
|
|
151
|
+
if (!(0, _messageBuilders.isTimestampFresh)(timestamp, maxAgeMs)) {
|
|
152
|
+
return false;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
// Build the canonical message
|
|
156
|
+
const message = (0, _messageBuilders.buildRequestMessage)(publicKey, timestamp, data);
|
|
157
|
+
|
|
158
|
+
// Verify the signature
|
|
159
|
+
return this.verify(message, signature, publicKey);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* Synchronous request signature verification (Node.js only)
|
|
164
|
+
*/
|
|
165
|
+
static verifyRequestSignatureSync(publicKey, data, signature, timestamp, maxAgeMs = MAX_SIGNATURE_AGE_MS) {
|
|
166
|
+
// Check timestamp freshness
|
|
167
|
+
if (!(0, _messageBuilders.isTimestampFresh)(timestamp, maxAgeMs)) {
|
|
168
|
+
return false;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
// Build the canonical message
|
|
172
|
+
const message = (0, _messageBuilders.buildRequestMessage)(publicKey, timestamp, data);
|
|
173
|
+
|
|
174
|
+
// Verify the signature
|
|
175
|
+
return this.verifySync(message, signature, publicKey);
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* Validate that a string is a valid public key
|
|
180
|
+
*/
|
|
181
|
+
static isValidPublicKey(publicKey) {
|
|
182
|
+
try {
|
|
183
|
+
ec.keyFromPublic(publicKey, 'hex');
|
|
184
|
+
return true;
|
|
185
|
+
} catch {
|
|
186
|
+
return false;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
exports.SignatureService = SignatureService;
|
|
191
|
+
//# sourceMappingURL=signature.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_elliptic","require","_platform","_messageBuilders","ec","EC","MAX_SIGNATURE_AGE_MS","exports","CHALLENGE_TTL_MS","SignatureService","verify","message","signature","publicKey","key","keyFromPublic","adapter","getCryptoAdapter","messageHash","sha256","verifySync","PlatformDetector","isNode","Error","getCrypto","Function","crypto","createHash","update","digest","verifyChallengeResponse","challenge","timestamp","maxAgeMs","isTimestampFresh","buildAuthMessage","verifyChallengeResponseSync","verifyRegistrationSignature","buildRegistrationMessage","verifyRegistrationSignatureSync","verifyRequestSignature","data","buildRequestMessage","verifyRequestSignatureSync","isValidPublicKey"],"sourceRoot":"../../../../src","sources":["shared/crypto/signature.ts"],"mappings":";;;;;;AAOA,IAAAA,SAAA,GAAAC,OAAA;AACA,IAAAC,SAAA,GAAAD,OAAA;AACA,IAAAE,gBAAA,GAAAF,OAAA;AATA;AACA;AACA;AACA;AACA;AACA;;AAWA,MAAMG,EAAE,GAAG,IAAIC,YAAE,CAAC,WAAW,CAAC;;AAE9B;AACA;AACA;AACO,MAAMC,oBAAoB,GAAAC,OAAA,CAAAD,oBAAA,GAAG,CAAC,GAAG,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AC;;IAE/D;IACA,OAAO,IAAI,CAACrB,UAAU,CAACT,OAAO,EAAEC,SAAS,EAAEC,SAAS,CAAC;EACvD;;EAEA;AACF;AACA;EACE,OAAO+B,gBAAgBA,CAAC/B,SAAiB,EAAW;IAClD,IAAI;MACFT,EAAE,CAACW,aAAa,CAACF,SAAS,EAAE,KAAK,CAAC;MAClC,OAAO,IAAI;IACb,CAAC,CAAC,MAAM;MACN,OAAO,KAAK;IACd;EACF;AACF;AAACN,OAAA,CAAAE,gBAAA,GAAAA,gBAAA","ignoreList":[]}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
var _exportNames = {
|
|
7
|
+
getCryptoAdapter: true,
|
|
8
|
+
PlatformDetector: true
|
|
9
|
+
};
|
|
10
|
+
Object.defineProperty(exports, "PlatformDetector", {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function () {
|
|
13
|
+
return _platform.PlatformDetector;
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
Object.defineProperty(exports, "getCryptoAdapter", {
|
|
17
|
+
enumerable: true,
|
|
18
|
+
get: function () {
|
|
19
|
+
return _platform.getCryptoAdapter;
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
var _index = require("./models/index");
|
|
23
|
+
Object.keys(_index).forEach(function (key) {
|
|
24
|
+
if (key === "default" || key === "__esModule") return;
|
|
25
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
26
|
+
if (key in exports && exports[key] === _index[key]) return;
|
|
27
|
+
Object.defineProperty(exports, key, {
|
|
28
|
+
enumerable: true,
|
|
29
|
+
get: function () {
|
|
30
|
+
return _index[key];
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
var _signature = require("./crypto/signature");
|
|
35
|
+
Object.keys(_signature).forEach(function (key) {
|
|
36
|
+
if (key === "default" || key === "__esModule") return;
|
|
37
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
38
|
+
if (key in exports && exports[key] === _signature[key]) return;
|
|
39
|
+
Object.defineProperty(exports, key, {
|
|
40
|
+
enumerable: true,
|
|
41
|
+
get: function () {
|
|
42
|
+
return _signature[key];
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
var _messageBuilders = require("./crypto/messageBuilders");
|
|
47
|
+
Object.keys(_messageBuilders).forEach(function (key) {
|
|
48
|
+
if (key === "default" || key === "__esModule") return;
|
|
49
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
50
|
+
if (key in exports && exports[key] === _messageBuilders[key]) return;
|
|
51
|
+
Object.defineProperty(exports, key, {
|
|
52
|
+
enumerable: true,
|
|
53
|
+
get: function () {
|
|
54
|
+
return _messageBuilders[key];
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
});
|
|
58
|
+
var _platform = require("./crypto/platform");
|
|
59
|
+
Object.keys(_platform).forEach(function (key) {
|
|
60
|
+
if (key === "default" || key === "__esModule") return;
|
|
61
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
62
|
+
if (key in exports && exports[key] === _platform[key]) return;
|
|
63
|
+
Object.defineProperty(exports, key, {
|
|
64
|
+
enumerable: true,
|
|
65
|
+
get: function () {
|
|
66
|
+
return _platform[key];
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
});
|
|
70
|
+
var _index2 = require("./utils/index");
|
|
71
|
+
Object.keys(_index2).forEach(function (key) {
|
|
72
|
+
if (key === "default" || key === "__esModule") return;
|
|
73
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
74
|
+
if (key in exports && exports[key] === _index2[key]) return;
|
|
75
|
+
Object.defineProperty(exports, key, {
|
|
76
|
+
enumerable: true,
|
|
77
|
+
get: function () {
|
|
78
|
+
return _index2[key];
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
});
|
|
82
|
+
var _index3 = require("./transport/index");
|
|
83
|
+
Object.keys(_index3).forEach(function (key) {
|
|
84
|
+
if (key === "default" || key === "__esModule") return;
|
|
85
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
86
|
+
if (key in exports && exports[key] === _index3[key]) return;
|
|
87
|
+
Object.defineProperty(exports, key, {
|
|
88
|
+
enumerable: true,
|
|
89
|
+
get: function () {
|
|
90
|
+
return _index3[key];
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
});
|
|
94
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_index","require","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","_signature","_messageBuilders","_platform","_index2","_index3"],"sourceRoot":"../../../src","sources":["shared/index.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAcA,IAAAA,MAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,MAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAC,YAAA,EAAAJ,GAAA;EAAA,IAAAA,GAAA,IAAAK,OAAA,IAAAA,OAAA,CAAAL,GAAA,MAAAL,MAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAS,cAAA,CAAAD,OAAA,EAAAL,GAAA;IAAAO,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAb,MAAA,CAAAK,GAAA;IAAA;EAAA;AAAA;AAGA,IAAAS,UAAA,GAAAb,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAW,UAAA,EAAAV,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA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