@sqrzro/auth 4.0.0-alpha.5 → 4.0.0-alpha.7

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.
@@ -1,5 +1,5 @@
1
1
 
2
2
  
3
- > @sqrzro/auth@4.0.0-alpha.4 build /Users/richard/Sites/@sqrzro/sqrzro/packages/auth
3
+ > @sqrzro/auth@4.0.0-alpha.5 build /Users/richard/Sites/@sqrzro/sqrzro/packages/auth
4
4
  > tsc
5
5
 
@@ -1,16 +1,12 @@
1
1
 
2
- > @sqrzro/auth@4.0.0-alpha.4 dev /Users/richard/Sites/@sqrzro/sqrzro/packages/auth
2
+ > @sqrzro/auth@4.0.0-alpha.5 dev /Users/richard/Sites/@sqrzro/sqrzro/packages/auth
3
3
  > tsc --watch
4
4
 
5
- [9:53:22 AM] Starting compilation in watch mode...
5
+ [2:01:09 PM] Starting compilation in watch mode...
6
6
 
7
- [9:53:24 AM] Found 0 errors. Watching for file changes.
7
+ [2:01:11 PM] Found 0 errors. Watching for file changes.
8
8
 
9
- [9:53:26 AM] File change detected. Starting incremental compilation...
10
-
11
- [9:53:26 AM] Found 0 errors. Watching for file changes.
12
-
13
- [9:53:27 AM] File change detected. Starting incremental compilation...
9
+ [2:01:13 PM] File change detected. Starting incremental compilation...
14
10
 
15
11
  src/components/LogoutButton/server.ts:3:31 - error TS7016: Could not find a declaration file for module '@sqrzro/server/auth'. '/Users/richard/Sites/@sqrzro/sqrzro/packages/server/dist/auth/index.js' implicitly has an 'any' type.
16
12
  Try `npm i --save-dev @types/sqrzro__server` if it exists or add a new declaration (.d.ts) file containing `declare module '@sqrzro/server/auth';`
@@ -72,26 +68,26 @@
72
68
  1 import { validateSession } from '@sqrzro/server/auth';
73
69
     ~~~~~~~~~~~~~~~~~~~~~
74
70
 
75
- [9:53:27 AM] Found 10 errors. Watching for file changes.
71
+ [2:01:13 PM] Found 10 errors. Watching for file changes.
76
72
 
77
- [9:53:29 AM] File change detected. Starting incremental compilation...
73
+ [2:01:16 PM] File change detected. Starting incremental compilation...
78
74
 
79
- [9:53:30 AM] Found 0 errors. Watching for file changes.
75
+ [2:01:16 PM] Found 0 errors. Watching for file changes.
80
76
 
81
- [10:02:28 AM] File change detected. Starting incremental compilation...
77
+ [2:13:49 PM] File change detected. Starting incremental compilation...
82
78
 
83
- [10:02:28 AM] Found 0 errors. Watching for file changes.
79
+ [2:13:50 PM] Found 0 errors. Watching for file changes.
84
80
 
85
- [10:06:19 AM] File change detected. Starting incremental compilation...
81
+ [2:13:50 PM] File change detected. Starting incremental compilation...
86
82
 
87
- [10:06:19 AM] Found 0 errors. Watching for file changes.
83
+ [2:13:50 PM] Found 0 errors. Watching for file changes.
88
84
 
89
- [10:15:31 AM] File change detected. Starting incremental compilation...
85
+ [2:21:47 PM] File change detected. Starting incremental compilation...
90
86
 
91
- [10:15:31 AM] Found 0 errors. Watching for file changes.
87
+ [2:21:47 PM] Found 0 errors. Watching for file changes.
92
88
 
93
- [10:21:37 AM] File change detected. Starting incremental compilation...
89
+ [2:21:49 PM] File change detected. Starting incremental compilation...
94
90
 
95
- [10:21:37 AM] Found 0 errors. Watching for file changes.
91
+ [2:21:49 PM] Found 0 errors. Watching for file changes.
96
92
 
97
93
   ELIFECYCLE  Command failed.
