@user-hub/auth 0.3.0 → 0.3.1

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/README.md CHANGED
@@ -54,7 +54,7 @@ Then register the app (`bunx` reads `.env` and `.env.local` automatically; if `H
54
54
  bunx hub-user register --name "Your App" --new --prod https://your-app.com --dev http://localhost:3000
55
55
  ```
56
56
 
57
- It prints your **app key** (made from the name) and the values to set. Not deployed yet? Leave out `--prod`: you can develop, and badge scans start reaching the app once you add it. Run it again with the same `--name` to update the URLs; a URL left out keeps the registered one. `--new` refuses to touch an app that already has that name, so you never take over someone else's; leave it out when updating your own app later. New apps are **listed** in the badge app list by default: when the hub shows the app list instead of one live app, listed apps with a production URL appear in it. Pass `--unlisted` to keep one out of it (it can still be scheduled or forced live), or `--listed` to show it again. Pass neither on an update and the hub's current setting stays; the output shows it. Only the account that created an app, or a hub admin, can update it; anyone else gets exit code 4 and is asked to pick another name. Apps registered before the hub had accounts belong to no account, so only a hub admin can change them. (A hub admin can do the same under **Apps** in the hub, and copy the values from **Setup**.)
57
+ It prints your **app key** (made from the name) and the values to set. Not deployed yet? Leave out `--prod`: you can develop, and badge scans start reaching the app once you add it. Run it again with the same `--name` to update the URLs; a URL left out keeps the registered one. `--new` refuses to touch an app that already has that name, so you never take over someone else's; leave it out when updating your own app later. New apps are **listed** in the badge app list by default: when the hub shows the app list instead of one live app, listed apps with a production URL appear in it. Pass `--unlisted` to keep one out of it (it can still be scheduled or forced live), or `--listed` to show it again. Pass neither on an update and the hub's current setting stays; the output shows it. Any hub account can update any app, so register only under your app's own name. (The same can be done under **Apps** in the hub, with the values under **Setup**.)
58
58
 
59
59
  ### 3. Set the values
60
60
 
@@ -187,7 +187,7 @@ Apps without Convex use `HubAuthProvider` and `HubSignedIn` from `@user-hub/auth
187
187
  | CLI | `hub-user login [--hub <url>] [--browser\|--api-key-stdin]` | Signs the folder in: an API key pasted (hidden) or from stdin, or a browser sign-in it prints a link for (it never opens a browser). Saves `HUB_URL` and `HUB_API_KEY` to `./.env.local` (mode 600) |
188
188
  | | `hub-user whoami [--json]` | The account `HUB_API_KEY` belongs to; exit code 4 when not signed in |
189
189
  | | `hub-user register --name <name> [--prod <url>] [--dev <url>] [--listed\|--unlisted] [--new] [--hub <url>] [--json]` | Registers or updates the app (a new app needs at least one URL; an update may leave both out); `--new` only creates, exit code 3 if the name is taken; `--listed`/`--unlisted` set whether the app shows in the badge app list once it has a production URL (new apps default to listed, omitted keeps the hub's setting) |
190
- | | Exit codes | 0 done, 1 error, 3 name taken (`register --new`), 4 not signed in (run `hub-user login`) or not allowed (another account's app) |
190
+ | | Exit codes | 0 done, 1 error, 3 name taken (`register --new`), 4 not signed in (run `hub-user login`) |
191
191
 
192
192
  ## Developing this package
193
193
 
package/dist/cli.js CHANGED
@@ -44,8 +44,7 @@ listing setting. Running it again with the same name updates that app.
44
44
  whoami and register need HUB_URL and HUB_API_KEY in the environment (.env and
45
45
  .env.local are read automatically); hub-user login puts them there.
46
46
 
47
- Exit codes: 0 done, 1 error, 3 name taken (register --new), 4 not signed in or
48
- not allowed.`;
47
+ Exit codes: 0 done, 1 error, 3 name taken (register --new), 4 not signed in.`;
49
48
  var ENV_FILE = ".env.local";
50
49
  var CLIENT_ID = "hub-user";
51
50
  var DEVICE_GRANT = "urn:ietf:params:oauth:grant-type:device_code";
@@ -331,10 +330,6 @@ async function whoami() {
331
330
  console.log(values.json ? JSON.stringify({ hub, ...me }, null, 2) : `${signedIn(hub, me)}${me.name && me.name !== me.username ? `
332
331
  Name: ${me.name}` : ""}`);
333
332
  }
334
- function forbidden(error = "This account may not change that app.") {
335
- const why = error.split(/(?<=\.)\s+/).filter((sentence) => !/\badmin\b|another name/i.test(sentence)).join(" ").replace(/\.?$/, ".");
336
- return `${why === "." ? "This account may not change that app." : why} Ask a hub admin, or pick another name.`;
337
- }
338
333
  async function register() {
339
334
  const name = values.name?.trim();
340
335
  for (const flag of ["prod", "dev"]) {
@@ -371,9 +366,6 @@ async function register() {
371
366
  if (status === 401) {
372
367
  denied(`${hub} did not accept HUB_API_KEY (deleted, or for another hub): run \`${LOGIN}\``, values.json ? { status: 401 } : undefined);
