@kya-os/contracts 1.5.2-canary.5 → 1.5.2

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.
@@ -3,4 +3,4 @@
3
3
  *
4
4
  * Types and schemas for consent page configuration and approval handling
5
5
  */
6
- export { consentBrandingSchema, consentTermsSchema, consentCustomFieldSchema, consentCustomFieldOptionSchema, consentPageConfigSchema, consentApprovalRequestSchema, consentApprovalResponseSchema, consentConfigSchema, validateConsentPageConfig, validateConsentApprovalRequest, validateConsentApprovalResponse, validateConsentConfig, type ConsentBranding, type ConsentTerms, type ConsentCustomField, type ConsentPageConfig, type ConsentApprovalRequest, type ConsentApprovalResponse, type ConsentConfig, } from './schemas.js';
6
+ export { consentBrandingSchema, consentTermsSchema, consentCustomFieldSchema, consentCustomFieldOptionSchema, consentPageConfigSchema, consentApprovalRequestSchema, consentApprovalResponseSchema, consentConfigSchema, oauthIdentitySchema, validateConsentPageConfig, validateConsentApprovalRequest, validateConsentApprovalResponse, validateConsentConfig, type ConsentBranding, type ConsentTerms, type ConsentCustomField, type ConsentPageConfig, type ConsentApprovalRequest, type ConsentApprovalResponse, type ConsentConfig, type OAuthIdentity, } from './schemas.js';
@@ -5,7 +5,7 @@
5
5
  * Types and schemas for consent page configuration and approval handling
6
6
  */
7
7
  Object.defineProperty(exports, "__esModule", { value: true });
8
- exports.validateConsentConfig = exports.validateConsentApprovalResponse = exports.validateConsentApprovalRequest = exports.validateConsentPageConfig = exports.consentConfigSchema = exports.consentApprovalResponseSchema = exports.consentApprovalRequestSchema = exports.consentPageConfigSchema = exports.consentCustomFieldOptionSchema = exports.consentCustomFieldSchema = exports.consentTermsSchema = exports.consentBrandingSchema = void 0;
8
+ exports.validateConsentConfig = exports.validateConsentApprovalResponse = exports.validateConsentApprovalRequest = exports.validateConsentPageConfig = exports.oauthIdentitySchema = exports.consentConfigSchema = exports.consentApprovalResponseSchema = exports.consentApprovalRequestSchema = exports.consentPageConfigSchema = exports.consentCustomFieldOptionSchema = exports.consentCustomFieldSchema = exports.consentTermsSchema = exports.consentBrandingSchema = void 0;
9
9
  // Export schemas and inferred types (types are derived from schemas)
10
10
  var schemas_js_1 = require("./schemas.js");
11
11
  Object.defineProperty(exports, "consentBrandingSchema", { enumerable: true, get: function () { return schemas_js_1.consentBrandingSchema; } });
