@kya-os/contracts 1.3.3 → 1.3.4
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/package.json +3 -2
- package/README.md +0 -130
- package/dist/agentshield-api/endpoints.d.ts +0 -21
- package/dist/agentshield-api/endpoints.js +0 -20
- package/dist/agentshield-api/index.d.ts +0 -5
- package/dist/agentshield-api/index.js +0 -27
- package/dist/agentshield-api/schemas.d.ts +0 -9846
- package/dist/agentshield-api/schemas.js +0 -92
- package/dist/agentshield-api/types.d.ts +0 -92
- package/dist/agentshield-api/types.js +0 -12
- package/dist/cli.d.ts +0 -375
- package/dist/cli.js +0 -109
- package/dist/config/base.d.ts +0 -19
- package/dist/config/base.js +0 -2
- package/dist/config/delegation.d.ts +0 -46
- package/dist/config/delegation.js +0 -2
- package/dist/config/identity.d.ts +0 -22
- package/dist/config/identity.js +0 -2
- package/dist/config/index.d.ts +0 -17
- package/dist/config/index.js +0 -2
- package/dist/config/proofing.d.ts +0 -26
- package/dist/config/proofing.js +0 -2
- package/dist/config/tool-protection.d.ts +0 -36
- package/dist/config/tool-protection.js +0 -2
- package/dist/delegation/constraints.d.ts +0 -726
- package/dist/delegation/constraints.js +0 -103
- package/dist/delegation/index.d.ts +0 -2
- package/dist/delegation/index.js +0 -18
- package/dist/delegation/schemas.d.ts +0 -8042
- package/dist/delegation/schemas.js +0 -232
- package/dist/did/index.d.ts +0 -3
- package/dist/did/index.js +0 -19
- package/dist/did/resolve-contract.d.ts +0 -53
- package/dist/did/resolve-contract.js +0 -12
- package/dist/did/schemas.d.ts +0 -33
- package/dist/did/schemas.js +0 -80
- package/dist/did/types.d.ts +0 -38
- package/dist/did/types.js +0 -37
- package/dist/env/constants.d.ts +0 -13
- package/dist/env/constants.js +0 -15
- package/dist/env/index.d.ts +0 -1
- package/dist/env/index.js +0 -17
- package/dist/handshake.d.ts +0 -138
- package/dist/handshake.js +0 -50
- package/dist/index.d.ts +0 -11
- package/dist/index.js +0 -28
- package/dist/proof/index.d.ts +0 -2
- package/dist/proof/index.js +0 -18
- package/dist/proof/proof-record.d.ts +0 -728
- package/dist/proof/proof-record.js +0 -60
- package/dist/proof/signing-spec.d.ts +0 -73
- package/dist/proof/signing-spec.js +0 -52
- package/dist/proof.d.ts +0 -378
- package/dist/proof.js +0 -59
- package/dist/registry.d.ts +0 -326
- package/dist/registry.js +0 -98
- package/dist/runtime/errors.d.ts +0 -179
- package/dist/runtime/errors.js +0 -51
- package/dist/runtime/headers.d.ts +0 -34
- package/dist/runtime/headers.js +0 -52
- package/dist/runtime/index.d.ts +0 -2
- package/dist/runtime/index.js +0 -18
- package/dist/test.d.ts +0 -215
- package/dist/test.js +0 -83
- package/dist/tlkrc/index.d.ts +0 -1
- package/dist/tlkrc/index.js +0 -17
- package/dist/tlkrc/rotation.d.ts +0 -168
- package/dist/tlkrc/rotation.js +0 -55
- package/dist/tool-protection/index.d.ts +0 -129
- package/dist/tool-protection/index.js +0 -80
- package/dist/utils/validation.d.ts +0 -14
- package/dist/utils/validation.js +0 -56
- package/dist/vc/index.d.ts +0 -2
- package/dist/vc/index.js +0 -18
- package/dist/vc/schemas.d.ts +0 -1888
- package/dist/vc/schemas.js +0 -116
- package/dist/vc/statuslist.d.ts +0 -292
- package/dist/vc/statuslist.js +0 -61
- package/dist/verifier.d.ts +0 -202
- package/dist/verifier.js +0 -76
- package/dist/well-known/index.d.ts +0 -248
- package/dist/well-known/index.js +0 -104
|
@@ -1,232 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DelegationCredentialSchema = exports.DelegationCredentialSubjectSchema = exports.DELEGATION_CREDENTIAL_CONTEXT = exports.DELEGATION_STATUSES = exports.DEFAULT_DELEGATION_STATUS = exports.MAX_DELEGATION_CHAIN_DEPTH = exports.DelegationVerificationResultSchema = exports.DelegationCreationRequestSchema = exports.DelegationChainSchema = exports.DelegationChainEntrySchema = exports.DelegationRecordSchema = exports.DelegationStatusSchema = void 0;
|
|
4
|
-
exports.validateDelegationRecord = validateDelegationRecord;
|
|
5
|
-
exports.validateDelegationChain = validateDelegationChain;
|
|
6
|
-
exports.isDelegationExpired = isDelegationExpired;
|
|
7
|
-
exports.isDelegationNotYetValid = isDelegationNotYetValid;
|
|
8
|
-
exports.isDelegationCurrentlyValid = isDelegationCurrentlyValid;
|
|
9
|
-
exports.validateDelegationCredential = validateDelegationCredential;
|
|
10
|
-
exports.extractDelegationFromVC = extractDelegationFromVC;
|
|
11
|
-
exports.wrapDelegationAsVC = wrapDelegationAsVC;
|
|
12
|
-
exports.isDelegationCredentialExpired = isDelegationCredentialExpired;
|
|
13
|
-
exports.isDelegationCredentialNotYetValid = isDelegationCredentialNotYetValid;
|
|
14
|
-
const zod_1 = require("zod");
|
|
15
|
-
const constraints_js_1 = require("./constraints.js");
|
|
16
|
-
const schemas_js_1 = require("../vc/schemas.js");
|
|
17
|
-
exports.DelegationStatusSchema = zod_1.z.enum(['active', 'revoked', 'expired']);
|
|
18
|
-
exports.DelegationRecordSchema = zod_1.z.object({
|
|
19
|
-
id: zod_1.z.string().min(1),
|
|
20
|
-
issuerDid: zod_1.z.string().min(1),
|
|
21
|
-
subjectDid: zod_1.z.string().min(1),
|
|
22
|
-
controller: zod_1.z.string().optional(),
|
|
23
|
-
vcId: zod_1.z.string().min(1),
|
|
24
|
-
parentId: zod_1.z.string().optional(),
|
|
25
|
-
constraints: constraints_js_1.DelegationConstraintsSchema,
|
|
26
|
-
signature: zod_1.z.string().min(1),
|
|
27
|
-
status: exports.DelegationStatusSchema,
|
|
28
|
-
createdAt: zod_1.z.number().int().positive().optional(),
|
|
29
|
-
revokedAt: zod_1.z.number().int().positive().optional(),
|
|
30
|
-
revokedReason: zod_1.z.string().optional(),
|
|
31
|
-
metadata: zod_1.z.record(zod_1.z.any()).optional(),
|
|
32
|
-
}).passthrough();
|
|
33
|
-
exports.DelegationChainEntrySchema = zod_1.z.object({
|
|
34
|
-
delegationId: zod_1.z.string().min(1),
|
|
35
|
-
issuerDid: zod_1.z.string().min(1),
|
|
36
|
-
subjectDid: zod_1.z.string().min(1),
|
|
37
|
-
vcId: zod_1.z.string().min(1),
|
|
38
|
-
depth: zod_1.z.number().int().nonnegative(),
|
|
39
|
-
constraints: constraints_js_1.DelegationConstraintsSchema,
|
|
40
|
-
status: exports.DelegationStatusSchema,
|
|
41
|
-
});
|
|
42
|
-
exports.DelegationChainSchema = zod_1.z.object({
|
|
43
|
-
rootIssuer: zod_1.z.string().min(1),
|
|
44
|
-
leafSubject: zod_1.z.string().min(1),
|
|
45
|
-
chain: zod_1.z.array(exports.DelegationChainEntrySchema).min(1),
|
|
46
|
-
depth: zod_1.z.number().int().nonnegative(),
|
|
47
|
-
valid: zod_1.z.boolean(),
|
|
48
|
-
errors: zod_1.z.array(zod_1.z.string()).optional(),
|
|
49
|
-
});
|
|
50
|
-
exports.DelegationCreationRequestSchema = zod_1.z.object({
|
|
51
|
-
issuerDid: zod_1.z.string().min(1),
|
|
52
|
-
subjectDid: zod_1.z.string().min(1),
|
|
53
|
-
controller: zod_1.z.string().optional(),
|
|
54
|
-
constraints: constraints_js_1.DelegationConstraintsSchema,
|
|
55
|
-
parentId: zod_1.z.string().optional(),
|
|
56
|
-
vcId: zod_1.z.string().optional(),
|
|
57
|
-
});
|
|
58
|
-
exports.DelegationVerificationResultSchema = zod_1.z.object({
|
|
59
|
-
valid: zod_1.z.boolean(),
|
|
60
|
-
delegationId: zod_1.z.string().min(1),
|
|
61
|
-
status: exports.DelegationStatusSchema,
|
|
62
|
-
reason: zod_1.z.string().optional(),
|
|
63
|
-
credentialValid: zod_1.z.boolean().optional(),
|
|
64
|
-
chainValid: zod_1.z.boolean().optional(),
|
|
65
|
-
verifiedAt: zod_1.z.number().int().positive(),
|
|
66
|
-
details: zod_1.z.record(zod_1.z.any()).optional(),
|
|
67
|
-
});
|
|
68
|
-
function validateDelegationRecord(record) {
|
|
69
|
-
return exports.DelegationRecordSchema.safeParse(record);
|
|
70
|
-
}
|
|
71
|
-
function validateDelegationChain(chain) {
|
|
72
|
-
return exports.DelegationChainSchema.safeParse(chain);
|
|
73
|
-
}
|
|
74
|
-
function isDelegationExpired(delegation) {
|
|
75
|
-
if (!delegation.constraints.notAfter) {
|
|
76
|
-
return false;
|
|
77
|
-
}
|
|
78
|
-
const nowSec = Math.floor(Date.now() / 1000);
|
|
79
|
-
return nowSec > delegation.constraints.notAfter;
|
|
80
|
-
}
|
|
81
|
-
function isDelegationNotYetValid(delegation) {
|
|
82
|
-
if (!delegation.constraints.notBefore) {
|
|
83
|
-
return false;
|
|
84
|
-
}
|
|
85
|
-
const nowSec = Math.floor(Date.now() / 1000);
|
|
86
|
-
return nowSec < delegation.constraints.notBefore;
|
|
87
|
-
}
|
|
88
|
-
function isDelegationCurrentlyValid(delegation) {
|
|
89
|
-
if (delegation.status !== 'active') {
|
|
90
|
-
return false;
|
|
91
|
-
}
|
|
92
|
-
if (isDelegationExpired(delegation)) {
|
|
93
|
-
return false;
|
|
94
|
-
}
|
|
95
|
-
if (isDelegationNotYetValid(delegation)) {
|
|
96
|
-
return false;
|
|
97
|
-
}
|
|
98
|
-
return true;
|
|
99
|
-
}
|
|
100
|
-
exports.MAX_DELEGATION_CHAIN_DEPTH = 10;
|
|
101
|
-
exports.DEFAULT_DELEGATION_STATUS = 'active';
|
|
102
|
-
exports.DELEGATION_STATUSES = ['active', 'revoked', 'expired'];
|
|
103
|
-
exports.DELEGATION_CREDENTIAL_CONTEXT = 'https://schemas.kya-os.ai/xmcp-i/credentials/delegation.v1.0.0.json';
|
|
104
|
-
exports.DelegationCredentialSubjectSchema = zod_1.z.object({
|
|
105
|
-
id: zod_1.z.string().min(1),
|
|
106
|
-
delegation: zod_1.z.object({
|
|
107
|
-
id: zod_1.z.string().min(1),
|
|
108
|
-
issuerDid: zod_1.z.string().min(1),
|
|
109
|
-
subjectDid: zod_1.z.string().min(1),
|
|
110
|
-
controller: zod_1.z.string().optional(),
|
|
111
|
-
parentId: zod_1.z.string().optional(),
|
|
112
|
-
constraints: constraints_js_1.DelegationConstraintsSchema,
|
|
113
|
-
status: exports.DelegationStatusSchema.default('active'),
|
|
114
|
-
createdAt: zod_1.z.number().int().positive().optional(),
|
|
115
|
-
metadata: zod_1.z.record(zod_1.z.any()).optional(),
|
|
116
|
-
}),
|
|
117
|
-
});
|
|
118
|
-
exports.DelegationCredentialSchema = schemas_js_1.VerifiableCredentialSchema.extend({
|
|
119
|
-
'@context': zod_1.z
|
|
120
|
-
.array(zod_1.z.union([zod_1.z.string().url(), zod_1.z.record(zod_1.z.any())]))
|
|
121
|
-
.refine((contexts) => {
|
|
122
|
-
const firstContext = contexts[0];
|
|
123
|
-
if (typeof firstContext !== 'string' ||
|
|
124
|
-
firstContext !== 'https://www.w3.org/2018/credentials/v1') {
|
|
125
|
-
return false;
|
|
126
|
-
}
|
|
127
|
-
return true;
|
|
128
|
-
}, {
|
|
129
|
-
message: 'First @context must be W3C VC context',
|
|
130
|
-
}),
|
|
131
|
-
type: zod_1.z
|
|
132
|
-
.array(zod_1.z.string())
|
|
133
|
-
.refine((types) => types.includes('VerifiableCredential') &&
|
|
134
|
-
types.includes('DelegationCredential'), {
|
|
135
|
-
message: 'type must include both "VerifiableCredential" and "DelegationCredential"',
|
|
136
|
-
}),
|
|
137
|
-
issuer: schemas_js_1.IssuerSchema,
|
|
138
|
-
issuanceDate: zod_1.z.string().datetime(),
|
|
139
|
-
expirationDate: zod_1.z.string().datetime().optional(),
|
|
140
|
-
credentialSubject: exports.DelegationCredentialSubjectSchema,
|
|
141
|
-
credentialStatus: schemas_js_1.CredentialStatusSchema.optional(),
|
|
142
|
-
proof: schemas_js_1.ProofSchema.optional(),
|
|
143
|
-
});
|
|
144
|
-
function validateDelegationCredential(credential) {
|
|
145
|
-
return exports.DelegationCredentialSchema.safeParse(credential);
|
|
146
|
-
}
|
|
147
|
-
function extractDelegationFromVC(vc) {
|
|
148
|
-
const delegation = vc.credentialSubject.delegation;
|
|
149
|
-
let signature = '';
|
|
150
|
-
if (vc.proof) {
|
|
151
|
-
const proof = vc.proof;
|
|
152
|
-
signature = proof.proofValue || proof.jws || proof.signatureValue || '';
|
|
153
|
-
}
|
|
154
|
-
return {
|
|
155
|
-
id: delegation.id,
|
|
156
|
-
issuerDid: delegation.issuerDid,
|
|
157
|
-
subjectDid: delegation.subjectDid,
|
|
158
|
-
controller: delegation.controller,
|
|
159
|
-
vcId: vc.id || `vc:${delegation.id}`,
|
|
160
|
-
parentId: delegation.parentId,
|
|
161
|
-
constraints: delegation.constraints,
|
|
162
|
-
signature,
|
|
163
|
-
status: delegation.status,
|
|
164
|
-
createdAt: delegation.createdAt,
|
|
165
|
-
revokedAt: undefined,
|
|
166
|
-
revokedReason: undefined,
|
|
167
|
-
metadata: delegation.metadata,
|
|
168
|
-
};
|
|
169
|
-
}
|
|
170
|
-
function wrapDelegationAsVC(delegation, options) {
|
|
171
|
-
const now = new Date().toISOString();
|
|
172
|
-
const expirationDate = delegation.constraints.notAfter
|
|
173
|
-
? new Date(delegation.constraints.notAfter * 1000).toISOString()
|
|
174
|
-
: options?.expirationDate;
|
|
175
|
-
let issuanceDate = options?.issuanceDate || now;
|
|
176
|
-
if (!options?.issuanceDate && delegation.createdAt) {
|
|
177
|
-
issuanceDate = new Date(delegation.createdAt).toISOString();
|
|
178
|
-
}
|
|
179
|
-
return {
|
|
180
|
-
'@context': [
|
|
181
|
-
'https://www.w3.org/2018/credentials/v1',
|
|
182
|
-
exports.DELEGATION_CREDENTIAL_CONTEXT,
|
|
183
|
-
],
|
|
184
|
-
id: options?.id || delegation.vcId || `urn:uuid:${delegation.id}`,
|
|
185
|
-
type: ['VerifiableCredential', 'DelegationCredential'],
|
|
186
|
-
issuer: delegation.issuerDid,
|
|
187
|
-
issuanceDate,
|
|
188
|
-
expirationDate,
|
|
189
|
-
credentialSubject: {
|
|
190
|
-
id: delegation.subjectDid,
|
|
191
|
-
delegation: {
|
|
192
|
-
id: delegation.id,
|
|
193
|
-
issuerDid: delegation.issuerDid,
|
|
194
|
-
subjectDid: delegation.subjectDid,
|
|
195
|
-
controller: delegation.controller,
|
|
196
|
-
parentId: delegation.parentId,
|
|
197
|
-
constraints: delegation.constraints,
|
|
198
|
-
status: delegation.status,
|
|
199
|
-
createdAt: delegation.createdAt,
|
|
200
|
-
metadata: delegation.metadata,
|
|
201
|
-
},
|
|
202
|
-
},
|
|
203
|
-
credentialStatus: options?.credentialStatus,
|
|
204
|
-
};
|
|
205
|
-
}
|
|
206
|
-
function isDelegationCredentialExpired(vc) {
|
|
207
|
-
if (vc.expirationDate) {
|
|
208
|
-
const expirationDate = new Date(vc.expirationDate);
|
|
209
|
-
const now = new Date();
|
|
210
|
-
if (expirationDate < now) {
|
|
211
|
-
return true;
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
const delegation = vc.credentialSubject.delegation;
|
|
215
|
-
if (delegation.constraints.notAfter) {
|
|
216
|
-
const nowSec = Math.floor(Date.now() / 1000);
|
|
217
|
-
if (nowSec > delegation.constraints.notAfter) {
|
|
218
|
-
return true;
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
return false;
|
|
222
|
-
}
|
|
223
|
-
function isDelegationCredentialNotYetValid(vc) {
|
|
224
|
-
const delegation = vc.credentialSubject.delegation;
|
|
225
|
-
if (delegation.constraints.notBefore) {
|
|
226
|
-
const nowSec = Math.floor(Date.now() / 1000);
|
|
227
|
-
if (nowSec < delegation.constraints.notBefore) {
|
|
228
|
-
return true;
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
|
-
return false;
|
|
232
|
-
}
|
package/dist/did/index.d.ts
DELETED
package/dist/did/index.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./types.js"), exports);
|
|
18
|
-
__exportStar(require("./resolve-contract.js"), exports);
|
|
19
|
-
__exportStar(require("./schemas.js"), exports);
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import type { DidDocument } from './types.js';
|
|
2
|
-
export interface ResolveOptions {
|
|
3
|
-
timeoutMs?: number;
|
|
4
|
-
acceptCache?: boolean;
|
|
5
|
-
cacheTtlSec?: number;
|
|
6
|
-
metadata?: Record<string, any>;
|
|
7
|
-
}
|
|
8
|
-
export interface ResolveResult {
|
|
9
|
-
doc: DidDocument;
|
|
10
|
-
fetchedAt: number;
|
|
11
|
-
cacheTtlSec?: number;
|
|
12
|
-
metadata?: {
|
|
13
|
-
source?: string;
|
|
14
|
-
method?: string;
|
|
15
|
-
fromCache?: boolean;
|
|
16
|
-
[key: string]: any;
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
export interface ResolutionError {
|
|
20
|
-
code: string;
|
|
21
|
-
message: string;
|
|
22
|
-
cause?: Error;
|
|
23
|
-
details?: Record<string, any>;
|
|
24
|
-
}
|
|
25
|
-
export interface DidResolver {
|
|
26
|
-
resolve(did: string, opts?: ResolveOptions): Promise<ResolveResult>;
|
|
27
|
-
}
|
|
28
|
-
export interface DidMethodResolver {
|
|
29
|
-
readonly method: string;
|
|
30
|
-
resolve(did: string, opts?: ResolveOptions): Promise<ResolveResult>;
|
|
31
|
-
supports(did: string): boolean;
|
|
32
|
-
}
|
|
33
|
-
export interface DidResolutionCache {
|
|
34
|
-
get(did: string): Promise<ResolveResult | null>;
|
|
35
|
-
set(did: string, result: ResolveResult, ttlSec: number): Promise<void>;
|
|
36
|
-
invalidate(did: string): Promise<void>;
|
|
37
|
-
clear(): Promise<void>;
|
|
38
|
-
}
|
|
39
|
-
export interface UniversalResolverConfig {
|
|
40
|
-
methodResolvers?: Map<string, DidMethodResolver> | Record<string, DidMethodResolver>;
|
|
41
|
-
cache?: DidResolutionCache;
|
|
42
|
-
defaultOptions?: ResolveOptions;
|
|
43
|
-
}
|
|
44
|
-
export declare const RESOLUTION_ERROR_CODES: {
|
|
45
|
-
readonly NOT_FOUND: "notFound";
|
|
46
|
-
readonly INVALID_DID: "invalidDid";
|
|
47
|
-
readonly METHOD_NOT_SUPPORTED: "methodNotSupported";
|
|
48
|
-
readonly TIMEOUT: "timeout";
|
|
49
|
-
readonly NETWORK_ERROR: "networkError";
|
|
50
|
-
readonly INVALID_DOCUMENT: "invalidDocument";
|
|
51
|
-
readonly INTERNAL_ERROR: "internalError";
|
|
52
|
-
};
|
|
53
|
-
export type ResolutionErrorCode = (typeof RESOLUTION_ERROR_CODES)[keyof typeof RESOLUTION_ERROR_CODES];
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.RESOLUTION_ERROR_CODES = void 0;
|
|
4
|
-
exports.RESOLUTION_ERROR_CODES = {
|
|
5
|
-
NOT_FOUND: 'notFound',
|
|
6
|
-
INVALID_DID: 'invalidDid',
|
|
7
|
-
METHOD_NOT_SUPPORTED: 'methodNotSupported',
|
|
8
|
-
TIMEOUT: 'timeout',
|
|
9
|
-
NETWORK_ERROR: 'networkError',
|
|
10
|
-
INVALID_DOCUMENT: 'invalidDocument',
|
|
11
|
-
INTERNAL_ERROR: 'internalError',
|
|
12
|
-
};
|
package/dist/did/schemas.d.ts
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
import type { DidDocument, VerificationMethod, DidService } from './types.js';
|
|
3
|
-
export declare const DID_CONTEXT: "https://www.w3.org/ns/did/v1";
|
|
4
|
-
export declare const DidContextEntrySchema: z.ZodUnion<[z.ZodString, z.ZodRecord<z.ZodString, z.ZodAny>]>;
|
|
5
|
-
export declare const DidContextSchema: z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodRecord<z.ZodString, z.ZodAny>]>, "atleastone">, z.ZodRecord<z.ZodString, z.ZodAny>]>;
|
|
6
|
-
export declare const VerificationMethodTypeSchema: z.ZodEnum<["Ed25519VerificationKey2020", "JsonWebKey2020", "EcdsaSecp256k1VerificationKey2019"]>;
|
|
7
|
-
export declare const PublicKeyJwkSchema: z.ZodObject<{
|
|
8
|
-
kty: z.ZodString;
|
|
9
|
-
crv: z.ZodString;
|
|
10
|
-
x: z.ZodString;
|
|
11
|
-
y: z.ZodOptional<z.ZodString>;
|
|
12
|
-
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
|
13
|
-
kty: z.ZodString;
|
|
14
|
-
crv: z.ZodString;
|
|
15
|
-
x: z.ZodString;
|
|
16
|
-
y: z.ZodOptional<z.ZodString>;
|
|
17
|
-
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
18
|
-
kty: z.ZodString;
|
|
19
|
-
crv: z.ZodString;
|
|
20
|
-
x: z.ZodString;
|
|
21
|
-
y: z.ZodOptional<z.ZodString>;
|
|
22
|
-
}, z.ZodTypeAny, "passthrough">>;
|
|
23
|
-
export declare const VerificationMethodSchema: z.ZodType<VerificationMethod>;
|
|
24
|
-
export declare const DidServiceSchema: z.ZodType<DidService>;
|
|
25
|
-
export declare const VerificationRelationshipEntrySchema: z.ZodUnion<[z.ZodString, z.ZodType<VerificationMethod, z.ZodTypeDef, VerificationMethod>]>;
|
|
26
|
-
export declare const DidDocumentSchema: z.ZodType<DidDocument>;
|
|
27
|
-
export declare const DidMethodSchema: z.ZodEnum<["key", "web", "jwk", "ion", "ebsi"]>;
|
|
28
|
-
export declare function validateDidDocument(doc: unknown): DidDocument;
|
|
29
|
-
export declare function safeValidateDidDocument(doc: unknown): {
|
|
30
|
-
success: boolean;
|
|
31
|
-
data?: DidDocument;
|
|
32
|
-
error?: z.ZodError;
|
|
33
|
-
};
|
package/dist/did/schemas.js
DELETED
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DidMethodSchema = exports.DidDocumentSchema = exports.VerificationRelationshipEntrySchema = exports.DidServiceSchema = exports.VerificationMethodSchema = exports.PublicKeyJwkSchema = exports.VerificationMethodTypeSchema = exports.DidContextSchema = exports.DidContextEntrySchema = exports.DID_CONTEXT = void 0;
|
|
4
|
-
exports.validateDidDocument = validateDidDocument;
|
|
5
|
-
exports.safeValidateDidDocument = safeValidateDidDocument;
|
|
6
|
-
const zod_1 = require("zod");
|
|
7
|
-
exports.DID_CONTEXT = 'https://www.w3.org/ns/did/v1';
|
|
8
|
-
exports.DidContextEntrySchema = zod_1.z.union([
|
|
9
|
-
zod_1.z.string().url(),
|
|
10
|
-
zod_1.z.record(zod_1.z.any()),
|
|
11
|
-
]);
|
|
12
|
-
exports.DidContextSchema = zod_1.z.union([
|
|
13
|
-
zod_1.z.string().url(),
|
|
14
|
-
zod_1.z.array(exports.DidContextEntrySchema).nonempty(),
|
|
15
|
-
zod_1.z.record(zod_1.z.any()),
|
|
16
|
-
]);
|
|
17
|
-
exports.VerificationMethodTypeSchema = zod_1.z.enum([
|
|
18
|
-
'Ed25519VerificationKey2020',
|
|
19
|
-
'JsonWebKey2020',
|
|
20
|
-
'EcdsaSecp256k1VerificationKey2019',
|
|
21
|
-
]);
|
|
22
|
-
exports.PublicKeyJwkSchema = zod_1.z
|
|
23
|
-
.object({
|
|
24
|
-
kty: zod_1.z.string(),
|
|
25
|
-
crv: zod_1.z.string(),
|
|
26
|
-
x: zod_1.z.string(),
|
|
27
|
-
y: zod_1.z.string().optional(),
|
|
28
|
-
})
|
|
29
|
-
.passthrough();
|
|
30
|
-
exports.VerificationMethodSchema = zod_1.z.object({
|
|
31
|
-
id: zod_1.z.string(),
|
|
32
|
-
type: exports.VerificationMethodTypeSchema,
|
|
33
|
-
controller: zod_1.z.string(),
|
|
34
|
-
publicKeyMultibase: zod_1.z.string().optional(),
|
|
35
|
-
publicKeyJwk: exports.PublicKeyJwkSchema.optional(),
|
|
36
|
-
});
|
|
37
|
-
exports.DidServiceSchema = zod_1.z.object({
|
|
38
|
-
id: zod_1.z.string(),
|
|
39
|
-
type: zod_1.z.union([zod_1.z.string(), zod_1.z.array(zod_1.z.string())]),
|
|
40
|
-
serviceEndpoint: zod_1.z.union([
|
|
41
|
-
zod_1.z.string(),
|
|
42
|
-
zod_1.z.array(zod_1.z.string()),
|
|
43
|
-
zod_1.z.record(zod_1.z.any()),
|
|
44
|
-
]),
|
|
45
|
-
});
|
|
46
|
-
exports.VerificationRelationshipEntrySchema = zod_1.z.union([
|
|
47
|
-
zod_1.z.string(),
|
|
48
|
-
exports.VerificationMethodSchema,
|
|
49
|
-
]);
|
|
50
|
-
exports.DidDocumentSchema = zod_1.z
|
|
51
|
-
.object({
|
|
52
|
-
'@context': exports.DidContextSchema.optional(),
|
|
53
|
-
id: zod_1.z.string().refine((val) => val.startsWith('did:'), {
|
|
54
|
-
message: 'DID must start with "did:"',
|
|
55
|
-
}),
|
|
56
|
-
alsoKnownAs: zod_1.z.array(zod_1.z.string()).optional(),
|
|
57
|
-
verificationMethod: zod_1.z.array(exports.VerificationMethodSchema).optional(),
|
|
58
|
-
authentication: zod_1.z.array(exports.VerificationRelationshipEntrySchema).optional(),
|
|
59
|
-
assertionMethod: zod_1.z.array(exports.VerificationRelationshipEntrySchema).optional(),
|
|
60
|
-
keyAgreement: zod_1.z.array(exports.VerificationRelationshipEntrySchema).optional(),
|
|
61
|
-
capabilityInvocation: zod_1.z
|
|
62
|
-
.array(exports.VerificationRelationshipEntrySchema)
|
|
63
|
-
.optional(),
|
|
64
|
-
capabilityDelegation: zod_1.z
|
|
65
|
-
.array(exports.VerificationRelationshipEntrySchema)
|
|
66
|
-
.optional(),
|
|
67
|
-
service: zod_1.z.array(exports.DidServiceSchema).optional(),
|
|
68
|
-
})
|
|
69
|
-
.passthrough();
|
|
70
|
-
exports.DidMethodSchema = zod_1.z.enum(['key', 'web', 'jwk', 'ion', 'ebsi']);
|
|
71
|
-
function validateDidDocument(doc) {
|
|
72
|
-
return exports.DidDocumentSchema.parse(doc);
|
|
73
|
-
}
|
|
74
|
-
function safeValidateDidDocument(doc) {
|
|
75
|
-
const result = exports.DidDocumentSchema.safeParse(doc);
|
|
76
|
-
if (result.success) {
|
|
77
|
-
return { success: true, data: result.data };
|
|
78
|
-
}
|
|
79
|
-
return { success: false, error: result.error };
|
|
80
|
-
}
|
package/dist/did/types.d.ts
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
export type VerificationMethodType = 'Ed25519VerificationKey2020' | 'JsonWebKey2020' | 'EcdsaSecp256k1VerificationKey2019';
|
|
2
|
-
export interface VerificationMethod {
|
|
3
|
-
id: string;
|
|
4
|
-
type: VerificationMethodType;
|
|
5
|
-
controller: string;
|
|
6
|
-
publicKeyMultibase?: string;
|
|
7
|
-
publicKeyJwk?: {
|
|
8
|
-
kty: string;
|
|
9
|
-
crv: string;
|
|
10
|
-
x: string;
|
|
11
|
-
y?: string;
|
|
12
|
-
[key: string]: any;
|
|
13
|
-
};
|
|
14
|
-
}
|
|
15
|
-
export interface DidService {
|
|
16
|
-
id: string;
|
|
17
|
-
type: string | string[];
|
|
18
|
-
serviceEndpoint: string | string[] | Record<string, any>;
|
|
19
|
-
}
|
|
20
|
-
export interface DidDocument {
|
|
21
|
-
'@context'?: string | string[] | Record<string, any>;
|
|
22
|
-
id: string;
|
|
23
|
-
alsoKnownAs?: string[];
|
|
24
|
-
verificationMethod?: VerificationMethod[];
|
|
25
|
-
authentication?: (string | VerificationMethod)[];
|
|
26
|
-
assertionMethod?: (string | VerificationMethod)[];
|
|
27
|
-
keyAgreement?: (string | VerificationMethod)[];
|
|
28
|
-
capabilityInvocation?: (string | VerificationMethod)[];
|
|
29
|
-
capabilityDelegation?: (string | VerificationMethod)[];
|
|
30
|
-
service?: DidService[];
|
|
31
|
-
[key: string]: any;
|
|
32
|
-
}
|
|
33
|
-
export type DidMethod = 'key' | 'web' | 'jwk' | 'ion' | 'ebsi';
|
|
34
|
-
export declare function isVerificationMethod(value: any): value is VerificationMethod;
|
|
35
|
-
export declare function isVerificationMethodReference(value: any): value is string;
|
|
36
|
-
export declare function isDidDocument(value: any): value is DidDocument;
|
|
37
|
-
export declare function extractDidMethod(did: string): string | null;
|
|
38
|
-
export declare function extractKeyId(didUrl: string): string | null;
|
package/dist/did/types.js
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isVerificationMethod = isVerificationMethod;
|
|
4
|
-
exports.isVerificationMethodReference = isVerificationMethodReference;
|
|
5
|
-
exports.isDidDocument = isDidDocument;
|
|
6
|
-
exports.extractDidMethod = extractDidMethod;
|
|
7
|
-
exports.extractKeyId = extractKeyId;
|
|
8
|
-
function isVerificationMethod(value) {
|
|
9
|
-
return (typeof value === 'object' &&
|
|
10
|
-
value !== null &&
|
|
11
|
-
typeof value.id === 'string' &&
|
|
12
|
-
typeof value.type === 'string' &&
|
|
13
|
-
typeof value.controller === 'string');
|
|
14
|
-
}
|
|
15
|
-
function isVerificationMethodReference(value) {
|
|
16
|
-
return typeof value === 'string';
|
|
17
|
-
}
|
|
18
|
-
function isDidDocument(value) {
|
|
19
|
-
return (typeof value === 'object' &&
|
|
20
|
-
value !== null &&
|
|
21
|
-
typeof value.id === 'string' &&
|
|
22
|
-
value.id.startsWith('did:'));
|
|
23
|
-
}
|
|
24
|
-
function extractDidMethod(did) {
|
|
25
|
-
const parts = did.split(':');
|
|
26
|
-
if (parts.length < 3 || parts[0] !== 'did') {
|
|
27
|
-
return null;
|
|
28
|
-
}
|
|
29
|
-
return parts[1];
|
|
30
|
-
}
|
|
31
|
-
function extractKeyId(didUrl) {
|
|
32
|
-
const hashIndex = didUrl.indexOf('#');
|
|
33
|
-
if (hashIndex === -1) {
|
|
34
|
-
return null;
|
|
35
|
-
}
|
|
36
|
-
return didUrl.substring(hashIndex + 1);
|
|
37
|
-
}
|
package/dist/env/constants.d.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
export declare const HASH_ALGO: "SHA-256";
|
|
2
|
-
export declare const SIG_ALGOS: readonly ["Ed25519", "ES256"];
|
|
3
|
-
export type SignatureAlgorithm = (typeof SIG_ALGOS)[number];
|
|
4
|
-
export declare const NONCE_TTL_MS: number;
|
|
5
|
-
export declare const RESUME_TOKEN_TTL_MS: number;
|
|
6
|
-
export declare const STATUSLIST_CACHE_SEC = 60;
|
|
7
|
-
export declare const DID_RESOLVE_TIMEOUT_MS = 500;
|
|
8
|
-
export declare const DEFAULT_SESSION_TTL_MINUTES = 30;
|
|
9
|
-
export declare const MAX_TIMESTAMP_SKEW_SEC = 120;
|
|
10
|
-
export declare const MAX_DELEGATION_CHAIN_DEPTH = 10;
|
|
11
|
-
export declare const MAX_STATUSLIST_SIZE = 1000000;
|
|
12
|
-
export declare const PROOF_ARCHIVE_TTL_SEC: number;
|
|
13
|
-
export declare const KEY_ROTATION_GRACE_PERIOD_SEC: number;
|
package/dist/env/constants.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.KEY_ROTATION_GRACE_PERIOD_SEC = exports.PROOF_ARCHIVE_TTL_SEC = exports.MAX_STATUSLIST_SIZE = exports.MAX_DELEGATION_CHAIN_DEPTH = exports.MAX_TIMESTAMP_SKEW_SEC = exports.DEFAULT_SESSION_TTL_MINUTES = exports.DID_RESOLVE_TIMEOUT_MS = exports.STATUSLIST_CACHE_SEC = exports.RESUME_TOKEN_TTL_MS = exports.NONCE_TTL_MS = exports.SIG_ALGOS = exports.HASH_ALGO = void 0;
|
|
4
|
-
exports.HASH_ALGO = 'SHA-256';
|
|
5
|
-
exports.SIG_ALGOS = ['Ed25519', 'ES256'];
|
|
6
|
-
exports.NONCE_TTL_MS = 5 * 60 * 1000;
|
|
7
|
-
exports.RESUME_TOKEN_TTL_MS = 10 * 60 * 1000;
|
|
8
|
-
exports.STATUSLIST_CACHE_SEC = 60;
|
|
9
|
-
exports.DID_RESOLVE_TIMEOUT_MS = 500;
|
|
10
|
-
exports.DEFAULT_SESSION_TTL_MINUTES = 30;
|
|
11
|
-
exports.MAX_TIMESTAMP_SKEW_SEC = 120;
|
|
12
|
-
exports.MAX_DELEGATION_CHAIN_DEPTH = 10;
|
|
13
|
-
exports.MAX_STATUSLIST_SIZE = 1000000;
|
|
14
|
-
exports.PROOF_ARCHIVE_TTL_SEC = 30 * 24 * 60 * 60;
|
|
15
|
-
exports.KEY_ROTATION_GRACE_PERIOD_SEC = 24 * 60 * 60;
|
package/dist/env/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './constants.js';
|
package/dist/env/index.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./constants.js"), exports);
|