@adastracomputing/ink 0.1.6 → 0.1.7

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.
package/CHANGELOG.md CHANGED
@@ -8,6 +8,14 @@ here. Pre-1.0 releases follow `0.Y.Z` semantics, see
8
8
 
9
9
  No unreleased changes.
10
10
 
11
+ ## 0.1.7, expose per-intent payload schemas and getPayloadSchema from the package root
12
+
13
+ Pure additive release. Re-exports every per-intent Zod payload schema (`ScheduleMeetingPayloadSchema`, `IntroRequestPayloadSchema`, `OpportunityPayloadSchema`, `ConnectionRequestPayloadSchema`, `FollowUpPayloadSchema`, `AskPayloadSchema`, `PingPayloadSchema`, `RetractPayloadSchema`, `ContextSharePayloadSchema`, `MultiPartySyncPayloadSchema`, plus the matching `*ResponsePayloadSchema` variants) and the `getPayloadSchema(intent)` resolver from the package root. Adopters writing intent-aware receivers / handlers can now type their dispatch surface directly against the canonical payload shapes.
14
+
15
+ No wire-level changes. No behavior changes inside the existing functions. Receivers on 0.1.6 work unchanged on 0.1.7.
16
+
17
+ Per the pre-1.0 policy this release publishes under the `next` dist-tag.
18
+
11
19
  ## 0.1.6, expose intent + key-entry types and add optional inclusionProof to InkAuditInclusionSchema
12
20
 
13
21
  Pure additive release. Two surface expansions and one backward-compatible schema addition:
package/dist/index.d.ts CHANGED
@@ -16,7 +16,7 @@ export type { InkAuditEventType, InkAuditEvent, InkAuditInclusion, InkReceipt, I
16
16
  export { InkChallengeSchema, InkRejectionSchema, InkResolutionSchema, InkTransportSchema, } from "./models/ink-handshake.js";
17
17
  export type { AgentCardVisibility, InkChallenge, InkRejection, InkResolution, InkTransport, } from "./models/ink-handshake.js";
18
18
  export { AgentCardSchema } from "./models/agent-card.js";
19
- export { validateMessage, MessageEnvelopeSchema, IntentTypeSchema, } from "./models/intent.js";
19
+ export { validateMessage, getPayloadSchema, MessageEnvelopeSchema, IntentTypeSchema, ScheduleMeetingPayloadSchema, ScheduleMeetingResponsePayloadSchema, IntroRequestPayloadSchema, IntroResponsePayloadSchema, OpportunityPayloadSchema, OpportunityResponsePayloadSchema, ConnectionRequestPayloadSchema, ConnectionResponsePayloadSchema, FollowUpPayloadSchema, AskPayloadSchema, AskResponsePayloadSchema, PingPayloadSchema, RetractPayloadSchema, ContextSharePayloadSchema, MultiPartySyncPayloadSchema, } from "./models/intent.js";
20
20
  export type { MessageEnvelope, IntentType, } from "./models/intent.js";
21
21
  export { KeyStatusSchema, KeyRoleSchema, KeyEntrySchema, } from "./models/key-entry.js";
22
22
  export type { KeyStatus, KeyRole, KeyEntry, StoredKey, } from "./models/key-entry.js";
package/dist/index.js CHANGED
@@ -32,7 +32,7 @@ export { AgentCardSchema } from "./models/agent-card.js";
32
32
  // reject malformed envelopes before signature verification; without
33
33
  // it they have to re-implement the schema check or import from a
34
34
  // non-public path.
35
- export { validateMessage, MessageEnvelopeSchema, IntentTypeSchema, } from "./models/intent.js";
35
+ export { validateMessage, getPayloadSchema, MessageEnvelopeSchema, IntentTypeSchema, ScheduleMeetingPayloadSchema, ScheduleMeetingResponsePayloadSchema, IntroRequestPayloadSchema, IntroResponsePayloadSchema, OpportunityPayloadSchema, OpportunityResponsePayloadSchema, ConnectionRequestPayloadSchema, ConnectionResponsePayloadSchema, FollowUpPayloadSchema, AskPayloadSchema, AskResponsePayloadSchema, PingPayloadSchema, RetractPayloadSchema, ContextSharePayloadSchema, MultiPartySyncPayloadSchema, } from "./models/intent.js";
36
36
  // Key-entry types and schemas for adopters wiring their own key-set
37
37
  // storage and rotation. `CandidateKey` was already root-exported via
38
38
  // the verifier surface; this batch adds the persistence shapes.
@@ -96,9 +96,9 @@ export declare const AgentCardResponseSchema: z.ZodObject<{
96
96
  timezone: z.ZodString;
97
97
  meetingHours: z.ZodOptional<z.ZodString>;
98
98
  responseSla: z.ZodOptional<z.ZodString>;
99
- }, z.core.$strip>>;
99
+ }, z.core.$strict>>;
100
100
  openTo: z.ZodArray<z.ZodString>;
