Update client for authService refactor (#448)

* Update for encrypted export support (to pass build only)
This commit is contained in:
Thomas Rittson 2022-02-08 09:31:36 +10:00 committed by GitHub
parent d938dc82df
commit 220afb98c6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 28 additions and 12 deletions

2
jslib

@ -1 +1 @@
Subproject commit e0cc754d6fe962a5e7eae6d1dead8b44606d4853
Subproject commit 6b8508579f89b4c54afa6aab2b7155aac70fb8a9

View File

@ -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();

View File

@ -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<Response> {
async run(
format: ImportType,
filepath: string,
options: program.OptionValues
): Promise<Response> {
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 === "") {

View File

@ -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<void>
@ -48,6 +50,7 @@ export class LoginCommand extends BaseLoginCommand {
stateService,
cryptoService,
policyService,
twoFactorService,
"cli"
);
this.logout = this.logoutCallback;

View File

@ -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()

View File

@ -5,6 +5,7 @@
"target": "ES2016",
"module": "es6",
"noImplicitAny": true,
"allowSyntheticDefaultImports": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"allowJs": true,