@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.js CHANGED
@@ -15,7 +15,7 @@ var Status2021 = /* @__PURE__ */ function(Status20212) {
15
15
  }({});
16
16
 
17
17
  // src/functions.ts
18
- import { CredentialMapper as CredentialMapper4, DocumentFormat as DocumentFormat4, StatusListType as StatusListType6 } from "@sphereon/ssi-types";
18
+ import { CredentialMapper as CredentialMapper3, DocumentFormat as DocumentFormat3, StatusListType as StatusListType5 } from "@sphereon/ssi-types";
19
19
  import { checkStatus } from "@sphereon/vc-status-list";
20
20
 
21
21
  // src/utils.ts
@@ -25,8 +25,7 @@ function getAssertedStatusListType(type) {
25
25
  const assertedType = type ?? StatusListType.StatusList2021;
26
26
  if (![
27
27
  StatusListType.StatusList2021,
28
- StatusListType.OAuthStatusList,
29
- StatusListType.BitstringStatusList
28
+ StatusListType.OAuthStatusList
30
29
  ].includes(assertedType)) {
31
30
  throw Error(`StatusList type ${assertedType} is not supported (yet)`);
32
31
  }
@@ -63,7 +62,8 @@ var ValidProofTypeMap = /* @__PURE__ */ new Map([
63
62
  StatusListType.StatusList2021,
64
63
  [
65
64
  "jwt",
66
- "lds"
65
+ "lds",
66
+ "EthereumEip712Signature2021"
67
67
  ]
68
68
  ],
69
69
  [
@@ -72,12 +72,6 @@ var ValidProofTypeMap = /* @__PURE__ */ new Map([
72
72
  "jwt",
73
73
  "cbor"
74
74
  ]
75
- ],
76
- [
77
- StatusListType.BitstringStatusList,
78
- [
79
- "lds"
80
- ]
81
75
  ]
82
76
  ]);
83
77
  function assertValidProofType(type, proofFormat) {
@@ -220,7 +214,7 @@ var StatusList2021Implementation = class {
220
214
  encodedList: args.encodedList
221
215
  });
222
216
  const index = typeof args.statusListIndex === "number" ? args.statusListIndex : parseInt(args.statusListIndex);
223
- statusList.setStatus(index, args.value !== 0);
217
+ statusList.setStatus(index, args.value);
224
218
  const newEncodedList = await statusList.encode();
225
219
  const credential = await this.createVerifiableCredential({
226
220
  id,
@@ -612,9 +606,6 @@ var OAuthStatusListImplementation = class {
612
606
  if (index < 0 || index >= statusList.statusList.length) {
613
607
  throw new Error("Status list index out of bounds");
614
608
  }
615
- if (typeof value !== "number") {
616
- throw new Error("Status list values should be of type number");
617
- }
618
609
  statusList.setStatus(index, value);
619
610
  const { statusListCredential: signedCredential, encodedList } = await this.createSignedStatusList(proofFormat, context, statusList, issuer, id, expiresAt, keyRef);
620
611
  return {
@@ -642,7 +633,7 @@ var OAuthStatusListImplementation = class {
642
633
  const issuerString = typeof issuer === "string" ? issuer : issuer.id;
643
634
  const listToUpdate = StatusList4.decompressStatusList(args.encodedList, bitsPerStatus ?? DEFAULT_BITS_PER_STATUS);
644
635
  const index = typeof args.statusListIndex === "number" ? args.statusListIndex : parseInt(args.statusListIndex);
645
- listToUpdate.setStatus(index, args.value);
636
+ listToUpdate.setStatus(index, args.value ? 1 : 0);
646
637
  const { statusListCredential, encodedList } = await this.createSignedStatusList(proofFormat ?? DEFAULT_PROOF_FORMAT2, context, listToUpdate, issuerString, id, expiresAt, keyRef);
647
638
  return {
648
639
  encodedList,
@@ -671,7 +662,7 @@ var OAuthStatusListImplementation = class {
671
662
  const { statusList } = proofFormat === "jwt" ? decodeStatusListJWT(statusListCredential) : decodeStatusListCWT(statusListCredential);
672
663
  const index = typeof statusListIndex === "number" ? statusListIndex : parseInt(statusListIndex);
673
664
  if (index < 0 || index >= statusList.statusList.length) {
674
- throw new Error(`Status list index out of bounds, has ${statusList.statusList.length} items, requested ${index}`);
665
+ throw new Error("Status list index out of bounds");
675
666
  }
676
667
  return statusList.getStatus(index);
677
668
  }
@@ -718,253 +709,7 @@ var OAuthStatusListImplementation = class {
718
709
  };
719
710
 
720
711
  // src/impl/StatusListFactory.ts
721
- import { StatusListType as StatusListType5 } from "@sphereon/ssi-types";
722
-
723
- // src/impl/BitstringStatusListImplementation.ts
724
- import { CredentialMapper as CredentialMapper3, DocumentFormat as DocumentFormat3, StatusListType as StatusListType4 } from "@sphereon/ssi-types";
725
- import { BitstreamStatusList, createStatusListCredential } from "@4sure-tech/vc-bitstring-status-lists";
726
- var DEFAULT_LIST_LENGTH3 = 131072;
727
- var DEFAULT_PROOF_FORMAT3 = "lds";
728
- var DEFAULT_STATUS_PURPOSE = "revocation";
729
- var BitstringStatusListImplementation = class {
730
- static {
731
- __name(this, "BitstringStatusListImplementation");
732
- }
733
- async createNewStatusList(args, context) {
734
- if (!args.bitstringStatusList) {
735
- throw new Error("BitstringStatusList options are required for type BitstringStatusList");
736
- }
737
- const length = args?.length ?? DEFAULT_LIST_LENGTH3;
738
- const proofFormat = args?.proofFormat ?? DEFAULT_PROOF_FORMAT3;
739
- assertValidProofType(StatusListType4.BitstringStatusList, proofFormat);
740
- const veramoProofFormat = proofFormat;
741
- const { issuer, id } = args;
742
- const correlationId = getAssertedValue("correlationId", args.correlationId);
743
- const { statusPurpose, bitsPerStatus, validFrom, validUntil, ttl } = args.bitstringStatusList;
744
- const statusListCredential = await this.createVerifiableCredential({
745
- ...args,
746
- proofFormat: veramoProofFormat,
747
- statusPurpose: statusPurpose ?? DEFAULT_STATUS_PURPOSE,
748
- validFrom,
749
- validUntil,
750
- ttl
751
- }, context);
752
- return {
753
- encodedList: statusListCredential.credentialSubject.encodedList,
754
- statusListCredential,
755
- bitstringStatusList: {
756
- statusPurpose: statusPurpose ?? DEFAULT_STATUS_PURPOSE,
757
- ...statusListCredential.validFrom && {
758
- validFrom: new Date(statusListCredential.validFrom)
759
- },
760
- ...statusListCredential.validUntil && {
761
- validUntil: new Date(statusListCredential.validUntil)
762
- },
763
- ttl,
764
- bitsPerStatus
765
- },
766
- length,
767
- type: StatusListType4.BitstringStatusList,
768
- proofFormat,
769
- id,
770
- correlationId,
771
- issuer,
772
- statuslistContentType: this.buildContentType(proofFormat)
773
- };
774
- }
775
- async updateStatusListIndex(args, context) {
776
- if (!args.bitsPerStatus || args.bitsPerStatus < 1) {
777
- return Promise.reject("bitsPerStatus must be set for bitstring status lists and must be 1 or higher. (updateStatusListIndex)");
778
- }
779
- const credential = args.statusListCredential;
780
- const uniform = CredentialMapper3.toUniformCredential(credential);
781
- const { issuer, credentialSubject } = uniform;
782
- const id = getAssertedValue("id", uniform.id);
783
- const origEncodedList = getAssertedProperty("encodedList", credentialSubject);
784
- const index = typeof args.statusListIndex === "number" ? args.statusListIndex : parseInt(args.statusListIndex);
785
- const statusList = await BitstreamStatusList.decode({
786
- encodedList: origEncodedList,
787
- statusSize: args.bitsPerStatus
788
- });
789
- statusList.setStatus(index, args.value);
790
- const proofFormat = CredentialMapper3.detectDocumentType(credential) === DocumentFormat3.JWT ? "jwt" : "lds";
791
- const credSubject = Array.isArray(credentialSubject) ? credentialSubject[0] : credentialSubject;
792
- const statusPurpose = getAssertedProperty("statusPurpose", credSubject);
793
- const validFrom = uniform.validFrom ? new Date(uniform.validFrom) : void 0;
794
- const validUntil = uniform.validUntil ? new Date(uniform.validUntil) : void 0;
795
- const ttl = credSubject.ttl;
796
- const updatedCredential = await this.createVerifiableCredential({
797
- ...args,
798
- id,
799
- issuer,
800
- statusList,
801
- proofFormat,
802
- statusPurpose,
803
- ttl,
804
- validFrom,
805
- validUntil
806
- }, context);
807
- return {
808
- statusListCredential: updatedCredential,
809
- encodedList: updatedCredential.credentialSubject.encodedList,
810
- bitstringStatusList: {
811
- statusPurpose,
812
- ...updatedCredential.validFrom && {
813
- validFrom: new Date(updatedCredential.validFrom)
814
- },
815
- ...updatedCredential.validUntil && {
816
- validUntil: new Date(updatedCredential.validUntil)
817
- },
818
- bitsPerStatus: args.bitsPerStatus,
819
- ttl
820
- },
821
- length: statusList.getLength(),
822
- type: StatusListType4.BitstringStatusList,
823
- proofFormat,
824
- id,
825
- issuer,
826
- statuslistContentType: this.buildContentType(proofFormat)
827
- };
828
- }
829
- async updateStatusListFromEncodedList(args, context) {
830
- if (!args.bitstringStatusList) {
831
- throw new Error("bitstringStatusList options required for type BitstringStatusList");
832
- }
833
- if (args.bitstringStatusList.bitsPerStatus < 1) {
834
- return Promise.reject("bitsPerStatus must be set for bitstring status lists and must be 1 or higher. (updateStatusListFromEncodedList)");
835
- }
836
- const { statusPurpose, bitsPerStatus, ttl, validFrom, validUntil } = args.bitstringStatusList;
837
- const proofFormat = args?.proofFormat ?? DEFAULT_PROOF_FORMAT3;
838
- assertValidProofType(StatusListType4.BitstringStatusList, proofFormat);
839
- const veramoProofFormat = proofFormat;
840
- const { issuer, id } = getAssertedValues(args);
841
- const statusList = await BitstreamStatusList.decode({
842
- encodedList: args.encodedList,
843
- statusSize: bitsPerStatus
844
- });
845
- const index = typeof args.statusListIndex === "number" ? args.statusListIndex : parseInt(args.statusListIndex);
846
- statusList.setStatus(index, args.value);
847
- const credential = await this.createVerifiableCredential({
848
- id,
849
- issuer,
850
- statusList,
851
- proofFormat: veramoProofFormat,
852
- keyRef: args.keyRef,
853
- statusPurpose,
854
- validFrom,
855
- validUntil,
856
- ttl
857
- }, context);
858
- return {
859
- type: StatusListType4.BitstringStatusList,
860
- statusListCredential: credential,
861
- encodedList: credential.credentialSubject.encodedList,
862
- bitstringStatusList: {
863
- statusPurpose,
864
- bitsPerStatus,
865
- ...credential.validFrom && {
866
- validFrom: new Date(credential.validFrom)
867
- },
868
- ...credential.validUntil && {
869
- validUntil: new Date(credential.validUntil)
870
- },
871
- ttl
872
- },
873
- length: statusList.getLength(),
874
- proofFormat: args.proofFormat ?? "lds",
875
- id,
876
- issuer,
877
- statuslistContentType: this.buildContentType(proofFormat)
878
- };
879
- }
880
- async checkStatusIndex(args) {
881
- if (!args.bitsPerStatus || args.bitsPerStatus < 1) {
882
- return Promise.reject("bitsPerStatus must be set for bitstring status lists and must be 1 or higher. (checkStatusIndex)");
883
- }
884
- const uniform = CredentialMapper3.toUniformCredential(args.statusListCredential);
885
- const { credentialSubject } = uniform;
886
- const encodedList = getAssertedProperty("encodedList", credentialSubject);
887
- const statusSize = args.bitsPerStatus;
888
- const statusList = await BitstreamStatusList.decode({
889
- encodedList,
890
- statusSize
891
- });
892
- const numIndex = typeof args.statusListIndex === "number" ? args.statusListIndex : parseInt(args.statusListIndex);
893
- if (statusList.getLength() <= numIndex) {
894
- throw new Error(`Status list index out of bounds, has ${statusList.getLength()} entries, requested ${numIndex}`);
895
- }
896
- return statusList.getStatus(numIndex);
897
- }
898
- async toStatusListDetails(args) {
899
- const { statusListPayload, bitsPerStatus } = args;
900
- if (!bitsPerStatus || bitsPerStatus < 1) {
901
- return Promise.reject("bitsPerStatus must be set for bitstring status lists and must be 1 or higher. (toStatusListDetails)");
902
- }
903
- const uniform = CredentialMapper3.toUniformCredential(statusListPayload);
904
- const { issuer, credentialSubject } = uniform;
905
- const id = getAssertedValue("id", uniform.id);
906
- const encodedList = getAssertedProperty("encodedList", credentialSubject);
907
- const proofFormat = CredentialMapper3.detectDocumentType(statusListPayload) === DocumentFormat3.JWT ? "jwt" : "lds";
908
- const credSubject = Array.isArray(credentialSubject) ? credentialSubject[0] : credentialSubject;
909
- const statusPurpose = getAssertedProperty("statusPurpose", credSubject);
910
- const validFrom = uniform.validFrom ? new Date(uniform.validFrom) : void 0;
911
- const validUntil = uniform.validUntil ? new Date(uniform.validUntil) : void 0;
912
- const ttl = credSubject.ttl;
913
- const statuslistLength = BitstreamStatusList.getStatusListLength(encodedList, bitsPerStatus);
914
- return {
915
- id,
916
- encodedList,
917
- issuer,
918
- type: StatusListType4.BitstringStatusList,
919
- proofFormat,
920
- length: statuslistLength,
921
- statusListCredential: statusListPayload,
922
- statuslistContentType: this.buildContentType(proofFormat),
923
- bitstringStatusList: {
924
- statusPurpose,
925
- bitsPerStatus,
926
- validFrom,
927
- validUntil,
928
- ttl
929
- },
930
- ...args.correlationId && {
931
- correlationId: args.correlationId
932
- },
933
- ...args.driverType && {
934
- driverType: args.driverType
935
- }
936
- };
937
- }
938
- async createVerifiableCredential(args, context) {
939
- const identifier = await context.agent.identifierManagedGet({
940
- identifier: typeof args.issuer === "string" ? args.issuer : args.issuer.id,
941
- vmRelationship: "assertionMethod",
942
- offlineWhenNoDIDRegistered: true
943
- });
944
- const unsignedCredential = await createStatusListCredential(args);
945
- const verifiableCredential = await context.agent.createVerifiableCredential({
946
- credential: unsignedCredential,
947
- keyRef: args.keyRef ?? identifier.kmsKeyRef,
948
- proofFormat: args.proofFormat,
949
- fetchRemoteContexts: true
950
- });
951
- return CredentialMapper3.toWrappedVerifiableCredential(verifiableCredential).original;
952
- }
953
- buildContentType(proofFormat) {
954
- switch (proofFormat) {
955
- case "jwt":
956
- return `application/statuslist+jwt`;
957
- case "cbor":
958
- return `application/statuslist+cwt`;
959
- case "lds":
960
- return "application/statuslist+ld+json";
961
- default:
962
- throw Error(`Unsupported content type '${proofFormat}' for status lists`);
963
- }
964
- }
965
- };
966
-
967
- // src/impl/StatusListFactory.ts
712
+ import { StatusListType as StatusListType4 } from "@sphereon/ssi-types";
968
713
  var StatusListFactory = class _StatusListFactory {
969
714
  static {
970
715
  __name(this, "StatusListFactory");
@@ -973,9 +718,8 @@ var StatusListFactory = class _StatusListFactory {
973
718
  implementations;
974
719
  constructor() {
975
720
  this.implementations = /* @__PURE__ */ new Map();
976
- this.implementations.set(StatusListType5.StatusList2021, new StatusList2021Implementation());
977
- this.implementations.set(StatusListType5.OAuthStatusList, new OAuthStatusListImplementation());
978
- this.implementations.set(StatusListType5.BitstringStatusList, new BitstringStatusListImplementation());
721
+ this.implementations.set(StatusListType4.StatusList2021, new StatusList2021Implementation());
722
+ this.implementations.set(StatusListType4.OAuthStatusList, new OAuthStatusListImplementation());
979
723
  }
980
724
  static getInstance() {
981
725
  if (!_StatusListFactory.instance) {
@@ -1048,7 +792,7 @@ __name(vcLibCheckStatusFunction, "vcLibCheckStatusFunction");
1048
792
  async function checkStatusForCredential(args) {
1049
793
  const verifyStatusListCredential = args.verifyStatusListCredential ?? true;
1050
794
  const verifyMatchingIssuers = args.verifyMatchingIssuers ?? true;
1051
- const uniform = CredentialMapper4.toUniformCredential(args.credential);
795
+ const uniform = CredentialMapper3.toUniformCredential(args.credential);
1052
796
  if (!("credentialStatus" in uniform) || !uniform.credentialStatus) {
1053
797
  if (args.mandatoryCredentialStatus) {
1054
798
  const error = "No credential status object found in the Verifiable Credential and it is mandatory";
@@ -1063,7 +807,7 @@ async function checkStatusForCredential(args) {
1063
807
  };
1064
808
  }
1065
809
  if ("credentialStatus" in uniform && uniform.credentialStatus) {
1066
- if (uniform.credentialStatus.type === "StatusList2021Entry" || uniform.credentialStatus.type === "BitstringStatusListEntry") {
810
+ if (uniform.credentialStatus.type === "StatusList2021Entry") {
1067
811
  return checkStatus({
1068
812
  ...args,
1069
813
  verifyStatusListCredential,
@@ -1111,22 +855,22 @@ async function updateStatusIndexFromStatusListCredential(args, context) {
1111
855
  return implementation.updateStatusListIndex(args, context);
1112
856
  }
1113
857
  __name(updateStatusIndexFromStatusListCredential, "updateStatusIndexFromStatusListCredential");
1114
- async function statusListCredentialToDetails({ correlationId, driverType, statusListCredential, bitsPerStatus }) {
1115
- const credential = getAssertedValue("statusListCredential", statusListCredential);
858
+ async function statusListCredentialToDetails(args) {
859
+ const credential = getAssertedValue("statusListCredential", args.statusListCredential);
1116
860
  let statusListType;
1117
- const documentFormat = CredentialMapper4.detectDocumentType(credential);
1118
- if (documentFormat === DocumentFormat4.JWT) {
861
+ const documentFormat = CredentialMapper3.detectDocumentType(credential);
862
+ if (documentFormat === DocumentFormat3.JWT) {
1119
863
  const [header] = credential.split(".");
1120
864
  const decodedHeader = JSON.parse(Buffer.from(header, "base64").toString());
1121
865
  if (decodedHeader.typ === "statuslist+jwt") {
1122
- statusListType = StatusListType6.OAuthStatusList;
866
+ statusListType = StatusListType5.OAuthStatusList;
1123
867
  }
1124
- } else if (documentFormat === DocumentFormat4.MSO_MDOC) {
1125
- statusListType = StatusListType6.OAuthStatusList;
868
+ } else if (documentFormat === DocumentFormat3.MSO_MDOC) {
869
+ statusListType = StatusListType5.OAuthStatusList;
1126
870
  }
1127
871
  if (!statusListType) {
1128
- const uniform = CredentialMapper4.toUniformCredential(credential);
1129
- const type = uniform.type.find((t) => t.includes("StatusList2021") || t.includes("OAuth2StatusList") || t.includes("BitstringStatusList"));
872
+ const uniform = CredentialMapper3.toUniformCredential(credential);
873
+ const type = uniform.type.find((t) => t.includes("StatusList2021") || t.includes("OAuth2StatusList"));
1130
874
  if (!type) {
1131
875
  throw new Error("Invalid status list credential type");
1132
876
  }
@@ -1135,9 +879,8 @@ async function statusListCredentialToDetails({ correlationId, driverType, status
1135
879
  const implementation = getStatusListImplementation(statusListType);
1136
880
  return await implementation.toStatusListDetails({
1137
881
  statusListPayload: credential,
1138
- correlationId,
1139
- driverType,
1140
- bitsPerStatus
882
+ correlationId: args.correlationId,
883
+ driverType: args.driverType
1141
884
  });
1142
885
  }
1143
886
  __name(statusListCredentialToDetails, "statusListCredentialToDetails");
@@ -1155,7 +898,7 @@ async function statusList2021ToVerifiableCredential(args, context) {
1155
898
  offlineWhenNoDIDRegistered: true
1156
899
  });
1157
900
  const proofFormat = args?.proofFormat ?? "lds";
1158
- assertValidProofType(StatusListType6.StatusList2021, proofFormat);
901
+ assertValidProofType(StatusListType5.StatusList2021, proofFormat);
1159
902
  const veramoProofFormat = proofFormat;
1160
903
  const encodedList = getAssertedValue("encodedList", args.encodedList);
1161
904
  const statusPurpose = getAssertedValue("statusPurpose", args.statusPurpose);
@@ -1184,7 +927,7 @@ async function statusList2021ToVerifiableCredential(args, context) {
1184
927
  proofFormat: veramoProofFormat,
1185
928
  fetchRemoteContexts: true
1186
929
  });
1187
- return CredentialMapper4.toWrappedVerifiableCredential(verifiableCredential).original;
930
+ return CredentialMapper3.toWrappedVerifiableCredential(verifiableCredential).original;
1188
931
  }
1189
932
  __name(statusList2021ToVerifiableCredential, "statusList2021ToVerifiableCredential");
1190
933
  export {