@protobase/cli 0.63.1 → 0.63.2

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.
@@ -1,4 +1,4 @@
1
1
  //#region package.json
2
- var version = "0.63.1";
2
+ var version = "0.63.2";
3
3
  //#endregion
4
4
  export { version };
@@ -87,12 +87,13 @@ const registerUsers = (program) => {
87
87
  });
88
88
  };
89
89
  const registerToken = (program) => {
90
- program.command("token").description("Print a bearer token (JWT) for an existing user").argument("<email>").option("--ttl <duration>", "lifetime: 30s, 15m, up to 24h", "15m").action(async (email, opts) => {
90
+ program.command("token").description("Print a bearer token (JWT) for an existing user").argument("<email>").option("--ttl <duration>", "lifetime: 30s, 15m, up to 24h", "15m").option("--organization <slug|id>", "with organizations, the one the token works in (default: where a new session starts)").action(async (email, opts) => {
91
91
  const ttlSeconds = parseTtl(opts.ttl);
92
92
  const [{ issueToken }, auth] = await Promise.all([import("@protobase/server"), loadAuth()]);
93
93
  const { token } = await issueToken(auth, {
94
94
  email,
95
- ttlSeconds
95
+ ttlSeconds,
96
+ ...opts.organization !== void 0 && { organization: opts.organization }
96
97
  });
97
98
  out(`${token}\n`);
98
99
  finish(0);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@protobase/cli",
3
- "version": "0.63.1",
3
+ "version": "0.63.2",
4
4
  "description": "The protobase command: scaffold, doctor, dev, build and serve a Protobase project.",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -42,12 +42,12 @@
42
42
  "dependencies": {
43
43
  "@better-auth/core": "^1.7.12",
44
44
  "@hono/node-server": "^2.1.3",
45
- "@protobase/config": "0.63.1",
46
- "@protobase/layout": "0.63.1",
47
- "@protobase/query": "0.63.1",
48
- "@protobase/schema": "0.63.1",
49
- "@protobase/server": "0.63.1",
50
- "@protobase/ui": "0.63.1",
45
+ "@protobase/config": "0.63.2",
46
+ "@protobase/layout": "0.63.2",
47
+ "@protobase/query": "0.63.2",
48
+ "@protobase/schema": "0.63.2",
49
+ "@protobase/server": "0.63.2",
50
+ "@protobase/ui": "0.63.2",
51
51
  "@react-email/render": "^2.1.0",
52
52
  "@scalar/hono-api-reference": "^0.12.10",
53
53
  "@tailwindcss/vite": "^4.3.3",
@@ -30,6 +30,6 @@ Sign-in methods, users, roles, organizations and tokens.
30
30
  - [Immediate revocation](../reference/auth.md#when-a-token-stops-working): A ban, removed role or ended session takes effect on the next request.
31
31
  - [Signing key rotation](../reference/auth.md#signing-keys): The keys that sign the tokens are replaced every 30 days on their own, and old ones keep verifying the tokens they signed for a week.
32
32
  - [Changing the secret](../reference/auth.md#changing-the-secret): The app's secret can change while the signing keys keep signing, by listing the old secret beside the new one.
33
- - [Tokens for scripts](../reference/auth.md#tokens-for-scripts-and-curl): A token for an existing user, for scripts and curl.
33
+ - [Tokens for scripts](../reference/auth.md#tokens-for-scripts-and-curl): A token for an existing user, for scripts and curl, in any organization they work in.
34
34
  - [Several origins](../reference/auth.md#several-origins): One app works on several domains, such as its own address and a custom domain.
35
35
  - [Sign-in rate limits](../reference/auth.md#client-addresses): Sign-in and code requests are limited per client address, also behind a proxy.
@@ -727,9 +727,10 @@ import { issueToken } from '@protobase/server'
727
727
 
728
728
  const auth = await loadProjectAuth(process.cwd())
729
729
  const { token, expiresAt } = await issueToken(auth, { email: 'you@example.com', ttlSeconds: 3600 }) // default 15 minutes, at most 24 hours
730
+ const inGlobex = await issueToken(auth, { email: 'you@example.com', organization: 'globex' }) // with organizations
730
731
  ```
731
732
 
732
- It is signed with the same keys and carries the same claims as a token from `/api/auth/token`, with the role the user last chose, else their first, so the API treats it as any other, and a ban, a role taken away or the user deleted ends it before it expires. Banned and unknown users get an error. There is no HTTP route for this.
733
+ It is signed with the same keys and carries the same claims as a token from `/api/auth/token` for a new session of the user, with the role the user last chose, else their first, so the API treats it as any other. With [organizations](#organizations) it works in the organization a new session would start in, the one the user last worked in, else their oldest membership, and carries its `org`, `org_role` and `app_roles`; `organization`, an id or slug (`protobase token --organization`), names another, and is refused when the user may not work there, and a user in no organization gets a token without one. A ban, a role taken away or the user deleted ends it before it expires. Banned and unknown users get an error. There is no HTTP route for this.
733
734
 
734
735
  ## OAuth for MCP clients
735
736
 
@@ -608,10 +608,10 @@ Builds the project in the current directory as an iOS or Android app with Capaci
608
608
  ## `token`
609
609
 
610
610
  ```sh
611
- protobase token <email> [--ttl 15m]
611
+ protobase token <email> [--ttl 15m] [--organization <slug|id>]
612
612
  ```
613
613
 
614
- Prints a bearer token (JWT, signed with the project's Better Auth keys, same claims as a browser token) for an existing user. The lifetime is `30s`, `15m`, `24h`, ... up to 24 hours, default 15 minutes. Only the token goes to stdout and errors go to stderr, so it composes in scripts:
614
+ Prints a bearer token (JWT, signed with the project's Better Auth keys, same claims as a browser token) for an existing user. The lifetime is `30s`, `15m`, `24h`, ... up to 24 hours, default 15 minutes. With [organizations](auth.md#organizations), `--organization` names the one the token works in; without it, the token works where a new session of the user would start. Only the token goes to stdout and errors go to stderr, so it composes in scripts:
615
615
 
616
616
  ```sh
617
617
  curl -H "Authorization: Bearer $(protobase token me@x)" http://localhost:5173/api/v1/orders?page_size=1