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