@stackframe/stack 1.2.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/EmailVerification.d.ts +0 -2
- package/dist/components/EmailVerification.d.ts.map +1 -1
- package/dist/components/ForgotPassword.d.ts +0 -1
- package/dist/components/OAuthCallback.d.ts +0 -1
- package/dist/components/OAuthCallback.d.ts.map +1 -1
- package/dist/components/OAuthCallback.js +0 -3
- package/dist/components/PasswordReset.d.ts +0 -1
- package/dist/components/SignIn.d.ts +1 -3
- package/dist/components/SignIn.d.ts.map +1 -1
- package/dist/components/SignIn.js +3 -3
- package/dist/components/SignOut.d.ts +1 -4
- package/dist/components/SignOut.d.ts.map +1 -1
- package/dist/components/SignOut.js +4 -3
- package/dist/components/SignUp.d.ts +1 -3
- package/dist/components/SignUp.d.ts.map +1 -1
- package/dist/components/SignUp.js +2 -2
- package/dist/components/StackHandler.d.ts +0 -1
- package/dist/components/StackHandler.js +4 -4
- package/dist/elements/Button.d.ts +0 -1
- package/dist/elements/CardFrame.d.ts +0 -1
- package/dist/elements/CardHeader.d.ts +0 -1
- package/dist/elements/CredentialSignIn.d.ts +1 -4
- package/dist/elements/CredentialSignIn.d.ts.map +1 -1
- package/dist/elements/CredentialSignIn.js +4 -4
- package/dist/elements/CredentialSignUp.d.ts +1 -4
- package/dist/elements/CredentialSignUp.d.ts.map +1 -1
- package/dist/elements/CredentialSignUp.js +4 -4
- package/dist/elements/DividerWithText.d.ts +0 -1
- package/dist/elements/ForgotPassword.d.ts +0 -1
- package/dist/elements/FormWarning.d.ts +0 -1
- package/dist/elements/MessageCard.d.ts +0 -1
- package/dist/elements/OAuthButton.d.ts +1 -3
- package/dist/elements/OAuthButton.d.ts.map +1 -1
- package/dist/elements/OAuthButton.js +1 -1
- package/dist/elements/OAuthGroup.d.ts +1 -3
- package/dist/elements/OAuthGroup.d.ts.map +1 -1
- package/dist/elements/OAuthGroup.js +2 -2
- package/dist/elements/PasswordField.d.ts +0 -1
- package/dist/elements/PasswordResetInner.d.ts +0 -1
- package/dist/elements/PasswordResetInner.js +1 -1
- package/dist/elements/RedirectMessageCard.d.ts +0 -1
- package/dist/elements/RedirectMessageCard.d.ts.map +1 -1
- package/dist/elements/RedirectMessageCard.js +19 -14
- package/dist/index.d.ts +0 -1
- package/dist/lib/auth.d.ts +1 -14
- package/dist/lib/auth.d.ts.map +1 -1
- package/dist/lib/auth.js +6 -30
- package/dist/lib/cookie.d.ts +0 -1
- package/dist/lib/hooks.d.ts +0 -1
- package/dist/lib/stack-app.d.ts +6 -9
- package/dist/lib/stack-app.d.ts.map +1 -1
- package/dist/lib/stack-app.js +43 -35
- package/dist/providers/StackProvider.d.ts +0 -1
- package/dist/providers/StackProviderClient.d.ts +0 -1
- package/dist/tailwind.css +6 -0
- package/dist/utils/email.d.ts +0 -1
- package/dist/utils/next.d.ts +0 -1
- package/dist/utils/react.d.ts +0 -1
- package/dist/utils/results.d.ts +0 -1
- package/dist/utils/url.d.ts +0 -1
- package/package.json +6 -6
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
export default function EmailVerification({ searchParams: { code, }, fullPage, }: {
|
|
2
2
|
searchParams?: Record<string, string>;
|
|
3
3
|
fullPage?: boolean;
|
|
4
|
-
redirectUrl?: string;
|
|
5
4
|
}): import("react/jsx-runtime").JSX.Element | null;
|
|
6
|
-
//# sourceMappingURL=EmailVerification.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EmailVerification.d.ts","sourceRoot":"","sources":["../../src/components/EmailVerification.tsx"],"names":[],"mappings":"AAQA,MAAM,CAAC,OAAO,UAAU,iBAAiB,CAAC,EACxC,YAAY,EAAE,EACZ,IAAS,GACL,EACN,QAAgB,GACjB,EAAE;IACD,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACtC,QAAQ,CAAC,EAAE,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"EmailVerification.d.ts","sourceRoot":"","sources":["../../src/components/EmailVerification.tsx"],"names":[],"mappings":"AAQA,MAAM,CAAC,OAAO,UAAU,iBAAiB,CAAC,EACxC,YAAY,EAAE,EACZ,IAAS,GACL,EACN,QAAgB,GACjB,EAAE;IACD,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACtC,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,kDAkCA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OAuthCallback.d.ts","sourceRoot":"","sources":["../../src/components/OAuthCallback.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"OAuthCallback.d.ts","sourceRoot":"","sources":["../../src/components/OAuthCallback.tsx"],"names":[],"mappings":"AAMA,MAAM,CAAC,OAAO,UAAU,aAAa,4CAWpC"}
|
|
@@ -4,17 +4,14 @@ import { useRef, useEffect } from "react";
|
|
|
4
4
|
import { useStackApp } from "..";
|
|
5
5
|
import { runAsynchronously } from "@stackframe/stack-shared/dist/utils/promises";
|
|
6
6
|
import MessageCard from "../elements/MessageCard";
|
|
7
|
-
import { useRouter } from "next/navigation";
|
|
8
7
|
export default function OAuthCallback() {
|
|
9
8
|
const app = useStackApp();
|
|
10
|
-
const router = useRouter();
|
|
11
9
|
const called = useRef(false);
|
|
12
10
|
useEffect(() => runAsynchronously(async () => {
|
|
13
11
|
if (called.current)
|
|
14
12
|
return;
|
|
15
13
|
called.current = true;
|
|
16
14
|
await app.callOAuthCallback();
|
|
17
|
-
router.push(app.urls.userHome);
|
|
18
15
|
}), []);
|
|
19
16
|
return _jsx(MessageCard, { title: 'Redirecting...', fullPage: true });
|
|
20
17
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SignIn.d.ts","sourceRoot":"","sources":["../../src/components/SignIn.tsx"],"names":[],"mappings":"AAWA,MAAM,CAAC,OAAO,UAAU,MAAM,CAAC,EAAE,
|
|
1
|
+
{"version":3,"file":"SignIn.d.ts","sourceRoot":"","sources":["../../src/components/SignIn.tsx"],"names":[],"mappings":"AAWA,MAAM,CAAC,OAAO,UAAU,MAAM,CAAC,EAAE,QAAc,EAAE,EAAE;IAAE,QAAQ,CAAC,EAAE,OAAO,CAAA;CAAE,2CA2BxE"}
|
|
@@ -8,13 +8,13 @@ import CardFrame from '../elements/CardFrame';
|
|
|
8
8
|
import CardHeader from '../elements/CardHeader';
|
|
9
9
|
import { useUser, useStackApp } from '..';
|
|
10
10
|
import RedirectMessageCard from '../elements/RedirectMessageCard';
|
|
11
|
-
export default function SignIn({
|
|
11
|
+
export default function SignIn({ fullPage = false }) {
|
|
12
12
|
const stackApp = useStackApp();
|
|
13
13
|
const user = useUser();
|
|
14
14
|
const project = stackApp.useProject();
|
|
15
15
|
if (user) {
|
|
16
16
|
return _jsx(RedirectMessageCard, { type: 'signedIn', fullPage: fullPage });
|
|
17
17
|
}
|
|
18
|
-
return (_jsxs(CardFrame, { fullPage: fullPage, children: [_jsx(CardHeader, { title: "Sign In to Your Account", children: _jsxs("p", { children: ["Don't have an account? ", _jsx(NextLink, { href: stackApp.urls['signUp'], passHref: true, className: "wl_text-blue-500", children: "Sign up" })] }) }), _jsx(OAuthGroup, { type: 'signin'
|
|
19
|
-
_jsxs(_Fragment, { children: [_jsx(DividerWithText, { text: 'OR' }), _jsx(CredentialSignIn, {
|
|
18
|
+
return (_jsxs(CardFrame, { fullPage: fullPage, children: [_jsx(CardHeader, { title: "Sign In to Your Account", children: _jsxs("p", { children: ["Don't have an account? ", _jsx(NextLink, { href: stackApp.urls['signUp'], passHref: true, className: "wl_text-blue-500", children: "Sign up" })] }) }), _jsx(OAuthGroup, { type: 'signin' }), project.credentialEnabled &&
|
|
19
|
+
_jsxs(_Fragment, { children: [_jsx(DividerWithText, { text: 'OR' }), _jsx(CredentialSignIn, {})] })] }));
|
|
20
20
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SignOut.d.ts","sourceRoot":"","sources":["../../src/components/SignOut.tsx"],"names":[],"mappings":"AAMA,MAAM,CAAC,OAAO,UAAU,OAAO,
|
|
1
|
+
{"version":3,"file":"SignOut.d.ts","sourceRoot":"","sources":["../../src/components/SignOut.tsx"],"names":[],"mappings":"AAMA,MAAM,CAAC,OAAO,UAAU,OAAO,4CAS9B"}
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
3
|
import { use } from "react";
|
|
4
|
-
import { useUser } from "..";
|
|
4
|
+
import { useStackApp, useUser } from "..";
|
|
5
5
|
import GoHomeMessageCard from "../elements/RedirectMessageCard";
|
|
6
|
-
export default function Signout(
|
|
6
|
+
export default function Signout() {
|
|
7
7
|
const user = useUser();
|
|
8
|
+
const app = useStackApp();
|
|
8
9
|
if (user) {
|
|
9
|
-
use(user.signOut(
|
|
10
|
+
use(user.signOut());
|
|
10
11
|
}
|
|
11
12
|
return _jsx(GoHomeMessageCard, { type: 'signedOut', fullPage: true });
|
|
12
13
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SignUp.d.ts","sourceRoot":"","sources":["../../src/components/SignUp.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"SignUp.d.ts","sourceRoot":"","sources":["../../src/components/SignUp.tsx"],"names":[],"mappings":"AAUA,MAAM,CAAC,OAAO,UAAU,MAAM,CAAC,EAAE,QAAc,EAAE,EAAE;IAAE,QAAQ,CAAC,EAAE,OAAO,CAAA;CAAE,2CA0BxE"}
|
|
@@ -8,12 +8,12 @@ import CredentialSignUp from '../elements/CredentialSignUp';
|
|
|
8
8
|
import CardHeader from '../elements/CardHeader';
|
|
9
9
|
import { useUser, useStackApp } from '..';
|
|
10
10
|
import RedirectMessageCard from '../elements/RedirectMessageCard';
|
|
11
|
-
export default function SignUp({
|
|
11
|
+
export default function SignUp({ fullPage = false }) {
|
|
12
12
|
const stackApp = useStackApp();
|
|
13
13
|
const user = useUser();
|
|
14
14
|
const project = stackApp.useProject();
|
|
15
15
|
if (user) {
|
|
16
16
|
return _jsx(RedirectMessageCard, { type: 'signedIn', fullPage: fullPage });
|
|
17
17
|
}
|
|
18
|
-
return (_jsxs(CardFrame, { fullPage: fullPage, children: [_jsx(CardHeader, { title: "Create a New Account", children: _jsxs("p", { children: ["Already have an account? ", _jsx(NextLink, { href: stackApp.urls['signIn'], passHref: true, className: "wl_text-blue-500", children: "Sign in" })] }) }), _jsx(OAuthGroup, { type: 'signup'
|
|
18
|
+
return (_jsxs(CardFrame, { fullPage: fullPage, children: [_jsx(CardHeader, { title: "Create a New Account", children: _jsxs("p", { children: ["Already have an account? ", _jsx(NextLink, { href: stackApp.urls['signIn'], passHref: true, className: "wl_text-blue-500", children: "Sign in" })] }) }), _jsx(OAuthGroup, { type: 'signup' }), project.credentialEnabled && _jsxs(_Fragment, { children: [_jsx(DividerWithText, { text: 'OR' }), _jsx(CredentialSignUp, {})] })] }));
|
|
19
19
|
}
|
|
@@ -25,15 +25,15 @@ export default async function StackHandler({ app, params: { stack } = {}, search
|
|
|
25
25
|
switch (path) {
|
|
26
26
|
case 'signin': {
|
|
27
27
|
redirectIfNotHandler('signIn');
|
|
28
|
-
return _jsx(SignIn, { fullPage: true
|
|
28
|
+
return _jsx(SignIn, { fullPage: true });
|
|
29
29
|
}
|
|
30
30
|
case 'signup': {
|
|
31
31
|
redirectIfNotHandler('signUp');
|
|
32
|
-
return _jsx(SignUp, { fullPage: true
|
|
32
|
+
return _jsx(SignUp, { fullPage: true });
|
|
33
33
|
}
|
|
34
34
|
case 'email-verification': {
|
|
35
35
|
redirectIfNotHandler('emailVerification');
|
|
36
|
-
return _jsx(EmailVerification, { searchParams: searchParams, fullPage: true
|
|
36
|
+
return _jsx(EmailVerification, { searchParams: searchParams, fullPage: true });
|
|
37
37
|
}
|
|
38
38
|
case 'password-reset': {
|
|
39
39
|
redirectIfNotHandler('passwordReset');
|
|
@@ -45,7 +45,7 @@ export default async function StackHandler({ app, params: { stack } = {}, search
|
|
|
45
45
|
}
|
|
46
46
|
case 'signout': {
|
|
47
47
|
redirectIfNotHandler('signOut');
|
|
48
|
-
return _jsx(Signout, {
|
|
48
|
+
return _jsx(Signout, {});
|
|
49
49
|
}
|
|
50
50
|
case 'oauth-callback': {
|
|
51
51
|
redirectIfNotHandler('oauthCallback');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CredentialSignIn.d.ts","sourceRoot":"","sources":["../../src/elements/CredentialSignIn.tsx"],"names":[],"mappings":"AAWA,MAAM,CAAC,OAAO,UAAU,gBAAgB,
|
|
1
|
+
{"version":3,"file":"CredentialSignIn.d.ts","sourceRoot":"","sources":["../../src/elements/CredentialSignIn.tsx"],"names":[],"mappings":"AAWA,MAAM,CAAC,OAAO,UAAU,gBAAgB,4CAkGvC"}
|
|
@@ -9,13 +9,13 @@ import Button from "./Button";
|
|
|
9
9
|
import { runAsynchronously } from "@stackframe/stack-shared/dist/utils/promises";
|
|
10
10
|
import { EmailPasswordMissMatchErrorCode, UserNotExistErrorCode } from "@stackframe/stack-shared/dist/utils/types";
|
|
11
11
|
// Import or define the PasswordField, FormWarningText, and validateEmail utilities if they're custom components or functions.
|
|
12
|
-
export default function CredentialSignIn(
|
|
12
|
+
export default function CredentialSignIn() {
|
|
13
13
|
const [email, setEmail] = useState('');
|
|
14
14
|
const [emailError, setEmailError] = useState('');
|
|
15
15
|
const [password, setPassword] = useState('');
|
|
16
16
|
const [passwordError, setPasswordError] = useState('');
|
|
17
17
|
const [loading, setLoading] = useState(false);
|
|
18
|
-
const
|
|
18
|
+
const app = useStackApp();
|
|
19
19
|
const onSubmit = async () => {
|
|
20
20
|
if (!email) {
|
|
21
21
|
setEmailError('Please enter your email');
|
|
@@ -30,7 +30,7 @@ export default function CredentialSignIn({ redirectUrl }) {
|
|
|
30
30
|
return;
|
|
31
31
|
}
|
|
32
32
|
setLoading(true);
|
|
33
|
-
const errorCode = await
|
|
33
|
+
const errorCode = await app.signInWithCredential({ email, password });
|
|
34
34
|
setLoading(false);
|
|
35
35
|
switch (errorCode) {
|
|
36
36
|
case UserNotExistErrorCode: {
|
|
@@ -53,5 +53,5 @@ export default function CredentialSignIn({ redirectUrl }) {
|
|
|
53
53
|
} }), _jsx(FormWarningText, { text: emailError })] }), _jsxs("div", { className: "wl_form-control", children: [_jsx("label", { className: "wl_label", htmlFor: "password", children: _jsx("span", { className: "wl_label-text", children: "Password" }) }), _jsx(PasswordField, { id: "password", name: "password", value: password, onChange: (e) => {
|
|
54
54
|
setPassword(e.target.value);
|
|
55
55
|
setPasswordError('');
|
|
56
|
-
} }), _jsx(FormWarningText, { text: passwordError })] }), _jsx("div", { className: "wl_flex wl_items-center wl_justify-between", children: _jsx(NextLink, { href:
|
|
56
|
+
} }), _jsx(FormWarningText, { text: passwordError })] }), _jsx("div", { className: "wl_flex wl_items-center wl_justify-between", children: _jsx(NextLink, { href: app.urls.forgotPassword, className: "wl_text-sm wl_text-blue-500 wl_no-underline wl_hover:wl_underline", children: "Forgot password?" }) }), _jsx("div", { className: "wl_flex wl_flex-col wl_items-stretch", children: _jsx(Button, { className: "wl_btn-primary wl_mt-6", onClick: () => runAsynchronously(onSubmit), loading: loading, children: "Sign In" }) })] }));
|
|
57
57
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CredentialSignUp.d.ts","sourceRoot":"","sources":["../../src/elements/CredentialSignUp.tsx"],"names":[],"mappings":"AAYA,MAAM,CAAC,OAAO,UAAU,gBAAgB,
|
|
1
|
+
{"version":3,"file":"CredentialSignUp.d.ts","sourceRoot":"","sources":["../../src/elements/CredentialSignUp.tsx"],"names":[],"mappings":"AAYA,MAAM,CAAC,OAAO,UAAU,gBAAgB,4CAuHvC"}
|
|
@@ -4,12 +4,12 @@ import { useState } from "react";
|
|
|
4
4
|
import { PasswordField } from "./PasswordField";
|
|
5
5
|
import { FormWarningText } from "./FormWarning";
|
|
6
6
|
import { validateEmail } from "../utils/email";
|
|
7
|
-
import { getPasswordError } from "@stackframe/stack-shared/
|
|
7
|
+
import { getPasswordError } from "@stackframe/stack-shared/dist/helpers/password";
|
|
8
8
|
import { useStackApp } from "..";
|
|
9
9
|
import { runAsynchronously } from "@stackframe/stack-shared/dist/utils/promises";
|
|
10
10
|
import Button from "./Button";
|
|
11
11
|
import { UserAlreadyExistErrorCode } from "@stackframe/stack-shared/dist/utils/types";
|
|
12
|
-
export default function CredentialSignUp(
|
|
12
|
+
export default function CredentialSignUp() {
|
|
13
13
|
const [email, setEmail] = useState('');
|
|
14
14
|
const [emailError, setEmailError] = useState('');
|
|
15
15
|
const [password, setPassword] = useState('');
|
|
@@ -17,7 +17,7 @@ export default function CredentialSignUp({ redirectUrl }) {
|
|
|
17
17
|
const [passwordRepeat, setPasswordRepeat] = useState('');
|
|
18
18
|
const [passwordRepeatError, setPasswordRepeatError] = useState('');
|
|
19
19
|
const [loading, setLoading] = useState(false);
|
|
20
|
-
const
|
|
20
|
+
const app = useStackApp();
|
|
21
21
|
const onSubmit = async () => {
|
|
22
22
|
if (!email) {
|
|
23
23
|
setEmailError('Please enter your email');
|
|
@@ -45,7 +45,7 @@ export default function CredentialSignUp({ redirectUrl }) {
|
|
|
45
45
|
return;
|
|
46
46
|
}
|
|
47
47
|
setLoading(true);
|
|
48
|
-
const errorCode = await
|
|
48
|
+
const errorCode = await app.signUpWithCredential({ email, password });
|
|
49
49
|
setLoading(false);
|
|
50
50
|
switch (errorCode) {
|
|
51
51
|
case UserAlreadyExistErrorCode: {
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
export default function OAuthButton({ provider, type,
|
|
1
|
+
export default function OAuthButton({ provider, type, }: {
|
|
2
2
|
provider: string;
|
|
3
3
|
type: 'signin' | 'signup';
|
|
4
|
-
redirectUrl?: string;
|
|
5
4
|
}): import("react/jsx-runtime").JSX.Element;
|
|
6
|
-
//# sourceMappingURL=OAuthButton.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OAuthButton.d.ts","sourceRoot":"","sources":["../../src/elements/OAuthButton.tsx"],"names":[],"mappings":"AASA,MAAM,CAAC,OAAO,UAAU,WAAW,CAAC,EAClC,QAAQ,EACR,IAAI,
|
|
1
|
+
{"version":3,"file":"OAuthButton.d.ts","sourceRoot":"","sources":["../../src/elements/OAuthButton.tsx"],"names":[],"mappings":"AASA,MAAM,CAAC,OAAO,UAAU,WAAW,CAAC,EAClC,QAAQ,EACR,IAAI,GACL,EAAE;IACD,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,QAAQ,GAAG,QAAQ,CAAC;CAC3B,2CAuGA"}
|
|
@@ -5,7 +5,7 @@ import { useStackApp } from '..';
|
|
|
5
5
|
import { runAsynchronously } from "@stackframe/stack-shared/dist/utils/promises";
|
|
6
6
|
import Button from './Button';
|
|
7
7
|
const iconSize = 24;
|
|
8
|
-
export default function OAuthButton({ provider, type,
|
|
8
|
+
export default function OAuthButton({ provider, type, }) {
|
|
9
9
|
const stackApp = useStackApp();
|
|
10
10
|
let style;
|
|
11
11
|
switch (provider) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OAuthGroup.d.ts","sourceRoot":"","sources":["../../src/elements/OAuthGroup.tsx"],"names":[],"mappings":"AAGA,MAAM,CAAC,OAAO,UAAU,UAAU,CAAC,EACjC,IAAI,
|
|
1
|
+
{"version":3,"file":"OAuthGroup.d.ts","sourceRoot":"","sources":["../../src/elements/OAuthGroup.tsx"],"names":[],"mappings":"AAGA,MAAM,CAAC,OAAO,UAAU,UAAU,CAAC,EACjC,IAAI,GACL,EAAE;IACD,IAAI,EAAE,QAAQ,GAAG,QAAQ,CAAC;CAC3B,2CAWA"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { useStackApp } from "..";
|
|
3
3
|
import OAuthButton from "./OAuthButton";
|
|
4
|
-
export default function OAuthGroup({ type,
|
|
4
|
+
export default function OAuthGroup({ type, }) {
|
|
5
5
|
const stackApp = useStackApp();
|
|
6
6
|
const project = stackApp.useProject();
|
|
7
|
-
return (_jsx("div", { className: "wl_space-y-4 wl_flex wl_flex-col wl_items-stretch", children: project.oauthProviders.filter(p => p.enabled).map(p => (_jsx(OAuthButton, { provider: p.id, type: type
|
|
7
|
+
return (_jsx("div", { className: "wl_space-y-4 wl_flex wl_flex-col wl_items-stretch", children: project.oauthProviders.filter(p => p.enabled).map(p => (_jsx(OAuthButton, { provider: p.id, type: type }, p.id))) }));
|
|
8
8
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { useState } from "react";
|
|
4
|
-
import { getPasswordError } from "@stackframe/stack-shared/
|
|
4
|
+
import { getPasswordError } from "@stackframe/stack-shared/dist/helpers/password";
|
|
5
5
|
import { useStackApp } from "..";
|
|
6
6
|
import { PasswordField } from "./PasswordField";
|
|
7
7
|
import { FormWarningText } from "./FormWarning";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RedirectMessageCard.d.ts","sourceRoot":"","sources":["../../src/elements/RedirectMessageCard.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"RedirectMessageCard.d.ts","sourceRoot":"","sources":["../../src/elements/RedirectMessageCard.tsx"],"names":[],"mappings":"AAOA,MAAM,CAAC,OAAO,UAAU,mBAAmB,CAAC,EAC1C,IAAI,EACJ,QAAc,GACf,EAAE;IACD,IAAI,EAAE,UAAU,GAAG,WAAW,GAAG,WAAW,GAAG,eAAe,GAAG,eAAe,CAAC;IACjF,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,2CAwEA"}
|
|
@@ -3,48 +3,53 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
3
3
|
import { useRouter } from "next/navigation";
|
|
4
4
|
import { useStackApp } from "..";
|
|
5
5
|
import MessageCard from "./MessageCard";
|
|
6
|
+
import Button from "./Button";
|
|
6
7
|
export default function RedirectMessageCard({ type, fullPage = false, }) {
|
|
7
8
|
const stackApp = useStackApp();
|
|
8
9
|
const router = useRouter();
|
|
9
10
|
let title;
|
|
10
|
-
let
|
|
11
|
+
let primaryUrl;
|
|
12
|
+
let secondaryUrl = null;
|
|
11
13
|
let message = null;
|
|
12
|
-
let
|
|
14
|
+
let primaryButton;
|
|
15
|
+
let secondaryButton = null;
|
|
13
16
|
switch (type) {
|
|
14
17
|
case 'signedIn': {
|
|
15
18
|
title = "You are already signed in";
|
|
16
|
-
message = 'You are already signed in.
|
|
17
|
-
|
|
18
|
-
|
|
19
|
+
message = 'You are already signed in.';
|
|
20
|
+
primaryUrl = stackApp.urls.home;
|
|
21
|
+
secondaryUrl = stackApp.urls.signOut;
|
|
22
|
+
primaryButton = "Go to Home";
|
|
23
|
+
secondaryButton = "Sign Out";
|
|
19
24
|
break;
|
|
20
25
|
}
|
|
21
26
|
case 'signedOut': {
|
|
22
27
|
title = "You are not currently signed in.";
|
|
23
|
-
|
|
24
|
-
|
|
28
|
+
primaryUrl = stackApp.urls.home;
|
|
29
|
+
primaryButton = "Go to Home";
|
|
25
30
|
break;
|
|
26
31
|
}
|
|
27
32
|
case 'emailSent': {
|
|
28
33
|
title = "Email sent!";
|
|
29
34
|
message = 'Please check your inbox. Make sure to check your spam folder.';
|
|
30
|
-
|
|
31
|
-
|
|
35
|
+
primaryUrl = stackApp.urls.home;
|
|
36
|
+
primaryButton = "Go to Home";
|
|
32
37
|
break;
|
|
33
38
|
}
|
|
34
39
|
case 'passwordReset': {
|
|
35
40
|
title = "Password reset successfully!";
|
|
36
41
|
message = 'Your password has been reset. You can now sign in with your new password.';
|
|
37
|
-
|
|
38
|
-
|
|
42
|
+
primaryUrl = stackApp.urls.signIn;
|
|
43
|
+
primaryButton = "Go to Sign In";
|
|
39
44
|
break;
|
|
40
45
|
}
|
|
41
46
|
case 'emailVerified': {
|
|
42
47
|
title = "Email verified!";
|
|
43
48
|
message = 'Your have successfully verified your email.';
|
|
44
|
-
|
|
45
|
-
|
|
49
|
+
primaryUrl = stackApp.urls.home;
|
|
50
|
+
primaryButton = "Go to Home";
|
|
46
51
|
break;
|
|
47
52
|
}
|
|
48
53
|
}
|
|
49
|
-
return (_jsxs(MessageCard, { title: title, fullPage: fullPage, children: [message && _jsx("p", { className: 'wl_mb-8', children: message }),
|
|
54
|
+
return (_jsxs(MessageCard, { title: title, fullPage: fullPage, children: [message && _jsx("p", { className: 'wl_mb-8', children: message }), _jsxs("div", { className: 'wl_flex wl_flex-row wl_align-center wl_justify-center wl_gap-4', children: [secondaryButton && (_jsx(Button, { className: 'wl_btn_ghost', onClick: () => router.push(stackApp.urls.signOut.toString()), children: secondaryButton })), _jsx(Button, { className: 'wl_btn wl_btn-primary', onClick: () => router.push(primaryUrl.toString()), children: primaryButton })] })] }));
|
|
50
55
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -8,4 +8,3 @@ export { default as EmailVerification } from "./components/EmailVerification";
|
|
|
8
8
|
export { default as PasswordReset } from "./components/PasswordReset";
|
|
9
9
|
export { default as ForgotPassword } from "./components/ForgotPassword";
|
|
10
10
|
import '../dist/tailwind.css';
|
|
11
|
-
//# sourceMappingURL=index.d.ts.map
|
package/dist/lib/auth.d.ts
CHANGED
|
@@ -1,20 +1,7 @@
|
|
|
1
1
|
import { StackClientInterface } from "@stackframe/stack-shared";
|
|
2
2
|
import { TokenStore } from "@stackframe/stack-shared/dist/interface/clientInterface";
|
|
3
|
-
import { SignInErrorCode, SignUpErrorCode } from "@stackframe/stack-shared/dist/utils/types";
|
|
4
3
|
export declare function signInWithOAuth(iface: StackClientInterface, { provider, redirectUrl, }: {
|
|
5
4
|
provider: string;
|
|
6
5
|
redirectUrl?: string;
|
|
7
6
|
}): Promise<void>;
|
|
8
|
-
export declare function callOAuthCallback(iface: StackClientInterface, tokenStore: TokenStore, redirectUrl
|
|
9
|
-
export declare function signInWithCredential(iface: StackClientInterface, tokenStore: TokenStore, { email, password, redirectUrl, }: {
|
|
10
|
-
email: string;
|
|
11
|
-
password: string;
|
|
12
|
-
redirectUrl?: string;
|
|
13
|
-
}): Promise<SignInErrorCode | undefined>;
|
|
14
|
-
export declare function signUpWithCredential(iface: StackClientInterface, tokenStore: TokenStore, { email, password, redirectUrl, emailVerificationRedirectUrl }: {
|
|
15
|
-
email: string;
|
|
16
|
-
password: string;
|
|
17
|
-
redirectUrl?: string;
|
|
18
|
-
emailVerificationRedirectUrl?: string;
|
|
19
|
-
}): Promise<SignUpErrorCode | undefined>;
|
|
20
|
-
//# sourceMappingURL=auth.d.ts.map
|
|
7
|
+
export declare function callOAuthCallback(iface: StackClientInterface, tokenStore: TokenStore, redirectUrl: string): Promise<import("oauth4webapi").OAuth2TokenEndpointResponse>;
|
package/dist/lib/auth.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../src/lib/auth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAGhE,OAAO,EAAE,UAAU,EAAE,MAAM,yDAAyD,CAAC;
|
|
1
|
+
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../src/lib/auth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAGhE,OAAO,EAAE,UAAU,EAAE,MAAM,yDAAyD,CAAC;AAErF,wBAAsB,eAAe,CACnC,KAAK,EAAE,oBAAoB,EAC3B,EACE,QAAQ,EACR,WAAW,GACZ,EAAG;IACF,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,iBAWF;AAuCD,wBAAsB,iBAAiB,CACrC,KAAK,EAAE,oBAAoB,EAC3B,UAAU,EAAE,UAAU,EACtB,WAAW,EAAE,MAAM,+DA6BpB"}
|
package/dist/lib/auth.js
CHANGED
|
@@ -35,51 +35,27 @@ function consumeOAuthCallbackQueryParams(expectedState) {
|
|
|
35
35
|
// We use history.replaceState instead of location.assign(...) to
|
|
36
36
|
// prevent an unnecessary reload
|
|
37
37
|
window.history.replaceState({}, "", newUrl.toString());
|
|
38
|
-
return
|
|
38
|
+
return originalUrl;
|
|
39
39
|
}
|
|
40
40
|
export async function callOAuthCallback(iface, tokenStore, redirectUrl) {
|
|
41
41
|
// note: this part of the function (until the return) needs
|
|
42
42
|
// to be synchronous, to prevent race conditions when
|
|
43
43
|
// callOAuthCallback is called multiple times in parallel
|
|
44
44
|
const { codeVerifier, state } = getVerifierAndState();
|
|
45
|
-
const
|
|
46
|
-
if (!
|
|
47
|
-
|
|
45
|
+
const originalUrl = consumeOAuthCallbackQueryParams(state);
|
|
46
|
+
if (!originalUrl) {
|
|
47
|
+
throw new Error("Invalid OAuth callback URL");
|
|
48
48
|
}
|
|
49
49
|
if (!codeVerifier || !state) {
|
|
50
|
-
|
|
50
|
+
throw new Error("Invalid OAuth callback URL");
|
|
51
51
|
}
|
|
52
52
|
// the rest can be asynchronous (we now know that we are the
|
|
53
53
|
// intended recipient of the callback)
|
|
54
|
-
const { newUrl, originalUrl } = consumeResult;
|
|
55
|
-
if (!redirectUrl) {
|
|
56
|
-
redirectUrl = newUrl.toString();
|
|
57
|
-
}
|
|
58
|
-
redirectUrl = redirectUrl.split("#")[0]; // remove hash
|
|
59
54
|
try {
|
|
60
|
-
await iface.callOAuthCallback(originalUrl.searchParams, redirectUrl, codeVerifier, state, tokenStore);
|
|
61
|
-
// reload/redirect so the server can update now that the user is signed in
|
|
62
|
-
window.location.assign(redirectUrl);
|
|
55
|
+
return await iface.callOAuthCallback(originalUrl.searchParams, constructRedirectUrl(redirectUrl), codeVerifier, state, tokenStore);
|
|
63
56
|
}
|
|
64
57
|
catch (e) {
|
|
65
58
|
console.error("Error signing in during OAuth callback", e);
|
|
66
59
|
throw new Error("Error signing in. Please try again.");
|
|
67
60
|
}
|
|
68
61
|
}
|
|
69
|
-
export async function signInWithCredential(iface, tokenStore, { email, password, redirectUrl, }) {
|
|
70
|
-
const errorCode = await iface.signInWithCredential(email, password, tokenStore);
|
|
71
|
-
if (!errorCode) {
|
|
72
|
-
redirectUrl = constructRedirectUrl(redirectUrl);
|
|
73
|
-
window.location.assign(redirectUrl);
|
|
74
|
-
}
|
|
75
|
-
return errorCode;
|
|
76
|
-
}
|
|
77
|
-
export async function signUpWithCredential(iface, tokenStore, { email, password, redirectUrl, emailVerificationRedirectUrl = "/" }) {
|
|
78
|
-
emailVerificationRedirectUrl = constructRedirectUrl(emailVerificationRedirectUrl);
|
|
79
|
-
const errorCode = await iface.signUpWithCredential(email, password, emailVerificationRedirectUrl, tokenStore);
|
|
80
|
-
if (!errorCode) {
|
|
81
|
-
redirectUrl = constructRedirectUrl(redirectUrl);
|
|
82
|
-
window.location.assign(redirectUrl);
|
|
83
|
-
}
|
|
84
|
-
return errorCode;
|
|
85
|
-
}
|
package/dist/lib/cookie.d.ts
CHANGED
package/dist/lib/hooks.d.ts
CHANGED
package/dist/lib/stack-app.d.ts
CHANGED
|
@@ -7,13 +7,15 @@ export type TokenStoreOptions<HasTokenStore extends boolean = boolean> = HasToke
|
|
|
7
7
|
export type HandlerUrls = {
|
|
8
8
|
handler: string;
|
|
9
9
|
signIn: string;
|
|
10
|
+
afterSignIn: string;
|
|
10
11
|
signUp: string;
|
|
12
|
+
afterSignUp: string;
|
|
11
13
|
signOut: string;
|
|
14
|
+
afterSignOut: string;
|
|
12
15
|
emailVerification: string;
|
|
13
16
|
passwordReset: string;
|
|
14
17
|
forgotPassword: string;
|
|
15
18
|
home: string;
|
|
16
|
-
userHome: string;
|
|
17
19
|
oauthCallback: string;
|
|
18
20
|
};
|
|
19
21
|
export type StackClientAppConstructorOptions<HasTokenStore extends boolean, ProjectId extends string> = {
|
|
@@ -38,7 +40,7 @@ export declare const stackAppInternalsSymbol: unique symbol;
|
|
|
38
40
|
type Auth<T, C> = {
|
|
39
41
|
readonly tokenStore: ReadonlyTokenStore;
|
|
40
42
|
update(this: T, user: Partial<C>): Promise<void>;
|
|
41
|
-
signOut(this: T
|
|
43
|
+
signOut(this: T): Promise<void>;
|
|
42
44
|
};
|
|
43
45
|
export type User = {
|
|
44
46
|
readonly projectId: string;
|
|
@@ -139,16 +141,12 @@ export type StackClientApp<HasTokenStore extends boolean = boolean, ProjectId ex
|
|
|
139
141
|
signInWithCredential(options: {
|
|
140
142
|
email: string;
|
|
141
143
|
password: string;
|
|
142
|
-
redirectUrl?: string;
|
|
143
144
|
}): Promise<SignInErrorCode | undefined>;
|
|
144
145
|
signUpWithCredential(options: {
|
|
145
146
|
email: string;
|
|
146
147
|
password: string;
|
|
147
|
-
redirectUrl?: string;
|
|
148
148
|
}): Promise<SignUpErrorCode | undefined>;
|
|
149
|
-
callOAuthCallback(
|
|
150
|
-
redirectUrl?: string;
|
|
151
|
-
}): Promise<void>;
|
|
149
|
+
callOAuthCallback(): Promise<void>;
|
|
152
150
|
sendForgotPasswordEmail(email: string): Promise<void>;
|
|
153
151
|
resetPassword(options: {
|
|
154
152
|
code: string;
|
|
@@ -160,7 +158,7 @@ export type StackClientApp<HasTokenStore extends boolean = boolean, ProjectId ex
|
|
|
160
158
|
toClientJson(): Promise<StackClientAppJson<HasTokenStore, ProjectId>>;
|
|
161
159
|
};
|
|
162
160
|
} & AsyncStoreProperty<"project", ClientProjectJson, false> & {
|
|
163
|
-
[K in `redirectTo${Capitalize<keyof Omit<HandlerUrls, 'oauthCallback'>>}`]: () => Promise<never>;
|
|
161
|
+
[K in `redirectTo${Capitalize<keyof Omit<HandlerUrls, 'handler' | 'oauthCallback'>>}`]: () => Promise<never>;
|
|
164
162
|
} & (HasTokenStore extends false ? {} : {
|
|
165
163
|
redirectToOAuthCallback(): Promise<never>;
|
|
166
164
|
useUser(options: GetUserOptions & {
|
|
@@ -204,4 +202,3 @@ type StackAdminAppConstructor = {
|
|
|
204
202
|
};
|
|
205
203
|
export declare const StackAdminApp: StackAdminAppConstructor;
|
|
206
204
|
export {};
|
|
207
|
-
//# sourceMappingURL=stack-app.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stack-app.d.ts","sourceRoot":"","sources":["../../src/lib/stack-app.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,uBAAuB,EAAE,0BAA0B,EAAE,cAAc,EAAmE,MAAM,0BAA0B,CAAC;AAOhL,OAAO,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,QAAQ,EAA2B,WAAW,EAAE,eAAe,EAAE,gBAAgB,EAAE,kBAAkB,EAA2B,mBAAmB,EAAE,MAAM,yDAAyD,CAAC;AAIvQ,OAAO,EAAE,YAAY,EAAE,MAAM,0CAA0C,CAAC;AAExE,OAAO,EAAE,8BAA8B,EAAE,0BAA0B,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,2CAA2C,CAAC;AAIzJ,OAAO,EAAqB,sBAAsB,EAAyC,oBAAoB,EAAE,MAAM,wDAAwD,CAAC;AAIhL,MAAM,MAAM,iBAAiB,CAAC,aAAa,SAAS,OAAO,GAAG,OAAO,IACnE,aAAa,SAAS,IAAI,GAAG,QAAQ,GAAG,eAAe,GAAG,QAAQ,GAClE,aAAa,SAAS,KAAK,GAAG,IAAI,GAClC,iBAAiB,CAAC,IAAI,CAAC,GAAG,iBAAiB,CAAC,KAAK,CAAC,CAAC;AAErD,MAAM,MAAM,WAAW,GAAG;IACxB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,aAAa,EAAE,MAAM,CAAC;IACtB,cAAc,EAAE,MAAM,CAAC;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,
|
|
1
|
+
{"version":3,"file":"stack-app.d.ts","sourceRoot":"","sources":["../../src/lib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AAa,CAAC,aAAa,SAAS,OAAO,GAAG,OAAO,EAAE,SAAS,SAAS,MAAM,GAAG,MAAM,IAAI,CACpG,cAAc,CAAC,aAAa,EAAE,SAAS,CAAC,GACxC,kBAAkB,CAAC,cAAc,EAAE,OAAO,EAAE,KAAK,CAAC,GAClD,kBAAkB,CAAC,YAAY,EAAE,SAAS,EAAE,EAAE,IAAI,CAAC,GACnD;IACA,eAAe,CAAC,OAAO,EAAE,sBAAsB,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAAC;CAC/E,CACF,CAAC;AACF,KAAK,wBAAwB,GAAG;IAC9B,KACE,cAAc,SAAS,MAAM,EAC7B,aAAa,SAAS,CAAC,cAAc,SAAS,EAAE,GAAG,IAAI,GAAG,OAAO,CAAC,EAClE,SAAS,SAAS,MAAM,EACxB,OAAO,EAAE,+BAA+B,CAAC,aAAa,EAAE,SAAS,CAAC,GAAG,aAAa,CAAC,aAAa,EAAE,SAAS,CAAC,CAAC;IAC/G,KAAK,OAAO,EAAE,+BAA+B,CAAC,OAAO,EAAE,MAAM,CAAC,GAAG,aAAa,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;CACjG,CAAC;AACF,eAAO,MAAM,aAAa,EAAE,wBAA6C,CAAC"}
|
package/dist/lib/stack-app.js
CHANGED
|
@@ -8,7 +8,7 @@ import { suspendIfSsr } from "@stackframe/stack-shared/dist/utils/react";
|
|
|
8
8
|
import { AsyncStore } from "@stackframe/stack-shared/dist/utils/stores";
|
|
9
9
|
import { getProductionModeErrors } from "@stackframe/stack-shared/dist/interface/clientInterface";
|
|
10
10
|
import { isClient } from "../utils/next";
|
|
11
|
-
import { callOAuthCallback,
|
|
11
|
+
import { callOAuthCallback, signInWithOAuth } from "./auth";
|
|
12
12
|
import { RedirectType, redirect, useRouter } from "next/navigation";
|
|
13
13
|
import { constructRedirectUrl } from "../utils/url";
|
|
14
14
|
import { filterUndefined } from "@stackframe/stack-shared/dist/utils/objects";
|
|
@@ -20,14 +20,16 @@ function getUrls(partial) {
|
|
|
20
20
|
return {
|
|
21
21
|
handler,
|
|
22
22
|
signIn: `${handler}/signin`,
|
|
23
|
+
afterSignIn: "/",
|
|
23
24
|
signUp: `${handler}/signup`,
|
|
25
|
+
afterSignUp: "/",
|
|
24
26
|
signOut: `${handler}/signout`,
|
|
27
|
+
afterSignOut: "/",
|
|
25
28
|
emailVerification: `${handler}/email-verification`,
|
|
26
29
|
passwordReset: `${handler}/password-reset`,
|
|
27
30
|
forgotPassword: `${handler}/forgot-password`,
|
|
28
31
|
oauthCallback: `${handler}/oauth-callback`,
|
|
29
32
|
home: "/",
|
|
30
|
-
userHome: "/",
|
|
31
33
|
...filterUndefined(partial),
|
|
32
34
|
};
|
|
33
35
|
}
|
|
@@ -122,9 +124,9 @@ function getTokenStore(tokenStoreOptions) {
|
|
|
122
124
|
return (tokenStoreInitializers.get(tokenStoreOptions) ?? throwErr(`Invalid token store ${tokenStoreOptions}`))();
|
|
123
125
|
}
|
|
124
126
|
const loadingSentinel = Symbol("stackAppCacheLoadingSentinel");
|
|
125
|
-
function useCache(cache, dependencies) {
|
|
127
|
+
function useCache(cache, dependencies, caller) {
|
|
126
128
|
// we explicitly don't want to run this hook in SSR
|
|
127
|
-
suspendIfSsr();
|
|
129
|
+
suspendIfSsr(caller);
|
|
128
130
|
const subscribe = useCallback((cb) => {
|
|
129
131
|
const { unsubscribe } = cache.onChange(dependencies, () => cb());
|
|
130
132
|
return unsubscribe;
|
|
@@ -232,8 +234,8 @@ class _StackClientAppImpl {
|
|
|
232
234
|
update(update) {
|
|
233
235
|
return app._updateUser(update, tokenStore);
|
|
234
236
|
},
|
|
235
|
-
signOut(
|
|
236
|
-
return app._signOut(tokenStore
|
|
237
|
+
signOut() {
|
|
238
|
+
return app._signOut(tokenStore);
|
|
237
239
|
},
|
|
238
240
|
};
|
|
239
241
|
Object.freeze(res);
|
|
@@ -302,7 +304,6 @@ class _StackClientAppImpl {
|
|
|
302
304
|
window.location.href = this.urls[handlerName];
|
|
303
305
|
return neverResolve();
|
|
304
306
|
}
|
|
305
|
-
async redirectToHandler() { return await this._redirectTo("handler"); }
|
|
306
307
|
async redirectToSignIn() { return await this._redirectTo("signIn"); }
|
|
307
308
|
async redirectToSignUp() { return await this._redirectTo("signUp"); }
|
|
308
309
|
async redirectToSignOut() { return await this._redirectTo("signOut"); }
|
|
@@ -310,8 +311,10 @@ class _StackClientAppImpl {
|
|
|
310
311
|
async redirectToPasswordReset() { return await this._redirectTo("passwordReset"); }
|
|
311
312
|
async redirectToForgotPassword() { return await this._redirectTo("forgotPassword"); }
|
|
312
313
|
async redirectToHome() { return await this._redirectTo("home"); }
|
|
313
|
-
async redirectToUserHome() { return await this._redirectTo("userHome"); }
|
|
314
314
|
async redirectToOAuthCallback() { return await this._redirectTo("oauthCallback"); }
|
|
315
|
+
async redirectToAfterSignIn() { return await this._redirectTo("afterSignIn"); }
|
|
316
|
+
async redirectToAfterSignUp() { return await this._redirectTo("afterSignUp"); }
|
|
317
|
+
async redirectToAfterSignOut() { return await this._redirectTo("afterSignOut"); }
|
|
315
318
|
async sendForgotPasswordEmail(email) {
|
|
316
319
|
const redirectUrl = constructRedirectUrl(this.urls.passwordReset);
|
|
317
320
|
await this._interface.sendForgotPasswordEmail(email, redirectUrl);
|
|
@@ -349,7 +352,7 @@ class _StackClientAppImpl {
|
|
|
349
352
|
this._ensurePersistentTokenStore();
|
|
350
353
|
const router = useRouter();
|
|
351
354
|
const tokenStore = getTokenStore(this._tokenStoreOptions);
|
|
352
|
-
const userJson = useCache(this._currentUserCache, [tokenStore]);
|
|
355
|
+
const userJson = useCache(this._currentUserCache, [tokenStore], "useUser()");
|
|
353
356
|
if (userJson === null) {
|
|
354
357
|
switch (options?.or) {
|
|
355
358
|
case 'redirect': {
|
|
@@ -384,45 +387,50 @@ class _StackClientAppImpl {
|
|
|
384
387
|
await signInWithOAuth(this._interface, { provider, redirectUrl: this.urls.oauthCallback });
|
|
385
388
|
}
|
|
386
389
|
async signInWithCredential(options) {
|
|
387
|
-
if (!options.redirectUrl) {
|
|
388
|
-
options.redirectUrl = constructRedirectUrl(options.redirectUrl);
|
|
389
|
-
}
|
|
390
390
|
this._ensurePersistentTokenStore();
|
|
391
391
|
const tokenStore = getTokenStore(this._tokenStoreOptions);
|
|
392
|
-
|
|
392
|
+
const errorCode = await this._interface.signInWithCredential(options.email, options.password, tokenStore);
|
|
393
|
+
if (!errorCode) {
|
|
394
|
+
window.location.assign(this.urls.afterSignIn);
|
|
395
|
+
}
|
|
396
|
+
return errorCode;
|
|
393
397
|
}
|
|
394
398
|
async signUpWithCredential(options) {
|
|
395
|
-
if (!options.redirectUrl) {
|
|
396
|
-
options.redirectUrl = constructRedirectUrl(options.redirectUrl);
|
|
397
|
-
}
|
|
398
399
|
this._ensurePersistentTokenStore();
|
|
399
400
|
const tokenStore = getTokenStore(this._tokenStoreOptions);
|
|
400
|
-
|
|
401
|
+
const emailVerificationRedirectUrl = constructRedirectUrl(this.urls.emailVerification);
|
|
402
|
+
const errorCode = await this._interface.signUpWithCredential(options.email, options.password, emailVerificationRedirectUrl, tokenStore);
|
|
403
|
+
if (!errorCode) {
|
|
404
|
+
window.location.assign(this.urls.afterSignUp);
|
|
405
|
+
}
|
|
406
|
+
return errorCode;
|
|
401
407
|
}
|
|
402
|
-
async callOAuthCallback(
|
|
408
|
+
async callOAuthCallback() {
|
|
403
409
|
this._ensurePersistentTokenStore();
|
|
404
410
|
const tokenStore = getTokenStore(this._tokenStoreOptions);
|
|
405
|
-
await callOAuthCallback(this._interface, tokenStore,
|
|
411
|
+
const result = await callOAuthCallback(this._interface, tokenStore, this.urls.oauthCallback);
|
|
412
|
+
if (result.newUser) {
|
|
413
|
+
await window.location.replace(this.urls.afterSignUp);
|
|
414
|
+
}
|
|
415
|
+
else {
|
|
416
|
+
await window.location.replace(this.urls.afterSignIn);
|
|
417
|
+
}
|
|
406
418
|
}
|
|
407
|
-
async _signOut(tokenStore
|
|
408
|
-
redirectUrl = constructRedirectUrl(redirectUrl);
|
|
419
|
+
async _signOut(tokenStore) {
|
|
409
420
|
await this._interface.signOut(tokenStore);
|
|
410
|
-
window.location.assign(
|
|
411
|
-
return await neverResolve();
|
|
421
|
+
window.location.assign(this.urls.afterSignOut);
|
|
412
422
|
}
|
|
413
|
-
async signOut(
|
|
423
|
+
async signOut() {
|
|
414
424
|
const user = await this.getUser();
|
|
415
425
|
if (user) {
|
|
416
|
-
await user.signOut(
|
|
426
|
+
await user.signOut();
|
|
417
427
|
}
|
|
418
|
-
window.location.assign(redirectUrl);
|
|
419
|
-
return await neverResolve();
|
|
420
428
|
}
|
|
421
429
|
async getProject() {
|
|
422
430
|
return await this._currentProjectCache.getOrWait([], "never");
|
|
423
431
|
}
|
|
424
432
|
useProject() {
|
|
425
|
-
return useCache(this._currentProjectCache, []);
|
|
433
|
+
return useCache(this._currentProjectCache, [], "useProject()");
|
|
426
434
|
}
|
|
427
435
|
onProjectChange(callback) {
|
|
428
436
|
return this._currentProjectCache.onChange([], callback);
|
|
@@ -436,7 +444,7 @@ class _StackClientAppImpl {
|
|
|
436
444
|
useOwnedProjects() {
|
|
437
445
|
this._ensureInternalProject();
|
|
438
446
|
const tokenStore = getTokenStore(this._tokenStoreOptions);
|
|
439
|
-
const json = useCache(this._ownedProjectsCache, [tokenStore]);
|
|
447
|
+
const json = useCache(this._ownedProjectsCache, [tokenStore], "useOwnedProjects()");
|
|
440
448
|
return json.map((j) => this._projectAdminFromJson(j, this._createAdminInterface(j.id, tokenStore), () => this._refreshOwnedProjects(tokenStore)));
|
|
441
449
|
}
|
|
442
450
|
onOwnedProjectsChange(callback) {
|
|
@@ -577,8 +585,8 @@ class _StackServerAppImpl extends _StackClientAppImpl {
|
|
|
577
585
|
await app._refreshUser(tokenStore);
|
|
578
586
|
return res;
|
|
579
587
|
},
|
|
580
|
-
signOut(
|
|
581
|
-
return app._signOut(tokenStore
|
|
588
|
+
signOut() {
|
|
589
|
+
return app._signOut(tokenStore);
|
|
582
590
|
},
|
|
583
591
|
getClientUser() {
|
|
584
592
|
return app._currentUserFromJson(json, tokenStore);
|
|
@@ -609,7 +617,7 @@ class _StackServerAppImpl extends _StackClientAppImpl {
|
|
|
609
617
|
useServerUser(options) {
|
|
610
618
|
this._ensurePersistentTokenStore();
|
|
611
619
|
const tokenStore = getTokenStore(this._tokenStoreOptions);
|
|
612
|
-
const userJson = useCache(this._currentServerUserCache, [tokenStore]);
|
|
620
|
+
const userJson = useCache(this._currentServerUserCache, [tokenStore], "useServerUser()");
|
|
613
621
|
if (options?.required && userJson === null) {
|
|
614
622
|
use(this.redirectToSignIn());
|
|
615
623
|
}
|
|
@@ -627,7 +635,7 @@ class _StackServerAppImpl extends _StackClientAppImpl {
|
|
|
627
635
|
return json.map((j) => this._serverUserFromJson(j));
|
|
628
636
|
}
|
|
629
637
|
useServerUsers() {
|
|
630
|
-
const json = useCache(this._serverUsersCache, []);
|
|
638
|
+
const json = useCache(this._serverUsersCache, [], "useServerUsers()");
|
|
631
639
|
return json.map((j) => this._serverUserFromJson(j));
|
|
632
640
|
}
|
|
633
641
|
onServerUsersChange(callback) {
|
|
@@ -717,7 +725,7 @@ class _StackAdminAppImpl extends _StackServerAppImpl {
|
|
|
717
725
|
return this._projectAdminFromJson(await this._adminProjectCache.getOrWait([], "never"), this._interface, () => this._refreshProject());
|
|
718
726
|
}
|
|
719
727
|
useProjectAdmin() {
|
|
720
|
-
return this._projectAdminFromJson(useCache(this._adminProjectCache, []), this._interface, () => this._refreshProject());
|
|
728
|
+
return this._projectAdminFromJson(useCache(this._adminProjectCache, [], "useProjectAdmin()"), this._interface, () => this._refreshProject());
|
|
721
729
|
}
|
|
722
730
|
onProjectAdminChange(callback) {
|
|
723
731
|
return this._adminProjectCache.onChange([], (project) => {
|
|
@@ -729,7 +737,7 @@ class _StackAdminAppImpl extends _StackServerAppImpl {
|
|
|
729
737
|
return json.map((j) => this._createApiKeySetFromJson(j));
|
|
730
738
|
}
|
|
731
739
|
useApiKeySets() {
|
|
732
|
-
const json = useCache(this._apiKeySetsCache, []);
|
|
740
|
+
const json = useCache(this._apiKeySetsCache, [], "useApiKeySets()");
|
|
733
741
|
return json.map((j) => this._createApiKeySetFromJson(j));
|
|
734
742
|
}
|
|
735
743
|
onApiKeySetsChange(callback) {
|
package/dist/tailwind.css
CHANGED
|
@@ -1190,6 +1190,9 @@ video:where(.stack-scope,.stack-scope *) {
|
|
|
1190
1190
|
.wl_flex-grow {
|
|
1191
1191
|
flex-grow: 1;
|
|
1192
1192
|
}
|
|
1193
|
+
.wl_flex-row {
|
|
1194
|
+
flex-direction: row;
|
|
1195
|
+
}
|
|
1193
1196
|
.wl_flex-col {
|
|
1194
1197
|
flex-direction: column;
|
|
1195
1198
|
}
|
|
@@ -1205,6 +1208,9 @@ video:where(.stack-scope,.stack-scope *) {
|
|
|
1205
1208
|
.wl_justify-between {
|
|
1206
1209
|
justify-content: space-between;
|
|
1207
1210
|
}
|
|
1211
|
+
.wl_gap-4 {
|
|
1212
|
+
gap: 1rem;
|
|
1213
|
+
}
|
|
1208
1214
|
.wl_space-y-2 > :not([hidden]) ~ :not([hidden]) {
|
|
1209
1215
|
--tw-space-y-reverse: 0;
|
|
1210
1216
|
margin-top: calc(0.5rem * calc(1 - var(--tw-space-y-reverse)));
|
package/dist/utils/email.d.ts
CHANGED
package/dist/utils/next.d.ts
CHANGED
package/dist/utils/react.d.ts
CHANGED
package/dist/utils/results.d.ts
CHANGED
|
@@ -22,4 +22,3 @@ declare function promiseToResult<T, E = unknown>(promise: Promise<T>): Promise<R
|
|
|
22
22
|
declare function mapResult<T, U, E = unknown, P = unknown>(result: Result<T, E>, fn: (data: T) => U): Result<U, E>;
|
|
23
23
|
declare function mapResult<T, U, E = unknown, P = unknown>(result: AsyncResult<T, E, P>, fn: (data: T) => U): AsyncResult<U, E, P>;
|
|
24
24
|
export {};
|
|
25
|
-
//# sourceMappingURL=results.d.ts.map
|
package/dist/utils/url.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stackframe/stack",
|
|
3
|
-
"version": "
|
|
4
|
-
"main": "./dist/index.js",
|
|
5
|
-
"types": "./dist/index.d.ts",
|
|
3
|
+
"version": "2.0.0",
|
|
6
4
|
"type": "module",
|
|
5
|
+
"types": "./dist/index.d.ts",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
7
|
"files": [
|
|
8
8
|
"dist"
|
|
9
9
|
],
|
|
@@ -13,11 +13,11 @@
|
|
|
13
13
|
"react-icons": "^5.0.1",
|
|
14
14
|
"tailwindcss-scoped-preflight": "^2.1.0",
|
|
15
15
|
"server-only": "^0.0.1",
|
|
16
|
-
"@stackframe/stack-
|
|
17
|
-
"@stackframe/stack-
|
|
16
|
+
"@stackframe/stack-shared": "2.0.0",
|
|
17
|
+
"@stackframe/stack-sc": "1.2.1"
|
|
18
18
|
},
|
|
19
19
|
"peerDependencies": {
|
|
20
|
-
"next": "^14",
|
|
20
|
+
"next": "^14.1",
|
|
21
21
|
"react": "^18.2.0"
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|