@sphereon/ssi-sdk.vc-status-list 0.34.1-feature.SSISDK.17.bitstring.sl.9 → 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 +29 -309
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +8 -49
- package/dist/index.d.ts +8 -49
- package/dist/index.js +30 -310
- package/dist/index.js.map +1 -1
- package/package.json +7 -8
- package/src/functions.ts +10 -19
- package/src/impl/IStatusList.ts +2 -3
- package/src/impl/OAuthStatusList.ts +11 -17
- package/src/impl/StatusList2021.ts +3 -3
- package/src/impl/StatusListFactory.ts +0 -2
- package/src/types/index.ts +4 -48
- package/src/utils.ts +2 -35
- package/src/impl/BitstringStatusListImplementation.ts +0 -301
- package/src/types/BitstringStatusList.ts +0 -4
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
|
|
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) {
|
|
@@ -128,26 +122,6 @@ function determineProofFormat(credential) {
|
|
|
128
122
|
}
|
|
129
123
|
}
|
|
130
124
|
__name(determineProofFormat, "determineProofFormat");
|
|
131
|
-
function ensureDate(value) {
|
|
132
|
-
if (value === void 0 || value === null) {
|
|
133
|
-
return void 0;
|
|
134
|
-
}
|
|
135
|
-
if (value instanceof Date) {
|
|
136
|
-
return value;
|
|
137
|
-
}
|
|
138
|
-
if (typeof value === "string") {
|
|
139
|
-
if (value.trim() === "") {
|
|
140
|
-
return void 0;
|
|
141
|
-
}
|
|
142
|
-
const date = new Date(value);
|
|
143
|
-
if (isNaN(date.getTime())) {
|
|
144
|
-
return void 0;
|
|
145
|
-
}
|
|
146
|
-
return date;
|
|
147
|
-
}
|
|
148
|
-
return void 0;
|
|
149
|
-
}
|
|
150
|
-
__name(ensureDate, "ensureDate");
|
|
151
125
|
|
|
152
126
|
// src/impl/StatusList2021.ts
|
|
153
127
|
import { CredentialMapper as CredentialMapper2, DocumentFormat as DocumentFormat2, StatusListType as StatusListType2 } from "@sphereon/ssi-types";
|
|
@@ -240,7 +214,7 @@ var StatusList2021Implementation = class {
|
|
|
240
214
|
encodedList: args.encodedList
|
|
241
215
|
});
|
|
242
216
|
const index = typeof args.statusListIndex === "number" ? args.statusListIndex : parseInt(args.statusListIndex);
|
|
243
|
-
statusList.setStatus(index, args.value
|
|
217
|
+
statusList.setStatus(index, args.value);
|
|
244
218
|
const newEncodedList = await statusList.encode();
|
|
245
219
|
const credential = await this.createVerifiableCredential({
|
|
246
220
|
id,
|
|
@@ -597,9 +571,8 @@ var OAuthStatusListImplementation = class {
|
|
|
597
571
|
throw new Error("OAuthStatusList options are required for type OAuthStatusList");
|
|
598
572
|
}
|
|
599
573
|
const proofFormat = args?.proofFormat ?? DEFAULT_PROOF_FORMAT2;
|
|
600
|
-
const { issuer, id, oauthStatusList
|
|
601
|
-
const { bitsPerStatus } =
|
|
602
|
-
const expiresAt = ensureDate(oauthStatusList1.expiresAt);
|
|
574
|
+
const { issuer, id, oauthStatusList, keyRef } = args;
|
|
575
|
+
const { bitsPerStatus, expiresAt } = oauthStatusList;
|
|
603
576
|
const length = args.length ?? DEFAULT_LIST_LENGTH2;
|
|
604
577
|
const issuerString = typeof issuer === "string" ? issuer : issuer.id;
|
|
605
578
|
const correlationId = getAssertedValue("correlationId", args.correlationId);
|
|
@@ -622,8 +595,7 @@ var OAuthStatusListImplementation = class {
|
|
|
622
595
|
};
|
|
623
596
|
}
|
|
624
597
|
async updateStatusListIndex(args, context) {
|
|
625
|
-
const { statusListCredential, value, keyRef } = args;
|
|
626
|
-
const expiresAt = ensureDate(oauthStatusList.expiresAt);
|
|
598
|
+
const { statusListCredential, value, expiresAt, keyRef } = args;
|
|
627
599
|
if (typeof statusListCredential !== "string") {
|
|
628
600
|
return Promise.reject("statusListCredential in neither JWT nor CWT");
|
|
629
601
|
}
|
|
@@ -634,9 +606,6 @@ var OAuthStatusListImplementation = class {
|
|
|
634
606
|
if (index < 0 || index >= statusList.statusList.length) {
|
|
635
607
|
throw new Error("Status list index out of bounds");
|
|
636
608
|
}
|
|
637
|
-
if (typeof value !== "number") {
|
|
638
|
-
throw new Error("Status list values should be of type number");
|
|
639
|
-
}
|
|
640
609
|
statusList.setStatus(index, value);
|
|
641
610
|
const { statusListCredential: signedCredential, encodedList } = await this.createSignedStatusList(proofFormat, context, statusList, issuer, id, expiresAt, keyRef);
|
|
642
611
|
return {
|
|
@@ -658,14 +627,13 @@ var OAuthStatusListImplementation = class {
|
|
|
658
627
|
if (!args.oauthStatusList) {
|
|
659
628
|
throw new Error("OAuthStatusList options are required for type OAuthStatusList");
|
|
660
629
|
}
|
|
661
|
-
const { proofFormat, oauthStatusList
|
|
662
|
-
const { bitsPerStatus } =
|
|
663
|
-
const expiresAt = ensureDate(oauthStatusList1.expiresAt);
|
|
630
|
+
const { proofFormat, oauthStatusList, keyRef } = args;
|
|
631
|
+
const { bitsPerStatus, expiresAt } = oauthStatusList;
|
|
664
632
|
const { issuer, id } = getAssertedValues(args);
|
|
665
633
|
const issuerString = typeof issuer === "string" ? issuer : issuer.id;
|
|
666
634
|
const listToUpdate = StatusList4.decompressStatusList(args.encodedList, bitsPerStatus ?? DEFAULT_BITS_PER_STATUS);
|
|
667
635
|
const index = typeof args.statusListIndex === "number" ? args.statusListIndex : parseInt(args.statusListIndex);
|
|
668
|
-
listToUpdate.setStatus(index, args.value);
|
|
636
|
+
listToUpdate.setStatus(index, args.value ? 1 : 0);
|
|
669
637
|
const { statusListCredential, encodedList } = await this.createSignedStatusList(proofFormat ?? DEFAULT_PROOF_FORMAT2, context, listToUpdate, issuerString, id, expiresAt, keyRef);
|
|
670
638
|
return {
|
|
671
639
|
encodedList,
|
|
@@ -694,7 +662,7 @@ var OAuthStatusListImplementation = class {
|
|
|
694
662
|
const { statusList } = proofFormat === "jwt" ? decodeStatusListJWT(statusListCredential) : decodeStatusListCWT(statusListCredential);
|
|
695
663
|
const index = typeof statusListIndex === "number" ? statusListIndex : parseInt(statusListIndex);
|
|
696
664
|
if (index < 0 || index >= statusList.statusList.length) {
|
|
697
|
-
throw new Error(
|
|
665
|
+
throw new Error("Status list index out of bounds");
|
|
698
666
|
}
|
|
699
667
|
return statusList.getStatus(index);
|
|
700
668
|
}
|
|
@@ -741,253 +709,7 @@ var OAuthStatusListImplementation = class {
|
|
|
741
709
|
};
|
|
742
710
|
|
|
743
711
|
// src/impl/StatusListFactory.ts
|
|
744
|
-
import { StatusListType as
|
|
745
|
-
|
|
746
|
-
// src/impl/BitstringStatusListImplementation.ts
|
|
747
|
-
import { CredentialMapper as CredentialMapper3, DocumentFormat as DocumentFormat3, StatusListType as StatusListType4 } from "@sphereon/ssi-types";
|
|
748
|
-
import { BitstreamStatusList, createStatusListCredential } from "@4sure-tech/vc-bitstring-status-lists";
|
|
749
|
-
var DEFAULT_LIST_LENGTH3 = 131072;
|
|
750
|
-
var DEFAULT_PROOF_FORMAT3 = "lds";
|
|
751
|
-
var DEFAULT_STATUS_PURPOSE = "revocation";
|
|
752
|
-
var BitstringStatusListImplementation = class {
|
|
753
|
-
static {
|
|
754
|
-
__name(this, "BitstringStatusListImplementation");
|
|
755
|
-
}
|
|
756
|
-
async createNewStatusList(args, context) {
|
|
757
|
-
if (!args.bitstringStatusList) {
|
|
758
|
-
throw new Error("BitstringStatusList options are required for type BitstringStatusList");
|
|
759
|
-
}
|
|
760
|
-
const length = args?.length ?? DEFAULT_LIST_LENGTH3;
|
|
761
|
-
const proofFormat = args?.proofFormat ?? DEFAULT_PROOF_FORMAT3;
|
|
762
|
-
assertValidProofType(StatusListType4.BitstringStatusList, proofFormat);
|
|
763
|
-
const veramoProofFormat = proofFormat;
|
|
764
|
-
const { issuer, id } = args;
|
|
765
|
-
const correlationId = getAssertedValue("correlationId", args.correlationId);
|
|
766
|
-
const { statusPurpose, bitsPerStatus, validFrom, validUntil, ttl } = args.bitstringStatusList;
|
|
767
|
-
const statusListCredential = await this.createVerifiableCredential({
|
|
768
|
-
...args,
|
|
769
|
-
proofFormat: veramoProofFormat,
|
|
770
|
-
statusPurpose: statusPurpose ?? DEFAULT_STATUS_PURPOSE,
|
|
771
|
-
validFrom: ensureDate(validFrom),
|
|
772
|
-
validUntil: ensureDate(validUntil),
|
|
773
|
-
ttl
|
|
774
|
-
}, context);
|
|
775
|
-
return {
|
|
776
|
-
encodedList: statusListCredential.credentialSubject.encodedList,
|
|
777
|
-
statusListCredential,
|
|
778
|
-
bitstringStatusList: {
|
|
779
|
-
statusPurpose: statusPurpose ?? DEFAULT_STATUS_PURPOSE,
|
|
780
|
-
...statusListCredential.validFrom && {
|
|
781
|
-
validFrom: new Date(statusListCredential.validFrom)
|
|
782
|
-
},
|
|
783
|
-
...statusListCredential.validUntil && {
|
|
784
|
-
validUntil: new Date(statusListCredential.validUntil)
|
|
785
|
-
},
|
|
786
|
-
ttl,
|
|
787
|
-
bitsPerStatus
|
|
788
|
-
},
|
|
789
|
-
length,
|
|
790
|
-
type: StatusListType4.BitstringStatusList,
|
|
791
|
-
proofFormat,
|
|
792
|
-
id,
|
|
793
|
-
correlationId,
|
|
794
|
-
issuer,
|
|
795
|
-
statuslistContentType: this.buildContentType(proofFormat)
|
|
796
|
-
};
|
|
797
|
-
}
|
|
798
|
-
async updateStatusListIndex(args, context) {
|
|
799
|
-
if (!args.bitsPerStatus || args.bitsPerStatus < 1) {
|
|
800
|
-
return Promise.reject("bitsPerStatus must be set for bitstring status lists and must be 1 or higher. (updateStatusListIndex)");
|
|
801
|
-
}
|
|
802
|
-
const credential = args.statusListCredential;
|
|
803
|
-
const uniform = CredentialMapper3.toUniformCredential(credential);
|
|
804
|
-
const { issuer, credentialSubject } = uniform;
|
|
805
|
-
const id = getAssertedValue("id", uniform.id);
|
|
806
|
-
const origEncodedList = getAssertedProperty("encodedList", credentialSubject);
|
|
807
|
-
const index = typeof args.statusListIndex === "number" ? args.statusListIndex : parseInt(args.statusListIndex);
|
|
808
|
-
const statusList = await BitstreamStatusList.decode({
|
|
809
|
-
encodedList: origEncodedList,
|
|
810
|
-
statusSize: args.bitsPerStatus
|
|
811
|
-
});
|
|
812
|
-
statusList.setStatus(index, args.value);
|
|
813
|
-
const proofFormat = CredentialMapper3.detectDocumentType(credential) === DocumentFormat3.JWT ? "jwt" : "lds";
|
|
814
|
-
const credSubject = Array.isArray(credentialSubject) ? credentialSubject[0] : credentialSubject;
|
|
815
|
-
const statusPurpose = getAssertedProperty("statusPurpose", credSubject);
|
|
816
|
-
const validFrom = uniform.validFrom ? new Date(uniform.validFrom) : void 0;
|
|
817
|
-
const validUntil = uniform.validUntil ? new Date(uniform.validUntil) : void 0;
|
|
818
|
-
const ttl = credSubject.ttl;
|
|
819
|
-
const updatedCredential = await this.createVerifiableCredential({
|
|
820
|
-
...args,
|
|
821
|
-
id,
|
|
822
|
-
issuer,
|
|
823
|
-
statusList,
|
|
824
|
-
proofFormat,
|
|
825
|
-
statusPurpose,
|
|
826
|
-
ttl,
|
|
827
|
-
validFrom,
|
|
828
|
-
validUntil
|
|
829
|
-
}, context);
|
|
830
|
-
return {
|
|
831
|
-
statusListCredential: updatedCredential,
|
|
832
|
-
encodedList: updatedCredential.credentialSubject.encodedList,
|
|
833
|
-
bitstringStatusList: {
|
|
834
|
-
statusPurpose,
|
|
835
|
-
...updatedCredential.validFrom && {
|
|
836
|
-
validFrom: new Date(updatedCredential.validFrom)
|
|
837
|
-
},
|
|
838
|
-
...updatedCredential.validUntil && {
|
|
839
|
-
validUntil: new Date(updatedCredential.validUntil)
|
|
840
|
-
},
|
|
841
|
-
bitsPerStatus: args.bitsPerStatus,
|
|
842
|
-
ttl
|
|
843
|
-
},
|
|
844
|
-
length: statusList.getLength(),
|
|
845
|
-
type: StatusListType4.BitstringStatusList,
|
|
846
|
-
proofFormat,
|
|
847
|
-
id,
|
|
848
|
-
issuer,
|
|
849
|
-
statuslistContentType: this.buildContentType(proofFormat)
|
|
850
|
-
};
|
|
851
|
-
}
|
|
852
|
-
async updateStatusListFromEncodedList(args, context) {
|
|
853
|
-
if (!args.bitstringStatusList) {
|
|
854
|
-
throw new Error("bitstringStatusList options required for type BitstringStatusList");
|
|
855
|
-
}
|
|
856
|
-
if (args.bitstringStatusList.bitsPerStatus < 1) {
|
|
857
|
-
return Promise.reject("bitsPerStatus must be set for bitstring status lists and must be 1 or higher. (updateStatusListFromEncodedList)");
|
|
858
|
-
}
|
|
859
|
-
const { statusPurpose, bitsPerStatus, ttl, validFrom, validUntil } = args.bitstringStatusList;
|
|
860
|
-
const proofFormat = args?.proofFormat ?? DEFAULT_PROOF_FORMAT3;
|
|
861
|
-
assertValidProofType(StatusListType4.BitstringStatusList, proofFormat);
|
|
862
|
-
const veramoProofFormat = proofFormat;
|
|
863
|
-
const { issuer, id } = getAssertedValues(args);
|
|
864
|
-
const statusList = await BitstreamStatusList.decode({
|
|
865
|
-
encodedList: args.encodedList,
|
|
866
|
-
statusSize: bitsPerStatus
|
|
867
|
-
});
|
|
868
|
-
const index = typeof args.statusListIndex === "number" ? args.statusListIndex : parseInt(args.statusListIndex);
|
|
869
|
-
statusList.setStatus(index, args.value);
|
|
870
|
-
const credential = await this.createVerifiableCredential({
|
|
871
|
-
id,
|
|
872
|
-
issuer,
|
|
873
|
-
statusList,
|
|
874
|
-
proofFormat: veramoProofFormat,
|
|
875
|
-
keyRef: args.keyRef,
|
|
876
|
-
statusPurpose,
|
|
877
|
-
validFrom: ensureDate(validFrom),
|
|
878
|
-
validUntil: ensureDate(validUntil),
|
|
879
|
-
ttl
|
|
880
|
-
}, context);
|
|
881
|
-
return {
|
|
882
|
-
type: StatusListType4.BitstringStatusList,
|
|
883
|
-
statusListCredential: credential,
|
|
884
|
-
encodedList: credential.credentialSubject.encodedList,
|
|
885
|
-
bitstringStatusList: {
|
|
886
|
-
statusPurpose,
|
|
887
|
-
bitsPerStatus,
|
|
888
|
-
...credential.validFrom && {
|
|
889
|
-
validFrom: new Date(credential.validFrom)
|
|
890
|
-
},
|
|
891
|
-
...credential.validUntil && {
|
|
892
|
-
validUntil: new Date(credential.validUntil)
|
|
893
|
-
},
|
|
894
|
-
ttl
|
|
895
|
-
},
|
|
896
|
-
length: statusList.getLength(),
|
|
897
|
-
proofFormat: args.proofFormat ?? "lds",
|
|
898
|
-
id,
|
|
899
|
-
issuer,
|
|
900
|
-
statuslistContentType: this.buildContentType(proofFormat)
|
|
901
|
-
};
|
|
902
|
-
}
|
|
903
|
-
async checkStatusIndex(args) {
|
|
904
|
-
if (!args.bitsPerStatus || args.bitsPerStatus < 1) {
|
|
905
|
-
return Promise.reject("bitsPerStatus must be set for bitstring status lists and must be 1 or higher. (checkStatusIndex)");
|
|
906
|
-
}
|
|
907
|
-
const uniform = CredentialMapper3.toUniformCredential(args.statusListCredential);
|
|
908
|
-
const { credentialSubject } = uniform;
|
|
909
|
-
const encodedList = getAssertedProperty("encodedList", credentialSubject);
|
|
910
|
-
const statusSize = args.bitsPerStatus;
|
|
911
|
-
const statusList = await BitstreamStatusList.decode({
|
|
912
|
-
encodedList,
|
|
913
|
-
statusSize
|
|
914
|
-
});
|
|
915
|
-
const numIndex = typeof args.statusListIndex === "number" ? args.statusListIndex : parseInt(args.statusListIndex);
|
|
916
|
-
if (statusList.getLength() <= numIndex) {
|
|
917
|
-
throw new Error(`Status list index out of bounds, has ${statusList.getLength()} entries, requested ${numIndex}`);
|
|
918
|
-
}
|
|
919
|
-
return statusList.getStatus(numIndex);
|
|
920
|
-
}
|
|
921
|
-
async toStatusListDetails(args) {
|
|
922
|
-
const { statusListPayload, bitsPerStatus } = args;
|
|
923
|
-
if (!bitsPerStatus || bitsPerStatus < 1) {
|
|
924
|
-
return Promise.reject("bitsPerStatus must be set for bitstring status lists and must be 1 or higher. (toStatusListDetails)");
|
|
925
|
-
}
|
|
926
|
-
const uniform = CredentialMapper3.toUniformCredential(statusListPayload);
|
|
927
|
-
const { issuer, credentialSubject } = uniform;
|
|
928
|
-
const id = getAssertedValue("id", uniform.id);
|
|
929
|
-
const encodedList = getAssertedProperty("encodedList", credentialSubject);
|
|
930
|
-
const proofFormat = CredentialMapper3.detectDocumentType(statusListPayload) === DocumentFormat3.JWT ? "jwt" : "lds";
|
|
931
|
-
const credSubject = Array.isArray(credentialSubject) ? credentialSubject[0] : credentialSubject;
|
|
932
|
-
const statusPurpose = getAssertedProperty("statusPurpose", credSubject);
|
|
933
|
-
const validFrom = uniform.validFrom ? new Date(uniform.validFrom) : void 0;
|
|
934
|
-
const validUntil = uniform.validUntil ? new Date(uniform.validUntil) : void 0;
|
|
935
|
-
const ttl = credSubject.ttl;
|
|
936
|
-
const statuslistLength = BitstreamStatusList.getStatusListLength(encodedList, bitsPerStatus);
|
|
937
|
-
return {
|
|
938
|
-
id,
|
|
939
|
-
encodedList,
|
|
940
|
-
issuer,
|
|
941
|
-
type: StatusListType4.BitstringStatusList,
|
|
942
|
-
proofFormat,
|
|
943
|
-
length: statuslistLength,
|
|
944
|
-
statusListCredential: statusListPayload,
|
|
945
|
-
statuslistContentType: this.buildContentType(proofFormat),
|
|
946
|
-
bitstringStatusList: {
|
|
947
|
-
statusPurpose,
|
|
948
|
-
bitsPerStatus,
|
|
949
|
-
validFrom,
|
|
950
|
-
validUntil,
|
|
951
|
-
ttl
|
|
952
|
-
},
|
|
953
|
-
...args.correlationId && {
|
|
954
|
-
correlationId: args.correlationId
|
|
955
|
-
},
|
|
956
|
-
...args.driverType && {
|
|
957
|
-
driverType: args.driverType
|
|
958
|
-
}
|
|
959
|
-
};
|
|
960
|
-
}
|
|
961
|
-
async createVerifiableCredential(args, context) {
|
|
962
|
-
const identifier = await context.agent.identifierManagedGet({
|
|
963
|
-
identifier: typeof args.issuer === "string" ? args.issuer : args.issuer.id,
|
|
964
|
-
vmRelationship: "assertionMethod",
|
|
965
|
-
offlineWhenNoDIDRegistered: true
|
|
966
|
-
});
|
|
967
|
-
const unsignedCredential = await createStatusListCredential(args);
|
|
968
|
-
const verifiableCredential = await context.agent.createVerifiableCredential({
|
|
969
|
-
credential: unsignedCredential,
|
|
970
|
-
keyRef: args.keyRef ?? identifier.kmsKeyRef,
|
|
971
|
-
proofFormat: args.proofFormat,
|
|
972
|
-
fetchRemoteContexts: true
|
|
973
|
-
});
|
|
974
|
-
return CredentialMapper3.toWrappedVerifiableCredential(verifiableCredential).original;
|
|
975
|
-
}
|
|
976
|
-
buildContentType(proofFormat) {
|
|
977
|
-
switch (proofFormat) {
|
|
978
|
-
case "jwt":
|
|
979
|
-
return `application/statuslist+jwt`;
|
|
980
|
-
case "cbor":
|
|
981
|
-
return `application/statuslist+cwt`;
|
|
982
|
-
case "lds":
|
|
983
|
-
return "application/statuslist+ld+json";
|
|
984
|
-
default:
|
|
985
|
-
throw Error(`Unsupported content type '${proofFormat}' for status lists`);
|
|
986
|
-
}
|
|
987
|
-
}
|
|
988
|
-
};
|
|
989
|
-
|
|
990
|
-
// src/impl/StatusListFactory.ts
|
|
712
|
+
import { StatusListType as StatusListType4 } from "@sphereon/ssi-types";
|
|
991
713
|
var StatusListFactory = class _StatusListFactory {
|
|
992
714
|
static {
|
|
993
715
|
__name(this, "StatusListFactory");
|
|
@@ -996,9 +718,8 @@ var StatusListFactory = class _StatusListFactory {
|
|
|
996
718
|
implementations;
|
|
997
719
|
constructor() {
|
|
998
720
|
this.implementations = /* @__PURE__ */ new Map();
|
|
999
|
-
this.implementations.set(
|
|
1000
|
-
this.implementations.set(
|
|
1001
|
-
this.implementations.set(StatusListType5.BitstringStatusList, new BitstringStatusListImplementation());
|
|
721
|
+
this.implementations.set(StatusListType4.StatusList2021, new StatusList2021Implementation());
|
|
722
|
+
this.implementations.set(StatusListType4.OAuthStatusList, new OAuthStatusListImplementation());
|
|
1002
723
|
}
|
|
1003
724
|
static getInstance() {
|
|
1004
725
|
if (!_StatusListFactory.instance) {
|
|
@@ -1071,7 +792,7 @@ __name(vcLibCheckStatusFunction, "vcLibCheckStatusFunction");
|
|
|
1071
792
|
async function checkStatusForCredential(args) {
|
|
1072
793
|
const verifyStatusListCredential = args.verifyStatusListCredential ?? true;
|
|
1073
794
|
const verifyMatchingIssuers = args.verifyMatchingIssuers ?? true;
|
|
1074
|
-
const uniform =
|
|
795
|
+
const uniform = CredentialMapper3.toUniformCredential(args.credential);
|
|
1075
796
|
if (!("credentialStatus" in uniform) || !uniform.credentialStatus) {
|
|
1076
797
|
if (args.mandatoryCredentialStatus) {
|
|
1077
798
|
const error = "No credential status object found in the Verifiable Credential and it is mandatory";
|
|
@@ -1086,7 +807,7 @@ async function checkStatusForCredential(args) {
|
|
|
1086
807
|
};
|
|
1087
808
|
}
|
|
1088
809
|
if ("credentialStatus" in uniform && uniform.credentialStatus) {
|
|
1089
|
-
if (uniform.credentialStatus.type === "StatusList2021Entry"
|
|
810
|
+
if (uniform.credentialStatus.type === "StatusList2021Entry") {
|
|
1090
811
|
return checkStatus({
|
|
1091
812
|
...args,
|
|
1092
813
|
verifyStatusListCredential,
|
|
@@ -1134,22 +855,22 @@ async function updateStatusIndexFromStatusListCredential(args, context) {
|
|
|
1134
855
|
return implementation.updateStatusListIndex(args, context);
|
|
1135
856
|
}
|
|
1136
857
|
__name(updateStatusIndexFromStatusListCredential, "updateStatusIndexFromStatusListCredential");
|
|
1137
|
-
async function statusListCredentialToDetails(
|
|
1138
|
-
const credential = getAssertedValue("statusListCredential", statusListCredential);
|
|
858
|
+
async function statusListCredentialToDetails(args) {
|
|
859
|
+
const credential = getAssertedValue("statusListCredential", args.statusListCredential);
|
|
1139
860
|
let statusListType;
|
|
1140
|
-
const documentFormat =
|
|
1141
|
-
if (documentFormat ===
|
|
861
|
+
const documentFormat = CredentialMapper3.detectDocumentType(credential);
|
|
862
|
+
if (documentFormat === DocumentFormat3.JWT) {
|
|
1142
863
|
const [header] = credential.split(".");
|
|
1143
864
|
const decodedHeader = JSON.parse(Buffer.from(header, "base64").toString());
|
|
1144
865
|
if (decodedHeader.typ === "statuslist+jwt") {
|
|
1145
|
-
statusListType =
|
|
866
|
+
statusListType = StatusListType5.OAuthStatusList;
|
|
1146
867
|
}
|
|
1147
|
-
} else if (documentFormat ===
|
|
1148
|
-
statusListType =
|
|
868
|
+
} else if (documentFormat === DocumentFormat3.MSO_MDOC) {
|
|
869
|
+
statusListType = StatusListType5.OAuthStatusList;
|
|
1149
870
|
}
|
|
1150
871
|
if (!statusListType) {
|
|
1151
|
-
const uniform =
|
|
1152
|
-
const type = uniform.type.find((t) => t.includes("StatusList2021") || t.includes("OAuth2StatusList")
|
|
872
|
+
const uniform = CredentialMapper3.toUniformCredential(credential);
|
|
873
|
+
const type = uniform.type.find((t) => t.includes("StatusList2021") || t.includes("OAuth2StatusList"));
|
|
1153
874
|
if (!type) {
|
|
1154
875
|
throw new Error("Invalid status list credential type");
|
|
1155
876
|
}
|
|
@@ -1158,9 +879,8 @@ async function statusListCredentialToDetails({ correlationId, driverType, status
|
|
|
1158
879
|
const implementation = getStatusListImplementation(statusListType);
|
|
1159
880
|
return await implementation.toStatusListDetails({
|
|
1160
881
|
statusListPayload: credential,
|
|
1161
|
-
correlationId,
|
|
1162
|
-
driverType
|
|
1163
|
-
bitsPerStatus
|
|
882
|
+
correlationId: args.correlationId,
|
|
883
|
+
driverType: args.driverType
|
|
1164
884
|
});
|
|
1165
885
|
}
|
|
1166
886
|
__name(statusListCredentialToDetails, "statusListCredentialToDetails");
|
|
@@ -1178,7 +898,7 @@ async function statusList2021ToVerifiableCredential(args, context) {
|
|
|
1178
898
|
offlineWhenNoDIDRegistered: true
|
|
1179
899
|
});
|
|
1180
900
|
const proofFormat = args?.proofFormat ?? "lds";
|
|
1181
|
-
assertValidProofType(
|
|
901
|
+
assertValidProofType(StatusListType5.StatusList2021, proofFormat);
|
|
1182
902
|
const veramoProofFormat = proofFormat;
|
|
1183
903
|
const encodedList = getAssertedValue("encodedList", args.encodedList);
|
|
1184
904
|
const statusPurpose = getAssertedValue("statusPurpose", args.statusPurpose);
|
|
@@ -1207,7 +927,7 @@ async function statusList2021ToVerifiableCredential(args, context) {
|
|
|
1207
927
|
proofFormat: veramoProofFormat,
|
|
1208
928
|
fetchRemoteContexts: true
|
|
1209
929
|
});
|
|
1210
|
-
return
|
|
930
|
+
return CredentialMapper3.toWrappedVerifiableCredential(verifiableCredential).original;
|
|
1211
931
|
}
|
|
1212
932
|
__name(statusList2021ToVerifiableCredential, "statusList2021ToVerifiableCredential");
|
|
1213
933
|
export {
|