@zkpassport/sdk 0.8.0-beta.1 → 0.8.0-beta.3

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.
@@ -815,6 +815,7 @@ var import_bridge = require("@obsidion/bridge");
815
815
  var import_utils4 = require("@zkpassport/utils");
816
816
  var VERSION = "0.8.0";
817
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];
@@ -968,7 +972,7 @@ var ZKPassport = class {
968
972
  neededCircuits.push("bind");
969
973
  }
970
974
  if (this.topicToConfig[topic].sanctions) {
971
- neededCircuits.push("sanctions");
975
+ neededCircuits.push("exclusion_check_sanctions");
972
976
  }
973
977
  if (this.topicToConfig[topic].facematch) {
974
978
  neededCircuits.push("facematch");
@@ -1092,12 +1096,13 @@ var ZKPassport = class {
1092
1096
  };
1093
1097
  return this.getZkPassportRequest(topic);
1094
1098
  },
1095
- facematch: (mode = "strict") => {
1099
+ // TODO: Uncomment this when the facematch is ready
1100
+ /*facematch: (mode: FacematchMode = "regular") => {
1096
1101
  this.topicToConfig[topic].facematch = {
1097
- mode
1098
- };
1099
- return this.getZkPassportRequest(topic);
1100
- },
1102
+ mode,
1103
+ }
1104
+ return this.getZkPassportRequest(topic)
1105
+ },*/
1101
1106
  done: () => {
1102
1107
  this.setExpectedProofCount(topic);
1103
1108
  return {
@@ -1122,7 +1127,7 @@ var ZKPassport = class {
1122
1127
  * @param logo The logo of your service
1123
1128
  * @param purpose To explain what you want to do with the user's data
1124
1129
  * @param scope Scope this request to a specific use case
1125
- * @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
1126
1131
  * @param devMode Whether to enable dev mode. This will allow you to verify mock proofs (i.e. from ZKR)
1127
1132
  * @returns The query builder object.
1128
1133
  */
@@ -1157,8 +1162,8 @@ var ZKPassport = class {
1157
1162
  this.topicToProofs[topic] = [];
1158
1163
  this.topicToExpectedProofCount[topic] = 0;
1159
1164
  this.topicToLocalConfig[topic] = {
1160
- // Default to 6 months
1161
- validity: validity || 6 * 30,
1165
+ // Default to 7 days
1166
+ validity: validity || DEFAULT_VALIDITY,
1162
1167
  mode: mode || "fast",
1163
1168
  devMode: devMode || false
1164
1169
  };
@@ -1187,25 +1192,7 @@ var ZKPassport = class {
1187
1192
  return this.getZkPassportRequest(topic);
1188
1193
  }
1189
1194
  checkDiscloseBytesPublicInputs(proof, queryResult) {
1190
- const queryResultErrors = {
1191
- sig_check_dsc: {},
1192
- sig_check_id_data: {},
1193
- data_check_integrity: {},
1194
- disclose: {},
1195
- age: {},
1196
- birthdate: {},
1197
- expiry_date: {},
1198
- document_type: {},
1199
- issuing_country: {},
1200
- gender: {},
1201
- nationality: {},
1202
- firstname: {},
1203
- lastname: {},
1204
- fullname: {},
1205
- document_number: {},
1206
- outer: {},
1207
- bind: {}
1208
- };
1195
+ const queryResultErrors = {};
1209
1196
  let isCorrect = true;
1210
1197
  const disclosedDataPassport = import_utils.DisclosedData.fromDisclosedBytes(
1211
1198
  (proof.committedInputs?.disclose_bytes).disclosedBytes,
@@ -1219,19 +1206,25 @@ var ZKPassport = class {
1219
1206
  if (queryResult.document_type.eq && queryResult.document_type.eq.result && queryResult.document_type.eq.expected !== disclosedDataPassport.documentType) {
1220
1207
  console.warn("Document type does not match the expected document type");
1221
1208
  isCorrect = false;
1222
- queryResultErrors.document_type.eq = {
1223
- expected: `${queryResult.document_type.eq.expected}`,
1224
- received: `${disclosedDataPassport.documentType ?? disclosedDataIDCard.documentType}`,
1225
- 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
+ }
1226
1216
  };
1227
1217
  }
1228
1218
  if (queryResult.document_type.disclose?.result !== disclosedDataIDCard.documentType) {
1229
1219
  console.warn("Document type does not match the disclosed document type in query result");
1230
1220
  isCorrect = false;
1231
- queryResultErrors.document_type.disclose = {
1232
- expected: `${queryResult.document_type.disclose?.result}`,
1233
- received: `${disclosedDataIDCard.documentType ?? disclosedDataPassport.documentType}`,
1234
- 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
+ }
1235
1228
  };
1236
1229
  }
1237
1230
  }
@@ -1241,19 +1234,25 @@ var ZKPassport = class {
1241
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)) {
1242
1235
  console.warn("Birthdate does not match the expected birthdate");
1243
1236
  isCorrect = false;
1244
- queryResultErrors.birthdate.eq = {
1245
- expected: `${queryResult.birthdate.eq.expected.toISOString()}`,
1246
- received: `${birthdatePassport?.toISOString() ?? birthdateIDCard?.toISOString()}`,
1247
- 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
+ }
1248
1244
  };
1249
1245
  }
1250
1246
  if (queryResult.birthdate.disclose && !(0, import_utils.areDatesEqual)(queryResult.birthdate.disclose.result, birthdatePassport) && !(0, import_utils.areDatesEqual)(queryResult.birthdate.disclose.result, birthdateIDCard)) {
1251
1247
  console.warn("Birthdate does not match the disclosed birthdate in query result");
1252
1248
  isCorrect = false;
1253
- queryResultErrors.birthdate.disclose = {
1254
- expected: `${queryResult.birthdate.disclose.result.toISOString()}`,
1255
- received: `${birthdatePassport?.toISOString() ?? birthdateIDCard?.toISOString()}`,
1256
- 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
+ }
1257
1256
  };
1258
1257
  }
1259
1258
  }
@@ -1263,19 +1262,25 @@ var ZKPassport = class {
1263
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)) {
1264
1263
  console.warn("Expiry date does not match the expected expiry date");
1265
1264
  isCorrect = false;
1266
- queryResultErrors.expiry_date.eq = {
1267
- expected: `${queryResult.expiry_date.eq.expected.toISOString()}`,
1268
- received: `${expiryDatePassport?.toISOString() ?? expiryDateIDCard?.toISOString()}`,
1269
- 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
+ }
1270
1272
  };
1271
1273
  }
1272
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)) {
1273
1275
  console.warn("Expiry date does not match the disclosed expiry date in query result");
1274
1276
  isCorrect = false;
1275
- queryResultErrors.expiry_date.disclose = {
1276
- expected: `${queryResult.expiry_date.disclose.result.toISOString()}`,
1277
- received: `${expiryDatePassport?.toISOString() ?? expiryDateIDCard?.toISOString()}`,
1278
- 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
+ }
1279
1284
  };
1280
1285
  }
1281
1286
  }
@@ -1285,19 +1290,25 @@ var ZKPassport = class {
1285
1290
  if (queryResult.nationality.eq && queryResult.nationality.eq.result && queryResult.nationality.eq.expected !== nationalityPassport && queryResult.nationality.eq.expected !== nationalityIDCard) {
1286
1291
  console.warn("Nationality does not match the expected nationality");
1287
1292
  isCorrect = false;
1288
- queryResultErrors.nationality.eq = {
1289
- expected: `${queryResult.nationality.eq.expected}`,
1290
- received: `${nationalityPassport ?? nationalityIDCard}`,
1291
- 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
+ }
1292
1300
  };
1293
1301
  }
1294
1302
  if (queryResult.nationality.disclose && queryResult.nationality.disclose.result !== nationalityPassport && queryResult.nationality.disclose.result !== nationalityIDCard) {
1295
1303
  console.warn("Nationality does not match the disclosed nationality in query result");
1296
1304
  isCorrect = false;
1297
- queryResultErrors.nationality.disclose = {
1298
- expected: `${queryResult.nationality.disclose.result}`,
1299
- received: `${nationalityPassport ?? nationalityIDCard}`,
1300
- 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
+ }
1301
1312
  };
1302
1313
  }
1303
1314
  }
@@ -1307,19 +1318,25 @@ var ZKPassport = class {
1307
1318
  if (queryResult.document_number.eq && queryResult.document_number.eq.result && queryResult.document_number.eq.expected !== documentNumberPassport && queryResult.document_number.eq.expected !== documentNumberIDCard) {
1308
1319
  console.warn("Document number does not match the expected document number");
1309
1320
  isCorrect = false;
1310
- queryResultErrors.document_number.eq = {
1311
- expected: `${queryResult.document_number.eq.expected}`,
1312
- received: `${documentNumberPassport ?? documentNumberIDCard}`,
1313
- 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
+ }
1314
1328
  };
1315
1329
  }
