@oxy.so/contracts 5.8.0 → 6.0.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 (219) hide show
  1. package/dist/cjs/accountAccess.js +6 -5
  2. package/dist/cjs/accountEmail.js +13 -5
  3. package/dist/cjs/accountGraph.js +10 -9
  4. package/dist/cjs/accountName.js +3 -2
  5. package/dist/cjs/agency.js +91 -34
  6. package/dist/cjs/agentKeys.js +21 -17
  7. package/dist/cjs/appAssertions.js +14 -13
  8. package/dist/cjs/applicationRoles.js +19 -12
  9. package/dist/cjs/civic.js +10 -9
  10. package/dist/cjs/client/check.js +61 -53
  11. package/dist/cjs/consoleOnboarding.js +9 -4
  12. package/dist/cjs/contentClaims.js +23 -14
  13. package/dist/cjs/deviceDirectory.js +11 -9
  14. package/dist/cjs/deviceSession.js +27 -25
  15. package/dist/cjs/email/messages.js +20 -18
  16. package/dist/cjs/emailAgentContext.js +11 -9
  17. package/dist/cjs/externalIdentity.js +15 -11
  18. package/dist/cjs/federationInstanceFetch.js +12 -7
  19. package/dist/cjs/identity.js +19 -17
  20. package/dist/cjs/identityLink.js +6 -4
  21. package/dist/cjs/identityProof.js +6 -4
  22. package/dist/cjs/inboxPush.js +5 -4
  23. package/dist/cjs/index.js +15 -6
  24. package/dist/cjs/inference/accountBilling.js +35 -33
  25. package/dist/cjs/inference/aliaModelRelease.js +9 -7
  26. package/dist/cjs/inference/attribution.js +14 -12
  27. package/dist/cjs/inference/catalogue.js +35 -29
  28. package/dist/cjs/inference/economics.js +24 -19
  29. package/dist/cjs/inference/embeddings.js +9 -7
  30. package/dist/cjs/inference/entitlement.js +17 -15
  31. package/dist/cjs/inference/errors.js +15 -8
  32. package/dist/cjs/inference/identifiers.js +33 -21
  33. package/dist/cjs/inference/inbox.js +37 -35
  34. package/dist/cjs/inference/modelDocumentation.js +16 -14
  35. package/dist/cjs/inference/money.js +5 -4
  36. package/dist/cjs/inference/priceVersion.js +10 -5
  37. package/dist/cjs/inference/providerConnection.js +21 -14
  38. package/dist/cjs/inference/realtime.js +88 -47
  39. package/dist/cjs/inference/request.js +27 -25
  40. package/dist/cjs/inference/routingPolicy.js +12 -10
  41. package/dist/cjs/inference/streamEvents.js +22 -16
  42. package/dist/cjs/inference/usage.js +32 -15
  43. package/dist/cjs/keyRecovery.js +8 -6
  44. package/dist/cjs/keyRotation.js +5 -4
  45. package/dist/cjs/linkedAccounts.js +22 -18
  46. package/dist/cjs/moderationReputation.js +29 -27
  47. package/dist/cjs/notifications.js +25 -9
  48. package/dist/cjs/numberChecks.js +45 -0
  49. package/dist/cjs/oauth.js +14 -12
  50. package/dist/cjs/organizations.js +23 -21
  51. package/dist/cjs/products/access.js +10 -8
  52. package/dist/cjs/products/billing.js +10 -8
  53. package/dist/cjs/products/checkout.js +22 -10
  54. package/dist/cjs/products/plans.js +15 -10
  55. package/dist/cjs/protocol.js +6 -5
  56. package/dist/cjs/recommendations.js +27 -19
  57. package/dist/cjs/reputation.js +15 -13
  58. package/dist/cjs/safety.js +43 -27
  59. package/dist/cjs/serviceToken.js +81 -2
  60. package/dist/cjs/sessionRevocation.js +8 -6
  61. package/dist/cjs/signIn.js +42 -24
  62. package/dist/cjs/stickers.js +19 -15
  63. package/dist/cjs/stringChecks.js +70 -0
  64. package/dist/cjs/transparency.js +14 -12
  65. package/dist/cjs/updates.js +24 -22
  66. package/dist/cjs/userInvalidation.js +7 -5
  67. package/dist/cjs/userResponse.js +8 -7
  68. package/dist/cjs/username.js +7 -6
  69. package/dist/esm/accountAccess.js +4 -3
  70. package/dist/esm/accountEmail.js +13 -5
  71. package/dist/esm/accountGraph.js +8 -7
  72. package/dist/esm/accountName.js +3 -2
  73. package/dist/esm/agency.js +90 -33
  74. package/dist/esm/agentKeys.js +21 -17
  75. package/dist/esm/appAssertions.js +11 -10
  76. package/dist/esm/applicationRoles.js +16 -9
  77. package/dist/esm/civic.js +8 -7
  78. package/dist/esm/client/check.js +61 -53
  79. package/dist/esm/consoleOnboarding.js +7 -2
  80. package/dist/esm/contentClaims.js +23 -14
  81. package/dist/esm/deviceDirectory.js +11 -9
  82. package/dist/esm/deviceSession.js +27 -25
  83. package/dist/esm/email/messages.js +18 -16
  84. package/dist/esm/emailAgentContext.js +11 -9
  85. package/dist/esm/externalIdentity.js +15 -11
  86. package/dist/esm/federationInstanceFetch.js +10 -5
  87. package/dist/esm/identity.js +17 -15
  88. package/dist/esm/identityLink.js +6 -4
  89. package/dist/esm/identityProof.js +6 -4
  90. package/dist/esm/inboxPush.js +3 -2
  91. package/dist/esm/index.js +4 -2
  92. package/dist/esm/inference/accountBilling.js +33 -31
  93. package/dist/esm/inference/aliaModelRelease.js +7 -5
  94. package/dist/esm/inference/attribution.js +14 -12
  95. package/dist/esm/inference/catalogue.js +33 -27
  96. package/dist/esm/inference/economics.js +22 -17
  97. package/dist/esm/inference/embeddings.js +9 -7
  98. package/dist/esm/inference/entitlement.js +15 -13
  99. package/dist/esm/inference/errors.js +13 -6
  100. package/dist/esm/inference/identifiers.js +31 -19
  101. package/dist/esm/inference/inbox.js +37 -35
  102. package/dist/esm/inference/modelDocumentation.js +14 -12
  103. package/dist/esm/inference/money.js +3 -2
  104. package/dist/esm/inference/priceVersion.js +8 -3
  105. package/dist/esm/inference/providerConnection.js +19 -12
  106. package/dist/esm/inference/realtime.js +85 -44
  107. package/dist/esm/inference/request.js +25 -23
  108. package/dist/esm/inference/routingPolicy.js +9 -7
  109. package/dist/esm/inference/streamEvents.js +20 -14
  110. package/dist/esm/inference/usage.js +30 -13
  111. package/dist/esm/keyRecovery.js +8 -6
  112. package/dist/esm/keyRotation.js +5 -4
  113. package/dist/esm/linkedAccounts.js +20 -16
  114. package/dist/esm/moderationReputation.js +27 -25
  115. package/dist/esm/notifications.js +23 -7
  116. package/dist/esm/numberChecks.js +41 -0
  117. package/dist/esm/oauth.js +14 -12
  118. package/dist/esm/organizations.js +23 -21
  119. package/dist/esm/products/access.js +10 -8
  120. package/dist/esm/products/billing.js +10 -8
  121. package/dist/esm/products/checkout.js +22 -10
  122. package/dist/esm/products/plans.js +15 -10
  123. package/dist/esm/protocol.js +4 -3
  124. package/dist/esm/recommendations.js +25 -17
  125. package/dist/esm/reputation.js +13 -11
  126. package/dist/esm/safety.js +43 -27
  127. package/dist/esm/serviceToken.js +80 -1
  128. package/dist/esm/sessionRevocation.js +6 -4
  129. package/dist/esm/signIn.js +42 -24
  130. package/dist/esm/stickers.js +17 -13
  131. package/dist/esm/stringChecks.js +63 -0
  132. package/dist/esm/transparency.js +14 -12
  133. package/dist/esm/updates.js +22 -20
  134. package/dist/esm/userInvalidation.js +4 -2
  135. package/dist/esm/userResponse.js +4 -3
  136. package/dist/esm/username.js +3 -2
  137. package/dist/types/accountAccess.d.ts +29 -70
  138. package/dist/types/accountEmail.d.ts +2 -14
  139. package/dist/types/accountGraph.d.ts +179 -171
  140. package/dist/types/accountName.d.ts +1 -1
  141. package/dist/types/accountSubject.d.ts +20 -93
  142. package/dist/types/agency.d.ts +528 -2924
  143. package/dist/types/agentKeys.d.ts +48 -421
  144. package/dist/types/appAssertions.d.ts +56 -210
  145. package/dist/types/applicationRoles.d.ts +30 -276
  146. package/dist/types/avatarCharacter.d.ts +1 -1
  147. package/dist/types/civic.d.ts +1 -13
  148. package/dist/types/client/agentKeys.d.ts +18 -18
  149. package/dist/types/client/appAssertions.d.ts +3 -3
  150. package/dist/types/client/check.d.ts +13 -13
  151. package/dist/types/client/deviceDirectory.d.ts +51 -51
  152. package/dist/types/client/deviceSession.d.ts +14 -14
  153. package/dist/types/client/organizations.d.ts +25 -25
  154. package/dist/types/client/products.d.ts +33 -33
  155. package/dist/types/client/recommendations.d.ts +2 -2
  156. package/dist/types/client/safety.d.ts +45 -45
  157. package/dist/types/client/sessionStatus.d.ts +4 -4
  158. package/dist/types/client/signIn.d.ts +1 -1
  159. package/dist/types/commonsSignIn.d.ts +4 -1
  160. package/dist/types/consoleOnboarding.d.ts +24 -44
  161. package/dist/types/contentClaims.d.ts +24 -180
  162. package/dist/types/deviceDirectory.d.ts +109 -1040
  163. package/dist/types/deviceSession.d.ts +36 -298
  164. package/dist/types/email/messages.d.ts +212 -1793
  165. package/dist/types/emailAgentContext.d.ts +10 -194
  166. package/dist/types/externalIdentity.d.ts +121 -615
  167. package/dist/types/federationInstanceFetch.d.ts +3 -32
  168. package/dist/types/identity.d.ts +15 -92
  169. package/dist/types/identityLink.d.ts +6 -84
  170. package/dist/types/identityProof.d.ts +5 -17
  171. package/dist/types/inboxPush.d.ts +1 -9
  172. package/dist/types/index.d.ts +5 -3
  173. package/dist/types/inference/accountBilling.d.ts +151 -488
  174. package/dist/types/inference/aliaModelRelease.d.ts +42 -439
  175. package/dist/types/inference/attribution.d.ts +75 -104
  176. package/dist/types/inference/catalogue.d.ts +417 -1599
  177. package/dist/types/inference/economics.d.ts +69 -276
  178. package/dist/types/inference/embeddings.d.ts +110 -406
  179. package/dist/types/inference/entitlement.d.ts +80 -335
  180. package/dist/types/inference/errors.d.ts +90 -102
  181. package/dist/types/inference/identifiers.d.ts +12 -4
  182. package/dist/types/inference/inbox.d.ts +105 -420
  183. package/dist/types/inference/modelDocumentation.d.ts +201 -1390
  184. package/dist/types/inference/money.d.ts +65 -32
  185. package/dist/types/inference/priceVersion.d.ts +53 -120
  186. package/dist/types/inference/providerConnection.d.ts +253 -710
  187. package/dist/types/inference/realtime.d.ts +954 -6825
  188. package/dist/types/inference/request.d.ts +300 -2572
  189. package/dist/types/inference/routingPolicy.d.ts +95 -503
  190. package/dist/types/inference/streamEvents.d.ts +253 -721
  191. package/dist/types/inference/usage.d.ts +317 -950
  192. package/dist/types/keyRecovery.d.ts +3 -51
  193. package/dist/types/keyRotation.d.ts +3 -38
  194. package/dist/types/linkedAccounts.d.ts +50 -236
  195. package/dist/types/moderationReputation.d.ts +81 -14
  196. package/dist/types/notifications.d.ts +19 -51
  197. package/dist/types/numberChecks.d.ts +9 -0
  198. package/dist/types/oauth.d.ts +101 -809
  199. package/dist/types/organizations.d.ts +268 -921
  200. package/dist/types/oxyRecordTypes.d.ts +11 -1
  201. package/dist/types/products/access.d.ts +125 -775
  202. package/dist/types/products/billing.d.ts +67 -503
  203. package/dist/types/products/checkout.d.ts +16 -69
  204. package/dist/types/products/plans.d.ts +33 -366
  205. package/dist/types/recommendations.d.ts +76 -389
  206. package/dist/types/reputation.d.ts +37 -5
  207. package/dist/types/safety.d.ts +408 -2048
  208. package/dist/types/serviceToken.d.ts +247 -7
  209. package/dist/types/sessionRevocation.d.ts +2 -17
  210. package/dist/types/sessionStatus.d.ts +27 -115
  211. package/dist/types/signIn.d.ts +53 -553
  212. package/dist/types/stickers.d.ts +67 -819
  213. package/dist/types/stringChecks.d.ts +16 -0
  214. package/dist/types/transparency.d.ts +14 -302
  215. package/dist/types/updates.d.ts +60 -316
  216. package/dist/types/userInvalidation.d.ts +4 -13
  217. package/dist/types/userResponse.d.ts +302 -2400
  218. package/dist/types/username.d.ts +3 -3
  219. package/package.json +2 -2
