@mystars-tg/faas-cli 0.1.2
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 +44 -0
- package/dist/bin.cjs +117 -0
- package/dist/bin.js +72 -0
- package/dist/chunk-LVDNP4X2.js +71 -0
- package/dist/index.cjs +95 -0
- package/dist/index.d.cts +157 -0
- package/dist/index.d.ts +157 -0
- package/dist/index.js +24 -0
- package/package.json +44 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 MyStars.tg
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# @mystars-tg/faas-cli
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/@mystars-tg/faas-cli) [](LICENSE)
|
|
4
|
+
|
|
5
|
+
Command-line tool for the MyStars FaaS API — quoting, recipient checks, order management, payment
|
|
6
|
+
links, and webhook verification. Great for onboarding, support, and quick smoke tests.
|
|
7
|
+
|
|
8
|
+
📖 API reference: **[mystars.tg/docs](https://mystars.tg/docs)**.
|
|
9
|
+
|
|
10
|
+
## Use it
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
# No install needed:
|
|
14
|
+
npx @mystars-tg/faas-cli --help
|
|
15
|
+
|
|
16
|
+
# Or install globally:
|
|
17
|
+
npm install -g @mystars-tg/faas-cli
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
Authenticate with `--api-key <key>` or `MYSTARS_API_KEY`. Every command prints JSON to stdout.
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
export MYSTARS_API_KEY=faas_...
|
|
24
|
+
|
|
25
|
+
mystars-faas pricing --type stars --quantity 100 --currency ton
|
|
26
|
+
mystars-faas products
|
|
27
|
+
mystars-faas recipient-check durov --type stars
|
|
28
|
+
mystars-faas orders create --type stars --recipient durov --quantity 100 --pay # prints a payable deeplink/QR/TON Connect
|
|
29
|
+
mystars-faas orders get <order-id>
|
|
30
|
+
mystars-faas orders ls --status delivered --limit 50
|
|
31
|
+
mystars-faas orders cancel <order-id>
|
|
32
|
+
mystars-faas watch <order-id> # poll until terminal
|
|
33
|
+
|
|
34
|
+
# webhook-verify: PREFER the env var — a secret on the command line leaks into `ps` + shell history.
|
|
35
|
+
export MYSTARS_WEBHOOK_SECRET=...
|
|
36
|
+
mystars-faas webhook-verify --body '<raw-json>' --signature <X-Faas-Signature>
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
`webhook-verify` runs entirely offline — handy for debugging a signature locally. The webhook secret
|
|
40
|
+
comes from `MYSTARS_WEBHOOK_SECRET` (preferred) or `--secret <secret>`; the env var **wins** when both
|
|
41
|
+
are set, because a secret passed on the command line is visible in the process list (`ps`) and your
|
|
42
|
+
shell history. The CLI never holds keys or moves funds; `orders create --pay` only **prints** a payment
|
|
43
|
+
request you can pay from your own wallet (see `@mystars-tg/faas-wallet` for programmatic signing +
|
|
44
|
+
broadcasting).
|
package/dist/bin.cjs
ADDED
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
|
|
4
|
+
// src/bin.ts
|
|
5
|
+
var import_commander = require("commander");
|
|
6
|
+
var import_faas_sdk2 = require("@mystars-tg/faas-sdk");
|
|
7
|
+
|
|
8
|
+
// src/commands.ts
|
|
9
|
+
var import_faas_sdk = require("@mystars-tg/faas-sdk");
|
|
10
|
+
function print(io2, value) {
|
|
11
|
+
io2.out(JSON.stringify(value, null, 2));
|
|
12
|
+
}
|
|
13
|
+
async function cmdPricing(client, opts, io2) {
|
|
14
|
+
const quote = opts.type === "stars" ? await client.getPricing({ type: "stars", quantity: opts.quantity, payment_currency: opts.currency }) : await client.getPricing({ type: "premium", months: opts.months, payment_currency: opts.currency });
|
|
15
|
+
print(io2, quote);
|
|
16
|
+
}
|
|
17
|
+
async function cmdProducts(client, io2) {
|
|
18
|
+
print(io2, await client.listProducts());
|
|
19
|
+
}
|
|
20
|
+
async function cmdCurrencies(client, io2) {
|
|
21
|
+
print(io2, await client.listCurrencies());
|
|
22
|
+
}
|
|
23
|
+
async function cmdRecipientCheck(client, opts, io2) {
|
|
24
|
+
const res = opts.type === "stars" ? await client.checkRecipient({ type: "stars", recipient: { username: opts.username } }) : await client.checkRecipient({ type: "premium", recipient: { username: opts.username }, months: opts.months });
|
|
25
|
+
print(io2, res);
|
|
26
|
+
}
|
|
27
|
+
async function cmdOrdersCreate(client, opts, io2) {
|
|
28
|
+
const order = opts.type === "stars" ? await client.createOrder({ type: "stars", recipient: { username: opts.recipient }, quantity: opts.quantity, payment_currency: opts.currency, callback_url: opts.callback }) : await client.createOrder({ type: "premium", recipient: { username: opts.recipient }, months: opts.months, payment_currency: opts.currency, callback_url: opts.callback });
|
|
29
|
+
if (opts.pay) {
|
|
30
|
+
print(io2, { order, payment_request: (0, import_faas_sdk.buildPaymentRequest)(order.payment) });
|
|
31
|
+
} else {
|
|
32
|
+
print(io2, order);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
async function cmdOrdersGet(client, id, io2) {
|
|
36
|
+
print(io2, await client.getOrder(id));
|
|
37
|
+
}
|
|
38
|
+
async function cmdOrdersList(client, opts, io2) {
|
|
39
|
+
const page = await client.listOrders(opts).page();
|
|
40
|
+
print(io2, page);
|
|
41
|
+
}
|
|
42
|
+
async function cmdOrdersCancel(client, id, io2) {
|
|
43
|
+
print(io2, await client.cancelOrder(id));
|
|
44
|
+
}
|
|
45
|
+
async function cmdWatch(client, id, io2) {
|
|
46
|
+
const final = await client.waitForOrder(id, {
|
|
47
|
+
onUpdate: (o) => io2.err(`status: ${o.status}`)
|
|
48
|
+
});
|
|
49
|
+
print(io2, final);
|
|
50
|
+
}
|
|
51
|
+
function resolveWebhookSecret(optSecret, env = process.env) {
|
|
52
|
+
const secret = env.MYSTARS_WEBHOOK_SECRET || optSecret;
|
|
53
|
+
if (!secret) {
|
|
54
|
+
throw new Error("a webhook secret is required (set MYSTARS_WEBHOOK_SECRET, or pass --secret <secret>)");
|
|
55
|
+
}
|
|
56
|
+
return secret;
|
|
57
|
+
}
|
|
58
|
+
async function cmdWebhookVerify(opts, io2) {
|
|
59
|
+
const valid = await (0, import_faas_sdk.verifyWebhookSignature)(opts.body, opts.signature, opts.secret);
|
|
60
|
+
print(io2, { valid });
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// src/bin.ts
|
|
64
|
+
var program = new import_commander.Command();
|
|
65
|
+
var io = { out: (s) => console.log(s), err: (s) => console.error(s) };
|
|
66
|
+
program.name("mystars-faas").description("CLI for the MyStars FaaS API (Telegram Stars & Premium for any @username).").version("0.1.2").option("--api-key <key>", "tenant API key (or set MYSTARS_API_KEY)");
|
|
67
|
+
function makeClient() {
|
|
68
|
+
const opts = program.opts();
|
|
69
|
+
const apiKey = opts.apiKey ?? process.env.MYSTARS_API_KEY;
|
|
70
|
+
if (!apiKey) {
|
|
71
|
+
io.err("error: an API key is required (--api-key <key> or MYSTARS_API_KEY)");
|
|
72
|
+
process.exit(1);
|
|
73
|
+
}
|
|
74
|
+
return import_faas_sdk2.MyStarsClient.production(apiKey);
|
|
75
|
+
}
|
|
76
|
+
function fail(msg) {
|
|
77
|
+
io.err(`error: ${msg}`);
|
|
78
|
+
process.exit(1);
|
|
79
|
+
}
|
|
80
|
+
var num = (v, name) => {
|
|
81
|
+
if (v === void 0) return void 0;
|
|
82
|
+
const n = Number(v);
|
|
83
|
+
if (!Number.isFinite(n)) fail(`--${name} must be a number, got "${v}"`);
|
|
84
|
+
return n;
|
|
85
|
+
};
|
|
86
|
+
function asType(t) {
|
|
87
|
+
if (t !== "stars" && t !== "premium") fail(`--type must be "stars" or "premium", got "${t}"`);
|
|
88
|
+
return t;
|
|
89
|
+
}
|
|
90
|
+
program.command("pricing").description("quote a price").requiredOption("--type <type>", "stars | premium").option("--quantity <n>", "stars quantity").option("--months <n>", "premium months (3|6|12)").option("--currency <c>", "ton | usdt_ton").action(
|
|
91
|
+
(o) => cmdPricing(makeClient(), { type: asType(o.type), quantity: num(o.quantity, "quantity"), months: num(o.months, "months"), currency: o.currency }, io)
|
|
92
|
+
);
|
|
93
|
+
program.command("products").description("list the product catalog").action(() => cmdProducts(makeClient(), io));
|
|
94
|
+
program.command("currencies").description("list payment currencies").action(() => cmdCurrencies(makeClient(), io));
|
|
95
|
+
program.command("recipient-check").description("resolve a @username and check eligibility").argument("<username>").requiredOption("--type <type>", "stars | premium").option("--months <n>", "premium months").action((username, o) => cmdRecipientCheck(makeClient(), { type: asType(o.type), username, months: num(o.months, "months") }, io));
|
|
96
|
+
var orders = program.command("orders").description("manage orders");
|
|
97
|
+
orders.command("create").requiredOption("--type <type>", "stars | premium").requiredOption("--recipient <username>").option("--quantity <n>").option("--months <n>").option("--currency <c>", "ton | usdt_ton").option("--callback <url>", "webhook callback_url").option("--pay", "also print a payable request (deeplink / QR / TON Connect)").action(
|
|
98
|
+
(o) => cmdOrdersCreate(
|
|
99
|
+
makeClient(),
|
|
100
|
+
{ type: asType(o.type), recipient: o.recipient, quantity: num(o.quantity, "quantity"), months: num(o.months, "months"), currency: o.currency, callback: o.callback, pay: o.pay },
|
|
101
|
+
io
|
|
102
|
+
)
|
|
103
|
+
);
|
|
104
|
+
orders.command("get").argument("<id>").action((id) => cmdOrdersGet(makeClient(), id, io));
|
|
105
|
+
orders.command("ls").option("--status <status>").option("--limit <n>").action((o) => cmdOrdersList(makeClient(), { status: o.status, limit: num(o.limit, "limit") }, io));
|
|
106
|
+
orders.command("cancel").argument("<id>").action((id) => cmdOrdersCancel(makeClient(), id, io));
|
|
107
|
+
program.command("watch").description("poll an order until it's terminal").argument("<id>").action((id) => cmdWatch(makeClient(), id, io));
|
|
108
|
+
program.command("webhook-verify").description("verify an X-Faas-Signature over a raw body").option(
|
|
109
|
+
"--secret <secret>",
|
|
110
|
+
"tenant webhook secret (PREFER MYSTARS_WEBHOOK_SECRET \u2014 a secret on the command line leaks into `ps` and shell history)"
|
|
111
|
+
).requiredOption("--body <json>").requiredOption("--signature <sig>").action(
|
|
112
|
+
(o) => cmdWebhookVerify({ secret: resolveWebhookSecret(o.secret), body: o.body, signature: o.signature }, io)
|
|
113
|
+
);
|
|
114
|
+
program.parseAsync(process.argv).catch((e) => {
|
|
115
|
+
io.err(e instanceof Error ? e.message : String(e));
|
|
116
|
+
process.exit(1);
|
|
117
|
+
});
|
package/dist/bin.js
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
cmdCurrencies,
|
|
4
|
+
cmdOrdersCancel,
|
|
5
|
+
cmdOrdersCreate,
|
|
6
|
+
cmdOrdersGet,
|
|
7
|
+
cmdOrdersList,
|
|
8
|
+
cmdPricing,
|
|
9
|
+
cmdProducts,
|
|
10
|
+
cmdRecipientCheck,
|
|
11
|
+
cmdWatch,
|
|
12
|
+
cmdWebhookVerify,
|
|
13
|
+
resolveWebhookSecret
|
|
14
|
+
} from "./chunk-LVDNP4X2.js";
|
|
15
|
+
|
|
16
|
+
// src/bin.ts
|
|
17
|
+
import { Command } from "commander";
|
|
18
|
+
import { MyStarsClient } from "@mystars-tg/faas-sdk";
|
|
19
|
+
var program = new Command();
|
|
20
|
+
var io = { out: (s) => console.log(s), err: (s) => console.error(s) };
|
|
21
|
+
program.name("mystars-faas").description("CLI for the MyStars FaaS API (Telegram Stars & Premium for any @username).").version("0.1.2").option("--api-key <key>", "tenant API key (or set MYSTARS_API_KEY)");
|
|
22
|
+
function makeClient() {
|
|
23
|
+
const opts = program.opts();
|
|
24
|
+
const apiKey = opts.apiKey ?? process.env.MYSTARS_API_KEY;
|
|
25
|
+
if (!apiKey) {
|
|
26
|
+
io.err("error: an API key is required (--api-key <key> or MYSTARS_API_KEY)");
|
|
27
|
+
process.exit(1);
|
|
28
|
+
}
|
|
29
|
+
return MyStarsClient.production(apiKey);
|
|
30
|
+
}
|
|
31
|
+
function fail(msg) {
|
|
32
|
+
io.err(`error: ${msg}`);
|
|
33
|
+
process.exit(1);
|
|
34
|
+
}
|
|
35
|
+
var num = (v, name) => {
|
|
36
|
+
if (v === void 0) return void 0;
|
|
37
|
+
const n = Number(v);
|
|
38
|
+
if (!Number.isFinite(n)) fail(`--${name} must be a number, got "${v}"`);
|
|
39
|
+
return n;
|
|
40
|
+
};
|
|
41
|
+
function asType(t) {
|
|
42
|
+
if (t !== "stars" && t !== "premium") fail(`--type must be "stars" or "premium", got "${t}"`);
|
|
43
|
+
return t;
|
|
44
|
+
}
|
|
45
|
+
program.command("pricing").description("quote a price").requiredOption("--type <type>", "stars | premium").option("--quantity <n>", "stars quantity").option("--months <n>", "premium months (3|6|12)").option("--currency <c>", "ton | usdt_ton").action(
|
|
46
|
+
(o) => cmdPricing(makeClient(), { type: asType(o.type), quantity: num(o.quantity, "quantity"), months: num(o.months, "months"), currency: o.currency }, io)
|
|
47
|
+
);
|
|
48
|
+
program.command("products").description("list the product catalog").action(() => cmdProducts(makeClient(), io));
|
|
49
|
+
program.command("currencies").description("list payment currencies").action(() => cmdCurrencies(makeClient(), io));
|
|
50
|
+
program.command("recipient-check").description("resolve a @username and check eligibility").argument("<username>").requiredOption("--type <type>", "stars | premium").option("--months <n>", "premium months").action((username, o) => cmdRecipientCheck(makeClient(), { type: asType(o.type), username, months: num(o.months, "months") }, io));
|
|
51
|
+
var orders = program.command("orders").description("manage orders");
|
|
52
|
+
orders.command("create").requiredOption("--type <type>", "stars | premium").requiredOption("--recipient <username>").option("--quantity <n>").option("--months <n>").option("--currency <c>", "ton | usdt_ton").option("--callback <url>", "webhook callback_url").option("--pay", "also print a payable request (deeplink / QR / TON Connect)").action(
|
|
53
|
+
(o) => cmdOrdersCreate(
|
|
54
|
+
makeClient(),
|
|
55
|
+
{ type: asType(o.type), recipient: o.recipient, quantity: num(o.quantity, "quantity"), months: num(o.months, "months"), currency: o.currency, callback: o.callback, pay: o.pay },
|
|
56
|
+
io
|
|
57
|
+
)
|
|
58
|
+
);
|
|
59
|
+
orders.command("get").argument("<id>").action((id) => cmdOrdersGet(makeClient(), id, io));
|
|
60
|
+
orders.command("ls").option("--status <status>").option("--limit <n>").action((o) => cmdOrdersList(makeClient(), { status: o.status, limit: num(o.limit, "limit") }, io));
|
|
61
|
+
orders.command("cancel").argument("<id>").action((id) => cmdOrdersCancel(makeClient(), id, io));
|
|
62
|
+
program.command("watch").description("poll an order until it's terminal").argument("<id>").action((id) => cmdWatch(makeClient(), id, io));
|
|
63
|
+
program.command("webhook-verify").description("verify an X-Faas-Signature over a raw body").option(
|
|
64
|
+
"--secret <secret>",
|
|
65
|
+
"tenant webhook secret (PREFER MYSTARS_WEBHOOK_SECRET \u2014 a secret on the command line leaks into `ps` and shell history)"
|
|
66
|
+
).requiredOption("--body <json>").requiredOption("--signature <sig>").action(
|
|
67
|
+
(o) => cmdWebhookVerify({ secret: resolveWebhookSecret(o.secret), body: o.body, signature: o.signature }, io)
|
|
68
|
+
);
|
|
69
|
+
program.parseAsync(process.argv).catch((e) => {
|
|
70
|
+
io.err(e instanceof Error ? e.message : String(e));
|
|
71
|
+
process.exit(1);
|
|
72
|
+
});
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
// src/commands.ts
|
|
2
|
+
import {
|
|
3
|
+
buildPaymentRequest,
|
|
4
|
+
verifyWebhookSignature
|
|
5
|
+
} from "@mystars-tg/faas-sdk";
|
|
6
|
+
function print(io, value) {
|
|
7
|
+
io.out(JSON.stringify(value, null, 2));
|
|
8
|
+
}
|
|
9
|
+
async function cmdPricing(client, opts, io) {
|
|
10
|
+
const quote = opts.type === "stars" ? await client.getPricing({ type: "stars", quantity: opts.quantity, payment_currency: opts.currency }) : await client.getPricing({ type: "premium", months: opts.months, payment_currency: opts.currency });
|
|
11
|
+
print(io, quote);
|
|
12
|
+
}
|
|
13
|
+
async function cmdProducts(client, io) {
|
|
14
|
+
print(io, await client.listProducts());
|
|
15
|
+
}
|
|
16
|
+
async function cmdCurrencies(client, io) {
|
|
17
|
+
print(io, await client.listCurrencies());
|
|
18
|
+
}
|
|
19
|
+
async function cmdRecipientCheck(client, opts, io) {
|
|
20
|
+
const res = opts.type === "stars" ? await client.checkRecipient({ type: "stars", recipient: { username: opts.username } }) : await client.checkRecipient({ type: "premium", recipient: { username: opts.username }, months: opts.months });
|
|
21
|
+
print(io, res);
|
|
22
|
+
}
|
|
23
|
+
async function cmdOrdersCreate(client, opts, io) {
|
|
24
|
+
const order = opts.type === "stars" ? await client.createOrder({ type: "stars", recipient: { username: opts.recipient }, quantity: opts.quantity, payment_currency: opts.currency, callback_url: opts.callback }) : await client.createOrder({ type: "premium", recipient: { username: opts.recipient }, months: opts.months, payment_currency: opts.currency, callback_url: opts.callback });
|
|
25
|
+
if (opts.pay) {
|
|
26
|
+
print(io, { order, payment_request: buildPaymentRequest(order.payment) });
|
|
27
|
+
} else {
|
|
28
|
+
print(io, order);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
async function cmdOrdersGet(client, id, io) {
|
|
32
|
+
print(io, await client.getOrder(id));
|
|
33
|
+
}
|
|
34
|
+
async function cmdOrdersList(client, opts, io) {
|
|
35
|
+
const page = await client.listOrders(opts).page();
|
|
36
|
+
print(io, page);
|
|
37
|
+
}
|
|
38
|
+
async function cmdOrdersCancel(client, id, io) {
|
|
39
|
+
print(io, await client.cancelOrder(id));
|
|
40
|
+
}
|
|
41
|
+
async function cmdWatch(client, id, io) {
|
|
42
|
+
const final = await client.waitForOrder(id, {
|
|
43
|
+
onUpdate: (o) => io.err(`status: ${o.status}`)
|
|
44
|
+
});
|
|
45
|
+
print(io, final);
|
|
46
|
+
}
|
|
47
|
+
function resolveWebhookSecret(optSecret, env = process.env) {
|
|
48
|
+
const secret = env.MYSTARS_WEBHOOK_SECRET || optSecret;
|
|
49
|
+
if (!secret) {
|
|
50
|
+
throw new Error("a webhook secret is required (set MYSTARS_WEBHOOK_SECRET, or pass --secret <secret>)");
|
|
51
|
+
}
|
|
52
|
+
return secret;
|
|
53
|
+
}
|
|
54
|
+
async function cmdWebhookVerify(opts, io) {
|
|
55
|
+
const valid = await verifyWebhookSignature(opts.body, opts.signature, opts.secret);
|
|
56
|
+
print(io, { valid });
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export {
|
|
60
|
+
cmdPricing,
|
|
61
|
+
cmdProducts,
|
|
62
|
+
cmdCurrencies,
|
|
63
|
+
cmdRecipientCheck,
|
|
64
|
+
cmdOrdersCreate,
|
|
65
|
+
cmdOrdersGet,
|
|
66
|
+
cmdOrdersList,
|
|
67
|
+
cmdOrdersCancel,
|
|
68
|
+
cmdWatch,
|
|
69
|
+
resolveWebhookSecret,
|
|
70
|
+
cmdWebhookVerify
|
|
71
|
+
};
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/index.ts
|
|
21
|
+
var index_exports = {};
|
|
22
|
+
__export(index_exports, {
|
|
23
|
+
cmdCurrencies: () => cmdCurrencies,
|
|
24
|
+
cmdOrdersCancel: () => cmdOrdersCancel,
|
|
25
|
+
cmdOrdersCreate: () => cmdOrdersCreate,
|
|
26
|
+
cmdOrdersGet: () => cmdOrdersGet,
|
|
27
|
+
cmdOrdersList: () => cmdOrdersList,
|
|
28
|
+
cmdPricing: () => cmdPricing,
|
|
29
|
+
cmdProducts: () => cmdProducts,
|
|
30
|
+
cmdRecipientCheck: () => cmdRecipientCheck,
|
|
31
|
+
cmdWatch: () => cmdWatch,
|
|
32
|
+
cmdWebhookVerify: () => cmdWebhookVerify
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(index_exports);
|
|
35
|
+
|
|
36
|
+
// src/commands.ts
|
|
37
|
+
var import_faas_sdk = require("@mystars-tg/faas-sdk");
|
|
38
|
+
function print(io, value) {
|
|
39
|
+
io.out(JSON.stringify(value, null, 2));
|
|
40
|
+
}
|
|
41
|
+
async function cmdPricing(client, opts, io) {
|
|
42
|
+
const quote = opts.type === "stars" ? await client.getPricing({ type: "stars", quantity: opts.quantity, payment_currency: opts.currency }) : await client.getPricing({ type: "premium", months: opts.months, payment_currency: opts.currency });
|
|
43
|
+
print(io, quote);
|
|
44
|
+
}
|
|
45
|
+
async function cmdProducts(client, io) {
|
|
46
|
+
print(io, await client.listProducts());
|
|
47
|
+
}
|
|
48
|
+
async function cmdCurrencies(client, io) {
|
|
49
|
+
print(io, await client.listCurrencies());
|
|
50
|
+
}
|
|
51
|
+
async function cmdRecipientCheck(client, opts, io) {
|
|
52
|
+
const res = opts.type === "stars" ? await client.checkRecipient({ type: "stars", recipient: { username: opts.username } }) : await client.checkRecipient({ type: "premium", recipient: { username: opts.username }, months: opts.months });
|
|
53
|
+
print(io, res);
|
|
54
|
+
}
|
|
55
|
+
async function cmdOrdersCreate(client, opts, io) {
|
|
56
|
+
const order = opts.type === "stars" ? await client.createOrder({ type: "stars", recipient: { username: opts.recipient }, quantity: opts.quantity, payment_currency: opts.currency, callback_url: opts.callback }) : await client.createOrder({ type: "premium", recipient: { username: opts.recipient }, months: opts.months, payment_currency: opts.currency, callback_url: opts.callback });
|
|
57
|
+
if (opts.pay) {
|
|
58
|
+
print(io, { order, payment_request: (0, import_faas_sdk.buildPaymentRequest)(order.payment) });
|
|
59
|
+
} else {
|
|
60
|
+
print(io, order);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
async function cmdOrdersGet(client, id, io) {
|
|
64
|
+
print(io, await client.getOrder(id));
|
|
65
|
+
}
|
|
66
|
+
async function cmdOrdersList(client, opts, io) {
|
|
67
|
+
const page = await client.listOrders(opts).page();
|
|
68
|
+
print(io, page);
|
|
69
|
+
}
|
|
70
|
+
async function cmdOrdersCancel(client, id, io) {
|
|
71
|
+
print(io, await client.cancelOrder(id));
|
|
72
|
+
}
|
|
73
|
+
async function cmdWatch(client, id, io) {
|
|
74
|
+
const final = await client.waitForOrder(id, {
|
|
75
|
+
onUpdate: (o) => io.err(`status: ${o.status}`)
|
|
76
|
+
});
|
|
77
|
+
print(io, final);
|
|
78
|
+
}
|
|
79
|
+
async function cmdWebhookVerify(opts, io) {
|
|
80
|
+
const valid = await (0, import_faas_sdk.verifyWebhookSignature)(opts.body, opts.signature, opts.secret);
|
|
81
|
+
print(io, { valid });
|
|
82
|
+
}
|
|
83
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
84
|
+
0 && (module.exports = {
|
|
85
|
+
cmdCurrencies,
|
|
86
|
+
cmdOrdersCancel,
|
|
87
|
+
cmdOrdersCreate,
|
|
88
|
+
cmdOrdersGet,
|
|
89
|
+
cmdOrdersList,
|
|
90
|
+
cmdPricing,
|
|
91
|
+
cmdProducts,
|
|
92
|
+
cmdRecipientCheck,
|
|
93
|
+
cmdWatch,
|
|
94
|
+
cmdWebhookVerify
|
|
95
|
+
});
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import { MyStarsClient, OrderType, Currency, OrderStatus } from '@mystars-tg/faas-sdk';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* CLI command handlers — pure-ish functions that take a client + parsed options +
|
|
5
|
+
* an IO sink, so they're unit-testable without spawning a process.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* The IO sink a command writes to — injected so commands are unit-testable
|
|
10
|
+
* without touching the real process streams. The `mystars-faas` bin wires
|
|
11
|
+
* `out` to stdout and `err` to stderr.
|
|
12
|
+
*/
|
|
13
|
+
interface CliIO {
|
|
14
|
+
/** Primary (machine-readable) output — pretty-printed JSON goes here. */
|
|
15
|
+
out: (line: string) => void;
|
|
16
|
+
/** Diagnostics / progress (e.g. status updates from `watch`) go here. */
|
|
17
|
+
err: (line: string) => void;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* `pricing` — quote the all-in price for an item and print the `PricingQuote` JSON.
|
|
21
|
+
*
|
|
22
|
+
* @param client - a configured {@link MyStarsClient}
|
|
23
|
+
* @param opts - `type` plus `quantity` (stars) or `months` (premium), and an optional `currency`
|
|
24
|
+
* @param io - the output sink
|
|
25
|
+
* @returns resolves once the quote has been printed
|
|
26
|
+
* @throws `MyStarsValidationError` if `quantity`/`months` is out of range
|
|
27
|
+
* @throws `MyStarsApiError` on an API failure (e.g. 503 when a price source is down)
|
|
28
|
+
*/
|
|
29
|
+
declare function cmdPricing(client: MyStarsClient, opts: {
|
|
30
|
+
type: OrderType;
|
|
31
|
+
quantity?: number;
|
|
32
|
+
months?: number;
|
|
33
|
+
currency?: Currency;
|
|
34
|
+
}, io: CliIO): Promise<void>;
|
|
35
|
+
/**
|
|
36
|
+
* `products` — print the price-free product catalog (`GET /v1/products`).
|
|
37
|
+
*
|
|
38
|
+
* @param client - a configured {@link MyStarsClient}
|
|
39
|
+
* @param io - the output sink
|
|
40
|
+
* @returns resolves once the catalog has been printed
|
|
41
|
+
* @throws `MyStarsApiError` on an API failure
|
|
42
|
+
*/
|
|
43
|
+
declare function cmdProducts(client: MyStarsClient, io: CliIO): Promise<void>;
|
|
44
|
+
/**
|
|
45
|
+
* `currencies` — print the supported on-chain payment currencies (`GET /v1/currencies`).
|
|
46
|
+
*
|
|
47
|
+
* @param client - a configured {@link MyStarsClient}
|
|
48
|
+
* @param io - the output sink
|
|
49
|
+
* @returns resolves once the currency list has been printed
|
|
50
|
+
* @throws `MyStarsApiError` on an API failure
|
|
51
|
+
*/
|
|
52
|
+
declare function cmdCurrencies(client: MyStarsClient, io: CliIO): Promise<void>;
|
|
53
|
+
/**
|
|
54
|
+
* `recipient-check` — resolve a `@username` and print eligibility (`POST /v1/recipients/check`).
|
|
55
|
+
*
|
|
56
|
+
* @param client - a configured {@link MyStarsClient}
|
|
57
|
+
* @param opts - `type`, the `username` (with or without a leading `@`), and `months` for premium
|
|
58
|
+
* @param io - the output sink
|
|
59
|
+
* @returns resolves once the result has been printed
|
|
60
|
+
* @throws `MyStarsValidationError` if the username is malformed
|
|
61
|
+
* @throws `MyStarsApiError` on an API failure
|
|
62
|
+
*/
|
|
63
|
+
declare function cmdRecipientCheck(client: MyStarsClient, opts: {
|
|
64
|
+
type: OrderType;
|
|
65
|
+
username: string;
|
|
66
|
+
months?: number;
|
|
67
|
+
}, io: CliIO): Promise<void>;
|
|
68
|
+
/**
|
|
69
|
+
* `orders create` — create an order (`POST /v1/orders`) and print it. With
|
|
70
|
+
* `pay: true` it also prints a non-custodial `payment_request` (deeplink / QR /
|
|
71
|
+
* TON Connect) built from the order's payment block.
|
|
72
|
+
*
|
|
73
|
+
* NOTE: the CLI does not pass a stable idempotency key, so the client mints a
|
|
74
|
+
* fresh uuid per invocation — fine for interactive one-offs, but for scripted /
|
|
75
|
+
* automated creation prefer the SDK with a caller-stable `idempotencyKey`.
|
|
76
|
+
*
|
|
77
|
+
* @param client - a configured {@link MyStarsClient}
|
|
78
|
+
* @param opts - `type`, `recipient` username, sizing (`quantity`/`months`), optional `currency`, `callback` URL, and `pay` to also emit a payment request
|
|
79
|
+
* @param io - the output sink
|
|
80
|
+
* @returns resolves once the order (and optional payment request) has been printed
|
|
81
|
+
* @throws `MyStarsValidationError` if inputs are invalid
|
|
82
|
+
* @throws `RecipientIneligibleError` (422) if the recipient cannot receive the item
|
|
83
|
+
* @throws `MyStarsApiError` on any other API failure
|
|
84
|
+
*/
|
|
85
|
+
declare function cmdOrdersCreate(client: MyStarsClient, opts: {
|
|
86
|
+
type: OrderType;
|
|
87
|
+
recipient: string;
|
|
88
|
+
quantity?: number;
|
|
89
|
+
months?: number;
|
|
90
|
+
currency?: Currency;
|
|
91
|
+
callback?: string;
|
|
92
|
+
pay?: boolean;
|
|
93
|
+
}, io: CliIO): Promise<void>;
|
|
94
|
+
/**
|
|
95
|
+
* `orders get` — fetch one order by id (`GET /v1/orders/:id`) and print it.
|
|
96
|
+
*
|
|
97
|
+
* @param client - a configured {@link MyStarsClient}
|
|
98
|
+
* @param id - the order UUID
|
|
99
|
+
* @param io - the output sink
|
|
100
|
+
* @returns resolves once the order has been printed
|
|
101
|
+
* @throws `NotFoundError` (404) if no such order exists for this tenant
|
|
102
|
+
* @throws `MyStarsApiError` on any other API failure
|
|
103
|
+
*/
|
|
104
|
+
declare function cmdOrdersGet(client: MyStarsClient, id: string, io: CliIO): Promise<void>;
|
|
105
|
+
/**
|
|
106
|
+
* `orders list` — print a SINGLE page of orders (`GET /v1/orders`), optionally
|
|
107
|
+
* filtered by `status`. (The CLI prints one page; use the SDK's `listOrders`
|
|
108
|
+
* async iterator to walk every page.)
|
|
109
|
+
*
|
|
110
|
+
* @param client - a configured {@link MyStarsClient}
|
|
111
|
+
* @param opts - optional `status` filter and `limit` (1-100, server default 50)
|
|
112
|
+
* @param io - the output sink
|
|
113
|
+
* @returns resolves once the page has been printed
|
|
114
|
+
* @throws `MyStarsApiError` on an API failure
|
|
115
|
+
*/
|
|
116
|
+
declare function cmdOrdersList(client: MyStarsClient, opts: {
|
|
117
|
+
status?: OrderStatus;
|
|
118
|
+
limit?: number;
|
|
119
|
+
}, io: CliIO): Promise<void>;
|
|
120
|
+
/**
|
|
121
|
+
* `orders cancel` — cancel an `awaiting_payment` order (`POST /v1/orders/:id/cancel`) and print the result.
|
|
122
|
+
*
|
|
123
|
+
* @param client - a configured {@link MyStarsClient}
|
|
124
|
+
* @param id - the order UUID
|
|
125
|
+
* @param io - the output sink
|
|
126
|
+
* @returns resolves once the cancel result has been printed
|
|
127
|
+
* @throws `OrderNotCancellableError` (409) if the order is no longer `awaiting_payment`
|
|
128
|
+
* @throws `MyStarsApiError` on any other API failure
|
|
129
|
+
*/
|
|
130
|
+
declare function cmdOrdersCancel(client: MyStarsClient, id: string, io: CliIO): Promise<void>;
|
|
131
|
+
/**
|
|
132
|
+
* `watch` — poll an order until it reaches a terminal state, streaming each
|
|
133
|
+
* status change to `io.err`, then print the final order to `io.out`.
|
|
134
|
+
*
|
|
135
|
+
* @param client - a configured {@link MyStarsClient}
|
|
136
|
+
* @param id - the order UUID
|
|
137
|
+
* @param io - the output sink (status updates → `err`, final order → `out`)
|
|
138
|
+
* @returns resolves once the order is terminal and has been printed
|
|
139
|
+
* @throws `OrderWaitTimeoutError` if the order does not finish before the default deadline
|
|
140
|
+
* @throws `MyStarsApiError` on an API failure during polling
|
|
141
|
+
*/
|
|
142
|
+
declare function cmdWatch(client: MyStarsClient, id: string, io: CliIO): Promise<void>;
|
|
143
|
+
/**
|
|
144
|
+
* `webhook-verify` — verify an `X-Faas-Signature` over a raw webhook body and
|
|
145
|
+
* print `{ valid: boolean }`. Does NOT need a client (offline HMAC check).
|
|
146
|
+
*
|
|
147
|
+
* @param opts - the tenant `secret`, the raw `body` string, and the `signature` header value
|
|
148
|
+
* @param io - the output sink
|
|
149
|
+
* @returns resolves once `{ valid }` has been printed (never throws on a bad signature — it prints `false`)
|
|
150
|
+
*/
|
|
151
|
+
declare function cmdWebhookVerify(opts: {
|
|
152
|
+
secret: string;
|
|
153
|
+
body: string;
|
|
154
|
+
signature: string;
|
|
155
|
+
}, io: CliIO): Promise<void>;
|
|
156
|
+
|
|
157
|
+
export { type CliIO, cmdCurrencies, cmdOrdersCancel, cmdOrdersCreate, cmdOrdersGet, cmdOrdersList, cmdPricing, cmdProducts, cmdRecipientCheck, cmdWatch, cmdWebhookVerify };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import { MyStarsClient, OrderType, Currency, OrderStatus } from '@mystars-tg/faas-sdk';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* CLI command handlers — pure-ish functions that take a client + parsed options +
|
|
5
|
+
* an IO sink, so they're unit-testable without spawning a process.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* The IO sink a command writes to — injected so commands are unit-testable
|
|
10
|
+
* without touching the real process streams. The `mystars-faas` bin wires
|
|
11
|
+
* `out` to stdout and `err` to stderr.
|
|
12
|
+
*/
|
|
13
|
+
interface CliIO {
|
|
14
|
+
/** Primary (machine-readable) output — pretty-printed JSON goes here. */
|
|
15
|
+
out: (line: string) => void;
|
|
16
|
+
/** Diagnostics / progress (e.g. status updates from `watch`) go here. */
|
|
17
|
+
err: (line: string) => void;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* `pricing` — quote the all-in price for an item and print the `PricingQuote` JSON.
|
|
21
|
+
*
|
|
22
|
+
* @param client - a configured {@link MyStarsClient}
|
|
23
|
+
* @param opts - `type` plus `quantity` (stars) or `months` (premium), and an optional `currency`
|
|
24
|
+
* @param io - the output sink
|
|
25
|
+
* @returns resolves once the quote has been printed
|
|
26
|
+
* @throws `MyStarsValidationError` if `quantity`/`months` is out of range
|
|
27
|
+
* @throws `MyStarsApiError` on an API failure (e.g. 503 when a price source is down)
|
|
28
|
+
*/
|
|
29
|
+
declare function cmdPricing(client: MyStarsClient, opts: {
|
|
30
|
+
type: OrderType;
|
|
31
|
+
quantity?: number;
|
|
32
|
+
months?: number;
|
|
33
|
+
currency?: Currency;
|
|
34
|
+
}, io: CliIO): Promise<void>;
|
|
35
|
+
/**
|
|
36
|
+
* `products` — print the price-free product catalog (`GET /v1/products`).
|
|
37
|
+
*
|
|
38
|
+
* @param client - a configured {@link MyStarsClient}
|
|
39
|
+
* @param io - the output sink
|
|
40
|
+
* @returns resolves once the catalog has been printed
|
|
41
|
+
* @throws `MyStarsApiError` on an API failure
|
|
42
|
+
*/
|
|
43
|
+
declare function cmdProducts(client: MyStarsClient, io: CliIO): Promise<void>;
|
|
44
|
+
/**
|
|
45
|
+
* `currencies` — print the supported on-chain payment currencies (`GET /v1/currencies`).
|
|
46
|
+
*
|
|
47
|
+
* @param client - a configured {@link MyStarsClient}
|
|
48
|
+
* @param io - the output sink
|
|
49
|
+
* @returns resolves once the currency list has been printed
|
|
50
|
+
* @throws `MyStarsApiError` on an API failure
|
|
51
|
+
*/
|
|
52
|
+
declare function cmdCurrencies(client: MyStarsClient, io: CliIO): Promise<void>;
|
|
53
|
+
/**
|
|
54
|
+
* `recipient-check` — resolve a `@username` and print eligibility (`POST /v1/recipients/check`).
|
|
55
|
+
*
|
|
56
|
+
* @param client - a configured {@link MyStarsClient}
|
|
57
|
+
* @param opts - `type`, the `username` (with or without a leading `@`), and `months` for premium
|
|
58
|
+
* @param io - the output sink
|
|
59
|
+
* @returns resolves once the result has been printed
|
|
60
|
+
* @throws `MyStarsValidationError` if the username is malformed
|
|
61
|
+
* @throws `MyStarsApiError` on an API failure
|
|
62
|
+
*/
|
|
63
|
+
declare function cmdRecipientCheck(client: MyStarsClient, opts: {
|
|
64
|
+
type: OrderType;
|
|
65
|
+
username: string;
|
|
66
|
+
months?: number;
|
|
67
|
+
}, io: CliIO): Promise<void>;
|
|
68
|
+
/**
|
|
69
|
+
* `orders create` — create an order (`POST /v1/orders`) and print it. With
|
|
70
|
+
* `pay: true` it also prints a non-custodial `payment_request` (deeplink / QR /
|
|
71
|
+
* TON Connect) built from the order's payment block.
|
|
72
|
+
*
|
|
73
|
+
* NOTE: the CLI does not pass a stable idempotency key, so the client mints a
|
|
74
|
+
* fresh uuid per invocation — fine for interactive one-offs, but for scripted /
|
|
75
|
+
* automated creation prefer the SDK with a caller-stable `idempotencyKey`.
|
|
76
|
+
*
|
|
77
|
+
* @param client - a configured {@link MyStarsClient}
|
|
78
|
+
* @param opts - `type`, `recipient` username, sizing (`quantity`/`months`), optional `currency`, `callback` URL, and `pay` to also emit a payment request
|
|
79
|
+
* @param io - the output sink
|
|
80
|
+
* @returns resolves once the order (and optional payment request) has been printed
|
|
81
|
+
* @throws `MyStarsValidationError` if inputs are invalid
|
|
82
|
+
* @throws `RecipientIneligibleError` (422) if the recipient cannot receive the item
|
|
83
|
+
* @throws `MyStarsApiError` on any other API failure
|
|
84
|
+
*/
|
|
85
|
+
declare function cmdOrdersCreate(client: MyStarsClient, opts: {
|
|
86
|
+
type: OrderType;
|
|
87
|
+
recipient: string;
|
|
88
|
+
quantity?: number;
|
|
89
|
+
months?: number;
|
|
90
|
+
currency?: Currency;
|
|
91
|
+
callback?: string;
|
|
92
|
+
pay?: boolean;
|
|
93
|
+
}, io: CliIO): Promise<void>;
|
|
94
|
+
/**
|
|
95
|
+
* `orders get` — fetch one order by id (`GET /v1/orders/:id`) and print it.
|
|
96
|
+
*
|
|
97
|
+
* @param client - a configured {@link MyStarsClient}
|
|
98
|
+
* @param id - the order UUID
|
|
99
|
+
* @param io - the output sink
|
|
100
|
+
* @returns resolves once the order has been printed
|
|
101
|
+
* @throws `NotFoundError` (404) if no such order exists for this tenant
|
|
102
|
+
* @throws `MyStarsApiError` on any other API failure
|
|
103
|
+
*/
|
|
104
|
+
declare function cmdOrdersGet(client: MyStarsClient, id: string, io: CliIO): Promise<void>;
|
|
105
|
+
/**
|
|
106
|
+
* `orders list` — print a SINGLE page of orders (`GET /v1/orders`), optionally
|
|
107
|
+
* filtered by `status`. (The CLI prints one page; use the SDK's `listOrders`
|
|
108
|
+
* async iterator to walk every page.)
|
|
109
|
+
*
|
|
110
|
+
* @param client - a configured {@link MyStarsClient}
|
|
111
|
+
* @param opts - optional `status` filter and `limit` (1-100, server default 50)
|
|
112
|
+
* @param io - the output sink
|
|
113
|
+
* @returns resolves once the page has been printed
|
|
114
|
+
* @throws `MyStarsApiError` on an API failure
|
|
115
|
+
*/
|
|
116
|
+
declare function cmdOrdersList(client: MyStarsClient, opts: {
|
|
117
|
+
status?: OrderStatus;
|
|
118
|
+
limit?: number;
|
|
119
|
+
}, io: CliIO): Promise<void>;
|
|
120
|
+
/**
|
|
121
|
+
* `orders cancel` — cancel an `awaiting_payment` order (`POST /v1/orders/:id/cancel`) and print the result.
|
|
122
|
+
*
|
|
123
|
+
* @param client - a configured {@link MyStarsClient}
|
|
124
|
+
* @param id - the order UUID
|
|
125
|
+
* @param io - the output sink
|
|
126
|
+
* @returns resolves once the cancel result has been printed
|
|
127
|
+
* @throws `OrderNotCancellableError` (409) if the order is no longer `awaiting_payment`
|
|
128
|
+
* @throws `MyStarsApiError` on any other API failure
|
|
129
|
+
*/
|
|
130
|
+
declare function cmdOrdersCancel(client: MyStarsClient, id: string, io: CliIO): Promise<void>;
|
|
131
|
+
/**
|
|
132
|
+
* `watch` — poll an order until it reaches a terminal state, streaming each
|
|
133
|
+
* status change to `io.err`, then print the final order to `io.out`.
|
|
134
|
+
*
|
|
135
|
+
* @param client - a configured {@link MyStarsClient}
|
|
136
|
+
* @param id - the order UUID
|
|
137
|
+
* @param io - the output sink (status updates → `err`, final order → `out`)
|
|
138
|
+
* @returns resolves once the order is terminal and has been printed
|
|
139
|
+
* @throws `OrderWaitTimeoutError` if the order does not finish before the default deadline
|
|
140
|
+
* @throws `MyStarsApiError` on an API failure during polling
|
|
141
|
+
*/
|
|
142
|
+
declare function cmdWatch(client: MyStarsClient, id: string, io: CliIO): Promise<void>;
|
|
143
|
+
/**
|
|
144
|
+
* `webhook-verify` — verify an `X-Faas-Signature` over a raw webhook body and
|
|
145
|
+
* print `{ valid: boolean }`. Does NOT need a client (offline HMAC check).
|
|
146
|
+
*
|
|
147
|
+
* @param opts - the tenant `secret`, the raw `body` string, and the `signature` header value
|
|
148
|
+
* @param io - the output sink
|
|
149
|
+
* @returns resolves once `{ valid }` has been printed (never throws on a bad signature — it prints `false`)
|
|
150
|
+
*/
|
|
151
|
+
declare function cmdWebhookVerify(opts: {
|
|
152
|
+
secret: string;
|
|
153
|
+
body: string;
|
|
154
|
+
signature: string;
|
|
155
|
+
}, io: CliIO): Promise<void>;
|
|
156
|
+
|
|
157
|
+
export { type CliIO, cmdCurrencies, cmdOrdersCancel, cmdOrdersCreate, cmdOrdersGet, cmdOrdersList, cmdPricing, cmdProducts, cmdRecipientCheck, cmdWatch, cmdWebhookVerify };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import {
|
|
2
|
+
cmdCurrencies,
|
|
3
|
+
cmdOrdersCancel,
|
|
4
|
+
cmdOrdersCreate,
|
|
5
|
+
cmdOrdersGet,
|
|
6
|
+
cmdOrdersList,
|
|
7
|
+
cmdPricing,
|
|
8
|
+
cmdProducts,
|
|
9
|
+
cmdRecipientCheck,
|
|
10
|
+
cmdWatch,
|
|
11
|
+
cmdWebhookVerify
|
|
12
|
+
} from "./chunk-LVDNP4X2.js";
|
|
13
|
+
export {
|
|
14
|
+
cmdCurrencies,
|
|
15
|
+
cmdOrdersCancel,
|
|
16
|
+
cmdOrdersCreate,
|
|
17
|
+
cmdOrdersGet,
|
|
18
|
+
cmdOrdersList,
|
|
19
|
+
cmdPricing,
|
|
20
|
+
cmdProducts,
|
|
21
|
+
cmdRecipientCheck,
|
|
22
|
+
cmdWatch,
|
|
23
|
+
cmdWebhookVerify
|
|
24
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@mystars-tg/faas-cli",
|
|
3
|
+
"version": "0.1.2",
|
|
4
|
+
"description": "Command-line tool for the MyStars FaaS API — pricing, recipient checks, order management, payment links, and webhook verification.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"author": "MyStars.tg",
|
|
7
|
+
"publishConfig": {
|
|
8
|
+
"access": "public"
|
|
9
|
+
},
|
|
10
|
+
"type": "module",
|
|
11
|
+
"engines": {
|
|
12
|
+
"node": ">=18"
|
|
13
|
+
},
|
|
14
|
+
"keywords": ["telegram", "stars", "premium", "ton", "usdt", "mystars", "faas", "cli"],
|
|
15
|
+
"homepage": "https://mystars.tg/docs",
|
|
16
|
+
"repository": {
|
|
17
|
+
"type": "git",
|
|
18
|
+
"url": "https://github.com/mystars-tg/faas-ts.git"
|
|
19
|
+
},
|
|
20
|
+
"bugs": {
|
|
21
|
+
"url": "https://github.com/mystars-tg/faas-ts/issues"
|
|
22
|
+
},
|
|
23
|
+
"bin": {
|
|
24
|
+
"mystars-faas": "./dist/bin.js"
|
|
25
|
+
},
|
|
26
|
+
"exports": {
|
|
27
|
+
".": {
|
|
28
|
+
"types": "./dist/index.d.ts",
|
|
29
|
+
"import": "./dist/index.js",
|
|
30
|
+
"require": "./dist/index.cjs"
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
"files": ["dist", "README.md", "LICENSE"],
|
|
34
|
+
"scripts": {
|
|
35
|
+
"build": "tsup",
|
|
36
|
+
"typecheck": "tsc --noEmit",
|
|
37
|
+
"test": "vitest run --root ../..",
|
|
38
|
+
"prepublishOnly": "npm run build"
|
|
39
|
+
},
|
|
40
|
+
"dependencies": {
|
|
41
|
+
"@mystars-tg/faas-sdk": "^0.1.2",
|
|
42
|
+
"commander": "^12.1.0"
|
|
43
|
+
}
|
|
44
|
+
}
|