@zkpassport/sdk 0.1.2 → 0.2.0

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.
Files changed (54) hide show
  1. package/README.md +80 -25
  2. package/dist/cjs/encryption.js +69 -0
  3. package/dist/cjs/index.d.ts +191 -0
  4. package/dist/cjs/index.js +857 -0
  5. package/dist/{json-rpc.d.ts → cjs/json-rpc.d.ts} +1 -1
  6. package/dist/cjs/json-rpc.js +48 -0
  7. package/dist/{logger.js → cjs/logger.js} +5 -38
  8. package/dist/cjs/mobile.js +131 -0
  9. package/dist/{websocket.js → cjs/websocket.js} +2 -2
  10. package/dist/esm/encryption.d.ts +7 -0
  11. package/dist/esm/encryption.js +40 -0
  12. package/dist/esm/index.d.ts +191 -0
  13. package/dist/esm/index.js +846 -0
  14. package/dist/esm/json-rpc.d.ts +6 -0
  15. package/dist/esm/json-rpc.js +41 -0
  16. package/dist/esm/logger.d.ts +7 -0
  17. package/dist/esm/logger.js +37 -0
  18. package/dist/esm/mobile.d.ts +39 -0
  19. package/dist/esm/mobile.js +126 -0
  20. package/dist/esm/websocket.d.ts +2 -0
  21. package/dist/esm/websocket.js +15 -0
  22. package/package.json +15 -7
  23. package/src/index.ts +974 -63
  24. package/src/json-rpc.ts +6 -2
  25. package/src/mobile.ts +14 -5
  26. package/tsconfig.json +14 -9
  27. package/dist/constants/index.d.ts +0 -13
  28. package/dist/constants/index.js +0 -52
  29. package/dist/encryption.js +0 -126
  30. package/dist/index.d.ts +0 -79
  31. package/dist/index.js +0 -384
  32. package/dist/json-rpc.js +0 -105
  33. package/dist/mobile.js +0 -253
  34. package/dist/types/countries.d.ts +0 -1
  35. package/dist/types/countries.js +0 -2
  36. package/dist/types/credentials.d.ts +0 -17
  37. package/dist/types/credentials.js +0 -2
  38. package/dist/types/index.d.ts +0 -4
  39. package/dist/types/index.js +0 -2
  40. package/dist/types/json-rpc.d.ts +0 -12
  41. package/dist/types/json-rpc.js +0 -2
  42. package/dist/types/query-result.d.ts +0 -46
  43. package/dist/types/query-result.js +0 -2
  44. package/src/circuits/proof_age.json +0 -1
  45. package/src/constants/index.ts +0 -54
  46. package/src/types/countries.ts +0 -278
  47. package/src/types/credentials.ts +0 -40
  48. package/src/types/index.ts +0 -13
  49. package/src/types/json-rpc.ts +0 -13
  50. package/src/types/query-result.ts +0 -49
  51. /package/dist/{encryption.d.ts → cjs/encryption.d.ts} +0 -0
  52. /package/dist/{logger.d.ts → cjs/logger.d.ts} +0 -0
  53. /package/dist/{mobile.d.ts → cjs/mobile.d.ts} +0 -0
  54. /package/dist/{websocket.d.ts → cjs/websocket.d.ts} +0 -0
@@ -1,4 +1,4 @@
1
- import { JsonRpcRequest, JsonRpcResponse } from './types/json-rpc';
1
+ import type { JsonRpcRequest, JsonRpcResponse } from '@zkpassport/utils';
2
2
  import { WebSocketClient } from './websocket';
3
3
  export declare function createJsonRpcRequest(method: string, params: any): JsonRpcRequest;
