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