@sphereon/ssi-sdk-ext.identifier-resolution 0.28.1-feature.oyd.cmsm.improv.21 → 0.28.1-next.54

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.
Files changed (64) hide show
  1. package/dist/index.cjs +12080 -0
  2. package/dist/index.cjs.map +1 -0
  3. package/dist/index.d.cts +439 -0
  4. package/dist/index.d.ts +434 -7
  5. package/dist/index.js +12047 -27
  6. package/dist/index.js.map +1 -1
  7. package/package.json +34 -21
  8. package/plugin.schema.json +7927 -1289
  9. package/src/agent/IdentifierResolution.ts +40 -39
  10. package/src/functions/LegacySupport.ts +2 -2
  11. package/src/functions/externalIdentifierFunctions.ts +27 -18
  12. package/src/functions/externalOIDFIdentifier.ts +9 -7
  13. package/src/functions/managedIdentifierFunctions.ts +25 -19
  14. package/src/index.ts +1 -1
  15. package/src/types/IIdentifierResolution.ts +4 -4
  16. package/src/types/IJwtService.d.ts +6 -5
  17. package/src/types/common.ts +4 -4
  18. package/src/types/externalIdentifierTypes.ts +7 -7
  19. package/src/types/managedIdentifierTypes.ts +4 -4
  20. package/dist/agent/IdentifierResolution.d.ts +0 -38
  21. package/dist/agent/IdentifierResolution.d.ts.map +0 -1
  22. package/dist/agent/IdentifierResolution.js +0 -123
  23. package/dist/agent/IdentifierResolution.js.map +0 -1
  24. package/dist/functions/LegacySupport.d.ts +0 -12
  25. package/dist/functions/LegacySupport.d.ts.map +0 -1
  26. package/dist/functions/LegacySupport.js +0 -39
  27. package/dist/functions/LegacySupport.js.map +0 -1
  28. package/dist/functions/externalIdentifierFunctions.d.ts +0 -26
  29. package/dist/functions/externalIdentifierFunctions.d.ts.map +0 -1
  30. package/dist/functions/externalIdentifierFunctions.js +0 -250
  31. package/dist/functions/externalIdentifierFunctions.js.map +0 -1
  32. package/dist/functions/externalOIDFIdentifier.d.ts +0 -19
  33. package/dist/functions/externalOIDFIdentifier.d.ts.map +0 -1
  34. package/dist/functions/externalOIDFIdentifier.js +0 -106
  35. package/dist/functions/externalOIDFIdentifier.js.map +0 -1
  36. package/dist/functions/index.d.ts +0 -5
  37. package/dist/functions/index.d.ts.map +0 -1
  38. package/dist/functions/index.js +0 -21
  39. package/dist/functions/index.js.map +0 -1
  40. package/dist/functions/managedIdentifierFunctions.d.ts +0 -38
  41. package/dist/functions/managedIdentifierFunctions.d.ts.map +0 -1
  42. package/dist/functions/managedIdentifierFunctions.js +0 -359
  43. package/dist/functions/managedIdentifierFunctions.js.map +0 -1
  44. package/dist/index.d.ts.map +0 -1
  45. package/dist/types/IIdentifierResolution.d.ts +0 -42
  46. package/dist/types/IIdentifierResolution.d.ts.map +0 -1
  47. package/dist/types/IIdentifierResolution.js +0 -21
  48. package/dist/types/IIdentifierResolution.js.map +0 -1
  49. package/dist/types/common.d.ts +0 -20
  50. package/dist/types/common.d.ts.map +0 -1
  51. package/dist/types/common.js +0 -51
  52. package/dist/types/common.js.map +0 -1
  53. package/dist/types/externalIdentifierTypes.d.ts +0 -114
  54. package/dist/types/externalIdentifierTypes.d.ts.map +0 -1
  55. package/dist/types/externalIdentifierTypes.js +0 -44
  56. package/dist/types/externalIdentifierTypes.js.map +0 -1
  57. package/dist/types/index.d.ts +0 -5
  58. package/dist/types/index.d.ts.map +0 -1
  59. package/dist/types/index.js +0 -21
  60. package/dist/types/index.js.map +0 -1
  61. package/dist/types/managedIdentifierTypes.d.ts +0 -122
  62. package/dist/types/managedIdentifierTypes.d.ts.map +0 -1
  63. package/dist/types/managedIdentifierTypes.js +0 -63
  64. package/dist/types/managedIdentifierTypes.js.map +0 -1
