@zkpassport/sdk 0.5.2 → 0.5.4

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.
@@ -243,17 +243,19 @@ export declare class ZKPassport {
243
243
  * @param scope Scope this request to a specific use case
244
244
  * @param evmChain The EVM chain to use for the verification (if using the proof onchain)
245
245
  * @param devMode Whether to enable dev mode. This will allow you to verify mock proofs (i.e. from ZKR)
246
+ * @param writingDirectory The directory (e.g. `./tmp`) where the necessary temporary artifacts for verification are written to.
247
+ * It should only be needed when running the `verify` function on a server with restricted write access (e.g. Vercel)
246
248
  * @returns An object containing the unique identifier associated to the user
247
249
  * and a boolean indicating whether the proofs were successfully verified.
248
250
  */
249
- verify({ proofs, queryResult, validity, scope, evmChain, devMode, crsPath, }: {
251
+ verify({ proofs, queryResult, validity, scope, evmChain, devMode, writingDirectory, }: {
250
252
  proofs: Array<ProofResult>;
251
253
  queryResult: QueryResult;
252
254
  validity?: number;
253
255
  scope?: string;
254
256
  evmChain?: EVMChain;
255
257
  devMode?: boolean;
256
- crsPath?: string;
258
+ writingDirectory?: string;
257
259
  }): Promise<{
258
260
  uniqueIdentifier: string | undefined;
259
261
  verified: boolean;
package/dist/cjs/index.js CHANGED
@@ -13,7 +13,7 @@ const utils_3 = require("@noble/hashes/utils");
13
13
  const ZKPassportVerifier_json_1 = tslib_1.__importDefault(require("./assets/abi/ZKPassportVerifier.json"));
14
14
  const registry_1 = require("@zkpassport/registry");
15
15
  const bridge_1 = require("@obsidion/bridge");
16
- const VERSION = "0.5.2";
16
+ const VERSION = "0.5.3";
17
17
  const DEFAULT_DATE_VALUE = new Date(1111, 10, 11);
18
18
  // If Buffer is not defined, then we use the Buffer from the buffer package
19
19
  if (typeof globalThis.Buffer === "undefined") {
@@ -2025,10 +2025,12 @@ class ZKPassport {
2025
2025
  * @param scope Scope this request to a specific use case
2026
2026
  * @param evmChain The EVM chain to use for the verification (if using the proof onchain)
2027
2027
  * @param devMode Whether to enable dev mode. This will allow you to verify mock proofs (i.e. from ZKR)
2028
+ * @param writingDirectory The directory (e.g. `./tmp`) where the necessary temporary artifacts for verification are written to.
2029
+ * It should only be needed when running the `verify` function on a server with restricted write access (e.g. Vercel)
2028
2030
  * @returns An object containing the unique identifier associated to the user
2029
2031
  * and a boolean indicating whether the proofs were successfully verified.
2030
2032
  */
2031
- async verify({ proofs, queryResult, validity, scope, evmChain, devMode = false, crsPath, }) {
2033
+ async verify({ proofs, queryResult, validity, scope, evmChain, devMode = false, writingDirectory, }) {
2032
2034
  // If no proofs were generated, the results can't be trusted.
2033
2035
  // We still return it but verified will be false
2034
2036
  if (!proofs || proofs.length === 0) {
@@ -2046,8 +2048,13 @@ class ZKPassport {
2046
2048
  formattedResult.expiry_date.disclose.result = new Date(formattedResult.expiry_date.disclose.result);
2047
2049
  }
2048
2050
  const { BarretenbergVerifier } = await Promise.resolve().then(() => tslib_1.__importStar(require("@aztec/bb.js")));
2051
+ // Automatically set the writing directory to `/tmp` if it is not provided
2052
+ // and the code is not running in the browser
2053
+ if (typeof window === "undefined" && !writingDirectory) {
2054
+ writingDirectory = "/tmp";
2055
+ }
2049
2056
  const verifier = new BarretenbergVerifier({
2050
- crsPath,
2057
+ crsPath: writingDirectory ? writingDirectory + "/.bb-crs" : undefined,
2051
2058
  });
2052
2059
  let verified = true;
2053
2060
  let uniqueIdentifier;
@@ -2057,8 +2064,10 @@ class ZKPassport {
2057
2064
  uniqueIdentifier = uniqueIdentifierFromPublicInputs;
2058
2065
  verified = isCorrect;
2059
2066
  queryResultErrors = isCorrect ? undefined : queryResultErrorsFromPublicInputs;
2060
- if (uniqueIdentifier && BigInt(uniqueIdentifier) === BigInt(0) && !devMode) {
2061
- // If the unique identifier is 0 and it is not in dev mode,
2067
+ if (uniqueIdentifier &&
2068
+ (BigInt(uniqueIdentifier) === BigInt(1) || BigInt(uniqueIdentifier) === BigInt(0)) &&
2069
+ !devMode) {
2070
+ // If the unique identifier is 0 (old ZKR proofs) or 1 (new ZKR proofs) and it is not in dev mode,
2062
2071
  // the proofs are considered invalid as these are mock proofs only meant
2063
2072
  // for testing purposes
2064
2073
  verified = false;
@@ -243,17 +243,19 @@ export declare class ZKPassport {
243
243
  * @param scope Scope this request to a specific use case
244
244
  * @param evmChain The EVM chain to use for the verification (if using the proof onchain)
245
245
  * @param devMode Whether to enable dev mode. This will allow you to verify mock proofs (i.e. from ZKR)
246
+ * @param writingDirectory The directory (e.g. `./tmp`) where the necessary temporary artifacts for verification are written to.
247
+ * It should only be needed when running the `verify` function on a server with restricted write access (e.g. Vercel)
246
248
  * @returns An object containing the unique identifier associated to the user
247
249
  * and a boolean indicating whether the proofs were successfully verified.
248
250
  */
249
- verify({ proofs, queryResult, validity, scope, evmChain, devMode, crsPath, }: {
251
+ verify({ proofs, queryResult, validity, scope, evmChain, devMode, writingDirectory, }: {
250
252
  proofs: Array<ProofResult>;
251
253
  queryResult: QueryResult;
252
254
  validity?: number;
253
255
  scope?: string;
254
256
  evmChain?: EVMChain;
255
257
  devMode?: boolean;
256
- crsPath?: string;
258
+ writingDirectory?: string;
257
259
  }): Promise<{
258
260
  uniqueIdentifier: string | undefined;
259
261
  verified: boolean;
package/dist/esm/index.js CHANGED
@@ -9,7 +9,7 @@ import { hexToBytes } from "@noble/hashes/utils";
9
9
  import ZKPassportVerifierAbi from "./assets/abi/ZKPassportVerifier.json";
10
10
  import { RegistryClient } from "@zkpassport/registry";
11
11
  import { Bridge } from "@obsidion/bridge";
12
- const VERSION = "0.5.2";
12
+ const VERSION = "0.5.3";
13
13
  const DEFAULT_DATE_VALUE = new Date(1111, 10, 11);
14
14
  // If Buffer is not defined, then we use the Buffer from the buffer package
15
15
  if (typeof globalThis.Buffer === "undefined") {
@@ -2015,10 +2015,12 @@ export class ZKPassport {
2015
2015
  * @param scope Scope this request to a specific use case
2016
2016
  * @param evmChain The EVM chain to use for the verification (if using the proof onchain)
2017
2017
  * @param devMode Whether to enable dev mode. This will allow you to verify mock proofs (i.e. from ZKR)
2018
+ * @param writingDirectory The directory (e.g. `./tmp`) where the necessary temporary artifacts for verification are written to.
2019
+ * It should only be needed when running the `verify` function on a server with restricted write access (e.g. Vercel)
2018
2020
  * @returns An object containing the unique identifier associated to the user
2019
2021
  * and a boolean indicating whether the proofs were successfully verified.
2020
2022
  */
2021
- async verify({ proofs, queryResult, validity, scope, evmChain, devMode = false, crsPath, }) {
2023
+ async verify({ proofs, queryResult, validity, scope, evmChain, devMode = false, writingDirectory, }) {
2022
2024
  // If no proofs were generated, the results can't be trusted.
2023
2025
  // We still return it but verified will be false
2024
2026
  if (!proofs || proofs.length === 0) {
@@ -2036,8 +2038,13 @@ export class ZKPassport {
2036
2038
  formattedResult.expiry_date.disclose.result = new Date(formattedResult.expiry_date.disclose.result);
2037
2039
  }
2038
2040
  const { BarretenbergVerifier } = await import("@aztec/bb.js");
2041
+ // Automatically set the writing directory to `/tmp` if it is not provided
2042
+ // and the code is not running in the browser
2043
+ if (typeof window === "undefined" && !writingDirectory) {
2044
+ writingDirectory = "/tmp";
2045
+ }
2039
2046
  const verifier = new BarretenbergVerifier({
2040
- crsPath,
2047
+ crsPath: writingDirectory ? writingDirectory + "/.bb-crs" : undefined,
2041
2048
  });
2042
2049
  let verified = true;
2043
2050
  let uniqueIdentifier;
@@ -2047,8 +2054,10 @@ export class ZKPassport {
2047
2054
  uniqueIdentifier = uniqueIdentifierFromPublicInputs;
2048
2055
  verified = isCorrect;
2049
2056
  queryResultErrors = isCorrect ? undefined : queryResultErrorsFromPublicInputs;
2050
- if (uniqueIdentifier && BigInt(uniqueIdentifier) === BigInt(0) && !devMode) {
2051
- // If the unique identifier is 0 and it is not in dev mode,
2057
+ if (uniqueIdentifier &&
2058
+ (BigInt(uniqueIdentifier) === BigInt(1) || BigInt(uniqueIdentifier) === BigInt(0)) &&
2059
+ !devMode) {
2060
+ // If the unique identifier is 0 (old ZKR proofs) or 1 (new ZKR proofs) and it is not in dev mode,
2052
2061
  // the proofs are considered invalid as these are mock proofs only meant
2053
2062
  // for testing purposes
2054
2063
  verified = false;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zkpassport/sdk",
3
- "version": "0.5.2",
3
+ "version": "0.5.4",
4
4
  "description": "Privacy-preserving identity verification using passports and ID cards",
5
5
  "main": "./dist/cjs/index.js",
6
6
  "module": "./dist/esm/index.js",
@@ -43,7 +43,7 @@
43
43
  "@noble/hashes": "^1.7.2",
44
44
  "@noble/secp256k1": "^2.2.3",
45
45
  "@obsidion/bridge": "^0.10.2",
46
- "@zkpassport/registry": "^0.5.1",
46
+ "@zkpassport/registry": "^0.5.2",
47
47
  "@zkpassport/utils": "^0.13.1",
48
48
  "buffer": "^6.0.3",
49
49
  "i18n-iso-countries": "^7.12.0",
package/src/index.ts CHANGED
@@ -76,7 +76,7 @@ import ZKPassportVerifierAbi from "./assets/abi/ZKPassportVerifier.json"
76
76
  import { RegistryClient } from "@zkpassport/registry"
77
77
  import { Bridge, BridgeInterface } from "@obsidion/bridge"
78
78
 
79
- const VERSION = "0.5.2"
79
+ const VERSION = "0.5.3"
80
80
 
81
81
  const DEFAULT_DATE_VALUE = new Date(1111, 10, 11)
82
82
 
@@ -2782,6 +2782,8 @@ export class ZKPassport {
2782
2782
  * @param scope Scope this request to a specific use case
2783
2783
  * @param evmChain The EVM chain to use for the verification (if using the proof onchain)
2784
2784
  * @param devMode Whether to enable dev mode. This will allow you to verify mock proofs (i.e. from ZKR)
2785
+ * @param writingDirectory The directory (e.g. `./tmp`) where the necessary temporary artifacts for verification are written to.
2786
+ * It should only be needed when running the `verify` function on a server with restricted write access (e.g. Vercel)
2785
2787
  * @returns An object containing the unique identifier associated to the user
2786
2788
  * and a boolean indicating whether the proofs were successfully verified.
2787
2789
  */
@@ -2792,7 +2794,7 @@ export class ZKPassport {
2792
2794
  scope,
2793
2795
  evmChain,
2794
2796
  devMode = false,
2795
- crsPath,
2797
+ writingDirectory,
2796
2798
  }: {
2797
2799
  proofs: Array<ProofResult>
2798
2800
  queryResult: QueryResult
@@ -2800,7 +2802,7 @@ export class ZKPassport {
2800
2802
  scope?: string
2801
2803
  evmChain?: EVMChain
2802
2804
  devMode?: boolean
2803
- crsPath?: string
2805
+ writingDirectory?: string
2804
2806
  }): Promise<{
2805
2807
  uniqueIdentifier: string | undefined
2806
2808
  verified: boolean
@@ -2828,8 +2830,13 @@ export class ZKPassport {
2828
2830
  }
2829
2831
 
2830
2832
  const { BarretenbergVerifier } = await import("@aztec/bb.js")
2833
+ // Automatically set the writing directory to `/tmp` if it is not provided
2834
+ // and the code is not running in the browser
2835
+ if (typeof window === "undefined" && !writingDirectory) {
2836
+ writingDirectory = "/tmp"
2837
+ }
2831
2838
  const verifier = new BarretenbergVerifier({
2832
- crsPath,
2839
+ crsPath: writingDirectory ? writingDirectory + "/.bb-crs" : undefined,
2833
2840
  })
2834
2841
  let verified = true
2835
2842
  let uniqueIdentifier: string | undefined
@@ -2843,8 +2850,12 @@ export class ZKPassport {
2843
2850
  uniqueIdentifier = uniqueIdentifierFromPublicInputs
2844
2851
  verified = isCorrect
2845
2852
  queryResultErrors = isCorrect ? undefined : queryResultErrorsFromPublicInputs
2846
- if (uniqueIdentifier && BigInt(uniqueIdentifier) === BigInt(0) && !devMode) {
2847
- // If the unique identifier is 0 and it is not in dev mode,
2853
+ if (
2854
+ uniqueIdentifier &&
2855
+ (BigInt(uniqueIdentifier) === BigInt(1) || BigInt(uniqueIdentifier) === BigInt(0)) &&
2856
+ !devMode
2857
+ ) {
2858
+ // If the unique identifier is 0 (old ZKR proofs) or 1 (new ZKR proofs) and it is not in dev mode,
2848
2859
  // the proofs are considered invalid as these are mock proofs only meant
2849
2860
  // for testing purposes
2850
2861
  verified = false