@ninefish/cli
v0.8.0
Published
nf: sign-in for your apps on your own domain, with your brand. Passkeys, OpenID Connect, SAML and email forwarding from the command line.
Maintainers
Readme
nf
The command line for nine fish: sign-in for your apps, on your own domain, with your brand. Set up an organisation, verify a domain, forward its mail and register the apps your people sign in to.
npm install -g @ninefish/cli
nf loginnf needs Node.js 22 or later and an OS keychain for its tokens: the macOS Keychain, Windows
Credential Manager, or on Linux the Secret Service (secret-tool, from libsecret, with a keyring
such as GNOME Keyring). nf never writes tokens to a file, so it can't sign in where there's no
keychain. nf doctor checks all of this.
Getting started
nf login # sign in with a passkey in your browser
nf org create acme --username alex # make an organisation; you are its owner, alex at its domains
nf billing setup # add a card on a secure payment page
nf domain setup example.com # say what the domain is for; get every DNS record at once
nf domain check example.com # where it's at: once the records are in DNS it finishes by itself
nf platform add # register an app; prints what to paste into itnf domain setup prints each record with its status, then the ones to publish as zone-file
lines, which paste into a DNS provider's import or an assistant that has access to it:
pending TXT _nf-challenge.example.com
pending MX example.com
pending TXT nf1._domainkey.example.com
pending TXT _dmarc.example.com (recommended)
pending CNAME auth.example.com
pending CNAME _acme-challenge.auth.example.com
_nf-challenge.example.com. 300 IN TXT "nf-verify=3kq9…"
example.com. 300 IN MX 10 inbound-smtp.us-east-1.amazonaws.com.
nf1._domainkey.example.com. 300 IN TXT "v=DKIM1; k=rsa; p=MIIBIjAN…"
_dmarc.example.com. 300 IN TXT "v=DMARC1; p=none" ; recommended
auth.example.com. 300 IN CNAME edge.nine.fish.
_acme-challenge.auth.example.com. 300 IN CNAME 3f9a….acme.nine.fish.
Publish these records at your DNS provider. The setup finishes by itself as they appear, and
you're emailed when it's live; nf domain check example.com shows where it's at.nf platform add ends with what to paste into the app:
Added dashboard on example.com. Every member can sign in to it. Paste these into the platform:
Issuer https://auth.example.com
Client ID plt_…
Client secret in ./dashboard.secret, readable only by you
Callback https://dashboard.example.org/auth/callbackAt a terminal, nf asks for anything you leave out. nf help <command> explains any command.
Commands
You can name anything by its name: an organisation (acme), a domain (example.com), a
platform (dashboard), a route or mailbox ([email protected]), and a member by their member
name (sam, or [email protected]). Ids such as org_… and mem_… work everywhere too.
Commands act on the organisation from --org, then NF_ORG, then the profile's (nf org use).
Lists show every item unless --limit caps them.
# Signing in
nf login [--device] # --device: approve a code from any signed-in browser
nf logout
nf whoami
# Your organisation
nf org create <slug> --username <username> [--name <name>]
nf org name set|clear [name] # owner: what people see; cleared, the slug is shown
nf org slug set <slug> # owner, step-up: the old slug is free at once
nf org use <org>
nf org list
nf org show [org]
nf org branding show|set|remove-logo|remove # the sign-in pages' colours and logo (a domain's own name with --domain)
nf org sign-in show|set # whether emailed sign-in links are on
nf org transfer <member> # owner: they become owner, you a member
nf org leave
nf org close --confirm <slug> # owner: once nothing billable is left
# Billing
nf billing setup # owner: a secure page to add a card on
nf billing show # the card, what is owed now and the next invoice
nf billing invoices
nf billing alert show|off
nf billing alert set <amount> # owner: email the owners once a month's spend reaches it
nf usage show [--from <date>] [--to <date>]
# Domains
nf domain setup <fqdn> # guided: what it's for, then every record
nf domain check <domain> # carries it on as far as DNS allows; a host names its domain
nf domain check <domain> --only proof|email|host
nf domain add <fqdn> # or by hand: claim, and see the TXT proof
nf domain instructions <fqdn>
nf domain list
nf domain show <fqdn>
nf domain remove <fqdn>
# Forwarding mail
nf email enable|show|disable <fqdn>
nf email list
nf email route create <address> --to <targets> [--note <text>] # mailboxes, your own addresses or members
nf email route list
nf email route show|update|delete <route>
nf email route disable|enable <route> # stop forwarding, keeping the route; disable an address with none to block it from the catch-all
nf email route note set <route> <text>
nf email route note clear <route>
nf email destination add <email> [--person <member>]
nf email destination list
nf email destination show|resend|remove <destination>
nf email log [--domain <d>] [--address <a>] [--since <date>] # what arrived and where it went, one greppable line per mailbox
nf email test <address> [--wait <duration>] # sends a test and follows it to each mailbox
# Platforms
nf platform add [slug] [--name <name>] # OpenID Connect; or SAML with --saml
nf platform list
nf platform show <platform>
nf platform name set|clear <platform> [name] # what members see when they sign in; cleared, the slug
nf platform slug set <platform> <slug>
nf platform callback add|remove <platform> <uri>
nf platform rotate-secret <platform>
nf platform restrict <platform> --group <group>... # owner: only members in one of the groups sign in
nf platform unrestrict <platform> # owner: every member again
nf platform remove <platform>
# People
nf person invite <email> [--name <name>] [--username <username>] # --username unless the address is on one of your domains
nf person list
nf person suspend|restore|remove <member>
nf person username add|remove <member> <username> # every member keeps at least one
nf person name set|clear <member> [name] # the name people and platforms see, such as "Sam Lee"; cleared, the username
nf person group add|remove <member> <group> # owner: groups a restricted platform lets sign in
nf invite list
nf invite revoke <invite>
# Sign-in hosts
nf auth-host add <hostname> # such as auth.example.com, one per domain
nf auth-host list
nf auth-host show|remove <hostname>
# The rest
nf approval list # changes this sign-in queued for your passkey
nf approval show <approval> # one of them, and how it went; --secret-file saves a secret it made
nf audit list
nf doctor # checks Node, config, profile, keychain and sign-in
nf completion bash|zsh|fish
nf version
nf help [command]Some changes need a step-up: a passkey presented in the last five minutes. At a terminal nf
asks for one in your browser and carries on. Run by an assistant, with no one at the keyboard,
nf queues the change for your approval instead: see "Approvals" below. Changes that are hard to undo, such as remove,
delete, revoke, suspend, leave and transfer, ask you to confirm first.
Scripts, CI and agents
Every command works without a person at the keyboard. Under --json, --output yaml,
--no-interactive or in CI, nf never prompts:
- Discover.
nf help --jsondescribes every command as data: its arguments and options, whether it needs the owner or a step-up, whether it confirms, and whether it can wait. It also lists the exit codes and environment variables below.nf help <command> --jsonnarrows it. - Read.
--json(or-o yaml) prints the API's own objects. A change that removes something prints{"removed": "<id>"}. - Give every answer. Anything nf would ask has a flag, and a missing one is a usage error
(exit 2).
nf domain setupneeds--email yes|no. - Confirm. Commands that ask at a terminal need
--yes(-y) anywhere else. Without it they exit 2 withconfirmation_requiredand send nothing. - Wait.
nf domain checktakes--wait <duration>, such as--wait 10m. It checks every 15 seconds and exits 0 once done (with--only, once that part is), or 10 if time runs out. - Retry. Every change carries an idempotency key, so retrying after exit 9 is safe.
- Secrets. A client secret never appears in JSON.
--secret-file <path>writes it to a file only you can read.
nf domain setup example.com --email yes --routes [email protected] --host auth.example.com --json
nf domain check example.com --wait 15m --json
nf platform add helpdesk --domain example.com --callback https://helpdesk.example.org/sso/callback \
--secret-file ./helpdesk.secret --json
nf person remove sam --yes --jsonSigning in. A script runs as a person, with that person's role. Sign in once where it runs
with nf login --device, approve the code from your browser with your passkey, and it stays signed in. The
machine needs an OS keychain, as above: a container or a stock CI runner usually has none.
--timeout bounds how long nf login waits for you. A change that needs a step-up waits for
your approval there, as above.
Approvals. Run without a person at the keyboard (no terminal, or --json or -o yaml),
a change that needs a step-up is queued for that person, so an assistant working for them is
never held up. nf prints what the change is and the page to approve it at, opens that page
the first time, and exits 10 (approval_pending, with the link in details.approval). On the
page you approve it with your passkey, and nine fish makes it, as you; nf approval show <id>
shows how it went. --wait <duration> waits for it instead and exits as the change itself
would; one you refused exits 6 (approval_denied). The page also offers the next hour, in
which that sign-in's changes go through at once, except handing on or closing an organisation,
which always ask. A secret such a change makes, such as a platform's client secret, is sealed
to a key only this nf holds: nf approval show <id> --secret-file <path> saves it. In CI and
under --no-interactive nf queues nothing and exits 6.
CI. When CI or GITHUB_ACTIONS is set, nf never assumes a profile: name one with
--profile or NF_PROFILE, or a command exits 7.
Errors
In a table, an error is a sentence and what to do next, on stderr. Under --json or --output
it is one object on stdout:
{
"code": "domain_txt_missing",
"message": "No TXT record at _nf-challenge.example.com holds the challenge yet. DNS changes can take minutes to reach the domain's name servers.",
"remediation": "Publish the TXT record from `nf domain add`, wait for DNS, then run nf domain check again.",
"request_id": "req_…",
"retryable": true
}details appears when there is more to say. Quote the request_id to support.
Exit codes
A code never changes meaning. An error from the API exits by its HTTP status: 400 and 422 are
2, 401 is 3, 403 is 8, 404 and 410 are 4, 409, 412 and 428 are 5, 429 and 5xx are 9.
step_up_required is 6 and domain_txt_missing is 10. No answer within --timeout, or no
connection, is 9.
| Code | Name | Meaning |
| ---- | ------------------ | ------------------------------------------------------------------------------------------------------------------------------- |
| 0 | ok | It worked. |
| 1 | error | Something failed that no other code covers, a doctor check failed, or you said no at a prompt. |
| 2 | usage | The command line is wrong: an unknown command or option, a missing argument or --yes, or a value the API refused as invalid. |
| 3 | unauthenticated | Not signed in, or the session has expired. Run nf login. |
| 4 | not_found | The organisation, person, domain or platform doesn't exist, or isn't visible to you. |
| 5 | conflict | The resource changed since it was read, or the change conflicts with another. |
| 6 | step_up_required | The change needs a passkey presented in the last five minutes (a step-up), or you refused it. |
| 7 | config | The config file, profile or stage selection is invalid or missing. |
| 8 | forbidden | Signed in, but not allowed to do this. |
| 9 | retryable | A timeout, rate limit or server error. Retrying may work. |
| 10 | pending | Not done yet: DNS or a certificate hasn't caught up, or a change waits for your approval. Run it again later, or pass --wait. |
Global options
| Option | |
| ------------------------------------------ | ------------------------------------------------------------------------------- |
| --org <id or name> | The organisation to act on |
| --profile <name> | The profile to use |
| --json, -o, --output json\|yaml\|table | The output format; the default is a table |
| --no-interactive | Never prompt; fail instead |
| --timeout <duration> | Give up on a request after this long: 30, 30s, 2m, 1500ms (default 30s) |
| --request-id <id> | The request id to send and report |
| -h, --help, --version | |
Environment
| Variable | |
| ---------------------- | ------------------------------------------------------------------- |
| NF_PROFILE | The profile to use, as --profile |
| NF_ORG | The organisation to act on, as --org |
| NF_CONFIG | The config file (see Profiles) |
| CI, GITHUB_ACTIONS | Either set means CI: no prompts, and no profile unless one is named |
| NO_COLOR | No colour in the banner |
| NF_NO_UPDATE_CHECK | Don't check npm once a day for a newer nf |
Profiles
A profile remembers an organisation, so you don't pass --org each time. nf org use and
nf org create write it for you. Flags win over environment variables, which win over the
config file: NF_CONFIG, else $XDG_CONFIG_HOME/nf/config.yaml, else
~/.config/nf/config.yaml.
profile: work
profiles:
work:
org: acme
studio:
org: acme-studioThe config file never holds a credential, and nf refuses one that does. Each profile has its own sign-in.
Shell completion
eval "$(nf completion bash)" # in ~/.bashrc
source <(nf completion zsh) # in ~/.zshrc
nf completion fish > ~/.config/fish/completions/nf.fishAt a terminal, nf checks npm once a day for a newer version and says so on stderr. It never
checks in CI or under --json, and NF_NO_UPDATE_CHECK=1 turns the check off.
Help
Write to [email protected], which also takes security reports. Use of nine fish is under its terms and privacy policy.