1316
1330
  if (queryResult.document_number.disclose && queryResult.document_number.disclose.result !== documentNumberPassport && queryResult.document_number.disclose.result !== documentNumberIDCard) {
1317
1331
  console.warn("Document number does not match the disclosed document number in query result");
1318
1332
  isCorrect = false;
1319
- queryResultErrors.document_number.disclose = {
1320
- expected: `${queryResult.document_number.disclose.result}`,
1321
- received: `${documentNumberPassport ?? documentNumberIDCard}`,
1322
- 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
+ }
1323
1340
  };
1324
1341
  }
1325
1342
  }
@@ -1329,19 +1346,25 @@ var ZKPassport = class {
1329
1346
  if (queryResult.gender.eq && queryResult.gender.eq.result && queryResult.gender.eq.expected !== genderPassport && queryResult.gender.eq.expected !== genderIDCard) {
1330
1347
  console.warn("Gender does not match the expected gender");
1331
1348
  isCorrect = false;
1332
- queryResultErrors.gender.eq = {
1333
- expected: `${queryResult.gender.eq.expected}`,
1334
- received: `${genderPassport ?? genderIDCard}`,
1335
- 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
+ }
1336
1356
  };
1337
1357
  }
1338
1358
  if (queryResult.gender.disclose && queryResult.gender.disclose.result !== genderPassport && queryResult.gender.disclose.result !== genderIDCard) {
1339
1359
  console.warn("Gender does not match the disclosed gender in query result");
1340
1360
  isCorrect = false;
1341
- queryResultErrors.gender.disclose = {
1342
- expected: `${queryResult.gender.disclose.result}`,
1343
- received: `${genderPassport ?? genderIDCard}`,
1344
- 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
+ }
1345
1368
  };
1346
1369
  }
1347
1370
  }
@@ -1351,19 +1374,25 @@ var ZKPassport = class {
1351
1374
  if (queryResult.issuing_country.eq && queryResult.issuing_country.eq.result && queryResult.issuing_country.eq.expected !== issuingCountryPassport && queryResult.issuing_country.eq.expected !== issuingCountryIDCard) {
1352
1375
  console.warn("Issuing country does not match the expected issuing country");
1353
1376
  isCorrect = false;
1354
- queryResultErrors.issuing_country.eq = {
1355
- expected: `${queryResult.issuing_country.eq.expected}`,
1356
- received: `${issuingCountryPassport ?? issuingCountryIDCard}`,
1357
- 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
+ }
1358
1384
  };
1359
1385
  }
1360
1386
  if (queryResult.issuing_country.disclose && queryResult.issuing_country.disclose.result !== issuingCountryPassport && queryResult.issuing_country.disclose.result !== issuingCountryIDCard) {
1361
1387
  console.warn("Issuing country does not match the disclosed issuing country in query result");
1362
1388
  isCorrect = false;
1363
- queryResultErrors.issuing_country.disclose = {
1364
- expected: `${queryResult.issuing_country.disclose.result}`,
1365
- received: `${issuingCountryPassport ?? issuingCountryIDCard}`,
1366
- 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
+ }
1367
1396
  };
1368
1397
  }
1369
1398
  }
@@ -1373,19 +1402,25 @@ var ZKPassport = class {
1373
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()) {
1374
1403
  console.warn("Fullname does not match the expected fullname");
1375
1404
  isCorrect = false;
1376
- queryResultErrors.fullname.eq = {
1377
- expected: `${queryResult.fullname.eq.expected}`,
1378
- received: `${fullnamePassport ?? fullnameIDCard}`,
1379
- 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
+ }
1380
1412
  };
1381
1413
  }
1382
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()) {
1383
1415
  console.warn("Fullname does not match the disclosed fullname in query result");
1384
1416
  isCorrect = false;
1385
- queryResultErrors.fullname.disclose = {
1386
- expected: `${queryResult.fullname.disclose.result}`,
1387
- received: `${fullnamePassport ?? fullnameIDCard}`,
1388
- 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
+ }
1389
1424
  };
1390
1425
  }
1391
1426
  }
@@ -1395,19 +1430,25 @@ var ZKPassport = class {
1395
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()) {
1396
1431
  console.warn("Firstname does not match the expected firstname");
1397
1432
  isCorrect = false;
1398
- queryResultErrors.firstname.eq = {
1399
- expected: `${queryResult.firstname.eq.expected}`,
1400
- received: `${firstnamePassport ?? firstnameIDCard}`,
1401
- 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
+ }
1402
1440
  };
1403
1441
  }
1404
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()) {
1405
1443
  console.warn("Firstname does not match the disclosed firstname in query result");
1406
1444
  isCorrect = false;
1407
- queryResultErrors.firstname.disclose = {
1408
- expected: `${queryResult.firstname.disclose.result}`,
1409
- received: `${firstnamePassport ?? firstnameIDCard}`,
1410
- 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
+ }
1411
1452
  };
1412
1453
  }
1413
1454
  }
@@ -1417,44 +1458,32 @@ var ZKPassport = class {
1417
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()) {
1418
1459
  console.warn("Lastname does not match the expected lastname");
1419
1460
  isCorrect = false;
1420
- queryResultErrors.lastname.eq = {
1421
- expected: `${queryResult.lastname.eq.expected}`,
1422
- received: `${lastnamePassport ?? lastnameIDCard}`,
1423
- 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
+ }
1424
1468
  };
1425
1469
  }
1426
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()) {
1427
1471
  console.warn("Lastname does not match the disclosed lastname in query result");
1428
1472
  isCorrect = false;
1429
- queryResultErrors.lastname.disclose = {
1430
- expected: `${queryResult.lastname.disclose.result}`,
1431
- received: `${lastnamePassport ?? lastnameIDCard}`,
1432
- 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
+ }
1433
1480
  };
1434
1481
  }
1435
1482
  }
1436
1483
  return { isCorrect, queryResultErrors };
1437
1484
  }
1438
1485
  checkAgePublicInputs(proof, queryResult) {
1439
- const queryResultErrors = {
1440
- sig_check_dsc: {},
1441
- sig_check_id_data: {},
1442
- data_check_integrity: {},
1443
- disclose: {},
1444
- age: {},
1445
- birthdate: {},
1446
- expiry_date: {},
1447
- document_type: {},
1448
- issuing_country: {},
1449
- gender: {},
1450
- nationality: {},
1451
- firstname: {},
1452
- lastname: {},
1453
- fullname: {},
1454
- document_number: {},
1455
- outer: {},
1456
- bind: {}
1457
- };
1486
+ const queryResultErrors = {};
1458
1487
  let isCorrect = true;
1459
1488
  const currentTime = /* @__PURE__ */ new Date();
1460
1489
  const today = new Date(
@@ -1476,64 +1505,85 @@ var ZKPassport = class {
1476
1505
  if (queryResult.age.gte && queryResult.age.gte.result && minAge !== queryResult.age.gte.expected) {
1477
1506
  console.warn("Age is not greater than or equal to the expected age");
1478
1507
  isCorrect = false;
1479
- queryResultErrors.age.gte = {
1480
- expected: queryResult.age.gte.expected,
1481
- received: minAge,
1482
- 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
+ }
1483
1515
  };
1484
1516
  }
1485
1517
  if (queryResult.age.lt && queryResult.age.lt.result && maxAge !== queryResult.age.lt.expected) {
1486
1518
  console.warn("Age is not less than the expected age");
1487
1519
  isCorrect = false;
1488
- queryResultErrors.age.lt = {
1489
- expected: queryResult.age.lt.expected,
1490
- received: maxAge,
1491
- 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
+ }
1492
1527
  };
1493
1528
  }
1494
1529
  if (queryResult.age.range) {
1495
1530
  if (queryResult.age.range.result && (minAge !== queryResult.age.range.expected[0] || maxAge !== queryResult.age.range.expected[1])) {
1496
1531
  console.warn("Age is not in the expected range");
1497
1532
  isCorrect = false;
1498
- queryResultErrors.age.range = {
1499
- expected: queryResult.age.range.expected,
1500
- received: [minAge, maxAge],
1501
- 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
+ }
1502
1540
  };
1503
1541
  }
1504
1542
  }
1505
1543
  if (!queryResult.age.lt && !queryResult.age.range && maxAge != 0) {
1506
1544
  console.warn("Maximum age should be equal to 0");
1507
1545
  isCorrect = false;
1508
- queryResultErrors.age.disclose = {
1509
- expected: 0,
1510
- received: maxAge,
1511
- 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
+ }
1512
1553
  };
