remove old Edge browser hacks (#168)
* remove old Edge browser hacks * Remove final edge hacks * Update constructor parameters * Update search-ciphers.pipe.ts Co-authored-by: Kyle Spearrin <kspearrin@users.noreply.github.com>
This commit is contained in:
parent
fa2b8e834b
commit
5e0a2d1d99
|
@ -49,13 +49,6 @@ describe('Utils Service', () => {
|
|||
expect(Utils.getHostname('https://bitwarden.com')).toBe('bitwarden.com');
|
||||
expect(Utils.getHostname('http://bitwarden.com')).toBe('bitwarden.com');
|
||||
expect(Utils.getHostname('http://vault.bitwarden.com')).toBe('vault.bitwarden.com');
|
||||
|
||||
if (Utils.isNode || window.navigator.userAgent.indexOf(' Edge/') === -1) {
|
||||
// Note: Broken in Edge browser. See
|
||||
// https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/8004284/
|
||||
expect(Utils.getHostname('https://user:password@bitwarden.com:8080/password/sites?and&query#hash'))
|
||||
.toBe('bitwarden.com');
|
||||
}
|
||||
});
|
||||
|
||||
it('should support localhost and IP', () => {
|
||||
|
|
|
@ -380,8 +380,8 @@ function testRsaGenerateKeyPair(length: 1024 | 2048 | 4096) {
|
|||
|
||||
function getWebCryptoFunctionService() {
|
||||
const platformUtilsMock = TypeMoq.Mock.ofType<PlatformUtilsService>(PlatformUtilsServiceMock);
|
||||
platformUtilsMock.setup((x) => x.isEdge()).returns(() => navigator.userAgent.indexOf(' Edge/') !== -1);
|
||||
platformUtilsMock.setup((x) => x.isIE()).returns(() => navigator.userAgent.indexOf(' Edge/') === -1 &&
|
||||
platformUtilsMock.setup((x) => x.isEdge()).returns(() => navigator.userAgent.indexOf(' Edg/') !== -1);
|
||||
platformUtilsMock.setup((x) => x.isIE()).returns(() => navigator.userAgent.indexOf(' Edg/') === -1 &&
|
||||
navigator.userAgent.indexOf(' Trident/') !== -1);
|
||||
return new WebCryptoFunctionService(window, platformUtilsMock.object);
|
||||
}
|
||||
|
|
|
@ -105,7 +105,7 @@ export class RegisterComponent {
|
|||
this.name = this.name === '' ? null : this.name;
|
||||
this.email = this.email.trim().toLowerCase();
|
||||
const kdf = KdfType.PBKDF2_SHA256;
|
||||
const useLowerKdf = this.platformUtilsService.isEdge() || this.platformUtilsService.isIE();
|
||||
const useLowerKdf = this.platformUtilsService.isIE();
|
||||
const kdfIterations = useLowerKdf ? 10000 : 100000;
|
||||
const key = await this.cryptoService.makeKey(this.masterPassword, this.email, kdf, kdfIterations);
|
||||
const encKey = await this.cryptoService.makeEncKey(key);
|
||||
|
|
|
@ -44,7 +44,7 @@ export class SetPasswordComponent extends BaseChangePasswordComponent {
|
|||
|
||||
async setupSubmitActions() {
|
||||
this.kdf = KdfType.PBKDF2_SHA256;
|
||||
const useLowerKdf = this.platformUtilsService.isEdge() || this.platformUtilsService.isIE();
|
||||
const useLowerKdf = this.platformUtilsService.isIE();
|
||||
this.kdfIterations = useLowerKdf ? 10000 : 100000;
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -5,20 +5,10 @@ import {
|
|||
|
||||
import { CipherView } from '../../models/view/cipherView';
|
||||
|
||||
import { PlatformUtilsService } from '../../abstractions/platformUtils.service';
|
||||
|
||||
import { DeviceType } from '../../enums';
|
||||
|
||||
@Pipe({
|
||||
name: 'searchCiphers',
|
||||
})
|
||||
export class SearchCiphersPipe implements PipeTransform {
|
||||
private onlySearchName = false;
|
||||
|
||||
constructor(platformUtilsService: PlatformUtilsService) {
|
||||
this.onlySearchName = platformUtilsService.getDevice() === DeviceType.EdgeExtension;
|
||||
}
|
||||
|
||||
transform(ciphers: CipherView[], searchText: string, deleted: boolean = false): CipherView[] {
|
||||
if (ciphers == null || ciphers.length === 0) {
|
||||
return [];
|
||||
|
@ -38,9 +28,6 @@ export class SearchCiphersPipe implements PipeTransform {
|
|||
if (c.name != null && c.name.toLowerCase().indexOf(searchText) > -1) {
|
||||
return true;
|
||||
}
|
||||
if (this.onlySearchName) {
|
||||
return false;
|
||||
}
|
||||
if (searchText.length >= 8 && c.id.startsWith(searchText)) {
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -3,22 +3,17 @@ import * as lunr from 'lunr';
|
|||
import { CipherView } from '../models/view/cipherView';
|
||||
|
||||
import { CipherService } from '../abstractions/cipher.service';
|
||||
import { PlatformUtilsService } from '../abstractions/platformUtils.service';
|
||||
import { SearchService as SearchServiceAbstraction } from '../abstractions/search.service';
|
||||
|
||||
import { CipherType } from '../enums/cipherType';
|
||||
import { DeviceType } from '../enums/deviceType';
|
||||
import { FieldType } from '../enums/fieldType';
|
||||
import { UriMatchType } from '../enums/uriMatchType';
|
||||
|
||||
export class SearchService implements SearchServiceAbstraction {
|
||||
private indexing = false;
|
||||
private index: lunr.Index = null;
|
||||
private onlySearchName = false;
|
||||
|
||||
constructor(private cipherService: CipherService, platformUtilsService: PlatformUtilsService) {
|
||||
this.onlySearchName = platformUtilsService == null ||
|
||||
platformUtilsService.getDevice() === DeviceType.EdgeExtension;
|
||||
constructor(private cipherService: CipherService) {
|
||||
}
|
||||
|
||||
clearIndex(): void {
|
||||
|
@ -152,9 +147,6 @@ export class SearchService implements SearchServiceAbstraction {
|
|||
if (c.name != null && c.name.toLowerCase().indexOf(query) > -1) {
|
||||
return true;
|
||||
}
|
||||
if (this.onlySearchName) {
|
||||
return false;
|
||||
}
|
||||
if (query.length >= 8 && c.id.startsWith(query)) {
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -11,14 +11,12 @@ import { SymmetricCryptoKey } from '../models/domain/symmetricCryptoKey';
|
|||
export class WebCryptoFunctionService implements CryptoFunctionService {
|
||||
private crypto: Crypto;
|
||||
private subtle: SubtleCrypto;
|
||||
private isEdge: boolean;
|
||||
private isIE: boolean;
|
||||
private isOldSafari: boolean;
|
||||
|
||||
constructor(private win: Window, private platformUtilsService: PlatformUtilsService) {
|
||||
this.crypto = typeof win.crypto !== 'undefined' ? win.crypto : null;
|
||||
this.subtle = (!!this.crypto && typeof win.crypto.subtle !== 'undefined') ? win.crypto.subtle : null;
|
||||
this.isEdge = platformUtilsService.isEdge();
|
||||
this.isIE = platformUtilsService.isIE();
|
||||
const ua = win.navigator.userAgent;
|
||||
this.isOldSafari = platformUtilsService.isSafari() &&
|
||||
|
@ -27,7 +25,7 @@ export class WebCryptoFunctionService implements CryptoFunctionService {
|
|||
|
||||
async pbkdf2(password: string | ArrayBuffer, salt: string | ArrayBuffer, algorithm: 'sha256' | 'sha512',
|
||||
iterations: number): Promise<ArrayBuffer> {
|
||||
if (this.isEdge || this.isIE || this.isOldSafari) {
|
||||
if (this.isIE || this.isOldSafari) {
|
||||
const forgeLen = algorithm === 'sha256' ? 32 : 64;
|
||||
const passwordBytes = this.toByteString(password);
|
||||
const saltBytes = this.toByteString(salt);
|
||||
|
@ -52,7 +50,7 @@ export class WebCryptoFunctionService implements CryptoFunctionService {
|
|||
}
|
||||
|
||||
async hash(value: string | ArrayBuffer, algorithm: 'sha1' | 'sha256' | 'sha512' | 'md5'): Promise<ArrayBuffer> {
|
||||
if (((this.isEdge || this.isIE) && algorithm === 'sha1') || algorithm === 'md5') {
|
||||
if ((this.isIE && algorithm === 'sha1') || algorithm === 'md5') {
|
||||
const md = algorithm === 'md5' ? forge.md.md5.create() : forge.md.sha1.create();
|
||||
const valueBytes = this.toByteString(value);
|
||||
md.update(valueBytes, 'raw');
|
||||
|
|
Loading…
Reference in New Issue