@sphereon/ssi-sdk.vc-status-list 0.34.1-feature.SSISDK.17.bitstring.sl.2 → 0.34.1-next.5
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 +17 -287
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +7 -53
- package/dist/index.d.ts +7 -53
- package/dist/index.js +18 -288
- package/dist/index.js.map +1 -1
- package/package.json +7 -9
- package/src/functions.ts +6 -7
- package/src/impl/IStatusList.ts +2 -3
- package/src/impl/OAuthStatusList.ts +4 -8
- package/src/impl/StatusList2021.ts +2 -2
- package/src/impl/StatusListFactory.ts +0 -2
- package/src/types/index.ts +3 -56
- package/src/utils.ts +1 -1
- package/src/impl/BitstringStatusListImplementation.ts +0 -334
- package/src/types/BitstringStatusList.ts +0 -42
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,
|
|
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';
|
|
@@ -16,18 +16,6 @@ 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
|
-
};
|
|
31
19
|
type StatusList2021Args = {
|
|
32
20
|
indexingDirection: StatusListIndexingDirection;
|
|
33
21
|
statusPurpose?: StatusPurpose2021;
|
|
@@ -36,14 +24,6 @@ type OAuthStatusListArgs = {
|
|
|
36
24
|
bitsPerStatus?: BitsPerStatus;
|
|
37
25
|
expiresAt?: Date;
|
|
38
26
|
};
|
|
39
|
-
type BitstringStatusListArgs = {
|
|
40
|
-
statusPurpose: BitstringStatusPurpose;
|
|
41
|
-
statusSize?: number;
|
|
42
|
-
statusMessage?: Array<BitstringStatus>;
|
|
43
|
-
ttl?: number;
|
|
44
|
-
validFrom?: Date;
|
|
45
|
-
validUntil?: Date;
|
|
46
|
-
};
|
|
47
27
|
type BaseCreateNewStatusListArgs = {
|
|
48
28
|
type: StatusListType;
|
|
49
29
|
id: string;
|
|
@@ -63,14 +43,6 @@ type UpdateOAuthStatusListArgs = {
|
|
|
63
43
|
bitsPerStatus: BitsPerStatus;
|
|
64
44
|
expiresAt?: Date;
|
|
65
45
|
};
|
|
66
|
-
type UpdateBitstringStatusListArgs = {
|
|
67
|
-
statusPurpose: BitstringStatusPurpose;
|
|
68
|
-
statusSize?: number;
|
|
69
|
-
statusMessage?: Array<BitstringStatus>;
|
|
70
|
-
validFrom?: Date;
|
|
71
|
-
validUntil?: Date;
|
|
72
|
-
ttl?: number;
|
|
73
|
-
};
|
|
74
46
|
interface UpdateStatusListFromEncodedListArgs {
|
|
75
47
|
type?: StatusListType;
|
|
76
48
|
statusListIndex: number | string;
|
|
@@ -83,13 +55,12 @@ interface UpdateStatusListFromEncodedListArgs {
|
|
|
83
55
|
id: string;
|
|
84
56
|
statusList2021?: UpdateStatusList2021Args;
|
|
85
57
|
oauthStatusList?: UpdateOAuthStatusListArgs;
|
|
86
|
-
bitstringStatusList?: UpdateBitstringStatusListArgs;
|
|
87
58
|
}
|
|
88
59
|
interface UpdateStatusListFromStatusListCredentialArgs {
|
|
89
60
|
statusListCredential: StatusListCredential;
|
|
90
61
|
keyRef?: string;
|
|
91
62
|
statusListIndex: number | string;
|
|
92
|
-
value: number | Status2021 | StatusOAuth
|
|
63
|
+
value: number | Status2021 | StatusOAuth;
|
|
93
64
|
}
|
|
94
65
|
interface StatusListResult {
|
|
95
66
|
encodedList: string;
|
|
@@ -102,7 +73,6 @@ interface StatusListResult {
|
|
|
102
73
|
issuer: string | IIssuer;
|
|
103
74
|
statusList2021?: StatusList2021Details;
|
|
104
75
|
oauthStatusList?: OAuthStatusDetails;
|
|
105
|
-
bitstringStatusList?: BitstringStatusDetails;
|
|
106
76
|
correlationId?: string;
|
|
107
77
|
driverType?: StatusListDriverType;
|
|
108
78
|
credentialIdMode?: StatusListCredentialIdMode;
|
|
@@ -115,12 +85,6 @@ interface OAuthStatusDetails {
|
|
|
115
85
|
bitsPerStatus?: BitsPerStatus;
|
|
116
86
|
expiresAt?: Date;
|
|
117
87
|
}
|
|
118
|
-
interface BitstringStatusDetails {
|
|
119
|
-
statusPurpose: BitstringStatusPurpose;
|
|
120
|
-
validFrom?: Date;
|
|
121
|
-
validUntil?: Date;
|
|
122
|
-
ttl?: number;
|
|
123
|
-
}
|
|
124
88
|
interface StatusList2021EntryCredentialStatus extends ICredentialStatus {
|
|
125
89
|
type: 'StatusList2021Entry';
|
|
126
90
|
statusPurpose: StatusPurpose2021;
|
|
@@ -134,15 +98,6 @@ interface StatusListOAuthEntryCredentialStatus extends ICredentialStatus {
|
|
|
134
98
|
statusListCredential: string;
|
|
135
99
|
expiresAt?: Date;
|
|
136
100
|
}
|
|
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
|
-
}
|
|
146
101
|
interface StatusList2021ToVerifiableCredentialArgs {
|
|
147
102
|
issuer: string | IIssuer;
|
|
148
103
|
id: string;
|
|
@@ -161,12 +116,11 @@ interface CreateStatusListArgs {
|
|
|
161
116
|
length?: number;
|
|
162
117
|
statusList2021?: StatusList2021Args;
|
|
163
118
|
oauthStatusList?: OAuthStatusListArgs;
|
|
164
|
-
bitstringStatusList?: BitstringStatusListArgs;
|
|
165
119
|
}
|
|
166
120
|
interface UpdateStatusListIndexArgs {
|
|
167
121
|
statusListCredential: StatusListCredential;
|
|
168
122
|
statusListIndex: number | string;
|
|
169
|
-
value: number | Status2021 | StatusOAuth
|
|
123
|
+
value: number | Status2021 | StatusOAuth;
|
|
170
124
|
keyRef?: string;
|
|
171
125
|
expiresAt?: Date;
|
|
172
126
|
}
|
|
@@ -300,14 +254,14 @@ declare function simpleCheckStatusFromStatusListUrl(args: {
|
|
|
300
254
|
type?: StatusListType | 'StatusList2021Entry';
|
|
301
255
|
id?: string;
|
|
302
256
|
statusListIndex: string;
|
|
303
|
-
}): Promise<number | Status2021 | StatusOAuth
|
|
257
|
+
}): Promise<number | Status2021 | StatusOAuth>;
|
|
304
258
|
declare function checkStatusIndexFromStatusListCredential(args: {
|
|
305
259
|
statusListCredential: StatusListCredential;
|
|
306
260
|
statusPurpose?: StatusPurpose2021;
|
|
307
|
-
type?: StatusListType | 'StatusList2021Entry'
|
|
261
|
+
type?: StatusListType | 'StatusList2021Entry';
|
|
308
262
|
id?: string;
|
|
309
263
|
statusListIndex: string | number;
|
|
310
|
-
}): Promise<number | Status2021 | StatusOAuth
|
|
264
|
+
}): Promise<number | Status2021 | StatusOAuth>;
|
|
311
265
|
declare function createNewStatusList(args: CreateNewStatusListFuncArgs, context: IAgentContext<(ICredentialPlugin | any) & IIdentifierResolution>): Promise<StatusListResult>;
|
|
312
266
|
declare function updateStatusIndexFromStatusListCredential(args: UpdateStatusListIndexArgs, context: IAgentContext<ICredentialPlugin & IIdentifierResolution>): Promise<StatusListResult>;
|
|
313
267
|
declare function statusListCredentialToDetails(args: {
|
|
@@ -318,4 +272,4 @@ declare function statusListCredentialToDetails(args: {
|
|
|
318
272
|
declare function updateStatusListIndexFromEncodedList(args: UpdateStatusListFromEncodedListArgs, context: IAgentContext<ICredentialPlugin & IIdentifierResolution>): Promise<StatusListResult>;
|
|
319
273
|
declare function statusList2021ToVerifiableCredential(args: StatusList2021ToVerifiableCredentialArgs, context: IAgentContext<ICredentialPlugin & IIdentifierResolution>): Promise<StatusListCredential>;
|
|
320
274
|
|
|
321
|
-
export { type BaseCreateNewStatusListArgs, type
|
|
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 };
|
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 CredentialMapper3, DocumentFormat as DocumentFormat3, StatusListType as StatusListType5 } from "@sphereon/ssi-types";
|
|
19
19
|
import { checkStatus } from "@sphereon/vc-status-list";
|
|
20
20
|
|
|
21
21
|
// src/utils.ts
|
|
@@ -62,7 +62,8 @@ var ValidProofTypeMap = /* @__PURE__ */ new Map([
|
|
|
62
62
|
StatusListType.StatusList2021,
|
|
63
63
|
[
|
|
64
64
|
"jwt",
|
|
65
|
-
"lds"
|
|
65
|
+
"lds",
|
|
66
|
+
"EthereumEip712Signature2021"
|
|
66
67
|
]
|
|
67
68
|
],
|
|
68
69
|
[
|
|
@@ -605,9 +606,6 @@ var OAuthStatusListImplementation = class {
|
|
|
605
606
|
if (index < 0 || index >= statusList.statusList.length) {
|
|
606
607
|
throw new Error("Status list index out of bounds");
|
|
607
608
|
}
|
|
608
|
-
if (typeof value !== "number") {
|
|
609
|
-
throw new Error("Status list values should be of type number");
|
|
610
|
-
}
|
|
611
609
|
statusList.setStatus(index, value);
|
|
612
610
|
const { statusListCredential: signedCredential, encodedList } = await this.createSignedStatusList(proofFormat, context, statusList, issuer, id, expiresAt, keyRef);
|
|
613
611
|
return {
|
|
@@ -664,7 +662,7 @@ var OAuthStatusListImplementation = class {
|
|
|
664
662
|
const { statusList } = proofFormat === "jwt" ? decodeStatusListJWT(statusListCredential) : decodeStatusListCWT(statusListCredential);
|
|
665
663
|
const index = typeof statusListIndex === "number" ? statusListIndex : parseInt(statusListIndex);
|
|
666
664
|
if (index < 0 || index >= statusList.statusList.length) {
|
|
667
|
-
throw new Error(
|
|
665
|
+
throw new Error("Status list index out of bounds");
|
|
668
666
|
}
|
|
669
667
|
return statusList.getStatus(index);
|
|
670
668
|
}
|
|
@@ -711,274 +709,7 @@ var OAuthStatusListImplementation = class {
|
|
|
711
709
|
};
|
|
712
710
|
|
|
713
711
|
// src/impl/StatusListFactory.ts
|
|
714
|
-
import { StatusListType as
|
|
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
|
|
712
|
+
import { StatusListType as StatusListType4 } from "@sphereon/ssi-types";
|
|
982
713
|
var StatusListFactory = class _StatusListFactory {
|
|
983
714
|
static {
|
|
984
715
|
__name(this, "StatusListFactory");
|
|
@@ -987,9 +718,8 @@ var StatusListFactory = class _StatusListFactory {
|
|
|
987
718
|
implementations;
|
|
988
719
|
constructor() {
|
|
989
720
|
this.implementations = /* @__PURE__ */ new Map();
|
|
990
|
-
this.implementations.set(
|
|
991
|
-
this.implementations.set(
|
|
992
|
-
this.implementations.set(StatusListType5.BitstringStatusList, new BitstringStatusListImplementation());
|
|
721
|
+
this.implementations.set(StatusListType4.StatusList2021, new StatusList2021Implementation());
|
|
722
|
+
this.implementations.set(StatusListType4.OAuthStatusList, new OAuthStatusListImplementation());
|
|
993
723
|
}
|
|
994
724
|
static getInstance() {
|
|
995
725
|
if (!_StatusListFactory.instance) {
|
|
@@ -1062,7 +792,7 @@ __name(vcLibCheckStatusFunction, "vcLibCheckStatusFunction");
|
|
|
1062
792
|
async function checkStatusForCredential(args) {
|
|
1063
793
|
const verifyStatusListCredential = args.verifyStatusListCredential ?? true;
|
|
1064
794
|
const verifyMatchingIssuers = args.verifyMatchingIssuers ?? true;
|
|
1065
|
-
const uniform =
|
|
795
|
+
const uniform = CredentialMapper3.toUniformCredential(args.credential);
|
|
1066
796
|
if (!("credentialStatus" in uniform) || !uniform.credentialStatus) {
|
|
1067
797
|
if (args.mandatoryCredentialStatus) {
|
|
1068
798
|
const error = "No credential status object found in the Verifiable Credential and it is mandatory";
|
|
@@ -1077,7 +807,7 @@ async function checkStatusForCredential(args) {
|
|
|
1077
807
|
};
|
|
1078
808
|
}
|
|
1079
809
|
if ("credentialStatus" in uniform && uniform.credentialStatus) {
|
|
1080
|
-
if (uniform.credentialStatus.type === "StatusList2021Entry"
|
|
810
|
+
if (uniform.credentialStatus.type === "StatusList2021Entry") {
|
|
1081
811
|
return checkStatus({
|
|
1082
812
|
...args,
|
|
1083
813
|
verifyStatusListCredential,
|
|
@@ -1128,19 +858,19 @@ __name(updateStatusIndexFromStatusListCredential, "updateStatusIndexFromStatusLi
|
|
|
1128
858
|
async function statusListCredentialToDetails(args) {
|
|
1129
859
|
const credential = getAssertedValue("statusListCredential", args.statusListCredential);
|
|
1130
860
|
let statusListType;
|
|
1131
|
-
const documentFormat =
|
|
1132
|
-
if (documentFormat ===
|
|
861
|
+
const documentFormat = CredentialMapper3.detectDocumentType(credential);
|
|
862
|
+
if (documentFormat === DocumentFormat3.JWT) {
|
|
1133
863
|
const [header] = credential.split(".");
|
|
1134
864
|
const decodedHeader = JSON.parse(Buffer.from(header, "base64").toString());
|
|
1135
865
|
if (decodedHeader.typ === "statuslist+jwt") {
|
|
1136
|
-
statusListType =
|
|
866
|
+
statusListType = StatusListType5.OAuthStatusList;
|
|
1137
867
|
}
|
|
1138
|
-
} else if (documentFormat ===
|
|
1139
|
-
statusListType =
|
|
868
|
+
} else if (documentFormat === DocumentFormat3.MSO_MDOC) {
|
|
869
|
+
statusListType = StatusListType5.OAuthStatusList;
|
|
1140
870
|
}
|
|
1141
871
|
if (!statusListType) {
|
|
1142
|
-
const uniform =
|
|
1143
|
-
const type = uniform.type.find((t) => t.includes("StatusList2021") || t.includes("OAuth2StatusList")
|
|
872
|
+
const uniform = CredentialMapper3.toUniformCredential(credential);
|
|
873
|
+
const type = uniform.type.find((t) => t.includes("StatusList2021") || t.includes("OAuth2StatusList"));
|
|
1144
874
|
if (!type) {
|
|
1145
875
|
throw new Error("Invalid status list credential type");
|
|
1146
876
|
}
|
|
@@ -1168,7 +898,7 @@ async function statusList2021ToVerifiableCredential(args, context) {
|
|
|
1168
898
|
offlineWhenNoDIDRegistered: true
|
|
1169
899
|
});
|
|
1170
900
|
const proofFormat = args?.proofFormat ?? "lds";
|
|
1171
|
-
assertValidProofType(
|
|
901
|
+
assertValidProofType(StatusListType5.StatusList2021, proofFormat);
|
|
1172
902
|
const veramoProofFormat = proofFormat;
|
|
1173
903
|
const encodedList = getAssertedValue("encodedList", args.encodedList);
|
|
1174
904
|
const statusPurpose = getAssertedValue("statusPurpose", args.statusPurpose);
|
|
@@ -1197,7 +927,7 @@ async function statusList2021ToVerifiableCredential(args, context) {
|
|
|
1197
927
|
proofFormat: veramoProofFormat,
|
|
1198
928
|
fetchRemoteContexts: true
|
|
1199
929
|
});
|
|
1200
|
-
return
|
|
930
|
+
return CredentialMapper3.toWrappedVerifiableCredential(verifiableCredential).original;
|
|
1201
931
|
}
|
|
1202
932
|
__name(statusList2021ToVerifiableCredential, "statusList2021ToVerifiableCredential");
|
|
1203
933
|
export {
|