@oxy.so/contracts 5.8.0 → 6.1.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 (231) 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/campaignAttribution.js +28 -0
  10. package/dist/cjs/civic.js +10 -9
  11. package/dist/cjs/client/campaignAttribution.js +14 -0
  12. package/dist/cjs/client/check.js +61 -53
  13. package/dist/cjs/client/index.js +7 -1
  14. package/dist/cjs/client/language.js +7 -0
  15. package/dist/cjs/consoleOnboarding.js +9 -4
  16. package/dist/cjs/contentClaims.js +23 -14
  17. package/dist/cjs/deviceDirectory.js +11 -9
  18. package/dist/cjs/deviceSession.js +27 -25
  19. package/dist/cjs/email/messages.js +20 -18
  20. package/dist/cjs/emailAgentContext.js +11 -9
  21. package/dist/cjs/externalIdentity.js +15 -11
  22. package/dist/cjs/federationInstanceFetch.js +12 -7
  23. package/dist/cjs/identity.js +19 -17
  24. package/dist/cjs/identityLink.js +6 -4
  25. package/dist/cjs/identityProof.js +6 -4
  26. package/dist/cjs/inboxPush.js +5 -4
  27. package/dist/cjs/index.js +17 -6
  28. package/dist/cjs/inference/accountBilling.js +35 -33
  29. package/dist/cjs/inference/aliaModelRelease.js +9 -7
  30. package/dist/cjs/inference/attribution.js +14 -12
  31. package/dist/cjs/inference/catalogue.js +35 -29
  32. package/dist/cjs/inference/economics.js +24 -19
  33. package/dist/cjs/inference/embeddings.js +9 -7
  34. package/dist/cjs/inference/entitlement.js +17 -15
  35. package/dist/cjs/inference/errors.js +15 -8
  36. package/dist/cjs/inference/identifiers.js +33 -21
  37. package/dist/cjs/inference/inbox.js +37 -35
  38. package/dist/cjs/inference/modelDocumentation.js +16 -14
  39. package/dist/cjs/inference/money.js +5 -4
  40. package/dist/cjs/inference/priceVersion.js +10 -5
  41. package/dist/cjs/inference/providerConnection.js +21 -14
  42. package/dist/cjs/inference/realtime.js +88 -47
  43. package/dist/cjs/inference/request.js +27 -25
  44. package/dist/cjs/inference/routingPolicy.js +12 -10
  45. package/dist/cjs/inference/streamEvents.js +22 -16
  46. package/dist/cjs/inference/usage.js +32 -15
  47. package/dist/cjs/keyRecovery.js +8 -6
  48. package/dist/cjs/keyRotation.js +5 -4
  49. package/dist/cjs/linkedAccounts.js +22 -18
  50. package/dist/cjs/moderationReputation.js +29 -27
  51. package/dist/cjs/notifications.js +25 -9
  52. package/dist/cjs/numberChecks.js +45 -0
  53. package/dist/cjs/oauth.js +14 -12
  54. package/dist/cjs/organizations.js +23 -21
  55. package/dist/cjs/products/access.js +10 -8
  56. package/dist/cjs/products/billing.js +10 -8
  57. package/dist/cjs/products/checkout.js +22 -10
  58. package/dist/cjs/products/plans.js +15 -10
  59. package/dist/cjs/protocol.js +6 -5
  60. package/dist/cjs/recommendations.js +27 -19
  61. package/dist/cjs/reputation.js +15 -13
  62. package/dist/cjs/safety.js +43 -27
  63. package/dist/cjs/serviceToken.js +81 -2
  64. package/dist/cjs/sessionRevocation.js +8 -6
  65. package/dist/cjs/signIn.js +50 -24
  66. package/dist/cjs/stickers.js +19 -15
  67. package/dist/cjs/stringChecks.js +70 -0
  68. package/dist/cjs/transparency.js +14 -12
  69. package/dist/cjs/updates.js +24 -22
  70. package/dist/cjs/userInvalidation.js +7 -5
  71. package/dist/cjs/userResponse.js +8 -7
  72. package/dist/cjs/username.js +7 -6
  73. package/dist/esm/accountAccess.js +4 -3
  74. package/dist/esm/accountEmail.js +13 -5
  75. package/dist/esm/accountGraph.js +8 -7
  76. package/dist/esm/accountName.js +3 -2
  77. package/dist/esm/agency.js +90 -33
  78. package/dist/esm/agentKeys.js +21 -17
  79. package/dist/esm/appAssertions.js +11 -10
  80. package/dist/esm/applicationRoles.js +16 -9
  81. package/dist/esm/campaignAttribution.js +25 -0
  82. package/dist/esm/civic.js +8 -7
  83. package/dist/esm/client/campaignAttribution.js +10 -0
  84. package/dist/esm/client/check.js +61 -53
  85. package/dist/esm/client/index.js +2 -0
  86. package/dist/esm/client/language.js +4 -0
  87. package/dist/esm/consoleOnboarding.js +7 -2
  88. package/dist/esm/contentClaims.js +23 -14
  89. package/dist/esm/deviceDirectory.js +11 -9
  90. package/dist/esm/deviceSession.js +27 -25
  91. package/dist/esm/email/messages.js +18 -16
  92. package/dist/esm/emailAgentContext.js +11 -9
  93. package/dist/esm/externalIdentity.js +15 -11
  94. package/dist/esm/federationInstanceFetch.js +10 -5
  95. package/dist/esm/identity.js +17 -15
  96. package/dist/esm/identityLink.js +6 -4
  97. package/dist/esm/identityProof.js +6 -4
  98. package/dist/esm/inboxPush.js +3 -2
  99. package/dist/esm/index.js +5 -2
  100. package/dist/esm/inference/accountBilling.js +33 -31
  101. package/dist/esm/inference/aliaModelRelease.js +7 -5
  102. package/dist/esm/inference/attribution.js +14 -12
  103. package/dist/esm/inference/catalogue.js +33 -27
  104. package/dist/esm/inference/economics.js +22 -17
  105. package/dist/esm/inference/embeddings.js +9 -7
  106. package/dist/esm/inference/entitlement.js +15 -13
  107. package/dist/esm/inference/errors.js +13 -6
  108. package/dist/esm/inference/identifiers.js +31 -19
  109. package/dist/esm/inference/inbox.js +37 -35
  110. package/dist/esm/inference/modelDocumentation.js +14 -12
  111. package/dist/esm/inference/money.js +3 -2
  112. package/dist/esm/inference/priceVersion.js +8 -3
  113. package/dist/esm/inference/providerConnection.js +19 -12
  114. package/dist/esm/inference/realtime.js +85 -44
  115. package/dist/esm/inference/request.js +25 -23
  116. package/dist/esm/inference/routingPolicy.js +9 -7
  117. package/dist/esm/inference/streamEvents.js +20 -14
  118. package/dist/esm/inference/usage.js +30 -13
  119. package/dist/esm/keyRecovery.js +8 -6
  120. package/dist/esm/keyRotation.js +5 -4
  121. package/dist/esm/linkedAccounts.js +20 -16
  122. package/dist/esm/moderationReputation.js +27 -25
  123. package/dist/esm/notifications.js +23 -7
  124. package/dist/esm/numberChecks.js +41 -0
  125. package/dist/esm/oauth.js +14 -12
  126. package/dist/esm/organizations.js +23 -21
  127. package/dist/esm/products/access.js +10 -8
  128. package/dist/esm/products/billing.js +10 -8
  129. package/dist/esm/products/checkout.js +22 -10
  130. package/dist/esm/products/plans.js +15 -10
  131. package/dist/esm/protocol.js +4 -3
  132. package/dist/esm/recommendations.js +25 -17
  133. package/dist/esm/reputation.js +13 -11
  134. package/dist/esm/safety.js +43 -27
  135. package/dist/esm/serviceToken.js +80 -1
  136. package/dist/esm/sessionRevocation.js +6 -4
  137. package/dist/esm/signIn.js +50 -24
  138. package/dist/esm/stickers.js +17 -13
  139. package/dist/esm/stringChecks.js +63 -0
  140. package/dist/esm/transparency.js +14 -12
  141. package/dist/esm/updates.js +22 -20
  142. package/dist/esm/userInvalidation.js +4 -2
  143. package/dist/esm/userResponse.js +4 -3
  144. package/dist/esm/username.js +3 -2
  145. package/dist/types/accountAccess.d.ts +29 -70
  146. package/dist/types/accountEmail.d.ts +2 -14
  147. package/dist/types/accountGraph.d.ts +179 -171
  148. package/dist/types/accountName.d.ts +1 -1
  149. package/dist/types/accountSubject.d.ts +20 -93
  150. package/dist/types/agency.d.ts +528 -2924
  151. package/dist/types/agentKeys.d.ts +48 -421
  152. package/dist/types/appAssertions.d.ts +56 -210
  153. package/dist/types/applicationRoles.d.ts +30 -276
  154. package/dist/types/avatarCharacter.d.ts +1 -1
  155. package/dist/types/campaignAttribution.d.ts +10 -0
  156. package/dist/types/civic.d.ts +1 -13
  157. package/dist/types/client/agentKeys.d.ts +18 -18
  158. package/dist/types/client/appAssertions.d.ts +3 -3
  159. package/dist/types/client/campaignAttribution.d.ts +12 -0
  160. package/dist/types/client/check.d.ts +13 -13
  161. package/dist/types/client/deviceDirectory.d.ts +51 -51
  162. package/dist/types/client/deviceSession.d.ts +14 -14
  163. package/dist/types/client/index.d.ts +3 -0
  164. package/dist/types/client/language.d.ts +2 -0
  165. package/dist/types/client/organizations.d.ts +25 -25
  166. package/dist/types/client/products.d.ts +33 -33
  167. package/dist/types/client/recommendations.d.ts +2 -2
  168. package/dist/types/client/safety.d.ts +45 -45
  169. package/dist/types/client/sessionStatus.d.ts +4 -4
  170. package/dist/types/client/signIn.d.ts +1 -1
  171. package/dist/types/commonsSignIn.d.ts +4 -1
  172. package/dist/types/consoleOnboarding.d.ts +24 -44
  173. package/dist/types/contentClaims.d.ts +24 -180
  174. package/dist/types/deviceDirectory.d.ts +109 -1040
  175. package/dist/types/deviceSession.d.ts +36 -298
  176. package/dist/types/email/messages.d.ts +212 -1793
  177. package/dist/types/emailAgentContext.d.ts +10 -194
  178. package/dist/types/externalIdentity.d.ts +121 -615
  179. package/dist/types/federationInstanceFetch.d.ts +3 -32
  180. package/dist/types/identity.d.ts +15 -92
  181. package/dist/types/identityLink.d.ts +6 -84
  182. package/dist/types/identityProof.d.ts +5 -17
  183. package/dist/types/inboxPush.d.ts +1 -9
  184. package/dist/types/index.d.ts +7 -3
  185. package/dist/types/inference/accountBilling.d.ts +151 -488
  186. package/dist/types/inference/aliaModelRelease.d.ts +42 -439
  187. package/dist/types/inference/attribution.d.ts +75 -104
  188. package/dist/types/inference/catalogue.d.ts +417 -1599
  189. package/dist/types/inference/economics.d.ts +69 -276
  190. package/dist/types/inference/embeddings.d.ts +110 -406
  191. package/dist/types/inference/entitlement.d.ts +80 -335
  192. package/dist/types/inference/errors.d.ts +90 -102
  193. package/dist/types/inference/identifiers.d.ts +12 -4
  194. package/dist/types/inference/inbox.d.ts +105 -420
  195. package/dist/types/inference/modelDocumentation.d.ts +201 -1390
  196. package/dist/types/inference/money.d.ts +65 -32
  197. package/dist/types/inference/priceVersion.d.ts +53 -120
  198. package/dist/types/inference/providerConnection.d.ts +253 -710
  199. package/dist/types/inference/realtime.d.ts +954 -6825
  200. package/dist/types/inference/request.d.ts +300 -2572
  201. package/dist/types/inference/routingPolicy.d.ts +95 -503
  202. package/dist/types/inference/streamEvents.d.ts +253 -721
  203. package/dist/types/inference/usage.d.ts +317 -950
  204. package/dist/types/keyRecovery.d.ts +3 -51
  205. package/dist/types/keyRotation.d.ts +3 -38
  206. package/dist/types/linkedAccounts.d.ts +50 -236
  207. package/dist/types/moderationReputation.d.ts +81 -14
  208. package/dist/types/notifications.d.ts +19 -51
  209. package/dist/types/numberChecks.d.ts +9 -0
  210. package/dist/types/oauth.d.ts +101 -809
  211. package/dist/types/organizations.d.ts +268 -921
  212. package/dist/types/oxyRecordTypes.d.ts +11 -1
  213. package/dist/types/products/access.d.ts +125 -775
  214. package/dist/types/products/billing.d.ts +67 -503
  215. package/dist/types/products/checkout.d.ts +16 -69
  216. package/dist/types/products/plans.d.ts +33 -366
  217. package/dist/types/recommendations.d.ts +76 -389
  218. package/dist/types/reputation.d.ts +37 -5
  219. package/dist/types/safety.d.ts +408 -2048
  220. package/dist/types/serviceToken.d.ts +247 -7
  221. package/dist/types/sessionRevocation.d.ts +2 -17
  222. package/dist/types/sessionStatus.d.ts +27 -115
  223. package/dist/types/signIn.d.ts +62 -553
  224. package/dist/types/stickers.d.ts +67 -819
  225. package/dist/types/stringChecks.d.ts +16 -0
  226. package/dist/types/transparency.d.ts +14 -302
  227. package/dist/types/updates.d.ts +60 -316
  228. package/dist/types/userInvalidation.d.ts +4 -13
  229. package/dist/types/userResponse.d.ts +302 -2400
  230. package/dist/types/username.d.ts +3 -3
  231. package/package.json +6 -4
