@sphereon/ssi-sdk.siopv2-oid4vp-op-auth 0.33.1-feature.vcdm2.tsup.26 → 0.33.1-feature.vcdm2.tsup.27

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
@@ -870,7 +870,7 @@ var import_ssi_types = require("@sphereon/ssi-types");
870
870
  var import_uuid = require("uuid");
871
871
  var import_pex2 = require("@sphereon/pex");
872
872
  var import_ssi_types2 = require("@sphereon/ssi-types");
873
- var debug = import_ssi_types2.Loggers.DEFAULT.get("sphereon:oid4vp:OpSession").debug;
873
+ var logger = import_ssi_types2.Loggers.DEFAULT.get("sphereon:oid4vp:OpSession");
874
874
  var OpSession = class _OpSession {
875
875
  static {
876
876
  __name(this, "OpSession");
@@ -936,9 +936,9 @@ var OpSession = class _OpSession {
936
936
  didPrefix,
937
937
  agentMethods
938
938
  });
939
- debug(`RP supports subject syntax types: ${JSON.stringify(this.getSubjectSyntaxTypesSupported())}`);
939
+ logger.debug(`RP supports subject syntax types: ${JSON.stringify(this.getSubjectSyntaxTypesSupported())}`);
940
940
  if (rpMethods.dids.length === 0) {
941
- debug(`RP does not support DIDs. Supported: ${JSON.stringify(this.getSubjectSyntaxTypesSupported())}`);
941
+ logger.debug(`RP does not support DIDs. Supported: ${JSON.stringify(this.getSubjectSyntaxTypesSupported())}`);
942
942
  return [];
943
943
  }
944
944
  let intersection;
@@ -956,7 +956,7 @@ var OpSession = class _OpSession {
956
956
  }
957
957
  getAgentDIDMethodsSupported(opts) {
958
958
  const agentMethods = this.options.supportedDIDMethods?.map((method) => convertDidMethod(method, opts.didPrefix));
959
- debug(`agent methods: ${JSON.stringify(agentMethods)}`);
959
+ logger.debug(`agent methods: ${JSON.stringify(agentMethods)}`);
960
960
  return agentMethods;
961
961
  }
962
962
  async getSubjectSyntaxTypesSupported() {
@@ -967,15 +967,15 @@ var OpSession = class _OpSession {
967
967
  async getRPDIDMethodsSupported(opts) {
968
968
  let keyType;
969
969
  const agentMethods = (opts.agentMethods ?? this.getAgentDIDMethodsSupported(opts))?.map((method) => convertDidMethod(method, opts.didPrefix)) ?? [];
970
- debug(`agent methods supported: ${JSON.stringify(agentMethods)}`);
970
+ logger.debug(`agent methods supported: ${JSON.stringify(agentMethods)}`);
971
971
  const authReq = await this.getAuthorizationRequest();
972
972
  const subjectSyntaxTypesSupported = authReq.registrationMetadataPayload?.subject_syntax_types_supported?.map((method) => convertDidMethod(method, opts.didPrefix)).filter((val) => !val.startsWith("did"));
973
- debug(`subject syntax types supported in rp method supported: ${JSON.stringify(subjectSyntaxTypesSupported)}`);
973
+ logger.debug(`subject syntax types supported in rp method supported: ${JSON.stringify(subjectSyntaxTypesSupported)}`);
974
974
  const aud = await authReq.authorizationRequest.getMergedProperty("aud");
975
975
  let rpMethods = [];
976
976
  if (aud && aud.startsWith("did:")) {
977
977
  const didMethod = convertDidMethod((0, import_ssi_types.parseDid)(aud).method, opts.didPrefix);
978
- debug(`aud did method: ${didMethod}`);
978
+ logger.debug(`aud did method: ${didMethod}`);
979
979
  if (subjectSyntaxTypesSupported && subjectSyntaxTypesSupported.length > 0 && !subjectSyntaxTypesSupported.includes("did") && !subjectSyntaxTypesSupported.includes(didMethod)) {
980
980
  throw Error(`The aud DID method ${didMethod} is not in the supported types ${subjectSyntaxTypesSupported}`);
981
981
  }
@@ -990,7 +990,7 @@ var OpSession = class _OpSession {
990
990
  const isEBSI = rpMethods.length === 0 && (authReq.issuer?.includes(".ebsi.eu") || (await authReq.authorizationRequest.getMergedProperty("client_id"))?.includes(".ebsi.eu"));
991
991
  let codecName = void 0;
992
992
  if (isEBSI && (!aud || !aud.startsWith("http"))) {
993
- debug(`EBSI detected, adding did:key to supported DID methods for RP`);
993
+ logger.debug(`EBSI detected, adding did:key to supported DID methods for RP`);
994
994
  const didKeyMethod = convertDidMethod("did:key", opts.didPrefix);
995
995
  if (!agentMethods?.includes(didKeyMethod)) {
996
996
  throw Error(`EBSI detected, but agent did not support did:key. Please reconfigure agent`);
@@ -1009,13 +1009,13 @@ var OpSession = class _OpSession {
1009
1009
  }
1010
1010
  async getSupportedIdentifiers(opts) {
1011
1011
  const methods = await this.getSupportedDIDMethods(true);
1012
- debug(`supported DID methods (did: prefix = true): ${JSON.stringify(methods)}`);
1012
+ logger.debug(`supported DID methods (did: prefix = true): ${JSON.stringify(methods)}`);
1013
1013
  if (methods.length === 0) {
1014
1014
  throw Error(`No DID methods are supported`);
1015
1015
  }
1016
1016
  const identifiers = await this.context.agent.didManagerFind().then((ids) => ids.filter((id) => methods.includes(id.provider)));
1017
1017
  if (identifiers.length === 0) {
1018
- debug(`No identifiers available in agent supporting methods ${JSON.stringify(methods)}`);
1018
+ logger.debug(`No identifiers available in agent supporting methods ${JSON.stringify(methods)}`);
1019
1019
  if (opts?.createInCaseNoDIDFound !== false) {
1020
1020
  const { codecName, keyType } = await this.getRPDIDMethodsSupported({
1021
1021
  didPrefix: true,
@@ -1029,11 +1029,11 @@ var OpSession = class _OpSession {
1029
1029
  type: keyType
1030
1030
  }
1031
1031
  });
1032
- debug(`Created a new identifier for the SIOP interaction: ${identifier.did}`);
1032
+ logger.debug(`Created a new identifier for the SIOP interaction: ${identifier.did}`);
1033
1033
  identifiers.push(identifier);
1034
1034
  }
1035
1035
  }
1036
- debug(`supported identifiers: ${JSON.stringify(identifiers.map((id) => id.did))}`);
1036
+ logger.debug(`supported identifiers: ${JSON.stringify(identifiers.map((id) => id.did))}`);
1037
1037
  return identifiers;
1038
1038
  }
1039
1039
  async getSupportedDIDs() {
@@ -1257,7 +1257,7 @@ var translate = Localization.translate;
1257
1257
 
1258
1258
  // src/machine/Siopv2Machine.ts
1259
1259
  var import_ssi_types3 = require("@sphereon/ssi-types");
1260
- var logger = import_ssi_types3.Loggers.DEFAULT.get(LOGGER_NAMESPACE);
1260
+ var logger2 = import_ssi_types3.Loggers.DEFAULT.get(LOGGER_NAMESPACE);
1261
1261
  var Siopv2HasNoContactGuard = /* @__PURE__ */ __name((_ctx, _event) => {
1262
1262
  const { contact } = _ctx;
1263
1263
  return contact === void 0;
@@ -1587,7 +1587,7 @@ var Siopv2Machine = class {
1587
1587
  __name(this, "Siopv2Machine");
1588
1588
  }
1589
1589
  static newInstance(opts) {
1590
- logger.info("New Siopv2Machine instance");
1590
+ logger2.info("New Siopv2Machine instance");
1591
1591
  const interpreter = (0, import_xstate.interpret)(createSiopv2Machine(opts).withConfig({
1592
1592
  services: {
1593
1593
  ...opts?.services
@@ -1615,7 +1615,7 @@ var Siopv2Machine = class {
1615
1615
  });
1616
1616
  }
1617
1617
  interpreter.onTransition((snapshot) => {
1618
- logger.info("onTransition to new state", snapshot.value);
1618
+ logger2.info("onTransition to new state", snapshot.value);
1619
1619
  });
1620
1620
  return {
1621
1621
  interpreter
@@ -1699,9 +1699,9 @@ function convertToDcqlCredentials(credential, hasher) {
1699
1699
  __name(convertToDcqlCredentials, "convertToDcqlCredentials");
1700
1700
 
1701
1701
  // src/services/Siopv2MachineService.ts
1702
- var logger2 = import_ssi_types6.Loggers.DEFAULT.get(LOGGER_NAMESPACE);
1702
+ var logger3 = import_ssi_types6.Loggers.DEFAULT.get(LOGGER_NAMESPACE);
1703
1703
  var createEbsiIdentifier = /* @__PURE__ */ __name(async (agentContext) => {
1704
- logger2.log(`No EBSI key present yet. Creating a new one...`);
1704
+ logger3.log(`No EBSI key present yet. Creating a new one...`);
1705
1705
  const { result: newIdentifier, created } = await (0, import_ssi_sdk_ext5.getOrCreatePrimaryIdentifier)(agentContext, {
1706
1706
  method: import_ssi_sdk_ext5.SupportedDidMethodEnum.DID_KEY,
1707
1707
  createOpts: {
@@ -1711,7 +1711,7 @@ var createEbsiIdentifier = /* @__PURE__ */ __name(async (agentContext) => {
1711
1711
  }
1712
1712
  }
1713
1713
  });
1714
- logger2.log(`EBSI key created: ${newIdentifier.did}`);
1714
+ logger3.log(`EBSI key created: ${newIdentifier.did}`);
1715
1715
  if (created) {
1716
1716
  await agentContext.agent.emit(Siopv2HolderEvent.IDENTIFIER_CREATED, {
1717
1717
  result: newIdentifier
@@ -1741,8 +1741,8 @@ var siopSendAuthorizationResponse = /* @__PURE__ */ __name(async (connectionType
1741
1741
  });
1742
1742
  const request = await session.getAuthorizationRequest();
1743
1743
  const aud = await request.authorizationRequest.getMergedProperty("aud");
1744
- logger2.debug(`AUD: ${aud}`);
1745
- logger2.debug(JSON.stringify(request.authorizationRequest));
1744
+ logger3.debug(`AUD: ${aud}`);
1745
+ logger3.debug(JSON.stringify(request.authorizationRequest));
1746
1746
  let presentationsAndDefs;
1747
1747
  let presentationSubmission;
1748
1748
  if (await session.hasPresentationDefinitions()) {
@@ -1751,7 +1751,7 @@ var siopSendAuthorizationResponse = /* @__PURE__ */ __name(async (connectionType
1751
1751
  });
1752
1752
  const credentialsAndDefinitions = args.verifiableCredentialsWithDefinition ? args.verifiableCredentialsWithDefinition : await oid4vp.filterCredentialsAgainstAllDefinitions(import_ssi_sdk6.CredentialRole.HOLDER);
1753
1753
  const domain = await request.authorizationRequest.getMergedProperty("client_id") ?? request.issuer ?? (request.versions.includes(import_did_auth_siop4.SupportedVersion.JWT_VC_PRESENTATION_PROFILE_v1) ? "https://self-issued.me/v2/openid-vc" : "https://self-issued.me/v2");
1754
- logger2.log(`NONCE: ${session.nonce}, domain: ${domain}`);
1754
+ logger3.log(`NONCE: ${session.nonce}, domain: ${domain}`);
1755
1755
  const firstUniqueDC = credentialsAndDefinitions[0].credentials[0];
1756
1756
  if (typeof firstUniqueDC !== "object" || !("digitalCredential" in firstUniqueDC)) {
1757
1757
  return Promise.reject(Error("SiopMachine only supports UniqueDigitalCredentials for now"));
@@ -1772,7 +1772,7 @@ var siopSendAuthorizationResponse = /* @__PURE__ */ __name(async (connectionType
1772
1772
  identifier: holder
1773
1773
  });
1774
1774
  } catch (e) {
1775
- logger2.debug(`Holder DID not found: ${holder}`);
1775
+ logger3.debug(`Holder DID not found: ${holder}`);
1776
1776
  throw e;
1777
1777
  }
1778
1778
  } else if ((0, import_ssi_sdk_ext4.isOID4VCIssuerIdentifier)(digitalCredential.kmsKeyRef)) {
@@ -1805,7 +1805,7 @@ var siopSendAuthorizationResponse = /* @__PURE__ */ __name(async (connectionType
1805
1805
  if (identifier === void 0 && idOpts2 !== void 0 && await hasEbsiClient(request.authorizationRequest)) {
1806
1806
  identifier = await createEbsiIdentifier(agentContext);
1807
1807
  }
1808
- logger2.debug(`Identifier`, identifier);
1808
+ logger3.debug(`Identifier`, identifier);
1809
1809
  presentationsAndDefs = await oid4vp.createVerifiablePresentations(import_ssi_sdk6.CredentialRole.HOLDER, credentialsAndDefinitions, {
1810
1810
  idOpts: identifier,
1811
1811
  proofOpts: {
@@ -1820,8 +1820,8 @@ var siopSendAuthorizationResponse = /* @__PURE__ */ __name(async (connectionType
1820
1820
  }
1821
1821
  idOpts2 = presentationsAndDefs[0].idOpts;
1822
1822
  presentationSubmission = presentationsAndDefs[0].presentationSubmission;
1823
- logger2.log(`Definitions and locations:`, JSON.stringify(presentationsAndDefs?.[0]?.verifiablePresentations, null, 2));
1824
- logger2.log(`Presentation Submission:`, JSON.stringify(presentationSubmission, null, 2));
1823
+ logger3.log(`Definitions and locations:`, JSON.stringify(presentationsAndDefs?.[0]?.verifiablePresentations, null, 2));
1824
+ logger3.log(`Presentation Submission:`, JSON.stringify(presentationSubmission, null, 2));
1825
1825
  const mergedVerifiablePresentations = presentationsAndDefs?.flatMap((pd) => pd.verifiablePresentations) || [];
1826
1826
  return await session.sendAuthorizationResponse({
1827
1827
  ...presentationsAndDefs && {
@@ -1838,7 +1838,7 @@ var siopSendAuthorizationResponse = /* @__PURE__ */ __name(async (connectionType
1838
1838
  if (args.verifiableCredentialsWithDefinition !== void 0 && args.verifiableCredentialsWithDefinition !== null) {
1839
1839
  const vcs = args.verifiableCredentialsWithDefinition.flatMap((vcd) => vcd.credentials);
1840
1840
  const domain = await request.authorizationRequest.getMergedProperty("client_id") ?? request.issuer ?? (request.versions.includes(import_did_auth_siop4.SupportedVersion.JWT_VC_PRESENTATION_PROFILE_v1) ? "https://self-issued.me/v2/openid-vc" : "https://self-issued.me/v2");
1841
- logger2.debug(`NONCE: ${session.nonce}, domain: ${domain}`);
1841
+ logger3.debug(`NONCE: ${session.nonce}, domain: ${domain}`);
1842
1842
  const firstUniqueDC = vcs[0];
1843
1843
  if (typeof firstUniqueDC !== "object" || !("digitalCredential" in firstUniqueDC)) {
1844
1844
  return Promise.reject(Error("SiopMachine only supports UniqueDigitalCredentials for now"));
@@ -1859,7 +1859,7 @@ var siopSendAuthorizationResponse = /* @__PURE__ */ __name(async (connectionType
1859
1859
  identifier: holder
1860
1860
  });
1861
1861
  } catch (e) {
1862
- logger2.debug(`Holder DID not found: ${holder}`);
1862
+ logger3.debug(`Holder DID not found: ${holder}`);
1863
1863
  throw e;
1864
1864
  }
1865
1865
  } else if ((0, import_ssi_sdk_ext4.isOID4VCIssuerIdentifier)(digitalCredential.kmsKeyRef)) {
@@ -1914,7 +1914,7 @@ var siopSendAuthorizationResponse = /* @__PURE__ */ __name(async (connectionType
1914
1914
  }
1915
1915
  }
1916
1916
  });
1917
- logger2.debug(`Response: `, response);
1917
+ logger3.debug(`Response: `, response);
1918
1918
  return response;
1919
1919
  }
1920
1920
  }
@@ -2009,7 +2009,7 @@ var translateCorrelationIdToName = /* @__PURE__ */ __name(async (correlationId,
2009
2009
  }, "translateCorrelationIdToName");
2010
2010
 
2011
2011
  // src/agent/DidAuthSiopOpAuthenticator.ts
2012
- var logger3 = import_ssi_types7.Loggers.DEFAULT.options(LOGGER_NAMESPACE, {}).get(LOGGER_NAMESPACE);
2012
+ var logger4 = import_ssi_types7.Loggers.DEFAULT.options(LOGGER_NAMESPACE, {}).get(LOGGER_NAMESPACE);
2013
2013
  var didAuthSiopOpAuthenticatorMethods = [
2014
2014
  "cmGetContacts",
2015
2015
  "cmGetContact",
@@ -2163,7 +2163,7 @@ var DidAuthSiopOpAuthenticator = class {
2163
2163
  hasher: this.hasher
2164
2164
  }
2165
2165
  }));
2166
- logger3.debug(`session: ${JSON.stringify(session.id, null, 2)}`);
2166
+ logger4.debug(`session: ${JSON.stringify(session.id, null, 2)}`);
2167
2167
  const verifiedAuthorizationRequest = await session.getAuthorizationRequest();
2168
2168
  const clientName = verifiedAuthorizationRequest.registrationMetadataPayload?.client_name;
2169
2169
  const url = verifiedAuthorizationRequest.responseURI ?? (args.url.includes("request_uri") ? decodeURIComponent(args.url.split("?request_uri=")[1].trim()) : verifiedAuthorizationRequest.issuer ?? verifiedAuthorizationRequest.registrationMetadataPayload?.client_id);
@@ -2243,7 +2243,7 @@ var DidAuthSiopOpAuthenticator = class {
2243
2243
  contactId: contact.id,
2244
2244
  identity: addedIdentity
2245
2245
  });
2246
- logger3.info(`Contact identity created: ${JSON.stringify(addedIdentity)}`);
2246
+ logger4.info(`Contact identity created: ${JSON.stringify(addedIdentity)}`);
2247
2247
  }
2248
2248
  }
2249
2249
  async siopSendResponse(args, context) {
@@ -2365,7 +2365,7 @@ var DidAuthSiopOpAuthenticator = class {
2365
2365
 
2366
2366
  // src/machine/CallbackStateListener.ts
2367
2367
  var import_ssi_types8 = require("@sphereon/ssi-types");
2368
- var logger4 = import_ssi_types8.Loggers.DEFAULT.options("sphereon:siopv2-oid4vp:op-auth", {
2368
+ var logger5 = import_ssi_types8.Loggers.DEFAULT.options("sphereon:siopv2-oid4vp:op-auth", {
2369
2369
  defaultLogLevel: import_ssi_types8.LogLevel.DEBUG,
2370
2370
  methods: [
2371
2371
  import_ssi_types8.LogMethod.CONSOLE
@@ -2374,21 +2374,21 @@ var logger4 = import_ssi_types8.Loggers.DEFAULT.options("sphereon:siopv2-oid4vp:
2374
2374
  var OID4VPCallbackStateListener = /* @__PURE__ */ __name((callbacks) => {
2375
2375
  return async (oid4vciMachine, state) => {
2376
2376
  if (state._event.type === "internal") {
2377
- logger4.debug("oid4vpCallbackStateListener: internal event");
2377
+ logger5.debug("oid4vpCallbackStateListener: internal event");
2378
2378
  return;
2379
2379
  }
2380
- logger4.info(`VP state listener state: ${JSON.stringify(state.value)}`);
2380
+ logger5.info(`VP state listener state: ${JSON.stringify(state.value)}`);
2381
2381
  if (!callbacks || callbacks.size === 0) {
2382
- logger4.info(`VP no callbacks registered for state: ${JSON.stringify(state.value)}`);
2382
+ logger5.info(`VP no callbacks registered for state: ${JSON.stringify(state.value)}`);
2383
2383
  return;
2384
2384
  }
2385
2385
  for (const [stateKey, callback] of callbacks) {
2386
2386
  if (state.matches(stateKey)) {
2387
- logger4.log(`VP state callback for state: ${JSON.stringify(state.value)}, will execute...`);
2388
- await callback(oid4vciMachine, state).then(() => logger4.log(`VP state callback executed for state: ${JSON.stringify(state.value)}`)).catch((error) => {
2389
- logger4.error(`VP state callback failed for state: ${JSON.stringify(state.value)}, error: ${JSON.stringify(error?.message)}, ${JSON.stringify(state.event)}`);
2387
+ logger5.log(`VP state callback for state: ${JSON.stringify(state.value)}, will execute...`);
2388
+ await callback(oid4vciMachine, state).then(() => logger5.log(`VP state callback executed for state: ${JSON.stringify(state.value)}`)).catch((error) => {
2389
+ logger5.error(`VP state callback failed for state: ${JSON.stringify(state.value)}, error: ${JSON.stringify(error?.message)}, ${JSON.stringify(state.event)}`);
2390
2390
  if (error.stack) {
2391
- logger4.error(error.stack);
2391
+ logger5.error(error.stack);
2392
2392
  }
2393
2393
  });
2394
2394
  break;
@@ -2402,7 +2402,7 @@ var import_ssi_sdk9 = require("@sphereon/ssi-sdk.agent-config");
2402
2402
  var import_ssi_sdk10 = require("@sphereon/ssi-sdk.core");
2403
2403
  var import_ssi_sdk11 = require("@sphereon/ssi-sdk.xstate-machine-persistence");
2404
2404
  var import_ssi_types9 = require("@sphereon/ssi-types");
2405
- var logger5 = import_ssi_types9.Loggers.DEFAULT.options(LOGGER_NAMESPACE, {}).get(LOGGER_NAMESPACE);
2405
+ var logger6 = import_ssi_types9.Loggers.DEFAULT.options(LOGGER_NAMESPACE, {}).get(LOGGER_NAMESPACE);
2406
2406
  var Siopv2OID4VPLinkHandler = class extends import_ssi_sdk10.LinkHandlerAdapter {
2407
2407
  static {
2408
2408
  __name(this, "Siopv2OID4VPLinkHandler");
@@ -2422,7 +2422,7 @@ var Siopv2OID4VPLinkHandler = class extends import_ssi_sdk10.LinkHandlerAdapter
2422
2422
  this.idOpts = args.idOpts;
2423
2423
  }
2424
2424
  async handle(url, opts) {
2425
- logger5.debug(`handling SIOP link: ${url}`);
2425
+ logger6.debug(`handling SIOP link: ${url}`);
2426
2426
  const siopv2Machine = await this.context.agent.siopGetMachineInterpreter({
2427
2427
  url,
2428
2428
  idOpts: opts?.idOpts ?? this.idOpts,
@@ -2438,10 +2438,10 @@ var Siopv2OID4VPLinkHandler = class extends import_ssi_sdk10.LinkHandlerAdapter
2438
2438
  singletonCheck: true,
2439
2439
  noRegistration: this.noStateMachinePersistence
2440
2440
  });
2441
- logger5.debug(`SIOP machine started for link: ${url}`, init);
2441
+ logger6.debug(`SIOP machine started for link: ${url}`, init);
2442
2442
  } else {
2443
2443
  interpreter.start(opts?.machineState);
2444
- logger5.debug(`SIOP machine started for link: ${url}`);
2444
+ logger6.debug(`SIOP machine started for link: ${url}`);
2445
2445
  }
2446
2446
  }
2447
2447
  };