@zkpassport/ui 0.16.1 → 0.17.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/README.md +61 -6
- package/dist/cjs/button.cjs +149 -0
- package/dist/cjs/button.cjs.map +1 -0
- package/dist/cjs/button.d.cts +10 -0
- package/dist/cjs/index.cjs +586 -20
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/index.d.cts +4 -3
- package/dist/cjs/react-button.cjs +150 -0
- package/dist/cjs/react-button.cjs.map +1 -0
- package/dist/cjs/react-button.d.cts +17 -0
- package/dist/cjs/react.cjs +586 -20
- package/dist/cjs/react.cjs.map +1 -1
- package/dist/cjs/react.d.cts +4 -3
- package/dist/cjs/types-BpU_Si5b.d.cts +123 -0
- package/dist/cjs/verify-button-BTuf-26F.d.cts +978 -0
- package/dist/esm/button.d.ts +10 -0
- package/dist/esm/button.js +149 -0
- package/dist/esm/button.js.map +1 -0
- package/dist/esm/index.d.ts +4 -3
- package/dist/esm/index.js +586 -20
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/react-button.d.ts +17 -0
- package/dist/esm/react-button.js +150 -0
- package/dist/esm/react-button.js.map +1 -0
- package/dist/esm/react.d.ts +4 -3
- package/dist/esm/react.js +586 -20
- package/dist/esm/react.js.map +1 -1
- package/dist/esm/types-DouDGnJI.d.ts +123 -0
- package/dist/esm/verify-button-BTuf-26F.d.ts +978 -0
- package/dist/styles.css +459 -16
- package/package.json +31 -13
- package/dist/cjs/types-DV8w93iS.d.cts +0 -31
- package/dist/esm/types-DV8w93iS.d.ts +0 -31
|
@@ -0,0 +1,978 @@
|
|
|
1
|
+
declare global {
|
|
2
|
+
interface BigIntConstructor {
|
|
3
|
+
(value: Binary): bigint;
|
|
4
|
+
}
|
|
5
|
+
}
|
|
6
|
+
type BinaryInput = bigint | Buffer | Uint8Array | number[] | string | number | ArrayBufferLike;
|
|
7
|
+
type HexString = string & {
|
|
8
|
+
readonly __hex: unique symbol;
|
|
9
|
+
};
|
|
10
|
+
declare class Binary {
|
|
11
|
+
private readonly bytes;
|
|
12
|
+
constructor(data: BinaryInput);
|
|
13
|
+
private static convertToBytes;
|
|
14
|
+
private static isHexString;
|
|
15
|
+
static from(data: BinaryInput): Binary;
|
|
16
|
+
static fromHex(hex: string): Binary;
|
|
17
|
+
static fromBuffer(buffer: Buffer): Binary;
|
|
18
|
+
static fromBase64(base64: string): Binary;
|
|
19
|
+
static empty(): Binary;
|
|
20
|
+
static zero(length: number): Binary;
|
|
21
|
+
toBigInt(): bigint;
|
|
22
|
+
toUInt8Array(): Uint8Array;
|
|
23
|
+
toNumberArray(): number[];
|
|
24
|
+
toHex(): HexString | string;
|
|
25
|
+
toBuffer(): Buffer;
|
|
26
|
+
toString(encoding?: BufferEncoding): string;
|
|
27
|
+
toBase64(): string;
|
|
28
|
+
toJSON(): string;
|
|
29
|
+
[Symbol.toPrimitive](hint: string): string | number | bigint;
|
|
30
|
+
valueOf(): bigint;
|
|
31
|
+
get length(): number;
|
|
32
|
+
[Symbol.iterator](): Iterator<number>;
|
|
33
|
+
equals(other: Binary): boolean;
|
|
34
|
+
slice(start?: number, end?: number): Binary;
|
|
35
|
+
concat(other: Binary): Binary;
|
|
36
|
+
compare(other: Binary): number;
|
|
37
|
+
xor(other: Binary): Binary;
|
|
38
|
+
and(other: Binary): Binary;
|
|
39
|
+
or(other: Binary): Binary;
|
|
40
|
+
not(): Binary;
|
|
41
|
+
padStart(length: number, fillByte?: number): Binary;
|
|
42
|
+
padEnd(length: number, fillByte?: number): Binary;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
type Alpha3Code =
|
|
46
|
+
| "AFG"
|
|
47
|
+
| "ALB"
|
|
48
|
+
| "DZA"
|
|
49
|
+
| "ASM"
|
|
50
|
+
| "AND"
|
|
51
|
+
| "AGO"
|
|
52
|
+
| "AIA"
|
|
53
|
+
| "ATA"
|
|
54
|
+
| "ATG"
|
|
55
|
+
| "ARG"
|
|
56
|
+
| "ARM"
|
|
57
|
+
| "ABW"
|
|
58
|
+
| "AUS"
|
|
59
|
+
| "AUT"
|
|
60
|
+
| "AZE"
|
|
61
|
+
| "BHS"
|
|
62
|
+
| "BHR"
|
|
63
|
+
| "BGD"
|
|
64
|
+
| "BRB"
|
|
65
|
+
| "BLR"
|
|
66
|
+
| "BEL"
|
|
67
|
+
| "BLZ"
|
|
68
|
+
| "BEN"
|
|
69
|
+
| "BMU"
|
|
70
|
+
| "BTN"
|
|
71
|
+
| "BOL"
|
|
72
|
+
| "BIH"
|
|
73
|
+
| "BWA"
|
|
74
|
+
| "BVT"
|
|
75
|
+
| "BRA"
|
|
76
|
+
| "IOT"
|
|
77
|
+
| "BRN"
|
|
78
|
+
| "BGR"
|
|
79
|
+
| "BFA"
|
|
80
|
+
| "BDI"
|
|
81
|
+
| "KHM"
|
|
82
|
+
| "CMR"
|
|
83
|
+
| "CAN"
|
|
84
|
+
| "CPV"
|
|
85
|
+
| "CYM"
|
|
86
|
+
| "CAF"
|
|
87
|
+
| "TCD"
|
|
88
|
+
| "CHL"
|
|
89
|
+
| "CHN"
|
|
90
|
+
| "CXR"
|
|
91
|
+
| "CCK"
|
|
92
|
+
| "COL"
|
|
93
|
+
| "COM"
|
|
94
|
+
| "COG"
|
|
95
|
+
| "COD"
|
|
96
|
+
| "COK"
|
|
97
|
+
| "CRI"
|
|
98
|
+
| "CIV"
|
|
99
|
+
| "HRV"
|
|
100
|
+
| "CUB"
|
|
101
|
+
| "CYP"
|
|
102
|
+
| "CZE"
|
|
103
|
+
| "DNK"
|
|
104
|
+
| "DJI"
|
|
105
|
+
| "DMA"
|
|
106
|
+
| "DOM"
|
|
107
|
+
| "ECU"
|
|
108
|
+
| "EGY"
|
|
109
|
+
| "SLV"
|
|
110
|
+
| "GNQ"
|
|
111
|
+
| "ERI"
|
|
112
|
+
| "EST"
|
|
113
|
+
| "ETH"
|
|
114
|
+
| "FLK"
|
|
115
|
+
| "FRO"
|
|
116
|
+
| "FJI"
|
|
117
|
+
| "FIN"
|
|
118
|
+
| "FRA"
|
|
119
|
+
| "GUF"
|
|
120
|
+
| "PYF"
|
|
121
|
+
| "ATF"
|
|
122
|
+
| "GAB"
|
|
123
|
+
| "GMB"
|
|
124
|
+
| "GEO"
|
|
125
|
+
| "DEU"
|
|
126
|
+
| "GHA"
|
|
127
|
+
| "GIB"
|
|
128
|
+
| "GRC"
|
|
129
|
+
| "GRL"
|
|
130
|
+
| "GRD"
|
|
131
|
+
| "GLP"
|
|
132
|
+
| "GUM"
|
|
133
|
+
| "GTM"
|
|
134
|
+
| "GIN"
|
|
135
|
+
| "GNB"
|
|
136
|
+
| "GUY"
|
|
137
|
+
| "HTI"
|
|
138
|
+
| "HMD"
|
|
139
|
+
| "VAT"
|
|
140
|
+
| "HND"
|
|
141
|
+
| "HKG"
|
|
142
|
+
| "HUN"
|
|
143
|
+
| "ISL"
|
|
144
|
+
| "IND"
|
|
145
|
+
| "IDN"
|
|
146
|
+
| "IRN"
|
|
147
|
+
| "IRQ"
|
|
148
|
+
| "IRL"
|
|
149
|
+
| "ISR"
|
|
150
|
+
| "ITA"
|
|
151
|
+
| "JAM"
|
|
152
|
+
| "JPN"
|
|
153
|
+
| "JOR"
|
|
154
|
+
| "KAZ"
|
|
155
|
+
| "KEN"
|
|
156
|
+
| "KIR"
|
|
157
|
+
| "PRK"
|
|
158
|
+
| "KOR"
|
|
159
|
+
| "KWT"
|
|
160
|
+
| "KGZ"
|
|
161
|
+
| "LAO"
|
|
162
|
+
| "LVA"
|
|
163
|
+
| "LBN"
|
|
164
|
+
| "LSO"
|
|
165
|
+
| "LBR"
|
|
166
|
+
| "LBY"
|
|
167
|
+
| "LIE"
|
|
168
|
+
| "LTU"
|
|
169
|
+
| "LUX"
|
|
170
|
+
| "MAC"
|
|
171
|
+
| "MDG"
|
|
172
|
+
| "MWI"
|
|
173
|
+
| "MYS"
|
|
174
|
+
| "MDV"
|
|
175
|
+
| "MLI"
|
|
176
|
+
| "MLT"
|
|
177
|
+
| "MHL"
|
|
178
|
+
| "MTQ"
|
|
179
|
+
| "MRT"
|
|
180
|
+
| "MUS"
|
|
181
|
+
| "MYT"
|
|
182
|
+
| "MEX"
|
|
183
|
+
| "FSM"
|
|
184
|
+
| "MDA"
|
|
185
|
+
| "MCO"
|
|
186
|
+
| "MNG"
|
|
187
|
+
| "MSR"
|
|
188
|
+
| "MAR"
|
|
189
|
+
| "MOZ"
|
|
190
|
+
| "MMR"
|
|
191
|
+
| "NAM"
|
|
192
|
+
| "NRU"
|
|
193
|
+
| "NPL"
|
|
194
|
+
| "NLD"
|
|
195
|
+
| "NCL"
|
|
196
|
+
| "NZL"
|
|
197
|
+
| "NIC"
|
|
198
|
+
| "NER"
|
|
199
|
+
| "NGA"
|
|
200
|
+
| "NIU"
|
|
201
|
+
| "NFK"
|
|
202
|
+
| "MNP"
|
|
203
|
+
| "MKD"
|
|
204
|
+
| "NOR"
|
|
205
|
+
| "OMN"
|
|
206
|
+
| "PAK"
|
|
207
|
+
| "PLW"
|
|
208
|
+
| "PSE"
|
|
209
|
+
| "PAN"
|
|
210
|
+
| "PNG"
|
|
211
|
+
| "PRY"
|
|
212
|
+
| "PER"
|
|
213
|
+
| "PHL"
|
|
214
|
+
| "PCN"
|
|
215
|
+
| "POL"
|
|
216
|
+
| "PRT"
|
|
217
|
+
| "PRI"
|
|
218
|
+
| "QAT"
|
|
219
|
+
| "REU"
|
|
220
|
+
| "ROU"
|
|
221
|
+
| "RUS"
|
|
222
|
+
| "RWA"
|
|
223
|
+
| "SHN"
|
|
224
|
+
| "KNA"
|
|
225
|
+
| "LCA"
|
|
226
|
+
| "SPM"
|
|
227
|
+
| "VCT"
|
|
228
|
+
| "WSM"
|
|
229
|
+
| "SMR"
|
|
230
|
+
| "STP"
|
|
231
|
+
| "SAU"
|
|
232
|
+
| "SEN"
|
|
233
|
+
| "SYC"
|
|
234
|
+
| "SLE"
|
|
235
|
+
| "SGP"
|
|
236
|
+
| "SVK"
|
|
237
|
+
| "SVN"
|
|
238
|
+
| "SLB"
|
|
239
|
+
| "SOM"
|
|
240
|
+
| "ZAF"
|
|
241
|
+
| "SGS"
|
|
242
|
+
| "ESP"
|
|
243
|
+
| "LKA"
|
|
244
|
+
| "SDN"
|
|
245
|
+
| "SUR"
|
|
246
|
+
| "SJM"
|
|
247
|
+
| "SWZ"
|
|
248
|
+
| "SWE"
|
|
249
|
+
| "CHE"
|
|
250
|
+
| "SYR"
|
|
251
|
+
| "TWN"
|
|
252
|
+
| "TJK"
|
|
253
|
+
| "TZA"
|
|
254
|
+
| "THA"
|
|
255
|
+
| "TLS"
|
|
256
|
+
| "TGO"
|
|
257
|
+
| "TKL"
|
|
258
|
+
| "TON"
|
|
259
|
+
| "TTO"
|
|
260
|
+
| "TUN"
|
|
261
|
+
| "TUR"
|
|
262
|
+
| "TKM"
|
|
263
|
+
| "TCA"
|
|
264
|
+
| "TUV"
|
|
265
|
+
| "UGA"
|
|
266
|
+
| "UKR"
|
|
267
|
+
| "ARE"
|
|
268
|
+
| "GBR"
|
|
269
|
+
| "USA"
|
|
270
|
+
| "UMI"
|
|
271
|
+
| "URY"
|
|
272
|
+
| "UZB"
|
|
273
|
+
| "VUT"
|
|
274
|
+
| "VEN"
|
|
275
|
+
| "VNM"
|
|
276
|
+
| "VGB"
|
|
277
|
+
| "VIR"
|
|
278
|
+
| "WLF"
|
|
279
|
+
| "ESH"
|
|
280
|
+
| "YEM"
|
|
281
|
+
| "ZMB"
|
|
282
|
+
| "ZWE"
|
|
283
|
+
| "ALA"
|
|
284
|
+
| "BES"
|
|
285
|
+
| "CUW"
|
|
286
|
+
| "GGY"
|
|
287
|
+
| "IMN"
|
|
288
|
+
| "JEY"
|
|
289
|
+
| "MNE"
|
|
290
|
+
| "BLM"
|
|
291
|
+
| "MAF"
|
|
292
|
+
| "SRB"
|
|
293
|
+
| "SXM"
|
|
294
|
+
| "SSD"
|
|
295
|
+
| "XKX"
|
|
296
|
+
|
|
297
|
+
type CountryName = "Afghanistan" | "Albania" | "Algeria" | "American Samoa" | "Andorra" | "Angola" | "Anguilla" | "Antarctica" | "Antigua and Barbuda" | "Argentina" | "Armenia" | "Aruba" | "Australia" | "Austria" | "Azerbaijan" | "Bahamas" | "Bahrain" | "Bangladesh" | "Barbados" | "Belarus" | "Belgium" | "Belize" | "Benin" | "Bermuda" | "Bhutan" | "Bolivia" | "Bosnia and Herzegovina" | "Botswana" | "Bouvet Island" | "Brazil" | "British Indian Ocean Territory" | "Brunei Darussalam" | "Bulgaria" | "Burkina Faso" | "Burundi" | "Cambodia" | "Cameroon" | "Canada" | "Cape Verde" | "Cayman Islands" | "Central African Republic" | "Chad" | "Chile" | "People's Republic of China" | "China" | "Christmas Island" | "Cocos (Keeling) Islands" | "Colombia" | "Comoros" | "Republic of the Congo" | "Congo" | "Democratic Republic of the Congo" | "Cook Islands" | "Costa Rica" | "Cote d'Ivoire" | "Côte d'Ivoire" | "Ivory Coast" | "Croatia" | "Cuba" | "Cyprus" | "Czech Republic" | "Czechia" | "Denmark" | "Djibouti" | "Dominica" | "Dominican Republic" | "Ecuador" | "Egypt" | "El Salvador" | "Equatorial Guinea" | "Eritrea" | "Estonia" | "Ethiopia" | "Falkland Islands (Malvinas)" | "Faroe Islands" | "Fiji" | "Finland" | "France" | "French Guiana" | "French Polynesia" | "French Southern Territories" | "Gabon" | "Republic of The Gambia" | "The Gambia" | "Gambia" | "Georgia" | "Germany" | "Ghana" | "Gibraltar" | "Greece" | "Greenland" | "Grenada" | "Guadeloupe" | "Guam" | "Guatemala" | "Guinea" | "Guinea-Bissau" | "Guyana" | "Haiti" | "Heard Island and McDonald Islands" | "Holy See (Vatican City State)" | "Honduras" | "Hong Kong" | "Hungary" | "Iceland" | "India" | "Indonesia" | "Islamic Republic of Iran" | "Iran" | "Iraq" | "Ireland" | "Israel" | "Italy" | "Jamaica" | "Japan" | "Jordan" | "Kazakhstan" | "Kenya" | "Kiribati" | "North Korea" | "South Korea" | "Korea, Republic of" | "Republic of Korea" | "Kuwait" | "Kyrgyzstan" | "Lao People's Democratic Republic" | "Latvia" | "Lebanon" | "Lesotho" | "Liberia" | "Libya" | "Liechtenstein" | "Lithuania" | "Luxembourg" | "Macao" | "Madagascar" | "Malawi" | "Malaysia" | "Maldives" | "Mali" | "Malta" | "Marshall Islands" | "Martinique" | "Mauritania" | "Mauritius" | "Mayotte" | "Mexico" | "Micronesia, Federated States of" | "Moldova, Republic of" | "Monaco" | "Mongolia" | "Montserrat" | "Morocco" | "Mozambique" | "Myanmar" | "Namibia" | "Nauru" | "Nepal" | "Netherlands" | "The Netherlands" | "Netherlands (Kingdom of the)" | "New Caledonia" | "New Zealand" | "Nicaragua" | "Niger" | "Nigeria" | "Niue" | "Norfolk Island" | "The Republic of North Macedonia" | "North Macedonia" | "Northern Mariana Islands" | "Norway" | "Oman" | "Pakistan" | "Palau" | "State of Palestine" | "Palestine" | "Panama" | "Papua New Guinea" | "Paraguay" | "Peru" | "Philippines" | "Pitcairn" | "Pitcairn Islands" | "Poland" | "Portugal" | "Puerto Rico" | "Qatar" | "Reunion" | "Romania" | "Russian Federation" | "Russia" | "Rwanda" | "Saint Helena" | "Saint Kitts and Nevis" | "Saint Lucia" | "Saint Pierre and Miquelon" | "Saint Vincent and the Grenadines" | "Samoa" | "San Marino" | "Sao Tome and Principe" | "Saudi Arabia" | "Senegal" | "Seychelles" | "Sierra Leone" | "Singapore" | "Slovakia" | "Slovenia" | "Solomon Islands" | "Somalia" | "South Africa" | "South Georgia and the South Sandwich Islands" | "Spain" | "Sri Lanka" | "Sudan" | "Suriname" | "Svalbard and Jan Mayen" | "Eswatini" | "Sweden" | "Switzerland" | "Syrian Arab Republic" | "Taiwan" | "Tajikistan" | "United Republic of Tanzania" | "Tanzania" | "Thailand" | "Timor-Leste" | "Togo" | "Tokelau" | "Tonga" | "Trinidad and Tobago" | "Tunisia" | "Türkiye" | "Turkey" | "Turkmenistan" | "Turks and Caicos Islands" | "Tuvalu" | "Uganda" | "Ukraine" | "United Arab Emirates" | "UAE" | "United Kingdom" | "UK" | "Great Britain" | "United States of America" | "United States" | "USA" | "U.S.A." | "US" | "U.S." | "United States Minor Outlying Islands" | "Uruguay" | "Uzbekistan" | "Vanuatu" | "Venezuela" | "Vietnam" | "Virgin Islands, British" | "Virgin Islands, U.S." | "Wallis and Futuna" | "Western Sahara" | "Yemen" | "Zambia" | "Zimbabwe" | "Åland Islands" | "Aland Islands" | "Bonaire, Sint Eustatius and Saba" | "Curaçao" | "Guernsey" | "Isle of Man" | "Jersey" | "Montenegro" | "Saint Barthélemy" | "Saint Martin (French part)" | "Serbia" | "Sint Maarten (Dutch part)" | "South Sudan" | "Kosovo" | "Zero Knowledge Republic";
|
|
298
|
+
|
|
299
|
+
type DisclosableIDCredential = "birthdate" | "expiry_date" | "nationality" | "firstname" | "lastname" | "fullname" | "document_number" | "document_type" | "issuing_country" | "gender";
|
|
300
|
+
type NumericalIDCredential = "age" | "birthdate" | "expiry_date";
|
|
301
|
+
type IDCredential = NumericalIDCredential | DisclosableIDCredential;
|
|
302
|
+
type IDCredentialValue<T extends IDCredential> = T extends "nationality" | "issuing_country" ? CountryName | Alpha3Code : T extends "gender" ? "male" | "female" : T extends "document_type" ? "passport" | "id_card" | "residence_permit" | "other" : T extends "age" ? number : T extends "birthdate" | "expiry_date" ? Date : string;
|
|
303
|
+
type IDCredentialConfig = {
|
|
304
|
+
eq?: any;
|
|
305
|
+
gte?: number | Date;
|
|
306
|
+
gt?: number | Date;
|
|
307
|
+
lte?: number | Date;
|
|
308
|
+
lt?: number | Date;
|
|
309
|
+
range?: [number | Date, number | Date];
|
|
310
|
+
in?: any[];
|
|
311
|
+
out?: any[];
|
|
312
|
+
disclose?: boolean;
|
|
313
|
+
};
|
|
314
|
+
type QueryResultValue<T extends IDCredential> = {
|
|
315
|
+
eq?: {
|
|
316
|
+
expected: T extends "nationality" | "issuing_country" ? Alpha3Code : T extends "age" ? number : T extends "birthdate" | "expiry_date" ? Date : string;
|
|
317
|
+
result: boolean;
|
|
318
|
+
};
|
|
319
|
+
gte?: {
|
|
320
|
+
expected: T extends "age" ? number : Date;
|
|
321
|
+
result: boolean;
|
|
322
|
+
};
|
|
323
|
+
gt?: {
|
|
324
|
+
expected: T extends "age" ? number : Date;
|
|
325
|
+
result: boolean;
|
|
326
|
+
};
|
|
327
|
+
lte?: {
|
|
328
|
+
expected: T extends "age" ? number : Date;
|
|
329
|
+
result: boolean;
|
|
330
|
+
};
|
|
331
|
+
lt?: {
|
|
332
|
+
expected: T extends "age" ? number : Date;
|
|
333
|
+
result: boolean;
|
|
334
|
+
};
|
|
335
|
+
range?: {
|
|
336
|
+
expected: [T extends "age" ? number : Date, T extends "age" ? number : Date];
|
|
337
|
+
result: boolean;
|
|
338
|
+
};
|
|
339
|
+
in?: {
|
|
340
|
+
expected: T extends "nationality" | "issuing_country" ? Alpha3Code[] : any[];
|
|
341
|
+
result: boolean;
|
|
342
|
+
};
|
|
343
|
+
out?: {
|
|
344
|
+
expected: T extends "nationality" | "issuing_country" ? Alpha3Code[] : any[];
|
|
345
|
+
result: boolean;
|
|
346
|
+
};
|
|
347
|
+
disclose?: {
|
|
348
|
+
result: T extends "birthdate" | "expiry_date" ? Date : T extends "age" ? number : T extends "nationality" | "issuing_country" ? Alpha3Code : string;
|
|
349
|
+
};
|
|
350
|
+
};
|
|
351
|
+
type SanctionsAlpha2Code = "US" | "GB" | "CH" | "EU";
|
|
352
|
+
type SanctionsCountries = "all";
|
|
353
|
+
type SanctionsLists = "all";
|
|
354
|
+
type SanctionsConfig = {
|
|
355
|
+
countries?: SanctionsCountries;
|
|
356
|
+
lists?: SanctionsLists;
|
|
357
|
+
strict?: boolean;
|
|
358
|
+
};
|
|
359
|
+
type SanctionsResult = {
|
|
360
|
+
passed: boolean;
|
|
361
|
+
countries?: Record<SanctionsAlpha2Code, {
|
|
362
|
+
passed: boolean;
|
|
363
|
+
}>;
|
|
364
|
+
lists?: Record<string, {
|
|
365
|
+
passed: boolean;
|
|
366
|
+
}>;
|
|
367
|
+
isStrict: boolean;
|
|
368
|
+
};
|
|
369
|
+
type FacematchMode = "strict" | "regular";
|
|
370
|
+
type FacematchConfig = {
|
|
371
|
+
mode: FacematchMode;
|
|
372
|
+
};
|
|
373
|
+
type FacematchResult = {
|
|
374
|
+
mode: FacematchMode;
|
|
375
|
+
passed: boolean;
|
|
376
|
+
};
|
|
377
|
+
type Query = {
|
|
378
|
+
[key in IDCredential]?: IDCredentialConfig;
|
|
379
|
+
} & {
|
|
380
|
+
bind?: BoundData;
|
|
381
|
+
sanctions?: SanctionsConfig;
|
|
382
|
+
facematch?: FacematchConfig;
|
|
383
|
+
policy?: string;
|
|
384
|
+
};
|
|
385
|
+
type QueryResult = {
|
|
386
|
+
[key in IDCredential]?: QueryResultValue<key>;
|
|
387
|
+
} & {
|
|
388
|
+
bind?: BoundData;
|
|
389
|
+
sanctions?: SanctionsResult;
|
|
390
|
+
facematch?: FacematchResult;
|
|
391
|
+
};
|
|
392
|
+
type AgeCommittedInputs = {
|
|
393
|
+
minAge: number;
|
|
394
|
+
maxAge: number;
|
|
395
|
+
};
|
|
396
|
+
type CountryCommittedInputs = {
|
|
397
|
+
countries: Alpha3Code[];
|
|
398
|
+
};
|
|
399
|
+
type DateCommittedInputs = {
|
|
400
|
+
minDateTimestamp: number;
|
|
401
|
+
maxDateTimestamp: number;
|
|
402
|
+
};
|
|
403
|
+
type DiscloseCommittedInputs = {
|
|
404
|
+
discloseMask: number[];
|
|
405
|
+
disclosedBytes: number[];
|
|
406
|
+
};
|
|
407
|
+
type FacematchCommittedInputs = {
|
|
408
|
+
rootKeyLeaf: string;
|
|
409
|
+
environment: "development" | "production";
|
|
410
|
+
appIdHash: string;
|
|
411
|
+
integrityPubkeyHash: string;
|
|
412
|
+
mode: FacematchMode;
|
|
413
|
+
};
|
|
414
|
+
type SupportedChain = "ethereum" | "base" | "arbitrum" | "optimism" | "polygon" | "celo" | "gnosis" | "scroll" | "linea" | "world_chain" | "ethereum_sepolia" | "base_sepolia" | "arbitrum_sepolia" | "polygon_amoy" | "celo_sepolia" | "gnosis_chiado" | "scroll_sepolia" | "linea_sepolia" | "world_chain_sepolia" | "local";
|
|
415
|
+
type BoundData = {
|
|
416
|
+
user_address?: string;
|
|
417
|
+
chain?: SupportedChain;
|
|
418
|
+
custom_data?: string;
|
|
419
|
+
};
|
|
420
|
+
type BindCommittedInputs = {
|
|
421
|
+
data: BoundData;
|
|
422
|
+
};
|
|
423
|
+
type SanctionsCommittedInputs = {
|
|
424
|
+
rootHash: string;
|
|
425
|
+
isStrict: boolean;
|
|
426
|
+
};
|
|
427
|
+
type CommittedInputs = AgeCommittedInputs | CountryCommittedInputs | DateCommittedInputs | DiscloseCommittedInputs | BindCommittedInputs | SanctionsCommittedInputs | FacematchCommittedInputs;
|
|
428
|
+
type DisclosureCircuitName = "disclose_bytes" | "disclose_bytes_evm" | "compare_age" | "compare_age_evm" | "compare_birthdate" | "compare_birthdate_evm" | "compare_expiry" | "compare_expiry_evm" | "exclusion_check_issuing_country" | "exclusion_check_issuing_country_evm" | "exclusion_check_nationality" | "exclusion_check_nationality_evm" | "exclusion_check_sanctions" | "exclusion_check_sanctions_evm" | "inclusion_check_issuing_country" | "inclusion_check_issuing_country_evm" | "inclusion_check_nationality" | "inclusion_check_nationality_evm" | "bind" | "bind_evm" | "facematch" | "facematch_evm";
|
|
429
|
+
type ProofResult = {
|
|
430
|
+
proof?: string;
|
|
431
|
+
vkeyHash?: string;
|
|
432
|
+
version?: `${number}.${number}.${number}`;
|
|
433
|
+
name?: string;
|
|
434
|
+
committedInputs?: {
|
|
435
|
+
[circuitName in DisclosureCircuitName]?: CommittedInputs;
|
|
436
|
+
};
|
|
437
|
+
index?: number;
|
|
438
|
+
total?: number;
|
|
439
|
+
};
|
|
440
|
+
type Service = {
|
|
441
|
+
name: string;
|
|
442
|
+
logo: string;
|
|
443
|
+
purpose: string;
|
|
444
|
+
scope?: string;
|
|
445
|
+
projectID?: string;
|
|
446
|
+
chainId?: number;
|
|
447
|
+
cloudProverUrl?: string;
|
|
448
|
+
bridgeUrl?: string;
|
|
449
|
+
};
|
|
450
|
+
type ProofMode = "fast" | "compressed" | "compressed-evm";
|
|
451
|
+
declare enum NullifierType {
|
|
452
|
+
NON_SALTED = 0,
|
|
453
|
+
SALTED = 1,
|
|
454
|
+
NON_SALTED_MOCK = 2,
|
|
455
|
+
SALTED_MOCK = 3,
|
|
456
|
+
NONE = 4
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
type QueryResultError<T> = {
|
|
460
|
+
expected?: T;
|
|
461
|
+
received?: T;
|
|
462
|
+
message: string;
|
|
463
|
+
};
|
|
464
|
+
type QueryResultErrors = {
|
|
465
|
+
[key in IDCredential | "sig_check_dsc" | "sig_check_id_data" | "data_check_integrity" | "outer" | "disclose" | "bind" | "facematch" | "sanctions"]: {
|
|
466
|
+
disclose?: QueryResultError<string | number | Date>;
|
|
467
|
+
gte?: QueryResultError<number | Date>;
|
|
468
|
+
gt?: QueryResultError<number | Date>;
|
|
469
|
+
lte?: QueryResultError<number | Date>;
|
|
470
|
+
lt?: QueryResultError<number | Date>;
|
|
471
|
+
range?: QueryResultError<[number | Date, number | Date]>;
|
|
472
|
+
in?: QueryResultError<string[]>;
|
|
473
|
+
out?: QueryResultError<string[]>;
|
|
474
|
+
eq?: QueryResultError<string | number | Date>;
|
|
475
|
+
commitment?: QueryResultError<string>;
|
|
476
|
+
date?: QueryResultError<string>;
|
|
477
|
+
certificate?: QueryResultError<string>;
|
|
478
|
+
scope?: QueryResultError<string>;
|
|
479
|
+
};
|
|
480
|
+
};
|
|
481
|
+
type VerifierMode = "auto" | "local" | "api";
|
|
482
|
+
type VerificationResult = {
|
|
483
|
+
uniqueIdentifier: string | undefined;
|
|
484
|
+
uniqueIdentifierType: NullifierType | undefined;
|
|
485
|
+
verified: boolean;
|
|
486
|
+
queryResultErrors?: Partial<QueryResultErrors>;
|
|
487
|
+
};
|
|
488
|
+
type SolidityProofVerificationData = {
|
|
489
|
+
vkeyHash: string;
|
|
490
|
+
proof: string;
|
|
491
|
+
publicInputs: string[];
|
|
492
|
+
};
|
|
493
|
+
type SolidityServiceConfig = {
|
|
494
|
+
validityPeriodInSeconds: number;
|
|
495
|
+
domain: string;
|
|
496
|
+
scope: string;
|
|
497
|
+
devMode: boolean;
|
|
498
|
+
};
|
|
499
|
+
type SolidityVerifierParameters = {
|
|
500
|
+
version: string;
|
|
501
|
+
proofVerificationData: SolidityProofVerificationData;
|
|
502
|
+
committedInputs: string;
|
|
503
|
+
serviceConfig: SolidityServiceConfig;
|
|
504
|
+
};
|
|
505
|
+
type RequestSuccess = {
|
|
506
|
+
proofs: ProofResult[];
|
|
507
|
+
result: QueryResult;
|
|
508
|
+
};
|
|
509
|
+
type OnSuccessVerdict = void | boolean | Promise<void | boolean>;
|
|
510
|
+
type QueryBuilderResult = {
|
|
511
|
+
/**
|
|
512
|
+
* The URL of the request.
|
|
513
|
+
*
|
|
514
|
+
* You can either encode the URL in a QR code or let the user click the link
|
|
515
|
+
* to this URL on your website if they're visiting your website on their phone.
|
|
516
|
+
*/
|
|
517
|
+
url: string;
|
|
518
|
+
/**
|
|
519
|
+
* The query object.
|
|
520
|
+
*/
|
|
521
|
+
query: Query;
|
|
522
|
+
/**
|
|
523
|
+
* The id of the request.
|
|
524
|
+
*/
|
|
525
|
+
requestId: string;
|
|
526
|
+
/**
|
|
527
|
+
* The id of the policy used to build the request, if one was provided.
|
|
528
|
+
*/
|
|
529
|
+
policy?: string;
|
|
530
|
+
/**
|
|
531
|
+
* Called when the user has scanned the QR code or clicked the link to the request.
|
|
532
|
+
*
|
|
533
|
+
* This means the user is currently viewing the request popup with your website information
|
|
534
|
+
* and the information requested from them.
|
|
535
|
+
*/
|
|
536
|
+
onRequestReceived: (callback: () => void) => void;
|
|
537
|
+
/**
|
|
538
|
+
* Called when the user has accepted the request and
|
|
539
|
+
* started to generate the proof on their phone.
|
|
540
|
+
*/
|
|
541
|
+
onGeneratingProof: (callback: () => void) => void;
|
|
542
|
+
/**
|
|
543
|
+
* Called when the SDK successfully connects to the bridge with the mobile app.
|
|
544
|
+
*/
|
|
545
|
+
onBridgeConnect: (callback: () => void) => void;
|
|
546
|
+
/**
|
|
547
|
+
* Called when the user has generated a proof.
|
|
548
|
+
*
|
|
549
|
+
* There is a minimum of 4 proofs, but there can be more depending
|
|
550
|
+
* on the type of information requested from the user.
|
|
551
|
+
*/
|
|
552
|
+
onProofGenerated: (callback: (proof: ProofResult) => void) => void;
|
|
553
|
+
/**
|
|
554
|
+
* Called when the user has completed the request and all proofs were received.
|
|
555
|
+
*
|
|
556
|
+
* The proofs are not verified at this point: send them along with the result
|
|
557
|
+
* to your backend and verify them there with `verify()`. The UI components wait
|
|
558
|
+
* for this callback before showing their success state; return `false` (or throw)
|
|
559
|
+
* to show the error state instead, e.g. when your backend rejects the proofs.
|
|
560
|
+
*/
|
|
561
|
+
onSuccess: (callback: (response: RequestSuccess) => OnSuccessVerdict) => void;
|
|
562
|
+
/**
|
|
563
|
+
* Called when the user has sent the query result.
|
|
564
|
+
*
|
|
565
|
+
* The response contains the unique identifier associated to the user,
|
|
566
|
+
* your domain name and chosen scope, along with the query result and whether
|
|
567
|
+
* the proofs were successfully verified.
|
|
568
|
+
*
|
|
569
|
+
* @deprecated The verified flag can be tampered with in the browser. Use `onSuccess`
|
|
570
|
+
* and verify the proofs on your backend with `verify()`.
|
|
571
|
+
*/
|
|
572
|
+
onResult: (callback: (response: {
|
|
573
|
+
uniqueIdentifier: string | undefined;
|
|
574
|
+
uniqueIdentifierType: NullifierType | undefined;
|
|
575
|
+
verified: boolean;
|
|
576
|
+
result: QueryResult;
|
|
577
|
+
queryResultErrors?: Partial<QueryResultErrors>;
|
|
578
|
+
proofs: ProofResult[];
|
|
579
|
+
sdkInstance: ZKPassport;
|
|
580
|
+
}) => void) => void;
|
|
581
|
+
/**
|
|
582
|
+
* Called when the user has rejected the request.
|
|
583
|
+
*/
|
|
584
|
+
onReject: (callback: () => void) => void;
|
|
585
|
+
/**
|
|
586
|
+
* Called when an error occurs, such as one of the requirements not being met
|
|
587
|
+
* or a proof failing to be generated.
|
|
588
|
+
*/
|
|
589
|
+
onError: (callback: (error: string) => void) => void;
|
|
590
|
+
/**
|
|
591
|
+
* @returns true if the bridge with the mobile app is connected
|
|
592
|
+
*/
|
|
593
|
+
isBridgeConnected: () => boolean;
|
|
594
|
+
/**
|
|
595
|
+
* Get if the user has scanned the QR code or the link to this request
|
|
596
|
+
* @returns true if the request has been received by the user on their phone
|
|
597
|
+
*/
|
|
598
|
+
requestReceived: () => boolean;
|
|
599
|
+
};
|
|
600
|
+
type OfflineQueryBuilderResult = {
|
|
601
|
+
query: Query;
|
|
602
|
+
};
|
|
603
|
+
type QueryBuilder<T extends "online" | "offline" = "online"> = {
|
|
604
|
+
/**
|
|
605
|
+
* Requires this attribute to be equal to the provided value.
|
|
606
|
+
* @param key The attribute to compare.
|
|
607
|
+
* @param value The value of the attribute you require.
|
|
608
|
+
*/
|
|
609
|
+
eq: <T extends IDCredential>(key: T, value: IDCredentialValue<T>) => QueryBuilder;
|
|
610
|
+
/**
|
|
611
|
+
* Requires this attribute to be greater than or equal to the provided value.
|
|
612
|
+
* @param key The attribute to compare.
|
|
613
|
+
* @param value The value of the attribute you require.
|
|
614
|
+
*/
|
|
615
|
+
gte: <T extends NumericalIDCredential>(key: T, value: IDCredentialValue<T>) => QueryBuilder;
|
|
616
|
+
/**
|
|
617
|
+
* Requires this attribute to be greater than the provided value.
|
|
618
|
+
* @param key The attribute to compare.
|
|
619
|
+
* @param value The value of the attribute you require.
|
|
620
|
+
*/
|
|
621
|
+
gt: <T extends NumericalIDCredential>(key: T, value: IDCredentialValue<T>) => QueryBuilder;
|
|
622
|
+
/**
|
|
623
|
+
* Requires this attribute to be less than or equal to the provided value.
|
|
624
|
+
* @param key The attribute to compare.
|
|
625
|
+
* @param value The value of the attribute you require.
|
|
626
|
+
*/
|
|
627
|
+
lte: <T extends NumericalIDCredential>(key: T, value: IDCredentialValue<T>) => QueryBuilder;
|
|
628
|
+
/**
|
|
629
|
+
* Requires this attribute to be less than the provided value.
|
|
630
|
+
* @param key The attribute to compare.
|
|
631
|
+
* @param value The value of the attribute you require.
|
|
632
|
+
*/
|
|
633
|
+
lt: <T extends NumericalIDCredential>(key: T, value: IDCredentialValue<T>) => QueryBuilder;
|
|
634
|
+
/**
|
|
635
|
+
* Requires this attribute to be included in the provided range.
|
|
636
|
+
* @param key The attribute to compare.
|
|
637
|
+
* @param start The start of the range.
|
|
638
|
+
* @param end The end of the range.
|
|
639
|
+
*/
|
|
640
|
+
range: <T extends NumericalIDCredential>(key: T, start: IDCredentialValue<T>, end: IDCredentialValue<T>) => QueryBuilder;
|
|
641
|
+
/**
|
|
642
|
+
* Requires this attribute to be included in the provided list.
|
|
643
|
+
* @param key The attribute to compare.
|
|
644
|
+
* @param value The list of values to check inclusion against.
|
|
645
|
+
*/
|
|
646
|
+
in: <T extends "nationality" | "issuing_country">(key: T, value: IDCredentialValue<T>[]) => QueryBuilder;
|
|
647
|
+
/**
|
|
648
|
+
* Requires this attribute to be excluded from the provided list.
|
|
649
|
+
* @param key The attribute to compare.
|
|
650
|
+
* @param value The list of values to check exclusion against.
|
|
651
|
+
*/
|
|
652
|
+
out: <T extends "nationality" | "issuing_country">(key: T, value: IDCredentialValue<T>[]) => QueryBuilder;
|
|
653
|
+
/**
|
|
654
|
+
* Requires this attribute to be disclosed.
|
|
655
|
+
* @param key The attribute to disclose.
|
|
656
|
+
*/
|
|
657
|
+
disclose: (key: DisclosableIDCredential) => QueryBuilder;
|
|
658
|
+
/**
|
|
659
|
+
* Binds a value to the request.
|
|
660
|
+
* @param key The key of the value to bind.
|
|
661
|
+
* @param value The value to bind the request to.
|
|
662
|
+
*/
|
|
663
|
+
bind: <T extends keyof BoundData>(key: T, value: T extends "chain" ? SupportedChain : T extends "user_address" ? `0x${string}` : string | undefined) => QueryBuilder;
|
|
664
|
+
/**
|
|
665
|
+
* Requires that the ID holder is not part of any of the specified sanction lists.
|
|
666
|
+
* @param countries The country or list of countries whose sanction lists to check against. Defaults to "all".
|
|
667
|
+
* e.g. "US", ["US", "GB", "CH", "EU"], "all"
|
|
668
|
+
* @param lists The specific lists from a given country to check against. Defaults to "all".
|
|
669
|
+
* e.g. ["OFAC_SDN"], "all"
|
|
670
|
+
* @param options The options to use for the sanction check.
|
|
671
|
+
* @param options.strict Whether to use a strict sanction check. Defaults to false.
|
|
672
|
+
*
|
|
673
|
+
* If set to true, this means the checks will be done against just the lastname and firstname,
|
|
674
|
+
* while when set to false, matches will need to include either the date of birth and name or
|
|
675
|
+
* the passport number and nationality.
|
|
676
|
+
* Strict mode has therefore a higher false positive rate but is harder to evade.
|
|
677
|
+
*/
|
|
678
|
+
sanctions: (countries?: SanctionsCountries, lists?: SanctionsLists, options?: {
|
|
679
|
+
strict?: boolean;
|
|
680
|
+
}) => QueryBuilder;
|
|
681
|
+
/**
|
|
682
|
+
* Requires that the ID holder's face matches the photo on the ID.
|
|
683
|
+
* @param mode The mode to use for the face match. Defaults to "strict".
|
|
684
|
+
* @param mode "strict" - The user will have to go through an extensive liveness check to prevent spoofing making it more secure.
|
|
685
|
+
* Best for high security requirements such as KYC.
|
|
686
|
+
* @param mode "regular" - The user will only have to go through a basic liveness check to prevent spoofing, making it faster for the user.
|
|
687
|
+
* Best for lower security requirements that requires fast verification such as age verification.
|
|
688
|
+
*/
|
|
689
|
+
facematch: (mode?: FacematchMode) => QueryBuilder;
|
|
690
|
+
raw: (query: Query) => QueryBuilder<T>;
|
|
691
|
+
/**
|
|
692
|
+
* Applies an immutable policy fetched from the dashboard. The policy's query,
|
|
693
|
+
* purpose and scope are locked; combining with builder methods (except
|
|
694
|
+
* `.bind()`, which may follow it) or calling twice throws.
|
|
695
|
+
* @param id The policy id (e.g. `'pol_xyz'`).
|
|
696
|
+
*/
|
|
697
|
+
policy: (id: string) => QueryBuilder<T>;
|
|
698
|
+
/**
|
|
699
|
+
* Builds the request.
|
|
700
|
+
*
|
|
701
|
+
* This will return the URL of the request, which you can either encode in a QR code
|
|
702
|
+
* or provide as a link to the user if they're visiting your website on their phone.
|
|
703
|
+
* It also returns all the callbacks you can use to handle the user's response.
|
|
704
|
+
*/
|
|
705
|
+
done: () => T extends "online" ? QueryBuilderResult : OfflineQueryBuilderResult;
|
|
706
|
+
};
|
|
707
|
+
declare function createOfflineQuery(): QueryBuilder<"offline">;
|
|
708
|
+
|
|
709
|
+
declare class ZKPassport {
|
|
710
|
+
private domain;
|
|
711
|
+
private domainProvided;
|
|
712
|
+
private topicToConfig;
|
|
713
|
+
private topicToLocalConfig;
|
|
714
|
+
private topicToPublicKey;
|
|
715
|
+
private topicToBridge;
|
|
716
|
+
private topicToRequestReceived;
|
|
717
|
+
private topicToService;
|
|
718
|
+
private topicToCallerPurpose;
|
|
719
|
+
private topicToProofs;
|
|
720
|
+
private topicToFailedProofCount;
|
|
721
|
+
private topicToResults;
|
|
722
|
+
private topicToPolicy;
|
|
723
|
+
private dashboardConfig;
|
|
724
|
+
private dashboardConfigPromise;
|
|
725
|
+
private dashboardConfigError;
|
|
726
|
+
private onRequestReceivedCallbacks;
|
|
727
|
+
private onGeneratingProofCallbacks;
|
|
728
|
+
private onBridgeConnectCallbacks;
|
|
729
|
+
private onProofGeneratedCallbacks;
|
|
730
|
+
private onSuccessCallbacks;
|
|
731
|
+
private onResultCallbacks;
|
|
732
|
+
private onRejectCallbacks;
|
|
733
|
+
private onErrorCallbacks;
|
|
734
|
+
private normalizeDomain;
|
|
735
|
+
constructor(_domain?: string);
|
|
736
|
+
private handleResult;
|
|
737
|
+
private verifyAndReportResult;
|
|
738
|
+
/**
|
|
739
|
+
* @notice Handle an encrypted message.
|
|
740
|
+
* @param request The request.
|
|
741
|
+
* @param outerRequest The outer request.
|
|
742
|
+
*/
|
|
743
|
+
private handleEncryptedMessage;
|
|
744
|
+
private assertNotPolicyLocked;
|
|
745
|
+
private getZkPassportRequest;
|
|
746
|
+
private getDashboardConfig;
|
|
747
|
+
private fetchDashboardConfig;
|
|
748
|
+
private findPolicy;
|
|
749
|
+
private assertCanApplyPolicy;
|
|
750
|
+
/**
|
|
751
|
+
* @notice Create a new request. To apply a policy, chain `.policy('<id>')` on
|
|
752
|
+
* the returned builder; a policy locks the query and scope.
|
|
753
|
+
* @param name Your service name. Defaults to the dashboard branding, then the domain.
|
|
754
|
+
* @param logo Your service logo. Defaults to the dashboard branding.
|
|
755
|
+
* @param purpose Explanation shown to the user. Defaults to the policy's purpose (if any), then a generic message.
|
|
756
|
+
* @param scope Use-case scope (drives the nullifier). Defaults to the domain. Locked by `.policy()` (to the policy id).
|
|
757
|
+
* @param projectID The project ID of your service
|
|
758
|
+
* @param validity How many seconds ago the proof checking the expiry date of the ID should have been generated
|
|
759
|
+
* @param mode The proof mode (e.g. "fast" / "compressed").
|
|
760
|
+
* @param devMode Whether to enable dev mode. This will allow you to verify mock proofs (i.e. from ZKR)
|
|
761
|
+
* @param verifierMode How the received proofs are verified: "local", "api" or "auto" (default).
|
|
762
|
+
* @returns The query builder object.
|
|
763
|
+
*/
|
|
764
|
+
request({ name, logo, purpose, scope, projectID, mode, validity, devMode, uniqueIdentifierType, oprfKeyId, topicOverride, keyPairOverride, cloudProverUrl, bridgeUrl, returnDeepLink, verifierMode, }: {
|
|
765
|
+
name?: string;
|
|
766
|
+
logo?: string;
|
|
767
|
+
purpose?: string;
|
|
768
|
+
scope?: string;
|
|
769
|
+
mode?: ProofMode;
|
|
770
|
+
projectID?: string;
|
|
771
|
+
validity?: number;
|
|
772
|
+
devMode?: boolean;
|
|
773
|
+
uniqueIdentifierType?: NullifierType.NON_SALTED | NullifierType.SALTED | NullifierType.NONE;
|
|
774
|
+
oprfKeyId?: string;
|
|
775
|
+
topicOverride?: string;
|
|
776
|
+
keyPairOverride?: {
|
|
777
|
+
privateKey: Uint8Array;
|
|
778
|
+
publicKey: Uint8Array;
|
|
779
|
+
};
|
|
780
|
+
cloudProverUrl?: string;
|
|
781
|
+
bridgeUrl?: string;
|
|
782
|
+
returnDeepLink?: string;
|
|
783
|
+
verifierMode?: VerifierMode;
|
|
784
|
+
}): Promise<QueryBuilder>;
|
|
785
|
+
/**
|
|
786
|
+
* @notice Create a new offline query
|
|
787
|
+
* Unlike request(), this function does not connect to the bridge.
|
|
788
|
+
* It returns only the query object and no callbacks and no URL.
|
|
789
|
+
* This can be useful to recreate the same query server-side when calling `verify()`
|
|
790
|
+
* to ensure the original query wasn't tampered with.
|
|
791
|
+
* @returns The query builder object.
|
|
792
|
+
*/
|
|
793
|
+
createQuery(): QueryBuilder<"offline">;
|
|
794
|
+
/**
|
|
795
|
+
* @notice Verify the proofs received from the mobile app.
|
|
796
|
+
* @param proofs The proofs to verify.
|
|
797
|
+
* @param originalQuery The original query that was sent to the mobile app.
|
|
798
|
+
* @param queryResult The query result to verify against
|
|
799
|
+
* @param validity How many seconds ago the proof checking the expiry date of the ID should have been generated
|
|
800
|
+
* @param scope The scope used in the original request, if any. Proofs generated for a different scope fail verification.
|
|
801
|
+
* @param devMode Whether to enable dev mode. This will allow you to verify mock proofs (i.e. from ZKR)
|
|
802
|
+
* @param writingDirectory The directory (e.g. `./tmp`) where the necessary temporary artifacts for verification are written to.
|
|
803
|
+
* It should only be needed when running the `verify` function on a server with restricted write access (e.g. Vercel)
|
|
804
|
+
* @param oprfKeyId The OPRF key id used in the original request, if any.
|
|
805
|
+
* @param verifierMode "local" verifies with the verifier bundled in this SDK, "api" with the
|
|
806
|
+
* ZKPassport verifier API, and "auto" (default) verifies locally but defers to the API when
|
|
807
|
+
* the local result is not verified — e.g. proofs from a newer bb version than this SDK supports.
|
|
808
|
+
* @returns An object containing the unique identifier associated to the user
|
|
809
|
+
* and a boolean indicating whether the proofs were successfully verified.
|
|
810
|
+
*/
|
|
811
|
+
verify({ proofs, originalQuery, queryResult, validity, scope, devMode, writingDirectory, oprfKeyId, verifierMode, }: {
|
|
812
|
+
proofs: Array<ProofResult>;
|
|
813
|
+
originalQuery: Query;
|
|
814
|
+
queryResult: QueryResult;
|
|
815
|
+
validity?: number;
|
|
816
|
+
scope?: string;
|
|
817
|
+
devMode?: boolean;
|
|
818
|
+
writingDirectory?: string;
|
|
819
|
+
oprfKeyId?: string;
|
|
820
|
+
verifierMode?: VerifierMode;
|
|
821
|
+
}): Promise<VerificationResult>;
|
|
822
|
+
private verifyLocally;
|
|
823
|
+
getSolidityVerifierDetails(): {
|
|
824
|
+
address: `0x${string}`;
|
|
825
|
+
functionName: string;
|
|
826
|
+
abi: {
|
|
827
|
+
type: "function" | "event" | "constructor";
|
|
828
|
+
name: string;
|
|
829
|
+
inputs: {
|
|
830
|
+
name: string;
|
|
831
|
+
type: string;
|
|
832
|
+
internalType: string;
|
|
833
|
+
}[];
|
|
834
|
+
outputs: {
|
|
835
|
+
name: string;
|
|
836
|
+
type: string;
|
|
837
|
+
internalType: string;
|
|
838
|
+
}[];
|
|
839
|
+
}[];
|
|
840
|
+
};
|
|
841
|
+
getSolidityVerifierParameters({ proof, validityPeriodInSeconds, domain, scope, devMode, }: {
|
|
842
|
+
proof: ProofResult;
|
|
843
|
+
validityPeriodInSeconds?: number;
|
|
844
|
+
domain?: string;
|
|
845
|
+
scope?: string;
|
|
846
|
+
devMode?: boolean;
|
|
847
|
+
}): SolidityVerifierParameters;
|
|
848
|
+
private _getUrl;
|
|
849
|
+
/**
|
|
850
|
+
* @notice Returns the URL of the request.
|
|
851
|
+
* @param requestId The request ID.
|
|
852
|
+
* @returns The URL of the request.
|
|
853
|
+
*/
|
|
854
|
+
getUrl(requestId: string): string;
|
|
855
|
+
/**
|
|
856
|
+
* @notice Returns the resolved service details (name, logo, purpose) shown to the
|
|
857
|
+
* user for a pending request, including branding resolved from the dashboard config.
|
|
858
|
+
* @param requestId The request ID.
|
|
859
|
+
*/
|
|
860
|
+
getServiceDetails(requestId: string): Service | undefined;
|
|
861
|
+
/**
|
|
862
|
+
* @notice Cancels a request by closing the WebSocket connection and deleting the associated data.
|
|
863
|
+
* @param requestId The request ID.
|
|
864
|
+
*/
|
|
865
|
+
cancelRequest(requestId: string): void;
|
|
866
|
+
/**
|
|
867
|
+
* @notice Clears all requests.
|
|
868
|
+
*/
|
|
869
|
+
clearAllRequests(): void;
|
|
870
|
+
}
|
|
871
|
+
|
|
872
|
+
type PopupRequestConfig = {
|
|
873
|
+
name?: string;
|
|
874
|
+
logo?: string;
|
|
875
|
+
purpose?: string;
|
|
876
|
+
scope?: string;
|
|
877
|
+
mode?: ProofMode;
|
|
878
|
+
devMode?: boolean;
|
|
879
|
+
validity?: number;
|
|
880
|
+
uniqueIdentifierType?: NullifierType.NON_SALTED | NullifierType.SALTED;
|
|
881
|
+
oprfKeyId?: string;
|
|
882
|
+
};
|
|
883
|
+
type PopupEventMessage = {
|
|
884
|
+
zkpassport: true;
|
|
885
|
+
type: "request-received";
|
|
886
|
+
} | {
|
|
887
|
+
zkpassport: true;
|
|
888
|
+
type: "generating";
|
|
889
|
+
} | {
|
|
890
|
+
zkpassport: true;
|
|
891
|
+
type: "proof-generated";
|
|
892
|
+
index?: number;
|
|
893
|
+
total?: number;
|
|
894
|
+
name?: string;
|
|
895
|
+
} | {
|
|
896
|
+
zkpassport: true;
|
|
897
|
+
type: "success";
|
|
898
|
+
proofs: ProofResult[];
|
|
899
|
+
result: QueryResult;
|
|
900
|
+
} | {
|
|
901
|
+
zkpassport: true;
|
|
902
|
+
type: "rejected";
|
|
903
|
+
} | {
|
|
904
|
+
zkpassport: true;
|
|
905
|
+
type: "error";
|
|
906
|
+
message: string;
|
|
907
|
+
};
|
|
908
|
+
|
|
909
|
+
type PopupSuccess = Extract<PopupEventMessage, {
|
|
910
|
+
type: "success";
|
|
911
|
+
}>;
|
|
912
|
+
type PopupCallbacks = {
|
|
913
|
+
onRequestReceived?: () => void;
|
|
914
|
+
onGeneratingProof?: () => void;
|
|
915
|
+
onProofGenerated?: (progress: {
|
|
916
|
+
index?: number;
|
|
917
|
+
total?: number;
|
|
918
|
+
name?: string;
|
|
919
|
+
}) => void;
|
|
920
|
+
onSuccess?: (response: Omit<PopupSuccess, "zkpassport" | "type">) => OnSuccessVerdict;
|
|
921
|
+
onReject?: () => void;
|
|
922
|
+
onError?: (message: string) => void;
|
|
923
|
+
onClose?: () => void;
|
|
924
|
+
};
|
|
925
|
+
type OpenVerificationPopupOptions = {
|
|
926
|
+
popupUrl?: string;
|
|
927
|
+
request: PopupRequestConfig;
|
|
928
|
+
query: Query;
|
|
929
|
+
callbacks?: PopupCallbacks;
|
|
930
|
+
};
|
|
931
|
+
type VerificationPopupHandle = {
|
|
932
|
+
close: () => void;
|
|
933
|
+
popup: Window;
|
|
934
|
+
};
|
|
935
|
+
/**
|
|
936
|
+
* Open the hosted verification popup. MUST be called from a user gesture
|
|
937
|
+
* (e.g. a click handler) or the browser will block the popup.
|
|
938
|
+
*
|
|
939
|
+
* If popup is blocked, will attempt to open in a new window.
|
|
940
|
+
*/
|
|
941
|
+
declare function openVerificationPopup(options: OpenVerificationPopupOptions): VerificationPopupHandle | null;
|
|
942
|
+
|
|
943
|
+
type VerificationStatus = "idle" | "in-progress" | "success" | "error";
|
|
944
|
+
type VerificationState = {
|
|
945
|
+
status: VerificationStatus;
|
|
946
|
+
error: string | null;
|
|
947
|
+
};
|
|
948
|
+
type VerificationOptions = PopupRequestConfig & PopupCallbacks & {
|
|
949
|
+
popupUrl?: string;
|
|
950
|
+
policyId?: string;
|
|
951
|
+
query: (queryBuilder: QueryBuilder) => QueryBuilderResult;
|
|
952
|
+
};
|
|
953
|
+
type VerificationController = {
|
|
954
|
+
readonly state: VerificationState;
|
|
955
|
+
verify: () => void;
|
|
956
|
+
close: () => void;
|
|
957
|
+
};
|
|
958
|
+
declare function createVerification(getOptions: () => VerificationOptions, onStateChange: (state: VerificationState) => void): VerificationController;
|
|
959
|
+
|
|
960
|
+
declare const BUTTON_FONT_SIZES: {
|
|
961
|
+
readonly small: "13px";
|
|
962
|
+
readonly medium: "15px";
|
|
963
|
+
readonly large: "18px";
|
|
964
|
+
};
|
|
965
|
+
type VerifyButtonSize = keyof typeof BUTTON_FONT_SIZES;
|
|
966
|
+
type VerifyWithZKPassportButtonOptions = VerificationOptions & {
|
|
967
|
+
theme?: "light" | "dark" | "auto";
|
|
968
|
+
size?: VerifyButtonSize;
|
|
969
|
+
label?: string;
|
|
970
|
+
showErrorMessage?: boolean;
|
|
971
|
+
classes?: {
|
|
972
|
+
root?: string;
|
|
973
|
+
button?: string;
|
|
974
|
+
error?: string;
|
|
975
|
+
};
|
|
976
|
+
};
|
|
977
|
+
|
|
978
|
+
export { type BoundData as B, type CountryName as C, type DisclosableIDCredential as D, type FacematchMode as F, type IDCredential as I, NullifierType as N, type ProofMode as P, type Query as Q, type SanctionsCountries as S, type VerificationOptions as V, ZKPassport as Z, type IDCredentialValue as a, type NumericalIDCredential as b, type ProofResult as c, type QueryBuilder as d, type QueryBuilderResult as e, type QueryResult as f, type QueryResultError as g, type QueryResultErrors as h, type SanctionsLists as i, type Service as j, type SupportedChain as k, type VerificationState as l, type VerificationStatus as m, type VerifyButtonSize as n, type VerifyWithZKPassportButtonOptions as o, type VerificationController as p, createVerification as q, type PopupRequestConfig as r, type PopupSuccess as s, type VerificationPopupHandle as t, createOfflineQuery as u, openVerificationPopup as v };
|