@sphereon/ssi-sdk.vc-status-list 0.34.1-feature.SSISDK.26.54 → 0.34.1-feature.SSISDK.26.RP.55
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 +35 -36
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +35 -36
- package/dist/index.js.map +1 -1
- package/package.json +8 -8
- package/src/impl/encoding/cbor.ts +44 -41
package/dist/index.cjs
CHANGED
|
@@ -563,12 +563,11 @@ var getSigningAlgo = /* @__PURE__ */ __name((type) => {
|
|
|
563
563
|
// src/impl/encoding/cbor.ts
|
|
564
564
|
var import_jwt_status_list2 = require("@sd-jwt/jwt-status-list");
|
|
565
565
|
var import_pako = require("pako");
|
|
566
|
-
var
|
|
566
|
+
var mdoc = __toESM(require("@sphereon/kmp-mdoc-core"), 1);
|
|
567
567
|
var import_base64url2 = __toESM(require("base64url"), 1);
|
|
568
|
-
var
|
|
569
|
-
var
|
|
570
|
-
var
|
|
571
|
-
var CborString = com.sphereon.cbor.CborString;
|
|
568
|
+
var CborByteString = mdoc.com.sphereon.cbor.CborByteString;
|
|
569
|
+
var CborUInt = mdoc.com.sphereon.cbor.CborUInt;
|
|
570
|
+
var CborString = mdoc.com.sphereon.cbor.CborString;
|
|
572
571
|
var decompressRawStatusList = import_jwt_status_list2.StatusList.decodeStatusList.bind(import_jwt_status_list2.StatusList);
|
|
573
572
|
var CWT_CLAIMS = {
|
|
574
573
|
SUBJECT: 2,
|
|
@@ -585,25 +584,25 @@ var createSignedCbor = /* @__PURE__ */ __name(async (context, statusList, issuer
|
|
|
585
584
|
level: 9
|
|
586
585
|
});
|
|
587
586
|
const compressedBytes = new Int8Array(compressedList);
|
|
588
|
-
const statusListMap = new com.sphereon.cbor.CborMap(kotlin.collections.KtMutableMap.fromJsMap(/* @__PURE__ */ new Map([
|
|
587
|
+
const statusListMap = new mdoc.com.sphereon.cbor.CborMap(mdoc.kotlin.collections.KtMutableMap.fromJsMap(/* @__PURE__ */ new Map([
|
|
589
588
|
[
|
|
590
|
-
new com.sphereon.cbor.CborString("bits"),
|
|
591
|
-
new com.sphereon.cbor.CborUInt(com.sphereon.kmp.LongKMP.fromNumber(statusList.getBitsPerStatus()))
|
|
589
|
+
new mdoc.com.sphereon.cbor.CborString("bits"),
|
|
590
|
+
new mdoc.com.sphereon.cbor.CborUInt(mdoc.com.sphereon.kmp.LongKMP.fromNumber(statusList.getBitsPerStatus()))
|
|
592
591
|
],
|
|
593
592
|
[
|
|
594
|
-
new com.sphereon.cbor.CborString("lst"),
|
|
595
|
-
new com.sphereon.cbor.CborByteString(compressedBytes)
|
|
593
|
+
new mdoc.com.sphereon.cbor.CborString("lst"),
|
|
594
|
+
new mdoc.com.sphereon.cbor.CborByteString(compressedBytes)
|
|
596
595
|
]
|
|
597
596
|
])));
|
|
598
|
-
const protectedHeader = new com.sphereon.cbor.CborMap(kotlin.collections.KtMutableMap.fromJsMap(/* @__PURE__ */ new Map([
|
|
597
|
+
const protectedHeader = new mdoc.com.sphereon.cbor.CborMap(mdoc.kotlin.collections.KtMutableMap.fromJsMap(/* @__PURE__ */ new Map([
|
|
599
598
|
[
|
|
600
|
-
new com.sphereon.cbor.CborUInt(com.sphereon.kmp.LongKMP.fromNumber(16)),
|
|
601
|
-
new com.sphereon.cbor.CborString("statuslist+cwt")
|
|
599
|
+
new mdoc.com.sphereon.cbor.CborUInt(mdoc.com.sphereon.kmp.LongKMP.fromNumber(16)),
|
|
600
|
+
new mdoc.com.sphereon.cbor.CborString("statuslist+cwt")
|
|
602
601
|
]
|
|
603
602
|
])));
|
|
604
|
-
const protectedHeaderEncoded = com.sphereon.cbor.Cbor.encode(protectedHeader);
|
|
603
|
+
const protectedHeaderEncoded = mdoc.com.sphereon.cbor.Cbor.encode(protectedHeader);
|
|
605
604
|
const claimsMap = buildClaimsMap(id, issuerString, statusListMap, expiresAt);
|
|
606
|
-
const claimsEncoded = com.sphereon.cbor.Cbor.encode(claimsMap);
|
|
605
|
+
const claimsEncoded = mdoc.com.sphereon.cbor.Cbor.encode(claimsMap);
|
|
607
606
|
const signedCWT = await context.agent.keyManagerSign({
|
|
608
607
|
keyRef: identifier.kmsKeyRef,
|
|
609
608
|
data: import_base64url2.default.encode(Buffer.from(claimsEncoded)),
|
|
@@ -618,8 +617,8 @@ var createSignedCbor = /* @__PURE__ */ __name(async (context, statusList, issuer
|
|
|
618
617
|
new CborByteString(claimsEncodedInt8),
|
|
619
618
|
new CborByteString(signatureInt8)
|
|
620
619
|
];
|
|
621
|
-
const cwtArray = new com.sphereon.cbor.CborArray(kotlin.collections.KtMutableList.fromJsArray(cwtArrayElements));
|
|
622
|
-
const cwtEncoded = com.sphereon.cbor.Cbor.encode(cwtArray);
|
|
620
|
+
const cwtArray = new mdoc.com.sphereon.cbor.CborArray(mdoc.kotlin.collections.KtMutableList.fromJsArray(cwtArrayElements));
|
|
621
|
+
const cwtEncoded = mdoc.com.sphereon.cbor.Cbor.encode(cwtArray);
|
|
623
622
|
const cwtBuffer = Buffer.from(cwtEncoded);
|
|
624
623
|
return {
|
|
625
624
|
statusListCredential: import_base64url2.default.encode(cwtBuffer),
|
|
@@ -630,35 +629,35 @@ function buildClaimsMap(id, issuerString, statusListMap, expiresAt) {
|
|
|
630
629
|
const ttl = 65535;
|
|
631
630
|
const claimsEntries = [
|
|
632
631
|
[
|
|
633
|
-
new CborUInt(com.sphereon.kmp.LongKMP.fromNumber(CWT_CLAIMS.SUBJECT)),
|
|
634
|
-
new com.sphereon.cbor.CborString(id)
|
|
632
|
+
new CborUInt(mdoc.com.sphereon.kmp.LongKMP.fromNumber(CWT_CLAIMS.SUBJECT)),
|
|
633
|
+
new mdoc.com.sphereon.cbor.CborString(id)
|
|
635
634
|
],
|
|
636
635
|
[
|
|
637
|
-
new CborUInt(com.sphereon.kmp.LongKMP.fromNumber(CWT_CLAIMS.ISSUER)),
|
|
638
|
-
new com.sphereon.cbor.CborString(issuerString)
|
|
636
|
+
new CborUInt(mdoc.com.sphereon.kmp.LongKMP.fromNumber(CWT_CLAIMS.ISSUER)),
|
|
637
|
+
new mdoc.com.sphereon.cbor.CborString(issuerString)
|
|
639
638
|
],
|
|
640
639
|
[
|
|
641
|
-
new CborUInt(com.sphereon.kmp.LongKMP.fromNumber(CWT_CLAIMS.ISSUED_AT)),
|
|
642
|
-
new CborUInt(com.sphereon.kmp.LongKMP.fromNumber(Math.floor(Date.now() / 1e3)))
|
|
640
|
+
new CborUInt(mdoc.com.sphereon.kmp.LongKMP.fromNumber(CWT_CLAIMS.ISSUED_AT)),
|
|
641
|
+
new CborUInt(mdoc.com.sphereon.kmp.LongKMP.fromNumber(Math.floor(Date.now() / 1e3)))
|
|
643
642
|
]
|
|
644
643
|
];
|
|
645
644
|
if (expiresAt) {
|
|
646
645
|
claimsEntries.push([
|
|
647
|
-
new com.sphereon.cbor.CborUInt(com.sphereon.kmp.LongKMP.fromNumber(CWT_CLAIMS.EXPIRATION)),
|
|
648
|
-
new com.sphereon.cbor.CborUInt(com.sphereon.kmp.LongKMP.fromNumber(Math.floor(expiresAt.getTime() / 1e3)))
|
|
646
|
+
new mdoc.com.sphereon.cbor.CborUInt(mdoc.com.sphereon.kmp.LongKMP.fromNumber(CWT_CLAIMS.EXPIRATION)),
|
|
647
|
+
new mdoc.com.sphereon.cbor.CborUInt(mdoc.com.sphereon.kmp.LongKMP.fromNumber(Math.floor(expiresAt.getTime() / 1e3)))
|
|
649
648
|
]);
|
|
650
649
|
}
|
|
651
650
|
if (ttl) {
|
|
652
651
|
claimsEntries.push([
|
|
653
|
-
new com.sphereon.cbor.CborUInt(com.sphereon.kmp.LongKMP.fromNumber(CWT_CLAIMS.TIME_TO_LIVE)),
|
|
654
|
-
new com.sphereon.cbor.CborUInt(com.sphereon.kmp.LongKMP.fromNumber(ttl))
|
|
652
|
+
new mdoc.com.sphereon.cbor.CborUInt(mdoc.com.sphereon.kmp.LongKMP.fromNumber(CWT_CLAIMS.TIME_TO_LIVE)),
|
|
653
|
+
new mdoc.com.sphereon.cbor.CborUInt(mdoc.com.sphereon.kmp.LongKMP.fromNumber(ttl))
|
|
655
654
|
]);
|
|
656
655
|
}
|
|
657
656
|
claimsEntries.push([
|
|
658
|
-
new com.sphereon.cbor.CborUInt(com.sphereon.kmp.LongKMP.fromNumber(CWT_CLAIMS.STATUS_LIST)),
|
|
657
|
+
new mdoc.com.sphereon.cbor.CborUInt(mdoc.com.sphereon.kmp.LongKMP.fromNumber(CWT_CLAIMS.STATUS_LIST)),
|
|
659
658
|
statusListMap
|
|
660
659
|
]);
|
|
661
|
-
const claimsMap = new com.sphereon.cbor.CborMap(kotlin.collections.KtMutableMap.fromJsMap(new Map(claimsEntries)));
|
|
660
|
+
const claimsMap = new mdoc.com.sphereon.cbor.CborMap(mdoc.kotlin.collections.KtMutableMap.fromJsMap(new Map(claimsEntries)));
|
|
662
661
|
return claimsMap;
|
|
663
662
|
}
|
|
664
663
|
__name(buildClaimsMap, "buildClaimsMap");
|
|
@@ -670,7 +669,7 @@ var getCborValueFromMap = /* @__PURE__ */ __name((map, key) => {
|
|
|
670
669
|
return value;
|
|
671
670
|
}, "getCborValueFromMap");
|
|
672
671
|
var getCborOptionalValueFromMap = /* @__PURE__ */ __name((map, key) => {
|
|
673
|
-
const value = map.get(new CborUInt(com.sphereon.kmp.LongKMP.fromNumber(key)));
|
|
672
|
+
const value = map.get(new CborUInt(mdoc.com.sphereon.kmp.LongKMP.fromNumber(key)));
|
|
674
673
|
if (!value) {
|
|
675
674
|
return void 0;
|
|
676
675
|
}
|
|
@@ -679,20 +678,20 @@ var getCborOptionalValueFromMap = /* @__PURE__ */ __name((map, key) => {
|
|
|
679
678
|
var decodeStatusListCWT = /* @__PURE__ */ __name((cwt) => {
|
|
680
679
|
const encodedCbor = import_base64url2.default.toBuffer(cwt);
|
|
681
680
|
const encodedCborArray = new Int8Array(encodedCbor);
|
|
682
|
-
const decodedCbor = com.sphereon.cbor.Cbor.decode(encodedCborArray);
|
|
683
|
-
if (!(decodedCbor instanceof com.sphereon.cbor.CborArray)) {
|
|
681
|
+
const decodedCbor = mdoc.com.sphereon.cbor.Cbor.decode(encodedCborArray);
|
|
682
|
+
if (!(decodedCbor instanceof mdoc.com.sphereon.cbor.CborArray)) {
|
|
684
683
|
throw new Error("Invalid CWT format: Expected a CBOR array");
|
|
685
684
|
}
|
|
686
685
|
const [, payload] = decodedCbor.value.asJsArrayView();
|
|
687
|
-
if (!(payload instanceof com.sphereon.cbor.CborByteString)) {
|
|
686
|
+
if (!(payload instanceof mdoc.com.sphereon.cbor.CborByteString)) {
|
|
688
687
|
throw new Error("Invalid payload format: Expected a CBOR ByteString");
|
|
689
688
|
}
|
|
690
|
-
const claims = com.sphereon.cbor.Cbor.decode(payload.value);
|
|
691
|
-
if (!(claims instanceof com.sphereon.cbor.CborMap)) {
|
|
689
|
+
const claims = mdoc.com.sphereon.cbor.Cbor.decode(payload.value);
|
|
690
|
+
if (!(claims instanceof mdoc.com.sphereon.cbor.CborMap)) {
|
|
692
691
|
throw new Error("Invalid claims format: Expected a CBOR map");
|
|
693
692
|
}
|
|
694
693
|
const claimsMap = claims.value.asJsMapView();
|
|
695
|
-
const statusListMap = claimsMap.get(new CborUInt(com.sphereon.kmp.LongKMP.fromNumber(65533))).value.asJsMapView();
|
|
694
|
+
const statusListMap = claimsMap.get(new CborUInt(mdoc.com.sphereon.kmp.LongKMP.fromNumber(65533))).value.asJsMapView();
|
|
696
695
|
const bits = Number(statusListMap.get(new CborString("bits")).value);
|
|
697
696
|
const decoded = new Uint8Array(statusListMap.get(new CborString("lst")).value);
|
|
698
697
|
const uint8Array = (0, import_pako.inflate)(decoded);
|