4
4
  export declare function createEncryptedJsonRpcRequest(method: string, params: any, sharedSecret: Uint8Array, topic: string): Promise<JsonRpcRequest>;
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createJsonRpcRequest = createJsonRpcRequest;
4
+ exports.createEncryptedJsonRpcRequest = createEncryptedJsonRpcRequest;
5
+ exports.sendEncryptedJsonRpcRequest = sendEncryptedJsonRpcRequest;
6
+ exports.createJsonRpcResponse = createJsonRpcResponse;
7
+ const tslib_1 = require("tslib");
8
+ const crypto_1 = require("crypto");
9
+ const encryption_1 = require("./encryption");
10
+ const logger_1 = tslib_1.__importDefault(require("./logger"));
11
+ function createJsonRpcRequest(method, params) {
12
+ return {
13
+ jsonrpc: '2.0',
14
+ id: (0, crypto_1.randomBytes)(16).toString('hex'),
15
+ method,
16
+ params,
17
+ };
18
+ }
19
+ async function createEncryptedJsonRpcRequest(method, params, sharedSecret, topic) {
20
+ const encryptedMessage = await (0, encryption_1.encrypt)(JSON.stringify({ method, params: params || {} }), sharedSecret, topic);
21
+ return createJsonRpcRequest('encryptedMessage', {
22
+ payload: Buffer.from(encryptedMessage).toString('base64'),
23
+ });
24
+ }
25
+ async function sendEncryptedJsonRpcRequest(method, params, sharedSecret, topic, wsClient) {
26
+ try {
27
+ const message = { method, params: params || {} };
28
+ const encryptedMessage = await (0, encryption_1.encrypt)(JSON.stringify(message), sharedSecret, topic);
29
+ const request = createJsonRpcRequest('encryptedMessage', {
30
+ payload: Buffer.from(encryptedMessage).toString('base64'),
31
+ });
32
+ logger_1.default.debug('Sending encrypted message (original):', message);
33
+ logger_1.default.debug('Sending encrypted message (encrypted):', request);
34
+ wsClient.send(JSON.stringify(request));
35
+ return true;
36
+ }
37
+ catch (error) {
38
+ logger_1.default.error('Error sending encrypted message:', error);
39
+ return false;
40
+ }
41
+ }
42
+ function createJsonRpcResponse(id, result) {
43
+ return {
44
+ jsonrpc: '2.0',
45
+ id,
46
+ result,
47
+ };
48
+ }
@@ -2,15 +2,6 @@
2
2
  // import { createLogger, transports, format } from 'winston'
3
3
  // import colors from 'colors/safe'
4
4
  // import util from 'util'
5
- var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
6
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
7
- if (ar || !(i in from)) {
8
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
9
- ar[i] = from[i];
10
- }
11
- }
12
- return to.concat(ar || Array.prototype.slice.call(from));
13
- };
14
5
  Object.defineProperty(exports, "__esModule", { value: true });
15
6
  // const logger = createLogger({
16
7
  // level: 'debug',
@@ -39,34 +30,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
39
30
  // warn: (message: string, ...args: any[]) => logger.warn(message, { additionalInfo: args }),
40
31
  // error: (message: string, ...args: any[]) => logger.error(message, { additionalInfo: args }),
41
32
  // }