1513
1554
  }
1514
1555
  if (!queryResult.age.gte && !queryResult.age.range && minAge != 0) {
1515
1556
  console.warn("Minimum age should be equal to 0");
1516
1557
  isCorrect = false;
1517
- queryResultErrors.age.disclose = {
1518
- expected: 0,
1519
- received: minAge,
1520
- 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
+ }
1521
1565
  };
1522
1566
  }
1523
1567
  if (queryResult.age.disclose && (queryResult.age.disclose.result !== minAge || queryResult.age.disclose.result !== maxAge)) {
1524
1568
  console.warn("Age does not match the disclosed age in query result");
1525
1569
  isCorrect = false;
1526
- queryResultErrors.age.disclose = {
1527
- expected: `${minAge}`,
1528
- received: `${queryResult.age.disclose.result}`,
1529
- 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
+ }
1530
1577
  };
1531
1578
  }
1532
1579
  } else {
1533
1580
  console.warn("Age is not set in the query result");
1534
1581
  isCorrect = false;
1535
- queryResultErrors.age.disclose = {
1536
- 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
+ }
1537
1587
  };
1538
1588
  }
1539
1589
  const currentDate = (0, import_utils.getCurrentDateFromCommittedInputs)(
@@ -1542,34 +1592,19 @@ var ZKPassport = class {
1542
1592
  if (!(0, import_utils.areDatesEqual)(currentDate, today) && !(0, import_utils.areDatesEqual)(currentDate, today.getTime() - 864e5)) {
1543
1593
  console.warn("Current date in the proof is too old");
1544
1594
  isCorrect = false;
1545
- queryResultErrors.age.disclose = {
1546
- expected: `${today.toISOString()}`,
1547
- received: `${currentDate.toISOString()}`,
1548
- 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
+ }
1549
1602
  };
1550
1603
  }
1551
1604
  return { isCorrect, queryResultErrors };
1552
1605
  }
1553
1606
  checkBirthdatePublicInputs(proof, queryResult) {
1554
- const queryResultErrors = {
1555
- sig_check_dsc: {},
1556
- sig_check_id_data: {},
1557
- data_check_integrity: {},
1558
- disclose: {},
1559
- age: {},
1560
- birthdate: {},
1561
- expiry_date: {},
1562
- document_type: {},
1563
- issuing_country: {},
1564
- gender: {},
1565
- nationality: {},
1566
- firstname: {},
1567
- lastname: {},
1568
- fullname: {},
1569
- document_number: {},
1570
- outer: {},
1571
- bind: {}
1572
- };
1607
+ const queryResultErrors = {};
1573
1608
  let isCorrect = true;
1574
1609
  const currentTime = /* @__PURE__ */ new Date();
1575
1610
  const today = new Date(
@@ -1580,10 +1615,10 @@ var ZKPassport = class {
1580
1615
  0,
1581
1616
  0
1582
1617
  );
1583
- const minDate = (0, import_utils.getMinDateFromCommittedInputs)(
1618
+ const minDate = (0, import_utils.getBirthdateMinDateTimestamp)(
1584
1619
  proof.committedInputs?.compare_birthdate
1585
1620
  );
1586
- const maxDate = (0, import_utils.getMaxDateFromCommittedInputs)(
1621
+ const maxDate = (0, import_utils.getBirthdateMaxDateTimestamp)(
1587
1622
  proof.committedInputs?.compare_birthdate
1588
1623
  );
1589
1624
  const currentDate = (0, import_utils.getCurrentDateFromCommittedInputs)(
@@ -1593,88 +1628,91 @@ var ZKPassport = class {
1593
1628
  if (queryResult.birthdate.gte && queryResult.birthdate.gte.result && minDate !== queryResult.birthdate.gte.expected) {
1594
1629
  console.warn("Birthdate is not greater than or equal to the expected birthdate");
1595
1630
  isCorrect = false;
1596
- queryResultErrors.birthdate.gte = {
1597
- expected: queryResult.birthdate.gte.expected,
1598
- received: minDate,
1599
- 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
+ }
1600
1638
  };
1601
1639
  }
1602
1640
  if (queryResult.birthdate.lte && queryResult.birthdate.lte.result && maxDate !== queryResult.birthdate.lte.expected) {
1603
1641
  console.warn("Birthdate is not less than the expected birthdate");
1604
1642
  isCorrect = false;
1605
- queryResultErrors.birthdate.lte = {
1606
- expected: queryResult.birthdate.lte.expected,
1607
- received: maxDate,
1608
- 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
+ }
1609
1650
  };
1610
1651
  }
1611
1652
  if (queryResult.birthdate.range) {
1612
1653
  if (queryResult.birthdate.range.result && (minDate !== queryResult.birthdate.range.expected[0] || maxDate !== queryResult.birthdate.range.expected[1])) {
1613
1654
  console.warn("Birthdate is not in the expected range");
1614
1655
  isCorrect = false;
1615
- queryResultErrors.birthdate.range = {
1616
- expected: queryResult.birthdate.range.expected,
1617
- received: [minDate, maxDate],
1618
- 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
+ }
1619
1663
  };
1620
1664
  }
1621
1665
  }
1622
1666
  if (!queryResult.birthdate.lte && !queryResult.birthdate.range && !(0, import_utils.areDatesEqual)(maxDate, DEFAULT_DATE_VALUE)) {
1623
1667
  console.warn("Maximum birthdate should be equal to default date value");
1624
1668
  isCorrect = false;
1625
- queryResultErrors.birthdate.disclose = {
1626
- expected: `${DEFAULT_DATE_VALUE.toISOString()}`,
1627
- received: `${maxDate.toISOString()}`,
1628
- 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
+ }
1629
1676
  };
1630
1677
  }
1631
1678
  if (!queryResult.birthdate.gte && !queryResult.birthdate.range && !(0, import_utils.areDatesEqual)(minDate, DEFAULT_DATE_VALUE)) {
1632
1679
  console.warn("Minimum birthdate should be equal to default date value");
1633
1680
  isCorrect = false;
1634
- queryResultErrors.birthdate.disclose = {
1635
- expected: `${DEFAULT_DATE_VALUE.toISOString()}`,
1636
- received: `${minDate.toISOString()}`,
1637
- 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
+ }
1638
1688
  };
1639
1689
  }
1640
1690
  } else {
1641
1691
  console.warn("Birthdate is not set in the query result");
1642
1692
  isCorrect = false;
1643
- queryResultErrors.birthdate.disclose = {
1644
- 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
+ }
1645
1698
  };
1646
1699
  }
1647
1700
  if (!(0, import_utils.areDatesEqual)(currentDate, today) && !(0, import_utils.areDatesEqual)(currentDate, today.getTime() - 864e5)) {
1648
1701
  console.warn("Current date in the proof is too old");
1649
1702
  isCorrect = false;
1650
- queryResultErrors.age.disclose = {
1651
- expected: `${today.toISOString()}`,
1652
- received: `${currentDate.toISOString()}`,
1653
- 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
+ }
1654
1710
  };
1655
1711
  }
1656
1712
  return { isCorrect, queryResultErrors };
1657
1713
  }
1658
1714
  checkExpiryDatePublicInputs(proof, queryResult) {
1659
- const queryResultErrors = {
1660
- sig_check_dsc: {},
1661
- sig_check_id_data: {},
1662
- data_check_integrity: {},
1663
- disclose: {},
1664
- age: {},
1665
- birthdate: {},
1666
- expiry_date: {},
1667
- document_type: {},
1668
- issuing_country: {},
1669
- gender: {},
1670
- nationality: {},
1671
- firstname: {},
1672
- lastname: {},
1673
- fullname: {},
1674
- document_number: {},
1675
- outer: {},
1676
- bind: {}
1677
- };
1715
+ const queryResultErrors = {};
1678
1716
  let isCorrect = true;
1679
1717
  const currentTime = /* @__PURE__ */ new Date();
1680
1718
  const today = new Date(
@@ -1698,104 +1736,113 @@ var ZKPassport = class {
1698
1736
  if (queryResult.expiry_date.gte && queryResult.expiry_date.gte.result && minDate !== queryResult.expiry_date.gte.expected) {
1699
1737
  console.warn("Expiry date is not greater than or equal to the expected expiry date");
1700
1738
  isCorrect = false;
1701
- queryResultErrors.expiry_date.gte = {
1702
- expected: queryResult.expiry_date.gte.expected,
1703
- received: minDate,
1704
- 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
+ }
1705
1746
  };
1706
1747
  }
1707
1748
  if (queryResult.expiry_date.lte && queryResult.expiry_date.lte.result && maxDate !== queryResult.expiry_date.lte.expected) {
1708
1749
  console.warn("Expiry date is not less than the expected expiry date");
1709
1750
  isCorrect = false;
1710
- queryResultErrors.expiry_date.lte = {
1711
- expected: queryResult.expiry_date.lte.expected,
1712
- received: maxDate,
1713
- 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
+ }
1714
1758
  };
1715
1759
  }
1716
1760
  if (queryResult.expiry_date.range) {
1717
1761
  if (queryResult.expiry_date.range.result && (minDate !== queryResult.expiry_date.range.expected[0] || maxDate !== queryResult.expiry_date.range.expected[1])) {
1718
1762
  console.warn("Expiry date is not in the expected range");
1719
1763
  isCorrect = false;
1720
- queryResultErrors.expiry_date.range = {
1721
- expected: queryResult.expiry_date.range.expected,
1722
- received: [minDate, maxDate],
1723
- 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
+ }
1724
1771
  };
1725
1772
  }
1726
1773
  }
