@sphereon/ssi-sdk.vc-status-list 0.34.1-feature.SSISDK.17.bitstring.sl.13 → 0.34.1-feature.SSISDK.17.bitstring.sl.16
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 +303 -159
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +117 -43
- package/dist/index.d.ts +117 -43
- package/dist/index.js +303 -159
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
- package/src/functions.ts +100 -36
- package/src/impl/BitstringStatusListImplementation.ts +117 -65
- package/src/impl/IStatusList.ts +35 -7
- package/src/impl/OAuthStatusList.ts +82 -30
- package/src/impl/StatusList2021.ts +78 -34
- package/src/index.ts +1 -0
- package/src/types/index.ts +18 -39
- 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,78 @@ 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
|
-
|
|
280
|
-
|
|
281
|
-
|
|
300
|
+
/**
|
|
301
|
+
* Performs the initial parsing of a StatusListCredential.
|
|
302
|
+
* This method handles expensive operations like JWT/CWT decoding once.
|
|
303
|
+
* It extracts all details available from the credential payload itself.
|
|
304
|
+
*/
|
|
305
|
+
async extractCredentialDetails(credential) {
|
|
306
|
+
const uniform = CredentialMapper2.toUniformCredential(credential);
|
|
282
307
|
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
|
-
});
|
|
308
|
+
const subject = Array.isArray(credentialSubject) ? credentialSubject[0] : credentialSubject;
|
|
291
309
|
return {
|
|
292
|
-
|
|
293
|
-
id,
|
|
294
|
-
encodedList,
|
|
310
|
+
id: getAssertedValue("id", uniform.id),
|
|
295
311
|
issuer,
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
correlationId
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
312
|
+
encodedList: getAssertedProperty("encodedList", subject)
|
|
313
|
+
};
|
|
314
|
+
}
|
|
315
|
+
async toStatusListDetails(args) {
|
|
316
|
+
if ("statusListCredential" in args) {
|
|
317
|
+
const { statusListCredential, correlationId, driverType } = args;
|
|
318
|
+
const uniform = CredentialMapper2.toUniformCredential(statusListCredential);
|
|
319
|
+
const { issuer, credentialSubject } = uniform;
|
|
320
|
+
const subject = Array.isArray(credentialSubject) ? credentialSubject[0] : credentialSubject;
|
|
321
|
+
const id = getAssertedValue("id", uniform.id);
|
|
322
|
+
const encodedList = getAssertedProperty("encodedList", subject);
|
|
323
|
+
const statusPurpose = getAssertedProperty("statusPurpose", subject);
|
|
324
|
+
const proofFormat = CredentialMapper2.detectDocumentType(statusListCredential) === DocumentFormat2.JWT ? "jwt" : "lds";
|
|
325
|
+
const list = await StatusList.decode({
|
|
326
|
+
encodedList
|
|
327
|
+
});
|
|
328
|
+
return {
|
|
329
|
+
id,
|
|
330
|
+
encodedList,
|
|
331
|
+
issuer,
|
|
332
|
+
type: StatusListType2.StatusList2021,
|
|
333
|
+
proofFormat,
|
|
334
|
+
length: list.length,
|
|
335
|
+
statusListCredential,
|
|
336
|
+
statuslistContentType: this.buildContentType(proofFormat),
|
|
337
|
+
correlationId,
|
|
338
|
+
driverType,
|
|
339
|
+
indexingDirection: "rightToLeft",
|
|
309
340
|
statusPurpose,
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
},
|
|
314
|
-
...args.driverType && {
|
|
315
|
-
driverType: args.driverType
|
|
341
|
+
statusList2021: {
|
|
342
|
+
indexingDirection: "rightToLeft",
|
|
343
|
+
statusPurpose
|
|
316
344
|
}
|
|
317
|
-
}
|
|
318
|
-
}
|
|
345
|
+
};
|
|
346
|
+
} else {
|
|
347
|
+
const { extractedDetails, statusListEntity } = args;
|
|
348
|
+
const statusList2021Entity = statusListEntity;
|
|
349
|
+
const proofFormat = CredentialMapper2.detectDocumentType(statusListEntity.statusListCredential) === DocumentFormat2.JWT ? "jwt" : "lds";
|
|
350
|
+
const list = await StatusList.decode({
|
|
351
|
+
encodedList: extractedDetails.encodedList
|
|
352
|
+
});
|
|
353
|
+
return {
|
|
354
|
+
id: extractedDetails.id,
|
|
355
|
+
encodedList: extractedDetails.encodedList,
|
|
356
|
+
issuer: extractedDetails.issuer,
|
|
357
|
+
type: StatusListType2.StatusList2021,
|
|
358
|
+
proofFormat,
|
|
359
|
+
length: list.length,
|
|
360
|
+
statusListCredential: statusListEntity.statusListCredential,
|
|
361
|
+
statuslistContentType: this.buildContentType(proofFormat),
|
|
362
|
+
correlationId: statusListEntity.correlationId,
|
|
363
|
+
driverType: statusListEntity.driverType,
|
|
364
|
+
indexingDirection: statusList2021Entity.indexingDirection,
|
|
365
|
+
statusPurpose: statusList2021Entity.statusPurpose,
|
|
366
|
+
statusList2021: {
|
|
367
|
+
indexingDirection: statusList2021Entity.indexingDirection,
|
|
368
|
+
statusPurpose: statusList2021Entity.statusPurpose
|
|
369
|
+
}
|
|
370
|
+
};
|
|
371
|
+
}
|
|
319
372
|
}
|
|
320
373
|
async createCredentialStatus(args) {
|
|
321
374
|
const { statusList, statusListIndex } = args;
|
|
@@ -717,45 +770,85 @@ var OAuthStatusListImplementation = class {
|
|
|
717
770
|
}
|
|
718
771
|
return statusList.getStatus(index);
|
|
719
772
|
}
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
773
|
+
/**
|
|
774
|
+
* Performs the initial parsing of a StatusListCredential.
|
|
775
|
+
* This method handles expensive operations like JWT/CWT decoding once.
|
|
776
|
+
* It extracts all details available from the credential payload itself.
|
|
777
|
+
*/
|
|
778
|
+
async extractCredentialDetails(credential) {
|
|
779
|
+
if (typeof credential !== "string") {
|
|
780
|
+
return Promise.reject("statusListCredential must be a JWT or CWT string");
|
|
781
|
+
}
|
|
782
|
+
const proofFormat = determineProofFormat(credential);
|
|
783
|
+
const decoded = proofFormat === "jwt" ? decodeStatusListJWT(credential) : decodeStatusListCWT(credential);
|
|
727
784
|
return {
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
encodedList: statusList.compressStatusList(),
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
785
|
+
id: decoded.id,
|
|
786
|
+
issuer: decoded.issuer,
|
|
787
|
+
encodedList: decoded.statusList.compressStatusList(),
|
|
788
|
+
decodedPayload: decoded
|
|
789
|
+
};
|
|
790
|
+
}
|
|
791
|
+
async toStatusListDetails(args) {
|
|
792
|
+
if ("statusListCredential" in args) {
|
|
793
|
+
const { statusListCredential, bitsPerStatus, correlationId, driverType } = args;
|
|
794
|
+
if (!bitsPerStatus || bitsPerStatus < 1) {
|
|
795
|
+
return Promise.reject(Error("bitsPerStatus must be set for OAuth status lists and must be 1 or higher"));
|
|
796
|
+
}
|
|
797
|
+
const proofFormat = determineProofFormat(statusListCredential);
|
|
798
|
+
const decoded = proofFormat === "jwt" ? decodeStatusListJWT(statusListCredential) : decodeStatusListCWT(statusListCredential);
|
|
799
|
+
const { statusList, issuer, id, exp } = decoded;
|
|
800
|
+
const expiresAt = exp ? new Date(exp * 1e3) : void 0;
|
|
801
|
+
return {
|
|
802
|
+
id,
|
|
803
|
+
encodedList: statusList.compressStatusList(),
|
|
804
|
+
issuer,
|
|
805
|
+
type: StatusListType3.OAuthStatusList,
|
|
806
|
+
proofFormat,
|
|
807
|
+
length: statusList.statusList.length,
|
|
808
|
+
statusListCredential,
|
|
809
|
+
statuslistContentType: this.buildContentType(proofFormat),
|
|
810
|
+
correlationId,
|
|
811
|
+
driverType,
|
|
746
812
|
bitsPerStatus,
|
|
747
813
|
...expiresAt && {
|
|
748
814
|
expiresAt
|
|
815
|
+
},
|
|
816
|
+
oauthStatusList: {
|
|
817
|
+
bitsPerStatus,
|
|
818
|
+
...expiresAt && {
|
|
819
|
+
expiresAt
|
|
820
|
+
}
|
|
749
821
|
}
|
|
750
|
-
}
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
822
|
+
};
|
|
823
|
+
} else {
|
|
824
|
+
const { extractedDetails, statusListEntity } = args;
|
|
825
|
+
const oauthEntity = statusListEntity;
|
|
826
|
+
const decoded = extractedDetails.decodedPayload;
|
|
827
|
+
const proofFormat = determineProofFormat(statusListEntity.statusListCredential);
|
|
828
|
+
const expiresAt = decoded.exp ? new Date(decoded.exp * 1e3) : void 0;
|
|
829
|
+
return {
|
|
830
|
+
id: extractedDetails.id,
|
|
831
|
+
encodedList: extractedDetails.encodedList,
|
|
832
|
+
issuer: extractedDetails.issuer,
|
|
833
|
+
type: StatusListType3.OAuthStatusList,
|
|
834
|
+
proofFormat,
|
|
835
|
+
length: decoded.statusList.statusList.length,
|
|
836
|
+
statusListCredential: statusListEntity.statusListCredential,
|
|
837
|
+
statuslistContentType: this.buildContentType(proofFormat),
|
|
838
|
+
correlationId: statusListEntity.correlationId,
|
|
839
|
+
driverType: statusListEntity.driverType,
|
|
840
|
+
bitsPerStatus: oauthEntity.bitsPerStatus,
|
|
841
|
+
...expiresAt && {
|
|
842
|
+
expiresAt
|
|
843
|
+
},
|
|
844
|
+
oauthStatusList: {
|
|
845
|
+
bitsPerStatus: oauthEntity.bitsPerStatus,
|
|
846
|
+
...expiresAt && {
|
|
847
|
+
expiresAt
|
|
848
|
+
}
|
|
849
|
+
}
|
|
850
|
+
};
|
|
851
|
+
}
|
|
759
852
|
}
|
|
760
853
|
async createCredentialStatus(args) {
|
|
761
854
|
const { statusList, statusListIndex } = args;
|
|
@@ -793,7 +886,7 @@ import { StatusListType as StatusListType5 } from "@sphereon/ssi-types";
|
|
|
793
886
|
import { CredentialMapper as CredentialMapper3, DocumentFormat as DocumentFormat3, StatusListType as StatusListType4 } from "@sphereon/ssi-types";
|
|
794
887
|
import { BitstreamStatusList, createStatusListCredential } from "@4sure-tech/vc-bitstring-status-lists";
|
|
795
888
|
var DEFAULT_LIST_LENGTH3 = 131072;
|
|
796
|
-
var DEFAULT_PROOF_FORMAT3 = "
|
|
889
|
+
var DEFAULT_PROOF_FORMAT3 = "vc+jwt";
|
|
797
890
|
var DEFAULT_STATUS_PURPOSE = "revocation";
|
|
798
891
|
var BitstringStatusListImplementation = class {
|
|
799
892
|
static {
|
|
@@ -875,8 +968,9 @@ var BitstringStatusListImplementation = class {
|
|
|
875
968
|
encodedList: origEncodedList,
|
|
876
969
|
statusSize: args.bitsPerStatus
|
|
877
970
|
});
|
|
878
|
-
|
|
879
|
-
|
|
971
|
+
const bitstringStatusId = args.value;
|
|
972
|
+
statusList.setStatus(index, bitstringStatusId);
|
|
973
|
+
const proofFormat = CredentialMapper3.detectDocumentType(credential) === DocumentFormat3.JWT ? "vc+jwt" : "lds";
|
|
880
974
|
const credSubject = Array.isArray(credentialSubject) ? credentialSubject[0] : credentialSubject;
|
|
881
975
|
const statusPurpose = getAssertedProperty("statusPurpose", credSubject);
|
|
882
976
|
const validFrom = uniform.validFrom ? new Date(uniform.validFrom) : void 0;
|
|
@@ -1006,53 +1100,48 @@ var BitstringStatusListImplementation = class {
|
|
|
1006
1100
|
return statusList.getStatus(numIndex);
|
|
1007
1101
|
}
|
|
1008
1102
|
/**
|
|
1009
|
-
*
|
|
1010
|
-
*
|
|
1011
|
-
*
|
|
1012
|
-
* @returns Promise resolving to detailed status list information
|
|
1103
|
+
* Performs the initial parsing of a StatusListCredential.
|
|
1104
|
+
* This method handles expensive operations like JWT/CWT decoding once.
|
|
1105
|
+
* It extracts all details available from the credential payload itself.
|
|
1013
1106
|
*/
|
|
1014
|
-
async
|
|
1015
|
-
const
|
|
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);
|
|
1107
|
+
async extractCredentialDetails(credential) {
|
|
1108
|
+
const uniform = CredentialMapper3.toUniformCredential(credential);
|
|
1020
1109
|
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);
|
|
1110
|
+
const subject = Array.isArray(credentialSubject) ? credentialSubject[0] : credentialSubject;
|
|
1030
1111
|
return {
|
|
1031
|
-
|
|
1032
|
-
id,
|
|
1033
|
-
encodedList,
|
|
1112
|
+
id: getAssertedValue("id", uniform.id),
|
|
1034
1113
|
issuer,
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
correlationId
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1114
|
+
encodedList: getAssertedProperty("encodedList", subject)
|
|
1115
|
+
};
|
|
1116
|
+
}
|
|
1117
|
+
async toStatusListDetails(args) {
|
|
1118
|
+
if ("statusListCredential" in args) {
|
|
1119
|
+
const { statusListCredential, bitsPerStatus, correlationId, driverType } = args;
|
|
1120
|
+
if (!bitsPerStatus || bitsPerStatus < 1) {
|
|
1121
|
+
return Promise.reject(Error("bitsPerStatus must be set for bitstring status lists and must be 1 or higher"));
|
|
1122
|
+
}
|
|
1123
|
+
const uniform = CredentialMapper3.toUniformCredential(statusListCredential);
|
|
1124
|
+
const { issuer, credentialSubject } = uniform;
|
|
1125
|
+
const subject = Array.isArray(credentialSubject) ? credentialSubject[0] : credentialSubject;
|
|
1126
|
+
const id = getAssertedValue("id", uniform.id);
|
|
1127
|
+
const encodedList = getAssertedProperty("encodedList", subject);
|
|
1128
|
+
const statusPurpose = getAssertedProperty("statusPurpose", subject);
|
|
1129
|
+
const validFrom = uniform.validFrom ? new Date(uniform.validFrom) : void 0;
|
|
1130
|
+
const validUntil = uniform.validUntil ? new Date(uniform.validUntil) : void 0;
|
|
1131
|
+
const ttl = subject.ttl;
|
|
1132
|
+
const proofFormat = CredentialMapper3.detectDocumentType(statusListCredential) === DocumentFormat3.JWT ? "vc+jwt" : "lds";
|
|
1133
|
+
const statuslistLength = BitstreamStatusList.getStatusListLength(encodedList, bitsPerStatus);
|
|
1134
|
+
return {
|
|
1135
|
+
id,
|
|
1136
|
+
encodedList,
|
|
1137
|
+
issuer,
|
|
1138
|
+
type: StatusListType4.BitstringStatusList,
|
|
1139
|
+
proofFormat,
|
|
1140
|
+
length: statuslistLength,
|
|
1141
|
+
statusListCredential,
|
|
1142
|
+
statuslistContentType: this.buildContentType(proofFormat),
|
|
1143
|
+
correlationId,
|
|
1144
|
+
driverType,
|
|
1056
1145
|
statusPurpose,
|
|
1057
1146
|
bitsPerStatus,
|
|
1058
1147
|
...validFrom && {
|
|
@@ -1063,16 +1152,66 @@ var BitstringStatusListImplementation = class {
|
|
|
1063
1152
|
},
|
|
1064
1153
|
...ttl && {
|
|
1065
1154
|
ttl
|
|
1155
|
+
},
|
|
1156
|
+
bitstringStatusList: {
|
|
1157
|
+
statusPurpose,
|
|
1158
|
+
bitsPerStatus,
|
|
1159
|
+
...validFrom && {
|
|
1160
|
+
validFrom
|
|
1161
|
+
},
|
|
1162
|
+
...validUntil && {
|
|
1163
|
+
validUntil
|
|
1164
|
+
},
|
|
1165
|
+
...ttl && {
|
|
1166
|
+
ttl
|
|
1167
|
+
}
|
|
1066
1168
|
}
|
|
1067
|
-
}
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
driverType: args.driverType
|
|
1169
|
+
};
|
|
1170
|
+
} else {
|
|
1171
|
+
const { extractedDetails, statusListEntity } = args;
|
|
1172
|
+
const bitstringEntity = statusListEntity;
|
|
1173
|
+
if (!bitstringEntity.bitsPerStatus) {
|
|
1174
|
+
return Promise.reject(Error("bitsPerStatus must be present for a bitstring status list"));
|
|
1074
1175
|
}
|
|
1075
|
-
|
|
1176
|
+
const proofFormat = CredentialMapper3.detectDocumentType(statusListEntity.statusListCredential) === DocumentFormat3.JWT ? "vc+jwt" : "lds";
|
|
1177
|
+
const statuslistLength = BitstreamStatusList.getStatusListLength(extractedDetails.encodedList, bitstringEntity.bitsPerStatus);
|
|
1178
|
+
return {
|
|
1179
|
+
id: extractedDetails.id,
|
|
1180
|
+
encodedList: extractedDetails.encodedList,
|
|
1181
|
+
issuer: extractedDetails.issuer,
|
|
1182
|
+
type: StatusListType4.BitstringStatusList,
|
|
1183
|
+
proofFormat,
|
|
1184
|
+
length: statuslistLength,
|
|
1185
|
+
statusListCredential: statusListEntity.statusListCredential,
|
|
1186
|
+
statuslistContentType: this.buildContentType(proofFormat),
|
|
1187
|
+
correlationId: statusListEntity.correlationId,
|
|
1188
|
+
driverType: statusListEntity.driverType,
|
|
1189
|
+
statusPurpose: bitstringEntity.statusPurpose,
|
|
1190
|
+
bitsPerStatus: bitstringEntity.bitsPerStatus,
|
|
1191
|
+
...bitstringEntity.validFrom && {
|
|
1192
|
+
validFrom: bitstringEntity.validFrom
|
|
1193
|
+
},
|
|
1194
|
+
...bitstringEntity.validUntil && {
|
|
1195
|
+
validUntil: bitstringEntity.validUntil
|
|
1196
|
+
},
|
|
1197
|
+
...bitstringEntity.ttl && {
|
|
1198
|
+
ttl: bitstringEntity.ttl
|
|
1199
|
+
},
|
|
1200
|
+
bitstringStatusList: {
|
|
1201
|
+
statusPurpose: bitstringEntity.statusPurpose,
|
|
1202
|
+
bitsPerStatus: bitstringEntity.bitsPerStatus,
|
|
1203
|
+
...bitstringEntity.validFrom && {
|
|
1204
|
+
validFrom: bitstringEntity.validFrom
|
|
1205
|
+
},
|
|
1206
|
+
...bitstringEntity.validUntil && {
|
|
1207
|
+
validUntil: bitstringEntity.validUntil
|
|
1208
|
+
},
|
|
1209
|
+
...bitstringEntity.ttl && {
|
|
1210
|
+
ttl: bitstringEntity.ttl
|
|
1211
|
+
}
|
|
1212
|
+
}
|
|
1213
|
+
};
|
|
1214
|
+
}
|
|
1076
1215
|
}
|
|
1077
1216
|
/**
|
|
1078
1217
|
* Creates a credential status entry for a specific credential in a status list
|
|
@@ -1082,20 +1221,17 @@ var BitstringStatusListImplementation = class {
|
|
|
1082
1221
|
*/
|
|
1083
1222
|
async createCredentialStatus(args) {
|
|
1084
1223
|
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
1224
|
const bitstringStatusList = statusList;
|
|
1225
|
+
const bitstringStatusListEntry = statusListEntry;
|
|
1092
1226
|
return {
|
|
1093
1227
|
id: `${statusList.id}#${statusListIndex}`,
|
|
1094
1228
|
type: "BitstringStatusListEntry",
|
|
1095
|
-
statusPurpose:
|
|
1229
|
+
statusPurpose: bitstringStatusListEntry.statusPurpose,
|
|
1096
1230
|
statusListIndex: "" + statusListIndex,
|
|
1097
1231
|
statusListCredential: statusList.id,
|
|
1098
|
-
bitsPerStatus: bitstringStatusList.bitsPerStatus
|
|
1232
|
+
bitsPerStatus: bitstringStatusList.bitsPerStatus,
|
|
1233
|
+
statusMessage: bitstringStatusListEntry.statusMessage,
|
|
1234
|
+
statusReference: bitstringStatusListEntry.statusReference
|
|
1099
1235
|
};
|
|
1100
1236
|
}
|
|
1101
1237
|
/**
|
|
@@ -1289,18 +1425,24 @@ async function updateStatusIndexFromStatusListCredential(args, context) {
|
|
|
1289
1425
|
return implementation.updateStatusListIndex(args, context);
|
|
1290
1426
|
}
|
|
1291
1427
|
__name(updateStatusIndexFromStatusListCredential, "updateStatusIndexFromStatusListCredential");
|
|
1292
|
-
async function
|
|
1293
|
-
const
|
|
1428
|
+
async function extractCredentialDetails(statusListCredential) {
|
|
1429
|
+
const statusListType = determineStatusListType(statusListCredential);
|
|
1294
1430
|
const implementation = getStatusListImplementation(statusListType);
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1431
|
+
return implementation.extractCredentialDetails(statusListCredential);
|
|
1432
|
+
}
|
|
1433
|
+
__name(extractCredentialDetails, "extractCredentialDetails");
|
|
1434
|
+
async function toStatusListDetails(args) {
|
|
1435
|
+
if ("statusListCredential" in args) {
|
|
1436
|
+
const statusListType = args.statusListType;
|
|
1437
|
+
const implementation = getStatusListImplementation(statusListType);
|
|
1438
|
+
return implementation.toStatusListDetails(args);
|
|
1439
|
+
} else {
|
|
1440
|
+
const statusListType = args.statusListEntity.type;
|
|
1441
|
+
const implementation = getStatusListImplementation(statusListType);
|
|
1442
|
+
return implementation.toStatusListDetails(args);
|
|
1443
|
+
}
|
|
1302
1444
|
}
|
|
1303
|
-
__name(
|
|
1445
|
+
__name(toStatusListDetails, "toStatusListDetails");
|
|
1304
1446
|
async function createCredentialStatusFromStatusList(args) {
|
|
1305
1447
|
const { statusList, statusListEntry, statusListIndex } = args;
|
|
1306
1448
|
const statusListType = determineStatusListType(statusList.statusListCredential);
|
|
@@ -1365,11 +1507,13 @@ export {
|
|
|
1365
1507
|
checkStatusIndexFromStatusListCredential,
|
|
1366
1508
|
createCredentialStatusFromStatusList,
|
|
1367
1509
|
createNewStatusList,
|
|
1510
|
+
determineStatusListType,
|
|
1511
|
+
extractCredentialDetails,
|
|
1368
1512
|
fetchStatusListCredential,
|
|
1369
1513
|
simpleCheckStatusFromStatusListUrl,
|
|
1370
1514
|
statusList2021ToVerifiableCredential,
|
|
1371
|
-
statusListCredentialToDetails,
|
|
1372
1515
|
statusPluginStatusFunction,
|
|
1516
|
+
toStatusListDetails,
|
|
1373
1517
|
updateStatusIndexFromStatusListCredential,
|
|
1374
1518
|
updateStatusListIndexFromEncodedList,
|
|
1375
1519
|
vcLibCheckStatusFunction
|