diff --git a/jslib b/jslib index e0cc754d6f..6b8508579f 160000 --- a/jslib +++ b/jslib @@ -1 +1 @@ -Subproject commit e0cc754d6fe962a5e7eae6d1dead8b44606d4853 +Subproject commit 6b8508579f89b4c54afa6aab2b7155aac70fb8a9 diff --git a/src/bw.ts b/src/bw.ts index da3f4088ff..4cd4b58d5e 100644 --- a/src/bw.ts +++ b/src/bw.ts @@ -39,6 +39,7 @@ import { StateMigrationService } from "jslib-common/services/stateMigration.serv import { SyncService } from "jslib-common/services/sync.service"; import { TokenService } from "jslib-common/services/token.service"; import { TotpService } from "jslib-common/services/totp.service"; +import { TwoFactorService } from "jslib-common/services/twoFactor.service"; import { UserVerificationService } from "jslib-common/services/userVerification.service"; import { VaultTimeoutService } from "jslib-common/services/vaultTimeout.service"; @@ -52,6 +53,7 @@ import { VaultProgram } from "./vault.program"; import { Account } from "jslib-common/models/domain/account"; import { GlobalState } from "jslib-common/models/domain/globalState"; +import { ApiLogInCredentials } from "jslib-common/models/domain/logInCredentials"; import { StateFactory } from "jslib-common/factories/stateFactory"; @@ -100,6 +102,7 @@ export class Main { stateMigrationService: StateMigrationService; organizationService: OrganizationService; providerService: ProviderService; + twoFactorService: TwoFactorService; constructor() { let p = null; @@ -167,7 +170,8 @@ export class Main { " (" + this.platformUtilsService.getDeviceString().toUpperCase() + ")", - (clientId, clientSecret) => this.authService.logInApiKey(clientId, clientSecret) + (clientId, clientSecret) => + this.authService.logIn(new ApiLogInCredentials(clientId, clientSecret)) ); this.containerService = new ContainerService(this.cryptoService); @@ -227,7 +231,8 @@ export class Main { this.apiService, this.tokenService, this.logService, - this.organizationService + this.organizationService, + this.cryptoFunctionService ); this.vaultTimeoutService = new VaultTimeoutService( @@ -289,24 +294,24 @@ export class Main { this.folderService, this.cipherService, this.apiService, - this.cryptoService + this.cryptoService, + this.cryptoFunctionService ); + this.twoFactorService = new TwoFactorService(this.i18nService, this.platformUtilsService); + this.authService = new AuthService( this.cryptoService, this.apiService, this.tokenService, this.appIdService, - this.i18nService, this.platformUtilsService, this.messagingService, - this.vaultTimeoutService, this.logService, - this.cryptoFunctionService, this.keyConnectorService, this.environmentService, this.stateService, - true + this.twoFactorService ); this.auditService = new AuditService(this.cryptoFunctionService, this.apiService); @@ -361,7 +366,7 @@ export class Main { await this.environmentService.setUrlsFromStorage(); const locale = await this.stateService.getLocale(); await this.i18nService.init(locale); - this.authService.init(); + this.twoFactorService.init(); const installedVersion = await this.stateService.getInstalledVersion(); const currentVersion = await this.platformUtilsService.getApplicationVersion(); diff --git a/src/commands/import.command.ts b/src/commands/import.command.ts index 727a64b041..f5e84c9b05 100644 --- a/src/commands/import.command.ts +++ b/src/commands/import.command.ts @@ -2,6 +2,8 @@ import * as program from "commander"; import { ImportService } from "jslib-common/abstractions/import.service"; import { OrganizationService } from "jslib-common/abstractions/organization.service"; +import { ImportType } from "jslib-common/services/import.service"; + import { Response } from "jslib-node/cli/models/response"; import { MessageResponse } from "jslib-node/cli/models/response/messageResponse"; @@ -13,7 +15,11 @@ export class ImportCommand { private organizationService: OrganizationService ) {} - async run(format: string, filepath: string, options: program.OptionValues): Promise { + async run( + format: ImportType, + filepath: string, + options: program.OptionValues + ): Promise { const organizationId = options.organizationid; if (organizationId != null) { const organization = await this.organizationService.get(organizationId); @@ -38,8 +44,8 @@ export class ImportCommand { } } - private async import(format: string, filepath: string, organizationId: string) { - if (format == null || format === "") { + private async import(format: ImportType, filepath: string, organizationId: string) { + if (format == null) { return Response.badRequest("`format` was not provided."); } if (filepath == null || filepath === "") { diff --git a/src/commands/login.command.ts b/src/commands/login.command.ts index 6a4571f22a..56280518ae 100644 --- a/src/commands/login.command.ts +++ b/src/commands/login.command.ts @@ -12,6 +12,7 @@ import { PlatformUtilsService } from "jslib-common/abstractions/platformUtils.se import { PolicyService } from "jslib-common/abstractions/policy.service"; import { StateService } from "jslib-common/abstractions/state.service"; import { SyncService } from "jslib-common/abstractions/sync.service"; +import { TwoFactorService } from "jslib-common/abstractions/twoFactor.service"; import { MessageResponse } from "jslib-node/cli/models/response/messageResponse"; @@ -33,6 +34,7 @@ export class LoginCommand extends BaseLoginCommand { stateService: StateService, cryptoService: CryptoService, policyService: PolicyService, + twoFactorService: TwoFactorService, private syncService: SyncService, private keyConnectorService: KeyConnectorService, private logoutCallback: () => Promise @@ -48,6 +50,7 @@ export class LoginCommand extends BaseLoginCommand { stateService, cryptoService, policyService, + twoFactorService, "cli" ); this.logout = this.logoutCallback; diff --git a/src/program.ts b/src/program.ts index 2fc43fad77..1ff242723d 100644 --- a/src/program.ts +++ b/src/program.ts @@ -156,6 +156,7 @@ export class Program extends BaseProgram { this.main.stateService, this.main.cryptoService, this.main.policyService, + this.main.twoFactorService, this.main.syncService, this.main.keyConnectorService, async () => await this.main.logout() diff --git a/tsconfig.json b/tsconfig.json index 462ad45236..158679b493 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -5,6 +5,7 @@ "target": "ES2016", "module": "es6", "noImplicitAny": true, + "allowSyntheticDefaultImports": true, "emitDecoratorMetadata": true, "experimentalDecorators": true, "allowJs": true,