1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-17 16:53:34 +00:00

chore(captcha): [PM-15162] Remove handling of captcha enforcement and bypass token

* Removed captcha references.

* Removed connectors from webpack

* Fixed extra parameter.

* Resolve merge conflicts.

* Fixed extra argument.

* Fixed failing tests.

* Fixed failing test.

* Accessibility cookie cleanup

* Cleaned up accessibility component.

* Deleted old registration endpoint

* Remove unused register request object.

* Fixed merge error that changed font family.

* Fixed formatting from merge.

* Linting
This commit is contained in:
Todd Martin
2025-05-09 10:44:11 -04:00
committed by GitHub
parent 625256b08e
commit 4191bb9533
59 changed files with 56 additions and 977 deletions

View File

@@ -52,7 +52,6 @@ describe("DefaultRegistrationFinishService", () => {
let userKey: UserKey;
let userKeyEncString: EncString;
let userKeyPair: [string, EncString];
let capchaBypassToken: string;
beforeEach(() => {
email = "test@email.com";
@@ -71,7 +70,6 @@ describe("DefaultRegistrationFinishService", () => {
userKeyEncString = new EncString("userKeyEncrypted");
userKeyPair = ["publicKey", new EncString("privateKey")];
capchaBypassToken = "capchaBypassToken";
});
it("throws an error if the user key cannot be created", async () => {
@@ -82,18 +80,12 @@ describe("DefaultRegistrationFinishService", () => {
);
});
it("registers the user and returns a captcha bypass token when given valid email verification input", async () => {
it("registers the user when given valid email verification input", async () => {
keyService.makeUserKey.mockResolvedValue([userKey, userKeyEncString]);
keyService.makeKeyPair.mockResolvedValue(userKeyPair);
accountApiService.registerFinish.mockResolvedValue(capchaBypassToken);
accountApiService.registerFinish.mockResolvedValue();
const result = await service.finishRegistration(
email,
passwordInputResult,
emailVerificationToken,
);
expect(result).toEqual(capchaBypassToken);
await service.finishRegistration(email, passwordInputResult, emailVerificationToken);
expect(keyService.makeUserKey).toHaveBeenCalledWith(masterKey);
expect(keyService.makeKeyPair).toHaveBeenCalledWith(userKey);

View File

@@ -34,7 +34,7 @@ export class DefaultRegistrationFinishService implements RegistrationFinishServi
emergencyAccessId?: string,
providerInviteToken?: string,
providerUserId?: string,
): Promise<string> {
): Promise<void> {
const [newUserKey, newEncUserKey] = await this.keyService.makeUserKey(
passwordInputResult.masterKey,
);
@@ -57,9 +57,7 @@ export class DefaultRegistrationFinishService implements RegistrationFinishServi
providerUserId,
);
const capchaBypassToken = await this.accountApiService.registerFinish(registerRequest);
return capchaBypassToken;
return await this.accountApiService.registerFinish(registerRequest);
}
protected async buildRegisterRequest(

View File

@@ -152,9 +152,8 @@ export class RegistrationFinishComponent implements OnInit, OnDestroy {
async handlePasswordFormSubmit(passwordInputResult: PasswordInputResult) {
this.submitting = true;
let captchaBypassToken: string = null;
try {
captchaBypassToken = await this.registrationFinishService.finishRegistration(
await this.registrationFinishService.finishRegistration(
this.email,
passwordInputResult,
this.emailVerificationToken,
@@ -179,12 +178,7 @@ export class RegistrationFinishComponent implements OnInit, OnDestroy {
// login with the new account
try {
const credentials = new PasswordLoginCredentials(
this.email,
passwordInputResult.newPassword,
captchaBypassToken,
null,
);
const credentials = new PasswordLoginCredentials(this.email, passwordInputResult.newPassword);
const authenticationResult = await this.loginStrategyService.logIn(credentials);

View File

@@ -27,7 +27,7 @@ export abstract class RegistrationFinishService {
* @param emergencyAccessId The optional emergency access id which is required to validate the emergency access invite token.
* @param providerInviteToken The optional provider invite token.
* @param providerUserId The optional provider user id which is required to validate the provider invite token.
* @returns a promise which resolves to the captcha bypass token string upon a successful account creation.
* @returns a promise which resolves upon a successful account creation.
*/
abstract finishRegistration(
email: string,
@@ -38,5 +38,5 @@ export abstract class RegistrationFinishService {
emergencyAccessId?: string,
providerInviteToken?: string,
providerUserId?: string,
): Promise<string>;
): Promise<void>;
}

View File

@@ -260,7 +260,6 @@ describe("TwoFactorAuthComponent", () => {
// Assert
expect(mockLoginStrategyService.logInTwoFactor).toHaveBeenCalledWith(
new TokenTwoFactorRequest(component.selectedProviderType, token, remember),
"",
);
});

View File

@@ -335,7 +335,6 @@ export class TwoFactorAuthComponent implements OnInit, OnDestroy {
try {
this.formPromise = this.loginStrategyService.logInTwoFactor(
new TokenTwoFactorRequest(this.selectedProviderType, tokenValue, rememberValue),
"", // TODO: PM-15162 - deprecate captchaResponse
);
const authResult: AuthResult = await this.formPromise;
this.logService.info("Successfully submitted two factor token");