@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.js
CHANGED
|
@@ -514,11 +514,12 @@ var getSigningAlgo = /* @__PURE__ */ __name((type) => {
|
|
|
514
514
|
// src/impl/encoding/cbor.ts
|
|
515
515
|
import { StatusList as StatusList3 } from "@sd-jwt/jwt-status-list";
|
|
516
516
|
import { deflate, inflate } from "pako";
|
|
517
|
-
import
|
|
517
|
+
import mdocPkg from "@sphereon/kmp-mdoc-core";
|
|
518
518
|
import base64url2 from "base64url";
|
|
519
|
-
var
|
|
520
|
-
var
|
|
521
|
-
var
|
|
519
|
+
var { com, kotlin } = mdocPkg;
|
|
520
|
+
var CborByteString = mdocPkg.com.sphereon.cbor.CborByteString;
|
|
521
|
+
var CborUInt = mdocPkg.com.sphereon.cbor.CborUInt;
|
|
522
|
+
var CborString = mdocPkg.com.sphereon.cbor.CborString;
|
|
522
523
|
var decompressRawStatusList = StatusList3.decodeStatusList.bind(StatusList3);
|
|
523
524
|
var CWT_CLAIMS = {
|
|
524
525
|
SUBJECT: 2,
|
|
@@ -535,25 +536,25 @@ var createSignedCbor = /* @__PURE__ */ __name(async (context, statusList, issuer
|
|
|
535
536
|
level: 9
|
|
536
537
|
});
|
|
537
538
|
const compressedBytes = new Int8Array(compressedList);
|
|
538
|
-
const statusListMap = new
|
|
539
|
+
const statusListMap = new com.sphereon.cbor.CborMap(kotlin.collections.KtMutableMap.fromJsMap(/* @__PURE__ */ new Map([
|
|
539
540
|
[
|
|
540
|
-
new
|
|
541
|
-
new
|
|
541
|
+
new com.sphereon.cbor.CborString("bits"),
|
|
542
|
+
new com.sphereon.cbor.CborUInt(com.sphereon.kmp.LongKMP.fromNumber(statusList.getBitsPerStatus()))
|
|
542
543
|
],
|
|
543
544
|
[
|
|
544
|
-
new
|
|
545
|
-
new
|
|
545
|
+
new com.sphereon.cbor.CborString("lst"),
|
|
546
|
+
new com.sphereon.cbor.CborByteString(compressedBytes)
|
|
546
547
|
]
|
|
547
548
|
])));
|
|
548
|
-
const protectedHeader = new
|
|
549
|
+
const protectedHeader = new com.sphereon.cbor.CborMap(kotlin.collections.KtMutableMap.fromJsMap(/* @__PURE__ */ new Map([
|
|
549
550
|
[
|
|
550
|
-
new
|
|
551
|
-
new
|
|
551
|
+
new com.sphereon.cbor.CborUInt(com.sphereon.kmp.LongKMP.fromNumber(16)),
|
|
552
|
+
new com.sphereon.cbor.CborString("statuslist+cwt")
|
|
552
553
|
]
|
|
553
554
|
])));
|
|
554
|
-
const protectedHeaderEncoded =
|
|
555
|
+
const protectedHeaderEncoded = com.sphereon.cbor.Cbor.encode(protectedHeader);
|
|
555
556
|
const claimsMap = buildClaimsMap(id, issuerString, statusListMap, expiresAt);
|
|
556
|
-
const claimsEncoded =
|
|
557
|
+
const claimsEncoded = com.sphereon.cbor.Cbor.encode(claimsMap);
|
|
557
558
|
const signedCWT = await context.agent.keyManagerSign({
|
|
558
559
|
keyRef: identifier.kmsKeyRef,
|
|
559
560
|
data: base64url2.encode(Buffer.from(claimsEncoded)),
|
|
@@ -568,8 +569,8 @@ var createSignedCbor = /* @__PURE__ */ __name(async (context, statusList, issuer
|
|
|
568
569
|
new CborByteString(claimsEncodedInt8),
|
|
569
570
|
new CborByteString(signatureInt8)
|
|
570
571
|
];
|
|
571
|
-
const cwtArray = new
|
|
572
|
-
const cwtEncoded =
|
|
572
|
+
const cwtArray = new com.sphereon.cbor.CborArray(kotlin.collections.KtMutableList.fromJsArray(cwtArrayElements));
|
|
573
|
+
const cwtEncoded = com.sphereon.cbor.Cbor.encode(cwtArray);
|
|
573
574
|
const cwtBuffer = Buffer.from(cwtEncoded);
|
|
574
575
|
return {
|
|
575
576
|
statusListCredential: base64url2.encode(cwtBuffer),
|
|
@@ -580,35 +581,35 @@ function buildClaimsMap(id, issuerString, statusListMap, expiresAt) {
|
|
|
580
581
|
const ttl = 65535;
|
|
581
582
|
const claimsEntries = [
|
|
582
583
|
[
|
|
583
|
-
new CborUInt(
|
|
584
|
-
new
|
|
584
|
+
new CborUInt(com.sphereon.kmp.LongKMP.fromNumber(CWT_CLAIMS.SUBJECT)),
|
|
585
|
+
new com.sphereon.cbor.CborString(id)
|
|
585
586
|
],
|
|
586
587
|
[
|
|
587
|
-
new CborUInt(
|
|
588
|
-
new
|
|
588
|
+
new CborUInt(com.sphereon.kmp.LongKMP.fromNumber(CWT_CLAIMS.ISSUER)),
|
|
589
|
+
new com.sphereon.cbor.CborString(issuerString)
|
|
589
590
|
],
|
|
590
591
|
[
|
|
591
|
-
new CborUInt(
|
|
592
|
-
new CborUInt(
|
|
592
|
+
new CborUInt(com.sphereon.kmp.LongKMP.fromNumber(CWT_CLAIMS.ISSUED_AT)),
|
|
593
|
+
new CborUInt(com.sphereon.kmp.LongKMP.fromNumber(Math.floor(Date.now() / 1e3)))
|
|
593
594
|
]
|
|
594
595
|
];
|
|
595
596
|
if (expiresAt) {
|
|
596
597
|
claimsEntries.push([
|
|
597
|
-
new
|
|
598
|
-
new
|
|
598
|
+
new com.sphereon.cbor.CborUInt(com.sphereon.kmp.LongKMP.fromNumber(CWT_CLAIMS.EXPIRATION)),
|
|
599
|
+
new com.sphereon.cbor.CborUInt(com.sphereon.kmp.LongKMP.fromNumber(Math.floor(expiresAt.getTime() / 1e3)))
|
|
599
600
|
]);
|
|
600
601
|
}
|
|
601
602
|
if (ttl) {
|
|
602
603
|
claimsEntries.push([
|
|
603
|
-
new
|
|
604
|
-
new
|
|
604
|
+
new com.sphereon.cbor.CborUInt(com.sphereon.kmp.LongKMP.fromNumber(CWT_CLAIMS.TIME_TO_LIVE)),
|
|
605
|
+
new com.sphereon.cbor.CborUInt(com.sphereon.kmp.LongKMP.fromNumber(ttl))
|
|
605
606
|
]);
|
|
606
607
|
}
|
|
607
608
|
claimsEntries.push([
|
|
608
|
-
new
|
|
609
|
+
new com.sphereon.cbor.CborUInt(com.sphereon.kmp.LongKMP.fromNumber(CWT_CLAIMS.STATUS_LIST)),
|
|
609
610
|
statusListMap
|
|
610
611
|
]);
|
|
611
|
-
const claimsMap = new
|
|
612
|
+
const claimsMap = new com.sphereon.cbor.CborMap(kotlin.collections.KtMutableMap.fromJsMap(new Map(claimsEntries)));
|
|
612
613
|
return claimsMap;
|
|
613
614
|
}
|
|
614
615
|
__name(buildClaimsMap, "buildClaimsMap");
|
|
@@ -620,7 +621,7 @@ var getCborValueFromMap = /* @__PURE__ */ __name((map, key) => {
|
|
|
620
621
|
return value;
|
|
621
622
|
}, "getCborValueFromMap");
|
|
622
623
|
var getCborOptionalValueFromMap = /* @__PURE__ */ __name((map, key) => {
|
|
623
|
-
const value = map.get(new CborUInt(
|
|
624
|
+
const value = map.get(new CborUInt(com.sphereon.kmp.LongKMP.fromNumber(key)));
|
|
624
625
|
if (!value) {
|
|
625
626
|
return void 0;
|
|
626
627
|
}
|
|
@@ -629,20 +630,20 @@ var getCborOptionalValueFromMap = /* @__PURE__ */ __name((map, key) => {
|
|
|
629
630
|
var decodeStatusListCWT = /* @__PURE__ */ __name((cwt) => {
|
|
630
631
|
const encodedCbor = base64url2.toBuffer(cwt);
|
|
631
632
|
const encodedCborArray = new Int8Array(encodedCbor);
|
|
632
|
-
const decodedCbor =
|
|
633
|
-
if (!(decodedCbor instanceof
|
|
633
|
+
const decodedCbor = com.sphereon.cbor.Cbor.decode(encodedCborArray);
|
|
634
|
+
if (!(decodedCbor instanceof com.sphereon.cbor.CborArray)) {
|
|
634
635
|
throw new Error("Invalid CWT format: Expected a CBOR array");
|
|
635
636
|
}
|
|
636
637
|
const [, payload] = decodedCbor.value.asJsArrayView();
|
|
637
|
-
if (!(payload instanceof
|
|
638
|
+
if (!(payload instanceof com.sphereon.cbor.CborByteString)) {
|
|
638
639
|
throw new Error("Invalid payload format: Expected a CBOR ByteString");
|
|
639
640
|
}
|
|
640
|
-
const claims =
|
|
641
|
-
if (!(claims instanceof
|
|
641
|
+
const claims = com.sphereon.cbor.Cbor.decode(payload.value);
|
|
642
|
+
if (!(claims instanceof com.sphereon.cbor.CborMap)) {
|
|
642
643
|
throw new Error("Invalid claims format: Expected a CBOR map");
|
|
643
644
|
}
|
|
644
645
|
const claimsMap = claims.value.asJsMapView();
|
|
645
|
-
const statusListMap = claimsMap.get(new CborUInt(
|
|
646
|
+
const statusListMap = claimsMap.get(new CborUInt(com.sphereon.kmp.LongKMP.fromNumber(65533))).value.asJsMapView();
|
|
646
647
|
const bits = Number(statusListMap.get(new CborString("bits")).value);
|
|
647
648
|
const decoded = new Uint8Array(statusListMap.get(new CborString("lst")).value);
|
|
648
649
|
const uint8Array = inflate(decoded);
|