@stackframe/stack 2.2.4 → 2.2.5
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 +6 -0
- package/dist/components/EmailVerification.d.ts.map +1 -0
- package/dist/components/EmailVerification.js +29 -0
- package/dist/components/ForgotPassword.d.ts +4 -0
- package/dist/components/ForgotPassword.d.ts.map +1 -0
- package/dist/components/ForgotPassword.js +22 -0
- package/dist/components/OAuthCallback.d.ts +2 -0
- package/dist/components/OAuthCallback.d.ts.map +1 -0
- package/dist/components/OAuthCallback.js +20 -0
- package/dist/components/PasswordReset.d.ts +5 -0
- package/dist/components/PasswordReset.d.ts.map +1 -0
- package/dist/components/PasswordReset.js +36 -0
- package/dist/components/SignIn.d.ts +5 -0
- package/dist/components/SignIn.d.ts.map +1 -0
- package/dist/components/SignIn.js +20 -0
- package/dist/components/SignOut.d.ts +4 -0
- package/dist/components/SignOut.d.ts.map +1 -0
- package/dist/components/SignOut.js +12 -0
- package/dist/components/SignUp.d.ts +5 -0
- package/dist/components/SignUp.d.ts.map +1 -0
- package/dist/components/SignUp.js +19 -0
- package/dist/components/StackHandler.d.ts +9 -0
- package/dist/components/StackHandler.d.ts.map +1 -0
- package/dist/components/StackHandler.js +58 -0
- package/dist/components/user-button.js +1 -1
- package/dist/elements/Button.d.ts +11 -0
- package/dist/elements/Button.d.ts.map +1 -0
- package/dist/elements/Button.js +18 -0
- package/dist/elements/CardFrame.d.ts +6 -0
- package/dist/elements/CardFrame.d.ts.map +1 -0
- package/dist/elements/CardFrame.js +10 -0
- package/dist/elements/CardHeader.d.ts +6 -0
- package/dist/elements/CardHeader.d.ts.map +1 -0
- package/dist/elements/CardHeader.js +4 -0
- package/dist/elements/CredentialSignIn.d.ts +4 -0
- package/dist/elements/CredentialSignIn.d.ts.map +1 -0
- package/dist/elements/CredentialSignIn.js +57 -0
- package/dist/elements/CredentialSignUp.d.ts +4 -0
- package/dist/elements/CredentialSignUp.d.ts.map +1 -0
- package/dist/elements/CredentialSignUp.js +73 -0
- package/dist/elements/DividerWithText.d.ts +4 -0
- package/dist/elements/DividerWithText.d.ts.map +1 -0
- package/dist/elements/DividerWithText.js +5 -0
- package/dist/elements/ForgotPassword.d.ts +4 -0
- package/dist/elements/ForgotPassword.d.ts.map +1 -0
- package/dist/elements/ForgotPassword.js +32 -0
- package/dist/elements/FormWarning.d.ts +4 -0
- package/dist/elements/FormWarning.d.ts.map +1 -0
- package/dist/elements/FormWarning.js +7 -0
- package/dist/elements/MessageCard.d.ts +7 -0
- package/dist/elements/MessageCard.d.ts.map +1 -0
- package/dist/elements/MessageCard.js +5 -0
- package/dist/elements/OAuthButton.d.ts +6 -0
- package/dist/elements/OAuthButton.d.ts.map +1 -0
- package/dist/elements/OAuthButton.js +67 -0
- 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 +3 -0
- package/dist/elements/PasswordField.d.ts.map +1 -0
- package/dist/elements/PasswordField.js +27 -0
- package/dist/elements/PasswordResetInner.d.ts +5 -0
- package/dist/elements/PasswordResetInner.d.ts.map +1 -0
- package/dist/elements/PasswordResetInner.js +61 -0
- package/dist/elements/RedirectMessageCard.d.ts +5 -0
- package/dist/elements/RedirectMessageCard.d.ts.map +1 -0
- package/dist/elements/RedirectMessageCard.js +55 -0
- package/dist/lib/hooks.d.ts +13 -5
- package/dist/lib/hooks.d.ts.map +1 -1
- package/dist/lib/hooks.js +11 -2
- package/dist/lib/stack-app.d.ts +16 -9
- package/dist/lib/stack-app.d.ts.map +1 -1
- package/dist/lib/stack-app.js +57 -14
- package/dist/providers/StackProvider.d.ts +7 -0
- package/dist/providers/StackProvider.d.ts.map +1 -0
- package/dist/providers/StackProvider.js +6 -0
- package/dist/providers/StackProviderClient.d.ts +10 -0
- package/dist/providers/StackProviderClient.d.ts.map +1 -0
- package/dist/providers/StackProviderClient.js +14 -0
- package/dist/utils/react.d.ts +2 -0
- package/dist/utils/react.d.ts.map +1 -0
- package/dist/utils/react.js +6 -0
- package/dist/utils/results.d.ts +25 -0
- package/dist/utils/results.d.ts.map +1 -0
- package/dist/utils/results.js +46 -0
- package/package.json +3 -3
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FormWarning.d.ts","sourceRoot":"","sources":["../../src/elements/FormWarning.tsx"],"names":[],"mappings":"AAAA,wBAAgB,eAAe,CAAC,EAAE,IAAI,EAAE,EAAE;IAAE,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,kDAS1D"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MessageCard.d.ts","sourceRoot":"","sources":["../../src/elements/MessageCard.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,MAAM,CAAC,OAAO,UAAU,WAAW,CACjC,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAc,EAAE,EACnC;IAAE,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,OAAO,CAAA;CAAC,2CAUjE"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import CardFrame from "./CardFrame";
|
|
3
|
+
export default function MessageCard({ children, title, fullPage = false }) {
|
|
4
|
+
return (_jsx(CardFrame, { fullPage: fullPage, children: _jsxs("div", { className: 'wl_text-center', children: [_jsx("h1", { className: "wl_text-2xl wl_mb-6", children: title }), children] }) }));
|
|
5
|
+
}
|
|
@@ -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"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { FaGithub, FaFacebook, FaApple } from 'react-icons/fa';
|
|
4
|
+
import { useStackApp } from '..';
|
|
5
|
+
import { runAsynchronously } from "@stackframe/stack-shared/dist/utils/promises";
|
|
6
|
+
import Button from './Button';
|
|
7
|
+
const iconSize = 24;
|
|
8
|
+
export default function OAuthButton({ provider, type, redirectUrl }) {
|
|
9
|
+
const stackApp = useStackApp();
|
|
10
|
+
let style;
|
|
11
|
+
switch (provider) {
|
|
12
|
+
case 'google': {
|
|
13
|
+
style = {
|
|
14
|
+
backgroundColor: '#fff',
|
|
15
|
+
textColor: '#000',
|
|
16
|
+
name: 'Google',
|
|
17
|
+
icon: (_jsxs("svg", { xmlns: "http://www.w3.org/2000/svg", width: iconSize, height: iconSize, viewBox: "0 0 24 24", children: [_jsx("path", { fill: "#4285F4", d: "M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92c-.26 1.37-1.04 2.53-2.21 3.31v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.09z" }), _jsx("path", { fill: "#34A853", d: "M12 23c2.97 0 5.46-.98 7.28-2.66l-3.57-2.77c-.98.66-2.23 1.06-3.71 1.06-2.86 0-5.29-1.93-6.16-4.53H2.18v2.84C3.99 20.53 7.7 23 12 23z" }), _jsx("path", { fill: "#FBBC05", d: "M5.84 14.09c-.22-.66-.35-1.36-.35-2.09s.13-1.43.35-2.09V7.07H2.18C1.43 8.55 1 10.22 1 12s.43 3.45 1.18 4.93l2.85-2.22.81-.62z" }), _jsx("path", { fill: "#EA4335", d: "M12 5.38c1.62 0 3.06.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1 7.7 1 3.99 3.47 2.18 7.07l3.66 2.84c.87-2.6 3.3-4.53 6.16-4.53z" }), _jsx("path", { fill: "none", d: "M1 1h22v22H1z" })] })),
|
|
18
|
+
};
|
|
19
|
+
break;
|
|
20
|
+
}
|
|
21
|
+
case 'github': {
|
|
22
|
+
style = {
|
|
23
|
+
backgroundColor: '#111',
|
|
24
|
+
textColor: '#fff',
|
|
25
|
+
name: 'GitHub',
|
|
26
|
+
icon: (_jsx(FaGithub, { color: "#fff", size: iconSize })),
|
|
27
|
+
};
|
|
28
|
+
break;
|
|
29
|
+
}
|
|
30
|
+
case 'facebook': {
|
|
31
|
+
style = {
|
|
32
|
+
backgroundColor: '#1877F2',
|
|
33
|
+
textColor: '#fff',
|
|
34
|
+
name: 'Facebook',
|
|
35
|
+
icon: (_jsx(FaFacebook, { color: "#fff", size: iconSize })),
|
|
36
|
+
};
|
|
37
|
+
break;
|
|
38
|
+
}
|
|
39
|
+
case 'apple': {
|
|
40
|
+
style = {
|
|
41
|
+
backgroundColor: '#000',
|
|
42
|
+
textColor: '#fff',
|
|
43
|
+
name: 'Apple',
|
|
44
|
+
icon: (_jsx(FaApple, { color: "#fff", size: iconSize })),
|
|
45
|
+
};
|
|
46
|
+
break;
|
|
47
|
+
}
|
|
48
|
+
case 'microsoft': {
|
|
49
|
+
style = {
|
|
50
|
+
backgroundColor: '#2f2f2f',
|
|
51
|
+
textColor: '#fff',
|
|
52
|
+
name: 'Microsoft',
|
|
53
|
+
icon: (_jsxs("svg", { xmlns: "http://www.w3.org/2000/svg", width: iconSize, height: iconSize, viewBox: "0 0 21 21", children: [_jsx("title", { children: "MS-SymbolLockup" }), _jsx("path", { fill: "#f25022", d: "M1 1h9v9H1z" }), _jsx("path", { fill: "#00a4ef", d: "M1 11h9v9H1z" }), _jsx("path", { fill: "#7fba00", d: "M11 1h9v9h-9z" }), _jsx("path", { fill: "#ffb900", d: "M11 11h9v9h-9z" })] })),
|
|
54
|
+
};
|
|
55
|
+
break;
|
|
56
|
+
}
|
|
57
|
+
default: {
|
|
58
|
+
style = {
|
|
59
|
+
backgroundColor: '#000',
|
|
60
|
+
textColor: '#fff',
|
|
61
|
+
name: provider,
|
|
62
|
+
icon: null
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
}
|
|
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
|
+
}
|
|
@@ -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
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PasswordField.d.ts","sourceRoot":"","sources":["../../src/elements/PasswordField.tsx"],"names":[],"mappings":";AAGA,eAAO,MAAM,aAAa,oJA8CxB,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef, useRef, useState } from 'react';
|
|
3
|
+
import { HiEye, HiEyeOff } from 'react-icons/hi';
|
|
4
|
+
export const PasswordField = forwardRef(({ id, name, ...props }, ref) => {
|
|
5
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
6
|
+
const inputRef = useRef(null);
|
|
7
|
+
const mergeRef = (node) => {
|
|
8
|
+
if (ref) {
|
|
9
|
+
if (typeof ref === 'function') {
|
|
10
|
+
ref(node);
|
|
11
|
+
}
|
|
12
|
+
else {
|
|
13
|
+
ref.current = node;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
inputRef.current = node;
|
|
17
|
+
};
|
|
18
|
+
const onClickReveal = () => {
|
|
19
|
+
setIsOpen(!isOpen);
|
|
20
|
+
const currentInput = inputRef.current;
|
|
21
|
+
if (currentInput) {
|
|
22
|
+
currentInput.focus({ preventScroll: true });
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
return (_jsxs("div", { className: "wl_relative", children: [_jsx("input", { id: id, ref: mergeRef, name: name, type: isOpen ? 'text' : 'password', autoComplete: "current-password", required: true, className: "wl_input wl_input-bordered wl_w-full", ...props }), _jsx("button", { tabIndex: -1, type: "button", className: "wl_absolute wl_inset-y-0 wl_right-0 wl_flex wl_items-center wl_pr-3", onClick: onClickReveal, "aria-label": isOpen ? 'Mask password' : 'Reveal password', children: isOpen ? _jsx(HiEyeOff, {}) : _jsx(HiEye, {}) })] }));
|
|
26
|
+
});
|
|
27
|
+
PasswordField.displayName = 'PasswordField';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PasswordResetInner.d.ts","sourceRoot":"","sources":["../../src/elements/PasswordResetInner.tsx"],"names":[],"mappings":"AAaA,MAAM,CAAC,OAAO,UAAU,kBAAkB,CACxC,EAAE,IAAI,EAAE,QAAgB,EAAE,EAC1B;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,OAAO,CAAA;CAAE,2CAiGrC"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useState } from "react";
|
|
4
|
+
import { getPasswordError } from "@stackframe/stack-shared/dist/helpers/password";
|
|
5
|
+
import { useStackApp } from "..";
|
|
6
|
+
import { PasswordField } from "./PasswordField";
|
|
7
|
+
import { FormWarningText } from "./FormWarning";
|
|
8
|
+
import RedirectMessageCard from "./RedirectMessageCard";
|
|
9
|
+
import MessageCard from "./MessageCard";
|
|
10
|
+
import CardFrame from "./CardFrame";
|
|
11
|
+
import CardHeader from "./CardHeader";
|
|
12
|
+
export default function PasswordResetInner({ code, fullPage = false }) {
|
|
13
|
+
const [password, setPassword] = useState('');
|
|
14
|
+
const [passwordError, setPasswordError] = useState('');
|
|
15
|
+
const [passwordRepeat, setPasswordRepeat] = useState('');
|
|
16
|
+
const [passwordRepeatError, setPasswordRepeatError] = useState('');
|
|
17
|
+
const [finished, setFinished] = useState(false);
|
|
18
|
+
const [resetError, setResetError] = useState(false);
|
|
19
|
+
const stackApp = useStackApp();
|
|
20
|
+
const onSubmit = async () => {
|
|
21
|
+
if (!password) {
|
|
22
|
+
setPasswordError('Please enter your password');
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
if (!passwordRepeat) {
|
|
26
|
+
setPasswordRepeatError('Please repeat your password');
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
if (password !== passwordRepeat) {
|
|
30
|
+
setPasswordRepeatError('Passwords do not match');
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
const errorMessage = getPasswordError(password);
|
|
34
|
+
if (errorMessage) {
|
|
35
|
+
setPasswordError(errorMessage);
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
const errorCode = await stackApp.resetPassword({ password, code });
|
|
39
|
+
// this should not happen, the outer component should verify the code before rendering this component
|
|
40
|
+
if (errorCode) {
|
|
41
|
+
setResetError(true);
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
setFinished(true);
|
|
45
|
+
};
|
|
46
|
+
if (finished) {
|
|
47
|
+
return _jsx(RedirectMessageCard, { type: 'passwordReset', fullPage: fullPage });
|
|
48
|
+
}
|
|
49
|
+
if (resetError) {
|
|
50
|
+
return (_jsx(MessageCard, { title: "Failed to reset password", fullPage: fullPage, children: _jsx("p", { children: "Failed to reset password. Please request a new password reset link" }) }));
|
|
51
|
+
}
|
|
52
|
+
return (_jsxs(CardFrame, { fullPage: fullPage, children: [_jsx(CardHeader, { title: "Reset Your Password" }), _jsxs("div", { className: "wl_flex wl_flex-col wl_space-y-2 wl_items-stretch", children: [_jsxs("div", { className: "wl_form-control", children: [_jsx("label", { className: "wl_label", htmlFor: "password", children: "New Password" }), _jsx(PasswordField, { id: "password", name: "password", value: password, onChange: (e) => {
|
|
53
|
+
setPassword(e.target.value);
|
|
54
|
+
setPasswordError('');
|
|
55
|
+
setPasswordRepeatError('');
|
|
56
|
+
} }), _jsx(FormWarningText, { text: passwordError })] }), _jsxs("div", { className: "wl_form-control", children: [_jsx("label", { className: "wl_label", htmlFor: "repeat-password", children: "Repeat New Password" }), _jsx(PasswordField, { id: "repeat-password", name: "repeat-password", value: passwordRepeat, onChange: (e) => {
|
|
57
|
+
setPasswordRepeat(e.target.value);
|
|
58
|
+
setPasswordError('');
|
|
59
|
+
setPasswordRepeatError('');
|
|
60
|
+
} }), _jsx(FormWarningText, { text: passwordRepeatError })] }), _jsx("div", { className: "wl_flex wl_flex-col wl_items-stretch", children: _jsx("button", { className: "wl_btn wl_btn-primary wl_mt-6", onClick: () => void onSubmit(), children: "Reset Password" }) })] })] }));
|
|
61
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useRouter } from "next/navigation";
|
|
4
|
+
import { useStackApp } from "..";
|
|
5
|
+
import MessageCard from "./MessageCard";
|
|
6
|
+
import Button from "./Button";
|
|
7
|
+
export default function RedirectMessageCard({ type, fullPage = false, }) {
|
|
8
|
+
const stackApp = useStackApp();
|
|
9
|
+
const router = useRouter();
|
|
10
|
+
let title;
|
|
11
|
+
let primaryUrl;
|
|
12
|
+
let secondaryUrl = null;
|
|
13
|
+
let message = null;
|
|
14
|
+
let primaryButton;
|
|
15
|
+
let secondaryButton = null;
|
|
16
|
+
switch (type) {
|
|
17
|
+
case 'signedIn': {
|
|
18
|
+
title = "You are already signed in";
|
|
19
|
+
message = 'You are already signed in.';
|
|
20
|
+
primaryUrl = stackApp.urls.userHome;
|
|
21
|
+
secondaryUrl = stackApp.urls.signOut;
|
|
22
|
+
primaryButton = "Go to Home";
|
|
23
|
+
secondaryButton = "Sign Out";
|
|
24
|
+
break;
|
|
25
|
+
}
|
|
26
|
+
case 'signedOut': {
|
|
27
|
+
title = "You are not currently signed in.";
|
|
28
|
+
primaryUrl = stackApp.urls.home;
|
|
29
|
+
primaryButton = "Go to Home";
|
|
30
|
+
break;
|
|
31
|
+
}
|
|
32
|
+
case 'emailSent': {
|
|
33
|
+
title = "Email sent!";
|
|
34
|
+
message = 'Please check your inbox. Make sure to check your spam folder.';
|
|
35
|
+
primaryUrl = stackApp.urls.home;
|
|
36
|
+
primaryButton = "Go to Home";
|
|
37
|
+
break;
|
|
38
|
+
}
|
|
39
|
+
case 'passwordReset': {
|
|
40
|
+
title = "Password reset successfully!";
|
|
41
|
+
message = 'Your password has been reset. You can now sign in with your new password.';
|
|
42
|
+
primaryUrl = stackApp.urls.signIn;
|
|
43
|
+
primaryButton = "Go to Sign In";
|
|
44
|
+
break;
|
|
45
|
+
}
|
|
46
|
+
case 'emailVerified': {
|
|
47
|
+
title = "Email verified!";
|
|
48
|
+
message = 'Your have successfully verified your email.';
|
|
49
|
+
primaryUrl = stackApp.urls.home;
|
|
50
|
+
primaryButton = "Go to Home";
|
|
51
|
+
break;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
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 })] })] }));
|
|
55
|
+
}
|
package/dist/lib/hooks.d.ts
CHANGED
|
@@ -1,16 +1,23 @@
|
|
|
1
|
-
import { CurrentUser, GetUserOptions, StackClientApp } from "./stack-app";
|
|
1
|
+
import { CurrentUser, GetUserOptions as AppGetUserOptions, StackClientApp, CurrentInternalUser } from "./stack-app";
|
|
2
2
|
/**
|
|
3
3
|
* Returns the current user object. Equivalent to `useStackApp().useUser()`.
|
|
4
4
|
*
|
|
5
5
|
* @returns the current user
|
|
6
6
|
*/
|
|
7
|
+
type GetUserOptions = AppGetUserOptions & {
|
|
8
|
+
projectIdMustMatch?: string;
|
|
9
|
+
};
|
|
7
10
|
export declare function useUser(options: GetUserOptions & {
|
|
8
|
-
or: 'redirect';
|
|
9
|
-
|
|
11
|
+
or: 'redirect' | 'throw';
|
|
12
|
+
projectIdMustMatch: "internal";
|
|
13
|
+
}): CurrentInternalUser;
|
|
10
14
|
export declare function useUser(options: GetUserOptions & {
|
|
11
|
-
or: 'throw';
|
|
15
|
+
or: 'redirect' | 'throw';
|
|
12
16
|
}): CurrentUser;
|
|
13
|
-
export declare function useUser(options
|
|
17
|
+
export declare function useUser(options: GetUserOptions & {
|
|
18
|
+
projectIdMustMatch: "internal";
|
|
19
|
+
}): CurrentInternalUser | null;
|
|
20
|
+
export declare function useUser(options?: GetUserOptions): CurrentUser | CurrentInternalUser | null;
|
|
14
21
|
/**
|
|
15
22
|
* Returns the current Stack app associated with the StackProvider.
|
|
16
23
|
*
|
|
@@ -19,4 +26,5 @@ export declare function useUser(options?: GetUserOptions): CurrentUser | null;
|
|
|
19
26
|
export declare function useStackApp<ProjectId extends string>(options?: {
|
|
20
27
|
projectIdMustMatch?: ProjectId;
|
|
21
28
|
}): StackClientApp<true, ProjectId>;
|
|
29
|
+
export {};
|
|
22
30
|
//# sourceMappingURL=hooks.d.ts.map
|
package/dist/lib/hooks.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hooks.d.ts","sourceRoot":"","sources":["../../src/lib/hooks.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"hooks.d.ts","sourceRoot":"","sources":["../../src/lib/hooks.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,cAAc,IAAI,iBAAiB,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAIpH;;;;GAIG;AAEH,KAAK,cAAc,GAAG,iBAAiB,GAAG;IACxC,kBAAkB,CAAC,EAAE,MAAM,CAAC;CAC7B,CAAA;AAED,wBAAgB,OAAO,CAAC,OAAO,EAAE,cAAc,GAAG;IAAE,EAAE,EAAE,UAAU,GAAG,OAAO,CAAC;IAAC,kBAAkB,EAAE,UAAU,CAAA;CAAE,GAAG,mBAAmB,CAAC;AACrI,wBAAgB,OAAO,CAAC,OAAO,EAAE,cAAc,GAAG;IAAE,EAAE,EAAE,UAAU,GAAG,OAAO,CAAA;CAAE,GAAG,WAAW,CAAC;AAC7F,wBAAgB,OAAO,CAAC,OAAO,EAAE,cAAc,GAAG;IAAE,kBAAkB,EAAE,UAAU,CAAA;CAAE,GAAG,mBAAmB,GAAG,IAAI,CAAC;AAClH,wBAAgB,OAAO,CAAC,OAAO,CAAC,EAAE,cAAc,GAAG,WAAW,GAAG,mBAAmB,GAAG,IAAI,CAAC;AAa5F;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,SAAS,SAAS,MAAM,EAAE,OAAO,GAAE;IAAE,kBAAkB,CAAC,EAAE,SAAS,CAAA;CAAO,GAAG,cAAc,CAAC,IAAI,EAAE,SAAS,CAAC,CAUvI"}
|
package/dist/lib/hooks.js
CHANGED
|
@@ -1,7 +1,16 @@
|
|
|
1
1
|
import { StackContext } from "../providers/stack-provider-client";
|
|
2
2
|
import { useContext } from "react";
|
|
3
|
-
export function useUser(options) {
|
|
4
|
-
|
|
3
|
+
export function useUser(options = {}) {
|
|
4
|
+
const stackApp = useStackApp(options);
|
|
5
|
+
if (options.projectIdMustMatch && stackApp.projectId !== options.projectIdMustMatch) {
|
|
6
|
+
throw new Error("Unexpected project ID in useStackApp: " + stackApp.projectId);
|
|
7
|
+
}
|
|
8
|
+
if (options.projectIdMustMatch === "internal") {
|
|
9
|
+
return stackApp.useUser(options);
|
|
10
|
+
}
|
|
11
|
+
else {
|
|
12
|
+
return stackApp.useUser(options);
|
|
13
|
+
}
|
|
5
14
|
}
|
|
6
15
|
/**
|
|
7
16
|
* Returns the current Stack app associated with the StackProvider.
|
package/dist/lib/stack-app.d.ts
CHANGED
|
@@ -18,6 +18,7 @@ export type HandlerUrls = {
|
|
|
18
18
|
oauthCallback: string;
|
|
19
19
|
accountSettings: string;
|
|
20
20
|
};
|
|
21
|
+
type ProjectCurrentUser<ProjectId> = ProjectId extends "internal" ? CurrentInternalUser : CurrentUser;
|
|
21
22
|
export type StackClientAppConstructorOptions<HasTokenStore extends boolean, ProjectId extends string> = {
|
|
22
23
|
baseUrl?: string;
|
|
23
24
|
projectId?: ProjectId;
|
|
@@ -49,6 +50,12 @@ type Auth<T, C> = {
|
|
|
49
50
|
newPassword: string;
|
|
50
51
|
}): Promise<KnownErrors["PasswordMismatch"] | KnownErrors["PasswordRequirementsNotMet"] | undefined>;
|
|
51
52
|
};
|
|
53
|
+
type InternalAuth<T> = {
|
|
54
|
+
createProject(this: T, newProject: Pick<Project, "displayName" | "description">): Promise<Project>;
|
|
55
|
+
listOwnedProjects(this: T): Promise<Project[]>;
|
|
56
|
+
useOwnedProjects(this: T): Project[];
|
|
57
|
+
onOwnedProjectsChange(this: T, callback: (projects: Project[]) => void): void;
|
|
58
|
+
};
|
|
52
59
|
export type User = {
|
|
53
60
|
readonly projectId: string;
|
|
54
61
|
readonly id: string;
|
|
@@ -67,6 +74,7 @@ export type User = {
|
|
|
67
74
|
toJson(this: CurrentUser): UserJson;
|
|
68
75
|
};
|
|
69
76
|
export type CurrentUser = Auth<User, UserCustomizableJson> & User;
|
|
77
|
+
export type CurrentInternalUser = CurrentUser & InternalAuth<CurrentUser>;
|
|
70
78
|
/**
|
|
71
79
|
* A user including sensitive fields that should only be used on the server, never sent to the client
|
|
72
80
|
* (such as sensitive information and serverMetadata).
|
|
@@ -84,6 +92,7 @@ export type ServerUser = Omit<User, "toJson"> & {
|
|
|
84
92
|
export type CurrentServerUser = Auth<ServerUser, ServerUserCustomizableJson> & Omit<ServerUser, "getClientUser"> & {
|
|
85
93
|
getClientUser(this: CurrentServerUser): CurrentUser;
|
|
86
94
|
};
|
|
95
|
+
export type CurrentInternalServerUser = CurrentServerUser & InternalAuth<CurrentServerUser>;
|
|
87
96
|
export type Project = {
|
|
88
97
|
readonly id: string;
|
|
89
98
|
readonly displayName: string;
|
|
@@ -171,22 +180,20 @@ export type StackClientApp<HasTokenStore extends boolean = boolean, ProjectId ex
|
|
|
171
180
|
redirectToOAuthCallback(): Promise<never>;
|
|
172
181
|
useUser(options: GetUserOptions & {
|
|
173
182
|
or: 'redirect';
|
|
174
|
-
}):
|
|
183
|
+
}): ProjectCurrentUser<ProjectId>;
|
|
175
184
|
useUser(options: GetUserOptions & {
|
|
176
185
|
or: 'throw';
|
|
177
|
-
}):
|
|
178
|
-
useUser(options?: GetUserOptions):
|
|
186
|
+
}): ProjectCurrentUser<ProjectId>;
|
|
187
|
+
useUser(options?: GetUserOptions): ProjectCurrentUser<ProjectId> | null;
|
|
179
188
|
getUser(options: GetUserOptions & {
|
|
180
189
|
or: 'redirect';
|
|
181
|
-
}): Promise<
|
|
190
|
+
}): Promise<ProjectCurrentUser<ProjectId>>;
|
|
182
191
|
getUser(options: GetUserOptions & {
|
|
183
192
|
or: 'throw';
|
|
184
|
-
}): Promise<
|
|
185
|
-
getUser(options?: GetUserOptions): Promise<
|
|
193
|
+
}): Promise<ProjectCurrentUser<ProjectId>>;
|
|
194
|
+
getUser(options?: GetUserOptions): Promise<ProjectCurrentUser<ProjectId> | null>;
|
|
186
195
|
onUserChange: AsyncStoreProperty<"user", CurrentUser | null, false>["onUserChange"];
|
|
187
|
-
})
|
|
188
|
-
createProject(project: Pick<Project, "displayName" | "description">): Promise<Project>;
|
|
189
|
-
}) : {}));
|
|
196
|
+
}));
|
|
190
197
|
type StackClientAppConstructor = {
|
|
191
198
|
new <TokenStoreType extends string, HasTokenStore extends (TokenStoreType extends {} ? true : boolean), ProjectId extends string>(options: StackClientAppConstructorOptions<HasTokenStore, ProjectId>): StackClientApp<HasTokenStore, ProjectId>;
|
|
192
199
|
new (options: StackClientAppConstructorOptions<boolean, string>): StackClientApp<boolean, string>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stack-app.d.ts","sourceRoot":"","sources":["../../src/lib/stack-app.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,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GAAG,OAAO,CAAC,kBAAkB,CAAC,CAAC;CAC/E,CACF,CAAC;AACF,KAAK,wBAAwB,GAAG;IAC9B,KACE,aAAa,SAAS,OAAO,EAC7B,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
|
@@ -249,7 +249,7 @@ class _StackClientAppImpl {
|
|
|
249
249
|
if (json === null)
|
|
250
250
|
return null;
|
|
251
251
|
const app = this;
|
|
252
|
-
const
|
|
252
|
+
const currentUser = {
|
|
253
253
|
...this._userFromJson(json),
|
|
254
254
|
tokenStore,
|
|
255
255
|
update(update) {
|
|
@@ -263,10 +263,31 @@ class _StackClientAppImpl {
|
|
|
263
263
|
},
|
|
264
264
|
updatePassword(options) {
|
|
265
265
|
return app._updatePassword(options, tokenStore);
|
|
266
|
-
}
|
|
266
|
+
},
|
|
267
267
|
};
|
|
268
|
-
|
|
269
|
-
|
|
268
|
+
if (this.isInternalProject()) {
|
|
269
|
+
const internalUser = {
|
|
270
|
+
...currentUser,
|
|
271
|
+
createProject(newProject) {
|
|
272
|
+
return app._createProject(newProject);
|
|
273
|
+
},
|
|
274
|
+
listOwnedProjects() {
|
|
275
|
+
return app._listOwnedProjects();
|
|
276
|
+
},
|
|
277
|
+
useOwnedProjects() {
|
|
278
|
+
return app._useOwnedProjects();
|
|
279
|
+
},
|
|
280
|
+
onOwnedProjectsChange(callback) {
|
|
281
|
+
return app._onOwnedProjectsChange(callback);
|
|
282
|
+
}
|
|
283
|
+
};
|
|
284
|
+
Object.freeze(internalUser);
|
|
285
|
+
return internalUser;
|
|
286
|
+
}
|
|
287
|
+
else {
|
|
288
|
+
Object.freeze(currentUser);
|
|
289
|
+
return currentUser;
|
|
290
|
+
}
|
|
270
291
|
}
|
|
271
292
|
_userToJson(user) {
|
|
272
293
|
return {
|
|
@@ -394,8 +415,9 @@ class _StackClientAppImpl {
|
|
|
394
415
|
case 'throw': {
|
|
395
416
|
throw new Error("User is not signed in but useUser was called with { or: 'throw' }");
|
|
396
417
|
}
|
|
397
|
-
|
|
398
|
-
|
|
418
|
+
case undefined:
|
|
419
|
+
case "return-null": {
|
|
420
|
+
// do nothing
|
|
399
421
|
}
|
|
400
422
|
}
|
|
401
423
|
}
|
|
@@ -476,26 +498,26 @@ class _StackClientAppImpl {
|
|
|
476
498
|
onProjectChange(callback) {
|
|
477
499
|
return this._currentProjectCache.onChange([], callback);
|
|
478
500
|
}
|
|
479
|
-
async
|
|
501
|
+
async _listOwnedProjects() {
|
|
480
502
|
this._ensureInternalProject();
|
|
481
503
|
const tokenStore = getTokenStore(this._tokenStoreOptions);
|
|
482
504
|
const json = await this._ownedProjectsCache.getOrWait([tokenStore], "write-only");
|
|
483
505
|
return json.map((j) => this._projectAdminFromJson(j, this._createAdminInterface(j.id, tokenStore), () => this._refreshOwnedProjects(tokenStore)));
|
|
484
506
|
}
|
|
485
|
-
|
|
507
|
+
_useOwnedProjects() {
|
|
486
508
|
this._ensureInternalProject();
|
|
487
509
|
const tokenStore = getTokenStore(this._tokenStoreOptions);
|
|
488
510
|
const json = useCache(this._ownedProjectsCache, [tokenStore], "useOwnedProjects()");
|
|
489
511
|
return useMemo(() => json.map((j) => this._projectAdminFromJson(j, this._createAdminInterface(j.id, tokenStore), () => this._refreshOwnedProjects(tokenStore))), [json]);
|
|
490
512
|
}
|
|
491
|
-
|
|
513
|
+
_onOwnedProjectsChange(callback) {
|
|
492
514
|
this._ensureInternalProject();
|
|
493
515
|
const tokenStore = getTokenStore(this._tokenStoreOptions);
|
|
494
516
|
return this._ownedProjectsCache.onChange([tokenStore], (projects) => {
|
|
495
517
|
callback(projects.map((j) => this._projectAdminFromJson(j, this._createAdminInterface(j.id, tokenStore), () => this._refreshOwnedProjects(tokenStore))));
|
|
496
518
|
});
|
|
497
519
|
}
|
|
498
|
-
async
|
|
520
|
+
async _createProject(newProject) {
|
|
499
521
|
this._ensureInternalProject();
|
|
500
522
|
const tokenStore = getTokenStore(this._tokenStoreOptions);
|
|
501
523
|
const json = await this._interface.createProject(newProject, tokenStore);
|
|
@@ -620,7 +642,7 @@ class _StackServerAppImpl extends _StackClientAppImpl {
|
|
|
620
642
|
return null;
|
|
621
643
|
const app = this;
|
|
622
644
|
const nonCurrentServerUser = this._serverUserFromJson(json);
|
|
623
|
-
const
|
|
645
|
+
const currentUser = {
|
|
624
646
|
...nonCurrentServerUser,
|
|
625
647
|
tokenStore,
|
|
626
648
|
async delete() {
|
|
@@ -644,10 +666,31 @@ class _StackServerAppImpl extends _StackClientAppImpl {
|
|
|
644
666
|
},
|
|
645
667
|
updatePassword(options) {
|
|
646
668
|
return app._updatePassword(options, tokenStore);
|
|
647
|
-
}
|
|
669
|
+
},
|
|
648
670
|
};
|
|
649
|
-
|
|
650
|
-
|
|
671
|
+
if (this.isInternalProject()) {
|
|
672
|
+
const internalUser = {
|
|
673
|
+
...currentUser,
|
|
674
|
+
createProject(newProject) {
|
|
675
|
+
return app._createProject(newProject);
|
|
676
|
+
},
|
|
677
|
+
listOwnedProjects() {
|
|
678
|
+
return app._listOwnedProjects();
|
|
679
|
+
},
|
|
680
|
+
useOwnedProjects() {
|
|
681
|
+
return app._useOwnedProjects();
|
|
682
|
+
},
|
|
683
|
+
onOwnedProjectsChange(callback) {
|
|
684
|
+
return app._onOwnedProjectsChange(callback);
|
|
685
|
+
}
|
|
686
|
+
};
|
|
687
|
+
Object.freeze(internalUser);
|
|
688
|
+
return internalUser;
|
|
689
|
+
}
|
|
690
|
+
else {
|
|
691
|
+
Object.freeze(currentUser);
|
|
692
|
+
return currentUser;
|
|
693
|
+
}
|
|
651
694
|
}
|
|
652
695
|
_serverUserToJson(user) {
|
|
653
696
|
return {
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { StackClientApp } from '../lib/stack-app';
|
|
3
|
+
export default function StackProvider({ children, app, }: {
|
|
4
|
+
children: ReactNode;
|
|
5
|
+
app: StackClientApp<true>;
|
|
6
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
//# sourceMappingURL=StackProvider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StackProvider.d.ts","sourceRoot":"","sources":["../../src/providers/StackProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAClC,OAAO,EAAE,cAAc,EAA2B,MAAM,kBAAkB,CAAC;AAI3E,MAAM,CAAC,OAAO,UAAU,aAAa,CAAC,EACpC,QAAQ,EACR,GAAG,GACJ,EAAE;IACD,QAAQ,EAAE,SAAS,CAAC;IACpB,GAAG,EAAE,cAAc,CAAC,IAAI,CAAC,CAAC;CAC3B,2CAMA"}
|