@@ -1,16 +1,18 @@
1
+ import { integerCheck } from './numberChecks.js';
2
+ import { urlCheck, utf16MaxLength, utf16MinLength } from './stringChecks.js';
1
3
  import { z } from 'zod';
2
4
  export { SESSION_ACCOUNTS_CHANGED_EVENT } from './client/deviceSession.js';
3
5
  export const sessionAccountSchema = z.object({
4
6
  accountId: z.string(),
5
7
  sessionId: z.string(),
6
- authuser: z.number().int().nonnegative(),
8
+ authuser: z.number().check(integerCheck()).nonnegative(),
7
9
  operatedByUserId: z.string().optional(),
8
10
  });
9
11
  export const deviceSessionStateSchema = z.object({
10
12
  deviceId: z.string(),
11
13
  accounts: z.array(sessionAccountSchema),
12
14
  activeAccountId: z.string().nullable(),
13
- revision: z.number().int().nonnegative(),
15
+ revision: z.number().check(integerCheck()).nonnegative(),
14
16
  updatedAt: z.number(),
15
17
  });
16
18
  export const activeTokenSchema = z.object({
@@ -41,9 +43,9 @@ export const deviceSessionSyncSchema = z.object({
41
43
  * state every other app observes.
42
44
  */
43
45
  export const deviceTokenMintRequestSchema = z.object({
44
- deviceId: z.string().min(1),
45
- deviceSecret: z.string().min(1),
46
- accountId: z.string().min(1).optional(),
46
+ deviceId: z.string().check(utf16MinLength(1)),
47
+ deviceSecret: z.string().check(utf16MinLength(1)),
48
+ accountId: z.string().check(utf16MinLength(1)).optional(),
47
49
  });
48
50
  /**
49
51
  * Wire shape of a successful `POST /session/device/token`: the freshly-minted
@@ -82,7 +84,7 @@ export const sessionAccountsChangedReasonSchema = z.enum([
82
84
  */
83
85
  export const sessionAccountsChangedEventSchema = z.object({
84
86
  userId: z.string(),
85
- revision: z.number().int().nonnegative(),
87
+ revision: z.number().check(integerCheck()).nonnegative(),
86
88
  reason: sessionAccountsChangedReasonSchema,
87
89
  });
88
90
  /* -------------------------------------------------------------------------- */
@@ -111,9 +113,9 @@ export const sessionAccountsChangedEventSchema = z.object({
111
113
  * the API's serializers checked against it — the producer is the same server.
112
114
  */
113
115
  export const deviceBackgroundCredentialResponseSchema = z.object({
114
- deviceId: z.string().min(1),
115
- secret: z.string().min(1),
116
- accountId: z.string().min(1),
116
+ deviceId: z.string().check(utf16MinLength(1)),
117
+ secret: z.string().check(utf16MinLength(1)),
118
+ accountId: z.string().check(utf16MinLength(1)),
117
119
  expiresAt: z.string(),
118
120
  });
119
121
  /**
@@ -127,8 +129,8 @@ export const deviceBackgroundCredentialResponseSchema = z.object({
127
129
  * run.
128
130
  */
129
131
  export const deviceBackgroundTokenRequestSchema = z.object({
130
- deviceId: z.string().min(1),
131
- secret: z.string().min(1),
132
+ deviceId: z.string().check(utf16MinLength(1)),
133
+ secret: z.string().check(utf16MinLength(1)),
132
134
  });
133
135
  /**
134
136
  * Wire shape of a successful `POST /session/device/background-token`: the short
@@ -143,7 +145,7 @@ export const deviceBackgroundTokenRequestSchema = z.object({
143
145
  export const deviceBackgroundTokenResponseSchema = z.object({
144
146
  accessToken: z.string(),
145
147
  expiresAt: z.string(),
146
- accountId: z.string().min(1),
148
+ accountId: z.string().check(utf16MinLength(1)),
147
149
  });
148
150
  /* -------------------------------------------------------------------------- */
149
151
  /* The browser bridge — joining the browser's DeviceSession (ADR 0029 D2) */
@@ -157,8 +159,8 @@ export const deviceBackgroundTokenResponseSchema = z.object({
157
159
  * the account. An invalid proof on a sign-in is ignored, never an error.
158
160
  */
159
161
  export const deviceProofSchema = z.object({
160
- deviceId: z.string().min(1).max(128),
161
- deviceSecret: z.string().min(1).max(256),
162
+ deviceId: z.string().check(utf16MinLength(1)).check(utf16MaxLength(128)),
163
+ deviceSecret: z.string().check(utf16MinLength(1)).check(utf16MaxLength(256)),
162
164
  });
163
165
  /**
164
166
  * `POST /session/device/register` — auth.oxy.so only. No body. A new, empty
@@ -166,8 +168,8 @@ export const deviceProofSchema = z.object({
166
168
  * auth.oxy.so. The raw secret is returned exactly once.
167
169
  */
168
170
  export const deviceRegisterResponseSchema = z.object({
169
- deviceId: z.string().min(1),
170
- deviceSecret: z.string().min(1),
171
+ deviceId: z.string().check(utf16MinLength(1)),
172
+ deviceSecret: z.string().check(utf16MinLength(1)),
171
173
  });
172
174
  /** PKCE S256 challenge: base64url of a SHA-256 digest (43 characters). */
173
175
  const pkceS256ChallengeSchema = z.string().regex(/^[A-Za-z0-9_-]{43}$/);
@@ -179,15 +181,15 @@ const pkceS256ChallengeSchema = z.string().regex(/^[A-Za-z0-9_-]{43}$/);
179
181
  * minute.
180
182
  */
181
183
  export const deviceJoinCodeRequestSchema = deviceProofSchema.extend({
182
- clientId: z.string().min(1).max(256),
183
- redirectUri: z.string().url().max(2048),
184
+ clientId: z.string().check(utf16MinLength(1)).check(utf16MaxLength(256)),
185
+ redirectUri: z.string().check(urlCheck()).check(utf16MaxLength(2048)),
184
186
  codeChallenge: pkceS256ChallengeSchema,
185
187
  codeChallengeMethod: z.literal('S256'),
186
188
  });
187
189
  export const deviceJoinCodeResponseSchema = z.object({
188
- code: z.string().min(1),
190
+ code: z.string().check(utf16MinLength(1)),
189
191
  /** Seconds until the code expires. */
190
- expiresIn: z.number().int().positive(),
192
+ expiresIn: z.number().check(integerCheck()).positive(),
191
193
  });
192
194
  /**
193
195
  * `POST /session/device/join` — called by the app's own origin with the code the
@@ -196,13 +198,13 @@ export const deviceJoinCodeResponseSchema = z.object({
196
198
  * ordinary `POST /session/device/token`.
197
199
  */
198
200
  export const deviceJoinRequestSchema = z.object({
199
- code: z.string().min(1).max(256),
201
+ code: z.string().check(utf16MinLength(1)).check(utf16MaxLength(256)),
200
202
  codeVerifier: z
201
203
  .string()
202
- .min(43)
203
- .max(128)
204
+ .check(utf16MinLength(43))
205
+ .check(utf16MaxLength(128))
204
206
  .regex(/^[A-Za-z0-9._~-]+$/),
205
- clientId: z.string().min(1).max(256),
206
- redirectUri: z.string().url().max(2048),
207
+ clientId: z.string().check(utf16MinLength(1)).check(utf16MaxLength(256)),
208
+ redirectUri: z.string().check(urlCheck()).check(utf16MaxLength(2048)),
207
209
  });
208
210
  export const deviceJoinResponseSchema = deviceRegisterResponseSchema;
@@ -1,3 +1,5 @@
1
+ import { integerCheck } from '../numberChecks.js';
2
+ import { isoDateTime } from '../stringChecks.js';
1
3
  /**
2
4
  * Wire contract for the Inbox read API (`/email/*` on oxy-api).
3
5
  *
@@ -21,7 +23,7 @@
21
23
  */
22
24
  import { z } from 'zod';
23
25
  /** An ISO-8601 instant as `Date.prototype.toJSON` writes it. */
24
- const isoInstant = z.string().datetime();
26
+ const isoInstant = z.string().check(isoDateTime());
25
27
  // ─── Vocabularies ───────────────────────────────────────────────────
26
28
  /** Structured data cards the AI extractor can emit. */
27
29
  export const MESSAGE_CARD_TYPES = ['trip', 'purchase', 'event', 'bill', 'package'];
@@ -138,8 +140,8 @@ export const emailMessageHighlightSchema = z.object({
138
140
  */
139
141
  export const emailMessageDeliverySchema = z.object({
140
142
  state: z.enum(EMAIL_DELIVERY_STATES),
141
- attempts: z.number().int(),
142
- maxAttempts: z.number().int(),
143
+ attempts: z.number().check(integerCheck()),
144
+ maxAttempts: z.number().check(integerCheck()),
143
145
  nextAttemptAt: isoInstant.nullable(),
144
146
  error: z.string().nullable(),
145
147
  errorCode: z.enum(EMAIL_DELIVERY_ERROR_CODES).nullable().catch(null),
@@ -186,14 +188,14 @@ export const emailMessageSchema = z.object({
186
188
  receivedAt: isoInstant,
187
189
  createdAt: isoInstant,
188
190
  updatedAt: isoInstant,
189
- draftRevision: z.number().int().min(1),
191
+ draftRevision: z.number().check(integerCheck()).min(1),
190
192
  /** Present only on the reads that return bodies (single message, thread). */
191
193
  text: z.string().nullable().optional(),
192
194
  html: z.string().nullable().optional(),
193
195
  headers: z.record(z.string(), z.string()).optional(),
194
196
  senderAvatarPath: z.string().nullable().optional(),
195
197
  /** Present only on list reads that walked the thread. */
196
- threadCount: z.number().int().optional(),
198
+ threadCount: z.number().check(integerCheck()).optional(),
197
199
  threadParticipants: z.array(z.string()).optional(),
198
200
  /**
199
201
  * Present only on a message the user sent through Oxy since delivery was
@@ -210,9 +212,9 @@ export const emailMailboxSchema = z.object({
210
212
  name: z.string(),
211
213
  path: z.string(),
212
214
  specialUse: z.string().nullable(),
213
- retentionDays: z.number().int().nullable(),
214
- totalMessages: z.number().int(),
215
- unseenMessages: z.number().int(),
215
+ retentionDays: z.number().check(integerCheck()).nullable(),
216
+ totalMessages: z.number().check(integerCheck()),
217
+ unseenMessages: z.number().check(integerCheck()),
216
218
  size: z.number(),
217
219
  createdAt: isoInstant,
218
220
  updatedAt: isoInstant,
@@ -224,7 +226,7 @@ export const emailUserLabelSchema = z.object({
224
226
  userId: z.string(),
225
227
  name: z.string(),
226
228
  color: z.string(),
227
- order: z.number().int(),
229
+ order: z.number().check(integerCheck()),
228
230
  system: z.literal(false),
229
231
  createdAt: isoInstant,
230
232
  updatedAt: isoInstant,
@@ -234,7 +236,7 @@ export const emailSystemLabelSchema = z.object({
234
236
  _id: z.string(),
235
237
  name: z.string(),
236
238
  color: z.string(),
237
- order: z.number().int(),
239
+ order: z.number().check(integerCheck()),
238
240
  system: z.literal(true),
239
241
  });
240
242
  export const emailLabelSchema = z.discriminatedUnion('system', [
@@ -259,7 +261,7 @@ export const emailFilterSchema = z.object({
259
261
  name: z.string(),
260
262
  enabled: z.boolean(),
261
263
  matchAll: z.boolean(),
262
- order: z.number().int(),
264
+ order: z.number().check(integerCheck()),
263
265
  conditions: z.array(emailFilterConditionSchema),
264
266
  actions: z.array(emailFilterActionSchema),
265
267
  createdAt: isoInstant,
@@ -275,7 +277,7 @@ export const emailBundleSchema = z.object({
275
277
  matchLabels: z.array(z.string()),
276
278
  enabled: z.boolean(),
277
279
  collapsed: z.boolean(),
278
- order: z.number().int(),
280
+ order: z.number().check(integerCheck()),
279
281
  createdAt: isoInstant,
280
282
  updatedAt: isoInstant,
281
283
  });
@@ -285,9 +287,9 @@ export const emailBundledInboxSchema = z.object({
285
287
  bundles: z.array(z.object({
286
288
  bundle: emailBundleSchema,
287
289
  messages: z.array(emailMessageSchema),
288
- unreadCount: z.number().int(),
290
+ unreadCount: z.number().check(integerCheck()),
289
291
  })),
290
- total: z.number().int(),
292
+ total: z.number().check(integerCheck()),
291
293
  });
292
294
  /** An address-book entry. `company` and `notes` are `null` when unset. */
293
295
  export const emailContactSchema = z.object({
@@ -312,8 +314,8 @@ export const emailOutboxSchema = z.object({
312
314
  id: z.string(),
313
315
  messageId: z.string(),
314
316
  status: z.enum(EMAIL_OUTBOX_STATUSES),
315
- attempts: z.number().int(),
316
- maxAttempts: z.number().int(),
317
+ attempts: z.number().check(integerCheck()),
318
+ maxAttempts: z.number().check(integerCheck()),
317
319
  terminal: z.boolean(),
318
320
  nextAttemptAt: isoInstant,
319
321
  lastError: z.string().nullable(),
@@ -1,3 +1,5 @@
1
+ import { integerCheck } from './numberChecks.js';
2
+ import { isoDateTime, utf16MinLength } from './stringChecks.js';
1
3
  import { z } from 'zod';
2
4
  export const emailContextAddressSchema = z
3
5
  .object({
@@ -7,29 +9,29 @@ export const emailContextAddressSchema = z
7
9
  .strict();
8
10
  export const emailContextMailboxSchema = z
9
11
  .object({
10
- mailboxId: z.string().min(1),
12
+ mailboxId: z.string().check(utf16MinLength(1)),
11
13
  name: z.string(),
12
14
  path: z.string(),
13
- totalMessages: z.number().int().nonnegative(),
14
- unseenMessages: z.number().int().nonnegative(),
15
+ totalMessages: z.number().check(integerCheck()).nonnegative(),
16
+ unseenMessages: z.number().check(integerCheck()).nonnegative(),
15
17
  })
16
18
  .strict();
17
19
  export const emailContextMessageSchema = z
18
20
  .object({
19
- messageId: z.string().min(1),
20
- mailboxId: z.string().min(1),
21
+ messageId: z.string().check(utf16MinLength(1)),
22
+ mailboxId: z.string().check(utf16MinLength(1)),
21
23
  from: emailContextAddressSchema,
22
24
  subject: z.string(),
23
- receivedAt: z.string().datetime(),
25
+ receivedAt: z.string().check(isoDateTime()),
24
26
  seen: z.boolean(),
25
27
  answered: z.boolean(),
26
28
  })
27
29
  .strict();
28
30
  export const emailAgentContextSchema = z
29
31
  .object({
30
- accountId: z.string().min(1),
31
- resourceMailboxId: z.string().min(1).nullable(),
32
- generatedAt: z.string().datetime(),
32
+ accountId: z.string().check(utf16MinLength(1)),
33
+ resourceMailboxId: z.string().check(utf16MinLength(1)).nullable(),
34
+ generatedAt: z.string().check(isoDateTime()),
33
35
  mailboxes: z.array(emailContextMailboxSchema),
34
36
  recentUnread: z.array(emailContextMessageSchema),
35
37
  needsResponse: z.array(emailContextMessageSchema),
@@ -1,3 +1,4 @@
1
+ import { utf16MaxLength, utf16MinLength } from './stringChecks.js';
1
2
  import { z } from 'zod';
2
3
  import { userResponseSchema } from './userResponse.js';
3
4
  /**
@@ -7,26 +8,26 @@ import { userResponseSchema } from './userResponse.js';
7
8
  */
8
9
  export const externalIdentityProtocolSchema = z.enum(['activitypub', 'atproto', 'instagram-graph']);
9
10
  export const externalIdentityReferenceSchema = z.object({
10
- canonicalAcct: z.string().min(1),
11
- network: z.string().min(1),
11
+ canonicalAcct: z.string().check(utf16MinLength(1)),
12
+ network: z.string().check(utf16MinLength(1)),
12
13
  protocol: externalIdentityProtocolSchema,
13
- actorUri: z.string().min(1),
14
- transportAcct: z.string().min(1),
15
- sourceUserId: z.string().min(1),
14
+ actorUri: z.string().check(utf16MinLength(1)),
15
+ transportAcct: z.string().check(utf16MinLength(1)),
16
+ sourceUserId: z.string().check(utf16MinLength(1)),
16
17
  });
17
18
  export const resolveExternalIdentityRequestSchema = z
18
19
  .object({
19
- actorUri: z.string().min(1).max(2048).optional(),
20
- handle: z.string().min(1).max(2048).optional(),
21
- transportAcct: z.string().max(320).optional(),
20
+ actorUri: z.string().check(utf16MinLength(1)).check(utf16MaxLength(2048)).optional(),
21
+ handle: z.string().check(utf16MinLength(1)).check(utf16MaxLength(2048)).optional(),
22
+ transportAcct: z.string().check(utf16MaxLength(320)).optional(),
22
23
  protocol: externalIdentityProtocolSchema.optional(),
23
24
  })
24
25
  .refine((value) => Boolean(value.actorUri) !== Boolean(value.handle), 'Exactly one actorUri or handle is required');
25
26
  export const resolveExternalIdentityResponseSchema = z
26
27
  .object({
27
28
  user: userResponseSchema.extend({
28
- id: z.string().min(1),
29
- username: z.string().min(1),
29
+ id: z.string().check(utf16MinLength(1)),
30
+ username: z.string().check(utf16MinLength(1)),
30
31
  bio: z.string().optional(),
31
32
  externalIdentities: z.array(externalIdentityReferenceSchema),
32
33
  redirectedUserIds: z.array(z.string()),
@@ -61,7 +62,10 @@ export const resolveExternalIdentityResponseSchema = z
61
62
  }
62
63
  });
63
64
  export const lookupExternalIdentitiesRequestSchema = z.object({
64
- identifiers: z.array(z.string().min(1).max(2048)).min(1).max(100),
65
+ identifiers: z
66
+ .array(z.string().check(utf16MinLength(1)).check(utf16MaxLength(2048)))
67
+ .min(1)
68
+ .max(100),
65
69
  });
66
70
  export const lookupExternalIdentitiesResponseSchema = z.object({
67
71
  identities: z.array(z.object({
@@ -1,3 +1,4 @@
1
+ import { urlCheck, utf16MaxLength, utf16MinLength } from './stringChecks.js';
1
2
  /**
2
3
  * Wire contract for `POST /federation/instance-fetch/sign`: Oxy's INSTANCE
3
4
  * actor signs one ActivityPub GET for a first-party service, so the service can
@@ -22,19 +23,23 @@ export const INSTANCE_FETCH_MAX_URL_LENGTH = 2048;
22
23
  export const instanceFetchSignRequestSchema = z
23
24
  .object({
24
25
  /** The absolute public `https://` URL the caller is about to GET. */
25
- url: z.string().trim().min(1).max(INSTANCE_FETCH_MAX_URL_LENGTH),
26
+ url: z
27
+ .string()
28
+ .trim()
29
+ .check(utf16MinLength(1))
30
+ .check(utf16MaxLength(INSTANCE_FETCH_MAX_URL_LENGTH)),
26
31
  })
27
32
  .strict();
28
33
  export const instanceFetchSignResponseSchema = z
29
34
  .object({
30
35
  /** The instance actor's key, e.g. `https://oxy.so/ap/users/instance#main-key`. */
31
- keyId: z.string().url(),
36
+ keyId: z.string().check(urlCheck()),
32
37
  /** Send all three on the GET, as they are. */
33
38
  headers: z
34
39
  .object({
35
- Host: z.string().min(1),
36
- Date: z.string().min(1),
37
- Signature: z.string().min(1),
40
+ Host: z.string().check(utf16MinLength(1)),
41
+ Date: z.string().check(utf16MinLength(1)),
42
+ Signature: z.string().check(utf16MinLength(1)),
38
43
  })
39
44
  .strict(),
40
45
  })
@@ -1,3 +1,5 @@
1
+ import { integerCheck } from './numberChecks.js';
2
+ import { isoDateTime, utf16MaxLength, utf16MinLength } from './stringChecks.js';
1
3
  /**
2
4
  * Self-sovereign identity API contracts.
3
5
  *
@@ -80,15 +82,15 @@ export const signedRecordEnvelopeSchema = z
80
82
  version: z.union([z.literal(1), z.literal(2)]),
81
83
  // Open, app-defined category (see the `type` doc above). The Oxy STORE
82
84
  // re-narrows to `oxySignedRecordTypeSchema`; an app to its own constant.
83
- type: z.string().min(1),
85
+ type: z.string().check(utf16MinLength(1)),
84
86
  subject: z.string(),
85
87
  issuer: z.string(),
86
- record: z.record(z.unknown()),
88
+ record: z.record(z.string(), z.unknown()),
87
89
  issuedAt: z.number(),
88
- seq: z.number().int().nonnegative().optional(),
90
+ seq: z.number().check(integerCheck()).nonnegative().optional(),
89
91
  prev: z.string().nullable().optional(),
90
- collection: z.string().min(1).optional(),
91
- rkey: z.string().min(1).optional(),
92
+ collection: z.string().check(utf16MinLength(1)).optional(),
93
+ rkey: z.string().check(utf16MinLength(1)).optional(),
92
94
  publicKey: z.string(),
93
95
  alg: z.literal('ES256K-DER-SHA256'),
94
96
  signature: z.string(),
@@ -167,7 +169,7 @@ export const verifiedDomainSchema = z.object({
167
169
  });
168
170
  /** Request body for `POST /identity/domains` — the domain to start verifying. */
169
171
  export const domainVerificationRequestSchema = z.object({
170
- domain: z.string().trim().min(1),
172
+ domain: z.string().trim().check(utf16MinLength(1)),
171
173
  });
172
174
  const resourceOriginHostSchema = z
173
175
  .string()
@@ -175,24 +177,24 @@ const resourceOriginHostSchema = z
175
177
  .toLowerCase()
176
178
  .pipe(z
177
179
  .string()
178
- .min(1)
179
- .max(253)
180
+ .check(utf16MinLength(1))
181
+ .check(utf16MaxLength(253))
180
182
  .regex(/^(?!-)[a-z0-9-]{1,63}(?<!-)(?:\.(?!-)[a-z0-9-]{1,63}(?<!-))+$/, 'originHost must be a public DNS hostname without scheme, port or path'));
181
183
  /** Clarity resource-server request to bind a site to Oxy domain authority. */
182
184
  export const resourceDomainOwnershipRequestSchema = z
183
185
  .object({
184
- accountId: z.string().min(1).max(128),
185
- verifiedDomainId: z.string().min(1).max(128),
186
+ accountId: z.string().check(utf16MinLength(1)).check(utf16MaxLength(128)),
187
+ verifiedDomainId: z.string().check(utf16MinLength(1)).check(utf16MaxLength(128)),
186
188
  originHost: resourceOriginHostSchema,
187
189
  })
188
190
  .strict();
189
191
  export const resourceDomainOwnershipResponseSchema = z
190
192
  .object({
191
193
  verified: z.boolean(),
192
- accountId: z.string().min(1).max(128),
193
- verifiedDomainId: z.string().min(1).max(128),
194
+ accountId: z.string().check(utf16MinLength(1)).check(utf16MaxLength(128)),
195
+ verifiedDomainId: z.string().check(utf16MinLength(1)).check(utf16MaxLength(128)),
194
196
  originHost: resourceOriginHostSchema,
195
- verifiedAt: z.string().datetime().optional(),
197
+ verifiedAt: z.string().check(isoDateTime()).optional(),
196
198
  method: z.enum(['dns-txt', 'well-known']).optional(),
197
199
  })
198
200
  .strict();
@@ -266,11 +268,11 @@ export const exportBundleSchema = z.object({
266
268
  exportedAt: z.string(),
267
269
  did: z.string(),
268
270
  didDocument: didDocumentSchema,
269
- profile: z.record(z.unknown()),
271
+ profile: z.record(z.string(), z.unknown()),
270
272
  verifiedDomains: z.array(verifiedDomainSchema),
271
273
  authMethods: z.array(authMethodEntrySchema),
272
274
  signedRecords: z.array(signedRecordEnvelopeSchema),
273
- appData: z.array(z.record(z.unknown())),
275
+ appData: z.array(z.record(z.string(), z.unknown())),
274
276
  social: z.object({
275
277
  following: z.array(z.string()),
276
278
  followers: z.array(z.string()),
@@ -1,3 +1,5 @@
1
+ import { integerCheck } from './numberChecks.js';
2
+ import { utf16MinLength } from './stringChecks.js';
1
3
  /**
2
4
  * Linking Commons to an account without a key (ADR 0029 D3) — the two-device
3
5
  * relay.
@@ -37,16 +39,16 @@ export const identityLinkIdSchema = z
37
39
  export const identityLinkCreateResponseSchema = z.object({
38
40
  linkId: identityLinkIdSchema,
39
41
  challenge: z.string().regex(CHALLENGE),
40
- expiresAt: z.number().int().positive(),
42
+ expiresAt: z.number().check(integerCheck()).positive(),
41
43
  qrPayload: z.string().startsWith(IDENTITY_LINK_QR_PREFIX),
42
44
  });
43
45
  export const identityLinkStateSchema = z.object({
44
46
  status: z.enum(IDENTITY_LINK_STATUSES),
45
- userId: z.string().min(1),
47
+ userId: z.string().check(utf16MinLength(1)),
46
48
  username: z.string().nullable(),
47
49
  publicKey: z.string().nullable(),
48
- audience: z.string().min(1),
49
- expiresAt: z.number().int().positive(),
50
+ audience: z.string().check(utf16MinLength(1)),
51
+ expiresAt: z.number().check(integerCheck()).positive(),
50
52
  });
51
53
  /** `POST /identity/link/:linkId/proof` — from Commons, no bearer. */
52
54
  export const identityLinkProofRequestSchema = z
@@ -1,3 +1,5 @@
1
+ import { integerCheck } from './numberChecks.js';
2
+ import { utf16MaxLength, utf16MinLength } from './stringChecks.js';
1
3
  /**
2
4
  * Identity proof contract — the ONE signed format for operations on a personal root.
3
5
  *
@@ -24,8 +26,8 @@ export { IDENTITY_PROOF_VERSION, IDENTITY_PROOF_DOMAIN, IDENTITY_PROOF_AUDIENCE,
24
26
  export const identityProofSchema = z.object({
25
27
  v: z.literal(IDENTITY_PROOF_VERSION),
26
28
  challenge: z.string().trim().regex(CHALLENGE, 'challenge must be 64 lowercase hex characters'),
27
- expiresAt: z.number().int().positive(),
28
- signature: z.string().trim().min(1).max(512),
29
+ expiresAt: z.number().check(integerCheck()).positive(),
30
+ signature: z.string().trim().check(utf16MinLength(1)).check(utf16MaxLength(512)),
29
31
  });
30
32
  /** `POST /identity/proof-challenge` */
31
33
  export const identityProofChallengeRequestSchema = z.object({
@@ -33,8 +35,8 @@ export const identityProofChallengeRequestSchema = z.object({
33
35
  });
34
36
  export const identityProofChallengeResponseSchema = z.object({
35
37
  challenge: z.string().regex(CHALLENGE),
36
- expiresAt: z.number().int().positive(),
37
- audience: z.string().min(1),
38
+ expiresAt: z.number().check(integerCheck()).positive(),
39
+ audience: z.string().check(utf16MinLength(1)),
38
40
  });
39
41
  export const identityRootStatusSchema = z.object({
40
42
  rootLinked: z.boolean(),
@@ -1,3 +1,4 @@
1
+ import { utf16MinLength } from './stringChecks.js';
1
2
  /**
2
3
  * Canonical contract for Inbox new-mail push notifications.
3
4
  *
@@ -16,6 +17,6 @@ export const INBOX_EMAIL_PUSH_CHANNEL = 'email';
16
17
  export const INBOX_EMAIL_PUSH_TYPE = 'oxy_inbox_new_message';
17
18
  export const inboxEmailPushDataSchema = z.object({
18
19
  type: z.literal(INBOX_EMAIL_PUSH_TYPE),
19
- messageId: z.string().min(1),
20
- mailboxId: z.string().min(1),
20
+ messageId: z.string().check(utf16MinLength(1)),
21
+ mailboxId: z.string().check(utf16MinLength(1)),
21
22
  });
package/dist/esm/index.js CHANGED
@@ -182,7 +182,7 @@ PRODUCT_PLAN_STATUSES, productPlanStatusSchema, LIVE_PRODUCT_PLAN_STATUSES, plan
182
182
  export {
183
183
  // Economic treatment (I09): derived by the server, never sent by a caller.
184
184
  INFERENCE_ECONOMIC_TREATMENTS, inferenceEconomicTreatmentSchema, PROVIDER_COST_SOURCES, providerCostSourceSchema, costCenterUsageSchema, } from './inference/economics.js';
185
- export { AUTONOMY_LEVELS, CAPABILITY_PACKAGES, autonomyLevelSchema, capabilityPackageSchema, actorRefSchema, executionActorRefSchema, foregroundExecutionAuthorizationInputSchema, resourceRefSchema, toolGrantOverrideSchema, grantLimitSchema, capabilityCatalogBindingSchema, executionAuthorizationRefSchema, capabilityCoordinatorSchema, capabilityTicketRequestSchema, delegationGrantSchema, AGENT_REQUESTER_CEILING_AUTONOMY, agentRequesterCeilingWriteSchema, agentRequesterCeilingSchema, APPLICATION_AGENT_AVAILABILITIES, applicationAgentAvailabilitySchema, applicationAgentWriteSchema, applicationAgentSchema, agentAvailabilitySchema, automationTriggerSchema, automationActorSelectionSchema, automationDataFlowSchema, automationDefinitionSchema, capabilityTicketClaimsSchema, invocationPrincipalSchema, policyDecisionSchema, auditResultSchema, auditEventSchema, CATALOG_TOOL_ACTOR_TYPES, CATALOG_TOOL_DEFAULT_ACTORS, catalogToolActorTypeSchema, catalogToolActors, catalogToolAllowsActor, catalogToolSchema, catalogEventSchema, catalogFeatureSchema, CATALOG_INTERNAL_TRANSPORTS, appCapabilityCatalogSchema, catalogRegistrationSchema, normalizedAppEventSchema, } from './agency.js';
185
+ export { AUTONOMY_LEVELS, CAPABILITY_PACKAGES, autonomyLevelSchema, capabilityPackageSchema, actorRefSchema, executionActorRefSchema, foregroundExecutionAuthorizationInputSchema, firstPartyExecutionAuthorizationInputSchema, firstPartyTaskInputSchema, resourceRefSchema, toolGrantOverrideSchema, grantLimitSchema, capabilityCatalogBindingSchema, executionAuthorizationRefSchema, capabilityCoordinatorSchema, capabilityTicketRequestSchema, delegationGrantSchema, AGENT_REQUESTER_CEILING_AUTONOMY, agentRequesterCeilingWriteSchema, agentRequesterCeilingSchema, APPLICATION_AGENT_AVAILABILITIES, applicationAgentAvailabilitySchema, applicationAgentWriteSchema, applicationAgentSchema, agentAvailabilitySchema, automationTriggerSchema, automationActorSelectionSchema, automationDataFlowSchema, automationDefinitionSchema, capabilityTicketClaimsSchema, invocationPrincipalSchema, policyDecisionSchema, auditResultSchema, auditEventSchema, CATALOG_TOOL_ACTOR_TYPES, CATALOG_TOOL_DEFAULT_ACTORS, catalogToolActorTypeSchema, catalogToolActors, catalogToolAllowsActor, catalogToolSchema, catalogEventSchema, catalogFeatureSchema, CATALOG_INTERNAL_TRANSPORTS, appCapabilityCatalogSchema, catalogRegistrationSchema, normalizedAppEventSchema, } from './agency.js';
186
186
  export { catalogInvocationPathParameters, catalogInvocationsOverlap, catalogInvocationTemplatesEquivalent, findOverlappingCatalogInvocations, matchCatalogInvocation, resolveCatalogInvocation, } from './capabilityInvocation.js';
187
187
  export { emailContextAddressSchema, emailContextMailboxSchema, emailContextMessageSchema, emailAgentContextSchema, } from './emailAgentContext.js';
188
188
  export { inboxComposeRequestSchema, inboxDailyBriefRequestSchema, inboxDailyBriefResponseSchema, INBOX_DAILY_BRIEF_SECTIONS, inboxNaturalSearchRequestSchema, inboxMessageInferenceParamsSchema, inboxInferenceTextResponseSchema, inboxNaturalSearchResponseSchema, inboxSmartRepliesResponseSchema, inboxThreadSummaryResponseSchema, inboxInferenceStreamEventSchema, } from './inference/inbox.js';
@@ -203,9 +203,11 @@ export { personalPlanDisplayPriceSchema, personalPlanCatalogueSchema, productPla
203
203
  export * from './products/checkout.js';
204
204
  export * from './organizations.js';
205
205
  export * from './safety.js';
206
- export { serviceTokenScopesSchema, serviceTokenOptionsSchema, } from './serviceToken.js';
206
+ export * from './serviceToken.js';
207
207
  export * from './applicationRoles.js';
208
208
  export * from './contentClaims.js';
209
209
  export * from './appAssertions.js';
210
210
  export * from './products/one.js';
211
211
  export { USER_PROFILE_COLORS, USER_PROFILE_COLOR_PRESETS, FREE_USER_PROFILE_COLOR_PRESETS, } from './profileColors.generated.js';
212
+ export { utf16MinLength, utf16MaxLength, utf16Length, isoDateTime, urlCheck, } from './stringChecks.js';
213
+ export { integerCheck, safeNumberCheck } from './numberChecks.js';