@sphereon/ssi-sdk-ext.identifier-resolution 0.28.1-feature.esm.cjs.8 → 0.28.1-feature.jose.vcdm.19

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.
@@ -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'
2
+ import type { IAgentContext, IAgentPlugin, IDIDManager, IKeyManager } from '@veramo/core'
3
+ import type { ExternalIdentifierOIDFEntityIdOpts, ExternalIdentifierOIDFEntityIdResult } from '../types'
4
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,7 +32,7 @@ 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
36
 
37
37
  import { webcrypto } from 'node:crypto'
38
38
 
@@ -40,7 +40,6 @@ import { webcrypto } from 'node:crypto'
40
40
  * @public
41
41
  */
42
42
  export class IdentifierResolution implements IAgentPlugin {
43
-
44
43
  readonly _crypto: webcrypto.Crypto
45
44
 
46
45
  readonly schema = schema.IMnemonicInfoGenerator
@@ -67,9 +66,7 @@ export class IdentifierResolution implements IAgentPlugin {
67
66
  /**
68
67
  * TODO: Add a cache, as we are retrieving the same keys/info quite often
69
68
  */
70
- constructor(opts?: {
71
- crypto?: webcrypto.Crypto
72
- }) {
69
+ constructor(opts?: { crypto?: webcrypto.Crypto }) {
73
70
  this._crypto = globalCrypto(false, opts?.crypto)
74
71
  }
75
72
 
@@ -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,
@@ -24,7 +24,9 @@ import {
24
24
  ExternalIdentifierResult,
25
25
  ExternalIdentifierX5cOpts,
26
26
  ExternalIdentifierX5cResult,
27
- ExternalJwkInfo,
27
+ ExternalJwkInfo
28
+ } from '../types'
29
+ import {
28
30
  isExternalIdentifierCoseKeyOpts,
29
31
  isExternalIdentifierDidOpts,
30
32
  isExternalIdentifierJwkOpts,
@@ -1,12 +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
6
  // @ts-ignore
7
- import { fromString } from 'uint8arrays/from-string'
8
- // @ts-ignore
9
- import { toString } from 'uint8arrays/to-string'
7
+ import * as u8a from 'uint8arrays'
8
+ const { fromString, toString } = u8a
10
9
  /**
11
10
  * Resolves an OIDF Entity ID against multiple trust anchors to establish trusted relationships
12
11
  *
@@ -46,10 +45,10 @@ export async function resolveExternalOIDFEntityIdIdentifier(
46
45
  trustAnchors: [trustAnchor],
47
46
  })
48
47
 
49
- if (resolveResult.error || !resolveResult.trustChain) {
48
+ if (resolveResult.errorMessage || !resolveResult.trustChain) {
50
49
  errorList[trustAnchor] = resolveResult.errorMessage ?? 'unspecified'
51
50
  } else {
52
- const trustChain: ReadonlyArray<string> = resolveResult.trustChain.asJsReadonlyArrayView()
51
+ const trustChain = resolveResult.trustChain
53
52
  if (trustChain.length === 0) {
54
53
  errorList[trustAnchor] = 'Trust chain is empty'
55
54
  continue
@@ -2,22 +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
8
  import { webcrypto } from 'node:crypto'
9
- import {
9
+ import type {
10
10
  IIdentifierResolution,
11
- isManagedIdentifierCoseKeyOpts,
12
- isManagedIdentifierDidOpts,
13
- isManagedIdentifierDidResult,
14
- isManagedIdentifierOID4VCIssuerOpts,
15
- isManagedIdentifierJwkOpts,
16
- isManagedIdentifierJwkResult,
17
- isManagedIdentifierKeyOpts,
18
- isManagedIdentifierKeyResult,
19
- isManagedIdentifierKidOpts,
20
- isManagedIdentifierX5cOpts,
21
11
  ManagedIdentifierCoseKeyOpts,
22
12
  ManagedIdentifierCoseKeyResult,
23
13
  ManagedIdentifierDidOpts,
@@ -36,6 +26,19 @@ import {
36
26
  ManagedIdentifierX5cResult,
37
27
  } from '../types'
38
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
+
39
42
  export async function getManagedKidIdentifier(
40
43
  opts: ManagedIdentifierKidOpts,
41
44
  context: IAgentContext<IKeyManager>
@@ -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,
@@ -8,9 +8,9 @@ import {
8
8
  ManagedIdentifierOptsOrResult,
9
9
  ManagedIdentifierResult,
10
10
  } from '../types'*/
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'
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 {
@@ -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
  /**