@oxy.so/contracts 4.16.0 → 4.21.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 (135) hide show
  1. package/dist/cjs/accountAccess.js +72 -0
  2. package/dist/cjs/accountEmail.js +12 -34
  3. package/dist/cjs/accountGraph.js +22 -320
  4. package/dist/cjs/agency.js +112 -1
  5. package/dist/cjs/agentKeys.js +11 -13
  6. package/dist/cjs/applicationRoles.js +211 -0
  7. package/dist/cjs/client/accountEmail.js +48 -0
  8. package/dist/cjs/client/accountGraph.js +323 -0
  9. package/dist/cjs/client/agentKeys.js +77 -0
  10. package/dist/cjs/client/check.js +475 -0
  11. package/dist/cjs/client/deviceBoot.js +22 -0
  12. package/dist/cjs/client/deviceDirectory.js +51 -0
  13. package/dist/cjs/client/deviceSession.js +63 -0
  14. package/dist/cjs/client/externalIdentity.js +19 -0
  15. package/dist/cjs/client/identity.js +45 -0
  16. package/dist/cjs/client/identityLink.js +55 -0
  17. package/dist/cjs/client/identityProof.js +109 -0
  18. package/dist/cjs/client/index.js +211 -0
  19. package/dist/cjs/client/organizations.js +114 -0
  20. package/dist/cjs/client/products.js +153 -0
  21. package/dist/cjs/client/recommendations.js +33 -0
  22. package/dist/cjs/client/reputation.js +41 -0
  23. package/dist/cjs/client/safety.js +196 -0
  24. package/dist/cjs/client/sessionStatus.js +23 -0
  25. package/dist/cjs/client/signIn.js +159 -0
  26. package/dist/cjs/client/userResponse.js +15 -0
  27. package/dist/cjs/client/username.js +173 -0
  28. package/dist/cjs/deviceSession.js +3 -16
  29. package/dist/cjs/identityLink.js +13 -34
  30. package/dist/cjs/identityProof.js +18 -106
  31. package/dist/cjs/index.js +13 -3
  32. package/dist/cjs/organizations.js +21 -41
  33. package/dist/cjs/reputation.js +3 -34
  34. package/dist/cjs/safety.js +430 -1
  35. package/dist/cjs/serviceToken.js +14 -0
  36. package/dist/cjs/signIn.js +33 -111
  37. package/dist/cjs/username.js +23 -158
  38. package/dist/esm/accountAccess.js +69 -0
  39. package/dist/esm/accountEmail.js +4 -32
  40. package/dist/esm/accountGraph.js +4 -309
  41. package/dist/esm/agency.js +111 -0
  42. package/dist/esm/agentKeys.js +4 -10
  43. package/dist/esm/applicationRoles.js +207 -0
  44. package/dist/esm/client/accountEmail.js +45 -0
  45. package/dist/esm/client/accountGraph.js +314 -0
  46. package/dist/esm/client/agentKeys.js +74 -0
  47. package/dist/esm/client/check.js +436 -0
  48. package/dist/esm/client/deviceBoot.js +19 -0
  49. package/dist/esm/client/deviceDirectory.js +48 -0
  50. package/dist/esm/client/deviceSession.js +60 -0
  51. package/dist/esm/client/externalIdentity.js +16 -0
  52. package/dist/esm/client/identity.js +42 -0
  53. package/dist/esm/client/identityLink.js +50 -0
  54. package/dist/esm/client/identityProof.js +104 -0
  55. package/dist/esm/client/index.js +37 -0
  56. package/dist/esm/client/organizations.js +111 -0
  57. package/dist/esm/client/products.js +150 -0
  58. package/dist/esm/client/recommendations.js +30 -0
  59. package/dist/esm/client/reputation.js +37 -0
  60. package/dist/esm/client/safety.js +193 -0
  61. package/dist/esm/client/sessionStatus.js +20 -0
  62. package/dist/esm/client/signIn.js +153 -0
  63. package/dist/esm/client/userResponse.js +12 -0
  64. package/dist/esm/client/username.js +167 -0
  65. package/dist/esm/deviceSession.js +1 -15
  66. package/dist/esm/identityLink.js +4 -27
  67. package/dist/esm/identityProof.js +4 -99
  68. package/dist/esm/index.js +4 -1
  69. package/dist/esm/organizations.js +4 -31
  70. package/dist/esm/reputation.js +1 -32
  71. package/dist/esm/safety.js +423 -0
  72. package/dist/esm/serviceToken.js +11 -0
  73. package/dist/esm/signIn.js +4 -96
  74. package/dist/esm/username.js +4 -148
  75. package/dist/types/accountAccess.d.ts +128 -0
  76. package/dist/types/accountEmail.d.ts +4 -36
  77. package/dist/types/accountGraph.d.ts +12 -208
  78. package/dist/types/agency.d.ts +351 -26
  79. package/dist/types/agentKeys.d.ts +14 -12
  80. package/dist/types/applicationRoles.d.ts +438 -0
  81. package/dist/types/client/accountEmail.d.ts +44 -0
  82. package/dist/types/client/accountGraph.d.ts +203 -0
  83. package/dist/types/client/agentKeys.d.ts +113 -0
  84. package/dist/types/client/check.d.ts +187 -0
  85. package/dist/types/client/deviceBoot.d.ts +6 -0
  86. package/dist/types/client/deviceDirectory.d.ts +134 -0
  87. package/dist/types/client/deviceSession.d.ts +91 -0
  88. package/dist/types/client/externalIdentity.d.ts +14 -0
  89. package/dist/types/client/identity.d.ts +8 -0
  90. package/dist/types/client/identityLink.d.ts +21 -0
  91. package/dist/types/client/identityProof.d.ts +73 -0
  92. package/dist/types/client/index.d.ts +37 -0
  93. package/dist/types/client/organizations.d.ts +167 -0
  94. package/dist/types/client/products.d.ts +145 -0
  95. package/dist/types/client/recommendations.d.ts +27 -0
  96. package/dist/types/client/reputation.d.ts +28 -0
  97. package/dist/types/client/safety.d.ts +213 -0
  98. package/dist/types/client/sessionStatus.d.ts +19 -0
  99. package/dist/types/client/signIn.d.ts +107 -0
  100. package/dist/types/client/userResponse.d.ts +7 -0
  101. package/dist/types/client/username.d.ts +126 -0
  102. package/dist/types/deviceDirectory.d.ts +28 -28
  103. package/dist/types/deviceSession.d.ts +5 -16
  104. package/dist/types/email/messages.d.ts +2 -2
  105. package/dist/types/externalIdentity.d.ts +15 -15
  106. package/dist/types/identityLink.d.ts +3 -11
  107. package/dist/types/identityProof.d.ts +2 -65
  108. package/dist/types/index.d.ts +5 -2
  109. package/dist/types/inference/accountBilling.d.ts +2 -2
  110. package/dist/types/inference/catalogue.d.ts +22 -22
  111. package/dist/types/inference/decisions.d.ts +10 -10
  112. package/dist/types/inference/embeddings.d.ts +16 -16
  113. package/dist/types/inference/errors.d.ts +8 -8
  114. package/dist/types/inference/inbox.d.ts +8 -8
  115. package/dist/types/inference/privateAutoExecution.d.ts +6 -6
  116. package/dist/types/inference/providerConnection.d.ts +4 -4
  117. package/dist/types/inference/realtime.d.ts +92 -92
  118. package/dist/types/inference/request.d.ts +48 -48
  119. package/dist/types/inference/streamEvents.d.ts +16 -16
  120. package/dist/types/inference/usage.d.ts +4 -4
  121. package/dist/types/oauth.d.ts +2 -2
  122. package/dist/types/organizations.d.ts +8 -10
  123. package/dist/types/products/access.d.ts +4 -4
  124. package/dist/types/products/billing.d.ts +3 -0
  125. package/dist/types/reputation.d.ts +1 -11
  126. package/dist/types/safety.d.ts +2374 -2
  127. package/dist/types/serviceToken.d.ts +11 -0
  128. package/dist/types/sessionStatus.d.ts +2 -2
  129. package/dist/types/signIn.d.ts +11 -94
  130. package/dist/types/userResponse.d.ts +22 -22
  131. package/dist/types/username.d.ts +1 -96
  132. package/package.json +24 -20
  133. package/dist/cjs/.tsbuildinfo +0 -1
  134. package/dist/esm/.tsbuildinfo +0 -1
  135. package/dist/types/.tsbuildinfo +0 -1
