@shieldz/cli 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +20 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +96 -0
- package/package.json +21 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Deniz Yanbollu / Shieldz
|
|
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,20 @@
|
|
|
1
|
+
# @shieldz/cli
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/@shieldz/cli)
|
|
4
|
+
|
|
5
|
+
Command-line interface for [Shieldz](https://shieldz.cash) — non-custodial crypto payments.
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install -g @shieldz/cli
|
|
9
|
+
export SHIELDZ_API_KEY=sk_live_…
|
|
10
|
+
|
|
11
|
+
shieldz invoices create --amount 5000 --memo "Order #1234"
|
|
12
|
+
shieldz invoices get <id>
|
|
13
|
+
shieldz invoices list --status paid --limit 10
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
Or run without installing: `npx @shieldz/cli invoices list`.
|
|
17
|
+
|
|
18
|
+
## License
|
|
19
|
+
|
|
20
|
+
MIT © Deniz Yanbollu / Shieldz
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import Shieldz, { ShieldzError } from "@shieldz/sdk";
|
|
3
|
+
const VERSION = "0.1.0";
|
|
4
|
+
function parseFlags(args) {
|
|
5
|
+
const out = {};
|
|
6
|
+
for (let i = 0; i < args.length; i++) {
|
|
7
|
+
const a = args[i];
|
|
8
|
+
if (a.startsWith("--")) {
|
|
9
|
+
const key = a.slice(2);
|
|
10
|
+
const next = args[i + 1];
|
|
11
|
+
if (next && !next.startsWith("--")) {
|
|
12
|
+
out[key] = next;
|
|
13
|
+
i++;
|
|
14
|
+
}
|
|
15
|
+
else {
|
|
16
|
+
out[key] = true;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return out;
|
|
21
|
+
}
|
|
22
|
+
function client() {
|
|
23
|
+
const key = process.env.SHIELDZ_API_KEY;
|
|
24
|
+
if (!key) {
|
|
25
|
+
console.error("shieldz: set SHIELDZ_API_KEY (sk_live_… or sk_test_…)");
|
|
26
|
+
process.exit(1);
|
|
27
|
+
}
|
|
28
|
+
return new Shieldz(key);
|
|
29
|
+
}
|
|
30
|
+
const HELP = `shieldz ${VERSION} — non-custodial crypto payments
|
|
31
|
+
|
|
32
|
+
Usage:
|
|
33
|
+
shieldz invoices create --amount <usd_cents> [--memo <text>] [--email <addr>]
|
|
34
|
+
shieldz invoices get <id>
|
|
35
|
+
shieldz invoices list [--limit <n>] [--status <pending|paid|expired|failed>]
|
|
36
|
+
|
|
37
|
+
Auth: set SHIELDZ_API_KEY in your environment.
|
|
38
|
+
Docs: https://shieldz.cash/docs`;
|
|
39
|
+
async function main() {
|
|
40
|
+
const [, , ...argv] = process.argv;
|
|
41
|
+
const [group, action, ...rest] = argv;
|
|
42
|
+
if (!group || group === "--help" || group === "-h" || group === "help") {
|
|
43
|
+
console.log(HELP);
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
if (group === "--version" || group === "-v") {
|
|
47
|
+
console.log(VERSION);
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
if (group === "invoices") {
|
|
51
|
+
const shieldz = client();
|
|
52
|
+
const flags = parseFlags(rest);
|
|
53
|
+
if (action === "create") {
|
|
54
|
+
const amount = Number(flags.amount);
|
|
55
|
+
if (!Number.isInteger(amount)) {
|
|
56
|
+
console.error("shieldz: --amount <usd_cents> is required (integer)");
|
|
57
|
+
process.exit(1);
|
|
58
|
+
}
|
|
59
|
+
const inv = await shieldz.invoices.create({
|
|
60
|
+
amount_usd_cents: amount,
|
|
61
|
+
...(flags.memo ? { memo: String(flags.memo) } : {}),
|
|
62
|
+
...(flags.email ? { customer_email: String(flags.email) } : {}),
|
|
63
|
+
});
|
|
64
|
+
console.log(JSON.stringify(inv, null, 2));
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
if (action === "get") {
|
|
68
|
+
const id = rest[0];
|
|
69
|
+
if (!id) {
|
|
70
|
+
console.error("shieldz: invoices get <id>");
|
|
71
|
+
process.exit(1);
|
|
72
|
+
}
|
|
73
|
+
console.log(JSON.stringify(await shieldz.invoices.retrieve(id), null, 2));
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
if (action === "list") {
|
|
77
|
+
const page = await shieldz.invoices.list({
|
|
78
|
+
...(flags.limit ? { limit: Number(flags.limit) } : {}),
|
|
79
|
+
...(flags.status ? { status: String(flags.status) } : {}),
|
|
80
|
+
});
|
|
81
|
+
console.log(JSON.stringify(page, null, 2));
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
console.error(`shieldz: unknown command. Run \`shieldz --help\`.`);
|
|
86
|
+
process.exit(1);
|
|
87
|
+
}
|
|
88
|
+
main().catch((err) => {
|
|
89
|
+
if (err instanceof ShieldzError) {
|
|
90
|
+
console.error(`shieldz: error ${err.status} ${err.type}/${err.code}: ${err.message}`);
|
|
91
|
+
}
|
|
92
|
+
else {
|
|
93
|
+
console.error("shieldz:", err instanceof Error ? err.message : err);
|
|
94
|
+
}
|
|
95
|
+
process.exit(1);
|
|
96
|
+
});
|
package/package.json
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@shieldz/cli",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Command-line interface for Shieldz — create and inspect non-custodial crypto payment invoices from your terminal.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bin": { "shieldz": "dist/index.js" },
|
|
7
|
+
"files": ["dist", "README.md", "LICENSE"],
|
|
8
|
+
"engines": { "node": ">=18" },
|
|
9
|
+
"scripts": {
|
|
10
|
+
"build": "tsc -p tsconfig.json",
|
|
11
|
+
"prepublishOnly": "npm run build"
|
|
12
|
+
},
|
|
13
|
+
"keywords": ["shieldz", "cli", "crypto", "payments", "non-custodial", "invoices"],
|
|
14
|
+
"license": "MIT",
|
|
15
|
+
"author": "Deniz Yanbollu (@dnzynbl)",
|
|
16
|
+
"homepage": "https://shieldz.cash",
|
|
17
|
+
"repository": { "type": "git", "url": "git+https://github.com/ShieldZCash/shieldz-cli.git" },
|
|
18
|
+
"bugs": { "url": "https://github.com/ShieldZCash/shieldz-cli/issues" },
|
|
19
|
+
"dependencies": { "@shieldz/sdk": "^0.2.0" },
|
|
20
|
+
"devDependencies": { "typescript": "^5.6.0", "@types/node": "^20.0.0" }
|
|
21
|
+
}
|