safari 2fa page cleanup

This commit is contained in:
Kyle Spearrin 2019-08-21 10:05:17 -04:00
parent 46bca30f04
commit 0e798c610e
9 changed files with 5 additions and 156 deletions

View File

@ -29,8 +29,7 @@ const filters = {
],
safari: [
'!build/safari/**/*',
'!build/downloader/**/*',
'!build/2fa/**/*'
'!build/downloader/**/*'
],
webExt: [
'!build/manifest.json'

2
jslib

@ -1 +1 @@
Subproject commit 2ab6b9f330144ef028c85ca3bbe210a28d012383
Subproject commit 94a12f76448fd21cb10b9eb2c5ff8086f043baf0

View File

@ -1,50 +0,0 @@
import * as DuoWebSDK from 'duo_web_sdk';
document.addEventListener('DOMContentLoaded', () => {
const isSafari = (typeof safari !== 'undefined') && navigator.userAgent.indexOf(' Safari/') !== -1 &&
navigator.userAgent.indexOf('Chrome') === -1;
if (!isSafari) {
return;
}
safari.self.addEventListener('message', (msgEvent: any) => {
init2fa(JSON.parse(msgEvent.message.msg));
}, false);
function init2fa(msg: any) {
if (msg.command !== '2faPageData' || !msg.data) {
return;
}
if (msg.data.type === 'duo') {
DuoWebSDK.init({
iframe: undefined,
host: msg.data.host,
sig_request: msg.data.signature,
submit_callback: (theForm: Document) => {
const sigElement = theForm.querySelector('input[name="sig_response"]') as HTMLInputElement;
if (sigElement) {
safari.extension.dispatchMessage('bitwarden', {
command: '2faPageResponse',
type: 'duo',
data: {
sigValue: sigElement.value,
},
});
}
},
});
} else if (msg.data.type === 'success') {
safari.extension.dispatchMessage('bitwarden', {
command: 'openPopup',
});
setTimeout(() => {
window.close();
}, 500);
} else {
// TODO: others like u2f?
}
}
});

View File

@ -1,31 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<title>Two-step Login</title>
<meta charset="utf-8" />
<style>
html, body {
height: 90%;
padding: 0;
}
.frameWrapper {
background: url('../popup/images/loading.svg') 0 0 no-repeat;
width: 100%;
height: 100%;
margin-bottom: -10px;
}
.frameWrapper iframe {
width: 100%;
height: 100%;
border: none;
}
</style>
</head>
<body>
<div class="frameWrapper">
<iframe id="duo_iframe"></iframe>
</div>
</body>
</html>

View File

@ -1102,9 +1102,6 @@
"message": "Clear",
"description": "To clear something out. example: To clear browser history."
},
"twoStepNewWindowMessage": {
"message": "Complete your two-step login request using the new tab."
},
"checkPassword": {
"message": "Check if password has been exposed."
},

View File

@ -78,8 +78,7 @@
</ng-container>
<ng-container *ngIf="selectedProviderType === providerType.Duo ||
selectedProviderType === providerType.OrganizationDuo">
<div id="duo-frame" *ngIf="!showNewWindowMessage"><iframe id="duo_iframe"></iframe></div>
<div *ngIf="showNewWindowMessage" class="content text-center">{{'twoStepNewWindowMessage' | i18n}}</div>
<div id="duo-frame"><iframe id="duo_iframe"></iframe></div>
<div class="box">
<div class="box-content">
<div class="box-content-row box-content-row-checkbox" appBoxRow>

View File

