@zkpassport/sdk 0.7.1 → 0.8.0-beta.2

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.
@@ -813,8 +813,9 @@ 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.7.0";
817
- var DEFAULT_DATE_VALUE = new Date(1111, 10, 11);
816
+ var VERSION = "0.8.0";
817
+ var DEFAULT_DATE_VALUE = /* @__PURE__ */ new Date(0);
818
+ var DEFAULT_VALIDITY = 7 * 24 * 60 * 60;
818
819
  if (typeof globalThis.Buffer === "undefined") {
819
820
  globalThis.Buffer = import_buffer.Buffer;
820
821
  if (typeof window !== "undefined") {
@@ -863,7 +864,6 @@ function generalCompare(fnName, key, value, requestId, requestIdToConfig) {
863
864
  };
864
865
  }
865
866
  var ZKPassport = class {
866
- //private wasmVerifierInit: boolean = false
867
867
  constructor(_domain) {
868
868
  this.topicToConfig = {};
869
869
  this.topicToLocalConfig = {};
@@ -885,7 +885,11 @@ var ZKPassport = class {
885
885
  if (!_domain && typeof window === "undefined") {
886
886
  throw new Error("Domain argument is required in Node.js environment");
887
887
  }
888
- this.domain = _domain || window.location.hostname;
888
+ this.domain = this.normalizeDomain(_domain || window.location.hostname);
889
+ }
890
+ //private wasmVerifierInit: boolean = false
891
+ normalizeDomain(domain) {
892
+ return domain.trim().replace(/^https?:\/\//, "").replace(/^.*\.([a-zA-Z0-9\-]+\.[a-zA-Z0-9\-]+)/, "$1").replace(/\/[^/]*$/, "").replace(/:[0-9]+/, "").replace(/\?.*$/, "").replace(/#.*$/, "").toLowerCase();
889
893
  }
890
894
  async handleResult(topic) {
891
895
  const result = this.topicToResults[topic];
@@ -967,6 +971,12 @@ var ZKPassport = class {
967
971
  if (this.topicToConfig[topic].bind) {
968
972
  neededCircuits.push("bind");
969
973
  }
974
+ if (this.topicToConfig[topic].sanctions) {
975
+ neededCircuits.push("exclusion_check_sanctions");
976
+ }
977
+ if (this.topicToConfig[topic].facematch) {
978
+ neededCircuits.push("facematch");
979
+ }
970
980
  this.topicToExpectedProofCount[topic] = neededCircuits.length === 0 ? 4 : 3 + neededCircuits.length;
971
981
  this.topicToFailedProofCount[topic] = 0;
972
982
  }
@@ -1072,6 +1082,27 @@ var ZKPassport = class {
1072
1082
  };
1073
1083
  return this.getZkPassportRequest(topic);
1074
1084
  },
1085
+ sanctions: (countries = "all", lists = "all") => {
1086
+ this.topicToConfig[topic].sanctions = {
1087
+ ...this.topicToConfig[topic].sanctions,
1088
+ countries: countries === "all" ? "all" : Array.isArray(countries) ? [
1089
+ ...this.topicToConfig[topic].sanctions?.countries ?? [],
1090
+ ...countries
1091
+ ] : [
1092
+ ...this.topicToConfig[topic].sanctions?.countries ?? [],
1093
+ countries
1094
+ ],
1095
+ lists: lists === "all" ? "all" : Array.isArray(lists) ? [...this.topicToConfig[topic].sanctions?.lists ?? [], ...lists] : [...this.topicToConfig[topic].sanctions?.lists ?? [], lists]
1096
+ };
1097
+ return this.getZkPassportRequest(topic);
1098
+ },
1099
+ // TODO: Uncomment this when the facematch is ready
1100
+ /*facematch: (mode: FacematchMode = "regular") => {
1101
+ this.topicToConfig[topic].facematch = {
1102
+ mode,
1103
+ }
1104
+ return this.getZkPassportRequest(topic)
1105
+ },*/
1075
1106
  done: () => {
1076
1107
  this.setExpectedProofCount(topic);
1077
1108
  return {
@@ -1096,7 +1127,7 @@ var ZKPassport = class {
1096
1127
  * @param logo The logo of your service
1097
1128
  * @param purpose To explain what you want to do with the user's data
1098
1129
  * @param scope Scope this request to a specific use case
1099
- * @param validity How many days ago should have the ID been last scanned by the user?
1130
+ * @param validity How many seconds ago the proof checking the expiry date of the ID should have been generated
1100
1131
  * @param devMode Whether to enable dev mode. This will allow you to verify mock proofs (i.e. from ZKR)
1101
1132
  * @returns The query builder object.
1102
1133
  */
@@ -1131,8 +1162,8 @@ var ZKPassport = class {
1131
1162
  this.topicToProofs[topic] = [];
1132
1163
  this.topicToExpectedProofCount[topic] = 0;
1133
1164
  this.topicToLocalConfig[topic] = {
1134
- // Default to 6 months
1135
- validity: validity || 6 * 30,
1165
+ // Default to 7 days
1166
+ validity: validity || DEFAULT_VALIDITY,
1136
1167
  mode: mode || "fast",
1137
1168
  devMode: devMode || false
1138
1169
  };
@@ -1161,25 +1192,7 @@ var ZKPassport = class {
1161
1192
  return this.getZkPassportRequest(topic);
1162
1193
  }
1163
1194
  checkDiscloseBytesPublicInputs(proof, queryResult) {
1164
- const queryResultErrors = {
1165
- sig_check_dsc: {},
1166
- sig_check_id_data: {},
1167
- data_check_integrity: {},
1168
- disclose: {},
1169
- age: {},
1170
- birthdate: {},
1171
- expiry_date: {},
1172
- document_type: {},
1173
- issuing_country: {},
1174
- gender: {},
1175
- nationality: {},
1176
- firstname: {},
1177
- lastname: {},
1178
- fullname: {},
1179
- document_number: {},
1180
- outer: {},
1181
- bind: {}
1182
- };
1195
+ const queryResultErrors = {};
1183
1196
  let isCorrect = true;
1184
1197
  const disclosedDataPassport = import_utils.DisclosedData.fromDisclosedBytes(
1185
1198
  (proof.committedInputs?.disclose_bytes).disclosedBytes,
@@ -1193,19 +1206,25 @@ var ZKPassport = class {
1193
1206
  if (queryResult.document_type.eq && queryResult.document_type.eq.result && queryResult.document_type.eq.expected !== disclosedDataPassport.documentType) {
1194
1207
  console.warn("Document type does not match the expected document type");
1195
1208
  isCorrect = false;
1196
- queryResultErrors.document_type.eq = {
1197
- expected: `${queryResult.document_type.eq.expected}`,
1198
- received: `${disclosedDataPassport.documentType ?? disclosedDataIDCard.documentType}`,
1199
- message: "Document type does not match the expected document type"
1209
+ queryResultErrors.document_type = {
1210
+ ...queryResultErrors.document_type,
1211
+ eq: {
1212
+ expected: `${queryResult.document_type.eq.expected}`,
1213
+ received: `${disclosedDataPassport.documentType ?? disclosedDataIDCard.documentType}`,
1214
+ message: "Document type does not match the expected document type"
1215
+ }
1200
1216
  };
1201
1217
  }
1202
1218
  if (queryResult.document_type.disclose?.result !== disclosedDataIDCard.documentType) {
1203
1219
  console.warn("Document type does not match the disclosed document type in query result");
1204
1220
  isCorrect = false;
1205
- queryResultErrors.document_type.disclose = {
1206
- expected: `${queryResult.document_type.disclose?.result}`,
1207
- received: `${disclosedDataIDCard.documentType ?? disclosedDataPassport.documentType}`,
1208
- message: "Document type does not match the disclosed document type in query result"
1221
+ queryResultErrors.document_type = {
1222
+ ...queryResultErrors.document_type,
1223
+ disclose: {
1224
+ expected: `${queryResult.document_type.disclose?.result}`,
1225
+ received: `${disclosedDataIDCard.documentType ?? disclosedDataPassport.documentType}`,
1226
+ message: "Document type does not match the disclosed document type in query result"
1227
+ }
1209
1228
  };
1210
1229
  }
1211
1230
  }
@@ -1215,19 +1234,25 @@ var ZKPassport = class {
1215
1234
  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)) {
1216
1235
  console.warn("Birthdate does not match the expected birthdate");
1217
1236
  isCorrect = false;
1218
- queryResultErrors.birthdate.eq = {
1219
- expected: `${queryResult.birthdate.eq.expected.toISOString()}`,
1220
- received: `${birthdatePassport?.toISOString() ?? birthdateIDCard?.toISOString()}`,
1221
- message: "Birthdate does not match the expected birthdate"
1237
+ queryResultErrors.birthdate = {
1238
+ ...queryResultErrors.birthdate,
1239
+ eq: {
1240
+ expected: `${queryResult.birthdate.eq.expected.toISOString()}`,
1241
+ received: `${birthdatePassport?.toISOString() ?? birthdateIDCard?.toISOString()}`,
1242
+ message: "Birthdate does not match the expected birthdate"
1243
+ }
1222
1244
  };
1223
1245
  }
1224
1246
  if (queryResult.birthdate.disclose && !(0, import_utils.areDatesEqual)(queryResult.birthdate.disclose.result, birthdatePassport) && !(0, import_utils.areDatesEqual)(queryResult.birthdate.disclose.result, birthdateIDCard)) {
1225
1247
  console.warn("Birthdate does not match the disclosed birthdate in query result");
1226
1248
  isCorrect = false;
1227
- queryResultErrors.birthdate.disclose = {
1228
- expected: `${queryResult.birthdate.disclose.result.toISOString()}`,
1229
- received: `${birthdatePassport?.toISOString() ?? birthdateIDCard?.toISOString()}`,
1230
- message: "Birthdate does not match the disclosed birthdate in query result"
1249
+ queryResultErrors.birthdate = {
1250
+ ...queryResultErrors.birthdate,
1251
+ disclose: {
1252
+ expected: `${queryResult.birthdate.disclose.result.toISOString()}`,
1253
+ received: `${birthdatePassport?.toISOString() ?? birthdateIDCard?.toISOString()}`,
1254
+ message: "Birthdate does not match the disclosed birthdate in query result"
1255
+ }
1231
1256
  };
1232
1257
  }
1233
1258
  }
@@ -1237,19 +1262,25 @@ var ZKPassport = class {
1237
1262
  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)) {
1238
1263
  console.warn("Expiry date does not match the expected expiry date");
1239
1264
  isCorrect = false;
1240
- queryResultErrors.expiry_date.eq = {
1241
- expected: `${queryResult.expiry_date.eq.expected.toISOString()}`,
1242
- received: `${expiryDatePassport?.toISOString() ?? expiryDateIDCard?.toISOString()}`,
1243
- message: "Expiry date does not match the expected expiry date"
1265
+ queryResultErrors.expiry_date = {
1266
+ ...queryResultErrors.expiry_date,
1267
+ eq: {
1268
+ expected: `${queryResult.expiry_date.eq.expected.toISOString()}`,
1269
+ received: `${expiryDatePassport?.toISOString() ?? expiryDateIDCard?.toISOString()}`,
1270
+ message: "Expiry date does not match the expected expiry date"
1271
+ }
1244
1272
  };
1245
1273
  }
1246
1274
  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)) {
1247
1275
  console.warn("Expiry date does not match the disclosed expiry date in query result");
1248
1276
  isCorrect = false;
1249
- queryResultErrors.expiry_date.disclose = {
1250
- expected: `${queryResult.expiry_date.disclose.result.toISOString()}`,
1251
- received: `${expiryDatePassport?.toISOString() ?? expiryDateIDCard?.toISOString()}`,
1252
- message: "Expiry date does not match the disclosed expiry date in query result"
1277
+ queryResultErrors.expiry_date = {
1278
+ ...queryResultErrors.expiry_date,
1279
+ disclose: {
1280
+ expected: `${queryResult.expiry_date.disclose.result.toISOString()}`,
1281
+ received: `${expiryDatePassport?.toISOString() ?? expiryDateIDCard?.toISOString()}`,
1282
+ message: "Expiry date does not match the disclosed expiry date in query result"
1283
+ }
1253
1284
  };
1254
1285
  }
1255
1286
  }
@@ -1259,19 +1290,25 @@ var ZKPassport = class {
1259
1290
  if (queryResult.nationality.eq && queryResult.nationality.eq.result && queryResult.nationality.eq.expected !== nationalityPassport && queryResult.nationality.eq.expected !== nationalityIDCard) {
1260
1291
  console.warn("Nationality does not match the expected nationality");
1261
1292
  isCorrect = false;
1262
- queryResultErrors.nationality.eq = {
1263
- expected: `${queryResult.nationality.eq.expected}`,
1264
- received: `${nationalityPassport ?? nationalityIDCard}`,
1265
- message: "Nationality does not match the expected nationality"
1293
+ queryResultErrors.nationality = {
1294
+ ...queryResultErrors.nationality,
1295
+ eq: {
1296
+ expected: `${queryResult.nationality.eq.expected}`,
1297
+ received: `${nationalityPassport ?? nationalityIDCard}`,
1298
+ message: "Nationality does not match the expected nationality"
1299
+ }
1266
1300
  };
1267
1301
  }
1268
1302
  if (queryResult.nationality.disclose && queryResult.nationality.disclose.result !== nationalityPassport && queryResult.nationality.disclose.result !== nationalityIDCard) {
1269
1303
  console.warn("Nationality does not match the disclosed nationality in query result");
1270
1304
  isCorrect = false;
1271
- queryResultErrors.nationality.disclose = {
1272
- expected: `${queryResult.nationality.disclose.result}`,
1273
- received: `${nationalityPassport ?? nationalityIDCard}`,
1274
- message: "Nationality does not match the disclosed nationality in query result"
1305
+ queryResultErrors.nationality = {
1306
+ ...queryResultErrors.nationality,
1307
+ disclose: {
1308
+ expected: `${queryResult.nationality.disclose.result}`,
1309
+ received: `${nationalityPassport ?? nationalityIDCard}`,
1310
+ message: "Nationality does not match the disclosed nationality in query result"
1311
+ }
1275
1312
  };
1276
1313
  }
1277
1314
  }
@@ -1281,19 +1318,25 @@ var ZKPassport = class {
1281
1318
  if (queryResult.document_number.eq && queryResult.document_number.eq.result && queryResult.document_number.eq.expected !== documentNumberPassport && queryResult.document_number.eq.expected !== documentNumberIDCard) {
1282
1319
  console.warn("Document number does not match the expected document number");
1283
1320
  isCorrect = false;
1284
- queryResultErrors.document_number.eq = {
1285
- expected: `${queryResult.document_number.eq.expected}`,
1286
- received: `${documentNumberPassport ?? documentNumberIDCard}`,
1287
- message: "Document number does not match the expected document number"
1321
+ queryResultErrors.document_number = {
1322
+ ...queryResultErrors.document_number,
1323
+ eq: {
1324
+ expected: `${queryResult.document_number.eq.expected}`,
1325
+ received: `${documentNumberPassport ?? documentNumberIDCard}`,
1326
+ message: "Document number does not match the expected document number"
1327
+ }
1288
1328
  };
1289
1329
  }
1290
1330
  if (queryResult.document_number.disclose && queryResult.document_number.disclose.result !== documentNumberPassport && queryResult.document_number.disclose.result !== documentNumberIDCard) {
1291
1331
  console.warn("Document number does not match the disclosed document number in query result");
1292
1332
  isCorrect = false;
1293
- queryResultErrors.document_number.disclose = {
1294
- expected: `${queryResult.document_number.disclose.result}`,
1295
- received: `${documentNumberPassport ?? documentNumberIDCard}`,
1296
- message: "Document number does not match the disclosed document number in query result"
1333
+ queryResultErrors.document_number = {
1334
+ ...queryResultErrors.document_number,
1335
+ disclose: {
1336
+ expected: `${queryResult.document_number.disclose.result}`,
1337
+ received: `${documentNumberPassport ?? documentNumberIDCard}`,
1338
+ message: "Document number does not match the disclosed document number in query result"
1339
+ }
1297
1340
  };
1298
1341
  }
1299
1342
  }
@@ -1303,19 +1346,25 @@ var ZKPassport = class {
1303
1346
  if (queryResult.gender.eq && queryResult.gender.eq.result && queryResult.gender.eq.expected !== genderPassport && queryResult.gender.eq.expected !== genderIDCard) {
1304
1347
  console.warn("Gender does not match the expected gender");
1305
1348
  isCorrect = false;
1306
- queryResultErrors.gender.eq = {
1307
- expected: `${queryResult.gender.eq.expected}`,
1308
- received: `${genderPassport ?? genderIDCard}`,
1309
- message: "Gender does not match the expected gender"
1349
+ queryResultErrors.gender = {
1350
+ ...queryResultErrors.gender,
1351
+ eq: {
1352
+ expected: `${queryResult.gender.eq.expected}`,
1353
+ received: `${genderPassport ?? genderIDCard}`,
1354
+ message: "Gender does not match the expected gender"
1355
+ }
1310
1356
  };
1311
1357
  }
1312
1358
  if (queryResult.gender.disclose && queryResult.gender.disclose.result !== genderPassport && queryResult.gender.disclose.result !== genderIDCard) {
1313
1359
  console.warn("Gender does not match the disclosed gender in query result");
1314
1360
  isCorrect = false;
1315
- queryResultErrors.gender.disclose = {
1316
- expected: `${queryResult.gender.disclose.result}`,
1317
- received: `${genderPassport ?? genderIDCard}`,
1318
- message: "Gender does not match the disclosed gender in query result"
1361
+ queryResultErrors.gender = {
1362
+ ...queryResultErrors.gender,
1363
+ disclose: {
1364
+ expected: `${queryResult.gender.disclose.result}`,
1365
+ received: `${genderPassport ?? genderIDCard}`,
1366
+ message: "Gender does not match the disclosed gender in query result"
1367
+ }
1319
1368
  };
1320
1369
  }
1321
1370
  }
@@ -1325,19 +1374,25 @@ var ZKPassport = class {
1325
1374
  if (queryResult.issuing_country.eq && queryResult.issuing_country.eq.result && queryResult.issuing_country.eq.expected !== issuingCountryPassport && queryResult.issuing_country.eq.expected !== issuingCountryIDCard) {
1326
1375
  console.warn("Issuing country does not match the expected issuing country");
1327
1376
  isCorrect = false;
1328
- queryResultErrors.issuing_country.eq = {
1329
- expected: `${queryResult.issuing_country.eq.expected}`,
1330
- received: `${issuingCountryPassport ?? issuingCountryIDCard}`,
1331
- message: "Issuing country does not match the expected issuing country"
1377
+ queryResultErrors.issuing_country = {
1378
+ ...queryResultErrors.issuing_country,
1379
+ eq: {
1380
+ expected: `${queryResult.issuing_country.eq.expected}`,
1381
+ received: `${issuingCountryPassport ?? issuingCountryIDCard}`,
1382
+ message: "Issuing country does not match the expected issuing country"
1383
+ }
1332
1384
  };
1333
1385
  }
1334
1386
  if (queryResult.issuing_country.disclose && queryResult.issuing_country.disclose.result !== issuingCountryPassport && queryResult.issuing_country.disclose.result !== issuingCountryIDCard) {
1335
1387
  console.warn("Issuing country does not match the disclosed issuing country in query result");
1336
1388
  isCorrect = false;
1337
- queryResultErrors.issuing_country.disclose = {
1338
- expected: `${queryResult.issuing_country.disclose.result}`,
1339
- received: `${issuingCountryPassport ?? issuingCountryIDCard}`,
1340
- message: "Issuing country does not match the disclosed issuing country in query result"
1389
+ queryResultErrors.issuing_country = {
1390
+ ...queryResultErrors.issuing_country,
1391
+ disclose: {
1392
+ expected: `${queryResult.issuing_country.disclose.result}`,
1393
+ received: `${issuingCountryPassport ?? issuingCountryIDCard}`,
1394
+ message: "Issuing country does not match the disclosed issuing country in query result"
1395
+ }
1341
1396
  };
1342
1397
  }
1343
1398
  }
@@ -1347,19 +1402,25 @@ var ZKPassport = class {
1347
1402
  if (queryResult.fullname.eq && queryResult.fullname.eq.result && (0, import_utils.formatName)(queryResult.fullname.eq.expected).toLowerCase() !== fullnamePassport.toLowerCase() && (0, import_utils.formatName)(queryResult.fullname.eq.expected).toLowerCase() !== fullnameIDCard.toLowerCase()) {
1348
1403
  console.warn("Fullname does not match the expected fullname");
1349
1404
  isCorrect = false;
1350
- queryResultErrors.fullname.eq = {
1351
- expected: `${queryResult.fullname.eq.expected}`,
1352
- received: `${fullnamePassport ?? fullnameIDCard}`,
1353
- message: "Fullname does not match the expected fullname"
1405
+ queryResultErrors.fullname = {
1406
+ ...queryResultErrors.fullname,
1407
+ eq: {
1408
+ expected: `${queryResult.fullname.eq.expected}`,
1409
+ received: `${fullnamePassport ?? fullnameIDCard}`,
1410
+ message: "Fullname does not match the expected fullname"
1411
+ }
1354
1412
  };
1355
1413
  }
1356
1414
  if (queryResult.fullname.disclose && (0, import_utils.formatName)(queryResult.fullname.disclose.result).toLowerCase() !== fullnamePassport.toLowerCase() && (0, import_utils.formatName)(queryResult.fullname.disclose.result).toLowerCase() !== fullnameIDCard.toLowerCase()) {
1357
1415
  console.warn("Fullname does not match the disclosed fullname in query result");
1358
1416
  isCorrect = false;
1359
- queryResultErrors.fullname.disclose = {
1360
- expected: `${queryResult.fullname.disclose.result}`,
1361
- received: `${fullnamePassport ?? fullnameIDCard}`,
1362
- message: "Fullname does not match the disclosed fullname in query result"
1417
+ queryResultErrors.fullname = {
1418
+ ...queryResultErrors.fullname,
1419
+ disclose: {
1420
+ expected: `${queryResult.fullname.disclose.result}`,
1421
+ received: `${fullnamePassport ?? fullnameIDCard}`,
1422
+ message: "Fullname does not match the disclosed fullname in query result"
1423
+ }
1363
1424
  };
1364
1425
  }
1365
1426
  }
@@ -1369,19 +1430,25 @@ var ZKPassport = class {
1369
1430
  if (queryResult.firstname.eq && queryResult.firstname.eq.result && (0, import_utils.formatName)(queryResult.firstname.eq.expected).toLowerCase() !== firstnamePassport.toLowerCase() && (0, import_utils.formatName)(queryResult.firstname.eq.expected).toLowerCase() !== firstnameIDCard.toLowerCase()) {
1370
1431
  console.warn("Firstname does not match the expected firstname");
1371
1432
  isCorrect = false;
1372
- queryResultErrors.firstname.eq = {
1373
- expected: `${queryResult.firstname.eq.expected}`,
1374
- received: `${firstnamePassport ?? firstnameIDCard}`,
1375
- message: "Firstname does not match the expected firstname"
1433
+ queryResultErrors.firstname = {
1434
+ ...queryResultErrors.firstname,
1435
+ eq: {
1436
+ expected: `${queryResult.firstname.eq.expected}`,
1437
+ received: `${firstnamePassport ?? firstnameIDCard}`,
1438
+ message: "Firstname does not match the expected firstname"
1439
+ }
1376
1440
  };
1377
1441
  }
1378
1442
  if (queryResult.firstname.disclose && (0, import_utils.formatName)(queryResult.firstname.disclose.result).toLowerCase() !== firstnamePassport.toLowerCase() && (0, import_utils.formatName)(queryResult.firstname.disclose.result).toLowerCase() !== firstnameIDCard.toLowerCase()) {
1379
1443
  console.warn("Firstname does not match the disclosed firstname in query result");
1380
1444
  isCorrect = false;
1381
- queryResultErrors.firstname.disclose = {
1382
- expected: `${queryResult.firstname.disclose.result}`,
1383
- received: `${firstnamePassport ?? firstnameIDCard}`,
1384
- message: "Firstname does not match the disclosed firstname in query result"
1445
+ queryResultErrors.firstname = {
1446
+ ...queryResultErrors.firstname,
1447
+ disclose: {
1448
+ expected: `${queryResult.firstname.disclose.result}`,
1449
+ received: `${firstnamePassport ?? firstnameIDCard}`,
1450
+ message: "Firstname does not match the disclosed firstname in query result"
1451
+ }
1385
1452
  };
1386
1453
  }
1387
1454
  }
@@ -1391,44 +1458,32 @@ var ZKPassport = class {
1391
1458
  if (queryResult.lastname.eq && queryResult.lastname.eq.result && (0, import_utils.formatName)(queryResult.lastname.eq.expected).toLowerCase() !== lastnamePassport.toLowerCase() && (0, import_utils.formatName)(queryResult.lastname.eq.expected).toLowerCase() !== lastnameIDCard.toLowerCase()) {
1392
1459
  console.warn("Lastname does not match the expected lastname");
1393
1460
  isCorrect = false;
1394
- queryResultErrors.lastname.eq = {
1395
- expected: `${queryResult.lastname.eq.expected}`,
1396
- received: `${lastnamePassport ?? lastnameIDCard}`,
1397
- message: "Lastname does not match the expected lastname"
1461
+ queryResultErrors.lastname = {
1462
+ ...queryResultErrors.lastname,
1463
+ eq: {
1464
+ expected: `${queryResult.lastname.eq.expected}`,
1465
+ received: `${lastnamePassport ?? lastnameIDCard}`,
1466
+ message: "Lastname does not match the expected lastname"
1467
+ }
1398
1468
  };
1399
1469
  }
1400
1470
  if (queryResult.lastname.disclose && (0, import_utils.formatName)(queryResult.lastname.disclose.result).toLowerCase() !== lastnamePassport.toLowerCase() && (0, import_utils.formatName)(queryResult.lastname.disclose.result).toLowerCase() !== lastnameIDCard.toLowerCase()) {
1401
1471
  console.warn("Lastname does not match the disclosed lastname in query result");
1402
1472
  isCorrect = false;
1403
- queryResultErrors.lastname.disclose = {
1404
- expected: `${queryResult.lastname.disclose.result}`,
1405
- received: `${lastnamePassport ?? lastnameIDCard}`,
1406
- message: "Lastname does not match the disclosed lastname in query result"
1473
+ queryResultErrors.lastname = {
1474
+ ...queryResultErrors.lastname,
1475
+ disclose: {
1476
+ expected: `${queryResult.lastname.disclose.result}`,
1477
+ received: `${lastnamePassport ?? lastnameIDCard}`,
1478
+ message: "Lastname does not match the disclosed lastname in query result"
1479
+ }
1407
1480
  };
1408
1481
  }
1409
1482
  }
1410
1483
  return { isCorrect, queryResultErrors };
1411
1484
  }
1412
1485
  checkAgePublicInputs(proof, queryResult) {
1413
- const queryResultErrors = {
1414
- sig_check_dsc: {},
1415
- sig_check_id_data: {},
1416
- data_check_integrity: {},
1417
- disclose: {},
1418
- age: {},
1419
- birthdate: {},
1420
- expiry_date: {},
1421
- document_type: {},
1422
- issuing_country: {},
1423
- gender: {},
1424
- nationality: {},
1425
- firstname: {},
1426
- lastname: {},
1427
- fullname: {},
1428
- document_number: {},
1429
- outer: {},
1430
- bind: {}
1431
- };
1486
+ const queryResultErrors = {};
1432
1487
  let isCorrect = true;
1433
1488
  const currentTime = /* @__PURE__ */ new Date();
1434
1489
  const today = new Date(
@@ -1450,64 +1505,85 @@ var ZKPassport = class {
1450
1505
  if (queryResult.age.gte && queryResult.age.gte.result && minAge !== queryResult.age.gte.expected) {
1451
1506
  console.warn("Age is not greater than or equal to the expected age");
1452
1507
  isCorrect = false;
1453
- queryResultErrors.age.gte = {
1454
- expected: queryResult.age.gte.expected,
1455
- received: minAge,
1456
- message: "Age is not greater than or equal to the expected age"
1508
+ queryResultErrors.age = {
1509
+ ...queryResultErrors.age,
1510
+ gte: {
1511
+ expected: queryResult.age.gte.expected,
1512
+ received: minAge,
1513
+ message: "Age is not greater than or equal to the expected age"
1514
+ }
1457
1515
  };
1458
1516
  }
1459
1517
  if (queryResult.age.lt && queryResult.age.lt.result && maxAge !== queryResult.age.lt.expected) {
1460
1518
  console.warn("Age is not less than the expected age");
1461
1519
  isCorrect = false;
1462
- queryResultErrors.age.lt = {
1463
- expected: queryResult.age.lt.expected,
1464
- received: maxAge,
1465
- message: "Age is not less than the expected age"
1520
+ queryResultErrors.age = {
1521
+ ...queryResultErrors.age,
1522
+ lt: {
1523
+ expected: queryResult.age.lt.expected,
1524
+ received: maxAge,
1525
+ message: "Age is not less than the expected age"
1526
+ }
1466
1527
  };
1467
1528
  }
1468
1529
  if (queryResult.age.range) {
1469
1530
  if (queryResult.age.range.result && (minAge !== queryResult.age.range.expected[0] || maxAge !== queryResult.age.range.expected[1])) {
1470
1531
  console.warn("Age is not in the expected range");
1471
1532
  isCorrect = false;
1472
- queryResultErrors.age.range = {
1473
- expected: queryResult.age.range.expected,
1474
- received: [minAge, maxAge],
1475
- message: "Age is not in the expected range"
1533
+ queryResultErrors.age = {
1534
+ ...queryResultErrors.age,
1535
+ range: {
1536
+ expected: queryResult.age.range.expected,
1537
+ received: [minAge, maxAge],
1538
+ message: "Age is not in the expected range"
1539
+ }
1476
1540
  };
1477
1541
  }
1478
1542
  }
1479
1543
  if (!queryResult.age.lt && !queryResult.age.range && maxAge != 0) {
1480
1544
  console.warn("Maximum age should be equal to 0");
1481
1545
  isCorrect = false;
1482
- queryResultErrors.age.disclose = {
1483
- expected: 0,
1484
- received: maxAge,
1485
- message: "Maximum age should be equal to 0"
1546
+ queryResultErrors.age = {
1547
+ ...queryResultErrors.age,
1548
+ disclose: {
1549
+ expected: 0,
1550
+ received: maxAge,
1551
+ message: "Maximum age should be equal to 0"
1552
+ }
1486
1553
  };
1487
1554
  }
1488
1555
  if (!queryResult.age.gte && !queryResult.age.range && minAge != 0) {
1489
1556
  console.warn("Minimum age should be equal to 0");
1490
1557
  isCorrect = false;
1491
- queryResultErrors.age.disclose = {
1492
- expected: 0,
1493
- received: minAge,
1494
- message: "Minimum age should be equal to 0"
1558
+ queryResultErrors.age = {
1559
+ ...queryResultErrors.age,
1560
+ disclose: {
1561
+ expected: 0,
1562
+ received: minAge,
1563
+ message: "Minimum age should be equal to 0"
1564
+ }
1495
1565
  };
1496
1566
  }
1497
1567
  if (queryResult.age.disclose && (queryResult.age.disclose.result !== minAge || queryResult.age.disclose.result !== maxAge)) {
1498
1568
  console.warn("Age does not match the disclosed age in query result");
1499
1569
  isCorrect = false;
1500
- queryResultErrors.age.disclose = {
1501
- expected: `${minAge}`,
1502
- received: `${queryResult.age.disclose.result}`,
1503
- message: "Age does not match the disclosed age in query result"
1570
+ queryResultErrors.age = {
1571
+ ...queryResultErrors.age,
1572
+ disclose: {
1573
+ expected: `${minAge}`,
1574
+ received: `${queryResult.age.disclose.result}`,
1575
+ message: "Age does not match the disclosed age in query result"
1576
+ }
1504
1577
  };
1505
1578
  }
1506
1579
  } else {
1507
1580
  console.warn("Age is not set in the query result");
1508
1581
  isCorrect = false;
1509
- queryResultErrors.age.disclose = {
1510
- message: "Age is not set in the query result"
1582
+ queryResultErrors.age = {
1583
+ ...queryResultErrors.age,
1584
+ disclose: {
1585
+ message: "Age is not set in the query result"
1586
+ }
1511
1587
  };
1512
1588
  }
1513
1589
  const currentDate = (0, import_utils.getCurrentDateFromCommittedInputs)(
@@ -1516,34 +1592,19 @@ var ZKPassport = class {
1516
1592
  if (!(0, import_utils.areDatesEqual)(currentDate, today) && !(0, import_utils.areDatesEqual)(currentDate, today.getTime() - 864e5)) {
1517
1593
  console.warn("Current date in the proof is too old");
1518
1594
  isCorrect = false;
1519
- queryResultErrors.age.disclose = {
1520
- expected: `${today.toISOString()}`,
1521
- received: `${currentDate.toISOString()}`,
1522
- message: "Current date in the proof is too old"
1595
+ queryResultErrors.age = {
1596
+ ...queryResultErrors.age,
1597
+ disclose: {
1598
+ expected: `${today.toISOString()}`,
1599
+ received: `${currentDate.toISOString()}`,
1600
+ message: "Current date in the proof is too old"
1601
+ }
1523
1602
  };
1524
1603
  }
1525
1604
  return { isCorrect, queryResultErrors };
1526
1605
  }
1527
1606
  checkBirthdatePublicInputs(proof, queryResult) {
1528
- const queryResultErrors = {
1529
- sig_check_dsc: {},
1530
- sig_check_id_data: {},
1531
- data_check_integrity: {},
1532
- disclose: {},
1533
- age: {},
1534
- birthdate: {},
1535
- expiry_date: {},
1536
- document_type: {},
1537
- issuing_country: {},
1538
- gender: {},
1539
- nationality: {},
1540
- firstname: {},
1541
- lastname: {},
1542
- fullname: {},
1543
- document_number: {},
1544
- outer: {},
1545
- bind: {}
1546
- };
1607
+ const queryResultErrors = {};
1547
1608
  let isCorrect = true;
1548
1609
  const currentTime = /* @__PURE__ */ new Date();
1549
1610
  const today = new Date(
@@ -1554,10 +1615,10 @@ var ZKPassport = class {
1554
1615
  0,
1555
1616
  0
1556
1617
  );
1557
- const minDate = (0, import_utils.getMinDateFromCommittedInputs)(
1618
+ const minDate = (0, import_utils.getBirthdateMinDateTimestamp)(
1558
1619
  proof.committedInputs?.compare_birthdate
1559
1620
  );
1560
- const maxDate = (0, import_utils.getMaxDateFromCommittedInputs)(
1621
+ const maxDate = (0, import_utils.getBirthdateMaxDateTimestamp)(
1561
1622
  proof.committedInputs?.compare_birthdate
1562
1623
  );
1563
1624
  const currentDate = (0, import_utils.getCurrentDateFromCommittedInputs)(
@@ -1567,88 +1628,91 @@ var ZKPassport = class {
1567
1628
  if (queryResult.birthdate.gte && queryResult.birthdate.gte.result && minDate !== queryResult.birthdate.gte.expected) {
1568
1629
  console.warn("Birthdate is not greater than or equal to the expected birthdate");
1569
1630
  isCorrect = false;
1570
- queryResultErrors.birthdate.gte = {
1571
- expected: queryResult.birthdate.gte.expected,
1572
- received: minDate,
1573
- message: "Birthdate is not greater than or equal to the expected birthdate"
1631
+ queryResultErrors.birthdate = {
1632
+ ...queryResultErrors.birthdate,
1633
+ gte: {
1634
+ expected: queryResult.birthdate.gte.expected,
1635
+ received: minDate,
1636
+ message: "Birthdate is not greater than or equal to the expected birthdate"
1637
+ }
1574
1638
  };
1575
1639
  }
1576
1640
  if (queryResult.birthdate.lte && queryResult.birthdate.lte.result && maxDate !== queryResult.birthdate.lte.expected) {
1577
1641
  console.warn("Birthdate is not less than the expected birthdate");
1578
1642
  isCorrect = false;
1579
- queryResultErrors.birthdate.lte = {
1580
- expected: queryResult.birthdate.lte.expected,
1581
- received: maxDate,
1582
- message: "Birthdate is not less than the expected birthdate"
1643
+ queryResultErrors.birthdate = {
1644
+ ...queryResultErrors.birthdate,
1645
+ lte: {
1646
+ expected: queryResult.birthdate.lte.expected,
1647
+ received: maxDate,
1648
+ message: "Birthdate is not less than the expected birthdate"
1649
+ }
1583
1650
  };
1584
1651
  }
1585
1652
  if (queryResult.birthdate.range) {
1586
1653
  if (queryResult.birthdate.range.result && (minDate !== queryResult.birthdate.range.expected[0] || maxDate !== queryResult.birthdate.range.expected[1])) {
1587
1654
  console.warn("Birthdate is not in the expected range");
1588
1655
  isCorrect = false;
1589
- queryResultErrors.birthdate.range = {
1590
- expected: queryResult.birthdate.range.expected,
1591
- received: [minDate, maxDate],
1592
- message: "Birthdate is not in the expected range"
1656
+ queryResultErrors.birthdate = {
1657
+ ...queryResultErrors.birthdate,
1658
+ range: {
1659
+ expected: queryResult.birthdate.range.expected,
1660
+ received: [minDate, maxDate],
1661
+ message: "Birthdate is not in the expected range"
1662
+ }
1593
1663
  };
1594
1664
  }
1595
1665
  }
1596
1666
  if (!queryResult.birthdate.lte && !queryResult.birthdate.range && !(0, import_utils.areDatesEqual)(maxDate, DEFAULT_DATE_VALUE)) {
1597
1667
  console.warn("Maximum birthdate should be equal to default date value");
1598
1668
  isCorrect = false;
1599
- queryResultErrors.birthdate.disclose = {
1600
- expected: `${DEFAULT_DATE_VALUE.toISOString()}`,
1601
- received: `${maxDate.toISOString()}`,
1602
- message: "Maximum birthdate should be equal to default date value"
1669
+ queryResultErrors.birthdate = {
1670
+ ...queryResultErrors.birthdate,
1671
+ disclose: {
1672
+ expected: `${DEFAULT_DATE_VALUE.toISOString()}`,
1673
+ received: `${maxDate.toISOString()}`,
1674
+ message: "Maximum birthdate should be equal to default date value"
1675
+ }
1603
1676
  };
1604
1677
  }
1605
1678
  if (!queryResult.birthdate.gte && !queryResult.birthdate.range && !(0, import_utils.areDatesEqual)(minDate, DEFAULT_DATE_VALUE)) {
1606
1679
  console.warn("Minimum birthdate should be equal to default date value");
1607
1680
  isCorrect = false;
1608
- queryResultErrors.birthdate.disclose = {
1609
- expected: `${DEFAULT_DATE_VALUE.toISOString()}`,
1610
- received: `${minDate.toISOString()}`,
1611
- message: "Minimum birthdate should be equal to default date value"
1681
+ queryResultErrors.birthdate = {
1682
+ ...queryResultErrors.birthdate,
1683
+ disclose: {
1684
+ expected: `${DEFAULT_DATE_VALUE.toISOString()}`,
1685
+ received: `${minDate.toISOString()}`,
1686
+ message: "Minimum birthdate should be equal to default date value"
1687
+ }
1612
1688
  };
1613
1689
  }
1614
1690
  } else {
1615
1691
  console.warn("Birthdate is not set in the query result");
1616
1692
  isCorrect = false;
1617
- queryResultErrors.birthdate.disclose = {
1618
- message: "Birthdate is not set in the query result"
1693
+ queryResultErrors.birthdate = {
1694
+ ...queryResultErrors.birthdate,
1695
+ disclose: {
1696
+ message: "Birthdate is not set in the query result"
1697
+ }
1619
1698
  };
1620
1699
  }
1621
1700
  if (!(0, import_utils.areDatesEqual)(currentDate, today) && !(0, import_utils.areDatesEqual)(currentDate, today.getTime() - 864e5)) {
1622
1701
  console.warn("Current date in the proof is too old");
1623
1702
  isCorrect = false;
1624
- queryResultErrors.age.disclose = {
1625
- expected: `${today.toISOString()}`,
1626
- received: `${currentDate.toISOString()}`,
1627
- message: "Current date in the proof is too old"
1703
+ queryResultErrors.birthdate = {
1704
+ ...queryResultErrors.birthdate,
1705
+ disclose: {
1706
+ expected: `${today.toISOString()}`,
1707
+ received: `${currentDate.toISOString()}`,
1708
+ message: "Current date in the proof is too old"
1709
+ }
1628
1710
  };
1629
1711
  }
1630
1712
  return { isCorrect, queryResultErrors };
1631
1713
  }
1632
1714
  checkExpiryDatePublicInputs(proof, queryResult) {
1633
- const queryResultErrors = {
1634
- sig_check_dsc: {},
1635
- sig_check_id_data: {},
1636
- data_check_integrity: {},
1637
- disclose: {},
1638
- age: {},
1639
- birthdate: {},
1640
- expiry_date: {},
1641
- document_type: {},
1642
- issuing_country: {},
1643
- gender: {},
1644
- nationality: {},
1645
- firstname: {},
1646
- lastname: {},
1647
- fullname: {},
1648
- document_number: {},
1649
- outer: {},
1650
- bind: {}
1651
- };
1715
+ const queryResultErrors = {};
1652
1716
  let isCorrect = true;
1653
1717
  const currentTime = /* @__PURE__ */ new Date();
1654
1718
  const today = new Date(
@@ -1672,104 +1736,113 @@ var ZKPassport = class {
1672
1736
  if (queryResult.expiry_date.gte && queryResult.expiry_date.gte.result && minDate !== queryResult.expiry_date.gte.expected) {
1673
1737
  console.warn("Expiry date is not greater than or equal to the expected expiry date");
1674
1738
  isCorrect = false;
1675
- queryResultErrors.expiry_date.gte = {
1676
- expected: queryResult.expiry_date.gte.expected,
1677
- received: minDate,
1678
- message: "Expiry date is not greater than or equal to the expected expiry date"
1739
+ queryResultErrors.expiry_date = {
1740
+ ...queryResultErrors.expiry_date,
1741
+ gte: {
1742
+ expected: queryResult.expiry_date.gte.expected,
1743
+ received: minDate,
1744
+ message: "Expiry date is not greater than or equal to the expected expiry date"
1745
+ }
1679
1746
  };
1680
1747
  }
1681
1748
  if (queryResult.expiry_date.lte && queryResult.expiry_date.lte.result && maxDate !== queryResult.expiry_date.lte.expected) {
1682
1749
  console.warn("Expiry date is not less than the expected expiry date");
1683
1750
  isCorrect = false;
1684
- queryResultErrors.expiry_date.lte = {
1685
- expected: queryResult.expiry_date.lte.expected,
1686
- received: maxDate,
1687
- message: "Expiry date is not less than the expected expiry date"
1751
+ queryResultErrors.expiry_date = {
1752
+ ...queryResultErrors.expiry_date,
1753
+ lte: {
1754
+ expected: queryResult.expiry_date.lte.expected,
1755
+ received: maxDate,
1756
+ message: "Expiry date is not less than the expected expiry date"
1757
+ }
1688
1758
  };
1689
1759
  }
1690
1760
  if (queryResult.expiry_date.range) {
1691
1761
  if (queryResult.expiry_date.range.result && (minDate !== queryResult.expiry_date.range.expected[0] || maxDate !== queryResult.expiry_date.range.expected[1])) {
1692
1762
  console.warn("Expiry date is not in the expected range");
1693
1763
  isCorrect = false;
1694
- queryResultErrors.expiry_date.range = {
1695
- expected: queryResult.expiry_date.range.expected,
1696
- received: [minDate, maxDate],
1697
- message: "Expiry date is not in the expected range"
1764
+ queryResultErrors.expiry_date = {
1765
+ ...queryResultErrors.expiry_date,
1766
+ range: {
1767
+ expected: queryResult.expiry_date.range.expected,
1768
+ received: [minDate, maxDate],
1769
+ message: "Expiry date is not in the expected range"
1770
+ }
1698
1771
  };
1699
1772
  }
1700
1773
  }
1701
1774
  if (!queryResult.expiry_date.lte && !queryResult.expiry_date.range && !(0, import_utils.areDatesEqual)(maxDate, DEFAULT_DATE_VALUE)) {
1702
1775
  console.warn("Maximum expiry date should be equal to default date value");
1703
1776
  isCorrect = false;
1704
- queryResultErrors.expiry_date.disclose = {
1705
- expected: `${DEFAULT_DATE_VALUE.toISOString()}`,
1706
- received: `${maxDate.toISOString()}`,
1707
- message: "Maximum expiry date should be equal to default date value"
1777
+ queryResultErrors.expiry_date = {
1778
+ ...queryResultErrors.expiry_date,
1779
+ disclose: {
1780
+ expected: `${DEFAULT_DATE_VALUE.toISOString()}`,
1781
+ received: `${maxDate.toISOString()}`,
1782
+ message: "Maximum expiry date should be equal to default date value"
1783
+ }
1708
1784
  };
1709
1785
  }
1710
1786
  if (!queryResult.expiry_date.gte && !queryResult.expiry_date.range && !(0, import_utils.areDatesEqual)(minDate, DEFAULT_DATE_VALUE)) {
1711
1787
  console.warn("Minimum expiry date should be equal to default date value");
1712
1788
  isCorrect = false;
1713
- queryResultErrors.expiry_date.disclose = {
1714
- expected: `${DEFAULT_DATE_VALUE.toISOString()}`,
1715
- received: `${minDate.toISOString()}`,
1716
- message: "Minimum expiry date should be equal to default date value"
1789
+ queryResultErrors.expiry_date = {
1790
+ ...queryResultErrors.expiry_date,
1791
+ disclose: {
1792
+ expected: `${DEFAULT_DATE_VALUE.toISOString()}`,
1793
+ received: `${minDate.toISOString()}`,
1794
+ message: "Minimum expiry date should be equal to default date value"
1795
+ }
1717
1796
  };
1718
1797
  }
1719
1798
  } else {
1720
1799
  console.warn("Expiry date is not set in the query result");
1721
1800
  isCorrect = false;
1722
- queryResultErrors.expiry_date.disclose = {
1723
- message: "Expiry date is not set in the query result"
1801
+ queryResultErrors.expiry_date = {
1802
+ ...queryResultErrors.expiry_date,
1803
+ disclose: {
1804
+ message: "Expiry date is not set in the query result"
1805
+ }
1724
1806
  };
1725
1807
  }
1726
1808
  if (!(0, import_utils.areDatesEqual)(currentDate, today) && !(0, import_utils.areDatesEqual)(currentDate, today.getTime() - 864e5)) {
1727
1809
  console.warn("Current date in the proof is too old");
1728
1810
  isCorrect = false;
1729
- queryResultErrors.age.disclose = {
1730
- expected: `${today.toISOString()}`,
1731
- received: `${currentDate.toISOString()}`,
1732
- message: "Current date in the proof is too old"
1811
+ queryResultErrors.expiry_date = {
1812
+ ...queryResultErrors.expiry_date,
1813
+ disclose: {
1814
+ expected: `${today.toISOString()}`,
1815
+ received: `${currentDate.toISOString()}`,
1816
+ message: "Current date in the proof is too old"
1817
+ }
1733
1818
  };
1734
1819
  }
1735
1820
  return { isCorrect, queryResultErrors };
1736
1821
  }
1737
1822
  checkNationalityExclusionPublicInputs(queryResult, countryList) {
1738
- const queryResultErrors = {
1739
- sig_check_dsc: {},
1740
- sig_check_id_data: {},
1741
- data_check_integrity: {},
1742
- disclose: {},
1743
- age: {},
1744
- birthdate: {},
1745
- expiry_date: {},
1746
- document_type: {},
1747
- issuing_country: {},
1748
- gender: {},
1749
- nationality: {},
1750
- firstname: {},
1751
- lastname: {},
1752
- fullname: {},
1753
- document_number: {},
1754
- outer: {},
1755
- bind: {}
1756
- };
1823
+ const queryResultErrors = {};
1757
1824
  let isCorrect = true;
1758
1825
  if (queryResult.nationality && queryResult.nationality.out && queryResult.nationality.out.result) {
1759
1826
  if (!queryResult.nationality.out.expected?.every((country) => countryList.includes(country))) {
1760
1827
  console.warn("Nationality exclusion list does not match the one from the query results");
1761
1828
  isCorrect = false;
1762
- queryResultErrors.nationality.out = {
1763
- expected: queryResult.nationality.out.expected,
1764
- received: countryList,
1765
- message: "Nationality exclusion list does not match the one from the query results"
1829
+ queryResultErrors.nationality = {
1830
+ ...queryResultErrors.nationality,
1831
+ out: {
1832
+ expected: queryResult.nationality.out.expected,
1833
+ received: countryList,
1834
+ message: "Nationality exclusion list does not match the one from the query results"
1835
+ }
1766
1836
  };
1767
1837
  }
1768
1838
  } else if (!queryResult.nationality || !queryResult.nationality.out) {
1769
1839
  console.warn("Nationality exclusion is not set in the query result");
1770
1840
  isCorrect = false;
1771
- queryResultErrors.nationality.out = {
1772
- message: "Nationality exclusion is not set in the query result"
1841
+ queryResultErrors.nationality = {
1842
+ ...queryResultErrors.nationality,
1843
+ out: {
1844
+ message: "Nationality exclusion is not set in the query result"
1845
+ }
1773
1846
  };
1774
1847
  }
1775
1848
  for (let i = 1; i < countryList.length; i++) {
@@ -1778,49 +1851,40 @@ var ZKPassport = class {
1778
1851
  "The nationality exclusion list has not been sorted, and thus the proof cannot be trusted"
1779
1852
  );
1780
1853
  isCorrect = false;
1781
- queryResultErrors.nationality.out = {
1782
- message: "The nationality exclusion list has not been sorted, and thus the proof cannot be trusted"
1854
+ queryResultErrors.nationality = {
1855
+ ...queryResultErrors.nationality,
1856
+ out: {
1857
+ message: "The nationality exclusion list has not been sorted, and thus the proof cannot be trusted"
1858
+ }
1783
1859
  };
1784
1860
  }
1785
1861
  }
1786
1862
  return { isCorrect, queryResultErrors };
1787
1863
  }
1788
1864
  checkIssuingCountryExclusionPublicInputs(queryResult, countryList) {
1789
- const queryResultErrors = {
1790
- sig_check_dsc: {},
1791
- sig_check_id_data: {},
1792
- data_check_integrity: {},
1793
- disclose: {},
1794
- age: {},
1795
- birthdate: {},
1796
- expiry_date: {},
1797
- document_type: {},
1798
- issuing_country: {},
1799
- gender: {},
1800
- nationality: {},
1801
- firstname: {},
1802
- lastname: {},
1803
- fullname: {},
1804
- document_number: {},
1805
- outer: {},
1806
- bind: {}
1807
- };
1865
+ const queryResultErrors = {};
1808
1866
  let isCorrect = true;
1809
1867
  if (queryResult.issuing_country && queryResult.issuing_country.out && queryResult.issuing_country.out.result) {
1810
1868
  if (!queryResult.issuing_country.out.expected?.every((country) => countryList.includes(country))) {
1811
1869
  console.warn("Issuing country exclusion list does not match the one from the query results");
1812
1870
  isCorrect = false;
1813
- queryResultErrors.issuing_country.out = {
1814
- expected: queryResult.issuing_country.out.expected,
1815
- received: countryList,
1816
- message: "Issuing country exclusion list does not match the one from the query results"
1871
+ queryResultErrors.issuing_country = {
1872
+ ...queryResultErrors.issuing_country,
1873
+ out: {
1874
+ expected: queryResult.issuing_country.out.expected,
1875
+ received: countryList,
1876
+ message: "Issuing country exclusion list does not match the one from the query results"
1877
+ }
1817
1878
  };
1818
1879
  }
1819
1880
  } else if (!queryResult.issuing_country || !queryResult.issuing_country.out) {
1820
1881
  console.warn("Issuing country exclusion is not set in the query result");
1821
1882
  isCorrect = false;
1822
- queryResultErrors.issuing_country.out = {
1823
- message: "Issuing country exclusion is not set in the query result"
1883
+ queryResultErrors.issuing_country = {
1884
+ ...queryResultErrors.issuing_country,
1885
+ out: {
1886
+ message: "Issuing country exclusion is not set in the query result"
1887
+ }
1824
1888
  };
1825
1889
  }
1826
1890
  for (let i = 1; i < countryList.length; i++) {
@@ -1829,98 +1893,80 @@ var ZKPassport = class {
1829
1893
  "The issuing country exclusion list has not been sorted, and thus the proof cannot be trusted"
1830
1894
  );
1831
1895
  isCorrect = false;
1832
- queryResultErrors.issuing_country.out = {
1833
- message: "The issuing country exclusion list has not been sorted, and thus the proof cannot be trusted"
1896
+ queryResultErrors.issuing_country = {
1897
+ ...queryResultErrors.issuing_country,
1898
+ out: {
1899
+ message: "The issuing country exclusion list has not been sorted, and thus the proof cannot be trusted"
1900
+ }
1834
1901
  };
1835
1902
  }
1836
1903
  }
1837
1904
  return { isCorrect, queryResultErrors };
1838
1905
  }
1839
1906
  checkNationalityInclusionPublicInputs(queryResult, countryList) {
1840
- const queryResultErrors = {
1841
- sig_check_dsc: {},
1842
- sig_check_id_data: {},
1843
- data_check_integrity: {},
1844
- disclose: {},
1845
- age: {},
1846
- birthdate: {},
1847
- expiry_date: {},
1848
- document_type: {},
1849
- issuing_country: {},
1850
- gender: {},
1851
- nationality: {},
1852
- firstname: {},
1853
- lastname: {},
1854
- fullname: {},
1855
- document_number: {},
1856
- outer: {},
1857
- bind: {}
1858
- };
1907
+ const queryResultErrors = {};
1859
1908
  let isCorrect = true;
1860
1909
  if (queryResult.nationality && queryResult.nationality.in && queryResult.nationality.in.result) {
1861
1910
  if (!queryResult.nationality.in.expected?.every((country) => countryList.includes(country))) {
1862
1911
  console.warn("Nationality inclusion list does not match the one from the query results");
1863
1912
  isCorrect = false;
1864
- queryResultErrors.nationality.in = {
1865
- expected: queryResult.nationality.in.expected,
1866
- received: countryList,
1867
- message: "Nationality inclusion list does not match the one from the query results"
1913
+ queryResultErrors.nationality = {
1914
+ ...queryResultErrors.nationality,
1915
+ in: {
1916
+ expected: queryResult.nationality.in.expected,
1917
+ received: countryList,
1918
+ message: "Nationality inclusion list does not match the one from the query results"
1919
+ }
1868
1920
  };
1869
1921
  }
1870
1922
  } else if (!queryResult.nationality || !queryResult.nationality.in) {
1871
1923
  console.warn("Nationality inclusion is not set in the query result");
1872
1924
  isCorrect = false;
1873
- queryResultErrors.nationality.in = {
1874
- message: "Nationality inclusion is not set in the query result"
1925
+ queryResultErrors.nationality = {
1926
+ ...queryResultErrors.nationality,
1927
+ in: {
1928
+ message: "Nationality inclusion is not set in the query result"
1929
+ }
1875
1930
  };
1876
1931
  }
1877
1932
  return { isCorrect, queryResultErrors };
1878
1933
  }
1879
1934
  checkIssuingCountryInclusionPublicInputs(queryResult, countryList) {
1880
- const queryResultErrors = {
1881
- sig_check_dsc: {},
1882
- sig_check_id_data: {},
1883
- data_check_integrity: {},
1884
- disclose: {},
1885
- age: {},
1886
- birthdate: {},
1887
- expiry_date: {},
1888
- document_type: {},
1889
- issuing_country: {},
1890
- gender: {},
1891
- nationality: {},
1892
- firstname: {},
1893
- lastname: {},
1894
- fullname: {},
1895
- document_number: {},
1896
- outer: {},
1897
- bind: {}
1898
- };
1935
+ const queryResultErrors = {};
1899
1936
  let isCorrect = true;
1900
1937
  if (queryResult.issuing_country && queryResult.issuing_country.in && queryResult.issuing_country.in.result) {
1901
1938
  if (!queryResult.issuing_country.in.expected?.every((country) => countryList.includes(country))) {
1902
1939
  console.warn("Issuing country inclusion list does not match the one from the query results");
1903
1940
  isCorrect = false;
1904
- queryResultErrors.issuing_country.in = {
1905
- expected: queryResult.issuing_country.in.expected,
1906
- received: countryList,
1907
- message: "Issuing country inclusion list does not match the one from the query results"
1941
+ queryResultErrors.issuing_country = {
1942
+ ...queryResultErrors.issuing_country,
1943
+ in: {
1944
+ expected: queryResult.issuing_country.in.expected,
1945
+ received: countryList,
1946
+ message: "Issuing country inclusion list does not match the one from the query results"
1947
+ }
1908
1948
  };
1909
1949
  }
1910
1950
  } else if (!queryResult.issuing_country || !queryResult.issuing_country.in) {
1911
1951
  console.warn("Issuing country inclusion is not set in the query result");
1912
1952
  isCorrect = false;
1913
- queryResultErrors.issuing_country.in = {
1914
- message: "Issuing country inclusion is not set in the query result"
1953
+ queryResultErrors.issuing_country = {
1954
+ ...queryResultErrors.issuing_country,
1955
+ in: {
1956
+ message: "Issuing country inclusion is not set in the query result"
1957
+ }
1915
1958
  };
1916
1959
  }
1917
1960
  return { isCorrect, queryResultErrors };
1918
1961
  }
1919
- checkScopeFromDisclosureProof(proofData, queryResultErrors, key, scope, chainId) {
1962
+ checkScopeFromDisclosureProof(proofData, queryResultErrors, key, scope) {
1920
1963
  let isCorrect = true;
1921
1964
  if (this.domain && (0, import_utils.getServiceScopeHash)(this.domain) !== BigInt(proofData.publicInputs[1])) {
1922
1965
  console.warn("The proof comes from a different domain than the one expected");
1923
1966
  isCorrect = false;
1967
+ if (!queryResultErrors[key]) {
1968
+ queryResultErrors[key] = {};
1969
+ }
1924
1970
  queryResultErrors[key].scope = {
1925
1971
  expected: `Scope: ${(0, import_utils.getServiceScopeHash)(this.domain).toString()}`,
1926
1972
  received: `Scope: ${BigInt(proofData.publicInputs[1]).toString()}`,
@@ -1930,6 +1976,9 @@ var ZKPassport = class {
1930
1976
  if (scope && (0, import_utils.getScopeHash)(scope) !== BigInt(proofData.publicInputs[2])) {
1931
1977
  console.warn("The proof uses a different scope than the one expected");
1932
1978
  isCorrect = false;
1979
+ if (!queryResultErrors[key]) {
1980
+ queryResultErrors[key] = {};
1981
+ }
1933
1982
  queryResultErrors[key].scope = {
1934
1983
  expected: `Scope: ${(0, import_utils.getScopeHash)(scope).toString()}`,
1935
1984
  received: `Scope: ${BigInt(proofData.publicInputs[2]).toString()}`,
@@ -1946,6 +1995,9 @@ var ZKPassport = class {
1946
1995
  if (!isValid) {
1947
1996
  console.warn("The ID was signed by an unrecognized root certificate");
1948
1997
  isCorrect = false;
1998
+ if (!queryResultErrors[outer ? "outer" : "sig_check_dsc"]) {
1999
+ queryResultErrors[outer ? "outer" : "sig_check_dsc"] = {};
2000
+ }
1949
2001
  queryResultErrors[outer ? "outer" : "sig_check_dsc"].certificate = {
1950
2002
  expected: `A valid root from ZKPassport Registry`,
1951
2003
  received: `Got invalid certificate registry root: ${root}`,
@@ -1956,6 +2008,9 @@ var ZKPassport = class {
1956
2008
  console.warn(error);
1957
2009
  console.warn("The ID was signed by an unrecognized root certificate");
1958
2010
  isCorrect = false;
2011
+ if (!queryResultErrors[outer ? "outer" : "sig_check_dsc"]) {
2012
+ queryResultErrors[outer ? "outer" : "sig_check_dsc"] = {};
2013
+ }
1959
2014
  queryResultErrors[outer ? "outer" : "sig_check_dsc"].certificate = {
1960
2015
  expected: `A valid root from ZKPassport Registry`,
1961
2016
  received: `Got invalid certificate registry root: ${root}`,
@@ -1991,52 +2046,63 @@ var ZKPassport = class {
1991
2046
  return { isCorrect, queryResultErrors };
1992
2047
  }
1993
2048
  checkBindPublicInputs(queryResult, boundData) {
1994
- const queryResultErrors = {
1995
- sig_check_dsc: {},
1996
- sig_check_id_data: {},
1997
- data_check_integrity: {},
1998
- disclose: {},
1999
- age: {},
2000
- birthdate: {},
2001
- expiry_date: {},
2002
- document_type: {},
2003
- issuing_country: {},
2004
- gender: {},
2005
- nationality: {},
2006
- firstname: {},
2007
- lastname: {},
2008
- fullname: {},
2009
- document_number: {},
2010
- outer: {},
2011
- bind: {}
2012
- };
2049
+ const queryResultErrors = {};
2013
2050
  let isCorrect = true;
2014
2051
  if (queryResult.bind) {
2015
2052
  if (queryResult.bind.user_address?.toLowerCase().replace("0x", "") !== boundData.user_address?.toLowerCase().replace("0x", "")) {
2016
2053
  console.warn("Bound user address does not match the one from the query results");
2017
2054
  isCorrect = false;
2018
- queryResultErrors.bind.eq = {
2019
- expected: queryResult.bind.user_address,
2020
- received: boundData.user_address,
2021
- message: "Bound user address does not match the one from the query results"
2055
+ queryResultErrors.bind = {
2056
+ ...queryResultErrors.bind,
2057
+ eq: {
2058
+ expected: queryResult.bind.user_address,
2059
+ received: boundData.user_address,
2060
+ message: "Bound user address does not match the one from the query results"
2061
+ }
2022
2062
  };
2023
2063
  }
2024
2064
  if (queryResult.bind.chain !== boundData.chain) {
2025
2065
  console.warn("Bound chain id does not match the one from the query results");
2026
2066
  isCorrect = false;
2027
- queryResultErrors.bind.eq = {
2028
- expected: queryResult.bind.chain,
2029
- received: boundData.chain,
2030
- message: "Bound chain id does not match the one from the query results"
2067
+ queryResultErrors.bind = {
2068
+ ...queryResultErrors.bind,
2069
+ eq: {
2070
+ expected: queryResult.bind.chain,
2071
+ received: boundData.chain,
2072
+ message: "Bound chain id does not match the one from the query results"
2073
+ }
2031
2074
  };
2032
2075
  }
2033
2076
  if (queryResult.bind.custom_data?.trim().toLowerCase() !== boundData.custom_data?.trim().toLowerCase()) {
2034
2077
  console.warn("Bound custom data does not match the one from the query results");
2035
2078
  isCorrect = false;
2036
- queryResultErrors.bind.eq = {
2037
- expected: queryResult.bind.custom_data,
2038
- received: boundData.custom_data,
2039
- message: "Bound custom data does not match the one from the query results"
2079
+ queryResultErrors.bind = {
2080
+ ...queryResultErrors.bind,
2081
+ eq: {
2082
+ expected: queryResult.bind.custom_data,
2083
+ received: boundData.custom_data,
2084
+ message: "Bound custom data does not match the one from the query results"
2085
+ }
2086
+ };
2087
+ }
2088
+ }
2089
+ return { isCorrect, queryResultErrors };
2090
+ }
2091
+ async checkSanctionsExclusionPublicInputs(queryResult, root, sanctionsBuilder) {
2092
+ const queryResultErrors = {};
2093
+ let isCorrect = true;
2094
+ if (queryResult.sanctions && queryResult.sanctions.passed) {
2095
+ const EXPECTED_ROOT = await sanctionsBuilder.getRoot();
2096
+ if (root !== BigInt(EXPECTED_ROOT)) {
2097
+ console.warn("Invalid sanctions registry root");
2098
+ isCorrect = false;
2099
+ queryResultErrors.sanctions = {
2100
+ ...queryResultErrors.sanctions,
2101
+ eq: {
2102
+ expected: EXPECTED_ROOT,
2103
+ received: root.toString(16),
2104
+ message: "Invalid sanctions registry root"
2105
+ }
2040
2106
  };
2041
2107
  }
2042
2108
  }
@@ -2057,25 +2123,7 @@ var ZKPassport = class {
2057
2123
  0,
2058
2124
  0
2059
2125
  );
2060
- let queryResultErrors = {
2061
- sig_check_dsc: {},
2062
- sig_check_id_data: {},
2063
- data_check_integrity: {},
2064
- disclose: {},
2065
- age: {},
2066
- birthdate: {},
2067
- expiry_date: {},
2068
- document_type: {},
2069
- issuing_country: {},
2070
- gender: {},
2071
- nationality: {},
2072
- firstname: {},
2073
- lastname: {},
2074
- fullname: {},
2075
- document_number: {},
2076
- outer: {},
2077
- bind: {}
2078
- };
2126
+ let queryResultErrors = {};
2079
2127
  const sortedProofs = proofs.sort((a, b) => {
2080
2128
  const proofOrder = [
2081
2129
  "sig_check_dsc",
@@ -2089,7 +2137,8 @@ var ZKPassport = class {
2089
2137
  "inclusion_check_nationality",
2090
2138
  "exclusion_check_issuing_country",
2091
2139
  "inclusion_check_issuing_country",
2092
- "bind"
2140
+ "bind",
2141
+ "exclusion_check_sanctions"
2093
2142
  ];
2094
2143
  const getIndex = (proof) => {
2095
2144
  const name = proof.name || "";
@@ -2127,18 +2176,20 @@ var ZKPassport = class {
2127
2176
  };
2128
2177
  const currentDate = (0, import_utils.getCurrentDateFromOuterProof)(proofData);
2129
2178
  const todayToCurrentDate = today.getTime() - currentDate.getTime();
2130
- const differenceInDays = validity ?? 180;
2131
- const expectedDifference = differenceInDays * 864e5;
2179
+ const expectedDifference = validity ? validity * 1e3 : DEFAULT_VALIDITY * 1e3;
2132
2180
  const actualDifference = today.getTime() - (today.getTime() - expectedDifference);
2133
2181
  if (todayToCurrentDate >= actualDifference) {
2134
2182
  console.warn(
2135
- `The date used to check the validity of the ID is older than ${differenceInDays} days. You can ask the user to rescan their ID or ask them to disclose their expiry date`
2183
+ `The date used to check the validity of the ID is older than the validity period`
2136
2184
  );
2137
2185
  isCorrect = false;
2138
- queryResultErrors.outer.date = {
2139
- expected: `Difference: ${differenceInDays} days`,
2140
- received: `Difference: ${Math.round(todayToCurrentDate / 864e5)} days`,
2141
- message: "The date used to check the validity of the ID is older than the validity period"
2186
+ queryResultErrors.outer = {
2187
+ ...queryResultErrors.outer,
2188
+ date: {
2189
+ expected: `Difference: ${validity} seconds`,
2190
+ received: `Difference: ${Math.round(todayToCurrentDate / 1e3)} seconds`,
2191
+ message: "The date used to check the validity of the ID is older than the validity period"
2192
+ }
2142
2193
  };
2143
2194
  }
2144
2195
  const paramCommitments = (0, import_utils.getParamCommitmentsFromOuterProof)(proofData);
@@ -2147,48 +2198,60 @@ var ZKPassport = class {
2147
2198
  if (keysInCommittedInputs.length !== paramCommitments.length) {
2148
2199
  console.warn("The proof does not verify all the requested conditions and information");
2149
2200
  isCorrect = false;
2150
- queryResultErrors.outer.commitment = {
2151
- expected: `Number of parameter commitments: ${paramCommitments.length}`,
2152
- received: `Number of disclosure proofs provided: ${keysInCommittedInputs.length}`,
2153
- message: "The proof does not verify all the requested conditions and information"
2201
+ queryResultErrors.outer = {
2202
+ ...queryResultErrors.outer,
2203
+ commitment: {
2204
+ expected: `Number of parameter commitments: ${paramCommitments.length}`,
2205
+ received: `Number of disclosure proofs provided: ${keysInCommittedInputs.length}`,
2206
+ message: "The proof does not verify all the requested conditions and information"
2207
+ }
2154
2208
  };
2155
2209
  }
2156
2210
  if (this.domain && (0, import_utils.getServiceScopeHash)(this.domain) !== (0, import_utils.getScopeFromOuterProof)(proofData)) {
2157
2211
  console.warn("The proof comes from a different domain than the one expected");
2158
2212
  isCorrect = false;
2159
- queryResultErrors.outer.scope = {
2160
- expected: `Scope: ${(0, import_utils.getServiceScopeHash)(this.domain).toString()}`,
2161
- received: `Scope: ${(0, import_utils.getScopeFromOuterProof)(proofData).toString()}`,
2162
- message: "The proof comes from a different domain than the one expected"
2213
+ queryResultErrors.outer = {
2214
+ ...queryResultErrors.outer,
2215
+ scope: {
2216
+ expected: `Scope: ${(0, import_utils.getServiceScopeHash)(this.domain).toString()}`,
2217
+ received: `Scope: ${(0, import_utils.getScopeFromOuterProof)(proofData).toString()}`,
2218
+ message: "The proof comes from a different domain than the one expected"
2219
+ }
2163
2220
  };
2164
2221
  }
2165
2222
  if (scope && (0, import_utils.getScopeHash)(scope) !== (0, import_utils.getSubscopeFromOuterProof)(proofData)) {
2166
2223
  console.warn("The proof uses a different scope than the one expected");
2167
2224
  isCorrect = false;
2168
- queryResultErrors.outer.scope = {
2169
- expected: `Scope: ${(0, import_utils.getScopeHash)(scope).toString()}`,
2170
- received: `Scope: ${(0, import_utils.getSubscopeFromOuterProof)(proofData).toString()}`,
2171
- message: "The proof uses a different scope than the one expected"
2225
+ queryResultErrors.outer = {
2226
+ ...queryResultErrors.outer,
2227
+ scope: {
2228
+ expected: `Scope: ${(0, import_utils.getScopeHash)(scope).toString()}`,
2229
+ received: `Scope: ${(0, import_utils.getSubscopeFromOuterProof)(proofData).toString()}`,
2230
+ message: "The proof uses a different scope than the one expected"
2231
+ }
2172
2232
  };
2173
2233
  }
2174
2234
  if (!!committedInputs?.compare_age) {
2175
2235
  const ageCommittedInputs = committedInputs?.compare_age;
2176
2236
  const ageParameterCommitment = isForEVM ? await (0, import_utils.getAgeEVMParameterCommitment)(
2177
- ageCommittedInputs.currentDate,
2237
+ ageCommittedInputs.currentDateTimestamp,
2178
2238
  ageCommittedInputs.minAge,
2179
2239
  ageCommittedInputs.maxAge
2180
2240
  ) : await (0, import_utils.getAgeParameterCommitment)(
2181
- ageCommittedInputs.currentDate,
2241
+ ageCommittedInputs.currentDateTimestamp,
2182
2242
  ageCommittedInputs.minAge,
2183
2243
  ageCommittedInputs.maxAge
2184
2244
  );
2185
2245
  if (!paramCommitments.includes(ageParameterCommitment)) {
2186
2246
  console.warn("This proof does not verify the age");
2187
2247
  isCorrect = false;
2188
- queryResultErrors.age.commitment = {
2189
- expected: `Age parameter commitment: ${ageParameterCommitment.toString()}`,
2190
- received: `Parameter commitments included: ${paramCommitments.join(", ")}`,
2191
- message: "This proof does not verify the age"
2248
+ queryResultErrors.age = {
2249
+ ...queryResultErrors.age,
2250
+ commitment: {
2251
+ expected: `Age parameter commitment: ${ageParameterCommitment.toString()}`,
2252
+ received: `Parameter commitments included: ${paramCommitments.join(", ")}`,
2253
+ message: "This proof does not verify the age"
2254
+ }
2192
2255
  };
2193
2256
  }
2194
2257
  const { isCorrect: isCorrectAge, queryResultErrors: queryResultErrorsAge } = this.checkAgePublicInputs(proof, queryResult);
@@ -2201,22 +2264,25 @@ var ZKPassport = class {
2201
2264
  const birthdateCommittedInputs = committedInputs?.compare_birthdate;
2202
2265
  const birthdateParameterCommitment = isForEVM ? await (0, import_utils.getDateEVMParameterCommitment)(
2203
2266
  import_utils.ProofType.BIRTHDATE,
2204
- birthdateCommittedInputs.currentDate,
2205
- birthdateCommittedInputs.minDate,
2206
- birthdateCommittedInputs.maxDate
2267
+ birthdateCommittedInputs.currentDateTimestamp,
2268
+ birthdateCommittedInputs.minDateTimestamp,
2269
+ birthdateCommittedInputs.maxDateTimestamp
2207
2270
  ) : await (0, import_utils.getDateParameterCommitment)(
2208
2271
  import_utils.ProofType.BIRTHDATE,
2209
- birthdateCommittedInputs.currentDate,
2210
- birthdateCommittedInputs.minDate,
2211
- birthdateCommittedInputs.maxDate
2272
+ birthdateCommittedInputs.currentDateTimestamp,
2273
+ birthdateCommittedInputs.minDateTimestamp,
2274
+ birthdateCommittedInputs.maxDateTimestamp
2212
2275
  );
2213
2276
  if (!paramCommitments.includes(birthdateParameterCommitment)) {
2214
2277
  console.warn("This proof does not verify the birthdate");
2215
2278
  isCorrect = false;
2216
- queryResultErrors.birthdate.commitment = {
2217
- expected: `Birthdate parameter commitment: ${birthdateParameterCommitment.toString()}`,
2218
- received: `Parameter commitments included: ${paramCommitments.join(", ")}`,
2219
- message: "This proof does not verify the birthdate"
2279
+ queryResultErrors.birthdate = {
2280
+ ...queryResultErrors.birthdate,
2281
+ commitment: {
2282
+ expected: `Birthdate parameter commitment: ${birthdateParameterCommitment.toString()}`,
2283
+ received: `Parameter commitments included: ${paramCommitments.join(", ")}`,
2284
+ message: "This proof does not verify the birthdate"
2285
+ }
2220
2286
  };
2221
2287
  }
2222
2288
  const { isCorrect: isCorrectBirthdate, queryResultErrors: queryResultErrorsBirthdate } = this.checkBirthdatePublicInputs(proof, queryResult);
@@ -2229,22 +2295,25 @@ var ZKPassport = class {
2229
2295
  const expiryCommittedInputs = committedInputs?.compare_expiry;
2230
2296
  const expiryParameterCommitment = isForEVM ? await (0, import_utils.getDateEVMParameterCommitment)(
2231
2297
  import_utils.ProofType.EXPIRY_DATE,
2232
- expiryCommittedInputs.currentDate,
2233
- expiryCommittedInputs.minDate,
2234
- expiryCommittedInputs.maxDate
2298
+ expiryCommittedInputs.currentDateTimestamp,
2299
+ expiryCommittedInputs.minDateTimestamp,
2300
+ expiryCommittedInputs.maxDateTimestamp
2235
2301
  ) : await (0, import_utils.getDateParameterCommitment)(
2236
2302
  import_utils.ProofType.EXPIRY_DATE,
2237
- expiryCommittedInputs.currentDate,
2238
- expiryCommittedInputs.minDate,
2239
- expiryCommittedInputs.maxDate
2303
+ expiryCommittedInputs.currentDateTimestamp,
2304
+ expiryCommittedInputs.minDateTimestamp,
2305
+ expiryCommittedInputs.maxDateTimestamp
2240
2306
  );
2241
2307
  if (!paramCommitments.includes(expiryParameterCommitment)) {
2242
2308
  console.warn("This proof does not verify the expiry date");
2243
2309
  isCorrect = false;
2244
- queryResultErrors.expiry_date.commitment = {
2245
- expected: `Expiry date parameter commitment: ${expiryParameterCommitment.toString()}`,
2246
- received: `Parameter commitments included: ${paramCommitments.join(", ")}`,
2247
- message: "This proof does not verify the expiry date"
2310
+ queryResultErrors.expiry_date = {
2311
+ ...queryResultErrors.expiry_date,
2312
+ commitment: {
2313
+ expected: `Expiry date parameter commitment: ${expiryParameterCommitment.toString()}`,
2314
+ received: `Parameter commitments included: ${paramCommitments.join(", ")}`,
2315
+ message: "This proof does not verify the expiry date"
2316
+ }
2248
2317
  };
2249
2318
  }
2250
2319
  const { isCorrect: isCorrectExpiryDate, queryResultErrors: queryResultErrorsExpiryDate } = this.checkExpiryDatePublicInputs(proof, queryResult);
@@ -2265,10 +2334,13 @@ var ZKPassport = class {
2265
2334
  if (!paramCommitments.includes(discloseParameterCommitment)) {
2266
2335
  console.warn("This proof does not verify any of the data disclosed");
2267
2336
  isCorrect = false;
2268
- queryResultErrors.disclose.commitment = {
2269
- expected: `Disclosure parameter commitment: ${discloseParameterCommitment.toString()}`,
2270
- received: `Parameter commitments included: ${paramCommitments.join(", ")}`,
2271
- message: "This proof does not verify any of the data disclosed"
2337
+ queryResultErrors.disclose = {
2338
+ ...queryResultErrors.disclose,
2339
+ commitment: {
2340
+ expected: `Disclosure parameter commitment: ${discloseParameterCommitment.toString()}`,
2341
+ received: `Parameter commitments included: ${paramCommitments.join(", ")}`,
2342
+ message: "This proof does not verify any of the data disclosed"
2343
+ }
2272
2344
  };
2273
2345
  }
2274
2346
  const { isCorrect: isCorrectDisclose, queryResultErrors: queryResultErrorsDisclose } = this.checkDiscloseBytesPublicInputs(proof, queryResult);
@@ -2289,10 +2361,13 @@ var ZKPassport = class {
2289
2361
  if (!paramCommitments.includes(inclusionCheckNationalityParameterCommitment)) {
2290
2362
  console.warn("This proof does not verify the inclusion of the nationality");
2291
2363
  isCorrect = false;
2292
- queryResultErrors.nationality.commitment = {
2293
- expected: `Nationality parameter commitment: ${inclusionCheckNationalityParameterCommitment.toString()}`,
2294
- received: `Parameter commitments included: ${paramCommitments.join(", ")}`,
2295
- message: "This proof does not verify the inclusion of the nationality"
2364
+ queryResultErrors.nationality = {
2365
+ ...queryResultErrors.nationality,
2366
+ commitment: {
2367
+ expected: `Nationality parameter commitment: ${inclusionCheckNationalityParameterCommitment.toString()}`,
2368
+ received: `Parameter commitments included: ${paramCommitments.join(", ")}`,
2369
+ message: "This proof does not verify the inclusion of the nationality"
2370
+ }
2296
2371
  };
2297
2372
  }
2298
2373
  const countryList = inclusionCheckNationalityCommittedInputs.countries;
@@ -2317,10 +2392,13 @@ var ZKPassport = class {
2317
2392
  if (!paramCommitments.includes(inclusionCheckIssuingCountryParameterCommitment)) {
2318
2393
  console.warn("This proof does not verify the inclusion of the issuing country");
2319
2394
  isCorrect = false;
2320
- queryResultErrors.issuing_country.commitment = {
2321
- expected: `Issuing country parameter commitment: ${inclusionCheckIssuingCountryParameterCommitment.toString()}`,
2322
- received: `Parameter commitments included: ${paramCommitments.join(", ")}`,
2323
- message: "This proof does not verify the inclusion of the issuing country"
2395
+ queryResultErrors.issuing_country = {
2396
+ ...queryResultErrors.issuing_country,
2397
+ commitment: {
2398
+ expected: `Issuing country parameter commitment: ${inclusionCheckIssuingCountryParameterCommitment.toString()}`,
2399
+ received: `Parameter commitments included: ${paramCommitments.join(", ")}`,
2400
+ message: "This proof does not verify the inclusion of the issuing country"
2401
+ }
2324
2402
  };
2325
2403
  }
2326
2404
  const countryList = inclusionCheckIssuingCountryCommittedInputs.countries;
@@ -2345,10 +2423,13 @@ var ZKPassport = class {
2345
2423
  if (!paramCommitments.includes(exclusionCheckNationalityParameterCommitment)) {
2346
2424
  console.warn("This proof does not verify the exclusion of the nationality");
2347
2425
  isCorrect = false;
2348
- queryResultErrors.nationality.commitment = {
2349
- expected: `Nationality parameter commitment: ${exclusionCheckNationalityParameterCommitment.toString()}`,
2350
- received: `Parameter commitments included: ${paramCommitments.join(", ")}`,
2351
- message: "This proof does not verify the exclusion of the nationality"
2426
+ queryResultErrors.nationality = {
2427
+ ...queryResultErrors.nationality,
2428
+ commitment: {
2429
+ expected: `Nationality parameter commitment: ${exclusionCheckNationalityParameterCommitment.toString()}`,
2430
+ received: `Parameter commitments included: ${paramCommitments.join(", ")}`,
2431
+ message: "This proof does not verify the exclusion of the nationality"
2432
+ }
2352
2433
  };
2353
2434
  }
2354
2435
  const countryList = exclusionCheckNationalityCommittedInputs.countries;
@@ -2373,10 +2454,13 @@ var ZKPassport = class {
2373
2454
  if (!paramCommitments.includes(exclusionCheckIssuingCountryParameterCommitment)) {
2374
2455
  console.warn("This proof does not verify the exclusion of the issuing country");
2375
2456
  isCorrect = false;
2376
- queryResultErrors.issuing_country.commitment = {
2377
- expected: `Issuing country parameter commitment: ${exclusionCheckIssuingCountryParameterCommitment.toString()}`,
2378
- received: `Parameter commitments included: ${paramCommitments.join(", ")}`,
2379
- message: "This proof does not verify the exclusion of the issuing country"
2457
+ queryResultErrors.issuing_country = {
2458
+ ...queryResultErrors.issuing_country,
2459
+ commitment: {
2460
+ expected: `Issuing country parameter commitment: ${exclusionCheckIssuingCountryParameterCommitment.toString()}`,
2461
+ received: `Parameter commitments included: ${paramCommitments.join(", ")}`,
2462
+ message: "This proof does not verify the exclusion of the issuing country"
2463
+ }
2380
2464
  };
2381
2465
  }
2382
2466
  const countryList = exclusionCheckIssuingCountryCommittedInputs.countries;
@@ -2395,10 +2479,13 @@ var ZKPassport = class {
2395
2479
  if (!paramCommitments.includes(bindParameterCommitment)) {
2396
2480
  console.warn("This proof does not verify the bound data");
2397
2481
  isCorrect = false;
2398
- queryResultErrors.bind.commitment = {
2399
- expected: `Bind parameter commitment: ${bindParameterCommitment.toString()}`,
2400
- received: `Parameter commitments included: ${paramCommitments.join(", ")}`,
2401
- message: "This proof does not verify the bound data"
2482
+ queryResultErrors.bind = {
2483
+ ...queryResultErrors.bind,
2484
+ commitment: {
2485
+ expected: `Bind parameter commitment: ${bindParameterCommitment.toString()}`,
2486
+ received: `Parameter commitments included: ${paramCommitments.join(", ")}`,
2487
+ message: "This proof does not verify the bound data"
2488
+ }
2402
2489
  };
2403
2490
  }
2404
2491
  const { isCorrect: isCorrectBind, queryResultErrors: queryResultErrorsBind } = this.checkBindPublicInputs(queryResult, bindCommittedInputs.data);
@@ -2407,6 +2494,35 @@ var ZKPassport = class {
2407
2494
  ...queryResultErrors,
2408
2495
  ...queryResultErrorsBind
2409
2496
  };
2497
+ } else if (!!committedInputs?.exclusion_check_sanctions) {
2498
+ const sanctionsBuilder = await import_utils.SanctionsBuilder.create();
2499
+ const exclusionCheckSanctionsCommittedInputs = committedInputs?.exclusion_check_sanctions;
2500
+ const exclusionCheckSanctionsParameterCommitment = isForEVM ? await sanctionsBuilder.getSanctionsEvmParameterCommitment() : await sanctionsBuilder.getSanctionsParameterCommitment();
2501
+ if (!paramCommitments.includes(exclusionCheckSanctionsParameterCommitment)) {
2502
+ console.warn("This proof does not verify the exclusion from the sanction lists");
2503
+ isCorrect = false;
2504
+ queryResultErrors.sanctions = {
2505
+ ...queryResultErrors.sanctions,
2506
+ commitment: {
2507
+ expected: `Sanctions parameter commitment: ${exclusionCheckSanctionsParameterCommitment.toString()}`,
2508
+ received: `Parameter commitments included: ${paramCommitments.join(", ")}`,
2509
+ message: "This proof does not verify the exclusion from the sanction lists"
2510
+ }
2511
+ };
2512
+ }
2513
+ const {
2514
+ isCorrect: isCorrectSanctionsExclusion,
2515
+ queryResultErrors: queryResultErrorsSanctionsExclusion
2516
+ } = await this.checkSanctionsExclusionPublicInputs(
2517
+ queryResult,
2518
+ BigInt(exclusionCheckSanctionsCommittedInputs.rootHash),
2519
+ sanctionsBuilder
2520
+ );
2521
+ isCorrect = isCorrect && isCorrectSanctionsExclusion;
2522
+ queryResultErrors = {
2523
+ ...queryResultErrors,
2524
+ ...queryResultErrorsSanctionsExclusion
2525
+ };
2410
2526
  }
2411
2527
  uniqueIdentifier = (0, import_utils.getNullifierFromOuterProof)(proofData).toString(10);
2412
2528
  } else if (proof.name?.startsWith("sig_check_dsc")) {
@@ -2432,10 +2548,13 @@ var ZKPassport = class {
2432
2548
  "Failed to check the link between the certificate signature and ID signature"
2433
2549
  );
2434
2550
  isCorrect = false;
2435
- queryResultErrors.sig_check_id_data.commitment = {
2436
- expected: `Commitment: ${commitmentOut?.toString() || "undefined"}`,
2437
- received: `Commitment: ${commitmentIn?.toString() || "undefined"}`,
2438
- message: "Failed to check the link between the certificate signature and ID signature"
2551
+ queryResultErrors.sig_check_id_data = {
2552
+ ...queryResultErrors.sig_check_id_data,
2553
+ commitment: {
2554
+ expected: `Commitment: ${commitmentOut?.toString() || "undefined"}`,
2555
+ received: `Commitment: ${commitmentIn?.toString() || "undefined"}`,
2556
+ message: "Failed to check the link between the certificate signature and ID signature"
2557
+ }
2439
2558
  };
2440
2559
  }
2441
2560
  commitmentOut = (0, import_utils.getCommitmentOutFromIDDataProof)(proofData);
@@ -2444,27 +2563,32 @@ var ZKPassport = class {
2444
2563
  if (commitmentIn !== commitmentOut) {
2445
2564
  console.warn("Failed to check the link between the ID signature and the data signed");
2446
2565
  isCorrect = false;
2447
- queryResultErrors.data_check_integrity.commitment = {
2448
- expected: `Commitment: ${commitmentOut?.toString() || "undefined"}`,
2449
- received: `Commitment: ${commitmentIn?.toString() || "undefined"}`,
2450
- message: "Failed to check the link between the ID signature and the data signed"
2566
+ queryResultErrors.data_check_integrity = {
2567
+ ...queryResultErrors.data_check_integrity,
2568
+ commitment: {
2569
+ expected: `Commitment: ${commitmentOut?.toString() || "undefined"}`,
2570
+ received: `Commitment: ${commitmentIn?.toString() || "undefined"}`,
2571
+ message: "Failed to check the link between the ID signature and the data signed"
2572
+ }
2451
2573
  };
2452
2574
  }
2453
2575
  commitmentOut = (0, import_utils.getCommitmentOutFromIntegrityProof)(proofData);
2454
2576
  const currentDate = (0, import_utils.getCurrentDateFromIntegrityProof)(proofData);
2455
2577
  const todayToCurrentDate = today.getTime() - currentDate.getTime();
2456
- const differenceInDays = validity ?? 180;
2457
- const expectedDifference = differenceInDays * 864e5;
2578
+ const expectedDifference = validity ? validity * 1e3 : DEFAULT_VALIDITY * 1e3;
2458
2579
  const actualDifference = today.getTime() - (today.getTime() - expectedDifference);
2459
2580
  if (todayToCurrentDate >= actualDifference) {
2460
2581
  console.warn(
2461
- `The date used to check the validity of the ID is older than ${differenceInDays} days. You can ask the user to rescan their ID or ask them to disclose their expiry date`
2582
+ `The date used to check the validity of the ID is older than the validity period`
2462
2583
  );
2463
2584
  isCorrect = false;
2464
- queryResultErrors.data_check_integrity.date = {
2465
- expected: `Difference: ${differenceInDays} days`,
2466
- received: `Difference: ${Math.round(todayToCurrentDate / 864e5)} days`,
2467
- message: "The date used to check the validity of the ID is older than the validity period"
2585
+ queryResultErrors.data_check_integrity = {
2586
+ ...queryResultErrors.data_check_integrity,
2587
+ date: {
2588
+ expected: `Difference: ${validity} seconds`,
2589
+ received: `Difference: ${Math.round(todayToCurrentDate / 1e3)} seconds`,
2590
+ message: "The date used to check the validity of the ID is older than the validity period"
2591
+ }
2468
2592
  };
2469
2593
  }
2470
2594
  } else if (proof.name === "disclose_bytes") {
@@ -2474,10 +2598,13 @@ var ZKPassport = class {
2474
2598
  "Failed to check the link between the validity of the ID and the data to disclose"
2475
2599
  );
2476
2600
  isCorrect = false;
2477
- queryResultErrors.disclose.commitment = {
2478
- expected: `Commitment: ${commitmentOut?.toString() || "undefined"}`,
2479
- received: `Commitment: ${commitmentIn?.toString() || "undefined"}`,
2480
- message: "Failed to check the link between the validity of the ID and the data to disclose"
2601
+ queryResultErrors.disclose = {
2602
+ ...queryResultErrors.disclose,
2603
+ commitment: {
2604
+ expected: `Commitment: ${commitmentOut?.toString() || "undefined"}`,
2605
+ received: `Commitment: ${commitmentIn?.toString() || "undefined"}`,
2606
+ message: "Failed to check the link between the validity of the ID and the data to disclose"
2607
+ }
2481
2608
  };
2482
2609
  }
2483
2610
  const paramCommitment = (0, import_utils.getParameterCommitmentFromDisclosureProof)(proofData);
@@ -2488,10 +2615,13 @@ var ZKPassport = class {
2488
2615
  if (paramCommitment !== calculatedParamCommitment) {
2489
2616
  console.warn("The disclosed data does not match the data committed by the proof");
2490
2617
  isCorrect = false;
2491
- queryResultErrors.disclose.commitment = {
2492
- expected: `Commitment: ${calculatedParamCommitment}`,
2493
- received: `Commitment: ${paramCommitment}`,
2494
- message: "The disclosed data does not match the data committed by the proof"
2618
+ queryResultErrors.disclose = {
2619
+ ...queryResultErrors.disclose,
2620
+ commitment: {
2621
+ expected: `Commitment: ${calculatedParamCommitment}`,
2622
+ received: `Commitment: ${paramCommitment}`,
2623
+ message: "The disclosed data does not match the data committed by the proof"
2624
+ }
2495
2625
  };
2496
2626
  }
2497
2627
  const { isCorrect: isCorrectScope, queryResultErrors: queryResultErrorsScope } = this.checkScopeFromDisclosureProof(proofData, queryResultErrors, "disclose", scope);
@@ -2515,16 +2645,19 @@ var ZKPassport = class {
2515
2645
  "Failed to check the link between the validity of the ID and the age derived from it"
2516
2646
  );
2517
2647
  isCorrect = false;
2518
- queryResultErrors.age.commitment = {
2519
- expected: `Commitment: ${commitmentOut}`,
2520
- received: `Commitment: ${commitmentIn}`,
2521
- message: "Failed to check the link between the validity of the ID and the age derived from it"
2648
+ queryResultErrors.age = {
2649
+ ...queryResultErrors.age,
2650
+ commitment: {
2651
+ expected: `Commitment: ${commitmentOut}`,
2652
+ received: `Commitment: ${commitmentIn}`,
2653
+ message: "Failed to check the link between the validity of the ID and the age derived from it"
2654
+ }
2522
2655
  };
2523
2656
  }
2524
2657
  const paramCommitment = (0, import_utils.getParameterCommitmentFromDisclosureProof)(proofData);
2525
2658
  const committedInputs = proof.committedInputs?.compare_age;
2526
2659
  const calculatedParamCommitment = await (0, import_utils.getAgeParameterCommitment)(
2527
- committedInputs.currentDate,
2660
+ committedInputs.currentDateTimestamp,
2528
2661
  committedInputs.minAge,
2529
2662
  committedInputs.maxAge
2530
2663
  );
@@ -2533,10 +2666,13 @@ var ZKPassport = class {
2533
2666
  "The conditions for the age check do not match the conditions checked by the proof"
2534
2667
  );
2535
2668
  isCorrect = false;
2536
- queryResultErrors.age.commitment = {
2537
- expected: `Commitment: ${calculatedParamCommitment}`,
2538
- received: `Commitment: ${paramCommitment}`,
2539
- message: "The conditions for the age check do not match the conditions checked by the proof"
2669
+ queryResultErrors.age = {
2670
+ ...queryResultErrors.age,
2671
+ commitment: {
2672
+ expected: `Commitment: ${calculatedParamCommitment}`,
2673
+ received: `Commitment: ${paramCommitment}`,
2674
+ message: "The conditions for the age check do not match the conditions checked by the proof"
2675
+ }
2540
2676
  };
2541
2677
  }
2542
2678
  const { isCorrect: isCorrectScope, queryResultErrors: queryResultErrorsScope } = this.checkScopeFromDisclosureProof(proofData, queryResultErrors, "age", scope);
@@ -2555,29 +2691,35 @@ var ZKPassport = class {
2555
2691
  "Failed to check the link between the validity of the ID and the birthdate derived from it"
2556
2692
  );
2557
2693
  isCorrect = false;
2558
- queryResultErrors.birthdate.commitment = {
2559
- expected: `Commitment: ${commitmentOut}`,
2560
- received: `Commitment: ${commitmentIn}`,
2561
- message: "Failed to check the link between the validity of the ID and the birthdate derived from it"
2694
+ queryResultErrors.birthdate = {
2695
+ ...queryResultErrors.birthdate,
2696
+ commitment: {
2697
+ expected: `Commitment: ${commitmentOut}`,
2698
+ received: `Commitment: ${commitmentIn}`,
2699
+ message: "Failed to check the link between the validity of the ID and the birthdate derived from it"
2700
+ }
2562
2701
  };
2563
2702
  }
2564
2703
  const paramCommitment = (0, import_utils.getParameterCommitmentFromDisclosureProof)(proofData);
2565
2704
  const committedInputs = proof.committedInputs?.compare_birthdate;
2566
2705
  const calculatedParamCommitment = await (0, import_utils.getDateParameterCommitment)(
2567
2706
  import_utils.ProofType.BIRTHDATE,
2568
- committedInputs.currentDate,
2569
- committedInputs.minDate,
2570
- committedInputs.maxDate
2707
+ committedInputs.currentDateTimestamp,
2708
+ committedInputs.minDateTimestamp,
2709
+ committedInputs.maxDateTimestamp
2571
2710
  );
2572
2711
  if (paramCommitment !== calculatedParamCommitment) {
2573
2712
  console.warn(
2574
2713
  "The conditions for the birthdate check do not match the conditions checked by the proof"
2575
2714
  );
2576
2715
  isCorrect = false;
2577
- queryResultErrors.birthdate.commitment = {
2578
- expected: `Commitment: ${calculatedParamCommitment}`,
2579
- received: `Commitment: ${paramCommitment}`,
2580
- message: "The conditions for the birthdate check do not match the conditions checked by the proof"
2716
+ queryResultErrors.birthdate = {
2717
+ ...queryResultErrors.birthdate,
2718
+ commitment: {
2719
+ expected: `Commitment: ${calculatedParamCommitment}`,
2720
+ received: `Commitment: ${paramCommitment}`,
2721
+ message: "The conditions for the birthdate check do not match the conditions checked by the proof"
2722
+ }
2581
2723
  };
2582
2724
  }
2583
2725
  const { isCorrect: isCorrectScope, queryResultErrors: queryResultErrorsScope } = this.checkScopeFromDisclosureProof(proofData, queryResultErrors, "birthdate", scope);
@@ -2596,29 +2738,35 @@ var ZKPassport = class {
2596
2738
  "Failed to check the link between the validity of the ID and its expiry date"
2597
2739
  );
2598
2740
  isCorrect = false;
2599
- queryResultErrors.expiry_date.commitment = {
2600
- expected: `Commitment: ${commitmentOut}`,
2601
- received: `Commitment: ${commitmentIn}`,
2602
- message: "Failed to check the link between the validity of the ID and its expiry date"
2741
+ queryResultErrors.expiry_date = {
2742
+ ...queryResultErrors.expiry_date,
2743
+ commitment: {
2744
+ expected: `Commitment: ${commitmentOut}`,
2745
+ received: `Commitment: ${commitmentIn}`,
2746
+ message: "Failed to check the link between the validity of the ID and its expiry date"
2747
+ }
2603
2748
  };
2604
2749
  }
2605
2750
  const paramCommitment = (0, import_utils.getParameterCommitmentFromDisclosureProof)(proofData);
2606
2751
  const committedInputs = proof.committedInputs?.compare_expiry;
2607
2752
  const calculatedParamCommitment = await (0, import_utils.getDateParameterCommitment)(
2608
2753
  import_utils.ProofType.EXPIRY_DATE,
2609
- committedInputs.currentDate,
2610
- committedInputs.minDate,
2611
- committedInputs.maxDate
2754
+ committedInputs.currentDateTimestamp,
2755
+ committedInputs.minDateTimestamp,
2756
+ committedInputs.maxDateTimestamp
2612
2757
  );
2613
2758
  if (paramCommitment !== calculatedParamCommitment) {
2614
2759
  console.warn(
2615
2760
  "The conditions for the expiry date check do not match the conditions checked by the proof"
2616
2761
  );
2617
2762
  isCorrect = false;
2618
- queryResultErrors.expiry_date.commitment = {
2619
- expected: `Commitment: ${calculatedParamCommitment}`,
2620
- received: `Commitment: ${paramCommitment}`,
2621
- message: "The conditions for the expiry date check do not match the conditions checked by the proof"
2763
+ queryResultErrors.expiry_date = {
2764
+ ...queryResultErrors.expiry_date,
2765
+ commitment: {
2766
+ expected: `Commitment: ${calculatedParamCommitment}`,
2767
+ received: `Commitment: ${paramCommitment}`,
2768
+ message: "The conditions for the expiry date check do not match the conditions checked by the proof"
2769
+ }
2622
2770
  };
2623
2771
  }
2624
2772
  const { isCorrect: isCorrectScope, queryResultErrors: queryResultErrorsScope } = this.checkScopeFromDisclosureProof(proofData, queryResultErrors, "expiry_date", scope);
@@ -2637,10 +2785,13 @@ var ZKPassport = class {
2637
2785
  "Failed to check the link between the validity of the ID and the nationality exclusion check"
2638
2786
  );
2639
2787
  isCorrect = false;
2640
- queryResultErrors.nationality.commitment = {
2641
- expected: `Commitment: ${commitmentOut}`,
2642
- received: `Commitment: ${commitmentIn}`,
2643
- message: "Failed to check the link between the validity of the ID and the nationality exclusion check"
2788
+ queryResultErrors.nationality = {
2789
+ ...queryResultErrors.nationality,
2790
+ commitment: {
2791
+ expected: `Commitment: ${commitmentOut}`,
2792
+ received: `Commitment: ${commitmentIn}`,
2793
+ message: "Failed to check the link between the validity of the ID and the nationality exclusion check"
2794
+ }
2644
2795
  };
2645
2796
  }
2646
2797
  const countryList = (proof.committedInputs?.exclusion_check_nationality).countries;
@@ -2655,10 +2806,13 @@ var ZKPassport = class {
2655
2806
  "The committed country list for the exclusion check does not match the one from the proof"
2656
2807
  );
2657
2808
  isCorrect = false;
2658
- queryResultErrors.nationality.commitment = {
2659
- expected: `Commitment: ${calculatedParamCommitment}`,
2660
- received: `Commitment: ${paramCommittment}`,
2661
- message: "The committed country list for the exclusion check does not match the one from the proof"
2809
+ queryResultErrors.nationality = {
2810
+ ...queryResultErrors.nationality,
2811
+ commitment: {
2812
+ expected: `Commitment: ${calculatedParamCommitment}`,
2813
+ received: `Commitment: ${paramCommittment}`,
2814
+ message: "The committed country list for the exclusion check does not match the one from the proof"
2815
+ }
2662
2816
  };
2663
2817
  }
2664
2818
  const { isCorrect: isCorrectScope, queryResultErrors: queryResultErrorsScope } = this.checkScopeFromDisclosureProof(proofData, queryResultErrors, "nationality", scope);
@@ -2680,10 +2834,13 @@ var ZKPassport = class {
2680
2834
  "Failed to check the link between the validity of the ID and the issuing country exclusion check"
2681
2835
  );
2682
2836
  isCorrect = false;
2683
- queryResultErrors.nationality.commitment = {
2684
- expected: `Commitment: ${commitmentOut}`,
2685
- received: `Commitment: ${commitmentIn}`,
2686
- message: "Failed to check the link between the validity of the ID and the issuing country exclusion check"
2837
+ queryResultErrors.nationality = {
2838
+ ...queryResultErrors.nationality,
2839
+ commitment: {
2840
+ expected: `Commitment: ${commitmentOut}`,
2841
+ received: `Commitment: ${commitmentIn}`,
2842
+ message: "Failed to check the link between the validity of the ID and the issuing country exclusion check"
2843
+ }
2687
2844
  };
2688
2845
  }
2689
2846
  const countryList = (proof.committedInputs?.exclusion_check_issuing_country).countries;
@@ -2698,10 +2855,13 @@ var ZKPassport = class {
2698
2855
  "The committed country list for the issuing country exclusion check does not match the one from the proof"
2699
2856
  );
2700
2857
  isCorrect = false;
2701
- queryResultErrors.issuing_country.commitment = {
2702
- expected: `Commitment: ${calculatedParamCommitment}`,
2703
- received: `Commitment: ${paramCommittment}`,
2704
- message: "The committed country list for the issuing country exclusion check does not match the one from the proof"
2858
+ queryResultErrors.issuing_country = {
2859
+ ...queryResultErrors.issuing_country,
2860
+ commitment: {
2861
+ expected: `Commitment: ${calculatedParamCommitment}`,
2862
+ received: `Commitment: ${paramCommittment}`,
2863
+ message: "The committed country list for the issuing country exclusion check does not match the one from the proof"
2864
+ }
2705
2865
  };
2706
2866
  }
2707
2867
  const { isCorrect: isCorrectScope, queryResultErrors: queryResultErrorsScope } = this.checkScopeFromDisclosureProof(proofData, queryResultErrors, "nationality", scope);
@@ -2723,10 +2883,13 @@ var ZKPassport = class {
2723
2883
  "Failed to check the link between the validity of the ID and the nationality inclusion check"
2724
2884
  );
2725
2885
  isCorrect = false;
2726
- queryResultErrors.nationality.commitment = {
2727
- expected: `Commitment: ${commitmentOut}`,
2728
- received: `Commitment: ${commitmentIn}`,
2729
- message: "Failed to check the link between the validity of the ID and the nationality inclusion check"
2886
+ queryResultErrors.nationality = {
2887
+ ...queryResultErrors.nationality,
2888
+ commitment: {
2889
+ expected: `Commitment: ${commitmentOut}`,
2890
+ received: `Commitment: ${commitmentIn}`,
2891
+ message: "Failed to check the link between the validity of the ID and the nationality inclusion check"
2892
+ }
2730
2893
  };
2731
2894
  }
2732
2895
  const countryList = (proof.committedInputs?.inclusion_check_nationality).countries;
@@ -2741,10 +2904,13 @@ var ZKPassport = class {
2741
2904
  "The committed country list for the nationality inclusion check does not match the one from the proof"
2742
2905
  );
2743
2906
  isCorrect = false;
2744
- queryResultErrors.nationality.commitment = {
2745
- expected: `Commitment: ${calculatedParamCommitment}`,
2746
- received: `Commitment: ${paramCommittment}`,
2747
- message: "The committed country list for the nationality inclusion check does not match the one from the proof"
2907
+ queryResultErrors.nationality = {
2908
+ ...queryResultErrors.nationality,
2909
+ commitment: {
2910
+ expected: `Commitment: ${calculatedParamCommitment}`,
2911
+ received: `Commitment: ${paramCommittment}`,
2912
+ message: "The committed country list for the nationality inclusion check does not match the one from the proof"
2913
+ }
2748
2914
  };
2749
2915
  }
2750
2916
  const { isCorrect: isCorrectScope, queryResultErrors: queryResultErrorsScope } = this.checkScopeFromDisclosureProof(proofData, queryResultErrors, "nationality", scope);
@@ -2766,10 +2932,13 @@ var ZKPassport = class {
2766
2932
  "Failed to check the link between the validity of the ID and the issuing country inclusion check"
2767
2933
  );
2768
2934
  isCorrect = false;
2769
- queryResultErrors.nationality.commitment = {
2770
- expected: `Commitment: ${commitmentOut}`,
2771
- received: `Commitment: ${commitmentIn}`,
2772
- message: "Failed to check the link between the validity of the ID and the issuing country inclusion check"
2935
+ queryResultErrors.nationality = {
2936
+ ...queryResultErrors.nationality,
2937
+ commitment: {
2938
+ expected: `Commitment: ${commitmentOut}`,
2939
+ received: `Commitment: ${commitmentIn}`,
2940
+ message: "Failed to check the link between the validity of the ID and the issuing country inclusion check"
2941
+ }
2773
2942
  };
2774
2943
  }
2775
2944
  const countryList = (proof.committedInputs?.inclusion_check_issuing_country).countries;
@@ -2784,10 +2953,13 @@ var ZKPassport = class {
2784
2953
  "The committed country list for the issuing country inclusion check does not match the one from the proof"
2785
2954
  );
2786
2955
  isCorrect = false;
2787
- queryResultErrors.issuing_country.commitment = {
2788
- expected: `Commitment: ${calculatedParamCommitment}`,
2789
- received: `Commitment: ${paramCommittment}`,
2790
- message: "The committed country list for the issuing country inclusion check does not match the one from the proof"
2956
+ queryResultErrors.issuing_country = {
2957
+ ...queryResultErrors.issuing_country,
2958
+ commitment: {
2959
+ expected: `Commitment: ${calculatedParamCommitment}`,
2960
+ received: `Commitment: ${paramCommittment}`,
2961
+ message: "The committed country list for the issuing country inclusion check does not match the one from the proof"
2962
+ }
2791
2963
  };
2792
2964
  }
2793
2965
  const { isCorrect: isCorrectScope, queryResultErrors: queryResultErrorsScope } = this.checkScopeFromDisclosureProof(proofData, queryResultErrors, "nationality", scope);
@@ -2811,10 +2983,13 @@ var ZKPassport = class {
2811
2983
  if (paramCommittment !== calculatedParamCommitment) {
2812
2984
  console.warn("The bound data does not match the one from the proof");
2813
2985
  isCorrect = false;
2814
- queryResultErrors.bind.commitment = {
2815
- expected: `Commitment: ${calculatedParamCommitment}`,
2816
- received: `Commitment: ${paramCommittment}`,
2817
- message: "The bound data does not match the one from the proof"
2986
+ queryResultErrors.bind = {
2987
+ ...queryResultErrors.bind,
2988
+ commitment: {
2989
+ expected: `Commitment: ${calculatedParamCommitment}`,
2990
+ received: `Commitment: ${paramCommittment}`,
2991
+ message: "The bound data does not match the one from the proof"
2992
+ }
2818
2993
  };
2819
2994
  }
2820
2995
  const { isCorrect: isCorrectBind, queryResultErrors: queryResultErrorsBind } = this.checkBindPublicInputs(queryResult, bindCommittedInputs.data);
@@ -2824,6 +2999,39 @@ var ZKPassport = class {
2824
2999
  ...queryResultErrorsBind
2825
3000
  };
2826
3001
  uniqueIdentifier = (0, import_utils.getNullifierFromDisclosureProof)(proofData).toString(10);
3002
+ } else if (proof.name === "exclusion_check_sanctions") {
3003
+ const sanctionsBuilder = await import_utils.SanctionsBuilder.create();
3004
+ const exclusionCheckSanctionsCommittedInputs = proof.committedInputs?.exclusion_check_sanctions;
3005
+ const calculatedParamCommitment = await sanctionsBuilder.getSanctionsParameterCommitment();
3006
+ const paramCommittment = (0, import_utils.getParameterCommitmentFromDisclosureProof)(proofData);
3007
+ if (paramCommittment !== calculatedParamCommitment) {
3008
+ console.warn(
3009
+ "The sanction lists check against do not match the sanction lists from the proof"
3010
+ );
3011
+ isCorrect = false;
3012
+ queryResultErrors.sanctions = {
3013
+ ...queryResultErrors.sanctions,
3014
+ commitment: {
3015
+ expected: `Commitment: ${calculatedParamCommitment.toString()}`,
3016
+ received: `Commitment: ${paramCommittment.toString()}`,
3017
+ message: "The sanction lists check against do not match the sanction lists from the proof"
3018
+ }
3019
+ };
3020
+ }
3021
+ const {
3022
+ isCorrect: isCorrectSanctionsExclusion,
3023
+ queryResultErrors: queryResultErrorsSanctionsExclusion
3024
+ } = await this.checkSanctionsExclusionPublicInputs(
3025
+ queryResult,
3026
+ BigInt(exclusionCheckSanctionsCommittedInputs.rootHash),
3027
+ sanctionsBuilder
3028
+ );
3029
+ isCorrect = isCorrect && isCorrectSanctionsExclusion;
3030
+ queryResultErrors = {
3031
+ ...queryResultErrors,
3032
+ ...queryResultErrorsSanctionsExclusion
3033
+ };
3034
+ uniqueIdentifier = (0, import_utils.getNullifierFromDisclosureProof)(proofData).toString(10);
2827
3035
  }
2828
3036
  }
2829
3037
  return { isCorrect, uniqueIdentifier, queryResultErrors };
@@ -2832,7 +3040,7 @@ var ZKPassport = class {
2832
3040
  * @notice Verify the proofs received from the mobile app.
2833
3041
  * @param proofs The proofs to verify.
2834
3042
  * @param queryResult The query result to verify against
2835
- * @param validity How many days ago should have the ID been last scanned by the user?
3043
+ * @param validity How many seconds ago the proof checking the expiry date of the ID should have been generated
2836
3044
  * @param scope Scope this request to a specific use case
2837
3045
  * @param devMode Whether to enable dev mode. This will allow you to verify mock proofs (i.e. from ZKR)
2838
3046
  * @param writingDirectory The directory (e.g. `./tmp`) where the necessary temporary artifacts for verification are written to.
@@ -2963,7 +3171,7 @@ var ZKPassport = class {
2963
3171
  }
2964
3172
  getSolidityVerifierParameters({
2965
3173
  proof,
2966
- validityPeriodInDays = 7,
3174
+ validityPeriodInSeconds = DEFAULT_VALIDITY,
2967
3175
  domain,
2968
3176
  scope,
2969
3177
  devMode = false
@@ -3005,19 +3213,19 @@ var ZKPassport = class {
3005
3213
  ).map((x) => x.toString(16).padStart(2, "0")).join("");
3006
3214
  } else if (circuitName === "compare_age_evm") {
3007
3215
  const value = proof.committedInputs[circuitName];
3008
- const currentDateBytes = Array.from(new TextEncoder().encode(value.currentDate));
3216
+ const currentDateBytes = Array.from((0, import_utils2.numberToBytesBE)(value.currentDateTimestamp, 8));
3009
3217
  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
3218
  } else if (circuitName === "compare_birthdate_evm") {
3011
3219
  const value = proof.committedInputs[circuitName];
3012
- const currentDateBytes = Array.from(new TextEncoder().encode(value.currentDate));
3013
- const minDateBytes = Array.from(new TextEncoder().encode(value.minDate));
3014
- const maxDateBytes = Array.from(new TextEncoder().encode(value.maxDate));
3220
+ const currentDateBytes = Array.from((0, import_utils2.numberToBytesBE)(value.currentDateTimestamp, 8));
3221
+ const minDateBytes = Array.from((0, import_utils2.numberToBytesBE)(value.minDateTimestamp, 8));
3222
+ const maxDateBytes = Array.from((0, import_utils2.numberToBytesBE)(value.maxDateTimestamp, 8));
3015
3223
  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
3224
  } else if (circuitName === "compare_expiry_evm") {
3017
3225
  const value = proof.committedInputs[circuitName];
3018
- const currentDateBytes = Array.from(new TextEncoder().encode(value.currentDate));
3019
- const minDateBytes = Array.from(new TextEncoder().encode(value.minDate));
3020
- const maxDateBytes = Array.from(new TextEncoder().encode(value.maxDate));
3226
+ const currentDateBytes = Array.from((0, import_utils2.numberToBytesBE)(value.currentDateTimestamp, 8));
3227
+ const minDateBytes = Array.from((0, import_utils2.numberToBytesBE)(value.minDateTimestamp, 8));
3228
+ const maxDateBytes = Array.from((0, import_utils2.numberToBytesBE)(value.maxDateTimestamp, 8));
3021
3229
  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
3230
  } else if (circuitName === "disclose_bytes_evm") {
3023
3231
  const value = proof.committedInputs[circuitName];
@@ -3064,7 +3272,7 @@ var ZKPassport = class {
3064
3272
  publicInputs: proofData.publicInputs,
3065
3273
  committedInputs: `0x${compressedCommittedInputs}`,
3066
3274
  committedInputCounts: committedInputCountsArray,
3067
- validityPeriodInDays,
3275
+ validityPeriodInSeconds,
3068
3276
  domain: domain ?? this.domain,
3069
3277
  scope: scope ?? "",
3070
3278
  devMode
@@ -3079,7 +3287,8 @@ var ZKPassport = class {
3079
3287
  "base64"
3080
3288
  );
3081
3289
  const pubkey = this.topicToPublicKey[requestId];
3082
- return `https://zkpassport.id/r?d=${this.domain}&t=${requestId}&c=${base64Config}&s=${base64Service}&p=${pubkey}&m=${this.topicToLocalConfig[requestId].mode}&v=${VERSION}`;
3290
+ const timestamp = Math.floor(Date.now() / 1e3) - this.topicToLocalConfig[requestId].validity;
3291
+ return `https://zkpassport.id/r?d=${this.domain}&t=${requestId}&c=${base64Config}&s=${base64Service}&p=${pubkey}&m=${this.topicToLocalConfig[requestId].mode}&v=${VERSION}&d=${timestamp}`;
3083
3292
  }
3084
3293
  /**
3085
3294
  * @notice Returns the URL of the request.