@sphereon/ssi-sdk.vc-status-list 0.34.1-feature.SSISDK.17.bitstring.sl.2 → 0.34.1-next.5

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
@@ -108,7 +108,8 @@ var ValidProofTypeMap = /* @__PURE__ */ new Map([
108
108
  import_ssi_types.StatusListType.StatusList2021,
109
109
  [
110
110
  "jwt",
111
- "lds"
111
+ "lds",
112
+ "EthereumEip712Signature2021"
112
113
  ]
113
114
  ],
114
115
  [
@@ -651,9 +652,6 @@ var OAuthStatusListImplementation = class {
651
652
  if (index < 0 || index >= statusList.statusList.length) {
652
653
  throw new Error("Status list index out of bounds");
653
654
  }
654
- if (typeof value !== "number") {
655
- throw new Error("Status list values should be of type number");
656
- }
657
655
  statusList.setStatus(index, value);
658
656
  const { statusListCredential: signedCredential, encodedList } = await this.createSignedStatusList(proofFormat, context, statusList, issuer, id, expiresAt, keyRef);
659
657
  return {
@@ -710,7 +708,7 @@ var OAuthStatusListImplementation = class {
710
708
  const { statusList } = proofFormat === "jwt" ? decodeStatusListJWT(statusListCredential) : decodeStatusListCWT(statusListCredential);
711
709
  const index = typeof statusListIndex === "number" ? statusListIndex : parseInt(statusListIndex);
712
710
  if (index < 0 || index >= statusList.statusList.length) {
713
- 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");
714
712
  }
715
713
  return statusList.getStatus(index);
716
714
  }
@@ -757,274 +755,7 @@ var OAuthStatusListImplementation = class {
757
755
  };
758
756
 
759
757
  // src/impl/StatusListFactory.ts
760
- var import_ssi_types6 = require("@sphereon/ssi-types");
761
-
762
- // src/impl/BitstringStatusListImplementation.ts
763
758
  var import_ssi_types5 = require("@sphereon/ssi-types");
764
- var import_vc_bitstring_status_list = require("@digitalbazaar/vc-bitstring-status-list");
765
- var DEFAULT_LIST_LENGTH3 = 131072;
766
- var DEFAULT_PROOF_FORMAT3 = "lds";
767
- var DEFAULT_STATUS_SIZE = 1;
768
- var DEFAULT_STATUS_PURPOSE = "revocation";
769
- var BitstringStatusListImplementation = class {
770
- static {
771
- __name(this, "BitstringStatusListImplementation");
772
- }
773
- async createNewStatusList(args, context) {
774
- if (!args.bitstringStatusList) {
775
- throw new Error("BitstringStatusList options are required for type BitstringStatusList");
776
- }
777
- const length = args?.length ?? DEFAULT_LIST_LENGTH3;
778
- const proofFormat = args?.proofFormat ?? DEFAULT_PROOF_FORMAT3;
779
- assertValidProofType(import_ssi_types5.StatusListType.BitstringStatusList, proofFormat);
780
- const veramoProofFormat = proofFormat;
781
- const { issuer, id } = args;
782
- const correlationId = getAssertedValue("correlationId", args.correlationId);
783
- const { statusPurpose, statusSize, statusMessage, ttl } = args.bitstringStatusList;
784
- const list = await (0, import_vc_bitstring_status_list.createList)({
785
- length
786
- });
787
- const encodedList = await list.encode();
788
- const statusListCredential = await this.createVerifiableCredential({
789
- ...args,
790
- encodedList,
791
- proofFormat: veramoProofFormat,
792
- statusPurpose: statusPurpose ?? DEFAULT_STATUS_PURPOSE,
793
- statusSize: statusSize ?? DEFAULT_STATUS_SIZE,
794
- statusMessage,
795
- ttl
796
- }, context);
797
- return {
798
- encodedList,
799
- statusListCredential,
800
- bitstringStatusList: {
801
- statusPurpose: statusPurpose ?? DEFAULT_STATUS_PURPOSE,
802
- ttl
803
- },
804
- length,
805
- type: import_ssi_types5.StatusListType.BitstringStatusList,
806
- proofFormat,
807
- id,
808
- correlationId,
809
- issuer,
810
- statuslistContentType: this.buildContentType(proofFormat)
811
- };
812
- }
813
- async updateStatusListIndex(args, context) {
814
- const credential = args.statusListCredential;
815
- const uniform = import_ssi_types5.CredentialMapper.toUniformCredential(credential);
816
- const { issuer, credentialSubject } = uniform;
817
- const id = getAssertedValue("id", uniform.id);
818
- const origEncodedList = getAssertedProperty("encodedList", credentialSubject);
819
- const index = typeof args.statusListIndex === "number" ? args.statusListIndex : parseInt(args.statusListIndex);
820
- const statusList = await (0, import_vc_bitstring_status_list.decodeList)({
821
- encodedList: origEncodedList
822
- });
823
- statusList.setStatus(index, args.value != 0);
824
- const encodedList = await statusList.encode();
825
- const proofFormat = import_ssi_types5.CredentialMapper.detectDocumentType(credential) === import_ssi_types5.DocumentFormat.JWT ? "jwt" : "lds";
826
- const credSubject = Array.isArray(credentialSubject) ? credentialSubject[0] : credentialSubject;
827
- const statusPurpose = getAssertedProperty("statusPurpose", credSubject);
828
- const validFrom = uniform.validFrom ? new Date(uniform.validFrom) : void 0;
829
- const validUntil = uniform.validUntil ? new Date(uniform.validUntil) : void 0;
830
- const ttl = credSubject.ttl;
831
- const updatedCredential = await this.createVerifiableCredential({
832
- ...args,
833
- id,
834
- issuer,
835
- encodedList,
836
- proofFormat,
837
- statusPurpose,
838
- ttl,
839
- validFrom,
840
- validUntil
841
- }, context);
842
- return {
843
- statusListCredential: updatedCredential,
844
- encodedList,
845
- bitstringStatusList: {
846
- statusPurpose,
847
- validFrom,
848
- validUntil,
849
- ttl
850
- },
851
- length: statusList.length - 1,
852
- type: import_ssi_types5.StatusListType.BitstringStatusList,
853
- proofFormat,
854
- id,
855
- issuer,
856
- statuslistContentType: this.buildContentType(proofFormat)
857
- };
858
- }
859
- async updateStatusListFromEncodedList(args, context) {
860
- if (!args.bitstringStatusList) {
861
- throw new Error("bitstringStatusList options required for type BitstringStatusList");
862
- }
863
- const proofFormat = args?.proofFormat ?? DEFAULT_PROOF_FORMAT3;
864
- assertValidProofType(import_ssi_types5.StatusListType.BitstringStatusList, proofFormat);
865
- const veramoProofFormat = proofFormat;
866
- const { issuer, id } = getAssertedValues(args);
867
- const statusList = await (0, import_vc_bitstring_status_list.decodeList)({
868
- encodedList: args.encodedList
869
- });
870
- const index = typeof args.statusListIndex === "number" ? args.statusListIndex : parseInt(args.statusListIndex);
871
- statusList.setStatus(index, args.value);
872
- const newEncodedList = await statusList.encode();
873
- const { statusPurpose, statusSize, statusMessage, ttl, validFrom, validUntil } = args.bitstringStatusList;
874
- const credential = await this.createVerifiableCredential({
875
- id,
876
- issuer,
877
- encodedList: newEncodedList,
878
- proofFormat: veramoProofFormat,
879
- keyRef: args.keyRef,
880
- statusPurpose,
881
- statusSize,
882
- statusMessage,
883
- validFrom,
884
- validUntil,
885
- ttl
886
- }, context);
887
- return {
888
- type: import_ssi_types5.StatusListType.BitstringStatusList,
889
- statusListCredential: credential,
890
- encodedList: newEncodedList,
891
- bitstringStatusList: {
892
- statusPurpose,
893
- validFrom,
894
- validUntil,
895
- ttl
896
- },
897
- length: statusList.length,
898
- proofFormat: args.proofFormat ?? "lds",
899
- id,
900
- issuer,
901
- statuslistContentType: this.buildContentType(proofFormat)
902
- };
903
- }
904
- async checkStatusIndex(args) {
905
- const uniform = import_ssi_types5.CredentialMapper.toUniformCredential(args.statusListCredential);
906
- const { credentialSubject } = uniform;
907
- const encodedList = getAssertedProperty("encodedList", credentialSubject);
908
- const subject = Array.isArray(credentialSubject) ? credentialSubject[0] : credentialSubject;
909
- const messageList = subject.statusMessage;
910
- const numIndex = typeof args.statusListIndex === "number" ? args.statusListIndex : parseInt(args.statusListIndex);
911
- const hexIndex = `0x${numIndex.toString(16)}`;
912
- const statusMessage = messageList.find((statMsg) => statMsg.status === hexIndex);
913
- const statusList = await (0, import_vc_bitstring_status_list.decodeList)({
914
- encodedList
915
- });
916
- if (statusList.length <= numIndex) {
917
- throw new Error(`Status list index out of bounds, has ${messageList.length} messages, requested ${numIndex}`);
918
- }
919
- const value = statusList.getStatus(numIndex);
920
- return {
921
- index: numIndex,
922
- status: hexIndex,
923
- message: statusMessage?.message,
924
- set: value
925
- };
926
- }
927
- async toStatusListDetails(args) {
928
- const { statusListPayload } = args;
929
- const uniform = import_ssi_types5.CredentialMapper.toUniformCredential(statusListPayload);
930
- const { issuer, credentialSubject } = uniform;
931
- const id = getAssertedValue("id", uniform.id);
932
- const encodedList = getAssertedProperty("encodedList", credentialSubject);
933
- const proofFormat = import_ssi_types5.CredentialMapper.detectDocumentType(statusListPayload) === import_ssi_types5.DocumentFormat.JWT ? "jwt" : "lds";
934
- const credSubject = Array.isArray(credentialSubject) ? credentialSubject[0] : credentialSubject;
935
- const statusPurpose = getAssertedProperty("statusPurpose", credSubject);
936
- const validFrom = uniform.validFrom ? new Date(uniform.validFrom) : void 0;
937
- const validUntil = uniform.validUntil ? new Date(uniform.validUntil) : void 0;
938
- const ttl = credSubject.ttl;
939
- const list = await (0, import_vc_bitstring_status_list.decodeList)({
940
- encodedList
941
- });
942
- return {
943
- id,
944
- encodedList,
945
- issuer,
946
- type: import_ssi_types5.StatusListType.BitstringStatusList,
947
- proofFormat,
948
- length: list.length,
949
- statusListCredential: statusListPayload,
950
- statuslistContentType: this.buildContentType(proofFormat),
951
- bitstringStatusList: {
952
- statusPurpose,
953
- validFrom,
954
- validUntil,
955
- ttl
956
- },
957
- ...args.correlationId && {
958
- correlationId: args.correlationId
959
- },
960
- ...args.driverType && {
961
- driverType: args.driverType
962
- }
963
- };
964
- }
965
- async createVerifiableCredential(args, context) {
966
- const identifier = await context.agent.identifierManagedGet({
967
- identifier: typeof args.issuer === "string" ? args.issuer : args.issuer.id,
968
- vmRelationship: "assertionMethod",
969
- offlineWhenNoDIDRegistered: true
970
- });
971
- const credentialSubject = {
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
- };
1005
- const verifiableCredential = await context.agent.createVerifiableCredential({
1006
- credential,
1007
- keyRef: args.keyRef ?? identifier.kmsKeyRef,
1008
- proofFormat: args.proofFormat,
1009
- fetchRemoteContexts: true
1010
- });
1011
- return import_ssi_types5.CredentialMapper.toWrappedVerifiableCredential(verifiableCredential).original;
1012
- }
1013
- buildContentType(proofFormat) {
1014
- switch (proofFormat) {
1015
- case "jwt":
1016
- return `application/statuslist+jwt`;
1017
- case "cbor":
1018
- return `application/statuslist+cwt`;
1019
- case "lds":
1020
- return "application/statuslist+ld+json";
1021
- default:
1022
- throw Error(`Unsupported content type '${proofFormat}' for status lists`);
1023
- }
1024
- }
1025
- };
1026
-
1027
- // src/impl/StatusListFactory.ts
1028
759
  var StatusListFactory = class _StatusListFactory {
1029
760
  static {
1030
761
  __name(this, "StatusListFactory");
@@ -1033,9 +764,8 @@ var StatusListFactory = class _StatusListFactory {
1033
764
  implementations;
1034
765
  constructor() {
1035
766
  this.implementations = /* @__PURE__ */ new Map();
1036
- this.implementations.set(import_ssi_types6.StatusListType.StatusList2021, new StatusList2021Implementation());
1037
- this.implementations.set(import_ssi_types6.StatusListType.OAuthStatusList, new OAuthStatusListImplementation());
1038
- 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());
1039
769
  }
1040
770
  static getInstance() {
1041
771
  if (!_StatusListFactory.instance) {
@@ -1108,7 +838,7 @@ __name(vcLibCheckStatusFunction, "vcLibCheckStatusFunction");
1108
838
  async function checkStatusForCredential(args) {
1109
839
  const verifyStatusListCredential = args.verifyStatusListCredential ?? true;
1110
840
  const verifyMatchingIssuers = args.verifyMatchingIssuers ?? true;
1111
- const uniform = import_ssi_types7.CredentialMapper.toUniformCredential(args.credential);
841
+ const uniform = import_ssi_types6.CredentialMapper.toUniformCredential(args.credential);
1112
842
  if (!("credentialStatus" in uniform) || !uniform.credentialStatus) {
1113
843
  if (args.mandatoryCredentialStatus) {
1114
844
  const error = "No credential status object found in the Verifiable Credential and it is mandatory";
@@ -1123,7 +853,7 @@ async function checkStatusForCredential(args) {
1123
853
  };
1124
854
  }
1125
855
  if ("credentialStatus" in uniform && uniform.credentialStatus) {
1126
- if (uniform.credentialStatus.type === "StatusList2021Entry" || uniform.credentialStatus.type === "BitstringStatusListEntry") {
856
+ if (uniform.credentialStatus.type === "StatusList2021Entry") {
1127
857
  return (0, import_vc_status_list2.checkStatus)({
1128
858
  ...args,
1129
859
  verifyStatusListCredential,
@@ -1174,19 +904,19 @@ __name(updateStatusIndexFromStatusListCredential, "updateStatusIndexFromStatusLi
1174
904
  async function statusListCredentialToDetails(args) {
1175
905
  const credential = getAssertedValue("statusListCredential", args.statusListCredential);
1176
906
  let statusListType;
1177
- const documentFormat = import_ssi_types7.CredentialMapper.detectDocumentType(credential);
1178
- if (documentFormat === import_ssi_types7.DocumentFormat.JWT) {
907
+ const documentFormat = import_ssi_types6.CredentialMapper.detectDocumentType(credential);
908
+ if (documentFormat === import_ssi_types6.DocumentFormat.JWT) {
1179
909
  const [header] = credential.split(".");
1180
910
  const decodedHeader = JSON.parse(Buffer.from(header, "base64").toString());
1181
911
  if (decodedHeader.typ === "statuslist+jwt") {
1182
- statusListType = import_ssi_types7.StatusListType.OAuthStatusList;
912
+ statusListType = import_ssi_types6.StatusListType.OAuthStatusList;
1183
913
  }
1184
- } else if (documentFormat === import_ssi_types7.DocumentFormat.MSO_MDOC) {
1185
- statusListType = import_ssi_types7.StatusListType.OAuthStatusList;
914
+ } else if (documentFormat === import_ssi_types6.DocumentFormat.MSO_MDOC) {
915
+ statusListType = import_ssi_types6.StatusListType.OAuthStatusList;
1186
916
  }
1187
917
  if (!statusListType) {
1188
- const uniform = import_ssi_types7.CredentialMapper.toUniformCredential(credential);
1189
- 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"));
1190
920
  if (!type) {
1191
921
  throw new Error("Invalid status list credential type");
1192
922
  }
@@ -1214,7 +944,7 @@ async function statusList2021ToVerifiableCredential(args, context) {
1214
944
  offlineWhenNoDIDRegistered: true
1215
945
  });
1216
946
  const proofFormat = args?.proofFormat ?? "lds";
1217
- assertValidProofType(import_ssi_types7.StatusListType.StatusList2021, proofFormat);
947
+ assertValidProofType(import_ssi_types6.StatusListType.StatusList2021, proofFormat);
1218
948
  const veramoProofFormat = proofFormat;
1219
949
  const encodedList = getAssertedValue("encodedList", args.encodedList);
1220
950
  const statusPurpose = getAssertedValue("statusPurpose", args.statusPurpose);
@@ -1243,7 +973,7 @@ async function statusList2021ToVerifiableCredential(args, context) {
1243
973
  proofFormat: veramoProofFormat,
1244
974
  fetchRemoteContexts: true
1245
975
  });
1246
- return import_ssi_types7.CredentialMapper.toWrappedVerifiableCredential(verifiableCredential).original;
976
+ return import_ssi_types6.CredentialMapper.toWrappedVerifiableCredential(verifiableCredential).original;
1247
977
  }
1248
978
  __name(statusList2021ToVerifiableCredential, "statusList2021ToVerifiableCredential");
1249
979
  //# sourceMappingURL=index.cjs.map