@sphereon/ssi-sdk.siopv2-oid4vp-op-auth 0.34.1-fix.223 → 0.34.1-fix.247

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.d.cts CHANGED
@@ -5,7 +5,7 @@ import { DIDDocument } from '@sphereon/did-uni-client';
5
5
  import { ManagedIdentifierOptsOrResult, IIdentifierResolution } from '@sphereon/ssi-sdk-ext.identifier-resolution';
6
6
  import { JwsPayload, IJwtService } from '@sphereon/ssi-sdk-ext.jwt-service';
7
7
  import { UniqueDigitalCredential, ICredentialStore } from '@sphereon/ssi-sdk.credential-store';
8
- import { ICredentialLocaleBranding, Party, DidAuthConfig, Identity } from '@sphereon/ssi-sdk.data-store';
8
+ import { ICredentialLocaleBranding, Party, DidAuthConfig, Identity } from '@sphereon/ssi-sdk.data-store-types';
9
9
  import { IPDManager } from '@sphereon/ssi-sdk.pd-manager';
10
10
  import { ISDJwtPlugin } from '@sphereon/ssi-sdk.sd-jwt';
11
11
  import { HasherSync, PresentationSubmission, W3CVerifiablePresentation, OriginalVerifiableCredential } from '@sphereon/ssi-types';
