-
Notifications
You must be signed in to change notification settings - Fork 159
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DO NOT MREGE: Mfa/demo #1398
Draft
rthomare
wants to merge
86
commits into
main
Choose a base branch
from
mfa/demo
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
DO NOT MREGE: Mfa/demo #1398
Changes from 63 commits
Commits
Show all changes
86 commits
Select commit
Hold shift + click to select a range
8ca926a
feat: add mfa totp to the email otp flow
blakecduncan a5038db
chore: fix rn build after mfa changes
blakecduncan bc887b6
feat: support mfa for magic link
blakecduncan e572159
feat: update auto generated docs
blakecduncan dc2c484
chore: fix signer build from missing listener
blakecduncan c021c79
feat: update api endpoints for mfa
blakecduncan e4f65fc
chore: update signer docs
blakecduncan 8113753
chore: fix build
blakecduncan af789b6
chore: update signer docs
blakecduncan 180935e
feat: wip mfa card
RobChangCA 3e06598
chore: update types to match api responses
blakecduncan 40da2d2
chore: auto generated docs pages
blakecduncan ae47938
chore: use AlchemyMfaStatus type
blakecduncan 901747a
feat: med-fi full flow
RobChangCA 3e89cd6
feat: verify handler for otp
RobChangCA 6cbf5b8
chore: use correct mfa verify api endpoint
blakecduncan 24aeb93
chore: fix verify mfa return value
blakecduncan fca6b30
chore: auto generated docs pages
blakecduncan 9f73714
chore: fix rn build
blakecduncan 4eea86c
Merge branch 'blake/add-mfa-totp' into mfa/demo
blakecduncan f477d36
feat: add mfa crud functionality to the UI
blakecduncan 0543c03
feat: dark mode, magic link
RobChangCA 98f3890
feat: add mfa to email otp authentication
blakecduncan 27ce637
Merge branch 'mfa/demo' of https://github.com/alchemyplatform/aa-sdk …
blakecduncan a5a47f3
chore: fix build
blakecduncan c33ff93
chore: temporarily using otp email instead of magic link
blakecduncan 07516d2
chore: remove image from qr code
blakecduncan b8ee838
chore: remove unused import
blakecduncan 0c20735
fix: increase card dimensions
RobChangCA af94812
fix: min height to cards
RobChangCA 13023b4
chore: fix auth mfa otp endpoint
blakecduncan cf2a82f
Merge branch 'rob/card-dimensions' into mfa/demo
blakecduncan e475a71
chore: auto generated docs pages
blakecduncan 46b3bd7
feat: minor ui tweaks
RobChangCA 263e202
feat: check status of mfa in mfa card
blakecduncan 7c43f87
chore: remove unused import
blakecduncan 9a1e543
chore: remove image from qr code
blakecduncan ef174aa
feat: ui tweaks
RobChangCA 4f04878
fix: image file name
RobChangCA 7e82e4e
feat: add mfa for magic link in the demo
blakecduncan 171ff78
Merge branch 'main' into mfa/demo
RobChangCA bde11ff
feat: cleanup mfa logic in signer (#1409)
blakecduncan 4b7973d
feat: add mfa hook (#1410)
blakecduncan 7edd6d0
feat: pass multiFactorType to api
blakecduncan 0460be1
chore: update error message
blakecduncan c88b569
feat: split mfa, clean up animation, error state (#1418)
RobChangCA e99325c
feat: update the stampedRequest on mfa calls
blakecduncan 75fcbed
feat: update mfa request payload
blakecduncan 6eb9300
Merge branch 'main' into mfa/demo
blakecduncan e9fdbfd
feat: fix build and wrap cards
blakecduncan c3ce923
docs: auto generated docs
blakecduncan 250c912
docs: add mfa docs
blakecduncan 2af3651
feat: use mfa hooks in the mfaModal
blakecduncan ba0e67b
docs: auto generated docs
blakecduncan bc22a0d
fix: fix lint error
blakecduncan 71775b4
feat: use staging signer
blakecduncan 0f7c6b9
feat: update hook exports
blakecduncan 13bdeaf
feat: fix error states for totp
blakecduncan efd6edd
feat: fix text overflow on small screens
blakecduncan 9719e29
docs: dogfooding feedback
blakecduncan 4eb58b6
docs: add social login with mfa docs page
blakecduncan f0f569c
docs: add reference to mfa in the getting started docs
blakecduncan 6980b35
docs: dogfooding feedback
blakecduncan 914b565
feat: clean up useMfa hook and documenation after dogfooding
blakecduncan e5cb8a3
Merge branch 'main' into mfa/demo
RobChangCA 5ec990b
feat: card alignment - switch to grid
RobChangCA b9a5603
test: add tests for the authenticate method
blakecduncan 709eec1
test: clean up mocks and base test
blakecduncan b66f88b
Merge branch 'mfa/demo' of github.com:alchemyplatform/aa-sdk into mfa…
blakecduncan 13bf95e
feat: mobile auth store (#1477)
RobChangCA b36865a
feat: use new verify mfa api
blakecduncan 47d0d0d
feat: fix build
blakecduncan f043d8a
feat: use new verify mfa api in the demo
blakecduncan 3325da7
feat: fix the demo app
blakecduncan 4d3fefb
feat: remove unused comment
blakecduncan 4aaa975
test: fix base.test.ts
blakecduncan cca8114
feat: change modal background to a blur
blakecduncan 126216d
docs: refactor docs after mfa api changes
blakecduncan 6f4cb87
Merge branch 'main' into mfa/demo
blakecduncan 92f70a4
fix: ui merge issues
blakecduncan 30c4e0b
Merge branch 'blake/test-modal-blur' into mfa/demo
blakecduncan 6c20e2b
fix: fix magic link auth card flow
blakecduncan a10199d
docs: make mfa docs more clear
blakecduncan fa4f9b5
docs: fix signer mfa docs with updates
blakecduncan 2aa64ac
docs: fix code example build
blakecduncan 9ea28df
fix: fix card ui jumping issue
blakecduncan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
101 changes: 101 additions & 0 deletions
101
account-kit/react/src/components/auth/card/loading/totp.tsx
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,101 @@ | ||
import { useState } from "react"; | ||
import { useAuthContext } from "../../context.js"; | ||
import { useAuthenticate } from "../../../../hooks/useAuthenticate.js"; | ||
import { | ||
OTPInput, | ||
initialOTPValue, | ||
isOTPCodeType, | ||
type OTPCodeType, | ||
} from "../../../otp-input/otp-input.js"; | ||
import { Spinner } from "../../../../icons/spinner.js"; | ||
import { ThreeStarsIcon } from "../../../../icons/threeStars.js"; | ||
|
||
export const LoadingTotp = () => { | ||
const { authStep, setAuthStep } = useAuthContext("totp_verify"); | ||
const [totpCode, setTotpCode] = useState<OTPCodeType>(initialOTPValue); | ||
const [errorText, setErrorText] = useState(authStep.error?.message || ""); | ||
const [isSubmitting, setIsSubmitting] = useState(false); | ||
const { authenticateAsync } = useAuthenticate({ | ||
onMutate: async (params) => { | ||
if (params.type === "email" && "email" in params) { | ||
if (params.emailMode === "magicLink") { | ||
setAuthStep({ type: "email_verify", email: params.email }); | ||
} | ||
} | ||
}, | ||
onSuccess: () => { | ||
setIsSubmitting(false); | ||
setAuthStep({ type: "complete" }); | ||
}, | ||
onError: (err) => { | ||
console.error("TOTP verify error", err); | ||
setIsSubmitting(false); | ||
setErrorText("The code you entered is incorrect"); | ||
setTotpCode(initialOTPValue); | ||
}, | ||
}); | ||
|
||
const setValue = async (otpCode: OTPCodeType) => { | ||
setTotpCode(otpCode); | ||
if (isOTPCodeType(otpCode)) { | ||
setIsSubmitting(true); | ||
const otp = otpCode.join(""); | ||
handleVerify(otp); | ||
} | ||
}; | ||
|
||
// Called when all digits are typed or user hits "Verify" button | ||
const handleVerify = async (codeString: string) => { | ||
try { | ||
if (authStep.previousStep === "magicLink") { | ||
await authenticateAsync({ | ||
type: "email", | ||
email: authStep.email, | ||
emailMode: "magicLink", | ||
redirectParams: new URLSearchParams(), | ||
multiFactors: [ | ||
{ | ||
multiFactorId: authStep.factorId, | ||
multiFactorCode: codeString, | ||
}, | ||
], | ||
}); | ||
} else if (authStep.previousStep === "otp") { | ||
await authenticateAsync({ | ||
type: "otp", | ||
otpCode: authStep.otpCode ?? "", | ||
multiFactors: [ | ||
{ | ||
multiFactorId: authStep.factorId, | ||
multiFactorCode: codeString, | ||
}, | ||
], | ||
}); | ||
} else { | ||
throw new Error("Invalid previous step"); | ||
} | ||
} catch (err) { | ||
console.error("TOTP submission error", err); | ||
} | ||
}; | ||
|
||
return ( | ||
<div className="flex flex-col items-center"> | ||
<div className="relative h-12 w-12 mb-5"> | ||
<Spinner className="absolute" /> | ||
<ThreeStarsIcon className="absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2" /> | ||
</div> | ||
<h3 className="text-fg-primary font-semibold text-lg mb-2"> | ||
Enter authentication code | ||
</h3> | ||
<OTPInput | ||
value={totpCode} | ||
setValue={setValue} | ||
errorText={errorText} | ||
setErrorText={setErrorText} | ||
disabled={isSubmitting} | ||
handleReset={() => setTotpCode(initialOTPValue)} | ||
/> | ||
</div> | ||
); | ||
}; |
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
React Hook useEffect has missing dependencies: 'form.state.values.email' and 'setAuthStep'. Either include them or remove the dependency array.