@@ -1,11 +1,13 @@
1
+ import { integerCheck } from './numberChecks.js';
2
+ import { isoDateTime, urlCheck, utf16MaxLength, utf16MinLength } from './stringChecks.js';
1
3
  import { z } from 'zod';
2
4
  import { catalogInvocationPathParameters, findOverlappingCatalogInvocations, } from './capabilityInvocation.js';
3
- const nonEmptyStringSchema = z.string().trim().min(1);
4
- const identifierSchema = z.string().trim().min(1).max(255);
5
+ const nonEmptyStringSchema = z.string().trim().check(utf16MinLength(1));
6
+ const identifierSchema = z.string().trim().check(utf16MinLength(1)).check(utf16MaxLength(255));
5
7
  const limitKeySchema = z
6
8
  .string()
7
9
  .regex(/^[A-Za-z][A-Za-z0-9_]*(?:\.[A-Za-z][A-Za-z0-9_]*)*$/, 'limit keys must be dot-separated input property names')
8
- .max(255);
10
+ .check(utf16MaxLength(255));
9
11
  const auditCodeSchema = z.string().regex(/^[A-Za-z0-9_.:-]{1,128}$/);
10
12
  const sha256HexSchema = z.string().regex(/^[a-f0-9]{64}$/);
11
13
  const invocationPathSchema = z