373
368
  }
374
- if (status === 403) {
375
- denied(forbidden(result.error), values.json ? { status: 403, forbidden: true } : undefined);
376
- }
377
369
  if (!ok) {
378
370
  fail(result.error ?? `the hub answered ${status}`);
379
371
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@user-hub/auth",
3
- "version": "0.3.0",
3
+ "version": "0.3.1",
4
4
  "description": "Sign people in from User Hub badges: Convex auth config, React provider, server verification and the hub-user CLI.",
5
5
  "type": "module",
6
6
  "files": [
@@ -73,9 +73,9 @@ The hub's URL comes from the human (or `HUB_URL` already in `.env.local`, which
73
73
 
74
74
  `--new` makes sure you never take over another app: if the name is already taken, nothing changes and it exits with code 3 and "already exists". Then ask the human for another name and run it again. Drop `--new` only when updating this app's own registration later.
75
75
 
76
- Leave out `--prod` if the app is not deployed yet. Running it again with the same `--name` updates the URLs; a URL left out keeps the registered one, and with no URL flags it keeps the registered URLs and just prints the values. Use the exact name the app has in the hub: the hub finds the app by the key made from the name and saves the name as you typed it. If it exits with code 4, read the message: "not signed in" or "did not accept HUB_API_KEY" means sign in again (**Signing in**); "Ask a hub admin, or pick another name" means the app belongs to another account (apps registered before the hub had accounts belong to none, so only a hub admin can change them): ask the human for another name, or to have a hub admin change it. Do not work around either.
76
+ Leave out `--prod` if the app is not deployed yet. Running it again with the same `--name` updates the URLs; a URL left out keeps the registered one, and with no URL flags it keeps the registered URLs and just prints the values. Use the exact name the app has in the hub: the hub finds the app by the key made from the name and saves the name as you typed it. If it exits with code 4, the hub did not accept this folder's sign-in ("not signed in" or "did not accept HUB_API_KEY"): sign in again (**Signing in**); do not work around it. Any hub account can update any app, so register only under this app's own name, never another app's.
77
77
 
78
- New apps are **listed** in the badge app list by default. When the hub admin sets **Badges go to** to the app list, a scan shows the listed apps that have a production URL and the person picks one; a listed app without a production URL does not appear. Pass `--unlisted` to keep one out of it (it can still be scheduled or forced live), or `--listed` to show it again; in a starter app whose `scripts/setup.ts` mentions `--unlisted`, pass it to `bun run setup`. Pass neither when updating and the hub's current setting stays; the output shows it ("Listed in the badge app list: yes", or "yes, once it has a production URL" without `--prod`). If it says the hub "did not apply" the flag, the hub is too old for the app list: tell the human; the rest of the registration went through.
78
+ New apps are **listed** in the badge app list by default. When whoever runs the hub sets **Badges go to** to the app list, a scan shows the listed apps that have a production URL and the person picks one; a listed app without a production URL does not appear. Pass `--unlisted` to keep one out of it (it can still be scheduled or forced live), or `--listed` to show it again; in a starter app whose `scripts/setup.ts` mentions `--unlisted`, pass it to `bun run setup`. Pass neither when updating and the hub's current setting stays; the output shows it ("Listed in the badge app list: yes", or "yes, once it has a production URL" without `--prod`). If it says the hub "did not apply" the flag, the hub is too old for the app list: tell the human; the rest of the registration went through.
79
79
 
80
80
  It prints the app **key** (made from the name), `HUB_ISSUER` and `HUB_JWKS` (server side) and `VITE_HUB_URL` (frontend). Add `--json` to parse them.
81
81
 
@@ -139,7 +139,7 @@ Then:
139
139
 
140
140
  1. `bunx convex deploy`.
141
141
  2. On the host, set `VITE_CONVEX_URL` (the production deployment's URL) and `VITE_HUB_URL` (the hub's URL).
142
- 3. Tell the human the app is ready for the hub admin to schedule (or force live) under **Schedule**; until then badge scans go to whichever app is live. While **Badges go to** shows the app list, a listed app appears there as soon as it has its production URL.
142
+ 3. Tell the human the app is ready to be scheduled (or forced live) under **Schedule** in the hub; until then badge scans go to whichever app is live. While **Badges go to** shows the app list, a listed app appears there as soon as it has its production URL.
143
143
 
144
144
  ## Hub moved to a new URL
145
145