@@ -533,7 +533,7 @@ type OnContactIdentityCreatedArgs = {
533
533
  type OnIdentifierCreatedArgs = {
534
534
  identifier: IIdentifier;
535
535
  };
536
- type RequiredContext = IAgentContext<IContactManager & IDidAuthSiopOpAuthenticator & IDIDManager & IResolver & IIdentifierResolution & ICredentialStore & IIssuanceBranding>;
536
+ type RequiredContext = IAgentContext<IContactManager & IDidAuthSiopOpAuthenticator & IDIDManager & IResolver & IIdentifierResolution & ICredentialStore & IIssuanceBranding & ISDJwtPlugin>;
537
537
 
538
538
  type Siopv2MachineContext = {
539
539
  url: string;
package/dist/index.d.ts CHANGED
@@ -5,7 +5,7 @@ import { DIDDocument } from '@sphereon/did-uni-client';
5
5
  import { ManagedIdentifierOptsOrResult, IIdentifierResolution } from '@sphereon/ssi-sdk-ext.identifier-resolution';
6
6
  import { JwsPayload, IJwtService } from '@sphereon/ssi-sdk-ext.jwt-service';
7
7
  import { UniqueDigitalCredential, ICredentialStore } from '@sphereon/ssi-sdk.credential-store';
8
- import { ICredentialLocaleBranding, Party, DidAuthConfig, Identity } from '@sphereon/ssi-sdk.data-store';
8
+ import { ICredentialLocaleBranding, Party, DidAuthConfig, Identity } from '@sphereon/ssi-sdk.data-store-types';
9
9
  import { IPDManager } from '@sphereon/ssi-sdk.pd-manager';
10
10
  import { ISDJwtPlugin } from '@sphereon/ssi-sdk.sd-jwt';
11
11
  import { HasherSync, PresentationSubmission, W3CVerifiablePresentation, OriginalVerifiableCredential } from '@sphereon/ssi-types';
@@ -533,7 +533,7 @@ type OnContactIdentityCreatedArgs = {
533
533
  type OnIdentifierCreatedArgs = {
534
534
  identifier: IIdentifier;
535
535
  };
536
- type RequiredContext = IAgentContext<IContactManager & IDidAuthSiopOpAuthenticator & IDIDManager & IResolver & IIdentifierResolution & ICredentialStore & IIssuanceBranding>;
536
+ type RequiredContext = IAgentContext<IContactManager & IDidAuthSiopOpAuthenticator & IDIDManager & IResolver & IIdentifierResolution & ICredentialStore & IIssuanceBranding & ISDJwtPlugin>;
537
537
 
538
538
  type Siopv2MachineContext = {
539
539
  url: string;
package/dist/index.js CHANGED
@@ -367,7 +367,7 @@ var plugin_schema_default = {
367
367
 
368
368
  // src/agent/DidAuthSiopOpAuthenticator.ts
369
369
  import { decodeUriAsJson } from "@sphereon/did-auth-siop";
370
- import { ConnectionType as ConnectionType2, CorrelationIdentifierType, IdentityOrigin } from "@sphereon/ssi-sdk.data-store";
370
+ import { ConnectionType as ConnectionType2, CorrelationIdentifierType, IdentityOrigin } from "@sphereon/ssi-sdk.data-store-types";
371
371
  import { Loggers as Loggers4, CredentialRole as CredentialRole2 } from "@sphereon/ssi-types";
372
372
  import { v4 as uuidv4 } from "uuid";
373
373
 
@@ -1287,11 +1287,13 @@ var Siopv2Machine = class {
1287
1287
  };
1288
1288
 
1289
1289
  // src/services/Siopv2MachineService.ts
1290
+ import { calculateSdHash } from "@sphereon/pex/dist/main/lib/utils/index.js";
1290
1291
  import { getOrCreatePrimaryIdentifier, SupportedDidMethodEnum } from "@sphereon/ssi-sdk-ext.did-utils";
1291
1292
  import { isOID4VCIssuerIdentifier } from "@sphereon/ssi-sdk-ext.identifier-resolution";
1292
1293
  import { encodeJoseBlob } from "@sphereon/ssi-sdk.core";
1293
1294
  import { verifiableCredentialForRoleFilter } from "@sphereon/ssi-sdk.credential-store";
1294
- import { ConnectionType } from "@sphereon/ssi-sdk.data-store";
1295
+ import { ConnectionType } from "@sphereon/ssi-sdk.data-store-types";
1296
+ import { defaultGenerateDigest } from "@sphereon/ssi-sdk.sd-jwt";
1295
1297
  import { CredentialMapper as CredentialMapper3, CredentialRole, Loggers as Loggers3 } from "@sphereon/ssi-types";
1296
1298
  import { DcqlPresentation, DcqlQuery } from "dcql";
1297
1299
 
@@ -1333,6 +1335,7 @@ function convertToDcqlCredentials(credential, hasher) {
1333
1335
  __name(convertToDcqlCredentials, "convertToDcqlCredentials");
1334
1336
 
1335
1337
  // src/services/Siopv2MachineService.ts
1338
+ var CLOCK_SKEW = 120;
1336
1339
  var logger3 = Loggers3.DEFAULT.get(LOGGER_NAMESPACE);
1337
1340
  var siopSendAuthorizationResponse = /* @__PURE__ */ __name(async (connectionType, args, context) => {
1338
1341
  const { agent } = context;
@@ -1413,8 +1416,23 @@ var siopSendAuthorizationResponse = /* @__PURE__ */ __name(async (connectionType
1413
1416
  if (!originalVc) {
1414
1417
  continue;
1415
1418
  }
1419
+ const decodedSdJwt = await CredentialMapper3.decodeSdJwtVcAsync(originalVc, defaultGenerateDigest);
1420
+ const updatedSdJwt = updateSdJwtCredential(decodedSdJwt, request.requestObject?.getPayload()?.nonce, domain);
1421
+ const presentationResult = await context.agent.createSdJwtPresentation({
1422
+ presentation: updatedSdJwt.compactSdJwtVc,
1423
+ kb: {
1424
+ payload: {
1425
+ ...updatedSdJwt.kbJwt?.payload,
1426
+ // FIXME SSISDK-44
1427
+ nonce: updatedSdJwt.kbJwt?.payload.nonce ?? request.requestObject.getPayload().nonce,
1428
+ // FIXME SSISDK-44
1429
+ aud: updatedSdJwt.kbJwt?.payload.aud ?? domain,
1430
+ iat: updatedSdJwt.kbJwt?.payload?.iat ?? Math.floor(Date.now() / 1e3 - CLOCK_SKEW)
1431
+ }
1432
+ }
1433
+ });
1416
1434
  if (originalVc) {
1417
- presentation[key] = originalVc;
1435
+ presentation[key] = presentationResult.presentation;
1418
1436
  }
1419
1437
  }
1420
1438
  }
@@ -1507,6 +1525,31 @@ var translateCorrelationIdToName = /* @__PURE__ */ __name(async (correlationId,
1507
1525
  }
1508
1526
  return contacts[0].contact.displayName;
1509
1527
  }, "translateCorrelationIdToName");
1528
+ var updateSdJwtCredential = /* @__PURE__ */ __name((credential, nonce, aud) => {
1529
+ const sdJwtCredential = credential;
1530
+ const hashAlg = sdJwtCredential.signedPayload._sd_alg ?? "sha-256";
1531
+ const sdHash = calculateSdHash(sdJwtCredential.compactSdJwtVc, hashAlg, defaultGenerateDigest);
1532
+ const kbJwt = {
1533
+ // alg MUST be set by the signer
1534
+ header: {
1535
+ typ: "kb+jwt"
1536
+ },
1537
+ payload: {
1538
+ iat: Math.floor((/* @__PURE__ */ new Date()).getTime() / 1e3),
1539
+ sd_hash: sdHash,
1540
+ ...nonce && {
1541
+ nonce
1542
+ },
1543
+ ...aud && {
1544
+ aud
1545
+ }
1546
+ }
1547
+ };
1548
+ return {
1549
+ ...sdJwtCredential,
1550
+ kbJwt
1551
+ };
1552
+ }, "updateSdJwtCredential");
1510
1553
 
1511
1554
  // src/agent/DidAuthSiopOpAuthenticator.ts
1512
1555
  var logger4 = Loggers4.DEFAULT.options(LOGGER_NAMESPACE, {}).get(LOGGER_NAMESPACE);