@zkpassport/sdk 0.2.7 → 0.2.9
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/LICENSE +201 -0
- package/dist/cjs/index.d.ts +36 -2
- package/dist/cjs/index.js +332 -82
- package/dist/esm/index.d.ts +36 -2
- package/dist/esm/index.js +332 -82
- package/package.json +1 -1
- package/src/index.ts +393 -85
package/dist/esm/index.d.ts
CHANGED
|
@@ -1,4 +1,24 @@
|
|
|
1
1
|
import { type DisclosableIDCredential, type IDCredential, type IDCredentialValue, type NumericalIDCredential, type ProofResult, type QueryResult } from "@zkpassport/utils";
|
|
2
|
+
export type QueryResultError<T> = {
|
|
3
|
+
expected?: T;
|
|
4
|
+
received?: T;
|
|
5
|
+
message: string;
|
|
6
|
+
};
|
|
7
|
+
export type QueryResultErrors = {
|
|
8
|
+
[key in IDCredential | "sig_check_dsc" | "sig_check_id_data" | "data_check_integrity" | "disclose"]: {
|
|
9
|
+
disclose?: QueryResultError<string | number | Date>;
|
|
10
|
+
gte?: QueryResultError<number | Date>;
|
|
11
|
+
lte?: QueryResultError<number | Date>;
|
|
12
|
+
lt?: QueryResultError<number | Date>;
|
|
13
|
+
range?: QueryResultError<[number | Date, number | Date]>;
|
|
14
|
+
in?: QueryResultError<string[]>;
|
|
15
|
+
out?: QueryResultError<string[]>;
|
|
16
|
+
eq?: QueryResultError<string | number | Date>;
|
|
17
|
+
commitment?: QueryResultError<string>;
|
|
18
|
+
date?: QueryResultError<string>;
|
|
19
|
+
certificate?: QueryResultError<string>;
|
|
20
|
+
};
|
|
21
|
+
};
|
|
2
22
|
export type * from "@zkpassport/utils";
|
|
3
23
|
export { SANCTIONED_COUNTRIES, EU_COUNTRIES, EEA_COUNTRIES, SCHENGEN_COUNTRIES, ASEAN_COUNTRIES, MERCOSUR_COUNTRIES, } from "@zkpassport/utils";
|
|
4
24
|
export type QueryBuilderResult = {
|
|
@@ -47,6 +67,7 @@ export type QueryBuilderResult = {
|
|
|
47
67
|
uniqueIdentifier: string | undefined;
|
|
48
68
|
verified: boolean;
|
|
49
69
|
result: QueryResult;
|
|
70
|
+
queryResultErrors?: QueryResultErrors;
|
|
50
71
|
}) => void) => void;
|
|
51
72
|
/**
|
|
52
73
|
* Called when the user has rejected the request.
|
|
@@ -128,6 +149,7 @@ export type QueryBuilder = {
|
|
|
128
149
|
export declare class ZKPassport {
|
|
129
150
|
private domain;
|
|
130
151
|
private topicToConfig;
|
|
152
|
+
private topicToLocalConfig;
|
|
131
153
|
private topicToKeyPair;
|
|
132
154
|
private topicToWebSocketClient;
|
|
133
155
|
private topicToSharedSecret;
|
|
@@ -135,6 +157,7 @@ export declare class ZKPassport {
|
|
|
135
157
|
private topicToService;
|
|
136
158
|
private topicToProofs;
|
|
137
159
|
private topicToExpectedProofCount;
|
|
160
|
+
private topicToFailedProofCount;
|
|
138
161
|
private topicToResults;
|
|
139
162
|
private onRequestReceivedCallbacks;
|
|
140
163
|
private onGeneratingProofCallbacks;
|
|
@@ -154,14 +177,20 @@ export declare class ZKPassport {
|
|
|
154
177
|
private handleEncryptedMessage;
|
|
155
178
|
private getZkPassportRequest;
|
|
156
179
|
/**
|
|
157
|
-
* @notice Create a new request
|
|
180
|
+
* @notice Create a new request
|
|
181
|
+
* @param name Your service name
|
|
182
|
+
* @param logo The logo of your service
|
|
183
|
+
* @param purpose To explain what you want to do with the user's data
|
|
184
|
+
* @param scope Scope this request to a specific use case
|
|
185
|
+
* @param validity How many days ago should have the ID been last scanned by the user?
|
|
158
186
|
* @returns The query builder object.
|
|
159
187
|
*/
|
|
160
|
-
request({ name, logo, purpose, scope, topicOverride, keyPairOverride, }: {
|
|
188
|
+
request({ name, logo, purpose, scope, validity, topicOverride, keyPairOverride, }: {
|
|
161
189
|
name: string;
|
|
162
190
|
logo: string;
|
|
163
191
|
purpose: string;
|
|
164
192
|
scope?: string;
|
|
193
|
+
validity?: number;
|
|
165
194
|
topicOverride?: string;
|
|
166
195
|
keyPairOverride?: {
|
|
167
196
|
privateKey: Uint8Array;
|
|
@@ -180,6 +209,7 @@ export declare class ZKPassport {
|
|
|
180
209
|
verify(requestId: string, proofs?: Array<ProofResult>, queryResult?: QueryResult): Promise<{
|
|
181
210
|
uniqueIdentifier: string | undefined;
|
|
182
211
|
verified: boolean;
|
|
212
|
+
queryResultErrors?: QueryResultErrors;
|
|
183
213
|
}>;
|
|
184
214
|
/**
|
|
185
215
|
* @notice Returns the URL of the request.
|
|
@@ -192,4 +222,8 @@ export declare class ZKPassport {
|
|
|
192
222
|
* @param requestId The request ID.
|
|
193
223
|
*/
|
|
194
224
|
cancelRequest(requestId: string): void;
|
|
225
|
+
/**
|
|
226
|
+
* @notice Clears all requests.
|
|
227
|
+
*/
|
|
228
|
+
clearAllRequests(): void;
|
|
195
229
|
}
|