This commit is contained in:
Kyle Spearrin 2018-06-07 23:36:39 -04:00
parent 8211e19db0
commit f40451ecc5
5 changed files with 23 additions and 7 deletions

View File

@ -10,6 +10,7 @@ export abstract class PlatformUtilsService {
isOpera: () => boolean;
isVivaldi: () => boolean;
isSafari: () => boolean;
isIE: () => boolean;
isMacAppStore: () => boolean;
analyticsId: () => string;
getDomain: (uriString: string) => string;

View File

@ -11,6 +11,8 @@ import { StateService } from '../../abstractions/state.service';
import { ConstantsService } from '../../services/constants.service';
import { Utils } from '../../misc/utils';
@Component({
selector: 'app-vault-icon',
templateUrl: 'icon.component.html',
@ -77,8 +79,7 @@ export class IconComponent implements OnChanges {
if (this.imageEnabled && isWebsite) {
try {
const url = new URL(hostnameUri);
this.image = this.iconsUrl + '/' + url.hostname + '/icon.png';
this.image = this.iconsUrl + '/' + Utils.getHostname(hostnameUri) + '/icon.png';
this.fallbackImage = 'images/fa-globe.png';
} catch (e) { }
}

View File

@ -74,6 +74,10 @@ export class ElectronPlatformUtilsService implements PlatformUtilsService {
return false;
}
isIE(): boolean {
return false;
}
isMacAppStore(): boolean {
return isMacAppStore();
}

View File

@ -165,7 +165,15 @@ export class Utils {
if (uriString.startsWith('http://') || uriString.startsWith('https://')) {
try {
return nodeURL != null ? new nodeURL(uriString) : new URL(uriString);
if (nodeURL != null) {
return new nodeURL(uriString);
} else if (typeof URL === 'function') {
return new URL(uriString);
} else if (window != null) {
const anchor = window.document.createElement('a');
anchor.href = uriString;
return anchor as any;
}
} catch (e) { }
}

View File

@ -12,16 +12,18 @@ export class WebCryptoFunctionService implements CryptoFunctionService {
private crypto: Crypto;
private subtle: SubtleCrypto;
private isEdge: boolean;
private isIE: boolean;
constructor(private win: Window, private platformUtilsService: PlatformUtilsService) {
this.crypto = win.crypto;
this.subtle = win.crypto.subtle;
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();
}
async pbkdf2(password: string | ArrayBuffer, salt: string | ArrayBuffer, algorithm: 'sha256' | 'sha512',
iterations: number): Promise<ArrayBuffer> {
if (this.isEdge) {
if (this.isEdge || this.isIE) {
const forgeLen = algorithm === 'sha256' ? 32 : 64;
const passwordBytes = this.toByteString(password);
const saltBytes = this.toByteString(salt);
@ -46,7 +48,7 @@ export class WebCryptoFunctionService implements CryptoFunctionService {
}
async hash(value: string | ArrayBuffer, algorithm: 'sha1' | 'sha256' | 'sha512'): Promise<ArrayBuffer> {
if (this.isEdge && algorithm === 'sha1') {
if ((this.isEdge || this.isIE) && algorithm === 'sha1') {
const md = forge.md.sha1.create();
const valueBytes = this.toByteString(value);
md.update(valueBytes, 'raw');