@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.js
CHANGED
|
@@ -15,7 +15,7 @@ var Status2021 = /* @__PURE__ */ function(Status20212) {
|
|
|
15
15
|
}({});
|
|
16
16
|
|
|
17
17
|
// src/functions.ts
|
|
18
|
-
import { CredentialMapper as CredentialMapper4,
|
|
18
|
+
import { CredentialMapper as CredentialMapper4, StatusListType as StatusListType6 } from "@sphereon/ssi-types";
|
|
19
19
|
import { checkStatus } from "@sphereon/vc-status-list";
|
|
20
20
|
|
|
21
21
|
// src/utils.ts
|
|
@@ -76,7 +76,8 @@ var ValidProofTypeMap = /* @__PURE__ */ new Map([
|
|
|
76
76
|
[
|
|
77
77
|
StatusListType.BitstringStatusList,
|
|
78
78
|
[
|
|
79
|
-
"lds"
|
|
79
|
+
"lds",
|
|
80
|
+
"vc+jwt"
|
|
80
81
|
]
|
|
81
82
|
]
|
|
82
83
|
]);
|
|
@@ -211,13 +212,14 @@ var StatusList2021Implementation = class {
|
|
|
211
212
|
encodedList,
|
|
212
213
|
proofFormat
|
|
213
214
|
}, context);
|
|
215
|
+
if (!("statusPurpose" in credentialSubject)) {
|
|
216
|
+
return Promise.reject(Error("statusPurpose is required in credentialSubject for StatusList2021"));
|
|
217
|
+
}
|
|
214
218
|
return {
|
|
215
219
|
statusListCredential: updatedCredential,
|
|
216
220
|
encodedList,
|
|
217
221
|
statusList2021: {
|
|
218
|
-
|
|
219
|
-
statusPurpose: credentialSubject.statusPurpose
|
|
220
|
-
} : {},
|
|
222
|
+
statusPurpose: credentialSubject.statusPurpose,
|
|
221
223
|
indexingDirection: "rightToLeft"
|
|
222
224
|
},
|
|
223
225
|
length: statusList.length - 1,
|
|
@@ -282,10 +284,12 @@ var StatusList2021Implementation = class {
|
|
|
282
284
|
const encodedList = getAssertedProperty("encodedList", credentialSubject);
|
|
283
285
|
const proofFormat = CredentialMapper2.detectDocumentType(statusListPayload) === DocumentFormat2.JWT ? "jwt" : "lds";
|
|
284
286
|
const statusPurpose = getAssertedProperty("statusPurpose", credentialSubject);
|
|
287
|
+
const indexingDirection = "rightToLeft";
|
|
285
288
|
const list = await StatusList.decode({
|
|
286
289
|
encodedList
|
|
287
290
|
});
|
|
288
291
|
return {
|
|
292
|
+
// Base implementation fields
|
|
289
293
|
id,
|
|
290
294
|
encodedList,
|
|
291
295
|
issuer,
|
|
@@ -294,18 +298,36 @@ var StatusList2021Implementation = class {
|
|
|
294
298
|
length: list.length,
|
|
295
299
|
statusListCredential: statusListPayload,
|
|
296
300
|
statuslistContentType: this.buildContentType(proofFormat),
|
|
301
|
+
correlationId: args.correlationId,
|
|
302
|
+
driverType: args.driverType,
|
|
303
|
+
// Flattened StatusList2021-specific fields
|
|
304
|
+
indexingDirection,
|
|
305
|
+
statusPurpose,
|
|
306
|
+
// Legacy nested structure for backward compatibility
|
|
297
307
|
statusList2021: {
|
|
298
|
-
indexingDirection
|
|
299
|
-
statusPurpose
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
308
|
+
indexingDirection,
|
|
309
|
+
statusPurpose,
|
|
310
|
+
// Optional fields from args
|
|
311
|
+
...args.correlationId && {
|
|
312
|
+
correlationId: args.correlationId
|
|
313
|
+
},
|
|
314
|
+
...args.driverType && {
|
|
315
|
+
driverType: args.driverType
|
|
316
|
+
}
|
|
306
317
|
}
|
|
307
318
|
};
|
|
308
319
|
}
|
|
320
|
+
async createCredentialStatus(args) {
|
|
321
|
+
const { statusList, statusListIndex } = args;
|
|
322
|
+
const statusList2021 = statusList;
|
|
323
|
+
return {
|
|
324
|
+
id: `${statusList.id}#${statusListIndex}`,
|
|
325
|
+
type: "StatusList2021Entry",
|
|
326
|
+
statusPurpose: statusList2021.statusPurpose ?? "revocation",
|
|
327
|
+
statusListIndex: "" + statusListIndex,
|
|
328
|
+
statusListCredential: statusList.id
|
|
329
|
+
};
|
|
330
|
+
}
|
|
309
331
|
async createVerifiableCredential(args, context) {
|
|
310
332
|
const identifier = await context.agent.identifierManagedGet({
|
|
311
333
|
identifier: typeof args.issuer === "string" ? args.issuer : args.issuer.id,
|
|
@@ -682,9 +704,6 @@ var OAuthStatusListImplementation = class {
|
|
|
682
704
|
statuslistContentType: this.buildContentType(proofFormat)
|
|
683
705
|
};
|
|
684
706
|
}
|
|
685
|
-
buildContentType(proofFormat) {
|
|
686
|
-
return `application/statuslist+${proofFormat === "cbor" ? "cwt" : "jwt"}`;
|
|
687
|
-
}
|
|
688
707
|
async checkStatusIndex(args) {
|
|
689
708
|
const { statusListCredential, statusListIndex } = args;
|
|
690
709
|
if (typeof statusListCredential !== "string") {
|
|
@@ -703,7 +722,10 @@ var OAuthStatusListImplementation = class {
|
|
|
703
722
|
const proofFormat = determineProofFormat(statusListPayload);
|
|
704
723
|
const decoded = proofFormat === "jwt" ? decodeStatusListJWT(statusListPayload) : decodeStatusListCWT(statusListPayload);
|
|
705
724
|
const { statusList, issuer, id, exp } = decoded;
|
|
725
|
+
const bitsPerStatus = statusList.getBitsPerStatus();
|
|
726
|
+
const expiresAt = exp ? new Date(exp * 1e3) : void 0;
|
|
706
727
|
return {
|
|
728
|
+
// Base implementation fields
|
|
707
729
|
id,
|
|
708
730
|
encodedList: statusList.compressStatusList(),
|
|
709
731
|
issuer,
|
|
@@ -712,12 +734,21 @@ var OAuthStatusListImplementation = class {
|
|
|
712
734
|
length: statusList.statusList.length,
|
|
713
735
|
statusListCredential: statusListPayload,
|
|
714
736
|
statuslistContentType: this.buildContentType(proofFormat),
|
|
737
|
+
correlationId: args.correlationId,
|
|
738
|
+
driverType: args.driverType,
|
|
739
|
+
// Flattened OAuth-specific fields
|
|
740
|
+
bitsPerStatus,
|
|
741
|
+
...expiresAt && {
|
|
742
|
+
expiresAt
|
|
743
|
+
},
|
|
744
|
+
// Legacy nested structure for backward compatibility
|
|
715
745
|
oauthStatusList: {
|
|
716
|
-
bitsPerStatus
|
|
717
|
-
...
|
|
718
|
-
expiresAt
|
|
746
|
+
bitsPerStatus,
|
|
747
|
+
...expiresAt && {
|
|
748
|
+
expiresAt
|
|
719
749
|
}
|
|
720
750
|
},
|
|
751
|
+
// Optional fields from args
|
|
721
752
|
...args.correlationId && {
|
|
722
753
|
correlationId: args.correlationId
|
|
723
754
|
},
|
|
@@ -726,6 +757,21 @@ var OAuthStatusListImplementation = class {
|
|
|
726
757
|
}
|
|
727
758
|
};
|
|
728
759
|
}
|
|
760
|
+
async createCredentialStatus(args) {
|
|
761
|
+
const { statusList, statusListIndex } = args;
|
|
762
|
+
const oauthStatusList = statusList;
|
|
763
|
+
return {
|
|
764
|
+
id: `${statusList.id}#${statusListIndex}`,
|
|
765
|
+
type: "OAuthStatusListEntry",
|
|
766
|
+
bitsPerStatus: oauthStatusList.bitsPerStatus,
|
|
767
|
+
statusListIndex: "" + statusListIndex,
|
|
768
|
+
statusListCredential: statusList.id,
|
|
769
|
+
expiresAt: oauthStatusList.expiresAt
|
|
770
|
+
};
|
|
771
|
+
}
|
|
772
|
+
buildContentType(proofFormat) {
|
|
773
|
+
return `application/statuslist+${proofFormat === "cbor" ? "cwt" : "jwt"}`;
|
|
774
|
+
}
|
|
729
775
|
async createSignedStatusList(proofFormat, context, statusList, issuerString, id, expiresAt, keyRef) {
|
|
730
776
|
switch (proofFormat) {
|
|
731
777
|
case "jwt": {
|
|
@@ -753,6 +799,13 @@ var BitstringStatusListImplementation = class {
|
|
|
753
799
|
static {
|
|
754
800
|
__name(this, "BitstringStatusListImplementation");
|
|
755
801
|
}
|
|
802
|
+
/**
|
|
803
|
+
* Creates a new bitstring status list with the specified configuration
|
|
804
|
+
*
|
|
805
|
+
* @param args - Configuration for the new status list including issuer, purpose, and size
|
|
806
|
+
* @param context - Veramo agent context for credential operations
|
|
807
|
+
* @returns Promise resolving to the created status list details
|
|
808
|
+
*/
|
|
756
809
|
async createNewStatusList(args, context) {
|
|
757
810
|
if (!args.bitstringStatusList) {
|
|
758
811
|
throw new Error("BitstringStatusList options are required for type BitstringStatusList");
|
|
@@ -760,28 +813,34 @@ var BitstringStatusListImplementation = class {
|
|
|
760
813
|
const length = args?.length ?? DEFAULT_LIST_LENGTH3;
|
|
761
814
|
const proofFormat = args?.proofFormat ?? DEFAULT_PROOF_FORMAT3;
|
|
762
815
|
assertValidProofType(StatusListType4.BitstringStatusList, proofFormat);
|
|
763
|
-
const veramoProofFormat = proofFormat;
|
|
764
816
|
const { issuer, id } = args;
|
|
765
817
|
const correlationId = getAssertedValue("correlationId", args.correlationId);
|
|
766
818
|
const { statusPurpose, bitsPerStatus, validFrom, validUntil, ttl } = args.bitstringStatusList;
|
|
767
|
-
const
|
|
768
|
-
|
|
769
|
-
|
|
819
|
+
const unsignedCredential = await createStatusListCredential({
|
|
820
|
+
id,
|
|
821
|
+
issuer,
|
|
770
822
|
statusPurpose: statusPurpose ?? DEFAULT_STATUS_PURPOSE,
|
|
771
823
|
validFrom: ensureDate(validFrom),
|
|
772
824
|
validUntil: ensureDate(validUntil),
|
|
773
825
|
ttl
|
|
826
|
+
});
|
|
827
|
+
const statusListCredential = await this.createVerifiableCredential({
|
|
828
|
+
unsignedCredential,
|
|
829
|
+
id,
|
|
830
|
+
issuer,
|
|
831
|
+
proofFormat,
|
|
832
|
+
keyRef: args.keyRef
|
|
774
833
|
}, context);
|
|
775
834
|
return {
|
|
776
|
-
encodedList:
|
|
835
|
+
encodedList: unsignedCredential.credentialSubject.encodedList,
|
|
777
836
|
statusListCredential,
|
|
778
837
|
bitstringStatusList: {
|
|
779
838
|
statusPurpose: statusPurpose ?? DEFAULT_STATUS_PURPOSE,
|
|
780
|
-
...
|
|
781
|
-
validFrom: new Date(
|
|
839
|
+
...unsignedCredential.validFrom && {
|
|
840
|
+
validFrom: new Date(unsignedCredential.validFrom)
|
|
782
841
|
},
|
|
783
|
-
...
|
|
784
|
-
validUntil: new Date(
|
|
842
|
+
...unsignedCredential.validUntil && {
|
|
843
|
+
validUntil: new Date(unsignedCredential.validUntil)
|
|
785
844
|
},
|
|
786
845
|
ttl,
|
|
787
846
|
bitsPerStatus
|
|
@@ -795,9 +854,16 @@ var BitstringStatusListImplementation = class {
|
|
|
795
854
|
statuslistContentType: this.buildContentType(proofFormat)
|
|
796
855
|
};
|
|
797
856
|
}
|
|
857
|
+
/**
|
|
858
|
+
* Updates the status of a specific credential in an existing status list
|
|
859
|
+
*
|
|
860
|
+
* @param args - Update parameters including the status list credential, index, and new value
|
|
861
|
+
* @param context - Veramo agent context for credential operations
|
|
862
|
+
* @returns Promise resolving to the updated status list details
|
|
863
|
+
*/
|
|
798
864
|
async updateStatusListIndex(args, context) {
|
|
799
865
|
if (!args.bitsPerStatus || args.bitsPerStatus < 1) {
|
|
800
|
-
return Promise.reject("bitsPerStatus must be set for bitstring status lists and must be 1 or higher. (updateStatusListIndex)");
|
|
866
|
+
return Promise.reject(Error("bitsPerStatus must be set for bitstring status lists and must be 1 or higher. (updateStatusListIndex)"));
|
|
801
867
|
}
|
|
802
868
|
const credential = args.statusListCredential;
|
|
803
869
|
const uniform = CredentialMapper3.toUniformCredential(credential);
|
|
@@ -816,27 +882,32 @@ var BitstringStatusListImplementation = class {
|
|
|
816
882
|
const validFrom = uniform.validFrom ? new Date(uniform.validFrom) : void 0;
|
|
817
883
|
const validUntil = uniform.validUntil ? new Date(uniform.validUntil) : void 0;
|
|
818
884
|
const ttl = credSubject.ttl;
|
|
819
|
-
const
|
|
820
|
-
...args,
|
|
885
|
+
const unsignedCredential = await createStatusListCredential({
|
|
821
886
|
id,
|
|
822
887
|
issuer,
|
|
823
888
|
statusList,
|
|
889
|
+
statusPurpose: statusPurpose ?? DEFAULT_STATUS_PURPOSE,
|
|
890
|
+
validFrom: ensureDate(validFrom),
|
|
891
|
+
validUntil: ensureDate(validUntil),
|
|
892
|
+
ttl
|
|
893
|
+
});
|
|
894
|
+
const updatedCredential = await this.createVerifiableCredential({
|
|
895
|
+
unsignedCredential,
|
|
896
|
+
id,
|
|
897
|
+
issuer,
|
|
824
898
|
proofFormat,
|
|
825
|
-
|
|
826
|
-
ttl,
|
|
827
|
-
validFrom,
|
|
828
|
-
validUntil
|
|
899
|
+
keyRef: args.keyRef
|
|
829
900
|
}, context);
|
|
830
901
|
return {
|
|
831
902
|
statusListCredential: updatedCredential,
|
|
832
|
-
encodedList:
|
|
903
|
+
encodedList: unsignedCredential.credentialSubject.encodedList,
|
|
833
904
|
bitstringStatusList: {
|
|
834
905
|
statusPurpose,
|
|
835
|
-
...
|
|
836
|
-
validFrom: new Date(
|
|
906
|
+
...unsignedCredential.validFrom && {
|
|
907
|
+
validFrom: new Date(unsignedCredential.validFrom)
|
|
837
908
|
},
|
|
838
|
-
...
|
|
839
|
-
validUntil: new Date(
|
|
909
|
+
...unsignedCredential.validUntil && {
|
|
910
|
+
validUntil: new Date(unsignedCredential.validUntil)
|
|
840
911
|
},
|
|
841
912
|
bitsPerStatus: args.bitsPerStatus,
|
|
842
913
|
ttl
|
|
@@ -849,17 +920,23 @@ var BitstringStatusListImplementation = class {
|
|
|
849
920
|
statuslistContentType: this.buildContentType(proofFormat)
|
|
850
921
|
};
|
|
851
922
|
}
|
|
923
|
+
/**
|
|
924
|
+
* Updates a status list by decoding an encoded list, modifying it, and re-encoding
|
|
925
|
+
*
|
|
926
|
+
* @param args - Update parameters including encoded list, index, and new value
|
|
927
|
+
* @param context - Veramo agent context for credential operations
|
|
928
|
+
* @returns Promise resolving to the updated status list details
|
|
929
|
+
*/
|
|
852
930
|
async updateStatusListFromEncodedList(args, context) {
|
|
853
931
|
if (!args.bitstringStatusList) {
|
|
854
932
|
throw new Error("bitstringStatusList options required for type BitstringStatusList");
|
|
855
933
|
}
|
|
856
934
|
if (args.bitstringStatusList.bitsPerStatus < 1) {
|
|
857
|
-
return Promise.reject("bitsPerStatus must be set for bitstring status lists and must be 1 or higher. (updateStatusListFromEncodedList)");
|
|
935
|
+
return Promise.reject(Error("bitsPerStatus must be set for bitstring status lists and must be 1 or higher. (updateStatusListFromEncodedList)"));
|
|
858
936
|
}
|
|
859
937
|
const { statusPurpose, bitsPerStatus, ttl, validFrom, validUntil } = args.bitstringStatusList;
|
|
860
938
|
const proofFormat = args?.proofFormat ?? DEFAULT_PROOF_FORMAT3;
|
|
861
939
|
assertValidProofType(StatusListType4.BitstringStatusList, proofFormat);
|
|
862
|
-
const veramoProofFormat = proofFormat;
|
|
863
940
|
const { issuer, id } = getAssertedValues(args);
|
|
864
941
|
const statusList = await BitstreamStatusList.decode({
|
|
865
942
|
encodedList: args.encodedList,
|
|
@@ -867,29 +944,34 @@ var BitstringStatusListImplementation = class {
|
|
|
867
944
|
});
|
|
868
945
|
const index = typeof args.statusListIndex === "number" ? args.statusListIndex : parseInt(args.statusListIndex);
|
|
869
946
|
statusList.setStatus(index, args.value);
|
|
870
|
-
const
|
|
947
|
+
const unsignedCredential = await createStatusListCredential({
|
|
871
948
|
id,
|
|
872
949
|
issuer,
|
|
873
950
|
statusList,
|
|
874
|
-
|
|
875
|
-
keyRef: args.keyRef,
|
|
876
|
-
statusPurpose,
|
|
951
|
+
statusPurpose: statusPurpose ?? DEFAULT_STATUS_PURPOSE,
|
|
877
952
|
validFrom: ensureDate(validFrom),
|
|
878
953
|
validUntil: ensureDate(validUntil),
|
|
879
954
|
ttl
|
|
955
|
+
});
|
|
956
|
+
const credential = await this.createVerifiableCredential({
|
|
957
|
+
unsignedCredential,
|
|
958
|
+
id,
|
|
959
|
+
issuer,
|
|
960
|
+
proofFormat,
|
|
961
|
+
keyRef: args.keyRef
|
|
880
962
|
}, context);
|
|
881
963
|
return {
|
|
882
964
|
type: StatusListType4.BitstringStatusList,
|
|
883
965
|
statusListCredential: credential,
|
|
884
|
-
encodedList:
|
|
966
|
+
encodedList: unsignedCredential.credentialSubject.encodedList,
|
|
885
967
|
bitstringStatusList: {
|
|
886
968
|
statusPurpose,
|
|
887
969
|
bitsPerStatus,
|
|
888
|
-
...
|
|
889
|
-
validFrom: new Date(
|
|
970
|
+
...unsignedCredential.validFrom && {
|
|
971
|
+
validFrom: new Date(unsignedCredential.validFrom)
|
|
890
972
|
},
|
|
891
|
-
...
|
|
892
|
-
validUntil: new Date(
|
|
973
|
+
...unsignedCredential.validUntil && {
|
|
974
|
+
validUntil: new Date(unsignedCredential.validUntil)
|
|
893
975
|
},
|
|
894
976
|
ttl
|
|
895
977
|
},
|
|
@@ -900,17 +982,22 @@ var BitstringStatusListImplementation = class {
|
|
|
900
982
|
statuslistContentType: this.buildContentType(proofFormat)
|
|
901
983
|
};
|
|
902
984
|
}
|
|
985
|
+
/**
|
|
986
|
+
* Checks the status of a specific credential by its index in the status list
|
|
987
|
+
*
|
|
988
|
+
* @param args - Check parameters including the status list credential and index
|
|
989
|
+
* @returns Promise resolving to the status value at the specified index
|
|
990
|
+
*/
|
|
903
991
|
async checkStatusIndex(args) {
|
|
904
992
|
if (!args.bitsPerStatus || args.bitsPerStatus < 1) {
|
|
905
|
-
return Promise.reject("bitsPerStatus must be set for bitstring status lists and must be 1 or higher. (checkStatusIndex)");
|
|
993
|
+
return Promise.reject(Error("bitsPerStatus must be set for bitstring status lists and must be 1 or higher. (checkStatusIndex)"));
|
|
906
994
|
}
|
|
907
995
|
const uniform = CredentialMapper3.toUniformCredential(args.statusListCredential);
|
|
908
996
|
const { credentialSubject } = uniform;
|
|
909
997
|
const encodedList = getAssertedProperty("encodedList", credentialSubject);
|
|
910
|
-
const statusSize = args.bitsPerStatus;
|
|
911
998
|
const statusList = await BitstreamStatusList.decode({
|
|
912
999
|
encodedList,
|
|
913
|
-
statusSize
|
|
1000
|
+
statusSize: args.bitsPerStatus
|
|
914
1001
|
});
|
|
915
1002
|
const numIndex = typeof args.statusListIndex === "number" ? args.statusListIndex : parseInt(args.statusListIndex);
|
|
916
1003
|
if (statusList.getLength() <= numIndex) {
|
|
@@ -918,16 +1005,22 @@ var BitstringStatusListImplementation = class {
|
|
|
918
1005
|
}
|
|
919
1006
|
return statusList.getStatus(numIndex);
|
|
920
1007
|
}
|
|
1008
|
+
/**
|
|
1009
|
+
* Converts a status list credential payload to detailed status list information
|
|
1010
|
+
*
|
|
1011
|
+
* @param args - Conversion parameters including the status list payload
|
|
1012
|
+
* @returns Promise resolving to detailed status list information
|
|
1013
|
+
*/
|
|
921
1014
|
async toStatusListDetails(args) {
|
|
922
1015
|
const { statusListPayload, bitsPerStatus } = args;
|
|
923
1016
|
if (!bitsPerStatus || bitsPerStatus < 1) {
|
|
924
|
-
return Promise.reject("bitsPerStatus must be set for bitstring status lists and must be 1 or higher. (toStatusListDetails)");
|
|
1017
|
+
return Promise.reject(Error("bitsPerStatus must be set for bitstring status lists and must be 1 or higher. (toStatusListDetails)"));
|
|
925
1018
|
}
|
|
926
1019
|
const uniform = CredentialMapper3.toUniformCredential(statusListPayload);
|
|
927
1020
|
const { issuer, credentialSubject } = uniform;
|
|
928
1021
|
const id = getAssertedValue("id", uniform.id);
|
|
929
1022
|
const encodedList = getAssertedProperty("encodedList", credentialSubject);
|
|
930
|
-
const proofFormat = CredentialMapper3.detectDocumentType(statusListPayload) === DocumentFormat3.JWT ? "jwt" : "lds";
|
|
1023
|
+
const proofFormat = CredentialMapper3.detectDocumentType(statusListPayload) === DocumentFormat3.JWT ? "vc+jwt" : "lds";
|
|
931
1024
|
const credSubject = Array.isArray(credentialSubject) ? credentialSubject[0] : credentialSubject;
|
|
932
1025
|
const statusPurpose = getAssertedProperty("statusPurpose", credSubject);
|
|
933
1026
|
const validFrom = uniform.validFrom ? new Date(uniform.validFrom) : void 0;
|
|
@@ -935,6 +1028,7 @@ var BitstringStatusListImplementation = class {
|
|
|
935
1028
|
const ttl = credSubject.ttl;
|
|
936
1029
|
const statuslistLength = BitstreamStatusList.getStatusListLength(encodedList, bitsPerStatus);
|
|
937
1030
|
return {
|
|
1031
|
+
// Base implementation fields
|
|
938
1032
|
id,
|
|
939
1033
|
encodedList,
|
|
940
1034
|
issuer,
|
|
@@ -943,13 +1037,35 @@ var BitstringStatusListImplementation = class {
|
|
|
943
1037
|
length: statuslistLength,
|
|
944
1038
|
statusListCredential: statusListPayload,
|
|
945
1039
|
statuslistContentType: this.buildContentType(proofFormat),
|
|
1040
|
+
correlationId: args.correlationId,
|
|
1041
|
+
driverType: args.driverType,
|
|
1042
|
+
// Flattened Bitstring-specific fields
|
|
1043
|
+
statusPurpose,
|
|
1044
|
+
bitsPerStatus,
|
|
1045
|
+
...validFrom && {
|
|
1046
|
+
validFrom
|
|
1047
|
+
},
|
|
1048
|
+
...validUntil && {
|
|
1049
|
+
validUntil
|
|
1050
|
+
},
|
|
1051
|
+
...ttl && {
|
|
1052
|
+
ttl
|
|
1053
|
+
},
|
|
1054
|
+
// Legacy nested structure for backward compatibility
|
|
946
1055
|
bitstringStatusList: {
|
|
947
1056
|
statusPurpose,
|
|
948
1057
|
bitsPerStatus,
|
|
949
|
-
validFrom
|
|
950
|
-
|
|
951
|
-
|
|
1058
|
+
...validFrom && {
|
|
1059
|
+
validFrom
|
|
1060
|
+
},
|
|
1061
|
+
...validUntil && {
|
|
1062
|
+
validUntil
|
|
1063
|
+
},
|
|
1064
|
+
...ttl && {
|
|
1065
|
+
ttl
|
|
1066
|
+
}
|
|
952
1067
|
},
|
|
1068
|
+
// Optional fields from args
|
|
953
1069
|
...args.correlationId && {
|
|
954
1070
|
correlationId: args.correlationId
|
|
955
1071
|
},
|
|
@@ -958,27 +1074,66 @@ var BitstringStatusListImplementation = class {
|
|
|
958
1074
|
}
|
|
959
1075
|
};
|
|
960
1076
|
}
|
|
1077
|
+
/**
|
|
1078
|
+
* Creates a credential status entry for a specific credential in a status list
|
|
1079
|
+
*
|
|
1080
|
+
* @param args - Parameters including the status list, entry details, and index
|
|
1081
|
+
* @returns Promise resolving to the credential status entry
|
|
1082
|
+
*/
|
|
1083
|
+
async createCredentialStatus(args) {
|
|
1084
|
+
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
|
+
const bitstringStatusList = statusList;
|
|
1092
|
+
return {
|
|
1093
|
+
id: `${statusList.id}#${statusListIndex}`,
|
|
1094
|
+
type: "BitstringStatusListEntry",
|
|
1095
|
+
statusPurpose: statusListEntry.statusPurpose,
|
|
1096
|
+
statusListIndex: "" + statusListIndex,
|
|
1097
|
+
statusListCredential: statusList.id,
|
|
1098
|
+
bitsPerStatus: bitstringStatusList.bitsPerStatus
|
|
1099
|
+
};
|
|
1100
|
+
}
|
|
1101
|
+
/**
|
|
1102
|
+
* Creates a signed verifiable credential from an unsigned status list credential
|
|
1103
|
+
*
|
|
1104
|
+
* @param args - Parameters including the unsigned credential and signing details
|
|
1105
|
+
* @param context - Veramo agent context for credential operations
|
|
1106
|
+
* @returns Promise resolving to the signed credential
|
|
1107
|
+
*/
|
|
961
1108
|
async createVerifiableCredential(args, context) {
|
|
1109
|
+
const { unsignedCredential, issuer, proofFormat, keyRef } = args;
|
|
962
1110
|
const identifier = await context.agent.identifierManagedGet({
|
|
963
|
-
identifier: typeof
|
|
1111
|
+
identifier: typeof issuer === "string" ? issuer : issuer.id,
|
|
964
1112
|
vmRelationship: "assertionMethod",
|
|
965
1113
|
offlineWhenNoDIDRegistered: true
|
|
966
1114
|
});
|
|
967
|
-
const unsignedCredential = await createStatusListCredential(args);
|
|
968
1115
|
const verifiableCredential = await context.agent.createVerifiableCredential({
|
|
969
1116
|
credential: unsignedCredential,
|
|
970
|
-
keyRef:
|
|
971
|
-
proofFormat
|
|
1117
|
+
keyRef: keyRef ?? identifier.kmsKeyRef,
|
|
1118
|
+
proofFormat,
|
|
972
1119
|
fetchRemoteContexts: true
|
|
973
1120
|
});
|
|
974
1121
|
return CredentialMapper3.toWrappedVerifiableCredential(verifiableCredential).original;
|
|
975
1122
|
}
|
|
1123
|
+
/**
|
|
1124
|
+
* Builds the appropriate content type string for a given proof format
|
|
1125
|
+
*
|
|
1126
|
+
* @param proofFormat - The proof format to build content type for
|
|
1127
|
+
* @returns The corresponding content type string
|
|
1128
|
+
*/
|
|
976
1129
|
buildContentType(proofFormat) {
|
|
977
1130
|
switch (proofFormat) {
|
|
978
1131
|
case "jwt":
|
|
979
|
-
return
|
|
1132
|
+
return "application/statuslist+jwt";
|
|
980
1133
|
case "cbor":
|
|
981
|
-
return
|
|
1134
|
+
return "application/statuslist+cwt";
|
|
1135
|
+
case "vc+jwt":
|
|
1136
|
+
return "application/statuslist+vc+jwt";
|
|
982
1137
|
case "lds":
|
|
983
1138
|
return "application/statuslist+ld+json";
|
|
984
1139
|
default:
|
|
@@ -1134,36 +1289,29 @@ async function updateStatusIndexFromStatusListCredential(args, context) {
|
|
|
1134
1289
|
return implementation.updateStatusListIndex(args, context);
|
|
1135
1290
|
}
|
|
1136
1291
|
__name(updateStatusIndexFromStatusListCredential, "updateStatusIndexFromStatusListCredential");
|
|
1137
|
-
async function statusListCredentialToDetails({ correlationId, driverType, statusListCredential, bitsPerStatus }) {
|
|
1292
|
+
async function statusListCredentialToDetails({ statusListType, correlationId, driverType, statusListCredential, bitsPerStatus }) {
|
|
1138
1293
|
const credential = getAssertedValue("statusListCredential", statusListCredential);
|
|
1139
|
-
let statusListType;
|
|
1140
|
-
const documentFormat = CredentialMapper4.detectDocumentType(credential);
|
|
1141
|
-
if (documentFormat === DocumentFormat4.JWT) {
|
|
1142
|
-
const [header] = credential.split(".");
|
|
1143
|
-
const decodedHeader = JSON.parse(Buffer.from(header, "base64").toString());
|
|
1144
|
-
if (decodedHeader.typ === "statuslist+jwt") {
|
|
1145
|
-
statusListType = StatusListType6.OAuthStatusList;
|
|
1146
|
-
}
|
|
1147
|
-
} else if (documentFormat === DocumentFormat4.MSO_MDOC) {
|
|
1148
|
-
statusListType = StatusListType6.OAuthStatusList;
|
|
1149
|
-
}
|
|
1150
|
-
if (!statusListType) {
|
|
1151
|
-
const uniform = CredentialMapper4.toUniformCredential(credential);
|
|
1152
|
-
const type = uniform.type.find((t) => t.includes("StatusList2021") || t.includes("OAuth2StatusList") || t.includes("BitstringStatusList"));
|
|
1153
|
-
if (!type) {
|
|
1154
|
-
throw new Error("Invalid status list credential type");
|
|
1155
|
-
}
|
|
1156
|
-
statusListType = type.replace("Credential", "");
|
|
1157
|
-
}
|
|
1158
1294
|
const implementation = getStatusListImplementation(statusListType);
|
|
1159
|
-
|
|
1295
|
+
const result = await implementation.toStatusListDetails({
|
|
1160
1296
|
statusListPayload: credential,
|
|
1161
1297
|
correlationId,
|
|
1162
1298
|
driverType,
|
|
1163
1299
|
bitsPerStatus
|
|
1164
1300
|
});
|
|
1301
|
+
return result;
|
|
1165
1302
|
}
|
|
1166
1303
|
__name(statusListCredentialToDetails, "statusListCredentialToDetails");
|
|
1304
|
+
async function createCredentialStatusFromStatusList(args) {
|
|
1305
|
+
const { statusList, statusListEntry, statusListIndex } = args;
|
|
1306
|
+
const statusListType = determineStatusListType(statusList.statusListCredential);
|
|
1307
|
+
const implementation = getStatusListImplementation(statusListType);
|
|
1308
|
+
return implementation.createCredentialStatus({
|
|
1309
|
+
statusList,
|
|
1310
|
+
statusListEntry,
|
|
1311
|
+
statusListIndex
|
|
1312
|
+
});
|
|
1313
|
+
}
|
|
1314
|
+
__name(createCredentialStatusFromStatusList, "createCredentialStatusFromStatusList");
|
|
1167
1315
|
async function updateStatusListIndexFromEncodedList(args, context) {
|
|
1168
1316
|
const { type } = getAssertedValue("type", args);
|
|
1169
1317
|
const implementation = getStatusListImplementation(type);
|
|
@@ -1215,6 +1363,7 @@ export {
|
|
|
1215
1363
|
StatusOAuth,
|
|
1216
1364
|
checkStatusForCredential,
|
|
1217
1365
|
checkStatusIndexFromStatusListCredential,
|
|
1366
|
+
createCredentialStatusFromStatusList,
|
|
1218
1367
|
createNewStatusList,
|
|
1219
1368
|
fetchStatusListCredential,
|
|
1220
1369
|
simpleCheckStatusFromStatusListUrl,
|