@hexclave/react 1.0.1 → 1.0.3
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/components/api-key-dialogs.js +5 -5
- 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 +1 -1
- package/dist/components/elements/user-avatar.js +1 -1
- package/dist/components/magic-link-sign-in.js +4 -4
- package/dist/components/message-cards/predefined-message-card.js +1 -1
- package/dist/components/oauth-button.d.ts.map +1 -1
- package/dist/components/oauth-button.js.map +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 +2 -2
- package/dist/components/user-button.js +1 -1
- package/dist/components-page/account-settings/active-sessions/active-sessions-page.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/mfa-section.js +1 -1
- package/dist/components-page/account-settings/email-and-auth/password-section.js +3 -3
- package/dist/components-page/account-settings/teams/team-api-keys-section.js +1 -1
- 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 +1 -1
- package/dist/components-page/cli-auth-confirm.js +1 -1
- package/dist/components-page/email-verification.js +2 -2
- package/dist/components-page/error-page.js +1 -1
- package/dist/components-page/forgot-password.js +5 -5
- package/dist/components-page/magic-link-callback.js +2 -2
- package/dist/components-page/mfa.js +3 -3
- package/dist/components-page/oauth-callback.js +3 -3
- package/dist/components-page/onboarding.js +4 -4
- package/dist/components-page/password-reset.js +9 -9
- package/dist/components-page/stack-handler-client.js +7 -3
- package/dist/components-page/stack-handler-client.js.map +1 -1
- package/dist/components-page/team-creation.js +5 -5
- package/dist/components-page/team-invitation.js +1 -1
- package/dist/dev-tool/index.js +1 -1
- package/dist/esm/components/api-key-dialogs.js +5 -5
- 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 +1 -1
- package/dist/esm/components/elements/user-avatar.js +1 -1
- package/dist/esm/components/magic-link-sign-in.js +4 -4
- package/dist/esm/components/message-cards/predefined-message-card.js +1 -1
- package/dist/esm/components/oauth-button.d.ts.map +1 -1
- package/dist/esm/components/oauth-button.js.map +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 +2 -2
- package/dist/esm/components/user-button.js +1 -1
- package/dist/esm/components-page/account-settings/active-sessions/active-sessions-page.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/mfa-section.js +1 -1
- package/dist/esm/components-page/account-settings/email-and-auth/password-section.js +3 -3
- package/dist/esm/components-page/account-settings/teams/team-api-keys-section.js +1 -1
- 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.d.ts +1 -1
- package/dist/esm/components-page/account-settings.js +3 -3
- package/dist/esm/components-page/auth-page.js +1 -1
- package/dist/esm/components-page/cli-auth-confirm.js +1 -1
- package/dist/esm/components-page/email-verification.js +2 -2
- package/dist/esm/components-page/error-page.js +1 -1
- package/dist/esm/components-page/forgot-password.js +5 -5
- package/dist/esm/components-page/magic-link-callback.js +2 -2
- package/dist/esm/components-page/mfa.js +3 -3
- package/dist/esm/components-page/oauth-callback.js +3 -3
- package/dist/esm/components-page/onboarding.js +4 -4
- package/dist/esm/components-page/password-reset.js +8 -8
- package/dist/esm/components-page/stack-handler-client.js +8 -4
- package/dist/esm/components-page/stack-handler-client.js.map +1 -1
- package/dist/esm/components-page/team-creation.js +5 -5
- package/dist/esm/components-page/team-invitation.js +1 -1
- package/dist/esm/dev-tool/index.js +1 -1
- package/dist/esm/generated/quetzal-translations.d.ts +2 -2
- package/dist/esm/lib/auth.js +1 -1
- package/dist/esm/lib/auth.test.js +1 -1
- package/dist/esm/lib/stack-app/apps/implementations/admin-app-impl.d.ts +1 -1
- package/dist/esm/lib/stack-app/apps/implementations/admin-app-impl.d.ts.map +1 -1
- package/dist/esm/lib/stack-app/apps/implementations/admin-app-impl.js +1 -1
- package/dist/esm/lib/stack-app/apps/implementations/client-app-impl.cross-domain.test.js +67 -1
- package/dist/esm/lib/stack-app/apps/implementations/client-app-impl.cross-domain.test.js.map +1 -1
- package/dist/esm/lib/stack-app/apps/implementations/client-app-impl.d.ts +2 -1
- package/dist/esm/lib/stack-app/apps/implementations/client-app-impl.d.ts.map +1 -1
- package/dist/esm/lib/stack-app/apps/implementations/client-app-impl.js +19 -3
- package/dist/esm/lib/stack-app/apps/implementations/client-app-impl.js.map +1 -1
- package/dist/esm/lib/stack-app/apps/implementations/common.js +2 -2
- package/dist/esm/lib/stack-app/apps/implementations/server-app-impl.d.ts +1 -1
- package/dist/esm/lib/stack-app/apps/implementations/server-app-impl.js +1 -1
- package/dist/esm/lib/stack-app/apps/implementations/session-replay.js +1 -1
- package/dist/esm/lib/stack-app/users/index.d.ts +1 -1
- package/dist/esm/providers/translation-provider.js +1 -1
- package/dist/generated/quetzal-translations.d.ts +2 -2
- package/dist/lib/auth.js +1 -1
- package/dist/lib/auth.test.js +1 -1
- package/dist/lib/stack-app/apps/implementations/admin-app-impl.d.ts.map +1 -1
- package/dist/lib/stack-app/apps/implementations/admin-app-impl.js +1 -1
- package/dist/lib/stack-app/apps/implementations/client-app-impl.cross-domain.test.js +66 -0
- package/dist/lib/stack-app/apps/implementations/client-app-impl.cross-domain.test.js.map +1 -1
- package/dist/lib/stack-app/apps/implementations/client-app-impl.d.ts +1 -0
- package/dist/lib/stack-app/apps/implementations/client-app-impl.d.ts.map +1 -1
- package/dist/lib/stack-app/apps/implementations/client-app-impl.js +19 -3
- package/dist/lib/stack-app/apps/implementations/client-app-impl.js.map +1 -1
- package/dist/lib/stack-app/apps/implementations/common.js +2 -2
- package/dist/lib/stack-app/apps/implementations/server-app-impl.js +1 -1
- package/dist/lib/stack-app/apps/implementations/session-replay.js +1 -1
- package/dist/providers/translation-provider.js +1 -1
- package/package.json +5 -5
|
@@ -4,9 +4,9 @@ import { Typography } from "@hexclave/ui";
|
|
|
4
4
|
import { useStackApp } from "../index.js";
|
|
5
5
|
import { useTranslation } from "../lib/translations.js";
|
|
6
6
|
import { jsx } from "react/jsx-runtime";
|
|
7
|
-
import { KnownError, KnownErrors } from "@hexclave/shared";
|
|
8
7
|
import { PredefinedMessageCard } from "../components/message-cards/predefined-message-card.js";
|
|
9
8
|
import { MessageCard as MessageCard$1 } from "../components/message-cards/message-card.js";
|
|
9
|
+
import { KnownError, KnownErrors } from "@hexclave/shared";
|
|
10
10
|
import { KnownErrorMessageCard } from "../components/message-cards/known-error-message-card.js";
|
|
11
11
|
|
|
12
12
|
//#region src/components-page/error-page.tsx
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
-
import { yupResolver } from "@hookform/resolvers/yup";
|
|
4
|
-
import { strictEmailSchema, yupObject } from "@hexclave/shared/dist/schema-fields";
|
|
5
3
|
import { runAsynchronouslyWithAlert } from "@hexclave/shared/dist/utils/promises";
|
|
6
4
|
import { Button, Input, Label, Typography, cn } from "@hexclave/ui";
|
|
7
5
|
import { useState } from "react";
|
|
8
|
-
import { useForm } from "react-hook-form";
|
|
9
6
|
import { useStackApp, useUser } from "../index.js";
|
|
10
|
-
import {
|
|
7
|
+
import { MaybeFullPage } from "../components/elements/maybe-full-page.js";
|
|
11
8
|
import { useTranslation } from "../lib/translations.js";
|
|
12
9
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
13
|
-
import { MaybeFullPage } from "../components/elements/maybe-full-page.js";
|
|
14
10
|
import { StyledLink } from "../components/link.js";
|
|
15
11
|
import { PredefinedMessageCard } from "../components/message-cards/predefined-message-card.js";
|
|
12
|
+
import { yupResolver } from "@hookform/resolvers/yup";
|
|
13
|
+
import { strictEmailSchema, yupObject } from "@hexclave/shared/dist/schema-fields";
|
|
14
|
+
import { useForm } from "react-hook-form";
|
|
15
|
+
import { FormWarningText } from "../components/elements/form-warning.js";
|
|
16
16
|
|
|
17
17
|
//#region src/components-page/forgot-password.tsx
|
|
18
18
|
function ForgotPasswordForm({ onSent }) {
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
-
import { throwErr } from "@hexclave/shared/dist/utils/errors";
|
|
4
3
|
import React from "react";
|
|
5
4
|
import { useStackApp, useUser } from "../index.js";
|
|
6
5
|
import { useTranslation } from "../lib/translations.js";
|
|
7
6
|
import { jsx } from "react/jsx-runtime";
|
|
8
|
-
import { KnownErrors } from "@hexclave/shared";
|
|
9
7
|
import { PredefinedMessageCard } from "../components/message-cards/predefined-message-card.js";
|
|
10
8
|
import { MessageCard as MessageCard$1 } from "../components/message-cards/message-card.js";
|
|
9
|
+
import { KnownErrors } from "@hexclave/shared";
|
|
10
|
+
import { throwErr } from "@hexclave/shared/dist/utils/errors";
|
|
11
11
|
import { cacheFunction } from "@hexclave/shared/dist/utils/caches";
|
|
12
12
|
|
|
13
13
|
//#region src/components-page/magic-link-callback.tsx
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
3
|
import { Button, InputOTP, InputOTPGroup, InputOTPSlot, Spinner, Typography, cn } from "@hexclave/ui";
|
|
4
|
+
import { CheckIcon } from "lucide-react";
|
|
4
5
|
import { useEffect, useMemo, useRef, useState } from "react";
|
|
5
6
|
import { useStackApp } from "../index.js";
|
|
6
|
-
import {
|
|
7
|
+
import { MaybeFullPage } from "../components/elements/maybe-full-page.js";
|
|
7
8
|
import { useTranslation } from "../lib/translations.js";
|
|
8
9
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
9
10
|
import { KnownErrors } from "@hexclave/shared";
|
|
10
|
-
import {
|
|
11
|
-
import { MaybeFullPage } from "../components/elements/maybe-full-page.js";
|
|
11
|
+
import { FormWarningText } from "../components/elements/form-warning.js";
|
|
12
12
|
|
|
13
13
|
//#region src/components-page/mfa.tsx
|
|
14
14
|
function MfaForm({ onSuccess, onCancel }) {
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
-
import { captureError } from "@hexclave/shared/dist/utils/errors";
|
|
4
3
|
import { runAsynchronously } from "@hexclave/shared/dist/utils/promises";
|
|
5
4
|
import { Spinner, cn } from "@hexclave/ui";
|
|
6
5
|
import { useEffect, useRef, useState } from "react";
|
|
7
6
|
import { useStackApp } from "../index.js";
|
|
7
|
+
import { MaybeFullPage } from "../components/elements/maybe-full-page.js";
|
|
8
8
|
import { useTranslation } from "../lib/translations.js";
|
|
9
9
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
10
|
-
import { KnownError } from "@hexclave/shared";
|
|
11
|
-
import { MaybeFullPage } from "../components/elements/maybe-full-page.js";
|
|
12
10
|
import { StyledLink } from "../components/link.js";
|
|
11
|
+
import { KnownError } from "@hexclave/shared";
|
|
12
|
+
import { captureError } from "@hexclave/shared/dist/utils/errors";
|
|
13
13
|
import { stackAppInternalsSymbol } from "../lib/stack-app/index.js";
|
|
14
14
|
|
|
15
15
|
//#region src/components-page/oauth-callback.tsx
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
-
import { yupResolver } from "@hookform/resolvers/yup";
|
|
4
|
-
import { strictEmailSchema, yupObject } from "@hexclave/shared/dist/schema-fields";
|
|
5
3
|
import { runAsynchronously, runAsynchronouslyWithAlert } from "@hexclave/shared/dist/utils/promises";
|
|
6
4
|
import { Button, Input, Typography } from "@hexclave/ui";
|
|
7
5
|
import { useState } from "react";
|
|
8
|
-
import { useForm } from "react-hook-form";
|
|
9
6
|
import { useStackApp, useUser } from "../index.js";
|
|
10
|
-
import { FormWarningText } from "../components/elements/form-warning.js";
|
|
11
7
|
import { useTranslation } from "../lib/translations.js";
|
|
12
8
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
13
9
|
import { MessageCard as MessageCard$1 } from "../components/message-cards/message-card.js";
|
|
10
|
+
import { yupResolver } from "@hookform/resolvers/yup";
|
|
11
|
+
import { strictEmailSchema, yupObject } from "@hexclave/shared/dist/schema-fields";
|
|
12
|
+
import { useForm } from "react-hook-form";
|
|
13
|
+
import { FormWarningText } from "../components/elements/form-warning.js";
|
|
14
14
|
|
|
15
15
|
//#region src/components-page/onboarding.tsx
|
|
16
16
|
function Onboarding(props) {
|
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
-
import { yupResolver } from "@hookform/resolvers/yup";
|
|
4
|
-
import { passwordSchema, yupObject, yupString } from "@hexclave/shared/dist/schema-fields";
|
|
5
3
|
import { runAsynchronouslyWithAlert } from "@hexclave/shared/dist/utils/promises";
|
|
6
4
|
import { Button, Label, PasswordInput, Typography, cn } from "@hexclave/ui";
|
|
7
5
|
import { useState } from "react";
|
|
8
|
-
import { useForm } from "react-hook-form";
|
|
9
6
|
import { useStackApp } from "../index.js";
|
|
10
|
-
import {
|
|
7
|
+
import { MaybeFullPage } from "../components/elements/maybe-full-page.js";
|
|
11
8
|
import { useTranslation } from "../lib/translations.js";
|
|
12
9
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
13
|
-
import { getPasswordError } from "@hexclave/shared/dist/helpers/password";
|
|
14
|
-
import * as yup from "yup";
|
|
15
|
-
import { KnownErrors } from "@hexclave/shared";
|
|
16
|
-
import { MaybeFullPage } from "../components/elements/maybe-full-page.js";
|
|
17
10
|
import { PredefinedMessageCard } from "../components/message-cards/predefined-message-card.js";
|
|
18
11
|
import { MessageCard as MessageCard$1 } from "../components/message-cards/message-card.js";
|
|
12
|
+
import { KnownErrors } from "@hexclave/shared";
|
|
13
|
+
import { yupResolver } from "@hookform/resolvers/yup";
|
|
14
|
+
import { passwordSchema, yupObject, yupString } from "@hexclave/shared/dist/schema-fields";
|
|
15
|
+
import { useForm } from "react-hook-form";
|
|
16
|
+
import { FormWarningText } from "../components/elements/form-warning.js";
|
|
19
17
|
import { cacheFunction } from "@hexclave/shared/dist/utils/caches";
|
|
18
|
+
import { getPasswordError } from "@hexclave/shared/dist/helpers/password";
|
|
20
19
|
import { use } from "@hexclave/shared/dist/utils/react";
|
|
20
|
+
import * as yup from "yup";
|
|
21
21
|
|
|
22
22
|
//#region src/components-page/password-reset.tsx
|
|
23
23
|
function PasswordResetForm(props) {
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
|
-
import { HexclaveAssertionError } from "@hexclave/shared/dist/utils/errors";
|
|
4
3
|
import { runAsynchronouslyWithAlert } from "@hexclave/shared/dist/utils/promises";
|
|
5
|
-
import { useEffect, useMemo, useRef } from "react";
|
|
4
|
+
import { useEffect, useMemo, useRef, useSyncExternalStore } from "react";
|
|
6
5
|
import { SignIn, SignUp } from "../index.js";
|
|
7
6
|
import { jsx } from "react/jsx-runtime";
|
|
8
|
-
import { useStackApp as useStackApp$1 } from "../lib/hooks.js";
|
|
9
7
|
import { CliAuthConfirmation } from "./cli-auth-confirm.js";
|
|
10
8
|
import { MessageCard as MessageCard$1 } from "../components/message-cards/message-card.js";
|
|
9
|
+
import { useStackApp as useStackApp$1 } from "../lib/hooks.js";
|
|
10
|
+
import { HexclaveAssertionError } from "@hexclave/shared/dist/utils/errors";
|
|
11
11
|
import { stackAppInternalsSymbol } from "../lib/stack-app/index.js";
|
|
12
12
|
import { filterUndefined } from "@hexclave/shared/dist/utils/objects";
|
|
13
13
|
import { getRelativePart } from "@hexclave/shared/dist/utils/urls";
|
|
@@ -152,6 +152,7 @@ function renderComponent(props) {
|
|
|
152
152
|
}
|
|
153
153
|
function StackHandlerClient(props) {
|
|
154
154
|
const stackApp = useStackApp$1();
|
|
155
|
+
const clientOrigin = useClientOriginAfterHydration();
|
|
155
156
|
const navigate = stackApp.useNavigate();
|
|
156
157
|
const navigateRef = useRef(navigate);
|
|
157
158
|
navigateRef.current = navigate;
|
|
@@ -183,7 +184,7 @@ function StackHandlerClient(props) {
|
|
|
183
184
|
return !isLocalHandlerUrlTarget({
|
|
184
185
|
targetUrl: url,
|
|
185
186
|
handlerPath,
|
|
186
|
-
currentOrigin:
|
|
187
|
+
currentOrigin: clientOrigin
|
|
187
188
|
});
|
|
188
189
|
};
|
|
189
190
|
const result = renderComponent({
|
|
@@ -234,6 +235,9 @@ function filterUndefinedINU(value) {
|
|
|
234
235
|
function toAbsoluteOrRelativeRedirectTarget(url) {
|
|
235
236
|
return url.origin === "http://example.com" ? getRelativePart(url) : url.toString();
|
|
236
237
|
}
|
|
238
|
+
function useClientOriginAfterHydration() {
|
|
239
|
+
return useSyncExternalStore(() => () => {}, () => window.location.origin, () => void 0);
|
|
240
|
+
}
|
|
237
241
|
|
|
238
242
|
//#endregion
|
|
239
243
|
export { StackHandlerClient };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stack-handler-client.js","names":["useStackApp","MessageCard"],"sources":["../../../src/components-page/stack-handler-client.tsx"],"sourcesContent":["\"use client\";\n\n\n//===========================================\n// THIS FILE IS AUTO-GENERATED FROM TEMPLATE. DO NOT EDIT IT DIRECTLY, INSTEAD EDIT THE CORRESPONDING FILE IN packages/template\n//===========================================\n\nimport { HexclaveAssertionError } from \"@hexclave/shared/dist/utils/errors\";\nimport { FilterUndefined, filterUndefined } from \"@hexclave/shared/dist/utils/objects\";\nimport { runAsynchronouslyWithAlert } from \"@hexclave/shared/dist/utils/promises\";\nimport { getRelativePart } from \"@hexclave/shared/dist/utils/urls\";\nimport { useEffect, useMemo } from 'react';\nimport { useRef } from 'react';\nimport { SignIn, SignUp, StackServerApp } from \"..\";\nimport { useStackApp } from \"../lib/hooks\";\nimport { HandlerUrls, StackClientApp, stackAppInternalsSymbol } from \"../lib/stack-app\";\nimport { isLocalHandlerUrlTarget, resolveUnknownHandlerPathFallbackUrl } from \"../lib/stack-app/url-targets\";\nimport { AccountSettings } from \"./account-settings\";\nimport { CliAuthConfirmation } from \"./cli-auth-confirm\";\nimport { EmailVerification } from \"./email-verification\";\nimport { ErrorPage } from \"./error-page\";\nimport { ForgotPassword } from \"./forgot-password\";\nimport { MagicLinkCallback } from \"./magic-link-callback\";\nimport { MFA } from \"./mfa\";\nimport { OAuthCallback } from \"./oauth-callback\";\nimport { Onboarding } from \"./onboarding\";\nimport { PasswordReset } from \"./password-reset\";\nimport { SignOut } from \"./sign-out\";\nimport { TeamInvitation } from \"./team-invitation\";\n\nimport { MessageCard } from \"../components/message-cards/message-card\";\n\ntype Components = {\n SignIn: typeof SignIn,\n SignUp: typeof SignUp,\n EmailVerification: typeof EmailVerification,\n PasswordReset: typeof PasswordReset,\n ForgotPassword: typeof ForgotPassword,\n SignOut: typeof SignOut,\n OAuthCallback: typeof OAuthCallback,\n MagicLinkCallback: typeof MagicLinkCallback,\n TeamInvitation: typeof TeamInvitation,\n ErrorPage: typeof ErrorPage,\n AccountSettings: typeof AccountSettings,\n CliAuthConfirmation: typeof CliAuthConfirmation,\n MFA: typeof MFA,\n Onboarding: typeof Onboarding,\n};\n\ntype RouteProps = {\n params: Promise<{ stack?: string[] }> | { stack?: string[] },\n searchParams: Promise<Record<string, string>> | Record<string, string>,\n};\n\nconst availablePaths = {\n signIn: 'sign-in',\n signUp: 'sign-up',\n emailVerification: 'email-verification',\n passwordReset: 'password-reset',\n forgotPassword: 'forgot-password',\n signOut: 'sign-out',\n oauthCallback: 'oauth-callback',\n magicLinkCallback: 'magic-link-callback',\n teamInvitation: 'team-invitation',\n accountSettings: 'account-settings',\n cliAuthConfirm: 'cli-auth-confirm',\n mfa: 'mfa',\n error: 'error',\n onboarding: 'onboarding',\n} as const;\n\nconst placeholderOrigin = \"http://example.com\";\n\nconst pathAliases = {\n // also includes the uppercase and non-dashed versions\n ...Object.fromEntries(Object.entries(availablePaths).map(([key, value]) => [value, value])),\n \"log-in\": availablePaths.signIn,\n \"register\": availablePaths.signUp,\n} as const;\n\nexport type BaseHandlerProps = {\n fullPage: boolean,\n componentProps?: {\n [K in keyof Components]?: Parameters<Components[K]>[0];\n },\n};\n\nfunction renderComponent(props: {\n path: string,\n searchParams: Record<string, string>,\n fullPage: boolean,\n componentProps?: BaseHandlerProps['componentProps'],\n shouldRedirectToPage?: (name: keyof HandlerUrls) => boolean,\n getDefaultUnknownPathUrl?: (path: string) => string | null,\n onNotFound: () => any,\n app: StackClientApp<any> | StackServerApp<any>,\n}) {\n const { path, searchParams, fullPage, componentProps, shouldRedirectToPage, getDefaultUnknownPathUrl, onNotFound, app } = props;\n\n switch (path) {\n case availablePaths.signIn: {\n if (shouldRedirectToPage?.('signIn')) return { redirectToPage: 'signIn' as const };\n return <SignIn\n fullPage={fullPage}\n automaticRedirect\n {...filterUndefinedINU(componentProps?.SignIn)}\n />;\n }\n case availablePaths.signUp: {\n if (shouldRedirectToPage?.('signUp')) return { redirectToPage: 'signUp' as const };\n return <SignUp\n fullPage={fullPage}\n automaticRedirect\n {...filterUndefinedINU(componentProps?.SignUp)}\n />;\n }\n case availablePaths.emailVerification: {\n if (shouldRedirectToPage?.('emailVerification')) return { redirectToPage: 'emailVerification' as const };\n return <EmailVerification\n searchParams={searchParams}\n fullPage={fullPage}\n {...filterUndefinedINU(componentProps?.EmailVerification)}\n />;\n }\n case availablePaths.passwordReset: {\n if (shouldRedirectToPage?.('passwordReset')) return { redirectToPage: 'passwordReset' as const };\n return <PasswordReset\n searchParams={searchParams}\n fullPage={fullPage}\n {...filterUndefinedINU(componentProps?.PasswordReset)}\n />;\n }\n case availablePaths.forgotPassword: {\n if (shouldRedirectToPage?.('forgotPassword')) return { redirectToPage: 'forgotPassword' as const };\n return <ForgotPassword\n fullPage={fullPage}\n {...filterUndefinedINU(componentProps?.ForgotPassword)}\n />;\n }\n case availablePaths.signOut: {\n if (shouldRedirectToPage?.('signOut')) return { redirectToPage: 'signOut' as const };\n return <SignOut\n fullPage={fullPage}\n {...filterUndefinedINU(componentProps?.SignOut)}\n />;\n }\n case availablePaths.oauthCallback: {\n if (shouldRedirectToPage?.('oauthCallback')) return { redirectToPage: 'oauthCallback' as const };\n return <OAuthCallback\n fullPage={fullPage}\n {...filterUndefinedINU(componentProps?.OAuthCallback)}\n />;\n }\n case availablePaths.magicLinkCallback: {\n if (shouldRedirectToPage?.('magicLinkCallback')) return { redirectToPage: 'magicLinkCallback' as const };\n return <MagicLinkCallback\n searchParams={searchParams}\n fullPage={fullPage}\n {...filterUndefinedINU(componentProps?.MagicLinkCallback)}\n />;\n }\n case availablePaths.teamInvitation: {\n if (shouldRedirectToPage?.('teamInvitation')) return { redirectToPage: 'teamInvitation' as const };\n return <TeamInvitation\n searchParams={searchParams}\n fullPage={fullPage}\n {...filterUndefinedINU(componentProps?.TeamInvitation)}\n />;\n }\n case availablePaths.accountSettings: {\n return <AccountSettings\n fullPage={fullPage}\n {...filterUndefinedINU(componentProps?.AccountSettings)}\n />;\n }\n case availablePaths.error: {\n return <ErrorPage\n searchParams={searchParams}\n fullPage={fullPage}\n {...filterUndefinedINU(componentProps?.ErrorPage)}\n />;\n }\n case availablePaths.cliAuthConfirm: {\n if (shouldRedirectToPage?.('cliAuthConfirm')) return { redirectToPage: 'cliAuthConfirm' as const };\n return <CliAuthConfirmation\n fullPage={fullPage}\n {...filterUndefinedINU(componentProps?.CliAuthConfirmation)}\n />;\n }\n case availablePaths.mfa: {\n if (shouldRedirectToPage?.('mfa')) return { redirectToPage: 'mfa' as const };\n return <MFA\n fullPage={fullPage}\n {...filterUndefinedINU(componentProps?.MFA)}\n />;\n }\n case availablePaths.onboarding: {\n if (shouldRedirectToPage?.('onboarding')) return { redirectToPage: 'onboarding' as const };\n return <Onboarding\n fullPage={fullPage}\n {...filterUndefinedINU(componentProps?.Onboarding)}\n />;\n }\n default: {\n if (Object.values(availablePaths).includes(path as any)) {\n throw new HexclaveAssertionError(`Path alias ${path} not included in switch statement, but in availablePaths?`, { availablePaths });\n }\n for (const [key, value] of Object.entries(pathAliases)) {\n if (path.toLowerCase().replaceAll('-', '') === key.toLowerCase().replaceAll('-', '')) {\n const redirectUrl = `${app.urls.handler}/${value}?${new URLSearchParams(searchParams).toString()}`;\n return { redirect: redirectUrl };\n }\n }\n const defaultUnknownPathUrl = getDefaultUnknownPathUrl?.(path);\n if (defaultUnknownPathUrl != null) {\n const defaultUnknownPathUrlObject = new URL(defaultUnknownPathUrl, \"http://example.com\");\n for (const [key, value] of Object.entries(searchParams)) {\n defaultUnknownPathUrlObject.searchParams.set(key, value);\n }\n return { redirect: toAbsoluteOrRelativeRedirectTarget(defaultUnknownPathUrlObject) };\n }\n return onNotFound();\n }\n }\n}\n\nexport function StackHandlerClient(props: BaseHandlerProps & Partial<RouteProps> & { location?: string }) {\n // Use hooks to get app\n const stackApp = useStackApp();\n\n const navigate = stackApp.useNavigate();\n const navigateRef = useRef(navigate);\n navigateRef.current = navigate;\n const currentLocation = props.location ?? (typeof window === \"undefined\" ? new URL(stackApp.urls.handler, placeholderOrigin).pathname : window.location.pathname);\n const searchParamsSource = new URLSearchParams(typeof window === \"undefined\" ? \"\" : window.location.search);\n const redirectTargets: (string | undefined)[] = [];\n\n const { path, searchParams, handlerPath } = useMemo(() => {\n const handlerPath = new URL(stackApp.urls.handler, 'http://example.com').pathname;\n const relativePath = currentLocation.startsWith(handlerPath)\n ? currentLocation.slice(handlerPath.length).replace(/^\\/+/, '')\n : currentLocation.replace(/^\\/+/, '');\n\n return {\n path: relativePath,\n searchParams: Object.fromEntries(searchParamsSource.entries()),\n handlerPath,\n };\n }, [currentLocation, searchParamsSource, stackApp.urls.handler]);\n\n const getDefaultUnknownPathUrl = (unknownPath: string): string | null => {\n return resolveUnknownHandlerPathFallbackUrl({\n defaultTarget: stackApp[stackAppInternalsSymbol].getConstructorOptions().urls?.default,\n projectId: stackApp.projectId,\n unknownPath,\n });\n };\n\n const shouldRedirectToPage = (name: keyof HandlerUrls): boolean => {\n const url = stackApp.urls[name];\n const isCrossDomainLocalOauthCallback = name === \"oauthCallback\" && searchParams.hexclave_cross_domain_auth === \"1\";\n if (isCrossDomainLocalOauthCallback) {\n return false;\n }\n return !isLocalHandlerUrlTarget({\n targetUrl: url,\n handlerPath,\n currentOrigin: typeof window === \"undefined\" ? undefined : window.location.origin,\n });\n };\n\n const result = renderComponent({\n path,\n searchParams,\n fullPage: props.fullPage,\n componentProps: props.componentProps,\n shouldRedirectToPage,\n getDefaultUnknownPathUrl,\n onNotFound: () =>\n (\n <MessageCard\n title=\"Page does not exist\"\n fullPage={props.fullPage}\n primaryButtonText=\"Go to Home\"\n primaryAction={() => stackApp.redirectToHome()}\n >\n The page you are looking for could not be found. Please check the URL and try again.\n </MessageCard>\n )\n ,\n app: stackApp,\n });\n\n const redirectToPage = (result != null && typeof result === 'object' && 'redirectToPage' in result) ? result.redirectToPage : undefined;\n\n useEffect(() => {\n if (redirectToPage == null) return;\n runAsynchronouslyWithAlert(\n stackApp[stackAppInternalsSymbol].redirectToHandler(redirectToPage, { replace: true })\n );\n }, [redirectToPage, stackApp]);\n\n if (redirectToPage != null) {\n return (\n <MessageCard title=\"Redirecting...\" fullPage={props.fullPage} />\n );\n }\n\n if (result && 'redirect' in result) {\n redirectTargets.push(result.redirect);\n }\n\n const redirectTarget = redirectTargets[0];\n const shouldRenderRedirectFallback = redirectTarget != null && stackApp[stackAppInternalsSymbol].getRedirectMethod() === \"none\";\n useEffect(() => {\n if (redirectTarget == null || shouldRenderRedirectFallback) {\n return;\n }\n navigateRef.current(redirectTarget);\n }, [redirectTarget, shouldRenderRedirectFallback]);\n\n if (redirectTarget != null && shouldRenderRedirectFallback) {\n return (\n <MessageCard\n title=\"Continue\"\n fullPage={props.fullPage}\n primaryButtonText=\"Continue\"\n primaryAction={() => window.location.assign(redirectTarget)}\n >\n Continue to the next page.\n </MessageCard>\n );\n }\n\n if (redirectTarget != null) {\n return null;\n }\n\n return result;\n}\n\n// filter undefined values in object. if object itself is undefined, return undefined\nfunction filterUndefinedINU<T extends {}>(value: T | undefined): FilterUndefined<T> | undefined {\n return value === undefined ? value : filterUndefined(value);\n}\n\nfunction toAbsoluteOrRelativeRedirectTarget(url: URL): string {\n return url.origin === \"http://example.com\" ? getRelativePart(url) : url.toString();\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAsDA,MAAM,iBAAiB;CACrB,QAAQ;CACR,QAAQ;CACR,mBAAmB;CACnB,eAAe;CACf,gBAAgB;CAChB,SAAS;CACT,eAAe;CACf,mBAAmB;CACnB,gBAAgB;CAChB,iBAAiB;CACjB,gBAAgB;CAChB,KAAK;CACL,OAAO;CACP,YAAY;CACb;AAED,MAAM,oBAAoB;AAE1B,MAAM,cAAc;CAElB,GAAG,OAAO,YAAY,OAAO,QAAQ,eAAe,CAAC,KAAK,CAAC,KAAK,WAAW,CAAC,OAAO,MAAM,CAAC,CAAC;CAC3F,UAAU,eAAe;CACzB,YAAY,eAAe;CAC5B;AASD,SAAS,gBAAgB,OAStB;CACD,MAAM,EAAE,MAAM,cAAc,UAAU,gBAAgB,sBAAsB,0BAA0B,YAAY,QAAQ;AAE1H,SAAQ,MAAR;EACE,KAAK,eAAe;AAClB,OAAI,uBAAuB,SAAS,CAAE,QAAO,EAAE,gBAAgB,UAAmB;AAClF,UAAO,oBAAC;IACI;IACV;IACA,GAAI,mBAAmB,gBAAgB,OAAO;KAC9C;EAEJ,KAAK,eAAe;AAClB,OAAI,uBAAuB,SAAS,CAAE,QAAO,EAAE,gBAAgB,UAAmB;AAClF,UAAO,oBAAC;IACI;IACV;IACA,GAAI,mBAAmB,gBAAgB,OAAO;KAC9C;EAEJ,KAAK,eAAe;AAClB,OAAI,uBAAuB,oBAA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,6BACE,SAAS,yBAAyB,kBAAkB,gBAAgB,EAAE,SAAS,MAAM,CAAC,CACvF;IACA,CAAC,gBAAgB,SAAS,CAAC;AAE9B,KAAI,kBAAkB,KACpB,QACE,oBAACA;EAAY,OAAM;EAAiB,UAAU,MAAM;GAAY;AAIpE,KAAI,UAAU,cAAc,OAC1B,iBAAgB,KAAK,OAAO,SAAS;CAGvC,MAAM,iBAAiB,gBAAgB;CACvC,MAAM,+BAA+B,kBAAkB,QAAQ,SAAS,yBAAyB,mBAAmB,KAAK;AACzH,iBAAgB;AACd,MAAI,kBAAkB,QAAQ,6BAC5B;AAEF,cAAY,QAAQ,eAAe;IAClC,CAAC,gBAAgB,6BAA6B,CAAC;AAElD,KAAI,kBAAkB,QAAQ,6BAC5B,QACE,oBAACA;EACC,OAAM;EACN,UAAU,MAAM;EAChB,mBAAkB;EAClB,qBAAqB,OAAO,SAAS,OAAO,eAAe;YAC5D;GAEa;AAIlB,KAAI,kBAAkB,KACpB,QAAO;AAGT,QAAO;;AAIT,SAAS,mBAAiC,OAAsD;AAC9F,QAAO,UAAU,SAAY,QAAQ,gBAAgB,MAAM;;AAG7D,SAAS,mCAAmC,KAAkB;AAC5D,QAAO,IAAI,WAAW,uBAAuB,gBAAgB,IAAI,GAAG,IAAI,UAAU"}
|
|
1
|
+
{"version":3,"file":"stack-handler-client.js","names":["useStackApp","MessageCard"],"sources":["../../../src/components-page/stack-handler-client.tsx"],"sourcesContent":["\"use client\";\n\n\n//===========================================\n// THIS FILE IS AUTO-GENERATED FROM TEMPLATE. DO NOT EDIT IT DIRECTLY, INSTEAD EDIT THE CORRESPONDING FILE IN packages/template\n//===========================================\n\nimport { HexclaveAssertionError } from \"@hexclave/shared/dist/utils/errors\";\nimport { FilterUndefined, filterUndefined } from \"@hexclave/shared/dist/utils/objects\";\nimport { runAsynchronouslyWithAlert } from \"@hexclave/shared/dist/utils/promises\";\nimport { getRelativePart } from \"@hexclave/shared/dist/utils/urls\";\nimport { useEffect, useMemo, useSyncExternalStore } from 'react';\nimport { useRef } from 'react';\nimport { SignIn, SignUp, StackServerApp } from \"..\";\nimport { useStackApp } from \"../lib/hooks\";\nimport { HandlerUrls, StackClientApp, stackAppInternalsSymbol } from \"../lib/stack-app\";\nimport { isLocalHandlerUrlTarget, resolveUnknownHandlerPathFallbackUrl } from \"../lib/stack-app/url-targets\";\nimport { AccountSettings } from \"./account-settings\";\nimport { CliAuthConfirmation } from \"./cli-auth-confirm\";\nimport { EmailVerification } from \"./email-verification\";\nimport { ErrorPage } from \"./error-page\";\nimport { ForgotPassword } from \"./forgot-password\";\nimport { MagicLinkCallback } from \"./magic-link-callback\";\nimport { MFA } from \"./mfa\";\nimport { OAuthCallback } from \"./oauth-callback\";\nimport { Onboarding } from \"./onboarding\";\nimport { PasswordReset } from \"./password-reset\";\nimport { SignOut } from \"./sign-out\";\nimport { TeamInvitation } from \"./team-invitation\";\n\nimport { MessageCard } from \"../components/message-cards/message-card\";\n\ntype Components = {\n SignIn: typeof SignIn,\n SignUp: typeof SignUp,\n EmailVerification: typeof EmailVerification,\n PasswordReset: typeof PasswordReset,\n ForgotPassword: typeof ForgotPassword,\n SignOut: typeof SignOut,\n OAuthCallback: typeof OAuthCallback,\n MagicLinkCallback: typeof MagicLinkCallback,\n TeamInvitation: typeof TeamInvitation,\n ErrorPage: typeof ErrorPage,\n AccountSettings: typeof AccountSettings,\n CliAuthConfirmation: typeof CliAuthConfirmation,\n MFA: typeof MFA,\n Onboarding: typeof Onboarding,\n};\n\ntype RouteProps = {\n params: Promise<{ stack?: string[] }> | { stack?: string[] },\n searchParams: Promise<Record<string, string>> | Record<string, string>,\n};\n\nconst availablePaths = {\n signIn: 'sign-in',\n signUp: 'sign-up',\n emailVerification: 'email-verification',\n passwordReset: 'password-reset',\n forgotPassword: 'forgot-password',\n signOut: 'sign-out',\n oauthCallback: 'oauth-callback',\n magicLinkCallback: 'magic-link-callback',\n teamInvitation: 'team-invitation',\n accountSettings: 'account-settings',\n cliAuthConfirm: 'cli-auth-confirm',\n mfa: 'mfa',\n error: 'error',\n onboarding: 'onboarding',\n} as const;\n\nconst placeholderOrigin = \"http://example.com\";\n\nconst pathAliases = {\n // also includes the uppercase and non-dashed versions\n ...Object.fromEntries(Object.entries(availablePaths).map(([key, value]) => [value, value])),\n \"log-in\": availablePaths.signIn,\n \"register\": availablePaths.signUp,\n} as const;\n\nexport type BaseHandlerProps = {\n fullPage: boolean,\n componentProps?: {\n [K in keyof Components]?: Parameters<Components[K]>[0];\n },\n};\n\nfunction renderComponent(props: {\n path: string,\n searchParams: Record<string, string>,\n fullPage: boolean,\n componentProps?: BaseHandlerProps['componentProps'],\n shouldRedirectToPage?: (name: keyof HandlerUrls) => boolean,\n getDefaultUnknownPathUrl?: (path: string) => string | null,\n onNotFound: () => any,\n app: StackClientApp<any> | StackServerApp<any>,\n}) {\n const { path, searchParams, fullPage, componentProps, shouldRedirectToPage, getDefaultUnknownPathUrl, onNotFound, app } = props;\n\n switch (path) {\n case availablePaths.signIn: {\n if (shouldRedirectToPage?.('signIn')) return { redirectToPage: 'signIn' as const };\n return <SignIn\n fullPage={fullPage}\n automaticRedirect\n {...filterUndefinedINU(componentProps?.SignIn)}\n />;\n }\n case availablePaths.signUp: {\n if (shouldRedirectToPage?.('signUp')) return { redirectToPage: 'signUp' as const };\n return <SignUp\n fullPage={fullPage}\n automaticRedirect\n {...filterUndefinedINU(componentProps?.SignUp)}\n />;\n }\n case availablePaths.emailVerification: {\n if (shouldRedirectToPage?.('emailVerification')) return { redirectToPage: 'emailVerification' as const };\n return <EmailVerification\n searchParams={searchParams}\n fullPage={fullPage}\n {...filterUndefinedINU(componentProps?.EmailVerification)}\n />;\n }\n case availablePaths.passwordReset: {\n if (shouldRedirectToPage?.('passwordReset')) return { redirectToPage: 'passwordReset' as const };\n return <PasswordReset\n searchParams={searchParams}\n fullPage={fullPage}\n {...filterUndefinedINU(componentProps?.PasswordReset)}\n />;\n }\n case availablePaths.forgotPassword: {\n if (shouldRedirectToPage?.('forgotPassword')) return { redirectToPage: 'forgotPassword' as const };\n return <ForgotPassword\n fullPage={fullPage}\n {...filterUndefinedINU(componentProps?.ForgotPassword)}\n />;\n }\n case availablePaths.signOut: {\n if (shouldRedirectToPage?.('signOut')) return { redirectToPage: 'signOut' as const };\n return <SignOut\n fullPage={fullPage}\n {...filterUndefinedINU(componentProps?.SignOut)}\n />;\n }\n case availablePaths.oauthCallback: {\n if (shouldRedirectToPage?.('oauthCallback')) return { redirectToPage: 'oauthCallback' as const };\n return <OAuthCallback\n fullPage={fullPage}\n {...filterUndefinedINU(componentProps?.OAuthCallback)}\n />;\n }\n case availablePaths.magicLinkCallback: {\n if (shouldRedirectToPage?.('magicLinkCallback')) return { redirectToPage: 'magicLinkCallback' as const };\n return <MagicLinkCallback\n searchParams={searchParams}\n fullPage={fullPage}\n {...filterUndefinedINU(componentProps?.MagicLinkCallback)}\n />;\n }\n case availablePaths.teamInvitation: {\n if (shouldRedirectToPage?.('teamInvitation')) return { redirectToPage: 'teamInvitation' as const };\n return <TeamInvitation\n searchParams={searchParams}\n fullPage={fullPage}\n {...filterUndefinedINU(componentProps?.TeamInvitation)}\n />;\n }\n case availablePaths.accountSettings: {\n return <AccountSettings\n fullPage={fullPage}\n {...filterUndefinedINU(componentProps?.AccountSettings)}\n />;\n }\n case availablePaths.error: {\n return <ErrorPage\n searchParams={searchParams}\n fullPage={fullPage}\n {...filterUndefinedINU(componentProps?.ErrorPage)}\n />;\n }\n case availablePaths.cliAuthConfirm: {\n if (shouldRedirectToPage?.('cliAuthConfirm')) return { redirectToPage: 'cliAuthConfirm' as const };\n return <CliAuthConfirmation\n fullPage={fullPage}\n {...filterUndefinedINU(componentProps?.CliAuthConfirmation)}\n />;\n }\n case availablePaths.mfa: {\n if (shouldRedirectToPage?.('mfa')) return { redirectToPage: 'mfa' as const };\n return <MFA\n fullPage={fullPage}\n {...filterUndefinedINU(componentProps?.MFA)}\n />;\n }\n case availablePaths.onboarding: {\n if (shouldRedirectToPage?.('onboarding')) return { redirectToPage: 'onboarding' as const };\n return <Onboarding\n fullPage={fullPage}\n {...filterUndefinedINU(componentProps?.Onboarding)}\n />;\n }\n default: {\n if (Object.values(availablePaths).includes(path as any)) {\n throw new HexclaveAssertionError(`Path alias ${path} not included in switch statement, but in availablePaths?`, { availablePaths });\n }\n for (const [key, value] of Object.entries(pathAliases)) {\n if (path.toLowerCase().replaceAll('-', '') === key.toLowerCase().replaceAll('-', '')) {\n const redirectUrl = `${app.urls.handler}/${value}?${new URLSearchParams(searchParams).toString()}`;\n return { redirect: redirectUrl };\n }\n }\n const defaultUnknownPathUrl = getDefaultUnknownPathUrl?.(path);\n if (defaultUnknownPathUrl != null) {\n const defaultUnknownPathUrlObject = new URL(defaultUnknownPathUrl, \"http://example.com\");\n for (const [key, value] of Object.entries(searchParams)) {\n defaultUnknownPathUrlObject.searchParams.set(key, value);\n }\n return { redirect: toAbsoluteOrRelativeRedirectTarget(defaultUnknownPathUrlObject) };\n }\n return onNotFound();\n }\n }\n}\n\nexport function StackHandlerClient(props: BaseHandlerProps & Partial<RouteProps> & { location?: string }) {\n // Use hooks to get app\n const stackApp = useStackApp();\n const clientOrigin = useClientOriginAfterHydration();\n\n const navigate = stackApp.useNavigate();\n const navigateRef = useRef(navigate);\n navigateRef.current = navigate;\n const currentLocation = props.location ?? (typeof window === \"undefined\" ? new URL(stackApp.urls.handler, placeholderOrigin).pathname : window.location.pathname);\n const searchParamsSource = new URLSearchParams(typeof window === \"undefined\" ? \"\" : window.location.search);\n const redirectTargets: (string | undefined)[] = [];\n\n const { path, searchParams, handlerPath } = useMemo(() => {\n const handlerPath = new URL(stackApp.urls.handler, 'http://example.com').pathname;\n const relativePath = currentLocation.startsWith(handlerPath)\n ? currentLocation.slice(handlerPath.length).replace(/^\\/+/, '')\n : currentLocation.replace(/^\\/+/, '');\n\n return {\n path: relativePath,\n searchParams: Object.fromEntries(searchParamsSource.entries()),\n handlerPath,\n };\n }, [currentLocation, searchParamsSource, stackApp.urls.handler]);\n\n const getDefaultUnknownPathUrl = (unknownPath: string): string | null => {\n return resolveUnknownHandlerPathFallbackUrl({\n defaultTarget: stackApp[stackAppInternalsSymbol].getConstructorOptions().urls?.default,\n projectId: stackApp.projectId,\n unknownPath,\n });\n };\n\n const shouldRedirectToPage = (name: keyof HandlerUrls): boolean => {\n const url = stackApp.urls[name];\n const isCrossDomainLocalOauthCallback = name === \"oauthCallback\" && searchParams.hexclave_cross_domain_auth === \"1\";\n if (isCrossDomainLocalOauthCallback) {\n return false;\n }\n return !isLocalHandlerUrlTarget({\n targetUrl: url,\n handlerPath,\n currentOrigin: clientOrigin,\n });\n };\n\n const result = renderComponent({\n path,\n searchParams,\n fullPage: props.fullPage,\n componentProps: props.componentProps,\n shouldRedirectToPage,\n getDefaultUnknownPathUrl,\n onNotFound: () =>\n (\n <MessageCard\n title=\"Page does not exist\"\n fullPage={props.fullPage}\n primaryButtonText=\"Go to Home\"\n primaryAction={() => stackApp.redirectToHome()}\n >\n The page you are looking for could not be found. Please check the URL and try again.\n </MessageCard>\n )\n ,\n app: stackApp,\n });\n\n const redirectToPage = (result != null && typeof result === 'object' && 'redirectToPage' in result) ? result.redirectToPage : undefined;\n\n useEffect(() => {\n if (redirectToPage == null) return;\n runAsynchronouslyWithAlert(\n stackApp[stackAppInternalsSymbol].redirectToHandler(redirectToPage, { replace: true })\n );\n }, [redirectToPage, stackApp]);\n\n if (redirectToPage != null) {\n return (\n <MessageCard title=\"Redirecting...\" fullPage={props.fullPage} />\n );\n }\n\n if (result && 'redirect' in result) {\n redirectTargets.push(result.redirect);\n }\n\n const redirectTarget = redirectTargets[0];\n const shouldRenderRedirectFallback = redirectTarget != null && stackApp[stackAppInternalsSymbol].getRedirectMethod() === \"none\";\n useEffect(() => {\n if (redirectTarget == null || shouldRenderRedirectFallback) {\n return;\n }\n navigateRef.current(redirectTarget);\n }, [redirectTarget, shouldRenderRedirectFallback]);\n\n if (redirectTarget != null && shouldRenderRedirectFallback) {\n return (\n <MessageCard\n title=\"Continue\"\n fullPage={props.fullPage}\n primaryButtonText=\"Continue\"\n primaryAction={() => window.location.assign(redirectTarget)}\n >\n Continue to the next page.\n </MessageCard>\n );\n }\n\n if (redirectTarget != null) {\n return null;\n }\n\n return result;\n}\n\n// filter undefined values in object. if object itself is undefined, return undefined\nfunction filterUndefinedINU<T extends {}>(value: T | undefined): FilterUndefined<T> | undefined {\n return value === undefined ? value : filterUndefined(value);\n}\n\nfunction toAbsoluteOrRelativeRedirectTarget(url: URL): string {\n return url.origin === \"http://example.com\" ? getRelativePart(url) : url.toString();\n}\n\nfunction useClientOriginAfterHydration(): string | undefined {\n // The first hydrated render must match SSR. After hydration, React re-checks\n // the snapshot and lets us distinguish same-path cross-origin handler URLs.\n return useSyncExternalStore(\n () => () => {},\n () => window.location.origin,\n () => undefined,\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAsDA,MAAM,iBAAiB;CACrB,QAAQ;CACR,QAAQ;CACR,mBAAmB;CACnB,eAAe;CACf,gBAAgB;CAChB,SAAS;CACT,eAAe;CACf,mBAAmB;CACnB,gBAAgB;CAChB,iBAAiB;CACjB,gBAAgB;CAChB,KAAK;CACL,OAAO;CACP,YAAY;CACb;AAED,MAAM,oBAAoB;AAE1B,MAAM,cAAc;CAElB,GAAG,OAAO,YAAY,OAAO,QAAQ,eAAe,CAAC,KAAK,CAAC,KAAK,WAAW,CAAC,OAAO,MAAM,CAAC,CAAC;CAC3F,UAAU,eAAe;CACzB,YAAY,eAAe;CAC5B;AASD,SAAS,gBAAgB,OAStB;CACD,MAAM,EAAE,MAAM,cAAc,UAAU,gBAAgB,sBAAsB,0BAA0B,YAAY,QAAQ;AAE1H,SAAQ,MAAR;EACE,KAAK,eAAe;AAClB,OAAI,uBAAuB,SAAS,CAAE,QAAO,EAAE,gBAAgB,UAAmB;AAClF,UAAO,oBAAC;IACI;IACV;IACA,GAAI,mBAAmB,gBAAgB,OAAO;KAC9C;EAEJ,KAA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gBAAgB;aAC/C;IAEa;EAGlB,KAAK;EACN,CAAC;CAEF,MAAM,iBAAkB,UAAU,QAAQ,OAAO,WAAW,YAAY,oBAAoB,SAAU,OAAO,iBAAiB;AAE9H,iBAAgB;AACd,MAAI,kBAAkB,KAAM;AAC5B,6BACE,SAAS,yBAAyB,kBAAkB,gBAAgB,EAAE,SAAS,MAAM,CAAC,CACvF;IACA,CAAC,gBAAgB,SAAS,CAAC;AAE9B,KAAI,kBAAkB,KACpB,QACE,oBAACA;EAAY,OAAM;EAAiB,UAAU,MAAM;GAAY;AAIpE,KAAI,UAAU,cAAc,OAC1B,iBAAgB,KAAK,OAAO,SAAS;CAGvC,MAAM,iBAAiB,gBAAgB;CACvC,MAAM,+BAA+B,kBAAkB,QAAQ,SAAS,yBAAyB,mBAAmB,KAAK;AACzH,iBAAgB;AACd,MAAI,kBAAkB,QAAQ,6BAC5B;AAEF,cAAY,QAAQ,eAAe;IAClC,CAAC,gBAAgB,6BAA6B,CAAC;AAElD,KAAI,kBAAkB,QAAQ,6BAC5B,QACE,oBAACA;EACC,OAAM;EACN,UAAU,MAAM;EAChB,mBAAkB;EAClB,qBAAqB,OAAO,SAAS,OAAO,eAAe;YAC5D;GAEa;AAIlB,KAAI,kBAAkB,KACpB,QAAO;AAGT,QAAO;;AAIT,SAAS,mBAAiC,OAAsD;AAC9F,QAAO,UAAU,SAAY,QAAQ,gBAAgB,MAAM;;AAG7D,SAAS,mCAAmC,KAAkB;AAC5D,QAAO,IAAI,WAAW,uBAAuB,gBAAgB,IAAI,GAAG,IAAI,UAAU;;AAGpF,SAAS,gCAAoD;AAG3D,QAAO,iCACO,UACN,OAAO,SAAS,cAChB,OACP"}
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
-
import { yupResolver } from "@hookform/resolvers/yup";
|
|
4
|
-
import { yupObject, yupString } from "@hexclave/shared/dist/schema-fields";
|
|
5
3
|
import { runAsynchronously } from "@hexclave/shared/dist/utils/promises";
|
|
6
4
|
import { Button, Input, Label, Typography } from "@hexclave/ui";
|
|
7
5
|
import { useState } from "react";
|
|
8
|
-
import { useForm } from "react-hook-form";
|
|
9
6
|
import { MessageCard, useStackApp, useUser } from "../index.js";
|
|
10
|
-
import {
|
|
7
|
+
import { MaybeFullPage } from "../components/elements/maybe-full-page.js";
|
|
11
8
|
import { useTranslation } from "../lib/translations.js";
|
|
12
9
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
13
|
-
import {
|
|
10
|
+
import { yupResolver } from "@hookform/resolvers/yup";
|
|
11
|
+
import { yupObject, yupString } from "@hexclave/shared/dist/schema-fields";
|
|
12
|
+
import { useForm } from "react-hook-form";
|
|
13
|
+
import { FormWarningText } from "../components/elements/form-warning.js";
|
|
14
14
|
|
|
15
15
|
//#region src/components-page/team-creation.tsx
|
|
16
16
|
function TeamCreation(props) {
|
|
@@ -6,8 +6,8 @@ import React from "react";
|
|
|
6
6
|
import { MessageCard, useStackApp, useUser } from "../index.js";
|
|
7
7
|
import { useTranslation } from "../lib/translations.js";
|
|
8
8
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
9
|
-
import { KnownErrors } from "@hexclave/shared";
|
|
10
9
|
import { PredefinedMessageCard } from "../components/message-cards/predefined-message-card.js";
|
|
10
|
+
import { KnownErrors } from "@hexclave/shared";
|
|
11
11
|
import { cacheFunction } from "@hexclave/shared/dist/utils/caches";
|
|
12
12
|
import { use } from "@hexclave/shared/dist/utils/react";
|
|
13
13
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { captureError } from "@hexclave/shared/dist/utils/errors";
|
|
2
1
|
import { runAsynchronously } from "@hexclave/shared/dist/utils/promises";
|
|
2
|
+
import { captureError } from "@hexclave/shared/dist/utils/errors";
|
|
3
3
|
import { isLocalhost } from "@hexclave/shared/dist/utils/urls";
|
|
4
4
|
|
|
5
5
|
//#region src/dev-tool/index.ts
|