@oxy.so/core 4.5.0-oxy-one.1 → 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 (282) 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 +1 -1
  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/server/index.d.ts +6 -6
  163. package/dist/types/server/workloadIdentity.client.d.ts +5 -1
  164. package/dist/types/server/workloadIdentity.d.ts +26 -0
  165. package/dist/types/session/accountDelegationAccess.d.ts +1 -1
  166. package/dist/types/session/index.d.ts +1 -1
  167. package/dist/types/utils/userIdentity.d.ts +1 -1
  168. package/dist/types/utils/validationUtils.d.ts +4 -5
  169. package/package.json +2 -3
  170. package/src/HttpService.ts +183 -53
  171. package/src/OxyServices.errors.ts +7 -3
  172. package/src/OxyServices.ts +6 -2
  173. package/src/api/accounts.ts +76 -26
  174. package/src/api/agency.ts +24 -9
  175. package/src/api/appData.ts +12 -2
  176. package/src/api/apps.ts +81 -31
  177. package/src/api/assets.ts +113 -43
  178. package/src/api/auth.ts +145 -77
  179. package/src/api/billing.ts +112 -65
  180. package/src/api/civic.ts +61 -19
  181. package/src/api/contacts.ts +4 -1
  182. package/src/api/devices.ts +54 -21
  183. package/src/api/follows.ts +88 -31
  184. package/src/api/identity.ts +101 -33
  185. package/src/api/linkedAccounts.ts +26 -8
  186. package/src/api/nodes.ts +18 -6
  187. package/src/api/notifications.ts +26 -6
  188. package/src/api/privacy.ts +42 -8
  189. package/src/api/reputation.ts +18 -7
  190. package/src/api/session.ts +23 -5
  191. package/src/api/store.ts +81 -31
  192. package/src/api/topics.ts +18 -6
  193. package/src/api/users.ts +98 -35
  194. package/src/boot/sessionColdBoot.ts +60 -19
  195. package/src/civic/payloads.ts +1 -4
  196. package/src/client/context.ts +6 -1
  197. package/src/constants/version.ts +7 -6
  198. package/src/crypto/aead.ts +1 -5
  199. package/src/crypto/ecdh.ts +1 -4
  200. package/src/crypto/identityDerivations.ts +5 -1
  201. package/src/crypto/identityMarker.ts +3 -1
  202. package/src/crypto/identityProof.ts +6 -1
  203. package/src/crypto/index.ts +11 -11
  204. package/src/crypto/internal.ts +6 -1
  205. package/src/crypto/keyManager.ts +348 -98
  206. package/src/crypto/recoveryPhrase.ts +14 -9
  207. package/src/crypto/registrationPow.ts +1 -1
  208. package/src/crypto/signatureService.ts +14 -6
  209. package/src/i18n/accountCategoryLabels.ts +1 -4
  210. package/src/i18n/accountRoleLabels.ts +1 -4
  211. package/src/i18n/index.ts +25 -7
  212. package/src/i18n/locales/ar-SA.ts +375 -366
  213. package/src/i18n/locales/ca-ES.ts +382 -366
  214. package/src/i18n/locales/de-DE.ts +387 -366
  215. package/src/i18n/locales/en-US.ts +2034 -1994
  216. package/src/i18n/locales/es-ES.ts +2043 -1994
  217. package/src/i18n/locales/fr-FR.ts +387 -366
  218. package/src/i18n/locales/it-IT.ts +380 -366
  219. package/src/i18n/locales/ja-JP.ts +380 -366
  220. package/src/i18n/locales/ko-KR.ts +377 -366
  221. package/src/i18n/locales/pt-PT.ts +383 -366
  222. package/src/i18n/locales/zh-CN.ts +373 -366
  223. package/src/i18n/trustTierLabels.ts +1 -4
  224. package/src/index.ts +371 -349
  225. package/src/inference/OxyInferenceClient.ts +784 -780
  226. package/src/models/interfaces.ts +30 -27
  227. package/src/server/OxyServer.ts +227 -68
  228. package/src/server/agentAccount.ts +8 -2
  229. package/src/server/aliaMachineCredential.ts +57 -16
  230. package/src/server/auth.ts +9 -5
  231. package/src/server/capabilityTicket.ts +30 -21
  232. package/src/server/index.ts +29 -6
  233. package/src/server/liveCapabilityTicket.ts +31 -9
  234. package/src/server/middleware.ts +212 -121
  235. package/src/server/namespaces.ts +247 -94
  236. package/src/server/rateLimit.ts +2 -4
  237. package/src/server/requesterAssertion.ts +93 -54
  238. package/src/server/serviceTokenLifetime.ts +9 -4
  239. package/src/server/traffic.ts +117 -23
  240. package/src/server/trafficNodeHttp.ts +61 -14
  241. package/src/server/userInvalidation.ts +1 -4
  242. package/src/server/workloadIdentity.client.ts +12 -1
  243. package/src/server/workloadIdentity.ts +52 -5
  244. package/src/session/SessionClient.ts +170 -49
  245. package/src/session/accountDelegationAccess.ts +24 -31
  246. package/src/session/accountDialogController.ts +59 -14
  247. package/src/session/accountSwitchTargets.ts +10 -15
  248. package/src/session/authStateStore.ts +121 -81
  249. package/src/session/deviceDirectory.ts +1 -3
  250. package/src/session/identityPin.ts +10 -11
  251. package/src/session/identitySession.ts +3 -1
  252. package/src/session/index.ts +87 -82
  253. package/src/session/refresh.ts +138 -44
  254. package/src/session/sessionClientHost.ts +1 -3
  255. package/src/session/sharedDeviceCredential.ts +35 -14
  256. package/src/session/socketLoader.ts +9 -2
  257. package/src/shared/utils/errorUtils.ts +5 -2
  258. package/src/shared/utils/networkUtils.ts +5 -8
  259. package/src/shared/utils/themeUtils.ts +2 -6
  260. package/src/types/buffer.d.ts +66 -21
  261. package/src/types/expo-secure-store.d.ts +5 -1
  262. package/src/utils/accountCacheSweep.ts +4 -5
  263. package/src/utils/accountUtils.ts +107 -108
  264. package/src/utils/apiUtils.ts +3 -3
  265. package/src/utils/asyncUtils.ts +2 -2
  266. package/src/utils/authHelpers.ts +10 -5
  267. package/src/utils/avatarUtils.ts +11 -6
  268. package/src/utils/cache.ts +9 -10
  269. package/src/utils/cacheKey.ts +5 -1
  270. package/src/utils/coldBoot.ts +1 -3
  271. package/src/utils/commonsDelivery.ts +1 -4
  272. package/src/utils/deviceManager.ts +15 -14
  273. package/src/utils/errorUtils.ts +68 -86
  274. package/src/utils/languageUtils.ts +407 -58
  275. package/src/utils/oauthPkce.ts +1 -4
  276. package/src/utils/platform.ts +0 -1
  277. package/src/utils/profileLinks.ts +2 -5
  278. package/src/utils/requestUtils.ts +18 -14
  279. package/src/utils/sessionUtils.ts +34 -33
  280. package/src/utils/userHandle.ts +3 -1
  281. package/src/utils/userIdentity.ts +1 -1
  282. package/src/utils/validationUtils.ts +11 -9
