@glinr/theauth 0.4.2
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/LICENSE +21 -0
- package/README.md +202 -0
- package/dist/a2a/index.d.ts +2341 -0
- package/dist/a2a/index.js +826 -0
- package/dist/a2a/index.js.map +1 -0
- package/dist/agent/index.d.ts +32 -0
- package/dist/agent/index.js +795 -0
- package/dist/agent/index.js.map +1 -0
- package/dist/audit/index.d.ts +24 -0
- package/dist/audit/index.js +641 -0
- package/dist/audit/index.js.map +1 -0
- package/dist/auth/index.d.ts +3466 -0
- package/dist/auth/index.js +16139 -0
- package/dist/auth/index.js.map +1 -0
- package/dist/crypto/index.d.ts +55 -0
- package/dist/crypto/index.js +186 -0
- package/dist/crypto/index.js.map +1 -0
- package/dist/index.d.ts +1711 -0
- package/dist/index.js +23160 -0
- package/dist/index.js.map +1 -0
- package/dist/mcp/index.d.ts +274 -0
- package/dist/mcp/index.js +1262 -0
- package/dist/mcp/index.js.map +1 -0
- package/dist/permission/index.d.ts +89 -0
- package/dist/permission/index.js +801 -0
- package/dist/permission/index.js.map +1 -0
- package/dist/redirect/index.d.ts +118 -0
- package/dist/redirect/index.js +292 -0
- package/dist/redirect/index.js.map +1 -0
- package/dist/standards/index.d.ts +139 -0
- package/dist/standards/index.js +72 -0
- package/dist/standards/index.js.map +1 -0
- package/dist/types-BiUe9e8u.d.ts +426 -0
- package/dist/types-D1sBnWrs.d.ts +9636 -0
- package/dist/types-RJPOU4un.d.ts +9636 -0
- package/dist/vc/index.d.ts +989 -0
- package/dist/vc/index.js +692 -0
- package/dist/vc/index.js.map +1 -0
- package/package.json +139 -0
|
@@ -0,0 +1,989 @@
|
|
|
1
|
+
import { l as AuditEntry } from '../types-D1sBnWrs.js';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import { R as Result } from '../types-BiUe9e8u.js';
|
|
4
|
+
import 'drizzle-orm/sqlite-core';
|
|
5
|
+
import '../redirect/index.js';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* W3C Verifiable Credentials Data Model 2.0 types for TheAuth.
|
|
9
|
+
*
|
|
10
|
+
* Defines Zod-validated schemas for credentials, presentations,
|
|
11
|
+
* proofs, and credential status. Agent-centric: the credential
|
|
12
|
+
* subject carries agent identity, permissions, trust level, and
|
|
13
|
+
* delegation scope.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
declare const VC_CONTEXT_V2 = "https://www.w3.org/ns/credentials/v2";
|
|
17
|
+
declare const VC_CONTEXT_V1 = "https://www.w3.org/2018/credentials/v1";
|
|
18
|
+
declare const VC_TYPE_CREDENTIAL = "VerifiableCredential";
|
|
19
|
+
declare const VC_TYPE_PRESENTATION = "VerifiablePresentation";
|
|
20
|
+
declare const KAVACH_AGENT_CREDENTIAL = "KavachAgentCredential";
|
|
21
|
+
declare const KAVACH_PERMISSION_CREDENTIAL = "KavachPermissionCredential";
|
|
22
|
+
declare const KAVACH_DELEGATION_CREDENTIAL = "KavachDelegationCredential";
|
|
23
|
+
declare const ProofSchema: z.ZodObject<{
|
|
24
|
+
type: z.ZodEnum<["Ed25519Signature2020", "JsonWebSignature2020"]>;
|
|
25
|
+
created: z.ZodString;
|
|
26
|
+
verificationMethod: z.ZodString;
|
|
27
|
+
proofPurpose: z.ZodEnum<["assertionMethod", "authentication"]>;
|
|
28
|
+
proofValue: z.ZodOptional<z.ZodString>;
|
|
29
|
+
jws: z.ZodOptional<z.ZodString>;
|
|
30
|
+
}, "strip", z.ZodTypeAny, {
|
|
31
|
+
type: "Ed25519Signature2020" | "JsonWebSignature2020";
|
|
32
|
+
created: string;
|
|
33
|
+
verificationMethod: string;
|
|
34
|
+
proofPurpose: "authentication" | "assertionMethod";
|
|
35
|
+
jws?: string | undefined;
|
|
36
|
+
proofValue?: string | undefined;
|
|
37
|
+
}, {
|
|
38
|
+
type: "Ed25519Signature2020" | "JsonWebSignature2020";
|
|
39
|
+
created: string;
|
|
40
|
+
verificationMethod: string;
|
|
41
|
+
proofPurpose: "authentication" | "assertionMethod";
|
|
42
|
+
jws?: string | undefined;
|
|
43
|
+
proofValue?: string | undefined;
|
|
44
|
+
}>;
|
|
45
|
+
type Proof = z.infer<typeof ProofSchema>;
|
|
46
|
+
declare const CredentialStatusSchema: z.ZodObject<{
|
|
47
|
+
id: z.ZodString;
|
|
48
|
+
type: z.ZodString;
|
|
49
|
+
statusPurpose: z.ZodEnum<["revocation", "suspension"]>;
|
|
50
|
+
statusListIndex: z.ZodNumber;
|
|
51
|
+
statusListCredential: z.ZodString;
|
|
52
|
+
}, "strip", z.ZodTypeAny, {
|
|
53
|
+
id: string;
|
|
54
|
+
type: string;
|
|
55
|
+
statusPurpose: "revocation" | "suspension";
|
|
56
|
+
statusListIndex: number;
|
|
57
|
+
statusListCredential: string;
|
|
58
|
+
}, {
|
|
59
|
+
id: string;
|
|
60
|
+
type: string;
|
|
61
|
+
statusPurpose: "revocation" | "suspension";
|
|
62
|
+
statusListIndex: number;
|
|
63
|
+
statusListCredential: string;
|
|
64
|
+
}>;
|
|
65
|
+
type CredentialStatus = z.infer<typeof CredentialStatusSchema>;
|
|
66
|
+
declare const CredentialSubjectSchema: z.ZodObject<{
|
|
67
|
+
id: z.ZodOptional<z.ZodString>;
|
|
68
|
+
agentId: z.ZodOptional<z.ZodString>;
|
|
69
|
+
permissions: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
70
|
+
trustLevel: z.ZodOptional<z.ZodNumber>;
|
|
71
|
+
delegationScope: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
72
|
+
delegationChain: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
73
|
+
delegator: z.ZodString;
|
|
74
|
+
delegatee: z.ZodString;
|
|
75
|
+
permissions: z.ZodArray<z.ZodString, "many">;
|
|
76
|
+
createdAt: z.ZodString;
|
|
77
|
+
}, "strip", z.ZodTypeAny, {
|
|
78
|
+
createdAt: string;
|
|
79
|
+
permissions: string[];
|
|
80
|
+
delegator: string;
|
|
81
|
+
delegatee: string;
|
|
82
|
+
}, {
|
|
83
|
+
createdAt: string;
|
|
84
|
+
permissions: string[];
|
|
85
|
+
delegator: string;
|
|
86
|
+
delegatee: string;
|
|
87
|
+
}>, "many">>;
|
|
88
|
+
name: z.ZodOptional<z.ZodString>;
|
|
89
|
+
type: z.ZodOptional<z.ZodString>;
|
|
90
|
+
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
|
91
|
+
id: z.ZodOptional<z.ZodString>;
|
|
92
|
+
agentId: z.ZodOptional<z.ZodString>;
|
|
93
|
+
permissions: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
94
|
+
trustLevel: z.ZodOptional<z.ZodNumber>;
|
|
95
|
+
delegationScope: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
96
|
+
delegationChain: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
97
|
+
delegator: z.ZodString;
|
|
98
|
+
delegatee: z.ZodString;
|
|
99
|
+
permissions: z.ZodArray<z.ZodString, "many">;
|
|
100
|
+
createdAt: z.ZodString;
|
|
101
|
+
}, "strip", z.ZodTypeAny, {
|
|
102
|
+
createdAt: string;
|
|
103
|
+
permissions: string[];
|
|
104
|
+
delegator: string;
|
|
105
|
+
delegatee: string;
|
|
106
|
+
}, {
|
|
107
|
+
createdAt: string;
|
|
108
|
+
permissions: string[];
|
|
109
|
+
delegator: string;
|
|
110
|
+
delegatee: string;
|
|
111
|
+
}>, "many">>;
|
|
112
|
+
name: z.ZodOptional<z.ZodString>;
|
|
113
|
+
type: z.ZodOptional<z.ZodString>;
|
|
114
|
+
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
115
|
+
id: z.ZodOptional<z.ZodString>;
|
|
116
|
+
agentId: z.ZodOptional<z.ZodString>;
|
|
117
|
+
permissions: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
118
|
+
trustLevel: z.ZodOptional<z.ZodNumber>;
|
|
119
|
+
delegationScope: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
120
|
+
delegationChain: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
121
|
+
delegator: z.ZodString;
|
|
122
|
+
delegatee: z.ZodString;
|
|
123
|
+
permissions: z.ZodArray<z.ZodString, "many">;
|
|
124
|
+
createdAt: z.ZodString;
|
|
125
|
+
}, "strip", z.ZodTypeAny, {
|
|
126
|
+
createdAt: string;
|
|
127
|
+
permissions: string[];
|
|
128
|
+
delegator: string;
|
|
129
|
+
delegatee: string;
|
|
130
|
+
}, {
|
|
131
|
+
createdAt: string;
|
|
132
|
+
permissions: string[];
|
|
133
|
+
delegator: string;
|
|
134
|
+
delegatee: string;
|
|
135
|
+
}>, "many">>;
|
|
136
|
+
name: z.ZodOptional<z.ZodString>;
|
|
137
|
+
type: z.ZodOptional<z.ZodString>;
|
|
138
|
+
}, z.ZodTypeAny, "passthrough">>;
|
|
139
|
+
type CredentialSubject = z.infer<typeof CredentialSubjectSchema>;
|
|
140
|
+
declare const VerifiableCredentialSchema: z.ZodObject<{
|
|
141
|
+
"@context": z.ZodArray<z.ZodString, "many">;
|
|
142
|
+
id: z.ZodOptional<z.ZodString>;
|
|
143
|
+
type: z.ZodArray<z.ZodString, "many">;
|
|
144
|
+
issuer: z.ZodUnion<[z.ZodString, z.ZodObject<{
|
|
145
|
+
id: z.ZodString;
|
|
146
|
+
name: z.ZodOptional<z.ZodString>;
|
|
147
|
+
}, "strip", z.ZodTypeAny, {
|
|
148
|
+
id: string;
|
|
149
|
+
name?: string | undefined;
|
|
150
|
+
}, {
|
|
151
|
+
id: string;
|
|
152
|
+
name?: string | undefined;
|
|
153
|
+
}>]>;
|
|
154
|
+
issuanceDate: z.ZodString;
|
|
155
|
+
expirationDate: z.ZodOptional<z.ZodString>;
|
|
156
|
+
credentialSubject: z.ZodObject<{
|
|
157
|
+
id: z.ZodOptional<z.ZodString>;
|
|
158
|
+
agentId: z.ZodOptional<z.ZodString>;
|
|
159
|
+
permissions: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
160
|
+
trustLevel: z.ZodOptional<z.ZodNumber>;
|
|
161
|
+
delegationScope: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
162
|
+
delegationChain: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
163
|
+
delegator: z.ZodString;
|
|
164
|
+
delegatee: z.ZodString;
|
|
165
|
+
permissions: z.ZodArray<z.ZodString, "many">;
|
|
166
|
+
createdAt: z.ZodString;
|
|
167
|
+
}, "strip", z.ZodTypeAny, {
|
|
168
|
+
createdAt: string;
|
|
169
|
+
permissions: string[];
|
|
170
|
+
delegator: string;
|
|
171
|
+
delegatee: string;
|
|
172
|
+
}, {
|
|
173
|
+
createdAt: string;
|
|
174
|
+
permissions: string[];
|
|
175
|
+
delegator: string;
|
|
176
|
+
delegatee: string;
|
|
177
|
+
}>, "many">>;
|
|
178
|
+
name: z.ZodOptional<z.ZodString>;
|
|
179
|
+
type: z.ZodOptional<z.ZodString>;
|
|
180
|
+
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
|
181
|
+
id: z.ZodOptional<z.ZodString>;
|
|
182
|
+
agentId: z.ZodOptional<z.ZodString>;
|
|
183
|
+
permissions: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
184
|
+
trustLevel: z.ZodOptional<z.ZodNumber>;
|
|
185
|
+
delegationScope: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
186
|
+
delegationChain: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
187
|
+
delegator: z.ZodString;
|
|
188
|
+
delegatee: z.ZodString;
|
|
189
|
+
permissions: z.ZodArray<z.ZodString, "many">;
|
|
190
|
+
createdAt: z.ZodString;
|
|
191
|
+
}, "strip", z.ZodTypeAny, {
|
|
192
|
+
createdAt: string;
|
|
193
|
+
permissions: string[];
|
|
194
|
+
delegator: string;
|
|
195
|
+
delegatee: string;
|
|
196
|
+
}, {
|
|
197
|
+
createdAt: string;
|
|
198
|
+
permissions: string[];
|
|
199
|
+
delegator: string;
|
|
200
|
+
delegatee: string;
|
|
201
|
+
}>, "many">>;
|
|
202
|
+
name: z.ZodOptional<z.ZodString>;
|
|
203
|
+
type: z.ZodOptional<z.ZodString>;
|
|
204
|
+
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
205
|
+
id: z.ZodOptional<z.ZodString>;
|
|
206
|
+
agentId: z.ZodOptional<z.ZodString>;
|
|
207
|
+
permissions: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
208
|
+
trustLevel: z.ZodOptional<z.ZodNumber>;
|
|
209
|
+
delegationScope: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
210
|
+
delegationChain: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
211
|
+
delegator: z.ZodString;
|
|
212
|
+
delegatee: z.ZodString;
|
|
213
|
+
permissions: z.ZodArray<z.ZodString, "many">;
|
|
214
|
+
createdAt: z.ZodString;
|
|
215
|
+
}, "strip", z.ZodTypeAny, {
|
|
216
|
+
createdAt: string;
|
|
217
|
+
permissions: string[];
|
|
218
|
+
delegator: string;
|
|
219
|
+
delegatee: string;
|
|
220
|
+
}, {
|
|
221
|
+
createdAt: string;
|
|
222
|
+
permissions: string[];
|
|
223
|
+
delegator: string;
|
|
224
|
+
delegatee: string;
|
|
225
|
+
}>, "many">>;
|
|
226
|
+
name: z.ZodOptional<z.ZodString>;
|
|
227
|
+
type: z.ZodOptional<z.ZodString>;
|
|
228
|
+
}, z.ZodTypeAny, "passthrough">>;
|
|
229
|
+
credentialStatus: z.ZodOptional<z.ZodObject<{
|
|
230
|
+
id: z.ZodString;
|
|
231
|
+
type: z.ZodString;
|
|
232
|
+
statusPurpose: z.ZodEnum<["revocation", "suspension"]>;
|
|
233
|
+
statusListIndex: z.ZodNumber;
|
|
234
|
+
statusListCredential: z.ZodString;
|
|
235
|
+
}, "strip", z.ZodTypeAny, {
|
|
236
|
+
id: string;
|
|
237
|
+
type: string;
|
|
238
|
+
statusPurpose: "revocation" | "suspension";
|
|
239
|
+
statusListIndex: number;
|
|
240
|
+
statusListCredential: string;
|
|
241
|
+
}, {
|
|
242
|
+
id: string;
|
|
243
|
+
type: string;
|
|
244
|
+
statusPurpose: "revocation" | "suspension";
|
|
245
|
+
statusListIndex: number;
|
|
246
|
+
statusListCredential: string;
|
|
247
|
+
}>>;
|
|
248
|
+
proof: z.ZodOptional<z.ZodObject<{
|
|
249
|
+
type: z.ZodEnum<["Ed25519Signature2020", "JsonWebSignature2020"]>;
|
|
250
|
+
created: z.ZodString;
|
|
251
|
+
verificationMethod: z.ZodString;
|
|
252
|
+
proofPurpose: z.ZodEnum<["assertionMethod", "authentication"]>;
|
|
253
|
+
proofValue: z.ZodOptional<z.ZodString>;
|
|
254
|
+
jws: z.ZodOptional<z.ZodString>;
|
|
255
|
+
}, "strip", z.ZodTypeAny, {
|
|
256
|
+
type: "Ed25519Signature2020" | "JsonWebSignature2020";
|
|
257
|
+
created: string;
|
|
258
|
+
verificationMethod: string;
|
|
259
|
+
proofPurpose: "authentication" | "assertionMethod";
|
|
260
|
+
jws?: string | undefined;
|
|
261
|
+
proofValue?: string | undefined;
|
|
262
|
+
}, {
|
|
263
|
+
type: "Ed25519Signature2020" | "JsonWebSignature2020";
|
|
264
|
+
created: string;
|
|
265
|
+
verificationMethod: string;
|
|
266
|
+
proofPurpose: "authentication" | "assertionMethod";
|
|
267
|
+
jws?: string | undefined;
|
|
268
|
+
proofValue?: string | undefined;
|
|
269
|
+
}>>;
|
|
270
|
+
}, "strip", z.ZodTypeAny, {
|
|
271
|
+
type: string[];
|
|
272
|
+
issuer: string | {
|
|
273
|
+
id: string;
|
|
274
|
+
name?: string | undefined;
|
|
275
|
+
};
|
|
276
|
+
"@context": string[];
|
|
277
|
+
issuanceDate: string;
|
|
278
|
+
credentialSubject: {
|
|
279
|
+
name?: string | undefined;
|
|
280
|
+
id?: string | undefined;
|
|
281
|
+
type?: string | undefined;
|
|
282
|
+
agentId?: string | undefined;
|
|
283
|
+
permissions?: string[] | undefined;
|
|
284
|
+
trustLevel?: number | undefined;
|
|
285
|
+
delegationScope?: string[] | undefined;
|
|
286
|
+
delegationChain?: {
|
|
287
|
+
createdAt: string;
|
|
288
|
+
permissions: string[];
|
|
289
|
+
delegator: string;
|
|
290
|
+
delegatee: string;
|
|
291
|
+
}[] | undefined;
|
|
292
|
+
} & {
|
|
293
|
+
[k: string]: unknown;
|
|
294
|
+
};
|
|
295
|
+
id?: string | undefined;
|
|
296
|
+
expirationDate?: string | undefined;
|
|
297
|
+
credentialStatus?: {
|
|
298
|
+
id: string;
|
|
299
|
+
type: string;
|
|
300
|
+
statusPurpose: "revocation" | "suspension";
|
|
301
|
+
statusListIndex: number;
|
|
302
|
+
statusListCredential: string;
|
|
303
|
+
} | undefined;
|
|
304
|
+
proof?: {
|
|
305
|
+
type: "Ed25519Signature2020" | "JsonWebSignature2020";
|
|
306
|
+
created: string;
|
|
307
|
+
verificationMethod: string;
|
|
308
|
+
proofPurpose: "authentication" | "assertionMethod";
|
|
309
|
+
jws?: string | undefined;
|
|
310
|
+
proofValue?: string | undefined;
|
|
311
|
+
} | undefined;
|
|
312
|
+
}, {
|
|
313
|
+
type: string[];
|
|
314
|
+
issuer: string | {
|
|
315
|
+
id: string;
|
|
316
|
+
name?: string | undefined;
|
|
317
|
+
};
|
|
318
|
+
"@context": string[];
|
|
319
|
+
issuanceDate: string;
|
|
320
|
+
credentialSubject: {
|
|
321
|
+
name?: string | undefined;
|
|
322
|
+
id?: string | undefined;
|
|
323
|
+
type?: string | undefined;
|
|
324
|
+
agentId?: string | undefined;
|
|
325
|
+
permissions?: string[] | undefined;
|
|
326
|
+
trustLevel?: number | undefined;
|
|
327
|
+
delegationScope?: string[] | undefined;
|
|
328
|
+
delegationChain?: {
|
|
329
|
+
createdAt: string;
|
|
330
|
+
permissions: string[];
|
|
331
|
+
delegator: string;
|
|
332
|
+
delegatee: string;
|
|
333
|
+
}[] | undefined;
|
|
334
|
+
} & {
|
|
335
|
+
[k: string]: unknown;
|
|
336
|
+
};
|
|
337
|
+
id?: string | undefined;
|
|
338
|
+
expirationDate?: string | undefined;
|
|
339
|
+
credentialStatus?: {
|
|
340
|
+
id: string;
|
|
341
|
+
type: string;
|
|
342
|
+
statusPurpose: "revocation" | "suspension";
|
|
343
|
+
statusListIndex: number;
|
|
344
|
+
statusListCredential: string;
|
|
345
|
+
} | undefined;
|
|
346
|
+
proof?: {
|
|
347
|
+
type: "Ed25519Signature2020" | "JsonWebSignature2020";
|
|
348
|
+
created: string;
|
|
349
|
+
verificationMethod: string;
|
|
350
|
+
proofPurpose: "authentication" | "assertionMethod";
|
|
351
|
+
jws?: string | undefined;
|
|
352
|
+
proofValue?: string | undefined;
|
|
353
|
+
} | undefined;
|
|
354
|
+
}>;
|
|
355
|
+
type VerifiableCredential = z.infer<typeof VerifiableCredentialSchema>;
|
|
356
|
+
declare const VerifiablePresentationSchema: z.ZodObject<{
|
|
357
|
+
"@context": z.ZodArray<z.ZodString, "many">;
|
|
358
|
+
id: z.ZodOptional<z.ZodString>;
|
|
359
|
+
type: z.ZodArray<z.ZodString, "many">;
|
|
360
|
+
holder: z.ZodOptional<z.ZodString>;
|
|
361
|
+
verifiableCredential: z.ZodArray<z.ZodObject<{
|
|
362
|
+
"@context": z.ZodArray<z.ZodString, "many">;
|
|
363
|
+
id: z.ZodOptional<z.ZodString>;
|
|
364
|
+
type: z.ZodArray<z.ZodString, "many">;
|
|
365
|
+
issuer: z.ZodUnion<[z.ZodString, z.ZodObject<{
|
|
366
|
+
id: z.ZodString;
|
|
367
|
+
name: z.ZodOptional<z.ZodString>;
|
|
368
|
+
}, "strip", z.ZodTypeAny, {
|
|
369
|
+
id: string;
|
|
370
|
+
name?: string | undefined;
|
|
371
|
+
}, {
|
|
372
|
+
id: string;
|
|
373
|
+
name?: string | undefined;
|
|
374
|
+
}>]>;
|
|
375
|
+
issuanceDate: z.ZodString;
|
|
376
|
+
expirationDate: z.ZodOptional<z.ZodString>;
|
|
377
|
+
credentialSubject: z.ZodObject<{
|
|
378
|
+
id: z.ZodOptional<z.ZodString>;
|
|
379
|
+
agentId: z.ZodOptional<z.ZodString>;
|
|
380
|
+
permissions: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
381
|
+
trustLevel: z.ZodOptional<z.ZodNumber>;
|
|
382
|
+
delegationScope: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
383
|
+
delegationChain: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
384
|
+
delegator: z.ZodString;
|
|
385
|
+
delegatee: z.ZodString;
|
|
386
|
+
permissions: z.ZodArray<z.ZodString, "many">;
|
|
387
|
+
createdAt: z.ZodString;
|
|
388
|
+
}, "strip", z.ZodTypeAny, {
|
|
389
|
+
createdAt: string;
|
|
390
|
+
permissions: string[];
|
|
391
|
+
delegator: string;
|
|
392
|
+
delegatee: string;
|
|
393
|
+
}, {
|
|
394
|
+
createdAt: string;
|
|
395
|
+
permissions: string[];
|
|
396
|
+
delegator: string;
|
|
397
|
+
delegatee: string;
|
|
398
|
+
}>, "many">>;
|
|
399
|
+
name: z.ZodOptional<z.ZodString>;
|
|
400
|
+
type: z.ZodOptional<z.ZodString>;
|
|
401
|
+
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
|
402
|
+
id: z.ZodOptional<z.ZodString>;
|
|
403
|
+
agentId: z.ZodOptional<z.ZodString>;
|
|
404
|
+
permissions: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
405
|
+
trustLevel: z.ZodOptional<z.ZodNumber>;
|
|
406
|
+
delegationScope: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
407
|
+
delegationChain: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
408
|
+
delegator: z.ZodString;
|
|
409
|
+
delegatee: z.ZodString;
|
|
410
|
+
permissions: z.ZodArray<z.ZodString, "many">;
|
|
411
|
+
createdAt: z.ZodString;
|
|
412
|
+
}, "strip", z.ZodTypeAny, {
|
|
413
|
+
createdAt: string;
|
|
414
|
+
permissions: string[];
|
|
415
|
+
delegator: string;
|
|
416
|
+
delegatee: string;
|
|
417
|
+
}, {
|
|
418
|
+
createdAt: string;
|
|
419
|
+
permissions: string[];
|
|
420
|
+
delegator: string;
|
|
421
|
+
delegatee: string;
|
|
422
|
+
}>, "many">>;
|
|
423
|
+
name: z.ZodOptional<z.ZodString>;
|
|
424
|
+
type: z.ZodOptional<z.ZodString>;
|
|
425
|
+
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
426
|
+
id: z.ZodOptional<z.ZodString>;
|
|
427
|
+
agentId: z.ZodOptional<z.ZodString>;
|
|
428
|
+
permissions: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
429
|
+
trustLevel: z.ZodOptional<z.ZodNumber>;
|
|
430
|
+
delegationScope: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
431
|
+
delegationChain: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
432
|
+
delegator: z.ZodString;
|
|
433
|
+
delegatee: z.ZodString;
|
|
434
|
+
permissions: z.ZodArray<z.ZodString, "many">;
|
|
435
|
+
createdAt: z.ZodString;
|
|
436
|
+
}, "strip", z.ZodTypeAny, {
|
|
437
|
+
createdAt: string;
|
|
438
|
+
permissions: string[];
|
|
439
|
+
delegator: string;
|
|
440
|
+
delegatee: string;
|
|
441
|
+
}, {
|
|
442
|
+
createdAt: string;
|
|
443
|
+
permissions: string[];
|
|
444
|
+
delegator: string;
|
|
445
|
+
delegatee: string;
|
|
446
|
+
}>, "many">>;
|
|
447
|
+
name: z.ZodOptional<z.ZodString>;
|
|
448
|
+
type: z.ZodOptional<z.ZodString>;
|
|
449
|
+
}, z.ZodTypeAny, "passthrough">>;
|
|
450
|
+
credentialStatus: z.ZodOptional<z.ZodObject<{
|
|
451
|
+
id: z.ZodString;
|
|
452
|
+
type: z.ZodString;
|
|
453
|
+
statusPurpose: z.ZodEnum<["revocation", "suspension"]>;
|
|
454
|
+
statusListIndex: z.ZodNumber;
|
|
455
|
+
statusListCredential: z.ZodString;
|
|
456
|
+
}, "strip", z.ZodTypeAny, {
|
|
457
|
+
id: string;
|
|
458
|
+
type: string;
|
|
459
|
+
statusPurpose: "revocation" | "suspension";
|
|
460
|
+
statusListIndex: number;
|
|
461
|
+
statusListCredential: string;
|
|
462
|
+
}, {
|
|
463
|
+
id: string;
|
|
464
|
+
type: string;
|
|
465
|
+
statusPurpose: "revocation" | "suspension";
|
|
466
|
+
statusListIndex: number;
|
|
467
|
+
statusListCredential: string;
|
|
468
|
+
}>>;
|
|
469
|
+
proof: z.ZodOptional<z.ZodObject<{
|
|
470
|
+
type: z.ZodEnum<["Ed25519Signature2020", "JsonWebSignature2020"]>;
|
|
471
|
+
created: z.ZodString;
|
|
472
|
+
verificationMethod: z.ZodString;
|
|
473
|
+
proofPurpose: z.ZodEnum<["assertionMethod", "authentication"]>;
|
|
474
|
+
proofValue: z.ZodOptional<z.ZodString>;
|
|
475
|
+
jws: z.ZodOptional<z.ZodString>;
|
|
476
|
+
}, "strip", z.ZodTypeAny, {
|
|
477
|
+
type: "Ed25519Signature2020" | "JsonWebSignature2020";
|
|
478
|
+
created: string;
|
|
479
|
+
verificationMethod: string;
|
|
480
|
+
proofPurpose: "authentication" | "assertionMethod";
|
|
481
|
+
jws?: string | undefined;
|
|
482
|
+
proofValue?: string | undefined;
|
|
483
|
+
}, {
|
|
484
|
+
type: "Ed25519Signature2020" | "JsonWebSignature2020";
|
|
485
|
+
created: string;
|
|
486
|
+
verificationMethod: string;
|
|
487
|
+
proofPurpose: "authentication" | "assertionMethod";
|
|
488
|
+
jws?: string | undefined;
|
|
489
|
+
proofValue?: string | undefined;
|
|
490
|
+
}>>;
|
|
491
|
+
}, "strip", z.ZodTypeAny, {
|
|
492
|
+
type: string[];
|
|
493
|
+
issuer: string | {
|
|
494
|
+
id: string;
|
|
495
|
+
name?: string | undefined;
|
|
496
|
+
};
|
|
497
|
+
"@context": string[];
|
|
498
|
+
issuanceDate: string;
|
|
499
|
+
credentialSubject: {
|
|
500
|
+
name?: string | undefined;
|
|
501
|
+
id?: string | undefined;
|
|
502
|
+
type?: string | undefined;
|
|
503
|
+
agentId?: string | undefined;
|
|
504
|
+
permissions?: string[] | undefined;
|
|
505
|
+
trustLevel?: number | undefined;
|
|
506
|
+
delegationScope?: string[] | undefined;
|
|
507
|
+
delegationChain?: {
|
|
508
|
+
createdAt: string;
|
|
509
|
+
permissions: string[];
|
|
510
|
+
delegator: string;
|
|
511
|
+
delegatee: string;
|
|
512
|
+
}[] | undefined;
|
|
513
|
+
} & {
|
|
514
|
+
[k: string]: unknown;
|
|
515
|
+
};
|
|
516
|
+
id?: string | undefined;
|
|
517
|
+
expirationDate?: string | undefined;
|
|
518
|
+
credentialStatus?: {
|
|
519
|
+
id: string;
|
|
520
|
+
type: string;
|
|
521
|
+
statusPurpose: "revocation" | "suspension";
|
|
522
|
+
statusListIndex: number;
|
|
523
|
+
statusListCredential: string;
|
|
524
|
+
} | undefined;
|
|
525
|
+
proof?: {
|
|
526
|
+
type: "Ed25519Signature2020" | "JsonWebSignature2020";
|
|
527
|
+
created: string;
|
|
528
|
+
verificationMethod: string;
|
|
529
|
+
proofPurpose: "authentication" | "assertionMethod";
|
|
530
|
+
jws?: string | undefined;
|
|
531
|
+
proofValue?: string | undefined;
|
|
532
|
+
} | undefined;
|
|
533
|
+
}, {
|
|
534
|
+
type: string[];
|
|
535
|
+
issuer: string | {
|
|
536
|
+
id: string;
|
|
537
|
+
name?: string | undefined;
|
|
538
|
+
};
|
|
539
|
+
"@context": string[];
|
|
540
|
+
issuanceDate: string;
|
|
541
|
+
credentialSubject: {
|
|
542
|
+
name?: string | undefined;
|
|
543
|
+
id?: string | undefined;
|
|
544
|
+
type?: string | undefined;
|
|
545
|
+
agentId?: string | undefined;
|
|
546
|
+
permissions?: string[] | undefined;
|
|
547
|
+
trustLevel?: number | undefined;
|
|
548
|
+
delegationScope?: string[] | undefined;
|
|
549
|
+
delegationChain?: {
|
|
550
|
+
createdAt: string;
|
|
551
|
+
permissions: string[];
|
|
552
|
+
delegator: string;
|
|
553
|
+
delegatee: string;
|
|
554
|
+
}[] | undefined;
|
|
555
|
+
} & {
|
|
556
|
+
[k: string]: unknown;
|
|
557
|
+
};
|
|
558
|
+
id?: string | undefined;
|
|
559
|
+
expirationDate?: string | undefined;
|
|
560
|
+
credentialStatus?: {
|
|
561
|
+
id: string;
|
|
562
|
+
type: string;
|
|
563
|
+
statusPurpose: "revocation" | "suspension";
|
|
564
|
+
statusListIndex: number;
|
|
565
|
+
statusListCredential: string;
|
|
566
|
+
} | undefined;
|
|
567
|
+
proof?: {
|
|
568
|
+
type: "Ed25519Signature2020" | "JsonWebSignature2020";
|
|
569
|
+
created: string;
|
|
570
|
+
verificationMethod: string;
|
|
571
|
+
proofPurpose: "authentication" | "assertionMethod";
|
|
572
|
+
jws?: string | undefined;
|
|
573
|
+
proofValue?: string | undefined;
|
|
574
|
+
} | undefined;
|
|
575
|
+
}>, "many">;
|
|
576
|
+
proof: z.ZodOptional<z.ZodObject<{
|
|
577
|
+
type: z.ZodEnum<["Ed25519Signature2020", "JsonWebSignature2020"]>;
|
|
578
|
+
created: z.ZodString;
|
|
579
|
+
verificationMethod: z.ZodString;
|
|
580
|
+
proofPurpose: z.ZodEnum<["assertionMethod", "authentication"]>;
|
|
581
|
+
proofValue: z.ZodOptional<z.ZodString>;
|
|
582
|
+
jws: z.ZodOptional<z.ZodString>;
|
|
583
|
+
}, "strip", z.ZodTypeAny, {
|
|
584
|
+
type: "Ed25519Signature2020" | "JsonWebSignature2020";
|
|
585
|
+
created: string;
|
|
586
|
+
verificationMethod: string;
|
|
587
|
+
proofPurpose: "authentication" | "assertionMethod";
|
|
588
|
+
jws?: string | undefined;
|
|
589
|
+
proofValue?: string | undefined;
|
|
590
|
+
}, {
|
|
591
|
+
type: "Ed25519Signature2020" | "JsonWebSignature2020";
|
|
592
|
+
created: string;
|
|
593
|
+
verificationMethod: string;
|
|
594
|
+
proofPurpose: "authentication" | "assertionMethod";
|
|
595
|
+
jws?: string | undefined;
|
|
596
|
+
proofValue?: string | undefined;
|
|
597
|
+
}>>;
|
|
598
|
+
}, "strip", z.ZodTypeAny, {
|
|
599
|
+
type: string[];
|
|
600
|
+
"@context": string[];
|
|
601
|
+
verifiableCredential: {
|
|
602
|
+
type: string[];
|
|
603
|
+
issuer: string | {
|
|
604
|
+
id: string;
|
|
605
|
+
name?: string | undefined;
|
|
606
|
+
};
|
|
607
|
+
"@context": string[];
|
|
608
|
+
issuanceDate: string;
|
|
609
|
+
credentialSubject: {
|
|
610
|
+
name?: string | undefined;
|
|
611
|
+
id?: string | undefined;
|
|
612
|
+
type?: string | undefined;
|
|
613
|
+
agentId?: string | undefined;
|
|
614
|
+
permissions?: string[] | undefined;
|
|
615
|
+
trustLevel?: number | undefined;
|
|
616
|
+
delegationScope?: string[] | undefined;
|
|
617
|
+
delegationChain?: {
|
|
618
|
+
createdAt: string;
|
|
619
|
+
permissions: string[];
|
|
620
|
+
delegator: string;
|
|
621
|
+
delegatee: string;
|
|
622
|
+
}[] | undefined;
|
|
623
|
+
} & {
|
|
624
|
+
[k: string]: unknown;
|
|
625
|
+
};
|
|
626
|
+
id?: string | undefined;
|
|
627
|
+
expirationDate?: string | undefined;
|
|
628
|
+
credentialStatus?: {
|
|
629
|
+
id: string;
|
|
630
|
+
type: string;
|
|
631
|
+
statusPurpose: "revocation" | "suspension";
|
|
632
|
+
statusListIndex: number;
|
|
633
|
+
statusListCredential: string;
|
|
634
|
+
} | undefined;
|
|
635
|
+
proof?: {
|
|
636
|
+
type: "Ed25519Signature2020" | "JsonWebSignature2020";
|
|
637
|
+
created: string;
|
|
638
|
+
verificationMethod: string;
|
|
639
|
+
proofPurpose: "authentication" | "assertionMethod";
|
|
640
|
+
jws?: string | undefined;
|
|
641
|
+
proofValue?: string | undefined;
|
|
642
|
+
} | undefined;
|
|
643
|
+
}[];
|
|
644
|
+
id?: string | undefined;
|
|
645
|
+
proof?: {
|
|
646
|
+
type: "Ed25519Signature2020" | "JsonWebSignature2020";
|
|
647
|
+
created: string;
|
|
648
|
+
verificationMethod: string;
|
|
649
|
+
proofPurpose: "authentication" | "assertionMethod";
|
|
650
|
+
jws?: string | undefined;
|
|
651
|
+
proofValue?: string | undefined;
|
|
652
|
+
} | undefined;
|
|
653
|
+
holder?: string | undefined;
|
|
654
|
+
}, {
|
|
655
|
+
type: string[];
|
|
656
|
+
"@context": string[];
|
|
657
|
+
verifiableCredential: {
|
|
658
|
+
type: string[];
|
|
659
|
+
issuer: string | {
|
|
660
|
+
id: string;
|
|
661
|
+
name?: string | undefined;
|
|
662
|
+
};
|
|
663
|
+
"@context": string[];
|
|
664
|
+
issuanceDate: string;
|
|
665
|
+
credentialSubject: {
|
|
666
|
+
name?: string | undefined;
|
|
667
|
+
id?: string | undefined;
|
|
668
|
+
type?: string | undefined;
|
|
669
|
+
agentId?: string | undefined;
|
|
670
|
+
permissions?: string[] | undefined;
|
|
671
|
+
trustLevel?: number | undefined;
|
|
672
|
+
delegationScope?: string[] | undefined;
|
|
673
|
+
delegationChain?: {
|
|
674
|
+
createdAt: string;
|
|
675
|
+
permissions: string[];
|
|
676
|
+
delegator: string;
|
|
677
|
+
delegatee: string;
|
|
678
|
+
}[] | undefined;
|
|
679
|
+
} & {
|
|
680
|
+
[k: string]: unknown;
|
|
681
|
+
};
|
|
682
|
+
id?: string | undefined;
|
|
683
|
+
expirationDate?: string | undefined;
|
|
684
|
+
credentialStatus?: {
|
|
685
|
+
id: string;
|
|
686
|
+
type: string;
|
|
687
|
+
statusPurpose: "revocation" | "suspension";
|
|
688
|
+
statusListIndex: number;
|
|
689
|
+
statusListCredential: string;
|
|
690
|
+
} | undefined;
|
|
691
|
+
proof?: {
|
|
692
|
+
type: "Ed25519Signature2020" | "JsonWebSignature2020";
|
|
693
|
+
created: string;
|
|
694
|
+
verificationMethod: string;
|
|
695
|
+
proofPurpose: "authentication" | "assertionMethod";
|
|
696
|
+
jws?: string | undefined;
|
|
697
|
+
proofValue?: string | undefined;
|
|
698
|
+
} | undefined;
|
|
699
|
+
}[];
|
|
700
|
+
id?: string | undefined;
|
|
701
|
+
proof?: {
|
|
702
|
+
type: "Ed25519Signature2020" | "JsonWebSignature2020";
|
|
703
|
+
created: string;
|
|
704
|
+
verificationMethod: string;
|
|
705
|
+
proofPurpose: "authentication" | "assertionMethod";
|
|
706
|
+
jws?: string | undefined;
|
|
707
|
+
proofValue?: string | undefined;
|
|
708
|
+
} | undefined;
|
|
709
|
+
holder?: string | undefined;
|
|
710
|
+
}>;
|
|
711
|
+
type VerifiablePresentation = z.infer<typeof VerifiablePresentationSchema>;
|
|
712
|
+
interface VCIssuerConfig {
|
|
713
|
+
/** DID of the issuer (e.g. did:key:z6Mk...) */
|
|
714
|
+
issuerDid: string;
|
|
715
|
+
/** Private key JWK for signing credentials */
|
|
716
|
+
privateKeyJwk: JsonWebKey;
|
|
717
|
+
/** Public key JWK for verification method references */
|
|
718
|
+
publicKeyJwk: JsonWebKey;
|
|
719
|
+
/** Default credential lifetime in seconds. Default: 86400 (24 hours). */
|
|
720
|
+
defaultTtl?: number;
|
|
721
|
+
/** Credential status endpoint base URL (for revocation). Optional. */
|
|
722
|
+
statusEndpoint?: string;
|
|
723
|
+
}
|
|
724
|
+
interface VCVerifierConfig {
|
|
725
|
+
/**
|
|
726
|
+
* Resolve a DID to its public key JWK.
|
|
727
|
+
* If not provided, only credentials with a known public key can be verified.
|
|
728
|
+
*/
|
|
729
|
+
resolveDidKey?: (did: string) => Promise<JsonWebKey | null>;
|
|
730
|
+
/**
|
|
731
|
+
* Check credential revocation status.
|
|
732
|
+
* If not provided, revocation checks are skipped.
|
|
733
|
+
*/
|
|
734
|
+
checkRevocationStatus?: (status: CredentialStatus) => Promise<boolean>;
|
|
735
|
+
}
|
|
736
|
+
/** Claims embedded in a JWT-encoded Verifiable Credential */
|
|
737
|
+
interface VCJwtPayload {
|
|
738
|
+
iss: string;
|
|
739
|
+
sub?: string;
|
|
740
|
+
vc: Omit<VerifiableCredential, "proof">;
|
|
741
|
+
iat: number;
|
|
742
|
+
exp?: number;
|
|
743
|
+
jti?: string;
|
|
744
|
+
}
|
|
745
|
+
/** The format a credential was issued in */
|
|
746
|
+
type CredentialFormat = "jwt" | "json-ld";
|
|
747
|
+
/** Result of a successful credential verification */
|
|
748
|
+
interface VerifiedCredential {
|
|
749
|
+
credential: VerifiableCredential;
|
|
750
|
+
format: CredentialFormat;
|
|
751
|
+
issuer: string;
|
|
752
|
+
issuedAt: Date;
|
|
753
|
+
expiresAt: Date | null;
|
|
754
|
+
}
|
|
755
|
+
/** Result of a successful presentation verification */
|
|
756
|
+
interface VerifiedPresentation {
|
|
757
|
+
presentation: VerifiablePresentation;
|
|
758
|
+
credentials: VerifiedCredential[];
|
|
759
|
+
holder: string | null;
|
|
760
|
+
}
|
|
761
|
+
/** Extracted permissions from a verified credential */
|
|
762
|
+
interface ExtractedPermissions {
|
|
763
|
+
agentId: string | null;
|
|
764
|
+
permissions: string[];
|
|
765
|
+
trustLevel: number | null;
|
|
766
|
+
delegationScope: string[];
|
|
767
|
+
}
|
|
768
|
+
|
|
769
|
+
/**
|
|
770
|
+
* Export audit records as W3C Verifiable Credentials.
|
|
771
|
+
*
|
|
772
|
+
* Takes a time range of audit log entries and returns either individual
|
|
773
|
+
* credentials per record or a single Verifiable Presentation wrapping
|
|
774
|
+
* all of them. Useful for compliance exports that must be
|
|
775
|
+
* cryptographically verifiable (EU AI Act Article 12, SOC 2 CC7).
|
|
776
|
+
*
|
|
777
|
+
* Context URL: https://theauth.com/contexts/audit/v1.jsonld
|
|
778
|
+
* This context is defined locally — the URL does not need to resolve at
|
|
779
|
+
* runtime. It serves as a stable identifier for the credential schema.
|
|
780
|
+
*/
|
|
781
|
+
|
|
782
|
+
declare const THEAUTH_AUDIT_CREDENTIAL = "TheAuthAuditCredential";
|
|
783
|
+
/**
|
|
784
|
+
* Context URL for TheAuthAuditCredential.
|
|
785
|
+
* Defined locally — the URL does not need to resolve at runtime.
|
|
786
|
+
*/
|
|
787
|
+
declare const THEAUTH_AUDIT_CONTEXT = "https://theauth.com/contexts/audit/v1.jsonld";
|
|
788
|
+
/** AuditRecord is an alias for AuditEntry used in the VC export surface. */
|
|
789
|
+
type AuditRecord = AuditEntry;
|
|
790
|
+
/** Options passed to `exportAuditAsVC`. */
|
|
791
|
+
interface ExportAuditOptions {
|
|
792
|
+
/** Start of the time range (inclusive). */
|
|
793
|
+
since: Date;
|
|
794
|
+
/** End of the time range (inclusive). */
|
|
795
|
+
until: Date;
|
|
796
|
+
/**
|
|
797
|
+
* DID of the issuer signing the credentials.
|
|
798
|
+
* Must match the keypair in `issuerConfig`.
|
|
799
|
+
*/
|
|
800
|
+
issuerDid: string;
|
|
801
|
+
/** Private/public keypair config for signing. */
|
|
802
|
+
issuerConfig: VCIssuerConfig;
|
|
803
|
+
/** Output format. Default: `"ldp_vc"` (JSON-LD with embedded proof). */
|
|
804
|
+
format?: "ldp_vc" | "jwt_vc";
|
|
805
|
+
/** Output structure. Default: `"individual"` (one VC per record). */
|
|
806
|
+
output?: "individual" | "presentation";
|
|
807
|
+
/** Optional filter applied after the time range query. */
|
|
808
|
+
filter?: (record: AuditRecord) => boolean;
|
|
809
|
+
/** Records to export. Pass the results of `listAuditRecords` or `kavach.audit.query()`. */
|
|
810
|
+
records: AuditRecord[];
|
|
811
|
+
}
|
|
812
|
+
/** The result of `exportAuditAsVC`. */
|
|
813
|
+
interface AuditExportResult {
|
|
814
|
+
/**
|
|
815
|
+
* Individual credentials — one per audit record.
|
|
816
|
+
* When `output === "presentation"`, these are also embedded in `presentation`.
|
|
817
|
+
*/
|
|
818
|
+
credentials: VerifiableCredential[];
|
|
819
|
+
/**
|
|
820
|
+
* JWT strings when `format === "jwt_vc"`. Parallel to `credentials`.
|
|
821
|
+
* Pass these to `verifyCredential()` instead of the credential objects.
|
|
822
|
+
*/
|
|
823
|
+
jwts?: string[];
|
|
824
|
+
/** Present only when `output === "presentation"`. */
|
|
825
|
+
presentation?: VerifiablePresentation;
|
|
826
|
+
/** The format used. */
|
|
827
|
+
format: "ldp_vc" | "jwt_vc";
|
|
828
|
+
/** Timestamp of the export run. */
|
|
829
|
+
issuedAt: Date;
|
|
830
|
+
/** Number of credentials produced. */
|
|
831
|
+
count: number;
|
|
832
|
+
}
|
|
833
|
+
/** The credentialSubject for a TheAuthAuditCredential. */
|
|
834
|
+
interface AuditCredentialSubject {
|
|
835
|
+
id: string;
|
|
836
|
+
agentId: string;
|
|
837
|
+
principalId?: string;
|
|
838
|
+
operation: string;
|
|
839
|
+
target: string;
|
|
840
|
+
decision: "allow" | "deny" | "approval_required";
|
|
841
|
+
policyName?: string;
|
|
842
|
+
timestamp: string;
|
|
843
|
+
traceId?: string;
|
|
844
|
+
theauthVersion: string;
|
|
845
|
+
}
|
|
846
|
+
/**
|
|
847
|
+
* Export a set of audit records as Verifiable Credentials.
|
|
848
|
+
*
|
|
849
|
+
* Pass `records` from `kavach.audit.query()` or `listAuditRecords`.
|
|
850
|
+
* The function applies the optional `filter`, signs each record with
|
|
851
|
+
* the issuer keypair, and returns either individual VCs or a single
|
|
852
|
+
* Verifiable Presentation.
|
|
853
|
+
*
|
|
854
|
+
* ```ts
|
|
855
|
+
* const result = await exportAuditAsVC({
|
|
856
|
+
* since: new Date('2025-01-01'),
|
|
857
|
+
* until: new Date('2025-01-31'),
|
|
858
|
+
* issuerDid: keyPair.did,
|
|
859
|
+
* issuerConfig: {
|
|
860
|
+
* issuerDid: keyPair.did,
|
|
861
|
+
* privateKeyJwk: keyPair.privateKeyJwk,
|
|
862
|
+
* publicKeyJwk: keyPair.publicKeyJwk,
|
|
863
|
+
* },
|
|
864
|
+
* records,
|
|
865
|
+
* });
|
|
866
|
+
* console.log(result.count); // 42
|
|
867
|
+
* ```
|
|
868
|
+
*/
|
|
869
|
+
declare function exportAuditAsVC(options: ExportAuditOptions): Promise<AuditExportResult>;
|
|
870
|
+
/**
|
|
871
|
+
* Filter audit records by time range with an optional predicate.
|
|
872
|
+
*
|
|
873
|
+
* Convenience helper for callers that already have records in memory
|
|
874
|
+
* and want to slice them before passing to `exportAuditAsVC`.
|
|
875
|
+
*
|
|
876
|
+
* ```ts
|
|
877
|
+
* const records = await kavach.audit.query({ since, until });
|
|
878
|
+
* const denyRecords = listAuditRecords(records, since, until, r => r.result === 'denied');
|
|
879
|
+
* ```
|
|
880
|
+
*/
|
|
881
|
+
declare function listAuditRecords(records: AuditRecord[], since: Date, until: Date, filter?: (record: AuditRecord) => boolean): AuditRecord[];
|
|
882
|
+
|
|
883
|
+
/**
|
|
884
|
+
* W3C Verifiable Credential issuance for TheAuth.
|
|
885
|
+
*
|
|
886
|
+
* Issues VCs as JWT (compact JWS) or JSON-LD with embedded proof.
|
|
887
|
+
* Credentials encode agent identity, permissions, and delegation chains
|
|
888
|
+
* so agents can prove their capabilities to any verifier without
|
|
889
|
+
* a network call back to TheAuth.
|
|
890
|
+
*/
|
|
891
|
+
|
|
892
|
+
interface IssueAgentCredentialInput {
|
|
893
|
+
/** Agent ID (used as credentialSubject.id and sub claim) */
|
|
894
|
+
agentId: string;
|
|
895
|
+
/** Agent name */
|
|
896
|
+
name?: string;
|
|
897
|
+
/** Agent type (e.g. "autonomous", "supervised") */
|
|
898
|
+
agentType?: string;
|
|
899
|
+
/** Permissions granted to this agent */
|
|
900
|
+
permissions?: string[];
|
|
901
|
+
/** Trust score between 0 and 1 */
|
|
902
|
+
trustLevel?: number;
|
|
903
|
+
/** Credential lifetime in seconds. Overrides the issuer default. */
|
|
904
|
+
ttl?: number;
|
|
905
|
+
/** Output format. Default: "jwt". */
|
|
906
|
+
format?: CredentialFormat;
|
|
907
|
+
}
|
|
908
|
+
interface IssuePermissionCredentialInput {
|
|
909
|
+
/** Agent DID or ID that receives the permissions */
|
|
910
|
+
agentId: string;
|
|
911
|
+
/** Permissions being granted */
|
|
912
|
+
permissions: string[];
|
|
913
|
+
/** Credential lifetime in seconds. Overrides the issuer default. */
|
|
914
|
+
ttl?: number;
|
|
915
|
+
/** Output format. Default: "jwt". */
|
|
916
|
+
format?: CredentialFormat;
|
|
917
|
+
}
|
|
918
|
+
interface DelegationLink {
|
|
919
|
+
delegator: string;
|
|
920
|
+
delegatee: string;
|
|
921
|
+
permissions: string[];
|
|
922
|
+
createdAt: string;
|
|
923
|
+
}
|
|
924
|
+
interface IssueDelegationCredentialInput {
|
|
925
|
+
/** The agent at the end of the delegation chain */
|
|
926
|
+
agentId: string;
|
|
927
|
+
/** Ordered delegation chain from root to leaf */
|
|
928
|
+
chain: DelegationLink[];
|
|
929
|
+
/** Scope of delegated permissions (subset of original) */
|
|
930
|
+
delegationScope?: string[];
|
|
931
|
+
/** Credential lifetime in seconds. Overrides the issuer default. */
|
|
932
|
+
ttl?: number;
|
|
933
|
+
/** Output format. Default: "jwt". */
|
|
934
|
+
format?: CredentialFormat;
|
|
935
|
+
}
|
|
936
|
+
interface VCIssuer {
|
|
937
|
+
/** Issue a VC encoding agent identity, permissions, and trust score */
|
|
938
|
+
issueAgentCredential(input: IssueAgentCredentialInput): Promise<Result<{
|
|
939
|
+
credential: VerifiableCredential;
|
|
940
|
+
jwt?: string;
|
|
941
|
+
}>>;
|
|
942
|
+
/** Issue a VC for specific permission grants */
|
|
943
|
+
issuePermissionCredential(input: IssuePermissionCredentialInput): Promise<Result<{
|
|
944
|
+
credential: VerifiableCredential;
|
|
945
|
+
jwt?: string;
|
|
946
|
+
}>>;
|
|
947
|
+
/** Issue a VC encoding a delegation chain */
|
|
948
|
+
issueDelegationCredential(input: IssueDelegationCredentialInput): Promise<Result<{
|
|
949
|
+
credential: VerifiableCredential;
|
|
950
|
+
jwt?: string;
|
|
951
|
+
}>>;
|
|
952
|
+
/** The DID of this issuer */
|
|
953
|
+
readonly issuerDid: string;
|
|
954
|
+
}
|
|
955
|
+
/**
|
|
956
|
+
* Create a VC issuer bound to a specific DID and keypair.
|
|
957
|
+
*
|
|
958
|
+
* The issuer can produce credentials in JWT or JSON-LD format.
|
|
959
|
+
* JWT credentials are signed as a compact JWS with the VC embedded
|
|
960
|
+
* in the `vc` claim. JSON-LD credentials carry an embedded proof.
|
|
961
|
+
*/
|
|
962
|
+
declare function createVCIssuer(config: VCIssuerConfig): VCIssuer;
|
|
963
|
+
|
|
964
|
+
/**
|
|
965
|
+
* W3C Verifiable Credential verification for TheAuth.
|
|
966
|
+
*
|
|
967
|
+
* Verifies credentials in both JWT and JSON-LD formats. Checks
|
|
968
|
+
* signatures, expiry, and optional revocation status. Extracts
|
|
969
|
+
* TheAuth-specific permissions from verified credentials.
|
|
970
|
+
*/
|
|
971
|
+
|
|
972
|
+
interface VCVerifier {
|
|
973
|
+
/** Verify a single credential (JWT string or JSON-LD object) */
|
|
974
|
+
verifyCredential(vc: string | VerifiableCredential, publicKeyJwk?: JsonWebKey): Promise<Result<VerifiedCredential>>;
|
|
975
|
+
/** Verify a presentation containing multiple VCs */
|
|
976
|
+
verifyPresentation(vp: string | VerifiablePresentation, publicKeyJwk?: JsonWebKey): Promise<Result<VerifiedPresentation>>;
|
|
977
|
+
/** Extract TheAuth permissions from a verified credential */
|
|
978
|
+
extractPermissions(vc: VerifiableCredential): ExtractedPermissions;
|
|
979
|
+
}
|
|
980
|
+
/**
|
|
981
|
+
* Create a VC verifier that checks signatures, expiry, and revocation.
|
|
982
|
+
*
|
|
983
|
+
* The verifier accepts both JWT-encoded and JSON-LD credentials.
|
|
984
|
+
* For JWT credentials, pass the compact JWS string. For JSON-LD
|
|
985
|
+
* credentials with embedded proof, pass the credential object.
|
|
986
|
+
*/
|
|
987
|
+
declare function createVCVerifier(config?: VCVerifierConfig): VCVerifier;
|
|
988
|
+
|
|
989
|
+
export { type AuditCredentialSubject, type AuditExportResult, type AuditRecord, type CredentialFormat, type CredentialStatus, CredentialStatusSchema, type CredentialSubject, CredentialSubjectSchema, type DelegationLink, type ExportAuditOptions, type ExtractedPermissions, type IssueAgentCredentialInput, type IssueDelegationCredentialInput, type IssuePermissionCredentialInput, KAVACH_AGENT_CREDENTIAL, KAVACH_DELEGATION_CREDENTIAL, KAVACH_PERMISSION_CREDENTIAL, type Proof, ProofSchema, THEAUTH_AUDIT_CONTEXT, THEAUTH_AUDIT_CREDENTIAL, type VCIssuer, type VCIssuerConfig, type VCJwtPayload, type VCVerifier, type VCVerifierConfig, VC_CONTEXT_V1, VC_CONTEXT_V2, VC_TYPE_CREDENTIAL, VC_TYPE_PRESENTATION, type VerifiableCredential, VerifiableCredentialSchema, type VerifiablePresentation, VerifiablePresentationSchema, type VerifiedCredential, type VerifiedPresentation, createVCIssuer, createVCVerifier, exportAuditAsVC, listAuditRecords };
|