101
- }, z.core.$strip>>;
101
+ }, z.core.$strict>>;
102
102
  capabilities: z.ZodObject<{
103
103
  intentsAccepted: z.ZodArray<z.ZodEnum<{
104
104
  schedule_meeting: "schedule_meeting";
@@ -23,9 +23,9 @@ export declare const AgentCardSchema: z.ZodObject<{
23
23
  timezone: z.ZodString;
24
24
  meetingHours: z.ZodOptional<z.ZodString>;
25
25
  responseSla: z.ZodOptional<z.ZodString>;
26
- }, z.core.$strip>>;
26
+ }, z.core.$strict>>;
27
27
  openTo: z.ZodArray<z.ZodString>;
28
- }, z.core.$strip>>;
28
+ }, z.core.$strict>>;
29
29
  capabilities: z.ZodObject<{
30
30
  intentsAccepted: z.ZodArray<z.ZodEnum<{
31
31
  schedule_meeting: "schedule_meeting";
@@ -33,7 +33,7 @@ export declare const ScheduleMeetingPayloadSchema: z.ZodObject<{
33
33
  }>;
34
34
  context: z.ZodOptional<z.ZodString>;
35
35
  location: z.ZodOptional<z.ZodString>;
36
- }, z.core.$strip>;
36
+ }, z.core.$strict>;
37
37
  export declare const ScheduleMeetingResponsePayloadSchema: z.ZodObject<{
38
38
  status: z.ZodEnum<{
39
39
  accepted: "accepted";
@@ -50,7 +50,7 @@ export declare const ScheduleMeetingResponsePayloadSchema: z.ZodObject<{
50
50
  too_busy: "too_busy";
51
51
  deferred: "deferred";
52
52
  }>>;
53
- }, z.core.$strip>;
53
+ }, z.core.$strict>;
54
54
  export declare const IntroRequestPayloadSchema: z.ZodObject<{
55
55
  target: z.ZodString;
56
56
  reason: z.ZodString;
@@ -59,7 +59,7 @@ export declare const IntroRequestPayloadSchema: z.ZodObject<{
59
59
  low: "low";
60
60
  normal: "normal";
61
61
  }>;
62
- }, z.core.$strip>;
62
+ }, z.core.$strict>;
63
63
  export declare const IntroResponsePayloadSchema: z.ZodObject<{
64
64
  status: z.ZodEnum<{
65
65
  declined: "declined";
@@ -72,7 +72,7 @@ export declare const IntroResponsePayloadSchema: z.ZodObject<{
72
72
  declined: "declined";
73
73
  pending: "pending";
74
74
  }>>;
75
- }, z.core.$strip>;
75
+ }, z.core.$strict>;
76
76
  export declare const OpportunityPayloadSchema: z.ZodObject<{
77
77
  type: z.ZodEnum<{
78
78
  role: "role";
@@ -88,7 +88,7 @@ export declare const OpportunityPayloadSchema: z.ZodObject<{
88
88
  matchReason: z.ZodString;
89
89
  expiresAt: z.ZodOptional<z.ZodString>;
90
90
  url: z.ZodOptional<z.ZodString>;
91
- }, z.core.$strip>;
91
+ }, z.core.$strict>;
92
92
  export declare const OpportunityResponsePayloadSchema: z.ZodObject<{
93
93
  status: z.ZodEnum<{
94
94
  not_interested: "not_interested";
@@ -113,7 +113,7 @@ export declare const OpportunityResponsePayloadSchema: z.ZodObject<{
113
113
  retract: "retract";
114
114
  multi_party_sync: "multi_party_sync";
115
115
  }>>;
116
- }, z.core.$strip>;
116
+ }, z.core.$strict>;
117
117
  export declare const ConnectionRequestPayloadSchema: z.ZodObject<{
118
118
  method: z.ZodEnum<{
119
119
  qr: "qr";
@@ -131,10 +131,10 @@ export declare const ConnectionRequestPayloadSchema: z.ZodObject<{
131
131
  timezone: z.ZodString;
132
132
  meetingHours: z.ZodOptional<z.ZodString>;
133
133
  responseSla: z.ZodOptional<z.ZodString>;
134
- }, z.core.$strip>>;
134
+ }, z.core.$strict>>;
135
135
  openTo: z.ZodArray<z.ZodString>;
136
- }, z.core.$strip>;
137
- }, z.core.$strip>;
136
+ }, z.core.$strict>;
137
+ }, z.core.$strict>;
138
138
  export declare const ConnectionResponsePayloadSchema: z.ZodObject<{
139
139
  status: z.ZodEnum<{
140
140
  accepted: "accepted";
@@ -149,11 +149,11 @@ export declare const ConnectionResponsePayloadSchema: z.ZodObject<{
149
149
  timezone: z.ZodString;
150
150
  meetingHours: z.ZodOptional<z.ZodString>;
151
151
  responseSla: z.ZodOptional<z.ZodString>;
152
- }, z.core.$strip>>;
152
+ }, z.core.$strict>>;
153
153
  openTo: z.ZodArray<z.ZodString>;
154
- }, z.core.$strip>>;
154
+ }, z.core.$strict>>;
155
155
  note: z.ZodOptional<z.ZodString>;
