@sphereon/ssi-sdk.vc-status-list 0.34.1-feature.SSISDK.17.bitstring.sl.11 → 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 +114 -64
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +10 -8
- package/dist/index.d.ts +10 -8
- package/dist/index.js +115 -65
- package/dist/index.js.map +1 -1
- package/package.json +5 -4
- package/src/functions.ts +8 -29
- package/src/impl/BitstringStatusListImplementation.ts +159 -62
- package/src/impl/IStatusList.ts +8 -4
- package/src/impl/OAuthStatusList.ts +4 -3
- package/src/impl/StatusList2021.ts +6 -5
- package/src/types/index.ts +4 -11
- package/src/utils.ts +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { IIdentifierResolution } from '@sphereon/ssi-sdk-ext.identifier-resolution';
|
|
2
2
|
import { StatusListIndexingDirection, StatusPurpose2021, StatusListType, IIssuer, CredentialProofFormat, StatusListDriverType, StatusListCredential, ICredentialStatus, OrPromise, ICredential, IVerifiableCredential } from '@sphereon/ssi-types';
|
|
3
|
-
import { IPluginMethodMap, IAgentContext, ICredentialIssuer, ICredentialVerifier, IKeyManager,
|
|
3
|
+
import { IPluginMethodMap, IAgentContext, ICredentialIssuer, ICredentialVerifier, IKeyManager, CredentialPayload } from '@veramo/core';
|
|
4
4
|
import { DataSource } from 'typeorm';
|
|
5
5
|
import { BitsPerStatus } from '@sd-jwt/jwt-status-list';
|
|
6
6
|
import { SdJwtVcPayload } from '@sd-jwt/sd-jwt-vc';
|
|
7
7
|
import { StatusListOpts } from '@sphereon/oid4vci-common';
|
|
8
8
|
import { BitstringStatusPurpose } from '@4sure-tech/vc-bitstring-status-lists';
|
|
9
|
+
import { IVcdmCredentialPlugin } from '@sphereon/ssi-sdk.credential-vcdm';
|
|
9
10
|
import { IAddStatusListArgs, StatusListEntity, IStatusListEntryEntity, IBitstringStatusListEntryEntity } from '@sphereon/ssi-sdk.data-store';
|
|
10
11
|
import { StatusMethod } from 'credential-status';
|
|
11
12
|
|
|
@@ -248,8 +249,8 @@ type SignedStatusListData = {
|
|
|
248
249
|
statusListCredential: StatusListCredential;
|
|
249
250
|
encodedList: string;
|
|
250
251
|
};
|
|
251
|
-
type IRequiredPlugins =
|
|
252
|
-
type IRequiredContext = IAgentContext<ICredentialIssuer & ICredentialVerifier & IIdentifierResolution & IKeyManager &
|
|
252
|
+
type IRequiredPlugins = IVcdmCredentialPlugin & IIdentifierResolution;
|
|
253
|
+
type IRequiredContext = IAgentContext<ICredentialIssuer & ICredentialVerifier & IIdentifierResolution & IKeyManager & IVcdmCredentialPlugin>;
|
|
253
254
|
|
|
254
255
|
declare function fetchStatusListCredential(args: {
|
|
255
256
|
statusListCredential: string;
|
|
@@ -306,9 +307,10 @@ declare function checkStatusIndexFromStatusListCredential(args: {
|
|
|
306
307
|
statusListIndex: string | number;
|
|
307
308
|
bitsPerStatus?: number;
|
|
308
309
|
}): Promise<number | Status2021 | StatusOAuth | BitstringStatus>;
|
|
309
|
-
declare function createNewStatusList(args: CreateNewStatusListFuncArgs, context: IAgentContext<(
|
|
310
|
-
declare function updateStatusIndexFromStatusListCredential(args: UpdateStatusListIndexArgs, context: IAgentContext<
|
|
311
|
-
declare function statusListCredentialToDetails({ correlationId, driverType, statusListCredential, bitsPerStatus, }: {
|
|
310
|
+
declare function createNewStatusList(args: CreateNewStatusListFuncArgs, context: IAgentContext<(IVcdmCredentialPlugin | any) & IIdentifierResolution>): Promise<StatusListResult>;
|
|
311
|
+
declare function updateStatusIndexFromStatusListCredential(args: UpdateStatusListIndexArgs, context: IAgentContext<IVcdmCredentialPlugin & IIdentifierResolution>): Promise<StatusListResult>;
|
|
312
|
+
declare function statusListCredentialToDetails({ statusListType, correlationId, driverType, statusListCredential, bitsPerStatus, }: {
|
|
313
|
+
statusListType: StatusListType;
|
|
312
314
|
statusListCredential: StatusListCredential;
|
|
313
315
|
correlationId?: string;
|
|
314
316
|
driverType?: StatusListDriverType;
|
|
@@ -319,7 +321,7 @@ declare function createCredentialStatusFromStatusList(args: {
|
|
|
319
321
|
statusListEntry: IStatusListEntryEntity | IBitstringStatusListEntryEntity;
|
|
320
322
|
statusListIndex: number;
|
|
321
323
|
}): Promise<StatusList2021EntryCredentialStatus | StatusListOAuthEntryCredentialStatus | BitstringStatusListEntryCredentialStatus>;
|
|
322
|
-
declare function updateStatusListIndexFromEncodedList(args: UpdateStatusListFromEncodedListArgs, context: IAgentContext<
|
|
323
|
-
declare function statusList2021ToVerifiableCredential(args: StatusList2021ToVerifiableCredentialArgs, context: IAgentContext<
|
|
324
|
+
declare function updateStatusListIndexFromEncodedList(args: UpdateStatusListFromEncodedListArgs, context: IAgentContext<IVcdmCredentialPlugin & IIdentifierResolution>): Promise<StatusListResult>;
|
|
325
|
+
declare function statusList2021ToVerifiableCredential(args: StatusList2021ToVerifiableCredentialArgs, context: IAgentContext<IVcdmCredentialPlugin & IIdentifierResolution>): Promise<StatusListCredential>;
|
|
324
326
|
|
|
325
327
|
export { type BaseCreateNewStatusListArgs, type BitstringStatus, type BitstringStatusListArgs, type BitstringStatusListEntryCredentialStatus, type CheckStatusIndexArgs, type CreateNewStatusListArgs, type CreateNewStatusListFuncArgs, type CreateStatusListArgs, type CredentialWithStatusSupport, type GetStatusListArgs, type IAddStatusToCredentialArgs, type IAddStatusToSdJwtCredentialArgs, type IIssueCredentialStatusOpts, type IRequiredContext, type IRequiredPlugins, type IStatusListPlugin, type OAuthStatusListArgs, type SignedStatusListData, Status2021, type StatusList2021Args, type StatusList2021EntryCredentialStatus, type StatusList2021ToVerifiableCredentialArgs, type StatusListOAuthEntryCredentialStatus, type StatusListResult, StatusOAuth, type ToStatusListDetailsArgs, type UpdateBitstringStatusListArgs, type UpdateOAuthStatusListArgs, type UpdateStatusList2021Args, type UpdateStatusListFromEncodedListArgs, type UpdateStatusListFromStatusListCredentialArgs, type UpdateStatusListIndexArgs, checkStatusForCredential, checkStatusIndexFromStatusListCredential, createCredentialStatusFromStatusList, createNewStatusList, fetchStatusListCredential, simpleCheckStatusFromStatusListUrl, statusList2021ToVerifiableCredential, statusListCredentialToDetails, statusPluginStatusFunction, updateStatusIndexFromStatusListCredential, updateStatusListIndexFromEncodedList, vcLibCheckStatusFunction };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { IIdentifierResolution } from '@sphereon/ssi-sdk-ext.identifier-resolution';
|
|
2
2
|
import { StatusListIndexingDirection, StatusPurpose2021, StatusListType, IIssuer, CredentialProofFormat, StatusListDriverType, StatusListCredential, ICredentialStatus, OrPromise, ICredential, IVerifiableCredential } from '@sphereon/ssi-types';
|
|
3
|
-
import { IPluginMethodMap, IAgentContext, ICredentialIssuer, ICredentialVerifier, IKeyManager,
|
|
3
|
+
import { IPluginMethodMap, IAgentContext, ICredentialIssuer, ICredentialVerifier, IKeyManager, CredentialPayload } from '@veramo/core';
|
|
4
4
|
import { DataSource } from 'typeorm';
|
|
5
5
|
import { BitsPerStatus } from '@sd-jwt/jwt-status-list';
|
|
6
6
|
import { SdJwtVcPayload } from '@sd-jwt/sd-jwt-vc';
|
|
7
7
|
import { StatusListOpts } from '@sphereon/oid4vci-common';
|
|
8
8
|
import { BitstringStatusPurpose } from '@4sure-tech/vc-bitstring-status-lists';
|
|
9
|
+
import { IVcdmCredentialPlugin } from '@sphereon/ssi-sdk.credential-vcdm';
|
|
9
10
|
import { IAddStatusListArgs, StatusListEntity, IStatusListEntryEntity, IBitstringStatusListEntryEntity } from '@sphereon/ssi-sdk.data-store';
|
|
10
11
|
import { StatusMethod } from 'credential-status';
|
|
11
12
|
|
|
@@ -248,8 +249,8 @@ type SignedStatusListData = {
|
|
|
248
249
|
statusListCredential: StatusListCredential;
|
|
249
250
|
encodedList: string;
|
|
250
251
|
};
|
|
251
|
-
type IRequiredPlugins =
|
|
252
|
-
type IRequiredContext = IAgentContext<ICredentialIssuer & ICredentialVerifier & IIdentifierResolution & IKeyManager &
|
|
252
|
+
type IRequiredPlugins = IVcdmCredentialPlugin & IIdentifierResolution;
|
|
253
|
+
type IRequiredContext = IAgentContext<ICredentialIssuer & ICredentialVerifier & IIdentifierResolution & IKeyManager & IVcdmCredentialPlugin>;
|
|
253
254
|
|
|
254
255
|
declare function fetchStatusListCredential(args: {
|
|
255
256
|
statusListCredential: string;
|
|
@@ -306,9 +307,10 @@ declare function checkStatusIndexFromStatusListCredential(args: {
|
|
|
306
307
|
statusListIndex: string | number;
|
|
307
308
|
bitsPerStatus?: number;
|
|
308
309
|
}): Promise<number | Status2021 | StatusOAuth | BitstringStatus>;
|
|
309
|
-
declare function createNewStatusList(args: CreateNewStatusListFuncArgs, context: IAgentContext<(
|
|
310
|
-
declare function updateStatusIndexFromStatusListCredential(args: UpdateStatusListIndexArgs, context: IAgentContext<
|
|
311
|
-
declare function statusListCredentialToDetails({ correlationId, driverType, statusListCredential, bitsPerStatus, }: {
|
|
310
|
+
declare function createNewStatusList(args: CreateNewStatusListFuncArgs, context: IAgentContext<(IVcdmCredentialPlugin | any) & IIdentifierResolution>): Promise<StatusListResult>;
|
|
311
|
+
declare function updateStatusIndexFromStatusListCredential(args: UpdateStatusListIndexArgs, context: IAgentContext<IVcdmCredentialPlugin & IIdentifierResolution>): Promise<StatusListResult>;
|
|
312
|
+
declare function statusListCredentialToDetails({ statusListType, correlationId, driverType, statusListCredential, bitsPerStatus, }: {
|
|
313
|
+
statusListType: StatusListType;
|
|
312
314
|
statusListCredential: StatusListCredential;
|
|
313
315
|
correlationId?: string;
|
|
314
316
|
driverType?: StatusListDriverType;
|
|
@@ -319,7 +321,7 @@ declare function createCredentialStatusFromStatusList(args: {
|
|
|
319
321
|
statusListEntry: IStatusListEntryEntity | IBitstringStatusListEntryEntity;
|
|
320
322
|
statusListIndex: number;
|
|
321
323
|
}): Promise<StatusList2021EntryCredentialStatus | StatusListOAuthEntryCredentialStatus | BitstringStatusListEntryCredentialStatus>;
|
|
322
|
-
declare function updateStatusListIndexFromEncodedList(args: UpdateStatusListFromEncodedListArgs, context: IAgentContext<
|
|
323
|
-
declare function statusList2021ToVerifiableCredential(args: StatusList2021ToVerifiableCredentialArgs, context: IAgentContext<
|
|
324
|
+
declare function updateStatusListIndexFromEncodedList(args: UpdateStatusListFromEncodedListArgs, context: IAgentContext<IVcdmCredentialPlugin & IIdentifierResolution>): Promise<StatusListResult>;
|
|
325
|
+
declare function statusList2021ToVerifiableCredential(args: StatusList2021ToVerifiableCredentialArgs, context: IAgentContext<IVcdmCredentialPlugin & IIdentifierResolution>): Promise<StatusListCredential>;
|
|
324
326
|
|
|
325
327
|
export { type BaseCreateNewStatusListArgs, type BitstringStatus, type BitstringStatusListArgs, type BitstringStatusListEntryCredentialStatus, type CheckStatusIndexArgs, type CreateNewStatusListArgs, type CreateNewStatusListFuncArgs, type CreateStatusListArgs, type CredentialWithStatusSupport, type GetStatusListArgs, type IAddStatusToCredentialArgs, type IAddStatusToSdJwtCredentialArgs, type IIssueCredentialStatusOpts, type IRequiredContext, type IRequiredPlugins, type IStatusListPlugin, type OAuthStatusListArgs, type SignedStatusListData, Status2021, type StatusList2021Args, type StatusList2021EntryCredentialStatus, type StatusList2021ToVerifiableCredentialArgs, type StatusListOAuthEntryCredentialStatus, type StatusListResult, StatusOAuth, type ToStatusListDetailsArgs, type UpdateBitstringStatusListArgs, type UpdateOAuthStatusListArgs, type UpdateStatusList2021Args, type UpdateStatusListFromEncodedListArgs, type UpdateStatusListFromStatusListCredentialArgs, type UpdateStatusListIndexArgs, checkStatusForCredential, checkStatusIndexFromStatusListCredential, createCredentialStatusFromStatusList, createNewStatusList, fetchStatusListCredential, simpleCheckStatusFromStatusListUrl, statusList2021ToVerifiableCredential, statusListCredentialToDetails, statusPluginStatusFunction, updateStatusIndexFromStatusListCredential, updateStatusListIndexFromEncodedList, vcLibCheckStatusFunction };
|
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
|
]);
|
|
@@ -798,6 +799,13 @@ var BitstringStatusListImplementation = class {
|
|
|
798
799
|
static {
|
|
799
800
|
__name(this, "BitstringStatusListImplementation");
|
|
800
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
|
+
*/
|
|
801
809
|
async createNewStatusList(args, context) {
|
|
802
810
|
if (!args.bitstringStatusList) {
|
|
803
811
|
throw new Error("BitstringStatusList options are required for type BitstringStatusList");
|
|
@@ -805,28 +813,34 @@ var BitstringStatusListImplementation = class {
|
|
|
805
813
|
const length = args?.length ?? DEFAULT_LIST_LENGTH3;
|
|
806
814
|
const proofFormat = args?.proofFormat ?? DEFAULT_PROOF_FORMAT3;
|
|
807
815
|
assertValidProofType(StatusListType4.BitstringStatusList, proofFormat);
|
|
808
|
-
const veramoProofFormat = proofFormat;
|
|
809
816
|
const { issuer, id } = args;
|
|
810
817
|
const correlationId = getAssertedValue("correlationId", args.correlationId);
|
|
811
818
|
const { statusPurpose, bitsPerStatus, validFrom, validUntil, ttl } = args.bitstringStatusList;
|
|
812
|
-
const
|
|
813
|
-
|
|
814
|
-
|
|
819
|
+
const unsignedCredential = await createStatusListCredential({
|
|
820
|
+
id,
|
|
821
|
+
issuer,
|
|
815
822
|
statusPurpose: statusPurpose ?? DEFAULT_STATUS_PURPOSE,
|
|
816
823
|
validFrom: ensureDate(validFrom),
|
|
817
824
|
validUntil: ensureDate(validUntil),
|
|
818
825
|
ttl
|
|
826
|
+
});
|
|
827
|
+
const statusListCredential = await this.createVerifiableCredential({
|
|
828
|
+
unsignedCredential,
|
|
829
|
+
id,
|
|
830
|
+
issuer,
|
|
831
|
+
proofFormat,
|
|
832
|
+
keyRef: args.keyRef
|
|
819
833
|
}, context);
|
|
820
834
|
return {
|
|
821
|
-
encodedList:
|
|
835
|
+
encodedList: unsignedCredential.credentialSubject.encodedList,
|
|
822
836
|
statusListCredential,
|
|
823
837
|
bitstringStatusList: {
|
|
824
838
|
statusPurpose: statusPurpose ?? DEFAULT_STATUS_PURPOSE,
|
|
825
|
-
...
|
|
826
|
-
validFrom: new Date(
|
|
839
|
+
...unsignedCredential.validFrom && {
|
|
840
|
+
validFrom: new Date(unsignedCredential.validFrom)
|
|
827
841
|
},
|
|
828
|
-
...
|
|
829
|
-
validUntil: new Date(
|
|
842
|
+
...unsignedCredential.validUntil && {
|
|
843
|
+
validUntil: new Date(unsignedCredential.validUntil)
|
|
830
844
|
},
|
|
831
845
|
ttl,
|
|
832
846
|
bitsPerStatus
|
|
@@ -840,9 +854,16 @@ var BitstringStatusListImplementation = class {
|
|
|
840
854
|
statuslistContentType: this.buildContentType(proofFormat)
|
|
841
855
|
};
|
|
842
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
|
+
*/
|
|
843
864
|
async updateStatusListIndex(args, context) {
|
|
844
865
|
if (!args.bitsPerStatus || args.bitsPerStatus < 1) {
|
|
845
|
-
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)"));
|
|
846
867
|
}
|
|
847
868
|
const credential = args.statusListCredential;
|
|
848
869
|
const uniform = CredentialMapper3.toUniformCredential(credential);
|
|
@@ -861,27 +882,32 @@ var BitstringStatusListImplementation = class {
|
|
|
861
882
|
const validFrom = uniform.validFrom ? new Date(uniform.validFrom) : void 0;
|
|
862
883
|
const validUntil = uniform.validUntil ? new Date(uniform.validUntil) : void 0;
|
|
863
884
|
const ttl = credSubject.ttl;
|
|
864
|
-
const
|
|
865
|
-
...args,
|
|
885
|
+
const unsignedCredential = await createStatusListCredential({
|
|
866
886
|
id,
|
|
867
887
|
issuer,
|
|
868
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,
|
|
869
898
|
proofFormat,
|
|
870
|
-
|
|
871
|
-
ttl,
|
|
872
|
-
validFrom,
|
|
873
|
-
validUntil
|
|
899
|
+
keyRef: args.keyRef
|
|
874
900
|
}, context);
|
|
875
901
|
return {
|
|
876
902
|
statusListCredential: updatedCredential,
|
|
877
|
-
encodedList:
|
|
903
|
+
encodedList: unsignedCredential.credentialSubject.encodedList,
|
|
878
904
|
bitstringStatusList: {
|
|
879
905
|
statusPurpose,
|
|
880
|
-
...
|
|
881
|
-
validFrom: new Date(
|
|
906
|
+
...unsignedCredential.validFrom && {
|
|
907
|
+
validFrom: new Date(unsignedCredential.validFrom)
|
|
882
908
|
},
|
|
883
|
-
...
|
|
884
|
-
validUntil: new Date(
|
|
909
|
+
...unsignedCredential.validUntil && {
|
|
910
|
+
validUntil: new Date(unsignedCredential.validUntil)
|
|
885
911
|
},
|
|
886
912
|
bitsPerStatus: args.bitsPerStatus,
|
|
887
913
|
ttl
|
|
@@ -894,17 +920,23 @@ var BitstringStatusListImplementation = class {
|
|
|
894
920
|
statuslistContentType: this.buildContentType(proofFormat)
|
|
895
921
|
};
|
|
896
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
|
+
*/
|
|
897
930
|
async updateStatusListFromEncodedList(args, context) {
|
|
898
931
|
if (!args.bitstringStatusList) {
|
|
899
932
|
throw new Error("bitstringStatusList options required for type BitstringStatusList");
|
|
900
933
|
}
|
|
901
934
|
if (args.bitstringStatusList.bitsPerStatus < 1) {
|
|
902
|
-
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)"));
|
|
903
936
|
}
|
|
904
937
|
const { statusPurpose, bitsPerStatus, ttl, validFrom, validUntil } = args.bitstringStatusList;
|
|
905
938
|
const proofFormat = args?.proofFormat ?? DEFAULT_PROOF_FORMAT3;
|
|
906
939
|
assertValidProofType(StatusListType4.BitstringStatusList, proofFormat);
|
|
907
|
-
const veramoProofFormat = proofFormat;
|
|
908
940
|
const { issuer, id } = getAssertedValues(args);
|
|
909
941
|
const statusList = await BitstreamStatusList.decode({
|
|
910
942
|
encodedList: args.encodedList,
|
|
@@ -912,29 +944,34 @@ var BitstringStatusListImplementation = class {
|
|
|
912
944
|
});
|
|
913
945
|
const index = typeof args.statusListIndex === "number" ? args.statusListIndex : parseInt(args.statusListIndex);
|
|
914
946
|
statusList.setStatus(index, args.value);
|
|
915
|
-
const
|
|
947
|
+
const unsignedCredential = await createStatusListCredential({
|
|
916
948
|
id,
|
|
917
949
|
issuer,
|
|
918
950
|
statusList,
|
|
919
|
-
|
|
920
|
-
keyRef: args.keyRef,
|
|
921
|
-
statusPurpose,
|
|
951
|
+
statusPurpose: statusPurpose ?? DEFAULT_STATUS_PURPOSE,
|
|
922
952
|
validFrom: ensureDate(validFrom),
|
|
923
953
|
validUntil: ensureDate(validUntil),
|
|
924
954
|
ttl
|
|
955
|
+
});
|
|
956
|
+
const credential = await this.createVerifiableCredential({
|
|
957
|
+
unsignedCredential,
|
|
958
|
+
id,
|
|
959
|
+
issuer,
|
|
960
|
+
proofFormat,
|
|
961
|
+
keyRef: args.keyRef
|
|
925
962
|
}, context);
|
|
926
963
|
return {
|
|
927
964
|
type: StatusListType4.BitstringStatusList,
|
|
928
965
|
statusListCredential: credential,
|
|
929
|
-
encodedList:
|
|
966
|
+
encodedList: unsignedCredential.credentialSubject.encodedList,
|
|
930
967
|
bitstringStatusList: {
|
|
931
968
|
statusPurpose,
|
|
932
969
|
bitsPerStatus,
|
|
933
|
-
...
|
|
934
|
-
validFrom: new Date(
|
|
970
|
+
...unsignedCredential.validFrom && {
|
|
971
|
+
validFrom: new Date(unsignedCredential.validFrom)
|
|
935
972
|
},
|
|
936
|
-
...
|
|
937
|
-
validUntil: new Date(
|
|
973
|
+
...unsignedCredential.validUntil && {
|
|
974
|
+
validUntil: new Date(unsignedCredential.validUntil)
|
|
938
975
|
},
|
|
939
976
|
ttl
|
|
940
977
|
},
|
|
@@ -945,17 +982,22 @@ var BitstringStatusListImplementation = class {
|
|
|
945
982
|
statuslistContentType: this.buildContentType(proofFormat)
|
|
946
983
|
};
|
|
947
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
|
+
*/
|
|
948
991
|
async checkStatusIndex(args) {
|
|
949
992
|
if (!args.bitsPerStatus || args.bitsPerStatus < 1) {
|
|
950
|
-
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)"));
|
|
951
994
|
}
|
|
952
995
|
const uniform = CredentialMapper3.toUniformCredential(args.statusListCredential);
|
|
953
996
|
const { credentialSubject } = uniform;
|
|
954
997
|
const encodedList = getAssertedProperty("encodedList", credentialSubject);
|
|
955
|
-
const statusSize = args.bitsPerStatus;
|
|
956
998
|
const statusList = await BitstreamStatusList.decode({
|
|
957
999
|
encodedList,
|
|
958
|
-
statusSize
|
|
1000
|
+
statusSize: args.bitsPerStatus
|
|
959
1001
|
});
|
|
960
1002
|
const numIndex = typeof args.statusListIndex === "number" ? args.statusListIndex : parseInt(args.statusListIndex);
|
|
961
1003
|
if (statusList.getLength() <= numIndex) {
|
|
@@ -963,16 +1005,22 @@ var BitstringStatusListImplementation = class {
|
|
|
963
1005
|
}
|
|
964
1006
|
return statusList.getStatus(numIndex);
|
|
965
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
|
+
*/
|
|
966
1014
|
async toStatusListDetails(args) {
|
|
967
1015
|
const { statusListPayload, bitsPerStatus } = args;
|
|
968
1016
|
if (!bitsPerStatus || bitsPerStatus < 1) {
|
|
969
|
-
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)"));
|
|
970
1018
|
}
|
|
971
1019
|
const uniform = CredentialMapper3.toUniformCredential(statusListPayload);
|
|
972
1020
|
const { issuer, credentialSubject } = uniform;
|
|
973
1021
|
const id = getAssertedValue("id", uniform.id);
|
|
974
1022
|
const encodedList = getAssertedProperty("encodedList", credentialSubject);
|
|
975
|
-
const proofFormat = CredentialMapper3.detectDocumentType(statusListPayload) === DocumentFormat3.JWT ? "jwt" : "lds";
|
|
1023
|
+
const proofFormat = CredentialMapper3.detectDocumentType(statusListPayload) === DocumentFormat3.JWT ? "vc+jwt" : "lds";
|
|
976
1024
|
const credSubject = Array.isArray(credentialSubject) ? credentialSubject[0] : credentialSubject;
|
|
977
1025
|
const statusPurpose = getAssertedProperty("statusPurpose", credSubject);
|
|
978
1026
|
const validFrom = uniform.validFrom ? new Date(uniform.validFrom) : void 0;
|
|
@@ -1026,6 +1074,12 @@ var BitstringStatusListImplementation = class {
|
|
|
1026
1074
|
}
|
|
1027
1075
|
};
|
|
1028
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
|
+
*/
|
|
1029
1083
|
async createCredentialStatus(args) {
|
|
1030
1084
|
const { statusList, statusListEntry, statusListIndex } = args;
|
|
1031
1085
|
const isBitstringEntry = /* @__PURE__ */ __name((entry) => {
|
|
@@ -1044,27 +1098,42 @@ var BitstringStatusListImplementation = class {
|
|
|
1044
1098
|
bitsPerStatus: bitstringStatusList.bitsPerStatus
|
|
1045
1099
|
};
|
|
1046
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
|
+
*/
|
|
1047
1108
|
async createVerifiableCredential(args, context) {
|
|
1109
|
+
const { unsignedCredential, issuer, proofFormat, keyRef } = args;
|
|
1048
1110
|
const identifier = await context.agent.identifierManagedGet({
|
|
1049
|
-
identifier: typeof
|
|
1111
|
+
identifier: typeof issuer === "string" ? issuer : issuer.id,
|
|
1050
1112
|
vmRelationship: "assertionMethod",
|
|
1051
1113
|
offlineWhenNoDIDRegistered: true
|
|
1052
1114
|
});
|
|
1053
|
-
const unsignedCredential = await createStatusListCredential(args);
|
|
1054
1115
|
const verifiableCredential = await context.agent.createVerifiableCredential({
|
|
1055
1116
|
credential: unsignedCredential,
|
|
1056
|
-
keyRef:
|
|
1057
|
-
proofFormat
|
|
1117
|
+
keyRef: keyRef ?? identifier.kmsKeyRef,
|
|
1118
|
+
proofFormat,
|
|
1058
1119
|
fetchRemoteContexts: true
|
|
1059
1120
|
});
|
|
1060
1121
|
return CredentialMapper3.toWrappedVerifiableCredential(verifiableCredential).original;
|
|
1061
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
|
+
*/
|
|
1062
1129
|
buildContentType(proofFormat) {
|
|
1063
1130
|
switch (proofFormat) {
|
|
1064
1131
|
case "jwt":
|
|
1065
|
-
return
|
|
1132
|
+
return "application/statuslist+jwt";
|
|
1066
1133
|
case "cbor":
|
|
1067
|
-
return
|
|
1134
|
+
return "application/statuslist+cwt";
|
|
1135
|
+
case "vc+jwt":
|
|
1136
|
+
return "application/statuslist+vc+jwt";
|
|
1068
1137
|
case "lds":
|
|
1069
1138
|
return "application/statuslist+ld+json";
|
|
1070
1139
|
default:
|
|
@@ -1220,27 +1289,8 @@ async function updateStatusIndexFromStatusListCredential(args, context) {
|
|
|
1220
1289
|
return implementation.updateStatusListIndex(args, context);
|
|
1221
1290
|
}
|
|
1222
1291
|
__name(updateStatusIndexFromStatusListCredential, "updateStatusIndexFromStatusListCredential");
|
|
1223
|
-
async function statusListCredentialToDetails({ correlationId, driverType, statusListCredential, bitsPerStatus }) {
|
|
1292
|
+
async function statusListCredentialToDetails({ statusListType, correlationId, driverType, statusListCredential, bitsPerStatus }) {
|
|
1224
1293
|
const credential = getAssertedValue("statusListCredential", statusListCredential);
|
|
1225
|
-
let statusListType;
|
|
1226
|
-
const documentFormat = CredentialMapper4.detectDocumentType(credential);
|
|
1227
|
-
if (documentFormat === DocumentFormat4.JWT) {
|
|
1228
|
-
const [header] = credential.split(".");
|
|
1229
|
-
const decodedHeader = JSON.parse(Buffer.from(header, "base64").toString());
|
|
1230
|
-
if (decodedHeader.typ === "statuslist+jwt") {
|
|
1231
|
-
statusListType = StatusListType6.OAuthStatusList;
|
|
1232
|
-
}
|
|
1233
|
-
} else if (documentFormat === DocumentFormat4.MSO_MDOC) {
|
|
1234
|
-
statusListType = StatusListType6.OAuthStatusList;
|
|
1235
|
-
}
|
|
1236
|
-
if (!statusListType) {
|
|
1237
|
-
const uniform = CredentialMapper4.toUniformCredential(credential);
|
|
1238
|
-
const type = uniform.type.find((t) => t.includes("StatusList2021") || t.includes("OAuth2StatusList") || t.includes("BitstringStatusList"));
|
|
1239
|
-
if (!type) {
|
|
1240
|
-
throw new Error("Invalid status list credential type");
|
|
1241
|
-
}
|
|
1242
|
-
statusListType = type.replace("Credential", "");
|
|
1243
|
-
}
|
|
1244
1294
|
const implementation = getStatusListImplementation(statusListType);
|
|
1245
1295
|
const result = await implementation.toStatusListDetails({
|
|
1246
1296
|
statusListPayload: credential,
|