@kya-os/contracts 1.3.5 → 1.5.1

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 (89) hide show
  1. package/dist/agentshield-api/endpoints.d.ts +50 -0
  2. package/dist/agentshield-api/endpoints.js +46 -0
  3. package/dist/agentshield-api/index.d.ts +13 -0
  4. package/dist/agentshield-api/index.js +38 -0
  5. package/dist/agentshield-api/schemas.d.ts +9914 -0
  6. package/dist/agentshield-api/schemas.js +165 -0
  7. package/dist/agentshield-api/types.d.ts +168 -0
  8. package/dist/agentshield-api/types.js +27 -0
  9. package/dist/cli.d.ts +13 -0
  10. package/dist/cli.js +13 -1
  11. package/dist/config/base.d.ts +96 -0
  12. package/dist/config/base.js +11 -0
  13. package/dist/config/delegation.d.ts +194 -0
  14. package/dist/config/delegation.js +10 -0
  15. package/dist/config/identity.d.ts +117 -0
  16. package/dist/config/identity.js +11 -0
  17. package/dist/config/index.d.ts +33 -0
  18. package/dist/config/index.js +11 -0
  19. package/dist/config/proofing.d.ts +120 -0
  20. package/dist/config/proofing.js +10 -0
  21. package/dist/config/tool-protection.d.ts +139 -0
  22. package/dist/config/tool-protection.js +10 -0
  23. package/dist/dashboard-config/default-config.d.ts +49 -0
  24. package/dist/dashboard-config/default-config.js +225 -0
  25. package/dist/dashboard-config/index.d.ts +10 -0
  26. package/dist/dashboard-config/index.js +35 -0
  27. package/dist/dashboard-config/schemas.d.ts +5847 -0
  28. package/dist/dashboard-config/schemas.js +251 -0
  29. package/dist/dashboard-config/types.d.ts +331 -0
  30. package/dist/dashboard-config/types.js +11 -0
  31. package/dist/delegation/constraints.d.ts +991 -0
  32. package/dist/delegation/constraints.js +209 -0
  33. package/dist/delegation/index.d.ts +7 -0
  34. package/dist/delegation/index.js +23 -0
  35. package/dist/delegation/schemas.d.ts +8381 -0
  36. package/dist/delegation/schemas.js +475 -0
  37. package/dist/did/index.d.ts +8 -0
  38. package/dist/did/index.js +24 -0
  39. package/dist/did/resolve-contract.d.ts +219 -0
  40. package/dist/did/resolve-contract.js +31 -0
  41. package/dist/did/schemas.d.ts +112 -0
  42. package/dist/did/schemas.js +172 -0
  43. package/dist/did/types.d.ts +163 -0
  44. package/dist/did/types.js +70 -0
  45. package/dist/env/constants.d.ts +57 -0
  46. package/dist/env/constants.js +59 -0
  47. package/dist/env/index.d.ts +4 -0
  48. package/dist/env/index.js +20 -0
  49. package/dist/handshake.d.ts +20 -0
  50. package/dist/handshake.js +10 -3
  51. package/dist/index.d.ts +14 -0
  52. package/dist/index.js +28 -0
  53. package/dist/proof/index.d.ts +8 -0
  54. package/dist/proof/index.js +24 -0
  55. package/dist/proof/proof-record.d.ts +837 -0
  56. package/dist/proof/proof-record.js +133 -0
  57. package/dist/proof/signing-spec.d.ts +146 -0
  58. package/dist/proof/signing-spec.js +122 -0
  59. package/dist/proof.d.ts +53 -16
  60. package/dist/proof.js +27 -3
  61. package/dist/registry.d.ts +16 -0
  62. package/dist/registry.js +29 -9
  63. package/dist/runtime/errors.d.ts +347 -0
  64. package/dist/runtime/errors.js +119 -0
  65. package/dist/runtime/headers.d.ts +83 -0
  66. package/dist/runtime/headers.js +81 -0
  67. package/dist/runtime/index.d.ts +5 -0
  68. package/dist/runtime/index.js +21 -0
  69. package/dist/test.d.ts +36 -0
  70. package/dist/test.js +36 -0
  71. package/dist/tlkrc/index.d.ts +4 -0
  72. package/dist/tlkrc/index.js +20 -0
  73. package/dist/tlkrc/rotation.d.ts +245 -0
  74. package/dist/tlkrc/rotation.js +126 -0
  75. package/dist/tool-protection/index.d.ts +227 -0
  76. package/dist/tool-protection/index.js +113 -0
  77. package/dist/utils/validation.d.ts +16 -0
  78. package/dist/utils/validation.js +13 -0
  79. package/dist/vc/index.d.ts +7 -0
  80. package/dist/vc/index.js +23 -0
  81. package/dist/vc/schemas.d.ts +2483 -0
  82. package/dist/vc/schemas.js +224 -0
  83. package/dist/vc/statuslist.d.ts +493 -0
  84. package/dist/vc/statuslist.js +132 -0
  85. package/dist/verifier.d.ts +3 -0
  86. package/dist/verifier.js +7 -0
  87. package/dist/well-known/index.d.ts +308 -0
  88. package/dist/well-known/index.js +134 -0
  89. package/package.json +6 -1
