@sphereon/ssi-types 0.34.1-next.3 → 0.34.1-next.322
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 +130 -84
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +172 -113
- package/dist/index.d.ts +172 -113
- package/dist/index.js +130 -84
- package/dist/index.js.map +1 -1
- package/package.json +5 -3
- package/src/index.ts +1 -1
- package/src/mapper/credential-mapper.ts +21 -10
- package/src/types/cose.ts +5 -4
- package/src/types/datastore.ts +6 -0
- package/src/types/index.ts +2 -1
- package/src/types/mso_mdoc.ts +9 -9
- package/src/types/sd-jwt-vc.ts +17 -10
- package/src/types/vc.ts +42 -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 +29 -12
- package/src/utils/mdoc.ts +8 -7
- package/src/utils/sd-jwt.ts +46 -27
- package/src/utils/vc.ts +1 -0
- package/src/types/dcql.ts +0 -39
package/dist/index.cjs
CHANGED
|
@@ -34,6 +34,7 @@ __export(index_exports, {
|
|
|
34
34
|
ActionType: () => ActionType,
|
|
35
35
|
BasicEventEmitter: () => BasicEventEmitter,
|
|
36
36
|
CredentialMapper: () => CredentialMapper,
|
|
37
|
+
CredentialRole: () => CredentialRole,
|
|
37
38
|
DefaultActionSubType: () => DefaultActionSubType,
|
|
38
39
|
DocumentFormat: () => DocumentFormat,
|
|
39
40
|
EventManager: () => EventManager,
|
|
@@ -100,26 +101,26 @@ module.exports = __toCommonJS(index_exports);
|
|
|
100
101
|
// src/logging/index.ts
|
|
101
102
|
var import_debug = __toESM(require("debug"), 1);
|
|
102
103
|
var import_events = require("events");
|
|
103
|
-
var LogLevel = /* @__PURE__ */ function(LogLevel2) {
|
|
104
|
+
var LogLevel = /* @__PURE__ */ (function(LogLevel2) {
|
|
104
105
|
LogLevel2[LogLevel2["TRACE"] = 0] = "TRACE";
|
|
105
106
|
LogLevel2[LogLevel2["DEBUG"] = 1] = "DEBUG";
|
|
106
107
|
LogLevel2[LogLevel2["INFO"] = 2] = "INFO";
|
|
107
108
|
LogLevel2[LogLevel2["WARNING"] = 3] = "WARNING";
|
|
108
109
|
LogLevel2[LogLevel2["ERROR"] = 4] = "ERROR";
|
|
109
110
|
return LogLevel2;
|
|
110
|
-
}({});
|
|
111
|
-
var LoggingEventType = /* @__PURE__ */ function(LoggingEventType2) {
|
|
111
|
+
})({});
|
|
112
|
+
var LoggingEventType = /* @__PURE__ */ (function(LoggingEventType2) {
|
|
112
113
|
LoggingEventType2["AUDIT"] = "audit";
|
|
113
114
|
LoggingEventType2["ACTIVITY"] = "activity";
|
|
114
115
|
LoggingEventType2["GENERAL"] = "general";
|
|
115
116
|
return LoggingEventType2;
|
|
116
|
-
}({});
|
|
117
|
-
var LogMethod = /* @__PURE__ */ function(LogMethod2) {
|
|
117
|
+
})({});
|
|
118
|
+
var LogMethod = /* @__PURE__ */ (function(LogMethod2) {
|
|
118
119
|
LogMethod2[LogMethod2["DEBUG_PKG"] = 0] = "DEBUG_PKG";
|
|
119
120
|
LogMethod2[LogMethod2["CONSOLE"] = 1] = "CONSOLE";
|
|
120
121
|
LogMethod2[LogMethod2["EVENT"] = 2] = "EVENT";
|
|
121
122
|
return LogMethod2;
|
|
122
|
-
}({});
|
|
123
|
+
})({});
|
|
123
124
|
function logOptions(opts) {
|
|
124
125
|
return {
|
|
125
126
|
namespace: opts?.namespace ?? "sphereon",
|
|
@@ -294,9 +295,18 @@ var SimpleRecordLogger = class extends SimpleLogger {
|
|
|
294
295
|
}
|
|
295
296
|
};
|
|
296
297
|
|
|
298
|
+
// src/types/datastore.ts
|
|
299
|
+
var CredentialRole = /* @__PURE__ */ (function(CredentialRole2) {
|
|
300
|
+
CredentialRole2["ISSUER"] = "ISSUER";
|
|
301
|
+
CredentialRole2["VERIFIER"] = "VERIFIER";
|
|
302
|
+
CredentialRole2["HOLDER"] = "HOLDER";
|
|
303
|
+
CredentialRole2["FEDERATION_TRUST_ANCHOR"] = "FEDERATION_TRUST_ANCHOR";
|
|
304
|
+
return CredentialRole2;
|
|
305
|
+
})({});
|
|
306
|
+
|
|
297
307
|
// src/events/index.ts
|
|
298
308
|
var import_events2 = require("events");
|
|
299
|
-
var System = /* @__PURE__ */ function(System2) {
|
|
309
|
+
var System = /* @__PURE__ */ (function(System2) {
|
|
300
310
|
System2["GENERAL"] = "general";
|
|
301
311
|
System2["KMS"] = "kms";
|
|
302
312
|
System2["IDENTITY"] = "identity";
|
|
@@ -309,8 +319,8 @@ var System = /* @__PURE__ */ function(System2) {
|
|
|
309
319
|
System2["PROFILE"] = "profile";
|
|
310
320
|
System2["CONTACT"] = "contact";
|
|
311
321
|
return System2;
|
|
312
|
-
}({});
|
|
313
|
-
var SubSystem = /* @__PURE__ */ function(SubSystem2) {
|
|
322
|
+
})({});
|
|
323
|
+
var SubSystem = /* @__PURE__ */ (function(SubSystem2) {
|
|
314
324
|
SubSystem2["KEY"] = "key";
|
|
315
325
|
SubSystem2["DID_PROVIDER"] = "did_provider";
|
|
316
326
|
SubSystem2["DID_RESOLVER"] = "did_resolver";
|
|
@@ -325,16 +335,16 @@ var SubSystem = /* @__PURE__ */ function(SubSystem2) {
|
|
|
325
335
|
SubSystem2["PROFILE"] = "profile";
|
|
326
336
|
SubSystem2["API"] = "api";
|
|
327
337
|
return SubSystem2;
|
|
328
|
-
}({});
|
|
329
|
-
var ActionType = /* @__PURE__ */ function(ActionType2) {
|
|
338
|
+
})({});
|
|
339
|
+
var ActionType = /* @__PURE__ */ (function(ActionType2) {
|
|
330
340
|
ActionType2["CREATE"] = "create";
|
|
331
341
|
ActionType2["READ"] = "read";
|
|
332
342
|
ActionType2["UPDATE"] = "update";
|
|
333
343
|
ActionType2["DELETE"] = "delete";
|
|
334
344
|
ActionType2["EXECUTE"] = "execute";
|
|
335
345
|
return ActionType2;
|
|
336
|
-
}({});
|
|
337
|
-
var DefaultActionSubType = /* @__PURE__ */ function(DefaultActionSubType2) {
|
|
346
|
+
})({});
|
|
347
|
+
var DefaultActionSubType = /* @__PURE__ */ (function(DefaultActionSubType2) {
|
|
338
348
|
DefaultActionSubType2["KEY_GENERATION"] = "Key generation";
|
|
339
349
|
DefaultActionSubType2["KEY_IMPORT"] = "Key import";
|
|
340
350
|
DefaultActionSubType2["KEY_PERSISTENCE"] = "Key persistence";
|
|
@@ -349,14 +359,14 @@ var DefaultActionSubType = /* @__PURE__ */ function(DefaultActionSubType2) {
|
|
|
349
359
|
DefaultActionSubType2["VC_ISSUE_DECLINE"] = "VC issue decline";
|
|
350
360
|
DefaultActionSubType2["VC_SHARE_DECLINE"] = "VC share decline";
|
|
351
361
|
return DefaultActionSubType2;
|
|
352
|
-
}({});
|
|
353
|
-
var InitiatorType = /* @__PURE__ */ function(InitiatorType2) {
|
|
362
|
+
})({});
|
|
363
|
+
var InitiatorType = /* @__PURE__ */ (function(InitiatorType2) {
|
|
354
364
|
InitiatorType2["USER"] = "user";
|
|
355
365
|
InitiatorType2["SYSTEM"] = "system";
|
|
356
366
|
InitiatorType2["EXTERNAL"] = "external";
|
|
357
367
|
return InitiatorType2;
|
|
358
|
-
}({});
|
|
359
|
-
var SystemCorrelationIdType = /* @__PURE__ */ function(SystemCorrelationIdType2) {
|
|
368
|
+
})({});
|
|
369
|
+
var SystemCorrelationIdType = /* @__PURE__ */ (function(SystemCorrelationIdType2) {
|
|
360
370
|
SystemCorrelationIdType2["DID"] = "did";
|
|
361
371
|
SystemCorrelationIdType2["URL"] = "url";
|
|
362
372
|
SystemCorrelationIdType2["EMAIL"] = "email";
|
|
@@ -364,7 +374,7 @@ var SystemCorrelationIdType = /* @__PURE__ */ function(SystemCorrelationIdType2)
|
|
|
364
374
|
SystemCorrelationIdType2["PHONE"] = "phone";
|
|
365
375
|
SystemCorrelationIdType2["USER"] = "user";
|
|
366
376
|
return SystemCorrelationIdType2;
|
|
367
|
-
}({});
|
|
377
|
+
})({});
|
|
368
378
|
var EventManager = class _EventManager {
|
|
369
379
|
static {
|
|
370
380
|
__name(this, "EventManager");
|
|
@@ -527,11 +537,12 @@ function isWrappedW3CVerifiablePresentation(vp) {
|
|
|
527
537
|
return vp.format === "jwt_vp" || vp.format === "ldp_vp";
|
|
528
538
|
}
|
|
529
539
|
__name(isWrappedW3CVerifiablePresentation, "isWrappedW3CVerifiablePresentation");
|
|
530
|
-
var StatusListType = /* @__PURE__ */ function(StatusListType2) {
|
|
540
|
+
var StatusListType = /* @__PURE__ */ (function(StatusListType2) {
|
|
531
541
|
StatusListType2["StatusList2021"] = "StatusList2021";
|
|
532
542
|
StatusListType2["OAuthStatusList"] = "OAuthStatusList";
|
|
543
|
+
StatusListType2["BitstringStatusList"] = "BitstringStatusList";
|
|
533
544
|
return StatusListType2;
|
|
534
|
-
}({});
|
|
545
|
+
})({});
|
|
535
546
|
function isVcdmCredential(credential, vcdmType) {
|
|
536
547
|
if (!credential || typeof credential !== "object") {
|
|
537
548
|
return false;
|
|
@@ -568,7 +579,7 @@ var VCDM_CREDENTIAL_CONTEXT_VERSIONS = [
|
|
|
568
579
|
];
|
|
569
580
|
|
|
570
581
|
// src/utils/did.ts
|
|
571
|
-
var IProofPurpose = /* @__PURE__ */ function(IProofPurpose2) {
|
|
582
|
+
var IProofPurpose = /* @__PURE__ */ (function(IProofPurpose2) {
|
|
572
583
|
IProofPurpose2["verificationMethod"] = "verificationMethod";
|
|
573
584
|
IProofPurpose2["assertionMethod"] = "assertionMethod";
|
|
574
585
|
IProofPurpose2["authentication"] = "authentication";
|
|
@@ -577,8 +588,8 @@ var IProofPurpose = /* @__PURE__ */ function(IProofPurpose2) {
|
|
|
577
588
|
IProofPurpose2["capabilityInvocation"] = "capabilityInvocation";
|
|
578
589
|
IProofPurpose2["capabilityDelegation"] = "capabilityDelegation";
|
|
579
590
|
return IProofPurpose2;
|
|
580
|
-
}({});
|
|
581
|
-
var IProofType = /* @__PURE__ */ function(IProofType2) {
|
|
591
|
+
})({});
|
|
592
|
+
var IProofType = /* @__PURE__ */ (function(IProofType2) {
|
|
582
593
|
IProofType2["Ed25519Signature2018"] = "Ed25519Signature2018";
|
|
583
594
|
IProofType2["Ed25519Signature2020"] = "Ed25519Signature2020";
|
|
584
595
|
IProofType2["EcdsaSecp256k1Signature2019"] = "EcdsaSecp256k1Signature2019";
|
|
@@ -593,7 +604,7 @@ var IProofType = /* @__PURE__ */ function(IProofType2) {
|
|
|
593
604
|
IProofType2["SdJwtProof2024"] = "SdJwtProof2024";
|
|
594
605
|
IProofType2["MdocProof2024"] = "MsoMdocProof2024";
|
|
595
606
|
return IProofType2;
|
|
596
|
-
}({});
|
|
607
|
+
})({});
|
|
597
608
|
var parseDid = /* @__PURE__ */ __name((did) => {
|
|
598
609
|
const parsedDid = parse(did);
|
|
599
610
|
if (parsedDid === null) {
|
|
@@ -639,7 +650,8 @@ var parse = /* @__PURE__ */ __name((didUrl) => {
|
|
|
639
650
|
}, "parse");
|
|
640
651
|
|
|
641
652
|
// src/utils/mdoc.ts
|
|
642
|
-
var
|
|
653
|
+
var import_kmp_mdoc_core = __toESM(require("@sphereon/kmp-mdoc-core"), 1);
|
|
654
|
+
var { com } = import_kmp_mdoc_core.default;
|
|
643
655
|
function isWrappedMdocCredential(vc) {
|
|
644
656
|
return vc.format === "mso_mdoc";
|
|
645
657
|
}
|
|
@@ -648,12 +660,12 @@ function isWrappedMdocPresentation(vp) {
|
|
|
648
660
|
return vp.format === "mso_mdoc";
|
|
649
661
|
}
|
|
650
662
|
__name(isWrappedMdocPresentation, "isWrappedMdocPresentation");
|
|
651
|
-
function getMdocDecodedPayload(
|
|
652
|
-
const mdocJson =
|
|
663
|
+
function getMdocDecodedPayload(mdoc) {
|
|
664
|
+
const mdocJson = mdoc.toJson();
|
|
653
665
|
if (!mdocJson.issuerSigned.nameSpaces) {
|
|
654
666
|
throw Error(`Cannot access Issuer Signed items from the Mdoc`);
|
|
655
667
|
}
|
|
656
|
-
const issuerSignedJson =
|
|
668
|
+
const issuerSignedJson = mdoc.issuerSigned.toJsonDTO();
|
|
657
669
|
const namespaces = issuerSignedJson.nameSpaces;
|
|
658
670
|
const decodedPayload = {};
|
|
659
671
|
for (const [namespace, items] of Object.entries(namespaces)) {
|
|
@@ -666,17 +678,17 @@ function getMdocDecodedPayload(mdoc2) {
|
|
|
666
678
|
}
|
|
667
679
|
__name(getMdocDecodedPayload, "getMdocDecodedPayload");
|
|
668
680
|
function decodeMdocIssuerSigned(oid4vpIssuerSigned) {
|
|
669
|
-
const issuerSigned =
|
|
681
|
+
const issuerSigned = com.sphereon.mdoc.data.device.IssuerSignedCbor.Static.cborDecode(com.sphereon.kmp.decodeFrom(oid4vpIssuerSigned, com.sphereon.kmp.Encoding.BASE64URL));
|
|
670
682
|
const holderMdoc = issuerSigned.toDocument();
|
|
671
683
|
return holderMdoc;
|
|
672
684
|
}
|
|
673
685
|
__name(decodeMdocIssuerSigned, "decodeMdocIssuerSigned");
|
|
674
686
|
function encodeMdocIssuerSigned(issuerSigned, encoding = "base64url") {
|
|
675
|
-
return
|
|
687
|
+
return com.sphereon.kmp.encodeTo(issuerSigned.cborEncode(), com.sphereon.kmp.Encoding.BASE64URL);
|
|
676
688
|
}
|
|
677
689
|
__name(encodeMdocIssuerSigned, "encodeMdocIssuerSigned");
|
|
678
690
|
function decodeMdocDeviceResponse(vpToken) {
|
|
679
|
-
const deviceResponse =
|
|
691
|
+
const deviceResponse = com.sphereon.mdoc.data.device.DeviceResponseCbor.Static.cborDecode(com.sphereon.kmp.decodeFrom(vpToken, com.sphereon.kmp.Encoding.BASE64URL));
|
|
680
692
|
return deviceResponse;
|
|
681
693
|
}
|
|
682
694
|
__name(decodeMdocDeviceResponse, "decodeMdocDeviceResponse");
|
|
@@ -729,7 +741,7 @@ var mdocDecodedCredentialToUniformCredential = /* @__PURE__ */ __name((decoded,
|
|
|
729
741
|
created: issuanceDate,
|
|
730
742
|
proofPurpose: IProofPurpose.authentication,
|
|
731
743
|
verificationMethod: json.issuerSigned.issuerAuth.payload,
|
|
732
|
-
mso_mdoc:
|
|
744
|
+
mso_mdoc: com.sphereon.kmp.encodeTo(decoded.cborEncode(), com.sphereon.kmp.Encoding.BASE64URL)
|
|
733
745
|
}
|
|
734
746
|
};
|
|
735
747
|
return credential;
|
|
@@ -742,8 +754,10 @@ function decodeSdJwtVc(compactSdJwtVc, hasher) {
|
|
|
742
754
|
const signedPayload = jwt.payload;
|
|
743
755
|
const decodedPayload = (0, import_decode.getClaimsSync)(signedPayload, disclosures, hasher);
|
|
744
756
|
const compactKeyBindingJwt = kbJwt ? compactSdJwtVc.split("~").pop() : void 0;
|
|
757
|
+
const type = decodedPayload.vct ? "dc+sd-jwt" : "vc+sd-jwt";
|
|
745
758
|
return {
|
|
746
759
|
compactSdJwtVc,
|
|
760
|
+
type,
|
|
747
761
|
decodedPayload,
|
|
748
762
|
disclosures: disclosures.map((d) => {
|
|
749
763
|
const decoded = d.key ? [
|
|
@@ -777,8 +791,10 @@ async function decodeSdJwtVcAsync(compactSdJwtVc, hasher) {
|
|
|
777
791
|
const signedPayload = jwt.payload;
|
|
778
792
|
const decodedPayload = await (0, import_decode.getClaims)(signedPayload, disclosures, hasher);
|
|
779
793
|
const compactKeyBindingJwt = kbJwt ? compactSdJwtVc.split("~").pop() : void 0;
|
|
794
|
+
const type = decodedPayload.vct ? "dc+sd-jwt" : "vc+sd-jwt";
|
|
780
795
|
return {
|
|
781
796
|
compactSdJwtVc,
|
|
797
|
+
type,
|
|
782
798
|
decodedPayload,
|
|
783
799
|
disclosures: disclosures.map((d) => {
|
|
784
800
|
const decoded = d.key ? [
|
|
@@ -809,13 +825,19 @@ async function decodeSdJwtVcAsync(compactSdJwtVc, hasher) {
|
|
|
809
825
|
__name(decodeSdJwtVcAsync, "decodeSdJwtVcAsync");
|
|
810
826
|
var sdJwtDecodedCredentialToUniformCredential = /* @__PURE__ */ __name((decoded, opts) => {
|
|
811
827
|
const { decodedPayload } = decoded;
|
|
812
|
-
const { exp, nbf, iss, iat, vct, cnf, status,
|
|
828
|
+
const { exp, nbf, iss, iat, vct, cnf, status, jti, validUntil, validFrom } = decodedPayload;
|
|
829
|
+
let credentialSubject = decodedPayload.credentialSubject;
|
|
830
|
+
let issuer = iss ?? decodedPayload.issuer;
|
|
831
|
+
if (typeof issuer === "object" && "id" in issuer && typeof issuer.id === "string") {
|
|
832
|
+
issuer = issuer.id;
|
|
833
|
+
}
|
|
834
|
+
const subId = decodedPayload.sub ?? (typeof credentialSubject == "object" && "id" in credentialSubject ? credentialSubject.id : void 0);
|
|
813
835
|
const maxSkewInMS = opts?.maxTimeSkewInMS ?? 1500;
|
|
814
|
-
const expirationDate = jwtDateToISOString({
|
|
836
|
+
const expirationDate = validUntil ?? jwtDateToISOString({
|
|
815
837
|
jwtClaim: exp,
|
|
816
838
|
claimName: "exp"
|
|
817
839
|
});
|
|
818
|
-
let issuanceDateStr = jwtDateToISOString({
|
|
840
|
+
let issuanceDateStr = validFrom ?? jwtDateToISOString({
|
|
819
841
|
jwtClaim: iat,
|
|
820
842
|
claimName: "iat"
|
|
821
843
|
});
|
|
@@ -826,7 +848,7 @@ var sdJwtDecodedCredentialToUniformCredential = /* @__PURE__ */ __name((decoded,
|
|
|
826
848
|
claimName: "nbf"
|
|
827
849
|
});
|
|
828
850
|
if (issuanceDateStr && nbfDateAsStr && issuanceDateStr !== nbfDateAsStr) {
|
|
829
|
-
const diff = Math.abs(new Date(nbfDateAsStr).getTime() - new Date(
|
|
851
|
+
const diff = Math.abs(new Date(nbfDateAsStr).getTime() - new Date(issuanceDateStr).getTime());
|
|
830
852
|
if (!maxSkewInMS || diff > maxSkewInMS) {
|
|
831
853
|
throw Error(`Inconsistent issuance dates between JWT claim (${nbfDateAsStr}) and VC value (${iss})`);
|
|
832
854
|
}
|
|
@@ -847,24 +869,39 @@ var sdJwtDecodedCredentialToUniformCredential = /* @__PURE__ */ __name((decoded,
|
|
|
847
869
|
"jti",
|
|
848
870
|
"sub"
|
|
849
871
|
]);
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
872
|
+
if (!credentialSubject) {
|
|
873
|
+
credentialSubject = Object.entries(decodedPayload).reduce((acc, [key, value]) => {
|
|
874
|
+
if (!excludedFields.has(key) && value !== void 0 && value !== "" && !(typeof value === "object" && value !== null && Object.keys(value).length === 0)) {
|
|
875
|
+
acc[key] = value;
|
|
876
|
+
}
|
|
877
|
+
return acc;
|
|
878
|
+
}, {});
|
|
879
|
+
}
|
|
880
|
+
const sdJwtVc = decodedPayload.vct && !decodedPayload.type;
|
|
856
881
|
const credential = {
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
882
|
+
...{
|
|
883
|
+
type: sdJwtVc ? [
|
|
884
|
+
vct
|
|
885
|
+
] : decodedPayload.type
|
|
886
|
+
},
|
|
887
|
+
...{
|
|
888
|
+
"@context": sdJwtVc ? [] : decodedPayload["@context"]
|
|
889
|
+
},
|
|
861
890
|
credentialSubject: {
|
|
862
891
|
...credentialSubject,
|
|
863
|
-
id:
|
|
892
|
+
id: subId ?? jti
|
|
864
893
|
},
|
|
865
|
-
issuanceDate
|
|
866
|
-
|
|
867
|
-
|
|
894
|
+
...issuanceDate && (sdJwtVc ? {
|
|
895
|
+
issuanceDate
|
|
896
|
+
} : {
|
|
897
|
+
validFrom: issuanceDateStr
|
|
898
|
+
}),
|
|
899
|
+
...expirationDate && (sdJwtVc ? {
|
|
900
|
+
expirationDate
|
|
901
|
+
} : {
|
|
902
|
+
validUntil: expirationDate
|
|
903
|
+
}),
|
|
904
|
+
issuer,
|
|
868
905
|
...cnf && {
|
|
869
906
|
cnf
|
|
870
907
|
},
|
|
@@ -892,14 +929,14 @@ var jwtDateToISOString = /* @__PURE__ */ __name(({ jwtClaim, claimName, isRequir
|
|
|
892
929
|
}, "jwtDateToISOString");
|
|
893
930
|
|
|
894
931
|
// src/utils/jose.ts
|
|
895
|
-
var JwkKeyType = /* @__PURE__ */ function(JwkKeyType2) {
|
|
932
|
+
var JwkKeyType = /* @__PURE__ */ (function(JwkKeyType2) {
|
|
896
933
|
JwkKeyType2["EC"] = "EC";
|
|
897
934
|
JwkKeyType2["RSA"] = "RSA";
|
|
898
935
|
JwkKeyType2["oct"] = "oct";
|
|
899
936
|
JwkKeyType2["OKP"] = "OKP";
|
|
900
937
|
return JwkKeyType2;
|
|
901
|
-
}({});
|
|
902
|
-
var JoseSignatureAlgorithm = /* @__PURE__ */ function(JoseSignatureAlgorithm2) {
|
|
938
|
+
})({});
|
|
939
|
+
var JoseSignatureAlgorithm = /* @__PURE__ */ (function(JoseSignatureAlgorithm2) {
|
|
903
940
|
JoseSignatureAlgorithm2["RS256"] = "RS256";
|
|
904
941
|
JoseSignatureAlgorithm2["RS384"] = "RS384";
|
|
905
942
|
JoseSignatureAlgorithm2["RS512"] = "RS512";
|
|
@@ -916,8 +953,8 @@ var JoseSignatureAlgorithm = /* @__PURE__ */ function(JoseSignatureAlgorithm2) {
|
|
|
916
953
|
JoseSignatureAlgorithm2["PS512"] = "PS512";
|
|
917
954
|
JoseSignatureAlgorithm2["none"] = "none";
|
|
918
955
|
return JoseSignatureAlgorithm2;
|
|
919
|
-
}({});
|
|
920
|
-
var JoseKeyOperation = /* @__PURE__ */ function(JoseKeyOperation2) {
|
|
956
|
+
})({});
|
|
957
|
+
var JoseKeyOperation = /* @__PURE__ */ (function(JoseKeyOperation2) {
|
|
921
958
|
JoseKeyOperation2["SIGN"] = "sign";
|
|
922
959
|
JoseKeyOperation2["VERIFY"] = "verify";
|
|
923
960
|
JoseKeyOperation2["ENCRYPT"] = "encrypt";
|
|
@@ -927,8 +964,8 @@ var JoseKeyOperation = /* @__PURE__ */ function(JoseKeyOperation2) {
|
|
|
927
964
|
JoseKeyOperation2["DERIVE_KEY"] = "deriveKey";
|
|
928
965
|
JoseKeyOperation2["DERIVE_BITS"] = "deriveBits";
|
|
929
966
|
return JoseKeyOperation2;
|
|
930
|
-
}({});
|
|
931
|
-
var JoseCurve = /* @__PURE__ */ function(JoseCurve2) {
|
|
967
|
+
})({});
|
|
968
|
+
var JoseCurve = /* @__PURE__ */ (function(JoseCurve2) {
|
|
932
969
|
JoseCurve2["P_256"] = "P-256";
|
|
933
970
|
JoseCurve2["P_384"] = "P-384";
|
|
934
971
|
JoseCurve2["P_521"] = "P-521";
|
|
@@ -939,18 +976,18 @@ var JoseCurve = /* @__PURE__ */ function(JoseCurve2) {
|
|
|
939
976
|
JoseCurve2["Ed448"] = "Ed448";
|
|
940
977
|
JoseCurve2["secp256k1"] = "secp256k1";
|
|
941
978
|
return JoseCurve2;
|
|
942
|
-
}({});
|
|
979
|
+
})({});
|
|
943
980
|
|
|
944
981
|
// src/utils/cose.ts
|
|
945
|
-
var ICoseKeyType = /* @__PURE__ */ function(ICoseKeyType2) {
|
|
982
|
+
var ICoseKeyType = /* @__PURE__ */ (function(ICoseKeyType2) {
|
|
946
983
|
ICoseKeyType2[ICoseKeyType2["OKP"] = 1] = "OKP";
|
|
947
984
|
ICoseKeyType2[ICoseKeyType2["EC2"] = 2] = "EC2";
|
|
948
985
|
ICoseKeyType2[ICoseKeyType2["RSA"] = 3] = "RSA";
|
|
949
986
|
ICoseKeyType2[ICoseKeyType2["Symmetric"] = 4] = "Symmetric";
|
|
950
987
|
ICoseKeyType2[ICoseKeyType2["Reserved"] = 0] = "Reserved";
|
|
951
988
|
return ICoseKeyType2;
|
|
952
|
-
}({});
|
|
953
|
-
var ICoseSignatureAlgorithm = /* @__PURE__ */ function(ICoseSignatureAlgorithm2) {
|
|
989
|
+
})({});
|
|
990
|
+
var ICoseSignatureAlgorithm = /* @__PURE__ */ (function(ICoseSignatureAlgorithm2) {
|
|
954
991
|
ICoseSignatureAlgorithm2[ICoseSignatureAlgorithm2["ES256"] = -7] = "ES256";
|
|
955
992
|
ICoseSignatureAlgorithm2[ICoseSignatureAlgorithm2["ES256K"] = -47] = "ES256K";
|
|
956
993
|
ICoseSignatureAlgorithm2[ICoseSignatureAlgorithm2["ES384"] = -35] = "ES384";
|
|
@@ -964,8 +1001,8 @@ var ICoseSignatureAlgorithm = /* @__PURE__ */ function(ICoseSignatureAlgorithm2)
|
|
|
964
1001
|
ICoseSignatureAlgorithm2[ICoseSignatureAlgorithm2["PS384"] = -38] = "PS384";
|
|
965
1002
|
ICoseSignatureAlgorithm2[ICoseSignatureAlgorithm2["PS512"] = -39] = "PS512";
|
|
966
1003
|
return ICoseSignatureAlgorithm2;
|
|
967
|
-
}({});
|
|
968
|
-
var ICoseKeyOperation = /* @__PURE__ */ function(ICoseKeyOperation2) {
|
|
1004
|
+
})({});
|
|
1005
|
+
var ICoseKeyOperation = /* @__PURE__ */ (function(ICoseKeyOperation2) {
|
|
969
1006
|
ICoseKeyOperation2[ICoseKeyOperation2["SIGN"] = 1] = "SIGN";
|
|
970
1007
|
ICoseKeyOperation2[ICoseKeyOperation2["VERIFY"] = 2] = "VERIFY";
|
|
971
1008
|
ICoseKeyOperation2[ICoseKeyOperation2["ENCRYPT"] = 3] = "ENCRYPT";
|
|
@@ -977,8 +1014,8 @@ var ICoseKeyOperation = /* @__PURE__ */ function(ICoseKeyOperation2) {
|
|
|
977
1014
|
ICoseKeyOperation2[ICoseKeyOperation2["MAC_CREATE"] = 9] = "MAC_CREATE";
|
|
978
1015
|
ICoseKeyOperation2[ICoseKeyOperation2["MAC_VERIFY"] = 10] = "MAC_VERIFY";
|
|
979
1016
|
return ICoseKeyOperation2;
|
|
980
|
-
}({});
|
|
981
|
-
var ICoseCurve = /* @__PURE__ */ function(ICoseCurve2) {
|
|
1017
|
+
})({});
|
|
1018
|
+
var ICoseCurve = /* @__PURE__ */ (function(ICoseCurve2) {
|
|
982
1019
|
ICoseCurve2[ICoseCurve2["P_256"] = 1] = "P_256";
|
|
983
1020
|
ICoseCurve2[ICoseCurve2["P_384"] = 2] = "P_384";
|
|
984
1021
|
ICoseCurve2[ICoseCurve2["P_521"] = 3] = "P_521";
|
|
@@ -988,18 +1025,18 @@ var ICoseCurve = /* @__PURE__ */ function(ICoseCurve2) {
|
|
|
988
1025
|
ICoseCurve2[ICoseCurve2["Ed448"] = 7] = "Ed448";
|
|
989
1026
|
ICoseCurve2[ICoseCurve2["secp256k1"] = -1] = "secp256k1";
|
|
990
1027
|
return ICoseCurve2;
|
|
991
|
-
}({});
|
|
1028
|
+
})({});
|
|
992
1029
|
|
|
993
1030
|
// src/mapper/credential-constraints.ts
|
|
994
|
-
var StatusListCredentialIdMode = /* @__PURE__ */ function(StatusListCredentialIdMode2) {
|
|
1031
|
+
var StatusListCredentialIdMode = /* @__PURE__ */ (function(StatusListCredentialIdMode2) {
|
|
995
1032
|
StatusListCredentialIdMode2["ISSUANCE"] = "ISSUANCE";
|
|
996
1033
|
StatusListCredentialIdMode2["NEVER"] = "NEVER";
|
|
997
1034
|
return StatusListCredentialIdMode2;
|
|
998
|
-
}({});
|
|
999
|
-
var StatusListDriverType = /* @__PURE__ */ function(StatusListDriverType2) {
|
|
1035
|
+
})({});
|
|
1036
|
+
var StatusListDriverType = /* @__PURE__ */ (function(StatusListDriverType2) {
|
|
1000
1037
|
StatusListDriverType2["AGENT_TYPEORM"] = "agent_typeorm";
|
|
1001
1038
|
return StatusListDriverType2;
|
|
1002
|
-
}({});
|
|
1039
|
+
})({});
|
|
1003
1040
|
|
|
1004
1041
|
// src/mapper/credential-mapper.ts
|
|
1005
1042
|
var import_jwt_decode = require("jwt-decode");
|
|
@@ -1064,6 +1101,7 @@ var CredentialMapper = class _CredentialMapper {
|
|
|
1064
1101
|
* an async hasher implementation, use the decodeSdJwtVcAsync method instead and you can provide the decoded payload to methods
|
|
1065
1102
|
* instead of the compact SD-JWT.
|
|
1066
1103
|
*
|
|
1104
|
+
* @param credential
|
|
1067
1105
|
* @param hasher Hasher implementation to use for SD-JWT decoding
|
|
1068
1106
|
*/
|
|
1069
1107
|
static decodeVerifiableCredential(credential, hasher) {
|
|
@@ -1100,7 +1138,8 @@ var CredentialMapper = class _CredentialMapper {
|
|
|
1100
1138
|
* an async hasher implementation, use the decodeSdJwtVcAsync method instead and you can provide the decoded payload to methods
|
|
1101
1139
|
* instead of the compact SD-JWT.
|
|
1102
1140
|
*
|
|
1103
|
-
* @param
|
|
1141
|
+
* @param originalPresentation
|
|
1142
|
+
* @param opts
|
|
1104
1143
|
*/
|
|
1105
1144
|
static toWrappedVerifiablePresentation(originalPresentation, opts) {
|
|
1106
1145
|
if (_CredentialMapper.isMsoMdocDecodedPresentation(originalPresentation) || _CredentialMapper.isMsoMdocOid4VPEncoded(originalPresentation)) {
|
|
@@ -1135,7 +1174,7 @@ var CredentialMapper = class _CredentialMapper {
|
|
|
1135
1174
|
}
|
|
1136
1175
|
return {
|
|
1137
1176
|
type: _CredentialMapper.isSdJwtDecodedCredential(originalPresentation) ? "sd-jwt-vc-decoded" : "sd-jwt-vc-encoded",
|
|
1138
|
-
format: "
|
|
1177
|
+
format: "dc+sd-jwt",
|
|
1139
1178
|
original: originalPresentation,
|
|
1140
1179
|
presentation: decodedPresentation,
|
|
1141
1180
|
decoded: decodedPresentation.decodedPayload,
|
|
@@ -1205,18 +1244,18 @@ var CredentialMapper = class _CredentialMapper {
|
|
|
1205
1244
|
*/
|
|
1206
1245
|
static toWrappedVerifiableCredential(verifiableCredential, opts) {
|
|
1207
1246
|
if (_CredentialMapper.isMsoMdocDecodedCredential(verifiableCredential) || _CredentialMapper.isMsoMdocOid4VPEncoded(verifiableCredential)) {
|
|
1208
|
-
let
|
|
1247
|
+
let mdoc;
|
|
1209
1248
|
if (_CredentialMapper.isMsoMdocOid4VPEncoded(verifiableCredential)) {
|
|
1210
|
-
|
|
1249
|
+
mdoc = decodeMdocIssuerSigned(verifiableCredential);
|
|
1211
1250
|
} else {
|
|
1212
|
-
|
|
1251
|
+
mdoc = verifiableCredential;
|
|
1213
1252
|
}
|
|
1214
1253
|
return {
|
|
1215
1254
|
type: _CredentialMapper.isMsoMdocDecodedCredential(verifiableCredential) ? "mso_mdoc-decoded" : "mso_mdoc-encoded",
|
|
1216
1255
|
format: "mso_mdoc",
|
|
1217
1256
|
original: verifiableCredential,
|
|
1218
|
-
credential:
|
|
1219
|
-
decoded: getMdocDecodedPayload(
|
|
1257
|
+
credential: mdoc,
|
|
1258
|
+
decoded: getMdocDecodedPayload(mdoc)
|
|
1220
1259
|
};
|
|
1221
1260
|
}
|
|
1222
1261
|
if (_CredentialMapper.isSdJwtDecodedCredential(verifiableCredential) || _CredentialMapper.isSdJwtEncoded(verifiableCredential)) {
|
|
@@ -1229,7 +1268,7 @@ var CredentialMapper = class _CredentialMapper {
|
|
|
1229
1268
|
}
|
|
1230
1269
|
return {
|
|
1231
1270
|
type: _CredentialMapper.isSdJwtDecodedCredential(verifiableCredential) ? "sd-jwt-vc-decoded" : "sd-jwt-vc-encoded",
|
|
1232
|
-
format: "
|
|
1271
|
+
format: "dc+sd-jwt",
|
|
1233
1272
|
original: verifiableCredential,
|
|
1234
1273
|
credential: decodedCredential,
|
|
1235
1274
|
decoded: decodedCredential.decodedPayload
|
|
@@ -1351,6 +1390,13 @@ var CredentialMapper = class _CredentialMapper {
|
|
|
1351
1390
|
static isSdJwtDecodedCredential(original) {
|
|
1352
1391
|
return typeof original === "object" && (original.compactSdJwtVc !== void 0 || original.kbJwt !== void 0);
|
|
1353
1392
|
}
|
|
1393
|
+
static isSdJwtVcdm2DecodedCredential(original) {
|
|
1394
|
+
if (typeof original !== "object") {
|
|
1395
|
+
return false;
|
|
1396
|
+
}
|
|
1397
|
+
const decoded = original;
|
|
1398
|
+
return decoded.compactSdJwtVc !== void 0 && !decoded.decodedPayload.vct && !decoded.decodedPayload["@context"];
|
|
1399
|
+
}
|
|
1354
1400
|
static isMsoMdocDecodedCredential(original) {
|
|
1355
1401
|
return typeof original === "object" && "issuerSigned" in original && original.issuerSigned !== void 0;
|
|
1356
1402
|
}
|
|
@@ -1674,14 +1720,14 @@ var CredentialMapper = class _CredentialMapper {
|
|
|
1674
1720
|
}
|
|
1675
1721
|
};
|
|
1676
1722
|
function isWrappedSdJwtVerifiableCredential(vc) {
|
|
1677
|
-
return vc.format === "
|
|
1723
|
+
return vc.format === "dc+sd-jwt";
|
|
1678
1724
|
}
|
|
1679
1725
|
__name(isWrappedSdJwtVerifiableCredential, "isWrappedSdJwtVerifiableCredential");
|
|
1680
1726
|
function isWrappedSdJwtVerifiablePresentation(vp) {
|
|
1681
|
-
return vp.format === "
|
|
1727
|
+
return vp.format === "dc+sd-jwt";
|
|
1682
1728
|
}
|
|
1683
1729
|
__name(isWrappedSdJwtVerifiablePresentation, "isWrappedSdJwtVerifiablePresentation");
|
|
1684
|
-
var OriginalType = /* @__PURE__ */ function(OriginalType2) {
|
|
1730
|
+
var OriginalType = /* @__PURE__ */ (function(OriginalType2) {
|
|
1685
1731
|
OriginalType2["JSONLD"] = "json-ld";
|
|
1686
1732
|
OriginalType2["JWT_ENCODED"] = "jwt-encoded";
|
|
1687
1733
|
OriginalType2["JWT_DECODED"] = "jwt-decoded";
|
|
@@ -1690,16 +1736,16 @@ var OriginalType = /* @__PURE__ */ function(OriginalType2) {
|
|
|
1690
1736
|
OriginalType2["MSO_MDOC_ENCODED"] = "mso_mdoc-encoded";
|
|
1691
1737
|
OriginalType2["MSO_MDOC_DECODED"] = "mso_mdoc-decoded";
|
|
1692
1738
|
return OriginalType2;
|
|
1693
|
-
}({});
|
|
1739
|
+
})({});
|
|
1694
1740
|
var JWT_PROOF_TYPE_2020 = "JwtProof2020";
|
|
1695
|
-
var DocumentFormat = /* @__PURE__ */ function(DocumentFormat2) {
|
|
1741
|
+
var DocumentFormat = /* @__PURE__ */ (function(DocumentFormat2) {
|
|
1696
1742
|
DocumentFormat2[DocumentFormat2["JWT"] = 0] = "JWT";
|
|
1697
1743
|
DocumentFormat2[DocumentFormat2["JSONLD"] = 1] = "JSONLD";
|
|
1698
1744
|
DocumentFormat2[DocumentFormat2["SD_JWT_VC"] = 2] = "SD_JWT_VC";
|
|
1699
1745
|
DocumentFormat2[DocumentFormat2["EIP712"] = 3] = "EIP712";
|
|
1700
1746
|
DocumentFormat2[DocumentFormat2["MSO_MDOC"] = 4] = "MSO_MDOC";
|
|
1701
1747
|
return DocumentFormat2;
|
|
1702
|
-
}({});
|
|
1748
|
+
})({});
|
|
1703
1749
|
|
|
1704
1750
|
// src/mapper/jsonld-language-values.ts
|
|
1705
1751
|
var isLanguageValueObject = /* @__PURE__ */ __name((claim) => {
|