@zkpassport/sdk 0.8.4 → 0.8.6
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.
- package/dist/cjs/index.cjs +26 -16
- package/dist/esm/index.js +21 -10
- package/package.json +2 -2
package/dist/cjs/index.cjs
CHANGED
|
@@ -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.
|
|
859
|
+
var VERSION = "0.8.5";
|
|
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") {
|
|
@@ -973,7 +973,6 @@ var ZKPassport = class {
|
|
|
973
973
|
for (const field of fields) {
|
|
974
974
|
for (const key in this.topicToConfig[topic][field]) {
|
|
975
975
|
switch (key) {
|
|
976
|
-
case "eq":
|
|
977
976
|
case "disclose":
|
|
978
977
|
if (field !== "age" && !neededCircuits.includes("disclose_bytes")) {
|
|
979
978
|
neededCircuits.push("disclose_bytes");
|
|
@@ -981,6 +980,17 @@ var ZKPassport = class {
|
|
|
981
980
|
neededCircuits.push("compare_age");
|
|
982
981
|
}
|
|
983
982
|
break;
|
|
983
|
+
case "eq":
|
|
984
|
+
if (field !== "age" && field !== "birthdate" && field !== "expiry_date" && !neededCircuits.includes("disclose_bytes")) {
|
|
985
|
+
neededCircuits.push("disclose_bytes");
|
|
986
|
+
} else if (field === "age" && !neededCircuits.includes("compare_age")) {
|
|
987
|
+
neededCircuits.push("compare_age");
|
|
988
|
+
} else if (field === "birthdate" && !neededCircuits.includes("compare_birthdate")) {
|
|
989
|
+
neededCircuits.push("compare_birthdate");
|
|
990
|
+
} else if (field === "expiry_date" && !neededCircuits.includes("compare_expiry")) {
|
|
991
|
+
neededCircuits.push("compare_expiry");
|
|
992
|
+
}
|
|
993
|
+
break;
|
|
984
994
|
case "gte":
|
|
985
995
|
case "gt":
|
|
986
996
|
case "lte":
|
|
@@ -1582,7 +1592,7 @@ var ZKPassport = class {
|
|
|
1582
1592
|
};
|
|
1583
1593
|
}
|
|
1584
1594
|
}
|
|
1585
|
-
if (!queryResult.age.lt && !queryResult.age.range && maxAge != 0) {
|
|
1595
|
+
if (!queryResult.age.lt && !queryResult.age.lte && !queryResult.age.eq && !queryResult.age.range && maxAge != 0) {
|
|
1586
1596
|
console.warn("Maximum age should be equal to 0");
|
|
1587
1597
|
isCorrect = false;
|
|
1588
1598
|
queryResultErrors.age = {
|
|
@@ -1594,7 +1604,7 @@ var ZKPassport = class {
|
|
|
1594
1604
|
}
|
|
1595
1605
|
};
|
|
1596
1606
|
}
|
|
1597
|
-
if (!queryResult.age.gte && !queryResult.age.range && minAge != 0) {
|
|
1607
|
+
if (!queryResult.age.gte && !queryResult.age.gt && !queryResult.age.eq && !queryResult.age.range && minAge != 0) {
|
|
1598
1608
|
console.warn("Minimum age should be equal to 0");
|
|
1599
1609
|
isCorrect = false;
|
|
1600
1610
|
queryResultErrors.age = {
|
|
@@ -1707,7 +1717,7 @@ var ZKPassport = class {
|
|
|
1707
1717
|
};
|
|
1708
1718
|
}
|
|
1709
1719
|
}
|
|
1710
|
-
if (!queryResult.birthdate.lte && !queryResult.birthdate.range && !(0, import_utils.areDatesEqual)(maxDate, DEFAULT_DATE_VALUE)) {
|
|
1720
|
+
if (!queryResult.birthdate.lte && !queryResult.birthdate.lt && !queryResult.birthdate.eq && !queryResult.birthdate.range && !(0, import_utils.areDatesEqual)(maxDate, DEFAULT_DATE_VALUE)) {
|
|
1711
1721
|
console.warn("Maximum birthdate should be equal to default date value");
|
|
1712
1722
|
isCorrect = false;
|
|
1713
1723
|
queryResultErrors.birthdate = {
|
|
@@ -1719,7 +1729,7 @@ var ZKPassport = class {
|
|
|
1719
1729
|
}
|
|
1720
1730
|
};
|
|
1721
1731
|
}
|
|
1722
|
-
if (!queryResult.birthdate.gte && !queryResult.birthdate.range && !(0, import_utils.areDatesEqual)(minDate, DEFAULT_DATE_VALUE)) {
|
|
1732
|
+
if (!queryResult.birthdate.gte && !queryResult.birthdate.gt && !queryResult.birthdate.eq && !queryResult.birthdate.range && !(0, import_utils.areDatesEqual)(minDate, DEFAULT_DATE_VALUE)) {
|
|
1723
1733
|
console.warn("Minimum birthdate should be equal to default date value");
|
|
1724
1734
|
isCorrect = false;
|
|
1725
1735
|
queryResultErrors.birthdate = {
|
|
@@ -1815,7 +1825,7 @@ var ZKPassport = class {
|
|
|
1815
1825
|
};
|
|
1816
1826
|
}
|
|
1817
1827
|
}
|
|
1818
|
-
if (!queryResult.expiry_date.lte && !queryResult.expiry_date.range && !(0, import_utils.areDatesEqual)(maxDate, DEFAULT_DATE_VALUE)) {
|
|
1828
|
+
if (!queryResult.expiry_date.lte && !queryResult.expiry_date.lt && !queryResult.expiry_date.eq && !queryResult.expiry_date.range && !(0, import_utils.areDatesEqual)(maxDate, DEFAULT_DATE_VALUE)) {
|
|
1819
1829
|
console.warn("Maximum expiry date should be equal to default date value");
|
|
1820
1830
|
isCorrect = false;
|
|
1821
1831
|
queryResultErrors.expiry_date = {
|
|
@@ -1827,7 +1837,7 @@ var ZKPassport = class {
|
|
|
1827
1837
|
}
|
|
1828
1838
|
};
|
|
1829
1839
|
}
|
|
1830
|
-
if (!queryResult.expiry_date.gte && !queryResult.expiry_date.range && !(0, import_utils.areDatesEqual)(minDate, DEFAULT_DATE_VALUE)) {
|
|
1840
|
+
if (!queryResult.expiry_date.gte && !queryResult.expiry_date.gt && !queryResult.expiry_date.eq && !queryResult.expiry_date.range && !(0, import_utils.areDatesEqual)(minDate, DEFAULT_DATE_VALUE)) {
|
|
1831
1841
|
console.warn("Minimum expiry date should be equal to default date value");
|
|
1832
1842
|
isCorrect = false;
|
|
1833
1843
|
queryResultErrors.expiry_date = {
|
|
@@ -3260,19 +3270,19 @@ var ZKPassport = class {
|
|
|
3260
3270
|
).map((x) => x.toString(16).padStart(2, "0")).join("");
|
|
3261
3271
|
} else if (circuitName === "compare_age_evm") {
|
|
3262
3272
|
const value = proof.committedInputs[circuitName];
|
|
3263
|
-
const currentDateBytes = Array.from((0,
|
|
3273
|
+
const currentDateBytes = Array.from((0, import_utils.numberToBytesBE)(value.currentDateTimestamp, 8));
|
|
3264
3274
|
compressedCommittedInputs2 = import_utils.ProofType.AGE.toString(16).padStart(2, "0") + currentDateBytes.map((x) => x.toString(16).padStart(2, "0")).join("") + value.minAge.toString(16).padStart(2, "0") + value.maxAge.toString(16).padStart(2, "0");
|
|
3265
3275
|
} else if (circuitName === "compare_birthdate_evm") {
|
|
3266
3276
|
const value = proof.committedInputs[circuitName];
|
|
3267
|
-
const currentDateBytes = Array.from((0,
|
|
3268
|
-
const minDateBytes = Array.from((0,
|
|
3269
|
-
const maxDateBytes = Array.from((0,
|
|
3277
|
+
const currentDateBytes = Array.from((0, import_utils.numberToBytesBE)(value.currentDateTimestamp, 8));
|
|
3278
|
+
const minDateBytes = Array.from((0, import_utils.numberToBytesBE)(value.minDateTimestamp, 8));
|
|
3279
|
+
const maxDateBytes = Array.from((0, import_utils.numberToBytesBE)(value.maxDateTimestamp, 8));
|
|
3270
3280
|
compressedCommittedInputs2 = import_utils.ProofType.BIRTHDATE.toString(16).padStart(2, "0") + currentDateBytes.map((x) => x.toString(16).padStart(2, "0")).join("") + minDateBytes.map((x) => x.toString(16).padStart(2, "0")).join("") + maxDateBytes.map((x) => x.toString(16).padStart(2, "0")).join("");
|
|
3271
3281
|
} else if (circuitName === "compare_expiry_evm") {
|
|
3272
3282
|
const value = proof.committedInputs[circuitName];
|
|
3273
|
-
const currentDateBytes = Array.from((0,
|
|
3274
|
-
const minDateBytes = Array.from((0,
|
|
3275
|
-
const maxDateBytes = Array.from((0,
|
|
3283
|
+
const currentDateBytes = Array.from((0, import_utils.numberToBytesBE)(value.currentDateTimestamp, 8));
|
|
3284
|
+
const minDateBytes = Array.from((0, import_utils.numberToBytesBE)(value.minDateTimestamp, 8));
|
|
3285
|
+
const maxDateBytes = Array.from((0, import_utils.numberToBytesBE)(value.maxDateTimestamp, 8));
|
|
3276
3286
|
compressedCommittedInputs2 = import_utils.ProofType.EXPIRY_DATE.toString(16).padStart(2, "0") + currentDateBytes.map((x) => x.toString(16).padStart(2, "0")).join("") + minDateBytes.map((x) => x.toString(16).padStart(2, "0")).join("") + maxDateBytes.map((x) => x.toString(16).padStart(2, "0")).join("");
|
|
3277
3287
|
} else if (circuitName === "disclose_bytes_evm") {
|
|
3278
3288
|
const value = proof.committedInputs[circuitName];
|
|
@@ -3282,7 +3292,7 @@ var ZKPassport = class {
|
|
|
3282
3292
|
compressedCommittedInputs2 = import_utils.ProofType.BIND.toString(16).padStart(2, "0") + (0, import_utils.rightPadArrayWithZeros)((0, import_utils.formatBoundData)(value.data), 500).map((x) => x.toString(16).padStart(2, "0")).join("");
|
|
3283
3293
|
} else if (circuitName === "exclusion_check_sanctions_evm") {
|
|
3284
3294
|
const value = proof.committedInputs[circuitName];
|
|
3285
|
-
compressedCommittedInputs2 = import_utils.ProofType.SANCTIONS_EXCLUSION.toString(16).padStart(2, "0") + Array.from((0,
|
|
3295
|
+
compressedCommittedInputs2 = import_utils.ProofType.SANCTIONS_EXCLUSION.toString(16).padStart(2, "0") + Array.from((0, import_utils.numberToBytesBE)(BigInt(value.rootHash), 32)).map((x) => x.toString(16).padStart(2, "0")).join("");
|
|
3286
3296
|
} else {
|
|
3287
3297
|
throw new Error(`Unsupported circuit for EVM verification: ${circuitName}`);
|
|
3288
3298
|
}
|
package/dist/esm/index.js
CHANGED
|
@@ -52,9 +52,10 @@ import {
|
|
|
52
52
|
getBirthdateMinDateTimestamp,
|
|
53
53
|
getBirthdateMaxDateTimestamp,
|
|
54
54
|
SanctionsBuilder,
|
|
55
|
-
SECONDS_BETWEEN_1900_AND_1970
|
|
55
|
+
SECONDS_BETWEEN_1900_AND_1970,
|
|
56
|
+
numberToBytesBE
|
|
56
57
|
} from "@zkpassport/utils";
|
|
57
|
-
import { bytesToHex
|
|
58
|
+
import { bytesToHex } from "@noble/ciphers/utils";
|
|
58
59
|
import i18en from "i18n-iso-countries/langs/en.json";
|
|
59
60
|
import { Buffer } from "buffer/";
|
|
60
61
|
import { sha256 } from "@noble/hashes/sha2";
|
|
@@ -862,7 +863,7 @@ import {
|
|
|
862
863
|
ASEAN_COUNTRIES,
|
|
863
864
|
MERCOSUR_COUNTRIES
|
|
864
865
|
} from "@zkpassport/utils";
|
|
865
|
-
var VERSION = "0.8.
|
|
866
|
+
var VERSION = "0.8.5";
|
|
866
867
|
var DEFAULT_DATE_VALUE = /* @__PURE__ */ new Date(0);
|
|
867
868
|
var DEFAULT_VALIDITY = 7 * 24 * 60 * 60;
|
|
868
869
|
if (typeof globalThis.Buffer === "undefined") {
|
|
@@ -979,7 +980,6 @@ var ZKPassport = class {
|
|
|
979
980
|
for (const field of fields) {
|
|
980
981
|
for (const key in this.topicToConfig[topic][field]) {
|
|
981
982
|
switch (key) {
|
|
982
|
-
case "eq":
|
|
983
983
|
case "disclose":
|
|
984
984
|
if (field !== "age" && !neededCircuits.includes("disclose_bytes")) {
|
|
985
985
|
neededCircuits.push("disclose_bytes");
|
|
@@ -987,6 +987,17 @@ var ZKPassport = class {
|
|
|
987
987
|
neededCircuits.push("compare_age");
|
|
988
988
|
}
|
|
989
989
|
break;
|
|
990
|
+
case "eq":
|
|
991
|
+
if (field !== "age" && field !== "birthdate" && field !== "expiry_date" && !neededCircuits.includes("disclose_bytes")) {
|
|
992
|
+
neededCircuits.push("disclose_bytes");
|
|
993
|
+
} else if (field === "age" && !neededCircuits.includes("compare_age")) {
|
|
994
|
+
neededCircuits.push("compare_age");
|
|
995
|
+
} else if (field === "birthdate" && !neededCircuits.includes("compare_birthdate")) {
|
|
996
|
+
neededCircuits.push("compare_birthdate");
|
|
997
|
+
} else if (field === "expiry_date" && !neededCircuits.includes("compare_expiry")) {
|
|
998
|
+
neededCircuits.push("compare_expiry");
|
|
999
|
+
}
|
|
1000
|
+
break;
|
|
990
1001
|
case "gte":
|
|
991
1002
|
case "gt":
|
|
992
1003
|
case "lte":
|
|
@@ -1588,7 +1599,7 @@ var ZKPassport = class {
|
|
|
1588
1599
|
};
|
|
1589
1600
|
}
|
|
1590
1601
|
}
|
|
1591
|
-
if (!queryResult.age.lt && !queryResult.age.range && maxAge != 0) {
|
|
1602
|
+
if (!queryResult.age.lt && !queryResult.age.lte && !queryResult.age.eq && !queryResult.age.range && maxAge != 0) {
|
|
1592
1603
|
console.warn("Maximum age should be equal to 0");
|
|
1593
1604
|
isCorrect = false;
|
|
1594
1605
|
queryResultErrors.age = {
|
|
@@ -1600,7 +1611,7 @@ var ZKPassport = class {
|
|
|
1600
1611
|
}
|
|
1601
1612
|
};
|
|
1602
1613
|
}
|
|
1603
|
-
if (!queryResult.age.gte && !queryResult.age.range && minAge != 0) {
|
|
1614
|
+
if (!queryResult.age.gte && !queryResult.age.gt && !queryResult.age.eq && !queryResult.age.range && minAge != 0) {
|
|
1604
1615
|
console.warn("Minimum age should be equal to 0");
|
|
1605
1616
|
isCorrect = false;
|
|
1606
1617
|
queryResultErrors.age = {
|
|
@@ -1713,7 +1724,7 @@ var ZKPassport = class {
|
|
|
1713
1724
|
};
|
|
1714
1725
|
}
|
|
1715
1726
|
}
|
|
1716
|
-
if (!queryResult.birthdate.lte && !queryResult.birthdate.range && !areDatesEqual(maxDate, DEFAULT_DATE_VALUE)) {
|
|
1727
|
+
if (!queryResult.birthdate.lte && !queryResult.birthdate.lt && !queryResult.birthdate.eq && !queryResult.birthdate.range && !areDatesEqual(maxDate, DEFAULT_DATE_VALUE)) {
|
|
1717
1728
|
console.warn("Maximum birthdate should be equal to default date value");
|
|
1718
1729
|
isCorrect = false;
|
|
1719
1730
|
queryResultErrors.birthdate = {
|
|
@@ -1725,7 +1736,7 @@ var ZKPassport = class {
|
|
|
1725
1736
|
}
|
|
1726
1737
|
};
|
|
1727
1738
|
}
|
|
1728
|
-
if (!queryResult.birthdate.gte && !queryResult.birthdate.range && !areDatesEqual(minDate, DEFAULT_DATE_VALUE)) {
|
|
1739
|
+
if (!queryResult.birthdate.gte && !queryResult.birthdate.gt && !queryResult.birthdate.eq && !queryResult.birthdate.range && !areDatesEqual(minDate, DEFAULT_DATE_VALUE)) {
|
|
1729
1740
|
console.warn("Minimum birthdate should be equal to default date value");
|
|
1730
1741
|
isCorrect = false;
|
|
1731
1742
|
queryResultErrors.birthdate = {
|
|
@@ -1821,7 +1832,7 @@ var ZKPassport = class {
|
|
|
1821
1832
|
};
|
|
1822
1833
|
}
|
|
1823
1834
|
}
|
|
1824
|
-
if (!queryResult.expiry_date.lte && !queryResult.expiry_date.range && !areDatesEqual(maxDate, DEFAULT_DATE_VALUE)) {
|
|
1835
|
+
if (!queryResult.expiry_date.lte && !queryResult.expiry_date.lt && !queryResult.expiry_date.eq && !queryResult.expiry_date.range && !areDatesEqual(maxDate, DEFAULT_DATE_VALUE)) {
|
|
1825
1836
|
console.warn("Maximum expiry date should be equal to default date value");
|
|
1826
1837
|
isCorrect = false;
|
|
1827
1838
|
queryResultErrors.expiry_date = {
|
|
@@ -1833,7 +1844,7 @@ var ZKPassport = class {
|
|
|
1833
1844
|
}
|
|
1834
1845
|
};
|
|
1835
1846
|
}
|
|
1836
|
-
if (!queryResult.expiry_date.gte && !queryResult.expiry_date.range && !areDatesEqual(minDate, DEFAULT_DATE_VALUE)) {
|
|
1847
|
+
if (!queryResult.expiry_date.gte && !queryResult.expiry_date.gt && !queryResult.expiry_date.eq && !queryResult.expiry_date.range && !areDatesEqual(minDate, DEFAULT_DATE_VALUE)) {
|
|
1837
1848
|
console.warn("Minimum expiry date should be equal to default date value");
|
|
1838
1849
|
isCorrect = false;
|
|
1839
1850
|
queryResultErrors.expiry_date = {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zkpassport/sdk",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.6",
|
|
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.
|
|
40
|
+
"@zkpassport/utils": "0.22.12",
|
|
41
41
|
"buffer": "^6.0.3",
|
|
42
42
|
"i18n-iso-countries": "^7.12.0",
|
|
43
43
|
"pako": "^2.1.0",
|