@sphereon/ssi-sdk.ebsi-support 0.27.0 → 0.27.1-next.10

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 (41) hide show
  1. package/dist/agent/EbsiSupport.d.ts +1 -0
  2. package/dist/agent/EbsiSupport.d.ts.map +1 -1
  3. package/dist/agent/EbsiSupport.js +207 -186
  4. package/dist/agent/EbsiSupport.js.map +1 -1
  5. package/dist/did/EbsiDidProvider.d.ts.map +1 -1
  6. package/dist/did/EbsiDidProvider.js +173 -136
  7. package/dist/did/EbsiDidProvider.js.map +1 -1
  8. package/dist/did/EbsiDidResolver.js +19 -6
  9. package/dist/did/EbsiDidResolver.js.map +1 -1
  10. package/dist/did/functions.d.ts.map +1 -1
  11. package/dist/did/functions.js +158 -120
  12. package/dist/did/functions.js.map +1 -1
  13. package/dist/did/index.js +28 -5
  14. package/dist/did/index.js.map +1 -1
  15. package/dist/did/services/EbsiRPCService.js +36 -20
  16. package/dist/did/services/EbsiRPCService.js.map +1 -1
  17. package/dist/did/services/EbsiRestService.js +37 -19
  18. package/dist/did/services/EbsiRestService.js.map +1 -1
  19. package/dist/did/types.d.ts +2 -1
  20. package/dist/did/types.d.ts.map +1 -1
  21. package/dist/did/types.js +10 -7
  22. package/dist/did/types.js.map +1 -1
  23. package/dist/functions/Attestation.js +79 -69
  24. package/dist/functions/Attestation.js.map +1 -1
  25. package/dist/functions/AttestationHeadlessCallbacks.js +91 -72
  26. package/dist/functions/AttestationHeadlessCallbacks.js.map +1 -1
  27. package/dist/functions/index.js +32 -4
  28. package/dist/functions/index.js.map +1 -1
  29. package/dist/index.d.ts +1 -1
  30. package/dist/index.d.ts.map +1 -1
  31. package/dist/index.js +26 -6
  32. package/dist/index.js.map +1 -1
  33. package/dist/types/IEbsiSupport.js +5 -2
  34. package/dist/types/IEbsiSupport.js.map +1 -1
  35. package/package.json +13 -12
  36. package/plugin.schema.json +2030 -0
  37. package/src/agent/EbsiSupport.ts +10 -0
  38. package/src/did/EbsiDidProvider.ts +18 -1
  39. package/src/did/functions.ts +2 -1
  40. package/src/did/types.ts +2 -1
  41. package/src/index.ts +1 -1
