@sphereon/ssi-sdk.vc-status-list 0.34.1-feature.SSISDK.17.bitstring.sl.2 → 0.34.1-feature.SSISDK.17.bitstring.sl.7
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 +82 -95
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +16 -21
- package/dist/index.d.ts +16 -21
- package/dist/index.js +82 -95
- package/dist/index.js.map +1 -1
- package/package.json +4 -5
- package/src/functions.ts +12 -4
- package/src/impl/BitstringStatusListImplementation.ts +58 -91
- package/src/impl/IStatusList.ts +2 -2
- package/src/impl/OAuthStatusList.ts +1 -2
- package/src/impl/StatusList2021.ts +1 -1
- package/src/types/BitstringStatusList.ts +3 -41
- package/src/types/index.ts +11 -20
- package/src/utils.ts +2 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { IIdentifierResolution } from '@sphereon/ssi-sdk-ext.identifier-resolution';
|
|
2
|
-
import { StatusListIndexingDirection, StatusPurpose2021,
|
|
2
|
+
import { StatusListIndexingDirection, StatusPurpose2021, StatusListType, IIssuer, CredentialProofFormat, StatusListDriverType, StatusListCredential, StatusListCredentialIdMode, ICredentialStatus, OrPromise, ICredential, IVerifiableCredential } from '@sphereon/ssi-types';
|
|
3
3
|
import { IPluginMethodMap, IAgentContext, ICredentialIssuer, ICredentialVerifier, IKeyManager, ICredentialPlugin, 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
|
+
import { BitstringStatusPurpose } from '@4sure-tech/vc-bitstring-status-lists';
|
|
8
9
|
import { StatusMethod } from 'credential-status';
|
|
9
10
|
|
|
10
11
|
declare enum StatusOAuth {
|
|
@@ -16,18 +17,7 @@ declare enum Status2021 {
|
|
|
16
17
|
Valid = 0,
|
|
17
18
|
Invalid = 1
|
|
18
19
|
}
|
|
19
|
-
type BitstringStatus =
|
|
20
|
-
status: string;
|
|
21
|
-
message?: string;
|
|
22
|
-
[x: string]: any;
|
|
23
|
-
};
|
|
24
|
-
type BitstringStatusResult = BitstringStatus & {
|
|
25
|
-
index: number;
|
|
26
|
-
status: string;
|
|
27
|
-
set: boolean;
|
|
28
|
-
message?: string;
|
|
29
|
-
[x: string]: any;
|
|
30
|
-
};
|
|
20
|
+
type BitstringStatus = number;
|
|
31
21
|
type StatusList2021Args = {
|
|
32
22
|
indexingDirection: StatusListIndexingDirection;
|
|
33
23
|
statusPurpose?: StatusPurpose2021;
|
|
@@ -38,8 +28,7 @@ type OAuthStatusListArgs = {
|
|
|
38
28
|
};
|
|
39
29
|
type BitstringStatusListArgs = {
|
|
40
30
|
statusPurpose: BitstringStatusPurpose;
|
|
41
|
-
|
|
42
|
-
statusMessage?: Array<BitstringStatus>;
|
|
31
|
+
bitsPerStatus: number;
|
|
43
32
|
ttl?: number;
|
|
44
33
|
validFrom?: Date;
|
|
45
34
|
validUntil?: Date;
|
|
@@ -54,6 +43,7 @@ type BaseCreateNewStatusListArgs = {
|
|
|
54
43
|
keyRef?: string;
|
|
55
44
|
statusList2021?: StatusList2021Args;
|
|
56
45
|
oauthStatusList?: OAuthStatusListArgs;
|
|
46
|
+
bitstringStatusList?: BitstringStatusListArgs;
|
|
57
47
|
driverType?: StatusListDriverType;
|
|
58
48
|
};
|
|
59
49
|
type UpdateStatusList2021Args = {
|
|
@@ -65,8 +55,7 @@ type UpdateOAuthStatusListArgs = {
|
|
|
65
55
|
};
|
|
66
56
|
type UpdateBitstringStatusListArgs = {
|
|
67
57
|
statusPurpose: BitstringStatusPurpose;
|
|
68
|
-
|
|
69
|
-
statusMessage?: Array<BitstringStatus>;
|
|
58
|
+
bitsPerStatus: number;
|
|
70
59
|
validFrom?: Date;
|
|
71
60
|
validUntil?: Date;
|
|
72
61
|
ttl?: number;
|
|
@@ -74,7 +63,7 @@ type UpdateBitstringStatusListArgs = {
|
|
|
74
63
|
interface UpdateStatusListFromEncodedListArgs {
|
|
75
64
|
type?: StatusListType;
|
|
76
65
|
statusListIndex: number | string;
|
|
77
|
-
value:
|
|
66
|
+
value: number;
|
|
78
67
|
proofFormat?: CredentialProofFormat;
|
|
79
68
|
keyRef?: string;
|
|
80
69
|
correlationId?: string;
|
|
@@ -117,6 +106,7 @@ interface OAuthStatusDetails {
|
|
|
117
106
|
}
|
|
118
107
|
interface BitstringStatusDetails {
|
|
119
108
|
statusPurpose: BitstringStatusPurpose;
|
|
109
|
+
bitsPerStatus: number;
|
|
120
110
|
validFrom?: Date;
|
|
121
111
|
validUntil?: Date;
|
|
122
112
|
ttl?: number;
|
|
@@ -139,7 +129,7 @@ interface BitstringStatusListEntryCredentialStatus extends ICredentialStatus {
|
|
|
139
129
|
statusPurpose: BitstringStatusPurpose | BitstringStatusPurpose[];
|
|
140
130
|
statusListIndex: string;
|
|
141
131
|
statusListCredential: string;
|
|
142
|
-
|
|
132
|
+
bitsPerStatus?: number;
|
|
143
133
|
statusMessage?: Array<BitstringStatus>;
|
|
144
134
|
statusReference?: string | string[];
|
|
145
135
|
}
|
|
@@ -167,17 +157,20 @@ interface UpdateStatusListIndexArgs {
|
|
|
167
157
|
statusListCredential: StatusListCredential;
|
|
168
158
|
statusListIndex: number | string;
|
|
169
159
|
value: number | Status2021 | StatusOAuth | BitstringStatus;
|
|
160
|
+
bitsPerStatus?: number;
|
|
170
161
|
keyRef?: string;
|
|
171
162
|
expiresAt?: Date;
|
|
172
163
|
}
|
|
173
164
|
interface CheckStatusIndexArgs {
|
|
174
165
|
statusListCredential: StatusListCredential;
|
|
175
166
|
statusListIndex: string | number;
|
|
167
|
+
bitsPerStatus?: number;
|
|
176
168
|
}
|
|
177
169
|
interface ToStatusListDetailsArgs {
|
|
178
170
|
statusListPayload: StatusListCredential;
|
|
179
171
|
correlationId?: string;
|
|
180
172
|
driverType?: StatusListDriverType;
|
|
173
|
+
bitsPerStatus?: number;
|
|
181
174
|
}
|
|
182
175
|
/**
|
|
183
176
|
* The interface definition for a plugin that can add statuslist info to a credential
|
|
@@ -307,15 +300,17 @@ declare function checkStatusIndexFromStatusListCredential(args: {
|
|
|
307
300
|
type?: StatusListType | 'StatusList2021Entry' | 'BitstringStatusListEntry';
|
|
308
301
|
id?: string;
|
|
309
302
|
statusListIndex: string | number;
|
|
303
|
+
bitsPerStatus?: number;
|
|
310
304
|
}): Promise<number | Status2021 | StatusOAuth | BitstringStatus>;
|
|
311
305
|
declare function createNewStatusList(args: CreateNewStatusListFuncArgs, context: IAgentContext<(ICredentialPlugin | any) & IIdentifierResolution>): Promise<StatusListResult>;
|
|
312
306
|
declare function updateStatusIndexFromStatusListCredential(args: UpdateStatusListIndexArgs, context: IAgentContext<ICredentialPlugin & IIdentifierResolution>): Promise<StatusListResult>;
|
|
313
|
-
declare function statusListCredentialToDetails(
|
|
307
|
+
declare function statusListCredentialToDetails({ correlationId, driverType, statusListCredential, bitsPerStatus, }: {
|
|
314
308
|
statusListCredential: StatusListCredential;
|
|
315
309
|
correlationId?: string;
|
|
316
310
|
driverType?: StatusListDriverType;
|
|
311
|
+
bitsPerStatus?: number;
|
|
317
312
|
}): Promise<StatusListResult>;
|
|
318
313
|
declare function updateStatusListIndexFromEncodedList(args: UpdateStatusListFromEncodedListArgs, context: IAgentContext<ICredentialPlugin & IIdentifierResolution>): Promise<StatusListResult>;
|
|
319
314
|
declare function statusList2021ToVerifiableCredential(args: StatusList2021ToVerifiableCredentialArgs, context: IAgentContext<ICredentialPlugin & IIdentifierResolution>): Promise<StatusListCredential>;
|
|
320
315
|
|
|
321
|
-
export { type BaseCreateNewStatusListArgs, type BitstringStatus, type BitstringStatusListArgs, type BitstringStatusListEntryCredentialStatus, type
|
|
316
|
+
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, createNewStatusList, fetchStatusListCredential, simpleCheckStatusFromStatusListUrl, statusList2021ToVerifiableCredential, statusListCredentialToDetails, statusPluginStatusFunction, updateStatusIndexFromStatusListCredential, updateStatusListIndexFromEncodedList, vcLibCheckStatusFunction };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { IIdentifierResolution } from '@sphereon/ssi-sdk-ext.identifier-resolution';
|
|
2
|
-
import { StatusListIndexingDirection, StatusPurpose2021,
|
|
2
|
+
import { StatusListIndexingDirection, StatusPurpose2021, StatusListType, IIssuer, CredentialProofFormat, StatusListDriverType, StatusListCredential, StatusListCredentialIdMode, ICredentialStatus, OrPromise, ICredential, IVerifiableCredential } from '@sphereon/ssi-types';
|
|
3
3
|
import { IPluginMethodMap, IAgentContext, ICredentialIssuer, ICredentialVerifier, IKeyManager, ICredentialPlugin, 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
|
+
import { BitstringStatusPurpose } from '@4sure-tech/vc-bitstring-status-lists';
|
|
8
9
|
import { StatusMethod } from 'credential-status';
|
|
9
10
|
|
|
10
11
|
declare enum StatusOAuth {
|
|
@@ -16,18 +17,7 @@ declare enum Status2021 {
|
|
|
16
17
|
Valid = 0,
|
|
17
18
|
Invalid = 1
|
|
18
19
|
}
|
|
19
|
-
type BitstringStatus =
|
|
20
|
-
status: string;
|
|
21
|
-
message?: string;
|
|
22
|
-
[x: string]: any;
|
|
23
|
-
};
|
|
24
|
-
type BitstringStatusResult = BitstringStatus & {
|
|
25
|
-
index: number;
|
|
26
|
-
status: string;
|
|
27
|
-
set: boolean;
|
|
28
|
-
message?: string;
|
|
29
|
-
[x: string]: any;
|
|
30
|
-
};
|
|
20
|
+
type BitstringStatus = number;
|
|
31
21
|
type StatusList2021Args = {
|
|
32
22
|
indexingDirection: StatusListIndexingDirection;
|
|
33
23
|
statusPurpose?: StatusPurpose2021;
|
|
@@ -38,8 +28,7 @@ type OAuthStatusListArgs = {
|
|
|
38
28
|
};
|
|
39
29
|
type BitstringStatusListArgs = {
|
|
40
30
|
statusPurpose: BitstringStatusPurpose;
|
|
41
|
-
|
|
42
|
-
statusMessage?: Array<BitstringStatus>;
|
|
31
|
+
bitsPerStatus: number;
|
|
43
32
|
ttl?: number;
|
|
44
33
|
validFrom?: Date;
|
|
45
34
|
validUntil?: Date;
|
|
@@ -54,6 +43,7 @@ type BaseCreateNewStatusListArgs = {
|
|
|
54
43
|
keyRef?: string;
|
|
55
44
|
statusList2021?: StatusList2021Args;
|
|
56
45
|
oauthStatusList?: OAuthStatusListArgs;
|
|
46
|
+
bitstringStatusList?: BitstringStatusListArgs;
|
|
57
47
|
driverType?: StatusListDriverType;
|
|
58
48
|
};
|
|
59
49
|
type UpdateStatusList2021Args = {
|
|
@@ -65,8 +55,7 @@ type UpdateOAuthStatusListArgs = {
|
|
|
65
55
|
};
|
|
66
56
|
type UpdateBitstringStatusListArgs = {
|
|
67
57
|
statusPurpose: BitstringStatusPurpose;
|
|
68
|
-
|
|
69
|
-
statusMessage?: Array<BitstringStatus>;
|
|
58
|
+
bitsPerStatus: number;
|
|
70
59
|
validFrom?: Date;
|
|
71
60
|
validUntil?: Date;
|
|
72
61
|
ttl?: number;
|
|
@@ -74,7 +63,7 @@ type UpdateBitstringStatusListArgs = {
|
|
|
74
63
|
interface UpdateStatusListFromEncodedListArgs {
|
|
75
64
|
type?: StatusListType;
|
|
76
65
|
statusListIndex: number | string;
|
|
77
|
-
value:
|
|
66
|
+
value: number;
|
|
78
67
|
proofFormat?: CredentialProofFormat;
|
|
79
68
|
keyRef?: string;
|
|
80
69
|
correlationId?: string;
|
|
@@ -117,6 +106,7 @@ interface OAuthStatusDetails {
|
|
|
117
106
|
}
|
|
118
107
|
interface BitstringStatusDetails {
|
|
119
108
|
statusPurpose: BitstringStatusPurpose;
|
|
109
|
+
bitsPerStatus: number;
|
|
120
110
|
validFrom?: Date;
|
|
121
111
|
validUntil?: Date;
|
|
122
112
|
ttl?: number;
|
|
@@ -139,7 +129,7 @@ interface BitstringStatusListEntryCredentialStatus extends ICredentialStatus {
|
|
|
139
129
|
statusPurpose: BitstringStatusPurpose | BitstringStatusPurpose[];
|
|
140
130
|
statusListIndex: string;
|
|
141
131
|
statusListCredential: string;
|
|
142
|
-
|
|
132
|
+
bitsPerStatus?: number;
|
|
143
133
|
statusMessage?: Array<BitstringStatus>;
|
|
144
134
|
statusReference?: string | string[];
|
|
145
135
|
}
|
|
@@ -167,17 +157,20 @@ interface UpdateStatusListIndexArgs {
|
|
|
167
157
|
statusListCredential: StatusListCredential;
|
|
168
158
|
statusListIndex: number | string;
|
|
169
159
|
value: number | Status2021 | StatusOAuth | BitstringStatus;
|
|
160
|
+
bitsPerStatus?: number;
|
|
170
161
|
keyRef?: string;
|
|
171
162
|
expiresAt?: Date;
|
|
172
163
|
}
|
|
173
164
|
interface CheckStatusIndexArgs {
|
|
174
165
|
statusListCredential: StatusListCredential;
|
|
175
166
|
statusListIndex: string | number;
|
|
167
|
+
bitsPerStatus?: number;
|
|
176
168
|
}
|
|
177
169
|
interface ToStatusListDetailsArgs {
|
|
178
170
|
statusListPayload: StatusListCredential;
|
|
179
171
|
correlationId?: string;
|
|
180
172
|
driverType?: StatusListDriverType;
|
|
173
|
+
bitsPerStatus?: number;
|
|
181
174
|
}
|
|
182
175
|
/**
|
|
183
176
|
* The interface definition for a plugin that can add statuslist info to a credential
|
|
@@ -307,15 +300,17 @@ declare function checkStatusIndexFromStatusListCredential(args: {
|
|
|
307
300
|
type?: StatusListType | 'StatusList2021Entry' | 'BitstringStatusListEntry';
|
|
308
301
|
id?: string;
|
|
309
302
|
statusListIndex: string | number;
|
|
303
|
+
bitsPerStatus?: number;
|
|
310
304
|
}): Promise<number | Status2021 | StatusOAuth | BitstringStatus>;
|
|
311
305
|
declare function createNewStatusList(args: CreateNewStatusListFuncArgs, context: IAgentContext<(ICredentialPlugin | any) & IIdentifierResolution>): Promise<StatusListResult>;
|
|
312
306
|
declare function updateStatusIndexFromStatusListCredential(args: UpdateStatusListIndexArgs, context: IAgentContext<ICredentialPlugin & IIdentifierResolution>): Promise<StatusListResult>;
|
|
313
|
-
declare function statusListCredentialToDetails(
|
|
307
|
+
declare function statusListCredentialToDetails({ correlationId, driverType, statusListCredential, bitsPerStatus, }: {
|
|
314
308
|
statusListCredential: StatusListCredential;
|
|
315
309
|
correlationId?: string;
|
|
316
310
|
driverType?: StatusListDriverType;
|
|
311
|
+
bitsPerStatus?: number;
|
|
317
312
|
}): Promise<StatusListResult>;
|
|
318
313
|
declare function updateStatusListIndexFromEncodedList(args: UpdateStatusListFromEncodedListArgs, context: IAgentContext<ICredentialPlugin & IIdentifierResolution>): Promise<StatusListResult>;
|
|
319
314
|
declare function statusList2021ToVerifiableCredential(args: StatusList2021ToVerifiableCredentialArgs, context: IAgentContext<ICredentialPlugin & IIdentifierResolution>): Promise<StatusListCredential>;
|
|
320
315
|
|
|
321
|
-
export { type BaseCreateNewStatusListArgs, type BitstringStatus, type BitstringStatusListArgs, type BitstringStatusListEntryCredentialStatus, type
|
|
316
|
+
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, createNewStatusList, fetchStatusListCredential, simpleCheckStatusFromStatusListUrl, statusList2021ToVerifiableCredential, statusListCredentialToDetails, statusPluginStatusFunction, updateStatusIndexFromStatusListCredential, updateStatusListIndexFromEncodedList, vcLibCheckStatusFunction };
|
package/dist/index.js
CHANGED
|
@@ -25,7 +25,8 @@ function getAssertedStatusListType(type) {
|
|
|
25
25
|
const assertedType = type ?? StatusListType.StatusList2021;
|
|
26
26
|
if (![
|
|
27
27
|
StatusListType.StatusList2021,
|
|
28
|
-
StatusListType.OAuthStatusList
|
|
28
|
+
StatusListType.OAuthStatusList,
|
|
29
|
+
StatusListType.BitstringStatusList
|
|
29
30
|
].includes(assertedType)) {
|
|
30
31
|
throw Error(`StatusList type ${assertedType} is not supported (yet)`);
|
|
31
32
|
}
|
|
@@ -71,6 +72,12 @@ var ValidProofTypeMap = /* @__PURE__ */ new Map([
|
|
|
71
72
|
"jwt",
|
|
72
73
|
"cbor"
|
|
73
74
|
]
|
|
75
|
+
],
|
|
76
|
+
[
|
|
77
|
+
StatusListType.BitstringStatusList,
|
|
78
|
+
[
|
|
79
|
+
"lds"
|
|
80
|
+
]
|
|
74
81
|
]
|
|
75
82
|
]);
|
|
76
83
|
function assertValidProofType(type, proofFormat) {
|
|
@@ -213,7 +220,7 @@ var StatusList2021Implementation = class {
|
|
|
213
220
|
encodedList: args.encodedList
|
|
214
221
|
});
|
|
215
222
|
const index = typeof args.statusListIndex === "number" ? args.statusListIndex : parseInt(args.statusListIndex);
|
|
216
|
-
statusList.setStatus(index, args.value);
|
|
223
|
+
statusList.setStatus(index, args.value !== 0);
|
|
217
224
|
const newEncodedList = await statusList.encode();
|
|
218
225
|
const credential = await this.createVerifiableCredential({
|
|
219
226
|
id,
|
|
@@ -635,7 +642,7 @@ var OAuthStatusListImplementation = class {
|
|
|
635
642
|
const issuerString = typeof issuer === "string" ? issuer : issuer.id;
|
|
636
643
|
const listToUpdate = StatusList4.decompressStatusList(args.encodedList, bitsPerStatus ?? DEFAULT_BITS_PER_STATUS);
|
|
637
644
|
const index = typeof args.statusListIndex === "number" ? args.statusListIndex : parseInt(args.statusListIndex);
|
|
638
|
-
listToUpdate.setStatus(index, args.value
|
|
645
|
+
listToUpdate.setStatus(index, args.value);
|
|
639
646
|
const { statusListCredential, encodedList } = await this.createSignedStatusList(proofFormat ?? DEFAULT_PROOF_FORMAT2, context, listToUpdate, issuerString, id, expiresAt, keyRef);
|
|
640
647
|
return {
|
|
641
648
|
encodedList,
|
|
@@ -715,10 +722,9 @@ import { StatusListType as StatusListType5 } from "@sphereon/ssi-types";
|
|
|
715
722
|
|
|
716
723
|
// src/impl/BitstringStatusListImplementation.ts
|
|
717
724
|
import { CredentialMapper as CredentialMapper3, DocumentFormat as DocumentFormat3, StatusListType as StatusListType4 } from "@sphereon/ssi-types";
|
|
718
|
-
import {
|
|
725
|
+
import { BitstreamStatusList, createStatusListCredential } from "@4sure-tech/vc-bitstring-status-lists";
|
|
719
726
|
var DEFAULT_LIST_LENGTH3 = 131072;
|
|
720
727
|
var DEFAULT_PROOF_FORMAT3 = "lds";
|
|
721
|
-
var DEFAULT_STATUS_SIZE = 1;
|
|
722
728
|
var DEFAULT_STATUS_PURPOSE = "revocation";
|
|
723
729
|
var BitstringStatusListImplementation = class {
|
|
724
730
|
static {
|
|
@@ -734,26 +740,28 @@ var BitstringStatusListImplementation = class {
|
|
|
734
740
|
const veramoProofFormat = proofFormat;
|
|
735
741
|
const { issuer, id } = args;
|
|
736
742
|
const correlationId = getAssertedValue("correlationId", args.correlationId);
|
|
737
|
-
const { statusPurpose,
|
|
738
|
-
const list = await createList({
|
|
739
|
-
length
|
|
740
|
-
});
|
|
741
|
-
const encodedList = await list.encode();
|
|
743
|
+
const { statusPurpose, bitsPerStatus, validFrom, validUntil, ttl } = args.bitstringStatusList;
|
|
742
744
|
const statusListCredential = await this.createVerifiableCredential({
|
|
743
745
|
...args,
|
|
744
|
-
encodedList,
|
|
745
746
|
proofFormat: veramoProofFormat,
|
|
746
747
|
statusPurpose: statusPurpose ?? DEFAULT_STATUS_PURPOSE,
|
|
747
|
-
|
|
748
|
-
|
|
748
|
+
validFrom,
|
|
749
|
+
validUntil,
|
|
749
750
|
ttl
|
|
750
751
|
}, context);
|
|
751
752
|
return {
|
|
752
|
-
encodedList,
|
|
753
|
+
encodedList: statusListCredential.credentialSubject.encodedList,
|
|
753
754
|
statusListCredential,
|
|
754
755
|
bitstringStatusList: {
|
|
755
756
|
statusPurpose: statusPurpose ?? DEFAULT_STATUS_PURPOSE,
|
|
756
|
-
|
|
757
|
+
...statusListCredential.validFrom && {
|
|
758
|
+
validFrom: new Date(statusListCredential.validFrom)
|
|
759
|
+
},
|
|
760
|
+
...statusListCredential.validUntil && {
|
|
761
|
+
validUntil: new Date(statusListCredential.validUntil)
|
|
762
|
+
},
|
|
763
|
+
ttl,
|
|
764
|
+
bitsPerStatus
|
|
757
765
|
},
|
|
758
766
|
length,
|
|
759
767
|
type: StatusListType4.BitstringStatusList,
|
|
@@ -765,17 +773,20 @@ var BitstringStatusListImplementation = class {
|
|
|
765
773
|
};
|
|
766
774
|
}
|
|
767
775
|
async updateStatusListIndex(args, context) {
|
|
776
|
+
if (!args.bitsPerStatus || args.bitsPerStatus < 1) {
|
|
777
|
+
return Promise.reject("bitsPerStatus must be set for bitstring status lists and must be 1 or higher. (updateStatusListIndex)");
|
|
778
|
+
}
|
|
768
779
|
const credential = args.statusListCredential;
|
|
769
780
|
const uniform = CredentialMapper3.toUniformCredential(credential);
|
|
770
781
|
const { issuer, credentialSubject } = uniform;
|
|
771
782
|
const id = getAssertedValue("id", uniform.id);
|
|
772
783
|
const origEncodedList = getAssertedProperty("encodedList", credentialSubject);
|
|
773
784
|
const index = typeof args.statusListIndex === "number" ? args.statusListIndex : parseInt(args.statusListIndex);
|
|
774
|
-
const statusList = await
|
|
775
|
-
encodedList: origEncodedList
|
|
785
|
+
const statusList = await BitstreamStatusList.decode({
|
|
786
|
+
encodedList: origEncodedList,
|
|
787
|
+
statusSize: args.bitsPerStatus
|
|
776
788
|
});
|
|
777
|
-
statusList.setStatus(index, args.value
|
|
778
|
-
const encodedList = await statusList.encode();
|
|
789
|
+
statusList.setStatus(index, args.value);
|
|
779
790
|
const proofFormat = CredentialMapper3.detectDocumentType(credential) === DocumentFormat3.JWT ? "jwt" : "lds";
|
|
780
791
|
const credSubject = Array.isArray(credentialSubject) ? credentialSubject[0] : credentialSubject;
|
|
781
792
|
const statusPurpose = getAssertedProperty("statusPurpose", credSubject);
|
|
@@ -786,7 +797,7 @@ var BitstringStatusListImplementation = class {
|
|
|
786
797
|
...args,
|
|
787
798
|
id,
|
|
788
799
|
issuer,
|
|
789
|
-
|
|
800
|
+
statusList,
|
|
790
801
|
proofFormat,
|
|
791
802
|
statusPurpose,
|
|
792
803
|
ttl,
|
|
@@ -795,14 +806,19 @@ var BitstringStatusListImplementation = class {
|
|
|
795
806
|
}, context);
|
|
796
807
|
return {
|
|
797
808
|
statusListCredential: updatedCredential,
|
|
798
|
-
encodedList,
|
|
809
|
+
encodedList: updatedCredential.credentialSubject.encodedList,
|
|
799
810
|
bitstringStatusList: {
|
|
800
811
|
statusPurpose,
|
|
801
|
-
validFrom
|
|
802
|
-
|
|
812
|
+
...updatedCredential.validFrom && {
|
|
813
|
+
validFrom: new Date(updatedCredential.validFrom)
|
|
814
|
+
},
|
|
815
|
+
...updatedCredential.validUntil && {
|
|
816
|
+
validUntil: new Date(updatedCredential.validUntil)
|
|
817
|
+
},
|
|
818
|
+
bitsPerStatus: args.bitsPerStatus,
|
|
803
819
|
ttl
|
|
804
820
|
},
|
|
805
|
-
length: statusList.
|
|
821
|
+
length: statusList.getLength(),
|
|
806
822
|
type: StatusListType4.BitstringStatusList,
|
|
807
823
|
proofFormat,
|
|
808
824
|
id,
|
|
@@ -814,26 +830,27 @@ var BitstringStatusListImplementation = class {
|
|
|
814
830
|
if (!args.bitstringStatusList) {
|
|
815
831
|
throw new Error("bitstringStatusList options required for type BitstringStatusList");
|
|
816
832
|
}
|
|
833
|
+
if (args.bitstringStatusList.bitsPerStatus < 1) {
|
|
834
|
+
return Promise.reject("bitsPerStatus must be set for bitstring status lists and must be 1 or higher. (updateStatusListFromEncodedList)");
|
|
835
|
+
}
|
|
836
|
+
const { statusPurpose, bitsPerStatus, ttl, validFrom, validUntil } = args.bitstringStatusList;
|
|
817
837
|
const proofFormat = args?.proofFormat ?? DEFAULT_PROOF_FORMAT3;
|
|
818
838
|
assertValidProofType(StatusListType4.BitstringStatusList, proofFormat);
|
|
819
839
|
const veramoProofFormat = proofFormat;
|
|
820
840
|
const { issuer, id } = getAssertedValues(args);
|
|
821
|
-
const statusList = await
|
|
822
|
-
encodedList: args.encodedList
|
|
841
|
+
const statusList = await BitstreamStatusList.decode({
|
|
842
|
+
encodedList: args.encodedList,
|
|
843
|
+
statusSize: bitsPerStatus
|
|
823
844
|
});
|
|
824
845
|
const index = typeof args.statusListIndex === "number" ? args.statusListIndex : parseInt(args.statusListIndex);
|
|
825
846
|
statusList.setStatus(index, args.value);
|
|
826
|
-
const newEncodedList = await statusList.encode();
|
|
827
|
-
const { statusPurpose, statusSize, statusMessage, ttl, validFrom, validUntil } = args.bitstringStatusList;
|
|
828
847
|
const credential = await this.createVerifiableCredential({
|
|
829
848
|
id,
|
|
830
849
|
issuer,
|
|
831
|
-
|
|
850
|
+
statusList,
|
|
832
851
|
proofFormat: veramoProofFormat,
|
|
833
852
|
keyRef: args.keyRef,
|
|
834
853
|
statusPurpose,
|
|
835
|
-
statusSize,
|
|
836
|
-
statusMessage,
|
|
837
854
|
validFrom,
|
|
838
855
|
validUntil,
|
|
839
856
|
ttl
|
|
@@ -841,14 +858,19 @@ var BitstringStatusListImplementation = class {
|
|
|
841
858
|
return {
|
|
842
859
|
type: StatusListType4.BitstringStatusList,
|
|
843
860
|
statusListCredential: credential,
|
|
844
|
-
encodedList:
|
|
861
|
+
encodedList: credential.credentialSubject.encodedList,
|
|
845
862
|
bitstringStatusList: {
|
|
846
863
|
statusPurpose,
|
|
847
|
-
|
|
848
|
-
|
|
864
|
+
bitsPerStatus,
|
|
865
|
+
...credential.validFrom && {
|
|
866
|
+
validFrom: new Date(credential.validFrom)
|
|
867
|
+
},
|
|
868
|
+
...credential.validUntil && {
|
|
869
|
+
validUntil: new Date(credential.validUntil)
|
|
870
|
+
},
|
|
849
871
|
ttl
|
|
850
872
|
},
|
|
851
|
-
length: statusList.
|
|
873
|
+
length: statusList.getLength(),
|
|
852
874
|
proofFormat: args.proofFormat ?? "lds",
|
|
853
875
|
id,
|
|
854
876
|
issuer,
|
|
@@ -856,30 +878,28 @@ var BitstringStatusListImplementation = class {
|
|
|
856
878
|
};
|
|
857
879
|
}
|
|
858
880
|
async checkStatusIndex(args) {
|
|
881
|
+
if (!args.bitsPerStatus || args.bitsPerStatus < 1) {
|
|
882
|
+
return Promise.reject("bitsPerStatus must be set for bitstring status lists and must be 1 or higher. (checkStatusIndex)");
|
|
883
|
+
}
|
|
859
884
|
const uniform = CredentialMapper3.toUniformCredential(args.statusListCredential);
|
|
860
885
|
const { credentialSubject } = uniform;
|
|
861
886
|
const encodedList = getAssertedProperty("encodedList", credentialSubject);
|
|
862
|
-
const
|
|
863
|
-
const
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
const statusMessage = messageList.find((statMsg) => statMsg.status === hexIndex);
|
|
867
|
-
const statusList = await decodeList({
|
|
868
|
-
encodedList
|
|
887
|
+
const statusSize = args.bitsPerStatus;
|
|
888
|
+
const statusList = await BitstreamStatusList.decode({
|
|
889
|
+
encodedList,
|
|
890
|
+
statusSize
|
|
869
891
|
});
|
|
870
|
-
|
|
871
|
-
|
|
892
|
+
const numIndex = typeof args.statusListIndex === "number" ? args.statusListIndex : parseInt(args.statusListIndex);
|
|
893
|
+
if (statusList.getLength() <= numIndex) {
|
|
894
|
+
throw new Error(`Status list index out of bounds, has ${statusList.getLength()} entries, requested ${numIndex}`);
|
|
872
895
|
}
|
|
873
|
-
|
|
874
|
-
return {
|
|
875
|
-
index: numIndex,
|
|
876
|
-
status: hexIndex,
|
|
877
|
-
message: statusMessage?.message,
|
|
878
|
-
set: value
|
|
879
|
-
};
|
|
896
|
+
return statusList.getStatus(numIndex);
|
|
880
897
|
}
|
|
881
898
|
async toStatusListDetails(args) {
|
|
882
|
-
const { statusListPayload } = args;
|
|
899
|
+
const { statusListPayload, bitsPerStatus } = args;
|
|
900
|
+
if (!bitsPerStatus || bitsPerStatus < 1) {
|
|
901
|
+
return Promise.reject("bitsPerStatus must be set for bitstring status lists and must be 1 or higher. (toStatusListDetails)");
|
|
902
|
+
}
|
|
883
903
|
const uniform = CredentialMapper3.toUniformCredential(statusListPayload);
|
|
884
904
|
const { issuer, credentialSubject } = uniform;
|
|
885
905
|
const id = getAssertedValue("id", uniform.id);
|
|
@@ -890,20 +910,19 @@ var BitstringStatusListImplementation = class {
|
|
|
890
910
|
const validFrom = uniform.validFrom ? new Date(uniform.validFrom) : void 0;
|
|
891
911
|
const validUntil = uniform.validUntil ? new Date(uniform.validUntil) : void 0;
|
|
892
912
|
const ttl = credSubject.ttl;
|
|
893
|
-
const
|
|
894
|
-
encodedList
|
|
895
|
-
});
|
|
913
|
+
const statuslistLength = BitstreamStatusList.getStatusListLength(encodedList, bitsPerStatus);
|
|
896
914
|
return {
|
|
897
915
|
id,
|
|
898
916
|
encodedList,
|
|
899
917
|
issuer,
|
|
900
918
|
type: StatusListType4.BitstringStatusList,
|
|
901
919
|
proofFormat,
|
|
902
|
-
length:
|
|
920
|
+
length: statuslistLength,
|
|
903
921
|
statusListCredential: statusListPayload,
|
|
904
922
|
statuslistContentType: this.buildContentType(proofFormat),
|
|
905
923
|
bitstringStatusList: {
|
|
906
924
|
statusPurpose,
|
|
925
|
+
bitsPerStatus,
|
|
907
926
|
validFrom,
|
|
908
927
|
validUntil,
|
|
909
928
|
ttl
|
|
@@ -922,42 +941,9 @@ var BitstringStatusListImplementation = class {
|
|
|
922
941
|
vmRelationship: "assertionMethod",
|
|
923
942
|
offlineWhenNoDIDRegistered: true
|
|
924
943
|
});
|
|
925
|
-
const
|
|
926
|
-
id: args.id,
|
|
927
|
-
type: "BitstringStatusList",
|
|
928
|
-
statusPurpose: args.statusPurpose,
|
|
929
|
-
encodedList: args.encodedList
|
|
930
|
-
};
|
|
931
|
-
if (args.statusSize && args.statusSize > 1) {
|
|
932
|
-
credentialSubject.statusSize = args.statusSize;
|
|
933
|
-
}
|
|
934
|
-
if (args.statusMessage) {
|
|
935
|
-
credentialSubject.statusMessage = args.statusMessage;
|
|
936
|
-
}
|
|
937
|
-
if (args.validFrom) {
|
|
938
|
-
credentialSubject.validFrom = args.validFrom;
|
|
939
|
-
}
|
|
940
|
-
if (args.validUntil) {
|
|
941
|
-
credentialSubject.validUntil = args.validUntil;
|
|
942
|
-
}
|
|
943
|
-
if (args.ttl) {
|
|
944
|
-
credentialSubject.ttl = args.ttl;
|
|
945
|
-
}
|
|
946
|
-
const credential = {
|
|
947
|
-
"@context": [
|
|
948
|
-
"https://www.w3.org/2018/credentials/v1",
|
|
949
|
-
"https://www.w3.org/ns/credentials/status/v1"
|
|
950
|
-
],
|
|
951
|
-
id: args.id,
|
|
952
|
-
issuer: args.issuer,
|
|
953
|
-
type: [
|
|
954
|
-
"VerifiableCredential",
|
|
955
|
-
"BitstringStatusListCredential"
|
|
956
|
-
],
|
|
957
|
-
credentialSubject
|
|
958
|
-
};
|
|
944
|
+
const unsignedCredential = await createStatusListCredential(args);
|
|
959
945
|
const verifiableCredential = await context.agent.createVerifiableCredential({
|
|
960
|
-
credential,
|
|
946
|
+
credential: unsignedCredential,
|
|
961
947
|
keyRef: args.keyRef ?? identifier.kmsKeyRef,
|
|
962
948
|
proofFormat: args.proofFormat,
|
|
963
949
|
fetchRemoteContexts: true
|
|
@@ -1125,8 +1111,8 @@ async function updateStatusIndexFromStatusListCredential(args, context) {
|
|
|
1125
1111
|
return implementation.updateStatusListIndex(args, context);
|
|
1126
1112
|
}
|
|
1127
1113
|
__name(updateStatusIndexFromStatusListCredential, "updateStatusIndexFromStatusListCredential");
|
|
1128
|
-
async function statusListCredentialToDetails(
|
|
1129
|
-
const credential = getAssertedValue("statusListCredential",
|
|
1114
|
+
async function statusListCredentialToDetails({ correlationId, driverType, statusListCredential, bitsPerStatus }) {
|
|
1115
|
+
const credential = getAssertedValue("statusListCredential", statusListCredential);
|
|
1130
1116
|
let statusListType;
|
|
1131
1117
|
const documentFormat = CredentialMapper4.detectDocumentType(credential);
|
|
1132
1118
|
if (documentFormat === DocumentFormat4.JWT) {
|
|
@@ -1149,8 +1135,9 @@ async function statusListCredentialToDetails(args) {
|
|
|
1149
1135
|
const implementation = getStatusListImplementation(statusListType);
|
|
1150
1136
|
return await implementation.toStatusListDetails({
|
|
1151
1137
|
statusListPayload: credential,
|
|
1152
|
-
correlationId
|
|
1153
|
-
driverType
|
|
1138
|
+
correlationId,
|
|
1139
|
+
driverType,
|
|
1140
|
+
bitsPerStatus
|
|
1154
1141
|
});
|
|
1155
1142
|
}
|
|
1156
1143
|
__name(statusListCredentialToDetails, "statusListCredentialToDetails");
|