@zkpassport/sdk 0.7.1 → 0.8.0-beta.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.
@@ -1,4 +1,4 @@
1
- import { IDCredential, ProofResult, QueryResult, IDCredentialValue, NumericalIDCredential, DisclosableIDCredential, BoundData, ProofMode, SupportedChain } from '@zkpassport/utils';
1
+ import { IDCredential, ProofResult, QueryResult, IDCredentialValue, NumericalIDCredential, DisclosableIDCredential, BoundData, SanctionsCountries, SanctionsLists, ProofMode, SupportedChain } from '@zkpassport/utils';
2
2
  export * from '@zkpassport/utils';
3
3
  export { ASEAN_COUNTRIES, EEA_COUNTRIES, EU_COUNTRIES, MERCOSUR_COUNTRIES, SANCTIONED_COUNTRIES, SCHENGEN_COUNTRIES } from '@zkpassport/utils';
4
4
 
@@ -8,7 +8,7 @@ type QueryResultError<T> = {
8
8
  message: string;
9
9
  };
10
10
  type QueryResultErrors = {
11
- [key in IDCredential | "sig_check_dsc" | "sig_check_id_data" | "data_check_integrity" | "outer" | "disclose" | "bind"]: {
11
+ [key in IDCredential | "sig_check_dsc" | "sig_check_id_data" | "data_check_integrity" | "outer" | "disclose" | "bind" | "facematch" | "sanctions"]: {
12
12
  disclose?: QueryResultError<string | number | Date>;
13
13
  gte?: QueryResultError<number | Date>;
14
14
  lte?: QueryResultError<number | Date>;
@@ -29,7 +29,7 @@ type SolidityVerifierParameters = {
29
29
  publicInputs: string[];
30
30
  committedInputs: string;
31
31
  committedInputCounts: number[];
32
- validityPeriodInDays: number;
32
+ validityPeriodInSeconds: number;
33
33
  domain: string;
34
34
  scope: string;
35
35
  devMode: boolean;
@@ -81,7 +81,7 @@ type QueryBuilderResult = {
81
81
  uniqueIdentifier: string | undefined;
82
82
  verified: boolean;
83
83
  result: QueryResult;
84
- queryResultErrors?: QueryResultErrors;
84
+ queryResultErrors?: Partial<QueryResultErrors>;
85
85
  }) => void) => void;
86
86
  /**
87
87
  * Called when the user has rejected the request.
@@ -157,6 +157,22 @@ type QueryBuilder = {
157
157
  * @param value The value to bind the request to.
158
158
  */
159
159
  bind: (key: keyof BoundData, value: BoundData[keyof BoundData]) => QueryBuilder;
160
+ /**
161
+ * Requires that the ID holder is not part of any of the specified sanction lists.
162
+ * @param countries The country or list of countries whose sanction lists to check against. Defaults to "all".
163
+ * e.g. "US", ["US", "GB", "CH", "EU"], "all"
164
+ * @param lists The specific lists from a given country to check against. Defaults to "all".
165
+ * e.g. ["OFAC_SDN"], "all"
166
+ */
167
+ sanctions: (countries?: SanctionsCountries, lists?: SanctionsLists) => QueryBuilder;
168
+ /**
169
+ * Requires that the ID holder's face matches the photo on the ID.
170
+ * @param mode The mode to use for the face match. Defaults to "regular".
171
+ * @param mode "strict" - The user will have to go through an extensive liveness check to prevent spoofing making it more secure.
172
+ * Best for high security requirements such as KYC.
173
+ * @param mode "regular" - The user will only have to go through a basic liveness check to prevent spoofing, making it faster for the user.
174
+ * Best for lower security requirements that requires fast verification such as age verification.
175
+ */
160
176
  /**
161
177
  * Builds the request.
162
178
  *
@@ -185,6 +201,7 @@ declare class ZKPassport {
185
201
  private onResultCallbacks;
186
202
  private onRejectCallbacks;
187
203
  private onErrorCallbacks;
204
+ private normalizeDomain;
188
205
  constructor(_domain?: string);
189
206
  private handleResult;
190
207
  private setExpectedProofCount;
@@ -201,7 +218,7 @@ declare class ZKPassport {
201
218
  * @param logo The logo of your service
202
219
  * @param purpose To explain what you want to do with the user's data
203
220
  * @param scope Scope this request to a specific use case
204
- * @param validity How many days ago should have the ID been last scanned by the user?
221
+ * @param validity How many seconds ago the proof checking the expiry date of the ID should have been generated
205
222
  * @param devMode Whether to enable dev mode. This will allow you to verify mock proofs (i.e. from ZKR)
206
223
  * @returns The query builder object.
207
224
  */
@@ -233,12 +250,13 @@ declare class ZKPassport {
233
250
  private checkCertificateRegistryRoot;
234
251
  private checkCircuitRegistryRoot;
235
252
  private checkBindPublicInputs;
253
+ private checkSanctionsExclusionPublicInputs;
236
254
  private checkPublicInputs;
237
255
  /**
238
256
  * @notice Verify the proofs received from the mobile app.
239
257
  * @param proofs The proofs to verify.
240
258
  * @param queryResult The query result to verify against
241
- * @param validity How many days ago should have the ID been last scanned by the user?
259
+ * @param validity How many seconds ago the proof checking the expiry date of the ID should have been generated
242
260
  * @param scope Scope this request to a specific use case
243
261
  * @param devMode Whether to enable dev mode. This will allow you to verify mock proofs (i.e. from ZKR)
244
262
  * @param writingDirectory The directory (e.g. `./tmp`) where the necessary temporary artifacts for verification are written to.
@@ -256,7 +274,7 @@ declare class ZKPassport {
256
274
  }): Promise<{
257
275
  uniqueIdentifier: string | undefined;
258
276
  verified: boolean;
259
- queryResultErrors?: QueryResultErrors;
277
+ queryResultErrors?: Partial<QueryResultErrors>;
260
278
  }>;
261
279
  getSolidityVerifierDetails(network: SupportedChain): {
262
280
  address: `0x${string}`;
@@ -276,9 +294,9 @@ declare class ZKPassport {
276
294
  }[];
277
295
  }[];
278
296
  };
279
- getSolidityVerifierParameters({ proof, validityPeriodInDays, domain, scope, devMode, }: {
297
+ getSolidityVerifierParameters({ proof, validityPeriodInSeconds, domain, scope, devMode, }: {
280
298
  proof: ProofResult;
281
- validityPeriodInDays?: number;
299
+ validityPeriodInSeconds?: number;
282
300
  domain?: string;
283
301
  scope?: string;
284
302
  devMode?: boolean;
@@ -1,4 +1,4 @@
1
- import { IDCredential, ProofResult, QueryResult, IDCredentialValue, NumericalIDCredential, DisclosableIDCredential, BoundData, ProofMode, SupportedChain } from '@zkpassport/utils';
1
+ import { IDCredential, ProofResult, QueryResult, IDCredentialValue, NumericalIDCredential, DisclosableIDCredential, BoundData, SanctionsCountries, SanctionsLists, ProofMode, SupportedChain } from '@zkpassport/utils';
2
2
  export * from '@zkpassport/utils';
3
3
  export { ASEAN_COUNTRIES, EEA_COUNTRIES, EU_COUNTRIES, MERCOSUR_COUNTRIES, SANCTIONED_COUNTRIES, SCHENGEN_COUNTRIES } from '@zkpassport/utils';
4
4
 
@@ -8,7 +8,7 @@ type QueryResultError<T> = {
8
8
  message: string;
9
9
  };
10
10
  type QueryResultErrors = {
11
- [key in IDCredential | "sig_check_dsc" | "sig_check_id_data" | "data_check_integrity" | "outer" | "disclose" | "bind"]: {
11
+ [key in IDCredential | "sig_check_dsc" | "sig_check_id_data" | "data_check_integrity" | "outer" | "disclose" | "bind" | "facematch" | "sanctions"]: {
12
12
  disclose?: QueryResultError<string | number | Date>;
13
13
  gte?: QueryResultError<number | Date>;
14
14
  lte?: QueryResultError<number | Date>;
@@ -29,7 +29,7 @@ type SolidityVerifierParameters = {
29
29
  publicInputs: string[];
30
30
  committedInputs: string;
31
31
  committedInputCounts: number[];
32
- validityPeriodInDays: number;
32
+ validityPeriodInSeconds: number;
33
33
  domain: string;
34
34
  scope: string;
35
35
  devMode: boolean;
@@ -81,7 +81,7 @@ type QueryBuilderResult = {
81
81
  uniqueIdentifier: string | undefined;
82
82
  verified: boolean;
83
83
  result: QueryResult;
84
- queryResultErrors?: QueryResultErrors;
84
+ queryResultErrors?: Partial<QueryResultErrors>;
85
85
  }) => void) => void;
86
86
  /**
87
87
  * Called when the user has rejected the request.
@@ -157,6 +157,22 @@ type QueryBuilder = {
157
157
  * @param value The value to bind the request to.
158
158
  */
159
159
  bind: (key: keyof BoundData, value: BoundData[keyof BoundData]) => QueryBuilder;
160
+ /**
161
+ * Requires that the ID holder is not part of any of the specified sanction lists.
162
+ * @param countries The country or list of countries whose sanction lists to check against. Defaults to "all".
163
+ * e.g. "US", ["US", "GB", "CH", "EU"], "all"
164
+ * @param lists The specific lists from a given country to check against. Defaults to "all".
165
+ * e.g. ["OFAC_SDN"], "all"
166
+ */
167
+ sanctions: (countries?: SanctionsCountries, lists?: SanctionsLists) => QueryBuilder;
168
+ /**
169
+ * Requires that the ID holder's face matches the photo on the ID.
170
+ * @param mode The mode to use for the face match. Defaults to "regular".
171
+ * @param mode "strict" - The user will have to go through an extensive liveness check to prevent spoofing making it more secure.
172
+ * Best for high security requirements such as KYC.
173
+ * @param mode "regular" - The user will only have to go through a basic liveness check to prevent spoofing, making it faster for the user.
174
+ * Best for lower security requirements that requires fast verification such as age verification.
175
+ */
160
176
  /**
161
177
  * Builds the request.
162
178
  *
@@ -185,6 +201,7 @@ declare class ZKPassport {
185
201
  private onResultCallbacks;
186
202
  private onRejectCallbacks;
187
203
  private onErrorCallbacks;
204
+ private normalizeDomain;
188
205
  constructor(_domain?: string);
189
206
  private handleResult;
190
207
  private setExpectedProofCount;
@@ -201,7 +218,7 @@ declare class ZKPassport {
201
218
  * @param logo The logo of your service
202
219
  * @param purpose To explain what you want to do with the user's data
203
220
  * @param scope Scope this request to a specific use case
204
- * @param validity How many days ago should have the ID been last scanned by the user?
221
+ * @param validity How many seconds ago the proof checking the expiry date of the ID should have been generated
205
222
  * @param devMode Whether to enable dev mode. This will allow you to verify mock proofs (i.e. from ZKR)
206
223
  * @returns The query builder object.
207
224
  */
@@ -233,12 +250,13 @@ declare class ZKPassport {
233
250
  private checkCertificateRegistryRoot;
234
251
  private checkCircuitRegistryRoot;
235
252
  private checkBindPublicInputs;
253
+ private checkSanctionsExclusionPublicInputs;
236
254
  private checkPublicInputs;
237
255
  /**
238
256
  * @notice Verify the proofs received from the mobile app.
239
257
  * @param proofs The proofs to verify.
240
258
  * @param queryResult The query result to verify against
241
- * @param validity How many days ago should have the ID been last scanned by the user?
259
+ * @param validity How many seconds ago the proof checking the expiry date of the ID should have been generated
242
260
  * @param scope Scope this request to a specific use case
243
261
  * @param devMode Whether to enable dev mode. This will allow you to verify mock proofs (i.e. from ZKR)
244
262
  * @param writingDirectory The directory (e.g. `./tmp`) where the necessary temporary artifacts for verification are written to.
@@ -256,7 +274,7 @@ declare class ZKPassport {
256
274
  }): Promise<{
257
275
  uniqueIdentifier: string | undefined;
258
276
  verified: boolean;
259
- queryResultErrors?: QueryResultErrors;
277
+ queryResultErrors?: Partial<QueryResultErrors>;
260
278
  }>;
261
279
  getSolidityVerifierDetails(network: SupportedChain): {
262
280
  address: `0x${string}`;
@@ -276,9 +294,9 @@ declare class ZKPassport {
276
294
  }[];
277
295
  }[];
278
296
  };
279
- getSolidityVerifierParameters({ proof, validityPeriodInDays, domain, scope, devMode, }: {
297
+ getSolidityVerifierParameters({ proof, validityPeriodInSeconds, domain, scope, devMode, }: {
280
298
  proof: ProofResult;
281
- validityPeriodInDays?: number;
299
+ validityPeriodInSeconds?: number;
282
300
  domain?: string;
283
301
  scope?: string;
284
302
  devMode?: boolean;