@zkpassport/sdk 0.5.9 → 0.6.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.
@@ -811,7 +811,7 @@ var ZKPassportVerifier_default = {
811
811
  var import_registry = require("@zkpassport/registry");
812
812
  var import_bridge = require("@obsidion/bridge");
813
813
  var import_utils4 = require("@zkpassport/utils");
814
- var VERSION = "0.5.5";
814
+ var VERSION = "0.6.0";
815
815
  var DEFAULT_DATE_VALUE = new Date(1111, 10, 11);
816
816
  if (typeof globalThis.Buffer === "undefined") {
817
817
  globalThis.Buffer = import_buffer.Buffer;
@@ -819,22 +819,6 @@ if (typeof globalThis.Buffer === "undefined") {
819
819
  window.Buffer = import_buffer.Buffer;
820
820
  }
821
821
  }
822
- function getChainIdFromEVMChain(chain) {
823
- if (chain === "ethereum_sepolia") {
824
- return 11155111;
825
- } else if (chain === "local_anvil") {
826
- return 31337;
827
- }
828
- throw new Error(`Unsupported chain: ${chain}`);
829
- }
830
- function getEVMChainFromChainId(chainId) {
831
- if (chainId === 11155111) {
832
- return "ethereum_sepolia";
833
- } else if (chainId === 31337) {
834
- return "local_anvil";
835
- }
836
- throw new Error(`Unsupported chain ID: ${chainId}`);
837
- }
838
822
  (0, import_i18n_iso_countries.registerLocale)(import_en.default);
839
823
  function hasRequestedAccessToField(credentialsRequest, field) {
840
824
  const fieldValue = credentialsRequest[field];
@@ -909,7 +893,6 @@ var ZKPassport = class {
909
893
  queryResult: result,
910
894
  validity: this.topicToLocalConfig[topic]?.validity,
911
895
  scope: this.topicToService[topic]?.scope,
912
- evmChain: this.topicToService[topic]?.chainId ? getEVMChainFromChainId(this.topicToService[topic]?.chainId) : void 0,
913
896
  devMode: this.topicToLocalConfig[topic]?.devMode
914
897
  });
915
898
  delete this.topicToProofs[topic];
@@ -1133,7 +1116,6 @@ var ZKPassport = class {
1133
1116
  purpose,
1134
1117
  scope,
1135
1118
  mode,
1136
- evmChain,
1137
1119
  validity,
1138
1120
  devMode,
1139
1121
  topicOverride,
@@ -1153,7 +1135,6 @@ var ZKPassport = class {
1153
1135
  logo,
1154
1136
  purpose,
1155
1137
  scope,
1156
- chainId: evmChain ? getChainIdFromEVMChain(evmChain) : void 0,
1157
1138
  cloudProverUrl,
1158
1139
  bridgeUrl
1159
1140
  };
@@ -1947,11 +1928,11 @@ var ZKPassport = class {
1947
1928
  }
1948
1929
  checkScopeFromDisclosureProof(proofData, queryResultErrors, key, scope, chainId) {
1949
1930
  let isCorrect = true;
1950
- if (this.domain && (0, import_utils.getServiceScopeHash)(this.domain, chainId) !== BigInt(proofData.publicInputs[1])) {
1931
+ if (this.domain && (0, import_utils.getServiceScopeHash)(this.domain) !== BigInt(proofData.publicInputs[1])) {
1951
1932
  console.warn("The proof comes from a different domain than the one expected");
1952
1933
  isCorrect = false;
1953
1934
  queryResultErrors[key].scope = {
1954
- expected: `Scope: ${(0, import_utils.getServiceScopeHash)(this.domain, chainId).toString()}`,
1935
+ expected: `Scope: ${(0, import_utils.getServiceScopeHash)(this.domain).toString()}`,
1955
1936
  received: `Scope: ${BigInt(proofData.publicInputs[1]).toString()}`,
1956
1937
  message: "The proof comes from a different domain than the one expected"
1957
1938
  };
@@ -2050,6 +2031,15 @@ var ZKPassport = class {
2050
2031
  message: "Bound user address does not match the one from the query results"
2051
2032
  };
2052
2033
  }
2034
+ if (queryResult.bind.chain !== boundData.chain) {
2035
+ console.warn("Bound chain id does not match the one from the query results");
2036
+ isCorrect = false;
2037
+ queryResultErrors.bind.eq = {
2038
+ expected: queryResult.bind.chain,
2039
+ received: boundData.chain,
2040
+ message: "Bound chain id does not match the one from the query results"
2041
+ };
2042
+ }
2053
2043
  if (queryResult.bind.custom_data?.trim().toLowerCase() !== boundData.custom_data?.trim().toLowerCase()) {
2054
2044
  console.warn("Bound custom data does not match the one from the query results");
2055
2045
  isCorrect = false;
@@ -2062,7 +2052,7 @@ var ZKPassport = class {
2062
2052
  }
2063
2053
  return { isCorrect, queryResultErrors };
2064
2054
  }
2065
- async checkPublicInputs(proofs, queryResult, validity, scope, chainId) {
2055
+ async checkPublicInputs(proofs, queryResult, validity, scope) {
2066
2056
  let commitmentIn;
2067
2057
  let commitmentOut;
2068
2058
  let isCorrect = true;
@@ -2173,11 +2163,11 @@ var ZKPassport = class {
2173
2163
  message: "The proof does not verify all the requested conditions and information"
2174
2164
  };
2175
2165
  }
2176
- if (this.domain && (0, import_utils.getServiceScopeHash)(this.domain, chainId) !== (0, import_utils.getScopeFromOuterProof)(proofData)) {
2166
+ if (this.domain && (0, import_utils.getServiceScopeHash)(this.domain) !== (0, import_utils.getScopeFromOuterProof)(proofData)) {
2177
2167
  console.warn("The proof comes from a different domain than the one expected");
2178
2168
  isCorrect = false;
2179
2169
  queryResultErrors.outer.scope = {
2180
- expected: `Scope: ${(0, import_utils.getServiceScopeHash)(this.domain, chainId).toString()}`,
2170
+ expected: `Scope: ${(0, import_utils.getServiceScopeHash)(this.domain).toString()}`,
2181
2171
  received: `Scope: ${(0, import_utils.getScopeFromOuterProof)(proofData).toString()}`,
2182
2172
  message: "The proof comes from a different domain than the one expected"
2183
2173
  };
@@ -2866,7 +2856,6 @@ var ZKPassport = class {
2866
2856
  queryResult,
2867
2857
  validity,
2868
2858
  scope,
2869
- evmChain,
2870
2859
  devMode = false,
2871
2860
  writingDirectory
2872
2861
  }) {
@@ -2897,12 +2886,11 @@ var ZKPassport = class {
2897
2886
  let verified = true;
2898
2887
  let uniqueIdentifier;
2899
2888
  let queryResultErrors;
2900
- const chainId = evmChain ? getChainIdFromEVMChain(evmChain) : void 0;
2901
2889
  const {
2902
2890
  isCorrect,
2903
2891
  uniqueIdentifier: uniqueIdentifierFromPublicInputs,
2904
2892
  queryResultErrors: queryResultErrorsFromPublicInputs
2905
- } = await this.checkPublicInputs(proofs, formattedResult, validity, scope, chainId);
2893
+ } = await this.checkPublicInputs(proofs, formattedResult, validity, scope);
2906
2894
  uniqueIdentifier = uniqueIdentifierFromPublicInputs;
2907
2895
  verified = isCorrect;
2908
2896
  queryResultErrors = isCorrect ? void 0 : queryResultErrorsFromPublicInputs;
@@ -1,4 +1,4 @@
1
- import { IDCredential, ProofResult, QueryResult, IDCredentialValue, NumericalIDCredential, DisclosableIDCredential, BoundData, ProofMode } from '@zkpassport/utils';
1
+ import { IDCredential, ProofResult, QueryResult, IDCredentialValue, NumericalIDCredential, DisclosableIDCredential, BoundData, 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
 
@@ -34,7 +34,6 @@ type SolidityVerifierParameters = {
34
34
  scope: string;
35
35
  devMode: boolean;
36
36
  };
37
- type EVMChain = "ethereum_sepolia" | "local_anvil";
38
37
 
39
38
  type QueryBuilderResult = {
40
39
  /**
@@ -207,13 +206,12 @@ declare class ZKPassport {
207
206
  * @param evmChain The EVM chain to use for the request (if using the proof onchain)
208
207
  * @returns The query builder object.
209
208
  */
210
- request({ name, logo, purpose, scope, mode, evmChain, validity, devMode, topicOverride, keyPairOverride, cloudProverUrl, bridgeUrl, }: {
209
+ request({ name, logo, purpose, scope, mode, validity, devMode, topicOverride, keyPairOverride, cloudProverUrl, bridgeUrl, }: {
211
210
  name: string;
212
211
  logo: string;
213
212
  purpose: string;
214
213
  scope?: string;
215
214
  mode?: ProofMode;
216
- evmChain?: EVMChain;
217
215
  validity?: number;
218
216
  devMode?: boolean;
219
217
  topicOverride?: string;
@@ -250,12 +248,11 @@ declare class ZKPassport {
250
248
  * @returns An object containing the unique identifier associated to the user
251
249
  * and a boolean indicating whether the proofs were successfully verified.
252
250
  */
253
- verify({ proofs, queryResult, validity, scope, evmChain, devMode, writingDirectory, }: {
251
+ verify({ proofs, queryResult, validity, scope, devMode, writingDirectory, }: {
254
252
  proofs: Array<ProofResult>;
255
253
  queryResult: QueryResult;
256
254
  validity?: number;
257
255
  scope?: string;
258
- evmChain?: EVMChain;
259
256
  devMode?: boolean;
260
257
  writingDirectory?: string;
261
258
  }): Promise<{
@@ -263,7 +260,7 @@ declare class ZKPassport {
263
260
  verified: boolean;
264
261
  queryResultErrors?: QueryResultErrors;
265
262
  }>;
266
- getSolidityVerifierDetails(network: EVMChain): {
263
+ getSolidityVerifierDetails(network: SupportedChain): {
267
264
  address: `0x${string}`;
268
265
  functionName: string;
269
266
  abi: {
@@ -306,4 +303,4 @@ declare class ZKPassport {
306
303
  clearAllRequests(): void;
307
304
  }
308
305
 
309
- export { type EVMChain, type QueryBuilder, type QueryBuilderResult, type QueryResultError, type QueryResultErrors, type SolidityVerifierParameters, ZKPassport };
306
+ export { type QueryBuilder, type QueryBuilderResult, type QueryResultError, type QueryResultErrors, type SolidityVerifierParameters, ZKPassport };
@@ -1,4 +1,4 @@
1
- import { IDCredential, ProofResult, QueryResult, IDCredentialValue, NumericalIDCredential, DisclosableIDCredential, BoundData, ProofMode } from '@zkpassport/utils';
1
+ import { IDCredential, ProofResult, QueryResult, IDCredentialValue, NumericalIDCredential, DisclosableIDCredential, BoundData, 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
 
@@ -34,7 +34,6 @@ type SolidityVerifierParameters = {
34
34
  scope: string;
35
35
  devMode: boolean;
36
36
  };
37
- type EVMChain = "ethereum_sepolia" | "local_anvil";
38
37
 
39
38
  type QueryBuilderResult = {
40
39
  /**
@@ -207,13 +206,12 @@ declare class ZKPassport {
207
206
  * @param evmChain The EVM chain to use for the request (if using the proof onchain)
208
207
  * @returns The query builder object.
209
208
  */
210
- request({ name, logo, purpose, scope, mode, evmChain, validity, devMode, topicOverride, keyPairOverride, cloudProverUrl, bridgeUrl, }: {
209
+ request({ name, logo, purpose, scope, mode, validity, devMode, topicOverride, keyPairOverride, cloudProverUrl, bridgeUrl, }: {
211
210
  name: string;
212
211
  logo: string;
213
212
  purpose: string;
214
213
  scope?: string;
215
214
  mode?: ProofMode;
216
- evmChain?: EVMChain;
217
215
  validity?: number;
218
216
  devMode?: boolean;
219
217
  topicOverride?: string;
@@ -250,12 +248,11 @@ declare class ZKPassport {
250
248
  * @returns An object containing the unique identifier associated to the user
251
249
  * and a boolean indicating whether the proofs were successfully verified.
252
250
  */
253
- verify({ proofs, queryResult, validity, scope, evmChain, devMode, writingDirectory, }: {
251
+ verify({ proofs, queryResult, validity, scope, devMode, writingDirectory, }: {
254
252
  proofs: Array<ProofResult>;
255
253
  queryResult: QueryResult;
256
254
  validity?: number;
257
255
  scope?: string;
258
- evmChain?: EVMChain;
259
256
  devMode?: boolean;
260
257
  writingDirectory?: string;
261
258
  }): Promise<{
@@ -263,7 +260,7 @@ declare class ZKPassport {
263
260
  verified: boolean;
264
261
  queryResultErrors?: QueryResultErrors;
265
262
  }>;
266
- getSolidityVerifierDetails(network: EVMChain): {
263
+ getSolidityVerifierDetails(network: SupportedChain): {
267
264
  address: `0x${string}`;
268
265
  functionName: string;
269
266
  abi: {
@@ -306,4 +303,4 @@ declare class ZKPassport {
306
303
  clearAllRequests(): void;
307
304
  }
308
305
 
309
- export { type EVMChain, type QueryBuilder, type QueryBuilderResult, type QueryResultError, type QueryResultErrors, type SolidityVerifierParameters, ZKPassport };
306
+ export { type QueryBuilder, type QueryBuilderResult, type QueryResultError, type QueryResultErrors, type SolidityVerifierParameters, ZKPassport };
package/dist/esm/index.js CHANGED
@@ -811,7 +811,7 @@ import {
811
811
  ASEAN_COUNTRIES,
812
812
  MERCOSUR_COUNTRIES
813
813
  } from "@zkpassport/utils";
814
- var VERSION = "0.5.5";
814
+ var VERSION = "0.6.0";
815
815
  var DEFAULT_DATE_VALUE = new Date(1111, 10, 11);
816
816
  if (typeof globalThis.Buffer === "undefined") {
817
817
  globalThis.Buffer = Buffer;
@@ -819,22 +819,6 @@ if (typeof globalThis.Buffer === "undefined") {
819
819
  window.Buffer = Buffer;
820
820
  }
821
821
  }
822
- function getChainIdFromEVMChain(chain) {
823
- if (chain === "ethereum_sepolia") {
824
- return 11155111;
825
- } else if (chain === "local_anvil") {
826
- return 31337;
827
- }
828
- throw new Error(`Unsupported chain: ${chain}`);
829
- }
830
- function getEVMChainFromChainId(chainId) {
831
- if (chainId === 11155111) {
832
- return "ethereum_sepolia";
833
- } else if (chainId === 31337) {
834
- return "local_anvil";
835
- }
836
- throw new Error(`Unsupported chain ID: ${chainId}`);
837
- }
838
822
  registerLocale(i18en);
839
823
  function hasRequestedAccessToField(credentialsRequest, field) {
840
824
  const fieldValue = credentialsRequest[field];
@@ -909,7 +893,6 @@ var ZKPassport = class {
909
893
  queryResult: result,
910
894
  validity: this.topicToLocalConfig[topic]?.validity,
911
895
  scope: this.topicToService[topic]?.scope,
912
- evmChain: this.topicToService[topic]?.chainId ? getEVMChainFromChainId(this.topicToService[topic]?.chainId) : void 0,
913
896
  devMode: this.topicToLocalConfig[topic]?.devMode
914
897
  });
915
898
  delete this.topicToProofs[topic];
@@ -1133,7 +1116,6 @@ var ZKPassport = class {
1133
1116
  purpose,
1134
1117
  scope,
1135
1118
  mode,
1136
- evmChain,
1137
1119
  validity,
1138
1120
  devMode,
1139
1121
  topicOverride,
@@ -1153,7 +1135,6 @@ var ZKPassport = class {
1153
1135
  logo,
1154
1136
  purpose,
1155
1137
  scope,
1156
- chainId: evmChain ? getChainIdFromEVMChain(evmChain) : void 0,
1157
1138
  cloudProverUrl,
1158
1139
  bridgeUrl
1159
1140
  };
@@ -1947,11 +1928,11 @@ var ZKPassport = class {
1947
1928
  }
1948
1929
  checkScopeFromDisclosureProof(proofData, queryResultErrors, key, scope, chainId) {
1949
1930
  let isCorrect = true;
1950
- if (this.domain && getServiceScopeHash(this.domain, chainId) !== BigInt(proofData.publicInputs[1])) {
1931
+ if (this.domain && getServiceScopeHash(this.domain) !== BigInt(proofData.publicInputs[1])) {
1951
1932
  console.warn("The proof comes from a different domain than the one expected");
1952
1933
  isCorrect = false;
1953
1934
  queryResultErrors[key].scope = {
1954
- expected: `Scope: ${getServiceScopeHash(this.domain, chainId).toString()}`,
1935
+ expected: `Scope: ${getServiceScopeHash(this.domain).toString()}`,
1955
1936
  received: `Scope: ${BigInt(proofData.publicInputs[1]).toString()}`,
1956
1937
  message: "The proof comes from a different domain than the one expected"
1957
1938
  };
@@ -2050,6 +2031,15 @@ var ZKPassport = class {
2050
2031
  message: "Bound user address does not match the one from the query results"
2051
2032
  };
2052
2033
  }
2034
+ if (queryResult.bind.chain !== boundData.chain) {
2035
+ console.warn("Bound chain id does not match the one from the query results");
2036
+ isCorrect = false;
2037
+ queryResultErrors.bind.eq = {
2038
+ expected: queryResult.bind.chain,
2039
+ received: boundData.chain,
2040
+ message: "Bound chain id does not match the one from the query results"
2041
+ };
2042
+ }
2053
2043
  if (queryResult.bind.custom_data?.trim().toLowerCase() !== boundData.custom_data?.trim().toLowerCase()) {
2054
2044
  console.warn("Bound custom data does not match the one from the query results");
2055
2045
  isCorrect = false;
@@ -2062,7 +2052,7 @@ var ZKPassport = class {
2062
2052
  }
2063
2053
  return { isCorrect, queryResultErrors };
2064
2054
  }
2065
- async checkPublicInputs(proofs, queryResult, validity, scope, chainId) {
2055
+ async checkPublicInputs(proofs, queryResult, validity, scope) {
2066
2056
  let commitmentIn;
2067
2057
  let commitmentOut;
2068
2058
  let isCorrect = true;
@@ -2173,11 +2163,11 @@ var ZKPassport = class {
2173
2163
  message: "The proof does not verify all the requested conditions and information"
2174
2164
  };
2175
2165
  }
2176
- if (this.domain && getServiceScopeHash(this.domain, chainId) !== getScopeFromOuterProof(proofData)) {
2166
+ if (this.domain && getServiceScopeHash(this.domain) !== getScopeFromOuterProof(proofData)) {
2177
2167
  console.warn("The proof comes from a different domain than the one expected");
2178
2168
  isCorrect = false;
2179
2169
  queryResultErrors.outer.scope = {
2180
- expected: `Scope: ${getServiceScopeHash(this.domain, chainId).toString()}`,
2170
+ expected: `Scope: ${getServiceScopeHash(this.domain).toString()}`,
2181
2171
  received: `Scope: ${getScopeFromOuterProof(proofData).toString()}`,
2182
2172
  message: "The proof comes from a different domain than the one expected"
2183
2173
  };
@@ -2866,7 +2856,6 @@ var ZKPassport = class {
2866
2856
  queryResult,
2867
2857
  validity,
2868
2858
  scope,
2869
- evmChain,
2870
2859
  devMode = false,
2871
2860
  writingDirectory
2872
2861
  }) {
@@ -2897,12 +2886,11 @@ var ZKPassport = class {
2897
2886
  let verified = true;
2898
2887
  let uniqueIdentifier;
2899
2888
  let queryResultErrors;
2900
- const chainId = evmChain ? getChainIdFromEVMChain(evmChain) : void 0;
2901
2889
  const {
2902
2890
  isCorrect,
2903
2891
  uniqueIdentifier: uniqueIdentifierFromPublicInputs,
2904
2892
  queryResultErrors: queryResultErrorsFromPublicInputs
2905
- } = await this.checkPublicInputs(proofs, formattedResult, validity, scope, chainId);
2893
+ } = await this.checkPublicInputs(proofs, formattedResult, validity, scope);
2906
2894
  uniqueIdentifier = uniqueIdentifierFromPublicInputs;
2907
2895
  verified = isCorrect;
2908
2896
  queryResultErrors = isCorrect ? void 0 : queryResultErrorsFromPublicInputs;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zkpassport/sdk",
3
- "version": "0.5.9",
3
+ "version": "0.6.0-beta.1",
4
4
  "description": "Privacy-preserving identity verification using passports and ID cards",
5
5
  "author": "ZKPassport",
6
6
  "license": "Apache-2.0",
@@ -31,13 +31,13 @@
31
31
  "sdk"
32
32
  ],
33
33
  "dependencies": {
34
- "@aztec/bb.js": "^0.82.2",
34
+ "@aztec/bb.js": "1.0.0",
35
35
  "@noble/ciphers": "^1.2.1",
36
36
  "@noble/hashes": "^1.7.2",
37
37
  "@noble/secp256k1": "^2.2.3",
38
- "@obsidion/bridge": "^0.10.3-beta.1",
39
- "@zkpassport/registry": "0.5.3",
40
- "@zkpassport/utils": "0.16.2",
38
+ "@obsidion/bridge": "^0.10.4",
39
+ "@zkpassport/registry": "0.6.0",
40
+ "@zkpassport/utils": "0.17.0",
41
41
  "buffer": "^6.0.3",
42
42
  "i18n-iso-countries": "^7.12.0",
43
43
  "pako": "^2.1.0",