@supatype/react-auth 0.3.6 → 0.8.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/.turbo/turbo-build.log +1 -1
- package/.turbo/turbo-test.log +13 -4
- package/.turbo/turbo-typecheck.log +2 -2
- package/LICENSE +1 -1
- package/README.md +103 -0
- package/dist/EmailLinkForm.d.ts +42 -0
- package/dist/EmailLinkForm.d.ts.map +1 -0
- package/dist/EmailLinkForm.js +14 -0
- package/dist/EmailLinkForm.js.map +1 -0
- package/dist/ForgotPasswordForm.d.ts +19 -0
- package/dist/ForgotPasswordForm.d.ts.map +1 -0
- package/dist/ForgotPasswordForm.js +33 -0
- package/dist/ForgotPasswordForm.js.map +1 -0
- package/dist/LoginForm.d.ts +4 -1
- package/dist/LoginForm.d.ts.map +1 -1
- package/dist/LoginForm.js +8 -24
- package/dist/LoginForm.js.map +1 -1
- package/dist/MagicLinkForm.d.ts +19 -0
- package/dist/MagicLinkForm.d.ts.map +1 -0
- package/dist/MagicLinkForm.js +33 -0
- package/dist/MagicLinkForm.js.map +1 -0
- package/dist/OAuthButton.d.ts +3 -2
- package/dist/OAuthButton.d.ts.map +1 -1
- package/dist/OAuthButton.js +79 -42
- package/dist/OAuthButton.js.map +1 -1
- package/dist/SignUpForm.d.ts +4 -1
- package/dist/SignUpForm.d.ts.map +1 -1
- package/dist/SignUpForm.js +13 -32
- package/dist/SignUpForm.js.map +1 -1
- package/dist/UpdatePasswordForm.d.ts +38 -0
- package/dist/UpdatePasswordForm.d.ts.map +1 -0
- package/dist/UpdatePasswordForm.js +36 -0
- package/dist/UpdatePasswordForm.js.map +1 -0
- package/dist/classNames.d.ts +36 -0
- package/dist/classNames.d.ts.map +1 -0
- package/dist/classNames.js +8 -0
- package/dist/classNames.js.map +1 -0
- package/dist/formParts.d.ts +68 -0
- package/dist/formParts.d.ts.map +1 -0
- package/dist/formParts.js +72 -0
- package/dist/formParts.js.map +1 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -1
- package/dist/usePasswordRecovery.d.ts +18 -0
- package/dist/usePasswordRecovery.d.ts.map +1 -0
- package/dist/usePasswordRecovery.js +27 -0
- package/dist/usePasswordRecovery.js.map +1 -0
- package/package.json +6 -4
- package/src/EmailLinkForm.tsx +62 -0
- package/src/ForgotPasswordForm.tsx +43 -0
- package/src/LoginForm.tsx +35 -62
- package/src/MagicLinkForm.tsx +43 -0
- package/src/OAuthButton.tsx +84 -60
- package/src/SignUpForm.tsx +40 -74
- package/src/UpdatePasswordForm.tsx +74 -0
- package/src/classNames.ts +41 -0
- package/src/formParts.tsx +153 -0
- package/src/index.ts +14 -0
- package/src/usePasswordRecovery.ts +32 -0
- package/tests/auth-ui.test.tsx +48 -0
- package/tests/email-link-forms.test.tsx +214 -0
- package/tests/helpers.tsx +41 -0
- package/tests/login-form.test.tsx +63 -0
- package/tests/oauth-button.test.tsx +75 -0
- package/tests/password-recovery.test.tsx +62 -0
- package/tests/props.ts +24 -0
- package/tests/signup-confirmation.test.tsx +50 -0
- package/tests/tsconfig.json +9 -0
- package/tsconfig.json +1 -1
- package/tsconfig.tsbuildinfo +1 -1
package/dist/OAuthButton.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OAuthButton.js","sourceRoot":"","sources":["../src/OAuthButton.tsx"],"names":[],"mappings":";AAAA;;;;;;;;;;;;GAYG;AAEH,OAAc,EAAE,QAAQ,EAAkB,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"OAuthButton.js","sourceRoot":"","sources":["../src/OAuthButton.tsx"],"names":[],"mappings":";AAAA;;;;;;;;;;;;GAYG;AAEH,OAAc,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAkB,MAAM,OAAO,CAAA;AAC1E,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAA;AAmBzC,qEAAqE;AACrE,MAA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CAAC,YAAY,CAAC,IAAI,CAAC,EAC/D,OAAO,EAAE,GAAG,EAAE,GAAG,KAAK,KAAK,EAAE,CAAA,CAAC,CAAC,EAC/B,QAAQ,EAAE,IAAI,aAEb,OAAO,KAAK,SAAS,IAAI,CACxB,8BACc,MAAM,EAClB,uBAAuB,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,EAC5C,KAAK,EAAE,EAAE,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,QAAQ,EAAE,GACvD,CACH,EACA,QAAQ,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,iBAAiB,YAAY,GAAG,CAAC,CAAC,CAAC,gBAAgB,YAAY,EAAE,CAAC,IACnF,CACV,CAAA;AACH,CAAC"}
|
package/dist/SignUpForm.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import type { Session, SupatypeError } from "@supatype/client";
|
|
3
|
+
import type { AuthFormClassNames } from "./classNames.js";
|
|
3
4
|
export interface SignUpFormLabels {
|
|
4
5
|
title?: string | undefined;
|
|
5
6
|
email?: string | undefined;
|
|
@@ -16,6 +17,8 @@ export interface SignUpFormProps {
|
|
|
16
17
|
className?: string | undefined;
|
|
17
18
|
/** Override display labels. */
|
|
18
19
|
labels?: SignUpFormLabels | undefined;
|
|
20
|
+
/** Class names for the elements inside the form, so an app can style them with its own classes. */
|
|
21
|
+
classNames?: AuthFormClassNames | undefined;
|
|
19
22
|
/**
|
|
20
23
|
* Additional metadata stored on the user's `user_metadata`.
|
|
21
24
|
* Merge with any custom fields collected in the form.
|
|
@@ -36,5 +39,5 @@ export interface SignUpFormProps {
|
|
|
36
39
|
* />
|
|
37
40
|
* ```
|
|
38
41
|
*/
|
|
39
|
-
export declare function SignUpForm({ onSuccess, onError, className, labels, metadata }: SignUpFormProps): React.ReactElement;
|
|
42
|
+
export declare function SignUpForm({ onSuccess, onError, className, classNames, labels, metadata }: SignUpFormProps): React.ReactElement;
|
|
40
43
|
//# sourceMappingURL=SignUpForm.d.ts.map
|
package/dist/SignUpForm.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SignUpForm.d.ts","sourceRoot":"","sources":["../src/SignUpForm.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"SignUpForm.d.ts","sourceRoot":"","sources":["../src/SignUpForm.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmB,MAAM,OAAO,CAAA;AACvC,OAAO,KAAK,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAA;AAE9D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAA;AAGzD,MAAM,WAAW,gBAAgB;IAC/B,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAC1B,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAC1B,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAC7B,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAC3B,cAAc,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;CACpC;AAED,MAAM,WAAW,eAAe;IAC9B,0GAA0G;IAC1G,SAAS,CAAC,EAAE,CAAC,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,KAAK,IAAI,CAAC,GAAG,SAAS,CAAA;IAC3D,0DAA0D;IAC1D,OAAO,CAAC,EAAE,CAAC,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,CAAC,GAAG,SAAS,CAAA;IACtD,yDAAyD;IACzD,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAC9B,+BAA+B;IAC/B,MAAM,CAAC,EAAE,gBAAgB,GAAG,SAAS,CAAA;IACrC,mGAAmG;IACnG,UAAU,CAAC,EAAE,kBAAkB,GAAG,SAAS,CAAA;IAC3C;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CAAA;CAC/C;AAUD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,UAAU,CAAC,EAAE,SAAS,EAAE,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,EAAE,eAAe,GAAG,KAAK,CAAC,YAAY,CA+C/H"}
|
package/dist/SignUpForm.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useState } from "react";
|
|
3
3
|
import { useAuth } from "@supatype/react";
|
|
4
|
+
import { FormField, FormShell, FormMessage, useAuthSubmit, withDefaults } from "./formParts.js";
|
|
4
5
|
const DEFAULT_LABELS = {
|
|
5
6
|
title: "Create account",
|
|
6
7
|
email: "Email address",
|
|
@@ -22,43 +23,23 @@ const DEFAULT_LABELS = {
|
|
|
22
23
|
* />
|
|
23
24
|
* ```
|
|
24
25
|
*/
|
|
25
|
-
export function SignUpForm({ onSuccess, onError, className, labels, metadata }) {
|
|
26
|
+
export function SignUpForm({ onSuccess, onError, className, classNames, labels, metadata }) {
|
|
26
27
|
const { signUp } = useAuth();
|
|
27
|
-
const l =
|
|
28
|
+
const l = withDefaults(DEFAULT_LABELS, labels);
|
|
28
29
|
const [email, setEmail] = useState("");
|
|
29
30
|
const [password, setPassword] = useState("");
|
|
30
|
-
const [loading, setLoading] = useState(false);
|
|
31
|
-
const [errorMessage, setErrorMessage] = useState(null);
|
|
32
31
|
const [confirmed, setConfirmed] = useState(false);
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
...(metadata !== undefined && { options: { data: metadata } }),
|
|
42
|
-
});
|
|
43
|
-
if (error !== null) {
|
|
44
|
-
setErrorMessage(error.message);
|
|
45
|
-
onError?.(error);
|
|
46
|
-
}
|
|
47
|
-
else {
|
|
48
|
-
if (data.session === null) {
|
|
49
|
-
// Email confirmation required
|
|
50
|
-
setConfirmed(true);
|
|
51
|
-
}
|
|
52
|
-
onSuccess?.(data.session);
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
finally {
|
|
56
|
-
setLoading(false);
|
|
57
|
-
}
|
|
58
|
-
}
|
|
32
|
+
const options = metadata !== undefined ? { options: { data: metadata } } : {};
|
|
33
|
+
const onDone = ({ session }) => {
|
|
34
|
+
// No session: the project requires the email to be confirmed first.
|
|
35
|
+
if (session === null)
|
|
36
|
+
setConfirmed(true);
|
|
37
|
+
onSuccess?.(session);
|
|
38
|
+
};
|
|
39
|
+
const request = useAuthSubmit(() => signUp({ email, password, ...options }), { onDone, onError });
|
|
59
40
|
if (confirmed) {
|
|
60
|
-
return
|
|
41
|
+
return _jsx(FormMessage, { text: l.successMessage, classNames: classNames });
|
|
61
42
|
}
|
|
62
|
-
return (_jsxs(
|
|
43
|
+
return (_jsxs(FormShell, { request: request, text: { title: l.title, submit: l.submit, busy: "Creating account…" }, className: className, classNames: classNames, children: [_jsx(FormField, { id: "st-signup-email", label: l.email, classNames: classNames, type: "email", autoComplete: "email", required: true, value: email, onChange: (e) => setEmail(e.target.value), disabled: request.loading }), _jsx(FormField, { id: "st-signup-password", label: l.password, classNames: classNames, type: "password", autoComplete: "new-password", required: true, minLength: 8, value: password, onChange: (e) => setPassword(e.target.value), disabled: request.loading })] }));
|
|
63
44
|
}
|
|
64
45
|
//# sourceMappingURL=SignUpForm.js.map
|
package/dist/SignUpForm.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SignUpForm.js","sourceRoot":"","sources":["../src/SignUpForm.tsx"],"names":[],"mappings":";AAAA,OAAc,EAAE,QAAQ,
|
|
1
|
+
{"version":3,"file":"SignUpForm.js","sourceRoot":"","sources":["../src/SignUpForm.tsx"],"names":[],"mappings":";AAAA,OAAc,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAEvC,OAAO,EAAE,OAAO,EA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"@supatype/client";
|
|
3
|
+
import type { AuthFormClassNames } from "./classNames.js";
|
|
4
|
+
export interface UpdatePasswordFormLabels {
|
|
5
|
+
title?: string | undefined;
|
|
6
|
+
password?: string | undefined;
|
|
7
|
+
submit?: string | undefined;
|
|
8
|
+
/** Shown in place of the form once the new password is set. */
|
|
9
|
+
successMessage?: string | undefined;
|
|
10
|
+
}
|
|
11
|
+
export interface UpdatePasswordFormProps {
|
|
12
|
+
/** Called with the updated user once the new password is set. */
|
|
13
|
+
onSuccess?: ((user: User) => void) | undefined;
|
|
14
|
+
/** Called with the error returned by the auth service. */
|
|
15
|
+
onError?: ((error: SupatypeError) => void) | undefined;
|
|
16
|
+
/** CSS class applied to the outermost <form> element. */
|
|
17
|
+
className?: string | undefined;
|
|
18
|
+
/** Override display labels. */
|
|
19
|
+
labels?: UpdatePasswordFormLabels | undefined;
|
|
20
|
+
/** Class names for the elements inside the form, so an app can style them with its own classes. */
|
|
21
|
+
classNames?: AuthFormClassNames | undefined;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Sets a new password for the signed-in user (`updateUser`, `PUT /user`).
|
|
25
|
+
* Must be rendered inside a `<SupatypeProvider>`.
|
|
26
|
+
*
|
|
27
|
+
* The landing for a password reset link: the link signs the user in and the client emits
|
|
28
|
+
* `PASSWORD_RECOVERY`, which `usePasswordRecovery` turns into state: show this form while it is active. With no session it reports
|
|
29
|
+
* "Not authenticated" through `onError`.
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* ```tsx
|
|
33
|
+
* const recovery = usePasswordRecovery()
|
|
34
|
+
* if (recovery.active) return <UpdatePasswordForm onSuccess={recovery.finish} />
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
export declare function UpdatePasswordForm({ onSuccess, onError, className, classNames, labels }: UpdatePasswordFormProps): React.ReactElement;
|
|
38
|
+
//# sourceMappingURL=UpdatePasswordForm.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"UpdatePasswordForm.d.ts","sourceRoot":"","sources":["../src/UpdatePasswordForm.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmB,MAAM,OAAO,CAAA;AACvC,OAAO,KAAK,EAAE,aAAa,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAA;AAE3D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAA;AAGzD,MAAM,WAAW,wBAAwB;IACvC,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAC1B,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAC7B,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAC3B,+DAA+D;IAC/D,cAAc,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;CACpC;AAED,MAAM,WAAW,uBAAuB;IACtC,iEAAiE;IACjE,SAAS,CAAC,EAAE,CAAC,CAAC,IAAI,EAAE,IAAI,KAAK,IAAI,CAAC,GAAG,SAAS,CAAA;IAC9C,0DAA0D;IAC1D,OAAO,CAAC,EAAE,CAAC,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,CAAC,GAAG,SAAS,CAAA;IACtD,yDAAyD;IACzD,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAC9B,+BAA+B;IAC/B,MAAM,CAAC,EAAE,wBAAwB,GAAG,SAAS,CAAA;IAC7C,mGAAmG;IACnG,UAAU,CAAC,EAAE,kBAAkB,GAAG,SAAS,CAAA;CAC5C;AASD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,kBAAkB,CAAC,EAAE,SAAS,EAAE,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,EAAE,EAAE,uBAAuB,GAAG,KAAK,CAAC,YAAY,CAyBrI"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useState } from "react";
|
|
3
|
+
import { useSupatype } from "@supatype/react";
|
|
4
|
+
import { FormField, FormShell, FormMessage, useAuthSubmit, withDefaults } from "./formParts.js";
|
|
5
|
+
const DEFAULT_LABELS = {
|
|
6
|
+
title: "Set a new password",
|
|
7
|
+
password: "New password",
|
|
8
|
+
submit: "Update password",
|
|
9
|
+
successMessage: "Your password has been updated.",
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Sets a new password for the signed-in user (`updateUser`, `PUT /user`).
|
|
13
|
+
* Must be rendered inside a `<SupatypeProvider>`.
|
|
14
|
+
*
|
|
15
|
+
* The landing for a password reset link: the link signs the user in and the client emits
|
|
16
|
+
* `PASSWORD_RECOVERY`, which `usePasswordRecovery` turns into state: show this form while it is active. With no session it reports
|
|
17
|
+
* "Not authenticated" through `onError`.
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```tsx
|
|
21
|
+
* const recovery = usePasswordRecovery()
|
|
22
|
+
* if (recovery.active) return <UpdatePasswordForm onSuccess={recovery.finish} />
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
export function UpdatePasswordForm({ onSuccess, onError, className, classNames, labels }) {
|
|
26
|
+
const { auth } = useSupatype();
|
|
27
|
+
const l = withDefaults(DEFAULT_LABELS, labels);
|
|
28
|
+
const [password, setPassword] = useState("");
|
|
29
|
+
const onDone = ({ user }) => { if (user !== null)
|
|
30
|
+
onSuccess?.(user); };
|
|
31
|
+
const request = useAuthSubmit(() => auth.updateUser({ password }), { onDone, onError });
|
|
32
|
+
if (request.done)
|
|
33
|
+
return _jsx(FormMessage, { text: l.successMessage, classNames: classNames });
|
|
34
|
+
return (_jsx(FormShell, { request: request, text: { title: l.title, submit: l.submit, busy: "Updating password…" }, className: className, classNames: classNames, children: _jsx(FormField, { id: "st-update-password", label: l.password, classNames: classNames, type: "password", autoComplete: "new-password", required: true, minLength: 8, value: password, onChange: (e) => setPassword(e.target.value), disabled: request.loading }) }));
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=UpdatePasswordForm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ExF,OAAO,CACL,KAAC,SAAS,IAAC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC,KAAK,EAAE,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,IAAI,EAAE,oBAAoB,EAAE,EAAE,SAAS,EAAE,SAAS,EAAE,UAAU,EAAE,UAAU,YAC/I,KAAC,SAAS,IACR,EAAE,EAAC,oBAAoB,EACvB,KAAK,EAAE,CAAC,CAAC,QAAQ,EACjB,UAAU,EAAE,UAAU,EACtB,IAAI,EAAC,UAAU,EACf,YAAY,EAAC,cAAc,EAC3B,QAAQ,QACR,SAAS,EAAE,CAAC,EACZ,KAAK,EAAE,QAAQ,EACf,QAAQ,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,WAAW,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAC5C,QAAQ,EAAE,OAAO,CAAC,OAAO,GACzB,GACQ,CACb,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type React from "react";
|
|
2
|
+
/**
|
|
3
|
+
* Class names for each element an auth form renders.
|
|
4
|
+
*
|
|
5
|
+
* The forms ship no stylesheet, so an app styles them with its own classes. `className` on the form
|
|
6
|
+
* only reaches the outer `<form>`; without these slots a class-based design system cannot reach the
|
|
7
|
+
* labels, inputs or button except through descendant selectors written for this one component.
|
|
8
|
+
*/
|
|
9
|
+
export interface AuthFormClassNames {
|
|
10
|
+
/** The `<h2>` heading. */
|
|
11
|
+
title?: string | undefined;
|
|
12
|
+
/** The error message shown when the auth service rejects the request. */
|
|
13
|
+
error?: string | undefined;
|
|
14
|
+
/** The wrapper around each label and input pair. */
|
|
15
|
+
field?: string | undefined;
|
|
16
|
+
/** Each `<label>`. */
|
|
17
|
+
label?: string | undefined;
|
|
18
|
+
/** Each `<input>`. */
|
|
19
|
+
input?: string | undefined;
|
|
20
|
+
/** The submit `<button>`. */
|
|
21
|
+
submit?: string | undefined;
|
|
22
|
+
/**
|
|
23
|
+
* The line a form shows in its place when done: `SignUpForm` awaiting confirmation,
|
|
24
|
+
* `ForgotPasswordForm` and `MagicLinkForm` once the email is sent, `UpdatePasswordForm` once the
|
|
25
|
+
* password is set.
|
|
26
|
+
*/
|
|
27
|
+
message?: string | undefined;
|
|
28
|
+
}
|
|
29
|
+
/** Applied to the error message only when the app gives it no class of its own. */
|
|
30
|
+
export declare const DEFAULT_ERROR_STYLE: React.CSSProperties;
|
|
31
|
+
/** Props for the error element: the app's class when given, the default colour otherwise. */
|
|
32
|
+
export declare function errorProps(classNames: AuthFormClassNames | undefined): {
|
|
33
|
+
className?: string;
|
|
34
|
+
style?: React.CSSProperties;
|
|
35
|
+
};
|
|
36
|
+
//# sourceMappingURL=classNames.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"classNames.d.ts","sourceRoot":"","sources":["../src/classNames.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAE9B;;;;;;GAMG;AACH,MAAM,WAAW,kBAAkB;IACjC,0BAA0B;IAC1B,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAC1B,yEAAyE;IACzE,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAC1B,oDAAoD;IACpD,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAC1B,sBAAsB;IACtB,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAC1B,sBAAsB;IACtB,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAC1B,6BAA6B;IAC7B,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAC3B;;;;OAIG;IACH,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;CAC7B;AAED,mFAAmF;AACnF,eAAO,MAAM,mBAAmB,EAAE,KAAK,CAAC,aAAgC,CAAA;AAExE,6FAA6F;AAC7F,wBAAgB,UAAU,CAAC,UAAU,EAAE,kBAAkB,GAAG,SAAS,GAAG;IACtE,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,KAAK,CAAC,EAAE,KAAK,CAAC,aAAa,CAAA;CAC5B,CAGA"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/** Applied to the error message only when the app gives it no class of its own. */
|
|
2
|
+
export const DEFAULT_ERROR_STYLE = { color: "red" };
|
|
3
|
+
/** Props for the error element: the app's class when given, the default colour otherwise. */
|
|
4
|
+
export function errorProps(classNames) {
|
|
5
|
+
const className = classNames?.error;
|
|
6
|
+
return className !== undefined ? { className } : { style: DEFAULT_ERROR_STYLE };
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=classNames.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"classNames.js","sourceRoot":"","sources":["../src/classNames.ts"],"names":[],"mappings":"AA8BA,mFAAmF;AACnF,MAAM,CAAC,MAAM,mBAAmB,GAAwB,EAAE,KAAK,EAAE,KAAK,EAAE,CAAA;AAExE,6FAA6F;AAC7F,MAAM,UAAU,UAAU,CAAC,UAA0C;IAInE,MAAM,SAAS,GAAG,UAAU,EAAE,KAAK,CAAA;IACnC,OAAO,SAAS,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,mBAAmB,EAAE,CAAA;AACjF,CAAC"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import React, { type FormEvent, type InputHTMLAttributes } from "react";
|
|
2
|
+
import { type SupatypeError } from "@supatype/client";
|
|
3
|
+
import { type AuthFormClassNames } from "./classNames.js";
|
|
4
|
+
/** The message a form shows in its place once the request has gone through. */
|
|
5
|
+
export declare function FormMessage({ text, classNames, }: {
|
|
6
|
+
text: string;
|
|
7
|
+
classNames: AuthFormClassNames | undefined;
|
|
8
|
+
}): React.ReactElement;
|
|
9
|
+
export type FormFieldProps = {
|
|
10
|
+
id: string;
|
|
11
|
+
label: string;
|
|
12
|
+
classNames: AuthFormClassNames | undefined;
|
|
13
|
+
} & Omit<InputHTMLAttributes<HTMLInputElement>, "className" | "id">;
|
|
14
|
+
/** One label and input pair, each carrying its `classNames` slot. */
|
|
15
|
+
export declare function FormField({ id, label, classNames, ...input }: FormFieldProps): React.ReactElement;
|
|
16
|
+
/** The words of a form's frame: its heading, its button, and the button while the request runs. */
|
|
17
|
+
export interface FormShellText {
|
|
18
|
+
title: string;
|
|
19
|
+
submit: string;
|
|
20
|
+
busy: string;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* The frame every form shares: heading, refusal, the form's own fields, then the submit button.
|
|
24
|
+
*
|
|
25
|
+
* `errorMessage` overrides the request's refusal text, for a form that words it differently.
|
|
26
|
+
*/
|
|
27
|
+
export declare function FormShell({ request, text, className, classNames, errorMessage, children }: {
|
|
28
|
+
request: AuthSubmit;
|
|
29
|
+
text: FormShellText;
|
|
30
|
+
className: string | undefined;
|
|
31
|
+
classNames: AuthFormClassNames | undefined;
|
|
32
|
+
errorMessage?: string | null | undefined;
|
|
33
|
+
children: React.ReactNode;
|
|
34
|
+
}): React.ReactElement;
|
|
35
|
+
export interface AuthSubmit {
|
|
36
|
+
loading: boolean;
|
|
37
|
+
/** The refusal to show, or null. */
|
|
38
|
+
errorMessage: string | null;
|
|
39
|
+
/** True once the request has succeeded. */
|
|
40
|
+
done: boolean;
|
|
41
|
+
onSubmit: (e: FormEvent<HTMLFormElement>) => void;
|
|
42
|
+
}
|
|
43
|
+
export interface AuthSubmitHandlers<T> {
|
|
44
|
+
onDone: (data: T) => void;
|
|
45
|
+
onError?: ((error: SupatypeError) => void) | undefined;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Submit a form's one auth request: loading while it runs, then the refusal or `done`.
|
|
49
|
+
*
|
|
50
|
+
* A refusal keeps the form so the user can correct it; `onError` hears both a refusal and a request
|
|
51
|
+
* that never reached the server. The app's own handlers run after the request, outside its error
|
|
52
|
+
* handling, so a throw in `onSuccess` is not shown as the server's refusal.
|
|
53
|
+
*/
|
|
54
|
+
export declare function useAuthSubmit<T>(send: () => Promise<{
|
|
55
|
+
data: T;
|
|
56
|
+
error: SupatypeError | null;
|
|
57
|
+
}>, handlers: AuthSubmitHandlers<T>): AuthSubmit;
|
|
58
|
+
/**
|
|
59
|
+
* The form's labels: each one the app gives, else the default.
|
|
60
|
+
*
|
|
61
|
+
* A plain spread would let `labels={{ title: undefined }}` blank the heading out.
|
|
62
|
+
*/
|
|
63
|
+
export declare function withDefaults<T extends object>(defaults: Filled<T>, overrides: T | undefined): Filled<T>;
|
|
64
|
+
/** Every label present and a string: `Required` keeps an explicit `| undefined`. */
|
|
65
|
+
export type Filled<T> = {
|
|
66
|
+
[K in keyof T]-?: Exclude<T[K], undefined>;
|
|
67
|
+
};
|
|
68
|
+
//# sourceMappingURL=formParts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formParts.d.ts","sourceRoot":"","sources":["../src/formParts.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAY,KAAK,SAAS,EAAE,KAAK,mBAAmB,EAAE,MAAM,OAAO,CAAA;AACjF,OAAO,EAAoB,KAAK,aAAa,EAAE,MAAM,kBAAkB,CAAA;AACvE,OAAO,EAAc,KAAK,kBAAkB,EAAE,MAAM,iBAAiB,CAAA;AAkBrE,+EAA+E;AAC/E,wBAAgB,WAAW,CAAC,EAC1B,IAAI,EACJ,UAAU,GACX,EAAE;IACD,IAAI,EAAE,MAAM,CAAA;IACZ,UAAU,EAAE,kBAAkB,GAAG,SAAS,CAAA;CAC3C,GAAG,KAAK,CAAC,YAAY,CAMrB;AAED,MAAM,MAAM,cAAc,GAAG;IAC3B,EAAE,EAAE,MAAM,CAAA;IACV,KAAK,EAAE,MAAM,CAAA;IACb,UAAU,EAAE,kBAAkB,GAAG,SAAS,CAAA;CAC3C,GAAG,IAAI,CAAC,mBAAmB,CAAC,gBAA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AAI,EAAE,MAAM,OAAO,CAAC;IAAE,IAAI,EAAE,CAAC,CAAC;IAAC,KAAK,EAAE,aAAa,GAAG,IAAI,CAAA;CAAE,CAAC,EAC7D,QAAQ,EAAE,kBAAkB,CAAC,CAAC,CAAC,GAC9B,UAAU,CAoBZ;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,CAAC,SAAS,MAAM,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,CAAC,GAAG,SAAS,GAAG,MAAM,CAAC,CAAC,CAAC,CAGvG;AAED,oFAAoF;AACpF,MAAM,MAAM,MAAM,CAAC,CAAC,IAAI;KAAG,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,SAAS,CAAC;CAAE,CAAA"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useState } from "react";
|
|
3
|
+
import { transportFailure } from "@supatype/client";
|
|
4
|
+
import { errorProps } from "./classNames.js";
|
|
5
|
+
/** The auth service's refusal, shown above the fields; nothing while there is none. */
|
|
6
|
+
function FormError({ message, classNames, }) {
|
|
7
|
+
if (message === null)
|
|
8
|
+
return null;
|
|
9
|
+
return (_jsx("p", { role: "alert", "aria-live": "polite", ...errorProps(classNames), children: message }));
|
|
10
|
+
}
|
|
11
|
+
/** The message a form shows in its place once the request has gone through. */
|
|
12
|
+
export function FormMessage({ text, classNames, }) {
|
|
13
|
+
return (_jsx("p", { role: "status", "aria-live": "polite", className: classNames?.message, children: text }));
|
|
14
|
+
}
|
|
15
|
+
/** One label and input pair, each carrying its `classNames` slot. */
|
|
16
|
+
export function FormField({ id, label, classNames, ...input }) {
|
|
17
|
+
return (_jsxs("div", { className: classNames?.field, children: [_jsx("label", { className: classNames?.label, htmlFor: id, children: label }), _jsx("input", { className: classNames?.input, id: id, ...input })] }));
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* The frame every form shares: heading, refusal, the form's own fields, then the submit button.
|
|
21
|
+
*
|
|
22
|
+
* `errorMessage` overrides the request's refusal text, for a form that words it differently.
|
|
23
|
+
*/
|
|
24
|
+
export function FormShell({ request, text, className, classNames, errorMessage, children }) {
|
|
25
|
+
return (_jsxs("form", { onSubmit: request.onSubmit, className: className, noValidate: true, children: [_jsx("h2", { className: classNames?.title, children: text.title }), _jsx(FormError, { message: errorMessage ?? request.errorMessage, classNames: classNames }), children, _jsx("button", { type: "submit", className: classNames?.submit, disabled: request.loading, children: request.loading ? text.busy : text.submit })] }));
|
|
26
|
+
}
|
|
27
|
+
/** The request's answer, with a request that threw (the network, not the server) as its refusal. */
|
|
28
|
+
async function settle(send) {
|
|
29
|
+
try {
|
|
30
|
+
const { data, error } = await send();
|
|
31
|
+
return error === null ? { data, error } : { error };
|
|
32
|
+
}
|
|
33
|
+
catch (err) {
|
|
34
|
+
return { error: transportFailure(err) };
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Submit a form's one auth request: loading while it runs, then the refusal or `done`.
|
|
39
|
+
*
|
|
40
|
+
* A refusal keeps the form so the user can correct it; `onError` hears both a refusal and a request
|
|
41
|
+
* that never reached the server. The app's own handlers run after the request, outside its error
|
|
42
|
+
* handling, so a throw in `onSuccess` is not shown as the server's refusal.
|
|
43
|
+
*/
|
|
44
|
+
export function useAuthSubmit(send, handlers) {
|
|
45
|
+
const [loading, setLoading] = useState(false);
|
|
46
|
+
const [errorMessage, setErrorMessage] = useState(null);
|
|
47
|
+
const [done, setDone] = useState(false);
|
|
48
|
+
async function run() {
|
|
49
|
+
setErrorMessage(null);
|
|
50
|
+
setLoading(true);
|
|
51
|
+
const result = await settle(send);
|
|
52
|
+
setLoading(false);
|
|
53
|
+
if (result.error !== null) {
|
|
54
|
+
setErrorMessage(result.error.message);
|
|
55
|
+
handlers.onError?.(result.error);
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
setDone(true);
|
|
59
|
+
handlers.onDone(result.data);
|
|
60
|
+
}
|
|
61
|
+
return { loading, errorMessage, done, onSubmit: (e) => { e.preventDefault(); void run(); } };
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* The form's labels: each one the app gives, else the default.
|
|
65
|
+
*
|
|
66
|
+
* A plain spread would let `labels={{ title: undefined }}` blank the heading out.
|
|
67
|
+
*/
|
|
68
|
+
export function withDefaults(defaults, overrides) {
|
|
69
|
+
const given = Object.entries(overrides ?? {}).filter(([, value]) => value !== undefined);
|
|
70
|
+
return { ...defaults, ...Object.fromEntries(given) };
|
|
71
|
+
}
|
|
72
|
+
//# sourceMappingURL=formParts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formParts.js","sourceRoot":"","sources":["../src/formParts.tsx"],"names":[],"mappings":";AAAA,OAAc,EAAE,QAAQ,EAA4C,MAAM,OAAO,CAAA;AACjF,OAAO,EAAE,gBAAgB,EAAsB,MAAM,kBAAkB,CAAA;AACvE,OAAO,EAAE,UAAU,EAA2B,MAAM,iBAAiB,CAAA;AAErE,uFAAuF;AACvF,SAAS,SAAS,CAAC,EACjB,OAAO,EACP,UAAU,GAIX;IACC,IAAI,OAAO,KAAK,IAAI;QAAE,OAAO,IAAI,CAAA;IACjC,OAAO,CACL,YAAG,IAAI,EAAC,OAAO,eAAW,QAAQ,KAAK,UAAU,CAAC,UAAU,CAAC,YAC1D,OAAO,GACN,CACL,CAAA;AACH,CAAC;AAED,+EAA+E;AAC/E,MAAM,UAAU,WAAW,CAAC,EAC1B,IAAI,EACJ,UAAU,GAIX;IACC,OAAO,CACL,YAAG,IAAI,EAAC,QAAQ,eAAW,QAAQ,EAAC,SAAS,EAAE,UAAU,EAAE,OAAO,YAC/D,IAAI,GACH,CACL,CAAA;AACH,CAAC;AAQD,qEAAqE;AACrE,MAAM,UAAU,SAAS,CAAC,EAAE,EAAE,EAAE,KAAK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E,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,KAAK,KAAK,SAAS,CAAC,CAAA;IACxF,OAAO,EAAE,GAAG,QAAQ,EAAE,GAAG,MAAM,CAAC,WAAW,CAAC,KAAK,CAAC,EAAE,CAAA;AACtD,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -2,6 +2,15 @@ export { LoginForm } from "./LoginForm.js";
|
|
|
2
2
|
export type { LoginFormProps, LoginFormLabels } from "./LoginForm.js";
|
|
3
3
|
export { SignUpForm } from "./SignUpForm.js";
|
|
4
4
|
export type { SignUpFormProps, SignUpFormLabels } from "./SignUpForm.js";
|
|
5
|
+
export { ForgotPasswordForm } from "./ForgotPasswordForm.js";
|
|
6
|
+
export type { ForgotPasswordFormProps, ForgotPasswordFormLabels } from "./ForgotPasswordForm.js";
|
|
7
|
+
export { MagicLinkForm } from "./MagicLinkForm.js";
|
|
8
|
+
export type { MagicLinkFormProps, MagicLinkFormLabels } from "./MagicLinkForm.js";
|
|
9
|
+
export { UpdatePasswordForm } from "./UpdatePasswordForm.js";
|
|
10
|
+
export type { UpdatePasswordFormProps, UpdatePasswordFormLabels } from "./UpdatePasswordForm.js";
|
|
11
|
+
export { usePasswordRecovery } from "./usePasswordRecovery.js";
|
|
12
|
+
export type { PasswordRecovery } from "./usePasswordRecovery.js";
|
|
5
13
|
export { OAuthButton } from "./OAuthButton.js";
|
|
6
14
|
export type { OAuthButtonProps } from "./OAuthButton.js";
|
|
15
|
+
export type { AuthFormClassNames } from "./classNames.js";
|
|
7
16
|
//# 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,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAC1C,YAAY,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,g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LoginForm } from "./LoginForm.js";
|
|
2
2
|
export { SignUpForm } from "./SignUpForm.js";
|
|
3
|
+
export { ForgotPasswordForm } from "./ForgotPasswordForm.js";
|
|
4
|
+
export { MagicLinkForm } from "./MagicLinkForm.js";
|
|
5
|
+
export { UpdatePasswordForm } from "./UpdatePasswordForm.js";
|
|
6
|
+
export { usePasswordRecovery } from "./usePasswordRecovery.js";
|
|
3
7
|
export { OAuthButton } from "./OAuthButton.js";
|
|
4
8
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAG1C,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAG5C,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAG1C,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAG5C,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AAG5D,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAGlD,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AAG5D,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAA;AAG9D,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export interface PasswordRecovery {
|
|
2
|
+
/** True from the moment a password reset link signs the user in until `finish` or a sign-out. */
|
|
3
|
+
active: boolean;
|
|
4
|
+
/** Call once the new password is set, so the app shows itself again. */
|
|
5
|
+
finish: () => void;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Whether the user arrived through a password reset link and still has to choose a new password.
|
|
9
|
+
*
|
|
10
|
+
* The link signs the user in and the client emits `PASSWORD_RECOVERY` after `SIGNED_IN`. Without
|
|
11
|
+
* this an app that renders whenever there is a user drops them inside it, signed in with the
|
|
12
|
+
* password they forgot. Show `UpdatePasswordForm` while `active`.
|
|
13
|
+
*
|
|
14
|
+
* Must be rendered inside a `<SupatypeProvider>`, mounted from the first render (beside `useAuth`),
|
|
15
|
+
* because the event is emitted once while the client finishes the link on start.
|
|
16
|
+
*/
|
|
17
|
+
export declare function usePasswordRecovery(): PasswordRecovery;
|
|
18
|
+
//# sourceMappingURL=usePasswordRecovery.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usePasswordRecovery.d.ts","sourceRoot":"","sources":["../src/usePasswordRecovery.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,gBAAgB;IAC/B,iGAAiG;IACjG,MAAM,EAAE,OAAO,CAAA;IACf,wEAAwE;IACxE,MAAM,EAAE,MAAM,IAAI,CAAA;CACnB;AAED;;;;;;;;;GASG;AACH,wBAAgB,mBAAmB,IAAI,gBAAgB,CAWtD"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { useEffect, useState } from "react";
|
|
2
|
+
import { useSupatype } from "@supatype/react";
|
|
3
|
+
/**
|
|
4
|
+
* Whether the user arrived through a password reset link and still has to choose a new password.
|
|
5
|
+
*
|
|
6
|
+
* The link signs the user in and the client emits `PASSWORD_RECOVERY` after `SIGNED_IN`. Without
|
|
7
|
+
* this an app that renders whenever there is a user drops them inside it, signed in with the
|
|
8
|
+
* password they forgot. Show `UpdatePasswordForm` while `active`.
|
|
9
|
+
*
|
|
10
|
+
* Must be rendered inside a `<SupatypeProvider>`, mounted from the first render (beside `useAuth`),
|
|
11
|
+
* because the event is emitted once while the client finishes the link on start.
|
|
12
|
+
*/
|
|
13
|
+
export function usePasswordRecovery() {
|
|
14
|
+
const client = useSupatype();
|
|
15
|
+
const [active, setActive] = useState(false);
|
|
16
|
+
useEffect(() => {
|
|
17
|
+
const { data } = client.auth.onAuthStateChange((event) => {
|
|
18
|
+
if (event === "PASSWORD_RECOVERY")
|
|
19
|
+
setActive(true);
|
|
20
|
+
if (event === "SIGNED_OUT")
|
|
21
|
+
setActive(false);
|
|
22
|
+
});
|
|
23
|
+
return () => data.subscription.unsubscribe();
|
|
24
|
+
}, [client]);
|
|
25
|
+
return { active, finish: () => setActive(false) };
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=usePasswordRecovery.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usePasswordRecovery.js","sourceRoot":"","sources":["../src/usePasswordRecovery.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAC3C,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAS7C;;;;;;;;;GASG;AACH,MAAM,UAAU,mBAAmB;IACjC,MAAM,MAAM,GAAG,WAAW,EAAE,CAAA;IAC5B,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAA;IAC3C,SAAS,CAAC,GAAG,EAAE;QACb,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC,KAAK,EAAE,EAAE;YACvD,IAAI,KAAK,KAAK,mBAAmB;gBAAE,SAAS,CAAC,IAAI,CAAC,CAAA;YAClD,IAAI,KAAK,KAAK,YAAY;gBAAE,SAAS,CAAC,KAAK,CAAC,CAAA;QAC9C,CAAC,CAAC,CAAA;QACF,OAAO,GAAG,EAAE,CAAC,IAAI,CAAC,YAAY,CAAC,WAAW,EAAE,CAAA;IAC9C,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,CAAA;IACZ,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,CAAA;AACnD,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@supatype/react-auth",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "Pre-built authentication UI components for Supatype",
|
|
6
6
|
"type": "module",
|
|
@@ -13,22 +13,24 @@
|
|
|
13
13
|
}
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@supatype/react": "0.
|
|
17
|
-
"@supatype/client": "0.
|
|
16
|
+
"@supatype/react": "0.8.0",
|
|
17
|
+
"@supatype/client": "0.8.0"
|
|
18
18
|
},
|
|
19
19
|
"peerDependencies": {
|
|
20
20
|
"react": ">=18"
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
23
|
"@types/react": "^18",
|
|
24
|
+
"@types/react-test-renderer": "^18",
|
|
24
25
|
"react": "^18",
|
|
26
|
+
"react-test-renderer": "^18",
|
|
25
27
|
"typescript": "^5",
|
|
26
28
|
"vitest": "^4.0.18"
|
|
27
29
|
},
|
|
28
30
|
"scripts": {
|
|
29
31
|
"build": "tsc",
|
|
30
32
|
"dev": "tsc --watch",
|
|
31
|
-
"typecheck": "tsc --noEmit",
|
|
33
|
+
"typecheck": "tsc --project tests/tsconfig.json --noEmit",
|
|
32
34
|
"test": "vitest run --passWithNoTests",
|
|
33
35
|
"clean": "rm -rf dist *.tsbuildinfo"
|
|
34
36
|
}
|