Skip to content

Commit bfeb3e3

Browse files
committed
chore: docs #83
1 parent 0f851ad commit bfeb3e3

File tree

2 files changed

+14
-9
lines changed

2 files changed

+14
-9
lines changed

docs/README.md

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,21 @@ Remix Auth TOTP exports one required method:
1919
Here's a basic overview of the authentication flow.
2020

2121
1. Users Sign Up or Log In via email.
22-
2. The Strategy generates and securely sends a Time-based One-Time Password (TOTP) to the user.
23-
3. Users submit the Code through a Form or Magic Link.
22+
2. The Strategy generates and securely sends a Time-Based One-Time Password (TOTP) to the user.
23+
3. The user submits the Code through a Form or Magic Link.
2424
4. The Strategy validates the TOTP Code, ensuring a secure authentication process.
2525
<br />
2626

2727
> [!NOTE]
28-
> Remix Auth TOTP is only Remix v2.0+ compatible.
28+
> Remix Auth TOTP is Remix v2.0+ and React Router v7 compatible.
2929
3030
Let's see how we can implement the Strategy into our Remix App.
3131

3232
## Email Service
3333

34-
We'll require an Email Service to send the codes to our users. Feel free to use any service of choice, such as [Resend](https://resend.com), [Mailgun](https://www.mailgun.com), [Sendgrid](https://sendgrid.com), etc. The goal is to have a sender function similar to the following one.
34+
We'll require an Email Service to send the codes to our users.
35+
36+
Feel free to use any service of choice, such as [Resend](https://resend.com), [Mailgun](https://www.mailgun.com), [Sendgrid](https://sendgrid.com), etc. The goal is to have a sender function similar to the following one.
3537

3638
```ts
3739
export type SendEmailBody = {
@@ -53,7 +55,9 @@ export async function sendEmail(body: SendEmailBody) {
5355
}
5456
```
5557

56-
In the [Starter Example](https://github.com/dev-xo/totp-starter-example/blob/main/app/modules/email/email.server.ts) project, we can find a straightforward `sendEmail` implementation using [Resend](https://resend.com).
58+
For a simple implementation, check out the [Remix Starter Example](https://github.com/dev-xo/totp-starter-example/blob/main/app/modules/email/email.server.ts), which provides a clean and straightforward `sendEmail` function using [Resend](https://resend.com).
59+
60+
This implementation works with both Remix and React Router v7 applications.
5761

5862
## Session Storage
5963

@@ -74,7 +78,7 @@ export const sessionStorage = createCookieSessionStorage({
7478
sameSite: 'lax',
7579
path: '/',
7680
httpOnly: true,
77-
secrets: [process.env.SESSION_SECRET || 'NOT_A_STRONG_SECRET'],
81+
secrets: [process.env.SESSION_SECRET || 'MY_STRONG_SECRET'],
7882
secure: process.env.NODE_ENV === 'production',
7983
},
8084
})
@@ -114,7 +118,7 @@ export let authenticator = new Authenticator<User>(sessionStorage)
114118
authenticator.use(
115119
new TOTPStrategy(
116120
{
117-
secret: process.env.ENCRYPTION_SECRET || 'NOT_A_STRONG_SECRET',
121+
secret: process.env.ENCRYPTION_SECRET || 'MY_64_HEX_SECRET',
118122
emailSentRedirect: '/verify',
119123
magicLinkPath: '/verify',
120124
successRedirect: '/dashboard',
@@ -305,6 +309,7 @@ export async function loader({ request }: Route.LoaderArgs) {
305309

306310
// Get the email from the TOTP cookie.
307311
let email = null
312+
308313
if (totpCookie) {
309314
const params = new URLSearchParams(totpCookie)
310315
email = params.get('email')
@@ -357,9 +362,9 @@ export default function Verify() {
357362
<fetcher.Form method="POST">
358363
<input
359364
required
365+
name="code"
360366
value={value}
361367
onChange={(e) => setValue(e.target.value)}
362-
disabled={isSubmitting}
363368
placeholder="Enter the 6-digit code"
364369
/>
365370
<button type="submit">Continue</button>

src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ export interface TOTPGenerationOptions {
5959

6060
/**
6161
* The algorithm used to generate the TOTP.
62-
* @default 'SHA1'
62+
* @default 'SHA-256'
6363
*/
6464
algorithm?: string
6565

0 commit comments

Comments
 (0)