1727
1774
  if (!queryResult.expiry_date.lte && !queryResult.expiry_date.range && !(0, import_utils.areDatesEqual)(maxDate, DEFAULT_DATE_VALUE)) {
1728
1775
  console.warn("Maximum expiry date should be equal to default date value");
1729
1776
  isCorrect = false;
1730
- queryResultErrors.expiry_date.disclose = {
1731
- expected: `${DEFAULT_DATE_VALUE.toISOString()}`,
1732
- received: `${maxDate.toISOString()}`,
1733
- 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
+ }
1734
1784
  };
1735
1785
  }
1736
1786
  if (!queryResult.expiry_date.gte && !queryResult.expiry_date.range && !(0, import_utils.areDatesEqual)(minDate, DEFAULT_DATE_VALUE)) {
1737
1787
  console.warn("Minimum expiry date should be equal to default date value");
1738
1788
  isCorrect = false;
1739
- queryResultErrors.expiry_date.disclose = {
1740
- expected: `${DEFAULT_DATE_VALUE.toISOString()}`,
1741
- received: `${minDate.toISOString()}`,
1742
- 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
+ }
1743
1796
  };
1744
1797
  }
1745
1798
  } else {
1746
1799
  console.warn("Expiry date is not set in the query result");
1747
1800
  isCorrect = false;
1748
- queryResultErrors.expiry_date.disclose = {
1749
- 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
+ }
1750
1806
  };
1751
1807
  }
1752
1808
  if (!(0, import_utils.areDatesEqual)(currentDate, today) && !(0, import_utils.areDatesEqual)(currentDate, today.getTime() - 864e5)) {
1753
1809
  console.warn("Current date in the proof is too old");
1754
1810
  isCorrect = false;
1755
- queryResultErrors.age.disclose = {
1756
- expected: `${today.toISOString()}`,
1757
- received: `${currentDate.toISOString()}`,
1758
- 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
+ }
1759
1818
  };
1760
1819
  }
1761
1820
  return { isCorrect, queryResultErrors };
1762
1821
  }
1763
1822
  checkNationalityExclusionPublicInputs(queryResult, countryList) {
1764
- const queryResultErrors = {
1765
- sig_check_dsc: {},
1766
- sig_check_id_data: {},
1767
- data_check_integrity: {},
1768
- disclose: {},
1769
- age: {},
1770
- birthdate: {},
1771
- expiry_date: {},
1772
- document_type: {},
1773
- issuing_country: {},
1774
- gender: {},
1775
- nationality: {},
1776
- firstname: {},
1777
- lastname: {},
1778
- fullname: {},
1779
- document_number: {},
1780
- outer: {},
1781
- bind: {}
1782
- };
1823
+ const queryResultErrors = {};
1783
1824
  let isCorrect = true;
1784
1825
  if (queryResult.nationality && queryResult.nationality.out && queryResult.nationality.out.result) {
1785
1826
  if (!queryResult.nationality.out.expected?.every((country) => countryList.includes(country))) {
1786
1827
  console.warn("Nationality exclusion list does not match the one from the query results");
1787
1828
  isCorrect = false;
1788
- queryResultErrors.nationality.out = {
1789
- expected: queryResult.nationality.out.expected,
1790
- received: countryList,
1791
- 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
+ }
1792
1836
  };
1793
1837
  }
1794
1838
  } else if (!queryResult.nationality || !queryResult.nationality.out) {
1795
1839
  console.warn("Nationality exclusion is not set in the query result");
1796
1840
  isCorrect = false;
1797
- queryResultErrors.nationality.out = {
1798
- 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
+ }
1799
1846
  };
1800
1847
  }
1801
1848
  for (let i = 1; i < countryList.length; i++) {
@@ -1804,49 +1851,40 @@ var ZKPassport = class {
1804
1851
  "The nationality exclusion list has not been sorted, and thus the proof cannot be trusted"
1805
1852
  );
1806
1853
  isCorrect = false;
1807
- queryResultErrors.nationality.out = {
1808
- 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
+ }
1809
1859
  };
1810
1860
  }
1811
1861
  }
1812
1862
  return { isCorrect, queryResultErrors };
1813
1863
  }
1814
1864
  checkIssuingCountryExclusionPublicInputs(queryResult, countryList) {
1815
- const queryResultErrors = {
1816
- sig_check_dsc: {},
1817
- sig_check_id_data: {},
1818
- data_check_integrity: {},
1819
- disclose: {},
1820
- age: {},
1821
- birthdate: {},
1822
- expiry_date: {},
1823
- document_type: {},
1824
- issuing_country: {},
1825
- gender: {},
1826
- nationality: {},
1827
- firstname: {},
1828
- lastname: {},
1829
- fullname: {},
1830
- document_number: {},
1831
- outer: {},
1832
- bind: {}
1833
- };
1865
+ const queryResultErrors = {};
1834
1866
  let isCorrect = true;
1835
1867
  if (queryResult.issuing_country && queryResult.issuing_country.out && queryResult.issuing_country.out.result) {
1836
1868
  if (!queryResult.issuing_country.out.expected?.every((country) => countryList.includes(country))) {
1837
1869
  console.warn("Issuing country exclusion list does not match the one from the query results");
1838
1870
  isCorrect = false;
1839
- queryResultErrors.issuing_country.out = {
1840
- expected: queryResult.issuing_country.out.expected,
1841
- received: countryList,
1842
- 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
+ }
1843
1878
  };
1844
1879
  }
1845
1880
  } else if (!queryResult.issuing_country || !queryResult.issuing_country.out) {
1846
1881
  console.warn("Issuing country exclusion is not set in the query result");
1847
1882
  isCorrect = false;
1848
- queryResultErrors.issuing_country.out = {
1849
- 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
+ }
1850
1888
  };
1851
1889
  }
1852
1890
  for (let i = 1; i < countryList.length; i++) {
@@ -1855,98 +1893,80 @@ var ZKPassport = class {
1855
1893
  "The issuing country exclusion list has not been sorted, and thus the proof cannot be trusted"
1856
1894
  );
1857
1895
  isCorrect = false;
1858
- queryResultErrors.issuing_country.out = {
1859
- 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
+ }
1860
1901
  };
1861
1902
  }
1862
1903
  }
1863
1904
  return { isCorrect, queryResultErrors };
1864
1905
  }
1865
1906
  checkNationalityInclusionPublicInputs(queryResult, countryList) {
1866
- const queryResultErrors = {
1867
- sig_check_dsc: {},
1868
- sig_check_id_data: {},
1869
- data_check_integrity: {},
1870
- disclose: {},
1871
- age: {},
1872
- birthdate: {},
1873
- expiry_date: {},
1874
- document_type: {},
1875
- issuing_country: {},
1876
- gender: {},
1877
- nationality: {},
1878
- firstname: {},
1879
- lastname: {},
1880
- fullname: {},
1881
- document_number: {},
1882
- outer: {},
1883
- bind: {}
1884
- };
1907
+ const queryResultErrors = {};
1885
1908
  let isCorrect = true;
1886
1909
  if (queryResult.nationality && queryResult.nationality.in && queryResult.nationality.in.result) {
1887
1910
  if (!queryResult.nationality.in.expected?.every((country) => countryList.includes(country))) {
1888
1911
  console.warn("Nationality inclusion list does not match the one from the query results");
1889
1912
  isCorrect = false;
1890
- queryResultErrors.nationality.in = {
1891
- expected: queryResult.nationality.in.expected,
1892
- received: countryList,
1893
- 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
+ }
1894
1920
  };
1895
1921
  }
1896
1922
  } else if (!queryResult.nationality || !queryResult.nationality.in) {
1897
1923
  console.warn("Nationality inclusion is not set in the query result");
1898
1924
  isCorrect = false;
1899
- queryResultErrors.nationality.in = {
1900
- 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
+ }
1901
1930
  };
1902
1931
  }
1903
1932
  return { isCorrect, queryResultErrors };
