@kya-os/contracts 1.3.3 → 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.
Files changed (66) hide show
  1. package/package.json +3 -2
  2. package/README.md +0 -130
  3. package/dist/agentshield-api/endpoints.d.ts +0 -21
  4. package/dist/agentshield-api/endpoints.js +0 -20
  5. package/dist/agentshield-api/index.d.ts +0 -5
  6. package/dist/agentshield-api/index.js +0 -27
  7. package/dist/agentshield-api/schemas.d.ts +0 -9846
  8. package/dist/agentshield-api/schemas.js +0 -92
  9. package/dist/agentshield-api/types.d.ts +0 -92
  10. package/dist/agentshield-api/types.js +0 -12
  11. package/dist/config/base.d.ts +0 -19
  12. package/dist/config/base.js +0 -2
  13. package/dist/config/delegation.d.ts +0 -46
  14. package/dist/config/delegation.js +0 -2
  15. package/dist/config/identity.d.ts +0 -22
  16. package/dist/config/identity.js +0 -2
  17. package/dist/config/index.d.ts +0 -17
  18. package/dist/config/index.js +0 -2
  19. package/dist/config/proofing.d.ts +0 -26
  20. package/dist/config/proofing.js +0 -2
  21. package/dist/config/tool-protection.d.ts +0 -36
  22. package/dist/config/tool-protection.js +0 -2
  23. package/dist/delegation/constraints.d.ts +0 -726
  24. package/dist/delegation/constraints.js +0 -103
  25. package/dist/delegation/index.d.ts +0 -2
  26. package/dist/delegation/index.js +0 -18
  27. package/dist/delegation/schemas.d.ts +0 -8042
  28. package/dist/delegation/schemas.js +0 -232
  29. package/dist/did/index.d.ts +0 -3
  30. package/dist/did/index.js +0 -19
  31. package/dist/did/resolve-contract.d.ts +0 -53
  32. package/dist/did/resolve-contract.js +0 -12
  33. package/dist/did/schemas.d.ts +0 -33
  34. package/dist/did/schemas.js +0 -80
  35. package/dist/did/types.d.ts +0 -38
  36. package/dist/did/types.js +0 -37
  37. package/dist/env/constants.d.ts +0 -13
  38. package/dist/env/constants.js +0 -15
  39. package/dist/env/index.d.ts +0 -1
  40. package/dist/env/index.js +0 -17
  41. package/dist/proof/index.d.ts +0 -2
  42. package/dist/proof/index.js +0 -18
  43. package/dist/proof/proof-record.d.ts +0 -728
  44. package/dist/proof/proof-record.js +0 -60
  45. package/dist/proof/signing-spec.d.ts +0 -73
  46. package/dist/proof/signing-spec.js +0 -52
  47. package/dist/runtime/errors.d.ts +0 -179
  48. package/dist/runtime/errors.js +0 -51
  49. package/dist/runtime/headers.d.ts +0 -34
  50. package/dist/runtime/headers.js +0 -52
  51. package/dist/runtime/index.d.ts +0 -2
  52. package/dist/runtime/index.js +0 -18
  53. package/dist/tlkrc/index.d.ts +0 -1
  54. package/dist/tlkrc/index.js +0 -17
  55. package/dist/tlkrc/rotation.d.ts +0 -168
  56. package/dist/tlkrc/rotation.js +0 -55
  57. package/dist/tool-protection/index.d.ts +0 -129
  58. package/dist/tool-protection/index.js +0 -80
  59. package/dist/vc/index.d.ts +0 -2
  60. package/dist/vc/index.js +0 -18
  61. package/dist/vc/schemas.d.ts +0 -1888
  62. package/dist/vc/schemas.js +0 -116
  63. package/dist/vc/statuslist.d.ts +0 -292
  64. package/dist/vc/statuslist.js +0 -61
  65. package/dist/well-known/index.d.ts +0 -248
  66. package/dist/well-known/index.js +0 -104
