Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,9 @@ export interface EmailIdentifierChallengeMembers extends BaseMembers {
resendCode(payload?: CustomOptions): Promise<void>;
resendManager(payload?: StartResendOptions): ResendControl;
returnToPrevious(payload?: CustomOptions): Promise<void>;
/**
* Switches from OTP/code authentication to password authentication.
* When called, the screen will re-render to the password authentication screen.
*/
switchToPasswordAuth(): Promise<void>;
}
5 changes: 5 additions & 0 deletions packages/auth0-acul-js/interfaces/screens/login-password.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,9 @@ export interface LoginPasswordMembers extends BaseMembers {
login(payload: LoginPasswordOptions): Promise<void>;
federatedLogin(payload: FederatedLoginOptions): Promise<void>;
switchConnection(payload: SwitchConnectionOptions): Promise<void>;
/**
* Switches from password authentication to OTP authentication.
* When called, the screen will re-render to the OTP authentication screen.
*/
switchToOtpAuth(): Promise<void>;
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,9 @@ export interface PhoneIdentifierChallengeMembers extends BaseMembers {
returnToPrevious(payload?: CustomOptions): Promise<void>;
switchToVoice(payload?: CustomOptions): Promise<void>;
switchToText(payload?: CustomOptions): Promise<void>;
/**
* Switches from OTP/code authentication to password authentication.
* When called, the screen will re-render to the password authentication screen.
*/
switchToPasswordAuth(): Promise<void>;
}
4 changes: 4 additions & 0 deletions packages/auth0-acul-js/src/constants/form-actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,8 @@ export const FormActions = {
TRY_AGAIN: 'tryagain' as const,
USE_PASSWORD: 'use-password' as const,
CHANGE_LANGUAGE: 'change-language' as const,
// actions for login-password screen
SWITCH_TO_OTP_AUTH: 'switch-to-otp-auth' as const,
// actions for email-identifier-challenge screen
SWITCH_TO_PASSWORD_AUTH: 'switch-to-password-auth' as const,
} as const;
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,31 @@ export default class EmailIdentifierChallenge extends BaseContext implements Ema
!!this.screen.data?.resendLimitReached
);
}

/**
* @remarks
* This method switches from OTP/code authentication to password authentication.
* When called, the screen will re-render to the password authentication screen.
*
* @example
* import EmailIdentifierChallenge from '@auth0/auth0-acul-js/email-identifier-challenge';
*
* const emailIdentifierChallenge = new EmailIdentifierChallenge();
*
* // Switch to password authentication
* emailIdentifierChallenge.switchToPasswordAuth();
*/
async switchToPasswordAuth(): Promise<void> {
const options: FormOptions = {
state: this.transaction.state,
telemetry: [EmailIdentifierChallenge.screenIdentifier, 'switchToPasswordAuth'],
};

await new FormHandler(options).submitData({
code: '',
action: FormActions.SWITCH_TO_PASSWORD_AUTH,
});
}
}

export { EmailIdentifierChallengeMembers, ScreenOptions as ScreenMembersOnEmailIdentifierChallenge, EmailChallengeOptions };
Expand Down
26 changes: 25 additions & 1 deletion packages/auth0-acul-js/src/screens/login-password/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ScreenIds } from '../../constants';
import { ScreenIds, FormActions } from '../../constants';
import { BaseContext } from '../../models/base-context';
import { getBrowserCapabilities } from '../../utils/browser-capabilities';
import { FormHandler } from '../../utils/form-handler';
Expand Down Expand Up @@ -110,6 +110,30 @@ export default class LoginPassword extends BaseContext implements LoginPasswordM

await new FormHandler(options).submitData<SwitchConnectionOptions>(payload);
}

/**
* @remarks
* This method switches from password authentication to OTP authentication.
* When called, the screen will re-render to the OTP authentication screen.
*
* @example
* import LoginPassword from "@auth0/auth0-acul-js/login-password";
*
* const loginPasswordManager = new LoginPassword();
*
* // Switch to OTP authentication
* loginPasswordManager.switchToOtpAuth();
*/
async switchToOtpAuth(): Promise<void> {
const options: FormOptions = {
state: this.transaction.state,
telemetry: [LoginPassword.screenIdentifier, 'switchToOtpAuth'],
};

await new FormHandler(options).submitData({
action: FormActions.SWITCH_TO_OTP_AUTH,
});
}
}

export {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,31 @@ export default class PhoneIdentifierChallenge extends BaseContext implements Pho
!!this.screen.data?.resendLimitReached
);
}

/**
* @remarks
* This method switches from OTP/code authentication to password authentication.
* When called, the screen will re-render to the password authentication screen.
*
* @example
* import PhoneIdentifierChallenge from '@auth0/auth0-acul-js/phone-identifier-challenge';
*
* const phoneIdentifierChallenge = new PhoneIdentifierChallenge();
*
* // Switch to password authentication
* phoneIdentifierChallenge.switchToPasswordAuth();
*/
async switchToPasswordAuth(): Promise<void> {
const options: FormOptions = {
state: this.transaction.state,
telemetry: [PhoneIdentifierChallenge.screenIdentifier, 'switchToPasswordAuth'],
};

await new FormHandler(options).submitData({
code: '',
action: FormActions.SWITCH_TO_PASSWORD_AUTH,
});
}
}

export { PhoneIdentifierChallengeMembers, PhoneChallengeOptions, ScreenOptions as ScreenMembersOnPhoneIdentifierChallenge };
Expand Down
Loading