@stackframe/stack 2.4.6 → 2.4.8
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/card-frame.d.mts +1 -1
- package/dist/components/card-frame.d.ts +1 -1
- package/dist/components-core/index.d.mts +4 -4
- package/dist/components-core/index.d.ts +4 -4
- package/dist/components-core/loading-indicator.d.mts +4 -6
- package/dist/components-core/loading-indicator.d.ts +4 -6
- package/dist/components-core/loading-indicator.js +9 -6
- package/dist/components-core/loading-indicator.js.map +1 -1
- package/dist/components-page/oauth-callback.js +21 -6
- package/dist/components-page/oauth-callback.js.map +1 -1
- package/dist/components-page/stack-handler.js +8 -0
- package/dist/components-page/stack-handler.js.map +1 -1
- package/dist/esm/components-core/loading-indicator.js +9 -6
- package/dist/esm/components-core/loading-indicator.js.map +1 -1
- package/dist/esm/components-page/oauth-callback.js +21 -6
- package/dist/esm/components-page/oauth-callback.js.map +1 -1
- package/dist/esm/components-page/stack-handler.js +10 -2
- package/dist/esm/components-page/stack-handler.js.map +1 -1
- package/dist/esm/lib/stack-app.js +36 -18
- package/dist/esm/lib/stack-app.js.map +1 -1
- package/dist/esm/providers/stack-provider-client.js.map +1 -1
- package/dist/lib/stack-app.d.mts +9 -3
- package/dist/lib/stack-app.d.ts +9 -3
- package/dist/lib/stack-app.js +35 -17
- package/dist/lib/stack-app.js.map +1 -1
- package/dist/providers/component-provider.d.mts +6 -6
- package/dist/providers/component-provider.d.ts +6 -6
- package/dist/providers/stack-provider-client.js.map +1 -1
- package/package.json +2 -2
|
@@ -4,6 +4,6 @@ import React__default from 'react';
|
|
|
4
4
|
declare function CardFrame({ children, fullPage }: {
|
|
5
5
|
children: React__default.ReactNode;
|
|
6
6
|
fullPage?: boolean;
|
|
7
|
-
}): string | number | boolean |
|
|
7
|
+
}): string | number | boolean | Iterable<React__default.ReactNode> | Promise<React__default.AwaitedReactNode> | react_jsx_runtime.JSX.Element | null | undefined;
|
|
8
8
|
|
|
9
9
|
export { CardFrame as default };
|
|
@@ -4,6 +4,6 @@ import React__default from 'react';
|
|
|
4
4
|
declare function CardFrame({ children, fullPage }: {
|
|
5
5
|
children: React__default.ReactNode;
|
|
6
6
|
fullPage?: boolean;
|
|
7
|
-
}): string | number | boolean |
|
|
7
|
+
}): string | number | boolean | Iterable<React__default.ReactNode> | Promise<React__default.AwaitedReactNode> | react_jsx_runtime.JSX.Element | null | undefined;
|
|
8
8
|
|
|
9
9
|
export { CardFrame as default };
|
|
@@ -12,18 +12,18 @@ import React__default from 'react';
|
|
|
12
12
|
declare const Button: React__default.ForwardRefExoticComponent<Omit<Omit<ButtonProps, "ref"> & React__default.RefAttributes<HTMLButtonElement>, "ref"> & React__default.RefAttributes<HTMLButtonElement>>;
|
|
13
13
|
declare const Input: React__default.ForwardRefExoticComponent<Omit<Omit<React__default.InputHTMLAttributes<HTMLInputElement> & Pick<React__default.HTMLProps<HTMLInputElement>, "ref">, "ref"> & React__default.RefAttributes<HTMLInputElement>, "ref"> & React__default.RefAttributes<HTMLInputElement>>;
|
|
14
14
|
declare const Container: React__default.ForwardRefExoticComponent<Omit<{
|
|
15
|
-
size?: number | "
|
|
15
|
+
size?: number | "xs" | "sm" | "md" | "lg" | "xl" | undefined;
|
|
16
16
|
} & Omit<React__default.HTMLProps<HTMLDivElement>, "size">, "ref"> & React__default.RefAttributes<HTMLDivElement>>;
|
|
17
17
|
declare const Separator: React__default.ForwardRefExoticComponent<Omit<Omit<_radix_ui_react_separator.SeparatorProps & React__default.RefAttributes<HTMLDivElement>, "ref"> & React__default.RefAttributes<HTMLDivElement>, "ref"> & React__default.RefAttributes<HTMLDivElement>>;
|
|
18
18
|
declare const Label: React__default.ForwardRefExoticComponent<Omit<Omit<_radix_ui_react_label.LabelProps & React__default.RefAttributes<HTMLLabelElement>, "ref"> & React__default.RefAttributes<HTMLLabelElement>, "ref"> & React__default.RefAttributes<HTMLLabelElement>>;
|
|
19
19
|
declare const Link: React__default.ForwardRefExoticComponent<Omit<Omit<{
|
|
20
|
-
size?: "
|
|
20
|
+
size?: "xs" | "sm" | "md" | "lg" | "xl" | undefined;
|
|
21
21
|
href: string | url.Url;
|
|
22
22
|
} & Omit<React__default.HTMLProps<HTMLLinkElement>, "size" | "href">, "ref"> & React__default.RefAttributes<HTMLAnchorElement>, "ref"> & React__default.RefAttributes<HTMLAnchorElement>>;
|
|
23
23
|
declare const Text: React__default.ForwardRefExoticComponent<Omit<Omit<{
|
|
24
24
|
variant?: "primary" | "secondary" | "warning" | "success" | undefined;
|
|
25
|
-
as?: "
|
|
26
|
-
size?: "
|
|
25
|
+
as?: "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "p" | undefined;
|
|
26
|
+
size?: "xs" | "sm" | "md" | "lg" | "xl" | undefined;
|
|
27
27
|
} & Omit<React__default.HTMLProps<HTMLParagraphElement>, "size">, "ref"> & React__default.RefAttributes<HTMLParagraphElement>, "ref"> & React__default.RefAttributes<HTMLParagraphElement>>;
|
|
28
28
|
declare const Popover: React__default.ForwardRefExoticComponent<_radix_ui_react_popover.PopoverProps & React__default.RefAttributes<never>>;
|
|
29
29
|
declare const PopoverTrigger: React__default.ForwardRefExoticComponent<Omit<_radix_ui_react_popover.PopoverTriggerProps & React__default.RefAttributes<HTMLButtonElement>, "ref"> & React__default.RefAttributes<HTMLButtonElement>>;
|
|
@@ -12,18 +12,18 @@ import React__default from 'react';
|
|
|
12
12
|
declare const Button: React__default.ForwardRefExoticComponent<Omit<Omit<ButtonProps, "ref"> & React__default.RefAttributes<HTMLButtonElement>, "ref"> & React__default.RefAttributes<HTMLButtonElement>>;
|
|
13
13
|
declare const Input: React__default.ForwardRefExoticComponent<Omit<Omit<React__default.InputHTMLAttributes<HTMLInputElement> & Pick<React__default.HTMLProps<HTMLInputElement>, "ref">, "ref"> & React__default.RefAttributes<HTMLInputElement>, "ref"> & React__default.RefAttributes<HTMLInputElement>>;
|
|
14
14
|
declare const Container: React__default.ForwardRefExoticComponent<Omit<{
|
|
15
|
-
size?: number | "
|
|
15
|
+
size?: number | "xs" | "sm" | "md" | "lg" | "xl" | undefined;
|
|
16
16
|
} & Omit<React__default.HTMLProps<HTMLDivElement>, "size">, "ref"> & React__default.RefAttributes<HTMLDivElement>>;
|
|
17
17
|
declare const Separator: React__default.ForwardRefExoticComponent<Omit<Omit<_radix_ui_react_separator.SeparatorProps & React__default.RefAttributes<HTMLDivElement>, "ref"> & React__default.RefAttributes<HTMLDivElement>, "ref"> & React__default.RefAttributes<HTMLDivElement>>;
|
|
18
18
|
declare const Label: React__default.ForwardRefExoticComponent<Omit<Omit<_radix_ui_react_label.LabelProps & React__default.RefAttributes<HTMLLabelElement>, "ref"> & React__default.RefAttributes<HTMLLabelElement>, "ref"> & React__default.RefAttributes<HTMLLabelElement>>;
|
|
19
19
|
declare const Link: React__default.ForwardRefExoticComponent<Omit<Omit<{
|
|
20
|
-
size?: "
|
|
20
|
+
size?: "xs" | "sm" | "md" | "lg" | "xl" | undefined;
|
|
21
21
|
href: string | url.Url;
|
|
22
22
|
} & Omit<React__default.HTMLProps<HTMLLinkElement>, "size" | "href">, "ref"> & React__default.RefAttributes<HTMLAnchorElement>, "ref"> & React__default.RefAttributes<HTMLAnchorElement>>;
|
|
23
23
|
declare const Text: React__default.ForwardRefExoticComponent<Omit<Omit<{
|
|
24
24
|
variant?: "primary" | "secondary" | "warning" | "success" | undefined;
|
|
25
|
-
as?: "
|
|
26
|
-
size?: "
|
|
25
|
+
as?: "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "p" | undefined;
|
|
26
|
+
size?: "xs" | "sm" | "md" | "lg" | "xl" | undefined;
|
|
27
27
|
} & Omit<React__default.HTMLProps<HTMLParagraphElement>, "size">, "ref"> & React__default.RefAttributes<HTMLParagraphElement>, "ref"> & React__default.RefAttributes<HTMLParagraphElement>>;
|
|
28
28
|
declare const Popover: React__default.ForwardRefExoticComponent<_radix_ui_react_popover.PopoverProps & React__default.RefAttributes<never>>;
|
|
29
29
|
declare const PopoverTrigger: React__default.ForwardRefExoticComponent<Omit<_radix_ui_react_popover.PopoverTriggerProps & React__default.RefAttributes<HTMLButtonElement>, "ref"> & React__default.RefAttributes<HTMLButtonElement>>;
|
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
import * as
|
|
2
|
-
import * as styled_components_dist_types from 'styled-components/dist/types';
|
|
3
|
-
import * as React from 'react';
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
4
2
|
|
|
5
|
-
declare
|
|
3
|
+
declare function LoadingIndicator(props: {
|
|
4
|
+
size?: number;
|
|
6
5
|
color: {
|
|
7
6
|
light: string;
|
|
8
7
|
dark: string;
|
|
9
8
|
};
|
|
10
|
-
|
|
11
|
-
}>>;
|
|
9
|
+
}): react_jsx_runtime.JSX.Element;
|
|
12
10
|
|
|
13
11
|
export { LoadingIndicator as default };
|
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
import * as
|
|
2
|
-
import * as styled_components_dist_types from 'styled-components/dist/types';
|
|
3
|
-
import * as React from 'react';
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
4
2
|
|
|
5
|
-
declare
|
|
3
|
+
declare function LoadingIndicator(props: {
|
|
4
|
+
size?: number;
|
|
6
5
|
color: {
|
|
7
6
|
light: string;
|
|
8
7
|
dark: string;
|
|
9
8
|
};
|
|
10
|
-
|
|
11
|
-
}>>;
|
|
9
|
+
}): react_jsx_runtime.JSX.Element;
|
|
12
10
|
|
|
13
11
|
export { LoadingIndicator as default };
|
|
@@ -30,17 +30,18 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
30
30
|
// src/components-core/loading-indicator.tsx
|
|
31
31
|
var loading_indicator_exports = {};
|
|
32
32
|
__export(loading_indicator_exports, {
|
|
33
|
-
default: () =>
|
|
33
|
+
default: () => LoadingIndicator
|
|
34
34
|
});
|
|
35
35
|
module.exports = __toCommonJS(loading_indicator_exports);
|
|
36
36
|
var import_styled_components = __toESM(require("styled-components"));
|
|
37
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
37
38
|
var l7 = import_styled_components.keyframes`
|
|
38
39
|
33% { background-size: calc(100%/3) 0%, calc(100%/3) 100%, calc(100%/3) 100%; }
|
|
39
40
|
50% { background-size: calc(100%/3) 100%, calc(100%/3) 0%, calc(100%/3) 100%; }
|
|
40
41
|
66% { background-size: calc(100%/3) 100%, calc(100%/3) 100%, calc(100%/3) 0%; }
|
|
41
42
|
`;
|
|
42
|
-
var
|
|
43
|
-
width: ${(props) => props
|
|
43
|
+
var StyledLoadingIndicator = import_styled_components.default.div`
|
|
44
|
+
width: ${(props) => props.$size || 36}px;
|
|
44
45
|
aspect-ratio: 4;
|
|
45
46
|
background:
|
|
46
47
|
var(--_g) 0% 50%,
|
|
@@ -49,11 +50,13 @@ var LoadingIndicator = import_styled_components.default.div`
|
|
|
49
50
|
background-size: calc(100%/3) 100%;
|
|
50
51
|
animation: ${l7} 1s infinite linear;
|
|
51
52
|
|
|
52
|
-
--_g: no-repeat radial-gradient(circle closest-side, ${(props) => props
|
|
53
|
+
--_g: no-repeat radial-gradient(circle closest-side, ${(props) => props.$color.light} 90%, #0000);
|
|
53
54
|
|
|
54
55
|
html[data-stack-theme='dark'] & {
|
|
55
|
-
--_g: no-repeat radial-gradient(circle closest-side, ${(props) => props
|
|
56
|
+
--_g: no-repeat radial-gradient(circle closest-side, ${(props) => props.$color.dark} 90%, #0000);
|
|
56
57
|
}
|
|
57
58
|
`;
|
|
58
|
-
|
|
59
|
+
function LoadingIndicator(props) {
|
|
60
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(StyledLoadingIndicator, { $size: props.size, $color: props.color });
|
|
61
|
+
}
|
|
59
62
|
//# sourceMappingURL=loading-indicator.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/components-core/loading-indicator.tsx"],"sourcesContent":["import styled, { keyframes } from 'styled-components';\n\nconst l7 = keyframes`\n 33% { background-size: calc(100%/3) 0%, calc(100%/3) 100%, calc(100%/3) 100%; }\n 50% { background-size: calc(100%/3) 100%, calc(100%/3) 0%, calc(100%/3) 100%; }\n 66% { background-size: calc(100%/3) 100%, calc(100%/3) 100%, calc(100%/3) 0%; }\n`;\n\nconst
|
|
1
|
+
{"version":3,"sources":["../../src/components-core/loading-indicator.tsx"],"sourcesContent":["import styled, { keyframes } from 'styled-components';\n\nconst l7 = keyframes`\n 33% { background-size: calc(100%/3) 0%, calc(100%/3) 100%, calc(100%/3) 100%; }\n 50% { background-size: calc(100%/3) 100%, calc(100%/3) 0%, calc(100%/3) 100%; }\n 66% { background-size: calc(100%/3) 100%, calc(100%/3) 100%, calc(100%/3) 0%; }\n`;\n\nconst StyledLoadingIndicator = styled.div<{ $color: { light: string, dark: string }, $size?: number }>`\n width: ${props => props.$size || 36}px;\n aspect-ratio: 4;\n background: \n var(--_g) 0% 50%, \n var(--_g) 50% 50%, \n var(--_g) 100% 50%;\n background-size: calc(100%/3) 100%;\n animation: ${l7} 1s infinite linear;\n\n --_g: no-repeat radial-gradient(circle closest-side, ${props => props.$color.light} 90%, #0000);\n\n html[data-stack-theme='dark'] & {\n --_g: no-repeat radial-gradient(circle closest-side, ${props => props.$color.dark} 90%, #0000);\n }\n`;\n\nexport default function LoadingIndicator(props: { size?: number, color: { light: string, dark: string } }) {\n return <StyledLoadingIndicator $size={props.size} $color={props.color} />;\n}"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,+BAAkC;AA0BzB;AAxBT,IAAM,KAAK;AAAA;AAAA;AAAA;AAAA;AAMX,IAAM,yBAAyB,yBAAAA,QAAO;AAAA,WAC3B,WAAS,MAAM,SAAS,EAAE;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,eAOtB,EAAE;AAAA;AAAA,yDAEwC,WAAS,MAAM,OAAO,KAAK;AAAA;AAAA;AAAA,2DAGzB,WAAS,MAAM,OAAO,IAAI;AAAA;AAAA;AAItE,SAAR,iBAAkC,OAAkE;AACzG,SAAO,4CAAC,0BAAuB,OAAO,MAAM,MAAM,QAAQ,MAAM,OAAO;AACzE;","names":["styled"]}
|
|
@@ -44,20 +44,35 @@ function OAuthCallback() {
|
|
|
44
44
|
const app = (0, import__.useStackApp)();
|
|
45
45
|
const called = (0, import_react.useRef)(false);
|
|
46
46
|
const [error, setError] = (0, import_react.useState)(null);
|
|
47
|
+
const [showRedirectLink, setShowRedirectLink] = (0, import_react.useState)(false);
|
|
47
48
|
(0, import_react.useEffect)(() => (0, import_promises.runAsynchronously)(async () => {
|
|
48
49
|
if (called.current)
|
|
49
50
|
return;
|
|
50
51
|
called.current = true;
|
|
52
|
+
let hasRedirected = false;
|
|
51
53
|
try {
|
|
52
|
-
await app.callOAuthCallback();
|
|
54
|
+
hasRedirected = await app.callOAuthCallback();
|
|
53
55
|
} catch (e) {
|
|
54
56
|
setError(e);
|
|
55
57
|
}
|
|
58
|
+
if (!hasRedirected) {
|
|
59
|
+
await app.redirectToSignIn();
|
|
60
|
+
}
|
|
56
61
|
}), []);
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
+
(0, import_react.useEffect)(() => {
|
|
63
|
+
setTimeout(() => setShowRedirectLink(true), 3e3);
|
|
64
|
+
}, []);
|
|
65
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_message_card.default, { title: "Redirecting...", fullPage: true, children: [
|
|
66
|
+
showRedirectLink ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", { children: [
|
|
67
|
+
"If you are not redirected automatically, ",
|
|
68
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("a", { href: app.urls.home, children: "click here" }),
|
|
69
|
+
"."
|
|
70
|
+
] }) : null,
|
|
71
|
+
error ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [
|
|
72
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { children: "Something went wrong while processing the OAuth callback:" }),
|
|
73
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("pre", { children: JSON.stringify(error, null, 2) }),
|
|
74
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { children: "This is most likely an error in Stack. Please report it." })
|
|
75
|
+
] }) : null
|
|
76
|
+
] });
|
|
62
77
|
}
|
|
63
78
|
//# sourceMappingURL=oauth-callback.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/components-page/oauth-callback.tsx"],"sourcesContent":["'use client';\n\nimport { useRef, useEffect, useState } from \"react\";\nimport { useStackApp } from \"..\";\nimport { runAsynchronously } from \"@stackframe/stack-shared/dist/utils/promises\";\nimport MessageCard from \"../components/message-card\";\n\nexport default function OAuthCallback () {\n const app = useStackApp();\n const called = useRef(false);\n const [error, setError] = useState<unknown>(null);\n\n useEffect(() => runAsynchronously(async () => {\n if (called.current) return;\n called.current = true;\n try {\n await app.callOAuthCallback();\n } catch (e: any) {\n setError(e);\n }\n }), []);\n\n return <MessageCard title='Redirecting...' fullPage>\n {error ? <div>\n <p>Something went wrong while processing the OAuth callback:</p>\n <pre>{JSON.stringify(error, null, 2)}</pre>\n <p>This is most likely an error in Stack. Please report it.</p>\n </div> : null}\n </MessageCard>;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,mBAA4C;AAC5C,eAA4B;AAC5B,sBAAkC;AAClC,0BAAwB;
|
|
1
|
+
{"version":3,"sources":["../../src/components-page/oauth-callback.tsx"],"sourcesContent":["'use client';\n\nimport { useRef, useEffect, useState } from \"react\";\nimport { useStackApp } from \"..\";\nimport { runAsynchronously } from \"@stackframe/stack-shared/dist/utils/promises\";\nimport MessageCard from \"../components/message-card\";\n\nexport default function OAuthCallback () {\n const app = useStackApp();\n const called = useRef(false);\n const [error, setError] = useState<unknown>(null);\n const [showRedirectLink, setShowRedirectLink] = useState(false);\n\n useEffect(() => runAsynchronously(async () => {\n if (called.current) return;\n called.current = true;\n let hasRedirected = false;\n try {\n hasRedirected = await app.callOAuthCallback();\n } catch (e: any) {\n setError(e);\n }\n if (!hasRedirected) {\n await app.redirectToSignIn();\n }\n }), []);\n\n useEffect(() => {\n setTimeout(() => setShowRedirectLink(true), 3000);\n }, []);\n\n return <MessageCard title='Redirecting...' fullPage>\n {showRedirectLink ? <p>If you are not redirected automatically, <a href={app.urls.home}>click here</a>.</p> : null}\n {error ? <div>\n <p>Something went wrong while processing the OAuth callback:</p>\n <pre>{JSON.stringify(error, null, 2)}</pre>\n <p>This is most likely an error in Stack. Please report it.</p>\n </div> : null}\n </MessageCard>;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,mBAA4C;AAC5C,eAA4B;AAC5B,sBAAkC;AAClC,0BAAwB;AA2BA;AAzBT,SAAR,gBAAkC;AACvC,QAAM,UAAM,sBAAY;AACxB,QAAM,aAAS,qBAAO,KAAK;AAC3B,QAAM,CAAC,OAAO,QAAQ,QAAI,uBAAkB,IAAI;AAChD,QAAM,CAAC,kBAAkB,mBAAmB,QAAI,uBAAS,KAAK;AAE9D,8BAAU,UAAM,mCAAkB,YAAY;AAC5C,QAAI,OAAO;AAAS;AACpB,WAAO,UAAU;AACjB,QAAI,gBAAgB;AACpB,QAAI;AACF,sBAAgB,MAAM,IAAI,kBAAkB;AAAA,IAC9C,SAAS,GAAQ;AACf,eAAS,CAAC;AAAA,IACZ;AACA,QAAI,CAAC,eAAe;AAClB,YAAM,IAAI,iBAAiB;AAAA,IAC7B;AAAA,EACF,CAAC,GAAG,CAAC,CAAC;AAEN,8BAAU,MAAM;AACd,eAAW,MAAM,oBAAoB,IAAI,GAAG,GAAI;AAAA,EAClD,GAAG,CAAC,CAAC;AAEL,SAAO,6CAAC,oBAAAA,SAAA,EAAY,OAAM,kBAAiB,UAAQ,MAChD;AAAA,uBAAmB,6CAAC,OAAE;AAAA;AAAA,MAAyC,4CAAC,OAAE,MAAM,IAAI,KAAK,MAAM,wBAAU;AAAA,MAAI;AAAA,OAAC,IAAO;AAAA,IAC7G,QAAQ,6CAAC,SACR;AAAA,kDAAC,OAAE,uEAAyD;AAAA,MAC5D,4CAAC,SAAK,eAAK,UAAU,OAAO,MAAM,CAAC,GAAE;AAAA,MACrC,4CAAC,OAAE,sEAAwD;AAAA,OAC7D,IAAS;AAAA,KACX;AACF;","names":["MessageCard"]}
|
|
@@ -61,14 +61,22 @@ async function StackHandler({
|
|
|
61
61
|
}
|
|
62
62
|
(0, import_navigation.redirect)(url, import_navigation.RedirectType.replace);
|
|
63
63
|
}
|
|
64
|
+
async function redirectIfHasUser() {
|
|
65
|
+
const user = await app.getServerUser();
|
|
66
|
+
if (user) {
|
|
67
|
+
(0, import_navigation.redirect)(app.urls.afterSignIn);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
64
70
|
const path = stack.join("/");
|
|
65
71
|
switch (path) {
|
|
66
72
|
case "signin": {
|
|
67
73
|
redirectIfNotHandler("signIn");
|
|
74
|
+
await redirectIfHasUser();
|
|
68
75
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_sign_in.default, { fullPage: true });
|
|
69
76
|
}
|
|
70
77
|
case "signup": {
|
|
71
78
|
redirectIfNotHandler("signUp");
|
|
79
|
+
await redirectIfHasUser();
|
|
72
80
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_sign_up.default, { fullPage: true });
|
|
73
81
|
}
|
|
74
82
|
case "email-verification": {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/components-page/stack-handler.tsx"],"sourcesContent":["import SignUp from \"./sign-up\";\nimport SignIn from \"./sign-in\";\nimport { RedirectType, notFound, redirect } from 'next/navigation';\nimport EmailVerification from \"./email-verification\";\nimport { PasswordReset, StackServerApp } from \"..\";\nimport MessageCard from \"../components/message-card\";\nimport { HandlerUrls } from \"../lib/stack-app\";\nimport
|
|
1
|
+
{"version":3,"sources":["../../src/components-page/stack-handler.tsx"],"sourcesContent":["import SignUp from \"./sign-up\";\nimport SignIn from \"./sign-in\";\nimport { RedirectType, notFound, redirect } from 'next/navigation';\nimport EmailVerification from \"./email-verification\";\nimport { PasswordReset, StackServerApp } from \"..\";\nimport MessageCard from \"../components/message-card\";\nimport { HandlerUrls } from \"../lib/stack-app\";\nimport SignOut from \"./sign-out\";\nimport ForgotPassword from \"./forgot-password\";\nimport OAuthCallback from \"./oauth-callback\";\nimport AccountSettings from \"./account-settings\";\nimport MagicLinkCallback from \"./magic-link-callback\";\n\nexport default async function StackHandler<HasTokenStore extends boolean>({\n app,\n params: { stack } = {},\n searchParams = {},\n}: { \n app: StackServerApp<HasTokenStore>,\n params?: { stack?: string[] }, \n searchParams?: Record<string, string>,\n}) {\n if (!stack) {\n return (\n <MessageCard title=\"Invalid Stack Handler Setup\" fullPage>\n <p>Can't use Stack handler at this location. Make sure that the file is in a folder called [...stack].</p>\n </MessageCard>\n );\n }\n\n function redirectIfNotHandler(name: keyof HandlerUrls) {\n const url = app.urls[name];\n const handlerUrl = app.urls.handler;\n\n if (url.startsWith(handlerUrl)) {\n // don't redirect if the url is a handler url\n return;\n }\n\n redirect(url, RedirectType.replace);\n }\n\n async function redirectIfHasUser() {\n const user = await app.getServerUser();\n if (user) {\n redirect(app.urls.afterSignIn);\n }\n }\n\n const path = stack.join('/');\n switch (path) {\n case 'signin': {\n redirectIfNotHandler('signIn');\n await redirectIfHasUser();\n return <SignIn fullPage/>;\n }\n case 'signup': {\n redirectIfNotHandler('signUp');\n await redirectIfHasUser();\n return <SignUp fullPage/>;\n }\n case 'email-verification': {\n redirectIfNotHandler('emailVerification');\n return <EmailVerification searchParams={searchParams} fullPage/>;\n }\n case 'password-reset': {\n redirectIfNotHandler('passwordReset');\n return <PasswordReset searchParams={searchParams} fullPage />;\n }\n case 'forgot-password': {\n redirectIfNotHandler('forgotPassword');\n return <ForgotPassword fullPage />;\n }\n case 'signout': {\n redirectIfNotHandler('signOut');\n return <SignOut/>;\n }\n case 'oauth-callback': {\n redirectIfNotHandler('oauthCallback');\n return <OAuthCallback />;\n }\n case 'account-settings': {\n redirectIfNotHandler('accountSettings');\n return <AccountSettings fullPage />;\n }\n case 'magic-link-callback': {\n redirectIfNotHandler('magicLinkCallback');\n return <MagicLinkCallback searchParams={searchParams} fullPage />;\n }\n default: {\n return notFound();\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAAmB;AACnB,qBAAmB;AACnB,wBAAiD;AACjD,gCAA8B;AAC9B,eAA8C;AAC9C,0BAAwB;AAExB,sBAAoB;AACpB,6BAA2B;AAC3B,4BAA0B;AAC1B,8BAA4B;AAC5B,iCAA8B;AActB;AAZR,eAAO,aAAmE;AAAA,EACxE;AAAA,EACA,QAAQ,EAAE,MAAM,IAAI,CAAC;AAAA,EACrB,eAAe,CAAC;AAClB,GAIG;AACD,MAAI,CAAC,OAAO;AACV,WACE,4CAAC,oBAAAA,SAAA,EAAY,OAAM,+BAA8B,UAAQ,MACvD,sDAAC,OAAE,iHAAmG,GACxG;AAAA,EAEJ;AAEA,WAAS,qBAAqB,MAAyB;AACrD,UAAM,MAAM,IAAI,KAAK,IAAI;AACzB,UAAM,aAAa,IAAI,KAAK;AAE5B,QAAI,IAAI,WAAW,UAAU,GAAG;AAE9B;AAAA,IACF;AAEA,oCAAS,KAAK,+BAAa,OAAO;AAAA,EACpC;AAEA,iBAAe,oBAAoB;AACjC,UAAM,OAAO,MAAM,IAAI,cAAc;AACrC,QAAI,MAAM;AACR,sCAAS,IAAI,KAAK,WAAW;AAAA,IAC/B;AAAA,EACF;AAEA,QAAM,OAAO,MAAM,KAAK,GAAG;AAC3B,UAAQ,MAAM;AAAA,IACZ,KAAK,UAAU;AACb,2BAAqB,QAAQ;AAC7B,YAAM,kBAAkB;AACxB,aAAO,4CAAC,eAAAC,SAAA,EAAO,UAAQ;AAAA,IACzB;AAAA,IACA,KAAK,UAAU;AACb,2BAAqB,QAAQ;AAC7B,YAAM,kBAAkB;AACxB,aAAO,4CAAC,eAAAC,SAAA,EAAO,UAAQ;AAAA,IACzB;AAAA,IACA,KAAK,sBAAsB;AACzB,2BAAqB,mBAAmB;AACxC,aAAO,4CAAC,0BAAAC,SAAA,EAAkB,cAA4B,UAAQ;AAAA,IAChE;AAAA,IACA,KAAK,kBAAkB;AACrB,2BAAqB,eAAe;AACpC,aAAO,4CAAC,0BAAc,cAA4B,UAAQ,MAAC;AAAA,IAC7D;AAAA,IACA,KAAK,mBAAmB;AACtB,2BAAqB,gBAAgB;AACrC,aAAO,4CAAC,uBAAAC,SAAA,EAAe,UAAQ,MAAC;AAAA,IAClC;AAAA,IACA,KAAK,WAAW;AACd,2BAAqB,SAAS;AAC9B,aAAO,4CAAC,gBAAAC,SAAA,EAAO;AAAA,IACjB;AAAA,IACA,KAAK,kBAAkB;AACrB,2BAAqB,eAAe;AACpC,aAAO,4CAAC,sBAAAC,SAAA,EAAc;AAAA,IACxB;AAAA,IACA,KAAK,oBAAoB;AACvB,2BAAqB,iBAAiB;AACtC,aAAO,4CAAC,wBAAAC,SAAA,EAAgB,UAAQ,MAAC;AAAA,IACnC;AAAA,IACA,KAAK,uBAAuB;AAC1B,2BAAqB,mBAAmB;AACxC,aAAO,4CAAC,2BAAAC,SAAA,EAAkB,cAA4B,UAAQ,MAAC;AAAA,IACjE;AAAA,IACA,SAAS;AACP,iBAAO,4BAAS;AAAA,IAClB;AAAA,EACF;AACF;","names":["MessageCard","SignIn","SignUp","EmailVerification","ForgotPassword","SignOut","OAuthCallback","AccountSettings","MagicLinkCallback"]}
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
// src/components-core/loading-indicator.tsx
|
|
2
2
|
import styled, { keyframes } from "styled-components";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
4
|
var l7 = keyframes`
|
|
4
5
|
33% { background-size: calc(100%/3) 0%, calc(100%/3) 100%, calc(100%/3) 100%; }
|
|
5
6
|
50% { background-size: calc(100%/3) 100%, calc(100%/3) 0%, calc(100%/3) 100%; }
|
|
6
7
|
66% { background-size: calc(100%/3) 100%, calc(100%/3) 100%, calc(100%/3) 0%; }
|
|
7
8
|
`;
|
|
8
|
-
var
|
|
9
|
-
width: ${(props) => props
|
|
9
|
+
var StyledLoadingIndicator = styled.div`
|
|
10
|
+
width: ${(props) => props.$size || 36}px;
|
|
10
11
|
aspect-ratio: 4;
|
|
11
12
|
background:
|
|
12
13
|
var(--_g) 0% 50%,
|
|
@@ -15,14 +16,16 @@ var LoadingIndicator = styled.div`
|
|
|
15
16
|
background-size: calc(100%/3) 100%;
|
|
16
17
|
animation: ${l7} 1s infinite linear;
|
|
17
18
|
|
|
18
|
-
--_g: no-repeat radial-gradient(circle closest-side, ${(props) => props
|
|
19
|
+
--_g: no-repeat radial-gradient(circle closest-side, ${(props) => props.$color.light} 90%, #0000);
|
|
19
20
|
|
|
20
21
|
html[data-stack-theme='dark'] & {
|
|
21
|
-
--_g: no-repeat radial-gradient(circle closest-side, ${(props) => props
|
|
22
|
+
--_g: no-repeat radial-gradient(circle closest-side, ${(props) => props.$color.dark} 90%, #0000);
|
|
22
23
|
}
|
|
23
24
|
`;
|
|
24
|
-
|
|
25
|
+
function LoadingIndicator(props) {
|
|
26
|
+
return /* @__PURE__ */ jsx(StyledLoadingIndicator, { $size: props.size, $color: props.color });
|
|
27
|
+
}
|
|
25
28
|
export {
|
|
26
|
-
|
|
29
|
+
LoadingIndicator as default
|
|
27
30
|
};
|
|
28
31
|
//# sourceMappingURL=loading-indicator.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components-core/loading-indicator.tsx"],"sourcesContent":["import styled, { keyframes } from 'styled-components';\n\nconst l7 = keyframes`\n 33% { background-size: calc(100%/3) 0%, calc(100%/3) 100%, calc(100%/3) 100%; }\n 50% { background-size: calc(100%/3) 100%, calc(100%/3) 0%, calc(100%/3) 100%; }\n 66% { background-size: calc(100%/3) 100%, calc(100%/3) 100%, calc(100%/3) 0%; }\n`;\n\nconst
|
|
1
|
+
{"version":3,"sources":["../../../src/components-core/loading-indicator.tsx"],"sourcesContent":["import styled, { keyframes } from 'styled-components';\n\nconst l7 = keyframes`\n 33% { background-size: calc(100%/3) 0%, calc(100%/3) 100%, calc(100%/3) 100%; }\n 50% { background-size: calc(100%/3) 100%, calc(100%/3) 0%, calc(100%/3) 100%; }\n 66% { background-size: calc(100%/3) 100%, calc(100%/3) 100%, calc(100%/3) 0%; }\n`;\n\nconst StyledLoadingIndicator = styled.div<{ $color: { light: string, dark: string }, $size?: number }>`\n width: ${props => props.$size || 36}px;\n aspect-ratio: 4;\n background: \n var(--_g) 0% 50%, \n var(--_g) 50% 50%, \n var(--_g) 100% 50%;\n background-size: calc(100%/3) 100%;\n animation: ${l7} 1s infinite linear;\n\n --_g: no-repeat radial-gradient(circle closest-side, ${props => props.$color.light} 90%, #0000);\n\n html[data-stack-theme='dark'] & {\n --_g: no-repeat radial-gradient(circle closest-side, ${props => props.$color.dark} 90%, #0000);\n }\n`;\n\nexport default function LoadingIndicator(props: { size?: number, color: { light: string, dark: string } }) {\n return <StyledLoadingIndicator $size={props.size} $color={props.color} />;\n}"],"mappings":";AAAA,OAAO,UAAU,iBAAiB;AA0BzB;AAxBT,IAAM,KAAK;AAAA;AAAA;AAAA;AAAA;AAMX,IAAM,yBAAyB,OAAO;AAAA,WAC3B,WAAS,MAAM,SAAS,EAAE;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,eAOtB,EAAE;AAAA;AAAA,yDAEwC,WAAS,MAAM,OAAO,KAAK;AAAA;AAAA;AAAA,2DAGzB,WAAS,MAAM,OAAO,IAAI;AAAA;AAAA;AAItE,SAAR,iBAAkC,OAAkE;AACzG,SAAO,oBAAC,0BAAuB,OAAO,MAAM,MAAM,QAAQ,MAAM,OAAO;AACzE;","names":[]}
|
|
@@ -11,21 +11,36 @@ function OAuthCallback() {
|
|
|
11
11
|
const app = useStackApp();
|
|
12
12
|
const called = useRef(false);
|
|
13
13
|
const [error, setError] = useState(null);
|
|
14
|
+
const [showRedirectLink, setShowRedirectLink] = useState(false);
|
|
14
15
|
useEffect(() => runAsynchronously(async () => {
|
|
15
16
|
if (called.current)
|
|
16
17
|
return;
|
|
17
18
|
called.current = true;
|
|
19
|
+
let hasRedirected = false;
|
|
18
20
|
try {
|
|
19
|
-
await app.callOAuthCallback();
|
|
21
|
+
hasRedirected = await app.callOAuthCallback();
|
|
20
22
|
} catch (e) {
|
|
21
23
|
setError(e);
|
|
22
24
|
}
|
|
25
|
+
if (!hasRedirected) {
|
|
26
|
+
await app.redirectToSignIn();
|
|
27
|
+
}
|
|
23
28
|
}), []);
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
+
useEffect(() => {
|
|
30
|
+
setTimeout(() => setShowRedirectLink(true), 3e3);
|
|
31
|
+
}, []);
|
|
32
|
+
return /* @__PURE__ */ jsxs(MessageCard, { title: "Redirecting...", fullPage: true, children: [
|
|
33
|
+
showRedirectLink ? /* @__PURE__ */ jsxs("p", { children: [
|
|
34
|
+
"If you are not redirected automatically, ",
|
|
35
|
+
/* @__PURE__ */ jsx("a", { href: app.urls.home, children: "click here" }),
|
|
36
|
+
"."
|
|
37
|
+
] }) : null,
|
|
38
|
+
error ? /* @__PURE__ */ jsxs("div", { children: [
|
|
39
|
+
/* @__PURE__ */ jsx("p", { children: "Something went wrong while processing the OAuth callback:" }),
|
|
40
|
+
/* @__PURE__ */ jsx("pre", { children: JSON.stringify(error, null, 2) }),
|
|
41
|
+
/* @__PURE__ */ jsx("p", { children: "This is most likely an error in Stack. Please report it." })
|
|
42
|
+
] }) : null
|
|
43
|
+
] });
|
|
29
44
|
}
|
|
30
45
|
export {
|
|
31
46
|
OAuthCallback as default
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components-page/oauth-callback.tsx"],"sourcesContent":["'use client';\n\nimport { useRef, useEffect, useState } from \"react\";\nimport { useStackApp } from \"..\";\nimport { runAsynchronously } from \"@stackframe/stack-shared/dist/utils/promises\";\nimport MessageCard from \"../components/message-card\";\n\nexport default function OAuthCallback () {\n const app = useStackApp();\n const called = useRef(false);\n const [error, setError] = useState<unknown>(null);\n\n useEffect(() => runAsynchronously(async () => {\n if (called.current) return;\n called.current = true;\n try {\n await app.callOAuthCallback();\n } catch (e: any) {\n setError(e);\n }\n }), []);\n\n return <MessageCard title='Redirecting...' fullPage>\n {error ? <div>\n <p>Something went wrong while processing the OAuth callback:</p>\n <pre>{JSON.stringify(error, null, 2)}</pre>\n <p>This is most likely an error in Stack. Please report it.</p>\n </div> : null}\n </MessageCard>;\n}\n"],"mappings":";;;AAEA,SAAS,QAAQ,WAAW,gBAAgB;AAC5C,SAAS,mBAAmB;AAC5B,SAAS,yBAAyB;AAClC,OAAO,iBAAiB;
|
|
1
|
+
{"version":3,"sources":["../../../src/components-page/oauth-callback.tsx"],"sourcesContent":["'use client';\n\nimport { useRef, useEffect, useState } from \"react\";\nimport { useStackApp } from \"..\";\nimport { runAsynchronously } from \"@stackframe/stack-shared/dist/utils/promises\";\nimport MessageCard from \"../components/message-card\";\n\nexport default function OAuthCallback () {\n const app = useStackApp();\n const called = useRef(false);\n const [error, setError] = useState<unknown>(null);\n const [showRedirectLink, setShowRedirectLink] = useState(false);\n\n useEffect(() => runAsynchronously(async () => {\n if (called.current) return;\n called.current = true;\n let hasRedirected = false;\n try {\n hasRedirected = await app.callOAuthCallback();\n } catch (e: any) {\n setError(e);\n }\n if (!hasRedirected) {\n await app.redirectToSignIn();\n }\n }), []);\n\n useEffect(() => {\n setTimeout(() => setShowRedirectLink(true), 3000);\n }, []);\n\n return <MessageCard title='Redirecting...' fullPage>\n {showRedirectLink ? <p>If you are not redirected automatically, <a href={app.urls.home}>click here</a>.</p> : null}\n {error ? <div>\n <p>Something went wrong while processing the OAuth callback:</p>\n <pre>{JSON.stringify(error, null, 2)}</pre>\n <p>This is most likely an error in Stack. Please report it.</p>\n </div> : null}\n </MessageCard>;\n}\n"],"mappings":";;;AAEA,SAAS,QAAQ,WAAW,gBAAgB;AAC5C,SAAS,mBAAmB;AAC5B,SAAS,yBAAyB;AAClC,OAAO,iBAAiB;AA2BA,SAA4C,KAA5C;AAzBT,SAAR,gBAAkC;AACvC,QAAM,MAAM,YAAY;AACxB,QAAM,SAAS,OAAO,KAAK;AAC3B,QAAM,CAAC,OAAO,QAAQ,IAAI,SAAkB,IAAI;AAChD,QAAM,CAAC,kBAAkB,mBAAmB,IAAI,SAAS,KAAK;AAE9D,YAAU,MAAM,kBAAkB,YAAY;AAC5C,QAAI,OAAO;AAAS;AACpB,WAAO,UAAU;AACjB,QAAI,gBAAgB;AACpB,QAAI;AACF,sBAAgB,MAAM,IAAI,kBAAkB;AAAA,IAC9C,SAAS,GAAQ;AACf,eAAS,CAAC;AAAA,IACZ;AACA,QAAI,CAAC,eAAe;AAClB,YAAM,IAAI,iBAAiB;AAAA,IAC7B;AAAA,EACF,CAAC,GAAG,CAAC,CAAC;AAEN,YAAU,MAAM;AACd,eAAW,MAAM,oBAAoB,IAAI,GAAG,GAAI;AAAA,EAClD,GAAG,CAAC,CAAC;AAEL,SAAO,qBAAC,eAAY,OAAM,kBAAiB,UAAQ,MAChD;AAAA,uBAAmB,qBAAC,OAAE;AAAA;AAAA,MAAyC,oBAAC,OAAE,MAAM,IAAI,KAAK,MAAM,wBAAU;AAAA,MAAI;AAAA,OAAC,IAAO;AAAA,IAC7G,QAAQ,qBAAC,SACR;AAAA,0BAAC,OAAE,uEAAyD;AAAA,MAC5D,oBAAC,SAAK,eAAK,UAAU,OAAO,MAAM,CAAC,GAAE;AAAA,MACrC,oBAAC,OAAE,sEAAwD;AAAA,OAC7D,IAAS;AAAA,KACX;AACF;","names":[]}
|
|
@@ -5,7 +5,7 @@ import { RedirectType, notFound, redirect } from "next/navigation";
|
|
|
5
5
|
import EmailVerification from "./email-verification";
|
|
6
6
|
import { PasswordReset } from "..";
|
|
7
7
|
import MessageCard from "../components/message-card";
|
|
8
|
-
import
|
|
8
|
+
import SignOut from "./sign-out";
|
|
9
9
|
import ForgotPassword from "./forgot-password";
|
|
10
10
|
import OAuthCallback from "./oauth-callback";
|
|
11
11
|
import AccountSettings from "./account-settings";
|
|
@@ -27,14 +27,22 @@ async function StackHandler({
|
|
|
27
27
|
}
|
|
28
28
|
redirect(url, RedirectType.replace);
|
|
29
29
|
}
|
|
30
|
+
async function redirectIfHasUser() {
|
|
31
|
+
const user = await app.getServerUser();
|
|
32
|
+
if (user) {
|
|
33
|
+
redirect(app.urls.afterSignIn);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
30
36
|
const path = stack.join("/");
|
|
31
37
|
switch (path) {
|
|
32
38
|
case "signin": {
|
|
33
39
|
redirectIfNotHandler("signIn");
|
|
40
|
+
await redirectIfHasUser();
|
|
34
41
|
return /* @__PURE__ */ jsx(SignIn, { fullPage: true });
|
|
35
42
|
}
|
|
36
43
|
case "signup": {
|
|
37
44
|
redirectIfNotHandler("signUp");
|
|
45
|
+
await redirectIfHasUser();
|
|
38
46
|
return /* @__PURE__ */ jsx(SignUp, { fullPage: true });
|
|
39
47
|
}
|
|
40
48
|
case "email-verification": {
|
|
@@ -51,7 +59,7 @@ async function StackHandler({
|
|
|
51
59
|
}
|
|
52
60
|
case "signout": {
|
|
53
61
|
redirectIfNotHandler("signOut");
|
|
54
|
-
return /* @__PURE__ */ jsx(
|
|
62
|
+
return /* @__PURE__ */ jsx(SignOut, {});
|
|
55
63
|
}
|
|
56
64
|
case "oauth-callback": {
|
|
57
65
|
redirectIfNotHandler("oauthCallback");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components-page/stack-handler.tsx"],"sourcesContent":["import SignUp from \"./sign-up\";\nimport SignIn from \"./sign-in\";\nimport { RedirectType, notFound, redirect } from 'next/navigation';\nimport EmailVerification from \"./email-verification\";\nimport { PasswordReset, StackServerApp } from \"..\";\nimport MessageCard from \"../components/message-card\";\nimport { HandlerUrls } from \"../lib/stack-app\";\nimport
|
|
1
|
+
{"version":3,"sources":["../../../src/components-page/stack-handler.tsx"],"sourcesContent":["import SignUp from \"./sign-up\";\nimport SignIn from \"./sign-in\";\nimport { RedirectType, notFound, redirect } from 'next/navigation';\nimport EmailVerification from \"./email-verification\";\nimport { PasswordReset, StackServerApp } from \"..\";\nimport MessageCard from \"../components/message-card\";\nimport { HandlerUrls } from \"../lib/stack-app\";\nimport SignOut from \"./sign-out\";\nimport ForgotPassword from \"./forgot-password\";\nimport OAuthCallback from \"./oauth-callback\";\nimport AccountSettings from \"./account-settings\";\nimport MagicLinkCallback from \"./magic-link-callback\";\n\nexport default async function StackHandler<HasTokenStore extends boolean>({\n app,\n params: { stack } = {},\n searchParams = {},\n}: { \n app: StackServerApp<HasTokenStore>,\n params?: { stack?: string[] }, \n searchParams?: Record<string, string>,\n}) {\n if (!stack) {\n return (\n <MessageCard title=\"Invalid Stack Handler Setup\" fullPage>\n <p>Can't use Stack handler at this location. Make sure that the file is in a folder called [...stack].</p>\n </MessageCard>\n );\n }\n\n function redirectIfNotHandler(name: keyof HandlerUrls) {\n const url = app.urls[name];\n const handlerUrl = app.urls.handler;\n\n if (url.startsWith(handlerUrl)) {\n // don't redirect if the url is a handler url\n return;\n }\n\n redirect(url, RedirectType.replace);\n }\n\n async function redirectIfHasUser() {\n const user = await app.getServerUser();\n if (user) {\n redirect(app.urls.afterSignIn);\n }\n }\n\n const path = stack.join('/');\n switch (path) {\n case 'signin': {\n redirectIfNotHandler('signIn');\n await redirectIfHasUser();\n return <SignIn fullPage/>;\n }\n case 'signup': {\n redirectIfNotHandler('signUp');\n await redirectIfHasUser();\n return <SignUp fullPage/>;\n }\n case 'email-verification': {\n redirectIfNotHandler('emailVerification');\n return <EmailVerification searchParams={searchParams} fullPage/>;\n }\n case 'password-reset': {\n redirectIfNotHandler('passwordReset');\n return <PasswordReset searchParams={searchParams} fullPage />;\n }\n case 'forgot-password': {\n redirectIfNotHandler('forgotPassword');\n return <ForgotPassword fullPage />;\n }\n case 'signout': {\n redirectIfNotHandler('signOut');\n return <SignOut/>;\n }\n case 'oauth-callback': {\n redirectIfNotHandler('oauthCallback');\n return <OAuthCallback />;\n }\n case 'account-settings': {\n redirectIfNotHandler('accountSettings');\n return <AccountSettings fullPage />;\n }\n case 'magic-link-callback': {\n redirectIfNotHandler('magicLinkCallback');\n return <MagicLinkCallback searchParams={searchParams} fullPage />;\n }\n default: {\n return notFound();\n }\n }\n}\n"],"mappings":";AAAA,OAAO,YAAY;AACnB,OAAO,YAAY;AACnB,SAAS,cAAc,UAAU,gBAAgB;AACjD,OAAO,uBAAuB;AAC9B,SAAS,qBAAqC;AAC9C,OAAO,iBAAiB;AAExB,OAAO,aAAa;AACpB,OAAO,oBAAoB;AAC3B,OAAO,mBAAmB;AAC1B,OAAO,qBAAqB;AAC5B,OAAO,uBAAuB;AActB;AAZR,eAAO,aAAmE;AAAA,EACxE;AAAA,EACA,QAAQ,EAAE,MAAM,IAAI,CAAC;AAAA,EACrB,eAAe,CAAC;AAClB,GAIG;AACD,MAAI,CAAC,OAAO;AACV,WACE,oBAAC,eAAY,OAAM,+BAA8B,UAAQ,MACvD,8BAAC,OAAE,iHAAmG,GACxG;AAAA,EAEJ;AAEA,WAAS,qBAAqB,MAAyB;AACrD,UAAM,MAAM,IAAI,KAAK,IAAI;AACzB,UAAM,aAAa,IAAI,KAAK;AAE5B,QAAI,IAAI,WAAW,UAAU,GAAG;AAE9B;AAAA,IACF;AAEA,aAAS,KAAK,aAAa,OAAO;AAAA,EACpC;AAEA,iBAAe,oBAAoB;AACjC,UAAM,OAAO,MAAM,IAAI,cAAc;AACrC,QAAI,MAAM;AACR,eAAS,IAAI,KAAK,WAAW;AAAA,IAC/B;AAAA,EACF;AAEA,QAAM,OAAO,MAAM,KAAK,GAAG;AAC3B,UAAQ,MAAM;AAAA,IACZ,KAAK,UAAU;AACb,2BAAqB,QAAQ;AAC7B,YAAM,kBAAkB;AACxB,aAAO,oBAAC,UAAO,UAAQ;AAAA,IACzB;AAAA,IACA,KAAK,UAAU;AACb,2BAAqB,QAAQ;AAC7B,YAAM,kBAAkB;AACxB,aAAO,oBAAC,UAAO,UAAQ;AAAA,IACzB;AAAA,IACA,KAAK,sBAAsB;AACzB,2BAAqB,mBAAmB;AACxC,aAAO,oBAAC,qBAAkB,cAA4B,UAAQ;AAAA,IAChE;AAAA,IACA,KAAK,kBAAkB;AACrB,2BAAqB,eAAe;AACpC,aAAO,oBAAC,iBAAc,cAA4B,UAAQ,MAAC;AAAA,IAC7D;AAAA,IACA,KAAK,mBAAmB;AACtB,2BAAqB,gBAAgB;AACrC,aAAO,oBAAC,kBAAe,UAAQ,MAAC;AAAA,IAClC;AAAA,IACA,KAAK,WAAW;AACd,2BAAqB,SAAS;AAC9B,aAAO,oBAAC,WAAO;AAAA,IACjB;AAAA,IACA,KAAK,kBAAkB;AACrB,2BAAqB,eAAe;AACpC,aAAO,oBAAC,iBAAc;AAAA,IACxB;AAAA,IACA,KAAK,oBAAoB;AACvB,2BAAqB,iBAAiB;AACtC,aAAO,oBAAC,mBAAgB,UAAQ,MAAC;AAAA,IACnC;AAAA,IACA,KAAK,uBAAuB;AAC1B,2BAAqB,mBAAmB;AACxC,aAAO,oBAAC,qBAAkB,cAA4B,UAAQ,MAAC;AAAA,IACjE;AAAA,IACA,SAAS;AACP,aAAO,SAAS;AAAA,IAClB;AAAA,EACF;AACF;","names":[]}
|
|
@@ -13,10 +13,10 @@ import { callOAuthCallback, signInWithOAuth } from "./auth";
|
|
|
13
13
|
import * as NextNavigation from "next/navigation";
|
|
14
14
|
import { constructRedirectUrl } from "../utils/url";
|
|
15
15
|
import { filterUndefined, omit } from "@stackframe/stack-shared/dist/utils/objects";
|
|
16
|
-
import {
|
|
16
|
+
import { resolved, runAsynchronously, wait } from "@stackframe/stack-shared/dist/utils/promises";
|
|
17
17
|
import { AsyncCache } from "@stackframe/stack-shared/dist/utils/caches";
|
|
18
18
|
import { suspend } from "@stackframe/stack-shared/dist/utils/react";
|
|
19
|
-
var clientVersion = "js @stackframe/stack@2.4.
|
|
19
|
+
var clientVersion = "js @stackframe/stack@2.4.8";
|
|
20
20
|
function permissionDefinitionScopeToType(scope) {
|
|
21
21
|
return { "any-team": "team", "specific-team": "team", "global": "global" }[scope.type];
|
|
22
22
|
}
|
|
@@ -41,16 +41,16 @@ function getUrls(partial) {
|
|
|
41
41
|
};
|
|
42
42
|
}
|
|
43
43
|
function getDefaultProjectId() {
|
|
44
|
-
return process.env.NEXT_PUBLIC_STACK_PROJECT_ID || throwErr("Welcome to Stack! It seems that you haven't provided a project ID. Please create a project on the Stack dashboard at https://app.stack-auth.com and put it in the NEXT_PUBLIC_STACK_PROJECT_ID environment variable.");
|
|
44
|
+
return process.env.NEXT_PUBLIC_STACK_PROJECT_ID || throwErr(new Error("Welcome to Stack! It seems that you haven't provided a project ID. Please create a project on the Stack dashboard at https://app.stack-auth.com and put it in the NEXT_PUBLIC_STACK_PROJECT_ID environment variable."));
|
|
45
45
|
}
|
|
46
46
|
function getDefaultPublishableClientKey() {
|
|
47
|
-
return process.env.NEXT_PUBLIC_STACK_PUBLISHABLE_CLIENT_KEY || throwErr("Welcome to Stack! It seems that you haven't provided a publishable client key. Please create an API key for your project on the Stack dashboard at https://app.stack-auth.com and copy your publishable client key into the NEXT_PUBLIC_STACK_PUBLISHABLE_CLIENT_KEY environment variable.");
|
|
47
|
+
return process.env.NEXT_PUBLIC_STACK_PUBLISHABLE_CLIENT_KEY || throwErr(new Error("Welcome to Stack! It seems that you haven't provided a publishable client key. Please create an API key for your project on the Stack dashboard at https://app.stack-auth.com and copy your publishable client key into the NEXT_PUBLIC_STACK_PUBLISHABLE_CLIENT_KEY environment variable."));
|
|
48
48
|
}
|
|
49
49
|
function getDefaultSecretServerKey() {
|
|
50
|
-
return process.env.STACK_SECRET_SERVER_KEY || throwErr("No secret server key provided. Please copy your key from the Stack dashboard and put your it in the STACK_SECRET_SERVER_KEY environment variable.");
|
|
50
|
+
return process.env.STACK_SECRET_SERVER_KEY || throwErr(new Error("No secret server key provided. Please copy your key from the Stack dashboard and put your it in the STACK_SECRET_SERVER_KEY environment variable."));
|
|
51
51
|
}
|
|
52
52
|
function getDefaultSuperSecretAdminKey() {
|
|
53
|
-
return process.env.STACK_SUPER_SECRET_ADMIN_KEY || throwErr("No super secret admin key provided. Please copy your key from the Stack dashboard and put it in the STACK_SUPER_SECRET_ADMIN_KEY environment variable.");
|
|
53
|
+
return process.env.STACK_SUPER_SECRET_ADMIN_KEY || throwErr(new Error("No super secret admin key provided. Please copy your key from the Stack dashboard and put it in the STACK_SUPER_SECRET_ADMIN_KEY environment variable."));
|
|
54
54
|
}
|
|
55
55
|
function getDefaultBaseUrl() {
|
|
56
56
|
return process.env.NEXT_PUBLIC_STACK_URL || defaultBaseUrl;
|
|
@@ -264,6 +264,12 @@ var _StackClientAppImpl = class __StackClientAppImpl {
|
|
|
264
264
|
hasPassword: json.hasPassword,
|
|
265
265
|
authWithEmail: json.authWithEmail,
|
|
266
266
|
oauthProviders: json.oauthProviders,
|
|
267
|
+
async getSelectedTeam() {
|
|
268
|
+
return await this.getTeam(json.selectedTeamId || "");
|
|
269
|
+
},
|
|
270
|
+
useSelectedTeam() {
|
|
271
|
+
return this.useTeam(json.selectedTeamId || "");
|
|
272
|
+
},
|
|
267
273
|
async getTeam(teamId) {
|
|
268
274
|
const teams = await this.listTeams();
|
|
269
275
|
return teams.find((t) => t.id === teamId) ?? null;
|
|
@@ -333,6 +339,9 @@ var _StackClientAppImpl = class __StackClientAppImpl {
|
|
|
333
339
|
const currentUser = {
|
|
334
340
|
...this._userFromJson(json),
|
|
335
341
|
tokenStore,
|
|
342
|
+
async updateSelectedTeam(team) {
|
|
343
|
+
await app._updateUser({ selectedTeamId: team?.id ?? null }, tokenStore);
|
|
344
|
+
},
|
|
336
345
|
update(update) {
|
|
337
346
|
return app._updateUser(update, tokenStore);
|
|
338
347
|
},
|
|
@@ -416,11 +425,16 @@ var _StackClientAppImpl = class __StackClientAppImpl {
|
|
|
416
425
|
get urls() {
|
|
417
426
|
return getUrls(this._urlOptions);
|
|
418
427
|
}
|
|
419
|
-
async _redirectTo(handlerName) {
|
|
420
|
-
|
|
428
|
+
async _redirectTo(handlerName, options) {
|
|
429
|
+
const url = this.urls[handlerName];
|
|
430
|
+
if (!url) {
|
|
421
431
|
throw new Error(`No URL for handler name ${handlerName}`);
|
|
422
432
|
}
|
|
423
|
-
|
|
433
|
+
if (options?.replace) {
|
|
434
|
+
window.location.replace(url);
|
|
435
|
+
} else {
|
|
436
|
+
window.location.assign(url);
|
|
437
|
+
}
|
|
424
438
|
return await wait(2e3);
|
|
425
439
|
}
|
|
426
440
|
async redirectToSignIn() {
|
|
@@ -547,7 +561,7 @@ var _StackClientAppImpl = class __StackClientAppImpl {
|
|
|
547
561
|
const tokenStore = getTokenStore(this._tokenStoreOptions);
|
|
548
562
|
const errorCode = await this._interface.signInWithCredential(options.email, options.password, tokenStore);
|
|
549
563
|
if (!errorCode) {
|
|
550
|
-
|
|
564
|
+
await this.redirectToAfterSignIn({ replace: true });
|
|
551
565
|
}
|
|
552
566
|
return errorCode;
|
|
553
567
|
}
|
|
@@ -562,7 +576,7 @@ var _StackClientAppImpl = class __StackClientAppImpl {
|
|
|
562
576
|
tokenStore
|
|
563
577
|
);
|
|
564
578
|
if (!errorCode) {
|
|
565
|
-
|
|
579
|
+
await this.redirectToAfterSignUp({ replace: true });
|
|
566
580
|
}
|
|
567
581
|
return errorCode;
|
|
568
582
|
}
|
|
@@ -574,11 +588,10 @@ var _StackClientAppImpl = class __StackClientAppImpl {
|
|
|
574
588
|
return result;
|
|
575
589
|
}
|
|
576
590
|
if (result.newUser) {
|
|
577
|
-
|
|
591
|
+
await this.redirectToAfterSignUp({ replace: true });
|
|
578
592
|
} else {
|
|
579
|
-
|
|
593
|
+
await this.redirectToAfterSignIn({ replace: true });
|
|
580
594
|
}
|
|
581
|
-
await neverResolve();
|
|
582
595
|
}
|
|
583
596
|
async callOAuthCallback() {
|
|
584
597
|
this._ensurePersistentTokenStore();
|
|
@@ -586,16 +599,18 @@ var _StackClientAppImpl = class __StackClientAppImpl {
|
|
|
586
599
|
const result = await callOAuthCallback(this._interface, tokenStore, this.urls.oauthCallback);
|
|
587
600
|
if (result) {
|
|
588
601
|
if (result.newUser) {
|
|
589
|
-
|
|
602
|
+
await this.redirectToAfterSignUp({ replace: true });
|
|
603
|
+
return true;
|
|
590
604
|
} else {
|
|
591
|
-
|
|
605
|
+
await this.redirectToAfterSignIn({ replace: true });
|
|
606
|
+
return true;
|
|
592
607
|
}
|
|
593
608
|
}
|
|
594
|
-
|
|
609
|
+
return false;
|
|
595
610
|
}
|
|
596
611
|
async _signOut(tokenStore) {
|
|
597
612
|
await this._interface.signOut(tokenStore);
|
|
598
|
-
|
|
613
|
+
await this.redirectToAfterSignOut();
|
|
599
614
|
}
|
|
600
615
|
async _sendVerificationEmail(tokenStore) {
|
|
601
616
|
const emailVerificationRedirectUrl = constructRedirectUrl(this.urls.emailVerification);
|
|
@@ -856,6 +871,9 @@ var _StackServerAppImpl = class extends _StackClientAppImpl {
|
|
|
856
871
|
await app._refreshUser(tokenStore);
|
|
857
872
|
return res;
|
|
858
873
|
},
|
|
874
|
+
async updateSelectedTeam(team) {
|
|
875
|
+
await this.update({ selectedTeamId: team?.id ?? null });
|
|
876
|
+
},
|
|
859
877
|
async update(update) {
|
|
860
878
|
const res = await nonCurrentServerUser.update(update);
|
|
861
879
|
await app._refreshUser(tokenStore);
|