@pacspace-io/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 +192 -0
- package/dist/client.d.ts +61 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +225 -0
- package/dist/client.js.map +1 -0
- package/dist/errors/index.d.ts +69 -0
- package/dist/errors/index.d.ts.map +1 -0
- package/dist/errors/index.js +126 -0
- package/dist/errors/index.js.map +1 -0
- package/dist/index.d.ts +64 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +68 -0
- package/dist/index.js.map +1 -0
- package/dist/resources/balance.d.ts +148 -0
- package/dist/resources/balance.d.ts.map +1 -0
- package/dist/resources/balance.js +231 -0
- package/dist/resources/balance.js.map +1 -0
- package/dist/types/balance.d.ts +218 -0
- package/dist/types/balance.d.ts.map +1 -0
- package/dist/types/balance.js +3 -0
- package/dist/types/balance.js.map +1 -0
- package/dist/types/common.d.ts +21 -0
- package/dist/types/common.d.ts.map +1 -0
- package/dist/types/common.js +3 -0
- package/dist/types/common.js.map +1 -0
- package/dist/types/config.d.ts +54 -0
- package/dist/types/config.d.ts.map +1 -0
- package/dist/types/config.js +3 -0
- package/dist/types/config.js.map +1 -0
- package/dist/utils/polling.d.ts +32 -0
- package/dist/utils/polling.d.ts.map +1 -0
- package/dist/utils/polling.js +56 -0
- package/dist/utils/polling.js.map +1 -0
- package/dist/utils/retry.d.ts +14 -0
- package/dist/utils/retry.d.ts.map +1 -0
- package/dist/utils/retry.js +21 -0
- package/dist/utils/retry.js.map +1 -0
- package/dist/webhooks/index.d.ts +3 -0
- package/dist/webhooks/index.d.ts.map +1 -0
- package/dist/webhooks/index.js +6 -0
- package/dist/webhooks/index.js.map +1 -0
- package/dist/webhooks/types.d.ts +99 -0
- package/dist/webhooks/types.d.ts.map +1 -0
- package/dist/webhooks/types.js +6 -0
- package/dist/webhooks/types.js.map +1 -0
- package/dist/webhooks/verify.d.ts +104 -0
- package/dist/webhooks/verify.d.ts.map +1 -0
- package/dist/webhooks/verify.js +167 -0
- package/dist/webhooks/verify.js.map +1 -0
- package/package.json +46 -0
package/README.md
ADDED
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
# @pacspace-io/sdk
|
|
2
|
+
|
|
3
|
+
Official TypeScript SDK for the [PacSpace Balance API](https://docs.pacspace.io). Zero dependencies, fully typed, built for Node.js 18+.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @pacspace-io/sdk
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Quick Start
|
|
12
|
+
|
|
13
|
+
```typescript
|
|
14
|
+
import { PacSpace } from '@pacspace-io/sdk';
|
|
15
|
+
|
|
16
|
+
const pac = new PacSpace({ apiKey: process.env.PACSPACE_API_KEY! });
|
|
17
|
+
|
|
18
|
+
// Record a delta
|
|
19
|
+
const delta = await pac.balance.emit('cust_123', -42.50, 'usage_charge');
|
|
20
|
+
console.log(delta.receiptId); // Store for later verification
|
|
21
|
+
|
|
22
|
+
// Derive balance
|
|
23
|
+
const { computedBalance } = await pac.balance.derive('cust_123');
|
|
24
|
+
|
|
25
|
+
// Compare against counterparty
|
|
26
|
+
const report = await pac.balance.compare('cust_123', {
|
|
27
|
+
yours: 95000,
|
|
28
|
+
theirs: 98000,
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
// Period-end checkpoint
|
|
32
|
+
const checkpoint = await pac.balance.checkpoint('cust_123', {
|
|
33
|
+
period: '2026-02',
|
|
34
|
+
});
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## API Reference
|
|
38
|
+
|
|
39
|
+
### `new PacSpace(config)`
|
|
40
|
+
|
|
41
|
+
| Option | Type | Default | Description |
|
|
42
|
+
|--------|------|---------|-------------|
|
|
43
|
+
| `apiKey` | `string` | **required** | Your PacSpace API key (`pk_live_*` or `pk_test_*`) |
|
|
44
|
+
| `baseUrl` | `string` | `https://balance-api.pacspace.io` | API base URL |
|
|
45
|
+
| `chainId` | `number` | auto-detected | Default chain ID (296 for sandbox, 295 for production) |
|
|
46
|
+
| `maxRetries` | `number` | `2` | Max retries on transient errors |
|
|
47
|
+
| `timeout` | `number` | `30000` | Request timeout in ms |
|
|
48
|
+
| `webhookSecret` | `string` | — | Webhook signing secret (enables `pac.webhooks`) |
|
|
49
|
+
|
|
50
|
+
### Balance API
|
|
51
|
+
|
|
52
|
+
#### `pac.balance.emit(customerId, delta, reason, options?)`
|
|
53
|
+
|
|
54
|
+
Record a credit or debit delta. Returns immediately with `QUEUED` status.
|
|
55
|
+
|
|
56
|
+
```typescript
|
|
57
|
+
const delta = await pac.balance.emit('cust_123', -42.50, 'usage_charge', {
|
|
58
|
+
referenceId: 'inv_001',
|
|
59
|
+
metadata: { plan: 'growth' },
|
|
60
|
+
});
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
#### `pac.balance.emitAndWait(customerId, delta, reason, options?)`
|
|
64
|
+
|
|
65
|
+
Record a delta and poll until it reaches a terminal status (`VERIFIED` or `FAILED`).
|
|
66
|
+
|
|
67
|
+
```typescript
|
|
68
|
+
const verified = await pac.balance.emitAndWait('cust_123', -42.50, 'usage', {
|
|
69
|
+
timeout: 30_000,
|
|
70
|
+
pollInterval: 1000,
|
|
71
|
+
});
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
#### `pac.balance.derive(customerId, options?)`
|
|
75
|
+
|
|
76
|
+
Derive a customer's balance from all verified deltas.
|
|
77
|
+
|
|
78
|
+
```typescript
|
|
79
|
+
const result = await pac.balance.derive('cust_123');
|
|
80
|
+
console.log(result.computedBalance);
|
|
81
|
+
|
|
82
|
+
// With checkpointing for efficiency:
|
|
83
|
+
const next = await pac.balance.derive('cust_123', {
|
|
84
|
+
startingBalance: result.computedBalance,
|
|
85
|
+
startingCheckpoint: result.latestReceiptId!,
|
|
86
|
+
});
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
#### `pac.balance.compare(customerId, balances, options?)`
|
|
90
|
+
|
|
91
|
+
Compare balances against neutral truth for dispute resolution.
|
|
92
|
+
|
|
93
|
+
```typescript
|
|
94
|
+
const report = await pac.balance.compare('cust_123', {
|
|
95
|
+
yours: 95000,
|
|
96
|
+
theirs: 98000,
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
if (report.matchesYours) {
|
|
100
|
+
console.log('Your balance is correct');
|
|
101
|
+
}
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
#### `pac.balance.receipt(customerId, options?)`
|
|
105
|
+
|
|
106
|
+
Generate a verifiable receipt with cryptographic proof data.
|
|
107
|
+
|
|
108
|
+
```typescript
|
|
109
|
+
const receipt = await pac.balance.receipt('cust_123');
|
|
110
|
+
console.log(receipt.finalBalance);
|
|
111
|
+
console.log(receipt.verification.itemHashes);
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
#### `pac.balance.checkpoint(customerId?, options?)`
|
|
115
|
+
|
|
116
|
+
Commit a period-end checkpoint (Merkle root anchored on-chain).
|
|
117
|
+
|
|
118
|
+
```typescript
|
|
119
|
+
const checkpoint = await pac.balance.checkpoint('cust_123', {
|
|
120
|
+
period: '2026-02',
|
|
121
|
+
});
|
|
122
|
+
console.log(checkpoint.merkleRoot); // Include in your invoice
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
### Webhooks
|
|
126
|
+
|
|
127
|
+
Verify webhook signatures and process events with type safety.
|
|
128
|
+
|
|
129
|
+
```typescript
|
|
130
|
+
const pac = new PacSpace({
|
|
131
|
+
apiKey: process.env.PACSPACE_API_KEY!,
|
|
132
|
+
webhookSecret: process.env.PACSPACE_WEBHOOK_SECRET!,
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
// Express middleware
|
|
136
|
+
app.use('/webhooks', express.json({
|
|
137
|
+
verify: (req, _res, buf) => { (req as any).rawBody = buf.toString(); }
|
|
138
|
+
}));
|
|
139
|
+
|
|
140
|
+
app.post('/webhooks/pacspace', pac.webhooks!.middleware(), (req, res) => {
|
|
141
|
+
const event = (req as any).pacspaceEvent;
|
|
142
|
+
|
|
143
|
+
if (event.event === 'delta.verified') {
|
|
144
|
+
console.log('Delta verified:', event.data.receiptId);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
res.status(200).json({ received: true });
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
// Manual verification
|
|
151
|
+
const event = pac.webhooks!.verify(signature, timestamp, rawBody);
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
### Error Handling
|
|
155
|
+
|
|
156
|
+
All errors extend `PacSpaceError` with structured data:
|
|
157
|
+
|
|
158
|
+
```typescript
|
|
159
|
+
import { PacSpace, InsufficientCreditsError, RateLimitError } from '@pacspace-io/sdk';
|
|
160
|
+
|
|
161
|
+
try {
|
|
162
|
+
await pac.balance.emit('cust_123', -1000, 'charge');
|
|
163
|
+
} catch (err) {
|
|
164
|
+
if (err instanceof InsufficientCreditsError) {
|
|
165
|
+
console.log('Buy more credits');
|
|
166
|
+
} else if (err instanceof RateLimitError) {
|
|
167
|
+
console.log(`Retry after ${err.retryAfter}s`);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
| Error Class | Status | When |
|
|
173
|
+
|-------------|--------|------|
|
|
174
|
+
| `ValidationError` | 400 | Invalid request data |
|
|
175
|
+
| `InvalidApiKeyError` | 401 | Bad or missing API key |
|
|
176
|
+
| `InsufficientCreditsError` | 402 | Not enough credits |
|
|
177
|
+
| `NotFoundError` | 404 | Resource not found |
|
|
178
|
+
| `ContractNotDeployedError` | 412 | No contract provisioned |
|
|
179
|
+
| `RateLimitError` | 429 | Rate limit exceeded |
|
|
180
|
+
| `TimeoutError` | — | Polling timeout exceeded |
|
|
181
|
+
|
|
182
|
+
## Environment Detection
|
|
183
|
+
|
|
184
|
+
The SDK auto-detects your environment from the API key prefix:
|
|
185
|
+
|
|
186
|
+
- `pk_test_*` → Sandbox (Hedera Testnet, chain 296)
|
|
187
|
+
- `pk_live_*` → Production (Hedera Mainnet, chain 295)
|
|
188
|
+
|
|
189
|
+
## Requirements
|
|
190
|
+
|
|
191
|
+
- Node.js 18+ (uses native `fetch`)
|
|
192
|
+
- TypeScript 5+ (for full type inference)
|
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import type { PacSpaceConfig, RequestOptions } from './types/config';
|
|
2
|
+
/**
|
|
3
|
+
* Low-level HTTP client for the PacSpace API.
|
|
4
|
+
* Handles authentication, response unwrapping, retries, and error mapping.
|
|
5
|
+
*
|
|
6
|
+
* @internal — Use the PacSpace class instead of this directly.
|
|
7
|
+
*/
|
|
8
|
+
export declare class HttpClient {
|
|
9
|
+
private readonly apiKey;
|
|
10
|
+
private readonly baseUrl;
|
|
11
|
+
private readonly maxRetries;
|
|
12
|
+
private readonly timeout;
|
|
13
|
+
private readonly fetchFn;
|
|
14
|
+
/** Default chain ID, auto-detected from API key prefix or explicit config. */
|
|
15
|
+
readonly defaultChainId: number | undefined;
|
|
16
|
+
/** Default credit pool ID. */
|
|
17
|
+
readonly defaultCreditPoolId: number | undefined;
|
|
18
|
+
constructor(config: PacSpaceConfig);
|
|
19
|
+
/**
|
|
20
|
+
* Make a GET request and return unwrapped data.
|
|
21
|
+
*/
|
|
22
|
+
get<T>(path: string, options?: RequestOptions): Promise<T>;
|
|
23
|
+
/**
|
|
24
|
+
* Make a POST request and return unwrapped data.
|
|
25
|
+
*/
|
|
26
|
+
post<T>(path: string, body?: unknown, options?: RequestOptions): Promise<T>;
|
|
27
|
+
/**
|
|
28
|
+
* Core request method with retry logic, auth injection, and response unwrapping.
|
|
29
|
+
*/
|
|
30
|
+
private request;
|
|
31
|
+
/**
|
|
32
|
+
* Build HTTP headers with auth and optional overrides.
|
|
33
|
+
*/
|
|
34
|
+
private buildHeaders;
|
|
35
|
+
/**
|
|
36
|
+
* Fetch with an AbortController-based timeout.
|
|
37
|
+
*/
|
|
38
|
+
private fetchWithTimeout;
|
|
39
|
+
/**
|
|
40
|
+
* Calculate retry delay with exponential backoff.
|
|
41
|
+
* Respects Retry-After header for rate limit errors.
|
|
42
|
+
*/
|
|
43
|
+
private getRetryDelay;
|
|
44
|
+
/**
|
|
45
|
+
* Safely parse JSON from a response, returning null on failure.
|
|
46
|
+
*/
|
|
47
|
+
private safeParseJson;
|
|
48
|
+
/**
|
|
49
|
+
* Extract a string error message from a parsed error body.
|
|
50
|
+
*/
|
|
51
|
+
private extractErrorMessage;
|
|
52
|
+
/**
|
|
53
|
+
* Auto-detect chain ID from API key prefix.
|
|
54
|
+
*/
|
|
55
|
+
private detectChainId;
|
|
56
|
+
/**
|
|
57
|
+
* Promise-based sleep utility.
|
|
58
|
+
*/
|
|
59
|
+
private sleep;
|
|
60
|
+
}
|
|
61
|
+
//# 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,cAAc,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAwBrE;;;;;GAKG;AACH,qBAAa,UAAU;IACrB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAChC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;IACjC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAS;IACpC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;IACjC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAe;IAEvC,8EAA8E;IAC9E,QAAQ,CAAC,cAAc,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5C,8BAA8B;IAC9B,QAAQ,CAAC,mBAAmB,EAAE,MAAM,GAAG,SAAS,CAAC;gBAErC,MAAM,EAAE,cAAc;IA4BlC;;OAEG;IACG,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,CAAC,CAAC;IAIhE;;OAEG;IACG,IAAI,CAAC,CAAC,EACV,IAAI,EAAE,MAAM,EACZ,IAAI,CAAC,EAAE,OAAO,EACd,OAAO,CAAC,EAAE,cAAc,GACvB,OAAO,CAAC,CAAC,CAAC;IAIb;;OAEG;YACW,OAAO;IAwFrB;;OAEG;IACH,OAAO,CAAC,YAAY;IAwBpB;;OAEG;YACW,gBAAgB;IAoC9B;;;OAGG;IACH,OAAO,CAAC,aAAa;IAcrB;;OAEG;YACW,aAAa;IAU3B;;OAEG;IACH,OAAO,CAAC,mBAAmB;IAU3B;;OAEG;IACH,OAAO,CAAC,aAAa;IAUrB;;OAEG;IACH,OAAO,CAAC,KAAK;CAGd"}
|
package/dist/client.js
ADDED
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.HttpClient = void 0;
|
|
4
|
+
const errors_1 = require("./errors");
|
|
5
|
+
/**
|
|
6
|
+
* Default base URL for the PacSpace API.
|
|
7
|
+
*/
|
|
8
|
+
const DEFAULT_BASE_URL = 'https://balance-api.pacspace.io';
|
|
9
|
+
/**
|
|
10
|
+
* Default request timeout in milliseconds.
|
|
11
|
+
*/
|
|
12
|
+
const DEFAULT_TIMEOUT_MS = 30000;
|
|
13
|
+
/**
|
|
14
|
+
* Default maximum number of retries on transient errors.
|
|
15
|
+
*/
|
|
16
|
+
const DEFAULT_MAX_RETRIES = 2;
|
|
17
|
+
/**
|
|
18
|
+
* HTTP status codes that are safe to retry.
|
|
19
|
+
*/
|
|
20
|
+
const RETRYABLE_STATUS_CODES = new Set([408, 429, 500, 502, 503, 504]);
|
|
21
|
+
/**
|
|
22
|
+
* Low-level HTTP client for the PacSpace API.
|
|
23
|
+
* Handles authentication, response unwrapping, retries, and error mapping.
|
|
24
|
+
*
|
|
25
|
+
* @internal — Use the PacSpace class instead of this directly.
|
|
26
|
+
*/
|
|
27
|
+
class HttpClient {
|
|
28
|
+
constructor(config) {
|
|
29
|
+
if (!config.apiKey) {
|
|
30
|
+
throw new errors_1.PacSpaceError('API key is required. Pass it via new PacSpace({ apiKey: "pk_..." })', 0, 'MISSING_API_KEY');
|
|
31
|
+
}
|
|
32
|
+
this.apiKey = config.apiKey;
|
|
33
|
+
this.baseUrl = (config.baseUrl || DEFAULT_BASE_URL).replace(/\/+$/, '');
|
|
34
|
+
this.maxRetries = config.maxRetries ?? DEFAULT_MAX_RETRIES;
|
|
35
|
+
this.timeout = config.timeout ?? DEFAULT_TIMEOUT_MS;
|
|
36
|
+
this.fetchFn = config.fetch || globalThis.fetch;
|
|
37
|
+
// Auto-detect chain ID from API key prefix
|
|
38
|
+
this.defaultChainId = config.chainId ?? this.detectChainId(config.apiKey);
|
|
39
|
+
this.defaultCreditPoolId = config.creditPoolId;
|
|
40
|
+
if (!this.fetchFn) {
|
|
41
|
+
throw new errors_1.PacSpaceError('No global fetch found. Upgrade to Node 18+ or pass a custom fetch implementation via config.', 0, 'NO_FETCH');
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Make a GET request and return unwrapped data.
|
|
46
|
+
*/
|
|
47
|
+
async get(path, options) {
|
|
48
|
+
return this.request('GET', path, undefined, options);
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Make a POST request and return unwrapped data.
|
|
52
|
+
*/
|
|
53
|
+
async post(path, body, options) {
|
|
54
|
+
return this.request('POST', path, body, options);
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Core request method with retry logic, auth injection, and response unwrapping.
|
|
58
|
+
*/
|
|
59
|
+
async request(method, path, body, options) {
|
|
60
|
+
const url = `${this.baseUrl}${path}`;
|
|
61
|
+
const headers = this.buildHeaders(options);
|
|
62
|
+
const requestInit = {
|
|
63
|
+
method,
|
|
64
|
+
headers,
|
|
65
|
+
signal: options?.signal,
|
|
66
|
+
};
|
|
67
|
+
if (body !== undefined) {
|
|
68
|
+
requestInit.body = JSON.stringify(body);
|
|
69
|
+
}
|
|
70
|
+
let lastError;
|
|
71
|
+
for (let attempt = 0; attempt <= this.maxRetries; attempt++) {
|
|
72
|
+
// Wait before retrying (exponential backoff)
|
|
73
|
+
if (attempt > 0) {
|
|
74
|
+
const delayMs = this.getRetryDelay(attempt, lastError);
|
|
75
|
+
await this.sleep(delayMs);
|
|
76
|
+
}
|
|
77
|
+
let response;
|
|
78
|
+
try {
|
|
79
|
+
response = await this.fetchWithTimeout(url, requestInit);
|
|
80
|
+
}
|
|
81
|
+
catch (err) {
|
|
82
|
+
// Network errors are retryable
|
|
83
|
+
lastError =
|
|
84
|
+
err instanceof Error
|
|
85
|
+
? err
|
|
86
|
+
: new Error(String(err));
|
|
87
|
+
if (attempt < this.maxRetries) {
|
|
88
|
+
continue;
|
|
89
|
+
}
|
|
90
|
+
throw new errors_1.PacSpaceError(`Network error: ${lastError.message}`, 0, 'NETWORK_ERROR', path);
|
|
91
|
+
}
|
|
92
|
+
// Successful response — parse and unwrap
|
|
93
|
+
if (response.ok) {
|
|
94
|
+
const raw = (await response.json());
|
|
95
|
+
if (raw.success && raw.data !== undefined) {
|
|
96
|
+
return raw.data;
|
|
97
|
+
}
|
|
98
|
+
// success: false in a 2xx response (shouldn't happen, but handle it)
|
|
99
|
+
throw (0, errors_1.mapApiError)(response.status, raw.error || raw.message || 'Unknown error', path, response.headers);
|
|
100
|
+
}
|
|
101
|
+
// Non-retryable error — throw immediately
|
|
102
|
+
if (!RETRYABLE_STATUS_CODES.has(response.status)) {
|
|
103
|
+
const errorBody = await this.safeParseJson(response);
|
|
104
|
+
const message = this.extractErrorMessage(errorBody, response.statusText);
|
|
105
|
+
throw (0, errors_1.mapApiError)(response.status, message, path, response.headers);
|
|
106
|
+
}
|
|
107
|
+
// Retryable error — continue to next attempt
|
|
108
|
+
const errorBody = await this.safeParseJson(response);
|
|
109
|
+
lastError = (0, errors_1.mapApiError)(response.status, this.extractErrorMessage(errorBody, response.statusText), path, response.headers);
|
|
110
|
+
}
|
|
111
|
+
// All retries exhausted
|
|
112
|
+
throw lastError || new errors_1.PacSpaceError('Request failed', 0, 'UNKNOWN', path);
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Build HTTP headers with auth and optional overrides.
|
|
116
|
+
*/
|
|
117
|
+
buildHeaders(options) {
|
|
118
|
+
const headers = {
|
|
119
|
+
'X-Api-Key': this.apiKey,
|
|
120
|
+
'Content-Type': 'application/json',
|
|
121
|
+
'User-Agent': '@pacspace-io/sdk/0.1.0',
|
|
122
|
+
};
|
|
123
|
+
const chainId = options?.chainId ?? this.defaultChainId;
|
|
124
|
+
if (chainId !== undefined) {
|
|
125
|
+
headers['X-Chain-Id'] = String(chainId);
|
|
126
|
+
}
|
|
127
|
+
const creditPoolId = options?.creditPoolId ?? this.defaultCreditPoolId;
|
|
128
|
+
if (creditPoolId !== undefined) {
|
|
129
|
+
headers['X-Credit-Pool-Id'] = String(creditPoolId);
|
|
130
|
+
}
|
|
131
|
+
if (options?.idempotencyKey) {
|
|
132
|
+
headers['Idempotency-Key'] = options.idempotencyKey;
|
|
133
|
+
}
|
|
134
|
+
return headers;
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Fetch with an AbortController-based timeout.
|
|
138
|
+
*/
|
|
139
|
+
async fetchWithTimeout(url, init) {
|
|
140
|
+
const controller = new AbortController();
|
|
141
|
+
const timeoutId = setTimeout(() => controller.abort(), this.timeout);
|
|
142
|
+
// Merge external signal with timeout signal
|
|
143
|
+
const externalSignal = init.signal;
|
|
144
|
+
if (externalSignal) {
|
|
145
|
+
externalSignal.addEventListener('abort', () => controller.abort());
|
|
146
|
+
}
|
|
147
|
+
try {
|
|
148
|
+
return await this.fetchFn(url, {
|
|
149
|
+
...init,
|
|
150
|
+
signal: controller.signal,
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
catch (err) {
|
|
154
|
+
if (err instanceof DOMException && err.name === 'AbortError') {
|
|
155
|
+
if (externalSignal?.aborted) {
|
|
156
|
+
throw new errors_1.PacSpaceError('Request cancelled', 0, 'CANCELLED', url);
|
|
157
|
+
}
|
|
158
|
+
throw new errors_1.PacSpaceError(`Request timed out after ${this.timeout}ms`, 0, 'TIMEOUT', url);
|
|
159
|
+
}
|
|
160
|
+
throw err;
|
|
161
|
+
}
|
|
162
|
+
finally {
|
|
163
|
+
clearTimeout(timeoutId);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Calculate retry delay with exponential backoff.
|
|
168
|
+
* Respects Retry-After header for rate limit errors.
|
|
169
|
+
*/
|
|
170
|
+
getRetryDelay(attempt, lastError) {
|
|
171
|
+
// Respect rate limit retry-after
|
|
172
|
+
if (lastError instanceof errors_1.RateLimitError && lastError.retryAfter) {
|
|
173
|
+
return lastError.retryAfter * 1000;
|
|
174
|
+
}
|
|
175
|
+
// Exponential backoff: 500ms, 1500ms, 3500ms, ...
|
|
176
|
+
const baseDelay = 500;
|
|
177
|
+
const delay = baseDelay * Math.pow(2, attempt - 1);
|
|
178
|
+
// Add jitter (0–25% of delay)
|
|
179
|
+
const jitter = delay * 0.25 * Math.random();
|
|
180
|
+
return delay + jitter;
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* Safely parse JSON from a response, returning null on failure.
|
|
184
|
+
*/
|
|
185
|
+
async safeParseJson(response) {
|
|
186
|
+
try {
|
|
187
|
+
return (await response.json());
|
|
188
|
+
}
|
|
189
|
+
catch {
|
|
190
|
+
return null;
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* Extract a string error message from a parsed error body.
|
|
195
|
+
*/
|
|
196
|
+
extractErrorMessage(errorBody, fallback) {
|
|
197
|
+
if (!errorBody)
|
|
198
|
+
return fallback;
|
|
199
|
+
if (typeof errorBody.error === 'string')
|
|
200
|
+
return errorBody.error;
|
|
201
|
+
if (typeof errorBody.message === 'string')
|
|
202
|
+
return errorBody.message;
|
|
203
|
+
return fallback;
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* Auto-detect chain ID from API key prefix.
|
|
207
|
+
*/
|
|
208
|
+
detectChainId(apiKey) {
|
|
209
|
+
if (apiKey.startsWith('pk_test_')) {
|
|
210
|
+
return 296; // Hedera Testnet
|
|
211
|
+
}
|
|
212
|
+
if (apiKey.startsWith('pk_live_')) {
|
|
213
|
+
return 295; // Hedera Mainnet
|
|
214
|
+
}
|
|
215
|
+
return undefined;
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* Promise-based sleep utility.
|
|
219
|
+
*/
|
|
220
|
+
sleep(ms) {
|
|
221
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
exports.HttpClient = HttpClient;
|
|
225
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":";;;AAEA,qCAAsE;AAEtE;;GAEG;AACH,MAAM,gBAAgB,GAAG,iCAAiC,CAAC;AAE3D;;GAEG;AACH,MAAM,kBAAkB,GAAG,KAAM,CAAC;AAElC;;GAEG;AACH,MAAM,mBAAmB,GAAG,CAAC,CAAC;AAE9B;;GAEG;AACH,MAAM,sBAAsB,GAAG,IAAI,GAAG,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC;AAEvE;;;;;GAKG;AACH,MAAa,UAAU;IAYrB,YAAY,MAAsB;QAChC,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC;YACnB,MAAM,IAAI,sBAAa,CACrB,qEAAqE,EACrE,CAAC,EACD,iBAAiB,CAClB,CAAC;QACJ,CAAC;QAED,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC;QAC5B,IAAI,CAAC,OAAO,GAAG,CAAC,MAAM,CAA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AChE,IAAI,OAAO,SAAS,CAAC,OAAO,KAAK,QAAQ;YAAE,OAAO,SAAS,CAAC,OAAO,CAAC;QACpE,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED;;OAEG;IACK,aAAa,CAAC,MAAc;QAClC,IAAI,MAAM,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC;YAClC,OAAO,GAAG,CAAC,CAAC,iBAAiB;QAC/B,CAAC;QACD,IAAI,MAAM,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC;YAClC,OAAO,GAAG,CAAC,CAAC,iBAAiB;QAC/B,CAAC;QACD,OAAO,SAAS,CAAC;IACnB,CAAC;IAED;;OAEG;IACK,KAAK,CAAC,EAAU;QACtB,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC;IAC3D,CAAC;CACF;AAtRD,gCAsRC"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Base error class for all PacSpace SDK errors.
|
|
3
|
+
* Extends native Error with structured API error data.
|
|
4
|
+
*/
|
|
5
|
+
export declare class PacSpaceError extends Error {
|
|
6
|
+
/** HTTP status code from the API response. */
|
|
7
|
+
readonly statusCode: number;
|
|
8
|
+
/** Machine-readable error code (e.g., 'INSUFFICIENT_CREDITS'). */
|
|
9
|
+
readonly code: string;
|
|
10
|
+
/** The original API request path that triggered this error. */
|
|
11
|
+
readonly requestPath?: string;
|
|
12
|
+
constructor(message: string, statusCode: number, code: string, requestPath?: string);
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Thrown when the API key is missing, invalid, or disabled (HTTP 401).
|
|
16
|
+
*/
|
|
17
|
+
export declare class InvalidApiKeyError extends PacSpaceError {
|
|
18
|
+
constructor(message?: string, requestPath?: string);
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Thrown when the tenant has insufficient credits for the operation (HTTP 402).
|
|
22
|
+
*/
|
|
23
|
+
export declare class InsufficientCreditsError extends PacSpaceError {
|
|
24
|
+
constructor(message?: string, requestPath?: string);
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Thrown when the requested resource is not found (HTTP 404).
|
|
28
|
+
*/
|
|
29
|
+
export declare class NotFoundError extends PacSpaceError {
|
|
30
|
+
constructor(message?: string, requestPath?: string);
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Thrown when no contract is deployed for the tenant (HTTP 412).
|
|
34
|
+
*/
|
|
35
|
+
export declare class ContractNotDeployedError extends PacSpaceError {
|
|
36
|
+
constructor(message?: string, requestPath?: string);
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Thrown when the API rate limit is exceeded (HTTP 429).
|
|
40
|
+
*/
|
|
41
|
+
export declare class RateLimitError extends PacSpaceError {
|
|
42
|
+
/** Seconds to wait before retrying, if provided by the API. */
|
|
43
|
+
readonly retryAfter: number | null;
|
|
44
|
+
constructor(message?: string, retryAfter?: number | null, requestPath?: string);
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Thrown when the API returns a validation error (HTTP 400).
|
|
48
|
+
*/
|
|
49
|
+
export declare class ValidationError extends PacSpaceError {
|
|
50
|
+
constructor(message?: string, requestPath?: string);
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Thrown when a polling operation exceeds the configured timeout.
|
|
54
|
+
*/
|
|
55
|
+
export declare class TimeoutError extends PacSpaceError {
|
|
56
|
+
constructor(message?: string, requestPath?: string);
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Thrown when the webhook signature is invalid.
|
|
60
|
+
*/
|
|
61
|
+
export declare class WebhookVerificationError extends PacSpaceError {
|
|
62
|
+
constructor(message?: string);
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Map an HTTP status code + API response to the appropriate typed error.
|
|
66
|
+
* @internal
|
|
67
|
+
*/
|
|
68
|
+
export declare function mapApiError(statusCode: number, message: string, requestPath?: string, headers?: Headers): PacSpaceError;
|
|
69
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/errors/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,qBAAa,aAAc,SAAQ,KAAK;IACtC,8CAA8C;IAC9C,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,kEAAkE;IAClE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,+DAA+D;IAC/D,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;gBAG5B,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,MAAM,EAClB,IAAI,EAAE,MAAM,EACZ,WAAW,CAAC,EAAE,MAAM;CAWvB;AAED;;GAEG;AACH,qBAAa,kBAAmB,SAAQ,aAAa;gBACvC,OAAO,SAA+B,EAAE,WAAW,CAAC,EAAE,MAAM;CAIzE;AAED;;GAEG;AACH,qBAAa,wBAAyB,SAAQ,aAAa;gBAEvD,OAAO,SAA4C,EACnD,WAAW,CAAC,EAAE,MAAM;CAKvB;AAED;;GAEG;AACH,qBAAa,aAAc,SAAQ,aAAa;gBAClC,OAAO,SAAuB,EAAE,WAAW,CAAC,EAAE,MAAM;CAIjE;AAED;;GAEG;AACH,qBAAa,wBAAyB,SAAQ,aAAa;gBAEvD,OAAO,SAA0D,EACjE,WAAW,CAAC,EAAE,MAAM;CAKvB;AAED;;GAEG;AACH,qBAAa,cAAe,SAAQ,aAAa;IAC/C,+DAA+D;IAC/D,QAAQ,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;gBAGjC,OAAO,SAAwB,EAC/B,UAAU,GAAE,MAAM,GAAG,IAAW,EAChC,WAAW,CAAC,EAAE,MAAM;CAMvB;AAED;;GAEG;AACH,qBAAa,eAAgB,SAAQ,aAAa;gBACpC,OAAO,SAAyB,EAAE,WAAW,C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