@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
@@ -17,10 +17,22 @@
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
- import type { AccountCategoryId, AccountKind, ChildAccountKind } from '@oxy.so/contracts';
30
+ import type {
31
+ AccountCategoryId,
32
+ AccountKind,
33
+ AvatarCharacter,
34
+ ChildAccountKind,
35
+ } from '@oxy.so/contracts';
24
36
  import type { SessionLoginResponse } from '../models/session';
25
37
  import type { OxyContext } from '../client/context';
26
38
  import { normalizeUserIdentity } from '../utils/userIdentity';
@@ -50,7 +62,7 @@ const enc = encodeURIComponent;
50
62
  *
51
63
  * Single source of truth is `@oxy.so/contracts`.
52
64
  */
53
- export type { AccountCategoryId, AccountKind } from '@oxy.so/contracts';
65
+ export type { AccountCategoryId, AccountKind, AvatarCharacter } from '@oxy.so/contracts';
54
66
  export {
55
67
  ACCOUNT_CATEGORY_IDS,
56
68
  ACCOUNT_KINDS,
@@ -136,7 +148,7 @@ export interface AccountMember {
136
148
  * `childCount` reflects the number of direct children.
137
149
  */
138
150
  export interface AccountNode {
139
- /** The account's Mongo `_id` (the underlying `User._id`). */
151
+ /** The account's user id. */
140
152
  accountId: string;
141
153
  kind: AccountKind;
142
154
  /** Parent account `_id`, or `null` for a root (personal) account. */
@@ -240,6 +252,13 @@ export interface CreateAccountInput {
240
252
  * discoverable at all, rather than discoverable until a second call lands.
241
253
  */
242
254
  isPrivateAccount?: boolean;
255
+ /**
256
+ * The 3D avatar character, for `kind: 'bot'` ONLY (any other kind is a 400).
257
+ * Optional: a bot created without one is given a look seeded from its
258
+ * handle, so every bot has a character from birth and its owner changes it
259
+ * afterwards with `accounts.update`.
260
+ */
261
+ character?: AvatarCharacter;
243
262
  }
244
263
 
245
264
  /** Input accepted by `accounts.update`. Tree placement changes go through `/move`. */
@@ -276,6 +295,12 @@ export interface UpdateAccountInput {
276
295
  * always allowed.
277
296
  */
278
297
  accountCategories?: AccountCategoryId[];
298
+ /**
299
+ * Replaces the WHOLE character of a `bot` account. Rejected (400) for any
300
+ * other kind, and not nullable: a bot always has one. Same authorization as
301
+ * every other field here (`account:update`).
302
+ */
303
+ character?: AvatarCharacter;
279
304
  }
280
305
 
281
306
  /** Input accepted by `accounts.members.invite`. The owner role cannot be invited. */
@@ -329,7 +354,6 @@ export interface SwitchAccountResult extends SessionLoginResponse {
329
354
  authuser?: number;
330
355
  }
331
356
 
332
-
333
357
  /** `oxy.accounts.members` — who can act on an account, and with what role. */
334
358
  export class AccountMembersApi {
335
359
  constructor(private readonly ctx: OxyContext) {}
@@ -387,7 +411,11 @@ export class AccountMembersApi {
387
411
  * @param memberId - The member's `_id`.
388
412
  * @param data - New role (never `owner`), inheritance, permission overrides.
389
413
  */
390
- async update(accountId: string, memberId: string, data: UpdateAccountMemberInput): Promise<AccountMember> {
414
+ async update(
415
+ accountId: string,
416
+ memberId: string,
417
+ data: UpdateAccountMemberInput,
418
+ ): Promise<AccountMember> {
391
419
  const res = await this.ctx.request<{ member: AccountMember }>(
392
420
  'PATCH',
393
421
  `/accounts/${enc(accountId)}/members/${enc(memberId)}`,
@@ -419,16 +447,28 @@ export class AccountMembersApi {
419
447
  export class AccountAgentKeysApi {
420
448
  constructor(private readonly ctx: OxyContext) {}
421
449
  async list(accountId: string) {
422
- return agentKeyListResponseSchema.parse(await this.ctx.request<unknown>('GET', `/accounts/${enc(accountId)}/agent-keys`, undefined, { cache: false }));
450
+ return agentKeyListResponseSchema.parse(
451
+ await this.ctx.request<unknown>('GET', `/accounts/${enc(accountId)}/agent-keys`, undefined, {
452
+ cache: false,
453
+ }),
454
+ );
423
455
  }
424
456
  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 });
457
+ const response = await this.ctx.request<unknown>(
458
+ 'POST',
459
+ `/accounts/${enc(accountId)}/agent-keys/challenge`,
460
+ agentKeyOperationSchema.parse(operation),
461
+ { cache: false },
462
+ );
427
463
  return agentKeyOperationChallengeSchema.parse(response);
428
464
  }
429
465
  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 });
466
+ const response = await this.ctx.request<unknown>(
467
+ 'POST',
468
+ `/accounts/${enc(accountId)}/agent-keys/execute`,
469
+ executeAgentKeyOperationSchema.parse({ operation, proof }),
470
+ { cache: false },
471
+ );
432
472
  return agentKeyOperationResultSchema.parse(response);
433
473
  }
434
474
  }
@@ -466,10 +506,15 @@ export class AccountsApi {
466
506
  * @param accountId - The account's `_id`.
467
507
  */
468
508
  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
- });
509
+ const res = await this.ctx.request<{ account: AccountNode }>(
510
+ 'GET',
511
+ `/accounts/${enc(accountId)}`,
512
+ undefined,
513
+ {
514
+ cache: true,
515
+ cacheTTL: LONG_TTL,
516
+ },
517
+ );
473
518
  return res.account;
474
519
  }
475
520
 
@@ -496,9 +541,14 @@ export class AccountsApi {
496
541
  * @returns The minted session, already planted as the active session.
497
542
  */
498
543
  async actAs(accountId: string): Promise<SwitchAccountResult> {
499
- const res = await this.ctx.request<SwitchAccountResult>('POST', `/accounts/${enc(accountId)}/switch`, undefined, {
500
- cache: false,
501
- });
544
+ const res = await this.ctx.request<SwitchAccountResult>(
545
+ 'POST',
546
+ `/accounts/${enc(accountId)}/switch`,
547
+ undefined,
548
+ {
549
+ cache: false,
550
+ },
551
+ );
502
552
  if (res?.accessToken) {
503
553
  this.ctx.oxy.session.setAccessToken(res.accessToken);
504
554
  }
@@ -518,7 +568,9 @@ export class AccountsApi {
518
568
  * @param data - Account configuration: kind, optional parent, and profile.
519
569
  */
520
570
  async create(data: CreateAccountInput): Promise<AccountNode> {
521
- const res = await this.ctx.request<{ account: AccountNode }>('POST', '/accounts', data, { cache: false });
571
+ const res = await this.ctx.request<{ account: AccountNode }>('POST', '/accounts', data, {
572
+ cache: false,
573
+ });
522
574
  // A new account changes the accessible forest — bust every cached list.
523
575
  evictOxyAccountForestCache(this.ctx.http);
524
576
  return res.account;
@@ -536,9 +588,14 @@ export class AccountsApi {
536
588
  * @param data - Subset of updatable profile fields.
537
589
  */
538
590
  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
- });
591
+ const res = await this.ctx.request<{ account: AccountNode }>(
592
+ 'PATCH',
593
+ `/accounts/${enc(accountId)}`,
594
+ data,
595
+ {
596
+ cache: false,
597
+ },
598
+ );
542
599
  evictOxyAccountForestCache(this.ctx.http, accountId);
543
600
  // The parent's children list embeds this account's profile and is keyed by
544
601
  // the PARENT id, so it is reachable only from the response node.
@@ -556,11 +613,19 @@ export class AccountsApi {
556
613
  * @param accountId - The account's `_id`.
557
614
  */
558
615
  async archive(accountId: string): Promise<AccountSuccessResult> {
559
- const result = await this.ctx.request<AccountSuccessResult>('DELETE', `/accounts/${enc(accountId)}`, undefined, {
560
- cache: false,
561
- });
616
+ const result = await this.ctx.request<AccountSuccessResult>(
617
+ 'DELETE',
618
+ `/accounts/${enc(accountId)}`,
619
+ undefined,
620
+ {
621
+ cache: false,
622
+ },
623
+ );
562
624
  this.ctx.http.invalidateCache({
563
- keys: [`GET:/accounts/${enc(accountId)}/members`, `GET:/accounts/${enc(accountId)}/credentials`],
625
+ keys: [
626
+ `GET:/accounts/${enc(accountId)}/members`,
627
+ `GET:/accounts/${enc(accountId)}/credentials`,
628
+ ],
564
629
  });
565
630
  evictOxyAccountForestCache(this.ctx.http, accountId);
566
631
  return result;
@@ -571,7 +636,10 @@ export class AccountsApi {
571
636
  * @param accountId - The account's `_id`.
572
637
  * @param data - Target user id.
573
638
  */
574
- async transferOwnership(accountId: string, data: TransferAccountOwnershipInput): Promise<AccountSuccessResult> {
639
+ async transferOwnership(
640
+ accountId: string,
641
+ data: TransferAccountOwnershipInput,
642
+ ): Promise<AccountSuccessResult> {
575
643
  const result = await this.ctx.request<AccountSuccessResult>(
576
644
  'POST',
577
645
  `/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