@userbox/cli 0.0.0-bootstrap.0 → 0.1.0-alpha.0

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/CHANGELOG.md ADDED
@@ -0,0 +1,10 @@
1
+ # Changelog
2
+
3
+ All notable changes to `@userbox/cli` are documented in this file.
4
+
5
+ ## [0.1.0-alpha.0] — 2026-11-04
6
+
7
+ ### Added
8
+ - First release. `userbox login`, `logout`, `whoami`, `init` (Next.js App
9
+ Router), `apply` (`userbox.yaml`), `dev seed` and `doctor`. Every command
10
+ takes `--json` for coding agents.
package/README.md CHANGED
@@ -1,3 +1,57 @@
1
- # @userbox/cli
1
+ # `@userbox/cli`
2
2
 
3
- Placeholder. Install `@userbox/cli@alpha`.
3
+ The Userbox command-line tool, binary `userbox`. It sets up
4
+ [Userbox](https://docs.test.userbox.app) in a Next.js App Router app: allowed
5
+ redirect domain, API key, `.env.local`, SDKs and the auth files. It then keeps
6
+ permissions and roles in sync with a `userbox.yaml` in your repository.
7
+
8
+ Status: alpha, `test` environment only. The unscoped npm name `userbox` belongs
9
+ to an unrelated third party; the CLI is only published as `@userbox/cli`.
10
+
11
+ ```bash
12
+ npx @userbox/cli login # a human, once: tenant slug, email, password
13
+ npx @userbox/cli init # in the app root
14
+ npx @userbox/cli apply # sync userbox.yaml
15
+ npx @userbox/cli dev seed # a dev workspace where you are admin
16
+ npx @userbox/cli doctor # check everything
17
+ ```
18
+
19
+ ## For coding agents
20
+
21
+ Every command takes `--json` and exits non-zero with `{ "ok": false, "error": { "code", "message", "hint" } }`.
22
+ Secrets never pass through the model:
23
+
24
+ - `login` refuses to run without an interactive terminal. If a command fails
25
+ with `NOT_LOGGED_IN`, `SESSION_EXPIRED` or `NEEDS_HUMAN`, ask the human to
26
+ run `npx @userbox/cli login` in their own terminal.
27
+ - `init` writes the API key straight to `.env.local` and never prints it.
28
+ - `apply` without `--yes` only prints the plan when there is no terminal: show
29
+ it to the human, then run `apply --yes`.
30
+
31
+ ## Commands
32
+
33
+ | Command | What it does |
34
+ |---|---|
35
+ | `login` | Logs in as a tenant admin (a user with console access). Stores the session in `~/.config/userbox/credentials.json`, mode 600. `--api-url` picks another API. |
36
+ | `logout` / `whoami` | Forget / show the login. |
37
+ | `init` | Needs Next.js with `app/` or `src/app/`. Adds the `--origin` host (default `http://localhost:3000`) to the allowed redirect domains, creates an API key with `access:check`, `memberships:read`, `workspaces:read` unless `.env.local` already has one, merges the five variables into `.env.local` without touching existing values (`--force` replaces them), makes sure `.env.local` is git-ignored, installs `@userbox/react@alpha` and `@userbox/node@alpha` (`--skip-install` skips it), and writes `providers.tsx`, `auth/callback/page.tsx` and `api/auth/refresh/route.ts` if they do not exist. It wraps `{children}` in the root layout with `<Providers>` when that edit is unambiguous. |
38
+ | `apply` | Reads `userbox.yaml`, creates missing permissions, and makes every declared role in every active workspace hold exactly its listed permissions. Permissions and roles that are not in the file are reported, never deleted. |
39
+ | `dev seed` | Creates (or reuses) the workspace `dev`, syncs `userbox.yaml` into it and gives you the `admin` role. `--invite email[:role]` invites more users by email (role defaults to `member`). Warns when the default environment is a production environment. |
40
+ | `doctor` | Checks the project, SDK versions, auth files, `.env.local`, secrets in `NEXT_PUBLIC_*`, `.gitignore`, the API and JWKS, the API key's tenant and `access:check` scope, and, when logged in, the redirect domain and sign-up mode. Exits 1 when a check fails. |
41
+
42
+ ## `userbox.yaml`
43
+
44
+ ```yaml
45
+ permissions: [projects.read, projects.create, projects.delete]
46
+ roles:
47
+ admin: [projects.*]
48
+ member: [projects.read, projects.create]
49
+ ```
50
+
51
+ Permission keys have 2 to 5 lowercase segments separated by dots. `prefix.*`
52
+ expands to every declared permission with that prefix. Roles live in
53
+ workspaces: run `userbox apply` again after creating a workspace.
54
+
55
+ ## License
56
+
57
+ Apache-2.0
package/SECURITY.md ADDED
@@ -0,0 +1,26 @@
1
+ # Security policy — `@userbox/cli`
2
+
3
+ ## Threat model summary
4
+
5
+ - **Server-side only.** The client authenticates with a Userbox API key (or a
6
+ JWT for audit logs). Never ship it to a browser bundle: an API key in client
7
+ code is a leaked key.
8
+ - **Credentials are never logged.** The client has no logging. Error messages,
9
+ `UserboxError` objects and their serialised forms never contain the API key,
10
+ the tenant ID header value or the request headers. A unit test
11
+ (`tests/credentials-not-logged.unit.test.ts`) asserts this for every API-key
12
+ prefix, and asserts that the source contains no `console.*` call.
13
+ - **Zero runtime dependencies.** The client uses the runtime's global `fetch`,
14
+ `URL` and `Headers`. Nothing is pulled in at install time.
15
+ - **Fail closed.** `can()` returns `true` only when the API answers
16
+ `allowed: true`. Any error throws; it never resolves to `true`.
17
+ - **Response shape guard.** 2xx bodies are checked at the top level before use.
18
+ A malformed body raises an error instead of being trusted.
19
+ - **Server authority.** Permission decisions are made by the Userbox API on
20
+ every call. The client caches nothing.
21
+
22
+ ## Reporting a vulnerability
23
+
24
+ See the repository [security policy](../SECURITY.md). Report privately through
25
+ GitHub private vulnerability reporting or **security@osbxtech.nl**, never in a
26
+ public issue.