@sphereon/ssi-sdk.vc-status-list 0.33.1-next.73 → 0.34.1-feature.SSISDK.17.bitstring.sl.2
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 +287 -17
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +53 -7
- package/dist/index.d.ts +53 -7
- package/dist/index.js +288 -18
- package/dist/index.js.map +1 -1
- package/package.json +9 -7
- package/src/functions.ts +7 -6
- package/src/impl/BitstringStatusListImplementation.ts +334 -0
- package/src/impl/IStatusList.ts +3 -2
- package/src/impl/OAuthStatusList.ts +8 -4
- package/src/impl/StatusList2021.ts +2 -2
- package/src/impl/StatusListFactory.ts +2 -0
- package/src/types/BitstringStatusList.ts +42 -0
- package/src/types/index.ts +56 -3
- package/src/utils.ts +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { IIdentifierResolution } from '@sphereon/ssi-sdk-ext.identifier-resolution';
|
|
2
|
-
import { StatusListIndexingDirection, StatusPurpose2021, StatusListType, IIssuer, CredentialProofFormat, StatusListDriverType, StatusListCredential, StatusListCredentialIdMode, ICredentialStatus, OrPromise, ICredential, IVerifiableCredential } from '@sphereon/ssi-types';
|
|
2
|
+
import { StatusListIndexingDirection, StatusPurpose2021, BitstringStatusPurpose, 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';
|
|
@@ -16,6 +16,18 @@ declare enum Status2021 {
|
|
|
16
16
|
Valid = 0,
|
|
17
17
|
Invalid = 1
|
|
18
18
|
}
|
|
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
|
+
};
|
|
19
31
|
type StatusList2021Args = {
|
|
20
32
|
indexingDirection: StatusListIndexingDirection;
|
|
21
33
|
statusPurpose?: StatusPurpose2021;
|
|
@@ -24,6 +36,14 @@ type OAuthStatusListArgs = {
|
|
|
24
36
|
bitsPerStatus?: BitsPerStatus;
|
|
25
37
|
expiresAt?: Date;
|
|
26
38
|
};
|
|
39
|
+
type BitstringStatusListArgs = {
|
|
40
|
+
statusPurpose: BitstringStatusPurpose;
|
|
41
|
+
statusSize?: number;
|
|
42
|
+
statusMessage?: Array<BitstringStatus>;
|
|
43
|
+
ttl?: number;
|
|
44
|
+
validFrom?: Date;
|
|
45
|
+
validUntil?: Date;
|
|
46
|
+
};
|
|
27
47
|
type BaseCreateNewStatusListArgs = {
|
|
28
48
|
type: StatusListType;
|
|
29
49
|
id: string;
|
|
@@ -43,6 +63,14 @@ type UpdateOAuthStatusListArgs = {
|
|
|
43
63
|
bitsPerStatus: BitsPerStatus;
|
|
44
64
|
expiresAt?: Date;
|
|
45
65
|
};
|
|
66
|
+
type UpdateBitstringStatusListArgs = {
|
|
67
|
+
statusPurpose: BitstringStatusPurpose;
|
|
68
|
+
statusSize?: number;
|
|
69
|
+
statusMessage?: Array<BitstringStatus>;
|
|
70
|
+
validFrom?: Date;
|
|
71
|
+
validUntil?: Date;
|
|
72
|
+
ttl?: number;
|
|
73
|
+
};
|
|
46
74
|
interface UpdateStatusListFromEncodedListArgs {
|
|
47
75
|
type?: StatusListType;
|
|
48
76
|
statusListIndex: number | string;
|
|
@@ -55,12 +83,13 @@ interface UpdateStatusListFromEncodedListArgs {
|
|
|
55
83
|
id: string;
|
|
56
84
|
statusList2021?: UpdateStatusList2021Args;
|
|
57
85
|
oauthStatusList?: UpdateOAuthStatusListArgs;
|
|
86
|
+
bitstringStatusList?: UpdateBitstringStatusListArgs;
|
|
58
87
|
}
|
|
59
88
|
interface UpdateStatusListFromStatusListCredentialArgs {
|
|
60
89
|
statusListCredential: StatusListCredential;
|
|
61
90
|
keyRef?: string;
|
|
62
91
|
statusListIndex: number | string;
|
|
63
|
-
value: number | Status2021 | StatusOAuth;
|
|
92
|
+
value: number | Status2021 | StatusOAuth | BitstringStatus;
|
|
64
93
|
}
|
|
65
94
|
interface StatusListResult {
|
|
66
95
|
encodedList: string;
|
|
@@ -73,6 +102,7 @@ interface StatusListResult {
|
|
|
73
102
|
issuer: string | IIssuer;
|
|
74
103
|
statusList2021?: StatusList2021Details;
|
|
75
104
|
oauthStatusList?: OAuthStatusDetails;
|
|
105
|
+
bitstringStatusList?: BitstringStatusDetails;
|
|
76
106
|
correlationId?: string;
|
|
77
107
|
driverType?: StatusListDriverType;
|
|
78
108
|
credentialIdMode?: StatusListCredentialIdMode;
|
|
@@ -85,6 +115,12 @@ interface OAuthStatusDetails {
|
|
|
85
115
|
bitsPerStatus?: BitsPerStatus;
|
|
86
116
|
expiresAt?: Date;
|
|
87
117
|
}
|
|
118
|
+
interface BitstringStatusDetails {
|
|
119
|
+
statusPurpose: BitstringStatusPurpose;
|
|
120
|
+
validFrom?: Date;
|
|
121
|
+
validUntil?: Date;
|
|
122
|
+
ttl?: number;
|
|
123
|
+
}
|
|
88
124
|
interface StatusList2021EntryCredentialStatus extends ICredentialStatus {
|
|
89
125
|
type: 'StatusList2021Entry';
|
|
90
126
|
statusPurpose: StatusPurpose2021;
|
|
@@ -98,6 +134,15 @@ interface StatusListOAuthEntryCredentialStatus extends ICredentialStatus {
|
|
|
98
134
|
statusListCredential: string;
|
|
99
135
|
expiresAt?: Date;
|
|
100
136
|
}
|
|
137
|
+
interface BitstringStatusListEntryCredentialStatus extends ICredentialStatus {
|
|
138
|
+
type: 'BitstringStatusListEntry';
|
|
139
|
+
statusPurpose: BitstringStatusPurpose | BitstringStatusPurpose[];
|
|
140
|
+
statusListIndex: string;
|
|
141
|
+
statusListCredential: string;
|
|
142
|
+
statusSize?: number;
|
|
143
|
+
statusMessage?: Array<BitstringStatus>;
|
|
144
|
+
statusReference?: string | string[];
|
|
145
|
+
}
|
|
101
146
|
interface StatusList2021ToVerifiableCredentialArgs {
|
|
102
147
|
issuer: string | IIssuer;
|
|
103
148
|
id: string;
|
|
@@ -116,11 +161,12 @@ interface CreateStatusListArgs {
|
|
|
116
161
|
length?: number;
|
|
117
162
|
statusList2021?: StatusList2021Args;
|
|
118
163
|
oauthStatusList?: OAuthStatusListArgs;
|
|
164
|
+
bitstringStatusList?: BitstringStatusListArgs;
|
|
119
165
|
}
|
|
120
166
|
interface UpdateStatusListIndexArgs {
|
|
121
167
|
statusListCredential: StatusListCredential;
|
|
122
168
|
statusListIndex: number | string;
|
|
123
|
-
value: number | Status2021 | StatusOAuth;
|
|
169
|
+
value: number | Status2021 | StatusOAuth | BitstringStatus;
|
|
124
170
|
keyRef?: string;
|
|
125
171
|
expiresAt?: Date;
|
|
126
172
|
}
|
|
@@ -254,14 +300,14 @@ declare function simpleCheckStatusFromStatusListUrl(args: {
|
|
|
254
300
|
type?: StatusListType | 'StatusList2021Entry';
|
|
255
301
|
id?: string;
|
|
256
302
|
statusListIndex: string;
|
|
257
|
-
}): Promise<number | Status2021 | StatusOAuth>;
|
|
303
|
+
}): Promise<number | Status2021 | StatusOAuth | BitstringStatus>;
|
|
258
304
|
declare function checkStatusIndexFromStatusListCredential(args: {
|
|
259
305
|
statusListCredential: StatusListCredential;
|
|
260
306
|
statusPurpose?: StatusPurpose2021;
|
|
261
|
-
type?: StatusListType | 'StatusList2021Entry';
|
|
307
|
+
type?: StatusListType | 'StatusList2021Entry' | 'BitstringStatusListEntry';
|
|
262
308
|
id?: string;
|
|
263
309
|
statusListIndex: string | number;
|
|
264
|
-
}): Promise<number | Status2021 | StatusOAuth>;
|
|
310
|
+
}): Promise<number | Status2021 | StatusOAuth | BitstringStatus>;
|
|
265
311
|
declare function createNewStatusList(args: CreateNewStatusListFuncArgs, context: IAgentContext<(ICredentialPlugin | any) & IIdentifierResolution>): Promise<StatusListResult>;
|
|
266
312
|
declare function updateStatusIndexFromStatusListCredential(args: UpdateStatusListIndexArgs, context: IAgentContext<ICredentialPlugin & IIdentifierResolution>): Promise<StatusListResult>;
|
|
267
313
|
declare function statusListCredentialToDetails(args: {
|
|
@@ -272,4 +318,4 @@ declare function statusListCredentialToDetails(args: {
|
|
|
272
318
|
declare function updateStatusListIndexFromEncodedList(args: UpdateStatusListFromEncodedListArgs, context: IAgentContext<ICredentialPlugin & IIdentifierResolution>): Promise<StatusListResult>;
|
|
273
319
|
declare function statusList2021ToVerifiableCredential(args: StatusList2021ToVerifiableCredentialArgs, context: IAgentContext<ICredentialPlugin & IIdentifierResolution>): Promise<StatusListCredential>;
|
|
274
320
|
|
|
275
|
-
export { type BaseCreateNewStatusListArgs, 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 UpdateOAuthStatusListArgs, type UpdateStatusList2021Args, type UpdateStatusListFromEncodedListArgs, type UpdateStatusListFromStatusListCredentialArgs, type UpdateStatusListIndexArgs, checkStatusForCredential, checkStatusIndexFromStatusListCredential, createNewStatusList, fetchStatusListCredential, simpleCheckStatusFromStatusListUrl, statusList2021ToVerifiableCredential, statusListCredentialToDetails, statusPluginStatusFunction, updateStatusIndexFromStatusListCredential, updateStatusListIndexFromEncodedList, vcLibCheckStatusFunction };
|
|
321
|
+
export { type BaseCreateNewStatusListArgs, type BitstringStatus, type BitstringStatusListArgs, type BitstringStatusListEntryCredentialStatus, type BitstringStatusResult, 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
|
@@ -15,7 +15,7 @@ var Status2021 = /* @__PURE__ */ function(Status20212) {
|
|
|
15
15
|
}({});
|
|
16
16
|
|
|
17
17
|
// src/functions.ts
|
|
18
|
-
import { CredentialMapper as
|
|
18
|
+
import { CredentialMapper as CredentialMapper4, DocumentFormat as DocumentFormat4, StatusListType as StatusListType6 } from "@sphereon/ssi-types";
|
|
19
19
|
import { checkStatus } from "@sphereon/vc-status-list";
|
|
20
20
|
|
|
21
21
|
// src/utils.ts
|
|
@@ -62,8 +62,7 @@ var ValidProofTypeMap = /* @__PURE__ */ new Map([
|
|
|
62
62
|
StatusListType.StatusList2021,
|
|
63
63
|
[
|
|
64
64
|
"jwt",
|
|
65
|
-
"lds"
|
|
66
|
-
"EthereumEip712Signature2021"
|
|
65
|
+
"lds"
|
|
67
66
|
]
|
|
68
67
|
],
|
|
69
68
|
[
|
|
@@ -606,6 +605,9 @@ var OAuthStatusListImplementation = class {
|
|
|
606
605
|
if (index < 0 || index >= statusList.statusList.length) {
|
|
607
606
|
throw new Error("Status list index out of bounds");
|
|
608
607
|
}
|
|
608
|
+
if (typeof value !== "number") {
|
|
609
|
+
throw new Error("Status list values should be of type number");
|
|
610
|
+
}
|
|
609
611
|
statusList.setStatus(index, value);
|
|
610
612
|
const { statusListCredential: signedCredential, encodedList } = await this.createSignedStatusList(proofFormat, context, statusList, issuer, id, expiresAt, keyRef);
|
|
611
613
|
return {
|
|
@@ -662,7 +664,7 @@ var OAuthStatusListImplementation = class {
|
|
|
662
664
|
const { statusList } = proofFormat === "jwt" ? decodeStatusListJWT(statusListCredential) : decodeStatusListCWT(statusListCredential);
|
|
663
665
|
const index = typeof statusListIndex === "number" ? statusListIndex : parseInt(statusListIndex);
|
|
664
666
|
if (index < 0 || index >= statusList.statusList.length) {
|
|
665
|
-
throw new Error(
|
|
667
|
+
throw new Error(`Status list index out of bounds, has ${statusList.statusList.length} items, requested ${index}`);
|
|
666
668
|
}
|
|
667
669
|
return statusList.getStatus(index);
|
|
668
670
|
}
|
|
@@ -709,7 +711,274 @@ var OAuthStatusListImplementation = class {
|
|
|
709
711
|
};
|
|
710
712
|
|
|
711
713
|
// src/impl/StatusListFactory.ts
|
|
712
|
-
import { StatusListType as
|
|
714
|
+
import { StatusListType as StatusListType5 } from "@sphereon/ssi-types";
|
|
715
|
+
|
|
716
|
+
// src/impl/BitstringStatusListImplementation.ts
|
|
717
|
+
import { CredentialMapper as CredentialMapper3, DocumentFormat as DocumentFormat3, StatusListType as StatusListType4 } from "@sphereon/ssi-types";
|
|
718
|
+
import { createList, decodeList } from "@digitalbazaar/vc-bitstring-status-list";
|
|
719
|
+
var DEFAULT_LIST_LENGTH3 = 131072;
|
|
720
|
+
var DEFAULT_PROOF_FORMAT3 = "lds";
|
|
721
|
+
var DEFAULT_STATUS_SIZE = 1;
|
|
722
|
+
var DEFAULT_STATUS_PURPOSE = "revocation";
|
|
723
|
+
var BitstringStatusListImplementation = class {
|
|
724
|
+
static {
|
|
725
|
+
__name(this, "BitstringStatusListImplementation");
|
|
726
|
+
}
|
|
727
|
+
async createNewStatusList(args, context) {
|
|
728
|
+
if (!args.bitstringStatusList) {
|
|
729
|
+
throw new Error("BitstringStatusList options are required for type BitstringStatusList");
|
|
730
|
+
}
|
|
731
|
+
const length = args?.length ?? DEFAULT_LIST_LENGTH3;
|
|
732
|
+
const proofFormat = args?.proofFormat ?? DEFAULT_PROOF_FORMAT3;
|
|
733
|
+
assertValidProofType(StatusListType4.BitstringStatusList, proofFormat);
|
|
734
|
+
const veramoProofFormat = proofFormat;
|
|
735
|
+
const { issuer, id } = args;
|
|
736
|
+
const correlationId = getAssertedValue("correlationId", args.correlationId);
|
|
737
|
+
const { statusPurpose, statusSize, statusMessage, ttl } = args.bitstringStatusList;
|
|
738
|
+
const list = await createList({
|
|
739
|
+
length
|
|
740
|
+
});
|
|
741
|
+
const encodedList = await list.encode();
|
|
742
|
+
const statusListCredential = await this.createVerifiableCredential({
|
|
743
|
+
...args,
|
|
744
|
+
encodedList,
|
|
745
|
+
proofFormat: veramoProofFormat,
|
|
746
|
+
statusPurpose: statusPurpose ?? DEFAULT_STATUS_PURPOSE,
|
|
747
|
+
statusSize: statusSize ?? DEFAULT_STATUS_SIZE,
|
|
748
|
+
statusMessage,
|
|
749
|
+
ttl
|
|
750
|
+
}, context);
|
|
751
|
+
return {
|
|
752
|
+
encodedList,
|
|
753
|
+
statusListCredential,
|
|
754
|
+
bitstringStatusList: {
|
|
755
|
+
statusPurpose: statusPurpose ?? DEFAULT_STATUS_PURPOSE,
|
|
756
|
+
ttl
|
|
757
|
+
},
|
|
758
|
+
length,
|
|
759
|
+
type: StatusListType4.BitstringStatusList,
|
|
760
|
+
proofFormat,
|
|
761
|
+
id,
|
|
762
|
+
correlationId,
|
|
763
|
+
issuer,
|
|
764
|
+
statuslistContentType: this.buildContentType(proofFormat)
|
|
765
|
+
};
|
|
766
|
+
}
|
|
767
|
+
async updateStatusListIndex(args, context) {
|
|
768
|
+
const credential = args.statusListCredential;
|
|
769
|
+
const uniform = CredentialMapper3.toUniformCredential(credential);
|
|
770
|
+
const { issuer, credentialSubject } = uniform;
|
|
771
|
+
const id = getAssertedValue("id", uniform.id);
|
|
772
|
+
const origEncodedList = getAssertedProperty("encodedList", credentialSubject);
|
|
773
|
+
const index = typeof args.statusListIndex === "number" ? args.statusListIndex : parseInt(args.statusListIndex);
|
|
774
|
+
const statusList = await decodeList({
|
|
775
|
+
encodedList: origEncodedList
|
|
776
|
+
});
|
|
777
|
+
statusList.setStatus(index, args.value != 0);
|
|
778
|
+
const encodedList = await statusList.encode();
|
|
779
|
+
const proofFormat = CredentialMapper3.detectDocumentType(credential) === DocumentFormat3.JWT ? "jwt" : "lds";
|
|
780
|
+
const credSubject = Array.isArray(credentialSubject) ? credentialSubject[0] : credentialSubject;
|
|
781
|
+
const statusPurpose = getAssertedProperty("statusPurpose", credSubject);
|
|
782
|
+
const validFrom = uniform.validFrom ? new Date(uniform.validFrom) : void 0;
|
|
783
|
+
const validUntil = uniform.validUntil ? new Date(uniform.validUntil) : void 0;
|
|
784
|
+
const ttl = credSubject.ttl;
|
|
785
|
+
const updatedCredential = await this.createVerifiableCredential({
|
|
786
|
+
...args,
|
|
787
|
+
id,
|
|
788
|
+
issuer,
|
|
789
|
+
encodedList,
|
|
790
|
+
proofFormat,
|
|
791
|
+
statusPurpose,
|
|
792
|
+
ttl,
|
|
793
|
+
validFrom,
|
|
794
|
+
validUntil
|
|
795
|
+
}, context);
|
|
796
|
+
return {
|
|
797
|
+
statusListCredential: updatedCredential,
|
|
798
|
+
encodedList,
|
|
799
|
+
bitstringStatusList: {
|
|
800
|
+
statusPurpose,
|
|
801
|
+
validFrom,
|
|
802
|
+
validUntil,
|
|
803
|
+
ttl
|
|
804
|
+
},
|
|
805
|
+
length: statusList.length - 1,
|
|
806
|
+
type: StatusListType4.BitstringStatusList,
|
|
807
|
+
proofFormat,
|
|
808
|
+
id,
|
|
809
|
+
issuer,
|
|
810
|
+
statuslistContentType: this.buildContentType(proofFormat)
|
|
811
|
+
};
|
|
812
|
+
}
|
|
813
|
+
async updateStatusListFromEncodedList(args, context) {
|
|
814
|
+
if (!args.bitstringStatusList) {
|
|
815
|
+
throw new Error("bitstringStatusList options required for type BitstringStatusList");
|
|
816
|
+
}
|
|
817
|
+
const proofFormat = args?.proofFormat ?? DEFAULT_PROOF_FORMAT3;
|
|
818
|
+
assertValidProofType(StatusListType4.BitstringStatusList, proofFormat);
|
|
819
|
+
const veramoProofFormat = proofFormat;
|
|
820
|
+
const { issuer, id } = getAssertedValues(args);
|
|
821
|
+
const statusList = await decodeList({
|
|
822
|
+
encodedList: args.encodedList
|
|
823
|
+
});
|
|
824
|
+
const index = typeof args.statusListIndex === "number" ? args.statusListIndex : parseInt(args.statusListIndex);
|
|
825
|
+
statusList.setStatus(index, args.value);
|
|
826
|
+
const newEncodedList = await statusList.encode();
|
|
827
|
+
const { statusPurpose, statusSize, statusMessage, ttl, validFrom, validUntil } = args.bitstringStatusList;
|
|
828
|
+
const credential = await this.createVerifiableCredential({
|
|
829
|
+
id,
|
|
830
|
+
issuer,
|
|
831
|
+
encodedList: newEncodedList,
|
|
832
|
+
proofFormat: veramoProofFormat,
|
|
833
|
+
keyRef: args.keyRef,
|
|
834
|
+
statusPurpose,
|
|
835
|
+
statusSize,
|
|
836
|
+
statusMessage,
|
|
837
|
+
validFrom,
|
|
838
|
+
validUntil,
|
|
839
|
+
ttl
|
|
840
|
+
}, context);
|
|
841
|
+
return {
|
|
842
|
+
type: StatusListType4.BitstringStatusList,
|
|
843
|
+
statusListCredential: credential,
|
|
844
|
+
encodedList: newEncodedList,
|
|
845
|
+
bitstringStatusList: {
|
|
846
|
+
statusPurpose,
|
|
847
|
+
validFrom,
|
|
848
|
+
validUntil,
|
|
849
|
+
ttl
|
|
850
|
+
},
|
|
851
|
+
length: statusList.length,
|
|
852
|
+
proofFormat: args.proofFormat ?? "lds",
|
|
853
|
+
id,
|
|
854
|
+
issuer,
|
|
855
|
+
statuslistContentType: this.buildContentType(proofFormat)
|
|
856
|
+
};
|
|
857
|
+
}
|
|
858
|
+
async checkStatusIndex(args) {
|
|
859
|
+
const uniform = CredentialMapper3.toUniformCredential(args.statusListCredential);
|
|
860
|
+
const { credentialSubject } = uniform;
|
|
861
|
+
const encodedList = getAssertedProperty("encodedList", credentialSubject);
|
|
862
|
+
const subject = Array.isArray(credentialSubject) ? credentialSubject[0] : credentialSubject;
|
|
863
|
+
const messageList = subject.statusMessage;
|
|
864
|
+
const numIndex = typeof args.statusListIndex === "number" ? args.statusListIndex : parseInt(args.statusListIndex);
|
|
865
|
+
const hexIndex = `0x${numIndex.toString(16)}`;
|
|
866
|
+
const statusMessage = messageList.find((statMsg) => statMsg.status === hexIndex);
|
|
867
|
+
const statusList = await decodeList({
|
|
868
|
+
encodedList
|
|
869
|
+
});
|
|
870
|
+
if (statusList.length <= numIndex) {
|
|
871
|
+
throw new Error(`Status list index out of bounds, has ${messageList.length} messages, requested ${numIndex}`);
|
|
872
|
+
}
|
|
873
|
+
const value = statusList.getStatus(numIndex);
|
|
874
|
+
return {
|
|
875
|
+
index: numIndex,
|
|
876
|
+
status: hexIndex,
|
|
877
|
+
message: statusMessage?.message,
|
|
878
|
+
set: value
|
|
879
|
+
};
|
|
880
|
+
}
|
|
881
|
+
async toStatusListDetails(args) {
|
|
882
|
+
const { statusListPayload } = args;
|
|
883
|
+
const uniform = CredentialMapper3.toUniformCredential(statusListPayload);
|
|
884
|
+
const { issuer, credentialSubject } = uniform;
|
|
885
|
+
const id = getAssertedValue("id", uniform.id);
|
|
886
|
+
const encodedList = getAssertedProperty("encodedList", credentialSubject);
|
|
887
|
+
const proofFormat = CredentialMapper3.detectDocumentType(statusListPayload) === DocumentFormat3.JWT ? "jwt" : "lds";
|
|
888
|
+
const credSubject = Array.isArray(credentialSubject) ? credentialSubject[0] : credentialSubject;
|
|
889
|
+
const statusPurpose = getAssertedProperty("statusPurpose", credSubject);
|
|
890
|
+
const validFrom = uniform.validFrom ? new Date(uniform.validFrom) : void 0;
|
|
891
|
+
const validUntil = uniform.validUntil ? new Date(uniform.validUntil) : void 0;
|
|
892
|
+
const ttl = credSubject.ttl;
|
|
893
|
+
const list = await decodeList({
|
|
894
|
+
encodedList
|
|
895
|
+
});
|
|
896
|
+
return {
|
|
897
|
+
id,
|
|
898
|
+
encodedList,
|
|
899
|
+
issuer,
|
|
900
|
+
type: StatusListType4.BitstringStatusList,
|
|
901
|
+
proofFormat,
|
|
902
|
+
length: list.length,
|
|
903
|
+
statusListCredential: statusListPayload,
|
|
904
|
+
statuslistContentType: this.buildContentType(proofFormat),
|
|
905
|
+
bitstringStatusList: {
|
|
906
|
+
statusPurpose,
|
|
907
|
+
validFrom,
|
|
908
|
+
validUntil,
|
|
909
|
+
ttl
|
|
910
|
+
},
|
|
911
|
+
...args.correlationId && {
|
|
912
|
+
correlationId: args.correlationId
|
|
913
|
+
},
|
|
914
|
+
...args.driverType && {
|
|
915
|
+
driverType: args.driverType
|
|
916
|
+
}
|
|
917
|
+
};
|
|
918
|
+
}
|
|
919
|
+
async createVerifiableCredential(args, context) {
|
|
920
|
+
const identifier = await context.agent.identifierManagedGet({
|
|
921
|
+
identifier: typeof args.issuer === "string" ? args.issuer : args.issuer.id,
|
|
922
|
+
vmRelationship: "assertionMethod",
|
|
923
|
+
offlineWhenNoDIDRegistered: true
|
|
924
|
+
});
|
|
925
|
+
const credentialSubject = {
|
|
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
|
+
};
|
|
959
|
+
const verifiableCredential = await context.agent.createVerifiableCredential({
|
|
960
|
+
credential,
|
|
961
|
+
keyRef: args.keyRef ?? identifier.kmsKeyRef,
|
|
962
|
+
proofFormat: args.proofFormat,
|
|
963
|
+
fetchRemoteContexts: true
|
|
964
|
+
});
|
|
965
|
+
return CredentialMapper3.toWrappedVerifiableCredential(verifiableCredential).original;
|
|
966
|
+
}
|
|
967
|
+
buildContentType(proofFormat) {
|
|
968
|
+
switch (proofFormat) {
|
|
969
|
+
case "jwt":
|
|
970
|
+
return `application/statuslist+jwt`;
|
|
971
|
+
case "cbor":
|
|
972
|
+
return `application/statuslist+cwt`;
|
|
973
|
+
case "lds":
|
|
974
|
+
return "application/statuslist+ld+json";
|
|
975
|
+
default:
|
|
976
|
+
throw Error(`Unsupported content type '${proofFormat}' for status lists`);
|
|
977
|
+
}
|
|
978
|
+
}
|
|
979
|
+
};
|
|
980
|
+
|
|
981
|
+
// src/impl/StatusListFactory.ts
|
|
713
982
|
var StatusListFactory = class _StatusListFactory {
|
|
714
983
|
static {
|
|
715
984
|
__name(this, "StatusListFactory");
|
|
@@ -718,8 +987,9 @@ var StatusListFactory = class _StatusListFactory {
|
|
|
718
987
|
implementations;
|
|
719
988
|
constructor() {
|
|
720
989
|
this.implementations = /* @__PURE__ */ new Map();
|
|
721
|
-
this.implementations.set(
|
|
722
|
-
this.implementations.set(
|
|
990
|
+
this.implementations.set(StatusListType5.StatusList2021, new StatusList2021Implementation());
|
|
991
|
+
this.implementations.set(StatusListType5.OAuthStatusList, new OAuthStatusListImplementation());
|
|
992
|
+
this.implementations.set(StatusListType5.BitstringStatusList, new BitstringStatusListImplementation());
|
|
723
993
|
}
|
|
724
994
|
static getInstance() {
|
|
725
995
|
if (!_StatusListFactory.instance) {
|
|
@@ -792,7 +1062,7 @@ __name(vcLibCheckStatusFunction, "vcLibCheckStatusFunction");
|
|
|
792
1062
|
async function checkStatusForCredential(args) {
|
|
793
1063
|
const verifyStatusListCredential = args.verifyStatusListCredential ?? true;
|
|
794
1064
|
const verifyMatchingIssuers = args.verifyMatchingIssuers ?? true;
|
|
795
|
-
const uniform =
|
|
1065
|
+
const uniform = CredentialMapper4.toUniformCredential(args.credential);
|
|
796
1066
|
if (!("credentialStatus" in uniform) || !uniform.credentialStatus) {
|
|
797
1067
|
if (args.mandatoryCredentialStatus) {
|
|
798
1068
|
const error = "No credential status object found in the Verifiable Credential and it is mandatory";
|
|
@@ -807,7 +1077,7 @@ async function checkStatusForCredential(args) {
|
|
|
807
1077
|
};
|
|
808
1078
|
}
|
|
809
1079
|
if ("credentialStatus" in uniform && uniform.credentialStatus) {
|
|
810
|
-
if (uniform.credentialStatus.type === "StatusList2021Entry") {
|
|
1080
|
+
if (uniform.credentialStatus.type === "StatusList2021Entry" || uniform.credentialStatus.type === "BitstringStatusListEntry") {
|
|
811
1081
|
return checkStatus({
|
|
812
1082
|
...args,
|
|
813
1083
|
verifyStatusListCredential,
|
|
@@ -858,19 +1128,19 @@ __name(updateStatusIndexFromStatusListCredential, "updateStatusIndexFromStatusLi
|
|
|
858
1128
|
async function statusListCredentialToDetails(args) {
|
|
859
1129
|
const credential = getAssertedValue("statusListCredential", args.statusListCredential);
|
|
860
1130
|
let statusListType;
|
|
861
|
-
const documentFormat =
|
|
862
|
-
if (documentFormat ===
|
|
1131
|
+
const documentFormat = CredentialMapper4.detectDocumentType(credential);
|
|
1132
|
+
if (documentFormat === DocumentFormat4.JWT) {
|
|
863
1133
|
const [header] = credential.split(".");
|
|
864
1134
|
const decodedHeader = JSON.parse(Buffer.from(header, "base64").toString());
|
|
865
1135
|
if (decodedHeader.typ === "statuslist+jwt") {
|
|
866
|
-
statusListType =
|
|
1136
|
+
statusListType = StatusListType6.OAuthStatusList;
|
|
867
1137
|
}
|
|
868
|
-
} else if (documentFormat ===
|
|
869
|
-
statusListType =
|
|
1138
|
+
} else if (documentFormat === DocumentFormat4.MSO_MDOC) {
|
|
1139
|
+
statusListType = StatusListType6.OAuthStatusList;
|
|
870
1140
|
}
|
|
871
1141
|
if (!statusListType) {
|
|
872
|
-
const uniform =
|
|
873
|
-
const type = uniform.type.find((t) => t.includes("StatusList2021") || t.includes("OAuth2StatusList"));
|
|
1142
|
+
const uniform = CredentialMapper4.toUniformCredential(credential);
|
|
1143
|
+
const type = uniform.type.find((t) => t.includes("StatusList2021") || t.includes("OAuth2StatusList") || t.includes("BitstringStatusList"));
|
|
874
1144
|
if (!type) {
|
|
875
1145
|
throw new Error("Invalid status list credential type");
|
|
876
1146
|
}
|
|
@@ -898,7 +1168,7 @@ async function statusList2021ToVerifiableCredential(args, context) {
|
|
|
898
1168
|
offlineWhenNoDIDRegistered: true
|
|
899
1169
|
});
|
|
900
1170
|
const proofFormat = args?.proofFormat ?? "lds";
|
|
901
|
-
assertValidProofType(
|
|
1171
|
+
assertValidProofType(StatusListType6.StatusList2021, proofFormat);
|
|
902
1172
|
const veramoProofFormat = proofFormat;
|
|
903
1173
|
const encodedList = getAssertedValue("encodedList", args.encodedList);
|
|
904
1174
|
const statusPurpose = getAssertedValue("statusPurpose", args.statusPurpose);
|
|
@@ -927,7 +1197,7 @@ async function statusList2021ToVerifiableCredential(args, context) {
|
|
|
927
1197
|
proofFormat: veramoProofFormat,
|
|
928
1198
|
fetchRemoteContexts: true
|
|
929
1199
|
});
|
|
930
|
-
return
|
|
1200
|
+
return CredentialMapper4.toWrappedVerifiableCredential(verifiableCredential).original;
|
|
931
1201
|
}
|
|
932
1202
|
__name(statusList2021ToVerifiableCredential, "statusList2021ToVerifiableCredential");
|
|
933
1203
|
export {
|