@sphereon/ssi-sdk.vc-status-list 0.34.1-feature.SSISDK.17.bitstring.sl.9 → 0.34.1-feature.disable.test.8
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 +29 -309
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +8 -49
- package/dist/index.d.ts +8 -49
- package/dist/index.js +30 -310
- package/dist/index.js.map +1 -1
- package/package.json +7 -8
- package/src/functions.ts +10 -19
- package/src/impl/IStatusList.ts +2 -3
- package/src/impl/OAuthStatusList.ts +11 -17
- package/src/impl/StatusList2021.ts +3 -3
- package/src/impl/StatusListFactory.ts +0 -2
- package/src/types/index.ts +4 -48
- package/src/utils.ts +2 -35
- package/src/impl/BitstringStatusListImplementation.ts +0 -301
- package/src/types/BitstringStatusList.ts +0 -4
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_types6 = require("@sphereon/ssi-types");
|
|
65
65
|
var import_vc_status_list2 = require("@sphereon/vc-status-list");
|
|
66
66
|
|
|
67
67
|
// src/utils.ts
|
|
@@ -71,8 +71,7 @@ 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
|
|
75
|
-
import_ssi_types.StatusListType.BitstringStatusList
|
|
74
|
+
import_ssi_types.StatusListType.OAuthStatusList
|
|
76
75
|
].includes(assertedType)) {
|
|
77
76
|
throw Error(`StatusList type ${assertedType} is not supported (yet)`);
|
|
78
77
|
}
|
|
@@ -109,7 +108,8 @@ var ValidProofTypeMap = /* @__PURE__ */ new Map([
|
|
|
109
108
|
import_ssi_types.StatusListType.StatusList2021,
|
|
110
109
|
[
|
|
111
110
|
"jwt",
|
|
112
|
-
"lds"
|
|
111
|
+
"lds",
|
|
112
|
+
"EthereumEip712Signature2021"
|
|
113
113
|
]
|
|
114
114
|
],
|
|
115
115
|
[
|
|
@@ -118,12 +118,6 @@ 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
|
-
]
|
|
127
121
|
]
|
|
128
122
|
]);
|
|
129
123
|
function assertValidProofType(type, proofFormat) {
|
|
@@ -174,26 +168,6 @@ function determineProofFormat(credential) {
|
|
|
174
168
|
}
|
|
175
169
|
}
|
|
176
170
|
__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");
|
|
197
171
|
|
|
198
172
|
// src/impl/StatusList2021.ts
|
|
199
173
|
var import_ssi_types2 = require("@sphereon/ssi-types");
|
|
@@ -286,7 +260,7 @@ var StatusList2021Implementation = class {
|
|
|
286
260
|
encodedList: args.encodedList
|
|
287
261
|
});
|
|
288
262
|
const index = typeof args.statusListIndex === "number" ? args.statusListIndex : parseInt(args.statusListIndex);
|
|
289
|
-
statusList.setStatus(index, args.value
|
|
263
|
+
statusList.setStatus(index, args.value);
|
|
290
264
|
const newEncodedList = await statusList.encode();
|
|
291
265
|
const credential = await this.createVerifiableCredential({
|
|
292
266
|
id,
|
|
@@ -643,9 +617,8 @@ var OAuthStatusListImplementation = class {
|
|
|
643
617
|
throw new Error("OAuthStatusList options are required for type OAuthStatusList");
|
|
644
618
|
}
|
|
645
619
|
const proofFormat = args?.proofFormat ?? DEFAULT_PROOF_FORMAT2;
|
|
646
|
-
const { issuer, id, oauthStatusList
|
|
647
|
-
const { bitsPerStatus } =
|
|
648
|
-
const expiresAt = ensureDate(oauthStatusList1.expiresAt);
|
|
620
|
+
const { issuer, id, oauthStatusList, keyRef } = args;
|
|
621
|
+
const { bitsPerStatus, expiresAt } = oauthStatusList;
|
|
649
622
|
const length = args.length ?? DEFAULT_LIST_LENGTH2;
|
|
650
623
|
const issuerString = typeof issuer === "string" ? issuer : issuer.id;
|
|
651
624
|
const correlationId = getAssertedValue("correlationId", args.correlationId);
|
|
@@ -668,8 +641,7 @@ var OAuthStatusListImplementation = class {
|
|
|
668
641
|
};
|
|
669
642
|
}
|
|
670
643
|
async updateStatusListIndex(args, context) {
|
|
671
|
-
const { statusListCredential, value, keyRef } = args;
|
|
672
|
-
const expiresAt = ensureDate(oauthStatusList.expiresAt);
|
|
644
|
+
const { statusListCredential, value, expiresAt, keyRef } = args;
|
|
673
645
|
if (typeof statusListCredential !== "string") {
|
|
674
646
|
return Promise.reject("statusListCredential in neither JWT nor CWT");
|
|
675
647
|
}
|
|
@@ -680,9 +652,6 @@ var OAuthStatusListImplementation = class {
|
|
|
680
652
|
if (index < 0 || index >= statusList.statusList.length) {
|
|
681
653
|
throw new Error("Status list index out of bounds");
|
|
682
654
|
}
|
|
683
|
-
if (typeof value !== "number") {
|
|
684
|
-
throw new Error("Status list values should be of type number");
|
|
685
|
-
}
|
|
686
655
|
statusList.setStatus(index, value);
|
|
687
656
|
const { statusListCredential: signedCredential, encodedList } = await this.createSignedStatusList(proofFormat, context, statusList, issuer, id, expiresAt, keyRef);
|
|
688
657
|
return {
|
|
@@ -704,14 +673,13 @@ var OAuthStatusListImplementation = class {
|
|
|
704
673
|
if (!args.oauthStatusList) {
|
|
705
674
|
throw new Error("OAuthStatusList options are required for type OAuthStatusList");
|
|
706
675
|
}
|
|
707
|
-
const { proofFormat, oauthStatusList
|
|
708
|
-
const { bitsPerStatus } =
|
|
709
|
-
const expiresAt = ensureDate(oauthStatusList1.expiresAt);
|
|
676
|
+
const { proofFormat, oauthStatusList, keyRef } = args;
|
|
677
|
+
const { bitsPerStatus, expiresAt } = oauthStatusList;
|
|
710
678
|
const { issuer, id } = getAssertedValues(args);
|
|
711
679
|
const issuerString = typeof issuer === "string" ? issuer : issuer.id;
|
|
712
680
|
const listToUpdate = import_jwt_status_list3.StatusList.decompressStatusList(args.encodedList, bitsPerStatus ?? DEFAULT_BITS_PER_STATUS);
|
|
713
681
|
const index = typeof args.statusListIndex === "number" ? args.statusListIndex : parseInt(args.statusListIndex);
|
|
714
|
-
listToUpdate.setStatus(index, args.value);
|
|
682
|
+
listToUpdate.setStatus(index, args.value ? 1 : 0);
|
|
715
683
|
const { statusListCredential, encodedList } = await this.createSignedStatusList(proofFormat ?? DEFAULT_PROOF_FORMAT2, context, listToUpdate, issuerString, id, expiresAt, keyRef);
|
|
716
684
|
return {
|
|
717
685
|
encodedList,
|
|
@@ -740,7 +708,7 @@ var OAuthStatusListImplementation = class {
|
|
|
740
708
|
const { statusList } = proofFormat === "jwt" ? decodeStatusListJWT(statusListCredential) : decodeStatusListCWT(statusListCredential);
|
|
741
709
|
const index = typeof statusListIndex === "number" ? statusListIndex : parseInt(statusListIndex);
|
|
742
710
|
if (index < 0 || index >= statusList.statusList.length) {
|
|
743
|
-
throw new Error(
|
|
711
|
+
throw new Error("Status list index out of bounds");
|
|
744
712
|
}
|
|
745
713
|
return statusList.getStatus(index);
|
|
746
714
|
}
|
|
@@ -787,253 +755,7 @@ var OAuthStatusListImplementation = class {
|
|
|
787
755
|
};
|
|
788
756
|
|
|
789
757
|
// src/impl/StatusListFactory.ts
|
|
790
|
-
var import_ssi_types6 = require("@sphereon/ssi-types");
|
|
791
|
-
|
|
792
|
-
// src/impl/BitstringStatusListImplementation.ts
|
|
793
758
|
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
|
|
1037
759
|
var StatusListFactory = class _StatusListFactory {
|
|
1038
760
|
static {
|
|
1039
761
|
__name(this, "StatusListFactory");
|
|
@@ -1042,9 +764,8 @@ var StatusListFactory = class _StatusListFactory {
|
|
|
1042
764
|
implementations;
|
|
1043
765
|
constructor() {
|
|
1044
766
|
this.implementations = /* @__PURE__ */ new Map();
|
|
1045
|
-
this.implementations.set(
|
|
1046
|
-
this.implementations.set(
|
|
1047
|
-
this.implementations.set(import_ssi_types6.StatusListType.BitstringStatusList, new BitstringStatusListImplementation());
|
|
767
|
+
this.implementations.set(import_ssi_types5.StatusListType.StatusList2021, new StatusList2021Implementation());
|
|
768
|
+
this.implementations.set(import_ssi_types5.StatusListType.OAuthStatusList, new OAuthStatusListImplementation());
|
|
1048
769
|
}
|
|
1049
770
|
static getInstance() {
|
|
1050
771
|
if (!_StatusListFactory.instance) {
|
|
@@ -1117,7 +838,7 @@ __name(vcLibCheckStatusFunction, "vcLibCheckStatusFunction");
|
|
|
1117
838
|
async function checkStatusForCredential(args) {
|
|
1118
839
|
const verifyStatusListCredential = args.verifyStatusListCredential ?? true;
|
|
1119
840
|
const verifyMatchingIssuers = args.verifyMatchingIssuers ?? true;
|
|
1120
|
-
const uniform =
|
|
841
|
+
const uniform = import_ssi_types6.CredentialMapper.toUniformCredential(args.credential);
|
|
1121
842
|
if (!("credentialStatus" in uniform) || !uniform.credentialStatus) {
|
|
1122
843
|
if (args.mandatoryCredentialStatus) {
|
|
1123
844
|
const error = "No credential status object found in the Verifiable Credential and it is mandatory";
|
|
@@ -1132,7 +853,7 @@ async function checkStatusForCredential(args) {
|
|
|
1132
853
|
};
|
|
1133
854
|
}
|
|
1134
855
|
if ("credentialStatus" in uniform && uniform.credentialStatus) {
|
|
1135
|
-
if (uniform.credentialStatus.type === "StatusList2021Entry"
|
|
856
|
+
if (uniform.credentialStatus.type === "StatusList2021Entry") {
|
|
1136
857
|
return (0, import_vc_status_list2.checkStatus)({
|
|
1137
858
|
...args,
|
|
1138
859
|
verifyStatusListCredential,
|
|
@@ -1180,22 +901,22 @@ async function updateStatusIndexFromStatusListCredential(args, context) {
|
|
|
1180
901
|
return implementation.updateStatusListIndex(args, context);
|
|
1181
902
|
}
|
|
1182
903
|
__name(updateStatusIndexFromStatusListCredential, "updateStatusIndexFromStatusListCredential");
|
|
1183
|
-
async function statusListCredentialToDetails(
|
|
1184
|
-
const credential = getAssertedValue("statusListCredential", statusListCredential);
|
|
904
|
+
async function statusListCredentialToDetails(args) {
|
|
905
|
+
const credential = getAssertedValue("statusListCredential", args.statusListCredential);
|
|
1185
906
|
let statusListType;
|
|
1186
|
-
const documentFormat =
|
|
1187
|
-
if (documentFormat ===
|
|
907
|
+
const documentFormat = import_ssi_types6.CredentialMapper.detectDocumentType(credential);
|
|
908
|
+
if (documentFormat === import_ssi_types6.DocumentFormat.JWT) {
|
|
1188
909
|
const [header] = credential.split(".");
|
|
1189
910
|
const decodedHeader = JSON.parse(Buffer.from(header, "base64").toString());
|
|
1190
911
|
if (decodedHeader.typ === "statuslist+jwt") {
|
|
1191
|
-
statusListType =
|
|
912
|
+
statusListType = import_ssi_types6.StatusListType.OAuthStatusList;
|
|
1192
913
|
}
|
|
1193
|
-
} else if (documentFormat ===
|
|
1194
|
-
statusListType =
|
|
914
|
+
} else if (documentFormat === import_ssi_types6.DocumentFormat.MSO_MDOC) {
|
|
915
|
+
statusListType = import_ssi_types6.StatusListType.OAuthStatusList;
|
|
1195
916
|
}
|
|
1196
917
|
if (!statusListType) {
|
|
1197
|
-
const uniform =
|
|
1198
|
-
const type = uniform.type.find((t) => t.includes("StatusList2021") || t.includes("OAuth2StatusList")
|
|
918
|
+
const uniform = import_ssi_types6.CredentialMapper.toUniformCredential(credential);
|
|
919
|
+
const type = uniform.type.find((t) => t.includes("StatusList2021") || t.includes("OAuth2StatusList"));
|
|
1199
920
|
if (!type) {
|
|
1200
921
|
throw new Error("Invalid status list credential type");
|
|
1201
922
|
}
|
|
@@ -1204,9 +925,8 @@ async function statusListCredentialToDetails({ correlationId, driverType, status
|
|
|
1204
925
|
const implementation = getStatusListImplementation(statusListType);
|
|
1205
926
|
return await implementation.toStatusListDetails({
|
|
1206
927
|
statusListPayload: credential,
|
|
1207
|
-
correlationId,
|
|
1208
|
-
driverType
|
|
1209
|
-
bitsPerStatus
|
|
928
|
+
correlationId: args.correlationId,
|
|
929
|
+
driverType: args.driverType
|
|
1210
930
|
});
|
|
1211
931
|
}
|
|
1212
932
|
__name(statusListCredentialToDetails, "statusListCredentialToDetails");
|
|
@@ -1224,7 +944,7 @@ async function statusList2021ToVerifiableCredential(args, context) {
|
|
|
1224
944
|
offlineWhenNoDIDRegistered: true
|
|
1225
945
|
});
|
|
1226
946
|
const proofFormat = args?.proofFormat ?? "lds";
|
|
1227
|
-
assertValidProofType(
|
|
947
|
+
assertValidProofType(import_ssi_types6.StatusListType.StatusList2021, proofFormat);
|
|
1228
948
|
const veramoProofFormat = proofFormat;
|
|
1229
949
|
const encodedList = getAssertedValue("encodedList", args.encodedList);
|
|
1230
950
|
const statusPurpose = getAssertedValue("statusPurpose", args.statusPurpose);
|
|
@@ -1253,7 +973,7 @@ async function statusList2021ToVerifiableCredential(args, context) {
|
|
|
1253
973
|
proofFormat: veramoProofFormat,
|
|
1254
974
|
fetchRemoteContexts: true
|
|
1255
975
|
});
|
|
1256
|
-
return
|
|
976
|
+
return import_ssi_types6.CredentialMapper.toWrappedVerifiableCredential(verifiableCredential).original;
|
|
1257
977
|
}
|
|
1258
978
|
__name(statusList2021ToVerifiableCredential, "statusList2021ToVerifiableCredential");
|
|
1259
979
|
//# sourceMappingURL=index.cjs.map
|