@@ -0,0 +1,173 @@
1
+ "use strict";
2
+ /**
3
+ * The username policy, without Zod. Schemas: `../username.ts`.
4
+ *
5
+ * Part of `@oxy.so/contracts/client`: never import `zod` here (see `./check.ts`).
6
+ */
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ exports.botUsernameCheck = exports.usernameCheck = exports.BOT_USERNAME_INVALID_MESSAGE = exports.BOT_USERNAME_SUFFIX = exports.USERNAME_PATTERN = exports.USERNAME_PATTERN_SOURCE = exports.NUMERIC_USERNAME_MESSAGE = exports.RESERVED_USERNAME_SEGMENTS = exports.RESERVED_USERNAME_MESSAGE = exports.RESERVED_USERNAMES = exports.USERNAME_INVALID_MESSAGE = exports.USERNAME_MAX_LENGTH = exports.USERNAME_MIN_LENGTH = void 0;
9
+ exports.stripDisallowedUsernameCharacters = stripDisallowedUsernameCharacters;
10
+ exports.applyBotUsernameSuffix = applyBotUsernameSuffix;
11
+ exports.usernameCheckForAccountKind = usernameCheckForAccountKind;
12
+ const check_1 = require("./check");
13
+ /** Shortest storable handle. `oxy` sets the floor. */
14
+ exports.USERNAME_MIN_LENGTH = 3;
15
+ /** Longest storable handle, and the `maxLength` an input field should carry. */
16
+ exports.USERNAME_MAX_LENGTH = 30;
17
+ /** The 400 / inline-validation copy for every path that rejects a handle. */
18
+ exports.USERNAME_INVALID_MESSAGE = 'Username must be 3-30 characters, use only letters, numbers, hyphens and underscores, ' +
19
+ 'start and end with a letter or number, and never repeat a separator';
20
+ /**
21
+ * Exact-match handles nobody may newly claim, regardless of account kind.
22
+ *
23
+ * This is NOT a namespace tightening like the bot suffix — it is a list of
24
+ * names withheld from `users_lower_username_key` before anybody asks for
25
+ * them. Compared against the same normalization the unique index applies
26
+ * (`lower(btrim(username))`), so `Admin`, ` ADMIN ` and `admin` are the one
27
+ * name this list means.
28
+ *
29
+ * `oxy`, `mention`, `homiio`, `clarity`, `faircoin`, `astro` and `mercaria`
30
+ * are deliberately NOT here: each already has an `organization`/`project`
31
+ * row, so the unique index already refuses a second one, and `oxy` is the
32
+ * name `USERNAME_MIN_LENGTH` is pinned against in
33
+ * `__tests__/username.test.ts` — listing it would make
34
+ * `usernameSchema.safeParse('oxy')` fail and falsify that comment. A brand
35
+ * with no account of its own yet (measured 2026-09-18: Alia, Allo, TNP,
36
+ * Kaana, Bloom) has no row to protect it, so it is listed until one exists.
37
+ */
38
+ exports.RESERVED_USERNAMES = new Set([
39
+ // Oxy product lines with no account row of their own yet.
40
+ 'alia',
41
+ 'allo',
42
+ 'tnp',
43
+ 'kaana',
44
+ 'bloom',
45
+ // System / role words a signup impersonating staff or Oxy itself would reach for.
46
+ 'admin',
47
+ 'administrator',
48
+ 'root',
49
+ 'superadmin',
50
+ 'super',
51
+ 'superuser',
52
+ 'support',
53
+ 'staff',
54
+ 'moderator',
55
+ 'mod',
56
+ 'security',
57
+ 'system',
58
+ 'official',
59
+ 'help',
60
+ 'noreply',
61
+ 'anonymous',
62
+ 'everyone',
63
+ 'owner',
64
+ ]);
65
+ /** The 400 / inline-validation copy for a handle on {@link RESERVED_USERNAMES}. */
66
+ exports.RESERVED_USERNAME_MESSAGE = 'This username is reserved and cannot be registered';
67
+ /**
68
+ * {@link RESERVED_USERNAMES}, minus `alia`, checked against each `-`/`_`
69
+ * separated SEGMENT of a candidate rather than the whole string — so
70
+ * `official-oxy`, `super-admin` and `team-kaana` are refused the same as the
71
+ * bare words, without banning every word that merely CONTAINS one as a
72
+ * substring (`superman`, `modern`, `grassroot`, `homeowner` all stay legal:
73
+ * none of them separates the reserved word from the rest with `-` or `_`).
74
+ *
75
+ * `alia` is excluded because `alia-` is the live internal-cost-centre
76
+ * namespace: `alia-production-chat` is a minted account and
77
+ * `alia-research` / `alia-voice` / `alia-evaluations` are pinned as legal
78
+ * slugs in `__tests__/username.test.ts` and `internalCostCenterSpecs.test.ts`.
79
+ * Segment-matching `alia` would refuse all four. The bare word `alia` is
80
+ * still refused — {@link RESERVED_USERNAMES} above catches it exactly.
81
+ */
82
+ exports.RESERVED_USERNAME_SEGMENTS = new Set([...exports.RESERVED_USERNAMES].filter((word) => word !== 'alia'));
83
+ /** The 400 / inline-validation copy for a handle that is only digits. */
84
+ exports.NUMERIC_USERNAME_MESSAGE = 'Username cannot be only numbers';
85
+ /**
86
+ * Alphanumeric runs joined by single separators, as a SOURCE string.
87
+ *
88
+ * A string rather than a literal because the OpenAPI docblocks that publish this
89
+ * rule (`POST /auth/register`, `PUT /users/:userId`) must quote it verbatim, and
90
+ * `usernamePolicySingleSource.test.ts` compares them against THIS constant. A
91
+ * published `pattern:` that drifts from the enforced rule is a lie told to every
92
+ * client that generates from the spec, and it is exactly the kind of copy nobody
93
+ * notices going stale.
94
+ *
95
+ * Deliberately NOT re-exported from the package barrel: it exists for the
96
+ * schema below and for that one gate. Anything validating a username uses
97
+ * {@link usernameSchema}, so there is no second way to ask the question.
98
+ *
99
+ * Written as an unambiguous alternation rather than a lookahead: every character
100
+ * belongs to exactly one branch, so matching is linear and there is no
101
+ * backtracking to bound. It also carries no `\p{…}` property escape, which
102
+ * mobile Hermes throws on at runtime — this module is reachable from every React
103
+ * Native consumer.
104
+ */
105
+ exports.USERNAME_PATTERN_SOURCE = '^[A-Za-z0-9]+(?:[-_][A-Za-z0-9]+)*$';
106
+ exports.USERNAME_PATTERN = new RegExp(exports.USERNAME_PATTERN_SOURCE);
107
+ /**
108
+ * Drop the characters the policy forbids, for an input field that filters
109
+ * keystrokes.
110
+ *
111
+ * This is a TYPING aid and nothing else — the result still has to pass
112
+ * {@link usernameSchema}, which is what decides. It does not lower-case (case is
113
+ * preserved, see the header) and it cannot repair a name: a value that is too
114
+ * short, edge-separated or doubly-separated comes back unchanged and fails
115
+ * validation with a message, which is the outcome the coercing rules this
116
+ * replaces used to hide.
117
+ */
118
+ function stripDisallowedUsernameCharacters(input) {
119
+ return input.replace(/[^A-Za-z0-9_-]/g, '');
120
+ }
121
+ /**
122
+ * The label a bot's handle ends in — the ONE exception the policy carries.
123
+ *
124
+ * Lower-case here because it is what a generator appends; the comparison that
125
+ * enforces it folds case, so `MyBot` satisfies it just as `mybot` does.
126
+ *
127
+ * Deliberately NOT re-exported from the package barrel, for the same reason
128
+ * {@link USERNAME_PATTERN_SOURCE} is not: it exists for the schema and the
129
+ * generator aid below. A consumer that wants to SAY the rule uses
130
+ * {@link BOT_USERNAME_INVALID_MESSAGE}, which already quotes it, and one that
131
+ * wants to APPLY it uses {@link applyBotUsernameSuffix} — so there is no second
132
+ * way to spell the check.
133
+ */
134
+ exports.BOT_USERNAME_SUFFIX = 'bot';
135
+ /** The 400 / inline-validation copy for a bot handle that carries no label. */
136
+ exports.BOT_USERNAME_INVALID_MESSAGE = `A bot account's username must end in "${exports.BOT_USERNAME_SUFFIX}"`;
137
+ /**
138
+ * Label a proposed bot handle, so a generator PROPOSES something the server will
139
+ * accept.
140
+ *
141
+ * Alia builds an agent's handle from its display name; without this it would
142
+ * propose `garden-helper` for a bot and be 400ed on submit, which is the same
143
+ * "suggest, then refuse" defect the minimum length already caused once.
144
+ *
145
+ * It appends and never inserts: a separator is the caller's choice, so
146
+ * `garden-helper` becomes `garden-helperbot` while a caller who typed
147
+ * `garden-helper-` gets `garden-helper-bot`. It truncates to leave room rather
148
+ * than overflowing {@link USERNAME_MAX_LENGTH}.
149
+ *
150
+ * Like {@link stripDisallowedUsernameCharacters} it is an aid, not a decision: it
151
+ * cannot repair a handle the base policy refuses, and the result still has to
152
+ * pass {@link botUsernameSchema}.
153
+ */
154
+ function applyBotUsernameSuffix(candidate) {
155
+ const trimmed = candidate.trim();
156
+ if (trimmed.toLowerCase().endsWith(exports.BOT_USERNAME_SUFFIX)) {
157
+ return trimmed;
158
+ }
159
+ return trimmed.slice(0, exports.USERNAME_MAX_LENGTH - exports.BOT_USERNAME_SUFFIX.length) + exports.BOT_USERNAME_SUFFIX;
160
+ }
161
+ /* -------------------------------------------------------------------------- */
162
+ /* Checks */
163
+ /* -------------------------------------------------------------------------- */
164
+ /** The username policy as a check — the twin of `usernameSchema`, same messages. */
165
+ exports.usernameCheck = (0, check_1.refine)((0, check_1.refine)((0, check_1.refine)((0, check_1.string)(check_1.trim, (0, check_1.minLength)(exports.USERNAME_MIN_LENGTH, exports.USERNAME_INVALID_MESSAGE), (0, check_1.maxLength)(exports.USERNAME_MAX_LENGTH, exports.USERNAME_INVALID_MESSAGE), (0, check_1.pattern)(exports.USERNAME_PATTERN, exports.USERNAME_INVALID_MESSAGE)), (username) => !/^[0-9]+$/.test(username), exports.NUMERIC_USERNAME_MESSAGE), (username) => !exports.RESERVED_USERNAMES.has(username.toLowerCase()), exports.RESERVED_USERNAME_MESSAGE), (username) => !username
166
+ .split(/[-_]/)
167
+ .some((segment) => exports.RESERVED_USERNAME_SEGMENTS.has(segment.toLowerCase())), exports.RESERVED_USERNAME_MESSAGE);
168
+ /** A bot's username: the policy plus the `bot` suffix — the twin of `botUsernameSchema`. */
169
+ exports.botUsernameCheck = (0, check_1.refine)(exports.usernameCheck, (username) => username.toLowerCase().endsWith(exports.BOT_USERNAME_SUFFIX), exports.BOT_USERNAME_INVALID_MESSAGE);
170
+ /** The twin of `usernameSchemaForAccountKind`. */
171
+ function usernameCheckForAccountKind(kind) {
172
+ return kind === 'bot' ? exports.botUsernameCheck : exports.usernameCheck;
173
+ }
@@ -1,7 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.deviceJoinResponseSchema = exports.deviceJoinRequestSchema = exports.deviceJoinCodeResponseSchema = exports.deviceJoinCodeRequestSchema = exports.deviceRegisterResponseSchema = exports.deviceProofSchema = exports.deviceBackgroundTokenResponseSchema = exports.deviceBackgroundTokenRequestSchema = exports.deviceBackgroundCredentialResponseSchema = exports.sessionAccountsChangedEventSchema = exports.sessionAccountsChangedReasonSchema = exports.SESSION_ACCOUNTS_CHANGED_EVENT = exports.deviceTokenMintResponseSchema = exports.deviceTokenMintRequestSchema = exports.deviceSessionSyncSchema = exports.activeTokenSchema = exports.deviceSessionStateSchema = exports.sessionAccountSchema = void 0;
3
+ exports.deviceJoinResponseSchema = exports.deviceJoinRequestSchema = exports.deviceJoinCodeResponseSchema = exports.deviceJoinCodeRequestSchema = exports.deviceRegisterResponseSchema = exports.deviceProofSchema = exports.deviceBackgroundTokenResponseSchema = exports.deviceBackgroundTokenRequestSchema = exports.deviceBackgroundCredentialResponseSchema = exports.sessionAccountsChangedEventSchema = exports.sessionAccountsChangedReasonSchema = exports.deviceTokenMintResponseSchema = exports.deviceTokenMintRequestSchema = exports.deviceSessionSyncSchema = exports.activeTokenSchema = exports.deviceSessionStateSchema = exports.sessionAccountSchema = exports.SESSION_ACCOUNTS_CHANGED_EVENT = void 0;
4
4
  const zod_1 = require("zod");
5
+ var deviceSession_1 = require("./client/deviceSession");
6
+ Object.defineProperty(exports, "SESSION_ACCOUNTS_CHANGED_EVENT", { enumerable: true, get: function () { return deviceSession_1.SESSION_ACCOUNTS_CHANGED_EVENT; } });
5
7
  exports.sessionAccountSchema = zod_1.z.object({
6
8
  accountId: zod_1.z.string(),
7
9
  sessionId: zod_1.z.string(),
@@ -61,21 +63,6 @@ exports.deviceTokenMintResponseSchema = zod_1.z.object({
61
63
  nextDeviceSecret: zod_1.z.string(),
62
64
  state: exports.deviceSessionStateSchema,
63
65
  });
64
- /* -------------------------------------------------------------------------- */
65
- /* Instant cross-app session sync (token-free socket signal) */
66
- /* -------------------------------------------------------------------------- */
67
- /**
68
- * Name of the token-free Socket.IO event emitted to room `user:<userId>` on
69
- * every DeviceSession mutation that changes what is signed in for that user.
70
- *
71
- * This is a pure SIGNAL — it carries NO access token, NO deviceSecret and NO
72
- * account bodies. A client that receives it re-fetches its authenticated
73
- * session/account state (`GET /session/device/state`, `GET /accounts`). Unlike
74
- * `session_state` (scoped to `device:<deviceId>`, i.e. a single origin), this
75
- * reaches ALL of a user's connected sockets across their devices/origins so
76
- * every Oxy app reflects an add / switch / signout instantly.
77
- */
78
- exports.SESSION_ACCOUNTS_CHANGED_EVENT = 'session_accounts_changed';
79
66
  /**
80
67
  * Why the signed-in set changed:
81
68
  * - `login` — a brand-new session was minted for the user (QR / cross-app authorize)
@@ -1,8 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.identityLinkCompleteRequestSchema = exports.identityLinkProofRequestSchema = exports.identityLinkStateSchema = exports.identityLinkCreateResponseSchema = exports.identityLinkIdSchema = exports.IDENTITY_LINK_QR_PREFIX = exports.IDENTITY_LINK_STATUSES = void 0;
4
- exports.buildIdentityLinkQrPayload = buildIdentityLinkQrPayload;
5
- exports.parseIdentityLinkQrPayload = parseIdentityLinkQrPayload;
3
+ exports.identityLinkCompleteRequestSchema = exports.identityLinkProofRequestSchema = exports.identityLinkStateSchema = exports.identityLinkCreateResponseSchema = exports.identityLinkIdSchema = exports.parseIdentityLinkQrPayload = exports.buildIdentityLinkQrPayload = exports.IDENTITY_LINK_QR_PREFIX = exports.IDENTITY_LINK_STATUSES = void 0;
6
4
  /**
7
5
  * Linking Commons to an account without a key (ADR 0029 D3) — the two-device
8
6
  * relay.
@@ -31,45 +29,26 @@ exports.parseIdentityLinkQrPayload = parseIdentityLinkQrPayload;
31
29
  const zod_1 = require("zod");
32
30
  const identityProof_1 = require("./identityProof");
33
31
  const signIn_1 = require("./signIn");
34
- exports.IDENTITY_LINK_STATUSES = ['pending', 'signed', 'completed', 'cancelled'];
35
- /** The scheme and host Commons routes a link QR to. */
36
- exports.IDENTITY_LINK_QR_PREFIX = 'oxycommons://link';
37
- const LINK_ID = /^[0-9a-f]{32}$/;
38
- const CHALLENGE = /^[0-9a-f]{64}$/;
32
+ // The Zod-free half of this contract lives in `./client/` (`@oxy.so/contracts/client`);
33
+ // it is re-exported here so the root entry is unchanged.
34
+ const identityLink_1 = require("./client/identityLink");
35
+ var identityLink_2 = require("./client/identityLink");
36
+ Object.defineProperty(exports, "IDENTITY_LINK_STATUSES", { enumerable: true, get: function () { return identityLink_2.IDENTITY_LINK_STATUSES; } });
37
+ Object.defineProperty(exports, "IDENTITY_LINK_QR_PREFIX", { enumerable: true, get: function () { return identityLink_2.IDENTITY_LINK_QR_PREFIX; } });
38
+ Object.defineProperty(exports, "buildIdentityLinkQrPayload", { enumerable: true, get: function () { return identityLink_2.buildIdentityLinkQrPayload; } });
39
+ Object.defineProperty(exports, "parseIdentityLinkQrPayload", { enumerable: true, get: function () { return identityLink_2.parseIdentityLinkQrPayload; } });
39
40
  exports.identityLinkIdSchema = zod_1.z
40
41
  .string()
41
42
  .trim()
42
- .regex(LINK_ID, 'linkId must be 32 lowercase hex characters');
43
- /** The QR auth.oxy.so shows: the request's id and the challenge Commons signs. */
44
- function buildIdentityLinkQrPayload(linkId, challenge) {
45
- return `${exports.IDENTITY_LINK_QR_PREFIX}?id=${linkId}&c=${challenge}`;
46
- }
47
- /** The request a scanned code names, or `null` for anything that is not a link QR. */
48
- function parseIdentityLinkQrPayload(raw) {
49
- const value = raw.trim();
50
- if (!value.startsWith(`${exports.IDENTITY_LINK_QR_PREFIX}?`))
51
- return null;
52
- // Parsed by hand: React Native's `URLSearchParams` does not implement `get`.
53
- const params = new Map();
54
- for (const pair of value.slice(exports.IDENTITY_LINK_QR_PREFIX.length + 1).split('&')) {
55
- const separator = pair.indexOf('=');
56
- if (separator > 0)
57
- params.set(pair.slice(0, separator), pair.slice(separator + 1));
58
- }
59
- const linkId = params.get('id') ?? '';
60
- const challenge = params.get('c') ?? '';
61
- if (!LINK_ID.test(linkId) || !CHALLENGE.test(challenge))
62
- return null;
63
- return { linkId, challenge };
64
- }
43
+ .regex(identityLink_1.LINK_ID, 'linkId must be 32 lowercase hex characters');
65
44
  exports.identityLinkCreateResponseSchema = zod_1.z.object({
66
45
  linkId: exports.identityLinkIdSchema,
67
- challenge: zod_1.z.string().regex(CHALLENGE),
46
+ challenge: zod_1.z.string().regex(identityLink_1.CHALLENGE),
68
47
  expiresAt: zod_1.z.number().int().positive(),
69
- qrPayload: zod_1.z.string().startsWith(exports.IDENTITY_LINK_QR_PREFIX),
48
+ qrPayload: zod_1.z.string().startsWith(identityLink_1.IDENTITY_LINK_QR_PREFIX),
70
49
  });
71
50
  exports.identityLinkStateSchema = zod_1.z.object({
72
- status: zod_1.z.enum(exports.IDENTITY_LINK_STATUSES),
51
+ status: zod_1.z.enum(identityLink_1.IDENTITY_LINK_STATUSES),
73
52
  userId: zod_1.z.string().min(1),
74
53
  username: zod_1.z.string().nullable(),
75
54
  publicKey: zod_1.z.string().nullable(),
@@ -1,8 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.identityRootStatusSchema = exports.IDENTITY_ERROR_CODES = exports.identityProofChallengeResponseSchema = exports.identityProofChallengeRequestSchema = exports.identityProofSchema = exports.IDENTITY_PROOF_ACTION_VALUES = exports.IDENTITY_PROOF_ACTIONS = exports.IDENTITY_PROOF_CHALLENGE_TTL_MS = exports.IDENTITY_PROOF_AUDIENCE = exports.IDENTITY_PROOF_DOMAIN = exports.IDENTITY_PROOF_VERSION = void 0;
4
- exports.canonicalJson = canonicalJson;
5
- exports.buildIdentityProofMessage = buildIdentityProofMessage;
3
+ exports.identityRootStatusSchema = exports.identityProofChallengeResponseSchema = exports.identityProofChallengeRequestSchema = exports.identityProofSchema = exports.IDENTITY_ERROR_CODES = exports.buildIdentityProofMessage = exports.canonicalJson = exports.IDENTITY_PROOF_ACTION_VALUES = exports.IDENTITY_PROOF_ACTIONS = exports.IDENTITY_PROOF_CHALLENGE_TTL_MS = exports.IDENTITY_PROOF_AUDIENCE = exports.IDENTITY_PROOF_DOMAIN = exports.IDENTITY_PROOF_VERSION = void 0;
6
4
  /**
7
5
  * Identity proof contract — the ONE signed format for operations on a personal root.
8
6
  *
@@ -21,121 +19,35 @@ exports.buildIdentityProofMessage = buildIdentityProofMessage;
21
19
  * primitive and passes the hex digest in).
22
20
  */
23
21
  const zod_1 = require("zod");
24
- exports.IDENTITY_PROOF_VERSION = 2;
25
- exports.IDENTITY_PROOF_DOMAIN = 'oxy-identity-proof';
26
- /** The audience every API-verified identity proof names. */
27
- exports.IDENTITY_PROOF_AUDIENCE = 'oxy-api/identity';
28
- /** How long a proof challenge lives: one interactive ceremony. */
29
- exports.IDENTITY_PROOF_CHALLENGE_TTL_MS = 5 * 60 * 1000;
30
- /**
31
- * Everything a root proof may authorize. A challenge is minted for exactly one
32
- * action and spent only by a proof for that action.
33
- */
34
- exports.IDENTITY_PROOF_ACTIONS = {
35
- /**
36
- * Link Commons' root to an account that has none (`POST /auth/link`).
37
- * The account becomes self-custodied and its email is deleted
38
- * (ADR 0029 D3).
39
- */
40
- link: 'link_identity',
41
- };
42
- exports.IDENTITY_PROOF_ACTION_VALUES = Object.values(exports.IDENTITY_PROOF_ACTIONS);
43
- const HEX_DIGEST = /^[0-9a-f]{64}$/;
44
- const ROOT_KEY = /^04[0-9a-f]{128}$/;
45
- const CHALLENGE = /^[0-9a-f]{64}$/;
46
- /**
47
- * Canonical JSON: object keys sorted by UTF-16 code unit, no whitespace,
48
- * `undefined` members omitted, arrays in order. Numbers must be finite. This is
49
- * the ONLY serializer for anything digested into a proof.
50
- */
51
- function canonicalJson(value) {
52
- if (value === null)
53
- return 'null';
54
- switch (typeof value) {
55
- case 'string':
56
- case 'boolean':
57
- return JSON.stringify(value);
58
- case 'number':
59
- if (!Number.isFinite(value))
60
- throw new Error('canonicalJson: non-finite number');
61
- return JSON.stringify(value);
62
- case 'object': {
63
- if (Array.isArray(value)) {
64
- return `[${value.map((entry) => (entry === undefined ? 'null' : canonicalJson(entry))).join(',')}]`;
65
- }
66
- const record = value;
67
- const keys = Object.keys(record)
68
- .filter((key) => record[key] !== undefined)
69
- .sort();
70
- return `{${keys.map((key) => `${JSON.stringify(key)}:${canonicalJson(record[key])}`).join(',')}}`;
71
- }
72
- default:
73
- throw new Error(`canonicalJson: unsupported ${typeof value}`);
74
- }
75
- }
76
- /**
77
- * The exact bytes a root signs. Throws on a malformed claim rather than signing
78
- * (or verifying) something ambiguous.
79
- */
80
- function buildIdentityProofMessage(claims) {
81
- if (!exports.IDENTITY_PROOF_ACTION_VALUES.includes(claims.action))
82
- throw new Error('identity proof: unknown action');
83
- if (!claims.subject || !claims.actor)
84
- throw new Error('identity proof: subject and actor are required');
85
- if (!ROOT_KEY.test(claims.rootPublicKey))
86
- throw new Error('identity proof: rootPublicKey must be canonical');
87
- if (claims.payloadDigest !== null && !HEX_DIGEST.test(claims.payloadDigest)) {
88
- throw new Error('identity proof: payloadDigest must be a lowercase SHA-256 hex digest');
89
- }
90
- if (claims.expectedRevision !== null &&
91
- (!Number.isSafeInteger(claims.expectedRevision) || claims.expectedRevision < 0)) {
92
- throw new Error('identity proof: expectedRevision must be a non-negative integer');
93
- }
94
- if (!CHALLENGE.test(claims.challenge))
95
- throw new Error('identity proof: challenge must be 64 lowercase hex characters');
96
- if (!Number.isSafeInteger(claims.expiresAt) || claims.expiresAt <= 0)
97
- throw new Error('identity proof: expiresAt must be unix milliseconds');
98
- return canonicalJson({
99
- v: exports.IDENTITY_PROOF_VERSION,
100
- domain: exports.IDENTITY_PROOF_DOMAIN,
101
- action: claims.action,
102
- subject: claims.subject,
103
- actor: claims.actor,
104
- rootPublicKey: claims.rootPublicKey,
105
- payloadDigest: claims.payloadDigest,
106
- expectedRevision: claims.expectedRevision,
107
- audience: claims.audience,
108
- challenge: claims.challenge,
109
- expiresAt: claims.expiresAt,
110
- });
111
- }
22
+ // The Zod-free half of this contract lives in `./client/` (`@oxy.so/contracts/client`);
23
+ // it is re-exported here so the root entry is unchanged.
24
+ const identityProof_1 = require("./client/identityProof");
25
+ var identityProof_2 = require("./client/identityProof");
26
+ Object.defineProperty(exports, "IDENTITY_PROOF_VERSION", { enumerable: true, get: function () { return identityProof_2.IDENTITY_PROOF_VERSION; } });
27
+ Object.defineProperty(exports, "IDENTITY_PROOF_DOMAIN", { enumerable: true, get: function () { return identityProof_2.IDENTITY_PROOF_DOMAIN; } });
28
+ Object.defineProperty(exports, "IDENTITY_PROOF_AUDIENCE", { enumerable: true, get: function () { return identityProof_2.IDENTITY_PROOF_AUDIENCE; } });
29
+ Object.defineProperty(exports, "IDENTITY_PROOF_CHALLENGE_TTL_MS", { enumerable: true, get: function () { return identityProof_2.IDENTITY_PROOF_CHALLENGE_TTL_MS; } });
30
+ Object.defineProperty(exports, "IDENTITY_PROOF_ACTIONS", { enumerable: true, get: function () { return identityProof_2.IDENTITY_PROOF_ACTIONS; } });
31
+ Object.defineProperty(exports, "IDENTITY_PROOF_ACTION_VALUES", { enumerable: true, get: function () { return identityProof_2.IDENTITY_PROOF_ACTION_VALUES; } });
32
+ Object.defineProperty(exports, "canonicalJson", { enumerable: true, get: function () { return identityProof_2.canonicalJson; } });
33
+ Object.defineProperty(exports, "buildIdentityProofMessage", { enumerable: true, get: function () { return identityProof_2.buildIdentityProofMessage; } });
34
+ Object.defineProperty(exports, "IDENTITY_ERROR_CODES", { enumerable: true, get: function () { return identityProof_2.IDENTITY_ERROR_CODES; } });
112
35
  /** The proof as it travels: the signature plus the two claims the verifier cannot derive. */
113
36
  exports.identityProofSchema = zod_1.z.object({
114
- v: zod_1.z.literal(exports.IDENTITY_PROOF_VERSION),
115
- challenge: zod_1.z.string().trim().regex(CHALLENGE, 'challenge must be 64 lowercase hex characters'),
37
+ v: zod_1.z.literal(identityProof_1.IDENTITY_PROOF_VERSION),
38
+ challenge: zod_1.z.string().trim().regex(identityProof_1.CHALLENGE, 'challenge must be 64 lowercase hex characters'),
116
39
  expiresAt: zod_1.z.number().int().positive(),
117
40
  signature: zod_1.z.string().trim().min(1).max(512),
118
41
  });
119
42
  /** `POST /identity/proof-challenge` */
120
43
  exports.identityProofChallengeRequestSchema = zod_1.z.object({
121
- action: zod_1.z.enum(exports.IDENTITY_PROOF_ACTION_VALUES),
44
+ action: zod_1.z.enum(identityProof_1.IDENTITY_PROOF_ACTION_VALUES),
122
45
  });
123
46
  exports.identityProofChallengeResponseSchema = zod_1.z.object({
124
- challenge: zod_1.z.string().regex(CHALLENGE),
47
+ challenge: zod_1.z.string().regex(identityProof_1.CHALLENGE),
125
48
  expiresAt: zod_1.z.number().int().positive(),
126
49
  audience: zod_1.z.string().min(1),
127
50
  });
128
- /**
129
- * Stable error codes the root routes answer with (`error.code` in the API error
130
- * body). Clients map these through their localization, never the English message.
131
- */
132
- exports.IDENTITY_ERROR_CODES = {
133
- proofInvalid: 'IDENTITY_PROOF_INVALID',
134
- rootAlreadyLinked: 'IDENTITY_ROOT_ALREADY_LINKED',
135
- rootLinkedElsewhere: 'IDENTITY_ROOT_LINKED_ELSEWHERE',
136
- freshFactorRequired: 'IDENTITY_FRESH_FACTOR_REQUIRED',
137
- notPersonal: 'IDENTITY_NOT_PERSONAL_ACCOUNT',
138
- };
139
51
  exports.identityRootStatusSchema = zod_1.z.object({
140
52
  rootLinked: zod_1.z.boolean(),
141
53
  recoveryEmail: zod_1.z.string().nullable(),
package/dist/cjs/index.js CHANGED
@@ -37,9 +37,9 @@ exports.inferenceToolCallSchema = exports.inferenceContentPartSchema = exports.i
37
37
  exports.realtimeItemTruncateCommandSchema = exports.realtimeItemDeleteCommandSchema = exports.realtimeItemCreateCommandSchema = exports.realtimeSessionUpdateCommandSchema = exports.realtimeResponseParametersSchema = exports.realtimeConversationItemSchema = exports.realtimeContentPartSchema = exports.realtimeSessionRequestSchema = exports.realtimeClientMetadataSchema = exports.realtimeSessionLimitsSchema = exports.realtimeSessionConfigUpdateSchema = exports.realtimeSessionConfigSchema = exports.realtimeTranslationSchema = exports.realtimeInputTranscriptionSchema = exports.realtimeTurnDetectionSchema = exports.realtimeOutputModalitySchema = exports.realtimeAudioFormatSchema = exports.realtimeResponseIdSchema = exports.realtimeItemIdSchema = exports.realtimeCommandIdSchema = exports.MAX_REALTIME_RESUME_WINDOW_MS = exports.MAX_REALTIME_SESSION_AUDIO_BYTES = exports.MAX_REALTIME_SESSION_DURATION_MS = exports.MAX_REALTIME_AUDIO_FRAME_BASE64_LENGTH = exports.inferenceStreamEventSchema = exports.inferenceStreamDoneEventSchema = exports.inferenceFinishReasonSchema = exports.inferenceStreamErrorEventSchema = exports.inferenceStreamRouteSwitchEventSchema = exports.inferenceRouteSwitchReasonSchema = exports.inferenceRouteSwitchDetailSchema = exports.inferenceStreamUsageEventSchema = exports.inferenceStreamToolCallEventSchema = exports.inferenceStreamAudioEventSchema = exports.MAX_INFERENCE_AUDIO_BYTES = exports.inferenceAudioMediaTypeSchema = exports.inferenceStreamDeltaEventSchema = exports.inferenceStreamStartEventSchema = exports.inferenceAudioOutputParametersSchema = exports.inferenceSpeechParametersSchema = exports.inferenceRequestSchema = exports.clientRequestMetadataSchema = exports.responseFormatSchema = exports.toolChoiceSchema = exports.toolDefinitionSchema = exports.inferenceReasoningSchema = exports.samplingParametersSchema = exports.inferenceInputSchema = exports.inferenceMessageSchema = exports.inferenceMessageRoleSchema = void 0;
38
38
  exports.kaanaCredentialRotateMutationSchema = exports.kaanaCredentialCreateMutationSchema = exports.kaanaCredentialIdentitySchema = exports.kaanaCredentialOperationActionSchema = exports.kaanaCredentialOperationIdSchema = exports.kaanaCredentialHandleSchema = exports.providerConnectionScopeSchema = exports.usageRefundSchema = exports.usageRefundReasonSchema = exports.usageRefundSubjectSchema = exports.usageReceiptSchema = exports.normalizedUsageReportSchema = exports.inferenceRequestOutcomeSchema = exports.usageReservationSchema = exports.usageReservationStatusSchema = exports.usageReservationRequestSchema = exports.realtimeServerEventSchema = exports.realtimeSessionClosedEventSchema = exports.realtimeSessionCloseReasonSchema = exports.realtimeErrorEventSchema = exports.realtimeResponseDoneEventSchema = exports.realtimeResponseStatusSchema = exports.realtimeToolCallEventSchema = exports.realtimeTextDeltaEventSchema = exports.realtimeTranscriptDoneEventSchema = exports.realtimeTranscriptDeltaEventSchema = exports.realtimeTranscriptSourceSchema = exports.realtimeOutputAudioDoneEventSchema = exports.realtimeOutputAudioDeltaEventSchema = exports.realtimeResponseCreatedEventSchema = exports.realtimeInputAudioClearedEventSchema = exports.realtimeInputAudioCommittedEventSchema = exports.realtimeSpeechStoppedEventSchema = exports.realtimeSpeechStartedEventSchema = exports.realtimeItemTruncatedEventSchema = exports.realtimeItemDeletedEventSchema = exports.realtimeItemDoneEventSchema = exports.realtimeItemAddedEventSchema = exports.realtimeCommandAcceptedEventSchema = exports.realtimeSessionResumedEventSchema = exports.realtimeSessionUpdatedEventSchema = exports.realtimeSessionCreatedEventSchema = exports.realtimeClientCommandSchema = exports.realtimeSessionCloseCommandSchema = exports.realtimeSessionResumeCommandSchema = exports.realtimeResponseCancelCommandSchema = exports.realtimeResponseCreateCommandSchema = exports.realtimeInputAudioClearCommandSchema = exports.realtimeInputAudioCommitCommandSchema = exports.realtimeInputAudioAppendCommandSchema = void 0;
39
39
  exports.payAsYouGoEntitlementSchema = exports.productPlanSchema = exports.planAllowanceSchema = exports.LIVE_PRODUCT_PLAN_STATUSES = exports.productPlanStatusSchema = exports.PRODUCT_PLAN_STATUSES = exports.reconciliationReportSchema = exports.reconciliationRunSchema = exports.reconciliationDiscrepancySchema = exports.reconciliationRunStatusSchema = exports.RECONCILIATION_RUN_STATUSES = exports.reconciliationDiscrepancyKindSchema = exports.RECONCILIATION_DISCREPANCY_KINDS = exports.autoRechargeAttemptSchema = exports.autoRechargeStatusSchema = exports.AUTO_RECHARGE_STATUSES = exports.externalPaymentSchema = exports.externalPaymentKindSchema = exports.EXTERNAL_PAYMENT_KINDS = exports.externalPaymentProviderSchema = exports.EXTERNAL_PAYMENT_PROVIDERS = exports.billingInvoiceSchema = exports.billingInvoiceStatusSchema = exports.BILLING_INVOICE_STATUSES = exports.accountBillingStateSchema = exports.billingProfileSchema = exports.autoRechargeSchema = exports.billingProfileStatusSchema = exports.BILLING_PROFILE_STATUSES = exports.billingModeSchema = exports.BILLING_MODES = exports.providerConnectionSchema = exports.providerConnectionStatusSchema = exports.providerConnectionValidationSchema = exports.providerCredentialCustodyStateSchema = exports.providerCredentialValidationDeploymentSchema = exports.providerCredentialValidationOperationSchema = exports.kaanaCredentialValidationOutcomeSchema = exports.kaanaCredentialValidationFailureCodeSchema = exports.kaanaCredentialValidationOutcomeStateSchema = exports.kaanaCredentialValidationTaskSchema = exports.kaanaCredentialOutcomeSchema = exports.kaanaCredentialConflictOutcomeSchema = exports.kaanaCredentialAppliedOutcomeSchema = exports.kaanaCredentialOutcomeRequestSchema = exports.kaanaCredentialRevokeOutcomeRequestSchema = exports.kaanaCredentialRotateOutcomeRequestSchema = exports.kaanaCredentialCreateOutcomeRequestSchema = exports.kaanaCredentialMutationSchema = exports.kaanaCredentialRevokeMutationSchema = void 0;
40
- exports.inboxComposeRequestSchema = exports.emailAgentContextSchema = exports.emailContextMessageSchema = exports.emailContextMailboxSchema = exports.emailContextAddressSchema = exports.resolveCatalogInvocation = exports.matchCatalogInvocation = exports.findOverlappingCatalogInvocations = exports.catalogInvocationTemplatesEquivalent = exports.catalogInvocationsOverlap = exports.catalogInvocationPathParameters = exports.normalizedAppEventSchema = exports.catalogRegistrationSchema = exports.appCapabilityCatalogSchema = exports.catalogEventSchema = exports.catalogToolSchema = exports.auditEventSchema = exports.auditResultSchema = exports.policyDecisionSchema = exports.invocationPrincipalSchema = exports.capabilityTicketClaimsSchema = exports.automationDefinitionSchema = exports.automationDataFlowSchema = exports.automationActorSelectionSchema = exports.automationTriggerSchema = exports.delegationGrantSchema = exports.capabilityTicketRequestSchema = exports.capabilityCoordinatorSchema = exports.executionAuthorizationRefSchema = exports.capabilityCatalogBindingSchema = exports.grantLimitSchema = exports.toolGrantOverrideSchema = exports.resourceRefSchema = exports.foregroundExecutionAuthorizationInputSchema = exports.executionActorRefSchema = exports.actorRefSchema = exports.capabilityPackageSchema = exports.autonomyLevelSchema = exports.CAPABILITY_PACKAGES = exports.AUTONOMY_LEVELS = exports.costCenterUsageSchema = exports.providerCostSourceSchema = exports.PROVIDER_COST_SOURCES = exports.inferenceEconomicTreatmentSchema = exports.INFERENCE_ECONOMIC_TREATMENTS = exports.productEntitlementSchema = exports.costCenterSpendSchema = exports.costCenterSchema = exports.costCenterStatusSchema = exports.COST_CENTER_STATUSES = void 0;
41
- exports.inputSatisfiesCapabilityLimits = exports.canonicalCapabilityJson = exports.meteredGenerationSchema = exports.subjectProductAccessSchema = exports.productOfferSegmentSchema = exports.subjectProductGrantSnapshotSchema = exports.productAccessGrantSchema = exports.productSubscriptionSourceSchema = exports.productOfferSchema = exports.productBenefitSchema = exports.subjectProductAccessQuerySchema = exports.productDefinitionSchema = exports.privateAutoInferenceRequestSchema = exports.privateAutoOperationId = exports.privateAutoInputSchema = exports.privateAutoExecutionSchema = exports.privateAutoSourceApprovalSchema = exports.privateAutoPrincipalSchema = exports.PRIVATE_AUTO_QUESTION = exports.PRIVATE_AUTO_INSTRUCTIONS = exports.PRIVATE_AUTO_LIMITS = exports.PRIVATE_AUTO_REQUEST_ENVELOPE_VERSION = exports.PRIVATE_AUTO_EXECUTION_CONTRACT_VERSION = exports.scopedInferenceRequestSchema = exports.canonicalScopedExecutionJson = exports.scopedExecutionSchema = exports.scopedExecutionAudienceSchema = exports.SCOPED_REQUEST_ENVELOPE_VERSION = exports.SCOPED_EXECUTION_CONTRACT_VERSION = exports.decisionAnswersMatch = exports.decisionFitsGateway = exports.decisionInputBudget = exports.decisionFailureSchema = exports.decisionSuccessSchema = exports.decisionResultSchema = exports.decisionAnswerSchema = exports.decisionRequestSchema = exports.decisionInputSchema = exports.decisionQuestionSchema = exports.decisionEffortSchema = exports.inboxInferenceStreamEventSchema = exports.inboxThreadSummaryResponseSchema = exports.inboxSmartRepliesResponseSchema = exports.inboxNaturalSearchResponseSchema = exports.inboxInferenceTextResponseSchema = exports.inboxMessageInferenceParamsSchema = exports.inboxNaturalSearchRequestSchema = exports.INBOX_DAILY_BRIEF_SECTIONS = exports.inboxDailyBriefResponseSchema = exports.inboxDailyBriefRequestSchema = void 0;
42
- exports.personalPlanCatalogueSchema = exports.personalPlanDisplayPriceSchema = exports.productSubscriptionCancellationResultSchema = exports.cancelProductSubscriptionSchema = exports.subscriptionCreditGrantsResponseSchema = exports.subscriptionCreditGrantSchema = exports.productSubscriptionsResponseSchema = exports.productSubscriptionSummarySchema = exports.isLoopbackOrigin = void 0;
40
+ exports.resolveCatalogInvocation = exports.matchCatalogInvocation = exports.findOverlappingCatalogInvocations = exports.catalogInvocationTemplatesEquivalent = exports.catalogInvocationsOverlap = exports.catalogInvocationPathParameters = exports.normalizedAppEventSchema = exports.catalogRegistrationSchema = exports.appCapabilityCatalogSchema = exports.CATALOG_INTERNAL_TRANSPORTS = exports.catalogFeatureSchema = exports.catalogEventSchema = exports.catalogToolSchema = exports.auditEventSchema = exports.auditResultSchema = exports.policyDecisionSchema = exports.invocationPrincipalSchema = exports.capabilityTicketClaimsSchema = exports.automationDefinitionSchema = exports.automationDataFlowSchema = exports.automationActorSelectionSchema = exports.automationTriggerSchema = exports.agentRequesterCeilingSchema = exports.agentRequesterCeilingWriteSchema = exports.AGENT_REQUESTER_CEILING_AUTONOMY = exports.delegationGrantSchema = exports.capabilityTicketRequestSchema = exports.capabilityCoordinatorSchema = exports.executionAuthorizationRefSchema = exports.capabilityCatalogBindingSchema = exports.grantLimitSchema = exports.toolGrantOverrideSchema = exports.resourceRefSchema = exports.foregroundExecutionAuthorizationInputSchema = exports.executionActorRefSchema = exports.actorRefSchema = exports.capabilityPackageSchema = exports.autonomyLevelSchema = exports.CAPABILITY_PACKAGES = exports.AUTONOMY_LEVELS = exports.costCenterUsageSchema = exports.providerCostSourceSchema = exports.PROVIDER_COST_SOURCES = exports.inferenceEconomicTreatmentSchema = exports.INFERENCE_ECONOMIC_TREATMENTS = exports.productEntitlementSchema = exports.costCenterSpendSchema = exports.costCenterSchema = exports.costCenterStatusSchema = exports.COST_CENTER_STATUSES = void 0;
41
+ exports.subjectProductGrantSnapshotSchema = exports.productAccessGrantSchema = exports.productSubscriptionSourceSchema = exports.productOfferSchema = exports.productBenefitSchema = exports.subjectProductAccessQuerySchema = exports.productDefinitionSchema = exports.privateAutoInferenceRequestSchema = exports.privateAutoOperationId = exports.privateAutoInputSchema = exports.privateAutoExecutionSchema = exports.privateAutoSourceApprovalSchema = exports.privateAutoPrincipalSchema = exports.PRIVATE_AUTO_QUESTION = exports.PRIVATE_AUTO_INSTRUCTIONS = exports.PRIVATE_AUTO_LIMITS = exports.PRIVATE_AUTO_REQUEST_ENVELOPE_VERSION = exports.PRIVATE_AUTO_EXECUTION_CONTRACT_VERSION = exports.scopedInferenceRequestSchema = exports.canonicalScopedExecutionJson = exports.scopedExecutionSchema = exports.scopedExecutionAudienceSchema = exports.SCOPED_REQUEST_ENVELOPE_VERSION = exports.SCOPED_EXECUTION_CONTRACT_VERSION = exports.decisionAnswersMatch = exports.decisionFitsGateway = exports.decisionInputBudget = exports.decisionFailureSchema = exports.decisionSuccessSchema = exports.decisionResultSchema = exports.decisionAnswerSchema = exports.decisionRequestSchema = exports.decisionInputSchema = exports.decisionQuestionSchema = exports.decisionEffortSchema = exports.inboxInferenceStreamEventSchema = exports.inboxThreadSummaryResponseSchema = exports.inboxSmartRepliesResponseSchema = exports.inboxNaturalSearchResponseSchema = exports.inboxInferenceTextResponseSchema = exports.inboxMessageInferenceParamsSchema = exports.inboxNaturalSearchRequestSchema = exports.INBOX_DAILY_BRIEF_SECTIONS = exports.inboxDailyBriefResponseSchema = exports.inboxDailyBriefRequestSchema = exports.inboxComposeRequestSchema = exports.emailAgentContextSchema = exports.emailContextMessageSchema = exports.emailContextMailboxSchema = exports.emailContextAddressSchema = void 0;
42
+ exports.serviceTokenOptionsSchema = exports.serviceTokenScopesSchema = exports.personalPlanCatalogueSchema = exports.personalPlanDisplayPriceSchema = exports.productSubscriptionCancellationResultSchema = exports.cancelProductSubscriptionSchema = exports.subscriptionCreditGrantsResponseSchema = exports.subscriptionCreditGrantSchema = exports.productSubscriptionsResponseSchema = exports.productSubscriptionSummarySchema = exports.isLoopbackOrigin = exports.inputSatisfiesCapabilityLimits = exports.canonicalCapabilityJson = exports.meteredGenerationSchema = exports.subjectProductAccessSchema = exports.productOfferSegmentSchema = void 0;
43
43
  var accountGraph_1 = require("./accountGraph");
44
44
  Object.defineProperty(exports, "ACCOUNT_KINDS", { enumerable: true, get: function () { return accountGraph_1.ACCOUNT_KINDS; } });
45
45
  Object.defineProperty(exports, "accountKindSchema", { enumerable: true, get: function () { return accountGraph_1.accountKindSchema; } });
@@ -782,6 +782,9 @@ Object.defineProperty(exports, "executionAuthorizationRefSchema", { enumerable:
782
782
  Object.defineProperty(exports, "capabilityCoordinatorSchema", { enumerable: true, get: function () { return agency_1.capabilityCoordinatorSchema; } });
783
783
  Object.defineProperty(exports, "capabilityTicketRequestSchema", { enumerable: true, get: function () { return agency_1.capabilityTicketRequestSchema; } });
784
784
  Object.defineProperty(exports, "delegationGrantSchema", { enumerable: true, get: function () { return agency_1.delegationGrantSchema; } });
785
+ Object.defineProperty(exports, "AGENT_REQUESTER_CEILING_AUTONOMY", { enumerable: true, get: function () { return agency_1.AGENT_REQUESTER_CEILING_AUTONOMY; } });
786
+ Object.defineProperty(exports, "agentRequesterCeilingWriteSchema", { enumerable: true, get: function () { return agency_1.agentRequesterCeilingWriteSchema; } });
787
+ Object.defineProperty(exports, "agentRequesterCeilingSchema", { enumerable: true, get: function () { return agency_1.agentRequesterCeilingSchema; } });
785
788
  Object.defineProperty(exports, "automationTriggerSchema", { enumerable: true, get: function () { return agency_1.automationTriggerSchema; } });
786
789
  Object.defineProperty(exports, "automationActorSelectionSchema", { enumerable: true, get: function () { return agency_1.automationActorSelectionSchema; } });
787
790
  Object.defineProperty(exports, "automationDataFlowSchema", { enumerable: true, get: function () { return agency_1.automationDataFlowSchema; } });
@@ -793,6 +796,8 @@ Object.defineProperty(exports, "auditResultSchema", { enumerable: true, get: fun
793
796
  Object.defineProperty(exports, "auditEventSchema", { enumerable: true, get: function () { return agency_1.auditEventSchema; } });
794
797
  Object.defineProperty(exports, "catalogToolSchema", { enumerable: true, get: function () { return agency_1.catalogToolSchema; } });
795
798
  Object.defineProperty(exports, "catalogEventSchema", { enumerable: true, get: function () { return agency_1.catalogEventSchema; } });
799
+ Object.defineProperty(exports, "catalogFeatureSchema", { enumerable: true, get: function () { return agency_1.catalogFeatureSchema; } });
800
+ Object.defineProperty(exports, "CATALOG_INTERNAL_TRANSPORTS", { enumerable: true, get: function () { return agency_1.CATALOG_INTERNAL_TRANSPORTS; } });
796
801
  Object.defineProperty(exports, "appCapabilityCatalogSchema", { enumerable: true, get: function () { return agency_1.appCapabilityCatalogSchema; } });
797
802
  Object.defineProperty(exports, "catalogRegistrationSchema", { enumerable: true, get: function () { return agency_1.catalogRegistrationSchema; } });
798
803
  Object.defineProperty(exports, "normalizedAppEventSchema", { enumerable: true, get: function () { return agency_1.normalizedAppEventSchema; } });
@@ -823,6 +828,7 @@ Object.defineProperty(exports, "inboxInferenceStreamEventSchema", { enumerable:
823
828
  __exportStar(require("./externalIdentity"), exports);
824
829
  __exportStar(require("./linkedAccounts"), exports);
825
830
  __exportStar(require("./federationInstanceFetch"), exports);
831
+ __exportStar(require("./accountAccess"), exports);
826
832
  __exportStar(require("./notifications"), exports);
827
833
  __exportStar(require("./email/messages"), exports);
828
834
  __exportStar(require("./stickers"), exports);
@@ -889,3 +895,7 @@ Object.defineProperty(exports, "personalPlanCatalogueSchema", { enumerable: true
889
895
  __exportStar(require("./products/checkout"), exports);
890
896
  __exportStar(require("./organizations"), exports);
891
897
  __exportStar(require("./safety"), exports);
898
+ var serviceToken_1 = require("./serviceToken");
899
+ Object.defineProperty(exports, "serviceTokenScopesSchema", { enumerable: true, get: function () { return serviceToken_1.serviceTokenScopesSchema; } });
900
+ Object.defineProperty(exports, "serviceTokenOptionsSchema", { enumerable: true, get: function () { return serviceToken_1.serviceTokenOptionsSchema; } });
901
+ __exportStar(require("./applicationRoles"), exports);
@@ -1,46 +1,38 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.organizationCurationResultSchema = exports.organizationCurationSchema = exports.organizationErrorSchema = exports.ORGANIZATION_ERROR_CODES = exports.organizationMergeSchema = exports.organizationExternalResolutionSchema = exports.organizationExternalSchema = exports.organizationImportBatchResultSchema = exports.organizationImportBatchSchema = exports.organizationExternalInputSchema = exports.organizationClaimReviewSchema = exports.organizationClaimListSchema = exports.organizationClaimListQuerySchema = exports.organizationClaimDetailSchema = exports.organizationClaimSchema = exports.organizationClaimInputSchema = exports.organizationBatchSchema = exports.organizationBatchInputSchema = exports.organizationListSchema = exports.organizationSearchSchema = exports.organizationSchema = exports.updateOrganizationSchema = exports.createOrganizationSchema = exports.organizationNameSchema = exports.ORGANIZATION_NAME_MAX_LENGTH = exports.organizationAliasSchema = exports.ORGANIZATION_CLAIM_DECISIONS = exports.ORGANIZATION_ALIAS_KINDS = exports.ORGANIZATION_CLAIM_STATUSES = exports.ORGANIZATION_STATUSES = exports.ORGANIZATION_TYPES = void 0;
3
+ exports.organizationCurationResultSchema = exports.organizationCurationSchema = exports.organizationErrorSchema = exports.organizationMergeSchema = exports.organizationExternalResolutionSchema = exports.organizationExternalSchema = exports.organizationImportBatchResultSchema = exports.organizationImportBatchSchema = exports.organizationExternalInputSchema = exports.organizationClaimReviewSchema = exports.organizationClaimListSchema = exports.organizationClaimListQuerySchema = exports.organizationClaimDetailSchema = exports.organizationClaimSchema = exports.organizationClaimInputSchema = exports.organizationBatchSchema = exports.organizationBatchInputSchema = exports.organizationListSchema = exports.organizationSearchSchema = exports.organizationSchema = exports.updateOrganizationSchema = exports.createOrganizationSchema = exports.organizationNameSchema = exports.organizationAliasSchema = exports.ORGANIZATION_ERROR_CODES = exports.ORGANIZATION_NAME_MAX_LENGTH = exports.ORGANIZATION_CLAIM_DECISIONS = exports.ORGANIZATION_ALIAS_KINDS = exports.ORGANIZATION_CLAIM_STATUSES = exports.ORGANIZATION_STATUSES = exports.ORGANIZATION_TYPES = void 0;
4
4
  const zod_1 = require("zod");
5
- /** Real-world identity classification, independent of account topics and permissions. */
6
- exports.ORGANIZATION_TYPES = [
7
- 'business',
8
- 'nonprofit',
9
- 'public_body',
10
- 'community',
11
- 'other',
12
- ];
13
- exports.ORGANIZATION_STATUSES = ['active', 'inactive', 'merged', 'suppressed'];
14
- exports.ORGANIZATION_CLAIM_STATUSES = ['unclaimed', 'claimed'];
15
- exports.ORGANIZATION_ALIAS_KINDS = [
16
- 'name_variant',
17
- 'former_name',
18
- 'localized_name',
19
- 'marketing_name',
20
- 'misspelling',
21
- ];
22
- exports.ORGANIZATION_CLAIM_DECISIONS = ['pending', 'approved', 'rejected'];
5
+ // The Zod-free half of this contract lives in `./client/` (`@oxy.so/contracts/client`);
6
+ // it is re-exported here so the root entry is unchanged.
7
+ const organizations_1 = require("./client/organizations");
8
+ var organizations_2 = require("./client/organizations");
9
+ Object.defineProperty(exports, "ORGANIZATION_TYPES", { enumerable: true, get: function () { return organizations_2.ORGANIZATION_TYPES; } });
10
+ Object.defineProperty(exports, "ORGANIZATION_STATUSES", { enumerable: true, get: function () { return organizations_2.ORGANIZATION_STATUSES; } });
11
+ Object.defineProperty(exports, "ORGANIZATION_CLAIM_STATUSES", { enumerable: true, get: function () { return organizations_2.ORGANIZATION_CLAIM_STATUSES; } });
12
+ Object.defineProperty(exports, "ORGANIZATION_ALIAS_KINDS", { enumerable: true, get: function () { return organizations_2.ORGANIZATION_ALIAS_KINDS; } });
13
+ Object.defineProperty(exports, "ORGANIZATION_CLAIM_DECISIONS", { enumerable: true, get: function () { return organizations_2.ORGANIZATION_CLAIM_DECISIONS; } });
14
+ Object.defineProperty(exports, "ORGANIZATION_NAME_MAX_LENGTH", { enumerable: true, get: function () { return organizations_2.ORGANIZATION_NAME_MAX_LENGTH; } });
15
+ Object.defineProperty(exports, "ORGANIZATION_ERROR_CODES", { enumerable: true, get: function () { return organizations_2.ORGANIZATION_ERROR_CODES; } });
23
16
  const id = zod_1.z.string().min(1).max(128);
24
17
  const optionalText = (max) => zod_1.z.string().trim().min(1).max(max).nullable().optional();
25
18
  exports.organizationAliasSchema = zod_1.z
26
19
  .object({
27
20
  alias: zod_1.z.string().trim().min(1).max(300),
28
- kind: zod_1.z.enum(exports.ORGANIZATION_ALIAS_KINDS),
21
+ kind: zod_1.z.enum(organizations_1.ORGANIZATION_ALIAS_KINDS),
29
22
  language: zod_1.z.string().min(2).max(35).optional(),
30
23
  })
31
24
  .strict();
32
- exports.ORGANIZATION_NAME_MAX_LENGTH = 300;
33
25
  exports.organizationNameSchema = zod_1.z
34
26
  .string()
35
27
  .trim()
36
28
  .min(1)
37
- .max(exports.ORGANIZATION_NAME_MAX_LENGTH)
29
+ .max(organizations_1.ORGANIZATION_NAME_MAX_LENGTH)
38
30
  .refine((value) => !/[<>]/.test(value) &&
39
31
  Array.from(value).every((character) => character.charCodeAt(0) >= 32 && character.charCodeAt(0) !== 127), 'Organization name must be plain text');
40
32
  exports.createOrganizationSchema = zod_1.z
41
33
  .object({
42
34
  name: exports.organizationNameSchema,
43
- organizationType: zod_1.z.enum(exports.ORGANIZATION_TYPES),
35
+ organizationType: zod_1.z.enum(organizations_1.ORGANIZATION_TYPES),
44
36
  legalName: optionalText(300),
45
37
  websiteUrl: zod_1.z
46
38
  .string()
@@ -68,8 +60,8 @@ exports.organizationSchema = exports.createOrganizationSchema
68
60
  countryCode: zod_1.z.string().nullable(),
69
61
  aliases: zod_1.z.array(exports.organizationAliasSchema),
70
62
  verifiedDomains: zod_1.z.array(zod_1.z.string()),
71
- claimStatus: zod_1.z.enum(exports.ORGANIZATION_CLAIM_STATUSES),
72
- status: zod_1.z.enum(exports.ORGANIZATION_STATUSES),
63
+ claimStatus: zod_1.z.enum(organizations_1.ORGANIZATION_CLAIM_STATUSES),
64
+ status: zod_1.z.enum(organizations_1.ORGANIZATION_STATUSES),
73
65
  mergedIntoAccountId: id.nullable(),
74
66
  createdAt: zod_1.z.string().datetime(),
75
67
  updatedAt: zod_1.z.string().datetime(),
@@ -78,7 +70,7 @@ exports.organizationSchema = exports.createOrganizationSchema
78
70
  exports.organizationSearchSchema = zod_1.z
79
71
  .object({
80
72
  query: zod_1.z.string().trim().max(200).default(''),
81
- organizationType: zod_1.z.enum(exports.ORGANIZATION_TYPES).optional(),
73
+ organizationType: zod_1.z.enum(organizations_1.ORGANIZATION_TYPES).optional(),
82
74
  limit: zod_1.z.coerce.number().int().min(1).max(50).default(20),
83
75
  cursor: zod_1.z.string().min(1).max(2048).optional(),
84
76
  })
@@ -103,7 +95,7 @@ exports.organizationClaimSchema = zod_1.z
103
95
  id,
104
96
  accountId: id,
105
97
  claimantUserId: id,
106
- status: zod_1.z.enum(exports.ORGANIZATION_CLAIM_DECISIONS),
98
+ status: zod_1.z.enum(organizations_1.ORGANIZATION_CLAIM_DECISIONS),
107
99
  createdAt: zod_1.z.string().datetime(),
108
100
  })
109
101
  .strict();
@@ -116,7 +108,7 @@ exports.organizationClaimDetailSchema = exports.organizationClaimSchema
116
108
  .strict();
117
109
  exports.organizationClaimListQuerySchema = zod_1.z
118
110
  .object({
119
- status: zod_1.z.enum(exports.ORGANIZATION_CLAIM_DECISIONS).optional(),
111
+ status: zod_1.z.enum(organizations_1.ORGANIZATION_CLAIM_DECISIONS).optional(),
120
112
  limit: zod_1.z.coerce.number().int().min(1).max(50).default(20),
121
113
  cursor: zod_1.z.string().min(1).max(2048).optional(),
122
114
  })
@@ -171,23 +163,11 @@ exports.organizationMergeSchema = zod_1.z
171
163
  evidenceReference: zod_1.z.string().trim().min(1).max(1000),
172
164
  })
173
165
  .strict();
174
- exports.ORGANIZATION_ERROR_CODES = [
175
- 'bad_request',
176
- 'unauthorized',
177
- 'forbidden',
178
- 'not_found',
179
- 'unknown_route',
180
- 'conflict',
181
- 'validation_failed',
182
- 'rate_limited',
183
- 'internal_error',
184
- 'service_unavailable',
185
- ];
186
166
  exports.organizationErrorSchema = zod_1.z
187
167
  .object({
188
168
  error: zod_1.z
189
169
  .object({
190
- code: zod_1.z.enum(exports.ORGANIZATION_ERROR_CODES),
170
+ code: zod_1.z.enum(organizations_1.ORGANIZATION_ERROR_CODES),
191
171
  message: zod_1.z.string(),
192
172
  details: zod_1.z
193
173
  .record(zod_1.z.string(), zod_1.z.union([zod_1.z.string(), zod_1.z.number(), zod_1.z.boolean(), zod_1.z.null()]))