@@ -57,7 +59,7 @@ export const foregroundExecutionAuthorizationInputSchema = z
57
59
  .strict(),
58
60
  runId: identifierSchema,
59
61
  stepId: identifierSchema.optional(),
60
- expiresAt: z.string().datetime(),
62
+ expiresAt: z.string().check(isoDateTime()),
61
63
  })
62
64
  .strict();
63
65
  export const resourceRefSchema = z
@@ -68,6 +70,50 @@ export const resourceRefSchema = z
68
70
  resourceId: identifierSchema,
69
71
  })
70
72
  .strict();
73
+ export const firstPartyTaskInputSchema = z
74
+ .object({
75
+ origin: z
76
+ .object({ kind: z.enum(['request', 'goal', 'automation']), id: identifierSchema })
77
+ .strict(),
78
+ actor: executionActorRefSchema,
79
+ effectiveAccountId: identifierSchema,
80
+ expiresAt: z.string().check(isoDateTime()),
81
+ })
82
+ .strict();
83
+ /** Oxy-owned tools use the authenticated requester's task, never per-app grants. */
84
+ export const firstPartyExecutionAuthorizationInputSchema = z
85
+ .object({
86
+ authority: z.literal('first_party'),
87
+ kind: z.enum(['direct_request', 'automation']).default('direct_request'),
88
+ actor: executionActorRefSchema,
89
+ resource: resourceRefSchema,
90
+ tool: identifierSchema,
91
+ expectedCatalog: foregroundExecutionAuthorizationInputSchema.shape.expectedCatalog,
92
+ runId: identifierSchema.optional(),
93
+ stepId: identifierSchema.optional(),
94
+ automationId: identifierSchema.optional(),
95
+ limits: z
96
+ .array(z
97
+ .object({
98
+ tool: identifierSchema,
99
+ key: limitKeySchema,
100
+ value: z.union([z.number().finite(), z.boolean()]),
101
+ })
102
+ .strict())
103
+ .default([]),
104
+ expiresAt: z.string().check(isoDateTime()),
105
+ })
106
+ .strict()
107
+ .superRefine((input, context) => {
108
+ if (input.kind === 'direct_request'
109
+ ? !input.runId || input.automationId !== undefined
110
+ : !input.automationId || input.runId !== undefined || input.stepId !== undefined) {
111
+ context.addIssue({
112
+ code: z.ZodIssueCode.custom,
113
+ message: 'Bind either a direct run or an automation identity.',
114
+ });
115
+ }
116
+ });
71
117
  export const toolGrantOverrideSchema = z
