@zkpassport/sdk 0.20.0 → 0.21.0-beta.1

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,5 @@
1
- import { Query, IDCredential, IDCredentialValue, NumericalIDCredential, DisclosableIDCredential, BoundData, SupportedChain, SanctionsCountries, SanctionsLists, FacematchMode, ProofResult, QueryResult, NullifierType, CountryName, ProofMode, Service } from '@zkpassport/utils';
1
+ import { Query, IDCredential, IDCredentialValue, NumericalIDCredential, DisclosableIDCredential, BoundData, SupportedChain, SanctionsCountries, SanctionsLists, FacematchMode, ProofResult, QueryResult, NullifierType, VerificationMethod, AllowedVerificationMethod, CountryName, ProofMode, Service } from '@zkpassport/utils';
2
+ import { createRegistryClient } from '@zkpassport/registry';
2
3
  import { KeyPair } from '@obsidion/bridge';
3
4
  import { Alpha3Code } from 'i18n-iso-countries';
4
5
 
@@ -8,7 +9,7 @@ type QueryResultError<T> = {
8
9
  message: string;
9
10
  };
10
11
  type QueryResultErrors = {
11
- [key in IDCredential | "sig_check_dsc" | "sig_check_id_data" | "data_check_integrity" | "outer" | "disclose" | "bind" | "facematch" | "sanctions"]: {
12
+ [key in IDCredential | "sig_check_dsc" | "sig_check_id_data" | "data_check_integrity" | "attested_id" | "verification_method" | "outer" | "disclose" | "bind" | "facematch" | "sanctions"]: {
12
13
  disclose?: QueryResultError<string | number | Date>;
13
14
  gte?: QueryResultError<number | Date>;
14
15
  gt?: QueryResultError<number | Date>;
@@ -21,6 +22,7 @@ type QueryResultErrors = {
21
22
  commitment?: QueryResultError<string>;
22
23
  date?: QueryResultError<string>;
23
24
  certificate?: QueryResultError<string>;
25
+ revocation?: QueryResultError<string>;
24
26
  scope?: QueryResultError<string>;
25
27
  };
26
28
  };
@@ -32,12 +34,28 @@ type VerificationConfig = {
32
34
  * and Ethereum otherwise. Defaults to the built-in endpoint for that chain.
33
35
  */
34
36
  rpcUrl?: string;
37
+ /**
38
+ * Where to fetch the circuit manifest and the packaged circuits (the verification keys) from,
39
+ * instead of ZKPassport's CDN. For verifying proofs made with locally packaged circuits, served
40
+ * with the circuits repo's `serve-circuits` script: it must be the same server the app proved
41
+ * with. Expects `<url>/by-version/<version>/manifest.json`, `<url>/by-root/<root>/manifest.json`
42
+ * and `<url>/by-hash/<vkey hash>.json`.
43
+ */
44
+ circuitsUrl?: string;
35
45
  };
36
46
  type RequestedNullifierType = NullifierType.NON_SALTED | NullifierType.SALTED | NullifierType.NONE;
37
47
  type VerificationResult = {
38
48
  uniqueIdentifier: string | undefined;
39
49
  uniqueIdentifierType: NullifierType | undefined;
40
50
  verified: boolean;
51
+ /**
52
+ * The scheme the proofs were made under. Its tier (`getTierForVerificationMethod`) says what
53
+ * they rest on. Tier 1: the ID's chip, signed by its issuing country. Tier 2: the printed data
54
+ * page read by camera and attested by the device (App Attest or Play Integrity) together with
55
+ * a strict face match. A Tier 2 unique identifier is derived from the printed MRZ, not from a
56
+ * signature, so it is not proof against fabricated documents.
57
+ */
58
+ verificationMethod?: VerificationMethod;
41
59
  queryResultErrors?: Partial<QueryResultErrors>;
42
60
  };
43
61
  type SolidityProofVerificationData = {
@@ -50,6 +68,8 @@ type SolidityServiceConfig = {
50
68
  domain: string;
51
69
  scope: string;
52
70
  devMode: boolean;
71
+ /** The credentials the service accepts; empty means signed credentials only */
72
+ allowedVerificationMethods?: AllowedVerificationMethod[];
53
73
  };
54
74
  type SolidityVerifierParameters = {
55
75
  version: string;
@@ -150,6 +170,7 @@ type QueryBuilderResult = {
150
170
  uniqueIdentifier: string | undefined;
151
171
  uniqueIdentifierType: NullifierType | undefined;
152
172
  verified: boolean;
173
+ verificationMethod?: VerificationMethod;
153
174
  result: QueryResult;
154
175
  queryResultErrors?: Partial<QueryResultErrors>;
155
176
  proofs: ProofResult[];
@@ -291,6 +312,10 @@ declare function createOfflineQuery(): QueryBuilder<"offline">;
291
312
 
292
313
  declare const VERSION: string;
293
314
 
315
+ type RegistryClientOptions = NonNullable<Parameters<typeof createRegistryClient>[1]>;
316
+ /** The registry client overrides a {@link VerificationConfig} asks for */
317
+ declare function getRegistryClientOptions(config: VerificationConfig | undefined): RegistryClientOptions;
318
+
294
319
  declare class ZKPassport {
295
320
  private domain;
296
321
  private domainProvided;
@@ -348,9 +373,12 @@ declare class ZKPassport {
348
373
  * @param keyPairOverride A keypair from {@link getRequestKeyPair}, which keeps the request ID and bridge topic.
349
374
  * @param replayMissedMessages Redelivers what was already sent on this topic, for a request resumed on a new page.
350
375
  * @param config Settings for verifying the received proofs, see {@link VerificationConfig}.
376
+ * @param allowedVerificationMethods The credentials your service accepts: tiers and/or exact schemes,
377
+ * see {@link AllowedVerificationMethod}. Defaults to signed credentials only (tier 1); an ID verified
378
+ * another way is refused by the app before proving and by `verify()` after.
351
379
  * @returns The query builder object.
352
380
  */
353
- request({ name, logo, purpose, scope, projectID, mode, validity, devMode, uniqueIdentifierType, oprfKeyId, topicOverride, keyPairOverride, replayMissedMessages, cloudProverUrl, bridgeUrl, returnDeepLink, verifierMode, config, overrides, }: {
381
+ request({ name, logo, purpose, scope, projectID, mode, validity, devMode, uniqueIdentifierType, oprfKeyId, topicOverride, keyPairOverride, replayMissedMessages, cloudProverUrl, bridgeUrl, returnDeepLink, verifierMode, config, overrides, allowedVerificationMethods, }: {
354
382
  name?: string;
355
383
  logo?: string;
356
384
  purpose?: string;
@@ -369,9 +397,11 @@ declare class ZKPassport {
369
397
  returnDeepLink?: string;
370
398
  verifierMode?: VerifierMode;
371
399
  config?: VerificationConfig;
400
+ /** `appClip` allows the popup to send a chip-only request to the no-install App Clip lane */
372
401
  overrides?: {
373
402
  appClip?: boolean;
374
403
  };
404
+ allowedVerificationMethods?: AllowedVerificationMethod[];
375
405
  }): Promise<QueryBuilder>;
376
406
  /**
377
407
  * @notice Create a new offline query
@@ -399,10 +429,12 @@ declare class ZKPassport {
399
429
  * ZKPassport verifier API, and "auto" (default) verifies locally but defers to the API when
400
430
  * the local result is not verified — e.g. proofs from a newer bb version than this SDK supports.
401
431
  * @param config Verification settings such as the RPC URL, see {@link VerificationConfig}.
432
+ * @param allowedVerificationMethods The credentials your service accepts, see {@link AllowedVerificationMethod}.
433
+ * Defaults to signed credentials only (tier 1).
402
434
  * @returns An object containing the unique identifier associated to the user
403
435
  * and a boolean indicating whether the proofs were successfully verified.
404
436
  */
405
- verify({ proofs, originalQuery, queryResult, validity, scope, devMode, writingDirectory, oprfKeyId, uniqueIdentifierType, verifierMode, config, }: {
437
+ verify({ proofs, originalQuery, queryResult, validity, scope, devMode, writingDirectory, oprfKeyId, uniqueIdentifierType, verifierMode, config, allowedVerificationMethods, }: {
406
438
  proofs: Array<ProofResult>;
407
439
  originalQuery: Query;
408
440
  queryResult: QueryResult;
@@ -414,6 +446,7 @@ declare class ZKPassport {
414
446
  uniqueIdentifierType?: RequestedNullifierType;
415
447
  verifierMode?: VerifierMode;
416
448
  config?: VerificationConfig;
449
+ allowedVerificationMethods?: AllowedVerificationMethod[];
417
450
  }): Promise<VerificationResult>;
418
451
  private verifyLocally;
419
452
  getSolidityVerifierDetails(): {
@@ -472,4 +505,4 @@ declare class ZKPassport {
472
505
  clearAllRequests(): void;
473
506
  }
474
507
 
475
- export { type DashboardConfig as D, type OnSuccessVerdict as O, type Policy as P, type QueryBuilder as Q, type RequestedNullifierType as R, type SolidityProofVerificationData as S, VERSION as V, ZKPassport as Z, type QueryBuilderResult as a, numericalCompare as b, createOfflineQuery as c, type OfflineQueryBuilderResult as d, type QueryResultError as e, type QueryResultErrors as f, generalCompare as g, type RequestSuccess as h, type SolidityServiceConfig as i, type SolidityVerifierParameters as j, type VerificationConfig as k, type VerificationResult as l, type VerifierMode as m, normalizeCountry as n, rangeCompare as r };
508
+ export { type DashboardConfig as D, type OnSuccessVerdict as O, type Policy as P, type QueryBuilder as Q, type RequestedNullifierType as R, type SolidityProofVerificationData as S, VERSION as V, ZKPassport as Z, type QueryBuilderResult as a, numericalCompare as b, createOfflineQuery as c, type OfflineQueryBuilderResult as d, type QueryResultError as e, type QueryResultErrors as f, generalCompare as g, type RequestSuccess as h, type SolidityServiceConfig as i, type SolidityVerifierParameters as j, type VerificationConfig as k, type VerificationResult as l, type VerifierMode as m, normalizeCountry as n, getRegistryClientOptions as o, rangeCompare as r };