@zkpassport/sdk 0.2.11 → 0.2.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/index.js +18 -2
- package/dist/esm/index.js +18 -2
- package/package.json +2 -2
- package/src/index.ts +27 -2
package/dist/cjs/index.js
CHANGED
|
@@ -218,7 +218,15 @@ class ZKPassport {
|
|
|
218
218
|
}
|
|
219
219
|
else if (request.method === "done") {
|
|
220
220
|
logger_1.noLogger.debug(`User sent the query result`);
|
|
221
|
-
|
|
221
|
+
const formattedResult = request.params;
|
|
222
|
+
// Make sure to reconvert the dates to Date objects
|
|
223
|
+
if (formattedResult.birthdate && formattedResult.birthdate.disclose) {
|
|
224
|
+
formattedResult.birthdate.disclose.result = new Date(formattedResult.birthdate.disclose.result);
|
|
225
|
+
}
|
|
226
|
+
if (formattedResult.expiry_date && formattedResult.expiry_date.disclose) {
|
|
227
|
+
formattedResult.expiry_date.disclose.result = new Date(formattedResult.expiry_date.disclose.result);
|
|
228
|
+
}
|
|
229
|
+
this.topicToResults[topic] = formattedResult;
|
|
222
230
|
// Make sure all the proofs have been received, otherwise we'll handle the result later
|
|
223
231
|
// once the proofs have all been received
|
|
224
232
|
if (this.topicToExpectedProofCount[topic] === this.topicToProofs[topic].length) {
|
|
@@ -1240,12 +1248,20 @@ class ZKPassport {
|
|
|
1240
1248
|
* and a boolean indicating whether the proofs were successfully verified.
|
|
1241
1249
|
*/
|
|
1242
1250
|
async verify({ proofs, queryResult, validity, }) {
|
|
1251
|
+
const formattedResult = queryResult;
|
|
1252
|
+
// Make sure to reconvert the dates to Date objects
|
|
1253
|
+
if (formattedResult.birthdate && formattedResult.birthdate.disclose) {
|
|
1254
|
+
formattedResult.birthdate.disclose.result = new Date(formattedResult.birthdate.disclose.result);
|
|
1255
|
+
}
|
|
1256
|
+
if (formattedResult.expiry_date && formattedResult.expiry_date.disclose) {
|
|
1257
|
+
formattedResult.expiry_date.disclose.result = new Date(formattedResult.expiry_date.disclose.result);
|
|
1258
|
+
}
|
|
1243
1259
|
const { BarretenbergVerifier } = await Promise.resolve().then(() => tslib_1.__importStar(require("@aztec/bb.js")));
|
|
1244
1260
|
const verifier = new BarretenbergVerifier();
|
|
1245
1261
|
let verified = true;
|
|
1246
1262
|
let uniqueIdentifier;
|
|
1247
1263
|
let queryResultErrors;
|
|
1248
|
-
const { isCorrect, uniqueIdentifier: uniqueIdentifierFromPublicInputs, queryResultErrors: queryResultErrorsFromPublicInputs, } = await this.checkPublicInputs(proofs,
|
|
1264
|
+
const { isCorrect, uniqueIdentifier: uniqueIdentifierFromPublicInputs, queryResultErrors: queryResultErrorsFromPublicInputs, } = await this.checkPublicInputs(proofs, formattedResult, validity);
|
|
1249
1265
|
uniqueIdentifier = uniqueIdentifierFromPublicInputs;
|
|
1250
1266
|
verified = isCorrect;
|
|
1251
1267
|
queryResultErrors = isCorrect ? undefined : queryResultErrorsFromPublicInputs;
|
package/dist/esm/index.js
CHANGED
|
@@ -208,7 +208,15 @@ export class ZKPassport {
|
|
|
208
208
|
}
|
|
209
209
|
else if (request.method === "done") {
|
|
210
210
|
logger.debug(`User sent the query result`);
|
|
211
|
-
|
|
211
|
+
const formattedResult = request.params;
|
|
212
|
+
// Make sure to reconvert the dates to Date objects
|
|
213
|
+
if (formattedResult.birthdate && formattedResult.birthdate.disclose) {
|
|
214
|
+
formattedResult.birthdate.disclose.result = new Date(formattedResult.birthdate.disclose.result);
|
|
215
|
+
}
|
|
216
|
+
if (formattedResult.expiry_date && formattedResult.expiry_date.disclose) {
|
|
217
|
+
formattedResult.expiry_date.disclose.result = new Date(formattedResult.expiry_date.disclose.result);
|
|
218
|
+
}
|
|
219
|
+
this.topicToResults[topic] = formattedResult;
|
|
212
220
|
// Make sure all the proofs have been received, otherwise we'll handle the result later
|
|
213
221
|
// once the proofs have all been received
|
|
214
222
|
if (this.topicToExpectedProofCount[topic] === this.topicToProofs[topic].length) {
|
|
@@ -1230,12 +1238,20 @@ export class ZKPassport {
|
|
|
1230
1238
|
* and a boolean indicating whether the proofs were successfully verified.
|
|
1231
1239
|
*/
|
|
1232
1240
|
async verify({ proofs, queryResult, validity, }) {
|
|
1241
|
+
const formattedResult = queryResult;
|
|
1242
|
+
// Make sure to reconvert the dates to Date objects
|
|
1243
|
+
if (formattedResult.birthdate && formattedResult.birthdate.disclose) {
|
|
1244
|
+
formattedResult.birthdate.disclose.result = new Date(formattedResult.birthdate.disclose.result);
|
|
1245
|
+
}
|
|
1246
|
+
if (formattedResult.expiry_date && formattedResult.expiry_date.disclose) {
|
|
1247
|
+
formattedResult.expiry_date.disclose.result = new Date(formattedResult.expiry_date.disclose.result);
|
|
1248
|
+
}
|
|
1233
1249
|
const { BarretenbergVerifier } = await import("@aztec/bb.js");
|
|
1234
1250
|
const verifier = new BarretenbergVerifier();
|
|
1235
1251
|
let verified = true;
|
|
1236
1252
|
let uniqueIdentifier;
|
|
1237
1253
|
let queryResultErrors;
|
|
1238
|
-
const { isCorrect, uniqueIdentifier: uniqueIdentifierFromPublicInputs, queryResultErrors: queryResultErrorsFromPublicInputs, } = await this.checkPublicInputs(proofs,
|
|
1254
|
+
const { isCorrect, uniqueIdentifier: uniqueIdentifierFromPublicInputs, queryResultErrors: queryResultErrorsFromPublicInputs, } = await this.checkPublicInputs(proofs, formattedResult, validity);
|
|
1239
1255
|
uniqueIdentifier = uniqueIdentifierFromPublicInputs;
|
|
1240
1256
|
verified = isCorrect;
|
|
1241
1257
|
queryResultErrors = isCorrect ? undefined : queryResultErrorsFromPublicInputs;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zkpassport/sdk",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.12",
|
|
4
4
|
"description": "Privacy-preserving identity verification using passports and ID cards",
|
|
5
5
|
"main": "./dist/cjs/index.js",
|
|
6
6
|
"module": "./dist/esm/index.js",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"@aztec/bb.js": "^0.76.4",
|
|
42
42
|
"@noble/ciphers": "^1.2.1",
|
|
43
43
|
"@noble/secp256k1": "^2.2.3",
|
|
44
|
-
"@zkpassport/utils": "^0.2.
|
|
44
|
+
"@zkpassport/utils": "^0.2.24",
|
|
45
45
|
"buffer": "^6.0.3",
|
|
46
46
|
"i18n-iso-countries": "^7.12.0",
|
|
47
47
|
"pako": "^2.1.0",
|
package/src/index.ts
CHANGED
|
@@ -479,7 +479,19 @@ export class ZKPassport {
|
|
|
479
479
|
}
|
|
480
480
|
} else if (request.method === "done") {
|
|
481
481
|
logger.debug(`User sent the query result`)
|
|
482
|
-
|
|
482
|
+
const formattedResult: QueryResult = request.params
|
|
483
|
+
// Make sure to reconvert the dates to Date objects
|
|
484
|
+
if (formattedResult.birthdate && formattedResult.birthdate.disclose) {
|
|
485
|
+
formattedResult.birthdate.disclose.result = new Date(
|
|
486
|
+
formattedResult.birthdate.disclose.result,
|
|
487
|
+
)
|
|
488
|
+
}
|
|
489
|
+
if (formattedResult.expiry_date && formattedResult.expiry_date.disclose) {
|
|
490
|
+
formattedResult.expiry_date.disclose.result = new Date(
|
|
491
|
+
formattedResult.expiry_date.disclose.result,
|
|
492
|
+
)
|
|
493
|
+
}
|
|
494
|
+
this.topicToResults[topic] = formattedResult
|
|
483
495
|
// Make sure all the proofs have been received, otherwise we'll handle the result later
|
|
484
496
|
// once the proofs have all been received
|
|
485
497
|
if (this.topicToExpectedProofCount[topic] === this.topicToProofs[topic].length) {
|
|
@@ -1709,6 +1721,19 @@ export class ZKPassport {
|
|
|
1709
1721
|
verified: boolean
|
|
1710
1722
|
queryResultErrors?: QueryResultErrors
|
|
1711
1723
|
}> {
|
|
1724
|
+
const formattedResult: QueryResult = queryResult
|
|
1725
|
+
// Make sure to reconvert the dates to Date objects
|
|
1726
|
+
if (formattedResult.birthdate && formattedResult.birthdate.disclose) {
|
|
1727
|
+
formattedResult.birthdate.disclose.result = new Date(
|
|
1728
|
+
formattedResult.birthdate.disclose.result,
|
|
1729
|
+
)
|
|
1730
|
+
}
|
|
1731
|
+
if (formattedResult.expiry_date && formattedResult.expiry_date.disclose) {
|
|
1732
|
+
formattedResult.expiry_date.disclose.result = new Date(
|
|
1733
|
+
formattedResult.expiry_date.disclose.result,
|
|
1734
|
+
)
|
|
1735
|
+
}
|
|
1736
|
+
|
|
1712
1737
|
const { BarretenbergVerifier } = await import("@aztec/bb.js")
|
|
1713
1738
|
const verifier = new BarretenbergVerifier()
|
|
1714
1739
|
let verified = true
|
|
@@ -1718,7 +1743,7 @@ export class ZKPassport {
|
|
|
1718
1743
|
isCorrect,
|
|
1719
1744
|
uniqueIdentifier: uniqueIdentifierFromPublicInputs,
|
|
1720
1745
|
queryResultErrors: queryResultErrorsFromPublicInputs,
|
|
1721
|
-
} = await this.checkPublicInputs(proofs,
|
|
1746
|
+
} = await this.checkPublicInputs(proofs, formattedResult, validity)
|
|
1722
1747
|
uniqueIdentifier = uniqueIdentifierFromPublicInputs
|
|
1723
1748
|
verified = isCorrect
|
|
1724
1749
|
queryResultErrors = isCorrect ? undefined : queryResultErrorsFromPublicInputs
|