@zkproofport-app/sdk 0.1.2-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/LICENSE +21 -0
- package/README.md +469 -0
- package/dist/ProofportSDK.d.ts +1011 -0
- package/dist/constants.d.ts +223 -0
- package/dist/deeplink.d.ts +192 -0
- package/dist/index.d.ts +29 -0
- package/dist/index.esm.js +5225 -0
- package/dist/index.esm.js.map +1 -0
- package/dist/index.js +2364 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +5225 -0
- package/dist/index.mjs.map +1 -0
- package/dist/qrcode.d.ts +120 -0
- package/dist/types.d.ts +434 -0
- package/dist/verifier.d.ts +224 -0
- package/package.json +75 -0
package/dist/qrcode.d.ts
ADDED
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* QR Code utilities for ZKProofport SDK
|
|
3
|
+
*/
|
|
4
|
+
import type { ProofRequest, QRCodeOptions } from './types';
|
|
5
|
+
/**
|
|
6
|
+
* Generates a QR code as a base64-encoded PNG data URL.
|
|
7
|
+
*
|
|
8
|
+
* Creates a scannable QR code image from a proof request or deep link URL.
|
|
9
|
+
* The returned data URL can be used directly in HTML img src attributes.
|
|
10
|
+
* Validates that the encoded data doesn't exceed the maximum QR code size.
|
|
11
|
+
*
|
|
12
|
+
* @param requestOrUrl - Proof request object or pre-built deep link URL
|
|
13
|
+
* @param options - QR code appearance options (width, colors, error correction)
|
|
14
|
+
* @param scheme - Custom URL scheme (only used if requestOrUrl is a ProofRequest)
|
|
15
|
+
* @returns Promise resolving to base64 PNG data URL (e.g., "data:image/png;base64,...")
|
|
16
|
+
*
|
|
17
|
+
* @throws {Error} If the URL exceeds MAX_QR_DATA_SIZE (2953 bytes)
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```typescript
|
|
21
|
+
* const request: ProofRequest = {
|
|
22
|
+
* requestId: generateRequestId(),
|
|
23
|
+
* circuit: 'coinbase_attestation',
|
|
24
|
+
* inputs: { scope: 'myapp.com' },
|
|
25
|
+
* createdAt: Date.now()
|
|
26
|
+
* };
|
|
27
|
+
*
|
|
28
|
+
* const dataUrl = await generateQRCodeDataUrl(request, {
|
|
29
|
+
* width: 400,
|
|
30
|
+
* darkColor: '#000000',
|
|
31
|
+
* lightColor: '#ffffff'
|
|
32
|
+
* });
|
|
33
|
+
*
|
|
34
|
+
* // Use in HTML: <img src={dataUrl} alt="Scan to prove" />
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
export declare function generateQRCodeDataUrl(requestOrUrl: ProofRequest | string, options?: QRCodeOptions, scheme?: string): Promise<string>;
|
|
38
|
+
/**
|
|
39
|
+
* Generates a QR code as an SVG string.
|
|
40
|
+
*
|
|
41
|
+
* Creates a scalable vector graphics QR code that can be embedded directly in HTML
|
|
42
|
+
* or saved to a file. SVG QR codes scale perfectly at any size and have smaller
|
|
43
|
+
* file sizes than raster formats.
|
|
44
|
+
*
|
|
45
|
+
* @param requestOrUrl - Proof request object or pre-built deep link URL
|
|
46
|
+
* @param options - QR code appearance options (width, colors, error correction)
|
|
47
|
+
* @param scheme - Custom URL scheme (only used if requestOrUrl is a ProofRequest)
|
|
48
|
+
* @returns Promise resolving to SVG markup string
|
|
49
|
+
*
|
|
50
|
+
* @throws {Error} If the URL exceeds MAX_QR_DATA_SIZE (2953 bytes)
|
|
51
|
+
*
|
|
52
|
+
* @example
|
|
53
|
+
* ```typescript
|
|
54
|
+
* const request: ProofRequest = { ... };
|
|
55
|
+
* const svg = await generateQRCodeSVG(request, { width: 300 });
|
|
56
|
+
*
|
|
57
|
+
* // Embed directly: <div dangerouslySetInnerHTML={{ __html: svg }} />
|
|
58
|
+
* // Or save to file: fs.writeFileSync('qr.svg', svg);
|
|
59
|
+
* ```
|
|
60
|
+
*/
|
|
61
|
+
export declare function generateQRCodeSVG(requestOrUrl: ProofRequest | string, options?: QRCodeOptions, scheme?: string): Promise<string>;
|
|
62
|
+
/**
|
|
63
|
+
* Renders a QR code directly to an HTML canvas element.
|
|
64
|
+
*
|
|
65
|
+
* Browser-only function that draws a QR code onto an existing canvas element.
|
|
66
|
+
* Useful for interactive applications or when you need direct canvas manipulation.
|
|
67
|
+
* The canvas dimensions will be set automatically based on the width option.
|
|
68
|
+
*
|
|
69
|
+
* @param canvas - HTML canvas element to render to (must exist in DOM)
|
|
70
|
+
* @param requestOrUrl - Proof request object or pre-built deep link URL
|
|
71
|
+
* @param options - QR code appearance options (width, colors, error correction)
|
|
72
|
+
* @param scheme - Custom URL scheme (only used if requestOrUrl is a ProofRequest)
|
|
73
|
+
* @returns Promise that resolves when rendering is complete
|
|
74
|
+
*
|
|
75
|
+
* @throws {Error} If the URL exceeds MAX_QR_DATA_SIZE (2953 bytes)
|
|
76
|
+
* @throws {Error} If canvas is not a valid HTMLCanvasElement (browser only)
|
|
77
|
+
*
|
|
78
|
+
* @example
|
|
79
|
+
* ```typescript
|
|
80
|
+
* // In a React component:
|
|
81
|
+
* const canvasRef = useRef<HTMLCanvasElement>(null);
|
|
82
|
+
*
|
|
83
|
+
* useEffect(() => {
|
|
84
|
+
* if (canvasRef.current) {
|
|
85
|
+
* generateQRCodeToCanvas(canvasRef.current, request, { width: 400 });
|
|
86
|
+
* }
|
|
87
|
+
* }, [request]);
|
|
88
|
+
*
|
|
89
|
+
* return <canvas ref={canvasRef} />;
|
|
90
|
+
* ```
|
|
91
|
+
*/
|
|
92
|
+
export declare function generateQRCodeToCanvas(canvas: HTMLCanvasElement, requestOrUrl: ProofRequest | string, options?: QRCodeOptions, scheme?: string): Promise<void>;
|
|
93
|
+
/**
|
|
94
|
+
* Estimates the byte size of a QR code's encoded data.
|
|
95
|
+
*
|
|
96
|
+
* Calculates the size of the deep link URL that will be encoded in the QR code,
|
|
97
|
+
* and checks if it's within the maximum supported size (2953 bytes for QR version 40
|
|
98
|
+
* with medium error correction). Use this before generating QR codes to avoid errors.
|
|
99
|
+
*
|
|
100
|
+
* @param requestOrUrl - Proof request object or pre-built deep link URL
|
|
101
|
+
* @param scheme - Custom URL scheme (only used if requestOrUrl is a ProofRequest)
|
|
102
|
+
* @returns Object with `size` in bytes and `withinLimit` boolean flag
|
|
103
|
+
*
|
|
104
|
+
* @example
|
|
105
|
+
* ```typescript
|
|
106
|
+
* const request: ProofRequest = { ... };
|
|
107
|
+
* const { size, withinLimit } = estimateQRDataSize(request);
|
|
108
|
+
*
|
|
109
|
+
* if (!withinLimit) {
|
|
110
|
+
* console.error(`QR code too large: ${size} bytes (max 2953)`);
|
|
111
|
+
* // Consider reducing request data or splitting into multiple QR codes
|
|
112
|
+
* }
|
|
113
|
+
*
|
|
114
|
+
* // Example output: { size: 384, withinLimit: true }
|
|
115
|
+
* ```
|
|
116
|
+
*/
|
|
117
|
+
export declare function estimateQRDataSize(requestOrUrl: ProofRequest | string, scheme?: string): {
|
|
118
|
+
size: number;
|
|
119
|
+
withinLimit: boolean;
|
|
120
|
+
};
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,434 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ZKProofport SDK Types
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Supported zero-knowledge circuit types.
|
|
6
|
+
* Uses canonical circuit names matching Nargo.toml circuit definitions.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* const circuit: CircuitType = 'coinbase_attestation';
|
|
11
|
+
* ```
|
|
12
|
+
*/
|
|
13
|
+
export type CircuitType = 'coinbase_attestation' | 'coinbase_country_attestation';
|
|
14
|
+
/**
|
|
15
|
+
* Proof request lifecycle status.
|
|
16
|
+
*
|
|
17
|
+
* - `pending`: Request sent to mobile app, awaiting proof generation
|
|
18
|
+
* - `completed`: Proof successfully generated and returned
|
|
19
|
+
* - `error`: Proof generation failed
|
|
20
|
+
* - `cancelled`: Request cancelled by user
|
|
21
|
+
*/
|
|
22
|
+
export type ProofRequestStatus = 'pending' | 'completed' | 'error' | 'cancelled';
|
|
23
|
+
/**
|
|
24
|
+
* Input parameters for Coinbase KYC attestation circuit.
|
|
25
|
+
*
|
|
26
|
+
* This circuit proves a user has completed Coinbase KYC verification
|
|
27
|
+
* without revealing their identity or Coinbase account details.
|
|
28
|
+
*
|
|
29
|
+
* @property userAddress - Ethereum address to prove ownership of (optional, app will connect wallet if not provided)
|
|
30
|
+
* @property rawTransaction - Raw attestation transaction data (optional, app can fetch from Etherscan)
|
|
31
|
+
* @property scope - Application-specific identifier for proof uniqueness (e.g., dapp domain)
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* ```typescript
|
|
35
|
+
* const inputs: CoinbaseKycInputs = {
|
|
36
|
+
* userAddress: '0x1234...', // Optional
|
|
37
|
+
* scope: 'myapp.com'
|
|
38
|
+
* };
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
41
|
+
export interface CoinbaseKycInputs {
|
|
42
|
+
userAddress?: string;
|
|
43
|
+
rawTransaction?: string;
|
|
44
|
+
scope: string;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Input parameters for Coinbase Country attestation circuit.
|
|
48
|
+
*
|
|
49
|
+
* This circuit proves a user's country based on Coinbase verification,
|
|
50
|
+
* supporting both inclusion (user IS from countries) and exclusion (user is NOT from countries) checks.
|
|
51
|
+
*
|
|
52
|
+
* @property userAddress - Ethereum address to prove ownership of (optional)
|
|
53
|
+
* @property rawTransaction - Raw attestation transaction data (optional)
|
|
54
|
+
* @property countryList - List of ISO 3166-1 alpha-2 country codes (e.g., ['US', 'KR']) (required)
|
|
55
|
+
* @property isIncluded - If true, proves user IS from countries; if false, proves user is NOT from countries (required)
|
|
56
|
+
* @property scope - Application-specific identifier for proof uniqueness
|
|
57
|
+
*
|
|
58
|
+
* @example
|
|
59
|
+
* ```typescript
|
|
60
|
+
* // Prove user is from US or KR
|
|
61
|
+
* const inputs: CoinbaseCountryInputs = {
|
|
62
|
+
* countryList: ['US', 'KR'],
|
|
63
|
+
* isIncluded: true,
|
|
64
|
+
* scope: 'myapp.com'
|
|
65
|
+
* };
|
|
66
|
+
* ```
|
|
67
|
+
*/
|
|
68
|
+
export interface CoinbaseCountryInputs {
|
|
69
|
+
userAddress?: string;
|
|
70
|
+
rawTransaction?: string;
|
|
71
|
+
countryList: string[];
|
|
72
|
+
isIncluded: boolean;
|
|
73
|
+
scope: string;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Empty input type for circuits that retrieve all data from the mobile app.
|
|
77
|
+
* Used when SDK doesn't need to provide any circuit-specific parameters.
|
|
78
|
+
*/
|
|
79
|
+
export interface EmptyInputs {
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Union type of all circuit-specific input types.
|
|
83
|
+
* Each circuit type has a corresponding input interface.
|
|
84
|
+
*/
|
|
85
|
+
export type CircuitInputs = CoinbaseKycInputs | CoinbaseCountryInputs | EmptyInputs;
|
|
86
|
+
/**
|
|
87
|
+
* Zero-knowledge proof request sent to mobile app via deep link.
|
|
88
|
+
*
|
|
89
|
+
* This structure is serialized into a deep link URL that opens the ZKProofport mobile app.
|
|
90
|
+
* The app generates the proof and sends the result to the callbackUrl.
|
|
91
|
+
*
|
|
92
|
+
* @example
|
|
93
|
+
* ```typescript
|
|
94
|
+
* const request: ProofRequest = {
|
|
95
|
+
* requestId: 'req_123',
|
|
96
|
+
* circuit: 'coinbase_attestation',
|
|
97
|
+
* inputs: { scope: 'myapp.com' },
|
|
98
|
+
* dappName: 'My DApp',
|
|
99
|
+
* createdAt: Date.now(),
|
|
100
|
+
* expiresAt: Date.now() + 600000 // 10 minutes
|
|
101
|
+
* };
|
|
102
|
+
* ```
|
|
103
|
+
*/
|
|
104
|
+
export interface ProofRequest {
|
|
105
|
+
/** Unique request identifier (used to match request with response) */
|
|
106
|
+
requestId: string;
|
|
107
|
+
/** Circuit type to use for proof generation */
|
|
108
|
+
circuit: CircuitType;
|
|
109
|
+
/** Circuit-specific input parameters */
|
|
110
|
+
inputs: CircuitInputs;
|
|
111
|
+
/** @internal URL where mobile app will POST the proof response (set by relay server internally, never by SDK users) */
|
|
112
|
+
callbackUrl?: string;
|
|
113
|
+
/** Optional: Custom message to display to user in mobile app */
|
|
114
|
+
message?: string;
|
|
115
|
+
/** Optional: DApp name displayed in mobile app UI */
|
|
116
|
+
dappName?: string;
|
|
117
|
+
/** Optional: DApp icon URL displayed in mobile app UI */
|
|
118
|
+
dappIcon?: string;
|
|
119
|
+
/** Unix timestamp (ms) when request was created */
|
|
120
|
+
createdAt: number;
|
|
121
|
+
/** Optional: Unix timestamp (ms) when request expires */
|
|
122
|
+
expiresAt?: number;
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Zero-knowledge proof response received from mobile app.
|
|
126
|
+
*
|
|
127
|
+
* This structure is returned via the callbackUrl after the mobile app generates the proof.
|
|
128
|
+
* For successful proofs, includes the proof data and public inputs needed for on-chain verification.
|
|
129
|
+
*
|
|
130
|
+
* @example
|
|
131
|
+
* ```typescript
|
|
132
|
+
* const response: ProofResponse = {
|
|
133
|
+
* requestId: 'req_123',
|
|
134
|
+
* circuit: 'coinbase_attestation',
|
|
135
|
+
* status: 'completed',
|
|
136
|
+
* proof: '0x1234...',
|
|
137
|
+
* publicInputs: ['0xabcd...', '0xef01...'],
|
|
138
|
+
* numPublicInputs: 2,
|
|
139
|
+
* verifierAddress: '0x5678...',
|
|
140
|
+
* chainId: 84532,
|
|
141
|
+
* nullifier: '0x9abc...',
|
|
142
|
+
* timestamp: Date.now()
|
|
143
|
+
* };
|
|
144
|
+
* ```
|
|
145
|
+
*/
|
|
146
|
+
export interface ProofResponse {
|
|
147
|
+
/** Original request ID (matches ProofRequest.requestId) */
|
|
148
|
+
requestId: string;
|
|
149
|
+
/** Circuit type used for proof generation */
|
|
150
|
+
circuit: CircuitType;
|
|
151
|
+
/** Request status (completed, error, cancelled) */
|
|
152
|
+
status: ProofRequestStatus;
|
|
153
|
+
/** Proof data as hex string (present if status is completed) */
|
|
154
|
+
proof?: string;
|
|
155
|
+
/** Public inputs as array of hex strings (present if status is completed) */
|
|
156
|
+
publicInputs?: string[];
|
|
157
|
+
/** Number of public inputs (used for verification) */
|
|
158
|
+
numPublicInputs?: number;
|
|
159
|
+
/** Error message (present if status is error) */
|
|
160
|
+
error?: string;
|
|
161
|
+
/** Unix timestamp (ms) when proof was generated */
|
|
162
|
+
timestamp?: number;
|
|
163
|
+
/** Verifier contract address on target chain (provided by mobile app) */
|
|
164
|
+
verifierAddress?: string;
|
|
165
|
+
/** Chain ID where verifier contract is deployed (provided by mobile app) */
|
|
166
|
+
chainId?: number;
|
|
167
|
+
/** Nullifier for proof uniqueness (prevents double-use, derived from scope) */
|
|
168
|
+
nullifier?: string;
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Parsed and formatted proof data ready for on-chain verification.
|
|
172
|
+
*
|
|
173
|
+
* Internal representation used by the SDK to prepare proof data
|
|
174
|
+
* for smart contract verification calls.
|
|
175
|
+
*/
|
|
176
|
+
export interface ParsedProof {
|
|
177
|
+
/** Proof bytes as hex string with 0x prefix */
|
|
178
|
+
proofHex: string;
|
|
179
|
+
/** Public inputs as array of hex strings with 0x prefix */
|
|
180
|
+
publicInputsHex: string[];
|
|
181
|
+
/** Number of public inputs (must match circuit specification) */
|
|
182
|
+
numPublicInputs: number;
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* QR code generation options for deep link encoding.
|
|
186
|
+
*
|
|
187
|
+
* Controls the appearance and error correction level of generated QR codes.
|
|
188
|
+
* Higher error correction allows for more damage tolerance but requires larger QR codes.
|
|
189
|
+
*
|
|
190
|
+
* @example
|
|
191
|
+
* ```typescript
|
|
192
|
+
* const options: QRCodeOptions = {
|
|
193
|
+
* width: 512,
|
|
194
|
+
* errorCorrectionLevel: 'M',
|
|
195
|
+
* darkColor: '#000000',
|
|
196
|
+
* lightColor: '#ffffff'
|
|
197
|
+
* };
|
|
198
|
+
* ```
|
|
199
|
+
*/
|
|
200
|
+
export interface QRCodeOptions {
|
|
201
|
+
/** QR code width in pixels (default: 300) */
|
|
202
|
+
width?: number;
|
|
203
|
+
/** Error correction level: L (7%), M (15%), Q (25%), H (30%) (default: M) */
|
|
204
|
+
errorCorrectionLevel?: 'L' | 'M' | 'Q' | 'H';
|
|
205
|
+
/** Margin around QR code in module units (default: 4) */
|
|
206
|
+
margin?: number;
|
|
207
|
+
/** Foreground color as hex string (default: #000000) */
|
|
208
|
+
darkColor?: string;
|
|
209
|
+
/** Background color as hex string (default: #ffffff) */
|
|
210
|
+
lightColor?: string;
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* Verifier smart contract configuration.
|
|
214
|
+
*
|
|
215
|
+
* Contains the address and ABI for a circuit's verifier contract on a specific chain.
|
|
216
|
+
* Each circuit has its own verifier contract that validates proofs on-chain.
|
|
217
|
+
*/
|
|
218
|
+
export interface VerifierContract {
|
|
219
|
+
/** Verifier contract address (checksummed) */
|
|
220
|
+
address: string;
|
|
221
|
+
/** Chain ID where contract is deployed (e.g., 84532 for Base Sepolia) */
|
|
222
|
+
chainId: number;
|
|
223
|
+
/** Contract ABI for verify function (ethers v6 format) */
|
|
224
|
+
abi: string[];
|
|
225
|
+
}
|
|
226
|
+
/**
|
|
227
|
+
* ZKProofport SDK configuration options.
|
|
228
|
+
*
|
|
229
|
+
* Allows customization of deep link scheme, default callback URL,
|
|
230
|
+
* and verifier contract addresses.
|
|
231
|
+
*
|
|
232
|
+
* @example
|
|
233
|
+
* ```typescript
|
|
234
|
+
* // Recommended: use environment preset
|
|
235
|
+
* const sdk = ProofportSDK.create('production');
|
|
236
|
+
*
|
|
237
|
+
* // Or custom config:
|
|
238
|
+
* const config: ProofportConfig = {
|
|
239
|
+
* relayUrl: 'https://relay.zkproofport.app',
|
|
240
|
+
* verifiers: {
|
|
241
|
+
* coinbase_attestation: {
|
|
242
|
+
* address: '0x1234...',
|
|
243
|
+
* chainId: 84532,
|
|
244
|
+
* abi: VERIFIER_ABI
|
|
245
|
+
* }
|
|
246
|
+
* }
|
|
247
|
+
* };
|
|
248
|
+
* const sdk = new ProofportSDK(config);
|
|
249
|
+
* ```
|
|
250
|
+
*/
|
|
251
|
+
/**
|
|
252
|
+
* SDK environment preset names.
|
|
253
|
+
* Used with `ProofportSDK.create('production')` for zero-config initialization.
|
|
254
|
+
*
|
|
255
|
+
* - `production` — relay.zkproofport.app
|
|
256
|
+
* - `staging` — stg-relay.zkproofport.app
|
|
257
|
+
* - `local` — localhost:4001
|
|
258
|
+
*/
|
|
259
|
+
export type SDKEnvironment = 'production' | 'staging' | 'local';
|
|
260
|
+
export interface ProofportConfig {
|
|
261
|
+
/** Deep link URL scheme (default: 'zkproofport') */
|
|
262
|
+
scheme?: string;
|
|
263
|
+
/** Relay server URL (e.g., 'https://relay.zkproofport.app'). Required for relay features. */
|
|
264
|
+
relayUrl?: string;
|
|
265
|
+
/** Custom verifier contract addresses per circuit type (overrides defaults) */
|
|
266
|
+
verifiers?: Partial<Record<CircuitType, VerifierContract>>;
|
|
267
|
+
/** Nullifier registry contract config. Required for checkNullifier() and getNullifierDetails(). */
|
|
268
|
+
nullifierRegistry?: {
|
|
269
|
+
/** Registry contract address */
|
|
270
|
+
address: string;
|
|
271
|
+
/** Chain ID where registry is deployed */
|
|
272
|
+
chainId: number;
|
|
273
|
+
};
|
|
274
|
+
}
|
|
275
|
+
/**
|
|
276
|
+
* Parsed deep link URL components.
|
|
277
|
+
*
|
|
278
|
+
* Internal representation of a deep link URL broken into its constituent parts.
|
|
279
|
+
* Used for deep link generation and parsing.
|
|
280
|
+
*/
|
|
281
|
+
export interface DeepLinkComponents {
|
|
282
|
+
/** URL scheme (e.g., 'zkproofport') */
|
|
283
|
+
scheme: string;
|
|
284
|
+
/** URL host (e.g., 'proof-request') */
|
|
285
|
+
host: string;
|
|
286
|
+
/** URL path (e.g., '/verify') */
|
|
287
|
+
path: string;
|
|
288
|
+
/** Query parameters as key-value pairs */
|
|
289
|
+
params: Record<string, string>;
|
|
290
|
+
}
|
|
291
|
+
/**
|
|
292
|
+
* Nullifier verification status returned by smart contract.
|
|
293
|
+
*
|
|
294
|
+
* Mirrors the NullifierVerifyStatus enum in the ZKProofportNullifierRegistry contract.
|
|
295
|
+
* Indicates the result of verifying and registering a proof's nullifier on-chain.
|
|
296
|
+
*
|
|
297
|
+
* - `verified_and_registered`: Proof verified and nullifier registered successfully
|
|
298
|
+
* - `already_registered`: Proof verified but nullifier was already used (duplicate)
|
|
299
|
+
* - `expired_and_reregistered`: Previous nullifier expired, new one registered
|
|
300
|
+
* - `verification_failed`: Proof verification failed (invalid proof)
|
|
301
|
+
* - `circuit_not_found`: Circuit not registered in the registry
|
|
302
|
+
*/
|
|
303
|
+
export type NullifierVerifyStatus = 'verified_and_registered' | 'already_registered' | 'expired_and_reregistered' | 'verification_failed' | 'circuit_not_found';
|
|
304
|
+
/**
|
|
305
|
+
* On-chain nullifier record from smart contract storage.
|
|
306
|
+
*
|
|
307
|
+
* Contains information about a registered nullifier retrieved from
|
|
308
|
+
* the ZKProofportNullifierRegistry contract.
|
|
309
|
+
*
|
|
310
|
+
* @example
|
|
311
|
+
* ```typescript
|
|
312
|
+
* const record: NullifierRecord = {
|
|
313
|
+
* registeredAt: 1707234567,
|
|
314
|
+
* scope: '0xabcd...',
|
|
315
|
+
* circuitId: '0x1234...'
|
|
316
|
+
* };
|
|
317
|
+
* ```
|
|
318
|
+
*/
|
|
319
|
+
export interface NullifierRecord {
|
|
320
|
+
/** Unix timestamp (seconds) when nullifier was registered */
|
|
321
|
+
registeredAt: number;
|
|
322
|
+
/** Scope bytes32 (application identifier) */
|
|
323
|
+
scope: string;
|
|
324
|
+
/** Circuit ID bytes32 (circuit identifier) */
|
|
325
|
+
circuitId: string;
|
|
326
|
+
}
|
|
327
|
+
/**
|
|
328
|
+
* ZKProofportNullifierRegistry smart contract configuration.
|
|
329
|
+
*
|
|
330
|
+
* Contains the address and ABI for the nullifier registry contract,
|
|
331
|
+
* which tracks used nullifiers to prevent proof replay attacks.
|
|
332
|
+
*
|
|
333
|
+
* @example
|
|
334
|
+
* ```typescript
|
|
335
|
+
* const registryConfig: NullifierRegistryConfig = {
|
|
336
|
+
* address: '0x5678...',
|
|
337
|
+
* chainId: 84532,
|
|
338
|
+
* abi: ZKPROOFPORT_NULLIFIER_REGISTRY_ABI
|
|
339
|
+
* };
|
|
340
|
+
* ```
|
|
341
|
+
*/
|
|
342
|
+
export interface NullifierRegistryConfig {
|
|
343
|
+
/** Registry contract address (checksummed) */
|
|
344
|
+
address: string;
|
|
345
|
+
/** Chain ID where registry is deployed */
|
|
346
|
+
chainId: number;
|
|
347
|
+
/** Contract ABI (ethers v6 format) */
|
|
348
|
+
abi: string[];
|
|
349
|
+
}
|
|
350
|
+
/**
|
|
351
|
+
* Client credentials for API authentication.
|
|
352
|
+
*
|
|
353
|
+
* Used to authenticate with the ZKProofport API server and obtain
|
|
354
|
+
* a JWT token for making authenticated requests to the relay server.
|
|
355
|
+
*
|
|
356
|
+
* @example
|
|
357
|
+
* ```typescript
|
|
358
|
+
* const credentials: AuthCredentials = {
|
|
359
|
+
* clientId: 'your-client-id',
|
|
360
|
+
* apiKey: 'your-api-key'
|
|
361
|
+
* };
|
|
362
|
+
* ```
|
|
363
|
+
*/
|
|
364
|
+
export interface AuthCredentials {
|
|
365
|
+
/** Client ID identifying the application */
|
|
366
|
+
clientId: string;
|
|
367
|
+
/** API key for authentication */
|
|
368
|
+
apiKey: string;
|
|
369
|
+
}
|
|
370
|
+
/**
|
|
371
|
+
* JWT authentication token received from the API server.
|
|
372
|
+
*
|
|
373
|
+
* Contains the JWT token and metadata about the authenticated session,
|
|
374
|
+
* including tier information, expiration time, and associated identifiers.
|
|
375
|
+
*
|
|
376
|
+
* @example
|
|
377
|
+
* ```typescript
|
|
378
|
+
* const auth: AuthToken = {
|
|
379
|
+
* token: 'eyJhbGc...',
|
|
380
|
+
* clientId: 'your-client-id',
|
|
381
|
+
* dappId: 'app-123',
|
|
382
|
+
* tier: 'plan1',
|
|
383
|
+
* expiresIn: 3600,
|
|
384
|
+
* expiresAt: 1707234567890
|
|
385
|
+
* };
|
|
386
|
+
* ```
|
|
387
|
+
*/
|
|
388
|
+
export interface AuthToken {
|
|
389
|
+
/** JWT token for authenticating relay requests */
|
|
390
|
+
token: string;
|
|
391
|
+
/** Client ID that the token was issued for */
|
|
392
|
+
clientId: string;
|
|
393
|
+
/** DApp ID associated with this client */
|
|
394
|
+
dappId: string;
|
|
395
|
+
/** Service tier (free, credit, plan1, plan2) */
|
|
396
|
+
tier: string;
|
|
397
|
+
/** Token lifetime in seconds (typically 3600 = 1 hour) */
|
|
398
|
+
expiresIn: number;
|
|
399
|
+
/** Unix timestamp (ms) when the token expires */
|
|
400
|
+
expiresAt: number;
|
|
401
|
+
}
|
|
402
|
+
/**
|
|
403
|
+
* Result from creating a proof request via relay.
|
|
404
|
+
* Contains relay-issued requestId, deep link, and poll URL.
|
|
405
|
+
*/
|
|
406
|
+
export interface RelayProofRequest {
|
|
407
|
+
/** Relay-issued unique request ID (UUID format) */
|
|
408
|
+
requestId: string;
|
|
409
|
+
/** Deep link URL to open ZKProofport app (built by relay) */
|
|
410
|
+
deepLink: string;
|
|
411
|
+
/** Relay status: pending, completed, failed */
|
|
412
|
+
status: string;
|
|
413
|
+
/** Relative poll URL for checking proof status (e.g., /api/v1/proof/{requestId}) */
|
|
414
|
+
pollUrl: string;
|
|
415
|
+
}
|
|
416
|
+
/**
|
|
417
|
+
* Proof result retrieved from relay polling.
|
|
418
|
+
*/
|
|
419
|
+
export interface RelayProofResult {
|
|
420
|
+
requestId: string;
|
|
421
|
+
status: 'pending' | 'completed' | 'failed';
|
|
422
|
+
deepLink?: string;
|
|
423
|
+
createdAt?: string;
|
|
424
|
+
updatedAt?: string;
|
|
425
|
+
/** Present when status is 'completed' */
|
|
426
|
+
proof?: string;
|
|
427
|
+
publicInputs?: string[];
|
|
428
|
+
verifierAddress?: string;
|
|
429
|
+
chainId?: number;
|
|
430
|
+
nullifier?: string;
|
|
431
|
+
circuit?: string;
|
|
432
|
+
/** Present when status is 'failed' */
|
|
433
|
+
error?: string;
|
|
434
|
+
}
|