72
118
  .object({
73
119
  tool: identifierSchema,
@@ -115,9 +161,9 @@ export const capabilityCoordinatorSchema = z
115
161
  /** Opt-in catalogue pin; legacy issuance omits expectedCatalog and its claim. */
116
162
  export const capabilityTicketRequestSchema = z
117
163
  .object({
118
- executionAuthorizationId: z.string().min(1),
119
- runId: z.string().min(1).optional(),
120
- stepId: z.string().min(1).optional(),
164
+ executionAuthorizationId: z.string().check(utf16MinLength(1)),
165
+ runId: z.string().check(utf16MinLength(1)).optional(),
166
+ stepId: z.string().check(utf16MinLength(1)).optional(),
121
167
  expectedCatalog: capabilityCatalogBindingSchema.optional(),
122
168
  })
123
169
  .strict();
@@ -134,10 +180,10 @@ export const delegationGrantSchema = z
134
180
  limits: z.array(grantLimitSchema).default([]),
135
181
  maximumAutonomy: autonomyLevelSchema,
136
182
  canRedelegate: z.boolean().default(false),
137
- expiresAt: z.string().datetime().nullable(),
138
- revokedAt: z.string().datetime().nullable().default(null),
139
- createdAt: z.string().datetime(),
140
- updatedAt: z.string().datetime(),
183
+ expiresAt: z.string().check(isoDateTime()).nullable(),
184
+ revokedAt: z.string().check(isoDateTime()).nullable().default(null),
185
+ createdAt: z.string().check(isoDateTime()),
186
+ updatedAt: z.string().check(isoDateTime()),
141
187
  })
142
188
  .strict();
143
189
  /**
@@ -163,10 +209,10 @@ export const agentRequesterCeilingSchema = agentRequesterCeilingWriteSchema
163
209
  agentAccountId: identifierSchema,
164
210
  appId: identifierSchema,
165
211
  catalog: capabilityCatalogBindingSchema,
166
- version: z.number().int().positive(),
167
- revokedAt: z.string().datetime().nullable(),
168
- createdAt: z.string().datetime(),
169
- updatedAt: z.string().datetime(),
212
+ version: z.number().check(integerCheck()).positive(),
213
+ revokedAt: z.string().check(isoDateTime()).nullable(),
214
+ createdAt: z.string().check(isoDateTime()),
215
+ updatedAt: z.string().check(isoDateTime()),
170
216
  })
171
217
  .strict();
172
218
  /**
@@ -186,8 +232,8 @@ export const applicationAgentSchema = applicationAgentWriteSchema
186
232
  applicationId: identifierSchema,
187
233
  agentAccountId: identifierSchema,
188
234
  createdByUserId: identifierSchema.nullable(),
189
- createdAt: z.string().datetime(),
190
- updatedAt: z.string().datetime(),
235
+ createdAt: z.string().check(isoDateTime()),
236
+ updatedAt: z.string().check(isoDateTime()),
191
237
  })
192
238
  .strict();
193
239
  /**
@@ -236,14 +282,14 @@ export const automationDefinitionSchema = z
236
282
  objective: nonEmptyStringSchema,
237
283
  trigger: automationTriggerSchema,
238
284
  actorSelection: automationActorSelectionSchema,
239
- inputs: z.record(z.unknown()),
285
+ inputs: z.record(z.string(), z.unknown()),
240
286
  resources: z.array(resourceRefSchema),
241
287
  dataFlow: automationDataFlowSchema,
242
288
  maximumAutonomy: autonomyLevelSchema,
243
289
  limits: z.array(grantLimitSchema).default([]),
244
290
  enabled: z.boolean(),
245
- createdAt: z.string().datetime(),
246
- updatedAt: z.string().datetime(),
291
+ createdAt: z.string().check(isoDateTime()),
292
+ updatedAt: z.string().check(isoDateTime()),
247
293
  })
248
294
  .strict();
249
295
  export const capabilityTicketClaimsSchema = z
@@ -252,12 +298,14 @@ export const capabilityTicketClaimsSchema = z
252
298
  aud: identifierSchema,
253
299
  sub: identifierSchema,
254
300
  jti: identifierSchema,
255
- iat: z.number().int().nonnegative(),
256
- exp: z.number().int().positive(),
301
+ iat: z.number().check(integerCheck()).nonnegative(),
302
+ exp: z.number().check(integerCheck()).positive(),
257
303
  runId: identifierSchema,
258
304
  stepId: identifierSchema.optional(),
259
305
  automationId: identifierSchema.optional(),
260
306
  executionAuthorization: executionAuthorizationRefSchema,
307
+ authority: z.enum(['first_party', 'external']).optional(),
308
+ taskId: identifierSchema.optional(),
261
309
  coordinator: capabilityCoordinatorSchema,
262
310
  /** Signed only for callers that explicitly requested a pinned catalogue. */
263
311
  catalog: capabilityCatalogBindingSchema.optional(),
@@ -291,6 +339,7 @@ export const capabilityTicketClaimsSchema = z
291
339
  });
292
340
  }
293
341
  if (claims.actor.type === 'requester' &&
342
+ claims.authority !== 'first_party' &&
294
343
  (claims.actor.accountId !== claims.requesterAccountId ||
295
344
  claims.executionAuthorization.kind !== 'direct_request' ||
296
345
  claims.autonomy !== 'read_only' ||
@@ -302,6 +351,14 @@ export const capabilityTicketClaimsSchema = z
302
351
  message: 'requester actors require their exact principal and direct read-only authority without standing grants',
303
352
  });
304
353
  }
