mirror of
https://github.com/bitwarden/jslib
synced 2025-12-15 15:53:51 +00:00
Feature/use hcaptcha if bot (#430)
* Handle hcaptch required identity response * Refactor iframe component for captcha and webauthn * Send captcha token to server * Add captcha callback * Clear captcha state * Remove captcha storage * linter fixes * Rename iframe components to include IFrame * Remove callback in favor of extenting submit * Limit publickey credentials access * Use captcha bypass token to bypass captcha for twofactor auth flows * Linter fixes * Set iframe version in components
This commit is contained in:
@@ -2,6 +2,7 @@ import { TwoFactorProviderType } from '../../enums/twoFactorProviderType';
|
||||
|
||||
export class AuthResult {
|
||||
twoFactor: boolean = false;
|
||||
captchaSiteKey: string = '';
|
||||
resetMasterPassword: boolean = false;
|
||||
twoFactorProviders: Map<TwoFactorProviderType, { [key: string]: string; }> = null;
|
||||
}
|
||||
|
||||
@@ -13,10 +13,11 @@ export class TokenRequest {
|
||||
token: string;
|
||||
provider: TwoFactorProviderType;
|
||||
remember: boolean;
|
||||
captchaToken: string;
|
||||
device?: DeviceRequest;
|
||||
|
||||
constructor(credentials: string[], codes: string[], clientIdClientSecret: string[], provider: TwoFactorProviderType,
|
||||
token: string, remember: boolean, device?: DeviceRequest) {
|
||||
token: string, remember: boolean, captchaToken: string, device?: DeviceRequest) {
|
||||
if (credentials != null && credentials.length > 1) {
|
||||
this.email = credentials[0];
|
||||
this.masterPasswordHash = credentials[1];
|
||||
@@ -32,6 +33,7 @@ export class TokenRequest {
|
||||
this.provider = provider;
|
||||
this.remember = remember;
|
||||
this.device = device != null ? device : null;
|
||||
this.captchaToken = captchaToken;
|
||||
}
|
||||
|
||||
toIdentityToken(clientId: string) {
|
||||
@@ -71,6 +73,11 @@ export class TokenRequest {
|
||||
obj.twoFactorRemember = this.remember ? '1' : '0';
|
||||
}
|
||||
|
||||
if (this.captchaToken != null) {
|
||||
obj.captchaResponse = this.captchaToken;
|
||||
}
|
||||
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
|
||||
10
common/src/models/response/identityCaptchaResponse.ts
Normal file
10
common/src/models/response/identityCaptchaResponse.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
import { BaseResponse } from './baseResponse';
|
||||
|
||||
export class IdentityCaptchaResponse extends BaseResponse {
|
||||
siteKey: string;
|
||||
|
||||
constructor(response: any) {
|
||||
super(response);
|
||||
this.siteKey = this.getResponseProperty('HCaptcha_SiteKey');
|
||||
}
|
||||
}
|
||||
@@ -5,9 +5,11 @@ import { TwoFactorProviderType } from '../../enums/twoFactorProviderType';
|
||||
export class IdentityTwoFactorResponse extends BaseResponse {
|
||||
twoFactorProviders: TwoFactorProviderType[];
|
||||
twoFactorProviders2 = new Map<TwoFactorProviderType, { [key: string]: string; }>();
|
||||
captchaToken: string;
|
||||
|
||||
constructor(response: any) {
|
||||
super(response);
|
||||
this.captchaToken = this.getResponseProperty('HCaptcha_BypassKey');
|
||||
this.twoFactorProviders = this.getResponseProperty('TwoFactorProviders');
|
||||
const twoFactorProviders2 = this.getResponseProperty('TwoFactorProviders2');
|
||||
if (twoFactorProviders2 != null) {
|
||||
|
||||
Reference in New Issue
Block a user