@sphereon/ssi-sdk.siopv2-oid4vp-op-auth 0.34.1-feature.SSISDK.44.finish.dcql.315 → 0.34.1-feature.SSISDK.44.finish.dcql.317
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 +19 -19
- package/src/session/OID4VP.ts +38 -65
package/dist/index.js
CHANGED
|
@@ -622,24 +622,6 @@ function extractOriginalCredential(credential) {
|
|
|
622
622
|
return credential;
|
|
623
623
|
}
|
|
624
624
|
__name(extractOriginalCredential, "extractOriginalCredential");
|
|
625
|
-
function detectCredentialFormat(credential) {
|
|
626
|
-
const documentFormat = CredentialMapper.detectDocumentType(credential);
|
|
627
|
-
switch (documentFormat) {
|
|
628
|
-
case DocumentFormat.JWT:
|
|
629
|
-
return "jwt_vc_json";
|
|
630
|
-
case DocumentFormat.SD_JWT_VC:
|
|
631
|
-
return "dc+sd-jwt";
|
|
632
|
-
case DocumentFormat.JSONLD:
|
|
633
|
-
return "ldp_vc";
|
|
634
|
-
case DocumentFormat.MSO_MDOC:
|
|
635
|
-
return "mso_mdoc";
|
|
636
|
-
case DocumentFormat.EIP712:
|
|
637
|
-
return "ldp_vc";
|
|
638
|
-
default:
|
|
639
|
-
return "jwt_vc_json";
|
|
640
|
-
}
|
|
641
|
-
}
|
|
642
|
-
__name(detectCredentialFormat, "detectCredentialFormat");
|
|
643
625
|
function getIdentifierString(identifier) {
|
|
644
626
|
if ("opts" in identifier && "method" in identifier) {
|
|
645
627
|
if (isManagedIdentifierDidResult(identifier)) {
|
|
@@ -652,10 +634,10 @@ __name(getIdentifierString, "getIdentifierString");
|
|
|
652
634
|
async function createVerifiablePresentationForFormat(credential, identifier, context) {
|
|
653
635
|
const { nonce, audience, agent, clockSkew = CLOCK_SKEW } = context;
|
|
654
636
|
const originalCredential = extractOriginalCredential(credential);
|
|
655
|
-
const
|
|
656
|
-
logger.debug(`Creating VP for format: ${
|
|
657
|
-
switch (
|
|
658
|
-
case
|
|
637
|
+
const documentFormat = CredentialMapper.detectDocumentType(originalCredential);
|
|
638
|
+
logger.debug(`Creating VP for format: ${documentFormat}`);
|
|
639
|
+
switch (documentFormat) {
|
|
640
|
+
case DocumentFormat.SD_JWT_VC: {
|
|
659
641
|
const decodedSdJwt = await CredentialMapper.decodeSdJwtVcAsync(typeof originalCredential === "string" ? originalCredential : originalCredential.compactSdJwtVc, defaultGenerateDigest);
|
|
660
642
|
const hashAlg = decodedSdJwt.signedPayload._sd_alg ?? "sha-256";
|
|
661
643
|
const sdHash = calculateSdHash(decodedSdJwt.compactSdJwtVc, hashAlg, defaultGenerateDigest);
|
|
@@ -673,7 +655,32 @@ async function createVerifiablePresentationForFormat(credential, identifier, con
|
|
|
673
655
|
});
|
|
674
656
|
return presentationResult.presentation;
|
|
675
657
|
}
|
|
676
|
-
case
|
|
658
|
+
case DocumentFormat.JSONLD: {
|
|
659
|
+
const vcObject = typeof originalCredential === "string" ? JSON.parse(originalCredential) : originalCredential;
|
|
660
|
+
const vpObject = {
|
|
661
|
+
"@context": [
|
|
662
|
+
"https://www.w3.org/2018/credentials/v1"
|
|
663
|
+
],
|
|
664
|
+
type: [
|
|
665
|
+
"VerifiablePresentation"
|
|
666
|
+
],
|
|
667
|
+
verifiableCredential: [
|
|
668
|
+
vcObject
|
|
669
|
+
]
|
|
670
|
+
};
|
|
671
|
+
return await agent.createVerifiablePresentation({
|
|
672
|
+
presentation: vpObject,
|
|
673
|
+
proofFormat: "lds",
|
|
674
|
+
challenge: nonce,
|
|
675
|
+
domain: audience,
|
|
676
|
+
keyRef: identifier.kmsKeyRef || identifier.kid
|
|
677
|
+
});
|
|
678
|
+
}
|
|
679
|
+
case DocumentFormat.MSO_MDOC: {
|
|
680
|
+
logger.warning("mso_mdoc format has basic support - production use requires proper mdoc VP token implementation");
|
|
681
|
+
return originalCredential;
|
|
682
|
+
}
|
|
683
|
+
default: {
|
|
677
684
|
const vcJwt = typeof originalCredential === "string" ? originalCredential : JSON.stringify(originalCredential);
|
|
678
685
|
const identifierString = getIdentifierString(identifier);
|
|
679
686
|
const vpPayload = {
|
|
@@ -693,7 +700,7 @@ async function createVerifiablePresentationForFormat(credential, identifier, con
|
|
|
693
700
|
]
|
|
694
701
|
},
|
|
695
702
|
iat: Math.floor(Date.now() / 1e3 - clockSkew),
|
|
696
|
-
exp: Math.floor(Date.now() / 1e3 + 600)
|
|
703
|
+
exp: Math.floor(Date.now() / 1e3 + 600 + clockSkew)
|
|
697
704
|
};
|
|
698
705
|
const vpJwt = await agent.createVerifiablePresentation({
|
|
699
706
|
presentation: vpPayload.vp,
|
|
@@ -704,33 +711,6 @@ async function createVerifiablePresentationForFormat(credential, identifier, con
|
|
|
704
711
|
});
|
|
705
712
|
return vpJwt.proof?.jwt || vpJwt;
|
|
706
713
|
}
|
|
707
|
-
case "ldp_vc": {
|
|
708
|
-
const vcObject = typeof originalCredential === "string" ? JSON.parse(originalCredential) : originalCredential;
|
|
709
|
-
const vpObject = {
|
|
710
|
-
"@context": [
|
|
711
|
-
"https://www.w3.org/2018/credentials/v1"
|
|
712
|
-
],
|
|
713
|
-
type: [
|
|
714
|
-
"VerifiablePresentation"
|
|
715
|
-
],
|
|
716
|
-
verifiableCredential: [
|
|
717
|
-
vcObject
|
|
718
|
-
]
|
|
719
|
-
};
|
|
720
|
-
return await agent.createVerifiablePresentation({
|
|
721
|
-
presentation: vpObject,
|
|
722
|
-
proofFormat: "lds",
|
|
723
|
-
challenge: nonce,
|
|
724
|
-
domain: audience,
|
|
725
|
-
keyRef: identifier.kmsKeyRef || identifier.kid
|
|
726
|
-
});
|
|
727
|
-
}
|
|
728
|
-
case "mso_mdoc": {
|
|
729
|
-
logger.warning("mso_mdoc format has basic support - production use requires proper mdoc VP token implementation");
|
|
730
|
-
return originalCredential;
|
|
731
|
-
}
|
|
732
|
-
default:
|
|
733
|
-
return Promise.reject(Error(`Unsupported credential format: ${format}`));
|
|
734
714
|
}
|
|
735
715
|
}
|
|
736
716
|
__name(createVerifiablePresentationForFormat, "createVerifiablePresentationForFormat");
|