156
- }, z.core.$strip>;
156
+ }, z.core.$strict>;
157
157
  export declare const FollowUpPayloadSchema: z.ZodObject<{
158
158
  referenceId: z.ZodString;
159
159
  message: z.ZodString;
@@ -163,7 +163,7 @@ export declare const FollowUpPayloadSchema: z.ZodObject<{
163
163
  review: "review";
164
164
  none: "none";
165
165
  }>>;
166
- }, z.core.$strip>;
166
+ }, z.core.$strict>;
167
167
  export declare const AskPayloadSchema: z.ZodObject<{
168
168
  question: z.ZodString;
169
169
  context: z.ZodOptional<z.ZodString>;
@@ -173,18 +173,18 @@ export declare const AskPayloadSchema: z.ZodObject<{
173
173
  }>>;
174
174
  choices: z.ZodOptional<z.ZodArray<z.ZodString>>;
175
175
  deadline: z.ZodOptional<z.ZodString>;
176
- }, z.core.$strip>;
176
+ }, z.core.$strict>;
177
177
  export declare const AskResponsePayloadSchema: z.ZodObject<{
178
178
  answer: z.ZodString;
179
179
  choiceIndex: z.ZodOptional<z.ZodNumber>;
180
- }, z.core.$strip>;
180
+ }, z.core.$strict>;
181
181
  export declare const PingPayloadSchema: z.ZodObject<{
182
182
  note: z.ZodOptional<z.ZodString>;
183
- }, z.core.$strip>;
183
+ }, z.core.$strict>;
184
184
  export declare const RetractPayloadSchema: z.ZodObject<{
185
185
  targetMessageId: z.ZodString;
186
186
  reason: z.ZodOptional<z.ZodString>;
187
- }, z.core.$strip>;
187
+ }, z.core.$strict>;
188
188
  export declare const ContextSharePayloadSchema: z.ZodObject<{
189
189
  context: z.ZodString;
190
190
  category: z.ZodEnum<{
@@ -196,7 +196,7 @@ export declare const ContextSharePayloadSchema: z.ZodObject<{
196
196
  }>;
197
197
  referenceId: z.ZodOptional<z.ZodString>;
198
198
  expiresAt: z.ZodOptional<z.ZodString>;
199
- }, z.core.$strip>;
199
+ }, z.core.$strict>;
200
200
  export declare const MultiPartySyncPayloadSchema: z.ZodObject<{
201
201
  enclaveType: z.ZodEnum<{
202
202
  meeting_sync: "meeting_sync";
@@ -204,7 +204,7 @@ export declare const MultiPartySyncPayloadSchema: z.ZodObject<{
204
204
  purpose: z.ZodString;
205
205
  participants: z.ZodArray<z.ZodString>;
206
206
  expiresAt: z.ZodString;
207
- }, z.core.$strip>;
207
+ }, z.core.$strict>;
208
208
  export declare const MessageProvenanceSchema: z.ZodOptional<z.ZodObject<{
209
209
  origin: z.ZodEnum<{
210
210
  human: "human";
@@ -213,7 +213,7 @@ export declare const MessageProvenanceSchema: z.ZodOptional<z.ZodObject<{
213
213
  }>;
214
214
  extensionId: z.ZodString;
215
215
  installationId: z.ZodString;
216
- }, z.core.$strip>>;
216
+ }, z.core.$strict>>;
217
217
  export declare const MessageEnvelopeSchema: z.ZodObject<{
218
218
  protocol: z.ZodLiteral<"ink/0.1">;
219
219
  id: z.ZodString;
@@ -242,6 +242,8 @@ export declare const MessageEnvelopeSchema: z.ZodObject<{
242
242
  payload: z.ZodUnknown;
243
243
  signature: z.ZodString;
244
244
  signingKeyId: z.ZodOptional<z.ZodString>;
245
+ timestamp: z.ZodOptional<z.ZodString>;
246
+ nonce: z.ZodOptional<z.ZodString>;
245
247
  provenance: z.ZodOptional<z.ZodObject<{
246
248
  origin: z.ZodEnum<{
247
249
  human: "human";
@@ -250,8 +252,8 @@ export declare const MessageEnvelopeSchema: z.ZodObject<{
250
252
  }>;
251
253
  extensionId: z.ZodString;
252
254
  installationId: z.ZodString;
253
- }, z.core.$strip>>;
254
- }, z.core.$strip>;
255
+ }, z.core.$strict>>;
256
+ }, z.core.$strict>;
255
257
  export type MessageEnvelope = z.infer<typeof MessageEnvelopeSchema>;
256
258
  /**
257
259
  * Validate a message envelope AND its payload based on the intent type.
@@ -260,6 +262,10 @@ export type MessageEnvelope = z.infer<typeof MessageEnvelopeSchema>;
260
262
  export declare function validateMessage(raw: unknown): MessageEnvelope;
261
263
  /**
262
264
  * Get the payload schema for a given intent type.
265
+ *
266
+ * Runtime-validates the `intent` argument against IntentTypeSchema so a
267
+ * JS caller cannot pass an arbitrary string and silently get `undefined`
268
+ * back; the function instead throws ZodError on an invalid intent.
263
269
  */
264
270
  export declare function getPayloadSchema(intent: IntentType): z.ZodObject<{
265
271
  proposedTimes: z.ZodArray<z.ZodString>;
@@ -277,7 +283,7 @@ export declare function getPayloadSchema(intent: IntentType): z.ZodObject<{
277
283
  }>;
278
284
  context: z.ZodOptional<z.ZodString>;
279
285
  location: z.ZodOptional<z.ZodString>;
280
- }, z.core.$strip> | z.ZodObject<{
286
+ }, z.core.$strict> | z.ZodObject<{
281
287
  status: z.ZodEnum<{
282
288
  accepted: "accepted";
283
289
  declined: "declined";
@@ -293,7 +299,7 @@ export declare function getPayloadSchema(intent: IntentType): z.ZodObject<{
293
299
  too_busy: "too_busy";
294
300
  deferred: "deferred";
295
301
  }>>;
296
- }, z.core.$strip> | z.ZodObject<{
302
+ }, z.core.$strict> | z.ZodObject<{
297
303
  target: z.ZodString;
298
304
  reason: z.ZodString;
299
305
  context: z.ZodOptional<z.ZodString>;
@@ -301,7 +307,7 @@ export declare function getPayloadSchema(intent: IntentType): z.ZodObject<{
301
307
  low: "low";
302
308
  normal: "normal";
303
309
  }>;
304
- }, z.core.$strip> | z.ZodObject<{
310
+ }, z.core.$strict> | z.ZodObject<{
305
311
  status: z.ZodEnum<{
306
312
  declined: "declined";
307
313
  forwarded: "forwarded";
@@ -313,7 +319,7 @@ export declare function getPayloadSchema(intent: IntentType): z.ZodObject<{
313
319
  declined: "declined";
314
320
  pending: "pending";
315
321
  }>>;
316
- }, z.core.$strip> | z.ZodObject<{
322
+ }, z.core.$strict> | z.ZodObject<{
317
323
  type: z.ZodEnum<{
318
324
  role: "role";
319
325
  investment: "investment";
@@ -328,7 +334,7 @@ export declare function getPayloadSchema(intent: IntentType): z.ZodObject<{
328
334
  matchReason: z.ZodString;
329
335
  expiresAt: z.ZodOptional<z.ZodString>;
330
336
  url: z.ZodOptional<z.ZodString>;
331
- }, z.core.$strip> | z.ZodObject<{
337
+ }, z.core.$strict> | z.ZodObject<{
332
338
  status: z.ZodEnum<{
333
339
  not_interested: "not_interested";
334
340
  interested: "interested";
@@ -352,7 +358,7 @@ export declare function getPayloadSchema(intent: IntentType): z.ZodObject<{
352
358
  retract: "retract";
353
359
  multi_party_sync: "multi_party_sync";
354
360
  }>>;
355
- }, z.core.$strip> | z.ZodObject<{
361
+ }, z.core.$strict> | z.ZodObject<{
356
362
  method: z.ZodEnum<{
357
363
  qr: "qr";
358
364
  intro: "intro";
@@ -369,10 +375,10 @@ export declare function getPayloadSchema(intent: IntentType): z.ZodObject<{
369
375
  timezone: z.ZodString;
370
376
  meetingHours: z.ZodOptional<z.ZodString>;
371
377
  responseSla: z.ZodOptional<z.ZodString>;
372
- }, z.core.$strip>>;
378
+ }, z.core.$strict>>;
373
379
  openTo: z.ZodArray<z.ZodString>;
374
- }, z.core.$strip>;
375
- }, z.core.$strip> | z.ZodObject<{
380
+ }, z.core.$strict>;
381
+ }, z.core.$strict> | z.ZodObject<{
376
382
  status: z.ZodEnum<{
377
383
  accepted: "accepted";
378
384
  declined: "declined";
@@ -386,11 +392,11 @@ export declare function getPayloadSchema(intent: IntentType): z.ZodObject<{
386
392
  timezone: z.ZodString;
387
393
  meetingHours: z.ZodOptional<z.ZodString>;
388
394
  responseSla: z.ZodOptional<z.ZodString>;
389
- }, z.core.$strip>>;
395
+ }, z.core.$strict>>;
390
396
  openTo: z.ZodArray<z.ZodString>;
391
- }, z.core.$strip>>;
397
+ }, z.core.$strict>>;
392
398
  note: z.ZodOptional<z.ZodString>;
393
- }, z.core.$strip> | z.ZodObject<{
399
+ }, z.core.$strict> | z.ZodObject<{
394
400
  referenceId: z.ZodString;
395
401
  message: z.ZodString;
396
402
  actionRequested: z.ZodOptional<z.ZodEnum<{
@@ -399,7 +405,7 @@ export declare function getPayloadSchema(intent: IntentType): z.ZodObject<{
399
405
  review: "review";
400
406
  none: "none";
401
407
  }>>;
402
- }, z.core.$strip> | z.ZodObject<{
408
+ }, z.core.$strict> | z.ZodObject<{
403
409
  question: z.ZodString;
404
410
  context: z.ZodOptional<z.ZodString>;
405
411
  responseFormat: z.ZodOptional<z.ZodEnum<{
@@ -408,15 +414,15 @@ export declare function getPayloadSchema(intent: IntentType): z.ZodObject<{
408
414
  }>>;
409
415
  choices: z.ZodOptional<z.ZodArray<z.ZodString>>;
410
416
  deadline: z.ZodOptional<z.ZodString>;
411
- }, z.core.$strip> | z.ZodObject<{
417
+ }, z.core.$strict> | z.ZodObject<{
412
418
  answer: z.ZodString;
413
419
  choiceIndex: z.ZodOptional<z.ZodNumber>;
414
- }, z.core.$strip> | z.ZodObject<{
420
+ }, z.core.$strict> | z.ZodObject<{
415
421
  note: z.ZodOptional<z.ZodString>;
416
- }, z.core.$strip> | z.ZodObject<{
422
+ }, z.core.$strict> | z.ZodObject<{
417
423
  targetMessageId: z.ZodString;
418
424
  reason: z.ZodOptional<z.ZodString>;
419
- }, z.core.$strip> | z.ZodObject<{
425
+ }, z.core.$strict> | z.ZodObject<{
420
426
  context: z.ZodString;
421
427
  category: z.ZodEnum<{
422
428
  availability: "availability";
@@ -427,11 +433,11 @@ export declare function getPayloadSchema(intent: IntentType): z.ZodObject<{
427
433
  }>;
428
434
  referenceId: z.ZodOptional<z.ZodString>;
429
435
  expiresAt: z.ZodOptional<z.ZodString>;
430
- }, z.core.$strip> | z.ZodObject<{
436
+ }, z.core.$strict> | z.ZodObject<{
431
437
  enclaveType: z.ZodEnum<{
432
438
  meeting_sync: "meeting_sync";
433
439
  }>;
434
440
  purpose: z.ZodString;
435
441
  participants: z.ZodArray<z.ZodString>;
436
442
  expiresAt: z.ZodString;
437
- }, z.core.$strip>;
443
+ }, z.core.$strict>;
@@ -19,35 +19,45 @@ export const IntentTypeSchema = z.enum([
19
19
  "multi_party_sync",
20
20
  ]);
21
21
  // --- Intent Payloads ---
22
+ // Reusable scalar caps. Timestamps cap at 64 chars (ISO-8601 fits in
23
+ // ~30), correlation/message IDs at 256, DIDs at 512. URL fields cap
24
+ // at 2048 BEFORE `.url()` parsing so the parser never runs on attacker-
25
+ // sized strings. Every exported schema is `.strict()` so adopters using
26
+ // the schemas directly (without `validateMessage()`) still get the
27
+ // same unknown-field rejection that the central validator applies.
28
+ const TIMESTAMP_MAX = 64;
29
+ const ID_MAX = 256;
30
+ const DID_MAX = 512;
31
+ const URL_MAX = 2048;
22
32
  export const ScheduleMeetingPayloadSchema = z.object({
23
- proposedTimes: z.array(z.string()).min(1).max(10),
33
+ proposedTimes: z.array(z.string().max(TIMESTAMP_MAX)).min(1).max(10),
24
34
  topic: z.string().max(500),
25
35
  format: z.enum(["video", "phone", "in_person", "async"]),
26
36
  urgency: z.enum(["low", "normal", "urgent"]),
27
37
  context: z.string().max(2000).optional(),
28
38
  location: z.string().max(500).optional(),
29
- });
39
+ }).strict();
30
40
  export const ScheduleMeetingResponsePayloadSchema = z.object({
31
41
  status: z.enum(["accepted", "declined", "countered"]),
32
- confirmedTime: z.string().optional(),
33
- counterTimes: z.array(z.string()).max(10).optional(),
34
- meetingLink: z.string().url().optional(),
42
+ confirmedTime: z.string().max(TIMESTAMP_MAX).optional(),
43
+ counterTimes: z.array(z.string().max(TIMESTAMP_MAX)).max(10).optional(),
44
+ meetingLink: z.string().max(URL_MAX).url().optional(),
35
45
  note: z.string().max(1000).optional(),
36
46
  declineReason: z
37
47
  .enum(["unavailable", "not_interested", "too_busy", "deferred"])
38
48
  .optional(),
39
- });
49
+ }).strict();
40
50
  export const IntroRequestPayloadSchema = z.object({
41
- target: z.string(),
51
+ target: z.string().max(DID_MAX),
42
52
  reason: z.string().max(2000),
43
53
  context: z.string().max(2000).optional(),
44
54
  urgency: z.enum(["low", "normal"]),
45
- });
55
+ }).strict();
46
56
  export const IntroResponsePayloadSchema = z.object({
47
57
  status: z.enum(["forwarded", "declined", "pending_target"]),
48
58
  note: z.string().max(1000).optional(),
49
59
  targetResponse: z.enum(["accepted", "declined", "pending"]).optional(),
50
- });
60
+ }).strict();
51
61
  export const OpportunityPayloadSchema = z.object({
52
62
  type: z.enum([
53
63
  "role",
@@ -61,60 +71,60 @@ export const OpportunityPayloadSchema = z.object({
61
71
  org: z.string().max(200).optional(),
62
72
  description: z.string().max(5000),
63
73
  matchReason: z.string().max(2000),
64
- expiresAt: z.string().optional(),
65
- url: z.string().url().optional(),
66
- });
74
+ expiresAt: z.string().max(TIMESTAMP_MAX).optional(),
75
+ url: z.string().max(URL_MAX).url().optional(),
76
+ }).strict();
67
77
  export const OpportunityResponsePayloadSchema = z.object({
68
78
  status: z.enum(["interested", "not_interested", "maybe_later"]),
69
79
  note: z.string().max(1000).optional(),
70
80
  followUpIntent: IntentTypeSchema.optional(),
71
- });
81
+ }).strict();
72
82
  export const ConnectionRequestPayloadSchema = z.object({
73
83
  method: z.enum(["qr", "intro", "discovery", "import"]),
74
- introducedBy: z.string().optional(),
84
+ introducedBy: z.string().max(DID_MAX).optional(),
75
85
  context: z.string().max(2000),
76
86
  profileSnapshot: ProfileSnapshotSchema,
77
- });
87
+ }).strict();
78
88
  export const ConnectionResponsePayloadSchema = z.object({
79
89
  status: z.enum(["accepted", "declined", "pending"]),
80
90
  profileSnapshot: ProfileSnapshotSchema.optional(),
81
91
  note: z.string().max(1000).optional(),
82
- });
92
+ }).strict();
83
93
  export const FollowUpPayloadSchema = z.object({
84
- referenceId: z.string(),
94
+ referenceId: z.string().max(ID_MAX),
85
95
  message: z.string().max(5000),
86
96
  actionRequested: z.enum(["reply", "schedule", "review", "none"]).optional(),
87
- });
97
+ }).strict();
88
98
  export const AskPayloadSchema = z.object({
89
99
  question: z.string().max(5000),
90
100
  context: z.string().max(2000).optional(),
91
101
  responseFormat: z.enum(["text", "choice"]).optional(),
92
102
  choices: z.array(z.string().max(500)).max(10).optional(),
93
- deadline: z.string().optional(),
94
- });
103
+ deadline: z.string().max(TIMESTAMP_MAX).optional(),
104
+ }).strict();
95
105
  export const AskResponsePayloadSchema = z.object({
96
106
  answer: z.string().max(5000),
97
107
  choiceIndex: z.number().int().min(0).optional(),
98
- });
108
+ }).strict();
99
109
  export const PingPayloadSchema = z.object({
100
110
  note: z.string().max(1000).optional(),
101
- });
111
+ }).strict();
102
112
  export const RetractPayloadSchema = z.object({
103
- targetMessageId: z.string(),
113
+ targetMessageId: z.string().max(ID_MAX),
104
114
  reason: z.string().max(1000).optional(),
105
- });
115
+ }).strict();
106
116
  export const ContextSharePayloadSchema = z.object({
107
117
  context: z.string().max(5000),
108
118
  category: z.enum(["professional_background", "project_update", "expertise", "availability", "general"]),
109
- referenceId: z.string().optional(),
110
- expiresAt: z.string().optional(),
111
- });
119
+ referenceId: z.string().max(ID_MAX).optional(),
120
+ expiresAt: z.string().max(TIMESTAMP_MAX).optional(),
121
+ }).strict();
112
122
  export const MultiPartySyncPayloadSchema = z.object({
113
123
  enclaveType: z.enum(["meeting_sync"]),
114
124
  purpose: z.string().max(500),
115
- participants: z.array(z.string()).min(2).max(20),
116
- expiresAt: z.string(),
117
- });
125
+ participants: z.array(z.string().max(DID_MAX)).min(2).max(20),
126
+ expiresAt: z.string().max(TIMESTAMP_MAX),
127
+ }).strict();
118
128
  // --- Payload discriminated union ---
