@molecule/app-auth-modal-react 1.0.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/LICENSE ADDED
@@ -0,0 +1,115 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work.
38
+
39
+ "Derivative Works" shall mean any work, whether in Source or Object
40
+ form, that is based on (or derived from) the Work and for which the
41
+ editorial revisions, annotations, elaborations, or other modifications
42
+ represent, as a whole, an original work of authorship.
43
+
44
+ "Contribution" shall mean any work of authorship, including the
45
+ original version of the Work and any modifications or additions
46
+ to that Work, that is intentionally submitted to the Licensor for
47
+ inclusion in the Work by the copyright owner or by an individual or
48
+ Legal Entity authorized to submit on behalf of the copyright owner.
49
+
50
+ "Contributor" shall mean Licensor and any individual or Legal Entity
51
+ on behalf of whom a Contribution has been received by the Licensor and
52
+ subsequently incorporated within the Work.
53
+
54
+ 2. Grant of Copyright License. Subject to the terms and conditions of
55
+ this License, each Contributor hereby grants to You a perpetual,
56
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
57
+ copyright license to reproduce, prepare Derivative Works of,
58
+ publicly display, publicly perform, sublicense, and distribute the
59
+ Work and such Derivative Works in Source or Object form.
60
+
61
+ 3. Grant of Patent License. Subject to the terms and conditions of
62
+ this License, each Contributor hereby grants to You a perpetual,
63
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
64
+ patent license to make, have made, use, offer to sell, sell, import,
65
+ and otherwise transfer the Work.
66
+
67
+ 4. Redistribution. You may reproduce and distribute copies of the
68
+ Work or Derivative Works thereof in any medium, with or without
69
+ modifications, and in Source or Object form, provided that You
70
+ meet the following conditions:
71
+
72
+ (a) You must give any other recipients of the Work or
73
+ Derivative Works a copy of this License; and
74
+
75
+ (b) You must cause any modified files to carry prominent notices
76
+ stating that You changed the files; and
77
+
78
+ (c) You must retain, in the Source form of any Derivative Works
79
+ that You distribute, all copyright, patent, trademark, and
80
+ attribution notices from the Source form of the Work,
81
+ excluding those notices that do not pertain to any part of
82
+ the Derivative Works; and
83
+
84
+ (d) If the Work includes a "NOTICE" text file as part of its
85
+ distribution, then any Derivative Works that You distribute must
86
+ include a readable copy of the attribution notices contained
87
+ within such NOTICE file.
88
+
89
+ 5. Submission of Contributions.
90
+
91
+ 6. Trademarks. This License does not grant permission to use the trade
92
+ names, trademarks, service marks, or product names of the Licensor.
93
+
94
+ 7. Disclaimer of Warranty. Unless required by applicable law or
95
+ agreed to in writing, Licensor provides the Work on an "AS IS" BASIS,
96
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND.
97
+
98
+ 8. Limitation of Liability. In no event and under no legal theory shall
99
+ any Contributor be liable to You for damages.
100
+
101
+ 9. Accepting Warranty or Additional Liability.
102
+
103
+ Copyright 2026 Molecule Dev, Inc.
104
+
105
+ Licensed under the Apache License, Version 2.0 (the "License");
106
+ you may not use this file except in compliance with the License.
107
+ You may obtain a copy of the License at
108
+
109
+ http://www.apache.org/licenses/LICENSE-2.0
110
+
111
+ Unless required by applicable law or agreed to in writing, software
112
+ distributed under the License is distributed on an "AS IS" BASIS,
113
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
114
+ See the License for the specific language governing permissions and
115
+ limitations under the License.
@@ -0,0 +1,56 @@
1
+ /**
2
+ * In-app login / signup modal — authenticate WITHOUT leaving the page.
3
+ *
4
+ * Reuses the framework auth hooks (`useLogin` / `useSignup` / `useOAuth` /
5
+ * `useAuth`) so behavior matches the standalone `/login` and `/signup` pages, but
6
+ * on success it stays in place: it refreshes the session (so guards + plan are
7
+ * current), runs an optional app `onAuthenticated` hook (e.g. claim guest work,
8
+ * invalidate usage), and closes — no navigation, no reload. OAuth runs in a POPUP
9
+ * (`loginViaPopup`) so social login never navigates the host either.
10
+ *
11
+ * Every app-specific concern is injected: the OAuth `oauthConfig`, an optional
12
+ * `onBeforeAuth` (run before any login attempt — e.g. stash the guest id) and
13
+ * `onAuthenticated` (run after success). With none of those it still works as a
14
+ * plain email/password + OAuth login that refreshes and closes — the default for
15
+ * the 133 flagship apps.
16
+ *
17
+ * @module
18
+ */
19
+ import { type JSX } from 'react';
20
+ import { useOAuth } from '@molecule/app-react';
21
+ import type { AuthModalMode } from './cta-intercept.js';
22
+ /** Props for {@link AuthModal}. */
23
+ export interface AuthModalProps {
24
+ /** Whether the modal is open. */
25
+ open: boolean;
26
+ /** Close without authenticating (backdrop / Escape / ✕). */
27
+ onClose: () => void;
28
+ /** Which form to open on. Defaults to `'signup'`. */
29
+ initialMode?: AuthModalMode;
30
+ /**
31
+ * OAuth config consumed by `useOAuth()` — `{ baseURL, oauthProviders, oauthEndpoint }`
32
+ * from the app's `config.ts`. Drives the popup OAuth buttons.
33
+ */
34
+ oauthConfig: Parameters<typeof useOAuth>[0];
35
+ /**
36
+ * Run synchronously BEFORE any login/signup/OAuth attempt — e.g. stash the guest
37
+ * id so the new session can claim its work. Optional.
38
+ */
39
+ onBeforeAuth?: () => void;
40
+ /**
41
+ * Run AFTER a successful login/signup/OAuth (the session is already refreshed),
42
+ * still on the same page — e.g. claim guest projects, invalidate usage. Optional.
43
+ */
44
+ onAuthenticated?: () => void | Promise<void>;
45
+ }
46
+ /**
47
+ * 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.
48
+ *
49
+ * @param props - {@link AuthModalProps}.
50
+ * @returns The modal element (renders nothing when closed).
51
+ */
52
+ export declare function AuthModal({ open, onClose, initialMode, oauthConfig, onBeforeAuth, onAuthenticated, }: AuthModalProps): JSX.Element;
53
+ export declare namespace AuthModal {
54
+ var displayName: string;
55
+ }
56
+ //# sourceMappingURL=AuthModal.d.ts.map
@@ -0,0 +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,CAAA;AAMrD,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAA;AAI9C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AA0CvD,mCAAmC;AACnC,MAAM,WAAW,cAAc;IAC7B,iCAAiC;IACjC,IAAI,EAAE,OAAO,CAAA;IACb,4DAA4D;IAC5D,OAAO,EAAE,MAAM,IAAI,CAAA;IACnB,qDAAqD;IACrD,WAAW,CAAC,EAAE,aAAa,CAAA;IAC3B;;;OAGG;IACH,WAAW,EAAE,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;CAC7C;AAED;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,EACxB,IAAI,EACJ,OAAO,EACP,WAAsB,EACtB,WAAW,EACX,YAAY,EACZ,eAAe,GAChB,EAAE,cAAc,GAAG,GAAG,CAAC,OAAO,CA8P9B;yBArQe,SAAS"}
@@ -0,0 +1,199 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ /**
3
+ * In-app login / signup modal — authenticate WITHOUT leaving the page.
4
+ *
5
+ * Reuses the framework auth hooks (`useLogin` / `useSignup` / `useOAuth` /
6
+ * `useAuth`) so behavior matches the standalone `/login` and `/signup` pages, but
7
+ * on success it stays in place: it refreshes the session (so guards + plan are
8
+ * current), runs an optional app `onAuthenticated` hook (e.g. claim guest work,
9
+ * invalidate usage), and closes — no navigation, no reload. OAuth runs in a POPUP
10
+ * (`loginViaPopup`) so social login never navigates the host either.
11
+ *
12
+ * Every app-specific concern is injected: the OAuth `oauthConfig`, an optional
13
+ * `onBeforeAuth` (run before any login attempt — e.g. stash the guest id) and
14
+ * `onAuthenticated` (run after success). With none of those it still works as a
15
+ * plain email/password + OAuth login that refreshes and closes — the default for
16
+ * the 133 flagship apps.
17
+ *
18
+ * @module
19
+ */
20
+ import { useEffect, useState } from 'react';
21
+ import { useAuthFormState } from '@molecule/app-auth-shell-react';
22
+ import { t } from '@molecule/app-i18n';
23
+ import { OAuthButtons, OAuthDivider } from '@molecule/app-oauth-buttons-react';
24
+ import { useAuth, useAuthClient, useI18nError, useLogin, useSignup } from '@molecule/app-react';
25
+ import { useOAuth } from '@molecule/app-react';
26
+ import { getClassMap } from '@molecule/app-ui';
27
+ import { Button, Icon, Modal } from '@molecule/app-ui-react';
28
+ /**
29
+ * Matches phones (narrow viewport) OR touch-first devices (coarse primary
30
+ * pointer) — the contexts where a sub-16px input font makes iOS Safari zoom
31
+ * the whole page on focus.
32
+ */
33
+ const TOUCH_FIRST_QUERY = '(max-width: 767px), (pointer: coarse)';
34
+ /**
35
+ * How long the "Signed up!" / "Logged in!" confirmation stays visible before
36
+ * the modal closes. Long enough to register, short enough not to feel like a
37
+ * wait — and the app's `onAuthenticated` work (claiming guest projects etc.)
38
+ * runs concurrently, so the real delay is `max(this, onAuthenticated)`.
39
+ */
40
+ const SUCCESS_DISPLAY_MS = 1000;
41
+ /**
42
+ * Whether {@link TOUCH_FIRST_QUERY} currently matches. SSR-safe (reports
43
+ * `false` until mounted in a browser) and subscribes to media-query changes
44
+ * (rotation, window resize across the breakpoint). Local to this package — it
45
+ * must not import IDE feature packages for a two-line media-query hook.
46
+ * @returns True on phone-width or touch-first devices.
47
+ */
48
+ function useTouchFirstViewport() {
49
+ const [matches, setMatches] = useState(() => typeof window !== 'undefined' &&
50
+ typeof window.matchMedia === 'function' &&
51
+ window.matchMedia(TOUCH_FIRST_QUERY).matches);
52
+ useEffect(() => {
53
+ if (typeof window === 'undefined' || typeof window.matchMedia !== 'function')
54
+ return;
55
+ const mql = window.matchMedia(TOUCH_FIRST_QUERY);
56
+ const onChange = (e) => setMatches(e.matches);
57
+ setMatches(mql.matches);
58
+ mql.addEventListener('change', onChange);
59
+ return () => mql.removeEventListener('change', onChange);
60
+ }, []);
61
+ return matches;
62
+ }
63
+ /**
64
+ * 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.
65
+ *
66
+ * @param props - {@link AuthModalProps}.
67
+ * @returns The modal element (renders nothing when closed).
68
+ */
69
+ export function AuthModal({ open, onClose, initialMode = 'signup', oauthConfig, onBeforeAuth, onAuthenticated, }) {
70
+ const cm = getClassMap();
71
+ const isTouchFirst = useTouchFirstViewport();
72
+ const [mode, setMode] = useState(initialMode);
73
+ const { refresh } = useAuth();
74
+ const authClient = useAuthClient();
75
+ const { status: loginStatus, error: loginError, login } = useLogin();
76
+ const { status: signupStatus, error: signupError, signup } = useSignup();
77
+ const { fields, setField, clear } = useAuthFormState();
78
+ const email = fields.email ?? '';
79
+ const [password, setPassword] = useState('');
80
+ const [name, setName] = useState('');
81
+ const [twoFactorToken, setTwoFactorToken] = useState('');
82
+ const [oauthError, setOauthError] = useState(null);
83
+ // Post-auth confirmation ("Signed up!" / "Logged in!") shown briefly before
84
+ // the modal closes — without it the modal just vanished, which read as
85
+ // "nothing happened".
86
+ const [succeeded, setSucceeded] = useState(false);
87
+ const isSignup = mode === 'signup';
88
+ const busy = isSignup ? signupStatus === 'pending' : loginStatus === 'pending';
89
+ const errorMessage = useI18nError(isSignup ? signupError : loginError);
90
+ // Universal post-auth: refresh the session (guards + plan current), show a
91
+ // brief confirmation, run the app's hook, then close — all in place, no
92
+ // navigation.
93
+ const finishAuth = async () => {
94
+ try {
95
+ await refresh();
96
+ }
97
+ catch (error) {
98
+ // Every path into finishAuth (password login/signup response, OAuth popup
99
+ // relay) has already established the session client-side, so the refresh
100
+ // is a freshness pass — a failure here (e.g. an API with neither a
101
+ // refresh endpoint nor cookie restore) must NOT strand an authenticated
102
+ // user in the modal with their account already created. Only a genuinely
103
+ // absent session is a real failure.
104
+ if (!authClient.isAuthenticated())
105
+ throw error;
106
+ }
107
+ setSucceeded(true);
108
+ // Hold the confirmation on screen while the app hook runs; whichever
109
+ // finishes last gates the close.
110
+ const minDisplay = new Promise((resolve) => setTimeout(resolve, SUCCESS_DISPLAY_MS));
111
+ await onAuthenticated?.();
112
+ await minDisplay;
113
+ onClose();
114
+ };
115
+ // OAuth (popup): success/error land back on THIS page; wire them into the hook.
116
+ const { providers, loginViaPopup } = useOAuth({
117
+ ...oauthConfig,
118
+ onSuccess: () => {
119
+ // Surface a finishAuth failure (no session established) in the modal
120
+ // instead of dying as an unhandled rejection.
121
+ finishAuth().catch((error) => {
122
+ setOauthError(error instanceof Error ? error.message : String(error));
123
+ });
124
+ },
125
+ onError: (message) => setOauthError(message),
126
+ });
127
+ const handleSubmit = async (e) => {
128
+ e.preventDefault();
129
+ onBeforeAuth?.();
130
+ try {
131
+ if (isSignup)
132
+ await signup({ email, password, name: name || undefined });
133
+ else
134
+ await login({ email, password });
135
+ clear();
136
+ await finishAuth();
137
+ }
138
+ catch (_error) {
139
+ // Auth errors are captured in the hook's error state and shown below; we
140
+ // deliberately do NOT navigate or reload on failure or success.
141
+ }
142
+ };
143
+ const fieldStyle = {
144
+ width: '100%',
145
+ padding: '10px 12px',
146
+ borderRadius: 6,
147
+ border: '1px solid var(--mol-color-border, rgba(127,127,127,0.3))',
148
+ background: 'var(--mol-color-surface-secondary, rgba(127,127,127,0.06))',
149
+ color: 'inherit',
150
+ outline: 'none',
151
+ // ≥16px on phones/touch — below 16px iOS Safari zooms the page when an
152
+ // input gains focus, which wrecks the modal on the primary conversion flow.
153
+ // Desktop keeps the compact 14px.
154
+ fontSize: isTouchFirst ? 16 : 14,
155
+ };
156
+ return (_jsx(Modal, { open: open, onClose: onClose, size: "sm", title: isSignup
157
+ ? t('auth.modal.signupTitle', undefined, { defaultValue: 'Create your account' })
158
+ : t('auth.modal.loginTitle', undefined, { defaultValue: 'Log in' }), "data-mol-id": "auth-modal", children: _jsx("div", { "data-mol-id": "auth-modal-body", style: { display: 'flex', flexDirection: 'column' }, children: succeeded ? ((() => {
159
+ // Who just authenticated — shown under the headline so the
160
+ // confirmation names the account, not just the outcome.
161
+ const profile = authClient.getUser();
162
+ const who = profile?.name || profile?.email || profile?.username || '';
163
+ return (_jsxs("div", { "data-mol-id": "auth-modal-success", style: {
164
+ display: 'flex',
165
+ flexDirection: 'column',
166
+ alignItems: 'center',
167
+ gap: 10,
168
+ padding: '26px 0 18px',
169
+ textAlign: 'center',
170
+ }, children: [_jsx(Icon, { name: "check-circle", size: 44, className: cm.textSuccess, "aria-hidden": "true" }), _jsx("div", { style: { fontSize: 17, fontWeight: 600 }, children: isSignup
171
+ ? t('auth.modal.signedUp', undefined, { defaultValue: 'Signed up!' })
172
+ : t('auth.modal.loggedIn', undefined, { defaultValue: 'Logged in!' }) }), who && (_jsx("div", { className: cm.textMuted, style: { fontSize: 13 }, children: t('auth.modal.loggedInAs', { who }, { defaultValue: `Logged in as ${who}` }) }))] }));
173
+ })()) : (_jsxs(_Fragment, { children: [_jsx("div", { className: cm.textMuted, style: { marginBottom: 12, fontSize: 13, lineHeight: 1.45 }, children: isSignup
174
+ ? t('auth.modal.signupBlurb', undefined, {
175
+ defaultValue: 'Sign up to keep your work.',
176
+ })
177
+ : t('auth.modal.loginBlurb', undefined, {
178
+ defaultValue: 'Log in to keep your work.',
179
+ }) }), _jsxs("form", { onSubmit: (e) => void handleSubmit(e), style: { display: 'grid', gap: 10 }, children: [isSignup && (_jsx("input", { type: "text", value: name, onChange: (e) => setName(e.target.value), autoComplete: "name", "data-mol-id": "auth-modal-name", placeholder: t('auth.signup.name', undefined, {
180
+ defaultValue: 'Name (optional)',
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
+ 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
184
+ ? t('auth.modal.working', undefined, { defaultValue: 'Just a moment…' })
185
+ : isSignup
186
+ ? t('auth.login.signUp', undefined, { defaultValue: 'Sign up' })
187
+ : t('auth.login.logIn', undefined, { defaultValue: 'Log in' }) }), (errorMessage || oauthError) && (_jsx("div", { className: cm.authFormError, children: errorMessage || oauthError }))] }), providers.length > 0 && (_jsxs("div", { style: { marginTop: 4 }, children: [_jsx(OAuthDivider, {}), _jsx(OAuthButtons, { providers: providers, onSelect: (provider) => {
188
+ setOauthError(null);
189
+ onBeforeAuth?.();
190
+ loginViaPopup(provider);
191
+ } })] })), _jsx("button", { type: "button", "data-mol-id": "auth-modal-switch", onClick: () => setMode(isSignup ? 'login' : 'signup'), className: cm.cn(cm.button({ variant: 'ghost', size: 'sm' })), style: { marginTop: 12, alignSelf: 'center' }, children: isSignup
192
+ ? t('auth.modal.haveAccount', undefined, {
193
+ defaultValue: 'Already have an account? Log in',
194
+ })
195
+ : t('auth.modal.needAccount', undefined, {
196
+ defaultValue: "Don't have an account? Sign up",
197
+ }) })] })) }) }));
198
+ }
199
+ AuthModal.displayName = 'AuthModal';
@@ -0,0 +1,61 @@
1
+ /**
2
+ * One-mount in-app auth + upgrade flow for any Molecule app.
3
+ *
4
+ * Mount `<AuthModalMount oauthConfig={oauthConfig} />` once inside the app's
5
+ * providers (where the auth hooks work) and every in-app `/login` / `/signup`
6
+ * link opens the {@link AuthModal} instead of navigating, while `/pricing` /
7
+ * `/billing` links open the upgrade flow WITHOUT navigating the current tab —
8
+ * so the user never loses their place or work. By default the upgrade flow
9
+ * opens in a new tab, and on returning from that tab the session is refreshed
10
+ * in place so a completed upgrade reflects without a manual reload. A host that
11
+ * prefers to keep the user fully in place (e.g. an IDE showing pricing in its
12
+ * own modal) passes `onUpgradeIntercept` to receive the click instead — it then
13
+ * owns rendering the upgrade UI and refreshing the session afterwards.
14
+ *
15
+ * Nothing here is app-specific by default; an app injects extras (claim guest
16
+ * work, invalidate usage, stash a guest id) via the optional hooks.
17
+ *
18
+ * @module
19
+ */
20
+ import { type JSX } from 'react';
21
+ import { type AuthModalProps } from './AuthModal.js';
22
+ import { type AuthModalMode } from './cta-intercept.js';
23
+ /** Props for {@link AuthModalMount}. */
24
+ export interface AuthModalMountProps {
25
+ /** OAuth config from the app's `config.ts` (drives the popup OAuth buttons). */
26
+ oauthConfig: AuthModalProps['oauthConfig'];
27
+ /** Run before any login attempt (e.g. stash the guest id). Optional. */
28
+ onBeforeAuth?: () => void;
29
+ /** Run after a successful login (session already refreshed). Optional. */
30
+ onAuthenticated?: () => void | Promise<void>;
31
+ /**
32
+ * Run when the user returns to this tab after the upgrade tab (the session is
33
+ * already refreshed here) — e.g. invalidate usage so a budget banner clears.
34
+ * Only fires for the default new-tab flow; irrelevant when
35
+ * {@link AuthModalMountProps.onUpgradeIntercept} is set. Optional.
36
+ */
37
+ onUpgradeReturn?: () => void;
38
+ /**
39
+ * Take over upgrade/billing CTA clicks instead of opening a new tab: called
40
+ * with the matched upgrade path (e.g. `/pricing`), navigation already
41
+ * prevented. The host renders its own upgrade UI (typically a modal) and owns
42
+ * refreshing the session when that flow completes. Optional — when omitted,
43
+ * the default new-tab flow (+ focus-return refresh) applies.
44
+ */
45
+ onUpgradeIntercept?: (path: string) => void;
46
+ /** Override the auth path→mode map (defaults to `/login`,`/signup`). */
47
+ authPaths?: Readonly<Record<string, AuthModalMode>>;
48
+ /** Override the upgrade paths opened in a new tab (defaults to `/pricing`,`/billing`). */
49
+ upgradePaths?: readonly string[];
50
+ }
51
+ /**
52
+ * 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.
53
+ *
54
+ * @param props - {@link AuthModalMountProps}.
55
+ * @returns The (lazily-mounted) auth modal element.
56
+ */
57
+ export declare function AuthModalMount({ oauthConfig, onBeforeAuth, onAuthenticated, onUpgradeReturn, onUpgradeIntercept, authPaths, upgradePaths, }: AuthModalMountProps): JSX.Element;
58
+ export declare namespace AuthModalMount {
59
+ var displayName: string;
60
+ }
61
+ //# sourceMappingURL=AuthModalMount.d.ts.map
@@ -0,0 +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,CAAA;IACnD,0FAA0F;IAC1F,YAAY,CAAC,EAAE,SAAS,MAAM,EAAE,CAAA;CACjC;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,EAC7B,WAAW,EACX,YAAY,EACZ,eAAe,EACf,eAAe,EACf,kBAAkB,EAClB,SAA8B,EAC9B,YAAoC,GACrC,EAAE,mBAAmB,GAAG,GAAG,CAAC,OAAO,CA8EnC;yBAtFe,cAAc"}
@@ -0,0 +1,96 @@
1
+ import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
2
+ /**
3
+ * One-mount in-app auth + upgrade flow for any Molecule app.
4
+ *
5
+ * Mount `<AuthModalMount oauthConfig={oauthConfig} />` once inside the app's
6
+ * providers (where the auth hooks work) and every in-app `/login` / `/signup`
7
+ * link opens the {@link AuthModal} instead of navigating, while `/pricing` /
8
+ * `/billing` links open the upgrade flow WITHOUT navigating the current tab —
9
+ * so the user never loses their place or work. By default the upgrade flow
10
+ * opens in a new tab, and on returning from that tab the session is refreshed
11
+ * in place so a completed upgrade reflects without a manual reload. A host that
12
+ * prefers to keep the user fully in place (e.g. an IDE showing pricing in its
13
+ * own modal) passes `onUpgradeIntercept` to receive the click instead — it then
14
+ * owns rendering the upgrade UI and refreshing the session afterwards.
15
+ *
16
+ * Nothing here is app-specific by default; an app injects extras (claim guest
17
+ * work, invalidate usage, stash a guest id) via the optional hooks.
18
+ *
19
+ * @module
20
+ */
21
+ import { useCallback, useEffect, useRef, useState } from 'react';
22
+ import { useAuth } from '@molecule/app-react';
23
+ import { AuthModal } from './AuthModal.js';
24
+ import { authModeForHref, DEFAULT_AUTH_PATHS, DEFAULT_UPGRADE_PATHS, upgradePathForHref, } from './cta-intercept.js';
25
+ /**
26
+ * 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.
27
+ *
28
+ * @param props - {@link AuthModalMountProps}.
29
+ * @returns The (lazily-mounted) auth modal element.
30
+ */
31
+ export function AuthModalMount({ oauthConfig, onBeforeAuth, onAuthenticated, onUpgradeReturn, onUpgradeIntercept, authPaths = DEFAULT_AUTH_PATHS, upgradePaths = DEFAULT_UPGRADE_PATHS, }) {
32
+ const { refresh } = useAuth();
33
+ const [open, setOpen] = useState(false);
34
+ const [mode, setMode] = useState('signup');
35
+ const openAuth = useCallback((next) => {
36
+ setMode(next);
37
+ setOpen(true);
38
+ }, []);
39
+ // Set when the user opens the upgrade/billing flow in a new tab, so we refresh
40
+ // when they return (a completed upgrade reflects with no manual reload).
41
+ const upgradeTabOpenedRef = useRef(false);
42
+ useEffect(() => {
43
+ const onFocus = () => {
44
+ if (!upgradeTabOpenedRef.current)
45
+ return;
46
+ upgradeTabOpenedRef.current = false;
47
+ refresh().catch((_error) => {
48
+ // Best-effort freshness pass: the user may have returned without a
49
+ // session to refresh (never logged in, or the API has no refresh
50
+ // path) — not an error worth surfacing on a simple tab focus.
51
+ });
52
+ onUpgradeReturn?.();
53
+ };
54
+ window.addEventListener('focus', onFocus);
55
+ return () => window.removeEventListener('focus', onFocus);
56
+ }, [refresh, onUpgradeReturn]);
57
+ // Intercept clicks on the in-app /login, /signup (→ modal) and /pricing, /billing
58
+ // (→ host's onUpgradeIntercept, else a new tab) CTAs — plain <a href> links from
59
+ // anywhere in the app, incl. ones opened with target="_blank". Capture-phase +
60
+ // preventDefault stops navigation. Plain left-clicks only — a modifier/middle
61
+ // click still opens the real page.
62
+ useEffect(() => {
63
+ const onClick = (e) => {
64
+ if (e.defaultPrevented || e.button !== 0 || e.metaKey || e.ctrlKey || e.shiftKey || e.altKey)
65
+ return;
66
+ const anchor = e.target?.closest('a[href]');
67
+ if (!anchor)
68
+ return;
69
+ const href = anchor.getAttribute('href');
70
+ const origin = window.location.origin;
71
+ const authMode = authModeForHref(href, origin, authPaths);
72
+ if (authMode) {
73
+ e.preventDefault();
74
+ e.stopPropagation();
75
+ openAuth(authMode);
76
+ return;
77
+ }
78
+ const upgradePath = upgradePathForHref(href, origin, upgradePaths);
79
+ if (upgradePath) {
80
+ e.preventDefault();
81
+ e.stopPropagation();
82
+ if (onUpgradeIntercept) {
83
+ onUpgradeIntercept(upgradePath);
84
+ return;
85
+ }
86
+ upgradeTabOpenedRef.current = true;
87
+ window.open(upgradePath, '_blank', 'noopener,noreferrer');
88
+ }
89
+ };
90
+ document.addEventListener('click', onClick, true);
91
+ return () => document.removeEventListener('click', onClick, true);
92
+ }, [openAuth, authPaths, upgradePaths, onUpgradeIntercept]);
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, {}));
95
+ }
96
+ AuthModalMount.displayName = 'AuthModalMount';
@@ -0,0 +1,39 @@
1
+ /**
2
+ * Pure routing decisions for the in-app auth/upgrade click-interceptor.
3
+ *
4
+ * A click on an in-app `/login` or `/signup` link opens the {@link AuthModal}
5
+ * instead of navigating; a click on `/pricing` or `/billing` opens the upgrade
6
+ * flow without navigating the current tab — the host's `onUpgradeIntercept`
7
+ * (e.g. an in-app modal) when provided, else a new tab. These helpers turn a
8
+ * clicked link's href into that decision so the interceptor stays trivial and
9
+ * unit-testable.
10
+ *
11
+ * @module
12
+ */
13
+ /** Which form {@link AuthModal} should show. */
14
+ export type AuthModalMode = 'login' | 'signup';
15
+ /** The default in-app auth routes that open the modal. */
16
+ export declare const DEFAULT_AUTH_PATHS: Readonly<Record<string, AuthModalMode>>;
17
+ /** The default routes that open the upgrade/billing flow (modal or new tab). */
18
+ export declare const DEFAULT_UPGRADE_PATHS: readonly string[];
19
+ /**
20
+ * Map a CTA link's href to the auth mode it should open, or `null` if it is not
21
+ * an auth link (so the interceptor leaves it alone).
22
+ *
23
+ * @param href - The clicked anchor's href (relative or absolute).
24
+ * @param origin - The page origin to resolve a relative href against.
25
+ * @param authPaths - Path→mode map (defaults to {@link DEFAULT_AUTH_PATHS}).
26
+ * @returns `'login'` / `'signup'`, else `null`.
27
+ */
28
+ export declare function authModeForHref(href: string | null | undefined, origin: string, authPaths?: Readonly<Record<string, AuthModalMode>>): AuthModalMode | null;
29
+ /**
30
+ * Whether a CTA link's href points at the upgrade/billing flow (which the
31
+ * interceptor hands to the host's `onUpgradeIntercept`, else opens in a new tab).
32
+ *
33
+ * @param href - The clicked anchor's href (relative or absolute).
34
+ * @param origin - The page origin to resolve a relative href against.
35
+ * @param upgradePaths - The upgrade paths (defaults to {@link DEFAULT_UPGRADE_PATHS}).
36
+ * @returns The matched pathname, else `null`.
37
+ */
38
+ export declare function upgradePathForHref(href: string | null | undefined, origin: string, upgradePaths?: readonly string[]): string | null;
39
+ //# sourceMappingURL=cta-intercept.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cta-intercept.d.ts","sourceRoot":"","sources":["../src/cta-intercept.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,gDAAgD;AAChD,MAAM,MAAM,aAAa,GAAG,OAAO,GAAG,QAAQ,CAAA;AAE9C,0DAA0D;AAC1D,eAAO,MAAM,kBAAkB,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAGtE,CAAA;AAED,gFAAgF;AAChF,eAAO,MAAM,qBAAqB,EAAE,SAAS,MAAM,EAA6B,CAAA;AAahF;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAC7B,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EAC/B,MAAM,EAAE,MAAM,EACd,SAAS,GAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAAsB,GACtE,aAAa,GAAG,IAAI,CAGtB;AAED;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EAC/B,MAAM,EAAE,MAAM,EACd,YAAY,GAAE,SAAS,MAAM,EAA0B,GACtD,MAAM,GAAG,IAAI,CAGf"}
@@ -0,0 +1,57 @@
1
+ /**
2
+ * Pure routing decisions for the in-app auth/upgrade click-interceptor.
3
+ *
4
+ * A click on an in-app `/login` or `/signup` link opens the {@link AuthModal}
5
+ * instead of navigating; a click on `/pricing` or `/billing` opens the upgrade
6
+ * flow without navigating the current tab — the host's `onUpgradeIntercept`
7
+ * (e.g. an in-app modal) when provided, else a new tab. These helpers turn a
8
+ * clicked link's href into that decision so the interceptor stays trivial and
9
+ * unit-testable.
10
+ *
11
+ * @module
12
+ */
13
+ /** The default in-app auth routes that open the modal. */
14
+ export const DEFAULT_AUTH_PATHS = {
15
+ '/login': 'login',
16
+ '/signup': 'signup',
17
+ };
18
+ /** The default routes that open the upgrade/billing flow (modal or new tab). */
19
+ export const DEFAULT_UPGRADE_PATHS = ['/pricing', '/billing'];
20
+ /** Resolve an href to its pathname against `origin`, or `null` if malformed. */
21
+ function pathOf(href, origin) {
22
+ if (!href)
23
+ return null;
24
+ try {
25
+ return new URL(href, origin).pathname;
26
+ }
27
+ catch (_error) {
28
+ // A malformed href is not an in-app CTA — leave it alone (intentional noop).
29
+ return null;
30
+ }
31
+ }
32
+ /**
33
+ * Map a CTA link's href to the auth mode it should open, or `null` if it is not
34
+ * an auth link (so the interceptor leaves it alone).
35
+ *
36
+ * @param href - The clicked anchor's href (relative or absolute).
37
+ * @param origin - The page origin to resolve a relative href against.
38
+ * @param authPaths - Path→mode map (defaults to {@link DEFAULT_AUTH_PATHS}).
39
+ * @returns `'login'` / `'signup'`, else `null`.
40
+ */
41
+ export function authModeForHref(href, origin, authPaths = DEFAULT_AUTH_PATHS) {
42
+ const path = pathOf(href, origin);
43
+ return path != null ? (authPaths[path] ?? null) : null;
44
+ }
45
+ /**
46
+ * Whether a CTA link's href points at the upgrade/billing flow (which the
47
+ * interceptor hands to the host's `onUpgradeIntercept`, else opens in a new tab).
48
+ *
49
+ * @param href - The clicked anchor's href (relative or absolute).
50
+ * @param origin - The page origin to resolve a relative href against.
51
+ * @param upgradePaths - The upgrade paths (defaults to {@link DEFAULT_UPGRADE_PATHS}).
52
+ * @returns The matched pathname, else `null`.
53
+ */
54
+ export function upgradePathForHref(href, origin, upgradePaths = DEFAULT_UPGRADE_PATHS) {
55
+ const path = pathOf(href, origin);
56
+ return path != null && upgradePaths.includes(path) ? path : null;
57
+ }
@@ -0,0 +1,46 @@
1
+ /**
2
+ * `@molecule/app-auth-modal-react` — the shared in-app login / signup /
3
+ * upgrade flow. Mount {@link AuthModalMount} ONCE inside the app's
4
+ * providers (where the `@molecule/app-react` auth hooks work) and every
5
+ * in-app `/login` / `/signup` link opens the {@link AuthModal} instead of
6
+ * navigating, while `/pricing` / `/billing` links open the upgrade flow in
7
+ * a new tab (session auto-refreshes when the user returns) — no
8
+ * navigation, no reload, no lost work. OAuth runs in a popup
9
+ * (`loginViaPopup`), so social login never navigates the host either.
10
+ *
11
+ * @example
12
+ * ```tsx
13
+ * import { AuthModalMount } from '@molecule/app-auth-modal-react'
14
+ * import { oauthConfig } from './config.js'
15
+ *
16
+ * // Once, inside the app's providers (e.g. in App.tsx):
17
+ * <AuthModalMount
18
+ * oauthConfig={oauthConfig}
19
+ * onAuthenticated={() => claimGuestWork()}
20
+ * />
21
+ * // Every plain <a href="/login">, <a href="/signup">, <a href="/pricing">
22
+ * // anywhere in the app is now intercepted — no other wiring needed.
23
+ * ```
24
+ *
25
+ * @remarks
26
+ * Interception is capture-phase on `document` and matches plain
27
+ * left-clicks on `<a href>` whose resolved pathname is in `authPaths`
28
+ * (default `/login`, `/signup`) or `upgradePaths` (default `/pricing`,
29
+ * `/billing`) — modifier/middle clicks still navigate normally, and
30
+ * non-anchor buttons that call `navigate()` are NOT intercepted. Hosts
31
+ * that render pricing in-place pass `onUpgradeIntercept` and own that UI
32
+ * + the post-upgrade session refresh. `AuthModalMount` must render inside
33
+ * the app's auth/HTTP providers (it calls `useAuth`), and the standalone
34
+ * `/login` & `/signup` pages should stay routed — they are the fallback
35
+ * for modifier clicks and deep links. App-specific extras (stash a guest
36
+ * id, claim guest work, invalidate usage) go in `onBeforeAuth` /
37
+ * `onAuthenticated`. The modal's `auth.modal.*` strings are homed in the
38
+ * `@molecule/app-locales-common` bond (79 languages), alongside the
39
+ * `auth.login.*` / `auth.signup.*` keys the modal also renders.
40
+ *
41
+ * @module
42
+ */
43
+ export * from './AuthModal.js';
44
+ export * from './AuthModalMount.js';
45
+ export * from './cta-intercept.js';
46
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +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"}
package/dist/index.js ADDED
@@ -0,0 +1,45 @@
1
+ /**
2
+ * `@molecule/app-auth-modal-react` — the shared in-app login / signup /
3
+ * upgrade flow. Mount {@link AuthModalMount} ONCE inside the app's
4
+ * providers (where the `@molecule/app-react` auth hooks work) and every
5
+ * in-app `/login` / `/signup` link opens the {@link AuthModal} instead of
6
+ * navigating, while `/pricing` / `/billing` links open the upgrade flow in
7
+ * a new tab (session auto-refreshes when the user returns) — no
8
+ * navigation, no reload, no lost work. OAuth runs in a popup
9
+ * (`loginViaPopup`), so social login never navigates the host either.
10
+ *
11
+ * @example
12
+ * ```tsx
13
+ * import { AuthModalMount } from '@molecule/app-auth-modal-react'
14
+ * import { oauthConfig } from './config.js'
15
+ *
16
+ * // Once, inside the app's providers (e.g. in App.tsx):
17
+ * <AuthModalMount
18
+ * oauthConfig={oauthConfig}
19
+ * onAuthenticated={() => claimGuestWork()}
20
+ * />
21
+ * // Every plain <a href="/login">, <a href="/signup">, <a href="/pricing">
22
+ * // anywhere in the app is now intercepted — no other wiring needed.
23
+ * ```
24
+ *
25
+ * @remarks
26
+ * Interception is capture-phase on `document` and matches plain
27
+ * left-clicks on `<a href>` whose resolved pathname is in `authPaths`
28
+ * (default `/login`, `/signup`) or `upgradePaths` (default `/pricing`,
29
+ * `/billing`) — modifier/middle clicks still navigate normally, and
30
+ * non-anchor buttons that call `navigate()` are NOT intercepted. Hosts
31
+ * that render pricing in-place pass `onUpgradeIntercept` and own that UI
32
+ * + the post-upgrade session refresh. `AuthModalMount` must render inside
33
+ * the app's auth/HTTP providers (it calls `useAuth`), and the standalone
34
+ * `/login` & `/signup` pages should stay routed — they are the fallback
35
+ * for modifier clicks and deep links. App-specific extras (stash a guest
36
+ * id, claim guest work, invalidate usage) go in `onBeforeAuth` /
37
+ * `onAuthenticated`. The modal's `auth.modal.*` strings are homed in the
38
+ * `@molecule/app-locales-common` bond (79 languages), alongside the
39
+ * `auth.login.*` / `auth.signup.*` keys the modal also renders.
40
+ *
41
+ * @module
42
+ */
43
+ export * from './AuthModal.js';
44
+ export * from './AuthModalMount.js';
45
+ export * from './cta-intercept.js';
package/package.json ADDED
@@ -0,0 +1,58 @@
1
+ {
2
+ "name": "@molecule/app-auth-modal-react",
3
+ "version": "1.0.0",
4
+ "description": "In-app login / signup modal + click-interceptor + popup OAuth — authenticate and upgrade without ever navigating away or losing work",
5
+ "type": "module",
6
+ "main": "dist/index.js",
7
+ "types": "dist/index.d.ts",
8
+ "scripts": {
9
+ "build": "tsc",
10
+ "test": "vitest run",
11
+ "test:watch": "vitest"
12
+ },
13
+ "exports": {
14
+ ".": {
15
+ "types": "./dist/index.d.ts",
16
+ "import": "./dist/index.js"
17
+ }
18
+ },
19
+ "files": [
20
+ "dist"
21
+ ],
22
+ "keywords": [
23
+ "molecule",
24
+ "auth",
25
+ "login",
26
+ "signup",
27
+ "modal",
28
+ "oauth",
29
+ "react"
30
+ ],
31
+ "license": "Apache-2.0",
32
+ "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
+ "react": "^18.0.0 || ^19.0.0"
40
+ },
41
+ "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
+ "@testing-library/react": "16.3.2",
49
+ "@types/node": "26.1.2",
50
+ "@types/react": "19.2.17",
51
+ "@types/react-dom": "19.2.3",
52
+ "jsdom": "30.0.1",
53
+ "react": "19.2.8",
54
+ "react-dom": "19.2.8",
55
+ "typescript": "6.0.3",
56
+ "vitest": "4.1.10"
57
+ }
58
+ }