@sphereon/ssi-sdk.vc-status-list 0.34.0 → 0.34.1-feature.SSISDK.17.bitstring.sl.7
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 +281 -24
- 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 +282 -25
- package/dist/index.js.map +1 -1
- package/package.json +4 -3
- 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 +9 -6
- 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 +3 -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) {
|
|
@@ -260,7 +266,7 @@ var StatusList2021Implementation = class {
|
|
|
260
266
|
encodedList: args.encodedList
|
|
261
267
|
});
|
|
262
268
|
const index = typeof args.statusListIndex === "number" ? args.statusListIndex : parseInt(args.statusListIndex);
|
|
263
|
-
statusList.setStatus(index, args.value);
|
|
269
|
+
statusList.setStatus(index, args.value !== 0);
|
|
264
270
|
const newEncodedList = await statusList.encode();
|
|
265
271
|
const credential = await this.createVerifiableCredential({
|
|
266
272
|
id,
|
|
@@ -652,6 +658,9 @@ var OAuthStatusListImplementation = class {
|
|
|
652
658
|
if (index < 0 || index >= statusList.statusList.length) {
|
|
653
659
|
throw new Error("Status list index out of bounds");
|
|
654
660
|
}
|
|
661
|
+
if (typeof value !== "number") {
|
|
662
|
+
throw new Error("Status list values should be of type number");
|
|
663
|
+
}
|
|
655
664
|
statusList.setStatus(index, value);
|
|
656
665
|
const { statusListCredential: signedCredential, encodedList } = await this.createSignedStatusList(proofFormat, context, statusList, issuer, id, expiresAt, keyRef);
|
|
657
666
|
return {
|
|
@@ -679,7 +688,7 @@ var OAuthStatusListImplementation = class {
|
|
|
679
688
|
const issuerString = typeof issuer === "string" ? issuer : issuer.id;
|
|
680
689
|
const listToUpdate = import_jwt_status_list3.StatusList.decompressStatusList(args.encodedList, bitsPerStatus ?? DEFAULT_BITS_PER_STATUS);
|
|
681
690
|
const index = typeof args.statusListIndex === "number" ? args.statusListIndex : parseInt(args.statusListIndex);
|
|
682
|
-
listToUpdate.setStatus(index, args.value
|
|
691
|
+
listToUpdate.setStatus(index, args.value);
|
|
683
692
|
const { statusListCredential, encodedList } = await this.createSignedStatusList(proofFormat ?? DEFAULT_PROOF_FORMAT2, context, listToUpdate, issuerString, id, expiresAt, keyRef);
|
|
684
693
|
return {
|
|
685
694
|
encodedList,
|
|
@@ -708,7 +717,7 @@ var OAuthStatusListImplementation = class {
|
|
|
708
717
|
const { statusList } = proofFormat === "jwt" ? decodeStatusListJWT(statusListCredential) : decodeStatusListCWT(statusListCredential);
|
|
709
718
|
const index = typeof statusListIndex === "number" ? statusListIndex : parseInt(statusListIndex);
|
|
710
719
|
if (index < 0 || index >= statusList.statusList.length) {
|
|
711
|
-
throw new Error(
|
|
720
|
+
throw new Error(`Status list index out of bounds, has ${statusList.statusList.length} items, requested ${index}`);
|
|
712
721
|
}
|
|
713
722
|
return statusList.getStatus(index);
|
|
714
723
|
}
|
|
@@ -755,7 +764,253 @@ var OAuthStatusListImplementation = class {
|
|
|
755
764
|
};
|
|
756
765
|
|
|
757
766
|
// src/impl/StatusListFactory.ts
|
|
767
|
+
var import_ssi_types6 = require("@sphereon/ssi-types");
|
|
768
|
+
|
|
769
|
+
// src/impl/BitstringStatusListImplementation.ts
|
|
758
770
|
var import_ssi_types5 = require("@sphereon/ssi-types");
|
|
771
|
+
var import_vc_bitstring_status_lists = require("@4sure-tech/vc-bitstring-status-lists");
|
|
772
|
+
var DEFAULT_LIST_LENGTH3 = 131072;
|
|
773
|
+
var DEFAULT_PROOF_FORMAT3 = "lds";
|
|
774
|
+
var DEFAULT_STATUS_PURPOSE = "revocation";
|
|
775
|
+
var BitstringStatusListImplementation = class {
|
|
776
|
+
static {
|
|
777
|
+
__name(this, "BitstringStatusListImplementation");
|
|
778
|
+
}
|
|
779
|
+
async createNewStatusList(args, context) {
|
|
780
|
+
if (!args.bitstringStatusList) {
|
|
781
|
+
throw new Error("BitstringStatusList options are required for type BitstringStatusList");
|
|
782
|
+
}
|
|
783
|
+
const length = args?.length ?? DEFAULT_LIST_LENGTH3;
|
|
784
|
+
const proofFormat = args?.proofFormat ?? DEFAULT_PROOF_FORMAT3;
|
|
785
|
+
assertValidProofType(import_ssi_types5.StatusListType.BitstringStatusList, proofFormat);
|
|
786
|
+
const veramoProofFormat = proofFormat;
|
|
787
|
+
const { issuer, id } = args;
|
|
788
|
+
const correlationId = getAssertedValue("correlationId", args.correlationId);
|
|
789
|
+
const { statusPurpose, bitsPerStatus, validFrom, validUntil, ttl } = args.bitstringStatusList;
|
|
790
|
+
const statusListCredential = await this.createVerifiableCredential({
|
|
791
|
+
...args,
|
|
792
|
+
proofFormat: veramoProofFormat,
|
|
793
|
+
statusPurpose: statusPurpose ?? DEFAULT_STATUS_PURPOSE,
|
|
794
|
+
validFrom,
|
|
795
|
+
validUntil,
|
|
796
|
+
ttl
|
|
797
|
+
}, context);
|
|
798
|
+
return {
|
|
799
|
+
encodedList: statusListCredential.credentialSubject.encodedList,
|
|
800
|
+
statusListCredential,
|
|
801
|
+
bitstringStatusList: {
|
|
802
|
+
statusPurpose: statusPurpose ?? DEFAULT_STATUS_PURPOSE,
|
|
803
|
+
...statusListCredential.validFrom && {
|
|
804
|
+
validFrom: new Date(statusListCredential.validFrom)
|
|
805
|
+
},
|
|
806
|
+
...statusListCredential.validUntil && {
|
|
807
|
+
validUntil: new Date(statusListCredential.validUntil)
|
|
808
|
+
},
|
|
809
|
+
ttl,
|
|
810
|
+
bitsPerStatus
|
|
811
|
+
},
|
|
812
|
+
length,
|
|
813
|
+
type: import_ssi_types5.StatusListType.BitstringStatusList,
|
|
814
|
+
proofFormat,
|
|
815
|
+
id,
|
|
816
|
+
correlationId,
|
|
817
|
+
issuer,
|
|
818
|
+
statuslistContentType: this.buildContentType(proofFormat)
|
|
819
|
+
};
|
|
820
|
+
}
|
|
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
|
+
}
|
|
825
|
+
const credential = args.statusListCredential;
|
|
826
|
+
const uniform = import_ssi_types5.CredentialMapper.toUniformCredential(credential);
|
|
827
|
+
const { issuer, credentialSubject } = uniform;
|
|
828
|
+
const id = getAssertedValue("id", uniform.id);
|
|
829
|
+
const origEncodedList = getAssertedProperty("encodedList", credentialSubject);
|
|
830
|
+
const index = typeof args.statusListIndex === "number" ? args.statusListIndex : parseInt(args.statusListIndex);
|
|
831
|
+
const statusList = await import_vc_bitstring_status_lists.BitstreamStatusList.decode({
|
|
832
|
+
encodedList: origEncodedList,
|
|
833
|
+
statusSize: args.bitsPerStatus
|
|
834
|
+
});
|
|
835
|
+
statusList.setStatus(index, args.value);
|
|
836
|
+
const proofFormat = import_ssi_types5.CredentialMapper.detectDocumentType(credential) === import_ssi_types5.DocumentFormat.JWT ? "jwt" : "lds";
|
|
837
|
+
const credSubject = Array.isArray(credentialSubject) ? credentialSubject[0] : credentialSubject;
|
|
838
|
+
const statusPurpose = getAssertedProperty("statusPurpose", credSubject);
|
|
839
|
+
const validFrom = uniform.validFrom ? new Date(uniform.validFrom) : void 0;
|
|
840
|
+
const validUntil = uniform.validUntil ? new Date(uniform.validUntil) : void 0;
|
|
841
|
+
const ttl = credSubject.ttl;
|
|
842
|
+
const updatedCredential = await this.createVerifiableCredential({
|
|
843
|
+
...args,
|
|
844
|
+
id,
|
|
845
|
+
issuer,
|
|
846
|
+
statusList,
|
|
847
|
+
proofFormat,
|
|
848
|
+
statusPurpose,
|
|
849
|
+
ttl,
|
|
850
|
+
validFrom,
|
|
851
|
+
validUntil
|
|
852
|
+
}, context);
|
|
853
|
+
return {
|
|
854
|
+
statusListCredential: updatedCredential,
|
|
855
|
+
encodedList: updatedCredential.credentialSubject.encodedList,
|
|
856
|
+
bitstringStatusList: {
|
|
857
|
+
statusPurpose,
|
|
858
|
+
...updatedCredential.validFrom && {
|
|
859
|
+
validFrom: new Date(updatedCredential.validFrom)
|
|
860
|
+
},
|
|
861
|
+
...updatedCredential.validUntil && {
|
|
862
|
+
validUntil: new Date(updatedCredential.validUntil)
|
|
863
|
+
},
|
|
864
|
+
bitsPerStatus: args.bitsPerStatus,
|
|
865
|
+
ttl
|
|
866
|
+
},
|
|
867
|
+
length: statusList.getLength(),
|
|
868
|
+
type: import_ssi_types5.StatusListType.BitstringStatusList,
|
|
869
|
+
proofFormat,
|
|
870
|
+
id,
|
|
871
|
+
issuer,
|
|
872
|
+
statuslistContentType: this.buildContentType(proofFormat)
|
|
873
|
+
};
|
|
874
|
+
}
|
|
875
|
+
async updateStatusListFromEncodedList(args, context) {
|
|
876
|
+
if (!args.bitstringStatusList) {
|
|
877
|
+
throw new Error("bitstringStatusList options required for type BitstringStatusList");
|
|
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;
|
|
883
|
+
const proofFormat = args?.proofFormat ?? DEFAULT_PROOF_FORMAT3;
|
|
884
|
+
assertValidProofType(import_ssi_types5.StatusListType.BitstringStatusList, proofFormat);
|
|
885
|
+
const veramoProofFormat = proofFormat;
|
|
886
|
+
const { issuer, id } = getAssertedValues(args);
|
|
887
|
+
const statusList = await import_vc_bitstring_status_lists.BitstreamStatusList.decode({
|
|
888
|
+
encodedList: args.encodedList,
|
|
889
|
+
statusSize: bitsPerStatus
|
|
890
|
+
});
|
|
891
|
+
const index = typeof args.statusListIndex === "number" ? args.statusListIndex : parseInt(args.statusListIndex);
|
|
892
|
+
statusList.setStatus(index, args.value);
|
|
893
|
+
const credential = await this.createVerifiableCredential({
|
|
894
|
+
id,
|
|
895
|
+
issuer,
|
|
896
|
+
statusList,
|
|
897
|
+
proofFormat: veramoProofFormat,
|
|
898
|
+
keyRef: args.keyRef,
|
|
899
|
+
statusPurpose,
|
|
900
|
+
validFrom,
|
|
901
|
+
validUntil,
|
|
902
|
+
ttl
|
|
903
|
+
}, context);
|
|
904
|
+
return {
|
|
905
|
+
type: import_ssi_types5.StatusListType.BitstringStatusList,
|
|
906
|
+
statusListCredential: credential,
|
|
907
|
+
encodedList: credential.credentialSubject.encodedList,
|
|
908
|
+
bitstringStatusList: {
|
|
909
|
+
statusPurpose,
|
|
910
|
+
bitsPerStatus,
|
|
911
|
+
...credential.validFrom && {
|
|
912
|
+
validFrom: new Date(credential.validFrom)
|
|
913
|
+
},
|
|
914
|
+
...credential.validUntil && {
|
|
915
|
+
validUntil: new Date(credential.validUntil)
|
|
916
|
+
},
|
|
917
|
+
ttl
|
|
918
|
+
},
|
|
919
|
+
length: statusList.getLength(),
|
|
920
|
+
proofFormat: args.proofFormat ?? "lds",
|
|
921
|
+
id,
|
|
922
|
+
issuer,
|
|
923
|
+
statuslistContentType: this.buildContentType(proofFormat)
|
|
924
|
+
};
|
|
925
|
+
}
|
|
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
|
+
}
|
|
930
|
+
const uniform = import_ssi_types5.CredentialMapper.toUniformCredential(args.statusListCredential);
|
|
931
|
+
const { credentialSubject } = uniform;
|
|
932
|
+
const encodedList = getAssertedProperty("encodedList", credentialSubject);
|
|
933
|
+
const statusSize = args.bitsPerStatus;
|
|
934
|
+
const statusList = await import_vc_bitstring_status_lists.BitstreamStatusList.decode({
|
|
935
|
+
encodedList,
|
|
936
|
+
statusSize
|
|
937
|
+
});
|
|
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}`);
|
|
941
|
+
}
|
|
942
|
+
return statusList.getStatus(numIndex);
|
|
943
|
+
}
|
|
944
|
+
async toStatusListDetails(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
|
+
}
|
|
949
|
+
const uniform = import_ssi_types5.CredentialMapper.toUniformCredential(statusListPayload);
|
|
950
|
+
const { issuer, credentialSubject } = uniform;
|
|
951
|
+
const id = getAssertedValue("id", uniform.id);
|
|
952
|
+
const encodedList = getAssertedProperty("encodedList", credentialSubject);
|
|
953
|
+
const proofFormat = import_ssi_types5.CredentialMapper.detectDocumentType(statusListPayload) === import_ssi_types5.DocumentFormat.JWT ? "jwt" : "lds";
|
|
954
|
+
const credSubject = Array.isArray(credentialSubject) ? credentialSubject[0] : credentialSubject;
|
|
955
|
+
const statusPurpose = getAssertedProperty("statusPurpose", credSubject);
|
|
956
|
+
const validFrom = uniform.validFrom ? new Date(uniform.validFrom) : void 0;
|
|
957
|
+
const validUntil = uniform.validUntil ? new Date(uniform.validUntil) : void 0;
|
|
958
|
+
const ttl = credSubject.ttl;
|
|
959
|
+
const statuslistLength = import_vc_bitstring_status_lists.BitstreamStatusList.getStatusListLength(encodedList, bitsPerStatus);
|
|
960
|
+
return {
|
|
961
|
+
id,
|
|
962
|
+
encodedList,
|
|
963
|
+
issuer,
|
|
964
|
+
type: import_ssi_types5.StatusListType.BitstringStatusList,
|
|
965
|
+
proofFormat,
|
|
966
|
+
length: statuslistLength,
|
|
967
|
+
statusListCredential: statusListPayload,
|
|
968
|
+
statuslistContentType: this.buildContentType(proofFormat),
|
|
969
|
+
bitstringStatusList: {
|
|
970
|
+
statusPurpose,
|
|
971
|
+
bitsPerStatus,
|
|
972
|
+
validFrom,
|
|
973
|
+
validUntil,
|
|
974
|
+
ttl
|
|
975
|
+
},
|
|
976
|
+
...args.correlationId && {
|
|
977
|
+
correlationId: args.correlationId
|
|
978
|
+
},
|
|
979
|
+
...args.driverType && {
|
|
980
|
+
driverType: args.driverType
|
|
981
|
+
}
|
|
982
|
+
};
|
|
983
|
+
}
|
|
984
|
+
async createVerifiableCredential(args, context) {
|
|
985
|
+
const identifier = await context.agent.identifierManagedGet({
|
|
986
|
+
identifier: typeof args.issuer === "string" ? args.issuer : args.issuer.id,
|
|
987
|
+
vmRelationship: "assertionMethod",
|
|
988
|
+
offlineWhenNoDIDRegistered: true
|
|
989
|
+
});
|
|
990
|
+
const unsignedCredential = await (0, import_vc_bitstring_status_lists.createStatusListCredential)(args);
|
|
991
|
+
const verifiableCredential = await context.agent.createVerifiableCredential({
|
|
992
|
+
credential: unsignedCredential,
|
|
993
|
+
keyRef: args.keyRef ?? identifier.kmsKeyRef,
|
|
994
|
+
proofFormat: args.proofFormat,
|
|
995
|
+
fetchRemoteContexts: true
|
|
996
|
+
});
|
|
997
|
+
return import_ssi_types5.CredentialMapper.toWrappedVerifiableCredential(verifiableCredential).original;
|
|
998
|
+
}
|
|
999
|
+
buildContentType(proofFormat) {
|
|
1000
|
+
switch (proofFormat) {
|
|
1001
|
+
case "jwt":
|
|
1002
|
+
return `application/statuslist+jwt`;
|
|
1003
|
+
case "cbor":
|
|
1004
|
+
return `application/statuslist+cwt`;
|
|
1005
|
+
case "lds":
|
|
1006
|
+
return "application/statuslist+ld+json";
|
|
1007
|
+
default:
|
|
1008
|
+
throw Error(`Unsupported content type '${proofFormat}' for status lists`);
|
|
1009
|
+
}
|
|
1010
|
+
}
|
|
1011
|
+
};
|
|
1012
|
+
|
|
1013
|
+
// src/impl/StatusListFactory.ts
|
|
759
1014
|
var StatusListFactory = class _StatusListFactory {
|
|
760
1015
|
static {
|
|
761
1016
|
__name(this, "StatusListFactory");
|
|
@@ -764,8 +1019,9 @@ var StatusListFactory = class _StatusListFactory {
|
|
|
764
1019
|
implementations;
|
|
765
1020
|
constructor() {
|
|
766
1021
|
this.implementations = /* @__PURE__ */ new Map();
|
|
767
|
-
this.implementations.set(
|
|
768
|
-
this.implementations.set(
|
|
1022
|
+
this.implementations.set(import_ssi_types6.StatusListType.StatusList2021, new StatusList2021Implementation());
|
|
1023
|
+
this.implementations.set(import_ssi_types6.StatusListType.OAuthStatusList, new OAuthStatusListImplementation());
|
|
1024
|
+
this.implementations.set(import_ssi_types6.StatusListType.BitstringStatusList, new BitstringStatusListImplementation());
|
|
769
1025
|
}
|
|
770
1026
|
static getInstance() {
|
|
771
1027
|
if (!_StatusListFactory.instance) {
|
|
@@ -838,7 +1094,7 @@ __name(vcLibCheckStatusFunction, "vcLibCheckStatusFunction");
|
|
|
838
1094
|
async function checkStatusForCredential(args) {
|
|
839
1095
|
const verifyStatusListCredential = args.verifyStatusListCredential ?? true;
|
|
840
1096
|
const verifyMatchingIssuers = args.verifyMatchingIssuers ?? true;
|
|
841
|
-
const uniform =
|
|
1097
|
+
const uniform = import_ssi_types7.CredentialMapper.toUniformCredential(args.credential);
|
|
842
1098
|
if (!("credentialStatus" in uniform) || !uniform.credentialStatus) {
|
|
843
1099
|
if (args.mandatoryCredentialStatus) {
|
|
844
1100
|
const error = "No credential status object found in the Verifiable Credential and it is mandatory";
|
|
@@ -853,7 +1109,7 @@ async function checkStatusForCredential(args) {
|
|
|
853
1109
|
};
|
|
854
1110
|
}
|
|
855
1111
|
if ("credentialStatus" in uniform && uniform.credentialStatus) {
|
|
856
|
-
if (uniform.credentialStatus.type === "StatusList2021Entry") {
|
|
1112
|
+
if (uniform.credentialStatus.type === "StatusList2021Entry" || uniform.credentialStatus.type === "BitstringStatusListEntry") {
|
|
857
1113
|
return (0, import_vc_status_list2.checkStatus)({
|
|
858
1114
|
...args,
|
|
859
1115
|
verifyStatusListCredential,
|
|
@@ -901,22 +1157,22 @@ async function updateStatusIndexFromStatusListCredential(args, context) {
|
|
|
901
1157
|
return implementation.updateStatusListIndex(args, context);
|
|
902
1158
|
}
|
|
903
1159
|
__name(updateStatusIndexFromStatusListCredential, "updateStatusIndexFromStatusListCredential");
|
|
904
|
-
async function statusListCredentialToDetails(
|
|
905
|
-
const credential = getAssertedValue("statusListCredential",
|
|
1160
|
+
async function statusListCredentialToDetails({ correlationId, driverType, statusListCredential, bitsPerStatus }) {
|
|
1161
|
+
const credential = getAssertedValue("statusListCredential", statusListCredential);
|
|
906
1162
|
let statusListType;
|
|
907
|
-
const documentFormat =
|
|
908
|
-
if (documentFormat ===
|
|
1163
|
+
const documentFormat = import_ssi_types7.CredentialMapper.detectDocumentType(credential);
|
|
1164
|
+
if (documentFormat === import_ssi_types7.DocumentFormat.JWT) {
|
|
909
1165
|
const [header] = credential.split(".");
|
|
910
1166
|
const decodedHeader = JSON.parse(Buffer.from(header, "base64").toString());
|
|
911
1167
|
if (decodedHeader.typ === "statuslist+jwt") {
|
|
912
|
-
statusListType =
|
|
1168
|
+
statusListType = import_ssi_types7.StatusListType.OAuthStatusList;
|
|
913
1169
|
}
|
|
914
|
-
} else if (documentFormat ===
|
|
915
|
-
statusListType =
|
|
1170
|
+
} else if (documentFormat === import_ssi_types7.DocumentFormat.MSO_MDOC) {
|
|
1171
|
+
statusListType = import_ssi_types7.StatusListType.OAuthStatusList;
|
|
916
1172
|
}
|
|
917
1173
|
if (!statusListType) {
|
|
918
|
-
const uniform =
|
|
919
|
-
const type = uniform.type.find((t) => t.includes("StatusList2021") || t.includes("OAuth2StatusList"));
|
|
1174
|
+
const uniform = import_ssi_types7.CredentialMapper.toUniformCredential(credential);
|
|
1175
|
+
const type = uniform.type.find((t) => t.includes("StatusList2021") || t.includes("OAuth2StatusList") || t.includes("BitstringStatusList"));
|
|
920
1176
|
if (!type) {
|
|
921
1177
|
throw new Error("Invalid status list credential type");
|
|
922
1178
|
}
|
|
@@ -925,8 +1181,9 @@ async function statusListCredentialToDetails(args) {
|
|
|
925
1181
|
const implementation = getStatusListImplementation(statusListType);
|
|
926
1182
|
return await implementation.toStatusListDetails({
|
|
927
1183
|
statusListPayload: credential,
|
|
928
|
-
correlationId
|
|
929
|
-
driverType
|
|
1184
|
+
correlationId,
|
|
1185
|
+
driverType,
|
|
1186
|
+
bitsPerStatus
|
|
930
1187
|
});
|
|
931
1188
|
}
|
|
932
1189
|
__name(statusListCredentialToDetails, "statusListCredentialToDetails");
|
|
@@ -944,7 +1201,7 @@ async function statusList2021ToVerifiableCredential(args, context) {
|
|
|
944
1201
|
offlineWhenNoDIDRegistered: true
|
|
945
1202
|
});
|
|
946
1203
|
const proofFormat = args?.proofFormat ?? "lds";
|
|
947
|
-
assertValidProofType(
|
|
1204
|
+
assertValidProofType(import_ssi_types7.StatusListType.StatusList2021, proofFormat);
|
|
948
1205
|
const veramoProofFormat = proofFormat;
|
|
949
1206
|
const encodedList = getAssertedValue("encodedList", args.encodedList);
|
|
950
1207
|
const statusPurpose = getAssertedValue("statusPurpose", args.statusPurpose);
|
|
@@ -973,7 +1230,7 @@ async function statusList2021ToVerifiableCredential(args, context) {
|
|
|
973
1230
|
proofFormat: veramoProofFormat,
|
|
974
1231
|
fetchRemoteContexts: true
|
|
975
1232
|
});
|
|
976
|
-
return
|
|
1233
|
+
return import_ssi_types7.CredentialMapper.toWrappedVerifiableCredential(verifiableCredential).original;
|
|
977
1234
|
}
|
|
978
1235
|
__name(statusList2021ToVerifiableCredential, "statusList2021ToVerifiableCredential");
|
|
979
1236
|
//# sourceMappingURL=index.cjs.map
|