@ninefish/cli 0.1.0 → 0.1.1
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 +135 -155
- package/dist/nf.js +25 -19
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -1,188 +1,162 @@
|
|
|
1
1
|
# nf
|
|
2
2
|
|
|
3
|
-
The nine fish
|
|
4
|
-
|
|
3
|
+
The command line for [nine fish](https://nine.fish): sign-in for your apps, on your own domain,
|
|
4
|
+
with your brand. Set up an organisation, verify a domain, forward its mail and register the apps
|
|
5
|
+
your people sign in to.
|
|
5
6
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
```sh
|
|
8
|
+
npm install -g @ninefish/cli
|
|
9
|
+
nf login
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
Needs Node.js 24 or later, and somewhere safe to keep tokens: the macOS Keychain, or on Linux
|
|
13
|
+
the Secret Service (`secret-tool`, from libsecret). nf never writes tokens to a file.
|
|
14
|
+
|
|
15
|
+
## Getting started
|
|
11
16
|
|
|
12
17
|
```sh
|
|
13
|
-
|
|
14
|
-
|
|
18
|
+
nf login # sign in with a passkey in your browser
|
|
19
|
+
nf org create acme # make an organisation; you are its owner
|
|
20
|
+
nf billing setup # add a card (opens a Stripe page)
|
|
21
|
+
nf domain setup example.com # what the domain is for, and every DNS record at once
|
|
22
|
+
nf domain check example.com # verify it, as DNS allows
|
|
23
|
+
nf platform add # register an app; prints what to paste into it
|
|
15
24
|
```
|
|
16
25
|
|
|
26
|
+
`nf help <command>` explains any command, and `nf --help` lists them in this order.
|
|
27
|
+
|
|
17
28
|
## Commands
|
|
18
29
|
|
|
19
|
-
An organisation can be named by its name or its id (`org_…`)
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
`--
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
|
28
|
-
|
|
|
29
|
-
| `nf
|
|
30
|
-
| `nf
|
|
31
|
-
| `nf
|
|
32
|
-
| `nf org
|
|
33
|
-
| `nf org
|
|
34
|
-
| `nf org
|
|
35
|
-
| `nf org
|
|
36
|
-
| `nf org branding
|
|
37
|
-
| `nf org branding
|
|
38
|
-
| `nf org branding remove --domain <domain
|
|
39
|
-
| `nf org
|
|
40
|
-
| `nf org sign-in
|
|
41
|
-
| `nf org
|
|
42
|
-
| `nf org
|
|
43
|
-
| `nf org
|
|
44
|
-
| `nf
|
|
45
|
-
| `nf billing
|
|
46
|
-
| `nf billing
|
|
47
|
-
| `nf
|
|
48
|
-
| `nf domain
|
|
49
|
-
| `nf domain
|
|
50
|
-
| `nf domain
|
|
51
|
-
| `nf domain
|
|
52
|
-
| `nf domain
|
|
53
|
-
| `nf domain
|
|
54
|
-
| `nf domain
|
|
55
|
-
| `nf
|
|
56
|
-
| `nf email route
|
|
57
|
-
| `nf email route
|
|
58
|
-
| `nf email route
|
|
59
|
-
| `nf email route
|
|
60
|
-
| `nf email
|
|
61
|
-
| `nf email destination
|
|
62
|
-
| `nf email destination
|
|
63
|
-
| `nf email destination
|
|
64
|
-
| `nf email destination
|
|
65
|
-
| `nf email
|
|
66
|
-
| `nf email
|
|
67
|
-
| `nf email
|
|
68
|
-
| `nf email
|
|
69
|
-
| `nf email
|
|
70
|
-
| `nf
|
|
71
|
-
| `nf platform add [name]
|
|
72
|
-
| `nf platform
|
|
73
|
-
| `nf platform
|
|
74
|
-
| `nf platform
|
|
75
|
-
| `nf platform callback
|
|
76
|
-
| `nf platform remove <platform>`
|
|
77
|
-
| `nf platform
|
|
78
|
-
| `nf
|
|
79
|
-
| `nf person
|
|
80
|
-
| `nf person
|
|
81
|
-
| `nf person
|
|
82
|
-
| `nf person
|
|
83
|
-
| `nf person
|
|
84
|
-
| `nf person name
|
|
85
|
-
| `nf
|
|
86
|
-
| `nf invite
|
|
87
|
-
| `nf
|
|
88
|
-
| `nf auth-host
|
|
89
|
-
| `nf auth-host
|
|
90
|
-
| `nf auth-host
|
|
91
|
-
| `nf auth-host
|
|
92
|
-
| `nf
|
|
93
|
-
| `nf
|
|
94
|
-
| `nf
|
|
95
|
-
| `nf
|
|
96
|
-
| `nf
|
|
97
|
-
|
|
98
|
-
Bare `nf` and `nf --help` draw the mark (`src/mark.ts`, generated from
|
|
99
|
-
`apps/marketing/public/logo.svg` by `pnpm --filter @ninefish/cli render-mark`) in the
|
|
100
|
-
brand blue, only on a terminal and never with `NO_COLOR` or `TERM=dumb`. With
|
|
101
|
-
`--json` or `--output yaml`, help is the command tree as data and there is no banner.
|
|
30
|
+
An organisation can be named by its name or its id (`org_…`). People and memberships are named
|
|
31
|
+
by id. Commands that act inside an organisation use `--org`, then `NF_ORG`, then the profile's
|
|
32
|
+
`org`, and exit 7 with `no_org_selected` when there is none. Lists follow every page unless
|
|
33
|
+
`--limit` caps them.
|
|
34
|
+
|
|
35
|
+
Some changes need a **step-up**: a passkey presented in the last five minutes. At a terminal nf
|
|
36
|
+
asks for one in your browser and carries on.
|
|
37
|
+
|
|
38
|
+
| Command | Notes |
|
|
39
|
+
| --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------- |
|
|
40
|
+
| `nf login [--device]` | `--device` shows a code to approve from any signed-in browser |
|
|
41
|
+
| `nf logout` | |
|
|
42
|
+
| `nf whoami` | |
|
|
43
|
+
| `nf org create <name>` | |
|
|
44
|
+
| `nf org use <org>` | Makes it the profile's organisation |
|
|
45
|
+
| `nf org list [--limit <n>]` | |
|
|
46
|
+
| `nf org show [org]` | |
|
|
47
|
+
| `nf org branding show [--domain <domain>]` | Once the organisation has a verified domain |
|
|
48
|
+
| `nf org branding set --name <display-name> --primary <#rrggbb> --background <#rrggbb> [--logo <file.png>] [--dark-primary <#rrggbb> --dark-background <#rrggbb>] [--dark-logo <file.png>] [--light-only] [--support-url <url>] [--domain <domain>]` | Your sign-in pages show it; the dark colours and logo are for viewers in dark mode |
|
|
49
|
+
| `nf org branding remove-logo [--dark] [--domain <domain>]` | With `--dark`, only the dark-mode logo |
|
|
50
|
+
| `nf org branding remove --domain <domain>` | The domain shows the organisation's brand again |
|
|
51
|
+
| `nf org sign-in show` | |
|
|
52
|
+
| `nf org sign-in set --email-links enabled\|disabled` | Owner, step-up |
|
|
53
|
+
| `nf org transfer <membership>` | Owner, step-up; they become owner and you a member |
|
|
54
|
+
| `nf org leave` | The last owner transfers or closes it first |
|
|
55
|
+
| `nf org close --confirm <name>` | Owner, step-up; once nothing billable is left; settles the account |
|
|
56
|
+
| `nf billing setup` | Owner, step-up; prints a Stripe page to add a card |
|
|
57
|
+
| `nf billing show` | Whether a card is on file |
|
|
58
|
+
| `nf billing invoices` | Totals in A$; usage not yet invoiced is in `nf usage show` |
|
|
59
|
+
| `nf domain setup <fqdn> [--email yes\|no] [--routes <local=address,…>] [--host <name\|none>] [--name <name>] [--zone]` | Asks what the domain is for, then prints every record at once |
|
|
60
|
+
| `nf domain check <domain> [--zone]` | Verifies, turns forwarding on, adds routes and the sign-in host, as DNS allows |
|
|
61
|
+
| `nf domain add <fqdn>` | Prints the TXT record to publish |
|
|
62
|
+
| `nf domain instructions <fqdn>` | |
|
|
63
|
+
| `nf domain verify <fqdn>` | Exit 2 with `domain_txt_missing` until DNS has the record |
|
|
64
|
+
| `nf domain list [--limit <n>]` | |
|
|
65
|
+
| `nf domain show <fqdn>` | |
|
|
66
|
+
| `nf domain remove <fqdn>` | |
|
|
67
|
+
| `nf email route create <address> --to <targets>` | Mailboxes or people, comma-separated; a new mailbox (step-up) gets mail once its owner agrees |
|
|
68
|
+
| `nf email route list [--limit <n>]` | |
|
|
69
|
+
| `nf email route show <route>` | |
|
|
70
|
+
| `nf email route update <route> --to <targets>` | |
|
|
71
|
+
| `nf email route delete <route>` | |
|
|
72
|
+
| `nf email destination add <email> [--person <person>]` | Step-up; pending until its owner agrees |
|
|
73
|
+
| `nf email destination list [--limit <n>]` | |
|
|
74
|
+
| `nf email destination show <destination>` | |
|
|
75
|
+
| `nf email destination resend <destination>` | |
|
|
76
|
+
| `nf email destination remove <destination>` | |
|
|
77
|
+
| `nf email enable <fqdn>` | Prints the MX and DKIM records to publish |
|
|
78
|
+
| `nf email list [--limit <n>]` | |
|
|
79
|
+
| `nf email show <fqdn>` | |
|
|
80
|
+
| `nf email check <fqdn>` | Looks up MX, DKIM and DMARC now |
|
|
81
|
+
| `nf email disable <fqdn>` | Routes are kept |
|
|
82
|
+
| `nf platform add [name] [--domain <fqdn>] [--callback <uri>]... [--public] [--secret-file <path>]` | An OpenID Connect app; prints the issuer, client ID, secret and callback to paste in; a callback needs a step-up |
|
|
83
|
+
| `nf platform add [name] --saml [--domain <fqdn>] [--entity-id <uri>] [--acs <url>]... [--sp-cert <path>] [--attributes <list>]` | A SAML app; prints the entity ID, metadata URL, SSO URL and certificate to paste in; an ACS URL needs a step-up |
|
|
84
|
+
| `nf platform list [--limit <n>]` | |
|
|
85
|
+
| `nf platform show <platform>` | Its issuer, client ID, endpoints and callbacks, or a SAML app's metadata URL, SSO URL and certificate |
|
|
86
|
+
| `nf platform callback add <platform> <uri>` | Step-up |
|
|
87
|
+
| `nf platform callback remove <platform> <uri>` | Step-up |
|
|
88
|
+
| `nf platform remove <platform>` | Sign-in and billing stop; to move it to another domain, remove it and add it again |
|
|
89
|
+
| `nf platform rotate-secret <platform> [--secret-file <path>]` | Step-up; the secret goes to the file, or is shown once at a terminal |
|
|
90
|
+
| `nf person invite <email> [--name <name>]` | They join as a member once they follow the emailed link and sign in |
|
|
91
|
+
| `nf person list [--limit <n>]` | |
|
|
92
|
+
| `nf person suspend <membership>` | |
|
|
93
|
+
| `nf person restore <membership>` | |
|
|
94
|
+
| `nf person remove <membership>` | |
|
|
95
|
+
| `nf person name add <membership> <name>` | A forwarding name, such as `alex` for `alex@` |
|
|
96
|
+
| `nf person name remove <membership> <name>` | |
|
|
97
|
+
| `nf invite list [--limit <n>]` | |
|
|
98
|
+
| `nf invite revoke <invite>` | |
|
|
99
|
+
| `nf auth-host add <hostname>` | Your sign-in host, such as `auth.example.com`; pending until its CNAME is in place and its certificate is issued |
|
|
100
|
+
| `nf auth-host list` | One host per verified domain |
|
|
101
|
+
| `nf auth-host show <hostname>` | |
|
|
102
|
+
| `nf auth-host check <hostname>` | Activates the host once its certificate is issued |
|
|
103
|
+
| `nf auth-host remove <hostname>` | |
|
|
104
|
+
| `nf usage show [--from <date>] [--to <date>]` | Exact amounts, this month to now by default |
|
|
105
|
+
| `nf audit list [--limit <n>]` | |
|
|
106
|
+
| `nf doctor` | Checks this machine: Node, the config file, the profile and whether you are signed in |
|
|
107
|
+
| `nf version` | |
|
|
108
|
+
| `nf help [command]` | |
|
|
102
109
|
|
|
103
110
|
## Signing in
|
|
104
111
|
|
|
105
|
-
`nf login`
|
|
106
|
-
`127.0.0.1`,
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
tokens, and a token is only ever sent to the API host it was issued for. An
|
|
113
|
-
expired access token is refreshed, and the refresh token rotates. `nf logout`
|
|
114
|
-
revokes the refresh token and forgets both.
|
|
115
|
-
|
|
116
|
-
A change on the step-up list (security/01) needs a passkey in the last five
|
|
117
|
-
minutes. At a terminal nf asks for it in place (A-078): it opens the browser for
|
|
118
|
-
a fresh passkey, keeps the new tokens and carries on with the command. Without a
|
|
119
|
-
terminal, or under `--json` or `--output`, it exits 6 with `step_up_required`:
|
|
120
|
-
run `nf login`, then the command again.
|
|
121
|
-
|
|
122
|
-
On dev, with no tokens, nf still takes the bootstrap credential (A-020) from
|
|
123
|
-
`NF_BOOTSTRAP_CREDENTIAL`, never stored or printed. It never sends it to prod:
|
|
124
|
-
on a prod profile it exits 3 with `bootstrap_credential_refused` before making
|
|
125
|
-
any request.
|
|
126
|
-
|
|
127
|
-
Every request carries `X-Request-Id` (the `--request-id`, or a fresh `req_…`),
|
|
128
|
-
and every POST, PATCH and DELETE a fresh `Idempotency-Key`. A suspend or restore
|
|
129
|
-
reads the membership first and sends its version as `If-Match`, so a change made
|
|
130
|
-
in between is refused rather than overwritten.
|
|
112
|
+
`nf login` opens your browser to sign in with a passkey, then takes the result back on
|
|
113
|
+
`127.0.0.1`. With `--device`, or with no browser, it shows a code to approve from any signed-in
|
|
114
|
+
device. Tokens go to the OS keychain, never to a file or the terminal, and are only ever sent
|
|
115
|
+
to nine fish. `nf logout` signs out and forgets them.
|
|
116
|
+
|
|
117
|
+
A change that needs a step-up, run without a terminal or with `--json` or `--output`, exits 6
|
|
118
|
+
with `step_up_required`: run `nf login`, then the command again.
|
|
131
119
|
|
|
132
120
|
## Scripts and CI
|
|
133
121
|
|
|
134
|
-
A script or CI job runs as a person
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
rather than writing tokens to a file. Anything on the step-up list needs that
|
|
139
|
-
person's recent passkey step-up, as it would at a laptop.
|
|
122
|
+
A script or CI job runs as a person: sign in once with `nf login --device` where it runs,
|
|
123
|
+
approve the code from your browser, and it acts with your role. It needs the macOS Keychain or
|
|
124
|
+
the Secret Service there too. Anything that needs a step-up needs your recent passkey, as it
|
|
125
|
+
would at a laptop.
|
|
140
126
|
|
|
141
|
-
|
|
127
|
+
In CI (`CI` or `GITHUB_ACTIONS` set), nf never assumes a profile: name one with `--profile` or
|
|
128
|
+
`NF_PROFILE`, or a command exits 7.
|
|
142
129
|
|
|
143
|
-
|
|
144
|
-
(`30`, `30s`, `2m`, `1500ms`; default 30s), `--request-id <id>`, `--json`,
|
|
145
|
-
`--output json|yaml|table` (`-o`), `--help` (`-h`), `--version`. There is no
|
|
146
|
-
`--environment`: a profile names a stage (A-021).
|
|
130
|
+
## Global options
|
|
147
131
|
|
|
148
|
-
|
|
132
|
+
`--org <id or name>`, `--profile <name>`, `--no-interactive`, `--timeout <duration>` (`30`,
|
|
133
|
+
`30s`, `2m`, `1500ms`; default 30s), `--request-id <id>`, `--json`, `--output json|yaml|table`
|
|
134
|
+
(`-o`), `--help` (`-h`), `--version`.
|
|
149
135
|
|
|
150
|
-
|
|
136
|
+
## Profiles
|
|
151
137
|
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
auth hosts come from `@nf/naming`, never from the file. The profiles `dev`
|
|
157
|
-
and `prod` are built in.
|
|
158
|
-
- `NF_PROFILE` and `NF_ORG` stand in for the flags. `NF_API` may name a stage's
|
|
159
|
-
own API, or a loopback `http://` origin for a local server (dev).
|
|
160
|
-
- With nothing selected on a laptop, the stage is dev.
|
|
161
|
-
- **In CI (`CI` or `GITHUB_ACTIONS` set) nf never picks a stage.** The file's
|
|
162
|
-
selected profile and the dev default are ignored, and a command exits 7 unless
|
|
163
|
-
`--profile`, `NF_PROFILE` or `NF_API` names one.
|
|
138
|
+
A profile chooses an organisation. Flags win over environment variables (`NF_PROFILE`,
|
|
139
|
+
`NF_ORG`), which win over the config file: `NF_CONFIG`, else `$XDG_CONFIG_HOME/nf/config.yaml`,
|
|
140
|
+
else `~/.config/nf/config.yaml`. The config file never holds a credential; nf refuses one that
|
|
141
|
+
does.
|
|
164
142
|
|
|
165
143
|
```yaml
|
|
166
144
|
profile: work
|
|
167
145
|
profiles:
|
|
168
146
|
work:
|
|
169
147
|
stage: prod
|
|
170
|
-
org:
|
|
148
|
+
org: acme
|
|
171
149
|
```
|
|
172
150
|
|
|
173
151
|
## Output and errors
|
|
174
152
|
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
ever holds a secret. A platform's client secret goes only to `--secret-file`, readable
|
|
181
|
-
only by you, or is shown once to a person at a terminal; it is never in `--json` output,
|
|
182
|
-
and without a terminal or a file `nf platform add` and `rotate-secret` refuse.
|
|
153
|
+
Output is a table by default, or `--json` / `--output yaml`. In JSON or YAML an error is
|
|
154
|
+
printed on stdout as `{"code", "message", "request_id", "details", "retryable"}`; in a table it
|
|
155
|
+
is a sentence and what to do next, on stderr. Quote the request id to support. A platform's
|
|
156
|
+
client secret goes only to `--secret-file`, readable only by you, or is shown once at a
|
|
157
|
+
terminal; it is never in `--json` output.
|
|
183
158
|
|
|
184
|
-
An
|
|
185
|
-
which is 6:
|
|
159
|
+
An error from the API exits by its HTTP status, except `step_up_required`, which is 6:
|
|
186
160
|
|
|
187
161
|
| Status | Exit |
|
|
188
162
|
| ------------- | ---- |
|
|
@@ -198,7 +172,7 @@ No answer within `--timeout`, or no connection, is 9 (`timeout`, `network_error`
|
|
|
198
172
|
|
|
199
173
|
## Exit codes
|
|
200
174
|
|
|
201
|
-
A code never changes meaning
|
|
175
|
+
A code never changes meaning.
|
|
202
176
|
|
|
203
177
|
| Code | Name | Meaning |
|
|
204
178
|
| ---- | ----------------- | ------------------------------------------------------------------------------------------------------------------- |
|
|
@@ -212,3 +186,9 @@ A code never changes meaning (`src/exit-codes.ts`).
|
|
|
212
186
|
| 7 | `config` | The config file, profile or stage selection is invalid or missing. |
|
|
213
187
|
| 8 | `forbidden` | Signed in, but not allowed to do this. |
|
|
214
188
|
| 9 | `retryable` | A timeout, rate limit or server error. Retrying may work. |
|
|
189
|
+
|
|
190
|
+
## Help
|
|
191
|
+
|
|
192
|
+
Write to [support@nine.fish](mailto:support@nine.fish), which also takes security reports. Use
|
|
193
|
+
of nine fish is under its [terms](https://nine.fish/terms) and
|
|
194
|
+
[privacy policy](https://nine.fish/privacy).
|
package/dist/nf.js
CHANGED
|
@@ -89,7 +89,9 @@ function secretService() {
|
|
|
89
89
|
}
|
|
90
90
|
function unavailableStore() {
|
|
91
91
|
const refuse = async () => {
|
|
92
|
-
throw new Error(
|
|
92
|
+
throw new Error(
|
|
93
|
+
"No OS keychain here: nf keeps tokens in the macOS Keychain or the Secret Service (secret-tool)."
|
|
94
|
+
);
|
|
93
95
|
};
|
|
94
96
|
return {
|
|
95
97
|
kind: "unavailable",
|
|
@@ -396,7 +398,7 @@ function bootstrapCredential(context, env) {
|
|
|
396
398
|
throw new CliError(
|
|
397
399
|
"bootstrap_credential_refused",
|
|
398
400
|
EXIT.unauthenticated,
|
|
399
|
-
"Prod refuses the bootstrap credential
|
|
401
|
+
"Prod refuses the bootstrap credential, so nf doesn't send it there",
|
|
400
402
|
{
|
|
401
403
|
remediation: "Unset it and run `nf login`."
|
|
402
404
|
}
|
|
@@ -465,8 +467,9 @@ var ApiError = class extends CliError {
|
|
|
465
467
|
function remediationFor(code) {
|
|
466
468
|
switch (code) {
|
|
467
469
|
case "unauthenticated":
|
|
470
|
+
return "Run `nf login`.";
|
|
468
471
|
case "bootstrap_credential_refused":
|
|
469
|
-
return `
|
|
472
|
+
return `Unset ${BOOTSTRAP_ENV}, then run \`nf login\`.`;
|
|
470
473
|
case "domain_txt_missing":
|
|
471
474
|
return "Publish the record from `nf domain instructions`. DNS can take minutes to propagate, so verify again shortly.";
|
|
472
475
|
case "version_mismatch":
|
|
@@ -619,7 +622,7 @@ import { isMap, parseDocument } from "yaml";
|
|
|
619
622
|
|
|
620
623
|
// ../../packages/naming/stages.js
|
|
621
624
|
var STAGE_DOMAINS = {
|
|
622
|
-
dev:
|
|
625
|
+
dev: void 0,
|
|
623
626
|
prod: "nine.fish"
|
|
624
627
|
};
|
|
625
628
|
var AUTH_SUBDOMAIN = "auth";
|
|
@@ -642,7 +645,10 @@ function apiOrigin(stage) {
|
|
|
642
645
|
|
|
643
646
|
// src/config.ts
|
|
644
647
|
import { parse as parse2 } from "yaml";
|
|
645
|
-
var
|
|
648
|
+
var STAGES = true ? ["prod"] : ["dev", "prod"];
|
|
649
|
+
var BUILT_IN = Object.fromEntries(
|
|
650
|
+
STAGES.map((stage) => [stage, { stage }])
|
|
651
|
+
);
|
|
646
652
|
var SECRET_KEYS = /token|secret|password|key|credential|cookie/i;
|
|
647
653
|
function configPath(env) {
|
|
648
654
|
if (env.NF_CONFIG) return env.NF_CONFIG;
|
|
@@ -694,12 +700,12 @@ function parseConfig(text, path) {
|
|
|
694
700
|
throw fail(`profile \`${name}\` has an unknown key \`${key}\``);
|
|
695
701
|
}
|
|
696
702
|
if (entry.stage === void 0) throw fail(`profile \`${name}\` needs a stage`);
|
|
697
|
-
if (typeof entry.stage !== "string" || !isStage(entry.stage))
|
|
698
|
-
throw fail(`profile \`${name}\`: stage must be
|
|
703
|
+
if (typeof entry.stage !== "string" || !isStage(entry.stage) || !STAGES.includes(entry.stage))
|
|
704
|
+
throw fail(`profile \`${name}\`: stage must be ${STAGES.join(" or ")}`);
|
|
699
705
|
const builtIn = BUILT_IN[name];
|
|
700
706
|
if (builtIn && builtIn.stage !== entry.stage) {
|
|
701
707
|
throw fail(
|
|
702
|
-
`profile \`${name}\` must have stage ${builtIn.stage}: the profiles
|
|
708
|
+
`profile \`${name}\` must have stage ${builtIn.stage}: the built-in profiles are named for their stage`
|
|
703
709
|
);
|
|
704
710
|
}
|
|
705
711
|
if (entry.org !== void 0 && (typeof entry.org !== "string" || entry.org === "")) {
|
|
@@ -727,7 +733,7 @@ function loadConfig(env, io) {
|
|
|
727
733
|
return { path, file: text === void 0 ? void 0 : parseConfig(text, path) };
|
|
728
734
|
}
|
|
729
735
|
function apiOverride(value) {
|
|
730
|
-
for (const stage of
|
|
736
|
+
for (const stage of STAGES) {
|
|
731
737
|
if (value.replace(/\/+$/, "") === apiOrigin(stage)) return { api: apiOrigin(stage), stage };
|
|
732
738
|
}
|
|
733
739
|
let url;
|
|
@@ -736,12 +742,12 @@ function apiOverride(value) {
|
|
|
736
742
|
} catch {
|
|
737
743
|
url = void 0;
|
|
738
744
|
}
|
|
739
|
-
if (url && url.protocol === "http:" && ["localhost", "127.0.0.1", "[::1]"].includes(url.hostname) && url.pathname === "/") {
|
|
745
|
+
if (STAGES.includes("dev") && url && url.protocol === "http:" && ["localhost", "127.0.0.1", "[::1]"].includes(url.hostname) && url.pathname === "/") {
|
|
740
746
|
return { api: url.origin, stage: "dev" };
|
|
741
747
|
}
|
|
742
748
|
throw configError(
|
|
743
749
|
"config_invalid",
|
|
744
|
-
`NF_API must be ${apiOrigin("
|
|
750
|
+
STAGES.includes("dev") ? `NF_API must be ${STAGES.map(apiOrigin).join(", ")} or a loopback http:// origin` : `NF_API must be ${apiOrigin("prod")}`
|
|
745
751
|
);
|
|
746
752
|
}
|
|
747
753
|
function resolveContext(flags, env, io) {
|
|
@@ -756,16 +762,16 @@ function resolveContext(flags, env, io) {
|
|
|
756
762
|
throw configError(
|
|
757
763
|
"stage_required_in_ci",
|
|
758
764
|
"In CI, nf never picks a stage for you",
|
|
759
|
-
|
|
765
|
+
`Name a profile with --profile or NF_PROFILE (built in: ${STAGES.join(", ")}), or set NF_API.`
|
|
760
766
|
);
|
|
761
767
|
}
|
|
762
|
-
profile ??= { name: override?.stage ?? "
|
|
768
|
+
profile ??= { name: override?.stage ?? "prod", source: "default" };
|
|
763
769
|
const chosen = file?.profiles[profile.name] ?? BUILT_IN[profile.name];
|
|
764
770
|
if (!chosen) {
|
|
765
771
|
throw configError(
|
|
766
772
|
"profile_not_found",
|
|
767
773
|
`No profile \`${profile.name}\`${path ? ` in ${path}` : ""}`,
|
|
768
|
-
|
|
774
|
+
`Built in: ${STAGES.join(", ")}; define others in the config file.`
|
|
769
775
|
);
|
|
770
776
|
}
|
|
771
777
|
if (override && override.stage !== chosen.stage) {
|
|
@@ -1085,7 +1091,7 @@ function pasteable(platform, state) {
|
|
|
1085
1091
|
pkce: "S256, required",
|
|
1086
1092
|
callbacks: platform.redirect_uris,
|
|
1087
1093
|
post_logout_redirect_uris: platform.post_logout_redirect_uris,
|
|
1088
|
-
// The `email` claim, at userinfo with the email scope
|
|
1094
|
+
// The `email` claim, at userinfo with the email scope.
|
|
1089
1095
|
email: `<member name>@${platform.domain}`
|
|
1090
1096
|
};
|
|
1091
1097
|
}
|
|
@@ -2127,7 +2133,7 @@ var COMMANDS = [
|
|
|
2127
2133
|
"dark-primary": {
|
|
2128
2134
|
type: "string",
|
|
2129
2135
|
value: "#rrggbb",
|
|
2130
|
-
description: "Dark mode's primary colour, with --dark-background
|
|
2136
|
+
description: "Dark mode's primary colour, with --dark-background: pages follow the viewer's system setting. Kept if left out"
|
|
2131
2137
|
},
|
|
2132
2138
|
"dark-background": {
|
|
2133
2139
|
type: "string",
|
|
@@ -2689,7 +2695,7 @@ var GLOBAL_OPTIONS = {
|
|
|
2689
2695
|
profile: {
|
|
2690
2696
|
type: "string",
|
|
2691
2697
|
value: "name",
|
|
2692
|
-
description: "The profile to use
|
|
2698
|
+
description: "The profile to use: a built-in stage profile, or one from the config file"
|
|
2693
2699
|
},
|
|
2694
2700
|
"no-interactive": { type: "boolean", description: "Never prompt; fail instead" },
|
|
2695
2701
|
timeout: {
|
|
@@ -2778,7 +2784,7 @@ function table(rows, options = {}) {
|
|
|
2778
2784
|
}
|
|
2779
2785
|
|
|
2780
2786
|
// src/version.ts
|
|
2781
|
-
var VERSION = "0.1.
|
|
2787
|
+
var VERSION = "0.1.1";
|
|
2782
2788
|
|
|
2783
2789
|
// src/help.ts
|
|
2784
2790
|
function optionRows(options) {
|
|
@@ -2865,7 +2871,7 @@ async function runSession(name, values, context, env, io, requestId2, timeoutMs)
|
|
|
2865
2871
|
}
|
|
2866
2872
|
if (io.tokens.kind === "unavailable")
|
|
2867
2873
|
throw new CliError("no_keychain", EXIT.config, "There's no OS keychain to keep tokens in", {
|
|
2868
|
-
remediation: "nf keeps tokens only in the macOS Keychain or the Secret Service
|
|
2874
|
+
remediation: "nf keeps tokens only in the macOS Keychain or the Secret Service."
|
|
2869
2875
|
});
|
|
2870
2876
|
const tokens = values.device === true || !io.isTTY ? await loginWithDevice(context, io) : await loginWithBrowser(context, io);
|
|
2871
2877
|
await io.tokens.write(profile, tokens);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ninefish/cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"license": "UNLICENSED",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -32,9 +32,9 @@
|
|
|
32
32
|
"access": "public"
|
|
33
33
|
},
|
|
34
34
|
"scripts": {
|
|
35
|
-
"build": "node ../../scripts/bundle-bin.mjs src/nf.ts dist/nf.js",
|
|
35
|
+
"build": "node ../../scripts/bundle-bin.mjs src/nf.ts dist/nf.js --public && node ../../scripts/bundle-bin.mjs src/nf.ts build/nf.js",
|
|
36
36
|
"type-check": "tsc --noEmit --tsBuildInfoFile tsconfig.type-check.tsbuildinfo",
|
|
37
|
-
"clean": "rm -rf dist .turbo *.tsbuildinfo",
|
|
37
|
+
"clean": "rm -rf dist build .turbo *.tsbuildinfo",
|
|
38
38
|
"render-mark": "node scripts/render-mark.mjs 14"
|
|
39
39
|
}
|
|
40
40
|
}
|