@aiquants/auth-react-router 0.2.1 → 0.3.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/README.md +8 -8
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -22,8 +22,8 @@ export const authServer = createAuthServer({
|
|
|
22
22
|
isEmailAllowed: emailDomainAllowlist(parseAllowlistCsv(env.ALLOWED_EMAILS), parseAllowlistCsv(env.ALLOWED_DOMAINS)),
|
|
23
23
|
backendAuth: { verify: verifyBackend, signup: (p, t) => signupBackend(p, t) }, // FastAPI verify/signup
|
|
24
24
|
getUserPhoto: async (openid) => (await getOpenids({ openid }))[0]?.picture ?? "", // drizzle TDOpenid
|
|
25
|
-
warmup: async () => { await Promise.all([
|
|
26
|
-
mockUser:
|
|
25
|
+
warmup: async () => { await Promise.all([ensurePrimaryConnection(), ensureSecondaryConnection()]) },
|
|
26
|
+
mockUser: mockUserPort, // test backdoor (E2E) — omit in production-only apps
|
|
27
27
|
})
|
|
28
28
|
export const { authenticator, sessionStorage, getSession, getSessionUser, saveSession, requireUser, requireAdminUser, commitSession, destroySession, authenticate, refreshedAccessToken, authenticateInLoader, loginLoader, loginAction, logoutLoader, logout, logoutAndRedirect, googleCallbackLoader } = authServer
|
|
29
29
|
```
|
|
@@ -46,23 +46,23 @@ Styling: this package has **no hand-written component CSS** (the `GoogleForm` cl
|
|
|
46
46
|
|
|
47
47
|
Never mix the two: importing the standalone utility CSS next to a host Tailwind build duplicates same-named utilities, and base/variant cascade winners flip versus the single-build canonical order.
|
|
48
48
|
|
|
49
|
-
## Behavior
|
|
49
|
+
## Behavior Contract
|
|
50
50
|
|
|
51
51
|
- **Session cookie byte compatibility**: `__session` (httpOnly/lax/30d), key `"user"`, value = `{ id, displayName, name, emails, accessToken, refreshToken?, expirationDateMs?, provider, role? }` — never `photo`/`_json`/`photos`. Changing this invalidates all live 30-day sessions.
|
|
52
|
-
- **Verify order**: Google profile check → `backendAuth.verify` → allowlist → `backendAuth.signup` (every login). Failures redirect to `<loginPath>?error=<encoded
|
|
52
|
+
- **Verify order**: Google profile check → `backendAuth.verify` → allowlist → `backendAuth.signup` (every login). Failures redirect to `<loginPath>?error=<encoded error message>` (messages overridable via `messages`).
|
|
53
53
|
- **Token refresh**: expiry check → Google `oauth2/v4/token` rotate → session update; `invalid_grant` destroys the session and redirects to login with `Set-Cookie`.
|
|
54
54
|
- **Loader guard**: `authenticateInLoader(request, { failureRedirect })` returns `{ user?, cookie? }`; `failureRedirect: null` = no-redirect mode. Photo lookups are cached with in-flight dedup per factory instance.
|
|
55
55
|
|
|
56
|
-
## DI
|
|
56
|
+
## DI Ports Absorbing Per-App Differences
|
|
57
57
|
|
|
58
|
-
| Port |
|
|
58
|
+
| Port | App A | App B |
|
|
59
59
|
| --- | --- | --- |
|
|
60
60
|
| `google.scopes` | default | + `directory.readonly` etc. |
|
|
61
61
|
| `mockUser` | `mock_user_id` cookie parse + name map | fixed id |
|
|
62
62
|
| `warmup` | 2 pools | 1 pool |
|
|
63
|
-
| `backendAuth` |
|
|
63
|
+
| `backendAuth` | primary-api | secondary-api |
|
|
64
64
|
|
|
65
|
-
## Intentional
|
|
65
|
+
## Intentional Changes vs Original (§8, approved)
|
|
66
66
|
|
|
67
67
|
1. No import-time env reads/throws — all validation happens in `createAuthServer`.
|
|
68
68
|
2. Allowlist matching is trim+lowercase (unified with the Python side via `@aiquants/auth-core`).
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aiquants/auth-react-router",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "React Router v7 auth adapter for @aiquants/auth-core: Google OAuth strategy factory (remix-auth), cookie session storage with DI test backdoor, per-request loader guard with token refresh + photo cache, auth route handlers, and a <GoogleForm> login button.",
|
|
5
5
|
"sideEffects": [
|
|
6
6
|
"**/*.css"
|