@kya-os/contracts 1.3.5 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agentshield-api/endpoints.d.ts +50 -0
- package/dist/agentshield-api/endpoints.js +46 -0
- package/dist/agentshield-api/index.d.ts +13 -0
- package/dist/agentshield-api/index.js +38 -0
- package/dist/agentshield-api/schemas.d.ts +9914 -0
- package/dist/agentshield-api/schemas.js +165 -0
- package/dist/agentshield-api/types.d.ts +168 -0
- package/dist/agentshield-api/types.js +27 -0
- package/dist/cli.d.ts +13 -0
- package/dist/cli.js +13 -1
- package/dist/config/base.d.ts +96 -0
- package/dist/config/base.js +11 -0
- package/dist/config/delegation.d.ts +194 -0
- package/dist/config/delegation.js +10 -0
- package/dist/config/identity.d.ts +117 -0
- package/dist/config/identity.js +11 -0
- package/dist/config/index.d.ts +33 -0
- package/dist/config/index.js +11 -0
- package/dist/config/proofing.d.ts +120 -0
- package/dist/config/proofing.js +10 -0
- package/dist/config/tool-protection.d.ts +139 -0
- package/dist/config/tool-protection.js +10 -0
- package/dist/dashboard-config/index.d.ts +10 -0
- package/dist/dashboard-config/index.js +31 -0
- package/dist/dashboard-config/schemas.d.ts +5847 -0
- package/dist/dashboard-config/schemas.js +251 -0
- package/dist/dashboard-config/types.d.ts +331 -0
- package/dist/dashboard-config/types.js +11 -0
- package/dist/delegation/constraints.d.ts +991 -0
- package/dist/delegation/constraints.js +209 -0
- package/dist/delegation/index.d.ts +7 -0
- package/dist/delegation/index.js +23 -0
- package/dist/delegation/schemas.d.ts +8381 -0
- package/dist/delegation/schemas.js +475 -0
- package/dist/did/index.d.ts +8 -0
- package/dist/did/index.js +24 -0
- package/dist/did/resolve-contract.d.ts +219 -0
- package/dist/did/resolve-contract.js +31 -0
- package/dist/did/schemas.d.ts +112 -0
- package/dist/did/schemas.js +172 -0
- package/dist/did/types.d.ts +163 -0
- package/dist/did/types.js +70 -0
- package/dist/env/constants.d.ts +57 -0
- package/dist/env/constants.js +59 -0
- package/dist/env/index.d.ts +4 -0
- package/dist/env/index.js +20 -0
- package/dist/handshake.d.ts +20 -0
- package/dist/handshake.js +10 -3
- package/dist/index.d.ts +14 -0
- package/dist/index.js +28 -0
- package/dist/proof/index.d.ts +8 -0
- package/dist/proof/index.js +24 -0
- package/dist/proof/proof-record.d.ts +837 -0
- package/dist/proof/proof-record.js +133 -0
- package/dist/proof/signing-spec.d.ts +146 -0
- package/dist/proof/signing-spec.js +122 -0
- package/dist/proof.d.ts +53 -16
- package/dist/proof.js +27 -3
- package/dist/registry.d.ts +16 -0
- package/dist/registry.js +29 -9
- package/dist/runtime/errors.d.ts +347 -0
- package/dist/runtime/errors.js +119 -0
- package/dist/runtime/headers.d.ts +83 -0
- package/dist/runtime/headers.js +81 -0
- package/dist/runtime/index.d.ts +5 -0
- package/dist/runtime/index.js +21 -0
- package/dist/test.d.ts +36 -0
- package/dist/test.js +36 -0
- package/dist/tlkrc/index.d.ts +4 -0
- package/dist/tlkrc/index.js +20 -0
- package/dist/tlkrc/rotation.d.ts +245 -0
- package/dist/tlkrc/rotation.js +126 -0
- package/dist/tool-protection/index.d.ts +227 -0
- package/dist/tool-protection/index.js +113 -0
- package/dist/utils/validation.d.ts +16 -0
- package/dist/utils/validation.js +13 -0
- package/dist/vc/index.d.ts +7 -0
- package/dist/vc/index.js +23 -0
- package/dist/vc/schemas.d.ts +2483 -0
- package/dist/vc/schemas.js +224 -0
- package/dist/vc/statuslist.d.ts +493 -0
- package/dist/vc/statuslist.js +132 -0
- package/dist/verifier.d.ts +3 -0
- package/dist/verifier.js +7 -0
- package/dist/well-known/index.d.ts +308 -0
- package/dist/well-known/index.js +134 -0
- package/package.json +6 -1
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Proof Record (Archive)
|
|
4
|
+
*
|
|
5
|
+
* Schema for proof records stored in KV/archive for audit trails
|
|
6
|
+
*
|
|
7
|
+
* Related Spec: MCP-I §5
|
|
8
|
+
* Python Reference: Edge-Delegation-Verification.md
|
|
9
|
+
*/
|
|
10
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
+
exports.DEFAULT_PROOF_RECORD_TTL_MS = exports.ProofRecordSchema = exports.VerificationInfoSchema = exports.CrispInfoSchema = exports.LinkageInfoSchema = exports.ProofDetailsSchema = exports.ResponseInfoSchema = exports.RequestInfoSchema = void 0;
|
|
12
|
+
exports.validateProofRecord = validateProofRecord;
|
|
13
|
+
exports.isProofRecordExpired = isProofRecordExpired;
|
|
14
|
+
const zod_1 = require("zod");
|
|
15
|
+
/**
|
|
16
|
+
* Request Info Schema
|
|
17
|
+
*
|
|
18
|
+
* Information about the request that was proven
|
|
19
|
+
*/
|
|
20
|
+
exports.RequestInfoSchema = zod_1.z.object({
|
|
21
|
+
method: zod_1.z.string(),
|
|
22
|
+
url: zod_1.z.string().url(),
|
|
23
|
+
bodyHash: zod_1.z.string().optional(),
|
|
24
|
+
headersHash: zod_1.z.string().optional(),
|
|
25
|
+
});
|
|
26
|
+
/**
|
|
27
|
+
* Response Info Schema
|
|
28
|
+
*
|
|
29
|
+
* Information about the response
|
|
30
|
+
*/
|
|
31
|
+
exports.ResponseInfoSchema = zod_1.z.object({
|
|
32
|
+
status: zod_1.z.number().int(),
|
|
33
|
+
bodyHash: zod_1.z.string().optional(),
|
|
34
|
+
});
|
|
35
|
+
/**
|
|
36
|
+
* Proof Details Schema
|
|
37
|
+
*
|
|
38
|
+
* Core proof information
|
|
39
|
+
*/
|
|
40
|
+
exports.ProofDetailsSchema = zod_1.z.object({
|
|
41
|
+
timestamp: zod_1.z.number().int().positive(),
|
|
42
|
+
nonce: zod_1.z.string().min(1),
|
|
43
|
+
did: zod_1.z.string().min(1),
|
|
44
|
+
signature: zod_1.z.string().regex(/^[A-Za-z0-9_-]+$/),
|
|
45
|
+
algorithm: zod_1.z.enum(['Ed25519', 'ES256']),
|
|
46
|
+
sessionId: zod_1.z.string().min(1),
|
|
47
|
+
audience: zod_1.z.string().min(1),
|
|
48
|
+
request: exports.RequestInfoSchema.optional(),
|
|
49
|
+
response: exports.ResponseInfoSchema.optional(),
|
|
50
|
+
});
|
|
51
|
+
/**
|
|
52
|
+
* Linkage Info Schema
|
|
53
|
+
*
|
|
54
|
+
* Links to delegations and credentials
|
|
55
|
+
*/
|
|
56
|
+
exports.LinkageInfoSchema = zod_1.z.object({
|
|
57
|
+
delegationId: zod_1.z.string().optional(),
|
|
58
|
+
credentialId: zod_1.z.string().optional(),
|
|
59
|
+
chainDepth: zod_1.z.number().int().nonnegative().optional(),
|
|
60
|
+
});
|
|
61
|
+
/**
|
|
62
|
+
* CRISP Info Schema
|
|
63
|
+
*
|
|
64
|
+
* CRISP spending information
|
|
65
|
+
*/
|
|
66
|
+
exports.CrispInfoSchema = zod_1.z.object({
|
|
67
|
+
unit: zod_1.z.enum(['USD', 'ops', 'points']),
|
|
68
|
+
delta: zod_1.z.number().optional(),
|
|
69
|
+
remaining: zod_1.z.number().optional(),
|
|
70
|
+
});
|
|
71
|
+
/**
|
|
72
|
+
* Verification Info Schema
|
|
73
|
+
*
|
|
74
|
+
* Verification result for the proof
|
|
75
|
+
*/
|
|
76
|
+
exports.VerificationInfoSchema = zod_1.z.object({
|
|
77
|
+
result: zod_1.z.enum(['pending', 'pass', 'fail']),
|
|
78
|
+
reason: zod_1.z.string().optional(),
|
|
79
|
+
checkedAt: zod_1.z.number().int().positive().optional(),
|
|
80
|
+
});
|
|
81
|
+
/**
|
|
82
|
+
* Proof Record Schema
|
|
83
|
+
*
|
|
84
|
+
* Complete proof record for archive/KV storage
|
|
85
|
+
*/
|
|
86
|
+
exports.ProofRecordSchema = zod_1.z.object({
|
|
87
|
+
/** Unique identifier for the proof record */
|
|
88
|
+
id: zod_1.z.string().min(1),
|
|
89
|
+
/** Tool/service name that created the proof */
|
|
90
|
+
toolName: zod_1.z.string().min(1),
|
|
91
|
+
/** Timestamp when stored (milliseconds since epoch) */
|
|
92
|
+
storedAt: zod_1.z.number().int().positive(),
|
|
93
|
+
/** Expiration timestamp (milliseconds since epoch) */
|
|
94
|
+
expiresAt: zod_1.z.number().int().positive(),
|
|
95
|
+
/** Core proof details */
|
|
96
|
+
proof: exports.ProofDetailsSchema,
|
|
97
|
+
/** Optional linkage to delegations/credentials */
|
|
98
|
+
linkage: exports.LinkageInfoSchema.optional(),
|
|
99
|
+
/** Optional CRISP spending info */
|
|
100
|
+
crisp: exports.CrispInfoSchema.optional(),
|
|
101
|
+
/** Optional verification info */
|
|
102
|
+
verification: exports.VerificationInfoSchema.optional(),
|
|
103
|
+
/** Optional metadata */
|
|
104
|
+
metadata: zod_1.z.record(zod_1.z.any()).optional(),
|
|
105
|
+
}).passthrough();
|
|
106
|
+
/**
|
|
107
|
+
* Validation Helpers
|
|
108
|
+
*/
|
|
109
|
+
/**
|
|
110
|
+
* Validate a proof record
|
|
111
|
+
*
|
|
112
|
+
* @param record - The record to validate
|
|
113
|
+
* @returns Validation result
|
|
114
|
+
*/
|
|
115
|
+
function validateProofRecord(record) {
|
|
116
|
+
return exports.ProofRecordSchema.safeParse(record);
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Check if proof record is expired
|
|
120
|
+
*
|
|
121
|
+
* @param record - The record to check
|
|
122
|
+
* @returns true if expired
|
|
123
|
+
*/
|
|
124
|
+
function isProofRecordExpired(record) {
|
|
125
|
+
return Date.now() > record.expiresAt;
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Constants
|
|
129
|
+
*/
|
|
130
|
+
/**
|
|
131
|
+
* Default proof record TTL (30 days in milliseconds)
|
|
132
|
+
*/
|
|
133
|
+
exports.DEFAULT_PROOF_RECORD_TTL_MS = 30 * 24 * 60 * 60 * 1000;
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Proof Signing Specification
|
|
3
|
+
*
|
|
4
|
+
* Canonical signing order and detached JWS contracts for proofs
|
|
5
|
+
*
|
|
6
|
+
* Related Spec: MCP-I §5
|
|
7
|
+
* Python Reference: Edge-Delegation-Verification.md
|
|
8
|
+
*/
|
|
9
|
+
import { z } from 'zod';
|
|
10
|
+
/**
|
|
11
|
+
* Canonical Request Parts Schema
|
|
12
|
+
*
|
|
13
|
+
* Parts of a request that are canonically signed
|
|
14
|
+
*/
|
|
15
|
+
export declare const CanonicalRequestPartsSchema: z.ZodObject<{
|
|
16
|
+
/** HTTP method (uppercased) */
|
|
17
|
+
method: z.ZodString;
|
|
18
|
+
/** Absolute URL */
|
|
19
|
+
url: z.ZodString;
|
|
20
|
+
/** Optional body hash (base64url of SHA-256) */
|
|
21
|
+
bodyHash: z.ZodOptional<z.ZodString>;
|
|
22
|
+
/** Optional headers hash (base64url of SHA-256 of allowlisted headers) */
|
|
23
|
+
headersHash: z.ZodOptional<z.ZodString>;
|
|
24
|
+
/** Nonce (base64) */
|
|
25
|
+
nonce: z.ZodString;
|
|
26
|
+
/** Timestamp (milliseconds since epoch) */
|
|
27
|
+
timestamp: z.ZodNumber;
|
|
28
|
+
/** Audience (e.g., 'mcp-client') */
|
|
29
|
+
audience: z.ZodString;
|
|
30
|
+
}, "strip", z.ZodTypeAny, {
|
|
31
|
+
nonce: string;
|
|
32
|
+
audience: string;
|
|
33
|
+
timestamp: number;
|
|
34
|
+
url: string;
|
|
35
|
+
method: string;
|
|
36
|
+
bodyHash?: string | undefined;
|
|
37
|
+
headersHash?: string | undefined;
|
|
38
|
+
}, {
|
|
39
|
+
nonce: string;
|
|
40
|
+
audience: string;
|
|
41
|
+
timestamp: number;
|
|
42
|
+
url: string;
|
|
43
|
+
method: string;
|
|
44
|
+
bodyHash?: string | undefined;
|
|
45
|
+
headersHash?: string | undefined;
|
|
46
|
+
}>;
|
|
47
|
+
export type CanonicalRequestParts = z.infer<typeof CanonicalRequestPartsSchema>;
|
|
48
|
+
/**
|
|
49
|
+
* Detached JWS Schema
|
|
50
|
+
*
|
|
51
|
+
* Detached JSON Web Signature for proofs
|
|
52
|
+
*/
|
|
53
|
+
export declare const DetachedJwsSchema: z.ZodObject<{
|
|
54
|
+
/** Algorithm (Ed25519 or ES256) */
|
|
55
|
+
alg: z.ZodEnum<["Ed25519", "ES256"]>;
|
|
56
|
+
/** Optional key ID (fragment from DID) */
|
|
57
|
+
kid: z.ZodOptional<z.ZodString>;
|
|
58
|
+
/** Base64url-encoded signature */
|
|
59
|
+
signature: z.ZodString;
|
|
60
|
+
}, "strip", z.ZodTypeAny, {
|
|
61
|
+
signature: string;
|
|
62
|
+
alg: "Ed25519" | "ES256";
|
|
63
|
+
kid?: string | undefined;
|
|
64
|
+
}, {
|
|
65
|
+
signature: string;
|
|
66
|
+
alg: "Ed25519" | "ES256";
|
|
67
|
+
kid?: string | undefined;
|
|
68
|
+
}>;
|
|
69
|
+
export type DetachedJws = z.infer<typeof DetachedJwsSchema>;
|
|
70
|
+
/**
|
|
71
|
+
* Signing Order
|
|
72
|
+
*
|
|
73
|
+
* **CRITICAL**: This order MUST be used for canonical string generation.
|
|
74
|
+
* Changing this order breaks signature verification.
|
|
75
|
+
*/
|
|
76
|
+
export declare const SIGNING_ORDER: readonly ["method", "url", "bodyHash", "headersHash", "nonce", "timestamp", "audience"];
|
|
77
|
+
/**
|
|
78
|
+
* Type for signing order fields
|
|
79
|
+
*/
|
|
80
|
+
export type SigningOrderField = (typeof SIGNING_ORDER)[number];
|
|
81
|
+
/**
|
|
82
|
+
* Validation Helpers
|
|
83
|
+
*/
|
|
84
|
+
/**
|
|
85
|
+
* Validate canonical request parts
|
|
86
|
+
*
|
|
87
|
+
* @param parts - The parts to validate
|
|
88
|
+
* @returns Validation result
|
|
89
|
+
*/
|
|
90
|
+
export declare function validateCanonicalRequestParts(parts: unknown): z.SafeParseReturnType<{
|
|
91
|
+
nonce: string;
|
|
92
|
+
audience: string;
|
|
93
|
+
timestamp: number;
|
|
94
|
+
url: string;
|
|
95
|
+
method: string;
|
|
96
|
+
bodyHash?: string | undefined;
|
|
97
|
+
headersHash?: string | undefined;
|
|
98
|
+
}, {
|
|
99
|
+
nonce: string;
|
|
100
|
+
audience: string;
|
|
101
|
+
timestamp: number;
|
|
102
|
+
url: string;
|
|
103
|
+
method: string;
|
|
104
|
+
bodyHash?: string | undefined;
|
|
105
|
+
headersHash?: string | undefined;
|
|
106
|
+
}>;
|
|
107
|
+
/**
|
|
108
|
+
* Validate detached JWS
|
|
109
|
+
*
|
|
110
|
+
* @param jws - The JWS to validate
|
|
111
|
+
* @returns Validation result
|
|
112
|
+
*/
|
|
113
|
+
export declare function validateDetachedJws(jws: unknown): z.SafeParseReturnType<{
|
|
114
|
+
signature: string;
|
|
115
|
+
alg: "Ed25519" | "ES256";
|
|
116
|
+
kid?: string | undefined;
|
|
117
|
+
}, {
|
|
118
|
+
signature: string;
|
|
119
|
+
alg: "Ed25519" | "ES256";
|
|
120
|
+
kid?: string | undefined;
|
|
121
|
+
}>;
|
|
122
|
+
/**
|
|
123
|
+
* Generate canonical signing string from parts
|
|
124
|
+
*
|
|
125
|
+
* **NOTE**: This is a type-level spec. Actual implementation
|
|
126
|
+
* requires runtime string concatenation.
|
|
127
|
+
*
|
|
128
|
+
* @param parts - Canonical request parts
|
|
129
|
+
* @returns Canonical string for signing
|
|
130
|
+
*/
|
|
131
|
+
export declare function getCanonicalSigningString(parts: CanonicalRequestParts): string;
|
|
132
|
+
/**
|
|
133
|
+
* Constants
|
|
134
|
+
*/
|
|
135
|
+
/**
|
|
136
|
+
* Supported signing algorithms
|
|
137
|
+
*/
|
|
138
|
+
export declare const SUPPORTED_SIGNING_ALGORITHMS: readonly ["Ed25519", "ES256"];
|
|
139
|
+
/**
|
|
140
|
+
* Hash algorithm for body/headers
|
|
141
|
+
*/
|
|
142
|
+
export declare const SIGNING_HASH_ALGORITHM = "SHA-256";
|
|
143
|
+
/**
|
|
144
|
+
* Base64url pattern for validation
|
|
145
|
+
*/
|
|
146
|
+
export declare const BASE64URL_PATTERN: RegExp;
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Proof Signing Specification
|
|
4
|
+
*
|
|
5
|
+
* Canonical signing order and detached JWS contracts for proofs
|
|
6
|
+
*
|
|
7
|
+
* Related Spec: MCP-I §5
|
|
8
|
+
* Python Reference: Edge-Delegation-Verification.md
|
|
9
|
+
*/
|
|
10
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
+
exports.BASE64URL_PATTERN = exports.SIGNING_HASH_ALGORITHM = exports.SUPPORTED_SIGNING_ALGORITHMS = exports.SIGNING_ORDER = exports.DetachedJwsSchema = exports.CanonicalRequestPartsSchema = void 0;
|
|
12
|
+
exports.validateCanonicalRequestParts = validateCanonicalRequestParts;
|
|
13
|
+
exports.validateDetachedJws = validateDetachedJws;
|
|
14
|
+
exports.getCanonicalSigningString = getCanonicalSigningString;
|
|
15
|
+
const zod_1 = require("zod");
|
|
16
|
+
/**
|
|
17
|
+
* Canonical Request Parts Schema
|
|
18
|
+
*
|
|
19
|
+
* Parts of a request that are canonically signed
|
|
20
|
+
*/
|
|
21
|
+
exports.CanonicalRequestPartsSchema = zod_1.z.object({
|
|
22
|
+
/** HTTP method (uppercased) */
|
|
23
|
+
method: zod_1.z.string().toUpperCase(),
|
|
24
|
+
/** Absolute URL */
|
|
25
|
+
url: zod_1.z.string().url(),
|
|
26
|
+
/** Optional body hash (base64url of SHA-256) */
|
|
27
|
+
bodyHash: zod_1.z.string().regex(/^[A-Za-z0-9_-]+$/).optional(),
|
|
28
|
+
/** Optional headers hash (base64url of SHA-256 of allowlisted headers) */
|
|
29
|
+
headersHash: zod_1.z.string().regex(/^[A-Za-z0-9_-]+$/).optional(),
|
|
30
|
+
/** Nonce (base64) */
|
|
31
|
+
nonce: zod_1.z.string().min(1),
|
|
32
|
+
/** Timestamp (milliseconds since epoch) */
|
|
33
|
+
timestamp: zod_1.z.number().int().positive(),
|
|
34
|
+
/** Audience (e.g., 'mcp-client') */
|
|
35
|
+
audience: zod_1.z.string().min(1),
|
|
36
|
+
});
|
|
37
|
+
/**
|
|
38
|
+
* Detached JWS Schema
|
|
39
|
+
*
|
|
40
|
+
* Detached JSON Web Signature for proofs
|
|
41
|
+
*/
|
|
42
|
+
exports.DetachedJwsSchema = zod_1.z.object({
|
|
43
|
+
/** Algorithm (Ed25519 or ES256) */
|
|
44
|
+
alg: zod_1.z.enum(['Ed25519', 'ES256']),
|
|
45
|
+
/** Optional key ID (fragment from DID) */
|
|
46
|
+
kid: zod_1.z.string().optional(),
|
|
47
|
+
/** Base64url-encoded signature */
|
|
48
|
+
signature: zod_1.z.string().regex(/^[A-Za-z0-9_-]+$/),
|
|
49
|
+
});
|
|
50
|
+
/**
|
|
51
|
+
* Signing Order
|
|
52
|
+
*
|
|
53
|
+
* **CRITICAL**: This order MUST be used for canonical string generation.
|
|
54
|
+
* Changing this order breaks signature verification.
|
|
55
|
+
*/
|
|
56
|
+
exports.SIGNING_ORDER = Object.freeze([
|
|
57
|
+
'method',
|
|
58
|
+
'url',
|
|
59
|
+
'bodyHash',
|
|
60
|
+
'headersHash',
|
|
61
|
+
'nonce',
|
|
62
|
+
'timestamp',
|
|
63
|
+
'audience',
|
|
64
|
+
]);
|
|
65
|
+
/**
|
|
66
|
+
* Validation Helpers
|
|
67
|
+
*/
|
|
68
|
+
/**
|
|
69
|
+
* Validate canonical request parts
|
|
70
|
+
*
|
|
71
|
+
* @param parts - The parts to validate
|
|
72
|
+
* @returns Validation result
|
|
73
|
+
*/
|
|
74
|
+
function validateCanonicalRequestParts(parts) {
|
|
75
|
+
return exports.CanonicalRequestPartsSchema.safeParse(parts);
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Validate detached JWS
|
|
79
|
+
*
|
|
80
|
+
* @param jws - The JWS to validate
|
|
81
|
+
* @returns Validation result
|
|
82
|
+
*/
|
|
83
|
+
function validateDetachedJws(jws) {
|
|
84
|
+
return exports.DetachedJwsSchema.safeParse(jws);
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Generate canonical signing string from parts
|
|
88
|
+
*
|
|
89
|
+
* **NOTE**: This is a type-level spec. Actual implementation
|
|
90
|
+
* requires runtime string concatenation.
|
|
91
|
+
*
|
|
92
|
+
* @param parts - Canonical request parts
|
|
93
|
+
* @returns Canonical string for signing
|
|
94
|
+
*/
|
|
95
|
+
function getCanonicalSigningString(parts) {
|
|
96
|
+
const values = [];
|
|
97
|
+
for (const field of exports.SIGNING_ORDER) {
|
|
98
|
+
const value = parts[field];
|
|
99
|
+
if (value !== undefined) {
|
|
100
|
+
values.push(String(value));
|
|
101
|
+
}
|
|
102
|
+
else {
|
|
103
|
+
values.push('');
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
return values.join('\n');
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Constants
|
|
110
|
+
*/
|
|
111
|
+
/**
|
|
112
|
+
* Supported signing algorithms
|
|
113
|
+
*/
|
|
114
|
+
exports.SUPPORTED_SIGNING_ALGORITHMS = ['Ed25519', 'ES256'];
|
|
115
|
+
/**
|
|
116
|
+
* Hash algorithm for body/headers
|
|
117
|
+
*/
|
|
118
|
+
exports.SIGNING_HASH_ALGORITHM = 'SHA-256';
|
|
119
|
+
/**
|
|
120
|
+
* Base64url pattern for validation
|
|
121
|
+
*/
|
|
122
|
+
exports.BASE64URL_PATTERN = /^[A-Za-z0-9_-]+$/;
|
package/dist/proof.d.ts
CHANGED
|
@@ -1,4 +1,14 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
+
/**
|
|
3
|
+
* Proof and signature schemas for MCP-I
|
|
4
|
+
*
|
|
5
|
+
* Note: The type name "DetachedProof" is maintained for backward compatibility,
|
|
6
|
+
* but the JWS format is actually FULL compact JWS (header.payload.signature),
|
|
7
|
+
* not detached format (header..signature).
|
|
8
|
+
*
|
|
9
|
+
* The JWS payload contains JWT standard claims (aud, sub, iss) plus custom
|
|
10
|
+
* proof claims (requestHash, responseHash, nonce, etc.).
|
|
11
|
+
*/
|
|
2
12
|
export declare const ProofMetaSchema: z.ZodObject<{
|
|
3
13
|
did: z.ZodString;
|
|
4
14
|
kid: z.ZodString;
|
|
@@ -10,28 +20,31 @@ export declare const ProofMetaSchema: z.ZodObject<{
|
|
|
10
20
|
responseHash: z.ZodString;
|
|
11
21
|
scopeId: z.ZodOptional<z.ZodString>;
|
|
12
22
|
delegationRef: z.ZodOptional<z.ZodString>;
|
|
23
|
+
clientDid: z.ZodOptional<z.ZodString>;
|
|
13
24
|
}, "strip", z.ZodTypeAny, {
|
|
14
25
|
did: string;
|
|
15
26
|
kid: string;
|
|
27
|
+
ts: number;
|
|
16
28
|
nonce: string;
|
|
17
29
|
audience: string;
|
|
18
30
|
sessionId: string;
|
|
19
|
-
ts: number;
|
|
20
31
|
requestHash: string;
|
|
21
32
|
responseHash: string;
|
|
22
33
|
scopeId?: string | undefined;
|
|
23
34
|
delegationRef?: string | undefined;
|
|
35
|
+
clientDid?: string | undefined;
|
|
24
36
|
}, {
|
|
25
37
|
did: string;
|
|
26
38
|
kid: string;
|
|
39
|
+
ts: number;
|
|
27
40
|
nonce: string;
|
|
28
41
|
audience: string;
|
|
29
42
|
sessionId: string;
|
|
30
|
-
ts: number;
|
|
31
43
|
requestHash: string;
|
|
32
44
|
responseHash: string;
|
|
33
45
|
scopeId?: string | undefined;
|
|
34
46
|
delegationRef?: string | undefined;
|
|
47
|
+
clientDid?: string | undefined;
|
|
35
48
|
}>;
|
|
36
49
|
export declare const DetachedProofSchema: z.ZodObject<{
|
|
37
50
|
jws: z.ZodString;
|
|
@@ -46,56 +59,61 @@ export declare const DetachedProofSchema: z.ZodObject<{
|
|
|
46
59
|
responseHash: z.ZodString;
|
|
47
60
|
scopeId: z.ZodOptional<z.ZodString>;
|
|
48
61
|
delegationRef: z.ZodOptional<z.ZodString>;
|
|
62
|
+
clientDid: z.ZodOptional<z.ZodString>;
|
|
49
63
|
}, "strip", z.ZodTypeAny, {
|
|
50
64
|
did: string;
|
|
51
65
|
kid: string;
|
|
66
|
+
ts: number;
|
|
52
67
|
nonce: string;
|
|
53
68
|
audience: string;
|
|
54
69
|
sessionId: string;
|
|
55
|
-
ts: number;
|
|
56
70
|
requestHash: string;
|
|
57
71
|
responseHash: string;
|
|
58
72
|
scopeId?: string | undefined;
|
|
59
73
|
delegationRef?: string | undefined;
|
|
74
|
+
clientDid?: string | undefined;
|
|
60
75
|
}, {
|
|
61
76
|
did: string;
|
|
62
77
|
kid: string;
|
|
78
|
+
ts: number;
|
|
63
79
|
nonce: string;
|
|
64
80
|
audience: string;
|
|
65
81
|
sessionId: string;
|
|
66
|
-
ts: number;
|
|
67
82
|
requestHash: string;
|
|
68
83
|
responseHash: string;
|
|
69
84
|
scopeId?: string | undefined;
|
|
70
85
|
delegationRef?: string | undefined;
|
|
86
|
+
clientDid?: string | undefined;
|
|
71
87
|
}>;
|
|
72
88
|
}, "strip", z.ZodTypeAny, {
|
|
73
89
|
jws: string;
|
|
74
90
|
meta: {
|
|
75
91
|
did: string;
|
|
76
92
|
kid: string;
|
|
93
|
+
ts: number;
|
|
77
94
|
nonce: string;
|
|
78
95
|
audience: string;
|
|
79
96
|
sessionId: string;
|
|
80
|
-
ts: number;
|
|
81
97
|
requestHash: string;
|
|
82
98
|
responseHash: string;
|
|
83
99
|
scopeId?: string | undefined;
|
|
84
100
|
delegationRef?: string | undefined;
|
|
101
|
+
clientDid?: string | undefined;
|
|
85
102
|
};
|
|
86
103
|
}, {
|
|
87
104
|
jws: string;
|
|
88
105
|
meta: {
|
|
89
106
|
did: string;
|
|
90
107
|
kid: string;
|
|
108
|
+
ts: number;
|
|
91
109
|
nonce: string;
|
|
92
110
|
audience: string;
|
|
93
111
|
sessionId: string;
|
|
94
|
-
ts: number;
|
|
95
112
|
requestHash: string;
|
|
96
113
|
responseHash: string;
|
|
97
114
|
scopeId?: string | undefined;
|
|
98
115
|
delegationRef?: string | undefined;
|
|
116
|
+
clientDid?: string | undefined;
|
|
99
117
|
};
|
|
100
118
|
}>;
|
|
101
119
|
export declare const CanonicalHashesSchema: z.ZodObject<{
|
|
@@ -120,22 +138,22 @@ export declare const AuditRecordSchema: z.ZodObject<{
|
|
|
120
138
|
verified: z.ZodEnum<["yes", "no"]>;
|
|
121
139
|
scope: z.ZodString;
|
|
122
140
|
}, "strip", z.ZodTypeAny, {
|
|
123
|
-
version: "audit.v1";
|
|
124
141
|
did: string;
|
|
125
142
|
kid: string;
|
|
126
|
-
audience: string;
|
|
127
143
|
ts: number;
|
|
144
|
+
audience: string;
|
|
145
|
+
version: "audit.v1";
|
|
128
146
|
session: string;
|
|
129
147
|
reqHash: string;
|
|
130
148
|
resHash: string;
|
|
131
149
|
verified: "yes" | "no";
|
|
132
150
|
scope: string;
|
|
133
151
|
}, {
|
|
134
|
-
version: "audit.v1";
|
|
135
152
|
did: string;
|
|
136
153
|
kid: string;
|
|
137
|
-
audience: string;
|
|
138
154
|
ts: number;
|
|
155
|
+
audience: string;
|
|
156
|
+
version: "audit.v1";
|
|
139
157
|
session: string;
|
|
140
158
|
reqHash: string;
|
|
141
159
|
resHash: string;
|
|
@@ -149,6 +167,10 @@ export type AuditRecord = z.infer<typeof AuditRecordSchema>;
|
|
|
149
167
|
export declare const JWS_ALGORITHM = "EdDSA";
|
|
150
168
|
export declare const HASH_ALGORITHM = "sha256";
|
|
151
169
|
export declare const AUDIT_VERSION = "audit.v1";
|
|
170
|
+
/**
|
|
171
|
+
* Tool call context for AgentShield dashboard integration
|
|
172
|
+
* Provides plaintext tool execution data alongside cryptographic proofs
|
|
173
|
+
*/
|
|
152
174
|
export declare const ToolCallContextSchema: z.ZodObject<{
|
|
153
175
|
tool: z.ZodString;
|
|
154
176
|
args: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
@@ -168,6 +190,10 @@ export declare const ToolCallContextSchema: z.ZodObject<{
|
|
|
168
190
|
result?: unknown;
|
|
169
191
|
userId?: string | undefined;
|
|
170
192
|
}>;
|
|
193
|
+
/**
|
|
194
|
+
* Proof submission context for AgentShield API
|
|
195
|
+
* Includes tool calls and optional MCP server URL for tool discovery
|
|
196
|
+
*/
|
|
171
197
|
export declare const ProofSubmissionContextSchema: z.ZodObject<{
|
|
172
198
|
toolCalls: z.ZodArray<z.ZodObject<{
|
|
173
199
|
tool: z.ZodString;
|
|
@@ -208,6 +234,9 @@ export declare const ProofSubmissionContextSchema: z.ZodObject<{
|
|
|
208
234
|
}[];
|
|
209
235
|
mcpServerUrl?: string | undefined;
|
|
210
236
|
}>;
|
|
237
|
+
/**
|
|
238
|
+
* Complete proof submission request to AgentShield
|
|
239
|
+
*/
|
|
211
240
|
export declare const ProofSubmissionRequestSchema: z.ZodObject<{
|
|
212
241
|
session_id: z.ZodString;
|
|
213
242
|
delegation_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
@@ -224,56 +253,61 @@ export declare const ProofSubmissionRequestSchema: z.ZodObject<{
|
|
|
224
253
|
responseHash: z.ZodString;
|
|
225
254
|
scopeId: z.ZodOptional<z.ZodString>;
|
|
226
255
|
delegationRef: z.ZodOptional<z.ZodString>;
|
|
256
|
+
clientDid: z.ZodOptional<z.ZodString>;
|
|
227
257
|
}, "strip", z.ZodTypeAny, {
|
|
228
258
|
did: string;
|
|
229
259
|
kid: string;
|
|
260
|
+
ts: number;
|
|
230
261
|
nonce: string;
|
|
231
262
|
audience: string;
|
|
232
263
|
sessionId: string;
|
|
233
|
-
ts: number;
|
|
234
264
|
requestHash: string;
|
|
235
265
|
responseHash: string;
|
|
236
266
|
scopeId?: string | undefined;
|
|
237
267
|
delegationRef?: string | undefined;
|
|
268
|
+
clientDid?: string | undefined;
|
|
238
269
|
}, {
|
|
239
270
|
did: string;
|
|
240
271
|
kid: string;
|
|
272
|
+
ts: number;
|
|
241
273
|
nonce: string;
|
|
242
274
|
audience: string;
|
|
243
275
|
sessionId: string;
|
|
244
|
-
ts: number;
|
|
245
276
|
requestHash: string;
|
|
246
277
|
responseHash: string;
|
|
247
278
|
scopeId?: string | undefined;
|
|
248
279
|
delegationRef?: string | undefined;
|
|
280
|
+
clientDid?: string | undefined;
|
|
249
281
|
}>;
|
|
250
282
|
}, "strip", z.ZodTypeAny, {
|
|
251
283
|
jws: string;
|
|
252
284
|
meta: {
|
|
253
285
|
did: string;
|
|
254
286
|
kid: string;
|
|
287
|
+
ts: number;
|
|
255
288
|
nonce: string;
|
|
256
289
|
audience: string;
|
|
257
290
|
sessionId: string;
|
|
258
|
-
ts: number;
|
|
259
291
|
requestHash: string;
|
|
260
292
|
responseHash: string;
|
|
261
293
|
scopeId?: string | undefined;
|
|
262
294
|
delegationRef?: string | undefined;
|
|
295
|
+
clientDid?: string | undefined;
|
|
263
296
|
};
|
|
264
297
|
}, {
|
|
265
298
|
jws: string;
|
|
266
299
|
meta: {
|
|
267
300
|
did: string;
|
|
268
301
|
kid: string;
|
|
302
|
+
ts: number;
|
|
269
303
|
nonce: string;
|
|
270
304
|
audience: string;
|
|
271
305
|
sessionId: string;
|
|
272
|
-
ts: number;
|
|
273
306
|
requestHash: string;
|
|
274
307
|
responseHash: string;
|
|
275
308
|
scopeId?: string | undefined;
|
|
276
309
|
delegationRef?: string | undefined;
|
|
310
|
+
clientDid?: string | undefined;
|
|
277
311
|
};
|
|
278
312
|
}>, "many">;
|
|
279
313
|
context: z.ZodOptional<z.ZodObject<{
|
|
@@ -323,14 +357,15 @@ export declare const ProofSubmissionRequestSchema: z.ZodObject<{
|
|
|
323
357
|
meta: {
|
|
324
358
|
did: string;
|
|
325
359
|
kid: string;
|
|
360
|
+
ts: number;
|
|
326
361
|
nonce: string;
|
|
327
362
|
audience: string;
|
|
328
363
|
sessionId: string;
|
|
329
|
-
ts: number;
|
|
330
364
|
requestHash: string;
|
|
331
365
|
responseHash: string;
|
|
332
366
|
scopeId?: string | undefined;
|
|
333
367
|
delegationRef?: string | undefined;
|
|
368
|
+
clientDid?: string | undefined;
|
|
334
369
|
};
|
|
335
370
|
}[];
|
|
336
371
|
delegation_id?: string | null | undefined;
|
|
@@ -351,14 +386,15 @@ export declare const ProofSubmissionRequestSchema: z.ZodObject<{
|
|
|
351
386
|
meta: {
|
|
352
387
|
did: string;
|
|
353
388
|
kid: string;
|
|
389
|
+
ts: number;
|
|
354
390
|
nonce: string;
|
|
355
391
|
audience: string;
|
|
356
392
|
sessionId: string;
|
|
357
|
-
ts: number;
|
|
358
393
|
requestHash: string;
|
|
359
394
|
responseHash: string;
|
|
360
395
|
scopeId?: string | undefined;
|
|
361
396
|
delegationRef?: string | undefined;
|
|
397
|
+
clientDid?: string | undefined;
|
|
362
398
|
};
|
|
363
399
|
}[];
|
|
364
400
|
delegation_id?: string | null | undefined;
|
|
@@ -376,3 +412,4 @@ export declare const ProofSubmissionRequestSchema: z.ZodObject<{
|
|
|
376
412
|
export type ToolCallContext = z.infer<typeof ToolCallContextSchema>;
|
|
377
413
|
export type ProofSubmissionContext = z.infer<typeof ProofSubmissionContextSchema>;
|
|
378
414
|
export type ProofSubmissionRequest = z.infer<typeof ProofSubmissionRequestSchema>;
|
|
415
|
+
//# sourceMappingURL=proof.d.ts.map
|