@@ -16,6 +16,7 @@ Object.defineProperty(exports, "consentPageConfigSchema", { enumerable: true, ge
16
16
  Object.defineProperty(exports, "consentApprovalRequestSchema", { enumerable: true, get: function () { return schemas_js_1.consentApprovalRequestSchema; } });
17
17
  Object.defineProperty(exports, "consentApprovalResponseSchema", { enumerable: true, get: function () { return schemas_js_1.consentApprovalResponseSchema; } });
18
18
  Object.defineProperty(exports, "consentConfigSchema", { enumerable: true, get: function () { return schemas_js_1.consentConfigSchema; } });
19
+ Object.defineProperty(exports, "oauthIdentitySchema", { enumerable: true, get: function () { return schemas_js_1.oauthIdentitySchema; } });
19
20
  Object.defineProperty(exports, "validateConsentPageConfig", { enumerable: true, get: function () { return schemas_js_1.validateConsentPageConfig; } });
20
21
  Object.defineProperty(exports, "validateConsentApprovalRequest", { enumerable: true, get: function () { return schemas_js_1.validateConsentApprovalRequest; } });
21
22
  Object.defineProperty(exports, "validateConsentApprovalResponse", { enumerable: true, get: function () { return schemas_js_1.validateConsentApprovalResponse; } });
@@ -43,8 +43,8 @@ export declare const consentTermsSchema: z.ZodObject<{
43
43
  }, {
44
44
  version?: string | undefined;
45
45
  url?: string | undefined;
46
- required?: boolean | undefined;
47
46
  text?: string | undefined;
47
+ required?: boolean | undefined;
48
48
  }>;
49
49
  export type ConsentTerms = z.infer<typeof consentTermsSchema>;
50
50
  /**
@@ -81,8 +81,8 @@ export declare const consentCustomFieldSchema: z.ZodEffects<z.ZodObject<{
81
81
  }>, "many">>;
82
82
  pattern: z.ZodOptional<z.ZodString>;
83
83
  }, "strip", z.ZodTypeAny, {
84
- type: "text" | "textarea" | "checkbox" | "select";
85
84
  name: string;
85
+ type: "text" | "textarea" | "checkbox" | "select";
86
86
  required: boolean;
87
87
  label: string;
88
88
  options?: {
@@ -92,8 +92,8 @@ export declare const consentCustomFieldSchema: z.ZodEffects<z.ZodObject<{
92
92
  placeholder?: string | undefined;
93
93
  pattern?: string | undefined;
94
94
  }, {
95
- type: "text" | "textarea" | "checkbox" | "select";
96
95
  name: string;
96
+ type: "text" | "textarea" | "checkbox" | "select";
97
97
  required: boolean;
98
98
  label: string;
99
99
  options?: {
@@ -103,8 +103,8 @@ export declare const consentCustomFieldSchema: z.ZodEffects<z.ZodObject<{
103
103
  placeholder?: string | undefined;
104
104
  pattern?: string | undefined;
105
105
  }>, {
106
- type: "text" | "textarea" | "checkbox" | "select";
107
106
  name: string;
107
+ type: "text" | "textarea" | "checkbox" | "select";
108
108
  required: boolean;
109
109
  label: string;
110
110
  options?: {
@@ -114,8 +114,8 @@ export declare const consentCustomFieldSchema: z.ZodEffects<z.ZodObject<{
114
114
  placeholder?: string | undefined;
115
115
  pattern?: string | undefined;
116
116
  }, {
117
- type: "text" | "textarea" | "checkbox" | "select";
118
117
  name: string;
118
+ type: "text" | "textarea" | "checkbox" | "select";
119
119
  required: boolean;
120
120
  label: string;
121
121
  options?: {
@@ -126,6 +126,42 @@ export declare const consentCustomFieldSchema: z.ZodEffects<z.ZodObject<{
126
126
  pattern?: string | undefined;
127
127
  }>;
128
128
  export type ConsentCustomField = z.infer<typeof consentCustomFieldSchema>;
129
+ /**
130
+ * OAuth Identity Schema
131
+ *
132
+ * Represents a user's OAuth provider account information.
133
+ * Used in Phase 4 to link OAuth accounts to persistent User DIDs.
134
+ */
135
+ export declare const oauthIdentitySchema: z.ZodObject<{
136
+ /**
137
+ * OAuth provider name (e.g., "google", "github", "microsoft")
138
+ */
139
+ provider: z.ZodString;
140
+ /**
141
+ * OAuth subject identifier (unique user ID from provider)
142
+ * @example "123456789" (Google), "github-user-id" (GitHub)
143
+ */
144
+ subject: z.ZodString;
145
+ /**
146
+ * User's email address from OAuth provider (optional)
147
+ */
148
+ email: z.ZodOptional<z.ZodString>;
149
+ /**
150
+ * User's display name from OAuth provider (optional)
151
+ */
152
+ name: z.ZodOptional<z.ZodString>;
153
+ }, "strip", z.ZodTypeAny, {
154
+ provider: string;
155
+ subject: string;
156
+ name?: string | undefined;
157
+ email?: string | undefined;
158
+ }, {
159
+ provider: string;
160
+ subject: string;
161
+ name?: string | undefined;
162
+ email?: string | undefined;
163
+ }>;
164
+ export type OAuthIdentity = z.infer<typeof oauthIdentitySchema>;
129
165
  /**
130
166
  * Consent Page Config Schema
131
167
  */
@@ -165,8 +201,8 @@ export declare const consentPageConfigSchema: z.ZodObject<{
165
201
  }, {
166
202
  version?: string | undefined;
167
203
  url?: string | undefined;
168
- required?: boolean | undefined;
169
204
  text?: string | undefined;
205
+ required?: boolean | undefined;
170
206
  }>>;
171
207
  customFields: z.ZodOptional<z.ZodArray<z.ZodEffects<z.ZodObject<{
172
208
  name: z.ZodString;
@@ -186,8 +222,8 @@ export declare const consentPageConfigSchema: z.ZodObject<{
186
222
  }>, "many">>;
187
223
  pattern: z.ZodOptional<z.ZodString>;
188
224
  }, "strip", z.ZodTypeAny, {
189
- type: "text" | "textarea" | "checkbox" | "select";
190
225
  name: string;
226
+ type: "text" | "textarea" | "checkbox" | "select";
191
227
  required: boolean;
192
228
  label: string;
193
229
  options?: {
@@ -197,8 +233,8 @@ export declare const consentPageConfigSchema: z.ZodObject<{
197
233
  placeholder?: string | undefined;
198
234
  pattern?: string | undefined;
199
235
  }, {
200
- type: "text" | "textarea" | "checkbox" | "select";
201
236
  name: string;
237
+ type: "text" | "textarea" | "checkbox" | "select";
202
238
  required: boolean;
203
239
  label: string;
204
240
  options?: {
@@ -208,8 +244,8 @@ export declare const consentPageConfigSchema: z.ZodObject<{
208
244
  placeholder?: string | undefined;
209
245
  pattern?: string | undefined;
210
246
  }>, {
211
- type: "text" | "textarea" | "checkbox" | "select";
212
247
  name: string;
248
+ type: "text" | "textarea" | "checkbox" | "select";
213
249
  required: boolean;
214
250
  label: string;
215
251
  options?: {
@@ -219,8 +255,8 @@ export declare const consentPageConfigSchema: z.ZodObject<{
219
255
  placeholder?: string | undefined;
220
256
  pattern?: string | undefined;
221
257
  }, {
222
- type: "text" | "textarea" | "checkbox" | "select";
223
258
  name: string;
259
+ type: "text" | "textarea" | "checkbox" | "select";
224
260
  required: boolean;
225
261
  label: string;
226
262
  options?: {
@@ -236,8 +272,8 @@ export declare const consentPageConfigSchema: z.ZodObject<{
236
272
  agentDid: string;
237
273
  sessionId: string;
238
274
  tool: string;
239
- scopes: string[];
240
275
  toolDescription: string;
276
+ scopes: string[];
241
277
  projectId: string;
242
278
  serverUrl: string;
243
279
  branding?: {
@@ -253,8 +289,8 @@ export declare const consentPageConfigSchema: z.ZodObject<{
253
289
  text?: string | undefined;
254
290
  } | undefined;
255
291
  customFields?: {
256
- type: "text" | "textarea" | "checkbox" | "select";
257
292
  name: string;
293
+ type: "text" | "textarea" | "checkbox" | "select";
258
294
  required: boolean;
259
295
  label: string;
260
296
  options?: {
@@ -269,8 +305,8 @@ export declare const consentPageConfigSchema: z.ZodObject<{
269
305
  agentDid: string;
270
306
  sessionId: string;
271
307
  tool: string;
272
- scopes: string[];
273
308
  toolDescription: string;
309
+ scopes: string[];
274
310
  projectId: string;
275
311
  serverUrl: string;
276
312
  branding?: {
@@ -282,12 +318,12 @@ export declare const consentPageConfigSchema: z.ZodObject<{
282
318
  terms?: {
283
319
  version?: string | undefined;
284
320
  url?: string | undefined;
285
- required?: boolean | undefined;
286
321
  text?: string | undefined;
322
+ required?: boolean | undefined;
287
323
  } | undefined;
288
324
  customFields?: {
289
- type: "text" | "textarea" | "checkbox" | "select";
290
325
  name: string;
326
+ type: "text" | "textarea" | "checkbox" | "select";
291
327
  required: boolean;
292
328
  label: string;
293
329
  options?: {
@@ -304,6 +340,10 @@ export type ConsentPageConfig = z.infer<typeof consentPageConfigSchema>;
304
340
  * Consent Approval Request Schema
305
341
  *
306
342
  * Note: Uses snake_case for API compatibility (agent_did, session_id, project_id)
343
+ *
344
+ * Phase 4 additions:
345
+ * - oauth_identity: Optional OAuth provider information for identity linking
346
+ * - user_did: Optional User DID for persistent identity (if already known)
307
347
  */
308
348
  export declare const consentApprovalRequestSchema: z.ZodObject<{
309
349
  tool: z.ZodString;
@@ -314,24 +354,77 @@ export declare const consentApprovalRequestSchema: z.ZodObject<{
314
354
  termsAccepted: z.ZodBoolean;
315
355
  termsVersion: z.ZodOptional<z.ZodString>;
316
356
  customFields: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodString, z.ZodBoolean]>>>;
357
+ /**
358
+ * OAuth provider identity information (optional)
359
+ * Used to link OAuth accounts to persistent User DIDs
360
+ */
361
+ oauth_identity: z.ZodOptional<z.ZodObject<{
362
+ /**
363
+ * OAuth provider name (e.g., "google", "github", "microsoft")
364
+ */
365
+ provider: z.ZodString;
366
+ /**
367
+ * OAuth subject identifier (unique user ID from provider)
368
+ * @example "123456789" (Google), "github-user-id" (GitHub)
369
+ */
370
+ subject: z.ZodString;
371
+ /**
372
+ * User's email address from OAuth provider (optional)
373
+ */
374
+ email: z.ZodOptional<z.ZodString>;
375
+ /**
376
+ * User's display name from OAuth provider (optional)
377
+ */
378
+ name: z.ZodOptional<z.ZodString>;
379
+ }, "strip", z.ZodTypeAny, {
380
+ provider: string;
381
+ subject: string;
382
+ name?: string | undefined;
383
+ email?: string | undefined;
384
+ }, {
385
+ provider: string;
386
+ subject: string;
387
+ name?: string | undefined;
388
+ email?: string | undefined;
389
+ }>>;
390
+ /**
391
+ * User DID (optional)
392
+ * If provided, represents the persistent User DID for this user
393
+ * Format: did:key:... or did:web:...
394
+ */
395
+ user_did: z.ZodOptional<z.ZodString>;
317
396
  }, "strip", z.ZodTypeAny, {
318
397
  tool: string;
319
- session_id: string;
320
398
  scopes: string[];
321
399
  agent_did: string;
400
+ session_id: string;
322
401
  project_id: string;
323
402
  termsAccepted: boolean;
324
403
  customFields?: Record<string, string | boolean> | undefined;
325
404
  termsVersion?: string | undefined;
405
+ oauth_identity?: {
406
+ provider: string;
407
+ subject: string;
408
+ name?: string | undefined;
409
+ email?: string | undefined;
410
+ } | undefined;
411
+ user_did?: string | undefined;
326
412
  }, {
327
413
  tool: string;
328
- session_id: string;
329
414
  scopes: string[];
330
415
  agent_did: string;
416
+ session_id: string;
331
417
  project_id: string;
332
418
  termsAccepted: boolean;
333
419
  customFields?: Record<string, string | boolean> | undefined;
334
420
  termsVersion?: string | undefined;
421
+ oauth_identity?: {
422
+ provider: string;
423
+ subject: string;
424
+ name?: string | undefined;
425
+ email?: string | undefined;
426
+ } | undefined;
427
+ user_did?: string | undefined;
335
428
  }>;
336
429
  export type ConsentApprovalRequest = z.infer<typeof consentApprovalRequestSchema>;
337
430
  /**
@@ -345,27 +438,27 @@ export declare const consentApprovalResponseSchema: z.ZodEffects<z.ZodObject<{
345
438
  error_code: z.ZodOptional<z.ZodString>;
346
439
  }, "strip", z.ZodTypeAny, {
347
440
  success: boolean;
348
- error?: string | undefined;
349
441
  delegation_id?: string | undefined;
350
442
  delegation_token?: string | undefined;
443
+ error?: string | undefined;
351
444
  error_code?: string | undefined;
352
445
  }, {
353
446
  success: boolean;
354
- error?: string | undefined;
355
447
  delegation_id?: string | undefined;
356
448
  delegation_token?: string | undefined;
449
+ error?: string | undefined;
357
450
  error_code?: string | undefined;
358
451
  }>, {
359
452
  success: boolean;
360
- error?: string | undefined;
361
453
  delegation_id?: string | undefined;
362
454
  delegation_token?: string | undefined;
455
+ error?: string | undefined;
363
456
  error_code?: string | undefined;
364
457
  }, {
365
458
  success: boolean;
366
- error?: string | undefined;
367
459
  delegation_id?: string | undefined;
368
460
  delegation_token?: string | undefined;
461
+ error?: string | undefined;
369
462
  error_code?: string | undefined;
370
463
  }>;
371
464
  export type ConsentApprovalResponse = z.infer<typeof consentApprovalResponseSchema>;
@@ -402,8 +495,8 @@ export declare const consentConfigSchema: z.ZodObject<{
402
495
  }, {
403
496
  version?: string | undefined;
404
497
  url?: string | undefined;
405
- required?: boolean | undefined;
406
498
  text?: string | undefined;
499
+ required?: boolean | undefined;
407
500
  }>>;
408
501
  customFields: z.ZodOptional<z.ZodArray<z.ZodEffects<z.ZodObject<{
409
502
  name: z.ZodString;
@@ -423,8 +516,8 @@ export declare const consentConfigSchema: z.ZodObject<{
423
516
  }>, "many">>;
424
517
  pattern: z.ZodOptional<z.ZodString>;
425
518
  }, "strip", z.ZodTypeAny, {
426
- type: "text" | "textarea" | "checkbox" | "select";
427
519
  name: string;
520
+ type: "text" | "textarea" | "checkbox" | "select";
428
521
  required: boolean;
429
522
  label: string;
430
523
  options?: {
@@ -434,8 +527,8 @@ export declare const consentConfigSchema: z.ZodObject<{
434
527
  placeholder?: string | undefined;
435
528
  pattern?: string | undefined;
436
529
  }, {
437
- type: "text" | "textarea" | "checkbox" | "select";
438
530
  name: string;
531
+ type: "text" | "textarea" | "checkbox" | "select";
439
532
  required: boolean;
440
533
  label: string;
441
534
  options?: {
@@ -445,8 +538,8 @@ export declare const consentConfigSchema: z.ZodObject<{
445
538
  placeholder?: string | undefined;
446
539
  pattern?: string | undefined;
447
540
  }>, {
448
- type: "text" | "textarea" | "checkbox" | "select";
449
541
  name: string;
542
+ type: "text" | "textarea" | "checkbox" | "select";
450
543
  required: boolean;
451
544
  label: string;
452
545
  options?: {
@@ -456,8 +549,8 @@ export declare const consentConfigSchema: z.ZodObject<{
456
549
  placeholder?: string | undefined;
457
550
  pattern?: string | undefined;
458
551
  }, {
459
- type: "text" | "textarea" | "checkbox" | "select";
460
552
  name: string;
553
+ type: "text" | "textarea" | "checkbox" | "select";
461
554
  required: boolean;
462
555
  label: string;
463
556
  options?: {
@@ -497,8 +590,8 @@ export declare const consentConfigSchema: z.ZodObject<{
497
590
  text?: string | undefined;
498
591
  } | undefined;
499
592
  customFields?: {
500
- type: "text" | "textarea" | "checkbox" | "select";
501
593
  name: string;
594
+ type: "text" | "textarea" | "checkbox" | "select";
502
595
  required: boolean;
503
596
  label: string;
504
597
  options?: {
@@ -524,12 +617,12 @@ export declare const consentConfigSchema: z.ZodObject<{
524
617
  terms?: {
525
618
  version?: string | undefined;
526
619
  url?: string | undefined;
527
- required?: boolean | undefined;
528
620
  text?: string | undefined;
621
+ required?: boolean | undefined;
529
622
  } | undefined;
530
623
  customFields?: {
531
- type: "text" | "textarea" | "checkbox" | "select";
532
624
  name: string;
625
+ type: "text" | "textarea" | "checkbox" | "select";
533
626
  required: boolean;
534
627
  label: string;
535
628
  options?: {
@@ -560,8 +653,8 @@ export declare function validateConsentPageConfig(config: unknown): z.SafeParseR
560
653
  agentDid: string;
561
654
  sessionId: string;
562
655
  tool: string;
563
- scopes: string[];
564
656
  toolDescription: string;
657
+ scopes: string[];
565
658
  projectId: string;
566
659
  serverUrl: string;
567
660
  branding?: {
@@ -573,12 +666,12 @@ export declare function validateConsentPageConfig(config: unknown): z.SafeParseR
573
666
  terms?: {
574
667
  version?: string | undefined;
575
668
  url?: string | undefined;
576
- required?: boolean | undefined;
577
669
  text?: string | undefined;
670
+ required?: boolean | undefined;
578
671
  } | undefined;
579
672
  customFields?: {
580
- type: "text" | "textarea" | "checkbox" | "select";
581
673
  name: string;
674
+ type: "text" | "textarea" | "checkbox" | "select";
582
675
  required: boolean;
583
676
  label: string;
584
677
  options?: {
@@ -593,8 +686,8 @@ export declare function validateConsentPageConfig(config: unknown): z.SafeParseR
593
686
  agentDid: string;
594
687
  sessionId: string;
595
688
  tool: string;
596
- scopes: string[];
597
689
  toolDescription: string;
690
+ scopes: string[];
598
691
  projectId: string;
599
692
  serverUrl: string;
600
693
  branding?: {
@@ -610,8 +703,8 @@ export declare function validateConsentPageConfig(config: unknown): z.SafeParseR
610
703
  text?: string | undefined;
611
704
  } | undefined;
612
705
  customFields?: {
613
- type: "text" | "textarea" | "checkbox" | "select";
614
706
  name: string;
707
+ type: "text" | "textarea" | "checkbox" | "select";
615
708
  required: boolean;
616
709
  label: string;
617
710
  options?: {
@@ -631,22 +724,36 @@ export declare function validateConsentPageConfig(config: unknown): z.SafeParseR
631
724
  */
632
725
  export declare function validateConsentApprovalRequest(request: unknown): z.SafeParseReturnType<{
633
726
  tool: string;
634
- session_id: string;
635
727
  scopes: string[];
636
728
  agent_did: string;
729
+ session_id: string;
637
730
  project_id: string;
638
731
  termsAccepted: boolean;
639
732
  customFields?: Record<string, string | boolean> | undefined;
640
733
  termsVersion?: string | undefined;
734
+ oauth_identity?: {
735
+ provider: string;
736
+ subject: string;
737
+ name?: string | undefined;
738
+ email?: string | undefined;
739
+ } | undefined;
740
+ user_did?: string | undefined;
641
741
  }, {
642
742
  tool: string;
643
- session_id: string;
644
743
  scopes: string[];
645
744
  agent_did: string;
745
+ session_id: string;
646
746
  project_id: string;
647
747
  termsAccepted: boolean;
648
748
  customFields?: Record<string, string | boolean> | undefined;
649
749
  termsVersion?: string | undefined;
750
+ oauth_identity?: {
751
+ provider: string;
752
+ subject: string;
753
+ name?: string | undefined;
754
+ email?: string | undefined;
755
+ } | undefined;
756
+ user_did?: string | undefined;
650
757
  }>;
651
758
  /**
652
759
  * Validate a consent approval response
@@ -656,15 +763,15 @@ export declare function validateConsentApprovalRequest(request: unknown): z.Safe
656
763
  */
657
764
  export declare function validateConsentApprovalResponse(response: unknown): z.SafeParseReturnType<{
658
765
  success: boolean;
659
- error?: string | undefined;
660
766
  delegation_id?: string | undefined;
661
767
  delegation_token?: string | undefined;
768
+ error?: string | undefined;
662
769
  error_code?: string | undefined;
663
770
  }, {
664
771
  success: boolean;
665
- error?: string | undefined;
666
772
  delegation_id?: string | undefined;
667
773
  delegation_token?: string | undefined;
774
+ error?: string | undefined;
668
775
  error_code?: string | undefined;
669
776
  }>;
670
777
  /**
@@ -683,12 +790,12 @@ export declare function validateConsentConfig(config: unknown): z.SafeParseRetur
683
790
  terms?: {
684
791
  version?: string | undefined;
685
792
  url?: string | undefined;
686
- required?: boolean | undefined;
687
793
  text?: string | undefined;
794
+ required?: boolean | undefined;
688
795
  } | undefined;
689
796
  customFields?: {
690
- type: "text" | "textarea" | "checkbox" | "select";
691
797
  name: string;
798
+ type: "text" | "textarea" | "checkbox" | "select";
692
799
  required: boolean;
693
800
  label: string;
694
801
  options?: {
@@ -718,8 +825,8 @@ export declare function validateConsentConfig(config: unknown): z.SafeParseRetur
718
825
  text?: string | undefined;
719
826
  } | undefined;
720
827
  customFields?: {
721
- type: "text" | "textarea" | "checkbox" | "select";
722
828
  name: string;
829
+ type: "text" | "textarea" | "checkbox" | "select";
723
830
  required: boolean;
724
831
  label: string;
725
832
  options?: {
@@ -8,7 +8,7 @@
8
8
  * Related Spec: MCP-I Phase 0 Implementation Plan
9
9
  */
10
10
  Object.defineProperty(exports, "__esModule", { value: true });
11
- exports.consentConfigSchema = exports.consentApprovalResponseSchema = exports.consentApprovalRequestSchema = exports.consentPageConfigSchema = exports.consentCustomFieldSchema = exports.consentCustomFieldOptionSchema = exports.consentTermsSchema = exports.consentBrandingSchema = void 0;
11
+ exports.consentConfigSchema = exports.consentApprovalResponseSchema = exports.consentApprovalRequestSchema = exports.consentPageConfigSchema = exports.oauthIdentitySchema = exports.consentCustomFieldSchema = exports.consentCustomFieldOptionSchema = exports.consentTermsSchema = exports.consentBrandingSchema = void 0;
12
12
  exports.validateConsentPageConfig = validateConsentPageConfig;
13
13
  exports.validateConsentApprovalRequest = validateConsentApprovalRequest;
14
14
  exports.validateConsentApprovalResponse = validateConsentApprovalResponse;
@@ -73,6 +73,40 @@ exports.consentCustomFieldSchema = zod_1.z.object({
73
73
  }, {
74
74
  message: 'Select fields must have options, and non-select fields must not have options',
75
75
  });
76
+ /**
77
+ * OAuth Identity Schema
78
+ *
79
+ * Represents a user's OAuth provider account information.
80
+ * Used in Phase 4 to link OAuth accounts to persistent User DIDs.
81
+ */
82
+ exports.oauthIdentitySchema = zod_1.z.object({
83
+ /**
84
+ * OAuth provider name (e.g., "google", "github", "microsoft")
85
+ */
86
+ provider: zod_1.z.string()
87
+ .min(1, 'Provider is required')
88
+ .max(50, 'Provider name must be 50 characters or less'),
89
+ /**
90
+ * OAuth subject identifier (unique user ID from provider)
91
+ * @example "123456789" (Google), "github-user-id" (GitHub)
92
+ */
93
+ subject: zod_1.z.string()
94
+ .min(1, 'Subject is required')
95
+ .max(255, 'Subject must be 255 characters or less'),
96
+ /**
97
+ * User's email address from OAuth provider (optional)
98
+ */
99
+ email: zod_1.z.string()
100
+ .email('Must be a valid email address')
101
+ .max(255, 'Email must be 255 characters or less')
102
+ .optional(),
103
+ /**
104
+ * User's display name from OAuth provider (optional)
105
+ */
106
+ name: zod_1.z.string()
107
+ .max(255, 'Name must be 255 characters or less')
108
+ .optional(),
109
+ });
76
110
  /**
77
111
  * Consent Page Config Schema
78
112
  */
@@ -96,6 +130,10 @@ exports.consentPageConfigSchema = zod_1.z.object({
96
130
  * Consent Approval Request Schema
97
131
  *
98
132
  * Note: Uses snake_case for API compatibility (agent_did, session_id, project_id)
133
+ *
134
+ * Phase 4 additions:
135
+ * - oauth_identity: Optional OAuth provider information for identity linking
136
+ * - user_did: Optional User DID for persistent identity (if already known)
99
137
  */
100
138
  exports.consentApprovalRequestSchema = zod_1.z.object({
101
139
  tool: zod_1.z.string().min(1, 'Tool name is required'),
@@ -104,10 +142,27 @@ exports.consentApprovalRequestSchema = zod_1.z.object({
104
142
  session_id: zod_1.z.string().min(1, 'Session ID is required'),
105
143
  project_id: zod_1.z.string().min(1, 'Project ID is required'),
106
144
  termsAccepted: zod_1.z.boolean(),
107
- termsVersion: zod_1.z.string().max(50, 'Terms version must be 50 characters or less').optional(),
145
+ termsVersion: zod_1.z.string()
146
+ .max(50, 'Terms version must be 50 characters or less')
147
+ .optional(),
108
148
  customFields: zod_1.z
109
149
  .record(zod_1.z.union([zod_1.z.string(), zod_1.z.boolean()]))
110
150
  .optional(),
151
+ // Phase 4: OAuth identity linking
152
+ /**
153
+ * OAuth provider identity information (optional)
154
+ * Used to link OAuth accounts to persistent User DIDs
155
+ */
156
+ oauth_identity: exports.oauthIdentitySchema.optional(),
157
+ /**
158
+ * User DID (optional)
159
+ * If provided, represents the persistent User DID for this user
160
+ * Format: did:key:... or did:web:...
161
+ */
162
+ user_did: zod_1.z.string()
163
+ .regex(/^did:/, 'Must be a valid DID format (starting with did:)')
164
+ .max(500, 'DID must be 500 characters or less')
165
+ .optional(),
111
166
  });
112
167
  /**
113
168
  * Consent Approval Response Schema
@@ -2,21 +2,126 @@ import { z } from "zod";
2
2
  /**
3
3
  * Handshake and session management schemas
4
4
  */
5
+ declare const MCPClientCapabilitiesSchema: z.ZodRecord<z.ZodString, z.ZodUnknown>;
6
+ export declare const MCPClientInfoSchema: z.ZodObject<{
7
+ name: z.ZodString;
8
+ title: z.ZodOptional<z.ZodString>;
9
+ version: z.ZodOptional<z.ZodString>;
10
+ platform: z.ZodOptional<z.ZodString>;
11
+ vendor: z.ZodOptional<z.ZodString>;
12
+ persistentId: z.ZodOptional<z.ZodString>;
13
+ }, "strip", z.ZodTypeAny, {
14
+ name: string;
15
+ title?: string | undefined;
16
+ version?: string | undefined;
17
+ platform?: string | undefined;
18
+ vendor?: string | undefined;
19
+ persistentId?: string | undefined;
20
+ }, {
21
+ name: string;
22
+ title?: string | undefined;
23
+ version?: string | undefined;
24
+ platform?: string | undefined;
25
+ vendor?: string | undefined;
26
+ persistentId?: string | undefined;
27
+ }>;
28
+ export declare const MCPClientSessionInfoSchema: z.ZodObject<{
29
+ name: z.ZodString;
30
+ title: z.ZodOptional<z.ZodString>;
31
+ version: z.ZodOptional<z.ZodString>;
32
+ platform: z.ZodOptional<z.ZodString>;
33
+ vendor: z.ZodOptional<z.ZodString>;
34
+ persistentId: z.ZodOptional<z.ZodString>;
35
+ } & {
36
+ clientId: z.ZodString;
37
+ protocolVersion: z.ZodOptional<z.ZodString>;
38
+ capabilities: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
39
+ }, "strip", z.ZodTypeAny, {
40
+ name: string;
41
+ clientId: string;
42
+ title?: string | undefined;
43
+ version?: string | undefined;
44
+ platform?: string | undefined;
45
+ vendor?: string | undefined;
46
+ persistentId?: string | undefined;
47
+ protocolVersion?: string | undefined;
48
+ capabilities?: Record<string, unknown> | undefined;
49
+ }, {
50
+ name: string;
51
+ clientId: string;
52
+ title?: string | undefined;
53
+ version?: string | undefined;
54
+ platform?: string | undefined;
55
+ vendor?: string | undefined;
56
+ persistentId?: string | undefined;
57
+ protocolVersion?: string | undefined;
58
+ capabilities?: Record<string, unknown> | undefined;
59
+ }>;
5
60
  export declare const HandshakeRequestSchema: z.ZodObject<{
6
61
  nonce: z.ZodString;
7
62
  audience: z.ZodString;
8
63
  timestamp: z.ZodNumber;
9
64
  agentDid: z.ZodOptional<z.ZodString>;
65
+ clientInfo: z.ZodOptional<z.ZodObject<{
66
+ name: z.ZodString;
67
+ title: z.ZodOptional<z.ZodString>;
68
+ version: z.ZodOptional<z.ZodString>;
69
+ platform: z.ZodOptional<z.ZodString>;
70
+ vendor: z.ZodOptional<z.ZodString>;
71
+ persistentId: z.ZodOptional<z.ZodString>;
72
+ } & {
73
+ clientId: z.ZodOptional<z.ZodString>;
74
+ }, "strip", z.ZodTypeAny, {
75
+ name: string;
76
+ title?: string | undefined;
77
+ version?: string | undefined;
78
+ platform?: string | undefined;
79
+ vendor?: string | undefined;
80
+ persistentId?: string | undefined;
81
+ clientId?: string | undefined;
82
+ }, {
83
+ name: string;
84
+ title?: string | undefined;
85
+ version?: string | undefined;
86
+ platform?: string | undefined;
87
+ vendor?: string | undefined;
88
+ persistentId?: string | undefined;
89
+ clientId?: string | undefined;
90
+ }>>;
91
+ clientProtocolVersion: z.ZodOptional<z.ZodString>;
92
+ clientCapabilities: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
10
93
  }, "strip", z.ZodTypeAny, {
11
94
  nonce: string;
12
95
  audience: string;
13
96
  timestamp: number;
14
97
  agentDid?: string | undefined;
98
+ clientInfo?: {
99
+ name: string;
100
+ title?: string | undefined;
101
+ version?: string | undefined;
102
+ platform?: string | undefined;
103
+ vendor?: string | undefined;
104
+ persistentId?: string | undefined;
105
+ clientId?: string | undefined;
106
+ } | undefined;
107
+ clientProtocolVersion?: string | undefined;
108
+ clientCapabilities?: Record<string, unknown> | undefined;
15
109
  }, {
16
110
  nonce: string;
17
111
  audience: string;
18
112
  timestamp: number;
19
113
  agentDid?: string | undefined;
114
+ clientInfo?: {
115
+ name: string;
116
+ title?: string | undefined;
117
+ version?: string | undefined;
118
+ platform?: string | undefined;
119
+ vendor?: string | undefined;
120
+ persistentId?: string | undefined;
121
+ clientId?: string | undefined;
122
+ } | undefined;
123
+ clientProtocolVersion?: string | undefined;
124
+ clientCapabilities?: Record<string, unknown> | undefined;
20
125
  }>;
21
126
  export declare const SessionContextSchema: z.ZodObject<{
22
127
  sessionId: z.ZodString;
@@ -30,26 +135,80 @@ export declare const SessionContextSchema: z.ZodObject<{
30
135
  serverDid: z.ZodOptional<z.ZodString>;
31
136
  clientDid: z.ZodOptional<z.ZodString>;
32
137
  userDid: z.ZodOptional<z.ZodString>;
138
+ clientInfo: z.ZodOptional<z.ZodObject<{
139
+ name: z.ZodString;
140
+ title: z.ZodOptional<z.ZodString>;
141
+ version: z.ZodOptional<z.ZodString>;
142
+ platform: z.ZodOptional<z.ZodString>;
143
+ vendor: z.ZodOptional<z.ZodString>;
144
+ persistentId: z.ZodOptional<z.ZodString>;
145
+ } & {
146
+ clientId: z.ZodString;
147
+ protocolVersion: z.ZodOptional<z.ZodString>;
148
+ capabilities: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
149
+ }, "strip", z.ZodTypeAny, {
150
+ name: string;
151
+ clientId: string;
152
+ title?: string | undefined;
153
+ version?: string | undefined;
154
+ platform?: string | undefined;
155
+ vendor?: string | undefined;
156
+ persistentId?: string | undefined;
157
+ protocolVersion?: string | undefined;
158
+ capabilities?: Record<string, unknown> | undefined;
159
+ }, {
160
+ name: string;
161
+ clientId: string;
162
+ title?: string | undefined;
163
+ version?: string | undefined;
164
+ platform?: string | undefined;
165
+ vendor?: string | undefined;
166
+ persistentId?: string | undefined;
167
+ protocolVersion?: string | undefined;
168
+ capabilities?: Record<string, unknown> | undefined;
169
+ }>>;
33
170
  }, "strip", z.ZodTypeAny, {
34
- createdAt: number;
35
171
  nonce: string;
36
172
  audience: string;
37
173
  timestamp: number;
38
174
  sessionId: string;
175
+ createdAt: number;
39
176
  lastActivity: number;
40
177
  ttlMinutes: number;
41
178
  agentDid?: string | undefined;
179
+ clientInfo?: {
180
+ name: string;
181
+ clientId: string;
182
+ title?: string | undefined;
183
+ version?: string | undefined;
184
+ platform?: string | undefined;
185
+ vendor?: string | undefined;
186
+ persistentId?: string | undefined;
187
+ protocolVersion?: string | undefined;
188
+ capabilities?: Record<string, unknown> | undefined;
189
+ } | undefined;
42
190
  serverDid?: string | undefined;
43
191
  clientDid?: string | undefined;
44
192
  userDid?: string | undefined;
45
193
  }, {
46
- createdAt: number;
47
194
  nonce: string;
48
195
  audience: string;
49
196
  timestamp: number;
50
197
  sessionId: string;
198
+ createdAt: number;
51
199
  lastActivity: number;
52
200
  agentDid?: string | undefined;
201
+ clientInfo?: {
202
+ name: string;
203
+ clientId: string;
204
+ title?: string | undefined;
205
+ version?: string | undefined;
206
+ platform?: string | undefined;
207
+ vendor?: string | undefined;
208
+ persistentId?: string | undefined;
209
+ protocolVersion?: string | undefined;
210
+ capabilities?: Record<string, unknown> | undefined;
211
+ } | undefined;
53
212
  ttlMinutes?: number | undefined;
54
213
  serverDid?: string | undefined;
55
214
  clientDid?: string | undefined;
@@ -65,8 +224,11 @@ export declare const NonceCacheEntrySchema: z.ZodObject<{
65
224
  sessionId: string;
66
225
  expiresAt: number;
67
226
  }>;
227
+ export type MCPClientInfo = z.infer<typeof MCPClientInfoSchema>;
228
+ export type MCPClientSessionInfo = z.infer<typeof MCPClientSessionInfoSchema>;
68
229
  export type HandshakeRequest = z.infer<typeof HandshakeRequestSchema>;
69
230
  export type SessionContext = z.infer<typeof SessionContextSchema>;
231
+ export type MCPClientCapabilities = z.infer<typeof MCPClientCapabilitiesSchema>;
70
232
  export type NonceCacheEntry = z.infer<typeof NonceCacheEntrySchema>;
71
233
  /**
72
234
  * Nonce cache interface for replay prevention
@@ -170,3 +332,4 @@ export type NonceCacheConfig = z.infer<typeof NonceCacheConfigSchema>;
170
332
  export declare const DEFAULT_SESSION_TTL_MINUTES = 30;
171
333
  export declare const DEFAULT_TIMESTAMP_SKEW_SECONDS = 120;
172
334
  export declare const NONCE_LENGTH_BYTES = 16;
335
+ export {};
package/dist/handshake.js CHANGED
@@ -1,15 +1,35 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.NONCE_LENGTH_BYTES = exports.DEFAULT_TIMESTAMP_SKEW_SECONDS = exports.DEFAULT_SESSION_TTL_MINUTES = exports.NonceCacheConfigSchema = exports.NonceCacheEntrySchema = exports.SessionContextSchema = exports.HandshakeRequestSchema = void 0;
3
+ exports.NONCE_LENGTH_BYTES = exports.DEFAULT_TIMESTAMP_SKEW_SECONDS = exports.DEFAULT_SESSION_TTL_MINUTES = exports.NonceCacheConfigSchema = exports.NonceCacheEntrySchema = exports.SessionContextSchema = exports.HandshakeRequestSchema = exports.MCPClientSessionInfoSchema = exports.MCPClientInfoSchema = void 0;
4
4
  const zod_1 = require("zod");
5
5
  /**
6
6
  * Handshake and session management schemas
7
7
  */
8
+ const MCPClientCapabilitiesSchema = zod_1.z.record(zod_1.z.string(), zod_1.z.unknown());
9
+ exports.MCPClientInfoSchema = zod_1.z.object({
10
+ name: zod_1.z.string().min(1), // e.g., "Claude Desktop"
11
+ title: zod_1.z.string().optional(), // Human-readable display name
12
+ version: zod_1.z.string().optional(), // e.g., "1.0.0"
13
+ platform: zod_1.z.string().optional(), // e.g., "desktop", "web", "mobile"
14
+ vendor: zod_1.z.string().optional(), // e.g., "Anthropic"
15
+ persistentId: zod_1.z.string().optional(), // Client-provided stable identifier
16
+ });
17
+ const MCPHandshakeClientInfoSchema = exports.MCPClientInfoSchema.extend({
18
+ clientId: zod_1.z.string().optional(), // Server-generated identifier (optional in request)
19
+ });
20
+ exports.MCPClientSessionInfoSchema = exports.MCPClientInfoSchema.extend({
21
+ clientId: zod_1.z.string(), // Generated by server
22
+ protocolVersion: zod_1.z.string().optional(), // Negotiated protocol version
23
+ capabilities: MCPClientCapabilitiesSchema.optional(), // Negotiated capabilities snapshot
24
+ });
8
25
  exports.HandshakeRequestSchema = zod_1.z.object({
9
26
  nonce: zod_1.z.string().min(1),
10
27
  audience: zod_1.z.string().min(1),
11
28
  timestamp: zod_1.z.number().int().positive(),
12
29
  agentDid: zod_1.z.string().startsWith("did:").optional(), // Agent DID for delegation verification
30
+ clientInfo: MCPHandshakeClientInfoSchema.optional(), // Optional client information from MCP initialize
31
+ clientProtocolVersion: zod_1.z.string().min(1).optional(), // Protocol version negotiated during initialize
32
+ clientCapabilities: MCPClientCapabilitiesSchema.optional(), // Client capability advertisement
13
33
  });
14
34
  exports.SessionContextSchema = zod_1.z.object({
15
35
  sessionId: zod_1.z.string().min(1),
@@ -20,9 +40,10 @@ exports.SessionContextSchema = zod_1.z.object({
20
40
  lastActivity: zod_1.z.number().int().positive(),
21
41
  ttlMinutes: zod_1.z.number().int().positive().default(30),
22
42
  agentDid: zod_1.z.string().optional(), // MCP Client/Agent DID (from handshake)
23
- serverDid: zod_1.z.string().min(1).optional(), // NEW: MCP-I Server DID (optional for backward compatibility)
43
+ serverDid: zod_1.z.string().min(1).optional(), // MCP-I Server DID (optional for backward compatibility)
24
44
  clientDid: zod_1.z.string().optional(), // Client app DID (if different from agent)
25
45
  userDid: zod_1.z.string().optional(), // User DID (delegator)
46
+ clientInfo: exports.MCPClientSessionInfoSchema.optional(), // MCP client information with negotiated metadata
26
47
  });
27
48
  exports.NonceCacheEntrySchema = zod_1.z.object({
28
49
  sessionId: zod_1.z.string().min(1),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kya-os/contracts",
3
- "version": "1.5.2-canary.5",
3
+ "version": "1.5.2",
4
4
  "description": "Shared types and schemas for XMCP-I ecosystem",
5
5
  "type": "commonjs",
6
6
  "sideEffects": false,