-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: increase entropy of email login OTP (#230)
* feat: move lib/auth.ts to its own directory, add constants * feat: add email auth schema to share between client and server * feat: use shared zod schema in email auth procedures * feat: use shared zod schema in client * fix: move lib/auth/session.ts into server folder since it uses some env vars, incorrect to put it in lib * feat: simplify login email state use one object (since they are always updated at the same time) instead of multiple different strings * feat: increase entropy of login OTP * feat: add handling for new alphanum OTP * feat: make BAD_REQUEST not retryable * feat: reset OTP field on resend OTP * fix: update email otp tests * feat: update otp story * fix: correct success test return * fix: test again
- Loading branch information
Showing
17 changed files
with
203 additions
and
100 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
export const MAX_VFN_ATTEMPTS = 5 | ||
|
||
export const OTP_LENGTH = 6 | ||
export const OTP_PREFIX_LENGTH = 3 | ||
|
||
// Alphabet space with ambiguous characters removed. | ||
export const OTP_ALPHABET = '23456789ABCDEFGHJKLMNPQRSTUVWXYZ' | ||
export const OTP_PREFIX_ALPHABET = 'ABCDEFGHJKLMNPQRSTUVWXYZ' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './constants' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { z } from 'zod' | ||
import { OTP_LENGTH } from '~/lib/auth' | ||
import { normaliseEmail } from '~/utils/zod' | ||
|
||
export const emailSignInSchema = z.object({ | ||
email: normaliseEmail, | ||
}) | ||
|
||
export const emailVerifyOtpSchema = emailSignInSchema.extend({ | ||
token: z | ||
.string() | ||
.trim() | ||
.min(1, 'OTP is required.') | ||
.length(OTP_LENGTH, `Please enter a ${OTP_LENGTH} character OTP.`), | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
1c6114e
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
starter-kit – ./
starter-kit-ogp-tooling.vercel.app
ogp-starter-kit.vercel.app
starter-kit-git-main-ogp-tooling.vercel.app