119
129
  const payloadSchemas = {
120
130
  schedule_meeting: ScheduleMeetingPayloadSchema,
@@ -134,25 +144,39 @@ const payloadSchemas = {
134
144
  multi_party_sync: MultiPartySyncPayloadSchema,
135
145
  };
136
146
  // --- Message Envelope ---
147
+ // Caps for envelope-level fields. Signatures are base64url-encoded
148
+ // Ed25519 (64 bytes raw → 86 chars base64url, plus the legacy keyId=
149
+ // suffix). 256 is comfortable headroom without permitting megabyte
150
+ // signature blobs.
151
+ const SIGNATURE_MAX = 256;
152
+ const KEY_ID_MAX = 128;
137
153
  export const MessageProvenanceSchema = z.object({
138
154
  origin: z.enum(["human", "agent_approved", "agent_autonomous"]),
139
- extensionId: z.string(),
155
+ extensionId: z.string().max(ID_MAX),
140
156
  installationId: z.string().uuid(),
141
- }).optional();
157
+ }).strict().optional();
142
158
  export const MessageEnvelopeSchema = z.object({
143
159
  protocol: z.literal("ink/0.1"),
144
- id: z.string(),
145
- correlationId: z.string(),
146
- createdAt: z.string(),
147
- expiresAt: z.string().optional(),
148
- from: z.string(),
149
- to: z.string(),
160
+ id: z.string().max(ID_MAX),
161
+ correlationId: z.string().max(ID_MAX),
162
+ createdAt: z.string().max(TIMESTAMP_MAX),
163
+ expiresAt: z.string().max(TIMESTAMP_MAX).optional(),
164
+ from: z.string().max(DID_MAX),
165
+ to: z.string().max(DID_MAX),
150
166
  intent: IntentTypeSchema,
151
167
  payload: z.unknown(),
152
- signature: z.string(),
153
- signingKeyId: z.string().optional(),
168
+ signature: z.string().max(SIGNATURE_MAX),
169
+ signingKeyId: z.string().max(KEY_ID_MAX).optional(),
170
+ // HTTP §3.3 transport-auth metadata that rides alongside the
171
+ // canonical envelope fields. The body-level signature commits to
172
+ // both (they cannot be tampered in transit) and `verifyInkAuth`
173
+ // reads them from the body for freshness + replay checks. Explicit
174
+ // optional capped declarations are required for `.strict()` to keep
175
+ // accepting documented sender envelopes (see README signing example).
176
+ timestamp: z.string().max(TIMESTAMP_MAX).optional(),
177
+ nonce: z.string().max(ID_MAX).optional(),
154
178
  provenance: MessageProvenanceSchema,
155
- });
179
+ }).strict();
156
180
  /**
157
181
  * Validate a message envelope AND its payload based on the intent type.
158
182
  * Returns the validated message or throws a ZodError.
@@ -166,7 +190,12 @@ export function validateMessage(raw) {
166
190
  }
167
191
  /**
168
192
  * Get the payload schema for a given intent type.
193
+ *
194
+ * Runtime-validates the `intent` argument against IntentTypeSchema so a
195
+ * JS caller cannot pass an arbitrary string and silently get `undefined`
196
+ * back; the function instead throws ZodError on an invalid intent.
169
197
  */
