mirror of
https://github.com/bitwarden/cli
synced 2025-12-06 04:23:19 +00:00
stub out some services
This commit is contained in:
@@ -6,10 +6,10 @@ import { AuthService } from 'jslib/abstractions/auth.service';
|
|||||||
|
|
||||||
export class LoginCommand {
|
export class LoginCommand {
|
||||||
constructor(private authService: AuthService) {
|
constructor(private authService: AuthService) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
run(email: string, password: string, cmd: program.Command) {
|
run(email: string, password: string, cmd: program.Command) {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
80
src/services/nodePlatformUtils.service.ts
Normal file
80
src/services/nodePlatformUtils.service.ts
Normal 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?
|
||||||
|
}
|
||||||
|
}
|
||||||
15
src/services/nodeSecureStorage.service.ts
Normal file
15
src/services/nodeSecureStorage.service.ts
Normal 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();
|
||||||
|
}
|
||||||
|
}
|
||||||
15
src/services/nodeStorage.service.ts
Normal file
15
src/services/nodeStorage.service.ts
Normal 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();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,5 +1,9 @@
|
|||||||
{
|
{
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
|
"pretty": true,
|
||||||
|
"moduleResolution": "node",
|
||||||
|
"target": "ES6",
|
||||||
|
"module": "commonjs",
|
||||||
"noImplicitAny": true,
|
"noImplicitAny": true,
|
||||||
"allowJs": true,
|
"allowJs": true,
|
||||||
"sourceMap": true,
|
"sourceMap": true,
|
||||||
|
|||||||
Reference in New Issue
Block a user