@@ -1,6 +1,7 @@
1
- interface AuthProps {
2
- params: Promise<Record<string, string>>;
3
- searchParams: Promise<Record<string, string>>;
1
+ import type { NextPageProps } from '@sqrzro/ui/utility';
2
+ import type { AuthClassNameProps } from '../../interfaces';
3
+ interface AuthPageProps extends AuthClassNameProps, NextPageProps {
4
+ logo?: React.ReactElement;
4
5
  }
5
- declare function Auth({ params, searchParams }: Readonly<AuthProps>): React.ReactElement;
6
+ declare function Auth({ classNames, logo, ...props }: AuthPageProps): React.ReactElement;
6
7
  export default Auth;
@@ -3,23 +3,23 @@ import { Suspense } from 'react';
3
3
  import { notFound } from 'next/navigation';
4
4
  import LoginForm from '../../forms/LoginForm';
5
5
  import Password from '../Password';
6
- async function AuthComponent({ params, searchParams, }) {
6
+ async function AuthComponent({ classNames, params, searchParams, }) {
7
7
  const awaitedParams = await params;
8
- if (!Array.isArray(awaitedParams.auth) || awaitedParams.auth.length !== 1) {
8
+ if (!awaitedParams || !Array.isArray(awaitedParams.auth) || awaitedParams.auth.length !== 1) {
9
9
  return notFound();
10
10
  }
11
11
  if (awaitedParams.auth[0] === 'login') {
12
- return _jsx(LoginForm, {});
12
+ return _jsx(LoginForm, { classNames: classNames });
13
13
  }
14
14
  if (awaitedParams.auth[0] === 'mfa') {
15
15
  return _jsx("div", { children: "[MFA NOT DONE]" });
16
16
  }
17
17
  if (awaitedParams.auth[0] === 'password') {
18
- return _jsx(Password, { searchParams: searchParams });
18
+ return _jsx(Password, { classNames: classNames, searchParams: searchParams });
19
19
  }
20
20
  return notFound();
21
21
  }
22
- function Auth({ params, searchParams }) {
23
- return (_jsxs("div", { children: ["AUTH PAGE HEADER", _jsx(Suspense, { children: _jsx(AuthComponent, { params: params, searchParams: searchParams }) })] }));
22
+ function Auth({ classNames, logo, ...props }) {
23
+ return (_jsxs("div", { className: classNames?.root, children: [_jsx("div", { className: classNames?.logo, children: logo }), _jsx("div", { className: classNames?.panel, children: _jsx(Suspense, { children: _jsx(AuthComponent, { classNames: classNames, ...props }) }) })] }));
24
24
  }
25
25
  export default Auth;
@@ -1,5 +1,6 @@
1
- interface PasswordProps {
2
- searchParams: Promise<Record<string, string>>;
1
+ import type { AuthClassNameProps } from '../../interfaces';
2
+ interface PasswordProps extends AuthClassNameProps {
3
+ searchParams?: Promise<Record<string, string>> | null;
3
4
  }
4
- declare function Password({ searchParams }: Readonly<PasswordProps>): Promise<React.ReactElement>;
5
+ declare function Password({ classNames, searchParams, }: Readonly<PasswordProps>): Promise<React.ReactElement>;
5
6
  export default Password;
@@ -2,17 +2,17 @@ import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { validateReset } from '@sqrzro/server/auth';
3
3
  import PasswordForm from '../../forms/PasswordForm';
4
4
  import PasswordResetForm from '../../forms/PasswordResetForm';
5
- async function Password({ searchParams }) {
5
+ async function Password({ classNames, searchParams, }) {
6
6
  const awaitedSearchParams = await searchParams;
7
- if (awaitedSearchParams.token) {
7
+ if (awaitedSearchParams?.token) {
8
8
  const validated = await validateReset('PASSWORD', awaitedSearchParams.token);
9
9
  if (validated) {
10
- return _jsx(PasswordResetForm, { token: awaitedSearchParams.token });
10
+ return _jsx(PasswordResetForm, { token: awaitedSearchParams.token, classNames: classNames });
11
11
  }
12
12
  else {
13
13
  return _jsx("div", { children: "Invalid or Expired Token" });
14
14
  }
15
15
  }
16
- return _jsx(PasswordForm, {});
16
+ return _jsx(PasswordForm, { classNames: classNames });
17
17
  }
18
18
  export default Password;
@@ -1,2 +1,3 @@
1
- declare function LoginForm(): React.ReactElement | null;
1
+ import type { AuthClassNameProps } from '../../interfaces';
2
+ declare function LoginForm({ classNames }: AuthClassNameProps): React.ReactElement | null;
2
3
  export default LoginForm;
@@ -4,10 +4,10 @@ import { Fragment } from 'react';
4
4
  import { Link } from '@sqrzro/ui/components';
5
5
  import { Form, FormSubmit, PasswordFormField, TextFormField, useForm } from '@sqrzro/ui/forms';
6
6
  import submit from './server';
7
- function LoginForm() {
7
+ function LoginForm({ classNames }) {
8
8
  const { fieldProps, formData, formProps } = useForm({
9
9
  onSubmit: submit,
10
10
  });
11
- return (_jsx(Fragment, { children: _jsxs(Form, { ...formProps, children: [_jsx(TextFormField, { ...fieldProps('email'), hasAssistiveError: true }), _jsx(PasswordFormField, { ...fieldProps('password'), hasAssistiveError: true }), _jsx(FormSubmit, { children: "Sign In" }), _jsx("footer", { children: _jsx(Link, { href: `/auth/password${formData.email ? `?email=${formData.email}` : ''}`, children: "Forgot Password?" }) })] }) }));
11
+ return (_jsxs(Fragment, { children: [_jsx("h1", { className: classNames?.title, children: "Sign in to continue" }), _jsxs(Form, { ...formProps, children: [_jsx(TextFormField, { ...fieldProps('email'), hasAssistiveError: true }), _jsx(PasswordFormField, { ...fieldProps('password'), hasAssistiveError: true }), _jsx("div", { className: classNames?.actions, children: _jsx(FormSubmit, { isFullWidth: true, children: "Sign In" }) }), _jsx("footer", { className: classNames?.footer, children: _jsx(Link, { className: classNames?.link, href: `/auth/password${formData.email ? `?email=${formData.email}` : ''}`, children: "Forgot Password?" }) })] })] }));
12
12
  }
13
13
  export default LoginForm;
@@ -1,2 +1,3 @@
1
- declare function PasswordForm(): React.ReactElement | null;
1
+ import type { AuthClassNameProps } from '../../interfaces';
2
+ declare function PasswordForm({ classNames }: AuthClassNameProps): React.ReactElement | null;
2
3
  export default PasswordForm;
@@ -3,7 +3,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import { Fragment } from 'react';
4
4
  import { Form, FormSubmit, TextFormField, useForm } from '@sqrzro/ui/forms';
5
5
  import submit from './server';
6
- function PasswordForm() {
6
+ function PasswordForm({ classNames }) {
7
7
  const { fieldProps, formProps } = useForm({
8
8
  onSubmit: submit,
9
9
  });
@@ -1,5 +1,6 @@
1
- interface PasswordResetFormProps {
1
+ import type { AuthClassNameProps } from '../../interfaces';
2
+ interface PasswordResetFormProps extends AuthClassNameProps {
2
3
  token: string;
3
4
  }
4
- declare function PasswordResetForm({ token }: Readonly<PasswordResetFormProps>): React.ReactElement | null;
5
+ declare function PasswordResetForm({ classNames, token, }: Readonly<PasswordResetFormProps>): React.ReactElement | null;
5
6
  export default PasswordResetForm;
@@ -3,7 +3,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import { Fragment } from 'react';
4
4
  import { Form, FormSubmit, PasswordFormField, useForm } from '@sqrzro/ui/forms';
5
5
  import submit from './server';
6
- function PasswordResetForm({ token }) {
6
+ function PasswordResetForm({ classNames, token, }) {
7
7
  const { fieldProps, formProps } = useForm({
8
8
  defaults: { token },
9
9
  onSubmit: submit,
@@ -8,3 +8,6 @@ export interface AuthClassNames {
8
8
  panel: string;
9
9
  title: string;
10
10
  }
11
+ export interface AuthClassNameProps {
12
+ classNames?: Partial<AuthClassNames>;
13
+ }
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@sqrzro/auth",
3
3
  "type": "module",
4
- "version": "4.0.0-alpha.5",
4
+ "version": "4.0.0-alpha.7",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "dependencies": {
8
8
  "zod": "^4.3.6",
9
- "@sqrzro/server": "^4.0.0-alpha.13",
10
- "@sqrzro/ui": "^4.0.0-alpha.5"
9
+ "@sqrzro/server": "^4.0.0-alpha.16",
10
+ "@sqrzro/ui": "^4.0.0-alpha.13"
11
11
  },
12
12
  "devDependencies": {
13
13
  "@types/react": "^19.2.7",
@@ -1,27 +1,30 @@
1
1
  import { Suspense } from 'react';
2
2
 
3
+ import type { NextPageProps } from '@sqrzro/ui/utility';
3
4
  import { notFound } from 'next/navigation';
4
5
 
5
6
  import LoginForm from '../../forms/LoginForm';
7
+ import type { AuthClassNameProps } from '../../interfaces';
8
+
6
9
  import Password from '../Password';
7
10
 
8
- interface AuthProps {
9
- params: Promise<Record<string, string>>;
10
- searchParams: Promise<Record<string, string>>;
11
+ interface AuthPageProps extends AuthClassNameProps, NextPageProps {
12
+ logo?: React.ReactElement;
11
13
  }
12
14
 
13
15
  async function AuthComponent({
16
+ classNames,
14
17
  params,
15
18
  searchParams,
16
- }: Readonly<AuthProps>): Promise<React.ReactElement> {
19
+ }: AuthPageProps): Promise<React.ReactElement> {
17
20
  const awaitedParams = await params;
18
21
 
19
- if (!Array.isArray(awaitedParams.auth) || awaitedParams.auth.length !== 1) {
22
+ if (!awaitedParams || !Array.isArray(awaitedParams.auth) || awaitedParams.auth.length !== 1) {
20
23
  return notFound();
21
24
  }
22
25
 
23
26
  if (awaitedParams.auth[0] === 'login') {
24
- return <LoginForm />;
27
+ return <LoginForm classNames={classNames} />;
25
28
  }
26
29
 
27
30
  if (awaitedParams.auth[0] === 'mfa') {
@@ -29,19 +32,21 @@ async function AuthComponent({
29
32
  }
30
33
 
31
34
  if (awaitedParams.auth[0] === 'password') {
32
- return <Password searchParams={searchParams} />;
35
+ return <Password classNames={classNames} searchParams={searchParams} />;
33
36
  }
34
37
 
35
38
  return notFound();
36
39
  }
37
40
 
38
- function Auth({ params, searchParams }: Readonly<AuthProps>): React.ReactElement {
41
+ function Auth({ classNames, logo, ...props }: AuthPageProps): React.ReactElement {
39
42
  return (
40
- <div>
41
- AUTH PAGE HEADER
42
- <Suspense>
43
- <AuthComponent params={params} searchParams={searchParams} />
44
- </Suspense>
43
+ <div className={classNames?.root}>
44
+ <div className={classNames?.logo}>{logo}</div>
45
+ <div className={classNames?.panel}>
46
+ <Suspense>
47
+ <AuthComponent classNames={classNames} {...props} />
48
+ </Suspense>
49
+ </div>
45
50
  </div>
46
51
  );
47
52
  }
@@ -2,25 +2,29 @@ import { validateReset } from '@sqrzro/server/auth';
2
2
 
3
3
  import PasswordForm from '../../forms/PasswordForm';
4
4
  import PasswordResetForm from '../../forms/PasswordResetForm';
5
+ import type { AuthClassNameProps } from '../../interfaces';
5
6
 
6
- interface PasswordProps {
7
- searchParams: Promise<Record<string, string>>;
7
+ interface PasswordProps extends AuthClassNameProps {
8
+ searchParams?: Promise<Record<string, string>> | null;
8
9
  }
9
10
 
10
- async function Password({ searchParams }: Readonly<PasswordProps>): Promise<React.ReactElement> {
11
+ async function Password({
12
+ classNames,
13
+ searchParams,
14
+ }: Readonly<PasswordProps>): Promise<React.ReactElement> {
11
15
  const awaitedSearchParams = await searchParams;
12
16
 
13
- if (awaitedSearchParams.token) {
17
+ if (awaitedSearchParams?.token) {
14
18
  const validated = await validateReset('PASSWORD', awaitedSearchParams.token);
15
19
 
16
20
  if (validated) {
17
- return <PasswordResetForm token={awaitedSearchParams.token} />;
21
+ return <PasswordResetForm token={awaitedSearchParams.token} classNames={classNames} />;
18
22
  } else {
19
23
  return <div>Invalid or Expired Token</div>;
20
24
  }
21
25
  }
22
26
 
23
- return <PasswordForm />;
27
+ return <PasswordForm classNames={classNames} />;
24
28
  }
25
29
 
26
30
  export default Password;
@@ -5,21 +5,27 @@ import { Fragment } from 'react';
5
5
  import { Link } from '@sqrzro/ui/components';
6
6
  import { Form, FormSubmit, PasswordFormField, TextFormField, useForm } from '@sqrzro/ui/forms';
7
7
 
8
+ import type { AuthClassNameProps } from '../../interfaces';
9
+
8
10
  import submit from './server';
9
11
 
10
- function LoginForm(): React.ReactElement | null {
12
+ function LoginForm({ classNames }: AuthClassNameProps): React.ReactElement | null {
11
13
  const { fieldProps, formData, formProps } = useForm({
12
14
  onSubmit: submit,
13
15
  });
14
16
 
15
17
  return (
16
18
  <Fragment>
19
+ <h1 className={classNames?.title}>Sign in to continue</h1>
17
20
  <Form {...formProps}>
18
21
  <TextFormField {...fieldProps('email')} hasAssistiveError />
19
22
  <PasswordFormField {...fieldProps('password')} hasAssistiveError />
20
- <FormSubmit>Sign In</FormSubmit>
21
- <footer>
23
+ <div className={classNames?.actions}>
24
+ <FormSubmit isFullWidth>Sign In</FormSubmit>
25
+ </div>
26
+ <footer className={classNames?.footer}>
22
27
  <Link
28
+ className={classNames?.link}
23
29
  href={`/auth/password${formData.email ? `?email=${formData.email}` : ''}`}
24
30
  >
25
31
  Forgot Password?
@@ -4,9 +4,11 @@ import { Fragment } from 'react';
4
4
 
5
5
  import { Form, FormSubmit, TextFormField, useForm } from '@sqrzro/ui/forms';
6
6
 
7
+ import type { AuthClassNameProps } from '../../interfaces';
8
+
7
9
  import submit from './server';
8
10
 
9
- function PasswordForm(): React.ReactElement | null {
11
+ function PasswordForm({ classNames }: AuthClassNameProps): React.ReactElement | null {
10
12
  const { fieldProps, formProps } = useForm({
11
13
  onSubmit: submit,
12
14
  });
@@ -4,13 +4,18 @@ import { Fragment } from 'react';
4
4
 
5
5
  import { Form, FormSubmit, PasswordFormField, useForm } from '@sqrzro/ui/forms';
6
6
 
7
+ import type { AuthClassNameProps } from '../../interfaces';
8
+
7
9
  import submit from './server';
8
10
 
9
- interface PasswordResetFormProps {
11
+ interface PasswordResetFormProps extends AuthClassNameProps {
10
12
  token: string;
11
13
  }
12
14
 
13
- function PasswordResetForm({ token }: Readonly<PasswordResetFormProps>): React.ReactElement | null {
15
+ function PasswordResetForm({
16
+ classNames,
17
+ token,
18
+ }: Readonly<PasswordResetFormProps>): React.ReactElement | null {
14
19
  const { fieldProps, formProps } = useForm({
15
20
  defaults: { token },
16
21
  onSubmit: submit,
package/src/interfaces.ts CHANGED
@@ -7,4 +7,8 @@ export interface AuthClassNames {
7
7
  root: string;
8
8
  panel: string;
9
9
  title: string;
10
- }
10
+ }
11
+
12
+ export interface AuthClassNameProps {
13
+ classNames?: Partial<AuthClassNames>;
14
+ }