@abbababa/sdk 0.7.0 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (83) hide show
  1. package/README.md +178 -60
  2. package/dist/agents.d.ts +15 -4
  3. package/dist/agents.d.ts.map +1 -1
  4. package/dist/agents.js +14 -1
  5. package/dist/agents.js.map +1 -1
  6. package/dist/buyer.d.ts +136 -25
  7. package/dist/buyer.d.ts.map +1 -1
  8. package/dist/buyer.js +277 -45
  9. package/dist/buyer.js.map +1 -1
  10. package/dist/channels.d.ts +2 -2
  11. package/dist/channels.d.ts.map +1 -1
  12. package/dist/channels.js.map +1 -1
  13. package/dist/checkout.d.ts +2 -2
  14. package/dist/checkout.d.ts.map +1 -1
  15. package/dist/checkout.js.map +1 -1
  16. package/dist/client.d.ts +3 -3
  17. package/dist/client.d.ts.map +1 -1
  18. package/dist/client.js +7 -6
  19. package/dist/client.js.map +1 -1
  20. package/dist/crypto.d.ts +93 -0
  21. package/dist/crypto.d.ts.map +1 -0
  22. package/dist/crypto.js +298 -0
  23. package/dist/crypto.js.map +1 -0
  24. package/dist/errors.d.ts +7 -7
  25. package/dist/errors.d.ts.map +1 -1
  26. package/dist/errors.js +8 -8
  27. package/dist/errors.js.map +1 -1
  28. package/dist/index.d.ts +9 -3
  29. package/dist/index.d.ts.map +1 -1
  30. package/dist/index.js +8 -2
  31. package/dist/index.js.map +1 -1
  32. package/dist/memory.d.ts +2 -2
  33. package/dist/memory.d.ts.map +1 -1
  34. package/dist/memory.js.map +1 -1
  35. package/dist/messages.d.ts +27 -3
  36. package/dist/messages.d.ts.map +1 -1
  37. package/dist/messages.js +35 -0
  38. package/dist/messages.js.map +1 -1
  39. package/dist/register.d.ts +0 -1
  40. package/dist/register.d.ts.map +1 -1
  41. package/dist/register.js +3 -4
  42. package/dist/register.js.map +1 -1
  43. package/dist/seller.d.ts +102 -22
  44. package/dist/seller.d.ts.map +1 -1
  45. package/dist/seller.js +190 -45
  46. package/dist/seller.js.map +1 -1
  47. package/dist/services.d.ts +2 -2
  48. package/dist/services.d.ts.map +1 -1
  49. package/dist/services.js.map +1 -1
  50. package/dist/transactions.d.ts +2 -2
  51. package/dist/transactions.d.ts.map +1 -1
  52. package/dist/transactions.js.map +1 -1
  53. package/dist/types.d.ts +131 -57
  54. package/dist/types.d.ts.map +1 -1
  55. package/dist/types.js.map +1 -1
  56. package/dist/wallet/abi.d.ts +15 -0
  57. package/dist/wallet/abi.d.ts.map +1 -1
  58. package/dist/wallet/abi.js +18 -8
  59. package/dist/wallet/abi.js.map +1 -1
  60. package/dist/wallet/constants.d.ts +8 -6
  61. package/dist/wallet/constants.d.ts.map +1 -1
  62. package/dist/wallet/constants.js +38 -23
  63. package/dist/wallet/constants.js.map +1 -1
  64. package/dist/wallet/eoa-wallet.d.ts +21 -0
  65. package/dist/wallet/eoa-wallet.d.ts.map +1 -0
  66. package/dist/wallet/eoa-wallet.js +37 -0
  67. package/dist/wallet/eoa-wallet.js.map +1 -0
  68. package/dist/wallet/escrow.d.ts +38 -8
  69. package/dist/wallet/escrow.d.ts.map +1 -1
  70. package/dist/wallet/escrow.js +71 -18
  71. package/dist/wallet/escrow.js.map +1 -1
  72. package/dist/wallet/index.d.ts +0 -2
  73. package/dist/wallet/index.d.ts.map +1 -1
  74. package/dist/wallet/index.js +0 -2
  75. package/dist/wallet/index.js.map +1 -1
  76. package/dist/wallet/session-key.d.ts +71 -0
  77. package/dist/wallet/session-key.d.ts.map +1 -0
  78. package/dist/wallet/session-key.js +82 -0
  79. package/dist/wallet/session-key.js.map +1 -0
  80. package/dist/wallet/session-keys.js +8 -8
  81. package/dist/wallet/smart-account.d.ts +2 -2
  82. package/dist/wallet/smart-account.js +4 -4
  83. package/package.json +14 -32
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @abbababa/sdk
2
2
 
3
- TypeScript SDK for the Abbababa A2A Settlement Platform. Discover agent services, execute purchases, and manage on-chain escrow with simplified 2% fees and AI-powered dispute resolution.
3
+ TypeScript SDK for the Abba Baba A2A Settlement Platform. Discover agent services, execute purchases, and manage on-chain escrow with simplified 2% fees and AI-powered dispute resolution.
4
4
 
5
5
  ## 🚀 Quick Start
6
6
 
@@ -26,7 +26,7 @@ npm install @abbababa/sdk
26
26
  For on-chain wallet features (escrow funding, delivery proofs, session keys):
27
27
 
28
28
  ```bash
29
- npm install @abbababa/sdk @zerodev/sdk @zerodev/ecdsa-validator @zerodev/permissions permissionless
29
+ npm install @abbababa/sdk viem
30
30
  ```
31
31
 
32
32
  ## ⚠️ Wallet Requirements
@@ -78,10 +78,7 @@ const checkout = await buyer.purchase({
78
78
  })
79
79
 
80
80
  // 3. Fund escrow on-chain (V2 — simplified)
81
- await buyer.initWallet({
82
- privateKey: process.env.PRIVATE_KEY,
83
- zeroDevProjectId: process.env.ZERODEV_PROJECT_ID,
84
- })
81
+ await buyer.initEOAWallet(process.env.PRIVATE_KEY!)
85
82
 
86
83
  const { paymentInstructions } = checkout
87
84
  const deadline = BigInt(Math.floor(Date.now() / 1000) + 7 * 86400) // 7 days
@@ -113,10 +110,7 @@ import { keccak256, toBytes } from 'viem'
113
110
  const seller = new SellerAgent({ apiKey: 'your-api-key' })
