Reference

CLI reference

Every avaccess command, flag, environment variable and exit code.

Read as Markdown

avaccess ships with @aventara/access. Run it with npx avaccess <command>.

Code
avaccess <command> [arguments] [flags]
avaccess --help | -h        the help
avaccess --version | -v     the package version
avaccess <command> --help   one command's usage

Commands

CommandDoesRead
push <rules> [--beacon <module>]Pushes the namespace's policies file: a .json file, or the module that holds the rules (default export, or rules), TypeScript includedRegistry
pull [--namespace <ns>] [--out <dir>] [--foreign <ns>:<Resource>,…] [--beacon <module>] [--env <env>]Writes the namespace's file to access/<ns>.policies.json and the org's guardrails to access/guardrails.json, and pins their hashes in avAccess.lock.jsonRegistry
verify [--env <env>]Holds the pulled files to the lock, and each avAccess.beacons.<env>.json to the rules, offlineThe lock
statusSays whether the lock is behind the registry's current revisions; exits 1 when it isRegistry
diff [<from> [<to>]] [--namespace <ns>]Names the rules that changed between two revisions: lock, head, a hash, or its first seven or more hex digits. Default lock to head.Registry
generate [--orm <orm>] [--out <file>] [--tsconfig <file>]Writes the generated client from the pulled filesGenerated client
schema --orm <orm> [--schema <path>] [--out <file>]Reads an ORM's schema into a module that exports model, to author rules againstGenerated client
serve [--config <file>] [--port <port>] [--hostname <host>] [--max-body-bytes <bytes>] [--migrate]Runs the standalone Access serverThe standalone server
keys issue <ns>, keys rotate <ns> <push|pull>, keys revoke <ns> <push|pull>, each with --server <module>The operator's keys. Run in the server's own process, never over HTTP.Keys

Flags

FlagCommandsDefault
--registry <url>push, pull, status, diffAVACCESS_REGISTRY_URL
--namespace <ns>pull, diffThe lock's namespace, else the key's (pull); the lock's (diff)
--out <dir>pullWhere the lock has the files, else access/
--foreign <ns>:<Resource>,…pullnone. May be given more than once.
--beacon <module>push, pullnone. The module must export beacon (Beacons).
--env <env>pull, verifyAVACCESS_ENV
--orm <orm>generate, schemagenerate: none. schema: required. Values: none (generate only), prisma7.
--out <file>generate, schemagenerate: src/generated/avAccess.ts. schema: src/generated/avAccess.schema.ts.
--tsconfig <file>generateThe nearest tsconfig.json above the output
--schema <path>schemaprisma/schema.prisma (a folder of .prisma files reads as one)
--config <file>serveaccess.config.ts (or .mts, .cts, .js, .mjs, .cjs) in the working directory
--port <port>servePORT, else 3000
--hostname <host>serve127.0.0.1
--max-body-bytes <bytes>serve1048576 (1 MiB)
--migrateserveoff
--server <module>keysrequired

Environment variables

VariableUsed byDoes
AVACCESS_REGISTRY_URLpush, pull, status, diffThe Access server's URL. With no path, /api/auth is added. https: only; http: is taken on a loopback address.
AVACCESS_KEYpush, pull, status, diffThe namespace's push or pull key. Never a flag.
AVACCESS_ENVpull, verifyThe environment name for beacon pins
AVACCESS_MIGRATEservetrue or 1 runs Better Auth's migration on start. false, 0 or unset does not. Any other value is refused.
PORTserveThe port, when --port is not given

avaccess keys reads no .env. Give it the environment the server runs with: DATABASE_URL, BETTER_AUTH_SECRET and BETTER_AUTH_URL.

Exit codes

CodeMeaning
0Done
1The check failed or the registry refused
2The command could not run (bad flag, missing file, no registry address)

A failure prints avaccess <command>: <code>: <message> on stderr, where <code> is the Access error code when there is one (Error codes). Running avaccess with no command prints the help and exits 2.

Files the commands read and write

FileWritten byRead by
avAccess.lock.jsonpullverify, status, diff, generate, your app at startup
access/<ns>.policies.jsonpullverify, generate, your app
access/guardrails.jsonpullverify, generate, your app
access/foreign.jsonpull --foreignverify, schema
avAccess.beacons.<env>.jsonpull --envverify, your app at startup
src/generated/avAccess.schema.tsschemayour rules
src/generated/avAccess.ts, avAccess.internal.tsgenerateyour service

pull and generate write only inside the project. A path through a symbolic link that leads out of it is refused. Formats are on File formats, hashes and the engine.