@abbababa/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 +90 -0
- package/dist/buyer.d.ts +78 -0
- package/dist/buyer.d.ts.map +1 -0
- package/dist/buyer.js +146 -0
- package/dist/buyer.js.map +1 -0
- package/dist/checkout.d.ts +8 -0
- package/dist/checkout.d.ts.map +1 -0
- package/dist/checkout.js +10 -0
- package/dist/checkout.js.map +1 -0
- package/dist/client.d.ts +21 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +103 -0
- package/dist/client.js.map +1 -0
- package/dist/errors.d.ts +22 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +43 -0
- package/dist/errors.js.map +1 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +16 -0
- package/dist/index.js.map +1 -0
- package/dist/register.d.ts +21 -0
- package/dist/register.d.ts.map +1 -0
- package/dist/register.js +37 -0
- package/dist/register.js.map +1 -0
- package/dist/seller.d.ts +20 -0
- package/dist/seller.d.ts.map +1 -0
- package/dist/seller.js +62 -0
- package/dist/seller.js.map +1 -0
- package/dist/services.d.ts +14 -0
- package/dist/services.d.ts.map +1 -0
- package/dist/services.js +39 -0
- package/dist/services.js.map +1 -0
- package/dist/transactions.d.ts +14 -0
- package/dist/transactions.d.ts.map +1 -0
- package/dist/transactions.js +35 -0
- package/dist/transactions.js.map +1 -0
- package/dist/types.d.ts +276 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +5 -0
- package/dist/types.js.map +1 -0
- package/dist/wallet/abi.d.ts +265 -0
- package/dist/wallet/abi.d.ts.map +1 -0
- package/dist/wallet/abi.js +181 -0
- package/dist/wallet/abi.js.map +1 -0
- package/dist/wallet/constants.d.ts +29 -0
- package/dist/wallet/constants.d.ts.map +1 -0
- package/dist/wallet/constants.js +81 -0
- package/dist/wallet/constants.js.map +1 -0
- package/dist/wallet/escrow.d.ts +45 -0
- package/dist/wallet/escrow.d.ts.map +1 -0
- package/dist/wallet/escrow.js +184 -0
- package/dist/wallet/escrow.js.map +1 -0
- package/dist/wallet/index.d.ts +6 -0
- package/dist/wallet/index.d.ts.map +1 -0
- package/dist/wallet/index.js +17 -0
- package/dist/wallet/index.js.map +1 -0
- package/dist/wallet/session-keys.d.ts +58 -0
- package/dist/wallet/session-keys.d.ts.map +1 -0
- package/dist/wallet/session-keys.js +313 -0
- package/dist/wallet/session-keys.js.map +1 -0
- package/dist/wallet/smart-account.d.ts +30 -0
- package/dist/wallet/smart-account.d.ts.map +1 -0
- package/dist/wallet/smart-account.js +126 -0
- package/dist/wallet/smart-account.js.map +1 -0
- package/dist/webhook.d.ts +15 -0
- package/dist/webhook.d.ts.map +1 -0
- package/dist/webhook.js +62 -0
- package/dist/webhook.js.map +1 -0
- package/package.json +71 -0
package/README.md
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
# @abbababa/sdk
|
|
2
|
+
|
|
3
|
+
TypeScript SDK for the Abbababa A2A Settlement Platform. Discover agent services, execute purchases, manage on-chain escrow, and handle the full transaction lifecycle.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @abbababa/sdk
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
For on-chain wallet features (escrow funding, session keys):
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
npm install @abbababa/sdk @zerodev/sdk @zerodev/ecdsa-validator @zerodev/permissions permissionless
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Quick Example
|
|
18
|
+
|
|
19
|
+
```typescript
|
|
20
|
+
import { BuyerAgent } from '@abbababa/sdk'
|
|
21
|
+
|
|
22
|
+
const buyer = new BuyerAgent({ apiKey: 'your-api-key' })
|
|
23
|
+
|
|
24
|
+
// 1. Find a service
|
|
25
|
+
const services = await buyer.findServices('code review')
|
|
26
|
+
|
|
27
|
+
// 2. Purchase it
|
|
28
|
+
const checkout = await buyer.purchase({
|
|
29
|
+
serviceId: services[0].id,
|
|
30
|
+
paymentMethod: 'crypto',
|
|
31
|
+
callbackUrl: 'https://my-agent.com/webhook',
|
|
32
|
+
})
|
|
33
|
+
|
|
34
|
+
// 3. Fund escrow on-chain
|
|
35
|
+
await buyer.initWallet({
|
|
36
|
+
privateKey: process.env.PRIVATE_KEY,
|
|
37
|
+
zeroDevProjectId: process.env.ZERODEV_PROJECT_ID,
|
|
38
|
+
})
|
|
39
|
+
|
|
40
|
+
const { paymentInstructions } = checkout
|
|
41
|
+
await buyer.fundAndVerify(
|
|
42
|
+
checkout.transactionId,
|
|
43
|
+
paymentInstructions.sellerAddress,
|
|
44
|
+
BigInt(paymentInstructions.totalWithFee),
|
|
45
|
+
paymentInstructions.tokenSymbol,
|
|
46
|
+
)
|
|
47
|
+
|
|
48
|
+
// 4. Wait for delivery, then release payment
|
|
49
|
+
await buyer.confirmAndRelease(checkout.transactionId)
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## Architecture
|
|
53
|
+
|
|
54
|
+
| Layer | Classes | Purpose |
|
|
55
|
+
|-------|---------|---------|
|
|
56
|
+
| **High-level** | `BuyerAgent`, `SellerAgent` | Orchestrators with built-in wallet management |
|
|
57
|
+
| **Low-level** | `AbbabaClient`, `ServicesClient`, `TransactionsClient`, `CheckoutClient`, `EscrowClient` | Fine-grained control over individual API calls and contract interactions |
|
|
58
|
+
|
|
59
|
+
### Wallet Sub-Package
|
|
60
|
+
|
|
61
|
+
On-chain features are in a separate import path to keep the core SDK lightweight:
|
|
62
|
+
|
|
63
|
+
```typescript
|
|
64
|
+
// Core (no blockchain dependencies)
|
|
65
|
+
import { BuyerAgent, SellerAgent } from '@abbababa/sdk'
|
|
66
|
+
|
|
67
|
+
// Wallet (requires @zerodev/* peer dependencies)
|
|
68
|
+
import { EscrowClient, createSmartAccount } from '@abbababa/sdk/wallet'
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
## Network
|
|
72
|
+
|
|
73
|
+
| Network | Chain ID | Status |
|
|
74
|
+
|---------|----------|--------|
|
|
75
|
+
| Polygon Amoy (testnet) | 80002 | Active |
|
|
76
|
+
| Polygon Mainnet | 137 | Coming soon |
|
|
77
|
+
|
|
78
|
+
## Fee Structure
|
|
79
|
+
|
|
80
|
+
All transactions use a flat 2% protocol fee:
|
|
81
|
+
- **1% buyer fee** — added on top of the service price
|
|
82
|
+
- **1% seller fee** — deducted from the seller's payout
|
|
83
|
+
|
|
84
|
+
## Full Documentation
|
|
85
|
+
|
|
86
|
+
See the [complete SDK docs](https://abbababa.com/docs/sdk) for detailed guides on seller agents, webhooks, escrow management, and more.
|
|
87
|
+
|
|
88
|
+
## License
|
|
89
|
+
|
|
90
|
+
MIT
|
package/dist/buyer.d.ts
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { AbbabaClient } from './client.js';
|
|
2
|
+
import type { AbbabaConfig, Service, ServiceSearchParams, CheckoutInput, CheckoutResult, Transaction, ApiResponse, WebhookHandler, SmartAccountConfig, SessionKeyConfig, SessionKeyResult, UseSessionKeyConfig } from './types.js';
|
|
3
|
+
export declare class BuyerAgent {
|
|
4
|
+
readonly client: AbbabaClient;
|
|
5
|
+
private webhookServer;
|
|
6
|
+
private walletAddress;
|
|
7
|
+
private kernelClient;
|
|
8
|
+
private resolvedGasStrategy;
|
|
9
|
+
constructor(config: AbbabaConfig);
|
|
10
|
+
/** Search the marketplace for services. */
|
|
11
|
+
findServices(query: string, filters?: Omit<ServiceSearchParams, 'q'>): Promise<Service[]>;
|
|
12
|
+
/** Purchase a service. Returns checkout result with payment instructions. */
|
|
13
|
+
purchase(input: CheckoutInput): Promise<CheckoutResult>;
|
|
14
|
+
/** Confirm delivery and release escrow via the API. */
|
|
15
|
+
confirm(transactionId: string): Promise<ApiResponse<Transaction>>;
|
|
16
|
+
/** Open a dispute on a transaction. */
|
|
17
|
+
dispute(transactionId: string, reason: string): Promise<ApiResponse<Transaction>>;
|
|
18
|
+
/**
|
|
19
|
+
* Start a webhook server to receive delivery notifications.
|
|
20
|
+
* Returns the callback URL to pass to checkout.
|
|
21
|
+
*/
|
|
22
|
+
onDelivery(port: number, handler: WebhookHandler): Promise<string>;
|
|
23
|
+
/** Stop the webhook server. */
|
|
24
|
+
stopWebhook(): Promise<void>;
|
|
25
|
+
/**
|
|
26
|
+
* Initialize a ZeroDev smart account for on-chain payments.
|
|
27
|
+
* Requires @zerodev/sdk, @zerodev/ecdsa-validator, and permissionless as peer deps.
|
|
28
|
+
*/
|
|
29
|
+
initWallet(config: SmartAccountConfig): Promise<string>;
|
|
30
|
+
/**
|
|
31
|
+
* Fund an on-chain escrow for a transaction.
|
|
32
|
+
* Requires initWallet() to have been called first.
|
|
33
|
+
* @param tokenSymbol - Settlement token symbol (default: 'USDC'). Must match the service's currency.
|
|
34
|
+
* Returns the on-chain transaction hash.
|
|
35
|
+
*/
|
|
36
|
+
fundEscrow(transactionId: string, sellerAddress: string, amount: bigint, tokenSymbol?: string): Promise<string>;
|
|
37
|
+
/**
|
|
38
|
+
* Fund escrow on-chain and verify with the backend.
|
|
39
|
+
* This is the complete funding flow:
|
|
40
|
+
* 1. Approve token spending
|
|
41
|
+
* 2. Call createEscrow on the escrow contract
|
|
42
|
+
* 3. POST /api/v1/transactions/:id/fund to verify on-chain state
|
|
43
|
+
*
|
|
44
|
+
* Returns the fund verification result from the backend.
|
|
45
|
+
* Requires initWallet() or initWithSessionKey() to have been called first.
|
|
46
|
+
*/
|
|
47
|
+
fundAndVerify(transactionId: string, sellerAddress: string, amount: bigint, tokenSymbol?: string): Promise<ApiResponse<import('./types.js').FundResult>>;
|
|
48
|
+
/**
|
|
49
|
+
* Confirm delivery via API and release escrow on-chain.
|
|
50
|
+
* Combines both the API confirm call and the smart contract release.
|
|
51
|
+
* Token doesn't matter for release — the contract reads it from the stored escrow.
|
|
52
|
+
*/
|
|
53
|
+
confirmAndRelease(transactionId: string): Promise<void>;
|
|
54
|
+
/**
|
|
55
|
+
* Initialize wallet from a serialized session key (agent operation).
|
|
56
|
+
* No owner private key needed — only the serialized session key string.
|
|
57
|
+
* The resulting wallet can only perform actions allowed by the session's policies.
|
|
58
|
+
* All existing methods (fundEscrow, confirmAndRelease) work after this call.
|
|
59
|
+
*
|
|
60
|
+
* Requires @zerodev/sdk and @zerodev/permissions as peer deps.
|
|
61
|
+
*/
|
|
62
|
+
initWithSessionKey(config: UseSessionKeyConfig): Promise<string>;
|
|
63
|
+
/**
|
|
64
|
+
* Generate a scoped session key for an agent (owner/developer operation).
|
|
65
|
+
* The owner calls this with their private key, then passes the serialized
|
|
66
|
+
* session key string to the agent. The session key is restricted to
|
|
67
|
+
* escrow operations (USDC.approve, createEscrow, release) by default.
|
|
68
|
+
*
|
|
69
|
+
* This is a static method — it doesn't require an API key or AbbabaClient.
|
|
70
|
+
*
|
|
71
|
+
* Requires @zerodev/sdk, @zerodev/ecdsa-validator, and @zerodev/permissions.
|
|
72
|
+
*/
|
|
73
|
+
static createSessionKey(config: SessionKeyConfig): Promise<SessionKeyResult>;
|
|
74
|
+
getWalletAddress(): string | null;
|
|
75
|
+
/** Returns the resolved gas strategy after initWallet() or initWithSessionKey(). */
|
|
76
|
+
getGasStrategy(): 'self-funded' | 'erc20' | null;
|
|
77
|
+
}
|
|
78
|
+
//# sourceMappingURL=buyer.d.ts.map
|
|
@@ -0,0 +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,EACpB,MAAM,YAAY,CAAA;AAEnB,qBAAa,UAAU;IACrB,SAAgB,MAAM,EAAE,Y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G;IACG,iBAAiB,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAU7D;;;;;;;OAOG;IACG,kBAAkB,CAAC,MAAM,EAAE,mBAAmB,GAAG,OAAO,CAAC,MAAM,CAAC;IAStE;;;;;;;;;OASG;WACU,gBAAgB,CAC3B,MAAM,EAAE,gBAAgB,GACvB,OAAO,CAAC,gBAAgB,CAAC;IAK5B,gBAAgB,IAAI,MAAM,GAAG,IAAI;IAIjC,oFAAoF;IACpF,cAAc,IAAI,aAAa,GAAG,OAAO,GAAG,IAAI;CAGjD"}
|
package/dist/buyer.js
ADDED
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import { AbbabaClient } from './client.js';
|
|
2
|
+
import { WebhookServer } from './webhook.js';
|
|
3
|
+
export class BuyerAgent {
|
|
4
|
+
client;
|
|
5
|
+
webhookServer = null;
|
|
6
|
+
walletAddress = null;
|
|
7
|
+
kernelClient = null;
|
|
8
|
+
resolvedGasStrategy = null;
|
|
9
|
+
constructor(config) {
|
|
10
|
+
this.client = new AbbabaClient(config);
|
|
11
|
+
}
|
|
12
|
+
/** Search the marketplace for services. */
|
|
13
|
+
async findServices(query, filters) {
|
|
14
|
+
const res = await this.client.services.search({ q: query, ...filters });
|
|
15
|
+
if (!res.success || !res.data) {
|
|
16
|
+
throw new Error(res.error ?? 'Search failed');
|
|
17
|
+
}
|
|
18
|
+
return res.data.services;
|
|
19
|
+
}
|
|
20
|
+
/** Purchase a service. Returns checkout result with payment instructions. */
|
|
21
|
+
async purchase(input) {
|
|
22
|
+
const res = await this.client.checkout.purchase(input);
|
|
23
|
+
if (!res.success || !res.data) {
|
|
24
|
+
throw new Error(res.error ?? 'Purchase failed');
|
|
25
|
+
}
|
|
26
|
+
return res.data;
|
|
27
|
+
}
|
|
28
|
+
/** Confirm delivery and release escrow via the API. */
|
|
29
|
+
async confirm(transactionId) {
|
|
30
|
+
return this.client.transactions.confirm(transactionId);
|
|
31
|
+
}
|
|
32
|
+
/** Open a dispute on a transaction. */
|
|
33
|
+
async dispute(transactionId, reason) {
|
|
34
|
+
return this.client.transactions.dispute(transactionId, { reason });
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Start a webhook server to receive delivery notifications.
|
|
38
|
+
* Returns the callback URL to pass to checkout.
|
|
39
|
+
*/
|
|
40
|
+
async onDelivery(port, handler) {
|
|
41
|
+
this.webhookServer = new WebhookServer(handler);
|
|
42
|
+
const info = await this.webhookServer.start(port);
|
|
43
|
+
return info.url;
|
|
44
|
+
}
|
|
45
|
+
/** Stop the webhook server. */
|
|
46
|
+
async stopWebhook() {
|
|
47
|
+
if (this.webhookServer) {
|
|
48
|
+
await this.webhookServer.stop();
|
|
49
|
+
this.webhookServer = null;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Initialize a ZeroDev smart account for on-chain payments.
|
|
54
|
+
* Requires @zerodev/sdk, @zerodev/ecdsa-validator, and permissionless as peer deps.
|
|
55
|
+
*/
|
|
56
|
+
async initWallet(config) {
|
|
57
|
+
const { createSmartAccount } = await import('./wallet/smart-account.js');
|
|
58
|
+
const result = await createSmartAccount(config);
|
|
59
|
+
this.walletAddress = result.address;
|
|
60
|
+
this.kernelClient = result.kernelClient;
|
|
61
|
+
this.resolvedGasStrategy = result.gasStrategy;
|
|
62
|
+
return result.address;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Fund an on-chain escrow for a transaction.
|
|
66
|
+
* Requires initWallet() to have been called first.
|
|
67
|
+
* @param tokenSymbol - Settlement token symbol (default: 'USDC'). Must match the service's currency.
|
|
68
|
+
* Returns the on-chain transaction hash.
|
|
69
|
+
*/
|
|
70
|
+
async fundEscrow(transactionId, sellerAddress, amount, tokenSymbol = 'USDC') {
|
|
71
|
+
if (!this.kernelClient) {
|
|
72
|
+
throw new Error('Wallet not initialized. Call initWallet() first.');
|
|
73
|
+
}
|
|
74
|
+
const { EscrowClient } = await import('./wallet/escrow.js');
|
|
75
|
+
const { getToken, POLYGON_AMOY_CHAIN_ID } = await import('./wallet/constants.js');
|
|
76
|
+
const token = getToken(POLYGON_AMOY_CHAIN_ID, tokenSymbol);
|
|
77
|
+
const escrow = new EscrowClient(this.kernelClient, token);
|
|
78
|
+
await escrow.approveToken(amount);
|
|
79
|
+
return escrow.fundEscrow(transactionId, sellerAddress, amount);
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Fund escrow on-chain and verify with the backend.
|
|
83
|
+
* This is the complete funding flow:
|
|
84
|
+
* 1. Approve token spending
|
|
85
|
+
* 2. Call createEscrow on the escrow contract
|
|
86
|
+
* 3. POST /api/v1/transactions/:id/fund to verify on-chain state
|
|
87
|
+
*
|
|
88
|
+
* Returns the fund verification result from the backend.
|
|
89
|
+
* Requires initWallet() or initWithSessionKey() to have been called first.
|
|
90
|
+
*/
|
|
91
|
+
async fundAndVerify(transactionId, sellerAddress, amount, tokenSymbol = 'USDC') {
|
|
92
|
+
const txHash = await this.fundEscrow(transactionId, sellerAddress, amount, tokenSymbol);
|
|
93
|
+
return this.client.transactions.fund(transactionId, { txHash });
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Confirm delivery via API and release escrow on-chain.
|
|
97
|
+
* Combines both the API confirm call and the smart contract release.
|
|
98
|
+
* Token doesn't matter for release — the contract reads it from the stored escrow.
|
|
99
|
+
*/
|
|
100
|
+
async confirmAndRelease(transactionId) {
|
|
101
|
+
await this.client.transactions.confirm(transactionId);
|
|
102
|
+
if (this.kernelClient) {
|
|
103
|
+
const { EscrowClient } = await import('./wallet/escrow.js');
|
|
104
|
+
const escrow = new EscrowClient(this.kernelClient);
|
|
105
|
+
await escrow.releaseEscrow(transactionId);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Initialize wallet from a serialized session key (agent operation).
|
|
110
|
+
* No owner private key needed — only the serialized session key string.
|
|
111
|
+
* The resulting wallet can only perform actions allowed by the session's policies.
|
|
112
|
+
* All existing methods (fundEscrow, confirmAndRelease) work after this call.
|
|
113
|
+
*
|
|
114
|
+
* Requires @zerodev/sdk and @zerodev/permissions as peer deps.
|
|
115
|
+
*/
|
|
116
|
+
async initWithSessionKey(config) {
|
|
117
|
+
const { useSessionKey } = await import('./wallet/session-keys.js');
|
|
118
|
+
const result = await useSessionKey(config);
|
|
119
|
+
this.walletAddress = result.address;
|
|
120
|
+
this.kernelClient = result.kernelClient;
|
|
121
|
+
this.resolvedGasStrategy = result.gasStrategy;
|
|
122
|
+
return result.address;
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Generate a scoped session key for an agent (owner/developer operation).
|
|
126
|
+
* The owner calls this with their private key, then passes the serialized
|
|
127
|
+
* session key string to the agent. The session key is restricted to
|
|
128
|
+
* escrow operations (USDC.approve, createEscrow, release) by default.
|
|
129
|
+
*
|
|
130
|
+
* This is a static method — it doesn't require an API key or AbbabaClient.
|
|
131
|
+
*
|
|
132
|
+
* Requires @zerodev/sdk, @zerodev/ecdsa-validator, and @zerodev/permissions.
|
|
133
|
+
*/
|
|
134
|
+
static async createSessionKey(config) {
|
|
135
|
+
const { generateSessionKey } = await import('./wallet/session-keys.js');
|
|
136
|
+
return generateSessionKey(config);
|
|
137
|
+
}
|
|
138
|
+
getWalletAddress() {
|
|
139
|
+
return this.walletAddress;
|
|
140
|
+
}
|
|
141
|
+
/** Returns the resolved gas strategy after initWallet() or initWithSessionKey(). */
|
|
142
|
+
getGasStrategy() {
|
|
143
|
+
return this.resolvedGasStrategy;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
//# sourceMappingURL=buyer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"buyer.js","sourceRoot":"","sources":["../src/buyer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AAgB5C,MA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AM,EAAE,aAAa,EAAE,GAAG,MAAM,MAAM,CAAC,0BAA0B,CAAC,CAAA;QAClE,MAAM,MAAM,GAAG,MAAM,aAAa,CAAC,MAAM,CAAC,CAAA;QAC1C,IAAI,CAAC,aAAa,GAAG,MAAM,CAAC,OAAO,CAAA;QACnC,IAAI,CAAC,YAAY,GAAG,MAAM,CAAC,YAAY,CAAA;QACvC,IAAI,CAAC,mBAAmB,GAAG,MAAM,CAAC,WAAW,CAAA;QAC7C,OAAO,MAAM,CAAC,OAAO,CAAA;IACvB,CAAC;IAED;;;;;;;;;OASG;IACH,MAAM,CAAC,KAAK,CAAC,gBAAgB,CAC3B,MAAwB;QAExB,MAAM,EAAE,kBAAkB,EAAE,GAAG,MAAM,MAAM,CAAC,0BAA0B,CAAC,CAAA;QACvE,OAAO,kBAAkB,CAAC,MAAM,CAAC,CAAA;IACnC,CAAC;IAED,gBAAgB;QACd,OAAO,IAAI,CAAC,aAAa,CAAA;IAC3B,CAAC;IAED,oFAAoF;IACpF,cAAc;QACZ,OAAO,IAAI,CAAC,mBAAmB,CAAA;IACjC,CAAC;CACF"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { AbbabaClient } from './client.js';
|
|
2
|
+
import type { ApiResponse, CheckoutInput, CheckoutResult } from './types.js';
|
|
3
|
+
export declare class CheckoutClient {
|
|
4
|
+
private client;
|
|
5
|
+
constructor(client: AbbabaClient);
|
|
6
|
+
purchase(input: CheckoutInput): Promise<ApiResponse<CheckoutResult>>;
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=checkout.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"checkout.d.ts","sourceRoot":"","sources":["../src/checkout.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAC/C,OAAO,KAAK,EAAE,WAAW,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAE5E,qBAAa,cAAc;IACb,OAAO,CAAC,MAAM;gBAAN,MAAM,EAAE,YAAY;IAElC,QAAQ,CAAC,KAAK,EAAE,aAAa,GAAG,OAAO,CAAC,WAAW,CAAC,cAAc,CAAC,CAAC;CAG3E"}
|
package/dist/checkout.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"checkout.js","sourceRoot":"","sources":["../src/checkout.ts"],"names":[],"mappings":"AAGA,MAAM,OAAO,cAAc;IACL;IAApB,YAAoB,MAAoB;QAApB,WAAM,GAAN,MAAM,CAAc;IAAG,CAAC;IAE5C,KAAK,CAAC,QAAQ,CAAC,KAAoB;QACjC,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,CAAiB,MAAM,EAAE,kBAAkB,EAAE,KAAK,CAAC,CAAA;IAC/E,CAAC;CACF"}
|
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { AbbabaConfig, ApiResponse } from './types.js';
|
|
2
|
+
import { ServicesClient } from './services.js';
|
|
3
|
+
import { CheckoutClient } from './checkout.js';
|
|
4
|
+
import { TransactionsClient } from './transactions.js';
|
|
5
|
+
import { type RegisterOptions, type RegisterResult } from './register.js';
|
|
6
|
+
export declare class AbbabaClient {
|
|
7
|
+
private apiKey;
|
|
8
|
+
private baseUrl;
|
|
9
|
+
private timeout;
|
|
10
|
+
readonly services: ServicesClient;
|
|
11
|
+
readonly checkout: CheckoutClient;
|
|
12
|
+
readonly transactions: TransactionsClient;
|
|
13
|
+
/**
|
|
14
|
+
* Headless registration: sign with a wallet private key, receive an API key.
|
|
15
|
+
* No browser, email, or CAPTCHA required.
|
|
16
|
+
*/
|
|
17
|
+
static register(opts: RegisterOptions): Promise<RegisterResult>;
|
|
18
|
+
constructor(config: AbbabaConfig);
|
|
19
|
+
request<T>(method: string, path: string, body?: unknown, queryParams?: Record<string, string>): Promise<ApiResponse<T>>;
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AAS3D,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAA;AAC9C,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAA;AAC9C,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAA;AACtD,OAAO,EAAY,KAAK,eAAe,EAAE,KAAK,cAAc,EAAE,MAAM,eAAe,CAAA;AAKnF,qBAAa,YAAY;IACvB,OAAO,CAAC,MAAM,CAAQ;IACtB,OAAO,CAAC,OAAO,CAAQ;IACvB,OAAO,CAAC,OAAO,CAAQ;IAEvB,SAAgB,QAAQ,EAAE,cAAc,CAAA;IACxC,SAAgB,QAAQ,EAAE,cAAc,CAAA;IACxC,SAAgB,YAAY,EAAE,kBAAkB,CAAA;IAEhD;;;OAGG;IACH,MAAM,CAAC,QAAQ,CAAC,IAAI,EAAE,eAAe,GAAG,OAAO,CAAC,cAAc,CAAC;gBAInD,MAAM,EAAE,YAAY;IAc1B,OAAO,CAAC,CAAC,EACb,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EACZ,IAAI,CAAC,EAAE,OAAO,EACd,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GACnC,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;CAgF3B"}
|
package/dist/client.js
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { AbbabaError, AuthenticationError, ForbiddenError, NotFoundError, RateLimitError, ValidationError, } from './errors.js';
|
|
2
|
+
import { ServicesClient } from './services.js';
|
|
3
|
+
import { CheckoutClient } from './checkout.js';
|
|
4
|
+
import { TransactionsClient } from './transactions.js';
|
|
5
|
+
import { register } from './register.js';
|
|
6
|
+
const DEFAULT_BASE_URL = 'https://abbababa.com';
|
|
7
|
+
const DEFAULT_TIMEOUT = 30_000;
|
|
8
|
+
export class AbbabaClient {
|
|
9
|
+
apiKey;
|
|
10
|
+
baseUrl;
|
|
11
|
+
timeout;
|
|
12
|
+
services;
|
|
13
|
+
checkout;
|
|
14
|
+
transactions;
|
|
15
|
+
/**
|
|
16
|
+
* Headless registration: sign with a wallet private key, receive an API key.
|
|
17
|
+
* No browser, email, or CAPTCHA required.
|
|
18
|
+
*/
|
|
19
|
+
static register(opts) {
|
|
20
|
+
return register(opts);
|
|
21
|
+
}
|
|
22
|
+
constructor(config) {
|
|
23
|
+
if (!config.apiKey) {
|
|
24
|
+
throw new Error('apiKey is required');
|
|
25
|
+
}
|
|
26
|
+
this.apiKey = config.apiKey;
|
|
27
|
+
this.baseUrl = (config.baseUrl ?? DEFAULT_BASE_URL).replace(/\/+$/, '');
|
|
28
|
+
this.timeout = config.timeout ?? DEFAULT_TIMEOUT;
|
|
29
|
+
this.services = new ServicesClient(this);
|
|
30
|
+
this.checkout = new CheckoutClient(this);
|
|
31
|
+
this.transactions = new TransactionsClient(this);
|
|
32
|
+
}
|
|
33
|
+
async request(method, path, body, queryParams) {
|
|
34
|
+
let url = `${this.baseUrl}${path}`;
|
|
35
|
+
if (queryParams) {
|
|
36
|
+
const params = new URLSearchParams();
|
|
37
|
+
for (const [key, value] of Object.entries(queryParams)) {
|
|
38
|
+
if (value !== undefined && value !== '') {
|
|
39
|
+
params.set(key, value);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
const qs = params.toString();
|
|
43
|
+
if (qs)
|
|
44
|
+
url += `?${qs}`;
|
|
45
|
+
}
|
|
46
|
+
const headers = {
|
|
47
|
+
'X-API-Key': this.apiKey,
|
|
48
|
+
'Accept': 'application/json',
|
|
49
|
+
};
|
|
50
|
+
const init = {
|
|
51
|
+
method,
|
|
52
|
+
headers,
|
|
53
|
+
};
|
|
54
|
+
if (body !== undefined && method !== 'GET') {
|
|
55
|
+
headers['Content-Type'] = 'application/json';
|
|
56
|
+
init.body = JSON.stringify(body);
|
|
57
|
+
}
|
|
58
|
+
const controller = new AbortController();
|
|
59
|
+
init.signal = controller.signal;
|
|
60
|
+
const timer = setTimeout(() => controller.abort(), this.timeout);
|
|
61
|
+
let response;
|
|
62
|
+
try {
|
|
63
|
+
response = await fetch(url, init);
|
|
64
|
+
}
|
|
65
|
+
catch (err) {
|
|
66
|
+
if (err instanceof DOMException && err.name === 'AbortError') {
|
|
67
|
+
throw new AbbabaError(0, `Request timed out after ${this.timeout}ms`);
|
|
68
|
+
}
|
|
69
|
+
throw new AbbabaError(0, `Network error: ${err instanceof Error ? err.message : String(err)}`);
|
|
70
|
+
}
|
|
71
|
+
finally {
|
|
72
|
+
clearTimeout(timer);
|
|
73
|
+
}
|
|
74
|
+
let json;
|
|
75
|
+
try {
|
|
76
|
+
json = await response.json();
|
|
77
|
+
}
|
|
78
|
+
catch {
|
|
79
|
+
throw new AbbabaError(response.status, `Invalid JSON response (HTTP ${response.status})`);
|
|
80
|
+
}
|
|
81
|
+
if (!response.ok) {
|
|
82
|
+
const message = json.error ?? `HTTP ${response.status}`;
|
|
83
|
+
switch (response.status) {
|
|
84
|
+
case 401:
|
|
85
|
+
throw new AuthenticationError(message);
|
|
86
|
+
case 403:
|
|
87
|
+
throw new ForbiddenError(message);
|
|
88
|
+
case 404:
|
|
89
|
+
throw new NotFoundError(message);
|
|
90
|
+
case 400:
|
|
91
|
+
throw new ValidationError(message, json.details);
|
|
92
|
+
case 429: {
|
|
93
|
+
const retryAfter = parseInt(response.headers.get('Retry-After') ?? '60', 10);
|
|
94
|
+
throw new RateLimitError(message, retryAfter);
|
|
95
|
+
}
|
|
96
|
+
default:
|
|
97
|
+
throw new AbbabaError(response.status, message, json.details);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
return json;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
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e,CAAC,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,CAAA;gBAClD,KAAK,GAAG,CAAC,CAAC,CAAC;oBACT,MAAM,UAAU,GAAG,QAAQ,CACzB,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC,IAAI,IAAI,EAC3C,EAAE,CACH,CAAA;oBACD,MAAM,IAAI,cAAc,CAAC,OAAO,EAAE,UAAU,CAAC,CAAA;gBAC/C,CAAC;gBACD;oBACE,MAAM,IAAI,WAAW,CAAC,QAAQ,CAAC,MAAM,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,CAAA;YACjE,CAAC;QACH,CAAC;QAED,OAAO,IAAI,CAAA;IACb,CAAC;CACF"}
|
package/dist/errors.d.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export declare class AbbabaError extends Error {
|
|
2
|
+
statusCode: number;
|
|
3
|
+
details?: unknown | undefined;
|
|
4
|
+
constructor(statusCode: number, message: string, details?: unknown | undefined);
|
|
5
|
+
}
|
|
6
|
+
export declare class AuthenticationError extends AbbabaError {
|
|
7
|
+
constructor(message?: string);
|
|
8
|
+
}
|
|
9
|
+
export declare class ForbiddenError extends AbbabaError {
|
|
10
|
+
constructor(message?: string);
|
|
11
|
+
}
|
|
12
|
+
export declare class NotFoundError extends AbbabaError {
|
|
13
|
+
constructor(message?: string);
|
|
14
|
+
}
|
|
15
|
+
export declare class ValidationError extends AbbabaError {
|
|
16
|
+
constructor(message?: string, details?: unknown);
|
|
17
|
+
}
|
|
18
|
+
export declare class RateLimitError extends AbbabaError {
|
|
19
|
+
retryAfter: number;
|
|
20
|
+
constructor(message?: string, retryAfter?: number);
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,qBAAa,WAAY,SAAQ,KAAK;IAE3B,UAAU,EAAE,MAAM;IAElB,OAAO,CAAC,EAAE,OAAO;gBAFjB,UAAU,EAAE,MAAM,EACzB,OAAO,EAAE,MAAM,EACR,OAAO,CAAC,EAAE,OAAO,YAAA;CAK3B;AAED,qBAAa,mBAAoB,SAAQ,WAAW;gBACtC,OAAO,SAA+B;CAInD;AAED,qBAAa,cAAe,SAAQ,WAAW;gBACjC,OAAO,SAAc;CAIlC;AAED,qBAAa,aAAc,SAAQ,WAAW;gBAChC,OAAO,SAAuB;CAI3C;AAED,qBAAa,eAAgB,SAAQ,WAAW;gBAClC,OAAO,SAAsB,EAAE,OAAO,CAAC,EAAE,OAAO;CAI7D;AAED,qBAAa,cAAe,SAAQ,WAAW;IACtC,UAAU,EAAE,MAAM,CAAA;gBAEb,OAAO,SAAwB,EAAE,UAAU,SAAK;CAK7D"}
|
package/dist/errors.js
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
export class AbbabaError extends Error {
|
|
2
|
+
statusCode;
|
|
3
|
+
details;
|
|
4
|
+
constructor(statusCode, message, details) {
|
|
5
|
+
super(message);
|
|
6
|
+
this.statusCode = statusCode;
|
|
7
|
+
this.details = details;
|
|
8
|
+
this.name = 'AbbabaError';
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
export class AuthenticationError extends AbbabaError {
|
|
12
|
+
constructor(message = 'Invalid or missing API key') {
|
|
13
|
+
super(401, message);
|
|
14
|
+
this.name = 'AuthenticationError';
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
export class ForbiddenError extends AbbabaError {
|
|
18
|
+
constructor(message = 'Forbidden') {
|
|
19
|
+
super(403, message);
|
|
20
|
+
this.name = 'ForbiddenError';
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
export class NotFoundError extends AbbabaError {
|
|
24
|
+
constructor(message = 'Resource not found') {
|
|
25
|
+
super(404, message);
|
|
26
|
+
this.name = 'NotFoundError';
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
export class ValidationError extends AbbabaError {
|
|
30
|
+
constructor(message = 'Validation failed', details) {
|
|
31
|
+
super(400, message, details);
|
|
32
|
+
this.name = 'ValidationError';
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
export class RateLimitError extends AbbabaError {
|
|
36
|
+
retryAfter;
|
|
37
|
+
constructor(message = 'Rate limit exceeded', retryAfter = 60) {
|
|
38
|
+
super(429, message);
|
|
39
|
+
this.name = 'RateLimitError';
|
|
40
|
+
this.retryAfter = retryAfter;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,WAAY,SAAQ,KAAK;IAE3B;IAEA;IAHT,YACS,UAAkB,EACzB,OAAe,EACR,OAAiB;QAExB,KAAK,CAAC,OAAO,CAAC,CAAA;QAJP,eAAU,GAAV,UAAU,CAAQ;QAElB,YAAO,GAAP,OAAO,CAAU;QAGxB,IAAI,CAAC,IAAI,GAAG,aAAa,CAAA;IAC3B,CAAC;CACF;AAED,MAAM,OAAO,mBAAoB,SAAQ,WAAW;IAClD,YAAY,OAAO,GAAG,4BAA4B;QAChD,KAAK,CAAC,GAAG,EAAE,OAAO,CAAC,CAAA;QACnB,IAAI,CAAC,IAAI,GAAG,qBAAqB,CAAA;IACnC,CAAC;CACF;AAED,MAAM,OAAO,cAAe,SAAQ,WAAW;IAC7C,YAAY,OAAO,GAAG,WAAW;QAC/B,KAAK,CAAC,GAAG,EAAE,OAAO,CAAC,CAAA;QACnB,IAAI,CAAC,IAAI,GAAG,gBAAgB,CAAA;IAC9B,CAAC;CACF;AAED,MAAM,OAAO,aAAc,SAAQ,WAAW;IAC5C,YAAY,OAAO,GAAG,oBAAoB;QACxC,KAAK,CAAC,GAAG,EAAE,OAAO,CAAC,CAAA;QACnB,IAAI,CAAC,IAAI,GAAG,eAAe,CAAA;IAC7B,CAAC;CACF;AAED,MAAM,OAAO,eAAgB,SAAQ,WAAW;IAC9C,YAAY,OAAO,GAAG,mBAAmB,EAAE,OAAiB;QAC1D,KAAK,CAAC,GAAG,EAAE,OAAO,EAAE,OAAO,CAAC,CAAA;QAC5B,IAAI,CAAC,IAAI,GAAG,iBAAiB,CAAA;IAC/B,CAAC;CACF;AAED,MAAM,OAAO,cAAe,SAAQ,WAAW;IACtC,UAAU,CAAQ;IAEzB,YAAY,OAAO,GAAG,qBAAqB,EAAE,UAAU,GAAG,EAAE;QAC1D,KAAK,CAAC,GAAG,EAAE,OAAO,CAAC,CAAA;QACnB,IAAI,CAAC,IAAI,GAAG,gBAAgB,CAAA;QAC5B,IAAI,CAAC,UAAU,GAAG,UAAU,CAAA;IAC9B,CAAC;CACF"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export { AbbabaClient } from './client.js';
|
|
2
|
+
export { register } from './register.js';
|
|
3
|
+
export { SellerAgent } from './seller.js';
|
|
4
|
+
export { BuyerAgent } from './buyer.js';
|
|
5
|
+
export { ServicesClient } from './services.js';
|
|
6
|
+
export { CheckoutClient } from './checkout.js';
|
|
7
|
+
export { TransactionsClient } from './transactions.js';
|
|
8
|
+
export { WebhookServer } from './webhook.js';
|
|
9
|
+
export { AbbabaError, AuthenticationError, ForbiddenError, NotFoundError, ValidationError, RateLimitError, } from './errors.js';
|
|
10
|
+
export type { AbbabaConfig, ApiResponse, ServiceCategory, PriceUnit, ServiceCurrency, DeliveryType, ServiceStatus, PaymentMethod, PaymentStatus, TransactionStatus, DisputeOutcome, WalletChain, CreateServiceInput, UpdateServiceInput, Service, ServiceSearchParams, ServiceListResult, AgentSummary, CheckoutInput, CheckoutResult, CryptoPaymentInstructions, PaymentInstructions, Transaction, TransactionListParams, TransactionListResult, DeliverInput, DisputeInput, FundInput, FundResult, WebhookEvent, WebhookHandler, GasStrategy, SmartAccountConfig, SmartAccountResult, EscrowDetails, SessionKeyConfig, SessionKeyResult, UseSessionKeyConfig, RevokeSessionKeyConfig, PollOptions, } from './types.js';
|
|
11
|
+
export type { RegisterOptions, RegisterResult } from './register.js';
|
|
12
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAG1C,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAGxC,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AACzC,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAGvC,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAA;AAC9C,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAA;AAC9C,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAA;AAGtD,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AAG5C,OAAO,EACL,WAAW,EACX,mBAAmB,EACnB,cAAc,EACd,aAAa,EACb,eAAe,EACf,cAAc,GACf,MAAM,aAAa,CAAA;AAGpB,YAAY,EAEV,YAAY,EACZ,WAAW,EAGX,eAAe,EACf,SAAS,EACT,eAAe,EACf,YAAY,EACZ,aAAa,EACb,aAAa,EACb,aAAa,EACb,iBAAiB,EACjB,cAAc,EACd,WAAW,EAGX,kBAAkB,EAClB,kBAAkB,EAClB,OAAO,EACP,mBAAmB,EACnB,iBAAiB,EACjB,YAAY,EAGZ,aAAa,EACb,cAAc,EACd,yBAAyB,EACzB,mBAAmB,EAGnB,WAAW,EACX,qBAAqB,EACrB,qBAAqB,EACrB,YAAY,EACZ,YAAY,EACZ,SAAS,EACT,UAAU,EAGV,YAAY,EACZ,cAAc,EAGd,WAAW,EACX,kBAAkB,EAClB,kBAAkB,EAClB,aAAa,EAGb,gBAAgB,EAChB,gBAAgB,EAChB,mBAAmB,EACnB,sBAAsB,EAGtB,WAAW,GACZ,MAAM,YAAY,CAAA;AAGnB,YAAY,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,eAAe,CAAA"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// Core client
|
|
2
|
+
export { AbbabaClient } from './client.js';
|
|
3
|
+
// Headless registration
|
|
4
|
+
export { register } from './register.js';
|
|
5
|
+
// Agent orchestrators
|
|
6
|
+
export { SellerAgent } from './seller.js';
|
|
7
|
+
export { BuyerAgent } from './buyer.js';
|
|
8
|
+
// Sub-clients
|
|
9
|
+
export { ServicesClient } from './services.js';
|
|
10
|
+
export { CheckoutClient } from './checkout.js';
|
|
11
|
+
export { TransactionsClient } from './transactions.js';
|
|
12
|
+
// Webhook server
|
|
13
|
+
export { WebhookServer } from './webhook.js';
|
|
14
|
+
// Errors
|
|
15
|
+
export { AbbabaError, AuthenticationError, ForbiddenError, NotFoundError, ValidationError, RateLimitError, } from './errors.js';
|
|
16
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc;AACd,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAE1C,wBAAwB;AACxB,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAExC,sBAAsB;AACtB,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AACzC,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAEvC,cAAc;AACd,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAA;AAC9C,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAA;AAC9C,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAA;AAEtD,iBAAiB;AACjB,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AAE5C,SAAS;AACT,OAAO,EACL,WAAW,EACX,mBAAmB,EACnB,cAAc,EACd,aAAa,EACb,eAAe,EACf,cAAc,GACf,MAAM,aAAa,CAAA"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export interface RegisterOptions {
|
|
2
|
+
privateKey: `0x${string}`;
|
|
3
|
+
agentName: string;
|
|
4
|
+
agentDescription?: string;
|
|
5
|
+
baseUrl?: string;
|
|
6
|
+
}
|
|
7
|
+
export interface RegisterResult {
|
|
8
|
+
apiKey: string;
|
|
9
|
+
agentId: string;
|
|
10
|
+
developerId: string;
|
|
11
|
+
walletAddress: string;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Headless agent registration using an EVM wallet signature.
|
|
15
|
+
* Signs a canonical message with the provided private key and
|
|
16
|
+
* POSTs to /api/v1/auth/register.
|
|
17
|
+
*
|
|
18
|
+
* Returns the API key, agent ID, and wallet address on success.
|
|
19
|
+
*/
|
|
20
|
+
export declare function register(opts: RegisterOptions): Promise<RegisterResult>;
|
|
21
|
+
//# sourceMappingURL=register.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"register.d.ts","sourceRoot":"","sources":["../src/register.ts"],"names":[],"mappings":"AAKA,MAAM,WAAW,eAAe;IAC9B,UAAU,EAAE,KAAK,MAAM,EAAE,CAAA;IACzB,SAAS,EAAE,MAAM,CAAA;IACjB,gBAAgB,CAAC,EAAE,MAAM,CAAA;IACzB,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB;AAED,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,MAAM,CAAA;IACd,OAAO,EAAE,MAAM,CAAA;IACf,WAAW,EAAE,MAAM,CAAA;IACnB,aAAa,EAAE,MAAM,CAAA;CACtB;AAOD;;;;;;GAMG;AACH,wBAAsB,QAAQ,CAAC,IAAI,EAAE,eAAe,GAAG,OAAO,CAAC,cAAc,CAAC,CAiC7E"}
|