@sphereon/ssi-sdk.vc-status-list 0.34.1-feature.SSISDK.17.bitstring.sl.8 → 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 CHANGED
@@ -61,7 +61,7 @@ var Status2021 = /* @__PURE__ */ function(Status20212) {
61
61
  }({});
62
62
 
63
63
  // src/functions.ts
64
- var import_ssi_types7 = require("@sphereon/ssi-types");
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) {
@@ -266,7 +260,7 @@ var StatusList2021Implementation = class {
266
260
  encodedList: args.encodedList
267
261
  });
268
262
  const index = typeof args.statusListIndex === "number" ? args.statusListIndex : parseInt(args.statusListIndex);
269
- statusList.setStatus(index, args.value !== 0);
263
+ statusList.setStatus(index, args.value);
270
264
  const newEncodedList = await statusList.encode();
271
265
  const credential = await this.createVerifiableCredential({
272
266
  id,
@@ -658,9 +652,6 @@ var OAuthStatusListImplementation = class {
658
652
  if (index < 0 || index >= statusList.statusList.length) {
659
653
  throw new Error("Status list index out of bounds");
660
654
  }
661
- if (typeof value !== "number") {
662
- throw new Error("Status list values should be of type number");
663
- }
664
655
  statusList.setStatus(index, value);
665
656
  const { statusListCredential: signedCredential, encodedList } = await this.createSignedStatusList(proofFormat, context, statusList, issuer, id, expiresAt, keyRef);
666
657
  return {
@@ -688,7 +679,7 @@ var OAuthStatusListImplementation = class {
688
679
  const issuerString = typeof issuer === "string" ? issuer : issuer.id;
689
680
  const listToUpdate = import_jwt_status_list3.StatusList.decompressStatusList(args.encodedList, bitsPerStatus ?? DEFAULT_BITS_PER_STATUS);
690
681
  const index = typeof args.statusListIndex === "number" ? args.statusListIndex : parseInt(args.statusListIndex);
691
- listToUpdate.setStatus(index, args.value);
682
+ listToUpdate.setStatus(index, args.value ? 1 : 0);
692
683
  const { statusListCredential, encodedList } = await this.createSignedStatusList(proofFormat ?? DEFAULT_PROOF_FORMAT2, context, listToUpdate, issuerString, id, expiresAt, keyRef);
693
684
  return {
694
685
  encodedList,
@@ -717,7 +708,7 @@ var OAuthStatusListImplementation = class {
717
708
  const { statusList } = proofFormat === "jwt" ? decodeStatusListJWT(statusListCredential) : decodeStatusListCWT(statusListCredential);
718
709
  const index = typeof statusListIndex === "number" ? statusListIndex : parseInt(statusListIndex);
719
710
  if (index < 0 || index >= statusList.statusList.length) {
720
- throw new Error(`Status list index out of bounds, has ${statusList.statusList.length} items, requested ${index}`);
711
+ throw new Error("Status list index out of bounds");
721
712
  }
722
713
  return statusList.getStatus(index);
723
714
  }
@@ -764,253 +755,7 @@ var OAuthStatusListImplementation = class {
764
755
  };
765
756
 
766
757
  // src/impl/StatusListFactory.ts
767
- var import_ssi_types6 = require("@sphereon/ssi-types");
768
-
769
- // src/impl/BitstringStatusListImplementation.ts
770
758
  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
1014
759
  var StatusListFactory = class _StatusListFactory {
1015
760
  static {
1016
761
  __name(this, "StatusListFactory");
@@ -1019,9 +764,8 @@ var StatusListFactory = class _StatusListFactory {
1019
764
  implementations;
1020
765
  constructor() {
1021
766
  this.implementations = /* @__PURE__ */ new Map();
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());
767
+ this.implementations.set(import_ssi_types5.StatusListType.StatusList2021, new StatusList2021Implementation());
768
+ this.implementations.set(import_ssi_types5.StatusListType.OAuthStatusList, new OAuthStatusListImplementation());
1025
769
  }
1026
770
  static getInstance() {
1027
771
  if (!_StatusListFactory.instance) {
@@ -1094,7 +838,7 @@ __name(vcLibCheckStatusFunction, "vcLibCheckStatusFunction");
1094
838
  async function checkStatusForCredential(args) {
1095
839
  const verifyStatusListCredential = args.verifyStatusListCredential ?? true;
1096
840
  const verifyMatchingIssuers = args.verifyMatchingIssuers ?? true;
1097
- const uniform = import_ssi_types7.CredentialMapper.toUniformCredential(args.credential);
841
+ const uniform = import_ssi_types6.CredentialMapper.toUniformCredential(args.credential);
1098
842
  if (!("credentialStatus" in uniform) || !uniform.credentialStatus) {
1099
843
  if (args.mandatoryCredentialStatus) {
1100
844
  const error = "No credential status object found in the Verifiable Credential and it is mandatory";
@@ -1109,7 +853,7 @@ async function checkStatusForCredential(args) {
1109
853
  };
1110
854
  }
1111
855
  if ("credentialStatus" in uniform && uniform.credentialStatus) {
1112
- if (uniform.credentialStatus.type === "StatusList2021Entry" || uniform.credentialStatus.type === "BitstringStatusListEntry") {
856
+ if (uniform.credentialStatus.type === "StatusList2021Entry") {
1113
857
  return (0, import_vc_status_list2.checkStatus)({
1114
858
  ...args,
1115
859
  verifyStatusListCredential,
@@ -1157,22 +901,22 @@ async function updateStatusIndexFromStatusListCredential(args, context) {
1157
901
  return implementation.updateStatusListIndex(args, context);
1158
902
  }
1159
903
  __name(updateStatusIndexFromStatusListCredential, "updateStatusIndexFromStatusListCredential");
1160
- async function statusListCredentialToDetails({ correlationId, driverType, statusListCredential, bitsPerStatus }) {
1161
- const credential = getAssertedValue("statusListCredential", statusListCredential);
904
+ async function statusListCredentialToDetails(args) {
905
+ const credential = getAssertedValue("statusListCredential", args.statusListCredential);
1162
906
  let statusListType;
1163
- const documentFormat = import_ssi_types7.CredentialMapper.detectDocumentType(credential);
1164
- if (documentFormat === import_ssi_types7.DocumentFormat.JWT) {
907
+ const documentFormat = import_ssi_types6.CredentialMapper.detectDocumentType(credential);
908
+ if (documentFormat === import_ssi_types6.DocumentFormat.JWT) {
1165
909
  const [header] = credential.split(".");
1166
910
  const decodedHeader = JSON.parse(Buffer.from(header, "base64").toString());
1167
911
  if (decodedHeader.typ === "statuslist+jwt") {
1168
- statusListType = import_ssi_types7.StatusListType.OAuthStatusList;
912
+ statusListType = import_ssi_types6.StatusListType.OAuthStatusList;
1169
913
  }
1170
- } else if (documentFormat === import_ssi_types7.DocumentFormat.MSO_MDOC) {
1171
- statusListType = import_ssi_types7.StatusListType.OAuthStatusList;
914
+ } else if (documentFormat === import_ssi_types6.DocumentFormat.MSO_MDOC) {
915
+ statusListType = import_ssi_types6.StatusListType.OAuthStatusList;
1172
916
  }
1173
917
  if (!statusListType) {
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"));
918
+ const uniform = import_ssi_types6.CredentialMapper.toUniformCredential(credential);
919
+ const type = uniform.type.find((t) => t.includes("StatusList2021") || t.includes("OAuth2StatusList"));
1176
920
  if (!type) {
1177
921
  throw new Error("Invalid status list credential type");
1178
922
  }
@@ -1181,9 +925,8 @@ async function statusListCredentialToDetails({ correlationId, driverType, status
1181
925
  const implementation = getStatusListImplementation(statusListType);
1182
926
  return await implementation.toStatusListDetails({
1183
927
  statusListPayload: credential,
1184
- correlationId,
1185
- driverType,
1186
- bitsPerStatus
928
+ correlationId: args.correlationId,
929
+ driverType: args.driverType
1187
930
  });
1188
931
  }
1189
932
  __name(statusListCredentialToDetails, "statusListCredentialToDetails");
@@ -1201,7 +944,7 @@ async function statusList2021ToVerifiableCredential(args, context) {
1201
944
  offlineWhenNoDIDRegistered: true
1202
945
  });
1203
946
  const proofFormat = args?.proofFormat ?? "lds";
1204
- assertValidProofType(import_ssi_types7.StatusListType.StatusList2021, proofFormat);
947
+ assertValidProofType(import_ssi_types6.StatusListType.StatusList2021, proofFormat);
1205
948
  const veramoProofFormat = proofFormat;
1206
949
  const encodedList = getAssertedValue("encodedList", args.encodedList);
1207
950
  const statusPurpose = getAssertedValue("statusPurpose", args.statusPurpose);
@@ -1230,7 +973,7 @@ async function statusList2021ToVerifiableCredential(args, context) {
1230
973
  proofFormat: veramoProofFormat,
1231
974
  fetchRemoteContexts: true
1232
975
  });
1233
- return import_ssi_types7.CredentialMapper.toWrappedVerifiableCredential(verifiableCredential).original;
976
+ return import_ssi_types6.CredentialMapper.toWrappedVerifiableCredential(verifiableCredential).original;
1234
977
  }
1235
978
  __name(statusList2021ToVerifiableCredential, "statusList2021ToVerifiableCredential");
1236
979
  //# sourceMappingURL=index.cjs.map