@sphereon/ssi-sdk-ext.identifier-resolution 0.28.1-feature.jose.vcdm.52 → 0.28.1-feature.oyd.cmsm.improv.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agent/IdentifierResolution.d.ts +38 -0
- package/dist/agent/IdentifierResolution.d.ts.map +1 -0
- package/dist/agent/IdentifierResolution.js +123 -0
- package/dist/agent/IdentifierResolution.js.map +1 -0
- package/dist/functions/LegacySupport.d.ts +12 -0
- package/dist/functions/LegacySupport.d.ts.map +1 -0
- package/dist/functions/LegacySupport.js +39 -0
- package/dist/functions/LegacySupport.js.map +1 -0
- package/dist/functions/externalIdentifierFunctions.d.ts +26 -0
- package/dist/functions/externalIdentifierFunctions.d.ts.map +1 -0
- package/dist/functions/externalIdentifierFunctions.js +250 -0
- package/dist/functions/externalIdentifierFunctions.js.map +1 -0
- package/dist/functions/externalOIDFIdentifier.d.ts +19 -0
- package/dist/functions/externalOIDFIdentifier.d.ts.map +1 -0
- package/dist/functions/externalOIDFIdentifier.js +106 -0
- package/dist/functions/externalOIDFIdentifier.js.map +1 -0
- package/dist/functions/index.d.ts +5 -0
- package/dist/functions/index.d.ts.map +1 -0
- package/dist/functions/index.js +21 -0
- package/dist/functions/index.js.map +1 -0
- package/dist/functions/managedIdentifierFunctions.d.ts +38 -0
- package/dist/functions/managedIdentifierFunctions.d.ts.map +1 -0
- package/dist/functions/managedIdentifierFunctions.js +359 -0
- package/dist/functions/managedIdentifierFunctions.js.map +1 -0
- package/dist/index.d.ts +7 -434
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +27 -12047
- package/dist/index.js.map +1 -1
- package/dist/types/IIdentifierResolution.d.ts +42 -0
- package/dist/types/IIdentifierResolution.d.ts.map +1 -0
- package/dist/types/IIdentifierResolution.js +21 -0
- package/dist/types/IIdentifierResolution.js.map +1 -0
- package/dist/types/common.d.ts +20 -0
- package/dist/types/common.d.ts.map +1 -0
- package/dist/types/common.js +51 -0
- package/dist/types/common.js.map +1 -0
- package/dist/types/externalIdentifierTypes.d.ts +114 -0
- package/dist/types/externalIdentifierTypes.d.ts.map +1 -0
- package/dist/types/externalIdentifierTypes.js +44 -0
- package/dist/types/externalIdentifierTypes.js.map +1 -0
- package/dist/types/index.d.ts +5 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +21 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/managedIdentifierTypes.d.ts +122 -0
- package/dist/types/managedIdentifierTypes.d.ts.map +1 -0
- package/dist/types/managedIdentifierTypes.js +63 -0
- package/dist/types/managedIdentifierTypes.js.map +1 -0
- package/package.json +21 -34
- package/plugin.schema.json +1368 -8006
- package/src/agent/IdentifierResolution.ts +39 -40
- package/src/functions/LegacySupport.ts +2 -2
- package/src/functions/externalIdentifierFunctions.ts +18 -27
- package/src/functions/externalOIDFIdentifier.ts +7 -9
- package/src/functions/managedIdentifierFunctions.ts +19 -25
- package/src/index.ts +1 -1
- package/src/types/IIdentifierResolution.ts +4 -4
- package/src/types/IJwtService.d.ts +5 -6
- package/src/types/common.ts +4 -4
- package/src/types/externalIdentifierTypes.ts +7 -7
- package/src/types/managedIdentifierTypes.ts +4 -4
- package/dist/index.cjs +0 -12080
- package/dist/index.cjs.map +0 -1
- package/dist/index.d.cts +0 -439
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { globalCrypto } from '@sphereon/ssi-sdk-ext.key-utils'
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import { schema } from '
|
|
2
|
+
import { IAgentContext, IAgentPlugin, IDIDManager, IKeyManager } from '@veramo/core'
|
|
3
|
+
import { ExternalIdentifierOIDFEntityIdOpts, ExternalIdentifierOIDFEntityIdResult } from '../types'
|
|
4
|
+
import { schema } from '..'
|
|
5
5
|
import { resolveExternalIdentifier, ensureManagedIdentifierResult } from '../functions'
|
|
6
|
-
import
|
|
6
|
+
import {
|
|
7
7
|
ExternalIdentifierDidOpts,
|
|
8
8
|
ExternalIdentifierDidResult,
|
|
9
9
|
ExternalIdentifierOpts,
|
|
@@ -32,28 +32,26 @@ import type {
|
|
|
32
32
|
ManagedIdentifierOptsOrResult,
|
|
33
33
|
ManagedIdentifierOID4VCIssuerOpts,
|
|
34
34
|
} from '../types'
|
|
35
|
-
import
|
|
36
|
-
|
|
37
|
-
import { webcrypto } from 'node:crypto'
|
|
35
|
+
import { IOIDFClient } from '@sphereon/ssi-sdk.oidf-client'
|
|
38
36
|
|
|
39
37
|
/**
|
|
40
38
|
* @public
|
|
41
39
|
*/
|
|
42
40
|
export class IdentifierResolution implements IAgentPlugin {
|
|
43
|
-
readonly _crypto:
|
|
41
|
+
private readonly _crypto: Crypto
|
|
44
42
|
|
|
45
43
|
readonly schema = schema.IMnemonicInfoGenerator
|
|
46
44
|
readonly methods: IIdentifierResolution = {
|
|
47
|
-
identifierManagedGet: this.
|
|
48
|
-
identifierManagedGetByDid: this.
|
|
49
|
-
identifierManagedGetByKid: this.
|
|
50
|
-
identifierManagedGetByJwk: this.
|
|
51
|
-
identifierManagedGetByX5c: this.
|
|
52
|
-
identifierManagedGetByKey: this.
|
|
53
|
-
identifierManagedGetByCoseKey: this.
|
|
54
|
-
identifierManagedGetByOID4VCIssuer: this.
|
|
55
|
-
|
|
56
|
-
identifierExternalResolve: this.
|
|
45
|
+
identifierManagedGet: this.identifierGetManaged.bind(this),
|
|
46
|
+
identifierManagedGetByDid: this.identifierGetManagedByDid.bind(this),
|
|
47
|
+
identifierManagedGetByKid: this.identifierGetManagedByKid.bind(this),
|
|
48
|
+
identifierManagedGetByJwk: this.identifierGetManagedByJwk.bind(this),
|
|
49
|
+
identifierManagedGetByX5c: this.identifierGetManagedByX5c.bind(this),
|
|
50
|
+
identifierManagedGetByKey: this.identifierGetManagedByKey.bind(this),
|
|
51
|
+
identifierManagedGetByCoseKey: this.identifierGetManagedByCoseKey.bind(this),
|
|
52
|
+
identifierManagedGetByOID4VCIssuer: this.identifierGetManagedByOID4VCIssuer.bind(this),
|
|
53
|
+
|
|
54
|
+
identifierExternalResolve: this.identifierResolveExternal.bind(this),
|
|
57
55
|
identifierExternalResolveByDid: this.identifierExternalResolveByDid.bind(this),
|
|
58
56
|
identifierExternalResolveByX5c: this.identifierExternalResolveByX5c.bind(this),
|
|
59
57
|
identifierExternalResolveByJwk: this.identifierExternalResolveByJwk.bind(this),
|
|
@@ -66,7 +64,7 @@ export class IdentifierResolution implements IAgentPlugin {
|
|
|
66
64
|
/**
|
|
67
65
|
* TODO: Add a cache, as we are retrieving the same keys/info quite often
|
|
68
66
|
*/
|
|
69
|
-
constructor(opts?: { crypto?:
|
|
67
|
+
constructor(opts?: { crypto?: Crypto }) {
|
|
70
68
|
this._crypto = globalCrypto(false, opts?.crypto)
|
|
71
69
|
}
|
|
72
70
|
|
|
@@ -75,64 +73,65 @@ export class IdentifierResolution implements IAgentPlugin {
|
|
|
75
73
|
* integrate a plugin for anomaly detection. Having a single method helps
|
|
76
74
|
* @param args
|
|
77
75
|
* @param context
|
|
76
|
+
* @private
|
|
78
77
|
*/
|
|
79
|
-
private async
|
|
78
|
+
private async identifierGetManaged(
|
|
80
79
|
args: ManagedIdentifierOptsOrResult,
|
|
81
80
|
context: IAgentContext<IKeyManager & IIdentifierResolution>
|
|
82
81
|
): Promise<ManagedIdentifierResult> {
|
|
83
82
|
return await ensureManagedIdentifierResult({ ...args, crypto: this._crypto }, context)
|
|
84
83
|
}
|
|
85
84
|
|
|
86
|
-
private async
|
|
85
|
+
private async identifierGetManagedByDid(
|
|
87
86
|
args: ManagedIdentifierDidOpts,
|
|
88
87
|
context: IAgentContext<IKeyManager & IDIDManager & IIdentifierResolution>
|
|
89
88
|
): Promise<ManagedIdentifierDidResult> {
|
|
90
|
-
return (await this.
|
|
89
|
+
return (await this.identifierGetManaged({ ...args, method: 'did' }, context)) as ManagedIdentifierDidResult
|
|
91
90
|
}
|
|
92
91
|
|
|
93
|
-
private async
|
|
92
|
+
private async identifierGetManagedByKid(
|
|
94
93
|
args: ManagedIdentifierKidOpts,
|
|
95
94
|
context: IAgentContext<IKeyManager & IIdentifierResolution>
|
|
96
95
|
): Promise<ManagedIdentifierKidResult> {
|
|
97
|
-
return (await this.
|
|
96
|
+
return (await this.identifierGetManaged({ ...args, method: 'kid' }, context)) as ManagedIdentifierKidResult
|
|
98
97
|
}
|
|
99
98
|
|
|
100
|
-
private async
|
|
99
|
+
private async identifierGetManagedByKey(
|
|
101
100
|
args: ManagedIdentifierKeyOpts,
|
|
102
101
|
context: IAgentContext<IKeyManager & IIdentifierResolution>
|
|
103
102
|
): Promise<ManagedIdentifierKeyResult> {
|
|
104
|
-
return (await this.
|
|
103
|
+
return (await this.identifierGetManaged({ ...args, method: 'key' }, context)) as ManagedIdentifierKeyResult
|
|
105
104
|
}
|
|
106
105
|
|
|
107
|
-
private async
|
|
106
|
+
private async identifierGetManagedByCoseKey(
|
|
108
107
|
args: ManagedIdentifierCoseKeyOpts,
|
|
109
108
|
context: IAgentContext<IKeyManager & IIdentifierResolution>
|
|
110
109
|
): Promise<ManagedIdentifierCoseKeyResult> {
|
|
111
|
-
return (await this.
|
|
110
|
+
return (await this.identifierGetManaged({ ...args, method: 'cose_key' }, context)) as ManagedIdentifierCoseKeyResult
|
|
112
111
|
}
|
|
113
112
|
|
|
114
|
-
private async
|
|
113
|
+
private async identifierGetManagedByOID4VCIssuer(
|
|
115
114
|
args: ManagedIdentifierOID4VCIssuerOpts,
|
|
116
115
|
context: IAgentContext<IKeyManager & IIdentifierResolution>
|
|
117
116
|
): Promise<ManagedIdentifierOID4VCIssuerResult> {
|
|
118
|
-
return (await this.
|
|
117
|
+
return (await this.identifierGetManaged({ ...args, method: 'oid4vci-issuer' }, context)) as ManagedIdentifierOID4VCIssuerResult
|
|
119
118
|
}
|
|
120
119
|
|
|
121
|
-
private async
|
|
120
|
+
private async identifierGetManagedByJwk(
|
|
122
121
|
args: ManagedIdentifierJwkOpts,
|
|
123
122
|
context: IAgentContext<IKeyManager & IIdentifierResolution>
|
|
124
123
|
): Promise<ManagedIdentifierJwkResult> {
|
|
125
|
-
return (await this.
|
|
124
|
+
return (await this.identifierGetManaged({ ...args, method: 'jwk' }, context)) as ManagedIdentifierJwkResult
|
|
126
125
|
}
|
|
127
126
|
|
|
128
|
-
private async
|
|
127
|
+
private async identifierGetManagedByX5c(
|
|
129
128
|
args: ManagedIdentifierX5cOpts,
|
|
130
129
|
context: IAgentContext<IKeyManager & IIdentifierResolution>
|
|
131
130
|
): Promise<ManagedIdentifierX5cResult> {
|
|
132
|
-
return (await this.
|
|
131
|
+
return (await this.identifierGetManaged({ ...args, method: 'x5c' }, context)) as ManagedIdentifierX5cResult
|
|
133
132
|
}
|
|
134
133
|
|
|
135
|
-
private async
|
|
134
|
+
private async identifierResolveExternal(
|
|
136
135
|
args: ExternalIdentifierOpts,
|
|
137
136
|
context: IAgentContext<IKeyManager | IOIDFClient>
|
|
138
137
|
): Promise<ExternalIdentifierResult> {
|
|
@@ -140,28 +139,28 @@ export class IdentifierResolution implements IAgentPlugin {
|
|
|
140
139
|
}
|
|
141
140
|
|
|
142
141
|
private async identifierExternalResolveByDid(args: ExternalIdentifierDidOpts, context: IAgentContext<any>): Promise<ExternalIdentifierDidResult> {
|
|
143
|
-
return (await this.
|
|
142
|
+
return (await this.identifierResolveExternal({ ...args, method: 'did' }, context)) as ExternalIdentifierDidResult
|
|
144
143
|
}
|
|
145
144
|
|
|
146
145
|
private async identifierExternalResolveByX5c(args: ExternalIdentifierX5cOpts, context: IAgentContext<any>): Promise<ExternalIdentifierX5cResult> {
|
|
147
|
-
return (await this.
|
|
146
|
+
return (await this.identifierResolveExternal({ ...args, method: 'x5c' }, context)) as ExternalIdentifierX5cResult
|
|
148
147
|
}
|
|
149
148
|
|
|
150
149
|
private async identifierExternalResolveByCoseKey(
|
|
151
150
|
args: ExternalIdentifierCoseKeyOpts,
|
|
152
151
|
context: IAgentContext<any>
|
|
153
152
|
): Promise<ExternalIdentifierCoseKeyResult> {
|
|
154
|
-
return (await this.
|
|
153
|
+
return (await this.identifierResolveExternal({ ...args, method: 'cose_key' }, context)) as ExternalIdentifierCoseKeyResult
|
|
155
154
|
}
|
|
156
155
|
|
|
157
156
|
private async identifierExternalResolveByJwk(args: ExternalIdentifierJwkOpts, context: IAgentContext<any>): Promise<ExternalIdentifierJwkResult> {
|
|
158
|
-
return (await this.
|
|
157
|
+
return (await this.identifierResolveExternal({ ...args, method: 'jwk' }, context)) as ExternalIdentifierJwkResult
|
|
159
158
|
}
|
|
160
159
|
|
|
161
160
|
private async identifierExternalResolveByOIDFEntityId(
|
|
162
161
|
args: ExternalIdentifierOIDFEntityIdOpts,
|
|
163
162
|
context: IAgentContext<any>
|
|
164
163
|
): Promise<ExternalIdentifierOIDFEntityIdResult> {
|
|
165
|
-
return (await this.
|
|
164
|
+
return (await this.identifierResolveExternal({ ...args, method: 'entity_id' }, context)) as ExternalIdentifierOIDFEntityIdResult
|
|
166
165
|
}
|
|
167
166
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import { IIdentifier } from '@veramo/core'
|
|
2
|
+
import { ManagedIdentifierDidOpts, ManagedIdentifierOptsOrResult } from '../types'
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Converts legacy id opts key refs to the new ManagedIdentifierOpts
|
|
@@ -5,14 +5,14 @@ import {
|
|
|
5
5
|
pemOrDerToX509Certificate,
|
|
6
6
|
PEMToDer,
|
|
7
7
|
validateX509CertificateChain,
|
|
8
|
-
|
|
8
|
+
X509ValidationResult,
|
|
9
9
|
} from '@sphereon/ssi-sdk-ext.x509-utils'
|
|
10
10
|
import { contextHasPlugin } from '@sphereon/ssi-sdk.agent-config'
|
|
11
|
-
import {
|
|
12
|
-
import
|
|
11
|
+
import { IParsedDID, JWK, parseDid } from '@sphereon/ssi-types'
|
|
12
|
+
import { IAgentContext, IDIDManager, IResolver } from '@veramo/core'
|
|
13
13
|
import { isDefined } from '@veramo/utils'
|
|
14
14
|
import { CryptoEngine, setEngine } from 'pkijs'
|
|
15
|
-
import
|
|
15
|
+
import {
|
|
16
16
|
ExternalIdentifierCoseKeyOpts,
|
|
17
17
|
ExternalIdentifierCoseKeyResult,
|
|
18
18
|
ExternalIdentifierDidOpts,
|
|
@@ -25,8 +25,6 @@ import type {
|
|
|
25
25
|
ExternalIdentifierX5cOpts,
|
|
26
26
|
ExternalIdentifierX5cResult,
|
|
27
27
|
ExternalJwkInfo,
|
|
28
|
-
} from '../types'
|
|
29
|
-
import {
|
|
30
28
|
isExternalIdentifierCoseKeyOpts,
|
|
31
29
|
isExternalIdentifierDidOpts,
|
|
32
30
|
isExternalIdentifierJwkOpts,
|
|
@@ -38,10 +36,9 @@ import {
|
|
|
38
36
|
} from '../types'
|
|
39
37
|
import { resolveExternalOIDFEntityIdIdentifier } from '.'
|
|
40
38
|
|
|
41
|
-
import { webcrypto } from 'node:crypto'
|
|
42
39
|
export async function resolveExternalIdentifier(
|
|
43
40
|
opts: ExternalIdentifierOpts & {
|
|
44
|
-
crypto?:
|
|
41
|
+
crypto?: Crypto
|
|
45
42
|
},
|
|
46
43
|
context: IAgentContext<any>
|
|
47
44
|
): Promise<ExternalIdentifierResult> {
|
|
@@ -68,7 +65,7 @@ export async function resolveExternalIdentifier(
|
|
|
68
65
|
|
|
69
66
|
export async function resolveExternalX5cIdentifier(
|
|
70
67
|
opts: ExternalIdentifierX5cOpts & {
|
|
71
|
-
crypto?:
|
|
68
|
+
crypto?: Crypto
|
|
72
69
|
},
|
|
73
70
|
context: IAgentContext<IResolver & IDIDManager>
|
|
74
71
|
): Promise<ExternalIdentifierX5cResult> {
|
|
@@ -248,24 +245,18 @@ export async function resolveExternalDidIdentifier(
|
|
|
248
245
|
const didDocument = didResolutionResult.didDocument ?? undefined
|
|
249
246
|
const didJwks = didDocument ? didDocumentToJwks(didDocument) : undefined
|
|
250
247
|
const jwks = didJwks
|
|
251
|
-
? Array.from(
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
publicKeyHex: jwkTtoPublicKeyHex(jwk),
|
|
264
|
-
}
|
|
265
|
-
})
|
|
266
|
-
.map((jwk) => JSON.stringify(jwk))
|
|
267
|
-
)
|
|
268
|
-
).map((jwks) => JSON.parse(jwks))
|
|
248
|
+
? Array.from(new Set(Array.from(
|
|
249
|
+
Object.values(didJwks)
|
|
250
|
+
.filter((jwks) => isDefined(jwks) && jwks.length > 0)
|
|
251
|
+
.flatMap((jwks) => jwks)
|
|
252
|
+
).flatMap((jwk) => {
|
|
253
|
+
return {
|
|
254
|
+
jwk,
|
|
255
|
+
jwkThumbprint: calculateJwkThumbprint({ jwk }),
|
|
256
|
+
kid: jwk.kid,
|
|
257
|
+
publicKeyHex: jwkTtoPublicKeyHex(jwk),
|
|
258
|
+
}
|
|
259
|
+
}).map(jwk => JSON.stringify(jwk)))).map((jwks) => JSON.parse(jwks))
|
|
269
260
|
: []
|
|
270
261
|
|
|
271
262
|
if (didResolutionResult?.didDocument) {
|
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import { ErrorMessage, ExternalIdentifierOIDFEntityIdOpts, ExternalIdentifierOIDFEntityIdResult, ExternalJwkInfo, TrustedAnchor } from '../types'
|
|
2
|
+
import { IAgentContext } from '@veramo/core'
|
|
3
|
+
import { IOIDFClient } from '@sphereon/ssi-sdk.oidf-client'
|
|
4
4
|
import { contextHasPlugin } from '@sphereon/ssi-sdk.agent-config'
|
|
5
|
-
import
|
|
6
|
-
// @ts-ignore
|
|
5
|
+
import {IJwsValidationResult, JwsPayload} from '../types/IJwtService'
|
|
7
6
|
import * as u8a from 'uint8arrays'
|
|
8
|
-
const { fromString, toString } = u8a
|
|
9
7
|
/**
|
|
10
8
|
* Resolves an OIDF Entity ID against multiple trust anchors to establish trusted relationships
|
|
11
9
|
*
|
|
@@ -45,10 +43,10 @@ export async function resolveExternalOIDFEntityIdIdentifier(
|
|
|
45
43
|
trustAnchors: [trustAnchor],
|
|
46
44
|
})
|
|
47
45
|
|
|
48
|
-
if (resolveResult.
|
|
46
|
+
if (resolveResult.error || !resolveResult.trustChain) {
|
|
49
47
|
errorList[trustAnchor] = resolveResult.errorMessage ?? 'unspecified'
|
|
50
48
|
} else {
|
|
51
|
-
const trustChain = resolveResult.trustChain
|
|
49
|
+
const trustChain: ReadonlyArray<string> = resolveResult.trustChain.asJsReadonlyArrayView()
|
|
52
50
|
if (trustChain.length === 0) {
|
|
53
51
|
errorList[trustAnchor] = 'Trust chain is empty'
|
|
54
52
|
continue
|
|
@@ -67,7 +65,7 @@ export async function resolveExternalOIDFEntityIdIdentifier(
|
|
|
67
65
|
continue
|
|
68
66
|
}
|
|
69
67
|
|
|
70
|
-
payload = JSON.parse(toString(fromString(jwtVerifyResult.jws.payload, 'base64url')))
|
|
68
|
+
payload = JSON.parse(u8a.toString(u8a.fromString(jwtVerifyResult.jws.payload, 'base64url')))
|
|
71
69
|
const signature = jwtVerifyResult.jws.signatures[0]
|
|
72
70
|
if (signature.identifier.jwks.length === 0) {
|
|
73
71
|
errorList[trustAnchor] = 'No JWK was present in the trust anchor signature'
|
|
@@ -2,12 +2,21 @@ import { getFirstKeyWithRelation } from '@sphereon/ssi-sdk-ext.did-utils'
|
|
|
2
2
|
import { calculateJwkThumbprint, coseKeyToJwk, globalCrypto, toJwk } from '@sphereon/ssi-sdk-ext.key-utils'
|
|
3
3
|
import { pemOrDerToX509Certificate } from '@sphereon/ssi-sdk-ext.x509-utils'
|
|
4
4
|
import { contextHasDidManager, contextHasKeyManager } from '@sphereon/ssi-sdk.agent-config'
|
|
5
|
-
import
|
|
6
|
-
import
|
|
5
|
+
import { ICoseKeyJson, JWK } from '@sphereon/ssi-types'
|
|
6
|
+
import { IAgentContext, IIdentifier, IKey, IKeyManager } from '@veramo/core'
|
|
7
7
|
import { CryptoEngine, setEngine } from 'pkijs'
|
|
8
|
-
import {
|
|
9
|
-
import type {
|
|
8
|
+
import {
|
|
10
9
|
IIdentifierResolution,
|
|
10
|
+
isManagedIdentifierCoseKeyOpts,
|
|
11
|
+
isManagedIdentifierDidOpts,
|
|
12
|
+
isManagedIdentifierDidResult,
|
|
13
|
+
isManagedIdentifierOID4VCIssuerOpts,
|
|
14
|
+
isManagedIdentifierJwkOpts,
|
|
15
|
+
isManagedIdentifierJwkResult,
|
|
16
|
+
isManagedIdentifierKeyOpts,
|
|
17
|
+
isManagedIdentifierKeyResult,
|
|
18
|
+
isManagedIdentifierKidOpts,
|
|
19
|
+
isManagedIdentifierX5cOpts,
|
|
11
20
|
ManagedIdentifierCoseKeyOpts,
|
|
12
21
|
ManagedIdentifierCoseKeyResult,
|
|
13
22
|
ManagedIdentifierDidOpts,
|
|
@@ -26,19 +35,6 @@ import type {
|
|
|
26
35
|
ManagedIdentifierX5cResult,
|
|
27
36
|
} from '../types'
|
|
28
37
|
|
|
29
|
-
import {
|
|
30
|
-
isManagedIdentifierCoseKeyOpts,
|
|
31
|
-
isManagedIdentifierDidOpts,
|
|
32
|
-
isManagedIdentifierDidResult,
|
|
33
|
-
isManagedIdentifierOID4VCIssuerOpts,
|
|
34
|
-
isManagedIdentifierJwkOpts,
|
|
35
|
-
isManagedIdentifierJwkResult,
|
|
36
|
-
isManagedIdentifierKeyOpts,
|
|
37
|
-
isManagedIdentifierKeyResult,
|
|
38
|
-
isManagedIdentifierKidOpts,
|
|
39
|
-
isManagedIdentifierX5cOpts,
|
|
40
|
-
} from '../types'
|
|
41
|
-
|
|
42
38
|
export async function getManagedKidIdentifier(
|
|
43
39
|
opts: ManagedIdentifierKidOpts,
|
|
44
40
|
context: IAgentContext<IKeyManager>
|
|
@@ -51,13 +47,13 @@ export async function getManagedKidIdentifier(
|
|
|
51
47
|
return Promise.reject(Error(`Cannot get Key/JWK identifier if KeyManager plugin is not enabled!`))
|
|
52
48
|
} else if (opts.identifier.startsWith('did:')) {
|
|
53
49
|
const did = opts.identifier.split('#')[0]
|
|
54
|
-
const didIdentifier = await getManagedDidIdentifier({
|
|
50
|
+
const didIdentifier = await getManagedDidIdentifier({...opts, method: 'did', identifier: did}, context)
|
|
55
51
|
key = didIdentifier.key
|
|
56
52
|
issuer = didIdentifier.issuer
|
|
57
53
|
kid = opts?.kid ?? (key.meta?.verificationMethod?.id as string) ?? didIdentifier.kid
|
|
58
54
|
}
|
|
59
55
|
if (!key) {
|
|
60
|
-
key = await context.agent.keyManagerGet({
|
|
56
|
+
key = await context.agent.keyManagerGet({kid: opts.kmsKeyRef ?? opts.identifier})
|
|
61
57
|
}
|
|
62
58
|
const jwk = toJwk(key.publicKeyHex, key.type, { key })
|
|
63
59
|
const jwkThumbprint = (key.meta?.jwkThumbprint as string) ?? calculateJwkThumbprint({ jwk })
|
|
@@ -84,7 +80,7 @@ export async function getManagedKidIdentifier(
|
|
|
84
80
|
|
|
85
81
|
export function isManagedIdentifierResult(
|
|
86
82
|
identifier: ManagedIdentifierOptsOrResult & {
|
|
87
|
-
crypto?:
|
|
83
|
+
crypto?: Crypto
|
|
88
84
|
}
|
|
89
85
|
): identifier is ManagedIdentifierResult {
|
|
90
86
|
return 'key' in identifier && 'kmsKeyRef' in identifier && 'method' in identifier && 'opts' in identifier && 'jwkThumbprint' in identifier
|
|
@@ -97,7 +93,7 @@ export function isManagedIdentifierResult(
|
|
|
97
93
|
*/
|
|
98
94
|
export async function ensureManagedIdentifierResult(
|
|
99
95
|
identifier: ManagedIdentifierOptsOrResult & {
|
|
100
|
-
crypto?:
|
|
96
|
+
crypto?: Crypto
|
|
101
97
|
},
|
|
102
98
|
context: IAgentContext<IKeyManager>
|
|
103
99
|
): Promise<ManagedIdentifierResult> {
|
|
@@ -187,8 +183,6 @@ export async function getManagedDidIdentifier(opts: ManagedIdentifierDidOpts, co
|
|
|
187
183
|
const extendedKey = await getFirstKeyWithRelation(
|
|
188
184
|
{
|
|
189
185
|
...opts,
|
|
190
|
-
// Make sure we use offline mode if no pref was supplied. We are looking for managed DIDs after all. Could be it is not published yet
|
|
191
|
-
offlineWhenNoDIDRegistered: opts.offlineWhenNoDIDRegistered ?? true,
|
|
192
186
|
identifier,
|
|
193
187
|
vmRelationship: opts.vmRelationship ?? 'verificationMethod',
|
|
194
188
|
},
|
|
@@ -253,7 +247,7 @@ export async function getManagedJwkIdentifier(
|
|
|
253
247
|
|
|
254
248
|
export async function getManagedX5cIdentifier(
|
|
255
249
|
opts: ManagedIdentifierX5cOpts & {
|
|
256
|
-
crypto?:
|
|
250
|
+
crypto?: Crypto
|
|
257
251
|
},
|
|
258
252
|
context: IAgentContext<IKeyManager>
|
|
259
253
|
): Promise<ManagedIdentifierX5cResult> {
|
|
@@ -337,7 +331,7 @@ export async function getManagedOID4VCIssuerIdentifier(
|
|
|
337
331
|
|
|
338
332
|
export async function getManagedIdentifier(
|
|
339
333
|
opts: ManagedIdentifierOptsOrResult & {
|
|
340
|
-
crypto?:
|
|
334
|
+
crypto?: Crypto
|
|
341
335
|
},
|
|
342
336
|
context: IAgentContext<IKeyManager>
|
|
343
337
|
): Promise<ManagedIdentifierResult> {
|
package/src/index.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import { IAgentContext, IDIDManager, IKeyManager, IPluginMethodMap } from '@veramo/core'
|
|
2
|
+
import {
|
|
3
3
|
ExternalIdentifierCoseKeyOpts,
|
|
4
4
|
ExternalIdentifierCoseKeyResult,
|
|
5
5
|
ExternalIdentifierDidOpts,
|
|
@@ -13,7 +13,7 @@ import type {
|
|
|
13
13
|
ExternalIdentifierX5cOpts,
|
|
14
14
|
ExternalIdentifierX5cResult,
|
|
15
15
|
} from './externalIdentifierTypes'
|
|
16
|
-
import
|
|
16
|
+
import {
|
|
17
17
|
ManagedIdentifierCoseKeyOpts,
|
|
18
18
|
ManagedIdentifierCoseKeyResult,
|
|
19
19
|
ManagedIdentifierDidOpts,
|
|
@@ -41,7 +41,7 @@ export const identifierResolutionContextMethods: Array<string> = [
|
|
|
41
41
|
'identifierManagedGetByX5c',
|
|
42
42
|
'identifierManagedGetByKey',
|
|
43
43
|
'identifierManagedGetByOID4VCIssuer',
|
|
44
|
-
'
|
|
44
|
+
'identifierGetManagedByCoseKey',
|
|
45
45
|
'identifierExternalResolve',
|
|
46
46
|
'identifierExternalResolveByDid',
|
|
47
47
|
'identifierExternalResolveByX5c',
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// Copy of jwt-service typings since we cannot include that as devDependency due to cyclic dep
|
|
2
|
-
|
|
2
|
+
|
|
3
3
|
import {
|
|
4
4
|
ExternalIdentifierDidOpts,
|
|
5
5
|
ExternalIdentifierResult,
|
|
@@ -7,10 +7,10 @@ import {
|
|
|
7
7
|
IIdentifierResolution,
|
|
8
8
|
ManagedIdentifierOptsOrResult,
|
|
9
9
|
ManagedIdentifierResult,
|
|
10
|
-
} from '
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
import
|
|
10
|
+
} from '@sphereon/ssi-sdk-ext.identifier-resolution'
|
|
11
|
+
import { ClientIdScheme } from '@sphereon/ssi-sdk-ext.x509-utils'
|
|
12
|
+
import { BaseJWK, IValidationResult, JoseSignatureAlgorithm, JoseSignatureAlgorithmString, JWK } from '@sphereon/ssi-types'
|
|
13
|
+
import { IAgentContext, IKeyManager, IPluginMethodMap } from '@veramo/core'
|
|
14
14
|
export type IRequiredContext = IAgentContext<IIdentifierResolution & IKeyManager>
|
|
15
15
|
export declare const jwtServiceContextMethods: Array<string>
|
|
16
16
|
export interface IJwtService extends IPluginMethodMap {
|
|
@@ -25,7 +25,6 @@ export interface IJwtService extends IPluginMethodMap {
|
|
|
25
25
|
export type IJwsValidationResult = IValidationResult & {
|
|
26
26
|
jws: JwsJsonGeneralWithIdentifiers
|
|
27
27
|
}
|
|
28
|
-
|
|
29
28
|
export interface PreparedJws {
|
|
30
29
|
protectedHeader: JwsHeader
|
|
31
30
|
payload: Uint8Array
|
package/src/types/common.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
1
|
+
import { ICoseKeyJson, JWK } from '@sphereon/ssi-types'
|
|
2
|
+
import { IIdentifier, IKey } from '@veramo/core'
|
|
3
|
+
import { ExternalIdentifierType } from './externalIdentifierTypes'
|
|
4
|
+
import { ManagedIdentifierType } from './managedIdentifierTypes'
|
|
5
5
|
|
|
6
6
|
export interface JwkInfo {
|
|
7
7
|
jwk: JWK
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
1
|
+
import { DidDocumentJwks } from '@sphereon/ssi-sdk-ext.did-utils'
|
|
2
|
+
import { ICoseKeyJson, JWK } from '@sphereon/ssi-types'
|
|
3
|
+
import { X509CertificateChainValidationOpts, X509ValidationResult } from '@sphereon/ssi-sdk-ext.x509-utils'
|
|
4
|
+
import { IParsedDID } from '@sphereon/ssi-types'
|
|
5
|
+
import { DIDDocument, DIDDocumentSection, DIDResolutionResult } from '@veramo/core'
|
|
6
6
|
import {
|
|
7
7
|
isCoseKeyIdentifier,
|
|
8
8
|
isDidIdentifier,
|
|
@@ -12,9 +12,9 @@ import {
|
|
|
12
12
|
isKidIdentifier,
|
|
13
13
|
isOidcDiscoveryIdentifier,
|
|
14
14
|
isX5cIdentifier,
|
|
15
|
-
|
|
15
|
+
JwkInfo,
|
|
16
16
|
} from './common'
|
|
17
|
-
import
|
|
17
|
+
import {JwsPayload} from "./IJwtService";
|
|
18
18
|
|
|
19
19
|
/**
|
|
20
20
|
* Use whenever we need to resolve an external identifier. We can pass in kids, DIDs, and x5chains
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import { ClientIdScheme } from '@sphereon/ssi-sdk-ext.x509-utils'
|
|
2
|
+
import { ICoseKeyJson, JWK } from '@sphereon/ssi-types'
|
|
3
|
+
import { DIDDocumentSection, IIdentifier, IKey, TKeyType } from '@veramo/core'
|
|
4
4
|
import {
|
|
5
5
|
isCoseKeyIdentifier,
|
|
6
6
|
isDidIdentifier,
|
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
isKeyIdentifier,
|
|
10
10
|
isKidIdentifier,
|
|
11
11
|
isX5cIdentifier,
|
|
12
|
-
|
|
12
|
+
JwkInfo,
|
|
13
13
|
} from './common'
|
|
14
14
|
|
|
15
15
|
/**
|