@jxsuite/auth 0.5.7 → 0.6.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 +10 -36
- package/package.json +6 -6
- package/src/Auth.class.json +1 -1
package/README.md
CHANGED
|
@@ -4,12 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
## Overview
|
|
6
6
|
|
|
7
|
-
`@jxsuite/auth` is the Jx extension putting users behind the connector's data tables. It owns the
|
|
8
|
-
project.json `auth` section and mounts [Better Auth](https://better-auth.com) at
|
|
9
|
-
`/_jx/auth`, publishing the `ctx.auth = { getSession, authorize }` hooks on the shared server
|
|
10
|
-
context (specs/extensions.md §11). That mount runs at **order 10**, ahead of the connector's
|
|
11
|
-
`/_jx/data` mount (order 20). With it active, table permission rules beyond `public`/`none` come
|
|
12
|
-
alive:
|
|
7
|
+
`@jxsuite/auth` is the Jx extension putting users behind the connector's data tables. It owns the project.json `auth` section and mounts [Better Auth](https://better-auth.com) at `/_jx/auth`, publishing the `ctx.auth = { getSession, authorize }` hooks on the shared server context (specs/extensions.md §11). That mount runs at **order 10**, ahead of the connector's `/_jx/data` mount (order 20). With it active, table permission rules beyond `public`/`none` come alive:
|
|
13
8
|
|
|
14
9
|
| Rule | Grants |
|
|
15
10
|
| --------------- | ------------------------------------------------------------------------------------------------- |
|
|
@@ -19,15 +14,9 @@ alive:
|
|
|
19
14
|
|
|
20
15
|
Without the auth mount the data mount **fails closed**: only `public` rules pass.
|
|
21
16
|
|
|
22
|
-
Declaring an `ownerField` makes that column authoritative: **every** session-granted insert
|
|
23
|
-
(`authenticated`, `owner`, `role:<r>`) stamps it with the signed-in user's id, so clients can
|
|
24
|
-
never forge ownership.
|
|
17
|
+
Declaring an `ownerField` makes that column authoritative: **every** session-granted insert (`authenticated`, `owner`, `role:<r>`) stamps it with the signed-in user's id, so clients can never forge ownership.
|
|
25
18
|
|
|
26
|
-
The auth system tables (`user`, `session`, `account`, `verification`) live on an ordinary
|
|
27
|
-
connector connection, named by `auth.connection` and defaulting to the project's first-declared
|
|
28
|
-
connection. Better Auth's additive migrations create them: `jx db push` (or the Studio's push
|
|
29
|
-
button) plans them as `kind: "auth"` steps after the connector plan, and the dev server also syncs
|
|
30
|
-
them on first touch of `/_jx/auth`.
|
|
19
|
+
The auth system tables (`user`, `session`, `account`, `verification`) live on an ordinary connector connection, named by `auth.connection` and defaulting to the project's first-declared connection. Better Auth's additive migrations create them: `jx db push` (or the Studio's push button) plans them as `kind: "auth"` steps after the connector plan, and the dev server also syncs them on first touch of `/_jx/auth`.
|
|
31
20
|
|
|
32
21
|
## Enable it
|
|
33
22
|
|
|
@@ -55,10 +44,7 @@ them on first touch of `/_jx/auth`.
|
|
|
55
44
|
}
|
|
56
45
|
```
|
|
57
46
|
|
|
58
|
-
Secrets never enter project.json (specs/extensions.md §13): set the signing secret under the env
|
|
59
|
-
var named by `auth.secretEnv` (default `BETTER_AUTH_SECRET`) in `.dev.vars` locally and via
|
|
60
|
-
`wrangler secret put` in production. Social providers name their credential env vars the same way
|
|
61
|
-
(`providers.github.clientIdEnv`, defaulting to `GITHUB_CLIENT_ID` / `GITHUB_CLIENT_SECRET`).
|
|
47
|
+
Secrets never enter project.json (specs/extensions.md §13): set the signing secret under the env var named by `auth.secretEnv` (default `BETTER_AUTH_SECRET`) in `.dev.vars` locally and via `wrangler secret put` in production. Social providers name their credential env vars the same way (`providers.github.clientIdEnv`, defaulting to `GITHUB_CLIENT_ID` / `GITHUB_CLIENT_SECRET`).
|
|
62
48
|
|
|
63
49
|
## Page UX
|
|
64
50
|
|
|
@@ -71,27 +57,15 @@ var named by `auth.secretEnv` (default `BETTER_AUTH_SECRET`) in `.dev.vars` loca
|
|
|
71
57
|
}
|
|
72
58
|
```
|
|
73
59
|
|
|
74
|
-
- **`Session`** resolves to `{ userId, role?, user }` or `null` and updates live via
|
|
75
|
-
|
|
76
|
-
render the signed-out state.
|
|
77
|
-
- **`AuthActions`** resolves to `{ signInEmail, signUpEmail, signInSocial, signOut }`. Wire a
|
|
78
|
-
form's `onsubmit` to `{ "$ref": "auth.signInEmail" }` and the handler reads the form's
|
|
79
|
-
`email`/`password` fields, refreshes the session store, bumps the `_v` read-after-write version,
|
|
80
|
-
and applies `auth.redirects`.
|
|
60
|
+
- **`Session`** resolves to `{ userId, role?, user }` or `null` and updates live via `subscribe()`. Outside browsers it resolves to `null`, so statically generated pages always render the signed-out state.
|
|
61
|
+
- **`AuthActions`** resolves to `{ signInEmail, signUpEmail, signInSocial, signOut }`. Wire a form's `onsubmit` to `{ "$ref": "auth.signInEmail" }` and the handler reads the form's `email`/`password` fields, refreshes the session store, bumps the `_v` read-after-write version, and applies `auth.redirects`.
|
|
81
62
|
|
|
82
63
|
## v1 cuts
|
|
83
64
|
|
|
84
|
-
- **No email transport**: no verification or password-reset emails ship in v1, so email/password
|
|
85
|
-
|
|
86
|
-
- **
|
|
87
|
-
`role` column to the user table); assign them by editing user rows in the Studio's data grid.
|
|
88
|
-
Sign-up input can never set a role.
|
|
89
|
-
- **Public-insert abuse**: a table with `insert: "public"` accepts writes from anyone on the
|
|
90
|
-
internet. Prefer `authenticated` inserts, or accept the risk knowingly (rate limiting /
|
|
91
|
-
Turnstile are future work).
|
|
65
|
+
- **No email transport**: no verification or password-reset emails ship in v1, so email/password accounts are live immediately after sign-up.
|
|
66
|
+
- **Roles are edited via the data grid**: declare role names in `auth.roles` (this adds the `role` column to the user table); assign them by editing user rows in the Studio's data grid. Sign-up input can never set a role.
|
|
67
|
+
- **Public-insert abuse**: a table with `insert: "public"` accepts writes from anyone on the internet. Prefer `authenticated` inserts, or accept the risk knowingly (rate limiting / Turnstile are future work).
|
|
92
68
|
|
|
93
69
|
## Versioning
|
|
94
70
|
|
|
95
|
-
Published to npm as `@jxsuite/auth`, TypeScript source like every `@jxsuite` package, following
|
|
96
|
-
the monorepo's release train. Depends on `@jxsuite/connector` (the `resolveDialect` seam and the
|
|
97
|
-
permission/hook types it publishes for dependents); core packages never depend on this extension.
|
|
71
|
+
Published to npm as `@jxsuite/auth`, TypeScript source like every `@jxsuite` package, following the monorepo's release train. Depends on `@jxsuite/connector` (the `resolveDialect` seam and the permission/hook types it publishes for dependents); core packages never depend on this extension.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jxsuite/auth",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.1",
|
|
4
4
|
"description": "Better Auth sessions, sign-in flows, and table permissions for Jx sites over /_jx/auth",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -38,13 +38,13 @@
|
|
|
38
38
|
"upgrade": "bun update --latest && bun install"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@jxsuite/connector": "^0.
|
|
42
|
-
"@jxsuite/schema": "^2.
|
|
43
|
-
"better-auth": "^1.7.
|
|
44
|
-
"kysely": "^0.29.
|
|
41
|
+
"@jxsuite/connector": "^0.6.1",
|
|
42
|
+
"@jxsuite/schema": "^2.3.0",
|
|
43
|
+
"better-auth": "^1.7.6",
|
|
44
|
+
"kysely": "^0.29.6"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
|
-
"@happy-dom/global-registrator": "^20.
|
|
47
|
+
"@happy-dom/global-registrator": "^20.14.5",
|
|
48
48
|
"ajv": "^8.20.0"
|
|
49
49
|
},
|
|
50
50
|
"jx": "./jx-extension.json"
|