kavachos 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/a2a/index.d.ts +2 -2
- package/dist/agent/index.d.ts +3 -3
- package/dist/agent/index.js +4 -0
- package/dist/agent/index.js.map +1 -1
- package/dist/audit/index.d.ts +2 -2
- package/dist/audit/index.js +4 -0
- package/dist/audit/index.js.map +1 -1
- package/dist/auth/index.d.ts +64 -3
- package/dist/auth/index.js +91 -2
- package/dist/auth/index.js.map +1 -1
- package/dist/index.d.ts +32 -4
- package/dist/index.js +851 -67
- package/dist/index.js.map +1 -1
- package/dist/mcp/index.d.ts +2 -2
- package/dist/mcp/index.js +38 -1
- package/dist/mcp/index.js.map +1 -1
- package/dist/permission/index.d.ts +8 -3
- package/dist/permission/index.js +68 -59
- package/dist/permission/index.js.map +1 -1
- package/dist/{types-BuHrZcjE.d.ts → types-BiUe9e8u.d.ts} +24 -0
- package/dist/{types-B02D3kZy.d.ts → types-RJPOU4un.d.ts} +114 -2
- package/dist/vc/index.d.ts +254 -65
- package/dist/vc/index.js +160 -12
- package/dist/vc/index.js.map +1 -1
- package/package.json +2 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as drizzle_orm_sqlite_core from 'drizzle-orm/sqlite-core';
|
|
2
2
|
import { BaseSQLiteDatabase } from 'drizzle-orm/sqlite-core';
|
|
3
|
-
import { R as Result, f as McpConfig } from './types-
|
|
3
|
+
import { R as Result, f as McpConfig } from './types-BiUe9e8u.js';
|
|
4
4
|
import { RedirectConfig } from './redirect/index.js';
|
|
5
5
|
|
|
6
6
|
declare const users: drizzle_orm_sqlite_core.SQLiteTableWithColumns<{
|
|
@@ -971,6 +971,25 @@ declare const permissions: drizzle_orm_sqlite_core.SQLiteTableWithColumns<{
|
|
|
971
971
|
}, {}, {
|
|
972
972
|
$type: PermissionConstraintsRow;
|
|
973
973
|
}>;
|
|
974
|
+
relation: drizzle_orm_sqlite_core.SQLiteColumn<{
|
|
975
|
+
name: "relation";
|
|
976
|
+
tableName: "kavach_permissions";
|
|
977
|
+
dataType: "string";
|
|
978
|
+
columnType: "SQLiteText";
|
|
979
|
+
data: string;
|
|
980
|
+
driverParam: string;
|
|
981
|
+
notNull: false;
|
|
982
|
+
hasDefault: false;
|
|
983
|
+
isPrimaryKey: false;
|
|
984
|
+
isAutoincrement: false;
|
|
985
|
+
hasRuntimeDefault: false;
|
|
986
|
+
enumValues: [string, ...string[]];
|
|
987
|
+
baseColumn: never;
|
|
988
|
+
identity: undefined;
|
|
989
|
+
generated: undefined;
|
|
990
|
+
}, {}, {
|
|
991
|
+
length: number | undefined;
|
|
992
|
+
}>;
|
|
974
993
|
createdAt: drizzle_orm_sqlite_core.SQLiteColumn<{
|
|
975
994
|
name: "created_at";
|
|
976
995
|
tableName: "kavach_permissions";
|
|
@@ -1403,6 +1422,23 @@ declare const auditLogs: drizzle_orm_sqlite_core.SQLiteTableWithColumns<{
|
|
|
1403
1422
|
}, {}, {
|
|
1404
1423
|
length: number | undefined;
|
|
1405
1424
|
}>;
|
|
1425
|
+
cacheHit: drizzle_orm_sqlite_core.SQLiteColumn<{
|
|
1426
|
+
name: "cache_hit";
|
|
1427
|
+
tableName: "kavach_audit_logs";
|
|
1428
|
+
dataType: "boolean";
|
|
1429
|
+
columnType: "SQLiteBoolean";
|
|
1430
|
+
data: boolean;
|
|
1431
|
+
driverParam: number;
|
|
1432
|
+
notNull: true;
|
|
1433
|
+
hasDefault: true;
|
|
1434
|
+
isPrimaryKey: false;
|
|
1435
|
+
isAutoincrement: false;
|
|
1436
|
+
hasRuntimeDefault: false;
|
|
1437
|
+
enumValues: undefined;
|
|
1438
|
+
baseColumn: never;
|
|
1439
|
+
identity: undefined;
|
|
1440
|
+
generated: undefined;
|
|
1441
|
+
}, {}, {}>;
|
|
1406
1442
|
timestamp: drizzle_orm_sqlite_core.SQLiteColumn<{
|
|
1407
1443
|
name: "timestamp";
|
|
1408
1444
|
tableName: "kavach_audit_logs";
|
|
@@ -9111,6 +9147,59 @@ interface PluginInitResult {
|
|
|
9111
9147
|
context?: Record<string, unknown>;
|
|
9112
9148
|
}
|
|
9113
9149
|
|
|
9150
|
+
type PolicyEffect = "permit" | "deny" | "indeterminate";
|
|
9151
|
+
interface PolicyDecisionSubject {
|
|
9152
|
+
agentId?: string;
|
|
9153
|
+
userId?: string;
|
|
9154
|
+
orgId?: string;
|
|
9155
|
+
}
|
|
9156
|
+
interface PolicyEvaluationContext {
|
|
9157
|
+
ip?: string;
|
|
9158
|
+
arguments?: Record<string, unknown>;
|
|
9159
|
+
timestamp?: Date;
|
|
9160
|
+
[key: string]: unknown;
|
|
9161
|
+
}
|
|
9162
|
+
interface EvaluateInput {
|
|
9163
|
+
subject: PolicyDecisionSubject;
|
|
9164
|
+
action: string;
|
|
9165
|
+
resource: string;
|
|
9166
|
+
context?: PolicyEvaluationContext;
|
|
9167
|
+
}
|
|
9168
|
+
interface PolicyDecision {
|
|
9169
|
+
allowed: boolean;
|
|
9170
|
+
effect: PolicyEffect;
|
|
9171
|
+
reason: string;
|
|
9172
|
+
matchedPermissionId?: string;
|
|
9173
|
+
matchedRelation?: string;
|
|
9174
|
+
cacheHit: boolean;
|
|
9175
|
+
durationMs: number;
|
|
9176
|
+
auditId?: string;
|
|
9177
|
+
}
|
|
9178
|
+
interface PolicyCacheStats {
|
|
9179
|
+
hits: number;
|
|
9180
|
+
misses: number;
|
|
9181
|
+
size: number;
|
|
9182
|
+
evictions: number;
|
|
9183
|
+
}
|
|
9184
|
+
interface InvalidateScope {
|
|
9185
|
+
agentId?: string;
|
|
9186
|
+
userId?: string;
|
|
9187
|
+
resource?: string;
|
|
9188
|
+
}
|
|
9189
|
+
type PolicyCombineStrategy = "deny-overrides" | "permit-overrides";
|
|
9190
|
+
interface PolicyCacheConfig {
|
|
9191
|
+
maxEntries?: number;
|
|
9192
|
+
ttlMs?: number;
|
|
9193
|
+
enabled?: boolean;
|
|
9194
|
+
}
|
|
9195
|
+
interface PolicyEngineConfig {
|
|
9196
|
+
cache?: PolicyCacheConfig;
|
|
9197
|
+
combineStrategy?: PolicyCombineStrategy;
|
|
9198
|
+
audit?: boolean;
|
|
9199
|
+
/** Sample rate for audit row writes, 0.0 to 1.0. Defaults to 1.0. */
|
|
9200
|
+
auditSampleRate?: number;
|
|
9201
|
+
}
|
|
9202
|
+
|
|
9114
9203
|
/**
|
|
9115
9204
|
* Session freshness enforcement for KavachOS.
|
|
9116
9205
|
*
|
|
@@ -9332,6 +9421,15 @@ interface KavachConfig {
|
|
|
9332
9421
|
* to. Deliveries are fire-and-forget with exponential backoff retries.
|
|
9333
9422
|
*/
|
|
9334
9423
|
webhooks?: WebhookConfig[];
|
|
9424
|
+
/**
|
|
9425
|
+
* Unified policy engine configuration.
|
|
9426
|
+
*
|
|
9427
|
+
* Controls the LRU cache (max entries, TTL), combining strategy
|
|
9428
|
+
* (deny-overrides vs permit-overrides), audit emission, and audit
|
|
9429
|
+
* sample rate. When omitted, the engine runs with safe defaults:
|
|
9430
|
+
* cache enabled (10,000 entries, 60s TTL), deny-overrides, full audit.
|
|
9431
|
+
*/
|
|
9432
|
+
policy?: PolicyEngineConfig;
|
|
9335
9433
|
/**
|
|
9336
9434
|
* Redirect chain configuration.
|
|
9337
9435
|
*
|
|
@@ -9347,6 +9445,18 @@ interface KavachConfig {
|
|
|
9347
9445
|
* When omitted, defaults to 300 seconds (5 minutes).
|
|
9348
9446
|
*/
|
|
9349
9447
|
sessionFreshness?: SessionFreshnessConfig;
|
|
9448
|
+
/**
|
|
9449
|
+
* Emit IETF agentic JWT claims on issued tokens.
|
|
9450
|
+
*
|
|
9451
|
+
* When true, tokens issued by the MCP token endpoint and the JWT session
|
|
9452
|
+
* module include additional claims defined in draft-goswami-agentic-jwt-00
|
|
9453
|
+
* and draft-liu-agent-operation-authorization-01, such as `agent_id`,
|
|
9454
|
+
* `agent_type`, and `trust_tier`. Off by default to preserve backward
|
|
9455
|
+
* compatibility with existing token consumers.
|
|
9456
|
+
*
|
|
9457
|
+
* @default false
|
|
9458
|
+
*/
|
|
9459
|
+
emitAgenticJwtClaims?: boolean;
|
|
9350
9460
|
}
|
|
9351
9461
|
/**
|
|
9352
9462
|
* The main KavachOS instance returned by createKavach()
|
|
@@ -9397,6 +9507,8 @@ interface Permission {
|
|
|
9397
9507
|
resource: string;
|
|
9398
9508
|
actions: string[];
|
|
9399
9509
|
constraints?: PermissionConstraints;
|
|
9510
|
+
/** Optional ReBAC relation. When set, the policy engine queries the relationship graph. */
|
|
9511
|
+
relation?: string;
|
|
9400
9512
|
}
|
|
9401
9513
|
interface PermissionConstraints {
|
|
9402
9514
|
maxCallsPerHour?: number;
|
|
@@ -9521,4 +9633,4 @@ interface TokenValidationResult {
|
|
|
9521
9633
|
}
|
|
9522
9634
|
type McpMiddleware = (request: Request) => Promise<Response | undefined>;
|
|
9523
9635
|
|
|
9524
|
-
export { type
|
|
9636
|
+
export { type AdminUser as $, type AgentIdentity as A, type SessionFreshnessModule as B, type CreateAgentInput as C, type Database as D, type EmailOtpModule as E, type PhoneAuthModule as F, type CaptchaModule as G, type EvaluateInput as H, type PolicyDecision as I, type InvalidateScope as J, type KavachConfig as K, type PolicyCacheStats as L, type McpServerInput as M, type PluginEndpoint as N, type OrgModule as O, type Permission as P, type EndpointContext as Q, type RequestContext as R, type SignedPayload as S, type TotpModule as T, type UpdateAgentInput as U, type VerificationResult as V, type WebhookModule as W, type KavachPlugin as X, type SessionConfig as Y, type Session as Z, type AdminConfig as _, type DatabaseConfig as a, createOneTimeTokenModule as a$, type AgentConfig as a0, type ApiKey as a1, type ApiKeyManagerConfig as a2, type ApprovalConfig as a3, type ApprovalModule as a4, type AuthAdapter as a5, type CaptchaConfig as a6, type CaptchaVerifyResult as a7, type CreateTokenInput as a8, type D1DatabaseBinding as a9, type SsoAuditEvent as aA, type SsoConfig as aB, type SsoConnection as aC, SsoError as aD, type TokenValidationResult as aE, type TotpConfig as aF, type TotpSetup as aG, type UsernameAuthConfig as aH, type ValidateTokenResult as aI, type VerificationMethod as aJ, agentCards as aK, agentDids as aL, agents as aM, apiKeys as aN, approvalRequests as aO, auditLogs as aP, budgetPolicies as aQ, classifyViolation as aR, createAdminModule as aS, createApiKeyManagerModule as aT, createApprovalModule as aU, createCaptchaModule as aV, createDatabase as aW, createDatabaseSync as aX, createEmailOtpModule as aY, createEmailVerificationModule as aZ, createMagicLinkModule as a_, type EmailOtpConfig as aa, type EmailVerificationConfig as ab, type KavachHooks as ac, type KavachInstance as ad, type MagicLinkConfig as ae, type McpMiddleware as af, type OidcProvider as ag, type OneTimeTokenConfig as ah, type OneTimeTokenPurpose as ai, type OrgConfig as aj, type OrgInvitation as ak, type OrgMember as al, type OrgRole as am, type Organization as an, type PasskeyConfig as ao, type PasskeyCredential as ap, type PasswordResetConfig as aq, type PermissionConstraints as ar, type PhoneAuthConfig as as, type PluginContext as at, type PluginInitResult as au, type RevokeTokensResult as av, SSO_ERROR as aw, type SamlProvider as ax, type ServiceEndpoint as ay, type SessionFreshnessConfig as az, type DelegateInput as b, createOrgModule as b0, createPasskeyModule as b1, createPasswordResetModule as b2, createPhoneAuthModule as b3, createSessionFreshnessModule as b4, createSessionManager as b5, createSsoModule as b6, createTotpModule as b7, createUsernameAuthModule as b8, delegationChains as b9, emailOtps as ba, magicLinks as bb, mcpServers as bc, oauthAccessTokens as bd, oauthAuthorizationCodes as be, oauthClients as bf, orgInvitations as bg, orgMembers as bh, orgRoles as bi, organizations as bj, passkeyChallenges as bk, passkeyCredentials as bl, permissions as bm, rateLimits as bn, sessions as bo, ssoConnections as bp, tenants as bq, totpRecords as br, trustScores as bs, users as bt, type WebhookConfig as bu, type WebhookEvent as bv, createWebhookModule as bw, type DelegationChain as c, type DidDocument as d, type DidKeyPair as e, type DidWebConfig as f, type AgentDid as g, type AgentFilter as h, type AuthorizeRequest as i, type AuthorizeResult as j, type AuditFilter as k, type AuditEntry as l, type AuditExportOptions as m, type McpServer as n, type ResolvedUser as o, type SessionManager as p, type ApprovalRequest as q, type MagicLinkModule as r, type PasskeyModule as s, type SsoModule as t, type AdminModule as u, type ApiKeyManagerModule as v, type UsernameAuthModule as w, type PasswordResetModule as x, type EmailVerificationModule as y, type OneTimeTokenModule as z };
|
package/dist/vc/index.d.ts
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { l as AuditEntry } from '../types-RJPOU4un.js';
|
|
2
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';
|
|
3
6
|
|
|
4
7
|
/**
|
|
5
8
|
* W3C Verifiable Credentials Data Model 2.0 types for KavachOS.
|
|
@@ -84,35 +87,55 @@ declare const CredentialSubjectSchema: z.ZodObject<{
|
|
|
84
87
|
}>, "many">>;
|
|
85
88
|
name: z.ZodOptional<z.ZodString>;
|
|
86
89
|
type: z.ZodOptional<z.ZodString>;
|
|
87
|
-
}, "
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
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, {
|
|
96
102
|
createdAt: string;
|
|
97
103
|
permissions: string[];
|
|
98
104
|
delegator: string;
|
|
99
105
|
delegatee: string;
|
|
100
|
-
}
|
|
101
|
-
}, {
|
|
102
|
-
name?: string | undefined;
|
|
103
|
-
id?: string | undefined;
|
|
104
|
-
type?: string | undefined;
|
|
105
|
-
agentId?: string | undefined;
|
|
106
|
-
permissions?: string[] | undefined;
|
|
107
|
-
trustLevel?: number | undefined;
|
|
108
|
-
delegationScope?: string[] | undefined;
|
|
109
|
-
delegationChain?: {
|
|
106
|
+
}, {
|
|
110
107
|
createdAt: string;
|
|
111
108
|
permissions: string[];
|
|
112
109
|
delegator: string;
|
|
113
110
|
delegatee: string;
|
|
114
|
-
}
|
|
115
|
-
|
|
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">>;
|
|
116
139
|
type CredentialSubject = z.infer<typeof CredentialSubjectSchema>;
|
|
117
140
|
declare const VerifiableCredentialSchema: z.ZodObject<{
|
|
118
141
|
"@context": z.ZodArray<z.ZodString, "many">;
|
|
@@ -154,35 +177,55 @@ declare const VerifiableCredentialSchema: z.ZodObject<{
|
|
|
154
177
|
}>, "many">>;
|
|
155
178
|
name: z.ZodOptional<z.ZodString>;
|
|
156
179
|
type: z.ZodOptional<z.ZodString>;
|
|
157
|
-
}, "
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
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, {
|
|
166
192
|
createdAt: string;
|
|
167
193
|
permissions: string[];
|
|
168
194
|
delegator: string;
|
|
169
195
|
delegatee: string;
|
|
170
|
-
}
|
|
171
|
-
}, {
|
|
172
|
-
name?: string | undefined;
|
|
173
|
-
id?: string | undefined;
|
|
174
|
-
type?: string | undefined;
|
|
175
|
-
agentId?: string | undefined;
|
|
176
|
-
permissions?: string[] | undefined;
|
|
177
|
-
trustLevel?: number | undefined;
|
|
178
|
-
delegationScope?: string[] | undefined;
|
|
179
|
-
delegationChain?: {
|
|
196
|
+
}, {
|
|
180
197
|
createdAt: string;
|
|
181
198
|
permissions: string[];
|
|
182
199
|
delegator: string;
|
|
183
200
|
delegatee: string;
|
|
184
|
-
}
|
|
185
|
-
|
|
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">>;
|
|
186
229
|
credentialStatus: z.ZodOptional<z.ZodObject<{
|
|
187
230
|
id: z.ZodString;
|
|
188
231
|
type: z.ZodString;
|
|
@@ -246,6 +289,8 @@ declare const VerifiableCredentialSchema: z.ZodObject<{
|
|
|
246
289
|
delegator: string;
|
|
247
290
|
delegatee: string;
|
|
248
291
|
}[] | undefined;
|
|
292
|
+
} & {
|
|
293
|
+
[k: string]: unknown;
|
|
249
294
|
};
|
|
250
295
|
id?: string | undefined;
|
|
251
296
|
expirationDate?: string | undefined;
|
|
@@ -286,6 +331,8 @@ declare const VerifiableCredentialSchema: z.ZodObject<{
|
|
|
286
331
|
delegator: string;
|
|
287
332
|
delegatee: string;
|
|
288
333
|
}[] | undefined;
|
|
334
|
+
} & {
|
|
335
|
+
[k: string]: unknown;
|
|
289
336
|
};
|
|
290
337
|
id?: string | undefined;
|
|
291
338
|
expirationDate?: string | undefined;
|
|
@@ -351,35 +398,55 @@ declare const VerifiablePresentationSchema: z.ZodObject<{
|
|
|
351
398
|
}>, "many">>;
|
|
352
399
|
name: z.ZodOptional<z.ZodString>;
|
|
353
400
|
type: z.ZodOptional<z.ZodString>;
|
|
354
|
-
}, "
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
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, {
|
|
363
413
|
createdAt: string;
|
|
364
414
|
permissions: string[];
|
|
365
415
|
delegator: string;
|
|
366
416
|
delegatee: string;
|
|
367
|
-
}
|
|
368
|
-
}, {
|
|
369
|
-
name?: string | undefined;
|
|
370
|
-
id?: string | undefined;
|
|
371
|
-
type?: string | undefined;
|
|
372
|
-
agentId?: string | undefined;
|
|
373
|
-
permissions?: string[] | undefined;
|
|
374
|
-
trustLevel?: number | undefined;
|
|
375
|
-
delegationScope?: string[] | undefined;
|
|
376
|
-
delegationChain?: {
|
|
417
|
+
}, {
|
|
377
418
|
createdAt: string;
|
|
378
419
|
permissions: string[];
|
|
379
420
|
delegator: string;
|
|
380
421
|
delegatee: string;
|
|
381
|
-
}
|
|
382
|
-
|
|
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">>;
|
|
383
450
|
credentialStatus: z.ZodOptional<z.ZodObject<{
|
|
384
451
|
id: z.ZodString;
|
|
385
452
|
type: z.ZodString;
|
|
@@ -443,6 +510,8 @@ declare const VerifiablePresentationSchema: z.ZodObject<{
|
|
|
443
510
|
delegator: string;
|
|
444
511
|
delegatee: string;
|
|
445
512
|
}[] | undefined;
|
|
513
|
+
} & {
|
|
514
|
+
[k: string]: unknown;
|
|
446
515
|
};
|
|
447
516
|
id?: string | undefined;
|
|
448
517
|
expirationDate?: string | undefined;
|
|
@@ -483,6 +552,8 @@ declare const VerifiablePresentationSchema: z.ZodObject<{
|
|
|
483
552
|
delegator: string;
|
|
484
553
|
delegatee: string;
|
|
485
554
|
}[] | undefined;
|
|
555
|
+
} & {
|
|
556
|
+
[k: string]: unknown;
|
|
486
557
|
};
|
|
487
558
|
id?: string | undefined;
|
|
488
559
|
expirationDate?: string | undefined;
|
|
@@ -549,6 +620,8 @@ declare const VerifiablePresentationSchema: z.ZodObject<{
|
|
|
549
620
|
delegator: string;
|
|
550
621
|
delegatee: string;
|
|
551
622
|
}[] | undefined;
|
|
623
|
+
} & {
|
|
624
|
+
[k: string]: unknown;
|
|
552
625
|
};
|
|
553
626
|
id?: string | undefined;
|
|
554
627
|
expirationDate?: string | undefined;
|
|
@@ -603,6 +676,8 @@ declare const VerifiablePresentationSchema: z.ZodObject<{
|
|
|
603
676
|
delegator: string;
|
|
604
677
|
delegatee: string;
|
|
605
678
|
}[] | undefined;
|
|
679
|
+
} & {
|
|
680
|
+
[k: string]: unknown;
|
|
606
681
|
};
|
|
607
682
|
id?: string | undefined;
|
|
608
683
|
expirationDate?: string | undefined;
|
|
@@ -691,6 +766,120 @@ interface ExtractedPermissions {
|
|
|
691
766
|
delegationScope: string[];
|
|
692
767
|
}
|
|
693
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://kavachos.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 KAVACHOS_AUDIT_CREDENTIAL = "KavachosAuditCredential";
|
|
783
|
+
/**
|
|
784
|
+
* Context URL for KavachosAuditCredential.
|
|
785
|
+
* Defined locally — the URL does not need to resolve at runtime.
|
|
786
|
+
*/
|
|
787
|
+
declare const KAVACHOS_AUDIT_CONTEXT = "https://kavachos.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 KavachosAuditCredential. */
|
|
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
|
+
kavachosVersion: 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
|
+
|
|
694
883
|
/**
|
|
695
884
|
* W3C Verifiable Credential issuance for KavachOS.
|
|
696
885
|
*
|
|
@@ -797,4 +986,4 @@ interface VCVerifier {
|
|
|
797
986
|
*/
|
|
798
987
|
declare function createVCVerifier(config?: VCVerifierConfig): VCVerifier;
|
|
799
988
|
|
|
800
|
-
export { type CredentialFormat, type CredentialStatus, CredentialStatusSchema, type CredentialSubject, CredentialSubjectSchema, type DelegationLink, type ExtractedPermissions, type IssueAgentCredentialInput, type IssueDelegationCredentialInput, type IssuePermissionCredentialInput, KAVACH_AGENT_CREDENTIAL, KAVACH_DELEGATION_CREDENTIAL, KAVACH_PERMISSION_CREDENTIAL, type Proof, ProofSchema, 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 };
|
|
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, KAVACHOS_AUDIT_CONTEXT, KAVACHOS_AUDIT_CREDENTIAL, KAVACH_AGENT_CREDENTIAL, KAVACH_DELEGATION_CREDENTIAL, KAVACH_PERMISSION_CREDENTIAL, type Proof, ProofSchema, 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 };
|