Skip to content

About

The AuthForge command line: manage apps, licenses, webhooks and logs from a terminal or CI

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

authforge

The command line for AuthForge: manage apps, licenses, webhooks and the authentication log from a terminal, a script or CI.

The interactive mode: browsing apps, filtering licenses, issuing three new ones and watching the live log

Run authforge with no arguments for the interactive mode above. Run it with a command for one result and an exit code: every command takes flags, and --json for scripts.

Install

npm install -g authforge

Needs Node.js 22.12 or later. Works in PowerShell and Windows Terminal, and in any terminal on macOS and Linux. To try it without installing: npx authforge.

Sign in

authforge login

This shows a short code and opens the pairing page in your browser. There you see what the key will be allowed to do, choose how long it lives (7, 30 or 90 days) and approve. No password is typed in the terminal.

The key is stored in the operating system's credential store: Windows Credential Manager, the macOS Keychain, or the Secret Service (GNOME Keyring, KWallet) on Linux. Where there is none, it goes into a file only your user account can read. authforge login and authforge whoami both say which one is in use. The whole key is never printed, only its first characters.

By default the key may read and write apps and licenses, read logs and read the account. Ask for something else with --scopes:

authforge login --scopes all                          # also pausing and deleting apps, and webhooks
authforge login --scopes read                         # a key that can only look
authforge login --scopes +admin:apps,+write:webhooks  # what you have now, plus two

authforge logout revokes the key and removes it from the machine.

A first session

authforge use "My Game"                  # the app the next commands work on
authforge licenses create --days 30      # issue a 30-day license
authforge licenses list --status active
authforge licenses show A3K9-BFWX-7NP2-QHDT
authforge licenses revoke A3K9-BFWX-7NP2-QHDT
authforge logs tail --failures           # watch failed authentications live

authforge <command> --help describes every flag, the scope the command needs, and gives examples.

Interactive mode

authforge on its own opens a full-screen view: your apps, each app's licenses, a live log, webhooks with their deliveries, and your account. It leaves the terminal as it found it.

An app's licenses The live log
The licenses of one app: key, status, expiry, devices, label and email Authentications arriving live, the refused ones in red
Key Does
↑ ↓ or j k Move. g and G jump to the ends, PgUp and PgDn move a page
Enter Open what is selected
Esc Back
/ Filter the list
? Every key on this screen
a Account, key and sign-in
q or Ctrl+C Quit

Each screen lists its own keys in the bottom line. Anything destructive asks first, and deleting an app asks for its name. An action your key has no scope for is dimmed, and pressing it says which scope is missing.

Commands

Three commands and their output: status, licenses create and logs search

Command What it does
login, logout, whoami Pair this device, sign out, show the key in use
status Credit balance and every app's last 24 hours
use <app> Set the app that commands work on when --app is not given
apps list, show, create, delete Manage apps
apps pause, unpause, set Stop an app's validations; change its credit caps
apps stats, problems Usage, and recent failures grouped by license and reason
apps vars get, set, unset App variables
licenses list, show, create, delete Manage licenses
licenses revoke, activate, extend Change whether and until when a license validates
licenses reset-hwid, set-devices, set-email Devices and the customer email
licenses vars get, set, unset License variables
licenses import, import-undo Bring existing keys in from a CSV file
licenses offline mint, list, machines, release Offline license files
logs tail, logs search Follow the authentication log live; search the last 90 days
webhooks list, create, update, delete Manage webhooks
webhooks test, rotate-secret, deliveries, replay Check and repair deliveries
security list, block, unblock, allow, unallow Device and IP lists for an app
api <method> <path> An authenticated request to any Developer API route
completion <shell> Shell completion for bash, zsh, fish and PowerShell

An app can be given by ID, by name, or by the start of either. licenses revoke, activate, reset-hwid and delete take several keys at once.

Scripts and CI

Set AUTHFORGE_API_KEY to a key from the dashboard; nothing is stored and no sign-in is needed.