354
+ if (claims.authority === 'first_party' &&
355
+ (claims.grantId !== undefined || claims.ceilingId !== undefined)) {
356
+ context.addIssue({
357
+ code: z.ZodIssueCode.custom,
358
+ message: 'Own tool tasks cannot carry external grants or ceilings',
359
+ path: ['authority'],
360
+ });
361
+ }
305
362
  if (claims.ceilingId !== undefined) {
306
363
  if (claims.grantId !== undefined) {
307
364
  context.addIssue({
@@ -363,7 +420,7 @@ export const invocationPrincipalSchema = z.discriminatedUnion('kind', [
363
420
  originAccountId: identifierSchema,
364
421
  activeAccountId: identifierSchema,
365
422
  scopes: z.array(identifierSchema),
366
- resource: z.string().url(),
423
+ resource: z.string().check(urlCheck()),
367
424
  })
368
425
  .strict(),
369
426
  z
@@ -393,7 +450,7 @@ export const auditResultSchema = z
393
450
  export const auditEventSchema = z
394
451
  .object({
395
452
  eventId: identifierSchema,
396
- occurredAt: z.string().datetime(),
453
+ occurredAt: z.string().check(isoDateTime()),
397
454
  requesterAccountId: identifierSchema,
398
455
  coordinator: capabilityCoordinatorSchema,
399
456
  executor: executionActorRefSchema,
@@ -440,8 +497,8 @@ export const catalogToolSchema = z
440
497
  name: identifierSchema,
441
498
  version: identifierSchema,
442
499
  description: nonEmptyStringSchema,
443
- inputSchema: z.record(z.unknown()),
444
- outputSchema: z.record(z.unknown()).optional(),
500
+ inputSchema: z.record(z.string(), z.unknown()),
501
+ outputSchema: z.record(z.string(), z.unknown()).optional(),
445
502
  capabilityPackage: capabilityPackageSchema,
446
503
  requiredCapabilities: z.array(identifierSchema).min(1),
447
504
  resourceTypes: z.array(identifierSchema).min(1),
@@ -618,7 +675,7 @@ export const catalogEventSchema = z
618
675
  type: identifierSchema,
619
676
  version: identifierSchema,
620
677
  description: nonEmptyStringSchema,
621
- dataSchema: z.record(z.unknown()),
678
+ dataSchema: z.record(z.string(), z.unknown()),
622
679
  resourceTypes: z.array(identifierSchema).min(1),
623
680
  })
624
681
  .strict();
@@ -632,7 +689,7 @@ export const catalogFeatureSchema = z
632
689
  key: z
633
690
  .string()
634
691
  .regex(/^[a-z][a-z0-9_-]*(?:\.[a-z][a-z0-9_-]*)*$/, 'feature keys are dot-separated slugs')
635
- .max(128),
692
+ .check(utf16MaxLength(128)),
636
693
  description: nonEmptyStringSchema,
637
694
  checkTool: identifierSchema,
638
695
  consumeTool: identifierSchema.optional(),
@@ -649,7 +706,7 @@ export const appCapabilityCatalogSchema = z
649
706
  /** HTTPS origin that serves the catalog's internal invocation paths. */
650
707
  internalBaseUrl: z
651
708
  .string()
652
- .url()
709
+ .check(urlCheck())
653
710
  .superRefine((value, context) => {
654
711
  const url = new URL(value);
655
712
  const localDevelopment = url.hostname === 'localhost' || url.hostname === '127.0.0.1';
@@ -673,7 +730,7 @@ export const appCapabilityCatalogSchema = z
673
730
  .object({
674
731
  resource: z
675
732
  .string()
676
- .url()
733
+ .check(urlCheck())
677
734
  .superRefine((value, context) => {
678
735
  const url = new URL(value);
679
736
  const localDevelopment = url.hostname === 'localhost' ||
@@ -783,7 +840,7 @@ export const catalogRegistrationSchema = z
783
840
  catalog: appCapabilityCatalogSchema,
784
841
  digest: z.string().regex(/^[a-f0-9]{64}$/),
785
842
  signature: nonEmptyStringSchema,
786
- deployedAt: z.string().datetime(),
843
+ deployedAt: z.string().check(isoDateTime()),
787
844
  })
788
845
  .strict();
789
846
  export const normalizedAppEventSchema = z
@@ -793,8 +850,8 @@ export const normalizedAppEventSchema = z
793
850
  accountId: identifierSchema,
794
851
  resource: resourceRefSchema,
795
852
  type: identifierSchema,
796
- occurredAt: z.string().datetime(),
797
- data: z.record(z.unknown()),
853
+ occurredAt: z.string().check(isoDateTime()),
854
+ data: z.record(z.string(), z.unknown()),
798
855
  })
799
856
  .strict();
800
857
  /** The actor types that may execute `tool`: the one reading of an absent `actors`. */
@@ -1,3 +1,5 @@
1
+ import { integerCheck } from './numberChecks.js';
2
+ import { isoDateTime, utf16MaxLength, utf16MinLength } from './stringChecks.js';
1
3
  /** Autonomous runtime proof. No private key crosses this contract. */
2
4
  import { z } from 'zod';
3
5
  import { reauthProofSchema } from './signIn.js';
@@ -11,13 +13,13 @@ export const agentProofClaimsSchema = z
11
13
  version: z.literal(1),
12
14
  audience: z.literal(AGENT_PROOF_AUDIENCE),
13
15
  action: z.enum(AGENT_PROOF_ACTIONS),
14
- accountId: z.string().min(1),
15
- actorId: z.string().min(1),
16
+ accountId: z.string().check(utf16MinLength(1)),
17
+ actorId: z.string().check(utf16MinLength(1)),
16
18
  authMethodId: z.string().nullable(),
17
- publicKey: z.string().min(1),
19
+ publicKey: z.string().check(utf16MinLength(1)),
18
20
  payloadDigest: z.string().regex(/^[0-9a-f]{64}$/),
19
21
  challenge: z.string().regex(/^[0-9a-f]{64}$/),
20
- expiresAt: z.number().int().positive(),
22
+ expiresAt: z.number().check(integerCheck()).positive(),
21
23
  })
22
24
  .strict();
23
25
  /** Different proof roles cannot substitute for one another on the same operation. */
@@ -35,19 +37,19 @@ export const agentSignatureSchema = z
35
37
  signature: z
36
38
  .string()
37
39
  .regex(/^[0-9a-f]+$/i)
38
- .max(160),
39
- timestamp: z.number().int().positive(),
40
+ .check(utf16MaxLength(160)),
41
+ timestamp: z.number().check(integerCheck()).positive(),
40
42
  })
41
43
  .strict();
42
44
  export const agentChallengeRequestSchema = z
43
- .object({ publicKey: z.string().trim().min(1).max(130) })
45
+ .object({ publicKey: z.string().trim().check(utf16MinLength(1)).check(utf16MaxLength(130)) })
44
46
  .strict();
45
47
  export const agentVerifyRequestSchema = agentSignatureSchema
46
- .extend({ publicKey: z.string().trim().min(1).max(130) })
48
+ .extend({ publicKey: z.string().trim().check(utf16MinLength(1)).check(utf16MaxLength(130)) })
47
49
  .strict();
48
50
  const newKey = {
49
- publicKey: z.string().trim().min(1).max(130),
50
- label: z.string().trim().min(1).max(120),
51
+ publicKey: z.string().trim().check(utf16MinLength(1)).check(utf16MaxLength(130)),
52
+ label: z.string().trim().check(utf16MinLength(1)).check(utf16MaxLength(120)),
51
53
  };
52
54
  export const agentKeyOperationSchema = z.discriminatedUnion('operation', [
53
55
  z.object({ operation: z.literal('enroll'), ...newKey }).strict(),
@@ -55,21 +57,23 @@ export const agentKeyOperationSchema = z.discriminatedUnion('operation', [
55
57
  z
56
58
  .object({ operation: z.literal('rotate'), ...newKey, retireCurrent: z.boolean().optional() })
57
59
  .strict(),
58
- z.object({ operation: z.literal('revoke'), methodId: z.string().min(1) }).strict(),
60
+ z
61
+ .object({ operation: z.literal('revoke'), methodId: z.string().check(utf16MinLength(1)) })
62
+ .strict(),
59
63
  ]);
60
64
  export const agentKeyOperationProofSchema = z
61
65
  .object({
62
66
  challenge: z.string().regex(/^[0-9a-f]{64}$/),
63
- timestamp: z.number().int().positive(),
67
+ timestamp: z.number().check(integerCheck()).positive(),
64
68
  keySignature: z
65
69
  .string()
66
70
  .regex(/^[0-9a-f]+$/i)
67
- .max(160)
71
+ .check(utf16MaxLength(160))
68
72
  .optional(),
69
73
  governorSignature: z
70
74
  .string()
71
75
  .regex(/^[0-9a-f]+$/i)
72
- .max(160)
76
+ .check(utf16MaxLength(160))
73
77
  .optional(),
74
78
  reauth: reauthProofSchema.optional(),
75
79
  })
@@ -102,9 +106,9 @@ export const agentKeyListResponseSchema = z
102
106
  label: z.string(),
103
107
  enrolledByUserId: z.string().nullable(),
104
108
  enrollmentMethod: z.enum(['governor', 'rotation', 'recovery']),
105
- linkedAt: z.string().datetime(),
106
- lastUsedAt: z.string().datetime().nullable(),
107
- revokedAt: z.string().datetime().nullable(),
109
+ linkedAt: z.string().check(isoDateTime()),
110
+ lastUsedAt: z.string().check(isoDateTime()).nullable(),
111
+ revokedAt: z.string().check(isoDateTime()).nullable(),
108
112
  })
109
113
  .strict()),
110
114
  })
