@oxy.so/services 14.8.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/android/src/main/java/so/oxy/identity/OxyIdentityModule.kt +78 -10
- package/ios/OxyIdentityModule.swift +57 -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/commonjs/ui/utils/identityCrypto.d.ts +6 -0
- package/lib/typescript/commonjs/ui/utils/identityCrypto.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/lib/typescript/module/ui/utils/identityCrypto.d.ts +6 -0
- package/lib/typescript/module/ui/utils/identityCrypto.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/ui/session/__tests__/nativeSecureStorage.test.ts +121 -0
- package/src/ui/session/nativeSecureStorage.ts +24 -10
|
@@ -31,6 +31,9 @@ import expo.modules.kotlin.modules.ModuleDefinition
|
|
|
31
31
|
* | `describeOrganization(accountId)` | `describe` + `accountId` | `{ v, publicKey, accountId }` |
|
|
32
32
|
* | `deriveOrganizationScopedSeed(info, accountId)` | `deriveScopedSeed` + `accountId` | `{ seed, accountId }` |
|
|
33
33
|
* | `signOrganizationSocialReceive(index, digest, accountId)` | `signSocialReceive` + `accountId` | `{ signature, publicKey, accountId }` |
|
|
34
|
+
* | `listRetiredKeys(accountId?)` | `listRetiredKeys` (+ `accountId`) | `{ publicKeys, accountId? }` |
|
|
35
|
+
* | `deriveRetiredScopedSeed(info, publicKey, accountId?)` | `deriveScopedSeed` + `keyPublicKey` (+ `accountId`) | `{ seed, keyPublicKey, accountId? }` |
|
|
36
|
+
* | `signRetiredSocialReceive(index, digest, publicKey, accountId?)` | `signSocialReceive` + `keyPublicKey` (+ `accountId`) | `{ signature, publicKey, keyPublicKey, accountId? }` |
|
|
34
37
|
*
|
|
35
38
|
* The organization functions (ADR 0061 D6) ask for an organization key Commons
|
|
36
39
|
* holds, by the organization's account id. Commons echoes `accountId` in its
|
|
@@ -38,6 +41,15 @@ import expo.modules.kotlin.modules.ModuleDefinition
|
|
|
38
41
|
* that predates organization keys ignores the extra and answers for the
|
|
39
42
|
* PERSONAL identity, which must never be taken for an organization's.
|
|
40
43
|
*
|
|
44
|
+
* The retired functions (Commons protocol 4) reach a key the person, or the
|
|
45
|
+
* organization with `accountId`, rotated away from, by its public key: for
|
|
46
|
+
* spending the coins still at its addresses, never for signing in. Commons
|
|
47
|
+
* echoes the `keyPublicKey` it answered with, and an answer without that echo,
|
|
48
|
+
* or whose `accountId` is not the one asked for (absent for the person), is
|
|
49
|
+
* `null`: a Commons before protocol 4 ignores the extra and answers with the
|
|
50
|
+
* CURRENT key, which must never be taken for a retired one. `listRetiredKeys`
|
|
51
|
+
* resolves the retired public keys of that scope, minus the current one.
|
|
52
|
+
*
|
|
41
53
|
* Every failure — Commons not installed, no identity, the caller refused, an
|
|
42
54
|
* exception — resolves `null`, and the JS side (`@oxy.so/protocol`'s
|
|
43
55
|
* `loadCommonsIdentityBridge`) narrows whatever does come back. Plain scalars in,
|
|
@@ -94,9 +106,9 @@ class OxyIdentityModule : Module() {
|
|
|
94
106
|
}
|
|
95
107
|
|
|
96
108
|
AsyncFunction("describeOrganization") { accountId: String ->
|
|
97
|
-
ask(METHOD_DESCRIBE,
|
|
109
|
+
ask(METHOD_DESCRIBE, scopeExtras(accountId)) { bundle ->
|
|
98
110
|
val publicKey = bundle.getString(KEY_PUBLIC_KEY)
|
|
99
|
-
if (publicKey.isNullOrEmpty() || !
|
|
111
|
+
if (publicKey.isNullOrEmpty() || !echoesScope(bundle, accountId)) null
|
|
100
112
|
else mapOf(
|
|
101
113
|
KEY_VERSION to bundle.getInt(KEY_VERSION),
|
|
102
114
|
KEY_PUBLIC_KEY to publicKey,
|
|
@@ -106,23 +118,23 @@ class OxyIdentityModule : Module() {
|
|
|
106
118
|
}
|
|
107
119
|
|
|
108
120
|
AsyncFunction("deriveOrganizationScopedSeed") { info: String, accountId: String ->
|
|
109
|
-
val extras =
|
|
121
|
+
val extras = scopeExtras(accountId).apply { putString(KEY_INFO, info) }
|
|
110
122
|
ask(METHOD_DERIVE_SCOPED_SEED, extras) { bundle ->
|
|
111
123
|
val seed = bundle.getString(KEY_SEED)
|
|
112
|
-
if (seed.isNullOrEmpty() || !
|
|
124
|
+
if (seed.isNullOrEmpty() || !echoesScope(bundle, accountId)) null
|
|
113
125
|
else mapOf(KEY_SEED to seed, KEY_ACCOUNT_ID to accountId)
|
|
114
126
|
}
|
|
115
127
|
}
|
|
116
128
|
|
|
117
129
|
AsyncFunction("signOrganizationSocialReceive") { index: Int, digest: String, accountId: String ->
|
|
118
|
-
val extras =
|
|
130
|
+
val extras = scopeExtras(accountId).apply {
|
|
119
131
|
putInt(KEY_INDEX, index)
|
|
120
132
|
putString(KEY_DIGEST, digest)
|
|
121
133
|
}
|
|
122
134
|
ask(METHOD_SIGN_SOCIAL_RECEIVE, extras) { bundle ->
|
|
123
135
|
val signature = bundle.getString(KEY_SIGNATURE)
|
|
124
136
|
val publicKey = bundle.getString(KEY_PUBLIC_KEY)
|
|
125
|
-
if (signature.isNullOrEmpty() || publicKey.isNullOrEmpty() || !
|
|
137
|
+
if (signature.isNullOrEmpty() || publicKey.isNullOrEmpty() || !echoesScope(bundle, accountId)) null
|
|
126
138
|
else mapOf(
|
|
127
139
|
KEY_SIGNATURE to signature,
|
|
128
140
|
KEY_PUBLIC_KEY to publicKey,
|
|
@@ -130,15 +142,68 @@ class OxyIdentityModule : Module() {
|
|
|
130
142
|
)
|
|
131
143
|
}
|
|
132
144
|
}
|
|
145
|
+
|
|
146
|
+
AsyncFunction("listRetiredKeys") { accountId: String? ->
|
|
147
|
+
ask(METHOD_LIST_RETIRED_KEYS, scopeExtras(accountId)) { bundle ->
|
|
148
|
+
val publicKeys = bundle.getStringArrayList(KEY_PUBLIC_KEYS)
|
|
149
|
+
if (publicKeys == null || !echoesScope(bundle, accountId)) null
|
|
150
|
+
else scoped(accountId, KEY_PUBLIC_KEYS to publicKeys.toList())
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
AsyncFunction("deriveRetiredScopedSeed") { info: String, publicKey: String, accountId: String? ->
|
|
155
|
+
val extras = retiredExtras(publicKey, accountId).apply { putString(KEY_INFO, info) }
|
|
156
|
+
ask(METHOD_DERIVE_SCOPED_SEED, extras) { bundle ->
|
|
157
|
+
val seed = bundle.getString(KEY_SEED)
|
|
158
|
+
if (seed.isNullOrEmpty() || !echoesRetired(bundle, publicKey, accountId)) null
|
|
159
|
+
else scoped(accountId, KEY_SEED to seed, KEY_KEY_PUBLIC_KEY to publicKey)
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
AsyncFunction("signRetiredSocialReceive") { index: Int, digest: String, publicKey: String, accountId: String? ->
|
|
164
|
+
val extras = retiredExtras(publicKey, accountId).apply {
|
|
165
|
+
putInt(KEY_INDEX, index)
|
|
166
|
+
putString(KEY_DIGEST, digest)
|
|
167
|
+
}
|
|
168
|
+
ask(METHOD_SIGN_SOCIAL_RECEIVE, extras) { bundle ->
|
|
169
|
+
val signature = bundle.getString(KEY_SIGNATURE)
|
|
170
|
+
val childPublicKey = bundle.getString(KEY_PUBLIC_KEY)
|
|
171
|
+
if (
|
|
172
|
+
signature.isNullOrEmpty() ||
|
|
173
|
+
childPublicKey.isNullOrEmpty() ||
|
|
174
|
+
!echoesRetired(bundle, publicKey, accountId)
|
|
175
|
+
) null
|
|
176
|
+
else scoped(
|
|
177
|
+
accountId,
|
|
178
|
+
KEY_SIGNATURE to signature,
|
|
179
|
+
KEY_PUBLIC_KEY to childPublicKey,
|
|
180
|
+
KEY_KEY_PUBLIC_KEY to publicKey,
|
|
181
|
+
)
|
|
182
|
+
}
|
|
183
|
+
}
|
|
133
184
|
}
|
|
134
185
|
|
|
135
|
-
private fun
|
|
136
|
-
Bundle().apply { putString(KEY_ACCOUNT_ID, accountId) }
|
|
186
|
+
private fun scopeExtras(accountId: String?): Bundle =
|
|
187
|
+
Bundle().apply { if (accountId != null) putString(KEY_ACCOUNT_ID, accountId) }
|
|
188
|
+
|
|
189
|
+
private fun retiredExtras(publicKey: String, accountId: String?): Bundle =
|
|
190
|
+
scopeExtras(accountId).apply { putString(KEY_KEY_PUBLIC_KEY, publicKey) }
|
|
137
191
|
|
|
138
|
-
/**
|
|
139
|
-
|
|
192
|
+
/**
|
|
193
|
+
* Whether Commons answered for the scope asked for: that organization, or,
|
|
194
|
+
* with no `accountId`, the person (an answer without the echo).
|
|
195
|
+
*/
|
|
196
|
+
private fun echoesScope(bundle: Bundle, accountId: String?): Boolean =
|
|
140
197
|
bundle.getString(KEY_ACCOUNT_ID) == accountId
|
|
141
198
|
|
|
199
|
+
/** Whether Commons answered with the retired key asked for, in the scope asked for. */
|
|
200
|
+
private fun echoesRetired(bundle: Bundle, publicKey: String, accountId: String?): Boolean =
|
|
201
|
+
bundle.getString(KEY_KEY_PUBLIC_KEY) == publicKey && echoesScope(bundle, accountId)
|
|
202
|
+
|
|
203
|
+
/** [fields], plus the `accountId` echo when the request named one. */
|
|
204
|
+
private fun scoped(accountId: String?, vararg fields: Pair<String, Any>): Map<String, Any> =
|
|
205
|
+
if (accountId == null) mapOf(*fields) else mapOf(*fields, KEY_ACCOUNT_ID to accountId)
|
|
206
|
+
|
|
142
207
|
/**
|
|
143
208
|
* Call [method] on the first Commons authority that answers, and read the
|
|
144
209
|
* answer with [read]. An authority that is absent, refuses, or throws is
|
|
@@ -160,6 +225,7 @@ class OxyIdentityModule : Module() {
|
|
|
160
225
|
private const val METHOD_PROVE_IDENTITY = "proveIdentity"
|
|
161
226
|
private const val METHOD_DERIVE_SCOPED_SEED = "deriveScopedSeed"
|
|
162
227
|
private const val METHOD_SIGN_SOCIAL_RECEIVE = "signSocialReceive"
|
|
228
|
+
private const val METHOD_LIST_RETIRED_KEYS = "listRetiredKeys"
|
|
163
229
|
|
|
164
230
|
private const val KEY_VERSION = "v"
|
|
165
231
|
private const val KEY_PUBLIC_KEY = "publicKey"
|
|
@@ -171,6 +237,8 @@ class OxyIdentityModule : Module() {
|
|
|
171
237
|
private const val KEY_INDEX = "index"
|
|
172
238
|
private const val KEY_DIGEST = "digest"
|
|
173
239
|
private const val KEY_ACCOUNT_ID = "accountId"
|
|
240
|
+
private const val KEY_KEY_PUBLIC_KEY = "keyPublicKey"
|
|
241
|
+
private const val KEY_PUBLIC_KEYS = "publicKeys"
|
|
174
242
|
|
|
175
243
|
/**
|
|
176
244
|
* Commons hosts its identity at "${applicationId}.identity": the prod app
|
|
@@ -90,6 +90,63 @@ public class OxyIdentityModule: Module {
|
|
|
90
90
|
}
|
|
91
91
|
return group
|
|
92
92
|
}
|
|
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
|
+
|
|
137
|
+
// Retired keys (Commons protocol 4): iOS reads them from the wallet group
|
|
138
|
+
// directly, like the current key.
|
|
139
|
+
AsyncFunction("listRetiredKeys") { (_ accountId: String?) -> [String: Any]? in
|
|
140
|
+
return nil
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
AsyncFunction("deriveRetiredScopedSeed") { (_ info: String, _ publicKey: String, _ accountId: String?) -> [String: String]? in
|
|
144
|
+
return nil
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
AsyncFunction("signRetiredSocialReceive") { (_ index: Int, _ digest: String, _ publicKey: String, _ accountId: String?) -> [String: String]? in
|
|
148
|
+
return nil
|
|
149
|
+
}
|
|
93
150
|
}
|
|
94
151
|
}
|
|
95
152
|
|
|
@@ -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,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rD,CAAC;IACDE,UAAU,EAAE,MAAO1B,GAAG,IAAK;MACzB,MAAMoB,MAAM,GAAG,MAAMN,eAAe,CAAC,CAAC;MACtC,IAAIM,MAAM,EAAE;QACV,MAAM,IAAAO,0BAAiB,EAACP,MAAM,EAAEpB,GAAG,EAAE,CAAC,CAAC,EAAE,CAAC,MAAMD,WAAW,CAACC,GAAG,CAAC,EAAE4B,MAAM,CAAC;QACzE;MACF;MACA,MAAM,CAAC,MAAMX,eAAe,CAAC,CAAC,EAAES,UAAU,CAAC1B,GAAG,CAAC;IACjD;EACF,CAAC;AACH","ignoreList":[]}
|
|
@@ -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;AAC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;MACA,OAAO,CAAC,MAAMH,eAAe,CAAC,CAAC,EAAEC,OAAO,CAACZ,GAAG,CAAC;IAC/C,CAAC;IACDe,OAAO,EAAE,MAAAA,CAAOf,GAAG,EAAEgB,KAAK,KAAK;MAC7B,MAAMH,MAAM,GAAG,MAAML,eAAe,CAAC,CAAC;MACtC,IAAIK,MAAM,EAAE;QACV,MAAMA,MAAM,CAACR,YAAY,CAACL,GAAG,EAAEgB,KAAK,EAAE,CAAC,MAAMjB,WAAW,CAACC,GAAG,CAAC,EAAEiB,KAAK,CAAC;QACrE;MACF;MACA,MAAM,CAAC,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"}
|
|
@@ -44,6 +44,12 @@ export declare const loadIdentityCrypto: () => Promise<{
|
|
|
44
44
|
deleteThroughPlan: typeof import("@oxy.so/core/session").deleteThroughPlan;
|
|
45
45
|
groupedKeychainStore: typeof import("@oxy.so/core/crypto").groupedKeychainStore;
|
|
46
46
|
ensureKeychainGroupsMigrated: typeof import("@oxy.so/core/crypto").ensureKeychainGroupsMigrated;
|
|
47
|
+
retireIdentityKey: typeof import("@oxy.so/core/crypto").retireIdentityKey;
|
|
48
|
+
listRetiredIdentityKeys: typeof import("@oxy.so/core/crypto").listRetiredIdentityKeys;
|
|
49
|
+
forgetRetiredIdentityKey: typeof import("@oxy.so/core/crypto").forgetRetiredIdentityKey;
|
|
50
|
+
forgetRetiredIdentityKeys: typeof import("@oxy.so/core/crypto").forgetRetiredIdentityKeys;
|
|
51
|
+
syncRetiredKeys: typeof import("@oxy.so/core/crypto").syncRetiredKeys;
|
|
52
|
+
retiredKeyFromPhrase: typeof import("@oxy.so/core/crypto").retiredKeyFromPhrase;
|
|
47
53
|
SignatureService: typeof import("@oxy.so/core/crypto").SignatureService;
|
|
48
54
|
RecoveryPhraseService: typeof import("@oxy.so/core/crypto").RecoveryPhraseService;
|
|
49
55
|
BACKUP_KDF_ENCRYPTION_INFO: "oxy-backup-encryption-key";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"identityCrypto.d.ts","sourceRoot":"","sources":["../../../../../src/ui/utils/identityCrypto.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,eAAO,MAAM,kBAAkB
|
|
1
|
+
{"version":3,"file":"identityCrypto.d.ts","sourceRoot":"","sources":["../../../../../src/ui/utils/identityCrypto.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAAsC,CAAC"}
|
|
@@ -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"}
|
|
@@ -44,6 +44,12 @@ export declare const loadIdentityCrypto: () => Promise<{
|
|
|
44
44
|
deleteThroughPlan: typeof import("@oxy.so/core/session").deleteThroughPlan;
|
|
45
45
|
groupedKeychainStore: typeof import("@oxy.so/core/crypto").groupedKeychainStore;
|
|
46
46
|
ensureKeychainGroupsMigrated: typeof import("@oxy.so/core/crypto").ensureKeychainGroupsMigrated;
|
|
47
|
+
retireIdentityKey: typeof import("@oxy.so/core/crypto").retireIdentityKey;
|
|
48
|
+
listRetiredIdentityKeys: typeof import("@oxy.so/core/crypto").listRetiredIdentityKeys;
|
|
49
|
+
forgetRetiredIdentityKey: typeof import("@oxy.so/core/crypto").forgetRetiredIdentityKey;
|
|
50
|
+
forgetRetiredIdentityKeys: typeof import("@oxy.so/core/crypto").forgetRetiredIdentityKeys;
|
|
51
|
+
syncRetiredKeys: typeof import("@oxy.so/core/crypto").syncRetiredKeys;
|
|
52
|
+
retiredKeyFromPhrase: typeof import("@oxy.so/core/crypto").retiredKeyFromPhrase;
|
|
47
53
|
SignatureService: typeof import("@oxy.so/core/crypto").SignatureService;
|
|
48
54
|
RecoveryPhraseService: typeof import("@oxy.so/core/crypto").RecoveryPhraseService;
|
|
49
55
|
BACKUP_KDF_ENCRYPTION_INFO: "oxy-backup-encryption-key";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"identityCrypto.d.ts","sourceRoot":"","sources":["../../../../../src/ui/utils/identityCrypto.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,eAAO,MAAM,kBAAkB
|
|
1
|
+
{"version":3,"file":"identityCrypto.d.ts","sourceRoot":"","sources":["../../../../../src/ui/utils/identityCrypto.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAAsC,CAAC"}
|
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",
|
|
@@ -176,14 +176,14 @@
|
|
|
176
176
|
"delete-dts.js": "find ./lib/commonjs ./lib/module \\( -name '*.d.js*' -o -name '*.d.ts' \\) -delete"
|
|
177
177
|
},
|
|
178
178
|
"dependencies": {
|
|
179
|
-
"@oxy.so/contracts": "^6.
|
|
179
|
+
"@oxy.so/contracts": "^6.12.0",
|
|
180
180
|
"color": "^5.0.3",
|
|
181
181
|
"@peable.to/sdk": "^4.0.0"
|
|
182
182
|
},
|
|
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);
|