@sphereon/ssi-sdk.vc-status-list 0.34.1-feature.SSISDK.17.bitstring.sl.13 → 0.34.1-feature.SSISDK.17.bitstring.sl.14
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 +290 -161
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +67 -35
- package/dist/index.d.ts +67 -35
- package/dist/index.js +290 -161
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
- package/src/functions.ts +44 -35
- package/src/impl/BitstringStatusListImplementation.ts +113 -66
- package/src/impl/IStatusList.ts +35 -7
- package/src/impl/OAuthStatusList.ts +77 -30
- package/src/impl/StatusList2021.ts +73 -34
- package/src/index.ts +1 -0
- package/src/types/index.ts +18 -25
- package/src/utils.ts +47 -18
package/dist/index.js
CHANGED
|
@@ -92,29 +92,50 @@ function determineStatusListType(credential) {
|
|
|
92
92
|
const proofFormat = determineProofFormat(credential);
|
|
93
93
|
switch (proofFormat) {
|
|
94
94
|
case "jwt":
|
|
95
|
-
|
|
96
|
-
const keys = Object.keys(payload);
|
|
97
|
-
if (keys.includes("status_list")) {
|
|
98
|
-
return StatusListType.OAuthStatusList;
|
|
99
|
-
} else if (keys.includes("vc")) {
|
|
100
|
-
return StatusListType.StatusList2021;
|
|
101
|
-
}
|
|
102
|
-
break;
|
|
95
|
+
return determineJwtStatusListType(credential);
|
|
103
96
|
case "lds":
|
|
104
|
-
|
|
105
|
-
const type = uniform.type.find((t) => {
|
|
106
|
-
return Object.values(StatusListType).some((statusType) => t.includes(statusType));
|
|
107
|
-
});
|
|
108
|
-
if (!type) {
|
|
109
|
-
throw new Error("Invalid status list credential type");
|
|
110
|
-
}
|
|
111
|
-
return type.replace("Credential", "");
|
|
97
|
+
return determineLdsStatusListType(credential);
|
|
112
98
|
case "cbor":
|
|
113
99
|
return StatusListType.OAuthStatusList;
|
|
100
|
+
default:
|
|
101
|
+
throw new Error("Cannot determine status list type from credential payload");
|
|
114
102
|
}
|
|
115
|
-
throw new Error("Cannot determine status list type from credential payload");
|
|
116
103
|
}
|
|
117
104
|
__name(determineStatusListType, "determineStatusListType");
|
|
105
|
+
function determineJwtStatusListType(credential) {
|
|
106
|
+
const payload = jwtDecode(credential);
|
|
107
|
+
if ("status_list" in payload) {
|
|
108
|
+
return StatusListType.OAuthStatusList;
|
|
109
|
+
}
|
|
110
|
+
if ("credentialSubject" in payload) {
|
|
111
|
+
return getStatusListTypeFromSubject(payload.credentialSubject);
|
|
112
|
+
}
|
|
113
|
+
if ("vc" in payload && "credentialSubject" in payload.vc) {
|
|
114
|
+
return getStatusListTypeFromSubject(payload.vc.credentialSubject);
|
|
115
|
+
}
|
|
116
|
+
throw new Error("Invalid status list credential: credentialSubject not found");
|
|
117
|
+
}
|
|
118
|
+
__name(determineJwtStatusListType, "determineJwtStatusListType");
|
|
119
|
+
function determineLdsStatusListType(credential) {
|
|
120
|
+
const uniform = CredentialMapper.toUniformCredential(credential);
|
|
121
|
+
const statusListType = uniform.type.find((type) => Object.values(StatusListType).some((statusType) => type.includes(statusType)));
|
|
122
|
+
if (!statusListType) {
|
|
123
|
+
throw new Error("Invalid status list credential type");
|
|
124
|
+
}
|
|
125
|
+
return statusListType.replace("Credential", "");
|
|
126
|
+
}
|
|
127
|
+
__name(determineLdsStatusListType, "determineLdsStatusListType");
|
|
128
|
+
function getStatusListTypeFromSubject(credentialSubject) {
|
|
129
|
+
switch (credentialSubject.type) {
|
|
130
|
+
case "StatusList2021":
|
|
131
|
+
return StatusListType.StatusList2021;
|
|
132
|
+
case "BitstringStatusList":
|
|
133
|
+
return StatusListType.BitstringStatusList;
|
|
134
|
+
default:
|
|
135
|
+
throw new Error(`Unknown credential subject type: ${credentialSubject.type}`);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
__name(getStatusListTypeFromSubject, "getStatusListTypeFromSubject");
|
|
118
139
|
function determineProofFormat(credential) {
|
|
119
140
|
const type = CredentialMapper.detectDocumentType(credential);
|
|
120
141
|
switch (type) {
|
|
@@ -276,46 +297,73 @@ var StatusList2021Implementation = class {
|
|
|
276
297
|
const status = statusList.getStatus(typeof args.statusListIndex === "number" ? args.statusListIndex : parseInt(args.statusListIndex));
|
|
277
298
|
return status ? Status2021.Invalid : Status2021.Valid;
|
|
278
299
|
}
|
|
279
|
-
async
|
|
280
|
-
const
|
|
281
|
-
const uniform = CredentialMapper2.toUniformCredential(statusListPayload);
|
|
300
|
+
async extractCredentialDetails(credential) {
|
|
301
|
+
const uniform = CredentialMapper2.toUniformCredential(credential);
|
|
282
302
|
const { issuer, credentialSubject } = uniform;
|
|
283
|
-
const
|
|
284
|
-
const encodedList = getAssertedProperty("encodedList", credentialSubject);
|
|
285
|
-
const proofFormat = CredentialMapper2.detectDocumentType(statusListPayload) === DocumentFormat2.JWT ? "jwt" : "lds";
|
|
286
|
-
const statusPurpose = getAssertedProperty("statusPurpose", credentialSubject);
|
|
287
|
-
const indexingDirection = "rightToLeft";
|
|
288
|
-
const list = await StatusList.decode({
|
|
289
|
-
encodedList
|
|
290
|
-
});
|
|
303
|
+
const subject = Array.isArray(credentialSubject) ? credentialSubject[0] : credentialSubject;
|
|
291
304
|
return {
|
|
292
|
-
|
|
293
|
-
id,
|
|
294
|
-
encodedList,
|
|
305
|
+
id: getAssertedValue("id", uniform.id),
|
|
295
306
|
issuer,
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
correlationId
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
307
|
+
encodedList: getAssertedProperty("encodedList", subject)
|
|
308
|
+
};
|
|
309
|
+
}
|
|
310
|
+
async toStatusListDetails(args) {
|
|
311
|
+
if ("statusListCredential" in args) {
|
|
312
|
+
const { statusListCredential, correlationId, driverType } = args;
|
|
313
|
+
const uniform = CredentialMapper2.toUniformCredential(statusListCredential);
|
|
314
|
+
const { issuer, credentialSubject } = uniform;
|
|
315
|
+
const subject = Array.isArray(credentialSubject) ? credentialSubject[0] : credentialSubject;
|
|
316
|
+
const id = getAssertedValue("id", uniform.id);
|
|
317
|
+
const encodedList = getAssertedProperty("encodedList", subject);
|
|
318
|
+
const statusPurpose = getAssertedProperty("statusPurpose", subject);
|
|
319
|
+
const proofFormat = CredentialMapper2.detectDocumentType(statusListCredential) === DocumentFormat2.JWT ? "jwt" : "lds";
|
|
320
|
+
const list = await StatusList.decode({
|
|
321
|
+
encodedList
|
|
322
|
+
});
|
|
323
|
+
return {
|
|
324
|
+
id,
|
|
325
|
+
encodedList,
|
|
326
|
+
issuer,
|
|
327
|
+
type: StatusListType2.StatusList2021,
|
|
328
|
+
proofFormat,
|
|
329
|
+
length: list.length,
|
|
330
|
+
statusListCredential,
|
|
331
|
+
statuslistContentType: this.buildContentType(proofFormat),
|
|
332
|
+
correlationId,
|
|
333
|
+
driverType,
|
|
334
|
+
indexingDirection: "rightToLeft",
|
|
309
335
|
statusPurpose,
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
},
|
|
314
|
-
...args.driverType && {
|
|
315
|
-
driverType: args.driverType
|
|
336
|
+
statusList2021: {
|
|
337
|
+
indexingDirection: "rightToLeft",
|
|
338
|
+
statusPurpose
|
|
316
339
|
}
|
|
317
|
-
}
|
|
318
|
-
}
|
|
340
|
+
};
|
|
341
|
+
} else {
|
|
342
|
+
const { extractedDetails, statusListEntity } = args;
|
|
343
|
+
const statusList2021Entity = statusListEntity;
|
|
344
|
+
const proofFormat = CredentialMapper2.detectDocumentType(statusListEntity.statusListCredential) === DocumentFormat2.JWT ? "jwt" : "lds";
|
|
345
|
+
const list = await StatusList.decode({
|
|
346
|
+
encodedList: extractedDetails.encodedList
|
|
347
|
+
});
|
|
348
|
+
return {
|
|
349
|
+
id: extractedDetails.id,
|
|
350
|
+
encodedList: extractedDetails.encodedList,
|
|
351
|
+
issuer: extractedDetails.issuer,
|
|
352
|
+
type: StatusListType2.StatusList2021,
|
|
353
|
+
proofFormat,
|
|
354
|
+
length: list.length,
|
|
355
|
+
statusListCredential: statusListEntity.statusListCredential,
|
|
356
|
+
statuslistContentType: this.buildContentType(proofFormat),
|
|
357
|
+
correlationId: statusListEntity.correlationId,
|
|
358
|
+
driverType: statusListEntity.driverType,
|
|
359
|
+
indexingDirection: statusList2021Entity.indexingDirection,
|
|
360
|
+
statusPurpose: statusList2021Entity.statusPurpose,
|
|
361
|
+
statusList2021: {
|
|
362
|
+
indexingDirection: statusList2021Entity.indexingDirection,
|
|
363
|
+
statusPurpose: statusList2021Entity.statusPurpose
|
|
364
|
+
}
|
|
365
|
+
};
|
|
366
|
+
}
|
|
319
367
|
}
|
|
320
368
|
async createCredentialStatus(args) {
|
|
321
369
|
const { statusList, statusListIndex } = args;
|
|
@@ -717,45 +765,80 @@ var OAuthStatusListImplementation = class {
|
|
|
717
765
|
}
|
|
718
766
|
return statusList.getStatus(index);
|
|
719
767
|
}
|
|
720
|
-
async
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
const
|
|
725
|
-
const
|
|
726
|
-
const expiresAt = exp ? new Date(exp * 1e3) : void 0;
|
|
768
|
+
async extractCredentialDetails(credential) {
|
|
769
|
+
if (typeof credential !== "string") {
|
|
770
|
+
return Promise.reject("statusListCredential must be a JWT or CWT string");
|
|
771
|
+
}
|
|
772
|
+
const proofFormat = determineProofFormat(credential);
|
|
773
|
+
const decoded = proofFormat === "jwt" ? decodeStatusListJWT(credential) : decodeStatusListCWT(credential);
|
|
727
774
|
return {
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
encodedList: statusList.compressStatusList(),
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
775
|
+
id: decoded.id,
|
|
776
|
+
issuer: decoded.issuer,
|
|
777
|
+
encodedList: decoded.statusList.compressStatusList(),
|
|
778
|
+
decodedPayload: decoded
|
|
779
|
+
};
|
|
780
|
+
}
|
|
781
|
+
async toStatusListDetails(args) {
|
|
782
|
+
if ("statusListCredential" in args) {
|
|
783
|
+
const { statusListCredential, bitsPerStatus, correlationId, driverType } = args;
|
|
784
|
+
if (!bitsPerStatus || bitsPerStatus < 1) {
|
|
785
|
+
return Promise.reject(Error("bitsPerStatus must be set for OAuth status lists and must be 1 or higher"));
|
|
786
|
+
}
|
|
787
|
+
const proofFormat = determineProofFormat(statusListCredential);
|
|
788
|
+
const decoded = proofFormat === "jwt" ? decodeStatusListJWT(statusListCredential) : decodeStatusListCWT(statusListCredential);
|
|
789
|
+
const { statusList, issuer, id, exp } = decoded;
|
|
790
|
+
const expiresAt = exp ? new Date(exp * 1e3) : void 0;
|
|
791
|
+
return {
|
|
792
|
+
id,
|
|
793
|
+
encodedList: statusList.compressStatusList(),
|
|
794
|
+
issuer,
|
|
795
|
+
type: StatusListType3.OAuthStatusList,
|
|
796
|
+
proofFormat,
|
|
797
|
+
length: statusList.statusList.length,
|
|
798
|
+
statusListCredential,
|
|
799
|
+
statuslistContentType: this.buildContentType(proofFormat),
|
|
800
|
+
correlationId,
|
|
801
|
+
driverType,
|
|
746
802
|
bitsPerStatus,
|
|
747
803
|
...expiresAt && {
|
|
748
804
|
expiresAt
|
|
805
|
+
},
|
|
806
|
+
oauthStatusList: {
|
|
807
|
+
bitsPerStatus,
|
|
808
|
+
...expiresAt && {
|
|
809
|
+
expiresAt
|
|
810
|
+
}
|
|
749
811
|
}
|
|
750
|
-
}
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
812
|
+
};
|
|
813
|
+
} else {
|
|
814
|
+
const { extractedDetails, statusListEntity } = args;
|
|
815
|
+
const oauthEntity = statusListEntity;
|
|
816
|
+
const decoded = extractedDetails.decodedPayload;
|
|
817
|
+
const proofFormat = determineProofFormat(statusListEntity.statusListCredential);
|
|
818
|
+
const expiresAt = decoded.exp ? new Date(decoded.exp * 1e3) : void 0;
|
|
819
|
+
return {
|
|
820
|
+
id: extractedDetails.id,
|
|
821
|
+
encodedList: extractedDetails.encodedList,
|
|
822
|
+
issuer: extractedDetails.issuer,
|
|
823
|
+
type: StatusListType3.OAuthStatusList,
|
|
824
|
+
proofFormat,
|
|
825
|
+
length: decoded.statusList.statusList.length,
|
|
826
|
+
statusListCredential: statusListEntity.statusListCredential,
|
|
827
|
+
statuslistContentType: this.buildContentType(proofFormat),
|
|
828
|
+
correlationId: statusListEntity.correlationId,
|
|
829
|
+
driverType: statusListEntity.driverType,
|
|
830
|
+
bitsPerStatus: oauthEntity.bitsPerStatus,
|
|
831
|
+
...expiresAt && {
|
|
832
|
+
expiresAt
|
|
833
|
+
},
|
|
834
|
+
oauthStatusList: {
|
|
835
|
+
bitsPerStatus: oauthEntity.bitsPerStatus,
|
|
836
|
+
...expiresAt && {
|
|
837
|
+
expiresAt
|
|
838
|
+
}
|
|
839
|
+
}
|
|
840
|
+
};
|
|
841
|
+
}
|
|
759
842
|
}
|
|
760
843
|
async createCredentialStatus(args) {
|
|
761
844
|
const { statusList, statusListIndex } = args;
|
|
@@ -793,7 +876,7 @@ import { StatusListType as StatusListType5 } from "@sphereon/ssi-types";
|
|
|
793
876
|
import { CredentialMapper as CredentialMapper3, DocumentFormat as DocumentFormat3, StatusListType as StatusListType4 } from "@sphereon/ssi-types";
|
|
794
877
|
import { BitstreamStatusList, createStatusListCredential } from "@4sure-tech/vc-bitstring-status-lists";
|
|
795
878
|
var DEFAULT_LIST_LENGTH3 = 131072;
|
|
796
|
-
var DEFAULT_PROOF_FORMAT3 = "
|
|
879
|
+
var DEFAULT_PROOF_FORMAT3 = "vc+jwt";
|
|
797
880
|
var DEFAULT_STATUS_PURPOSE = "revocation";
|
|
798
881
|
var BitstringStatusListImplementation = class {
|
|
799
882
|
static {
|
|
@@ -875,8 +958,9 @@ var BitstringStatusListImplementation = class {
|
|
|
875
958
|
encodedList: origEncodedList,
|
|
876
959
|
statusSize: args.bitsPerStatus
|
|
877
960
|
});
|
|
878
|
-
|
|
879
|
-
|
|
961
|
+
const bitstringStatusId = args.value;
|
|
962
|
+
statusList.setStatus(index, bitstringStatusId);
|
|
963
|
+
const proofFormat = CredentialMapper3.detectDocumentType(credential) === DocumentFormat3.JWT ? "vc+jwt" : "lds";
|
|
880
964
|
const credSubject = Array.isArray(credentialSubject) ? credentialSubject[0] : credentialSubject;
|
|
881
965
|
const statusPurpose = getAssertedProperty("statusPurpose", credSubject);
|
|
882
966
|
const validFrom = uniform.validFrom ? new Date(uniform.validFrom) : void 0;
|
|
@@ -1005,54 +1089,44 @@ var BitstringStatusListImplementation = class {
|
|
|
1005
1089
|
}
|
|
1006
1090
|
return statusList.getStatus(numIndex);
|
|
1007
1091
|
}
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
*
|
|
1011
|
-
* @param args - Conversion parameters including the status list payload
|
|
1012
|
-
* @returns Promise resolving to detailed status list information
|
|
1013
|
-
*/
|
|
1014
|
-
async toStatusListDetails(args) {
|
|
1015
|
-
const { statusListPayload, bitsPerStatus } = args;
|
|
1016
|
-
if (!bitsPerStatus || bitsPerStatus < 1) {
|
|
1017
|
-
return Promise.reject(Error("bitsPerStatus must be set for bitstring status lists and must be 1 or higher. (toStatusListDetails)"));
|
|
1018
|
-
}
|
|
1019
|
-
const uniform = CredentialMapper3.toUniformCredential(statusListPayload);
|
|
1092
|
+
async extractCredentialDetails(credential) {
|
|
1093
|
+
const uniform = CredentialMapper3.toUniformCredential(credential);
|
|
1020
1094
|
const { issuer, credentialSubject } = uniform;
|
|
1021
|
-
const
|
|
1022
|
-
const encodedList = getAssertedProperty("encodedList", credentialSubject);
|
|
1023
|
-
const proofFormat = CredentialMapper3.detectDocumentType(statusListPayload) === DocumentFormat3.JWT ? "vc+jwt" : "lds";
|
|
1024
|
-
const credSubject = Array.isArray(credentialSubject) ? credentialSubject[0] : credentialSubject;
|
|
1025
|
-
const statusPurpose = getAssertedProperty("statusPurpose", credSubject);
|
|
1026
|
-
const validFrom = uniform.validFrom ? new Date(uniform.validFrom) : void 0;
|
|
1027
|
-
const validUntil = uniform.validUntil ? new Date(uniform.validUntil) : void 0;
|
|
1028
|
-
const ttl = credSubject.ttl;
|
|
1029
|
-
const statuslistLength = BitstreamStatusList.getStatusListLength(encodedList, bitsPerStatus);
|
|
1095
|
+
const subject = Array.isArray(credentialSubject) ? credentialSubject[0] : credentialSubject;
|
|
1030
1096
|
return {
|
|
1031
|
-
|
|
1032
|
-
id,
|
|
1033
|
-
encodedList,
|
|
1097
|
+
id: getAssertedValue("id", uniform.id),
|
|
1034
1098
|
issuer,
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
correlationId
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1099
|
+
encodedList: getAssertedProperty("encodedList", subject)
|
|
1100
|
+
};
|
|
1101
|
+
}
|
|
1102
|
+
async toStatusListDetails(args) {
|
|
1103
|
+
if ("statusListCredential" in args) {
|
|
1104
|
+
const { statusListCredential, bitsPerStatus, correlationId, driverType } = args;
|
|
1105
|
+
if (!bitsPerStatus || bitsPerStatus < 1) {
|
|
1106
|
+
return Promise.reject(Error("bitsPerStatus must be set for bitstring status lists and must be 1 or higher"));
|
|
1107
|
+
}
|
|
1108
|
+
const uniform = CredentialMapper3.toUniformCredential(statusListCredential);
|
|
1109
|
+
const { issuer, credentialSubject } = uniform;
|
|
1110
|
+
const subject = Array.isArray(credentialSubject) ? credentialSubject[0] : credentialSubject;
|
|
1111
|
+
const id = getAssertedValue("id", uniform.id);
|
|
1112
|
+
const encodedList = getAssertedProperty("encodedList", subject);
|
|
1113
|
+
const statusPurpose = getAssertedProperty("statusPurpose", subject);
|
|
1114
|
+
const validFrom = uniform.validFrom ? new Date(uniform.validFrom) : void 0;
|
|
1115
|
+
const validUntil = uniform.validUntil ? new Date(uniform.validUntil) : void 0;
|
|
1116
|
+
const ttl = subject.ttl;
|
|
1117
|
+
const proofFormat = CredentialMapper3.detectDocumentType(statusListCredential) === DocumentFormat3.JWT ? "vc+jwt" : "lds";
|
|
1118
|
+
const statuslistLength = BitstreamStatusList.getStatusListLength(encodedList, bitsPerStatus);
|
|
1119
|
+
return {
|
|
1120
|
+
id,
|
|
1121
|
+
encodedList,
|
|
1122
|
+
issuer,
|
|
1123
|
+
type: StatusListType4.BitstringStatusList,
|
|
1124
|
+
proofFormat,
|
|
1125
|
+
length: statuslistLength,
|
|
1126
|
+
statusListCredential,
|
|
1127
|
+
statuslistContentType: this.buildContentType(proofFormat),
|
|
1128
|
+
correlationId,
|
|
1129
|
+
driverType,
|
|
1056
1130
|
statusPurpose,
|
|
1057
1131
|
bitsPerStatus,
|
|
1058
1132
|
...validFrom && {
|
|
@@ -1063,16 +1137,66 @@ var BitstringStatusListImplementation = class {
|
|
|
1063
1137
|
},
|
|
1064
1138
|
...ttl && {
|
|
1065
1139
|
ttl
|
|
1140
|
+
},
|
|
1141
|
+
bitstringStatusList: {
|
|
1142
|
+
statusPurpose,
|
|
1143
|
+
bitsPerStatus,
|
|
1144
|
+
...validFrom && {
|
|
1145
|
+
validFrom
|
|
1146
|
+
},
|
|
1147
|
+
...validUntil && {
|
|
1148
|
+
validUntil
|
|
1149
|
+
},
|
|
1150
|
+
...ttl && {
|
|
1151
|
+
ttl
|
|
1152
|
+
}
|
|
1066
1153
|
}
|
|
1067
|
-
}
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
driverType: args.driverType
|
|
1154
|
+
};
|
|
1155
|
+
} else {
|
|
1156
|
+
const { extractedDetails, statusListEntity } = args;
|
|
1157
|
+
const bitstringEntity = statusListEntity;
|
|
1158
|
+
if (!bitstringEntity.bitsPerStatus) {
|
|
1159
|
+
return Promise.reject(Error("bitsPerStatus must be present for a bitstring status list"));
|
|
1074
1160
|
}
|
|
1075
|
-
|
|
1161
|
+
const proofFormat = CredentialMapper3.detectDocumentType(statusListEntity.statusListCredential) === DocumentFormat3.JWT ? "vc+jwt" : "lds";
|
|
1162
|
+
const statuslistLength = BitstreamStatusList.getStatusListLength(extractedDetails.encodedList, bitstringEntity.bitsPerStatus);
|
|
1163
|
+
return {
|
|
1164
|
+
id: extractedDetails.id,
|
|
1165
|
+
encodedList: extractedDetails.encodedList,
|
|
1166
|
+
issuer: extractedDetails.issuer,
|
|
1167
|
+
type: StatusListType4.BitstringStatusList,
|
|
1168
|
+
proofFormat,
|
|
1169
|
+
length: statuslistLength,
|
|
1170
|
+
statusListCredential: statusListEntity.statusListCredential,
|
|
1171
|
+
statuslistContentType: this.buildContentType(proofFormat),
|
|
1172
|
+
correlationId: statusListEntity.correlationId,
|
|
1173
|
+
driverType: statusListEntity.driverType,
|
|
1174
|
+
statusPurpose: bitstringEntity.statusPurpose,
|
|
1175
|
+
bitsPerStatus: bitstringEntity.bitsPerStatus,
|
|
1176
|
+
...bitstringEntity.validFrom && {
|
|
1177
|
+
validFrom: bitstringEntity.validFrom
|
|
1178
|
+
},
|
|
1179
|
+
...bitstringEntity.validUntil && {
|
|
1180
|
+
validUntil: bitstringEntity.validUntil
|
|
1181
|
+
},
|
|
1182
|
+
...bitstringEntity.ttl && {
|
|
1183
|
+
ttl: bitstringEntity.ttl
|
|
1184
|
+
},
|
|
1185
|
+
bitstringStatusList: {
|
|
1186
|
+
statusPurpose: bitstringEntity.statusPurpose,
|
|
1187
|
+
bitsPerStatus: bitstringEntity.bitsPerStatus,
|
|
1188
|
+
...bitstringEntity.validFrom && {
|
|
1189
|
+
validFrom: bitstringEntity.validFrom
|
|
1190
|
+
},
|
|
1191
|
+
...bitstringEntity.validUntil && {
|
|
1192
|
+
validUntil: bitstringEntity.validUntil
|
|
1193
|
+
},
|
|
1194
|
+
...bitstringEntity.ttl && {
|
|
1195
|
+
ttl: bitstringEntity.ttl
|
|
1196
|
+
}
|
|
1197
|
+
}
|
|
1198
|
+
};
|
|
1199
|
+
}
|
|
1076
1200
|
}
|
|
1077
1201
|
/**
|
|
1078
1202
|
* Creates a credential status entry for a specific credential in a status list
|
|
@@ -1082,20 +1206,17 @@ var BitstringStatusListImplementation = class {
|
|
|
1082
1206
|
*/
|
|
1083
1207
|
async createCredentialStatus(args) {
|
|
1084
1208
|
const { statusList, statusListEntry, statusListIndex } = args;
|
|
1085
|
-
const isBitstringEntry = /* @__PURE__ */ __name((entry) => {
|
|
1086
|
-
return "statusPurpose" in entry;
|
|
1087
|
-
}, "isBitstringEntry");
|
|
1088
|
-
if (!isBitstringEntry(statusListEntry)) {
|
|
1089
|
-
throw new Error("Expected bitstring status list entry for bitstring status list");
|
|
1090
|
-
}
|
|
1091
1209
|
const bitstringStatusList = statusList;
|
|
1210
|
+
const bitstringStatusListEntry = statusListEntry;
|
|
1092
1211
|
return {
|
|
1093
1212
|
id: `${statusList.id}#${statusListIndex}`,
|
|
1094
1213
|
type: "BitstringStatusListEntry",
|
|
1095
|
-
statusPurpose:
|
|
1214
|
+
statusPurpose: bitstringStatusListEntry.statusPurpose,
|
|
1096
1215
|
statusListIndex: "" + statusListIndex,
|
|
1097
1216
|
statusListCredential: statusList.id,
|
|
1098
|
-
bitsPerStatus: bitstringStatusList.bitsPerStatus
|
|
1217
|
+
bitsPerStatus: bitstringStatusList.bitsPerStatus,
|
|
1218
|
+
statusMessage: bitstringStatusListEntry.statusMessage,
|
|
1219
|
+
statusReference: bitstringStatusListEntry.statusReference
|
|
1099
1220
|
};
|
|
1100
1221
|
}
|
|
1101
1222
|
/**
|
|
@@ -1289,18 +1410,24 @@ async function updateStatusIndexFromStatusListCredential(args, context) {
|
|
|
1289
1410
|
return implementation.updateStatusListIndex(args, context);
|
|
1290
1411
|
}
|
|
1291
1412
|
__name(updateStatusIndexFromStatusListCredential, "updateStatusIndexFromStatusListCredential");
|
|
1292
|
-
async function
|
|
1293
|
-
const
|
|
1413
|
+
async function extractCredentialDetails(statusListCredential) {
|
|
1414
|
+
const statusListType = determineStatusListType(statusListCredential);
|
|
1294
1415
|
const implementation = getStatusListImplementation(statusListType);
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1416
|
+
return implementation.extractCredentialDetails(statusListCredential);
|
|
1417
|
+
}
|
|
1418
|
+
__name(extractCredentialDetails, "extractCredentialDetails");
|
|
1419
|
+
async function toStatusListDetails(args) {
|
|
1420
|
+
if ("statusListCredential" in args) {
|
|
1421
|
+
const statusListType = args.statusListType;
|
|
1422
|
+
const implementation = getStatusListImplementation(statusListType);
|
|
1423
|
+
return implementation.toStatusListDetails(args);
|
|
1424
|
+
} else {
|
|
1425
|
+
const statusListType = args.statusListEntity.type;
|
|
1426
|
+
const implementation = getStatusListImplementation(statusListType);
|
|
1427
|
+
return implementation.toStatusListDetails(args);
|
|
1428
|
+
}
|
|
1302
1429
|
}
|
|
1303
|
-
__name(
|
|
1430
|
+
__name(toStatusListDetails, "toStatusListDetails");
|
|
1304
1431
|
async function createCredentialStatusFromStatusList(args) {
|
|
1305
1432
|
const { statusList, statusListEntry, statusListIndex } = args;
|
|
1306
1433
|
const statusListType = determineStatusListType(statusList.statusListCredential);
|
|
@@ -1365,11 +1492,13 @@ export {
|
|
|
1365
1492
|
checkStatusIndexFromStatusListCredential,
|
|
1366
1493
|
createCredentialStatusFromStatusList,
|
|
1367
1494
|
createNewStatusList,
|
|
1495
|
+
determineStatusListType,
|
|
1496
|
+
extractCredentialDetails,
|
|
1368
1497
|
fetchStatusListCredential,
|
|
1369
1498
|
simpleCheckStatusFromStatusListUrl,
|
|
1370
1499
|
statusList2021ToVerifiableCredential,
|
|
1371
|
-
statusListCredentialToDetails,
|
|
1372
1500
|
statusPluginStatusFunction,
|
|
1501
|
+
toStatusListDetails,
|
|
1373
1502
|
updateStatusIndexFromStatusListCredential,
|
|
1374
1503
|
updateStatusListIndexFromEncodedList,
|
|
1375
1504
|
vcLibCheckStatusFunction
|