@sphereon/ssi-sdk-ext.identifier-resolution 0.36.1-feature.integration.fides.88 → 0.36.1-feature.vdx24.einvoice.inbox.127

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sphereon/ssi-sdk-ext.identifier-resolution",
3
- "version": "0.36.1-feature.integration.fides.88+5eba8a30",
3
+ "version": "0.36.1-feature.vdx24.einvoice.inbox.127+3fa475f6",
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.integration.fides.88+5eba8a30",
31
- "@sphereon/ssi-sdk-ext.key-utils": "0.36.1-feature.integration.fides.88+5eba8a30",
32
- "@sphereon/ssi-sdk-ext.x509-utils": "0.36.1-feature.integration.fides.88+5eba8a30",
33
- "@sphereon/ssi-sdk.agent-config": "0.36.1-feature.integration.fides.88+5eba8a30",
34
- "@sphereon/ssi-sdk.oidf-client": "0.36.1-feature.integration.fides.88+5eba8a30",
35
- "@sphereon/ssi-types": "0.36.1-feature.integration.fides.88+5eba8a30",
30
+ "@sphereon/ssi-sdk-ext.did-utils": "0.36.1-feature.vdx24.einvoice.inbox.127+3fa475f6",
31
+ "@sphereon/ssi-sdk-ext.key-utils": "0.36.1-feature.vdx24.einvoice.inbox.127+3fa475f6",
32
+ "@sphereon/ssi-sdk-ext.x509-utils": "0.36.1-feature.vdx24.einvoice.inbox.127+3fa475f6",
33
+ "@sphereon/ssi-sdk.agent-config": "0.36.1-feature.vdx24.einvoice.inbox.127+3fa475f6",
34
+ "@sphereon/ssi-sdk.oidf-client": "0.36.1-feature.vdx24.einvoice.inbox.127+3fa475f6",
35
+ "@sphereon/ssi-types": "0.36.1-feature.vdx24.einvoice.inbox.127+3fa475f6",
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.integration.fides.88+5eba8a30",
44
- "@sphereon/ssi-sdk-ext.did-resolver-jwk": "0.36.1-feature.integration.fides.88+5eba8a30",
45
- "@sphereon/ssi-sdk-ext.key-manager": "0.36.1-feature.integration.fides.88+5eba8a30",
46
- "@sphereon/ssi-sdk-ext.kms-local": "0.36.1-feature.integration.fides.88+5eba8a30",
47
- "@sphereon/ssi-sdk.dev": "0.36.1-feature.integration.fides.88+5eba8a30",
43
+ "@sphereon/ssi-sdk-ext.did-provider-jwk": "0.36.1-feature.vdx24.einvoice.inbox.127+3fa475f6",
44
+ "@sphereon/ssi-sdk-ext.did-resolver-jwk": "0.36.1-feature.vdx24.einvoice.inbox.127+3fa475f6",
45
+ "@sphereon/ssi-sdk-ext.key-manager": "0.36.1-feature.vdx24.einvoice.inbox.127+3fa475f6",
46
+ "@sphereon/ssi-sdk-ext.kms-local": "0.36.1-feature.vdx24.einvoice.inbox.127+3fa475f6",
47
+ "@sphereon/ssi-sdk.dev": "0.36.1-feature.vdx24.einvoice.inbox.127+3fa475f6",
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": "5eba8a30455af768df2d4129f6934bf5c1246715"
81
+ "gitHead": "3fa475f6938149c7104b7ca746e6883aa44c3d24"
82
82
  }
@@ -195,8 +195,8 @@ export async function getManagedDidIdentifier(opts: ManagedIdentifierDidOpts, co
195
195
  const key = extendedKey
196
196
  const jwk = toJwk(key.publicKeyHex, key.type, { key })
197
197
  const jwkThumbprint = key.meta?.jwkThumbprint ?? calculateJwkThumbprint({ jwk })
198
- let kid = opts.kid ?? extendedKey.meta?.verificationMethod?.id
199
- if (!kid.startsWith(did)) {
198
+ let kid = opts.kid ?? extendedKey.meta?.verificationMethod?.id ?? extendedKey.kid
199
+ if (kid && !kid.startsWith(did)) {
200
200
  // Make sure we create a fully qualified kid
201
201
  const hash = kid.startsWith('#') ? '' : '#'
202
202
  kid = `${did}${hash}${kid}`
@@ -206,16 +206,20 @@ export async function getManagedDidIdentifier(opts: ManagedIdentifierDidOpts, co
206
206
  // filter keys based on the criteria
207
207
  let filteredKeys = identifier?.keys ?? []
208
208
 
209
+ // Use a flag to track if we have successfully applied a specific filter
210
+ let isFiltered = false
211
+
209
212
  // first try to filter by kmsKeyRef if supplied
210
213
  if (opts.kmsKeyRef) {
211
214
  const keysByKmsKeyRef = filteredKeys.filter((k) => k.kid === opts.kmsKeyRef)
212
215
  if (keysByKmsKeyRef.length > 0) {
213
216
  filteredKeys = keysByKmsKeyRef
217
+ isFiltered = true
214
218
  }
215
219
  }
216
220
 
217
221
  // no match or kmsKeyRef not supplied, try vmRelationship
218
- if (filteredKeys.length === identifier?.keys?.length && opts.vmRelationship) {
222
+ if (!isFiltered && opts.vmRelationship) {
219
223
  const keysByVmRelationship = filteredKeys.filter((k) => {
220
224
  const purposes = k.meta?.purposes
221
225
  if (!purposes || purposes.length === 0) {
@@ -225,11 +229,12 @@ export async function getManagedDidIdentifier(opts: ManagedIdentifierDidOpts, co
225
229
  })
226
230
  if (keysByVmRelationship.length > 0) {
227
231
  filteredKeys = keysByVmRelationship
232
+ isFiltered = true
228
233
  }
229
234
  }
230
235
 
231
236
  //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('#')) {
237
+ if (!isFiltered && typeof opts.identifier === 'string' && opts.identifier.includes('#')) {
233
238
  const fragment = opts.identifier.split('#')[1]
234
239
  const keysByFragment = filteredKeys.filter((k) => {
235
240
  const vmId = k.meta?.verificationMethod?.id
@@ -240,7 +245,7 @@ export async function getManagedDidIdentifier(opts: ManagedIdentifierDidOpts, co
240
245
  }
241
246
  }
242
247
 
243
- // fall back to original keys if no filtering occurred
248
+ // Use the filtered keys (or original keys if no filtering occurred)
244
249
  const keys = filteredKeys
245
250
 
246
251
  // Update controllerKeyId to match the selected key
@@ -389,10 +394,10 @@ export async function getManagedIdentifier(
389
394
  },
390
395
  context: IAgentContext<IKeyManager>,
391
396
  ): Promise<ManagedIdentifierResult> {
392
- let resolutionResult: ManagedIdentifierResult
393
397
  if (isManagedIdentifierResult(opts)) {
394
- opts
398
+ return opts
395
399
  }
400
+ let resolutionResult: ManagedIdentifierResult
396
401
  if (isManagedIdentifierKidOpts(opts)) {
397
402
  resolutionResult = await getManagedKidIdentifier(opts, context)
398
403
  } else if (isManagedIdentifierDidOpts(opts)) {