@oxy.so/core 4.5.0-oxy-one.0 → 4.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.
Files changed (285) hide show
  1. package/README.md +1 -1
  2. package/dist/cjs/HttpService.js +63 -19
  3. package/dist/cjs/api/accounts.js +10 -3
  4. package/dist/cjs/api/agency.js +3 -1
  5. package/dist/cjs/api/apps.js +15 -4
  6. package/dist/cjs/api/assets.js +49 -12
  7. package/dist/cjs/api/auth.js +37 -11
  8. package/dist/cjs/api/billing.js +24 -7
  9. package/dist/cjs/api/civic.js +14 -4
  10. package/dist/cjs/api/follows.js +9 -2
  11. package/dist/cjs/api/identity.js +31 -9
  12. package/dist/cjs/api/nodes.js +3 -1
  13. package/dist/cjs/api/privacy.js +8 -2
  14. package/dist/cjs/api/session.js +15 -4
  15. package/dist/cjs/api/store.js +15 -5
  16. package/dist/cjs/api/topics.js +10 -3
  17. package/dist/cjs/api/users.js +16 -4
  18. package/dist/cjs/boot/sessionColdBoot.js +40 -13
  19. package/dist/cjs/constants/version.js +6 -6
  20. package/dist/cjs/crypto/identityMarker.js +3 -1
  21. package/dist/cjs/crypto/identityProof.js +6 -1
  22. package/dist/cjs/crypto/keyManager.js +87 -32
  23. package/dist/cjs/crypto/recoveryPhrase.js +2 -2
  24. package/dist/cjs/crypto/signatureService.js +3 -4
  25. package/dist/cjs/i18n/index.js +16 -3
  26. package/dist/cjs/i18n/locales/ar-SA.js +366 -366
  27. package/dist/cjs/i18n/locales/ca-ES.js +366 -366
  28. package/dist/cjs/i18n/locales/de-DE.js +366 -366
  29. package/dist/cjs/i18n/locales/en-US.js +1994 -1994
  30. package/dist/cjs/i18n/locales/es-ES.js +1994 -1994
  31. package/dist/cjs/i18n/locales/fr-FR.js +366 -366
  32. package/dist/cjs/i18n/locales/it-IT.js +366 -366
  33. package/dist/cjs/i18n/locales/ja-JP.js +366 -366
  34. package/dist/cjs/i18n/locales/ko-KR.js +366 -366
  35. package/dist/cjs/i18n/locales/pt-PT.js +366 -366
  36. package/dist/cjs/i18n/locales/zh-CN.js +366 -366
  37. package/dist/cjs/inference/OxyInferenceClient.js +12 -18
  38. package/dist/cjs/models/interfaces.js +11 -11
  39. package/dist/cjs/server/OxyServer.js +86 -28
  40. package/dist/cjs/server/agentAccount.js +6 -2
  41. package/dist/cjs/server/aliaMachineCredential.js +39 -14
  42. package/dist/cjs/server/auth.js +5 -4
  43. package/dist/cjs/server/capabilityTicket.js +5 -5
  44. package/dist/cjs/server/index.js +2 -1
  45. package/dist/cjs/server/liveCapabilityTicket.js +4 -1
  46. package/dist/cjs/server/middleware.js +61 -42
  47. package/dist/cjs/server/namespaces.js +28 -7
  48. package/dist/cjs/server/requesterAssertion.js +36 -30
  49. package/dist/cjs/server/serviceTokenLifetime.js +7 -4
  50. package/dist/cjs/server/traffic.js +53 -14
  51. package/dist/cjs/server/trafficNodeHttp.js +33 -8
  52. package/dist/cjs/server/workloadIdentity.client.js +4 -0
  53. package/dist/cjs/server/workloadIdentity.js +28 -1
  54. package/dist/cjs/session/SessionClient.js +54 -17
  55. package/dist/cjs/session/accountDelegationAccess.js +4 -6
  56. package/dist/cjs/session/accountDialogController.js +1 -1
  57. package/dist/cjs/session/authStateStore.js +18 -9
  58. package/dist/cjs/session/identityPin.js +6 -2
  59. package/dist/cjs/session/refresh.js +81 -23
  60. package/dist/cjs/session/sharedDeviceCredential.js +28 -15
  61. package/dist/cjs/shared/utils/errorUtils.js +1 -1
  62. package/dist/cjs/shared/utils/networkUtils.js +1 -1
  63. package/dist/cjs/shared/utils/themeUtils.js +1 -1
  64. package/dist/cjs/utils/accountCacheSweep.js +3 -1
  65. package/dist/cjs/utils/accountUtils.js +1 -3
  66. package/dist/cjs/utils/asyncUtils.js +1 -1
  67. package/dist/cjs/utils/authHelpers.js +2 -1
  68. package/dist/cjs/utils/avatarUtils.js +4 -2
  69. package/dist/cjs/utils/cache.js +1 -1
  70. package/dist/cjs/utils/cacheKey.js +3 -1
  71. package/dist/cjs/utils/deviceManager.js +4 -4
  72. package/dist/cjs/utils/errorUtils.js +6 -4
  73. package/dist/cjs/utils/languageUtils.js +404 -57
  74. package/dist/cjs/utils/profileLinks.js +1 -3
  75. package/dist/cjs/utils/requestUtils.js +7 -1
  76. package/dist/cjs/utils/userIdentity.js +1 -1
  77. package/dist/cjs/utils/validationUtils.js +5 -6
  78. package/dist/esm/HttpService.js +64 -20
  79. package/dist/esm/api/accounts.js +11 -4
  80. package/dist/esm/api/agency.js +3 -1
  81. package/dist/esm/api/apps.js +15 -4
  82. package/dist/esm/api/assets.js +49 -12
  83. package/dist/esm/api/auth.js +37 -11
  84. package/dist/esm/api/billing.js +25 -8
  85. package/dist/esm/api/civic.js +14 -4
  86. package/dist/esm/api/follows.js +9 -2
  87. package/dist/esm/api/identity.js +31 -9
  88. package/dist/esm/api/nodes.js +3 -1
  89. package/dist/esm/api/privacy.js +8 -2
  90. package/dist/esm/api/session.js +15 -4
  91. package/dist/esm/api/store.js +15 -5
  92. package/dist/esm/api/topics.js +10 -3
  93. package/dist/esm/api/users.js +16 -4
  94. package/dist/esm/boot/sessionColdBoot.js +41 -14
  95. package/dist/esm/constants/version.js +6 -6
  96. package/dist/esm/crypto/identityMarker.js +3 -1
  97. package/dist/esm/crypto/identityProof.js +6 -1
  98. package/dist/esm/crypto/internal.js +1 -1
  99. package/dist/esm/crypto/keyManager.js +87 -32
  100. package/dist/esm/crypto/recoveryPhrase.js +2 -2
  101. package/dist/esm/crypto/signatureService.js +3 -4
  102. package/dist/esm/i18n/index.js +16 -3
  103. package/dist/esm/i18n/locales/ar-SA.js +366 -366
  104. package/dist/esm/i18n/locales/ca-ES.js +366 -366
  105. package/dist/esm/i18n/locales/de-DE.js +366 -366
  106. package/dist/esm/i18n/locales/en-US.js +1994 -1994
  107. package/dist/esm/i18n/locales/es-ES.js +1994 -1994
  108. package/dist/esm/i18n/locales/fr-FR.js +366 -366
  109. package/dist/esm/i18n/locales/it-IT.js +366 -366
  110. package/dist/esm/i18n/locales/ja-JP.js +366 -366
  111. package/dist/esm/i18n/locales/ko-KR.js +366 -366
  112. package/dist/esm/i18n/locales/pt-PT.js +366 -366
  113. package/dist/esm/i18n/locales/zh-CN.js +366 -366
  114. package/dist/esm/index.js +1 -1
  115. package/dist/esm/inference/OxyInferenceClient.js +13 -19
  116. package/dist/esm/models/interfaces.js +11 -11
  117. package/dist/esm/server/OxyServer.js +87 -29
  118. package/dist/esm/server/agentAccount.js +6 -2
  119. package/dist/esm/server/aliaMachineCredential.js +39 -14
  120. package/dist/esm/server/auth.js +6 -5
  121. package/dist/esm/server/capabilityTicket.js +6 -6
  122. package/dist/esm/server/index.js +5 -5
  123. package/dist/esm/server/liveCapabilityTicket.js +6 -3
  124. package/dist/esm/server/middleware.js +62 -43
  125. package/dist/esm/server/namespaces.js +31 -10
  126. package/dist/esm/server/requesterAssertion.js +36 -30
  127. package/dist/esm/server/serviceTokenLifetime.js +7 -4
  128. package/dist/esm/server/traffic.js +55 -16
  129. package/dist/esm/server/trafficNodeHttp.js +34 -9
  130. package/dist/esm/server/userInvalidation.js +1 -1
  131. package/dist/esm/server/workloadIdentity.client.js +3 -0
  132. package/dist/esm/server/workloadIdentity.js +27 -1
  133. package/dist/esm/session/SessionClient.js +54 -17
  134. package/dist/esm/session/accountDelegationAccess.js +5 -7
  135. package/dist/esm/session/accountDialogController.js +1 -1
  136. package/dist/esm/session/authStateStore.js +18 -9
  137. package/dist/esm/session/identityPin.js +6 -2
  138. package/dist/esm/session/refresh.js +82 -24
  139. package/dist/esm/session/sharedDeviceCredential.js +28 -15
  140. package/dist/esm/shared/utils/errorUtils.js +1 -1
  141. package/dist/esm/shared/utils/networkUtils.js +1 -1
  142. package/dist/esm/shared/utils/themeUtils.js +1 -1
  143. package/dist/esm/utils/accountCacheSweep.js +3 -1
  144. package/dist/esm/utils/accountUtils.js +1 -3
  145. package/dist/esm/utils/asyncUtils.js +1 -1
  146. package/dist/esm/utils/authHelpers.js +2 -1
  147. package/dist/esm/utils/avatarUtils.js +4 -2
  148. package/dist/esm/utils/cache.js +1 -1
  149. package/dist/esm/utils/cacheKey.js +3 -1
  150. package/dist/esm/utils/deviceManager.js +4 -4
  151. package/dist/esm/utils/errorUtils.js +6 -4
  152. package/dist/esm/utils/languageUtils.js +404 -57
  153. package/dist/esm/utils/profileLinks.js +1 -3
  154. package/dist/esm/utils/requestUtils.js +7 -1
  155. package/dist/esm/utils/userIdentity.js +1 -1
  156. package/dist/esm/utils/validationUtils.js +5 -6
  157. package/dist/types/HttpService.d.ts +1 -1
  158. package/dist/types/api/accounts.d.ts +1 -1
  159. package/dist/types/api/apps.d.ts +4 -4
  160. package/dist/types/api/assets.d.ts +2 -0
  161. package/dist/types/api/auth.d.ts +8 -3
  162. package/dist/types/crypto/internal.d.ts +1 -1
  163. package/dist/types/index.d.ts +4 -4
  164. package/dist/types/server/index.d.ts +6 -6
  165. package/dist/types/server/requesterAssertion.d.ts +2 -2
  166. package/dist/types/server/workloadIdentity.client.d.ts +5 -1
  167. package/dist/types/server/workloadIdentity.d.ts +26 -0
  168. package/dist/types/session/accountDelegationAccess.d.ts +1 -1
  169. package/dist/types/session/index.d.ts +1 -1
  170. package/dist/types/utils/userIdentity.d.ts +1 -1
  171. package/dist/types/utils/validationUtils.d.ts +4 -5
  172. package/package.json +2 -3
  173. package/src/HttpService.ts +183 -53
  174. package/src/OxyServices.errors.ts +7 -3
  175. package/src/OxyServices.ts +6 -2
  176. package/src/api/accounts.ts +76 -26
  177. package/src/api/agency.ts +24 -9
  178. package/src/api/appData.ts +12 -2
  179. package/src/api/apps.ts +81 -31
  180. package/src/api/assets.ts +122 -40
  181. package/src/api/auth.ts +154 -79
  182. package/src/api/billing.ts +112 -65
  183. package/src/api/civic.ts +61 -19
  184. package/src/api/contacts.ts +4 -1
  185. package/src/api/devices.ts +54 -21
  186. package/src/api/follows.ts +88 -31
  187. package/src/api/identity.ts +101 -33
  188. package/src/api/linkedAccounts.ts +26 -8
  189. package/src/api/nodes.ts +18 -6
  190. package/src/api/notifications.ts +26 -6
  191. package/src/api/privacy.ts +42 -8
  192. package/src/api/reputation.ts +18 -7
  193. package/src/api/session.ts +23 -5
  194. package/src/api/store.ts +81 -31
  195. package/src/api/topics.ts +18 -6
  196. package/src/api/users.ts +98 -35
  197. package/src/boot/sessionColdBoot.ts +60 -19
  198. package/src/civic/payloads.ts +1 -4
  199. package/src/client/context.ts +6 -1
  200. package/src/constants/version.ts +7 -6
  201. package/src/crypto/aead.ts +1 -5
  202. package/src/crypto/ecdh.ts +1 -4
  203. package/src/crypto/identityDerivations.ts +5 -1
  204. package/src/crypto/identityMarker.ts +3 -1
  205. package/src/crypto/identityProof.ts +6 -1
  206. package/src/crypto/index.ts +11 -11
  207. package/src/crypto/internal.ts +6 -1
  208. package/src/crypto/keyManager.ts +348 -98
  209. package/src/crypto/recoveryPhrase.ts +14 -9
  210. package/src/crypto/registrationPow.ts +1 -1
  211. package/src/crypto/signatureService.ts +14 -6
  212. package/src/i18n/accountCategoryLabels.ts +1 -4
  213. package/src/i18n/accountRoleLabels.ts +1 -4
  214. package/src/i18n/index.ts +25 -7
  215. package/src/i18n/locales/ar-SA.ts +375 -366
  216. package/src/i18n/locales/ca-ES.ts +382 -366
  217. package/src/i18n/locales/de-DE.ts +387 -366
  218. package/src/i18n/locales/en-US.ts +2034 -1994
  219. package/src/i18n/locales/es-ES.ts +2043 -1994
  220. package/src/i18n/locales/fr-FR.ts +387 -366
  221. package/src/i18n/locales/it-IT.ts +380 -366
  222. package/src/i18n/locales/ja-JP.ts +380 -366
  223. package/src/i18n/locales/ko-KR.ts +377 -366
  224. package/src/i18n/locales/pt-PT.ts +383 -366
  225. package/src/i18n/locales/zh-CN.ts +373 -366
  226. package/src/i18n/trustTierLabels.ts +1 -4
  227. package/src/index.ts +371 -349
  228. package/src/inference/OxyInferenceClient.ts +784 -780
  229. package/src/models/interfaces.ts +30 -27
  230. package/src/server/OxyServer.ts +227 -68
  231. package/src/server/agentAccount.ts +8 -2
  232. package/src/server/aliaMachineCredential.ts +57 -16
  233. package/src/server/auth.ts +9 -5
  234. package/src/server/capabilityTicket.ts +30 -21
  235. package/src/server/index.ts +29 -6
  236. package/src/server/liveCapabilityTicket.ts +31 -9
  237. package/src/server/middleware.ts +212 -121
  238. package/src/server/namespaces.ts +247 -94
  239. package/src/server/rateLimit.ts +2 -4
  240. package/src/server/requesterAssertion.ts +93 -54
  241. package/src/server/serviceTokenLifetime.ts +9 -4
  242. package/src/server/traffic.ts +117 -23
  243. package/src/server/trafficNodeHttp.ts +61 -14
  244. package/src/server/userInvalidation.ts +1 -4
  245. package/src/server/workloadIdentity.client.ts +12 -1
  246. package/src/server/workloadIdentity.ts +52 -5
  247. package/src/session/SessionClient.ts +170 -49
  248. package/src/session/accountDelegationAccess.ts +24 -31
  249. package/src/session/accountDialogController.ts +59 -14
  250. package/src/session/accountSwitchTargets.ts +10 -15
  251. package/src/session/authStateStore.ts +121 -81
  252. package/src/session/deviceDirectory.ts +1 -3
  253. package/src/session/identityPin.ts +10 -11
  254. package/src/session/identitySession.ts +3 -1
  255. package/src/session/index.ts +87 -82
  256. package/src/session/refresh.ts +138 -44
  257. package/src/session/sessionClientHost.ts +1 -3
  258. package/src/session/sharedDeviceCredential.ts +35 -14
  259. package/src/session/socketLoader.ts +9 -2
  260. package/src/shared/utils/errorUtils.ts +5 -2
  261. package/src/shared/utils/networkUtils.ts +5 -8
  262. package/src/shared/utils/themeUtils.ts +2 -6
  263. package/src/types/buffer.d.ts +66 -21
  264. package/src/types/expo-secure-store.d.ts +5 -1
  265. package/src/utils/accountCacheSweep.ts +4 -5
  266. package/src/utils/accountUtils.ts +107 -108
  267. package/src/utils/apiUtils.ts +3 -3
  268. package/src/utils/asyncUtils.ts +2 -2
  269. package/src/utils/authHelpers.ts +10 -5
  270. package/src/utils/avatarUtils.ts +11 -6
  271. package/src/utils/cache.ts +9 -10
  272. package/src/utils/cacheKey.ts +5 -1
  273. package/src/utils/coldBoot.ts +1 -3
  274. package/src/utils/commonsDelivery.ts +1 -4
  275. package/src/utils/deviceManager.ts +15 -14
  276. package/src/utils/errorUtils.ts +68 -86
  277. package/src/utils/languageUtils.ts +407 -58
  278. package/src/utils/oauthPkce.ts +1 -4
  279. package/src/utils/platform.ts +0 -1
  280. package/src/utils/profileLinks.ts +2 -5
  281. package/src/utils/requestUtils.ts +18 -14
  282. package/src/utils/sessionUtils.ts +34 -33
  283. package/src/utils/userHandle.ts +3 -1
  284. package/src/utils/userIdentity.ts +1 -1
  285. package/src/utils/validationUtils.ts +11 -9