export AUTHFORGE_API_KEY=af_live_...
export AUTHFORGE_APP="My Game"

# 50 keys, one per line, into a file
authforge licenses create -n 50 --days 365 --label reseller-7 > keys.txt

# Revoke every license of one customer
authforge licenses list --all --json \
  | jq -r '.licenses[] | select(.email == "sam@example.com") | .licenseKey' \
  | xargs authforge licenses revoke --yes

What scripts can rely on:

  • stdout carries the result and nothing else. Progress, hints and errors go to stderr.
  • --json prints one JSON document (logs tail --json prints one object per line). An error is then JSON on stderr: {"error":{"code","message","hint","status"}}.
  • Piped output is plain. Tables become tab-separated lines with no header and no colour.
  • Nothing waits for an answer in a pipeline. Without a terminal, a command that needs a confirmation fails and says to pass --yes. --no-input does the same on a terminal.
  • Creating licenses is safe to retry: the request carries an idempotency key.
  • --wait waits out a rate limit instead of failing.
Exit code Meaning
0 Done
1 Failed
2 Wrong usage: an unknown command or flag, a bad value
3 Not signed in, key expired or revoked, or a scope is missing
4 Not found
5 Rate limited, or a limit of the account was reached
6 Out of credits
7 AuthForge could not be reached, or is in maintenance
130 Interrupted with Ctrl+C

Environment

Variable
AUTHFORGE_API_KEY Use this key instead of a stored sign-in
AUTHFORGE_APP The app to work on when --app is not given
AUTHFORGE_KEY_STORAGE Where login keeps the key: keychain or file
AUTHFORGE_CONFIG_DIR Where settings are kept. Default: %APPDATA%\authforge on Windows, $XDG_CONFIG_HOME/authforge or ~/.config/authforge elsewhere
AUTHFORGE_ASCII Set to 1 to draw with plain ASCII characters
NO_COLOR Turn colour off (--no-color does the same)

Shell completion

authforge completion powershell >> $PROFILE
authforge completion bash > ~/.local/share/bash-completion/completions/authforge
authforge completion zsh > ~/.zfunc/_authforge
authforge completion fish > ~/.config/fish/completions/authforge.fish

When something goes wrong

Errors say what happened and what to do next. The common ones:

  • "This key lacks write:licenses": the key was paired without that scope. authforge login --scopes +write:licenses pairs a new one that has it.
  • "Your key expired": keys paired by login live 7, 30 or 90 days. Run authforge login again.
  • Rate limited: wait the time the message names, or pass --wait.
  • Out of credits: buy more at app.authforge.cc/buy-credits.

--debug prints each API request to stderr, without the key.

Documentation

Development

npm ci
npm run check    # type-check, tests, build, and a smoke run of the built binary
npm run dev      # build and open the interactive mode

The tests run every command and the interactive mode against a local fake of the API; nothing talks to the real service.

The pictures in media/ are made by npm run media: it records the real interactive mode and commands against that same fake API with made-up data (test/media-demo.ts), draws the frames as a terminal window and photographs them. It needs Edge, Chrome or Chromium and ffmpeg; run it again after changing how a screen looks.

Releasing

A tag publishes. Raise the version, push the commit and its tag, and .github/workflows/release.yml checks the tag against package.json, runs npm run check and publishes to npm with provenance:

npm version patch    # or minor, major: edits package.json and the lockfile, commits, tags vX.Y.Z
git push origin main --follow-tags

No npm token is stored: the package on npmjs.com names this repository and release.yml as its trusted publisher.

Thanks

The authforge name on npm belonged to Hosung (devho, devho.net), who generously handed it over so the CLI could have it. Thank you, Hosung. Versions 1.x of this package are his earlier, unrelated project; the CLI begins at 2.0.0.

Licence

MIT

About

The AuthForge command line: manage apps, licenses, webhooks and logs from a terminal or CI

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages