@sphereon/ssi-sdk-ext.identifier-resolution 0.24.1-unstable.93 → 0.25.1-feature.SDK.41.oidf.support.11

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 (54) hide show
  1. package/dist/agent/IdentifierResolution.d.ts +5 -0
  2. package/dist/agent/IdentifierResolution.d.ts.map +1 -1
  3. package/dist/agent/IdentifierResolution.js +31 -1
  4. package/dist/agent/IdentifierResolution.js.map +1 -1
  5. package/dist/functions/LegacySupport.d.ts +12 -0
  6. package/dist/functions/LegacySupport.d.ts.map +1 -0
  7. package/dist/functions/LegacySupport.js +39 -0
  8. package/dist/functions/LegacySupport.js.map +1 -0
  9. package/dist/functions/externalIdentifierFunctions.d.ts +17 -1
  10. package/dist/functions/externalIdentifierFunctions.d.ts.map +1 -1
  11. package/dist/functions/externalIdentifierFunctions.js +89 -6
  12. package/dist/functions/externalIdentifierFunctions.js.map +1 -1
  13. package/dist/functions/externalOIDFIdentifier.d.ts +19 -0
  14. package/dist/functions/externalOIDFIdentifier.d.ts.map +1 -0
  15. package/dist/functions/externalOIDFIdentifier.js +84 -0
  16. package/dist/functions/externalOIDFIdentifier.js.map +1 -0
  17. package/dist/functions/index.d.ts +2 -11
  18. package/dist/functions/index.d.ts.map +1 -1
  19. package/dist/functions/index.js +2 -36
  20. package/dist/functions/index.js.map +1 -1
  21. package/dist/functions/managedIdentifierFunctions.d.ts +17 -3
  22. package/dist/functions/managedIdentifierFunctions.d.ts.map +1 -1
  23. package/dist/functions/managedIdentifierFunctions.js +134 -12
  24. package/dist/functions/managedIdentifierFunctions.js.map +1 -1
  25. package/dist/tsdoc-metadata.json +1 -1
  26. package/dist/types/IIdentifierResolution.d.ts +14 -3
  27. package/dist/types/IIdentifierResolution.d.ts.map +1 -1
  28. package/dist/types/IIdentifierResolution.js +18 -0
  29. package/dist/types/IIdentifierResolution.js.map +1 -1
  30. package/dist/types/common.d.ts +4 -1
  31. package/dist/types/common.d.ts.map +1 -1
  32. package/dist/types/common.js +21 -10
  33. package/dist/types/common.js.map +1 -1
  34. package/dist/types/externalIdentifierTypes.d.ts +38 -6
  35. package/dist/types/externalIdentifierTypes.d.ts.map +1 -1
  36. package/dist/types/externalIdentifierTypes.js +16 -7
  37. package/dist/types/externalIdentifierTypes.js.map +1 -1
  38. package/dist/types/managedIdentifierTypes.d.ts +43 -15
  39. package/dist/types/managedIdentifierTypes.d.ts.map +1 -1
  40. package/dist/types/managedIdentifierTypes.js +24 -11
  41. package/dist/types/managedIdentifierTypes.js.map +1 -1
  42. package/package.json +13 -12
  43. package/plugin.schema.json +2652 -281
  44. package/src/agent/IdentifierResolution.ts +71 -11
  45. package/src/functions/LegacySupport.ts +54 -0
  46. package/src/functions/externalIdentifierFunctions.ts +101 -6
  47. package/src/functions/externalOIDFIdentifier.ts +95 -0
  48. package/src/functions/index.ts +2 -51
  49. package/src/functions/managedIdentifierFunctions.ts +162 -14
  50. package/src/types/IIdentifierResolution.ts +47 -3
  51. package/src/types/IJwtService.d.ts +226 -0
  52. package/src/types/common.ts +14 -2
  53. package/src/types/externalIdentifierTypes.ts +76 -12
  54. package/src/types/managedIdentifierTypes.ts +78 -16
