@sphereon/ssi-sdk.vc-status-list 0.34.1-feature.SSISDK.26.RP.57 → 0.34.1-feature.SSISDK.44.finish.dcql.309
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 +50 -44
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +51 -45
- package/dist/index.js.map +1 -1
- package/package.json +13 -12
- package/src/impl/StatusList2021.ts +6 -0
- package/src/impl/encoding/cbor.ts +40 -41
- package/src/types/BitstringStatusList.ts +1 -1
- package/src/types/index.ts +2 -0
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { IIdentifierResolution } from '@sphereon/ssi-sdk-ext.identifier-resolution';
|
|
2
|
-
import { IIssuer, StatusListType, CredentialProofFormat, StatusListCredential, StatusListDriverType, StatusListIndexingDirection, StatusPurpose2021, ICredentialStatus, OrPromise, ICredential, IVerifiableCredential } from '@sphereon/ssi-types';
|
|
2
|
+
import { IIssuer, StatusListType, CredentialProofFormat, StatusListCredential, StatusListDriverType, StatusListIndexingDirection, StatusPurpose2021, StatusListCredentialIdMode, ICredentialStatus, OrPromise, ICredential, IVerifiableCredential } from '@sphereon/ssi-types';
|
|
3
3
|
import { IPluginMethodMap, IAgentContext, ICredentialIssuer, ICredentialVerifier, IKeyManager, CredentialPayload } from '@veramo/core';
|
|
4
4
|
import { DataSource } from 'typeorm';
|
|
5
5
|
import { StatusList, BitsPerStatus } from '@sd-jwt/jwt-status-list';
|
|
@@ -134,6 +134,7 @@ interface StatusListResult {
|
|
|
134
134
|
statusList2021?: {
|
|
135
135
|
indexingDirection: StatusListIndexingDirection;
|
|
136
136
|
statusPurpose: StatusPurpose2021;
|
|
137
|
+
credentialIdMode: StatusListCredentialIdMode;
|
|
137
138
|
};
|
|
138
139
|
oauthStatusList?: {
|
|
139
140
|
bitsPerStatus: number;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { IIdentifierResolution } from '@sphereon/ssi-sdk-ext.identifier-resolution';
|
|
2
|
-
import { IIssuer, StatusListType, CredentialProofFormat, StatusListCredential, StatusListDriverType, StatusListIndexingDirection, StatusPurpose2021, ICredentialStatus, OrPromise, ICredential, IVerifiableCredential } from '@sphereon/ssi-types';
|
|
2
|
+
import { IIssuer, StatusListType, CredentialProofFormat, StatusListCredential, StatusListDriverType, StatusListIndexingDirection, StatusPurpose2021, StatusListCredentialIdMode, ICredentialStatus, OrPromise, ICredential, IVerifiableCredential } from '@sphereon/ssi-types';
|
|
3
3
|
import { IPluginMethodMap, IAgentContext, ICredentialIssuer, ICredentialVerifier, IKeyManager, CredentialPayload } from '@veramo/core';
|
|
4
4
|
import { DataSource } from 'typeorm';
|
|
5
5
|
import { StatusList, BitsPerStatus } from '@sd-jwt/jwt-status-list';
|
|
@@ -134,6 +134,7 @@ interface StatusListResult {
|
|
|
134
134
|
statusList2021?: {
|
|
135
135
|
indexingDirection: StatusListIndexingDirection;
|
|
136
136
|
statusPurpose: StatusPurpose2021;
|
|
137
|
+
credentialIdMode: StatusListCredentialIdMode;
|
|
137
138
|
};
|
|
138
139
|
oauthStatusList?: {
|
|
139
140
|
bitsPerStatus: number;
|
package/dist/index.js
CHANGED
|
@@ -2,17 +2,17 @@ var __defProp = Object.defineProperty;
|
|
|
2
2
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
3
|
|
|
4
4
|
// src/types/index.ts
|
|
5
|
-
var StatusOAuth = /* @__PURE__ */ function(StatusOAuth2) {
|
|
5
|
+
var StatusOAuth = /* @__PURE__ */ (function(StatusOAuth2) {
|
|
6
6
|
StatusOAuth2[StatusOAuth2["Valid"] = 0] = "Valid";
|
|
7
7
|
StatusOAuth2[StatusOAuth2["Invalid"] = 1] = "Invalid";
|
|
8
8
|
StatusOAuth2[StatusOAuth2["Suspended"] = 2] = "Suspended";
|
|
9
9
|
return StatusOAuth2;
|
|
10
|
-
}({});
|
|
11
|
-
var Status2021 = /* @__PURE__ */ function(Status20212) {
|
|
10
|
+
})({});
|
|
11
|
+
var Status2021 = /* @__PURE__ */ (function(Status20212) {
|
|
12
12
|
Status20212[Status20212["Valid"] = 0] = "Valid";
|
|
13
13
|
Status20212[Status20212["Invalid"] = 1] = "Invalid";
|
|
14
14
|
return Status20212;
|
|
15
|
-
}({});
|
|
15
|
+
})({});
|
|
16
16
|
|
|
17
17
|
// src/functions.ts
|
|
18
18
|
import { CredentialMapper as CredentialMapper4, StatusListType as StatusListType6 } from "@sphereon/ssi-types";
|
|
@@ -172,7 +172,7 @@ function ensureDate(value) {
|
|
|
172
172
|
__name(ensureDate, "ensureDate");
|
|
173
173
|
|
|
174
174
|
// src/impl/StatusList2021.ts
|
|
175
|
-
import { CredentialMapper as CredentialMapper2, DocumentFormat as DocumentFormat2, StatusListType as StatusListType2 } from "@sphereon/ssi-types";
|
|
175
|
+
import { CredentialMapper as CredentialMapper2, DocumentFormat as DocumentFormat2, StatusListCredentialIdMode, StatusListType as StatusListType2 } from "@sphereon/ssi-types";
|
|
176
176
|
import { StatusList } from "@sphereon/vc-status-list";
|
|
177
177
|
var DEFAULT_LIST_LENGTH = 25e4;
|
|
178
178
|
var DEFAULT_PROOF_FORMAT = "lds";
|
|
@@ -202,7 +202,8 @@ var StatusList2021Implementation = class {
|
|
|
202
202
|
statusListCredential,
|
|
203
203
|
statusList2021: {
|
|
204
204
|
statusPurpose,
|
|
205
|
-
indexingDirection: "rightToLeft"
|
|
205
|
+
indexingDirection: "rightToLeft",
|
|
206
|
+
credentialIdMode: StatusListCredentialIdMode.ISSUANCE
|
|
206
207
|
},
|
|
207
208
|
length,
|
|
208
209
|
type: StatusListType2.StatusList2021,
|
|
@@ -241,7 +242,8 @@ var StatusList2021Implementation = class {
|
|
|
241
242
|
encodedList,
|
|
242
243
|
statusList2021: {
|
|
243
244
|
statusPurpose: credentialSubject.statusPurpose,
|
|
244
|
-
indexingDirection: "rightToLeft"
|
|
245
|
+
indexingDirection: "rightToLeft",
|
|
246
|
+
credentialIdMode: StatusListCredentialIdMode.ISSUANCE
|
|
245
247
|
},
|
|
246
248
|
length: statusList.length - 1,
|
|
247
249
|
type: StatusListType2.StatusList2021,
|
|
@@ -278,7 +280,8 @@ var StatusList2021Implementation = class {
|
|
|
278
280
|
encodedList: newEncodedList,
|
|
279
281
|
statusList2021: {
|
|
280
282
|
statusPurpose: args.statusList2021.statusPurpose,
|
|
281
|
-
indexingDirection: "rightToLeft"
|
|
283
|
+
indexingDirection: "rightToLeft",
|
|
284
|
+
credentialIdMode: StatusListCredentialIdMode.ISSUANCE
|
|
282
285
|
},
|
|
283
286
|
length: statusList.length,
|
|
284
287
|
proofFormat: args.proofFormat ?? "lds",
|
|
@@ -340,7 +343,8 @@ var StatusList2021Implementation = class {
|
|
|
340
343
|
statusPurpose,
|
|
341
344
|
statusList2021: {
|
|
342
345
|
indexingDirection: "rightToLeft",
|
|
343
|
-
statusPurpose
|
|
346
|
+
statusPurpose,
|
|
347
|
+
credentialIdMode: StatusListCredentialIdMode.ISSUANCE
|
|
344
348
|
}
|
|
345
349
|
};
|
|
346
350
|
} else {
|
|
@@ -365,7 +369,8 @@ var StatusList2021Implementation = class {
|
|
|
365
369
|
statusPurpose: statusList2021Entity.statusPurpose,
|
|
366
370
|
statusList2021: {
|
|
367
371
|
indexingDirection: statusList2021Entity.indexingDirection,
|
|
368
|
-
statusPurpose: statusList2021Entity.statusPurpose
|
|
372
|
+
statusPurpose: statusList2021Entity.statusPurpose,
|
|
373
|
+
credentialIdMode: StatusListCredentialIdMode.ISSUANCE
|
|
369
374
|
}
|
|
370
375
|
};
|
|
371
376
|
}
|
|
@@ -514,11 +519,12 @@ var getSigningAlgo = /* @__PURE__ */ __name((type) => {
|
|
|
514
519
|
// src/impl/encoding/cbor.ts
|
|
515
520
|
import { StatusList as StatusList3 } from "@sd-jwt/jwt-status-list";
|
|
516
521
|
import { deflate, inflate } from "pako";
|
|
517
|
-
import
|
|
522
|
+
import mdocPkg from "@sphereon/kmp-mdoc-core";
|
|
518
523
|
import base64url2 from "base64url";
|
|
519
|
-
var
|
|
520
|
-
var
|
|
521
|
-
var
|
|
524
|
+
var { com, kotlin } = mdocPkg;
|
|
525
|
+
var CborByteString = mdocPkg.com.sphereon.cbor.CborByteString;
|
|
526
|
+
var CborUInt = mdocPkg.com.sphereon.cbor.CborUInt;
|
|
527
|
+
var CborString = mdocPkg.com.sphereon.cbor.CborString;
|
|
522
528
|
var decompressRawStatusList = StatusList3.decodeStatusList.bind(StatusList3);
|
|
523
529
|
var CWT_CLAIMS = {
|
|
524
530
|
SUBJECT: 2,
|
|
@@ -535,25 +541,25 @@ var createSignedCbor = /* @__PURE__ */ __name(async (context, statusList, issuer
|
|
|
535
541
|
level: 9
|
|
536
542
|
});
|
|
537
543
|
const compressedBytes = new Int8Array(compressedList);
|
|
538
|
-
const statusListMap = new
|
|
544
|
+
const statusListMap = new com.sphereon.cbor.CborMap(kotlin.collections.KtMutableMap.fromJsMap(/* @__PURE__ */ new Map([
|
|
539
545
|
[
|
|
540
|
-
new
|
|
541
|
-
new
|
|
546
|
+
new com.sphereon.cbor.CborString("bits"),
|
|
547
|
+
new com.sphereon.cbor.CborUInt(com.sphereon.kmp.LongKMP.fromNumber(statusList.getBitsPerStatus()))
|
|
542
548
|
],
|
|
543
549
|
[
|
|
544
|
-
new
|
|
545
|
-
new
|
|
550
|
+
new com.sphereon.cbor.CborString("lst"),
|
|
551
|
+
new com.sphereon.cbor.CborByteString(compressedBytes)
|
|
546
552
|
]
|
|
547
553
|
])));
|
|
548
|
-
const protectedHeader = new
|
|
554
|
+
const protectedHeader = new com.sphereon.cbor.CborMap(kotlin.collections.KtMutableMap.fromJsMap(/* @__PURE__ */ new Map([
|
|
549
555
|
[
|
|
550
|
-
new
|
|
551
|
-
new
|
|
556
|
+
new com.sphereon.cbor.CborUInt(com.sphereon.kmp.LongKMP.fromNumber(16)),
|
|
557
|
+
new com.sphereon.cbor.CborString("statuslist+cwt")
|
|
552
558
|
]
|
|
553
559
|
])));
|
|
554
|
-
const protectedHeaderEncoded =
|
|
560
|
+
const protectedHeaderEncoded = com.sphereon.cbor.Cbor.encode(protectedHeader);
|
|
555
561
|
const claimsMap = buildClaimsMap(id, issuerString, statusListMap, expiresAt);
|
|
556
|
-
const claimsEncoded =
|
|
562
|
+
const claimsEncoded = com.sphereon.cbor.Cbor.encode(claimsMap);
|
|
557
563
|
const signedCWT = await context.agent.keyManagerSign({
|
|
558
564
|
keyRef: identifier.kmsKeyRef,
|
|
559
565
|
data: base64url2.encode(Buffer.from(claimsEncoded)),
|
|
@@ -568,8 +574,8 @@ var createSignedCbor = /* @__PURE__ */ __name(async (context, statusList, issuer
|
|
|
568
574
|
new CborByteString(claimsEncodedInt8),
|
|
569
575
|
new CborByteString(signatureInt8)
|
|
570
576
|
];
|
|
571
|
-
const cwtArray = new
|
|
572
|
-
const cwtEncoded =
|
|
577
|
+
const cwtArray = new com.sphereon.cbor.CborArray(kotlin.collections.KtMutableList.fromJsArray(cwtArrayElements));
|
|
578
|
+
const cwtEncoded = com.sphereon.cbor.Cbor.encode(cwtArray);
|
|
573
579
|
const cwtBuffer = Buffer.from(cwtEncoded);
|
|
574
580
|
return {
|
|
575
581
|
statusListCredential: base64url2.encode(cwtBuffer),
|
|
@@ -580,35 +586,35 @@ function buildClaimsMap(id, issuerString, statusListMap, expiresAt) {
|
|
|
580
586
|
const ttl = 65535;
|
|
581
587
|
const claimsEntries = [
|
|
582
588
|
[
|
|
583
|
-
new CborUInt(
|
|
584
|
-
new
|
|
589
|
+
new CborUInt(com.sphereon.kmp.LongKMP.fromNumber(CWT_CLAIMS.SUBJECT)),
|
|
590
|
+
new com.sphereon.cbor.CborString(id)
|
|
585
591
|
],
|
|
586
592
|
[
|
|
587
|
-
new CborUInt(
|
|
588
|
-
new
|
|
593
|
+
new CborUInt(com.sphereon.kmp.LongKMP.fromNumber(CWT_CLAIMS.ISSUER)),
|
|
594
|
+
new com.sphereon.cbor.CborString(issuerString)
|
|
589
595
|
],
|
|
590
596
|
[
|
|
591
|
-
new CborUInt(
|
|
592
|
-
new CborUInt(
|
|
597
|
+
new CborUInt(com.sphereon.kmp.LongKMP.fromNumber(CWT_CLAIMS.ISSUED_AT)),
|
|
598
|
+
new CborUInt(com.sphereon.kmp.LongKMP.fromNumber(Math.floor(Date.now() / 1e3)))
|
|
593
599
|
]
|
|
594
600
|
];
|
|
595
601
|
if (expiresAt) {
|
|
596
602
|
claimsEntries.push([
|
|
597
|
-
new
|
|
598
|
-
new
|
|
603
|
+
new com.sphereon.cbor.CborUInt(com.sphereon.kmp.LongKMP.fromNumber(CWT_CLAIMS.EXPIRATION)),
|
|
604
|
+
new com.sphereon.cbor.CborUInt(com.sphereon.kmp.LongKMP.fromNumber(Math.floor(expiresAt.getTime() / 1e3)))
|
|
599
605
|
]);
|
|
600
606
|
}
|
|
601
607
|
if (ttl) {
|
|
602
608
|
claimsEntries.push([
|
|
603
|
-
new
|
|
604
|
-
new
|
|
609
|
+
new com.sphereon.cbor.CborUInt(com.sphereon.kmp.LongKMP.fromNumber(CWT_CLAIMS.TIME_TO_LIVE)),
|
|
610
|
+
new com.sphereon.cbor.CborUInt(com.sphereon.kmp.LongKMP.fromNumber(ttl))
|
|
605
611
|
]);
|
|
606
612
|
}
|
|
607
613
|
claimsEntries.push([
|
|
608
|
-
new
|
|
614
|
+
new com.sphereon.cbor.CborUInt(com.sphereon.kmp.LongKMP.fromNumber(CWT_CLAIMS.STATUS_LIST)),
|
|
609
615
|
statusListMap
|
|
610
616
|
]);
|
|
611
|
-
const claimsMap = new
|
|
617
|
+
const claimsMap = new com.sphereon.cbor.CborMap(kotlin.collections.KtMutableMap.fromJsMap(new Map(claimsEntries)));
|
|
612
618
|
return claimsMap;
|
|
613
619
|
}
|
|
614
620
|
__name(buildClaimsMap, "buildClaimsMap");
|
|
@@ -620,7 +626,7 @@ var getCborValueFromMap = /* @__PURE__ */ __name((map, key) => {
|
|
|
620
626
|
return value;
|
|
621
627
|
}, "getCborValueFromMap");
|
|
622
628
|
var getCborOptionalValueFromMap = /* @__PURE__ */ __name((map, key) => {
|
|
623
|
-
const value = map.get(new CborUInt(
|
|
629
|
+
const value = map.get(new CborUInt(com.sphereon.kmp.LongKMP.fromNumber(key)));
|
|
624
630
|
if (!value) {
|
|
625
631
|
return void 0;
|
|
626
632
|
}
|
|
@@ -629,20 +635,20 @@ var getCborOptionalValueFromMap = /* @__PURE__ */ __name((map, key) => {
|
|
|
629
635
|
var decodeStatusListCWT = /* @__PURE__ */ __name((cwt) => {
|
|
630
636
|
const encodedCbor = base64url2.toBuffer(cwt);
|
|
631
637
|
const encodedCborArray = new Int8Array(encodedCbor);
|
|
632
|
-
const decodedCbor =
|
|
633
|
-
if (!(decodedCbor instanceof
|
|
638
|
+
const decodedCbor = com.sphereon.cbor.Cbor.decode(encodedCborArray);
|
|
639
|
+
if (!(decodedCbor instanceof com.sphereon.cbor.CborArray)) {
|
|
634
640
|
throw new Error("Invalid CWT format: Expected a CBOR array");
|
|
635
641
|
}
|
|
636
642
|
const [, payload] = decodedCbor.value.asJsArrayView();
|
|
637
|
-
if (!(payload instanceof
|
|
643
|
+
if (!(payload instanceof com.sphereon.cbor.CborByteString)) {
|
|
638
644
|
throw new Error("Invalid payload format: Expected a CBOR ByteString");
|
|
639
645
|
}
|
|
640
|
-
const claims =
|
|
641
|
-
if (!(claims instanceof
|
|
646
|
+
const claims = com.sphereon.cbor.Cbor.decode(payload.value);
|
|
647
|
+
if (!(claims instanceof com.sphereon.cbor.CborMap)) {
|
|
642
648
|
throw new Error("Invalid claims format: Expected a CBOR map");
|
|
643
649
|
}
|
|
644
650
|
const claimsMap = claims.value.asJsMapView();
|
|
645
|
-
const statusListMap = claimsMap.get(new CborUInt(
|
|
651
|
+
const statusListMap = claimsMap.get(new CborUInt(com.sphereon.kmp.LongKMP.fromNumber(65533))).value.asJsMapView();
|
|
646
652
|
const bits = Number(statusListMap.get(new CborString("bits")).value);
|
|
647
653
|
const decoded = new Uint8Array(statusListMap.get(new CborString("lst")).value);
|
|
648
654
|
const uint8Array = inflate(decoded);
|