@sphereon/ssi-sdk-ext.identifier-resolution 0.24.1-next.112 → 0.24.1-next.148

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 (35) hide show
  1. package/dist/agent/IdentifierResolution.d.ts +1 -0
  2. package/dist/agent/IdentifierResolution.d.ts.map +1 -1
  3. package/dist/agent/IdentifierResolution.js +7 -1
  4. package/dist/agent/IdentifierResolution.js.map +1 -1
  5. package/dist/functions/LegacySupport.js +1 -2
  6. package/dist/functions/LegacySupport.js.map +1 -1
  7. package/dist/functions/externalIdentifierFunctions.js +6 -7
  8. package/dist/functions/externalIdentifierFunctions.js.map +1 -1
  9. package/dist/functions/managedIdentifierFunctions.d.ts +2 -1
  10. package/dist/functions/managedIdentifierFunctions.d.ts.map +1 -1
  11. package/dist/functions/managedIdentifierFunctions.js +55 -13
  12. package/dist/functions/managedIdentifierFunctions.js.map +1 -1
  13. package/dist/tsdoc-metadata.json +1 -1
  14. package/dist/types/IIdentifierResolution.d.ts +2 -1
  15. package/dist/types/IIdentifierResolution.d.ts.map +1 -1
  16. package/dist/types/IIdentifierResolution.js +1 -0
  17. package/dist/types/IIdentifierResolution.js.map +1 -1
  18. package/dist/types/common.d.ts +1 -0
  19. package/dist/types/common.d.ts.map +1 -1
  20. package/dist/types/common.js +14 -11
  21. package/dist/types/common.js.map +1 -1
  22. package/dist/types/externalIdentifierTypes.js +7 -8
  23. package/dist/types/externalIdentifierTypes.js.map +1 -1
  24. package/dist/types/managedIdentifierTypes.d.ts +19 -10
  25. package/dist/types/managedIdentifierTypes.d.ts.map +1 -1
  26. package/dist/types/managedIdentifierTypes.js +20 -16
  27. package/dist/types/managedIdentifierTypes.js.map +1 -1
  28. package/package.json +12 -12
  29. package/plugin.schema.json +388 -44
  30. package/src/agent/IdentifierResolution.ts +21 -14
  31. package/src/functions/externalIdentifierFunctions.ts +1 -1
  32. package/src/functions/managedIdentifierFunctions.ts +50 -1
  33. package/src/types/IIdentifierResolution.ts +5 -0
  34. package/src/types/common.ts +5 -1
  35. package/src/types/managedIdentifierTypes.ts +38 -12
