diff --git a/jslib b/jslib index 18bf616..ecdd086 160000 --- a/jslib +++ b/jslib @@ -1 +1 @@ -Subproject commit 18bf616e2e0821a46b1cb71737d80b099a64b237 +Subproject commit ecdd08624f61ccff8128b7cb3241f39e664e1c7f diff --git a/package-lock.json b/package-lock.json index 71134d6..2f71857 100644 --- a/package-lock.json +++ b/package-lock.json @@ -23,6 +23,7 @@ "node-forge": "0.10.0", "open": "^8.0.8", "papaparse": "^5.3.0", + "rxjs": "6.6.7", "tldjs": "^2.3.1", "zxcvbn": "^4.4.2" }, diff --git a/package.json b/package.json index 3764c3d..9787dfa 100644 --- a/package.json +++ b/package.json @@ -87,6 +87,7 @@ "node-forge": "0.10.0", "open": "^8.0.8", "papaparse": "^5.3.0", + "rxjs": "6.6.7", "tldjs": "^2.3.1", "zxcvbn": "^4.4.2" }, diff --git a/src/bw.ts b/src/bw.ts index 175ea73..b3c8411 100644 --- a/src/bw.ts +++ b/src/bw.ts @@ -116,11 +116,11 @@ export class Main { this.appIdService = new AppIdService(this.storageService); this.tokenService = new TokenService(this.storageService); this.messagingService = new NoopMessagingService(); - this.apiService = new NodeApiService(this.tokenService, this.platformUtilsService, + this.environmentService = new EnvironmentService(this.storageService); + this.apiService = new NodeApiService(this.tokenService, this.platformUtilsService, this.environmentService, async (expired: boolean) => await this.logout(), 'Bitwarden_CLI/' + this.platformUtilsService.getApplicationVersion() + ' (' + this.platformUtilsService.getDeviceString().toUpperCase() + ')'); - this.environmentService = new EnvironmentService(this.apiService, this.storageService, null); this.userService = new UserService(this.tokenService, this.storageService); this.containerService = new ContainerService(this.cryptoService); this.settingsService = new SettingsService(this.userService, this.storageService); diff --git a/src/commands/config.command.ts b/src/commands/config.command.ts index fdac3a1..4806550 100644 --- a/src/commands/config.command.ts +++ b/src/commands/config.command.ts @@ -23,8 +23,9 @@ export class ConfigCommand { private async getOrSetServer(url: string, options: program.OptionValues): Promise { if ((url == null || url.trim() === '') && !options.webVault && !options.api && !options.identity && !options.icons && !options.notifications && !options.events) { - const baseUrl = this.environmentService.baseUrl; - const stringRes = new StringResponse(baseUrl == null ? 'https://bitwarden.com' : baseUrl); + const stringRes = new StringResponse( + this.environmentService.hasBaseUrl() ? this.environmentService.getUrls().base : 'https://bitwarden.com' + ); return Response.success(stringRes); } diff --git a/src/commands/send/receive.command.ts b/src/commands/send/receive.command.ts index cf424f7..fc508ba 100644 --- a/src/commands/send/receive.command.ts +++ b/src/commands/send/receive.command.ts @@ -99,12 +99,13 @@ export class SendReceiveCommand extends DownloadCommand { } private getApiUrl(url: URL) { + const urls = this.environmentService.getUrls(); if (url.origin === 'https://send.bitwarden.com') { return 'https://vault.bitwarden.com/api'; - } else if (url.origin === this.apiService.apiBaseUrl) { + } else if (url.origin === urls.api) { return url.origin; - } else if (this.platformUtilsService.isDev() && url.origin === this.environmentService.getWebVaultUrl()) { - return this.apiService.apiBaseUrl; + } else if (this.platformUtilsService.isDev() && url.origin === urls.webVault) { + return urls.api; } else { return url.origin + '/api'; } diff --git a/src/commands/status.command.ts b/src/commands/status.command.ts index 9260e08..5ffe98d 100644 --- a/src/commands/status.command.ts +++ b/src/commands/status.command.ts @@ -35,11 +35,7 @@ export class StatusCommand { } private baseUrl(): string { - let url = this.envService.baseUrl; - if (url == null) { - url = 'https://bitwarden.com'; - } - return url; + return this.envService.getUrls().base; } private async status(): Promise {