@zkpassport/sdk 0.7.0 → 0.8.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.
- package/dist/cjs/index.cjs +71 -66
- package/dist/cjs/index.d.cts +21 -4
- package/dist/esm/index.d.ts +21 -4
- package/dist/esm/index.js +75 -68
- package/package.json +3 -3
package/dist/cjs/index.cjs
CHANGED
|
@@ -813,8 +813,8 @@ var ZKPassportVerifier_default = {
|
|
|
813
813
|
var import_registry = require("@zkpassport/registry");
|
|
814
814
|
var import_bridge = require("@obsidion/bridge");
|
|
815
815
|
var import_utils4 = require("@zkpassport/utils");
|
|
816
|
-
var VERSION = "0.
|
|
817
|
-
var DEFAULT_DATE_VALUE = new Date(
|
|
816
|
+
var VERSION = "0.8.0";
|
|
817
|
+
var DEFAULT_DATE_VALUE = /* @__PURE__ */ new Date(0);
|
|
818
818
|
if (typeof globalThis.Buffer === "undefined") {
|
|
819
819
|
globalThis.Buffer = import_buffer.Buffer;
|
|
820
820
|
if (typeof window !== "undefined") {
|
|
@@ -967,6 +967,12 @@ var ZKPassport = class {
|
|
|
967
967
|
if (this.topicToConfig[topic].bind) {
|
|
968
968
|
neededCircuits.push("bind");
|
|
969
969
|
}
|
|
970
|
+
if (this.topicToConfig[topic].sanctions) {
|
|
971
|
+
neededCircuits.push("sanctions");
|
|
972
|
+
}
|
|
973
|
+
if (this.topicToConfig[topic].facematch) {
|
|
974
|
+
neededCircuits.push("facematch");
|
|
975
|
+
}
|
|
970
976
|
this.topicToExpectedProofCount[topic] = neededCircuits.length === 0 ? 4 : 3 + neededCircuits.length;
|
|
971
977
|
this.topicToFailedProofCount[topic] = 0;
|
|
972
978
|
}
|
|
@@ -994,18 +1000,7 @@ var ZKPassport = class {
|
|
|
994
1000
|
}
|
|
995
1001
|
} else if (request.method === "done") {
|
|
996
1002
|
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;
|
|
1003
|
+
this.topicToResults[topic] = (0, import_utils.formatQueryResultDates)(request.params);
|
|
1009
1004
|
if (this.topicToExpectedProofCount[topic] === this.topicToProofs[topic].length) {
|
|
1010
1005
|
await this.handleResult(topic);
|
|
1011
1006
|
}
|
|
@@ -1083,6 +1078,26 @@ var ZKPassport = class {
|
|
|
1083
1078
|
};
|
|
1084
1079
|
return this.getZkPassportRequest(topic);
|
|
1085
1080
|
},
|
|
1081
|
+
sanctions: (countries = "all", lists = "all") => {
|
|
1082
|
+
this.topicToConfig[topic].sanctions = {
|
|
1083
|
+
...this.topicToConfig[topic].sanctions,
|
|
1084
|
+
countries: countries === "all" ? "all" : Array.isArray(countries) ? [
|
|
1085
|
+
...this.topicToConfig[topic].sanctions?.countries ?? [],
|
|
1086
|
+
...countries
|
|
1087
|
+
] : [
|
|
1088
|
+
...this.topicToConfig[topic].sanctions?.countries ?? [],
|
|
1089
|
+
countries
|
|
1090
|
+
],
|
|
1091
|
+
lists: lists === "all" ? "all" : Array.isArray(lists) ? [...this.topicToConfig[topic].sanctions?.lists ?? [], ...lists] : [...this.topicToConfig[topic].sanctions?.lists ?? [], lists]
|
|
1092
|
+
};
|
|
1093
|
+
return this.getZkPassportRequest(topic);
|
|
1094
|
+
},
|
|
1095
|
+
facematch: (mode = "strict") => {
|
|
1096
|
+
this.topicToConfig[topic].facematch = {
|
|
1097
|
+
mode
|
|
1098
|
+
};
|
|
1099
|
+
return this.getZkPassportRequest(topic);
|
|
1100
|
+
},
|
|
1086
1101
|
done: () => {
|
|
1087
1102
|
this.setExpectedProofCount(topic);
|
|
1088
1103
|
return {
|
|
@@ -1223,7 +1238,7 @@ var ZKPassport = class {
|
|
|
1223
1238
|
if (queryResult.birthdate) {
|
|
1224
1239
|
const birthdatePassport = disclosedDataPassport.dateOfBirth;
|
|
1225
1240
|
const birthdateIDCard = disclosedDataIDCard.dateOfBirth;
|
|
1226
|
-
if (queryResult.birthdate.eq && queryResult.birthdate.eq.result && queryResult.birthdate.eq.expected
|
|
1241
|
+
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
1242
|
console.warn("Birthdate does not match the expected birthdate");
|
|
1228
1243
|
isCorrect = false;
|
|
1229
1244
|
queryResultErrors.birthdate.eq = {
|
|
@@ -1232,7 +1247,7 @@ var ZKPassport = class {
|
|
|
1232
1247
|
message: "Birthdate does not match the expected birthdate"
|
|
1233
1248
|
};
|
|
1234
1249
|
}
|
|
1235
|
-
if (queryResult.birthdate.disclose && queryResult.birthdate.disclose.result
|
|
1250
|
+
if (queryResult.birthdate.disclose && !(0, import_utils.areDatesEqual)(queryResult.birthdate.disclose.result, birthdatePassport) && !(0, import_utils.areDatesEqual)(queryResult.birthdate.disclose.result, birthdateIDCard)) {
|
|
1236
1251
|
console.warn("Birthdate does not match the disclosed birthdate in query result");
|
|
1237
1252
|
isCorrect = false;
|
|
1238
1253
|
queryResultErrors.birthdate.disclose = {
|
|
@@ -1245,7 +1260,7 @@ var ZKPassport = class {
|
|
|
1245
1260
|
if (queryResult.expiry_date) {
|
|
1246
1261
|
const expiryDatePassport = disclosedDataPassport.dateOfExpiry;
|
|
1247
1262
|
const expiryDateIDCard = disclosedDataIDCard.dateOfExpiry;
|
|
1248
|
-
if (queryResult.expiry_date.eq && queryResult.expiry_date.eq.result && queryResult.expiry_date.eq.expected
|
|
1263
|
+
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
1264
|
console.warn("Expiry date does not match the expected expiry date");
|
|
1250
1265
|
isCorrect = false;
|
|
1251
1266
|
queryResultErrors.expiry_date.eq = {
|
|
@@ -1254,7 +1269,7 @@ var ZKPassport = class {
|
|
|
1254
1269
|
message: "Expiry date does not match the expected expiry date"
|
|
1255
1270
|
};
|
|
1256
1271
|
}
|
|
1257
|
-
if (queryResult.expiry_date.disclose && queryResult.expiry_date.disclose.result
|
|
1272
|
+
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
1273
|
console.warn("Expiry date does not match the disclosed expiry date in query result");
|
|
1259
1274
|
isCorrect = false;
|
|
1260
1275
|
queryResultErrors.expiry_date.disclose = {
|
|
@@ -1524,7 +1539,7 @@ var ZKPassport = class {
|
|
|
1524
1539
|
const currentDate = (0, import_utils.getCurrentDateFromCommittedInputs)(
|
|
1525
1540
|
proof.committedInputs?.compare_age
|
|
1526
1541
|
);
|
|
1527
|
-
if (
|
|
1542
|
+
if (!(0, import_utils.areDatesEqual)(currentDate, today) && !(0, import_utils.areDatesEqual)(currentDate, today.getTime() - 864e5)) {
|
|
1528
1543
|
console.warn("Current date in the proof is too old");
|
|
1529
1544
|
isCorrect = false;
|
|
1530
1545
|
queryResultErrors.age.disclose = {
|
|
@@ -1604,7 +1619,7 @@ var ZKPassport = class {
|
|
|
1604
1619
|
};
|
|
1605
1620
|
}
|
|
1606
1621
|
}
|
|
1607
|
-
if (!queryResult.birthdate.lte && !queryResult.birthdate.range &&
|
|
1622
|
+
if (!queryResult.birthdate.lte && !queryResult.birthdate.range && !(0, import_utils.areDatesEqual)(maxDate, DEFAULT_DATE_VALUE)) {
|
|
1608
1623
|
console.warn("Maximum birthdate should be equal to default date value");
|
|
1609
1624
|
isCorrect = false;
|
|
1610
1625
|
queryResultErrors.birthdate.disclose = {
|
|
@@ -1613,7 +1628,7 @@ var ZKPassport = class {
|
|
|
1613
1628
|
message: "Maximum birthdate should be equal to default date value"
|
|
1614
1629
|
};
|
|
1615
1630
|
}
|
|
1616
|
-
if (!queryResult.birthdate.gte && !queryResult.birthdate.range &&
|
|
1631
|
+
if (!queryResult.birthdate.gte && !queryResult.birthdate.range && !(0, import_utils.areDatesEqual)(minDate, DEFAULT_DATE_VALUE)) {
|
|
1617
1632
|
console.warn("Minimum birthdate should be equal to default date value");
|
|
1618
1633
|
isCorrect = false;
|
|
1619
1634
|
queryResultErrors.birthdate.disclose = {
|
|
@@ -1629,7 +1644,7 @@ var ZKPassport = class {
|
|
|
1629
1644
|
message: "Birthdate is not set in the query result"
|
|
1630
1645
|
};
|
|
1631
1646
|
}
|
|
1632
|
-
if (
|
|
1647
|
+
if (!(0, import_utils.areDatesEqual)(currentDate, today) && !(0, import_utils.areDatesEqual)(currentDate, today.getTime() - 864e5)) {
|
|
1633
1648
|
console.warn("Current date in the proof is too old");
|
|
1634
1649
|
isCorrect = false;
|
|
1635
1650
|
queryResultErrors.age.disclose = {
|
|
@@ -1709,7 +1724,7 @@ var ZKPassport = class {
|
|
|
1709
1724
|
};
|
|
1710
1725
|
}
|
|
1711
1726
|
}
|
|
1712
|
-
if (!queryResult.expiry_date.lte && !queryResult.expiry_date.range &&
|
|
1727
|
+
if (!queryResult.expiry_date.lte && !queryResult.expiry_date.range && !(0, import_utils.areDatesEqual)(maxDate, DEFAULT_DATE_VALUE)) {
|
|
1713
1728
|
console.warn("Maximum expiry date should be equal to default date value");
|
|
1714
1729
|
isCorrect = false;
|
|
1715
1730
|
queryResultErrors.expiry_date.disclose = {
|
|
@@ -1718,7 +1733,7 @@ var ZKPassport = class {
|
|
|
1718
1733
|
message: "Maximum expiry date should be equal to default date value"
|
|
1719
1734
|
};
|
|
1720
1735
|
}
|
|
1721
|
-
if (!queryResult.expiry_date.gte && !queryResult.expiry_date.range &&
|
|
1736
|
+
if (!queryResult.expiry_date.gte && !queryResult.expiry_date.range && !(0, import_utils.areDatesEqual)(minDate, DEFAULT_DATE_VALUE)) {
|
|
1722
1737
|
console.warn("Minimum expiry date should be equal to default date value");
|
|
1723
1738
|
isCorrect = false;
|
|
1724
1739
|
queryResultErrors.expiry_date.disclose = {
|
|
@@ -1734,7 +1749,7 @@ var ZKPassport = class {
|
|
|
1734
1749
|
message: "Expiry date is not set in the query result"
|
|
1735
1750
|
};
|
|
1736
1751
|
}
|
|
1737
|
-
if (
|
|
1752
|
+
if (!(0, import_utils.areDatesEqual)(currentDate, today) && !(0, import_utils.areDatesEqual)(currentDate, today.getTime() - 864e5)) {
|
|
1738
1753
|
console.warn("Current date in the proof is too old");
|
|
1739
1754
|
isCorrect = false;
|
|
1740
1755
|
queryResultErrors.age.disclose = {
|
|
@@ -2185,11 +2200,11 @@ var ZKPassport = class {
|
|
|
2185
2200
|
if (!!committedInputs?.compare_age) {
|
|
2186
2201
|
const ageCommittedInputs = committedInputs?.compare_age;
|
|
2187
2202
|
const ageParameterCommitment = isForEVM ? await (0, import_utils.getAgeEVMParameterCommitment)(
|
|
2188
|
-
ageCommittedInputs.
|
|
2203
|
+
ageCommittedInputs.currentDateTimestamp,
|
|
2189
2204
|
ageCommittedInputs.minAge,
|
|
2190
2205
|
ageCommittedInputs.maxAge
|
|
2191
2206
|
) : await (0, import_utils.getAgeParameterCommitment)(
|
|
2192
|
-
ageCommittedInputs.
|
|
2207
|
+
ageCommittedInputs.currentDateTimestamp,
|
|
2193
2208
|
ageCommittedInputs.minAge,
|
|
2194
2209
|
ageCommittedInputs.maxAge
|
|
2195
2210
|
);
|
|
@@ -2212,14 +2227,14 @@ var ZKPassport = class {
|
|
|
2212
2227
|
const birthdateCommittedInputs = committedInputs?.compare_birthdate;
|
|
2213
2228
|
const birthdateParameterCommitment = isForEVM ? await (0, import_utils.getDateEVMParameterCommitment)(
|
|
2214
2229
|
import_utils.ProofType.BIRTHDATE,
|
|
2215
|
-
birthdateCommittedInputs.
|
|
2216
|
-
birthdateCommittedInputs.
|
|
2217
|
-
birthdateCommittedInputs.
|
|
2230
|
+
birthdateCommittedInputs.currentDateTimestamp,
|
|
2231
|
+
birthdateCommittedInputs.minDateTimestamp,
|
|
2232
|
+
birthdateCommittedInputs.maxDateTimestamp
|
|
2218
2233
|
) : await (0, import_utils.getDateParameterCommitment)(
|
|
2219
2234
|
import_utils.ProofType.BIRTHDATE,
|
|
2220
|
-
birthdateCommittedInputs.
|
|
2221
|
-
birthdateCommittedInputs.
|
|
2222
|
-
birthdateCommittedInputs.
|
|
2235
|
+
birthdateCommittedInputs.currentDateTimestamp,
|
|
2236
|
+
birthdateCommittedInputs.minDateTimestamp,
|
|
2237
|
+
birthdateCommittedInputs.maxDateTimestamp
|
|
2223
2238
|
);
|
|
2224
2239
|
if (!paramCommitments.includes(birthdateParameterCommitment)) {
|
|
2225
2240
|
console.warn("This proof does not verify the birthdate");
|
|
@@ -2240,14 +2255,14 @@ var ZKPassport = class {
|
|
|
2240
2255
|
const expiryCommittedInputs = committedInputs?.compare_expiry;
|
|
2241
2256
|
const expiryParameterCommitment = isForEVM ? await (0, import_utils.getDateEVMParameterCommitment)(
|
|
2242
2257
|
import_utils.ProofType.EXPIRY_DATE,
|
|
2243
|
-
expiryCommittedInputs.
|
|
2244
|
-
expiryCommittedInputs.
|
|
2245
|
-
expiryCommittedInputs.
|
|
2258
|
+
expiryCommittedInputs.currentDateTimestamp,
|
|
2259
|
+
expiryCommittedInputs.minDateTimestamp,
|
|
2260
|
+
expiryCommittedInputs.maxDateTimestamp
|
|
2246
2261
|
) : await (0, import_utils.getDateParameterCommitment)(
|
|
2247
2262
|
import_utils.ProofType.EXPIRY_DATE,
|
|
2248
|
-
expiryCommittedInputs.
|
|
2249
|
-
expiryCommittedInputs.
|
|
2250
|
-
expiryCommittedInputs.
|
|
2263
|
+
expiryCommittedInputs.currentDateTimestamp,
|
|
2264
|
+
expiryCommittedInputs.minDateTimestamp,
|
|
2265
|
+
expiryCommittedInputs.maxDateTimestamp
|
|
2251
2266
|
);
|
|
2252
2267
|
if (!paramCommitments.includes(expiryParameterCommitment)) {
|
|
2253
2268
|
console.warn("This proof does not verify the expiry date");
|
|
@@ -2535,7 +2550,7 @@ var ZKPassport = class {
|
|
|
2535
2550
|
const paramCommitment = (0, import_utils.getParameterCommitmentFromDisclosureProof)(proofData);
|
|
2536
2551
|
const committedInputs = proof.committedInputs?.compare_age;
|
|
2537
2552
|
const calculatedParamCommitment = await (0, import_utils.getAgeParameterCommitment)(
|
|
2538
|
-
committedInputs.
|
|
2553
|
+
committedInputs.currentDateTimestamp,
|
|
2539
2554
|
committedInputs.minAge,
|
|
2540
2555
|
committedInputs.maxAge
|
|
2541
2556
|
);
|
|
@@ -2576,9 +2591,9 @@ var ZKPassport = class {
|
|
|
2576
2591
|
const committedInputs = proof.committedInputs?.compare_birthdate;
|
|
2577
2592
|
const calculatedParamCommitment = await (0, import_utils.getDateParameterCommitment)(
|
|
2578
2593
|
import_utils.ProofType.BIRTHDATE,
|
|
2579
|
-
committedInputs.
|
|
2580
|
-
committedInputs.
|
|
2581
|
-
committedInputs.
|
|
2594
|
+
committedInputs.currentDateTimestamp,
|
|
2595
|
+
committedInputs.minDateTimestamp,
|
|
2596
|
+
committedInputs.maxDateTimestamp
|
|
2582
2597
|
);
|
|
2583
2598
|
if (paramCommitment !== calculatedParamCommitment) {
|
|
2584
2599
|
console.warn(
|
|
@@ -2617,9 +2632,9 @@ var ZKPassport = class {
|
|
|
2617
2632
|
const committedInputs = proof.committedInputs?.compare_expiry;
|
|
2618
2633
|
const calculatedParamCommitment = await (0, import_utils.getDateParameterCommitment)(
|
|
2619
2634
|
import_utils.ProofType.EXPIRY_DATE,
|
|
2620
|
-
committedInputs.
|
|
2621
|
-
committedInputs.
|
|
2622
|
-
committedInputs.
|
|
2635
|
+
committedInputs.currentDateTimestamp,
|
|
2636
|
+
committedInputs.minDateTimestamp,
|
|
2637
|
+
committedInputs.maxDateTimestamp
|
|
2623
2638
|
);
|
|
2624
2639
|
if (paramCommitment !== calculatedParamCommitment) {
|
|
2625
2640
|
console.warn(
|
|
@@ -2865,17 +2880,7 @@ var ZKPassport = class {
|
|
|
2865
2880
|
verified: false
|
|
2866
2881
|
};
|
|
2867
2882
|
}
|
|
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
|
-
}
|
|
2883
|
+
const formattedResult = (0, import_utils.formatQueryResultDates)(queryResult);
|
|
2879
2884
|
const { BarretenbergVerifier } = await import("@aztec/bb.js");
|
|
2880
2885
|
if (typeof window === "undefined" && !writingDirectory) {
|
|
2881
2886
|
writingDirectory = "/tmp";
|
|
@@ -2984,7 +2989,7 @@ var ZKPassport = class {
|
|
|
2984
2989
|
}
|
|
2985
2990
|
getSolidityVerifierParameters({
|
|
2986
2991
|
proof,
|
|
2987
|
-
|
|
2992
|
+
validityPeriodInSeconds = 7 * 24 * 60 * 60,
|
|
2988
2993
|
domain,
|
|
2989
2994
|
scope,
|
|
2990
2995
|
devMode = false
|
|
@@ -3026,19 +3031,19 @@ var ZKPassport = class {
|
|
|
3026
3031
|
).map((x) => x.toString(16).padStart(2, "0")).join("");
|
|
3027
3032
|
} else if (circuitName === "compare_age_evm") {
|
|
3028
3033
|
const value = proof.committedInputs[circuitName];
|
|
3029
|
-
const currentDateBytes = Array.from(
|
|
3034
|
+
const currentDateBytes = Array.from((0, import_utils2.numberToBytesBE)(value.currentDateTimestamp, 4));
|
|
3030
3035
|
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");
|
|
3031
3036
|
} else if (circuitName === "compare_birthdate_evm") {
|
|
3032
3037
|
const value = proof.committedInputs[circuitName];
|
|
3033
|
-
const currentDateBytes = Array.from(
|
|
3034
|
-
const minDateBytes = Array.from(
|
|
3035
|
-
const maxDateBytes = Array.from(
|
|
3038
|
+
const currentDateBytes = Array.from((0, import_utils2.numberToBytesBE)(value.currentDateTimestamp, 4));
|
|
3039
|
+
const minDateBytes = Array.from((0, import_utils2.numberToBytesBE)(value.minDateTimestamp, 4));
|
|
3040
|
+
const maxDateBytes = Array.from((0, import_utils2.numberToBytesBE)(value.maxDateTimestamp, 4));
|
|
3036
3041
|
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("");
|
|
3037
3042
|
} else if (circuitName === "compare_expiry_evm") {
|
|
3038
3043
|
const value = proof.committedInputs[circuitName];
|
|
3039
|
-
const currentDateBytes = Array.from(
|
|
3040
|
-
const minDateBytes = Array.from(
|
|
3041
|
-
const maxDateBytes = Array.from(
|
|
3044
|
+
const currentDateBytes = Array.from((0, import_utils2.numberToBytesBE)(value.currentDateTimestamp, 4));
|
|
3045
|
+
const minDateBytes = Array.from((0, import_utils2.numberToBytesBE)(value.minDateTimestamp, 4));
|
|
3046
|
+
const maxDateBytes = Array.from((0, import_utils2.numberToBytesBE)(value.maxDateTimestamp, 4));
|
|
3042
3047
|
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("");
|
|
3043
3048
|
} else if (circuitName === "disclose_bytes_evm") {
|
|
3044
3049
|
const value = proof.committedInputs[circuitName];
|
|
@@ -3085,7 +3090,7 @@ var ZKPassport = class {
|
|
|
3085
3090
|
publicInputs: proofData.publicInputs,
|
|
3086
3091
|
committedInputs: `0x${compressedCommittedInputs}`,
|
|
3087
3092
|
committedInputCounts: committedInputCountsArray,
|
|
3088
|
-
|
|
3093
|
+
validityPeriodInSeconds,
|
|
3089
3094
|
domain: domain ?? this.domain,
|
|
3090
3095
|
scope: scope ?? "",
|
|
3091
3096
|
devMode
|
package/dist/cjs/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IDCredential, ProofResult, QueryResult, IDCredentialValue, NumericalIDCredential, DisclosableIDCredential, BoundData, ProofMode, SupportedChain } from '@zkpassport/utils';
|
|
1
|
+
import { IDCredential, ProofResult, QueryResult, IDCredentialValue, NumericalIDCredential, DisclosableIDCredential, BoundData, SanctionsCountries, SanctionsLists, FacematchMode, 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
|
|
|
@@ -29,7 +29,7 @@ type SolidityVerifierParameters = {
|
|
|
29
29
|
publicInputs: string[];
|
|
30
30
|
committedInputs: string;
|
|
31
31
|
committedInputCounts: number[];
|
|
32
|
-
|
|
32
|
+
validityPeriodInSeconds: number;
|
|
33
33
|
domain: string;
|
|
34
34
|
scope: string;
|
|
35
35
|
devMode: boolean;
|
|
@@ -157,6 +157,23 @@ type QueryBuilder = {
|
|
|
157
157
|
* @param value The value to bind the request to.
|
|
158
158
|
*/
|
|
159
159
|
bind: (key: keyof BoundData, value: BoundData[keyof BoundData]) => QueryBuilder;
|
|
160
|
+
/**
|
|
161
|
+
* Requires that the ID holder is not part of any of the specified sanction lists.
|
|
162
|
+
* @param countries The country or list of countries whose sanction lists to check against. Defaults to "all".
|
|
163
|
+
* e.g. "US", ["US", "GB", "CH", "EU"], "all"
|
|
164
|
+
* @param lists The specific lists from a given country to check against. Defaults to "all".
|
|
165
|
+
* e.g. ["OFAC-SDN"], "all"
|
|
166
|
+
*/
|
|
167
|
+
sanctions: (countries?: SanctionsCountries, lists?: SanctionsLists) => QueryBuilder;
|
|
168
|
+
/**
|
|
169
|
+
* Requires that the ID holder's face matches the photo on the ID.
|
|
170
|
+
* @param mode The mode to use for the face match. Defaults to "strict".
|
|
171
|
+
* @param mode "strict" - The user will have to go through an extensive liveness check to prevent spoofing making it more secure.
|
|
172
|
+
* Best for high security requirements such as KYC.
|
|
173
|
+
* @param mode "relaxed" - The user will only have to go through a basic liveness check to prevent spoofing, making it faster for the user.
|
|
174
|
+
* Best for lower security requirements that requires fast verification such as age verification.
|
|
175
|
+
*/
|
|
176
|
+
facematch: (mode?: FacematchMode) => QueryBuilder;
|
|
160
177
|
/**
|
|
161
178
|
* Builds the request.
|
|
162
179
|
*
|
|
@@ -276,9 +293,9 @@ declare class ZKPassport {
|
|
|
276
293
|
}[];
|
|
277
294
|
}[];
|
|
278
295
|
};
|
|
279
|
-
getSolidityVerifierParameters({ proof,
|
|
296
|
+
getSolidityVerifierParameters({ proof, validityPeriodInSeconds, domain, scope, devMode, }: {
|
|
280
297
|
proof: ProofResult;
|
|
281
|
-
|
|
298
|
+
validityPeriodInSeconds?: number;
|
|
282
299
|
domain?: string;
|
|
283
300
|
scope?: string;
|
|
284
301
|
devMode?: boolean;
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IDCredential, ProofResult, QueryResult, IDCredentialValue, NumericalIDCredential, DisclosableIDCredential, BoundData, ProofMode, SupportedChain } from '@zkpassport/utils';
|
|
1
|
+
import { IDCredential, ProofResult, QueryResult, IDCredentialValue, NumericalIDCredential, DisclosableIDCredential, BoundData, SanctionsCountries, SanctionsLists, FacematchMode, 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
|
|
|
@@ -29,7 +29,7 @@ type SolidityVerifierParameters = {
|
|
|
29
29
|
publicInputs: string[];
|
|
30
30
|
committedInputs: string;
|
|
31
31
|
committedInputCounts: number[];
|
|
32
|
-
|
|
32
|
+
validityPeriodInSeconds: number;
|
|
33
33
|
domain: string;
|
|
34
34
|
scope: string;
|
|
35
35
|
devMode: boolean;
|
|
@@ -157,6 +157,23 @@ type QueryBuilder = {
|
|
|
157
157
|
* @param value The value to bind the request to.
|
|
158
158
|
*/
|
|
159
159
|
bind: (key: keyof BoundData, value: BoundData[keyof BoundData]) => QueryBuilder;
|
|
160
|
+
/**
|
|
161
|
+
* Requires that the ID holder is not part of any of the specified sanction lists.
|
|
162
|
+
* @param countries The country or list of countries whose sanction lists to check against. Defaults to "all".
|
|
163
|
+
* e.g. "US", ["US", "GB", "CH", "EU"], "all"
|
|
164
|
+
* @param lists The specific lists from a given country to check against. Defaults to "all".
|
|
165
|
+
* e.g. ["OFAC-SDN"], "all"
|
|
166
|
+
*/
|
|
167
|
+
sanctions: (countries?: SanctionsCountries, lists?: SanctionsLists) => QueryBuilder;
|
|
168
|
+
/**
|
|
169
|
+
* Requires that the ID holder's face matches the photo on the ID.
|
|
170
|
+
* @param mode The mode to use for the face match. Defaults to "strict".
|
|
171
|
+
* @param mode "strict" - The user will have to go through an extensive liveness check to prevent spoofing making it more secure.
|
|
172
|
+
* Best for high security requirements such as KYC.
|
|
173
|
+
* @param mode "relaxed" - The user will only have to go through a basic liveness check to prevent spoofing, making it faster for the user.
|
|
174
|
+
* Best for lower security requirements that requires fast verification such as age verification.
|
|
175
|
+
*/
|
|
176
|
+
facematch: (mode?: FacematchMode) => QueryBuilder;
|
|
160
177
|
/**
|
|
161
178
|
* Builds the request.
|
|
162
179
|
*
|
|
@@ -276,9 +293,9 @@ declare class ZKPassport {
|
|
|
276
293
|
}[];
|
|
277
294
|
}[];
|
|
278
295
|
};
|
|
279
|
-
getSolidityVerifierParameters({ proof,
|
|
296
|
+
getSolidityVerifierParameters({ proof, validityPeriodInSeconds, domain, scope, devMode, }: {
|
|
280
297
|
proof: ProofResult;
|
|
281
|
-
|
|
298
|
+
validityPeriodInSeconds?: number;
|
|
282
299
|
domain?: string;
|
|
283
300
|
scope?: string;
|
|
284
301
|
devMode?: boolean;
|
package/dist/esm/index.js
CHANGED
|
@@ -46,9 +46,11 @@ import {
|
|
|
46
46
|
getBindEVMParameterCommitment,
|
|
47
47
|
getBindParameterCommitment,
|
|
48
48
|
formatBoundData,
|
|
49
|
-
getCircuitRegistryRootFromOuterProof
|
|
49
|
+
getCircuitRegistryRootFromOuterProof,
|
|
50
|
+
areDatesEqual,
|
|
51
|
+
formatQueryResultDates
|
|
50
52
|
} from "@zkpassport/utils";
|
|
51
|
-
import { bytesToHex } from "@noble/ciphers/utils";
|
|
53
|
+
import { bytesToHex, numberToBytesBE } from "@noble/ciphers/utils";
|
|
52
54
|
import i18en from "i18n-iso-countries/langs/en.json";
|
|
53
55
|
import { Buffer } from "buffer/";
|
|
54
56
|
import { sha256 } from "@noble/hashes/sha2";
|
|
@@ -813,8 +815,8 @@ import {
|
|
|
813
815
|
ASEAN_COUNTRIES,
|
|
814
816
|
MERCOSUR_COUNTRIES
|
|
815
817
|
} from "@zkpassport/utils";
|
|
816
|
-
var VERSION = "0.
|
|
817
|
-
var DEFAULT_DATE_VALUE = new Date(
|
|
818
|
+
var VERSION = "0.8.0";
|
|
819
|
+
var DEFAULT_DATE_VALUE = /* @__PURE__ */ new Date(0);
|
|
818
820
|
if (typeof globalThis.Buffer === "undefined") {
|
|
819
821
|
globalThis.Buffer = Buffer;
|
|
820
822
|
if (typeof window !== "undefined") {
|
|
@@ -967,6 +969,12 @@ var ZKPassport = class {
|
|
|
967
969
|
if (this.topicToConfig[topic].bind) {
|
|
968
970
|
neededCircuits.push("bind");
|
|
969
971
|
}
|
|
972
|
+
if (this.topicToConfig[topic].sanctions) {
|
|
973
|
+
neededCircuits.push("sanctions");
|
|
974
|
+
}
|
|
975
|
+
if (this.topicToConfig[topic].facematch) {
|
|
976
|
+
neededCircuits.push("facematch");
|
|
977
|
+
}
|
|
970
978
|
this.topicToExpectedProofCount[topic] = neededCircuits.length === 0 ? 4 : 3 + neededCircuits.length;
|
|
971
979
|
this.topicToFailedProofCount[topic] = 0;
|
|
972
980
|
}
|
|
@@ -994,18 +1002,7 @@ var ZKPassport = class {
|
|
|
994
1002
|
}
|
|
995
1003
|
} else if (request.method === "done") {
|
|
996
1004
|
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;
|
|
1005
|
+
this.topicToResults[topic] = formatQueryResultDates(request.params);
|
|
1009
1006
|
if (this.topicToExpectedProofCount[topic] === this.topicToProofs[topic].length) {
|
|
1010
1007
|
await this.handleResult(topic);
|
|
1011
1008
|
}
|
|
@@ -1083,6 +1080,26 @@ var ZKPassport = class {
|
|
|
1083
1080
|
};
|
|
1084
1081
|
return this.getZkPassportRequest(topic);
|
|
1085
1082
|
},
|
|
1083
|
+
sanctions: (countries = "all", lists = "all") => {
|
|
1084
|
+
this.topicToConfig[topic].sanctions = {
|
|
1085
|
+
...this.topicToConfig[topic].sanctions,
|
|
1086
|
+
countries: countries === "all" ? "all" : Array.isArray(countries) ? [
|
|
1087
|
+
...this.topicToConfig[topic].sanctions?.countries ?? [],
|
|
1088
|
+
...countries
|
|
1089
|
+
] : [
|
|
1090
|
+
...this.topicToConfig[topic].sanctions?.countries ?? [],
|
|
1091
|
+
countries
|
|
1092
|
+
],
|
|
1093
|
+
lists: lists === "all" ? "all" : Array.isArray(lists) ? [...this.topicToConfig[topic].sanctions?.lists ?? [], ...lists] : [...this.topicToConfig[topic].sanctions?.lists ?? [], lists]
|
|
1094
|
+
};
|
|
1095
|
+
return this.getZkPassportRequest(topic);
|
|
1096
|
+
},
|
|
1097
|
+
facematch: (mode = "strict") => {
|
|
1098
|
+
this.topicToConfig[topic].facematch = {
|
|
1099
|
+
mode
|
|
1100
|
+
};
|
|
1101
|
+
return this.getZkPassportRequest(topic);
|
|
1102
|
+
},
|
|
1086
1103
|
done: () => {
|
|
1087
1104
|
this.setExpectedProofCount(topic);
|
|
1088
1105
|
return {
|
|
@@ -1223,7 +1240,7 @@ var ZKPassport = class {
|
|
|
1223
1240
|
if (queryResult.birthdate) {
|
|
1224
1241
|
const birthdatePassport = disclosedDataPassport.dateOfBirth;
|
|
1225
1242
|
const birthdateIDCard = disclosedDataIDCard.dateOfBirth;
|
|
1226
|
-
if (queryResult.birthdate.eq && queryResult.birthdate.eq.result && queryResult.birthdate.eq.expected
|
|
1243
|
+
if (queryResult.birthdate.eq && queryResult.birthdate.eq.result && !areDatesEqual(queryResult.birthdate.eq.expected, birthdatePassport) && !areDatesEqual(queryResult.birthdate.eq.expected, birthdateIDCard)) {
|
|
1227
1244
|
console.warn("Birthdate does not match the expected birthdate");
|
|
1228
1245
|
isCorrect = false;
|
|
1229
1246
|
queryResultErrors.birthdate.eq = {
|
|
@@ -1232,7 +1249,7 @@ var ZKPassport = class {
|
|
|
1232
1249
|
message: "Birthdate does not match the expected birthdate"
|
|
1233
1250
|
};
|
|
1234
1251
|
}
|
|
1235
|
-
if (queryResult.birthdate.disclose && queryResult.birthdate.disclose.result
|
|
1252
|
+
if (queryResult.birthdate.disclose && !areDatesEqual(queryResult.birthdate.disclose.result, birthdatePassport) && !areDatesEqual(queryResult.birthdate.disclose.result, birthdateIDCard)) {
|
|
1236
1253
|
console.warn("Birthdate does not match the disclosed birthdate in query result");
|
|
1237
1254
|
isCorrect = false;
|
|
1238
1255
|
queryResultErrors.birthdate.disclose = {
|
|
@@ -1245,7 +1262,7 @@ var ZKPassport = class {
|
|
|
1245
1262
|
if (queryResult.expiry_date) {
|
|
1246
1263
|
const expiryDatePassport = disclosedDataPassport.dateOfExpiry;
|
|
1247
1264
|
const expiryDateIDCard = disclosedDataIDCard.dateOfExpiry;
|
|
1248
|
-
if (queryResult.expiry_date.eq && queryResult.expiry_date.eq.result && queryResult.expiry_date.eq.expected
|
|
1265
|
+
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
1266
|
console.warn("Expiry date does not match the expected expiry date");
|
|
1250
1267
|
isCorrect = false;
|
|
1251
1268
|
queryResultErrors.expiry_date.eq = {
|
|
@@ -1254,7 +1271,7 @@ var ZKPassport = class {
|
|
|
1254
1271
|
message: "Expiry date does not match the expected expiry date"
|
|
1255
1272
|
};
|
|
1256
1273
|
}
|
|
1257
|
-
if (queryResult.expiry_date.disclose && queryResult.expiry_date.disclose.result
|
|
1274
|
+
if (queryResult.expiry_date.disclose && !areDatesEqual(queryResult.expiry_date.disclose.result, expiryDatePassport) && !areDatesEqual(queryResult.expiry_date.disclose.result, expiryDateIDCard)) {
|
|
1258
1275
|
console.warn("Expiry date does not match the disclosed expiry date in query result");
|
|
1259
1276
|
isCorrect = false;
|
|
1260
1277
|
queryResultErrors.expiry_date.disclose = {
|
|
@@ -1524,7 +1541,7 @@ var ZKPassport = class {
|
|
|
1524
1541
|
const currentDate = getCurrentDateFromCommittedInputs(
|
|
1525
1542
|
proof.committedInputs?.compare_age
|
|
1526
1543
|
);
|
|
1527
|
-
if (currentDate
|
|
1544
|
+
if (!areDatesEqual(currentDate, today) && !areDatesEqual(currentDate, today.getTime() - 864e5)) {
|
|
1528
1545
|
console.warn("Current date in the proof is too old");
|
|
1529
1546
|
isCorrect = false;
|
|
1530
1547
|
queryResultErrors.age.disclose = {
|
|
@@ -1604,7 +1621,7 @@ var ZKPassport = class {
|
|
|
1604
1621
|
};
|
|
1605
1622
|
}
|
|
1606
1623
|
}
|
|
1607
|
-
if (!queryResult.birthdate.lte && !queryResult.birthdate.range && maxDate
|
|
1624
|
+
if (!queryResult.birthdate.lte && !queryResult.birthdate.range && !areDatesEqual(maxDate, DEFAULT_DATE_VALUE)) {
|
|
1608
1625
|
console.warn("Maximum birthdate should be equal to default date value");
|
|
1609
1626
|
isCorrect = false;
|
|
1610
1627
|
queryResultErrors.birthdate.disclose = {
|
|
@@ -1613,7 +1630,7 @@ var ZKPassport = class {
|
|
|
1613
1630
|
message: "Maximum birthdate should be equal to default date value"
|
|
1614
1631
|
};
|
|
1615
1632
|
}
|
|
1616
|
-
if (!queryResult.birthdate.gte && !queryResult.birthdate.range && minDate
|
|
1633
|
+
if (!queryResult.birthdate.gte && !queryResult.birthdate.range && !areDatesEqual(minDate, DEFAULT_DATE_VALUE)) {
|
|
1617
1634
|
console.warn("Minimum birthdate should be equal to default date value");
|
|
1618
1635
|
isCorrect = false;
|
|
1619
1636
|
queryResultErrors.birthdate.disclose = {
|
|
@@ -1629,7 +1646,7 @@ var ZKPassport = class {
|
|
|
1629
1646
|
message: "Birthdate is not set in the query result"
|
|
1630
1647
|
};
|
|
1631
1648
|
}
|
|
1632
|
-
if (currentDate
|
|
1649
|
+
if (!areDatesEqual(currentDate, today) && !areDatesEqual(currentDate, today.getTime() - 864e5)) {
|
|
1633
1650
|
console.warn("Current date in the proof is too old");
|
|
1634
1651
|
isCorrect = false;
|
|
1635
1652
|
queryResultErrors.age.disclose = {
|
|
@@ -1709,7 +1726,7 @@ var ZKPassport = class {
|
|
|
1709
1726
|
};
|
|
1710
1727
|
}
|
|
1711
1728
|
}
|
|
1712
|
-
if (!queryResult.expiry_date.lte && !queryResult.expiry_date.range && maxDate
|
|
1729
|
+
if (!queryResult.expiry_date.lte && !queryResult.expiry_date.range && !areDatesEqual(maxDate, DEFAULT_DATE_VALUE)) {
|
|
1713
1730
|
console.warn("Maximum expiry date should be equal to default date value");
|
|
1714
1731
|
isCorrect = false;
|
|
1715
1732
|
queryResultErrors.expiry_date.disclose = {
|
|
@@ -1718,7 +1735,7 @@ var ZKPassport = class {
|
|
|
1718
1735
|
message: "Maximum expiry date should be equal to default date value"
|
|
1719
1736
|
};
|
|
1720
1737
|
}
|
|
1721
|
-
if (!queryResult.expiry_date.gte && !queryResult.expiry_date.range && minDate
|
|
1738
|
+
if (!queryResult.expiry_date.gte && !queryResult.expiry_date.range && !areDatesEqual(minDate, DEFAULT_DATE_VALUE)) {
|
|
1722
1739
|
console.warn("Minimum expiry date should be equal to default date value");
|
|
1723
1740
|
isCorrect = false;
|
|
1724
1741
|
queryResultErrors.expiry_date.disclose = {
|
|
@@ -1734,7 +1751,7 @@ var ZKPassport = class {
|
|
|
1734
1751
|
message: "Expiry date is not set in the query result"
|
|
1735
1752
|
};
|
|
1736
1753
|
}
|
|
1737
|
-
if (currentDate
|
|
1754
|
+
if (!areDatesEqual(currentDate, today) && !areDatesEqual(currentDate, today.getTime() - 864e5)) {
|
|
1738
1755
|
console.warn("Current date in the proof is too old");
|
|
1739
1756
|
isCorrect = false;
|
|
1740
1757
|
queryResultErrors.age.disclose = {
|
|
@@ -2185,11 +2202,11 @@ var ZKPassport = class {
|
|
|
2185
2202
|
if (!!committedInputs?.compare_age) {
|
|
2186
2203
|
const ageCommittedInputs = committedInputs?.compare_age;
|
|
2187
2204
|
const ageParameterCommitment = isForEVM ? await getAgeEVMParameterCommitment(
|
|
2188
|
-
ageCommittedInputs.
|
|
2205
|
+
ageCommittedInputs.currentDateTimestamp,
|
|
2189
2206
|
ageCommittedInputs.minAge,
|
|
2190
2207
|
ageCommittedInputs.maxAge
|
|
2191
2208
|
) : await getAgeParameterCommitment(
|
|
2192
|
-
ageCommittedInputs.
|
|
2209
|
+
ageCommittedInputs.currentDateTimestamp,
|
|
2193
2210
|
ageCommittedInputs.minAge,
|
|
2194
2211
|
ageCommittedInputs.maxAge
|
|
2195
2212
|
);
|
|
@@ -2212,14 +2229,14 @@ var ZKPassport = class {
|
|
|
2212
2229
|
const birthdateCommittedInputs = committedInputs?.compare_birthdate;
|
|
2213
2230
|
const birthdateParameterCommitment = isForEVM ? await getDateEVMParameterCommitment(
|
|
2214
2231
|
ProofType.BIRTHDATE,
|
|
2215
|
-
birthdateCommittedInputs.
|
|
2216
|
-
birthdateCommittedInputs.
|
|
2217
|
-
birthdateCommittedInputs.
|
|
2232
|
+
birthdateCommittedInputs.currentDateTimestamp,
|
|
2233
|
+
birthdateCommittedInputs.minDateTimestamp,
|
|
2234
|
+
birthdateCommittedInputs.maxDateTimestamp
|
|
2218
2235
|
) : await getDateParameterCommitment(
|
|
2219
2236
|
ProofType.BIRTHDATE,
|
|
2220
|
-
birthdateCommittedInputs.
|
|
2221
|
-
birthdateCommittedInputs.
|
|
2222
|
-
birthdateCommittedInputs.
|
|
2237
|
+
birthdateCommittedInputs.currentDateTimestamp,
|
|
2238
|
+
birthdateCommittedInputs.minDateTimestamp,
|
|
2239
|
+
birthdateCommittedInputs.maxDateTimestamp
|
|
2223
2240
|
);
|
|
2224
2241
|
if (!paramCommitments.includes(birthdateParameterCommitment)) {
|
|
2225
2242
|
console.warn("This proof does not verify the birthdate");
|
|
@@ -2240,14 +2257,14 @@ var ZKPassport = class {
|
|
|
2240
2257
|
const expiryCommittedInputs = committedInputs?.compare_expiry;
|
|
2241
2258
|
const expiryParameterCommitment = isForEVM ? await getDateEVMParameterCommitment(
|
|
2242
2259
|
ProofType.EXPIRY_DATE,
|
|
2243
|
-
expiryCommittedInputs.
|
|
2244
|
-
expiryCommittedInputs.
|
|
2245
|
-
expiryCommittedInputs.
|
|
2260
|
+
expiryCommittedInputs.currentDateTimestamp,
|
|
2261
|
+
expiryCommittedInputs.minDateTimestamp,
|
|
2262
|
+
expiryCommittedInputs.maxDateTimestamp
|
|
2246
2263
|
) : await getDateParameterCommitment(
|
|
2247
2264
|
ProofType.EXPIRY_DATE,
|
|
2248
|
-
expiryCommittedInputs.
|
|
2249
|
-
expiryCommittedInputs.
|
|
2250
|
-
expiryCommittedInputs.
|
|
2265
|
+
expiryCommittedInputs.currentDateTimestamp,
|
|
2266
|
+
expiryCommittedInputs.minDateTimestamp,
|
|
2267
|
+
expiryCommittedInputs.maxDateTimestamp
|
|
2251
2268
|
);
|
|
2252
2269
|
if (!paramCommitments.includes(expiryParameterCommitment)) {
|
|
2253
2270
|
console.warn("This proof does not verify the expiry date");
|
|
@@ -2535,7 +2552,7 @@ var ZKPassport = class {
|
|
|
2535
2552
|
const paramCommitment = getParameterCommitmentFromDisclosureProof(proofData);
|
|
2536
2553
|
const committedInputs = proof.committedInputs?.compare_age;
|
|
2537
2554
|
const calculatedParamCommitment = await getAgeParameterCommitment(
|
|
2538
|
-
committedInputs.
|
|
2555
|
+
committedInputs.currentDateTimestamp,
|
|
2539
2556
|
committedInputs.minAge,
|
|
2540
2557
|
committedInputs.maxAge
|
|
2541
2558
|
);
|
|
@@ -2576,9 +2593,9 @@ var ZKPassport = class {
|
|
|
2576
2593
|
const committedInputs = proof.committedInputs?.compare_birthdate;
|
|
2577
2594
|
const calculatedParamCommitment = await getDateParameterCommitment(
|
|
2578
2595
|
ProofType.BIRTHDATE,
|
|
2579
|
-
committedInputs.
|
|
2580
|
-
committedInputs.
|
|
2581
|
-
committedInputs.
|
|
2596
|
+
committedInputs.currentDateTimestamp,
|
|
2597
|
+
committedInputs.minDateTimestamp,
|
|
2598
|
+
committedInputs.maxDateTimestamp
|
|
2582
2599
|
);
|
|
2583
2600
|
if (paramCommitment !== calculatedParamCommitment) {
|
|
2584
2601
|
console.warn(
|
|
@@ -2617,9 +2634,9 @@ var ZKPassport = class {
|
|
|
2617
2634
|
const committedInputs = proof.committedInputs?.compare_expiry;
|
|
2618
2635
|
const calculatedParamCommitment = await getDateParameterCommitment(
|
|
2619
2636
|
ProofType.EXPIRY_DATE,
|
|
2620
|
-
committedInputs.
|
|
2621
|
-
committedInputs.
|
|
2622
|
-
committedInputs.
|
|
2637
|
+
committedInputs.currentDateTimestamp,
|
|
2638
|
+
committedInputs.minDateTimestamp,
|
|
2639
|
+
committedInputs.maxDateTimestamp
|
|
2623
2640
|
);
|
|
2624
2641
|
if (paramCommitment !== calculatedParamCommitment) {
|
|
2625
2642
|
console.warn(
|
|
@@ -2865,17 +2882,7 @@ var ZKPassport = class {
|
|
|
2865
2882
|
verified: false
|
|
2866
2883
|
};
|
|
2867
2884
|
}
|
|
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
|
-
}
|
|
2885
|
+
const formattedResult = formatQueryResultDates(queryResult);
|
|
2879
2886
|
const { BarretenbergVerifier } = await import("@aztec/bb.js");
|
|
2880
2887
|
if (typeof window === "undefined" && !writingDirectory) {
|
|
2881
2888
|
writingDirectory = "/tmp";
|
|
@@ -2984,7 +2991,7 @@ var ZKPassport = class {
|
|
|
2984
2991
|
}
|
|
2985
2992
|
getSolidityVerifierParameters({
|
|
2986
2993
|
proof,
|
|
2987
|
-
|
|
2994
|
+
validityPeriodInSeconds = 7 * 24 * 60 * 60,
|
|
2988
2995
|
domain,
|
|
2989
2996
|
scope,
|
|
2990
2997
|
devMode = false
|
|
@@ -3026,19 +3033,19 @@ var ZKPassport = class {
|
|
|
3026
3033
|
).map((x) => x.toString(16).padStart(2, "0")).join("");
|
|
3027
3034
|
} else if (circuitName === "compare_age_evm") {
|
|
3028
3035
|
const value = proof.committedInputs[circuitName];
|
|
3029
|
-
const currentDateBytes = Array.from(
|
|
3036
|
+
const currentDateBytes = Array.from(numberToBytesBE(value.currentDateTimestamp, 4));
|
|
3030
3037
|
compressedCommittedInputs2 = 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");
|
|
3031
3038
|
} else if (circuitName === "compare_birthdate_evm") {
|
|
3032
3039
|
const value = proof.committedInputs[circuitName];
|
|
3033
|
-
const currentDateBytes = Array.from(
|
|
3034
|
-
const minDateBytes = Array.from(
|
|
3035
|
-
const maxDateBytes = Array.from(
|
|
3040
|
+
const currentDateBytes = Array.from(numberToBytesBE(value.currentDateTimestamp, 4));
|
|
3041
|
+
const minDateBytes = Array.from(numberToBytesBE(value.minDateTimestamp, 4));
|
|
3042
|
+
const maxDateBytes = Array.from(numberToBytesBE(value.maxDateTimestamp, 4));
|
|
3036
3043
|
compressedCommittedInputs2 = 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("");
|
|
3037
3044
|
} else if (circuitName === "compare_expiry_evm") {
|
|
3038
3045
|
const value = proof.committedInputs[circuitName];
|
|
3039
|
-
const currentDateBytes = Array.from(
|
|
3040
|
-
const minDateBytes = Array.from(
|
|
3041
|
-
const maxDateBytes = Array.from(
|
|
3046
|
+
const currentDateBytes = Array.from(numberToBytesBE(value.currentDateTimestamp, 4));
|
|
3047
|
+
const minDateBytes = Array.from(numberToBytesBE(value.minDateTimestamp, 4));
|
|
3048
|
+
const maxDateBytes = Array.from(numberToBytesBE(value.maxDateTimestamp, 4));
|
|
3042
3049
|
compressedCommittedInputs2 = 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("");
|
|
3043
3050
|
} else if (circuitName === "disclose_bytes_evm") {
|
|
3044
3051
|
const value = proof.committedInputs[circuitName];
|
|
@@ -3085,7 +3092,7 @@ var ZKPassport = class {
|
|
|
3085
3092
|
publicInputs: proofData.publicInputs,
|
|
3086
3093
|
committedInputs: `0x${compressedCommittedInputs}`,
|
|
3087
3094
|
committedInputCounts: committedInputCountsArray,
|
|
3088
|
-
|
|
3095
|
+
validityPeriodInSeconds,
|
|
3089
3096
|
domain: domain ?? this.domain,
|
|
3090
3097
|
scope: scope ?? "",
|
|
3091
3098
|
devMode
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zkpassport/sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.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",
|
|
@@ -36,8 +36,8 @@
|
|
|
36
36
|
"@noble/hashes": "^1.7.2",
|
|
37
37
|
"@noble/secp256k1": "^2.2.3",
|
|
38
38
|
"@obsidion/bridge": "^0.10.4",
|
|
39
|
-
"@zkpassport/registry": "0.
|
|
40
|
-
"@zkpassport/utils": "0.
|
|
39
|
+
"@zkpassport/registry": "0.10.0",
|
|
40
|
+
"@zkpassport/utils": "0.22.1",
|
|
41
41
|
"buffer": "^6.0.3",
|
|
42
42
|
"i18n-iso-countries": "^7.12.0",
|
|
43
43
|
"pako": "^2.1.0",
|