@sphereon/ssi-sdk.vc-status-list 0.34.0 → 0.34.1-feature.SSISDK.17.bitstring.sl.11
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 +424 -45
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +76 -26
- package/dist/index.d.ts +76 -26
- package/dist/index.js +425 -46
- package/dist/index.js.map +1 -1
- package/package.json +5 -3
- package/src/functions.ts +50 -14
- package/src/impl/BitstringStatusListImplementation.ts +347 -0
- package/src/impl/IStatusList.ts +66 -4
- package/src/impl/OAuthStatusList.ts +60 -18
- package/src/impl/StatusList2021.ts +47 -12
- package/src/impl/StatusListFactory.ts +2 -0
- package/src/types/BitstringStatusList.ts +4 -0
- package/src/types/index.ts +71 -22
- package/src/utils.ts +35 -2
package/dist/index.cjs
CHANGED
|
@@ -35,6 +35,7 @@ __export(index_exports, {
|
|
|
35
35
|
StatusOAuth: () => StatusOAuth,
|
|
36
36
|
checkStatusForCredential: () => checkStatusForCredential,
|
|
37
37
|
checkStatusIndexFromStatusListCredential: () => checkStatusIndexFromStatusListCredential,
|
|
38
|
+
createCredentialStatusFromStatusList: () => createCredentialStatusFromStatusList,
|
|
38
39
|
createNewStatusList: () => createNewStatusList,
|
|
39
40
|
fetchStatusListCredential: () => fetchStatusListCredential,
|
|
40
41
|
simpleCheckStatusFromStatusListUrl: () => simpleCheckStatusFromStatusListUrl,
|
|
@@ -61,7 +62,7 @@ var Status2021 = /* @__PURE__ */ function(Status20212) {
|
|
|
61
62
|
}({});
|
|
62
63
|
|
|
63
64
|
// src/functions.ts
|
|
64
|
-
var
|
|
65
|
+
var import_ssi_types7 = require("@sphereon/ssi-types");
|
|
65
66
|
var import_vc_status_list2 = require("@sphereon/vc-status-list");
|
|
66
67
|
|
|
67
68
|
// src/utils.ts
|
|
@@ -71,7 +72,8 @@ function getAssertedStatusListType(type) {
|
|
|
71
72
|
const assertedType = type ?? import_ssi_types.StatusListType.StatusList2021;
|
|
72
73
|
if (![
|
|
73
74
|
import_ssi_types.StatusListType.StatusList2021,
|
|
74
|
-
import_ssi_types.StatusListType.OAuthStatusList
|
|
75
|
+
import_ssi_types.StatusListType.OAuthStatusList,
|
|
76
|
+
import_ssi_types.StatusListType.BitstringStatusList
|
|
75
77
|
].includes(assertedType)) {
|
|
76
78
|
throw Error(`StatusList type ${assertedType} is not supported (yet)`);
|
|
77
79
|
}
|
|
@@ -108,8 +110,7 @@ var ValidProofTypeMap = /* @__PURE__ */ new Map([
|
|
|
108
110
|
import_ssi_types.StatusListType.StatusList2021,
|
|
109
111
|
[
|
|
110
112
|
"jwt",
|
|
111
|
-
"lds"
|
|
112
|
-
"EthereumEip712Signature2021"
|
|
113
|
+
"lds"
|
|
113
114
|
]
|
|
114
115
|
],
|
|
115
116
|
[
|
|
@@ -118,6 +119,12 @@ var ValidProofTypeMap = /* @__PURE__ */ new Map([
|
|
|
118
119
|
"jwt",
|
|
119
120
|
"cbor"
|
|
120
121
|
]
|
|
122
|
+
],
|
|
123
|
+
[
|
|
124
|
+
import_ssi_types.StatusListType.BitstringStatusList,
|
|
125
|
+
[
|
|
126
|
+
"lds"
|
|
127
|
+
]
|
|
121
128
|
]
|
|
122
129
|
]);
|
|
123
130
|
function assertValidProofType(type, proofFormat) {
|
|
@@ -168,6 +175,26 @@ function determineProofFormat(credential) {
|
|
|
168
175
|
}
|
|
169
176
|
}
|
|
170
177
|
__name(determineProofFormat, "determineProofFormat");
|
|
178
|
+
function ensureDate(value) {
|
|
179
|
+
if (value === void 0 || value === null) {
|
|
180
|
+
return void 0;
|
|
181
|
+
}
|
|
182
|
+
if (value instanceof Date) {
|
|
183
|
+
return value;
|
|
184
|
+
}
|
|
185
|
+
if (typeof value === "string") {
|
|
186
|
+
if (value.trim() === "") {
|
|
187
|
+
return void 0;
|
|
188
|
+
}
|
|
189
|
+
const date = new Date(value);
|
|
190
|
+
if (isNaN(date.getTime())) {
|
|
191
|
+
return void 0;
|
|
192
|
+
}
|
|
193
|
+
return date;
|
|
194
|
+
}
|
|
195
|
+
return void 0;
|
|
196
|
+
}
|
|
197
|
+
__name(ensureDate, "ensureDate");
|
|
171
198
|
|
|
172
199
|
// src/impl/StatusList2021.ts
|
|
173
200
|
var import_ssi_types2 = require("@sphereon/ssi-types");
|
|
@@ -231,13 +258,14 @@ var StatusList2021Implementation = class {
|
|
|
231
258
|
encodedList,
|
|
232
259
|
proofFormat
|
|
233
260
|
}, context);
|
|
261
|
+
if (!("statusPurpose" in credentialSubject)) {
|
|
262
|
+
return Promise.reject(Error("statusPurpose is required in credentialSubject for StatusList2021"));
|
|
263
|
+
}
|
|
234
264
|
return {
|
|
235
265
|
statusListCredential: updatedCredential,
|
|
236
266
|
encodedList,
|
|
237
267
|
statusList2021: {
|
|
238
|
-
|
|
239
|
-
statusPurpose: credentialSubject.statusPurpose
|
|
240
|
-
} : {},
|
|
268
|
+
statusPurpose: credentialSubject.statusPurpose,
|
|
241
269
|
indexingDirection: "rightToLeft"
|
|
242
270
|
},
|
|
243
271
|
length: statusList.length - 1,
|
|
@@ -260,7 +288,7 @@ var StatusList2021Implementation = class {
|
|
|
260
288
|
encodedList: args.encodedList
|
|
261
289
|
});
|
|
262
290
|
const index = typeof args.statusListIndex === "number" ? args.statusListIndex : parseInt(args.statusListIndex);
|
|
263
|
-
statusList.setStatus(index, args.value);
|
|
291
|
+
statusList.setStatus(index, args.value !== 0);
|
|
264
292
|
const newEncodedList = await statusList.encode();
|
|
265
293
|
const credential = await this.createVerifiableCredential({
|
|
266
294
|
id,
|
|
@@ -302,10 +330,12 @@ var StatusList2021Implementation = class {
|
|
|
302
330
|
const encodedList = getAssertedProperty("encodedList", credentialSubject);
|
|
303
331
|
const proofFormat = import_ssi_types2.CredentialMapper.detectDocumentType(statusListPayload) === import_ssi_types2.DocumentFormat.JWT ? "jwt" : "lds";
|
|
304
332
|
const statusPurpose = getAssertedProperty("statusPurpose", credentialSubject);
|
|
333
|
+
const indexingDirection = "rightToLeft";
|
|
305
334
|
const list = await import_vc_status_list.StatusList.decode({
|
|
306
335
|
encodedList
|
|
307
336
|
});
|
|
308
337
|
return {
|
|
338
|
+
// Base implementation fields
|
|
309
339
|
id,
|
|
310
340
|
encodedList,
|
|
311
341
|
issuer,
|
|
@@ -314,18 +344,36 @@ var StatusList2021Implementation = class {
|
|
|
314
344
|
length: list.length,
|
|
315
345
|
statusListCredential: statusListPayload,
|
|
316
346
|
statuslistContentType: this.buildContentType(proofFormat),
|
|
347
|
+
correlationId: args.correlationId,
|
|
348
|
+
driverType: args.driverType,
|
|
349
|
+
// Flattened StatusList2021-specific fields
|
|
350
|
+
indexingDirection,
|
|
351
|
+
statusPurpose,
|
|
352
|
+
// Legacy nested structure for backward compatibility
|
|
317
353
|
statusList2021: {
|
|
318
|
-
indexingDirection
|
|
319
|
-
statusPurpose
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
354
|
+
indexingDirection,
|
|
355
|
+
statusPurpose,
|
|
356
|
+
// Optional fields from args
|
|
357
|
+
...args.correlationId && {
|
|
358
|
+
correlationId: args.correlationId
|
|
359
|
+
},
|
|
360
|
+
...args.driverType && {
|
|
361
|
+
driverType: args.driverType
|
|
362
|
+
}
|
|
326
363
|
}
|
|
327
364
|
};
|
|
328
365
|
}
|
|
366
|
+
async createCredentialStatus(args) {
|
|
367
|
+
const { statusList, statusListIndex } = args;
|
|
368
|
+
const statusList2021 = statusList;
|
|
369
|
+
return {
|
|
370
|
+
id: `${statusList.id}#${statusListIndex}`,
|
|
371
|
+
type: "StatusList2021Entry",
|
|
372
|
+
statusPurpose: statusList2021.statusPurpose ?? "revocation",
|
|
373
|
+
statusListIndex: "" + statusListIndex,
|
|
374
|
+
statusListCredential: statusList.id
|
|
375
|
+
};
|
|
376
|
+
}
|
|
329
377
|
async createVerifiableCredential(args, context) {
|
|
330
378
|
const identifier = await context.agent.identifierManagedGet({
|
|
331
379
|
identifier: typeof args.issuer === "string" ? args.issuer : args.issuer.id,
|
|
@@ -618,7 +666,8 @@ var OAuthStatusListImplementation = class {
|
|
|
618
666
|
}
|
|
619
667
|
const proofFormat = args?.proofFormat ?? DEFAULT_PROOF_FORMAT2;
|
|
620
668
|
const { issuer, id, oauthStatusList, keyRef } = args;
|
|
621
|
-
const { bitsPerStatus
|
|
669
|
+
const { bitsPerStatus } = oauthStatusList;
|
|
670
|
+
const expiresAt = ensureDate(oauthStatusList.expiresAt);
|
|
622
671
|
const length = args.length ?? DEFAULT_LIST_LENGTH2;
|
|
623
672
|
const issuerString = typeof issuer === "string" ? issuer : issuer.id;
|
|
624
673
|
const correlationId = getAssertedValue("correlationId", args.correlationId);
|
|
@@ -641,7 +690,8 @@ var OAuthStatusListImplementation = class {
|
|
|
641
690
|
};
|
|
642
691
|
}
|
|
643
692
|
async updateStatusListIndex(args, context) {
|
|
644
|
-
const { statusListCredential, value,
|
|
693
|
+
const { statusListCredential, value, keyRef } = args;
|
|
694
|
+
const expiresAt = ensureDate(args.expiresAt);
|
|
645
695
|
if (typeof statusListCredential !== "string") {
|
|
646
696
|
return Promise.reject("statusListCredential in neither JWT nor CWT");
|
|
647
697
|
}
|
|
@@ -652,6 +702,9 @@ var OAuthStatusListImplementation = class {
|
|
|
652
702
|
if (index < 0 || index >= statusList.statusList.length) {
|
|
653
703
|
throw new Error("Status list index out of bounds");
|
|
654
704
|
}
|
|
705
|
+
if (typeof value !== "number") {
|
|
706
|
+
throw new Error("Status list values should be of type number");
|
|
707
|
+
}
|
|
655
708
|
statusList.setStatus(index, value);
|
|
656
709
|
const { statusListCredential: signedCredential, encodedList } = await this.createSignedStatusList(proofFormat, context, statusList, issuer, id, expiresAt, keyRef);
|
|
657
710
|
return {
|
|
@@ -674,12 +727,13 @@ var OAuthStatusListImplementation = class {
|
|
|
674
727
|
throw new Error("OAuthStatusList options are required for type OAuthStatusList");
|
|
675
728
|
}
|
|
676
729
|
const { proofFormat, oauthStatusList, keyRef } = args;
|
|
677
|
-
const { bitsPerStatus
|
|
730
|
+
const { bitsPerStatus } = oauthStatusList;
|
|
731
|
+
const expiresAt = ensureDate(oauthStatusList.expiresAt);
|
|
678
732
|
const { issuer, id } = getAssertedValues(args);
|
|
679
733
|
const issuerString = typeof issuer === "string" ? issuer : issuer.id;
|
|
680
734
|
const listToUpdate = import_jwt_status_list3.StatusList.decompressStatusList(args.encodedList, bitsPerStatus ?? DEFAULT_BITS_PER_STATUS);
|
|
681
735
|
const index = typeof args.statusListIndex === "number" ? args.statusListIndex : parseInt(args.statusListIndex);
|
|
682
|
-
listToUpdate.setStatus(index, args.value
|
|
736
|
+
listToUpdate.setStatus(index, args.value);
|
|
683
737
|
const { statusListCredential, encodedList } = await this.createSignedStatusList(proofFormat ?? DEFAULT_PROOF_FORMAT2, context, listToUpdate, issuerString, id, expiresAt, keyRef);
|
|
684
738
|
return {
|
|
685
739
|
encodedList,
|
|
@@ -696,9 +750,6 @@ var OAuthStatusListImplementation = class {
|
|
|
696
750
|
statuslistContentType: this.buildContentType(proofFormat)
|
|
697
751
|
};
|
|
698
752
|
}
|
|
699
|
-
buildContentType(proofFormat) {
|
|
700
|
-
return `application/statuslist+${proofFormat === "cbor" ? "cwt" : "jwt"}`;
|
|
701
|
-
}
|
|
702
753
|
async checkStatusIndex(args) {
|
|
703
754
|
const { statusListCredential, statusListIndex } = args;
|
|
704
755
|
if (typeof statusListCredential !== "string") {
|
|
@@ -708,7 +759,7 @@ var OAuthStatusListImplementation = class {
|
|
|
708
759
|
const { statusList } = proofFormat === "jwt" ? decodeStatusListJWT(statusListCredential) : decodeStatusListCWT(statusListCredential);
|
|
709
760
|
const index = typeof statusListIndex === "number" ? statusListIndex : parseInt(statusListIndex);
|
|
710
761
|
if (index < 0 || index >= statusList.statusList.length) {
|
|
711
|
-
throw new Error(
|
|
762
|
+
throw new Error(`Status list index out of bounds, has ${statusList.statusList.length} items, requested ${index}`);
|
|
712
763
|
}
|
|
713
764
|
return statusList.getStatus(index);
|
|
714
765
|
}
|
|
@@ -717,7 +768,10 @@ var OAuthStatusListImplementation = class {
|
|
|
717
768
|
const proofFormat = determineProofFormat(statusListPayload);
|
|
718
769
|
const decoded = proofFormat === "jwt" ? decodeStatusListJWT(statusListPayload) : decodeStatusListCWT(statusListPayload);
|
|
719
770
|
const { statusList, issuer, id, exp } = decoded;
|
|
771
|
+
const bitsPerStatus = statusList.getBitsPerStatus();
|
|
772
|
+
const expiresAt = exp ? new Date(exp * 1e3) : void 0;
|
|
720
773
|
return {
|
|
774
|
+
// Base implementation fields
|
|
721
775
|
id,
|
|
722
776
|
encodedList: statusList.compressStatusList(),
|
|
723
777
|
issuer,
|
|
@@ -726,12 +780,21 @@ var OAuthStatusListImplementation = class {
|
|
|
726
780
|
length: statusList.statusList.length,
|
|
727
781
|
statusListCredential: statusListPayload,
|
|
728
782
|
statuslistContentType: this.buildContentType(proofFormat),
|
|
783
|
+
correlationId: args.correlationId,
|
|
784
|
+
driverType: args.driverType,
|
|
785
|
+
// Flattened OAuth-specific fields
|
|
786
|
+
bitsPerStatus,
|
|
787
|
+
...expiresAt && {
|
|
788
|
+
expiresAt
|
|
789
|
+
},
|
|
790
|
+
// Legacy nested structure for backward compatibility
|
|
729
791
|
oauthStatusList: {
|
|
730
|
-
bitsPerStatus
|
|
731
|
-
...
|
|
732
|
-
expiresAt
|
|
792
|
+
bitsPerStatus,
|
|
793
|
+
...expiresAt && {
|
|
794
|
+
expiresAt
|
|
733
795
|
}
|
|
734
796
|
},
|
|
797
|
+
// Optional fields from args
|
|
735
798
|
...args.correlationId && {
|
|
736
799
|
correlationId: args.correlationId
|
|
737
800
|
},
|
|
@@ -740,6 +803,21 @@ var OAuthStatusListImplementation = class {
|
|
|
740
803
|
}
|
|
741
804
|
};
|
|
742
805
|
}
|
|
806
|
+
async createCredentialStatus(args) {
|
|
807
|
+
const { statusList, statusListIndex } = args;
|
|
808
|
+
const oauthStatusList = statusList;
|
|
809
|
+
return {
|
|
810
|
+
id: `${statusList.id}#${statusListIndex}`,
|
|
811
|
+
type: "OAuthStatusListEntry",
|
|
812
|
+
bitsPerStatus: oauthStatusList.bitsPerStatus,
|
|
813
|
+
statusListIndex: "" + statusListIndex,
|
|
814
|
+
statusListCredential: statusList.id,
|
|
815
|
+
expiresAt: oauthStatusList.expiresAt
|
|
816
|
+
};
|
|
817
|
+
}
|
|
818
|
+
buildContentType(proofFormat) {
|
|
819
|
+
return `application/statuslist+${proofFormat === "cbor" ? "cwt" : "jwt"}`;
|
|
820
|
+
}
|
|
743
821
|
async createSignedStatusList(proofFormat, context, statusList, issuerString, id, expiresAt, keyRef) {
|
|
744
822
|
switch (proofFormat) {
|
|
745
823
|
case "jwt": {
|
|
@@ -755,7 +833,294 @@ var OAuthStatusListImplementation = class {
|
|
|
755
833
|
};
|
|
756
834
|
|
|
757
835
|
// src/impl/StatusListFactory.ts
|
|
836
|
+
var import_ssi_types6 = require("@sphereon/ssi-types");
|
|
837
|
+
|
|
838
|
+
// src/impl/BitstringStatusListImplementation.ts
|
|
758
839
|
var import_ssi_types5 = require("@sphereon/ssi-types");
|
|
840
|
+
var import_vc_bitstring_status_lists = require("@4sure-tech/vc-bitstring-status-lists");
|
|
841
|
+
var DEFAULT_LIST_LENGTH3 = 131072;
|
|
842
|
+
var DEFAULT_PROOF_FORMAT3 = "lds";
|
|
843
|
+
var DEFAULT_STATUS_PURPOSE = "revocation";
|
|
844
|
+
var BitstringStatusListImplementation = class {
|
|
845
|
+
static {
|
|
846
|
+
__name(this, "BitstringStatusListImplementation");
|
|
847
|
+
}
|
|
848
|
+
async createNewStatusList(args, context) {
|
|
849
|
+
if (!args.bitstringStatusList) {
|
|
850
|
+
throw new Error("BitstringStatusList options are required for type BitstringStatusList");
|
|
851
|
+
}
|
|
852
|
+
const length = args?.length ?? DEFAULT_LIST_LENGTH3;
|
|
853
|
+
const proofFormat = args?.proofFormat ?? DEFAULT_PROOF_FORMAT3;
|
|
854
|
+
assertValidProofType(import_ssi_types5.StatusListType.BitstringStatusList, proofFormat);
|
|
855
|
+
const veramoProofFormat = proofFormat;
|
|
856
|
+
const { issuer, id } = args;
|
|
857
|
+
const correlationId = getAssertedValue("correlationId", args.correlationId);
|
|
858
|
+
const { statusPurpose, bitsPerStatus, validFrom, validUntil, ttl } = args.bitstringStatusList;
|
|
859
|
+
const statusListCredential = await this.createVerifiableCredential({
|
|
860
|
+
...args,
|
|
861
|
+
proofFormat: veramoProofFormat,
|
|
862
|
+
statusPurpose: statusPurpose ?? DEFAULT_STATUS_PURPOSE,
|
|
863
|
+
validFrom: ensureDate(validFrom),
|
|
864
|
+
validUntil: ensureDate(validUntil),
|
|
865
|
+
ttl
|
|
866
|
+
}, context);
|
|
867
|
+
return {
|
|
868
|
+
encodedList: statusListCredential.credentialSubject.encodedList,
|
|
869
|
+
statusListCredential,
|
|
870
|
+
bitstringStatusList: {
|
|
871
|
+
statusPurpose: statusPurpose ?? DEFAULT_STATUS_PURPOSE,
|
|
872
|
+
...statusListCredential.validFrom && {
|
|
873
|
+
validFrom: new Date(statusListCredential.validFrom)
|
|
874
|
+
},
|
|
875
|
+
...statusListCredential.validUntil && {
|
|
876
|
+
validUntil: new Date(statusListCredential.validUntil)
|
|
877
|
+
},
|
|
878
|
+
ttl,
|
|
879
|
+
bitsPerStatus
|
|
880
|
+
},
|
|
881
|
+
length,
|
|
882
|
+
type: import_ssi_types5.StatusListType.BitstringStatusList,
|
|
883
|
+
proofFormat,
|
|
884
|
+
id,
|
|
885
|
+
correlationId,
|
|
886
|
+
issuer,
|
|
887
|
+
statuslistContentType: this.buildContentType(proofFormat)
|
|
888
|
+
};
|
|
889
|
+
}
|
|
890
|
+
async updateStatusListIndex(args, context) {
|
|
891
|
+
if (!args.bitsPerStatus || args.bitsPerStatus < 1) {
|
|
892
|
+
return Promise.reject("bitsPerStatus must be set for bitstring status lists and must be 1 or higher. (updateStatusListIndex)");
|
|
893
|
+
}
|
|
894
|
+
const credential = args.statusListCredential;
|
|
895
|
+
const uniform = import_ssi_types5.CredentialMapper.toUniformCredential(credential);
|
|
896
|
+
const { issuer, credentialSubject } = uniform;
|
|
897
|
+
const id = getAssertedValue("id", uniform.id);
|
|
898
|
+
const origEncodedList = getAssertedProperty("encodedList", credentialSubject);
|
|
899
|
+
const index = typeof args.statusListIndex === "number" ? args.statusListIndex : parseInt(args.statusListIndex);
|
|
900
|
+
const statusList = await import_vc_bitstring_status_lists.BitstreamStatusList.decode({
|
|
901
|
+
encodedList: origEncodedList,
|
|
902
|
+
statusSize: args.bitsPerStatus
|
|
903
|
+
});
|
|
904
|
+
statusList.setStatus(index, args.value);
|
|
905
|
+
const proofFormat = import_ssi_types5.CredentialMapper.detectDocumentType(credential) === import_ssi_types5.DocumentFormat.JWT ? "jwt" : "lds";
|
|
906
|
+
const credSubject = Array.isArray(credentialSubject) ? credentialSubject[0] : credentialSubject;
|
|
907
|
+
const statusPurpose = getAssertedProperty("statusPurpose", credSubject);
|
|
908
|
+
const validFrom = uniform.validFrom ? new Date(uniform.validFrom) : void 0;
|
|
909
|
+
const validUntil = uniform.validUntil ? new Date(uniform.validUntil) : void 0;
|
|
910
|
+
const ttl = credSubject.ttl;
|
|
911
|
+
const updatedCredential = await this.createVerifiableCredential({
|
|
912
|
+
...args,
|
|
913
|
+
id,
|
|
914
|
+
issuer,
|
|
915
|
+
statusList,
|
|
916
|
+
proofFormat,
|
|
917
|
+
statusPurpose,
|
|
918
|
+
ttl,
|
|
919
|
+
validFrom,
|
|
920
|
+
validUntil
|
|
921
|
+
}, context);
|
|
922
|
+
return {
|
|
923
|
+
statusListCredential: updatedCredential,
|
|
924
|
+
encodedList: updatedCredential.credentialSubject.encodedList,
|
|
925
|
+
bitstringStatusList: {
|
|
926
|
+
statusPurpose,
|
|
927
|
+
...updatedCredential.validFrom && {
|
|
928
|
+
validFrom: new Date(updatedCredential.validFrom)
|
|
929
|
+
},
|
|
930
|
+
...updatedCredential.validUntil && {
|
|
931
|
+
validUntil: new Date(updatedCredential.validUntil)
|
|
932
|
+
},
|
|
933
|
+
bitsPerStatus: args.bitsPerStatus,
|
|
934
|
+
ttl
|
|
935
|
+
},
|
|
936
|
+
length: statusList.getLength(),
|
|
937
|
+
type: import_ssi_types5.StatusListType.BitstringStatusList,
|
|
938
|
+
proofFormat,
|
|
939
|
+
id,
|
|
940
|
+
issuer,
|
|
941
|
+
statuslistContentType: this.buildContentType(proofFormat)
|
|
942
|
+
};
|
|
943
|
+
}
|
|
944
|
+
async updateStatusListFromEncodedList(args, context) {
|
|
945
|
+
if (!args.bitstringStatusList) {
|
|
946
|
+
throw new Error("bitstringStatusList options required for type BitstringStatusList");
|
|
947
|
+
}
|
|
948
|
+
if (args.bitstringStatusList.bitsPerStatus < 1) {
|
|
949
|
+
return Promise.reject("bitsPerStatus must be set for bitstring status lists and must be 1 or higher. (updateStatusListFromEncodedList)");
|
|
950
|
+
}
|
|
951
|
+
const { statusPurpose, bitsPerStatus, ttl, validFrom, validUntil } = args.bitstringStatusList;
|
|
952
|
+
const proofFormat = args?.proofFormat ?? DEFAULT_PROOF_FORMAT3;
|
|
953
|
+
assertValidProofType(import_ssi_types5.StatusListType.BitstringStatusList, proofFormat);
|
|
954
|
+
const veramoProofFormat = proofFormat;
|
|
955
|
+
const { issuer, id } = getAssertedValues(args);
|
|
956
|
+
const statusList = await import_vc_bitstring_status_lists.BitstreamStatusList.decode({
|
|
957
|
+
encodedList: args.encodedList,
|
|
958
|
+
statusSize: bitsPerStatus
|
|
959
|
+
});
|
|
960
|
+
const index = typeof args.statusListIndex === "number" ? args.statusListIndex : parseInt(args.statusListIndex);
|
|
961
|
+
statusList.setStatus(index, args.value);
|
|
962
|
+
const credential = await this.createVerifiableCredential({
|
|
963
|
+
id,
|
|
964
|
+
issuer,
|
|
965
|
+
statusList,
|
|
966
|
+
proofFormat: veramoProofFormat,
|
|
967
|
+
keyRef: args.keyRef,
|
|
968
|
+
statusPurpose,
|
|
969
|
+
validFrom: ensureDate(validFrom),
|
|
970
|
+
validUntil: ensureDate(validUntil),
|
|
971
|
+
ttl
|
|
972
|
+
}, context);
|
|
973
|
+
return {
|
|
974
|
+
type: import_ssi_types5.StatusListType.BitstringStatusList,
|
|
975
|
+
statusListCredential: credential,
|
|
976
|
+
encodedList: credential.credentialSubject.encodedList,
|
|
977
|
+
bitstringStatusList: {
|
|
978
|
+
statusPurpose,
|
|
979
|
+
bitsPerStatus,
|
|
980
|
+
...credential.validFrom && {
|
|
981
|
+
validFrom: new Date(credential.validFrom)
|
|
982
|
+
},
|
|
983
|
+
...credential.validUntil && {
|
|
984
|
+
validUntil: new Date(credential.validUntil)
|
|
985
|
+
},
|
|
986
|
+
ttl
|
|
987
|
+
},
|
|
988
|
+
length: statusList.getLength(),
|
|
989
|
+
proofFormat: args.proofFormat ?? "lds",
|
|
990
|
+
id,
|
|
991
|
+
issuer,
|
|
992
|
+
statuslistContentType: this.buildContentType(proofFormat)
|
|
993
|
+
};
|
|
994
|
+
}
|
|
995
|
+
async checkStatusIndex(args) {
|
|
996
|
+
if (!args.bitsPerStatus || args.bitsPerStatus < 1) {
|
|
997
|
+
return Promise.reject("bitsPerStatus must be set for bitstring status lists and must be 1 or higher. (checkStatusIndex)");
|
|
998
|
+
}
|
|
999
|
+
const uniform = import_ssi_types5.CredentialMapper.toUniformCredential(args.statusListCredential);
|
|
1000
|
+
const { credentialSubject } = uniform;
|
|
1001
|
+
const encodedList = getAssertedProperty("encodedList", credentialSubject);
|
|
1002
|
+
const statusSize = args.bitsPerStatus;
|
|
1003
|
+
const statusList = await import_vc_bitstring_status_lists.BitstreamStatusList.decode({
|
|
1004
|
+
encodedList,
|
|
1005
|
+
statusSize
|
|
1006
|
+
});
|
|
1007
|
+
const numIndex = typeof args.statusListIndex === "number" ? args.statusListIndex : parseInt(args.statusListIndex);
|
|
1008
|
+
if (statusList.getLength() <= numIndex) {
|
|
1009
|
+
throw new Error(`Status list index out of bounds, has ${statusList.getLength()} entries, requested ${numIndex}`);
|
|
1010
|
+
}
|
|
1011
|
+
return statusList.getStatus(numIndex);
|
|
1012
|
+
}
|
|
1013
|
+
async toStatusListDetails(args) {
|
|
1014
|
+
const { statusListPayload, bitsPerStatus } = args;
|
|
1015
|
+
if (!bitsPerStatus || bitsPerStatus < 1) {
|
|
1016
|
+
return Promise.reject("bitsPerStatus must be set for bitstring status lists and must be 1 or higher. (toStatusListDetails)");
|
|
1017
|
+
}
|
|
1018
|
+
const uniform = import_ssi_types5.CredentialMapper.toUniformCredential(statusListPayload);
|
|
1019
|
+
const { issuer, credentialSubject } = uniform;
|
|
1020
|
+
const id = getAssertedValue("id", uniform.id);
|
|
1021
|
+
const encodedList = getAssertedProperty("encodedList", credentialSubject);
|
|
1022
|
+
const proofFormat = import_ssi_types5.CredentialMapper.detectDocumentType(statusListPayload) === import_ssi_types5.DocumentFormat.JWT ? "jwt" : "lds";
|
|
1023
|
+
const credSubject = Array.isArray(credentialSubject) ? credentialSubject[0] : credentialSubject;
|
|
1024
|
+
const statusPurpose = getAssertedProperty("statusPurpose", credSubject);
|
|
1025
|
+
const validFrom = uniform.validFrom ? new Date(uniform.validFrom) : void 0;
|
|
1026
|
+
const validUntil = uniform.validUntil ? new Date(uniform.validUntil) : void 0;
|
|
1027
|
+
const ttl = credSubject.ttl;
|
|
1028
|
+
const statuslistLength = import_vc_bitstring_status_lists.BitstreamStatusList.getStatusListLength(encodedList, bitsPerStatus);
|
|
1029
|
+
return {
|
|
1030
|
+
// Base implementation fields
|
|
1031
|
+
id,
|
|
1032
|
+
encodedList,
|
|
1033
|
+
issuer,
|
|
1034
|
+
type: import_ssi_types5.StatusListType.BitstringStatusList,
|
|
1035
|
+
proofFormat,
|
|
1036
|
+
length: statuslistLength,
|
|
1037
|
+
statusListCredential: statusListPayload,
|
|
1038
|
+
statuslistContentType: this.buildContentType(proofFormat),
|
|
1039
|
+
correlationId: args.correlationId,
|
|
1040
|
+
driverType: args.driverType,
|
|
1041
|
+
// Flattened Bitstring-specific fields
|
|
1042
|
+
statusPurpose,
|
|
1043
|
+
bitsPerStatus,
|
|
1044
|
+
...validFrom && {
|
|
1045
|
+
validFrom
|
|
1046
|
+
},
|
|
1047
|
+
...validUntil && {
|
|
1048
|
+
validUntil
|
|
1049
|
+
},
|
|
1050
|
+
...ttl && {
|
|
1051
|
+
ttl
|
|
1052
|
+
},
|
|
1053
|
+
// Legacy nested structure for backward compatibility
|
|
1054
|
+
bitstringStatusList: {
|
|
1055
|
+
statusPurpose,
|
|
1056
|
+
bitsPerStatus,
|
|
1057
|
+
...validFrom && {
|
|
1058
|
+
validFrom
|
|
1059
|
+
},
|
|
1060
|
+
...validUntil && {
|
|
1061
|
+
validUntil
|
|
1062
|
+
},
|
|
1063
|
+
...ttl && {
|
|
1064
|
+
ttl
|
|
1065
|
+
}
|
|
1066
|
+
},
|
|
1067
|
+
// Optional fields from args
|
|
1068
|
+
...args.correlationId && {
|
|
1069
|
+
correlationId: args.correlationId
|
|
1070
|
+
},
|
|
1071
|
+
...args.driverType && {
|
|
1072
|
+
driverType: args.driverType
|
|
1073
|
+
}
|
|
1074
|
+
};
|
|
1075
|
+
}
|
|
1076
|
+
async createCredentialStatus(args) {
|
|
1077
|
+
const { statusList, statusListEntry, statusListIndex } = args;
|
|
1078
|
+
const isBitstringEntry = /* @__PURE__ */ __name((entry) => {
|
|
1079
|
+
return "statusPurpose" in entry;
|
|
1080
|
+
}, "isBitstringEntry");
|
|
1081
|
+
if (!isBitstringEntry(statusListEntry)) {
|
|
1082
|
+
throw new Error("Expected bitstring status list entry for bitstring status list");
|
|
1083
|
+
}
|
|
1084
|
+
const bitstringStatusList = statusList;
|
|
1085
|
+
return {
|
|
1086
|
+
id: `${statusList.id}#${statusListIndex}`,
|
|
1087
|
+
type: "BitstringStatusListEntry",
|
|
1088
|
+
statusPurpose: statusListEntry.statusPurpose,
|
|
1089
|
+
statusListIndex: "" + statusListIndex,
|
|
1090
|
+
statusListCredential: statusList.id,
|
|
1091
|
+
bitsPerStatus: bitstringStatusList.bitsPerStatus
|
|
1092
|
+
};
|
|
1093
|
+
}
|
|
1094
|
+
async createVerifiableCredential(args, context) {
|
|
1095
|
+
const identifier = await context.agent.identifierManagedGet({
|
|
1096
|
+
identifier: typeof args.issuer === "string" ? args.issuer : args.issuer.id,
|
|
1097
|
+
vmRelationship: "assertionMethod",
|
|
1098
|
+
offlineWhenNoDIDRegistered: true
|
|
1099
|
+
});
|
|
1100
|
+
const unsignedCredential = await (0, import_vc_bitstring_status_lists.createStatusListCredential)(args);
|
|
1101
|
+
const verifiableCredential = await context.agent.createVerifiableCredential({
|
|
1102
|
+
credential: unsignedCredential,
|
|
1103
|
+
keyRef: args.keyRef ?? identifier.kmsKeyRef,
|
|
1104
|
+
proofFormat: args.proofFormat,
|
|
1105
|
+
fetchRemoteContexts: true
|
|
1106
|
+
});
|
|
1107
|
+
return import_ssi_types5.CredentialMapper.toWrappedVerifiableCredential(verifiableCredential).original;
|
|
1108
|
+
}
|
|
1109
|
+
buildContentType(proofFormat) {
|
|
1110
|
+
switch (proofFormat) {
|
|
1111
|
+
case "jwt":
|
|
1112
|
+
return `application/statuslist+jwt`;
|
|
1113
|
+
case "cbor":
|
|
1114
|
+
return `application/statuslist+cwt`;
|
|
1115
|
+
case "lds":
|
|
1116
|
+
return "application/statuslist+ld+json";
|
|
1117
|
+
default:
|
|
1118
|
+
throw Error(`Unsupported content type '${proofFormat}' for status lists`);
|
|
1119
|
+
}
|
|
1120
|
+
}
|
|
1121
|
+
};
|
|
1122
|
+
|
|
1123
|
+
// src/impl/StatusListFactory.ts
|
|
759
1124
|
var StatusListFactory = class _StatusListFactory {
|
|
760
1125
|
static {
|
|
761
1126
|
__name(this, "StatusListFactory");
|
|
@@ -764,8 +1129,9 @@ var StatusListFactory = class _StatusListFactory {
|
|
|
764
1129
|
implementations;
|
|
765
1130
|
constructor() {
|
|
766
1131
|
this.implementations = /* @__PURE__ */ new Map();
|
|
767
|
-
this.implementations.set(
|
|
768
|
-
this.implementations.set(
|
|
1132
|
+
this.implementations.set(import_ssi_types6.StatusListType.StatusList2021, new StatusList2021Implementation());
|
|
1133
|
+
this.implementations.set(import_ssi_types6.StatusListType.OAuthStatusList, new OAuthStatusListImplementation());
|
|
1134
|
+
this.implementations.set(import_ssi_types6.StatusListType.BitstringStatusList, new BitstringStatusListImplementation());
|
|
769
1135
|
}
|
|
770
1136
|
static getInstance() {
|
|
771
1137
|
if (!_StatusListFactory.instance) {
|
|
@@ -838,7 +1204,7 @@ __name(vcLibCheckStatusFunction, "vcLibCheckStatusFunction");
|
|
|
838
1204
|
async function checkStatusForCredential(args) {
|
|
839
1205
|
const verifyStatusListCredential = args.verifyStatusListCredential ?? true;
|
|
840
1206
|
const verifyMatchingIssuers = args.verifyMatchingIssuers ?? true;
|
|
841
|
-
const uniform =
|
|
1207
|
+
const uniform = import_ssi_types7.CredentialMapper.toUniformCredential(args.credential);
|
|
842
1208
|
if (!("credentialStatus" in uniform) || !uniform.credentialStatus) {
|
|
843
1209
|
if (args.mandatoryCredentialStatus) {
|
|
844
1210
|
const error = "No credential status object found in the Verifiable Credential and it is mandatory";
|
|
@@ -853,7 +1219,7 @@ async function checkStatusForCredential(args) {
|
|
|
853
1219
|
};
|
|
854
1220
|
}
|
|
855
1221
|
if ("credentialStatus" in uniform && uniform.credentialStatus) {
|
|
856
|
-
if (uniform.credentialStatus.type === "StatusList2021Entry") {
|
|
1222
|
+
if (uniform.credentialStatus.type === "StatusList2021Entry" || uniform.credentialStatus.type === "BitstringStatusListEntry") {
|
|
857
1223
|
return (0, import_vc_status_list2.checkStatus)({
|
|
858
1224
|
...args,
|
|
859
1225
|
verifyStatusListCredential,
|
|
@@ -901,35 +1267,48 @@ async function updateStatusIndexFromStatusListCredential(args, context) {
|
|
|
901
1267
|
return implementation.updateStatusListIndex(args, context);
|
|
902
1268
|
}
|
|
903
1269
|
__name(updateStatusIndexFromStatusListCredential, "updateStatusIndexFromStatusListCredential");
|
|
904
|
-
async function statusListCredentialToDetails(
|
|
905
|
-
const credential = getAssertedValue("statusListCredential",
|
|
1270
|
+
async function statusListCredentialToDetails({ correlationId, driverType, statusListCredential, bitsPerStatus }) {
|
|
1271
|
+
const credential = getAssertedValue("statusListCredential", statusListCredential);
|
|
906
1272
|
let statusListType;
|
|
907
|
-
const documentFormat =
|
|
908
|
-
if (documentFormat ===
|
|
1273
|
+
const documentFormat = import_ssi_types7.CredentialMapper.detectDocumentType(credential);
|
|
1274
|
+
if (documentFormat === import_ssi_types7.DocumentFormat.JWT) {
|
|
909
1275
|
const [header] = credential.split(".");
|
|
910
1276
|
const decodedHeader = JSON.parse(Buffer.from(header, "base64").toString());
|
|
911
1277
|
if (decodedHeader.typ === "statuslist+jwt") {
|
|
912
|
-
statusListType =
|
|
1278
|
+
statusListType = import_ssi_types7.StatusListType.OAuthStatusList;
|
|
913
1279
|
}
|
|
914
|
-
} else if (documentFormat ===
|
|
915
|
-
statusListType =
|
|
1280
|
+
} else if (documentFormat === import_ssi_types7.DocumentFormat.MSO_MDOC) {
|
|
1281
|
+
statusListType = import_ssi_types7.StatusListType.OAuthStatusList;
|
|
916
1282
|
}
|
|
917
1283
|
if (!statusListType) {
|
|
918
|
-
const uniform =
|
|
919
|
-
const type = uniform.type.find((t) => t.includes("StatusList2021") || t.includes("OAuth2StatusList"));
|
|
1284
|
+
const uniform = import_ssi_types7.CredentialMapper.toUniformCredential(credential);
|
|
1285
|
+
const type = uniform.type.find((t) => t.includes("StatusList2021") || t.includes("OAuth2StatusList") || t.includes("BitstringStatusList"));
|
|
920
1286
|
if (!type) {
|
|
921
1287
|
throw new Error("Invalid status list credential type");
|
|
922
1288
|
}
|
|
923
1289
|
statusListType = type.replace("Credential", "");
|
|
924
1290
|
}
|
|
925
1291
|
const implementation = getStatusListImplementation(statusListType);
|
|
926
|
-
|
|
1292
|
+
const result = await implementation.toStatusListDetails({
|
|
927
1293
|
statusListPayload: credential,
|
|
928
|
-
correlationId
|
|
929
|
-
driverType
|
|
1294
|
+
correlationId,
|
|
1295
|
+
driverType,
|
|
1296
|
+
bitsPerStatus
|
|
930
1297
|
});
|
|
1298
|
+
return result;
|
|
931
1299
|
}
|
|
932
1300
|
__name(statusListCredentialToDetails, "statusListCredentialToDetails");
|
|
1301
|
+
async function createCredentialStatusFromStatusList(args) {
|
|
1302
|
+
const { statusList, statusListEntry, statusListIndex } = args;
|
|
1303
|
+
const statusListType = determineStatusListType(statusList.statusListCredential);
|
|
1304
|
+
const implementation = getStatusListImplementation(statusListType);
|
|
1305
|
+
return implementation.createCredentialStatus({
|
|
1306
|
+
statusList,
|
|
1307
|
+
statusListEntry,
|
|
1308
|
+
statusListIndex
|
|
1309
|
+
});
|
|
1310
|
+
}
|
|
1311
|
+
__name(createCredentialStatusFromStatusList, "createCredentialStatusFromStatusList");
|
|
933
1312
|
async function updateStatusListIndexFromEncodedList(args, context) {
|
|
934
1313
|
const { type } = getAssertedValue("type", args);
|
|
935
1314
|
const implementation = getStatusListImplementation(type);
|
|
@@ -944,7 +1323,7 @@ async function statusList2021ToVerifiableCredential(args, context) {
|
|
|
944
1323
|
offlineWhenNoDIDRegistered: true
|
|
945
1324
|
});
|
|
946
1325
|
const proofFormat = args?.proofFormat ?? "lds";
|
|
947
|
-
assertValidProofType(
|
|
1326
|
+
assertValidProofType(import_ssi_types7.StatusListType.StatusList2021, proofFormat);
|
|
948
1327
|
const veramoProofFormat = proofFormat;
|
|
949
1328
|
const encodedList = getAssertedValue("encodedList", args.encodedList);
|
|
950
1329
|
const statusPurpose = getAssertedValue("statusPurpose", args.statusPurpose);
|
|
@@ -973,7 +1352,7 @@ async function statusList2021ToVerifiableCredential(args, context) {
|
|
|
973
1352
|
proofFormat: veramoProofFormat,
|
|
974
1353
|
fetchRemoteContexts: true
|
|
975
1354
|
});
|
|
976
|
-
return
|
|
1355
|
+
return import_ssi_types7.CredentialMapper.toWrappedVerifiableCredential(verifiableCredential).original;
|
|
977
1356
|
}
|
|
978
1357
|
__name(statusList2021ToVerifiableCredential, "statusList2021ToVerifiableCredential");
|
|
979
1358
|
//# sourceMappingURL=index.cjs.map
|