@@ -30,6 +30,16 @@ import {
30
30
 
31
31
  import { v4 } from 'uuid'
32
32
 
33
+
34
+ export const ebsiSupportMethods: Array<string> = [
35
+ 'ebsiWellknownMetadata',
36
+ 'ebsiAuthorizationServerJwks',
37
+ 'ebsiPresentationDefinitionGet',
38
+ 'ebsiAccessTokenGet',
39
+ 'ebsiCreateAttestationAuthRequestURL',
40
+ 'ebsiGetAttestation'
41
+ ]
42
+
33
43
  export class EbsiSupport implements IAgentPlugin {
34
44
  readonly schema = schema.IEbsiSupport
35
45
  readonly methods: IEbsiSupport = {
@@ -35,6 +35,7 @@ export class EbsiDidProvider extends AbstractIdentifierProvider {
35
35
  notAfter,
36
36
  secp256k1Key,
37
37
  secp256r1Key,
38
+ keys,
38
39
  accessTokenOpts,
39
40
  executeLedgerOperation = !!args.options?.accessTokenOpts,
40
41
  methodSpecificId = generateEbsiMethodSpecificId(EBSI_DID_SPEC_INFOS.V1),
@@ -48,9 +49,11 @@ export class EbsiDidProvider extends AbstractIdentifierProvider {
48
49
  const rpcId = options?.rpcId ?? randomRpcId()
49
50
 
50
51
  if (type === EBSI_DID_SPEC_INFOS.KEY) {
51
- throw new Error(`Type ${type} not supported. Please use @sphereon/ssi-sdk-ext.did-provider-key for Natural Person EBSI DIDs`)
52
+ return Promise.reject(Error(`Type ${type} not supported. Please use @sphereon/ssi-sdk-ext.did-provider-key for Natural Person EBSI DIDs`))
52
53
  } else if (!kms) {
53
54
  return Promise.reject(Error(`No KMS value provided`))
55
+ } else if (keys && keys.length > 0 && !executeLedgerOperation) {
56
+ return Promise.reject(Error(`Cannot add additional keys if ledger operation is not enabled at creation. Please add the keys later yourself`))
54
57
  }
55
58
 
56
59
  // CapabilityInvocation purpose
@@ -106,6 +109,20 @@ export class EbsiDidProvider extends AbstractIdentifierProvider {
106
109
  },
107
110
  context,
108
111
  )
112
+ if (keys && keys.length > 0) {
113
+ for (const keyOpts of keys) {
114
+ const key = await ebsiGenerateOrUseKeyPair(
115
+ {
116
+ keyOpts,
117
+ keyType: keyOpts.type ?? 'Secp256r1',
118
+ kms,
119
+ },
120
+ context,
121
+ )
122
+ const managedKeyInfo = await context.agent.keyManagerImport(key)
123
+ console.warn(`FIXME: Anchor additional key on EBSI`, managedKeyInfo)
124
+ }
125
+ }
109
126
  }
110
127
 
111
128
  debug('Created', identifier.did)
@@ -253,7 +253,8 @@ export const assertedPurposes = (args: { key?: IKeyOpts }): EbsiPublicKeyPurpose
253
253
  if (
254
254
  key?.purposes &&
255
255
  key.purposes.length > 0 &&
256
- key.purposes.every((purpose) => [EbsiPublicKeyPurpose.AssertionMethod, EbsiPublicKeyPurpose.Authentication].includes(purpose))
256
+ key.purposes.includes(EbsiPublicKeyPurpose.AssertionMethod) &&
257
+ key.purposes.includes(EbsiPublicKeyPurpose.Authentication)
257
258
  ) {
258
259
  return key.purposes
259
260
  }
package/src/did/types.ts CHANGED
@@ -83,6 +83,7 @@ export type EbsiCreateIdentifierOpts = {
83
83
  rpcId?: number
84
84
  secp256k1Key?: IKeyOpts
85
85
  secp256r1Key?: IKeyOpts
86
+ keys?: IKeyOpts[] // additional importable keys, but only in case execute ledger is true
86
87
  executeLedgerOperation?: boolean // Whether to persist on the EBSI ledger. By default looks at whether access token opts are set or not
87
88
  baseDocument?: string
88
89
  notBefore?: number
@@ -379,7 +380,7 @@ export type GetDidDocumentsResponse = {
379
380
  links: Links
380
381
  }
381
382
 
382
- type EbsiAccessTokenOpts = {
383
+ export type EbsiAccessTokenOpts = {
383
384
  attestationToOnboard?: W3CVerifiableCredential
384
385
  jwksUri?: string
385
386
  redirectUri: string
package/src/index.ts CHANGED
@@ -3,6 +3,6 @@ import { Loggers } from '@sphereon/ssi-types'
3
3
  export const logger = Loggers.DEFAULT.get('sphereon:ebsi-support')
4
4
  const schema = require('../plugin.schema.json')
5
5
  export { schema }
6
- export { EbsiSupport } from './agent/EbsiSupport'
6
+ export { EbsiSupport, ebsiSupportMethods } from './agent/EbsiSupport'
7
7
  export * from './types/IEbsiSupport'
8
8
  export { EbsiDidProvider } from './did'