@@ -1,9 +1,18 @@
1
1
  import { DidDocumentJwks } from '@sphereon/ssi-sdk-ext.did-utils'
2
- import { JWK } from '@sphereon/ssi-sdk-ext.key-utils'
3
- import { X509ValidationResult } from '@sphereon/ssi-sdk-ext.x509-utils'
2
+ import { ICoseKeyJson, JWK } from '@sphereon/ssi-types'
3
+ import { X509CertificateChainValidationOpts, X509ValidationResult } from '@sphereon/ssi-sdk-ext.x509-utils'
4
4
  import { IParsedDID } from '@sphereon/ssi-types'
5
5
  import { DIDDocument, DIDDocumentSection, DIDResolutionResult } from '@veramo/core'
6
- import { isDidIdentifier, isJwkIdentifier, isJwksUrlIdentifier, isKidIdentifier, isOidcDiscoveryIdentifier, isX5cIdentifier, JwkInfo } from './common'
6
+ import {
7
+ isCoseKeyIdentifier,
8
+ isDidIdentifier, isOIDFEntityIdIdentifier,
9
+ isJwkIdentifier,
10
+ isJwksUrlIdentifier,
11
+ isKidIdentifier,
12
+ isOidcDiscoveryIdentifier,
13
+ isX5cIdentifier,
14
+ JwkInfo,
15
+ } from './common'
7
16
 
