@zkpassport/sdk 0.7.1 → 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 +58 -32
- package/dist/cjs/index.d.cts +21 -4
- package/dist/esm/index.d.ts +21 -4
- package/dist/esm/index.js +59 -33
- 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
|
}
|
|
@@ -1072,6 +1078,26 @@ var ZKPassport = class {
|
|
|
1072
1078
|
};
|
|
1073
1079
|
return this.getZkPassportRequest(topic);
|
|
1074
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
|
+
},
|
|
1075
1101
|
done: () => {
|
|
1076
1102
|
this.setExpectedProofCount(topic);
|
|
1077
1103
|
return {
|
|
@@ -2174,11 +2200,11 @@ var ZKPassport = class {
|
|
|
2174
2200
|
if (!!committedInputs?.compare_age) {
|
|
2175
2201
|
const ageCommittedInputs = committedInputs?.compare_age;
|
|
2176
2202
|
const ageParameterCommitment = isForEVM ? await (0, import_utils.getAgeEVMParameterCommitment)(
|
|
2177
|
-
ageCommittedInputs.
|
|
2203
|
+
ageCommittedInputs.currentDateTimestamp,
|
|
2178
2204
|
ageCommittedInputs.minAge,
|
|
2179
2205
|
ageCommittedInputs.maxAge
|
|
2180
2206
|
) : await (0, import_utils.getAgeParameterCommitment)(
|
|
2181
|
-
ageCommittedInputs.
|
|
2207
|
+
ageCommittedInputs.currentDateTimestamp,
|
|
2182
2208
|
ageCommittedInputs.minAge,
|
|
2183
2209
|
ageCommittedInputs.maxAge
|
|
2184
2210
|
);
|
|
@@ -2201,14 +2227,14 @@ var ZKPassport = class {
|
|
|
2201
2227
|
const birthdateCommittedInputs = committedInputs?.compare_birthdate;
|
|
2202
2228
|
const birthdateParameterCommitment = isForEVM ? await (0, import_utils.getDateEVMParameterCommitment)(
|
|
2203
2229
|
import_utils.ProofType.BIRTHDATE,
|
|
2204
|
-
birthdateCommittedInputs.
|
|
2205
|
-
birthdateCommittedInputs.
|
|
2206
|
-
birthdateCommittedInputs.
|
|
2230
|
+
birthdateCommittedInputs.currentDateTimestamp,
|
|
2231
|
+
birthdateCommittedInputs.minDateTimestamp,
|
|
2232
|
+
birthdateCommittedInputs.maxDateTimestamp
|
|
2207
2233
|
) : await (0, import_utils.getDateParameterCommitment)(
|
|
2208
2234
|
import_utils.ProofType.BIRTHDATE,
|
|
2209
|
-
birthdateCommittedInputs.
|
|
2210
|
-
birthdateCommittedInputs.
|
|
2211
|
-
birthdateCommittedInputs.
|
|
2235
|
+
birthdateCommittedInputs.currentDateTimestamp,
|
|
2236
|
+
birthdateCommittedInputs.minDateTimestamp,
|
|
2237
|
+
birthdateCommittedInputs.maxDateTimestamp
|
|
2212
2238
|
);
|
|
2213
2239
|
if (!paramCommitments.includes(birthdateParameterCommitment)) {
|
|
2214
2240
|
console.warn("This proof does not verify the birthdate");
|
|
@@ -2229,14 +2255,14 @@ var ZKPassport = class {
|
|
|
2229
2255
|
const expiryCommittedInputs = committedInputs?.compare_expiry;
|
|
2230
2256
|
const expiryParameterCommitment = isForEVM ? await (0, import_utils.getDateEVMParameterCommitment)(
|
|
2231
2257
|
import_utils.ProofType.EXPIRY_DATE,
|
|
2232
|
-
expiryCommittedInputs.
|
|
2233
|
-
expiryCommittedInputs.
|
|
2234
|
-
expiryCommittedInputs.
|
|
2258
|
+
expiryCommittedInputs.currentDateTimestamp,
|
|
2259
|
+
expiryCommittedInputs.minDateTimestamp,
|
|
2260
|
+
expiryCommittedInputs.maxDateTimestamp
|
|
2235
2261
|
) : await (0, import_utils.getDateParameterCommitment)(
|
|
2236
2262
|
import_utils.ProofType.EXPIRY_DATE,
|
|
2237
|
-
expiryCommittedInputs.
|
|
2238
|
-
expiryCommittedInputs.
|
|
2239
|
-
expiryCommittedInputs.
|
|
2263
|
+
expiryCommittedInputs.currentDateTimestamp,
|
|
2264
|
+
expiryCommittedInputs.minDateTimestamp,
|
|
2265
|
+
expiryCommittedInputs.maxDateTimestamp
|
|
2240
2266
|
);
|
|
2241
2267
|
if (!paramCommitments.includes(expiryParameterCommitment)) {
|
|
2242
2268
|
console.warn("This proof does not verify the expiry date");
|
|
@@ -2524,7 +2550,7 @@ var ZKPassport = class {
|
|
|
2524
2550
|
const paramCommitment = (0, import_utils.getParameterCommitmentFromDisclosureProof)(proofData);
|
|
2525
2551
|
const committedInputs = proof.committedInputs?.compare_age;
|
|
2526
2552
|
const calculatedParamCommitment = await (0, import_utils.getAgeParameterCommitment)(
|
|
2527
|
-
committedInputs.
|
|
2553
|
+
committedInputs.currentDateTimestamp,
|
|
2528
2554
|
committedInputs.minAge,
|
|
2529
2555
|
committedInputs.maxAge
|
|
2530
2556
|
);
|
|
@@ -2565,9 +2591,9 @@ var ZKPassport = class {
|
|
|
2565
2591
|
const committedInputs = proof.committedInputs?.compare_birthdate;
|
|
2566
2592
|
const calculatedParamCommitment = await (0, import_utils.getDateParameterCommitment)(
|
|
2567
2593
|
import_utils.ProofType.BIRTHDATE,
|
|
2568
|
-
committedInputs.
|
|
2569
|
-
committedInputs.
|
|
2570
|
-
committedInputs.
|
|
2594
|
+
committedInputs.currentDateTimestamp,
|
|
2595
|
+
committedInputs.minDateTimestamp,
|
|
2596
|
+
committedInputs.maxDateTimestamp
|
|
2571
2597
|
);
|
|
2572
2598
|
if (paramCommitment !== calculatedParamCommitment) {
|
|
2573
2599
|
console.warn(
|
|
@@ -2606,9 +2632,9 @@ var ZKPassport = class {
|
|
|
2606
2632
|
const committedInputs = proof.committedInputs?.compare_expiry;
|
|
2607
2633
|
const calculatedParamCommitment = await (0, import_utils.getDateParameterCommitment)(
|
|
2608
2634
|
import_utils.ProofType.EXPIRY_DATE,
|
|
2609
|
-
committedInputs.
|
|
2610
|
-
committedInputs.
|
|
2611
|
-
committedInputs.
|
|
2635
|
+
committedInputs.currentDateTimestamp,
|
|
2636
|
+
committedInputs.minDateTimestamp,
|
|
2637
|
+
committedInputs.maxDateTimestamp
|
|
2612
2638
|
);
|
|
2613
2639
|
if (paramCommitment !== calculatedParamCommitment) {
|
|
2614
2640
|
console.warn(
|
|
@@ -2963,7 +2989,7 @@ var ZKPassport = class {
|
|
|
2963
2989
|
}
|
|
2964
2990
|
getSolidityVerifierParameters({
|
|
2965
2991
|
proof,
|
|
2966
|
-
|
|
2992
|
+
validityPeriodInSeconds = 7 * 24 * 60 * 60,
|
|
2967
2993
|
domain,
|
|
2968
2994
|
scope,
|
|
2969
2995
|
devMode = false
|
|
@@ -3005,19 +3031,19 @@ var ZKPassport = class {
|
|
|
3005
3031
|
).map((x) => x.toString(16).padStart(2, "0")).join("");
|
|
3006
3032
|
} else if (circuitName === "compare_age_evm") {
|
|
3007
3033
|
const value = proof.committedInputs[circuitName];
|
|
3008
|
-
const currentDateBytes = Array.from(
|
|
3034
|
+
const currentDateBytes = Array.from((0, import_utils2.numberToBytesBE)(value.currentDateTimestamp, 4));
|
|
3009
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");
|
|
3010
3036
|
} else if (circuitName === "compare_birthdate_evm") {
|
|
3011
3037
|
const value = proof.committedInputs[circuitName];
|
|
3012
|
-
const currentDateBytes = Array.from(
|
|
3013
|
-
const minDateBytes = Array.from(
|
|
3014
|
-
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));
|
|
3015
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("");
|
|
3016
3042
|
} else if (circuitName === "compare_expiry_evm") {
|
|
3017
3043
|
const value = proof.committedInputs[circuitName];
|
|
3018
|
-
const currentDateBytes = Array.from(
|
|
3019
|
-
const minDateBytes = Array.from(
|
|
3020
|
-
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));
|
|
3021
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("");
|
|
3022
3048
|
} else if (circuitName === "disclose_bytes_evm") {
|
|
3023
3049
|
const value = proof.committedInputs[circuitName];
|
|
@@ -3064,7 +3090,7 @@ var ZKPassport = class {
|
|
|
3064
3090
|
publicInputs: proofData.publicInputs,
|
|
3065
3091
|
committedInputs: `0x${compressedCommittedInputs}`,
|
|
3066
3092
|
committedInputCounts: committedInputCountsArray,
|
|
3067
|
-
|
|
3093
|
+
validityPeriodInSeconds,
|
|
3068
3094
|
domain: domain ?? this.domain,
|
|
3069
3095
|
scope: scope ?? "",
|
|
3070
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
|
@@ -50,7 +50,7 @@ import {
|
|
|
50
50
|
areDatesEqual,
|
|
51
51
|
formatQueryResultDates
|
|
52
52
|
} from "@zkpassport/utils";
|
|
53
|
-
import { bytesToHex } from "@noble/ciphers/utils";
|
|
53
|
+
import { bytesToHex, numberToBytesBE } from "@noble/ciphers/utils";
|
|
54
54
|
import i18en from "i18n-iso-countries/langs/en.json";
|
|
55
55
|
import { Buffer } from "buffer/";
|
|
56
56
|
import { sha256 } from "@noble/hashes/sha2";
|
|
@@ -815,8 +815,8 @@ import {
|
|
|
815
815
|
ASEAN_COUNTRIES,
|
|
816
816
|
MERCOSUR_COUNTRIES
|
|
817
817
|
} from "@zkpassport/utils";
|
|
818
|
-
var VERSION = "0.
|
|
819
|
-
var DEFAULT_DATE_VALUE = new Date(
|
|
818
|
+
var VERSION = "0.8.0";
|
|
819
|
+
var DEFAULT_DATE_VALUE = /* @__PURE__ */ new Date(0);
|
|
820
820
|
if (typeof globalThis.Buffer === "undefined") {
|
|
821
821
|
globalThis.Buffer = Buffer;
|
|
822
822
|
if (typeof window !== "undefined") {
|
|
@@ -969,6 +969,12 @@ var ZKPassport = class {
|
|
|
969
969
|
if (this.topicToConfig[topic].bind) {
|
|
970
970
|
neededCircuits.push("bind");
|
|
971
971
|
}
|
|
972
|
+
if (this.topicToConfig[topic].sanctions) {
|
|
973
|
+
neededCircuits.push("sanctions");
|
|
974
|
+
}
|
|
975
|
+
if (this.topicToConfig[topic].facematch) {
|
|
976
|
+
neededCircuits.push("facematch");
|
|
977
|
+
}
|
|
972
978
|
this.topicToExpectedProofCount[topic] = neededCircuits.length === 0 ? 4 : 3 + neededCircuits.length;
|
|
973
979
|
this.topicToFailedProofCount[topic] = 0;
|
|
974
980
|
}
|
|
@@ -1074,6 +1080,26 @@ var ZKPassport = class {
|
|
|
1074
1080
|
};
|
|
1075
1081
|
return this.getZkPassportRequest(topic);
|
|
1076
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
|
+
},
|
|
1077
1103
|
done: () => {
|
|
1078
1104
|
this.setExpectedProofCount(topic);
|
|
1079
1105
|
return {
|
|
@@ -2176,11 +2202,11 @@ var ZKPassport = class {
|
|
|
2176
2202
|
if (!!committedInputs?.compare_age) {
|
|
2177
2203
|
const ageCommittedInputs = committedInputs?.compare_age;
|
|
2178
2204
|
const ageParameterCommitment = isForEVM ? await getAgeEVMParameterCommitment(
|
|
2179
|
-
ageCommittedInputs.
|
|
2205
|
+
ageCommittedInputs.currentDateTimestamp,
|
|
2180
2206
|
ageCommittedInputs.minAge,
|
|
2181
2207
|
ageCommittedInputs.maxAge
|
|
2182
2208
|
) : await getAgeParameterCommitment(
|
|
2183
|
-
ageCommittedInputs.
|
|
2209
|
+
ageCommittedInputs.currentDateTimestamp,
|
|
2184
2210
|
ageCommittedInputs.minAge,
|
|
2185
2211
|
ageCommittedInputs.maxAge
|
|
2186
2212
|
);
|
|
@@ -2203,14 +2229,14 @@ var ZKPassport = class {
|
|
|
2203
2229
|
const birthdateCommittedInputs = committedInputs?.compare_birthdate;
|
|
2204
2230
|
const birthdateParameterCommitment = isForEVM ? await getDateEVMParameterCommitment(
|
|
2205
2231
|
ProofType.BIRTHDATE,
|
|
2206
|
-
birthdateCommittedInputs.
|
|
2207
|
-
birthdateCommittedInputs.
|
|
2208
|
-
birthdateCommittedInputs.
|
|
2232
|
+
birthdateCommittedInputs.currentDateTimestamp,
|
|
2233
|
+
birthdateCommittedInputs.minDateTimestamp,
|
|
2234
|
+
birthdateCommittedInputs.maxDateTimestamp
|
|
2209
2235
|
) : await getDateParameterCommitment(
|
|
2210
2236
|
ProofType.BIRTHDATE,
|
|
2211
|
-
birthdateCommittedInputs.
|
|
2212
|
-
birthdateCommittedInputs.
|
|
2213
|
-
birthdateCommittedInputs.
|
|
2237
|
+
birthdateCommittedInputs.currentDateTimestamp,
|
|
2238
|
+
birthdateCommittedInputs.minDateTimestamp,
|
|
2239
|
+
birthdateCommittedInputs.maxDateTimestamp
|
|
2214
2240
|
);
|
|
2215
2241
|
if (!paramCommitments.includes(birthdateParameterCommitment)) {
|
|
2216
2242
|
console.warn("This proof does not verify the birthdate");
|
|
@@ -2231,14 +2257,14 @@ var ZKPassport = class {
|
|
|
2231
2257
|
const expiryCommittedInputs = committedInputs?.compare_expiry;
|
|
2232
2258
|
const expiryParameterCommitment = isForEVM ? await getDateEVMParameterCommitment(
|
|
2233
2259
|
ProofType.EXPIRY_DATE,
|
|
2234
|
-
expiryCommittedInputs.
|
|
2235
|
-
expiryCommittedInputs.
|
|
2236
|
-
expiryCommittedInputs.
|
|
2260
|
+
expiryCommittedInputs.currentDateTimestamp,
|
|
2261
|
+
expiryCommittedInputs.minDateTimestamp,
|
|
2262
|
+
expiryCommittedInputs.maxDateTimestamp
|
|
2237
2263
|
) : await getDateParameterCommitment(
|
|
2238
2264
|
ProofType.EXPIRY_DATE,
|
|
2239
|
-
expiryCommittedInputs.
|
|
2240
|
-
expiryCommittedInputs.
|
|
2241
|
-
expiryCommittedInputs.
|
|
2265
|
+
expiryCommittedInputs.currentDateTimestamp,
|
|
2266
|
+
expiryCommittedInputs.minDateTimestamp,
|
|
2267
|
+
expiryCommittedInputs.maxDateTimestamp
|
|
2242
2268
|
);
|
|
2243
2269
|
if (!paramCommitments.includes(expiryParameterCommitment)) {
|
|
2244
2270
|
console.warn("This proof does not verify the expiry date");
|
|
@@ -2526,7 +2552,7 @@ var ZKPassport = class {
|
|
|
2526
2552
|
const paramCommitment = getParameterCommitmentFromDisclosureProof(proofData);
|
|
2527
2553
|
const committedInputs = proof.committedInputs?.compare_age;
|
|
2528
2554
|
const calculatedParamCommitment = await getAgeParameterCommitment(
|
|
2529
|
-
committedInputs.
|
|
2555
|
+
committedInputs.currentDateTimestamp,
|
|
2530
2556
|
committedInputs.minAge,
|
|
2531
2557
|
committedInputs.maxAge
|
|
2532
2558
|
);
|
|
@@ -2567,9 +2593,9 @@ var ZKPassport = class {
|
|
|
2567
2593
|
const committedInputs = proof.committedInputs?.compare_birthdate;
|
|
2568
2594
|
const calculatedParamCommitment = await getDateParameterCommitment(
|
|
2569
2595
|
ProofType.BIRTHDATE,
|
|
2570
|
-
committedInputs.
|
|
2571
|
-
committedInputs.
|
|
2572
|
-
committedInputs.
|
|
2596
|
+
committedInputs.currentDateTimestamp,
|
|
2597
|
+
committedInputs.minDateTimestamp,
|
|
2598
|
+
committedInputs.maxDateTimestamp
|
|
2573
2599
|
);
|
|
2574
2600
|
if (paramCommitment !== calculatedParamCommitment) {
|
|
2575
2601
|
console.warn(
|
|
@@ -2608,9 +2634,9 @@ var ZKPassport = class {
|
|
|
2608
2634
|
const committedInputs = proof.committedInputs?.compare_expiry;
|
|
2609
2635
|
const calculatedParamCommitment = await getDateParameterCommitment(
|
|
2610
2636
|
ProofType.EXPIRY_DATE,
|
|
2611
|
-
committedInputs.
|
|
2612
|
-
committedInputs.
|
|
2613
|
-
committedInputs.
|
|
2637
|
+
committedInputs.currentDateTimestamp,
|
|
2638
|
+
committedInputs.minDateTimestamp,
|
|
2639
|
+
committedInputs.maxDateTimestamp
|
|
2614
2640
|
);
|
|
2615
2641
|
if (paramCommitment !== calculatedParamCommitment) {
|
|
2616
2642
|
console.warn(
|
|
@@ -2965,7 +2991,7 @@ var ZKPassport = class {
|
|
|
2965
2991
|
}
|
|
2966
2992
|
getSolidityVerifierParameters({
|
|
2967
2993
|
proof,
|
|
2968
|
-
|
|
2994
|
+
validityPeriodInSeconds = 7 * 24 * 60 * 60,
|
|
2969
2995
|
domain,
|
|
2970
2996
|
scope,
|
|
2971
2997
|
devMode = false
|
|
@@ -3007,19 +3033,19 @@ var ZKPassport = class {
|
|
|
3007
3033
|
).map((x) => x.toString(16).padStart(2, "0")).join("");
|
|
3008
3034
|
} else if (circuitName === "compare_age_evm") {
|
|
3009
3035
|
const value = proof.committedInputs[circuitName];
|
|
3010
|
-
const currentDateBytes = Array.from(
|
|
3036
|
+
const currentDateBytes = Array.from(numberToBytesBE(value.currentDateTimestamp, 4));
|
|
3011
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");
|
|
3012
3038
|
} else if (circuitName === "compare_birthdate_evm") {
|
|
3013
3039
|
const value = proof.committedInputs[circuitName];
|
|
3014
|
-
const currentDateBytes = Array.from(
|
|
3015
|
-
const minDateBytes = Array.from(
|
|
3016
|
-
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));
|
|
3017
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("");
|
|
3018
3044
|
} else if (circuitName === "compare_expiry_evm") {
|
|
3019
3045
|
const value = proof.committedInputs[circuitName];
|
|
3020
|
-
const currentDateBytes = Array.from(
|
|
3021
|
-
const minDateBytes = Array.from(
|
|
3022
|
-
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));
|
|
3023
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("");
|
|
3024
3050
|
} else if (circuitName === "disclose_bytes_evm") {
|
|
3025
3051
|
const value = proof.committedInputs[circuitName];
|
|
@@ -3066,7 +3092,7 @@ var ZKPassport = class {
|
|
|
3066
3092
|
publicInputs: proofData.publicInputs,
|
|
3067
3093
|
committedInputs: `0x${compressedCommittedInputs}`,
|
|
3068
3094
|
committedInputCounts: committedInputCountsArray,
|
|
3069
|
-
|
|
3095
|
+
validityPeriodInSeconds,
|
|
3070
3096
|
domain: domain ?? this.domain,
|
|
3071
3097
|
scope: scope ?? "",
|
|
3072
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",
|