@sphereon/ssi-sdk.siopv2-oid4vp-op-auth 0.34.1-feature.SSISDK.44.finish.dcql.315 → 0.34.1-feature.SSISDK.44.finish.dcql.318
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 +31 -51
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +31 -51
- package/dist/index.js.map +1 -1
- package/package.json +22 -22
- package/src/session/OID4VP.ts +38 -65
package/dist/index.cjs
CHANGED
|
@@ -679,24 +679,6 @@ function extractOriginalCredential(credential) {
|
|
|
679
679
|
return credential;
|
|
680
680
|
}
|
|
681
681
|
__name(extractOriginalCredential, "extractOriginalCredential");
|
|
682
|
-
function detectCredentialFormat(credential) {
|
|
683
|
-
const documentFormat = import_ssi_types.CredentialMapper.detectDocumentType(credential);
|
|
684
|
-
switch (documentFormat) {
|
|
685
|
-
case import_ssi_types.DocumentFormat.JWT:
|
|
686
|
-
return "jwt_vc_json";
|
|
687
|
-
case import_ssi_types.DocumentFormat.SD_JWT_VC:
|
|
688
|
-
return "dc+sd-jwt";
|
|
689
|
-
case import_ssi_types.DocumentFormat.JSONLD:
|
|
690
|
-
return "ldp_vc";
|
|
691
|
-
case import_ssi_types.DocumentFormat.MSO_MDOC:
|
|
692
|
-
return "mso_mdoc";
|
|
693
|
-
case import_ssi_types.DocumentFormat.EIP712:
|
|
694
|
-
return "ldp_vc";
|
|
695
|
-
default:
|
|
696
|
-
return "jwt_vc_json";
|
|
697
|
-
}
|
|
698
|
-
}
|
|
699
|
-
__name(detectCredentialFormat, "detectCredentialFormat");
|
|
700
682
|
function getIdentifierString(identifier) {
|
|
701
683
|
if ("opts" in identifier && "method" in identifier) {
|
|
702
684
|
if ((0, import_ssi_sdk_ext2.isManagedIdentifierDidResult)(identifier)) {
|
|
@@ -709,10 +691,10 @@ __name(getIdentifierString, "getIdentifierString");
|
|
|
709
691
|
async function createVerifiablePresentationForFormat(credential, identifier, context) {
|
|
710
692
|
const { nonce, audience, agent, clockSkew = CLOCK_SKEW } = context;
|
|
711
693
|
const originalCredential = extractOriginalCredential(credential);
|
|
712
|
-
const
|
|
713
|
-
logger.debug(`Creating VP for format: ${
|
|
714
|
-
switch (
|
|
715
|
-
case
|
|
694
|
+
const documentFormat = import_ssi_types.CredentialMapper.detectDocumentType(originalCredential);
|
|
695
|
+
logger.debug(`Creating VP for format: ${documentFormat}`);
|
|
696
|
+
switch (documentFormat) {
|
|
697
|
+
case import_ssi_types.DocumentFormat.SD_JWT_VC: {
|
|
716
698
|
const decodedSdJwt = await import_ssi_types.CredentialMapper.decodeSdJwtVcAsync(typeof originalCredential === "string" ? originalCredential : originalCredential.compactSdJwtVc, import_ssi_sdk2.defaultGenerateDigest);
|
|
717
699
|
const hashAlg = decodedSdJwt.signedPayload._sd_alg ?? "sha-256";
|
|
718
700
|
const sdHash = (0, import_utils.calculateSdHash)(decodedSdJwt.compactSdJwtVc, hashAlg, import_ssi_sdk2.defaultGenerateDigest);
|
|
@@ -730,7 +712,32 @@ async function createVerifiablePresentationForFormat(credential, identifier, con
|
|
|
730
712
|
});
|
|
731
713
|
return presentationResult.presentation;
|
|
732
714
|
}
|
|
733
|
-
case
|
|
715
|
+
case import_ssi_types.DocumentFormat.JSONLD: {
|
|
716
|
+
const vcObject = typeof originalCredential === "string" ? JSON.parse(originalCredential) : originalCredential;
|
|
717
|
+
const vpObject = {
|
|
718
|
+
"@context": [
|
|
719
|
+
"https://www.w3.org/2018/credentials/v1"
|
|
720
|
+
],
|
|
721
|
+
type: [
|
|
722
|
+
"VerifiablePresentation"
|
|
723
|
+
],
|
|
724
|
+
verifiableCredential: [
|
|
725
|
+
vcObject
|
|
726
|
+
]
|
|
727
|
+
};
|
|
728
|
+
return await agent.createVerifiablePresentation({
|
|
729
|
+
presentation: vpObject,
|
|
730
|
+
proofFormat: "lds",
|
|
731
|
+
challenge: nonce,
|
|
732
|
+
domain: audience,
|
|
733
|
+
keyRef: identifier.kmsKeyRef || identifier.kid
|
|
734
|
+
});
|
|
735
|
+
}
|
|
736
|
+
case import_ssi_types.DocumentFormat.MSO_MDOC: {
|
|
737
|
+
logger.warning("mso_mdoc format has basic support - production use requires proper mdoc VP token implementation");
|
|
738
|
+
return originalCredential;
|
|
739
|
+
}
|
|
740
|
+
default: {
|
|
734
741
|
const vcJwt = typeof originalCredential === "string" ? originalCredential : JSON.stringify(originalCredential);
|
|
735
742
|
const identifierString = getIdentifierString(identifier);
|
|
736
743
|
const vpPayload = {
|
|
@@ -750,7 +757,7 @@ async function createVerifiablePresentationForFormat(credential, identifier, con
|
|
|
750
757
|
]
|
|
751
758
|
},
|
|
752
759
|
iat: Math.floor(Date.now() / 1e3 - clockSkew),
|
|
753
|
-
exp: Math.floor(Date.now() / 1e3 + 600)
|
|
760
|
+
exp: Math.floor(Date.now() / 1e3 + 600 + clockSkew)
|
|
754
761
|
};
|
|
755
762
|
const vpJwt = await agent.createVerifiablePresentation({
|
|
756
763
|
presentation: vpPayload.vp,
|
|
@@ -761,33 +768,6 @@ async function createVerifiablePresentationForFormat(credential, identifier, con
|
|
|
761
768
|
});
|
|
762
769
|
return vpJwt.proof?.jwt || vpJwt;
|
|
763
770
|
}
|
|
764
|
-
case "ldp_vc": {
|
|
765
|
-
const vcObject = typeof originalCredential === "string" ? JSON.parse(originalCredential) : originalCredential;
|
|
766
|
-
const vpObject = {
|
|
767
|
-
"@context": [
|
|
768
|
-
"https://www.w3.org/2018/credentials/v1"
|
|
769
|
-
],
|
|
770
|
-
type: [
|
|
771
|
-
"VerifiablePresentation"
|
|
772
|
-
],
|
|
773
|
-
verifiableCredential: [
|
|
774
|
-
vcObject
|
|
775
|
-
]
|
|
776
|
-
};
|
|
777
|
-
return await agent.createVerifiablePresentation({
|
|
778
|
-
presentation: vpObject,
|
|
779
|
-
proofFormat: "lds",
|
|
780
|
-
challenge: nonce,
|
|
781
|
-
domain: audience,
|
|
782
|
-
keyRef: identifier.kmsKeyRef || identifier.kid
|
|
783
|
-
});
|
|
784
|
-
}
|
|
785
|
-
case "mso_mdoc": {
|
|
786
|
-
logger.warning("mso_mdoc format has basic support - production use requires proper mdoc VP token implementation");
|
|
787
|
-
return originalCredential;
|
|
788
|
-
}
|
|
789
|
-
default:
|
|
790
|
-
return Promise.reject(Error(`Unsupported credential format: ${format}`));
|
|
791
771
|
}
|
|
792
772
|
}
|
|
793
773
|
__name(createVerifiablePresentationForFormat, "createVerifiablePresentationForFormat");
|