8
17
  /**
9
18
  * Use whenever we need to resolve an external identifier. We can pass in kids, DIDs, and x5chains
@@ -32,7 +41,14 @@ export function isExternalIdentifierDidOpts(opts: ExternalIdentifierOptsBase): o
32
41
  return ('method' in opts && opts.method === 'did') || isDidIdentifier(identifier)
33
42
  }
34
43
 
35
- export type ExternalIdentifierOpts = (ExternalIdentifierJwkOpts | ExternalIdentifierX5cOpts | ExternalIdentifierDidOpts | ExternalIdentifierKidOpts) &
44
+ export type ExternalIdentifierOpts = (
45
+ | ExternalIdentifierJwkOpts
46
+ | ExternalIdentifierX5cOpts
47
+ | ExternalIdentifierDidOpts
48
+ | ExternalIdentifierKidOpts
49
+ | ExternalIdentifierCoseKeyOpts
50
+ | ExternalIdentifierOIDFEntityIdOpts
51
+ ) &
36
52
  ExternalIdentifierOptsBase
37
53
 
38
54
  export type ExternalIdentifierKidOpts = Omit<ExternalIdentifierOptsBase, 'method'> & {
@@ -48,6 +64,7 @@ export function isExternalIdentifierKidOpts(opts: ExternalIdentifierOptsBase): o
48
64
  export type ExternalIdentifierJwkOpts = Omit<ExternalIdentifierOptsBase, 'method'> & {
49
65
  method?: 'jwk'
50
66
  identifier: JWK
67
+ x5c?: ExternalIdentifierX5cOpts
51
68
  }
52
69
 
53
70
  export function isExternalIdentifierJwkOpts(opts: ExternalIdentifierOptsBase): opts is ExternalIdentifierJwkOpts {
@@ -55,6 +72,16 @@ export function isExternalIdentifierJwkOpts(opts: ExternalIdentifierOptsBase): o
55
72
  return ('method' in opts && opts.method === 'jwk') || isJwkIdentifier(identifier)
56
73
  }
57
74
 
75
+ export type ExternalIdentifierCoseKeyOpts = Omit<ExternalIdentifierOptsBase, 'method'> & {
76
+ method?: 'cose_key'
77
+ identifier: ICoseKeyJson
78
+ }
79
+
80
+ export function isExternalIdentifierCoseKeyOpts(opts: ExternalIdentifierOptsBase): opts is ExternalIdentifierCoseKeyOpts {
81
+ const { identifier } = opts
82
+ return ('method' in opts && opts.method === 'cose_key') || isCoseKeyIdentifier(identifier)
83
+ }
84
+
58
85
  export type ExternalIdentifierOidcDiscoveryOpts = Omit<ExternalIdentifierOptsBase, 'method'> & {
59
86
  method?: 'oidc-discovery'
60
87
  identifier: string
@@ -75,28 +102,53 @@ export function isExternalIdentifierJwksUrlOpts(opts: ExternalIdentifierOptsBase
75
102
  return ('method' in opts && opts.method === 'oidc-discovery') || isJwksUrlIdentifier(identifier)
76
103
  }
77
104
 
78
- export type ExternalIdentifierX5cOpts = Omit<ExternalIdentifierOptsBase, 'method'> & {
79
- method?: 'x5c'
80
- identifier: string[]
81
- verify?: boolean // defaults to true
82
- verificationTime?: Date
83
- trustAnchors?: string[]
105
+ export type ExternalIdentifierOIDFEntityIdOpts = Omit<ExternalIdentifierOptsBase, 'method'> & {
106
+ method?: 'entity_id'
107
+ identifier: string
108
+ trustAnchors?: Array<string>
109
+ }
110
+
111
+ export function isExternalIdentifierOIDFEntityIdOpts(opts: ExternalIdentifierOptsBase): opts is ExternalIdentifierCoseKeyOpts {
112
+ const { identifier } = opts
113
+ return ('method' in opts && opts.method === 'entity_id' || 'trustAnchors' in opts) && isOIDFEntityIdIdentifier(identifier)
84
114
  }
85
115
 
116
+ export type ExternalIdentifierX5cOpts = Omit<ExternalIdentifierOptsBase, 'method'> &
117
+ X509CertificateChainValidationOpts & {
118
+ method?: 'x5c'
119
+ identifier: string[]
120
+ verify?: boolean // defaults to true
121
+ verificationTime?: Date
122
+ trustAnchors?: string[]
123
+ }
124
+
86
125
  export function isExternalIdentifierX5cOpts(opts: ExternalIdentifierOptsBase): opts is ExternalIdentifierX5cOpts {
87
126
  const { identifier } = opts
88
127
  return ('method' in opts && opts.method === 'x5c') || isX5cIdentifier(identifier)
89
128
  }
90
129
 
91
- export type ExternalIdentifierMethod = 'did' | 'jwk' | 'x5c' | 'kid' | 'oidc-discovery' | 'jwks-url' | 'oid4vci-issuer'
130
+ export type ExternalIdentifierMethod = 'did' | 'jwk' | 'x5c' | 'kid' | 'cose_key' | 'oidc-discovery' | 'jwks-url' | 'oid4vci-issuer' | 'entity_id'
92
131
 
93
- export type ExternalIdentifierResult = ExternalIdentifierDidResult | ExternalIdentifierX5cResult
132
+ export type ExternalIdentifierResult = IExternalIdentifierResultBase &
133
+ (ExternalIdentifierDidResult | ExternalIdentifierX5cResult | ExternalIdentifierJwkResult | ExternalIdentifierOIDFEntityIdResult | ExternalIdentifierCoseKeyResult )
94
134
 
95
135
  export interface IExternalIdentifierResultBase {
96
136
  method: ExternalIdentifierMethod
97
137
  jwks: Array<ExternalJwkInfo>
98
138
  }
99
139
 
140
+ export interface ExternalIdentifierJwkResult extends IExternalIdentifierResultBase {
141
+ method: 'jwk'
142
+ jwk: JWK
143
+ x5c?: ExternalIdentifierX5cResult
144
+ }
145
+
146
+ export interface ExternalIdentifierCoseKeyResult extends IExternalIdentifierResultBase {
147
+ method: 'cose_key'
148
+ coseKey: ICoseKeyJson
149
+ x5c?: ExternalIdentifierX5cResult
150
+ }
151
+
100
152
  export interface ExternalIdentifierX5cResult extends IExternalIdentifierResultBase {
101
153
  method: 'x5c'
102
154
  x5c: string[]
@@ -105,8 +157,20 @@ export interface ExternalIdentifierX5cResult extends IExternalIdentifierResultBa
105
157
  certificates: any[] // for now since our schema generator trips on pkijs Certificate(Json) object //fixme
106
158
  }
107
159
 
160
+ export type TrustedAnchor = string
161
+ export type PublicKeyHex = string
162
+ export type ErrorMessage = string
163
+
164
+ export interface ExternalIdentifierOIDFEntityIdResult extends IExternalIdentifierResultBase {
165
+ method: 'entity_id'
166
+ trustedAnchors: Record<TrustedAnchor, PublicKeyHex>
167
+ errorList?: Record<TrustedAnchor, ErrorMessage>
168
+ trustEstablished: boolean
169
+ }
170
+
108
171
  export interface ExternalJwkInfo extends JwkInfo {
109
172
  kid?: string
173
+ publicKeyHex: string
110
174
  }
111
175
 
112
176
  export interface ExternalIdentifierDidResult extends IExternalIdentifierResultBase {
@@ -1,13 +1,23 @@
1
- import { JWK } from '@sphereon/ssi-sdk-ext.key-utils'
1
+ import { ClientIdScheme } from '@sphereon/ssi-sdk-ext.x509-utils'
2
+ import { ICoseKeyJson, JWK } from '@sphereon/ssi-types'
2
3
  import { DIDDocumentSection, IIdentifier, IKey, TKeyType } from '@veramo/core'
3
- import { isDidIdentifier, isJwkIdentifier, isKeyIdentifier, isKidIdentifier, isX5cIdentifier, JwkInfo } from './common'
4
+ import {
5
+ isCoseKeyIdentifier,
6
+ isDidIdentifier,
7
+ isOID4VCIssuerIdentifier,
8
+ isJwkIdentifier,
9
+ isKeyIdentifier,
10
+ isKidIdentifier,
11
+ isX5cIdentifier,
12
+ JwkInfo
13
+ } from './common'
4
14
 
5
15
  /**
6
16
  * Use whenever we need to pass in an identifier. We can pass in kids, DIDs, IIdentifier objects and x5chains
7
17
  *
8
18
  * The functions below can be used to check the type, and they also provide the proper 'runtime' types
9
19
  */