1904
1933
  }
1905
1934
  checkIssuingCountryInclusionPublicInputs(queryResult, countryList) {
1906
- const queryResultErrors = {
1907
- sig_check_dsc: {},
1908
- sig_check_id_data: {},
1909
- data_check_integrity: {},
1910
- disclose: {},
1911
- age: {},
1912
- birthdate: {},
1913
- expiry_date: {},
1914
- document_type: {},
1915
- issuing_country: {},
1916
- gender: {},
1917
- nationality: {},
1918
- firstname: {},
1919
- lastname: {},
1920
- fullname: {},
1921
- document_number: {},
1922
- outer: {},
1923
- bind: {}
1924
- };
1935
+ const queryResultErrors = {};
1925
1936
  let isCorrect = true;
1926
1937
  if (queryResult.issuing_country && queryResult.issuing_country.in && queryResult.issuing_country.in.result) {
1927
1938
  if (!queryResult.issuing_country.in.expected?.every((country) => countryList.includes(country))) {
1928
1939
  console.warn("Issuing country inclusion list does not match the one from the query results");
1929
1940
  isCorrect = false;
1930
- queryResultErrors.issuing_country.in = {
1931
- expected: queryResult.issuing_country.in.expected,
1932
- received: countryList,
1933
- 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
+ }
1934
1948
  };
1935
1949
  }
1936
1950
  } else if (!queryResult.issuing_country || !queryResult.issuing_country.in) {
1937
1951
  console.warn("Issuing country inclusion is not set in the query result");
1938
1952
  isCorrect = false;
1939
- queryResultErrors.issuing_country.in = {
1940
- 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
+ }
1941
1958
  };
1942
1959
  }
1943
1960
  return { isCorrect, queryResultErrors };
1944
1961
  }
