@sphereon/ssi-sdk.siopv2-oid4vp-op-auth 0.34.1-feature.SSISDK.62.218 → 0.34.1-feature.SSISDK.62.224
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 +55 -12
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +46 -3
- package/dist/index.js.map +1 -1
- package/package.json +19 -19
- package/src/agent/DidAuthSiopOpAuthenticator.ts +1 -1
- package/src/machine/Siopv2Machine.ts +1 -1
- package/src/services/Siopv2MachineService.ts +56 -3
- package/src/session/OID4VP.ts +183 -184
- package/src/types/IDidAuthSiopOpAuthenticator.ts +1 -1
- package/src/types/machine/index.ts +1 -1
- package/src/types/siop-service/index.ts +11 -7
package/dist/index.cjs
CHANGED
|
@@ -424,7 +424,7 @@ var plugin_schema_default = {
|
|
|
424
424
|
|
|
425
425
|
// src/agent/DidAuthSiopOpAuthenticator.ts
|
|
426
426
|
var import_did_auth_siop4 = require("@sphereon/did-auth-siop");
|
|
427
|
-
var
|
|
427
|
+
var import_ssi_sdk7 = require("@sphereon/ssi-sdk.data-store-types");
|
|
428
428
|
var import_ssi_types7 = require("@sphereon/ssi-types");
|
|
429
429
|
var import_uuid2 = require("uuid");
|
|
430
430
|
|
|
@@ -1344,11 +1344,13 @@ var Siopv2Machine = class {
|
|
|
1344
1344
|
};
|
|
1345
1345
|
|
|
1346
1346
|
// src/services/Siopv2MachineService.ts
|
|
1347
|
+
var import_utils = require("@sphereon/pex/dist/main/lib/utils/index.js");
|
|
1347
1348
|
var import_ssi_sdk_ext3 = require("@sphereon/ssi-sdk-ext.did-utils");
|
|
1348
1349
|
var import_ssi_sdk_ext4 = require("@sphereon/ssi-sdk-ext.identifier-resolution");
|
|
1349
1350
|
var import_ssi_sdk3 = require("@sphereon/ssi-sdk.core");
|
|
1350
1351
|
var import_ssi_sdk4 = require("@sphereon/ssi-sdk.credential-store");
|
|
1351
|
-
var import_ssi_sdk5 = require("@sphereon/ssi-sdk.data-store");
|
|
1352
|
+
var import_ssi_sdk5 = require("@sphereon/ssi-sdk.data-store-types");
|
|
1353
|
+
var import_ssi_sdk6 = require("@sphereon/ssi-sdk.sd-jwt");
|
|
1352
1354
|
var import_ssi_types6 = require("@sphereon/ssi-types");
|
|
1353
1355
|
var import_dcql = require("dcql");
|
|
1354
1356
|
|
|
@@ -1390,6 +1392,7 @@ function convertToDcqlCredentials(credential, hasher) {
|
|
|
1390
1392
|
__name(convertToDcqlCredentials, "convertToDcqlCredentials");
|
|
1391
1393
|
|
|
1392
1394
|
// src/services/Siopv2MachineService.ts
|
|
1395
|
+
var CLOCK_SKEW = 120;
|
|
1393
1396
|
var logger3 = import_ssi_types6.Loggers.DEFAULT.get(LOGGER_NAMESPACE);
|
|
1394
1397
|
var siopSendAuthorizationResponse = /* @__PURE__ */ __name(async (connectionType, args, context) => {
|
|
1395
1398
|
const { agent } = context;
|
|
@@ -1470,8 +1473,23 @@ var siopSendAuthorizationResponse = /* @__PURE__ */ __name(async (connectionType
|
|
|
1470
1473
|
if (!originalVc) {
|
|
1471
1474
|
continue;
|
|
1472
1475
|
}
|
|
1476
|
+
const decodedSdJwt = await import_ssi_types6.CredentialMapper.decodeSdJwtVcAsync(originalVc, import_ssi_sdk6.defaultGenerateDigest);
|
|
1477
|
+
const updatedSdJwt = updateSdJwtCredential(decodedSdJwt, request.requestObject?.getPayload()?.nonce, domain);
|
|
1478
|
+
const presentationResult = await context.agent.createSdJwtPresentation({
|
|
1479
|
+
presentation: updatedSdJwt.compactSdJwtVc,
|
|
1480
|
+
kb: {
|
|
1481
|
+
payload: {
|
|
1482
|
+
...updatedSdJwt.kbJwt?.payload,
|
|
1483
|
+
// FIXME SSISDK-44
|
|
1484
|
+
nonce: updatedSdJwt.kbJwt?.payload.nonce ?? request.requestObject.getPayload().nonce,
|
|
1485
|
+
// FIXME SSISDK-44
|
|
1486
|
+
aud: updatedSdJwt.kbJwt?.payload.aud ?? domain,
|
|
1487
|
+
iat: updatedSdJwt.kbJwt?.payload?.iat ?? Math.floor(Date.now() / 1e3 - CLOCK_SKEW)
|
|
1488
|
+
}
|
|
1489
|
+
}
|
|
1490
|
+
});
|
|
1473
1491
|
if (originalVc) {
|
|
1474
|
-
presentation[key] =
|
|
1492
|
+
presentation[key] = presentationResult.presentation;
|
|
1475
1493
|
}
|
|
1476
1494
|
}
|
|
1477
1495
|
}
|
|
@@ -1564,6 +1582,31 @@ var translateCorrelationIdToName = /* @__PURE__ */ __name(async (correlationId,
|
|
|
1564
1582
|
}
|
|
1565
1583
|
return contacts[0].contact.displayName;
|
|
1566
1584
|
}, "translateCorrelationIdToName");
|
|
1585
|
+
var updateSdJwtCredential = /* @__PURE__ */ __name((credential, nonce, aud) => {
|
|
1586
|
+
const sdJwtCredential = credential;
|
|
1587
|
+
const hashAlg = sdJwtCredential.signedPayload._sd_alg ?? "sha-256";
|
|
1588
|
+
const sdHash = (0, import_utils.calculateSdHash)(sdJwtCredential.compactSdJwtVc, hashAlg, import_ssi_sdk6.defaultGenerateDigest);
|
|
1589
|
+
const kbJwt = {
|
|
1590
|
+
// alg MUST be set by the signer
|
|
1591
|
+
header: {
|
|
1592
|
+
typ: "kb+jwt"
|
|
1593
|
+
},
|
|
1594
|
+
payload: {
|
|
1595
|
+
iat: Math.floor((/* @__PURE__ */ new Date()).getTime() / 1e3),
|
|
1596
|
+
sd_hash: sdHash,
|
|
1597
|
+
...nonce && {
|
|
1598
|
+
nonce
|
|
1599
|
+
},
|
|
1600
|
+
...aud && {
|
|
1601
|
+
aud
|
|
1602
|
+
}
|
|
1603
|
+
}
|
|
1604
|
+
};
|
|
1605
|
+
return {
|
|
1606
|
+
...sdJwtCredential,
|
|
1607
|
+
kbJwt
|
|
1608
|
+
};
|
|
1609
|
+
}, "updateSdJwtCredential");
|
|
1567
1610
|
|
|
1568
1611
|
// src/agent/DidAuthSiopOpAuthenticator.ts
|
|
1569
1612
|
var logger4 = import_ssi_types7.Loggers.DEFAULT.options(LOGGER_NAMESPACE, {}).get(LOGGER_NAMESPACE);
|
|
@@ -1782,12 +1825,12 @@ var DidAuthSiopOpAuthenticator = class {
|
|
|
1782
1825
|
if (correlationId) {
|
|
1783
1826
|
const identity = {
|
|
1784
1827
|
alias: correlationId,
|
|
1785
|
-
origin:
|
|
1828
|
+
origin: import_ssi_sdk7.IdentityOrigin.EXTERNAL,
|
|
1786
1829
|
roles: [
|
|
1787
1830
|
import_ssi_types7.CredentialRole.ISSUER
|
|
1788
1831
|
],
|
|
1789
1832
|
identifier: {
|
|
1790
|
-
type: correlationId.startsWith("did:") ?
|
|
1833
|
+
type: correlationId.startsWith("did:") ? import_ssi_sdk7.CorrelationIdentifierType.DID : import_ssi_sdk7.CorrelationIdentifierType.URL,
|
|
1791
1834
|
correlationId
|
|
1792
1835
|
}
|
|
1793
1836
|
};
|
|
@@ -1810,7 +1853,7 @@ var DidAuthSiopOpAuthenticator = class {
|
|
|
1810
1853
|
if (authorizationRequestData === void 0) {
|
|
1811
1854
|
return Promise.reject(Error("Missing authorization request data in context"));
|
|
1812
1855
|
}
|
|
1813
|
-
const response = await siopSendAuthorizationResponse(
|
|
1856
|
+
const response = await siopSendAuthorizationResponse(import_ssi_sdk7.ConnectionType.SIOPv2_OpenID4VP, {
|
|
1814
1857
|
sessionId: didAuthConfig.sessionId,
|
|
1815
1858
|
...args.idOpts && {
|
|
1816
1859
|
idOpts: args.idOpts
|
|
@@ -1875,12 +1918,12 @@ var OID4VPCallbackStateListener = /* @__PURE__ */ __name((callbacks) => {
|
|
|
1875
1918
|
}, "OID4VPCallbackStateListener");
|
|
1876
1919
|
|
|
1877
1920
|
// src/link-handler/index.ts
|
|
1878
|
-
var
|
|
1879
|
-
var
|
|
1880
|
-
var
|
|
1921
|
+
var import_ssi_sdk8 = require("@sphereon/ssi-sdk.agent-config");
|
|
1922
|
+
var import_ssi_sdk9 = require("@sphereon/ssi-sdk.core");
|
|
1923
|
+
var import_ssi_sdk10 = require("@sphereon/ssi-sdk.xstate-machine-persistence");
|
|
1881
1924
|
var import_ssi_types9 = require("@sphereon/ssi-types");
|
|
1882
1925
|
var logger6 = import_ssi_types9.Loggers.DEFAULT.options(LOGGER_NAMESPACE, {}).get(LOGGER_NAMESPACE);
|
|
1883
|
-
var Siopv2OID4VPLinkHandler = class extends
|
|
1926
|
+
var Siopv2OID4VPLinkHandler = class extends import_ssi_sdk9.LinkHandlerAdapter {
|
|
1884
1927
|
static {
|
|
1885
1928
|
__name(this, "Siopv2OID4VPLinkHandler");
|
|
1886
1929
|
}
|
|
@@ -1906,8 +1949,8 @@ var Siopv2OID4VPLinkHandler = class extends import_ssi_sdk8.LinkHandlerAdapter {
|
|
|
1906
1949
|
stateNavigationListener: this.stateNavigationListener
|
|
1907
1950
|
});
|
|
1908
1951
|
const interpreter = siopv2Machine.interpreter;
|
|
1909
|
-
if (!this.noStateMachinePersistence && !opts?.machineState && (0,
|
|
1910
|
-
const init = await (0,
|
|
1952
|
+
if (!this.noStateMachinePersistence && !opts?.machineState && (0, import_ssi_sdk8.contextHasPlugin)(this.context, "machineStatesFindActive")) {
|
|
1953
|
+
const init = await (0, import_ssi_sdk10.interpreterStartOrResume)({
|
|
1911
1954
|
interpreter,
|
|
1912
1955
|
context: this.context,
|
|
1913
1956
|
cleanupAllOtherInstances: true,
|