@@ -127,7 +127,9 @@ class CivicApi {
127
127
  ...(input.geohash !== undefined ? { geohash: input.geohash } : {}),
128
128
  ...(input.biometricOk !== undefined ? { biometricOk: input.biometricOk } : {}),
129
129
  }, { collection: ATTEST_COLLECTION, rkey: input.nonce });
130
- return this.ctx.request('POST', '/civic/attestations', envelope, { cache: false });
130
+ return this.ctx.request('POST', '/civic/attestations', envelope, {
131
+ cache: false,
132
+ });
131
133
  }
132
134
  /**
133
135
  * Vouch that another user is a real person as the VOUCHER (B): sign a
@@ -225,7 +227,9 @@ class CivicCredentialsApi {
225
227
  * base type; an `expiresAt` ISO string becomes epoch ms. NATIVE-ONLY.
226
228
  */
227
229
  async issue(input) {
228
- const types = input.types.includes(CREDENTIAL_BASE_TYPE) ? input.types : [CREDENTIAL_BASE_TYPE, ...input.types];
230
+ const types = input.types.includes(CREDENTIAL_BASE_TYPE)
231
+ ? input.types
232
+ : [CREDENTIAL_BASE_TYPE, ...input.types];
229
233
  let expiresAtMs;
230
234
  if (input.expiresAt !== undefined) {
231
235
  const parsed = Date.parse(input.expiresAt);
@@ -243,7 +247,10 @@ class CivicCredentialsApi {
243
247
  // A fresh crypto-random rkey: every credential is its own chain entry.
244
248
  const { SignatureService } = await Promise.resolve().then(() => __importStar(require('../crypto/internal')));
245
249
  const rkey = await SignatureService.generateChallenge();
246
- const envelope = await (0, identity_1.signOwnChainRecord)(this.ctx, 'credential', record, { collection: CREDENTIAL_COLLECTION, rkey });
250
+ const envelope = await (0, identity_1.signOwnChainRecord)(this.ctx, 'credential', record, {
251
+ collection: CREDENTIAL_COLLECTION,
252
+ rkey,
253
+ });
247
254
  const result = await this.ctx.request('POST', '/civic/credentials', envelope, { cache: false });
248
255
  this.sweep();
249
256
  return result;
@@ -261,7 +268,10 @@ class CivicCredentialsApi {
261
268
  }
262
269
  const base = `/civic/credentials/${encodeURIComponent(holder)}`;
263
270
  const url = opts.status ? `${base}?status=${encodeURIComponent(opts.status)}` : base;
264
- return this.ctx.request('GET', url, undefined, { cache: true, cacheTTL: SHORT_TTL });
271
+ return this.ctx.request('GET', url, undefined, {
272
+ cache: true,
273
+ cacheTTL: SHORT_TTL,
274
+ });
265
275
  }
266
276
  /**
267
277
  * Verify a credential by its signed-record id: the server re-checks the
@@ -44,7 +44,10 @@ class FollowsApi {
44
44
  }
45
45
  /** Whether the signed-in user follows `userId`. Cached 1 minute, busted by every write. */
46
46
  async status(userId) {
47
- return this.ctx.request('GET', `/users/${userId}/follow-status`, undefined, { cache: true, cacheTTL: STATUS_TTL });
47
+ return this.ctx.request('GET', `/users/${userId}/follow-status`, undefined, {
48
+ cache: true,
49
+ cacheTTL: STATUS_TTL,
50
+ });
48
51
  }
49
52
  /**
50
53
  * Follow status for MANY users, one round-trip per chunk of 200 — for list
@@ -211,7 +214,11 @@ class FollowsApi {
211
214
  // ── Internals ────────────────────────────────────────────────────────────
212
215
  async userPage(path, params) {
213
216
  const response = await this.ctx.request('GET', path, (0, apiUtils_1.buildQueryParams)(params ?? {}), { cache: true, cacheTTL: GRAPH_TTL });
214
- return { data: response.data || [], total: response.pagination.total, hasMore: response.pagination.hasMore };
217
+ return {
218
+ data: response.data || [],
219
+ total: response.pagination.total,
220
+ hasMore: response.pagination.hasMore,
221
+ };
215
222
  }
216
223
  /**
217
224
  * Every cached read a follow write makes stale, in ONE pass over the cache.
@@ -131,14 +131,19 @@ class IdentityApi {
131
131
  * verification-method fragment.
132
132
  */
133
133
  async authMethods() {
134
- return this.ctx.request('GET', '/auth/methods', undefined, { cache: true, cacheTTL: SHORT_TTL });
134
+ return this.ctx.request('GET', '/auth/methods', undefined, {
135
+ cache: true,
136
+ cacheTTL: SHORT_TTL,
137
+ });
135
138
  }
136
139
  /**
137
140
  * How the signed-in account is kept (ADR 0029 D3): whether Commons' root is
138
141
  * linked (self-custody), or the email of an account without a key.
139
142
  */
140
143
  async rootStatus() {
141
- return this.ctx.request('GET', '/identity/root-status', undefined, { cache: false });
144
+ return this.ctx.request('GET', '/identity/root-status', undefined, {
145
+ cache: false,
146
+ });
142
147
  }
143
148
  /**
144
149
  * Rotate the account's identity key: derive a brand-new keypair, prove
@@ -313,7 +318,9 @@ class IdentityApi {
313
318
  */
314
319
  async rotationAlreadyApplied(userId, newPublicKey) {
315
320
  return this.ctx
316
- .request('GET', `/u/${encodeURIComponent(userId)}/did.json`, undefined, { cache: false })
321
+ .request('GET', `/u/${encodeURIComponent(userId)}/did.json`, undefined, {
322
+ cache: false,
323
+ })
317
324
  .then((doc) => doc.verificationMethod.some((vm) => 'publicKeyHex' in vm &&
318
325
  typeof vm.publicKeyHex === 'string' &&
319
326
  vm.publicKeyHex.toLowerCase() === newPublicKey.toLowerCase()))
@@ -343,7 +350,9 @@ class IdentityLinksApi {
343
350
  * The "Link Commons" panel shows its `qrPayload`; Commons scans it and signs with `sign`.
344
351
  */
345
352
  async create() {
346
- const res = await this.ctx.request('POST', '/identity/link', undefined, { cache: false });
353
+ const res = await this.ctx.request('POST', '/identity/link', undefined, {
354
+ cache: false,
355
+ });
347
356
  const parsed = (0, contracts_1.safeParseContract)(contracts_1.identityLinkCreateResponseSchema, res);
348
357
  if (!parsed)
349
358
  throw new Error('identity/link returned an unexpected response shape');
@@ -367,7 +376,10 @@ class IdentityLinksApi {
367
376
  */
368
377
  async sign(linkId, challenge) {
369
378
  const { KeyManager, signIdentityProof, deriveIdentityLinkCode } = await Promise.resolve().then(() => __importStar(require('../crypto/internal')));
370
- const [privateKey, publicKey] = await Promise.all([KeyManager.getPrivateKey(), KeyManager.getPublicKey()]);
379
+ const [privateKey, publicKey] = await Promise.all([
380
+ KeyManager.getPrivateKey(),
381
+ KeyManager.getPublicKey(),
382
+ ]);
371
383
  if (!privateKey || !publicKey) {
372
384
  throw new Error('No identity on this device to link');
373
385
  }
@@ -385,7 +397,11 @@ class IdentityLinksApi {
385
397
  expiresAt: state.expiresAt,
386
398
  });
387
399
  await this.ctx.request('POST', `/identity/link/${encodeURIComponent(linkId)}/proof`, { publicKey: root, proof }, { cache: false, skipAuth: true });
388
- return { publicKey: root, code: deriveIdentityLinkCode(linkId, root), username: state.username };
400
+ return {
401
+ publicKey: root,
402
+ code: deriveIdentityLinkCode(linkId, root),
403
+ username: state.username,
404
+ };
389
405
  }
390
406
  /**
391
407
  * Complete a link with a code just sent to the account's email
@@ -527,18 +543,24 @@ class IdentityBackupApi {
527
543
  createdAt,
528
544
  lookupId,
529
545
  };
530
- return this.ctx.request('POST', '/identity/backup', body, { cache: false });
546
+ return this.ctx.request('POST', '/identity/backup', body, {
547
+ cache: false,
548
+ });
531
549
  }
532
550
  /**
533
551
  * Whether the signed-in user has a stored backup, plus its non-sensitive hint
534
552
  * and timestamp. Returns no ciphertext and no locator.
535
553
  */
536
554
  async status() {
537
- return this.ctx.request('GET', '/identity/backup/status', undefined, { cache: false });
555
+ return this.ctx.request('GET', '/identity/backup/status', undefined, {
556
+ cache: false,
557
+ });
538
558
  }
539
559
  /** Delete the signed-in user's stored backup. Idempotent. */
540
560
  async delete() {
541
- return this.ctx.request('DELETE', '/identity/backup', undefined, { cache: false });
561
+ return this.ctx.request('DELETE', '/identity/backup', undefined, {
562
+ cache: false,
563
+ });
542
564
  }
543
565
  /**
544
566
  * Restore an identity from its encrypted backup using ONLY the recovery
@@ -48,7 +48,9 @@ class NodesApi {
48
48
  }
49
49
  /** Revoke the signed-in user's node registration. */
50
50
  async removeMine() {
51
- const res = await this.ctx.request('DELETE', '/nodes/me', undefined, { cache: false });
51
+ const res = await this.ctx.request('DELETE', '/nodes/me', undefined, {
52
+ cache: false,
53
+ });
52
54
  this.sweep();
53
55
  return { revoked: res.success === true };
54
56
  }
@@ -30,7 +30,10 @@ class PrivacyApi {
30
30
  // ── Blocked ──────────────────────────────────────────────────────────────
31
31
  /** The signed-in user's blocked users. */
32
32
  async blocked() {
33
- return this.ctx.request('GET', '/privacy/blocked', undefined, { cache: true, cacheTTL: LIST_TTL });
33
+ return this.ctx.request('GET', '/privacy/blocked', undefined, {
34
+ cache: true,
35
+ cacheTTL: LIST_TTL,
36
+ });
34
37
  }
35
38
  /** Block a user. */
36
39
  async block(userId) {
@@ -60,7 +63,10 @@ class PrivacyApi {
60
63
  // ── Restricted ───────────────────────────────────────────────────────────
61
64
  /** The signed-in user's restricted users. */
62
65
  async restricted() {
63
- return this.ctx.request('GET', '/privacy/restricted', undefined, { cache: true, cacheTTL: LIST_TTL });
66
+ return this.ctx.request('GET', '/privacy/restricted', undefined, {
67
+ cache: true,
68
+ cacheTTL: LIST_TTL,
69
+ });
64
70
  }
65
71
  /** Restrict a user: limit their interactions without blocking them. */
66
72
  async restrict(userId) {
@@ -107,7 +107,11 @@ class SessionApi {
107
107
  return null;
108
108
  try {
109
109
  const proof = await provider();
110
- if (proof && typeof proof.deviceId === 'string' && proof.deviceId && typeof proof.deviceSecret === 'string' && proof.deviceSecret) {
110
+ if (proof &&
111
+ typeof proof.deviceId === 'string' &&
112
+ proof.deviceId &&
113
+ typeof proof.deviceSecret === 'string' &&
114
+ proof.deviceSecret) {
111
115
  return { deviceId: proof.deviceId, deviceSecret: proof.deviceSecret };
112
116
  }
113
117
  return null;
@@ -122,7 +126,10 @@ class SessionApi {
122
126
  if (!this.isAuthenticated)
123
127
  return false;
124
128
  try {
125
- const res = await this.ctx.request('GET', '/auth/validate', undefined, { cache: false, retry: false });
129
+ const res = await this.ctx.request('GET', '/auth/validate', undefined, {
130
+ cache: false,
131
+ retry: false,
132
+ });
126
133
  return res.valid === true;
127
134
  }
128
135
  catch {
@@ -148,11 +155,15 @@ class SessionApi {
148
155
  }
149
156
  /** The sessions that belong with `sessionId` (same account set). */
150
157
  async list(sessionId) {
151
- return this.ctx.request('GET', `/session/sessions/${sessionId}`, undefined, { cache: false });
158
+ return this.ctx.request('GET', `/session/sessions/${sessionId}`, undefined, {
159
+ cache: false,
160
+ });
152
161
  }
153
162
  /** Sign out `sessionId`, or — with `targetSessionId` — one of the sessions beside it. */
154
163
  async logout(sessionId, targetSessionId) {
155
- const url = targetSessionId ? `/session/logout/${sessionId}/${targetSessionId}` : `/session/logout/${sessionId}`;
164
+ const url = targetSessionId
165
+ ? `/session/logout/${sessionId}/${targetSessionId}`
166
+ : `/session/logout/${sessionId}`;
156
167
  await this.ctx.request('POST', url, undefined, { cache: false });
157
168
  }
158
169
  /** Sign out every session beside `sessionId`, and it. */
@@ -53,7 +53,9 @@ class StoreReviewsApi {
53
53
  * hidden when its author edits it.
54
54
  */
55
55
  async write(slug, input) {
56
- const res = await this.ctx.request('PUT', reviewPath(slug), input, { cache: false });
56
+ const res = await this.ctx.request('PUT', reviewPath(slug), input, {
57
+ cache: false,
58
+ });
57
59
  return res.data;
58
60
  }
59
61
  /** Withdraw the caller's own review. A real delete — the words were theirs. */
@@ -69,7 +71,9 @@ class ListingScreenshotsApi {
69
71
  }
70
72
  /** Every picture on the listing, in the author's order. */
71
73
  async list(applicationId) {
72
- return this.ctx.request('GET', screenshotsPath(applicationId), undefined, { cache: false });
74
+ return this.ctx.request('GET', screenshotsPath(applicationId), undefined, {
75
+ cache: false,
76
+ });
73
77
  }
74
78
  /**
75
79
  * Attach an already-uploaded image, appended to the end.
@@ -79,7 +83,9 @@ class ListingScreenshotsApi {
79
83
  * one the caller is entitled to.
80
84
  */
81
85
  async add(applicationId, input) {
82
- return this.ctx.request('POST', screenshotsPath(applicationId), input, { cache: false });
86
+ return this.ctx.request('POST', screenshotsPath(applicationId), input, {
87
+ cache: false,
88
+ });
83
89
  }
84
90
  /** Edit a picture's caption or the frame it was taken in. Order is `reorder`. */
85
91
  async update(applicationId, screenshotId, input) {
@@ -113,7 +119,9 @@ class StoreListingApi {
113
119
  }
114
120
  /** The application's store page in whatever state, or `null` if it has none. */
115
121
  async get(applicationId) {
116
- return this.ctx.request('GET', listingPath(applicationId), undefined, { cache: false });
122
+ return this.ctx.request('GET', listingPath(applicationId), undefined, {
123
+ cache: false,
124
+ });
117
125
  }
118
126
  /**
119
127
  * Create the page or replace its content. Never its status.
@@ -122,7 +130,9 @@ class StoreListingApi {
122
130
  * it live, and fixing a rejected one does not re-submit it.
123
131
  */
124
132
  async write(applicationId, input) {
125
- return this.ctx.request('PUT', listingPath(applicationId), input, { cache: false });
133
+ return this.ctx.request('PUT', listingPath(applicationId), input, {
134
+ cache: false,
135
+ });
126
136
  }
127
137
  /** Hand the page to the store for review. From a draft, or a rejected page once fixed. */
128
138
  async submit(applicationId) {
@@ -37,12 +37,17 @@ class TopicsApi {
37
37
  const params = { q: query };
38
38
  if (limit)
39
39
  params.limit = limit;
40
- const res = await this.ctx.request('GET', '/topics/search', params, { cache: false });
40
+ const res = await this.ctx.request('GET', '/topics/search', params, {
41
+ cache: false,
42
+ });
41
43
  return res.topics ?? [];
42
44
  }
43
45
  /** One topic by slug. */
44
46
  async get(slug) {
45
- return this.ctx.request('GET', `/topics/${slug}`, undefined, { cache: true, cacheTTL: LONG });
47
+ return this.ctx.request('GET', `/topics/${slug}`, undefined, {
48
+ cache: true,
49
+ cacheTTL: LONG,
50
+ });
46
51
  }
47
52
  /** The top-level categories, optionally translated. */
48
53
  async categories(locale) {
@@ -58,7 +63,9 @@ class TopicsApi {
58
63
  }
59
64
  /** Update a topic's description and translations. Staff or service only. */
60
65
  async update(slug, data) {
61
- const topic = await this.ctx.request('PATCH', `/topics/${slug}`, data, { cache: false });
66
+ const topic = await this.ctx.request('PATCH', `/topics/${slug}`, data, {
67
+ cache: false,
68
+ });
62
69
  this.ctx.oxy.cache.delete(`GET:/topics/${slug}`);
63
70
  return topic;
64
71
  }
@@ -110,7 +110,10 @@ class UsersApi {
110
110
  }
111
111
  /** The signed-in user. Cached 1 minute. */
112
112
  async me(options) {
113
- const user = await this.ctx.request('GET', '/users/me', undefined, { cache: options?.cache ?? true, cacheTTL: ME_TTL });
113
+ const user = await this.ctx.request('GET', '/users/me', undefined, {
114
+ cache: options?.cache ?? true,
115
+ cacheTTL: ME_TTL,
116
+ });
114
117
  return (0, userIdentity_1.normalizeUserIdentity)(user);
115
118
  }
116
119
  /** A profile by username. Cached 5 minutes; `{ cache: false }` as in `get`. */
@@ -183,7 +186,9 @@ class UsersApi {
183
186
  // A 404 (absent) and an upstream failure both return null; the log keeps
184
187
  // them distinguishable without turning expected misses into noise.
185
188
  const status = (0, errorUtils_1.extractErrorStatus)(error);
186
- logger_1.logger.debug(status === 404 ? 'users.resolveHandle: handle not found' : 'users.resolveHandle: discovery failed', {
189
+ logger_1.logger.debug(status === 404
190
+ ? 'users.resolveHandle: handle not found'
191
+ : 'users.resolveHandle: discovery failed', {
187
192
  method: 'users.resolveHandle',
188
193
  handle,
189
194
  status,
@@ -203,7 +208,9 @@ class UsersApi {
203
208
  }
204
209
  /** Profiles similar to `userId`, by co-follower overlap. Cached 5 minutes. */
205
210
  async similar(userId, limitOrPagination) {
206
- const pagination = typeof limitOrPagination === 'number' ? { limit: limitOrPagination } : limitOrPagination ?? {};
211
+ const pagination = typeof limitOrPagination === 'number'
212
+ ? { limit: limitOrPagination }
213
+ : (limitOrPagination ?? {});
207
214
  const users = await this.ctx.request('GET', `/profiles/${userId}/similar`, (0, apiUtils_1.buildQueryParams)(pagination), {
208
215
  cache: true,
209
216
  cacheTTL: PROFILE_TTL,
@@ -303,7 +310,12 @@ class UsersApi {
303
310
  }
304
311
  const timestamp = Date.now();
305
312
  const signature = await SignatureService.sign(`delete:${publicKey}:${timestamp}`);
306
- return this.ctx.request('DELETE', '/users/me', { signature, timestamp, confirmText, ...(proof.totpCode ? { totpCode: proof.totpCode } : {}) }, { cache: false });
313
+ return this.ctx.request('DELETE', '/users/me', {
314
+ signature,
315
+ timestamp,
316
+ confirmText,
317
+ ...(proof.totpCode ? { totpCode: proof.totpCode } : {}),
318
+ }, { cache: false });
307
319
  }
308
320
  }
309
321
  exports.UsersApi = UsersApi;
@@ -59,7 +59,7 @@ async function runSessionColdBoot(opts) {
59
59
  const isNative = opts.platform?.isNative ?? (0, platform_1.isNative)();
60
60
  // Non-null ONLY in identity mode; every `!== null` test below therefore reads
61
61
  // as "is this boot identity-bound?" while also narrowing the binding.
62
- const identityBinding = opts.sessionMode === 'identity' ? opts.identity ?? null : null;
62
+ const identityBinding = opts.sessionMode === 'identity' ? (opts.identity ?? null) : null;
63
63
  if (opts.sessionMode === 'identity' && identityBinding === null) {
64
64
  logger_1.logger.error('runSessionColdBoot: sessionMode "identity" requires an `identity` binding — refusing to run any lane (an identity-bound client must never adopt the device active account)', undefined, { component: 'sessionColdBoot', method: 'runSessionColdBoot' });
65
65
  await opts.onSignedOut?.('error');
@@ -105,10 +105,15 @@ async function runSessionColdBoot(opts) {
105
105
  steps.push({
106
106
  id: 'warm-token-plant',
107
107
  run: async () => {
108
- if (identityBinding === null && isNative && await store.isAutomaticIdentitySignInSuppressed?.())
108
+ if (identityBinding === null &&
109
+ isNative &&
110
+ (await store.isAutomaticIdentitySignInSuppressed?.()))
109
111
  return { kind: 'skip' };
110
112
  const persisted = await store.load();
111
- if (!persisted?.accessToken || !persisted.sessionId || !persisted.userId || !persisted.expiresAt) {
113
+ if (!persisted?.accessToken ||
114
+ !persisted.sessionId ||
115
+ !persisted.userId ||
116
+ !persisted.expiresAt) {
112
117
  return { kind: 'skip' };
113
118
  }
114
119
  // Guard a malformed `expiresAt` (Date.parse -> NaN): treat as not-valid and
@@ -179,7 +184,9 @@ async function runSessionColdBoot(opts) {
179
184
  },
180
185
  };
181
186
  case 'invalid-secret': {
182
- if (identityBinding === null && store.setAutomaticIdentitySignInSuppressed && await store.isAutomaticIdentitySignInSuppressed?.()) {
187
+ if (identityBinding === null &&
188
+ store.setAutomaticIdentitySignInSuppressed &&
189
+ (await store.isAutomaticIdentitySignInSuppressed?.())) {
183
190
  rejectedLocalHolder = true;
184
191
  signedOutReason = 'no_session';
185
192
  return { kind: 'skip' };
@@ -214,7 +221,10 @@ async function runSessionColdBoot(opts) {
214
221
  return { kind: 'skip' };
215
222
  case 'transient':
216
223
  // Network / 5xx: keep the secret; a later attempt can succeed.
217
- logger_1.logger.debug('device-secret mint failed (transient) — keeping secret', { component: 'sessionColdBoot', method: 'device-secret-mint' });
224
+ logger_1.logger.debug('device-secret mint failed (transient) — keeping secret', {
225
+ component: 'sessionColdBoot',
226
+ method: 'device-secret-mint',
227
+ });
218
228
  return { kind: 'skip' };
219
229
  case 'session-ended':
220
230
  // The prior holder/epoch was superseded. This boot must not turn a
@@ -287,11 +297,22 @@ async function runSessionColdBoot(opts) {
287
297
  // like every other network step.
288
298
  enabled: () => isNative && !isOffline() && !accountRecoverySuperseded,
289
299
  run: async () => {
290
- const result = await (0, refresh_1.refreshSharedDeviceArm)({ oxy, store, shared: sharedSlot, rejectedLocalHolder });
300
+ const result = await (0, refresh_1.refreshSharedDeviceArm)({
301
+ oxy,
302
+ store,
303
+ shared: sharedSlot,
304
+ rejectedLocalHolder,
305
+ });
291
306
  if (result.status === 'ok') {
292
- return { kind: 'session', session: {
293
- sessionId: result.sessionId, userId: result.userId, accessToken: result.token, state: result.state,
294
- } };
307
+ return {
308
+ kind: 'session',
309
+ session: {
310
+ sessionId: result.sessionId,
311
+ userId: result.userId,
312
+ accessToken: result.token,
313
+ state: result.state,
314
+ },
315
+ };
295
316
  }
296
317
  if (result.status === 'no-session')
297
318
  signedOutReason = 'no_session';
@@ -322,11 +343,16 @@ async function runSessionColdBoot(opts) {
322
343
  id: 'commons-proof-signin',
323
344
  enabled: () => isNative && !isOffline(),
324
345
  run: async () => {
325
- if (accountRecoverySuperseded || await store.isAutomaticIdentitySignInSuppressed?.())
346
+ if (accountRecoverySuperseded || (await store.isAutomaticIdentitySignInSuppressed?.()))
326
347
  return { kind: 'skip' };
327
348
  const epoch = oxy.http.getSessionEpoch();
328
- const session = await oxy.auth.signInWithCommonsIdentity({ plantTokens: false, requestOptions: { retry: false } });
329
- if (!session?.accessToken || oxy.http.getSessionEpoch() !== epoch || await store.isAutomaticIdentitySignInSuppressed?.()) {
349
+ const session = await oxy.auth.signInWithCommonsIdentity({
350
+ plantTokens: false,
351
+ requestOptions: { retry: false },
352
+ });
353
+ if (!session?.accessToken ||
354
+ oxy.http.getSessionEpoch() !== epoch ||
355
+ (await store.isAutomaticIdentitySignInSuppressed?.())) {
330
356
  return { kind: 'skip' };
331
357
  }
332
358
  // `verifyChallenge` issues a deviceSecret; persist it so the next
@@ -342,7 +368,8 @@ async function runSessionColdBoot(opts) {
342
368
  expiresAt: session.expiresAt,
343
369
  });
344
370
  }
345
- if (oxy.http.getSessionEpoch() !== epoch || await store.isAutomaticIdentitySignInSuppressed?.())
371
+ if (oxy.http.getSessionEpoch() !== epoch ||
372
+ (await store.isAutomaticIdentitySignInSuppressed?.()))
346
373
  return { kind: 'skip' };
347
374
  oxy.session.setAccessToken(session.accessToken);
348
375
  return {
@@ -6,11 +6,11 @@
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
7
  exports.description = exports.version = exports.name = exports.packageInfo = void 0;
8
8
  exports.packageInfo = {
9
- name: "@oxy.so/services",
10
- version: "5.2.1",
11
- description: "Reusable OxyHQ module to handle authentication, user management, reputation system (Oxy Trust) and more 🚀",
12
- main: "lib/commonjs/node/index.js",
13
- module: "lib/module/node/index.js",
14
- types: "lib/typescript/node/index.d.ts"
9
+ name: '@oxy.so/services',
10
+ version: '5.2.1',
11
+ description: 'Reusable OxyHQ module to handle authentication, user management, reputation system (Oxy Trust) and more 🚀',
12
+ main: 'lib/commonjs/node/index.js',
13
+ module: 'lib/module/node/index.js',
14
+ types: 'lib/typescript/node/index.d.ts',
15
15
  };
16
16
  exports.name = exports.packageInfo.name, exports.version = exports.packageInfo.version, exports.description = exports.packageInfo.description;
@@ -215,7 +215,9 @@ async function updateIdentityMarker(partial) {
215
215
  }
216
216
  return false;
217
217
  }
218
- const nextOnboarding = partial.onboardingComplete !== undefined ? partial.onboardingComplete : existing.onboardingComplete;
218
+ const nextOnboarding = partial.onboardingComplete !== undefined
219
+ ? partial.onboardingComplete
220
+ : existing.onboardingComplete;
219
221
  const next = {
220
222
  v: 1,
221
223
  publicKey: partial.publicKey ?? existing.publicKey,
@@ -24,5 +24,10 @@ async function signIdentityProof(identity, claims) {
24
24
  throw new Error('identity proof: the claims name a different root');
25
25
  }
26
26
  const signature = await (0, protocol_1.signMessage)((0, contracts_1.buildIdentityProofMessage)(claims), identity.privateKey);
27
- return { v: contracts_1.IDENTITY_PROOF_VERSION, challenge: claims.challenge, expiresAt: claims.expiresAt, signature };
27
+ return {
28
+ v: contracts_1.IDENTITY_PROOF_VERSION,
29
+ challenge: claims.challenge,
30
+ expiresAt: claims.expiresAt,
31
+ signature,
32
+ };
28
33
  }