@sphereon/ssi-sdk.vc-status-list 0.34.1-feature.SSISDK.17.bitstring.sl.10 → 0.34.1-feature.SSISDK.17.bitstring.sl.13
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 +234 -85
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +43 -32
- package/dist/index.d.ts +43 -32
- package/dist/index.js +235 -86
- package/dist/index.js.map +1 -1
- package/package.json +5 -3
- package/src/functions.ts +39 -33
- package/src/impl/BitstringStatusListImplementation.ts +210 -67
- package/src/impl/IStatusList.ts +71 -6
- package/src/impl/OAuthStatusList.ts +48 -11
- package/src/impl/StatusList2021.ts +50 -14
- package/src/types/index.ts +32 -34
- package/src/utils.ts +1 -1
package/dist/index.cjs
CHANGED
|
@@ -35,6 +35,7 @@ __export(index_exports, {
|
|
|
35
35
|
StatusOAuth: () => StatusOAuth,
|
|
36
36
|
checkStatusForCredential: () => checkStatusForCredential,
|
|
37
37
|
checkStatusIndexFromStatusListCredential: () => checkStatusIndexFromStatusListCredential,
|
|
38
|
+
createCredentialStatusFromStatusList: () => createCredentialStatusFromStatusList,
|
|
38
39
|
createNewStatusList: () => createNewStatusList,
|
|
39
40
|
fetchStatusListCredential: () => fetchStatusListCredential,
|
|
40
41
|
simpleCheckStatusFromStatusListUrl: () => simpleCheckStatusFromStatusListUrl,
|
|
@@ -122,7 +123,8 @@ var ValidProofTypeMap = /* @__PURE__ */ new Map([
|
|
|
122
123
|
[
|
|
123
124
|
import_ssi_types.StatusListType.BitstringStatusList,
|
|
124
125
|
[
|
|
125
|
-
"lds"
|
|
126
|
+
"lds",
|
|
127
|
+
"vc+jwt"
|
|
126
128
|
]
|
|
127
129
|
]
|
|
128
130
|
]);
|
|
@@ -257,13 +259,14 @@ var StatusList2021Implementation = class {
|
|
|
257
259
|
encodedList,
|
|
258
260
|
proofFormat
|
|
259
261
|
}, context);
|
|
262
|
+
if (!("statusPurpose" in credentialSubject)) {
|
|
263
|
+
return Promise.reject(Error("statusPurpose is required in credentialSubject for StatusList2021"));
|
|
264
|
+
}
|
|
260
265
|
return {
|
|
261
266
|
statusListCredential: updatedCredential,
|
|
262
267
|
encodedList,
|
|
263
268
|
statusList2021: {
|
|
264
|
-
|
|
265
|
-
statusPurpose: credentialSubject.statusPurpose
|
|
266
|
-
} : {},
|
|
269
|
+
statusPurpose: credentialSubject.statusPurpose,
|
|
267
270
|
indexingDirection: "rightToLeft"
|
|
268
271
|
},
|
|
269
272
|
length: statusList.length - 1,
|
|
@@ -328,10 +331,12 @@ var StatusList2021Implementation = class {
|
|
|
328
331
|
const encodedList = getAssertedProperty("encodedList", credentialSubject);
|
|
329
332
|
const proofFormat = import_ssi_types2.CredentialMapper.detectDocumentType(statusListPayload) === import_ssi_types2.DocumentFormat.JWT ? "jwt" : "lds";
|
|
330
333
|
const statusPurpose = getAssertedProperty("statusPurpose", credentialSubject);
|
|
334
|
+
const indexingDirection = "rightToLeft";
|
|
331
335
|
const list = await import_vc_status_list.StatusList.decode({
|
|
332
336
|
encodedList
|
|
333
337
|
});
|
|
334
338
|
return {
|
|
339
|
+
// Base implementation fields
|
|
335
340
|
id,
|
|
336
341
|
encodedList,
|
|
337
342
|
issuer,
|
|
@@ -340,18 +345,36 @@ var StatusList2021Implementation = class {
|
|
|
340
345
|
length: list.length,
|
|
341
346
|
statusListCredential: statusListPayload,
|
|
342
347
|
statuslistContentType: this.buildContentType(proofFormat),
|
|
348
|
+
correlationId: args.correlationId,
|
|
349
|
+
driverType: args.driverType,
|
|
350
|
+
// Flattened StatusList2021-specific fields
|
|
351
|
+
indexingDirection,
|
|
352
|
+
statusPurpose,
|
|
353
|
+
// Legacy nested structure for backward compatibility
|
|
343
354
|
statusList2021: {
|
|
344
|
-
indexingDirection
|
|
345
|
-
statusPurpose
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
355
|
+
indexingDirection,
|
|
356
|
+
statusPurpose,
|
|
357
|
+
// Optional fields from args
|
|
358
|
+
...args.correlationId && {
|
|
359
|
+
correlationId: args.correlationId
|
|
360
|
+
},
|
|
361
|
+
...args.driverType && {
|
|
362
|
+
driverType: args.driverType
|
|
363
|
+
}
|
|
352
364
|
}
|
|
353
365
|
};
|
|
354
366
|
}
|
|
367
|
+
async createCredentialStatus(args) {
|
|
368
|
+
const { statusList, statusListIndex } = args;
|
|
369
|
+
const statusList2021 = statusList;
|
|
370
|
+
return {
|
|
371
|
+
id: `${statusList.id}#${statusListIndex}`,
|
|
372
|
+
type: "StatusList2021Entry",
|
|
373
|
+
statusPurpose: statusList2021.statusPurpose ?? "revocation",
|
|
374
|
+
statusListIndex: "" + statusListIndex,
|
|
375
|
+
statusListCredential: statusList.id
|
|
376
|
+
};
|
|
377
|
+
}
|
|
355
378
|
async createVerifiableCredential(args, context) {
|
|
356
379
|
const identifier = await context.agent.identifierManagedGet({
|
|
357
380
|
identifier: typeof args.issuer === "string" ? args.issuer : args.issuer.id,
|
|
@@ -728,9 +751,6 @@ var OAuthStatusListImplementation = class {
|
|
|
728
751
|
statuslistContentType: this.buildContentType(proofFormat)
|
|
729
752
|
};
|
|
730
753
|
}
|
|
731
|
-
buildContentType(proofFormat) {
|
|
732
|
-
return `application/statuslist+${proofFormat === "cbor" ? "cwt" : "jwt"}`;
|
|
733
|
-
}
|
|
734
754
|
async checkStatusIndex(args) {
|
|
735
755
|
const { statusListCredential, statusListIndex } = args;
|
|
736
756
|
if (typeof statusListCredential !== "string") {
|
|
@@ -749,7 +769,10 @@ var OAuthStatusListImplementation = class {
|
|
|
749
769
|
const proofFormat = determineProofFormat(statusListPayload);
|
|
750
770
|
const decoded = proofFormat === "jwt" ? decodeStatusListJWT(statusListPayload) : decodeStatusListCWT(statusListPayload);
|
|
751
771
|
const { statusList, issuer, id, exp } = decoded;
|
|
772
|
+
const bitsPerStatus = statusList.getBitsPerStatus();
|
|
773
|
+
const expiresAt = exp ? new Date(exp * 1e3) : void 0;
|
|
752
774
|
return {
|
|
775
|
+
// Base implementation fields
|
|
753
776
|
id,
|
|
754
777
|
encodedList: statusList.compressStatusList(),
|
|
755
778
|
issuer,
|
|
@@ -758,12 +781,21 @@ var OAuthStatusListImplementation = class {
|
|
|
758
781
|
length: statusList.statusList.length,
|
|
759
782
|
statusListCredential: statusListPayload,
|
|
760
783
|
statuslistContentType: this.buildContentType(proofFormat),
|
|
784
|
+
correlationId: args.correlationId,
|
|
785
|
+
driverType: args.driverType,
|
|
786
|
+
// Flattened OAuth-specific fields
|
|
787
|
+
bitsPerStatus,
|
|
788
|
+
...expiresAt && {
|
|
789
|
+
expiresAt
|
|
790
|
+
},
|
|
791
|
+
// Legacy nested structure for backward compatibility
|
|
761
792
|
oauthStatusList: {
|
|
762
|
-
bitsPerStatus
|
|
763
|
-
...
|
|
764
|
-
expiresAt
|
|
793
|
+
bitsPerStatus,
|
|
794
|
+
...expiresAt && {
|
|
795
|
+
expiresAt
|
|
765
796
|
}
|
|
766
797
|
},
|
|
798
|
+
// Optional fields from args
|
|
767
799
|
...args.correlationId && {
|
|
768
800
|
correlationId: args.correlationId
|
|
769
801
|
},
|
|
@@ -772,6 +804,21 @@ var OAuthStatusListImplementation = class {
|
|
|
772
804
|
}
|
|
773
805
|
};
|
|
774
806
|
}
|
|
807
|
+
async createCredentialStatus(args) {
|
|
808
|
+
const { statusList, statusListIndex } = args;
|
|
809
|
+
const oauthStatusList = statusList;
|
|
810
|
+
return {
|
|
811
|
+
id: `${statusList.id}#${statusListIndex}`,
|
|
812
|
+
type: "OAuthStatusListEntry",
|
|
813
|
+
bitsPerStatus: oauthStatusList.bitsPerStatus,
|
|
814
|
+
statusListIndex: "" + statusListIndex,
|
|
815
|
+
statusListCredential: statusList.id,
|
|
816
|
+
expiresAt: oauthStatusList.expiresAt
|
|
817
|
+
};
|
|
818
|
+
}
|
|
819
|
+
buildContentType(proofFormat) {
|
|
820
|
+
return `application/statuslist+${proofFormat === "cbor" ? "cwt" : "jwt"}`;
|
|
821
|
+
}
|
|
775
822
|
async createSignedStatusList(proofFormat, context, statusList, issuerString, id, expiresAt, keyRef) {
|
|
776
823
|
switch (proofFormat) {
|
|
777
824
|
case "jwt": {
|
|
@@ -799,6 +846,13 @@ var BitstringStatusListImplementation = class {
|
|
|
799
846
|
static {
|
|
800
847
|
__name(this, "BitstringStatusListImplementation");
|
|
801
848
|
}
|
|
849
|
+
/**
|
|
850
|
+
* Creates a new bitstring status list with the specified configuration
|
|
851
|
+
*
|
|
852
|
+
* @param args - Configuration for the new status list including issuer, purpose, and size
|
|
853
|
+
* @param context - Veramo agent context for credential operations
|
|
854
|
+
* @returns Promise resolving to the created status list details
|
|
855
|
+
*/
|
|
802
856
|
async createNewStatusList(args, context) {
|
|
803
857
|
if (!args.bitstringStatusList) {
|
|
804
858
|
throw new Error("BitstringStatusList options are required for type BitstringStatusList");
|
|
@@ -806,28 +860,34 @@ var BitstringStatusListImplementation = class {
|
|
|
806
860
|
const length = args?.length ?? DEFAULT_LIST_LENGTH3;
|
|
807
861
|
const proofFormat = args?.proofFormat ?? DEFAULT_PROOF_FORMAT3;
|
|
808
862
|
assertValidProofType(import_ssi_types5.StatusListType.BitstringStatusList, proofFormat);
|
|
809
|
-
const veramoProofFormat = proofFormat;
|
|
810
863
|
const { issuer, id } = args;
|
|
811
864
|
const correlationId = getAssertedValue("correlationId", args.correlationId);
|
|
812
865
|
const { statusPurpose, bitsPerStatus, validFrom, validUntil, ttl } = args.bitstringStatusList;
|
|
813
|
-
const
|
|
814
|
-
|
|
815
|
-
|
|
866
|
+
const unsignedCredential = await (0, import_vc_bitstring_status_lists.createStatusListCredential)({
|
|
867
|
+
id,
|
|
868
|
+
issuer,
|
|
816
869
|
statusPurpose: statusPurpose ?? DEFAULT_STATUS_PURPOSE,
|
|
817
870
|
validFrom: ensureDate(validFrom),
|
|
818
871
|
validUntil: ensureDate(validUntil),
|
|
819
872
|
ttl
|
|
873
|
+
});
|
|
874
|
+
const statusListCredential = await this.createVerifiableCredential({
|
|
875
|
+
unsignedCredential,
|
|
876
|
+
id,
|
|
877
|
+
issuer,
|
|
878
|
+
proofFormat,
|
|
879
|
+
keyRef: args.keyRef
|
|
820
880
|
}, context);
|
|
821
881
|
return {
|
|
822
|
-
encodedList:
|
|
882
|
+
encodedList: unsignedCredential.credentialSubject.encodedList,
|
|
823
883
|
statusListCredential,
|
|
824
884
|
bitstringStatusList: {
|
|
825
885
|
statusPurpose: statusPurpose ?? DEFAULT_STATUS_PURPOSE,
|
|
826
|
-
...
|
|
827
|
-
validFrom: new Date(
|
|
886
|
+
...unsignedCredential.validFrom && {
|
|
887
|
+
validFrom: new Date(unsignedCredential.validFrom)
|
|
828
888
|
},
|
|
829
|
-
...
|
|
830
|
-
validUntil: new Date(
|
|
889
|
+
...unsignedCredential.validUntil && {
|
|
890
|
+
validUntil: new Date(unsignedCredential.validUntil)
|
|
831
891
|
},
|
|
832
892
|
ttl,
|
|
833
893
|
bitsPerStatus
|
|
@@ -841,9 +901,16 @@ var BitstringStatusListImplementation = class {
|
|
|
841
901
|
statuslistContentType: this.buildContentType(proofFormat)
|
|
842
902
|
};
|
|
843
903
|
}
|
|
904
|
+
/**
|
|
905
|
+
* Updates the status of a specific credential in an existing status list
|
|
906
|
+
*
|
|
907
|
+
* @param args - Update parameters including the status list credential, index, and new value
|
|
908
|
+
* @param context - Veramo agent context for credential operations
|
|
909
|
+
* @returns Promise resolving to the updated status list details
|
|
910
|
+
*/
|
|
844
911
|
async updateStatusListIndex(args, context) {
|
|
845
912
|
if (!args.bitsPerStatus || args.bitsPerStatus < 1) {
|
|
846
|
-
return Promise.reject("bitsPerStatus must be set for bitstring status lists and must be 1 or higher. (updateStatusListIndex)");
|
|
913
|
+
return Promise.reject(Error("bitsPerStatus must be set for bitstring status lists and must be 1 or higher. (updateStatusListIndex)"));
|
|
847
914
|
}
|
|
848
915
|
const credential = args.statusListCredential;
|
|
849
916
|
const uniform = import_ssi_types5.CredentialMapper.toUniformCredential(credential);
|
|
@@ -862,27 +929,32 @@ var BitstringStatusListImplementation = class {
|
|
|
862
929
|
const validFrom = uniform.validFrom ? new Date(uniform.validFrom) : void 0;
|
|
863
930
|
const validUntil = uniform.validUntil ? new Date(uniform.validUntil) : void 0;
|
|
864
931
|
const ttl = credSubject.ttl;
|
|
865
|
-
const
|
|
866
|
-
...args,
|
|
932
|
+
const unsignedCredential = await (0, import_vc_bitstring_status_lists.createStatusListCredential)({
|
|
867
933
|
id,
|
|
868
934
|
issuer,
|
|
869
935
|
statusList,
|
|
936
|
+
statusPurpose: statusPurpose ?? DEFAULT_STATUS_PURPOSE,
|
|
937
|
+
validFrom: ensureDate(validFrom),
|
|
938
|
+
validUntil: ensureDate(validUntil),
|
|
939
|
+
ttl
|
|
940
|
+
});
|
|
941
|
+
const updatedCredential = await this.createVerifiableCredential({
|
|
942
|
+
unsignedCredential,
|
|
943
|
+
id,
|
|
944
|
+
issuer,
|
|
870
945
|
proofFormat,
|
|
871
|
-
|
|
872
|
-
ttl,
|
|
873
|
-
validFrom,
|
|
874
|
-
validUntil
|
|
946
|
+
keyRef: args.keyRef
|
|
875
947
|
}, context);
|
|
876
948
|
return {
|
|
877
949
|
statusListCredential: updatedCredential,
|
|
878
|
-
encodedList:
|
|
950
|
+
encodedList: unsignedCredential.credentialSubject.encodedList,
|
|
879
951
|
bitstringStatusList: {
|
|
880
952
|
statusPurpose,
|
|
881
|
-
...
|
|
882
|
-
validFrom: new Date(
|
|
953
|
+
...unsignedCredential.validFrom && {
|
|
954
|
+
validFrom: new Date(unsignedCredential.validFrom)
|
|
883
955
|
},
|
|
884
|
-
...
|
|
885
|
-
validUntil: new Date(
|
|
956
|
+
...unsignedCredential.validUntil && {
|
|
957
|
+
validUntil: new Date(unsignedCredential.validUntil)
|
|
886
958
|
},
|
|
887
959
|
bitsPerStatus: args.bitsPerStatus,
|
|
888
960
|
ttl
|
|
@@ -895,17 +967,23 @@ var BitstringStatusListImplementation = class {
|
|
|
895
967
|
statuslistContentType: this.buildContentType(proofFormat)
|
|
896
968
|
};
|
|
897
969
|
}
|
|
970
|
+
/**
|
|
971
|
+
* Updates a status list by decoding an encoded list, modifying it, and re-encoding
|
|
972
|
+
*
|
|
973
|
+
* @param args - Update parameters including encoded list, index, and new value
|
|
974
|
+
* @param context - Veramo agent context for credential operations
|
|
975
|
+
* @returns Promise resolving to the updated status list details
|
|
976
|
+
*/
|
|
898
977
|
async updateStatusListFromEncodedList(args, context) {
|
|
899
978
|
if (!args.bitstringStatusList) {
|
|
900
979
|
throw new Error("bitstringStatusList options required for type BitstringStatusList");
|
|
901
980
|
}
|
|
902
981
|
if (args.bitstringStatusList.bitsPerStatus < 1) {
|
|
903
|
-
return Promise.reject("bitsPerStatus must be set for bitstring status lists and must be 1 or higher. (updateStatusListFromEncodedList)");
|
|
982
|
+
return Promise.reject(Error("bitsPerStatus must be set for bitstring status lists and must be 1 or higher. (updateStatusListFromEncodedList)"));
|
|
904
983
|
}
|
|
905
984
|
const { statusPurpose, bitsPerStatus, ttl, validFrom, validUntil } = args.bitstringStatusList;
|
|
906
985
|
const proofFormat = args?.proofFormat ?? DEFAULT_PROOF_FORMAT3;
|
|
907
986
|
assertValidProofType(import_ssi_types5.StatusListType.BitstringStatusList, proofFormat);
|
|
908
|
-
const veramoProofFormat = proofFormat;
|
|
909
987
|
const { issuer, id } = getAssertedValues(args);
|
|
910
988
|
const statusList = await import_vc_bitstring_status_lists.BitstreamStatusList.decode({
|
|
911
989
|
encodedList: args.encodedList,
|
|
@@ -913,29 +991,34 @@ var BitstringStatusListImplementation = class {
|
|
|
913
991
|
});
|
|
914
992
|
const index = typeof args.statusListIndex === "number" ? args.statusListIndex : parseInt(args.statusListIndex);
|
|
915
993
|
statusList.setStatus(index, args.value);
|
|
916
|
-
const
|
|
994
|
+
const unsignedCredential = await (0, import_vc_bitstring_status_lists.createStatusListCredential)({
|
|
917
995
|
id,
|
|
918
996
|
issuer,
|
|
919
997
|
statusList,
|
|
920
|
-
|
|
921
|
-
keyRef: args.keyRef,
|
|
922
|
-
statusPurpose,
|
|
998
|
+
statusPurpose: statusPurpose ?? DEFAULT_STATUS_PURPOSE,
|
|
923
999
|
validFrom: ensureDate(validFrom),
|
|
924
1000
|
validUntil: ensureDate(validUntil),
|
|
925
1001
|
ttl
|
|
1002
|
+
});
|
|
1003
|
+
const credential = await this.createVerifiableCredential({
|
|
1004
|
+
unsignedCredential,
|
|
1005
|
+
id,
|
|
1006
|
+
issuer,
|
|
1007
|
+
proofFormat,
|
|
1008
|
+
keyRef: args.keyRef
|
|
926
1009
|
}, context);
|
|
927
1010
|
return {
|
|
928
1011
|
type: import_ssi_types5.StatusListType.BitstringStatusList,
|
|
929
1012
|
statusListCredential: credential,
|
|
930
|
-
encodedList:
|
|
1013
|
+
encodedList: unsignedCredential.credentialSubject.encodedList,
|
|
931
1014
|
bitstringStatusList: {
|
|
932
1015
|
statusPurpose,
|
|
933
1016
|
bitsPerStatus,
|
|
934
|
-
...
|
|
935
|
-
validFrom: new Date(
|
|
1017
|
+
...unsignedCredential.validFrom && {
|
|
1018
|
+
validFrom: new Date(unsignedCredential.validFrom)
|
|
936
1019
|
},
|
|
937
|
-
...
|
|
938
|
-
validUntil: new Date(
|
|
1020
|
+
...unsignedCredential.validUntil && {
|
|
1021
|
+
validUntil: new Date(unsignedCredential.validUntil)
|
|
939
1022
|
},
|
|
940
1023
|
ttl
|
|
941
1024
|
},
|
|
@@ -946,17 +1029,22 @@ var BitstringStatusListImplementation = class {
|
|
|
946
1029
|
statuslistContentType: this.buildContentType(proofFormat)
|
|
947
1030
|
};
|
|
948
1031
|
}
|
|
1032
|
+
/**
|
|
1033
|
+
* Checks the status of a specific credential by its index in the status list
|
|
1034
|
+
*
|
|
1035
|
+
* @param args - Check parameters including the status list credential and index
|
|
1036
|
+
* @returns Promise resolving to the status value at the specified index
|
|
1037
|
+
*/
|
|
949
1038
|
async checkStatusIndex(args) {
|
|
950
1039
|
if (!args.bitsPerStatus || args.bitsPerStatus < 1) {
|
|
951
|
-
return Promise.reject("bitsPerStatus must be set for bitstring status lists and must be 1 or higher. (checkStatusIndex)");
|
|
1040
|
+
return Promise.reject(Error("bitsPerStatus must be set for bitstring status lists and must be 1 or higher. (checkStatusIndex)"));
|
|
952
1041
|
}
|
|
953
1042
|
const uniform = import_ssi_types5.CredentialMapper.toUniformCredential(args.statusListCredential);
|
|
954
1043
|
const { credentialSubject } = uniform;
|
|
955
1044
|
const encodedList = getAssertedProperty("encodedList", credentialSubject);
|
|
956
|
-
const statusSize = args.bitsPerStatus;
|
|
957
1045
|
const statusList = await import_vc_bitstring_status_lists.BitstreamStatusList.decode({
|
|
958
1046
|
encodedList,
|
|
959
|
-
statusSize
|
|
1047
|
+
statusSize: args.bitsPerStatus
|
|
960
1048
|
});
|
|
961
1049
|
const numIndex = typeof args.statusListIndex === "number" ? args.statusListIndex : parseInt(args.statusListIndex);
|
|
962
1050
|
if (statusList.getLength() <= numIndex) {
|
|
@@ -964,16 +1052,22 @@ var BitstringStatusListImplementation = class {
|
|
|
964
1052
|
}
|
|
965
1053
|
return statusList.getStatus(numIndex);
|
|
966
1054
|
}
|
|
1055
|
+
/**
|
|
1056
|
+
* Converts a status list credential payload to detailed status list information
|
|
1057
|
+
*
|
|
1058
|
+
* @param args - Conversion parameters including the status list payload
|
|
1059
|
+
* @returns Promise resolving to detailed status list information
|
|
1060
|
+
*/
|
|
967
1061
|
async toStatusListDetails(args) {
|
|
968
1062
|
const { statusListPayload, bitsPerStatus } = args;
|
|
969
1063
|
if (!bitsPerStatus || bitsPerStatus < 1) {
|
|
970
|
-
return Promise.reject("bitsPerStatus must be set for bitstring status lists and must be 1 or higher. (toStatusListDetails)");
|
|
1064
|
+
return Promise.reject(Error("bitsPerStatus must be set for bitstring status lists and must be 1 or higher. (toStatusListDetails)"));
|
|
971
1065
|
}
|
|
972
1066
|
const uniform = import_ssi_types5.CredentialMapper.toUniformCredential(statusListPayload);
|
|
973
1067
|
const { issuer, credentialSubject } = uniform;
|
|
974
1068
|
const id = getAssertedValue("id", uniform.id);
|
|
975
1069
|
const encodedList = getAssertedProperty("encodedList", credentialSubject);
|
|
976
|
-
const proofFormat = import_ssi_types5.CredentialMapper.detectDocumentType(statusListPayload) === import_ssi_types5.DocumentFormat.JWT ? "jwt" : "lds";
|
|
1070
|
+
const proofFormat = import_ssi_types5.CredentialMapper.detectDocumentType(statusListPayload) === import_ssi_types5.DocumentFormat.JWT ? "vc+jwt" : "lds";
|
|
977
1071
|
const credSubject = Array.isArray(credentialSubject) ? credentialSubject[0] : credentialSubject;
|
|
978
1072
|
const statusPurpose = getAssertedProperty("statusPurpose", credSubject);
|
|
979
1073
|
const validFrom = uniform.validFrom ? new Date(uniform.validFrom) : void 0;
|
|
@@ -981,6 +1075,7 @@ var BitstringStatusListImplementation = class {
|
|
|
981
1075
|
const ttl = credSubject.ttl;
|
|
982
1076
|
const statuslistLength = import_vc_bitstring_status_lists.BitstreamStatusList.getStatusListLength(encodedList, bitsPerStatus);
|
|
983
1077
|
return {
|
|
1078
|
+
// Base implementation fields
|
|
984
1079
|
id,
|
|
985
1080
|
encodedList,
|
|
986
1081
|
issuer,
|
|
@@ -989,13 +1084,35 @@ var BitstringStatusListImplementation = class {
|
|
|
989
1084
|
length: statuslistLength,
|
|
990
1085
|
statusListCredential: statusListPayload,
|
|
991
1086
|
statuslistContentType: this.buildContentType(proofFormat),
|
|
1087
|
+
correlationId: args.correlationId,
|
|
1088
|
+
driverType: args.driverType,
|
|
1089
|
+
// Flattened Bitstring-specific fields
|
|
1090
|
+
statusPurpose,
|
|
1091
|
+
bitsPerStatus,
|
|
1092
|
+
...validFrom && {
|
|
1093
|
+
validFrom
|
|
1094
|
+
},
|
|
1095
|
+
...validUntil && {
|
|
1096
|
+
validUntil
|
|
1097
|
+
},
|
|
1098
|
+
...ttl && {
|
|
1099
|
+
ttl
|
|
1100
|
+
},
|
|
1101
|
+
// Legacy nested structure for backward compatibility
|
|
992
1102
|
bitstringStatusList: {
|
|
993
1103
|
statusPurpose,
|
|
994
1104
|
bitsPerStatus,
|
|
995
|
-
validFrom
|
|
996
|
-
|
|
997
|
-
|
|
1105
|
+
...validFrom && {
|
|
1106
|
+
validFrom
|
|
1107
|
+
},
|
|
1108
|
+
...validUntil && {
|
|
1109
|
+
validUntil
|
|
1110
|
+
},
|
|
1111
|
+
...ttl && {
|
|
1112
|
+
ttl
|
|
1113
|
+
}
|
|
998
1114
|
},
|
|
1115
|
+
// Optional fields from args
|
|
999
1116
|
...args.correlationId && {
|
|
1000
1117
|
correlationId: args.correlationId
|
|
1001
1118
|
},
|
|
@@ -1004,27 +1121,66 @@ var BitstringStatusListImplementation = class {
|
|
|
1004
1121
|
}
|
|
1005
1122
|
};
|
|
1006
1123
|
}
|
|
1124
|
+
/**
|
|
1125
|
+
* Creates a credential status entry for a specific credential in a status list
|
|
1126
|
+
*
|
|
1127
|
+
* @param args - Parameters including the status list, entry details, and index
|
|
1128
|
+
* @returns Promise resolving to the credential status entry
|
|
1129
|
+
*/
|
|
1130
|
+
async createCredentialStatus(args) {
|
|
1131
|
+
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
|
+
const bitstringStatusList = statusList;
|
|
1139
|
+
return {
|
|
1140
|
+
id: `${statusList.id}#${statusListIndex}`,
|
|
1141
|
+
type: "BitstringStatusListEntry",
|
|
1142
|
+
statusPurpose: statusListEntry.statusPurpose,
|
|
1143
|
+
statusListIndex: "" + statusListIndex,
|
|
1144
|
+
statusListCredential: statusList.id,
|
|
1145
|
+
bitsPerStatus: bitstringStatusList.bitsPerStatus
|
|
1146
|
+
};
|
|
1147
|
+
}
|
|
1148
|
+
/**
|
|
1149
|
+
* Creates a signed verifiable credential from an unsigned status list credential
|
|
1150
|
+
*
|
|
1151
|
+
* @param args - Parameters including the unsigned credential and signing details
|
|
1152
|
+
* @param context - Veramo agent context for credential operations
|
|
1153
|
+
* @returns Promise resolving to the signed credential
|
|
1154
|
+
*/
|
|
1007
1155
|
async createVerifiableCredential(args, context) {
|
|
1156
|
+
const { unsignedCredential, issuer, proofFormat, keyRef } = args;
|
|
1008
1157
|
const identifier = await context.agent.identifierManagedGet({
|
|
1009
|
-
identifier: typeof
|
|
1158
|
+
identifier: typeof issuer === "string" ? issuer : issuer.id,
|
|
1010
1159
|
vmRelationship: "assertionMethod",
|
|
1011
1160
|
offlineWhenNoDIDRegistered: true
|
|
1012
1161
|
});
|
|
1013
|
-
const unsignedCredential = await (0, import_vc_bitstring_status_lists.createStatusListCredential)(args);
|
|
1014
1162
|
const verifiableCredential = await context.agent.createVerifiableCredential({
|
|
1015
1163
|
credential: unsignedCredential,
|
|
1016
|
-
keyRef:
|
|
1017
|
-
proofFormat
|
|
1164
|
+
keyRef: keyRef ?? identifier.kmsKeyRef,
|
|
1165
|
+
proofFormat,
|
|
1018
1166
|
fetchRemoteContexts: true
|
|
1019
1167
|
});
|
|
1020
1168
|
return import_ssi_types5.CredentialMapper.toWrappedVerifiableCredential(verifiableCredential).original;
|
|
1021
1169
|
}
|
|
1170
|
+
/**
|
|
1171
|
+
* Builds the appropriate content type string for a given proof format
|
|
1172
|
+
*
|
|
1173
|
+
* @param proofFormat - The proof format to build content type for
|
|
1174
|
+
* @returns The corresponding content type string
|
|
1175
|
+
*/
|
|
1022
1176
|
buildContentType(proofFormat) {
|
|
1023
1177
|
switch (proofFormat) {
|
|
1024
1178
|
case "jwt":
|
|
1025
|
-
return
|
|
1179
|
+
return "application/statuslist+jwt";
|
|
1026
1180
|
case "cbor":
|
|
1027
|
-
return
|
|
1181
|
+
return "application/statuslist+cwt";
|
|
1182
|
+
case "vc+jwt":
|
|
1183
|
+
return "application/statuslist+vc+jwt";
|
|
1028
1184
|
case "lds":
|
|
1029
1185
|
return "application/statuslist+ld+json";
|
|
1030
1186
|
default:
|
|
@@ -1180,36 +1336,29 @@ async function updateStatusIndexFromStatusListCredential(args, context) {
|
|
|
1180
1336
|
return implementation.updateStatusListIndex(args, context);
|
|
1181
1337
|
}
|
|
1182
1338
|
__name(updateStatusIndexFromStatusListCredential, "updateStatusIndexFromStatusListCredential");
|
|
1183
|
-
async function statusListCredentialToDetails({ correlationId, driverType, statusListCredential, bitsPerStatus }) {
|
|
1339
|
+
async function statusListCredentialToDetails({ statusListType, correlationId, driverType, statusListCredential, bitsPerStatus }) {
|
|
1184
1340
|
const credential = getAssertedValue("statusListCredential", statusListCredential);
|
|
1185
|
-
let statusListType;
|
|
1186
|
-
const documentFormat = import_ssi_types7.CredentialMapper.detectDocumentType(credential);
|
|
1187
|
-
if (documentFormat === import_ssi_types7.DocumentFormat.JWT) {
|
|
1188
|
-
const [header] = credential.split(".");
|
|
1189
|
-
const decodedHeader = JSON.parse(Buffer.from(header, "base64").toString());
|
|
1190
|
-
if (decodedHeader.typ === "statuslist+jwt") {
|
|
1191
|
-
statusListType = import_ssi_types7.StatusListType.OAuthStatusList;
|
|
1192
|
-
}
|
|
1193
|
-
} else if (documentFormat === import_ssi_types7.DocumentFormat.MSO_MDOC) {
|
|
1194
|
-
statusListType = import_ssi_types7.StatusListType.OAuthStatusList;
|
|
1195
|
-
}
|
|
1196
|
-
if (!statusListType) {
|
|
1197
|
-
const uniform = import_ssi_types7.CredentialMapper.toUniformCredential(credential);
|
|
1198
|
-
const type = uniform.type.find((t) => t.includes("StatusList2021") || t.includes("OAuth2StatusList") || t.includes("BitstringStatusList"));
|
|
1199
|
-
if (!type) {
|
|
1200
|
-
throw new Error("Invalid status list credential type");
|
|
1201
|
-
}
|
|
1202
|
-
statusListType = type.replace("Credential", "");
|
|
1203
|
-
}
|
|
1204
1341
|
const implementation = getStatusListImplementation(statusListType);
|
|
1205
|
-
|
|
1342
|
+
const result = await implementation.toStatusListDetails({
|
|
1206
1343
|
statusListPayload: credential,
|
|
1207
1344
|
correlationId,
|
|
1208
1345
|
driverType,
|
|
1209
1346
|
bitsPerStatus
|
|
1210
1347
|
});
|
|
1348
|
+
return result;
|
|
1211
1349
|
}
|
|
1212
1350
|
__name(statusListCredentialToDetails, "statusListCredentialToDetails");
|
|
1351
|
+
async function createCredentialStatusFromStatusList(args) {
|
|
1352
|
+
const { statusList, statusListEntry, statusListIndex } = args;
|
|
1353
|
+
const statusListType = determineStatusListType(statusList.statusListCredential);
|
|
1354
|
+
const implementation = getStatusListImplementation(statusListType);
|
|
1355
|
+
return implementation.createCredentialStatus({
|
|
1356
|
+
statusList,
|
|
1357
|
+
statusListEntry,
|
|
1358
|
+
statusListIndex
|
|
1359
|
+
});
|
|
1360
|
+
}
|
|
1361
|
+
__name(createCredentialStatusFromStatusList, "createCredentialStatusFromStatusList");
|
|
1213
1362
|
async function updateStatusListIndexFromEncodedList(args, context) {
|
|
1214
1363
|
const { type } = getAssertedValue("type", args);
|
|
1215
1364
|
const implementation = getStatusListImplementation(type);
|