@kya-os/contracts 1.3.2 → 1.3.3
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/README.md +1 -1
- package/dist/agentshield-api/endpoints.d.ts +21 -0
- package/dist/agentshield-api/endpoints.js +20 -0
- package/dist/agentshield-api/index.d.ts +5 -0
- package/dist/agentshield-api/index.js +27 -0
- package/dist/agentshield-api/schemas.d.ts +9846 -0
- package/dist/agentshield-api/schemas.js +92 -0
- package/dist/agentshield-api/types.d.ts +92 -0
- package/dist/agentshield-api/types.js +12 -0
- package/dist/cli.d.ts +3 -6
- package/dist/cli.js +3 -10
- package/dist/config/base.d.ts +19 -0
- package/dist/config/base.js +2 -0
- package/dist/config/delegation.d.ts +46 -0
- package/dist/config/delegation.js +2 -0
- package/dist/config/identity.d.ts +22 -0
- package/dist/config/identity.js +2 -0
- package/dist/config/index.d.ts +17 -0
- package/dist/config/index.js +2 -0
- package/dist/config/proofing.d.ts +26 -0
- package/dist/config/proofing.js +2 -0
- package/dist/config/tool-protection.d.ts +36 -0
- package/dist/config/tool-protection.js +2 -0
- package/dist/delegation/constraints.d.ts +0 -266
- package/dist/delegation/constraints.js +3 -110
- package/dist/delegation/index.d.ts +0 -6
- package/dist/delegation/index.js +0 -6
- package/dist/delegation/schemas.d.ts +174 -514
- package/dist/delegation/schemas.js +3 -247
- package/dist/did/index.d.ts +0 -6
- package/dist/did/index.js +0 -6
- package/dist/did/resolve-contract.d.ts +0 -167
- package/dist/did/resolve-contract.js +0 -20
- package/dist/did/schemas.d.ts +0 -80
- package/dist/did/schemas.js +4 -97
- package/dist/did/types.d.ts +0 -126
- package/dist/did/types.js +0 -34
- package/dist/env/constants.d.ts +0 -45
- package/dist/env/constants.js +0 -45
- package/dist/env/index.d.ts +0 -4
- package/dist/env/index.js +0 -4
- package/dist/handshake.d.ts +0 -21
- package/dist/handshake.js +3 -11
- package/dist/index.d.ts +0 -15
- package/dist/index.js +0 -25
- package/dist/proof/index.d.ts +0 -7
- package/dist/proof/index.js +0 -7
- package/dist/proof/proof-record.d.ts +62 -172
- package/dist/proof/proof-record.js +0 -74
- package/dist/proof/signing-spec.d.ts +12 -86
- package/dist/proof/signing-spec.js +0 -71
- package/dist/proof.d.ts +16 -38
- package/dist/proof.js +3 -26
- package/dist/registry.d.ts +10 -27
- package/dist/registry.js +9 -30
- package/dist/runtime/errors.d.ts +0 -169
- package/dist/runtime/errors.js +0 -69
- package/dist/runtime/headers.d.ts +0 -50
- package/dist/runtime/headers.js +0 -30
- package/dist/runtime/index.d.ts +0 -4
- package/dist/runtime/index.js +0 -4
- package/dist/test.d.ts +0 -37
- package/dist/test.js +0 -37
- package/dist/tlkrc/index.d.ts +0 -4
- package/dist/tlkrc/index.js +0 -4
- package/dist/tlkrc/rotation.d.ts +12 -90
- package/dist/tlkrc/rotation.js +0 -72
- package/dist/tool-protection/index.d.ts +129 -0
- package/dist/tool-protection/index.js +80 -0
- package/dist/utils/validation.d.ts +0 -17
- package/dist/utils/validation.js +0 -14
- package/dist/vc/index.d.ts +0 -6
- package/dist/vc/index.js +0 -6
- package/dist/vc/schemas.d.ts +0 -596
- package/dist/vc/schemas.js +2 -111
- package/dist/vc/statuslist.d.ts +0 -202
- package/dist/vc/statuslist.js +1 -73
- package/dist/verifier.d.ts +9 -13
- package/dist/verifier.js +0 -8
- package/dist/well-known/index.d.ts +248 -0
- package/dist/well-known/index.js +104 -0
- package/package.json +27 -5
|
@@ -1,32 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* DID Resolver Contract
|
|
4
|
-
*
|
|
5
|
-
* Interface contracts for DID resolution across different implementations.
|
|
6
|
-
* This file contains ONLY interfaces and types - no functional code.
|
|
7
|
-
*
|
|
8
|
-
* Related Spec: MCP-I §2.3
|
|
9
|
-
* Python Reference: DID-Service.md
|
|
10
|
-
*/
|
|
11
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
3
|
exports.RESOLUTION_ERROR_CODES = void 0;
|
|
13
|
-
/**
|
|
14
|
-
* Common resolution error codes
|
|
15
|
-
*/
|
|
16
4
|
exports.RESOLUTION_ERROR_CODES = {
|
|
17
|
-
/** DID not found */
|
|
18
5
|
NOT_FOUND: 'notFound',
|
|
19
|
-
/** Invalid DID format */
|
|
20
6
|
INVALID_DID: 'invalidDid',
|
|
21
|
-
/** DID method not supported */
|
|
22
7
|
METHOD_NOT_SUPPORTED: 'methodNotSupported',
|
|
23
|
-
/** Resolution timeout */
|
|
24
8
|
TIMEOUT: 'timeout',
|
|
25
|
-
/** Network error during resolution */
|
|
26
9
|
NETWORK_ERROR: 'networkError',
|
|
27
|
-
/** Invalid DID Document structure */
|
|
28
10
|
INVALID_DOCUMENT: 'invalidDocument',
|
|
29
|
-
/** Internal resolver error */
|
|
30
11
|
INTERNAL_ERROR: 'internalError',
|
|
31
12
|
};
|
|
32
|
-
//# sourceMappingURL=resolve-contract.js.map
|
package/dist/did/schemas.d.ts
CHANGED
|
@@ -1,113 +1,33 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* DID Document Zod Schemas
|
|
3
|
-
*
|
|
4
|
-
* Runtime validation schemas for DID Documents conforming to W3C DID Core specification.
|
|
5
|
-
* These schemas complement the TypeScript types in types.ts with runtime validation.
|
|
6
|
-
*
|
|
7
|
-
* Related Spec: MCP-I §2.1, §2.3, W3C DID Core 1.0
|
|
8
|
-
*/
|
|
9
1
|
import { z } from 'zod';
|
|
10
2
|
import type { DidDocument, VerificationMethod, DidService } from './types.js';
|
|
11
|
-
/**
|
|
12
|
-
* Standard W3C DID Core context
|
|
13
|
-
*/
|
|
14
3
|
export declare const DID_CONTEXT: "https://www.w3.org/ns/did/v1";
|
|
15
|
-
/**
|
|
16
|
-
* DID Context Entry Schema
|
|
17
|
-
*
|
|
18
|
-
* A context entry can be:
|
|
19
|
-
* - A URL string (most common)
|
|
20
|
-
* - A context definition object
|
|
21
|
-
*/
|
|
22
4
|
export declare const DidContextEntrySchema: z.ZodUnion<[z.ZodString, z.ZodRecord<z.ZodString, z.ZodAny>]>;
|
|
23
|
-
/**
|
|
24
|
-
* DID @context Schema
|
|
25
|
-
*
|
|
26
|
-
* The @context property in DID Documents can be:
|
|
27
|
-
* - A single string (typically the base DID context)
|
|
28
|
-
* - An array of strings/objects (base context + additional contexts)
|
|
29
|
-
* - A context definition object (for custom contexts)
|
|
30
|
-
*
|
|
31
|
-
* Per W3C DID Core spec, the base DID context should be present,
|
|
32
|
-
* but we allow flexibility for different DID methods and extensions.
|
|
33
|
-
*/
|
|
34
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>]>;
|
|
35
|
-
/**
|
|
36
|
-
* Verification Method Type Schema
|
|
37
|
-
*/
|
|
38
6
|
export declare const VerificationMethodTypeSchema: z.ZodEnum<["Ed25519VerificationKey2020", "JsonWebKey2020", "EcdsaSecp256k1VerificationKey2019"]>;
|
|
39
|
-
/**
|
|
40
|
-
* Public Key JWK Schema (RFC 7517)
|
|
41
|
-
*/
|
|
42
7
|
export declare const PublicKeyJwkSchema: z.ZodObject<{
|
|
43
|
-
/** Key Type */
|
|
44
8
|
kty: z.ZodString;
|
|
45
|
-
/** Curve (for elliptic curve keys) */
|
|
46
9
|
crv: z.ZodString;
|
|
47
|
-
/** X coordinate */
|
|
48
10
|
x: z.ZodString;
|
|
49
|
-
/** Y coordinate (optional for some key types) */
|
|
50
11
|
y: z.ZodOptional<z.ZodString>;
|
|
51
12
|
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
|
52
|
-
/** Key Type */
|
|
53
13
|
kty: z.ZodString;
|
|
54
|
-
/** Curve (for elliptic curve keys) */
|
|
55
14
|
crv: z.ZodString;
|
|
56
|
-
/** X coordinate */
|
|
57
15
|
x: z.ZodString;
|
|
58
|
-
/** Y coordinate (optional for some key types) */
|
|
59
16
|
y: z.ZodOptional<z.ZodString>;
|
|
60
17
|
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
61
|
-
/** Key Type */
|
|
62
18
|
kty: z.ZodString;
|
|
63
|
-
/** Curve (for elliptic curve keys) */
|
|
64
19
|
crv: z.ZodString;
|
|
65
|
-
/** X coordinate */
|
|
66
20
|
x: z.ZodString;
|
|
67
|
-
/** Y coordinate (optional for some key types) */
|
|
68
21
|
y: z.ZodOptional<z.ZodString>;
|
|
69
22
|
}, z.ZodTypeAny, "passthrough">>;
|
|
70
|
-
/**
|
|
71
|
-
* Verification Method Schema
|
|
72
|
-
*/
|
|
73
23
|
export declare const VerificationMethodSchema: z.ZodType<VerificationMethod>;
|
|
74
|
-
/**
|
|
75
|
-
* DID Service Schema
|
|
76
|
-
*/
|
|
77
24
|
export declare const DidServiceSchema: z.ZodType<DidService>;
|
|
78
|
-
/**
|
|
79
|
-
* Verification Relationship Entry Schema
|
|
80
|
-
*
|
|
81
|
-
* Can be either a string reference to a verification method
|
|
82
|
-
* or an embedded verification method object.
|
|
83
|
-
*/
|
|
84
25
|
export declare const VerificationRelationshipEntrySchema: z.ZodUnion<[z.ZodString, z.ZodType<VerificationMethod, z.ZodTypeDef, VerificationMethod>]>;
|
|
85
|
-
/**
|
|
86
|
-
* DID Document Schema
|
|
87
|
-
*
|
|
88
|
-
* Validates a DID Document structure per W3C DID Core specification.
|
|
89
|
-
*/
|
|
90
26
|
export declare const DidDocumentSchema: z.ZodType<DidDocument>;
|
|
91
|
-
/**
|
|
92
|
-
* DID Method Schema
|
|
93
|
-
*/
|
|
94
27
|
export declare const DidMethodSchema: z.ZodEnum<["key", "web", "jwk", "ion", "ebsi"]>;
|
|
95
|
-
/**
|
|
96
|
-
* Helper function to validate a DID Document
|
|
97
|
-
*
|
|
98
|
-
* @param doc - The document to validate
|
|
99
|
-
* @returns The validated document or throws ZodError
|
|
100
|
-
*/
|
|
101
28
|
export declare function validateDidDocument(doc: unknown): DidDocument;
|
|
102
|
-
/**
|
|
103
|
-
* Helper function to safely validate a DID Document
|
|
104
|
-
*
|
|
105
|
-
* @param doc - The document to validate
|
|
106
|
-
* @returns Result object with success status and data/error
|
|
107
|
-
*/
|
|
108
29
|
export declare function safeValidateDidDocument(doc: unknown): {
|
|
109
30
|
success: boolean;
|
|
110
31
|
data?: DidDocument;
|
|
111
32
|
error?: z.ZodError;
|
|
112
33
|
};
|
|
113
|
-
//# sourceMappingURL=schemas.d.ts.map
|
package/dist/did/schemas.js
CHANGED
|
@@ -1,168 +1,76 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* DID Document Zod Schemas
|
|
4
|
-
*
|
|
5
|
-
* Runtime validation schemas for DID Documents conforming to W3C DID Core specification.
|
|
6
|
-
* These schemas complement the TypeScript types in types.ts with runtime validation.
|
|
7
|
-
*
|
|
8
|
-
* Related Spec: MCP-I §2.1, §2.3, W3C DID Core 1.0
|
|
9
|
-
*/
|
|
10
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
3
|
exports.DidMethodSchema = exports.DidDocumentSchema = exports.VerificationRelationshipEntrySchema = exports.DidServiceSchema = exports.VerificationMethodSchema = exports.PublicKeyJwkSchema = exports.VerificationMethodTypeSchema = exports.DidContextSchema = exports.DidContextEntrySchema = exports.DID_CONTEXT = void 0;
|
|
12
4
|
exports.validateDidDocument = validateDidDocument;
|
|
13
5
|
exports.safeValidateDidDocument = safeValidateDidDocument;
|
|
14
6
|
const zod_1 = require("zod");
|
|
15
|
-
/**
|
|
16
|
-
* Standard W3C DID Core context
|
|
17
|
-
*/
|
|
18
7
|
exports.DID_CONTEXT = 'https://www.w3.org/ns/did/v1';
|
|
19
|
-
/**
|
|
20
|
-
* DID Context Entry Schema
|
|
21
|
-
*
|
|
22
|
-
* A context entry can be:
|
|
23
|
-
* - A URL string (most common)
|
|
24
|
-
* - A context definition object
|
|
25
|
-
*/
|
|
26
8
|
exports.DidContextEntrySchema = zod_1.z.union([
|
|
27
9
|
zod_1.z.string().url(),
|
|
28
10
|
zod_1.z.record(zod_1.z.any()),
|
|
29
11
|
]);
|
|
30
|
-
/**
|
|
31
|
-
* DID @context Schema
|
|
32
|
-
*
|
|
33
|
-
* The @context property in DID Documents can be:
|
|
34
|
-
* - A single string (typically the base DID context)
|
|
35
|
-
* - An array of strings/objects (base context + additional contexts)
|
|
36
|
-
* - A context definition object (for custom contexts)
|
|
37
|
-
*
|
|
38
|
-
* Per W3C DID Core spec, the base DID context should be present,
|
|
39
|
-
* but we allow flexibility for different DID methods and extensions.
|
|
40
|
-
*/
|
|
41
12
|
exports.DidContextSchema = zod_1.z.union([
|
|
42
|
-
// Single string context (e.g., "https://www.w3.org/ns/did/v1")
|
|
43
13
|
zod_1.z.string().url(),
|
|
44
|
-
// Array of contexts (strings or objects)
|
|
45
14
|
zod_1.z.array(exports.DidContextEntrySchema).nonempty(),
|
|
46
|
-
// Context definition object
|
|
47
15
|
zod_1.z.record(zod_1.z.any()),
|
|
48
16
|
]);
|
|
49
|
-
/**
|
|
50
|
-
* Verification Method Type Schema
|
|
51
|
-
*/
|
|
52
17
|
exports.VerificationMethodTypeSchema = zod_1.z.enum([
|
|
53
18
|
'Ed25519VerificationKey2020',
|
|
54
19
|
'JsonWebKey2020',
|
|
55
20
|
'EcdsaSecp256k1VerificationKey2019',
|
|
56
21
|
]);
|
|
57
|
-
/**
|
|
58
|
-
* Public Key JWK Schema (RFC 7517)
|
|
59
|
-
*/
|
|
60
22
|
exports.PublicKeyJwkSchema = zod_1.z
|
|
61
23
|
.object({
|
|
62
|
-
/** Key Type */
|
|
63
24
|
kty: zod_1.z.string(),
|
|
64
|
-
/** Curve (for elliptic curve keys) */
|
|
65
25
|
crv: zod_1.z.string(),
|
|
66
|
-
/** X coordinate */
|
|
67
26
|
x: zod_1.z.string(),
|
|
68
|
-
/** Y coordinate (optional for some key types) */
|
|
69
27
|
y: zod_1.z.string().optional(),
|
|
70
28
|
})
|
|
71
|
-
.passthrough();
|
|
72
|
-
/**
|
|
73
|
-
* Verification Method Schema
|
|
74
|
-
*/
|
|
29
|
+
.passthrough();
|
|
75
30
|
exports.VerificationMethodSchema = zod_1.z.object({
|
|
76
|
-
/** Verification method identifier */
|
|
77
31
|
id: zod_1.z.string(),
|
|
78
|
-
/** Type of verification method */
|
|
79
32
|
type: exports.VerificationMethodTypeSchema,
|
|
80
|
-
/** Controller DID */
|
|
81
33
|
controller: zod_1.z.string(),
|
|
82
|
-
/** Multibase-encoded public key (for Ed25519VerificationKey2020) */
|
|
83
34
|
publicKeyMultibase: zod_1.z.string().optional(),
|
|
84
|
-
/** JSON Web Key (for JsonWebKey2020) */
|
|
85
35
|
publicKeyJwk: exports.PublicKeyJwkSchema.optional(),
|
|
86
36
|
});
|
|
87
|
-
/**
|
|
88
|
-
* DID Service Schema
|
|
89
|
-
*/
|
|
90
37
|
exports.DidServiceSchema = zod_1.z.object({
|
|
91
|
-
/** Service identifier */
|
|
92
38
|
id: zod_1.z.string(),
|
|
93
|
-
/** Service type(s) */
|
|
94
39
|
type: zod_1.z.union([zod_1.z.string(), zod_1.z.array(zod_1.z.string())]),
|
|
95
|
-
/** Service endpoint(s) */
|
|
96
40
|
serviceEndpoint: zod_1.z.union([
|
|
97
41
|
zod_1.z.string(),
|
|
98
42
|
zod_1.z.array(zod_1.z.string()),
|
|
99
43
|
zod_1.z.record(zod_1.z.any()),
|
|
100
44
|
]),
|
|
101
45
|
});
|
|
102
|
-
/**
|
|
103
|
-
* Verification Relationship Entry Schema
|
|
104
|
-
*
|
|
105
|
-
* Can be either a string reference to a verification method
|
|
106
|
-
* or an embedded verification method object.
|
|
107
|
-
*/
|
|
108
46
|
exports.VerificationRelationshipEntrySchema = zod_1.z.union([
|
|
109
|
-
zod_1.z.string(),
|
|
110
|
-
exports.VerificationMethodSchema,
|
|
47
|
+
zod_1.z.string(),
|
|
48
|
+
exports.VerificationMethodSchema,
|
|
111
49
|
]);
|
|
112
|
-
/**
|
|
113
|
-
* DID Document Schema
|
|
114
|
-
*
|
|
115
|
-
* Validates a DID Document structure per W3C DID Core specification.
|
|
116
|
-
*/
|
|
117
50
|
exports.DidDocumentSchema = zod_1.z
|
|
118
51
|
.object({
|
|
119
|
-
/** JSON-LD context */
|
|
120
52
|
'@context': exports.DidContextSchema.optional(),
|
|
121
|
-
/** The DID this document describes */
|
|
122
53
|
id: zod_1.z.string().refine((val) => val.startsWith('did:'), {
|
|
123
54
|
message: 'DID must start with "did:"',
|
|
124
55
|
}),
|
|
125
|
-
/** Alternative identifiers */
|
|
126
56
|
alsoKnownAs: zod_1.z.array(zod_1.z.string()).optional(),
|
|
127
|
-
/** Verification methods */
|
|
128
57
|
verificationMethod: zod_1.z.array(exports.VerificationMethodSchema).optional(),
|
|
129
|
-
/** Authentication verification relationship */
|
|
130
58
|
authentication: zod_1.z.array(exports.VerificationRelationshipEntrySchema).optional(),
|
|
131
|
-
/** Assertion method verification relationship */
|
|
132
59
|
assertionMethod: zod_1.z.array(exports.VerificationRelationshipEntrySchema).optional(),
|
|
133
|
-
/** Key agreement verification relationship */
|
|
134
60
|
keyAgreement: zod_1.z.array(exports.VerificationRelationshipEntrySchema).optional(),
|
|
135
|
-
/** Capability invocation verification relationship */
|
|
136
61
|
capabilityInvocation: zod_1.z
|
|
137
62
|
.array(exports.VerificationRelationshipEntrySchema)
|
|
138
63
|
.optional(),
|
|
139
|
-
/** Capability delegation verification relationship */
|
|
140
64
|
capabilityDelegation: zod_1.z
|
|
141
65
|
.array(exports.VerificationRelationshipEntrySchema)
|
|
142
66
|
.optional(),
|
|
143
|
-
/** Service endpoints */
|
|
144
67
|
service: zod_1.z.array(exports.DidServiceSchema).optional(),
|
|
145
68
|
})
|
|
146
|
-
.passthrough();
|
|
147
|
-
/**
|
|
148
|
-
* DID Method Schema
|
|
149
|
-
*/
|
|
69
|
+
.passthrough();
|
|
150
70
|
exports.DidMethodSchema = zod_1.z.enum(['key', 'web', 'jwk', 'ion', 'ebsi']);
|
|
151
|
-
/**
|
|
152
|
-
* Helper function to validate a DID Document
|
|
153
|
-
*
|
|
154
|
-
* @param doc - The document to validate
|
|
155
|
-
* @returns The validated document or throws ZodError
|
|
156
|
-
*/
|
|
157
71
|
function validateDidDocument(doc) {
|
|
158
72
|
return exports.DidDocumentSchema.parse(doc);
|
|
159
73
|
}
|
|
160
|
-
/**
|
|
161
|
-
* Helper function to safely validate a DID Document
|
|
162
|
-
*
|
|
163
|
-
* @param doc - The document to validate
|
|
164
|
-
* @returns Result object with success status and data/error
|
|
165
|
-
*/
|
|
166
74
|
function safeValidateDidDocument(doc) {
|
|
167
75
|
const result = exports.DidDocumentSchema.safeParse(doc);
|
|
168
76
|
if (result.success) {
|
|
@@ -170,4 +78,3 @@ function safeValidateDidDocument(doc) {
|
|
|
170
78
|
}
|
|
171
79
|
return { success: false, error: result.error };
|
|
172
80
|
}
|
|
173
|
-
//# sourceMappingURL=schemas.js.map
|
package/dist/did/types.d.ts
CHANGED
|
@@ -1,45 +1,9 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* DID Document Types (W3C Compliant)
|
|
3
|
-
*
|
|
4
|
-
* These types conform to the W3C DID Core specification and provide
|
|
5
|
-
* TypeScript parity with the Python implementation.
|
|
6
|
-
*
|
|
7
|
-
* Related Spec: MCP-I §2.1, §2.3
|
|
8
|
-
* Python Reference: DID-Documentation.md, DID-Service.md
|
|
9
|
-
*/
|
|
10
|
-
/**
|
|
11
|
-
* Verification Method Types
|
|
12
|
-
*
|
|
13
|
-
* Supported types for verification methods in DID Documents.
|
|
14
|
-
*/
|
|
15
1
|
export type VerificationMethodType = 'Ed25519VerificationKey2020' | 'JsonWebKey2020' | 'EcdsaSecp256k1VerificationKey2019';
|
|
16
|
-
/**
|
|
17
|
-
* Verification Method
|
|
18
|
-
*
|
|
19
|
-
* A verification method as defined in the W3C DID Core specification.
|
|
20
|
-
* Used for cryptographic verification of signatures and authentication.
|
|
21
|
-
*
|
|
22
|
-
* **kid Derivation Guidelines:**
|
|
23
|
-
* - For did:key: kid = `${did}#${multibaseKey}`
|
|
24
|
-
* - For did:web: kid = `${did}#${kid}` where kid is from DID Document
|
|
25
|
-
* - The kid MUST be resolvable to a verification method in the DID Document
|
|
26
|
-
*/
|
|
27
2
|
export interface VerificationMethod {
|
|
28
|
-
/** Verification method identifier (e.g., "#key-1" or full DID URL) */
|
|
29
3
|
id: string;
|
|
30
|
-
/** Type of verification method */
|
|
31
4
|
type: VerificationMethodType;
|
|
32
|
-
/** DID of the controller of this verification method */
|
|
33
5
|
controller: string;
|
|
34
|
-
/**
|
|
35
|
-
* Public key encoded as multibase for Ed25519VerificationKey2020
|
|
36
|
-
* Format: z + base58btc(public key bytes)
|
|
37
|
-
*/
|
|
38
6
|
publicKeyMultibase?: string;
|
|
39
|
-
/**
|
|
40
|
-
* Public key as JSON Web Key for JsonWebKey2020
|
|
41
|
-
* See RFC 7517 for JWK format
|
|
42
|
-
*/
|
|
43
7
|
publicKeyJwk?: {
|
|
44
8
|
kty: string;
|
|
45
9
|
crv: string;
|
|
@@ -48,117 +12,27 @@ export interface VerificationMethod {
|
|
|
48
12
|
[key: string]: any;
|
|
49
13
|
};
|
|
50
14
|
}
|
|
51
|
-
/**
|
|
52
|
-
* DID Service
|
|
53
|
-
*
|
|
54
|
-
* A service endpoint as defined in the W3C DID Core specification.
|
|
55
|
-
* Services enable discovery of service endpoints for the DID subject.
|
|
56
|
-
*/
|
|
57
15
|
export interface DidService {
|
|
58
|
-
/** Service identifier (e.g., "#service-1") */
|
|
59
16
|
id: string;
|
|
60
|
-
/** Service type (e.g., "LinkedDomains", "CredentialRegistry") */
|
|
61
17
|
type: string | string[];
|
|
62
|
-
/** Service endpoint URL(s) or endpoint descriptor object */
|
|
63
18
|
serviceEndpoint: string | string[] | Record<string, any>;
|
|
64
19
|
}
|
|
65
|
-
/**
|
|
66
|
-
* DID Document
|
|
67
|
-
*
|
|
68
|
-
* A DID Document as defined in the W3C DID Core specification.
|
|
69
|
-
* Represents the full descriptor of a DID, including verification methods
|
|
70
|
-
* and service endpoints.
|
|
71
|
-
*
|
|
72
|
-
* **Supported DID Methods:**
|
|
73
|
-
* - did:key - Self-contained, ephemeral identities
|
|
74
|
-
* - did:web - Domain-bound identities resolved via HTTPS
|
|
75
|
-
* - did:jwk - JWK-based identities
|
|
76
|
-
*
|
|
77
|
-
* **@context:**
|
|
78
|
-
* While the W3C spec requires @context, it's optional in this type to support
|
|
79
|
-
* simplified parsing. Implementations should include "https://www.w3.org/ns/did/v1"
|
|
80
|
-
* as the base context.
|
|
81
|
-
*/
|
|
82
20
|
export interface DidDocument {
|
|
83
|
-
/** JSON-LD context (typically "https://www.w3.org/ns/did/v1") */
|
|
84
21
|
'@context'?: string | string[] | Record<string, any>;
|
|
85
|
-
/** The DID this document describes (e.g., "did:key:z6Mk...") */
|
|
86
22
|
id: string;
|
|
87
|
-
/** Also known as - alternative identifiers for this DID */
|
|
88
23
|
alsoKnownAs?: string[];
|
|
89
|
-
/**
|
|
90
|
-
* Verification methods available for this DID
|
|
91
|
-
* Contains public key information for signature verification
|
|
92
|
-
*/
|
|
93
24
|
verificationMethod?: VerificationMethod[];
|
|
94
|
-
/**
|
|
95
|
-
* Authentication verification relationship
|
|
96
|
-
* References to verification methods or embedded methods
|
|
97
|
-
* Used for authenticating as the DID subject
|
|
98
|
-
*/
|
|
99
25
|
authentication?: (string | VerificationMethod)[];
|
|
100
|
-
/**
|
|
101
|
-
* Assertion method verification relationship
|
|
102
|
-
* References to verification methods or embedded methods
|
|
103
|
-
* Used for issuing verifiable credentials
|
|
104
|
-
*/
|
|
105
26
|
assertionMethod?: (string | VerificationMethod)[];
|
|
106
|
-
/**
|
|
107
|
-
* Key agreement verification relationship
|
|
108
|
-
* References to verification methods or embedded methods
|
|
109
|
-
* Used for encryption and key agreement protocols
|
|
110
|
-
*/
|
|
111
27
|
keyAgreement?: (string | VerificationMethod)[];
|
|
112
|
-
/**
|
|
113
|
-
* Capability invocation verification relationship
|
|
114
|
-
* References to verification methods or embedded methods
|
|
115
|
-
* Used for invoking capabilities
|
|
116
|
-
*/
|
|
117
28
|
capabilityInvocation?: (string | VerificationMethod)[];
|
|
118
|
-
/**
|
|
119
|
-
* Capability delegation verification relationship
|
|
120
|
-
* References to verification methods or embedded methods
|
|
121
|
-
* Used for delegating capabilities
|
|
122
|
-
*/
|
|
123
29
|
capabilityDelegation?: (string | VerificationMethod)[];
|
|
124
|
-
/** Service endpoints for the DID */
|
|
125
30
|
service?: DidService[];
|
|
126
|
-
/** Additional properties allowed for extensibility */
|
|
127
31
|
[key: string]: any;
|
|
128
32
|
}
|
|
129
|
-
/**
|
|
130
|
-
* DID Method
|
|
131
|
-
*
|
|
132
|
-
* String literal type for supported DID methods
|
|
133
|
-
*/
|
|
134
33
|
export type DidMethod = 'key' | 'web' | 'jwk' | 'ion' | 'ebsi';
|
|
135
|
-
/**
|
|
136
|
-
* Helper type guards
|
|
137
|
-
*/
|
|
138
|
-
/**
|
|
139
|
-
* Type guard to check if a value is a VerificationMethod
|
|
140
|
-
*/
|
|
141
34
|
export declare function isVerificationMethod(value: any): value is VerificationMethod;
|
|
142
|
-
/**
|
|
143
|
-
* Type guard to check if a value is a string reference to a verification method
|
|
144
|
-
*/
|
|
145
35
|
export declare function isVerificationMethodReference(value: any): value is string;
|
|
146
|
-
/**
|
|
147
|
-
* Type guard to check if a DID Document is valid (basic structural check)
|
|
148
|
-
*/
|
|
149
36
|
export declare function isDidDocument(value: any): value is DidDocument;
|
|
150
|
-
/**
|
|
151
|
-
* Extract DID method from a DID string
|
|
152
|
-
*
|
|
153
|
-
* @param did - The DID string (e.g., "did:key:z6Mk...")
|
|
154
|
-
* @returns The method name (e.g., "key") or null if invalid
|
|
155
|
-
*/
|
|
156
37
|
export declare function extractDidMethod(did: string): string | null;
|
|
157
|
-
/**
|
|
158
|
-
* Extract key ID from a DID URL
|
|
159
|
-
*
|
|
160
|
-
* @param didUrl - A DID URL with fragment (e.g., "did:key:z6Mk...#key-1")
|
|
161
|
-
* @returns The fragment part (e.g., "key-1") or null if no fragment
|
|
162
|
-
*/
|
|
163
38
|
export declare function extractKeyId(didUrl: string): string | null;
|
|
164
|
-
//# sourceMappingURL=types.d.ts.map
|
package/dist/did/types.js
CHANGED
|
@@ -1,25 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* DID Document Types (W3C Compliant)
|
|
4
|
-
*
|
|
5
|
-
* These types conform to the W3C DID Core specification and provide
|
|
6
|
-
* TypeScript parity with the Python implementation.
|
|
7
|
-
*
|
|
8
|
-
* Related Spec: MCP-I §2.1, §2.3
|
|
9
|
-
* Python Reference: DID-Documentation.md, DID-Service.md
|
|
10
|
-
*/
|
|
11
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
3
|
exports.isVerificationMethod = isVerificationMethod;
|
|
13
4
|
exports.isVerificationMethodReference = isVerificationMethodReference;
|
|
14
5
|
exports.isDidDocument = isDidDocument;
|
|
15
6
|
exports.extractDidMethod = extractDidMethod;
|
|
16
7
|
exports.extractKeyId = extractKeyId;
|
|
17
|
-
/**
|
|
18
|
-
* Helper type guards
|
|
19
|
-
*/
|
|
20
|
-
/**
|
|
21
|
-
* Type guard to check if a value is a VerificationMethod
|
|
22
|
-
*/
|
|
23
8
|
function isVerificationMethod(value) {
|
|
24
9
|
return (typeof value === 'object' &&
|
|
25
10
|
value !== null &&
|
|
@@ -27,27 +12,15 @@ function isVerificationMethod(value) {
|
|
|
27
12
|
typeof value.type === 'string' &&
|
|
28
13
|
typeof value.controller === 'string');
|
|
29
14
|
}
|
|
30
|
-
/**
|
|
31
|
-
* Type guard to check if a value is a string reference to a verification method
|
|
32
|
-
*/
|
|
33
15
|
function isVerificationMethodReference(value) {
|
|
34
16
|
return typeof value === 'string';
|
|
35
17
|
}
|
|
36
|
-
/**
|
|
37
|
-
* Type guard to check if a DID Document is valid (basic structural check)
|
|
38
|
-
*/
|
|
39
18
|
function isDidDocument(value) {
|
|
40
19
|
return (typeof value === 'object' &&
|
|
41
20
|
value !== null &&
|
|
42
21
|
typeof value.id === 'string' &&
|
|
43
22
|
value.id.startsWith('did:'));
|
|
44
23
|
}
|
|
45
|
-
/**
|
|
46
|
-
* Extract DID method from a DID string
|
|
47
|
-
*
|
|
48
|
-
* @param did - The DID string (e.g., "did:key:z6Mk...")
|
|
49
|
-
* @returns The method name (e.g., "key") or null if invalid
|
|
50
|
-
*/
|
|
51
24
|
function extractDidMethod(did) {
|
|
52
25
|
const parts = did.split(':');
|
|
53
26
|
if (parts.length < 3 || parts[0] !== 'did') {
|
|
@@ -55,12 +28,6 @@ function extractDidMethod(did) {
|
|
|
55
28
|
}
|
|
56
29
|
return parts[1];
|
|
57
30
|
}
|
|
58
|
-
/**
|
|
59
|
-
* Extract key ID from a DID URL
|
|
60
|
-
*
|
|
61
|
-
* @param didUrl - A DID URL with fragment (e.g., "did:key:z6Mk...#key-1")
|
|
62
|
-
* @returns The fragment part (e.g., "key-1") or null if no fragment
|
|
63
|
-
*/
|
|
64
31
|
function extractKeyId(didUrl) {
|
|
65
32
|
const hashIndex = didUrl.indexOf('#');
|
|
66
33
|
if (hashIndex === -1) {
|
|
@@ -68,4 +35,3 @@ function extractKeyId(didUrl) {
|
|
|
68
35
|
}
|
|
69
36
|
return didUrl.substring(hashIndex + 1);
|
|
70
37
|
}
|
|
71
|
-
//# sourceMappingURL=types.js.map
|
package/dist/env/constants.d.ts
CHANGED
|
@@ -1,58 +1,13 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Environment Constants
|
|
3
|
-
*
|
|
4
|
-
* System-wide constants for algorithms, TTLs, and limits
|
|
5
|
-
*
|
|
6
|
-
* Related Spec: MCP-I §8
|
|
7
|
-
* Python Reference: All service documentation files
|
|
8
|
-
*/
|
|
9
|
-
/**
|
|
10
|
-
* Hash algorithm for cryptographic operations
|
|
11
|
-
*/
|
|
12
1
|
export declare const HASH_ALGO: "SHA-256";
|
|
13
|
-
/**
|
|
14
|
-
* Supported signature algorithms
|
|
15
|
-
*/
|
|
16
2
|
export declare const SIG_ALGOS: readonly ["Ed25519", "ES256"];
|
|
17
3
|
export type SignatureAlgorithm = (typeof SIG_ALGOS)[number];
|
|
18
|
-
/**
|
|
19
|
-
* Nonce TTL in milliseconds (5 minutes)
|
|
20
|
-
*/
|
|
21
4
|
export declare const NONCE_TTL_MS: number;
|
|
22
|
-
/**
|
|
23
|
-
* Resume token TTL in milliseconds (10 minutes)
|
|
24
|
-
*/
|
|
25
5
|
export declare const RESUME_TOKEN_TTL_MS: number;
|
|
26
|
-
/**
|
|
27
|
-
* StatusList2021 cache TTL in seconds (1 minute)
|
|
28
|
-
*/
|
|
29
6
|
export declare const STATUSLIST_CACHE_SEC = 60;
|
|
30
|
-
/**
|
|
31
|
-
* DID resolution timeout in milliseconds (500ms)
|
|
32
|
-
*/
|
|
33
7
|
export declare const DID_RESOLVE_TIMEOUT_MS = 500;
|
|
34
|
-
/**
|
|
35
|
-
* Default session TTL in minutes (30 minutes)
|
|
36
|
-
*/
|
|
37
8
|
export declare const DEFAULT_SESSION_TTL_MINUTES = 30;
|
|
38
|
-
/**
|
|
39
|
-
* Maximum timestamp skew in seconds (2 minutes)
|
|
40
|
-
*/
|
|
41
9
|
export declare const MAX_TIMESTAMP_SKEW_SEC = 120;
|
|
42
|
-
/**
|
|
43
|
-
* Maximum delegation chain depth
|
|
44
|
-
*/
|
|
45
10
|
export declare const MAX_DELEGATION_CHAIN_DEPTH = 10;
|
|
46
|
-
/**
|
|
47
|
-
* Maximum status list size (1 million entries)
|
|
48
|
-
*/
|
|
49
11
|
export declare const MAX_STATUSLIST_SIZE = 1000000;
|
|
50
|
-
/**
|
|
51
|
-
* Proof archive TTL in seconds (30 days)
|
|
52
|
-
*/
|
|
53
12
|
export declare const PROOF_ARCHIVE_TTL_SEC: number;
|
|
54
|
-
/**
|
|
55
|
-
* Key rotation grace period in seconds (24 hours)
|
|
56
|
-
*/
|
|
57
13
|
export declare const KEY_ROTATION_GRACE_PERIOD_SEC: number;
|
|
58
|
-
//# sourceMappingURL=constants.d.ts.map
|
package/dist/env/constants.js
CHANGED
|
@@ -1,60 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Environment Constants
|
|
4
|
-
*
|
|
5
|
-
* System-wide constants for algorithms, TTLs, and limits
|
|
6
|
-
*
|
|
7
|
-
* Related Spec: MCP-I §8
|
|
8
|
-
* Python Reference: All service documentation files
|
|
9
|
-
*/
|
|
10
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
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;
|
|
12
|
-
/**
|
|
13
|
-
* Hash algorithm for cryptographic operations
|
|
14
|
-
*/
|
|
15
4
|
exports.HASH_ALGO = 'SHA-256';
|
|
16
|
-
/**
|
|
17
|
-
* Supported signature algorithms
|
|
18
|
-
*/
|
|
19
5
|
exports.SIG_ALGOS = ['Ed25519', 'ES256'];
|
|
20
|
-
/**
|
|
21
|
-
* Nonce TTL in milliseconds (5 minutes)
|
|
22
|
-
*/
|
|
23
6
|
exports.NONCE_TTL_MS = 5 * 60 * 1000;
|
|
24
|
-
/**
|
|
25
|
-
* Resume token TTL in milliseconds (10 minutes)
|
|
26
|
-
*/
|
|
27
7
|
exports.RESUME_TOKEN_TTL_MS = 10 * 60 * 1000;
|
|
28
|
-
/**
|
|
29
|
-
* StatusList2021 cache TTL in seconds (1 minute)
|
|
30
|
-
*/
|
|
31
8
|
exports.STATUSLIST_CACHE_SEC = 60;
|
|
32
|
-
/**
|
|
33
|
-
* DID resolution timeout in milliseconds (500ms)
|
|
34
|
-
*/
|
|
35
9
|
exports.DID_RESOLVE_TIMEOUT_MS = 500;
|
|
36
|
-
/**
|
|
37
|
-
* Default session TTL in minutes (30 minutes)
|
|
38
|
-
*/
|
|
39
10
|
exports.DEFAULT_SESSION_TTL_MINUTES = 30;
|
|
40
|
-
/**
|
|
41
|
-
* Maximum timestamp skew in seconds (2 minutes)
|
|
42
|
-
*/
|
|
43
11
|
exports.MAX_TIMESTAMP_SKEW_SEC = 120;
|
|
44
|
-
/**
|
|
45
|
-
* Maximum delegation chain depth
|
|
46
|
-
*/
|
|
47
12
|
exports.MAX_DELEGATION_CHAIN_DEPTH = 10;
|
|
48
|
-
/**
|
|
49
|
-
* Maximum status list size (1 million entries)
|
|
50
|
-
*/
|
|
51
13
|
exports.MAX_STATUSLIST_SIZE = 1000000;
|
|
52
|
-
/**
|
|
53
|
-
* Proof archive TTL in seconds (30 days)
|
|
54
|
-
*/
|
|
55
14
|
exports.PROOF_ARCHIVE_TTL_SEC = 30 * 24 * 60 * 60;
|
|
56
|
-
/**
|
|
57
|
-
* Key rotation grace period in seconds (24 hours)
|
|
58
|
-
*/
|
|
59
15
|
exports.KEY_ROTATION_GRACE_PERIOD_SEC = 24 * 60 * 60;
|
|
60
|
-
//# sourceMappingURL=constants.js.map
|