migrate constants to jslib

This commit is contained in:
Kyle Spearrin 2018-01-09 22:22:49 -05:00
parent 0069c2b700
commit f20c217321
6 changed files with 9 additions and 122 deletions

View File

@ -1,7 +1,8 @@
import ConstantsService from '../services/constants.service';
import LockService from '../services/lock.service'; import LockService from '../services/lock.service';
import MainBackground from './main.background'; import MainBackground from './main.background';
import { ConstantsService } from 'jslib/services';
import { StorageService } from 'jslib/abstractions'; import { StorageService } from 'jslib/abstractions';
export default class IdleBackground { export default class IdleBackground {

View File

@ -3,6 +3,7 @@ import { CipherType } from 'jslib/enums';
import { import {
ApiService, ApiService,
AppIdService, AppIdService,
ConstantsService,
CryptoService, CryptoService,
EnvironmentService, EnvironmentService,
PasswordGenerationService, PasswordGenerationService,
@ -43,7 +44,6 @@ import BrowserPlatformUtilsService from '../services/browserPlatformUtils.servic
import BrowserStorageService from '../services/browserStorage.service'; import BrowserStorageService from '../services/browserStorage.service';
import CipherService from '../services/cipher.service'; import CipherService from '../services/cipher.service';
import CollectionService from '../services/collection.service'; import CollectionService from '../services/collection.service';
import ConstantsService from '../services/constants.service';
import ContainerService from '../services/container.service'; import ContainerService from '../services/container.service';
import FolderService from '../services/folder.service'; import FolderService from '../services/folder.service';
import i18nService from '../services/i18n.service'; import i18nService from '../services/i18n.service';

View File

@ -2,13 +2,13 @@ import * as angular from 'angular';
import { DeviceType } from 'jslib/enums/deviceType'; import { DeviceType } from 'jslib/enums/deviceType';
import { ConstantsService } from 'jslib/services/constants.service';
import { CryptoService } from 'jslib/abstractions/crypto.service'; import { CryptoService } from 'jslib/abstractions/crypto.service';
import { MessagingService } from 'jslib/abstractions/messaging.service'; import { MessagingService } from 'jslib/abstractions/messaging.service';
import { PlatformUtilsService } from 'jslib/abstractions/platformUtils.service'; import { PlatformUtilsService } from 'jslib/abstractions/platformUtils.service';
import { StorageService } from 'jslib/abstractions/storage.service'; import { StorageService } from 'jslib/abstractions/storage.service';
import ConstantsService from '../../../services/constants.service';
import * as template from './settings.component.html'; import * as template from './settings.component.html';
const RateUrls = { const RateUrls = {

View File

@ -16,6 +16,8 @@ import {
ErrorResponse, ErrorResponse,
} from 'jslib/models/response'; } from 'jslib/models/response';
import { ConstantsService } from 'jslib/services';
import { import {
ApiService, ApiService,
CryptoService, CryptoService,
@ -23,7 +25,6 @@ import {
UserService, UserService,
} from 'jslib/abstractions'; } from 'jslib/abstractions';
import ConstantsService from './constants.service';
import SettingsService from './settings.service'; import SettingsService from './settings.service';
const Keys = { const Keys = {

View File

@ -1,116 +0,0 @@
import { PlatformUtilsService } from 'jslib/abstractions';
export default class ConstantsService {
static readonly environmentUrlsKey: string = 'environmentUrls';
static readonly disableGaKey: string = 'disableGa';
static readonly disableAddLoginNotificationKey: string = 'disableAddLoginNotification';
static readonly disableContextMenuItemKey: string = 'disableContextMenuItem';
static readonly disableFaviconKey: string = 'disableFavicon';
static readonly disableAutoTotpCopyKey: string = 'disableAutoTotpCopy';
static readonly enableAutoFillOnPageLoadKey: string = 'enableAutoFillOnPageLoad';
static readonly lockOptionKey: string = 'lockOption';
static readonly lastActiveKey: string = 'lastActive';
// TODO: remove these instance properties once all references are reading from the static properties
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';
// 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,
};
twoFactorProviderInfo: any[];
constructor(i18nService: any, platformUtilsService: PlatformUtilsService) {
if (platformUtilsService.isEdge()) {
// delay for i18n fetch
setTimeout(() => {
this.bootstrap(i18nService);
}, 1000);
} else {
this.bootstrap(i18nService);
}
}
private bootstrap(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,
},
];
}
}

View File

@ -1,8 +1,9 @@
import CipherService from './cipher.service'; import CipherService from './cipher.service';
import CollectionService from './collection.service'; import CollectionService from './collection.service';
import ConstantsService from './constants.service';
import FolderService from './folder.service'; import FolderService from './folder.service';
import { ConstantsService } from 'jslib/services';
import { import {
CryptoService, CryptoService,
PlatformUtilsService, PlatformUtilsService,