@@ -1,9 +1,9 @@
1
1
  import { globalCrypto } from '@sphereon/ssi-sdk-ext.key-utils'
2
- import { IAgentContext, IAgentPlugin, IDIDManager, IKeyManager } from '@veramo/core'
3
- import { ExternalIdentifierOIDFEntityIdOpts, ExternalIdentifierOIDFEntityIdResult } from '../types'
4
- import { schema } from '..'
2
+ import type { IAgentContext, IAgentPlugin, IDIDManager, IKeyManager } from '@veramo/core'
3
+ import type { ExternalIdentifierOIDFEntityIdOpts, ExternalIdentifierOIDFEntityIdResult } from '../types'
4
+ import { schema } from '../index'
5
5
  import { resolveExternalIdentifier, ensureManagedIdentifierResult } from '../functions'
6
- import {
6
+ import type {
7
7
  ExternalIdentifierDidOpts,
8
8
  ExternalIdentifierDidResult,
9
9
  ExternalIdentifierOpts,
@@ -32,26 +32,28 @@ import {
32
32
  ManagedIdentifierOptsOrResult,
33
33
  ManagedIdentifierOID4VCIssuerOpts,
34
34
  } from '../types'
35
- import { IOIDFClient } from '@sphereon/ssi-sdk.oidf-client'
35
+ import type { IOIDFClient } from '@sphereon/ssi-sdk.oidf-client'
36
+
37
+ import { webcrypto } from 'node:crypto'
36
38
 
37
39
  /**
38
40
  * @public
39
41
  */
40
42
  export class IdentifierResolution implements IAgentPlugin {
41
- private readonly _crypto: Crypto
43
+ readonly _crypto: webcrypto.Crypto
42
44
 
43
45
  readonly schema = schema.IMnemonicInfoGenerator
44
46
  readonly methods: IIdentifierResolution = {
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),
47
+ identifierManagedGet: this.identifierManagedGet.bind(this),
48
+ identifierManagedGetByDid: this.identifierManagedGetByDid.bind(this),
49
+ identifierManagedGetByKid: this.identifierManagedGetByKid.bind(this),
50
+ identifierManagedGetByJwk: this.identifierManagedGetByJwk.bind(this),
51
+ identifierManagedGetByX5c: this.identifierManagedGetByX5c.bind(this),
52
+ identifierManagedGetByKey: this.identifierManagedGetByKey.bind(this),
53
+ identifierManagedGetByCoseKey: this.identifierManagedGetByCoseKey.bind(this),
54
+ identifierManagedGetByOID4VCIssuer: this.identifierManagedGetByOID4VCIssuer.bind(this),
55
+
56
+ identifierExternalResolve: this.identifierExternalResolve.bind(this),
55
57
  identifierExternalResolveByDid: this.identifierExternalResolveByDid.bind(this),
56
58
  identifierExternalResolveByX5c: this.identifierExternalResolveByX5c.bind(this),
57
59
  identifierExternalResolveByJwk: this.identifierExternalResolveByJwk.bind(this),
@@ -64,7 +66,7 @@ export class IdentifierResolution implements IAgentPlugin {
64
66
  /**
65
67
  * TODO: Add a cache, as we are retrieving the same keys/info quite often
66
68
  */
67
- constructor(opts?: { crypto?: Crypto }) {
69
+ constructor(opts?: { crypto?: webcrypto.Crypto }) {
68
70
  this._crypto = globalCrypto(false, opts?.crypto)
69
71
  }
70
72
 
@@ -73,65 +75,64 @@ export class IdentifierResolution implements IAgentPlugin {
73
75
  * integrate a plugin for anomaly detection. Having a single method helps
74
76
  * @param args
75
77
  * @param context
76
- * @private
77
78
  */
78
- private async identifierGetManaged(
79
+ private async identifierManagedGet(
79
80
  args: ManagedIdentifierOptsOrResult,
80
81
  context: IAgentContext<IKeyManager & IIdentifierResolution>
81
82
  ): Promise<ManagedIdentifierResult> {
82
83
  return await ensureManagedIdentifierResult({ ...args, crypto: this._crypto }, context)
83
84
  }
84
85
 
85
- private async identifierGetManagedByDid(
86
+ private async identifierManagedGetByDid(
86
87
  args: ManagedIdentifierDidOpts,
87
88
  context: IAgentContext<IKeyManager & IDIDManager & IIdentifierResolution>
88
89
  ): Promise<ManagedIdentifierDidResult> {
89
- return (await this.identifierGetManaged({ ...args, method: 'did' }, context)) as ManagedIdentifierDidResult
90
+ return (await this.identifierManagedGet({ ...args, method: 'did' }, context)) as ManagedIdentifierDidResult
90
91
  }
91
92
 
92
- private async identifierGetManagedByKid(
93
+ private async identifierManagedGetByKid(
93
94
  args: ManagedIdentifierKidOpts,
94
95
  context: IAgentContext<IKeyManager & IIdentifierResolution>
95
96
  ): Promise<ManagedIdentifierKidResult> {
96
- return (await this.identifierGetManaged({ ...args, method: 'kid' }, context)) as ManagedIdentifierKidResult
97
+ return (await this.identifierManagedGet({ ...args, method: 'kid' }, context)) as ManagedIdentifierKidResult
97
98
  }
98
99
 
99
- private async identifierGetManagedByKey(
100
+ private async identifierManagedGetByKey(
100
101
  args: ManagedIdentifierKeyOpts,
101
102
  context: IAgentContext<IKeyManager & IIdentifierResolution>
102
103
  ): Promise<ManagedIdentifierKeyResult> {
103
- return (await this.identifierGetManaged({ ...args, method: 'key' }, context)) as ManagedIdentifierKeyResult
104
+ return (await this.identifierManagedGet({ ...args, method: 'key' }, context)) as ManagedIdentifierKeyResult
104
105
  }
105
106
 
106
- private async identifierGetManagedByCoseKey(
107
+ private async identifierManagedGetByCoseKey(
107
108
  args: ManagedIdentifierCoseKeyOpts,
108
109
  context: IAgentContext<IKeyManager & IIdentifierResolution>
109
110
  ): Promise<ManagedIdentifierCoseKeyResult> {
110
- return (await this.identifierGetManaged({ ...args, method: 'cose_key' }, context)) as ManagedIdentifierCoseKeyResult
111
+ return (await this.identifierManagedGet({ ...args, method: 'cose_key' }, context)) as ManagedIdentifierCoseKeyResult
111
112
  }
112
113
 
113
- private async identifierGetManagedByOID4VCIssuer(
114
+ private async identifierManagedGetByOID4VCIssuer(
114
115
  args: ManagedIdentifierOID4VCIssuerOpts,
115
116
  context: IAgentContext<IKeyManager & IIdentifierResolution>
116
117
  ): Promise<ManagedIdentifierOID4VCIssuerResult> {
117
- return (await this.identifierGetManaged({ ...args, method: 'oid4vci-issuer' }, context)) as ManagedIdentifierOID4VCIssuerResult
118
+ return (await this.identifierManagedGet({ ...args, method: 'oid4vci-issuer' }, context)) as ManagedIdentifierOID4VCIssuerResult
118
119
  }
119
120
 
120
- private async identifierGetManagedByJwk(
121
+ private async identifierManagedGetByJwk(
121
122
  args: ManagedIdentifierJwkOpts,
122
123
  context: IAgentContext<IKeyManager & IIdentifierResolution>
123
124
  ): Promise<ManagedIdentifierJwkResult> {
124
- return (await this.identifierGetManaged({ ...args, method: 'jwk' }, context)) as ManagedIdentifierJwkResult
125
+ return (await this.identifierManagedGet({ ...args, method: 'jwk' }, context)) as ManagedIdentifierJwkResult
125
126
  }
126
127
 
127
- private async identifierGetManagedByX5c(
128
+ private async identifierManagedGetByX5c(
128
129
  args: ManagedIdentifierX5cOpts,
129
130
  context: IAgentContext<IKeyManager & IIdentifierResolution>
130
131
  ): Promise<ManagedIdentifierX5cResult> {
131
- return (await this.identifierGetManaged({ ...args, method: 'x5c' }, context)) as ManagedIdentifierX5cResult
132
+ return (await this.identifierManagedGet({ ...args, method: 'x5c' }, context)) as ManagedIdentifierX5cResult
132
133
  }
133
134
 
134
- private async identifierResolveExternal(
135
+ private async identifierExternalResolve(
135
136
  args: ExternalIdentifierOpts,
136
137
  context: IAgentContext<IKeyManager | IOIDFClient>
137
138
  ): Promise<ExternalIdentifierResult> {
@@ -139,28 +140,28 @@ export class IdentifierResolution implements IAgentPlugin {
139
140
  }
140
141
 
141
142
  private async identifierExternalResolveByDid(args: ExternalIdentifierDidOpts, context: IAgentContext<any>): Promise<ExternalIdentifierDidResult> {
142
- return (await this.identifierResolveExternal({ ...args, method: 'did' }, context)) as ExternalIdentifierDidResult
143
+ return (await this.identifierExternalResolve({ ...args, method: 'did' }, context)) as ExternalIdentifierDidResult
143
144
  }
144
145
 
145
146
  private async identifierExternalResolveByX5c(args: ExternalIdentifierX5cOpts, context: IAgentContext<any>): Promise<ExternalIdentifierX5cResult> {
146
- return (await this.identifierResolveExternal({ ...args, method: 'x5c' }, context)) as ExternalIdentifierX5cResult
147
+ return (await this.identifierExternalResolve({ ...args, method: 'x5c' }, context)) as ExternalIdentifierX5cResult
147
148
  }
148
149
 
149
150
  private async identifierExternalResolveByCoseKey(
150
151
  args: ExternalIdentifierCoseKeyOpts,
151
152
  context: IAgentContext<any>
152
153
  ): Promise<ExternalIdentifierCoseKeyResult> {
153
- return (await this.identifierResolveExternal({ ...args, method: 'cose_key' }, context)) as ExternalIdentifierCoseKeyResult
154
+ return (await this.identifierExternalResolve({ ...args, method: 'cose_key' }, context)) as ExternalIdentifierCoseKeyResult
154
155
  }
155
156
 
156
157
  private async identifierExternalResolveByJwk(args: ExternalIdentifierJwkOpts, context: IAgentContext<any>): Promise<ExternalIdentifierJwkResult> {
157
- return (await this.identifierResolveExternal({ ...args, method: 'jwk' }, context)) as ExternalIdentifierJwkResult
158
+ return (await this.identifierExternalResolve({ ...args, method: 'jwk' }, context)) as ExternalIdentifierJwkResult
158
159
  }
159
160
 
160
161
  private async identifierExternalResolveByOIDFEntityId(
161
162
  args: ExternalIdentifierOIDFEntityIdOpts,
162
163
  context: IAgentContext<any>
163
164
  ): Promise<ExternalIdentifierOIDFEntityIdResult> {
164
- return (await this.identifierResolveExternal({ ...args, method: 'entity_id' }, context)) as ExternalIdentifierOIDFEntityIdResult
165
+ return (await this.identifierExternalResolve({ ...args, method: 'entity_id' }, context)) as ExternalIdentifierOIDFEntityIdResult
165
166
  }
166
167
  }
@@ -1,5 +1,5 @@
1
- import { IIdentifier } from '@veramo/core'
2
- import { ManagedIdentifierDidOpts, ManagedIdentifierOptsOrResult } from '../types'
1
+ import type { IIdentifier } from '@veramo/core'
2
+ import type { 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
- X509ValidationResult,
8
+ type X509ValidationResult,
9
9
  } from '@sphereon/ssi-sdk-ext.x509-utils'
10
10
  import { contextHasPlugin } from '@sphereon/ssi-sdk.agent-config'
11
- import { IParsedDID, JWK, parseDid } from '@sphereon/ssi-types'
12
- import { IAgentContext, IDIDManager, IResolver } from '@veramo/core'
11
+ import { type IParsedDID, type JWK, parseDid } from '@sphereon/ssi-types'
12
+ import type { IAgentContext, IDIDManager, IResolver } from '@veramo/core'
13
13
  import { isDefined } from '@veramo/utils'
14
14
  import { CryptoEngine, setEngine } from 'pkijs'
15
- import {
15
+ import type {
16
16
  ExternalIdentifierCoseKeyOpts,
17
17
  ExternalIdentifierCoseKeyResult,
18
18
  ExternalIdentifierDidOpts,
@@ -25,6 +25,8 @@ import {
25
25
  ExternalIdentifierX5cOpts,
26
26
  ExternalIdentifierX5cResult,
27
27
  ExternalJwkInfo,
28
+ } from '../types'
29
+ import {
28
30
  isExternalIdentifierCoseKeyOpts,
29
31
  isExternalIdentifierDidOpts,
30
32
  isExternalIdentifierJwkOpts,
@@ -36,9 +38,10 @@ import {
36
38
  } from '../types'
37
39
  import { resolveExternalOIDFEntityIdIdentifier } from '.'
38
40
 
41
+ import { webcrypto } from 'node:crypto'
39
42
  export async function resolveExternalIdentifier(
40
43
  opts: ExternalIdentifierOpts & {
41
- crypto?: Crypto
44
+ crypto?: webcrypto.Crypto
42
45
  },
43
46
  context: IAgentContext<any>
44
47
  ): Promise<ExternalIdentifierResult> {
@@ -65,7 +68,7 @@ export async function resolveExternalIdentifier(
65
68
 
66
69
  export async function resolveExternalX5cIdentifier(
67
70
  opts: ExternalIdentifierX5cOpts & {
68
- crypto?: Crypto
71
+ crypto?: webcrypto.Crypto
69
72
  },
70
73
  context: IAgentContext<IResolver & IDIDManager>
71
74
  ): Promise<ExternalIdentifierX5cResult> {
@@ -245,18 +248,24 @@ export async function resolveExternalDidIdentifier(
245
248
  const didDocument = didResolutionResult.didDocument ?? undefined
246
249
  const didJwks = didDocument ? didDocumentToJwks(didDocument) : undefined
247
250
  const jwks = didJwks
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))
251
+ ? Array.from(
252
+ new Set(
253
+ Array.from(
254
+ Object.values(didJwks)
255
+ .filter((jwks) => isDefined(jwks) && jwks.length > 0)
256
+ .flatMap((jwks) => jwks)
257
+ )
258
+ .flatMap((jwk) => {
259
+ return {
260
+ jwk,
261
+ jwkThumbprint: calculateJwkThumbprint({ jwk }),
262
+ kid: jwk.kid,
263
+ publicKeyHex: jwkTtoPublicKeyHex(jwk),
264
+ }
265
+ })
266
+ .map((jwk) => JSON.stringify(jwk))
267
+ )
268
+ ).map((jwks) => JSON.parse(jwks))
260
269
  : []
261
270
 
262
271
  if (didResolutionResult?.didDocument) {
@@ -1,9 +1,11 @@
1
- import { ErrorMessage, ExternalIdentifierOIDFEntityIdOpts, ExternalIdentifierOIDFEntityIdResult, ExternalJwkInfo, TrustedAnchor } from '../types'
2
- import { IAgentContext } from '@veramo/core'
3
- import { IOIDFClient } from '@sphereon/ssi-sdk.oidf-client'
1
+ import type { ErrorMessage, ExternalIdentifierOIDFEntityIdOpts, ExternalIdentifierOIDFEntityIdResult, ExternalJwkInfo, TrustedAnchor } from '../types'
2
+ import type { IAgentContext } from '@veramo/core'
3
+ import type { IOIDFClient } from '@sphereon/ssi-sdk.oidf-client'
4
4
  import { contextHasPlugin } from '@sphereon/ssi-sdk.agent-config'
5
- import {IJwsValidationResult, JwsPayload} from '../types/IJwtService'
5
+ import type { IJwsValidationResult, JwsPayload } from '../types/IJwtService'
6
+ // @ts-ignore
6
7
  import * as u8a from 'uint8arrays'
8
+ const { fromString, toString } = u8a
7
9
  /**
8
10
  * Resolves an OIDF Entity ID against multiple trust anchors to establish trusted relationships
9
11
  *
@@ -43,10 +45,10 @@ export async function resolveExternalOIDFEntityIdIdentifier(
43
45
  trustAnchors: [trustAnchor],
44
46
  })
45
47
 
46
- if (resolveResult.error || !resolveResult.trustChain) {
48
+ if (resolveResult.errorMessage || !resolveResult.trustChain) {
47
49
  errorList[trustAnchor] = resolveResult.errorMessage ?? 'unspecified'
48
50
  } else {
49
- const trustChain: ReadonlyArray<string> = resolveResult.trustChain.asJsReadonlyArrayView()
51
+ const trustChain = resolveResult.trustChain
50
52
  if (trustChain.length === 0) {
51
53
  errorList[trustAnchor] = 'Trust chain is empty'
52
54
  continue
@@ -65,7 +67,7 @@ export async function resolveExternalOIDFEntityIdIdentifier(
65
67
  continue
66
68
  }
67
69
 
68
- payload = JSON.parse(u8a.toString(u8a.fromString(jwtVerifyResult.jws.payload, 'base64url')))
70
+ payload = JSON.parse(toString(fromString(jwtVerifyResult.jws.payload, 'base64url')))
69
71
  const signature = jwtVerifyResult.jws.signatures[0]
70
72
  if (signature.identifier.jwks.length === 0) {
71
73
  errorList[trustAnchor] = 'No JWK was present in the trust anchor signature'
@@ -2,21 +2,12 @@ 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 { ICoseKeyJson, JWK } from '@sphereon/ssi-types'
6
- import { IAgentContext, IIdentifier, IKey, IKeyManager } from '@veramo/core'
5
+ import type { ICoseKeyJson, JWK } from '@sphereon/ssi-types'
6
+ import type { IAgentContext, IIdentifier, IKey, IKeyManager } from '@veramo/core'
7
7
  import { CryptoEngine, setEngine } from 'pkijs'
8
- import {
8
+ import { webcrypto } from 'node:crypto'
9
+ import type {
9
10
  IIdentifierResolution,
10
- isManagedIdentifierCoseKeyOpts,
11
- isManagedIdentifierDidOpts,
12
- isManagedIdentifierDidResult,
13
- isManagedIdentifierOID4VCIssuerOpts,
14
- isManagedIdentifierJwkOpts,
15
- isManagedIdentifierJwkResult,
16
- isManagedIdentifierKeyOpts,
17
- isManagedIdentifierKeyResult,
18
- isManagedIdentifierKidOpts,
19
- isManagedIdentifierX5cOpts,
20
11
  ManagedIdentifierCoseKeyOpts,
21
12
  ManagedIdentifierCoseKeyResult,
22
13
  ManagedIdentifierDidOpts,
@@ -35,6 +26,19 @@ import {
35
26
  ManagedIdentifierX5cResult,
36
27
  } from '../types'
37
28
 
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
+
38
42
  export async function getManagedKidIdentifier(
39
43
  opts: ManagedIdentifierKidOpts,
40
44
  context: IAgentContext<IKeyManager>
@@ -47,13 +51,13 @@ export async function getManagedKidIdentifier(
47
51
  return Promise.reject(Error(`Cannot get Key/JWK identifier if KeyManager plugin is not enabled!`))
48
52
  } else if (opts.identifier.startsWith('did:')) {
49
53
  const did = opts.identifier.split('#')[0]
50
- const didIdentifier = await getManagedDidIdentifier({...opts, method: 'did', identifier: did}, context)
54
+ const didIdentifier = await getManagedDidIdentifier({ ...opts, method: 'did', identifier: did }, context)
51
55
  key = didIdentifier.key
52
56
  issuer = didIdentifier.issuer
53
57
  kid = opts?.kid ?? (key.meta?.verificationMethod?.id as string) ?? didIdentifier.kid
54
58
  }
55
59
  if (!key) {
56
- key = await context.agent.keyManagerGet({kid: opts.kmsKeyRef ?? opts.identifier})
60
+ key = await context.agent.keyManagerGet({ kid: opts.kmsKeyRef ?? opts.identifier })
57
61
  }
58
62
  const jwk = toJwk(key.publicKeyHex, key.type, { key })
59
63
  const jwkThumbprint = (key.meta?.jwkThumbprint as string) ?? calculateJwkThumbprint({ jwk })
@@ -80,7 +84,7 @@ export async function getManagedKidIdentifier(
80
84
 
81
85
  export function isManagedIdentifierResult(
82
86
  identifier: ManagedIdentifierOptsOrResult & {
83
- crypto?: Crypto
87
+ crypto?: webcrypto.Crypto
84
88
  }
85
89
  ): identifier is ManagedIdentifierResult {
86
90
  return 'key' in identifier && 'kmsKeyRef' in identifier && 'method' in identifier && 'opts' in identifier && 'jwkThumbprint' in identifier
@@ -93,7 +97,7 @@ export function isManagedIdentifierResult(
93
97
  */
94
98
  export async function ensureManagedIdentifierResult(
95
99
  identifier: ManagedIdentifierOptsOrResult & {
96
- crypto?: Crypto
100
+ crypto?: webcrypto.Crypto
97
101
  },
98
102
  context: IAgentContext<IKeyManager>
99
103
  ): Promise<ManagedIdentifierResult> {
@@ -183,6 +187,8 @@ export async function getManagedDidIdentifier(opts: ManagedIdentifierDidOpts, co
183
187
  const extendedKey = await getFirstKeyWithRelation(
184
188
  {
185
189
  ...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,
186
192
  identifier,
187
193
  vmRelationship: opts.vmRelationship ?? 'verificationMethod',
188
194
  },
@@ -247,7 +253,7 @@ export async function getManagedJwkIdentifier(
247
253
 
248
254
  export async function getManagedX5cIdentifier(
249
255
  opts: ManagedIdentifierX5cOpts & {
250
- crypto?: Crypto
256
+ crypto?: webcrypto.Crypto
251
257
  },
252
258
  context: IAgentContext<IKeyManager>
253
259
  ): Promise<ManagedIdentifierX5cResult> {
@@ -331,7 +337,7 @@ export async function getManagedOID4VCIssuerIdentifier(
331
337
 
332
338
  export async function getManagedIdentifier(
333
339
  opts: ManagedIdentifierOptsOrResult & {
334
- crypto?: Crypto
340
+ crypto?: webcrypto.Crypto
335
341
  },
336
342
  context: IAgentContext<IKeyManager>
337
343
  ): Promise<ManagedIdentifierResult> {
package/src/index.ts CHANGED
@@ -6,6 +6,6 @@ export { schema }
6
6
  /**
7
7
  * @public
8
8
  */
9
+ export * from './types'
9
10
  export { IdentifierResolution } from './agent/IdentifierResolution'
10
11
  export * from './functions'
11
- export * from './types'
@@ -1,5 +1,5 @@
1
- import { IAgentContext, IDIDManager, IKeyManager, IPluginMethodMap } from '@veramo/core'
2
- import {
1
+ import type { IAgentContext, IDIDManager, IKeyManager, IPluginMethodMap } from '@veramo/core'
2
+ import type {
3
3
  ExternalIdentifierCoseKeyOpts,
4
4
  ExternalIdentifierCoseKeyResult,
5
5
  ExternalIdentifierDidOpts,
@@ -13,7 +13,7 @@ import {
13
13
  ExternalIdentifierX5cOpts,
14
14
  ExternalIdentifierX5cResult,
15
15
  } from './externalIdentifierTypes'
16
- import {
16
+ import type {
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
- 'identifierGetManagedByCoseKey',
44
+ 'identifierManagedGetByCoseKey',
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 '@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'
10
+ } from '../types'*/
11
+ import type { ClientIdScheme } from '@sphereon/ssi-sdk-ext.x509-utils'
12
+ import type { BaseJWK, IValidationResult, JoseSignatureAlgorithm, JoseSignatureAlgorithmString, JWK } from '@sphereon/ssi-types'
13
+ import type { 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,6 +25,7 @@ export interface IJwtService extends IPluginMethodMap {
25
25
  export type IJwsValidationResult = IValidationResult & {
26
26
  jws: JwsJsonGeneralWithIdentifiers
27
27
  }
28
+
28
29
  export interface PreparedJws {
29
30
  protectedHeader: JwsHeader
30
31
  payload: Uint8Array
@@ -1,7 +1,7 @@
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'
1
+ import type { ICoseKeyJson, JWK } from '@sphereon/ssi-types'
2
+ import type { IIdentifier, IKey } from '@veramo/core'
3
+ import type { ExternalIdentifierType } from './externalIdentifierTypes'
4
+ import type { ManagedIdentifierType } from './managedIdentifierTypes'
5
5
 
6
6
  export interface JwkInfo {
7
7
  jwk: JWK
@@ -1,8 +1,8 @@
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'
1
+ import type { DidDocumentJwks } from '@sphereon/ssi-sdk-ext.did-utils'
2
+ import type { ICoseKeyJson, JWK } from '@sphereon/ssi-types'
3
+ import type { X509CertificateChainValidationOpts, X509ValidationResult } from '@sphereon/ssi-sdk-ext.x509-utils'
4
+ import type { IParsedDID } from '@sphereon/ssi-types'
5
+ import type { 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
- JwkInfo,
15
+ type JwkInfo,
16
16
  } from './common'
17
- import {JwsPayload} from "./IJwtService";
17
+ import type { 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 { 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'
1
+ import type { ClientIdScheme } from '@sphereon/ssi-sdk-ext.x509-utils'
2
+ import type { ICoseKeyJson, JWK } from '@sphereon/ssi-types'
3
+ import type { 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
- JwkInfo,
12
+ type JwkInfo,
13
13
  } from './common'
14
14
 
15
15
  /**
@@ -1,38 +0,0 @@
1
- import { IAgentPlugin } from '@veramo/core';
2
- import { IIdentifierResolution } from '../types';
3
- /**
4
- * @public
5
- */
6
- export declare class IdentifierResolution implements IAgentPlugin {
7
- private readonly _crypto;
8
- readonly schema: any;
9
- readonly methods: IIdentifierResolution;
10
- /**
11
- * TODO: Add a cache, as we are retrieving the same keys/info quite often
12
- */
13
- constructor(opts?: {
14
- crypto?: Crypto;
15
- });
16
- /**
17
- * Main method for managed identifiers. We always go through this method (also the other methods below) as we want to
18
- * integrate a plugin for anomaly detection. Having a single method helps
19
- * @param args
20
- * @param context
21
- * @private
22
- */
23
- private identifierGetManaged;
24
- private identifierGetManagedByDid;
25
- private identifierGetManagedByKid;
26
- private identifierGetManagedByKey;
27
- private identifierGetManagedByCoseKey;
28
- private identifierGetManagedByOID4VCIssuer;
29
- private identifierGetManagedByJwk;
30
- private identifierGetManagedByX5c;
31
- private identifierResolveExternal;
32
- private identifierExternalResolveByDid;
33
- private identifierExternalResolveByX5c;
34
- private identifierExternalResolveByCoseKey;
35
- private identifierExternalResolveByJwk;
36
- private identifierExternalResolveByOIDFEntityId;
37
- }
38
- //# sourceMappingURL=IdentifierResolution.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"IdentifierResolution.d.ts","sourceRoot":"","sources":["../../src/agent/IdentifierResolution.ts"],"names":[],"mappings":"AACA,OAAO,EAAiB,YAAY,EAA4B,MAAM,cAAc,CAAA;AAIpF,OAAO,EAWL,qBAAqB,EAiBtB,MAAM,UAAU,CAAA;AAGjB;;GAEG;AACH,qBAAa,oBAAqB,YAAW,YAAY;IACvD,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAQ;IAEhC,QAAQ,CAAC,MAAM,MAAgC;IAC/C,QAAQ,CAAC,OAAO,EAAE,qBAAqB,CAkBtC;IAED;;OAEG;gBACS,IAAI,CAAC,EAAE;QAAE,MAAM,CAAC,EAAE,MAAM,CAAA;KAAE;IAItC;;;;;;OAMG;YACW,oBAAoB;YAOpB,yBAAyB;YAOzB,yBAAyB;YAOzB,yBAAyB;YAOzB,6BAA6B;YAO7B,kCAAkC;YAOlC,yBAAyB;YAOzB,yBAAyB;YAOzB,yBAAyB;YAOzB,8BAA8B;YAI9B,8BAA8B;YAI9B,kCAAkC;YAOlC,8BAA8B;YAI9B,uCAAuC;CAMtD"}