@sphereon/ssi-sdk.vc-status-list 0.34.1-feature.SSISDK.17.bitstring.sl.2 → 0.34.1-feature.SSISDK.17.bitstring.sl.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 +82 -95
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +16 -21
- package/dist/index.d.ts +16 -21
- package/dist/index.js +82 -95
- package/dist/index.js.map +1 -1
- package/package.json +4 -5
- package/src/functions.ts +12 -4
- package/src/impl/BitstringStatusListImplementation.ts +58 -91
- package/src/impl/IStatusList.ts +2 -2
- package/src/impl/OAuthStatusList.ts +1 -2
- package/src/impl/StatusList2021.ts +1 -1
- package/src/types/BitstringStatusList.ts +3 -41
- package/src/types/index.ts +11 -20
- package/src/utils.ts +2 -1
package/dist/index.cjs
CHANGED
|
@@ -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
|
}
|
|
@@ -117,6 +118,12 @@ var ValidProofTypeMap = /* @__PURE__ */ new Map([
|
|
|
117
118
|
"jwt",
|
|
118
119
|
"cbor"
|
|
119
120
|
]
|
|
121
|
+
],
|
|
122
|
+
[
|
|
123
|
+
import_ssi_types.StatusListType.BitstringStatusList,
|
|
124
|
+
[
|
|
125
|
+
"lds"
|
|
126
|
+
]
|
|
120
127
|
]
|
|
121
128
|
]);
|
|
122
129
|
function assertValidProofType(type, proofFormat) {
|
|
@@ -259,7 +266,7 @@ var StatusList2021Implementation = class {
|
|
|
259
266
|
encodedList: args.encodedList
|
|
260
267
|
});
|
|
261
268
|
const index = typeof args.statusListIndex === "number" ? args.statusListIndex : parseInt(args.statusListIndex);
|
|
262
|
-
statusList.setStatus(index, args.value);
|
|
269
|
+
statusList.setStatus(index, args.value !== 0);
|
|
263
270
|
const newEncodedList = await statusList.encode();
|
|
264
271
|
const credential = await this.createVerifiableCredential({
|
|
265
272
|
id,
|
|
@@ -681,7 +688,7 @@ var OAuthStatusListImplementation = class {
|
|
|
681
688
|
const issuerString = typeof issuer === "string" ? issuer : issuer.id;
|
|
682
689
|
const listToUpdate = import_jwt_status_list3.StatusList.decompressStatusList(args.encodedList, bitsPerStatus ?? DEFAULT_BITS_PER_STATUS);
|
|
683
690
|
const index = typeof args.statusListIndex === "number" ? args.statusListIndex : parseInt(args.statusListIndex);
|
|
684
|
-
listToUpdate.setStatus(index, args.value
|
|
691
|
+
listToUpdate.setStatus(index, args.value);
|
|
685
692
|
const { statusListCredential, encodedList } = await this.createSignedStatusList(proofFormat ?? DEFAULT_PROOF_FORMAT2, context, listToUpdate, issuerString, id, expiresAt, keyRef);
|
|
686
693
|
return {
|
|
687
694
|
encodedList,
|
|
@@ -761,10 +768,9 @@ var import_ssi_types6 = require("@sphereon/ssi-types");
|
|
|
761
768
|
|
|
762
769
|
// src/impl/BitstringStatusListImplementation.ts
|
|
763
770
|
var import_ssi_types5 = require("@sphereon/ssi-types");
|
|
764
|
-
var
|
|
771
|
+
var import_vc_bitstring_status_lists = require("@4sure-tech/vc-bitstring-status-lists");
|
|
765
772
|
var DEFAULT_LIST_LENGTH3 = 131072;
|
|
766
773
|
var DEFAULT_PROOF_FORMAT3 = "lds";
|
|
767
|
-
var DEFAULT_STATUS_SIZE = 1;
|
|
768
774
|
var DEFAULT_STATUS_PURPOSE = "revocation";
|
|
769
775
|
var BitstringStatusListImplementation = class {
|
|
770
776
|
static {
|
|
@@ -780,26 +786,28 @@ var BitstringStatusListImplementation = class {
|
|
|
780
786
|
const veramoProofFormat = proofFormat;
|
|
781
787
|
const { issuer, id } = args;
|
|
782
788
|
const correlationId = getAssertedValue("correlationId", args.correlationId);
|
|
783
|
-
const { statusPurpose,
|
|
784
|
-
const list = await (0, import_vc_bitstring_status_list.createList)({
|
|
785
|
-
length
|
|
786
|
-
});
|
|
787
|
-
const encodedList = await list.encode();
|
|
789
|
+
const { statusPurpose, bitsPerStatus, validFrom, validUntil, ttl } = args.bitstringStatusList;
|
|
788
790
|
const statusListCredential = await this.createVerifiableCredential({
|
|
789
791
|
...args,
|
|
790
|
-
encodedList,
|
|
791
792
|
proofFormat: veramoProofFormat,
|
|
792
793
|
statusPurpose: statusPurpose ?? DEFAULT_STATUS_PURPOSE,
|
|
793
|
-
|
|
794
|
-
|
|
794
|
+
validFrom,
|
|
795
|
+
validUntil,
|
|
795
796
|
ttl
|
|
796
797
|
}, context);
|
|
797
798
|
return {
|
|
798
|
-
encodedList,
|
|
799
|
+
encodedList: statusListCredential.credentialSubject.encodedList,
|
|
799
800
|
statusListCredential,
|
|
800
801
|
bitstringStatusList: {
|
|
801
802
|
statusPurpose: statusPurpose ?? DEFAULT_STATUS_PURPOSE,
|
|
802
|
-
|
|
803
|
+
...statusListCredential.validFrom && {
|
|
804
|
+
validFrom: new Date(statusListCredential.validFrom)
|
|
805
|
+
},
|
|
806
|
+
...statusListCredential.validUntil && {
|
|
807
|
+
validUntil: new Date(statusListCredential.validUntil)
|
|
808
|
+
},
|
|
809
|
+
ttl,
|
|
810
|
+
bitsPerStatus
|
|
803
811
|
},
|
|
804
812
|
length,
|
|
805
813
|
type: import_ssi_types5.StatusListType.BitstringStatusList,
|
|
@@ -811,17 +819,20 @@ var BitstringStatusListImplementation = class {
|
|
|
811
819
|
};
|
|
812
820
|
}
|
|
813
821
|
async updateStatusListIndex(args, context) {
|
|
822
|
+
if (!args.bitsPerStatus || args.bitsPerStatus < 1) {
|
|
823
|
+
return Promise.reject("bitsPerStatus must be set for bitstring status lists and must be 1 or higher. (updateStatusListIndex)");
|
|
824
|
+
}
|
|
814
825
|
const credential = args.statusListCredential;
|
|
815
826
|
const uniform = import_ssi_types5.CredentialMapper.toUniformCredential(credential);
|
|
816
827
|
const { issuer, credentialSubject } = uniform;
|
|
817
828
|
const id = getAssertedValue("id", uniform.id);
|
|
818
829
|
const origEncodedList = getAssertedProperty("encodedList", credentialSubject);
|
|
819
830
|
const index = typeof args.statusListIndex === "number" ? args.statusListIndex : parseInt(args.statusListIndex);
|
|
820
|
-
const statusList = await
|
|
821
|
-
encodedList: origEncodedList
|
|
831
|
+
const statusList = await import_vc_bitstring_status_lists.BitstreamStatusList.decode({
|
|
832
|
+
encodedList: origEncodedList,
|
|
833
|
+
statusSize: args.bitsPerStatus
|
|
822
834
|
});
|
|
823
|
-
statusList.setStatus(index, args.value
|
|
824
|
-
const encodedList = await statusList.encode();
|
|
835
|
+
statusList.setStatus(index, args.value);
|
|
825
836
|
const proofFormat = import_ssi_types5.CredentialMapper.detectDocumentType(credential) === import_ssi_types5.DocumentFormat.JWT ? "jwt" : "lds";
|
|
826
837
|
const credSubject = Array.isArray(credentialSubject) ? credentialSubject[0] : credentialSubject;
|
|
827
838
|
const statusPurpose = getAssertedProperty("statusPurpose", credSubject);
|
|
@@ -832,7 +843,7 @@ var BitstringStatusListImplementation = class {
|
|
|
832
843
|
...args,
|
|
833
844
|
id,
|
|
834
845
|
issuer,
|
|
835
|
-
|
|
846
|
+
statusList,
|
|
836
847
|
proofFormat,
|
|
837
848
|
statusPurpose,
|
|
838
849
|
ttl,
|
|
@@ -841,14 +852,19 @@ var BitstringStatusListImplementation = class {
|
|
|
841
852
|
}, context);
|
|
842
853
|
return {
|
|
843
854
|
statusListCredential: updatedCredential,
|
|
844
|
-
encodedList,
|
|
855
|
+
encodedList: updatedCredential.credentialSubject.encodedList,
|
|
845
856
|
bitstringStatusList: {
|
|
846
857
|
statusPurpose,
|
|
847
|
-
validFrom
|
|
848
|
-
|
|
858
|
+
...updatedCredential.validFrom && {
|
|
859
|
+
validFrom: new Date(updatedCredential.validFrom)
|
|
860
|
+
},
|
|
861
|
+
...updatedCredential.validUntil && {
|
|
862
|
+
validUntil: new Date(updatedCredential.validUntil)
|
|
863
|
+
},
|
|
864
|
+
bitsPerStatus: args.bitsPerStatus,
|
|
849
865
|
ttl
|
|
850
866
|
},
|
|
851
|
-
length: statusList.
|
|
867
|
+
length: statusList.getLength(),
|
|
852
868
|
type: import_ssi_types5.StatusListType.BitstringStatusList,
|
|
853
869
|
proofFormat,
|
|
854
870
|
id,
|
|
@@ -860,26 +876,27 @@ var BitstringStatusListImplementation = class {
|
|
|
860
876
|
if (!args.bitstringStatusList) {
|
|
861
877
|
throw new Error("bitstringStatusList options required for type BitstringStatusList");
|
|
862
878
|
}
|
|
879
|
+
if (args.bitstringStatusList.bitsPerStatus < 1) {
|
|
880
|
+
return Promise.reject("bitsPerStatus must be set for bitstring status lists and must be 1 or higher. (updateStatusListFromEncodedList)");
|
|
881
|
+
}
|
|
882
|
+
const { statusPurpose, bitsPerStatus, ttl, validFrom, validUntil } = args.bitstringStatusList;
|
|
863
883
|
const proofFormat = args?.proofFormat ?? DEFAULT_PROOF_FORMAT3;
|
|
864
884
|
assertValidProofType(import_ssi_types5.StatusListType.BitstringStatusList, proofFormat);
|
|
865
885
|
const veramoProofFormat = proofFormat;
|
|
866
886
|
const { issuer, id } = getAssertedValues(args);
|
|
867
|
-
const statusList = await
|
|
868
|
-
encodedList: args.encodedList
|
|
887
|
+
const statusList = await import_vc_bitstring_status_lists.BitstreamStatusList.decode({
|
|
888
|
+
encodedList: args.encodedList,
|
|
889
|
+
statusSize: bitsPerStatus
|
|
869
890
|
});
|
|
870
891
|
const index = typeof args.statusListIndex === "number" ? args.statusListIndex : parseInt(args.statusListIndex);
|
|
871
892
|
statusList.setStatus(index, args.value);
|
|
872
|
-
const newEncodedList = await statusList.encode();
|
|
873
|
-
const { statusPurpose, statusSize, statusMessage, ttl, validFrom, validUntil } = args.bitstringStatusList;
|
|
874
893
|
const credential = await this.createVerifiableCredential({
|
|
875
894
|
id,
|
|
876
895
|
issuer,
|
|
877
|
-
|
|
896
|
+
statusList,
|
|
878
897
|
proofFormat: veramoProofFormat,
|
|
879
898
|
keyRef: args.keyRef,
|
|
880
899
|
statusPurpose,
|
|
881
|
-
statusSize,
|
|
882
|
-
statusMessage,
|
|
883
900
|
validFrom,
|
|
884
901
|
validUntil,
|
|
885
902
|
ttl
|
|
@@ -887,14 +904,19 @@ var BitstringStatusListImplementation = class {
|
|
|
887
904
|
return {
|
|
888
905
|
type: import_ssi_types5.StatusListType.BitstringStatusList,
|
|
889
906
|
statusListCredential: credential,
|
|
890
|
-
encodedList:
|
|
907
|
+
encodedList: credential.credentialSubject.encodedList,
|
|
891
908
|
bitstringStatusList: {
|
|
892
909
|
statusPurpose,
|
|
893
|
-
|
|
894
|
-
|
|
910
|
+
bitsPerStatus,
|
|
911
|
+
...credential.validFrom && {
|
|
912
|
+
validFrom: new Date(credential.validFrom)
|
|
913
|
+
},
|
|
914
|
+
...credential.validUntil && {
|
|
915
|
+
validUntil: new Date(credential.validUntil)
|
|
916
|
+
},
|
|
895
917
|
ttl
|
|
896
918
|
},
|
|
897
|
-
length: statusList.
|
|
919
|
+
length: statusList.getLength(),
|
|
898
920
|
proofFormat: args.proofFormat ?? "lds",
|
|
899
921
|
id,
|
|
900
922
|
issuer,
|
|
@@ -902,30 +924,28 @@ var BitstringStatusListImplementation = class {
|
|
|
902
924
|
};
|
|
903
925
|
}
|
|
904
926
|
async checkStatusIndex(args) {
|
|
927
|
+
if (!args.bitsPerStatus || args.bitsPerStatus < 1) {
|
|
928
|
+
return Promise.reject("bitsPerStatus must be set for bitstring status lists and must be 1 or higher. (checkStatusIndex)");
|
|
929
|
+
}
|
|
905
930
|
const uniform = import_ssi_types5.CredentialMapper.toUniformCredential(args.statusListCredential);
|
|
906
931
|
const { credentialSubject } = uniform;
|
|
907
932
|
const encodedList = getAssertedProperty("encodedList", credentialSubject);
|
|
908
|
-
const
|
|
909
|
-
const
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
const statusMessage = messageList.find((statMsg) => statMsg.status === hexIndex);
|
|
913
|
-
const statusList = await (0, import_vc_bitstring_status_list.decodeList)({
|
|
914
|
-
encodedList
|
|
933
|
+
const statusSize = args.bitsPerStatus;
|
|
934
|
+
const statusList = await import_vc_bitstring_status_lists.BitstreamStatusList.decode({
|
|
935
|
+
encodedList,
|
|
936
|
+
statusSize
|
|
915
937
|
});
|
|
916
|
-
|
|
917
|
-
|
|
938
|
+
const numIndex = typeof args.statusListIndex === "number" ? args.statusListIndex : parseInt(args.statusListIndex);
|
|
939
|
+
if (statusList.getLength() <= numIndex) {
|
|
940
|
+
throw new Error(`Status list index out of bounds, has ${statusList.getLength()} entries, requested ${numIndex}`);
|
|
918
941
|
}
|
|
919
|
-
|
|
920
|
-
return {
|
|
921
|
-
index: numIndex,
|
|
922
|
-
status: hexIndex,
|
|
923
|
-
message: statusMessage?.message,
|
|
924
|
-
set: value
|
|
925
|
-
};
|
|
942
|
+
return statusList.getStatus(numIndex);
|
|
926
943
|
}
|
|
927
944
|
async toStatusListDetails(args) {
|
|
928
|
-
const { statusListPayload } = args;
|
|
945
|
+
const { statusListPayload, bitsPerStatus } = args;
|
|
946
|
+
if (!bitsPerStatus || bitsPerStatus < 1) {
|
|
947
|
+
return Promise.reject("bitsPerStatus must be set for bitstring status lists and must be 1 or higher. (toStatusListDetails)");
|
|
948
|
+
}
|
|
929
949
|
const uniform = import_ssi_types5.CredentialMapper.toUniformCredential(statusListPayload);
|
|
930
950
|
const { issuer, credentialSubject } = uniform;
|
|
931
951
|
const id = getAssertedValue("id", uniform.id);
|
|
@@ -936,20 +956,19 @@ var BitstringStatusListImplementation = class {
|
|
|
936
956
|
const validFrom = uniform.validFrom ? new Date(uniform.validFrom) : void 0;
|
|
937
957
|
const validUntil = uniform.validUntil ? new Date(uniform.validUntil) : void 0;
|
|
938
958
|
const ttl = credSubject.ttl;
|
|
939
|
-
const
|
|
940
|
-
encodedList
|
|
941
|
-
});
|
|
959
|
+
const statuslistLength = import_vc_bitstring_status_lists.BitstreamStatusList.getStatusListLength(encodedList, bitsPerStatus);
|
|
942
960
|
return {
|
|
943
961
|
id,
|
|
944
962
|
encodedList,
|
|
945
963
|
issuer,
|
|
946
964
|
type: import_ssi_types5.StatusListType.BitstringStatusList,
|
|
947
965
|
proofFormat,
|
|
948
|
-
length:
|
|
966
|
+
length: statuslistLength,
|
|
949
967
|
statusListCredential: statusListPayload,
|
|
950
968
|
statuslistContentType: this.buildContentType(proofFormat),
|
|
951
969
|
bitstringStatusList: {
|
|
952
970
|
statusPurpose,
|
|
971
|
+
bitsPerStatus,
|
|
953
972
|
validFrom,
|
|
954
973
|
validUntil,
|
|
955
974
|
ttl
|
|
@@ -968,42 +987,9 @@ var BitstringStatusListImplementation = class {
|
|
|
968
987
|
vmRelationship: "assertionMethod",
|
|
969
988
|
offlineWhenNoDIDRegistered: true
|
|
970
989
|
});
|
|
971
|
-
const
|
|
972
|
-
id: args.id,
|
|
973
|
-
type: "BitstringStatusList",
|
|
974
|
-
statusPurpose: args.statusPurpose,
|
|
975
|
-
encodedList: args.encodedList
|
|
976
|
-
};
|
|
977
|
-
if (args.statusSize && args.statusSize > 1) {
|
|
978
|
-
credentialSubject.statusSize = args.statusSize;
|
|
979
|
-
}
|
|
980
|
-
if (args.statusMessage) {
|
|
981
|
-
credentialSubject.statusMessage = args.statusMessage;
|
|
982
|
-
}
|
|
983
|
-
if (args.validFrom) {
|
|
984
|
-
credentialSubject.validFrom = args.validFrom;
|
|
985
|
-
}
|
|
986
|
-
if (args.validUntil) {
|
|
987
|
-
credentialSubject.validUntil = args.validUntil;
|
|
988
|
-
}
|
|
989
|
-
if (args.ttl) {
|
|
990
|
-
credentialSubject.ttl = args.ttl;
|
|
991
|
-
}
|
|
992
|
-
const credential = {
|
|
993
|
-
"@context": [
|
|
994
|
-
"https://www.w3.org/2018/credentials/v1",
|
|
995
|
-
"https://www.w3.org/ns/credentials/status/v1"
|
|
996
|
-
],
|
|
997
|
-
id: args.id,
|
|
998
|
-
issuer: args.issuer,
|
|
999
|
-
type: [
|
|
1000
|
-
"VerifiableCredential",
|
|
1001
|
-
"BitstringStatusListCredential"
|
|
1002
|
-
],
|
|
1003
|
-
credentialSubject
|
|
1004
|
-
};
|
|
990
|
+
const unsignedCredential = await (0, import_vc_bitstring_status_lists.createStatusListCredential)(args);
|
|
1005
991
|
const verifiableCredential = await context.agent.createVerifiableCredential({
|
|
1006
|
-
credential,
|
|
992
|
+
credential: unsignedCredential,
|
|
1007
993
|
keyRef: args.keyRef ?? identifier.kmsKeyRef,
|
|
1008
994
|
proofFormat: args.proofFormat,
|
|
1009
995
|
fetchRemoteContexts: true
|
|
@@ -1171,8 +1157,8 @@ async function updateStatusIndexFromStatusListCredential(args, context) {
|
|
|
1171
1157
|
return implementation.updateStatusListIndex(args, context);
|
|
1172
1158
|
}
|
|
1173
1159
|
__name(updateStatusIndexFromStatusListCredential, "updateStatusIndexFromStatusListCredential");
|
|
1174
|
-
async function statusListCredentialToDetails(
|
|
1175
|
-
const credential = getAssertedValue("statusListCredential",
|
|
1160
|
+
async function statusListCredentialToDetails({ correlationId, driverType, statusListCredential, bitsPerStatus }) {
|
|
1161
|
+
const credential = getAssertedValue("statusListCredential", statusListCredential);
|
|
1176
1162
|
let statusListType;
|
|
1177
1163
|
const documentFormat = import_ssi_types7.CredentialMapper.detectDocumentType(credential);
|
|
1178
1164
|
if (documentFormat === import_ssi_types7.DocumentFormat.JWT) {
|
|
@@ -1195,8 +1181,9 @@ async function statusListCredentialToDetails(args) {
|
|
|
1195
1181
|
const implementation = getStatusListImplementation(statusListType);
|
|
1196
1182
|
return await implementation.toStatusListDetails({
|
|
1197
1183
|
statusListPayload: credential,
|
|
1198
|
-
correlationId
|
|
1199
|
-
driverType
|
|
1184
|
+
correlationId,
|
|
1185
|
+
driverType,
|
|
1186
|
+
bitsPerStatus
|
|
1200
1187
|
});
|
|
1201
1188
|
}
|
|
1202
1189
|
__name(statusListCredentialToDetails, "statusListCredentialToDetails");
|