@sphereon/ssi-sdk.vc-status-list 0.33.1-next.73 → 0.34.1-feature.SSISDK.17.bitstring.sl.10
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 +307 -27
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +49 -8
- package/dist/index.d.ts +49 -8
- package/dist/index.js +308 -28
- package/dist/index.js.map +1 -1
- package/package.json +8 -7
- package/src/functions.ts +19 -10
- package/src/impl/BitstringStatusListImplementation.ts +301 -0
- package/src/impl/IStatusList.ts +3 -2
- package/src/impl/OAuthStatusList.ts +17 -11
- package/src/impl/StatusList2021.ts +3 -3
- package/src/impl/StatusListFactory.ts +2 -0
- package/src/types/BitstringStatusList.ts +4 -0
- package/src/types/index.ts +48 -4
- package/src/utils.ts +35 -2
package/dist/index.js
CHANGED
|
@@ -15,7 +15,7 @@ var Status2021 = /* @__PURE__ */ function(Status20212) {
|
|
|
15
15
|
}({});
|
|
16
16
|
|
|
17
17
|
// src/functions.ts
|
|
18
|
-
import { CredentialMapper as
|
|
18
|
+
import { CredentialMapper as CredentialMapper4, DocumentFormat as DocumentFormat4, StatusListType as StatusListType6 } from "@sphereon/ssi-types";
|
|
19
19
|
import { checkStatus } from "@sphereon/vc-status-list";
|
|
20
20
|
|
|
21
21
|
// src/utils.ts
|
|
@@ -25,7 +25,8 @@ function getAssertedStatusListType(type) {
|
|
|
25
25
|
const assertedType = type ?? StatusListType.StatusList2021;
|
|
26
26
|
if (![
|
|
27
27
|
StatusListType.StatusList2021,
|
|
28
|
-
StatusListType.OAuthStatusList
|
|
28
|
+
StatusListType.OAuthStatusList,
|
|
29
|
+
StatusListType.BitstringStatusList
|
|
29
30
|
].includes(assertedType)) {
|
|
30
31
|
throw Error(`StatusList type ${assertedType} is not supported (yet)`);
|
|
31
32
|
}
|
|
@@ -62,8 +63,7 @@ var ValidProofTypeMap = /* @__PURE__ */ new Map([
|
|
|
62
63
|
StatusListType.StatusList2021,
|
|
63
64
|
[
|
|
64
65
|
"jwt",
|
|
65
|
-
"lds"
|
|
66
|
-
"EthereumEip712Signature2021"
|
|
66
|
+
"lds"
|
|
67
67
|
]
|
|
68
68
|
],
|
|
69
69
|
[
|
|
@@ -72,6 +72,12 @@ var ValidProofTypeMap = /* @__PURE__ */ new Map([
|
|
|
72
72
|
"jwt",
|
|
73
73
|
"cbor"
|
|
74
74
|
]
|
|
75
|
+
],
|
|
76
|
+
[
|
|
77
|
+
StatusListType.BitstringStatusList,
|
|
78
|
+
[
|
|
79
|
+
"lds"
|
|
80
|
+
]
|
|
75
81
|
]
|
|
76
82
|
]);
|
|
77
83
|
function assertValidProofType(type, proofFormat) {
|
|
@@ -122,6 +128,26 @@ function determineProofFormat(credential) {
|
|
|
122
128
|
}
|
|
123
129
|
}
|
|
124
130
|
__name(determineProofFormat, "determineProofFormat");
|
|
131
|
+
function ensureDate(value) {
|
|
132
|
+
if (value === void 0 || value === null) {
|
|
133
|
+
return void 0;
|
|
134
|
+
}
|
|
135
|
+
if (value instanceof Date) {
|
|
136
|
+
return value;
|
|
137
|
+
}
|
|
138
|
+
if (typeof value === "string") {
|
|
139
|
+
if (value.trim() === "") {
|
|
140
|
+
return void 0;
|
|
141
|
+
}
|
|
142
|
+
const date = new Date(value);
|
|
143
|
+
if (isNaN(date.getTime())) {
|
|
144
|
+
return void 0;
|
|
145
|
+
}
|
|
146
|
+
return date;
|
|
147
|
+
}
|
|
148
|
+
return void 0;
|
|
149
|
+
}
|
|
150
|
+
__name(ensureDate, "ensureDate");
|
|
125
151
|
|
|
126
152
|
// src/impl/StatusList2021.ts
|
|
127
153
|
import { CredentialMapper as CredentialMapper2, DocumentFormat as DocumentFormat2, StatusListType as StatusListType2 } from "@sphereon/ssi-types";
|
|
@@ -214,7 +240,7 @@ var StatusList2021Implementation = class {
|
|
|
214
240
|
encodedList: args.encodedList
|
|
215
241
|
});
|
|
216
242
|
const index = typeof args.statusListIndex === "number" ? args.statusListIndex : parseInt(args.statusListIndex);
|
|
217
|
-
statusList.setStatus(index, args.value);
|
|
243
|
+
statusList.setStatus(index, args.value !== 0);
|
|
218
244
|
const newEncodedList = await statusList.encode();
|
|
219
245
|
const credential = await this.createVerifiableCredential({
|
|
220
246
|
id,
|
|
@@ -572,7 +598,8 @@ var OAuthStatusListImplementation = class {
|
|
|
572
598
|
}
|
|
573
599
|
const proofFormat = args?.proofFormat ?? DEFAULT_PROOF_FORMAT2;
|
|
574
600
|
const { issuer, id, oauthStatusList, keyRef } = args;
|
|
575
|
-
const { bitsPerStatus
|
|
601
|
+
const { bitsPerStatus } = oauthStatusList;
|
|
602
|
+
const expiresAt = ensureDate(oauthStatusList.expiresAt);
|
|
576
603
|
const length = args.length ?? DEFAULT_LIST_LENGTH2;
|
|
577
604
|
const issuerString = typeof issuer === "string" ? issuer : issuer.id;
|
|
578
605
|
const correlationId = getAssertedValue("correlationId", args.correlationId);
|
|
@@ -595,7 +622,8 @@ var OAuthStatusListImplementation = class {
|
|
|
595
622
|
};
|
|
596
623
|
}
|
|
597
624
|
async updateStatusListIndex(args, context) {
|
|
598
|
-
const { statusListCredential, value,
|
|
625
|
+
const { statusListCredential, value, keyRef } = args;
|
|
626
|
+
const expiresAt = ensureDate(args.expiresAt);
|
|
599
627
|
if (typeof statusListCredential !== "string") {
|
|
600
628
|
return Promise.reject("statusListCredential in neither JWT nor CWT");
|
|
601
629
|
}
|
|
@@ -606,6 +634,9 @@ var OAuthStatusListImplementation = class {
|
|
|
606
634
|
if (index < 0 || index >= statusList.statusList.length) {
|
|
607
635
|
throw new Error("Status list index out of bounds");
|
|
608
636
|
}
|
|
637
|
+
if (typeof value !== "number") {
|
|
638
|
+
throw new Error("Status list values should be of type number");
|
|
639
|
+
}
|
|
609
640
|
statusList.setStatus(index, value);
|
|
610
641
|
const { statusListCredential: signedCredential, encodedList } = await this.createSignedStatusList(proofFormat, context, statusList, issuer, id, expiresAt, keyRef);
|
|
611
642
|
return {
|
|
@@ -628,12 +659,13 @@ var OAuthStatusListImplementation = class {
|
|
|
628
659
|
throw new Error("OAuthStatusList options are required for type OAuthStatusList");
|
|
629
660
|
}
|
|
630
661
|
const { proofFormat, oauthStatusList, keyRef } = args;
|
|
631
|
-
const { bitsPerStatus
|
|
662
|
+
const { bitsPerStatus } = oauthStatusList;
|
|
663
|
+
const expiresAt = ensureDate(oauthStatusList.expiresAt);
|
|
632
664
|
const { issuer, id } = getAssertedValues(args);
|
|
633
665
|
const issuerString = typeof issuer === "string" ? issuer : issuer.id;
|
|
634
666
|
const listToUpdate = StatusList4.decompressStatusList(args.encodedList, bitsPerStatus ?? DEFAULT_BITS_PER_STATUS);
|
|
635
667
|
const index = typeof args.statusListIndex === "number" ? args.statusListIndex : parseInt(args.statusListIndex);
|
|
636
|
-
listToUpdate.setStatus(index, args.value
|
|
668
|
+
listToUpdate.setStatus(index, args.value);
|
|
637
669
|
const { statusListCredential, encodedList } = await this.createSignedStatusList(proofFormat ?? DEFAULT_PROOF_FORMAT2, context, listToUpdate, issuerString, id, expiresAt, keyRef);
|
|
638
670
|
return {
|
|
639
671
|
encodedList,
|
|
@@ -662,7 +694,7 @@ var OAuthStatusListImplementation = class {
|
|
|
662
694
|
const { statusList } = proofFormat === "jwt" ? decodeStatusListJWT(statusListCredential) : decodeStatusListCWT(statusListCredential);
|
|
663
695
|
const index = typeof statusListIndex === "number" ? statusListIndex : parseInt(statusListIndex);
|
|
664
696
|
if (index < 0 || index >= statusList.statusList.length) {
|
|
665
|
-
throw new Error(
|
|
697
|
+
throw new Error(`Status list index out of bounds, has ${statusList.statusList.length} items, requested ${index}`);
|
|
666
698
|
}
|
|
667
699
|
return statusList.getStatus(index);
|
|
668
700
|
}
|
|
@@ -709,7 +741,253 @@ var OAuthStatusListImplementation = class {
|
|
|
709
741
|
};
|
|
710
742
|
|
|
711
743
|
// src/impl/StatusListFactory.ts
|
|
712
|
-
import { StatusListType as
|
|
744
|
+
import { StatusListType as StatusListType5 } from "@sphereon/ssi-types";
|
|
745
|
+
|
|
746
|
+
// src/impl/BitstringStatusListImplementation.ts
|
|
747
|
+
import { CredentialMapper as CredentialMapper3, DocumentFormat as DocumentFormat3, StatusListType as StatusListType4 } from "@sphereon/ssi-types";
|
|
748
|
+
import { BitstreamStatusList, createStatusListCredential } from "@4sure-tech/vc-bitstring-status-lists";
|
|
749
|
+
var DEFAULT_LIST_LENGTH3 = 131072;
|
|
750
|
+
var DEFAULT_PROOF_FORMAT3 = "lds";
|
|
751
|
+
var DEFAULT_STATUS_PURPOSE = "revocation";
|
|
752
|
+
var BitstringStatusListImplementation = class {
|
|
753
|
+
static {
|
|
754
|
+
__name(this, "BitstringStatusListImplementation");
|
|
755
|
+
}
|
|
756
|
+
async createNewStatusList(args, context) {
|
|
757
|
+
if (!args.bitstringStatusList) {
|
|
758
|
+
throw new Error("BitstringStatusList options are required for type BitstringStatusList");
|
|
759
|
+
}
|
|
760
|
+
const length = args?.length ?? DEFAULT_LIST_LENGTH3;
|
|
761
|
+
const proofFormat = args?.proofFormat ?? DEFAULT_PROOF_FORMAT3;
|
|
762
|
+
assertValidProofType(StatusListType4.BitstringStatusList, proofFormat);
|
|
763
|
+
const veramoProofFormat = proofFormat;
|
|
764
|
+
const { issuer, id } = args;
|
|
765
|
+
const correlationId = getAssertedValue("correlationId", args.correlationId);
|
|
766
|
+
const { statusPurpose, bitsPerStatus, validFrom, validUntil, ttl } = args.bitstringStatusList;
|
|
767
|
+
const statusListCredential = await this.createVerifiableCredential({
|
|
768
|
+
...args,
|
|
769
|
+
proofFormat: veramoProofFormat,
|
|
770
|
+
statusPurpose: statusPurpose ?? DEFAULT_STATUS_PURPOSE,
|
|
771
|
+
validFrom: ensureDate(validFrom),
|
|
772
|
+
validUntil: ensureDate(validUntil),
|
|
773
|
+
ttl
|
|
774
|
+
}, context);
|
|
775
|
+
return {
|
|
776
|
+
encodedList: statusListCredential.credentialSubject.encodedList,
|
|
777
|
+
statusListCredential,
|
|
778
|
+
bitstringStatusList: {
|
|
779
|
+
statusPurpose: statusPurpose ?? DEFAULT_STATUS_PURPOSE,
|
|
780
|
+
...statusListCredential.validFrom && {
|
|
781
|
+
validFrom: new Date(statusListCredential.validFrom)
|
|
782
|
+
},
|
|
783
|
+
...statusListCredential.validUntil && {
|
|
784
|
+
validUntil: new Date(statusListCredential.validUntil)
|
|
785
|
+
},
|
|
786
|
+
ttl,
|
|
787
|
+
bitsPerStatus
|
|
788
|
+
},
|
|
789
|
+
length,
|
|
790
|
+
type: StatusListType4.BitstringStatusList,
|
|
791
|
+
proofFormat,
|
|
792
|
+
id,
|
|
793
|
+
correlationId,
|
|
794
|
+
issuer,
|
|
795
|
+
statuslistContentType: this.buildContentType(proofFormat)
|
|
796
|
+
};
|
|
797
|
+
}
|
|
798
|
+
async updateStatusListIndex(args, context) {
|
|
799
|
+
if (!args.bitsPerStatus || args.bitsPerStatus < 1) {
|
|
800
|
+
return Promise.reject("bitsPerStatus must be set for bitstring status lists and must be 1 or higher. (updateStatusListIndex)");
|
|
801
|
+
}
|
|
802
|
+
const credential = args.statusListCredential;
|
|
803
|
+
const uniform = CredentialMapper3.toUniformCredential(credential);
|
|
804
|
+
const { issuer, credentialSubject } = uniform;
|
|
805
|
+
const id = getAssertedValue("id", uniform.id);
|
|
806
|
+
const origEncodedList = getAssertedProperty("encodedList", credentialSubject);
|
|
807
|
+
const index = typeof args.statusListIndex === "number" ? args.statusListIndex : parseInt(args.statusListIndex);
|
|
808
|
+
const statusList = await BitstreamStatusList.decode({
|
|
809
|
+
encodedList: origEncodedList,
|
|
810
|
+
statusSize: args.bitsPerStatus
|
|
811
|
+
});
|
|
812
|
+
statusList.setStatus(index, args.value);
|
|
813
|
+
const proofFormat = CredentialMapper3.detectDocumentType(credential) === DocumentFormat3.JWT ? "jwt" : "lds";
|
|
814
|
+
const credSubject = Array.isArray(credentialSubject) ? credentialSubject[0] : credentialSubject;
|
|
815
|
+
const statusPurpose = getAssertedProperty("statusPurpose", credSubject);
|
|
816
|
+
const validFrom = uniform.validFrom ? new Date(uniform.validFrom) : void 0;
|
|
817
|
+
const validUntil = uniform.validUntil ? new Date(uniform.validUntil) : void 0;
|
|
818
|
+
const ttl = credSubject.ttl;
|
|
819
|
+
const updatedCredential = await this.createVerifiableCredential({
|
|
820
|
+
...args,
|
|
821
|
+
id,
|
|
822
|
+
issuer,
|
|
823
|
+
statusList,
|
|
824
|
+
proofFormat,
|
|
825
|
+
statusPurpose,
|
|
826
|
+
ttl,
|
|
827
|
+
validFrom,
|
|
828
|
+
validUntil
|
|
829
|
+
}, context);
|
|
830
|
+
return {
|
|
831
|
+
statusListCredential: updatedCredential,
|
|
832
|
+
encodedList: updatedCredential.credentialSubject.encodedList,
|
|
833
|
+
bitstringStatusList: {
|
|
834
|
+
statusPurpose,
|
|
835
|
+
...updatedCredential.validFrom && {
|
|
836
|
+
validFrom: new Date(updatedCredential.validFrom)
|
|
837
|
+
},
|
|
838
|
+
...updatedCredential.validUntil && {
|
|
839
|
+
validUntil: new Date(updatedCredential.validUntil)
|
|
840
|
+
},
|
|
841
|
+
bitsPerStatus: args.bitsPerStatus,
|
|
842
|
+
ttl
|
|
843
|
+
},
|
|
844
|
+
length: statusList.getLength(),
|
|
845
|
+
type: StatusListType4.BitstringStatusList,
|
|
846
|
+
proofFormat,
|
|
847
|
+
id,
|
|
848
|
+
issuer,
|
|
849
|
+
statuslistContentType: this.buildContentType(proofFormat)
|
|
850
|
+
};
|
|
851
|
+
}
|
|
852
|
+
async updateStatusListFromEncodedList(args, context) {
|
|
853
|
+
if (!args.bitstringStatusList) {
|
|
854
|
+
throw new Error("bitstringStatusList options required for type BitstringStatusList");
|
|
855
|
+
}
|
|
856
|
+
if (args.bitstringStatusList.bitsPerStatus < 1) {
|
|
857
|
+
return Promise.reject("bitsPerStatus must be set for bitstring status lists and must be 1 or higher. (updateStatusListFromEncodedList)");
|
|
858
|
+
}
|
|
859
|
+
const { statusPurpose, bitsPerStatus, ttl, validFrom, validUntil } = args.bitstringStatusList;
|
|
860
|
+
const proofFormat = args?.proofFormat ?? DEFAULT_PROOF_FORMAT3;
|
|
861
|
+
assertValidProofType(StatusListType4.BitstringStatusList, proofFormat);
|
|
862
|
+
const veramoProofFormat = proofFormat;
|
|
863
|
+
const { issuer, id } = getAssertedValues(args);
|
|
864
|
+
const statusList = await BitstreamStatusList.decode({
|
|
865
|
+
encodedList: args.encodedList,
|
|
866
|
+
statusSize: bitsPerStatus
|
|
867
|
+
});
|
|
868
|
+
const index = typeof args.statusListIndex === "number" ? args.statusListIndex : parseInt(args.statusListIndex);
|
|
869
|
+
statusList.setStatus(index, args.value);
|
|
870
|
+
const credential = await this.createVerifiableCredential({
|
|
871
|
+
id,
|
|
872
|
+
issuer,
|
|
873
|
+
statusList,
|
|
874
|
+
proofFormat: veramoProofFormat,
|
|
875
|
+
keyRef: args.keyRef,
|
|
876
|
+
statusPurpose,
|
|
877
|
+
validFrom: ensureDate(validFrom),
|
|
878
|
+
validUntil: ensureDate(validUntil),
|
|
879
|
+
ttl
|
|
880
|
+
}, context);
|
|
881
|
+
return {
|
|
882
|
+
type: StatusListType4.BitstringStatusList,
|
|
883
|
+
statusListCredential: credential,
|
|
884
|
+
encodedList: credential.credentialSubject.encodedList,
|
|
885
|
+
bitstringStatusList: {
|
|
886
|
+
statusPurpose,
|
|
887
|
+
bitsPerStatus,
|
|
888
|
+
...credential.validFrom && {
|
|
889
|
+
validFrom: new Date(credential.validFrom)
|
|
890
|
+
},
|
|
891
|
+
...credential.validUntil && {
|
|
892
|
+
validUntil: new Date(credential.validUntil)
|
|
893
|
+
},
|
|
894
|
+
ttl
|
|
895
|
+
},
|
|
896
|
+
length: statusList.getLength(),
|
|
897
|
+
proofFormat: args.proofFormat ?? "lds",
|
|
898
|
+
id,
|
|
899
|
+
issuer,
|
|
900
|
+
statuslistContentType: this.buildContentType(proofFormat)
|
|
901
|
+
};
|
|
902
|
+
}
|
|
903
|
+
async checkStatusIndex(args) {
|
|
904
|
+
if (!args.bitsPerStatus || args.bitsPerStatus < 1) {
|
|
905
|
+
return Promise.reject("bitsPerStatus must be set for bitstring status lists and must be 1 or higher. (checkStatusIndex)");
|
|
906
|
+
}
|
|
907
|
+
const uniform = CredentialMapper3.toUniformCredential(args.statusListCredential);
|
|
908
|
+
const { credentialSubject } = uniform;
|
|
909
|
+
const encodedList = getAssertedProperty("encodedList", credentialSubject);
|
|
910
|
+
const statusSize = args.bitsPerStatus;
|
|
911
|
+
const statusList = await BitstreamStatusList.decode({
|
|
912
|
+
encodedList,
|
|
913
|
+
statusSize
|
|
914
|
+
});
|
|
915
|
+
const numIndex = typeof args.statusListIndex === "number" ? args.statusListIndex : parseInt(args.statusListIndex);
|
|
916
|
+
if (statusList.getLength() <= numIndex) {
|
|
917
|
+
throw new Error(`Status list index out of bounds, has ${statusList.getLength()} entries, requested ${numIndex}`);
|
|
918
|
+
}
|
|
919
|
+
return statusList.getStatus(numIndex);
|
|
920
|
+
}
|
|
921
|
+
async toStatusListDetails(args) {
|
|
922
|
+
const { statusListPayload, bitsPerStatus } = args;
|
|
923
|
+
if (!bitsPerStatus || bitsPerStatus < 1) {
|
|
924
|
+
return Promise.reject("bitsPerStatus must be set for bitstring status lists and must be 1 or higher. (toStatusListDetails)");
|
|
925
|
+
}
|
|
926
|
+
const uniform = CredentialMapper3.toUniformCredential(statusListPayload);
|
|
927
|
+
const { issuer, credentialSubject } = uniform;
|
|
928
|
+
const id = getAssertedValue("id", uniform.id);
|
|
929
|
+
const encodedList = getAssertedProperty("encodedList", credentialSubject);
|
|
930
|
+
const proofFormat = CredentialMapper3.detectDocumentType(statusListPayload) === DocumentFormat3.JWT ? "jwt" : "lds";
|
|
931
|
+
const credSubject = Array.isArray(credentialSubject) ? credentialSubject[0] : credentialSubject;
|
|
932
|
+
const statusPurpose = getAssertedProperty("statusPurpose", credSubject);
|
|
933
|
+
const validFrom = uniform.validFrom ? new Date(uniform.validFrom) : void 0;
|
|
934
|
+
const validUntil = uniform.validUntil ? new Date(uniform.validUntil) : void 0;
|
|
935
|
+
const ttl = credSubject.ttl;
|
|
936
|
+
const statuslistLength = BitstreamStatusList.getStatusListLength(encodedList, bitsPerStatus);
|
|
937
|
+
return {
|
|
938
|
+
id,
|
|
939
|
+
encodedList,
|
|
940
|
+
issuer,
|
|
941
|
+
type: StatusListType4.BitstringStatusList,
|
|
942
|
+
proofFormat,
|
|
943
|
+
length: statuslistLength,
|
|
944
|
+
statusListCredential: statusListPayload,
|
|
945
|
+
statuslistContentType: this.buildContentType(proofFormat),
|
|
946
|
+
bitstringStatusList: {
|
|
947
|
+
statusPurpose,
|
|
948
|
+
bitsPerStatus,
|
|
949
|
+
validFrom,
|
|
950
|
+
validUntil,
|
|
951
|
+
ttl
|
|
952
|
+
},
|
|
953
|
+
...args.correlationId && {
|
|
954
|
+
correlationId: args.correlationId
|
|
955
|
+
},
|
|
956
|
+
...args.driverType && {
|
|
957
|
+
driverType: args.driverType
|
|
958
|
+
}
|
|
959
|
+
};
|
|
960
|
+
}
|
|
961
|
+
async createVerifiableCredential(args, context) {
|
|
962
|
+
const identifier = await context.agent.identifierManagedGet({
|
|
963
|
+
identifier: typeof args.issuer === "string" ? args.issuer : args.issuer.id,
|
|
964
|
+
vmRelationship: "assertionMethod",
|
|
965
|
+
offlineWhenNoDIDRegistered: true
|
|
966
|
+
});
|
|
967
|
+
const unsignedCredential = await createStatusListCredential(args);
|
|
968
|
+
const verifiableCredential = await context.agent.createVerifiableCredential({
|
|
969
|
+
credential: unsignedCredential,
|
|
970
|
+
keyRef: args.keyRef ?? identifier.kmsKeyRef,
|
|
971
|
+
proofFormat: args.proofFormat,
|
|
972
|
+
fetchRemoteContexts: true
|
|
973
|
+
});
|
|
974
|
+
return CredentialMapper3.toWrappedVerifiableCredential(verifiableCredential).original;
|
|
975
|
+
}
|
|
976
|
+
buildContentType(proofFormat) {
|
|
977
|
+
switch (proofFormat) {
|
|
978
|
+
case "jwt":
|
|
979
|
+
return `application/statuslist+jwt`;
|
|
980
|
+
case "cbor":
|
|
981
|
+
return `application/statuslist+cwt`;
|
|
982
|
+
case "lds":
|
|
983
|
+
return "application/statuslist+ld+json";
|
|
984
|
+
default:
|
|
985
|
+
throw Error(`Unsupported content type '${proofFormat}' for status lists`);
|
|
986
|
+
}
|
|
987
|
+
}
|
|
988
|
+
};
|
|
989
|
+
|
|
990
|
+
// src/impl/StatusListFactory.ts
|
|
713
991
|
var StatusListFactory = class _StatusListFactory {
|
|
714
992
|
static {
|
|
715
993
|
__name(this, "StatusListFactory");
|
|
@@ -718,8 +996,9 @@ var StatusListFactory = class _StatusListFactory {
|
|
|
718
996
|
implementations;
|
|
719
997
|
constructor() {
|
|
720
998
|
this.implementations = /* @__PURE__ */ new Map();
|
|
721
|
-
this.implementations.set(
|
|
722
|
-
this.implementations.set(
|
|
999
|
+
this.implementations.set(StatusListType5.StatusList2021, new StatusList2021Implementation());
|
|
1000
|
+
this.implementations.set(StatusListType5.OAuthStatusList, new OAuthStatusListImplementation());
|
|
1001
|
+
this.implementations.set(StatusListType5.BitstringStatusList, new BitstringStatusListImplementation());
|
|
723
1002
|
}
|
|
724
1003
|
static getInstance() {
|
|
725
1004
|
if (!_StatusListFactory.instance) {
|
|
@@ -792,7 +1071,7 @@ __name(vcLibCheckStatusFunction, "vcLibCheckStatusFunction");
|
|
|
792
1071
|
async function checkStatusForCredential(args) {
|
|
793
1072
|
const verifyStatusListCredential = args.verifyStatusListCredential ?? true;
|
|
794
1073
|
const verifyMatchingIssuers = args.verifyMatchingIssuers ?? true;
|
|
795
|
-
const uniform =
|
|
1074
|
+
const uniform = CredentialMapper4.toUniformCredential(args.credential);
|
|
796
1075
|
if (!("credentialStatus" in uniform) || !uniform.credentialStatus) {
|
|
797
1076
|
if (args.mandatoryCredentialStatus) {
|
|
798
1077
|
const error = "No credential status object found in the Verifiable Credential and it is mandatory";
|
|
@@ -807,7 +1086,7 @@ async function checkStatusForCredential(args) {
|
|
|
807
1086
|
};
|
|
808
1087
|
}
|
|
809
1088
|
if ("credentialStatus" in uniform && uniform.credentialStatus) {
|
|
810
|
-
if (uniform.credentialStatus.type === "StatusList2021Entry") {
|
|
1089
|
+
if (uniform.credentialStatus.type === "StatusList2021Entry" || uniform.credentialStatus.type === "BitstringStatusListEntry") {
|
|
811
1090
|
return checkStatus({
|
|
812
1091
|
...args,
|
|
813
1092
|
verifyStatusListCredential,
|
|
@@ -855,22 +1134,22 @@ async function updateStatusIndexFromStatusListCredential(args, context) {
|
|
|
855
1134
|
return implementation.updateStatusListIndex(args, context);
|
|
856
1135
|
}
|
|
857
1136
|
__name(updateStatusIndexFromStatusListCredential, "updateStatusIndexFromStatusListCredential");
|
|
858
|
-
async function statusListCredentialToDetails(
|
|
859
|
-
const credential = getAssertedValue("statusListCredential",
|
|
1137
|
+
async function statusListCredentialToDetails({ correlationId, driverType, statusListCredential, bitsPerStatus }) {
|
|
1138
|
+
const credential = getAssertedValue("statusListCredential", statusListCredential);
|
|
860
1139
|
let statusListType;
|
|
861
|
-
const documentFormat =
|
|
862
|
-
if (documentFormat ===
|
|
1140
|
+
const documentFormat = CredentialMapper4.detectDocumentType(credential);
|
|
1141
|
+
if (documentFormat === DocumentFormat4.JWT) {
|
|
863
1142
|
const [header] = credential.split(".");
|
|
864
1143
|
const decodedHeader = JSON.parse(Buffer.from(header, "base64").toString());
|
|
865
1144
|
if (decodedHeader.typ === "statuslist+jwt") {
|
|
866
|
-
statusListType =
|
|
1145
|
+
statusListType = StatusListType6.OAuthStatusList;
|
|
867
1146
|
}
|
|
868
|
-
} else if (documentFormat ===
|
|
869
|
-
statusListType =
|
|
1147
|
+
} else if (documentFormat === DocumentFormat4.MSO_MDOC) {
|
|
1148
|
+
statusListType = StatusListType6.OAuthStatusList;
|
|
870
1149
|
}
|
|
871
1150
|
if (!statusListType) {
|
|
872
|
-
const uniform =
|
|
873
|
-
const type = uniform.type.find((t) => t.includes("StatusList2021") || t.includes("OAuth2StatusList"));
|
|
1151
|
+
const uniform = CredentialMapper4.toUniformCredential(credential);
|
|
1152
|
+
const type = uniform.type.find((t) => t.includes("StatusList2021") || t.includes("OAuth2StatusList") || t.includes("BitstringStatusList"));
|
|
874
1153
|
if (!type) {
|
|
875
1154
|
throw new Error("Invalid status list credential type");
|
|
876
1155
|
}
|
|
@@ -879,8 +1158,9 @@ async function statusListCredentialToDetails(args) {
|
|
|
879
1158
|
const implementation = getStatusListImplementation(statusListType);
|
|
880
1159
|
return await implementation.toStatusListDetails({
|
|
881
1160
|
statusListPayload: credential,
|
|
882
|
-
correlationId
|
|
883
|
-
driverType
|
|
1161
|
+
correlationId,
|
|
1162
|
+
driverType,
|
|
1163
|
+
bitsPerStatus
|
|
884
1164
|
});
|
|
885
1165
|
}
|
|
886
1166
|
__name(statusListCredentialToDetails, "statusListCredentialToDetails");
|
|
@@ -898,7 +1178,7 @@ async function statusList2021ToVerifiableCredential(args, context) {
|
|
|
898
1178
|
offlineWhenNoDIDRegistered: true
|
|
899
1179
|
});
|
|
900
1180
|
const proofFormat = args?.proofFormat ?? "lds";
|
|
901
|
-
assertValidProofType(
|
|
1181
|
+
assertValidProofType(StatusListType6.StatusList2021, proofFormat);
|
|
902
1182
|
const veramoProofFormat = proofFormat;
|
|
903
1183
|
const encodedList = getAssertedValue("encodedList", args.encodedList);
|
|
904
1184
|
const statusPurpose = getAssertedValue("statusPurpose", args.statusPurpose);
|
|
@@ -927,7 +1207,7 @@ async function statusList2021ToVerifiableCredential(args, context) {
|
|
|
927
1207
|
proofFormat: veramoProofFormat,
|
|
928
1208
|
fetchRemoteContexts: true
|
|
929
1209
|
});
|
|
930
|
-
return
|
|
1210
|
+
return CredentialMapper4.toWrappedVerifiableCredential(verifiableCredential).original;
|
|
931
1211
|
}
|
|
932
1212
|
__name(statusList2021ToVerifiableCredential, "statusList2021ToVerifiableCredential");
|
|
933
1213
|
export {
|