@zkpassport/sdk 0.7.0 → 0.7.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.
- package/dist/cjs/index.cjs +13 -34
- package/dist/esm/index.js +16 -35
- package/package.json +2 -2
package/dist/cjs/index.cjs
CHANGED
|
@@ -994,18 +994,7 @@ var ZKPassport = class {
|
|
|
994
994
|
}
|
|
995
995
|
} else if (request.method === "done") {
|
|
996
996
|
noLogger.debug(`User sent the query result`);
|
|
997
|
-
|
|
998
|
-
if (formattedResult.birthdate && formattedResult.birthdate.disclose) {
|
|
999
|
-
formattedResult.birthdate.disclose.result = new Date(
|
|
1000
|
-
formattedResult.birthdate.disclose.result
|
|
1001
|
-
);
|
|
1002
|
-
}
|
|
1003
|
-
if (formattedResult.expiry_date && formattedResult.expiry_date.disclose) {
|
|
1004
|
-
formattedResult.expiry_date.disclose.result = new Date(
|
|
1005
|
-
formattedResult.expiry_date.disclose.result
|
|
1006
|
-
);
|
|
1007
|
-
}
|
|
1008
|
-
this.topicToResults[topic] = formattedResult;
|
|
997
|
+
this.topicToResults[topic] = (0, import_utils.formatQueryResultDates)(request.params);
|
|
1009
998
|
if (this.topicToExpectedProofCount[topic] === this.topicToProofs[topic].length) {
|
|
1010
999
|
await this.handleResult(topic);
|
|
1011
1000
|
}
|
|
@@ -1223,7 +1212,7 @@ var ZKPassport = class {
|
|
|
1223
1212
|
if (queryResult.birthdate) {
|
|
1224
1213
|
const birthdatePassport = disclosedDataPassport.dateOfBirth;
|
|
1225
1214
|
const birthdateIDCard = disclosedDataIDCard.dateOfBirth;
|
|
1226
|
-
if (queryResult.birthdate.eq && queryResult.birthdate.eq.result && queryResult.birthdate.eq.expected
|
|
1215
|
+
if (queryResult.birthdate.eq && queryResult.birthdate.eq.result && !(0, import_utils.areDatesEqual)(queryResult.birthdate.eq.expected, birthdatePassport) && !(0, import_utils.areDatesEqual)(queryResult.birthdate.eq.expected, birthdateIDCard)) {
|
|
1227
1216
|
console.warn("Birthdate does not match the expected birthdate");
|
|
1228
1217
|
isCorrect = false;
|
|
1229
1218
|
queryResultErrors.birthdate.eq = {
|
|
@@ -1232,7 +1221,7 @@ var ZKPassport = class {
|
|
|
1232
1221
|
message: "Birthdate does not match the expected birthdate"
|
|
1233
1222
|
};
|
|
1234
1223
|
}
|
|
1235
|
-
if (queryResult.birthdate.disclose && queryResult.birthdate.disclose.result
|
|
1224
|
+
if (queryResult.birthdate.disclose && !(0, import_utils.areDatesEqual)(queryResult.birthdate.disclose.result, birthdatePassport) && !(0, import_utils.areDatesEqual)(queryResult.birthdate.disclose.result, birthdateIDCard)) {
|
|
1236
1225
|
console.warn("Birthdate does not match the disclosed birthdate in query result");
|
|
1237
1226
|
isCorrect = false;
|
|
1238
1227
|
queryResultErrors.birthdate.disclose = {
|
|
@@ -1245,7 +1234,7 @@ var ZKPassport = class {
|
|
|
1245
1234
|
if (queryResult.expiry_date) {
|
|
1246
1235
|
const expiryDatePassport = disclosedDataPassport.dateOfExpiry;
|
|
1247
1236
|
const expiryDateIDCard = disclosedDataIDCard.dateOfExpiry;
|
|
1248
|
-
if (queryResult.expiry_date.eq && queryResult.expiry_date.eq.result && queryResult.expiry_date.eq.expected
|
|
1237
|
+
if (queryResult.expiry_date.eq && queryResult.expiry_date.eq.result && !(0, import_utils.areDatesEqual)(queryResult.expiry_date.eq.expected, expiryDatePassport) && !(0, import_utils.areDatesEqual)(queryResult.expiry_date.eq.expected, expiryDateIDCard)) {
|
|
1249
1238
|
console.warn("Expiry date does not match the expected expiry date");
|
|
1250
1239
|
isCorrect = false;
|
|
1251
1240
|
queryResultErrors.expiry_date.eq = {
|
|
@@ -1254,7 +1243,7 @@ var ZKPassport = class {
|
|
|
1254
1243
|
message: "Expiry date does not match the expected expiry date"
|
|
1255
1244
|
};
|
|
1256
1245
|
}
|
|
1257
|
-
if (queryResult.expiry_date.disclose && queryResult.expiry_date.disclose.result
|
|
1246
|
+
if (queryResult.expiry_date.disclose && !(0, import_utils.areDatesEqual)(queryResult.expiry_date.disclose.result, expiryDatePassport) && !(0, import_utils.areDatesEqual)(queryResult.expiry_date.disclose.result, expiryDateIDCard)) {
|
|
1258
1247
|
console.warn("Expiry date does not match the disclosed expiry date in query result");
|
|
1259
1248
|
isCorrect = false;
|
|
1260
1249
|
queryResultErrors.expiry_date.disclose = {
|
|
@@ -1524,7 +1513,7 @@ var ZKPassport = class {
|
|
|
1524
1513
|
const currentDate = (0, import_utils.getCurrentDateFromCommittedInputs)(
|
|
1525
1514
|
proof.committedInputs?.compare_age
|
|
1526
1515
|
);
|
|
1527
|
-
if (
|
|
1516
|
+
if (!(0, import_utils.areDatesEqual)(currentDate, today) && !(0, import_utils.areDatesEqual)(currentDate, today.getTime() - 864e5)) {
|
|
1528
1517
|
console.warn("Current date in the proof is too old");
|
|
1529
1518
|
isCorrect = false;
|
|
1530
1519
|
queryResultErrors.age.disclose = {
|
|
@@ -1604,7 +1593,7 @@ var ZKPassport = class {
|
|
|
1604
1593
|
};
|
|
1605
1594
|
}
|
|
1606
1595
|
}
|
|
1607
|
-
if (!queryResult.birthdate.lte && !queryResult.birthdate.range &&
|
|
1596
|
+
if (!queryResult.birthdate.lte && !queryResult.birthdate.range && !(0, import_utils.areDatesEqual)(maxDate, DEFAULT_DATE_VALUE)) {
|
|
1608
1597
|
console.warn("Maximum birthdate should be equal to default date value");
|
|
1609
1598
|
isCorrect = false;
|
|
1610
1599
|
queryResultErrors.birthdate.disclose = {
|
|
@@ -1613,7 +1602,7 @@ var ZKPassport = class {
|
|
|
1613
1602
|
message: "Maximum birthdate should be equal to default date value"
|
|
1614
1603
|
};
|
|
1615
1604
|
}
|
|
1616
|
-
if (!queryResult.birthdate.gte && !queryResult.birthdate.range &&
|
|
1605
|
+
if (!queryResult.birthdate.gte && !queryResult.birthdate.range && !(0, import_utils.areDatesEqual)(minDate, DEFAULT_DATE_VALUE)) {
|
|
1617
1606
|
console.warn("Minimum birthdate should be equal to default date value");
|
|
1618
1607
|
isCorrect = false;
|
|
1619
1608
|
queryResultErrors.birthdate.disclose = {
|
|
@@ -1629,7 +1618,7 @@ var ZKPassport = class {
|
|
|
1629
1618
|
message: "Birthdate is not set in the query result"
|
|
1630
1619
|
};
|
|
1631
1620
|
}
|
|
1632
|
-
if (
|
|
1621
|
+
if (!(0, import_utils.areDatesEqual)(currentDate, today) && !(0, import_utils.areDatesEqual)(currentDate, today.getTime() - 864e5)) {
|
|
1633
1622
|
console.warn("Current date in the proof is too old");
|
|
1634
1623
|
isCorrect = false;
|
|
1635
1624
|
queryResultErrors.age.disclose = {
|
|
@@ -1709,7 +1698,7 @@ var ZKPassport = class {
|
|
|
1709
1698
|
};
|
|
1710
1699
|
}
|
|
1711
1700
|
}
|
|
1712
|
-
if (!queryResult.expiry_date.lte && !queryResult.expiry_date.range &&
|
|
1701
|
+
if (!queryResult.expiry_date.lte && !queryResult.expiry_date.range && !(0, import_utils.areDatesEqual)(maxDate, DEFAULT_DATE_VALUE)) {
|
|
1713
1702
|
console.warn("Maximum expiry date should be equal to default date value");
|
|
1714
1703
|
isCorrect = false;
|
|
1715
1704
|
queryResultErrors.expiry_date.disclose = {
|
|
@@ -1718,7 +1707,7 @@ var ZKPassport = class {
|
|
|
1718
1707
|
message: "Maximum expiry date should be equal to default date value"
|
|
1719
1708
|
};
|
|
1720
1709
|
}
|
|
1721
|
-
if (!queryResult.expiry_date.gte && !queryResult.expiry_date.range &&
|
|
1710
|
+
if (!queryResult.expiry_date.gte && !queryResult.expiry_date.range && !(0, import_utils.areDatesEqual)(minDate, DEFAULT_DATE_VALUE)) {
|
|
1722
1711
|
console.warn("Minimum expiry date should be equal to default date value");
|
|
1723
1712
|
isCorrect = false;
|
|
1724
1713
|
queryResultErrors.expiry_date.disclose = {
|
|
@@ -1734,7 +1723,7 @@ var ZKPassport = class {
|
|
|
1734
1723
|
message: "Expiry date is not set in the query result"
|
|
1735
1724
|
};
|
|
1736
1725
|
}
|
|
1737
|
-
if (
|
|
1726
|
+
if (!(0, import_utils.areDatesEqual)(currentDate, today) && !(0, import_utils.areDatesEqual)(currentDate, today.getTime() - 864e5)) {
|
|
1738
1727
|
console.warn("Current date in the proof is too old");
|
|
1739
1728
|
isCorrect = false;
|
|
1740
1729
|
queryResultErrors.age.disclose = {
|
|
@@ -2865,17 +2854,7 @@ var ZKPassport = class {
|
|
|
2865
2854
|
verified: false
|
|
2866
2855
|
};
|
|
2867
2856
|
}
|
|
2868
|
-
const formattedResult = queryResult;
|
|
2869
|
-
if (formattedResult.birthdate && formattedResult.birthdate.disclose) {
|
|
2870
|
-
formattedResult.birthdate.disclose.result = new Date(
|
|
2871
|
-
formattedResult.birthdate.disclose.result
|
|
2872
|
-
);
|
|
2873
|
-
}
|
|
2874
|
-
if (formattedResult.expiry_date && formattedResult.expiry_date.disclose) {
|
|
2875
|
-
formattedResult.expiry_date.disclose.result = new Date(
|
|
2876
|
-
formattedResult.expiry_date.disclose.result
|
|
2877
|
-
);
|
|
2878
|
-
}
|
|
2857
|
+
const formattedResult = (0, import_utils.formatQueryResultDates)(queryResult);
|
|
2879
2858
|
const { BarretenbergVerifier } = await import("@aztec/bb.js");
|
|
2880
2859
|
if (typeof window === "undefined" && !writingDirectory) {
|
|
2881
2860
|
writingDirectory = "/tmp";
|
package/dist/esm/index.js
CHANGED
|
@@ -46,7 +46,9 @@ import {
|
|
|
46
46
|
getBindEVMParameterCommitment,
|
|
47
47
|
getBindParameterCommitment,
|
|
48
48
|
formatBoundData,
|
|
49
|
-
getCircuitRegistryRootFromOuterProof
|
|
49
|
+
getCircuitRegistryRootFromOuterProof,
|
|
50
|
+
areDatesEqual,
|
|
51
|
+
formatQueryResultDates
|
|
50
52
|
} from "@zkpassport/utils";
|
|
51
53
|
import { bytesToHex } from "@noble/ciphers/utils";
|
|
52
54
|
import i18en from "i18n-iso-countries/langs/en.json";
|
|
@@ -994,18 +996,7 @@ var ZKPassport = class {
|
|
|
994
996
|
}
|
|
995
997
|
} else if (request.method === "done") {
|
|
996
998
|
noLogger.debug(`User sent the query result`);
|
|
997
|
-
|
|
998
|
-
if (formattedResult.birthdate && formattedResult.birthdate.disclose) {
|
|
999
|
-
formattedResult.birthdate.disclose.result = new Date(
|
|
1000
|
-
formattedResult.birthdate.disclose.result
|
|
1001
|
-
);
|
|
1002
|
-
}
|
|
1003
|
-
if (formattedResult.expiry_date && formattedResult.expiry_date.disclose) {
|
|
1004
|
-
formattedResult.expiry_date.disclose.result = new Date(
|
|
1005
|
-
formattedResult.expiry_date.disclose.result
|
|
1006
|
-
);
|
|
1007
|
-
}
|
|
1008
|
-
this.topicToResults[topic] = formattedResult;
|
|
999
|
+
this.topicToResults[topic] = formatQueryResultDates(request.params);
|
|
1009
1000
|
if (this.topicToExpectedProofCount[topic] === this.topicToProofs[topic].length) {
|
|
1010
1001
|
await this.handleResult(topic);
|
|
1011
1002
|
}
|
|
@@ -1223,7 +1214,7 @@ var ZKPassport = class {
|
|
|
1223
1214
|
if (queryResult.birthdate) {
|
|
1224
1215
|
const birthdatePassport = disclosedDataPassport.dateOfBirth;
|
|
1225
1216
|
const birthdateIDCard = disclosedDataIDCard.dateOfBirth;
|
|
1226
|
-
if (queryResult.birthdate.eq && queryResult.birthdate.eq.result && queryResult.birthdate.eq.expected
|
|
1217
|
+
if (queryResult.birthdate.eq && queryResult.birthdate.eq.result && !areDatesEqual(queryResult.birthdate.eq.expected, birthdatePassport) && !areDatesEqual(queryResult.birthdate.eq.expected, birthdateIDCard)) {
|
|
1227
1218
|
console.warn("Birthdate does not match the expected birthdate");
|
|
1228
1219
|
isCorrect = false;
|
|
1229
1220
|
queryResultErrors.birthdate.eq = {
|
|
@@ -1232,7 +1223,7 @@ var ZKPassport = class {
|
|
|
1232
1223
|
message: "Birthdate does not match the expected birthdate"
|
|
1233
1224
|
};
|
|
1234
1225
|
}
|
|
1235
|
-
if (queryResult.birthdate.disclose && queryResult.birthdate.disclose.result
|
|
1226
|
+
if (queryResult.birthdate.disclose && !areDatesEqual(queryResult.birthdate.disclose.result, birthdatePassport) && !areDatesEqual(queryResult.birthdate.disclose.result, birthdateIDCard)) {
|
|
1236
1227
|
console.warn("Birthdate does not match the disclosed birthdate in query result");
|
|
1237
1228
|
isCorrect = false;
|
|
1238
1229
|
queryResultErrors.birthdate.disclose = {
|
|
@@ -1245,7 +1236,7 @@ var ZKPassport = class {
|
|
|
1245
1236
|
if (queryResult.expiry_date) {
|
|
1246
1237
|
const expiryDatePassport = disclosedDataPassport.dateOfExpiry;
|
|
1247
1238
|
const expiryDateIDCard = disclosedDataIDCard.dateOfExpiry;
|
|
1248
|
-
if (queryResult.expiry_date.eq && queryResult.expiry_date.eq.result && queryResult.expiry_date.eq.expected
|
|
1239
|
+
if (queryResult.expiry_date.eq && queryResult.expiry_date.eq.result && !areDatesEqual(queryResult.expiry_date.eq.expected, expiryDatePassport) && !areDatesEqual(queryResult.expiry_date.eq.expected, expiryDateIDCard)) {
|
|
1249
1240
|
console.warn("Expiry date does not match the expected expiry date");
|
|
1250
1241
|
isCorrect = false;
|
|
1251
1242
|
queryResultErrors.expiry_date.eq = {
|
|
@@ -1254,7 +1245,7 @@ var ZKPassport = class {
|
|
|
1254
1245
|
message: "Expiry date does not match the expected expiry date"
|
|
1255
1246
|
};
|
|
1256
1247
|
}
|
|
1257
|
-
if (queryResult.expiry_date.disclose && queryResult.expiry_date.disclose.result
|
|
1248
|
+
if (queryResult.expiry_date.disclose && !areDatesEqual(queryResult.expiry_date.disclose.result, expiryDatePassport) && !areDatesEqual(queryResult.expiry_date.disclose.result, expiryDateIDCard)) {
|
|
1258
1249
|
console.warn("Expiry date does not match the disclosed expiry date in query result");
|
|
1259
1250
|
isCorrect = false;
|
|
1260
1251
|
queryResultErrors.expiry_date.disclose = {
|
|
@@ -1524,7 +1515,7 @@ var ZKPassport = class {
|
|
|
1524
1515
|
const currentDate = getCurrentDateFromCommittedInputs(
|
|
1525
1516
|
proof.committedInputs?.compare_age
|
|
1526
1517
|
);
|
|
1527
|
-
if (currentDate
|
|
1518
|
+
if (!areDatesEqual(currentDate, today) && !areDatesEqual(currentDate, today.getTime() - 864e5)) {
|
|
1528
1519
|
console.warn("Current date in the proof is too old");
|
|
1529
1520
|
isCorrect = false;
|
|
1530
1521
|
queryResultErrors.age.disclose = {
|
|
@@ -1604,7 +1595,7 @@ var ZKPassport = class {
|
|
|
1604
1595
|
};
|
|
1605
1596
|
}
|
|
1606
1597
|
}
|
|
1607
|
-
if (!queryResult.birthdate.lte && !queryResult.birthdate.range && maxDate
|
|
1598
|
+
if (!queryResult.birthdate.lte && !queryResult.birthdate.range && !areDatesEqual(maxDate, DEFAULT_DATE_VALUE)) {
|
|
1608
1599
|
console.warn("Maximum birthdate should be equal to default date value");
|
|
1609
1600
|
isCorrect = false;
|
|
1610
1601
|
queryResultErrors.birthdate.disclose = {
|
|
@@ -1613,7 +1604,7 @@ var ZKPassport = class {
|
|
|
1613
1604
|
message: "Maximum birthdate should be equal to default date value"
|
|
1614
1605
|
};
|
|
1615
1606
|
}
|
|
1616
|
-
if (!queryResult.birthdate.gte && !queryResult.birthdate.range && minDate
|
|
1607
|
+
if (!queryResult.birthdate.gte && !queryResult.birthdate.range && !areDatesEqual(minDate, DEFAULT_DATE_VALUE)) {
|
|
1617
1608
|
console.warn("Minimum birthdate should be equal to default date value");
|
|
1618
1609
|
isCorrect = false;
|
|
1619
1610
|
queryResultErrors.birthdate.disclose = {
|
|
@@ -1629,7 +1620,7 @@ var ZKPassport = class {
|
|
|
1629
1620
|
message: "Birthdate is not set in the query result"
|
|
1630
1621
|
};
|
|
1631
1622
|
}
|
|
1632
|
-
if (currentDate
|
|
1623
|
+
if (!areDatesEqual(currentDate, today) && !areDatesEqual(currentDate, today.getTime() - 864e5)) {
|
|
1633
1624
|
console.warn("Current date in the proof is too old");
|
|
1634
1625
|
isCorrect = false;
|
|
1635
1626
|
queryResultErrors.age.disclose = {
|
|
@@ -1709,7 +1700,7 @@ var ZKPassport = class {
|
|
|
1709
1700
|
};
|
|
1710
1701
|
}
|
|
1711
1702
|
}
|
|
1712
|
-
if (!queryResult.expiry_date.lte && !queryResult.expiry_date.range && maxDate
|
|
1703
|
+
if (!queryResult.expiry_date.lte && !queryResult.expiry_date.range && !areDatesEqual(maxDate, DEFAULT_DATE_VALUE)) {
|
|
1713
1704
|
console.warn("Maximum expiry date should be equal to default date value");
|
|
1714
1705
|
isCorrect = false;
|
|
1715
1706
|
queryResultErrors.expiry_date.disclose = {
|
|
@@ -1718,7 +1709,7 @@ var ZKPassport = class {
|
|
|
1718
1709
|
message: "Maximum expiry date should be equal to default date value"
|
|
1719
1710
|
};
|
|
1720
1711
|
}
|
|
1721
|
-
if (!queryResult.expiry_date.gte && !queryResult.expiry_date.range && minDate
|
|
1712
|
+
if (!queryResult.expiry_date.gte && !queryResult.expiry_date.range && !areDatesEqual(minDate, DEFAULT_DATE_VALUE)) {
|
|
1722
1713
|
console.warn("Minimum expiry date should be equal to default date value");
|
|
1723
1714
|
isCorrect = false;
|
|
1724
1715
|
queryResultErrors.expiry_date.disclose = {
|
|
@@ -1734,7 +1725,7 @@ var ZKPassport = class {
|
|
|
1734
1725
|
message: "Expiry date is not set in the query result"
|
|
1735
1726
|
};
|
|
1736
1727
|
}
|
|
1737
|
-
if (currentDate
|
|
1728
|
+
if (!areDatesEqual(currentDate, today) && !areDatesEqual(currentDate, today.getTime() - 864e5)) {
|
|
1738
1729
|
console.warn("Current date in the proof is too old");
|
|
1739
1730
|
isCorrect = false;
|
|
1740
1731
|
queryResultErrors.age.disclose = {
|
|
@@ -2865,17 +2856,7 @@ var ZKPassport = class {
|
|
|
2865
2856
|
verified: false
|
|
2866
2857
|
};
|
|
2867
2858
|
}
|
|
2868
|
-
const formattedResult = queryResult;
|
|
2869
|
-
if (formattedResult.birthdate && formattedResult.birthdate.disclose) {
|
|
2870
|
-
formattedResult.birthdate.disclose.result = new Date(
|
|
2871
|
-
formattedResult.birthdate.disclose.result
|
|
2872
|
-
);
|
|
2873
|
-
}
|
|
2874
|
-
if (formattedResult.expiry_date && formattedResult.expiry_date.disclose) {
|
|
2875
|
-
formattedResult.expiry_date.disclose.result = new Date(
|
|
2876
|
-
formattedResult.expiry_date.disclose.result
|
|
2877
|
-
);
|
|
2878
|
-
}
|
|
2859
|
+
const formattedResult = formatQueryResultDates(queryResult);
|
|
2879
2860
|
const { BarretenbergVerifier } = await import("@aztec/bb.js");
|
|
2880
2861
|
if (typeof window === "undefined" && !writingDirectory) {
|
|
2881
2862
|
writingDirectory = "/tmp";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zkpassport/sdk",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.1",
|
|
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.8.0",
|
|
40
|
-
"@zkpassport/utils": "0.19.
|
|
40
|
+
"@zkpassport/utils": "0.19.1",
|
|
41
41
|
"buffer": "^6.0.3",
|
|
42
42
|
"i18n-iso-countries": "^7.12.0",
|
|
43
43
|
"pako": "^2.1.0",
|