@molecule/app-auth-modal-react 1.0.0 → 1.1.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 ADDED
@@ -0,0 +1,308 @@
1
+ <!--
2
+ AUTO-GENERATED — DO NOT EDIT THIS FILE.
3
+ Generated by `mlcl sync-docs` from the package's src/index.ts JSDoc + mlcl/registry.json.
4
+ Edits here are overwritten on the next commit (molecule's pre-commit hook regenerates).
5
+ To change this document, edit the module-level JSDoc in src/index.ts.
6
+ Generated: 2026-08-17T05:34:54.179Z
7
+ -->
8
+
9
+ # @molecule/app-auth-modal-react
10
+
11
+ > **Auto-generated, AI-first package reference** for the [molecule.dev](https://molecule.dev) ecosystem.
12
+ > It is written to be read by coding agents as much as by people, and is generated from this
13
+ > package's source — edit `src/index.ts` JSDoc, not this file.
14
+
15
+ `@molecule/app-auth-modal-react` — the shared in-app login / signup /
16
+ upgrade flow. Mount {@link AuthModalMount} ONCE inside the app's
17
+ providers (where the `@molecule/app-react` auth hooks work) and every
18
+ in-app `/login` / `/signup` link opens the {@link AuthModal} instead of
19
+ navigating, while `/pricing` / `/billing` links open the upgrade flow in
20
+ a new tab (session auto-refreshes when the user returns) — no
21
+ navigation, no reload, no lost work. OAuth runs in a popup
22
+ (`loginViaPopup`), so social login never navigates the host either.
23
+
24
+ ## Quick Start
25
+
26
+ ```tsx
27
+ import { AuthModalMount } from '@molecule/app-auth-modal-react'
28
+ import { oauthConfig } from './config.js'
29
+
30
+ // Once, inside the app's providers (e.g. in App.tsx):
31
+ ;<AuthModalMount oauthConfig={oauthConfig} onAuthenticated={() => claimGuestWork()} />
32
+ // Every plain <a href="/login">, <a href="/signup">, <a href="/pricing">
33
+ // anywhere in the app is now intercepted — no other wiring needed.
34
+ ```
35
+
36
+ ## Type
37
+
38
+ `feature`
39
+
40
+ ## Installation
41
+
42
+ ```bash
43
+ npm install @molecule/app-auth-modal-react @molecule/app-auth-shell-react @molecule/app-i18n @molecule/app-oauth-buttons-react @molecule/app-react @molecule/app-ui @molecule/app-ui-react react
44
+ npm install -D @types/react
45
+ ```
46
+
47
+ ## API
48
+
49
+ ### Interfaces
50
+
51
+ #### `AuthModalMountProps`
52
+
53
+ Props for {@link AuthModalMount}.
54
+
55
+ ```typescript
56
+ interface AuthModalMountProps {
57
+ /** OAuth config from the app's `config.ts` (drives the popup OAuth buttons). */
58
+ oauthConfig: AuthModalProps['oauthConfig']
59
+ /** Run before any login attempt (e.g. stash the guest id). Optional. */
60
+ onBeforeAuth?: () => void
61
+ /** Run after a successful login (session already refreshed). Optional. */
62
+ onAuthenticated?: () => void | Promise<void>
63
+ /**
64
+ * Run when the user returns to this tab after the upgrade tab (the session is
65
+ * already refreshed here) — e.g. invalidate usage so a budget banner clears.
66
+ * Only fires for the default new-tab flow; irrelevant when
67
+ * {@link AuthModalMountProps.onUpgradeIntercept} is set. Optional.
68
+ */
69
+ onUpgradeReturn?: () => void
70
+ /**
71
+ * Take over upgrade/billing CTA clicks instead of opening a new tab: called
72
+ * with the matched upgrade path (e.g. `/pricing`), navigation already
73
+ * prevented. The host renders its own upgrade UI (typically a modal) and owns
74
+ * refreshing the session when that flow completes. Optional — when omitted,
75
+ * the default new-tab flow (+ focus-return refresh) applies.
76
+ */
77
+ onUpgradeIntercept?: (path: string) => void
78
+ /**
79
+ * Human-verification challenge rendered inside the modal's SIGNUP form — see
80
+ * {@link AuthModalProps.captchaSlot}. Pass it together with
81
+ * {@link AuthModalMountProps.captchaSolved} whenever the app's signup API
82
+ * requires a challenge token, otherwise the in-app signup POSTs without one
83
+ * while the standalone `/signup` page (which renders its own widget) works —
84
+ * a mismatch the user experiences as "complete the challenge" with no
85
+ * challenge on screen. Optional.
86
+ */
87
+ captchaSlot?: AuthModalProps['captchaSlot']
88
+ /** Whether {@link AuthModalMountProps.captchaSlot} is solved; `false` disables the signup submit. Defaults to `true`. */
89
+ captchaSolved?: AuthModalProps['captchaSolved']
90
+ /** Override the auth path→mode map (defaults to `/login`,`/signup`). */
91
+ authPaths?: Readonly<Record<string, AuthModalMode>>
92
+ /** Override the upgrade paths opened in a new tab (defaults to `/pricing`,`/billing`). */
93
+ upgradePaths?: readonly string[]
94
+ }
95
+ ```
96
+
97
+ #### `AuthModalProps`
98
+
99
+ Props for {@link AuthModal}.
100
+
101
+ ```typescript
102
+ interface AuthModalProps {
103
+ /** Whether the modal is open. */
104
+ open: boolean
105
+ /** Close without authenticating (backdrop / Escape / ✕). */
106
+ onClose: () => void
107
+ /** Which form to open on. Defaults to `'signup'`. */
108
+ initialMode?: AuthModalMode
109
+ /**
110
+ * OAuth config consumed by `useOAuth()` — `{ baseURL, oauthProviders, oauthEndpoint }`
111
+ * from the app's `config.ts`. Drives the popup OAuth buttons.
112
+ */
113
+ oauthConfig: Parameters<typeof useOAuth>[0]
114
+ /**
115
+ * Run synchronously BEFORE any login/signup/OAuth attempt — e.g. stash the guest
116
+ * id so the new session can claim its work. Optional.
117
+ */
118
+ onBeforeAuth?: () => void
119
+ /**
120
+ * Run AFTER a successful login/signup/OAuth (the session is already refreshed),
121
+ * still on the same page — e.g. claim guest projects, invalidate usage. Optional.
122
+ */
123
+ onAuthenticated?: () => void | Promise<void>
124
+ /**
125
+ * A human-verification challenge rendered inside the SIGNUP form, above the
126
+ * submit button (e.g. the app's Turnstile/hCaptcha widget). Login is not
127
+ * gated, so the slot is unmounted in login mode — which lets the widget clear
128
+ * its own token when the user switches tabs and re-issue a fresh one on the
129
+ * way back.
130
+ *
131
+ * The modal stays provider-agnostic: it renders the node and never inspects
132
+ * it. An app whose signup API requires a challenge MUST pass
133
+ * {@link AuthModalProps.captchaSolved} as well, or the form will submit
134
+ * without a token and the API will reject it.
135
+ *
136
+ * Optional — omitted (the default for apps with no challenge) the signup form
137
+ * is unchanged.
138
+ */
139
+ captchaSlot?: ReactNode
140
+ /**
141
+ * Whether the {@link AuthModalProps.captchaSlot} challenge is currently
142
+ * solved. `false` disables the signup submit, so the form cannot POST a
143
+ * missing/expired token. Defaults to `true` (no challenge → nothing to wait
144
+ * for). Ignored in login mode.
145
+ */
146
+ captchaSolved?: boolean
147
+ }
148
+ ```
149
+
150
+ ### Types
151
+
152
+ #### `AuthModalMode`
153
+
154
+ Which form {@link AuthModal} should show.
155
+
156
+ ```typescript
157
+ type AuthModalMode = 'login' | 'signup'
158
+ ```
159
+
160
+ ### Functions
161
+
162
+ #### `AuthModal(props)`
163
+
164
+ The in-app auth modal: login/signup tabs rendered in a Modal overlay — the user authenticates without leaving the current page (no navigation, no lost work). Usually rendered via `AuthModalMount`, not directly.
165
+
166
+ ```typescript
167
+ function AuthModal({
168
+ open,
169
+ onClose,
170
+ initialMode = 'signup',
171
+ oauthConfig,
172
+ onBeforeAuth,
173
+ onAuthenticated,
174
+ captchaSlot,
175
+ captchaSolved = true,
176
+ }: AuthModalProps): JSX.Element
177
+ ```
178
+
179
+ - `props` — {@link AuthModalProps}.
180
+
181
+ **Returns:** The modal element (renders nothing when closed).
182
+
183
+ #### `AuthModalMount(props)`
184
+
185
+ Mounts the in-app auth modal + the CTA click-interceptor: renders the (initially hidden) AuthModal and installs a capture-phase document click handler that opens it for in-app `/login`/`/signup` links (and routes `/pricing`/`/billing` clicks to the upgrade flow). Mount ONCE inside the app providers.
186
+
187
+ ```typescript
188
+ function AuthModalMount({
189
+ oauthConfig,
190
+ onBeforeAuth,
191
+ onAuthenticated,
192
+ onUpgradeReturn,
193
+ onUpgradeIntercept,
194
+ captchaSlot,
195
+ captchaSolved,
196
+ authPaths = DEFAULT_AUTH_PATHS,
197
+ upgradePaths = DEFAULT_UPGRADE_PATHS,
198
+ }: AuthModalMountProps): JSX.Element
199
+ ```
200
+
201
+ - `props` — {@link AuthModalMountProps}.
202
+
203
+ **Returns:** The (lazily-mounted) auth modal element.
204
+
205
+ #### `authModeForHref(href, origin, authPaths)`
206
+
207
+ Map a CTA link's href to the auth mode it should open, or `null` if it is not
208
+ an auth link (so the interceptor leaves it alone).
209
+
210
+ ```typescript
211
+ function authModeForHref(
212
+ href: string | null | undefined,
213
+ origin: string,
214
+ authPaths?: Readonly<Record<string, AuthModalMode>>,
215
+ ): AuthModalMode | null
216
+ ```
217
+
218
+ - `href` — The clicked anchor's href (relative or absolute).
219
+ - `origin` — The page origin to resolve a relative href against.
220
+ - `authPaths` — Path→mode map (defaults to {@link DEFAULT_AUTH_PATHS}).
221
+
222
+ **Returns:** `'login'` / `'signup'`, else `null`.
223
+
224
+ #### `upgradePathForHref(href, origin, upgradePaths)`
225
+
226
+ Whether a CTA link's href points at the upgrade/billing flow (which the
227
+ interceptor hands to the host's `onUpgradeIntercept`, else opens in a new tab).
228
+
229
+ ```typescript
230
+ function upgradePathForHref(
231
+ href: string | null | undefined,
232
+ origin: string,
233
+ upgradePaths?: readonly string[],
234
+ ): string | null
235
+ ```
236
+
237
+ - `href` — The clicked anchor's href (relative or absolute).
238
+ - `origin` — The page origin to resolve a relative href against.
239
+ - `upgradePaths` — The upgrade paths (defaults to {@link DEFAULT_UPGRADE_PATHS}).
240
+
241
+ **Returns:** The matched pathname, else `null`.
242
+
243
+ ### Constants
244
+
245
+ #### `DEFAULT_AUTH_PATHS`
246
+
247
+ The default in-app auth routes that open the modal.
248
+
249
+ ```typescript
250
+ const DEFAULT_AUTH_PATHS: Readonly<Record<string, AuthModalMode>>
251
+ ```
252
+
253
+ #### `DEFAULT_UPGRADE_PATHS`
254
+
255
+ The default routes that open the upgrade/billing flow (modal or new tab).
256
+
257
+ ```typescript
258
+ const DEFAULT_UPGRADE_PATHS: readonly string[]
259
+ ```
260
+
261
+ ## Injection Notes
262
+
263
+ ### Requirements
264
+
265
+ Peer dependencies:
266
+
267
+ - `@molecule/app-auth-shell-react` ^1.0.1
268
+ - `@molecule/app-i18n` ^1.0.1
269
+ - `@molecule/app-oauth-buttons-react` ^1.0.1
270
+ - `@molecule/app-react` ^1.0.1
271
+ - `@molecule/app-ui` ^1.0.1
272
+ - `@molecule/app-ui-react` ^1.0.1
273
+ - `react` ^18.0.0 || ^19.0.0
274
+
275
+ ### Runtime Dependencies
276
+
277
+ - `@molecule/app-auth-shell-react`
278
+ - `@molecule/app-i18n`
279
+ - `@molecule/app-oauth-buttons-react`
280
+ - `@molecule/app-react`
281
+ - `@molecule/app-ui`
282
+ - `@molecule/app-ui-react`
283
+ - `react`
284
+
285
+ Interception is capture-phase on `document` and matches plain
286
+ left-clicks on `<a href>` whose resolved pathname is in `authPaths`
287
+ (default `/login`, `/signup`) or `upgradePaths` (default `/pricing`,
288
+ `/billing`) — modifier/middle clicks still navigate normally, and
289
+ non-anchor buttons that call `navigate()` are NOT intercepted. Hosts
290
+ that render pricing in-place pass `onUpgradeIntercept` and own that UI
291
+
292
+ - the post-upgrade session refresh. `AuthModalMount` must render inside
293
+ the app's auth/HTTP providers (it calls `useAuth`), and the standalone
294
+ `/login` & `/signup` pages should stay routed — they are the fallback
295
+ for modifier clicks and deep links. App-specific extras (stash a guest
296
+ id, claim guest work, invalidate usage) go in `onBeforeAuth` /
297
+ `onAuthenticated`. The modal's `auth.modal.*` strings are homed in the
298
+ `@molecule/app-locales-common` bond (79 languages), alongside the
299
+ `auth.login.*` / `auth.signup.*` keys the modal also renders.
300
+
301
+ If the signup API requires a human-verification challenge (Turnstile /
302
+ hCaptcha), pass BOTH `captchaSlot` (the widget, rendered in the signup
303
+ form) and `captchaSolved` (which gates the submit). Rendering the widget
304
+ on the standalone `/signup` page alone is NOT enough: this modal is what
305
+ a `/signup` link actually opens, so the in-app signup would POST with no
306
+ token and the API would answer "complete the verification challenge"
307
+ while no challenge is on screen. Login is not gated, so the slot is
308
+ unmounted in login mode.
@@ -16,7 +16,7 @@
16
16
  *
17
17
  * @module
18
18
  */
19
- import { type JSX } from 'react';
19
+ import { type JSX, type ReactNode } from 'react';
20
20
  import { useOAuth } from '@molecule/app-react';
21
21
  import type { AuthModalMode } from './cta-intercept.js';
22
22
  /** Props for {@link AuthModal}. */
@@ -42,6 +42,29 @@ export interface AuthModalProps {
42
42
  * still on the same page — e.g. claim guest projects, invalidate usage. Optional.
43
43
  */
44
44
  onAuthenticated?: () => void | Promise<void>;
45
+ /**
46
+ * A human-verification challenge rendered inside the SIGNUP form, above the
47
+ * submit button (e.g. the app's Turnstile/hCaptcha widget). Login is not
48
+ * gated, so the slot is unmounted in login mode — which lets the widget clear
49
+ * its own token when the user switches tabs and re-issue a fresh one on the
50
+ * way back.
51
+ *
52
+ * The modal stays provider-agnostic: it renders the node and never inspects
53
+ * it. An app whose signup API requires a challenge MUST pass
54
+ * {@link AuthModalProps.captchaSolved} as well, or the form will submit
55
+ * without a token and the API will reject it.
56
+ *
57
+ * Optional — omitted (the default for apps with no challenge) the signup form
58
+ * is unchanged.
59
+ */
60
+ captchaSlot?: ReactNode;
61
+ /**
62
+ * Whether the {@link AuthModalProps.captchaSlot} challenge is currently
63
+ * solved. `false` disables the signup submit, so the form cannot POST a
64
+ * missing/expired token. Defaults to `true` (no challenge → nothing to wait
65
+ * for). Ignored in login mode.
66
+ */
67
+ captchaSolved?: boolean;
45
68
  }
46
69
  /**
47
70
  * The in-app auth modal: login/signup tabs rendered in a Modal overlay — the user authenticates without leaving the current page (no navigation, no lost work). Usually rendered via `AuthModalMount`, not directly.
@@ -49,7 +72,7 @@ export interface AuthModalProps {
49
72
  * @param props - {@link AuthModalProps}.
50
73
  * @returns The modal element (renders nothing when closed).
51
74
  */
52
- export declare function AuthModal({ open, onClose, initialMode, oauthConfig, onBeforeAuth, onAuthenticated, }: AuthModalProps): JSX.Element;
75
+ export declare function AuthModal({ open, onClose, initialMode, oauthConfig, onBeforeAuth, onAuthenticated, captchaSlot, captchaSolved, }: AuthModalProps): JSX.Element;
53
76
  export declare namespace AuthModal {
54
77
  var displayName: string;
55
78
  }
@@ -1 +1 @@
1
- {"version":3,"file":"AuthModal.d.ts","sourceRoot":"","sources":["../src/AuthModal.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAAE,KAAK,GAAG,EAAuB,MAAM,OAAO,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UAAU,CAAC,OAAO,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAA;IAC3C;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,IAAI,CAAA;IACzB;;;OAGG;IACH,eAAe,CAAC,EAAE,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAC5C;;;;;;;;;;;;;;OAcG;IACH,WAAW,CAAC,EAAE,SAAS,CAAA;IACvB;;;;;OAKG;IACH,aAAa,CAAC,EAAE,OAAO,CAAA;CACxB;AAED;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,EACxB,IAAI,EACJ,OAAO,EACP,WAAsB,EACtB,WAAW,EACX,YAAY,EACZ,eAAe,EACf,WAAW,EACX,aAAoB,GACrB,EAAE,cAAc,GAAG,GAAG,CAAC,OAAO,CAoQ9B;yBA7Qe,SAAS"}
package/dist/AuthModal.js CHANGED
@@ -66,7 +66,7 @@ function useTouchFirstViewport() {
66
66
  * @param props - {@link AuthModalProps}.
67
67
  * @returns The modal element (renders nothing when closed).
68
68
  */
69
- export function AuthModal({ open, onClose, initialMode = 'signup', oauthConfig, onBeforeAuth, onAuthenticated, }) {
69
+ export function AuthModal({ open, onClose, initialMode = 'signup', oauthConfig, onBeforeAuth, onAuthenticated, captchaSlot, captchaSolved = true, }) {
70
70
  const cm = getClassMap();
71
71
  const isTouchFirst = useTouchFirstViewport();
72
72
  const [mode, setMode] = useState(initialMode);
@@ -180,7 +180,7 @@ export function AuthModal({ open, onClose, initialMode = 'signup', oauthConfig,
180
180
  defaultValue: 'Name (optional)',
181
181
  }), style: fieldStyle })), _jsx("input", { type: "email", value: email, onChange: (e) => setField('email', e.target.value), autoComplete: "email", autoFocus: true, required: true, "data-mol-id": "auth-modal-email", placeholder: t('auth.login.email', undefined, { defaultValue: 'Email' }), style: fieldStyle }), _jsx("input", { type: "password", value: password, onChange: (e) => setPassword(e.target.value), autoComplete: isSignup ? 'new-password' : 'current-password', required: true, "data-mol-id": "auth-modal-password", placeholder: t('auth.login.password', undefined, { defaultValue: 'Password' }), style: fieldStyle }), !isSignup && (_jsx("input", { type: "text", inputMode: "numeric", value: twoFactorToken, onChange: (e) => setTwoFactorToken(e.target.value), autoComplete: "one-time-code", "data-mol-id": "auth-modal-2fa", placeholder: t('auth.login.twoFactor', undefined, {
182
182
  defaultValue: '2FA code (if enabled)',
183
- }), style: fieldStyle })), _jsx(Button, { type: "submit", size: "lg", color: "success", disabled: busy, "data-mol-id": "auth-modal-submit", style: { width: '100%', marginTop: 2 }, children: busy
183
+ }), style: fieldStyle })), isSignup && captchaSlot && (_jsx("div", { "data-mol-id": "auth-modal-captcha", style: { display: 'grid', marginTop: 2 }, children: captchaSlot })), _jsx(Button, { type: "submit", size: "lg", color: "success", disabled: busy || (isSignup && !captchaSolved), "data-mol-id": "auth-modal-submit", style: { width: '100%', marginTop: 2 }, children: busy
184
184
  ? t('auth.modal.working', undefined, { defaultValue: 'Just a moment…' })
185
185
  : isSignup
186
186
  ? t('auth.login.signUp', undefined, { defaultValue: 'Sign up' })
@@ -43,6 +43,18 @@ export interface AuthModalMountProps {
43
43
  * the default new-tab flow (+ focus-return refresh) applies.
44
44
  */
45
45
  onUpgradeIntercept?: (path: string) => void;
46
+ /**
47
+ * Human-verification challenge rendered inside the modal's SIGNUP form — see
48
+ * {@link AuthModalProps.captchaSlot}. Pass it together with
49
+ * {@link AuthModalMountProps.captchaSolved} whenever the app's signup API
50
+ * requires a challenge token, otherwise the in-app signup POSTs without one
51
+ * while the standalone `/signup` page (which renders its own widget) works —
52
+ * a mismatch the user experiences as "complete the challenge" with no
53
+ * challenge on screen. Optional.
54
+ */
55
+ captchaSlot?: AuthModalProps['captchaSlot'];
56
+ /** Whether {@link AuthModalMountProps.captchaSlot} is solved; `false` disables the signup submit. Defaults to `true`. */
57
+ captchaSolved?: AuthModalProps['captchaSolved'];
46
58
  /** Override the auth path→mode map (defaults to `/login`,`/signup`). */
47
59
  authPaths?: Readonly<Record<string, AuthModalMode>>;
48
60
  /** Override the upgrade paths opened in a new tab (defaults to `/pricing`,`/billing`). */
@@ -54,7 +66,7 @@ export interface AuthModalMountProps {
54
66
  * @param props - {@link AuthModalMountProps}.
55
67
  * @returns The (lazily-mounted) auth modal element.
56
68
  */
57
- export declare function AuthModalMount({ oauthConfig, onBeforeAuth, onAuthenticated, onUpgradeReturn, onUpgradeIntercept, authPaths, upgradePaths, }: AuthModalMountProps): JSX.Element;
69
+ export declare function AuthModalMount({ oauthConfig, onBeforeAuth, onAuthenticated, onUpgradeReturn, onUpgradeIntercept, captchaSlot, captchaSolved, authPaths, upgradePaths, }: AuthModalMountProps): JSX.Element;
58
70
  export declare namespace AuthModalMount {
59
71
  var displayName: string;
60
72
  }
@@ -1 +1 @@
1
- {"version":3,"file":"AuthModalMount.d.ts","sourceRoot":"","sources":["../src/AuthModalMount.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EAAE,KAAK,GAAG,EAA4C,MAAM,OAAO,CAAA;AAI1E,OAAO,EAAa,KAAK,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAC/D,OAAO,EACL,KAAK,aAAa,EAKnB,MAAM,oBAAoB,CAAA;AAE3B,wCAAwC;AACxC,MAAM,WAAW,mBAAmB;IAClC,gFAAgF;IAChF,WAAW,EAAE,cAAc,CAAC,aAAa,CAAC,CAAA;IAC1C,wEAAwE;IACxE,YAAY,CAAC,EAAE,MAAM,IAAI,CAAA;IACzB,0EAA0E;IAC1E,eAAe,CAAC,EAAE,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAC5C;;;;;OAKG;IACH,eAAe,CAAC,EAAE,MAAM,IAAI,CAAA;IAC5B;;;;;;OAMG;IACH,kBAAkB,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAA;IAC3C,wEAAwE;IACxE,SAAS,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC,CAA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AAE,SAAS,MAAM,EAAE,CAAA;CACjC;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,EAC7B,WAAW,EACX,YAAY,EACZ,eAAe,EACf,eAAe,EACf,kBAAkB,EAClB,WAAW,EACX,aAAa,EACb,SAA8B,EAC9B,YAAoC,GACrC,EAAE,mBAAmB,GAAG,GAAG,CAAC,OAAO,CAgFnC;yBA1Fe,cAAc"}
@@ -28,7 +28,7 @@ import { authModeForHref, DEFAULT_AUTH_PATHS, DEFAULT_UPGRADE_PATHS, upgradePath
28
28
  * @param props - {@link AuthModalMountProps}.
29
29
  * @returns The (lazily-mounted) auth modal element.
30
30
  */
31
- export function AuthModalMount({ oauthConfig, onBeforeAuth, onAuthenticated, onUpgradeReturn, onUpgradeIntercept, authPaths = DEFAULT_AUTH_PATHS, upgradePaths = DEFAULT_UPGRADE_PATHS, }) {
31
+ export function AuthModalMount({ oauthConfig, onBeforeAuth, onAuthenticated, onUpgradeReturn, onUpgradeIntercept, captchaSlot, captchaSolved, authPaths = DEFAULT_AUTH_PATHS, upgradePaths = DEFAULT_UPGRADE_PATHS, }) {
32
32
  const { refresh } = useAuth();
33
33
  const [open, setOpen] = useState(false);
34
34
  const [mode, setMode] = useState('signup');
@@ -91,6 +91,6 @@ export function AuthModalMount({ oauthConfig, onBeforeAuth, onAuthenticated, onU
91
91
  return () => document.removeEventListener('click', onClick, true);
92
92
  }, [openAuth, authPaths, upgradePaths, onUpgradeIntercept]);
93
93
  // Mounted only while open so the auth hooks don't run on every app render.
94
- return open ? (_jsx(AuthModal, { open: open, onClose: () => setOpen(false), initialMode: mode, oauthConfig: oauthConfig, onBeforeAuth: onBeforeAuth, onAuthenticated: onAuthenticated })) : (_jsx(_Fragment, {}));
94
+ return open ? (_jsx(AuthModal, { open: open, onClose: () => setOpen(false), initialMode: mode, oauthConfig: oauthConfig, onBeforeAuth: onBeforeAuth, onAuthenticated: onAuthenticated, captchaSlot: captchaSlot, captchaSolved: captchaSolved })) : (_jsx(_Fragment, {}));
95
95
  }
96
96
  AuthModalMount.displayName = 'AuthModalMount';
package/dist/index.d.ts CHANGED
@@ -38,6 +38,15 @@
38
38
  * `@molecule/app-locales-common` bond (79 languages), alongside the
39
39
  * `auth.login.*` / `auth.signup.*` keys the modal also renders.
40
40
  *
41
+ * If the signup API requires a human-verification challenge (Turnstile /
42
+ * hCaptcha), pass BOTH `captchaSlot` (the widget, rendered in the signup
43
+ * form) and `captchaSolved` (which gates the submit). Rendering the widget
44
+ * on the standalone `/signup` page alone is NOT enough: this modal is what
45
+ * a `/signup` link actually opens, so the in-app signup would POST with no
46
+ * token and the API would answer "complete the verification challenge"
47
+ * while no challenge is on screen. Login is not gated, so the slot is
48
+ * unmounted in login mode.
49
+ *
41
50
  * @module
42
51
  */
43
52
  export * from './AuthModal.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AAEH,cAAc,gBAAgB,CAAA;AAC9B,cAAc,qBAAqB,CAAA;AACnC,cAAc,oBAAoB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkDG;AAEH,cAAc,gBAAgB,CAAA;AAC9B,cAAc,qBAAqB,CAAA;AACnC,cAAc,oBAAoB,CAAA"}
package/dist/index.js CHANGED
@@ -38,6 +38,15 @@
38
38
  * `@molecule/app-locales-common` bond (79 languages), alongside the
39
39
  * `auth.login.*` / `auth.signup.*` keys the modal also renders.
40
40
  *
41
+ * If the signup API requires a human-verification challenge (Turnstile /
42
+ * hCaptcha), pass BOTH `captchaSlot` (the widget, rendered in the signup
43
+ * form) and `captchaSolved` (which gates the submit). Rendering the widget
44
+ * on the standalone `/signup` page alone is NOT enough: this modal is what
45
+ * a `/signup` link actually opens, so the in-app signup would POST with no
46
+ * token and the API would answer "complete the verification challenge"
47
+ * while no challenge is on screen. Login is not gated, so the slot is
48
+ * unmounted in login mode.
49
+ *
41
50
  * @module
42
51
  */
43
52
  export * from './AuthModal.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@molecule/app-auth-modal-react",
3
- "version": "1.0.0",
3
+ "version": "1.1.0",
4
4
  "description": "In-app login / signup modal + click-interceptor + popup OAuth — authenticate and upgrade without ever navigating away or losing work",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -17,7 +17,8 @@
17
17
  }
18
18
  },
19
19
  "files": [
20
- "dist"
20
+ "dist",
21
+ "README.md"
21
22
  ],
22
23
  "keywords": [
23
24
  "molecule",
@@ -29,22 +30,27 @@
29
30
  "react"
30
31
  ],
31
32
  "license": "Apache-2.0",
33
+ "repository": {
34
+ "type": "git",
35
+ "url": "https://github.com/molecule-dev/molecule.git",
36
+ "directory": "packages/app/features/auth-modal-react"
37
+ },
32
38
  "peerDependencies": {
33
- "@molecule/app-auth-shell-react": "^1.0.0",
34
- "@molecule/app-i18n": "^1.0.0",
35
- "@molecule/app-oauth-buttons-react": "^1.0.0",
36
- "@molecule/app-react": "^1.0.0",
37
- "@molecule/app-ui": "^1.0.0",
38
- "@molecule/app-ui-react": "^1.0.0",
39
+ "@molecule/app-auth-shell-react": "^1.0.1",
40
+ "@molecule/app-i18n": "^1.0.1",
41
+ "@molecule/app-oauth-buttons-react": "^1.0.1",
42
+ "@molecule/app-react": "^1.0.1",
43
+ "@molecule/app-ui": "^1.0.1",
44
+ "@molecule/app-ui-react": "^1.0.1",
39
45
  "react": "^18.0.0 || ^19.0.0"
40
46
  },
41
47
  "devDependencies": {
42
- "@molecule/app-auth-shell-react": "1.0.0",
43
- "@molecule/app-i18n": "1.0.0",
44
- "@molecule/app-oauth-buttons-react": "1.0.0",
45
- "@molecule/app-react": "1.0.0",
46
- "@molecule/app-ui": "1.0.0",
47
- "@molecule/app-ui-react": "1.0.0",
48
+ "@molecule/app-auth-shell-react": "1.0.1",
49
+ "@molecule/app-i18n": "1.0.1",
50
+ "@molecule/app-oauth-buttons-react": "1.0.1",
51
+ "@molecule/app-react": "1.1.0",
52
+ "@molecule/app-ui": "1.1.0",
53
+ "@molecule/app-ui-react": "1.0.1",
48
54
  "@testing-library/react": "16.3.2",
49
55
  "@types/node": "26.1.2",
50
56
  "@types/react": "19.2.17",