@@ -10,6 +10,7 @@ import {
10
10
  isManagedIdentifierCoseKeyOpts,
11
11
  isManagedIdentifierDidOpts,
12
12
  isManagedIdentifierDidResult,
13
+ isManagedIdentifierOID4VCIssuerOpts,
13
14
  isManagedIdentifierJwkOpts,
14
15
  isManagedIdentifierJwkResult,
15
16
  isManagedIdentifierKeyOpts,
@@ -20,6 +21,8 @@ import {
20
21
  ManagedIdentifierCoseKeyResult,
21
22
  ManagedIdentifierDidOpts,
22
23
  ManagedIdentifierDidResult,
24
+ ManagedIdentifierOID4VCIssuerOpts,
25
+ ManagedIdentifierOID4VCIssuerResult,
23
26
  ManagedIdentifierJwkOpts,
24
27
  ManagedIdentifierJwkResult,
25
28
  ManagedIdentifierKeyOpts,
@@ -270,6 +273,49 @@ export async function getManagedX5cIdentifier(
270
273
  } satisfies ManagedIdentifierX5cResult
271
274
  }
272
275
 
276
+ export async function getManagedOID4VCIssuerIdentifier(
277
+ opts: ManagedIdentifierOID4VCIssuerOpts,
278
+ context: IAgentContext<IKeyManager>
279
+ ): Promise<ManagedIdentifierOID4VCIssuerResult> {
280
+ const { identifier } = opts
281
+ const method = 'oid4vci-issuer'
282
+ // FIXME: We need to eventually determine the JWK based on the issuer. Using a dummy JWK for now
283
+ const jwk = {
284
+ "kty" : "RSA",
285
+ "kid" : "dummy-jwk-for-vci-issuer-signing",
286
+ "use" : "sig",
287
+ "n" : "pjdss8ZaDfEH6K6U7GeW2nxDqR4IP049fk1fK0lndimbMMVBdPv_hSpm8T8EtBDxrUdi1OHZfMhUixGaut-3nQ4GG9nM249oxhCtxqqNvEXrmQRGqczyLxuh-fKn9Fg--hS9UpazHpfVAFnB5aCfXoNhPuI8oByyFKMKaOVgHNqP5NBEqabiLftZD3W_lsFCPGuzr4Vp0YS7zS2hDYScC2oOMu4rGU1LcMZf39p3153Cq7bS2Xh6Y-vw5pwzF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hWOv8vpzokQPRl5cQt3NckzX3fs6xlJN4Ai2Hh2zduKFVQ2p-AF2p6Yfahscjtq-GY9cB85NxLy2IXCC0PF--Sq9LOrTE9QV988SJy_yUrAjcZ5MmECk",
294
+ "qi" : "ldHXIrEmMZVaNwGzDF9WG8sHj2mOZmQpw9yrjLK9hAsmsNr5LTyqWAqJIYZSwPTYWhY4nu2O0EY9G9uYiqewXfCKw_UngrJt8Xwfq1Zruz0YY869zPN4GiE9-9rzdZB33RBw8kIOquY3MK74FMwCihYx_LiU2YTHkaoJ3ncvtvg"
295
+ } as JWK
296
+ const jwkThumbprint = calculateJwkThumbprint({ jwk })
297
+
298
+ const key = {
299
+ kid: 'dummy-key-for-vci-issuer-signing',
300
+ kms: 'local',
301
+ type: "RSA",
302
+ publicKeyHex: '9a3f75b2e4d8b91128fc6e9a8f6782e5a4f1cba3718e58b5d0a789d6e5f52b3a'
303
+ } as IKey
304
+
305
+ return {
306
+ method,
307
+ identifier,
308
+ jwk,
309
+ jwkThumbprint,
310
+ key, // FIXME: We need construct a key as soon as we have the external VCI Issuer resolution
311
+ kmsKeyRef: identifier, // FIXME: We need use kmsKeyRef as soon as we have the external VCI Issuer resolution
312
+ issuer: identifier.replace('/.well-known/openid-credential-issuer', ''),
313
+ clientId: opts.clientId,
314
+ clientIdScheme: opts.clientIdScheme,
315
+ opts,
316
+ } satisfies ManagedIdentifierOID4VCIssuerResult
317
+ }
318
+
273
319
  export async function getManagedIdentifier(
274
320
  opts: ManagedIdentifierOptsOrResult & {
275
321
  crypto?: Crypto
@@ -292,11 +338,13 @@ export async function getManagedIdentifier(
292
338
  resolutionResult = await getManagedKeyIdentifier(opts, context)
293
339
  } else if (isManagedIdentifierCoseKeyOpts(opts)) {
294
340
  resolutionResult = await getManagedCoseKeyIdentifier(opts, context)
341
+ } else if (isManagedIdentifierOID4VCIssuerOpts(opts)) {
342
+ resolutionResult = await getManagedOID4VCIssuerIdentifier(opts, context)
295
343
  } else {
296
344
  return Promise.reject(Error(`Could not determine identifier method. Please provide explicitly`))
297
345
  }
298
346
  const { key } = resolutionResult
299
- if (!key || (isManagedIdentifierDidOpts(opts) && isManagedIdentifierDidResult(resolutionResult) && !resolutionResult.identifier)) {
347
+ if ((!key && !isManagedIdentifierOID4VCIssuerOpts(opts)) || (isManagedIdentifierDidOpts(opts) && isManagedIdentifierDidResult(resolutionResult) && !resolutionResult.identifier)) {
300
348
  console.log(`Cannot find identifier`, opts.identifier)
301
349
  return Promise.reject(`Cannot find identifier ${opts.identifier}`)
302
350
  }
@@ -311,6 +359,7 @@ export async function managedIdentifierToKeyResult(
311
359
  if (isManagedIdentifierKeyResult(resolved)) {
312
360
  return resolved
313
361
  }
362
+
314
363
  return {
315
364
  ...resolved,
316
365
  method: 'key',
@@ -16,6 +16,8 @@ import {
16
16
  ManagedIdentifierCoseKeyResult,
17
17
  ManagedIdentifierDidOpts,
18
18
  ManagedIdentifierDidResult,
19
+ ManagedIdentifierOID4VCIssuerOpts,
20
+ ManagedIdentifierOID4VCIssuerResult,
19
21
  ManagedIdentifierJwkOpts,
20
22
  ManagedIdentifierJwkResult,
21
23
  ManagedIdentifierKeyOpts,
@@ -36,6 +38,7 @@ export const identifierResolutionContextMethods: Array<string> = [
36
38
  'identifierManagedGetByJwk',
37
39
  'identifierManagedGetByX5c',
38
40
  'identifierManagedGetByKey',
41
+ 'identifierManagedGetByOID4VCIssuer',
39
42
  'identifierGetManagedByCoseKey',
40
43
  'identifierExternalResolve',
41
44
  'identifierExternalResolveByDid',
@@ -77,6 +80,8 @@ export interface IIdentifierResolution extends IPluginMethodMap {
77
80
  context: IAgentContext<IKeyManager & IIdentifierResolution>
78
81
  ): Promise<ManagedIdentifierCoseKeyResult>
79
82
 
83
+ identifierManagedGetByOID4VCIssuer(args: ManagedIdentifierOID4VCIssuerOpts, context: IAgentContext<any>): Promise<ManagedIdentifierOID4VCIssuerResult>
84
+
80
85
  // TODO: We can create a custom managed identifier method allowing developers to register a callback function to get their implementation hooked up. Needs more investigation as it would also impact the KMS
81
86
 
82
87
  /**
@@ -29,7 +29,11 @@ export function isJwksUrlIdentifier(identifier: ManagedIdentifierType | External
29
29
  }
30
30
 
31
31
  export function isKidIdentifier(identifier: ManagedIdentifierType | ExternalIdentifierType): identifier is string {
32
- return typeof identifier === 'string' && !identifier.startsWith('did:')
32
+ return typeof identifier === 'string' && !identifier.startsWith('did:') && !identifier.startsWith('http')
33
+ }
34
+
35
+ export function isOID4VCIssuerIdentifier(identifier: ManagedIdentifierType | ExternalIdentifierType): identifier is string {
36
+ return typeof identifier === 'string' && identifier.startsWith('http') && identifier.endsWith('/.well-known/openid-credential-issuer')
33
37
  }
34
38
 
35
39
  export function isKeyIdentifier(identifier: ManagedIdentifierType): identifier is IKey {
@@ -1,7 +1,16 @@
1
1
  import { ClientIdScheme } from '@sphereon/ssi-sdk-ext.x509-utils'
2
2
  import { ICoseKeyJson, JWK } from '@sphereon/ssi-types'
3
3
  import { DIDDocumentSection, IIdentifier, IKey, TKeyType } from '@veramo/core'
4
- import { isCoseKeyIdentifier, 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'
5
14
 
6
15
  /**
7
16
  * Use whenever we need to pass in an identifier. We can pass in kids, DIDs, IIdentifier objects and x5chains
@@ -17,6 +26,7 @@ export type ManagedIdentifierOpts = (
17
26
  | ManagedIdentifierKidOpts
18
27
  | ManagedIdentifierKeyOpts
19
28
  | ManagedIdentifierCoseKeyOpts
29
+ | ManagedIdentifierOID4VCIssuerOpts
20
30
  ) &
21
31
  ManagedIdentifierOptsBase
22
32
 
@@ -30,7 +40,7 @@ export type ManagedIdentifierOptsBase = {
30
40
  clientIdScheme?: ClientIdScheme | 'did' | string
31
41
  }
32
42
 
33
- export type ManagedIdentifierDidOpts = Omit<ManagedIdentifierOptsBase, 'method'> & {
43
+ export type ManagedIdentifierDidOpts = Omit<ManagedIdentifierOptsBase, 'method' | 'identifier'> & {
34
44
  method?: 'did'
35
45
  identifier: IIdentifier | string
36
46
  keyType?: TKeyType
@@ -45,7 +55,7 @@ export function isManagedIdentifierDidOpts(opts: ManagedIdentifierOptsBase): opt
45
55
  return ('method' in opts && opts.method === 'did') || isDidIdentifier(identifier)
46
56
  }
47
57
 
48
- export type ManagedIdentifierKidOpts = Omit<ManagedIdentifierOptsBase, 'method'> & {
58
+ export type ManagedIdentifierKidOpts = Omit<ManagedIdentifierOptsBase, 'method' | 'identifier'> & {
49
59
  method?: 'kid'
50
60
  identifier: string
51
61
  }
@@ -55,7 +65,7 @@ export function isManagedIdentifierKidOpts(opts: ManagedIdentifierOptsBase): opt
55
65
  return ('method' in opts && opts.method === 'kid') || isKidIdentifier(identifier)
56
66
  }
57
67
 
58
- export type ManagedIdentifierKeyOpts = Omit<ManagedIdentifierOptsBase, 'method'> & {
68
+ export type ManagedIdentifierKeyOpts = Omit<ManagedIdentifierOptsBase, 'method' | 'identifier'> & {
59
69
  method?: 'key'
60
70
  identifier: IKey
61
71
  }
@@ -65,7 +75,7 @@ export function isManagedIdentifierKeyOpts(opts: ManagedIdentifierOptsBase): opt
65
75
  return ('method' in opts && opts.method === 'key') || isKeyIdentifier(identifier)
66
76
  }
67
77
 
68
- export type ManagedIdentifierCoseKeyOpts = Omit<ManagedIdentifierOptsBase, 'method'> & {
78
+ export type ManagedIdentifierCoseKeyOpts = Omit<ManagedIdentifierOptsBase, 'method' | 'identifier'> & {
69
79
  method?: 'cose_key'
70
80
  identifier: ICoseKeyJson
71
81
  }
@@ -75,7 +85,17 @@ export function isManagedIdentifierCoseKeyOpts(opts: ManagedIdentifierOptsBase):
75
85
  return ('method' in opts && opts.method === 'cose_key') || isCoseKeyIdentifier(identifier)
76
86
  }
77
87
 
78
- export type ManagedIdentifierJwkOpts = Omit<ManagedIdentifierOptsBase, 'method'> & {
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'> & {
79
99
  method?: 'jwk'
80
100
  identifier: JWK
81
101
  }
@@ -85,7 +105,7 @@ export function isManagedIdentifierJwkOpts(opts: ManagedIdentifierOptsBase): opt
85
105
  return ('method' in opts && opts.method === 'jwk') || isJwkIdentifier(identifier)
86
106
  }
87
107
 
88
- export type ManagedIdentifierX5cOpts = Omit<ManagedIdentifierOptsBase, 'method'> & {
108
+ export type ManagedIdentifierX5cOpts = Omit<ManagedIdentifierOptsBase, 'method' | 'identifier'> & {
89
109
  method?: 'x5c'
90
110
  identifier: string[]
91
111
  }
@@ -110,6 +130,10 @@ export interface IManagedIdentifierResultBase extends ManagedJwkInfo {
110
130
  identifier: ManagedIdentifierType
111
131
  }
112
132
 
133
+ export function isManagedIdentifierCoseKeyResult(object: IManagedIdentifierResultBase): object is ManagedIdentifierCoseKeyResult {
134
+ return object!! && typeof object === 'object' && 'method' in object && object.method === 'cose_key'
135
+ }
136
+
113
137
  export function isManagedIdentifierDidResult(object: IManagedIdentifierResultBase): object is ManagedIdentifierDidResult {
114
138
  return object!! && typeof object === 'object' && 'method' in object && object.method === 'did'
115
139
  }
@@ -130,10 +154,6 @@ export function isManagedIdentifierKeyResult(object: IManagedIdentifierResultBas
130
154
  return object!! && typeof object === 'object' && 'method' in object && object.method === 'key'
131
155
  }
132
156
 
133
- export function isManagedIdentifierCoseKeyResult(object: IManagedIdentifierResultBase): object is ManagedIdentifierCoseKeyResult {
134
- return object!! && typeof object === 'object' && 'method' in object && object.method === 'cose_key'
135
- }
136
-
137
157
  export interface ManagedIdentifierDidResult extends IManagedIdentifierResultBase {
138
158
  method: 'did'
139
159
  identifier: IIdentifier
@@ -167,6 +187,11 @@ export interface ManagedIdentifierCoseKeyResult extends IManagedIdentifierResult
167
187
  identifier: ICoseKeyJson
168
188
  }
169
189
 
190
+ export interface ManagedIdentifierOID4VCIssuerResult extends IManagedIdentifierResultBase {
191
+ method: 'oid4vci-issuer'
192
+ identifier: string
193
+ }
194
+
170
195
  export interface ManagedIdentifierX5cResult extends IManagedIdentifierResultBase {
171
196
  method: 'x5c'
172
197
  identifier: string[]
@@ -174,7 +199,7 @@ export interface ManagedIdentifierX5cResult extends IManagedIdentifierResultBase
174
199
  certificate: any // Certificate(JSON_, but trips schema generator. Probably want to create our own DTO
175
200
  }
176
201
 
177
- export type ManagedIdentifierMethod = 'did' | 'jwk' | 'x5c' | 'kid' | 'key' | 'cose_key'
202
+ export type ManagedIdentifierMethod = 'did' | 'jwk' | 'x5c' | 'kid' | 'key' | 'cose_key' | 'oid4vci-issuer'
178
203
 
179
204
  export type ManagedIdentifierResult = IManagedIdentifierResultBase &
180
205
  (
@@ -184,6 +209,7 @@ export type ManagedIdentifierResult = IManagedIdentifierResultBase &
184
209
  | ManagedIdentifierKidResult
185
210
  | ManagedIdentifierKeyResult
186
211
  | ManagedIdentifierCoseKeyResult
212
+ | ManagedIdentifierOID4VCIssuerResult
187
213
  )
188
214
 
189
215
  export type ManagedIdentifierOptsOrResult = (ManagedIdentifierResult | ManagedIdentifierOpts) & {