1945
- checkScopeFromDisclosureProof(proofData, queryResultErrors, key, scope, chainId) {
1962
+ checkScopeFromDisclosureProof(proofData, queryResultErrors, key, scope) {
1946
1963
  let isCorrect = true;
1947
1964
  if (this.domain && (0, import_utils.getServiceScopeHash)(this.domain) !== BigInt(proofData.publicInputs[1])) {
1948
1965
  console.warn("The proof comes from a different domain than the one expected");
1949
1966
  isCorrect = false;
1967
+ if (!queryResultErrors[key]) {
1968
+ queryResultErrors[key] = {};
1969
+ }
1950
1970
  queryResultErrors[key].scope = {
1951
1971
  expected: `Scope: ${(0, import_utils.getServiceScopeHash)(this.domain).toString()}`,
1952
1972
  received: `Scope: ${BigInt(proofData.publicInputs[1]).toString()}`,
@@ -1956,6 +1976,9 @@ var ZKPassport = class {
1956
1976
  if (scope && (0, import_utils.getScopeHash)(scope) !== BigInt(proofData.publicInputs[2])) {
1957
1977
  console.warn("The proof uses a different scope than the one expected");
1958
1978
  isCorrect = false;
1979
+ if (!queryResultErrors[key]) {
1980
+ queryResultErrors[key] = {};
1981
+ }
1959
1982
  queryResultErrors[key].scope = {
1960
1983
  expected: `Scope: ${(0, import_utils.getScopeHash)(scope).toString()}`,
1961
1984
  received: `Scope: ${BigInt(proofData.publicInputs[2]).toString()}`,
@@ -1972,6 +1995,9 @@ var ZKPassport = class {
1972
1995
  if (!isValid) {
1973
1996
  console.warn("The ID was signed by an unrecognized root certificate");
1974
1997
  isCorrect = false;
1998
+ if (!queryResultErrors[outer ? "outer" : "sig_check_dsc"]) {
1999
+ queryResultErrors[outer ? "outer" : "sig_check_dsc"] = {};
2000
+ }
1975
2001
  queryResultErrors[outer ? "outer" : "sig_check_dsc"].certificate = {
1976
2002
  expected: `A valid root from ZKPassport Registry`,
1977
2003
  received: `Got invalid certificate registry root: ${root}`,
@@ -1982,6 +2008,9 @@ var ZKPassport = class {
1982
2008
  console.warn(error);
1983
2009
  console.warn("The ID was signed by an unrecognized root certificate");
1984
2010
  isCorrect = false;
2011
+ if (!queryResultErrors[outer ? "outer" : "sig_check_dsc"]) {
2012
+ queryResultErrors[outer ? "outer" : "sig_check_dsc"] = {};
2013
+ }
1985
2014
  queryResultErrors[outer ? "outer" : "sig_check_dsc"].certificate = {
1986
2015
  expected: `A valid root from ZKPassport Registry`,
1987
2016
  received: `Got invalid certificate registry root: ${root}`,
@@ -2017,52 +2046,63 @@ var ZKPassport = class {
2017
2046
  return { isCorrect, queryResultErrors };
2018
2047
  }
2019
2048
  checkBindPublicInputs(queryResult, boundData) {
2020
- const queryResultErrors = {
2021
- sig_check_dsc: {},
2022
- sig_check_id_data: {},
2023
- data_check_integrity: {},
2024
- disclose: {},
2025
- age: {},
2026
- birthdate: {},
2027
- expiry_date: {},
2028
- document_type: {},
2029
- issuing_country: {},
2030
- gender: {},
2031
- nationality: {},
2032
- firstname: {},
2033
- lastname: {},
2034
- fullname: {},
2035
- document_number: {},
2036
- outer: {},
2037
- bind: {}
2038
- };
2049
+ const queryResultErrors = {};
2039
2050
  let isCorrect = true;
2040
2051
  if (queryResult.bind) {
2041
2052
  if (queryResult.bind.user_address?.toLowerCase().replace("0x", "") !== boundData.user_address?.toLowerCase().replace("0x", "")) {
2042
2053
  console.warn("Bound user address does not match the one from the query results");
2043
2054
  isCorrect = false;
2044
- queryResultErrors.bind.eq = {
2045
- expected: queryResult.bind.user_address,
2046
- received: boundData.user_address,
2047
- 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
+ }
2048
2062
  };
2049
2063
  }
2050
2064
  if (queryResult.bind.chain !== boundData.chain) {
2051
2065
  console.warn("Bound chain id does not match the one from the query results");
2052
2066
  isCorrect = false;
2053
- queryResultErrors.bind.eq = {
2054
- expected: queryResult.bind.chain,
2055
- received: boundData.chain,
2056
- 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
+ }
2057
2074
  };
2058
2075
  }
2059
2076
  if (queryResult.bind.custom_data?.trim().toLowerCase() !== boundData.custom_data?.trim().toLowerCase()) {
2060
2077
  console.warn("Bound custom data does not match the one from the query results");
2061
2078
  isCorrect = false;
2062
- queryResultErrors.bind.eq = {
2063
- expected: queryResult.bind.custom_data,
2064
- received: boundData.custom_data,
2065
- 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
+ }
2066
2106
  };
2067
2107
  }
2068
2108
  }
@@ -2083,25 +2123,7 @@ var ZKPassport = class {
2083
2123
  0,
2084
2124
  0
2085
2125
  );
2086
- let queryResultErrors = {
2087
- sig_check_dsc: {},
2088
- sig_check_id_data: {},
2089
- data_check_integrity: {},
2090
- disclose: {},
2091
- age: {},
2092
- birthdate: {},
2093
- expiry_date: {},
2094
- document_type: {},
2095
- issuing_country: {},
2096
- gender: {},
2097
- nationality: {},
2098
- firstname: {},
2099
- lastname: {},
2100
- fullname: {},
2101
- document_number: {},
2102
- outer: {},
2103
- bind: {}
2104
- };
2126
+ let queryResultErrors = {};
2105
2127
  const sortedProofs = proofs.sort((a, b) => {
2106
2128
  const proofOrder = [
2107
2129
  "sig_check_dsc",
@@ -2115,7 +2137,8 @@ var ZKPassport = class {
2115
2137
  "inclusion_check_nationality",
2116
2138
  "exclusion_check_issuing_country",
2117
2139
  "inclusion_check_issuing_country",
2118
- "bind"
2140
+ "bind",
2141
+ "exclusion_check_sanctions"
2119
2142
  ];
2120
2143
  const getIndex = (proof) => {
2121
2144
  const name = proof.name || "";
@@ -2153,18 +2176,20 @@ var ZKPassport = class {
2153
2176
  };
2154
2177
  const currentDate = (0, import_utils.getCurrentDateFromOuterProof)(proofData);
2155
2178
  const todayToCurrentDate = today.getTime() - currentDate.getTime();
2156
- const differenceInDays = validity ?? 180;
2157
- const expectedDifference = differenceInDays * 864e5;
2179
+ const expectedDifference = validity ? validity * 1e3 : DEFAULT_VALIDITY * 1e3;
2158
2180
  const actualDifference = today.getTime() - (today.getTime() - expectedDifference);
2159
2181
  if (todayToCurrentDate >= actualDifference) {
2160
2182
  console.warn(
2161
- `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`
2162
2184
  );
2163
2185
  isCorrect = false;
2164
- queryResultErrors.outer.date = {
2165
- expected: `Difference: ${differenceInDays} days`,
2166
- received: `Difference: ${Math.round(todayToCurrentDate / 864e5)} days`,
2167
- 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
+ }
2168
2193
  };
2169
2194
  }
2170
2195
  const paramCommitments = (0, import_utils.getParamCommitmentsFromOuterProof)(proofData);
@@ -2173,28 +2198,37 @@ var ZKPassport = class {
2173
2198
  if (keysInCommittedInputs.length !== paramCommitments.length) {
2174
2199
  console.warn("The proof does not verify all the requested conditions and information");
2175
2200
  isCorrect = false;
2176
- queryResultErrors.outer.commitment = {
2177
- expected: `Number of parameter commitments: ${paramCommitments.length}`,
2178
- received: `Number of disclosure proofs provided: ${keysInCommittedInputs.length}`,
2179
- 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
+ }
2180
2208
  };
2181
2209
  }
2182
2210
  if (this.domain && (0, import_utils.getServiceScopeHash)(this.domain) !== (0, import_utils.getScopeFromOuterProof)(proofData)) {
2183
2211
  console.warn("The proof comes from a different domain than the one expected");
2184
2212
  isCorrect = false;
2185
- queryResultErrors.outer.scope = {
2186
- expected: `Scope: ${(0, import_utils.getServiceScopeHash)(this.domain).toString()}`,
2187
- received: `Scope: ${(0, import_utils.getScopeFromOuterProof)(proofData).toString()}`,
2188
- 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
+ }
2189
2220
  };
2190
2221
  }
2191
2222
  if (scope && (0, import_utils.getScopeHash)(scope) !== (0, import_utils.getSubscopeFromOuterProof)(proofData)) {
2192
2223
  console.warn("The proof uses a different scope than the one expected");
2193
2224
  isCorrect = false;
2194
- queryResultErrors.outer.scope = {
2195
- expected: `Scope: ${(0, import_utils.getScopeHash)(scope).toString()}`,
2196
- received: `Scope: ${(0, import_utils.getSubscopeFromOuterProof)(proofData).toString()}`,
2197
- 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
+ }
2198
2232
  };
2199
2233
  }
2200
2234
  if (!!committedInputs?.compare_age) {
@@ -2211,10 +2245,13 @@ var ZKPassport = class {
2211
2245
  if (!paramCommitments.includes(ageParameterCommitment)) {
2212
2246
  console.warn("This proof does not verify the age");
2213
2247
  isCorrect = false;
2214
- queryResultErrors.age.commitment = {
2215
- expected: `Age parameter commitment: ${ageParameterCommitment.toString()}`,
2216
- received: `Parameter commitments included: ${paramCommitments.join(", ")}`,
2217
- 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
+ }
2218
2255
  };
2219
2256
  }
2220
2257
  const { isCorrect: isCorrectAge, queryResultErrors: queryResultErrorsAge } = this.checkAgePublicInputs(proof, queryResult);
@@ -2239,10 +2276,13 @@ var ZKPassport = class {
2239
2276
  if (!paramCommitments.includes(birthdateParameterCommitment)) {
2240
2277
  console.warn("This proof does not verify the birthdate");
2241
2278
  isCorrect = false;
2242
- queryResultErrors.birthdate.commitment = {
2243
- expected: `Birthdate parameter commitment: ${birthdateParameterCommitment.toString()}`,
2244
- received: `Parameter commitments included: ${paramCommitments.join(", ")}`,
2245
- 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
+ }
2246
2286
  };
2247
2287
  }
2248
2288
  const { isCorrect: isCorrectBirthdate, queryResultErrors: queryResultErrorsBirthdate } = this.checkBirthdatePublicInputs(proof, queryResult);
@@ -2267,10 +2307,13 @@ var ZKPassport = class {
2267
2307
  if (!paramCommitments.includes(expiryParameterCommitment)) {
2268
2308
  console.warn("This proof does not verify the expiry date");
2269
2309
  isCorrect = false;
2270
- queryResultErrors.expiry_date.commitment = {
2271
- expected: `Expiry date parameter commitment: ${expiryParameterCommitment.toString()}`,
2272
- received: `Parameter commitments included: ${paramCommitments.join(", ")}`,
2273
- 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
+ }
2274
2317
  };
2275
2318
  }
2276
2319
  const { isCorrect: isCorrectExpiryDate, queryResultErrors: queryResultErrorsExpiryDate } = this.checkExpiryDatePublicInputs(proof, queryResult);
@@ -2291,10 +2334,13 @@ var ZKPassport = class {
2291
2334
  if (!paramCommitments.includes(discloseParameterCommitment)) {
2292
2335
  console.warn("This proof does not verify any of the data disclosed");
2293
2336
  isCorrect = false;
2294
- queryResultErrors.disclose.commitment = {
2295
- expected: `Disclosure parameter commitment: ${discloseParameterCommitment.toString()}`,
2296
- received: `Parameter commitments included: ${paramCommitments.join(", ")}`,
2297
- 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
+ }
2298
2344
  };
2299
2345
  }
2300
2346
  const { isCorrect: isCorrectDisclose, queryResultErrors: queryResultErrorsDisclose } = this.checkDiscloseBytesPublicInputs(proof, queryResult);
@@ -2315,10 +2361,13 @@ var ZKPassport = class {
2315
2361
  if (!paramCommitments.includes(inclusionCheckNationalityParameterCommitment)) {
2316
2362
  console.warn("This proof does not verify the inclusion of the nationality");
2317
2363
  isCorrect = false;
2318
- queryResultErrors.nationality.commitment = {
2319
- expected: `Nationality parameter commitment: ${inclusionCheckNationalityParameterCommitment.toString()}`,
2320
- received: `Parameter commitments included: ${paramCommitments.join(", ")}`,
2321
- 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
+ }
2322
2371
  };
2323
2372
  }
2324
2373
  const countryList = inclusionCheckNationalityCommittedInputs.countries;
@@ -2343,10 +2392,13 @@ var ZKPassport = class {
2343
2392
  if (!paramCommitments.includes(inclusionCheckIssuingCountryParameterCommitment)) {
2344
2393
  console.warn("This proof does not verify the inclusion of the issuing country");
2345
2394
  isCorrect = false;
2346
- queryResultErrors.issuing_country.commitment = {
2347
- expected: `Issuing country parameter commitment: ${inclusionCheckIssuingCountryParameterCommitment.toString()}`,
2348
- received: `Parameter commitments included: ${paramCommitments.join(", ")}`,
2349
- 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
+ }
2350
2402
  };
2351
2403
  }
2352
2404
  const countryList = inclusionCheckIssuingCountryCommittedInputs.countries;
@@ -2371,10 +2423,13 @@ var ZKPassport = class {
2371
2423
  if (!paramCommitments.includes(exclusionCheckNationalityParameterCommitment)) {
2372
2424
  console.warn("This proof does not verify the exclusion of the nationality");
2373
2425
  isCorrect = false;
2374
- queryResultErrors.nationality.commitment = {
2375
- expected: `Nationality parameter commitment: ${exclusionCheckNationalityParameterCommitment.toString()}`,
2376
- received: `Parameter commitments included: ${paramCommitments.join(", ")}`,
2377
- 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
+ }
2378
2433
  };
2379
2434
  }
2380
2435
  const countryList = exclusionCheckNationalityCommittedInputs.countries;
@@ -2399,10 +2454,13 @@ var ZKPassport = class {
2399
2454
  if (!paramCommitments.includes(exclusionCheckIssuingCountryParameterCommitment)) {
2400
2455
  console.warn("This proof does not verify the exclusion of the issuing country");
2401
2456
  isCorrect = false;
2402
- queryResultErrors.issuing_country.commitment = {
2403
- expected: `Issuing country parameter commitment: ${exclusionCheckIssuingCountryParameterCommitment.toString()}`,
2404
- received: `Parameter commitments included: ${paramCommitments.join(", ")}`,
2405
- 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
+ }
2406
2464
  };
2407
2465
  }
2408
2466
  const countryList = exclusionCheckIssuingCountryCommittedInputs.countries;
@@ -2421,10 +2479,13 @@ var ZKPassport = class {
2421
2479
  if (!paramCommitments.includes(bindParameterCommitment)) {
2422
2480
  console.warn("This proof does not verify the bound data");
2423
2481
  isCorrect = false;
2424
- queryResultErrors.bind.commitment = {
2425
- expected: `Bind parameter commitment: ${bindParameterCommitment.toString()}`,
2426
- received: `Parameter commitments included: ${paramCommitments.join(", ")}`,
2427
- 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
+ }
2428
2489
  };
2429
2490
  }
2430
2491
  const { isCorrect: isCorrectBind, queryResultErrors: queryResultErrorsBind } = this.checkBindPublicInputs(queryResult, bindCommittedInputs.data);
@@ -2433,6 +2494,35 @@ var ZKPassport = class {
2433
2494
  ...queryResultErrors,
2434
2495
  ...queryResultErrorsBind
2435
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
+ };
2436
2526
  }
2437
2527
  uniqueIdentifier = (0, import_utils.getNullifierFromOuterProof)(proofData).toString(10);
2438
2528
  } else if (proof.name?.startsWith("sig_check_dsc")) {
@@ -2458,10 +2548,13 @@ var ZKPassport = class {
2458
2548
  "Failed to check the link between the certificate signature and ID signature"
2459
2549
  );
2460
2550
  isCorrect = false;
2461
- queryResultErrors.sig_check_id_data.commitment = {
2462
- expected: `Commitment: ${commitmentOut?.toString() || "undefined"}`,
2463
- received: `Commitment: ${commitmentIn?.toString() || "undefined"}`,
2464
- 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
+ }
2465
2558
  };
2466
2559
  }
2467
2560
  commitmentOut = (0, import_utils.getCommitmentOutFromIDDataProof)(proofData);
@@ -2470,27 +2563,32 @@ var ZKPassport = class {
2470
2563
  if (commitmentIn !== commitmentOut) {
2471
2564
  console.warn("Failed to check the link between the ID signature and the data signed");
2472
2565
  isCorrect = false;
2473
- queryResultErrors.data_check_integrity.commitment = {
2474
- expected: `Commitment: ${commitmentOut?.toString() || "undefined"}`,
2475
- received: `Commitment: ${commitmentIn?.toString() || "undefined"}`,
2476
- 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
+ }
2477
2573
  };
2478
2574
  }
2479
2575
  commitmentOut = (0, import_utils.getCommitmentOutFromIntegrityProof)(proofData);
2480
2576
  const currentDate = (0, import_utils.getCurrentDateFromIntegrityProof)(proofData);
2481
2577
  const todayToCurrentDate = today.getTime() - currentDate.getTime();
2482
- const differenceInDays = validity ?? 180;
2483
- const expectedDifference = differenceInDays * 864e5;
2578
+ const expectedDifference = validity ? validity * 1e3 : DEFAULT_VALIDITY * 1e3;
2484
2579
  const actualDifference = today.getTime() - (today.getTime() - expectedDifference);
2485
2580
  if (todayToCurrentDate >= actualDifference) {
2486
2581
  console.warn(
2487
- `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`
2488
2583
  );
2489
2584
  isCorrect = false;
2490
- queryResultErrors.data_check_integrity.date = {
2491
- expected: `Difference: ${differenceInDays} days`,
2492
- received: `Difference: ${Math.round(todayToCurrentDate / 864e5)} days`,
2493
- 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
+ }
2494
2592
  };
2495
2593
  }
2496
2594
  } else if (proof.name === "disclose_bytes") {
@@ -2500,10 +2598,13 @@ var ZKPassport = class {
2500
2598
  "Failed to check the link between the validity of the ID and the data to disclose"
2501
2599
  );
2502
2600
  isCorrect = false;
2503
- queryResultErrors.disclose.commitment = {
2504
- expected: `Commitment: ${commitmentOut?.toString() || "undefined"}`,
2505
- received: `Commitment: ${commitmentIn?.toString() || "undefined"}`,
2506
- 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
+ }
2507
2608
  };
2508
2609
  }
2509
2610
  const paramCommitment = (0, import_utils.getParameterCommitmentFromDisclosureProof)(proofData);
@@ -2514,10 +2615,13 @@ var ZKPassport = class {
2514
2615
  if (paramCommitment !== calculatedParamCommitment) {
2515
2616
  console.warn("The disclosed data does not match the data committed by the proof");
2516
2617
  isCorrect = false;
2517
- queryResultErrors.disclose.commitment = {
2518
- expected: `Commitment: ${calculatedParamCommitment}`,
2519
- received: `Commitment: ${paramCommitment}`,
2520
- 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
+ }
2521
2625
  };
2522
2626
  }
2523
2627
  const { isCorrect: isCorrectScope, queryResultErrors: queryResultErrorsScope } = this.checkScopeFromDisclosureProof(proofData, queryResultErrors, "disclose", scope);
@@ -2541,10 +2645,13 @@ var ZKPassport = class {
2541
2645
  "Failed to check the link between the validity of the ID and the age derived from it"
2542
2646
  );
2543
2647
  isCorrect = false;
2544
- queryResultErrors.age.commitment = {
2545
- expected: `Commitment: ${commitmentOut}`,
2546
- received: `Commitment: ${commitmentIn}`,
2547
- 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
+ }
2548
2655
  };
2549
2656
  }
2550
2657
  const paramCommitment = (0, import_utils.getParameterCommitmentFromDisclosureProof)(proofData);
@@ -2559,10 +2666,13 @@ var ZKPassport = class {
2559
2666
  "The conditions for the age check do not match the conditions checked by the proof"
2560
2667
  );
2561
2668
  isCorrect = false;
2562
- queryResultErrors.age.commitment = {
2563
- expected: `Commitment: ${calculatedParamCommitment}`,
2564
- received: `Commitment: ${paramCommitment}`,
2565
- 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
+ }
2566
2676
  };
2567
2677
  }
2568
2678
  const { isCorrect: isCorrectScope, queryResultErrors: queryResultErrorsScope } = this.checkScopeFromDisclosureProof(proofData, queryResultErrors, "age", scope);
@@ -2581,10 +2691,13 @@ var ZKPassport = class {
2581
2691
  "Failed to check the link between the validity of the ID and the birthdate derived from it"
2582
2692
  );
2583
2693
  isCorrect = false;
2584
- queryResultErrors.birthdate.commitment = {
2585
- expected: `Commitment: ${commitmentOut}`,
2586
- received: `Commitment: ${commitmentIn}`,
2587
- 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
+ }
2588
2701
  };
2589
2702
  }