@@ -1,3 +1,4 @@
1
+ import { isoDateTime, utf16MaxLength, utf16MinLength } from './stringChecks.js';
1
2
  /**
2
3
  * App assertions (ADR 0045): how an Oxy app proves which app it is.
3
4
  *
@@ -25,12 +26,12 @@
25
26
  import { z } from 'zod';
26
27
  import { APP_ASSERTION_CHALLENGE_PURPOSES, APP_ASSERTION_ERROR_CODES, APP_ASSERTION_PLATFORMS, OXY_APP_ASSERTION_AUDIENCE, OXY_APP_ASSERTION_HEADER, OXY_APP_ASSERTION_TTL_SECONDS, OXY_APP_ASSERTION_TYPE, } from './client/appAssertions.js';
27
28
  export { APP_ASSERTION_CHALLENGE_PURPOSES, APP_ASSERTION_ERROR_CODES, APP_ASSERTION_PLATFORMS, OXY_APP_ASSERTION_AUDIENCE, OXY_APP_ASSERTION_HEADER, OXY_APP_ASSERTION_TTL_SECONDS, OXY_APP_ASSERTION_TYPE, };
28
- const applicationIdSchema = z.string().trim().min(1).max(255);
29
+ const applicationIdSchema = z.string().trim().check(utf16MinLength(1)).check(utf16MaxLength(255));
29
30
  const base64Url32Schema = z.string().regex(/^[A-Za-z0-9_-]{43}$/);
30
31
  const base64Schema = (max) => z
31
32
  .string()
32
- .min(4)
33
- .max(max)
33
+ .check(utf16MinLength(4))
34
+ .check(utf16MaxLength(max))
34
35
  .regex(/^[A-Za-z0-9+/]+={0,2}$/);
35
36
  export const appAssertionPlatformSchema = z.enum(APP_ASSERTION_PLATFORMS);
36
37
  export const appAssertionErrorCodeSchema = z.enum(APP_ASSERTION_ERROR_CODES);
@@ -50,12 +51,12 @@ export function isExactHttpsOrigin(value) {
50
51
  /** An exact `https://` origin, in the form a browser sends in `Origin` (`https://mention.earth`). */
51
52
  export const applicationWebOriginSchema = z
