@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.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,78 @@ 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
|
-
|
|
327
|
-
|
|
328
|
-
|
|
349
|
+
/**
|
|
350
|
+
* Performs the initial parsing of a StatusListCredential.
|
|
351
|
+
* This method handles expensive operations like JWT/CWT decoding once.
|
|
352
|
+
* It extracts all details available from the credential payload itself.
|
|
353
|
+
*/
|
|
354
|
+
async extractCredentialDetails(credential) {
|
|
355
|
+
const uniform = import_ssi_types2.CredentialMapper.toUniformCredential(credential);
|
|
329
356
|
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
|
-
});
|
|
357
|
+
const subject = Array.isArray(credentialSubject) ? credentialSubject[0] : credentialSubject;
|
|
338
358
|
return {
|
|
339
|
-
|
|
340
|
-
id,
|
|
341
|
-
encodedList,
|
|
359
|
+
id: getAssertedValue("id", uniform.id),
|
|
342
360
|
issuer,
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
correlationId
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
361
|
+
encodedList: getAssertedProperty("encodedList", subject)
|
|
362
|
+
};
|
|
363
|
+
}
|
|
364
|
+
async toStatusListDetails(args) {
|
|
365
|
+
if ("statusListCredential" in args) {
|
|
366
|
+
const { statusListCredential, correlationId, driverType } = args;
|
|
367
|
+
const uniform = import_ssi_types2.CredentialMapper.toUniformCredential(statusListCredential);
|
|
368
|
+
const { issuer, credentialSubject } = uniform;
|
|
369
|
+
const subject = Array.isArray(credentialSubject) ? credentialSubject[0] : credentialSubject;
|
|
370
|
+
const id = getAssertedValue("id", uniform.id);
|
|
371
|
+
const encodedList = getAssertedProperty("encodedList", subject);
|
|
372
|
+
const statusPurpose = getAssertedProperty("statusPurpose", subject);
|
|
373
|
+
const proofFormat = import_ssi_types2.CredentialMapper.detectDocumentType(statusListCredential) === import_ssi_types2.DocumentFormat.JWT ? "jwt" : "lds";
|
|
374
|
+
const list = await import_vc_status_list.StatusList.decode({
|
|
375
|
+
encodedList
|
|
376
|
+
});
|
|
377
|
+
return {
|
|
378
|
+
id,
|
|
379
|
+
encodedList,
|
|
380
|
+
issuer,
|
|
381
|
+
type: import_ssi_types2.StatusListType.StatusList2021,
|
|
382
|
+
proofFormat,
|
|
383
|
+
length: list.length,
|
|
384
|
+
statusListCredential,
|
|
385
|
+
statuslistContentType: this.buildContentType(proofFormat),
|
|
386
|
+
correlationId,
|
|
387
|
+
driverType,
|
|
388
|
+
indexingDirection: "rightToLeft",
|
|
356
389
|
statusPurpose,
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
},
|
|
361
|
-
...args.driverType && {
|
|
362
|
-
driverType: args.driverType
|
|
390
|
+
statusList2021: {
|
|
391
|
+
indexingDirection: "rightToLeft",
|
|
392
|
+
statusPurpose
|
|
363
393
|
}
|
|
364
|
-
}
|
|
365
|
-
}
|
|
394
|
+
};
|
|
395
|
+
} else {
|
|
396
|
+
const { extractedDetails, statusListEntity } = args;
|
|
397
|
+
const statusList2021Entity = statusListEntity;
|
|
398
|
+
const proofFormat = import_ssi_types2.CredentialMapper.detectDocumentType(statusListEntity.statusListCredential) === import_ssi_types2.DocumentFormat.JWT ? "jwt" : "lds";
|
|
399
|
+
const list = await import_vc_status_list.StatusList.decode({
|
|
400
|
+
encodedList: extractedDetails.encodedList
|
|
401
|
+
});
|
|
402
|
+
return {
|
|
403
|
+
id: extractedDetails.id,
|
|
404
|
+
encodedList: extractedDetails.encodedList,
|
|
405
|
+
issuer: extractedDetails.issuer,
|
|
406
|
+
type: import_ssi_types2.StatusListType.StatusList2021,
|
|
407
|
+
proofFormat,
|
|
408
|
+
length: list.length,
|
|
409
|
+
statusListCredential: statusListEntity.statusListCredential,
|
|
410
|
+
statuslistContentType: this.buildContentType(proofFormat),
|
|
411
|
+
correlationId: statusListEntity.correlationId,
|
|
412
|
+
driverType: statusListEntity.driverType,
|
|
413
|
+
indexingDirection: statusList2021Entity.indexingDirection,
|
|
414
|
+
statusPurpose: statusList2021Entity.statusPurpose,
|
|
415
|
+
statusList2021: {
|
|
416
|
+
indexingDirection: statusList2021Entity.indexingDirection,
|
|
417
|
+
statusPurpose: statusList2021Entity.statusPurpose
|
|
418
|
+
}
|
|
419
|
+
};
|
|
420
|
+
}
|
|
366
421
|
}
|
|
367
422
|
async createCredentialStatus(args) {
|
|
368
423
|
const { statusList, statusListIndex } = args;
|
|
@@ -764,45 +819,85 @@ var OAuthStatusListImplementation = class {
|
|
|
764
819
|
}
|
|
765
820
|
return statusList.getStatus(index);
|
|
766
821
|
}
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
822
|
+
/**
|
|
823
|
+
* Performs the initial parsing of a StatusListCredential.
|
|
824
|
+
* This method handles expensive operations like JWT/CWT decoding once.
|
|
825
|
+
* It extracts all details available from the credential payload itself.
|
|
826
|
+
*/
|
|
827
|
+
async extractCredentialDetails(credential) {
|
|
828
|
+
if (typeof credential !== "string") {
|
|
829
|
+
return Promise.reject("statusListCredential must be a JWT or CWT string");
|
|
830
|
+
}
|
|
831
|
+
const proofFormat = determineProofFormat(credential);
|
|
832
|
+
const decoded = proofFormat === "jwt" ? decodeStatusListJWT(credential) : decodeStatusListCWT(credential);
|
|
774
833
|
return {
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
encodedList: statusList.compressStatusList(),
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
834
|
+
id: decoded.id,
|
|
835
|
+
issuer: decoded.issuer,
|
|
836
|
+
encodedList: decoded.statusList.compressStatusList(),
|
|
837
|
+
decodedPayload: decoded
|
|
838
|
+
};
|
|
839
|
+
}
|
|
840
|
+
async toStatusListDetails(args) {
|
|
841
|
+
if ("statusListCredential" in args) {
|
|
842
|
+
const { statusListCredential, bitsPerStatus, correlationId, driverType } = args;
|
|
843
|
+
if (!bitsPerStatus || bitsPerStatus < 1) {
|
|
844
|
+
return Promise.reject(Error("bitsPerStatus must be set for OAuth status lists and must be 1 or higher"));
|
|
845
|
+
}
|
|
846
|
+
const proofFormat = determineProofFormat(statusListCredential);
|
|
847
|
+
const decoded = proofFormat === "jwt" ? decodeStatusListJWT(statusListCredential) : decodeStatusListCWT(statusListCredential);
|
|
848
|
+
const { statusList, issuer, id, exp } = decoded;
|
|
849
|
+
const expiresAt = exp ? new Date(exp * 1e3) : void 0;
|
|
850
|
+
return {
|
|
851
|
+
id,
|
|
852
|
+
encodedList: statusList.compressStatusList(),
|
|
853
|
+
issuer,
|
|
854
|
+
type: import_ssi_types4.StatusListType.OAuthStatusList,
|
|
855
|
+
proofFormat,
|
|
856
|
+
length: statusList.statusList.length,
|
|
857
|
+
statusListCredential,
|
|
858
|
+
statuslistContentType: this.buildContentType(proofFormat),
|
|
859
|
+
correlationId,
|
|
860
|
+
driverType,
|
|
793
861
|
bitsPerStatus,
|
|
794
862
|
...expiresAt && {
|
|
795
863
|
expiresAt
|
|
864
|
+
},
|
|
865
|
+
oauthStatusList: {
|
|
866
|
+
bitsPerStatus,
|
|
867
|
+
...expiresAt && {
|
|
868
|
+
expiresAt
|
|
869
|
+
}
|
|
796
870
|
}
|
|
797
|
-
}
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
871
|
+
};
|
|
872
|
+
} else {
|
|
873
|
+
const { extractedDetails, statusListEntity } = args;
|
|
874
|
+
const oauthEntity = statusListEntity;
|
|
875
|
+
const decoded = extractedDetails.decodedPayload;
|
|
876
|
+
const proofFormat = determineProofFormat(statusListEntity.statusListCredential);
|
|
877
|
+
const expiresAt = decoded.exp ? new Date(decoded.exp * 1e3) : void 0;
|
|
878
|
+
return {
|
|
879
|
+
id: extractedDetails.id,
|
|
880
|
+
encodedList: extractedDetails.encodedList,
|
|
881
|
+
issuer: extractedDetails.issuer,
|
|
882
|
+
type: import_ssi_types4.StatusListType.OAuthStatusList,
|
|
883
|
+
proofFormat,
|
|
884
|
+
length: decoded.statusList.statusList.length,
|
|
885
|
+
statusListCredential: statusListEntity.statusListCredential,
|
|
886
|
+
statuslistContentType: this.buildContentType(proofFormat),
|
|
887
|
+
correlationId: statusListEntity.correlationId,
|
|
888
|
+
driverType: statusListEntity.driverType,
|
|
889
|
+
bitsPerStatus: oauthEntity.bitsPerStatus,
|
|
890
|
+
...expiresAt && {
|
|
891
|
+
expiresAt
|
|
892
|
+
},
|
|
893
|
+
oauthStatusList: {
|
|
894
|
+
bitsPerStatus: oauthEntity.bitsPerStatus,
|
|
895
|
+
...expiresAt && {
|
|
896
|
+
expiresAt
|
|
897
|
+
}
|
|
898
|
+
}
|
|
899
|
+
};
|
|
900
|
+
}
|
|
806
901
|
}
|
|
807
902
|
async createCredentialStatus(args) {
|
|
808
903
|
const { statusList, statusListIndex } = args;
|
|
@@ -840,7 +935,7 @@ var import_ssi_types6 = require("@sphereon/ssi-types");
|
|
|
840
935
|
var import_ssi_types5 = require("@sphereon/ssi-types");
|
|
841
936
|
var import_vc_bitstring_status_lists = require("@4sure-tech/vc-bitstring-status-lists");
|
|
842
937
|
var DEFAULT_LIST_LENGTH3 = 131072;
|
|
843
|
-
var DEFAULT_PROOF_FORMAT3 = "
|
|
938
|
+
var DEFAULT_PROOF_FORMAT3 = "vc+jwt";
|
|
844
939
|
var DEFAULT_STATUS_PURPOSE = "revocation";
|
|
845
940
|
var BitstringStatusListImplementation = class {
|
|
846
941
|
static {
|
|
@@ -922,8 +1017,9 @@ var BitstringStatusListImplementation = class {
|
|
|
922
1017
|
encodedList: origEncodedList,
|
|
923
1018
|
statusSize: args.bitsPerStatus
|
|
924
1019
|
});
|
|
925
|
-
|
|
926
|
-
|
|
1020
|
+
const bitstringStatusId = args.value;
|
|
1021
|
+
statusList.setStatus(index, bitstringStatusId);
|
|
1022
|
+
const proofFormat = import_ssi_types5.CredentialMapper.detectDocumentType(credential) === import_ssi_types5.DocumentFormat.JWT ? "vc+jwt" : "lds";
|
|
927
1023
|
const credSubject = Array.isArray(credentialSubject) ? credentialSubject[0] : credentialSubject;
|
|
928
1024
|
const statusPurpose = getAssertedProperty("statusPurpose", credSubject);
|
|
929
1025
|
const validFrom = uniform.validFrom ? new Date(uniform.validFrom) : void 0;
|
|
@@ -1053,53 +1149,48 @@ var BitstringStatusListImplementation = class {
|
|
|
1053
1149
|
return statusList.getStatus(numIndex);
|
|
1054
1150
|
}
|
|
1055
1151
|
/**
|
|
1056
|
-
*
|
|
1057
|
-
*
|
|
1058
|
-
*
|
|
1059
|
-
* @returns Promise resolving to detailed status list information
|
|
1152
|
+
* Performs the initial parsing of a StatusListCredential.
|
|
1153
|
+
* This method handles expensive operations like JWT/CWT decoding once.
|
|
1154
|
+
* It extracts all details available from the credential payload itself.
|
|
1060
1155
|
*/
|
|
1061
|
-
async
|
|
1062
|
-
const
|
|
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);
|
|
1156
|
+
async extractCredentialDetails(credential) {
|
|
1157
|
+
const uniform = import_ssi_types5.CredentialMapper.toUniformCredential(credential);
|
|
1067
1158
|
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);
|
|
1159
|
+
const subject = Array.isArray(credentialSubject) ? credentialSubject[0] : credentialSubject;
|
|
1077
1160
|
return {
|
|
1078
|
-
|
|
1079
|
-
id,
|
|
1080
|
-
encodedList,
|
|
1161
|
+
id: getAssertedValue("id", uniform.id),
|
|
1081
1162
|
issuer,
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
correlationId
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1163
|
+
encodedList: getAssertedProperty("encodedList", subject)
|
|
1164
|
+
};
|
|
1165
|
+
}
|
|
1166
|
+
async toStatusListDetails(args) {
|
|
1167
|
+
if ("statusListCredential" in args) {
|
|
1168
|
+
const { statusListCredential, bitsPerStatus, correlationId, driverType } = args;
|
|
1169
|
+
if (!bitsPerStatus || bitsPerStatus < 1) {
|
|
1170
|
+
return Promise.reject(Error("bitsPerStatus must be set for bitstring status lists and must be 1 or higher"));
|
|
1171
|
+
}
|
|
1172
|
+
const uniform = import_ssi_types5.CredentialMapper.toUniformCredential(statusListCredential);
|
|
1173
|
+
const { issuer, credentialSubject } = uniform;
|
|
1174
|
+
const subject = Array.isArray(credentialSubject) ? credentialSubject[0] : credentialSubject;
|
|
1175
|
+
const id = getAssertedValue("id", uniform.id);
|
|
1176
|
+
const encodedList = getAssertedProperty("encodedList", subject);
|
|
1177
|
+
const statusPurpose = getAssertedProperty("statusPurpose", subject);
|
|
1178
|
+
const validFrom = uniform.validFrom ? new Date(uniform.validFrom) : void 0;
|
|
1179
|
+
const validUntil = uniform.validUntil ? new Date(uniform.validUntil) : void 0;
|
|
1180
|
+
const ttl = subject.ttl;
|
|
1181
|
+
const proofFormat = import_ssi_types5.CredentialMapper.detectDocumentType(statusListCredential) === import_ssi_types5.DocumentFormat.JWT ? "vc+jwt" : "lds";
|
|
1182
|
+
const statuslistLength = import_vc_bitstring_status_lists.BitstreamStatusList.getStatusListLength(encodedList, bitsPerStatus);
|
|
1183
|
+
return {
|
|
1184
|
+
id,
|
|
1185
|
+
encodedList,
|
|
1186
|
+
issuer,
|
|
1187
|
+
type: import_ssi_types5.StatusListType.BitstringStatusList,
|
|
1188
|
+
proofFormat,
|
|
1189
|
+
length: statuslistLength,
|
|
1190
|
+
statusListCredential,
|
|
1191
|
+
statuslistContentType: this.buildContentType(proofFormat),
|
|
1192
|
+
correlationId,
|
|
1193
|
+
driverType,
|
|
1103
1194
|
statusPurpose,
|
|
1104
1195
|
bitsPerStatus,
|
|
1105
1196
|
...validFrom && {
|
|
@@ -1110,16 +1201,66 @@ var BitstringStatusListImplementation = class {
|
|
|
1110
1201
|
},
|
|
1111
1202
|
...ttl && {
|
|
1112
1203
|
ttl
|
|
1204
|
+
},
|
|
1205
|
+
bitstringStatusList: {
|
|
1206
|
+
statusPurpose,
|
|
1207
|
+
bitsPerStatus,
|
|
1208
|
+
...validFrom && {
|
|
1209
|
+
validFrom
|
|
1210
|
+
},
|
|
1211
|
+
...validUntil && {
|
|
1212
|
+
validUntil
|
|
1213
|
+
},
|
|
1214
|
+
...ttl && {
|
|
1215
|
+
ttl
|
|
1216
|
+
}
|
|
1113
1217
|
}
|
|
1114
|
-
}
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
driverType: args.driverType
|
|
1218
|
+
};
|
|
1219
|
+
} else {
|
|
1220
|
+
const { extractedDetails, statusListEntity } = args;
|
|
1221
|
+
const bitstringEntity = statusListEntity;
|
|
1222
|
+
if (!bitstringEntity.bitsPerStatus) {
|
|
1223
|
+
return Promise.reject(Error("bitsPerStatus must be present for a bitstring status list"));
|
|
1121
1224
|
}
|
|
1122
|
-
|
|
1225
|
+
const proofFormat = import_ssi_types5.CredentialMapper.detectDocumentType(statusListEntity.statusListCredential) === import_ssi_types5.DocumentFormat.JWT ? "vc+jwt" : "lds";
|
|
1226
|
+
const statuslistLength = import_vc_bitstring_status_lists.BitstreamStatusList.getStatusListLength(extractedDetails.encodedList, bitstringEntity.bitsPerStatus);
|
|
1227
|
+
return {
|
|
1228
|
+
id: extractedDetails.id,
|
|
1229
|
+
encodedList: extractedDetails.encodedList,
|
|
1230
|
+
issuer: extractedDetails.issuer,
|
|
1231
|
+
type: import_ssi_types5.StatusListType.BitstringStatusList,
|
|
1232
|
+
proofFormat,
|
|
1233
|
+
length: statuslistLength,
|
|
1234
|
+
statusListCredential: statusListEntity.statusListCredential,
|
|
1235
|
+
statuslistContentType: this.buildContentType(proofFormat),
|
|
1236
|
+
correlationId: statusListEntity.correlationId,
|
|
1237
|
+
driverType: statusListEntity.driverType,
|
|
1238
|
+
statusPurpose: bitstringEntity.statusPurpose,
|
|
1239
|
+
bitsPerStatus: bitstringEntity.bitsPerStatus,
|
|
1240
|
+
...bitstringEntity.validFrom && {
|
|
1241
|
+
validFrom: bitstringEntity.validFrom
|
|
1242
|
+
},
|
|
1243
|
+
...bitstringEntity.validUntil && {
|
|
1244
|
+
validUntil: bitstringEntity.validUntil
|
|
1245
|
+
},
|
|
1246
|
+
...bitstringEntity.ttl && {
|
|
1247
|
+
ttl: bitstringEntity.ttl
|
|
1248
|
+
},
|
|
1249
|
+
bitstringStatusList: {
|
|
1250
|
+
statusPurpose: bitstringEntity.statusPurpose,
|
|
1251
|
+
bitsPerStatus: bitstringEntity.bitsPerStatus,
|
|
1252
|
+
...bitstringEntity.validFrom && {
|
|
1253
|
+
validFrom: bitstringEntity.validFrom
|
|
1254
|
+
},
|
|
1255
|
+
...bitstringEntity.validUntil && {
|
|
1256
|
+
validUntil: bitstringEntity.validUntil
|
|
1257
|
+
},
|
|
1258
|
+
...bitstringEntity.ttl && {
|
|
1259
|
+
ttl: bitstringEntity.ttl
|
|
1260
|
+
}
|
|
1261
|
+
}
|
|
1262
|
+
};
|
|
1263
|
+
}
|
|
1123
1264
|
}
|
|
1124
1265
|
/**
|
|
1125
1266
|
* Creates a credential status entry for a specific credential in a status list
|
|
@@ -1129,20 +1270,17 @@ var BitstringStatusListImplementation = class {
|
|
|
1129
1270
|
*/
|
|
1130
1271
|
async createCredentialStatus(args) {
|
|
1131
1272
|
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
1273
|
const bitstringStatusList = statusList;
|
|
1274
|
+
const bitstringStatusListEntry = statusListEntry;
|
|
1139
1275
|
return {
|
|
1140
1276
|
id: `${statusList.id}#${statusListIndex}`,
|
|
1141
1277
|
type: "BitstringStatusListEntry",
|
|
1142
|
-
statusPurpose:
|
|
1278
|
+
statusPurpose: bitstringStatusListEntry.statusPurpose,
|
|
1143
1279
|
statusListIndex: "" + statusListIndex,
|
|
1144
1280
|
statusListCredential: statusList.id,
|
|
1145
|
-
bitsPerStatus: bitstringStatusList.bitsPerStatus
|
|
1281
|
+
bitsPerStatus: bitstringStatusList.bitsPerStatus,
|
|
1282
|
+
statusMessage: bitstringStatusListEntry.statusMessage,
|
|
1283
|
+
statusReference: bitstringStatusListEntry.statusReference
|
|
1146
1284
|
};
|
|
1147
1285
|
}
|
|
1148
1286
|
/**
|
|
@@ -1336,18 +1474,24 @@ async function updateStatusIndexFromStatusListCredential(args, context) {
|
|
|
1336
1474
|
return implementation.updateStatusListIndex(args, context);
|
|
1337
1475
|
}
|
|
1338
1476
|
__name(updateStatusIndexFromStatusListCredential, "updateStatusIndexFromStatusListCredential");
|
|
1339
|
-
async function
|
|
1340
|
-
const
|
|
1477
|
+
async function extractCredentialDetails(statusListCredential) {
|
|
1478
|
+
const statusListType = determineStatusListType(statusListCredential);
|
|
1341
1479
|
const implementation = getStatusListImplementation(statusListType);
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1480
|
+
return implementation.extractCredentialDetails(statusListCredential);
|
|
1481
|
+
}
|
|
1482
|
+
__name(extractCredentialDetails, "extractCredentialDetails");
|
|
1483
|
+
async function toStatusListDetails(args) {
|
|
1484
|
+
if ("statusListCredential" in args) {
|
|
1485
|
+
const statusListType = args.statusListType;
|
|
1486
|
+
const implementation = getStatusListImplementation(statusListType);
|
|
1487
|
+
return implementation.toStatusListDetails(args);
|
|
1488
|
+
} else {
|
|
1489
|
+
const statusListType = args.statusListEntity.type;
|
|
1490
|
+
const implementation = getStatusListImplementation(statusListType);
|
|
1491
|
+
return implementation.toStatusListDetails(args);
|
|
1492
|
+
}
|
|
1349
1493
|
}
|
|
1350
|
-
__name(
|
|
1494
|
+
__name(toStatusListDetails, "toStatusListDetails");
|
|
1351
1495
|
async function createCredentialStatusFromStatusList(args) {
|
|
1352
1496
|
const { statusList, statusListEntry, statusListIndex } = args;
|
|
1353
1497
|
const statusListType = determineStatusListType(statusList.statusListCredential);
|