@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.cjs
CHANGED
|
@@ -61,7 +61,7 @@ var Status2021 = /* @__PURE__ */ function(Status20212) {
|
|
|
61
61
|
}({});
|
|
62
62
|
|
|
63
63
|
// src/functions.ts
|
|
64
|
-
var
|
|
64
|
+
var import_ssi_types7 = require("@sphereon/ssi-types");
|
|
65
65
|
var import_vc_status_list2 = require("@sphereon/vc-status-list");
|
|
66
66
|
|
|
67
67
|
// src/utils.ts
|
|
@@ -71,7 +71,8 @@ function getAssertedStatusListType(type) {
|
|
|
71
71
|
const assertedType = type ?? import_ssi_types.StatusListType.StatusList2021;
|
|
72
72
|
if (![
|
|
73
73
|
import_ssi_types.StatusListType.StatusList2021,
|
|
74
|
-
import_ssi_types.StatusListType.OAuthStatusList
|
|
74
|
+
import_ssi_types.StatusListType.OAuthStatusList,
|
|
75
|
+
import_ssi_types.StatusListType.BitstringStatusList
|
|
75
76
|
].includes(assertedType)) {
|
|
76
77
|
throw Error(`StatusList type ${assertedType} is not supported (yet)`);
|
|
77
78
|
}
|
|
@@ -108,8 +109,7 @@ var ValidProofTypeMap = /* @__PURE__ */ new Map([
|
|
|
108
109
|
import_ssi_types.StatusListType.StatusList2021,
|
|
109
110
|
[
|
|
110
111
|
"jwt",
|
|
111
|
-
"lds"
|
|
112
|
-
"EthereumEip712Signature2021"
|
|
112
|
+
"lds"
|
|
113
113
|
]
|
|
114
114
|
],
|
|
115
115
|
[
|
|
@@ -118,6 +118,12 @@ var ValidProofTypeMap = /* @__PURE__ */ new Map([
|
|
|
118
118
|
"jwt",
|
|
119
119
|
"cbor"
|
|
120
120
|
]
|
|
121
|
+
],
|
|
122
|
+
[
|
|
123
|
+
import_ssi_types.StatusListType.BitstringStatusList,
|
|
124
|
+
[
|
|
125
|
+
"lds"
|
|
126
|
+
]
|
|
121
127
|
]
|
|
122
128
|
]);
|
|
123
129
|
function assertValidProofType(type, proofFormat) {
|
|
@@ -168,6 +174,26 @@ function determineProofFormat(credential) {
|
|
|
168
174
|
}
|
|
169
175
|
}
|
|
170
176
|
__name(determineProofFormat, "determineProofFormat");
|
|
177
|
+
function ensureDate(value) {
|
|
178
|
+
if (value === void 0 || value === null) {
|
|
179
|
+
return void 0;
|
|
180
|
+
}
|
|
181
|
+
if (value instanceof Date) {
|
|
182
|
+
return value;
|
|
183
|
+
}
|
|
184
|
+
if (typeof value === "string") {
|
|
185
|
+
if (value.trim() === "") {
|
|
186
|
+
return void 0;
|
|
187
|
+
}
|
|
188
|
+
const date = new Date(value);
|
|
189
|
+
if (isNaN(date.getTime())) {
|
|
190
|
+
return void 0;
|
|
191
|
+
}
|
|
192
|
+
return date;
|
|
193
|
+
}
|
|
194
|
+
return void 0;
|
|
195
|
+
}
|
|
196
|
+
__name(ensureDate, "ensureDate");
|
|
171
197
|
|
|
172
198
|
// src/impl/StatusList2021.ts
|
|
173
199
|
var import_ssi_types2 = require("@sphereon/ssi-types");
|
|
@@ -260,7 +286,7 @@ var StatusList2021Implementation = class {
|
|
|
260
286
|
encodedList: args.encodedList
|
|
261
287
|
});
|
|
262
288
|
const index = typeof args.statusListIndex === "number" ? args.statusListIndex : parseInt(args.statusListIndex);
|
|
263
|
-
statusList.setStatus(index, args.value);
|
|
289
|
+
statusList.setStatus(index, args.value !== 0);
|
|
264
290
|
const newEncodedList = await statusList.encode();
|
|
265
291
|
const credential = await this.createVerifiableCredential({
|
|
266
292
|
id,
|
|
@@ -618,7 +644,8 @@ var OAuthStatusListImplementation = class {
|
|
|
618
644
|
}
|
|
619
645
|
const proofFormat = args?.proofFormat ?? DEFAULT_PROOF_FORMAT2;
|
|
620
646
|
const { issuer, id, oauthStatusList, keyRef } = args;
|
|
621
|
-
const { bitsPerStatus
|
|
647
|
+
const { bitsPerStatus } = oauthStatusList;
|
|
648
|
+
const expiresAt = ensureDate(oauthStatusList.expiresAt);
|
|
622
649
|
const length = args.length ?? DEFAULT_LIST_LENGTH2;
|
|
623
650
|
const issuerString = typeof issuer === "string" ? issuer : issuer.id;
|
|
624
651
|
const correlationId = getAssertedValue("correlationId", args.correlationId);
|
|
@@ -641,7 +668,8 @@ var OAuthStatusListImplementation = class {
|
|
|
641
668
|
};
|
|
642
669
|
}
|
|
643
670
|
async updateStatusListIndex(args, context) {
|
|
644
|
-
const { statusListCredential, value,
|
|
671
|
+
const { statusListCredential, value, keyRef } = args;
|
|
672
|
+
const expiresAt = ensureDate(args.expiresAt);
|
|
645
673
|
if (typeof statusListCredential !== "string") {
|
|
646
674
|
return Promise.reject("statusListCredential in neither JWT nor CWT");
|
|
647
675
|
}
|
|
@@ -652,6 +680,9 @@ var OAuthStatusListImplementation = class {
|
|
|
652
680
|
if (index < 0 || index >= statusList.statusList.length) {
|
|
653
681
|
throw new Error("Status list index out of bounds");
|
|
654
682
|
}
|
|
683
|
+
if (typeof value !== "number") {
|
|
684
|
+
throw new Error("Status list values should be of type number");
|
|
685
|
+
}
|
|
655
686
|
statusList.setStatus(index, value);
|
|
656
687
|
const { statusListCredential: signedCredential, encodedList } = await this.createSignedStatusList(proofFormat, context, statusList, issuer, id, expiresAt, keyRef);
|
|
657
688
|
return {
|
|
@@ -674,12 +705,13 @@ var OAuthStatusListImplementation = class {
|
|
|
674
705
|
throw new Error("OAuthStatusList options are required for type OAuthStatusList");
|
|
675
706
|
}
|
|
676
707
|
const { proofFormat, oauthStatusList, keyRef } = args;
|
|
677
|
-
const { bitsPerStatus
|
|
708
|
+
const { bitsPerStatus } = oauthStatusList;
|
|
709
|
+
const expiresAt = ensureDate(oauthStatusList.expiresAt);
|
|
678
710
|
const { issuer, id } = getAssertedValues(args);
|
|
679
711
|
const issuerString = typeof issuer === "string" ? issuer : issuer.id;
|
|
680
712
|
const listToUpdate = import_jwt_status_list3.StatusList.decompressStatusList(args.encodedList, bitsPerStatus ?? DEFAULT_BITS_PER_STATUS);
|
|
681
713
|
const index = typeof args.statusListIndex === "number" ? args.statusListIndex : parseInt(args.statusListIndex);
|
|
682
|
-
listToUpdate.setStatus(index, args.value
|
|
714
|
+
listToUpdate.setStatus(index, args.value);
|
|
683
715
|
const { statusListCredential, encodedList } = await this.createSignedStatusList(proofFormat ?? DEFAULT_PROOF_FORMAT2, context, listToUpdate, issuerString, id, expiresAt, keyRef);
|
|
684
716
|
return {
|
|
685
717
|
encodedList,
|
|
@@ -708,7 +740,7 @@ var OAuthStatusListImplementation = class {
|
|
|
708
740
|
const { statusList } = proofFormat === "jwt" ? decodeStatusListJWT(statusListCredential) : decodeStatusListCWT(statusListCredential);
|
|
709
741
|
const index = typeof statusListIndex === "number" ? statusListIndex : parseInt(statusListIndex);
|
|
710
742
|
if (index < 0 || index >= statusList.statusList.length) {
|
|
711
|
-
throw new Error(
|
|
743
|
+
throw new Error(`Status list index out of bounds, has ${statusList.statusList.length} items, requested ${index}`);
|
|
712
744
|
}
|
|
713
745
|
return statusList.getStatus(index);
|
|
714
746
|
}
|
|
@@ -755,7 +787,253 @@ var OAuthStatusListImplementation = class {
|
|
|
755
787
|
};
|
|
756
788
|
|
|
757
789
|
// src/impl/StatusListFactory.ts
|
|
790
|
+
var import_ssi_types6 = require("@sphereon/ssi-types");
|
|
791
|
+
|
|
792
|
+
// src/impl/BitstringStatusListImplementation.ts
|
|
758
793
|
var import_ssi_types5 = require("@sphereon/ssi-types");
|
|
794
|
+
var import_vc_bitstring_status_lists = require("@4sure-tech/vc-bitstring-status-lists");
|
|
795
|
+
var DEFAULT_LIST_LENGTH3 = 131072;
|
|
796
|
+
var DEFAULT_PROOF_FORMAT3 = "lds";
|
|
797
|
+
var DEFAULT_STATUS_PURPOSE = "revocation";
|
|
798
|
+
var BitstringStatusListImplementation = class {
|
|
799
|
+
static {
|
|
800
|
+
__name(this, "BitstringStatusListImplementation");
|
|
801
|
+
}
|
|
802
|
+
async createNewStatusList(args, context) {
|
|
803
|
+
if (!args.bitstringStatusList) {
|
|
804
|
+
throw new Error("BitstringStatusList options are required for type BitstringStatusList");
|
|
805
|
+
}
|
|
806
|
+
const length = args?.length ?? DEFAULT_LIST_LENGTH3;
|
|
807
|
+
const proofFormat = args?.proofFormat ?? DEFAULT_PROOF_FORMAT3;
|
|
808
|
+
assertValidProofType(import_ssi_types5.StatusListType.BitstringStatusList, proofFormat);
|
|
809
|
+
const veramoProofFormat = proofFormat;
|
|
810
|
+
const { issuer, id } = args;
|
|
811
|
+
const correlationId = getAssertedValue("correlationId", args.correlationId);
|
|
812
|
+
const { statusPurpose, bitsPerStatus, validFrom, validUntil, ttl } = args.bitstringStatusList;
|
|
813
|
+
const statusListCredential = await this.createVerifiableCredential({
|
|
814
|
+
...args,
|
|
815
|
+
proofFormat: veramoProofFormat,
|
|
816
|
+
statusPurpose: statusPurpose ?? DEFAULT_STATUS_PURPOSE,
|
|
817
|
+
validFrom: ensureDate(validFrom),
|
|
818
|
+
validUntil: ensureDate(validUntil),
|
|
819
|
+
ttl
|
|
820
|
+
}, context);
|
|
821
|
+
return {
|
|
822
|
+
encodedList: statusListCredential.credentialSubject.encodedList,
|
|
823
|
+
statusListCredential,
|
|
824
|
+
bitstringStatusList: {
|
|
825
|
+
statusPurpose: statusPurpose ?? DEFAULT_STATUS_PURPOSE,
|
|
826
|
+
...statusListCredential.validFrom && {
|
|
827
|
+
validFrom: new Date(statusListCredential.validFrom)
|
|
828
|
+
},
|
|
829
|
+
...statusListCredential.validUntil && {
|
|
830
|
+
validUntil: new Date(statusListCredential.validUntil)
|
|
831
|
+
},
|
|
832
|
+
ttl,
|
|
833
|
+
bitsPerStatus
|
|
834
|
+
},
|
|
835
|
+
length,
|
|
836
|
+
type: import_ssi_types5.StatusListType.BitstringStatusList,
|
|
837
|
+
proofFormat,
|
|
838
|
+
id,
|
|
839
|
+
correlationId,
|
|
840
|
+
issuer,
|
|
841
|
+
statuslistContentType: this.buildContentType(proofFormat)
|
|
842
|
+
};
|
|
843
|
+
}
|
|
844
|
+
async updateStatusListIndex(args, context) {
|
|
845
|
+
if (!args.bitsPerStatus || args.bitsPerStatus < 1) {
|
|
846
|
+
return Promise.reject("bitsPerStatus must be set for bitstring status lists and must be 1 or higher. (updateStatusListIndex)");
|
|
847
|
+
}
|
|
848
|
+
const credential = args.statusListCredential;
|
|
849
|
+
const uniform = import_ssi_types5.CredentialMapper.toUniformCredential(credential);
|
|
850
|
+
const { issuer, credentialSubject } = uniform;
|
|
851
|
+
const id = getAssertedValue("id", uniform.id);
|
|
852
|
+
const origEncodedList = getAssertedProperty("encodedList", credentialSubject);
|
|
853
|
+
const index = typeof args.statusListIndex === "number" ? args.statusListIndex : parseInt(args.statusListIndex);
|
|
854
|
+
const statusList = await import_vc_bitstring_status_lists.BitstreamStatusList.decode({
|
|
855
|
+
encodedList: origEncodedList,
|
|
856
|
+
statusSize: args.bitsPerStatus
|
|
857
|
+
});
|
|
858
|
+
statusList.setStatus(index, args.value);
|
|
859
|
+
const proofFormat = import_ssi_types5.CredentialMapper.detectDocumentType(credential) === import_ssi_types5.DocumentFormat.JWT ? "jwt" : "lds";
|
|
860
|
+
const credSubject = Array.isArray(credentialSubject) ? credentialSubject[0] : credentialSubject;
|
|
861
|
+
const statusPurpose = getAssertedProperty("statusPurpose", credSubject);
|
|
862
|
+
const validFrom = uniform.validFrom ? new Date(uniform.validFrom) : void 0;
|
|
863
|
+
const validUntil = uniform.validUntil ? new Date(uniform.validUntil) : void 0;
|
|
864
|
+
const ttl = credSubject.ttl;
|
|
865
|
+
const updatedCredential = await this.createVerifiableCredential({
|
|
866
|
+
...args,
|
|
867
|
+
id,
|
|
868
|
+
issuer,
|
|
869
|
+
statusList,
|
|
870
|
+
proofFormat,
|
|
871
|
+
statusPurpose,
|
|
872
|
+
ttl,
|
|
873
|
+
validFrom,
|
|
874
|
+
validUntil
|
|
875
|
+
}, context);
|
|
876
|
+
return {
|
|
877
|
+
statusListCredential: updatedCredential,
|
|
878
|
+
encodedList: updatedCredential.credentialSubject.encodedList,
|
|
879
|
+
bitstringStatusList: {
|
|
880
|
+
statusPurpose,
|
|
881
|
+
...updatedCredential.validFrom && {
|
|
882
|
+
validFrom: new Date(updatedCredential.validFrom)
|
|
883
|
+
},
|
|
884
|
+
...updatedCredential.validUntil && {
|
|
885
|
+
validUntil: new Date(updatedCredential.validUntil)
|
|
886
|
+
},
|
|
887
|
+
bitsPerStatus: args.bitsPerStatus,
|
|
888
|
+
ttl
|
|
889
|
+
},
|
|
890
|
+
length: statusList.getLength(),
|
|
891
|
+
type: import_ssi_types5.StatusListType.BitstringStatusList,
|
|
892
|
+
proofFormat,
|
|
893
|
+
id,
|
|
894
|
+
issuer,
|
|
895
|
+
statuslistContentType: this.buildContentType(proofFormat)
|
|
896
|
+
};
|
|
897
|
+
}
|
|
898
|
+
async updateStatusListFromEncodedList(args, context) {
|
|
899
|
+
if (!args.bitstringStatusList) {
|
|
900
|
+
throw new Error("bitstringStatusList options required for type BitstringStatusList");
|
|
901
|
+
}
|
|
902
|
+
if (args.bitstringStatusList.bitsPerStatus < 1) {
|
|
903
|
+
return Promise.reject("bitsPerStatus must be set for bitstring status lists and must be 1 or higher. (updateStatusListFromEncodedList)");
|
|
904
|
+
}
|
|
905
|
+
const { statusPurpose, bitsPerStatus, ttl, validFrom, validUntil } = args.bitstringStatusList;
|
|
906
|
+
const proofFormat = args?.proofFormat ?? DEFAULT_PROOF_FORMAT3;
|
|
907
|
+
assertValidProofType(import_ssi_types5.StatusListType.BitstringStatusList, proofFormat);
|
|
908
|
+
const veramoProofFormat = proofFormat;
|
|
909
|
+
const { issuer, id } = getAssertedValues(args);
|
|
910
|
+
const statusList = await import_vc_bitstring_status_lists.BitstreamStatusList.decode({
|
|
911
|
+
encodedList: args.encodedList,
|
|
912
|
+
statusSize: bitsPerStatus
|
|
913
|
+
});
|
|
914
|
+
const index = typeof args.statusListIndex === "number" ? args.statusListIndex : parseInt(args.statusListIndex);
|
|
915
|
+
statusList.setStatus(index, args.value);
|
|
916
|
+
const credential = await this.createVerifiableCredential({
|
|
917
|
+
id,
|
|
918
|
+
issuer,
|
|
919
|
+
statusList,
|
|
920
|
+
proofFormat: veramoProofFormat,
|
|
921
|
+
keyRef: args.keyRef,
|
|
922
|
+
statusPurpose,
|
|
923
|
+
validFrom: ensureDate(validFrom),
|
|
924
|
+
validUntil: ensureDate(validUntil),
|
|
925
|
+
ttl
|
|
926
|
+
}, context);
|
|
927
|
+
return {
|
|
928
|
+
type: import_ssi_types5.StatusListType.BitstringStatusList,
|
|
929
|
+
statusListCredential: credential,
|
|
930
|
+
encodedList: credential.credentialSubject.encodedList,
|
|
931
|
+
bitstringStatusList: {
|
|
932
|
+
statusPurpose,
|
|
933
|
+
bitsPerStatus,
|
|
934
|
+
...credential.validFrom && {
|
|
935
|
+
validFrom: new Date(credential.validFrom)
|
|
936
|
+
},
|
|
937
|
+
...credential.validUntil && {
|
|
938
|
+
validUntil: new Date(credential.validUntil)
|
|
939
|
+
},
|
|
940
|
+
ttl
|
|
941
|
+
},
|
|
942
|
+
length: statusList.getLength(),
|
|
943
|
+
proofFormat: args.proofFormat ?? "lds",
|
|
944
|
+
id,
|
|
945
|
+
issuer,
|
|
946
|
+
statuslistContentType: this.buildContentType(proofFormat)
|
|
947
|
+
};
|
|
948
|
+
}
|
|
949
|
+
async checkStatusIndex(args) {
|
|
950
|
+
if (!args.bitsPerStatus || args.bitsPerStatus < 1) {
|
|
951
|
+
return Promise.reject("bitsPerStatus must be set for bitstring status lists and must be 1 or higher. (checkStatusIndex)");
|
|
952
|
+
}
|
|
953
|
+
const uniform = import_ssi_types5.CredentialMapper.toUniformCredential(args.statusListCredential);
|
|
954
|
+
const { credentialSubject } = uniform;
|
|
955
|
+
const encodedList = getAssertedProperty("encodedList", credentialSubject);
|
|
956
|
+
const statusSize = args.bitsPerStatus;
|
|
957
|
+
const statusList = await import_vc_bitstring_status_lists.BitstreamStatusList.decode({
|
|
958
|
+
encodedList,
|
|
959
|
+
statusSize
|
|
960
|
+
});
|
|
961
|
+
const numIndex = typeof args.statusListIndex === "number" ? args.statusListIndex : parseInt(args.statusListIndex);
|
|
962
|
+
if (statusList.getLength() <= numIndex) {
|
|
963
|
+
throw new Error(`Status list index out of bounds, has ${statusList.getLength()} entries, requested ${numIndex}`);
|
|
964
|
+
}
|
|
965
|
+
return statusList.getStatus(numIndex);
|
|
966
|
+
}
|
|
967
|
+
async toStatusListDetails(args) {
|
|
968
|
+
const { statusListPayload, bitsPerStatus } = args;
|
|
969
|
+
if (!bitsPerStatus || bitsPerStatus < 1) {
|
|
970
|
+
return Promise.reject("bitsPerStatus must be set for bitstring status lists and must be 1 or higher. (toStatusListDetails)");
|
|
971
|
+
}
|
|
972
|
+
const uniform = import_ssi_types5.CredentialMapper.toUniformCredential(statusListPayload);
|
|
973
|
+
const { issuer, credentialSubject } = uniform;
|
|
974
|
+
const id = getAssertedValue("id", uniform.id);
|
|
975
|
+
const encodedList = getAssertedProperty("encodedList", credentialSubject);
|
|
976
|
+
const proofFormat = import_ssi_types5.CredentialMapper.detectDocumentType(statusListPayload) === import_ssi_types5.DocumentFormat.JWT ? "jwt" : "lds";
|
|
977
|
+
const credSubject = Array.isArray(credentialSubject) ? credentialSubject[0] : credentialSubject;
|
|
978
|
+
const statusPurpose = getAssertedProperty("statusPurpose", credSubject);
|
|
979
|
+
const validFrom = uniform.validFrom ? new Date(uniform.validFrom) : void 0;
|
|
980
|
+
const validUntil = uniform.validUntil ? new Date(uniform.validUntil) : void 0;
|
|
981
|
+
const ttl = credSubject.ttl;
|
|
982
|
+
const statuslistLength = import_vc_bitstring_status_lists.BitstreamStatusList.getStatusListLength(encodedList, bitsPerStatus);
|
|
983
|
+
return {
|
|
984
|
+
id,
|
|
985
|
+
encodedList,
|
|
986
|
+
issuer,
|
|
987
|
+
type: import_ssi_types5.StatusListType.BitstringStatusList,
|
|
988
|
+
proofFormat,
|
|
989
|
+
length: statuslistLength,
|
|
990
|
+
statusListCredential: statusListPayload,
|
|
991
|
+
statuslistContentType: this.buildContentType(proofFormat),
|
|
992
|
+
bitstringStatusList: {
|
|
993
|
+
statusPurpose,
|
|
994
|
+
bitsPerStatus,
|
|
995
|
+
validFrom,
|
|
996
|
+
validUntil,
|
|
997
|
+
ttl
|
|
998
|
+
},
|
|
999
|
+
...args.correlationId && {
|
|
1000
|
+
correlationId: args.correlationId
|
|
1001
|
+
},
|
|
1002
|
+
...args.driverType && {
|
|
1003
|
+
driverType: args.driverType
|
|
1004
|
+
}
|
|
1005
|
+
};
|
|
1006
|
+
}
|
|
1007
|
+
async createVerifiableCredential(args, context) {
|
|
1008
|
+
const identifier = await context.agent.identifierManagedGet({
|
|
1009
|
+
identifier: typeof args.issuer === "string" ? args.issuer : args.issuer.id,
|
|
1010
|
+
vmRelationship: "assertionMethod",
|
|
1011
|
+
offlineWhenNoDIDRegistered: true
|
|
1012
|
+
});
|
|
1013
|
+
const unsignedCredential = await (0, import_vc_bitstring_status_lists.createStatusListCredential)(args);
|
|
1014
|
+
const verifiableCredential = await context.agent.createVerifiableCredential({
|
|
1015
|
+
credential: unsignedCredential,
|
|
1016
|
+
keyRef: args.keyRef ?? identifier.kmsKeyRef,
|
|
1017
|
+
proofFormat: args.proofFormat,
|
|
1018
|
+
fetchRemoteContexts: true
|
|
1019
|
+
});
|
|
1020
|
+
return import_ssi_types5.CredentialMapper.toWrappedVerifiableCredential(verifiableCredential).original;
|
|
1021
|
+
}
|
|
1022
|
+
buildContentType(proofFormat) {
|
|
1023
|
+
switch (proofFormat) {
|
|
1024
|
+
case "jwt":
|
|
1025
|
+
return `application/statuslist+jwt`;
|
|
1026
|
+
case "cbor":
|
|
1027
|
+
return `application/statuslist+cwt`;
|
|
1028
|
+
case "lds":
|
|
1029
|
+
return "application/statuslist+ld+json";
|
|
1030
|
+
default:
|
|
1031
|
+
throw Error(`Unsupported content type '${proofFormat}' for status lists`);
|
|
1032
|
+
}
|
|
1033
|
+
}
|
|
1034
|
+
};
|
|
1035
|
+
|
|
1036
|
+
// src/impl/StatusListFactory.ts
|
|
759
1037
|
var StatusListFactory = class _StatusListFactory {
|
|
760
1038
|
static {
|
|
761
1039
|
__name(this, "StatusListFactory");
|
|
@@ -764,8 +1042,9 @@ var StatusListFactory = class _StatusListFactory {
|
|
|
764
1042
|
implementations;
|
|
765
1043
|
constructor() {
|
|
766
1044
|
this.implementations = /* @__PURE__ */ new Map();
|
|
767
|
-
this.implementations.set(
|
|
768
|
-
this.implementations.set(
|
|
1045
|
+
this.implementations.set(import_ssi_types6.StatusListType.StatusList2021, new StatusList2021Implementation());
|
|
1046
|
+
this.implementations.set(import_ssi_types6.StatusListType.OAuthStatusList, new OAuthStatusListImplementation());
|
|
1047
|
+
this.implementations.set(import_ssi_types6.StatusListType.BitstringStatusList, new BitstringStatusListImplementation());
|
|
769
1048
|
}
|
|
770
1049
|
static getInstance() {
|
|
771
1050
|
if (!_StatusListFactory.instance) {
|
|
@@ -838,7 +1117,7 @@ __name(vcLibCheckStatusFunction, "vcLibCheckStatusFunction");
|
|
|
838
1117
|
async function checkStatusForCredential(args) {
|
|
839
1118
|
const verifyStatusListCredential = args.verifyStatusListCredential ?? true;
|
|
840
1119
|
const verifyMatchingIssuers = args.verifyMatchingIssuers ?? true;
|
|
841
|
-
const uniform =
|
|
1120
|
+
const uniform = import_ssi_types7.CredentialMapper.toUniformCredential(args.credential);
|
|
842
1121
|
if (!("credentialStatus" in uniform) || !uniform.credentialStatus) {
|
|
843
1122
|
if (args.mandatoryCredentialStatus) {
|
|
844
1123
|
const error = "No credential status object found in the Verifiable Credential and it is mandatory";
|
|
@@ -853,7 +1132,7 @@ async function checkStatusForCredential(args) {
|
|
|
853
1132
|
};
|
|
854
1133
|
}
|
|
855
1134
|
if ("credentialStatus" in uniform && uniform.credentialStatus) {
|
|
856
|
-
if (uniform.credentialStatus.type === "StatusList2021Entry") {
|
|
1135
|
+
if (uniform.credentialStatus.type === "StatusList2021Entry" || uniform.credentialStatus.type === "BitstringStatusListEntry") {
|
|
857
1136
|
return (0, import_vc_status_list2.checkStatus)({
|
|
858
1137
|
...args,
|
|
859
1138
|
verifyStatusListCredential,
|
|
@@ -901,22 +1180,22 @@ async function updateStatusIndexFromStatusListCredential(args, context) {
|
|
|
901
1180
|
return implementation.updateStatusListIndex(args, context);
|
|
902
1181
|
}
|
|
903
1182
|
__name(updateStatusIndexFromStatusListCredential, "updateStatusIndexFromStatusListCredential");
|
|
904
|
-
async function statusListCredentialToDetails(
|
|
905
|
-
const credential = getAssertedValue("statusListCredential",
|
|
1183
|
+
async function statusListCredentialToDetails({ correlationId, driverType, statusListCredential, bitsPerStatus }) {
|
|
1184
|
+
const credential = getAssertedValue("statusListCredential", statusListCredential);
|
|
906
1185
|
let statusListType;
|
|
907
|
-
const documentFormat =
|
|
908
|
-
if (documentFormat ===
|
|
1186
|
+
const documentFormat = import_ssi_types7.CredentialMapper.detectDocumentType(credential);
|
|
1187
|
+
if (documentFormat === import_ssi_types7.DocumentFormat.JWT) {
|
|
909
1188
|
const [header] = credential.split(".");
|
|
910
1189
|
const decodedHeader = JSON.parse(Buffer.from(header, "base64").toString());
|
|
911
1190
|
if (decodedHeader.typ === "statuslist+jwt") {
|
|
912
|
-
statusListType =
|
|
1191
|
+
statusListType = import_ssi_types7.StatusListType.OAuthStatusList;
|
|
913
1192
|
}
|
|
914
|
-
} else if (documentFormat ===
|
|
915
|
-
statusListType =
|
|
1193
|
+
} else if (documentFormat === import_ssi_types7.DocumentFormat.MSO_MDOC) {
|
|
1194
|
+
statusListType = import_ssi_types7.StatusListType.OAuthStatusList;
|
|
916
1195
|
}
|
|
917
1196
|
if (!statusListType) {
|
|
918
|
-
const uniform =
|
|
919
|
-
const type = uniform.type.find((t) => t.includes("StatusList2021") || t.includes("OAuth2StatusList"));
|
|
1197
|
+
const uniform = import_ssi_types7.CredentialMapper.toUniformCredential(credential);
|
|
1198
|
+
const type = uniform.type.find((t) => t.includes("StatusList2021") || t.includes("OAuth2StatusList") || t.includes("BitstringStatusList"));
|
|
920
1199
|
if (!type) {
|
|
921
1200
|
throw new Error("Invalid status list credential type");
|
|
922
1201
|
}
|
|
@@ -925,8 +1204,9 @@ async function statusListCredentialToDetails(args) {
|
|
|
925
1204
|
const implementation = getStatusListImplementation(statusListType);
|
|
926
1205
|
return await implementation.toStatusListDetails({
|
|
927
1206
|
statusListPayload: credential,
|
|
928
|
-
correlationId
|
|
929
|
-
driverType
|
|
1207
|
+
correlationId,
|
|
1208
|
+
driverType,
|
|
1209
|
+
bitsPerStatus
|
|
930
1210
|
});
|
|
931
1211
|
}
|
|
932
1212
|
__name(statusListCredentialToDetails, "statusListCredentialToDetails");
|
|
@@ -944,7 +1224,7 @@ async function statusList2021ToVerifiableCredential(args, context) {
|
|
|
944
1224
|
offlineWhenNoDIDRegistered: true
|
|
945
1225
|
});
|
|
946
1226
|
const proofFormat = args?.proofFormat ?? "lds";
|
|
947
|
-
assertValidProofType(
|
|
1227
|
+
assertValidProofType(import_ssi_types7.StatusListType.StatusList2021, proofFormat);
|
|
948
1228
|
const veramoProofFormat = proofFormat;
|
|
949
1229
|
const encodedList = getAssertedValue("encodedList", args.encodedList);
|
|
950
1230
|
const statusPurpose = getAssertedValue("statusPurpose", args.statusPurpose);
|
|
@@ -973,7 +1253,7 @@ async function statusList2021ToVerifiableCredential(args, context) {
|
|
|
973
1253
|
proofFormat: veramoProofFormat,
|
|
974
1254
|
fetchRemoteContexts: true
|
|
975
1255
|
});
|
|
976
|
-
return
|
|
1256
|
+
return import_ssi_types7.CredentialMapper.toWrappedVerifiableCredential(verifiableCredential).original;
|
|
977
1257
|
}
|
|
978
1258
|
__name(statusList2021ToVerifiableCredential, "statusList2021ToVerifiableCredential");
|
|
979
1259
|
//# sourceMappingURL=index.cjs.map
|