mirror of
https://github.com/bitwarden/browser
synced 2026-01-04 09:33:27 +00:00
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:
@@ -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');
|
||||
|
||||
Reference in New Issue
Block a user