170
198
  export function getPayloadSchema(intent) {
199
+ IntentTypeSchema.parse(intent);
171
200
  return payloadSchemas[intent];
172
201
  }
@@ -3,7 +3,7 @@ export declare const AvailabilityConfigSchema: z.ZodObject<{
3
3
  timezone: z.ZodString;
4
4
  meetingHours: z.ZodOptional<z.ZodString>;
5
5
  responseSla: z.ZodOptional<z.ZodString>;
6
- }, z.core.$strip>;
6
+ }, z.core.$strict>;
7
7
  export declare const ProfileSnapshotSchema: z.ZodObject<{
8
8
  headline: z.ZodString;
9
9
  skills: z.ZodArray<z.ZodString>;
@@ -12,9 +12,9 @@ export declare const ProfileSnapshotSchema: z.ZodObject<{
12
12
  timezone: z.ZodString;
13
13
  meetingHours: z.ZodOptional<z.ZodString>;
14
14
  responseSla: z.ZodOptional<z.ZodString>;
15
- }, z.core.$strip>>;
15
+ }, z.core.$strict>>;
16
16
  openTo: z.ZodArray<z.ZodString>;
17
- }, z.core.$strip>;
17
+ }, z.core.$strict>;
18
18
  export declare const ProfileSchema: z.ZodObject<{
19
19
  agentId: z.ZodString;
20
20
  handle: z.ZodString;
@@ -29,9 +29,9 @@ export declare const ProfileSchema: z.ZodObject<{
29
29
  timezone: z.ZodString;
30
30
  meetingHours: z.ZodOptional<z.ZodString>;
31
31
  responseSla: z.ZodOptional<z.ZodString>;
32
- }, z.core.$strip>>;
32
+ }, z.core.$strict>>;
33
33
  openTo: z.ZodArray<z.ZodString>;
