@hexclave/tanstack-start 1.0.64 → 1.0.65
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/dist/{admin-app-impl-Cdh1oCee.d.ts → admin-app-impl-Cz4f8VJ9.d.ts} +7 -7
- package/dist/{admin-app-impl-Cdh1oCee.d.ts.map → admin-app-impl-Cz4f8VJ9.d.ts.map} +1 -1
- package/dist/auth-page-YnM_LtbN.d.ts.map +1 -1
- package/dist/cli-auth-confirm-BW3PYpKb.d.ts.map +1 -1
- package/dist/components/api-key-dialogs.d.ts +1 -1
- package/dist/components/api-key-dialogs.js +4 -4
- package/dist/components/credential-sign-in.js +3 -3
- package/dist/components/credential-sign-up.js +5 -5
- package/dist/components/elements/sidebar-layout.js +2 -2
- package/dist/components/elements/user-avatar.js +1 -1
- package/dist/components/magic-link-sign-in.js +5 -5
- package/dist/components/message-cards/no-auth-methods-message-card.d.ts +13 -0
- package/dist/components/message-cards/no-auth-methods-message-card.d.ts.map +1 -0
- package/dist/components/message-cards/no-auth-methods-message-card.js +75 -0
- package/dist/components/message-cards/no-auth-methods-message-card.js.map +1 -0
- package/dist/components/message-cards/predefined-message-card.js +1 -1
- package/dist/components/passkey-button.js +1 -1
- package/dist/components/profile-image-editor.js +1 -1
- package/dist/components/team-icon.js +1 -1
- package/dist/components/team-switcher.js +1 -1
- package/dist/components/user-button.js +1 -1
- package/dist/components-page/account-settings/editable-text.js +1 -1
- package/dist/components-page/account-settings/email-and-auth/emails-section.js +3 -3
- package/dist/components-page/account-settings/email-and-auth/password-section.js +3 -3
- package/dist/components-page/account-settings/teams/team-creation-page.js +3 -3
- package/dist/components-page/account-settings/teams/team-member-invitation-section.js +4 -4
- package/dist/components-page/account-settings.js +3 -3
- package/dist/components-page/auth-page.js +8 -3
- package/dist/components-page/auth-page.js.map +1 -1
- package/dist/components-page/cli-auth-confirm.js +8 -2
- package/dist/components-page/cli-auth-confirm.js.map +1 -1
- package/dist/components-page/cli-auth-confirm.test.js +42 -0
- package/dist/components-page/cli-auth-confirm.test.js.map +1 -1
- package/dist/components-page/forgot-password.js +5 -5
- package/dist/components-page/hexclave-handler-client.js +1 -1
- package/dist/components-page/mfa.js +3 -3
- package/dist/components-page/oauth-callback.js +1 -1
- package/dist/components-page/onboarding.js +4 -4
- package/dist/components-page/password-reset.js +8 -8
- package/dist/components-page/team-creation.js +5 -5
- package/dist/esm/components/api-key-dialogs.d.ts +1 -1
- package/dist/esm/components/api-key-dialogs.js +4 -4
- package/dist/esm/components/credential-sign-in.js +3 -3
- package/dist/esm/components/credential-sign-up.js +5 -5
- package/dist/esm/components/elements/sidebar-layout.js +2 -2
- package/dist/esm/components/elements/user-avatar.js +1 -1
- package/dist/esm/components/magic-link-sign-in.js +5 -5
- package/dist/esm/components/message-cards/no-auth-methods-message-card.d.ts +13 -0
- package/dist/esm/components/message-cards/no-auth-methods-message-card.d.ts.map +1 -0
- package/dist/esm/components/message-cards/no-auth-methods-message-card.js +74 -0
- package/dist/esm/components/message-cards/no-auth-methods-message-card.js.map +1 -0
- package/dist/esm/components/message-cards/predefined-message-card.js +1 -1
- package/dist/esm/components/passkey-button.js +1 -1
- package/dist/esm/components/profile-image-editor.js +1 -1
- package/dist/esm/components/team-icon.js +1 -1
- package/dist/esm/components/team-switcher.js +1 -1
- package/dist/esm/components/user-button.js +1 -1
- package/dist/esm/components-page/account-settings/editable-text.js +1 -1
- package/dist/esm/components-page/account-settings/email-and-auth/emails-section.js +3 -3
- package/dist/esm/components-page/account-settings/email-and-auth/password-section.js +3 -3
- package/dist/esm/components-page/account-settings/teams/team-creation-page.js +3 -3
- package/dist/esm/components-page/account-settings/teams/team-member-invitation-section.js +4 -4
- package/dist/esm/components-page/account-settings.js +3 -3
- package/dist/esm/components-page/auth-page.d.ts.map +1 -1
- package/dist/esm/components-page/auth-page.js +8 -3
- package/dist/esm/components-page/auth-page.js.map +1 -1
- package/dist/esm/components-page/cli-auth-confirm.d.ts.map +1 -1
- package/dist/esm/components-page/cli-auth-confirm.js +8 -2
- package/dist/esm/components-page/cli-auth-confirm.js.map +1 -1
- package/dist/esm/components-page/cli-auth-confirm.test.js +42 -0
- package/dist/esm/components-page/cli-auth-confirm.test.js.map +1 -1
- package/dist/esm/components-page/forgot-password.js +5 -5
- package/dist/esm/components-page/hexclave-handler-client.js +1 -1
- package/dist/esm/components-page/mfa.js +3 -3
- package/dist/esm/components-page/oauth-callback.js +1 -1
- package/dist/esm/components-page/onboarding.js +4 -4
- package/dist/esm/components-page/password-reset.js +7 -7
- package/dist/esm/components-page/team-creation.js +5 -5
- package/dist/esm/generated/global-css.d.ts +1 -1
- package/dist/esm/generated/global-css.js +1 -1
- package/dist/esm/generated/global-css.js.map +1 -1
- package/dist/esm/generated/quetzal-translations.d.ts +2 -2
- package/dist/esm/lib/hexclave-app/apps/implementations/admin-app-impl.d.ts +5 -5
- package/dist/esm/lib/hexclave-app/apps/implementations/client-app-impl.d.ts +3 -3
- package/dist/esm/lib/hexclave-app/apps/implementations/common.js +2 -2
- package/dist/esm/lib/hexclave-app/apps/implementations/server-app-impl.d.ts +1 -1
- package/dist/esm/lib/hexclave-app/users/index.d.ts +1 -1
- package/dist/generated/global-css.d.ts +1 -1
- package/dist/generated/global-css.js +1 -1
- package/dist/generated/global-css.js.map +1 -1
- package/dist/generated/quetzal-translations.d.ts +1 -1
- package/dist/{hexclave-provider-Dxrf-i1f.d.ts → hexclave-provider-CN52q2zh.d.ts} +2 -2
- package/dist/{hexclave-provider-Dxrf-i1f.d.ts.map → hexclave-provider-CN52q2zh.d.ts.map} +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/lib/hexclave-app/apps/implementations/admin-app-impl.d.ts +1 -1
- package/dist/lib/hexclave-app/apps/implementations/client-app-impl.d.ts +1 -1
- package/dist/lib/hexclave-app/apps/implementations/common.js +2 -2
- package/dist/lib/hexclave-app/apps/implementations/index.d.ts +1 -1
- package/dist/lib/hexclave-app/apps/implementations/server-app-impl.d.ts +1 -1
- package/dist/providers/hexclave-provider.d.ts +1 -1
- package/dist/providers/translation-provider.d.ts +1 -1
- package/dist/{quetzal-translations-CK45_4Dm.d.ts → quetzal-translations-XeH3zQ9l.d.ts} +3 -3
- package/dist/{quetzal-translations-CK45_4Dm.d.ts.map → quetzal-translations-XeH3zQ9l.d.ts.map} +1 -1
- package/dist/{translation-provider-DQ3BJepJ.d.ts → translation-provider-WOaZXqAz.d.ts} +2 -2
- package/dist/{translation-provider-DQ3BJepJ.d.ts.map → translation-provider-WOaZXqAz.d.ts.map} +1 -1
- package/package.json +3 -3
- package/src/components/message-cards/no-auth-methods-message-card.tsx +57 -0
- package/src/components-page/auth-page.tsx +18 -1
- package/src/components-page/cli-auth-confirm.test.tsx +55 -0
- package/src/components-page/cli-auth-confirm.tsx +11 -1
|
@@ -5,10 +5,10 @@ let _hexclave_shared_dist_utils_errors = require("@hexclave/shared/dist/utils/er
|
|
|
5
5
|
let _hexclave_ui = require("@hexclave/ui");
|
|
6
6
|
let react = require("react");
|
|
7
7
|
let ___index_js = require("../index.js");
|
|
8
|
-
let ___components_elements_maybe_full_page_js = require("../components/elements/maybe-full-page.js");
|
|
9
8
|
let ___lib_translations_js = require("../lib/translations.js");
|
|
10
9
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
11
10
|
let _hexclave_shared = require("@hexclave/shared");
|
|
11
|
+
let ___components_elements_maybe_full_page_js = require("../components/elements/maybe-full-page.js");
|
|
12
12
|
let _hexclave_shared_dist_utils_react = require("@hexclave/shared/dist/utils/react");
|
|
13
13
|
let ___components_credential_sign_in_js = require("../components/credential-sign-in.js");
|
|
14
14
|
let ___components_credential_sign_up_js = require("../components/credential-sign-up.js");
|
|
@@ -16,6 +16,7 @@ let ___components_elements_separator_with_text_js = require("../components/eleme
|
|
|
16
16
|
let ___components_link_js = require("../components/link.js");
|
|
17
17
|
let ___components_message_cards_known_error_message_card_js = require("../components/message-cards/known-error-message-card.js");
|
|
18
18
|
let ___components_message_cards_message_card_js = require("../components/message-cards/message-card.js");
|
|
19
|
+
let ___components_message_cards_no_auth_methods_message_card_js = require("../components/message-cards/no-auth-methods-message-card.js");
|
|
19
20
|
let ___components_magic_link_sign_in_js = require("../components/magic-link-sign-in.js");
|
|
20
21
|
let ___components_message_cards_predefined_message_card_js = require("../components/message-cards/predefined-message-card.js");
|
|
21
22
|
let ___components_oauth_button_group_js = require("../components/oauth-button-group.js");
|
|
@@ -112,6 +113,10 @@ function Inner(props) {
|
|
|
112
113
|
const hasOAuthProviders = project.config.oauthProviders.length > 0;
|
|
113
114
|
const hasPasskey = project.config.passkeyEnabled === true && props.type === "sign-in";
|
|
114
115
|
const enableSeparator = (project.config.credentialEnabled || project.config.magicLinkEnabled) && (hasOAuthProviders || hasPasskey);
|
|
116
|
+
if (!(hasOAuthProviders || project.config.passkeyEnabled === true || project.config.credentialEnabled || project.config.magicLinkEnabled)) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(___components_message_cards_no_auth_methods_message_card_js.NoAuthMethodsMessageCard, {
|
|
117
|
+
fullPage: props.fullPage,
|
|
118
|
+
projectDisplayName: "displayName" in project ? project.displayName : void 0
|
|
119
|
+
});
|
|
115
120
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(___components_elements_maybe_full_page_js.MaybeFullPage, {
|
|
116
121
|
fullPage: !!props.fullPage,
|
|
117
122
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
@@ -184,9 +189,9 @@ function Inner(props) {
|
|
|
184
189
|
})
|
|
185
190
|
]
|
|
186
191
|
}) : project.config.credentialEnabled ? props.type === "sign-up" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(___components_credential_sign_up_js.CredentialSignUp, { noPasswordRepeat: props.noPasswordRepeat }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(___components_credential_sign_in_js.CredentialSignIn, {}) : project.config.magicLinkEnabled ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(___components_magic_link_sign_in_js.MagicLinkSignIn, {}) : !(hasOAuthProviders || hasPasskey) ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_hexclave_ui.Typography, {
|
|
187
|
-
variant: "
|
|
192
|
+
variant: "secondary",
|
|
188
193
|
className: "text-center",
|
|
189
|
-
children: t("
|
|
194
|
+
children: t("New accounts can't be created with the sign-in methods enabled for this app. Sign in instead.")
|
|
190
195
|
}) : null,
|
|
191
196
|
props.extraInfo && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
192
197
|
className: (0, _hexclave_ui.cn)("flex flex-col items-center text-center text-sm text-gray-500", {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth-page.js","names":["Suspense","MaybeFullPage","Skeleton","KnownError","KnownErrorMessageCard","PredefinedMessageCard","MessageCard","Typography","StyledLink","OAuthButtonGroup","PasskeyButton","SeparatorWithText","Tabs","TabsList","TabsTrigger","TabsContent","MagicLinkSignIn","CredentialSignUp","CredentialSignIn"],"sources":["../../src/components-page/auth-page.tsx"],"sourcesContent":["'use client';\n\n\n//===========================================\n// THIS FILE IS AUTO-GENERATED FROM TEMPLATE. DO NOT EDIT IT DIRECTLY UNLESS YOU ALSO EDIT THE CORRESPONDING FILE IN packages/template\n//===========================================\n\nimport { KnownError } from '@hexclave/shared';\nimport { captureError } from '@hexclave/shared/dist/utils/errors';\nimport { runAsynchronously } from '@hexclave/shared/dist/utils/promises';\nimport { use } from '@hexclave/shared/dist/utils/react';\nimport { Skeleton, Tabs, TabsContent, TabsList, TabsTrigger, Typography, cn } from '@hexclave/ui';\nimport { Suspense, useMemo } from 'react';\nimport { useStackApp, useUser } from '..';\nimport { CredentialSignIn } from '../components/credential-sign-in';\nimport { CredentialSignUp } from '../components/credential-sign-up';\nimport { MaybeFullPage } from '../components/elements/maybe-full-page';\nimport { SeparatorWithText } from '../components/elements/separator-with-text';\nimport { StyledLink } from '../components/link';\nimport { KnownErrorMessageCard } from '../components/message-cards/known-error-message-card';\nimport { MessageCard } from '../components/message-cards/message-card';\nimport { MagicLinkSignIn } from '../components/magic-link-sign-in';\nimport { PredefinedMessageCard } from '../components/message-cards/predefined-message-card';\nimport { OAuthButtonGroup } from '../components/oauth-button-group';\nimport { PasskeyButton } from '../components/passkey-button';\nimport { useTranslation } from '../lib/translations';\n\ntype Props = {\n noPasswordRepeat?: boolean,\n firstTab?: 'magic-link' | 'password',\n fullPage?: boolean,\n type: 'sign-in' | 'sign-up',\n automaticRedirect?: boolean,\n extraInfo?: React.ReactNode,\n mockProject?: {\n config: {\n signUpEnabled: boolean,\n credentialEnabled: boolean,\n passkeyEnabled: boolean,\n magicLinkEnabled: boolean,\n oauthProviders: {\n id: string,\n }[],\n },\n },\n}\n\ntype AutomaticRedirectResult =\n | { status: \"success\" }\n | { status: \"known-error\", error: KnownError }\n | { status: \"unknown-error\" };\n\nexport function AuthPage(props: Props) {\n return <Suspense fallback={<Fallback {...props} />}>\n <Inner {...props} />\n </Suspense>;\n}\n\nfunction Fallback(props: Props) {\n return (\n <MaybeFullPage fullPage={!!props.fullPage}>\n <div className='stack-scope flex flex-col items-stretch' style={{ maxWidth: '380px', flexBasis: '380px', padding: props.fullPage ? '1rem' : 0 }}>\n <div className=\"text-center mb-6 flex flex-col\">\n <Skeleton className='h-9 w-2/3 self-center' />\n\n <Skeleton className='h-3 w-16 mt-8' />\n <Skeleton className='h-9 w-full mt-1' />\n\n <Skeleton className='h-3 w-24 mt-2' />\n <Skeleton className='h-9 w-full mt-1' />\n\n <Skeleton className='h-9 w-full mt-6' />\n </div>\n </div>\n </MaybeFullPage>\n );\n}\n\nfunction AutomaticRedirect(props: {\n fullPage?: boolean,\n isRestricted: boolean,\n type: 'sign-in' | 'sign-up',\n}) {\n const hexclaveApp = useStackApp();\n const { t } = useTranslation();\n const redirectResultPromise = useMemo(async (): Promise<AutomaticRedirectResult> => {\n try {\n await (\n props.isRestricted\n ? hexclaveApp.redirectToOnboarding({ replace: true })\n : props.type === 'sign-in'\n ? hexclaveApp.redirectToAfterSignIn({ replace: true })\n : hexclaveApp.redirectToAfterSignUp({ replace: true })\n );\n return { status: \"success\" };\n } catch (e) {\n if (KnownError.isKnownError(e)) {\n return { status: \"known-error\", error: e };\n }\n captureError(\"<AuthPage automaticRedirect />\", e);\n return { status: \"unknown-error\" };\n }\n }, [hexclaveApp, props.isRestricted, props.type]);\n\n const redirectResult = use(redirectResultPromise);\n if (redirectResult.status === \"known-error\") {\n return <KnownErrorMessageCard error={redirectResult.error} fullPage={props.fullPage} />;\n }\n if (redirectResult.status === \"unknown-error\") {\n return <PredefinedMessageCard type='unknownError' fullPage={props.fullPage} />;\n }\n return <MessageCard title={t(\"Redirecting...\")} fullPage={props.fullPage} />;\n}\n\nfunction Inner(props: Props) {\n const hexclaveApp = useStackApp();\n const user = useUser({ includeRestricted: true });\n const projectFromHook = hexclaveApp.useProject();\n const project = props.mockProject || projectFromHook;\n const { t } = useTranslation();\n\n if (props.automaticRedirect && user && !props.mockProject) {\n return <Suspense fallback={<MessageCard title={t(\"Redirecting...\")} fullPage={props.fullPage} />}>\n <AutomaticRedirect fullPage={props.fullPage} isRestricted={user.isRestricted} type={props.type} />\n </Suspense>;\n }\n\n if (user && !props.mockProject && !props.automaticRedirect) {\n return <PredefinedMessageCard type='signedIn' fullPage={props.fullPage} />;\n }\n\n if (props.type === 'sign-up' && !project.config.signUpEnabled) {\n return <PredefinedMessageCard type='signUpDisabled' fullPage={props.fullPage} />;\n }\n\n const hasOAuthProviders = project.config.oauthProviders.length > 0;\n const hasPasskey = (project.config.passkeyEnabled === true && props.type === \"sign-in\");\n const enableSeparator = (project.config.credentialEnabled || project.config.magicLinkEnabled) && (hasOAuthProviders || hasPasskey);\n\n return (\n <MaybeFullPage fullPage={!!props.fullPage}>\n <div className='stack-scope flex flex-col items-stretch' style={{ maxWidth: '380px', flexBasis: '380px', padding: props.fullPage ? '1rem' : 0 }}>\n <div className=\"text-center mb-6\">\n <Typography type='h2'>\n {props.type === 'sign-in' ? t(\"Sign in to your account\") : t(\"Create a new account\")}\n </Typography>\n {props.type === 'sign-in' ? (\n project.config.signUpEnabled && (\n <Typography>\n {t(\"Don't have an account?\")}{\" \"}\n <StyledLink href=\"#\" onClick={(e) => {\n runAsynchronously(hexclaveApp.redirectToSignUp());\n e.preventDefault();\n }}>{t(\"Sign up\")}</StyledLink>\n </Typography>\n )\n ) : (\n <Typography>\n {t(\"Already have an account?\")}{\" \"}\n <StyledLink href=\"#\" onClick={(e) => {\n runAsynchronously(hexclaveApp.redirectToSignIn());\n e.preventDefault();\n }}>{t(\"Sign in\")}</StyledLink>\n </Typography>\n )}\n </div>\n {(hasOAuthProviders || hasPasskey) && (\n <div className='gap-4 flex flex-col items-stretch stack-scope'>\n {hasOAuthProviders && <OAuthButtonGroup type={props.type} mockProject={props.mockProject} />}\n {hasPasskey && <PasskeyButton type={props.type} />}\n </div>\n )}\n\n {enableSeparator && <SeparatorWithText text={t('Or continue with')} />}\n {project.config.credentialEnabled && project.config.magicLinkEnabled ? (\n <Tabs defaultValue={props.firstTab || 'magic-link'}>\n <TabsList className={cn('w-full mb-2', {\n 'flex-row-reverse': props.firstTab === 'password'\n })}>\n <TabsTrigger value='magic-link' className='flex-1'>{t(\"Email\")}</TabsTrigger>\n <TabsTrigger value='password' className='flex-1'>{t(\"Email & Password\")}</TabsTrigger>\n </TabsList>\n <TabsContent value='magic-link'>\n <MagicLinkSignIn />\n </TabsContent>\n <TabsContent value='password'>\n {props.type === 'sign-up' ? <CredentialSignUp noPasswordRepeat={props.noPasswordRepeat} /> : <CredentialSignIn />}\n </TabsContent>\n </Tabs>\n ) : project.config.credentialEnabled ? (\n props.type === 'sign-up' ? <CredentialSignUp noPasswordRepeat={props.noPasswordRepeat} /> : <CredentialSignIn />\n ) : project.config.magicLinkEnabled ? (\n <MagicLinkSignIn />\n ) : !(hasOAuthProviders || hasPasskey) ? <Typography variant={\"destructive\"} className=\"text-center\">{t(\"No authentication method enabled.\")}</Typography> : null}\n {props.extraInfo && (\n <div className={cn('flex flex-col items-center text-center text-sm text-gray-500', {\n 'mt-2': project.config.credentialEnabled || project.config.magicLinkEnabled,\n 'mt-6': !(project.config.credentialEnabled || project.config.magicLinkEnabled),\n })}>\n <div>{props.extraInfo}</div>\n </div>\n )}\n </div>\n </MaybeFullPage>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAoDA,SAAgB,SAAS,OAAc;CACrC,OAAO,iBAAA,GAAA,kBAAA,IAAA,CAACA,MAAAA,UAAD;EAAU,UAAU,iBAAA,GAAA,kBAAA,IAAA,CAAC,UAAD,EAAU,GAAI,MAAQ,CAAA;YAC/C,iBAAA,GAAA,kBAAA,IAAA,CAAC,OAAD,EAAO,GAAI,MAAQ,CAAA;CACX,CAAA;AACZ;AAEA,SAAS,SAAS,OAAc;CAC9B,OACE,iBAAA,GAAA,kBAAA,IAAA,CAACC,0CAAAA,eAAD;EAAe,UAAU,CAAC,CAAC,MAAM;YAC/B,iBAAA,GAAA,kBAAA,IAAA,CAAC,OAAD;GAAK,WAAU;GAA0C,OAAO;IAAE,UAAU;IAAS,WAAW;IAAS,SAAS,MAAM,WAAW,SAAS;GAAE;aAC5I,iBAAA,GAAA,kBAAA,KAAA,CAAC,OAAD;IAAK,WAAU;cAAf;KACE,iBAAA,GAAA,kBAAA,IAAA,CAACC,aAAAA,UAAD,EAAU,WAAU,wBAAyB,CAAA;KAE7C,iBAAA,GAAA,kBAAA,IAAA,CAACA,aAAAA,UAAD,EAAU,WAAU,gBAAiB,CAAA;KACrC,iBAAA,GAAA,kBAAA,IAAA,CAACA,aAAAA,UAAD,EAAU,WAAU,kBAAmB,CAAA;KAEvC,iBAAA,GAAA,kBAAA,IAAA,CAACA,aAAAA,UAAD,EAAU,WAAU,gBAAiB,CAAA;KACrC,iBAAA,GAAA,kBAAA,IAAA,CAACA,aAAAA,UAAD,EAAU,WAAU,kBAAmB,CAAA;KAEvC,iBAAA,GAAA,kBAAA,IAAA,CAACA,aAAAA,UAAD,EAAU,WAAU,kBA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Ae,EAAE,mCAAmC;IAAc,CAAA,IAAI;IAC5J,MAAM,aACL,iBAAA,GAAA,kBAAA,IAAA,CAAC,OAAD;KAAK,YAAA,GAAA,aAAA,GAAA,CAAc,gEAAgE;MACjF,QAAQ,QAAQ,OAAO,qBAAqB,QAAQ,OAAO;MAC3D,QAAQ,EAAE,QAAQ,OAAO,qBAAqB,QAAQ,OAAO;KAC/D,CAAC;eACC,iBAAA,GAAA,kBAAA,IAAA,CAAC,OAAD,EAAA,UAAM,MAAM,UAAe,CAAA;IACxB,CAAA;GAEJ;;CACQ,CAAA;AAEnB"}
|
|
1
|
+
{"version":3,"file":"auth-page.js","names":["Suspense","MaybeFullPage","Skeleton","KnownError","KnownErrorMessageCard","PredefinedMessageCard","MessageCard","NoAuthMethodsMessageCard","Typography","StyledLink","OAuthButtonGroup","PasskeyButton","SeparatorWithText","Tabs","TabsList","TabsTrigger","TabsContent","MagicLinkSignIn","CredentialSignUp","CredentialSignIn"],"sources":["../../src/components-page/auth-page.tsx"],"sourcesContent":["'use client';\n\n\n//===========================================\n// THIS FILE IS AUTO-GENERATED FROM TEMPLATE. DO NOT EDIT IT DIRECTLY UNLESS YOU ALSO EDIT THE CORRESPONDING FILE IN packages/template\n//===========================================\n\nimport { KnownError } from '@hexclave/shared';\nimport { captureError } from '@hexclave/shared/dist/utils/errors';\nimport { runAsynchronously } from '@hexclave/shared/dist/utils/promises';\nimport { use } from '@hexclave/shared/dist/utils/react';\nimport { Skeleton, Tabs, TabsContent, TabsList, TabsTrigger, Typography, cn } from '@hexclave/ui';\nimport { Suspense, useMemo } from 'react';\nimport { useStackApp, useUser } from '..';\nimport { CredentialSignIn } from '../components/credential-sign-in';\nimport { CredentialSignUp } from '../components/credential-sign-up';\nimport { MaybeFullPage } from '../components/elements/maybe-full-page';\nimport { SeparatorWithText } from '../components/elements/separator-with-text';\nimport { StyledLink } from '../components/link';\nimport { KnownErrorMessageCard } from '../components/message-cards/known-error-message-card';\nimport { MessageCard } from '../components/message-cards/message-card';\nimport { NoAuthMethodsMessageCard } from '../components/message-cards/no-auth-methods-message-card';\nimport { MagicLinkSignIn } from '../components/magic-link-sign-in';\nimport { PredefinedMessageCard } from '../components/message-cards/predefined-message-card';\nimport { OAuthButtonGroup } from '../components/oauth-button-group';\nimport { PasskeyButton } from '../components/passkey-button';\nimport { useTranslation } from '../lib/translations';\n\ntype Props = {\n noPasswordRepeat?: boolean,\n firstTab?: 'magic-link' | 'password',\n fullPage?: boolean,\n type: 'sign-in' | 'sign-up',\n automaticRedirect?: boolean,\n extraInfo?: React.ReactNode,\n mockProject?: {\n config: {\n signUpEnabled: boolean,\n credentialEnabled: boolean,\n passkeyEnabled: boolean,\n magicLinkEnabled: boolean,\n oauthProviders: {\n id: string,\n }[],\n },\n },\n}\n\ntype AutomaticRedirectResult =\n | { status: \"success\" }\n | { status: \"known-error\", error: KnownError }\n | { status: \"unknown-error\" };\n\nexport function AuthPage(props: Props) {\n return <Suspense fallback={<Fallback {...props} />}>\n <Inner {...props} />\n </Suspense>;\n}\n\nfunction Fallback(props: Props) {\n return (\n <MaybeFullPage fullPage={!!props.fullPage}>\n <div className='stack-scope flex flex-col items-stretch' style={{ maxWidth: '380px', flexBasis: '380px', padding: props.fullPage ? '1rem' : 0 }}>\n <div className=\"text-center mb-6 flex flex-col\">\n <Skeleton className='h-9 w-2/3 self-center' />\n\n <Skeleton className='h-3 w-16 mt-8' />\n <Skeleton className='h-9 w-full mt-1' />\n\n <Skeleton className='h-3 w-24 mt-2' />\n <Skeleton className='h-9 w-full mt-1' />\n\n <Skeleton className='h-9 w-full mt-6' />\n </div>\n </div>\n </MaybeFullPage>\n );\n}\n\nfunction AutomaticRedirect(props: {\n fullPage?: boolean,\n isRestricted: boolean,\n type: 'sign-in' | 'sign-up',\n}) {\n const hexclaveApp = useStackApp();\n const { t } = useTranslation();\n const redirectResultPromise = useMemo(async (): Promise<AutomaticRedirectResult> => {\n try {\n await (\n props.isRestricted\n ? hexclaveApp.redirectToOnboarding({ replace: true })\n : props.type === 'sign-in'\n ? hexclaveApp.redirectToAfterSignIn({ replace: true })\n : hexclaveApp.redirectToAfterSignUp({ replace: true })\n );\n return { status: \"success\" };\n } catch (e) {\n if (KnownError.isKnownError(e)) {\n return { status: \"known-error\", error: e };\n }\n captureError(\"<AuthPage automaticRedirect />\", e);\n return { status: \"unknown-error\" };\n }\n }, [hexclaveApp, props.isRestricted, props.type]);\n\n const redirectResult = use(redirectResultPromise);\n if (redirectResult.status === \"known-error\") {\n return <KnownErrorMessageCard error={redirectResult.error} fullPage={props.fullPage} />;\n }\n if (redirectResult.status === \"unknown-error\") {\n return <PredefinedMessageCard type='unknownError' fullPage={props.fullPage} />;\n }\n return <MessageCard title={t(\"Redirecting...\")} fullPage={props.fullPage} />;\n}\n\nfunction Inner(props: Props) {\n const hexclaveApp = useStackApp();\n const user = useUser({ includeRestricted: true });\n const projectFromHook = hexclaveApp.useProject();\n const project = props.mockProject || projectFromHook;\n const { t } = useTranslation();\n\n if (props.automaticRedirect && user && !props.mockProject) {\n return <Suspense fallback={<MessageCard title={t(\"Redirecting...\")} fullPage={props.fullPage} />}>\n <AutomaticRedirect fullPage={props.fullPage} isRestricted={user.isRestricted} type={props.type} />\n </Suspense>;\n }\n\n if (user && !props.mockProject && !props.automaticRedirect) {\n return <PredefinedMessageCard type='signedIn' fullPage={props.fullPage} />;\n }\n\n if (props.type === 'sign-up' && !project.config.signUpEnabled) {\n return <PredefinedMessageCard type='signUpDisabled' fullPage={props.fullPage} />;\n }\n\n const hasOAuthProviders = project.config.oauthProviders.length > 0;\n const hasPasskey = (project.config.passkeyEnabled === true && props.type === \"sign-in\");\n const enableSeparator = (project.config.credentialEnabled || project.config.magicLinkEnabled) && (hasOAuthProviders || hasPasskey);\n\n // Note that we check passkeys regardless of `props.type` here (unlike `hasPasskey`); a project with only\n // passkeys enabled can't sign up with them, but it is configured correctly, so the sign-up page should\n // keep pointing at the sign-in page instead of claiming that the project is misconfigured.\n const hasAnyAuthMethod = hasOAuthProviders\n || project.config.passkeyEnabled === true\n || project.config.credentialEnabled\n || project.config.magicLinkEnabled;\n\n if (!hasAnyAuthMethod) {\n return <NoAuthMethodsMessageCard fullPage={props.fullPage} projectDisplayName={'displayName' in project ? project.displayName : undefined} />;\n }\n\n return (\n <MaybeFullPage fullPage={!!props.fullPage}>\n <div className='stack-scope flex flex-col items-stretch' style={{ maxWidth: '380px', flexBasis: '380px', padding: props.fullPage ? '1rem' : 0 }}>\n <div className=\"text-center mb-6\">\n <Typography type='h2'>\n {props.type === 'sign-in' ? t(\"Sign in to your account\") : t(\"Create a new account\")}\n </Typography>\n {props.type === 'sign-in' ? (\n project.config.signUpEnabled && (\n <Typography>\n {t(\"Don't have an account?\")}{\" \"}\n <StyledLink href=\"#\" onClick={(e) => {\n runAsynchronously(hexclaveApp.redirectToSignUp());\n e.preventDefault();\n }}>{t(\"Sign up\")}</StyledLink>\n </Typography>\n )\n ) : (\n <Typography>\n {t(\"Already have an account?\")}{\" \"}\n <StyledLink href=\"#\" onClick={(e) => {\n runAsynchronously(hexclaveApp.redirectToSignIn());\n e.preventDefault();\n }}>{t(\"Sign in\")}</StyledLink>\n </Typography>\n )}\n </div>\n {(hasOAuthProviders || hasPasskey) && (\n <div className='gap-4 flex flex-col items-stretch stack-scope'>\n {hasOAuthProviders && <OAuthButtonGroup type={props.type} mockProject={props.mockProject} />}\n {hasPasskey && <PasskeyButton type={props.type} />}\n </div>\n )}\n\n {enableSeparator && <SeparatorWithText text={t('Or continue with')} />}\n {project.config.credentialEnabled && project.config.magicLinkEnabled ? (\n <Tabs defaultValue={props.firstTab || 'magic-link'}>\n <TabsList className={cn('w-full mb-2', {\n 'flex-row-reverse': props.firstTab === 'password'\n })}>\n <TabsTrigger value='magic-link' className='flex-1'>{t(\"Email\")}</TabsTrigger>\n <TabsTrigger value='password' className='flex-1'>{t(\"Email & Password\")}</TabsTrigger>\n </TabsList>\n <TabsContent value='magic-link'>\n <MagicLinkSignIn />\n </TabsContent>\n <TabsContent value='password'>\n {props.type === 'sign-up' ? <CredentialSignUp noPasswordRepeat={props.noPasswordRepeat} /> : <CredentialSignIn />}\n </TabsContent>\n </Tabs>\n ) : project.config.credentialEnabled ? (\n props.type === 'sign-up' ? <CredentialSignUp noPasswordRepeat={props.noPasswordRepeat} /> : <CredentialSignIn />\n ) : project.config.magicLinkEnabled ? (\n <MagicLinkSignIn />\n ) : !(hasOAuthProviders || hasPasskey) ? (\n // Only reachable on the sign-up page of a passkey-only project: the project is configured\n // correctly, there is just no way to create an account with a passkey alone.\n <Typography variant=\"secondary\" className=\"text-center\">{t(\"New accounts can't be created with the sign-in methods enabled for this app. Sign in instead.\")}</Typography>\n ) : null}\n {props.extraInfo && (\n <div className={cn('flex flex-col items-center text-center text-sm text-gray-500', {\n 'mt-2': project.config.credentialEnabled || project.config.magicLinkEnabled,\n 'mt-6': !(project.config.credentialEnabled || project.config.magicLinkEnabled),\n })}>\n <div>{props.extraInfo}</div>\n </div>\n )}\n </div>\n </MaybeFullPage>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAqDA,SAAgB,SAAS,OAAc;CACrC,OAAO,iBAAA,GAAA,kBAAA,IAAA,CAACA,MAAAA,UAAD;EAAU,UAAU,iBAAA,GAAA,kBAAA,IAAA,CAAC,UAAD,EAAU,GAAI,MAAQ,CAAA;YAC/C,iBAAA,GAAA,kBAAA,IAAA,CAAC,OAAD,EAAO,GAAI,MAAQ,CAAA;CACX,CAAA;AACZ;AAEA,SAAS,SAAS,OAAc;CAC9B,OACE,iBAAA,GAAA,kBAAA,IAAA,CAACC,0CAAAA,eAAD;EAAe,UAAU,CAAC,CAAC,MAAM;YAC/B,iBAAA,GAAA,kBAAA,IAAA,CAAC,OAAD;GAAK,WAAU;GAA0C,OAAO;IAAE,UAAU;IAAS,WAAW;IAAS,SAAS,MAAM,WAAW,SAAS;GAAE;aAC5I,iBAAA,GAAA,kBAAA,KAAA,CAAC,OAAD;IAAK,WAAU;cAAf;K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,CAACC,oCAAAA,iBAAD,CAAkB,CAAA;MACP,CAAA;MACb,iBAAA,GAAA,kBAAA,IAAA,CAACD,aAAAA,aAAD;OAAa,OAAM;iBAChB,MAAM,SAAS,YAAY,iBAAA,GAAA,kBAAA,IAAA,CAACE,oCAAAA,kBAAD,EAAkB,kBAAkB,MAAM,iBAAmB,CAAA,IAAI,iBAAA,GAAA,kBAAA,IAAA,CAACC,oCAAAA,kBAAD,CAAmB,CAAA;MACrG,CAAA;KACT;SACJ,QAAQ,OAAO,oBACjB,MAAM,SAAS,YAAY,iBAAA,GAAA,kBAAA,IAAA,CAACD,oCAAAA,kBAAD,EAAkB,kBAAkB,MAAM,iBAAmB,CAAA,IAAI,iBAAA,GAAA,kBAAA,IAAA,CAACC,oCAAAA,kBAAD,CAAmB,CAAA,IAC7G,QAAQ,OAAO,mBACjB,iBAAA,GAAA,kBAAA,IAAA,CAACF,oCAAAA,iBAAD,CAAkB,CAAA,IAChB,EAAE,qBAAqB,cAGzB,iBAAA,GAAA,kBAAA,IAAA,CAACT,aAAAA,YAAD;KAAY,SAAQ;KAAY,WAAU;eAAe,EAAE,+FAA+F;IAAc,CAAA,IACtK;IACH,MAAM,aACL,iBAAA,GAAA,kBAAA,IAAA,CAAC,OAAD;KAAK,YAAA,GAAA,aAAA,GAAA,CAAc,gEAAgE;MACjF,QAAQ,QAAQ,OAAO,qBAAqB,QAAQ,OAAO;MAC3D,QAAQ,EAAE,QAAQ,OAAO,qBAAqB,QAAQ,OAAO;KAC/D,CAAC;eACC,iBAAA,GAAA,kBAAA,IAAA,CAAC,OAAD,EAAA,UAAM,MAAM,UAAe,CAAA;IACxB,CAAA;GAEJ;;CACQ,CAAA;AAEnB"}
|
|
@@ -6,8 +6,8 @@ let _hexclave_ui = require("@hexclave/ui");
|
|
|
6
6
|
let react = require("react");
|
|
7
7
|
let ___lib_translations_js = require("../lib/translations.js");
|
|
8
8
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
9
|
-
let ___components_message_cards_message_card_js = require("../components/message-cards/message-card.js");
|
|
10
9
|
let ___lib_hooks_js = require("../lib/hooks.js");
|
|
10
|
+
let ___components_message_cards_message_card_js = require("../components/message-cards/message-card.js");
|
|
11
11
|
//#region src/components-page/cli-auth-confirm.tsx
|
|
12
12
|
async function postCliAuthComplete(app, body) {
|
|
13
13
|
return await app[___lib_hexclave_app_common_js.hexclaveAppInternalsSymbol].sendRequest("/auth/cli/complete", {
|
|
@@ -72,7 +72,7 @@ function useCliAuthConfirmation() {
|
|
|
72
72
|
user
|
|
73
73
|
]);
|
|
74
74
|
(0, react.useEffect)(() => {
|
|
75
|
-
if (!confirmed || !user || autoCompleteRef.current) return;
|
|
75
|
+
if (!confirmed || !user || user.isRestricted || autoCompleteRef.current) return;
|
|
76
76
|
autoCompleteRef.current = true;
|
|
77
77
|
(0, _hexclave_shared_dist_utils_promises.runAsynchronouslyWithAlert)(async () => {
|
|
78
78
|
setStatus("authorizing");
|
|
@@ -102,6 +102,12 @@ function useCliAuthConfirmation() {
|
|
|
102
102
|
setError(null);
|
|
103
103
|
setStatus("authorizing");
|
|
104
104
|
if (user) {
|
|
105
|
+
if (user.isRestricted) {
|
|
106
|
+
markConfirmed(loginCode);
|
|
107
|
+
setStatus("redirecting");
|
|
108
|
+
await (user.isAnonymous ? app.redirectToSignUp({ replace: true }) : app.redirectToOnboarding({ replace: true }));
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
105
111
|
await completeWithCurrentUser();
|
|
106
112
|
clearConfirmed();
|
|
107
113
|
setStatus("success");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli-auth-confirm.js","names":["hexclaveAppInternalsSymbol","MessageCard","Typography"],"sources":["../../src/components-page/cli-auth-confirm.tsx"],"sourcesContent":["'use client';\n\n\n//===========================================\n// THIS FILE IS AUTO-GENERATED FROM TEMPLATE. DO NOT EDIT IT DIRECTLY UNLESS YOU ALSO EDIT THE CORRESPONDING FILE IN packages/template\n//===========================================\n\nimport { runAsynchronouslyWithAlert } from \"@hexclave/shared/dist/utils/promises\";\nimport { Typography } from \"@hexclave/ui\";\nimport { useCallback, useEffect, useRef, useState } from \"react\";\nimport { MessageCard } from \"../components/message-cards/message-card\";\nimport { useTranslation } from \"../lib/translations\";\nimport { hexclaveAppInternalsSymbol } from \"../lib/hexclave-app/common\";\nimport type { StackClientApp } from \"../lib/hexclave-app/apps/interfaces/client-app\";\nimport { useStackApp } from \"../lib/hooks\";\n\nasync function postCliAuthComplete(app: StackClientApp, body: Record<string, unknown>) {\n return await app[hexclaveAppInternalsSymbol].sendRequest(\"/auth/cli/complete\", {\n method: \"POST\",\n headers: { \"Content-Type\": \"application/json\" },\n body: JSON.stringify(body),\n });\n}\n\nasync function ensureCliCompleteOk(result: Response) {\n if (!result.ok) {\n throw new Error(`Authorization failed: ${result.status} ${await result.text()}`);\n }\n}\n\nasync function completeCliAuthWithRefreshToken(app: StackClientApp, loginCode: string, refreshToken: string) {\n const result = await postCliAuthComplete(app, { login_code: loginCode, refresh_token: refreshToken });\n await ensureCliCompleteOk(result);\n}\n\n// Hexclave rebrand: sessionStorage key — straight rename (per-tab, low TTL).\nconst CLI_AUTH_CONFIRMED_KEY = \"hexclave-cli-auth-confirmed\";\n\nfunction markConfirmed(loginCode: string) {\n sessionStorage.setItem(CLI_AUTH_CONFIRMED_KEY, loginCode);\n}\n\nfunction isConfirmed(loginCode: string): boolean {\n return sessionStorage.getItem(CLI_AUTH_CONFIRMED_KEY) === loginCode;\n}\n\nfunction clearConfirmed() {\n sessionStorage.removeItem(CLI_AUTH_CONFIRMED_KEY);\n}\n\nfunction getError(err: unknown): Error {\n return err instanceof Error ? err : new Error(String(err));\n}\n\nfunction getObjectField(data: unknown, fieldName: string): unknown {\n return typeof data === \"object\" && data !== null && fieldName in data\n ? data[fieldName as keyof typeof data]\n : undefined;\n}\n\nfunction getStringField(data: unknown, fieldName: string): string | undefined {\n const value = getObjectField(data, fieldName);\n return typeof value === \"string\" ? value : undefined;\n}\n\nexport type CliAuthConfirmationStatus =\n | \"idle\"\n | \"invalid\"\n | \"authorizing\"\n | \"redirecting\"\n | \"success\"\n | \"error\";\n\nexport type CliAuthConfirmationState = {\n status: CliAuthConfirmationStatus,\n loginCode: string | null,\n error: Error | null,\n isLoading: boolean,\n authorize: () => Promise<void>,\n retry: () => void,\n};\n\nexport function useCliAuthConfirmation(): CliAuthConfirmationState {\n const app = useStackApp();\n const user = app.useUser({ includeRestricted: true });\n const [status, setStatus] = useState<Exclude<CliAuthConfirmationStatus, \"invalid\">>(\"idle\");\n const [error, setError] = useState<Error | null>(null);\n const autoCompleteRef = useRef(false);\n const authorizeInProgressRef = useRef(false);\n const [loginCode] = useState(() => {\n if (typeof window === 'undefined') return null;\n return new URLSearchParams(window.location.search).get(\"login_code\");\n });\n const [confirmed] = useState(() => {\n if (typeof window === 'undefined') return false;\n return loginCode != null && isConfirmed(loginCode);\n });\n\n const completeWithCurrentUser = useCallback(async () => {\n if (!loginCode) {\n throw new Error(\"Missing login code in URL parameters\");\n }\n if (!user) {\n throw new Error(\"Cannot complete CLI authorization without a signed-in user\");\n }\n const refreshToken = (await user.currentSession.getTokens()).refreshToken;\n if (!refreshToken) {\n throw new Error(\"Could not retrieve session token\");\n }\n await completeCliAuthWithRefreshToken(app, loginCode, refreshToken);\n }, [app, loginCode, user]);\n\n useEffect(() => {\n if (!confirmed || !user || autoCompleteRef.current) {\n return;\n }\n autoCompleteRef.current = true;\n runAsynchronouslyWithAlert(async () => {\n setStatus(\"authorizing\");\n try {\n await completeWithCurrentUser();\n clearConfirmed();\n setStatus(\"success\");\n } catch (err) {\n setError(getError(err));\n setStatus(\"error\");\n }\n });\n }, [confirmed, user, completeWithCurrentUser]);\n\n const authorize = useCallback(async () => {\n if (authorizeInProgressRef.current) {\n return;\n }\n authorizeInProgressRef.current = true;\n\n try {\n if (!loginCode) {\n setError(new Error(\"Missing login code in URL parameters\"));\n setStatus(\"error\");\n return;\n }\n\n setError(null);\n setStatus(\"authorizing\");\n if (user) {\n await completeWithCurrentUser();\n clearConfirmed();\n setStatus(\"success\");\n return;\n }\n\n const checkResult = await postCliAuthComplete(app, { login_code: loginCode, mode: \"check\" });\n if (!checkResult.ok) {\n throw new Error(`Failed to verify login code: ${checkResult.status} ${await checkResult.text()}`);\n }\n const checkData: unknown = await checkResult.json();\n const cliSessionState = getStringField(checkData, \"cli_session_state\") ?? null;\n\n if (cliSessionState === \"anonymous\") {\n const claimResult = await postCliAuthComplete(app, { login_code: loginCode, mode: \"claim-anon-session\" });\n\n if (!claimResult.ok) {\n throw new Error(`Failed to claim anonymous session: ${claimResult.status} ${await claimResult.text()}`);\n }\n\n const tokens: unknown = await claimResult.json();\n const accessToken = getStringField(tokens, \"access_token\");\n const refreshToken = getStringField(tokens, \"refresh_token\");\n if (!accessToken || !refreshToken) {\n throw new Error(\"Anonymous CLI session claim did not return tokens\");\n }\n await app[hexclaveAppInternalsSymbol].signInWithTokens({\n accessToken,\n refreshToken,\n });\n markConfirmed(loginCode);\n setStatus(\"redirecting\");\n await app.redirectToSignUp({ replace: true });\n return;\n }\n\n markConfirmed(loginCode);\n setStatus(\"redirecting\");\n await app.redirectToSignIn({ replace: true });\n } catch (err) {\n setError(getError(err));\n setStatus(\"error\");\n } finally {\n authorizeInProgressRef.current = false;\n }\n }, [app, completeWithCurrentUser, loginCode, user]);\n\n const retry = useCallback(() => {\n setError(null);\n autoCompleteRef.current = false;\n setStatus(\"idle\");\n }, []);\n\n const visibleStatus = loginCode == null ? \"invalid\" : status;\n return {\n status: visibleStatus,\n loginCode,\n error,\n isLoading: visibleStatus === \"authorizing\" || visibleStatus === \"redirecting\",\n authorize,\n retry,\n };\n}\n\nexport function CliAuthConfirmation({ fullPage = true }: { fullPage?: boolean }) {\n const { t } = useTranslation();\n const cliAuth = useCliAuthConfirmation();\n\n if (cliAuth.status === \"success\") {\n return (\n <MessageCard title={t(\"CLI Authorization Successful\")} fullPage={fullPage}>\n <Typography>\n {t(\"The CLI application has been authorized successfully. You can close this window and return to the command line.\")}\n </Typography>\n </MessageCard>\n );\n }\n\n if (cliAuth.status === \"error\") {\n return (\n <MessageCard\n title={t(\"Authorization Failed\")}\n fullPage={fullPage}\n primaryButtonText={t(\"Try Again\")}\n primaryAction={cliAuth.retry}\n >\n <Typography className=\"text-red-600\">\n {t(\"Failed to authorize the CLI application:\")}\n </Typography>\n <Typography className=\"text-red-600\">\n {cliAuth.error?.message}\n </Typography>\n </MessageCard>\n );\n }\n\n if (cliAuth.status === \"invalid\") {\n return (\n <MessageCard title={t(\"Invalid CLI Authorization Link\")} fullPage={fullPage}>\n <Typography className=\"text-red-600\">\n {t(\"This CLI authorization link is missing a login code. Please return to the command line and start the login process again.\")}\n </Typography>\n </MessageCard>\n );\n }\n\n if (cliAuth.status === \"authorizing\" || cliAuth.status === \"redirecting\") {\n return (\n <MessageCard title={t(\"Completing Authorization...\")} fullPage={fullPage}>\n <Typography>\n {t(\"Finishing up the CLI authorization...\")}\n </Typography>\n </MessageCard>\n );\n }\n\n return (\n <MessageCard\n title={t(\"Authorize CLI Application\")}\n fullPage={fullPage}\n primaryButtonText={cliAuth.isLoading ? t(\"Authorizing...\") : t(\"Authorize\")}\n primaryAction={cliAuth.authorize}\n >\n <Typography>\n {t(\"A command line application is requesting access to your account. Click the button below to authorize it.\")}\n </Typography>\n <Typography variant=\"destructive\">\n {t(\"WARNING: Make sure you trust the command line application, as it will gain access to your account. If you did not initiate this request, you can close this page and ignore it. We will never send you this link via email or any other means.\")}\n </Typography>\n </MessageCard>\n );\n}\n"],"mappings":";;;;;;;;;;;AAgBA,eAAe,oBAAoB,KAAqB,MAA+B;CACrF,OAAO,MAAM,IAAIA,8BAAAA,2BAA2B,CAAC,YAAY,sBAAsB;EAC7E,QAAQ;EACR,SAAS,EAAE,gBAAgB,mBAAmB;EAC9C,MAAM,KAAK,UAAU,IAAI;CAC3B,CAAC;AACH;AAEA,eAAe,oBAAoB,QAAkB;CACnD,IAAI,CAAC,OAAO,IACV,MAAM,I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AAmB,QAAQ,YAAY,EAAE,gBAAgB,IAAI,EAAE,WAAW;EAC1E,eAAe,QAAQ;YAJzB,CAME,iBAAA,GAAA,kBAAA,IAAA,CAACC,aAAAA,YAAD,EAAA,UACG,EAAE,0GAA0G,EACnG,CAAA,GACZ,iBAAA,GAAA,kBAAA,IAAA,CAACA,aAAAA,YAAD;GAAY,SAAQ;aACjB,EAAE,gPAAgP;EACzO,CAAA,CACD;;AAEjB"}
|
|
1
|
+
{"version":3,"file":"cli-auth-confirm.js","names":["hexclaveAppInternalsSymbol","MessageCard","Typography"],"sources":["../../src/components-page/cli-auth-confirm.tsx"],"sourcesContent":["'use client';\n\n\n//===========================================\n// THIS FILE IS AUTO-GENERATED FROM TEMPLATE. DO NOT EDIT IT DIRECTLY UNLESS YOU ALSO EDIT THE CORRESPONDING FILE IN packages/template\n//===========================================\n\nimport { runAsynchronouslyWithAlert } from \"@hexclave/shared/dist/utils/promises\";\nimport { Typography } from \"@hexclave/ui\";\nimport { useCallback, useEffect, useRef, useState } from \"react\";\nimport { MessageCard } from \"../components/message-cards/message-card\";\nimport { useTranslation } from \"../lib/translations\";\nimport { hexclaveAppInternalsSymbol } from \"../lib/hexclave-app/common\";\nimport type { StackClientApp } from \"../lib/hexclave-app/apps/interfaces/client-app\";\nimport { useStackApp } from \"../lib/hooks\";\n\nasync function postCliAuthComplete(app: StackClientApp, body: Record<string, unknown>) {\n return await app[hexclaveAppInternalsSymbol].sendRequest(\"/auth/cli/complete\", {\n method: \"POST\",\n headers: { \"Content-Type\": \"application/json\" },\n body: JSON.stringify(body),\n });\n}\n\nasync function ensureCliCompleteOk(result: Response) {\n if (!result.ok) {\n throw new Error(`Authorization failed: ${result.status} ${await result.text()}`);\n }\n}\n\nasync function completeCliAuthWithRefreshToken(app: StackClientApp, loginCode: string, refreshToken: string) {\n const result = await postCliAuthComplete(app, { login_code: loginCode, refresh_token: refreshToken });\n await ensureCliCompleteOk(result);\n}\n\n// Hexclave rebrand: sessionStorage key — straight rename (per-tab, low TTL).\nconst CLI_AUTH_CONFIRMED_KEY = \"hexclave-cli-auth-confirmed\";\n\nfunction markConfirmed(loginCode: string) {\n sessionStorage.setItem(CLI_AUTH_CONFIRMED_KEY, loginCode);\n}\n\nfunction isConfirmed(loginCode: string): boolean {\n return sessionStorage.getItem(CLI_AUTH_CONFIRMED_KEY) === loginCode;\n}\n\nfunction clearConfirmed() {\n sessionStorage.removeItem(CLI_AUTH_CONFIRMED_KEY);\n}\n\nfunction getError(err: unknown): Error {\n return err instanceof Error ? err : new Error(String(err));\n}\n\nfunction getObjectField(data: unknown, fieldName: string): unknown {\n return typeof data === \"object\" && data !== null && fieldName in data\n ? data[fieldName as keyof typeof data]\n : undefined;\n}\n\nfunction getStringField(data: unknown, fieldName: string): string | undefined {\n const value = getObjectField(data, fieldName);\n return typeof value === \"string\" ? value : undefined;\n}\n\nexport type CliAuthConfirmationStatus =\n | \"idle\"\n | \"invalid\"\n | \"authorizing\"\n | \"redirecting\"\n | \"success\"\n | \"error\";\n\nexport type CliAuthConfirmationState = {\n status: CliAuthConfirmationStatus,\n loginCode: string | null,\n error: Error | null,\n isLoading: boolean,\n authorize: () => Promise<void>,\n retry: () => void,\n};\n\nexport function useCliAuthConfirmation(): CliAuthConfirmationState {\n const app = useStackApp();\n const user = app.useUser({ includeRestricted: true });\n const [status, setStatus] = useState<Exclude<CliAuthConfirmationStatus, \"invalid\">>(\"idle\");\n const [error, setError] = useState<Error | null>(null);\n const autoCompleteRef = useRef(false);\n const authorizeInProgressRef = useRef(false);\n const [loginCode] = useState(() => {\n if (typeof window === 'undefined') return null;\n return new URLSearchParams(window.location.search).get(\"login_code\");\n });\n const [confirmed] = useState(() => {\n if (typeof window === 'undefined') return false;\n return loginCode != null && isConfirmed(loginCode);\n });\n\n const completeWithCurrentUser = useCallback(async () => {\n if (!loginCode) {\n throw new Error(\"Missing login code in URL parameters\");\n }\n if (!user) {\n throw new Error(\"Cannot complete CLI authorization without a signed-in user\");\n }\n const refreshToken = (await user.currentSession.getTokens()).refreshToken;\n if (!refreshToken) {\n throw new Error(\"Could not retrieve session token\");\n }\n await completeCliAuthWithRefreshToken(app, loginCode, refreshToken);\n }, [app, loginCode, user]);\n\n useEffect(() => {\n if (!confirmed || !user || user.isRestricted || autoCompleteRef.current) {\n return;\n }\n autoCompleteRef.current = true;\n runAsynchronouslyWithAlert(async () => {\n setStatus(\"authorizing\");\n try {\n await completeWithCurrentUser();\n clearConfirmed();\n setStatus(\"success\");\n } catch (err) {\n setError(getError(err));\n setStatus(\"error\");\n }\n });\n }, [confirmed, user, completeWithCurrentUser]);\n\n const authorize = useCallback(async () => {\n if (authorizeInProgressRef.current) {\n return;\n }\n authorizeInProgressRef.current = true;\n\n try {\n if (!loginCode) {\n setError(new Error(\"Missing login code in URL parameters\"));\n setStatus(\"error\");\n return;\n }\n\n setError(null);\n setStatus(\"authorizing\");\n if (user) {\n if (user.isRestricted) {\n markConfirmed(loginCode);\n setStatus(\"redirecting\");\n await (\n user.isAnonymous\n ? app.redirectToSignUp({ replace: true })\n : app.redirectToOnboarding({ replace: true })\n );\n return;\n }\n await completeWithCurrentUser();\n clearConfirmed();\n setStatus(\"success\");\n return;\n }\n\n const checkResult = await postCliAuthComplete(app, { login_code: loginCode, mode: \"check\" });\n if (!checkResult.ok) {\n throw new Error(`Failed to verify login code: ${checkResult.status} ${await checkResult.text()}`);\n }\n const checkData: unknown = await checkResult.json();\n const cliSessionState = getStringField(checkData, \"cli_session_state\") ?? null;\n\n if (cliSessionState === \"anonymous\") {\n const claimResult = await postCliAuthComplete(app, { login_code: loginCode, mode: \"claim-anon-session\" });\n\n if (!claimResult.ok) {\n throw new Error(`Failed to claim anonymous session: ${claimResult.status} ${await claimResult.text()}`);\n }\n\n const tokens: unknown = await claimResult.json();\n const accessToken = getStringField(tokens, \"access_token\");\n const refreshToken = getStringField(tokens, \"refresh_token\");\n if (!accessToken || !refreshToken) {\n throw new Error(\"Anonymous CLI session claim did not return tokens\");\n }\n await app[hexclaveAppInternalsSymbol].signInWithTokens({\n accessToken,\n refreshToken,\n });\n markConfirmed(loginCode);\n setStatus(\"redirecting\");\n await app.redirectToSignUp({ replace: true });\n return;\n }\n\n markConfirmed(loginCode);\n setStatus(\"redirecting\");\n await app.redirectToSignIn({ replace: true });\n } catch (err) {\n setError(getError(err));\n setStatus(\"error\");\n } finally {\n authorizeInProgressRef.current = false;\n }\n }, [app, completeWithCurrentUser, loginCode, user]);\n\n const retry = useCallback(() => {\n setError(null);\n autoCompleteRef.current = false;\n setStatus(\"idle\");\n }, []);\n\n const visibleStatus = loginCode == null ? \"invalid\" : status;\n return {\n status: visibleStatus,\n loginCode,\n error,\n isLoading: visibleStatus === \"authorizing\" || visibleStatus === \"redirecting\",\n authorize,\n retry,\n };\n}\n\nexport function CliAuthConfirmation({ fullPage = true }: { fullPage?: boolean }) {\n const { t } = useTranslation();\n const cliAuth = useCliAuthConfirmation();\n\n if (cliAuth.status === \"success\") {\n return (\n <MessageCard title={t(\"CLI Authorization Successful\")} fullPage={fullPage}>\n <Typography>\n {t(\"The CLI application has been authorized successfully. You can close this window and return to the command line.\")}\n </Typography>\n </MessageCard>\n );\n }\n\n if (cliAuth.status === \"error\") {\n return (\n <MessageCard\n title={t(\"Authorization Failed\")}\n fullPage={fullPage}\n primaryButtonText={t(\"Try Again\")}\n primaryAction={cliAuth.retry}\n >\n <Typography className=\"text-red-600\">\n {t(\"Failed to authorize the CLI application:\")}\n </Typography>\n <Typography className=\"text-red-600\">\n {cliAuth.error?.message}\n </Typography>\n </MessageCard>\n );\n }\n\n if (cliAuth.status === \"invalid\") {\n return (\n <MessageCard title={t(\"Invalid CLI Authorization Link\")} fullPage={fullPage}>\n <Typography className=\"text-red-600\">\n {t(\"This CLI authorization link is missing a login code. Please return to the command line and start the login process again.\")}\n </Typography>\n </MessageCard>\n );\n }\n\n if (cliAuth.status === \"authorizing\" || cliAuth.status === \"redirecting\") {\n return (\n <MessageCard title={t(\"Completing Authorization...\")} fullPage={fullPage}>\n <Typography>\n {t(\"Finishing up the CLI authorization...\")}\n </Typography>\n </MessageCard>\n );\n }\n\n return (\n <MessageCard\n title={t(\"Authorize CLI Application\")}\n fullPage={fullPage}\n primaryButtonText={cliAuth.isLoading ? t(\"Authorizing...\") : t(\"Authorize\")}\n primaryAction={cliAuth.authorize}\n >\n <Typography>\n {t(\"A command line application is requesting access to your account. Click the button below to authorize it.\")}\n </Typography>\n <Typography variant=\"destructive\">\n {t(\"WARNING: Make sure you trust the command line application, as it will gain access to your account. If you did not initiate this request, you can close this page and ignore it. We will never send you this link via email or any other means.\")}\n </Typography>\n </MessageCard>\n );\n}\n"],"mappings":";;;;;;;;;;;AAgBA,eAAe,oBAAoB,KAAqB,MAA+B;CACrF,OAAO,MAAM,IAAIA,8BAAAA,2BAA2B,CAAC,YAAY,sBAAsB;EAC7E,QAAQ;EACR,SAAS,EAAE,gBAAgB,mBAAmB;EAC9C,MAAM,KAAK,UAAU,IAAI;CAC3B,CAAC;AACH;AAEA,eAAe,oBAAoB,QAAkB;CACnD,IAAI,CAAC,OAAO,IACV,MAAM,IAAI,MAAM,yBAAyB,OAAO,OAAO,GAAG,MAAM,OAAO,KAAK,GAAG;AAEnF;AAEA,eAAe,gCAAgC,KAAqB,WAAmB,cAAsB;CAE3G,MAAM,oBAAoB,MADL,oBAAoB,KAAK;EAAE,YAAY;EAAW,eAAe;CAAa,CAAC,CACpE;AAClC;AAGA,MAAM,yBAAyB;AAE/B,SAAS,cAAc,WAAmB;CACxC,eAAe,QAAQ,wBAAwB,SAAS;AAC1D;AAEA,SAAS,YAAY,WAA4B;CAC/C,OAAO,eAAe,QAAQ,sBAAsB,MAAM;AAC5D;AAEA,SAAS,iBAAiB;CACxB,eAAe,WAAW,sBAAsB;AAClD;AAEA,SAAS,SAAS,KAAqB;CACrC,OAAO,eAAe,QAAQ,MAAM,IAAI,MAAM,OAAO,GAAG,CAAC;AAC3D;AAEA,SAAS,eAAe,MAAe,WAA4B;CACjE,OAAO,OAA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ectToSignIn: options.redirectToSignIn ?? vitest.vi.fn(async () => {}),
|
|
24
24
|
redirectToSignUp: options.redirectToSignUp ?? vitest.vi.fn(async () => {}),
|
|
25
|
+
redirectToOnboarding: options.redirectToOnboarding ?? vitest.vi.fn(async () => {}),
|
|
25
26
|
[___lib_hexclave_app_common_js.hexclaveAppInternalsSymbol]: {
|
|
26
27
|
sendRequest: options.sendRequest,
|
|
27
28
|
signInWithTokens: options.signInWithTokens ?? vitest.vi.fn(async () => {})
|
|
@@ -85,6 +86,7 @@ function getButton(label) {
|
|
|
85
86
|
root = null;
|
|
86
87
|
container = null;
|
|
87
88
|
vitest.vi.restoreAllMocks();
|
|
89
|
+
sessionStorage.clear();
|
|
88
90
|
window.history.replaceState({}, "", "/");
|
|
89
91
|
Reflect.set(globalThis, "IS_REACT_ACT_ENVIRONMENT", previousActEnvironment);
|
|
90
92
|
});
|
|
@@ -110,6 +112,46 @@ function getButton(label) {
|
|
|
110
112
|
}
|
|
111
113
|
`);
|
|
112
114
|
});
|
|
115
|
+
(0, vitest.it)("redirects restricted users to onboarding without completing CLI auth", async () => {
|
|
116
|
+
window.history.replaceState({}, "", "/handler/cli-auth-confirm?login_code=login-code");
|
|
117
|
+
const redirectToOnboarding = vitest.vi.fn(async (_options) => {});
|
|
118
|
+
const sendRequest = vitest.vi.fn(async (_path, _requestOptions) => new Response(null, { status: 200 }));
|
|
119
|
+
await renderWithApp(createAppTestDouble({
|
|
120
|
+
user: {
|
|
121
|
+
isRestricted: true,
|
|
122
|
+
isAnonymous: false,
|
|
123
|
+
currentSession: { getTokens: vitest.vi.fn(async () => ({ refreshToken: "restricted-refresh-token" })) }
|
|
124
|
+
},
|
|
125
|
+
sendRequest,
|
|
126
|
+
redirectToOnboarding
|
|
127
|
+
}));
|
|
128
|
+
await (0, react.act)(async () => {
|
|
129
|
+
getButton("authorize").click();
|
|
130
|
+
});
|
|
131
|
+
(0, vitest.expect)(redirectToOnboarding).toHaveBeenCalledWith({ replace: true });
|
|
132
|
+
(0, vitest.expect)(sessionStorage.getItem("hexclave-cli-auth-confirmed")).toBe("login-code");
|
|
133
|
+
(0, vitest.expect)(sendRequest).not.toHaveBeenCalled();
|
|
134
|
+
});
|
|
135
|
+
(0, vitest.it)("redirects anonymous users to sign-up without completing CLI auth", async () => {
|
|
136
|
+
window.history.replaceState({}, "", "/handler/cli-auth-confirm?login_code=login-code");
|
|
137
|
+
const redirectToSignUp = vitest.vi.fn(async (_options) => {});
|
|
138
|
+
const sendRequest = vitest.vi.fn(async (_path, _requestOptions) => new Response(null, { status: 200 }));
|
|
139
|
+
await renderWithApp(createAppTestDouble({
|
|
140
|
+
user: {
|
|
141
|
+
isRestricted: true,
|
|
142
|
+
isAnonymous: true,
|
|
143
|
+
currentSession: { getTokens: vitest.vi.fn(async () => ({ refreshToken: "anonymous-refresh-token" })) }
|
|
144
|
+
},
|
|
145
|
+
sendRequest,
|
|
146
|
+
redirectToSignUp
|
|
147
|
+
}));
|
|
148
|
+
await (0, react.act)(async () => {
|
|
149
|
+
getButton("authorize").click();
|
|
150
|
+
});
|
|
151
|
+
(0, vitest.expect)(redirectToSignUp).toHaveBeenCalledWith({ replace: true });
|
|
152
|
+
(0, vitest.expect)(sessionStorage.getItem("hexclave-cli-auth-confirmed")).toBe("login-code");
|
|
153
|
+
(0, vitest.expect)(sendRequest).not.toHaveBeenCalled();
|
|
154
|
+
});
|
|
113
155
|
(0, vitest.it)("ignores duplicate authorize clicks before React re-renders", async () => {
|
|
114
156
|
window.history.replaceState({}, "", "/handler/cli-auth-confirm?login_code=login-code");
|
|
115
157
|
const getTokens = vitest.vi.fn(async () => ({ refreshToken: "refresh-token" }));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli-auth-confirm.test.js","names":["vi","hexclaveAppInternalsSymbol","HexclaveContext"],"sources":["../../src/components-page/cli-auth-confirm.test.tsx"],"sourcesContent":["\n//===========================================\n// THIS FILE IS AUTO-GENERATED FROM TEMPLATE. DO NOT EDIT IT DIRECTLY UNLESS YOU ALSO EDIT THE CORRESPONDING FILE IN packages/template\n//===========================================\n// @vitest-environment jsdom\n\nimport { runAsynchronously } from \"@hexclave/shared/dist/utils/promises\";\nimport React, { act } from \"react\";\nimport { createRoot, type Root } from \"react-dom/client\";\nimport { afterEach, beforeEach, describe, expect, it, vi } from \"vitest\";\nimport type { StackClientApp } from \"../lib/hexclave-app/apps/interfaces/client-app\";\nimport { hexclaveAppInternalsSymbol } from \"../lib/hexclave-app/common\";\nimport { HexclaveContext } from \"../providers/hexclave-context\";\nimport { useCliAuthConfirmation } from \"./cli-auth-confirm\";\n\nconst previousActEnvironment = Reflect.get(globalThis, \"IS_REACT_ACT_ENVIRONMENT\");\n\nfunction responseJson(data: unknown, init?: ResponseInit) {\n return new Response(JSON.stringify(data), {\n status: init?.status ?? 200,\n headers: { \"Content-Type\": \"application/json\" },\n });\n}\n\nfunction createAppTestDouble(options: {\n user: unknown,\n sendRequest: (path: string, requestOptions: RequestInit) => Promise<Response>,\n signInWithTokens?: (tokens: { accessToken: string, refreshToken: string }) => Promise<void>,\n redirectToSignIn?: (options: { replace: true }) => Promise<void>,\n redirectToSignUp?: (options: { replace: true }) => Promise<void>,\n}) {\n const app = {\n useUser: () => options.user,\n redirectToSignIn: options.redirectToSignIn ?? vi.fn(async () => {}),\n redirectToSignUp: options.redirectToSignUp ?? vi.fn(async () => {}),\n [hexclaveAppInternalsSymbol]: {\n sendRequest: options.sendRequest,\n signInWithTokens: options.signInWithTokens ?? vi.fn(async () => {}),\n },\n };\n\n // This test double intentionally implements only the StackClientApp surface\n // that useCliAuthConfirmation touches.\n return app as unknown as StackClientApp<true>;\n}\n\nfunction HookProbe() {\n const cliAuth = useCliAuthConfirmation();\n return (\n <>\n <div data-testid=\"status\">{cliAuth.status}</div>\n <div data-testid=\"error\">{cliAuth.error?.message}</div>\n <button type=\"button\" onClick={() => runAsynchronously(cliAuth.authorize)}>authorize</button>\n <button onClick={cliAuth.retry}>retry</button>\n </>\n );\n}\n\nlet root: Root | null = null;\nlet container: HTMLDivElement | null = null;\n\nasync function renderWithApp(app: StackClientApp<true>) {\n container = document.createElement(\"div\");\n document.body.append(container);\n root = createRoot(container);\n await act(async () => {\n root?.render(\n <HexclaveContext.Provider value={{ app }}>\n <HookProbe />\n </HexclaveContext.Provider>\n );\n });\n}\n\nfunction getByTestId(testId: string): HTMLElement {\n const element = container?.querySelector(`[data-testid=\"${testId}\"]`);\n if (!(element instanceof HTMLElement)) {\n throw new Error(`Could not find test element ${testId}`);\n }\n return element;\n}\n\nfunction getButton(label: string): HTMLButtonElement {\n const button = [...container?.querySelectorAll(\"button\") ?? []]\n .find((element) => element.textContent === label);\n if (!(button instanceof HTMLButtonElement)) {\n throw new Error(`Could not find button ${label}`);\n }\n return button;\n}\n\ndescribe(\"useCliAuthConfirmation\", () => {\n beforeEach(() => {\n Reflect.set(globalThis, \"IS_REACT_ACT_ENVIRONMENT\", true);\n });\n\n afterEach(() => {\n act(() => {\n root?.unmount();\n });\n container?.remove();\n root = null;\n container = null;\n vi.restoreAllMocks();\n window.history.replaceState({}, \"\", \"/\");\n Reflect.set(globalThis, \"IS_REACT_ACT_ENVIRONMENT\", previousActEnvironment);\n });\n\n it(\"completes CLI auth with the current user's refresh token\", async () => {\n window.history.replaceState({}, \"\", \"/handler/cli-auth-confirm?login_code=login-code\");\n const getTokens = vi.fn(async () => ({ refreshToken: \"refresh-token\" }));\n const sendRequest = vi.fn(async (_path: string, _requestOptions: RequestInit) => new Response(null, { status: 200 }));\n const app = createAppTestDouble({\n user: { currentSession: { getTokens } },\n sendRequest,\n });\n\n await renderWithApp(app);\n await act(async () => {\n getButton(\"authorize\").click();\n });\n\n expect(getByTestId(\"status\").textContent).toBe(\"success\");\n expect(getTokens).toHaveBeenCalledOnce();\n expect(sendRequest).toHaveBeenCalledOnce();\n expect(sendRequest.mock.calls[0][0]).toBe(\"/auth/cli/complete\");\n expect(JSON.parse(String(sendRequest.mock.calls[0][1].body))).toMatchInlineSnapshot(`\n {\n \"login_code\": \"login-code\",\n \"refresh_token\": \"refresh-token\",\n }\n `);\n });\n\n it(\"ignores duplicate authorize clicks before React re-renders\", async () => {\n window.history.replaceState({}, \"\", \"/handler/cli-auth-confirm?login_code=login-code\");\n const getTokens = vi.fn(async () => ({ refreshToken: \"refresh-token\" }));\n const sendRequest = vi.fn(async (_path: string, _requestOptions: RequestInit) => new Response(null, { status: 200 }));\n const app = createAppTestDouble({\n user: { currentSession: { getTokens } },\n sendRequest,\n });\n\n await renderWithApp(app);\n await act(async () => {\n const authorizeButton = getButton(\"authorize\");\n authorizeButton.click();\n authorizeButton.click();\n });\n\n expect(sendRequest).toHaveBeenCalledOnce();\n });\n\n it(\"claims anonymous CLI sessions before redirecting to sign-up\", async () => {\n window.history.replaceState({}, \"\", \"/handler/cli-auth-confirm?login_code=login-code\");\n const signInWithTokens = vi.fn(async (_tokens: { accessToken: string, refreshToken: string }) => {});\n const redirectToSignUp = vi.fn(async (_options: { replace: true }) => {});\n const sendRequest = vi.fn(async (_path: string, _requestOptions: RequestInit) => new Response(null, { status: 200 }))\n .mockResolvedValueOnce(responseJson({ cli_session_state: \"anonymous\" }))\n .mockResolvedValueOnce(responseJson({ access_token: \"access-token\", refresh_token: \"refresh-token\" }));\n const app = createAppTestDouble({\n user: null,\n sendRequest,\n signInWithTokens,\n redirectToSignUp,\n });\n\n await renderWithApp(app);\n await act(async () => {\n getButton(\"authorize\").click();\n });\n\n expect(redirectToSignUp).toHaveBeenCalledWith({ replace: true });\n expect(signInWithTokens).toHaveBeenCalledWith({\n accessToken: \"access-token\",\n refreshToken: \"refresh-token\",\n });\n expect(sessionStorage.getItem(\"hexclave-cli-auth-confirmed\")).toBe(\"login-code\");\n expect(sendRequest.mock.calls.map(call => JSON.parse(String(call[1].body)))).toMatchInlineSnapshot(`\n [\n {\n \"login_code\": \"login-code\",\n \"mode\": \"check\",\n },\n {\n \"login_code\": \"login-code\",\n \"mode\": \"claim-anon-session\",\n },\n ]\n `);\n });\n\n it(\"reports invalid when the login code is missing\", async () => {\n window.history.replaceState({}, \"\", \"/handler/cli-auth-confirm\");\n const app = createAppTestDouble({\n user: null,\n sendRequest: vi.fn(async (_path: string, _requestOptions: RequestInit) => new Response(null, { status: 200 })),\n });\n\n await renderWithApp(app);\n\n expect(getByTestId(\"status\").textContent).toBe(\"invalid\");\n });\n});\n"],"mappings":";;;;;;;;;;;;AAeA,MAAM,yBAAyB,QAAQ,IAAI,YAAY,0BAA0B;AAEjF,SAAS,aAAa,MAAe,MAAqB;CACxD,OAAO,IAAI,SAAS,KAAK,UAAU,IAAI,GAAG;EACxC,QAAQ,MAAM,UAAU;EACxB,SAAS,EAAE,gBAAgB,mBAAmB;CAChD,CAAC;AACH;AAEA,SAAS,oBAAoB,SAM1B;CAaD,OAAO;EAXL,eAAe,QAAQ;EACvB,kBAAkB,QAAQ,oBAAoBA,OAAAA,GAAG,GAAG,YAAY,CAAC,CAAC;EAClE,kBAAkB,QAAQ,oBAAoBA,OAAAA,GAAG,GAAG,YAAY,CAAC,CAAC;GACjEC,8BAAAA,6BAA6B;GAC5B,aAAa,QAAQ;GACrB,kBAAkB,QAAQ,oBAAoBD,OAAAA,GAAG,GAAG,YAAY,CAAC,CAAC;EACpE;CAKO;AACX;AAEA,SAAS,YAAY;CACnB,MAAM,WAAA,GAAA,sBAAA,uBAAA,CAAiC;CACvC,OACE,iBAAA,GAAA,kBAAA,KAAA,CAAA,kBAAA,UAAA,EAAA,UAAA;EACE,iBAAA,GAAA,kBAAA,IAAA,CAAC,OAAD;GAAK,eAAY;aAAU,QAAQ;EAAY,CAAA;EAC/C,iBAAA,GAAA,kBAAA,IAAA,CAAC,OAAD;GAAK,eAAY;aAAS,QAAQ,OAAO;EAAa,CAAA;EACtD,iBAAA,GAAA,kBAAA,IAAA,CAAC,UAAD;GAAQ,MAAK;GAAS,gBAAA,GAAA,qCAAA,kBAAA,CAAiC,QAAQ,SAAS;aAAG;EAAiB,CAAA;EAC5F,iBAAA,G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AC/E,CAAA,GAAA,OAAA,OAAA,CAAO,YAAY,KAAK,MAAM,KAAI,SAAQ,KAAK,MAAM,OAAO,KAAK,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,sBAAsB;;;;;;;;;;;KAWlG;CACH,CAAC;CAED,CAAA,GAAA,OAAA,GAAA,CAAG,kDAAkD,YAAY;EAC/D,OAAO,QAAQ,aAAa,CAAC,GAAG,IAAI,2BAA2B;EAM/D,MAAM,cALM,oBAAoB;GAC9B,MAAM;GACN,aAAaA,OAAAA,GAAG,GAAG,OAAO,OAAe,oBAAiC,IAAI,SAAS,MAAM,EAAE,QAAQ,IAAI,CAAC,CAAC;EAC/G,CAEsB,CAAC;EAEvB,CAAA,GAAA,OAAA,OAAA,CAAO,YAAY,QAAQ,CAAC,CAAC,WAAW,CAAC,CAAC,KAAK,SAAS;CAC1D,CAAC;AACH,CAAC"}
|
|
1
|
+
{"version":3,"file":"cli-auth-confirm.test.js","names":["vi","hexclaveAppInternalsSymbol","HexclaveContext"],"sources":["../../src/components-page/cli-auth-confirm.test.tsx"],"sourcesContent":["\n//===========================================\n// THIS FILE IS AUTO-GENERATED FROM TEMPLATE. DO NOT EDIT IT DIRECTLY UNLESS YOU ALSO EDIT THE CORRESPONDING FILE IN packages/template\n//===========================================\n// @vitest-environment jsdom\n\nimport { runAsynchronously } from \"@hexclave/shared/dist/utils/promises\";\nimport React, { act } from \"react\";\nimport { createRoot, type Root } from \"react-dom/client\";\nimport { afterEach, beforeEach, describe, expect, it, vi } from \"vitest\";\nimport type { StackClientApp } from \"../lib/hexclave-app/apps/interfaces/client-app\";\nimport { hexclaveAppInternalsSymbol } from \"../lib/hexclave-app/common\";\nimport { HexclaveContext } from \"../providers/hexclave-context\";\nimport { useCliAuthConfirmation } from \"./cli-auth-confirm\";\n\nconst previousActEnvironment = Reflect.get(globalThis, \"IS_REACT_ACT_ENVIRONMENT\");\n\nfunction responseJson(data: unknown, init?: ResponseInit) {\n return new Response(JSON.stringify(data), {\n status: init?.status ?? 200,\n headers: { \"Content-Type\": \"application/json\" },\n });\n}\n\nfunction createAppTestDouble(options: {\n user: unknown,\n sendRequest: (path: string, requestOptions: RequestInit) => Promise<Response>,\n signInWithTokens?: (tokens: { accessToken: string, refreshToken: string }) => Promise<void>,\n redirectToSignIn?: (options: { replace: true }) => Promise<void>,\n redirectToSignUp?: (options: { replace: true }) => Promise<void>,\n redirectToOnboarding?: (options: { replace: true }) => Promise<void>,\n}) {\n const app = {\n useUser: () => options.user,\n redirectToSignIn: options.redirectToSignIn ?? vi.fn(async () => {}),\n redirectToSignUp: options.redirectToSignUp ?? vi.fn(async () => {}),\n redirectToOnboarding: options.redirectToOnboarding ?? vi.fn(async () => {}),\n [hexclaveAppInternalsSymbol]: {\n sendRequest: options.sendRequest,\n signInWithTokens: options.signInWithTokens ?? vi.fn(async () => {}),\n },\n };\n\n // This test double intentionally implements only the StackClientApp surface\n // that useCliAuthConfirmation touches.\n return app as unknown as StackClientApp<true>;\n}\n\nfunction HookProbe() {\n const cliAuth = useCliAuthConfirmation();\n return (\n <>\n <div data-testid=\"status\">{cliAuth.status}</div>\n <div data-testid=\"error\">{cliAuth.error?.message}</div>\n <button type=\"button\" onClick={() => runAsynchronously(cliAuth.authorize)}>authorize</button>\n <button onClick={cliAuth.retry}>retry</button>\n </>\n );\n}\n\nlet root: Root | null = null;\nlet container: HTMLDivElement | null = null;\n\nasync function renderWithApp(app: StackClientApp<true>) {\n container = document.createElement(\"div\");\n document.body.append(container);\n root = createRoot(container);\n await act(async () => {\n root?.render(\n <HexclaveContext.Provider value={{ app }}>\n <HookProbe />\n </HexclaveContext.Provider>\n );\n });\n}\n\nfunction getByTestId(testId: string): HTMLElement {\n const element = container?.querySelector(`[data-testid=\"${testId}\"]`);\n if (!(element instanceof HTMLElement)) {\n throw new Error(`Could not find test element ${testId}`);\n }\n return element;\n}\n\nfunction getButton(label: string): HTMLButtonElement {\n const button = [...container?.querySelectorAll(\"button\") ?? []]\n .find((element) => element.textContent === label);\n if (!(button instanceof HTMLButtonElement)) {\n throw new Error(`Could not find button ${label}`);\n }\n return button;\n}\n\ndescribe(\"useCliAuthConfirmation\", () => {\n beforeEach(() => {\n Reflect.set(globalThis, \"IS_REACT_ACT_ENVIRONMENT\", true);\n });\n\n afterEach(() => {\n act(() => {\n root?.unmount();\n });\n container?.remove();\n root = null;\n container = null;\n vi.restoreAllMocks();\n sessionStorage.clear();\n window.history.replaceState({}, \"\", \"/\");\n Reflect.set(globalThis, \"IS_REACT_ACT_ENVIRONMENT\", previousActEnvironment);\n });\n\n it(\"completes CLI auth with the current user's refresh token\", async () => {\n window.history.replaceState({}, \"\", \"/handler/cli-auth-confirm?login_code=login-code\");\n const getTokens = vi.fn(async () => ({ refreshToken: \"refresh-token\" }));\n const sendRequest = vi.fn(async (_path: string, _requestOptions: RequestInit) => new Response(null, { status: 200 }));\n const app = createAppTestDouble({\n user: { currentSession: { getTokens } },\n sendRequest,\n });\n\n await renderWithApp(app);\n await act(async () => {\n getButton(\"authorize\").click();\n });\n\n expect(getByTestId(\"status\").textContent).toBe(\"success\");\n expect(getTokens).toHaveBeenCalledOnce();\n expect(sendRequest).toHaveBeenCalledOnce();\n expect(sendRequest.mock.calls[0][0]).toBe(\"/auth/cli/complete\");\n expect(JSON.parse(String(sendRequest.mock.calls[0][1].body))).toMatchInlineSnapshot(`\n {\n \"login_code\": \"login-code\",\n \"refresh_token\": \"refresh-token\",\n }\n `);\n });\n\n it(\"redirects restricted users to onboarding without completing CLI auth\", async () => {\n window.history.replaceState({}, \"\", \"/handler/cli-auth-confirm?login_code=login-code\");\n const redirectToOnboarding = vi.fn(async (_options: { replace: true }) => {});\n const sendRequest = vi.fn(async (_path: string, _requestOptions: RequestInit) => new Response(null, { status: 200 }));\n const app = createAppTestDouble({\n user: {\n isRestricted: true,\n isAnonymous: false,\n currentSession: {\n getTokens: vi.fn(async () => ({ refreshToken: \"restricted-refresh-token\" })),\n },\n },\n sendRequest,\n redirectToOnboarding,\n });\n\n await renderWithApp(app);\n await act(async () => {\n getButton(\"authorize\").click();\n });\n\n expect(redirectToOnboarding).toHaveBeenCalledWith({ replace: true });\n expect(sessionStorage.getItem(\"hexclave-cli-auth-confirmed\")).toBe(\"login-code\");\n expect(sendRequest).not.toHaveBeenCalled();\n });\n\n it(\"redirects anonymous users to sign-up without completing CLI auth\", async () => {\n window.history.replaceState({}, \"\", \"/handler/cli-auth-confirm?login_code=login-code\");\n const redirectToSignUp = vi.fn(async (_options: { replace: true }) => {});\n const sendRequest = vi.fn(async (_path: string, _requestOptions: RequestInit) => new Response(null, { status: 200 }));\n const app = createAppTestDouble({\n user: {\n isRestricted: true,\n isAnonymous: true,\n currentSession: {\n getTokens: vi.fn(async () => ({ refreshToken: \"anonymous-refresh-token\" })),\n },\n },\n sendRequest,\n redirectToSignUp,\n });\n\n await renderWithApp(app);\n await act(async () => {\n getButton(\"authorize\").click();\n });\n\n expect(redirectToSignUp).toHaveBeenCalledWith({ replace: true });\n expect(sessionStorage.getItem(\"hexclave-cli-auth-confirmed\")).toBe(\"login-code\");\n expect(sendRequest).not.toHaveBeenCalled();\n });\n\n it(\"ignores duplicate authorize clicks before React re-renders\", async () => {\n window.history.replaceState({}, \"\", \"/handler/cli-auth-confirm?login_code=login-code\");\n const getTokens = vi.fn(async () => ({ refreshToken: \"refresh-token\" }));\n const sendRequest = vi.fn(async (_path: string, _requestOptions: RequestInit) => new Response(null, { status: 200 }));\n const app = createAppTestDouble({\n user: { currentSession: { getTokens } },\n sendRequest,\n });\n\n await renderWithApp(app);\n await act(async () => {\n const authorizeButton = getButton(\"authorize\");\n authorizeButton.click();\n authorizeButton.click();\n });\n\n expect(sendRequest).toHaveBeenCalledOnce();\n });\n\n it(\"claims anonymous CLI sessions before redirecting to sign-up\", async () => {\n window.history.replaceState({}, \"\", \"/handler/cli-auth-confirm?login_code=login-code\");\n const signInWithTokens = vi.fn(async (_tokens: { accessToken: string, refreshToken: string }) => {});\n const redirectToSignUp = vi.fn(async (_options: { replace: true }) => {});\n const sendRequest = vi.fn(async (_path: string, _requestOptions: RequestInit) => new Response(null, { status: 200 }))\n .mockResolvedValueOnce(responseJson({ cli_session_state: \"anonymous\" }))\n .mockResolvedValueOnce(responseJson({ access_token: \"access-token\", refresh_token: \"refresh-token\" }));\n const app = createAppTestDouble({\n user: null,\n sendRequest,\n signInWithTokens,\n redirectToSignUp,\n });\n\n await renderWithApp(app);\n await act(async () => {\n getButton(\"authorize\").click();\n });\n\n expect(redirectToSignUp).toHaveBeenCalledWith({ replace: true });\n expect(signInWithTokens).toHaveBeenCalledWith({\n accessToken: \"access-token\",\n refreshToken: \"refresh-token\",\n });\n expect(sessionStorage.getItem(\"hexclave-cli-auth-confirmed\")).toBe(\"login-code\");\n expect(sendRequest.mock.calls.map(call => JSON.parse(String(call[1].body)))).toMatchInlineSnapshot(`\n [\n {\n \"login_code\": \"login-code\",\n \"mode\": \"check\",\n },\n {\n \"login_code\": \"login-code\",\n \"mode\": \"claim-anon-session\",\n },\n ]\n `);\n });\n\n it(\"reports invalid when the login code is missing\", async () => {\n window.history.replaceState({}, \"\", \"/handler/cli-auth-confirm\");\n const app = createAppTestDouble({\n user: null,\n sendRequest: vi.fn(async (_path: string, _requestOptions: RequestInit) => new Response(null, { status: 200 })),\n });\n\n await renderWithApp(app);\n\n expect(getByTestId(\"status\").textContent).toBe(\"invalid\");\n });\n});\n"],"mappings":";;;;;;;;;;;;AAeA,MAAM,yBAAyB,QAAQ,IAAI,YAAY,0BAA0B;AAEjF,SAAS,aAAa,MAAe,MAAqB;CACxD,OAAO,IAAI,SAAS,KAAK,UAAU,IAAI,GAAG;EACxC,QAAQ,MAAM,UAAU;EACxB,SAAS,EAAE,gBAAgB,mBAAmB;CAChD,CAAC;AACH;AAEA,SAAS,oBAAoB,SAO1B;CAcD,OAAO;EAZL,eAAe,QAAQ;EACvB,kBAAkB,QAAQ,oBAAoBA,OAAAA,GAAG,GAAG,YAAY,CAAC,CAAC;EAClE,kBA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CAAC,CAAC,sBAAsB;;;;;;;;;;;KAWlG;CACH,CAAC;CAED,CAAA,GAAA,OAAA,GAAA,CAAG,kDAAkD,YAAY;EAC/D,OAAO,QAAQ,aAAa,CAAC,GAAG,IAAI,2BAA2B;EAM/D,MAAM,cALM,oBAAoB;GAC9B,MAAM;GACN,aAAaA,OAAAA,GAAG,GAAG,OAAO,OAAe,oBAAiC,IAAI,SAAS,MAAM,EAAE,QAAQ,IAAI,CAAC,CAAC;EAC/G,CAEsB,CAAC;EAEvB,CAAA,GAAA,OAAA,OAAA,CAAO,YAAY,QAAQ,CAAC,CAAC,WAAW,CAAC,CAAC,KAAK,SAAS;CAC1D,CAAC;AACH,CAAC"}
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
let _hexclave_shared_dist_utils_promises = require("@hexclave/shared/dist/utils/promises");
|
|
4
|
+
let _hookform_resolvers_yup = require("@hookform/resolvers/yup");
|
|
5
|
+
let _hexclave_shared_dist_schema_fields = require("@hexclave/shared/dist/schema-fields");
|
|
4
6
|
let _hexclave_ui = require("@hexclave/ui");
|
|
5
7
|
let react = require("react");
|
|
8
|
+
let react_hook_form = require("react-hook-form");
|
|
6
9
|
let ___index_js = require("../index.js");
|
|
7
|
-
let
|
|
10
|
+
let ___components_elements_form_warning_js = require("../components/elements/form-warning.js");
|
|
8
11
|
let ___lib_translations_js = require("../lib/translations.js");
|
|
9
12
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
13
|
+
let ___components_elements_maybe_full_page_js = require("../components/elements/maybe-full-page.js");
|
|
10
14
|
let ___components_link_js = require("../components/link.js");
|
|
11
15
|
let ___components_message_cards_predefined_message_card_js = require("../components/message-cards/predefined-message-card.js");
|
|
12
|
-
let _hookform_resolvers_yup = require("@hookform/resolvers/yup");
|
|
13
|
-
let _hexclave_shared_dist_schema_fields = require("@hexclave/shared/dist/schema-fields");
|
|
14
|
-
let react_hook_form = require("react-hook-form");
|
|
15
|
-
let ___components_elements_form_warning_js = require("../components/elements/form-warning.js");
|
|
16
16
|
//#region src/components-page/forgot-password.tsx
|
|
17
17
|
function ForgotPasswordForm({ onSent }) {
|
|
18
18
|
const { t } = (0, ___lib_translations_js.useTranslation)();
|
|
@@ -4,13 +4,13 @@ let _hexclave_shared_dist_utils_errors = require("@hexclave/shared/dist/utils/er
|
|
|
4
4
|
let react = require("react");
|
|
5
5
|
let ___index_js = require("../index.js");
|
|
6
6
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
7
|
+
let ___lib_hooks_js = require("../lib/hooks.js");
|
|
7
8
|
let _hexclave_shared = require("@hexclave/shared");
|
|
8
9
|
let _hexclave_shared_dist_utils_react = require("@hexclave/shared/dist/utils/react");
|
|
9
10
|
let ___components_message_cards_known_error_message_card_js = require("../components/message-cards/known-error-message-card.js");
|
|
10
11
|
let ___components_message_cards_message_card_js = require("../components/message-cards/message-card.js");
|
|
11
12
|
let ___components_message_cards_predefined_message_card_js = require("../components/message-cards/predefined-message-card.js");
|
|
12
13
|
let __cli_auth_confirm_js = require("./cli-auth-confirm.js");
|
|
13
|
-
let ___lib_hooks_js = require("../lib/hooks.js");
|
|
14
14
|
let ___lib_hexclave_app_index_js = require("../lib/hexclave-app/index.js");
|
|
15
15
|
let _hexclave_shared_dist_utils_objects = require("@hexclave/shared/dist/utils/objects");
|
|
16
16
|
let _hexclave_shared_dist_utils_urls = require("@hexclave/shared/dist/utils/urls");
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
let _hexclave_ui = require("@hexclave/ui");
|
|
4
|
-
let lucide_react = require("lucide-react");
|
|
5
4
|
let react = require("react");
|
|
6
5
|
let ___index_js = require("../index.js");
|
|
7
|
-
let
|
|
6
|
+
let ___components_elements_form_warning_js = require("../components/elements/form-warning.js");
|
|
8
7
|
let ___lib_translations_js = require("../lib/translations.js");
|
|
9
8
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
10
9
|
let _hexclave_shared = require("@hexclave/shared");
|
|
11
|
-
let
|
|
10
|
+
let lucide_react = require("lucide-react");
|
|
11
|
+
let ___components_elements_maybe_full_page_js = require("../components/elements/maybe-full-page.js");
|
|
12
12
|
//#region src/components-page/mfa.tsx
|
|
13
13
|
function MfaForm({ onSuccess, onCancel }) {
|
|
14
14
|
const hexclaveApp = (0, ___index_js.useStackApp)();
|
|
@@ -6,10 +6,10 @@ let _hexclave_shared_dist_utils_errors = require("@hexclave/shared/dist/utils/er
|
|
|
6
6
|
let _hexclave_ui = require("@hexclave/ui");
|
|
7
7
|
let react = require("react");
|
|
8
8
|
let ___index_js = require("../index.js");
|
|
9
|
-
let ___components_elements_maybe_full_page_js = require("../components/elements/maybe-full-page.js");
|
|
10
9
|
let ___lib_translations_js = require("../lib/translations.js");
|
|
11
10
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
12
11
|
let _hexclave_shared = require("@hexclave/shared");
|
|
12
|
+
let ___components_elements_maybe_full_page_js = require("../components/elements/maybe-full-page.js");
|
|
13
13
|
let ___components_link_js = require("../components/link.js");
|
|
14
14
|
let __error_page_js = require("./error-page.js");
|
|
15
15
|
//#region src/components-page/oauth-callback.tsx
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
let _hexclave_shared_dist_utils_promises = require("@hexclave/shared/dist/utils/promises");
|
|
4
|
+
let _hookform_resolvers_yup = require("@hookform/resolvers/yup");
|
|
5
|
+
let _hexclave_shared_dist_schema_fields = require("@hexclave/shared/dist/schema-fields");
|
|
4
6
|
let _hexclave_ui = require("@hexclave/ui");
|
|
5
7
|
let react = require("react");
|
|
8
|
+
let react_hook_form = require("react-hook-form");
|
|
6
9
|
let ___index_js = require("../index.js");
|
|
10
|
+
let ___components_elements_form_warning_js = require("../components/elements/form-warning.js");
|
|
7
11
|
let ___lib_translations_js = require("../lib/translations.js");
|
|
8
12
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
9
13
|
let ___components_message_cards_message_card_js = require("../components/message-cards/message-card.js");
|
|
10
|
-
let _hookform_resolvers_yup = require("@hookform/resolvers/yup");
|
|
11
|
-
let _hexclave_shared_dist_schema_fields = require("@hexclave/shared/dist/schema-fields");
|
|
12
|
-
let react_hook_form = require("react-hook-form");
|
|
13
|
-
let ___components_elements_form_warning_js = require("../components/elements/form-warning.js");
|
|
14
14
|
//#region src/components-page/onboarding.tsx
|
|
15
15
|
function Onboarding(props) {
|
|
16
16
|
const { t } = (0, ___lib_translations_js.useTranslation)();
|
|
@@ -5,24 +5,24 @@ Object.defineProperties(exports, {
|
|
|
5
5
|
});
|
|
6
6
|
const require_rolldown_runtime = require("../rolldown-runtime-D6vf50IK.js");
|
|
7
7
|
let _hexclave_shared_dist_utils_promises = require("@hexclave/shared/dist/utils/promises");
|
|
8
|
+
let _hookform_resolvers_yup = require("@hookform/resolvers/yup");
|
|
9
|
+
let _hexclave_shared_dist_schema_fields = require("@hexclave/shared/dist/schema-fields");
|
|
8
10
|
let _hexclave_ui = require("@hexclave/ui");
|
|
9
11
|
let react = require("react");
|
|
12
|
+
let react_hook_form = require("react-hook-form");
|
|
10
13
|
let ___index_js = require("../index.js");
|
|
11
|
-
let
|
|
14
|
+
let ___components_elements_form_warning_js = require("../components/elements/form-warning.js");
|
|
12
15
|
let ___lib_translations_js = require("../lib/translations.js");
|
|
13
16
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
17
|
+
let _hexclave_shared_dist_helpers_password = require("@hexclave/shared/dist/helpers/password");
|
|
18
|
+
let yup = require("yup");
|
|
19
|
+
yup = require_rolldown_runtime.__toESM(yup);
|
|
14
20
|
let _hexclave_shared = require("@hexclave/shared");
|
|
21
|
+
let ___components_elements_maybe_full_page_js = require("../components/elements/maybe-full-page.js");
|
|
15
22
|
let _hexclave_shared_dist_utils_react = require("@hexclave/shared/dist/utils/react");
|
|
16
23
|
let ___components_message_cards_message_card_js = require("../components/message-cards/message-card.js");
|
|
17
24
|
let ___components_message_cards_predefined_message_card_js = require("../components/message-cards/predefined-message-card.js");
|
|
18
|
-
let _hookform_resolvers_yup = require("@hookform/resolvers/yup");
|
|
19
|
-
let _hexclave_shared_dist_schema_fields = require("@hexclave/shared/dist/schema-fields");
|
|
20
|
-
let react_hook_form = require("react-hook-form");
|
|
21
|
-
let ___components_elements_form_warning_js = require("../components/elements/form-warning.js");
|
|
22
25
|
let _hexclave_shared_dist_utils_caches = require("@hexclave/shared/dist/utils/caches");
|
|
23
|
-
let _hexclave_shared_dist_helpers_password = require("@hexclave/shared/dist/helpers/password");
|
|
24
|
-
let yup = require("yup");
|
|
25
|
-
yup = require_rolldown_runtime.__toESM(yup);
|
|
26
26
|
//#region src/components-page/password-reset.tsx
|
|
27
27
|
function PasswordResetForm(props) {
|
|
28
28
|
const { t } = (0, ___lib_translations_js.useTranslation)();
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
let _hexclave_shared_dist_utils_promises = require("@hexclave/shared/dist/utils/promises");
|
|
4
|
+
let _hookform_resolvers_yup = require("@hookform/resolvers/yup");
|
|
5
|
+
let _hexclave_shared_dist_schema_fields = require("@hexclave/shared/dist/schema-fields");
|
|
4
6
|
let _hexclave_ui = require("@hexclave/ui");
|
|
5
7
|
let react = require("react");
|
|
8
|
+
let react_hook_form = require("react-hook-form");
|
|
6
9
|
let ___index_js = require("../index.js");
|
|
7
|
-
let
|
|
10
|
+
let ___components_elements_form_warning_js = require("../components/elements/form-warning.js");
|
|
8
11
|
let ___lib_translations_js = require("../lib/translations.js");
|
|
9
12
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
10
|
-
let
|
|
11
|
-
let _hexclave_shared_dist_schema_fields = require("@hexclave/shared/dist/schema-fields");
|
|
12
|
-
let react_hook_form = require("react-hook-form");
|
|
13
|
-
let ___components_elements_form_warning_js = require("../components/elements/form-warning.js");
|
|
13
|
+
let ___components_elements_maybe_full_page_js = require("../components/elements/maybe-full-page.js");
|
|
14
14
|
//#region src/components-page/team-creation.tsx
|
|
15
15
|
function TeamCreation(props) {
|
|
16
16
|
const { t } = (0, ___lib_translations_js.useTranslation)();
|
|
@@ -3,7 +3,7 @@ import { ApiKey, ApiKeyCreationOptions, ApiKeyType } from "../lib/hexclave-app/a
|
|
|
3
3
|
//#region src/components/api-key-dialogs.d.ts
|
|
4
4
|
declare const neverInMs: number;
|
|
5
5
|
declare const expiresInOptions: {
|
|
6
|
-
readonly [x: number]: "
|
|
6
|
+
readonly [x: number]: "1 day" | "7 days" | "30 days" | "90 days" | "1 year" | "Never";
|
|
7
7
|
};
|
|
8
8
|
/**
|
|
9
9
|
* Dialog for creating a new API key
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { runAsynchronously } from "@hexclave/shared/dist/utils/promises";
|
|
3
3
|
import { captureError } from "@hexclave/shared/dist/utils/errors";
|
|
4
|
+
import { yupResolver } from "@hookform/resolvers/yup";
|
|
5
|
+
import { yupObject, yupString } from "@hexclave/shared/dist/schema-fields";
|
|
4
6
|
import { ActionDialog, Button, CopyField, Input, Label, Typography } from "@hexclave/ui";
|
|
5
7
|
import { useState } from "react";
|
|
8
|
+
import { useForm } from "react-hook-form";
|
|
6
9
|
import { useUser } from "../index.js";
|
|
10
|
+
import { FormWarningText } from "../components/elements/form-warning.js";
|
|
7
11
|
import { useTranslation } from "../lib/translations.js";
|
|
8
12
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
9
|
-
import { yupResolver } from "@hookform/resolvers/yup";
|
|
10
|
-
import { yupObject, yupString } from "@hexclave/shared/dist/schema-fields";
|
|
11
|
-
import { useForm } from "react-hook-form";
|
|
12
|
-
import { FormWarningText } from "../components/elements/form-warning.js";
|
|
13
13
|
//#region src/components/api-key-dialogs.tsx
|
|
14
14
|
const neverInMs = 1e3 * 60 * 60 * 24 * 365 * 200;
|
|
15
15
|
const expiresInOptions = {
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { runAsynchronouslyWithAlert } from "@hexclave/shared/dist/utils/promises";
|
|
3
|
+
import { yupResolver } from "@hookform/resolvers/yup";
|
|
4
|
+
import { passwordSchema, strictEmailSchema, yupObject } from "@hexclave/shared/dist/schema-fields";
|
|
3
5
|
import { Button, Input, Label, PasswordInput } from "@hexclave/ui";
|
|
4
6
|
import { useState } from "react";
|
|
7
|
+
import { useForm } from "react-hook-form";
|
|
5
8
|
import { useStackApp } from "../index.js";
|
|
6
9
|
import { useTranslation } from "../lib/translations.js";
|
|
7
10
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
8
|
-
import { yupResolver } from "@hookform/resolvers/yup";
|
|
9
|
-
import { passwordSchema, strictEmailSchema, yupObject } from "@hexclave/shared/dist/schema-fields";
|
|
10
|
-
import { useForm } from "react-hook-form";
|
|
11
11
|
import { FormWarningText } from "./elements/form-warning.js";
|
|
12
12
|
import { StyledLink } from "./link.js";
|
|
13
13
|
//#region src/components/credential-sign-in.tsx
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { runAsynchronously, runAsynchronouslyWithAlert } from "@hexclave/shared/dist/utils/promises";
|
|
3
|
+
import { yupResolver } from "@hookform/resolvers/yup";
|
|
4
|
+
import { passwordSchema, strictEmailSchema, yupObject } from "@hexclave/shared/dist/schema-fields";
|
|
3
5
|
import { Button, Input, Label, PasswordInput } from "@hexclave/ui";
|
|
4
6
|
import { useState } from "react";
|
|
7
|
+
import { useForm } from "react-hook-form";
|
|
5
8
|
import { useTranslation } from "../lib/translations.js";
|
|
6
9
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
7
|
-
import {
|
|
8
|
-
import { yupResolver } from "@hookform/resolvers/yup";
|
|
9
|
-
import { passwordSchema, strictEmailSchema, yupObject } from "@hexclave/shared/dist/schema-fields";
|
|
10
|
-
import { useForm } from "react-hook-form";
|
|
10
|
+
import { FormWarningText } from "./elements/form-warning.js";
|
|
11
11
|
import { getPasswordError } from "@hexclave/shared/dist/helpers/password";
|
|
12
12
|
import * as yup from "yup";
|
|
13
|
-
import {
|
|
13
|
+
import { useStackApp } from "../lib/hooks.js";
|
|
14
14
|
//#region src/components/credential-sign-up.tsx
|
|
15
15
|
function CredentialSignUp(props) {
|
|
16
16
|
const { t } = useTranslation();
|