@oxy.so/services 14.8.0 → 14.9.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.
@@ -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, organizationExtras(accountId)) { bundle ->
109
+ ask(METHOD_DESCRIBE, scopeExtras(accountId)) { bundle ->
98
110
  val publicKey = bundle.getString(KEY_PUBLIC_KEY)
99
- if (publicKey.isNullOrEmpty() || !echoes(bundle, accountId)) null
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 = organizationExtras(accountId).apply { putString(KEY_INFO, info) }
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() || !echoes(bundle, accountId)) null
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 = organizationExtras(accountId).apply {
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() || !echoes(bundle, accountId)) null
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 organizationExtras(accountId: String): Bundle =
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
- /** Whether Commons answered for the organization asked for, not for the person. */
139
- private fun echoes(bundle: Bundle, accountId: String): Boolean =
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,20 @@ public class OxyIdentityModule: Module {
90
90
  }
91
91
  return group
92
92
  }
93
+
94
+ // Retired keys (Commons protocol 4): iOS reads them from the wallet group
95
+ // directly, like the current key.
96
+ AsyncFunction("listRetiredKeys") { (_ accountId: String?) -> [String: Any]? in
97
+ return nil
98
+ }
99
+
100
+ AsyncFunction("deriveRetiredScopedSeed") { (_ info: String, _ publicKey: String, _ accountId: String?) -> [String: String]? in
101
+ return nil
102
+ }
103
+
104
+ AsyncFunction("signRetiredSocialReceive") { (_ index: Int, _ digest: String, _ publicKey: String, _ accountId: String?) -> [String: String]? in
105
+ return nil
106
+ }
93
107
  }
94
108
  }
95
109
 
@@ -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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAAsC,CAAC"}
1
+ {"version":3,"file":"identityCrypto.d.ts","sourceRoot":"","sources":["../../../../../src/ui/utils/identityCrypto.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAAsC,CAAC"}
@@ -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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAAsC,CAAC"}
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.8.0",
3
+ "version": "14.9.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.11.0",
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.29.0",
186
+ "@oxy.so/core": "7.30.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.29.0",
239
+ "@oxy.so/core": "^7.30.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",