diff --git a/src/background.html b/src/background.html index 4e0713875ad..118292fa31c 100644 --- a/src/background.html +++ b/src/background.html @@ -5,11 +5,7 @@ - - - - diff --git a/src/background.js b/src/background.js index dff97168b30..3b65a8230c3 100644 --- a/src/background.js +++ b/src/background.js @@ -1,4 +1,6 @@ // Service imports +import ConstantsService from './services/constants.service'; +import i18nService from './services/i18nService.js'; import LockService from './services/lockService.js'; import UtilsService from './services/utils.service'; diff --git a/src/services/constants.service.ts b/src/services/constants.service.ts new file mode 100644 index 00000000000..51b8b3ef304 --- /dev/null +++ b/src/services/constants.service.ts @@ -0,0 +1,94 @@ +export default class ConstantsService { + // TODO: these should probably all be made static + readonly environmentUrlsKey: string = 'environmentUrls'; + readonly disableGaKey: string = 'disableGa'; + readonly disableAddLoginNotificationKey: string = 'disableAddLoginNotification'; + readonly disableContextMenuItemKey: string = 'disableContextMenuItem'; + readonly disableFaviconKey: string = 'disableFavicon'; + readonly disableAutoTotpCopyKey: string = 'disableAutoTotpCopy'; + readonly enableAutoFillOnPageLoadKey: string = 'enableAutoFillOnPageLoad'; + readonly lockOptionKey: string = 'lockOption'; + readonly lastActiveKey: string = 'lastActive'; + readonly generatedPasswordHistoryKey: string = 'generatedPasswordHistory'; + + // TODO: Convert these objects to enums + readonly encType: any = { + AesCbc256_B64: 0, + AesCbc128_HmacSha256_B64: 1, + AesCbc256_HmacSha256_B64: 2, + Rsa2048_OaepSha256_B64: 3, + Rsa2048_OaepSha1_B64: 4, + Rsa2048_OaepSha256_HmacSha256_B64: 5, + Rsa2048_OaepSha1_HmacSha256_B64: 6, + }; + + readonly cipherType: any = { + login: 1, + secureNote: 2, + card: 3, + identity: 4, + }; + + readonly fieldType: any = { + text: 0, + hidden: 1, + boolean: 2, + }; + + readonly twoFactorProvider: any = { + u2f: 4, + yubikey: 3, + duo: 2, + authenticator: 0, + email: 1, + remember: 5, + }; + + readonly twoFactorProviderInfo: any[]; + + constructor(i18nService: any) { + this.twoFactorProviderInfo = [ + { + type: 0, + name: i18nService.authenticatorAppTitle, + description: i18nService.authenticatorAppDesc, + active: true, + free: true, + displayOrder: 0, + priority: 1, + }, + { + type: 3, + name: i18nService.yubiKeyTitle, + description: i18nService.yubiKeyDesc, + active: true, + displayOrder: 1, + priority: 3, + }, + { + type: 2, + name: 'Duo', + description: i18nService.duoDesc, + active: true, + displayOrder: 2, + priority: 2, + }, + { + type: 4, + name: i18nService.u2fTitle, + description: i18nService.u2fDesc, + active: true, + displayOrder: 3, + priority: 4, + }, + { + type: 1, + name: i18nService.emailTitle, + description: i18nService.emailDesc, + active: true, + displayOrder: 4, + priority: 0, + }, + ]; + } +} diff --git a/src/services/constantsService.js b/src/services/constantsService.js deleted file mode 100644 index fc2296b2906..00000000000 --- a/src/services/constantsService.js +++ /dev/null @@ -1,85 +0,0 @@ -function ConstantsService(i18nService) { - return { - environmentUrlsKey: 'environmentUrls', - disableGaKey: 'disableGa', - disableAddLoginNotificationKey: 'disableAddLoginNotification', - disableContextMenuItemKey: 'disableContextMenuItem', - disableFaviconKey: 'disableFavicon', - disableAutoTotpCopyKey: 'disableAutoTotpCopy', - enableAutoFillOnPageLoadKey: 'enableAutoFillOnPageLoad', - lockOptionKey: 'lockOption', - lastActiveKey: 'lastActive', - generatedPasswordHistory: 'generatedPasswordHistory', - encType: { - AesCbc256_B64: 0, - AesCbc128_HmacSha256_B64: 1, - AesCbc256_HmacSha256_B64: 2, - Rsa2048_OaepSha256_B64: 3, - Rsa2048_OaepSha1_B64: 4, - Rsa2048_OaepSha256_HmacSha256_B64: 5, - Rsa2048_OaepSha1_HmacSha256_B64: 6 - }, - cipherType: { - login: 1, - secureNote: 2, - card: 3, - identity: 4 - }, - fieldType: { - text: 0, - hidden: 1, - boolean: 2 - }, - twoFactorProvider: { - u2f: 4, - yubikey: 3, - duo: 2, - authenticator: 0, - email: 1, - remember: 5 - }, - twoFactorProviderInfo: [ - { - type: 0, - name: i18nService.authenticatorAppTitle, - description: i18nService.authenticatorAppDesc, - active: true, - free: true, - displayOrder: 0, - priority: 1 - }, - { - type: 3, - name: i18nService.yubiKeyTitle, - description: i18nService.yubiKeyDesc, - active: true, - displayOrder: 1, - priority: 3 - }, - { - type: 2, - name: 'Duo', - description: i18nService.duoDesc, - active: true, - displayOrder: 2, - priority: 2 - }, - { - type: 4, - name: i18nService.u2fTitle, - description: i18nService.u2fDesc, - active: true, - displayOrder: 3, - priority: 4 - }, - { - type: 1, - name: i18nService.emailTitle, - description: i18nService.emailDesc, - active: true, - displayOrder: 4, - priority: 0 - } - ] - }; -} diff --git a/src/services/i18nService.js b/src/services/i18nService.js index 8571b82c2e0..7ffc90c8ace 100644 --- a/src/services/i18nService.js +++ b/src/services/i18nService.js @@ -1,4 +1,4 @@ -function i18nService(utilsService) { +export default function i18nService(utilsService) { this.utilsService = utilsService; this.messages = {};