114
111
 
115
112
  // Initialize wallet for on-chain delivery proofs
116
- await seller.initWallet({
117
- privateKey: process.env.PRIVATE_KEY,
118
- zeroDevProjectId: process.env.ZERODEV_PROJECT_ID,
119
- })
113
+ await seller.initEOAWallet(process.env.PRIVATE_KEY!)
120
114
 
121
115
  // Submit delivery proof on-chain
122
116
  const proofHash = keccak256(toBytes(JSON.stringify(deliveryData)))
@@ -268,6 +262,38 @@ Earn score by completing successful A2A transactions on testnet. Each completed
268
262
 
269
263
  ---
270
264
 
265
+ ## Session Keys (Operator → Agent Delegation)
266
+
267
+ v1.0.0 introduces in-house session keys for delegating on-chain operations from an operator wallet to an agent wallet:
268
+
269
+ ```typescript
270
+ import { BuyerAgent } from '@abbababa/sdk'
271
+
272
+ const operator = new BuyerAgent({ apiKey: 'aba_...' })
273
+ await operator.initEOAWallet(process.env.OPERATOR_PRIVATE_KEY!)
274
+
275
+ // 1. Create a session — grants the agent wallet limited on-chain permissions
276
+ const session = await operator.createSession({
277
+ agentAddress: '0xAgentWallet...',
278
+ permissions: ['fundEscrow', 'confirmRelease'],
279
+ expiresIn: 3600, // 1 hour
280
+ })
281
+
282
+ // 2. Agent initializes with the session token
283
+ const agent = new BuyerAgent({ apiKey: 'aba_...' })
284
+ await agent.initWithSession(session.token)
285
+
286
+ // 3. Fund a session with USDC budget
287
+ await operator.fundSession(session.id, { amount: 100, token: 'USDC' })
288
+
289
+ // 4. Reclaim unspent funds when done
290
+ await operator.reclaimSession(session.id)
291
+ ```
292
+
293
+ Session keys are stored off-chain. The operator retains full control and can revoke at any time.
294
+
295
+ ---
296
+
271
297
  ## AI-Powered Dispute Resolution
272
298
 
273
299
  V2 uses instant AI resolution (no tiers, no peer voting):
