@zkproofport-ai/sdk 0.1.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.
- package/README.md +437 -0
- package/dist/attestation.d.ts +60 -0
- package/dist/attestation.d.ts.map +1 -0
- package/dist/attestation.js +220 -0
- package/dist/attestation.js.map +1 -0
- package/dist/cdp.d.ts +44 -0
- package/dist/cdp.d.ts.map +1 -0
- package/dist/cdp.js +89 -0
- package/dist/cdp.js.map +1 -0
- package/dist/config.d.ts +19 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +25 -0
- package/dist/config.js.map +1 -0
- package/dist/constants.d.ts +18 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +29 -0
- package/dist/constants.js.map +1 -0
- package/dist/flow.d.ts +19 -0
- package/dist/flow.d.ts.map +1 -0
- package/dist/flow.js +82 -0
- package/dist/flow.js.map +1 -0
- package/dist/index.d.ts +17 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +22 -0
- package/dist/index.js.map +1 -0
- package/dist/inputs.d.ts +56 -0
- package/dist/inputs.d.ts.map +1 -0
- package/dist/inputs.js +204 -0
- package/dist/inputs.js.map +1 -0
- package/dist/merkle.d.ts +34 -0
- package/dist/merkle.d.ts.map +1 -0
- package/dist/merkle.js +95 -0
- package/dist/merkle.js.map +1 -0
- package/dist/payment.d.ts +15 -0
- package/dist/payment.d.ts.map +1 -0
- package/dist/payment.js +114 -0
- package/dist/payment.js.map +1 -0
- package/dist/prove.d.ts +12 -0
- package/dist/prove.d.ts.map +1 -0
- package/dist/prove.js +25 -0
- package/dist/prove.js.map +1 -0
- package/dist/session.d.ts +8 -0
- package/dist/session.d.ts.map +1 -0
- package/dist/session.js +20 -0
- package/dist/session.js.map +1 -0
- package/dist/signer.d.ts +69 -0
- package/dist/signer.d.ts.map +1 -0
- package/dist/signer.js +51 -0
- package/dist/signer.js.map +1 -0
- package/dist/types.d.ts +136 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +12 -0
- package/dist/types.js.map +1 -0
- package/dist/verify.d.ts +29 -0
- package/dist/verify.d.ts.map +1 -0
- package/dist/verify.js +56 -0
- package/dist/verify.js.map +1 -0
- package/package.json +34 -0
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
import { ethers } from 'ethers';
|
|
2
|
+
import { CIRCUITS, COINBASE_ATTESTER_CONTRACT, DEFAULT_EAS_GRAPHQL, DEFAULT_EAS_RPC } from './constants.js';
|
|
3
|
+
// ─── GraphQL query ──────────────────────────────────────────────────────
|
|
4
|
+
const EAS_ATTESTATIONS_QUERY = `
|
|
5
|
+
query GetAttestations($schemaId: String!, $recipient: String!) {
|
|
6
|
+
attestations(
|
|
7
|
+
where: {
|
|
8
|
+
schemaId: { equals: $schemaId }
|
|
9
|
+
recipient: { equals: $recipient }
|
|
10
|
+
revoked: { equals: false }
|
|
11
|
+
}
|
|
12
|
+
orderBy: [{ time: desc }]
|
|
13
|
+
take: 1
|
|
14
|
+
) {
|
|
15
|
+
id
|
|
16
|
+
txid
|
|
17
|
+
recipient
|
|
18
|
+
attester
|
|
19
|
+
time
|
|
20
|
+
expirationTime
|
|
21
|
+
schemaId
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
`;
|
|
25
|
+
// ─── Retry constants ────────────────────────────────────────────────────
|
|
26
|
+
const MAX_RETRIES = 3;
|
|
27
|
+
const RETRY_DELAY_MS = 1000;
|
|
28
|
+
const RETRYABLE_STATUS = new Set([429, 500, 502, 503, 504]);
|
|
29
|
+
// ─── EAS GraphQL fetch ──────────────────────────────────────────────────
|
|
30
|
+
/**
|
|
31
|
+
* Query EAS GraphQL for the latest attestation matching schemaId + recipient.
|
|
32
|
+
*/
|
|
33
|
+
export async function fetchAttestationFromEAS(easGraphqlUrl, circuitId, recipientAddress) {
|
|
34
|
+
const circuit = CIRCUITS[circuitId];
|
|
35
|
+
const schemaId = circuit.easSchemaId;
|
|
36
|
+
const response = await fetch(easGraphqlUrl, {
|
|
37
|
+
method: 'POST',
|
|
38
|
+
headers: { 'Content-Type': 'application/json' },
|
|
39
|
+
body: JSON.stringify({
|
|
40
|
+
query: EAS_ATTESTATIONS_QUERY,
|
|
41
|
+
variables: {
|
|
42
|
+
schemaId,
|
|
43
|
+
recipient: recipientAddress.toLowerCase(),
|
|
44
|
+
},
|
|
45
|
+
}),
|
|
46
|
+
});
|
|
47
|
+
if (!response.ok) {
|
|
48
|
+
throw new Error(`EAS GraphQL request failed: HTTP ${response.status}`);
|
|
49
|
+
}
|
|
50
|
+
const data = await response.json();
|
|
51
|
+
if (data.errors && data.errors.length > 0) {
|
|
52
|
+
throw new Error(`EAS GraphQL error: ${data.errors[0].message}`);
|
|
53
|
+
}
|
|
54
|
+
const attestations = data.data?.attestations;
|
|
55
|
+
if (!attestations || attestations.length === 0) {
|
|
56
|
+
throw new Error(`No attestation found for schema ${schemaId} and recipient ${recipientAddress}`);
|
|
57
|
+
}
|
|
58
|
+
return attestations[0];
|
|
59
|
+
}
|
|
60
|
+
// ─── Raw transaction fetch ──────────────────────────────────────────────
|
|
61
|
+
/**
|
|
62
|
+
* Fetch raw transaction via eth_getTransactionByHash from an RPC endpoint.
|
|
63
|
+
* Includes retry logic for 429/5xx responses with exponential backoff.
|
|
64
|
+
*/
|
|
65
|
+
export async function fetchRawTransaction(rpcUrl, txHash) {
|
|
66
|
+
let lastError;
|
|
67
|
+
for (let attempt = 0; attempt < MAX_RETRIES; attempt++) {
|
|
68
|
+
try {
|
|
69
|
+
const response = await fetch(rpcUrl, {
|
|
70
|
+
method: 'POST',
|
|
71
|
+
headers: { 'Content-Type': 'application/json' },
|
|
72
|
+
body: JSON.stringify({
|
|
73
|
+
jsonrpc: '2.0',
|
|
74
|
+
id: 1,
|
|
75
|
+
method: 'eth_getTransactionByHash',
|
|
76
|
+
params: [txHash],
|
|
77
|
+
}),
|
|
78
|
+
});
|
|
79
|
+
if (!response.ok) {
|
|
80
|
+
if (RETRYABLE_STATUS.has(response.status) && attempt < MAX_RETRIES - 1) {
|
|
81
|
+
lastError = new Error(`RPC request failed: HTTP ${response.status}`);
|
|
82
|
+
await new Promise(r => setTimeout(r, RETRY_DELAY_MS * (attempt + 1)));
|
|
83
|
+
continue;
|
|
84
|
+
}
|
|
85
|
+
throw new Error(`RPC request failed: HTTP ${response.status}`);
|
|
86
|
+
}
|
|
87
|
+
const data = await response.json();
|
|
88
|
+
if (data.error) {
|
|
89
|
+
throw new Error(`RPC error: ${data.error.message}`);
|
|
90
|
+
}
|
|
91
|
+
if (!data.result) {
|
|
92
|
+
throw new Error(`Transaction ${txHash} not found`);
|
|
93
|
+
}
|
|
94
|
+
return reconstructRawTransaction(data.result);
|
|
95
|
+
}
|
|
96
|
+
catch (err) {
|
|
97
|
+
lastError = err;
|
|
98
|
+
const cause = err?.cause?.code;
|
|
99
|
+
if (attempt < MAX_RETRIES - 1 && (cause === 'ECONNRESET' || cause === 'ETIMEDOUT')) {
|
|
100
|
+
await new Promise(r => setTimeout(r, RETRY_DELAY_MS * (attempt + 1)));
|
|
101
|
+
continue;
|
|
102
|
+
}
|
|
103
|
+
throw err;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
throw lastError || new Error(`RPC request failed after ${MAX_RETRIES} retries`);
|
|
107
|
+
}
|
|
108
|
+
// ─── Transaction reconstruction ─────────────────────────────────────────
|
|
109
|
+
/**
|
|
110
|
+
* Reconstruct a raw signed transaction hex from RPC response fields.
|
|
111
|
+
* Uses ethers v6 Transaction class. Returns tx.serialized (SIGNED).
|
|
112
|
+
*/
|
|
113
|
+
export function reconstructRawTransaction(txData) {
|
|
114
|
+
const txType = parseInt(txData.type, 16);
|
|
115
|
+
const tx = ethers.Transaction.from({
|
|
116
|
+
to: txData.to,
|
|
117
|
+
nonce: parseInt(txData.nonce, 16),
|
|
118
|
+
gasLimit: BigInt(txData.gas),
|
|
119
|
+
maxFeePerGas: txData.maxFeePerGas ? BigInt(txData.maxFeePerGas) : undefined,
|
|
120
|
+
maxPriorityFeePerGas: txData.maxPriorityFeePerGas ? BigInt(txData.maxPriorityFeePerGas) : undefined,
|
|
121
|
+
gasPrice: txData.gasPrice ? BigInt(txData.gasPrice) : undefined,
|
|
122
|
+
data: txData.input,
|
|
123
|
+
value: BigInt(txData.value),
|
|
124
|
+
chainId: BigInt(txData.chainId),
|
|
125
|
+
type: txType,
|
|
126
|
+
signature: {
|
|
127
|
+
r: txData.r,
|
|
128
|
+
s: txData.s,
|
|
129
|
+
v: parseInt(txData.v, 16),
|
|
130
|
+
},
|
|
131
|
+
accessList: txData.accessList || [],
|
|
132
|
+
});
|
|
133
|
+
return tx.serialized;
|
|
134
|
+
}
|
|
135
|
+
// ─── Validation ─────────────────────────────────────────────────────────
|
|
136
|
+
/**
|
|
137
|
+
* Validate the attestation transaction:
|
|
138
|
+
* - tx.to matches COINBASE_ATTESTER_CONTRACT
|
|
139
|
+
* - function selector matches the circuit's expected selector
|
|
140
|
+
*/
|
|
141
|
+
export function validateAttestationTx(rawTransaction, circuitId) {
|
|
142
|
+
const tx = ethers.Transaction.from(rawTransaction);
|
|
143
|
+
// Check destination
|
|
144
|
+
if (!tx.to || tx.to.toLowerCase() !== COINBASE_ATTESTER_CONTRACT.toLowerCase()) {
|
|
145
|
+
return {
|
|
146
|
+
valid: false,
|
|
147
|
+
error: `Transaction destination ${tx.to} does not match Coinbase Attester Contract ${COINBASE_ATTESTER_CONTRACT}`,
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
// Check function selector
|
|
151
|
+
const expectedSelector = CIRCUITS[circuitId].functionSelector;
|
|
152
|
+
const actualSelector = tx.data.slice(0, 10);
|
|
153
|
+
if (actualSelector !== expectedSelector) {
|
|
154
|
+
return {
|
|
155
|
+
valid: false,
|
|
156
|
+
error: `Function selector ${actualSelector} does not match expected ${expectedSelector} for ${circuitId}`,
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
return { valid: true };
|
|
160
|
+
}
|
|
161
|
+
// ─── Public key recovery ────────────────────────────────────────────────
|
|
162
|
+
/**
|
|
163
|
+
* Recover the Coinbase attester's uncompressed public key from the transaction signature.
|
|
164
|
+
* Returns "0x04..." (130 hex chars).
|
|
165
|
+
*/
|
|
166
|
+
export function recoverAttesterPubkey(rawTransaction) {
|
|
167
|
+
const tx = ethers.Transaction.from(rawTransaction);
|
|
168
|
+
// Reconstruct unsigned tx to get the hash that was signed
|
|
169
|
+
const unsignedTx = ethers.Transaction.from({
|
|
170
|
+
to: tx.to,
|
|
171
|
+
nonce: tx.nonce,
|
|
172
|
+
gasLimit: tx.gasLimit,
|
|
173
|
+
maxFeePerGas: tx.maxFeePerGas,
|
|
174
|
+
maxPriorityFeePerGas: tx.maxPriorityFeePerGas,
|
|
175
|
+
gasPrice: tx.gasPrice,
|
|
176
|
+
data: tx.data,
|
|
177
|
+
value: tx.value,
|
|
178
|
+
chainId: tx.chainId,
|
|
179
|
+
type: tx.type,
|
|
180
|
+
accessList: tx.accessList,
|
|
181
|
+
});
|
|
182
|
+
const unsignedTxHash = ethers.keccak256(unsignedTx.unsignedSerialized);
|
|
183
|
+
if (!tx.signature) {
|
|
184
|
+
throw new Error('Transaction has no signature');
|
|
185
|
+
}
|
|
186
|
+
const pubkey = ethers.SigningKey.recoverPublicKey(unsignedTxHash, tx.signature);
|
|
187
|
+
return pubkey;
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Get the signer address from a recovered public key.
|
|
191
|
+
*/
|
|
192
|
+
export function getSignerAddress(pubkey) {
|
|
193
|
+
return ethers.computeAddress(pubkey);
|
|
194
|
+
}
|
|
195
|
+
// ─── Full pipeline ──────────────────────────────────────────────────────
|
|
196
|
+
/**
|
|
197
|
+
* Full attestation fetch pipeline:
|
|
198
|
+
* 1. Query EAS GraphQL for the latest attestation
|
|
199
|
+
* 2. Fetch the raw transaction from RPC
|
|
200
|
+
* 3. Validate transaction fields
|
|
201
|
+
* 4. Return attestation + raw transaction
|
|
202
|
+
*/
|
|
203
|
+
export async function fetchAttestation(config, circuitId, recipientAddress) {
|
|
204
|
+
const easGraphqlUrl = config.easGraphqlUrl || DEFAULT_EAS_GRAPHQL;
|
|
205
|
+
const easRpcUrl = config.easRpcUrl || DEFAULT_EAS_RPC;
|
|
206
|
+
// Step 1: Query EAS
|
|
207
|
+
const attestation = await fetchAttestationFromEAS(easGraphqlUrl, circuitId, recipientAddress);
|
|
208
|
+
// Step 2: Fetch raw TX
|
|
209
|
+
const rawTransaction = await fetchRawTransaction(easRpcUrl, attestation.txid);
|
|
210
|
+
// Step 3: Validate
|
|
211
|
+
const validation = validateAttestationTx(rawTransaction, circuitId);
|
|
212
|
+
if (!validation.valid) {
|
|
213
|
+
throw new Error(`Attestation TX validation failed: ${validation.error}`);
|
|
214
|
+
}
|
|
215
|
+
return {
|
|
216
|
+
attestation,
|
|
217
|
+
rawTransaction,
|
|
218
|
+
};
|
|
219
|
+
}
|
|
220
|
+
//# sourceMappingURL=attestation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"attestation.js","sourceRoot":"","sources":["../src/attestation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,QAAQ,EAAE,0BAA0B,EAAE,mBAAmB,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAG5G,2EAA2E;AAE3E,MAAM,sBAAsB,GAAG;;;;;;;;;;;;;;;;;;;;CAoB9B,CAAC;AAEF,2EAA2E;AAE3E,MAAM,WAAW,GAAG,CAAC,CAAC;AACtB,MAAM,cAAc,GAAG,IAAI,CAAC;AAC5B,MAAM,gBAAgB,GAAG,IAAI,GAAG,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC;AAE5D,2EAA2E;AAE3E;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,uBAAuB,CAC3C,aAAqB,EACrB,SAAoB,EACpB,gBAAwB;IA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AA2E;AAE3E;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CACpC,MAAoB,EACpB,SAAoB,EACpB,gBAAwB;IAExB,MAAM,aAAa,GAAG,MAAM,CAAC,aAAa,IAAI,mBAAmB,CAAC;IAClE,MAAM,SAAS,GAAG,MAAM,CAAC,SAAS,IAAI,eAAe,CAAC;IAEtD,oBAAoB;IACpB,MAAM,WAAW,GAAG,MAAM,uBAAuB,CAC/C,aAAa,EACb,SAAS,EACT,gBAAgB,CACjB,CAAC;IAEF,uBAAuB;IACvB,MAAM,cAAc,GAAG,MAAM,mBAAmB,CAAC,SAAS,EAAE,WAAW,CAAC,IAAI,CAAC,CAAC;IAE9E,mBAAmB;IACnB,MAAM,UAAU,GAAG,qBAAqB,CAAC,cAAc,EAAE,SAAS,CAAC,CAAC;IACpE,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE,CAAC;QACtB,MAAM,IAAI,KAAK,CAAC,qCAAqC,UAAU,CAAC,KAAK,EAAE,CAAC,CAAC;IAC3E,CAAC;IAED,OAAO;QACL,WAAW;QACX,cAAc;KACf,CAAC;AACJ,CAAC"}
|
package/dist/cdp.d.ts
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { ProofportSigner } from './signer.js';
|
|
2
|
+
/**
|
|
3
|
+
* CDP MPC Wallet adapter implementing ProofportSigner.
|
|
4
|
+
* Uses Coinbase AgentKit's CdpEvmWalletProvider for key management.
|
|
5
|
+
* Private keys never leave Coinbase's TEE.
|
|
6
|
+
*/
|
|
7
|
+
export declare class CdpWalletSigner implements ProofportSigner {
|
|
8
|
+
private provider;
|
|
9
|
+
private constructor();
|
|
10
|
+
/**
|
|
11
|
+
* Create a CdpWalletSigner from environment variables.
|
|
12
|
+
* Requires: CDP_API_KEY_ID, CDP_API_KEY_SECRET, CDP_WALLET_SECRET
|
|
13
|
+
* Optional: CDP_WALLET_ADDRESS (to load existing wallet), CDP_NETWORK_ID (default: base-sepolia)
|
|
14
|
+
*/
|
|
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
|
+
signMessage(message: Uint8Array): Promise<string>;
|
|
24
|
+
signTypedData(domain: {
|
|
25
|
+
name: string;
|
|
26
|
+
version: string;
|
|
27
|
+
chainId: number;
|
|
28
|
+
verifyingContract: string;
|
|
29
|
+
}, types: Record<string, Array<{
|
|
30
|
+
name: string;
|
|
31
|
+
type: string;
|
|
32
|
+
}>>, message: Record<string, unknown>): Promise<string>;
|
|
33
|
+
sendTransaction(tx: {
|
|
34
|
+
to: string;
|
|
35
|
+
data: string;
|
|
36
|
+
value?: bigint;
|
|
37
|
+
}): Promise<{
|
|
38
|
+
hash: string;
|
|
39
|
+
wait(): Promise<{
|
|
40
|
+
status: number | null;
|
|
41
|
+
}>;
|
|
42
|
+
}>;
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=cdp.d.ts.map
|
|
@@ -0,0 +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;;;;GAIG;AACH,qBAAa,eAAgB,YAAW,eAAe;IAErD,OAAO,CAAC,QAAQ,CAAM;IAEtB,OAAO;IAIP;;;;OAIG;WACU,MAAM,CAAC,IAAI,CAAC,EAAE;QACzB,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,YAAY,CAAC,EAAE,MAAM,CAAC;QACtB,YAAY,CAAC,EAAE,MAAM,CAAC;QACtB,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,OAAO,CAAC,EAAE,MAAM,CAAC;KAClB,GAAG,OAAO,CAAC,eAAe,CAAC;IA4B5B,UAAU,IAAI,MAAM;IAId,WAAW,CAAC,OAAO,EAAE,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC;IAIjD,aAAa,CACjB,MAAM,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,iBAAiB,EAAE,MAAM,CAAA;KAAE,EACrF,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;IAsBZ,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;CAsB1E"}
|
package/dist/cdp.js
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CDP MPC Wallet adapter implementing ProofportSigner.
|
|
3
|
+
* Uses Coinbase AgentKit's CdpEvmWalletProvider for key management.
|
|
4
|
+
* Private keys never leave Coinbase's TEE.
|
|
5
|
+
*/
|
|
6
|
+
export class CdpWalletSigner {
|
|
7
|
+
// Store the wallet provider as `any` to avoid hard dependency on @coinbase/agentkit types
|
|
8
|
+
provider;
|
|
9
|
+
constructor(provider) {
|
|
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);
|
|
39
|
+
}
|
|
40
|
+
getAddress() {
|
|
41
|
+
return this.provider.getAddress();
|
|
42
|
+
}
|
|
43
|
+
async signMessage(message) {
|
|
44
|
+
return this.provider.signMessage(message);
|
|
45
|
+
}
|
|
46
|
+
async signTypedData(domain, types, message) {
|
|
47
|
+
// Bridge ethers 3-arg style → viem single-object style
|
|
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
|
+
});
|
|
65
|
+
}
|
|
66
|
+
async sendTransaction(tx) {
|
|
67
|
+
// AgentKit's sendTransaction returns just the tx hash
|
|
68
|
+
const hash = await this.provider.sendTransaction({
|
|
69
|
+
to: tx.to,
|
|
70
|
+
data: tx.data,
|
|
71
|
+
value: tx.value ?? 0n,
|
|
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
|
+
};
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
//# sourceMappingURL=cdp.js.map
|
package/dist/cdp.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cdp.js","sourceRoot":"","sources":["../src/cdp.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,MAAM,OAAO,eAAe;IAC1B,0FAA0F;IAClF,QAAQ,CAAM;IAEtB,YAAoB,QAAa;QAC/B,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC3B,CAAC;IAED;;;;OAIG;IACH,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,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C,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;gBAC1B,CAAC;YACH,CAAC;SACF,CAAC;IACJ,CAAC;CACF"}
|
package/dist/config.d.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { ClientConfig } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Create a client configuration with sensible defaults.
|
|
4
|
+
* Defaults to mainnet (production) settings.
|
|
5
|
+
*
|
|
6
|
+
* @param overrides - Optional overrides for any config field
|
|
7
|
+
* @returns Complete ClientConfig
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```typescript
|
|
11
|
+
* // Mainnet (default)
|
|
12
|
+
* const config = createConfig();
|
|
13
|
+
*
|
|
14
|
+
* // Custom server URL
|
|
15
|
+
* const config = createConfig({ baseUrl: 'https://custom-server.example.com' });
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
export declare function createConfig(overrides?: Partial<ClientConfig>): ClientConfig;
|
|
19
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE/C;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,YAAY,CAAC,SAAS,CAAC,EAAE,OAAO,CAAC,YAAY,CAAC,GAAG,YAAY,CAO5E"}
|
package/dist/config.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Create a client configuration with sensible defaults.
|
|
3
|
+
* Defaults to mainnet (production) settings.
|
|
4
|
+
*
|
|
5
|
+
* @param overrides - Optional overrides for any config field
|
|
6
|
+
* @returns Complete ClientConfig
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* // Mainnet (default)
|
|
11
|
+
* const config = createConfig();
|
|
12
|
+
*
|
|
13
|
+
* // Custom server URL
|
|
14
|
+
* const config = createConfig({ baseUrl: 'https://custom-server.example.com' });
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
export function createConfig(overrides) {
|
|
18
|
+
return {
|
|
19
|
+
baseUrl: 'https://ai.zkproofport.app',
|
|
20
|
+
easRpcUrl: 'https://mainnet.base.org',
|
|
21
|
+
easGraphqlUrl: 'https://base.easscan.org/graphql',
|
|
22
|
+
...overrides,
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,YAAY,CAAC,SAAiC;IAC5D,OAAO;QACL,OAAO,EAAE,4BAA4B;QACrC,SAAS,EAAE,0BAA0B;QACrC,aAAa,EAAE,kCAAkC;QACjD,GAAG,SAAS;KACb,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { CircuitId } from './types.js';
|
|
2
|
+
export declare const CIRCUITS: Record<CircuitId, {
|
|
3
|
+
displayName: string;
|
|
4
|
+
easSchemaId: string;
|
|
5
|
+
functionSelector: string;
|
|
6
|
+
}>;
|
|
7
|
+
export declare const COINBASE_ATTESTER_CONTRACT = "0x357458739F90461b99789350868CD7CF330Dd7EE";
|
|
8
|
+
export declare const AUTHORIZED_SIGNERS: string[];
|
|
9
|
+
export declare const USDC_ADDRESSES: {
|
|
10
|
+
readonly 'base-sepolia': "0x036CbD53842c5426634e7929541eC2318f3dCF7e";
|
|
11
|
+
readonly base: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913";
|
|
12
|
+
};
|
|
13
|
+
export declare const DEFAULT_EAS_GRAPHQL = "https://base.easscan.org/graphql";
|
|
14
|
+
export declare const DEFAULT_EAS_RPC = "https://mainnet.base.org";
|
|
15
|
+
export declare const RAW_TX_PADDED_LENGTH = 300;
|
|
16
|
+
export declare const MERKLE_PROOF_MAX_DEPTH = 8;
|
|
17
|
+
export declare const COUNTRY_LIST_MAX_LENGTH = 10;
|
|
18
|
+
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAE5C,eAAO,MAAM,QAAQ,EAAE,MAAM,CAAC,SAAS,EAAE;IACvC,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,gBAAgB,EAAE,MAAM,CAAC;CAC1B,CAWA,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"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export const CIRCUITS = {
|
|
2
|
+
coinbase_attestation: {
|
|
3
|
+
displayName: 'Coinbase KYC',
|
|
4
|
+
easSchemaId: '0xf8b05c79f090979bf4a80270aba232dff11a10d9ca55c4f88de95317970f0de9',
|
|
5
|
+
functionSelector: '0x56feed5e',
|
|
6
|
+
},
|
|
7
|
+
coinbase_country_attestation: {
|
|
8
|
+
displayName: 'Coinbase Country',
|
|
9
|
+
easSchemaId: '0x1801901fabd0e6189356b4fb52bb0ab855276d84f7ec140839fbd1f6801ca065',
|
|
10
|
+
functionSelector: '0x0a225248',
|
|
11
|
+
},
|
|
12
|
+
};
|
|
13
|
+
export const COINBASE_ATTESTER_CONTRACT = '0x357458739F90461b99789350868CD7CF330Dd7EE';
|
|
14
|
+
export const AUTHORIZED_SIGNERS = [
|
|
15
|
+
'0x952f32128AF084422539C4Ff96df5C525322E564',
|
|
16
|
+
'0x8844591D47F17bcA6F5dF8f6B64F4a739F1C0080',
|
|
17
|
+
'0x88fe64ea2e121f49bb77abea6c0a45e93638c3c5',
|
|
18
|
+
'0x44ace9abb148e8412ac4492e9a1ae6bd88226803',
|
|
19
|
+
];
|
|
20
|
+
export const USDC_ADDRESSES = {
|
|
21
|
+
'base-sepolia': '0x036CbD53842c5426634e7929541eC2318f3dCF7e',
|
|
22
|
+
'base': '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913',
|
|
23
|
+
};
|
|
24
|
+
export const DEFAULT_EAS_GRAPHQL = 'https://base.easscan.org/graphql';
|
|
25
|
+
export const DEFAULT_EAS_RPC = 'https://mainnet.base.org';
|
|
26
|
+
export const RAW_TX_PADDED_LENGTH = 300;
|
|
27
|
+
export const MERKLE_PROOF_MAX_DEPTH = 8;
|
|
28
|
+
export const COUNTRY_LIST_MAX_LENGTH = 10;
|
|
29
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,QAAQ,GAIhB;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;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
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { ClientConfig, ProofParams, ProofResult, StepResult } from './types.js';
|
|
2
|
+
import type { ProofportSigner } from './signer.js';
|
|
3
|
+
export interface FlowCallbacks {
|
|
4
|
+
onStep?: (step: StepResult) => void;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Generate a ZK proof end-to-end using x402 single-step flow.
|
|
8
|
+
*
|
|
9
|
+
* @param config - Server URL and RPC endpoints
|
|
10
|
+
* @param signers - ProofportSigner for attestation (required) and payment (optional, defaults to attestation)
|
|
11
|
+
* @param params - Circuit name, scope, and optional country params
|
|
12
|
+
* @param callbacks - Optional callbacks for step progress
|
|
13
|
+
* @returns ProofResult with proof, publicInputs, payment info
|
|
14
|
+
*/
|
|
15
|
+
export declare function generateProof(config: ClientConfig, signers: {
|
|
16
|
+
attestation: ProofportSigner;
|
|
17
|
+
payment?: ProofportSigner;
|
|
18
|
+
}, params: ProofParams, callbacks?: FlowCallbacks): Promise<ProofResult>;
|
|
19
|
+
//# sourceMappingURL=flow.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"flow.d.ts","sourceRoot":"","sources":["../src/flow.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,YAAY,EAEZ,WAAW,EACX,WAAW,EACX,UAAU,EAEX,MAAM,YAAY,CAAC;AAMpB,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAGnD,MAAM,WAAW,aAAa;IAC5B,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,UAAU,KAAK,IAAI,CAAC;CACrC;AAED;;;;;;;;GAQG;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,CA0EtB"}
|
package/dist/flow.js
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { ethers } from 'ethers';
|
|
2
|
+
import { CIRCUIT_NAME_MAP } from './types.js';
|
|
3
|
+
import { requestChallenge } from './session.js';
|
|
4
|
+
import { prepareInputs, computeSignalHash } from './inputs.js';
|
|
5
|
+
import { makePayment } from './payment.js';
|
|
6
|
+
import { submitProof } from './prove.js';
|
|
7
|
+
import { USDC_ADDRESSES } from './constants.js';
|
|
8
|
+
/**
|
|
9
|
+
* Generate a ZK proof end-to-end using x402 single-step flow.
|
|
10
|
+
*
|
|
11
|
+
* @param config - Server URL and RPC endpoints
|
|
12
|
+
* @param signers - ProofportSigner for attestation (required) and payment (optional, defaults to attestation)
|
|
13
|
+
* @param params - Circuit name, scope, and optional country params
|
|
14
|
+
* @param callbacks - Optional callbacks for step progress
|
|
15
|
+
* @returns ProofResult with proof, publicInputs, payment info
|
|
16
|
+
*/
|
|
17
|
+
export async function generateProof(config, signers, params, callbacks) {
|
|
18
|
+
const circuitId = CIRCUIT_NAME_MAP[params.circuit];
|
|
19
|
+
const scope = params.scope || 'proofport';
|
|
20
|
+
const paymentSigner = signers.payment || signers.attestation;
|
|
21
|
+
const steps = [];
|
|
22
|
+
function recordStep(step, name, data, startTime) {
|
|
23
|
+
const result = { step, name, data, durationMs: Date.now() - startTime };
|
|
24
|
+
steps.push(result);
|
|
25
|
+
callbacks?.onStep?.(result);
|
|
26
|
+
return data;
|
|
27
|
+
}
|
|
28
|
+
// Step 1: Sign signal hash with attestation signer
|
|
29
|
+
let t = Date.now();
|
|
30
|
+
const attestationAddress = await signers.attestation.getAddress();
|
|
31
|
+
const signalHash = computeSignalHash(attestationAddress, scope, circuitId);
|
|
32
|
+
const signalHashHex = ethers.hexlify(signalHash);
|
|
33
|
+
const signature = await signers.attestation.signMessage(signalHash);
|
|
34
|
+
recordStep(1, 'Sign Signal Hash', { signalHash: signalHashHex, signature }, t);
|
|
35
|
+
// Step 2: Prepare circuit inputs
|
|
36
|
+
t = Date.now();
|
|
37
|
+
const inputs = await prepareInputs(config, {
|
|
38
|
+
circuitId,
|
|
39
|
+
userAddress: attestationAddress,
|
|
40
|
+
userSignature: signature,
|
|
41
|
+
scope,
|
|
42
|
+
countryList: params.countryList,
|
|
43
|
+
isIncluded: params.isIncluded,
|
|
44
|
+
});
|
|
45
|
+
recordStep(2, 'Prepare Inputs', inputs, t);
|
|
46
|
+
// Step 3: Request 402 challenge (POST /prove without payment headers)
|
|
47
|
+
t = Date.now();
|
|
48
|
+
const challenge = await requestChallenge(config, params.circuit, inputs);
|
|
49
|
+
recordStep(3, 'Request Challenge', challenge, t);
|
|
50
|
+
// Step 4: Make payment
|
|
51
|
+
t = Date.now();
|
|
52
|
+
const network = challenge.payment.network;
|
|
53
|
+
const paymentInfo = {
|
|
54
|
+
nonce: challenge.nonce,
|
|
55
|
+
recipient: challenge.payment.payTo,
|
|
56
|
+
amount: parseInt(challenge.payment.maxAmountRequired),
|
|
57
|
+
asset: USDC_ADDRESSES[network],
|
|
58
|
+
network: challenge.payment.network,
|
|
59
|
+
instruction: challenge.payment.description,
|
|
60
|
+
};
|
|
61
|
+
const paymentTxHash = await makePayment(paymentSigner, paymentInfo);
|
|
62
|
+
recordStep(4, 'Make Payment', { txHash: paymentTxHash }, t);
|
|
63
|
+
// Step 5: Submit proof with payment headers
|
|
64
|
+
t = Date.now();
|
|
65
|
+
const proveResponse = await submitProof(config, {
|
|
66
|
+
circuit: params.circuit,
|
|
67
|
+
inputs,
|
|
68
|
+
paymentTxHash,
|
|
69
|
+
paymentNonce: challenge.nonce,
|
|
70
|
+
});
|
|
71
|
+
recordStep(5, 'Generate Proof', proveResponse, t);
|
|
72
|
+
return {
|
|
73
|
+
proof: proveResponse.proof,
|
|
74
|
+
publicInputs: proveResponse.publicInputs,
|
|
75
|
+
proofWithInputs: proveResponse.proofWithInputs,
|
|
76
|
+
paymentTxHash,
|
|
77
|
+
attestation: proveResponse.attestation,
|
|
78
|
+
timing: proveResponse.timing,
|
|
79
|
+
verification: proveResponse.verification,
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
//# sourceMappingURL=flow.js.map
|
package/dist/flow.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"flow.js","sourceRoot":"","sources":["../src/flow.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAShC,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAC/D,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAEzC,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAMhD;;;;;;;;GAQG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CACjC,MAAoB,EACpB,OAAoE,EACpE,MAAmB,EACnB,SAAyB;IAEzB,MAAM,SAAS,GAAc,gBAAgB,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IAC9D,MAAM,KAAK,GAAG,MA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aAAa,EAAE,CAAC,CAAC,CAAC;IAElD,OAAO;QACL,KAAK,EAAE,aAAa,CAAC,KAAK;QAC1B,YAAY,EAAE,aAAa,CAAC,YAAY;QACxC,eAAe,EAAE,aAAa,CAAC,eAAe;QAC9C,aAAa;QACb,WAAW,EAAE,aAAa,CAAC,WAAW;QACtC,MAAM,EAAE,aAAa,CAAC,MAAM;QAC5B,YAAY,EAAE,aAAa,CAAC,YAAY;KACzC,CAAC;AACJ,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export type { ClientConfig, CircuitName, CircuitId, PaymentInfo, PaymentRequirements, ChallengeResponse, ProveInputs, ProveRequest, ProveResponse, VerifyResult, EASAttestation, AttestationData, ProofParams, ProofResult, StepResult, } from './types.js';
|
|
2
|
+
export { CIRCUIT_NAME_MAP, CIRCUIT_ID_MAP } from './types.js';
|
|
3
|
+
export { CIRCUITS, COINBASE_ATTESTER_CONTRACT, AUTHORIZED_SIGNERS, USDC_ADDRESSES, } from './constants.js';
|
|
4
|
+
export { createConfig } from './config.js';
|
|
5
|
+
export { generateProof } from './flow.js';
|
|
6
|
+
export type { FlowCallbacks } from './flow.js';
|
|
7
|
+
export { requestChallenge, createSession } from './session.js';
|
|
8
|
+
export { makePayment } from './payment.js';
|
|
9
|
+
export { submitProof } from './prove.js';
|
|
10
|
+
export { verifyOnChain, verifyProof } from './verify.js';
|
|
11
|
+
export { prepareInputs, computeSignalHash, computeScope, computeNullifier, recoverUserPubkey, hexToBytes, extractPubkeyCoordinates, } from './inputs.js';
|
|
12
|
+
export type { ProofportSigner } from './signer.js';
|
|
13
|
+
export { EthersWalletSigner, fromEthersWallet, fromPrivateKey } from './signer.js';
|
|
14
|
+
export { CdpWalletSigner } from './cdp.js';
|
|
15
|
+
export { fetchAttestation, fetchAttestationFromEAS, fetchRawTransaction, recoverAttesterPubkey, getSignerAddress, } from './attestation.js';
|
|
16
|
+
export { SimpleMerkleTree, findSignerIndex, buildSignerMerkleTree, } from './merkle.js';
|
|
17
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,YAAY,EACV,YAAY,EACZ,WAAW,EACX,SAAS,EACT,WAAW,EACX,mBAAmB,EACnB,iBAAiB,EACjB,WAAW,EACX,YAAY,EACZ,aAAa,EACb,YAAY,EACZ,cAAc,EACd,eAAe,EACf,WAAW,EACX,WAAW,EACX,UAAU,GACX,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAG9D,OAAO,EACL,QAAQ,EACR,0BAA0B,EAC1B,kBAAkB,EAClB,cAAc,GACf,MAAM,gBAAgB,CAAC;AAGxB,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAG3C,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC1C,YAAY,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAG/C,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC/D,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AACzC,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAGzD,OAAO,EACL,aAAa,EACb,iBAAiB,EACjB,YAAY,EACZ,gBAAgB,EAChB,iBAAiB,EACjB,UAAU,EACV,wBAAwB,GACzB,MAAM,aAAa,CAAC;AAGrB,YAAY,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAGnF,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAG3C,OAAO,EACL,gBAAgB,EAChB,uBAAuB,EACvB,mBAAmB,EACnB,qBAAqB,EACrB,gBAAgB,GACjB,MAAM,kBAAkB,CAAC;AAG1B,OAAO,EACL,gBAAgB,EAChB,eAAe,EACf,qBAAqB,GACtB,MAAM,aAAa,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export { CIRCUIT_NAME_MAP, CIRCUIT_ID_MAP } from './types.js';
|
|
2
|
+
// Constants
|
|
3
|
+
export { CIRCUITS, COINBASE_ATTESTER_CONTRACT, AUTHORIZED_SIGNERS, USDC_ADDRESSES, } from './constants.js';
|
|
4
|
+
// Configuration
|
|
5
|
+
export { createConfig } from './config.js';
|
|
6
|
+
// Flow (main entry point)
|
|
7
|
+
export { generateProof } from './flow.js';
|
|
8
|
+
// Individual steps (for step-by-step usage)
|
|
9
|
+
export { requestChallenge, createSession } from './session.js';
|
|
10
|
+
export { makePayment } from './payment.js';
|
|
11
|
+
export { submitProof } from './prove.js';
|
|
12
|
+
export { verifyOnChain, verifyProof } from './verify.js';
|
|
13
|
+
// Input computation
|
|
14
|
+
export { prepareInputs, computeSignalHash, computeScope, computeNullifier, recoverUserPubkey, hexToBytes, extractPubkeyCoordinates, } from './inputs.js';
|
|
15
|
+
export { EthersWalletSigner, fromEthersWallet, fromPrivateKey } from './signer.js';
|
|
16
|
+
// CDP (Coinbase Developer Platform) signer
|
|
17
|
+
export { CdpWalletSigner } from './cdp.js';
|
|
18
|
+
// Attestation
|
|
19
|
+
export { fetchAttestation, fetchAttestationFromEAS, fetchRawTransaction, recoverAttesterPubkey, getSignerAddress, } from './attestation.js';
|
|
20
|
+
// Merkle
|
|
21
|
+
export { SimpleMerkleTree, findSignerIndex, buildSignerMerkleTree, } from './merkle.js';
|
|
22
|
+
//# sourceMappingURL=index.js.map
|