2590
2703
  const paramCommitment = (0, import_utils.getParameterCommitmentFromDisclosureProof)(proofData);
@@ -2600,10 +2713,13 @@ var ZKPassport = class {
2600
2713
  "The conditions for the birthdate check do not match the conditions checked by the proof"
2601
2714
  );
2602
2715
  isCorrect = false;
2603
- queryResultErrors.birthdate.commitment = {
2604
- expected: `Commitment: ${calculatedParamCommitment}`,
2605
- received: `Commitment: ${paramCommitment}`,
2606
- 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
+ }
2607
2723
  };
2608
2724
  }
2609
2725
  const { isCorrect: isCorrectScope, queryResultErrors: queryResultErrorsScope } = this.checkScopeFromDisclosureProof(proofData, queryResultErrors, "birthdate", scope);
@@ -2622,10 +2738,13 @@ var ZKPassport = class {
2622
2738
  "Failed to check the link between the validity of the ID and its expiry date"
2623
2739
  );
2624
2740
  isCorrect = false;
2625
- queryResultErrors.expiry_date.commitment = {
2626
- expected: `Commitment: ${commitmentOut}`,
2627
- received: `Commitment: ${commitmentIn}`,
2628
- 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
+ }
2629
2748
  };
2630
2749
  }
2631
2750
  const paramCommitment = (0, import_utils.getParameterCommitmentFromDisclosureProof)(proofData);
@@ -2641,10 +2760,13 @@ var ZKPassport = class {
2641
2760
  "The conditions for the expiry date check do not match the conditions checked by the proof"
2642
2761
  );
2643
2762
  isCorrect = false;
2644
- queryResultErrors.expiry_date.commitment = {
2645
- expected: `Commitment: ${calculatedParamCommitment}`,
2646
- received: `Commitment: ${paramCommitment}`,
2647
- 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
+ }
2648
2770
  };
2649
2771
  }
2650
2772
  const { isCorrect: isCorrectScope, queryResultErrors: queryResultErrorsScope } = this.checkScopeFromDisclosureProof(proofData, queryResultErrors, "expiry_date", scope);
@@ -2663,10 +2785,13 @@ var ZKPassport = class {
2663
2785
  "Failed to check the link between the validity of the ID and the nationality exclusion check"
2664
2786
  );
2665
2787
  isCorrect = false;