@ -6,8 +6,6 @@ import {
import { Router } from '@angular/router';
import { BrowserApi } from '../../browser/browserApi';
import { TwoFactorProviderType } from 'jslib/enums/twoFactorProviderType';
import { ApiService } from 'jslib/abstractions/api.service';
@ -50,42 +48,19 @@ export class TwoFactorComponent extends BaseTwoFactorComponent {
}
async ngOnInit() {
/*
this.broadcasterService.subscribe(BroadcasterSubscriptionId, (message: any) => {
this.ngZone.run(async () => {
switch (message.command) {
case '2faPageResponse':
if (message.type === 'duo') {
this.token = message.data.sigValue;
this.submitWithTab(message.webExtSender.tab);
}
default:
break;
}
this.changeDetectorRef.detectChanges();
});
});
*/
const isFirefox = this.platformUtilsService.isFirefox();
if (this.popupUtilsService.inPopup(window) && isFirefox &&
this.win.navigator.userAgent.indexOf('Windows NT 10.0;') > -1) {
// ref: https://bugzilla.mozilla.org/show_bug.cgi?id=1562620
this.initU2f = false;
}
/*
const isSafari = this.platformUtilsService.isSafari();
this.showNewWindowMessage = isSafari;
*/
await super.ngOnInit();
if (this.selectedProviderType == null) {
return;
}
if (/*!isSafari && */this.selectedProviderType === TwoFactorProviderType.Email &&
if (!isSafari && this.selectedProviderType === TwoFactorProviderType.Email &&
this.popupUtilsService.inPopup(window)) {
const confirmed = await this.platformUtilsService.showDialog(this.i18nService.t('popup2faCloseMessage'),
null, this.i18nService.t('yes'), this.i18nService.t('no'));
@ -102,28 +77,6 @@ export class TwoFactorComponent extends BaseTwoFactorComponent {
this.popupUtilsService.popOut(window);
}
}
/*
const isDuo = this.selectedProviderType === TwoFactorProviderType.Duo ||
this.selectedProviderType === TwoFactorProviderType.OrganizationDuo;
if (!isSafari || !isDuo) {
return;
}
const params = this.authService.twoFactorProvidersData.get(this.selectedProviderType);
const tab = BrowserApi.createNewTab(BrowserApi.getAssetUrl('2fa/index.html'));
const tabToSend = BrowserApi.makeTabObject(tab);
window.setTimeout(() => {
BrowserApi.tabSendMessage(tabToSend, {
command: '2faPageData',
data: {
type: 'duo',
host: params.Host,
signature: params.Signature,
},
});
}, 500);
*/
}
ngOnDestroy() {
@ -134,16 +87,4 @@ export class TwoFactorComponent extends BaseTwoFactorComponent {
anotherMethod() {
this.router.navigate(['2fa-options']);
}
async submitWithTab(sendSuccessToTab: any) {
await super.submit();
if (sendSuccessToTab != null) {
window.setTimeout(() => {
BrowserApi.tabSendMessage(sendSuccessToTab, {
command: '2faPageData',
data: { type: 'success' },
});
}, 1000);
}
}
}

View File

@ -36,7 +36,7 @@ const RateUrls = {
[DeviceType.VivaldiExtension]:
'https://chrome.google.com/webstore/detail/bitwarden-free-password-m/nngceckbapebfimnlniiiahkandclblb/reviews',
[DeviceType.SafariExtension]:
'https://itunes.apple.com/app/bitwarden-password-manager/id1137397744',
'https://apps.apple.com/app/bitwarden/id1352778147',
};
@Component({

View File

@ -99,11 +99,6 @@ const plugins = [
filename: 'downloader/index.html',
chunks: ['downloader/downloader'],
}),
new HtmlWebpackPlugin({
template: './src/2fa/index.html',
filename: '2fa/index.html',
chunks: ['2fa/2fa'],
}),
new CopyWebpackPlugin([
'./src/manifest.json',
{ from: './src/_locales', to: '_locales' },
@ -154,7 +149,6 @@ const config = {
'content/shortcuts': './src/content/shortcuts.ts',
'notification/bar': './src/notification/bar.js',
'downloader/downloader': './src/downloader/downloader.ts',
'2fa/2fa': './src/2fa/2fa.ts',
},
optimization: {
minimize: false,