@zkpassport/sdk 0.5.5 → 0.5.7-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/index.cjs +3169 -0
- package/dist/cjs/{index.d.ts → index.d.cts} +14 -10
- package/dist/cjs/logger.cjs +47 -0
- package/dist/cjs/{logger.d.ts → logger.d.cts} +4 -2
- package/dist/esm/index.js +14 -14
- package/package.json +33 -36
- package/dist/cjs/assets/abi/ZKPassportVerifier.json +0 -744
- package/dist/cjs/encryption.d.ts +0 -7
- package/dist/cjs/encryption.js +0 -79
- package/dist/cjs/index.js +0 -2345
- package/dist/cjs/json-rpc.d.ts +0 -6
- package/dist/cjs/json-rpc.js +0 -47
- package/dist/cjs/logger.js +0 -15
- package/dist/cjs/mobile.d.ts +0 -39
- package/dist/cjs/mobile.js +0 -130
- package/dist/cjs/websocket.d.ts +0 -2
- package/dist/cjs/websocket.js +0 -18
- package/dist/esm/encryption.d.ts +0 -7
- package/dist/esm/encryption.js +0 -40
- package/dist/esm/json-rpc.d.ts +0 -6
- package/dist/esm/json-rpc.js +0 -41
- package/dist/esm/mobile.d.ts +0 -39
- package/dist/esm/mobile.js +0 -126
- package/dist/esm/websocket.d.ts +0 -2
- package/dist/esm/websocket.js +0 -15
- package/src/assets/abi/ZKPassportVerifier.json +0 -744
- package/src/index.ts +0 -3174
- package/src/logger.ts +0 -13
- package/tsconfig.json +0 -24
|
@@ -1,10 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export
|
|
1
|
+
import { IDCredential, ProofResult, QueryResult, IDCredentialValue, NumericalIDCredential, DisclosableIDCredential, BoundData, ProofMode } from '@zkpassport/utils';
|
|
2
|
+
export * from '@zkpassport/utils';
|
|
3
|
+
export { ASEAN_COUNTRIES, EEA_COUNTRIES, EU_COUNTRIES, MERCOSUR_COUNTRIES, SANCTIONED_COUNTRIES, SCHENGEN_COUNTRIES } from '@zkpassport/utils';
|
|
4
|
+
|
|
5
|
+
type QueryResultError<T> = {
|
|
3
6
|
expected?: T;
|
|
4
7
|
received?: T;
|
|
5
8
|
message: string;
|
|
6
9
|
};
|
|
7
|
-
|
|
10
|
+
type QueryResultErrors = {
|
|
8
11
|
[key in IDCredential | "sig_check_dsc" | "sig_check_id_data" | "data_check_integrity" | "outer" | "disclose" | "bind"]: {
|
|
9
12
|
disclose?: QueryResultError<string | number | Date>;
|
|
10
13
|
gte?: QueryResultError<number | Date>;
|
|
@@ -20,7 +23,7 @@ export type QueryResultErrors = {
|
|
|
20
23
|
scope?: QueryResultError<string>;
|
|
21
24
|
};
|
|
22
25
|
};
|
|
23
|
-
|
|
26
|
+
type SolidityVerifierParameters = {
|
|
24
27
|
vkeyHash: string;
|
|
25
28
|
proof: string;
|
|
26
29
|
publicInputs: string[];
|
|
@@ -31,10 +34,9 @@ export type SolidityVerifierParameters = {
|
|
|
31
34
|
scope: string;
|
|
32
35
|
devMode: boolean;
|
|
33
36
|
};
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
export type QueryBuilderResult = {
|
|
37
|
+
type EVMChain = "ethereum_sepolia" | "local_anvil";
|
|
38
|
+
|
|
39
|
+
type QueryBuilderResult = {
|
|
38
40
|
/**
|
|
39
41
|
* The URL of the request.
|
|
40
42
|
*
|
|
@@ -101,7 +103,7 @@ export type QueryBuilderResult = {
|
|
|
101
103
|
*/
|
|
102
104
|
requestReceived: () => boolean;
|
|
103
105
|
};
|
|
104
|
-
|
|
106
|
+
type QueryBuilder = {
|
|
105
107
|
/**
|
|
106
108
|
* Requires this attribute to be equal to the provided value.
|
|
107
109
|
* @param key The attribute to compare.
|
|
@@ -165,7 +167,7 @@ export type QueryBuilder = {
|
|
|
165
167
|
*/
|
|
166
168
|
done: () => QueryBuilderResult;
|
|
167
169
|
};
|
|
168
|
-
|
|
170
|
+
declare class ZKPassport {
|
|
169
171
|
private domain;
|
|
170
172
|
private topicToConfig;
|
|
171
173
|
private topicToLocalConfig;
|
|
@@ -303,3 +305,5 @@ export declare class ZKPassport {
|
|
|
303
305
|
*/
|
|
304
306
|
clearAllRequests(): void;
|
|
305
307
|
}
|
|
308
|
+
|
|
309
|
+
export { type EVMChain, type QueryBuilder, type QueryBuilderResult, type QueryResultError, type QueryResultErrors, type SolidityVerifierParameters, ZKPassport };
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/logger.ts
|
|
21
|
+
var logger_exports = {};
|
|
22
|
+
__export(logger_exports, {
|
|
23
|
+
customLogger: () => customLogger,
|
|
24
|
+
noLogger: () => noLogger
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(logger_exports);
|
|
27
|
+
var customLogger = {
|
|
28
|
+
debug: (message, ...args) => console.debug(message, ...args),
|
|
29
|
+
info: (message, ...args) => console.info(message, ...args),
|
|
30
|
+
warn: (message, ...args) => console.warn(message, ...args),
|
|
31
|
+
error: (message, ...args) => console.error(message, ...args)
|
|
32
|
+
};
|
|
33
|
+
var noLogger = {
|
|
34
|
+
debug: (..._) => {
|
|
35
|
+
},
|
|
36
|
+
info: (..._) => {
|
|
37
|
+
},
|
|
38
|
+
warn: (..._) => {
|
|
39
|
+
},
|
|
40
|
+
error: (..._) => {
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
44
|
+
0 && (module.exports = {
|
|
45
|
+
customLogger,
|
|
46
|
+
noLogger
|
|
47
|
+
});
|
|
@@ -1,12 +1,14 @@
|
|
|
1
|
-
|
|
1
|
+
declare const customLogger: {
|
|
2
2
|
debug: (message: string, ...args: any[]) => void;
|
|
3
3
|
info: (message: string, ...args: any[]) => void;
|
|
4
4
|
warn: (message: string, ...args: any[]) => void;
|
|
5
5
|
error: (message: string, ...args: any[]) => void;
|
|
6
6
|
};
|
|
7
|
-
|
|
7
|
+
declare const noLogger: {
|
|
8
8
|
debug: (..._: any[]) => void;
|
|
9
9
|
info: (..._: any[]) => void;
|
|
10
10
|
warn: (..._: any[]) => void;
|
|
11
11
|
error: (..._: any[]) => void;
|
|
12
12
|
};
|
|
13
|
+
|
|
14
|
+
export { customLogger, noLogger };
|
package/dist/esm/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { getAlpha3Code, registerLocale } from "i18n-iso-countries";
|
|
2
2
|
import { getProofData, getCommitmentFromDSCProof, getCommitmentInFromIDDataProof, getCommitmentOutFromIDDataProof, getNullifierFromDisclosureProof, getCommitmentInFromIntegrityProof, getCommitmentOutFromIntegrityProof, getCommitmentInFromDisclosureProof, getMerkleRootFromDSCProof, getCurrentDateFromIntegrityProof, DisclosedData, formatName, getNumberOfPublicInputs, getParameterCommitmentFromDisclosureProof, getCountryParameterCommitment, getDiscloseParameterCommitment, getDateParameterCommitment, getCertificateRegistryRootFromOuterProof, getParamCommitmentsFromOuterProof, getCurrentDateFromCommittedInputs, getMinAgeFromCommittedInputs, getMaxAgeFromCommittedInputs, getAgeParameterCommitment, getMinDateFromCommittedInputs, getMaxDateFromCommittedInputs, getCurrentDateFromOuterProof, getNullifierFromOuterProof, getAgeEVMParameterCommitment, getDateEVMParameterCommitment, getDiscloseEVMParameterCommitment, getCountryEVMParameterCommitment, rightPadArrayWithZeros, getCommittedInputCount, ProofType, getScopeHash, getScopeFromOuterProof, getSubscopeFromOuterProof, getServiceScopeHash, getBindEVMParameterCommitment, getBindParameterCommitment, formatBoundData, getCircuitRegistryRootFromOuterProof, } from "@zkpassport/utils";
|
|
3
3
|
import { bytesToHex } from "@noble/ciphers/utils";
|
|
4
|
-
import { noLogger as logger } from "./logger";
|
|
4
|
+
import { noLogger as logger } from "./logger.js";
|
|
5
5
|
import i18en from "i18n-iso-countries/langs/en.json";
|
|
6
|
-
import { Buffer } from "buffer
|
|
6
|
+
import { Buffer } from "buffer";
|
|
7
7
|
import { sha256 } from "@noble/hashes/sha2";
|
|
8
8
|
import { hexToBytes } from "@noble/hashes/utils";
|
|
9
9
|
import ZKPassportVerifierAbi from "./assets/abi/ZKPassportVerifier.json";
|
|
@@ -746,7 +746,7 @@ export class ZKPassport {
|
|
|
746
746
|
if (queryResult.age) {
|
|
747
747
|
if (queryResult.age.gte &&
|
|
748
748
|
queryResult.age.gte.result &&
|
|
749
|
-
minAge
|
|
749
|
+
minAge !== queryResult.age.gte.expected) {
|
|
750
750
|
console.warn("Age is not greater than or equal to the expected age");
|
|
751
751
|
isCorrect = false;
|
|
752
752
|
queryResultErrors.age.gte = {
|
|
@@ -757,7 +757,7 @@ export class ZKPassport {
|
|
|
757
757
|
}
|
|
758
758
|
if (queryResult.age.lt &&
|
|
759
759
|
queryResult.age.lt.result &&
|
|
760
|
-
maxAge
|
|
760
|
+
maxAge !== queryResult.age.lt.expected) {
|
|
761
761
|
console.warn("Age is not less than the expected age");
|
|
762
762
|
isCorrect = false;
|
|
763
763
|
queryResultErrors.age.lt = {
|
|
@@ -768,8 +768,8 @@ export class ZKPassport {
|
|
|
768
768
|
}
|
|
769
769
|
if (queryResult.age.range) {
|
|
770
770
|
if (queryResult.age.range.result &&
|
|
771
|
-
(minAge
|
|
772
|
-
maxAge
|
|
771
|
+
(minAge !== queryResult.age.range.expected[0] ||
|
|
772
|
+
maxAge !== queryResult.age.range.expected[1])) {
|
|
773
773
|
console.warn("Age is not in the expected range");
|
|
774
774
|
isCorrect = false;
|
|
775
775
|
queryResultErrors.age.range = {
|
|
@@ -857,7 +857,7 @@ export class ZKPassport {
|
|
|
857
857
|
if (queryResult.birthdate) {
|
|
858
858
|
if (queryResult.birthdate.gte &&
|
|
859
859
|
queryResult.birthdate.gte.result &&
|
|
860
|
-
minDate
|
|
860
|
+
minDate !== queryResult.birthdate.gte.expected) {
|
|
861
861
|
console.warn("Birthdate is not greater than or equal to the expected birthdate");
|
|
862
862
|
isCorrect = false;
|
|
863
863
|
queryResultErrors.birthdate.gte = {
|
|
@@ -868,7 +868,7 @@ export class ZKPassport {
|
|
|
868
868
|
}
|
|
869
869
|
if (queryResult.birthdate.lte &&
|
|
870
870
|
queryResult.birthdate.lte.result &&
|
|
871
|
-
maxDate
|
|
871
|
+
maxDate !== queryResult.birthdate.lte.expected) {
|
|
872
872
|
console.warn("Birthdate is not less than the expected birthdate");
|
|
873
873
|
isCorrect = false;
|
|
874
874
|
queryResultErrors.birthdate.lte = {
|
|
@@ -879,8 +879,8 @@ export class ZKPassport {
|
|
|
879
879
|
}
|
|
880
880
|
if (queryResult.birthdate.range) {
|
|
881
881
|
if (queryResult.birthdate.range.result &&
|
|
882
|
-
(minDate
|
|
883
|
-
maxDate
|
|
882
|
+
(minDate !== queryResult.birthdate.range.expected[0] ||
|
|
883
|
+
maxDate !== queryResult.birthdate.range.expected[1])) {
|
|
884
884
|
console.warn("Birthdate is not in the expected range");
|
|
885
885
|
isCorrect = false;
|
|
886
886
|
queryResultErrors.birthdate.range = {
|
|
@@ -961,7 +961,7 @@ export class ZKPassport {
|
|
|
961
961
|
if (queryResult.expiry_date) {
|
|
962
962
|
if (queryResult.expiry_date.gte &&
|
|
963
963
|
queryResult.expiry_date.gte.result &&
|
|
964
|
-
minDate
|
|
964
|
+
minDate !== queryResult.expiry_date.gte.expected) {
|
|
965
965
|
console.warn("Expiry date is not greater than or equal to the expected expiry date");
|
|
966
966
|
isCorrect = false;
|
|
967
967
|
queryResultErrors.expiry_date.gte = {
|
|
@@ -972,7 +972,7 @@ export class ZKPassport {
|
|
|
972
972
|
}
|
|
973
973
|
if (queryResult.expiry_date.lte &&
|
|
974
974
|
queryResult.expiry_date.lte.result &&
|
|
975
|
-
maxDate
|
|
975
|
+
maxDate !== queryResult.expiry_date.lte.expected) {
|
|
976
976
|
console.warn("Expiry date is not less than the expected expiry date");
|
|
977
977
|
isCorrect = false;
|
|
978
978
|
queryResultErrors.expiry_date.lte = {
|
|
@@ -983,8 +983,8 @@ export class ZKPassport {
|
|
|
983
983
|
}
|
|
984
984
|
if (queryResult.expiry_date.range) {
|
|
985
985
|
if (queryResult.expiry_date.range.result &&
|
|
986
|
-
(minDate
|
|
987
|
-
maxDate
|
|
986
|
+
(minDate !== queryResult.expiry_date.range.expected[0] ||
|
|
987
|
+
maxDate !== queryResult.expiry_date.range.expected[1])) {
|
|
988
988
|
console.warn("Expiry date is not in the expected range");
|
|
989
989
|
isCorrect = false;
|
|
990
990
|
queryResultErrors.expiry_date.range = {
|
package/package.json
CHANGED
|
@@ -1,55 +1,52 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zkpassport/sdk",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.7-beta.1",
|
|
4
4
|
"description": "Privacy-preserving identity verification using passports and ID cards",
|
|
5
|
-
"
|
|
6
|
-
"
|
|
7
|
-
"types": "./dist/esm/index.d.ts",
|
|
5
|
+
"author": "ZKPassport",
|
|
6
|
+
"license": "Apache-2.0",
|
|
8
7
|
"type": "module",
|
|
9
|
-
"
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
"
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
"prepublishOnly": "npm run test && npm run build",
|
|
17
|
-
"build": "npm run build:esm && npm run build:cjs",
|
|
18
|
-
"build:esm": "tsc -p tsconfig.json",
|
|
19
|
-
"build:cjs": "tsc -p tsconfig.cjs.json",
|
|
20
|
-
"test": "NODE_OPTIONS='--require ts-node/register' NODE_NO_WARNINGS=1 node node_modules/.bin/jest --no-cache --passWithNoTests --runInBand **/*.test.ts",
|
|
21
|
-
"test:debug": "NODE_OPTIONS='--require ts-node/register' NODE_NO_WARNINGS=1 node --inspect-brk=0.0.0.0 node_modules/.bin/jest --no-cache --passWithNoTests --runInBand **/*.test.ts",
|
|
22
|
-
"deploy": "npm publish --access public"
|
|
8
|
+
"main": "./dist/esm/index.js",
|
|
9
|
+
"types": "./dist/esm/index.d.ts",
|
|
10
|
+
"exports": {
|
|
11
|
+
".": {
|
|
12
|
+
"import": "./dist/esm/index.js",
|
|
13
|
+
"require": "./dist/cjs/index.cjs"
|
|
14
|
+
}
|
|
23
15
|
},
|
|
24
|
-
"
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
"
|
|
29
|
-
"
|
|
30
|
-
"
|
|
31
|
-
"@jest/globals": "^29.7.0",
|
|
32
|
-
"@types/jest": "^29.5.14",
|
|
33
|
-
"@types/node": "^22.10.9",
|
|
34
|
-
"@types/pako": "^2.0.3",
|
|
35
|
-
"@types/ws": "^8.5.12",
|
|
36
|
-
"jest": "^29.7.0",
|
|
37
|
-
"ts-node": "^10.9.2",
|
|
38
|
-
"typescript": "^5.6.2"
|
|
16
|
+
"scripts": {
|
|
17
|
+
"test": "bun test",
|
|
18
|
+
"coverage": "bun test --coverage",
|
|
19
|
+
"check": "tsc --noEmit && prettier -c src tests",
|
|
20
|
+
"format": "prettier -c -w src tests",
|
|
21
|
+
"build": "rimraf dist && tsc && bun run scripts/fix-aliases.mjs && tsup",
|
|
22
|
+
"prepublishOnly": "./scripts/prepublish.sh"
|
|
39
23
|
},
|
|
24
|
+
"files": [
|
|
25
|
+
"dist/esm",
|
|
26
|
+
"dist/cjs"
|
|
27
|
+
],
|
|
28
|
+
"keywords": [
|
|
29
|
+
"zkpassport",
|
|
30
|
+
"zkpassport-sdk",
|
|
31
|
+
"sdk"
|
|
32
|
+
],
|
|
40
33
|
"dependencies": {
|
|
41
34
|
"@aztec/bb.js": "^0.82.2",
|
|
42
35
|
"@noble/ciphers": "^1.2.1",
|
|
43
36
|
"@noble/hashes": "^1.7.2",
|
|
44
37
|
"@noble/secp256k1": "^2.2.3",
|
|
45
38
|
"@obsidion/bridge": "^0.10.2",
|
|
46
|
-
"@zkpassport/registry": "
|
|
47
|
-
"@zkpassport/utils": "
|
|
39
|
+
"@zkpassport/registry": "0.5.2",
|
|
40
|
+
"@zkpassport/utils": "0.16.2",
|
|
48
41
|
"buffer": "^6.0.3",
|
|
49
42
|
"i18n-iso-countries": "^7.12.0",
|
|
50
43
|
"pako": "^2.1.0",
|
|
51
44
|
"viem": "^2.27.2",
|
|
52
45
|
"ws": "^8.18.0"
|
|
53
46
|
},
|
|
54
|
-
"
|
|
47
|
+
"devDependencies": {
|
|
48
|
+
"@types/pako": "^2.0.3",
|
|
49
|
+
"@types/ws": "^8.5.12"
|
|
50
|
+
},
|
|
51
|
+
"packageManager": "bun@1.2.13"
|
|
55
52
|
}
|