52
53
  .string()
53
- .max(255)
54
+ .check(utf16MaxLength(255))
54
55
  .refine(isExactHttpsOrigin, 'Must be an exact https origin, as a browser sends it');
55
56
  /** A Java-style Android application id, at least two segments. */
56
57
  export const androidPackageNameSchema = z
57
58
  .string()
58
- .max(255)
59
+ .check(utf16MaxLength(255))
59
60
  .regex(/^[A-Za-z][A-Za-z0-9_]*(?:\.[A-Za-z][A-Za-z0-9_]*)+$/, 'Must be an Android package name');
60
61
  /** A signing certificate's SHA-256, 64 lowercase hex characters (keytool's digest without colons). */
61
62
  export const signingCertSha256Schema = z
@@ -66,7 +67,7 @@ export const appleTeamIdSchema = z.string().regex(/^[A-Z0-9]{10}$/, 'Must be an
66
67
  /** An Apple bundle id. */
67
68
  export const appleBundleIdSchema = z
68
69
  .string()
69
- .max(255)
70
+ .check(utf16MaxLength(255))
70
71
  .regex(/^[A-Za-z0-9-]+(?:\.[A-Za-z0-9-]+)+$/, 'Must be an Apple bundle id');
71
72
  const unique = (values) => new Set(values).size === values.length;
72
73
  export const applicationAndroidRecognitionSchema = z
@@ -100,7 +101,7 @@ export const applicationRecognitionWriteSchema = z
100
101
  export const applicationRecognitionSchema = applicationRecognitionWriteSchema
101
102
  .extend({
102
103
  applicationId: applicationIdSchema,
103
- updatedAt: z.string().datetime().nullable(),
104
+ updatedAt: z.string().check(isoDateTime()).nullable(),
104
105
  })
105
106
  .strict();
106
107
  // ---------------------------------------------------------------------------
@@ -127,7 +128,7 @@ export const appAssertionChallengeResponseSchema = z
127
128
  .object({
128
129
  challenge: base64Url32Schema,
129
130
  requestHash: base64Url32Schema,
130
- expiresAt: z.string().datetime(),
131
+ expiresAt: z.string().check(isoDateTime()),
131
132
  cloudProjectNumber: z
132
133
  .string()
133
134
  .regex(/^[0-9]{1,20}$/)
@@ -161,7 +162,7 @@ export const appAssertionRequestSchema = z.discriminatedUnion('platform', [
161
162
  proof: z
162
163
  .object({
163
164
  challenge: base64Url32Schema,
164
- integrityToken: z.string().min(1).max(16384),
165
+ integrityToken: z.string().check(utf16MinLength(1)).check(utf16MaxLength(16384)),
165
166
  })
166
167
  .strict(),
167
168
  })
@@ -186,6 +187,6 @@ export const appAssertionResponseSchema = z
186
187
  assertion: z.string().regex(/^[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+$/),
187
188
  applicationId: z.string().regex(/^\S{1,255}$/),
188
189
  platform: appAssertionPlatformSchema,
189
- expiresAt: z.string().datetime(),
190
+ expiresAt: z.string().check(isoDateTime()),
190
191
  })
191
192
  .strict();
@@ -1,3 +1,5 @@
1
+ import { integerCheck } from './numberChecks.js';
2
+ import { utf16MaxLength, utf16MinLength } from './stringChecks.js';
1
3
  /**
2
4
  * Application roles — the wire contract for permissions an APPLICATION declares
3
5
  * about its own users, and for the grants that give them to Oxy users.
@@ -68,22 +70,22 @@ export function isApplicationPermissionKey(value) {
68
70
  }
69
71
  export const applicationPermissionKeySchema = z
70
72
  .string()
71
- .max(APPLICATION_PERMISSION_KEY_MAX_LENGTH)
73
+ .check(utf16MaxLength(APPLICATION_PERMISSION_KEY_MAX_LENGTH))
72
74
  .regex(APPLICATION_PERMISSION_KEY_PATTERN, 'A permission key is 2-4 dot-separated lowercase segments, e.g. payments.operate');
73
75
  /** Plain text: no control characters other than a newline or a tab. */
74
76
  function plainText(max) {
75
77
  return z
76
78
  .string()
77
79
  .trim()
78
- .min(1)
79
- .max(max)
80
+ .check(utf16MinLength(1))
81
+ .check(utf16MaxLength(max))
80
82
  .refine((value) => Array.from(value).every((character) => {
81
83
  const code = character.charCodeAt(0);
82
84
  return (code >= 32 && code !== 127) || character === '\n' || character === '\t';
83
85
  }), 'Must be plain text');
84
86
  }
85
- const id = z.string().min(1).max(128);
86
- const isoTimestamp = z.string().min(1);
87
+ const id = z.string().check(utf16MinLength(1)).check(utf16MaxLength(128));
88
+ const isoTimestamp = z.string().check(utf16MinLength(1));
87
89
  const reasonSchema = plainText(APPLICATION_ROLE_REASON_MAX_LENGTH);
88
90
  /** One key as the application's owners declare it. */
89
91
  export const applicationPermissionDeclarationSchema = z
@@ -140,7 +142,7 @@ export const declareApplicationPermissionsResponseSchema = applicationPermission
140
142
  /** Live keys whose description changed. */
141
143
  described: z.array(applicationPermissionKeySchema),
142
144
  /** Live grants revoked because their key was retired. */
143
- revokedGrants: z.number().int().nonnegative(),
145
+ revokedGrants: z.number().check(integerCheck()).nonnegative(),
144
146
  });
145
147
  /** One grant of one key to one Oxy user. Revocation is a stamp, never a delete. */
