@stackframe/stack 1.1.1 → 1.2.1
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 +1 -0
- package/dist/components/ForgotPassword.d.ts +1 -0
- package/dist/components/OAuthCallback.d.ts +2 -0
- package/dist/components/OAuthCallback.d.ts.map +1 -0
- package/dist/components/{OauthCallback.js → OAuthCallback.js} +2 -2
- package/dist/components/PasswordReset.d.ts +1 -0
- package/dist/components/PasswordReset.d.ts.map +1 -1
- package/dist/components/PasswordReset.js +5 -5
- package/dist/components/SignIn.d.ts +1 -0
- package/dist/components/SignIn.d.ts.map +1 -1
- package/dist/components/SignIn.js +5 -3
- package/dist/components/SignOut.d.ts +1 -0
- package/dist/components/SignUp.d.ts +1 -0
- package/dist/components/SignUp.d.ts.map +1 -1
- package/dist/components/SignUp.js +4 -3
- package/dist/components/StackHandler.d.ts +1 -0
- package/dist/components/StackHandler.js +2 -2
- package/dist/elements/Button.d.ts +1 -0
- package/dist/elements/CardFrame.d.ts +1 -0
- package/dist/elements/CardHeader.d.ts +1 -0
- package/dist/elements/CredentialSignIn.d.ts +1 -0
- package/dist/elements/CredentialSignUp.d.ts +1 -0
- package/dist/elements/CredentialSignUp.js +1 -1
- package/dist/elements/DividerWithText.d.ts +1 -0
- package/dist/elements/ForgotPassword.d.ts +1 -0
- package/dist/elements/FormWarning.d.ts +1 -0
- package/dist/elements/MessageCard.d.ts +1 -0
- package/dist/elements/{OauthButton.d.ts → OAuthButton.d.ts} +2 -1
- package/dist/elements/OAuthButton.d.ts.map +1 -0
- package/dist/elements/{OauthButton.js → OAuthButton.js} +2 -2
- package/dist/elements/OAuthGroup.d.ts +5 -0
- package/dist/elements/OAuthGroup.d.ts.map +1 -0
- package/dist/elements/OAuthGroup.js +8 -0
- package/dist/elements/PasswordField.d.ts +1 -0
- package/dist/elements/PasswordResetInner.d.ts +1 -0
- package/dist/elements/PasswordResetInner.js +1 -1
- package/dist/elements/RedirectMessageCard.d.ts +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -1
- package/dist/lib/auth.d.ts +3 -2
- package/dist/lib/auth.js +8 -8
- package/dist/lib/cookie.d.ts +1 -0
- package/dist/lib/hooks.d.ts +1 -0
- package/dist/lib/stack-app.d.ts +69 -34
- package/dist/lib/stack-app.d.ts.map +1 -1
- package/dist/lib/stack-app.js +252 -70
- package/dist/providers/StackProvider.d.ts +1 -0
- package/dist/providers/StackProviderClient.d.ts +1 -0
- package/dist/utils/email.d.ts +1 -0
- package/dist/utils/next.d.ts +1 -0
- package/dist/utils/react.d.ts +1 -0
- package/dist/utils/results.d.ts +1 -0
- package/dist/utils/types.d.ts +1 -0
- package/dist/utils/url.d.ts +1 -0
- package/package.json +3 -3
- package/dist/components/OauthCallback.d.ts +0 -1
- package/dist/components/OauthCallback.d.ts.map +0 -1
- package/dist/elements/OauthButton.d.ts.map +0 -1
- package/dist/elements/OauthGroup.d.ts +0 -4
- package/dist/elements/OauthGroup.d.ts.map +0 -1
- package/dist/elements/OauthGroup.js +0 -11
- package/dist/lib/cookie-server.d.ts +0 -2
- package/dist/lib/cookie-server.d.ts.map +0 -1
- package/dist/lib/cookie-server.js +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OAuthCallback.d.ts","sourceRoot":"","sources":["../../src/components/OAuthCallback.tsx"],"names":[],"mappings":"AAOA,MAAM,CAAC,OAAO,UAAU,aAAa,4CAapC"}
|
|
@@ -5,7 +5,7 @@ import { useStackApp } from "..";
|
|
|
5
5
|
import { runAsynchronously } from "@stackframe/stack-shared/dist/utils/promises";
|
|
6
6
|
import MessageCard from "../elements/MessageCard";
|
|
7
7
|
import { useRouter } from "next/navigation";
|
|
8
|
-
export default function
|
|
8
|
+
export default function OAuthCallback() {
|
|
9
9
|
const app = useStackApp();
|
|
10
10
|
const router = useRouter();
|
|
11
11
|
const called = useRef(false);
|
|
@@ -13,7 +13,7 @@ export default function OauthCallback() {
|
|
|
13
13
|
if (called.current)
|
|
14
14
|
return;
|
|
15
15
|
called.current = true;
|
|
16
|
-
await app.
|
|
16
|
+
await app.callOAuthCallback();
|
|
17
17
|
router.push(app.urls.userHome);
|
|
18
18
|
}), []);
|
|
19
19
|
return _jsx(MessageCard, { title: 'Redirecting...', fullPage: true });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PasswordReset.d.ts","sourceRoot":"","sources":["../../src/components/PasswordReset.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"PasswordReset.d.ts","sourceRoot":"","sources":["../../src/components/PasswordReset.tsx"],"names":[],"mappings":"AAaA,MAAM,CAAC,OAAO,UAAU,aAAa,CAAC,EACpC,YAAY,EACZ,QAAgB,GACjB,EAAE;IACD,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACtC,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,2CA0CA"}
|
|
@@ -5,7 +5,10 @@ import { useStackApp } from "..";
|
|
|
5
5
|
import { use } from "react";
|
|
6
6
|
import PasswordResetInner from "../elements/PasswordResetInner";
|
|
7
7
|
import { PasswordResetLinkExpiredErrorCode, PasswordResetLinkInvalidErrorCode, PasswordResetLinkUsedErrorCode } from "@stackframe/stack-shared/dist/utils/types";
|
|
8
|
-
import {
|
|
8
|
+
import { cacheFunction } from "@stackframe/stack-shared/dist/utils/caches";
|
|
9
|
+
const cachedVerifyPasswordResetCode = cacheFunction(async (stackApp, code) => {
|
|
10
|
+
return await stackApp.verifyPasswordResetCode(code);
|
|
11
|
+
});
|
|
9
12
|
export default function PasswordReset({ searchParams, fullPage = false, }) {
|
|
10
13
|
const stackApp = useStackApp();
|
|
11
14
|
const invalidJsx = (_jsx(MessageCard, { title: "Invalid Password Reset Link", fullPage: fullPage, children: _jsx("p", { children: "Please check if you have the correct password reset link. If you continue to have issues, please contact support." }) }));
|
|
@@ -15,10 +18,7 @@ export default function PasswordReset({ searchParams, fullPage = false, }) {
|
|
|
15
18
|
if (!code) {
|
|
16
19
|
return invalidJsx;
|
|
17
20
|
}
|
|
18
|
-
const
|
|
19
|
-
return stackApp.verifyPasswordResetCode(code);
|
|
20
|
-
}, [code]);
|
|
21
|
-
const errorCode = use(errorCdoePromise);
|
|
21
|
+
const errorCode = use(cachedVerifyPasswordResetCode(stackApp, code));
|
|
22
22
|
switch (errorCode) {
|
|
23
23
|
case PasswordResetLinkInvalidErrorCode: {
|
|
24
24
|
return invalidJsx;
|
|
@@ -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,WAAW,EAAE,QAAc,EAAE,EAAE;IAAE,WAAW,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,OAAO,CAAA;CAAE,
|
|
1
|
+
{"version":3,"file":"SignIn.d.ts","sourceRoot":"","sources":["../../src/components/SignIn.tsx"],"names":[],"mappings":"AAWA,MAAM,CAAC,OAAO,UAAU,MAAM,CAAC,EAAE,WAAW,EAAE,QAAc,EAAE,EAAE;IAAE,WAAW,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,OAAO,CAAA;CAAE,2CA2B3G"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
3
|
import NextLink from 'next/link';
|
|
4
4
|
import CredentialSignIn from '../elements/CredentialSignIn';
|
|
5
5
|
import DividerWithText from '../elements/DividerWithText';
|
|
6
|
-
import
|
|
6
|
+
import OAuthGroup from '../elements/OAuthGroup';
|
|
7
7
|
import CardFrame from '../elements/CardFrame';
|
|
8
8
|
import CardHeader from '../elements/CardHeader';
|
|
9
9
|
import { useUser, useStackApp } from '..';
|
|
@@ -11,8 +11,10 @@ import RedirectMessageCard from '../elements/RedirectMessageCard';
|
|
|
11
11
|
export default function SignIn({ redirectUrl, fullPage = false }) {
|
|
12
12
|
const stackApp = useStackApp();
|
|
13
13
|
const user = useUser();
|
|
14
|
+
const project = stackApp.useProject();
|
|
14
15
|
if (user) {
|
|
15
16
|
return _jsx(RedirectMessageCard, { type: 'signedIn', fullPage: fullPage });
|
|
16
17
|
}
|
|
17
|
-
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(
|
|
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', redirectUrl: redirectUrl }), project.credentialEnabled &&
|
|
19
|
+
_jsxs(_Fragment, { children: [_jsx(DividerWithText, { text: 'OR' }), _jsx(CredentialSignIn, { redirectUrl: redirectUrl })] })] }));
|
|
18
20
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SignUp.d.ts","sourceRoot":"","sources":["../../src/components/SignUp.tsx"],"names":[],"mappings":"AAWA,MAAM,CAAC,OAAO,UAAU,MAAM,CAAC,EAAE,WAAW,EAAE,QAAc,EAAE,EAAE;IAAE,WAAW,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,OAAO,CAAA;CAAE,
|
|
1
|
+
{"version":3,"file":"SignUp.d.ts","sourceRoot":"","sources":["../../src/components/SignUp.tsx"],"names":[],"mappings":"AAWA,MAAM,CAAC,OAAO,UAAU,MAAM,CAAC,EAAE,WAAW,EAAE,QAAc,EAAE,EAAE;IAAE,WAAW,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,OAAO,CAAA;CAAE,2CA0B3G"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
3
|
import NextLink from 'next/link';
|
|
4
4
|
import DividerWithText from '../elements/DividerWithText';
|
|
5
|
-
import
|
|
5
|
+
import OAuthGroup from '../elements/OAuthGroup';
|
|
6
6
|
import CardFrame from '../elements/CardFrame';
|
|
7
7
|
import CredentialSignUp from '../elements/CredentialSignUp';
|
|
8
8
|
import CardHeader from '../elements/CardHeader';
|
|
@@ -11,8 +11,9 @@ import RedirectMessageCard from '../elements/RedirectMessageCard';
|
|
|
11
11
|
export default function SignUp({ redirectUrl, fullPage = false }) {
|
|
12
12
|
const stackApp = useStackApp();
|
|
13
13
|
const user = useUser();
|
|
14
|
+
const project = stackApp.useProject();
|
|
14
15
|
if (user) {
|
|
15
16
|
return _jsx(RedirectMessageCard, { type: 'signedIn', fullPage: fullPage });
|
|
16
17
|
}
|
|
17
|
-
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(
|
|
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', redirectUrl: redirectUrl }), project.credentialEnabled && _jsxs(_Fragment, { children: [_jsx(DividerWithText, { text: 'OR' }), _jsx(CredentialSignUp, { redirectUrl: redirectUrl })] })] }));
|
|
18
19
|
}
|
|
@@ -7,7 +7,7 @@ import { PasswordReset } from "..";
|
|
|
7
7
|
import MessageCard from "../elements/MessageCard";
|
|
8
8
|
import Signout from "./SignOut";
|
|
9
9
|
import ForgotPassword from "./ForgotPassword";
|
|
10
|
-
import
|
|
10
|
+
import OAuthCallback from "./OAuthCallback";
|
|
11
11
|
export default async function StackHandler({ app, params: { stack } = {}, searchParams = {}, }) {
|
|
12
12
|
if (!stack) {
|
|
13
13
|
return (_jsx(MessageCard, { title: "Invalid Stack Handler Setup", fullPage: true, children: _jsx("p", { children: "Can't use Stack handler at this location. Make sure that the file is in a folder called [...stack]." }) }));
|
|
@@ -49,7 +49,7 @@ export default async function StackHandler({ app, params: { stack } = {}, search
|
|
|
49
49
|
}
|
|
50
50
|
case 'oauth-callback': {
|
|
51
51
|
redirectIfNotHandler('oauthCallback');
|
|
52
|
-
return _jsx(
|
|
52
|
+
return _jsx(OAuthCallback, {});
|
|
53
53
|
}
|
|
54
54
|
default: {
|
|
55
55
|
return notFound();
|
|
@@ -4,7 +4,7 @@ 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";
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
export default function
|
|
1
|
+
export default function OAuthButton({ provider, type, redirectUrl }: {
|
|
2
2
|
provider: string;
|
|
3
3
|
type: 'signin' | 'signup';
|
|
4
4
|
redirectUrl?: string;
|
|
5
5
|
}): import("react/jsx-runtime").JSX.Element;
|
|
6
|
+
//# sourceMappingURL=OAuthButton.d.ts.map
|
|
@@ -0,0 +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,EACJ,WAAW,EACZ,EAAE;IACD,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,QAAQ,GAAG,QAAQ,CAAC;IAC1B,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,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
|
|
8
|
+
export default function OAuthButton({ provider, type, redirectUrl }) {
|
|
9
9
|
const stackApp = useStackApp();
|
|
10
10
|
let style;
|
|
11
11
|
switch (provider) {
|
|
@@ -63,5 +63,5 @@ export default function OauthButton({ provider, type, redirectUrl }) {
|
|
|
63
63
|
};
|
|
64
64
|
}
|
|
65
65
|
}
|
|
66
|
-
return (_jsxs(Button, { style: { backgroundColor: style.backgroundColor, color: style.textColor }, onClick: () => runAsynchronously(stackApp.
|
|
66
|
+
return (_jsxs(Button, { style: { backgroundColor: style.backgroundColor, color: style.textColor }, onClick: () => runAsynchronously(stackApp.signInWithOAuth(provider)), leftIcon: style.icon, children: [type === 'signup' ? 'Sign up with ' : 'Sign in with ', style.name] }));
|
|
67
67
|
}
|
|
@@ -0,0 +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,EACJ,WAAW,EACZ,EAAE;IACD,IAAI,EAAE,QAAQ,GAAG,QAAQ,CAAC;IAC1B,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,2CAWA"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useStackApp } from "..";
|
|
3
|
+
import OAuthButton from "./OAuthButton";
|
|
4
|
+
export default function OAuthGroup({ type, redirectUrl }) {
|
|
5
|
+
const stackApp = useStackApp();
|
|
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, redirectUrl: redirectUrl }, p.id))) }));
|
|
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";
|
package/dist/index.d.ts
CHANGED
|
@@ -7,5 +7,5 @@ export { default as StackHandler } from "./components/StackHandler";
|
|
|
7
7
|
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
|
-
export { validateEmail } from "./utils/email";
|
|
11
10
|
import '../dist/tailwind.css';
|
|
11
|
+
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAErE,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhF,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACpE,OAAO,EAAE,OAAO,IAAI,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AAC9E,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,4BAA4B,CAAC;AACtE,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,6BAA6B,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAErE,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhF,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACpE,OAAO,EAAE,OAAO,IAAI,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AAC9E,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,4BAA4B,CAAC;AACtE,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAGxE,OAAO,sBAAsB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -7,6 +7,5 @@ export { default as StackHandler } from "./components/StackHandler";
|
|
|
7
7
|
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
|
-
export { validateEmail } from "./utils/email";
|
|
11
10
|
// TODO we can't import it like this
|
|
12
11
|
import '../dist/tailwind.css';
|
package/dist/lib/auth.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { StackClientInterface } from "@stackframe/stack-shared";
|
|
2
2
|
import { TokenStore } from "@stackframe/stack-shared/dist/interface/clientInterface";
|
|
3
3
|
import { SignInErrorCode, SignUpErrorCode } from "@stackframe/stack-shared/dist/utils/types";
|
|
4
|
-
export declare function
|
|
4
|
+
export declare function signInWithOAuth(iface: StackClientInterface, { provider, redirectUrl, }: {
|
|
5
5
|
provider: string;
|
|
6
6
|
redirectUrl?: string;
|
|
7
7
|
}): Promise<void>;
|
|
8
|
-
export declare function
|
|
8
|
+
export declare function callOAuthCallback(iface: StackClientInterface, tokenStore: TokenStore, redirectUrl?: string): Promise<void>;
|
|
9
9
|
export declare function signInWithCredential(iface: StackClientInterface, tokenStore: TokenStore, { email, password, redirectUrl, }: {
|
|
10
10
|
email: string;
|
|
11
11
|
password: string;
|
|
@@ -17,3 +17,4 @@ export declare function signUpWithCredential(iface: StackClientInterface, tokenS
|
|
|
17
17
|
redirectUrl?: string;
|
|
18
18
|
emailVerificationRedirectUrl?: string;
|
|
19
19
|
}): Promise<SignUpErrorCode | undefined>;
|
|
20
|
+
//# sourceMappingURL=auth.d.ts.map
|
package/dist/lib/auth.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { saveVerifierAndState, getVerifierAndState } from "./cookie";
|
|
2
2
|
import { constructRedirectUrl } from "../utils/url";
|
|
3
|
-
export async function
|
|
3
|
+
export async function signInWithOAuth(iface, { provider, redirectUrl, }) {
|
|
4
4
|
redirectUrl = constructRedirectUrl(redirectUrl);
|
|
5
5
|
const { codeChallenge, state } = await saveVerifierAndState();
|
|
6
|
-
const location = await iface.
|
|
6
|
+
const location = await iface.getOAuthUrl(provider, redirectUrl, codeChallenge, state);
|
|
7
7
|
window.location.assign(location);
|
|
8
8
|
}
|
|
9
9
|
/**
|
|
10
10
|
* Checks if the current URL has the query parameters for an OAuth callback, and if so, removes them.
|
|
11
11
|
*
|
|
12
|
-
* Must be synchronous for the logic in
|
|
12
|
+
* Must be synchronous for the logic in callOAuthCallback to work without race conditions.
|
|
13
13
|
*/
|
|
14
|
-
function
|
|
14
|
+
function consumeOAuthCallbackQueryParams(expectedState) {
|
|
15
15
|
const requiredParams = ["code", "state"];
|
|
16
16
|
const originalUrl = new URL(window.location.href);
|
|
17
17
|
for (const param of requiredParams) {
|
|
@@ -37,12 +37,12 @@ function consumeOauthCallbackQueryParams(expectedState) {
|
|
|
37
37
|
window.history.replaceState({}, "", newUrl.toString());
|
|
38
38
|
return { newUrl, originalUrl };
|
|
39
39
|
}
|
|
40
|
-
export async function
|
|
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 consumeResult =
|
|
45
|
+
const consumeResult = consumeOAuthCallbackQueryParams(state);
|
|
46
46
|
if (!consumeResult) {
|
|
47
47
|
return;
|
|
48
48
|
}
|
|
@@ -57,7 +57,7 @@ export async function callOauthCallback(iface, tokenStore, redirectUrl) {
|
|
|
57
57
|
}
|
|
58
58
|
redirectUrl = redirectUrl.split("#")[0]; // remove hash
|
|
59
59
|
try {
|
|
60
|
-
await iface.
|
|
60
|
+
await iface.callOAuthCallback(originalUrl.searchParams, redirectUrl, codeVerifier, state, tokenStore);
|
|
61
61
|
// reload/redirect so the server can update now that the user is signed in
|
|
62
62
|
window.location.assign(redirectUrl);
|
|
63
63
|
}
|
package/dist/lib/cookie.d.ts
CHANGED
package/dist/lib/hooks.d.ts
CHANGED
package/dist/lib/stack-app.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { ClientProjectJson, UserCustomizableJson, UserJson, EmailConfigJson, DomainConfigJson } from "@stackframe/stack-shared/dist/interface/clientInterface";
|
|
3
|
-
import { ReadonlyJson } from "
|
|
1
|
+
import { OAuthProviderConfigJson, ServerUserCustomizableJson, ServerUserJson } from "@stackframe/stack-shared";
|
|
2
|
+
import { ClientProjectJson, UserCustomizableJson, UserJson, ProjectJson, EmailConfigJson, DomainConfigJson, ReadonlyTokenStore, ProductionModeError } from "@stackframe/stack-shared/dist/interface/clientInterface";
|
|
3
|
+
import { ReadonlyJson } from "@stackframe/stack-shared/dist/utils/json";
|
|
4
4
|
import { EmailVerificationLinkErrorCode, PasswordResetLinkErrorCode, SignInErrorCode, SignUpErrorCode } from "@stackframe/stack-shared/dist/utils/types";
|
|
5
|
+
import { ApiKeySetCreateOptions, ProjectUpdateOptions } from "@stackframe/stack-shared/dist/interface/adminInterface";
|
|
5
6
|
export type TokenStoreOptions<HasTokenStore extends boolean = boolean> = HasTokenStore extends true ? "cookie" | "nextjs-cookie" | "memory" : HasTokenStore extends false ? null : TokenStoreOptions<true> | TokenStoreOptions<false>;
|
|
6
7
|
export type HandlerUrls = {
|
|
7
8
|
handler: string;
|
|
@@ -25,16 +26,17 @@ export type StackClientAppConstructorOptions<HasTokenStore extends boolean, Proj
|
|
|
25
26
|
export type StackServerAppConstructorOptions<HasTokenStore extends boolean, ProjectId extends string> = StackClientAppConstructorOptions<HasTokenStore, ProjectId> & {
|
|
26
27
|
secretServerKey?: string;
|
|
27
28
|
};
|
|
28
|
-
export type StackAdminAppConstructorOptions<HasTokenStore extends boolean, ProjectId extends string> = StackServerAppConstructorOptions<HasTokenStore, ProjectId> & {
|
|
29
|
+
export type StackAdminAppConstructorOptions<HasTokenStore extends boolean, ProjectId extends string> = ((StackServerAppConstructorOptions<HasTokenStore, ProjectId> & {
|
|
29
30
|
superSecretAdminKey?: string;
|
|
30
|
-
}
|
|
31
|
+
}) | (Omit<StackServerAppConstructorOptions<HasTokenStore, ProjectId>, "publishableClientKey" | "secretServerKey"> & {
|
|
32
|
+
projectOwnerTokens: ReadonlyTokenStore;
|
|
33
|
+
}));
|
|
31
34
|
export type StackClientAppJson<HasTokenStore extends boolean, ProjectId extends string> = StackClientAppConstructorOptions<HasTokenStore, ProjectId> & {
|
|
32
35
|
uniqueIdentifier: string;
|
|
33
36
|
};
|
|
34
37
|
export declare const stackAppInternalsSymbol: unique symbol;
|
|
35
38
|
type Auth<T, C> = {
|
|
36
|
-
readonly
|
|
37
|
-
readonly refreshToken: string | null;
|
|
39
|
+
readonly tokenStore: ReadonlyTokenStore;
|
|
38
40
|
update(this: T, user: Partial<C>): Promise<void>;
|
|
39
41
|
signOut(this: T, redirectUrl?: string): Promise<never>;
|
|
40
42
|
};
|
|
@@ -72,38 +74,68 @@ export type ServerUser = Omit<User, "toJson"> & {
|
|
|
72
74
|
export type CurrentServerUser = Auth<ServerUser, ServerUserCustomizableJson> & Omit<ServerUser, "getClientUser"> & {
|
|
73
75
|
getClientUser(this: CurrentServerUser): CurrentUser;
|
|
74
76
|
};
|
|
75
|
-
export type Project =
|
|
77
|
+
export type Project = {
|
|
78
|
+
readonly id: string;
|
|
79
|
+
readonly displayName: string;
|
|
80
|
+
readonly description?: string;
|
|
81
|
+
readonly createdAt: Date;
|
|
82
|
+
readonly userCount: number;
|
|
83
|
+
readonly isProductionMode: boolean;
|
|
84
|
+
readonly evaluatedConfig: {
|
|
85
|
+
readonly id: string;
|
|
86
|
+
readonly allowLocalhost: boolean;
|
|
87
|
+
readonly credentialEnabled: boolean;
|
|
88
|
+
readonly oauthProviders: OAuthProviderConfig[];
|
|
89
|
+
readonly emailConfig?: EmailConfig;
|
|
90
|
+
readonly domains: DomainConfig[];
|
|
91
|
+
};
|
|
92
|
+
update(this: Project, update: ProjectUpdateOptions): Promise<void>;
|
|
93
|
+
toJson(this: Project): ProjectJson;
|
|
94
|
+
getProductionModeErrors(this: Project): ProductionModeError[];
|
|
95
|
+
};
|
|
96
|
+
export type ApiKeySetBase = {
|
|
76
97
|
id: string;
|
|
77
|
-
|
|
78
|
-
|
|
98
|
+
description: string;
|
|
99
|
+
expiresAt: Date;
|
|
100
|
+
manuallyRevokedAt: Date | null;
|
|
79
101
|
createdAt: Date;
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
102
|
+
isValid(): boolean;
|
|
103
|
+
whyInvalid(): "expired" | "manually-revoked" | null;
|
|
104
|
+
revoke(): Promise<void>;
|
|
105
|
+
};
|
|
106
|
+
export type ApiKeySetFirstView = ApiKeySetBase & {
|
|
107
|
+
publishableClientKey?: string;
|
|
108
|
+
secretServerKey?: string;
|
|
109
|
+
superSecretAdminKey?: string;
|
|
110
|
+
};
|
|
111
|
+
export type ApiKeySet = ApiKeySetBase & {
|
|
112
|
+
publishableClientKey: null | {
|
|
113
|
+
lastFour: string;
|
|
88
114
|
};
|
|
89
|
-
|
|
115
|
+
secretServerKey: null | {
|
|
116
|
+
lastFour: string;
|
|
117
|
+
};
|
|
118
|
+
superSecretAdminKey: null | {
|
|
119
|
+
lastFour: string;
|
|
120
|
+
};
|
|
121
|
+
};
|
|
90
122
|
export type EmailConfig = EmailConfigJson;
|
|
91
123
|
export type DomainConfig = DomainConfigJson;
|
|
92
|
-
export type
|
|
124
|
+
export type OAuthProviderConfig = OAuthProviderConfigJson;
|
|
93
125
|
export type GetUserOptions = {
|
|
94
|
-
or?: 'redirect' | 'throw';
|
|
126
|
+
or?: 'redirect' | 'throw' | 'return-null';
|
|
95
127
|
};
|
|
96
|
-
type AsyncStoreProperty<Name extends string, Value> = {
|
|
97
|
-
[key in
|
|
128
|
+
type AsyncStoreProperty<Name extends string, Value, IsMultiple extends boolean> = {
|
|
129
|
+
[key in `${IsMultiple extends true ? "list" : "get"}${Capitalize<Name>}`]: () => Promise<Value>;
|
|
98
130
|
} & {
|
|
99
131
|
[key in `on${Capitalize<Name>}Change`]: (callback: (value: Value) => void) => void;
|
|
100
132
|
} & {
|
|
101
133
|
[key in `use${Capitalize<Name>}`]: () => Value;
|
|
102
134
|
};
|
|
103
|
-
export type StackClientApp<HasTokenStore extends boolean, ProjectId extends string = string> = ({
|
|
135
|
+
export type StackClientApp<HasTokenStore extends boolean = boolean, ProjectId extends string = string> = ({
|
|
104
136
|
readonly projectId: ProjectId;
|
|
105
137
|
readonly urls: Readonly<HandlerUrls>;
|
|
106
|
-
|
|
138
|
+
signInWithOAuth(provider: string): Promise<void>;
|
|
107
139
|
signInWithCredential(options: {
|
|
108
140
|
email: string;
|
|
109
141
|
password: string;
|
|
@@ -114,7 +146,7 @@ export type StackClientApp<HasTokenStore extends boolean, ProjectId extends stri
|
|
|
114
146
|
password: string;
|
|
115
147
|
redirectUrl?: string;
|
|
116
148
|
}): Promise<SignUpErrorCode | undefined>;
|
|
117
|
-
|
|
149
|
+
callOAuthCallback(options?: {
|
|
118
150
|
redirectUrl?: string;
|
|
119
151
|
}): Promise<void>;
|
|
120
152
|
sendForgotPasswordEmail(email: string): Promise<void>;
|
|
@@ -127,9 +159,10 @@ export type StackClientApp<HasTokenStore extends boolean, ProjectId extends stri
|
|
|
127
159
|
[stackAppInternalsSymbol]: {
|
|
128
160
|
toClientJson(): Promise<StackClientAppJson<HasTokenStore, ProjectId>>;
|
|
129
161
|
};
|
|
130
|
-
} & AsyncStoreProperty<"project", ClientProjectJson> & {
|
|
131
|
-
[K in `redirectTo${Capitalize<keyof HandlerUrls
|
|
162
|
+
} & AsyncStoreProperty<"project", ClientProjectJson, false> & {
|
|
163
|
+
[K in `redirectTo${Capitalize<keyof Omit<HandlerUrls, 'oauthCallback'>>}`]: () => Promise<never>;
|
|
132
164
|
} & (HasTokenStore extends false ? {} : {
|
|
165
|
+
redirectToOAuthCallback(): Promise<never>;
|
|
133
166
|
useUser(options: GetUserOptions & {
|
|
134
167
|
or: 'redirect';
|
|
135
168
|
}): CurrentUser;
|
|
@@ -144,11 +177,10 @@ export type StackClientApp<HasTokenStore extends boolean, ProjectId extends stri
|
|
|
144
177
|
or: 'throw';
|
|
145
178
|
}): Promise<CurrentUser>;
|
|
146
179
|
getUser(options?: GetUserOptions): Promise<CurrentUser | null>;
|
|
147
|
-
onUserChange: AsyncStoreProperty<"user", CurrentUser | null>["onUserChange"];
|
|
148
|
-
}) & (ProjectId extends "internal" ? {
|
|
149
|
-
listOwnedProjects(): Promise<Project[]>;
|
|
180
|
+
onUserChange: AsyncStoreProperty<"user", CurrentUser | null, false>["onUserChange"];
|
|
181
|
+
}) & (ProjectId extends "internal" ? (AsyncStoreProperty<"ownedProjects", Project[], true> & {
|
|
150
182
|
createProject(project: Pick<Project, "displayName" | "description">): Promise<Project>;
|
|
151
|
-
} : {}));
|
|
183
|
+
}) : {}));
|
|
152
184
|
type StackClientAppConstructor = {
|
|
153
185
|
new <TokenStoreType extends string, HasTokenStore extends (TokenStoreType extends {} ? true : boolean), ProjectId extends string>(options: StackClientAppConstructorOptions<HasTokenStore, ProjectId>): StackClientApp<HasTokenStore, ProjectId>;
|
|
154
186
|
new (options: StackClientAppConstructorOptions<boolean, string>): StackClientApp<boolean, string>;
|
|
@@ -157,16 +189,19 @@ type StackClientAppConstructor = {
|
|
|
157
189
|
};
|
|
158
190
|
};
|
|
159
191
|
export declare const StackClientApp: StackClientAppConstructor;
|
|
160
|
-
export type StackServerApp<HasTokenStore extends boolean, ProjectId extends string = string> = (StackClientApp<HasTokenStore, ProjectId> & AsyncStoreProperty<"serverUser", CurrentServerUser | null> & {});
|
|
192
|
+
export type StackServerApp<HasTokenStore extends boolean = boolean, ProjectId extends string = string> = (StackClientApp<HasTokenStore, ProjectId> & AsyncStoreProperty<"serverUser", CurrentServerUser | null, false> & AsyncStoreProperty<"serverUsers", ServerUser[], true> & {});
|
|
161
193
|
type StackServerAppConstructor = {
|
|
162
194
|
new <TokenStoreType extends string, HasTokenStore extends (TokenStoreType extends {} ? true : boolean), ProjectId extends string>(options: StackServerAppConstructorOptions<HasTokenStore, ProjectId>): StackServerApp<HasTokenStore, ProjectId>;
|
|
163
195
|
new (options: StackServerAppConstructorOptions<boolean, string>): StackServerApp<boolean, string>;
|
|
164
196
|
};
|
|
165
197
|
export declare const StackServerApp: StackServerAppConstructor;
|
|
166
|
-
export type StackAdminApp<HasTokenStore extends boolean, ProjectId extends string = string> = (StackServerApp<HasTokenStore, ProjectId> & AsyncStoreProperty<"projectAdmin", Project>
|
|
198
|
+
export type StackAdminApp<HasTokenStore extends boolean = boolean, ProjectId extends string = string> = (StackServerApp<HasTokenStore, ProjectId> & AsyncStoreProperty<"projectAdmin", Project, false> & AsyncStoreProperty<"apiKeySets", ApiKeySet[], true> & {
|
|
199
|
+
createApiKeySet(options: ApiKeySetCreateOptions): Promise<ApiKeySetFirstView>;
|
|
200
|
+
});
|
|
167
201
|
type StackAdminAppConstructor = {
|
|
168
202
|
new <TokenStoreType extends string, HasTokenStore extends (TokenStoreType extends {} ? true : boolean), ProjectId extends string>(options: StackAdminAppConstructorOptions<HasTokenStore, ProjectId>): StackAdminApp<HasTokenStore, ProjectId>;
|
|
169
203
|
new (options: StackAdminAppConstructorOptions<boolean, string>): StackAdminApp<boolean, string>;
|
|
170
204
|
};
|
|
171
205
|
export declare const StackAdminApp: StackAdminAppConstructor;
|
|
172
206
|
export {};
|
|
207
|
+
//# sourceMappingURL=stack-app.d.ts.map
|