2666
- queryResultErrors.nationality.commitment = {
2667
- expected: `Commitment: ${commitmentOut}`,
2668
- received: `Commitment: ${commitmentIn}`,
2669
- 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
+ }
2670
2795
  };
2671
2796
  }
2672
2797
  const countryList = (proof.committedInputs?.exclusion_check_nationality).countries;
@@ -2681,10 +2806,13 @@ var ZKPassport = class {
2681
2806
  "The committed country list for the exclusion check does not match the one from the proof"
2682
2807
  );
2683
2808
  isCorrect = false;
2684
- queryResultErrors.nationality.commitment = {
2685
- expected: `Commitment: ${calculatedParamCommitment}`,
2686
- received: `Commitment: ${paramCommittment}`,
2687
- 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
+ }
2688
2816
  };
2689
2817
  }
2690
2818
  const { isCorrect: isCorrectScope, queryResultErrors: queryResultErrorsScope } = this.checkScopeFromDisclosureProof(proofData, queryResultErrors, "nationality", scope);
@@ -2706,10 +2834,13 @@ var ZKPassport = class {
2706
2834
  "Failed to check the link between the validity of the ID and the issuing country exclusion check"
2707
2835
  );
2708
2836
  isCorrect = false;
2709
- queryResultErrors.nationality.commitment = {
2710
- expected: `Commitment: ${commitmentOut}`,
2711
- received: `Commitment: ${commitmentIn}`,
2712
- 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
+ }
2713
2844
  };
2714
2845
  }
2715
2846
  const countryList = (proof.committedInputs?.exclusion_check_issuing_country).countries;
@@ -2724,10 +2855,13 @@ var ZKPassport = class {
2724
2855
  "The committed country list for the issuing country exclusion check does not match the one from the proof"
2725
2856
  );
2726
2857
  isCorrect = false;
2727
- queryResultErrors.issuing_country.commitment = {
2728
- expected: `Commitment: ${calculatedParamCommitment}`,
2729
- received: `Commitment: ${paramCommittment}`,
2730
- 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
+ }
2731
2865
  };
2732
2866
  }
2733
2867
  const { isCorrect: isCorrectScope, queryResultErrors: queryResultErrorsScope } = this.checkScopeFromDisclosureProof(proofData, queryResultErrors, "nationality", scope);
@@ -2749,10 +2883,13 @@ var ZKPassport = class {
2749
2883
  "Failed to check the link between the validity of the ID and the nationality inclusion check"
2750
2884
  );
2751
2885
  isCorrect = false;
2752
- queryResultErrors.nationality.commitment = {
2753
- expected: `Commitment: ${commitmentOut}`,
2754
- received: `Commitment: ${commitmentIn}`,
2755
- 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
+ }
2756
2893
  };
2757
2894
  }
2758
2895
  const countryList = (proof.committedInputs?.inclusion_check_nationality).countries;
@@ -2767,10 +2904,13 @@ var ZKPassport = class {
2767
2904
  "The committed country list for the nationality inclusion check does not match the one from the proof"
2768
2905
  );
2769
2906
  isCorrect = false;
2770
- queryResultErrors.nationality.commitment = {
2771
- expected: `Commitment: ${calculatedParamCommitment}`,
2772
- received: `Commitment: ${paramCommittment}`,
2773
- 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
+ }
2774
2914
  };
2775
2915
  }
2776
2916
  const { isCorrect: isCorrectScope, queryResultErrors: queryResultErrorsScope } = this.checkScopeFromDisclosureProof(proofData, queryResultErrors, "nationality", scope);
@@ -2792,10 +2932,13 @@ var ZKPassport = class {
2792
2932
  "Failed to check the link between the validity of the ID and the issuing country inclusion check"
2793
2933
  );
2794
2934
  isCorrect = false;
2795
- queryResultErrors.nationality.commitment = {
2796
- expected: `Commitment: ${commitmentOut}`,
2797
- received: `Commitment: ${commitmentIn}`,
2798
- 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
+ }
2799
2942
  };
2800
2943
  }
2801
2944
  const countryList = (proof.committedInputs?.inclusion_check_issuing_country).countries;
@@ -2810,10 +2953,13 @@ var ZKPassport = class {
2810
2953
  "The committed country list for the issuing country inclusion check does not match the one from the proof"
2811
2954
  );
2812
2955
  isCorrect = false;
2813
- queryResultErrors.issuing_country.commitment = {
2814
- expected: `Commitment: ${calculatedParamCommitment}`,
2815
- received: `Commitment: ${paramCommittment}`,
2816
- 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
+ }
2817
2963
  };
2818
2964
  }
2819
2965
  const { isCorrect: isCorrectScope, queryResultErrors: queryResultErrorsScope } = this.checkScopeFromDisclosureProof(proofData, queryResultErrors, "nationality", scope);
@@ -2837,10 +2983,13 @@ var ZKPassport = class {
2837
2983
  if (paramCommittment !== calculatedParamCommitment) {
2838
2984
  console.warn("The bound data does not match the one from the proof");
2839
2985
  isCorrect = false;
2840
- queryResultErrors.bind.commitment = {
2841
- expected: `Commitment: ${calculatedParamCommitment}`,
2842
- received: `Commitment: ${paramCommittment}`,
2843
- 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
+ }
2844
2993
  };
2845
2994
  }
2846
2995
  const { isCorrect: isCorrectBind, queryResultErrors: queryResultErrorsBind } = this.checkBindPublicInputs(queryResult, bindCommittedInputs.data);
@@ -2850,6 +2999,39 @@ var ZKPassport = class {
2850
2999
  ...queryResultErrorsBind
2851
3000
  };
2852
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);
2853
3035
  }
2854
3036
  }
2855
3037
  return { isCorrect, uniqueIdentifier, queryResultErrors };
@@ -2858,7 +3040,7 @@ var ZKPassport = class {
2858
3040
  * @notice Verify the proofs received from the mobile app.
2859
3041
  * @param proofs The proofs to verify.
2860
3042
  * @param queryResult The query result to verify against
2861
- * @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
2862
3044
  * @param scope Scope this request to a specific use case
2863
3045
  * @param devMode Whether to enable dev mode. This will allow you to verify mock proofs (i.e. from ZKR)
2864
3046
  * @param writingDirectory The directory (e.g. `./tmp`) where the necessary temporary artifacts for verification are written to.
@@ -2989,7 +3171,7 @@ var ZKPassport = class {
2989
3171
  }
2990
3172
  getSolidityVerifierParameters({
2991
3173
  proof,
2992
- validityPeriodInSeconds = 7 * 24 * 60 * 60,
3174
+ validityPeriodInSeconds = DEFAULT_VALIDITY,
2993
3175
  domain,
2994
3176
  scope,
2995
3177
  devMode = false
@@ -3031,19 +3213,19 @@ var ZKPassport = class {
3031
3213
  ).map((x) => x.toString(16).padStart(2, "0")).join("");
3032
3214
  } else if (circuitName === "compare_age_evm") {
3033
3215
  const value = proof.committedInputs[circuitName];
3034
- const currentDateBytes = Array.from((0, import_utils2.numberToBytesBE)(value.currentDateTimestamp, 4));
3216
+ const currentDateBytes = Array.from((0, import_utils2.numberToBytesBE)(value.currentDateTimestamp, 8));
3035
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");
3036
3218
  } else if (circuitName === "compare_birthdate_evm") {
3037
3219
  const value = proof.committedInputs[circuitName];
3038
- const currentDateBytes = Array.from((0, import_utils2.numberToBytesBE)(value.currentDateTimestamp, 4));
3039
- const minDateBytes = Array.from((0, import_utils2.numberToBytesBE)(value.minDateTimestamp, 4));
3040
- const maxDateBytes = Array.from((0, import_utils2.numberToBytesBE)(value.maxDateTimestamp, 4));
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));
3041
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("");
3042
3224
  } else if (circuitName === "compare_expiry_evm") {
3043
3225
  const value = proof.committedInputs[circuitName];
3044
- const currentDateBytes = Array.from((0, import_utils2.numberToBytesBE)(value.currentDateTimestamp, 4));
3045
- const minDateBytes = Array.from((0, import_utils2.numberToBytesBE)(value.minDateTimestamp, 4));
3046
- const maxDateBytes = Array.from((0, import_utils2.numberToBytesBE)(value.maxDateTimestamp, 4));
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));
3047
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("");
3048
3230
  } else if (circuitName === "disclose_bytes_evm") {
3049
3231
  const value = proof.committedInputs[circuitName];
@@ -3105,7 +3287,8 @@ var ZKPassport = class {
3105
3287
  "base64"
3106
3288
  );
3107
3289
  const pubkey = this.topicToPublicKey[requestId];
3108
- 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}`;
3109
3292
  }
3110
3293
  /**
3111
3294
  * @notice Returns the URL of the request.