146
148
  export const applicationRoleGrantSchema = z.object({
@@ -166,7 +168,7 @@ export const applicationRoleGrantListSchema = z.object({
166
168
  export const createApplicationRoleGrantRequestSchema = z
167
169
  .object({
168
170
  userId: id.optional(),
169
- username: z.string().trim().min(1).max(64).optional(),
171
+ username: z.string().trim().check(utf16MinLength(1)).check(utf16MaxLength(64)).optional(),
170
172
  permission: applicationPermissionKeySchema,
171
173
  reason: reasonSchema.optional(),
172
174
  })
@@ -190,8 +192,13 @@ export const listApplicationRoleGrantsQuerySchema = z
190
192
  .enum(['true', 'false'])
191
193
  .transform((value) => value === 'true')
192
194
  .optional(),
193
- limit: z.coerce.number().int().min(1).max(APPLICATION_ROLE_GRANTS_PAGE_MAX).optional(),
194
- cursor: z.string().min(1).max(512).optional(),
195
+ limit: z.coerce
196
+ .number()
197
+ .check(integerCheck())
198
+ .min(1)
199
+ .max(APPLICATION_ROLE_GRANTS_PAGE_MAX)
200
+ .optional(),
201
+ cursor: z.string().check(utf16MinLength(1)).check(utf16MaxLength(512)).optional(),
195
202
  })
196
203
  .strict();
197
204
  /**
@@ -0,0 +1,25 @@
1
+ import { z } from 'zod';
2
+ import { utf16MaxLength, utf16MinLength } from './stringChecks.js';
3
+ import { CAMPAIGN_LABEL_MAX_LENGTH, hasCampaignControlCharacters, CAMPAIGN_CLICK_ID_MAX_LENGTH, } from './client/campaignAttribution.js';
4
+ const campaignValue = (limit) => z
5
+ .string()
6
+ .trim()
7
+ .check(utf16MinLength(1))
8
+ .check(utf16MaxLength(limit))
9
+ .refine((value) => !hasCampaignControlCharacters(value), {
10
+ message: 'Campaign values cannot contain control characters',
11
+ });
12
+ /** Only bounded campaign labels are accepted, never a URL, IP or profile data. */
13
+ export const campaignAttributionSchema = z
14
+ .object({
15
+ utmSource: campaignValue(CAMPAIGN_LABEL_MAX_LENGTH).optional(),
16
+ utmMedium: campaignValue(CAMPAIGN_LABEL_MAX_LENGTH).optional(),
17
+ utmCampaign: campaignValue(CAMPAIGN_LABEL_MAX_LENGTH).optional(),
18
+ utmContent: campaignValue(CAMPAIGN_LABEL_MAX_LENGTH).optional(),
19
+ utmTerm: campaignValue(CAMPAIGN_LABEL_MAX_LENGTH).optional(),
20
+ fbclid: campaignValue(CAMPAIGN_CLICK_ID_MAX_LENGTH).optional(),
21
+ })
22
+ .strict()
23
+ .refine((value) => Object.values(value).some((entry) => entry !== undefined), {
24
+ message: 'At least one campaign parameter is required',
25
+ });
package/dist/esm/civic.js CHANGED
@@ -1,3 +1,4 @@
1
+ import { utf16MinLength } from './stringChecks.js';
1
2
  /**
2
3
  * Civic / Commons API contracts (Fase 1 — DNI + crypto-owned reputation).
3
4
  *
@@ -68,9 +69,9 @@ export const validationVerdictRecordSchema = z.object({
68
69
  /** Request body for opening a validation request (`POST /civic/validations`). */
69
70
  export const validationOpenRequestSchema = z.object({
70
71
  subjectUserId: z.string(),
71
- actionType: z.string().min(1),
72
- sourceActionId: z.string().min(1),
73
- payload: z.record(z.unknown()),
72
+ actionType: z.string().check(utf16MinLength(1)),
73
+ sourceActionId: z.string().check(utf16MinLength(1)),
74
+ payload: z.record(z.string(), z.unknown()),
74
75
  highValue: z.boolean().optional(),
75
76
  });
76
77
  export const validationOpenResultSchema = z.object({
@@ -82,7 +83,7 @@ export const validationRequestSummarySchema = z.object({
82
83
  id: z.string(),
83
84
  subjectUserId: z.string(),
84
85
  actionType: z.string(),
85
- payload: z.record(z.unknown()),
86
+ payload: z.record(z.string(), z.unknown()),
86
87
  payloadHash: z.string(),
87
88
  status: z.enum(['pending', 'quorum_met', 'validated', 'rejected', 'expired']),
88
89
  highValue: z.boolean(),
@@ -128,8 +129,8 @@ export const vouchResultSchema = z.object({
128
129
  });
129
130
  export const credentialRecordSchema = z.object({
130
131
  about: z.string(),
131
- types: z.array(z.string().min(1)).min(1),
132
- claims: z.record(z.unknown()),
132
+ types: z.array(z.string().check(utf16MinLength(1))).min(1),
133
+ claims: z.record(z.string(), z.unknown()),
133
134
  expiresAt: z.number().optional(),
134
135
  });
135
136
  export const verifiableCredentialResponseSchema = z.object({
@@ -140,7 +141,7 @@ export const verifiableCredentialResponseSchema = z.object({
140
141
  issuerUserId: z.string().optional(),
141
142
  issuerDid: z.string(),
142
143
  types: z.array(z.string()),
143
- claims: z.record(z.unknown()),
144
+ claims: z.record(z.string(), z.unknown()),
144
145
  status: z.enum(['active', 'revoked', 'expired']),
145
146
  issuedAt: z.number(),
146
147
  expiresAt: z.number().optional(),
@@ -0,0 +1,10 @@
1
+ export const CAMPAIGN_LABEL_MAX_LENGTH = 256;
2
+ export const CAMPAIGN_CLICK_ID_MAX_LENGTH = 1024;
3
+ export function hasCampaignControlCharacters(value) {
4
+ for (let index = 0; index < value.length; index += 1) {
5
+ const code = value.charCodeAt(index);
6
+ if (code < 32 || code === 127)
7
+ return true;
8
+ }
9
+ return false;
10
+ }