42
- var customLogger = {
43
- debug: function (message) {
44
- var args = [];
45
- for (var _i = 1; _i < arguments.length; _i++) {
46
- args[_i - 1] = arguments[_i];
47
- }
48
- return console.debug.apply(console, __spreadArray([message], args, false));
49
- },
50
- info: function (message) {
51
- var args = [];
52
- for (var _i = 1; _i < arguments.length; _i++) {
53
- args[_i - 1] = arguments[_i];
54
- }
55
- return console.info.apply(console, __spreadArray([message], args, false));
56
- },
57
- warn: function (message) {
58
- var args = [];
59
- for (var _i = 1; _i < arguments.length; _i++) {
60
- args[_i - 1] = arguments[_i];
61
- }
62
- return console.warn.apply(console, __spreadArray([message], args, false));
63
- },
64
- error: function (message) {
65
- var args = [];
66
- for (var _i = 1; _i < arguments.length; _i++) {
67
- args[_i - 1] = arguments[_i];
68
- }
69
- return console.error.apply(console, __spreadArray([message], args, false));
70
- },
33
+ const customLogger = {
34
+ debug: (message, ...args) => console.debug(message, ...args),
35
+ info: (message, ...args) => console.info(message, ...args),
36
+ warn: (message, ...args) => console.warn(message, ...args),
37
+ error: (message, ...args) => console.error(message, ...args),
71
38
  };
72
39
  exports.default = customLogger;
@@ -0,0 +1,131 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ZkPassportProver = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const utils_1 = require("@noble/ciphers/utils");
6
+ const websocket_1 = require("./websocket");
7
+ const json_rpc_1 = require("./json-rpc");
8
+ const encryption_1 = require("./encryption");
9
+ const logger_1 = tslib_1.__importDefault(require("./logger"));
10
+ class ZkPassportProver {
11
+ constructor() {
12
+ this.topicToKeyPair = {};
13
+ this.topicToWebSocketClient = {};
14
+ this.topicToRemoteDomainVerified = {};
15
+ this.topicToSharedSecret = {};
16
+ this.topicToRemotePublicKey = {};
17
+ this.onDomainVerifiedCallbacks = {};
18
+ this.onBridgeConnectCallbacks = {};
19
+ this.onWebsiteDomainVerifyFailureCallbacks = {};
20
+ }
21
+ /**
22
+ * @notice Handle an encrypted message.
23
+ * @param request The request.
24
+ * @param outerRequest The outer request.
25
+ */
26
+ async handleEncryptedMessage(topic, request, outerRequest) {
27
+ logger_1.default.debug('Received encrypted message:', request);
28
+ if (request.method === 'hello') {
29
+ logger_1.default.info(`Successfully verified origin domain name: ${outerRequest.origin}`);
30
+ this.topicToRemoteDomainVerified[topic] = true;
31
+ await Promise.all(this.onDomainVerifiedCallbacks[topic].map((callback) => callback()));
32
+ }
33
+ else if (request.method === 'closed_page') {
34
+ // TODO: Implement
35
+ }
36
+ }
37
+ /**
38
+ * @notice Scan a credentirequest QR code.
39
+ * @returns
40
+ */
41
+ async scan(url, { keyPairOverride, } = {}) {
42
+ const parsedUrl = new URL(url);
43
+ const domain = parsedUrl.searchParams.get('d');
44
+ const topic = parsedUrl.searchParams.get('t');
45
+ const pubkeyHex = parsedUrl.searchParams.get('p');
46
+ if (!domain || !topic || !pubkeyHex) {
47
+ throw new Error('Invalid URL: missing required parameters');
48
+ }
49
+ const pubkey = new Uint8Array(Buffer.from(pubkeyHex, 'hex'));
50
+ this.domain = domain;
51
+ const keyPair = keyPairOverride || (await (0, encryption_1.generateECDHKeyPair)());
52
+ this.topicToKeyPair[topic] = {
53
+ privateKey: keyPair.privateKey,
54
+ publicKey: keyPair.publicKey,
55
+ };
56
+ this.topicToRemotePublicKey[topic] = pubkey;
57
+ this.topicToSharedSecret[topic] = await (0, encryption_1.getSharedSecret)((0, utils_1.bytesToHex)(keyPair.privateKey), (0, utils_1.bytesToHex)(pubkey));
58
+ this.topicToRemoteDomainVerified[topic] = false;
59
+ this.onDomainVerifiedCallbacks[topic] = [];
60
+ this.onBridgeConnectCallbacks[topic] = [];
61
+ // Set up WebSocket connection
62
+ const wsClient = (0, websocket_1.getWebSocketClient)(`wss://bridge.zkpassport.id?topic=${topic}&pubkey=${(0, utils_1.bytesToHex)(keyPair.publicKey)}`);
63
+ this.topicToWebSocketClient[topic] = wsClient;
64
+ wsClient.onopen = async () => {
65
+ logger_1.default.info('[mobile] WebSocket connection established');
66
+ await Promise.all(this.onBridgeConnectCallbacks[topic].map((callback) => callback()));
67
+ // Server sends handshake automatically (when it sees a pubkey in websocket URI)
68
+ // wsClient.send(
69
+ // JSON.stringify(
70
+ // createJsonRpcRequest('handshake', {
71
+ // pubkey: bytesToHex(keyPair.publicKey),
72
+ // }),
73
+ // ),
74
+ // )
75
+ };
76
+ wsClient.addEventListener('message', async (event) => {
77
+ logger_1.default.info('[mobile] Received message:', event.data);
78
+ try {
79
+ const data = JSON.parse(event.data);
80
+ const originDomain = data.origin ? new URL(data.origin).hostname : undefined;
81
+ // Origin domain must match domain in QR code
82
+ if (originDomain !== this.domain) {
83
+ logger_1.default.warn(`[mobile] Origin does not match domain in QR code. Expected ${this.domain} but got ${originDomain}`);
84
+ return;
85
+ }
86
+ if (data.method === 'encryptedMessage') {
87
+ // Decode the payload from base64 to Uint8Array
88
+ const payload = new Uint8Array(atob(data.params.payload)
89
+ .split('')
90
+ .map((c) => c.charCodeAt(0)));
91
+ try {
92
+ // Decrypt the payload using the shared secret
93
+ const decrypted = await (0, encryption_1.decrypt)(payload, this.topicToSharedSecret[topic], topic);
94
+ const decryptedJson = JSON.parse(decrypted);
95
+ await this.handleEncryptedMessage(topic, decryptedJson, data);
96
+ }
97
+ catch (error) {
98
+ logger_1.default.error('[mobile] Error decrypting message:', error);
99
+ }
100
+ }
101
+ }
102
+ catch (error) {
103
+ logger_1.default.error('[mobile] Error:', error);
104
+ }
105
+ });
106
+ wsClient.onerror = (error) => {
107
+ logger_1.default.error('[mobile] WebSocket error:', error);
108
+ };
109
+ return {
110
+ domain: this.domain,
111
+ requestId: topic,
112
+ isBridgeConnected: () => this.topicToWebSocketClient[topic].readyState === WebSocket.OPEN,
113
+ isDomainVerified: () => this.topicToRemoteDomainVerified[topic] === true,
114
+ onDomainVerified: (callback) => this.onDomainVerifiedCallbacks[topic].push(callback),
115
+ onBridgeConnect: (callback) => this.onBridgeConnectCallbacks[topic].push(callback),
116
+ notifyReject: async () => {
117
+ await (0, json_rpc_1.sendEncryptedJsonRpcRequest)('reject', null, this.topicToSharedSecret[topic], topic, this.topicToWebSocketClient[topic]);
118
+ },
119
+ notifyAccept: async () => {
120
+ await (0, json_rpc_1.sendEncryptedJsonRpcRequest)('accept', null, this.topicToSharedSecret[topic], topic, this.topicToWebSocketClient[topic]);
121
+ },
122
+ notifyDone: async (proof) => {
123
+ await (0, json_rpc_1.sendEncryptedJsonRpcRequest)('done', { proof }, this.topicToSharedSecret[topic], topic, this.topicToWebSocketClient[topic]);
124
+ },
125
+ notifyError: async (error) => {
126
+ await (0, json_rpc_1.sendEncryptedJsonRpcRequest)('error', { error }, this.topicToSharedSecret[topic], topic, this.topicToWebSocketClient[topic]);
127
+ },
128
+ };
129
+ }
130
+ }
131
+ exports.ZkPassportProver = ZkPassportProver;
@@ -8,8 +8,8 @@ function getWebSocketClient(url, origin) {
8
8
  }
9
9
  else {
10
10
  // Node.js environment
11
- var WebSocket_1 = require('ws');
12
- return new WebSocket_1(url, {
11
+ const WebSocket = require('ws');
12
+ return new WebSocket(url, {
13
13
  headers: {
14
14
  Origin: origin || 'nodejs',
15
15
  },
@@ -0,0 +1,7 @@
1
+ export declare function generateECDHKeyPair(): Promise<{
2
+ privateKey: Uint8Array;
3
+ publicKey: Uint8Array;
4
+ }>;
5
+ export declare function getSharedSecret(privateKey: string, publicKey: string): Promise<Uint8Array>;
6
+ export declare function encrypt(message: string, sharedSecret: Uint8Array, topic: string): Promise<Uint8Array>;
7
+ export declare function decrypt(ciphertext: Uint8Array, sharedSecret: Uint8Array, topic: string): Promise<string>;
@@ -0,0 +1,40 @@
1
+ import { gcm } from '@noble/ciphers/aes';
2
+ import { utf8ToBytes } from '@noble/ciphers/utils';
3
+ async function sha256Truncate(topic) {
4
+ const encoder = new TextEncoder();
5
+ const data = encoder.encode(topic);
6
+ const hashBuffer = await crypto.subtle.digest('SHA-256', data);
7
+ const fullHashArray = new Uint8Array(hashBuffer);
8
+ const truncatedHashArray = fullHashArray.slice(0, 12);
9
+ return truncatedHashArray;
10
+ }
11
+ export async function generateECDHKeyPair() {
12
+ const secp256k1 = await import('@noble/secp256k1');
13
+ const privKey = secp256k1.utils.randomPrivateKey();
14
+ const pubKey = secp256k1.getPublicKey(privKey);
15
+ return {
16
+ privateKey: privKey,
17
+ publicKey: pubKey,
18
+ };
19
+ }
20
+ export async function getSharedSecret(privateKey, publicKey) {
21
+ const secp256k1 = await import('@noble/secp256k1');
22
+ const sharedSecret = secp256k1.getSharedSecret(privateKey, publicKey);
23
+ return sharedSecret.slice(0, 32);
24
+ }
25
+ export async function encrypt(message, sharedSecret, topic) {
26
+ // Nonce must be 12 bytes
27
+ const nonce = await sha256Truncate(topic);
28
+ const aes = gcm(sharedSecret, nonce);
29
+ const data = utf8ToBytes(message);
30
+ const ciphertext = aes.encrypt(data);
31
+ return ciphertext;
32
+ }
33
+ export async function decrypt(ciphertext, sharedSecret, topic) {
34
+ // Nonce must be 12 bytes
35
+ const nonce = await sha256Truncate(topic);
36
+ const aes = gcm(sharedSecret, nonce);
37
+ const data = aes.decrypt(ciphertext);
38
+ const dataString = new TextDecoder().decode(data);
39
+ return dataString;
40
+ }
@@ -0,0 +1,191 @@
1
+ import { type DisclosableIDCredential, type IDCredential, type IDCredentialValue, type NumericalIDCredential, type ProofResult, type QueryResult } from '@zkpassport/utils';
2
+ export type * from '@zkpassport/utils';
3
+ export { SANCTIONED_COUNTRIES, EU_COUNTRIES, EEA_COUNTRIES, SCHENGEN_COUNTRIES, ASEAN_COUNTRIES, MERCOSUR_COUNTRIES, } from '@zkpassport/utils';
4
+ export type QueryBuilderResult = {
5
+ /**
6
+ * The URL of the request.
7
+ *
8
+ * You can either encode the URL in a QR code or let the user click the link
9
+ * to this URL on your website if they're visiting your website on their phone.
10
+ */
11
+ url: string;
12
+ /**
13
+ * The id of the request.
14
+ */
15
+ requestId: string;
16
+ /**
17
+ * Called when the user has scanned the QR code or clicked the link to the request.
18
+ *
19
+ * This means the user is currently viewing the request popup with your website information
20
+ * and the information requested from them.
21
+ */
22
+ onRequestReceived: (callback: () => void) => void;
23
+ /**
24
+ * Called when the user has accepted the request and
25
+ * started to generate the proof on their phone.
26
+ */
27
+ onGeneratingProof: (callback: () => void) => void;
28
+ /**
29
+ * Called when the SDK successfully connects to the bridge with the mobile app.
30
+ */
31
+ onBridgeConnect: (callback: () => void) => void;
32
+ /**
33
+ * Called when the user has generated a proof.
34
+ *
35
+ * There is a minimum of 4 proofs, but there can be more depending
36
+ * on the type of information requested from the user.
37
+ */
38
+ onProofGenerated: (callback: (proof: ProofResult) => void) => void;
39
+ /**
40
+ * Called when the user has sent the query result.
41
+ *
42
+ * The response contains the unique identifier associated to the user,
43
+ * your domain name and chosen scope, along with the query result and whether
44
+ * the proofs were successfully verified.
45
+ */
46
+ onResult: (callback: (response: {
47
+ uniqueIdentifier: string | undefined;
48
+ verified: boolean;
49
+ result: QueryResult;
50
+ }) => void) => void;
51
+ /**
52
+ * Called when the user has rejected the request.
53
+ */
54
+ onReject: (callback: () => void) => void;
55
+ /**
56
+ * Called when an error occurs, such as one of the requirements not being met
57
+ * or a proof failing to be generated.
58
+ */
59
+ onError: (callback: (error: string) => void) => void;
60
+ /**
61
+ * @returns true if the bridge with the mobile app is connected
62
+ */
63
+ isBridgeConnected: () => boolean;
64
+ /**
65
+ * Get if the user has scanned the QR code or the link to this request
66
+ * @returns true if the request has been received by the user on their phone
67
+ */
68
+ requestReceived: () => boolean;
69
+ };
70
+ export type QueryBuilder = {
71
+ /**
72
+ * Requires this attribute to be equal to the provided value.
73
+ * @param key The attribute to compare.
74
+ * @param value The value of the attribute you require.
75
+ */
76
+ eq: <T extends IDCredential>(key: T, value: IDCredentialValue<T>) => QueryBuilder;
77
+ /**
78
+ * Requires this attribute to be greater than or equal to the provided value.
79
+ * @param key The attribute to compare.
80
+ * @param value The value of the attribute you require.
81
+ */
82
+ gte: <T extends NumericalIDCredential>(key: T, value: IDCredentialValue<T>) => QueryBuilder;
83
+ /**
84
+ * Requires this attribute to be less than or equal to the provided value.
85
+ * @param key The attribute to compare.
86
+ * @param value The value of the attribute you require.
87
+ */
88
+ lte: <T extends 'birthdate' | 'expiry_date'>(key: T, value: IDCredentialValue<T>) => QueryBuilder;
89
+ /**
90
+ * Requires this attribute to be less than the provided value.
91
+ * @param key The attribute to compare.
92
+ * @param value The value of the attribute you require.
93
+ */
94
+ lt: <T extends 'age'>(key: T, value: IDCredentialValue<T>) => QueryBuilder;
95
+ /**
96
+ * Requires this attribute to be included in the provided range.
97
+ * @param key The attribute to compare.
98
+ * @param start The start of the range.
99
+ * @param end The end of the range.
100
+ */
101
+ range: <T extends NumericalIDCredential>(key: T, start: IDCredentialValue<T>, end: IDCredentialValue<T>) => QueryBuilder;
102
+ /**
103
+ * Requires this attribute to be included in the provided list.
104
+ * @param key The attribute to compare.
105
+ * @param value The list of values to check inclusion against.
106
+ */
107
+ in: <T extends 'nationality'>(key: T, value: IDCredentialValue<T>[]) => QueryBuilder;
108
+ /**
109
+ * Requires this attribute to be excluded from the provided list.
110
+ * @param key The attribute to compare.
111
+ * @param value The list of values to check exclusion against.
112
+ */
113
+ out: <T extends 'nationality'>(key: T, value: IDCredentialValue<T>[]) => QueryBuilder;
114
+ /**
115
+ * Requires this attribute to be disclosed.
116
+ * @param key The attribute to disclose.
117
+ */
118
+ disclose: (key: DisclosableIDCredential) => QueryBuilder;
119
+ /**
120
+ * Builds the request.
121
+ *
122
+ * This will return the URL of the request, which you can either encode in a QR code
123
+ * or provide as a link to the user if they're visiting your website on their phone.
124
+ * It also returns all the callbacks you can use to handle the user's response.
125
+ */
126
+ done: () => QueryBuilderResult;
127
+ };
128
+ export declare class ZKPassport {
129
+ private domain;
130
+ private topicToConfig;
131
+ private topicToKeyPair;
132
+ private topicToWebSocketClient;
133
+ private topicToSharedSecret;
134
+ private topicToRequestReceived;
135
+ private topicToService;
136
+ private topicToProofs;
137
+ private onRequestReceivedCallbacks;
138
+ private onGeneratingProofCallbacks;
139
+ private onBridgeConnectCallbacks;
140
+ private onProofGeneratedCallbacks;
141
+ private onResultCallbacks;
142
+ private onRejectCallbacks;
143
+ private onErrorCallbacks;
144
+ constructor(_domain?: string);
145
+ /**
146
+ * @notice Handle an encrypted message.
147
+ * @param request The request.
148
+ * @param outerRequest The outer request.
149
+ */
150
+ private handleEncryptedMessage;
151
+ private getZkPassportRequest;
152
+ /**
153
+ * @notice Create a new request.
154
+ * @returns The query builder object.
155
+ */
156
+ request({ name, logo, purpose, scope, topicOverride, keyPairOverride, }: {
157
+ name: string;
158
+ logo: string;
159
+ purpose: string;
160
+ scope?: string;
161
+ topicOverride?: string;
162
+ keyPairOverride?: {
163
+ privateKey: Uint8Array;
164
+ publicKey: Uint8Array;
165
+ };
166
+ }): Promise<QueryBuilder>;
167
+ private checkPublicInputs;
168
+ /**
169
+ * @notice Verify the proofs received from the mobile app.
170
+ * @param requestId The request ID.
171
+ * @param proofs The proofs to verify.
172
+ * @param queryResult The query result to verify against
173
+ * @returns An object containing the unique identifier associated to the user
174
+ * and a boolean indicating whether the proofs were successfully verified.
175
+ */
176
+ verify(requestId: string, proofs?: Array<ProofResult>, queryResult?: QueryResult): Promise<{
177
+ uniqueIdentifier: string | undefined;
178
+ verified: boolean;
179
+ }>;
180
+ /**
181
+ * @notice Returns the URL of the request.
182
+ * @param requestId The request ID.
183
+ * @returns The URL of the request.
184
+ */
185
+ getUrl(requestId: string): string;
186
+ /**
187
+ * @notice Cancels a request by closing the WebSocket connection and deleting the associated data.
188
+ * @param requestId The request ID.
189
+ */
190
+ cancelRequest(requestId: string): void;
191
+ }