pontive 1.17.0 → 1.19.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.
Files changed (3) hide show
  1. package/README.md +260 -3
  2. package/dist/cli.js +3357 -46
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -1,9 +1,266 @@
1
1
  # pontive
2
2
 
3
- The Pontive CLI.
3
+ The Pontive CLI. It adds Pontive sign-in to an app, and when you have no
4
+ Pontive account yet it creates an **unclaimed development instance** for it:
5
+ everything the app needs to run on your machine, plus a link to claim the
6
+ instance into your workspace whenever you sign up.
4
7
 
5
8
  ```sh
6
- npx pontive@latest --help
9
+ npx pontive@latest init
7
10
  ```
8
11
 
9
- Node.js 20 or later.
12
+ Node.js 20 or later. Nothing to install first.
13
+
14
+ ## Commands
15
+
16
+ | Command | Does |
17
+ | --- | --- |
18
+ | `pontive init` | Detects the framework, installs the pontkit package with your package manager, writes the auth route and middleware, and creates an unclaimed development instance. |
19
+ | `pontive claim` | Mints a claim link, opens it in your browser, and waits up to 5 minutes for the claim. |
20
+ | `pontive status` | The instance, its region, when it is deleted unless claimed (or that it is claimed), and which `PONTIVE_*` variables are set. Names only, never values. |
21
+ | `pontive init --reset` | Creates a new unclaimed instance and points `.env.local` at it, after asking (or with `--yes`). |
22
+ | `pontive migrate` | Moves users, passwords, TOTP, social sign-ins and organizations from Auth0, Clerk, Supabase, Firebase or Cognito into an instance. See [Migrating users](#migrating-users-pontive-migrate). |
23
+
24
+ `pontive <command> --help` lists each command's options.
25
+
26
+ ### `pontive init`
27
+
28
+ | Framework | Detected by | Installs | Writes |
29
+ | --- | --- | --- | --- |
30
+ | Next.js | `next` | `@pontive/pontkit-nextjs` | `lib/pontive.ts`, `app/api/auth/[...pontive]/route.ts`, `middleware.ts` (`proxy.ts` from Next 16); under `src/` when the app is |
31
+ | Vite + React | `vite` and `react` | `@pontive/pontkit-react`, `@pontive/pontkit-loader` | `src/pontive.tsx` (the provider), `vite.pontive.ts` (the dev server's `/__pontive` proxy) |
32
+ | Express | `express` | `@pontive/pontkit-server` | `pontive.ts`: `pontiveRoutes` and `pontiveSession` middleware |
33
+ | Node | anything else | `@pontive/pontkit-server` | `pontive.ts`: `handlePontive(req, res)` for `node:http` |
34
+
35
+ JavaScript projects get `.js`/`.jsx` files, CommonJS ones `require`. The package
36
+ manager is the one whose lockfile is there (npm, pnpm, yarn or bun). `init`
37
+ never overwrites a file: one that exists is skipped and reported with what to
38
+ add to it by hand. `--framework` overrides the detection; `--skip-install`
39
+ leaves the install to you.
40
+
41
+ Then the instance. Signed out (`pontive login` is not available yet, so always
42
+ for now), `init` calls `POST https://api.pontive.com/v1/unclaimed-instances`
43
+ and writes:
44
+
45
+ - **`.env.local`**: `PONTIVE_ISSUER`, `PONTIVE_CLIENT_ID`, `PONTIVE_CLIENT_SECRET`
46
+ (web apps), `PONTIVE_SESSION_SECRET` (generated on your machine),
47
+ `PONTIVE_SECRET_KEY`, `PONTIVE_INSTANCE_ID`. Appended: a line already there
48
+ is never overwritten.
49
+ - **`.pontive/keyless.json`**: the instance, its issuer and app, its region,
50
+ its expiry and the **claim token**, which is the instance's ownership. Keep
51
+ it private.
52
+ - **`.gitignore`**: `.env.local` and `.pontive/`.
53
+
54
+ The secrets come back encrypted to a P-256 key the CLI generates for the call
55
+ and keeps only in memory, so they never travel in a response body anything in
56
+ between could keep. An instance already in `.pontive/keyless.json`, or already
57
+ configured in `.env.local`, is used rather than replaced.
58
+
59
+ | Option | |
60
+ | --- | --- |
61
+ | `--region <us\|eu\|au>` | Where the instance lives, for good. Default `PONTIVE_REGION`, else the region nearest you. |
62
+ | `--name <name>` | The project's name. Default: from `package.json`. |
63
+ | `--tenancy-mode <b2c\|b2b>` | Default `b2c`. |
64
+ | `--mcp <agent>` | Connect `claude-code`, `cursor`, `gemini-cli` or `codex` to Pontive's MCP server with the new secret key. |
65
+ | `--no-mcp` | Do not offer to. |
66
+
67
+ **Connecting your coding agent.** When `init` knows the agent (from its
68
+ environment variable, or a `.mcp.json`, `.cursor/` or `.gemini/` in the
69
+ project), it offers to add Pontive's hosted MCP server, with the secret key, to
70
+ that agent's project config (`.mcp.json`, `.cursor/mcp.json`,
71
+ `.gemini/settings.json`) and gitignores the file. It never writes a key into a
72
+ file git already tracks. Codex keeps its config in your home directory, so
73
+ `init` prints what to add instead.
74
+
75
+ ### Unclaimed instances
76
+
77
+ An unclaimed instance is a development instance with Free's limits that
78
+ Pontive deletes, with its users, **7 days** after it was created unless it is
79
+ claimed. Its sign-in accepts only loopback redirects (`localhost` and
80
+ `127.0.0.1`, any port). At most 3 can be created per IP address per day.
81
+
82
+ `pontive claim` mints a claim link: single use, valid for an hour. Open it,
83
+ sign in or sign up, choose a workspace, and the instance moves into it intact:
84
+ its ids, issuer, users, apps and keys do not change, so nothing in your app
85
+ does. The CLI then removes the claim token from `.pontive/keyless.json`.
86
+ `--no-wait` prints the link and returns; `--timeout <seconds>` changes how long
87
+ it waits.
88
+
89
+ When an unclaimed instance has expired, or was claimed by someone else, the CLI
90
+ says so and stops (exit `5`); it never creates a replacement silently, since
91
+ the new instance would have none of your users. `pontive init --reset` creates
92
+ a new one when you choose to.
93
+
94
+ ## Migrating users: `pontive migrate`
95
+
96
+ Moves users, their passwords, TOTP and social sign-ins, and organizations with
97
+ their members from another system into a Pontive instance. Everything goes
98
+ through the management API with the instance's secret key, read from
99
+ `PONTIVE_SECRET_KEY` (never a flag); the key's region picks the API
100
+ (`pontive_sk_live_us_…` → `api.us.pontive.com`), and `PONTIVE_MGMT_URL`
101
+ overrides it in development.
102
+
103
+ ```sh
104
+ export PONTIVE_SECRET_KEY=pontive_sk_live_us_…
105
+ pontive migrate source create --name "Auth0 production" --type auth0 # → msrc_…
106
+ pontive migrate export auth0 --hashes hashes.ndjson # → pontive-users.ndjson
107
+ pontive migrate import pontive-users.ndjson --source msrc_… # a dry run
108
+ pontive migrate import pontive-users.ndjson --source msrc_… --apply # asks, then imports
109
+ pontive migrate records uimp_… --outcome failed
110
+ pontive migrate revert uimp_… --apply # undo
111
+ ```
112
+
113
+ | Subcommand | Does |
114
+ | --- | --- |
115
+ | `export <provider> [--out file]` | Writes the provider's users, then its organizations, as `pontive-users/v1`. |
116
+ | `import <file> [--run uimp_…] [--source msrc_…] [--apply]` | Creates an import run (or uses `--run`), sends users in batches of 100, then organizations in batches of 100 rows and 1,000 members, one batch at a time. |
117
+ | `run <provider> --source msrc_… [--apply]` | `export` and `import` in one go, with nothing written to disk. |
118
+ | `status [uimp_…]` | A run with its options and counters, or the latest runs. |
119
+ | `records <uimp_…> [--outcome failed] [--kind user\|organization]` | Every record of a run, page by page. |
120
+ | `revert <uimp_…> [--apply]` | What the run created that can be deleted; with `--apply`, deletes it, calling until nothing remains. |
121
+ | `source create\|get\|update\|validate\|list\|delete` | Migration sources: `--name`, `--type`, and Firebase's hash parameters. |
122
+
123
+ **Dry run first, always.** `import`, `run` and `revert` only dry-run without
124
+ `--apply`: every batch is sent with `dry_run: true` and the report says what
125
+ would happen. With `--apply` the CLI runs the full dry run, prints its
126
+ summary, asks, and then applies the same batches. `--yes` answers the
127
+ question. In a dry run, an organization whose members are users the same
128
+ import creates is reported as *pending users*, not failed: a dry run creates
129
+ no users for it to find.
130
+
131
+ **Resumable.** `import` keeps `.pontive-import-state.json` beside the file:
132
+ the run, the file's SHA-256, the phase and the last batch applied. Run the
133
+ same command again and it continues in the same run from the next batch;
134
+ batches are idempotent anyway, since a re-sent row matches what it created and
135
+ is skipped. Changing the run's options part way is refused; delete the state
136
+ file to start a new run.
137
+
138
+ **Import options**, fixed on the run once its first batch is applied:
139
+
140
+ | Option | |
141
+ | --- | --- |
142
+ | `--on-existing skip\|update` | A row matching an existing user, by its legacy id or `external_id` (never by email). Default `skip`. |
143
+ | `--allow-weak-passwords` | An imported password that breaks the password policy is not forced to change at first sign-in. |
144
+ | `--identity-connection google=app_…:google` | Import external identities of that type into that app's connection. Repeatable. Without one for a type, those identities are left out (counted in the report) and the users re-link by email at their first sign-in. |
145
+ | `--totp-app app_…` | Store imported TOTP secrets under that app's issuer. Repeatable. Without one, TOTP secrets are left out and the users enroll again. |
146
+ | `--no-events` | No `pontive.user.created` per imported user. |
147
+ | `--role-map org:admin=owner,org:member=member` | Organization roles. With a map, a member holding a role it does not name is left out and reported (`role_not_mapped`); without one, roles are sent as exported. A new organization needs an `owner`. |
148
+ | `--name <name>` | The run's name. |
149
+ | `--delete-after` | With `--apply`: delete the file and its state once applied. |
150
+
151
+ **The report** at the end has the counts (created, updated, skipped, failed)
152
+ for users and organizations, the failures grouped by error code with the rows'
153
+ keys (`identifier_conflict`, `owners_required`, `password_hash_invalid`, …),
154
+ the warnings, how many password users were exported without a hash (they set
155
+ a new password by email at their first Pontive sign-in), and what to do next.
156
+
157
+ ### Exporters
158
+
159
+ Each reads its provider's own credentials from the environment. The heavy SDKs
160
+ are not installed with `pontive`: run with `npx -p pontive -p pg pontive …`,
161
+ or `npm install --no-save pg` in the directory, and the CLI says which.
162
+
163
+ | Provider | Reads | Environment | Passwords | TOTP | Organizations |
164
+ | --- | --- | --- | --- | --- | --- |
165
+ | `auth0` | Management API users export job; organizations and members with roles | `AUTH0_DOMAIN`, `AUTH0_CLIENT_ID`, `AUTH0_CLIENT_SECRET` (scopes `read:users`, `read:organizations`, `read:organization_members`, `read:organization_member_roles`) | bcrypt, from Auth0 support's hash export, decrypted, with `--hashes <file>` | not exported | yes |
166
+ | `clerk` | Backend API users, organizations, memberships | `CLERK_SECRET_KEY` | from the dashboard's CSV export, `--csv <file>` | from the same CSV | yes |
167
+ | `supabase` | `auth.users`, `auth.identities`, `auth.mfa_factors` over Postgres; never the app's tables | `SUPABASE_DB_URL` (or `--db-url`); needs `pg` | bcrypt | verified TOTP factors | none |
168
+ | `firebase` | Admin SDK `listUsers` | `GOOGLE_APPLICATION_CREDENTIALS`; needs `firebase-admin` | Firebase scrypt; the account needs `firebaseauth.configs.getHashConfig` | not exportable | none |
169
+ | `cognito` | `ListUsers`, groups as `metadata.cognito_groups` | AWS credentials, `--user-pool-id`; needs `@aws-sdk/client-cognito-identity-provider` | none: users reset | none | none |
170
+
171
+ `--external-id none` leaves `external_id` unset; by default it is the
172
+ provider's user id, as `legacy_subject` always is, so an app whose database
173
+ keys users by the old id keeps working. Users without an email (phone-only)
174
+ are left out and listed: Pontive requires one. Microsoft and Entra identities
175
+ are left out (their subject differs per app registration, so Pontive cannot
176
+ import it); those users re-link by email. Firebase's hash parameters go on the
177
+ migration source, never in the file:
178
+
179
+ ```sh
180
+ FIREBASE_SIGNER_KEY=… pontive migrate source create --name Firebase --type firebase \
181
+ --salt-separator Bw== --rounds 8 --mem-cost 14 # or --hash-config <file>
182
+ PONTIVE_SAMPLE_PASSWORD=… pontive migrate source validate msrc_… --file pontive-users.ndjson --email known@user.com
183
+ ```
184
+
185
+ ### The `pontive-users/v1` format
186
+
187
+ NDJSON, one JSON object per line. Any system can write it and skip `export`:
188
+
189
+ ```json
190
+ {"format":"pontive-users/v1","source_type":"auth0","exported_at":"2026-12-02T10:00:00Z"}
191
+ {"kind":"user","legacy_subject":"auth0|65f2c1…","email":"jane@acme.com","email_verified":true,"password_hash":{"hasher":"bcrypt","value":"$2b$10$…"}}
192
+ {"kind":"organization","external_id":"org_8Hq2…","name":"Acme Corp","members":[{"legacy_subject":"auth0|65f2c1…","roles":["owner"]}]}
193
+ {"kind":"summary","users":1,"organizations":1,"password_users_without_hash":0}
194
+ ```
195
+
196
+ - The header (first line) and the summary (last line) are optional.
197
+ - A `user` line is `POST /v1/users/import`'s user object, an `organization`
198
+ line `POST /v1/organizations/import`'s organization object, each with
199
+ `kind` beside its fields. Users come before organizations.
200
+ - `legacy_subject` needs a migration source on the run (`--source`).
201
+
202
+ An export holds password hashes and TOTP secrets: the CLI writes it with mode
203
+ `0600` and refuses to overwrite one (`--force`). Keep it out of git and delete
204
+ it once imported (`--delete-after`). The CLI never prints a credential, hash,
205
+ TOTP secret or password.
206
+
207
+ ### Agent mode
208
+
209
+ As for every command (below): JSON only on stdout, and never a prompt, so
210
+ `import --apply`, `run --apply`, `revert --apply` and `source delete` need
211
+ `--yes`; without it they stop before calling anything, with exit `2`. An
212
+ agent runs the dry run, reads its `report`, and applies with
213
+ `--apply --yes`.
214
+
215
+ ```json
216
+ { "ok": true, "command": "migrate", "run_id": "uimp_…", "applied": false,
217
+ "report": { "dry_run": true, "users": { "created": 97, "updated": 0, "skipped": 1, "failed": 2 },
218
+ "failures": [{ "code": "identifier_conflict", "kind": "user", "count": 2, "keys": ["auth0|7a01…", "jo@acme.com"] }],
219
+ "password_users_without_hash": 0, "next_steps": ["…"] } }
220
+ ```
221
+
222
+ ## Agent mode
223
+
224
+ On when `CLAUDECODE`, `CURSOR_AGENT`, `CODEX_SANDBOX`, `GEMINI_CLI` or `CI` is
225
+ set, or with `--json`:
226
+
227
+ - no prompts: a confirmation without `--yes` is answered no;
228
+ - exactly one JSON object on stdout (progress goes to stderr);
229
+ - the claim link is printed, never opened;
230
+ - writes outside `.env.local`, `.pontive/` and the files `init` scaffolds (the
231
+ agent's MCP config, say) need `--yes`.
232
+
233
+ ```json
234
+ { "ok": false, "command": "init", "error": { "code": "unclaimed_instance_limit", "message": "…" }, "retry_after": 3600 }
235
+ ```
236
+
237
+ | Exit code | Meaning |
238
+ | --- | --- |
239
+ | `0` | Success |
240
+ | `1` | Error |
241
+ | `2` | Cancelled (declined, or `--yes` missing in agent mode) |
242
+ | `3` | Rate limited; `retry_after` is in seconds |
243
+ | `4` | Sign-in required |
244
+ | `5` | The unclaimed instance expired or was claimed away |
245
+
246
+ An agent that cannot wait 5 minutes runs `pontive claim --no-wait`, gives the
247
+ user the link, and checks later with `pontive status`.
248
+
249
+ The CLI never prints a secret or the claim token. Server errors are retried
250
+ with the same idempotency key, so a retry never creates a second instance.
251
+
252
+ ## Environment
253
+
254
+ | Variable | |
255
+ | --- | --- |
256
+ | `PONTIVE_API_URL` | Where the provisioning routes live. Default `https://api.pontive.com`. |
257
+ | `PONTIVE_SECRET_KEY` | `migrate`: the instance's secret key. |
258
+ | `PONTIVE_MGMT_URL` | `migrate`: the management API. Default `https://api.{region}.pontive.com`, the key's region. |
259
+ | `PONTIVE_REGION` | The default for `--region`. |
260
+ | `PONTIVE_MCP_URL` | The MCP server `init` connects agents to. Default `https://mcp.<region>.pontive.com/mcp`. |
261
+
262
+ ## Development
263
+
264
+ Commands live one per module in `src/commands/`, each exporting `command`; the
265
+ router finds them there, so a new command is a new file. `npm test`,
266
+ `npm run typecheck` and `npm run build` in this directory.