@sphereon/ssi-types 0.34.1-next.29 → 0.34.1-next.299
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 +129 -84
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +169 -111
- package/dist/index.d.ts +169 -111
- package/dist/index.js +129 -84
- package/dist/index.js.map +1 -1
- package/package.json +5 -3
- package/src/index.ts +1 -0
- package/src/mapper/credential-mapper.ts +46 -35
- 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 +19 -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 +30 -12
- package/src/utils/mdoc.ts +10 -9
- package/src/utils/sd-jwt.ts +32 -18
- 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,12 +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";
|
|
533
543
|
StatusListType2["BitstringStatusList"] = "BitstringStatusList";
|
|
534
544
|
return StatusListType2;
|
|
535
|
-
}({});
|
|
545
|
+
})({});
|
|
536
546
|
function isVcdmCredential(credential, vcdmType) {
|
|
537
547
|
if (!credential || typeof credential !== "object") {
|
|
538
548
|
return false;
|
|
@@ -569,7 +579,7 @@ var VCDM_CREDENTIAL_CONTEXT_VERSIONS = [
|
|
|
569
579
|
];
|
|
570
580
|
|
|
571
581
|
// src/utils/did.ts
|
|
572
|
-
var IProofPurpose = /* @__PURE__ */ function(IProofPurpose2) {
|
|
582
|
+
var IProofPurpose = /* @__PURE__ */ (function(IProofPurpose2) {
|
|
573
583
|
IProofPurpose2["verificationMethod"] = "verificationMethod";
|
|
574
584
|
IProofPurpose2["assertionMethod"] = "assertionMethod";
|
|
575
585
|
IProofPurpose2["authentication"] = "authentication";
|
|
@@ -578,8 +588,8 @@ var IProofPurpose = /* @__PURE__ */ function(IProofPurpose2) {
|
|
|
578
588
|
IProofPurpose2["capabilityInvocation"] = "capabilityInvocation";
|
|
579
589
|
IProofPurpose2["capabilityDelegation"] = "capabilityDelegation";
|
|
580
590
|
return IProofPurpose2;
|
|
581
|
-
}({});
|
|
582
|
-
var IProofType = /* @__PURE__ */ function(IProofType2) {
|
|
591
|
+
})({});
|
|
592
|
+
var IProofType = /* @__PURE__ */ (function(IProofType2) {
|
|
583
593
|
IProofType2["Ed25519Signature2018"] = "Ed25519Signature2018";
|
|
584
594
|
IProofType2["Ed25519Signature2020"] = "Ed25519Signature2020";
|
|
585
595
|
IProofType2["EcdsaSecp256k1Signature2019"] = "EcdsaSecp256k1Signature2019";
|
|
@@ -594,7 +604,7 @@ var IProofType = /* @__PURE__ */ function(IProofType2) {
|
|
|
594
604
|
IProofType2["SdJwtProof2024"] = "SdJwtProof2024";
|
|
595
605
|
IProofType2["MdocProof2024"] = "MsoMdocProof2024";
|
|
596
606
|
return IProofType2;
|
|
597
|
-
}({});
|
|
607
|
+
})({});
|
|
598
608
|
var parseDid = /* @__PURE__ */ __name((did) => {
|
|
599
609
|
const parsedDid = parse(did);
|
|
600
610
|
if (parsedDid === null) {
|
|
@@ -640,7 +650,8 @@ var parse = /* @__PURE__ */ __name((didUrl) => {
|
|
|
640
650
|
}, "parse");
|
|
641
651
|
|
|
642
652
|
// src/utils/mdoc.ts
|
|
643
|
-
var
|
|
653
|
+
var import_kmp_mdoc_core = __toESM(require("@sphereon/kmp-mdoc-core"), 1);
|
|
654
|
+
var { com } = import_kmp_mdoc_core.default;
|
|
644
655
|
function isWrappedMdocCredential(vc) {
|
|
645
656
|
return vc.format === "mso_mdoc";
|
|
646
657
|
}
|
|
@@ -649,12 +660,12 @@ function isWrappedMdocPresentation(vp) {
|
|
|
649
660
|
return vp.format === "mso_mdoc";
|
|
650
661
|
}
|
|
651
662
|
__name(isWrappedMdocPresentation, "isWrappedMdocPresentation");
|
|
652
|
-
function getMdocDecodedPayload(
|
|
653
|
-
const mdocJson =
|
|
663
|
+
function getMdocDecodedPayload(mdoc) {
|
|
664
|
+
const mdocJson = mdoc.toJson();
|
|
654
665
|
if (!mdocJson.issuerSigned.nameSpaces) {
|
|
655
666
|
throw Error(`Cannot access Issuer Signed items from the Mdoc`);
|
|
656
667
|
}
|
|
657
|
-
const issuerSignedJson =
|
|
668
|
+
const issuerSignedJson = mdoc.issuerSigned.toJsonDTO();
|
|
658
669
|
const namespaces = issuerSignedJson.nameSpaces;
|
|
659
670
|
const decodedPayload = {};
|
|
660
671
|
for (const [namespace, items] of Object.entries(namespaces)) {
|
|
@@ -667,17 +678,17 @@ function getMdocDecodedPayload(mdoc2) {
|
|
|
667
678
|
}
|
|
668
679
|
__name(getMdocDecodedPayload, "getMdocDecodedPayload");
|
|
669
680
|
function decodeMdocIssuerSigned(oid4vpIssuerSigned) {
|
|
670
|
-
const issuerSigned =
|
|
681
|
+
const issuerSigned = com.sphereon.mdoc.data.device.IssuerSignedCbor.Static.cborDecode(com.sphereon.kmp.decodeFrom(oid4vpIssuerSigned, com.sphereon.kmp.Encoding.BASE64URL));
|
|
671
682
|
const holderMdoc = issuerSigned.toDocument();
|
|
672
683
|
return holderMdoc;
|
|
673
684
|
}
|
|
674
685
|
__name(decodeMdocIssuerSigned, "decodeMdocIssuerSigned");
|
|
675
686
|
function encodeMdocIssuerSigned(issuerSigned, encoding = "base64url") {
|
|
676
|
-
return
|
|
687
|
+
return com.sphereon.kmp.encodeTo(issuerSigned.cborEncode(), com.sphereon.kmp.Encoding.BASE64URL);
|
|
677
688
|
}
|
|
678
689
|
__name(encodeMdocIssuerSigned, "encodeMdocIssuerSigned");
|
|
679
690
|
function decodeMdocDeviceResponse(vpToken) {
|
|
680
|
-
const deviceResponse =
|
|
691
|
+
const deviceResponse = com.sphereon.mdoc.data.device.DeviceResponseCbor.Static.cborDecode(com.sphereon.kmp.decodeFrom(vpToken, com.sphereon.kmp.Encoding.BASE64URL));
|
|
681
692
|
return deviceResponse;
|
|
682
693
|
}
|
|
683
694
|
__name(decodeMdocDeviceResponse, "decodeMdocDeviceResponse");
|
|
@@ -730,7 +741,7 @@ var mdocDecodedCredentialToUniformCredential = /* @__PURE__ */ __name((decoded,
|
|
|
730
741
|
created: issuanceDate,
|
|
731
742
|
proofPurpose: IProofPurpose.authentication,
|
|
732
743
|
verificationMethod: json.issuerSigned.issuerAuth.payload,
|
|
733
|
-
mso_mdoc:
|
|
744
|
+
mso_mdoc: com.sphereon.kmp.encodeTo(decoded.cborEncode(), com.sphereon.kmp.Encoding.BASE64URL)
|
|
734
745
|
}
|
|
735
746
|
};
|
|
736
747
|
return credential;
|
|
@@ -743,8 +754,10 @@ function decodeSdJwtVc(compactSdJwtVc, hasher) {
|
|
|
743
754
|
const signedPayload = jwt.payload;
|
|
744
755
|
const decodedPayload = (0, import_decode.getClaimsSync)(signedPayload, disclosures, hasher);
|
|
745
756
|
const compactKeyBindingJwt = kbJwt ? compactSdJwtVc.split("~").pop() : void 0;
|
|
757
|
+
const type = decodedPayload.vct ? "dc+sd-jwt" : "vc+sd-jwt";
|
|
746
758
|
return {
|
|
747
759
|
compactSdJwtVc,
|
|
760
|
+
type,
|
|
748
761
|
decodedPayload,
|
|
749
762
|
disclosures: disclosures.map((d) => {
|
|
750
763
|
const decoded = d.key ? [
|
|
@@ -778,8 +791,10 @@ async function decodeSdJwtVcAsync(compactSdJwtVc, hasher) {
|
|
|
778
791
|
const signedPayload = jwt.payload;
|
|
779
792
|
const decodedPayload = await (0, import_decode.getClaims)(signedPayload, disclosures, hasher);
|
|
780
793
|
const compactKeyBindingJwt = kbJwt ? compactSdJwtVc.split("~").pop() : void 0;
|
|
794
|
+
const type = decodedPayload.vct ? "dc+sd-jwt" : "vc+sd-jwt";
|
|
781
795
|
return {
|
|
782
796
|
compactSdJwtVc,
|
|
797
|
+
type,
|
|
783
798
|
decodedPayload,
|
|
784
799
|
disclosures: disclosures.map((d) => {
|
|
785
800
|
const decoded = d.key ? [
|
|
@@ -810,13 +825,19 @@ async function decodeSdJwtVcAsync(compactSdJwtVc, hasher) {
|
|
|
810
825
|
__name(decodeSdJwtVcAsync, "decodeSdJwtVcAsync");
|
|
811
826
|
var sdJwtDecodedCredentialToUniformCredential = /* @__PURE__ */ __name((decoded, opts) => {
|
|
812
827
|
const { decodedPayload } = decoded;
|
|
813
|
-
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);
|
|
814
835
|
const maxSkewInMS = opts?.maxTimeSkewInMS ?? 1500;
|
|
815
|
-
const expirationDate = jwtDateToISOString({
|
|
836
|
+
const expirationDate = validUntil ?? jwtDateToISOString({
|
|
816
837
|
jwtClaim: exp,
|
|
817
838
|
claimName: "exp"
|
|
818
839
|
});
|
|
819
|
-
let issuanceDateStr = jwtDateToISOString({
|
|
840
|
+
let issuanceDateStr = validFrom ?? jwtDateToISOString({
|
|
820
841
|
jwtClaim: iat,
|
|
821
842
|
claimName: "iat"
|
|
822
843
|
});
|
|
@@ -827,7 +848,7 @@ var sdJwtDecodedCredentialToUniformCredential = /* @__PURE__ */ __name((decoded,
|
|
|
827
848
|
claimName: "nbf"
|
|
828
849
|
});
|
|
829
850
|
if (issuanceDateStr && nbfDateAsStr && issuanceDateStr !== nbfDateAsStr) {
|
|
830
|
-
const diff = Math.abs(new Date(nbfDateAsStr).getTime() - new Date(
|
|
851
|
+
const diff = Math.abs(new Date(nbfDateAsStr).getTime() - new Date(issuanceDateStr).getTime());
|
|
831
852
|
if (!maxSkewInMS || diff > maxSkewInMS) {
|
|
832
853
|
throw Error(`Inconsistent issuance dates between JWT claim (${nbfDateAsStr}) and VC value (${iss})`);
|
|
833
854
|
}
|
|
@@ -848,24 +869,39 @@ var sdJwtDecodedCredentialToUniformCredential = /* @__PURE__ */ __name((decoded,
|
|
|
848
869
|
"jti",
|
|
849
870
|
"sub"
|
|
850
871
|
]);
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
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;
|
|
857
881
|
const credential = {
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
882
|
+
...{
|
|
883
|
+
type: sdJwtVc ? [
|
|
884
|
+
vct
|
|
885
|
+
] : decodedPayload.type
|
|
886
|
+
},
|
|
887
|
+
...{
|
|
888
|
+
"@context": sdJwtVc ? [] : decodedPayload["@context"]
|
|
889
|
+
},
|
|
862
890
|
credentialSubject: {
|
|
863
891
|
...credentialSubject,
|
|
864
|
-
id:
|
|
892
|
+
id: subId ?? jti
|
|
865
893
|
},
|
|
866
|
-
issuanceDate
|
|
867
|
-
|
|
868
|
-
|
|
894
|
+
...issuanceDate && (sdJwtVc ? {
|
|
895
|
+
issuanceDate
|
|
896
|
+
} : {
|
|
897
|
+
validFrom: issuanceDateStr
|
|
898
|
+
}),
|
|
899
|
+
...expirationDate && (sdJwtVc ? {
|
|
900
|
+
expirationDate
|
|
901
|
+
} : {
|
|
902
|
+
validUntil: expirationDate
|
|
903
|
+
}),
|
|
904
|
+
issuer,
|
|
869
905
|
...cnf && {
|
|
870
906
|
cnf
|
|
871
907
|
},
|
|
@@ -893,14 +929,14 @@ var jwtDateToISOString = /* @__PURE__ */ __name(({ jwtClaim, claimName, isRequir
|
|
|
893
929
|
}, "jwtDateToISOString");
|
|
894
930
|
|
|
895
931
|
// src/utils/jose.ts
|
|
896
|
-
var JwkKeyType = /* @__PURE__ */ function(JwkKeyType2) {
|
|
932
|
+
var JwkKeyType = /* @__PURE__ */ (function(JwkKeyType2) {
|
|
897
933
|
JwkKeyType2["EC"] = "EC";
|
|
898
934
|
JwkKeyType2["RSA"] = "RSA";
|
|
899
935
|
JwkKeyType2["oct"] = "oct";
|
|
900
936
|
JwkKeyType2["OKP"] = "OKP";
|
|
901
937
|
return JwkKeyType2;
|
|
902
|
-
}({});
|
|
903
|
-
var JoseSignatureAlgorithm = /* @__PURE__ */ function(JoseSignatureAlgorithm2) {
|
|
938
|
+
})({});
|
|
939
|
+
var JoseSignatureAlgorithm = /* @__PURE__ */ (function(JoseSignatureAlgorithm2) {
|
|
904
940
|
JoseSignatureAlgorithm2["RS256"] = "RS256";
|
|
905
941
|
JoseSignatureAlgorithm2["RS384"] = "RS384";
|
|
906
942
|
JoseSignatureAlgorithm2["RS512"] = "RS512";
|
|
@@ -917,8 +953,8 @@ var JoseSignatureAlgorithm = /* @__PURE__ */ function(JoseSignatureAlgorithm2) {
|
|
|
917
953
|
JoseSignatureAlgorithm2["PS512"] = "PS512";
|
|
918
954
|
JoseSignatureAlgorithm2["none"] = "none";
|
|
919
955
|
return JoseSignatureAlgorithm2;
|
|
920
|
-
}({});
|
|
921
|
-
var JoseKeyOperation = /* @__PURE__ */ function(JoseKeyOperation2) {
|
|
956
|
+
})({});
|
|
957
|
+
var JoseKeyOperation = /* @__PURE__ */ (function(JoseKeyOperation2) {
|
|
922
958
|
JoseKeyOperation2["SIGN"] = "sign";
|
|
923
959
|
JoseKeyOperation2["VERIFY"] = "verify";
|
|
924
960
|
JoseKeyOperation2["ENCRYPT"] = "encrypt";
|
|
@@ -928,8 +964,8 @@ var JoseKeyOperation = /* @__PURE__ */ function(JoseKeyOperation2) {
|
|
|
928
964
|
JoseKeyOperation2["DERIVE_KEY"] = "deriveKey";
|
|
929
965
|
JoseKeyOperation2["DERIVE_BITS"] = "deriveBits";
|
|
930
966
|
return JoseKeyOperation2;
|
|
931
|
-
}({});
|
|
932
|
-
var JoseCurve = /* @__PURE__ */ function(JoseCurve2) {
|
|
967
|
+
})({});
|
|
968
|
+
var JoseCurve = /* @__PURE__ */ (function(JoseCurve2) {
|
|
933
969
|
JoseCurve2["P_256"] = "P-256";
|
|
934
970
|
JoseCurve2["P_384"] = "P-384";
|
|
935
971
|
JoseCurve2["P_521"] = "P-521";
|
|
@@ -940,18 +976,18 @@ var JoseCurve = /* @__PURE__ */ function(JoseCurve2) {
|
|
|
940
976
|
JoseCurve2["Ed448"] = "Ed448";
|
|
941
977
|
JoseCurve2["secp256k1"] = "secp256k1";
|
|
942
978
|
return JoseCurve2;
|
|
943
|
-
}({});
|
|
979
|
+
})({});
|
|
944
980
|
|
|
945
981
|
// src/utils/cose.ts
|
|
946
|
-
var ICoseKeyType = /* @__PURE__ */ function(ICoseKeyType2) {
|
|
982
|
+
var ICoseKeyType = /* @__PURE__ */ (function(ICoseKeyType2) {
|
|
947
983
|
ICoseKeyType2[ICoseKeyType2["OKP"] = 1] = "OKP";
|
|
948
984
|
ICoseKeyType2[ICoseKeyType2["EC2"] = 2] = "EC2";
|
|
949
985
|
ICoseKeyType2[ICoseKeyType2["RSA"] = 3] = "RSA";
|
|
950
986
|
ICoseKeyType2[ICoseKeyType2["Symmetric"] = 4] = "Symmetric";
|
|
951
987
|
ICoseKeyType2[ICoseKeyType2["Reserved"] = 0] = "Reserved";
|
|
952
988
|
return ICoseKeyType2;
|
|
953
|
-
}({});
|
|
954
|
-
var ICoseSignatureAlgorithm = /* @__PURE__ */ function(ICoseSignatureAlgorithm2) {
|
|
989
|
+
})({});
|
|
990
|
+
var ICoseSignatureAlgorithm = /* @__PURE__ */ (function(ICoseSignatureAlgorithm2) {
|
|
955
991
|
ICoseSignatureAlgorithm2[ICoseSignatureAlgorithm2["ES256"] = -7] = "ES256";
|
|
956
992
|
ICoseSignatureAlgorithm2[ICoseSignatureAlgorithm2["ES256K"] = -47] = "ES256K";
|
|
957
993
|
ICoseSignatureAlgorithm2[ICoseSignatureAlgorithm2["ES384"] = -35] = "ES384";
|
|
@@ -965,8 +1001,8 @@ var ICoseSignatureAlgorithm = /* @__PURE__ */ function(ICoseSignatureAlgorithm2)
|
|
|
965
1001
|
ICoseSignatureAlgorithm2[ICoseSignatureAlgorithm2["PS384"] = -38] = "PS384";
|
|
966
1002
|
ICoseSignatureAlgorithm2[ICoseSignatureAlgorithm2["PS512"] = -39] = "PS512";
|
|
967
1003
|
return ICoseSignatureAlgorithm2;
|
|
968
|
-
}({});
|
|
969
|
-
var ICoseKeyOperation = /* @__PURE__ */ function(ICoseKeyOperation2) {
|
|
1004
|
+
})({});
|
|
1005
|
+
var ICoseKeyOperation = /* @__PURE__ */ (function(ICoseKeyOperation2) {
|
|
970
1006
|
ICoseKeyOperation2[ICoseKeyOperation2["SIGN"] = 1] = "SIGN";
|
|
971
1007
|
ICoseKeyOperation2[ICoseKeyOperation2["VERIFY"] = 2] = "VERIFY";
|
|
972
1008
|
ICoseKeyOperation2[ICoseKeyOperation2["ENCRYPT"] = 3] = "ENCRYPT";
|
|
@@ -978,8 +1014,8 @@ var ICoseKeyOperation = /* @__PURE__ */ function(ICoseKeyOperation2) {
|
|
|
978
1014
|
ICoseKeyOperation2[ICoseKeyOperation2["MAC_CREATE"] = 9] = "MAC_CREATE";
|
|
979
1015
|
ICoseKeyOperation2[ICoseKeyOperation2["MAC_VERIFY"] = 10] = "MAC_VERIFY";
|
|
980
1016
|
return ICoseKeyOperation2;
|
|
981
|
-
}({});
|
|
982
|
-
var ICoseCurve = /* @__PURE__ */ function(ICoseCurve2) {
|
|
1017
|
+
})({});
|
|
1018
|
+
var ICoseCurve = /* @__PURE__ */ (function(ICoseCurve2) {
|
|
983
1019
|
ICoseCurve2[ICoseCurve2["P_256"] = 1] = "P_256";
|
|
984
1020
|
ICoseCurve2[ICoseCurve2["P_384"] = 2] = "P_384";
|
|
985
1021
|
ICoseCurve2[ICoseCurve2["P_521"] = 3] = "P_521";
|
|
@@ -989,18 +1025,18 @@ var ICoseCurve = /* @__PURE__ */ function(ICoseCurve2) {
|
|
|
989
1025
|
ICoseCurve2[ICoseCurve2["Ed448"] = 7] = "Ed448";
|
|
990
1026
|
ICoseCurve2[ICoseCurve2["secp256k1"] = -1] = "secp256k1";
|
|
991
1027
|
return ICoseCurve2;
|
|
992
|
-
}({});
|
|
1028
|
+
})({});
|
|
993
1029
|
|
|
994
1030
|
// src/mapper/credential-constraints.ts
|
|
995
|
-
var StatusListCredentialIdMode = /* @__PURE__ */ function(StatusListCredentialIdMode2) {
|
|
1031
|
+
var StatusListCredentialIdMode = /* @__PURE__ */ (function(StatusListCredentialIdMode2) {
|
|
996
1032
|
StatusListCredentialIdMode2["ISSUANCE"] = "ISSUANCE";
|
|
997
1033
|
StatusListCredentialIdMode2["NEVER"] = "NEVER";
|
|
998
1034
|
return StatusListCredentialIdMode2;
|
|
999
|
-
}({});
|
|
1000
|
-
var StatusListDriverType = /* @__PURE__ */ function(StatusListDriverType2) {
|
|
1035
|
+
})({});
|
|
1036
|
+
var StatusListDriverType = /* @__PURE__ */ (function(StatusListDriverType2) {
|
|
1001
1037
|
StatusListDriverType2["AGENT_TYPEORM"] = "agent_typeorm";
|
|
1002
1038
|
return StatusListDriverType2;
|
|
1003
|
-
}({});
|
|
1039
|
+
})({});
|
|
1004
1040
|
|
|
1005
1041
|
// src/mapper/credential-mapper.ts
|
|
1006
1042
|
var import_jwt_decode = require("jwt-decode");
|
|
@@ -1065,6 +1101,7 @@ var CredentialMapper = class _CredentialMapper {
|
|
|
1065
1101
|
* an async hasher implementation, use the decodeSdJwtVcAsync method instead and you can provide the decoded payload to methods
|
|
1066
1102
|
* instead of the compact SD-JWT.
|
|
1067
1103
|
*
|
|
1104
|
+
* @param credential
|
|
1068
1105
|
* @param hasher Hasher implementation to use for SD-JWT decoding
|
|
1069
1106
|
*/
|
|
1070
1107
|
static decodeVerifiableCredential(credential, hasher) {
|
|
@@ -1101,7 +1138,8 @@ var CredentialMapper = class _CredentialMapper {
|
|
|
1101
1138
|
* an async hasher implementation, use the decodeSdJwtVcAsync method instead and you can provide the decoded payload to methods
|
|
1102
1139
|
* instead of the compact SD-JWT.
|
|
1103
1140
|
*
|
|
1104
|
-
* @param
|
|
1141
|
+
* @param originalPresentation
|
|
1142
|
+
* @param opts
|
|
1105
1143
|
*/
|
|
1106
1144
|
static toWrappedVerifiablePresentation(originalPresentation, opts) {
|
|
1107
1145
|
if (_CredentialMapper.isMsoMdocDecodedPresentation(originalPresentation) || _CredentialMapper.isMsoMdocOid4VPEncoded(originalPresentation)) {
|
|
@@ -1136,7 +1174,7 @@ var CredentialMapper = class _CredentialMapper {
|
|
|
1136
1174
|
}
|
|
1137
1175
|
return {
|
|
1138
1176
|
type: _CredentialMapper.isSdJwtDecodedCredential(originalPresentation) ? "sd-jwt-vc-decoded" : "sd-jwt-vc-encoded",
|
|
1139
|
-
format: "
|
|
1177
|
+
format: "dc+sd-jwt",
|
|
1140
1178
|
original: originalPresentation,
|
|
1141
1179
|
presentation: decodedPresentation,
|
|
1142
1180
|
decoded: decodedPresentation.decodedPayload,
|
|
@@ -1206,18 +1244,18 @@ var CredentialMapper = class _CredentialMapper {
|
|
|
1206
1244
|
*/
|
|
1207
1245
|
static toWrappedVerifiableCredential(verifiableCredential, opts) {
|
|
1208
1246
|
if (_CredentialMapper.isMsoMdocDecodedCredential(verifiableCredential) || _CredentialMapper.isMsoMdocOid4VPEncoded(verifiableCredential)) {
|
|
1209
|
-
let
|
|
1247
|
+
let mdoc;
|
|
1210
1248
|
if (_CredentialMapper.isMsoMdocOid4VPEncoded(verifiableCredential)) {
|
|
1211
|
-
|
|
1249
|
+
mdoc = decodeMdocIssuerSigned(verifiableCredential);
|
|
1212
1250
|
} else {
|
|
1213
|
-
|
|
1251
|
+
mdoc = verifiableCredential;
|
|
1214
1252
|
}
|
|
1215
1253
|
return {
|
|
1216
1254
|
type: _CredentialMapper.isMsoMdocDecodedCredential(verifiableCredential) ? "mso_mdoc-decoded" : "mso_mdoc-encoded",
|
|
1217
1255
|
format: "mso_mdoc",
|
|
1218
1256
|
original: verifiableCredential,
|
|
1219
|
-
credential:
|
|
1220
|
-
decoded: getMdocDecodedPayload(
|
|
1257
|
+
credential: mdoc,
|
|
1258
|
+
decoded: getMdocDecodedPayload(mdoc)
|
|
1221
1259
|
};
|
|
1222
1260
|
}
|
|
1223
1261
|
if (_CredentialMapper.isSdJwtDecodedCredential(verifiableCredential) || _CredentialMapper.isSdJwtEncoded(verifiableCredential)) {
|
|
@@ -1230,7 +1268,7 @@ var CredentialMapper = class _CredentialMapper {
|
|
|
1230
1268
|
}
|
|
1231
1269
|
return {
|
|
1232
1270
|
type: _CredentialMapper.isSdJwtDecodedCredential(verifiableCredential) ? "sd-jwt-vc-decoded" : "sd-jwt-vc-encoded",
|
|
1233
|
-
format: "
|
|
1271
|
+
format: "dc+sd-jwt",
|
|
1234
1272
|
original: verifiableCredential,
|
|
1235
1273
|
credential: decodedCredential,
|
|
1236
1274
|
decoded: decodedCredential.decodedPayload
|
|
@@ -1352,6 +1390,13 @@ var CredentialMapper = class _CredentialMapper {
|
|
|
1352
1390
|
static isSdJwtDecodedCredential(original) {
|
|
1353
1391
|
return typeof original === "object" && (original.compactSdJwtVc !== void 0 || original.kbJwt !== void 0);
|
|
1354
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
|
+
}
|
|
1355
1400
|
static isMsoMdocDecodedCredential(original) {
|
|
1356
1401
|
return typeof original === "object" && "issuerSigned" in original && original.issuerSigned !== void 0;
|
|
1357
1402
|
}
|
|
@@ -1675,14 +1720,14 @@ var CredentialMapper = class _CredentialMapper {
|
|
|
1675
1720
|
}
|
|
1676
1721
|
};
|
|
1677
1722
|
function isWrappedSdJwtVerifiableCredential(vc) {
|
|
1678
|
-
return vc.format === "
|
|
1723
|
+
return vc.format === "dc+sd-jwt";
|
|
1679
1724
|
}
|
|
1680
1725
|
__name(isWrappedSdJwtVerifiableCredential, "isWrappedSdJwtVerifiableCredential");
|
|
1681
1726
|
function isWrappedSdJwtVerifiablePresentation(vp) {
|
|
1682
|
-
return vp.format === "
|
|
1727
|
+
return vp.format === "dc+sd-jwt";
|
|
1683
1728
|
}
|
|
1684
1729
|
__name(isWrappedSdJwtVerifiablePresentation, "isWrappedSdJwtVerifiablePresentation");
|
|
1685
|
-
var OriginalType = /* @__PURE__ */ function(OriginalType2) {
|
|
1730
|
+
var OriginalType = /* @__PURE__ */ (function(OriginalType2) {
|
|
1686
1731
|
OriginalType2["JSONLD"] = "json-ld";
|
|
1687
1732
|
OriginalType2["JWT_ENCODED"] = "jwt-encoded";
|
|
1688
1733
|
OriginalType2["JWT_DECODED"] = "jwt-decoded";
|
|
@@ -1691,16 +1736,16 @@ var OriginalType = /* @__PURE__ */ function(OriginalType2) {
|
|
|
1691
1736
|
OriginalType2["MSO_MDOC_ENCODED"] = "mso_mdoc-encoded";
|
|
1692
1737
|
OriginalType2["MSO_MDOC_DECODED"] = "mso_mdoc-decoded";
|
|
1693
1738
|
return OriginalType2;
|
|
1694
|
-
}({});
|
|
1739
|
+
})({});
|
|
1695
1740
|
var JWT_PROOF_TYPE_2020 = "JwtProof2020";
|
|
1696
|
-
var DocumentFormat = /* @__PURE__ */ function(DocumentFormat2) {
|
|
1741
|
+
var DocumentFormat = /* @__PURE__ */ (function(DocumentFormat2) {
|
|
1697
1742
|
DocumentFormat2[DocumentFormat2["JWT"] = 0] = "JWT";
|
|
1698
1743
|
DocumentFormat2[DocumentFormat2["JSONLD"] = 1] = "JSONLD";
|
|
1699
1744
|
DocumentFormat2[DocumentFormat2["SD_JWT_VC"] = 2] = "SD_JWT_VC";
|
|
1700
1745
|
DocumentFormat2[DocumentFormat2["EIP712"] = 3] = "EIP712";
|
|
1701
1746
|
DocumentFormat2[DocumentFormat2["MSO_MDOC"] = 4] = "MSO_MDOC";
|
|
1702
1747
|
return DocumentFormat2;
|
|
1703
|
-
}({});
|
|
1748
|
+
})({});
|
|
1704
1749
|
|
|
1705
1750
|
// src/mapper/jsonld-language-values.ts
|
|
1706
1751
|
var isLanguageValueObject = /* @__PURE__ */ __name((claim) => {
|