1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-23 19:53:43 +00:00

pack main and renderer

This commit is contained in:
Kyle Spearrin
2018-01-23 13:59:01 -05:00
parent 0a803958e9
commit 268ec9960e
10 changed files with 136 additions and 82 deletions

View File

@@ -1,14 +0,0 @@
import { Injectable } from '@angular/core';
import {
MessagingService,
PlatformUtilsService,
} from 'jslib/abstractions';
@Injectable()
export class DesktopMessagingService implements MessagingService {
send(subscriber: string, arg: any = {}) {
const message = Object.assign({}, { command: subscriber }, arg);
// TODO
}
}

View File

@@ -1,84 +0,0 @@
import { Injectable } from '@angular/core';
import { DeviceType } from 'jslib/enums';
import { PlatformUtilsService } from 'jslib/abstractions';
const AnalyticsIds = {
[DeviceType.Windows]: 'UA-81915606-17',
[DeviceType.Linux]: 'UA-81915606-19',
[DeviceType.MacOs]: 'UA-81915606-18',
};
@Injectable()
export class DesktopPlatformUtilsService implements PlatformUtilsService {
private deviceCache: DeviceType = null;
private analyticsIdCache: string = null;
getDevice(): DeviceType {
if (!this.deviceCache) {
switch (process.platform) {
case 'win32':
this.deviceCache = DeviceType.Windows;
break;
case 'darwin':
this.deviceCache = DeviceType.MacOs;
break;
case 'linux':
this.deviceCache = DeviceType.Linux;
break;
default:
this.deviceCache = DeviceType.Linux;
break;
}
}
return this.deviceCache;
}
getDeviceString(): string {
return DeviceType[this.getDevice()].toLowerCase();
}
isFirefox(): boolean {
return false;
}
isChrome(): boolean {
return true;
}
isEdge(): boolean {
return false;
}
isOpera(): boolean {
return false;
}
isVivaldi(): boolean {
return false;
}
isSafari(): boolean {
return false;
}
analyticsId(): string {
if (this.analyticsIdCache) {
return this.analyticsIdCache;
}
// FIX?
// this.analyticsIdCache = AnalyticsIds[this.getDevice() as DeviceType];
return this.analyticsIdCache;
}
getDomain(uriString: string): string {
return uriString;
}
isViewOpen(): boolean {
return true;
}
}

View File

@@ -1,20 +0,0 @@
import { Injectable } from '@angular/core';
import { getPassword, setPassword, deletePassword } from 'keytar';
import { StorageService } from 'jslib/abstractions';
@Injectable()
export class DesktopSecureStorageService implements StorageService {
async get<T>(key: string): Promise<T> {
const val: string = await getPassword('bitwarden', key);
return val ? JSON.parse(val) as T : null
}
async save(key: string, obj: any): Promise<any> {
await setPassword('bitwarden', key, JSON.stringify(obj));
}
async remove(key: string): Promise<any> {
await deletePassword('bitwarden', key);
}
}

View File

@@ -1,24 +0,0 @@
import { Injectable } from '@angular/core';
import { StorageService } from 'jslib/abstractions';
const Store = require('electron-store');
const store = new Store();
@Injectable()
export class DesktopStorageService implements StorageService {
get<T>(key: string): Promise<T> {
const val = store.get(key) as T;
return Promise.resolve(val ? val : null);
}
save(key: string, obj: any): Promise<any> {
store.set(key, obj);
return Promise.resolve();
}
remove(key: string): Promise<any> {
store.delete(key);
return Promise.resolve();
}
}

View File

@@ -1,9 +1,10 @@
//import { remote } from 'electron';
import { NgModule } from '@angular/core';
import { DesktopMessagingService } from './desktopMessaging.service';
import { DesktopPlatformUtilsService } from './desktopPlatformUtils.service';
import { DesktopStorageService } from './desktopStorage.service';
import { DesktopSecureStorageService } from './desktopSecureStorage.service';
import { DesktopMessagingService } from '../../services/desktopMessaging.service';
import { DesktopPlatformUtilsService } from '../../services/desktopPlatformUtils.service';
import { DesktopStorageService } from '../../services/desktopStorage.service';
import {
ApiService,
@@ -52,7 +53,7 @@ const utilsService = new UtilsService();
const platformUtilsService = new DesktopPlatformUtilsService();
const messagingService = new DesktopMessagingService();
const storageService: StorageServiceAbstraction = new DesktopStorageService();
//const secureStorageService: StorageServiceAbstraction = new DesktopSecureStorageService();
const secureStorageService: StorageServiceAbstraction = storageService; //remote.getGlobal('secureStorageService');
const constantsService = new ConstantsService({}, 0);
const cryptoService = new CryptoService(storageService, storageService);
const tokenService = new TokenService(storageService);