@kya-os/contracts 1.3.4 → 1.3.5
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/cli.d.ts +375 -0
- package/dist/cli.js +109 -0
- package/dist/handshake.d.ts +138 -0
- package/dist/handshake.js +50 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +28 -0
- package/dist/proof.d.ts +378 -0
- package/dist/proof.js +59 -0
- package/dist/registry.d.ts +326 -0
- package/dist/registry.js +98 -0
- package/dist/test.d.ts +215 -0
- package/dist/test.js +83 -0
- package/dist/utils/validation.d.ts +14 -0
- package/dist/utils/validation.js +56 -0
- package/dist/verifier.d.ts +202 -0
- package/dist/verifier.js +76 -0
- package/package.json +1 -1
package/dist/test.js
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TEST_ERROR_CODES = exports.TEST_KEY_IDS = exports.TEST_DIDS = exports.LocalVerificationResultSchema = exports.MockIdentityProviderConfigSchema = exports.MockKTAFailureTypeSchema = exports.MockDelegationStatusSchema = exports.MockIdentitySchema = exports.TestEnvironmentSchema = void 0;
|
|
4
|
+
exports.isTestEnvironment = isTestEnvironment;
|
|
5
|
+
exports.getTestSeed = getTestSeed;
|
|
6
|
+
const zod_1 = require("zod");
|
|
7
|
+
exports.TestEnvironmentSchema = zod_1.z.object({
|
|
8
|
+
mode: zod_1.z.literal("test"),
|
|
9
|
+
seed: zod_1.z.string().optional(),
|
|
10
|
+
deterministicKeys: zod_1.z.boolean().default(true),
|
|
11
|
+
skipKTACalls: zod_1.z.boolean().default(true),
|
|
12
|
+
});
|
|
13
|
+
exports.MockIdentitySchema = zod_1.z.object({
|
|
14
|
+
did: zod_1.z.string(),
|
|
15
|
+
kid: zod_1.z.string(),
|
|
16
|
+
privateKey: zod_1.z.string().regex(/^[A-Za-z0-9+/]{43}=$/, "Must be a valid base64-encoded Ed25519 private key (44 characters)"),
|
|
17
|
+
publicKey: zod_1.z.string().regex(/^[A-Za-z0-9+/]{43}=$/, "Must be a valid base64-encoded Ed25519 public key (44 characters)"),
|
|
18
|
+
createdAt: zod_1.z.string(),
|
|
19
|
+
lastRotated: zod_1.z.string().optional(),
|
|
20
|
+
});
|
|
21
|
+
exports.MockDelegationStatusSchema = zod_1.z.enum([
|
|
22
|
+
"active",
|
|
23
|
+
"revoked",
|
|
24
|
+
"pending",
|
|
25
|
+
]);
|
|
26
|
+
exports.MockKTAFailureTypeSchema = zod_1.z.enum([
|
|
27
|
+
"network",
|
|
28
|
+
"auth",
|
|
29
|
+
"invalid",
|
|
30
|
+
"timeout",
|
|
31
|
+
]);
|
|
32
|
+
exports.MockIdentityProviderConfigSchema = zod_1.z.object({
|
|
33
|
+
identities: zod_1.z.record(zod_1.z.string(), exports.MockIdentitySchema),
|
|
34
|
+
delegations: zod_1.z.record(zod_1.z.string(), exports.MockDelegationStatusSchema),
|
|
35
|
+
ktaFailures: zod_1.z.array(exports.MockKTAFailureTypeSchema).default([]),
|
|
36
|
+
deterministicSeed: zod_1.z.string().optional(),
|
|
37
|
+
});
|
|
38
|
+
exports.LocalVerificationResultSchema = zod_1.z.object({
|
|
39
|
+
valid: zod_1.z.boolean(),
|
|
40
|
+
did: zod_1.z.string().optional(),
|
|
41
|
+
kid: zod_1.z.string().optional(),
|
|
42
|
+
signature: zod_1.z.object({
|
|
43
|
+
valid: zod_1.z.boolean(),
|
|
44
|
+
algorithm: zod_1.z.string(),
|
|
45
|
+
error: zod_1.z.string().optional(),
|
|
46
|
+
}),
|
|
47
|
+
proof: zod_1.z.object({
|
|
48
|
+
valid: zod_1.z.boolean(),
|
|
49
|
+
structure: zod_1.z.boolean(),
|
|
50
|
+
timestamps: zod_1.z.boolean(),
|
|
51
|
+
hashes: zod_1.z.boolean(),
|
|
52
|
+
error: zod_1.z.string().optional(),
|
|
53
|
+
}),
|
|
54
|
+
session: zod_1.z.object({
|
|
55
|
+
valid: zod_1.z.boolean(),
|
|
56
|
+
expired: zod_1.z.boolean(),
|
|
57
|
+
error: zod_1.z.string().optional(),
|
|
58
|
+
}),
|
|
59
|
+
errors: zod_1.z.array(zod_1.z.string()).default([]),
|
|
60
|
+
warnings: zod_1.z.array(zod_1.z.string()).default([]),
|
|
61
|
+
});
|
|
62
|
+
exports.TEST_DIDS = {
|
|
63
|
+
AGENT_1: "did:test:agent-1",
|
|
64
|
+
AGENT_2: "did:test:agent-2",
|
|
65
|
+
VERIFIER_1: "did:test:verifier-1",
|
|
66
|
+
};
|
|
67
|
+
exports.TEST_KEY_IDS = {
|
|
68
|
+
KEY_TEST_1: "key-test-1",
|
|
69
|
+
KEY_TEST_2: "key-test-2",
|
|
70
|
+
KEY_VERIFIER_1: "key-verifier-1",
|
|
71
|
+
};
|
|
72
|
+
function isTestEnvironment() {
|
|
73
|
+
return process.env.XMCP_ENV === "test";
|
|
74
|
+
}
|
|
75
|
+
function getTestSeed(testName) {
|
|
76
|
+
return process.env.XMCP_TEST_SEED || testName || "default-test-seed";
|
|
77
|
+
}
|
|
78
|
+
exports.TEST_ERROR_CODES = {
|
|
79
|
+
MOCK_KTA_FAILURE: "XMCP_I_TEST_MOCK_KTA_FAILURE",
|
|
80
|
+
DETERMINISTIC_KEY_GENERATION_FAILED: "XMCP_I_TEST_DETERMINISTIC_KEY_FAILED",
|
|
81
|
+
LOCAL_VERIFICATION_FAILED: "XMCP_I_TEST_LOCAL_VERIFICATION_FAILED",
|
|
82
|
+
INVALID_TEST_CONFIGURATION: "XMCP_I_TEST_INVALID_CONFIG",
|
|
83
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export interface ValidationResult<T = any> {
|
|
3
|
+
valid: boolean;
|
|
4
|
+
data?: T;
|
|
5
|
+
errors: string[];
|
|
6
|
+
}
|
|
7
|
+
export declare function validateInput<T>(schema: z.ZodSchema<T>, data: unknown, context?: string): ValidationResult<T>;
|
|
8
|
+
export declare function hasRequiredProperties(obj: any, properties: string[], context?: string): ValidationResult;
|
|
9
|
+
export declare const StringValidators: {
|
|
10
|
+
did: (value: string) => boolean;
|
|
11
|
+
kid: (value: string) => boolean;
|
|
12
|
+
url: (value: string) => boolean;
|
|
13
|
+
projectName: (value: string) => boolean;
|
|
14
|
+
};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.StringValidators = void 0;
|
|
4
|
+
exports.validateInput = validateInput;
|
|
5
|
+
exports.hasRequiredProperties = hasRequiredProperties;
|
|
6
|
+
function validateInput(schema, data, context) {
|
|
7
|
+
const result = schema.safeParse(data);
|
|
8
|
+
if (result.success) {
|
|
9
|
+
return {
|
|
10
|
+
valid: true,
|
|
11
|
+
data: result.data,
|
|
12
|
+
errors: [],
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
const errors = result.error.errors.map((err) => {
|
|
16
|
+
const path = err.path.length > 0 ? ` at ${err.path.join(".")}` : "";
|
|
17
|
+
const contextStr = context ? ` (${context})` : "";
|
|
18
|
+
return `${err.message}${path}${contextStr}`;
|
|
19
|
+
});
|
|
20
|
+
return {
|
|
21
|
+
valid: false,
|
|
22
|
+
errors,
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
function hasRequiredProperties(obj, properties, context) {
|
|
26
|
+
if (typeof obj !== "object" || obj === null) {
|
|
27
|
+
return {
|
|
28
|
+
valid: false,
|
|
29
|
+
errors: [`Expected object${context ? ` for ${context}` : ""}`],
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
const missing = properties.filter((prop) => !(prop in obj));
|
|
33
|
+
if (missing.length > 0) {
|
|
34
|
+
return {
|
|
35
|
+
valid: false,
|
|
36
|
+
errors: [
|
|
37
|
+
`Missing required properties: ${missing.join(", ")}${context ? ` in ${context}` : ""}`,
|
|
38
|
+
],
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
return { valid: true, errors: [] };
|
|
42
|
+
}
|
|
43
|
+
exports.StringValidators = {
|
|
44
|
+
did: (value) => /^did:[a-z0-9]+:[a-zA-Z0-9._-]+$/.test(value),
|
|
45
|
+
kid: (value) => /^[a-zA-Z0-9._-]+$/.test(value),
|
|
46
|
+
url: (value) => {
|
|
47
|
+
try {
|
|
48
|
+
new URL(value);
|
|
49
|
+
return true;
|
|
50
|
+
}
|
|
51
|
+
catch {
|
|
52
|
+
return false;
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
projectName: (value) => /^[a-z0-9-]+$/.test(value) && value.length >= 1 && value.length <= 214,
|
|
56
|
+
};
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const AgentContextSchema: z.ZodObject<{
|
|
3
|
+
did: z.ZodString;
|
|
4
|
+
kid: z.ZodString;
|
|
5
|
+
subject: z.ZodOptional<z.ZodString>;
|
|
6
|
+
scopes: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
|
|
7
|
+
session: z.ZodString;
|
|
8
|
+
confidence: z.ZodLiteral<"verified">;
|
|
9
|
+
delegationRef: z.ZodOptional<z.ZodString>;
|
|
10
|
+
registry: z.ZodString;
|
|
11
|
+
verifiedAt: z.ZodNumber;
|
|
12
|
+
}, "strip", z.ZodTypeAny, {
|
|
13
|
+
did: string;
|
|
14
|
+
kid: string;
|
|
15
|
+
session: string;
|
|
16
|
+
scopes: string[];
|
|
17
|
+
confidence: "verified";
|
|
18
|
+
registry: string;
|
|
19
|
+
verifiedAt: number;
|
|
20
|
+
delegationRef?: string | undefined;
|
|
21
|
+
subject?: string | undefined;
|
|
22
|
+
}, {
|
|
23
|
+
did: string;
|
|
24
|
+
kid: string;
|
|
25
|
+
session: string;
|
|
26
|
+
confidence: "verified";
|
|
27
|
+
registry: string;
|
|
28
|
+
verifiedAt: number;
|
|
29
|
+
delegationRef?: string | undefined;
|
|
30
|
+
subject?: string | undefined;
|
|
31
|
+
scopes?: string[] | undefined;
|
|
32
|
+
}>;
|
|
33
|
+
export declare const VerifierResultSchema: z.ZodObject<{
|
|
34
|
+
success: z.ZodBoolean;
|
|
35
|
+
headers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
36
|
+
agentContext: z.ZodOptional<z.ZodObject<{
|
|
37
|
+
did: z.ZodString;
|
|
38
|
+
kid: z.ZodString;
|
|
39
|
+
subject: z.ZodOptional<z.ZodString>;
|
|
40
|
+
scopes: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
|
|
41
|
+
session: z.ZodString;
|
|
42
|
+
confidence: z.ZodLiteral<"verified">;
|
|
43
|
+
delegationRef: z.ZodOptional<z.ZodString>;
|
|
44
|
+
registry: z.ZodString;
|
|
45
|
+
verifiedAt: z.ZodNumber;
|
|
46
|
+
}, "strip", z.ZodTypeAny, {
|
|
47
|
+
did: string;
|
|
48
|
+
kid: string;
|
|
49
|
+
session: string;
|
|
50
|
+
scopes: string[];
|
|
51
|
+
confidence: "verified";
|
|
52
|
+
registry: string;
|
|
53
|
+
verifiedAt: number;
|
|
54
|
+
delegationRef?: string | undefined;
|
|
55
|
+
subject?: string | undefined;
|
|
56
|
+
}, {
|
|
57
|
+
did: string;
|
|
58
|
+
kid: string;
|
|
59
|
+
session: string;
|
|
60
|
+
confidence: "verified";
|
|
61
|
+
registry: string;
|
|
62
|
+
verifiedAt: number;
|
|
63
|
+
delegationRef?: string | undefined;
|
|
64
|
+
subject?: string | undefined;
|
|
65
|
+
scopes?: string[] | undefined;
|
|
66
|
+
}>>;
|
|
67
|
+
error: z.ZodOptional<z.ZodObject<{
|
|
68
|
+
code: z.ZodString;
|
|
69
|
+
message: z.ZodString;
|
|
70
|
+
details: z.ZodOptional<z.ZodAny>;
|
|
71
|
+
httpStatus: z.ZodNumber;
|
|
72
|
+
}, "strip", z.ZodTypeAny, {
|
|
73
|
+
code: string;
|
|
74
|
+
message: string;
|
|
75
|
+
httpStatus: number;
|
|
76
|
+
details?: any;
|
|
77
|
+
}, {
|
|
78
|
+
code: string;
|
|
79
|
+
message: string;
|
|
80
|
+
httpStatus: number;
|
|
81
|
+
details?: any;
|
|
82
|
+
}>>;
|
|
83
|
+
}, "strip", z.ZodTypeAny, {
|
|
84
|
+
success: boolean;
|
|
85
|
+
error?: {
|
|
86
|
+
code: string;
|
|
87
|
+
message: string;
|
|
88
|
+
httpStatus: number;
|
|
89
|
+
details?: any;
|
|
90
|
+
} | undefined;
|
|
91
|
+
headers?: Record<string, string> | undefined;
|
|
92
|
+
agentContext?: {
|
|
93
|
+
did: string;
|
|
94
|
+
kid: string;
|
|
95
|
+
session: string;
|
|
96
|
+
scopes: string[];
|
|
97
|
+
confidence: "verified";
|
|
98
|
+
registry: string;
|
|
99
|
+
verifiedAt: number;
|
|
100
|
+
delegationRef?: string | undefined;
|
|
101
|
+
subject?: string | undefined;
|
|
102
|
+
} | undefined;
|
|
103
|
+
}, {
|
|
104
|
+
success: boolean;
|
|
105
|
+
error?: {
|
|
106
|
+
code: string;
|
|
107
|
+
message: string;
|
|
108
|
+
httpStatus: number;
|
|
109
|
+
details?: any;
|
|
110
|
+
} | undefined;
|
|
111
|
+
headers?: Record<string, string> | undefined;
|
|
112
|
+
agentContext?: {
|
|
113
|
+
did: string;
|
|
114
|
+
kid: string;
|
|
115
|
+
session: string;
|
|
116
|
+
confidence: "verified";
|
|
117
|
+
registry: string;
|
|
118
|
+
verifiedAt: number;
|
|
119
|
+
delegationRef?: string | undefined;
|
|
120
|
+
subject?: string | undefined;
|
|
121
|
+
scopes?: string[] | undefined;
|
|
122
|
+
} | undefined;
|
|
123
|
+
}>;
|
|
124
|
+
export declare const StructuredErrorSchema: z.ZodObject<{
|
|
125
|
+
code: z.ZodString;
|
|
126
|
+
message: z.ZodString;
|
|
127
|
+
httpStatus: z.ZodNumber;
|
|
128
|
+
details: z.ZodOptional<z.ZodObject<{
|
|
129
|
+
reason: z.ZodOptional<z.ZodString>;
|
|
130
|
+
expected: z.ZodOptional<z.ZodAny>;
|
|
131
|
+
received: z.ZodOptional<z.ZodAny>;
|
|
132
|
+
remediation: z.ZodOptional<z.ZodString>;
|
|
133
|
+
}, "strip", z.ZodTypeAny, {
|
|
134
|
+
expected?: any;
|
|
135
|
+
received?: any;
|
|
136
|
+
reason?: string | undefined;
|
|
137
|
+
remediation?: string | undefined;
|
|
138
|
+
}, {
|
|
139
|
+
expected?: any;
|
|
140
|
+
received?: any;
|
|
141
|
+
reason?: string | undefined;
|
|
142
|
+
remediation?: string | undefined;
|
|
143
|
+
}>>;
|
|
144
|
+
}, "strip", z.ZodTypeAny, {
|
|
145
|
+
code: string;
|
|
146
|
+
message: string;
|
|
147
|
+
httpStatus: number;
|
|
148
|
+
details?: {
|
|
149
|
+
expected?: any;
|
|
150
|
+
received?: any;
|
|
151
|
+
reason?: string | undefined;
|
|
152
|
+
remediation?: string | undefined;
|
|
153
|
+
} | undefined;
|
|
154
|
+
}, {
|
|
155
|
+
code: string;
|
|
156
|
+
message: string;
|
|
157
|
+
httpStatus: number;
|
|
158
|
+
details?: {
|
|
159
|
+
expected?: any;
|
|
160
|
+
received?: any;
|
|
161
|
+
reason?: string | undefined;
|
|
162
|
+
remediation?: string | undefined;
|
|
163
|
+
} | undefined;
|
|
164
|
+
}>;
|
|
165
|
+
export type AgentContext = z.infer<typeof AgentContextSchema>;
|
|
166
|
+
export type VerifierResult = z.infer<typeof VerifierResultSchema>;
|
|
167
|
+
export type StructuredError = z.infer<typeof StructuredErrorSchema>;
|
|
168
|
+
export declare const AGENT_HEADERS: {
|
|
169
|
+
readonly DID: "X-Agent-DID";
|
|
170
|
+
readonly KEY_ID: "X-Agent-KeyId";
|
|
171
|
+
readonly SUBJECT: "X-Agent-Subject";
|
|
172
|
+
readonly SCOPES: "X-Agent-Scopes";
|
|
173
|
+
readonly SESSION: "X-Agent-Session";
|
|
174
|
+
readonly CONFIDENCE: "X-Agent-Confidence";
|
|
175
|
+
readonly DELEGATION_REF: "X-Agent-Delegation-Ref";
|
|
176
|
+
readonly REGISTRY: "X-Agent-Registry";
|
|
177
|
+
readonly VERIFIED_AT: "X-Agent-Verified-At";
|
|
178
|
+
};
|
|
179
|
+
export declare const VERIFIER_ERROR_CODES: {
|
|
180
|
+
readonly PROOF_INVALID_TS: "XMCP_I_PROOF_INVALID_TS";
|
|
181
|
+
readonly PROOF_FUTURE_TS: "XMCP_I_PROOF_FUTURE_TS";
|
|
182
|
+
readonly PROOF_TOO_OLD: "XMCP_I_PROOF_TOO_OLD";
|
|
183
|
+
readonly PROOF_SKEW_EXCEEDED: "XMCP_I_PROOF_SKEW_EXCEEDED";
|
|
184
|
+
readonly SESSION_IDLE_EXPIRED: "XMCP_I_SESSION_IDLE_EXPIRED";
|
|
185
|
+
readonly SERVER_TIME_INVALID: "XMCP_I_SERVER_TIME_INVALID";
|
|
186
|
+
};
|
|
187
|
+
export declare const ERROR_HTTP_STATUS: {
|
|
188
|
+
readonly XMCP_I_EBADPROOF: 403;
|
|
189
|
+
readonly XMCP_I_ENOIDENTITY: 500;
|
|
190
|
+
readonly XMCP_I_EMIRRORPENDING: 200;
|
|
191
|
+
readonly XMCP_I_EHANDSHAKE: 401;
|
|
192
|
+
readonly XMCP_I_ESESSION: 401;
|
|
193
|
+
readonly XMCP_I_ECLAIM: 400;
|
|
194
|
+
readonly XMCP_I_ECONFIG: 500;
|
|
195
|
+
readonly XMCP_I_ERUNTIME: 500;
|
|
196
|
+
readonly XMCP_I_PROOF_INVALID_TS: 403;
|
|
197
|
+
readonly XMCP_I_PROOF_FUTURE_TS: 403;
|
|
198
|
+
readonly XMCP_I_PROOF_TOO_OLD: 403;
|
|
199
|
+
readonly XMCP_I_PROOF_SKEW_EXCEEDED: 401;
|
|
200
|
+
readonly XMCP_I_SESSION_IDLE_EXPIRED: 401;
|
|
201
|
+
readonly XMCP_I_SERVER_TIME_INVALID: 500;
|
|
202
|
+
};
|
package/dist/verifier.js
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ERROR_HTTP_STATUS = exports.VERIFIER_ERROR_CODES = exports.AGENT_HEADERS = exports.StructuredErrorSchema = exports.VerifierResultSchema = exports.AgentContextSchema = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
exports.AgentContextSchema = zod_1.z.object({
|
|
6
|
+
did: zod_1.z.string().min(1),
|
|
7
|
+
kid: zod_1.z.string().min(1),
|
|
8
|
+
subject: zod_1.z.string().optional(),
|
|
9
|
+
scopes: zod_1.z.array(zod_1.z.string()).default([]),
|
|
10
|
+
session: zod_1.z.string().min(1),
|
|
11
|
+
confidence: zod_1.z.literal("verified"),
|
|
12
|
+
delegationRef: zod_1.z.string().optional(),
|
|
13
|
+
registry: zod_1.z.string().url(),
|
|
14
|
+
verifiedAt: zod_1.z.number().int().positive(),
|
|
15
|
+
});
|
|
16
|
+
exports.VerifierResultSchema = zod_1.z.object({
|
|
17
|
+
success: zod_1.z.boolean(),
|
|
18
|
+
headers: zod_1.z.record(zod_1.z.string()).optional(),
|
|
19
|
+
agentContext: exports.AgentContextSchema.optional(),
|
|
20
|
+
error: zod_1.z
|
|
21
|
+
.object({
|
|
22
|
+
code: zod_1.z.string(),
|
|
23
|
+
message: zod_1.z.string(),
|
|
24
|
+
details: zod_1.z.any().optional(),
|
|
25
|
+
httpStatus: zod_1.z.number().int().min(400).max(599),
|
|
26
|
+
})
|
|
27
|
+
.optional(),
|
|
28
|
+
});
|
|
29
|
+
exports.StructuredErrorSchema = zod_1.z.object({
|
|
30
|
+
code: zod_1.z.string(),
|
|
31
|
+
message: zod_1.z.string(),
|
|
32
|
+
httpStatus: zod_1.z.number().int().min(400).max(599),
|
|
33
|
+
details: zod_1.z
|
|
34
|
+
.object({
|
|
35
|
+
reason: zod_1.z.string().optional(),
|
|
36
|
+
expected: zod_1.z.any().optional(),
|
|
37
|
+
received: zod_1.z.any().optional(),
|
|
38
|
+
remediation: zod_1.z.string().optional(),
|
|
39
|
+
})
|
|
40
|
+
.optional(),
|
|
41
|
+
});
|
|
42
|
+
exports.AGENT_HEADERS = {
|
|
43
|
+
DID: "X-Agent-DID",
|
|
44
|
+
KEY_ID: "X-Agent-KeyId",
|
|
45
|
+
SUBJECT: "X-Agent-Subject",
|
|
46
|
+
SCOPES: "X-Agent-Scopes",
|
|
47
|
+
SESSION: "X-Agent-Session",
|
|
48
|
+
CONFIDENCE: "X-Agent-Confidence",
|
|
49
|
+
DELEGATION_REF: "X-Agent-Delegation-Ref",
|
|
50
|
+
REGISTRY: "X-Agent-Registry",
|
|
51
|
+
VERIFIED_AT: "X-Agent-Verified-At",
|
|
52
|
+
};
|
|
53
|
+
exports.VERIFIER_ERROR_CODES = {
|
|
54
|
+
PROOF_INVALID_TS: "XMCP_I_PROOF_INVALID_TS",
|
|
55
|
+
PROOF_FUTURE_TS: "XMCP_I_PROOF_FUTURE_TS",
|
|
56
|
+
PROOF_TOO_OLD: "XMCP_I_PROOF_TOO_OLD",
|
|
57
|
+
PROOF_SKEW_EXCEEDED: "XMCP_I_PROOF_SKEW_EXCEEDED",
|
|
58
|
+
SESSION_IDLE_EXPIRED: "XMCP_I_SESSION_IDLE_EXPIRED",
|
|
59
|
+
SERVER_TIME_INVALID: "XMCP_I_SERVER_TIME_INVALID",
|
|
60
|
+
};
|
|
61
|
+
exports.ERROR_HTTP_STATUS = {
|
|
62
|
+
XMCP_I_EBADPROOF: 403,
|
|
63
|
+
XMCP_I_ENOIDENTITY: 500,
|
|
64
|
+
XMCP_I_EMIRRORPENDING: 200,
|
|
65
|
+
XMCP_I_EHANDSHAKE: 401,
|
|
66
|
+
XMCP_I_ESESSION: 401,
|
|
67
|
+
XMCP_I_ECLAIM: 400,
|
|
68
|
+
XMCP_I_ECONFIG: 500,
|
|
69
|
+
XMCP_I_ERUNTIME: 500,
|
|
70
|
+
[exports.VERIFIER_ERROR_CODES.PROOF_INVALID_TS]: 403,
|
|
71
|
+
[exports.VERIFIER_ERROR_CODES.PROOF_FUTURE_TS]: 403,
|
|
72
|
+
[exports.VERIFIER_ERROR_CODES.PROOF_TOO_OLD]: 403,
|
|
73
|
+
[exports.VERIFIER_ERROR_CODES.PROOF_SKEW_EXCEEDED]: 401,
|
|
74
|
+
[exports.VERIFIER_ERROR_CODES.SESSION_IDLE_EXPIRED]: 401,
|
|
75
|
+
[exports.VERIFIER_ERROR_CODES.SERVER_TIME_INVALID]: 500,
|
|
76
|
+
};
|