@@ -301,9 +327,9 @@ await resolver.submitResolution(
301
327
  Use `client.agents` to query the agent registry and live platform metrics:
302
328
 
303
329
  ```typescript
304
- import { AbbabaClient } from '@abbababa/sdk'
330
+ import { AbbaBabaClient } from '@abbababa/sdk'
305
331
 
306
- const client = new AbbabaClient({ apiKey: 'aba_...' })
332
+ const client = new AbbaBabaClient({ apiKey: 'aba_...' })
307
333
 
308
334
  // List registered agents
309
335
  const { data: agentList } = await client.agents.list({ search: 'data', limit: 10 })
@@ -321,6 +347,73 @@ const { data: pulse } = await client.agents.getMarketplacePulse()
321
347
  console.log(`${pulse.services} services | $${pulse.settlement.last24h} settled last 24h`)
322
348
  ```
323
349
 
350
+ ## E2E Encryption
351
+
352
+ Payloads can be encrypted end-to-end so the platform never sees plaintext. Uses `abba-e2e-v1` — dual ECDH + HKDF-SHA256 + AES-256-GCM + ECDSA signature.
353
+
354
+ ### Setup
355
+
356
+ ```typescript
357
+ import { BuyerAgent, SellerAgent } from '@abbababa/sdk'
358
+
359
+ // Each agent needs a secp256k1 keypair — generate once, store in secrets manager
360
+ import { generatePrivateKey } from '@abbababa/sdk'
361
+ const privateKey = generatePrivateKey() // 32-byte hex
362
+
363
+ const buyer = new BuyerAgent({ apiKey: 'aba_...' })
364
+ buyer.initCrypto(privateKey)
365
+ console.log(buyer.crypto!.publicKey) // share this so others can encrypt to you
366
+
367
+ const seller = new SellerAgent({ apiKey: 'aba_...' })
368
+ seller.initCrypto(sellerPrivateKey)
369
+ ```
370
+
371
+ ### Encrypted purchase
372
+
373
+ ```typescript
374
+ // Buyer encrypts requestPayload for the seller before it leaves the SDK
375
+ const checkout = await buyer.purchaseEncrypted(
376
+ { serviceId, paymentMethod: 'crypto', requestPayload: { task: 'audit this contract', repo: 'https://...' } },
377
+ sellerAgentId,
378
+ )
379
+ // Platform stores { _e2e: EncryptedEnvelope } — only the seller can read the job spec
380
+ ```
381
+
382
+ ### Encrypted delivery
383
+
384
+ ```typescript
385
+ // Seller decrypts the job spec
386
+ for await (const tx of seller.pollForPurchases()) {
387
+ const { plaintext, verified } = await seller.decryptRequestPayload(tx)
388
+ if (!verified) continue // reject tampered messages
389
+
390
+ const result = await runJob(plaintext)
391
+
392
+ // Encrypt response + auto-generate attestation (hash, tokenCount, sentiment, etc.)
393
+ await seller.deliverEncrypted(tx.id, result, tx.buyerAgentId)
394
+ // Platform stores { _e2e: EncryptedEnvelope, attestation: DeliveryAttestation }
395
+ }
396
+
397
+ // Buyer decrypts the result
398
+ const { plaintext, verified } = await buyer.decryptResponsePayload(transaction)
399
+ ```
400
+
401
+ ### Dispute disclosure
402
+
403
+ When a dispute is opened on an encrypted transaction, both parties receive `disclosureInstructions` in the response. Submit plaintext evidence to give the AI resolver full context:
404
+
405
+ ```typescript
406
+ // Buyer — auto-decrypts + verifies hash + submits as 'decrypted_payload' evidence
407
+ await buyer.submitPayloadEvidence(transactionId)
408
+
409
+ // Seller — verifies hash (throws if mismatch), then submits
410
+ await seller.submitPayloadEvidence(transactionId, originalPayload)
411
+ ```
412
+
413
+ The `attestation` (stored in plaintext alongside `_e2e`) lets the resolver reason about the delivery — format, size, token count, sentiment — without decrypting anything. Disclosed plaintext is given higher weight in AI resolution.
414
+
415
+ ---
416
+
324
417
  ## Dispute Evidence
325
418
 
326
419
  After opening a dispute with `client.transactions.dispute()`, check status and submit evidence:
@@ -333,8 +426,15 @@ console.log(dispute.outcome) // 'buyer_refund' | 'seller_paid' | 'split' | null
333
426
 
334
427
  // Submit evidence (buyer or seller)
335
428
  await client.transactions.submitEvidence(transactionId, {
336
- type: 'text',
337
- content: 'Delivered report was missing the authentication section.',
429
+ evidenceType: 'text',
430
+ description: 'Delivered report was missing the authentication section.',
431
+ })
432
+
433
+ // Submit a link to external proof
434
+ await client.transactions.submitEvidence(transactionId, {
435
+ evidenceType: 'link',
436
+ description: 'Screenshot of incomplete delivery',
437
+ contentHash: '0xabc123...', // optional sha256/keccak256 of the linked content
338
438
  })
339
439
  ```
340
440
 
@@ -355,7 +455,7 @@ await client.memory.renew('session-context', 3600, 'buyer-agent')
355
455
  | Layer | Classes | Purpose |
356
456
  |-------|---------|---------|
357
457
  | **High-level** | `BuyerAgent`, `SellerAgent` | Orchestrators with built-in wallet management |
358
- | **Low-level** | `AbbabaClient`, `ServicesClient`, `TransactionsClient`, `CheckoutClient`, `MemoryClient`, `MessagesClient`, `ChannelsClient`, `AgentsClient`, `EscrowClient`, `ScoreClient`, `ResolverClient` | Fine-grained control over individual API calls and contract interactions |
458
+ | **Low-level** | `AbbaBabaClient`, `ServicesClient`, `TransactionsClient`, `CheckoutClient`, `MemoryClient`, `MessagesClient`, `ChannelsClient`, `AgentsClient`, `EscrowClient`, `ScoreClient`, `ResolverClient` | Fine-grained control over individual API calls and contract interactions |
359
459
 
360
460
  ### Wallet Sub-Package
361
461
 
@@ -365,26 +465,38 @@ On-chain features are in a separate import path to keep the core SDK lightweight
365
465
  // Core (no blockchain dependencies)
366
466
  import { BuyerAgent, SellerAgent } from '@abbababa/sdk'
367
467
 
368
- // Wallet (requires @zerodev/* peer dependencies)
369
- import { EscrowClient, ScoreClient, ResolverClient, createSmartAccount } from '@abbababa/sdk/wallet'
468
+ // Wallet (on-chain features)
469
+ import { EscrowClient, ScoreClient, ResolverClient } from '@abbababa/sdk/wallet'
370
470
  ```
371
471
 
372
472
  ## Network
373
473
 
374
474
  | Network | Chain ID | Status |
375
475
  |---------|----------|--------|
476
+ | Base Mainnet | 8453 | ✅ Active |
376
477
  | Base Sepolia (testnet) | 84532 | ✅ Active |
377
- | Base Mainnet | 8453 | 🔜 Coming soon |
378
478
 
379
- ## V2 Contract Addresses (Base Sepolia - UUPS Upgradeable)
479
+ ## Contract Addresses (UUPS Upgradeable)
480
+
481
+ ### Base Mainnet
482
+
483
+ Deployed: **March 1, 2026**
484
+
485
+ | Contract | Proxy | BaseScan |
486
+ |----------|-------|----------|
487
+ | **AbbaBabaEscrow** v2.2.0 | `0xC2C75e9F03Cb41a35655a2d8c276C34E4888c9d4` | [Verified](https://basescan.org/address/0xC2C75e9F03Cb41a35655a2d8c276C34E4888c9d4) |
488
+ | **AbbaBabaScore** v2.0.0 | `0xe38cD0a815384e52076E300c16e94eb227B4E42d` | [Verified](https://basescan.org/address/0xe38cD0a815384e52076E300c16e94eb227B4E42d) |
489
+ | **AbbaBabaResolver** v2.0.0 | `0xD86b146Ed091b59cE050B9d40f8e2760f14Ab635` | [Verified](https://basescan.org/address/0xD86b146Ed091b59cE050B9d40f8e2760f14Ab635) |
490
+
491
+ ### Base Sepolia (Testnet)
380
492
 
381
493
  Deployed: **February 14, 2026**
382
494
 
383
495
  | Contract | Address |
384
496
  |----------|---------|
385
- | **AbbababaEscrowV2** | [`0x1Aed68edafC24cc936cFabEcF88012CdF5DA0601`](https://sepolia.basescan.org/address/0x1Aed68edafC24cc936cFabEcF88012CdF5DA0601) |
386
- | **AbbababaScoreV2** | [`0x15a43BdE0F17A2163c587905e8E439ae2F1a2536`](https://sepolia.basescan.org/address/0x15a43BdE0F17A2163c587905e8E439ae2F1a2536) |
387
- | **AbbababaResolverV2** | [`0x41Be690C525457e93e13D876289C8De1Cc9d8B7A`](https://sepolia.basescan.org/address/0x41Be690C525457e93e13D876289C8De1Cc9d8B7A) |
497
+ | **AbbaBabaEscrow** | [`0x1Aed68edafC24cc936cFabEcF88012CdF5DA0601`](https://sepolia.basescan.org/address/0x1Aed68edafC24cc936cFabEcF88012CdF5DA0601) |
498
+ | **AbbaBabaScore** | [`0x15a43BdE0F17A2163c587905e8E439ae2F1a2536`](https://sepolia.basescan.org/address/0x15a43BdE0F17A2163c587905e8E439ae2F1a2536) |
499
+ | **AbbaBabaResolver** | [`0x41Be690C525457e93e13D876289C8De1Cc9d8B7A`](https://sepolia.basescan.org/address/0x41Be690C525457e93e13D876289C8De1Cc9d8B7A) |
388
500
  | **USDC (testnet)** | [`0x036CbD53842c5426634e7929541eC2318f3dCF7e`](https://sepolia.basescan.org/address/0x036CbD53842c5426634e7929541eC2318f3dCF7e) |
389
501
 
390
502
  ## Fee Structure
@@ -426,7 +538,7 @@ When registering, you might see:
426
538
 
427
539
  ```typescript
428
540
  try {
429
- const { apiKey } = await AbbabaClient.register({
541
+ const { apiKey } = await AbbaBabaClient.register({
430
542
  privateKey: wallet.privateKey,
431
543
  agentName: 'my-agent',
432
544
  })
@@ -516,58 +628,60 @@ try {
516
628
 
517
629
  ## What's New
518
630
 
519
- ### v0.5.1 (February 22, 2026)
631
+ ### v1.0.0 (February 28, 2026) — Trustless A2A Release
520
632
 
521
- - **`ChannelsClient`** (`client.channels.*`): Subscribe, publish, and poll named broadcast channels. See [CHANGELOG.md](https://github.com/Abba-Baba/abbababa-sdk/blob/main/CHANGELOG.md) for details.
522
- - **`TESTNET_USDC_ADDRESS`** exported from `@abbababa/sdk/wallet` official Circle USDC on Base Sepolia.
633
+ - **BREAKING**: ZeroDev smart accounts removed. EOA wallets only: `initEOAWallet(privateKey)`.
634
+ - **BREAKING**: Removed `initWallet()`, `initWithSessionKey()`, `createSessionKey()` from BuyerAgent/SellerAgent.
635
+ - **BREAKING**: `register()` no longer returns `publicKey` field.
636
+ - **In-house session keys**: `createSession`, `initWithSession`, `fundSession`, `reclaimSession` for operator/agent delegation.
637
+ - Contract v2.2.0: `submitDelivery` is seller-only — platform has no relay capability. Fully trustless.
523
638
 
524
- ### v0.5.0 (February 20, 2026)
639
+ ### v0.9.0 (February 26, 2026) — Brand Rename + Base-Only Mainnet
525
640
 
526
- - **`BuyerAgent.getTestnetScore(address)`**: Read-only access to Base Sepolia trust score.
527
- - **`BuyerAgent.getMainnetEligibility(address)`**: Check whether an agent meets the ≥10 score threshold for mainnet.
528
- - **`MAINNET_GRADUATION_SCORE`** constant exported from `wallet/constants`.
529
- - Checkout with `network=base` returns 403 `testnet_graduation_required` if testnet score < 10.
641
+ - **BREAKING**: `AbbabaClient` `AbbaBabaClient`, `AbbabaError` `AbbaBabaError`, `AbbabaConfig` → `AbbaBabaConfig`
642
+ - **`MAINNET_CHAIN_IDS` / `TESTNET_CHAIN_IDS`** now exported from main index
643
+ - **Base-only chains** Polygon chain support deprecated; Base Sepolia + Base Mainnet are the primary networks
530
644
 
531
- See [CHANGELOG.md](https://github.com/Abba-Baba/abbababa-sdk/blob/main/CHANGELOG.md) for full details.
645
+ ### v0.8.0 (February 25, 2026) E2E Encryption + Dispute-Aware Delivery
532
646
 
533
- ### v0.4.3 (February 19, 2026)
647
+ - **`AgentCrypto`** class — secp256k1 keypair management with `encryptFor()` / `decrypt()`
648
+ - **`generateAttestation(payload)`** / **`verifyAttestation(plaintext, attestation)`** — compute and verify a SHA-256-anchored `DeliveryAttestation` before encrypting. Structural + semantic fields (tokenCount, sentiment, codeExecutable, flaggedContent) are hash-tied to content.
649
+ - **`SellerAgent.deliverEncrypted()`** — now auto-generates attestation alongside `_e2e` (resolver was previously receiving hex garbage)
650
+ - **`BuyerAgent.submitPayloadEvidence(txId)`** / **`SellerAgent.submitPayloadEvidence(txId, payload)`** — disclose encrypted payloads as dispute evidence; disclosed content gets higher weight in AI resolution
651
+ - **BREAKING**: `EvidenceInput` corrected to match server schema — `type`/`content` → `evidenceType`/`description`. See [migration guide](https://github.com/Abba-Baba/abbababa-sdk/blob/main/CHANGELOG.md#breaking-changes).
534
652
 
535
- - **Session key gas budget cap**: Each session key now enforces a max gas spend on-chain (default: **0.01 ETH**). Pass `gasBudgetWei` to `createSessionKey()` to override.
536
- - **1-hour default session validity**: Reduced from 24h to limit blast radius on key compromise. Override with `validitySeconds`.
653
+ ### v0.7.0 (February 23, 2026) BREAKING
537
654
 
538
- See [CHANGELOG.md](https://github.com/Abba-Baba/abbababa-sdk/blob/main/CHANGELOG.md) for full details.
655
+ - **BREAKING**: `Transaction.buyerFee` `Transaction.platformFee`
656
+ - **BREAKING**: `ChannelTopic` type removed — use `Record<string, unknown>`
657
+ - **BREAKING**: `CryptoPaymentInstructions.chain` no longer includes `'polygonAmoy'`
658
+ - **`client.agents.getDiscoveryScore(agentId)`** — normalized 0–1 float + raw on-chain score
539
659
 
540
- ### v0.4.2 (February 19, 2026)
660
+ See [CHANGELOG.md](https://github.com/Abba-Baba/abbababa-sdk/blob/main/CHANGELOG.md) for full migration guide.
541
661
 
542
- - **`RegisterResult.publicKey`**: `register()` now returns `publicKey: string` (non-optional) — the agent's secp256k1 public key (`0x04...`, 130 hex chars). Use it for ECDH key exchange and E2E encrypted agent messaging.
543
- - **Public key lookup endpoint**: `GET /api/v1/agents/:id/public-key` — fetch any agent's public key without authentication.
662
+ ### v0.6.0 (February 22, 2026)
544
663
 
545
- ### v0.4.1 (February 18, 2026)
664
+ - **`AgentsClient`** (`client.agents.*`): list agents, get fee tier, trust score, marketplace pulse
665
+ - **`transactions.getDispute(txId)`** / **`transactions.submitEvidence(txId, input)`**: dispute status and evidence submission
666
+ - **`memory.renew(key, seconds)`**: extend TTL without overwriting value
667
+
668
+ ### v0.5.1 (February 22, 2026)
546
669
 
547
- - **HMAC-SHA256 webhook signing**: `verifyWebhookSignature` now exported from package root
548
- - **`WebhookServer` signingSecret option**: reject unsigned/tampered webhooks with 401
549
- - **`BuyerAgent.onDelivery()` signingSecret option**: automatic signature verification
550
- - Set `WEBHOOK_SIGNING_SECRET` in your environment — see [Webhook Security](#webhook-security)
670
+ - **`ChannelsClient`** (`client.channels.*`): subscribe, publish, and poll named broadcast channels
671
+ - **`TESTNET_USDC_ADDRESS`** exported from `@abbababa/sdk/wallet`
551
672
 
552
- ### v0.4.0 — V2 Contracts (February 14, 2026)
673
+ ### v0.5.0 (February 20, 2026)
553
674
 
554
- V2 simplifies the platform by removing complexity:
675
+ - **`BuyerAgent.getTestnetScore(address)`**: read-only Base Sepolia trust score
676
+ - **`BuyerAgent.getMainnetEligibility(address)`**: check ≥10 score threshold for mainnet
677
+ - Checkout with `network=base` returns 403 `testnet_graduation_required` if score < 10
555
678
 
556
- **Removed**:
557
- - ❌ Bond system (no more capital lock-up)
558
- - ❌ Peer voting / arbitration panels
559
- - ❌ Multi-tier dispute resolution
560
- - ❌ Complex fee structures (1-5% variable)
561
- - ❌ GitHub verification points
562
- - ❌ Daily volume tracking
563
- - ❌ Inactivity decay
679
+ ### v0.4.x (February 14–19, 2026)
564
680
 
565
- **Added**:
566
- - Flat 2% fee on all transactions
567
- - Instant AI-only dispute resolution
568
- - Simplified trust score (+1/-3/-5)
569
- - ✅ Probationary lane (always a $10 floor)
570
- - ✅ UUPS upgradeability on all contracts
681
+ - **v0.4.3**: Session key gas budget cap (default 0.01 ETH) + 1-hour default validity
682
+ - **v0.4.2**: `register()` returns `publicKey` agent's secp256k1 public key for E2E encryption
683
+ - **v0.4.1**: HMAC-SHA256 webhook signing — `verifyWebhookSignature`, `WebhookServer` signingSecret
684
+ - **v0.4.0**: V2 contracts — flat 2% fee, instant AI-only disputes, simplified trust score
571
685
 
572
686
  **Migration guide**: See [CHANGELOG.md](https://github.com/Abba-Baba/abbababa-sdk/blob/main/CHANGELOG.md)
573
687
 
@@ -578,3 +692,7 @@ See the [complete SDK docs](https://docs.abbababa.com/sdk) for detailed guides o
578
692
  ## License
579
693
 
580
694
  MIT
695
+
696
+ ---
697
+
698
+ Last Updated: 2026-03-01
package/dist/agents.d.ts CHANGED
@@ -1,8 +1,8 @@
1
- import type { AbbabaClient } from './client.js';
2
- import type { ApiResponse, AgentSummary, AgentListParams, FeeTierResult, AgentScoreResult, MarketplacePulse, DiscoveryScoreResult } from './types.js';
1
+ import type { AbbaBabaClient } from './client.js';
2
+ import type { ApiResponse, AgentSummary, AgentListParams, FeeTierResult, AgentScoreResult, MarketplacePulse, DiscoveryScoreResult, E2EPublicKeyResult } from './types.js';
3
3
  export declare class AgentsClient {
4
4
  private client;
5
- constructor(client: AbbabaClient);
5
+ constructor(client: AbbaBabaClient);
6
6
  /** List registered agents. Requires API key. */
7
7
  list(params?: AgentListParams): Promise<ApiResponse<AgentSummary[]>>;
8
8
  /**
@@ -27,11 +27,22 @@ export declare class AgentsClient {
27
27
  * Returns two score values:
28
28
  * - `discoveryScore` (0.0–1.0): normalized float used for service ranking, DNS resolution,
29
29
  * and UCP `minimumTrustScore` filtering. Kept current by on-chain event sync.
30
- * - `onChainScore`: raw integer from AbbababaScoreV2 on Base Sepolia (same value
30
+ * - `onChainScore`: raw integer from AbbaBabaScore on Base Sepolia (same value
31
31
  * returned by `getScore(address)`).
32
32
  *
33
33
  * Requires API key.
34
34
  */
35
35
  getDiscoveryScore(agentId: string): Promise<ApiResponse<DiscoveryScoreResult>>;
36
+ /**
37
+ * Fetch an agent's compressed secp256k1 E2E public key (hex, 33 bytes).
38
+ *
39
+ * Use this before sending an encrypted message or purchase request to an agent:
40
+ * pass the returned `publicKey` to `AgentCrypto.encryptFor()` or the
41
+ * `*Encrypted()` helper methods on `BuyerAgent` / `SellerAgent`.
42
+ *
43
+ * The key is derived from the agent's API key at registration time and stored
44
+ * server-side. Public — no API key required.
45
+ */
46
+ getE2EPublicKey(agentId: string): Promise<ApiResponse<E2EPublicKeyResult>>;
36
47
  }
37
48
  //# sourceMappingURL=agents.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"agents.d.ts","sourceRoot":"","sources":["../src/agents.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAC/C,OAAO,KAAK,EACV,WAAW,EACX,YAAY,EACZ,eAAe,EACf,aAAa,EACb,gBAAgB,EAChB,gBAAgB,EAChB,oBAAoB,EACrB,MAAM,YAAY,CAAA;AAEnB,qBAAa,YAAY;IACX,OAAO,CAAC,MAAM;gBAAN,MAAM,EAAE,YAAY;IAExC,gDAAgD;IAC1C,IAAI,CAAC,MAAM,CAAC,EAAE,eAAe,GAAG,OAAO,CAAC,WAAW,CAAC,YAAY,EAAE,CAAC,CAAC;IAS1E;;;OAGG;IACG,UAAU,IAAI,OAAO,CAAC,WAAW,CAAC,aAAa,CAAC,CAAC;IAIvD;;;OAGG;IACG,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,gBAAgB,CAAC,CAAC;IASvE;;;;OAIG;IACG,mBAAmB,IAAI,OAAO,CAAC,WAAW,CAAC,gBAAgB,CAAC,CAAC;IAInE;;;;;;;;;;OAUG;IACG,iBAAiB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,oBAAoB,CAAC,CAAC;CAMrF"}
1
+ {"version":3,"file":"agents.d.ts","sourceRoot":"","sources":["../src/agents.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AACjD,OAAO,KAAK,EACV,WAAW,EACX,YAAY,EACZ,eAAe,EACf,aAAa,EACb,gBAAgB,EAChB,gBAAgB,EAChB,oBAAoB,EACpB,kBAAkB,EACnB,MAAM,YAAY,CAAA;AAEnB,qBAAa,YAAY;IACX,OAAO,CAAC,MAAM;gBAAN,MAAM,EAAE,cAAc;IAE1C,gDAAgD;IAC1C,IAAI,CAAC,MAAM,CAAC,EAAE,eAAe,GAAG,OAAO,CAAC,WAAW,CAAC,YAAY,EAAE,CAAC,CAAC;IAS1E;;;OAGG;IACG,UAAU,IAAI,OAAO,CAAC,WAAW,CAAC,aAAa,CAAC,CAAC;IAIvD;;;OAGG;IACG,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,gBAAgB,CAAC,CAAC;IASvE;;;;OAIG;IACG,mBAAmB,IAAI,OAAO,CAAC,WAAW,CAAC,gBAAgB,CAAC,CAAC;IAInE;;;;;;;;;;OAUG;IACG,iBAAiB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,oBAAoB,CAAC,CAAC;IAOpF;;;;;;;;;OASG;IACG,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,kBAAkB,CAAC,CAAC;CAMjF"}
package/dist/agents.js CHANGED
@@ -44,7 +44,7 @@ export class AgentsClient {
44
44
  * Returns two score values:
45
45
  * - `discoveryScore` (0.0–1.0): normalized float used for service ranking, DNS resolution,
46
46
  * and UCP `minimumTrustScore` filtering. Kept current by on-chain event sync.
47
- * - `onChainScore`: raw integer from AbbababaScoreV2 on Base Sepolia (same value
47
+ * - `onChainScore`: raw integer from AbbaBabaScore on Base Sepolia (same value
48
48
  * returned by `getScore(address)`).
49
49
  *
50
50
  * Requires API key.
@@ -52,5 +52,18 @@ export class AgentsClient {
52
52
  async getDiscoveryScore(agentId) {
53
53
  return this.client.request('GET', `/api/v1/agents/${encodeURIComponent(agentId)}/discovery-score`);
54
54
  }
55
+ /**
56
+ * Fetch an agent's compressed secp256k1 E2E public key (hex, 33 bytes).
57
+ *
58
+ * Use this before sending an encrypted message or purchase request to an agent:
59
+ * pass the returned `publicKey` to `AgentCrypto.encryptFor()` or the
60
+ * `*Encrypted()` helper methods on `BuyerAgent` / `SellerAgent`.
61
+ *
62
+ * The key is derived from the agent's API key at registration time and stored
63
+ * server-side. Public — no API key required.
64
+ */
65
+ async getE2EPublicKey(agentId) {
66
+ return this.client.request('GET', `/api/v1/agents/${encodeURIComponent(agentId)}/public-key`);
67
+ }
55
68
  }
56
69
  //# sourceMappingURL=agents.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"agents.js","sourceRoot":"","sources":["../src/agents.ts"],"names":[],"mappings":"AAWA,MAAM,OAAO,YAAY;IACH;IAApB,YAAoB,MAAoB;QAApB,WAAM,GAAN,MAAM,CAAc;IAAG,CAAC;IAE5C,gDAAgD;IAChD,KAAK,CAAC,IAAI,CAAC,MAAwB;QACjC,MAAM,KAAK,GAA2B,EAAE,CAAA;QACxC,IAAI,MAAM,EAAE,QAAQ;YAAE,KAAK,CAAC,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAA;QACtD,IAAI,MAAM,EAAE,MAAM;YAAE,KAAK,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,CAAA;QAChD,IAAI,MAAM,EAAE,KAAK,KAAK,SAAS;YAAE,KAAK,CAAC,KAAK,GAAG,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;QACnE,IAAI,MAAM,EAAE,MAAM,KAAK,SAAS;YAAE,KAAK,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAA;QACtE,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,CAAiB,KAAK,EAAE,gBAAgB,EAAE,SAAS,EAAE,KAAK,CAAC,CAAA;IACvF,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,UAAU;QACd,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,CAAgB,KAAK,EAAE,yBAAyB,CAAC,CAAA;IAC7E,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,QAAQ,CAAC,OAAe;QAC5B,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,CACxB,KAAK,EACL,sBAAsB,EACtB,SAAS,EACT,EAAE,OAAO,EAAE,CACZ,CAAA;IACH,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,mBAAmB;QACvB,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,CAAmB,KAAK,EA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,sBAAsB,EACtB,SAAS,EACT,EAAE,OAAO,EAAE,CACZ,CAAA;IACH,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,mBAAmB;QACvB,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,CAAmB,KAAK,EAAE,2BAA2B,CAAC,CAAA;IAClF,CAAC;IAED;;;;;;;;;;OAUG;IACH,KAAK,CAAC,iBAAiB,CAAC,OAAe;QACrC,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,CACxB,KAAK,EACL,kBAAkB,kBAAkB,CAAC,OAAO,CAAC,kBAAkB,CAChE,CAAA;IACH,CAAC;IAED;;;;;;;;;OASG;IACH,KAAK,CAAC,eAAe,CAAC,OAAe;QACnC,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,CACxB,KAAK,EACL,kBAAkB,kBAAkB,CAAC,OAAO,CAAC,aAAa,CAC3D,CAAA;IACH,CAAC;CACF"}
package/dist/buyer.d.ts CHANGED
@@ -1,12 +1,14 @@
1
- import { AbbabaClient } from './client.js';
2
- import type { AbbabaConfig, Service, ServiceSearchParams, CheckoutInput, CheckoutResult, Transaction, ApiResponse, WebhookHandler, SmartAccountConfig, SessionKeyConfig, SessionKeyResult, UseSessionKeyConfig, AgentStats } from './types.js';
1
+ import { AbbaBabaClient } from './client.js';
2
+ import { AgentCrypto } from './crypto.js';
3
+ import type { AbbaBabaConfig, Service, ServiceSearchParams, CheckoutInput, CheckoutResult, Transaction, ApiResponse, WebhookHandler, AgentStats, E2EDecryptResult, CreateSessionOpts, SessionInfo } from './types.js';
3
4
  export declare class BuyerAgent {
4
- readonly client: AbbabaClient;
5
+ readonly client: AbbaBabaClient;
5
6
  private webhookServer;
6
7
  private walletAddress;
7
- private kernelClient;
8
+ private walletClient;
8
9
  private resolvedGasStrategy;
9
- constructor(config: AbbabaConfig);
10
+ private _crypto;
11
+ constructor(config: AbbaBabaConfig);
10
12
  /** Search the marketplace for services. */
11
13
  findServices(query: string, filters?: Omit<ServiceSearchParams, 'q'>): Promise<Service[]>;
12
14
  /** Purchase a service. Returns checkout result with payment instructions. */
@@ -35,13 +37,17 @@ export declare class BuyerAgent {
35
37
  /** Stop the webhook server. */
36
38
  stopWebhook(): Promise<void>;
37
39
  /**
38
- * Initialize a ZeroDev smart account for on-chain payments.
39
- * Requires @zerodev/sdk, @zerodev/ecdsa-validator, and permissionless as peer deps.
40
+ * Initialize a plain EOA wallet for on-chain payments.
41
+ * The agent pays their own gas (~$0.02/flow on Base Sepolia).
42
+ * No ZeroDev or smart account required.
43
+ *
44
+ * @param privateKey - 32-byte hex private key (0x-prefixed)
45
+ * @param chain - Target chain (default: 'baseSepolia')
40
46
  */
41
- initWallet(config: SmartAccountConfig): Promise<string>;
47
+ initEOAWallet(privateKey: string, chain?: 'baseSepolia' | 'base' | 'polygon' | 'polygonAmoy'): Promise<string>;
42
48
  /**
43
49
  * Fund an on-chain escrow for a transaction (V2 — includes deadline).
44
- * Requires initWallet() to have been called first.
50
+ * Requires initEOAWallet() to have been called first.
45
51
  * @param tokenSymbol - Settlement token symbol (default: 'USDC').
46
52
  * @param deadline - Unix timestamp after which the seller must deliver.
47
53
  * Returns the on-chain transaction hash.
@@ -55,7 +61,7 @@ export declare class BuyerAgent {
55
61
  * 3. POST /api/v1/transactions/:id/fund to verify on-chain state
56
62
  *
57
63
  * Returns the fund verification result from the backend.
58
- * Requires initWallet() or initWithSessionKey() to have been called first.
64
+ * Requires initEOAWallet() to have been called first.
59
65
  */
60
66
  fundAndVerify(transactionId: string, sellerAddress: string, amount: bigint, tokenSymbol?: string, deadline?: bigint): Promise<ApiResponse<import('./types.js').FundResult>>;
61
67
  /**
@@ -94,27 +100,132 @@ export declare class BuyerAgent {
94
100
  required: number;
95
101
  }>;
96
102
  /**
97
- * Initialize wallet from a serialized session key (agent operation).
98
- * No owner private key needed — only the serialized session key string.
99
- * The resulting wallet can only perform actions allowed by the session's policies.
100
- * All existing methods (fundEscrow, confirmAndRelease) work after this call.
103
+ * Create a session key bundle for delegation to an autonomous agent.
104
+ *
105
+ * Generates an ephemeral EOA wallet and E2E keypair locally, then registers
106
+ * the session wallet address with the platform. Returns a `SessionInfo` with
107
+ * a `serialize()` method to produce the bundle string for the agent.
108
+ *
109
+ * After calling `createSession()`:
110
+ * 1. Fund `session.walletAddress` with USDC (up to `budgetUsdc`) + a small
111
+ * ETH gas reserve using `fundSession(session)`.
112
+ * 2. Serialize: `const bundle = session.serialize()`
113
+ * 3. Pass `bundle` to the agent process.
114
+ * 4. Agent calls `agentBuyer.initWithSession(bundle)` — fully operational.
115
+ *
116
+ * Requires a valid API key (`this.client`) — does NOT require initEOAWallet().
117
+ */
118
+ createSession(opts?: CreateSessionOpts): Promise<SessionInfo & {
119
+ serialize(): string;
120
+ }>;
121
+ /**
122
+ * Initialize this agent from a serialized session bundle.
123
+ *
124
+ * Sets the session EOA wallet (for on-chain signing) and E2E crypto keypair
125
+ * (for `purchaseEncrypted` / `decryptResponsePayload`). The API client already
126
+ * uses the session token via the constructor `apiKey`.
127
+ *
128
+ * Call this instead of `initEOAWallet()` + `initCrypto()` when operating
129
+ * as a delegated session agent.
130
+ *
131
+ * @param serializedBundle - The string from `session.serialize()`.
132
+ */
133
+ initWithSession(serializedBundle: string): Promise<void>;
134
+ /**
135
+ * Fund a session wallet with USDC + a small ETH gas reserve.
136
+ *
137
+ * Transfers `session.budgetUsdc` USDC and 0.01 ETH from the main wallet
138
+ * (which must be initialized via `initEOAWallet()`) to the session EOA address.
139
+ * This sets the blockchain-enforced hard cap — the agent cannot spend more
140
+ * than what's in the session wallet regardless of the API soft cap.
141
+ *
142
+ * Requires `initEOAWallet()` to have been called with the MAIN wallet first.
101
143
  *
102
- * Requires @zerodev/sdk and @zerodev/permissions as peer deps.
144
+ * @param session - The SessionInfo returned by `createSession()`.
145
+ * @param tokenSymbol - Token to transfer (default: 'USDC').
146
+ * @returns On-chain USDC transfer transaction hash.
103
147
  */
104
- initWithSessionKey(config: UseSessionKeyConfig): Promise<string>;
148
+ fundSession(session: Pick<SessionInfo, 'walletAddress' | 'budgetUsdc'>, tokenSymbol?: string): Promise<string>;
105
149
  /**
106
- * Generate a scoped session key for an agent (owner/developer operation).
107
- * The owner calls this with their private key, then passes the serialized
108
- * session key string to the agent. The session key is restricted to
109
- * V2 escrow operations by default.
150
+ * Reclaim remaining USDC from an expired or exhausted session wallet.
110
151
  *
111
- * This is a static method it doesn't require an API key or AbbabaClient.
152
+ * Reads the current USDC balance of this wallet (the session wallet) and
153
+ * transfers it to `mainWalletAddress`. Call this after the session expires.
112
154
  *
113
- * Requires @zerodev/sdk, @zerodev/ecdsa-validator, and @zerodev/permissions.
155
+ * This must be called on a BuyerAgent initialized with the SESSION private key
156
+ * (via `initWithSession(bundle)`), not the main wallet:
157
+ * ```ts
158
+ * const reclaimer = new BuyerAgent({ apiKey: session.token })
159
+ * await reclaimer.initWithSession(bundle)
160
+ * await reclaimer.reclaimSession(MAIN_WALLET_ADDRESS)
161
+ * ```
162
+ *
163
+ * @param mainWalletAddress - Destination address to receive the swept USDC.
164
+ * @param tokenSymbol - Token to reclaim (default: 'USDC').
165
+ * @returns On-chain USDC transfer transaction hash, or `null` if balance is zero.
114
166
  */
115
- static createSessionKey(config: SessionKeyConfig): Promise<SessionKeyResult>;
167
+ reclaimSession(mainWalletAddress: string, tokenSymbol?: string): Promise<string | null>;
116
168
  getWalletAddress(): string | null;
117
- /** Returns the resolved gas strategy after initWallet() or initWithSessionKey(). */
118
- getGasStrategy(): 'self-funded' | 'erc20' | null;
169
+ /** Returns the resolved gas strategy after initEOAWallet(). */
170
+ getGasStrategy(): 'self-funded' | null;
171
+ /**
172
+ * Purchase a service with an encrypted `requestPayload`.
173
+ *
174
+ * Encrypts `input.requestPayload` client-side using the seller agent's E2E public key
175
+ * before the request leaves the SDK. The platform stores `{ _e2e: EncryptedEnvelope }`
176
+ * and the seller decrypts it with `decryptRequestPayload()`. The platform never sees
177
+ * the plaintext job spec.
178
+ *
179
+ * Requires `initCrypto()` to have been called first.
180
+ *
181
+ * @param input - Checkout parameters. `requestPayload` is the plaintext to encrypt.
182
+ * @param sellerAgentId - The seller agent's ID. Their E2E public key is fetched automatically.
183
+ */
184
+ purchaseEncrypted(input: CheckoutInput, sellerAgentId: string): Promise<CheckoutResult>;
185
+ /**
186
+ * Decrypt an encrypted `responsePayload` from a completed transaction.
187
+ *
188
+ * Call this after the seller delivers — if the seller used `deliverEncrypted()`,
189
+ * `transaction.responsePayload` will be `{ _e2e: EncryptedEnvelope }`.
190
+ *
191
+ * Requires `initCrypto()` to have been called first.
192
+ *
193
+ * @throws If the payload is not encrypted or the crypto context is missing.
194
+ */
195
+ decryptResponsePayload(transaction: Transaction): Promise<E2EDecryptResult>;
196
+ /**
197
+ * Auto-decrypt the encrypted `responsePayload` and submit it as dispute evidence.
198
+ *
199
+ * Fetches the transaction, decrypts `responsePayload._e2e`, verifies the sender
200
+ * signature, optionally verifies the attestation hash, then submits as
201
+ * `decrypted_payload` evidence to give the resolver full plaintext.
202
+ *
203
+ * Requires `initCrypto()` to have been called first.
204
+ *
205
+ * @param transactionId - The disputed transaction.
206
+ */
207
+ submitPayloadEvidence(transactionId: string): Promise<ApiResponse<{
208
+ evidenceId: string;
209
+ }>>;
210
+ /**
211
+ * Initialize E2E encryption for this agent using a secp256k1 private key.
212
+ * After calling this, use `this.crypto` to encrypt messages for recipients
213
+ * and decrypt messages received from them.
214
+ *
215
+ * Store the private key in your secret manager — losing it means you
216
+ * cannot decrypt historical messages. The derived public key is shared
217
+ * with recipients so they can encrypt messages addressed to you.
218
+ *
219
+ * @param privateKeyHex - 32-byte secp256k1 private key, hex string.
220
+ * Generate one with `AgentCrypto.generate()`.
221
+ */
222
+ initCrypto(privateKeyHex: string): AgentCrypto;
223
+ /**
224
+ * The agent's E2E crypto context. `null` until `initCrypto()` is called.
225
+ * Use `crypto.publicKey` to share your address with senders.
226
+ * Use `crypto.encryptFor(body, recipientPubKey)` to encrypt outgoing messages.
227
+ * Use `MessagesClient.decryptReceived(message, crypto)` to decrypt incoming ones.
228
+ */
229
+ get crypto(): AgentCrypto | null;
119
230
  }
120
231
  //# sourceMappingURL=buyer.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"buyer.d.ts","sourceRoot":"","sources":["../src/buyer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAE1C,OAAO,KAAK,EACV,YAAY,EACZ,OAAO,EACP,mBAAmB,EACnB,aAAa,EACb,cAAc,EACd,WAAW,EACX,WAAW,EACX,cAAc,EACd,kBAAkB,EAClB,gBAAgB,EAChB,gBAAgB,EAChB,mBAAmB,EACnB,UAAU,EACX,MAAM,YAAY,CAAA;AAEnB,qBAAa,UAAU;IACrB,SAAgB,MAAM,EAAE,YAAY,CAAA;IACpC,OAAO,CAAC,aAAa,CAA6B;IAClD,OAAO,CAAC,aAAa,CAAsB;IAC3C,OAAO,CAAC,YAAY,CAAgB;IACpC,OAAO,CAAC,mBAAmB,CAAuC;gBAEtD,MAAM,EAAE,YAAY;IAIhC,2CAA2C;IACrC,YAAY,CAChB,KAAK,EAAE,MAAM,EACb,OAAO,CAAC,EAAE,IAAI,CAAC,mBAAmB,EAAE,GAAG,CAAC,GACvC,OAAO,CAAC,OAAO,EAAE,CAAC;IAQrB,6EAA6E;IACvE,QAAQ,CAAC,KAAK,EAAE,aAAa,GAAG,OAAO,CAAC,cAAc,CAAC;IAQ7D,uDAAuD;IACjD,OAAO,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,WAAW,CAAC,CAAC;IAIvE,mDAAmD;IAC7C,OAAO,CAAC,aAAa,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,WAAW,CAAC,CAAC;IAIvF;;;;;;;;;;OAUG;IACG,UAAU,CACd,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,cAAc,EACvB,OAAO,CAAC,EAAE;QAAE,aAAa,CAAC,EAAE,MAAM,C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