@paybox-sh/sdk 1.0.0 → 2.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 +56 -12
- package/SKILL.md +241 -235
- package/dist/{chunk-SMPW2GUM.js → chunk-OZ7KVOBT.js} +166 -30
- package/dist/chunk-OZ7KVOBT.js.map +1 -0
- package/dist/cli.js +760 -69
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +101 -6
- package/dist/index.js +3 -1
- package/package.json +2 -1
- package/dist/chunk-SMPW2GUM.js.map +0 -1
package/dist/cli.js
CHANGED
|
@@ -1,23 +1,690 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
PayboxClient,
|
|
4
|
-
agentClientId,
|
|
5
4
|
appBaseFrom,
|
|
6
5
|
configDir,
|
|
7
6
|
configFile,
|
|
8
7
|
didNotHappen,
|
|
8
|
+
encodeToken,
|
|
9
9
|
loadConfig,
|
|
10
10
|
loginDevice,
|
|
11
11
|
openBrowser,
|
|
12
|
+
pendingFundingResponse,
|
|
13
|
+
pendingFundingToolResponse,
|
|
14
|
+
refreshTokens,
|
|
12
15
|
saveConfig
|
|
13
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-OZ7KVOBT.js";
|
|
14
17
|
|
|
15
18
|
// src/cli.ts
|
|
16
19
|
import { spawnSync } from "node:child_process";
|
|
17
20
|
import { readFileSync, rmSync } from "node:fs";
|
|
18
21
|
import { createRequire } from "node:module";
|
|
19
|
-
import { createInterface } from "node:readline/promises";
|
|
20
22
|
import { Command } from "commander";
|
|
23
|
+
|
|
24
|
+
// src/pairing.ts
|
|
25
|
+
import nacl from "tweetnacl";
|
|
26
|
+
|
|
27
|
+
// node_modules/.pnpm/@noble+hashes@1.8.0/node_modules/@noble/hashes/esm/utils.js
|
|
28
|
+
function isBytes(a) {
|
|
29
|
+
return a instanceof Uint8Array || ArrayBuffer.isView(a) && a.constructor.name === "Uint8Array";
|
|
30
|
+
}
|
|
31
|
+
function abytes(b, ...lengths) {
|
|
32
|
+
if (!isBytes(b))
|
|
33
|
+
throw new Error("Uint8Array expected");
|
|
34
|
+
if (lengths.length > 0 && !lengths.includes(b.length))
|
|
35
|
+
throw new Error("Uint8Array expected of length " + lengths + ", got length=" + b.length);
|
|
36
|
+
}
|
|
37
|
+
function aexists(instance, checkFinished = true) {
|
|
38
|
+
if (instance.destroyed)
|
|
39
|
+
throw new Error("Hash instance has been destroyed");
|
|
40
|
+
if (checkFinished && instance.finished)
|
|
41
|
+
throw new Error("Hash#digest() has already been called");
|
|
42
|
+
}
|
|
43
|
+
function aoutput(out, instance) {
|
|
44
|
+
abytes(out);
|
|
45
|
+
const min = instance.outputLen;
|
|
46
|
+
if (out.length < min) {
|
|
47
|
+
throw new Error("digestInto() expects output buffer of length at least " + min);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
function clean(...arrays) {
|
|
51
|
+
for (let i = 0; i < arrays.length; i++) {
|
|
52
|
+
arrays[i].fill(0);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
function createView(arr) {
|
|
56
|
+
return new DataView(arr.buffer, arr.byteOffset, arr.byteLength);
|
|
57
|
+
}
|
|
58
|
+
function rotr(word, shift) {
|
|
59
|
+
return word << 32 - shift | word >>> shift;
|
|
60
|
+
}
|
|
61
|
+
function utf8ToBytes(str) {
|
|
62
|
+
if (typeof str !== "string")
|
|
63
|
+
throw new Error("string expected");
|
|
64
|
+
return new Uint8Array(new TextEncoder().encode(str));
|
|
65
|
+
}
|
|
66
|
+
function toBytes(data) {
|
|
67
|
+
if (typeof data === "string")
|
|
68
|
+
data = utf8ToBytes(data);
|
|
69
|
+
abytes(data);
|
|
70
|
+
return data;
|
|
71
|
+
}
|
|
72
|
+
var Hash = class {
|
|
73
|
+
};
|
|
74
|
+
function createHasher(hashCons) {
|
|
75
|
+
const hashC = (msg) => hashCons().update(toBytes(msg)).digest();
|
|
76
|
+
const tmp = hashCons();
|
|
77
|
+
hashC.outputLen = tmp.outputLen;
|
|
78
|
+
hashC.blockLen = tmp.blockLen;
|
|
79
|
+
hashC.create = () => hashCons();
|
|
80
|
+
return hashC;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// node_modules/.pnpm/@noble+hashes@1.8.0/node_modules/@noble/hashes/esm/_md.js
|
|
84
|
+
function setBigUint64(view, byteOffset, value, isLE) {
|
|
85
|
+
if (typeof view.setBigUint64 === "function")
|
|
86
|
+
return view.setBigUint64(byteOffset, value, isLE);
|
|
87
|
+
const _32n = BigInt(32);
|
|
88
|
+
const _u32_max = BigInt(4294967295);
|
|
89
|
+
const wh = Number(value >> _32n & _u32_max);
|
|
90
|
+
const wl = Number(value & _u32_max);
|
|
91
|
+
const h = isLE ? 4 : 0;
|
|
92
|
+
const l = isLE ? 0 : 4;
|
|
93
|
+
view.setUint32(byteOffset + h, wh, isLE);
|
|
94
|
+
view.setUint32(byteOffset + l, wl, isLE);
|
|
95
|
+
}
|
|
96
|
+
function Chi(a, b, c) {
|
|
97
|
+
return a & b ^ ~a & c;
|
|
98
|
+
}
|
|
99
|
+
function Maj(a, b, c) {
|
|
100
|
+
return a & b ^ a & c ^ b & c;
|
|
101
|
+
}
|
|
102
|
+
var HashMD = class extends Hash {
|
|
103
|
+
constructor(blockLen, outputLen, padOffset, isLE) {
|
|
104
|
+
super();
|
|
105
|
+
this.finished = false;
|
|
106
|
+
this.length = 0;
|
|
107
|
+
this.pos = 0;
|
|
108
|
+
this.destroyed = false;
|
|
109
|
+
this.blockLen = blockLen;
|
|
110
|
+
this.outputLen = outputLen;
|
|
111
|
+
this.padOffset = padOffset;
|
|
112
|
+
this.isLE = isLE;
|
|
113
|
+
this.buffer = new Uint8Array(blockLen);
|
|
114
|
+
this.view = createView(this.buffer);
|
|
115
|
+
}
|
|
116
|
+
update(data) {
|
|
117
|
+
aexists(this);
|
|
118
|
+
data = toBytes(data);
|
|
119
|
+
abytes(data);
|
|
120
|
+
const { view, buffer, blockLen } = this;
|
|
121
|
+
const len = data.length;
|
|
122
|
+
for (let pos = 0; pos < len; ) {
|
|
123
|
+
const take = Math.min(blockLen - this.pos, len - pos);
|
|
124
|
+
if (take === blockLen) {
|
|
125
|
+
const dataView = createView(data);
|
|
126
|
+
for (; blockLen <= len - pos; pos += blockLen)
|
|
127
|
+
this.process(dataView, pos);
|
|
128
|
+
continue;
|
|
129
|
+
}
|
|
130
|
+
buffer.set(data.subarray(pos, pos + take), this.pos);
|
|
131
|
+
this.pos += take;
|
|
132
|
+
pos += take;
|
|
133
|
+
if (this.pos === blockLen) {
|
|
134
|
+
this.process(view, 0);
|
|
135
|
+
this.pos = 0;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
this.length += data.length;
|
|
139
|
+
this.roundClean();
|
|
140
|
+
return this;
|
|
141
|
+
}
|
|
142
|
+
digestInto(out) {
|
|
143
|
+
aexists(this);
|
|
144
|
+
aoutput(out, this);
|
|
145
|
+
this.finished = true;
|
|
146
|
+
const { buffer, view, blockLen, isLE } = this;
|
|
147
|
+
let { pos } = this;
|
|
148
|
+
buffer[pos++] = 128;
|
|
149
|
+
clean(this.buffer.subarray(pos));
|
|
150
|
+
if (this.padOffset > blockLen - pos) {
|
|
151
|
+
this.process(view, 0);
|
|
152
|
+
pos = 0;
|
|
153
|
+
}
|
|
154
|
+
for (let i = pos; i < blockLen; i++)
|
|
155
|
+
buffer[i] = 0;
|
|
156
|
+
setBigUint64(view, blockLen - 8, BigInt(this.length * 8), isLE);
|
|
157
|
+
this.process(view, 0);
|
|
158
|
+
const oview = createView(out);
|
|
159
|
+
const len = this.outputLen;
|
|
160
|
+
if (len % 4)
|
|
161
|
+
throw new Error("_sha2: outputLen should be aligned to 32bit");
|
|
162
|
+
const outLen = len / 4;
|
|
163
|
+
const state = this.get();
|
|
164
|
+
if (outLen > state.length)
|
|
165
|
+
throw new Error("_sha2: outputLen bigger than state");
|
|
166
|
+
for (let i = 0; i < outLen; i++)
|
|
167
|
+
oview.setUint32(4 * i, state[i], isLE);
|
|
168
|
+
}
|
|
169
|
+
digest() {
|
|
170
|
+
const { buffer, outputLen } = this;
|
|
171
|
+
this.digestInto(buffer);
|
|
172
|
+
const res = buffer.slice(0, outputLen);
|
|
173
|
+
this.destroy();
|
|
174
|
+
return res;
|
|
175
|
+
}
|
|
176
|
+
_cloneInto(to) {
|
|
177
|
+
to || (to = new this.constructor());
|
|
178
|
+
to.set(...this.get());
|
|
179
|
+
const { blockLen, buffer, length, finished, destroyed, pos } = this;
|
|
180
|
+
to.destroyed = destroyed;
|
|
181
|
+
to.finished = finished;
|
|
182
|
+
to.length = length;
|
|
183
|
+
to.pos = pos;
|
|
184
|
+
if (length % blockLen)
|
|
185
|
+
to.buffer.set(buffer);
|
|
186
|
+
return to;
|
|
187
|
+
}
|
|
188
|
+
clone() {
|
|
189
|
+
return this._cloneInto();
|
|
190
|
+
}
|
|
191
|
+
};
|
|
192
|
+
var SHA256_IV = /* @__PURE__ */ Uint32Array.from([
|
|
193
|
+
1779033703,
|
|
194
|
+
3144134277,
|
|
195
|
+
1013904242,
|
|
196
|
+
2773480762,
|
|
197
|
+
1359893119,
|
|
198
|
+
2600822924,
|
|
199
|
+
528734635,
|
|
200
|
+
1541459225
|
|
201
|
+
]);
|
|
202
|
+
|
|
203
|
+
// node_modules/.pnpm/@noble+hashes@1.8.0/node_modules/@noble/hashes/esm/sha2.js
|
|
204
|
+
var SHA256_K = /* @__PURE__ */ Uint32Array.from([
|
|
205
|
+
1116352408,
|
|
206
|
+
1899447441,
|
|
207
|
+
3049323471,
|
|
208
|
+
3921009573,
|
|
209
|
+
961987163,
|
|
210
|
+
1508970993,
|
|
211
|
+
2453635748,
|
|
212
|
+
2870763221,
|
|
213
|
+
3624381080,
|
|
214
|
+
310598401,
|
|
215
|
+
607225278,
|
|
216
|
+
1426881987,
|
|
217
|
+
1925078388,
|
|
218
|
+
2162078206,
|
|
219
|
+
2614888103,
|
|
220
|
+
3248222580,
|
|
221
|
+
3835390401,
|
|
222
|
+
4022224774,
|
|
223
|
+
264347078,
|
|
224
|
+
604807628,
|
|
225
|
+
770255983,
|
|
226
|
+
1249150122,
|
|
227
|
+
1555081692,
|
|
228
|
+
1996064986,
|
|
229
|
+
2554220882,
|
|
230
|
+
2821834349,
|
|
231
|
+
2952996808,
|
|
232
|
+
3210313671,
|
|
233
|
+
3336571891,
|
|
234
|
+
3584528711,
|
|
235
|
+
113926993,
|
|
236
|
+
338241895,
|
|
237
|
+
666307205,
|
|
238
|
+
773529912,
|
|
239
|
+
1294757372,
|
|
240
|
+
1396182291,
|
|
241
|
+
1695183700,
|
|
242
|
+
1986661051,
|
|
243
|
+
2177026350,
|
|
244
|
+
2456956037,
|
|
245
|
+
2730485921,
|
|
246
|
+
2820302411,
|
|
247
|
+
3259730800,
|
|
248
|
+
3345764771,
|
|
249
|
+
3516065817,
|
|
250
|
+
3600352804,
|
|
251
|
+
4094571909,
|
|
252
|
+
275423344,
|
|
253
|
+
430227734,
|
|
254
|
+
506948616,
|
|
255
|
+
659060556,
|
|
256
|
+
883997877,
|
|
257
|
+
958139571,
|
|
258
|
+
1322822218,
|
|
259
|
+
1537002063,
|
|
260
|
+
1747873779,
|
|
261
|
+
1955562222,
|
|
262
|
+
2024104815,
|
|
263
|
+
2227730452,
|
|
264
|
+
2361852424,
|
|
265
|
+
2428436474,
|
|
266
|
+
2756734187,
|
|
267
|
+
3204031479,
|
|
268
|
+
3329325298
|
|
269
|
+
]);
|
|
270
|
+
var SHA256_W = /* @__PURE__ */ new Uint32Array(64);
|
|
271
|
+
var SHA256 = class extends HashMD {
|
|
272
|
+
constructor(outputLen = 32) {
|
|
273
|
+
super(64, outputLen, 8, false);
|
|
274
|
+
this.A = SHA256_IV[0] | 0;
|
|
275
|
+
this.B = SHA256_IV[1] | 0;
|
|
276
|
+
this.C = SHA256_IV[2] | 0;
|
|
277
|
+
this.D = SHA256_IV[3] | 0;
|
|
278
|
+
this.E = SHA256_IV[4] | 0;
|
|
279
|
+
this.F = SHA256_IV[5] | 0;
|
|
280
|
+
this.G = SHA256_IV[6] | 0;
|
|
281
|
+
this.H = SHA256_IV[7] | 0;
|
|
282
|
+
}
|
|
283
|
+
get() {
|
|
284
|
+
const { A, B, C, D, E, F, G, H } = this;
|
|
285
|
+
return [A, B, C, D, E, F, G, H];
|
|
286
|
+
}
|
|
287
|
+
// prettier-ignore
|
|
288
|
+
set(A, B, C, D, E, F, G, H) {
|
|
289
|
+
this.A = A | 0;
|
|
290
|
+
this.B = B | 0;
|
|
291
|
+
this.C = C | 0;
|
|
292
|
+
this.D = D | 0;
|
|
293
|
+
this.E = E | 0;
|
|
294
|
+
this.F = F | 0;
|
|
295
|
+
this.G = G | 0;
|
|
296
|
+
this.H = H | 0;
|
|
297
|
+
}
|
|
298
|
+
process(view, offset) {
|
|
299
|
+
for (let i = 0; i < 16; i++, offset += 4)
|
|
300
|
+
SHA256_W[i] = view.getUint32(offset, false);
|
|
301
|
+
for (let i = 16; i < 64; i++) {
|
|
302
|
+
const W15 = SHA256_W[i - 15];
|
|
303
|
+
const W2 = SHA256_W[i - 2];
|
|
304
|
+
const s0 = rotr(W15, 7) ^ rotr(W15, 18) ^ W15 >>> 3;
|
|
305
|
+
const s1 = rotr(W2, 17) ^ rotr(W2, 19) ^ W2 >>> 10;
|
|
306
|
+
SHA256_W[i] = s1 + SHA256_W[i - 7] + s0 + SHA256_W[i - 16] | 0;
|
|
307
|
+
}
|
|
308
|
+
let { A, B, C, D, E, F, G, H } = this;
|
|
309
|
+
for (let i = 0; i < 64; i++) {
|
|
310
|
+
const sigma1 = rotr(E, 6) ^ rotr(E, 11) ^ rotr(E, 25);
|
|
311
|
+
const T1 = H + sigma1 + Chi(E, F, G) + SHA256_K[i] + SHA256_W[i] | 0;
|
|
312
|
+
const sigma0 = rotr(A, 2) ^ rotr(A, 13) ^ rotr(A, 22);
|
|
313
|
+
const T2 = sigma0 + Maj(A, B, C) | 0;
|
|
314
|
+
H = G;
|
|
315
|
+
G = F;
|
|
316
|
+
F = E;
|
|
317
|
+
E = D + T1 | 0;
|
|
318
|
+
D = C;
|
|
319
|
+
C = B;
|
|
320
|
+
B = A;
|
|
321
|
+
A = T1 + T2 | 0;
|
|
322
|
+
}
|
|
323
|
+
A = A + this.A | 0;
|
|
324
|
+
B = B + this.B | 0;
|
|
325
|
+
C = C + this.C | 0;
|
|
326
|
+
D = D + this.D | 0;
|
|
327
|
+
E = E + this.E | 0;
|
|
328
|
+
F = F + this.F | 0;
|
|
329
|
+
G = G + this.G | 0;
|
|
330
|
+
H = H + this.H | 0;
|
|
331
|
+
this.set(A, B, C, D, E, F, G, H);
|
|
332
|
+
}
|
|
333
|
+
roundClean() {
|
|
334
|
+
clean(SHA256_W);
|
|
335
|
+
}
|
|
336
|
+
destroy() {
|
|
337
|
+
this.set(0, 0, 0, 0, 0, 0, 0, 0);
|
|
338
|
+
clean(this.buffer);
|
|
339
|
+
}
|
|
340
|
+
};
|
|
341
|
+
var sha256 = /* @__PURE__ */ createHasher(() => new SHA256());
|
|
342
|
+
|
|
343
|
+
// node_modules/.pnpm/@noble+hashes@1.8.0/node_modules/@noble/hashes/esm/sha256.js
|
|
344
|
+
var sha2562 = sha256;
|
|
345
|
+
|
|
346
|
+
// node_modules/.pnpm/@paybox+mcp-app@file+..+mcp-app_@modelcontextprotocol+sdk@1.29.0_zod@4.4.3__bn.js@5.2.3_ac1e09a20c76a1143611be5dd3d4f9db/node_modules/@paybox/mcp-app/src/signing/agent-code.ts
|
|
347
|
+
var ALPHABET = [
|
|
348
|
+
"\u{1F436}",
|
|
349
|
+
"\u{1F431}",
|
|
350
|
+
"\u{1F42D}",
|
|
351
|
+
"\u{1F430}",
|
|
352
|
+
"\u{1F98A}",
|
|
353
|
+
"\u{1F43B}",
|
|
354
|
+
"\u{1F43C}",
|
|
355
|
+
"\u{1F981}",
|
|
356
|
+
"\u{1F42E}",
|
|
357
|
+
"\u{1F437}",
|
|
358
|
+
"\u{1F438}",
|
|
359
|
+
"\u{1F435}",
|
|
360
|
+
"\u{1F414}",
|
|
361
|
+
"\u{1F427}",
|
|
362
|
+
"\u{1F426}",
|
|
363
|
+
"\u{1F424}",
|
|
364
|
+
"\u{1F986}",
|
|
365
|
+
"\u{1F985}",
|
|
366
|
+
"\u{1F989}",
|
|
367
|
+
"\u{1F987}",
|
|
368
|
+
"\u{1F417}",
|
|
369
|
+
"\u{1F434}",
|
|
370
|
+
"\u{1F984}",
|
|
371
|
+
"\u{1F41D}",
|
|
372
|
+
"\u{1F41B}",
|
|
373
|
+
"\u{1F98B}",
|
|
374
|
+
"\u{1F40C}",
|
|
375
|
+
"\u{1F41E}",
|
|
376
|
+
"\u{1F41C}",
|
|
377
|
+
"\u{1F422}",
|
|
378
|
+
"\u{1F40D}",
|
|
379
|
+
"\u{1F98E}",
|
|
380
|
+
"\u{1F419}",
|
|
381
|
+
"\u{1F990}",
|
|
382
|
+
"\u{1F980}",
|
|
383
|
+
"\u{1F421}",
|
|
384
|
+
"\u{1F420}",
|
|
385
|
+
"\u{1F42C}",
|
|
386
|
+
"\u{1F433}",
|
|
387
|
+
"\u{1F988}",
|
|
388
|
+
"\u{1F406}",
|
|
389
|
+
"\u{1F993}",
|
|
390
|
+
"\u{1F98D}",
|
|
391
|
+
"\u{1F418}",
|
|
392
|
+
"\u{1F98F}",
|
|
393
|
+
"\u{1F42A}",
|
|
394
|
+
"\u{1F992}",
|
|
395
|
+
"\u{1F411}",
|
|
396
|
+
"\u{1F98C}",
|
|
397
|
+
"\u{1F983}",
|
|
398
|
+
"\u{1F99A}",
|
|
399
|
+
"\u{1F335}",
|
|
400
|
+
"\u{1F384}",
|
|
401
|
+
"\u{1F333}",
|
|
402
|
+
"\u{1F334}",
|
|
403
|
+
"\u{1F331}",
|
|
404
|
+
"\u{1F340}",
|
|
405
|
+
"\u{1F38D}",
|
|
406
|
+
"\u{1F341}",
|
|
407
|
+
"\u{1F342}",
|
|
408
|
+
"\u{1F343}",
|
|
409
|
+
"\u{1F33B}",
|
|
410
|
+
"\u{1F339}",
|
|
411
|
+
"\u{1F337}",
|
|
412
|
+
"\u{1F338}",
|
|
413
|
+
"\u{1F33C}",
|
|
414
|
+
"\u{1F33E}",
|
|
415
|
+
"\u{1F490}",
|
|
416
|
+
"\u{1F344}",
|
|
417
|
+
"\u{1F330}",
|
|
418
|
+
"\u{1F30D}",
|
|
419
|
+
"\u{1F319}",
|
|
420
|
+
"\u2B50",
|
|
421
|
+
"\u{1F308}",
|
|
422
|
+
"\u{1F525}",
|
|
423
|
+
"\u{1F4A7}",
|
|
424
|
+
"\u{1F30A}",
|
|
425
|
+
"\u{1F32A}",
|
|
426
|
+
"\u{1F329}",
|
|
427
|
+
"\u{1F347}",
|
|
428
|
+
"\u{1F349}",
|
|
429
|
+
"\u{1F34A}",
|
|
430
|
+
"\u{1F34B}",
|
|
431
|
+
"\u{1F34C}",
|
|
432
|
+
"\u{1F34D}",
|
|
433
|
+
"\u{1F34E}",
|
|
434
|
+
"\u{1F350}",
|
|
435
|
+
"\u{1F351}",
|
|
436
|
+
"\u{1F352}",
|
|
437
|
+
"\u{1F353}",
|
|
438
|
+
"\u{1F95D}",
|
|
439
|
+
"\u{1F951}",
|
|
440
|
+
"\u{1F346}",
|
|
441
|
+
"\u{1F955}",
|
|
442
|
+
"\u{1F33D}",
|
|
443
|
+
"\u{1F966}",
|
|
444
|
+
"\u{1F952}",
|
|
445
|
+
"\u{1F95C}",
|
|
446
|
+
"\u{1F35E}",
|
|
447
|
+
"\u{1F950}",
|
|
448
|
+
"\u{1F9C0}",
|
|
449
|
+
"\u{1F373}",
|
|
450
|
+
"\u{1F95E}",
|
|
451
|
+
"\u{1F354}",
|
|
452
|
+
"\u{1F35F}",
|
|
453
|
+
"\u{1F355}",
|
|
454
|
+
"\u{1F32D}",
|
|
455
|
+
"\u{1F32E}",
|
|
456
|
+
"\u{1F32F}",
|
|
457
|
+
"\u{1F35C}",
|
|
458
|
+
"\u{1F360}",
|
|
459
|
+
"\u{1F364}",
|
|
460
|
+
"\u{1F365}",
|
|
461
|
+
"\u{1F366}",
|
|
462
|
+
"\u{1F368}",
|
|
463
|
+
"\u{1F369}",
|
|
464
|
+
"\u{1F36A}",
|
|
465
|
+
"\u{1F382}",
|
|
466
|
+
"\u{1F370}",
|
|
467
|
+
"\u{1F36B}",
|
|
468
|
+
"\u{1F36C}",
|
|
469
|
+
"\u{1F36D}",
|
|
470
|
+
"\u{1F36E}",
|
|
471
|
+
"\u{1F36F}",
|
|
472
|
+
"\u{1F37C}",
|
|
473
|
+
"\u{1F95B}",
|
|
474
|
+
"\u2615",
|
|
475
|
+
"\u{1F375}",
|
|
476
|
+
"\u{1F376}",
|
|
477
|
+
"\u{1F37E}",
|
|
478
|
+
"\u{1F377}",
|
|
479
|
+
"\u{1F378}",
|
|
480
|
+
"\u{1F379}",
|
|
481
|
+
"\u{1F37A}",
|
|
482
|
+
"\u{1F943}",
|
|
483
|
+
"\u26BD",
|
|
484
|
+
"\u{1F3C0}",
|
|
485
|
+
"\u{1F3C8}",
|
|
486
|
+
"\u26BE",
|
|
487
|
+
"\u{1F3BE}",
|
|
488
|
+
"\u{1F3B1}",
|
|
489
|
+
"\u{1F3D3}",
|
|
490
|
+
"\u{1F3F8}",
|
|
491
|
+
"\u{1F945}",
|
|
492
|
+
"\u{1F3D2}",
|
|
493
|
+
"\u{1F3F9}",
|
|
494
|
+
"\u{1F3A3}",
|
|
495
|
+
"\u{1F94A}",
|
|
496
|
+
"\u{1F3BF}",
|
|
497
|
+
"\u{1F6F7}",
|
|
498
|
+
"\u{1F3AF}",
|
|
499
|
+
"\u{1F3AE}",
|
|
500
|
+
"\u{1F3B2}",
|
|
501
|
+
"\u{1F3B8}",
|
|
502
|
+
"\u{1F3BA}",
|
|
503
|
+
"\u{1F941}",
|
|
504
|
+
"\u{1F3B9}",
|
|
505
|
+
"\u{1F3A4}",
|
|
506
|
+
"\u{1F3A7}",
|
|
507
|
+
"\u{1F4FB}",
|
|
508
|
+
"\u{1F3AC}",
|
|
509
|
+
"\u{1F3A8}",
|
|
510
|
+
"\u{1F3AA}",
|
|
511
|
+
"\u{1F680}",
|
|
512
|
+
"\u{1F6F8}",
|
|
513
|
+
"\u{1F681}",
|
|
514
|
+
"\u{1F682}",
|
|
515
|
+
"\u{1F684}",
|
|
516
|
+
"\u{1F68C}",
|
|
517
|
+
"\u{1F691}",
|
|
518
|
+
"\u{1F693}",
|
|
519
|
+
"\u{1F695}",
|
|
520
|
+
"\u{1F697}",
|
|
521
|
+
"\u{1F69A}",
|
|
522
|
+
"\u{1F69C}",
|
|
523
|
+
"\u{1F6B2}",
|
|
524
|
+
"\u26F5",
|
|
525
|
+
"\u{1F6F6}",
|
|
526
|
+
"\u{1F6A4}",
|
|
527
|
+
"\u{1F5FF}",
|
|
528
|
+
"\u{1F5FD}",
|
|
529
|
+
"\u{1F3A1}",
|
|
530
|
+
"\u{1F3A2}",
|
|
531
|
+
"\u{1F3A0}",
|
|
532
|
+
"\u26F2",
|
|
533
|
+
"\u{1F3F0}",
|
|
534
|
+
"\u{1F3DF}",
|
|
535
|
+
"\u{1F3AD}",
|
|
536
|
+
"\u{1F381}",
|
|
537
|
+
"\u{1F9ED}",
|
|
538
|
+
"\u231A",
|
|
539
|
+
"\u{1F4F1}",
|
|
540
|
+
"\u{1F4BB}",
|
|
541
|
+
"\u{1F4F7}",
|
|
542
|
+
"\u{1F4FA}",
|
|
543
|
+
"\u{1F4DE}",
|
|
544
|
+
"\u{1F4E0}",
|
|
545
|
+
"\u{1F50B}",
|
|
546
|
+
"\u{1F50C}",
|
|
547
|
+
"\u{1F4A1}",
|
|
548
|
+
"\u{1F526}",
|
|
549
|
+
"\u{1F56F}",
|
|
550
|
+
"\u{1F5D1}",
|
|
551
|
+
"\u{1F4B8}",
|
|
552
|
+
"\u{1F4B0}",
|
|
553
|
+
"\u{1F4B3}",
|
|
554
|
+
"\u{1F48E}",
|
|
555
|
+
"\u{1F527}",
|
|
556
|
+
"\u{1F528}",
|
|
557
|
+
"\u{1F529}",
|
|
558
|
+
"\u{1F52B}",
|
|
559
|
+
"\u{1F4A3}",
|
|
560
|
+
"\u{1F52A}",
|
|
561
|
+
"\u{1F52E}",
|
|
562
|
+
"\u{1F4FF}",
|
|
563
|
+
"\u{1F52C}",
|
|
564
|
+
"\u{1F4D4}",
|
|
565
|
+
"\u{1F4DA}",
|
|
566
|
+
"\u{1F31E}",
|
|
567
|
+
"\u26C4",
|
|
568
|
+
"\u2614",
|
|
569
|
+
"\u{1F30B}",
|
|
570
|
+
"\u{1F94C}",
|
|
571
|
+
"\u{1F3E0}",
|
|
572
|
+
"\u{1F3E5}",
|
|
573
|
+
"\u{1F3ED}",
|
|
574
|
+
"\u{1F511}",
|
|
575
|
+
"\u{1F512}",
|
|
576
|
+
"\u23F0",
|
|
577
|
+
"\u231B",
|
|
578
|
+
"\u{1F4C5}",
|
|
579
|
+
"\u{1F4CC}",
|
|
580
|
+
"\u{1F4CE}",
|
|
581
|
+
"\u{1F4CF}",
|
|
582
|
+
"\u{1F388}",
|
|
583
|
+
"\u{1F383}",
|
|
584
|
+
"\u{1F451}",
|
|
585
|
+
"\u{1F453}",
|
|
586
|
+
"\u{1F3A9}",
|
|
587
|
+
"\u{1F45F}",
|
|
588
|
+
"\u{1F462}",
|
|
589
|
+
"\u{1F45C}",
|
|
590
|
+
"\u{1F392}",
|
|
591
|
+
"\u{1F9F2}",
|
|
592
|
+
"\u{1F9EA}",
|
|
593
|
+
"\u{1F9EC}",
|
|
594
|
+
"\u{1F9F8}",
|
|
595
|
+
"\u{1F9E6}",
|
|
596
|
+
"\u{1F9E2}",
|
|
597
|
+
"\u{1F3C6}",
|
|
598
|
+
"\u{1F6F4}",
|
|
599
|
+
"\u{1FA90}",
|
|
600
|
+
"\u{1F3B3}",
|
|
601
|
+
"\u{1F6A6}",
|
|
602
|
+
"\u{1F9EF}",
|
|
603
|
+
"\u{1F9F9}"
|
|
604
|
+
];
|
|
605
|
+
function toHex(bytes) {
|
|
606
|
+
return Array.from(bytes, (b) => b.toString(16).padStart(2, "0")).join("");
|
|
607
|
+
}
|
|
608
|
+
var CODE_LENGTH = 8;
|
|
609
|
+
if (ALPHABET.length !== 256) {
|
|
610
|
+
throw new Error(`agent-code alphabet must be exactly 256 entries, got ${ALPHABET.length}`);
|
|
611
|
+
}
|
|
612
|
+
function sha2563(bytes) {
|
|
613
|
+
return sha2562(bytes);
|
|
614
|
+
}
|
|
615
|
+
function codeFromDigest(digest) {
|
|
616
|
+
const code = [];
|
|
617
|
+
for (let i = 0; i < CODE_LENGTH; i += 1) code.push(ALPHABET[digest[i]]);
|
|
618
|
+
return code;
|
|
619
|
+
}
|
|
620
|
+
async function deriveAgentCode(publicKey) {
|
|
621
|
+
if (publicKey.length !== 32) {
|
|
622
|
+
throw new Error(`public key must be 32 bytes, got ${publicKey.length}`);
|
|
623
|
+
}
|
|
624
|
+
return codeFromDigest(sha2563(publicKey));
|
|
625
|
+
}
|
|
626
|
+
|
|
627
|
+
// src/pairing.ts
|
|
628
|
+
var POLL_MS = 1500;
|
|
629
|
+
var TIMEOUT_MS = 10 * 60 * 1e3;
|
|
630
|
+
var MAX_BACKOFF_MS = 15e3;
|
|
631
|
+
var GIVE_UP_AFTER_FAILING_MS = 9e4;
|
|
632
|
+
async function json(url, init) {
|
|
633
|
+
const res = await fetch(url, init);
|
|
634
|
+
if (!res.ok) {
|
|
635
|
+
const body = await res.text().catch(() => "");
|
|
636
|
+
throw new Error(`${init.method ?? "GET"} ${new URL(url).pathname} failed (${res.status})${body ? `: ${body.slice(0, 200)}` : ""}`);
|
|
637
|
+
}
|
|
638
|
+
return res.json();
|
|
639
|
+
}
|
|
640
|
+
async function pairSigningKey(opts) {
|
|
641
|
+
const { pairing_token, client_id } = await json(`${opts.baseUrl}/api/agent-pairings/token`, {
|
|
642
|
+
method: "POST",
|
|
643
|
+
headers: { authorization: `Bearer ${opts.bearer}`, accept: "application/json" }
|
|
644
|
+
});
|
|
645
|
+
const seed = nacl.randomBytes(nacl.sign.seedLength);
|
|
646
|
+
const pair = nacl.sign.keyPair.fromSeed(seed);
|
|
647
|
+
const keypair = { apiPubHex: toHex(pair.publicKey), apiPrivHex: toHex(seed) };
|
|
648
|
+
const { pairing_id } = await json(`${opts.baseUrl}/iframe/pairing`, {
|
|
649
|
+
method: "POST",
|
|
650
|
+
headers: {
|
|
651
|
+
authorization: `Bearer ${pairing_token}`,
|
|
652
|
+
"content-type": "application/json",
|
|
653
|
+
accept: "application/json"
|
|
654
|
+
},
|
|
655
|
+
body: JSON.stringify({ api_pub_hex: keypair.apiPubHex })
|
|
656
|
+
});
|
|
657
|
+
const url = `${opts.appBase}/agent-key?client_id=${client_id}&pairing_id=${pairing_id}`;
|
|
658
|
+
opts.onCode(await deriveAgentCode(pair.publicKey), url);
|
|
659
|
+
const deadline = Date.now() + TIMEOUT_MS;
|
|
660
|
+
let failures = 0;
|
|
661
|
+
let failingSince = 0;
|
|
662
|
+
while (Date.now() < deadline) {
|
|
663
|
+
const backoff = failures ? Math.min(POLL_MS * 2 ** failures, MAX_BACKOFF_MS) : POLL_MS;
|
|
664
|
+
await new Promise((resolve) => setTimeout(resolve, backoff));
|
|
665
|
+
let status;
|
|
666
|
+
try {
|
|
667
|
+
status = (await json(`${opts.baseUrl}/iframe/pairing/${pairing_id}`, {
|
|
668
|
+
headers: { accept: "application/json" }
|
|
669
|
+
})).status;
|
|
670
|
+
failures = 0;
|
|
671
|
+
failingSince = 0;
|
|
672
|
+
} catch (err) {
|
|
673
|
+
failures += 1;
|
|
674
|
+
failingSince ||= Date.now();
|
|
675
|
+
if (Date.now() - failingSince >= GIVE_UP_AFTER_FAILING_MS) {
|
|
676
|
+
throw new Error(`lost contact with PayBox while waiting: ${err.message}`);
|
|
677
|
+
}
|
|
678
|
+
continue;
|
|
679
|
+
}
|
|
680
|
+
if (status === "completed") return encodeToken(keypair);
|
|
681
|
+
if (status === "cancelled") throw new Error("that request was declined in PayBox");
|
|
682
|
+
if (status === "expired") throw new Error("that request expired \u2014 run `paybox connect` again");
|
|
683
|
+
}
|
|
684
|
+
throw new Error("timed out waiting for you to pick the code in PayBox");
|
|
685
|
+
}
|
|
686
|
+
|
|
687
|
+
// src/cli.ts
|
|
21
688
|
var DEFAULT_BASE_URL = "https://api.paybox.sh";
|
|
22
689
|
var PKG = "@paybox-sh/sdk";
|
|
23
690
|
var VERSION = createRequire(import.meta.url)("../package.json").version;
|
|
@@ -27,10 +694,16 @@ function jsonMode() {
|
|
|
27
694
|
return Boolean(program.opts().json);
|
|
28
695
|
}
|
|
29
696
|
function emit(data) {
|
|
697
|
+
const funding = pendingFundingResponse(data) ?? (Array.isArray(data?.content) ? pendingFundingToolResponse(data) : null);
|
|
698
|
+
if (funding) {
|
|
699
|
+
console.error(
|
|
700
|
+
`Request incomplete; funding status is pending, not proof that funding has started or completed. Poll \`paybox request ${funding.request_id}\`; do not repeat the purchase.`
|
|
701
|
+
);
|
|
702
|
+
}
|
|
30
703
|
if (jsonMode()) console.log(JSON.stringify(data, null, 2));
|
|
31
704
|
else console.dir(data, { depth: null, colors: process.stdout.isTTY });
|
|
32
705
|
const d = data;
|
|
33
|
-
if (didNotHappen(d) || didNotHappen(d?.response) || d?.isError === true) {
|
|
706
|
+
if (!funding && (didNotHappen(d) || didNotHappen(d?.response) || d?.isError === true)) {
|
|
34
707
|
process.exitCode = 1;
|
|
35
708
|
}
|
|
36
709
|
}
|
|
@@ -87,15 +760,6 @@ function isNewer(a, b) {
|
|
|
87
760
|
}
|
|
88
761
|
return false;
|
|
89
762
|
}
|
|
90
|
-
async function prompt(question) {
|
|
91
|
-
if (!process.stdin.isTTY) return "";
|
|
92
|
-
const rl = createInterface({ input: process.stdin, output: process.stderr });
|
|
93
|
-
try {
|
|
94
|
-
return (await rl.question(question)).trim();
|
|
95
|
-
} finally {
|
|
96
|
-
rl.close();
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
763
|
async function run(fn) {
|
|
100
764
|
try {
|
|
101
765
|
await fn();
|
|
@@ -106,64 +770,72 @@ async function run(fn) {
|
|
|
106
770
|
process.exitCode = 1;
|
|
107
771
|
}
|
|
108
772
|
}
|
|
109
|
-
function
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
773
|
+
function withNextAction(c, result) {
|
|
774
|
+
const value = result;
|
|
775
|
+
const response = value.response;
|
|
776
|
+
if (response?.status) {
|
|
777
|
+
return {
|
|
778
|
+
...value,
|
|
779
|
+
response: { ...response, next_action: c.nextAction(response) }
|
|
780
|
+
};
|
|
781
|
+
}
|
|
782
|
+
if (value.status) {
|
|
783
|
+
return { ...value, next_action: c.nextAction(value) };
|
|
114
784
|
}
|
|
785
|
+
return result;
|
|
786
|
+
}
|
|
787
|
+
function resolveBaseUrl() {
|
|
788
|
+
const cfg = loadConfig();
|
|
789
|
+
return (program.opts().baseUrl ?? process.env.PAYBOX_API_URL ?? cfg.baseUrl ?? DEFAULT_BASE_URL).replace(/\/+$/, "");
|
|
115
790
|
}
|
|
116
|
-
program.command("login").description("Authenticate via OAuth
|
|
117
|
-
"--signing-key <token>",
|
|
118
|
-
"store a pbxk1. wallet signing key; prefer PAYBOX_SIGNING_KEY (an argument is visible in shell history)"
|
|
119
|
-
).option("--app-url <url>", "PayBox app origin for key provisioning (default: derived from --base-url)").option("--no-provision", "skip the wallet signing-key provisioning step").action(
|
|
791
|
+
program.command("login").description("Authenticate via OAuth device approval, or store a pbx_live_ key").option("--key <key>", "store a pbx_live_ personal API key instead of OAuth").option("--no-open", "print the approval link without opening a browser").action(
|
|
120
792
|
(opts) => run(async () => {
|
|
121
793
|
const cfg = loadConfig();
|
|
122
|
-
|
|
123
|
-
cfg.baseUrl = baseUrl;
|
|
124
|
-
if (opts.appUrl) cfg.appUrl = opts.appUrl;
|
|
125
|
-
const keepExistingLogin = Boolean(opts.signingKey) && Boolean(cfg.apiKey ?? cfg.oauth);
|
|
794
|
+
cfg.baseUrl = resolveBaseUrl();
|
|
126
795
|
if (opts.key) {
|
|
127
796
|
cfg.apiKey = opts.key;
|
|
128
797
|
delete cfg.oauth;
|
|
129
|
-
} else
|
|
130
|
-
cfg.oauth = await loginDevice(baseUrl);
|
|
798
|
+
} else {
|
|
799
|
+
cfg.oauth = await loginDevice(cfg.baseUrl, { open: opts.open });
|
|
131
800
|
delete cfg.apiKey;
|
|
132
801
|
}
|
|
133
|
-
|
|
802
|
+
delete cfg.signingKey;
|
|
134
803
|
saveConfig(cfg);
|
|
135
804
|
console.error(`Saved credentials to ${configFile()}`);
|
|
136
|
-
if (!
|
|
137
|
-
|
|
138
|
-
const appBase = appBaseFrom(baseUrl, opts.appUrl ?? process.env.PAYBOX_APP_URL ?? cfg.appUrl);
|
|
139
|
-
if (!cid || !appBase) {
|
|
140
|
-
console.error(
|
|
141
|
-
"To enable wallet sign/swap, provision a signing key, then set\n PAYBOX_SIGNING_KEY=<pbxk1...> and re-run `paybox login`" + (cid && !appBase ? " (or pass --app-url <paybox app origin>)" : "")
|
|
142
|
-
);
|
|
143
|
-
return;
|
|
805
|
+
if (!process.env.PAYBOX_SIGNING_KEY) {
|
|
806
|
+
console.error("Run `paybox connect` to connect a signing key; until then sign and swap stop at pending_signature.");
|
|
144
807
|
}
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
);
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
if (
|
|
155
|
-
cfg.
|
|
808
|
+
})
|
|
809
|
+
);
|
|
810
|
+
program.command("connect").description("Connect a wallet signing key to this machine by picking a code in PayBox").option("--app-url <url>", "PayBox app origin (default: derived from --base-url)").option("--no-open", "print the pairing link without opening a browser").action(
|
|
811
|
+
(opts) => run(async () => {
|
|
812
|
+
const cfg = loadConfig();
|
|
813
|
+
const baseUrl = resolveBaseUrl();
|
|
814
|
+
const appBase = appBaseFrom(baseUrl, opts.appUrl ?? process.env.PAYBOX_APP_URL ?? cfg.appUrl);
|
|
815
|
+
if (!appBase) throw new Error("could not derive the PayBox app origin \u2014 pass --app-url");
|
|
816
|
+
if (opts.appUrl) cfg.appUrl = opts.appUrl;
|
|
817
|
+
if (!cfg.apiKey && cfg.oauth?.expiresAt && Date.now() > cfg.oauth.expiresAt - 3e4) {
|
|
818
|
+
cfg.oauth = await refreshTokens(baseUrl, cfg.oauth);
|
|
156
819
|
saveConfig(cfg);
|
|
157
|
-
console.error("Signing key saved \u2014 sign/swap enabled.");
|
|
158
|
-
} else if (process.stdin.isTTY) {
|
|
159
|
-
console.error(
|
|
160
|
-
"Skipped \u2014 provision one later by setting PAYBOX_SIGNING_KEY and re-running `paybox login`."
|
|
161
|
-
);
|
|
162
|
-
} else {
|
|
163
|
-
console.error(
|
|
164
|
-
"No signing key configured, so sign and swap will stop at pending_signature.\nSet PAYBOX_SIGNING_KEY to the `pbxk1.` token and re-run `paybox login`."
|
|
165
|
-
);
|
|
166
820
|
}
|
|
821
|
+
const bearer = cfg.apiKey ?? cfg.oauth?.accessToken;
|
|
822
|
+
if (!bearer) throw new Error("not authenticated \u2014 run `paybox login` first");
|
|
823
|
+
cfg.signingKey = await pairSigningKey({
|
|
824
|
+
baseUrl,
|
|
825
|
+
appBase,
|
|
826
|
+
bearer,
|
|
827
|
+
onCode(code, url) {
|
|
828
|
+
console.error(`
|
|
829
|
+
${code.join(" ")}
|
|
830
|
+
`);
|
|
831
|
+
console.error(`Open this on any device and pick that code to connect this machine:
|
|
832
|
+
${url}
|
|
833
|
+
`);
|
|
834
|
+
if (opts.open) openBrowser(url);
|
|
835
|
+
}
|
|
836
|
+
});
|
|
837
|
+
saveConfig(cfg);
|
|
838
|
+
console.error("Connected \u2014 sign and swap are enabled on this machine.");
|
|
167
839
|
})
|
|
168
840
|
);
|
|
169
841
|
program.command("logout").description("Forget stored credentials").action(
|
|
@@ -216,8 +888,7 @@ program.command("sign").description("Sign with a wallet credential (intent JSON,
|
|
|
216
888
|
credentialId: credentialId(o.credential),
|
|
217
889
|
intent: readIntent(o.intent)
|
|
218
890
|
});
|
|
219
|
-
|
|
220
|
-
emit(res);
|
|
891
|
+
emit(withNextAction(c, res));
|
|
221
892
|
})
|
|
222
893
|
);
|
|
223
894
|
program.command("swap").description("Swap tokens from a wallet credential").requiredOption("--credential <id>", "credential id from `paybox credentials`").requiredOption("--src-chain <caip2>").requiredOption("--src-token <addr>", '"native" or a token address').requiredOption("--dst-token <addr>").requiredOption("--amount <smallest-unit>", "source amount in smallest units").option("--dst-chain <caip2>", "defaults to --src-chain").option("--direction <dir>", "exact-amount-in | exact-amount-out", "exact-amount-in").option("--slippage <bps>", "slippage in bps", "150").option("--recipient <addr>").option("--value-cents <n>").option("--wait", "if approval is required, wait for it and then sign in-process").action(
|
|
@@ -238,8 +909,7 @@ program.command("swap").description("Swap tokens from a wallet credential").requ
|
|
|
238
909
|
},
|
|
239
910
|
{ waitForApproval: Boolean(o.wait) }
|
|
240
911
|
);
|
|
241
|
-
|
|
242
|
-
emit(result);
|
|
912
|
+
emit(withNextAction(c, result));
|
|
243
913
|
})
|
|
244
914
|
);
|
|
245
915
|
program.command("discover [query]").description("Discover curated paid x402 services from Bazaar (optional search)").option("--raw", "return uncurated compact Bazaar service summaries (debug)").action(
|
|
@@ -256,8 +926,7 @@ program.command("pay-x402").description("Pay a paid x402 endpoint (header mode \
|
|
|
256
926
|
},
|
|
257
927
|
{ waitForApproval: Boolean(o.wait) }
|
|
258
928
|
);
|
|
259
|
-
|
|
260
|
-
emit(result);
|
|
929
|
+
emit(withNextAction(c, result));
|
|
261
930
|
})
|
|
262
931
|
);
|
|
263
932
|
program.command("use-service").description("Fetch a paid x402 resource and have paybox pay for it (gateway mode)").requiredOption("--credential <id>", "credential id from `paybox credentials`").requiredOption("--url <url>", "the paid x402 resource URL").option("--method <verb>", "HTTP method", "GET").option("--body <json>", "request body (JSON or @file)").option("--wait", "if approval is required, wait for it and then sign in-process").action(
|
|
@@ -272,13 +941,19 @@ program.command("use-service").description("Fetch a paid x402 resource and have
|
|
|
272
941
|
},
|
|
273
942
|
{ waitForApproval: Boolean(o.wait) }
|
|
274
943
|
);
|
|
275
|
-
|
|
276
|
-
emit(result);
|
|
944
|
+
emit(withNextAction(c, result));
|
|
277
945
|
})
|
|
278
946
|
);
|
|
279
|
-
program.command("portfolio").description("List a wallet address's token balances across chains").requiredOption("--address <addr>").option("--networks <ids>", 'comma-separated network IDs, e.g. "1,8453"').action(
|
|
947
|
+
program.command("portfolio").description("List a wallet address's token balances across chains").requiredOption("--address <addr>").option("--networks <ids>", 'comma-separated network IDs, e.g. "1,8453"').option("--token <addr>", "mint, ERC-20, or native").option("--network-id <id>", "MoonX network id required with --token").action(
|
|
280
948
|
(o) => run(
|
|
281
|
-
async () => emit(
|
|
949
|
+
async () => emit(
|
|
950
|
+
await client().getPortfolio({
|
|
951
|
+
address: o.address,
|
|
952
|
+
networkIds: o.networks,
|
|
953
|
+
token: o.token,
|
|
954
|
+
networkId: o.networkId == null ? void 0 : Number(o.networkId)
|
|
955
|
+
})
|
|
956
|
+
)
|
|
282
957
|
)
|
|
283
958
|
);
|
|
284
959
|
program.command("verify-solana-balance").description("Verify a Solana transaction's wallet/token effect and current balance").requiredOption("--address <addr>", "canonical Solana wallet address").requiredOption("--mint <addr>", "canonical SPL or Token-2022 mint").requiredOption("--transaction <signature>", "confirmed Solana transaction signature").action(
|
|
@@ -294,6 +969,16 @@ program.command("verify-solana-balance").description("Verify a Solana transactio
|
|
|
294
969
|
);
|
|
295
970
|
program.command("claim <request-id>").description("Claim the usable card credentials of an approved payment (one-time)").action((id) => run(async () => emit(await client().claimPaymentCredentials(requestId(id)))));
|
|
296
971
|
program.command("account-change").description("Get a manage_url for the USER to update this client's access in the app").option("--note <text>", "why the change is needed (shown to the user)").action((o) => run(async () => emit(await client().requestAccountChange(o.note))));
|
|
972
|
+
program.command("deposit-link").description("Open Deposit URL for a granted wallet (charges nothing)").requiredOption("--credential <id>", "a granted wallet credential").option("--amount-usd <n>", "optional amount hint in USD").action(
|
|
973
|
+
(o) => run(
|
|
974
|
+
async () => emit(
|
|
975
|
+
await client().getDepositLink({
|
|
976
|
+
credentialId: credentialId(o.credential),
|
|
977
|
+
amountUsd: o.amountUsd === void 0 ? void 0 : Number(o.amountUsd)
|
|
978
|
+
})
|
|
979
|
+
)
|
|
980
|
+
)
|
|
981
|
+
);
|
|
297
982
|
program.command("buy-link").description("Signed MoonPay checkout URL funding a granted wallet (charges nothing)").requiredOption("--credential <id>", "a granted wallet credential").option(
|
|
298
983
|
"--destination <chain>",
|
|
299
984
|
"exact network: eip155:8453 (default EVM), eip155:1, eip155:4663, or solana:mainnet"
|
|
@@ -342,11 +1027,12 @@ plugins.command("use <plugin-id> <tool-id>").description("Invoke a tool from its
|
|
|
342
1027
|
)
|
|
343
1028
|
)
|
|
344
1029
|
);
|
|
345
|
-
program.command("request <id>").description("Poll a request's status").option("--wait", "block until it leaves the pending state").action(
|
|
1030
|
+
program.command("request <id>").description("Poll a request's status").option("--wait", "block until it leaves the pending state").option("--complete-signature", "sign an existing wallet-sign request with the local key").action(
|
|
346
1031
|
(id, o) => run(async () => {
|
|
347
1032
|
const c = client();
|
|
348
1033
|
const rid = requestId(id);
|
|
349
|
-
|
|
1034
|
+
const response = o.completeSignature ? await c.completeWalletSignRequest(rid) : await c.getRequest(rid);
|
|
1035
|
+
emit(withNextAction(c, o.wait ? await c.waitForRequest(rid) : response));
|
|
350
1036
|
})
|
|
351
1037
|
);
|
|
352
1038
|
program.command("version").description("Show the installed CLI version (and whether an update is available)").action(
|
|
@@ -421,4 +1107,9 @@ function rejectUnknownCommand(argv) {
|
|
|
421
1107
|
}
|
|
422
1108
|
rejectUnknownCommand(process.argv);
|
|
423
1109
|
program.parseAsync(process.argv);
|
|
1110
|
+
/*! Bundled license information:
|
|
1111
|
+
|
|
1112
|
+
@noble/hashes/esm/utils.js:
|
|
1113
|
+
(*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
|
|
1114
|
+
*/
|
|
424
1115
|
//# sourceMappingURL=cli.js.map
|