@zkp2p/sdk 0.4.3 → 0.5.2

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 CHANGED
@@ -6,7 +6,7 @@
6
6
 
7
7
  Stable TypeScript SDK for trustless fiat-to-crypto on Base. ZKP2P combines escrowed on-chain settlement, TLS attestations for payment verification, and API/indexer helpers so makers, takers, wallets, and embedded ramps can ship production-grade fiat liquidity flows without building their own contract or indexing stack.
8
8
 
9
- Current version: `0.3.3`
9
+ Current version: `0.5.0`
10
10
 
11
11
  ## Why This SDK
12
12
 
@@ -105,50 +105,59 @@ Indexer defaults by environment:
105
105
  | React hooks | `@zkp2p/sdk/react` exports hooks for deposits, intents, delegation, vaults, payment methods, and taker tier |
106
106
  | Attribution | ERC-8021 helpers like `sendTransactionWithAttribution`, `encodeWithAttribution`, and `txOverrides.referrer` support |
107
107
 
108
- ## Extension Onramp Deeplinks
108
+ ## Extension Metadata Bridge
109
109
 
110
- Use `createPeerExtensionSdk()` when a third-party page has signaled an intent and should hand payment authentication and proof generation into the Peer extension.
110
+ Use `createPeerExtensionSdk()` when a page needs the Peer extension to open a
111
+ provider auth tab and interact with the Peer TEE protocol. The extension owns
112
+ provider-tab capture and Buyer TEE session encryption. For seller automated
113
+ release, the extension captures seller session material, creates the encrypted
114
+ attestation-service bundle, and returns only that bundle plus the maker
115
+ `offchainId`. The page owns maker payee registration and curator credential
116
+ storage.
111
117
 
112
118
  ```ts
113
119
  import { createPeerExtensionSdk } from '@zkp2p/sdk';
114
120
 
115
121
  const peer = createPeerExtensionSdk();
116
- const intentHash = await client.signalIntent({
117
- // quote-selected intent params
118
- });
119
122
 
120
- const submitPreparedTransaction = async ({ transaction }) => {
121
- await walletClient.sendTransaction({
122
- to: transaction.to,
123
- data: transaction.data,
124
- value: BigInt(transaction.value),
125
- });
126
- };
127
-
128
- const existing = await peer.getOnrampTransaction(intentHash);
129
- if (existing) {
130
- await submitPreparedTransaction(existing);
131
- } else {
132
- peer.onramp(
133
- {
134
- intentHash,
135
- referrer: 'Liquidity Page',
136
- inputCurrency: 'USD',
137
- inputAmount: '500',
138
- paymentPlatform: 'venmo',
139
- depositId: '12345678901234567890',
140
- amountUsdc: '488280000',
141
- toToken: '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913',
142
- recipientAddress: '0xRecipient',
143
- },
144
- submitPreparedTransaction,
145
- );
123
+ if ((await peer.getState()) === 'needs_connection') {
124
+ await peer.requestConnection();
146
125
  }
147
- ```
148
126
 
149
- For exact-deposit handoffs, pass `depositId` as a string or bigint unless it is known to be a JavaScript-safe integer. The extension derives payment method hashes from `paymentPlatform`; do not pass escrow addresses, payment method hashes, or hashed on-chain ids through the onramp URL. `getOnrampTransaction(intentHash)` is the pull recovery path for prepared calldata when the callback message was missed.
127
+ const unsubscribe = peer.onMetadataMessage((message) => {
128
+ if (message.sarCredentialCapture) {
129
+ console.log('SAR credential bundle captured', message.sarCredentialCapture.credentialBundle);
130
+ return;
131
+ }
150
132
 
151
- See [Extension Onramp Deeplinks](../../docs/extension-onramp-deeplinks.md) for the full parameter contract, exact-deposit semantics, and prepared calldata recovery behavior.
133
+ console.log('captured payment metadata', message.metadata);
134
+ });
135
+
136
+ peer.authenticate({
137
+ actionType: 'transfer_venmo',
138
+ captureMode: 'buyerTee',
139
+ platform: 'venmo',
140
+ attestationServiceUrl: 'https://attestation.zkp2p.xyz',
141
+ });
142
+ ```
143
+
144
+ `requestConnection()` is required for third-party origins. `authenticate()`
145
+ accepts an optional inline `providerConfig` object; otherwise the extension
146
+ fetches the default template from `https://api.zkp2p.xyz/providers/`. Buyer TEE
147
+ is API/template driven: pass `captureMode: "buyerTee"` plus
148
+ `attestationServiceUrl`, and the extension returns encrypted session material.
149
+ For SAR, pass `captureMode: "sellerCredential"` and optionally pass
150
+ `attestationServiceUrl` only when overriding the extension's production
151
+ attestation default. The extension returns `sarCredentialCapture.credentialBundle`
152
+ plus `offchainId`. The page should call `apiUploadSellerCredentialBundle()` to
153
+ register maker payee details with curator, compare the registered hash to the
154
+ bundle `payeeIdHash`, and store the encrypted bundle with curator. Plaintext
155
+ seller session material is never returned to the page.
156
+
157
+ `Zkp2pClient.uploadSellerCredential()` remains the backwards-compatible
158
+ plaintext convenience path for mobile and React Native callers. Internally it
159
+ creates the encrypted bundle, then uses the same
160
+ `apiUploadSellerCredentialBundle()` storage helper.
152
161
 
153
162
  ## Create a Deposit
154
163
 
@@ -247,7 +256,11 @@ const intentHash = await client.signalIntent({
247
256
 
248
257
  await client.fulfillIntent({
249
258
  intentHash,
250
- proof: zkTlsProofJson,
259
+ proof: {
260
+ proofType: 'buyerTee',
261
+ encryptedSessionMaterial,
262
+ params: buyerTeePaymentParams,
263
+ },
251
264
  });
252
265
 
253
266
  await client.releaseFundsToPayer({
@@ -406,7 +419,7 @@ await client.setDepositWhitelistHook({
406
419
  });
407
420
  ```
408
421
 
409
- Use `removeDelegate()` and `clearRateManager()` to unwind delegation. Phase-4 hook methods are available when the target deployment supports them.
422
+ Use `removeDelegate()` and `clearRateManager()` to unwind delegation. Hook methods are part of the current V2 surface; still validate target contract support before assuming a deployment exposes every hook.
410
423
 
411
424
  ## Vault / DRM
412
425
 
@@ -502,6 +515,11 @@ const fulfilledEvents = await client.indexer.getFulfilledIntentEvents(['0xIntent
502
515
  const fulfillment = await client.indexer.getIntentFulfillmentAmounts('0xIntentHash');
503
516
  const fulfillmentAndPayment = await client.indexer.getFulfillmentAndPayment('0xIntentHash');
504
517
 
518
+ // Received USDC:
519
+ // - fulfilledEvents[0].amount is the net USDC transferred to the taker.
520
+ // - fulfillment.takerAmountNetFees is the same net taker amount from the Intent row.
521
+ // - fulfillment.releasedAmount is gross USDC released from the deposit before fees.
522
+
505
523
  // Fund activity and snapshots
506
524
  const fundActivities = await client.indexer.getDepositFundActivities('8453_0xEscrowAddress_42');
507
525
  const makerActivities = await client.indexer.getMakerFundActivities('0xMaker', 50);