@enbox/dids 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -0
- package/README.md +1 -0
- package/dist/browser.js +77 -0
- package/dist/browser.js.map +7 -0
- package/dist/browser.mjs +77 -0
- package/dist/browser.mjs.map +7 -0
- package/dist/cjs/index.js +6303 -0
- package/dist/cjs/index.js.map +7 -0
- package/dist/cjs/package.json +1 -0
- package/dist/cjs/utils.js +245 -0
- package/dist/cjs/utils.js.map +7 -0
- package/dist/esm/bearer-did.js +201 -0
- package/dist/esm/bearer-did.js.map +1 -0
- package/dist/esm/did-error.js +62 -0
- package/dist/esm/did-error.js.map +1 -0
- package/dist/esm/did.js +114 -0
- package/dist/esm/did.js.map +1 -0
- package/dist/esm/index.js +16 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/methods/did-dht.js +1241 -0
- package/dist/esm/methods/did-dht.js.map +1 -0
- package/dist/esm/methods/did-ion.js +570 -0
- package/dist/esm/methods/did-ion.js.map +1 -0
- package/dist/esm/methods/did-jwk.js +298 -0
- package/dist/esm/methods/did-jwk.js.map +1 -0
- package/dist/esm/methods/did-key.js +983 -0
- package/dist/esm/methods/did-key.js.map +1 -0
- package/dist/esm/methods/did-method.js +53 -0
- package/dist/esm/methods/did-method.js.map +1 -0
- package/dist/esm/methods/did-web.js +83 -0
- package/dist/esm/methods/did-web.js.map +1 -0
- package/dist/esm/resolver/resolver-cache-level.js +101 -0
- package/dist/esm/resolver/resolver-cache-level.js.map +1 -0
- package/dist/esm/resolver/resolver-cache-noop.js +24 -0
- package/dist/esm/resolver/resolver-cache-noop.js.map +1 -0
- package/dist/esm/resolver/universal-resolver.js +187 -0
- package/dist/esm/resolver/universal-resolver.js.map +1 -0
- package/dist/esm/types/did-core.js +51 -0
- package/dist/esm/types/did-core.js.map +1 -0
- package/dist/esm/types/did-resolution.js +12 -0
- package/dist/esm/types/did-resolution.js.map +1 -0
- package/dist/esm/types/multibase.js +2 -0
- package/dist/esm/types/multibase.js.map +1 -0
- package/dist/esm/types/portable-did.js +2 -0
- package/dist/esm/types/portable-did.js.map +1 -0
- package/dist/esm/utils.js +458 -0
- package/dist/esm/utils.js.map +1 -0
- package/dist/types/bearer-did.d.ts +143 -0
- package/dist/types/bearer-did.d.ts.map +1 -0
- package/dist/types/did-error.d.ts +50 -0
- package/dist/types/did-error.d.ts.map +1 -0
- package/dist/types/did.d.ts +125 -0
- package/dist/types/did.d.ts.map +1 -0
- package/dist/types/index.d.ts +18 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/methods/did-dht.d.ts +682 -0
- package/dist/types/methods/did-dht.d.ts.map +1 -0
- package/dist/types/methods/did-ion.d.ts +492 -0
- package/dist/types/methods/did-ion.d.ts.map +1 -0
- package/dist/types/methods/did-jwk.d.ts +236 -0
- package/dist/types/methods/did-jwk.d.ts.map +1 -0
- package/dist/types/methods/did-key.d.ts +499 -0
- package/dist/types/methods/did-key.d.ts.map +1 -0
- package/dist/types/methods/did-method.d.ts +238 -0
- package/dist/types/methods/did-method.d.ts.map +1 -0
- package/dist/types/methods/did-web.d.ts +37 -0
- package/dist/types/methods/did-web.d.ts.map +1 -0
- package/dist/types/resolver/resolver-cache-level.d.ts +86 -0
- package/dist/types/resolver/resolver-cache-level.d.ts.map +1 -0
- package/dist/types/resolver/resolver-cache-noop.d.ts +9 -0
- package/dist/types/resolver/resolver-cache-noop.d.ts.map +1 -0
- package/dist/types/resolver/universal-resolver.d.ts +109 -0
- package/dist/types/resolver/universal-resolver.d.ts.map +1 -0
- package/dist/types/types/did-core.d.ts +523 -0
- package/dist/types/types/did-core.d.ts.map +1 -0
- package/dist/types/types/did-resolution.d.ts +85 -0
- package/dist/types/types/did-resolution.d.ts.map +1 -0
- package/dist/types/types/multibase.d.ts +28 -0
- package/dist/types/types/multibase.d.ts.map +1 -0
- package/dist/types/types/portable-did.d.ts +59 -0
- package/dist/types/types/portable-did.d.ts.map +1 -0
- package/dist/types/utils.d.ts +378 -0
- package/dist/types/utils.d.ts.map +1 -0
- package/dist/utils.js +28 -0
- package/dist/utils.js.map +7 -0
- package/package.json +116 -0
- package/src/bearer-did.ts +287 -0
- package/src/did-error.ts +75 -0
- package/src/did.ts +186 -0
- package/src/index.ts +21 -0
- package/src/methods/did-dht.ts +1637 -0
- package/src/methods/did-ion.ts +887 -0
- package/src/methods/did-jwk.ts +410 -0
- package/src/methods/did-key.ts +1248 -0
- package/src/methods/did-method.ts +276 -0
- package/src/methods/did-web.ts +96 -0
- package/src/resolver/resolver-cache-level.ts +163 -0
- package/src/resolver/resolver-cache-noop.ts +26 -0
- package/src/resolver/universal-resolver.ts +238 -0
- package/src/types/did-core.ts +580 -0
- package/src/types/did-resolution.ts +93 -0
- package/src/types/multibase.ts +29 -0
- package/src/types/portable-did.ts +64 -0
- package/src/utils.ts +532 -0
|
@@ -0,0 +1,523 @@
|
|
|
1
|
+
import { Jwk } from '@enbox/crypto';
|
|
2
|
+
/**
|
|
3
|
+
* Represents metadata related to the process of DID dereferencing.
|
|
4
|
+
*
|
|
5
|
+
* This type includes fields that provide information about the outcome of a DID dereferencing operation,
|
|
6
|
+
* including the content type of the returned resource and any errors that occurred during the dereferencing process.
|
|
7
|
+
*
|
|
8
|
+
* @see {@link https://www.w3.org/TR/did-core/#did-url-dereferencing-metadata | DID Core Specification, § DID URL Dereferencing Metadata}
|
|
9
|
+
*/
|
|
10
|
+
export type DidDereferencingMetadata = {
|
|
11
|
+
/**
|
|
12
|
+
* The Media Type of the returned contentStream SHOULD be expressed using this property if
|
|
13
|
+
* dereferencing is successful.
|
|
14
|
+
*/
|
|
15
|
+
contentType?: string;
|
|
16
|
+
/**
|
|
17
|
+
* The error code from the dereferencing process. This property is REQUIRED when there is an
|
|
18
|
+
* error in the dereferencing process. The value of this property MUST be a single keyword
|
|
19
|
+
* expressed as an ASCII string. The possible property values of this field SHOULD be registered
|
|
20
|
+
* in the {@link https://www.w3.org/TR/did-spec-registries/ | DID Specification Registries}.
|
|
21
|
+
* The DID Core specification defines the following common error values:
|
|
22
|
+
*
|
|
23
|
+
* - `invalidDidUrl`: The DID URL supplied to the DID URL dereferencing function does not conform
|
|
24
|
+
* to valid syntax.
|
|
25
|
+
* - `notFound`: The DID URL dereferencer was unable to find the `contentStream` resulting from
|
|
26
|
+
* this dereferencing request.
|
|
27
|
+
*
|
|
28
|
+
* @see {@link https://www.w3.org/TR/did-core/#did-url-dereferencing-metadata | DID Core Specification, § DID URL Dereferencing Metadata}
|
|
29
|
+
*/
|
|
30
|
+
error?: string;
|
|
31
|
+
[key: string]: any;
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* Represents the options that can be used during the process of DID dereferencing.
|
|
35
|
+
*
|
|
36
|
+
* This interface allows the caller to specify preferences and additional parameters for the DID
|
|
37
|
+
* dereferencing operation.
|
|
38
|
+
*
|
|
39
|
+
* @see {@link https://www.w3.org/TR/did-core/#did-url-dereferencing-options}
|
|
40
|
+
*/
|
|
41
|
+
export interface DidDereferencingOptions {
|
|
42
|
+
/** The Media Type that the caller prefers for contentStream. */
|
|
43
|
+
accept?: string;
|
|
44
|
+
/** Additional properties used during DID dereferencing. */
|
|
45
|
+
[key: string]: any;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Represents the result of a DID dereferencing operation.
|
|
49
|
+
*
|
|
50
|
+
* This type encapsulates the outcomes of the DID URL dereferencing process, including metadata
|
|
51
|
+
* about the dereferencing operation, the content stream retrieved (if any), and metadata about the
|
|
52
|
+
* content stream.
|
|
53
|
+
*
|
|
54
|
+
* @see {@link https://www.w3.org/TR/did-core/#did-url-dereferencing | DID Core Specification, § DID URL Dereferencing}
|
|
55
|
+
*/
|
|
56
|
+
export type DidDereferencingResult = {
|
|
57
|
+
/**
|
|
58
|
+
* A metadata structure consisting of values relating to the results of the DID URL dereferencing
|
|
59
|
+
* process. This structure is REQUIRED, and in the case of an error in the dereferencing process,
|
|
60
|
+
* this MUST NOT be empty. Properties defined by this specification are in 7.2.2 DID URL
|
|
61
|
+
* Dereferencing Metadata. If the dereferencing is not successful, this structure MUST contain an
|
|
62
|
+
* `error` property describing the error.
|
|
63
|
+
*/
|
|
64
|
+
dereferencingMetadata: DidDereferencingMetadata;
|
|
65
|
+
/**
|
|
66
|
+
* If the `dereferencing` function was called and successful, this MUST contain a resource
|
|
67
|
+
* corresponding to the DID URL. The contentStream MAY be a resource such as:
|
|
68
|
+
* - a DID document that is serializable in one of the conformant representations
|
|
69
|
+
* - a Verification Method
|
|
70
|
+
* - a service.
|
|
71
|
+
* - any other resource format that can be identified via a Media Type and obtained through the
|
|
72
|
+
* resolution process.
|
|
73
|
+
*
|
|
74
|
+
* If the dereferencing is unsuccessful, this value MUST be empty.
|
|
75
|
+
*/
|
|
76
|
+
contentStream: DidResource | null;
|
|
77
|
+
/**
|
|
78
|
+
* If the dereferencing is successful, this MUST be a metadata structure, but the structure MAY be
|
|
79
|
+
* empty. This structure contains metadata about the contentStream. If the contentStream is a DID
|
|
80
|
+
* document, this MUST be a didDocumentMetadata structure as described in DID Resolution. If the
|
|
81
|
+
* dereferencing is unsuccessful, this output MUST be an empty metadata structure.
|
|
82
|
+
*/
|
|
83
|
+
contentMetadata: DidDocumentMetadata;
|
|
84
|
+
};
|
|
85
|
+
/**
|
|
86
|
+
* A set of data describing the Decentralized Identifierr (DID) subject.
|
|
87
|
+
*
|
|
88
|
+
* A DID Document contains information associated with the DID, such as cryptographic public keys
|
|
89
|
+
* and service endpoints, enabling trustable interactions associated with the DID subject.
|
|
90
|
+
*
|
|
91
|
+
* - Cryptographic public keys - Used by the DID subject or a DID delegate to authenticate itself
|
|
92
|
+
* and prove its association with the DID.
|
|
93
|
+
* - Service endpoints - Used to communicate or interact with the DID subject or associated
|
|
94
|
+
* entities. Examples include discovery, agent, social networking, file
|
|
95
|
+
* storage, and verifiable credential repository services.
|
|
96
|
+
*
|
|
97
|
+
* A DID Document can be retrieved by resolving a DID, as described in
|
|
98
|
+
* {@link https://www.w3.org/TR/did-core/#did-resolution | DID Core Specification, § DID Resolution}.
|
|
99
|
+
*/
|
|
100
|
+
export interface DidDocument {
|
|
101
|
+
/**
|
|
102
|
+
* A JSON-LD context link, which provides a JSON-LD processor with the information necessary to
|
|
103
|
+
* interpret the DID document JSON. The default context URL is 'https://www.w3.org/ns/did/v1'.
|
|
104
|
+
*/
|
|
105
|
+
'@context'?: 'https://www.w3.org/ns/did/v1' | string | (string | Record<string, any>)[];
|
|
106
|
+
/**
|
|
107
|
+
* The DID Subject to which this DID Document pertains.
|
|
108
|
+
*
|
|
109
|
+
* The `id` property is REQUIRED and must be a valid DID.
|
|
110
|
+
*
|
|
111
|
+
* @see {@link https://www.w3.org/TR/did-core/#did-subject | DID Core Specification, § DID Subject}
|
|
112
|
+
*/
|
|
113
|
+
id: string;
|
|
114
|
+
/**
|
|
115
|
+
* A DID subject can have multiple identifiers for different purposes, or at different times.
|
|
116
|
+
* The assertion that two or more DIDs (or other types of URI) refer to the same DID subject can
|
|
117
|
+
* be made using the `alsoKnownAs` property.
|
|
118
|
+
*
|
|
119
|
+
* @see {@link https://www.w3.org/TR/did-core/#also-known-as | DID Core Specification, § Also Known As}
|
|
120
|
+
*/
|
|
121
|
+
alsoKnownAs?: string[];
|
|
122
|
+
/**
|
|
123
|
+
* A DID controller is an entity that is authorized to make changes to a DID document. Typically,
|
|
124
|
+
* only the DID Subject (i.e., the value of `id` property in the DID document) is authoritative.
|
|
125
|
+
* However, another DID can be specified as the DID controller, and when doing so, any
|
|
126
|
+
* verification methods contained in the DID document for the other DID should be accepted as
|
|
127
|
+
* authoritative. In other words, proofs created by the controller DID should be considered
|
|
128
|
+
* equivalent to proofs created by the DID Subject.
|
|
129
|
+
*
|
|
130
|
+
* @see {@link https://www.w3.org/TR/did-core/#did-controller | DID Core Specification, § DID Controller}
|
|
131
|
+
*/
|
|
132
|
+
controller?: string | string[];
|
|
133
|
+
/**
|
|
134
|
+
* A DID document can express verification methods, such as cryptographic public keys, which can
|
|
135
|
+
* be used to authenticate or authorize interactions with the DID subject or associated parties.
|
|
136
|
+
*
|
|
137
|
+
* @see {@link https://www.w3.org/TR/did-core/#verification-methods | DID Core Specification, § Verification Methods}
|
|
138
|
+
*/
|
|
139
|
+
verificationMethod?: DidVerificationMethod[];
|
|
140
|
+
/**
|
|
141
|
+
* The `assertionMethod` verification relationship is used to specify how the DID subject is
|
|
142
|
+
* expected to express claims, such as for the purposes of issuing a Verifiable Credential.
|
|
143
|
+
*
|
|
144
|
+
* @see {@link https://www.w3.org/TR/did-core/#assertion | DID Core Specification, § Assertion}
|
|
145
|
+
*/
|
|
146
|
+
assertionMethod?: (DidVerificationMethod | string)[];
|
|
147
|
+
/**
|
|
148
|
+
* The `authentication` verification relationship is used to specify how the DID subject is expected
|
|
149
|
+
* to be authenticated, for purposes such as logging into a website or engaging in any sort of
|
|
150
|
+
* challenge-response protocol.
|
|
151
|
+
|
|
152
|
+
* @see {@link https://www.w3.org/TR/did-core/#authentication | DID Core Specification, § Authentication}
|
|
153
|
+
*/
|
|
154
|
+
authentication?: (DidVerificationMethod | string)[];
|
|
155
|
+
/**
|
|
156
|
+
* The `keyAgreement` verification relationship is used to specify how an entity can generate
|
|
157
|
+
* encryption material in order to transmit confidential information intended for the DID
|
|
158
|
+
* subject, such as for the purposes of establishing a secure communication channel with the
|
|
159
|
+
* recipient.
|
|
160
|
+
*
|
|
161
|
+
* @see {@link https://www.w3.org/TR/did-core/#key-agreement | DID Core Specification, § Key Agreement}
|
|
162
|
+
*/
|
|
163
|
+
keyAgreement?: (DidVerificationMethod | string)[];
|
|
164
|
+
/**
|
|
165
|
+
* The `capabilityDelegation` verification relationship is used to specify a mechanism that might
|
|
166
|
+
* be used by the DID subject to delegate a cryptographic capability to another party, such as
|
|
167
|
+
* delegating the authority to access a specific HTTP API to a subordinate.
|
|
168
|
+
*
|
|
169
|
+
* @see {@link https://www.w3.org/TR/did-core/#capability-delegation | DID Core Specification, § Capability Delegation}
|
|
170
|
+
*/
|
|
171
|
+
capabilityDelegation?: (DidVerificationMethod | string)[];
|
|
172
|
+
/**
|
|
173
|
+
* The `capabilityInvocation` verification relationship is used to specify a verification method
|
|
174
|
+
* that might be used by the DID subject to invoke a cryptographic capability, such as the
|
|
175
|
+
* authorization to update the DID Document.
|
|
176
|
+
*/
|
|
177
|
+
capabilityInvocation?: (DidVerificationMethod | string)[];
|
|
178
|
+
/**
|
|
179
|
+
* Services are used in DID documents to express ways of communicating with the DID subject or
|
|
180
|
+
* associated entities. A service can be any type of service the DID subject wants to advertise,
|
|
181
|
+
* including decentralized identity management services for further discovery, authentication,
|
|
182
|
+
* authorization, or interaction.
|
|
183
|
+
*
|
|
184
|
+
* @see {@link https://www.w3.org/TR/did-core/#services | DID Core Specification, § Services}
|
|
185
|
+
*/
|
|
186
|
+
service?: DidService[];
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Represents metadata about the DID document resulting from a DID resolution operation.
|
|
190
|
+
*
|
|
191
|
+
* This metadata typically does not change between invocations of the `resolve` and
|
|
192
|
+
* `resolveRepresentation` functions unless the DID document changes, as it represents metadata
|
|
193
|
+
* about the DID document.
|
|
194
|
+
*
|
|
195
|
+
* @see {@link https://www.w3.org/TR/did-core/#did-document-metadata | DID Core Specification, § DID Document Metadata}
|
|
196
|
+
*/
|
|
197
|
+
export interface DidDocumentMetadata {
|
|
198
|
+
/**
|
|
199
|
+
* Timestamp of the Create operation.
|
|
200
|
+
*
|
|
201
|
+
* The value of the property MUST be a string formatted as an XML Datetime normalized to
|
|
202
|
+
* UTC 00:00:00 and without sub-second decimal precision. For example: `2020-12-20T19:17:47Z`.
|
|
203
|
+
*/
|
|
204
|
+
created?: string;
|
|
205
|
+
/**
|
|
206
|
+
* Timestamp of the last Update operation for the document version which was resolved.
|
|
207
|
+
*
|
|
208
|
+
* The value of the property MUST follow the same formatting rules as the `created` property.
|
|
209
|
+
* The `updated` property is omitted if an Update operation has never been performed on the DID
|
|
210
|
+
* document. If an `updated` property exists, it can be the same value as the `created` property
|
|
211
|
+
* when the difference between the two timestamps is less than one second.
|
|
212
|
+
*/
|
|
213
|
+
updated?: string;
|
|
214
|
+
/**
|
|
215
|
+
* Whether the DID has been deactivated.
|
|
216
|
+
*
|
|
217
|
+
* If a DID has been deactivated, DID document metadata MUST include this property with the
|
|
218
|
+
* boolean value `true`. If a DID has not been deactivated, this properrty is OPTIONAL, but if
|
|
219
|
+
* present, MUST have the boolean value `false`.
|
|
220
|
+
*/
|
|
221
|
+
deactivated?: boolean;
|
|
222
|
+
/**
|
|
223
|
+
* Version ID of the last Update operation for the document version which was resolved.
|
|
224
|
+
*/
|
|
225
|
+
versionId?: string;
|
|
226
|
+
/**
|
|
227
|
+
* Timestamp of the next Update operation if the resolved document version is not the latest
|
|
228
|
+
* version of the document.
|
|
229
|
+
*
|
|
230
|
+
* The value of the property MUST follow the same formatting rules as the `created` property.
|
|
231
|
+
*/
|
|
232
|
+
nextUpdate?: string;
|
|
233
|
+
/**
|
|
234
|
+
* Version ID of the next Update operation if the resolved document version is not the latest
|
|
235
|
+
* version of the document.
|
|
236
|
+
*/
|
|
237
|
+
nextVersionId?: string;
|
|
238
|
+
/**
|
|
239
|
+
* A DID method can define different forms of a DID that are logically equivalent. An example is
|
|
240
|
+
* when a DID takes one form prior to registration in a verifiable data registry and another form
|
|
241
|
+
* after such registration. In this case, the DID method specification might need to express one
|
|
242
|
+
* or more DIDs that are logically equivalent to the resolved DID as a property of the DID
|
|
243
|
+
* document. This is the purpose of the `equivalentId` property.
|
|
244
|
+
*
|
|
245
|
+
* A requesting party is expected to retain the values from the id and equivalentId properties to
|
|
246
|
+
* ensure any subsequent interactions with any of the values they contain are correctly handled as
|
|
247
|
+
* logically equivalent (e.g., retain all variants in a database so an interaction with any one
|
|
248
|
+
* maps to the same underlying account).
|
|
249
|
+
*
|
|
250
|
+
* @see {@link https://www.w3.org/TR/did-core/#dfn-equivalentid | DID Core Specification, § DID Document Metadata}
|
|
251
|
+
*/
|
|
252
|
+
equivalentId?: string[];
|
|
253
|
+
/**
|
|
254
|
+
* The `canonicalId` property is identical to the `equivalentId` property except:
|
|
255
|
+
* - it is associated with a single value rather than a set
|
|
256
|
+
* - the DID is defined to be the canonical ID for the DID subject within the scope of the
|
|
257
|
+
* containing DID document.
|
|
258
|
+
*
|
|
259
|
+
* A requesting party is expected to use the `canonicalId` value as its primary ID value for the
|
|
260
|
+
* DID subject and treat all other equivalent values as secondary aliases (e.g., update
|
|
261
|
+
* corresponding primary references in their systems to reflect the new canonical ID directive).
|
|
262
|
+
*
|
|
263
|
+
* @see {@link https://www.w3.org/TR/did-core/#dfn-canonicalid | DID Core Specification, § DID Document Metadata}
|
|
264
|
+
*/
|
|
265
|
+
canonicalId?: string;
|
|
266
|
+
[key: string]: any;
|
|
267
|
+
}
|
|
268
|
+
/**
|
|
269
|
+
* Represents metadata related to the result of a DID resolution operation.
|
|
270
|
+
*
|
|
271
|
+
* This type includes fields that provide information about the outcome of a DID resolution process,
|
|
272
|
+
* including the content type of the returned DID document and any errors that occurred during the
|
|
273
|
+
* resolution process.
|
|
274
|
+
*
|
|
275
|
+
* This metadata typically changes between invocations of the `resolve` and `resolveRepresentation`
|
|
276
|
+
* functions, as it represents data about the resolution process itself.
|
|
277
|
+
*
|
|
278
|
+
* @see {@link https://www.w3.org/TR/did-core/#did-resolution-metadata | DID Core Specification, § DID Resolution Metadata}
|
|
279
|
+
*/
|
|
280
|
+
export type DidResolutionMetadata = {
|
|
281
|
+
/**
|
|
282
|
+
* The Media Type of the returned `didDocumentStream`.
|
|
283
|
+
*
|
|
284
|
+
* This property is REQUIRED if resolution is successful and if the `resolveRepresentation`
|
|
285
|
+
* function was called. This property MUST NOT be present if the `resolve` function was called.
|
|
286
|
+
* The value of this property MUST be an ASCII string that is the Media Type of the conformant
|
|
287
|
+
* representations. The caller of the `resolveRepresentation` function MUST use this value when
|
|
288
|
+
* determining how to parse and process the `didDocumentStream` returned by this function into the
|
|
289
|
+
* data model.
|
|
290
|
+
*/
|
|
291
|
+
contentType?: string;
|
|
292
|
+
/**
|
|
293
|
+
* An error code indicating issues encountered during the DID Resolution or DID URL
|
|
294
|
+
* Dereferencing process.
|
|
295
|
+
*
|
|
296
|
+
* Defined error codes include:
|
|
297
|
+
* - `internalError`: An unexpected error occurred during DID Resolution or DID URL
|
|
298
|
+
* dereferencing process.
|
|
299
|
+
* - `invalidDid`: The provided DID is invalid.
|
|
300
|
+
* - `methodNotSupported`: The DID method specified is not supported.
|
|
301
|
+
* - `notFound`: The DID or DID URL does not exist.
|
|
302
|
+
* - `representationNotSupported`: The DID document representation is not supported.
|
|
303
|
+
* - Custom error codes can also be provided as strings.
|
|
304
|
+
*
|
|
305
|
+
* @see {@link https://www.w3.org/TR/did-core/#did-resolution-metadata | DID Core Specification, § DID Resolution Metadata}
|
|
306
|
+
* @see {@link https://www.w3.org/TR/did-spec-registries/#error | DID Specification Registries, § Error}
|
|
307
|
+
*/
|
|
308
|
+
error?: string;
|
|
309
|
+
[key: string]: any;
|
|
310
|
+
};
|
|
311
|
+
/**
|
|
312
|
+
* DID Resolution input metadata.
|
|
313
|
+
*
|
|
314
|
+
* The DID Core specification defines the following common properties:
|
|
315
|
+
* - `accept`: The Media Type that the caller prefers for the returned representation of the DID
|
|
316
|
+
* Document.
|
|
317
|
+
*
|
|
318
|
+
* The possible properties within this structure and their possible values are registered in the
|
|
319
|
+
* {@link https://www.w3.org/TR/did-spec-registries/#did-resolution-options | DID Specification Registries}.
|
|
320
|
+
*
|
|
321
|
+
* @see {@link https://www.w3.org/TR/did-core/#did-resolution-options | DID Core Specification, § DID Resolution Options}
|
|
322
|
+
*/
|
|
323
|
+
export interface DidResolutionOptions {
|
|
324
|
+
/**
|
|
325
|
+
* The Media Type that the caller prefers for the returned representation of the DID Document.
|
|
326
|
+
*
|
|
327
|
+
* This property is REQUIRED if the `resolveRepresentation` function was called. This property
|
|
328
|
+
* MUST NOT be present if the `resolve` function was called.
|
|
329
|
+
*
|
|
330
|
+
* The value of this property MUST be an ASCII string that is the Media Type of the conformant
|
|
331
|
+
* representations. The caller of the `resolveRepresentation` function MUST use this value when
|
|
332
|
+
* determining how to parse and process the `didDocumentStream` returned by this function into the
|
|
333
|
+
* data model.
|
|
334
|
+
*
|
|
335
|
+
* @see {@link https://www.w3.org/TR/did-core/#did-resolution-options | DID Core Specification, § DID Resolution Options}
|
|
336
|
+
*/
|
|
337
|
+
accept?: string;
|
|
338
|
+
[key: string]: any;
|
|
339
|
+
}
|
|
340
|
+
/**
|
|
341
|
+
* Represents the result of a Decentralized Identifier (DID) resolution operation.
|
|
342
|
+
*
|
|
343
|
+
* This type encapsulates the complete outcome of resolving a DID, including the resolution metadata,
|
|
344
|
+
* the DID document (if resolution is successful), and metadata about the DID document.
|
|
345
|
+
*
|
|
346
|
+
* @see {@link https://www.w3.org/TR/did-core/#did-resolution | DID Core Specification, § DID Resolution}
|
|
347
|
+
*/
|
|
348
|
+
export type DidResolutionResult = {
|
|
349
|
+
/**
|
|
350
|
+
* A JSON-LD context link, which provides the JSON-LD processor with the information necessary to
|
|
351
|
+
* interpret the resolution result JSON. The default context URL is
|
|
352
|
+
* 'https://w3id.org/did-resolution/v1'.
|
|
353
|
+
*/
|
|
354
|
+
'@context'?: 'https://w3id.org/did-resolution/v1' | string | (string | Record<string, any>)[];
|
|
355
|
+
/**
|
|
356
|
+
* A metadata structure consisting of values relating to the results of the DID resolution
|
|
357
|
+
* process.
|
|
358
|
+
*
|
|
359
|
+
* This structure is REQUIRED, and in the case of an error in the resolution process,
|
|
360
|
+
* this MUST NOT be empty. If the resolution is not successful, this structure MUST contain an
|
|
361
|
+
* `error` property describing the error.
|
|
362
|
+
*
|
|
363
|
+
* @see {@link https://www.w3.org/TR/did-core/#dfn-didresolutionmetadata | DID Core Specification, § DID Resolution Metadata}
|
|
364
|
+
*/
|
|
365
|
+
didResolutionMetadata: DidResolutionMetadata;
|
|
366
|
+
/**
|
|
367
|
+
* The DID document resulting from the resolution process, if successful.
|
|
368
|
+
*
|
|
369
|
+
* If the `resolve` function was called and successful, this MUST contain a DID document
|
|
370
|
+
* corresponding to the DID. If the resolution is unsuccessful, this value MUST be empty.
|
|
371
|
+
*
|
|
372
|
+
* @see {@link https://www.w3.org/TR/did-core/#dfn-diddocument | DID Core Specification, § DID Document}
|
|
373
|
+
*/
|
|
374
|
+
didDocument: DidDocument | null;
|
|
375
|
+
/**
|
|
376
|
+
* Metadata about the DID Document.
|
|
377
|
+
*
|
|
378
|
+
* This structure contains information about the DID Document like creation and update timestamps,
|
|
379
|
+
* deactivation status, versioning information, and other details relevant to the DID Document.
|
|
380
|
+
*
|
|
381
|
+
* @see {@link https://www.w3.org/TR/did-core/#dfn-diddocumentmetadata | DID Core Specification, § DID Document Metadata}
|
|
382
|
+
*/
|
|
383
|
+
didDocumentMetadata: DidDocumentMetadata;
|
|
384
|
+
};
|
|
385
|
+
/**
|
|
386
|
+
* A DID Resource is either a DID Document, a DID Verification method or a DID Service
|
|
387
|
+
*/
|
|
388
|
+
export type DidResource = DidDocument | DidService | DidVerificationMethod;
|
|
389
|
+
/**
|
|
390
|
+
* Services are used in DID documents to express ways of communicating with the DID subject or
|
|
391
|
+
* associated entities. A service can be any type of service the DID subject wants to advertise.
|
|
392
|
+
*
|
|
393
|
+
* @see {@link https://www.w3.org/TR/did-core/#services}
|
|
394
|
+
*/
|
|
395
|
+
export type DidService = {
|
|
396
|
+
/**
|
|
397
|
+
* Identifier of the service.
|
|
398
|
+
*
|
|
399
|
+
* The `id` property is REQUIRED. It MUST be a URI conforming to
|
|
400
|
+
* {@link https://datatracker.ietf.org/doc/html/rfc3986 | RFC3986} and MUST be unique within the
|
|
401
|
+
* DID document.
|
|
402
|
+
*/
|
|
403
|
+
id: string;
|
|
404
|
+
/**
|
|
405
|
+
* The type of service being described.
|
|
406
|
+
*
|
|
407
|
+
* The `type` property is REQUIRED. It MUST be a string. To maximize interoperability, the value
|
|
408
|
+
* SHOULD be registered in the
|
|
409
|
+
* {@link https://www.w3.org/TR/did-spec-registries/ | DID Specification Registries}. Examples of
|
|
410
|
+
* service types can be found in
|
|
411
|
+
* {@link https://www.w3.org/TR/did-spec-registries/#service-types | § Service Types}.
|
|
412
|
+
*/
|
|
413
|
+
type: string;
|
|
414
|
+
/**
|
|
415
|
+
* A URI that can be used to interact with the DID service.
|
|
416
|
+
*
|
|
417
|
+
* The value of the `serviceEndpoint` property MUST be a string, an object containing key/value
|
|
418
|
+
* pairs, or an array composed of strings or objects. All string values MUST be valid URIs
|
|
419
|
+
* conforming to {@link https://datatracker.ietf.org/doc/html/rfc3986 | RFC3986}.
|
|
420
|
+
*/
|
|
421
|
+
serviceEndpoint: DidServiceEndpoint | DidServiceEndpoint[];
|
|
422
|
+
[key: string]: any;
|
|
423
|
+
};
|
|
424
|
+
/**
|
|
425
|
+
* A service endpoint is a URI (Uniform Resource Identifier) that can be used to interact with the
|
|
426
|
+
* DID service.
|
|
427
|
+
*
|
|
428
|
+
* The value of the `serviceEndpoint` property MUST be a string or an object containing key/value
|
|
429
|
+
* pairs. All string values MUST be valid URIs conforming to
|
|
430
|
+
* {@link https://datatracker.ietf.org/doc/html/rfc3986 | RFC3986}.
|
|
431
|
+
*
|
|
432
|
+
* @see {@link https://www.w3.org/TR/did-core/#dfn-serviceendpoint | RFC3986, § 5.4 Services}
|
|
433
|
+
*/
|
|
434
|
+
export type DidServiceEndpoint = string | Record<string, any>;
|
|
435
|
+
/**
|
|
436
|
+
* Represents a verification method in the context of a DID document.
|
|
437
|
+
*
|
|
438
|
+
* A verification method is a mechanism by which a DID controller can cryptographically assert proof
|
|
439
|
+
* of ownership or control over a DID or DID document. This can include, but is not limited to,
|
|
440
|
+
* cryptographic public keys or other data that can be used to authenticate or authorize actions.
|
|
441
|
+
*
|
|
442
|
+
* @see {@link https://www.w3.org/TR/did-core/#verification-methods | DID Core Specification, § Verification Methods}
|
|
443
|
+
*/
|
|
444
|
+
export interface DidVerificationMethod {
|
|
445
|
+
/**
|
|
446
|
+
* The identifier of the verification method, which must be a URI.
|
|
447
|
+
*/
|
|
448
|
+
id: string;
|
|
449
|
+
/**
|
|
450
|
+
* The type of the verification method.
|
|
451
|
+
*
|
|
452
|
+
* To maximize interoperability this value SHOULD be one of the valid verification method types
|
|
453
|
+
* registered in the {@link https://www.w3.org/TR/did-spec-registries/#verification-method-types | DID Specification Registries}.
|
|
454
|
+
*/
|
|
455
|
+
type: string;
|
|
456
|
+
/**
|
|
457
|
+
* The DID of the entity that controls this verification method.
|
|
458
|
+
*/
|
|
459
|
+
controller: string;
|
|
460
|
+
/**
|
|
461
|
+
* (Optional) A public key in JWK format.
|
|
462
|
+
*
|
|
463
|
+
* A JSON Web Key (JWK) that conforms to {@link https://datatracker.ietf.org/doc/html/rfc7517 | RFC 7517}.
|
|
464
|
+
*/
|
|
465
|
+
publicKeyJwk?: Jwk;
|
|
466
|
+
/**
|
|
467
|
+
* (Optional) A public key in Multibase format.
|
|
468
|
+
*
|
|
469
|
+
* A multibase key that conforms to the draft
|
|
470
|
+
* {@link https://datatracker.ietf.org/doc/draft-multiformats-multibase/ | Multibase specification}.
|
|
471
|
+
*/
|
|
472
|
+
publicKeyMultibase?: string;
|
|
473
|
+
}
|
|
474
|
+
/**
|
|
475
|
+
* Represents the various verification relationships defined in a DID document.
|
|
476
|
+
*
|
|
477
|
+
* These verification relationships indicate the intended usage of verification methods within a DID
|
|
478
|
+
* document. Each relationship signifies a different purpose or context in which a verification
|
|
479
|
+
* method can be used, such as authentication, assertionMethod, keyAgreement, capabilityDelegation,
|
|
480
|
+
* and capabilityInvocation. The array provides a standardized set of relationship names for
|
|
481
|
+
* consistent referencing and implementation across different DID methods.
|
|
482
|
+
*
|
|
483
|
+
* @see {@link https://www.w3.org/TR/did-core/#verification-relationships | DID Core Specification, § Verification Relationships}
|
|
484
|
+
*/
|
|
485
|
+
export declare enum DidVerificationRelationship {
|
|
486
|
+
/**
|
|
487
|
+
* Specifies how the DID subject is expected to be authenticated. This is commonly used for
|
|
488
|
+
* purposes like logging into a website or participating in challenge-response protocols.
|
|
489
|
+
*
|
|
490
|
+
* @see {@link https://www.w3.org/TR/did-core/#authentication | DID Core Specification, § Authentication}
|
|
491
|
+
*/
|
|
492
|
+
authentication = "authentication",
|
|
493
|
+
/**
|
|
494
|
+
* Specifies how the DID subject is expected to express claims, such as for issuing Verifiable
|
|
495
|
+
* Credentials. This relationship is typically used when the DID subject is the issuer of a
|
|
496
|
+
* credential.
|
|
497
|
+
*
|
|
498
|
+
* @see {@link https://www.w3.org/TR/did-core/#assertion | DID Core Specification, § Assertion}
|
|
499
|
+
*/
|
|
500
|
+
assertionMethod = "assertionMethod",
|
|
501
|
+
/**
|
|
502
|
+
* Specifies how an entity can generate encryption material to communicate confidentially with the
|
|
503
|
+
* DID subject. Often used in scenarios requiring secure communication channels.
|
|
504
|
+
*
|
|
505
|
+
* @see {@link https://www.w3.org/TR/did-core/#key-agreement | DID Core Specification, § Key Agreement}
|
|
506
|
+
*/
|
|
507
|
+
keyAgreement = "keyAgreement",
|
|
508
|
+
/**
|
|
509
|
+
* Specifies a verification method used by the DID subject to invoke a cryptographic capability.
|
|
510
|
+
* This is frequently associated with authorization actions, like updating the DID Document.
|
|
511
|
+
*
|
|
512
|
+
* @see {@link https://www.w3.org/TR/did-core/#capability-invocation | DID Core Specification, § Capability Invocation}
|
|
513
|
+
*/
|
|
514
|
+
capabilityInvocation = "capabilityInvocation",
|
|
515
|
+
/**
|
|
516
|
+
* Specifies a mechanism used by the DID subject to delegate a cryptographic capability to another
|
|
517
|
+
* party. This can include delegating access to a specific resource or API.
|
|
518
|
+
*
|
|
519
|
+
* @see {@link https://www.w3.org/TR/did-core/#capability-delegation | DID Core Specification, § Capability Delegation}
|
|
520
|
+
*/
|
|
521
|
+
capabilityDelegation = "capabilityDelegation"
|
|
522
|
+
}
|
|
523
|
+
//# sourceMappingURL=did-core.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"did-core.d.ts","sourceRoot":"","sources":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;;;;;;;GAUG;AACH,oBAAY,2BAA2B;IACrC;;;;;OAKG;IACH,cAAc,mBAAmB;IAEjC;;;;;;OAMG;IACH,eAAe,oBAAoB;IAEnC;;;;;OAKG;IACH,YAAY,iBAAiB;IAE7B;;;;;OAKG;IACH,oBAAoB,yBAAyB;IAE7C;;;;;OAKG;IACH,oBAAoB,yBAAyB;CAC9C"}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import type { KeyValueStore } from '@enbox/common';
|
|
2
|
+
import type { DidDereferencingOptions, DidDereferencingResult, DidResolutionOptions, DidResolutionResult } from './did-core.js';
|
|
3
|
+
/**
|
|
4
|
+
* Represents the interface for resolving a Decentralized Identifier (DID) to its corresponding DID
|
|
5
|
+
* document.
|
|
6
|
+
*
|
|
7
|
+
* The `DidResolver` interface defines a single method, `resolve`, which takes a DID URL as input
|
|
8
|
+
* and returns a `Promise` that resolves to a `DidResolutionResult`. This result contains the DID
|
|
9
|
+
* document associated with the given DID, along with metadata about the resolution process.
|
|
10
|
+
*
|
|
11
|
+
* Implementations of this interface are expected to support resolution of DIDs according to the
|
|
12
|
+
* specific rules and methods defined by the DID scheme in use.
|
|
13
|
+
*
|
|
14
|
+
* More information on DID URL dereferencing can be found in the
|
|
15
|
+
* {@link https://www.w3.org/TR/did-core/#did-resolution | DID Core specification}.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```typescript
|
|
19
|
+
* const resolutionResult = await didResolver.resolve('did:example:123456789abcdefghi');
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
export interface DidResolver {
|
|
23
|
+
/**
|
|
24
|
+
* Resolves a DID URI to a DID document and associated metadata.
|
|
25
|
+
*
|
|
26
|
+
* This function should resolve the DID URI in accordance with the relevant DID method
|
|
27
|
+
* specification, using the provided `options`.
|
|
28
|
+
*
|
|
29
|
+
* @param didUri - The DID URI to be resolved.
|
|
30
|
+
* @param options - Optional. The options used for resolving the DID.
|
|
31
|
+
* @returns A {@link DidResolutionResult} object containing the DID document and metadata or an
|
|
32
|
+
* error.
|
|
33
|
+
*/
|
|
34
|
+
resolve(didUrl: string, options?: DidResolutionOptions): Promise<DidResolutionResult>;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Interface for cache implementations used by to store resolved DID documents.
|
|
38
|
+
*/
|
|
39
|
+
export interface DidResolverCache extends KeyValueStore<string, DidResolutionResult | void> {
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Represents the interface for dereferencing a DID URL to a specific resource within a DID
|
|
43
|
+
* document.
|
|
44
|
+
*
|
|
45
|
+
* The `DidUrlDereferencer` interface defines a single method, `dereference`, which takes a DID URL
|
|
46
|
+
* as input and returns a `Promise` that resolves to a `DidDereferencingResult`. This result
|
|
47
|
+
* includes the dereferenced resource (if found) and metadata about the dereferencing process.
|
|
48
|
+
*
|
|
49
|
+
* Dereferencing a DID URL involves parsing the URL to identify the specific part of the DID
|
|
50
|
+
* document being referenced, which could be a verification method, a service endpoint, or the
|
|
51
|
+
* entire document itself.
|
|
52
|
+
*
|
|
53
|
+
* Implementations of this interface must adhere to the dereferencing mechanisms defined in the DID
|
|
54
|
+
* Core specifications, handling various components of the DID URL including the DID itself, path,
|
|
55
|
+
* query, and fragment.
|
|
56
|
+
*
|
|
57
|
+
* More information on DID URL dereferencing can be found in the
|
|
58
|
+
* {@link https://www.w3.org/TR/did-core/#did-url-dereferencing | DID Core specification}.
|
|
59
|
+
*
|
|
60
|
+
* @example
|
|
61
|
+
* ```typescript
|
|
62
|
+
* const dereferenceResult = await didUrlDereferencer.dereference('did:example:123456789abcdefghi#keys-1');
|
|
63
|
+
* ```
|
|
64
|
+
*/
|
|
65
|
+
export interface DidUrlDereferencer {
|
|
66
|
+
/**
|
|
67
|
+
* Dereferences a DID (Decentralized Identifier) URL to a corresponding DID resource.
|
|
68
|
+
*
|
|
69
|
+
* This method interprets the DID URL's components, which include the DID method, method-specific
|
|
70
|
+
* identifier, path, query, and fragment, and retrieves the related resource as per the DID Core
|
|
71
|
+
* specifications.
|
|
72
|
+
*
|
|
73
|
+
* @param didUrl - The DID URL string to dereference.
|
|
74
|
+
* @param options - Input options to the dereference function. Optional.
|
|
75
|
+
* @returns a {@link DidDereferencingResult}
|
|
76
|
+
*/
|
|
77
|
+
dereference(didUrl: string, options?: DidDereferencingOptions): Promise<DidDereferencingResult>;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* A constant representing an empty DID Resolution Result. This object is used as the basis for a
|
|
81
|
+
* result of DID resolution and is typically augmented with additional properties by the
|
|
82
|
+
* DID method resolver.
|
|
83
|
+
*/
|
|
84
|
+
export declare const EMPTY_DID_RESOLUTION_RESULT: DidResolutionResult;
|
|
85
|
+
//# sourceMappingURL=did-resolution.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"did-resolution.d.ts","sourceRoot":"","sources":["../../../src/types/did-resolution.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAEnD,OAAO,KAAK,EAAE,uBAAuB,EAAE,sBAAsB,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAEhI;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,WAAW,WAAW;IAC1B;;;;;;;;;;OAUG;IACH,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,oBAAoB,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAAC;CACvF;AAED;;GAEG;AACH,MAAM,WAAW,gBAAiB,SAAQ,aAAa,CAAC,MAAM,EAAE,mBAAmB,GAAG,IAAI,CAAC;CAAG;AAE9F;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,WAAW,kBAAkB;IACjC;;;;;;;;;;OAUG;IACH,WAAW,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,uBAAuB,GAAG,OAAO,CAAC,sBAAsB,CAAC,CAAC;CACjG;AAED;;;;GAIG;AACH,eAAO,MAAM,2BAA2B,EAAE,mBAKzC,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Represents a cryptographic key with associated multicodec metadata.
|
|
3
|
+
*
|
|
4
|
+
* The `KeyWithMulticodec` type encapsulates a cryptographic key along with optional multicodec
|
|
5
|
+
* information. It is primarily used in functions that convert between cryptographic keys and their
|
|
6
|
+
* string representations, ensuring that the key's format and encoding are preserved and understood
|
|
7
|
+
* across different systems and applications.
|
|
8
|
+
*/
|
|
9
|
+
export type KeyWithMulticodec = {
|
|
10
|
+
/**
|
|
11
|
+
* A `Uint8Array` representing the raw bytes of the cryptographic key. This is the primary data of
|
|
12
|
+
* the type and is essential for cryptographic operations.
|
|
13
|
+
*/
|
|
14
|
+
keyBytes: Uint8Array;
|
|
15
|
+
/**
|
|
16
|
+
* An optional number representing the multicodec code. This code uniquely identifies the encoding
|
|
17
|
+
* format or protocol associated with the key. The presence of this code is crucial for decoding
|
|
18
|
+
* the key correctly in different contexts.
|
|
19
|
+
*/
|
|
20
|
+
multicodecCode?: number;
|
|
21
|
+
/**
|
|
22
|
+
* An optional string representing the human-readable name of the multicodec. This name provides
|
|
23
|
+
* an easier way to identify the encoding format or protocol of the key, especially when the
|
|
24
|
+
* numerical code is not immediately recognizable.
|
|
25
|
+
*/
|
|
26
|
+
multicodecName?: string;
|
|
27
|
+
};
|
|
28
|
+
//# sourceMappingURL=multibase.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"multibase.d.ts","sourceRoot":"","sources":["../../../src/types/multibase.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,MAAM,MAAM,iBAAiB,GAAG;IAC9B;;;OAGG;IACH,QAAQ,EAAE,UAAU,CAAC;IAErB;;;;OAIG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IAExB;;;;OAIG;IACH,cAAc,CAAC,EAAE,MAAM,CAAA;CACxB,CAAC"}
|