1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-10-06 05:28:51 +02:00

stub out some services

This commit is contained in:
Kyle Spearrin 2018-05-12 21:24:28 -04:00
parent bb54e2a381
commit 8f49b58d2e
5 changed files with 116 additions and 2 deletions

View File

@ -6,10 +6,10 @@ import { AuthService } from 'jslib/abstractions/auth.service';
export class LoginCommand {
constructor(private authService: AuthService) {
}
run(email: string, password: string, cmd: program.Command) {
}
}

View File

@ -0,0 +1,80 @@
import { DeviceType } from 'jslib/enums/deviceType';
import { I18nService } from 'jslib/abstractions/i18n.service';
import { PlatformUtilsService } from 'jslib/abstractions/platformUtils.service';
import { Utils } from 'jslib/misc/utils';
export class NodePlatformUtilsService implements PlatformUtilsService {
identityClientId: string;
private deviceCache: DeviceType = null;
constructor(private i18nService: I18nService, private isDesktopApp: boolean) {
this.identityClientId = 'cli';
}
getDevice(): DeviceType {
if (!this.deviceCache) {
switch (process.platform) {
case 'win32':
this.deviceCache = DeviceType.Windows;
break;
case 'darwin':
this.deviceCache = DeviceType.MacOs;
break;
case 'linux':
default:
this.deviceCache = DeviceType.Linux;
break;
}
}
return this.deviceCache;
}
getDeviceString(): string {
return DeviceType[this.getDevice()].toLowerCase();
}
isFirefox: () => false;
isChrome: () => false;
isEdge: () => false;
isOpera: () => false;
isVivaldi: () => false;
isSafari: () => false;
isMacAppStore: () => false;
analyticsId: () => null;
getDomain(uriString: string): string {
return Utils.getHostname(uriString);
}
isViewOpen: () => false;
launchUri(uri: string, options?: any): void { }
saveFile(win: Window, blobData: any, blobOptions: any, fileName: string): void {
}
getApplicationVersion(): string {
return '1.0.0'; // TODO
}
supportsU2f: (win: Window) => false;
showDialog(text: string, title?: string, confirmText?: string, cancelText?: string, type?: string):
Promise<boolean> {
console.log(title);
console.log(text);
return Promise.resolve(true);
}
isDev(): boolean {
return false; // TODO?
}
copyToClipboard(text: string, options?: any): void {
// TODO?
}
}

View File

@ -0,0 +1,15 @@
import { StorageService } from 'jslib/abstractions/storage.service';
export class NodeSecureStorageService implements StorageService {
get<T>(key: string): Promise<T> {
return Promise.resolve(null);
}
save(key: string, obj: any): Promise<any> {
return Promise.resolve();
}
remove(key: string): Promise<any> {
return Promise.resolve();
}
}

View File

@ -0,0 +1,15 @@
import { StorageService } from 'jslib/abstractions/storage.service';
export class NodeStorageService implements StorageService {
get<T>(key: string): Promise<T> {
return Promise.resolve(null);
}
save(key: string, obj: any): Promise<any> {
return Promise.resolve();
}
remove(key: string): Promise<any> {
return Promise.resolve();
}
}

View File

@ -1,5 +1,9 @@
{
"compilerOptions": {
"pretty": true,
"moduleResolution": "node",
"target": "ES6",
"module": "commonjs",
"noImplicitAny": true,
"allowJs": true,
"sourceMap": true,