@kya-os/contracts 1.7.13 → 1.7.15
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/dist/agentshield-api/schemas.d.ts +83 -83
- package/dist/agentshield-api/schemas.js +2 -1
- package/dist/agentshield-api/types.d.ts +1 -1
- package/dist/audit/index.d.ts +21 -21
- package/dist/cli.d.ts +5 -5
- package/dist/consent/schemas.d.ts +28 -28
- package/dist/dashboard-config/schemas.d.ts +3106 -2582
- package/dist/delegation/schemas.d.ts +24 -24
- package/dist/deploy/schemas.d.ts +2 -2
- package/dist/handshake.d.ts +26 -26
- package/dist/proof/proof-record.d.ts +12 -12
- package/dist/proof/signing-spec.d.ts +4 -4
- package/dist/proof.d.ts +24 -24
- package/dist/reputation/api.d.ts +18 -18
- package/dist/reputation/schemas.d.ts +10 -10
- package/dist/tool-protection/index.d.ts +132 -37
- package/dist/tool-protection/index.js +42 -7
- package/dist/verifier.d.ts +6 -6
- package/dist/well-known/index.d.ts +18 -18
- package/package.json +1 -1
|
@@ -16,9 +16,17 @@ import { z } from 'zod';
|
|
|
16
16
|
* The VC output is always a DelegationCredential created on consent confirmation.
|
|
17
17
|
*/
|
|
18
18
|
export type AuthorizationRequirement = {
|
|
19
|
+
/**
|
|
20
|
+
* @deprecated Use 'oauth2' instead. Will be removed in v2.0.0.
|
|
21
|
+
*/
|
|
19
22
|
type: 'oauth';
|
|
20
23
|
provider: string;
|
|
21
24
|
requiredScopes?: string[];
|
|
25
|
+
} | {
|
|
26
|
+
/** OAuth 2.0 provider authentication (canonical) */
|
|
27
|
+
type: 'oauth2';
|
|
28
|
+
provider: string;
|
|
29
|
+
requiredScopes?: string[];
|
|
22
30
|
} | {
|
|
23
31
|
type: 'password';
|
|
24
32
|
provider: string;
|
|
@@ -48,7 +56,10 @@ export type AuthorizationRequirement = {
|
|
|
48
56
|
};
|
|
49
57
|
/** Canonical authorization type values for type safety */
|
|
50
58
|
export declare const AUTHORIZATION_TYPES: {
|
|
59
|
+
/** @deprecated Use OAUTH2 instead. Will be removed in v2.0.0. */
|
|
51
60
|
readonly OAUTH: "oauth";
|
|
61
|
+
/** OAuth 2.0 provider authentication (canonical) */
|
|
62
|
+
readonly OAUTH2: "oauth2";
|
|
52
63
|
readonly PASSWORD: "password";
|
|
53
64
|
readonly MDL: "mdl";
|
|
54
65
|
readonly IDV: "idv";
|
|
@@ -199,6 +210,18 @@ export declare const AuthorizationRequirementSchema: z.ZodDiscriminatedUnion<"ty
|
|
|
199
210
|
type: "oauth";
|
|
200
211
|
provider: string;
|
|
201
212
|
requiredScopes?: string[] | undefined;
|
|
213
|
+
}>, z.ZodObject<{
|
|
214
|
+
type: z.ZodLiteral<"oauth2">;
|
|
215
|
+
provider: z.ZodString;
|
|
216
|
+
requiredScopes: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
217
|
+
}, "strip", z.ZodTypeAny, {
|
|
218
|
+
type: "oauth2";
|
|
219
|
+
provider: string;
|
|
220
|
+
requiredScopes?: string[] | undefined;
|
|
221
|
+
}, {
|
|
222
|
+
type: "oauth2";
|
|
223
|
+
provider: string;
|
|
224
|
+
requiredScopes?: string[] | undefined;
|
|
202
225
|
}>, z.ZodObject<{
|
|
203
226
|
type: z.ZodLiteral<"password">;
|
|
204
227
|
provider: z.ZodString;
|
|
@@ -280,6 +303,18 @@ export declare const ToolProtectionSchema: z.ZodObject<{
|
|
|
280
303
|
type: "oauth";
|
|
281
304
|
provider: string;
|
|
282
305
|
requiredScopes?: string[] | undefined;
|
|
306
|
+
}>, z.ZodObject<{
|
|
307
|
+
type: z.ZodLiteral<"oauth2">;
|
|
308
|
+
provider: z.ZodString;
|
|
309
|
+
requiredScopes: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
310
|
+
}, "strip", z.ZodTypeAny, {
|
|
311
|
+
type: "oauth2";
|
|
312
|
+
provider: string;
|
|
313
|
+
requiredScopes?: string[] | undefined;
|
|
314
|
+
}, {
|
|
315
|
+
type: "oauth2";
|
|
316
|
+
provider: string;
|
|
317
|
+
requiredScopes?: string[] | undefined;
|
|
283
318
|
}>, z.ZodObject<{
|
|
284
319
|
type: z.ZodLiteral<"password">;
|
|
285
320
|
provider: z.ZodString;
|
|
@@ -345,12 +380,18 @@ export declare const ToolProtectionSchema: z.ZodObject<{
|
|
|
345
380
|
type: "none";
|
|
346
381
|
}>]>>;
|
|
347
382
|
}, "strip", z.ZodTypeAny, {
|
|
348
|
-
requiresDelegation: boolean;
|
|
349
383
|
requiredScopes: string[];
|
|
384
|
+
requiresDelegation: boolean;
|
|
385
|
+
riskLevel?: "low" | "medium" | "high" | "critical" | undefined;
|
|
386
|
+
oauthProvider?: string | undefined;
|
|
350
387
|
authorization?: {
|
|
351
388
|
type: "oauth";
|
|
352
389
|
provider: string;
|
|
353
390
|
requiredScopes?: string[] | undefined;
|
|
391
|
+
} | {
|
|
392
|
+
type: "oauth2";
|
|
393
|
+
provider: string;
|
|
394
|
+
requiredScopes?: string[] | undefined;
|
|
354
395
|
} | {
|
|
355
396
|
type: "password";
|
|
356
397
|
provider: string;
|
|
@@ -373,15 +414,19 @@ export declare const ToolProtectionSchema: z.ZodObject<{
|
|
|
373
414
|
} | {
|
|
374
415
|
type: "none";
|
|
375
416
|
} | undefined;
|
|
376
|
-
riskLevel?: "low" | "medium" | "high" | "critical" | undefined;
|
|
377
|
-
oauthProvider?: string | undefined;
|
|
378
417
|
}, {
|
|
379
|
-
requiresDelegation: boolean;
|
|
380
418
|
requiredScopes: string[];
|
|
419
|
+
requiresDelegation: boolean;
|
|
420
|
+
riskLevel?: "low" | "medium" | "high" | "critical" | undefined;
|
|
421
|
+
oauthProvider?: string | undefined;
|
|
381
422
|
authorization?: {
|
|
382
423
|
type: "oauth";
|
|
383
424
|
provider: string;
|
|
384
425
|
requiredScopes?: string[] | undefined;
|
|
426
|
+
} | {
|
|
427
|
+
type: "oauth2";
|
|
428
|
+
provider: string;
|
|
429
|
+
requiredScopes?: string[] | undefined;
|
|
385
430
|
} | {
|
|
386
431
|
type: "password";
|
|
387
432
|
provider: string;
|
|
@@ -404,8 +449,6 @@ export declare const ToolProtectionSchema: z.ZodObject<{
|
|
|
404
449
|
} | {
|
|
405
450
|
type: "none";
|
|
406
451
|
} | undefined;
|
|
407
|
-
riskLevel?: "low" | "medium" | "high" | "critical" | undefined;
|
|
408
|
-
oauthProvider?: string | undefined;
|
|
409
452
|
}>;
|
|
410
453
|
export declare const ToolProtectionMapSchema: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
411
454
|
requiresDelegation: z.ZodBoolean;
|
|
@@ -424,6 +467,18 @@ export declare const ToolProtectionMapSchema: z.ZodRecord<z.ZodString, z.ZodObje
|
|
|
424
467
|
type: "oauth";
|
|
425
468
|
provider: string;
|
|
426
469
|
requiredScopes?: string[] | undefined;
|
|
470
|
+
}>, z.ZodObject<{
|
|
471
|
+
type: z.ZodLiteral<"oauth2">;
|
|
472
|
+
provider: z.ZodString;
|
|
473
|
+
requiredScopes: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
474
|
+
}, "strip", z.ZodTypeAny, {
|
|
475
|
+
type: "oauth2";
|
|
476
|
+
provider: string;
|
|
477
|
+
requiredScopes?: string[] | undefined;
|
|
478
|
+
}, {
|
|
479
|
+
type: "oauth2";
|
|
480
|
+
provider: string;
|
|
481
|
+
requiredScopes?: string[] | undefined;
|
|
427
482
|
}>, z.ZodObject<{
|
|
428
483
|
type: z.ZodLiteral<"password">;
|
|
429
484
|
provider: z.ZodString;
|
|
@@ -489,12 +544,18 @@ export declare const ToolProtectionMapSchema: z.ZodRecord<z.ZodString, z.ZodObje
|
|
|
489
544
|
type: "none";
|
|
490
545
|
}>]>>;
|
|
491
546
|
}, "strip", z.ZodTypeAny, {
|
|
492
|
-
requiresDelegation: boolean;
|
|
493
547
|
requiredScopes: string[];
|
|
548
|
+
requiresDelegation: boolean;
|
|
549
|
+
riskLevel?: "low" | "medium" | "high" | "critical" | undefined;
|
|
550
|
+
oauthProvider?: string | undefined;
|
|
494
551
|
authorization?: {
|
|
495
552
|
type: "oauth";
|
|
496
553
|
provider: string;
|
|
497
554
|
requiredScopes?: string[] | undefined;
|
|
555
|
+
} | {
|
|
556
|
+
type: "oauth2";
|
|
557
|
+
provider: string;
|
|
558
|
+
requiredScopes?: string[] | undefined;
|
|
498
559
|
} | {
|
|
499
560
|
type: "password";
|
|
500
561
|
provider: string;
|
|
@@ -517,15 +578,19 @@ export declare const ToolProtectionMapSchema: z.ZodRecord<z.ZodString, z.ZodObje
|
|
|
517
578
|
} | {
|
|
518
579
|
type: "none";
|
|
519
580
|
} | undefined;
|
|
520
|
-
riskLevel?: "low" | "medium" | "high" | "critical" | undefined;
|
|
521
|
-
oauthProvider?: string | undefined;
|
|
522
581
|
}, {
|
|
523
|
-
requiresDelegation: boolean;
|
|
524
582
|
requiredScopes: string[];
|
|
583
|
+
requiresDelegation: boolean;
|
|
584
|
+
riskLevel?: "low" | "medium" | "high" | "critical" | undefined;
|
|
585
|
+
oauthProvider?: string | undefined;
|
|
525
586
|
authorization?: {
|
|
526
587
|
type: "oauth";
|
|
527
588
|
provider: string;
|
|
528
589
|
requiredScopes?: string[] | undefined;
|
|
590
|
+
} | {
|
|
591
|
+
type: "oauth2";
|
|
592
|
+
provider: string;
|
|
593
|
+
requiredScopes?: string[] | undefined;
|
|
529
594
|
} | {
|
|
530
595
|
type: "password";
|
|
531
596
|
provider: string;
|
|
@@ -548,8 +613,6 @@ export declare const ToolProtectionMapSchema: z.ZodRecord<z.ZodString, z.ZodObje
|
|
|
548
613
|
} | {
|
|
549
614
|
type: "none";
|
|
550
615
|
} | undefined;
|
|
551
|
-
riskLevel?: "low" | "medium" | "high" | "critical" | undefined;
|
|
552
|
-
oauthProvider?: string | undefined;
|
|
553
616
|
}>>;
|
|
554
617
|
export declare const ToolProtectionResponseSchema: z.ZodObject<{
|
|
555
618
|
toolProtections: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
@@ -569,6 +632,18 @@ export declare const ToolProtectionResponseSchema: z.ZodObject<{
|
|
|
569
632
|
type: "oauth";
|
|
570
633
|
provider: string;
|
|
571
634
|
requiredScopes?: string[] | undefined;
|
|
635
|
+
}>, z.ZodObject<{
|
|
636
|
+
type: z.ZodLiteral<"oauth2">;
|
|
637
|
+
provider: z.ZodString;
|
|
638
|
+
requiredScopes: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
639
|
+
}, "strip", z.ZodTypeAny, {
|
|
640
|
+
type: "oauth2";
|
|
641
|
+
provider: string;
|
|
642
|
+
requiredScopes?: string[] | undefined;
|
|
643
|
+
}, {
|
|
644
|
+
type: "oauth2";
|
|
645
|
+
provider: string;
|
|
646
|
+
requiredScopes?: string[] | undefined;
|
|
572
647
|
}>, z.ZodObject<{
|
|
573
648
|
type: z.ZodLiteral<"password">;
|
|
574
649
|
provider: z.ZodString;
|
|
@@ -634,12 +709,18 @@ export declare const ToolProtectionResponseSchema: z.ZodObject<{
|
|
|
634
709
|
type: "none";
|
|
635
710
|
}>]>>;
|
|
636
711
|
}, "strip", z.ZodTypeAny, {
|
|
637
|
-
requiresDelegation: boolean;
|
|
638
712
|
requiredScopes: string[];
|
|
713
|
+
requiresDelegation: boolean;
|
|
714
|
+
riskLevel?: "low" | "medium" | "high" | "critical" | undefined;
|
|
715
|
+
oauthProvider?: string | undefined;
|
|
639
716
|
authorization?: {
|
|
640
717
|
type: "oauth";
|
|
641
718
|
provider: string;
|
|
642
719
|
requiredScopes?: string[] | undefined;
|
|
720
|
+
} | {
|
|
721
|
+
type: "oauth2";
|
|
722
|
+
provider: string;
|
|
723
|
+
requiredScopes?: string[] | undefined;
|
|
643
724
|
} | {
|
|
644
725
|
type: "password";
|
|
645
726
|
provider: string;
|
|
@@ -662,15 +743,19 @@ export declare const ToolProtectionResponseSchema: z.ZodObject<{
|
|
|
662
743
|
} | {
|
|
663
744
|
type: "none";
|
|
664
745
|
} | undefined;
|
|
665
|
-
riskLevel?: "low" | "medium" | "high" | "critical" | undefined;
|
|
666
|
-
oauthProvider?: string | undefined;
|
|
667
746
|
}, {
|
|
668
|
-
requiresDelegation: boolean;
|
|
669
747
|
requiredScopes: string[];
|
|
748
|
+
requiresDelegation: boolean;
|
|
749
|
+
riskLevel?: "low" | "medium" | "high" | "critical" | undefined;
|
|
750
|
+
oauthProvider?: string | undefined;
|
|
670
751
|
authorization?: {
|
|
671
752
|
type: "oauth";
|
|
672
753
|
provider: string;
|
|
673
754
|
requiredScopes?: string[] | undefined;
|
|
755
|
+
} | {
|
|
756
|
+
type: "oauth2";
|
|
757
|
+
provider: string;
|
|
758
|
+
requiredScopes?: string[] | undefined;
|
|
674
759
|
} | {
|
|
675
760
|
type: "password";
|
|
676
761
|
provider: string;
|
|
@@ -693,30 +778,34 @@ export declare const ToolProtectionResponseSchema: z.ZodObject<{
|
|
|
693
778
|
} | {
|
|
694
779
|
type: "none";
|
|
695
780
|
} | undefined;
|
|
696
|
-
riskLevel?: "low" | "medium" | "high" | "critical" | undefined;
|
|
697
|
-
oauthProvider?: string | undefined;
|
|
698
781
|
}>>;
|
|
699
782
|
metadata: z.ZodOptional<z.ZodObject<{
|
|
700
783
|
lastUpdated: z.ZodOptional<z.ZodString>;
|
|
701
784
|
version: z.ZodOptional<z.ZodString>;
|
|
702
785
|
source: z.ZodOptional<z.ZodString>;
|
|
703
786
|
}, "strip", z.ZodTypeAny, {
|
|
787
|
+
lastUpdated?: string | undefined;
|
|
704
788
|
version?: string | undefined;
|
|
705
789
|
source?: string | undefined;
|
|
706
|
-
lastUpdated?: string | undefined;
|
|
707
790
|
}, {
|
|
791
|
+
lastUpdated?: string | undefined;
|
|
708
792
|
version?: string | undefined;
|
|
709
793
|
source?: string | undefined;
|
|
710
|
-
lastUpdated?: string | undefined;
|
|
711
794
|
}>>;
|
|
712
795
|
}, "strip", z.ZodTypeAny, {
|
|
713
796
|
toolProtections: Record<string, {
|
|
714
|
-
requiresDelegation: boolean;
|
|
715
797
|
requiredScopes: string[];
|
|
798
|
+
requiresDelegation: boolean;
|
|
799
|
+
riskLevel?: "low" | "medium" | "high" | "critical" | undefined;
|
|
800
|
+
oauthProvider?: string | undefined;
|
|
716
801
|
authorization?: {
|
|
717
802
|
type: "oauth";
|
|
718
803
|
provider: string;
|
|
719
804
|
requiredScopes?: string[] | undefined;
|
|
805
|
+
} | {
|
|
806
|
+
type: "oauth2";
|
|
807
|
+
provider: string;
|
|
808
|
+
requiredScopes?: string[] | undefined;
|
|
720
809
|
} | {
|
|
721
810
|
type: "password";
|
|
722
811
|
provider: string;
|
|
@@ -739,22 +828,26 @@ export declare const ToolProtectionResponseSchema: z.ZodObject<{
|
|
|
739
828
|
} | {
|
|
740
829
|
type: "none";
|
|
741
830
|
} | undefined;
|
|
742
|
-
riskLevel?: "low" | "medium" | "high" | "critical" | undefined;
|
|
743
|
-
oauthProvider?: string | undefined;
|
|
744
831
|
}>;
|
|
745
832
|
metadata?: {
|
|
833
|
+
lastUpdated?: string | undefined;
|
|
746
834
|
version?: string | undefined;
|
|
747
835
|
source?: string | undefined;
|
|
748
|
-
lastUpdated?: string | undefined;
|
|
749
836
|
} | undefined;
|
|
750
837
|
}, {
|
|
751
838
|
toolProtections: Record<string, {
|
|
752
|
-
requiresDelegation: boolean;
|
|
753
839
|
requiredScopes: string[];
|
|
840
|
+
requiresDelegation: boolean;
|
|
841
|
+
riskLevel?: "low" | "medium" | "high" | "critical" | undefined;
|
|
842
|
+
oauthProvider?: string | undefined;
|
|
754
843
|
authorization?: {
|
|
755
844
|
type: "oauth";
|
|
756
845
|
provider: string;
|
|
757
846
|
requiredScopes?: string[] | undefined;
|
|
847
|
+
} | {
|
|
848
|
+
type: "oauth2";
|
|
849
|
+
provider: string;
|
|
850
|
+
requiredScopes?: string[] | undefined;
|
|
758
851
|
} | {
|
|
759
852
|
type: "password";
|
|
760
853
|
provider: string;
|
|
@@ -777,13 +870,11 @@ export declare const ToolProtectionResponseSchema: z.ZodObject<{
|
|
|
777
870
|
} | {
|
|
778
871
|
type: "none";
|
|
779
872
|
} | undefined;
|
|
780
|
-
riskLevel?: "low" | "medium" | "high" | "critical" | undefined;
|
|
781
|
-
oauthProvider?: string | undefined;
|
|
782
873
|
}>;
|
|
783
874
|
metadata?: {
|
|
875
|
+
lastUpdated?: string | undefined;
|
|
784
876
|
version?: string | undefined;
|
|
785
877
|
source?: string | undefined;
|
|
786
|
-
lastUpdated?: string | undefined;
|
|
787
878
|
} | undefined;
|
|
788
879
|
}>;
|
|
789
880
|
export declare const DelegationRequiredErrorDataSchema: z.ZodObject<{
|
|
@@ -795,15 +886,15 @@ export declare const DelegationRequiredErrorDataSchema: z.ZodObject<{
|
|
|
795
886
|
}, "strip", z.ZodTypeAny, {
|
|
796
887
|
requiredScopes: string[];
|
|
797
888
|
toolName: string;
|
|
889
|
+
consentUrl?: string | undefined;
|
|
798
890
|
authorizationUrl?: string | undefined;
|
|
799
891
|
reason?: string | undefined;
|
|
800
|
-
consentUrl?: string | undefined;
|
|
801
892
|
}, {
|
|
802
893
|
requiredScopes: string[];
|
|
803
894
|
toolName: string;
|
|
895
|
+
consentUrl?: string | undefined;
|
|
804
896
|
authorizationUrl?: string | undefined;
|
|
805
897
|
reason?: string | undefined;
|
|
806
|
-
consentUrl?: string | undefined;
|
|
807
898
|
}>;
|
|
808
899
|
/**
|
|
809
900
|
* Type Guards
|
|
@@ -818,10 +909,11 @@ export declare function isDelegationRequiredErrorData(obj: any): obj is Delegati
|
|
|
818
909
|
export declare function isAuthorizationRequirement(obj: unknown): obj is AuthorizationRequirement;
|
|
819
910
|
/**
|
|
820
911
|
* Type guard to check if a ToolProtection has OAuth authorization
|
|
912
|
+
* Checks for both 'oauth' (deprecated) and 'oauth2' (canonical)
|
|
821
913
|
*/
|
|
822
914
|
export declare function hasOAuthAuthorization(protection: ToolProtection): protection is ToolProtection & {
|
|
823
915
|
authorization: {
|
|
824
|
-
type: 'oauth';
|
|
916
|
+
type: 'oauth' | 'oauth2';
|
|
825
917
|
};
|
|
826
918
|
};
|
|
827
919
|
/**
|
|
@@ -921,21 +1013,24 @@ export declare function getAuthorizationTypeKey(auth: AuthorizationRequirement):
|
|
|
921
1013
|
/**
|
|
922
1014
|
* Normalize authorization requirement type
|
|
923
1015
|
*
|
|
924
|
-
* Normalizes deprecated
|
|
925
|
-
*
|
|
926
|
-
*
|
|
1016
|
+
* Normalizes deprecated types to their canonical equivalents:
|
|
1017
|
+
* - 'oauth' → 'oauth2'
|
|
1018
|
+
* - 'credential' → 'verifiable_credential'
|
|
1019
|
+
*
|
|
1020
|
+
* This function should be called at runtime boundaries when processing
|
|
1021
|
+
* authorization requirements.
|
|
927
1022
|
*
|
|
928
|
-
* @param auth - Authorization requirement (may contain deprecated
|
|
1023
|
+
* @param auth - Authorization requirement (may contain deprecated types)
|
|
929
1024
|
* @param options - Normalization options
|
|
930
1025
|
* @returns Normalized authorization requirement
|
|
931
1026
|
*
|
|
932
1027
|
* @example
|
|
933
1028
|
* ```typescript
|
|
934
1029
|
* const normalized = normalizeAuthorizationType(
|
|
935
|
-
* { type: '
|
|
1030
|
+
* { type: 'oauth', provider: 'github' },
|
|
936
1031
|
* { warn: true }
|
|
937
1032
|
* );
|
|
938
|
-
* // Returns: { type: '
|
|
1033
|
+
* // Returns: { type: 'oauth2', provider: 'github' }
|
|
939
1034
|
* // Logs: DEPRECATION warning
|
|
940
1035
|
* ```
|
|
941
1036
|
*/
|
|
@@ -35,7 +35,10 @@ exports.normalizeAuthorizationType = normalizeAuthorizationType;
|
|
|
35
35
|
const zod_1 = require("zod");
|
|
36
36
|
/** Canonical authorization type values for type safety */
|
|
37
37
|
exports.AUTHORIZATION_TYPES = {
|
|
38
|
+
/** @deprecated Use OAUTH2 instead. Will be removed in v2.0.0. */
|
|
38
39
|
OAUTH: 'oauth',
|
|
40
|
+
/** OAuth 2.0 provider authentication (canonical) */
|
|
41
|
+
OAUTH2: 'oauth2',
|
|
39
42
|
PASSWORD: 'password',
|
|
40
43
|
MDL: 'mdl',
|
|
41
44
|
IDV: 'idv',
|
|
@@ -46,11 +49,19 @@ exports.AUTHORIZATION_TYPES = {
|
|
|
46
49
|
* Zod Schemas for Validation
|
|
47
50
|
*/
|
|
48
51
|
exports.AuthorizationRequirementSchema = zod_1.z.discriminatedUnion('type', [
|
|
52
|
+
// Deprecated: 'oauth' is an alias for 'oauth2'
|
|
53
|
+
// Will be removed in v2.0.0. Use 'oauth2' instead.
|
|
49
54
|
zod_1.z.object({
|
|
50
55
|
type: zod_1.z.literal('oauth'),
|
|
51
56
|
provider: zod_1.z.string(),
|
|
52
57
|
requiredScopes: zod_1.z.array(zod_1.z.string()).optional(),
|
|
53
58
|
}),
|
|
59
|
+
// OAuth 2.0 provider authentication (canonical)
|
|
60
|
+
zod_1.z.object({
|
|
61
|
+
type: zod_1.z.literal('oauth2'),
|
|
62
|
+
provider: zod_1.z.string(),
|
|
63
|
+
requiredScopes: zod_1.z.array(zod_1.z.string()).optional(),
|
|
64
|
+
}),
|
|
54
65
|
zod_1.z.object({
|
|
55
66
|
type: zod_1.z.literal('password'),
|
|
56
67
|
provider: zod_1.z.string(),
|
|
@@ -127,9 +138,10 @@ function isAuthorizationRequirement(obj) {
|
|
|
127
138
|
}
|
|
128
139
|
/**
|
|
129
140
|
* Type guard to check if a ToolProtection has OAuth authorization
|
|
141
|
+
* Checks for both 'oauth' (deprecated) and 'oauth2' (canonical)
|
|
130
142
|
*/
|
|
131
143
|
function hasOAuthAuthorization(protection) {
|
|
132
|
-
return protection.authorization?.type === 'oauth';
|
|
144
|
+
return protection.authorization?.type === 'oauth' || protection.authorization?.type === 'oauth2';
|
|
133
145
|
}
|
|
134
146
|
/**
|
|
135
147
|
* Type guard to check if a ToolProtection has password authorization
|
|
@@ -290,6 +302,7 @@ function determineConsentProviderType(hasOAuthIdentity, isPasswordFlow = false,
|
|
|
290
302
|
function getAuthorizationTypeLabel(auth) {
|
|
291
303
|
switch (auth.type) {
|
|
292
304
|
case 'oauth':
|
|
305
|
+
case 'oauth2':
|
|
293
306
|
return auth.provider
|
|
294
307
|
? auth.provider.charAt(0).toUpperCase() + auth.provider.slice(1)
|
|
295
308
|
: 'OAuth Provider';
|
|
@@ -318,7 +331,10 @@ function getAuthorizationTypeLabel(auth) {
|
|
|
318
331
|
function getAuthorizationTypeKey(auth) {
|
|
319
332
|
switch (auth.type) {
|
|
320
333
|
case 'oauth':
|
|
334
|
+
// Keep original key format for backward compatibility with existing cache entries
|
|
321
335
|
return `oauth:${auth.provider}`;
|
|
336
|
+
case 'oauth2':
|
|
337
|
+
return `oauth2:${auth.provider}`;
|
|
322
338
|
case 'password':
|
|
323
339
|
return `password:${auth.provider}`;
|
|
324
340
|
case 'mdl':
|
|
@@ -341,26 +357,45 @@ function getAuthorizationTypeKey(auth) {
|
|
|
341
357
|
/**
|
|
342
358
|
* Normalize authorization requirement type
|
|
343
359
|
*
|
|
344
|
-
* Normalizes deprecated
|
|
345
|
-
*
|
|
346
|
-
*
|
|
360
|
+
* Normalizes deprecated types to their canonical equivalents:
|
|
361
|
+
* - 'oauth' → 'oauth2'
|
|
362
|
+
* - 'credential' → 'verifiable_credential'
|
|
363
|
+
*
|
|
364
|
+
* This function should be called at runtime boundaries when processing
|
|
365
|
+
* authorization requirements.
|
|
347
366
|
*
|
|
348
|
-
* @param auth - Authorization requirement (may contain deprecated
|
|
367
|
+
* @param auth - Authorization requirement (may contain deprecated types)
|
|
349
368
|
* @param options - Normalization options
|
|
350
369
|
* @returns Normalized authorization requirement
|
|
351
370
|
*
|
|
352
371
|
* @example
|
|
353
372
|
* ```typescript
|
|
354
373
|
* const normalized = normalizeAuthorizationType(
|
|
355
|
-
* { type: '
|
|
374
|
+
* { type: 'oauth', provider: 'github' },
|
|
356
375
|
* { warn: true }
|
|
357
376
|
* );
|
|
358
|
-
* // Returns: { type: '
|
|
377
|
+
* // Returns: { type: 'oauth2', provider: 'github' }
|
|
359
378
|
* // Logs: DEPRECATION warning
|
|
360
379
|
* ```
|
|
361
380
|
*/
|
|
362
381
|
function normalizeAuthorizationType(auth, options = {}) {
|
|
363
382
|
const { warn = true, logger = console.warn } = options;
|
|
383
|
+
// Normalize 'oauth' to 'oauth2'
|
|
384
|
+
if (auth.type === 'oauth') {
|
|
385
|
+
if (warn) {
|
|
386
|
+
logger(`DEPRECATION: Authorization type 'oauth' is deprecated and will be removed in v2.0.0. ` +
|
|
387
|
+
`Please update to 'oauth2'. ` +
|
|
388
|
+
`See https://github.com/modelcontextprotocol-identity/xmcp-i/blob/main/docs/migrations/oauth-to-oauth2.md`);
|
|
389
|
+
}
|
|
390
|
+
// Normalize to oauth2
|
|
391
|
+
const normalized = {
|
|
392
|
+
type: 'oauth2',
|
|
393
|
+
provider: auth.provider,
|
|
394
|
+
...(auth.requiredScopes !== undefined && { requiredScopes: auth.requiredScopes }),
|
|
395
|
+
};
|
|
396
|
+
return normalized;
|
|
397
|
+
}
|
|
398
|
+
// Normalize 'credential' to 'verifiable_credential'
|
|
364
399
|
if (auth.type === 'credential') {
|
|
365
400
|
if (warn) {
|
|
366
401
|
logger(`DEPRECATION: Authorization type 'credential' is deprecated and will be removed in v2.0.0. ` +
|
package/dist/verifier.d.ts
CHANGED
|
@@ -20,8 +20,8 @@ export declare const AgentContextSchema: z.ZodObject<{
|
|
|
20
20
|
confidence: "verified";
|
|
21
21
|
registry: string;
|
|
22
22
|
verifiedAt: number;
|
|
23
|
-
subject?: string | undefined;
|
|
24
23
|
delegationRef?: string | undefined;
|
|
24
|
+
subject?: string | undefined;
|
|
25
25
|
}, {
|
|
26
26
|
did: string;
|
|
27
27
|
kid: string;
|
|
@@ -30,8 +30,8 @@ export declare const AgentContextSchema: z.ZodObject<{
|
|
|
30
30
|
registry: string;
|
|
31
31
|
verifiedAt: number;
|
|
32
32
|
scopes?: string[] | undefined;
|
|
33
|
-
subject?: string | undefined;
|
|
34
33
|
delegationRef?: string | undefined;
|
|
34
|
+
subject?: string | undefined;
|
|
35
35
|
}>;
|
|
36
36
|
export declare const VerifierResultSchema: z.ZodObject<{
|
|
37
37
|
success: z.ZodBoolean;
|
|
@@ -54,8 +54,8 @@ export declare const VerifierResultSchema: z.ZodObject<{
|
|
|
54
54
|
confidence: "verified";
|
|
55
55
|
registry: string;
|
|
56
56
|
verifiedAt: number;
|
|
57
|
-
subject?: string | undefined;
|
|
58
57
|
delegationRef?: string | undefined;
|
|
58
|
+
subject?: string | undefined;
|
|
59
59
|
}, {
|
|
60
60
|
did: string;
|
|
61
61
|
kid: string;
|
|
@@ -64,8 +64,8 @@ export declare const VerifierResultSchema: z.ZodObject<{
|
|
|
64
64
|
registry: string;
|
|
65
65
|
verifiedAt: number;
|
|
66
66
|
scopes?: string[] | undefined;
|
|
67
|
-
subject?: string | undefined;
|
|
68
67
|
delegationRef?: string | undefined;
|
|
68
|
+
subject?: string | undefined;
|
|
69
69
|
}>>;
|
|
70
70
|
error: z.ZodOptional<z.ZodObject<{
|
|
71
71
|
code: z.ZodString;
|
|
@@ -100,8 +100,8 @@ export declare const VerifierResultSchema: z.ZodObject<{
|
|
|
100
100
|
confidence: "verified";
|
|
101
101
|
registry: string;
|
|
102
102
|
verifiedAt: number;
|
|
103
|
-
subject?: string | undefined;
|
|
104
103
|
delegationRef?: string | undefined;
|
|
104
|
+
subject?: string | undefined;
|
|
105
105
|
} | undefined;
|
|
106
106
|
}, {
|
|
107
107
|
success: boolean;
|
|
@@ -120,8 +120,8 @@ export declare const VerifierResultSchema: z.ZodObject<{
|
|
|
120
120
|
registry: string;
|
|
121
121
|
verifiedAt: number;
|
|
122
122
|
scopes?: string[] | undefined;
|
|
123
|
-
subject?: string | undefined;
|
|
124
123
|
delegationRef?: string | undefined;
|
|
124
|
+
subject?: string | undefined;
|
|
125
125
|
} | undefined;
|
|
126
126
|
}>;
|
|
127
127
|
export declare const StructuredErrorSchema: z.ZodObject<{
|