34
- }, z.core.$strip>;
34
+ }, z.core.$strict>;
35
35
  connected: z.ZodObject<{
36
36
  headline: z.ZodString;
37
37
  skills: z.ZodArray<z.ZodString>;
@@ -40,9 +40,9 @@ export declare const ProfileSchema: z.ZodObject<{
40
40
  timezone: z.ZodString;
41
41
  meetingHours: z.ZodOptional<z.ZodString>;
42
42
  responseSla: z.ZodOptional<z.ZodString>;
43
- }, z.core.$strip>>;
43
+ }, z.core.$strict>>;
44
44
  openTo: z.ZodArray<z.ZodString>;
45
- }, z.core.$strip>;
45
+ }, z.core.$strict>;
46
46
  custom: z.ZodRecord<z.ZodString, z.ZodObject<{
47
47
  headline: z.ZodString;
48
48
  skills: z.ZodArray<z.ZodString>;
@@ -51,9 +51,9 @@ export declare const ProfileSchema: z.ZodObject<{
51
51
  timezone: z.ZodString;
52
52
  meetingHours: z.ZodOptional<z.ZodString>;
53
53
  responseSla: z.ZodOptional<z.ZodString>;
54
- }, z.core.$strip>>;
54
+ }, z.core.$strict>>;
55
55
  openTo: z.ZodArray<z.ZodString>;
