@@ -7,16 +7,19 @@ import { EnvironmentService } from "../../deps/bw/libs/shared/dist/src/services/
7import { StateMigrationService } from "../../deps/bw/libs/shared/dist/src/services/stateMigration.service";
7import { StateMigrationService } from "../../deps/bw/libs/shared/dist/src/services/stateMigration.service";
8import { TokenService } from "../../deps/bw/libs/shared/dist/src/services/token.service";
8import { TokenService } from "../../deps/bw/libs/shared/dist/src/services/token.service";
9import { WebCryptoFunctionService } from "../../deps/bw/libs/shared/dist/src/services/webCryptoFunction.service";
9import { WebCryptoFunctionService } from "../../deps/bw/libs/shared/dist/src/services/webCryptoFunction.service";
10+import { Account, AccountSettings } from "../../deps/bw/libs/shared/dist/src/models/domain/account";
11// import BrowserStorageService from "../../deps/bw/libs/shared/dist/src/services/browserStorage.service";
12// import BrowserStorageService from "../../deps/bw/libs/shared/dist/src/services/browserStorage.service";
12import { CryptoService } from "../../deps/bw/libs/shared/dist/src/abstractions/crypto.service";
13import { CryptoService } from "../../deps/bw/libs/shared/dist/src/abstractions/crypto.service";
13import { I18nService } from "../../deps/bw/libs/shared/dist/src/services/i18n.service";
14import { I18nService } from "../../deps/bw/libs/shared/dist/src/services/i18n.service";
14import { StateService } from "../../deps/bw/libs/shared/dist/src/services/state.service";
15import { StateService } from "../../deps/bw/libs/shared/dist/src/services/state.service";
16−export function getAPI() {
17+export function getAPI(urls) {
17 return function () {
18 return function () {
18 const bg = new MainBackground()
19 const bg = new MainBackground()
21+ bg.environmentService.setUrls(urls)
20 return bg.apiService
23 return bg.apiService
@@ -38,11 +41,9 @@ class MainBackground {
38 stateMigrationService; //: StateMigrationService;
41 stateMigrationService; //: StateMigrationService;
41− constructor(isPrivateMode = false) {
44+ constructor() {
43− this.messagingService = isPrivateMode
44− ? new BrowserMessagingPrivateModeBackgroundService()
45− : new BrowserMessagingService();
46+ this.messagingService = new BrowserMessagingService();
46 this.storageService = new BrowserStorageService();
47 this.storageService = new BrowserStorageService();
47 this.logService = new ConsoleLogService(false);
48 this.logService = new ConsoleLogService(false);
48 this.stateMigrationService = new StateMigrationService(
49 this.stateMigrationService = new StateMigrationService(
@@ -79,7 +80,7 @@ class MainBackground {
82− this.i18nService = new I18nService(BrowserApi.getUILanguage(window));
83+ this.i18nService = new I18nService("en");
83 this.cryptoFunctionService = new WebCryptoFunctionService(window);
84 this.cryptoFunctionService = new WebCryptoFunctionService(window);
84 this.cryptoService = new BrowserCryptoService(
85 this.cryptoService = new BrowserCryptoService(
85 this.cryptoFunctionService,
86 this.cryptoFunctionService,
@@ -135,7 +136,7 @@ class BrowserStorageService {
137 async get(key) {
138 async get(key) {
138− return resolve(JSON.parse(this.storage.getItem(key)));
139+ return JSON.parse(this.storage.getItem(key));
141 async has(key) {
142 async has(key) {
@@ -175,13 +176,6 @@ class BrowserMessagingService {
178−class BrowserMessagingPrivateModeBackgroundService {
179− send(subscriber, arg = {}) {
180− const message = Object.assign({}, { command: subscriber }, arg);
181− window.bitwardenPopupMainMessageListener(message);
185class BrowserPlatformUtilsService {
179class BrowserPlatformUtilsService {
186 constructor(messagingService, stateService, clipboardWriteCallback, biometricCallback) {
180 constructor(messagingService, stateService, clipboardWriteCallback, biometricCallback) {
187 this.messagingService = messagingService;
181 this.messagingService = messagingService;
@@ -194,31 +188,7 @@ class BrowserPlatformUtilsService {
194 this.prefersColorSchemeDark = window.matchMedia("(prefers-color-scheme: dark)");
188 this.prefersColorSchemeDark = window.matchMedia("(prefers-color-scheme: dark)");
196 getDevice() {
190 getDevice() {
197− if (this.deviceCache) {
191+ return 9; // Chrome
198− return this.deviceCache;
200− if (navigator.userAgent.indexOf(" Firefox/") !== -1 ||
201− navigator.userAgent.indexOf(" Gecko/") !== -1) {
202− this.deviceCache = DeviceType.FirefoxExtension;
204− else if ((!!window.opr && !!opr.addons) ||
206− navigator.userAgent.indexOf(" OPR/") >= 0) {
207− this.deviceCache = DeviceType.OperaExtension;
209− else if (navigator.userAgent.indexOf(" Edg/") !== -1) {
210− this.deviceCache = DeviceType.EdgeExtension;
212− else if (navigator.userAgent.indexOf(" Vivaldi/") !== -1) {
213− this.deviceCache = DeviceType.VivaldiExtension;
215− else if (window.chrome && navigator.userAgent.indexOf(" Chrome/") !== -1) {
216− this.deviceCache = DeviceType.ChromeExtension;
218− else if (navigator.userAgent.indexOf(" Safari/") !== -1) {
219− this.deviceCache = DeviceType.SafariExtension;
221− return this.deviceCache;
223 getDeviceString() {
193 getDeviceString() {
224 const device = DeviceType[this.getDevice()].toLowerCase();
194 const device = DeviceType[this.getDevice()].toLowerCase();
@@ -252,33 +222,19 @@ class BrowserPlatformUtilsService {
252 return false;
222 return false;
254 isViewOpen() {
224 isViewOpen() {
255− return __awaiter(this, void 0, void 0, function* () {
256− if (yield BrowserApi.isPopupOpen()) {
257− return true;
225+ return true;
259− if (this.isSafari()) {
262− const sidebarView = this.sidebarViewName();
263− const sidebarOpen = sidebarView != null && chrome.extension.getViews({ type: sidebarView }).length > 0;
267− const tabOpen = chrome.extension.getViews({ type: "tab" }).length > 0;
271 lockTimeout() {
227 lockTimeout() {
272 return null;
228 return null;
274 launchUri(uri, options) {
230 launchUri(uri, options) {
275− BrowserApi.createNewTab(uri, options && options.extensionPage === true);
231+ // BrowserApi.createNewTab(uri, options && options.extensionPage === true);
277 saveFile(win, blobData, blobOptions, fileName) {
233 saveFile(win, blobData, blobOptions, fileName) {
278− BrowserApi.downloadFile(win, blobData, blobOptions, fileName);
234+ // BrowserApi.downloadFile(win, blobData, blobOptions, fileName);
280 getApplicationVersion() {
236 getApplicationVersion() {
281− return Promise.resolve(BrowserApi.getApplicationVersion());
237+ // return Promise.resolve(BrowserApi.getApplicationVersion());
283 supportsWebAuthn(win) {
239 supportsWebAuthn(win) {
284 return typeof PublicKeyCredential !== "undefined";
240 return typeof PublicKeyCredential !== "undefined";
@@ -452,16 +408,7 @@ class BrowserPlatformUtilsService {
454 supportsBiometric() {
410 supportsBiometric() {
455− return __awaiter(this, void 0, void 0, function* () {
456− const platformInfo = yield BrowserApi.getPlatformInfo();
457− if (platformInfo.os === "android") {
458− return false;
411+ return false;
460− if (this.isFirefox()) {
461− return parseInt((yield browser.runtime.getBrowserInfo()).version.split(".")[0], 10) >= 87;
466 authenticateBiometric() {
413 authenticateBiometric() {
467 return this.biometricCallback();
414 return this.biometricCallback();