10
- export type ManagedIdentifierType = IIdentifier /*did*/ | string /*did or kid*/ | string[] /*x5c*/ | JWK | IKey
20
+ export type ManagedIdentifierType = IIdentifier /*did*/ | string /*did or kid*/ | string[] /*x5c*/ | JWK | IKey | ICoseKeyJson
11
21
 
12
22
  export type ManagedIdentifierOpts = (
13
23
  | ManagedIdentifierJwkOpts
@@ -15,6 +25,8 @@ export type ManagedIdentifierOpts = (
15
25
  | ManagedIdentifierDidOpts
16
26
  | ManagedIdentifierKidOpts
17
27
  | ManagedIdentifierKeyOpts
28
+ | ManagedIdentifierCoseKeyOpts
29
+ | ManagedIdentifierOID4VCIssuerOpts
18
30
  ) &
19
31
  ManagedIdentifierOptsBase
20
32
 
@@ -24,9 +36,11 @@ export type ManagedIdentifierOptsBase = {
24
36
  kmsKeyRef?: string // The key reference for the KMS system. If provided this value will be used to determine the appropriate key. Otherwise it will be inferred
25
37
  issuer?: string // can be used when a specific issuer needs to end up, for instance when signing JWTs. Will be returned or inferred if not provided
26
38
  kid?: string // can be used when a specific kid value needs to be used. For instance when signing JWTs. Will be returned or inferred if not provided
39
+ clientId?: string
40
+ clientIdScheme?: ClientIdScheme | 'did' | string
27
41
  }
28
42
 
29
- export type ManagedIdentifierDidOpts = Omit<ManagedIdentifierOptsBase, 'method'> & {
43
+ export type ManagedIdentifierDidOpts = Omit<ManagedIdentifierOptsBase, 'method' | 'identifier'> & {
30
44
  method?: 'did'
31
45
  identifier: IIdentifier | string
32
46
  keyType?: TKeyType
@@ -41,7 +55,7 @@ export function isManagedIdentifierDidOpts(opts: ManagedIdentifierOptsBase): opt
41
55
  return ('method' in opts && opts.method === 'did') || isDidIdentifier(identifier)
42
56
  }
43
57
 
44
- export type ManagedIdentifierKidOpts = Omit<ManagedIdentifierOptsBase, 'method'> & {
58
+ export type ManagedIdentifierKidOpts = Omit<ManagedIdentifierOptsBase, 'method' | 'identifier'> & {
45
59
  method?: 'kid'
46
60
  identifier: string
47
61
  }
@@ -51,17 +65,37 @@ export function isManagedIdentifierKidOpts(opts: ManagedIdentifierOptsBase): opt
51
65
  return ('method' in opts && opts.method === 'kid') || isKidIdentifier(identifier)
52
66
  }
53
67
 
54
- export type ManagedIdentifierKeyOpts = Omit<ManagedIdentifierOptsBase, 'method'> & {
68
+ export type ManagedIdentifierKeyOpts = Omit<ManagedIdentifierOptsBase, 'method' | 'identifier'> & {
55
69
  method?: 'key'
56
70
  identifier: IKey
57
71
  }
58
72
 
59
- export function isManagedIdentifierKeyOpts(opts: ManagedIdentifierOptsBase): opts is ManagedIdentifierKidOpts {
73
+ export function isManagedIdentifierKeyOpts(opts: ManagedIdentifierOptsBase): opts is ManagedIdentifierKeyOpts {
60
74
  const { identifier } = opts
61
75
  return ('method' in opts && opts.method === 'key') || isKeyIdentifier(identifier)
62
76
  }
63
77
 
64
- export type ManagedIdentifierJwkOpts = Omit<ManagedIdentifierOptsBase, 'method'> & {
78
+ export type ManagedIdentifierCoseKeyOpts = Omit<ManagedIdentifierOptsBase, 'method' | 'identifier'> & {
79
+ method?: 'cose_key'
80
+ identifier: ICoseKeyJson
81
+ }
82
+
83
+ export function isManagedIdentifierCoseKeyOpts(opts: ManagedIdentifierOptsBase): opts is ManagedIdentifierCoseKeyOpts {
84
+ const { identifier } = opts
85
+ return ('method' in opts && opts.method === 'cose_key') || isCoseKeyIdentifier(identifier)
86
+ }
87
+
88
+ export type ManagedIdentifierOID4VCIssuerOpts = Omit<ManagedIdentifierOptsBase, 'method' | 'identifier'> & {
89
+ method?: 'oid4vci-issuer'
90
+ identifier: string
91
+ }
92
+
93
+ export function isManagedIdentifierOID4VCIssuerOpts(opts: ManagedIdentifierOptsBase): opts is ManagedIdentifierCoseKeyOpts {
94
+ const { identifier } = opts
95
+ return ('method' in opts && opts.method === 'oid4vci-issuer') || isOID4VCIssuerIdentifier(identifier)
96
+ }
97
+
98
+ export type ManagedIdentifierJwkOpts = Omit<ManagedIdentifierOptsBase, 'method' | 'identifier'> & {
65
99
  method?: 'jwk'
66
100
  identifier: JWK
67
101
  }
@@ -71,7 +105,7 @@ export function isManagedIdentifierJwkOpts(opts: ManagedIdentifierOptsBase): opt
71
105
  return ('method' in opts && opts.method === 'jwk') || isJwkIdentifier(identifier)
72
106
  }
73
107
 
74
- export type ManagedIdentifierX5cOpts = Omit<ManagedIdentifierOptsBase, 'method'> & {
108
+ export type ManagedIdentifierX5cOpts = Omit<ManagedIdentifierOptsBase, 'method' | 'identifier'> & {
75
109
  method?: 'x5c'
76
110
  identifier: string[]
77
111
  }
@@ -91,6 +125,13 @@ export interface IManagedIdentifierResultBase extends ManagedJwkInfo {
91
125
  key: IKey
92
126
  kid?: string
93
127
  issuer?: string
128
+ clientId?: string
129
+ clientIdScheme?: ClientIdScheme | 'did' | string
130
+ identifier: ManagedIdentifierType
131
+ }
132
+
133
+ export function isManagedIdentifierCoseKeyResult(object: IManagedIdentifierResultBase): object is ManagedIdentifierCoseKeyResult {
134
+ return object!! && typeof object === 'object' && 'method' in object && object.method === 'cose_key'
94
135
  }
95
136
 
96
137
  export function isManagedIdentifierDidResult(object: IManagedIdentifierResultBase): object is ManagedIdentifierDidResult {
@@ -126,30 +167,51 @@ export interface ManagedIdentifierDidResult extends IManagedIdentifierResultBase
126
167
  }
127
168
 
128
169
  export interface ManagedIdentifierJwkResult extends IManagedIdentifierResultBase {
170
+ identifier: JWK
129
171
  method: 'jwk'
130
172
  }
131
173
 
132
174
  export interface ManagedIdentifierKidResult extends IManagedIdentifierResultBase {
133
175
  method: 'kid'
134
- issuer: string
176
+ identifier: string
135
177
  kid: string
136
178
  }
137
179
 
138
180
  export interface ManagedIdentifierKeyResult extends IManagedIdentifierResultBase {
139
181
  method: 'key'
140
- issuer: string
141
- kid: string
182
+ identifier: IKey
183
+ }
184
+
185
+ export interface ManagedIdentifierCoseKeyResult extends IManagedIdentifierResultBase {
186
+ method: 'cose_key'
187
+ identifier: ICoseKeyJson
188
+ }
189
+
190
+ export interface ManagedIdentifierOID4VCIssuerResult extends IManagedIdentifierResultBase {
191
+ method: 'oid4vci-issuer'
192
+ identifier: string
142
193
  }
143
194
 
144
195
  export interface ManagedIdentifierX5cResult extends IManagedIdentifierResultBase {
145
196
  method: 'x5c'
197
+ identifier: string[]
146
198
  x5c: string[]
147
199
  certificate: any // Certificate(JSON_, but trips schema generator. Probably want to create our own DTO
148
200
  }
149
201
 
150
- export type ManagedIdentifierMethod = 'did' | 'jwk' | 'x5c' | 'kid' | 'key'
202
+ export type ManagedIdentifierMethod = 'did' | 'jwk' | 'x5c' | 'kid' | 'key' | 'cose_key' | 'oid4vci-issuer'
151
203
 
152
204
  export type ManagedIdentifierResult = IManagedIdentifierResultBase &
153
- (ManagedIdentifierX5cResult | ManagedIdentifierDidResult | ManagedIdentifierJwkResult | ManagedIdentifierKidResult | ManagedIdentifierKeyResult)
154
-
155
- export type ManagedIdentifierOptsOrResult = ManagedIdentifierResult | ManagedIdentifierOpts
205
+ (
206
+ | ManagedIdentifierX5cResult
207
+ | ManagedIdentifierDidResult
208
+ | ManagedIdentifierJwkResult
209
+ | ManagedIdentifierKidResult
210
+ | ManagedIdentifierKeyResult
211
+ | ManagedIdentifierCoseKeyResult
212
+ | ManagedIdentifierOID4VCIssuerResult
213
+ )
214
+
215
+ export type ManagedIdentifierOptsOrResult = (ManagedIdentifierResult | ManagedIdentifierOpts) & {
216
+ lazyDisabled?: boolean
217
+ }