Skip to content
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

[AUT-117] - Add modal support for enrolment #10

Merged
merged 5 commits into from
Jul 21, 2022
Merged

Conversation

hwhmeikle
Copy link
Contributor

  • Deprecate challenge() and mfa()
  • Add launch()
  • Remove authsignal-challenge-success and authsignal-challenge-success event listener
  • Add listener for AuthsignalWindowMessage.AUTHSIGNAL_CLOSE_POPUP event
  • Add endpoint option so that we can verify event messages come from a trusted source

mfa(challenge: {mode?: "redirect"} & MfaInput): undefined;
mfa(challenge: {mode: "popup"} & MfaInput): Promise<boolean>;
mfa({mode, url}: MfaInput) {
if (mode === "popup") {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Had to do this if to make typescript happy due to function overload things

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could potentially do a @ts-expect-error here instead

return new Promise<boolean>((resolve) => {
const onMessage = (event: MessageEvent) => {
if (event.origin === this.endpoint) {
if (event.data === AuthsignalWindowMessage.AUTHSIGNAL_CLOSE_POPUP) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only listening for the single message now, and never rejecting the promise

Copy link
Contributor

@chrisfisher chrisfisher left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice

@hwhmeikle hwhmeikle merged commit cadc724 into main Jul 21, 2022
@hwhmeikle hwhmeikle deleted the enrolment-modal branch July 21, 2022 04:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants