@zkproofport-ai/sdk 0.1.1 → 0.1.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.
- package/README.md +127 -21
- package/dist/cdp.d.ts +114 -16
- package/dist/cdp.d.ts.map +1 -1
- package/dist/cdp.js +64 -75
- package/dist/cdp.js.map +1 -1
- package/dist/constants.d.ts +4 -4
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +4 -0
- package/dist/constants.js.map +1 -1
- package/dist/flow.d.ts.map +1 -1
- package/dist/flow.js +46 -24
- package/dist/flow.js.map +1 -1
- package/dist/index.d.ts +6 -9
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -12
- package/dist/index.js.map +1 -1
- package/dist/oidc-inputs.d.ts +60 -0
- package/dist/oidc-inputs.d.ts.map +1 -0
- package/dist/oidc-inputs.js +296 -0
- package/dist/oidc-inputs.js.map +1 -0
- package/dist/payment.d.ts +3 -1
- package/dist/payment.d.ts.map +1 -1
- package/dist/payment.js +7 -4
- package/dist/payment.js.map +1 -1
- package/dist/prove.d.ts +2 -2
- package/dist/prove.d.ts.map +1 -1
- package/dist/types.d.ts +14 -3
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@ Client SDK for ZKProofport zero-knowledge proof generation on Base Mainnet.
|
|
|
4
4
|
|
|
5
5
|
## Overview
|
|
6
6
|
|
|
7
|
-
@zkproofport-ai/sdk is a TypeScript SDK for generating privacy-preserving zero-knowledge proofs using Coinbase KYC attestations. Generate a proof with a single function call, or fine-tune each step for custom workflows.
|
|
7
|
+
@zkproofport-ai/sdk is a TypeScript SDK for generating privacy-preserving zero-knowledge proofs using Coinbase KYC attestations and OIDC JWT tokens. Generate a proof with a single function call, or fine-tune each step for custom workflows.
|
|
8
8
|
|
|
9
9
|
Proofs are generated in trusted execution environments (Nitro Enclaves) with cryptographic attestation. Payment is handled transparently via the x402 protocol using EIP-3009 (no user gas costs).
|
|
10
10
|
|
|
@@ -40,13 +40,14 @@ Before using the SDK, you need:
|
|
|
40
40
|
3. **USDC balance on Base** — At least $0.10 per proof. Payment is gasless (EIP-3009 signature, facilitator pays gas).
|
|
41
41
|
4. **Attestation wallet private key** (required) — The private key of the wallet that holds the EAS attestation. This is always a raw private key because the attestation is tied to a specific address.
|
|
42
42
|
|
|
43
|
-
5. **Payment wallet** (
|
|
43
|
+
5. **Payment wallet** (recommended) — Separate wallet with USDC balance for proof payment. Choose one:
|
|
44
44
|
|
|
45
|
-
- **Same as attestation wallet** — No additional setup
|
|
45
|
+
- **Same as attestation wallet (NOT recommended)** — No additional setup, but **defeats zero-knowledge privacy**.
|
|
46
|
+
> ⚠️ **Privacy risk:** Using the attestation wallet for payment exposes your KYC-verified wallet address on-chain in the payment transaction, **directly linking your real-world identity to on-chain activity**. This defeats the purpose of zero-knowledge proofs. Always use a separate payment wallet (private key or CDP) to preserve privacy.
|
|
46
47
|
- **Separate private key** — A different wallet with USDC balance.
|
|
47
48
|
- **CDP MPC wallet** — Coinbase Developer Platform managed wallet. Private keys never leave Coinbase's TEE. Get credentials at [CDP Portal](https://portal.cdp.coinbase.com). Requires additional install:
|
|
48
49
|
```bash
|
|
49
|
-
npm install @coinbase/
|
|
50
|
+
npm install @coinbase/cdp-sdk
|
|
50
51
|
```
|
|
51
52
|
| Credential | Required | Description |
|
|
52
53
|
|------------|----------|-------------|
|
|
@@ -57,17 +58,18 @@ Before using the SDK, you need:
|
|
|
57
58
|
|
|
58
59
|
## Quick Start
|
|
59
60
|
|
|
60
|
-
###
|
|
61
|
+
### Separate Payment Wallet (Recommended)
|
|
61
62
|
|
|
62
63
|
```typescript
|
|
63
64
|
import { generateProof, createConfig, fromPrivateKey, verifyProof } from '@zkproofport-ai/sdk';
|
|
64
65
|
|
|
65
66
|
const config = createConfig();
|
|
66
|
-
const
|
|
67
|
+
const attestationSigner = fromPrivateKey(process.env.ATTESTATION_KEY);
|
|
68
|
+
const paymentSigner = fromPrivateKey(process.env.PAYMENT_KEY);
|
|
67
69
|
|
|
68
70
|
const result = await generateProof(
|
|
69
71
|
config,
|
|
70
|
-
{ attestation:
|
|
72
|
+
{ attestation: attestationSigner, payment: paymentSigner },
|
|
71
73
|
{ circuit: 'coinbase_kyc', scope: 'my-app' }
|
|
72
74
|
);
|
|
73
75
|
|
|
@@ -75,14 +77,38 @@ const verification = await verifyProof(result);
|
|
|
75
77
|
console.log('Valid:', verification.valid);
|
|
76
78
|
```
|
|
77
79
|
|
|
78
|
-
###
|
|
80
|
+
### With CDP Payment Wallet
|
|
79
81
|
|
|
80
82
|
```typescript
|
|
81
|
-
import { generateProof, createConfig, fromPrivateKey, verifyProof } from '@zkproofport-ai/sdk';
|
|
83
|
+
import { generateProof, createConfig, fromPrivateKey, fromExternalWallet, verifyProof } from '@zkproofport-ai/sdk';
|
|
84
|
+
import { CdpClient } from '@coinbase/cdp-sdk';
|
|
82
85
|
|
|
83
86
|
const config = createConfig();
|
|
84
87
|
const attestationSigner = fromPrivateKey(process.env.ATTESTATION_KEY);
|
|
85
|
-
|
|
88
|
+
|
|
89
|
+
// Create CDP MPC wallet (private keys never leave Coinbase's TEE)
|
|
90
|
+
const cdp = new CdpClient();
|
|
91
|
+
const account = await cdp.evm.getOrCreateAccount({ name: 'proofport-payment' });
|
|
92
|
+
|
|
93
|
+
const paymentSigner = fromExternalWallet({
|
|
94
|
+
getAddress: () => account.address!,
|
|
95
|
+
signMessage: async (msg) => {
|
|
96
|
+
const message = msg instanceof Uint8Array ? Buffer.from(msg).toString() : msg;
|
|
97
|
+
const result = await cdp.evm.signMessage({ address: account.address!, message });
|
|
98
|
+
return result.signature;
|
|
99
|
+
},
|
|
100
|
+
signTypedData: async (domain, types, message) => {
|
|
101
|
+
const primaryType = Object.keys(types).find(k => k !== 'EIP712Domain') || '';
|
|
102
|
+
const result = await cdp.evm.signTypedData({ address: account.address!, domain, types, primaryType, message });
|
|
103
|
+
return result.signature;
|
|
104
|
+
},
|
|
105
|
+
sendTransaction: async (tx) => {
|
|
106
|
+
const result = await cdp.evm.sendTransaction({
|
|
107
|
+
address: account.address!, transaction: tx, network: 'base-sepolia',
|
|
108
|
+
});
|
|
109
|
+
return { hash: result.transactionHash, wait: async () => ({ status: 1 }) };
|
|
110
|
+
},
|
|
111
|
+
});
|
|
86
112
|
|
|
87
113
|
const result = await generateProof(
|
|
88
114
|
config,
|
|
@@ -94,19 +120,19 @@ const verification = await verifyProof(result);
|
|
|
94
120
|
console.log('Valid:', verification.valid);
|
|
95
121
|
```
|
|
96
122
|
|
|
97
|
-
###
|
|
123
|
+
### External Wallet Adapter
|
|
124
|
+
|
|
125
|
+
Wrap any external wallet (WalletConnect, MetaMask, etc.) using `fromExternalWallet()`:
|
|
98
126
|
|
|
99
127
|
```typescript
|
|
100
|
-
import { generateProof, createConfig, fromPrivateKey,
|
|
128
|
+
import { generateProof, createConfig, fromPrivateKey, fromExternalWallet, verifyProof } from '@zkproofport-ai/sdk';
|
|
101
129
|
|
|
102
130
|
const config = createConfig();
|
|
103
131
|
const attestationSigner = fromPrivateKey(process.env.ATTESTATION_KEY);
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
address: process.env.CDP_WALLET_ADDRESS,
|
|
109
|
-
});
|
|
132
|
+
|
|
133
|
+
// Wrap external wallet (e.g., from WalletConnect modal, Privy, etc.)
|
|
134
|
+
const externalWallet = await getWalletFromUI(); // Your wallet integration
|
|
135
|
+
const paymentSigner = fromExternalWallet(externalWallet);
|
|
110
136
|
|
|
111
137
|
const result = await generateProof(
|
|
112
138
|
config,
|
|
@@ -132,6 +158,14 @@ const config = createConfig({
|
|
|
132
158
|
easRpcUrl: 'https://mainnet.base.org',
|
|
133
159
|
easGraphqlUrl: 'https://base.easscan.org/graphql',
|
|
134
160
|
});
|
|
161
|
+
|
|
162
|
+
// Custom x402 facilitator (e.g., for CDP with JWT auth)
|
|
163
|
+
const config = createConfig({
|
|
164
|
+
facilitatorUrl: 'https://facilitator.example.com',
|
|
165
|
+
facilitatorHeaders: {
|
|
166
|
+
'Authorization': `Bearer ${process.env.CDP_FACILITATOR_TOKEN}`,
|
|
167
|
+
},
|
|
168
|
+
});
|
|
135
169
|
```
|
|
136
170
|
|
|
137
171
|
**Configuration fields:**
|
|
@@ -141,6 +175,8 @@ const config = createConfig({
|
|
|
141
175
|
| `baseUrl` | string | `https://ai.zkproofport.app` | proofport-ai server URL |
|
|
142
176
|
| `easRpcUrl` | string | `https://mainnet.base.org` | Base Mainnet RPC for EAS attestation queries |
|
|
143
177
|
| `easGraphqlUrl` | string | `https://base.easscan.org/graphql` | EAS GraphQL endpoint for attestation schema queries |
|
|
178
|
+
| `facilitatorUrl` | string | `https://x402.dexter.cash` | x402 payment facilitator URL |
|
|
179
|
+
| `facilitatorHeaders` | object | `{}` | Optional auth headers for custom facilitator (e.g., CDP with JWT) |
|
|
144
180
|
|
|
145
181
|
## Proof Generation
|
|
146
182
|
|
|
@@ -318,13 +354,36 @@ const result = await generateProof(config, signers, {
|
|
|
318
354
|
});
|
|
319
355
|
```
|
|
320
356
|
|
|
357
|
+
### OIDC Domain
|
|
358
|
+
|
|
359
|
+
Proves email domain affiliation using an OIDC JWT token (e.g., Google, Microsoft). No EAS attestation or Coinbase account required — only a payment wallet and a JWT `id_token`.
|
|
360
|
+
|
|
361
|
+
```typescript
|
|
362
|
+
import { createConfig, generateProof, fromPrivateKey } from '@zkproofport-ai/sdk';
|
|
363
|
+
|
|
364
|
+
const config = createConfig();
|
|
365
|
+
const paymentSigner = fromPrivateKey(process.env.PAYMENT_KEY);
|
|
366
|
+
|
|
367
|
+
const result = await generateProof(
|
|
368
|
+
config,
|
|
369
|
+
{ attestation: paymentSigner }, // OIDC skips attestation; payment signer is used for x402 payment only
|
|
370
|
+
{
|
|
371
|
+
circuit: 'oidc_domain',
|
|
372
|
+
jwt: idToken, // JWT id_token from Google/Microsoft OAuth
|
|
373
|
+
scope: 'myapp:verify-domain',
|
|
374
|
+
},
|
|
375
|
+
);
|
|
376
|
+
```
|
|
377
|
+
|
|
378
|
+
> **Note:** For OIDC circuits, the `attestation` signer field is only used as a payment fallback. Pass your payment wallet — no EAS-attested wallet needed.
|
|
379
|
+
|
|
321
380
|
## Types Reference
|
|
322
381
|
|
|
323
382
|
**Circuit Types:**
|
|
324
383
|
|
|
325
384
|
```typescript
|
|
326
|
-
type CircuitName = 'coinbase_kyc' | 'coinbase_country';
|
|
327
|
-
type CircuitId = 'coinbase_attestation' | 'coinbase_country_attestation';
|
|
385
|
+
type CircuitName = 'coinbase_kyc' | 'coinbase_country' | 'oidc_domain';
|
|
386
|
+
type CircuitId = 'coinbase_attestation' | 'coinbase_country_attestation' | 'oidc_domain_attestation';
|
|
328
387
|
```
|
|
329
388
|
|
|
330
389
|
**Configuration:**
|
|
@@ -334,6 +393,8 @@ interface ClientConfig {
|
|
|
334
393
|
baseUrl: string;
|
|
335
394
|
easRpcUrl?: string;
|
|
336
395
|
easGraphqlUrl?: string;
|
|
396
|
+
facilitatorUrl?: string; // x402 facilitator URL (default: https://x402.dexter.cash)
|
|
397
|
+
facilitatorHeaders?: Record<string, string>; // Auth headers for custom facilitator
|
|
337
398
|
}
|
|
338
399
|
```
|
|
339
400
|
|
|
@@ -346,6 +407,27 @@ interface ProofportSigner {
|
|
|
346
407
|
signTypedData(domain: {...}, types: {...}, message: {...}): Promise<string>;
|
|
347
408
|
sendTransaction(tx: {...}): Promise<{ hash: string; wait(): Promise<{...}> }>;
|
|
348
409
|
}
|
|
410
|
+
|
|
411
|
+
// Create signer from ethers private key
|
|
412
|
+
function fromPrivateKey(key: string, provider?: ethers.Provider): ProofportSigner;
|
|
413
|
+
|
|
414
|
+
// Create signer from any external wallet (CDP, WalletConnect, Privy, etc.)
|
|
415
|
+
class CdpWalletSigner implements ProofportSigner {
|
|
416
|
+
constructor(wallet: {
|
|
417
|
+
getAddress(): string | Promise<string>;
|
|
418
|
+
signMessage(message: Uint8Array | string): Promise<string>;
|
|
419
|
+
signTypedData(domain: Record<string, unknown>, types: Record<string, Array<{ name: string; type: string }>>, message: Record<string, unknown>): Promise<string>;
|
|
420
|
+
sendTransaction?(tx: { to: string; data: string; value?: bigint }): Promise<{ hash: string; wait(): Promise<{ status: number | null }> }>;
|
|
421
|
+
});
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
// Wrap external wallet (WalletConnect, MetaMask, Privy, etc.)
|
|
425
|
+
function fromExternalWallet(wallet: {
|
|
426
|
+
getAddress(): string | Promise<string>;
|
|
427
|
+
signMessage(message: Uint8Array): Promise<string>;
|
|
428
|
+
signTypedData(domain: any, types: any, message: any): Promise<string>;
|
|
429
|
+
sendTransaction?(tx: any): Promise<{ hash: string; wait(): Promise<any> }>;
|
|
430
|
+
}): ProofportSigner;
|
|
349
431
|
```
|
|
350
432
|
|
|
351
433
|
**Proof Parameters:**
|
|
@@ -356,6 +438,7 @@ interface ProofParams {
|
|
|
356
438
|
scope?: string; // defaults to 'proofport'
|
|
357
439
|
countryList?: string[]; // for coinbase_country only
|
|
358
440
|
isIncluded?: boolean; // for coinbase_country only
|
|
441
|
+
jwt?: string; // JWT id_token for OIDC circuits (required for oidc_domain)
|
|
359
442
|
}
|
|
360
443
|
```
|
|
361
444
|
|
|
@@ -391,6 +474,15 @@ interface ProofResult {
|
|
|
391
474
|
}
|
|
392
475
|
```
|
|
393
476
|
|
|
477
|
+
**OIDC Inputs:**
|
|
478
|
+
|
|
479
|
+
```typescript
|
|
480
|
+
interface OidcProveInputs {
|
|
481
|
+
jwt: string;
|
|
482
|
+
scope_string: string;
|
|
483
|
+
}
|
|
484
|
+
```
|
|
485
|
+
|
|
394
486
|
**Callbacks:**
|
|
395
487
|
|
|
396
488
|
```typescript
|
|
@@ -414,11 +506,25 @@ Payment is transparent to the application. When `generateProof()` runs, the user
|
|
|
414
506
|
- Method: EIP-3009 `TransferWithAuthorization`
|
|
415
507
|
- Token: USDC on Base Mainnet
|
|
416
508
|
- Amount: $0.10 per proof
|
|
417
|
-
- Facilitator: https://
|
|
509
|
+
- Facilitator: `https://x402.dexter.cash` (default, pays gas)
|
|
418
510
|
- User cost: Only USDC, no ETH for gas
|
|
511
|
+
- Custom facilitator: Use `facilitatorUrl` + `facilitatorHeaders` in `ClientConfig` for alternative facilitators (e.g., CDP with JWT auth)
|
|
419
512
|
|
|
420
513
|
The payment transaction hash is included in `result.paymentTxHash` for settlement tracking.
|
|
421
514
|
|
|
515
|
+
### Custom Facilitator (CDP Example)
|
|
516
|
+
|
|
517
|
+
```typescript
|
|
518
|
+
const config = createConfig({
|
|
519
|
+
facilitatorUrl: 'https://cdp-facilitator.example.com',
|
|
520
|
+
facilitatorHeaders: {
|
|
521
|
+
'Authorization': `Bearer ${process.env.CDP_JWT_TOKEN}`,
|
|
522
|
+
},
|
|
523
|
+
});
|
|
524
|
+
|
|
525
|
+
const result = await generateProof(config, signers, params);
|
|
526
|
+
```
|
|
527
|
+
|
|
422
528
|
## Error Handling
|
|
423
529
|
|
|
424
530
|
```typescript
|
package/dist/cdp.d.ts
CHANGED
|
@@ -1,26 +1,100 @@
|
|
|
1
1
|
import type { ProofportSigner } from './signer.js';
|
|
2
2
|
/**
|
|
3
|
-
* CDP
|
|
4
|
-
*
|
|
5
|
-
*
|
|
3
|
+
* Adapter interface for CDP wallet-like objects (or any external wallet).
|
|
4
|
+
*
|
|
5
|
+
* Pass any object that satisfies these method signatures — CDP MPC wallets,
|
|
6
|
+
* viem wallets, Privy embedded wallets, etc. — and wrap it with
|
|
7
|
+
* `CdpWalletSigner` or `fromExternalWallet()` to get a `ProofportSigner`.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```typescript
|
|
11
|
+
* // With @coinbase/cdp-sdk
|
|
12
|
+
* import { CdpClient } from '@coinbase/cdp-sdk';
|
|
13
|
+
* import { CdpWalletSigner } from '@zkproofport-ai/sdk';
|
|
14
|
+
*
|
|
15
|
+
* const cdp = new CdpClient();
|
|
16
|
+
* const wallet = await cdp.evm.getOrCreateWallet({ networkId: 'base' });
|
|
17
|
+
* const account = await wallet.getDefaultAddress();
|
|
18
|
+
*
|
|
19
|
+
* const signer = new CdpWalletSigner({
|
|
20
|
+
* getAddress: () => account.getId(),
|
|
21
|
+
* signMessage: (msg) => account.signPayload({ payload: Buffer.from(msg).toString('hex') }).then(r => r.signature),
|
|
22
|
+
* signTypedData: (domain, types, message) => account.signTypedData({ domain, types, message }),
|
|
23
|
+
* sendTransaction: async (tx) => {
|
|
24
|
+
* const result = await account.sendTransaction(tx);
|
|
25
|
+
* return { hash: result.transactionHash, wait: async () => ({ status: 1 }) };
|
|
26
|
+
* },
|
|
27
|
+
* });
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
export interface ExternalWallet {
|
|
31
|
+
/**
|
|
32
|
+
* Returns the wallet's Ethereum address.
|
|
33
|
+
* May be synchronous or asynchronous depending on the provider.
|
|
34
|
+
*/
|
|
35
|
+
getAddress(): string | Promise<string>;
|
|
36
|
+
/**
|
|
37
|
+
* Signs a raw message (personal_sign style).
|
|
38
|
+
* Accepts either a Uint8Array of raw bytes or a pre-encoded string.
|
|
39
|
+
*/
|
|
40
|
+
signMessage(message: Uint8Array | string): Promise<string>;
|
|
41
|
+
/**
|
|
42
|
+
* Signs EIP-712 typed data.
|
|
43
|
+
* Compatible with ethers v6 `signTypedData` and viem `signTypedData` call shapes.
|
|
44
|
+
*/
|
|
45
|
+
signTypedData(domain: Record<string, unknown>, types: Record<string, Array<{
|
|
46
|
+
name: string;
|
|
47
|
+
type: string;
|
|
48
|
+
}>>, message: Record<string, unknown>): Promise<string>;
|
|
49
|
+
/**
|
|
50
|
+
* Sends a transaction and returns the hash plus a `wait()` helper.
|
|
51
|
+
* Optional — omit if the wallet is used only for signing (e.g., attestation signer).
|
|
52
|
+
* If omitted and `sendTransaction` is called on the signer, an error is thrown at runtime.
|
|
53
|
+
*/
|
|
54
|
+
sendTransaction?(tx: {
|
|
55
|
+
to: string;
|
|
56
|
+
data: string;
|
|
57
|
+
value?: bigint;
|
|
58
|
+
}): Promise<{
|
|
59
|
+
hash: string;
|
|
60
|
+
wait(): Promise<{
|
|
61
|
+
status: number | null;
|
|
62
|
+
}>;
|
|
63
|
+
}>;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Adapter that bridges any `ExternalWallet`-compatible object to the
|
|
67
|
+
* `ProofportSigner` interface. No additional npm dependencies required —
|
|
68
|
+
* the caller brings their own wallet implementation.
|
|
69
|
+
*
|
|
70
|
+
* @example
|
|
71
|
+
* ```typescript
|
|
72
|
+
* import { CdpWalletSigner } from '@zkproofport-ai/sdk';
|
|
73
|
+
*
|
|
74
|
+
* // Wrap any CDP / external wallet
|
|
75
|
+
* const signer = new CdpWalletSigner(myExternalWallet);
|
|
76
|
+
*
|
|
77
|
+
* // Use as attestation signer
|
|
78
|
+
* const client = new ProofportClient({ ... }, { attestation: signer });
|
|
79
|
+
* ```
|
|
6
80
|
*/
|
|
7
81
|
export declare class CdpWalletSigner implements ProofportSigner {
|
|
8
|
-
private
|
|
9
|
-
|
|
82
|
+
private readonly wallet;
|
|
83
|
+
constructor(wallet: ExternalWallet);
|
|
84
|
+
/** Returns the wallet address, resolving async providers transparently. */
|
|
85
|
+
getAddress(): string | Promise<string>;
|
|
10
86
|
/**
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
87
|
+
* Signs a raw byte message.
|
|
88
|
+
* Passes the Uint8Array directly to the underlying wallet; the wallet is
|
|
89
|
+
* responsible for any encoding (e.g., personal_sign prefix).
|
|
14
90
|
*/
|
|
15
|
-
static create(opts?: {
|
|
16
|
-
apiKeyId?: string;
|
|
17
|
-
apiKeySecret?: string;
|
|
18
|
-
walletSecret?: string;
|
|
19
|
-
networkId?: string;
|
|
20
|
-
address?: string;
|
|
21
|
-
}): Promise<CdpWalletSigner>;
|
|
22
|
-
getAddress(): string;
|
|
23
91
|
signMessage(message: Uint8Array): Promise<string>;
|
|
92
|
+
/**
|
|
93
|
+
* Signs EIP-712 typed data.
|
|
94
|
+
* The strict `ProofportSigner` domain shape is widened to
|
|
95
|
+
* `Record<string, unknown>` when forwarded so any external wallet
|
|
96
|
+
* implementation can accept it without type conflicts.
|
|
97
|
+
*/
|
|
24
98
|
signTypedData(domain: {
|
|
25
99
|
name: string;
|
|
26
100
|
version: string;
|
|
@@ -30,6 +104,11 @@ export declare class CdpWalletSigner implements ProofportSigner {
|
|
|
30
104
|
name: string;
|
|
31
105
|
type: string;
|
|
32
106
|
}>>, message: Record<string, unknown>): Promise<string>;
|
|
107
|
+
/**
|
|
108
|
+
* Sends a transaction via the underlying wallet.
|
|
109
|
+
* Throws a descriptive error if the wrapped wallet did not provide
|
|
110
|
+
* a `sendTransaction` method (e.g., signing-only attestation wallets).
|
|
111
|
+
*/
|
|
33
112
|
sendTransaction(tx: {
|
|
34
113
|
to: string;
|
|
35
114
|
data: string;
|
|
@@ -41,4 +120,23 @@ export declare class CdpWalletSigner implements ProofportSigner {
|
|
|
41
120
|
}>;
|
|
42
121
|
}>;
|
|
43
122
|
}
|
|
123
|
+
/**
|
|
124
|
+
* Convenience factory — equivalent to `new CdpWalletSigner(wallet)`.
|
|
125
|
+
*
|
|
126
|
+
* Useful for returning a `ProofportSigner` without exposing the concrete
|
|
127
|
+
* `CdpWalletSigner` class to callers.
|
|
128
|
+
*
|
|
129
|
+
* @example
|
|
130
|
+
* ```typescript
|
|
131
|
+
* import { fromExternalWallet } from '@zkproofport-ai/sdk';
|
|
132
|
+
*
|
|
133
|
+
* const signer = fromExternalWallet({
|
|
134
|
+
* getAddress: () => '0xYourAddress',
|
|
135
|
+
* signMessage: (msg) => myWallet.sign(msg),
|
|
136
|
+
* signTypedData: (domain, types, message) =>
|
|
137
|
+
* myWallet.signTypedData({ domain, types, message }),
|
|
138
|
+
* });
|
|
139
|
+
* ```
|
|
140
|
+
*/
|
|
141
|
+
export declare function fromExternalWallet(wallet: ExternalWallet): ProofportSigner;
|
|
44
142
|
//# sourceMappingURL=cdp.d.ts.map
|
package/dist/cdp.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cdp.d.ts","sourceRoot":"","sources":["../src/cdp.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAEnD
|
|
1
|
+
{"version":3,"file":"cdp.d.ts","sourceRoot":"","sources":["../src/cdp.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAEnD;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,MAAM,WAAW,cAAc;IAC7B;;;OAGG;IACH,UAAU,IAAI,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAEvC;;;OAGG;IACH,WAAW,CAAC,OAAO,EAAE,UAAU,GAAG,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAE3D;;;OAGG;IACH,aAAa,CACX,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC/B,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC,EAC5D,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC/B,OAAO,CAAC,MAAM,CAAC,CAAC;IAEnB;;;;OAIG;IACH,eAAe,CAAC,CAAC,EAAE,EAAE;QACnB,EAAE,EAAE,MAAM,CAAC;QACX,IAAI,EAAE,MAAM,CAAC;QACb,KAAK,CAAC,EAAE,MAAM,CAAC;KAChB,GAAG,OAAO,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,IAAI,OAAO,CAAC;YAAE,MAAM,EAAE,MAAM,GAAG,IAAI,CAAA;SAAE,CAAC,CAAA;KAAE,CAAC,CAAC;CAC3E;AAED;;;;;;;;;;;;;;;GAeG;AACH,qBAAa,eAAgB,YAAW,eAAe;IACrD,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAiB;gBAE5B,MAAM,EAAE,cAAc;IAIlC,2EAA2E;IAC3E,UAAU,IAAI,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAItC;;;;OAIG;IACG,WAAW,CAAC,OAAO,EAAE,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC;IAIvD;;;;;OAKG;IACG,aAAa,CACjB,MAAM,EAAE;QACN,IAAI,EAAE,MAAM,CAAC;QACb,OAAO,EAAE,MAAM,CAAC;QAChB,OAAO,EAAE,MAAM,CAAC;QAChB,iBAAiB,EAAE,MAAM,CAAC;KAC3B,EACD,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC,EAC5D,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC/B,OAAO,CAAC,MAAM,CAAC;IAIlB;;;;OAIG;IACG,eAAe,CAAC,EAAE,EAAE;QACxB,EAAE,EAAE,MAAM,CAAC;QACX,IAAI,EAAE,MAAM,CAAC;QACb,KAAK,CAAC,EAAE,MAAM,CAAC;KAChB,GAAG,OAAO,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,IAAI,OAAO,CAAC;YAAE,MAAM,EAAE,MAAM,GAAG,IAAI,CAAA;SAAE,CAAC,CAAA;KAAE,CAAC;CAU1E;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,cAAc,GAAG,eAAe,CAE1E"}
|
package/dist/cdp.js
CHANGED
|
@@ -1,89 +1,78 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
2
|
+
* Adapter that bridges any `ExternalWallet`-compatible object to the
|
|
3
|
+
* `ProofportSigner` interface. No additional npm dependencies required —
|
|
4
|
+
* the caller brings their own wallet implementation.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```typescript
|
|
8
|
+
* import { CdpWalletSigner } from '@zkproofport-ai/sdk';
|
|
9
|
+
*
|
|
10
|
+
* // Wrap any CDP / external wallet
|
|
11
|
+
* const signer = new CdpWalletSigner(myExternalWallet);
|
|
12
|
+
*
|
|
13
|
+
* // Use as attestation signer
|
|
14
|
+
* const client = new ProofportClient({ ... }, { attestation: signer });
|
|
15
|
+
* ```
|
|
5
16
|
*/
|
|
6
17
|
export class CdpWalletSigner {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
this.provider = provider;
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* Create a CdpWalletSigner from environment variables.
|
|
14
|
-
* Requires: CDP_API_KEY_ID, CDP_API_KEY_SECRET, CDP_WALLET_SECRET
|
|
15
|
-
* Optional: CDP_WALLET_ADDRESS (to load existing wallet), CDP_NETWORK_ID (default: base-sepolia)
|
|
16
|
-
*/
|
|
17
|
-
static async create(opts) {
|
|
18
|
-
let CdpEvmWalletProvider;
|
|
19
|
-
try {
|
|
20
|
-
// @ts-ignore — optional peer dependency, may not be installed
|
|
21
|
-
const mod = await import('@coinbase/agentkit');
|
|
22
|
-
CdpEvmWalletProvider = mod.CdpEvmWalletProvider;
|
|
23
|
-
}
|
|
24
|
-
catch {
|
|
25
|
-
throw new Error('CDP wallet requires @coinbase/agentkit. Install it: npm install @coinbase/agentkit @coinbase/cdp-sdk');
|
|
26
|
-
}
|
|
27
|
-
const config = {
|
|
28
|
-
apiKeyId: opts?.apiKeyId || process.env.CDP_API_KEY_ID,
|
|
29
|
-
apiKeySecret: opts?.apiKeySecret || process.env.CDP_API_KEY_SECRET,
|
|
30
|
-
walletSecret: opts?.walletSecret || process.env.CDP_WALLET_SECRET,
|
|
31
|
-
networkId: opts?.networkId || process.env.CDP_NETWORK_ID || 'base-sepolia',
|
|
32
|
-
};
|
|
33
|
-
const address = opts?.address || process.env.CDP_WALLET_ADDRESS;
|
|
34
|
-
if (address) {
|
|
35
|
-
config.address = address;
|
|
36
|
-
}
|
|
37
|
-
const provider = await CdpEvmWalletProvider.configureWithWallet(config);
|
|
38
|
-
return new CdpWalletSigner(provider);
|
|
18
|
+
wallet;
|
|
19
|
+
constructor(wallet) {
|
|
20
|
+
this.wallet = wallet;
|
|
39
21
|
}
|
|
22
|
+
/** Returns the wallet address, resolving async providers transparently. */
|
|
40
23
|
getAddress() {
|
|
41
|
-
return this.
|
|
24
|
+
return this.wallet.getAddress();
|
|
42
25
|
}
|
|
26
|
+
/**
|
|
27
|
+
* Signs a raw byte message.
|
|
28
|
+
* Passes the Uint8Array directly to the underlying wallet; the wallet is
|
|
29
|
+
* responsible for any encoding (e.g., personal_sign prefix).
|
|
30
|
+
*/
|
|
43
31
|
async signMessage(message) {
|
|
44
|
-
return this.
|
|
32
|
+
return this.wallet.signMessage(message);
|
|
45
33
|
}
|
|
34
|
+
/**
|
|
35
|
+
* Signs EIP-712 typed data.
|
|
36
|
+
* The strict `ProofportSigner` domain shape is widened to
|
|
37
|
+
* `Record<string, unknown>` when forwarded so any external wallet
|
|
38
|
+
* implementation can accept it without type conflicts.
|
|
39
|
+
*/
|
|
46
40
|
async signTypedData(domain, types, message) {
|
|
47
|
-
|
|
48
|
-
// AgentKit's signTypedData expects { domain, types, primaryType, message }
|
|
49
|
-
// Determine primaryType: it's the first key in types that isn't EIP712Domain
|
|
50
|
-
const primaryType = Object.keys(types).find(k => k !== 'EIP712Domain') || Object.keys(types)[0];
|
|
51
|
-
return this.provider.signTypedData({
|
|
52
|
-
domain,
|
|
53
|
-
types: {
|
|
54
|
-
...types,
|
|
55
|
-
EIP712Domain: [
|
|
56
|
-
{ name: 'name', type: 'string' },
|
|
57
|
-
{ name: 'version', type: 'string' },
|
|
58
|
-
{ name: 'chainId', type: 'uint256' },
|
|
59
|
-
{ name: 'verifyingContract', type: 'address' },
|
|
60
|
-
],
|
|
61
|
-
},
|
|
62
|
-
primaryType,
|
|
63
|
-
message,
|
|
64
|
-
});
|
|
41
|
+
return this.wallet.signTypedData(domain, types, message);
|
|
65
42
|
}
|
|
43
|
+
/**
|
|
44
|
+
* Sends a transaction via the underlying wallet.
|
|
45
|
+
* Throws a descriptive error if the wrapped wallet did not provide
|
|
46
|
+
* a `sendTransaction` method (e.g., signing-only attestation wallets).
|
|
47
|
+
*/
|
|
66
48
|
async sendTransaction(tx) {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
return {
|
|
74
|
-
hash,
|
|
75
|
-
wait: async () => {
|
|
76
|
-
// Use AgentKit's waitForTransactionReceipt if available
|
|
77
|
-
try {
|
|
78
|
-
const receipt = await this.provider.waitForTransactionReceipt(hash);
|
|
79
|
-
return { status: receipt?.status === 'success' ? 1 : 0 };
|
|
80
|
-
}
|
|
81
|
-
catch {
|
|
82
|
-
// Unknown status if receipt method unavailable
|
|
83
|
-
return { status: null };
|
|
84
|
-
}
|
|
85
|
-
},
|
|
86
|
-
};
|
|
49
|
+
if (typeof this.wallet.sendTransaction !== 'function') {
|
|
50
|
+
throw new Error('CdpWalletSigner: the wrapped wallet does not implement sendTransaction. ' +
|
|
51
|
+
'Provide a sendTransaction method on the ExternalWallet object, or use a ' +
|
|
52
|
+
'different signer for payment transactions.');
|
|
53
|
+
}
|
|
54
|
+
return this.wallet.sendTransaction(tx);
|
|
87
55
|
}
|
|
88
56
|
}
|
|
57
|
+
/**
|
|
58
|
+
* Convenience factory — equivalent to `new CdpWalletSigner(wallet)`.
|
|
59
|
+
*
|
|
60
|
+
* Useful for returning a `ProofportSigner` without exposing the concrete
|
|
61
|
+
* `CdpWalletSigner` class to callers.
|
|
62
|
+
*
|
|
63
|
+
* @example
|
|
64
|
+
* ```typescript
|
|
65
|
+
* import { fromExternalWallet } from '@zkproofport-ai/sdk';
|
|
66
|
+
*
|
|
67
|
+
* const signer = fromExternalWallet({
|
|
68
|
+
* getAddress: () => '0xYourAddress',
|
|
69
|
+
* signMessage: (msg) => myWallet.sign(msg),
|
|
70
|
+
* signTypedData: (domain, types, message) =>
|
|
71
|
+
* myWallet.signTypedData({ domain, types, message }),
|
|
72
|
+
* });
|
|
73
|
+
* ```
|
|
74
|
+
*/
|
|
75
|
+
export function fromExternalWallet(wallet) {
|
|
76
|
+
return new CdpWalletSigner(wallet);
|
|
77
|
+
}
|
|
89
78
|
//# sourceMappingURL=cdp.js.map
|
package/dist/cdp.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cdp.js","sourceRoot":"","sources":["../src/cdp.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"cdp.js","sourceRoot":"","sources":["../src/cdp.ts"],"names":[],"mappings":"AAiEA;;;;;;;;;;;;;;;GAeG;AACH,MAAM,OAAO,eAAe;IACT,MAAM,CAAiB;IAExC,YAAY,MAAsB;QAChC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAED,2EAA2E;IAC3E,UAAU;QACR,OAAO,IAAI,CAAC,MAAM,CAAC,UAAU,EAAE,CAAC;IAClC,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,WAAW,CAAC,OAAmB;QACnC,OAAO,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;IAC1C,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,aAAa,CACjB,MAKC,EACD,KAA4D,EAC5D,OAAgC;QAEhC,OAAO,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,MAAiC,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;IACtF,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,eAAe,CAAC,EAIrB;QACC,IAAI,OAAO,IAAI,CAAC,MAAM,CAAC,eAAe,KAAK,UAAU,EAAE,CAAC;YACtD,MAAM,IAAI,KAAK,CACb,0EAA0E;gBACxE,0EAA0E;gBAC1E,4CAA4C,CAC/C,CAAC;QACJ,CAAC;QACD,OAAO,IAAI,CAAC,MAAM,CAAC,eAAe,CAAC,EAAE,CAAC,CAAC;IACzC,CAAC;CACF;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,UAAU,kBAAkB,CAAC,MAAsB;IACvD,OAAO,IAAI,eAAe,CAAC,MAAM,CAAC,CAAC;AACrC,CAAC"}
|
package/dist/constants.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
export declare const CIRCUITS: Record<CircuitId, {
|
|
1
|
+
export declare const CIRCUITS: Record<string, {
|
|
3
2
|
displayName: string;
|
|
4
|
-
easSchemaId
|
|
5
|
-
functionSelector
|
|
3
|
+
easSchemaId?: string;
|
|
4
|
+
functionSelector?: string;
|
|
5
|
+
inputType?: string;
|
|
6
6
|
}>;
|
|
7
7
|
export declare const COINBASE_ATTESTER_CONTRACT = "0x357458739F90461b99789350868CD7CF330Dd7EE";
|
|
8
8
|
export declare const AUTHORIZED_SIGNERS: string[];
|
package/dist/constants.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE;IACpC,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAeA,CAAC;AAEF,eAAO,MAAM,0BAA0B,+CAA+C,CAAC;AAEvF,eAAO,MAAM,kBAAkB,UAK9B,CAAC;AAEF,eAAO,MAAM,cAAc;;;CAGjB,CAAC;AAEX,eAAO,MAAM,mBAAmB,qCAAqC,CAAC;AACtE,eAAO,MAAM,eAAe,6BAA6B,CAAC;AAE1D,eAAO,MAAM,oBAAoB,MAAM,CAAC;AACxC,eAAO,MAAM,sBAAsB,IAAI,CAAC;AACxC,eAAO,MAAM,uBAAuB,KAAK,CAAC"}
|
package/dist/constants.js
CHANGED
|
@@ -9,6 +9,10 @@ export const CIRCUITS = {
|
|
|
9
9
|
easSchemaId: '0x1801901fabd0e6189356b4fb52bb0ab855276d84f7ec140839fbd1f6801ca065',
|
|
10
10
|
functionSelector: '0x0a225248',
|
|
11
11
|
},
|
|
12
|
+
oidc_domain_attestation: {
|
|
13
|
+
displayName: 'OIDC Domain',
|
|
14
|
+
inputType: 'oidc',
|
|
15
|
+
},
|
|
12
16
|
};
|
|
13
17
|
export const COINBASE_ATTESTER_CONTRACT = '0x357458739F90461b99789350868CD7CF330Dd7EE';
|
|
14
18
|
export const AUTHORIZED_SIGNERS = [
|
package/dist/constants.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,QAAQ,
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,QAAQ,GAKhB;IACH,oBAAoB,EAAE;QACpB,WAAW,EAAE,cAAc;QAC3B,WAAW,EAAE,oEAAoE;QACjF,gBAAgB,EAAE,YAAY;KAC/B;IACD,4BAA4B,EAAE;QAC5B,WAAW,EAAE,kBAAkB;QAC/B,WAAW,EAAE,oEAAoE;QACjF,gBAAgB,EAAE,YAAY;KAC/B;IACD,uBAAuB,EAAE;QACvB,WAAW,EAAE,aAAa;QAC1B,SAAS,EAAE,MAAM;KAClB;CACF,CAAC;AAEF,MAAM,CAAC,MAAM,0BAA0B,GAAG,4CAA4C,CAAC;AAEvF,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAChC,4CAA4C;IAC5C,4CAA4C;IAC5C,4CAA4C;IAC5C,4CAA4C;CAC7C,CAAC;AAEF,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,cAAc,EAAE,4CAA4C;IAC5D,MAAM,EAAE,4CAA4C;CAC5C,CAAC;AAEX,MAAM,CAAC,MAAM,mBAAmB,GAAG,kCAAkC,CAAC;AACtE,MAAM,CAAC,MAAM,eAAe,GAAG,0BAA0B,CAAC;AAE1D,MAAM,CAAC,MAAM,oBAAoB,GAAG,GAAG,CAAC;AACxC,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,CAAC;AACxC,MAAM,CAAC,MAAM,uBAAuB,GAAG,EAAE,CAAC"}
|
package/dist/flow.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"flow.d.ts","sourceRoot":"","sources":["../src/flow.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,YAAY,
|
|
1
|
+
{"version":3,"file":"flow.d.ts","sourceRoot":"","sources":["../src/flow.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,YAAY,EAGZ,WAAW,EACX,WAAW,EACX,UAAU,EAEX,MAAM,YAAY,CAAC;AAMpB,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAKnD,MAAM,WAAW,aAAa;IAC5B,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,UAAU,KAAK,IAAI,CAAC;CACrC;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAsB,aAAa,CACjC,MAAM,EAAE,YAAY,EACpB,OAAO,EAAE;IAAE,WAAW,EAAE,eAAe,CAAC;IAAC,OAAO,CAAC,EAAE,eAAe,CAAA;CAAE,EACpE,MAAM,EAAE,WAAW,EACnB,SAAS,CAAC,EAAE,aAAa,GACxB,OAAO,CAAC,WAAW,CAAC,CAqHtB"}
|