@@ -0,0 +1,493 @@
1
+ /**
2
+ * StatusList2021 Types and Schemas
3
+ *
4
+ * Implementation of the W3C StatusList2021 specification for credential status.
5
+ * Provides types for status list credentials and helpers for bitstring operations.
6
+ *
7
+ * Related Spec: W3C StatusList2021
8
+ * Python Reference: Credential-Documentation.md (StatusList2021 section)
9
+ */
10
+ import { z } from 'zod';
11
+ /**
12
+ * Status Purpose
13
+ *
14
+ * Indicates the purpose of the status list
15
+ */
16
+ export type StatusPurpose = 'revocation' | 'suspension';
17
+ /**
18
+ * Status List Credential Subject Schema
19
+ *
20
+ * The credential subject of a StatusList2021Credential
21
+ */
22
+ export declare const StatusList2021CredentialSubjectSchema: z.ZodObject<{
23
+ /** Optional identifier for the status list */
24
+ id: z.ZodOptional<z.ZodString>;
25
+ /** Type MUST be StatusList2021 */
26
+ type: z.ZodLiteral<"StatusList2021">;
27
+ /** Purpose of the status list */
28
+ statusPurpose: z.ZodEnum<["revocation", "suspension"]>;
29
+ /**
30
+ * Encoded bitstring
31
+ *
32
+ * Base64url-encoded and GZIP-compressed bitstring.
33
+ * Each bit represents the status of a credential:
34
+ * - 0: Not revoked/suspended
35
+ * - 1: Revoked/suspended
36
+ */
37
+ encodedList: z.ZodString;
38
+ }, "strip", z.ZodTypeAny, {
39
+ type: "StatusList2021";
40
+ statusPurpose: "revocation" | "suspension";
41
+ encodedList: string;
42
+ id?: string | undefined;
43
+ }, {
44
+ type: "StatusList2021";
45
+ statusPurpose: "revocation" | "suspension";
46
+ encodedList: string;
47
+ id?: string | undefined;
48
+ }>;
49
+ /**
50
+ * StatusList2021 Credential Schema
51
+ *
52
+ * A credential that contains a status list for checking revocation/suspension
53
+ * of other credentials.
54
+ */
55
+ export declare const StatusList2021CredentialSchema: z.ZodObject<{
56
+ /** JSON-LD context */
57
+ '@context': z.ZodEffects<z.ZodEffects<z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodRecord<z.ZodString, z.ZodAny>]>, "atleastone">, [string | Record<string, any>, ...(string | Record<string, any>)[]], [string | Record<string, any>, ...(string | Record<string, any>)[]]>, [string | Record<string, any>, ...(string | Record<string, any>)[]], [string | Record<string, any>, ...(string | Record<string, any>)[]]>;
58
+ /** Unique identifier for the status list credential */
59
+ id: z.ZodString;
60
+ /** Type MUST include VerifiableCredential and StatusList2021Credential */
61
+ type: z.ZodUnion<[z.ZodTuple<[z.ZodLiteral<"VerifiableCredential">, z.ZodLiteral<"StatusList2021Credential">], null>, z.ZodEffects<z.ZodArray<z.ZodString, "many">, string[], string[]>]>;
62
+ /** Issuer of the status list credential */
63
+ issuer: z.ZodUnion<[z.ZodString, z.ZodObject<{
64
+ id: z.ZodString;
65
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
66
+ id: z.ZodString;
67
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
68
+ id: z.ZodString;
69
+ }, z.ZodTypeAny, "passthrough">>]>;
70
+ /** Issuance date in ISO 8601 format */
71
+ issuanceDate: z.ZodString;
72
+ /** The status list credential subject */
73
+ credentialSubject: z.ZodObject<{
74
+ /** Optional identifier for the status list */
75
+ id: z.ZodOptional<z.ZodString>;
76
+ /** Type MUST be StatusList2021 */
77
+ type: z.ZodLiteral<"StatusList2021">;
78
+ /** Purpose of the status list */
79
+ statusPurpose: z.ZodEnum<["revocation", "suspension"]>;
80
+ /**
81
+ * Encoded bitstring
82
+ *
83
+ * Base64url-encoded and GZIP-compressed bitstring.
84
+ * Each bit represents the status of a credential:
85
+ * - 0: Not revoked/suspended
86
+ * - 1: Revoked/suspended
87
+ */
88
+ encodedList: z.ZodString;
89
+ }, "strip", z.ZodTypeAny, {
90
+ type: "StatusList2021";
91
+ statusPurpose: "revocation" | "suspension";
92
+ encodedList: string;
93
+ id?: string | undefined;
94
+ }, {
95
+ type: "StatusList2021";
96
+ statusPurpose: "revocation" | "suspension";
97
+ encodedList: string;
98
+ id?: string | undefined;
99
+ }>;
100
+ /** Cryptographic proof (optional) */
101
+ proof: z.ZodOptional<z.ZodObject<{
102
+ type: z.ZodString;
103
+ created: z.ZodOptional<z.ZodString>;
104
+ verificationMethod: z.ZodOptional<z.ZodString>;
105
+ proofPurpose: z.ZodOptional<z.ZodString>;
106
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
107
+ type: z.ZodString;
108
+ created: z.ZodOptional<z.ZodString>;
109
+ verificationMethod: z.ZodOptional<z.ZodString>;
110
+ proofPurpose: z.ZodOptional<z.ZodString>;
111
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
112
+ type: z.ZodString;
113
+ created: z.ZodOptional<z.ZodString>;
114
+ verificationMethod: z.ZodOptional<z.ZodString>;
115
+ proofPurpose: z.ZodOptional<z.ZodString>;
116
+ }, z.ZodTypeAny, "passthrough">>>;
117
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
118
+ /** JSON-LD context */
119
+ '@context': z.ZodEffects<z.ZodEffects<z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodRecord<z.ZodString, z.ZodAny>]>, "atleastone">, [string | Record<string, any>, ...(string | Record<string, any>)[]], [string | Record<string, any>, ...(string | Record<string, any>)[]]>, [string | Record<string, any>, ...(string | Record<string, any>)[]], [string | Record<string, any>, ...(string | Record<string, any>)[]]>;
120
+ /** Unique identifier for the status list credential */
121
+ id: z.ZodString;
122
+ /** Type MUST include VerifiableCredential and StatusList2021Credential */
123
+ type: z.ZodUnion<[z.ZodTuple<[z.ZodLiteral<"VerifiableCredential">, z.ZodLiteral<"StatusList2021Credential">], null>, z.ZodEffects<z.ZodArray<z.ZodString, "many">, string[], string[]>]>;
124
+ /** Issuer of the status list credential */
125
+ issuer: z.ZodUnion<[z.ZodString, z.ZodObject<{
126
+ id: z.ZodString;
127
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
128
+ id: z.ZodString;
129
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
130
+ id: z.ZodString;
131
+ }, z.ZodTypeAny, "passthrough">>]>;
132
+ /** Issuance date in ISO 8601 format */
133
+ issuanceDate: z.ZodString;
134
+ /** The status list credential subject */
135
+ credentialSubject: z.ZodObject<{
136
+ /** Optional identifier for the status list */
137
+ id: z.ZodOptional<z.ZodString>;
138
+ /** Type MUST be StatusList2021 */
139
+ type: z.ZodLiteral<"StatusList2021">;
140
+ /** Purpose of the status list */
141
+ statusPurpose: z.ZodEnum<["revocation", "suspension"]>;
142
+ /**
143
+ * Encoded bitstring
144
+ *
145
+ * Base64url-encoded and GZIP-compressed bitstring.
146
+ * Each bit represents the status of a credential:
147
+ * - 0: Not revoked/suspended
148
+ * - 1: Revoked/suspended
149
+ */
150
+ encodedList: z.ZodString;
151
+ }, "strip", z.ZodTypeAny, {
152
+ type: "StatusList2021";
153
+ statusPurpose: "revocation" | "suspension";
154
+ encodedList: string;
155
+ id?: string | undefined;
156
+ }, {
157
+ type: "StatusList2021";
158
+ statusPurpose: "revocation" | "suspension";
159
+ encodedList: string;
160
+ id?: string | undefined;
161
+ }>;
162
+ /** Cryptographic proof (optional) */
163
+ proof: z.ZodOptional<z.ZodObject<{
164
+ type: z.ZodString;
165
+ created: z.ZodOptional<z.ZodString>;
166
+ verificationMethod: z.ZodOptional<z.ZodString>;
167
+ proofPurpose: z.ZodOptional<z.ZodString>;
168
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
169
+ type: z.ZodString;
170
+ created: z.ZodOptional<z.ZodString>;
171
+ verificationMethod: z.ZodOptional<z.ZodString>;
172
+ proofPurpose: z.ZodOptional<z.ZodString>;
173
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
174
+ type: z.ZodString;
175
+ created: z.ZodOptional<z.ZodString>;
176
+ verificationMethod: z.ZodOptional<z.ZodString>;
177
+ proofPurpose: z.ZodOptional<z.ZodString>;
178
+ }, z.ZodTypeAny, "passthrough">>>;
179
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
180
+ /** JSON-LD context */
181
+ '@context': z.ZodEffects<z.ZodEffects<z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodRecord<z.ZodString, z.ZodAny>]>, "atleastone">, [string | Record<string, any>, ...(string | Record<string, any>)[]], [string | Record<string, any>, ...(string | Record<string, any>)[]]>, [string | Record<string, any>, ...(string | Record<string, any>)[]], [string | Record<string, any>, ...(string | Record<string, any>)[]]>;
182
+ /** Unique identifier for the status list credential */
183
+ id: z.ZodString;
184
+ /** Type MUST include VerifiableCredential and StatusList2021Credential */
185
+ type: z.ZodUnion<[z.ZodTuple<[z.ZodLiteral<"VerifiableCredential">, z.ZodLiteral<"StatusList2021Credential">], null>, z.ZodEffects<z.ZodArray<z.ZodString, "many">, string[], string[]>]>;
186
+ /** Issuer of the status list credential */
187
+ issuer: z.ZodUnion<[z.ZodString, z.ZodObject<{
188
+ id: z.ZodString;
189
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
190
+ id: z.ZodString;
191
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
192
+ id: z.ZodString;
193
+ }, z.ZodTypeAny, "passthrough">>]>;
194
+ /** Issuance date in ISO 8601 format */
195
+ issuanceDate: z.ZodString;
196
+ /** The status list credential subject */
197
+ credentialSubject: z.ZodObject<{
198
+ /** Optional identifier for the status list */
199
+ id: z.ZodOptional<z.ZodString>;
200
+ /** Type MUST be StatusList2021 */
201
+ type: z.ZodLiteral<"StatusList2021">;
202
+ /** Purpose of the status list */
203
+ statusPurpose: z.ZodEnum<["revocation", "suspension"]>;
204
+ /**
205
+ * Encoded bitstring
206
+ *
207
+ * Base64url-encoded and GZIP-compressed bitstring.
208
+ * Each bit represents the status of a credential:
209
+ * - 0: Not revoked/suspended
210
+ * - 1: Revoked/suspended
211
+ */
212
+ encodedList: z.ZodString;
213
+ }, "strip", z.ZodTypeAny, {
214
+ type: "StatusList2021";
215
+ statusPurpose: "revocation" | "suspension";
216
+ encodedList: string;
217
+ id?: string | undefined;
218
+ }, {
219
+ type: "StatusList2021";
220
+ statusPurpose: "revocation" | "suspension";
221
+ encodedList: string;
222
+ id?: string | undefined;
223
+ }>;
224
+ /** Cryptographic proof (optional) */
225
+ proof: z.ZodOptional<z.ZodObject<{
226
+ type: z.ZodString;
227
+ created: z.ZodOptional<z.ZodString>;
228
+ verificationMethod: z.ZodOptional<z.ZodString>;
229
+ proofPurpose: z.ZodOptional<z.ZodString>;
230
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
231
+ type: z.ZodString;
232
+ created: z.ZodOptional<z.ZodString>;
233
+ verificationMethod: z.ZodOptional<z.ZodString>;
234
+ proofPurpose: z.ZodOptional<z.ZodString>;
235
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
236
+ type: z.ZodString;
237
+ created: z.ZodOptional<z.ZodString>;
238
+ verificationMethod: z.ZodOptional<z.ZodString>;
239
+ proofPurpose: z.ZodOptional<z.ZodString>;
240
+ }, z.ZodTypeAny, "passthrough">>>;
241
+ }, z.ZodTypeAny, "passthrough">>;
242
+ /**
243
+ * Type exports
244
+ */
245
+ export type StatusList2021CredentialSubject = z.infer<typeof StatusList2021CredentialSubjectSchema>;
246
+ export type StatusList2021Credential = z.infer<typeof StatusList2021CredentialSchema>;
247
+ /**
248
+ * StatusList2021 Credential Type (traditional TypeScript interface)
249
+ *
250
+ * For use when not using Zod validation
251
+ */
252
+ export interface StatusList2021CredentialInterface {
253
+ '@context': (string | Record<string, any>)[];
254
+ id: string;
255
+ type: ['VerifiableCredential', 'StatusList2021Credential'];
256
+ issuer: string | {
257
+ id: string;
258
+ };
259
+ issuanceDate: string;
260
+ credentialSubject: {
261
+ id?: string;
262
+ type: 'StatusList2021';
263
+ statusPurpose: 'revocation' | 'suspension';
264
+ encodedList: string;
265
+ };
266
+ proof?: Record<string, any>;
267
+ }
268
+ /**
269
+ * Validation Helpers
270
+ */
271
+ /**
272
+ * Validate a StatusList2021 credential
273
+ *
274
+ * @param credential - The credential to validate
275
+ * @returns Validation result with parsed credential or errors
276
+ */
277
+ export declare function validateStatusList2021Credential(credential: unknown): z.SafeParseReturnType<z.objectInputType<{
278
+ /** JSON-LD context */
279
+ '@context': z.ZodEffects<z.ZodEffects<z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodRecord<z.ZodString, z.ZodAny>]>, "atleastone">, [string | Record<string, any>, ...(string | Record<string, any>)[]], [string | Record<string, any>, ...(string | Record<string, any>)[]]>, [string | Record<string, any>, ...(string | Record<string, any>)[]], [string | Record<string, any>, ...(string | Record<string, any>)[]]>;
280
+ /** Unique identifier for the status list credential */
281
+ id: z.ZodString;
282
+ /** Type MUST include VerifiableCredential and StatusList2021Credential */
283
+ type: z.ZodUnion<[z.ZodTuple<[z.ZodLiteral<"VerifiableCredential">, z.ZodLiteral<"StatusList2021Credential">], null>, z.ZodEffects<z.ZodArray<z.ZodString, "many">, string[], string[]>]>;
284
+ /** Issuer of the status list credential */
285
+ issuer: z.ZodUnion<[z.ZodString, z.ZodObject<{
286
+ id: z.ZodString;
287
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
288
+ id: z.ZodString;
289
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
290
+ id: z.ZodString;
291
+ }, z.ZodTypeAny, "passthrough">>]>;
292
+ /** Issuance date in ISO 8601 format */
293
+ issuanceDate: z.ZodString;
294
+ /** The status list credential subject */
295
+ credentialSubject: z.ZodObject<{
296
+ /** Optional identifier for the status list */
297
+ id: z.ZodOptional<z.ZodString>;
298
+ /** Type MUST be StatusList2021 */
299
+ type: z.ZodLiteral<"StatusList2021">;
300
+ /** Purpose of the status list */
301
+ statusPurpose: z.ZodEnum<["revocation", "suspension"]>;
302
+ /**
303
+ * Encoded bitstring
304
+ *
305
+ * Base64url-encoded and GZIP-compressed bitstring.
306
+ * Each bit represents the status of a credential:
307
+ * - 0: Not revoked/suspended
308
+ * - 1: Revoked/suspended
309
+ */
310
+ encodedList: z.ZodString;
311
+ }, "strip", z.ZodTypeAny, {
312
+ type: "StatusList2021";
313
+ statusPurpose: "revocation" | "suspension";
314
+ encodedList: string;
315
+ id?: string | undefined;
316
+ }, {
317
+ type: "StatusList2021";
318
+ statusPurpose: "revocation" | "suspension";
319
+ encodedList: string;
320
+ id?: string | undefined;
321
+ }>;
322
+ /** Cryptographic proof (optional) */
323
+ proof: z.ZodOptional<z.ZodObject<{
324
+ type: z.ZodString;
325
+ created: z.ZodOptional<z.ZodString>;
326
+ verificationMethod: z.ZodOptional<z.ZodString>;
327
+ proofPurpose: z.ZodOptional<z.ZodString>;
328
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
329
+ type: z.ZodString;
330
+ created: z.ZodOptional<z.ZodString>;
331
+ verificationMethod: z.ZodOptional<z.ZodString>;
332
+ proofPurpose: z.ZodOptional<z.ZodString>;
333
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
334
+ type: z.ZodString;
335
+ created: z.ZodOptional<z.ZodString>;
336
+ verificationMethod: z.ZodOptional<z.ZodString>;
337
+ proofPurpose: z.ZodOptional<z.ZodString>;
338
+ }, z.ZodTypeAny, "passthrough">>>;
339
+ }, z.ZodTypeAny, "passthrough">, z.objectOutputType<{
340
+ /** JSON-LD context */
341
+ '@context': z.ZodEffects<z.ZodEffects<z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodRecord<z.ZodString, z.ZodAny>]>, "atleastone">, [string | Record<string, any>, ...(string | Record<string, any>)[]], [string | Record<string, any>, ...(string | Record<string, any>)[]]>, [string | Record<string, any>, ...(string | Record<string, any>)[]], [string | Record<string, any>, ...(string | Record<string, any>)[]]>;
342
+ /** Unique identifier for the status list credential */
343
+ id: z.ZodString;
344
+ /** Type MUST include VerifiableCredential and StatusList2021Credential */
345
+ type: z.ZodUnion<[z.ZodTuple<[z.ZodLiteral<"VerifiableCredential">, z.ZodLiteral<"StatusList2021Credential">], null>, z.ZodEffects<z.ZodArray<z.ZodString, "many">, string[], string[]>]>;
346
+ /** Issuer of the status list credential */
347
+ issuer: z.ZodUnion<[z.ZodString, z.ZodObject<{
348
+ id: z.ZodString;
349
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
350
+ id: z.ZodString;
351
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
352
+ id: z.ZodString;
353
+ }, z.ZodTypeAny, "passthrough">>]>;
354
+ /** Issuance date in ISO 8601 format */
355
+ issuanceDate: z.ZodString;
356
+ /** The status list credential subject */
357
+ credentialSubject: z.ZodObject<{
358
+ /** Optional identifier for the status list */
359
+ id: z.ZodOptional<z.ZodString>;
360
+ /** Type MUST be StatusList2021 */
361
+ type: z.ZodLiteral<"StatusList2021">;
362
+ /** Purpose of the status list */
363
+ statusPurpose: z.ZodEnum<["revocation", "suspension"]>;
364
+ /**
365
+ * Encoded bitstring
366
+ *
367
+ * Base64url-encoded and GZIP-compressed bitstring.
368
+ * Each bit represents the status of a credential:
369
+ * - 0: Not revoked/suspended
370
+ * - 1: Revoked/suspended
371
+ */
372
+ encodedList: z.ZodString;
373
+ }, "strip", z.ZodTypeAny, {
374
+ type: "StatusList2021";
375
+ statusPurpose: "revocation" | "suspension";
376
+ encodedList: string;
377
+ id?: string | undefined;
378
+ }, {
379
+ type: "StatusList2021";
380
+ statusPurpose: "revocation" | "suspension";
381
+ encodedList: string;
382
+ id?: string | undefined;
383
+ }>;
384
+ /** Cryptographic proof (optional) */
385
+ proof: z.ZodOptional<z.ZodObject<{
386
+ type: z.ZodString;
387
+ created: z.ZodOptional<z.ZodString>;
388
+ verificationMethod: z.ZodOptional<z.ZodString>;
389
+ proofPurpose: z.ZodOptional<z.ZodString>;
390
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
391
+ type: z.ZodString;
392
+ created: z.ZodOptional<z.ZodString>;
393
+ verificationMethod: z.ZodOptional<z.ZodString>;
394
+ proofPurpose: z.ZodOptional<z.ZodString>;
395
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
396
+ type: z.ZodString;
397
+ created: z.ZodOptional<z.ZodString>;
398
+ verificationMethod: z.ZodOptional<z.ZodString>;
399
+ proofPurpose: z.ZodOptional<z.ZodString>;
400
+ }, z.ZodTypeAny, "passthrough">>>;
401
+ }, z.ZodTypeAny, "passthrough">>;
402
+ /**
403
+ * Helper Types for Bitstring Operations
404
+ *
405
+ * These types define the interface for bitstring encode/decode operations.
406
+ * Actual implementation would be in a separate utility module.
407
+ */
408
+ /**
409
+ * Bitstring encoding options
410
+ */
411
+ export interface BitStringEncodeOptions {
412
+ /** Total size of the bitstring (number of bits) */
413
+ size: number;
414
+ /** Positions to set to 1 (revoked/suspended) */
415
+ setBits?: number[];
416
+ }
417
+ /**
418
+ * Bitstring decoding result
419
+ */
420
+ export interface BitStringDecodeResult {
421
+ /** Total size of the bitstring */
422
+ size: number;
423
+ /** Positions that are set to 1 */
424
+ setBits: number[];
425
+ /** Check if a specific index is set */
426
+ isSet: (index: number) => boolean;
427
+ }
428
+ /**
429
+ * Cache entry for StatusList2021 credentials
430
+ *
431
+ * Used for efficient caching of status list credentials with ETag support
432
+ */
433
+ export interface StatusListCacheEntry {
434
+ /** The cached status list credential */
435
+ credential: StatusList2021Credential;
436
+ /** ETag from the HTTP response (if applicable) */
437
+ etag?: string;
438
+ /** Timestamp when cached (milliseconds since epoch) */
439
+ cachedAt: number;
440
+ /** TTL in seconds */
441
+ ttlSec: number;
442
+ /** Expires at timestamp (milliseconds since epoch) */
443
+ expiresAt: number;
444
+ }
445
+ /**
446
+ * Status checking result
447
+ */
448
+ export interface StatusCheckResult {
449
+ /** Whether the credential is valid (not revoked/suspended) */
450
+ valid: boolean;
451
+ /** The status (active, revoked, suspended) */
452
+ status: 'active' | 'revoked' | 'suspended';
453
+ /** Optional reason for status */
454
+ reason?: string;
455
+ /** Timestamp when checked */
456
+ checkedAt: number;
457
+ /** Whether result came from cache */
458
+ fromCache?: boolean;
459
+ }
460
+ /**
461
+ * Helper to create a minimal status list credential structure
462
+ *
463
+ * This is a type-safe helper, actual credential creation requires
464
+ * proper signing and encoding implementation.
465
+ *
466
+ * @param config - Configuration for the status list credential
467
+ * @returns Partial credential structure (needs proof to be complete)
468
+ */
469
+ export declare function createStatusListCredentialStructure(config: {
470
+ id: string;
471
+ issuer: string | {
472
+ id: string;
473
+ };
474
+ statusPurpose: StatusPurpose;
475
+ encodedList: string;
476
+ }): Omit<StatusList2021Credential, 'proof'>;
477
+ /**
478
+ * Constants
479
+ */
480
+ /**
481
+ * Default cache TTL for status list credentials (in seconds)
482
+ * As per spec recommendation
483
+ */
484
+ export declare const DEFAULT_STATUSLIST_CACHE_TTL_SEC = 60;
485
+ /**
486
+ * Maximum reasonable bitstring size
487
+ * Used for validation to prevent memory exhaustion
488
+ */
489
+ export declare const MAX_STATUSLIST_SIZE = 1000000;
490
+ /**
491
+ * StatusList2021 context URL
492
+ */
493
+ export declare const STATUSLIST_2021_CONTEXT = "https://w3id.org/vc/status-list/2021/v1";
@@ -0,0 +1,132 @@
1
+ "use strict";
2
+ /**
3
+ * StatusList2021 Types and Schemas
4
+ *
5
+ * Implementation of the W3C StatusList2021 specification for credential status.
6
+ * Provides types for status list credentials and helpers for bitstring operations.
7
+ *
8
+ * Related Spec: W3C StatusList2021
9
+ * Python Reference: Credential-Documentation.md (StatusList2021 section)
10
+ */
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.STATUSLIST_2021_CONTEXT = exports.MAX_STATUSLIST_SIZE = exports.DEFAULT_STATUSLIST_CACHE_TTL_SEC = exports.StatusList2021CredentialSchema = exports.StatusList2021CredentialSubjectSchema = void 0;
13
+ exports.validateStatusList2021Credential = validateStatusList2021Credential;
14
+ exports.createStatusListCredentialStructure = createStatusListCredentialStructure;
15
+ const zod_1 = require("zod");
16
+ const schemas_js_1 = require("./schemas.js");
17
+ /**
18
+ * Status List Credential Subject Schema
19
+ *
20
+ * The credential subject of a StatusList2021Credential
21
+ */
22
+ exports.StatusList2021CredentialSubjectSchema = zod_1.z.object({
23
+ /** Optional identifier for the status list */
24
+ id: zod_1.z.string().optional(),
25
+ /** Type MUST be StatusList2021 */
26
+ type: zod_1.z.literal('StatusList2021'),
27
+ /** Purpose of the status list */
28
+ statusPurpose: zod_1.z.enum(['revocation', 'suspension']),
29
+ /**
30
+ * Encoded bitstring
31
+ *
32
+ * Base64url-encoded and GZIP-compressed bitstring.
33
+ * Each bit represents the status of a credential:
34
+ * - 0: Not revoked/suspended
35
+ * - 1: Revoked/suspended
36
+ */
37
+ encodedList: zod_1.z.string().regex(/^[A-Za-z0-9_-]+$/, {
38
+ message: 'encodedList must be base64url encoded',
39
+ }),
40
+ });
41
+ /**
42
+ * StatusList2021 Credential Schema
43
+ *
44
+ * A credential that contains a status list for checking revocation/suspension
45
+ * of other credentials.
46
+ */
47
+ exports.StatusList2021CredentialSchema = zod_1.z.object({
48
+ /** JSON-LD context */
49
+ '@context': schemas_js_1.ContextSchema.refine((contexts) => {
50
+ // Must include both base VC context and StatusList context
51
+ return (contexts.length >= 2 &&
52
+ typeof contexts[0] === 'string' &&
53
+ contexts[0] === 'https://www.w3.org/2018/credentials/v1' &&
54
+ (contexts.includes('https://w3id.org/vc/status-list/2021/v1') ||
55
+ contexts.some((ctx) => typeof ctx === 'object' &&
56
+ ctx['StatusList2021Credential'] !== undefined)));
57
+ }, {
58
+ message: '@context must include VC context and StatusList2021 context',
59
+ }),
60
+ /** Unique identifier for the status list credential */
61
+ id: zod_1.z.string().url(),
62
+ /** Type MUST include VerifiableCredential and StatusList2021Credential */
63
+ type: zod_1.z
64
+ .tuple([zod_1.z.literal('VerifiableCredential'), zod_1.z.literal('StatusList2021Credential')])
65
+ .or(zod_1.z.array(zod_1.z.string()).refine((types) => types.includes('VerifiableCredential') &&
66
+ types.includes('StatusList2021Credential'), {
67
+ message: 'type must include "VerifiableCredential" and "StatusList2021Credential"',
68
+ })),
69
+ /** Issuer of the status list credential */
70
+ issuer: schemas_js_1.IssuerSchema,
71
+ /** Issuance date in ISO 8601 format */
72
+ issuanceDate: zod_1.z.string().datetime(),
73
+ /** The status list credential subject */
74
+ credentialSubject: exports.StatusList2021CredentialSubjectSchema,
75
+ /** Cryptographic proof (optional) */
76
+ proof: schemas_js_1.ProofSchema.optional(),
77
+ }).passthrough();
78
+ /**
79
+ * Validation Helpers
80
+ */
81
+ /**
82
+ * Validate a StatusList2021 credential
83
+ *
84
+ * @param credential - The credential to validate
85
+ * @returns Validation result with parsed credential or errors
86
+ */
87
+ function validateStatusList2021Credential(credential) {
88
+ return exports.StatusList2021CredentialSchema.safeParse(credential);
89
+ }
90
+ /**
91
+ * Helper to create a minimal status list credential structure
92
+ *
93
+ * This is a type-safe helper, actual credential creation requires
94
+ * proper signing and encoding implementation.
95
+ *
96
+ * @param config - Configuration for the status list credential
97
+ * @returns Partial credential structure (needs proof to be complete)
98
+ */
99
+ function createStatusListCredentialStructure(config) {
100
+ return {
101
+ '@context': [
102
+ 'https://www.w3.org/2018/credentials/v1',
103
+ 'https://w3id.org/vc/status-list/2021/v1',
104
+ ],
105
+ id: config.id,
106
+ type: ['VerifiableCredential', 'StatusList2021Credential'],
107
+ issuer: config.issuer,
108
+ issuanceDate: new Date().toISOString(),
109
+ credentialSubject: {
110
+ type: 'StatusList2021',
111
+ statusPurpose: config.statusPurpose,
112
+ encodedList: config.encodedList,
113
+ },
114
+ };
115
+ }
116
+ /**
117
+ * Constants
118
+ */
119
+ /**
120
+ * Default cache TTL for status list credentials (in seconds)
121
+ * As per spec recommendation
122
+ */
123
+ exports.DEFAULT_STATUSLIST_CACHE_TTL_SEC = 60;
124
+ /**
125
+ * Maximum reasonable bitstring size
126
+ * Used for validation to prevent memory exhaustion
127
+ */
128
+ exports.MAX_STATUSLIST_SIZE = 1000000; // 1 million entries
129
+ /**
130
+ * StatusList2021 context URL
131
+ */
132
+ exports.STATUSLIST_2021_CONTEXT = 'https://w3id.org/vc/status-list/2021/v1';
@@ -1,4 +1,7 @@
1
1
  import { z } from "zod";