56
- }, z.core.$strip>>;
56
+ }, z.core.$strict>>;
57
57
  }, z.core.$strip>;
58
58
  }, z.core.$strip>;
59
59
  export type AvailabilityConfig = z.infer<typeof AvailabilityConfigSchema>;
@@ -1,16 +1,20 @@
1
1
  import { z } from "zod";
2
2
  export const AvailabilityConfigSchema = z.object({
3
- timezone: z.string(),
4
- meetingHours: z.string().optional(),
5
- responseSla: z.string().optional(),
6
- });
3
+ // IANA timezone name. The longest legitimate value is ~50 chars.
4
+ timezone: z.string().max(64),
5
+ // Free-text availability description ("9-5 PT weekdays") capped
6
+ // to a sane display length. Larger values are almost certainly
7
+ // garbage or an attempted DoS.
8
+ meetingHours: z.string().max(200).optional(),
9
+ responseSla: z.string().max(200).optional(),
10
+ }).strict();
7
11
  export const ProfileSnapshotSchema = z.object({
8
12
  headline: z.string().max(500),
9
13
  skills: z.array(z.string().max(100)).max(50),
10
14
  interests: z.array(z.string().max(100)).max(50),
11
15
  availability: AvailabilityConfigSchema.optional(),
12
16
  openTo: z.array(z.string().max(100)).max(20),
13
- });
17
+ }).strict();
14
18
  export const ProfileSchema = z.object({
15
19
  agentId: z.string(),
16
20
  handle: z.string(),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adastracomputing/ink",
3
- "version": "0.1.6",
3
+ "version": "0.1.7",
4
4
  "description": "Library and specification for the INK (Inter-agent Networking Kernel) protocol",
5
5
  "license": "MIT OR Apache-2.0",
6
6
  "author": "Ad Astra Computing Inc.",