@reblu/site-next 1.0.0 → 1.2.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 CHANGED
@@ -1,22 +1,33 @@
1
1
  # @reblu/site-next
2
2
 
3
- Next.js glue for Reblu SITEs (REB-418). Two responsibilities, both intentionally
4
- Next-coupled so the lower SDK layers — [`@reblu/site-client`](../site-client),
5
- [`@reblu/site-contracts`](../site-contracts),
3
+ Next.js glue for Reblu SITEs (REB-418, REB-510). Three responsibilities, all
4
+ intentionally Next-coupled so the lower SDK layers —
5
+ [`@reblu/site-client`](../site-client), [`@reblu/site-contracts`](../site-contracts),
6
6
  [`@reblu/site-ui`](../site-ui) — stay framework-agnostic:
7
7
 
8
8
  1. **`NextCacheAdapter`** — implements `@reblu/site-client`'s `RebluCacheAdapter`,
9
9
  translating a cache policy into Next ISR `fetch` options.
10
10
  2. **Editable-CTA glue** — the `EditableCta` async Server Component, its
11
11
  `CtaButtons` `'use client'` boundary, and `StickyMobileCta`.
12
+ 3. **Auth** (`./auth`) + **`createProxyRoute`** (`./route-handlers`) — the
13
+ client auth components (`LoginForm`, password reset, set-password,
14
+ email confirm, MFA step-up, `AuthLogo`) and the server-only Route Handler
15
+ factory that proxies them to base-api's `/api/site/auth/*`.
12
16
 
13
17
  ## Install
14
18
 
15
19
  ```bash
16
- pnpm add @reblu/site-next @reblu/site-client @reblu/site-contracts @reblu/site-ui
20
+ pnpm add @reblu/site-next @reblu/site-client @reblu/site-contracts @reblu/site-ui next-themes
17
21
  ```
18
22
 
19
- Peer deps: `react >=19`, `next >=16`, `@reblu/site-ui`.
23
+ Peer deps: `react >=19`, `next >=16`, `@reblu/site-ui`, `next-themes`.
24
+
25
+ `next-themes` is required by the `./auth` entry as a whole, not only by
26
+ `AuthLogo`: `tsup.config.ts` builds `auth.js`/`auth.cjs` as ONE
27
+ self-contained bundle (`splitting: false`, `treeshake: false`, both required
28
+ to preserve the `'use client'` directive — R4), so importing anything from
29
+ `@reblu/site-next/auth` pulls in `AuthLogo`'s `next-themes` import at module
30
+ resolution time, even if your code never renders `<AuthLogo/>`.
20
31
 
21
32
  ## ISR caching
22
33
 
@@ -57,6 +68,61 @@ import { client } from '@/lib/reblu'
57
68
  `CtaButtons` is additionally available at the `@reblu/site-next/cta-buttons`
58
69
  subpath, which resolves directly to the emitted `'use client'` boundary.
59
70
 
71
+ ## Auth
72
+
73
+ `@reblu/site-next/auth` exports the copy-injectable client components a SITE
74
+ mounts at its auth pages, each with Spanish-default copy overridable via a
75
+ `copy` prop:
76
+
77
+ ```tsx
78
+ import { LoginForm, AuthLogo, mapLoginError } from '@reblu/site-next/auth'
79
+
80
+ <AuthLogo
81
+ logoLightExpandedUrl={config.logoLightExpandedUrl}
82
+ logoDarkExpandedUrl={config.logoDarkExpandedUrl}
83
+ logoLightSmallUrl={config.logoLightSmallUrl}
84
+ logoDarkSmallUrl={config.logoDarkSmallUrl}
85
+ siteName={config.siteName}
86
+ />
87
+ <LoginForm
88
+ passwordLoginUrl="/api/auth/login"
89
+ mfaVerifyUrl="/api/auth/mfa-verify"
90
+ magicLinkRequestUrl="/api/auth/magic-link-request"
91
+ resetPasswordUrl="/reset-password"
92
+ />
93
+ ```
94
+
95
+ | Export | Mount path (fixed by base-api) | Notes |
96
+ | ------------------------- | ----------------------------------- | ----------------------------------------- |
97
+ | `LoginForm` | `/login` | Password + magic-link + MFA |
98
+ | `AuthCallback` | Supabase email-template target | No `AuthLogo` (transient, R1 exception) |
99
+ | `ResetPasswordRequest` | SITE-owned (e.g. `/reset-password`) | Anti-enumeration generic success; posts to its own `requestUrl` prop |
100
+ | `ResetPasswordConfirm` | `/reset-password/confirm` | Includes REB-378 MFA step-up branch |
101
+ | `SetPassword` | `/auth/set-password` | Invite flow, `session_exchange_token` |
102
+ | `AuthConfirm` | `/auth/confirm` | Dual-mode: `success=true` / `token_hash` |
103
+ | `AuthLogo` | — | Dynamic tenant logo, `next-themes`-driven |
104
+ | `mapLoginError` | — | Maps Supabase `?error=` to Spanish copy |
105
+
106
+ `ResetPasswordConfirm`, `SetPassword`, and `AuthConfirm` read their own URL
107
+ params internally via `useSearchParams()`. Next.js requires that hook's
108
+ subtree to render inside a `<Suspense>` boundary — wrap the page/route that
109
+ mounts one of these three in `<Suspense>` yourself (`LoginForm` and
110
+ `AuthCallback` don't need it: they don't call `useSearchParams()`).
111
+
112
+ `createProxyRoute` (`@reblu/site-next/route-handlers`, server-only,
113
+ dependency-free) wires a Route Handler file to base-api in one line:
114
+
115
+ ```ts
116
+ // app/api/auth/login/route.ts
117
+ import { createProxyRoute } from '@reblu/site-next/route-handlers'
118
+
119
+ export const POST = createProxyRoute('/api/site/auth/login')
120
+ ```
121
+
122
+ `baseUrl`/`apiKey` resolve from `opts` first, falling back to the
123
+ `REBLU_API_BASE_URL`/`REBLU_API_KEY` env vars — read lazily per request, not at
124
+ module load.
125
+
60
126
  ## Build
61
127
 
62
128
  `tsup` → dual ESM/CJS + `.d.ts`. Code-splitting is **off** so each entry keeps its