@sphereon/ssi-types 0.30.1-unstable.4 → 0.30.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 -201
- package/README.md +49 -49
- package/dist/events/index.d.ts +1 -0
- package/dist/events/index.d.ts.map +1 -1
- package/dist/logging/index.d.ts +1 -0
- package/dist/logging/index.d.ts.map +1 -1
- package/dist/logging/index.js +2 -2
- package/dist/logging/index.js.map +1 -1
- package/dist/mapper/jsonld-language-values.d.ts.map +1 -1
- package/dist/types/mso_mdoc.js +5 -5
- package/dist/types/mso_mdoc.js.map +1 -1
- package/dist/types/sd-jwt-vc.js +5 -5
- package/dist/types/sd-jwt-vc.js.map +1 -1
- package/dist/types/w3c-vc.js +3 -3
- package/dist/types/w3c-vc.js.map +1 -1
- package/package.json +4 -4
- package/src/events/index.ts +206 -206
- package/src/index.ts +9 -9
- package/src/logging/index.ts +224 -224
- package/src/mapper/credential-mapper.ts +919 -919
- package/src/mapper/index.ts +2 -2
- package/src/mapper/jsonld-language-values.ts +91 -91
- package/src/types/cose.ts +69 -69
- package/src/types/did.ts +268 -268
- package/src/types/generic.ts +48 -48
- package/src/types/index.ts +9 -9
- package/src/types/jose.ts +115 -115
- package/src/types/mso_mdoc.ts +174 -174
- package/src/types/pex.ts +36 -36
- package/src/types/sd-jwt-vc.ts +369 -369
- package/src/types/vc.ts +87 -87
- package/src/types/w3c-vc.ts +306 -306
- package/src/utils/index.ts +1 -1
- package/src/utils/object.ts +28 -28
package/src/types/did.ts
CHANGED
|
@@ -1,268 +1,268 @@
|
|
|
1
|
-
export enum IProofPurpose {
|
|
2
|
-
verificationMethod = 'verificationMethod',
|
|
3
|
-
assertionMethod = 'assertionMethod',
|
|
4
|
-
authentication = 'authentication',
|
|
5
|
-
keyAgreement = 'keyAgreement',
|
|
6
|
-
contractAgreement = 'contactAgreement',
|
|
7
|
-
capabilityInvocation = 'capabilityInvocation',
|
|
8
|
-
capabilityDelegation = 'capabilityDelegation',
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export enum IProofType {
|
|
12
|
-
Ed25519Signature2018 = 'Ed25519Signature2018',
|
|
13
|
-
Ed25519Signature2020 = 'Ed25519Signature2020',
|
|
14
|
-
EcdsaSecp256k1Signature2019 = 'EcdsaSecp256k1Signature2019',
|
|
15
|
-
EcdsaSecp256k1RecoverySignature2020 = 'EcdsaSecp256k1RecoverySignature2020',
|
|
16
|
-
JsonWebSignature2020 = 'JsonWebSignature2020',
|
|
17
|
-
RsaSignature2018 = 'RsaSignature2018',
|
|
18
|
-
GpgSignature2020 = 'GpgSignature2020',
|
|
19
|
-
JcsEd25519Signature2020 = 'JcsEd25519Signature2020',
|
|
20
|
-
BbsBlsSignatureProof2020 = 'BbsBlsSignatureProof2020',
|
|
21
|
-
BbsBlsBoundSignatureProof2020 = 'BbsBlsBoundSignatureProof2020',
|
|
22
|
-
JwtProof2020 = 'JwtProof2020',
|
|
23
|
-
SdJwtProof2024 = 'SdJwtProof2024',
|
|
24
|
-
MdocProof2024 = 'MsoMdocProof2024',
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export interface IParsedDID {
|
|
28
|
-
did: string
|
|
29
|
-
didUrl: string
|
|
30
|
-
method: string
|
|
31
|
-
id: string
|
|
32
|
-
path?: string
|
|
33
|
-
fragment?: string
|
|
34
|
-
query?: string
|
|
35
|
-
params?: {
|
|
36
|
-
[index: string]: string
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
export const parseDid = (did: string): IParsedDID => {
|
|
41
|
-
const parsedDid = parse(did)
|
|
42
|
-
if (parsedDid === null) {
|
|
43
|
-
throw new Error('invalid did')
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
return parsedDid
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
const parse = (didUrl: string): IParsedDID | null => {
|
|
50
|
-
const PCT_ENCODED = '(?:%[0-9a-fA-F]{2})'
|
|
51
|
-
const ID_CHAR = `(?:[a-zA-Z0-9._-]|${PCT_ENCODED})`
|
|
52
|
-
const METHOD = '([a-z0-9]+)'
|
|
53
|
-
const METHOD_ID = `((?:${ID_CHAR}*:)*(${ID_CHAR}+))`
|
|
54
|
-
const PARAM_CHAR = '[a-zA-Z0-9_.:%-]'
|
|
55
|
-
const PARAM = `;${PARAM_CHAR}+=${PARAM_CHAR}*`
|
|
56
|
-
const PARAMS = `((${PARAM})*)`
|
|
57
|
-
const PATH = `(/[^#?]*)?`
|
|
58
|
-
const QUERY = `([?][^#]*)?`
|
|
59
|
-
const FRAGMENT = `(#.*)?`
|
|
60
|
-
const DID_MATCHER = new RegExp(`^did:${METHOD}:${METHOD_ID}${PARAMS}${PATH}${QUERY}${FRAGMENT}$`)
|
|
61
|
-
|
|
62
|
-
if (didUrl === '' || !didUrl) return null
|
|
63
|
-
const sections = didUrl.match(DID_MATCHER)
|
|
64
|
-
if (sections) {
|
|
65
|
-
const parts: IParsedDID = {
|
|
66
|
-
did: `did:${sections[1]}:${sections[2]}`,
|
|
67
|
-
method: sections[1],
|
|
68
|
-
id: sections[2],
|
|
69
|
-
didUrl,
|
|
70
|
-
}
|
|
71
|
-
if (sections[4]) {
|
|
72
|
-
const params = sections[4].slice(1).split(';')
|
|
73
|
-
parts.params = {}
|
|
74
|
-
for (const p of params) {
|
|
75
|
-
const kv = p.split('=')
|
|
76
|
-
parts.params[kv[0]] = kv[1]
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
if (sections[6]) parts.path = sections[6]
|
|
80
|
-
if (sections[7]) parts.query = sections[7].slice(1)
|
|
81
|
-
if (sections[8]) parts.fragment = sections[8].slice(1)
|
|
82
|
-
return parts
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
return null
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
// Copied from did-resolver, so we have types without external dep
|
|
89
|
-
|
|
90
|
-
// Copyright 2018 Consensys AG
|
|
91
|
-
|
|
92
|
-
// Licensed under the Apache License, Version 2.0(the "License");
|
|
93
|
-
// you may not use this file except in compliance with the License.
|
|
94
|
-
// You may obtain a copy of the License at
|
|
95
|
-
|
|
96
|
-
// http://www.apache.org/licenses/LICENSE-2.0
|
|
97
|
-
|
|
98
|
-
// Unless required by applicable law or agreed to in writing, software
|
|
99
|
-
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
100
|
-
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
101
|
-
// See the License for the specific language governing permissions and
|
|
102
|
-
// limitations under the License.
|
|
103
|
-
|
|
104
|
-
/**
|
|
105
|
-
* Defines an object type that can be extended with other properties.
|
|
106
|
-
*/
|
|
107
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
108
|
-
export type Extensible = Record<string, any>
|
|
109
|
-
|
|
110
|
-
/**
|
|
111
|
-
* Defines the result of a DID resolution operation.
|
|
112
|
-
*
|
|
113
|
-
* @see {@link Resolvable.resolve}
|
|
114
|
-
* @see {@link https://www.w3.org/TR/did-core/#did-resolution}
|
|
115
|
-
*/
|
|
116
|
-
export interface DIDResolutionResult {
|
|
117
|
-
'@context'?: 'https://w3id.org/did-resolution/v1' | string | string[]
|
|
118
|
-
didResolutionMetadata: DIDResolutionMetadata
|
|
119
|
-
didDocument: DIDDocument | null
|
|
120
|
-
didDocumentMetadata: DIDDocumentMetadata
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
/**
|
|
124
|
-
* Describes the options forwarded to the resolver when executing a {@link Resolvable.resolve} operation.
|
|
125
|
-
*
|
|
126
|
-
* @see {@link https://www.w3.org/TR/did-core/#did-resolution-options}
|
|
127
|
-
*/
|
|
128
|
-
export interface DIDResolutionOptions extends Extensible {
|
|
129
|
-
accept?: string
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
/**
|
|
133
|
-
* Encapsulates the resolution metadata resulting from a {@link Resolvable.resolve} operation.
|
|
134
|
-
*
|
|
135
|
-
* @see {@link https://www.w3.org/TR/did-core/#did-resolution-metadata}
|
|
136
|
-
*/
|
|
137
|
-
export interface DIDResolutionMetadata extends Extensible {
|
|
138
|
-
contentType?: string
|
|
139
|
-
error?: 'invalidDid' | 'notFound' | 'representationNotSupported' | 'unsupportedDidMethod' | string
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
/**
|
|
143
|
-
* Represents metadata about the DID document resulting from a {@link Resolvable.resolve} operation.
|
|
144
|
-
*
|
|
145
|
-
* @see {@link https://www.w3.org/TR/did-core/#did-document-metadata}
|
|
146
|
-
*/
|
|
147
|
-
export interface DIDDocumentMetadata extends Extensible {
|
|
148
|
-
created?: string
|
|
149
|
-
updated?: string
|
|
150
|
-
deactivated?: boolean
|
|
151
|
-
versionId?: string
|
|
152
|
-
nextUpdate?: string
|
|
153
|
-
nextVersionId?: string
|
|
154
|
-
equivalentId?: string
|
|
155
|
-
canonicalId?: string
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
/**
|
|
159
|
-
* Represents the Verification Relationship between a DID subject and a Verification Method.
|
|
160
|
-
*
|
|
161
|
-
* @see {@link https://www.w3.org/TR/did-core/#verification-relationships}
|
|
162
|
-
*/
|
|
163
|
-
export type KeyCapabilitySection = 'authentication' | 'assertionMethod' | 'keyAgreement' | 'capabilityInvocation' | 'capabilityDelegation'
|
|
164
|
-
|
|
165
|
-
/**
|
|
166
|
-
* Represents a DID document.
|
|
167
|
-
*
|
|
168
|
-
* @see {@link https://www.w3.org/TR/did-core/#did-document-properties}
|
|
169
|
-
*/
|
|
170
|
-
export type DIDDocument = {
|
|
171
|
-
'@context'?: 'https://www.w3.org/ns/did/v1' | string | string[]
|
|
172
|
-
id: string
|
|
173
|
-
alsoKnownAs?: string[]
|
|
174
|
-
controller?: string | string[]
|
|
175
|
-
verificationMethod?: VerificationMethod[]
|
|
176
|
-
service?: Service[]
|
|
177
|
-
/**
|
|
178
|
-
* @deprecated
|
|
179
|
-
*/
|
|
180
|
-
publicKey?: VerificationMethod[]
|
|
181
|
-
} & {
|
|
182
|
-
[x in KeyCapabilitySection]?: (string | VerificationMethod)[]
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
/**
|
|
186
|
-
* Represents a Service entry in a {@link https://www.w3.org/TR/did-core/#did-document-properties | DID document}.
|
|
187
|
-
*
|
|
188
|
-
* @see {@link https://www.w3.org/TR/did-core/#services}
|
|
189
|
-
* @see {@link https://www.w3.org/TR/did-core/#service-properties}
|
|
190
|
-
*/
|
|
191
|
-
export interface Service {
|
|
192
|
-
id: string
|
|
193
|
-
type: string
|
|
194
|
-
serviceEndpoint: ServiceEndpoint | ServiceEndpoint[]
|
|
195
|
-
|
|
196
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
197
|
-
[x: string]: any
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
/**
|
|
201
|
-
* Represents an endpoint of a Service entry in a DID document.
|
|
202
|
-
*
|
|
203
|
-
* @see {@link https://www.w3.org/TR/did-core/#dfn-serviceendpoint}
|
|
204
|
-
* @see {@link https://www.w3.org/TR/did-core/#services}
|
|
205
|
-
*/
|
|
206
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
207
|
-
export type ServiceEndpoint = string | Record<string, any>
|
|
208
|
-
|
|
209
|
-
/**
|
|
210
|
-
* Encapsulates a JSON web key type that includes only the public properties that
|
|
211
|
-
* can be used in DID documents.
|
|
212
|
-
*
|
|
213
|
-
* The private properties are intentionally omitted to discourage the use
|
|
214
|
-
* (and accidental disclosure) of private keys in DID documents.
|
|
215
|
-
*
|
|
216
|
-
* @see {@link https://www.rfc-editor.org/rfc/rfc7517 | RFC7517 JsonWebKey (JWK)}
|
|
217
|
-
*/
|
|
218
|
-
export interface JsonWebKey extends Extensible {
|
|
219
|
-
alg?: string
|
|
220
|
-
crv?: string
|
|
221
|
-
e?: string
|
|
222
|
-
ext?: boolean
|
|
223
|
-
key_ops?: string[]
|
|
224
|
-
kid?: string
|
|
225
|
-
kty: string
|
|
226
|
-
n?: string
|
|
227
|
-
use?: string
|
|
228
|
-
x?: string
|
|
229
|
-
y?: string
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
/**
|
|
233
|
-
* Represents the properties of a Verification Method listed in a DID document.
|
|
234
|
-
*
|
|
235
|
-
* This data type includes public key representations that are no longer present in the spec but are still used by
|
|
236
|
-
* several DID methods / resolvers and kept for backward compatibility.
|
|
237
|
-
*
|
|
238
|
-
* @see {@link https://www.w3.org/TR/did-core/#verification-methods}
|
|
239
|
-
* @see {@link https://www.w3.org/TR/did-core/#verification-method-properties}
|
|
240
|
-
*/
|
|
241
|
-
export interface VerificationMethod {
|
|
242
|
-
id: string
|
|
243
|
-
type: string
|
|
244
|
-
controller: string
|
|
245
|
-
publicKeyBase58?: string
|
|
246
|
-
publicKeyBase64?: string
|
|
247
|
-
publicKeyJwk?: JsonWebKey
|
|
248
|
-
publicKeyHex?: string
|
|
249
|
-
publicKeyMultibase?: string
|
|
250
|
-
blockchainAccountId?: string
|
|
251
|
-
ethereumAddress?: string
|
|
252
|
-
|
|
253
|
-
// ConditionalProof2022 subtypes
|
|
254
|
-
conditionOr?: VerificationMethod[]
|
|
255
|
-
conditionAnd?: VerificationMethod[]
|
|
256
|
-
threshold?: number
|
|
257
|
-
conditionThreshold?: VerificationMethod[]
|
|
258
|
-
conditionWeightedThreshold?: ConditionWeightedThreshold[]
|
|
259
|
-
conditionDelegated?: string
|
|
260
|
-
relationshipParent?: string[]
|
|
261
|
-
relationshipChild?: string[]
|
|
262
|
-
relationshipSibling?: string[]
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
export interface ConditionWeightedThreshold {
|
|
266
|
-
condition: VerificationMethod
|
|
267
|
-
weight: number
|
|
268
|
-
}
|
|
1
|
+
export enum IProofPurpose {
|
|
2
|
+
verificationMethod = 'verificationMethod',
|
|
3
|
+
assertionMethod = 'assertionMethod',
|
|
4
|
+
authentication = 'authentication',
|
|
5
|
+
keyAgreement = 'keyAgreement',
|
|
6
|
+
contractAgreement = 'contactAgreement',
|
|
7
|
+
capabilityInvocation = 'capabilityInvocation',
|
|
8
|
+
capabilityDelegation = 'capabilityDelegation',
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export enum IProofType {
|
|
12
|
+
Ed25519Signature2018 = 'Ed25519Signature2018',
|
|
13
|
+
Ed25519Signature2020 = 'Ed25519Signature2020',
|
|
14
|
+
EcdsaSecp256k1Signature2019 = 'EcdsaSecp256k1Signature2019',
|
|
15
|
+
EcdsaSecp256k1RecoverySignature2020 = 'EcdsaSecp256k1RecoverySignature2020',
|
|
16
|
+
JsonWebSignature2020 = 'JsonWebSignature2020',
|
|
17
|
+
RsaSignature2018 = 'RsaSignature2018',
|
|
18
|
+
GpgSignature2020 = 'GpgSignature2020',
|
|
19
|
+
JcsEd25519Signature2020 = 'JcsEd25519Signature2020',
|
|
20
|
+
BbsBlsSignatureProof2020 = 'BbsBlsSignatureProof2020',
|
|
21
|
+
BbsBlsBoundSignatureProof2020 = 'BbsBlsBoundSignatureProof2020',
|
|
22
|
+
JwtProof2020 = 'JwtProof2020',
|
|
23
|
+
SdJwtProof2024 = 'SdJwtProof2024',
|
|
24
|
+
MdocProof2024 = 'MsoMdocProof2024',
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export interface IParsedDID {
|
|
28
|
+
did: string
|
|
29
|
+
didUrl: string
|
|
30
|
+
method: string
|
|
31
|
+
id: string
|
|
32
|
+
path?: string
|
|
33
|
+
fragment?: string
|
|
34
|
+
query?: string
|
|
35
|
+
params?: {
|
|
36
|
+
[index: string]: string
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export const parseDid = (did: string): IParsedDID => {
|
|
41
|
+
const parsedDid = parse(did)
|
|
42
|
+
if (parsedDid === null) {
|
|
43
|
+
throw new Error('invalid did')
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return parsedDid
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const parse = (didUrl: string): IParsedDID | null => {
|
|
50
|
+
const PCT_ENCODED = '(?:%[0-9a-fA-F]{2})'
|
|
51
|
+
const ID_CHAR = `(?:[a-zA-Z0-9._-]|${PCT_ENCODED})`
|
|
52
|
+
const METHOD = '([a-z0-9]+)'
|
|
53
|
+
const METHOD_ID = `((?:${ID_CHAR}*:)*(${ID_CHAR}+))`
|
|
54
|
+
const PARAM_CHAR = '[a-zA-Z0-9_.:%-]'
|
|
55
|
+
const PARAM = `;${PARAM_CHAR}+=${PARAM_CHAR}*`
|
|
56
|
+
const PARAMS = `((${PARAM})*)`
|
|
57
|
+
const PATH = `(/[^#?]*)?`
|
|
58
|
+
const QUERY = `([?][^#]*)?`
|
|
59
|
+
const FRAGMENT = `(#.*)?`
|
|
60
|
+
const DID_MATCHER = new RegExp(`^did:${METHOD}:${METHOD_ID}${PARAMS}${PATH}${QUERY}${FRAGMENT}$`)
|
|
61
|
+
|
|
62
|
+
if (didUrl === '' || !didUrl) return null
|
|
63
|
+
const sections = didUrl.match(DID_MATCHER)
|
|
64
|
+
if (sections) {
|
|
65
|
+
const parts: IParsedDID = {
|
|
66
|
+
did: `did:${sections[1]}:${sections[2]}`,
|
|
67
|
+
method: sections[1],
|
|
68
|
+
id: sections[2],
|
|
69
|
+
didUrl,
|
|
70
|
+
}
|
|
71
|
+
if (sections[4]) {
|
|
72
|
+
const params = sections[4].slice(1).split(';')
|
|
73
|
+
parts.params = {}
|
|
74
|
+
for (const p of params) {
|
|
75
|
+
const kv = p.split('=')
|
|
76
|
+
parts.params[kv[0]] = kv[1]
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
if (sections[6]) parts.path = sections[6]
|
|
80
|
+
if (sections[7]) parts.query = sections[7].slice(1)
|
|
81
|
+
if (sections[8]) parts.fragment = sections[8].slice(1)
|
|
82
|
+
return parts
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
return null
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// Copied from did-resolver, so we have types without external dep
|
|
89
|
+
|
|
90
|
+
// Copyright 2018 Consensys AG
|
|
91
|
+
|
|
92
|
+
// Licensed under the Apache License, Version 2.0(the "License");
|
|
93
|
+
// you may not use this file except in compliance with the License.
|
|
94
|
+
// You may obtain a copy of the License at
|
|
95
|
+
|
|
96
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
97
|
+
|
|
98
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
99
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
100
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
101
|
+
// See the License for the specific language governing permissions and
|
|
102
|
+
// limitations under the License.
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Defines an object type that can be extended with other properties.
|
|
106
|
+
*/
|
|
107
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
108
|
+
export type Extensible = Record<string, any>
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Defines the result of a DID resolution operation.
|
|
112
|
+
*
|
|
113
|
+
* @see {@link Resolvable.resolve}
|
|
114
|
+
* @see {@link https://www.w3.org/TR/did-core/#did-resolution}
|
|
115
|
+
*/
|
|
116
|
+
export interface DIDResolutionResult {
|
|
117
|
+
'@context'?: 'https://w3id.org/did-resolution/v1' | string | string[]
|
|
118
|
+
didResolutionMetadata: DIDResolutionMetadata
|
|
119
|
+
didDocument: DIDDocument | null
|
|
120
|
+
didDocumentMetadata: DIDDocumentMetadata
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* Describes the options forwarded to the resolver when executing a {@link Resolvable.resolve} operation.
|
|
125
|
+
*
|
|
126
|
+
* @see {@link https://www.w3.org/TR/did-core/#did-resolution-options}
|
|
127
|
+
*/
|
|
128
|
+
export interface DIDResolutionOptions extends Extensible {
|
|
129
|
+
accept?: string
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Encapsulates the resolution metadata resulting from a {@link Resolvable.resolve} operation.
|
|
134
|
+
*
|
|
135
|
+
* @see {@link https://www.w3.org/TR/did-core/#did-resolution-metadata}
|
|
136
|
+
*/
|
|
137
|
+
export interface DIDResolutionMetadata extends Extensible {
|
|
138
|
+
contentType?: string
|
|
139
|
+
error?: 'invalidDid' | 'notFound' | 'representationNotSupported' | 'unsupportedDidMethod' | string
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* Represents metadata about the DID document resulting from a {@link Resolvable.resolve} operation.
|
|
144
|
+
*
|
|
145
|
+
* @see {@link https://www.w3.org/TR/did-core/#did-document-metadata}
|
|
146
|
+
*/
|
|
147
|
+
export interface DIDDocumentMetadata extends Extensible {
|
|
148
|
+
created?: string
|
|
149
|
+
updated?: string
|
|
150
|
+
deactivated?: boolean
|
|
151
|
+
versionId?: string
|
|
152
|
+
nextUpdate?: string
|
|
153
|
+
nextVersionId?: string
|
|
154
|
+
equivalentId?: string
|
|
155
|
+
canonicalId?: string
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* Represents the Verification Relationship between a DID subject and a Verification Method.
|
|
160
|
+
*
|
|
161
|
+
* @see {@link https://www.w3.org/TR/did-core/#verification-relationships}
|
|
162
|
+
*/
|
|
163
|
+
export type KeyCapabilitySection = 'authentication' | 'assertionMethod' | 'keyAgreement' | 'capabilityInvocation' | 'capabilityDelegation'
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* Represents a DID document.
|
|
167
|
+
*
|
|
168
|
+
* @see {@link https://www.w3.org/TR/did-core/#did-document-properties}
|
|
169
|
+
*/
|
|
170
|
+
export type DIDDocument = {
|
|
171
|
+
'@context'?: 'https://www.w3.org/ns/did/v1' | string | string[]
|
|
172
|
+
id: string
|
|
173
|
+
alsoKnownAs?: string[]
|
|
174
|
+
controller?: string | string[]
|
|
175
|
+
verificationMethod?: VerificationMethod[]
|
|
176
|
+
service?: Service[]
|
|
177
|
+
/**
|
|
178
|
+
* @deprecated
|
|
179
|
+
*/
|
|
180
|
+
publicKey?: VerificationMethod[]
|
|
181
|
+
} & {
|
|
182
|
+
[x in KeyCapabilitySection]?: (string | VerificationMethod)[]
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* Represents a Service entry in a {@link https://www.w3.org/TR/did-core/#did-document-properties | DID document}.
|
|
187
|
+
*
|
|
188
|
+
* @see {@link https://www.w3.org/TR/did-core/#services}
|
|
189
|
+
* @see {@link https://www.w3.org/TR/did-core/#service-properties}
|
|
190
|
+
*/
|
|
191
|
+
export interface Service {
|
|
192
|
+
id: string
|
|
193
|
+
type: string
|
|
194
|
+
serviceEndpoint: ServiceEndpoint | ServiceEndpoint[]
|
|
195
|
+
|
|
196
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
197
|
+
[x: string]: any
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* Represents an endpoint of a Service entry in a DID document.
|
|
202
|
+
*
|
|
203
|
+
* @see {@link https://www.w3.org/TR/did-core/#dfn-serviceendpoint}
|
|
204
|
+
* @see {@link https://www.w3.org/TR/did-core/#services}
|
|
205
|
+
*/
|
|
206
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
207
|
+
export type ServiceEndpoint = string | Record<string, any>
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* Encapsulates a JSON web key type that includes only the public properties that
|
|
211
|
+
* can be used in DID documents.
|
|
212
|
+
*
|
|
213
|
+
* The private properties are intentionally omitted to discourage the use
|
|
214
|
+
* (and accidental disclosure) of private keys in DID documents.
|
|
215
|
+
*
|
|
216
|
+
* @see {@link https://www.rfc-editor.org/rfc/rfc7517 | RFC7517 JsonWebKey (JWK)}
|
|
217
|
+
*/
|
|
218
|
+
export interface JsonWebKey extends Extensible {
|
|
219
|
+
alg?: string
|
|
220
|
+
crv?: string
|
|
221
|
+
e?: string
|
|
222
|
+
ext?: boolean
|
|
223
|
+
key_ops?: string[]
|
|
224
|
+
kid?: string
|
|
225
|
+
kty: string
|
|
226
|
+
n?: string
|
|
227
|
+
use?: string
|
|
228
|
+
x?: string
|
|
229
|
+
y?: string
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
/**
|
|
233
|
+
* Represents the properties of a Verification Method listed in a DID document.
|
|
234
|
+
*
|
|
235
|
+
* This data type includes public key representations that are no longer present in the spec but are still used by
|
|
236
|
+
* several DID methods / resolvers and kept for backward compatibility.
|
|
237
|
+
*
|
|
238
|
+
* @see {@link https://www.w3.org/TR/did-core/#verification-methods}
|
|
239
|
+
* @see {@link https://www.w3.org/TR/did-core/#verification-method-properties}
|
|
240
|
+
*/
|
|
241
|
+
export interface VerificationMethod {
|
|
242
|
+
id: string
|
|
243
|
+
type: string
|
|
244
|
+
controller: string
|
|
245
|
+
publicKeyBase58?: string
|
|
246
|
+
publicKeyBase64?: string
|
|
247
|
+
publicKeyJwk?: JsonWebKey
|
|
248
|
+
publicKeyHex?: string
|
|
249
|
+
publicKeyMultibase?: string
|
|
250
|
+
blockchainAccountId?: string
|
|
251
|
+
ethereumAddress?: string
|
|
252
|
+
|
|
253
|
+
// ConditionalProof2022 subtypes
|
|
254
|
+
conditionOr?: VerificationMethod[]
|
|
255
|
+
conditionAnd?: VerificationMethod[]
|
|
256
|
+
threshold?: number
|
|
257
|
+
conditionThreshold?: VerificationMethod[]
|
|
258
|
+
conditionWeightedThreshold?: ConditionWeightedThreshold[]
|
|
259
|
+
conditionDelegated?: string
|
|
260
|
+
relationshipParent?: string[]
|
|
261
|
+
relationshipChild?: string[]
|
|
262
|
+
relationshipSibling?: string[]
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
export interface ConditionWeightedThreshold {
|
|
266
|
+
condition: VerificationMethod
|
|
267
|
+
weight: number
|
|
268
|
+
}
|
package/src/types/generic.ts
CHANGED
|
@@ -1,48 +1,48 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Accept a Type or a Promise of that Type.
|
|
3
|
-
*
|
|
4
|
-
* @internal
|
|
5
|
-
*/
|
|
6
|
-
export type OrPromise<T> = T | Promise<T>
|
|
7
|
-
export type Optional<T, K extends keyof T> = Pick<Partial<T>, K> & Omit<T, K>
|
|
8
|
-
|
|
9
|
-
export type BearerTokenArg = (() => Promise<string>) | string
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Generic structure used for validations. For instance for X509 and JWs signature checks. Allows us to create multilevel structures for complex validations
|
|
13
|
-
*/
|
|
14
|
-
export type IValidationResult = {
|
|
15
|
-
/**
|
|
16
|
-
* The name of the validation or its subsystem. Mainly used for information purposes. Not assumed to be unique
|
|
17
|
-
*/
|
|
18
|
-
name: string
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Whether the validation was successful or not
|
|
22
|
-
*/
|
|
23
|
-
error: boolean
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Whether an error can be ignored or not (up to processing logic)
|
|
27
|
-
*/
|
|
28
|
-
critical: boolean
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* Any status/info message about the validation
|
|
32
|
-
*/
|
|
33
|
-
message: string
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* The date and time of the validation
|
|
37
|
-
*/
|
|
38
|
-
verificationTime: Date
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
export type IValidationResults = {
|
|
42
|
-
/**
|
|
43
|
-
* Global derived error state for easy access
|
|
44
|
-
*/
|
|
45
|
-
error: boolean
|
|
46
|
-
|
|
47
|
-
verifications: Array<IValidationResult>
|
|
48
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* Accept a Type or a Promise of that Type.
|
|
3
|
+
*
|
|
4
|
+
* @internal
|
|
5
|
+
*/
|
|
6
|
+
export type OrPromise<T> = T | Promise<T>
|
|
7
|
+
export type Optional<T, K extends keyof T> = Pick<Partial<T>, K> & Omit<T, K>
|
|
8
|
+
|
|
9
|
+
export type BearerTokenArg = (() => Promise<string>) | string
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Generic structure used for validations. For instance for X509 and JWs signature checks. Allows us to create multilevel structures for complex validations
|
|
13
|
+
*/
|
|
14
|
+
export type IValidationResult = {
|
|
15
|
+
/**
|
|
16
|
+
* The name of the validation or its subsystem. Mainly used for information purposes. Not assumed to be unique
|
|
17
|
+
*/
|
|
18
|
+
name: string
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Whether the validation was successful or not
|
|
22
|
+
*/
|
|
23
|
+
error: boolean
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Whether an error can be ignored or not (up to processing logic)
|
|
27
|
+
*/
|
|
28
|
+
critical: boolean
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Any status/info message about the validation
|
|
32
|
+
*/
|
|
33
|
+
message: string
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* The date and time of the validation
|
|
37
|
+
*/
|
|
38
|
+
verificationTime: Date
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export type IValidationResults = {
|
|
42
|
+
/**
|
|
43
|
+
* Global derived error state for easy access
|
|
44
|
+
*/
|
|
45
|
+
error: boolean
|
|
46
|
+
|
|
47
|
+
verifications: Array<IValidationResult>
|
|
48
|
+
}
|
package/src/types/index.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
export * from './did'
|
|
2
|
-
export * from './pex'
|
|
3
|
-
export * from './vc'
|
|
4
|
-
export * from './generic'
|
|
5
|
-
export * from './sd-jwt-vc'
|
|
6
|
-
export * from './w3c-vc'
|
|
7
|
-
export * from './jose'
|
|
8
|
-
export * from './cose'
|
|
9
|
-
export * from './mso_mdoc'
|
|
1
|
+
export * from './did'
|
|
2
|
+
export * from './pex'
|
|
3
|
+
export * from './vc'
|
|
4
|
+
export * from './generic'
|
|
5
|
+
export * from './sd-jwt-vc'
|
|
6
|
+
export * from './w3c-vc'
|
|
7
|
+
export * from './jose'
|
|
8
|
+
export * from './cose'
|
|
9
|
+
export * from './mso_mdoc'
|