@oxy.so/services 14.9.0 → 14.10.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/ios/OxyIdentityModule.swift +43 -0
- package/lib/commonjs/ui/session/nativeSecureStorage.js +23 -10
- package/lib/commonjs/ui/session/nativeSecureStorage.js.map +1 -1
- package/lib/module/ui/session/nativeSecureStorage.js +24 -11
- package/lib/module/ui/session/nativeSecureStorage.js.map +1 -1
- package/lib/typescript/commonjs/ui/session/nativeSecureStorage.d.ts +14 -0
- package/lib/typescript/commonjs/ui/session/nativeSecureStorage.d.ts.map +1 -1
- package/lib/typescript/module/ui/session/nativeSecureStorage.d.ts +14 -0
- package/lib/typescript/module/ui/session/nativeSecureStorage.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/ui/session/__tests__/nativeSecureStorage.test.ts +121 -0
- package/src/ui/session/nativeSecureStorage.ts +24 -10
|
@@ -91,6 +91,49 @@ public class OxyIdentityModule: Module {
|
|
|
91
91
|
return group
|
|
92
92
|
}
|
|
93
93
|
|
|
94
|
+
/// This app's OWN access group, `<prefix><bundle id>` (its application
|
|
95
|
+
/// identifier), or `nil` when the keychain refuses it. Apple makes every
|
|
96
|
+
/// app a member of that group whatever `keychain-access-groups` lists, and
|
|
97
|
+
/// no other app can name it, so the SDK keeps the items that are this app's
|
|
98
|
+
/// alone there (its session credential: ADR 0062 D6), as Android keeps them
|
|
99
|
+
/// in the app's own storage.
|
|
100
|
+
///
|
|
101
|
+
/// The answer is proven, not assumed: a probe item is written into the group
|
|
102
|
+
/// explicitly and the group is returned only when the keychain took it.
|
|
103
|
+
/// `errSecMissingEntitlement` answers `nil` (the SDK keeps the placement this
|
|
104
|
+
/// build had before); any other failure throws and is asked again.
|
|
105
|
+
AsyncFunction("keychainApplicationAccessGroup") { (_ prefix: String) throws -> String? in
|
|
106
|
+
guard let bundleId = Bundle.main.bundleIdentifier, prefix.hasSuffix(".") else {
|
|
107
|
+
return nil
|
|
108
|
+
}
|
|
109
|
+
let group = prefix + bundleId
|
|
110
|
+
let match: [String: Any] = [
|
|
111
|
+
kSecClass as String: kSecClassGenericPassword,
|
|
112
|
+
kSecAttrService as String: OxyIdentityModule.probeService,
|
|
113
|
+
kSecAttrAccount as String: "\(bundleId).application-group",
|
|
114
|
+
kSecAttrAccessGroup as String: group,
|
|
115
|
+
]
|
|
116
|
+
let deleted = SecItemDelete(match as CFDictionary)
|
|
117
|
+
if deleted == errSecMissingEntitlement {
|
|
118
|
+
return nil
|
|
119
|
+
}
|
|
120
|
+
if deleted != errSecSuccess && deleted != errSecItemNotFound {
|
|
121
|
+
throw KeychainProbeException(deleted)
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
var add = match
|
|
125
|
+
add[kSecValueData as String] = Data("probe".utf8)
|
|
126
|
+
add[kSecAttrAccessible as String] = kSecAttrAccessibleAfterFirstUnlockThisDeviceOnly
|
|
127
|
+
let added = SecItemAdd(add as CFDictionary, nil)
|
|
128
|
+
if added == errSecMissingEntitlement {
|
|
129
|
+
return nil
|
|
130
|
+
}
|
|
131
|
+
guard added == errSecSuccess else {
|
|
132
|
+
throw KeychainProbeException(added)
|
|
133
|
+
}
|
|
134
|
+
return group
|
|
135
|
+
}
|
|
136
|
+
|
|
94
137
|
// Retired keys (Commons protocol 4): iOS reads them from the wallet group
|
|
95
138
|
// directly, like the current key.
|
|
96
139
|
AsyncFunction("listRetiredKeys") { (_ accountId: String?) -> [String: Any]? in
|
|
@@ -26,16 +26,29 @@ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r
|
|
|
26
26
|
* `const m = 'expo-secure-store'; import(m)` never hid it from Metro (Babel
|
|
27
27
|
* evaluates the constant, so Metro resolved it anyway) and only hid it from the
|
|
28
28
|
* gates that read this source.
|
|
29
|
+
*
|
|
30
|
+
* ## Whose item this is (iOS)
|
|
31
|
+
*
|
|
32
|
+
* Every key stored here is the SAME name in every Oxy app (`oxy.auth.v1`, the
|
|
33
|
+
* warm token, the sign-out marker, the identity pin). On Android each app's
|
|
34
|
+
* expo-secure-store is its own; on iOS an item written without an access group
|
|
35
|
+
* lands in the app's default group, which for every app but Commons and the
|
|
36
|
+
* Peable wallet is the shared one, so they all read and overwrote ONE session.
|
|
37
|
+
* The items now live in the app's own group (`<prefix><bundle id>`,
|
|
38
|
+
* `ownKeychainItemPlan`, ADR 0062 D6); the copy in the shared group is never
|
|
39
|
+
* read as this app's (it may be another app's, or Commons' vault session) and
|
|
40
|
+
* never deleted (apps still on an older build use it). The cross-app join point
|
|
41
|
+
* is the dedicated device-session slot (`sharedDeviceCredentialStore.ts`), whose
|
|
42
|
+
* credential every adopting app proves with a mint.
|
|
29
43
|
*/
|
|
30
44
|
/**
|
|
31
|
-
* Where this app's own
|
|
32
|
-
* docs/identity/ios-keychain-access-groups.md):
|
|
33
|
-
* wallet
|
|
34
|
-
*
|
|
35
|
-
* made. Android and web: no options.
|
|
45
|
+
* Where this app's own copy of `key` is on iOS (`ownKeychainItemPlan`,
|
|
46
|
+
* docs/identity/ios-keychain-access-groups.md): the app's own group, then
|
|
47
|
+
* Commons' or the wallet's default group where D3 put it. Android and web: no
|
|
48
|
+
* options.
|
|
36
49
|
*/
|
|
37
|
-
async function ownItemPlan() {
|
|
38
|
-
return (0, _session.ownKeychainItemPlan)(await (0, _session.resolveKeychainAccess)());
|
|
50
|
+
async function ownItemPlan(key) {
|
|
51
|
+
return (0, _session.ownKeychainItemPlan)(await (0, _session.resolveKeychainAccess)(), (0, _session.nativeSessionItemNames)(key));
|
|
39
52
|
}
|
|
40
53
|
let secureStorePromise = null;
|
|
41
54
|
|
|
@@ -84,14 +97,14 @@ function createNativeSecureKeyValueStorage() {
|
|
|
84
97
|
getItem: async key => {
|
|
85
98
|
const secure = await loadSecureStore();
|
|
86
99
|
if (secure) {
|
|
87
|
-
return (0, _session.readThroughPlan)(secure, key, {}, (await ownItemPlan()).read);
|
|
100
|
+
return (0, _session.readThroughPlan)(secure, key, {}, (await ownItemPlan(key)).read);
|
|
88
101
|
}
|
|
89
102
|
return (await getAsyncStorage()).getItem(key);
|
|
90
103
|
},
|
|
91
104
|
setItem: async (key, value) => {
|
|
92
105
|
const secure = await loadSecureStore();
|
|
93
106
|
if (secure) {
|
|
94
|
-
await secure.setItemAsync(key, value, (await ownItemPlan()).write);
|
|
107
|
+
await secure.setItemAsync(key, value, (await ownItemPlan(key)).write);
|
|
95
108
|
return;
|
|
96
109
|
}
|
|
97
110
|
await (await getAsyncStorage()).setItem(key, value);
|
|
@@ -99,7 +112,7 @@ function createNativeSecureKeyValueStorage() {
|
|
|
99
112
|
removeItem: async key => {
|
|
100
113
|
const secure = await loadSecureStore();
|
|
101
114
|
if (secure) {
|
|
102
|
-
await (0, _session.deleteThroughPlan)(secure, key, {}, (await ownItemPlan()).delete);
|
|
115
|
+
await (0, _session.deleteThroughPlan)(secure, key, {}, (await ownItemPlan(key)).delete);
|
|
103
116
|
return;
|
|
104
117
|
}
|
|
105
118
|
await (await getAsyncStorage()).removeItem(key);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_session","require","_storageHelpers","_interopRequireWildcard","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","ownItemPlan","ownKeychainItemPlan","resolveKeychainAccess","secureStorePromise","importSecureStore","mod","Promise","resolve","then","getItemAsync","setItemAsync","deleteItemAsync","bind","loadSecureStore","createNativeSecureKeyValueStorage","asyncStorage","getAsyncStorage","createPlatformStorage","getItem","
|
|
1
|
+
{"version":3,"names":["_session","require","_storageHelpers","_interopRequireWildcard","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","ownItemPlan","key","ownKeychainItemPlan","resolveKeychainAccess","nativeSessionItemNames","secureStorePromise","importSecureStore","mod","Promise","resolve","then","getItemAsync","setItemAsync","deleteItemAsync","bind","loadSecureStore","createNativeSecureKeyValueStorage","asyncStorage","getAsyncStorage","createPlatformStorage","getItem","secure","readThroughPlan","read","setItem","value","write","removeItem","deleteThroughPlan","delete"],"sourceRoot":"../../../../src","sources":["ui/session/nativeSecureStorage.ts"],"mappings":";;;;;;AAmCA,IAAAA,QAAA,GAAAC,OAAA;AAQA,IAAAC,eAAA,GAAAD,OAAA;AAAgE,SAAAE,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,IAAAD,CAAA,gBAAAC,CAAA,OAAAa,cAAA,CAAAC,IAAA,CAAAf,CAAA,EAAAC,CAAA,OAAAM,CAAA,IAAAD,CAAA,GAAAU,MAAA,CAAAC,cAAA,KAAAD,MAAA,CAAAE,wBAAA,CAAAlB,CAAA,EAAAC,CAAA,OAAAM,CAAA,CAAAK,GAAA,IAAAL,CAAA,CAAAM,GAAA,IAAAP,CAAA,CAAAE,CAAA,EAAAP,CAAA,EAAAM,CAAA,IAAAC,CAAA,CAAAP,CAAA,IAAAD,CAAA,CAAAC,CAAA,WAAAO,CAAA,KAAAR,CAAA,EAAAC,CAAA,KA3ChE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;A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reList":[]}
|
|
@@ -20,18 +20,31 @@
|
|
|
20
20
|
* `const m = 'expo-secure-store'; import(m)` never hid it from Metro (Babel
|
|
21
21
|
* evaluates the constant, so Metro resolved it anyway) and only hid it from the
|
|
22
22
|
* gates that read this source.
|
|
23
|
+
*
|
|
24
|
+
* ## Whose item this is (iOS)
|
|
25
|
+
*
|
|
26
|
+
* Every key stored here is the SAME name in every Oxy app (`oxy.auth.v1`, the
|
|
27
|
+
* warm token, the sign-out marker, the identity pin). On Android each app's
|
|
28
|
+
* expo-secure-store is its own; on iOS an item written without an access group
|
|
29
|
+
* lands in the app's default group, which for every app but Commons and the
|
|
30
|
+
* Peable wallet is the shared one, so they all read and overwrote ONE session.
|
|
31
|
+
* The items now live in the app's own group (`<prefix><bundle id>`,
|
|
32
|
+
* `ownKeychainItemPlan`, ADR 0062 D6); the copy in the shared group is never
|
|
33
|
+
* read as this app's (it may be another app's, or Commons' vault session) and
|
|
34
|
+
* never deleted (apps still on an older build use it). The cross-app join point
|
|
35
|
+
* is the dedicated device-session slot (`sharedDeviceCredentialStore.ts`), whose
|
|
36
|
+
* credential every adopting app proves with a mint.
|
|
23
37
|
*/
|
|
24
|
-
import { deleteThroughPlan, ownKeychainItemPlan, readThroughPlan, resolveKeychainAccess } from '@oxy.so/core/session';
|
|
38
|
+
import { deleteThroughPlan, nativeSessionItemNames, ownKeychainItemPlan, readThroughPlan, resolveKeychainAccess } from '@oxy.so/core/session';
|
|
25
39
|
import { createPlatformStorage } from "../utils/storageHelpers.js";
|
|
26
40
|
/**
|
|
27
|
-
* Where this app's own
|
|
28
|
-
* docs/identity/ios-keychain-access-groups.md):
|
|
29
|
-
* wallet
|
|
30
|
-
*
|
|
31
|
-
* made. Android and web: no options.
|
|
41
|
+
* Where this app's own copy of `key` is on iOS (`ownKeychainItemPlan`,
|
|
42
|
+
* docs/identity/ios-keychain-access-groups.md): the app's own group, then
|
|
43
|
+
* Commons' or the wallet's default group where D3 put it. Android and web: no
|
|
44
|
+
* options.
|
|
32
45
|
*/
|
|
33
|
-
async function ownItemPlan() {
|
|
34
|
-
return ownKeychainItemPlan(await resolveKeychainAccess());
|
|
46
|
+
async function ownItemPlan(key) {
|
|
47
|
+
return ownKeychainItemPlan(await resolveKeychainAccess(), nativeSessionItemNames(key));
|
|
35
48
|
}
|
|
36
49
|
let secureStorePromise = null;
|
|
37
50
|
|
|
@@ -80,14 +93,14 @@ export function createNativeSecureKeyValueStorage() {
|
|
|
80
93
|
getItem: async key => {
|
|
81
94
|
const secure = await loadSecureStore();
|
|
82
95
|
if (secure) {
|
|
83
|
-
return readThroughPlan(secure, key, {}, (await ownItemPlan()).read);
|
|
96
|
+
return readThroughPlan(secure, key, {}, (await ownItemPlan(key)).read);
|
|
84
97
|
}
|
|
85
98
|
return (await getAsyncStorage()).getItem(key);
|
|
86
99
|
},
|
|
87
100
|
setItem: async (key, value) => {
|
|
88
101
|
const secure = await loadSecureStore();
|
|
89
102
|
if (secure) {
|
|
90
|
-
await secure.setItemAsync(key, value, (await ownItemPlan()).write);
|
|
103
|
+
await secure.setItemAsync(key, value, (await ownItemPlan(key)).write);
|
|
91
104
|
return;
|
|
92
105
|
}
|
|
93
106
|
await (await getAsyncStorage()).setItem(key, value);
|
|
@@ -95,7 +108,7 @@ export function createNativeSecureKeyValueStorage() {
|
|
|
95
108
|
removeItem: async key => {
|
|
96
109
|
const secure = await loadSecureStore();
|
|
97
110
|
if (secure) {
|
|
98
|
-
await deleteThroughPlan(secure, key, {}, (await ownItemPlan()).delete);
|
|
111
|
+
await deleteThroughPlan(secure, key, {}, (await ownItemPlan(key)).delete);
|
|
99
112
|
return;
|
|
100
113
|
}
|
|
101
114
|
await (await getAsyncStorage()).removeItem(key);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["deleteThroughPlan","ownKeychainItemPlan","readThroughPlan","resolveKeychainAccess","createPlatformStorage","ownItemPlan","secureStorePromise","importSecureStore","mod","getItemAsync","setItemAsync","deleteItemAsync","bind","loadSecureStore","createNativeSecureKeyValueStorage","asyncStorage","getAsyncStorage","getItem","
|
|
1
|
+
{"version":3,"names":["deleteThroughPlan","nativeSessionItemNames","ownKeychainItemPlan","readThroughPlan","resolveKeychainAccess","createPlatformStorage","ownItemPlan","key","secureStorePromise","importSecureStore","mod","getItemAsync","setItemAsync","deleteItemAsync","bind","loadSecureStore","createNativeSecureKeyValueStorage","asyncStorage","getAsyncStorage","getItem","secure","read","setItem","value","write","removeItem","delete"],"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;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAEEA,iBAAiB,EACjBC,sBAAsB,EACtBC,mBAAmB,EACnBC,eAAe,EACfC,qBAAqB,QAChB,sBAAsB;AAC7B,SAASC,qBAAqB,QAAQ,4BAAyB;AAQ/D;AACA;AACA;AACA;AACA;AACA;AACA,eAAeC,WAAWA,CAACC,GAAW,EAAE;EACtC,OAAOL,mBAAmB,CAAC,MAAME,qBAAqB,CAAC,CAAC,EAAEH,sBAAsB,CAACM,GAAG,CAAC,CAAC;AACxF;AAEA,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,CAAC,MAAM;IACN,OAAO,IAAI;EACb;EACA,IACE,OAAOA,GAAG,CAACC,YAAY,KAAK,UAAU,IACtC,OAAOD,GAAG,CAACE,YAAY,KAAK,UAAU,IACtC,OAAOF,GAAG,CAACG,eAAe,KAAK,UAAU,EACzC;IACA,OAAO;MACLF,YAAY,EAAED,GAAG,CAACC,YAAY,CAACG,I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C,MAAMN,eAAe,CAAC,CAAC,EAAEI,OAAO,CAACf,GAAG,EAAEgB,KAAK,CAAC;IACrD,CAAC;IACDE,UAAU,EAAE,MAAOlB,GAAG,IAAK;MACzB,MAAMa,MAAM,GAAG,MAAML,eAAe,CAAC,CAAC;MACtC,IAAIK,MAAM,EAAE;QACV,MAAMpB,iBAAiB,CAACoB,MAAM,EAAEb,GAAG,EAAE,CAAC,CAAC,EAAE,CAAC,MAAMD,WAAW,CAACC,GAAG,CAAC,EAAEmB,MAAM,CAAC;QACzE;MACF;MACA,MAAM,CAAC,MAAMR,eAAe,CAAC,CAAC,EAAEO,UAAU,CAAClB,GAAG,CAAC;IACjD;EACF,CAAC;AACH","ignoreList":[]}
|
|
@@ -18,6 +18,20 @@
|
|
|
18
18
|
* `const m = 'expo-secure-store'; import(m)` never hid it from Metro (Babel
|
|
19
19
|
* evaluates the constant, so Metro resolved it anyway) and only hid it from the
|
|
20
20
|
* gates that read this source.
|
|
21
|
+
*
|
|
22
|
+
* ## Whose item this is (iOS)
|
|
23
|
+
*
|
|
24
|
+
* Every key stored here is the SAME name in every Oxy app (`oxy.auth.v1`, the
|
|
25
|
+
* warm token, the sign-out marker, the identity pin). On Android each app's
|
|
26
|
+
* expo-secure-store is its own; on iOS an item written without an access group
|
|
27
|
+
* lands in the app's default group, which for every app but Commons and the
|
|
28
|
+
* Peable wallet is the shared one, so they all read and overwrote ONE session.
|
|
29
|
+
* The items now live in the app's own group (`<prefix><bundle id>`,
|
|
30
|
+
* `ownKeychainItemPlan`, ADR 0062 D6); the copy in the shared group is never
|
|
31
|
+
* read as this app's (it may be another app's, or Commons' vault session) and
|
|
32
|
+
* never deleted (apps still on an older build use it). The cross-app join point
|
|
33
|
+
* is the dedicated device-session slot (`sharedDeviceCredentialStore.ts`), whose
|
|
34
|
+
* credential every adopting app proves with a mint.
|
|
21
35
|
*/
|
|
22
36
|
import { type NativeKeyValueStorage } from '@oxy.so/core/session';
|
|
23
37
|
/**
|
|
@@ -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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,OAAO,EACL,KAAK,qBAAqB,EAM3B,MAAM,sBAAsB,CAAC;AAqD9B;;;;;GAKG;AACH,wBAAgB,iCAAiC,IAAI,qBAAqB,CAiCzE"}
|
|
@@ -18,6 +18,20 @@
|
|
|
18
18
|
* `const m = 'expo-secure-store'; import(m)` never hid it from Metro (Babel
|
|
19
19
|
* evaluates the constant, so Metro resolved it anyway) and only hid it from the
|
|
20
20
|
* gates that read this source.
|
|
21
|
+
*
|
|
22
|
+
* ## Whose item this is (iOS)
|
|
23
|
+
*
|
|
24
|
+
* Every key stored here is the SAME name in every Oxy app (`oxy.auth.v1`, the
|
|
25
|
+
* warm token, the sign-out marker, the identity pin). On Android each app's
|
|
26
|
+
* expo-secure-store is its own; on iOS an item written without an access group
|
|
27
|
+
* lands in the app's default group, which for every app but Commons and the
|
|
28
|
+
* Peable wallet is the shared one, so they all read and overwrote ONE session.
|
|
29
|
+
* The items now live in the app's own group (`<prefix><bundle id>`,
|
|
30
|
+
* `ownKeychainItemPlan`, ADR 0062 D6); the copy in the shared group is never
|
|
31
|
+
* read as this app's (it may be another app's, or Commons' vault session) and
|
|
32
|
+
* never deleted (apps still on an older build use it). The cross-app join point
|
|
33
|
+
* is the dedicated device-session slot (`sharedDeviceCredentialStore.ts`), whose
|
|
34
|
+
* credential every adopting app proves with a mint.
|
|
21
35
|
*/
|
|
22
36
|
import { type NativeKeyValueStorage } from '@oxy.so/core/session';
|
|
23
37
|
/**
|
|
@@ -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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,OAAO,EACL,KAAK,qBAAqB,EAM3B,MAAM,sBAAsB,CAAC;AAqD9B;;;;;GAKG;AACH,wBAAgB,iCAAiC,IAAI,qBAAqB,CAiCzE"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oxy.so/services",
|
|
3
|
-
"version": "14.
|
|
3
|
+
"version": "14.10.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",
|
|
@@ -183,7 +183,7 @@
|
|
|
183
183
|
"devDependencies": {
|
|
184
184
|
"@expo/app-integrity": "~58.0.2",
|
|
185
185
|
"@expo/vector-icons": "^15.1.1",
|
|
186
|
-
"@oxy.so/core": "7.
|
|
186
|
+
"@oxy.so/core": "7.31.0",
|
|
187
187
|
"@react-native-async-storage/async-storage": "^3.1.1",
|
|
188
188
|
"@react-native-community/netinfo": "^12.0.1",
|
|
189
189
|
"@react-native/babel-preset": "^0.88.1",
|
|
@@ -236,7 +236,7 @@
|
|
|
236
236
|
"@expo/app-integrity": ">=0.1.10 <59.0.0",
|
|
237
237
|
"@expo/vector-icons": "^15.0.3",
|
|
238
238
|
"@oxy.so/bloom": ">=11.1.0",
|
|
239
|
-
"@oxy.so/core": "^7.
|
|
239
|
+
"@oxy.so/core": "^7.31.0",
|
|
240
240
|
"@react-native-async-storage/async-storage": ">=2.0.0 <4.0.0",
|
|
241
241
|
"@react-native-community/netinfo": ">=11.4.1 <13.0.0",
|
|
242
242
|
"@tanstack/query-async-storage-persister": "^5.101",
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The native secure key/value seam on iOS (ADR 0062 D6): every key it stores is
|
|
3
|
+
* one every Oxy app writes under the same name, so each call must name only this
|
|
4
|
+
* app's own locations — never the shared group's copy, which may be another
|
|
5
|
+
* app's session. `@oxy.so/core` owns and tests the placement rules against a
|
|
6
|
+
* keychain with Apple's semantics (`ownSessionItems.test.ts`); what is pinned
|
|
7
|
+
* here is that this adapter asks for them per key and passes them through.
|
|
8
|
+
*/
|
|
9
|
+
import type { KeychainAccess, NativeKeyValueStorage } from '@oxy.so/core/session';
|
|
10
|
+
|
|
11
|
+
const TEAM = 'ABCDE12345.';
|
|
12
|
+
const SHARED = `${TEAM}group.so.oxy.shared`;
|
|
13
|
+
const IDENTITY = `${TEAM}so.oxy.identity`;
|
|
14
|
+
const MENTION = `${TEAM}so.oxy.mention`;
|
|
15
|
+
const COMMONS = `${TEAM}so.oxy.commons`;
|
|
16
|
+
const MARKER = 'oxy.auth.automatic-identity-signin-suppressed.v1';
|
|
17
|
+
|
|
18
|
+
function makeSecureStore() {
|
|
19
|
+
const calls: Array<{ op: string; key: string; options?: Record<string, unknown> }> = [];
|
|
20
|
+
return {
|
|
21
|
+
calls,
|
|
22
|
+
module: {
|
|
23
|
+
getItemAsync: async (key: string, options?: Record<string, unknown>) => {
|
|
24
|
+
calls.push({ op: 'get', key, options });
|
|
25
|
+
return null;
|
|
26
|
+
},
|
|
27
|
+
setItemAsync: async (key: string, _value: string, options?: Record<string, unknown>) => {
|
|
28
|
+
calls.push({ op: 'set', key, options });
|
|
29
|
+
},
|
|
30
|
+
deleteItemAsync: async (key: string, options?: Record<string, unknown>) => {
|
|
31
|
+
calls.push({ op: 'delete', key, options });
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function load(access: KeychainAccess, secureStore: ReturnType<typeof makeSecureStore>) {
|
|
38
|
+
jest.resetModules();
|
|
39
|
+
jest.doMock('@oxy.so/core/session', () => ({
|
|
40
|
+
...jest.requireActual('@oxy.so/core/session'),
|
|
41
|
+
resolveKeychainAccess: async () => access,
|
|
42
|
+
}));
|
|
43
|
+
jest.doMock('expo-secure-store', () => secureStore.module);
|
|
44
|
+
const mod = require('../nativeSecureStorage') as typeof import('../nativeSecureStorage');
|
|
45
|
+
return mod.createNativeSecureKeyValueStorage();
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
async function exercise(storage: NativeKeyValueStorage, key: string) {
|
|
49
|
+
await storage.getItem(key);
|
|
50
|
+
await storage.setItem(key, 'v');
|
|
51
|
+
await storage.removeItem(key);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const options = (store: ReturnType<typeof makeSecureStore>, key: string) =>
|
|
55
|
+
store.calls.filter((c) => c.key === key).map((c) => [c.op, c.options]);
|
|
56
|
+
|
|
57
|
+
afterEach(() => {
|
|
58
|
+
jest.dontMock('@oxy.so/core/session');
|
|
59
|
+
jest.dontMock('expo-secure-store');
|
|
60
|
+
jest.resetModules();
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
describe('createNativeSecureKeyValueStorage on iOS', () => {
|
|
64
|
+
test('a member keeps its session in its own group, never the shared copy', async () => {
|
|
65
|
+
const store = makeSecureStore();
|
|
66
|
+
const storage = load(
|
|
67
|
+
{ mode: 'grouped', prefix: TEAM, defaultGroup: SHARED, role: 'member', appGroup: MENTION },
|
|
68
|
+
store,
|
|
69
|
+
);
|
|
70
|
+
for (const key of ['oxy.auth.v1', 'oxy.auth.token.v1', 'oxy.identity.pin.v1']) {
|
|
71
|
+
await exercise(storage, key);
|
|
72
|
+
expect(options(store, key)).toEqual([
|
|
73
|
+
['get', { accessGroup: MENTION }],
|
|
74
|
+
['set', { accessGroup: MENTION }],
|
|
75
|
+
['delete', { accessGroup: MENTION }],
|
|
76
|
+
]);
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
test('the sign-out marker also honours, and releases, a shared copy', async () => {
|
|
81
|
+
const store = makeSecureStore();
|
|
82
|
+
const storage = load(
|
|
83
|
+
{ mode: 'grouped', prefix: TEAM, defaultGroup: SHARED, role: 'member', appGroup: MENTION },
|
|
84
|
+
store,
|
|
85
|
+
);
|
|
86
|
+
await exercise(storage, MARKER);
|
|
87
|
+
expect(options(store, MARKER)).toEqual([
|
|
88
|
+
['get', { accessGroup: MENTION }],
|
|
89
|
+
['get', { accessGroup: SHARED }],
|
|
90
|
+
['set', { accessGroup: MENTION }],
|
|
91
|
+
['delete', { accessGroup: SHARED }],
|
|
92
|
+
['delete', { accessGroup: MENTION }],
|
|
93
|
+
]);
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
test('Commons reads the copy the split put in its default group, and deletes it first', async () => {
|
|
97
|
+
const store = makeSecureStore();
|
|
98
|
+
const storage = load(
|
|
99
|
+
{ mode: 'grouped', prefix: TEAM, defaultGroup: IDENTITY, role: 'holder', appGroup: COMMONS },
|
|
100
|
+
store,
|
|
101
|
+
);
|
|
102
|
+
await exercise(storage, 'oxy.auth.v1');
|
|
103
|
+
expect(options(store, 'oxy.auth.v1')).toEqual([
|
|
104
|
+
['get', { accessGroup: COMMONS }],
|
|
105
|
+
['get', { accessGroup: IDENTITY }],
|
|
106
|
+
['set', { accessGroup: COMMONS }],
|
|
107
|
+
['delete', { accessGroup: IDENTITY }],
|
|
108
|
+
['delete', { accessGroup: COMMONS }],
|
|
109
|
+
]);
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
test('Android, web and an older native build pass no group', async () => {
|
|
113
|
+
const store = makeSecureStore();
|
|
114
|
+
await exercise(load({ mode: 'ungrouped' }, store), 'oxy.auth.v1');
|
|
115
|
+
expect(options(store, 'oxy.auth.v1')).toEqual([
|
|
116
|
+
['get', {}],
|
|
117
|
+
['set', {}],
|
|
118
|
+
['delete', {}],
|
|
119
|
+
]);
|
|
120
|
+
});
|
|
121
|
+
});
|
|
@@ -18,10 +18,25 @@
|
|
|
18
18
|
* `const m = 'expo-secure-store'; import(m)` never hid it from Metro (Babel
|
|
19
19
|
* evaluates the constant, so Metro resolved it anyway) and only hid it from the
|
|
20
20
|
* gates that read this source.
|
|
21
|
+
*
|
|
22
|
+
* ## Whose item this is (iOS)
|
|
23
|
+
*
|
|
24
|
+
* Every key stored here is the SAME name in every Oxy app (`oxy.auth.v1`, the
|
|
25
|
+
* warm token, the sign-out marker, the identity pin). On Android each app's
|
|
26
|
+
* expo-secure-store is its own; on iOS an item written without an access group
|
|
27
|
+
* lands in the app's default group, which for every app but Commons and the
|
|
28
|
+
* Peable wallet is the shared one, so they all read and overwrote ONE session.
|
|
29
|
+
* The items now live in the app's own group (`<prefix><bundle id>`,
|
|
30
|
+
* `ownKeychainItemPlan`, ADR 0062 D6); the copy in the shared group is never
|
|
31
|
+
* read as this app's (it may be another app's, or Commons' vault session) and
|
|
32
|
+
* never deleted (apps still on an older build use it). The cross-app join point
|
|
33
|
+
* is the dedicated device-session slot (`sharedDeviceCredentialStore.ts`), whose
|
|
34
|
+
* credential every adopting app proves with a mint.
|
|
21
35
|
*/
|
|
22
36
|
import {
|
|
23
37
|
type NativeKeyValueStorage,
|
|
24
38
|
deleteThroughPlan,
|
|
39
|
+
nativeSessionItemNames,
|
|
25
40
|
ownKeychainItemPlan,
|
|
26
41
|
readThroughPlan,
|
|
27
42
|
resolveKeychainAccess,
|
|
@@ -35,14 +50,13 @@ interface SecureStoreLike {
|
|
|
35
50
|
}
|
|
36
51
|
|
|
37
52
|
/**
|
|
38
|
-
* Where this app's own
|
|
39
|
-
* docs/identity/ios-keychain-access-groups.md):
|
|
40
|
-
* wallet
|
|
41
|
-
*
|
|
42
|
-
* made. Android and web: no options.
|
|
53
|
+
* Where this app's own copy of `key` is on iOS (`ownKeychainItemPlan`,
|
|
54
|
+
* docs/identity/ios-keychain-access-groups.md): the app's own group, then
|
|
55
|
+
* Commons' or the wallet's default group where D3 put it. Android and web: no
|
|
56
|
+
* options.
|
|
43
57
|
*/
|
|
44
|
-
async function ownItemPlan() {
|
|
45
|
-
return ownKeychainItemPlan(await resolveKeychainAccess());
|
|
58
|
+
async function ownItemPlan(key: string) {
|
|
59
|
+
return ownKeychainItemPlan(await resolveKeychainAccess(), nativeSessionItemNames(key));
|
|
46
60
|
}
|
|
47
61
|
|
|
48
62
|
let secureStorePromise: Promise<SecureStoreLike | null> | null = null;
|
|
@@ -97,14 +111,14 @@ export function createNativeSecureKeyValueStorage(): NativeKeyValueStorage {
|
|
|
97
111
|
getItem: async (key) => {
|
|
98
112
|
const secure = await loadSecureStore();
|
|
99
113
|
if (secure) {
|
|
100
|
-
return readThroughPlan(secure, key, {}, (await ownItemPlan()).read);
|
|
114
|
+
return readThroughPlan(secure, key, {}, (await ownItemPlan(key)).read);
|
|
101
115
|
}
|
|
102
116
|
return (await getAsyncStorage()).getItem(key);
|
|
103
117
|
},
|
|
104
118
|
setItem: async (key, value) => {
|
|
105
119
|
const secure = await loadSecureStore();
|
|
106
120
|
if (secure) {
|
|
107
|
-
await secure.setItemAsync(key, value, (await ownItemPlan()).write);
|
|
121
|
+
await secure.setItemAsync(key, value, (await ownItemPlan(key)).write);
|
|
108
122
|
return;
|
|
109
123
|
}
|
|
110
124
|
await (await getAsyncStorage()).setItem(key, value);
|
|
@@ -112,7 +126,7 @@ export function createNativeSecureKeyValueStorage(): NativeKeyValueStorage {
|
|
|
112
126
|
removeItem: async (key) => {
|
|
113
127
|
const secure = await loadSecureStore();
|
|
114
128
|
if (secure) {
|
|
115
|
-
await deleteThroughPlan(secure, key, {}, (await ownItemPlan()).delete);
|
|
129
|
+
await deleteThroughPlan(secure, key, {}, (await ownItemPlan(key)).delete);
|
|
116
130
|
return;
|
|
117
131
|
}
|
|
118
132
|
await (await getAsyncStorage()).removeItem(key);
|