@@ -1,60 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DEFAULT_PROOF_RECORD_TTL_MS = exports.ProofRecordSchema = exports.VerificationInfoSchema = exports.CrispInfoSchema = exports.LinkageInfoSchema = exports.ProofDetailsSchema = exports.ResponseInfoSchema = exports.RequestInfoSchema = void 0;
4
- exports.validateProofRecord = validateProofRecord;
5
- exports.isProofRecordExpired = isProofRecordExpired;
6
- const zod_1 = require("zod");
7
- exports.RequestInfoSchema = zod_1.z.object({
8
- method: zod_1.z.string(),
9
- url: zod_1.z.string().url(),
10
- bodyHash: zod_1.z.string().optional(),
11
- headersHash: zod_1.z.string().optional(),
12
- });
13
- exports.ResponseInfoSchema = zod_1.z.object({
14
- status: zod_1.z.number().int(),
15
- bodyHash: zod_1.z.string().optional(),
16
- });
17
- exports.ProofDetailsSchema = zod_1.z.object({
18
- timestamp: zod_1.z.number().int().positive(),
19
- nonce: zod_1.z.string().min(1),
20
- did: zod_1.z.string().min(1),
21
- signature: zod_1.z.string().regex(/^[A-Za-z0-9_-]+$/),
22
- algorithm: zod_1.z.enum(['Ed25519', 'ES256']),
23
- sessionId: zod_1.z.string().min(1),
24
- audience: zod_1.z.string().min(1),
25
- request: exports.RequestInfoSchema.optional(),
26
- response: exports.ResponseInfoSchema.optional(),
27
- });
28
- exports.LinkageInfoSchema = zod_1.z.object({
29
- delegationId: zod_1.z.string().optional(),
30
- credentialId: zod_1.z.string().optional(),
31
- chainDepth: zod_1.z.number().int().nonnegative().optional(),
32
- });
33
- exports.CrispInfoSchema = zod_1.z.object({
34
- unit: zod_1.z.enum(['USD', 'ops', 'points']),
35
- delta: zod_1.z.number().optional(),
36
- remaining: zod_1.z.number().optional(),
37
- });
38
- exports.VerificationInfoSchema = zod_1.z.object({
39
- result: zod_1.z.enum(['pending', 'pass', 'fail']),
40
- reason: zod_1.z.string().optional(),
41
- checkedAt: zod_1.z.number().int().positive().optional(),
42
- });
43
- exports.ProofRecordSchema = zod_1.z.object({
44
- id: zod_1.z.string().min(1),
45
- toolName: zod_1.z.string().min(1),
46
- storedAt: zod_1.z.number().int().positive(),
47
- expiresAt: zod_1.z.number().int().positive(),
48
- proof: exports.ProofDetailsSchema,
49
- linkage: exports.LinkageInfoSchema.optional(),
50
- crisp: exports.CrispInfoSchema.optional(),
51
- verification: exports.VerificationInfoSchema.optional(),
52
- metadata: zod_1.z.record(zod_1.z.any()).optional(),
53
- }).passthrough();
54
- function validateProofRecord(record) {
55
- return exports.ProofRecordSchema.safeParse(record);
56
- }
57
- function isProofRecordExpired(record) {
58
- return Date.now() > record.expiresAt;
59
- }
60
- exports.DEFAULT_PROOF_RECORD_TTL_MS = 30 * 24 * 60 * 60 * 1000;
@@ -1,73 +0,0 @@
1
- import { z } from 'zod';
2
- export declare const CanonicalRequestPartsSchema: z.ZodObject<{
3
- method: z.ZodString;
4
- url: z.ZodString;
5
- bodyHash: z.ZodOptional<z.ZodString>;
6
- headersHash: z.ZodOptional<z.ZodString>;
7
- nonce: z.ZodString;
8
- timestamp: z.ZodNumber;
9
- audience: z.ZodString;
10
- }, "strip", z.ZodTypeAny, {
11
- nonce: string;
12
- audience: string;
13
- timestamp: number;
14
- url: string;
15
- method: string;
16
- bodyHash?: string | undefined;
17
- headersHash?: string | undefined;
18
- }, {
19
- nonce: string;
20
- audience: string;
21
- timestamp: number;
22
- url: string;
23
- method: string;
24
- bodyHash?: string | undefined;
25
- headersHash?: string | undefined;
26
- }>;
27
- export type CanonicalRequestParts = z.infer<typeof CanonicalRequestPartsSchema>;
28
- export declare const DetachedJwsSchema: z.ZodObject<{
29
- alg: z.ZodEnum<["Ed25519", "ES256"]>;
30
- kid: z.ZodOptional<z.ZodString>;
31
- signature: z.ZodString;
32
- }, "strip", z.ZodTypeAny, {
33
- signature: string;
34
- alg: "Ed25519" | "ES256";
35
- kid?: string | undefined;
36
- }, {
37
- signature: string;
38
- alg: "Ed25519" | "ES256";
39
- kid?: string | undefined;
40
- }>;
41
- export type DetachedJws = z.infer<typeof DetachedJwsSchema>;
42
- export declare const SIGNING_ORDER: readonly ["method", "url", "bodyHash", "headersHash", "nonce", "timestamp", "audience"];
43
- export type SigningOrderField = (typeof SIGNING_ORDER)[number];
44
- export declare function validateCanonicalRequestParts(parts: unknown): z.SafeParseReturnType<{
45
- nonce: string;
46
- audience: string;
47
- timestamp: number;
48
- url: string;
49
- method: string;
50
- bodyHash?: string | undefined;
51
- headersHash?: string | undefined;
52
- }, {
53
- nonce: string;
54
- audience: string;
55
- timestamp: number;
56
- url: string;
57
- method: string;
58
- bodyHash?: string | undefined;
59
- headersHash?: string | undefined;
60
- }>;
61
- export declare function validateDetachedJws(jws: unknown): z.SafeParseReturnType<{
62
- signature: string;
63
- alg: "Ed25519" | "ES256";
64
- kid?: string | undefined;
65
- }, {
66
- signature: string;
67
- alg: "Ed25519" | "ES256";
68
- kid?: string | undefined;
69
- }>;
70
- export declare function getCanonicalSigningString(parts: CanonicalRequestParts): string;
71
- export declare const SUPPORTED_SIGNING_ALGORITHMS: readonly ["Ed25519", "ES256"];
72
- export declare const SIGNING_HASH_ALGORITHM = "SHA-256";
73
- export declare const BASE64URL_PATTERN: RegExp;
@@ -1,52 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.BASE64URL_PATTERN = exports.SIGNING_HASH_ALGORITHM = exports.SUPPORTED_SIGNING_ALGORITHMS = exports.SIGNING_ORDER = exports.DetachedJwsSchema = exports.CanonicalRequestPartsSchema = void 0;
4
- exports.validateCanonicalRequestParts = validateCanonicalRequestParts;
5
- exports.validateDetachedJws = validateDetachedJws;
6
- exports.getCanonicalSigningString = getCanonicalSigningString;
7
- const zod_1 = require("zod");
8
- exports.CanonicalRequestPartsSchema = zod_1.z.object({
9
- method: zod_1.z.string().toUpperCase(),
10
- url: zod_1.z.string().url(),
11
- bodyHash: zod_1.z.string().regex(/^[A-Za-z0-9_-]+$/).optional(),
12
- headersHash: zod_1.z.string().regex(/^[A-Za-z0-9_-]+$/).optional(),
13
- nonce: zod_1.z.string().min(1),
14
- timestamp: zod_1.z.number().int().positive(),
15
- audience: zod_1.z.string().min(1),
16
- });
17
- exports.DetachedJwsSchema = zod_1.z.object({
18
- alg: zod_1.z.enum(['Ed25519', 'ES256']),
19
- kid: zod_1.z.string().optional(),
20
- signature: zod_1.z.string().regex(/^[A-Za-z0-9_-]+$/),
21
- });
22
- exports.SIGNING_ORDER = Object.freeze([
23
- 'method',
24
- 'url',
25
- 'bodyHash',
26
- 'headersHash',
27
- 'nonce',
28
- 'timestamp',
29
- 'audience',
30
- ]);
31
- function validateCanonicalRequestParts(parts) {
32
- return exports.CanonicalRequestPartsSchema.safeParse(parts);
33
- }
34
- function validateDetachedJws(jws) {
35
- return exports.DetachedJwsSchema.safeParse(jws);
36
- }
37
- function getCanonicalSigningString(parts) {
38
- const values = [];
39
- for (const field of exports.SIGNING_ORDER) {
40
- const value = parts[field];
41
- if (value !== undefined) {
42
- values.push(String(value));
43
- }
44
- else {
45
- values.push('');
46
- }
47
- }
48
- return values.join('\n');
49
- }
50
- exports.SUPPORTED_SIGNING_ALGORITHMS = ['Ed25519', 'ES256'];
51
- exports.SIGNING_HASH_ALGORITHM = 'SHA-256';
52
- exports.BASE64URL_PATTERN = /^[A-Za-z0-9_-]+$/;
@@ -1,179 +0,0 @@
1
- import { z } from 'zod';
2
- export declare const DisplayHintSchema: z.ZodEnum<["link", "qr", "code"]>;
3
- export type DisplayHint = z.infer<typeof DisplayHintSchema>;
4
- export declare const AuthorizationDisplaySchema: z.ZodObject<{
5
- title: z.ZodOptional<z.ZodString>;
6
- hint: z.ZodOptional<z.ZodArray<z.ZodEnum<["link", "qr", "code"]>, "many">>;
7
- authorizationCode: z.ZodOptional<z.ZodString>;
8
- qrUrl: z.ZodOptional<z.ZodString>;
9
- }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
10
- title: z.ZodOptional<z.ZodString>;
11
- hint: z.ZodOptional<z.ZodArray<z.ZodEnum<["link", "qr", "code"]>, "many">>;
12
- authorizationCode: z.ZodOptional<z.ZodString>;
13
- qrUrl: z.ZodOptional<z.ZodString>;
14
- }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
15
- title: z.ZodOptional<z.ZodString>;
16
- hint: z.ZodOptional<z.ZodArray<z.ZodEnum<["link", "qr", "code"]>, "many">>;
17
- authorizationCode: z.ZodOptional<z.ZodString>;
18
- qrUrl: z.ZodOptional<z.ZodString>;
19
- }, z.ZodTypeAny, "passthrough">>;
20
- export type AuthorizationDisplay = z.infer<typeof AuthorizationDisplaySchema>;
21
- export declare const NeedsAuthorizationErrorSchema: z.ZodObject<{
22
- error: z.ZodLiteral<"needs_authorization">;
23
- message: z.ZodString;
24
- authorizationUrl: z.ZodString;
25
- resumeToken: z.ZodString;
26
- expiresAt: z.ZodNumber;
27
- scopes: z.ZodArray<z.ZodString, "many">;
28
- display: z.ZodOptional<z.ZodObject<{
29
- title: z.ZodOptional<z.ZodString>;
30
- hint: z.ZodOptional<z.ZodArray<z.ZodEnum<["link", "qr", "code"]>, "many">>;
31
- authorizationCode: z.ZodOptional<z.ZodString>;
32
- qrUrl: z.ZodOptional<z.ZodString>;
33
- }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
34
- title: z.ZodOptional<z.ZodString>;
35
- hint: z.ZodOptional<z.ZodArray<z.ZodEnum<["link", "qr", "code"]>, "many">>;
36
- authorizationCode: z.ZodOptional<z.ZodString>;
37
- qrUrl: z.ZodOptional<z.ZodString>;
38
- }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
39
- title: z.ZodOptional<z.ZodString>;
40
- hint: z.ZodOptional<z.ZodArray<z.ZodEnum<["link", "qr", "code"]>, "many">>;
41
- authorizationCode: z.ZodOptional<z.ZodString>;
42
- qrUrl: z.ZodOptional<z.ZodString>;
43
- }, z.ZodTypeAny, "passthrough">>>;
44
- context: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
45
- }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
46
- error: z.ZodLiteral<"needs_authorization">;
47
- message: z.ZodString;
48
- authorizationUrl: z.ZodString;
49
- resumeToken: z.ZodString;
50
- expiresAt: z.ZodNumber;
51
- scopes: z.ZodArray<z.ZodString, "many">;
52
- display: z.ZodOptional<z.ZodObject<{
53
- title: z.ZodOptional<z.ZodString>;
54
- hint: z.ZodOptional<z.ZodArray<z.ZodEnum<["link", "qr", "code"]>, "many">>;
55
- authorizationCode: z.ZodOptional<z.ZodString>;
56
- qrUrl: z.ZodOptional<z.ZodString>;
57
- }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
58
- title: z.ZodOptional<z.ZodString>;
59
- hint: z.ZodOptional<z.ZodArray<z.ZodEnum<["link", "qr", "code"]>, "many">>;
60
- authorizationCode: z.ZodOptional<z.ZodString>;
61
- qrUrl: z.ZodOptional<z.ZodString>;
62
- }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
63
- title: z.ZodOptional<z.ZodString>;
64
- hint: z.ZodOptional<z.ZodArray<z.ZodEnum<["link", "qr", "code"]>, "many">>;
65
- authorizationCode: z.ZodOptional<z.ZodString>;
66
- qrUrl: z.ZodOptional<z.ZodString>;
67
- }, z.ZodTypeAny, "passthrough">>>;
68
- context: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
69
- }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
70
- error: z.ZodLiteral<"needs_authorization">;
71
- message: z.ZodString;
72
- authorizationUrl: z.ZodString;
73
- resumeToken: z.ZodString;
74
- expiresAt: z.ZodNumber;
75
- scopes: z.ZodArray<z.ZodString, "many">;
76
- display: z.ZodOptional<z.ZodObject<{
77
- title: z.ZodOptional<z.ZodString>;
78
- hint: z.ZodOptional<z.ZodArray<z.ZodEnum<["link", "qr", "code"]>, "many">>;
79
- authorizationCode: z.ZodOptional<z.ZodString>;
80
- qrUrl: z.ZodOptional<z.ZodString>;
81
- }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
82
- title: z.ZodOptional<z.ZodString>;
83
- hint: z.ZodOptional<z.ZodArray<z.ZodEnum<["link", "qr", "code"]>, "many">>;
84
- authorizationCode: z.ZodOptional<z.ZodString>;
85
- qrUrl: z.ZodOptional<z.ZodString>;
86
- }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
87
- title: z.ZodOptional<z.ZodString>;
88
- hint: z.ZodOptional<z.ZodArray<z.ZodEnum<["link", "qr", "code"]>, "many">>;
89
- authorizationCode: z.ZodOptional<z.ZodString>;
90
- qrUrl: z.ZodOptional<z.ZodString>;
91
- }, z.ZodTypeAny, "passthrough">>>;
92
- context: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
93
- }, z.ZodTypeAny, "passthrough">>;
94
- export type NeedsAuthorizationError = z.infer<typeof NeedsAuthorizationErrorSchema>;
95
- export declare const RuntimeErrorSchema: z.ZodObject<{
96
- error: z.ZodString;
97
- message: z.ZodString;
98
- details: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
99
- httpStatus: z.ZodOptional<z.ZodNumber>;
100
- }, "strip", z.ZodTypeAny, {
101
- message: string;
102
- error: string;
103
- details?: Record<string, any> | undefined;
104
- httpStatus?: number | undefined;
105
- }, {
106
- message: string;
107
- error: string;
108
- details?: Record<string, any> | undefined;
109
- httpStatus?: number | undefined;
110
- }>;
111
- export type RuntimeError = z.infer<typeof RuntimeErrorSchema>;
112
- export declare function validateNeedsAuthorizationError(error: unknown): z.SafeParseReturnType<z.objectInputType<{
113
- error: z.ZodLiteral<"needs_authorization">;
114
- message: z.ZodString;
115
- authorizationUrl: z.ZodString;
116
- resumeToken: z.ZodString;
117
- expiresAt: z.ZodNumber;
118
- scopes: z.ZodArray<z.ZodString, "many">;
119
- display: z.ZodOptional<z.ZodObject<{
120
- title: z.ZodOptional<z.ZodString>;
121
- hint: z.ZodOptional<z.ZodArray<z.ZodEnum<["link", "qr", "code"]>, "many">>;
122
- authorizationCode: z.ZodOptional<z.ZodString>;
123
- qrUrl: z.ZodOptional<z.ZodString>;
124
- }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
125
- title: z.ZodOptional<z.ZodString>;
126
- hint: z.ZodOptional<z.ZodArray<z.ZodEnum<["link", "qr", "code"]>, "many">>;
127
- authorizationCode: z.ZodOptional<z.ZodString>;
128
- qrUrl: z.ZodOptional<z.ZodString>;
129
- }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
130
- title: z.ZodOptional<z.ZodString>;
131
- hint: z.ZodOptional<z.ZodArray<z.ZodEnum<["link", "qr", "code"]>, "many">>;
132
- authorizationCode: z.ZodOptional<z.ZodString>;
133
- qrUrl: z.ZodOptional<z.ZodString>;
134
- }, z.ZodTypeAny, "passthrough">>>;
135
- context: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
136
- }, z.ZodTypeAny, "passthrough">, z.objectOutputType<{
137
- error: z.ZodLiteral<"needs_authorization">;
138
- message: z.ZodString;
139
- authorizationUrl: z.ZodString;
140
- resumeToken: z.ZodString;
141
- expiresAt: z.ZodNumber;
142
- scopes: z.ZodArray<z.ZodString, "many">;
143
- display: z.ZodOptional<z.ZodObject<{
144
- title: z.ZodOptional<z.ZodString>;
145
- hint: z.ZodOptional<z.ZodArray<z.ZodEnum<["link", "qr", "code"]>, "many">>;
146
- authorizationCode: z.ZodOptional<z.ZodString>;
147
- qrUrl: z.ZodOptional<z.ZodString>;
148
- }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
149
- title: z.ZodOptional<z.ZodString>;
150
- hint: z.ZodOptional<z.ZodArray<z.ZodEnum<["link", "qr", "code"]>, "many">>;
151
- authorizationCode: z.ZodOptional<z.ZodString>;
152
- qrUrl: z.ZodOptional<z.ZodString>;
153
- }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
154
- title: z.ZodOptional<z.ZodString>;
155
- hint: z.ZodOptional<z.ZodArray<z.ZodEnum<["link", "qr", "code"]>, "many">>;
156
- authorizationCode: z.ZodOptional<z.ZodString>;
157
- qrUrl: z.ZodOptional<z.ZodString>;
158
- }, z.ZodTypeAny, "passthrough">>>;
159
- context: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
160
- }, z.ZodTypeAny, "passthrough">>;
161
- export declare function isNeedsAuthorizationError(error: any): error is NeedsAuthorizationError;
162
- export declare function createNeedsAuthorizationError(config: {
163
- message: string;
164
- authorizationUrl: string;
165
- resumeToken: string;
166
- expiresAt: number;
167
- scopes: string[];
168
- display?: AuthorizationDisplay;
169
- }): NeedsAuthorizationError;
170
- export declare const ERROR_CODES: Readonly<{
171
- readonly NEEDS_AUTHORIZATION: "needs_authorization";
172
- readonly INVALID_TOKEN: "invalid_token";
173
- readonly TOKEN_EXPIRED: "token_expired";
174
- readonly INSUFFICIENT_SCOPE: "insufficient_scope";
175
- readonly INVALID_SIGNATURE: "invalid_signature";
176
- readonly DELEGATION_REVOKED: "delegation_revoked";
177
- readonly CREDENTIAL_REVOKED: "credential_revoked";
178
- }>;
179
- export type ErrorCode = typeof ERROR_CODES[keyof typeof ERROR_CODES];
@@ -1,51 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ERROR_CODES = exports.RuntimeErrorSchema = exports.NeedsAuthorizationErrorSchema = exports.AuthorizationDisplaySchema = exports.DisplayHintSchema = void 0;
4
- exports.validateNeedsAuthorizationError = validateNeedsAuthorizationError;
5
- exports.isNeedsAuthorizationError = isNeedsAuthorizationError;
6
- exports.createNeedsAuthorizationError = createNeedsAuthorizationError;
7
- const zod_1 = require("zod");
8
- exports.DisplayHintSchema = zod_1.z.enum(['link', 'qr', 'code']);
9
- exports.AuthorizationDisplaySchema = zod_1.z.object({
10
- title: zod_1.z.string().optional(),
11
- hint: zod_1.z.array(exports.DisplayHintSchema).optional(),
12
- authorizationCode: zod_1.z.string().optional(),
13
- qrUrl: zod_1.z.string().url().optional(),
14
- }).passthrough();
15
- exports.NeedsAuthorizationErrorSchema = zod_1.z.object({
16
- error: zod_1.z.literal('needs_authorization'),
17
- message: zod_1.z.string().min(1),
18
- authorizationUrl: zod_1.z.string().url(),
19
- resumeToken: zod_1.z.string().min(1),
20
- expiresAt: zod_1.z.number().int().positive(),
21
- scopes: zod_1.z.array(zod_1.z.string()),
22
- display: exports.AuthorizationDisplaySchema.optional(),
23
- context: zod_1.z.record(zod_1.z.any()).optional(),
24
- }).passthrough();
25
- exports.RuntimeErrorSchema = zod_1.z.object({
26
- error: zod_1.z.string().min(1),
27
- message: zod_1.z.string().min(1),
28
- details: zod_1.z.record(zod_1.z.any()).optional(),
29
- httpStatus: zod_1.z.number().int().min(400).max(599).optional(),
30
- });
31
- function validateNeedsAuthorizationError(error) {
32
- return exports.NeedsAuthorizationErrorSchema.safeParse(error);
33
- }
34
- function isNeedsAuthorizationError(error) {
35
- return error && error.error === 'needs_authorization';
36
- }
37
- function createNeedsAuthorizationError(config) {
38
- return {
39
- error: 'needs_authorization',
40
- ...config,
41
- };
42
- }
43
- exports.ERROR_CODES = Object.freeze({
44
- NEEDS_AUTHORIZATION: 'needs_authorization',
45
- INVALID_TOKEN: 'invalid_token',
46
- TOKEN_EXPIRED: 'token_expired',
47
- INSUFFICIENT_SCOPE: 'insufficient_scope',
48
- INVALID_SIGNATURE: 'invalid_signature',
49
- DELEGATION_REVOKED: 'delegation_revoked',
50
- CREDENTIAL_REVOKED: 'credential_revoked',
51
- });
@@ -1,34 +0,0 @@
1
- export interface DownstreamHeaders {
2
- 'X-Agent-DID': string;
3
- 'X-Delegation-Id'?: string;
4
- 'X-Delegation-Chain'?: string;
5
- 'X-MCPI-Proof-Id': string;
6
- 'X-CRISP-Spend'?: string;
7
- 'X-Session-Id'?: string;
8
- 'X-Scopes'?: string;
9
- }
10
- export declare const DOWNSTREAM_HEADER_NAMES: Readonly<{
11
- readonly AGENT_DID: "X-Agent-DID";
12
- readonly DELEGATION_ID: "X-Delegation-Id";
13
- readonly DELEGATION_CHAIN: "X-Delegation-Chain";
14
- readonly PROOF_ID: "X-MCPI-Proof-Id";
15
- readonly CRISP_SPEND: "X-CRISP-Spend";
16
- readonly SESSION_ID: "X-Session-Id";
17
- readonly SCOPES: "X-Scopes";
18
- }>;
19
- export interface CrispSpendInfo {
20
- unit: 'USD' | 'ops' | 'points';
21
- delta?: number;
22
- remaining?: number;
23
- }
24
- export declare function serializeCrispSpend(info: CrispSpendInfo): string;
25
- export declare function parseCrispSpend(headerValue: string): CrispSpendInfo | null;
26
- export declare function createDownstreamHeaders(config: {
27
- agentDid: string;
28
- proofId: string;
29
- delegationId?: string;
30
- delegationChain?: string;
31
- crispSpend?: CrispSpendInfo;
32
- sessionId?: string;
33
- scopes?: string[];
34
- }): DownstreamHeaders;
@@ -1,52 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DOWNSTREAM_HEADER_NAMES = void 0;
4
- exports.serializeCrispSpend = serializeCrispSpend;
5
- exports.parseCrispSpend = parseCrispSpend;
6
- exports.createDownstreamHeaders = createDownstreamHeaders;
7
- exports.DOWNSTREAM_HEADER_NAMES = Object.freeze({
8
- AGENT_DID: 'X-Agent-DID',
9
- DELEGATION_ID: 'X-Delegation-Id',
10
- DELEGATION_CHAIN: 'X-Delegation-Chain',
11
- PROOF_ID: 'X-MCPI-Proof-Id',
12
- CRISP_SPEND: 'X-CRISP-Spend',
13
- SESSION_ID: 'X-Session-Id',
14
- SCOPES: 'X-Scopes',
15
- });
16
- function serializeCrispSpend(info) {
17
- return JSON.stringify(info);
18
- }
19
- function parseCrispSpend(headerValue) {
20
- try {
21
- const parsed = JSON.parse(headerValue);
22
- if (parsed && typeof parsed.unit === 'string') {
23
- return parsed;
24
- }
25
- return null;
26
- }
27
- catch {
28
- return null;
29
- }
30
- }
31
- function createDownstreamHeaders(config) {
32
- const headers = {
33
- 'X-Agent-DID': config.agentDid,
34
- 'X-MCPI-Proof-Id': config.proofId,
35
- };
36
- if (config.delegationId) {
37
- headers['X-Delegation-Id'] = config.delegationId;
38
- }
39
- if (config.delegationChain) {
40
- headers['X-Delegation-Chain'] = config.delegationChain;
41
- }
42
- if (config.crispSpend) {
43
- headers['X-CRISP-Spend'] = serializeCrispSpend(config.crispSpend);
44
- }
45
- if (config.sessionId) {
46
- headers['X-Session-Id'] = config.sessionId;
47
- }
48
- if (config.scopes && config.scopes.length > 0) {
49
- headers['X-Scopes'] = config.scopes.join(',');
50
- }
51
- return headers;
52
- }
@@ -1,2 +0,0 @@
1
- export * from './errors.js';
2
- export * from './headers.js';
@@ -1,18 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./errors.js"), exports);
18
- __exportStar(require("./headers.js"), exports);
@@ -1 +0,0 @@
1
- export * from './rotation.js';
@@ -1,17 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./rotation.js"), exports);