1
0
mirror of https://github.com/bitwarden/cli synced 2025-12-25 04:33:13 +00:00

move shared CLI items to jslib

This commit is contained in:
Kyle Spearrin
2019-03-15 22:34:59 -04:00
parent b7a07bb483
commit a3ba833f0d
32 changed files with 58 additions and 352 deletions

View File

@@ -1,135 +0,0 @@
import { DeviceType } from 'jslib/enums/deviceType';
import { PlatformUtilsService } from 'jslib/abstractions/platformUtils.service';
// tslint:disable-next-line
const pjson = require('../../package.json');
export class NodePlatformUtilsService implements PlatformUtilsService {
identityClientId: string;
private deviceCache: DeviceType = null;
constructor() {
this.identityClientId = 'cli';
}
getDevice(): DeviceType {
if (!this.deviceCache) {
switch (process.platform) {
case 'win32':
this.deviceCache = DeviceType.WindowsDesktop;
break;
case 'darwin':
this.deviceCache = DeviceType.MacOsDesktop;
break;
case 'linux':
default:
this.deviceCache = DeviceType.LinuxDesktop;
break;
}
}
return this.deviceCache;
}
getDeviceString(): string {
const device = DeviceType[this.getDevice()].toLowerCase();
return device.replace('desktop', '');
}
isFirefox() {
return false;
}
isChrome() {
return false;
}
isEdge() {
return false;
}
isOpera() {
return false;
}
isVivaldi() {
return false;
}
isSafari() {
return false;
}
isIE() {
return false;
}
isMacAppStore() {
return false;
}
analyticsId() {
return null as string;
}
isViewOpen() {
return false;
}
lockTimeout(): number {
return null;
}
launchUri(uri: string, options?: any): void {
throw new Error('Not implemented.');
}
saveFile(win: Window, blobData: any, blobOptions: any, fileName: string): void {
throw new Error('Not implemented.');
}
getApplicationVersion(): string {
return pjson.version;
}
supportsU2f(win: Window) {
return false;
}
supportsDuo(): boolean {
return false;
}
showToast(type: 'error' | 'success' | 'warning' | 'info', title: string, text: string | string[],
options?: any): void {
throw new Error('Not implemented.');
}
showDialog(text: string, title?: string, confirmText?: string, cancelText?: string, type?: string):
Promise<boolean> {
throw new Error('Not implemented.');
}
eventTrack(action: string, label?: string, options?: any) {
throw new Error('Not implemented.');
}
isDev(): boolean {
return process.env.BWCLI_ENV === 'development';
}
isSelfHost(): boolean {
return false;
}
copyToClipboard(text: string, options?: any): void {
throw new Error('Not implemented.');
}
readFromClipboard(options?: any): Promise<string> {
throw new Error('Not implemented.');
}
}

View File

@@ -1,7 +0,0 @@
import { MessagingService } from 'jslib/abstractions/messaging.service';
export class NoopMessagingService implements MessagingService {
send(subscriber: string, arg: any = {}) {
// Do nothing...
}
}