@sphereon/ssi-sdk-ext.identifier-resolution 0.36.1-feature.SSISDK.70.integrate.digidentity.56 → 0.36.1-feature.SSISDK.78.41
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/index.cjs +5 -39
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +5 -39
- package/dist/index.js.map +1 -1
- package/package.json +13 -13
- package/plugin.schema.json +2 -2
- package/src/functions/managedIdentifierFunctions.ts +8 -56
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sphereon/ssi-sdk-ext.identifier-resolution",
|
|
3
|
-
"version": "0.36.1-feature.SSISDK.
|
|
3
|
+
"version": "0.36.1-feature.SSISDK.78.41+996303cf",
|
|
4
4
|
"source": "./src/index.ts",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -27,12 +27,12 @@
|
|
|
27
27
|
"generate-plugin-schema": "tsx ../../packages/dev/bin/sphereon.js dev generate-plugin-schema"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@sphereon/ssi-sdk-ext.did-utils": "0.36.1-feature.SSISDK.
|
|
31
|
-
"@sphereon/ssi-sdk-ext.key-utils": "0.36.1-feature.SSISDK.
|
|
32
|
-
"@sphereon/ssi-sdk-ext.x509-utils": "0.36.1-feature.SSISDK.
|
|
33
|
-
"@sphereon/ssi-sdk.agent-config": "0.36.1-feature.SSISDK.
|
|
34
|
-
"@sphereon/ssi-sdk.oidf-client": "0.36.1-feature.SSISDK.
|
|
35
|
-
"@sphereon/ssi-types": "0.36.1-feature.SSISDK.
|
|
30
|
+
"@sphereon/ssi-sdk-ext.did-utils": "0.36.1-feature.SSISDK.78.41+996303cf",
|
|
31
|
+
"@sphereon/ssi-sdk-ext.key-utils": "0.36.1-feature.SSISDK.78.41+996303cf",
|
|
32
|
+
"@sphereon/ssi-sdk-ext.x509-utils": "0.36.1-feature.SSISDK.78.41+996303cf",
|
|
33
|
+
"@sphereon/ssi-sdk.agent-config": "0.36.1-feature.SSISDK.78.41+996303cf",
|
|
34
|
+
"@sphereon/ssi-sdk.oidf-client": "0.36.1-feature.SSISDK.78.41+996303cf",
|
|
35
|
+
"@sphereon/ssi-types": "0.36.1-feature.SSISDK.78.41+996303cf",
|
|
36
36
|
"@veramo/core": "4.2.0",
|
|
37
37
|
"@veramo/utils": "4.2.0",
|
|
38
38
|
"debug": "^4.3.4",
|
|
@@ -40,11 +40,11 @@
|
|
|
40
40
|
"uint8arrays": "3.1.1"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
|
-
"@sphereon/ssi-sdk-ext.did-provider-jwk": "0.36.1-feature.SSISDK.
|
|
44
|
-
"@sphereon/ssi-sdk-ext.did-resolver-jwk": "0.36.1-feature.SSISDK.
|
|
45
|
-
"@sphereon/ssi-sdk-ext.key-manager": "0.36.1-feature.SSISDK.
|
|
46
|
-
"@sphereon/ssi-sdk-ext.kms-local": "0.36.1-feature.SSISDK.
|
|
47
|
-
"@sphereon/ssi-sdk.dev": "0.36.1-feature.SSISDK.
|
|
43
|
+
"@sphereon/ssi-sdk-ext.did-provider-jwk": "0.36.1-feature.SSISDK.78.41+996303cf",
|
|
44
|
+
"@sphereon/ssi-sdk-ext.did-resolver-jwk": "0.36.1-feature.SSISDK.78.41+996303cf",
|
|
45
|
+
"@sphereon/ssi-sdk-ext.key-manager": "0.36.1-feature.SSISDK.78.41+996303cf",
|
|
46
|
+
"@sphereon/ssi-sdk-ext.kms-local": "0.36.1-feature.SSISDK.78.41+996303cf",
|
|
47
|
+
"@sphereon/ssi-sdk.dev": "0.36.1-feature.SSISDK.78.41+996303cf",
|
|
48
48
|
"@veramo/data-store": "4.2.0",
|
|
49
49
|
"@veramo/did-manager": "4.2.0",
|
|
50
50
|
"@veramo/did-resolver": "4.2.0",
|
|
@@ -78,5 +78,5 @@
|
|
|
78
78
|
"X.509 Certificates",
|
|
79
79
|
"ARF"
|
|
80
80
|
],
|
|
81
|
-
"gitHead": "
|
|
81
|
+
"gitHead": "996303cfb5bd6f63857be9c94d06ff6adee0d9c1"
|
|
82
82
|
}
|
package/plugin.schema.json
CHANGED
|
@@ -1052,9 +1052,9 @@
|
|
|
1052
1052
|
"type": "object"
|
|
1053
1053
|
},
|
|
1054
1054
|
"DidDocumentJwks": {
|
|
1055
|
-
"$ref": "#/components/schemas/Record<Exclude<DIDDocumentSection,(\"publicKey\"|\"service\")>,def-interface-.ts-
|
|
1055
|
+
"$ref": "#/components/schemas/Record<Exclude<DIDDocumentSection,(\"publicKey\"|\"service\")>,def-interface-.ts-36152-36877-.ts-0-63876[]>"
|
|
1056
1056
|
},
|
|
1057
|
-
"Record<Exclude<DIDDocumentSection,(\"publicKey\"|\"service\")>,def-interface-.ts-
|
|
1057
|
+
"Record<Exclude<DIDDocumentSection,(\"publicKey\"|\"service\")>,def-interface-.ts-36152-36877-.ts-0-63876[]>": {
|
|
1058
1058
|
"type": "object",
|
|
1059
1059
|
"properties": {
|
|
1060
1060
|
"verificationMethod": {
|
|
@@ -4,37 +4,38 @@ import { pemOrDerToX509Certificate } from '@sphereon/ssi-sdk-ext.x509-utils'
|
|
|
4
4
|
import { contextHasDidManager, contextHasKeyManager } from '@sphereon/ssi-sdk.agent-config'
|
|
5
5
|
import type { ICoseKeyJson, JWK } from '@sphereon/ssi-types'
|
|
6
6
|
import type { IAgentContext, IIdentifier, IKey, IKeyManager } from '@veramo/core'
|
|
7
|
-
import { webcrypto } from 'node:crypto'
|
|
8
7
|
import { CryptoEngine, setEngine } from 'pkijs'
|
|
8
|
+
import { webcrypto } from 'node:crypto'
|
|
9
9
|
import type {
|
|
10
10
|
IIdentifierResolution,
|
|
11
11
|
ManagedIdentifierCoseKeyOpts,
|
|
12
12
|
ManagedIdentifierCoseKeyResult,
|
|
13
13
|
ManagedIdentifierDidOpts,
|
|
14
14
|
ManagedIdentifierDidResult,
|
|
15
|
+
ManagedIdentifierOID4VCIssuerOpts,
|
|
16
|
+
ManagedIdentifierOID4VCIssuerResult,
|
|
15
17
|
ManagedIdentifierJwkOpts,
|
|
16
18
|
ManagedIdentifierJwkResult,
|
|
17
19
|
ManagedIdentifierKeyOpts,
|
|
18
20
|
ManagedIdentifierKeyResult,
|
|
19
21
|
ManagedIdentifierKidOpts,
|
|
20
22
|
ManagedIdentifierKidResult,
|
|
21
|
-
ManagedIdentifierOID4VCIssuerOpts,
|
|
22
|
-
ManagedIdentifierOID4VCIssuerResult,
|
|
23
23
|
ManagedIdentifierOptsOrResult,
|
|
24
24
|
ManagedIdentifierResult,
|
|
25
25
|
ManagedIdentifierX5cOpts,
|
|
26
26
|
ManagedIdentifierX5cResult,
|
|
27
27
|
} from '../types'
|
|
28
|
+
|
|
28
29
|
import {
|
|
29
30
|
isManagedIdentifierCoseKeyOpts,
|
|
30
31
|
isManagedIdentifierDidOpts,
|
|
31
32
|
isManagedIdentifierDidResult,
|
|
33
|
+
isManagedIdentifierOID4VCIssuerOpts,
|
|
32
34
|
isManagedIdentifierJwkOpts,
|
|
33
35
|
isManagedIdentifierJwkResult,
|
|
34
36
|
isManagedIdentifierKeyOpts,
|
|
35
37
|
isManagedIdentifierKeyResult,
|
|
36
38
|
isManagedIdentifierKidOpts,
|
|
37
|
-
isManagedIdentifierOID4VCIssuerOpts,
|
|
38
39
|
isManagedIdentifierX5cOpts,
|
|
39
40
|
} from '../types'
|
|
40
41
|
|
|
@@ -182,6 +183,7 @@ export async function getManagedDidIdentifier(opts: ManagedIdentifierDidOpts, co
|
|
|
182
183
|
}
|
|
183
184
|
|
|
184
185
|
const did = identifier.did
|
|
186
|
+
const keys = identifier?.keys // fixme: We really want to return the vmRelationship keys here actually
|
|
185
187
|
const extendedKey = await getFirstKeyWithRelation(
|
|
186
188
|
{
|
|
187
189
|
...opts,
|
|
@@ -193,6 +195,7 @@ export async function getManagedDidIdentifier(opts: ManagedIdentifierDidOpts, co
|
|
|
193
195
|
context,
|
|
194
196
|
)
|
|
195
197
|
const key = extendedKey
|
|
198
|
+
const controllerKeyId = identifier.controllerKeyId
|
|
196
199
|
const jwk = toJwk(key.publicKeyHex, key.type, { key })
|
|
197
200
|
const jwkThumbprint = key.meta?.jwkThumbprint ?? calculateJwkThumbprint({ jwk })
|
|
198
201
|
let kid = opts.kid ?? extendedKey.meta?.verificationMethod?.id
|
|
@@ -202,57 +205,6 @@ export async function getManagedDidIdentifier(opts: ManagedIdentifierDidOpts, co
|
|
|
202
205
|
kid = `${did}${hash}${kid}`
|
|
203
206
|
}
|
|
204
207
|
const issuer = opts.issuer ?? did
|
|
205
|
-
|
|
206
|
-
// filter keys based on the criteria
|
|
207
|
-
let filteredKeys = identifier?.keys ?? []
|
|
208
|
-
|
|
209
|
-
// first try to filter by kmsKeyRef if supplied
|
|
210
|
-
if (opts.kmsKeyRef) {
|
|
211
|
-
const keysByKmsKeyRef = filteredKeys.filter((k) => k.kid === opts.kmsKeyRef)
|
|
212
|
-
if (keysByKmsKeyRef.length > 0) {
|
|
213
|
-
filteredKeys = keysByKmsKeyRef
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
// no match or kmsKeyRef not supplied, try vmRelationship
|
|
218
|
-
if (filteredKeys.length === identifier?.keys?.length && opts.vmRelationship) {
|
|
219
|
-
const keysByVmRelationship = filteredKeys.filter((k) => {
|
|
220
|
-
const purposes = k.meta?.purposes
|
|
221
|
-
if (!purposes || purposes.length === 0) {
|
|
222
|
-
return opts.vmRelationship === 'verificationMethod'
|
|
223
|
-
}
|
|
224
|
-
return purposes.includes(opts.vmRelationship!)
|
|
225
|
-
})
|
|
226
|
-
if (keysByVmRelationship.length > 0) {
|
|
227
|
-
filteredKeys = keysByVmRelationship
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
//no match, try to filter by fragment from opts.identifier (if it's a string with fragment)
|
|
232
|
-
if (filteredKeys.length === identifier?.keys?.length && typeof opts.identifier === 'string' && opts.identifier.includes('#')) {
|
|
233
|
-
const fragment = opts.identifier.split('#')[1]
|
|
234
|
-
const keysByFragment = filteredKeys.filter((k) => {
|
|
235
|
-
const vmId = k.meta?.verificationMethod?.id
|
|
236
|
-
return vmId === `${did}#${fragment}` || vmId === fragment || k.kid === fragment
|
|
237
|
-
})
|
|
238
|
-
if (keysByFragment.length > 0) {
|
|
239
|
-
filteredKeys = keysByFragment
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
// fall back to original keys if no filtering occurred
|
|
244
|
-
const keys = filteredKeys
|
|
245
|
-
|
|
246
|
-
// Update controllerKeyId to match the selected key
|
|
247
|
-
const controllerKeyId = key.kid
|
|
248
|
-
|
|
249
|
-
// update the identifier object with filtered keys and updated controllerKeyId
|
|
250
|
-
const filteredIdentifier: IIdentifier = {
|
|
251
|
-
...identifier,
|
|
252
|
-
keys: filteredKeys,
|
|
253
|
-
controllerKeyId,
|
|
254
|
-
}
|
|
255
|
-
|
|
256
208
|
return {
|
|
257
209
|
method,
|
|
258
210
|
key,
|
|
@@ -264,7 +216,7 @@ export async function getManagedDidIdentifier(opts: ManagedIdentifierDidOpts, co
|
|
|
264
216
|
kid,
|
|
265
217
|
keys,
|
|
266
218
|
issuer,
|
|
267
|
-
identifier
|
|
219
|
+
identifier,
|
|
268
220
|
clientId: opts.clientId,
|
|
269
221
|
clientIdScheme: opts.clientIdScheme,
|
|
270
222
|
opts,
|