@sphereon/ssi-types 0.34.1-next.6 → 0.34.1-next.85
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 +117 -83
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +129 -80
- package/dist/index.d.ts +129 -80
- package/dist/index.js +117 -83
- package/dist/index.js.map +1 -1
- package/package.json +4 -3
- package/src/index.ts +1 -0
- package/src/mapper/credential-mapper.ts +43 -34
- package/src/types/cose.ts +5 -4
- package/src/types/index.ts +1 -0
- package/src/types/mso_mdoc.ts +9 -9
- package/src/types/sd-jwt-vc.ts +19 -10
- package/src/types/vc.ts +2 -1
- package/src/types/vcdm2-sdjwt/index.ts +2 -0
- package/src/types/vcdm2-sdjwt/sd-jwt-vc-config.ts +22 -0
- package/src/types/vcdm2-sdjwt/sd-jwt-vc-payload.ts +23 -0
- package/src/types/w3c-vc.ts +30 -12
- package/src/utils/mdoc.ts +10 -9
- package/src/utils/sd-jwt.ts +32 -18
- package/src/utils/vc.ts +2 -1
package/dist/index.cjs
CHANGED
|
@@ -100,26 +100,26 @@ module.exports = __toCommonJS(index_exports);
|
|
|
100
100
|
// src/logging/index.ts
|
|
101
101
|
var import_debug = __toESM(require("debug"), 1);
|
|
102
102
|
var import_events = require("events");
|
|
103
|
-
var LogLevel = /* @__PURE__ */ function(LogLevel2) {
|
|
103
|
+
var LogLevel = /* @__PURE__ */ (function(LogLevel2) {
|
|
104
104
|
LogLevel2[LogLevel2["TRACE"] = 0] = "TRACE";
|
|
105
105
|
LogLevel2[LogLevel2["DEBUG"] = 1] = "DEBUG";
|
|
106
106
|
LogLevel2[LogLevel2["INFO"] = 2] = "INFO";
|
|
107
107
|
LogLevel2[LogLevel2["WARNING"] = 3] = "WARNING";
|
|
108
108
|
LogLevel2[LogLevel2["ERROR"] = 4] = "ERROR";
|
|
109
109
|
return LogLevel2;
|
|
110
|
-
}({});
|
|
111
|
-
var LoggingEventType = /* @__PURE__ */ function(LoggingEventType2) {
|
|
110
|
+
})({});
|
|
111
|
+
var LoggingEventType = /* @__PURE__ */ (function(LoggingEventType2) {
|
|
112
112
|
LoggingEventType2["AUDIT"] = "audit";
|
|
113
113
|
LoggingEventType2["ACTIVITY"] = "activity";
|
|
114
114
|
LoggingEventType2["GENERAL"] = "general";
|
|
115
115
|
return LoggingEventType2;
|
|
116
|
-
}({});
|
|
117
|
-
var LogMethod = /* @__PURE__ */ function(LogMethod2) {
|
|
116
|
+
})({});
|
|
117
|
+
var LogMethod = /* @__PURE__ */ (function(LogMethod2) {
|
|
118
118
|
LogMethod2[LogMethod2["DEBUG_PKG"] = 0] = "DEBUG_PKG";
|
|
119
119
|
LogMethod2[LogMethod2["CONSOLE"] = 1] = "CONSOLE";
|
|
120
120
|
LogMethod2[LogMethod2["EVENT"] = 2] = "EVENT";
|
|
121
121
|
return LogMethod2;
|
|
122
|
-
}({});
|
|
122
|
+
})({});
|
|
123
123
|
function logOptions(opts) {
|
|
124
124
|
return {
|
|
125
125
|
namespace: opts?.namespace ?? "sphereon",
|
|
@@ -296,7 +296,7 @@ var SimpleRecordLogger = class extends SimpleLogger {
|
|
|
296
296
|
|
|
297
297
|
// src/events/index.ts
|
|
298
298
|
var import_events2 = require("events");
|
|
299
|
-
var System = /* @__PURE__ */ function(System2) {
|
|
299
|
+
var System = /* @__PURE__ */ (function(System2) {
|
|
300
300
|
System2["GENERAL"] = "general";
|
|
301
301
|
System2["KMS"] = "kms";
|
|
302
302
|
System2["IDENTITY"] = "identity";
|
|
@@ -309,8 +309,8 @@ var System = /* @__PURE__ */ function(System2) {
|
|
|
309
309
|
System2["PROFILE"] = "profile";
|
|
310
310
|
System2["CONTACT"] = "contact";
|
|
311
311
|
return System2;
|
|
312
|
-
}({});
|
|
313
|
-
var SubSystem = /* @__PURE__ */ function(SubSystem2) {
|
|
312
|
+
})({});
|
|
313
|
+
var SubSystem = /* @__PURE__ */ (function(SubSystem2) {
|
|
314
314
|
SubSystem2["KEY"] = "key";
|
|
315
315
|
SubSystem2["DID_PROVIDER"] = "did_provider";
|
|
316
316
|
SubSystem2["DID_RESOLVER"] = "did_resolver";
|
|
@@ -325,16 +325,16 @@ var SubSystem = /* @__PURE__ */ function(SubSystem2) {
|
|
|
325
325
|
SubSystem2["PROFILE"] = "profile";
|
|
326
326
|
SubSystem2["API"] = "api";
|
|
327
327
|
return SubSystem2;
|
|
328
|
-
}({});
|
|
329
|
-
var ActionType = /* @__PURE__ */ function(ActionType2) {
|
|
328
|
+
})({});
|
|
329
|
+
var ActionType = /* @__PURE__ */ (function(ActionType2) {
|
|
330
330
|
ActionType2["CREATE"] = "create";
|
|
331
331
|
ActionType2["READ"] = "read";
|
|
332
332
|
ActionType2["UPDATE"] = "update";
|
|
333
333
|
ActionType2["DELETE"] = "delete";
|
|
334
334
|
ActionType2["EXECUTE"] = "execute";
|
|
335
335
|
return ActionType2;
|
|
336
|
-
}({});
|
|
337
|
-
var DefaultActionSubType = /* @__PURE__ */ function(DefaultActionSubType2) {
|
|
336
|
+
})({});
|
|
337
|
+
var DefaultActionSubType = /* @__PURE__ */ (function(DefaultActionSubType2) {
|
|
338
338
|
DefaultActionSubType2["KEY_GENERATION"] = "Key generation";
|
|
339
339
|
DefaultActionSubType2["KEY_IMPORT"] = "Key import";
|
|
340
340
|
DefaultActionSubType2["KEY_PERSISTENCE"] = "Key persistence";
|
|
@@ -349,14 +349,14 @@ var DefaultActionSubType = /* @__PURE__ */ function(DefaultActionSubType2) {
|
|
|
349
349
|
DefaultActionSubType2["VC_ISSUE_DECLINE"] = "VC issue decline";
|
|
350
350
|
DefaultActionSubType2["VC_SHARE_DECLINE"] = "VC share decline";
|
|
351
351
|
return DefaultActionSubType2;
|
|
352
|
-
}({});
|
|
353
|
-
var InitiatorType = /* @__PURE__ */ function(InitiatorType2) {
|
|
352
|
+
})({});
|
|
353
|
+
var InitiatorType = /* @__PURE__ */ (function(InitiatorType2) {
|
|
354
354
|
InitiatorType2["USER"] = "user";
|
|
355
355
|
InitiatorType2["SYSTEM"] = "system";
|
|
356
356
|
InitiatorType2["EXTERNAL"] = "external";
|
|
357
357
|
return InitiatorType2;
|
|
358
|
-
}({});
|
|
359
|
-
var SystemCorrelationIdType = /* @__PURE__ */ function(SystemCorrelationIdType2) {
|
|
358
|
+
})({});
|
|
359
|
+
var SystemCorrelationIdType = /* @__PURE__ */ (function(SystemCorrelationIdType2) {
|
|
360
360
|
SystemCorrelationIdType2["DID"] = "did";
|
|
361
361
|
SystemCorrelationIdType2["URL"] = "url";
|
|
362
362
|
SystemCorrelationIdType2["EMAIL"] = "email";
|
|
@@ -364,7 +364,7 @@ var SystemCorrelationIdType = /* @__PURE__ */ function(SystemCorrelationIdType2)
|
|
|
364
364
|
SystemCorrelationIdType2["PHONE"] = "phone";
|
|
365
365
|
SystemCorrelationIdType2["USER"] = "user";
|
|
366
366
|
return SystemCorrelationIdType2;
|
|
367
|
-
}({});
|
|
367
|
+
})({});
|
|
368
368
|
var EventManager = class _EventManager {
|
|
369
369
|
static {
|
|
370
370
|
__name(this, "EventManager");
|
|
@@ -527,11 +527,12 @@ function isWrappedW3CVerifiablePresentation(vp) {
|
|
|
527
527
|
return vp.format === "jwt_vp" || vp.format === "ldp_vp";
|
|
528
528
|
}
|
|
529
529
|
__name(isWrappedW3CVerifiablePresentation, "isWrappedW3CVerifiablePresentation");
|
|
530
|
-
var StatusListType = /* @__PURE__ */ function(StatusListType2) {
|
|
530
|
+
var StatusListType = /* @__PURE__ */ (function(StatusListType2) {
|
|
531
531
|
StatusListType2["StatusList2021"] = "StatusList2021";
|
|
532
532
|
StatusListType2["OAuthStatusList"] = "OAuthStatusList";
|
|
533
|
+
StatusListType2["BitstringStatusList"] = "BitstringStatusList";
|
|
533
534
|
return StatusListType2;
|
|
534
|
-
}({});
|
|
535
|
+
})({});
|
|
535
536
|
function isVcdmCredential(credential, vcdmType) {
|
|
536
537
|
if (!credential || typeof credential !== "object") {
|
|
537
538
|
return false;
|
|
@@ -568,7 +569,7 @@ var VCDM_CREDENTIAL_CONTEXT_VERSIONS = [
|
|
|
568
569
|
];
|
|
569
570
|
|
|
570
571
|
// src/utils/did.ts
|
|
571
|
-
var IProofPurpose = /* @__PURE__ */ function(IProofPurpose2) {
|
|
572
|
+
var IProofPurpose = /* @__PURE__ */ (function(IProofPurpose2) {
|
|
572
573
|
IProofPurpose2["verificationMethod"] = "verificationMethod";
|
|
573
574
|
IProofPurpose2["assertionMethod"] = "assertionMethod";
|
|
574
575
|
IProofPurpose2["authentication"] = "authentication";
|
|
@@ -577,8 +578,8 @@ var IProofPurpose = /* @__PURE__ */ function(IProofPurpose2) {
|
|
|
577
578
|
IProofPurpose2["capabilityInvocation"] = "capabilityInvocation";
|
|
578
579
|
IProofPurpose2["capabilityDelegation"] = "capabilityDelegation";
|
|
579
580
|
return IProofPurpose2;
|
|
580
|
-
}({});
|
|
581
|
-
var IProofType = /* @__PURE__ */ function(IProofType2) {
|
|
581
|
+
})({});
|
|
582
|
+
var IProofType = /* @__PURE__ */ (function(IProofType2) {
|
|
582
583
|
IProofType2["Ed25519Signature2018"] = "Ed25519Signature2018";
|
|
583
584
|
IProofType2["Ed25519Signature2020"] = "Ed25519Signature2020";
|
|
584
585
|
IProofType2["EcdsaSecp256k1Signature2019"] = "EcdsaSecp256k1Signature2019";
|
|
@@ -593,7 +594,7 @@ var IProofType = /* @__PURE__ */ function(IProofType2) {
|
|
|
593
594
|
IProofType2["SdJwtProof2024"] = "SdJwtProof2024";
|
|
594
595
|
IProofType2["MdocProof2024"] = "MsoMdocProof2024";
|
|
595
596
|
return IProofType2;
|
|
596
|
-
}({});
|
|
597
|
+
})({});
|
|
597
598
|
var parseDid = /* @__PURE__ */ __name((did) => {
|
|
598
599
|
const parsedDid = parse(did);
|
|
599
600
|
if (parsedDid === null) {
|
|
@@ -639,7 +640,8 @@ var parse = /* @__PURE__ */ __name((didUrl) => {
|
|
|
639
640
|
}, "parse");
|
|
640
641
|
|
|
641
642
|
// src/utils/mdoc.ts
|
|
642
|
-
var
|
|
643
|
+
var import_kmp_mdoc_core = __toESM(require("@sphereon/kmp-mdoc-core"), 1);
|
|
644
|
+
var { com } = import_kmp_mdoc_core.default;
|
|
643
645
|
function isWrappedMdocCredential(vc) {
|
|
644
646
|
return vc.format === "mso_mdoc";
|
|
645
647
|
}
|
|
@@ -648,12 +650,12 @@ function isWrappedMdocPresentation(vp) {
|
|
|
648
650
|
return vp.format === "mso_mdoc";
|
|
649
651
|
}
|
|
650
652
|
__name(isWrappedMdocPresentation, "isWrappedMdocPresentation");
|
|
651
|
-
function getMdocDecodedPayload(
|
|
652
|
-
const mdocJson =
|
|
653
|
+
function getMdocDecodedPayload(mdoc) {
|
|
654
|
+
const mdocJson = mdoc.toJson();
|
|
653
655
|
if (!mdocJson.issuerSigned.nameSpaces) {
|
|
654
656
|
throw Error(`Cannot access Issuer Signed items from the Mdoc`);
|
|
655
657
|
}
|
|
656
|
-
const issuerSignedJson =
|
|
658
|
+
const issuerSignedJson = mdoc.issuerSigned.toJsonDTO();
|
|
657
659
|
const namespaces = issuerSignedJson.nameSpaces;
|
|
658
660
|
const decodedPayload = {};
|
|
659
661
|
for (const [namespace, items] of Object.entries(namespaces)) {
|
|
@@ -666,17 +668,17 @@ function getMdocDecodedPayload(mdoc2) {
|
|
|
666
668
|
}
|
|
667
669
|
__name(getMdocDecodedPayload, "getMdocDecodedPayload");
|
|
668
670
|
function decodeMdocIssuerSigned(oid4vpIssuerSigned) {
|
|
669
|
-
const issuerSigned =
|
|
671
|
+
const issuerSigned = com.sphereon.mdoc.data.device.IssuerSignedCbor.Static.cborDecode(com.sphereon.kmp.decodeFrom(oid4vpIssuerSigned, com.sphereon.kmp.Encoding.BASE64URL));
|
|
670
672
|
const holderMdoc = issuerSigned.toDocument();
|
|
671
673
|
return holderMdoc;
|
|
672
674
|
}
|
|
673
675
|
__name(decodeMdocIssuerSigned, "decodeMdocIssuerSigned");
|
|
674
676
|
function encodeMdocIssuerSigned(issuerSigned, encoding = "base64url") {
|
|
675
|
-
return
|
|
677
|
+
return com.sphereon.kmp.encodeTo(issuerSigned.cborEncode(), com.sphereon.kmp.Encoding.BASE64URL);
|
|
676
678
|
}
|
|
677
679
|
__name(encodeMdocIssuerSigned, "encodeMdocIssuerSigned");
|
|
678
680
|
function decodeMdocDeviceResponse(vpToken) {
|
|
679
|
-
const deviceResponse =
|
|
681
|
+
const deviceResponse = com.sphereon.mdoc.data.device.DeviceResponseCbor.Static.cborDecode(com.sphereon.kmp.decodeFrom(vpToken, com.sphereon.kmp.Encoding.BASE64URL));
|
|
680
682
|
return deviceResponse;
|
|
681
683
|
}
|
|
682
684
|
__name(decodeMdocDeviceResponse, "decodeMdocDeviceResponse");
|
|
@@ -729,7 +731,7 @@ var mdocDecodedCredentialToUniformCredential = /* @__PURE__ */ __name((decoded,
|
|
|
729
731
|
created: issuanceDate,
|
|
730
732
|
proofPurpose: IProofPurpose.authentication,
|
|
731
733
|
verificationMethod: json.issuerSigned.issuerAuth.payload,
|
|
732
|
-
mso_mdoc:
|
|
734
|
+
mso_mdoc: com.sphereon.kmp.encodeTo(decoded.cborEncode(), com.sphereon.kmp.Encoding.BASE64URL)
|
|
733
735
|
}
|
|
734
736
|
};
|
|
735
737
|
return credential;
|
|
@@ -742,8 +744,10 @@ function decodeSdJwtVc(compactSdJwtVc, hasher) {
|
|
|
742
744
|
const signedPayload = jwt.payload;
|
|
743
745
|
const decodedPayload = (0, import_decode.getClaimsSync)(signedPayload, disclosures, hasher);
|
|
744
746
|
const compactKeyBindingJwt = kbJwt ? compactSdJwtVc.split("~").pop() : void 0;
|
|
747
|
+
const type = decodedPayload.vct ? "dc+sd-jwt" : "vc+sd-jwt";
|
|
745
748
|
return {
|
|
746
749
|
compactSdJwtVc,
|
|
750
|
+
type,
|
|
747
751
|
decodedPayload,
|
|
748
752
|
disclosures: disclosures.map((d) => {
|
|
749
753
|
const decoded = d.key ? [
|
|
@@ -777,8 +781,10 @@ async function decodeSdJwtVcAsync(compactSdJwtVc, hasher) {
|
|
|
777
781
|
const signedPayload = jwt.payload;
|
|
778
782
|
const decodedPayload = await (0, import_decode.getClaims)(signedPayload, disclosures, hasher);
|
|
779
783
|
const compactKeyBindingJwt = kbJwt ? compactSdJwtVc.split("~").pop() : void 0;
|
|
784
|
+
const type = decodedPayload.vct ? "dc+sd-jwt" : "vc+sd-jwt";
|
|
780
785
|
return {
|
|
781
786
|
compactSdJwtVc,
|
|
787
|
+
type,
|
|
782
788
|
decodedPayload,
|
|
783
789
|
disclosures: disclosures.map((d) => {
|
|
784
790
|
const decoded = d.key ? [
|
|
@@ -809,13 +815,19 @@ async function decodeSdJwtVcAsync(compactSdJwtVc, hasher) {
|
|
|
809
815
|
__name(decodeSdJwtVcAsync, "decodeSdJwtVcAsync");
|
|
810
816
|
var sdJwtDecodedCredentialToUniformCredential = /* @__PURE__ */ __name((decoded, opts) => {
|
|
811
817
|
const { decodedPayload } = decoded;
|
|
812
|
-
const { exp, nbf, iss, iat, vct, cnf, status,
|
|
818
|
+
const { exp, nbf, iss, iat, vct, cnf, status, jti, validUntil, validFrom } = decodedPayload;
|
|
819
|
+
let credentialSubject = decodedPayload.credentialSubject;
|
|
820
|
+
let issuer = iss ?? decodedPayload.issuer;
|
|
821
|
+
if (typeof issuer === "object" && "id" in issuer && typeof issuer.id === "string") {
|
|
822
|
+
issuer = issuer.id;
|
|
823
|
+
}
|
|
824
|
+
const subId = decodedPayload.sub ?? (typeof credentialSubject == "object" && "id" in credentialSubject ? credentialSubject.id : void 0);
|
|
813
825
|
const maxSkewInMS = opts?.maxTimeSkewInMS ?? 1500;
|
|
814
|
-
const expirationDate = jwtDateToISOString({
|
|
826
|
+
const expirationDate = validUntil ?? jwtDateToISOString({
|
|
815
827
|
jwtClaim: exp,
|
|
816
828
|
claimName: "exp"
|
|
817
829
|
});
|
|
818
|
-
let issuanceDateStr = jwtDateToISOString({
|
|
830
|
+
let issuanceDateStr = validFrom ?? jwtDateToISOString({
|
|
819
831
|
jwtClaim: iat,
|
|
820
832
|
claimName: "iat"
|
|
821
833
|
});
|
|
@@ -826,7 +838,7 @@ var sdJwtDecodedCredentialToUniformCredential = /* @__PURE__ */ __name((decoded,
|
|
|
826
838
|
claimName: "nbf"
|
|
827
839
|
});
|
|
828
840
|
if (issuanceDateStr && nbfDateAsStr && issuanceDateStr !== nbfDateAsStr) {
|
|
829
|
-
const diff = Math.abs(new Date(nbfDateAsStr).getTime() - new Date(
|
|
841
|
+
const diff = Math.abs(new Date(nbfDateAsStr).getTime() - new Date(issuanceDateStr).getTime());
|
|
830
842
|
if (!maxSkewInMS || diff > maxSkewInMS) {
|
|
831
843
|
throw Error(`Inconsistent issuance dates between JWT claim (${nbfDateAsStr}) and VC value (${iss})`);
|
|
832
844
|
}
|
|
@@ -847,24 +859,39 @@ var sdJwtDecodedCredentialToUniformCredential = /* @__PURE__ */ __name((decoded,
|
|
|
847
859
|
"jti",
|
|
848
860
|
"sub"
|
|
849
861
|
]);
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
862
|
+
if (!credentialSubject) {
|
|
863
|
+
credentialSubject = Object.entries(decodedPayload).reduce((acc, [key, value]) => {
|
|
864
|
+
if (!excludedFields.has(key) && value !== void 0 && value !== "" && !(typeof value === "object" && value !== null && Object.keys(value).length === 0)) {
|
|
865
|
+
acc[key] = value;
|
|
866
|
+
}
|
|
867
|
+
return acc;
|
|
868
|
+
}, {});
|
|
869
|
+
}
|
|
870
|
+
const sdJwtVc = decodedPayload.vct && !decodedPayload.type;
|
|
856
871
|
const credential = {
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
872
|
+
...{
|
|
873
|
+
type: sdJwtVc ? [
|
|
874
|
+
vct
|
|
875
|
+
] : decodedPayload.type
|
|
876
|
+
},
|
|
877
|
+
...{
|
|
878
|
+
"@context": sdJwtVc ? [] : decodedPayload["@context"]
|
|
879
|
+
},
|
|
861
880
|
credentialSubject: {
|
|
862
881
|
...credentialSubject,
|
|
863
|
-
id:
|
|
882
|
+
id: subId ?? jti
|
|
864
883
|
},
|
|
865
|
-
issuanceDate
|
|
866
|
-
|
|
867
|
-
|
|
884
|
+
...issuanceDate && (sdJwtVc ? {
|
|
885
|
+
issuanceDate
|
|
886
|
+
} : {
|
|
887
|
+
validFrom: issuanceDateStr
|
|
888
|
+
}),
|
|
889
|
+
...expirationDate && (sdJwtVc ? {
|
|
890
|
+
expirationDate
|
|
891
|
+
} : {
|
|
892
|
+
validUntil: expirationDate
|
|
893
|
+
}),
|
|
894
|
+
issuer,
|
|
868
895
|
...cnf && {
|
|
869
896
|
cnf
|
|
870
897
|
},
|
|
@@ -892,14 +919,14 @@ var jwtDateToISOString = /* @__PURE__ */ __name(({ jwtClaim, claimName, isRequir
|
|
|
892
919
|
}, "jwtDateToISOString");
|
|
893
920
|
|
|
894
921
|
// src/utils/jose.ts
|
|
895
|
-
var JwkKeyType = /* @__PURE__ */ function(JwkKeyType2) {
|
|
922
|
+
var JwkKeyType = /* @__PURE__ */ (function(JwkKeyType2) {
|
|
896
923
|
JwkKeyType2["EC"] = "EC";
|
|
897
924
|
JwkKeyType2["RSA"] = "RSA";
|
|
898
925
|
JwkKeyType2["oct"] = "oct";
|
|
899
926
|
JwkKeyType2["OKP"] = "OKP";
|
|
900
927
|
return JwkKeyType2;
|
|
901
|
-
}({});
|
|
902
|
-
var JoseSignatureAlgorithm = /* @__PURE__ */ function(JoseSignatureAlgorithm2) {
|
|
928
|
+
})({});
|
|
929
|
+
var JoseSignatureAlgorithm = /* @__PURE__ */ (function(JoseSignatureAlgorithm2) {
|
|
903
930
|
JoseSignatureAlgorithm2["RS256"] = "RS256";
|
|
904
931
|
JoseSignatureAlgorithm2["RS384"] = "RS384";
|
|
905
932
|
JoseSignatureAlgorithm2["RS512"] = "RS512";
|
|
@@ -916,8 +943,8 @@ var JoseSignatureAlgorithm = /* @__PURE__ */ function(JoseSignatureAlgorithm2) {
|
|
|
916
943
|
JoseSignatureAlgorithm2["PS512"] = "PS512";
|
|
917
944
|
JoseSignatureAlgorithm2["none"] = "none";
|
|
918
945
|
return JoseSignatureAlgorithm2;
|
|
919
|
-
}({});
|
|
920
|
-
var JoseKeyOperation = /* @__PURE__ */ function(JoseKeyOperation2) {
|
|
946
|
+
})({});
|
|
947
|
+
var JoseKeyOperation = /* @__PURE__ */ (function(JoseKeyOperation2) {
|
|
921
948
|
JoseKeyOperation2["SIGN"] = "sign";
|
|
922
949
|
JoseKeyOperation2["VERIFY"] = "verify";
|
|
923
950
|
JoseKeyOperation2["ENCRYPT"] = "encrypt";
|
|
@@ -927,8 +954,8 @@ var JoseKeyOperation = /* @__PURE__ */ function(JoseKeyOperation2) {
|
|
|
927
954
|
JoseKeyOperation2["DERIVE_KEY"] = "deriveKey";
|
|
928
955
|
JoseKeyOperation2["DERIVE_BITS"] = "deriveBits";
|
|
929
956
|
return JoseKeyOperation2;
|
|
930
|
-
}({});
|
|
931
|
-
var JoseCurve = /* @__PURE__ */ function(JoseCurve2) {
|
|
957
|
+
})({});
|
|
958
|
+
var JoseCurve = /* @__PURE__ */ (function(JoseCurve2) {
|
|
932
959
|
JoseCurve2["P_256"] = "P-256";
|
|
933
960
|
JoseCurve2["P_384"] = "P-384";
|
|
934
961
|
JoseCurve2["P_521"] = "P-521";
|
|
@@ -939,18 +966,18 @@ var JoseCurve = /* @__PURE__ */ function(JoseCurve2) {
|
|
|
939
966
|
JoseCurve2["Ed448"] = "Ed448";
|
|
940
967
|
JoseCurve2["secp256k1"] = "secp256k1";
|
|
941
968
|
return JoseCurve2;
|
|
942
|
-
}({});
|
|
969
|
+
})({});
|
|
943
970
|
|
|
944
971
|
// src/utils/cose.ts
|
|
945
|
-
var ICoseKeyType = /* @__PURE__ */ function(ICoseKeyType2) {
|
|
972
|
+
var ICoseKeyType = /* @__PURE__ */ (function(ICoseKeyType2) {
|
|
946
973
|
ICoseKeyType2[ICoseKeyType2["OKP"] = 1] = "OKP";
|
|
947
974
|
ICoseKeyType2[ICoseKeyType2["EC2"] = 2] = "EC2";
|
|
948
975
|
ICoseKeyType2[ICoseKeyType2["RSA"] = 3] = "RSA";
|
|
949
976
|
ICoseKeyType2[ICoseKeyType2["Symmetric"] = 4] = "Symmetric";
|
|
950
977
|
ICoseKeyType2[ICoseKeyType2["Reserved"] = 0] = "Reserved";
|
|
951
978
|
return ICoseKeyType2;
|
|
952
|
-
}({});
|
|
953
|
-
var ICoseSignatureAlgorithm = /* @__PURE__ */ function(ICoseSignatureAlgorithm2) {
|
|
979
|
+
})({});
|
|
980
|
+
var ICoseSignatureAlgorithm = /* @__PURE__ */ (function(ICoseSignatureAlgorithm2) {
|
|
954
981
|
ICoseSignatureAlgorithm2[ICoseSignatureAlgorithm2["ES256"] = -7] = "ES256";
|
|
955
982
|
ICoseSignatureAlgorithm2[ICoseSignatureAlgorithm2["ES256K"] = -47] = "ES256K";
|
|
956
983
|
ICoseSignatureAlgorithm2[ICoseSignatureAlgorithm2["ES384"] = -35] = "ES384";
|
|
@@ -964,8 +991,8 @@ var ICoseSignatureAlgorithm = /* @__PURE__ */ function(ICoseSignatureAlgorithm2)
|
|
|
964
991
|
ICoseSignatureAlgorithm2[ICoseSignatureAlgorithm2["PS384"] = -38] = "PS384";
|
|
965
992
|
ICoseSignatureAlgorithm2[ICoseSignatureAlgorithm2["PS512"] = -39] = "PS512";
|
|
966
993
|
return ICoseSignatureAlgorithm2;
|
|
967
|
-
}({});
|
|
968
|
-
var ICoseKeyOperation = /* @__PURE__ */ function(ICoseKeyOperation2) {
|
|
994
|
+
})({});
|
|
995
|
+
var ICoseKeyOperation = /* @__PURE__ */ (function(ICoseKeyOperation2) {
|
|
969
996
|
ICoseKeyOperation2[ICoseKeyOperation2["SIGN"] = 1] = "SIGN";
|
|
970
997
|
ICoseKeyOperation2[ICoseKeyOperation2["VERIFY"] = 2] = "VERIFY";
|
|
971
998
|
ICoseKeyOperation2[ICoseKeyOperation2["ENCRYPT"] = 3] = "ENCRYPT";
|
|
@@ -977,8 +1004,8 @@ var ICoseKeyOperation = /* @__PURE__ */ function(ICoseKeyOperation2) {
|
|
|
977
1004
|
ICoseKeyOperation2[ICoseKeyOperation2["MAC_CREATE"] = 9] = "MAC_CREATE";
|
|
978
1005
|
ICoseKeyOperation2[ICoseKeyOperation2["MAC_VERIFY"] = 10] = "MAC_VERIFY";
|
|
979
1006
|
return ICoseKeyOperation2;
|
|
980
|
-
}({});
|
|
981
|
-
var ICoseCurve = /* @__PURE__ */ function(ICoseCurve2) {
|
|
1007
|
+
})({});
|
|
1008
|
+
var ICoseCurve = /* @__PURE__ */ (function(ICoseCurve2) {
|
|
982
1009
|
ICoseCurve2[ICoseCurve2["P_256"] = 1] = "P_256";
|
|
983
1010
|
ICoseCurve2[ICoseCurve2["P_384"] = 2] = "P_384";
|
|
984
1011
|
ICoseCurve2[ICoseCurve2["P_521"] = 3] = "P_521";
|
|
@@ -988,18 +1015,18 @@ var ICoseCurve = /* @__PURE__ */ function(ICoseCurve2) {
|
|
|
988
1015
|
ICoseCurve2[ICoseCurve2["Ed448"] = 7] = "Ed448";
|
|
989
1016
|
ICoseCurve2[ICoseCurve2["secp256k1"] = -1] = "secp256k1";
|
|
990
1017
|
return ICoseCurve2;
|
|
991
|
-
}({});
|
|
1018
|
+
})({});
|
|
992
1019
|
|
|
993
1020
|
// src/mapper/credential-constraints.ts
|
|
994
|
-
var StatusListCredentialIdMode = /* @__PURE__ */ function(StatusListCredentialIdMode2) {
|
|
1021
|
+
var StatusListCredentialIdMode = /* @__PURE__ */ (function(StatusListCredentialIdMode2) {
|
|
995
1022
|
StatusListCredentialIdMode2["ISSUANCE"] = "ISSUANCE";
|
|
996
1023
|
StatusListCredentialIdMode2["NEVER"] = "NEVER";
|
|
997
1024
|
return StatusListCredentialIdMode2;
|
|
998
|
-
}({});
|
|
999
|
-
var StatusListDriverType = /* @__PURE__ */ function(StatusListDriverType2) {
|
|
1025
|
+
})({});
|
|
1026
|
+
var StatusListDriverType = /* @__PURE__ */ (function(StatusListDriverType2) {
|
|
1000
1027
|
StatusListDriverType2["AGENT_TYPEORM"] = "agent_typeorm";
|
|
1001
1028
|
return StatusListDriverType2;
|
|
1002
|
-
}({});
|
|
1029
|
+
})({});
|
|
1003
1030
|
|
|
1004
1031
|
// src/mapper/credential-mapper.ts
|
|
1005
1032
|
var import_jwt_decode = require("jwt-decode");
|
|
@@ -1135,7 +1162,7 @@ var CredentialMapper = class _CredentialMapper {
|
|
|
1135
1162
|
}
|
|
1136
1163
|
return {
|
|
1137
1164
|
type: _CredentialMapper.isSdJwtDecodedCredential(originalPresentation) ? "sd-jwt-vc-decoded" : "sd-jwt-vc-encoded",
|
|
1138
|
-
format: "
|
|
1165
|
+
format: "dc+sd-jwt",
|
|
1139
1166
|
original: originalPresentation,
|
|
1140
1167
|
presentation: decodedPresentation,
|
|
1141
1168
|
decoded: decodedPresentation.decodedPayload,
|
|
@@ -1205,18 +1232,18 @@ var CredentialMapper = class _CredentialMapper {
|
|
|
1205
1232
|
*/
|
|
1206
1233
|
static toWrappedVerifiableCredential(verifiableCredential, opts) {
|
|
1207
1234
|
if (_CredentialMapper.isMsoMdocDecodedCredential(verifiableCredential) || _CredentialMapper.isMsoMdocOid4VPEncoded(verifiableCredential)) {
|
|
1208
|
-
let
|
|
1235
|
+
let mdoc;
|
|
1209
1236
|
if (_CredentialMapper.isMsoMdocOid4VPEncoded(verifiableCredential)) {
|
|
1210
|
-
|
|
1237
|
+
mdoc = decodeMdocIssuerSigned(verifiableCredential);
|
|
1211
1238
|
} else {
|
|
1212
|
-
|
|
1239
|
+
mdoc = verifiableCredential;
|
|
1213
1240
|
}
|
|
1214
1241
|
return {
|
|
1215
1242
|
type: _CredentialMapper.isMsoMdocDecodedCredential(verifiableCredential) ? "mso_mdoc-decoded" : "mso_mdoc-encoded",
|
|
1216
1243
|
format: "mso_mdoc",
|
|
1217
1244
|
original: verifiableCredential,
|
|
1218
|
-
credential:
|
|
1219
|
-
decoded: getMdocDecodedPayload(
|
|
1245
|
+
credential: mdoc,
|
|
1246
|
+
decoded: getMdocDecodedPayload(mdoc)
|
|
1220
1247
|
};
|
|
1221
1248
|
}
|
|
1222
1249
|
if (_CredentialMapper.isSdJwtDecodedCredential(verifiableCredential) || _CredentialMapper.isSdJwtEncoded(verifiableCredential)) {
|
|
@@ -1229,7 +1256,7 @@ var CredentialMapper = class _CredentialMapper {
|
|
|
1229
1256
|
}
|
|
1230
1257
|
return {
|
|
1231
1258
|
type: _CredentialMapper.isSdJwtDecodedCredential(verifiableCredential) ? "sd-jwt-vc-decoded" : "sd-jwt-vc-encoded",
|
|
1232
|
-
format: "
|
|
1259
|
+
format: "dc+sd-jwt",
|
|
1233
1260
|
original: verifiableCredential,
|
|
1234
1261
|
credential: decodedCredential,
|
|
1235
1262
|
decoded: decodedCredential.decodedPayload
|
|
@@ -1351,6 +1378,13 @@ var CredentialMapper = class _CredentialMapper {
|
|
|
1351
1378
|
static isSdJwtDecodedCredential(original) {
|
|
1352
1379
|
return typeof original === "object" && (original.compactSdJwtVc !== void 0 || original.kbJwt !== void 0);
|
|
1353
1380
|
}
|
|
1381
|
+
static isSdJwtVcdm2DecodedCredential(original) {
|
|
1382
|
+
if (typeof original !== "object") {
|
|
1383
|
+
return false;
|
|
1384
|
+
}
|
|
1385
|
+
const decoded = original;
|
|
1386
|
+
return decoded.compactSdJwtVc !== void 0 && !decoded.decodedPayload.vct && !decoded.decodedPayload["@context"];
|
|
1387
|
+
}
|
|
1354
1388
|
static isMsoMdocDecodedCredential(original) {
|
|
1355
1389
|
return typeof original === "object" && "issuerSigned" in original && original.issuerSigned !== void 0;
|
|
1356
1390
|
}
|
|
@@ -1674,14 +1708,14 @@ var CredentialMapper = class _CredentialMapper {
|
|
|
1674
1708
|
}
|
|
1675
1709
|
};
|
|
1676
1710
|
function isWrappedSdJwtVerifiableCredential(vc) {
|
|
1677
|
-
return vc.format === "
|
|
1711
|
+
return vc.format === "dc+sd-jwt";
|
|
1678
1712
|
}
|
|
1679
1713
|
__name(isWrappedSdJwtVerifiableCredential, "isWrappedSdJwtVerifiableCredential");
|
|
1680
1714
|
function isWrappedSdJwtVerifiablePresentation(vp) {
|
|
1681
|
-
return vp.format === "
|
|
1715
|
+
return vp.format === "dc+sd-jwt";
|
|
1682
1716
|
}
|
|
1683
1717
|
__name(isWrappedSdJwtVerifiablePresentation, "isWrappedSdJwtVerifiablePresentation");
|
|
1684
|
-
var OriginalType = /* @__PURE__ */ function(OriginalType2) {
|
|
1718
|
+
var OriginalType = /* @__PURE__ */ (function(OriginalType2) {
|
|
1685
1719
|
OriginalType2["JSONLD"] = "json-ld";
|
|
1686
1720
|
OriginalType2["JWT_ENCODED"] = "jwt-encoded";
|
|
1687
1721
|
OriginalType2["JWT_DECODED"] = "jwt-decoded";
|
|
@@ -1690,16 +1724,16 @@ var OriginalType = /* @__PURE__ */ function(OriginalType2) {
|
|
|
1690
1724
|
OriginalType2["MSO_MDOC_ENCODED"] = "mso_mdoc-encoded";
|
|
1691
1725
|
OriginalType2["MSO_MDOC_DECODED"] = "mso_mdoc-decoded";
|
|
1692
1726
|
return OriginalType2;
|
|
1693
|
-
}({});
|
|
1727
|
+
})({});
|
|
1694
1728
|
var JWT_PROOF_TYPE_2020 = "JwtProof2020";
|
|
1695
|
-
var DocumentFormat = /* @__PURE__ */ function(DocumentFormat2) {
|
|
1729
|
+
var DocumentFormat = /* @__PURE__ */ (function(DocumentFormat2) {
|
|
1696
1730
|
DocumentFormat2[DocumentFormat2["JWT"] = 0] = "JWT";
|
|
1697
1731
|
DocumentFormat2[DocumentFormat2["JSONLD"] = 1] = "JSONLD";
|
|
1698
1732
|
DocumentFormat2[DocumentFormat2["SD_JWT_VC"] = 2] = "SD_JWT_VC";
|
|
1699
1733
|
DocumentFormat2[DocumentFormat2["EIP712"] = 3] = "EIP712";
|
|
1700
1734
|
DocumentFormat2[DocumentFormat2["MSO_MDOC"] = 4] = "MSO_MDOC";
|
|
1701
1735
|
return DocumentFormat2;
|
|
1702
|
-
}({});
|
|
1736
|
+
})({});
|
|
1703
1737
|
|
|
1704
1738
|
// src/mapper/jsonld-language-values.ts
|
|
1705
1739
|
var isLanguageValueObject = /* @__PURE__ */ __name((claim) => {
|