cspr402 0.4.7
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/LICENSE +21 -0
- package/README.md +173 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +108 -0
- package/dist/cli.js.map +1 -0
- package/dist/client.d.ts +207 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +400 -0
- package/dist/client.js.map +1 -0
- package/dist/commands/onboard.d.ts +4 -0
- package/dist/commands/onboard.d.ts.map +1 -0
- package/dist/commands/onboard.js +192 -0
- package/dist/commands/onboard.js.map +1 -0
- package/dist/commands/onboard.test.d.ts +2 -0
- package/dist/commands/onboard.test.d.ts.map +1 -0
- package/dist/commands/onboard.test.js +48 -0
- package/dist/commands/onboard.test.js.map +1 -0
- package/dist/commands/purchase.d.ts +2 -0
- package/dist/commands/purchase.d.ts.map +1 -0
- package/dist/commands/purchase.js +206 -0
- package/dist/commands/purchase.js.map +1 -0
- package/dist/commands/wallet.d.ts +2 -0
- package/dist/commands/wallet.d.ts.map +1 -0
- package/dist/commands/wallet.js +161 -0
- package/dist/commands/wallet.js.map +1 -0
- package/dist/config.d.ts +77 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +329 -0
- package/dist/config.js.map +1 -0
- package/dist/errors.d.ts +101 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +197 -0
- package/dist/errors.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +22 -0
- package/dist/index.js.map +1 -0
- package/dist/mcp.d.ts +2 -0
- package/dist/mcp.d.ts.map +1 -0
- package/dist/mcp.js +337 -0
- package/dist/mcp.js.map +1 -0
- package/dist/mpp.d.ts +57 -0
- package/dist/mpp.d.ts.map +1 -0
- package/dist/mpp.js +165 -0
- package/dist/mpp.js.map +1 -0
- package/dist/ows.d.ts +190 -0
- package/dist/ows.d.ts.map +1 -0
- package/dist/ows.js +565 -0
- package/dist/ows.js.map +1 -0
- package/dist/soroban.d.ts +92 -0
- package/dist/soroban.d.ts.map +1 -0
- package/dist/soroban.js +313 -0
- package/dist/soroban.js.map +1 -0
- package/dist/stellar.d.ts +53 -0
- package/dist/stellar.d.ts.map +1 -0
- package/dist/stellar.js +180 -0
- package/dist/stellar.js.map +1 -0
- package/dist/version-check.d.ts +5 -0
- package/dist/version-check.d.ts.map +1 -0
- package/dist/version-check.js +203 -0
- package/dist/version-check.js.map +1 -0
- package/package.json +80 -0
package/dist/client.js
ADDED
|
@@ -0,0 +1,400 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CSPR402Client = exports.Cards402Client = exports.ResumableError = exports.WaitTimeoutError = exports.OrderFailedError = exports.AuthError = exports.InvalidAmountError = exports.PriceUnavailableError = exports.ServiceUnavailableError = exports.RateLimitError = exports.SpendLimitError = exports.Cards402Error = void 0;
|
|
4
|
+
var errors_1 = require("./errors");
|
|
5
|
+
Object.defineProperty(exports, "Cards402Error", { enumerable: true, get: function () { return errors_1.Cards402Error; } });
|
|
6
|
+
Object.defineProperty(exports, "SpendLimitError", { enumerable: true, get: function () { return errors_1.SpendLimitError; } });
|
|
7
|
+
Object.defineProperty(exports, "RateLimitError", { enumerable: true, get: function () { return errors_1.RateLimitError; } });
|
|
8
|
+
Object.defineProperty(exports, "ServiceUnavailableError", { enumerable: true, get: function () { return errors_1.ServiceUnavailableError; } });
|
|
9
|
+
Object.defineProperty(exports, "PriceUnavailableError", { enumerable: true, get: function () { return errors_1.PriceUnavailableError; } });
|
|
10
|
+
Object.defineProperty(exports, "InvalidAmountError", { enumerable: true, get: function () { return errors_1.InvalidAmountError; } });
|
|
11
|
+
Object.defineProperty(exports, "AuthError", { enumerable: true, get: function () { return errors_1.AuthError; } });
|
|
12
|
+
Object.defineProperty(exports, "OrderFailedError", { enumerable: true, get: function () { return errors_1.OrderFailedError; } });
|
|
13
|
+
Object.defineProperty(exports, "WaitTimeoutError", { enumerable: true, get: function () { return errors_1.WaitTimeoutError; } });
|
|
14
|
+
Object.defineProperty(exports, "ResumableError", { enumerable: true, get: function () { return errors_1.ResumableError; } });
|
|
15
|
+
const errors_2 = require("./errors");
|
|
16
|
+
// Shared order-ID shape validator. Keeps the client, the MCP tool,
|
|
17
|
+
// and anything else that stamps an order id into a URL in lockstep.
|
|
18
|
+
// The backend mints UUIDv4 but we allow any 1–64 char alphanumeric +
|
|
19
|
+
// `_` + `-` string so hand-crafted test ids still work.
|
|
20
|
+
const ORDER_ID_PATTERN = /^[a-zA-Z0-9_-]{1,64}$/;
|
|
21
|
+
function validateOrderId(orderId) {
|
|
22
|
+
if (typeof orderId !== 'string' || !ORDER_ID_PATTERN.test(orderId)) {
|
|
23
|
+
throw new errors_2.Cards402Error(`Invalid order id: ${String(orderId).slice(0, 32)}`, 'invalid_order_id', 400);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
class Cards402Client {
|
|
27
|
+
baseUrl;
|
|
28
|
+
apiKey;
|
|
29
|
+
retry;
|
|
30
|
+
constructor({ baseUrl, apiKey, retry = {}, } = {}) {
|
|
31
|
+
// Resolve api key + base URL in priority order:
|
|
32
|
+
// 1. Explicit constructor args
|
|
33
|
+
// 2. CARDS402_API_KEY / CARDS402_BASE_URL env vars
|
|
34
|
+
// 3. ~/.cards402/config.json (written by `cards402 onboard`)
|
|
35
|
+
// This lets agents that went through the claim-code onboarding
|
|
36
|
+
// flow just do `new Cards402Client()` without passing anything.
|
|
37
|
+
//
|
|
38
|
+
// Use a synchronous require of ./config so the auto-load path
|
|
39
|
+
// doesn't force callers into an async constructor.
|
|
40
|
+
let resolvedKey = apiKey;
|
|
41
|
+
let resolvedBase = baseUrl;
|
|
42
|
+
if (!resolvedKey || !resolvedBase) {
|
|
43
|
+
try {
|
|
44
|
+
// Synchronous require avoids forcing the constructor to be async.
|
|
45
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
46
|
+
const config = require('./config');
|
|
47
|
+
const resolved = config.resolveCredentials({ apiKey: resolvedKey, baseUrl: resolvedBase });
|
|
48
|
+
if (!resolvedKey)
|
|
49
|
+
resolvedKey = resolved.apiKey;
|
|
50
|
+
if (!resolvedBase)
|
|
51
|
+
resolvedBase = resolved.baseUrl;
|
|
52
|
+
}
|
|
53
|
+
catch {
|
|
54
|
+
/* config helper unavailable (e.g. in a browser bundle) — fall through */
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
if (!resolvedKey || !resolvedKey.trim())
|
|
58
|
+
throw new errors_2.AuthError();
|
|
59
|
+
// F1-client-constructor (2026-04-16): validate baseUrl unconditionally.
|
|
60
|
+
// Pre-fix, assertSafeBaseUrl only ran inside resolveCredentials —
|
|
61
|
+
// which is skipped entirely when both apiKey and baseUrl are passed
|
|
62
|
+
// explicitly (the common case for MCP, CLI purchase, and OWS callers).
|
|
63
|
+
// An http:// or ftp:// URL would be used as-is, sending the agent's
|
|
64
|
+
// API key over plaintext. Now every code path is covered.
|
|
65
|
+
const finalBase = resolvedBase || 'https://api.cspr402.xyz/v1';
|
|
66
|
+
try {
|
|
67
|
+
// Lazy-require to avoid circular deps in the browser-bundle path
|
|
68
|
+
// where config.ts isn't available. If assertSafeBaseUrl isn't
|
|
69
|
+
// loadable (browser, bundler that tree-shook config.ts), fall
|
|
70
|
+
// through to the bare URL — the same behaviour as before the fix,
|
|
71
|
+
// which is correct for environments without a filesystem.
|
|
72
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
73
|
+
const { assertSafeBaseUrl } = require('./config');
|
|
74
|
+
assertSafeBaseUrl(finalBase, { context: 'Cards402Client constructor' });
|
|
75
|
+
}
|
|
76
|
+
catch (err) {
|
|
77
|
+
// Re-throw URL-safety rejections (non-HTTPS, userinfo, etc.)
|
|
78
|
+
// but swallow "module not found" errors from environments where
|
|
79
|
+
// config.ts isn't bundled.
|
|
80
|
+
if (err instanceof Error && !err.message.includes('Cannot find module')) {
|
|
81
|
+
throw err;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
this.baseUrl = finalBase.replace(/\/$/, '');
|
|
85
|
+
this.apiKey = resolvedKey;
|
|
86
|
+
// Audit A-23: default to retry on transient errors so every agent doesn't
|
|
87
|
+
// reimplement its own backoff loop. 2 retries with 500ms base + 5s cap
|
|
88
|
+
// covers brief network blips without punishing a persistent outage.
|
|
89
|
+
this.retry = {
|
|
90
|
+
attempts: retry.attempts ?? 2,
|
|
91
|
+
baseDelayMs: retry.baseDelayMs ?? 500,
|
|
92
|
+
maxDelayMs: retry.maxDelayMs ?? 5000,
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
async handleError(res) {
|
|
96
|
+
const body = (await res.json().catch(() => ({})));
|
|
97
|
+
throw (0, errors_2.parseApiError)(res.status, body);
|
|
98
|
+
}
|
|
99
|
+
// Retry only on transient/network errors. Non-idempotent 2xx-class errors
|
|
100
|
+
// (validation, auth, policy) are NOT retried because they're not transient.
|
|
101
|
+
// createOrder is special-cased: it passes an Idempotency-Key so retries are
|
|
102
|
+
// safe for 5xx and network errors only.
|
|
103
|
+
shouldRetry(status) {
|
|
104
|
+
return status === 429 || status === 503 || status === 504 || status === 502 || status === 0;
|
|
105
|
+
}
|
|
106
|
+
async fetchWithRetry(url, init) {
|
|
107
|
+
const { attempts, baseDelayMs, maxDelayMs } = this.retry;
|
|
108
|
+
let lastErr;
|
|
109
|
+
for (let i = 0; i <= attempts; i++) {
|
|
110
|
+
try {
|
|
111
|
+
const res = await fetch(url, init);
|
|
112
|
+
if (res.ok || !this.shouldRetry(res.status) || i === attempts)
|
|
113
|
+
return res;
|
|
114
|
+
lastErr = new Error(`HTTP ${res.status}`);
|
|
115
|
+
}
|
|
116
|
+
catch (err) {
|
|
117
|
+
lastErr = err;
|
|
118
|
+
if (i === attempts)
|
|
119
|
+
throw err;
|
|
120
|
+
}
|
|
121
|
+
// F3-sdk (2026-04-16): full-range jitter. Pre-fix the jitter was
|
|
122
|
+
// [0, delay/4] (always additive), so in a thundering-herd scenario
|
|
123
|
+
// (many agents 429'd simultaneously) they all retried within
|
|
124
|
+
// [delay, 1.25*delay] — too narrow to decorrelate. Standard "full
|
|
125
|
+
// jitter" is [0, delay], which spreads retries across the entire
|
|
126
|
+
// backoff window and avoids the herd re-colliding at each level.
|
|
127
|
+
const delay = Math.min(baseDelayMs * Math.pow(2, i), maxDelayMs);
|
|
128
|
+
const jitter = Math.floor(Math.random() * delay);
|
|
129
|
+
await new Promise((r) => setTimeout(r, jitter));
|
|
130
|
+
}
|
|
131
|
+
// Unreachable because we always either return or throw above.
|
|
132
|
+
throw lastErr ?? new Error('fetchWithRetry: exhausted without result');
|
|
133
|
+
}
|
|
134
|
+
async createOrder(opts) {
|
|
135
|
+
const { idempotencyKey: providedKey, ...body } = opts;
|
|
136
|
+
const idempotencyKey = providedKey ?? crypto.randomUUID();
|
|
137
|
+
// Safe to retry: the Idempotency-Key collapses duplicate creates on the
|
|
138
|
+
// backend, so replaying on a 5xx/timeout can't charge twice.
|
|
139
|
+
const res = await this.fetchWithRetry(`${this.baseUrl}/orders`, {
|
|
140
|
+
method: 'POST',
|
|
141
|
+
headers: {
|
|
142
|
+
'Content-Type': 'application/json',
|
|
143
|
+
'X-Api-Key': this.apiKey,
|
|
144
|
+
'Idempotency-Key': idempotencyKey,
|
|
145
|
+
},
|
|
146
|
+
body: JSON.stringify(body),
|
|
147
|
+
});
|
|
148
|
+
if (!res.ok)
|
|
149
|
+
return this.handleError(res);
|
|
150
|
+
return res.json();
|
|
151
|
+
}
|
|
152
|
+
async getOrder(orderId) {
|
|
153
|
+
// Validate and encode — path param must be a UUID-shaped identifier.
|
|
154
|
+
// The server also validates, but failing here avoids a round-trip
|
|
155
|
+
// on typos and eliminates a path-traversal surface on misuse.
|
|
156
|
+
validateOrderId(orderId);
|
|
157
|
+
const res = await this.fetchWithRetry(`${this.baseUrl}/orders/${encodeURIComponent(orderId)}`, {
|
|
158
|
+
headers: { 'X-Api-Key': this.apiKey },
|
|
159
|
+
});
|
|
160
|
+
if (!res.ok)
|
|
161
|
+
return this.handleError(res);
|
|
162
|
+
return res.json();
|
|
163
|
+
}
|
|
164
|
+
async verifyCasperPayment(orderId, deployHash, opts = {}) {
|
|
165
|
+
validateOrderId(orderId);
|
|
166
|
+
if (!/^[0-9a-fA-F]{64}$/.test(deployHash)) {
|
|
167
|
+
throw new errors_2.Cards402Error('Invalid Casper deploy hash', 'invalid_deploy_hash', 400);
|
|
168
|
+
}
|
|
169
|
+
const res = await this.fetchWithRetry(`${this.baseUrl}/orders/${encodeURIComponent(orderId)}/verify-payment`, {
|
|
170
|
+
method: 'POST',
|
|
171
|
+
headers: {
|
|
172
|
+
'Content-Type': 'application/json',
|
|
173
|
+
'X-Api-Key': this.apiKey,
|
|
174
|
+
},
|
|
175
|
+
body: JSON.stringify({
|
|
176
|
+
deploy_hash: deployHash,
|
|
177
|
+
...(opts.senderPublicKey ? { sender_public_key: opts.senderPublicKey } : {}),
|
|
178
|
+
}),
|
|
179
|
+
});
|
|
180
|
+
if (!res.ok)
|
|
181
|
+
return this.handleError(res);
|
|
182
|
+
return res.json();
|
|
183
|
+
}
|
|
184
|
+
// Wait until the card is ready. Uses SSE (GET /orders/:id/stream) by
|
|
185
|
+
// default — one open connection pushed to as the phase changes — and
|
|
186
|
+
// falls back to HTTP polling if SSE fails for any reason (old backend,
|
|
187
|
+
// hostile middlebox stripping text/event-stream, etc.).
|
|
188
|
+
async waitForCard(orderId, { timeoutMs = 300000, intervalMs = 3000 } = {}) {
|
|
189
|
+
validateOrderId(orderId);
|
|
190
|
+
// Shared deadline so an SSE attempt that eats most of the budget
|
|
191
|
+
// can't also grant polling its own full timeoutMs. Pre-fix, a
|
|
192
|
+
// stream that aborted at t=timeoutMs fell through to a polling
|
|
193
|
+
// loop that ran for another full timeoutMs — total wait 2×
|
|
194
|
+
// requested. Now the polling fallback inherits whatever time is
|
|
195
|
+
// left and the total stays within timeoutMs ± a few ms.
|
|
196
|
+
const deadlineMs = Date.now() + timeoutMs;
|
|
197
|
+
try {
|
|
198
|
+
return await this.waitForCardStream(orderId, timeoutMs);
|
|
199
|
+
}
|
|
200
|
+
catch (err) {
|
|
201
|
+
// Typed order-lifecycle errors must propagate unchanged — the stream
|
|
202
|
+
// correctly reported a terminal failure / expiry / timeout.
|
|
203
|
+
if (err instanceof errors_2.OrderFailedError ||
|
|
204
|
+
err instanceof errors_2.WaitTimeoutError ||
|
|
205
|
+
err instanceof errors_2.Cards402Error) {
|
|
206
|
+
throw err;
|
|
207
|
+
}
|
|
208
|
+
// An AbortError from the timer firing means we hit the stream's
|
|
209
|
+
// own deadline — that's a WaitTimeoutError, not "fall back to
|
|
210
|
+
// polling". Only genuine transport failures fall through.
|
|
211
|
+
if (err instanceof Error && (err.name === 'AbortError' || err.message.includes('aborted'))) {
|
|
212
|
+
throw new errors_2.WaitTimeoutError(orderId, timeoutMs);
|
|
213
|
+
}
|
|
214
|
+
const remainingMs = Math.max(0, deadlineMs - Date.now());
|
|
215
|
+
if (remainingMs === 0)
|
|
216
|
+
throw new errors_2.WaitTimeoutError(orderId, timeoutMs);
|
|
217
|
+
return this.waitForCardPoll(orderId, remainingMs, intervalMs);
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
// SSE fast path.
|
|
221
|
+
async waitForCardStream(orderId, timeoutMs) {
|
|
222
|
+
const controller = new AbortController();
|
|
223
|
+
const timer = setTimeout(() => controller.abort(), timeoutMs);
|
|
224
|
+
try {
|
|
225
|
+
const res = await fetch(`${this.baseUrl}/orders/${orderId}/stream`, {
|
|
226
|
+
headers: { 'X-Api-Key': this.apiKey, Accept: 'text/event-stream' },
|
|
227
|
+
signal: controller.signal,
|
|
228
|
+
});
|
|
229
|
+
if (!res.ok) {
|
|
230
|
+
if (res.status === 404)
|
|
231
|
+
throw new errors_2.OrderFailedError(orderId, 'order_not_found', undefined);
|
|
232
|
+
if (res.status === 401)
|
|
233
|
+
throw new errors_2.AuthError();
|
|
234
|
+
// Fall back to polling on any other non-2xx.
|
|
235
|
+
throw new Error(`stream http ${res.status}`);
|
|
236
|
+
}
|
|
237
|
+
if (!res.body)
|
|
238
|
+
throw new Error('stream has no body');
|
|
239
|
+
const reader = res.body.getReader();
|
|
240
|
+
const decoder = new TextDecoder();
|
|
241
|
+
let buffer = '';
|
|
242
|
+
// F2-sdk (2026-04-16): cap the SSE buffer so a misbehaving server
|
|
243
|
+
// or MITM can't OOM the agent process by injecting a single
|
|
244
|
+
// multi-megabyte "event" between delimiters. 1 MB is generous for
|
|
245
|
+
// any realistic SSE payload (the backend sends <2 KB per phase
|
|
246
|
+
// change); anything larger is definitionally adversarial or corrupt.
|
|
247
|
+
const SSE_BUFFER_CAP = 1024 * 1024;
|
|
248
|
+
while (true) {
|
|
249
|
+
const { value, done } = await reader.read();
|
|
250
|
+
if (done)
|
|
251
|
+
break;
|
|
252
|
+
// F1-sdk (2026-04-16): normalize CRLF and bare CR to LF before
|
|
253
|
+
// accumulating into the buffer. The SSE spec (HTML Living
|
|
254
|
+
// Standard § EventSource) defines end-of-line as \r\n, \r, or
|
|
255
|
+
// \n. The backend sends \n, but a transparent HTTP proxy
|
|
256
|
+
// (nginx on Windows, some Cloudflare configs, corporate proxy
|
|
257
|
+
// appliances) can rewrite line endings to \r\n. Pre-fix, the
|
|
258
|
+
// parser split on '\n\n' only — a \r\n rewrite meant
|
|
259
|
+
// buffer.indexOf('\n\n') never matched and the buffer grew
|
|
260
|
+
// unbounded until OOM. Normalizing at ingestion fixes all
|
|
261
|
+
// three delimiter variants in one step.
|
|
262
|
+
const chunk = decoder
|
|
263
|
+
.decode(value, { stream: true })
|
|
264
|
+
.replace(/\r\n/g, '\n')
|
|
265
|
+
.replace(/\r/g, '\n');
|
|
266
|
+
buffer += chunk;
|
|
267
|
+
// F2-sdk: abort if the buffer exceeds the cap — drop the stream
|
|
268
|
+
// and fall through to the polling fallback (or re-throw as a
|
|
269
|
+
// generic error that waitForCard's catch handler routes to
|
|
270
|
+
// polling).
|
|
271
|
+
if (buffer.length > SSE_BUFFER_CAP) {
|
|
272
|
+
reader.cancel();
|
|
273
|
+
throw new Error('sse buffer exceeded 1 MB — aborting stream');
|
|
274
|
+
}
|
|
275
|
+
// Split on blank lines — each SSE event is terminated by \n\n.
|
|
276
|
+
let idx;
|
|
277
|
+
while ((idx = buffer.indexOf('\n\n')) !== -1) {
|
|
278
|
+
const raw = buffer.slice(0, idx);
|
|
279
|
+
buffer = buffer.slice(idx + 2);
|
|
280
|
+
const dataLine = raw.split('\n').find((line) => line.startsWith('data: '));
|
|
281
|
+
if (!dataLine)
|
|
282
|
+
continue;
|
|
283
|
+
const json = dataLine.slice(6);
|
|
284
|
+
let payload;
|
|
285
|
+
try {
|
|
286
|
+
payload = JSON.parse(json);
|
|
287
|
+
}
|
|
288
|
+
catch {
|
|
289
|
+
continue;
|
|
290
|
+
}
|
|
291
|
+
if (payload.phase === 'ready' && payload.card) {
|
|
292
|
+
return payload.card;
|
|
293
|
+
}
|
|
294
|
+
if (payload.phase === 'failed' ||
|
|
295
|
+
payload.phase === 'refunded' ||
|
|
296
|
+
payload.phase === 'rejected') {
|
|
297
|
+
throw new errors_2.OrderFailedError(orderId, payload.error ?? payload.phase, payload.refund);
|
|
298
|
+
}
|
|
299
|
+
if (payload.phase === 'expired') {
|
|
300
|
+
throw new errors_2.OrderFailedError(orderId, 'Payment window expired — no funds were taken', undefined);
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
// Stream ended without a terminal event — treat as timeout.
|
|
305
|
+
throw new errors_2.WaitTimeoutError(orderId, timeoutMs);
|
|
306
|
+
}
|
|
307
|
+
finally {
|
|
308
|
+
clearTimeout(timer);
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
// Legacy polling path — kept as the fallback so old backends still work.
|
|
312
|
+
async waitForCardPoll(orderId, timeoutMs, intervalMs) {
|
|
313
|
+
const deadline = Date.now() + timeoutMs;
|
|
314
|
+
while (Date.now() < deadline) {
|
|
315
|
+
const order = await this.getOrder(orderId);
|
|
316
|
+
if (order.phase === 'ready' && order.card)
|
|
317
|
+
return order.card;
|
|
318
|
+
if (order.phase === 'failed' || order.phase === 'refunded' || order.phase === 'rejected') {
|
|
319
|
+
throw new errors_2.OrderFailedError(orderId, order.error ?? order.phase, order.refund);
|
|
320
|
+
}
|
|
321
|
+
if (order.phase === 'expired') {
|
|
322
|
+
throw new errors_2.OrderFailedError(orderId, 'Payment window expired — no funds were taken', undefined);
|
|
323
|
+
}
|
|
324
|
+
await new Promise((r) => setTimeout(r, intervalMs));
|
|
325
|
+
}
|
|
326
|
+
throw new errors_2.WaitTimeoutError(orderId, timeoutMs);
|
|
327
|
+
}
|
|
328
|
+
// List this agent's recent orders — useful for resuming after a crash.
|
|
329
|
+
// Audit A-19: supports `since_created_at` / `since_updated_at` so agents
|
|
330
|
+
// can poll for delta without re-fetching the full history.
|
|
331
|
+
async listOrders({ status, limit = 20, offset, since_created_at, since_updated_at, } = {}) {
|
|
332
|
+
const params = new URLSearchParams();
|
|
333
|
+
if (status)
|
|
334
|
+
params.set('status', status);
|
|
335
|
+
if (limit)
|
|
336
|
+
params.set('limit', String(limit));
|
|
337
|
+
if (offset)
|
|
338
|
+
params.set('offset', String(offset));
|
|
339
|
+
if (since_created_at)
|
|
340
|
+
params.set('since_created_at', since_created_at);
|
|
341
|
+
if (since_updated_at)
|
|
342
|
+
params.set('since_updated_at', since_updated_at);
|
|
343
|
+
const qs = params.toString() ? `?${params}` : '';
|
|
344
|
+
const res = await this.fetchWithRetry(`${this.baseUrl}/orders${qs}`, {
|
|
345
|
+
headers: { 'X-Api-Key': this.apiKey },
|
|
346
|
+
});
|
|
347
|
+
if (!res.ok)
|
|
348
|
+
return this.handleError(res);
|
|
349
|
+
return res.json();
|
|
350
|
+
}
|
|
351
|
+
// Get the agent's own spend and budget summary — useful for reporting to owners.
|
|
352
|
+
async getUsage() {
|
|
353
|
+
const res = await this.fetchWithRetry(`${this.baseUrl}/usage`, {
|
|
354
|
+
headers: { 'X-Api-Key': this.apiKey },
|
|
355
|
+
});
|
|
356
|
+
if (!res.ok)
|
|
357
|
+
return this.handleError(res);
|
|
358
|
+
return res.json();
|
|
359
|
+
}
|
|
360
|
+
// Report a setup lifecycle transition to the backend. The owner's
|
|
361
|
+
// admin dashboard and the agent's own dashboard subscribe to these
|
|
362
|
+
// via SSE and show a live "onboarding state" pill, so operators can
|
|
363
|
+
// see at a glance which agents are setting up, which are awaiting
|
|
364
|
+
// deposits, and which are active.
|
|
365
|
+
//
|
|
366
|
+
// Valid states:
|
|
367
|
+
// 'initializing' — the agent is just starting setup
|
|
368
|
+
// 'awaiting_funding' — wallet created, waiting for on-chain deposit
|
|
369
|
+
//
|
|
370
|
+
// 'minted' (never contacted) and 'active' (first delivered order) are
|
|
371
|
+
// derived by the backend from activity, so you don't report those.
|
|
372
|
+
//
|
|
373
|
+
// Errors are swallowed: dashboard state is a best-effort signal, not
|
|
374
|
+
// something that should break the purchase flow if the endpoint is
|
|
375
|
+
// transiently unreachable.
|
|
376
|
+
async reportStatus(state, opts = {}) {
|
|
377
|
+
try {
|
|
378
|
+
await this.fetchWithRetry(`${this.baseUrl}/agent/status`, {
|
|
379
|
+
method: 'POST',
|
|
380
|
+
headers: {
|
|
381
|
+
'X-Api-Key': this.apiKey,
|
|
382
|
+
'Content-Type': 'application/json',
|
|
383
|
+
},
|
|
384
|
+
body: JSON.stringify({
|
|
385
|
+
state,
|
|
386
|
+
wallet_public_key: opts.wallet_public_key,
|
|
387
|
+
detail: opts.detail,
|
|
388
|
+
}),
|
|
389
|
+
});
|
|
390
|
+
}
|
|
391
|
+
catch {
|
|
392
|
+
/* best-effort; do not block the caller */
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
exports.Cards402Client = Cards402Client;
|
|
397
|
+
class CSPR402Client extends Cards402Client {
|
|
398
|
+
}
|
|
399
|
+
exports.CSPR402Client = CSPR402Client;
|
|
400
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":";;;AAAA,mCAWkB;AAVhB,uGAAA,aAAa,OAAA;AACb,yGAAA,eAAe,OAAA;AACf,wGAAA,cAAc,OAAA;AACd,iHAAA,uBAAuB,OAAA;AACvB,+GAAA,qBAAqB,OAAA;AACrB,4GAAA,kBAAkB,OAAA;AAClB,mGAAA,SAAS,OAAA;AACT,0GAAA,gBAAgB,OAAA;AAChB,0GAAA,gBAAgB,OAAA;AAChB,wGAAA,cAAc,OAAA;AAEhB,qCAMkB;AAmMlB,mEAAmE;AACnE,oEAAoE;AACpE,qEAAqE;AACrE,wDAAwD;AACxD,MAAM,gBAAgB,GAAG,uBAAuB,CAAC;AACjD,SAAS,eAAe,CAAC,OAAe;IACtC,IAAI,OAAO,OAAO,KAAK,QAAQ,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC;QACnE,MAAM,IAAI,sBAAiB,CACzB,qBAAqB,MAAM,CAAC,OAAO,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,EAAE,EACnD,kBAAkB,EAClB,GAAG,CACJ,CAAC;IACJ,CAAC;AACH,CAAC;AAED,MAAa,cAAc;IACjB,OAAO,CAAS;IAChB,MAAM,CAAS;IACf,KAAK,CAAyB;IAEtC,YAAY,EACV,OAAO,EACP,MAAM,EACN,KAAK,GAAG,EAAE,MAKR,EAAE;QACJ,gDAAgD;QAChD,iCAAiC;QACjC,qDAAqD;QACrD,+DAA+D;QAC/D,+DAA+D;QAC/D,gEAAgE;QAChE,EAAE;QACF,8DAA8D;QAC9D,mDAAmD;QACnD,IAAI,WAAW,GAAG,MAAM,CAAC;QACzB,IAAI,YAAY,GAAG,OAAO,CAAC;QAC3B,IAAI,CAAC,WAAW,IAAI,CAAC,YAAY,EAAE,CAA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AAkE;IAClE,mEAAmE;IACnE,oEAAoE;IACpE,kEAAkE;IAClE,kCAAkC;IAClC,EAAE;IACF,gBAAgB;IAChB,0DAA0D;IAC1D,sEAAsE;IACtE,EAAE;IACF,sEAAsE;IACtE,mEAAmE;IACnE,EAAE;IACF,qEAAqE;IACrE,mEAAmE;IACnE,2BAA2B;IAC3B,KAAK,CAAC,YAAY,CAChB,KAA0C,EAC1C,OAAwD,EAAE;QAE1D,IAAI,CAAC;YACH,MAAM,IAAI,CAAC,cAAc,CAAC,GAAG,IAAI,CAAC,OAAO,eAAe,EAAE;gBACxD,MAAM,EAAE,MAAM;gBACd,OAAO,EAAE;oBACP,WAAW,EAAE,IAAI,CAAC,MAAM;oBACxB,cAAc,EAAE,kBAAkB;iBACnC;gBACD,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC;oBACnB,KAAK;oBACL,iBAAiB,EAAE,IAAI,CAAC,iBAAiB;oBACzC,MAAM,EAAE,IAAI,CAAC,MAAM;iBACpB,CAAC;aACH,CAAC,CAAC;QACL,CAAC;QAAC,MAAM,CAAC;YACP,0CAA0C;QAC5C,CAAC;IACH,CAAC;CACF;AAraD,wCAqaC;AAED,MAAa,aAAc,SAAQ,cAAc;CAAG;AAApD,sCAAoD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"onboard.d.ts","sourceRoot":"","sources":["../../src/commands/onboard.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,uBAAuB,IAAI,wBAAwB,EAAE,CAAC;AAsE/D,iBAAS,uBAAuB,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM,CAU5E;AAyBD,wBAAsB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CA6GpE"}
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// `cspr402 onboard --claim <code>` - one-shot agent setup.
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports._deriveDefaultWalletName = deriveDefaultWalletName;
|
|
5
|
+
exports.onboardCommand = onboardCommand;
|
|
6
|
+
const config_1 = require("../config");
|
|
7
|
+
const client_1 = require("../client");
|
|
8
|
+
const CASPER_PUBLIC_KEY_RE = /^(01[0-9a-fA-F]{64}|02[0-9a-fA-F]{66})$/;
|
|
9
|
+
function parseArgs(argv) {
|
|
10
|
+
const out = {};
|
|
11
|
+
for (let i = 0; i < argv.length; i++) {
|
|
12
|
+
const arg = argv[i];
|
|
13
|
+
if (arg === undefined)
|
|
14
|
+
continue;
|
|
15
|
+
if (arg === '--help' || arg === '-h')
|
|
16
|
+
out.help = true;
|
|
17
|
+
else if (arg === '--claim')
|
|
18
|
+
out.claim = argv[++i];
|
|
19
|
+
else if (arg.startsWith('--claim='))
|
|
20
|
+
out.claim = arg.slice('--claim='.length);
|
|
21
|
+
else if (arg === '--agent-name')
|
|
22
|
+
out.agentName = argv[++i];
|
|
23
|
+
else if (arg.startsWith('--agent-name='))
|
|
24
|
+
out.agentName = arg.slice('--agent-name='.length);
|
|
25
|
+
else if (arg === '--wallet-name')
|
|
26
|
+
out.walletName = argv[++i];
|
|
27
|
+
else if (arg.startsWith('--wallet-name='))
|
|
28
|
+
out.walletName = arg.slice('--wallet-name='.length);
|
|
29
|
+
else if (arg === '--api-base')
|
|
30
|
+
out.apiBase = argv[++i];
|
|
31
|
+
else if (arg.startsWith('--api-base='))
|
|
32
|
+
out.apiBase = arg.slice('--api-base='.length);
|
|
33
|
+
else if (arg === '--casper-public-key' || arg === '--public-key')
|
|
34
|
+
out.casperPublicKey = argv[++i];
|
|
35
|
+
else if (arg.startsWith('--casper-public-key='))
|
|
36
|
+
out.casperPublicKey = arg.slice('--casper-public-key='.length);
|
|
37
|
+
else if (arg.startsWith('--public-key='))
|
|
38
|
+
out.casperPublicKey = arg.slice('--public-key='.length);
|
|
39
|
+
else if (arg === '--casper-key-path' || arg === '--key-path')
|
|
40
|
+
out.casperKeyPath = argv[++i];
|
|
41
|
+
else if (arg.startsWith('--casper-key-path='))
|
|
42
|
+
out.casperKeyPath = arg.slice('--casper-key-path='.length);
|
|
43
|
+
else if (arg.startsWith('--key-path='))
|
|
44
|
+
out.casperKeyPath = arg.slice('--key-path='.length);
|
|
45
|
+
}
|
|
46
|
+
return out;
|
|
47
|
+
}
|
|
48
|
+
function usage() {
|
|
49
|
+
process.stderr
|
|
50
|
+
.write(`Usage: cspr402 onboard --claim <code> [--casper-public-key <hex>] [--casper-key-path <path>] [--api-base <url>]
|
|
51
|
+
|
|
52
|
+
Exchanges a one-time claim code from the CSPR402 dashboard for an api key and
|
|
53
|
+
writes ~/.cspr402/config.json with 0600 permissions. The config can store a
|
|
54
|
+
Casper public key or a path to a local key file, but never stores private key
|
|
55
|
+
material directly.
|
|
56
|
+
|
|
57
|
+
Options:
|
|
58
|
+
--claim <code> One-time claim code from the dashboard. Required.
|
|
59
|
+
--casper-public-key <hex> Casper testnet public key for payer binding.
|
|
60
|
+
--casper-key-path <path> Local key-file path. Keep the file outside git.
|
|
61
|
+
--api-base <url> Override the default https://api.cspr402.xyz/v1
|
|
62
|
+
-h, --help Show this message
|
|
63
|
+
`);
|
|
64
|
+
}
|
|
65
|
+
function deriveDefaultWalletName(claim, label) {
|
|
66
|
+
const raw = claim.replace(/^(cspr402_claim_|c402_)/i, '');
|
|
67
|
+
const suffix = raw.slice(0, 8).toLowerCase();
|
|
68
|
+
const slug = (label ?? 'agent')
|
|
69
|
+
.toLowerCase()
|
|
70
|
+
.replace(/[^a-z0-9]+/g, '-')
|
|
71
|
+
.replace(/^-+|-+$/g, '')
|
|
72
|
+
.slice(0, 24) || 'agent';
|
|
73
|
+
return `cspr402-${slug}-${suffix}`;
|
|
74
|
+
}
|
|
75
|
+
function normalizeCasperPublicKey(value) {
|
|
76
|
+
const normalized = value?.trim().toLowerCase();
|
|
77
|
+
if (!normalized)
|
|
78
|
+
return undefined;
|
|
79
|
+
if (!CASPER_PUBLIC_KEY_RE.test(normalized)) {
|
|
80
|
+
throw new Error('Casper public key must be a valid public key hex string.');
|
|
81
|
+
}
|
|
82
|
+
return normalized;
|
|
83
|
+
}
|
|
84
|
+
async function redeemClaim(apiBase, claim) {
|
|
85
|
+
const claimUrl = new URL(`${apiBase.replace(/\/$/, '')}/agent/claim`);
|
|
86
|
+
const res = await fetch(claimUrl, {
|
|
87
|
+
method: 'POST',
|
|
88
|
+
headers: { 'Content-Type': 'application/json' },
|
|
89
|
+
body: JSON.stringify({ code: claim }),
|
|
90
|
+
});
|
|
91
|
+
const body = (await res.json().catch(() => ({})));
|
|
92
|
+
if (!res.ok) {
|
|
93
|
+
throw new Error(body.message || body.error || `claim failed with HTTP ${res.status}`);
|
|
94
|
+
}
|
|
95
|
+
return body;
|
|
96
|
+
}
|
|
97
|
+
async function onboardCommand(argv) {
|
|
98
|
+
const args = parseArgs(argv);
|
|
99
|
+
if (args.help) {
|
|
100
|
+
usage();
|
|
101
|
+
return 0;
|
|
102
|
+
}
|
|
103
|
+
if (!args.claim) {
|
|
104
|
+
process.stderr.write('error: --claim <code> is required\n\n');
|
|
105
|
+
usage();
|
|
106
|
+
return 2;
|
|
107
|
+
}
|
|
108
|
+
const claim = args.claim.trim();
|
|
109
|
+
if (!/^(cspr402_claim_|c402_)[a-f0-9]{16,}$/i.test(claim)) {
|
|
110
|
+
process.stderr.write(`error: '${claim.slice(0, 16)}...' does not look like a valid claim code.\n` +
|
|
111
|
+
'Expected format: cspr402_claim_<hex>.\n');
|
|
112
|
+
return 2;
|
|
113
|
+
}
|
|
114
|
+
let apiBase = args.apiBase ||
|
|
115
|
+
process.env.CSPR402_BASE_URL ||
|
|
116
|
+
process.env.CARDS402_BASE_URL ||
|
|
117
|
+
'https://api.cspr402.xyz/v1';
|
|
118
|
+
try {
|
|
119
|
+
apiBase = (0, config_1.assertSafeBaseUrl)(apiBase, { context: '--api-base / CSPR402_BASE_URL' });
|
|
120
|
+
}
|
|
121
|
+
catch (err) {
|
|
122
|
+
process.stderr.write(`error: ${err instanceof Error ? err.message : String(err)}\n`);
|
|
123
|
+
return 2;
|
|
124
|
+
}
|
|
125
|
+
let casperPublicKey;
|
|
126
|
+
try {
|
|
127
|
+
casperPublicKey = normalizeCasperPublicKey(args.casperPublicKey || process.env.CSPR402_CASPER_PUBLIC_KEY);
|
|
128
|
+
}
|
|
129
|
+
catch (err) {
|
|
130
|
+
process.stderr.write(`error: ${err instanceof Error ? err.message : String(err)}\n`);
|
|
131
|
+
return 2;
|
|
132
|
+
}
|
|
133
|
+
const casperKeyPath = args.casperKeyPath || process.env.CSPR402_CASPER_KEY_PATH;
|
|
134
|
+
const existing = (0, config_1.loadCards402Config)();
|
|
135
|
+
if (existing) {
|
|
136
|
+
process.stderr.write('An existing cspr402 config was found at ~/.cspr402/config.json; proceeding with the new claim.\n\n');
|
|
137
|
+
}
|
|
138
|
+
process.stdout.write('Redeeming CSPR402 claim...\n');
|
|
139
|
+
let claimResponse;
|
|
140
|
+
try {
|
|
141
|
+
claimResponse = await redeemClaim(apiBase, claim);
|
|
142
|
+
}
|
|
143
|
+
catch (err) {
|
|
144
|
+
process.stderr.write(`error: ${err instanceof Error ? err.message : String(err)}\n`);
|
|
145
|
+
return 1;
|
|
146
|
+
}
|
|
147
|
+
if (!claimResponse.api_key) {
|
|
148
|
+
process.stderr.write('error: claim response missing api_key.\n');
|
|
149
|
+
return 1;
|
|
150
|
+
}
|
|
151
|
+
const finalApiUrl = (0, config_1.assertSafeBaseUrl)(claimResponse.api_url || apiBase, {
|
|
152
|
+
context: 'claim response api_url',
|
|
153
|
+
});
|
|
154
|
+
const agentName = args.agentName ||
|
|
155
|
+
args.walletName ||
|
|
156
|
+
deriveDefaultWalletName(claim, claimResponse.label ?? null);
|
|
157
|
+
const { path: configPath } = (0, config_1.saveCards402Config)({
|
|
158
|
+
api_key: claimResponse.api_key,
|
|
159
|
+
api_url: finalApiUrl,
|
|
160
|
+
webhook_secret: claimResponse.webhook_secret ?? null,
|
|
161
|
+
wallet_name: agentName,
|
|
162
|
+
casper_public_key: casperPublicKey,
|
|
163
|
+
casper_key_path: casperKeyPath,
|
|
164
|
+
created_at: new Date().toISOString(),
|
|
165
|
+
});
|
|
166
|
+
const client = new client_1.CSPR402Client({ apiKey: claimResponse.api_key, baseUrl: finalApiUrl });
|
|
167
|
+
await client.reportStatus(casperPublicKey ? 'awaiting_funding' : 'initializing', {
|
|
168
|
+
wallet_public_key: casperPublicKey,
|
|
169
|
+
detail: casperPublicKey
|
|
170
|
+
? 'Casper public key configured'
|
|
171
|
+
: 'Claim redeemed; Casper public key not configured yet',
|
|
172
|
+
});
|
|
173
|
+
process.stdout.write('\n');
|
|
174
|
+
process.stdout.write('cspr402 agent ready\n');
|
|
175
|
+
process.stdout.write(` Label: ${claimResponse.label ?? '(none)'}\n`);
|
|
176
|
+
process.stdout.write(` Config: ${configPath}\n`);
|
|
177
|
+
process.stdout.write(` API base: ${finalApiUrl}\n`);
|
|
178
|
+
if (casperPublicKey)
|
|
179
|
+
process.stdout.write(` Casper key: ${casperPublicKey}\n`);
|
|
180
|
+
if (casperKeyPath)
|
|
181
|
+
process.stdout.write(` Key file path: ${casperKeyPath}\n`);
|
|
182
|
+
process.stdout.write('\n');
|
|
183
|
+
if (!casperPublicKey) {
|
|
184
|
+
process.stdout.write('Next step: set CSPR402_CASPER_PUBLIC_KEY or rerun with --casper-public-key.\n');
|
|
185
|
+
}
|
|
186
|
+
else {
|
|
187
|
+
process.stdout.write('Next step: fund that public key with Casper testnet CSPR for native transfers.\n');
|
|
188
|
+
}
|
|
189
|
+
process.stdout.write('Your operator sees setup progress live in the CSPR402 dashboard.\n');
|
|
190
|
+
return 0;
|
|
191
|
+
}
|
|
192
|
+
//# sourceMappingURL=onboard.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"onboard.js","sourceRoot":"","sources":["../../src/commands/onboard.ts"],"names":[],"mappings":";AAAA,2DAA2D;;AAK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