2
+ /**
3
+ * Verifier middleware schemas and headers
4
+ */
2
5
  export declare const AgentContextSchema: z.ZodObject<{
3
6
  did: z.ZodString;
4
7
  kid: z.ZodString;
package/dist/verifier.js CHANGED
@@ -2,6 +2,9 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ERROR_HTTP_STATUS = exports.VERIFIER_ERROR_CODES = exports.AGENT_HEADERS = exports.StructuredErrorSchema = exports.VerifierResultSchema = exports.AgentContextSchema = void 0;
4
4
  const zod_1 = require("zod");
5
+ /**
6
+ * Verifier middleware schemas and headers
7
+ */
5
8
  exports.AgentContextSchema = zod_1.z.object({
6
9
  did: zod_1.z.string().min(1),
7
10
  kid: zod_1.z.string().min(1),
@@ -39,6 +42,7 @@ exports.StructuredErrorSchema = zod_1.z.object({
39
42
  })
40
43
  .optional(),
41
44
  });
45
+ // Header constants (frozen names)
42
46
  exports.AGENT_HEADERS = {
43
47
  DID: "X-Agent-DID",
44
48
  KEY_ID: "X-Agent-KeyId",
@@ -50,6 +54,7 @@ exports.AGENT_HEADERS = {
50
54
  REGISTRY: "X-Agent-Registry",
51
55
  VERIFIED_AT: "X-Agent-Verified-At",
52
56
  };
57
+ // Verifier-specific error codes
53
58
  exports.VERIFIER_ERROR_CODES = {
54
59
  PROOF_INVALID_TS: "XMCP_I_PROOF_INVALID_TS",
55
60
  PROOF_FUTURE_TS: "XMCP_I_PROOF_FUTURE_TS",
@@ -58,6 +63,7 @@ exports.VERIFIER_ERROR_CODES = {
58
63
  SESSION_IDLE_EXPIRED: "XMCP_I_SESSION_IDLE_EXPIRED",
59
64
  SERVER_TIME_INVALID: "XMCP_I_SERVER_TIME_INVALID",
60
65
  };
66
+ // HTTP status mappings
61
67
  exports.ERROR_HTTP_STATUS = {
62
68
  XMCP_I_EBADPROOF: 403,
63
69
  XMCP_I_ENOIDENTITY: 500,
@@ -67,6 +73,7 @@ exports.ERROR_HTTP_STATUS = {
67
73
  XMCP_I_ECLAIM: 400,
68
74
  XMCP_I_ECONFIG: 500,
69
75
  XMCP_I_ERUNTIME: 500,
76
+ // Verifier-specific codes
70
77
  [exports.VERIFIER_ERROR_CODES.PROOF_INVALID_TS]: 403,
71
78
  [exports.VERIFIER_ERROR_CODES.PROOF_FUTURE_TS]: 403,
72
79
  [exports.VERIFIER_ERROR_CODES.PROOF_TOO_OLD]: 403,