mirror of
https://github.com/bitwarden/jslib
synced 2025-12-21 02:33:37 +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:
26
common/src/misc/webauthn_iframe.ts
Normal file
26
common/src/misc/webauthn_iframe.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
import { I18nService } from '../abstractions/i18n.service';
|
||||
import { PlatformUtilsService } from '../abstractions/platformUtils.service';
|
||||
import { IFrameComponent } from './iframe_component';
|
||||
|
||||
export class WebAuthnIFrame extends IFrameComponent {
|
||||
constructor(win: Window, webVaultUrl: string, private webAuthnNewTab: boolean,
|
||||
private platformUtilsService: PlatformUtilsService, private i18nService: I18nService,
|
||||
successCallback: (message: string) => any, errorCallback: (message: string) => any,
|
||||
infoCallback: (message: string) => any) {
|
||||
super(win, webVaultUrl, 'webauthn-connector.html', 'webauthn_iframe', successCallback, errorCallback, infoCallback);
|
||||
}
|
||||
|
||||
|
||||
init(data: any): void {
|
||||
const params = this.createParams({ data: JSON.stringify(data), btnText: this.i18nService.t('webAuthnAuthenticate') }, 2);
|
||||
|
||||
if (this.webAuthnNewTab) {
|
||||
// Firefox fallback which opens the webauthn page in a new tab
|
||||
params.append('locale', this.i18nService.translationLocale);
|
||||
this.platformUtilsService.launchUri(`${this.webVaultUrl}/webauthn-fallback-connector.html?${params}`);
|
||||
} else {
|
||||
super.initComponent(params);
|
||||
this.iframe.allow = 'publickey-credentials-get ' + new URL(this.webVaultUrl).origin;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user