@sphereon/ssi-sdk.ebsi-support 0.34.1-next.3 → 0.34.1-next.322

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.
package/dist/index.cjs CHANGED
@@ -382,7 +382,7 @@ var require_plugin_schema = __commonJS({
382
382
  di_vp: {
383
383
  $ref: "#/components/schemas/DiObject"
384
384
  },
385
- "vc+sd-jwt": {
385
+ "dc+sd-jwt": {
386
386
  $ref: "#/components/schemas/SdJwtObject"
387
387
  }
388
388
  }
@@ -2070,20 +2070,42 @@ var require_plugin_schema = __commonJS({
2070
2070
  // src/index.ts
2071
2071
  var index_exports = {};
2072
2072
  __export(index_exports, {
2073
+ BASE_CONTEXT_DOC: () => BASE_CONTEXT_DOC,
2074
+ EBSI_DID_SPEC_INFOS: () => EBSI_DID_SPEC_INFOS,
2073
2075
  EbsiDidProvider: () => EbsiDidProvider,
2076
+ EbsiPublicKeyPurpose: () => EbsiPublicKeyPurpose,
2077
+ EbsiRpcMethod: () => EbsiRpcMethod,
2074
2078
  EbsiSupport: () => EbsiSupport,
2079
+ JSON_RPC_VERSION: () => JSON_RPC_VERSION,
2075
2080
  TokenType: () => TokenType,
2081
+ assertedPurposes: () => assertedPurposes,
2082
+ determineWellknownEndpoint: () => determineWellknownEndpoint,
2083
+ ebsiCreateDidOnLedger: () => ebsiCreateDidOnLedger,
2084
+ ebsiGenerateOrUseKeyPair: () => ebsiGenerateOrUseKeyPair,
2085
+ ebsiGetAuthorisationServer: () => ebsiGetAuthorisationServer,
2086
+ ebsiGetDidDocument: () => ebsiGetDidDocument,
2087
+ ebsiGetIssuerMock: () => ebsiGetIssuerMock,
2088
+ ebsiGetRegistryAPIUrls: () => ebsiGetRegistryAPIUrls,
2089
+ ebsiListDidDocuments: () => ebsiListDidDocuments,
2090
+ ebsiSignAndSendTransaction: () => ebsiSignAndSendTransaction,
2076
2091
  ebsiSupportMethods: () => ebsiSupportMethods,
2092
+ ebsiWaitTillDocumentAnchored: () => ebsiWaitTillDocumentAnchored,
2093
+ formatEbsiPublicKey: () => formatEbsiPublicKey,
2094
+ generateEbsiMethodSpecificId: () => generateEbsiMethodSpecificId,
2095
+ generateOrUseProvidedEbsiPrivateKeyHex: () => generateOrUseProvidedEbsiPrivateKeyHex,
2096
+ getDidEbsiResolver: () => getDidEbsiResolver,
2077
2097
  logger: () => logger,
2078
- schema: () => schema
2098
+ randomRpcId: () => randomRpcId,
2099
+ schema: () => schema,
2100
+ setPurposes: () => setPurposes,
2101
+ toMinimalImportableKey: () => toMinimalImportableKey
2079
2102
  });
2080
2103
  module.exports = __toCommonJS(index_exports);
2081
- var import_ssi_types2 = require("@sphereon/ssi-types");
2104
+ var import_ssi_types3 = require("@sphereon/ssi-types");
2082
2105
 
2083
2106
  // src/agent/EbsiSupport.ts
2084
- var import_did_auth_siop2 = require("@sphereon/did-auth-siop");
2085
2107
  var import_oid4vci_common4 = require("@sphereon/oid4vci-common");
2086
- var import_ssi_types = require("@sphereon/ssi-types");
2108
+ var import_ssi_types2 = require("@sphereon/ssi-types");
2087
2109
  var import_cross_fetch4 = __toESM(require("cross-fetch"), 1);
2088
2110
 
2089
2111
  // src/did/functions.ts
@@ -2103,13 +2125,14 @@ var import_ssi_sdk_ext = require("@sphereon/ssi-sdk-ext.did-utils");
2103
2125
  var import_ssi_sdk_ext2 = require("@sphereon/ssi-sdk-ext.key-utils");
2104
2126
  var import_ssi_sdk3 = require("@sphereon/ssi-sdk.oid4vci-holder");
2105
2127
  var import_ssi_sdk4 = require("@sphereon/ssi-sdk.siopv2-oid4vp-op-auth");
2106
- var import_waitFor = require("xstate/lib/waitFor");
2128
+ var import_waitFor = require("xstate/lib/waitFor.js");
2107
2129
 
2108
2130
  // src/functions/AttestationHeadlessCallbacks.ts
2109
2131
  var import_did_auth_siop = require("@sphereon/did-auth-siop");
2110
2132
  var import_oid4vci_common = require("@sphereon/oid4vci-common");
2111
- var import_ssi_sdk = require("@sphereon/ssi-sdk.data-store");
2133
+ var import_ssi_sdk = require("@sphereon/ssi-sdk.data-store-types");
2112
2134
  var import_ssi_sdk2 = require("@sphereon/ssi-sdk.oid4vci-holder");
2135
+ var import_ssi_types = require("@sphereon/ssi-types");
2113
2136
  var import_cross_fetch = __toESM(require("cross-fetch"), 1);
2114
2137
  var addContactCallback = /* @__PURE__ */ __name((context) => {
2115
2138
  return async (oid4vciMachine, state) => {
@@ -2140,7 +2163,7 @@ var addContactCallback = /* @__PURE__ */ __name((context) => {
2140
2163
  {
2141
2164
  alias: correlationId,
2142
2165
  roles: [
2143
- import_ssi_sdk.CredentialRole.ISSUER
2166
+ import_ssi_types.CredentialRole.ISSUER
2144
2167
  ],
2145
2168
  origin: import_ssi_sdk.IdentityOrigin.EXTERNAL,
2146
2169
  identifier: {
@@ -2353,7 +2376,7 @@ var ebsiCreateAttestationAuthRequestURL = /* @__PURE__ */ __name(async ({ client
2353
2376
  createAuthorizationRequestURL: false,
2354
2377
  retrieveServerMetadata: true
2355
2378
  });
2356
- const allMatches = vciClient.getCredentialsSupported(false);
2379
+ const allMatches = {};
2357
2380
  let arrayMatches;
2358
2381
  if (Array.isArray(allMatches)) {
2359
2382
  arrayMatches = allMatches;
@@ -2370,10 +2393,14 @@ var ebsiCreateAttestationAuthRequestURL = /* @__PURE__ */ __name(async ({ client
2370
2393
  throw Error(`Could not find '${credentialType}' with format(s) '${formats.join(",")}' in list of supported types for issuer: ${credentialIssuer}`);
2371
2394
  }
2372
2395
  const authorizationDetails = supportedConfigurations.map((supported) => {
2396
+ const credential_configuration_id = supported.id;
2397
+ if (!credential_configuration_id) {
2398
+ throw Error(`Credential configuration id missing for credential type: ${credentialType}`);
2399
+ }
2373
2400
  return {
2374
2401
  type: "openid_credential",
2375
- format: supported.format,
2376
- types: (0, import_oid4vci_common2.getTypesFromCredentialSupported)(supported)
2402
+ credential_configuration_id,
2403
+ credential_identifiers: (0, import_oid4vci_common2.getTypesFromCredentialSupported)(supported)
2377
2404
  };
2378
2405
  });
2379
2406
  const signCallbacks = requestObjectOpts.signCallbacks ?? {
@@ -2573,6 +2600,24 @@ var ebsiWaitTillDocumentAnchored = /* @__PURE__ */ __name(async (args) => {
2573
2600
  count
2574
2601
  };
2575
2602
  }, "ebsiWaitTillDocumentAnchored");
2603
+ var ebsiListDidDocuments = /* @__PURE__ */ __name(async (args) => {
2604
+ const { params, apiOpts } = args;
2605
+ const { offset, size, controller } = params;
2606
+ const queryParams = [];
2607
+ if (offset) {
2608
+ queryParams.push(`page[after]=${offset}`);
2609
+ }
2610
+ if (size) {
2611
+ queryParams.push(`page[size]=${size}`);
2612
+ }
2613
+ if (controller) {
2614
+ queryParams.push(`controller=${controller}`);
2615
+ }
2616
+ const query = `?${queryParams.filter(Boolean).join("&")}`;
2617
+ return await (await (0, import_cross_fetch2.default)(`${ebsiGetRegistryAPIUrls({
2618
+ ...apiOpts
2619
+ }).query}/${query}`)).json();
2620
+ }, "ebsiListDidDocuments");
2576
2621
 
2577
2622
  // src/did/services/EbsiRPCService.ts
2578
2623
  var import_cross_fetch3 = __toESM(require("cross-fetch"), 1);
@@ -2591,12 +2636,12 @@ var EBSI_DID_SPEC_INFOS = {
2591
2636
  method: "did:key:"
2592
2637
  }
2593
2638
  };
2594
- var EbsiPublicKeyPurpose = /* @__PURE__ */ function(EbsiPublicKeyPurpose2) {
2639
+ var EbsiPublicKeyPurpose = /* @__PURE__ */ (function(EbsiPublicKeyPurpose2) {
2595
2640
  EbsiPublicKeyPurpose2["Authentication"] = "authentication";
2596
2641
  EbsiPublicKeyPurpose2["AssertionMethod"] = "assertionMethod";
2597
2642
  EbsiPublicKeyPurpose2["CapabilityInvocation"] = "capabilityInvocation";
2598
2643
  return EbsiPublicKeyPurpose2;
2599
- }({});
2644
+ })({});
2600
2645
  var JSON_RPC_VERSION = "2.0";
2601
2646
  var BASE_CONTEXT_DOC = JSON.stringify({
2602
2647
  "@context": [
@@ -2604,7 +2649,7 @@ var BASE_CONTEXT_DOC = JSON.stringify({
2604
2649
  "https://w3id.org/security/suites/jws-2020/v1"
2605
2650
  ]
2606
2651
  });
2607
- var EbsiRpcMethod = /* @__PURE__ */ function(EbsiRpcMethod2) {
2652
+ var EbsiRpcMethod = /* @__PURE__ */ (function(EbsiRpcMethod2) {
2608
2653
  EbsiRpcMethod2["INSERT_DID_DOCUMENT"] = "insertDidDocument";
2609
2654
  EbsiRpcMethod2["UPDATE_DID_DOCUMENT"] = "updateBaseDocument";
2610
2655
  EbsiRpcMethod2["ADD_VERIFICATION_METHOD"] = "addVerificationMethod";
@@ -2612,7 +2657,7 @@ var EbsiRpcMethod = /* @__PURE__ */ function(EbsiRpcMethod2) {
2612
2657
  EbsiRpcMethod2["ADD_SERVICE"] = "addService";
2613
2658
  EbsiRpcMethod2["SEND_SIGNED_TRANSACTION"] = "sendSignedTransaction";
2614
2659
  return EbsiRpcMethod2;
2615
- }({});
2660
+ })({});
2616
2661
 
2617
2662
  // src/did/services/EbsiRPCService.ts
2618
2663
  var callRpcMethod = /* @__PURE__ */ __name(async (args) => {
@@ -2730,6 +2775,14 @@ var ebsiGetIssuerMock = /* @__PURE__ */ __name((args) => {
2730
2775
  system: environment
2731
2776
  })}/issuer-mock`;
2732
2777
  }, "ebsiGetIssuerMock");
2778
+ var ebsiGetAuthorisationServer = /* @__PURE__ */ __name((args) => {
2779
+ const { environment = "pilot", version = "v4" } = args;
2780
+ return `${getEbsiApiBaseUrl({
2781
+ environment,
2782
+ version,
2783
+ system: "authorisation"
2784
+ })}`;
2785
+ }, "ebsiGetAuthorisationServer");
2733
2786
  var ebsiGetRegistryAPIUrls = /* @__PURE__ */ __name((args) => {
2734
2787
  const { environment = "pilot", version = "v5" } = args;
2735
2788
  const baseUrl = `${getEbsiApiBaseUrl({
@@ -2843,7 +2896,7 @@ var toMinimalImportableKey = /* @__PURE__ */ __name(async (args) => {
2843
2896
  minimalImportableKey.meta = {
2844
2897
  purposes: assertedPurposes({
2845
2898
  key
2846
- }) ?? setDefaultPurposes({
2899
+ }) ?? setPurposes({
2847
2900
  key,
2848
2901
  type
2849
2902
  }),
@@ -2879,7 +2932,7 @@ var assertedPurposes = /* @__PURE__ */ __name((args) => {
2879
2932
  }
2880
2933
  return key?.purposes;
2881
2934
  }, "assertedPurposes");
2882
- var setDefaultPurposes = /* @__PURE__ */ __name((args) => {
2935
+ var setPurposes = /* @__PURE__ */ __name((args) => {
2883
2936
  const { key, type } = args;
2884
2937
  if (!key?.purposes || key.purposes.length === 0) {
2885
2938
  switch (type) {
@@ -2897,7 +2950,7 @@ var setDefaultPurposes = /* @__PURE__ */ __name((args) => {
2897
2950
  }
2898
2951
  }
2899
2952
  return key.purposes;
2900
- }, "setDefaultPurposes");
2953
+ }, "setPurposes");
2901
2954
  var randomRpcId = /* @__PURE__ */ __name(() => {
2902
2955
  return Math.floor(Math.random() * Number.MAX_SAFE_INTEGER);
2903
2956
  }, "randomRpcId");
@@ -3131,7 +3184,6 @@ var ebsiCreateDidOnLedger = /* @__PURE__ */ __name(async (args, context) => {
3131
3184
 
3132
3185
  // src/agent/EbsiSupport.ts
3133
3186
  var import_uuid = require("uuid");
3134
- var import_did_auth_siop_adapter = require("@sphereon/did-auth-siop-adapter");
3135
3187
  var import_ssi_sdk5 = require("@sphereon/ssi-sdk.core");
3136
3188
  var ebsiSupportMethods = [
3137
3189
  "ebsiCreateDidOnLedger",
@@ -3223,15 +3275,15 @@ var EbsiSupport = class {
3223
3275
  let attestationCredential = args.attestationCredential;
3224
3276
  if (hasInputDescriptors && !attestationCredential) {
3225
3277
  if (allVerifiableCredentials && allVerifiableCredentials.length > 0) {
3226
- const pexResult2 = await context.agent.pexDefinitionFilterCredentials({
3278
+ const pexResult = await context.agent.pexDefinitionFilterCredentials({
3227
3279
  presentationDefinition: definitionResponse,
3228
3280
  credentialFilterOpts: {
3229
3281
  credentialRole: args.credentialRole,
3230
3282
  verifiableCredentials: allVerifiableCredentials
3231
3283
  }
3232
3284
  });
3233
- if (pexResult2.filteredCredentials.length > 0) {
3234
- const filtered = pexResult2.filteredCredentials.map((cred) => import_ssi_types.CredentialMapper.toUniformCredential(cred, {
3285
+ if (pexResult.filteredCredentials.length > 0) {
3286
+ const filtered = pexResult.filteredCredentials.map((cred) => import_ssi_types2.CredentialMapper.toUniformCredential(cred, {
3235
3287
  hasher: import_ssi_sdk5.defaultHasher
3236
3288
  })).filter((cred) => {
3237
3289
  if (!cred.expirationDate) {
@@ -3276,57 +3328,7 @@ var EbsiSupport = class {
3276
3328
  attestationCredential = attestationResult.credentials[0].rawVerifiableCredential;
3277
3329
  }
3278
3330
  }
3279
- const definition = {
3280
- definition: definitionResponse,
3281
- location: import_did_auth_siop2.PresentationDefinitionLocation.TOPLEVEL_PRESENTATION_DEF,
3282
- version: import_did_auth_siop2.SupportedVersion.SIOPv2_D11
3283
- };
3284
- const pexResult = hasInputDescriptors ? await context.agent.pexDefinitionFilterCredentials({
3285
- presentationDefinition: definitionResponse,
3286
- credentialFilterOpts: {
3287
- credentialRole: args.credentialRole,
3288
- verifiableCredentials: [
3289
- attestationCredential
3290
- ]
3291
- }
3292
- }) : {
3293
- // LOL, let's see whether we can trick PEX to create a VP without VCs
3294
- filteredCredentials: [],
3295
- id: definitionResponse.id,
3296
- selectResults: {
3297
- verifiableCredential: [],
3298
- areRequiredCredentialsPresent: "info"
3299
- }
3300
- };
3301
- const opSession = await context.agent.siopRegisterOPSession({
3302
- requestJwtOrUri: "",
3303
- op: {
3304
- checkLinkedDomains: import_did_auth_siop_adapter.CheckLinkedDomain.NEVER
3305
- },
3306
- providedPresentationDefinitions: [
3307
- definition
3308
- ]
3309
- });
3310
- const oid4vp = await opSession.getOID4VP({
3311
- allIdentifiers: [
3312
- identifier.did
3313
- ]
3314
- });
3315
- const vp = await oid4vp.createVerifiablePresentation(args.credentialRole, {
3316
- definition,
3317
- credentials: pexResult.filteredCredentials
3318
- }, {
3319
- proofOpts: {
3320
- domain: openIDMetadata.issuer,
3321
- nonce: (0, import_uuid.v4)(),
3322
- created: new Date(Date.now() - 12e4).toString()
3323
- },
3324
- holder: identifier.did,
3325
- idOpts,
3326
- skipDidResolution,
3327
- forceNoCredentialsInVP: !hasInputDescriptors
3328
- });
3329
- const presentationSubmission = hasInputDescriptors ? vp.presentationSubmission : {
3331
+ const presentationSubmission = {
3330
3332
  id: (0, import_uuid.v4)(),
3331
3333
  definition_id: definitionResponse.id,
3332
3334
  descriptor_map: []
@@ -3334,7 +3336,8 @@ var EbsiSupport = class {
3334
3336
  console.log(`Presentation submission`, presentationSubmission);
3335
3337
  const tokenRequestArgs = {
3336
3338
  grant_type: "vp_token",
3337
- vp_token: import_ssi_types.CredentialMapper.toCompactJWT(vp.verifiablePresentations[0]),
3339
+ // FIXME SSISDK-40
3340
+ vp_token: "",
3338
3341
  scope,
3339
3342
  presentation_submission: presentationSubmission,
3340
3343
  apiOpts: {
@@ -3383,10 +3386,10 @@ ${JSON.stringify(accessTokenResponse)}`);
3383
3386
  };
3384
3387
 
3385
3388
  // src/types/IEbsiSupport.ts
3386
- var TokenType = /* @__PURE__ */ function(TokenType2) {
3389
+ var TokenType = /* @__PURE__ */ (function(TokenType2) {
3387
3390
  TokenType2["BEARER"] = "Bearer";
3388
3391
  return TokenType2;
3389
- }({});
3392
+ })({});
3390
3393
 
3391
3394
  // src/did/EbsiDidProvider.ts
3392
3395
  var import_ssi_sdk_ext5 = require("@sphereon/ssi-sdk-ext.did-utils");
@@ -3597,13 +3600,25 @@ var EbsiDidProvider = class _EbsiDidProvider extends import_did_manager.Abstract
3597
3600
  // src/did/EbsiDidResolver.ts
3598
3601
  var import_did_resolver = require("did-resolver");
3599
3602
  var import_ssi_sdk_ext7 = require("@sphereon/ssi-sdk-ext.did-resolver-ebsi");
3603
+ var resolveDidEbsi = /* @__PURE__ */ __name(async (didUrl, _parsed, _resolver, options) => {
3604
+ const resolver = new import_did_resolver.Resolver({
3605
+ ...(0, import_ssi_sdk_ext7.getResolver)()
3606
+ });
3607
+ return resolver.resolve(didUrl, options);
3608
+ }, "resolveDidEbsi");
3609
+ function getDidEbsiResolver() {
3610
+ return {
3611
+ key: resolveDidEbsi
3612
+ };
3613
+ }
3614
+ __name(getDidEbsiResolver, "getDidEbsiResolver");
3600
3615
 
3601
3616
  // src/index.ts
3602
- var logger = import_ssi_types2.Loggers.DEFAULT.options("sphereon:ebsi-support", {
3603
- defaultLogLevel: import_ssi_types2.LogLevel.DEBUG,
3617
+ var logger = import_ssi_types3.Loggers.DEFAULT.options("sphereon:ebsi-support", {
3618
+ defaultLogLevel: import_ssi_types3.LogLevel.DEBUG,
3604
3619
  methods: [
3605
- import_ssi_types2.LogMethod.CONSOLE,
3606
- import_ssi_types2.LogMethod.DEBUG_PKG
3620
+ import_ssi_types3.LogMethod.CONSOLE,
3621
+ import_ssi_types3.LogMethod.DEBUG_PKG
3607
3622
  ]
3608
3623
  }).get("sphereon:ebsi-support");
3609
3624
  var schema = require_plugin_schema();