@zkpassport/sdk 0.8.3-beta.1 → 0.8.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.
@@ -856,7 +856,7 @@ var ZKPassportVerifier_default = {
856
856
  var import_registry = require("@zkpassport/registry");
857
857
  var import_bridge = require("@obsidion/bridge");
858
858
  var import_utils4 = require("@zkpassport/utils");
859
- var VERSION = "0.8.0";
859
+ var VERSION = "0.8.4";
860
860
  var DEFAULT_DATE_VALUE = /* @__PURE__ */ new Date(0);
861
861
  var DEFAULT_VALIDITY = 7 * 24 * 60 * 60;
862
862
  if (typeof globalThis.Buffer === "undefined") {
@@ -1085,10 +1085,10 @@ var ZKPassport = class {
1085
1085
  }
1086
1086
  return this.getZkPassportRequest(topic);
1087
1087
  },
1088
- /*gt: <T extends NumericalIDCredential>(key: T, value: IDCredentialValue<T>) => {
1089
- numericalCompare('gt', key, value, topic, this.topicToConfig)
1090
- return this.getZkPassportRequest(topic)
1091
- },*/
1088
+ gt: (key, value) => {
1089
+ numericalCompare("gt", key, value, topic, this.topicToConfig);
1090
+ return this.getZkPassportRequest(topic);
1091
+ },
1092
1092
  lte: (key, value) => {
1093
1093
  numericalCompare("lte", key, value, topic, this.topicToConfig);
1094
1094
  return this.getZkPassportRequest(topic);
@@ -1658,16 +1658,18 @@ var ZKPassport = class {
1658
1658
  0
1659
1659
  );
1660
1660
  const minDate = (0, import_utils.getBirthdateMinDateTimestamp)(
1661
- proof.committedInputs?.compare_birthdate
1661
+ proof.committedInputs?.compare_birthdate,
1662
+ -1 * import_utils.SECONDS_BETWEEN_1900_AND_1970
1662
1663
  );
1663
1664
  const maxDate = (0, import_utils.getBirthdateMaxDateTimestamp)(
1664
- proof.committedInputs?.compare_birthdate
1665
+ proof.committedInputs?.compare_birthdate,
1666
+ -1 * import_utils.SECONDS_BETWEEN_1900_AND_1970
1665
1667
  );
1666
1668
  const currentDate = (0, import_utils.getCurrentDateFromCommittedInputs)(
1667
1669
  proof.committedInputs?.compare_birthdate
1668
1670
  );
1669
1671
  if (queryResult.birthdate) {
1670
- if (queryResult.birthdate.gte && queryResult.birthdate.gte.result && minDate !== queryResult.birthdate.gte.expected) {
1672
+ if (queryResult.birthdate.gte && queryResult.birthdate.gte.result && !(0, import_utils.areDatesEqual)(minDate, queryResult.birthdate.gte.expected)) {
1671
1673
  console.warn("Birthdate is not greater than or equal to the expected birthdate");
1672
1674
  isCorrect = false;
1673
1675
  queryResultErrors.birthdate = {
@@ -1679,7 +1681,7 @@ var ZKPassport = class {
1679
1681
  }
1680
1682
  };
1681
1683
  }
1682
- if (queryResult.birthdate.lte && queryResult.birthdate.lte.result && maxDate !== queryResult.birthdate.lte.expected) {
1684
+ if (queryResult.birthdate.lte && queryResult.birthdate.lte.result && !(0, import_utils.areDatesEqual)(maxDate, queryResult.birthdate.lte.expected)) {
1683
1685
  console.warn("Birthdate is not less than the expected birthdate");
1684
1686
  isCorrect = false;
1685
1687
  queryResultErrors.birthdate = {
@@ -1692,7 +1694,7 @@ var ZKPassport = class {
1692
1694
  };
1693
1695
  }
1694
1696
  if (queryResult.birthdate.range) {
1695
- if (queryResult.birthdate.range.result && (minDate !== queryResult.birthdate.range.expected[0] || maxDate !== queryResult.birthdate.range.expected[1])) {
1697
+ if (queryResult.birthdate.range.result && (!(0, import_utils.areDatesEqual)(minDate, queryResult.birthdate.range.expected[0]) || !(0, import_utils.areDatesEqual)(maxDate, queryResult.birthdate.range.expected[1]))) {
1696
1698
  console.warn("Birthdate is not in the expected range");
1697
1699
  isCorrect = false;
1698
1700
  queryResultErrors.birthdate = {
@@ -1775,7 +1777,7 @@ var ZKPassport = class {
1775
1777
  proof.committedInputs?.compare_expiry
1776
1778
  );
1777
1779
  if (queryResult.expiry_date) {
1778
- if (queryResult.expiry_date.gte && queryResult.expiry_date.gte.result && minDate !== queryResult.expiry_date.gte.expected) {
1780
+ if (queryResult.expiry_date.gte && queryResult.expiry_date.gte.result && !(0, import_utils.areDatesEqual)(minDate, queryResult.expiry_date.gte.expected)) {
1779
1781
  console.warn("Expiry date is not greater than or equal to the expected expiry date");
1780
1782
  isCorrect = false;
1781
1783
  queryResultErrors.expiry_date = {
@@ -1787,7 +1789,7 @@ var ZKPassport = class {
1787
1789
  }
1788
1790
  };
1789
1791
  }
1790
- if (queryResult.expiry_date.lte && queryResult.expiry_date.lte.result && maxDate !== queryResult.expiry_date.lte.expected) {
1792
+ if (queryResult.expiry_date.lte && queryResult.expiry_date.lte.result && !(0, import_utils.areDatesEqual)(maxDate, queryResult.expiry_date.lte.expected)) {
1791
1793
  console.warn("Expiry date is not less than the expected expiry date");
1792
1794
  isCorrect = false;
1793
1795
  queryResultErrors.expiry_date = {
@@ -1800,7 +1802,7 @@ var ZKPassport = class {
1800
1802
  };
1801
1803
  }
1802
1804
  if (queryResult.expiry_date.range) {
1803
- if (queryResult.expiry_date.range.result && (minDate !== queryResult.expiry_date.range.expected[0] || maxDate !== queryResult.expiry_date.range.expected[1])) {
1805
+ if (queryResult.expiry_date.range.result && (!(0, import_utils.areDatesEqual)(minDate, queryResult.expiry_date.range.expected[0]) || !(0, import_utils.areDatesEqual)(maxDate, queryResult.expiry_date.range.expected[1]))) {
1804
1806
  console.warn("Expiry date is not in the expected range");
1805
1807
  isCorrect = false;
1806
1808
  queryResultErrors.expiry_date = {
@@ -2308,12 +2310,14 @@ var ZKPassport = class {
2308
2310
  import_utils.ProofType.BIRTHDATE,
2309
2311
  birthdateCommittedInputs.currentDateTimestamp,
2310
2312
  birthdateCommittedInputs.minDateTimestamp,
2311
- birthdateCommittedInputs.maxDateTimestamp
2313
+ birthdateCommittedInputs.maxDateTimestamp,
2314
+ 0
2312
2315
  ) : await (0, import_utils.getDateParameterCommitment)(
2313
2316
  import_utils.ProofType.BIRTHDATE,
2314
2317
  birthdateCommittedInputs.currentDateTimestamp,
2315
2318
  birthdateCommittedInputs.minDateTimestamp,
2316
- birthdateCommittedInputs.maxDateTimestamp
2319
+ birthdateCommittedInputs.maxDateTimestamp,
2320
+ 0
2317
2321
  );
2318
2322
  if (!paramCommitments.includes(birthdateParameterCommitment)) {
2319
2323
  console.warn("This proof does not verify the birthdate");
@@ -2748,7 +2752,8 @@ var ZKPassport = class {
2748
2752
  import_utils.ProofType.BIRTHDATE,
2749
2753
  committedInputs.currentDateTimestamp,
2750
2754
  committedInputs.minDateTimestamp,
2751
- committedInputs.maxDateTimestamp
2755
+ committedInputs.maxDateTimestamp,
2756
+ 0
2752
2757
  );
2753
2758
  if (paramCommitment !== calculatedParamCommitment) {
2754
2759
  console.warn(
@@ -115,18 +115,24 @@ type QueryBuilder = {
115
115
  * @param value The value of the attribute you require.
116
116
  */
117
117
  gte: <T extends NumericalIDCredential>(key: T, value: IDCredentialValue<T>) => QueryBuilder;
118
+ /**
119
+ * Requires this attribute to be greater than the provided value.
120
+ * @param key The attribute to compare.
121
+ * @param value The value of the attribute you require.
122
+ */
123
+ gt: <T extends NumericalIDCredential>(key: T, value: IDCredentialValue<T>) => QueryBuilder;
118
124
  /**
119
125
  * Requires this attribute to be less than or equal to the provided value.
120
126
  * @param key The attribute to compare.
121
127
  * @param value The value of the attribute you require.
122
128
  */
123
- lte: <T extends "birthdate" | "expiry_date">(key: T, value: IDCredentialValue<T>) => QueryBuilder;
129
+ lte: <T extends NumericalIDCredential>(key: T, value: IDCredentialValue<T>) => QueryBuilder;
124
130
  /**
125
131
  * Requires this attribute to be less than the provided value.
126
132
  * @param key The attribute to compare.
127
133
  * @param value The value of the attribute you require.
128
134
  */
129
- lt: <T extends "age">(key: T, value: IDCredentialValue<T>) => QueryBuilder;
135
+ lt: <T extends NumericalIDCredential>(key: T, value: IDCredentialValue<T>) => QueryBuilder;
130
136
  /**
131
137
  * Requires this attribute to be included in the provided range.
132
138
  * @param key The attribute to compare.
@@ -166,6 +172,7 @@ type QueryBuilder = {
166
172
  */
167
173
  sanctions: (countries?: SanctionsCountries, lists?: SanctionsLists) => QueryBuilder;
168
174
  /**
175
+ * This feature is not available yet in the public release of the app.
169
176
  * Requires that the ID holder's face matches the photo on the ID.
170
177
  * @param mode The mode to use for the face match. Defaults to "regular".
171
178
  * @param mode "strict" - The user will have to go through an extensive liveness check to prevent spoofing making it more secure.
@@ -115,18 +115,24 @@ type QueryBuilder = {
115
115
  * @param value The value of the attribute you require.
116
116
  */
117
117
  gte: <T extends NumericalIDCredential>(key: T, value: IDCredentialValue<T>) => QueryBuilder;
118
+ /**
119
+ * Requires this attribute to be greater than the provided value.
120
+ * @param key The attribute to compare.
121
+ * @param value The value of the attribute you require.
122
+ */
123
+ gt: <T extends NumericalIDCredential>(key: T, value: IDCredentialValue<T>) => QueryBuilder;
118
124
  /**
119
125
  * Requires this attribute to be less than or equal to the provided value.
120
126
  * @param key The attribute to compare.
121
127
  * @param value The value of the attribute you require.
122
128
  */
123
- lte: <T extends "birthdate" | "expiry_date">(key: T, value: IDCredentialValue<T>) => QueryBuilder;
129
+ lte: <T extends NumericalIDCredential>(key: T, value: IDCredentialValue<T>) => QueryBuilder;
124
130
  /**
125
131
  * Requires this attribute to be less than the provided value.
126
132
  * @param key The attribute to compare.
127
133
  * @param value The value of the attribute you require.
128
134
  */
129
- lt: <T extends "age">(key: T, value: IDCredentialValue<T>) => QueryBuilder;
135
+ lt: <T extends NumericalIDCredential>(key: T, value: IDCredentialValue<T>) => QueryBuilder;
130
136
  /**
131
137
  * Requires this attribute to be included in the provided range.
132
138
  * @param key The attribute to compare.
@@ -166,6 +172,7 @@ type QueryBuilder = {
166
172
  */
167
173
  sanctions: (countries?: SanctionsCountries, lists?: SanctionsLists) => QueryBuilder;
168
174
  /**
175
+ * This feature is not available yet in the public release of the app.
169
176
  * Requires that the ID holder's face matches the photo on the ID.
170
177
  * @param mode The mode to use for the face match. Defaults to "regular".
171
178
  * @param mode "strict" - The user will have to go through an extensive liveness check to prevent spoofing making it more secure.
package/dist/esm/index.js CHANGED
@@ -51,7 +51,8 @@ import {
51
51
  formatQueryResultDates,
52
52
  getBirthdateMinDateTimestamp,
53
53
  getBirthdateMaxDateTimestamp,
54
- SanctionsBuilder
54
+ SanctionsBuilder,
55
+ SECONDS_BETWEEN_1900_AND_1970
55
56
  } from "@zkpassport/utils";
56
57
  import { bytesToHex, numberToBytesBE } from "@noble/ciphers/utils";
57
58
  import i18en from "i18n-iso-countries/langs/en.json";
@@ -861,7 +862,7 @@ import {
861
862
  ASEAN_COUNTRIES,
862
863
  MERCOSUR_COUNTRIES
863
864
  } from "@zkpassport/utils";
864
- var VERSION = "0.8.0";
865
+ var VERSION = "0.8.4";
865
866
  var DEFAULT_DATE_VALUE = /* @__PURE__ */ new Date(0);
866
867
  var DEFAULT_VALIDITY = 7 * 24 * 60 * 60;
867
868
  if (typeof globalThis.Buffer === "undefined") {
@@ -1090,10 +1091,10 @@ var ZKPassport = class {
1090
1091
  }
1091
1092
  return this.getZkPassportRequest(topic);
1092
1093
  },
1093
- /*gt: <T extends NumericalIDCredential>(key: T, value: IDCredentialValue<T>) => {
1094
- numericalCompare('gt', key, value, topic, this.topicToConfig)
1095
- return this.getZkPassportRequest(topic)
1096
- },*/
1094
+ gt: (key, value) => {
1095
+ numericalCompare("gt", key, value, topic, this.topicToConfig);
1096
+ return this.getZkPassportRequest(topic);
1097
+ },
1097
1098
  lte: (key, value) => {
1098
1099
  numericalCompare("lte", key, value, topic, this.topicToConfig);
1099
1100
  return this.getZkPassportRequest(topic);
@@ -1663,16 +1664,18 @@ var ZKPassport = class {
1663
1664
  0
1664
1665
  );
1665
1666
  const minDate = getBirthdateMinDateTimestamp(
1666
- proof.committedInputs?.compare_birthdate
1667
+ proof.committedInputs?.compare_birthdate,
1668
+ -1 * SECONDS_BETWEEN_1900_AND_1970
1667
1669
  );
1668
1670
  const maxDate = getBirthdateMaxDateTimestamp(
1669
- proof.committedInputs?.compare_birthdate
1671
+ proof.committedInputs?.compare_birthdate,
1672
+ -1 * SECONDS_BETWEEN_1900_AND_1970
1670
1673
  );
1671
1674
  const currentDate = getCurrentDateFromCommittedInputs(
1672
1675
  proof.committedInputs?.compare_birthdate
1673
1676
  );
1674
1677
  if (queryResult.birthdate) {
1675
- if (queryResult.birthdate.gte && queryResult.birthdate.gte.result && minDate !== queryResult.birthdate.gte.expected) {
1678
+ if (queryResult.birthdate.gte && queryResult.birthdate.gte.result && !areDatesEqual(minDate, queryResult.birthdate.gte.expected)) {
1676
1679
  console.warn("Birthdate is not greater than or equal to the expected birthdate");
1677
1680
  isCorrect = false;
1678
1681
  queryResultErrors.birthdate = {
@@ -1684,7 +1687,7 @@ var ZKPassport = class {
1684
1687
  }
1685
1688
  };
1686
1689
  }
1687
- if (queryResult.birthdate.lte && queryResult.birthdate.lte.result && maxDate !== queryResult.birthdate.lte.expected) {
1690
+ if (queryResult.birthdate.lte && queryResult.birthdate.lte.result && !areDatesEqual(maxDate, queryResult.birthdate.lte.expected)) {
1688
1691
  console.warn("Birthdate is not less than the expected birthdate");
1689
1692
  isCorrect = false;
1690
1693
  queryResultErrors.birthdate = {
@@ -1697,7 +1700,7 @@ var ZKPassport = class {
1697
1700
  };
1698
1701
  }
1699
1702
  if (queryResult.birthdate.range) {
1700
- if (queryResult.birthdate.range.result && (minDate !== queryResult.birthdate.range.expected[0] || maxDate !== queryResult.birthdate.range.expected[1])) {
1703
+ if (queryResult.birthdate.range.result && (!areDatesEqual(minDate, queryResult.birthdate.range.expected[0]) || !areDatesEqual(maxDate, queryResult.birthdate.range.expected[1]))) {
1701
1704
  console.warn("Birthdate is not in the expected range");
1702
1705
  isCorrect = false;
1703
1706
  queryResultErrors.birthdate = {
@@ -1780,7 +1783,7 @@ var ZKPassport = class {
1780
1783
  proof.committedInputs?.compare_expiry
1781
1784
  );
1782
1785
  if (queryResult.expiry_date) {
1783
- if (queryResult.expiry_date.gte && queryResult.expiry_date.gte.result && minDate !== queryResult.expiry_date.gte.expected) {
1786
+ if (queryResult.expiry_date.gte && queryResult.expiry_date.gte.result && !areDatesEqual(minDate, queryResult.expiry_date.gte.expected)) {
1784
1787
  console.warn("Expiry date is not greater than or equal to the expected expiry date");
1785
1788
  isCorrect = false;
1786
1789
  queryResultErrors.expiry_date = {
@@ -1792,7 +1795,7 @@ var ZKPassport = class {
1792
1795
  }
1793
1796
  };
1794
1797
  }
1795
- if (queryResult.expiry_date.lte && queryResult.expiry_date.lte.result && maxDate !== queryResult.expiry_date.lte.expected) {
1798
+ if (queryResult.expiry_date.lte && queryResult.expiry_date.lte.result && !areDatesEqual(maxDate, queryResult.expiry_date.lte.expected)) {
1796
1799
  console.warn("Expiry date is not less than the expected expiry date");
1797
1800
  isCorrect = false;
1798
1801
  queryResultErrors.expiry_date = {
@@ -1805,7 +1808,7 @@ var ZKPassport = class {
1805
1808
  };
1806
1809
  }
1807
1810
  if (queryResult.expiry_date.range) {
1808
- if (queryResult.expiry_date.range.result && (minDate !== queryResult.expiry_date.range.expected[0] || maxDate !== queryResult.expiry_date.range.expected[1])) {
1811
+ if (queryResult.expiry_date.range.result && (!areDatesEqual(minDate, queryResult.expiry_date.range.expected[0]) || !areDatesEqual(maxDate, queryResult.expiry_date.range.expected[1]))) {
1809
1812
  console.warn("Expiry date is not in the expected range");
1810
1813
  isCorrect = false;
1811
1814
  queryResultErrors.expiry_date = {
@@ -2313,12 +2316,14 @@ var ZKPassport = class {
2313
2316
  ProofType.BIRTHDATE,
2314
2317
  birthdateCommittedInputs.currentDateTimestamp,
2315
2318
  birthdateCommittedInputs.minDateTimestamp,
2316
- birthdateCommittedInputs.maxDateTimestamp
2319
+ birthdateCommittedInputs.maxDateTimestamp,
2320
+ 0
2317
2321
  ) : await getDateParameterCommitment(
2318
2322
  ProofType.BIRTHDATE,
2319
2323
  birthdateCommittedInputs.currentDateTimestamp,
2320
2324
  birthdateCommittedInputs.minDateTimestamp,
2321
- birthdateCommittedInputs.maxDateTimestamp
2325
+ birthdateCommittedInputs.maxDateTimestamp,
2326
+ 0
2322
2327
  );
2323
2328
  if (!paramCommitments.includes(birthdateParameterCommitment)) {
2324
2329
  console.warn("This proof does not verify the birthdate");
@@ -2753,7 +2758,8 @@ var ZKPassport = class {
2753
2758
  ProofType.BIRTHDATE,
2754
2759
  committedInputs.currentDateTimestamp,
2755
2760
  committedInputs.minDateTimestamp,
2756
- committedInputs.maxDateTimestamp
2761
+ committedInputs.maxDateTimestamp,
2762
+ 0
2757
2763
  );
2758
2764
  if (paramCommitment !== calculatedParamCommitment) {
2759
2765
  console.warn(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zkpassport/sdk",
3
- "version": "0.8.3-beta.1",
3
+ "version": "0.8.4",
4
4
  "description": "Privacy-preserving identity verification using passports and ID cards",
5
5
  "author": "ZKPassport",
6
6
  "license": "Apache-2.0",
@@ -37,7 +37,7 @@
37
37
  "@noble/secp256k1": "^2.2.3",
38
38
  "@obsidion/bridge": "^0.10.4",
39
39
  "@zkpassport/registry": "0.10.2",
40
- "@zkpassport/utils": "0.22.7",
40
+ "@zkpassport/utils": "0.22.9",
41
41
  "buffer": "^6.0.3",
42
42
  "i18n-iso-countries": "^7.12.0",
43
43
  "pako": "^2.1.0",