@@ -98,7 +98,12 @@ export class OxyServices {
98
98
  * built on, for the routes no namespace covers yet. GET sends `data` as the
99
99
  * query string, every other method as the body. Rejects with `OxyApiError`.
100
100
  */
101
- async request<T>(method: HttpMethod, url: string, data?: unknown, options: RequestOptions = {}): Promise<T> {
101
+ async request<T>(
102
+ method: HttpMethod,
103
+ url: string,
104
+ data?: unknown,
105
+ options: RequestOptions = {},
106
+ ): Promise<T> {
102
107
  try {
103
108
  return await this.http.request<T>({
104
109
  method,
@@ -303,4 +308,3 @@ export class OxyServices {
303
308
  return this._contacts;
304
309
  }
305
310
  }
306
-
@@ -17,8 +17,15 @@
17
17
  * no per-request "acting-as" header. Identity is carried by the session/token,
18
18
  * so a switch propagates through reload and cross-domain exactly like a login.
19
19
  */
20
- import { agentKeyOperationSchema, executeAgentKeyOperationSchema, agentKeyOperationChallengeSchema,
21
- agentKeyOperationResultSchema, agentKeyListResponseSchema, type AgentKeyOperation, type AgentKeyOperationProof } from '@oxy.so/contracts';
20
+ import {
21
+ agentKeyOperationSchema,
22
+ executeAgentKeyOperationSchema,
23
+ agentKeyOperationChallengeSchema,
24
+ agentKeyOperationResultSchema,
25
+ agentKeyListResponseSchema,
26
+ type AgentKeyOperation,
27
+ type AgentKeyOperationProof,
28
+ } from '@oxy.so/contracts';
22
29
  import type { User } from '../models/interfaces';
23
30
  import type { AccountCategoryId, AccountKind, ChildAccountKind } from '@oxy.so/contracts';
24
31
  import type { SessionLoginResponse } from '../models/session';
@@ -136,7 +143,7 @@ export interface AccountMember {
136
143
  * `childCount` reflects the number of direct children.
137
144
  */
138
145
  export interface AccountNode {
139
- /** The account's Mongo `_id` (the underlying `User._id`). */
146
+ /** The account's user id. */
140
147
  accountId: string;
141
148
  kind: AccountKind;
142
149
  /** Parent account `_id`, or `null` for a root (personal) account. */
@@ -329,7 +336,6 @@ export interface SwitchAccountResult extends SessionLoginResponse {
329
336
  authuser?: number;
330
337
  }
331
338
 
332
-
333
339
  /** `oxy.accounts.members` — who can act on an account, and with what role. */
334
340
  export class AccountMembersApi {
335
341
  constructor(private readonly ctx: OxyContext) {}
@@ -387,7 +393,11 @@ export class AccountMembersApi {
387
393
  * @param memberId - The member's `_id`.
388
394
  * @param data - New role (never `owner`), inheritance, permission overrides.
389
395
  */
390
- async update(accountId: string, memberId: string, data: UpdateAccountMemberInput): Promise<AccountMember> {
396
+ async update(
397
+ accountId: string,
398
+ memberId: string,
399
+ data: UpdateAccountMemberInput,
400
+ ): Promise<AccountMember> {
391
401
  const res = await this.ctx.request<{ member: AccountMember }>(
392
402
  'PATCH',
393
403
  `/accounts/${enc(accountId)}/members/${enc(memberId)}`,
@@ -419,16 +429,28 @@ export class AccountMembersApi {
419
429
  export class AccountAgentKeysApi {
420
430
  constructor(private readonly ctx: OxyContext) {}
421
431
  async list(accountId: string) {
422
- return agentKeyListResponseSchema.parse(await this.ctx.request<unknown>('GET', `/accounts/${enc(accountId)}/agent-keys`, undefined, { cache: false }));
432
+ return agentKeyListResponseSchema.parse(
433
+ await this.ctx.request<unknown>('GET', `/accounts/${enc(accountId)}/agent-keys`, undefined, {
434
+ cache: false,
435
+ }),
436
+ );
423
437
  }
424
438
  async requestChallenge(accountId: string, operation: AgentKeyOperation) {
425
- const response = await this.ctx.request<unknown>('POST', `/accounts/${enc(accountId)}/agent-keys/challenge`,
426
- agentKeyOperationSchema.parse(operation), { cache: false });
439
+ const response = await this.ctx.request<unknown>(
440
+ 'POST',
441
+ `/accounts/${enc(accountId)}/agent-keys/challenge`,
442
+ agentKeyOperationSchema.parse(operation),
443
+ { cache: false },
444
+ );
427
445
  return agentKeyOperationChallengeSchema.parse(response);
428
446
  }
429
447
  async execute(accountId: string, operation: AgentKeyOperation, proof: AgentKeyOperationProof) {
430
- const response = await this.ctx.request<unknown>('POST', `/accounts/${enc(accountId)}/agent-keys/execute`,
431
- executeAgentKeyOperationSchema.parse({ operation, proof }), { cache: false });
448
+ const response = await this.ctx.request<unknown>(
449
+ 'POST',
450
+ `/accounts/${enc(accountId)}/agent-keys/execute`,
451
+ executeAgentKeyOperationSchema.parse({ operation, proof }),
452
+ { cache: false },
453
+ );
432
454
  return agentKeyOperationResultSchema.parse(response);
433
455
  }
434
456
  }
@@ -466,10 +488,15 @@ export class AccountsApi {
466
488
  * @param accountId - The account's `_id`.
467
489
  */
468
490
  async get(accountId: string): Promise<AccountNode> {
469
- const res = await this.ctx.request<{ account: AccountNode }>('GET', `/accounts/${enc(accountId)}`, undefined, {
470
- cache: true,
471
- cacheTTL: LONG_TTL,
472
- });
491
+ const res = await this.ctx.request<{ account: AccountNode }>(
492
+ 'GET',
493
+ `/accounts/${enc(accountId)}`,
494
+ undefined,
495
+ {
496
+ cache: true,
497
+ cacheTTL: LONG_TTL,
498
+ },
499
+ );
473
500
  return res.account;
474
501
  }
475
502
 
@@ -496,9 +523,14 @@ export class AccountsApi {
496
523
  * @returns The minted session, already planted as the active session.
497
524
  */
498
525
  async actAs(accountId: string): Promise<SwitchAccountResult> {
499
- const res = await this.ctx.request<SwitchAccountResult>('POST', `/accounts/${enc(accountId)}/switch`, undefined, {
500
- cache: false,
501
- });
526
+ const res = await this.ctx.request<SwitchAccountResult>(
527
+ 'POST',
528
+ `/accounts/${enc(accountId)}/switch`,
529
+ undefined,
530
+ {
531
+ cache: false,
532
+ },
533
+ );
502
534
  if (res?.accessToken) {
503
535
  this.ctx.oxy.session.setAccessToken(res.accessToken);
504
536
  }
@@ -518,7 +550,9 @@ export class AccountsApi {
518
550
  * @param data - Account configuration: kind, optional parent, and profile.
519
551
  */
520
552
  async create(data: CreateAccountInput): Promise<AccountNode> {
521
- const res = await this.ctx.request<{ account: AccountNode }>('POST', '/accounts', data, { cache: false });
553
+ const res = await this.ctx.request<{ account: AccountNode }>('POST', '/accounts', data, {
554
+ cache: false,
555
+ });
522
556
  // A new account changes the accessible forest — bust every cached list.
523
557
  evictOxyAccountForestCache(this.ctx.http);
524
558
  return res.account;
@@ -536,9 +570,14 @@ export class AccountsApi {
536
570
  * @param data - Subset of updatable profile fields.
537
571
  */
538
572
  async update(accountId: string, data: UpdateAccountInput): Promise<AccountNode> {
539
- const res = await this.ctx.request<{ account: AccountNode }>('PATCH', `/accounts/${enc(accountId)}`, data, {
540
- cache: false,
541
- });
573
+ const res = await this.ctx.request<{ account: AccountNode }>(
574
+ 'PATCH',
575
+ `/accounts/${enc(accountId)}`,
576
+ data,
577
+ {
578
+ cache: false,
579
+ },
580
+ );
542
581
  evictOxyAccountForestCache(this.ctx.http, accountId);
543
582
  // The parent's children list embeds this account's profile and is keyed by
544
583
  // the PARENT id, so it is reachable only from the response node.
@@ -556,11 +595,19 @@ export class AccountsApi {
556
595
  * @param accountId - The account's `_id`.
557
596
  */
558
597
  async archive(accountId: string): Promise<AccountSuccessResult> {
559
- const result = await this.ctx.request<AccountSuccessResult>('DELETE', `/accounts/${enc(accountId)}`, undefined, {
560
- cache: false,
561
- });
598
+ const result = await this.ctx.request<AccountSuccessResult>(
599
+ 'DELETE',
600
+ `/accounts/${enc(accountId)}`,
601
+ undefined,
602
+ {
603
+ cache: false,
604
+ },
605
+ );
562
606
  this.ctx.http.invalidateCache({
563
- keys: [`GET:/accounts/${enc(accountId)}/members`, `GET:/accounts/${enc(accountId)}/credentials`],
607
+ keys: [
608
+ `GET:/accounts/${enc(accountId)}/members`,
609
+ `GET:/accounts/${enc(accountId)}/credentials`,
610
+ ],
564
611
  });
565
612
  evictOxyAccountForestCache(this.ctx.http, accountId);
566
613
  return result;
@@ -571,7 +618,10 @@ export class AccountsApi {
571
618
  * @param accountId - The account's `_id`.
572
619
  * @param data - Target user id.
573
620
  */
574
- async transferOwnership(accountId: string, data: TransferAccountOwnershipInput): Promise<AccountSuccessResult> {
621
+ async transferOwnership(
622
+ accountId: string,
623
+ data: TransferAccountOwnershipInput,
624
+ ): Promise<AccountSuccessResult> {
575
625
  const result = await this.ctx.request<AccountSuccessResult>(
576
626
  'POST',
577
627
  `/accounts/${enc(accountId)}/transfer-ownership`,
package/src/api/agency.ts CHANGED
@@ -122,13 +122,14 @@ export interface RequesterAssertionIntrospection {
122
122
  expiresAt?: string;
123
123
  }
124
124
 
125
-
126
125
  function query(path: string, key: string, value: string): string {
127
126
  return `${path}?${key}=${enc(value)}`;
128
127
  }
129
128
 
130
- const grantsKey = (ownerAccountId: string): string => `GET:${query('/capabilities/grants', 'ownerAccountId', ownerAccountId)}`;
131
- const policiesKey = (accountId: string): string => `GET:${query('/capabilities/account-policies', 'accountId', accountId)}`;
129
+ const grantsKey = (ownerAccountId: string): string =>
130
+ `GET:${query('/capabilities/grants', 'ownerAccountId', ownerAccountId)}`;
131
+ const policiesKey = (accountId: string): string =>
132
+ `GET:${query('/capabilities/account-policies', 'accountId', accountId)}`;
132
133
  const authorizationsKey = (ownerAccountId: string): string =>
133
134
  `GET:${query('/capabilities/execution-authorizations', 'ownerAccountId', ownerAccountId)}`;
134
135
 
@@ -149,15 +150,24 @@ export class DelegationGrantsApi {
149
150
 
150
151
  /** Issue a delegation grant. */
151
152
  async create(input: CreateDelegationGrantInput): Promise<DelegationGrantView> {
152
- const res = await this.ctx.request<{ grant: DelegationGrantView }>('POST', '/capabilities/grants', input, {
153
- cache: false,
154
- });
153
+ const res = await this.ctx.request<{ grant: DelegationGrantView }>(
154
+ 'POST',
155
+ '/capabilities/grants',
156
+ input,
157
+ {
158
+ cache: false,
159
+ },
160
+ );
155
161
  this.ctx.oxy.cache.delete(grantsKey(input.ownerAccountId));
156
162
  return res.grant;
157
163
  }
158
164
 
159
165
  /** Change a grant's capabilities, limits or autonomy. */
160
- async update(grantId: string, ownerAccountId: string, input: UpdateDelegationGrantInput): Promise<DelegationGrantView> {
166
+ async update(
167
+ grantId: string,
168
+ ownerAccountId: string,
169
+ input: UpdateDelegationGrantInput,
170
+ ): Promise<DelegationGrantView> {
161
171
  const res = await this.ctx.request<{ grant: DelegationGrantView }>(
162
172
  'PUT',
163
173
  `/capabilities/grants/${enc(grantId)}`,
@@ -170,7 +180,9 @@ export class DelegationGrantsApi {
170
180
 
171
181
  /** Revoke a grant. */
172
182
  async revoke(grantId: string, ownerAccountId: string): Promise<void> {
173
- await this.ctx.request<void>('DELETE', `/capabilities/grants/${enc(grantId)}`, undefined, { cache: false });
183
+ await this.ctx.request<void>('DELETE', `/capabilities/grants/${enc(grantId)}`, undefined, {
184
+ cache: false,
185
+ });
174
186
  this.ctx.oxy.cache.delete(grantsKey(ownerAccountId));
175
187
  }
176
188
  }
@@ -191,7 +203,10 @@ export class CapabilityPoliciesApi {
191
203
  }
192
204
 
193
205
  /** Set an account's policy for one app. */
194
- async put(appId: string, input: PutAccountCapabilityPolicyInput): Promise<AccountCapabilityPolicy> {
206
+ async put(
207
+ appId: string,
208
+ input: PutAccountCapabilityPolicyInput,
209
+ ): Promise<AccountCapabilityPolicy> {
195
210
  const res = await this.ctx.request<{ policy: AccountCapabilityPolicy }>(
196
211
  'PUT',
197
212
  `/capabilities/account-policies/${enc(appId)}`,
@@ -31,13 +31,23 @@ export class AppDataApi {
31
31
 
32
32
  /** The value under `(namespace, key)`, or `null` when nothing is stored. */
33
33
  async get<T = unknown>(namespace: string, key: string): Promise<T | null> {
34
- const res = await this.ctx.request<{ value: T | null }>('GET', this.path(namespace, key), undefined, { cache: false });
34
+ const res = await this.ctx.request<{ value: T | null }>(
35
+ 'GET',
36
+ this.path(namespace, key),
37
+ undefined,
38
+ { cache: false },
39
+ );
35
40
  return res?.value ?? null;
36
41
  }
37
42
 
38
43
  /** Store `value` under `(namespace, key)`; returns what the server stored. */
39
44
  async set<T = unknown>(namespace: string, key: string, value: T): Promise<T> {
40
- const res = await this.ctx.request<{ value: T | null }>('PUT', this.path(namespace, key), { value }, { cache: false });
45
+ const res = await this.ctx.request<{ value: T | null }>(
46
+ 'PUT',
47
+ this.path(namespace, key),
48
+ { value },
49
+ { cache: false },
50
+ );
41
51
  return (res?.value ?? value) as T;
42
52
  }
43
53
 
package/src/api/apps.ts CHANGED
@@ -273,7 +273,6 @@ export interface ApplicationUsageStats {
273
273
  byEndpoint: ApplicationUsageByEndpoint[];
274
274
  }
275
275
 
276
-
277
276
  // ---------------------------------------------------------------------------
278
277
  // OAuth consent (connected apps) types
279
278
  // ---------------------------------------------------------------------------
@@ -289,7 +288,7 @@ export interface ApplicationUsageStats {
289
288
  * `_id` as a string.
290
289
  */
291
290
  export interface PublicApplication {
292
- /** The application's Mongo `_id` as a string. */
291
+ /** The application's id as a string. */
293
292
  id: string;
294
293
  /** Human-readable application name shown to the user. */
295
294
  name: string;
@@ -320,14 +319,14 @@ export interface PublicApplication {
320
319
  * view: an application the user has granted access to via the consent flow.
321
320
  *
322
321
  * Returned by `GET /auth/grants` and rendered in the user-facing "Connected
323
- * apps" management surface. Keyed by `applicationId` (the application's Mongo
324
- * `_id`) rather than a credential/client id, so the grant — and a subsequent
322
+ * apps" management surface. Keyed by `applicationId` (the application's own
323
+ * id) rather than a credential/client id, so the grant — and a subsequent
325
324
  * `apps.connected.revoke` — survive credential
326
325
  * rotation. This is a display shape: it carries the application's name/logo and
327
326
  * the granted scopes, never any membership or credential material.
328
327
  */
329
328
  export interface ConnectedApp {
330
- /** The connected application's Mongo `_id`. Use this to revoke the grant. */
329
+ /** The connected application's id. Use this to revoke the grant. */
331
330
  applicationId: string;
332
331
  /** Human-readable application name shown to the user. */
333
332
  name: string;
@@ -353,7 +352,6 @@ export interface ConnectedMcpClient {
353
352
  lastUsedAt: string;
354
353
  }
355
354
 
356
-
357
355
  /** `oxy.apps.credentials` — an application's OAuth client credentials. */
358
356
  export class AppCredentialsApi {
359
357
  constructor(private readonly ctx: OxyContext) {}
@@ -379,10 +377,18 @@ export class AppCredentialsApi {
379
377
  * @param applicationId - The application's `_id`.
380
378
  * @param data - Credential configuration.
381
379
  */
382
- async create(applicationId: string, data: CreateApplicationCredentialInput): Promise<ApplicationCredentialWithSecret> {
383
- const result = await this.ctx.request<ApplicationCredentialWithSecret>('POST', credentialsPath(applicationId), data, {
384
- cache: false,
385
- });
380
+ async create(
381
+ applicationId: string,
382
+ data: CreateApplicationCredentialInput,
383
+ ): Promise<ApplicationCredentialWithSecret> {
384
+ const result = await this.ctx.request<ApplicationCredentialWithSecret>(
385
+ 'POST',
386
+ credentialsPath(applicationId),
387
+ data,
388
+ {
389
+ cache: false,
390
+ },
391
+ );
386
392
  this.ctx.oxy.cache.delete(`GET:${credentialsPath(applicationId)}`);
387
393
  return result;
388
394
  }
@@ -441,7 +447,10 @@ export class ConnectedAppsApi {
441
447
  * `GET /auth/grants`, briefly cached; `revoke` busts it.
442
448
  */
443
449
  async list(): Promise<ConnectedApp[]> {
444
- return this.ctx.request<ConnectedApp[]>('GET', '/auth/grants', undefined, { cache: true, cacheTTL: SHORT_TTL });
450
+ return this.ctx.request<ConnectedApp[]>('GET', '/auth/grants', undefined, {
451
+ cache: true,
452
+ cacheTTL: SHORT_TTL,
453
+ });
445
454
  }
446
455
 
447
456
  /**
@@ -451,22 +460,34 @@ export class ConnectedAppsApi {
451
460
  * `ConnectedApp.applicationId`, NOT a credential/client id).
452
461
  */
453
462
  async revoke(applicationId: string): Promise<void> {
454
- await this.ctx.request<{ revoked: boolean }>('DELETE', `/auth/grants/${applicationId}`, undefined, { cache: false });
463
+ await this.ctx.request<{ revoked: boolean }>(
464
+ 'DELETE',
465
+ `/auth/grants/${applicationId}`,
466
+ undefined,
467
+ { cache: false },
468
+ );
455
469
  this.ctx.oxy.cache.delete('GET:/auth/grants');
456
470
  }
457
471
 
458
472
  /** Resource-bound external MCP connections for the active Oxy account. */
459
473
  async mcpClients(): Promise<ConnectedMcpClient[]> {
460
- const res = await this.ctx.request<{ grants: ConnectedMcpClient[] }>('GET', '/auth/mcp/oauth/grants', undefined, {
461
- cache: true,
462
- cacheTTL: SHORT_TTL,
463
- });
474
+ const res = await this.ctx.request<{ grants: ConnectedMcpClient[] }>(
475
+ 'GET',
476
+ '/auth/mcp/oauth/grants',
477
+ undefined,
478
+ {
479
+ cache: true,
480
+ cacheTTL: SHORT_TTL,
481
+ },
482
+ );
464
483
  return res.grants;
465
484
  }
466
485
 
467
486
  /** Revoke one external MCP connection and every token in its family. */
468
487
  async revokeMcpClient(grantId: string): Promise<void> {
469
- await this.ctx.request<void>('DELETE', `/auth/mcp/oauth/grants/${enc(grantId)}`, undefined, { cache: false });
488
+ await this.ctx.request<void>('DELETE', `/auth/mcp/oauth/grants/${enc(grantId)}`, undefined, {
489
+ cache: false,
490
+ });
470
491
  this.ctx.oxy.cache.delete('GET:/auth/mcp/oauth/grants');
471
492
  }
472
493
  }
@@ -501,10 +522,15 @@ export class AppsApi {
501
522
  * @param applicationId - The application's `_id`.
502
523
  */
503
524
  async get(applicationId: string): Promise<Application> {
504
- const res = await this.ctx.request<{ application: Application }>('GET', appPath(applicationId), undefined, {
505
- cache: true,
506
- cacheTTL: LONG_TTL,
507
- });
525
+ const res = await this.ctx.request<{ application: Application }>(
526
+ 'GET',
527
+ appPath(applicationId),
528
+ undefined,
529
+ {
530
+ cache: true,
531
+ cacheTTL: LONG_TTL,
532
+ },
533
+ );
508
534
  return res.application;
509
535
  }
510
536
 
@@ -514,7 +540,12 @@ export class AppsApi {
514
540
  * caller's personal account when omitted. Staff-only fields are ignored.
515
541
  */
516
542
  async create(data: CreateApplicationInput): Promise<Application> {
517
- const res = await this.ctx.request<{ application: Application }>('POST', '/applications', data, { cache: false });
543
+ const res = await this.ctx.request<{ application: Application }>(
544
+ 'POST',
545
+ '/applications',
546
+ data,
547
+ { cache: false },
548
+ );
518
549
  this.invalidateLists();
519
550
  return res.application;
520
551
  }
@@ -525,9 +556,14 @@ export class AppsApi {
525
556
  * @param data - Subset of updatable fields. Staff-only fields are ignored.
526
557
  */
527
558
  async update(applicationId: string, data: UpdateApplicationInput): Promise<Application> {
528
- const res = await this.ctx.request<{ application: Application }>('PATCH', appPath(applicationId), data, {
529
- cache: false,
530
- });
559
+ const res = await this.ctx.request<{ application: Application }>(
560
+ 'PATCH',
561
+ appPath(applicationId),
562
+ data,
563
+ {
564
+ cache: false,
565
+ },
566
+ );
531
567
  this.invalidateLists([`GET:${appPath(applicationId)}`]);
532
568
  return res.application;
533
569
  }
@@ -537,10 +573,18 @@ export class AppsApi {
537
573
  * @param applicationId - The application's `_id`.
538
574
  */
539
575
  async delete(applicationId: string): Promise<AccountSuccessResult> {
540
- const result = await this.ctx.request<AccountSuccessResult>('DELETE', appPath(applicationId), undefined, {
541
- cache: false,
542
- });
543
- this.invalidateLists([`GET:${appPath(applicationId)}`, `GET:${credentialsPath(applicationId)}`]);
576
+ const result = await this.ctx.request<AccountSuccessResult>(
577
+ 'DELETE',
578
+ appPath(applicationId),
579
+ undefined,
580
+ {
581
+ cache: false,
582
+ },
583
+ );
584
+ this.invalidateLists([
585
+ `GET:${appPath(applicationId)}`,
586
+ `GET:${credentialsPath(applicationId)}`,
587
+ ]);
544
588
  return result;
545
589
  }
546
590
 
@@ -549,7 +593,10 @@ export class AppsApi {
549
593
  * @param applicationId - The application's `_id`.
550
594
  * @param period - Time window (defaults to the server default).
551
595
  */
552
- async usage(applicationId: string, period?: ApplicationUsagePeriod): Promise<ApplicationUsageStats> {
596
+ async usage(
597
+ applicationId: string,
598
+ period?: ApplicationUsagePeriod,
599
+ ): Promise<ApplicationUsageStats> {
553
600
  return this.ctx.request<ApplicationUsageStats>(
554
601
  'GET',
555
602
  `${appPath(applicationId)}/usage`,
@@ -583,7 +630,10 @@ export class AppsApi {
583
630
  * `GET:/applications/<id>…` detail keys.
584
631
  */
585
632
  private invalidateLists(extraKeys: string[] = []): void {
586
- this.ctx.http.invalidateCache({ keys: ['GET:/applications', ...extraKeys], prefixes: ['GET:/applications?'] });
633
+ this.ctx.http.invalidateCache({
634
+ keys: ['GET:/applications', ...extraKeys],
635
+ prefixes: ['GET:/applications?'],
636
+ });
587
637
  }
588
638
  }
589
639