@oxyhq/core 4.0.0 → 5.0.0
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/dist/cjs/.tsbuildinfo +1 -1
- package/dist/cjs/HttpService.js +6 -18
- package/dist/cjs/OxyServices.base.js +0 -21
- package/dist/cjs/crypto/keyManager.js +7 -7
- package/dist/cjs/crypto/polyfill.js +6 -5
- package/dist/cjs/crypto/signatureService.js +44 -220
- package/dist/cjs/i18n/locales/en-US.json +391 -17
- package/dist/cjs/i18n/locales/es-ES.json +391 -17
- package/dist/cjs/i18n/locales/locales/en-US.json +391 -17
- package/dist/cjs/i18n/locales/locales/es-ES.json +391 -17
- package/dist/cjs/index.js +4 -8
- package/dist/cjs/mixins/OxyServices.accounts.js +54 -0
- package/dist/cjs/mixins/OxyServices.assets.js +2 -2
- package/dist/cjs/mixins/OxyServices.auth.js +3 -3
- package/dist/cjs/mixins/OxyServices.civic.js +3 -3
- package/dist/cjs/mixins/OxyServices.language.js +2 -2
- package/dist/cjs/mixins/OxyServices.utility.js +7 -95
- package/dist/cjs/utils/cacheKey.js +17 -19
- package/dist/cjs/utils/deviceManager.js +2 -2
- package/dist/cjs/utils/platform.js +0 -14
- package/dist/esm/.tsbuildinfo +1 -1
- package/dist/esm/HttpService.js +6 -18
- package/dist/esm/OxyServices.base.js +0 -21
- package/dist/esm/crypto/keyManager.js +4 -4
- package/dist/esm/crypto/polyfill.js +5 -4
- package/dist/esm/crypto/signatureService.js +39 -214
- package/dist/esm/i18n/locales/en-US.json +391 -17
- package/dist/esm/i18n/locales/es-ES.json +391 -17
- package/dist/esm/i18n/locales/locales/en-US.json +391 -17
- package/dist/esm/i18n/locales/locales/es-ES.json +391 -17
- package/dist/esm/index.js +1 -2
- package/dist/esm/mixins/OxyServices.accounts.js +54 -0
- package/dist/esm/mixins/OxyServices.assets.js +1 -1
- package/dist/esm/mixins/OxyServices.auth.js +1 -1
- package/dist/esm/mixins/OxyServices.civic.js +3 -3
- package/dist/esm/mixins/OxyServices.language.js +1 -1
- package/dist/esm/mixins/OxyServices.utility.js +6 -94
- package/dist/esm/utils/cacheKey.js +17 -19
- package/dist/esm/utils/deviceManager.js +1 -1
- package/dist/esm/utils/platform.js +0 -12
- package/dist/types/.tsbuildinfo +1 -1
- package/dist/types/HttpService.d.ts +3 -6
- package/dist/types/OxyServices.base.d.ts +0 -17
- package/dist/types/crypto/polyfill.d.ts +2 -2
- package/dist/types/crypto/signatureService.d.ts +18 -84
- package/dist/types/index.d.ts +3 -4
- package/dist/types/mixins/OxyServices.accounts.d.ts +57 -5
- package/dist/types/mixins/OxyServices.analytics.d.ts +0 -2
- package/dist/types/mixins/OxyServices.appData.d.ts +0 -2
- package/dist/types/mixins/OxyServices.assets.d.ts +0 -2
- package/dist/types/mixins/OxyServices.auth.d.ts +0 -2
- package/dist/types/mixins/OxyServices.civic.d.ts +3 -5
- package/dist/types/mixins/OxyServices.connectedApps.d.ts +0 -2
- package/dist/types/mixins/OxyServices.contacts.d.ts +0 -2
- package/dist/types/mixins/OxyServices.devices.d.ts +0 -2
- package/dist/types/mixins/OxyServices.features.d.ts +0 -2
- package/dist/types/mixins/OxyServices.fedcm.d.ts +0 -2
- package/dist/types/mixins/OxyServices.identity.d.ts +8 -5
- package/dist/types/mixins/OxyServices.language.d.ts +0 -2
- package/dist/types/mixins/OxyServices.links.d.ts +0 -2
- package/dist/types/mixins/OxyServices.location.d.ts +0 -2
- package/dist/types/mixins/OxyServices.nodes.d.ts +0 -44
- package/dist/types/mixins/OxyServices.payment.d.ts +0 -2
- package/dist/types/mixins/OxyServices.privacy.d.ts +0 -2
- package/dist/types/mixins/OxyServices.redirect.d.ts +0 -2
- package/dist/types/mixins/OxyServices.reputation.d.ts +0 -2
- package/dist/types/mixins/OxyServices.security.d.ts +0 -2
- package/dist/types/mixins/OxyServices.silent.d.ts +0 -2
- package/dist/types/mixins/OxyServices.sso.d.ts +0 -2
- package/dist/types/mixins/OxyServices.topics.d.ts +0 -2
- package/dist/types/mixins/OxyServices.user.d.ts +0 -2
- package/dist/types/mixins/OxyServices.utility.d.ts +0 -32
- package/dist/types/server/auth.d.ts +0 -6
- package/dist/types/server/index.d.ts +1 -1
- package/dist/types/utils/cacheKey.d.ts +6 -7
- package/dist/types/utils/platform.d.ts +0 -8
- package/package.json +4 -7
- package/src/HttpService.ts +6 -22
- package/src/OxyServices.base.ts +0 -23
- package/src/__tests__/httpServiceCache.test.ts +0 -19
- package/src/crypto/__tests__/keyManager.atomicity.test.ts +2 -1
- package/src/crypto/__tests__/keyManager.test.ts +9 -7
- package/src/crypto/__tests__/signChallengeShared.test.ts +2 -1
- package/src/crypto/__tests__/signedRecord.test.ts +37 -150
- package/src/crypto/keyManager.ts +28 -17
- package/src/crypto/polyfill.ts +5 -4
- package/src/crypto/signatureService.ts +67 -255
- package/src/i18n/locales/en-US.json +391 -17
- package/src/i18n/locales/es-ES.json +391 -17
- package/src/index.ts +3 -3
- package/src/mixins/OxyServices.accounts.ts +91 -3
- package/src/mixins/OxyServices.assets.ts +1 -1
- package/src/mixins/OxyServices.auth.ts +1 -1
- package/src/mixins/OxyServices.civic.ts +6 -17
- package/src/mixins/OxyServices.identity.ts +8 -2
- package/src/mixins/OxyServices.language.ts +1 -1
- package/src/mixins/OxyServices.nodes.ts +1 -12
- package/src/mixins/OxyServices.utility.ts +6 -119
- package/src/mixins/__tests__/OxyServices.civic.test.ts +2 -2
- package/src/mixins/__tests__/accounts.test.ts +70 -0
- package/src/server/auth.ts +0 -7
- package/src/server/index.ts +0 -1
- package/src/utils/__tests__/cacheKey.test.ts +0 -0
- package/src/utils/cacheKey.ts +16 -21
- package/src/utils/deviceManager.ts +1 -1
- package/src/utils/platform.ts +0 -14
- package/dist/cjs/crypto/canonicalJson.js +0 -107
- package/dist/cjs/utils/platformCrypto.js +0 -165
- package/dist/cjs/utils/platformCrypto.native.js +0 -123
- package/dist/esm/crypto/canonicalJson.js +0 -104
- package/dist/esm/utils/platformCrypto.js +0 -125
- package/dist/esm/utils/platformCrypto.native.js +0 -80
- package/dist/types/crypto/canonicalJson.d.ts +0 -44
- package/dist/types/utils/platformCrypto.d.ts +0 -87
- package/dist/types/utils/platformCrypto.native.d.ts +0 -54
- package/src/crypto/__tests__/canonicalJson.test.ts +0 -116
- package/src/crypto/canonicalJson.ts +0 -120
- package/src/utils/platformCrypto.native.ts +0 -101
- package/src/utils/platformCrypto.ts +0 -145
|
@@ -1,145 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Platform Crypto / Storage — Default Variant (Node.js, Browser, generic bundlers)
|
|
3
|
-
*
|
|
4
|
-
* Provides lazy access to platform-specific crypto and storage modules.
|
|
5
|
-
*
|
|
6
|
-
* # Variants
|
|
7
|
-
*
|
|
8
|
-
* This module ships in two physical variants on disk, selected per consumer
|
|
9
|
-
* by the bundler / runtime:
|
|
10
|
-
*
|
|
11
|
-
* - `platformCrypto.js` — this file. Used by Node.js, Vite, webpack,
|
|
12
|
-
* Rollup, esbuild, and anything that does
|
|
13
|
-
* not match Metro's `*.native.js`
|
|
14
|
-
* source-extension preference.
|
|
15
|
-
* - `platformCrypto.native.js` — sibling file. Picked up automatically by
|
|
16
|
-
* Metro's resolver (which prefers
|
|
17
|
-
* `*.<platform>.js` and `*.native.js` over
|
|
18
|
-
* plain `*.js` when `preferNativePlatform`
|
|
19
|
-
* is true — Expo sets this for all non-web
|
|
20
|
-
* builds).
|
|
21
|
-
*
|
|
22
|
-
* The `package.json#exports` map also declares a `"react-native"` condition
|
|
23
|
-
* pointing at the same `dist/esm/index.js` entry — that entry transitively
|
|
24
|
-
* imports `./platformCrypto`, and Metro's per-file source-extension lookup
|
|
25
|
-
* substitutes the `.native.js` sibling automatically inside `dist/`. This
|
|
26
|
-
* means consumers never have to add resolver shims; Metro Just Works.
|
|
27
|
-
*
|
|
28
|
-
* Both variants expose the EXACT same public API; importers don't need to know
|
|
29
|
-
* which one they got. The variant difference is purely about which underlying
|
|
30
|
-
* native modules each one references:
|
|
31
|
-
*
|
|
32
|
-
* ┌──────────────────┬───────────────────────┬───────────────────────────────┐
|
|
33
|
-
* │ Function │ Default variant │ React Native variant │
|
|
34
|
-
* ├──────────────────┼───────────────────────┼───────────────────────────────┤
|
|
35
|
-
* │ loadNodeCrypto │ `await import('crypto')` (Node built-in) │
|
|
36
|
-
* │ │ │ throws — Node crypto is not │
|
|
37
|
-
* │ │ │ available on Hermes/RN │
|
|
38
|
-
* ├──────────────────┼───────────────────────┼───────────────────────────────┤
|
|
39
|
-
* │ loadExpoCrypto │ throws — expo-crypto │ static `import 'expo-crypto'` │
|
|
40
|
-
* │ │ is not part of a │ │
|
|
41
|
-
* │ │ Node/Vite bundle │ │
|
|
42
|
-
* ├──────────────────┼───────────────────────┼───────────────────────────────┤
|
|
43
|
-
* │ loadSecureStore │ throws (web/Node have │ static `import 'expo-secure-` │
|
|
44
|
-
* │ │ their own storage) │ store' │
|
|
45
|
-
* ├──────────────────┼───────────────────────┼───────────────────────────────┤
|
|
46
|
-
* │ loadAsyncStorage │ throws (web/Node have │ static `import '@react- │
|
|
47
|
-
* │ │ their own storage) │ native-async-storage/...' │
|
|
48
|
-
* ├──────────────────┼───────────────────────┼───────────────────────────────┤
|
|
49
|
-
* │ getRandomBytesRN │ throws (RN-only) │ direct call into expo-crypto │
|
|
50
|
-
* └──────────────────┴───────────────────────┴───────────────────────────────┘
|
|
51
|
-
*
|
|
52
|
-
* Crucially, the default variant references ONLY Node's `'crypto'`. It never
|
|
53
|
-
* mentions `expo-*` or `@react-native-async-storage/*` — so Vite, webpack,
|
|
54
|
-
* esbuild, Rollup, and Node itself can bundle / require it without ever
|
|
55
|
-
* attempting to resolve those RN-only packages.
|
|
56
|
-
*
|
|
57
|
-
* The React Native variant references ONLY the RN packages. It never
|
|
58
|
-
* mentions `'crypto'` — so Metro and Hermes have nothing to choke on.
|
|
59
|
-
*
|
|
60
|
-
* # Why not a single file with dynamic import?
|
|
61
|
-
*
|
|
62
|
-
* A previous iteration used a "bundler-opaque" `new Function('s', 'return
|
|
63
|
-
* import(s)')` trick so a single file could service every platform. It
|
|
64
|
-
* bundled cleanly on Metro but Hermes refused to PARSE the resulting
|
|
65
|
-
* `import()` expression inside a Function-constructor body
|
|
66
|
-
* (`SyntaxError: Invalid expression encountered` at the `(` of `import(`).
|
|
67
|
-
* The platform-extension split is the only approach that lets each runtime
|
|
68
|
-
* see a file containing only specifiers it can understand — no tricks, no
|
|
69
|
-
* runtime parsing risks.
|
|
70
|
-
*/
|
|
71
|
-
|
|
72
|
-
import { isReactNative } from './platform';
|
|
73
|
-
|
|
74
|
-
// ---------------------------------------------------------------------------
|
|
75
|
-
// Node `crypto` — Node built-in
|
|
76
|
-
//
|
|
77
|
-
// `await import('crypto')` here is a real, static-from-tsc's-perspective
|
|
78
|
-
// dynamic import. Node ESM, Vite, webpack, and esbuild all resolve it fine.
|
|
79
|
-
// Metro never sees this file because the `.react-native.js` sibling shadows
|
|
80
|
-
// it, so Metro never tries to resolve `'crypto'`.
|
|
81
|
-
// ---------------------------------------------------------------------------
|
|
82
|
-
|
|
83
|
-
let cachedNodeCrypto: typeof import('crypto') | null = null;
|
|
84
|
-
|
|
85
|
-
export async function loadNodeCrypto(): Promise<typeof import('crypto')> {
|
|
86
|
-
if (cachedNodeCrypto) {
|
|
87
|
-
return cachedNodeCrypto;
|
|
88
|
-
}
|
|
89
|
-
cachedNodeCrypto = await import('node:crypto');
|
|
90
|
-
return cachedNodeCrypto;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
// ---------------------------------------------------------------------------
|
|
94
|
-
// RN-only modules — never called from this variant.
|
|
95
|
-
//
|
|
96
|
-
// These throw a clear error if anything ever reaches them outside RN. In
|
|
97
|
-
// practice every caller gates with `isReactNative()` before calling, so
|
|
98
|
-
// these are belt-and-braces.
|
|
99
|
-
// ---------------------------------------------------------------------------
|
|
100
|
-
|
|
101
|
-
function notReactNativeError(module: string): Error {
|
|
102
|
-
return new Error(
|
|
103
|
-
`[oxy.platformCrypto] Tried to load '${module}' outside React Native. This module is only available in a React Native runtime; bundling routed this consumer to the default (Node/web) variant. This indicates a missing platform gate (\`isReactNative()\`) in the calling code.`,
|
|
104
|
-
);
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
export async function loadExpoCrypto(): Promise<typeof import('expo-crypto')> {
|
|
108
|
-
if (isReactNative()) {
|
|
109
|
-
// Should be unreachable: when running on RN, Metro / the `react-native`
|
|
110
|
-
// exports condition serves the sibling variant. If we got here, the
|
|
111
|
-
// package-exports map is misconfigured for this host. Throw with a
|
|
112
|
-
// helpful diagnostic rather than fall back to a broken dynamic import.
|
|
113
|
-
throw new Error(
|
|
114
|
-
'[oxy.platformCrypto] React Native runtime resolved the default ' +
|
|
115
|
-
'(non-RN) variant of @oxyhq/core/utils/platformCrypto. Check the ' +
|
|
116
|
-
"consumer's bundler resolution — Metro should pick the sibling " +
|
|
117
|
-
'.react-native.js file via package exports.',
|
|
118
|
-
);
|
|
119
|
-
}
|
|
120
|
-
throw notReactNativeError('expo-crypto');
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
export async function loadSecureStore(): Promise<typeof import('expo-secure-store')> {
|
|
124
|
-
throw notReactNativeError('expo-secure-store');
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
export async function loadAsyncStorage(): Promise<{
|
|
128
|
-
default: {
|
|
129
|
-
getItem: (key: string) => Promise<string | null>;
|
|
130
|
-
setItem: (key: string, value: string) => Promise<void>;
|
|
131
|
-
removeItem: (key: string) => Promise<void>;
|
|
132
|
-
};
|
|
133
|
-
}> {
|
|
134
|
-
throw notReactNativeError('@react-native-async-storage/async-storage');
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
/**
|
|
138
|
-
* Synchronous random-bytes via `expo-crypto.getRandomBytes`. Only available
|
|
139
|
-
* in the React Native variant. The default variant throws because Node and
|
|
140
|
-
* browsers have their own native CSPRNGs (`crypto.randomBytes` and
|
|
141
|
-
* `crypto.getRandomValues` respectively) — callers should use those.
|
|
142
|
-
*/
|
|
143
|
-
export function getRandomBytesRN(_byteCount: number): Uint8Array {
|
|
144
|
-
throw notReactNativeError('expo-crypto.getRandomBytes (sync)');
|
|
145
|
-
}
|