mayar 0.1.6 → 0.1.8
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 +40 -16
- package/package.json +4 -4
- package/src/api.js +1 -1
- package/src/cli.js +2 -1
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# mayar
|
|
2
2
|
|
|
3
|
-
Command-line interface for the [Mayar](https://docs.mayar.id) API.
|
|
3
|
+
Command-line interface for the [Mayar](https://docs.mayar.id) API. Zero runtime dependencies — Node.js 18+ stdlib only.
|
|
4
4
|
|
|
5
5
|
## Install
|
|
6
6
|
|
|
@@ -13,26 +13,47 @@ npx mayar --help
|
|
|
13
13
|
Or from source:
|
|
14
14
|
|
|
15
15
|
```bash
|
|
16
|
-
git clone https://github.com/
|
|
16
|
+
git clone https://github.com/mayarid/mayar-cli.git
|
|
17
17
|
cd mayar-cli
|
|
18
18
|
npm link # exposes a `mayar` command on your PATH
|
|
19
19
|
```
|
|
20
20
|
|
|
21
|
-
##
|
|
21
|
+
## Authentication
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
Resolution order: `--api-key` flag → `MAYAR_API_KEY` env → saved config file.
|
|
24
|
+
|
|
25
|
+
**Option 1 — environment variable (recommended for CI/agents):**
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
export MAYAR_API_KEY=your_api_key_here
|
|
29
|
+
mayar whoami
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
**Option 2 — saved config (interactive first run):**
|
|
33
|
+
|
|
34
|
+
The first time you invoke any command without a key configured, the CLI prompts for your production API key (input is masked). Paste it once; it's stored at `~/.config/mayar/config.json` (chmod 600, follows [XDG Base Directory](https://specification.freedesktop.org/basedir-spec/latest/)) and reused on subsequent runs.
|
|
24
35
|
|
|
25
36
|
```bash
|
|
26
37
|
mayar balance
|
|
27
|
-
# ███╗ ███╗ █████╗ ██╗ ██╗ █████╗ ██████╗
|
|
28
|
-
# ...
|
|
29
38
|
# Welcome to Mayar CLI.
|
|
30
39
|
# No API key found. Get yours from https://web.mayar.id → Integration → API Key.
|
|
31
40
|
# Paste your production API key: ************
|
|
32
41
|
# ✓ Saved to /Users/you/.config/mayar/config.json
|
|
33
42
|
```
|
|
34
43
|
|
|
35
|
-
|
|
44
|
+
**Option 3 — non-interactive setup:**
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
mayar api-key YOUR_KEY_HERE
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
**Option 4 — per-command override:**
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
mayar --api-key YOUR_KEY_HERE balance
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
Get your API key from [web.mayar.id](https://web.mayar.id) → Integration → API Key.
|
|
36
57
|
|
|
37
58
|
## Commands
|
|
38
59
|
|
|
@@ -40,11 +61,11 @@ You can also run `mayar init` explicitly to (re-)configure the key, or pass `--a
|
|
|
40
61
|
Setup
|
|
41
62
|
init Run first-time setup (interactive, masked input)
|
|
42
63
|
api-key <key> Save API key non-interactively (e.g. for scripts)
|
|
43
|
-
config show Show masked saved key
|
|
64
|
+
config show Show masked saved key and config path
|
|
44
65
|
config reset Remove the saved key
|
|
45
66
|
|
|
46
67
|
Account
|
|
47
|
-
whoami Show merchant identity (decoded from JWT
|
|
68
|
+
whoami Show merchant identity (decoded from JWT) + verify key
|
|
48
69
|
balance GET /hl/v1/balance
|
|
49
70
|
|
|
50
71
|
Invoices
|
|
@@ -94,14 +115,16 @@ Global flags
|
|
|
94
115
|
-v, --version Show version
|
|
95
116
|
|
|
96
117
|
Environment
|
|
97
|
-
MAYAR_API_KEY
|
|
118
|
+
MAYAR_API_KEY API key — used when --api-key flag is absent and no config is saved
|
|
119
|
+
MAYAR_API_URL Override API base URL (default: https://api.mayar.id)
|
|
98
120
|
```
|
|
99
121
|
|
|
100
|
-
Resolution order: `--api-key` flag → `MAYAR_API_KEY` env → saved config.
|
|
101
|
-
|
|
102
122
|
## Examples
|
|
103
123
|
|
|
104
124
|
```bash
|
|
125
|
+
# Verify active user / API key
|
|
126
|
+
mayar whoami
|
|
127
|
+
|
|
105
128
|
# Account balance
|
|
106
129
|
mayar balance
|
|
107
130
|
|
|
@@ -146,10 +169,10 @@ mayar invoice list --json | jq '.data[] | {id, status}'
|
|
|
146
169
|
|
|
147
170
|
## Config
|
|
148
171
|
|
|
149
|
-
| Key | Value
|
|
150
|
-
| -------- |
|
|
172
|
+
| Key | Value |
|
|
173
|
+
| -------- | ------------------------------------------------------------------------------------------- |
|
|
151
174
|
| Path | `$XDG_CONFIG_HOME/mayar/config.json`, defaulting to `~/.config/mayar/config.json` (chmod 600) |
|
|
152
|
-
| Endpoint | `https://api.mayar.id` (
|
|
175
|
+
| Endpoint | `MAYAR_API_URL` env or `https://api.mayar.id` (default) |
|
|
153
176
|
|
|
154
177
|
Legacy installs that wrote to `~/.mayar/config.json` are migrated automatically on first run.
|
|
155
178
|
|
|
@@ -157,6 +180,7 @@ To rotate keys: `mayar config reset && mayar init`.
|
|
|
157
180
|
|
|
158
181
|
## Notes
|
|
159
182
|
|
|
160
|
-
- Sandbox is intentionally not supported — this CLI hits production only.
|
|
161
183
|
- All requests use `Authorization: Bearer <key>`. Errors print `API <status> — <message>` and exit non-zero.
|
|
162
184
|
- `--data @file.json` reads from disk; `--data '{...}'` reads inline JSON.
|
|
185
|
+
- `MAYAR_API_URL` overrides the base URL — useful for staging or custom proxy environments.
|
|
186
|
+
- `mayar whoami` decodes the JWT locally and verifies the key live against `/hl/v1/balance`.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mayar",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.8",
|
|
4
4
|
"description": "Zero-dependency Node.js CLI for the Mayar API (production endpoint).",
|
|
5
5
|
"bin": {
|
|
6
6
|
"mayar": "bin/mayar.js"
|
|
@@ -23,13 +23,13 @@
|
|
|
23
23
|
],
|
|
24
24
|
"author": "Frianto Moerdowo <frianto@duck.com>",
|
|
25
25
|
"license": "MIT",
|
|
26
|
-
"homepage": "https://github.com/
|
|
26
|
+
"homepage": "https://github.com/mayarid/mayar-cli#readme",
|
|
27
27
|
"repository": {
|
|
28
28
|
"type": "git",
|
|
29
|
-
"url": "git+https://github.com/
|
|
29
|
+
"url": "git+https://github.com/mayarid/mayar-cli.git"
|
|
30
30
|
},
|
|
31
31
|
"bugs": {
|
|
32
|
-
"url": "https://github.com/
|
|
32
|
+
"url": "https://github.com/mayarid/mayar-cli/issues"
|
|
33
33
|
},
|
|
34
34
|
"files": [
|
|
35
35
|
"bin",
|
package/src/api.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const https = require('https');
|
|
2
2
|
const { URL } = require('url');
|
|
3
3
|
|
|
4
|
-
const BASE_URL = 'https://api.mayar.id';
|
|
4
|
+
const BASE_URL = process.env.MAYAR_API_URL || 'https://api.mayar.id';
|
|
5
5
|
const VERSION = require('../package.json').version;
|
|
6
6
|
|
|
7
7
|
function request(method, pathname, { apiKey, body, query } = {}) {
|
package/src/cli.js
CHANGED
|
@@ -66,9 +66,10 @@ ${ui.bold('Global flags:')}
|
|
|
66
66
|
|
|
67
67
|
${ui.bold('Environment:')}
|
|
68
68
|
MAYAR_API_KEY Used when --api-key is not given and no config is saved
|
|
69
|
+
MAYAR_API_URL Override API base URL (default: https://api.mayar.id)
|
|
69
70
|
|
|
70
71
|
${ui.dim('Resolution order: --api-key flag > MAYAR_API_KEY env > saved config.')}
|
|
71
|
-
${ui.dim('Endpoint: https://api.mayar.id (
|
|
72
|
+
${ui.dim('Endpoint: MAYAR_API_URL env or https://api.mayar.id (default)')}
|
|
72
73
|
${ui.dim('Config: ~/.config/mayar/config.json (chmod 600)')}
|
|
73
74
|
`;
|
|
74
75
|
|