diff --git a/src/background.html b/src/background.html index 820ba065..0ecb2203 100644 --- a/src/background.html +++ b/src/background.html @@ -17,7 +17,7 @@ - + diff --git a/src/background.js b/src/background.js index d4dceb1a..c045414c 100644 --- a/src/background.js +++ b/src/background.js @@ -9,7 +9,7 @@ var bg_isBackground = true, bg_environmentService, bg_userService, bg_settingsService, - bg_loginService, + bg_cipherService, bg_folderService, bg_lockService, bg_syncService, @@ -38,16 +38,16 @@ var bg_isBackground = true, bg_environmentService = new EnvironmentService(bg_constantsService, bg_apiService); bg_userService = new UserService(bg_tokenService, bg_apiService, bg_cryptoService, bg_utilsService); bg_settingsService = new SettingsService(bg_userService, bg_utilsService); - bg_loginService = new LoginService(bg_cryptoService, bg_userService, bg_apiService, bg_settingsService, bg_utilsService, + bg_cipherService = new CipherService(bg_cryptoService, bg_userService, bg_apiService, bg_settingsService, bg_utilsService, bg_constantsService); bg_folderService = new FolderService(bg_cryptoService, bg_userService, bg_apiService, bg_i18nService, bg_utilsService); - bg_lockService = new LockService(bg_constantsService, bg_cryptoService, bg_folderService, bg_loginService, bg_utilsService, + bg_lockService = new LockService(bg_constantsService, bg_cryptoService, bg_folderService, bg_cipherService, bg_utilsService, setIcon, refreshBadgeAndMenu); - bg_syncService = new SyncService(bg_loginService, bg_folderService, bg_userService, bg_apiService, bg_settingsService, + bg_syncService = new SyncService(bg_cipherService, bg_folderService, bg_userService, bg_apiService, bg_settingsService, bg_cryptoService, logout); bg_passwordGenerationService = new PasswordGenerationService(); bg_totpService = new TotpService(bg_constantsService); - bg_autofillService = new AutofillService(bg_utilsService, bg_totpService, bg_tokenService, bg_loginService); + bg_autofillService = new AutofillService(bg_utilsService, bg_totpService, bg_tokenService, bg_cipherService); if (chrome.commands) { chrome.commands.onCommand.addListener(function (command) { @@ -202,7 +202,7 @@ var bg_isBackground = true, return; } - bg_loginService.getAllDecrypted().then(function (logins) { + bg_cipherService.getAllDecrypted().then(function (logins) { for (var i = 0; i < logins.length; i++) { if (logins[i].id === id) { if (info.parentMenuItemId === 'autofill') { @@ -257,7 +257,7 @@ var bg_isBackground = true, if (bg_utilsService.isFirefox()) { return new Promise(function (resolve, reject) { - bg_loginService.getAllDecryptedForDomain(domain).then(function (logins) { + bg_cipherService.getAllDecryptedForDomain(domain).then(function (logins) { if (!logins || logins.length !== 1) { reject(); return; @@ -275,7 +275,7 @@ var bg_isBackground = true, }); } else { - bg_loginService.getAllDecryptedForDomain(domain).then(function (logins) { + bg_cipherService.getAllDecryptedForDomain(domain).then(function (logins) { if (!logins || logins.length !== 1) { callback(); return; @@ -456,8 +456,8 @@ var bg_isBackground = true, setActionBadgeColor(bg_sidebarAction); menuOptionsLoaded = []; - bg_loginService.getAllDecryptedForDomain(tabDomain).then(function (logins) { - logins.sort(bg_loginService.sortLoginsByLastUsedThenName); + bg_cipherService.getAllDecryptedForDomain(tabDomain).then(function (logins) { + logins.sort(bg_cipherService.sortLoginsByLastUsedThenName); if (contextMenuEnabled) { for (var i = 0; i < logins.length; i++) { @@ -579,7 +579,7 @@ var bg_isBackground = true, return; } - bg_loginService.getAllDecryptedForDomain(loginDomain).then(function (logins) { + bg_cipherService.getAllDecryptedForDomain(loginDomain).then(function (logins) { var match = false; for (var i = 0; i < logins.length; i++) { if (logins[i].username === login.username) { @@ -634,7 +634,7 @@ var bg_isBackground = true, bg_loginsToAdd.splice(i, 1); /* jshint ignore:start */ - bg_loginService.encrypt({ + bg_cipherService.encrypt({ id: null, folderId: null, favorite: false, @@ -645,7 +645,7 @@ var bg_isBackground = true, notes: null }).then(function (loginModel) { var login = new Login(loginModel, true); - bg_loginService.saveWithServer(login).then(function (login) { + bg_cipherService.saveWithServer(login).then(function (login) { ga('send', { hitType: 'event', eventAction: 'Added Login from Notification Bar' @@ -669,7 +669,7 @@ var bg_isBackground = true, if (tabDomain && tabDomain === loginToAdd.domain) { bg_loginsToAdd.splice(i, 1); var hostname = bg_utilsService.getHostname(tab.url); - bg_loginService.saveNeverDomain(hostname); + bg_cipherService.saveNeverDomain(hostname); messageTab(tab.id, 'closeNotificationBar'); } } @@ -816,7 +816,7 @@ var bg_isBackground = true, bg_cryptoService.clearKeys(), bg_userService.clear(), bg_settingsService.clear(userId), - bg_loginService.clear(userId), + bg_cipherService.clear(userId), bg_folderService.clear(userId) ]).then(function () { chrome.runtime.sendMessage({ diff --git a/src/popup/app/current/currentController.js b/src/popup/app/current/currentController.js index a633047e..222fa9c5 100644 --- a/src/popup/app/current/currentController.js +++ b/src/popup/app/current/currentController.js @@ -1,7 +1,7 @@ angular .module('bit.current') - .controller('currentController', function ($scope, loginService, utilsService, toastr, $window, $state, $timeout, + .controller('currentController', function ($scope, cipherService, utilsService, toastr, $window, $state, $timeout, autofillService, $analytics, i18nService, totpService, tokenService) { $scope.i18n = i18nService; @@ -44,7 +44,7 @@ angular canAutofill = true; }); - loginService.getAllDecryptedForDomain(domain).then(function (ciphers) { + cipherService.getAllDecryptedForDomain(domain).then(function (ciphers) { $timeout(function () { $scope.loaded = true; $scope.ciphers = ciphers; diff --git a/src/popup/app/services/authService.js b/src/popup/app/services/authService.js index 6d08bc27..7634fa0a 100644 --- a/src/popup/app/services/authService.js +++ b/src/popup/app/services/authService.js @@ -1,7 +1,7 @@ angular .module('bit.services') - .factory('authService', function (cryptoService, apiService, userService, tokenService, $q, $rootScope, loginService, + .factory('authService', function (cryptoService, apiService, userService, tokenService, $q, $rootScope, folderService, settingsService, syncService, appIdService, utilsService, constantsService) { var _service = {}; diff --git a/src/popup/app/services/backgroundService.js b/src/popup/app/services/backgroundService.js index 766f76fd..009ef61d 100644 --- a/src/popup/app/services/backgroundService.js +++ b/src/popup/app/services/backgroundService.js @@ -21,9 +21,9 @@ var page = chrome.extension.getBackgroundPage(); return page ? page.bg_folderService : null; }) - .factory('loginService', function () { + .factory('cipherService', function () { var page = chrome.extension.getBackgroundPage(); - return page ? page.bg_loginService : null; + return page ? page.bg_cipherService : null; }) .factory('syncService', function () { var page = chrome.extension.getBackgroundPage(); diff --git a/src/popup/app/tools/toolsExportController.js b/src/popup/app/tools/toolsExportController.js index 757edcd5..974b6ae3 100644 --- a/src/popup/app/tools/toolsExportController.js +++ b/src/popup/app/tools/toolsExportController.js @@ -2,7 +2,7 @@ .module('bit.tools') .controller('toolsExportController', function ($scope, $state, toastr, $q, $analytics, - i18nService, cryptoService, userService, folderService, loginService, $window) { + i18nService, cryptoService, userService, folderService, cipherService, $window) { $scope.i18n = i18nService; $('#master-password').focus(); @@ -51,7 +51,7 @@ }); promises.push(folderPromise); - var loginPromise = $q.when(loginService.getAllDecrypted()); + var loginPromise = $q.when(cipherService.getAllDecrypted()); loginPromise.then(function (logins) { decLogins = logins; }); diff --git a/src/popup/app/vault/vaultAddCipherController.js b/src/popup/app/vault/vaultAddCipherController.js index 67ee1f95..ddcd9e3f 100644 --- a/src/popup/app/vault/vaultAddCipherController.js +++ b/src/popup/app/vault/vaultAddCipherController.js @@ -1,7 +1,7 @@ angular .module('bit.vault') - .controller('vaultAddCipherController', function ($scope, $state, $stateParams, loginService, folderService, + .controller('vaultAddCipherController', function ($scope, $state, $stateParams, cipherService, folderService, cryptoService, toastr, utilsService, $analytics, i18nService, constantsService) { $scope.i18n = i18nService; $scope.constants = constantsService; @@ -51,9 +51,9 @@ return; } - $scope.savePromise = loginService.encrypt($scope.cipher).then(function (cipherModel) { + $scope.savePromise = cipherService.encrypt($scope.cipher).then(function (cipherModel) { var cipher = new Cipher(cipherModel, true); - return loginService.saveWithServer(cipher); + return cipherService.saveWithServer(cipher); }).then(function (c) { $analytics.eventTrack('Added Cipher'); toastr.success(i18nService.addedLogin); diff --git a/src/popup/app/vault/vaultAttachmentsController.js b/src/popup/app/vault/vaultAttachmentsController.js index cb7732b7..456b3129 100644 --- a/src/popup/app/vault/vaultAttachmentsController.js +++ b/src/popup/app/vault/vaultAttachmentsController.js @@ -1,7 +1,7 @@ angular .module('bit.vault') - .controller('vaultAttachmentsController', function ($scope, $state, $stateParams, loginService, toastr, + .controller('vaultAttachmentsController', function ($scope, $state, $stateParams, cipherService, toastr, SweetAlert, utilsService, $analytics, i18nService, cryptoService, tokenService) { $scope.i18n = i18nService; utilsService.initListSectionItemListeners($(document), angular); @@ -10,7 +10,7 @@ angular $scope.canAccessAttachments = $scope.isPremium; $scope.hasUpdatedKey = false; - loginService.get($stateParams.id).then(function (login) { + cipherService.get($stateParams.id).then(function (login) { return login.decrypt(); }).then(function (model) { $scope.login = model; @@ -69,7 +69,7 @@ angular return deferred.promise; } - $scope.submitPromise = loginService.saveAttachmentWithServer($scope.login, files[0]).then(function (login) { + $scope.submitPromise = cipherService.saveAttachmentWithServer($scope.login, files[0]).then(function (login) { login.decrypt().then(function (model) { $scope.login = model; }); @@ -100,7 +100,7 @@ angular cancelButtonText: i18nService.no }, function (confirmed) { if (confirmed) { - loginService.deleteAttachmentWithServer($stateParams.id, attachment.id).then(function () { + cipherService.deleteAttachmentWithServer($stateParams.id, attachment.id).then(function () { var index = $scope.login.attachments.indexOf(attachment); if (index > -1) { $scope.login.attachments.splice(index, 1); diff --git a/src/popup/app/vault/vaultController.js b/src/popup/app/vault/vaultController.js index d2be85cc..1a5d2833 100644 --- a/src/popup/app/vault/vaultController.js +++ b/src/popup/app/vault/vaultController.js @@ -1,7 +1,7 @@ angular .module('bit.vault') - .controller('vaultController', function ($scope, $rootScope, loginService, folderService, $q, $state, $stateParams, toastr, + .controller('vaultController', function ($scope, $rootScope, cipherService, folderService, $q, $state, $stateParams, toastr, syncService, utilsService, $analytics, i18nService, stateService, $timeout, $window) { var stateKey = 'vault', state = stateService.getState(stateKey) || {}; @@ -50,7 +50,7 @@ }); promises.push(folderPromise); - var cipherPromise = loginService.getAllDecrypted().then(function (ciphers) { + var cipherPromise = cipherService.getAllDecrypted().then(function (ciphers) { decCiphers = ciphers; }); promises.push(cipherPromise); diff --git a/src/popup/app/vault/vaultEditCipherController.js b/src/popup/app/vault/vaultEditCipherController.js index c4929ccc..bd1da80e 100644 --- a/src/popup/app/vault/vaultEditCipherController.js +++ b/src/popup/app/vault/vaultEditCipherController.js @@ -1,7 +1,7 @@ angular .module('bit.vault') - .controller('vaultEditCipherController', function ($scope, $state, $stateParams, loginService, folderService, + .controller('vaultEditCipherController', function ($scope, $state, $stateParams, cipherService, folderService, cryptoService, toastr, SweetAlert, utilsService, $analytics, i18nService, constantsService) { $scope.i18n = i18nService; $scope.constants = constantsService; @@ -22,7 +22,7 @@ angular angular.extend($scope.cipher, $stateParams.cipher); } else { - loginService.get(cipherId).then(function (cipher) { + cipherService.get(cipherId).then(function (cipher) { return cipher.decrypt(); }).then(function (model) { $scope.cipher = model; @@ -46,9 +46,9 @@ angular return; } - $scope.savePromise = loginService.encrypt($scope.cipher).then(function (cipherModel) { + $scope.savePromise = cipherService.encrypt($scope.cipher).then(function (cipherModel) { var cipher = new Cipher(cipherModel, true); - return loginService.saveWithServer(cipher).then(function (c) { + return cipherService.saveWithServer(cipher).then(function (c) { $analytics.eventTrack('Edited Cipher'); toastr.success(i18nService.editedLogin); $scope.close(); @@ -65,7 +65,7 @@ angular cancelButtonText: i18nService.no }, function (confirmed) { if (confirmed) { - loginService.deleteWithServer(cipherId).then(function () { + cipherService.deleteWithServer(cipherId).then(function () { $analytics.eventTrack('Deleted Cipher'); toastr.success(i18nService.deletedLogin); $state.go('tabs.vault', { diff --git a/src/popup/app/vault/vaultViewCipherController.js b/src/popup/app/vault/vaultViewCipherController.js index 94feb646..fd618e74 100644 --- a/src/popup/app/vault/vaultViewCipherController.js +++ b/src/popup/app/vault/vaultViewCipherController.js @@ -1,7 +1,7 @@ angular .module('bit.vault') - .controller('vaultViewCipherController', function ($scope, $state, $stateParams, loginService, toastr, + .controller('vaultViewCipherController', function ($scope, $state, $stateParams, cipherService, toastr, $analytics, i18nService, utilsService, totpService, $timeout, tokenService, $window, cryptoService, SweetAlert, constantsService) { $scope.constants = constantsService; @@ -13,7 +13,7 @@ angular $scope.isPremium = tokenService.getPremium(); $scope.cipher = null; var cipherObj = null; - loginService.get($stateParams.cipherId).then(function (cipher) { + cipherService.get($stateParams.cipherId).then(function (cipher) { if (!cipher) { return; } diff --git a/src/popup/app/vault/vaultViewFolderController.js b/src/popup/app/vault/vaultViewFolderController.js index e217d91e..3f1b9201 100644 --- a/src/popup/app/vault/vaultViewFolderController.js +++ b/src/popup/app/vault/vaultViewFolderController.js @@ -1,7 +1,7 @@ angular .module('bit.vault') - .controller('vaultViewFolderController', function ($scope, loginService, folderService, $q, $state, $stateParams, toastr, + .controller('vaultViewFolderController', function ($scope, cipherService, folderService, $q, $state, $stateParams, toastr, syncService, $analytics, i18nService, stateService, utilsService, $timeout, $window) { var stateKey = 'viewFolder', state = stateService.getState(stateKey) || {}; @@ -39,7 +39,7 @@ promises.push(folderDeferred.promise); } - var cipherPromise = loginService.getAllDecryptedForFolder($scope.folder.id).then(function (ciphers) { + var cipherPromise = cipherService.getAllDecryptedForFolder($scope.folder.id).then(function (ciphers) { if (utilsService.isEdge()) { // Edge is super slow at sorting decCiphers = ciphers; diff --git a/src/services/apiService.js b/src/services/apiService.js index fdaa109c..a0ebeb4e 100644 --- a/src/services/apiService.js +++ b/src/services/apiService.js @@ -38,16 +38,16 @@ function initApiService() { //self.identityBaseUrl = 'https://localhost:44392'; // Desktop external - //self.baseUrl = 'http://192.168.1.4:4000'; - //self.identityBaseUrl = 'http://192.168.1.4:33656'; + self.baseUrl = 'http://192.168.1.3:4000'; + self.identityBaseUrl = 'http://192.168.1.3:33656'; // Preview //self.baseUrl = 'https://preview-api.bitwarden.com'; //self.identityBaseUrl = 'https://preview-identity.bitwarden.com'; // Production - self.baseUrl = 'https://api.bitwarden.com'; - self.identityBaseUrl = 'https://identity.bitwarden.com'; + //self.baseUrl = 'https://api.bitwarden.com'; + //self.identityBaseUrl = 'https://identity.bitwarden.com'; }; // Auth APIs diff --git a/src/services/autofillService.js b/src/services/autofillService.js index a1286782..1ec70351 100644 --- a/src/services/autofillService.js +++ b/src/services/autofillService.js @@ -1,8 +1,8 @@ -function AutofillService(utilsService, totpService, tokenService, loginService) { +function AutofillService(utilsService, totpService, tokenService, cipherService) { this.utilsService = utilsService; this.totpService = totpService; this.tokenService = tokenService; - this.loginService = loginService; + this.cipherService = cipherService; initAutofill(); } @@ -226,7 +226,7 @@ function initAutofill() { didAutofill = true; if (!options.skipLastUsed) { - self.loginService.updateLastUsedDate(options.login.id); + self.cipherService.updateLastUsedDate(options.login.id); } chrome.tabs.sendMessage(tab.id, { @@ -294,13 +294,13 @@ function initAutofill() { return; } - self.loginService.getLastUsedForDomain(tabDomain).then(function (login) { - if (!login) { + self.cipherService.getLastUsedForDomain(tabDomain).then(function (cipher) { + if (!cipher) { return; } self.doAutoFill({ - login: login, + login: cipher, pageDetails: pageDetails, fromBackground: true, skipTotp: !fromCommand, diff --git a/src/services/loginService.js b/src/services/cipherService.js similarity index 85% rename from src/services/loginService.js rename to src/services/cipherService.js index e37e2a7c..e191d895 100644 --- a/src/services/loginService.js +++ b/src/services/cipherService.js @@ -1,4 +1,4 @@ -function LoginService(cryptoService, userService, apiService, settingsService, utilsService, constantsService) { +function CipherService(cryptoService, userService, apiService, settingsService, utilsService, constantsService) { this.cryptoService = cryptoService; this.userService = userService; this.apiService = apiService; @@ -9,33 +9,33 @@ function LoginService(cryptoService, userService, apiService, settingsService, u this.localDataKey = 'sitesLocalData'; this.neverDomainsKey = 'neverDomains'; - initLoginService(); + initCipherService(); } -function initLoginService() { - LoginService.prototype.clearCache = function () { +function initCipherService() { + CipherService.prototype.clearCache = function () { this.decryptedCipherCache = null; }; - LoginService.prototype.encrypt = function (login) { + CipherService.prototype.encrypt = function (cipher) { var self = this; var model = { - id: login.id, - folderId: login.folderId, - favorite: login.favorite, - organizationId: login.organizationId, - type: login.type + id: cipher.id, + folderId: cipher.folderId, + favorite: cipher.favorite, + organizationId: cipher.organizationId, + type: cipher.type }; - return self.cryptoService.getOrgKey(login.organizationId).then(function (key) { + return self.cryptoService.getOrgKey(cipher.organizationId).then(function (key) { return Q.all([ - encryptObjProperty(login, model, { + encryptObjProperty(cipher, model, { name: null, notes: null }, key, self), - encryptCipherData(login, model, key, self), - self.encryptFields(login.fields, key).then(function (fields) { + encryptCipherData(cipher, model, key, self), + self.encryptFields(cipher.fields, key).then(function (fields) { model.fields = fields; }) ]); @@ -96,7 +96,7 @@ function initLoginService() { } } - LoginService.prototype.encryptFields = function (fields, key) { + CipherService.prototype.encryptFields = function (fields, key) { var self = this; if (!fields || !fields.length) { return Q(null); @@ -114,7 +114,7 @@ function initLoginService() { }); }; - LoginService.prototype.encryptField = function (field, key) { + CipherService.prototype.encryptField = function (field, key) { var self = this; var model = { @@ -155,7 +155,7 @@ function initLoginService() { return Q.all(promises); } - LoginService.prototype.get = function (id) { + CipherService.prototype.get = function (id) { var self = this, key = null, localData; @@ -178,7 +178,7 @@ function initLoginService() { }); }; - LoginService.prototype.getAll = function () { + CipherService.prototype.getAll = function () { var self = this, key = null, localData = null; @@ -204,7 +204,7 @@ function initLoginService() { }); }; - LoginService.prototype.getAllDecrypted = function () { + CipherService.prototype.getAllDecrypted = function () { if (this.decryptedCipherCache) { return Q(this.decryptedCipherCache); } @@ -247,7 +247,7 @@ function initLoginService() { return deferred.promise; }; - LoginService.prototype.getAllDecryptedForFolder = function (folderId) { + CipherService.prototype.getAllDecryptedForFolder = function (folderId) { return this.getAllDecrypted().then(function (ciphers) { var ciphersToReturn = []; for (var i = 0; i < ciphers.length; i++) { @@ -260,7 +260,7 @@ function initLoginService() { }); }; - LoginService.prototype.getAllDecryptedForDomain = function (domain) { + CipherService.prototype.getAllDecryptedForDomain = function (domain) { var self = this; var eqDomainsPromise = self.settingsService.getEquivalentDomains().then(function (eqDomains) { @@ -294,7 +294,7 @@ function initLoginService() { }); }; - LoginService.prototype.getLastUsedForDomain = function (domain) { + CipherService.prototype.getLastUsedForDomain = function (domain) { var self = this, deferred = Q.defer(); @@ -311,7 +311,7 @@ function initLoginService() { return deferred.promise; }; - LoginService.prototype.saveWithServer = function (cipher) { + CipherService.prototype.saveWithServer = function (cipher) { var deferred = Q.defer(); var self = this, @@ -341,7 +341,7 @@ function initLoginService() { return deferred.promise; }; - LoginService.prototype.upsert = function (cipher) { + CipherService.prototype.upsert = function (cipher) { var self = this, key = null; @@ -368,7 +368,7 @@ function initLoginService() { }); }; - LoginService.prototype.updateLastUsedDate = function (id) { + CipherService.prototype.updateLastUsedDate = function (id) { var self = this; var ciphersLocalData = null; @@ -403,7 +403,7 @@ function initLoginService() { }); }; - LoginService.prototype.replace = function (ciphers) { + CipherService.prototype.replace = function (ciphers) { var self = this; self.userService.getUserIdPromise().then(function (userId) { return self.utilsService.saveObjToStorage('ciphers_' + userId, ciphers); @@ -412,46 +412,46 @@ function initLoginService() { }); }; - LoginService.prototype.clear = function (userId) { + CipherService.prototype.clear = function (userId) { var self = this; return self.utilsService.removeFromStorage('ciphers_' + userId).then(function () { self.decryptedCipherCache = null; }); }; - LoginService.prototype.delete = function (id) { + CipherService.prototype.delete = function (id) { var self = this, key = null; self.userService.getUserIdPromise().then(function () { key = 'ciphers_' + userId; return self.utilsService.getObjFromStorage(key); - }).then(function (logins) { - if (!logins) { + }).then(function (ciphers) { + if (!ciphers) { return null; } if (id.constructor === Array) { for (var i = 0; i < id.length; i++) { - if (id[i] in logins) { - delete logins[id[i]]; + if (id[i] in ciphers) { + delete ciphers[id[i]]; } } } - else if (id in logins) { - delete logins[id]; + else if (id in ciphers) { + delete ciphers[id]; } else { return null; } - return logins; - }).then(function (logins) { - if (!logins) { + return ciphers; + }).then(function (ciphers) { + if (!ciphers) { return false; } - return self.utilsService.saveObjToStorage(key, logins); + return self.utilsService.saveObjToStorage(key, ciphers); }).then(function (clearCache) { if (clearCache !== false) { self.decryptedCipherCache = null; @@ -459,14 +459,14 @@ function initLoginService() { }); }; - LoginService.prototype.deleteWithServer = function (id) { + CipherService.prototype.deleteWithServer = function (id) { var self = this; return self.apiService.deleteCipher(id).then(function () { return self.delete(id); }); }; - LoginService.prototype.saveNeverDomain = function (domain) { + CipherService.prototype.saveNeverDomain = function (domain) { if (!domain) { return Q(); } @@ -482,7 +482,7 @@ function initLoginService() { }); }; - LoginService.prototype.saveAttachmentWithServer = function (cipher, unencryptedFile) { + CipherService.prototype.saveAttachmentWithServer = function (cipher, unencryptedFile) { var deferred = Q.defer(), self = this, response = null, @@ -531,22 +531,22 @@ function initLoginService() { return deferred.promise; }; - LoginService.prototype.deleteAttachment = function (id, attachmentId) { + CipherService.prototype.deleteAttachment = function (id, attachmentId) { var self = this, key = null; self.userService.getUserIdPromise().then(function () { key = 'ciphers_' + userId; return self.utilsService.getObjFromStorage(key); - }).then(function (logins) { - if (logins && id in logins && logins[id].attachments) { - for (var i = 0; i < logins[id].attachments.length; i++) { - if (logins[id].attachments[i].id === attachmentId) { - logins[id].attachments.splice(i, 1); + }).then(function (ciphers) { + if (ciphers && id in ciphers && ciphers[id].attachments) { + for (var i = 0; i < ciphers[id].attachments.length; i++) { + if (ciphers[id].attachments[i].id === attachmentId) { + ciphers[id].attachments.splice(i, 1); } } - return self.utilsService.saveObjToStorage(key, logins); + return self.utilsService.saveObjToStorage(key, ciphers); } else { return false; @@ -558,7 +558,7 @@ function initLoginService() { }); }; - LoginService.prototype.deleteAttachmentWithServer = function (id, attachmentId) { + CipherService.prototype.deleteAttachmentWithServer = function (id, attachmentId) { var self = this, deferred = Q.defer(); @@ -576,9 +576,9 @@ function initLoginService() { return deferred.promise; }; - LoginService.prototype.sortLoginsByLastUsed = sortLoginsByLastUsed; + CipherService.prototype.sortLoginsByLastUsed = sortLoginsByLastUsed; - LoginService.prototype.sortLoginsByLastUsedThenName = function (a, b) { + CipherService.prototype.sortLoginsByLastUsedThenName = function (a, b) { var result = sortLoginsByLastUsed(a, b); if (result !== 0) { return result; diff --git a/src/services/lockService.js b/src/services/lockService.js index 3c128d7b..9f903ea7 100644 --- a/src/services/lockService.js +++ b/src/services/lockService.js @@ -1,9 +1,9 @@ -function LockService(constantsService, cryptoService, folderService, loginService, utilsService, setIcon, refreshBadgeAndMenu) { +function LockService(constantsService, cryptoService, folderService, cipherService, utilsService, setIcon, refreshBadgeAndMenu) { this.lastLockCheck = null; this.constantsService = constantsService; this.cryptoService = cryptoService; this.folderService = folderService; - this.loginService = loginService; + this.cipherService = cipherService; this.utilsService = utilsService; this.setIcon = setIcon; this.refreshBadgeAndMenu = refreshBadgeAndMenu; @@ -84,7 +84,7 @@ function initLockService(self) { ]).then(function () { self.setIcon(); self.folderService.clearCache(); - self.loginService.clearCache(); + self.cipherService.clearCache(); self.refreshBadgeAndMenu(); }); }; diff --git a/src/services/syncService.js b/src/services/syncService.js index c0846d9f..6afcb9e6 100644 --- a/src/services/syncService.js +++ b/src/services/syncService.js @@ -1,6 +1,6 @@ -function SyncService(loginService, folderService, userService, apiService, settingsService, +function SyncService(cipherService, folderService, userService, apiService, settingsService, cryptoService, logoutCallback) { - this.loginService = loginService; + this.cipherService = cipherService; this.folderService = folderService; this.userService = userService; this.apiService = apiService; @@ -143,7 +143,7 @@ function initSyncService() { for (var i = 0; i < response.length; i++) { ciphers[response[i].id] = new CipherData(response[i], userId); } - return self.loginService.replace(ciphers); + return self.cipherService.replace(ciphers); } function syncSettings(self, userId, response) {