@oxy.so/services 13.4.0 → 13.5.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/README.md +12 -11
- package/lib/commonjs/ui/session/nativeSecureStorage.js +26 -18
- package/lib/commonjs/ui/session/nativeSecureStorage.js.map +1 -1
- package/lib/commonjs/ui/session/sharedDeviceCredentialStore.js +25 -16
- package/lib/commonjs/ui/session/sharedDeviceCredentialStore.js.map +1 -1
- package/lib/module/ui/session/nativeSecureStorage.js +26 -19
- package/lib/module/ui/session/nativeSecureStorage.js.map +1 -1
- package/lib/module/ui/session/sharedDeviceCredentialStore.js +25 -16
- package/lib/module/ui/session/sharedDeviceCredentialStore.js.map +1 -1
- package/lib/typescript/commonjs/ui/session/nativeSecureStorage.d.ts +9 -4
- package/lib/typescript/commonjs/ui/session/nativeSecureStorage.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/session/sharedDeviceCredentialStore.d.ts.map +1 -1
- package/lib/typescript/module/ui/session/nativeSecureStorage.d.ts +9 -4
- package/lib/typescript/module/ui/session/nativeSecureStorage.d.ts.map +1 -1
- package/lib/typescript/module/ui/session/sharedDeviceCredentialStore.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/ui/session/nativeSecureStorage.ts +31 -25
- package/src/ui/session/sharedDeviceCredentialStore.ts +30 -23
package/README.md
CHANGED
|
@@ -121,21 +121,22 @@ bun add @oxy.so/services @oxy.so/core
|
|
|
121
121
|
|
|
122
122
|
### Peer Dependencies
|
|
123
123
|
|
|
124
|
-
|
|
124
|
+
The native modules `@oxy.so/services` needs on iOS and Android (Expo SDK 54 to 58;
|
|
125
|
+
`package.json` has the exact ranges):
|
|
125
126
|
|
|
126
|
-
- react: >=18, react-native: >=0.76
|
|
127
|
-
- react-native-reanimated: >=3.16, react-native-gesture-handler: >=2.16
|
|
128
|
-
- react-native-safe-area-context: ^5.4.0, react-native-svg: >=13
|
|
129
|
-
- Expo projects: expo, expo-font, expo-image, expo-linear-gradient
|
|
130
|
-
- Navigation (if you use the provided screens): @react-navigation/native
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
Example for Expo:
|
|
134
127
|
```bash
|
|
135
|
-
|
|
136
|
-
|
|
128
|
+
npx expo install expo-crypto expo-secure-store expo-file-system expo-image @expo/app-integrity \
|
|
129
|
+
@react-native-async-storage/async-storage @react-native-community/netinfo \
|
|
130
|
+
react-native-reanimated react-native-gesture-handler react-native-keyboard-controller \
|
|
131
|
+
react-native-safe-area-context react-native-svg
|
|
137
132
|
```
|
|
138
133
|
|
|
134
|
+
Every native module above is a **required** peer: the app must list each one
|
|
135
|
+
itself. Expo's autolinking skips optional peers and installs nothing an app does
|
|
136
|
+
not name at its SDK's version, so an app without `expo-crypto` builds and then
|
|
137
|
+
fails at launch (`Cannot find native module 'ExpoCrypto'`: no CSPRNG, no
|
|
138
|
+
sign-in). `bunx @oxy.so/doctor --ci` fails an app that is missing one.
|
|
139
|
+
|
|
139
140
|
### React Native/Expo Setup
|
|
140
141
|
|
|
141
142
|
For React Native and Expo projects, add the polyfill import at the very top of your entry file:
|
|
@@ -16,33 +16,41 @@ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r
|
|
|
16
16
|
* different backings — a device credential in SecureStore and a pin in
|
|
17
17
|
* AsyncStorage would resolve differently after a keystore reset.
|
|
18
18
|
*
|
|
19
|
-
* `expo-secure-store` is
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
19
|
+
* `expo-secure-store` is a REQUIRED peer of this package (13.5.0): without its
|
|
20
|
+
* native module the device credential would sit in plaintext AsyncStorage. It
|
|
21
|
+
* is still loaded lazily, as a direct statement of a `try` block (the shape
|
|
22
|
+
* Metro marks optional, `optionalPeerLoads.test.ts`), so a build whose native
|
|
23
|
+
* module is missing (react-native-macos, an app that has not rebuilt) degrades
|
|
24
|
+
* to AsyncStorage instead of crashing. The specifier is a LITERAL: the old
|
|
25
|
+
* `const m = 'expo-secure-store'; import(m)` never hid it from Metro (Babel
|
|
26
|
+
* evaluates the constant, so Metro resolved it anyway) and only hid it from the
|
|
27
|
+
* gates that read this source.
|
|
23
28
|
*/
|
|
24
|
-
// Variable indirection so Metro's static analyzer never traces expo-secure-store
|
|
25
|
-
// into the web bundle; the module is native-only and optional.
|
|
26
|
-
const SECURE_STORE_MODULE = 'expo-secure-store';
|
|
27
29
|
let secureStorePromise = null;
|
|
28
30
|
|
|
29
31
|
/**
|
|
30
32
|
* Resolve the `expo-secure-store` module once (memoised), or `null` when it is
|
|
31
33
|
* unavailable — callers then fall back to AsyncStorage. Never throws.
|
|
32
34
|
*/
|
|
35
|
+
async function importSecureStore() {
|
|
36
|
+
let mod;
|
|
37
|
+
try {
|
|
38
|
+
mod = await Promise.resolve().then(() => _interopRequireWildcard(require('expo-secure-store')));
|
|
39
|
+
} catch {
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
if (typeof mod.getItemAsync === 'function' && typeof mod.setItemAsync === 'function' && typeof mod.deleteItemAsync === 'function') {
|
|
43
|
+
return {
|
|
44
|
+
getItemAsync: mod.getItemAsync.bind(mod),
|
|
45
|
+
setItemAsync: mod.setItemAsync.bind(mod),
|
|
46
|
+
deleteItemAsync: mod.deleteItemAsync.bind(mod)
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
return null;
|
|
50
|
+
}
|
|
33
51
|
function loadSecureStore() {
|
|
34
52
|
if (!secureStorePromise) {
|
|
35
|
-
|
|
36
|
-
secureStorePromise = (specifier => new Promise(r => r(`${specifier}`)).then(s => _interopRequireWildcard(require(s))))(moduleName).then(mod => {
|
|
37
|
-
if (typeof mod.getItemAsync === 'function' && typeof mod.setItemAsync === 'function' && typeof mod.deleteItemAsync === 'function') {
|
|
38
|
-
return {
|
|
39
|
-
getItemAsync: mod.getItemAsync.bind(mod),
|
|
40
|
-
setItemAsync: mod.setItemAsync.bind(mod),
|
|
41
|
-
deleteItemAsync: mod.deleteItemAsync.bind(mod)
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
return null;
|
|
45
|
-
}).catch(() => null);
|
|
53
|
+
secureStorePromise = importSecureStore();
|
|
46
54
|
}
|
|
47
55
|
return secureStorePromise;
|
|
48
56
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_storageHelpers","require","_interopRequireWildcard","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","
|
|
1
|
+
{"version":3,"names":["_storageHelpers","require","_interopRequireWildcard","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","secureStorePromise","importSecureStore","mod","Promise","resolve","then","getItemAsync","setItemAsync","deleteItemAsync","bind","loadSecureStore","createNativeSecureKeyValueStorage","asyncStorage","getAsyncStorage","createPlatformStorage","getItem","key","secure","setItem","value","removeItem"],"sourceRoot":"../../../../src","sources":["ui/session/nativeSecureStorage.ts"],"mappings":";;;;;;AAsBA,IAAAA,eAAA,GAAAC,OAAA;AAAgE,SAAAC,wBAAAC,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAH,uBAAA,YAAAA,CAAAC,CAAA,EAAAC,CAAA,SAAAA,CAAA,IAAAD,CAAA,IAAAA,CAAA,CAAAK,UAAA,SAAAL,CAAA,MAAAM,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,QAAAC,OAAA,EAAAV,CAAA,iBAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,SAAAQ,CAAA,MAAAF,CAAA,GAAAL,CAAA,GAAAG,CAAA,GAAAD,CAAA,QAAAG,CAAA,CAAAK,GAAA,CAAAX,CAAA,UAAAM,CAAA,CAAAM,GAAA,CAAAZ,CAAA,GAAAM,CAAA,CAAAO,GAAA,CAAAb,CAAA,EAAAQ,CAAA,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OS_DEVICE_SESSION_KEYCHAIN_SERVICE = exports.IOS_DEVICE_SESSION_KEYCHAIN_
|
|
|
65
65
|
/** The single key holding the JSON-encoded `{deviceId, deviceSecret}` pair. */
|
|
66
66
|
const SHARED_DEVICE_SESSION_STORAGE_KEY = exports.SHARED_DEVICE_SESSION_STORAGE_KEY = 'oxy_shared_device_session_v1';
|
|
67
67
|
|
|
68
|
-
// Variable indirection so Metro's static analyzer never traces expo-secure-store
|
|
69
|
-
// into the web bundle; the module is native-only and optional.
|
|
70
|
-
const SECURE_STORE_MODULE = 'expo-secure-store';
|
|
71
|
-
|
|
72
68
|
/**
|
|
73
69
|
* The subset of `expo-secure-store` this module needs. Unlike the adapter in
|
|
74
70
|
* `nativeSecureStorage.ts` it must pass OPTIONS — the access group and the
|
|
@@ -77,20 +73,33 @@ const SECURE_STORE_MODULE = 'expo-secure-store';
|
|
|
77
73
|
*/
|
|
78
74
|
|
|
79
75
|
let keychainStorePromise = null;
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* `expo-secure-store`, a required peer of this package, loaded lazily as a
|
|
79
|
+
* direct statement of a `try` block with a LITERAL specifier (see
|
|
80
|
+
* `nativeSecureStorage.ts` for why the old runtime-computed one hid nothing
|
|
81
|
+
* from Metro). A build without its native module reads `unsupported`.
|
|
82
|
+
*/
|
|
83
|
+
async function importKeychainGroupStore() {
|
|
84
|
+
let mod;
|
|
85
|
+
try {
|
|
86
|
+
mod = await Promise.resolve().then(() => _interopRequireWildcard(require('expo-secure-store')));
|
|
87
|
+
} catch {
|
|
88
|
+
return null;
|
|
89
|
+
}
|
|
90
|
+
if (typeof mod.getItemAsync === 'function' && typeof mod.setItemAsync === 'function' && typeof mod.deleteItemAsync === 'function' && typeof mod.WHEN_UNLOCKED_THIS_DEVICE_ONLY === 'number') {
|
|
91
|
+
return {
|
|
92
|
+
getItemAsync: mod.getItemAsync.bind(mod),
|
|
93
|
+
setItemAsync: mod.setItemAsync.bind(mod),
|
|
94
|
+
deleteItemAsync: mod.deleteItemAsync.bind(mod),
|
|
95
|
+
WHEN_UNLOCKED_THIS_DEVICE_ONLY: mod.WHEN_UNLOCKED_THIS_DEVICE_ONLY
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
return null;
|
|
99
|
+
}
|
|
80
100
|
function loadKeychainGroupStore() {
|
|
81
101
|
if (!keychainStorePromise) {
|
|
82
|
-
|
|
83
|
-
keychainStorePromise = (specifier => new Promise(r => r(`${specifier}`)).then(s => _interopRequireWildcard(require(s))))(moduleName).then(mod => {
|
|
84
|
-
if (typeof mod.getItemAsync === 'function' && typeof mod.setItemAsync === 'function' && typeof mod.deleteItemAsync === 'function' && typeof mod.WHEN_UNLOCKED_THIS_DEVICE_ONLY === 'number') {
|
|
85
|
-
return {
|
|
86
|
-
getItemAsync: mod.getItemAsync.bind(mod),
|
|
87
|
-
setItemAsync: mod.setItemAsync.bind(mod),
|
|
88
|
-
deleteItemAsync: mod.deleteItemAsync.bind(mod),
|
|
89
|
-
WHEN_UNLOCKED_THIS_DEVICE_ONLY: mod.WHEN_UNLOCKED_THIS_DEVICE_ONLY
|
|
90
|
-
};
|
|
91
|
-
}
|
|
92
|
-
return null;
|
|
93
|
-
}).catch(() => null);
|
|
102
|
+
keychainStorePromise = importKeychainGroupStore();
|
|
94
103
|
}
|
|
95
104
|
return keychainStorePromise;
|
|
96
105
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_reactNative","require","_expoModulesCore","_session","_interopRequireWildcard","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","IOS_KEYCHAIN_ACCESS_GROUP","exports","IOS_DEVICE_SESSION_KEYCHAIN_SERVICE","SHARED_DEVICE_SESSION_STORAGE_KEY","
|
|
1
|
+
{"version":3,"names":["_reactNative","require","_expoModulesCore","_session","_interopRequireWildcard","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","IOS_KEYCHAIN_ACCESS_GROUP","exports","IOS_DEVICE_SESSION_KEYCHAIN_SERVICE","SHARED_DEVICE_SESSION_STORAGE_KEY","keychainStorePromise","importKeychainGroupStore","mod","Promise","resolve","then","getItemAsync","setItemAsync","deleteItemAsync","WHEN_UNLOCKED_THIS_DEVICE_ONLY","bind","loadKeychainGroupStore","parseStoredCredential","raw","parsed","JSON","parse","candidate","deviceId","length","deviceSecret","createKeychainGroupCredentialStore","readOptions","keychainService","keychainAccessGroup","read","store","state","error","cause","credential","Error","publish","value","stringify","keychainAccessible","clear","brokerModule","loadBrokerModule","undefined","native","requireOptionalNativeModule","write","createBrokerCredentialStore","broker","normalizeSharedDeviceSessionRead","createPlatformSharedDeviceCredentialStore","Platform","OS"],"sourceRoot":"../../../../src","sources":["ui/session/sharedDeviceCredentialStore.ts"],"mappings":";;;;;;;AAuCA,IAAAA,YAAA,GAAAC,OAAA;AACA,IAAAC,gBAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AAK8B,SAAAG,wBAAAC,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAH,uBAAA,YAAAA,CAAAC,CAAA,EAAAC,CAAA,SAAAA,CAAA,IAAAD,CAAA,IAAAA,CAAA,CAAAK,UAAA,SAAAL,CAAA,MAAAM,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,QAAAC,OAAA,EAAAV,CAAA,iBAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,SAAAQ,CAAA,MAAAF,CAAA,GAAAL,CAAA,GAAAG,CAAA,GAAAD,CAAA,QAAAG,CAAA,CAAAK,GAAA,CAAAX,CAAA,UAAAM,CAAA,CAAAM,GAAA,CAAAZ,CAAA,GAAAM,CAAA,CAAAO,GAAA,CAAAb,CAAA,EAAAQ,CAAA,gBAAAP,CAAA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36 +11,43 @@
|
|
|
11
11
|
* different backings — a device credential in SecureStore and a pin in
|
|
12
12
|
* AsyncStorage would resolve differently after a keystore reset.
|
|
13
13
|
*
|
|
14
|
-
* `expo-secure-store` is
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
14
|
+
* `expo-secure-store` is a REQUIRED peer of this package (13.5.0): without its
|
|
15
|
+
* native module the device credential would sit in plaintext AsyncStorage. It
|
|
16
|
+
* is still loaded lazily, as a direct statement of a `try` block (the shape
|
|
17
|
+
* Metro marks optional, `optionalPeerLoads.test.ts`), so a build whose native
|
|
18
|
+
* module is missing (react-native-macos, an app that has not rebuilt) degrades
|
|
19
|
+
* to AsyncStorage instead of crashing. The specifier is a LITERAL: the old
|
|
20
|
+
* `const m = 'expo-secure-store'; import(m)` never hid it from Metro (Babel
|
|
21
|
+
* evaluates the constant, so Metro resolved it anyway) and only hid it from the
|
|
22
|
+
* gates that read this source.
|
|
18
23
|
*/
|
|
19
24
|
|
|
20
25
|
import { createPlatformStorage } from "../utils/storageHelpers.js";
|
|
21
|
-
|
|
22
|
-
// Variable indirection so Metro's static analyzer never traces expo-secure-store
|
|
23
|
-
// into the web bundle; the module is native-only and optional.
|
|
24
|
-
const SECURE_STORE_MODULE = 'expo-secure-store';
|
|
25
26
|
let secureStorePromise = null;
|
|
26
27
|
|
|
27
28
|
/**
|
|
28
29
|
* Resolve the `expo-secure-store` module once (memoised), or `null` when it is
|
|
29
30
|
* unavailable — callers then fall back to AsyncStorage. Never throws.
|
|
30
31
|
*/
|
|
32
|
+
async function importSecureStore() {
|
|
33
|
+
let mod;
|
|
34
|
+
try {
|
|
35
|
+
mod = await import('expo-secure-store');
|
|
36
|
+
} catch {
|
|
37
|
+
return null;
|
|
38
|
+
}
|
|
39
|
+
if (typeof mod.getItemAsync === 'function' && typeof mod.setItemAsync === 'function' && typeof mod.deleteItemAsync === 'function') {
|
|
40
|
+
return {
|
|
41
|
+
getItemAsync: mod.getItemAsync.bind(mod),
|
|
42
|
+
setItemAsync: mod.setItemAsync.bind(mod),
|
|
43
|
+
deleteItemAsync: mod.deleteItemAsync.bind(mod)
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
31
48
|
function loadSecureStore() {
|
|
32
49
|
if (!secureStorePromise) {
|
|
33
|
-
|
|
34
|
-
secureStorePromise = import(moduleName).then(mod => {
|
|
35
|
-
if (typeof mod.getItemAsync === 'function' && typeof mod.setItemAsync === 'function' && typeof mod.deleteItemAsync === 'function') {
|
|
36
|
-
return {
|
|
37
|
-
getItemAsync: mod.getItemAsync.bind(mod),
|
|
38
|
-
setItemAsync: mod.setItemAsync.bind(mod),
|
|
39
|
-
deleteItemAsync: mod.deleteItemAsync.bind(mod)
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
return null;
|
|
43
|
-
}).catch(() => null);
|
|
50
|
+
secureStorePromise = importSecureStore();
|
|
44
51
|
}
|
|
45
52
|
return secureStorePromise;
|
|
46
53
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["createPlatformStorage","
|
|
1
|
+
{"version":3,"names":["createPlatformStorage","secureStorePromise","importSecureStore","mod","getItemAsync","setItemAsync","deleteItemAsync","bind","loadSecureStore","createNativeSecureKeyValueStorage","asyncStorage","getAsyncStorage","getItem","key","secure","setItem","value","removeItem"],"sourceRoot":"../../../../src","sources":["ui/session/nativeSecureStorage.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,qBAAqB,QAAQ,4BAAyB;AAQ/D,IAAIC,kBAA0D,GAAG,IAAI;;AAErE;AACA;AACA;AACA;AACA,eAAeC,iBAAiBA,CAAA,EAAoC;EAClE,IAAIC,GAA6B;EACjC,IAAI;IACFA,GAAG,GAAI,MAAM,MAAM,CAAC,mBAAmB,CAAyC;EAClF,CAAC,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QACV,MAAMA,MAAM,CAACT,YAAY,CAACQ,GAAG,EAAEG,KAAK,CAAC;QACrC;MACF;MACA,MAAM,CAAC,MAAML,eAAe,CAAC,CAAC,EAAEI,OAAO,CAACF,GAAG,EAAEG,KAAK,CAAC;IACrD,CAAC;IACDC,UAAU,EAAE,MAAOJ,GAAG,IAAK;MACzB,MAAMC,MAAM,GAAG,MAAMN,eAAe,CAAC,CAAC;MACtC,IAAIM,MAAM,EAAE;QACV,MAAMA,MAAM,CAACR,eAAe,CAACO,GAAG,CAAC;QACjC;MACF;MACA,MAAM,CAAC,MAAMF,eAAe,CAAC,CAAC,EAAEM,UAAU,CAACJ,GAAG,CAAC;IACjD;EACF,CAAC;AACH","ignoreList":[]}
|
|
@@ -61,10 +61,6 @@ export const IOS_DEVICE_SESSION_KEYCHAIN_SERVICE = 'oxy_device_session';
|
|
|
61
61
|
/** The single key holding the JSON-encoded `{deviceId, deviceSecret}` pair. */
|
|
62
62
|
export const SHARED_DEVICE_SESSION_STORAGE_KEY = 'oxy_shared_device_session_v1';
|
|
63
63
|
|
|
64
|
-
// Variable indirection so Metro's static analyzer never traces expo-secure-store
|
|
65
|
-
// into the web bundle; the module is native-only and optional.
|
|
66
|
-
const SECURE_STORE_MODULE = 'expo-secure-store';
|
|
67
|
-
|
|
68
64
|
/**
|
|
69
65
|
* The subset of `expo-secure-store` this module needs. Unlike the adapter in
|
|
70
66
|
* `nativeSecureStorage.ts` it must pass OPTIONS — the access group and the
|
|
@@ -73,20 +69,33 @@ const SECURE_STORE_MODULE = 'expo-secure-store';
|
|
|
73
69
|
*/
|
|
74
70
|
|
|
75
71
|
let keychainStorePromise = null;
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* `expo-secure-store`, a required peer of this package, loaded lazily as a
|
|
75
|
+
* direct statement of a `try` block with a LITERAL specifier (see
|
|
76
|
+
* `nativeSecureStorage.ts` for why the old runtime-computed one hid nothing
|
|
77
|
+
* from Metro). A build without its native module reads `unsupported`.
|
|
78
|
+
*/
|
|
79
|
+
async function importKeychainGroupStore() {
|
|
80
|
+
let mod;
|
|
81
|
+
try {
|
|
82
|
+
mod = await import('expo-secure-store');
|
|
83
|
+
} catch {
|
|
84
|
+
return null;
|
|
85
|
+
}
|
|
86
|
+
if (typeof mod.getItemAsync === 'function' && typeof mod.setItemAsync === 'function' && typeof mod.deleteItemAsync === 'function' && typeof mod.WHEN_UNLOCKED_THIS_DEVICE_ONLY === 'number') {
|
|
87
|
+
return {
|
|
88
|
+
getItemAsync: mod.getItemAsync.bind(mod),
|
|
89
|
+
setItemAsync: mod.setItemAsync.bind(mod),
|
|
90
|
+
deleteItemAsync: mod.deleteItemAsync.bind(mod),
|
|
91
|
+
WHEN_UNLOCKED_THIS_DEVICE_ONLY: mod.WHEN_UNLOCKED_THIS_DEVICE_ONLY
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
return null;
|
|
95
|
+
}
|
|
76
96
|
function loadKeychainGroupStore() {
|
|
77
97
|
if (!keychainStorePromise) {
|
|
78
|
-
|
|
79
|
-
keychainStorePromise = import(moduleName).then(mod => {
|
|
80
|
-
if (typeof mod.getItemAsync === 'function' && typeof mod.setItemAsync === 'function' && typeof mod.deleteItemAsync === 'function' && typeof mod.WHEN_UNLOCKED_THIS_DEVICE_ONLY === 'number') {
|
|
81
|
-
return {
|
|
82
|
-
getItemAsync: mod.getItemAsync.bind(mod),
|
|
83
|
-
setItemAsync: mod.setItemAsync.bind(mod),
|
|
84
|
-
deleteItemAsync: mod.deleteItemAsync.bind(mod),
|
|
85
|
-
WHEN_UNLOCKED_THIS_DEVICE_ONLY: mod.WHEN_UNLOCKED_THIS_DEVICE_ONLY
|
|
86
|
-
};
|
|
87
|
-
}
|
|
88
|
-
return null;
|
|
89
|
-
}).catch(() => null);
|
|
98
|
+
keychainStorePromise = importKeychainGroupStore();
|
|
90
99
|
}
|
|
91
100
|
return keychainStorePromise;
|
|
92
101
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Platform","requireOptionalNativeModule","normalizeSharedDeviceSessionRead","IOS_KEYCHAIN_ACCESS_GROUP","IOS_DEVICE_SESSION_KEYCHAIN_SERVICE","SHARED_DEVICE_SESSION_STORAGE_KEY","
|
|
1
|
+
{"version":3,"names":["Platform","requireOptionalNativeModule","normalizeSharedDeviceSessionRead","IOS_KEYCHAIN_ACCESS_GROUP","IOS_DEVICE_SESSION_KEYCHAIN_SERVICE","SHARED_DEVICE_SESSION_STORAGE_KEY","keychainStorePromise","importKeychainGroupStore","mod","getItemAsync","setItemAsync","deleteItemAsync","WHEN_UNLOCKED_THIS_DEVICE_ONLY","bind","loadKeychainGroupStore","parseStoredCredential","raw","parsed","JSON","parse","candidate","deviceId","length","deviceSecret","createKeychainGroupCredentialStore","readOptions","keychainService","keychainAccessGroup","read","store","state","error","cause","credential","Error","publish","value","stringify","keychainAccessible","clear","brokerModule","loadBrokerModule","undefined","native","write","createBrokerCredentialStore","broker","createPlatformSharedDeviceCredentialStore","OS"],"sourceRoot":"../../../../src","sources":["ui/session/sharedDeviceCredentialStore.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,QAAQ,QAAQ,cAAc;AACvC,SAASC,2BAA2B,QAAQ,mBAAmB;AAC/D,SACEC,gCAAgC,QAI3B,sBAAsB;;AAE7B;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,yBAAyB,GAAG,qBAAqB;;AAE9D;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,mCAAmC,GAAG,oBAAoB;;AAEvE;AACA,OAAO,MAAMC,iCAAiC,GAAG,8BAA8B;;AAE/E;AACA;AACA;AACA;AACA;AACA;;AAQA,IAAIC,oBAA+D,GAAG,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;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASQ,yCAAyCA,CAAA,EAAuC;EAC9F,IAAI/C,QAAQ,CAACgD,EAAE,KAAK,KAAK,EAAE;IACzB,OAAO,IAAI;EACb;EACA,OAAOhD,QAAQ,CAACgD,EAAE,KAAK,KAAK,GACxBxB,kCAAkC,CAAC,CAAC,GACpCqB,2BAA2B,CAAC,CAAC;AACnC","ignoreList":[]}
|
|
@@ -9,10 +9,15 @@
|
|
|
9
9
|
* different backings — a device credential in SecureStore and a pin in
|
|
10
10
|
* AsyncStorage would resolve differently after a keystore reset.
|
|
11
11
|
*
|
|
12
|
-
* `expo-secure-store` is
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
12
|
+
* `expo-secure-store` is a REQUIRED peer of this package (13.5.0): without its
|
|
13
|
+
* native module the device credential would sit in plaintext AsyncStorage. It
|
|
14
|
+
* is still loaded lazily, as a direct statement of a `try` block (the shape
|
|
15
|
+
* Metro marks optional, `optionalPeerLoads.test.ts`), so a build whose native
|
|
16
|
+
* module is missing (react-native-macos, an app that has not rebuilt) degrades
|
|
17
|
+
* to AsyncStorage instead of crashing. The specifier is a LITERAL: the old
|
|
18
|
+
* `const m = 'expo-secure-store'; import(m)` never hid it from Metro (Babel
|
|
19
|
+
* evaluates the constant, so Metro resolved it anyway) and only hid it from the
|
|
20
|
+
* gates that read this source.
|
|
16
21
|
*/
|
|
17
22
|
import type { NativeKeyValueStorage } from '@oxy.so/core/session';
|
|
18
23
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nativeSecureStorage.d.ts","sourceRoot":"","sources":["../../../../../src/ui/session/nativeSecureStorage.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"nativeSecureStorage.d.ts","sourceRoot":"","sources":["../../../../../src/ui/session/nativeSecureStorage.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AA2ClE;;;;;GAKG;AACH,wBAAgB,iCAAiC,IAAI,qBAAqB,CAiCzE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sharedDeviceCredentialStore.d.ts","sourceRoot":"","sources":["../../../../../src/ui/session/sharedDeviceCredentialStore.ts"],"names":[],"mappings":"AAyCA,OAAO,EAIL,KAAK,2BAA2B,EACjC,MAAM,sBAAsB,CAAC;AAE9B;;;;GAIG;AACH,eAAO,MAAM,yBAAyB,wBAAwB,CAAC;AAE/D;;;;;GAKG;AACH,eAAO,MAAM,mCAAmC,uBAAuB,CAAC;AAExE,+EAA+E;AAC/E,eAAO,MAAM,iCAAiC,iCAAiC,CAAC;
|
|
1
|
+
{"version":3,"file":"sharedDeviceCredentialStore.d.ts","sourceRoot":"","sources":["../../../../../src/ui/session/sharedDeviceCredentialStore.ts"],"names":[],"mappings":"AAyCA,OAAO,EAIL,KAAK,2BAA2B,EACjC,MAAM,sBAAsB,CAAC;AAE9B;;;;GAIG;AACH,eAAO,MAAM,yBAAyB,wBAAwB,CAAC;AAE/D;;;;;GAKG;AACH,eAAO,MAAM,mCAAmC,uBAAuB,CAAC;AAExE,+EAA+E;AAC/E,eAAO,MAAM,iCAAiC,iCAAiC,CAAC;AAqPhF;;;;;;;;;;;;;GAaG;AACH,wBAAgB,yCAAyC,IAAI,2BAA2B,GAAG,IAAI,CAO9F"}
|
|
@@ -9,10 +9,15 @@
|
|
|
9
9
|
* different backings — a device credential in SecureStore and a pin in
|
|
10
10
|
* AsyncStorage would resolve differently after a keystore reset.
|
|
11
11
|
*
|
|
12
|
-
* `expo-secure-store` is
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
12
|
+
* `expo-secure-store` is a REQUIRED peer of this package (13.5.0): without its
|
|
13
|
+
* native module the device credential would sit in plaintext AsyncStorage. It
|
|
14
|
+
* is still loaded lazily, as a direct statement of a `try` block (the shape
|
|
15
|
+
* Metro marks optional, `optionalPeerLoads.test.ts`), so a build whose native
|
|
16
|
+
* module is missing (react-native-macos, an app that has not rebuilt) degrades
|
|
17
|
+
* to AsyncStorage instead of crashing. The specifier is a LITERAL: the old
|
|
18
|
+
* `const m = 'expo-secure-store'; import(m)` never hid it from Metro (Babel
|
|
19
|
+
* evaluates the constant, so Metro resolved it anyway) and only hid it from the
|
|
20
|
+
* gates that read this source.
|
|
16
21
|
*/
|
|
17
22
|
import type { NativeKeyValueStorage } from '@oxy.so/core/session';
|
|
18
23
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nativeSecureStorage.d.ts","sourceRoot":"","sources":["../../../../../src/ui/session/nativeSecureStorage.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"nativeSecureStorage.d.ts","sourceRoot":"","sources":["../../../../../src/ui/session/nativeSecureStorage.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AA2ClE;;;;;GAKG;AACH,wBAAgB,iCAAiC,IAAI,qBAAqB,CAiCzE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sharedDeviceCredentialStore.d.ts","sourceRoot":"","sources":["../../../../../src/ui/session/sharedDeviceCredentialStore.ts"],"names":[],"mappings":"AAyCA,OAAO,EAIL,KAAK,2BAA2B,EACjC,MAAM,sBAAsB,CAAC;AAE9B;;;;GAIG;AACH,eAAO,MAAM,yBAAyB,wBAAwB,CAAC;AAE/D;;;;;GAKG;AACH,eAAO,MAAM,mCAAmC,uBAAuB,CAAC;AAExE,+EAA+E;AAC/E,eAAO,MAAM,iCAAiC,iCAAiC,CAAC;
|
|
1
|
+
{"version":3,"file":"sharedDeviceCredentialStore.d.ts","sourceRoot":"","sources":["../../../../../src/ui/session/sharedDeviceCredentialStore.ts"],"names":[],"mappings":"AAyCA,OAAO,EAIL,KAAK,2BAA2B,EACjC,MAAM,sBAAsB,CAAC;AAE9B;;;;GAIG;AACH,eAAO,MAAM,yBAAyB,wBAAwB,CAAC;AAE/D;;;;;GAKG;AACH,eAAO,MAAM,mCAAmC,uBAAuB,CAAC;AAExE,+EAA+E;AAC/E,eAAO,MAAM,iCAAiC,iCAAiC,CAAC;AAqPhF;;;;;;;;;;;;;GAaG;AACH,wBAAgB,yCAAyC,IAAI,2BAA2B,GAAG,IAAI,CAO9F"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oxy.so/services",
|
|
3
|
-
"version": "13.
|
|
3
|
+
"version": "13.5.0",
|
|
4
4
|
"description": "OxyHQ Expo/React Native SDK — UI components, screens, and native features",
|
|
5
5
|
"main": "lib/commonjs/index.js",
|
|
6
6
|
"module": "lib/module/index.js",
|
|
@@ -178,6 +178,7 @@
|
|
|
178
178
|
"copyfiles": "^2.4.1",
|
|
179
179
|
"expo-clipboard": "~58.0.4",
|
|
180
180
|
"expo-constants": "~58.0.13",
|
|
181
|
+
"expo-crypto": "~58.0.7",
|
|
181
182
|
"expo-file-system": "~58.0.11",
|
|
182
183
|
"expo-haptics": "~58.0.7",
|
|
183
184
|
"expo-image": "~58.0.17",
|
|
@@ -227,6 +228,7 @@
|
|
|
227
228
|
"expo": ">=54.0.0 <59.0.0",
|
|
228
229
|
"expo-clipboard": ">=8.0.0 <59.0.0",
|
|
229
230
|
"expo-constants": ">=18.0.0 <59.0.0",
|
|
231
|
+
"expo-crypto": ">=15.0.0 <59.0.0",
|
|
230
232
|
"expo-document-picker": ">=14.0.0 <59.0.0",
|
|
231
233
|
"expo-file-system": ">=19.0.0 <59.0.0",
|
|
232
234
|
"expo-haptics": ">=15.0.0 <59.0.0",
|
|
@@ -236,6 +238,7 @@
|
|
|
236
238
|
"expo-linear-gradient": ">=15.0.0 <59.0.0",
|
|
237
239
|
"expo-modules-core": "<59.0.0",
|
|
238
240
|
"expo-notifications": ">=0.32.0 <59.0.0",
|
|
241
|
+
"expo-secure-store": ">=15.0.0 <59.0.0",
|
|
239
242
|
"expo-web-browser": ">=15.0.0 <59.0.0",
|
|
240
243
|
"nativewind": ">=5.0.0-preview.3 <6.0.0",
|
|
241
244
|
"react-native-css": "^3.0.6 || 3.1.0-rc.0",
|
|
@@ -263,9 +266,6 @@
|
|
|
263
266
|
"@types/react": {
|
|
264
267
|
"optional": true
|
|
265
268
|
},
|
|
266
|
-
"react-native-keyboard-controller": {
|
|
267
|
-
"optional": true
|
|
268
|
-
},
|
|
269
269
|
"expo": {
|
|
270
270
|
"optional": true
|
|
271
271
|
},
|
|
@@ -9,18 +9,19 @@
|
|
|
9
9
|
* different backings — a device credential in SecureStore and a pin in
|
|
10
10
|
* AsyncStorage would resolve differently after a keystore reset.
|
|
11
11
|
*
|
|
12
|
-
* `expo-secure-store` is
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
12
|
+
* `expo-secure-store` is a REQUIRED peer of this package (13.5.0): without its
|
|
13
|
+
* native module the device credential would sit in plaintext AsyncStorage. It
|
|
14
|
+
* is still loaded lazily, as a direct statement of a `try` block (the shape
|
|
15
|
+
* Metro marks optional, `optionalPeerLoads.test.ts`), so a build whose native
|
|
16
|
+
* module is missing (react-native-macos, an app that has not rebuilt) degrades
|
|
17
|
+
* to AsyncStorage instead of crashing. The specifier is a LITERAL: the old
|
|
18
|
+
* `const m = 'expo-secure-store'; import(m)` never hid it from Metro (Babel
|
|
19
|
+
* evaluates the constant, so Metro resolved it anyway) and only hid it from the
|
|
20
|
+
* gates that read this source.
|
|
16
21
|
*/
|
|
17
22
|
import type { NativeKeyValueStorage } from '@oxy.so/core/session';
|
|
18
23
|
import { createPlatformStorage } from '../utils/storageHelpers';
|
|
19
24
|
|
|
20
|
-
// Variable indirection so Metro's static analyzer never traces expo-secure-store
|
|
21
|
-
// into the web bundle; the module is native-only and optional.
|
|
22
|
-
const SECURE_STORE_MODULE = 'expo-secure-store';
|
|
23
|
-
|
|
24
25
|
interface SecureStoreLike {
|
|
25
26
|
getItemAsync(key: string): Promise<string | null>;
|
|
26
27
|
setItemAsync(key: string, value: string): Promise<void>;
|
|
@@ -33,25 +34,30 @@ let secureStorePromise: Promise<SecureStoreLike | null> | null = null;
|
|
|
33
34
|
* Resolve the `expo-secure-store` module once (memoised), or `null` when it is
|
|
34
35
|
* unavailable — callers then fall back to AsyncStorage. Never throws.
|
|
35
36
|
*/
|
|
37
|
+
async function importSecureStore(): Promise<SecureStoreLike | null> {
|
|
38
|
+
let mod: Partial<SecureStoreLike>;
|
|
39
|
+
try {
|
|
40
|
+
mod = (await import('expo-secure-store')) as unknown as Partial<SecureStoreLike>;
|
|
41
|
+
} catch {
|
|
42
|
+
return null;
|
|
43
|
+
}
|
|
44
|
+
if (
|
|
45
|
+
typeof mod.getItemAsync === 'function' &&
|
|
46
|
+
typeof mod.setItemAsync === 'function' &&
|
|
47
|
+
typeof mod.deleteItemAsync === 'function'
|
|
48
|
+
) {
|
|
49
|
+
return {
|
|
50
|
+
getItemAsync: mod.getItemAsync.bind(mod),
|
|
51
|
+
setItemAsync: mod.setItemAsync.bind(mod),
|
|
52
|
+
deleteItemAsync: mod.deleteItemAsync.bind(mod),
|
|
53
|
+
} satisfies SecureStoreLike;
|
|
54
|
+
}
|
|
55
|
+
return null;
|
|
56
|
+
}
|
|
57
|
+
|
|
36
58
|
function loadSecureStore(): Promise<SecureStoreLike | null> {
|
|
37
59
|
if (!secureStorePromise) {
|
|
38
|
-
|
|
39
|
-
secureStorePromise = import(moduleName)
|
|
40
|
-
.then((mod: Partial<SecureStoreLike>) => {
|
|
41
|
-
if (
|
|
42
|
-
typeof mod.getItemAsync === 'function' &&
|
|
43
|
-
typeof mod.setItemAsync === 'function' &&
|
|
44
|
-
typeof mod.deleteItemAsync === 'function'
|
|
45
|
-
) {
|
|
46
|
-
return {
|
|
47
|
-
getItemAsync: mod.getItemAsync.bind(mod),
|
|
48
|
-
setItemAsync: mod.setItemAsync.bind(mod),
|
|
49
|
-
deleteItemAsync: mod.deleteItemAsync.bind(mod),
|
|
50
|
-
} satisfies SecureStoreLike;
|
|
51
|
-
}
|
|
52
|
-
return null;
|
|
53
|
-
})
|
|
54
|
-
.catch(() => null);
|
|
60
|
+
secureStorePromise = importSecureStore();
|
|
55
61
|
}
|
|
56
62
|
return secureStorePromise;
|
|
57
63
|
}
|
|
@@ -64,10 +64,6 @@ export const IOS_DEVICE_SESSION_KEYCHAIN_SERVICE = 'oxy_device_session';
|
|
|
64
64
|
/** The single key holding the JSON-encoded `{deviceId, deviceSecret}` pair. */
|
|
65
65
|
export const SHARED_DEVICE_SESSION_STORAGE_KEY = 'oxy_shared_device_session_v1';
|
|
66
66
|
|
|
67
|
-
// Variable indirection so Metro's static analyzer never traces expo-secure-store
|
|
68
|
-
// into the web bundle; the module is native-only and optional.
|
|
69
|
-
const SECURE_STORE_MODULE = 'expo-secure-store';
|
|
70
|
-
|
|
71
67
|
/**
|
|
72
68
|
* The subset of `expo-secure-store` this module needs. Unlike the adapter in
|
|
73
69
|
* `nativeSecureStorage.ts` it must pass OPTIONS — the access group and the
|
|
@@ -83,27 +79,38 @@ interface KeychainGroupStore {
|
|
|
83
79
|
|
|
84
80
|
let keychainStorePromise: Promise<KeychainGroupStore | null> | null = null;
|
|
85
81
|
|
|
82
|
+
/**
|
|
83
|
+
* `expo-secure-store`, a required peer of this package, loaded lazily as a
|
|
84
|
+
* direct statement of a `try` block with a LITERAL specifier (see
|
|
85
|
+
* `nativeSecureStorage.ts` for why the old runtime-computed one hid nothing
|
|
86
|
+
* from Metro). A build without its native module reads `unsupported`.
|
|
87
|
+
*/
|
|
88
|
+
async function importKeychainGroupStore(): Promise<KeychainGroupStore | null> {
|
|
89
|
+
let mod: Partial<KeychainGroupStore>;
|
|
90
|
+
try {
|
|
91
|
+
mod = (await import('expo-secure-store')) as unknown as Partial<KeychainGroupStore>;
|
|
92
|
+
} catch {
|
|
93
|
+
return null;
|
|
94
|
+
}
|
|
95
|
+
if (
|
|
96
|
+
typeof mod.getItemAsync === 'function' &&
|
|
97
|
+
typeof mod.setItemAsync === 'function' &&
|
|
98
|
+
typeof mod.deleteItemAsync === 'function' &&
|
|
99
|
+
typeof mod.WHEN_UNLOCKED_THIS_DEVICE_ONLY === 'number'
|
|
100
|
+
) {
|
|
101
|
+
return {
|
|
102
|
+
getItemAsync: mod.getItemAsync.bind(mod),
|
|
103
|
+
setItemAsync: mod.setItemAsync.bind(mod),
|
|
104
|
+
deleteItemAsync: mod.deleteItemAsync.bind(mod),
|
|
105
|
+
WHEN_UNLOCKED_THIS_DEVICE_ONLY: mod.WHEN_UNLOCKED_THIS_DEVICE_ONLY,
|
|
106
|
+
} satisfies KeychainGroupStore;
|
|
107
|
+
}
|
|
108
|
+
return null;
|
|
109
|
+
}
|
|
110
|
+
|
|
86
111
|
function loadKeychainGroupStore(): Promise<KeychainGroupStore | null> {
|
|
87
112
|
if (!keychainStorePromise) {
|
|
88
|
-
|
|
89
|
-
keychainStorePromise = import(moduleName)
|
|
90
|
-
.then((mod: Partial<KeychainGroupStore>) => {
|
|
91
|
-
if (
|
|
92
|
-
typeof mod.getItemAsync === 'function' &&
|
|
93
|
-
typeof mod.setItemAsync === 'function' &&
|
|
94
|
-
typeof mod.deleteItemAsync === 'function' &&
|
|
95
|
-
typeof mod.WHEN_UNLOCKED_THIS_DEVICE_ONLY === 'number'
|
|
96
|
-
) {
|
|
97
|
-
return {
|
|
98
|
-
getItemAsync: mod.getItemAsync.bind(mod),
|
|
99
|
-
setItemAsync: mod.setItemAsync.bind(mod),
|
|
100
|
-
deleteItemAsync: mod.deleteItemAsync.bind(mod),
|
|
101
|
-
WHEN_UNLOCKED_THIS_DEVICE_ONLY: mod.WHEN_UNLOCKED_THIS_DEVICE_ONLY,
|
|
102
|
-
} satisfies KeychainGroupStore;
|
|
103
|
-
}
|
|
104
|
-
return null;
|
|
105
|
-
})
|
|
106
|
-
.catch(() => null);
|
|
113
|
+
keychainStorePromise = importKeychainGroupStore();
|
|
107
114
|
}
|
|
108
115
|
return keychainStorePromise;
|
|
109
116
|
}
|