@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.cjs
CHANGED
|
@@ -37,11 +37,13 @@ __export(index_exports, {
|
|
|
37
37
|
checkStatusIndexFromStatusListCredential: () => checkStatusIndexFromStatusListCredential,
|
|
38
38
|
createCredentialStatusFromStatusList: () => createCredentialStatusFromStatusList,
|
|
39
39
|
createNewStatusList: () => createNewStatusList,
|
|
40
|
+
determineStatusListType: () => determineStatusListType,
|
|
41
|
+
extractCredentialDetails: () => extractCredentialDetails,
|
|
40
42
|
fetchStatusListCredential: () => fetchStatusListCredential,
|
|
41
43
|
simpleCheckStatusFromStatusListUrl: () => simpleCheckStatusFromStatusListUrl,
|
|
42
44
|
statusList2021ToVerifiableCredential: () => statusList2021ToVerifiableCredential,
|
|
43
|
-
statusListCredentialToDetails: () => statusListCredentialToDetails,
|
|
44
45
|
statusPluginStatusFunction: () => statusPluginStatusFunction,
|
|
46
|
+
toStatusListDetails: () => toStatusListDetails,
|
|
45
47
|
updateStatusIndexFromStatusListCredential: () => updateStatusIndexFromStatusListCredential,
|
|
46
48
|
updateStatusListIndexFromEncodedList: () => updateStatusListIndexFromEncodedList,
|
|
47
49
|
vcLibCheckStatusFunction: () => vcLibCheckStatusFunction
|
|
@@ -139,29 +141,50 @@ function determineStatusListType(credential) {
|
|
|
139
141
|
const proofFormat = determineProofFormat(credential);
|
|
140
142
|
switch (proofFormat) {
|
|
141
143
|
case "jwt":
|
|
142
|
-
|
|
143
|
-
const keys = Object.keys(payload);
|
|
144
|
-
if (keys.includes("status_list")) {
|
|
145
|
-
return import_ssi_types.StatusListType.OAuthStatusList;
|
|
146
|
-
} else if (keys.includes("vc")) {
|
|
147
|
-
return import_ssi_types.StatusListType.StatusList2021;
|
|
148
|
-
}
|
|
149
|
-
break;
|
|
144
|
+
return determineJwtStatusListType(credential);
|
|
150
145
|
case "lds":
|
|
151
|
-
|
|
152
|
-
const type = uniform.type.find((t) => {
|
|
153
|
-
return Object.values(import_ssi_types.StatusListType).some((statusType) => t.includes(statusType));
|
|
154
|
-
});
|
|
155
|
-
if (!type) {
|
|
156
|
-
throw new Error("Invalid status list credential type");
|
|
157
|
-
}
|
|
158
|
-
return type.replace("Credential", "");
|
|
146
|
+
return determineLdsStatusListType(credential);
|
|
159
147
|
case "cbor":
|
|
160
148
|
return import_ssi_types.StatusListType.OAuthStatusList;
|
|
149
|
+
default:
|
|
150
|
+
throw new Error("Cannot determine status list type from credential payload");
|
|
161
151
|
}
|
|
162
|
-
throw new Error("Cannot determine status list type from credential payload");
|
|
163
152
|
}
|
|
164
153
|
__name(determineStatusListType, "determineStatusListType");
|
|
154
|
+
function determineJwtStatusListType(credential) {
|
|
155
|
+
const payload = (0, import_jwt_decode.jwtDecode)(credential);
|
|
156
|
+
if ("status_list" in payload) {
|
|
157
|
+
return import_ssi_types.StatusListType.OAuthStatusList;
|
|
158
|
+
}
|
|
159
|
+
if ("credentialSubject" in payload) {
|
|
160
|
+
return getStatusListTypeFromSubject(payload.credentialSubject);
|
|
161
|
+
}
|
|
162
|
+
if ("vc" in payload && "credentialSubject" in payload.vc) {
|
|
163
|
+
return getStatusListTypeFromSubject(payload.vc.credentialSubject);
|
|
164
|
+
}
|
|
165
|
+
throw new Error("Invalid status list credential: credentialSubject not found");
|
|
166
|
+
}
|
|
167
|
+
__name(determineJwtStatusListType, "determineJwtStatusListType");
|
|
168
|
+
function determineLdsStatusListType(credential) {
|
|
169
|
+
const uniform = import_ssi_types.CredentialMapper.toUniformCredential(credential);
|
|
170
|
+
const statusListType = uniform.type.find((type) => Object.values(import_ssi_types.StatusListType).some((statusType) => type.includes(statusType)));
|
|
171
|
+
if (!statusListType) {
|
|
172
|
+
throw new Error("Invalid status list credential type");
|
|
173
|
+
}
|
|
174
|
+
return statusListType.replace("Credential", "");
|
|
175
|
+
}
|
|
176
|
+
__name(determineLdsStatusListType, "determineLdsStatusListType");
|
|
177
|
+
function getStatusListTypeFromSubject(credentialSubject) {
|
|
178
|
+
switch (credentialSubject.type) {
|
|
179
|
+
case "StatusList2021":
|
|
180
|
+
return import_ssi_types.StatusListType.StatusList2021;
|
|
181
|
+
case "BitstringStatusList":
|
|
182
|
+
return import_ssi_types.StatusListType.BitstringStatusList;
|
|
183
|
+
default:
|
|
184
|
+
throw new Error(`Unknown credential subject type: ${credentialSubject.type}`);
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
__name(getStatusListTypeFromSubject, "getStatusListTypeFromSubject");
|
|
165
188
|
function determineProofFormat(credential) {
|
|
166
189
|
const type = import_ssi_types.CredentialMapper.detectDocumentType(credential);
|
|
167
190
|
switch (type) {
|
|
@@ -323,46 +346,73 @@ var StatusList2021Implementation = class {
|
|
|
323
346
|
const status = statusList.getStatus(typeof args.statusListIndex === "number" ? args.statusListIndex : parseInt(args.statusListIndex));
|
|
324
347
|
return status ? Status2021.Invalid : Status2021.Valid;
|
|
325
348
|
}
|
|
326
|
-
async
|
|
327
|
-
const
|
|
328
|
-
const uniform = import_ssi_types2.CredentialMapper.toUniformCredential(statusListPayload);
|
|
349
|
+
async extractCredentialDetails(credential) {
|
|
350
|
+
const uniform = import_ssi_types2.CredentialMapper.toUniformCredential(credential);
|
|
329
351
|
const { issuer, credentialSubject } = uniform;
|
|
330
|
-
const
|
|
331
|
-
const encodedList = getAssertedProperty("encodedList", credentialSubject);
|
|
332
|
-
const proofFormat = import_ssi_types2.CredentialMapper.detectDocumentType(statusListPayload) === import_ssi_types2.DocumentFormat.JWT ? "jwt" : "lds";
|
|
333
|
-
const statusPurpose = getAssertedProperty("statusPurpose", credentialSubject);
|
|
334
|
-
const indexingDirection = "rightToLeft";
|
|
335
|
-
const list = await import_vc_status_list.StatusList.decode({
|
|
336
|
-
encodedList
|
|
337
|
-
});
|
|
352
|
+
const subject = Array.isArray(credentialSubject) ? credentialSubject[0] : credentialSubject;
|
|
338
353
|
return {
|
|
339
|
-
|
|
340
|
-
id,
|
|
341
|
-
encodedList,
|
|
354
|
+
id: getAssertedValue("id", uniform.id),
|
|
342
355
|
issuer,
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
correlationId
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
+
encodedList: getAssertedProperty("encodedList", subject)
|
|
357
|
+
};
|
|
358
|
+
}
|
|
359
|
+
async toStatusListDetails(args) {
|
|
360
|
+
if ("statusListCredential" in args) {
|
|
361
|
+
const { statusListCredential, correlationId, driverType } = args;
|
|
362
|
+
const uniform = import_ssi_types2.CredentialMapper.toUniformCredential(statusListCredential);
|
|
363
|
+
const { issuer, credentialSubject } = uniform;
|
|
364
|
+
const subject = Array.isArray(credentialSubject) ? credentialSubject[0] : credentialSubject;
|
|
365
|
+
const id = getAssertedValue("id", uniform.id);
|
|
366
|
+
const encodedList = getAssertedProperty("encodedList", subject);
|
|
367
|
+
const statusPurpose = getAssertedProperty("statusPurpose", subject);
|
|
368
|
+
const proofFormat = import_ssi_types2.CredentialMapper.detectDocumentType(statusListCredential) === import_ssi_types2.DocumentFormat.JWT ? "jwt" : "lds";
|
|
369
|
+
const list = await import_vc_status_list.StatusList.decode({
|
|
370
|
+
encodedList
|
|
371
|
+
});
|
|
372
|
+
return {
|
|
373
|
+
id,
|
|
374
|
+
encodedList,
|
|
375
|
+
issuer,
|
|
376
|
+
type: import_ssi_types2.StatusListType.StatusList2021,
|
|
377
|
+
proofFormat,
|
|
378
|
+
length: list.length,
|
|
379
|
+
statusListCredential,
|
|
380
|
+
statuslistContentType: this.buildContentType(proofFormat),
|
|
381
|
+
correlationId,
|
|
382
|
+
driverType,
|
|
383
|
+
indexingDirection: "rightToLeft",
|
|
356
384
|
statusPurpose,
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
},
|
|
361
|
-
...args.driverType && {
|
|
362
|
-
driverType: args.driverType
|
|
385
|
+
statusList2021: {
|
|
386
|
+
indexingDirection: "rightToLeft",
|
|
387
|
+
statusPurpose
|
|
363
388
|
}
|
|
364
|
-
}
|
|
365
|
-
}
|
|
389
|
+
};
|
|
390
|
+
} else {
|
|
391
|
+
const { extractedDetails, statusListEntity } = args;
|
|
392
|
+
const statusList2021Entity = statusListEntity;
|
|
393
|
+
const proofFormat = import_ssi_types2.CredentialMapper.detectDocumentType(statusListEntity.statusListCredential) === import_ssi_types2.DocumentFormat.JWT ? "jwt" : "lds";
|
|
394
|
+
const list = await import_vc_status_list.StatusList.decode({
|
|
395
|
+
encodedList: extractedDetails.encodedList
|
|
396
|
+
});
|
|
397
|
+
return {
|
|
398
|
+
id: extractedDetails.id,
|
|
399
|
+
encodedList: extractedDetails.encodedList,
|
|
400
|
+
issuer: extractedDetails.issuer,
|
|
401
|
+
type: import_ssi_types2.StatusListType.StatusList2021,
|
|
402
|
+
proofFormat,
|
|
403
|
+
length: list.length,
|
|
404
|
+
statusListCredential: statusListEntity.statusListCredential,
|
|
405
|
+
statuslistContentType: this.buildContentType(proofFormat),
|
|
406
|
+
correlationId: statusListEntity.correlationId,
|
|
407
|
+
driverType: statusListEntity.driverType,
|
|
408
|
+
indexingDirection: statusList2021Entity.indexingDirection,
|
|
409
|
+
statusPurpose: statusList2021Entity.statusPurpose,
|
|
410
|
+
statusList2021: {
|
|
411
|
+
indexingDirection: statusList2021Entity.indexingDirection,
|
|
412
|
+
statusPurpose: statusList2021Entity.statusPurpose
|
|
413
|
+
}
|
|
414
|
+
};
|
|
415
|
+
}
|
|
366
416
|
}
|
|
367
417
|
async createCredentialStatus(args) {
|
|
368
418
|
const { statusList, statusListIndex } = args;
|
|
@@ -764,45 +814,80 @@ var OAuthStatusListImplementation = class {
|
|
|
764
814
|
}
|
|
765
815
|
return statusList.getStatus(index);
|
|
766
816
|
}
|
|
767
|
-
async
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
const
|
|
772
|
-
const
|
|
773
|
-
const expiresAt = exp ? new Date(exp * 1e3) : void 0;
|
|
817
|
+
async extractCredentialDetails(credential) {
|
|
818
|
+
if (typeof credential !== "string") {
|
|
819
|
+
return Promise.reject("statusListCredential must be a JWT or CWT string");
|
|
820
|
+
}
|
|
821
|
+
const proofFormat = determineProofFormat(credential);
|
|
822
|
+
const decoded = proofFormat === "jwt" ? decodeStatusListJWT(credential) : decodeStatusListCWT(credential);
|
|
774
823
|
return {
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
encodedList: statusList.compressStatusList(),
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
824
|
+
id: decoded.id,
|
|
825
|
+
issuer: decoded.issuer,
|
|
826
|
+
encodedList: decoded.statusList.compressStatusList(),
|
|
827
|
+
decodedPayload: decoded
|
|
828
|
+
};
|
|
829
|
+
}
|
|
830
|
+
async toStatusListDetails(args) {
|
|
831
|
+
if ("statusListCredential" in args) {
|
|
832
|
+
const { statusListCredential, bitsPerStatus, correlationId, driverType } = args;
|
|
833
|
+
if (!bitsPerStatus || bitsPerStatus < 1) {
|
|
834
|
+
return Promise.reject(Error("bitsPerStatus must be set for OAuth status lists and must be 1 or higher"));
|
|
835
|
+
}
|
|
836
|
+
const proofFormat = determineProofFormat(statusListCredential);
|
|
837
|
+
const decoded = proofFormat === "jwt" ? decodeStatusListJWT(statusListCredential) : decodeStatusListCWT(statusListCredential);
|
|
838
|
+
const { statusList, issuer, id, exp } = decoded;
|
|
839
|
+
const expiresAt = exp ? new Date(exp * 1e3) : void 0;
|
|
840
|
+
return {
|
|
841
|
+
id,
|
|
842
|
+
encodedList: statusList.compressStatusList(),
|
|
843
|
+
issuer,
|
|
844
|
+
type: import_ssi_types4.StatusListType.OAuthStatusList,
|
|
845
|
+
proofFormat,
|
|
846
|
+
length: statusList.statusList.length,
|
|
847
|
+
statusListCredential,
|
|
848
|
+
statuslistContentType: this.buildContentType(proofFormat),
|
|
849
|
+
correlationId,
|
|
850
|
+
driverType,
|
|
793
851
|
bitsPerStatus,
|
|
794
852
|
...expiresAt && {
|
|
795
853
|
expiresAt
|
|
854
|
+
},
|
|
855
|
+
oauthStatusList: {
|
|
856
|
+
bitsPerStatus,
|
|
857
|
+
...expiresAt && {
|
|
858
|
+
expiresAt
|
|
859
|
+
}
|
|
796
860
|
}
|
|
797
|
-
}
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
861
|
+
};
|
|
862
|
+
} else {
|
|
863
|
+
const { extractedDetails, statusListEntity } = args;
|
|
864
|
+
const oauthEntity = statusListEntity;
|
|
865
|
+
const decoded = extractedDetails.decodedPayload;
|
|
866
|
+
const proofFormat = determineProofFormat(statusListEntity.statusListCredential);
|
|
867
|
+
const expiresAt = decoded.exp ? new Date(decoded.exp * 1e3) : void 0;
|
|
868
|
+
return {
|
|
869
|
+
id: extractedDetails.id,
|
|
870
|
+
encodedList: extractedDetails.encodedList,
|
|
871
|
+
issuer: extractedDetails.issuer,
|
|
872
|
+
type: import_ssi_types4.StatusListType.OAuthStatusList,
|
|
873
|
+
proofFormat,
|
|
874
|
+
length: decoded.statusList.statusList.length,
|
|
875
|
+
statusListCredential: statusListEntity.statusListCredential,
|
|
876
|
+
statuslistContentType: this.buildContentType(proofFormat),
|
|
877
|
+
correlationId: statusListEntity.correlationId,
|
|
878
|
+
driverType: statusListEntity.driverType,
|
|
879
|
+
bitsPerStatus: oauthEntity.bitsPerStatus,
|
|
880
|
+
...expiresAt && {
|
|
881
|
+
expiresAt
|
|
882
|
+
},
|
|
883
|
+
oauthStatusList: {
|
|
884
|
+
bitsPerStatus: oauthEntity.bitsPerStatus,
|
|
885
|
+
...expiresAt && {
|
|
886
|
+
expiresAt
|
|
887
|
+
}
|
|
888
|
+
}
|
|
889
|
+
};
|
|
890
|
+
}
|
|
806
891
|
}
|
|
807
892
|
async createCredentialStatus(args) {
|
|
808
893
|
const { statusList, statusListIndex } = args;
|
|
@@ -840,7 +925,7 @@ var import_ssi_types6 = require("@sphereon/ssi-types");
|
|
|
840
925
|
var import_ssi_types5 = require("@sphereon/ssi-types");
|
|
841
926
|
var import_vc_bitstring_status_lists = require("@4sure-tech/vc-bitstring-status-lists");
|
|
842
927
|
var DEFAULT_LIST_LENGTH3 = 131072;
|
|
843
|
-
var DEFAULT_PROOF_FORMAT3 = "
|
|
928
|
+
var DEFAULT_PROOF_FORMAT3 = "vc+jwt";
|
|
844
929
|
var DEFAULT_STATUS_PURPOSE = "revocation";
|
|
845
930
|
var BitstringStatusListImplementation = class {
|
|
846
931
|
static {
|
|
@@ -922,8 +1007,9 @@ var BitstringStatusListImplementation = class {
|
|
|
922
1007
|
encodedList: origEncodedList,
|
|
923
1008
|
statusSize: args.bitsPerStatus
|
|
924
1009
|
});
|
|
925
|
-
|
|
926
|
-
|
|
1010
|
+
const bitstringStatusId = args.value;
|
|
1011
|
+
statusList.setStatus(index, bitstringStatusId);
|
|
1012
|
+
const proofFormat = import_ssi_types5.CredentialMapper.detectDocumentType(credential) === import_ssi_types5.DocumentFormat.JWT ? "vc+jwt" : "lds";
|
|
927
1013
|
const credSubject = Array.isArray(credentialSubject) ? credentialSubject[0] : credentialSubject;
|
|
928
1014
|
const statusPurpose = getAssertedProperty("statusPurpose", credSubject);
|
|
929
1015
|
const validFrom = uniform.validFrom ? new Date(uniform.validFrom) : void 0;
|
|
@@ -1052,54 +1138,44 @@ var BitstringStatusListImplementation = class {
|
|
|
1052
1138
|
}
|
|
1053
1139
|
return statusList.getStatus(numIndex);
|
|
1054
1140
|
}
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
*
|
|
1058
|
-
* @param args - Conversion parameters including the status list payload
|
|
1059
|
-
* @returns Promise resolving to detailed status list information
|
|
1060
|
-
*/
|
|
1061
|
-
async toStatusListDetails(args) {
|
|
1062
|
-
const { statusListPayload, bitsPerStatus } = args;
|
|
1063
|
-
if (!bitsPerStatus || bitsPerStatus < 1) {
|
|
1064
|
-
return Promise.reject(Error("bitsPerStatus must be set for bitstring status lists and must be 1 or higher. (toStatusListDetails)"));
|
|
1065
|
-
}
|
|
1066
|
-
const uniform = import_ssi_types5.CredentialMapper.toUniformCredential(statusListPayload);
|
|
1141
|
+
async extractCredentialDetails(credential) {
|
|
1142
|
+
const uniform = import_ssi_types5.CredentialMapper.toUniformCredential(credential);
|
|
1067
1143
|
const { issuer, credentialSubject } = uniform;
|
|
1068
|
-
const
|
|
1069
|
-
const encodedList = getAssertedProperty("encodedList", credentialSubject);
|
|
1070
|
-
const proofFormat = import_ssi_types5.CredentialMapper.detectDocumentType(statusListPayload) === import_ssi_types5.DocumentFormat.JWT ? "vc+jwt" : "lds";
|
|
1071
|
-
const credSubject = Array.isArray(credentialSubject) ? credentialSubject[0] : credentialSubject;
|
|
1072
|
-
const statusPurpose = getAssertedProperty("statusPurpose", credSubject);
|
|
1073
|
-
const validFrom = uniform.validFrom ? new Date(uniform.validFrom) : void 0;
|
|
1074
|
-
const validUntil = uniform.validUntil ? new Date(uniform.validUntil) : void 0;
|
|
1075
|
-
const ttl = credSubject.ttl;
|
|
1076
|
-
const statuslistLength = import_vc_bitstring_status_lists.BitstreamStatusList.getStatusListLength(encodedList, bitsPerStatus);
|
|
1144
|
+
const subject = Array.isArray(credentialSubject) ? credentialSubject[0] : credentialSubject;
|
|
1077
1145
|
return {
|
|
1078
|
-
|
|
1079
|
-
id,
|
|
1080
|
-
encodedList,
|
|
1146
|
+
id: getAssertedValue("id", uniform.id),
|
|
1081
1147
|
issuer,
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
correlationId
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1148
|
+
encodedList: getAssertedProperty("encodedList", subject)
|
|
1149
|
+
};
|
|
1150
|
+
}
|
|
1151
|
+
async toStatusListDetails(args) {
|
|
1152
|
+
if ("statusListCredential" in args) {
|
|
1153
|
+
const { statusListCredential, bitsPerStatus, correlationId, driverType } = args;
|
|
1154
|
+
if (!bitsPerStatus || bitsPerStatus < 1) {
|
|
1155
|
+
return Promise.reject(Error("bitsPerStatus must be set for bitstring status lists and must be 1 or higher"));
|
|
1156
|
+
}
|
|
1157
|
+
const uniform = import_ssi_types5.CredentialMapper.toUniformCredential(statusListCredential);
|
|
1158
|
+
const { issuer, credentialSubject } = uniform;
|
|
1159
|
+
const subject = Array.isArray(credentialSubject) ? credentialSubject[0] : credentialSubject;
|
|
1160
|
+
const id = getAssertedValue("id", uniform.id);
|
|
1161
|
+
const encodedList = getAssertedProperty("encodedList", subject);
|
|
1162
|
+
const statusPurpose = getAssertedProperty("statusPurpose", subject);
|
|
1163
|
+
const validFrom = uniform.validFrom ? new Date(uniform.validFrom) : void 0;
|
|
1164
|
+
const validUntil = uniform.validUntil ? new Date(uniform.validUntil) : void 0;
|
|
1165
|
+
const ttl = subject.ttl;
|
|
1166
|
+
const proofFormat = import_ssi_types5.CredentialMapper.detectDocumentType(statusListCredential) === import_ssi_types5.DocumentFormat.JWT ? "vc+jwt" : "lds";
|
|
1167
|
+
const statuslistLength = import_vc_bitstring_status_lists.BitstreamStatusList.getStatusListLength(encodedList, bitsPerStatus);
|
|
1168
|
+
return {
|
|
1169
|
+
id,
|
|
1170
|
+
encodedList,
|
|
1171
|
+
issuer,
|
|
1172
|
+
type: import_ssi_types5.StatusListType.BitstringStatusList,
|
|
1173
|
+
proofFormat,
|
|
1174
|
+
length: statuslistLength,
|
|
1175
|
+
statusListCredential,
|
|
1176
|
+
statuslistContentType: this.buildContentType(proofFormat),
|
|
1177
|
+
correlationId,
|
|
1178
|
+
driverType,
|
|
1103
1179
|
statusPurpose,
|
|
1104
1180
|
bitsPerStatus,
|
|
1105
1181
|
...validFrom && {
|
|
@@ -1110,16 +1186,66 @@ var BitstringStatusListImplementation = class {
|
|
|
1110
1186
|
},
|
|
1111
1187
|
...ttl && {
|
|
1112
1188
|
ttl
|
|
1189
|
+
},
|
|
1190
|
+
bitstringStatusList: {
|
|
1191
|
+
statusPurpose,
|
|
1192
|
+
bitsPerStatus,
|
|
1193
|
+
...validFrom && {
|
|
1194
|
+
validFrom
|
|
1195
|
+
},
|
|
1196
|
+
...validUntil && {
|
|
1197
|
+
validUntil
|
|
1198
|
+
},
|
|
1199
|
+
...ttl && {
|
|
1200
|
+
ttl
|
|
1201
|
+
}
|
|
1113
1202
|
}
|
|
1114
|
-
}
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
driverType: args.driverType
|
|
1203
|
+
};
|
|
1204
|
+
} else {
|
|
1205
|
+
const { extractedDetails, statusListEntity } = args;
|
|
1206
|
+
const bitstringEntity = statusListEntity;
|
|
1207
|
+
if (!bitstringEntity.bitsPerStatus) {
|
|
1208
|
+
return Promise.reject(Error("bitsPerStatus must be present for a bitstring status list"));
|
|
1121
1209
|
}
|
|
1122
|
-
|
|
1210
|
+
const proofFormat = import_ssi_types5.CredentialMapper.detectDocumentType(statusListEntity.statusListCredential) === import_ssi_types5.DocumentFormat.JWT ? "vc+jwt" : "lds";
|
|
1211
|
+
const statuslistLength = import_vc_bitstring_status_lists.BitstreamStatusList.getStatusListLength(extractedDetails.encodedList, bitstringEntity.bitsPerStatus);
|
|
1212
|
+
return {
|
|
1213
|
+
id: extractedDetails.id,
|
|
1214
|
+
encodedList: extractedDetails.encodedList,
|
|
1215
|
+
issuer: extractedDetails.issuer,
|
|
1216
|
+
type: import_ssi_types5.StatusListType.BitstringStatusList,
|
|
1217
|
+
proofFormat,
|
|
1218
|
+
length: statuslistLength,
|
|
1219
|
+
statusListCredential: statusListEntity.statusListCredential,
|
|
1220
|
+
statuslistContentType: this.buildContentType(proofFormat),
|
|
1221
|
+
correlationId: statusListEntity.correlationId,
|
|
1222
|
+
driverType: statusListEntity.driverType,
|
|
1223
|
+
statusPurpose: bitstringEntity.statusPurpose,
|
|
1224
|
+
bitsPerStatus: bitstringEntity.bitsPerStatus,
|
|
1225
|
+
...bitstringEntity.validFrom && {
|
|
1226
|
+
validFrom: bitstringEntity.validFrom
|
|
1227
|
+
},
|
|
1228
|
+
...bitstringEntity.validUntil && {
|
|
1229
|
+
validUntil: bitstringEntity.validUntil
|
|
1230
|
+
},
|
|
1231
|
+
...bitstringEntity.ttl && {
|
|
1232
|
+
ttl: bitstringEntity.ttl
|
|
1233
|
+
},
|
|
1234
|
+
bitstringStatusList: {
|
|
1235
|
+
statusPurpose: bitstringEntity.statusPurpose,
|
|
1236
|
+
bitsPerStatus: bitstringEntity.bitsPerStatus,
|
|
1237
|
+
...bitstringEntity.validFrom && {
|
|
1238
|
+
validFrom: bitstringEntity.validFrom
|
|
1239
|
+
},
|
|
1240
|
+
...bitstringEntity.validUntil && {
|
|
1241
|
+
validUntil: bitstringEntity.validUntil
|
|
1242
|
+
},
|
|
1243
|
+
...bitstringEntity.ttl && {
|
|
1244
|
+
ttl: bitstringEntity.ttl
|
|
1245
|
+
}
|
|
1246
|
+
}
|
|
1247
|
+
};
|
|
1248
|
+
}
|
|
1123
1249
|
}
|
|
1124
1250
|
/**
|
|
1125
1251
|
* Creates a credential status entry for a specific credential in a status list
|
|
@@ -1129,20 +1255,17 @@ var BitstringStatusListImplementation = class {
|
|
|
1129
1255
|
*/
|
|
1130
1256
|
async createCredentialStatus(args) {
|
|
1131
1257
|
const { statusList, statusListEntry, statusListIndex } = args;
|
|
1132
|
-
const isBitstringEntry = /* @__PURE__ */ __name((entry) => {
|
|
1133
|
-
return "statusPurpose" in entry;
|
|
1134
|
-
}, "isBitstringEntry");
|
|
1135
|
-
if (!isBitstringEntry(statusListEntry)) {
|
|
1136
|
-
throw new Error("Expected bitstring status list entry for bitstring status list");
|
|
1137
|
-
}
|
|
1138
1258
|
const bitstringStatusList = statusList;
|
|
1259
|
+
const bitstringStatusListEntry = statusListEntry;
|
|
1139
1260
|
return {
|
|
1140
1261
|
id: `${statusList.id}#${statusListIndex}`,
|
|
1141
1262
|
type: "BitstringStatusListEntry",
|
|
1142
|
-
statusPurpose:
|
|
1263
|
+
statusPurpose: bitstringStatusListEntry.statusPurpose,
|
|
1143
1264
|
statusListIndex: "" + statusListIndex,
|
|
1144
1265
|
statusListCredential: statusList.id,
|
|
1145
|
-
bitsPerStatus: bitstringStatusList.bitsPerStatus
|
|
1266
|
+
bitsPerStatus: bitstringStatusList.bitsPerStatus,
|
|
1267
|
+
statusMessage: bitstringStatusListEntry.statusMessage,
|
|
1268
|
+
statusReference: bitstringStatusListEntry.statusReference
|
|
1146
1269
|
};
|
|
1147
1270
|
}
|
|
1148
1271
|
/**
|
|
@@ -1336,18 +1459,24 @@ async function updateStatusIndexFromStatusListCredential(args, context) {
|
|
|
1336
1459
|
return implementation.updateStatusListIndex(args, context);
|
|
1337
1460
|
}
|
|
1338
1461
|
__name(updateStatusIndexFromStatusListCredential, "updateStatusIndexFromStatusListCredential");
|
|
1339
|
-
async function
|
|
1340
|
-
const
|
|
1462
|
+
async function extractCredentialDetails(statusListCredential) {
|
|
1463
|
+
const statusListType = determineStatusListType(statusListCredential);
|
|
1341
1464
|
const implementation = getStatusListImplementation(statusListType);
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1465
|
+
return implementation.extractCredentialDetails(statusListCredential);
|
|
1466
|
+
}
|
|
1467
|
+
__name(extractCredentialDetails, "extractCredentialDetails");
|
|
1468
|
+
async function toStatusListDetails(args) {
|
|
1469
|
+
if ("statusListCredential" in args) {
|
|
1470
|
+
const statusListType = args.statusListType;
|
|
1471
|
+
const implementation = getStatusListImplementation(statusListType);
|
|
1472
|
+
return implementation.toStatusListDetails(args);
|
|
1473
|
+
} else {
|
|
1474
|
+
const statusListType = args.statusListEntity.type;
|
|
1475
|
+
const implementation = getStatusListImplementation(statusListType);
|
|
1476
|
+
return implementation.toStatusListDetails(args);
|
|
1477
|
+
}
|
|
1349
1478
|
}
|
|
1350
|
-
__name(
|
|
1479
|
+
__name(toStatusListDetails, "toStatusListDetails");
|
|
1351
1480
|
async function createCredentialStatusFromStatusList(args) {
|
|
1352
1481
|
const { statusList, statusListEntry, statusListIndex } = args;
|
|
1353
1482
|
const statusListType = determineStatusListType(statusList.statusListCredential);
|