[refactor(Account Switching)] Implement StateService (#424)
This commit is contained in:
parent
eb122532bd
commit
179f1dfe5d
2
jslib
2
jslib
|
@ -1 +1 @@
|
||||||
Subproject commit 8fc3cf50d2967212ffbbf0d57cac71d0774aa2a8
|
Subproject commit d68c1dafaf0528f5323dd595773b0fa122403d0d
|
132
src/bw.ts
132
src/bw.ts
|
@ -3,6 +3,7 @@ import * as fs from "fs";
|
||||||
import * as jsdom from "jsdom";
|
import * as jsdom from "jsdom";
|
||||||
import * as path from "path";
|
import * as path from "path";
|
||||||
|
|
||||||
|
import { KeySuffixOptions } from "jslib-common/enums/keySuffixOptions";
|
||||||
import { LogLevelType } from "jslib-common/enums/logLevelType";
|
import { LogLevelType } from "jslib-common/enums/logLevelType";
|
||||||
|
|
||||||
import { AuthService } from "jslib-common/services/auth.service";
|
import { AuthService } from "jslib-common/services/auth.service";
|
||||||
|
@ -17,7 +18,6 @@ import { AppIdService } from "jslib-common/services/appId.service";
|
||||||
import { AuditService } from "jslib-common/services/audit.service";
|
import { AuditService } from "jslib-common/services/audit.service";
|
||||||
import { CipherService } from "jslib-common/services/cipher.service";
|
import { CipherService } from "jslib-common/services/cipher.service";
|
||||||
import { CollectionService } from "jslib-common/services/collection.service";
|
import { CollectionService } from "jslib-common/services/collection.service";
|
||||||
import { ConstantsService } from "jslib-common/services/constants.service";
|
|
||||||
import { ContainerService } from "jslib-common/services/container.service";
|
import { ContainerService } from "jslib-common/services/container.service";
|
||||||
import { CryptoService } from "jslib-common/services/crypto.service";
|
import { CryptoService } from "jslib-common/services/crypto.service";
|
||||||
import { EnvironmentService } from "jslib-common/services/environment.service";
|
import { EnvironmentService } from "jslib-common/services/environment.service";
|
||||||
|
@ -27,17 +27,21 @@ import { FolderService } from "jslib-common/services/folder.service";
|
||||||
import { ImportService } from "jslib-common/services/import.service";
|
import { ImportService } from "jslib-common/services/import.service";
|
||||||
import { KeyConnectorService } from "jslib-common/services/keyConnector.service";
|
import { KeyConnectorService } from "jslib-common/services/keyConnector.service";
|
||||||
import { NoopMessagingService } from "jslib-common/services/noopMessaging.service";
|
import { NoopMessagingService } from "jslib-common/services/noopMessaging.service";
|
||||||
|
import { OrganizationService } from "jslib-common/services/organization.service";
|
||||||
import { PasswordGenerationService } from "jslib-common/services/passwordGeneration.service";
|
import { PasswordGenerationService } from "jslib-common/services/passwordGeneration.service";
|
||||||
import { PolicyService } from "jslib-common/services/policy.service";
|
import { PolicyService } from "jslib-common/services/policy.service";
|
||||||
|
import { ProviderService } from "jslib-common/services/provider.service";
|
||||||
import { SearchService } from "jslib-common/services/search.service";
|
import { SearchService } from "jslib-common/services/search.service";
|
||||||
import { SendService } from "jslib-common/services/send.service";
|
import { SendService } from "jslib-common/services/send.service";
|
||||||
import { SettingsService } from "jslib-common/services/settings.service";
|
import { SettingsService } from "jslib-common/services/settings.service";
|
||||||
|
import { StateService } from "jslib-common/services/state.service";
|
||||||
|
import { StateMigrationService } from "jslib-common/services/stateMigration.service";
|
||||||
import { SyncService } from "jslib-common/services/sync.service";
|
import { SyncService } from "jslib-common/services/sync.service";
|
||||||
import { TokenService } from "jslib-common/services/token.service";
|
import { TokenService } from "jslib-common/services/token.service";
|
||||||
import { TotpService } from "jslib-common/services/totp.service";
|
import { TotpService } from "jslib-common/services/totp.service";
|
||||||
import { UserService } from "jslib-common/services/user.service";
|
|
||||||
import { UserVerificationService } from "jslib-common/services/userVerification.service";
|
import { UserVerificationService } from "jslib-common/services/userVerification.service";
|
||||||
import { VaultTimeoutService } from "jslib-common/services/vaultTimeout.service";
|
import { VaultTimeoutService } from "jslib-common/services/vaultTimeout.service";
|
||||||
|
|
||||||
import { LowdbStorageService } from "jslib-node/services/lowdbStorage.service";
|
import { LowdbStorageService } from "jslib-node/services/lowdbStorage.service";
|
||||||
import { NodeApiService } from "jslib-node/services/nodeApi.service";
|
import { NodeApiService } from "jslib-node/services/nodeApi.service";
|
||||||
import { NodeCryptoFunctionService } from "jslib-node/services/nodeCryptoFunction.service";
|
import { NodeCryptoFunctionService } from "jslib-node/services/nodeCryptoFunction.service";
|
||||||
|
@ -58,13 +62,11 @@ export class Main {
|
||||||
secureStorageService: NodeEnvSecureStorageService;
|
secureStorageService: NodeEnvSecureStorageService;
|
||||||
i18nService: I18nService;
|
i18nService: I18nService;
|
||||||
platformUtilsService: CliPlatformUtilsService;
|
platformUtilsService: CliPlatformUtilsService;
|
||||||
constantsService: ConstantsService;
|
|
||||||
cryptoService: CryptoService;
|
cryptoService: CryptoService;
|
||||||
tokenService: TokenService;
|
tokenService: TokenService;
|
||||||
appIdService: AppIdService;
|
appIdService: AppIdService;
|
||||||
apiService: NodeApiService;
|
apiService: NodeApiService;
|
||||||
environmentService: EnvironmentService;
|
environmentService: EnvironmentService;
|
||||||
userService: UserService;
|
|
||||||
settingsService: SettingsService;
|
settingsService: SettingsService;
|
||||||
cipherService: CipherService;
|
cipherService: CipherService;
|
||||||
folderService: FolderService;
|
folderService: FolderService;
|
||||||
|
@ -89,6 +91,10 @@ export class Main {
|
||||||
fileUploadService: FileUploadService;
|
fileUploadService: FileUploadService;
|
||||||
keyConnectorService: KeyConnectorService;
|
keyConnectorService: KeyConnectorService;
|
||||||
userVerificationService: UserVerificationService;
|
userVerificationService: UserVerificationService;
|
||||||
|
stateService: StateService;
|
||||||
|
stateMigrationService: StateMigrationService;
|
||||||
|
organizationService: OrganizationService;
|
||||||
|
providerService: ProviderService;
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
let p = null;
|
let p = null;
|
||||||
|
@ -120,17 +126,30 @@ export class Main {
|
||||||
this.logService,
|
this.logService,
|
||||||
() => this.cryptoService
|
() => this.cryptoService
|
||||||
);
|
);
|
||||||
this.cryptoService = new CryptoService(
|
|
||||||
|
this.stateMigrationService = new StateMigrationService(
|
||||||
|
this.storageService,
|
||||||
|
this.secureStorageService
|
||||||
|
);
|
||||||
|
|
||||||
|
this.stateService = new StateService(
|
||||||
this.storageService,
|
this.storageService,
|
||||||
this.secureStorageService,
|
this.secureStorageService,
|
||||||
|
this.logService,
|
||||||
|
this.stateMigrationService
|
||||||
|
);
|
||||||
|
|
||||||
|
this.cryptoService = new CryptoService(
|
||||||
this.cryptoFunctionService,
|
this.cryptoFunctionService,
|
||||||
this.platformUtilsService,
|
this.platformUtilsService,
|
||||||
this.logService
|
this.logService,
|
||||||
|
this.stateService
|
||||||
);
|
);
|
||||||
|
|
||||||
this.appIdService = new AppIdService(this.storageService);
|
this.appIdService = new AppIdService(this.storageService);
|
||||||
this.tokenService = new TokenService(this.storageService);
|
this.tokenService = new TokenService(this.stateService);
|
||||||
this.messagingService = new NoopMessagingService();
|
this.messagingService = new NoopMessagingService();
|
||||||
this.environmentService = new EnvironmentService(this.storageService);
|
this.environmentService = new EnvironmentService(this.stateService);
|
||||||
this.apiService = new NodeApiService(
|
this.apiService = new NodeApiService(
|
||||||
this.tokenService,
|
this.tokenService,
|
||||||
this.platformUtilsService,
|
this.platformUtilsService,
|
||||||
|
@ -143,97 +162,113 @@ export class Main {
|
||||||
")",
|
")",
|
||||||
(clientId, clientSecret) => this.authService.logInApiKey(clientId, clientSecret)
|
(clientId, clientSecret) => this.authService.logInApiKey(clientId, clientSecret)
|
||||||
);
|
);
|
||||||
this.userService = new UserService(this.tokenService, this.storageService);
|
|
||||||
this.containerService = new ContainerService(this.cryptoService);
|
this.containerService = new ContainerService(this.cryptoService);
|
||||||
this.settingsService = new SettingsService(this.userService, this.storageService);
|
|
||||||
|
this.settingsService = new SettingsService(this.stateService);
|
||||||
|
|
||||||
this.fileUploadService = new FileUploadService(this.logService, this.apiService);
|
this.fileUploadService = new FileUploadService(this.logService, this.apiService);
|
||||||
|
|
||||||
this.cipherService = new CipherService(
|
this.cipherService = new CipherService(
|
||||||
this.cryptoService,
|
this.cryptoService,
|
||||||
this.userService,
|
|
||||||
this.settingsService,
|
this.settingsService,
|
||||||
this.apiService,
|
this.apiService,
|
||||||
this.fileUploadService,
|
this.fileUploadService,
|
||||||
this.storageService,
|
|
||||||
this.i18nService,
|
this.i18nService,
|
||||||
null,
|
null,
|
||||||
this.logService
|
this.logService,
|
||||||
|
this.stateService
|
||||||
);
|
);
|
||||||
|
|
||||||
this.folderService = new FolderService(
|
this.folderService = new FolderService(
|
||||||
this.cryptoService,
|
this.cryptoService,
|
||||||
this.userService,
|
|
||||||
this.apiService,
|
this.apiService,
|
||||||
this.storageService,
|
|
||||||
this.i18nService,
|
this.i18nService,
|
||||||
this.cipherService
|
this.cipherService,
|
||||||
|
this.stateService
|
||||||
);
|
);
|
||||||
|
|
||||||
this.collectionService = new CollectionService(
|
this.collectionService = new CollectionService(
|
||||||
this.cryptoService,
|
this.cryptoService,
|
||||||
this.userService,
|
this.i18nService,
|
||||||
this.storageService,
|
this.stateService
|
||||||
this.i18nService
|
|
||||||
);
|
);
|
||||||
|
|
||||||
this.searchService = new SearchService(this.cipherService, this.logService, this.i18nService);
|
this.searchService = new SearchService(this.cipherService, this.logService, this.i18nService);
|
||||||
this.policyService = new PolicyService(this.userService, this.storageService, this.apiService);
|
|
||||||
|
this.providerService = new ProviderService(this.stateService);
|
||||||
|
|
||||||
|
this.organizationService = new OrganizationService(this.stateService);
|
||||||
|
|
||||||
|
this.policyService = new PolicyService(
|
||||||
|
this.stateService,
|
||||||
|
this.organizationService,
|
||||||
|
this.apiService
|
||||||
|
);
|
||||||
|
|
||||||
this.sendService = new SendService(
|
this.sendService = new SendService(
|
||||||
this.cryptoService,
|
this.cryptoService,
|
||||||
this.userService,
|
|
||||||
this.apiService,
|
this.apiService,
|
||||||
this.fileUploadService,
|
this.fileUploadService,
|
||||||
this.storageService,
|
|
||||||
this.i18nService,
|
this.i18nService,
|
||||||
this.cryptoFunctionService
|
this.cryptoFunctionService,
|
||||||
|
this.stateService
|
||||||
);
|
);
|
||||||
|
|
||||||
this.keyConnectorService = new KeyConnectorService(
|
this.keyConnectorService = new KeyConnectorService(
|
||||||
this.storageService,
|
this.stateService,
|
||||||
this.userService,
|
|
||||||
this.cryptoService,
|
this.cryptoService,
|
||||||
this.apiService,
|
this.apiService,
|
||||||
this.tokenService,
|
this.tokenService,
|
||||||
this.logService
|
this.logService,
|
||||||
|
this.organizationService
|
||||||
);
|
);
|
||||||
|
|
||||||
this.vaultTimeoutService = new VaultTimeoutService(
|
this.vaultTimeoutService = new VaultTimeoutService(
|
||||||
this.cipherService,
|
this.cipherService,
|
||||||
this.folderService,
|
this.folderService,
|
||||||
this.collectionService,
|
this.collectionService,
|
||||||
this.cryptoService,
|
this.cryptoService,
|
||||||
this.platformUtilsService,
|
this.platformUtilsService,
|
||||||
this.storageService,
|
|
||||||
this.messagingService,
|
this.messagingService,
|
||||||
this.searchService,
|
this.searchService,
|
||||||
this.userService,
|
|
||||||
this.tokenService,
|
this.tokenService,
|
||||||
this.policyService,
|
this.policyService,
|
||||||
this.keyConnectorService,
|
this.keyConnectorService,
|
||||||
async () => await this.cryptoService.clearStoredKey("auto"),
|
this.stateService,
|
||||||
|
async () => await this.cryptoService.clearStoredKey(KeySuffixOptions.Auto),
|
||||||
null
|
null
|
||||||
);
|
);
|
||||||
|
|
||||||
this.syncService = new SyncService(
|
this.syncService = new SyncService(
|
||||||
this.userService,
|
|
||||||
this.apiService,
|
this.apiService,
|
||||||
this.settingsService,
|
this.settingsService,
|
||||||
this.folderService,
|
this.folderService,
|
||||||
this.cipherService,
|
this.cipherService,
|
||||||
this.cryptoService,
|
this.cryptoService,
|
||||||
this.collectionService,
|
this.collectionService,
|
||||||
this.storageService,
|
|
||||||
this.messagingService,
|
this.messagingService,
|
||||||
this.policyService,
|
this.policyService,
|
||||||
this.sendService,
|
this.sendService,
|
||||||
this.logService,
|
this.logService,
|
||||||
this.tokenService,
|
|
||||||
this.keyConnectorService,
|
this.keyConnectorService,
|
||||||
|
this.stateService,
|
||||||
|
this.organizationService,
|
||||||
|
this.providerService,
|
||||||
async (expired: boolean) => await this.logout()
|
async (expired: boolean) => await this.logout()
|
||||||
);
|
);
|
||||||
|
|
||||||
this.passwordGenerationService = new PasswordGenerationService(
|
this.passwordGenerationService = new PasswordGenerationService(
|
||||||
this.cryptoService,
|
this.cryptoService,
|
||||||
this.storageService,
|
this.policyService,
|
||||||
this.policyService
|
this.stateService
|
||||||
);
|
);
|
||||||
|
|
||||||
this.totpService = new TotpService(
|
this.totpService = new TotpService(
|
||||||
this.storageService,
|
|
||||||
this.cryptoFunctionService,
|
this.cryptoFunctionService,
|
||||||
this.logService
|
this.logService,
|
||||||
|
this.stateService
|
||||||
);
|
);
|
||||||
|
|
||||||
this.importService = new ImportService(
|
this.importService = new ImportService(
|
||||||
this.cipherService,
|
this.cipherService,
|
||||||
this.folderService,
|
this.folderService,
|
||||||
|
@ -249,10 +284,10 @@ export class Main {
|
||||||
this.apiService,
|
this.apiService,
|
||||||
this.cryptoService
|
this.cryptoService
|
||||||
);
|
);
|
||||||
|
|
||||||
this.authService = new AuthService(
|
this.authService = new AuthService(
|
||||||
this.cryptoService,
|
this.cryptoService,
|
||||||
this.apiService,
|
this.apiService,
|
||||||
this.userService,
|
|
||||||
this.tokenService,
|
this.tokenService,
|
||||||
this.appIdService,
|
this.appIdService,
|
||||||
this.i18nService,
|
this.i18nService,
|
||||||
|
@ -261,10 +296,12 @@ export class Main {
|
||||||
this.vaultTimeoutService,
|
this.vaultTimeoutService,
|
||||||
this.logService,
|
this.logService,
|
||||||
this.cryptoFunctionService,
|
this.cryptoFunctionService,
|
||||||
this.environmentService,
|
|
||||||
this.keyConnectorService,
|
this.keyConnectorService,
|
||||||
|
this.environmentService,
|
||||||
|
this.stateService,
|
||||||
true
|
true
|
||||||
);
|
);
|
||||||
|
|
||||||
this.auditService = new AuditService(this.cryptoFunctionService, this.apiService);
|
this.auditService = new AuditService(this.cryptoFunctionService, this.apiService);
|
||||||
this.program = new Program(this);
|
this.program = new Program(this);
|
||||||
this.vaultProgram = new VaultProgram(this);
|
this.vaultProgram = new VaultProgram(this);
|
||||||
|
@ -291,12 +328,11 @@ export class Main {
|
||||||
}
|
}
|
||||||
|
|
||||||
async logout() {
|
async logout() {
|
||||||
const userId = await this.userService.getUserId();
|
const userId = await this.stateService.getUserId();
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
this.syncService.setLastSync(new Date(0)),
|
this.syncService.setLastSync(new Date(0)),
|
||||||
this.tokenService.clearToken(),
|
this.tokenService.clearToken(),
|
||||||
this.cryptoService.clearKeys(),
|
this.cryptoService.clearKeys(),
|
||||||
this.userService.clear(),
|
|
||||||
this.settingsService.clear(userId),
|
this.settingsService.clear(userId),
|
||||||
this.cipherService.clear(userId),
|
this.cipherService.clear(userId),
|
||||||
this.folderService.clear(userId),
|
this.folderService.clear(userId),
|
||||||
|
@ -304,29 +340,23 @@ export class Main {
|
||||||
this.policyService.clear(userId),
|
this.policyService.clear(userId),
|
||||||
this.passwordGenerationService.clear(),
|
this.passwordGenerationService.clear(),
|
||||||
]);
|
]);
|
||||||
|
await this.stateService.clean();
|
||||||
process.env.BW_SESSION = null;
|
process.env.BW_SESSION = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private async init() {
|
private async init() {
|
||||||
await this.storageService.init();
|
await this.storageService.init();
|
||||||
|
await this.stateService.init();
|
||||||
this.containerService.attachToWindow(global);
|
this.containerService.attachToWindow(global);
|
||||||
await this.environmentService.setUrlsFromStorage();
|
await this.environmentService.setUrlsFromStorage();
|
||||||
// Dev Server URLs. Comment out the line above.
|
const locale = await this.stateService.getLocale();
|
||||||
// this.apiService.setUrls({
|
|
||||||
// base: null,
|
|
||||||
// api: 'http://localhost:4000',
|
|
||||||
// identity: 'http://localhost:33656',
|
|
||||||
// });
|
|
||||||
const locale = await this.storageService.get<string>(ConstantsService.localeKey);
|
|
||||||
await this.i18nService.init(locale);
|
await this.i18nService.init(locale);
|
||||||
this.authService.init();
|
this.authService.init();
|
||||||
|
|
||||||
const installedVersion = await this.storageService.get<string>(
|
const installedVersion = await this.stateService.getInstalledVersion();
|
||||||
ConstantsService.installedVersionKey
|
|
||||||
);
|
|
||||||
const currentVersion = await this.platformUtilsService.getApplicationVersion();
|
const currentVersion = await this.platformUtilsService.getApplicationVersion();
|
||||||
if (installedVersion == null || installedVersion !== currentVersion) {
|
if (installedVersion == null || installedVersion !== currentVersion) {
|
||||||
await this.storageService.save(ConstantsService.installedVersionKey, currentVersion);
|
await this.stateService.setInstalledVersion(currentVersion);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,7 @@ import { ApiService } from "jslib-common/abstractions/api.service";
|
||||||
import { CipherService } from "jslib-common/abstractions/cipher.service";
|
import { CipherService } from "jslib-common/abstractions/cipher.service";
|
||||||
import { CryptoService } from "jslib-common/abstractions/crypto.service";
|
import { CryptoService } from "jslib-common/abstractions/crypto.service";
|
||||||
import { FolderService } from "jslib-common/abstractions/folder.service";
|
import { FolderService } from "jslib-common/abstractions/folder.service";
|
||||||
import { UserService } from "jslib-common/abstractions/user.service";
|
import { StateService } from "jslib-common/abstractions/state.service";
|
||||||
|
|
||||||
import { Cipher } from "jslib-common/models/export/cipher";
|
import { Cipher } from "jslib-common/models/export/cipher";
|
||||||
import { Collection } from "jslib-common/models/export/collection";
|
import { Collection } from "jslib-common/models/export/collection";
|
||||||
|
@ -31,7 +31,7 @@ export class CreateCommand {
|
||||||
constructor(
|
constructor(
|
||||||
private cipherService: CipherService,
|
private cipherService: CipherService,
|
||||||
private folderService: FolderService,
|
private folderService: FolderService,
|
||||||
private userService: UserService,
|
private stateService: StateService,
|
||||||
private cryptoService: CryptoService,
|
private cryptoService: CryptoService,
|
||||||
private apiService: ApiService
|
private apiService: ApiService
|
||||||
) {}
|
) {}
|
||||||
|
@ -100,7 +100,7 @@ export class CreateCommand {
|
||||||
return Response.notFound();
|
return Response.notFound();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cipher.organizationId == null && !(await this.userService.canAccessPremium())) {
|
if (cipher.organizationId == null && !(await this.stateService.getCanAccessPremium())) {
|
||||||
return Response.error("Premium status is required to use this feature.");
|
return Response.error("Premium status is required to use this feature.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@ import * as program from "commander";
|
||||||
import { ApiService } from "jslib-common/abstractions/api.service";
|
import { ApiService } from "jslib-common/abstractions/api.service";
|
||||||
import { CipherService } from "jslib-common/abstractions/cipher.service";
|
import { CipherService } from "jslib-common/abstractions/cipher.service";
|
||||||
import { FolderService } from "jslib-common/abstractions/folder.service";
|
import { FolderService } from "jslib-common/abstractions/folder.service";
|
||||||
import { UserService } from "jslib-common/abstractions/user.service";
|
import { StateService } from "jslib-common/abstractions/state.service";
|
||||||
|
|
||||||
import { Response } from "jslib-node/cli/models/response";
|
import { Response } from "jslib-node/cli/models/response";
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@ export class DeleteCommand {
|
||||||
constructor(
|
constructor(
|
||||||
private cipherService: CipherService,
|
private cipherService: CipherService,
|
||||||
private folderService: FolderService,
|
private folderService: FolderService,
|
||||||
private userService: UserService,
|
private stateService: StateService,
|
||||||
private apiService: ApiService
|
private apiService: ApiService
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
|
@ -74,7 +74,7 @@ export class DeleteCommand {
|
||||||
return Response.error("Attachment `" + id + "` was not found.");
|
return Response.error("Attachment `" + id + "` was not found.");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cipher.organizationId == null && !(await this.userService.canAccessPremium())) {
|
if (cipher.organizationId == null && !(await this.stateService.getCanAccessPremium())) {
|
||||||
return Response.error("Premium status is required to use this feature.");
|
return Response.error("Premium status is required to use this feature.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -112,9 +112,7 @@ export class ExportCommand {
|
||||||
|
|
||||||
private async verifyOTP() {
|
private async verifyOTP() {
|
||||||
await this.userVerificationService.requestOTP();
|
await this.userVerificationService.requestOTP();
|
||||||
const answer: inquirer.Answers = await inquirer.createPromptModule({
|
const answer: inquirer.Answers = await inquirer.createPromptModule({ output: process.stderr })({
|
||||||
output: process.stderr,
|
|
||||||
})({
|
|
||||||
type: "password",
|
type: "password",
|
||||||
name: "otp",
|
name: "otp",
|
||||||
message: "A verification code has been emailed to you.\n Verification code:",
|
message: "A verification code has been emailed to you.\n Verification code:",
|
||||||
|
|
|
@ -7,12 +7,11 @@ import { AuditService } from "jslib-common/abstractions/audit.service";
|
||||||
import { CipherService } from "jslib-common/abstractions/cipher.service";
|
import { CipherService } from "jslib-common/abstractions/cipher.service";
|
||||||
import { CollectionService } from "jslib-common/abstractions/collection.service";
|
import { CollectionService } from "jslib-common/abstractions/collection.service";
|
||||||
import { CryptoService } from "jslib-common/abstractions/crypto.service";
|
import { CryptoService } from "jslib-common/abstractions/crypto.service";
|
||||||
import { EnvironmentService } from "jslib-common/abstractions/environment.service";
|
|
||||||
import { FolderService } from "jslib-common/abstractions/folder.service";
|
import { FolderService } from "jslib-common/abstractions/folder.service";
|
||||||
|
import { OrganizationService } from "jslib-common/abstractions/organization.service";
|
||||||
import { SearchService } from "jslib-common/abstractions/search.service";
|
import { SearchService } from "jslib-common/abstractions/search.service";
|
||||||
import { SendService } from "jslib-common/abstractions/send.service";
|
import { StateService } from "jslib-common/abstractions/state.service";
|
||||||
import { TotpService } from "jslib-common/abstractions/totp.service";
|
import { TotpService } from "jslib-common/abstractions/totp.service";
|
||||||
import { UserService } from "jslib-common/abstractions/user.service";
|
|
||||||
|
|
||||||
import { Organization } from "jslib-common/models/domain/organization";
|
import { Organization } from "jslib-common/models/domain/organization";
|
||||||
|
|
||||||
|
@ -64,11 +63,10 @@ export class GetCommand extends DownloadCommand {
|
||||||
private totpService: TotpService,
|
private totpService: TotpService,
|
||||||
private auditService: AuditService,
|
private auditService: AuditService,
|
||||||
cryptoService: CryptoService,
|
cryptoService: CryptoService,
|
||||||
private userService: UserService,
|
private stateService: StateService,
|
||||||
private searchService: SearchService,
|
private searchService: SearchService,
|
||||||
private apiService: ApiService,
|
private apiService: ApiService,
|
||||||
private sendService: SendService,
|
private organizationService: OrganizationService
|
||||||
private environmentService: EnvironmentService
|
|
||||||
) {
|
) {
|
||||||
super(cryptoService);
|
super(cryptoService);
|
||||||
}
|
}
|
||||||
|
@ -250,7 +248,7 @@ export class GetCommand extends DownloadCommand {
|
||||||
return Response.error("Couldn't generate TOTP code.");
|
return Response.error("Couldn't generate TOTP code.");
|
||||||
}
|
}
|
||||||
|
|
||||||
const canAccessPremium = await this.userService.canAccessPremium();
|
const canAccessPremium = await this.stateService.getCanAccessPremium();
|
||||||
if (!canAccessPremium) {
|
if (!canAccessPremium) {
|
||||||
const originalCipher = await this.cipherService.get(cipher.id);
|
const originalCipher = await this.cipherService.get(cipher.id);
|
||||||
if (
|
if (
|
||||||
|
@ -333,7 +331,7 @@ export class GetCommand extends DownloadCommand {
|
||||||
return Response.multipleResults(attachments.map((a) => a.id));
|
return Response.multipleResults(attachments.map((a) => a.id));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(await this.userService.canAccessPremium())) {
|
if (!(await this.stateService.getCanAccessPremium())) {
|
||||||
const originalCipher = await this.cipherService.get(cipher.id);
|
const originalCipher = await this.cipherService.get(cipher.id);
|
||||||
if (originalCipher == null || originalCipher.organizationId == null) {
|
if (originalCipher == null || originalCipher.organizationId == null) {
|
||||||
return Response.error("Premium status is required to use this feature.");
|
return Response.error("Premium status is required to use this feature.");
|
||||||
|
@ -450,9 +448,9 @@ export class GetCommand extends DownloadCommand {
|
||||||
private async getOrganization(id: string) {
|
private async getOrganization(id: string) {
|
||||||
let org: Organization = null;
|
let org: Organization = null;
|
||||||
if (Utils.isGuid(id)) {
|
if (Utils.isGuid(id)) {
|
||||||
org = await this.userService.getOrganization(id);
|
org = await this.organizationService.get(id);
|
||||||
} else if (id.trim() !== "") {
|
} else if (id.trim() !== "") {
|
||||||
let orgs = await this.userService.getAllOrganizations();
|
let orgs = await this.organizationService.getAll();
|
||||||
orgs = CliUtils.searchOrganizations(orgs, id);
|
orgs = CliUtils.searchOrganizations(orgs, id);
|
||||||
if (orgs.length > 1) {
|
if (orgs.length > 1) {
|
||||||
return Response.multipleResults(orgs.map((c) => c.id));
|
return Response.multipleResults(orgs.map((c) => c.id));
|
||||||
|
@ -522,7 +520,7 @@ export class GetCommand extends DownloadCommand {
|
||||||
private async getFingerprint(id: string) {
|
private async getFingerprint(id: string) {
|
||||||
let fingerprint: string[] = null;
|
let fingerprint: string[] = null;
|
||||||
if (id === "me") {
|
if (id === "me") {
|
||||||
fingerprint = await this.cryptoService.getFingerprint(await this.userService.getUserId());
|
fingerprint = await this.cryptoService.getFingerprint(await this.stateService.getUserId());
|
||||||
} else if (Utils.isGuid(id)) {
|
} else if (Utils.isGuid(id)) {
|
||||||
try {
|
try {
|
||||||
const response = await this.apiService.getUserPublicKey(id);
|
const response = await this.apiService.getUserPublicKey(id);
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import * as program from "commander";
|
import * as program from "commander";
|
||||||
import { ImportService } from "jslib-common/abstractions/import.service";
|
import { ImportService } from "jslib-common/abstractions/import.service";
|
||||||
import { UserService } from "jslib-common/abstractions/user.service";
|
import { OrganizationService } from "jslib-common/abstractions/organization.service";
|
||||||
|
|
||||||
import { Response } from "jslib-node/cli/models/response";
|
import { Response } from "jslib-node/cli/models/response";
|
||||||
import { MessageResponse } from "jslib-node/cli/models/response/messageResponse";
|
import { MessageResponse } from "jslib-node/cli/models/response/messageResponse";
|
||||||
|
@ -8,12 +8,15 @@ import { MessageResponse } from "jslib-node/cli/models/response/messageResponse"
|
||||||
import { CliUtils } from "../utils";
|
import { CliUtils } from "../utils";
|
||||||
|
|
||||||
export class ImportCommand {
|
export class ImportCommand {
|
||||||
constructor(private importService: ImportService, private userService: UserService) {}
|
constructor(
|
||||||
|
private importService: ImportService,
|
||||||
|
private organizationService: OrganizationService
|
||||||
|
) {}
|
||||||
|
|
||||||
async run(format: string, filepath: string, options: program.OptionValues): Promise<Response> {
|
async run(format: string, filepath: string, options: program.OptionValues): Promise<Response> {
|
||||||
const organizationId = options.organizationid;
|
const organizationId = options.organizationid;
|
||||||
if (organizationId != null) {
|
if (organizationId != null) {
|
||||||
const organization = await this.userService.getOrganization(organizationId);
|
const organization = await this.organizationService.get(organizationId);
|
||||||
|
|
||||||
if (organization == null) {
|
if (organization == null) {
|
||||||
return Response.badRequest(
|
return Response.badRequest(
|
||||||
|
|
|
@ -6,8 +6,8 @@ import { ApiService } from "jslib-common/abstractions/api.service";
|
||||||
import { CipherService } from "jslib-common/abstractions/cipher.service";
|
import { CipherService } from "jslib-common/abstractions/cipher.service";
|
||||||
import { CollectionService } from "jslib-common/abstractions/collection.service";
|
import { CollectionService } from "jslib-common/abstractions/collection.service";
|
||||||
import { FolderService } from "jslib-common/abstractions/folder.service";
|
import { FolderService } from "jslib-common/abstractions/folder.service";
|
||||||
|
import { OrganizationService } from "jslib-common/abstractions/organization.service";
|
||||||
import { SearchService } from "jslib-common/abstractions/search.service";
|
import { SearchService } from "jslib-common/abstractions/search.service";
|
||||||
import { UserService } from "jslib-common/abstractions/user.service";
|
|
||||||
|
|
||||||
import {
|
import {
|
||||||
CollectionDetailsResponse as ApiCollectionDetailsResponse,
|
CollectionDetailsResponse as ApiCollectionDetailsResponse,
|
||||||
|
@ -37,7 +37,7 @@ export class ListCommand {
|
||||||
private cipherService: CipherService,
|
private cipherService: CipherService,
|
||||||
private folderService: FolderService,
|
private folderService: FolderService,
|
||||||
private collectionService: CollectionService,
|
private collectionService: CollectionService,
|
||||||
private userService: UserService,
|
private organizationService: OrganizationService,
|
||||||
private searchService: SearchService,
|
private searchService: SearchService,
|
||||||
private apiService: ApiService
|
private apiService: ApiService
|
||||||
) {}
|
) {}
|
||||||
|
@ -171,7 +171,7 @@ export class ListCommand {
|
||||||
if (!Utils.isGuid(options.organizationid)) {
|
if (!Utils.isGuid(options.organizationid)) {
|
||||||
return Response.error("`" + options.organizationid + "` is not a GUID.");
|
return Response.error("`" + options.organizationid + "` is not a GUID.");
|
||||||
}
|
}
|
||||||
const organization = await this.userService.getOrganization(options.organizationid);
|
const organization = await this.organizationService.get(options.organizationid);
|
||||||
if (organization == null) {
|
if (organization == null) {
|
||||||
return Response.error("Organization not found.");
|
return Response.error("Organization not found.");
|
||||||
}
|
}
|
||||||
|
@ -204,7 +204,7 @@ export class ListCommand {
|
||||||
if (!Utils.isGuid(options.organizationid)) {
|
if (!Utils.isGuid(options.organizationid)) {
|
||||||
return Response.error("`" + options.organizationid + "` is not a GUID.");
|
return Response.error("`" + options.organizationid + "` is not a GUID.");
|
||||||
}
|
}
|
||||||
const organization = await this.userService.getOrganization(options.organizationid);
|
const organization = await this.organizationService.get(options.organizationid);
|
||||||
if (organization == null) {
|
if (organization == null) {
|
||||||
return Response.error("Organization not found.");
|
return Response.error("Organization not found.");
|
||||||
}
|
}
|
||||||
|
@ -230,7 +230,7 @@ export class ListCommand {
|
||||||
}
|
}
|
||||||
|
|
||||||
private async listOrganizations(options: program.OptionValues) {
|
private async listOrganizations(options: program.OptionValues) {
|
||||||
let organizations = await this.userService.getAllOrganizations();
|
let organizations = await this.organizationService.getAll();
|
||||||
|
|
||||||
if (options.search != null && options.search.trim() !== "") {
|
if (options.search != null && options.search.trim() !== "") {
|
||||||
organizations = CliUtils.searchOrganizations(organizations, options.search);
|
organizations = CliUtils.searchOrganizations(organizations, options.search);
|
||||||
|
|
|
@ -11,8 +11,8 @@ import { KeyConnectorService } from "jslib-common/abstractions/keyConnector.serv
|
||||||
import { PasswordGenerationService } from "jslib-common/abstractions/passwordGeneration.service";
|
import { PasswordGenerationService } from "jslib-common/abstractions/passwordGeneration.service";
|
||||||
import { PlatformUtilsService } from "jslib-common/abstractions/platformUtils.service";
|
import { PlatformUtilsService } from "jslib-common/abstractions/platformUtils.service";
|
||||||
import { PolicyService } from "jslib-common/abstractions/policy.service";
|
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 { SyncService } from "jslib-common/abstractions/sync.service";
|
||||||
import { UserService } from "jslib-common/abstractions/user.service";
|
|
||||||
|
|
||||||
import { MessageResponse } from "jslib-node/cli/models/response/messageResponse";
|
import { MessageResponse } from "jslib-node/cli/models/response/messageResponse";
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@ export class LoginCommand extends BaseLoginCommand {
|
||||||
environmentService: EnvironmentService,
|
environmentService: EnvironmentService,
|
||||||
passwordGenerationService: PasswordGenerationService,
|
passwordGenerationService: PasswordGenerationService,
|
||||||
platformUtilsService: PlatformUtilsService,
|
platformUtilsService: PlatformUtilsService,
|
||||||
userService: UserService,
|
stateService: StateService,
|
||||||
cryptoService: CryptoService,
|
cryptoService: CryptoService,
|
||||||
policyService: PolicyService,
|
policyService: PolicyService,
|
||||||
keyConnectorService: KeyConnectorService,
|
keyConnectorService: KeyConnectorService,
|
||||||
|
@ -46,7 +46,7 @@ export class LoginCommand extends BaseLoginCommand {
|
||||||
passwordGenerationService,
|
passwordGenerationService,
|
||||||
cryptoFunctionService,
|
cryptoFunctionService,
|
||||||
platformUtilsService,
|
platformUtilsService,
|
||||||
userService,
|
stateService,
|
||||||
cryptoService,
|
cryptoService,
|
||||||
policyService,
|
policyService,
|
||||||
"cli",
|
"cli",
|
||||||
|
|
|
@ -4,7 +4,7 @@ import * as path from "path";
|
||||||
|
|
||||||
import { EnvironmentService } from "jslib-common/abstractions/environment.service";
|
import { EnvironmentService } from "jslib-common/abstractions/environment.service";
|
||||||
import { SendService } from "jslib-common/abstractions/send.service";
|
import { SendService } from "jslib-common/abstractions/send.service";
|
||||||
import { UserService } from "jslib-common/abstractions/user.service";
|
import { StateService } from "jslib-common/abstractions/state.service";
|
||||||
|
|
||||||
import { SendType } from "jslib-common/enums/sendType";
|
import { SendType } from "jslib-common/enums/sendType";
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ import { CliUtils } from "../../utils";
|
||||||
export class SendCreateCommand {
|
export class SendCreateCommand {
|
||||||
constructor(
|
constructor(
|
||||||
private sendService: SendService,
|
private sendService: SendService,
|
||||||
private userService: UserService,
|
private stateService: StateService,
|
||||||
private environmentService: EnvironmentService
|
private environmentService: EnvironmentService
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
|
@ -73,7 +73,7 @@ export class SendCreateCommand {
|
||||||
|
|
||||||
switch (req.type) {
|
switch (req.type) {
|
||||||
case SendType.File:
|
case SendType.File:
|
||||||
if (!(await this.userService.canAccessPremium())) {
|
if (!(await this.stateService.getCanAccessPremium())) {
|
||||||
return Response.error("Premium status is required to use this feature.");
|
return Response.error("Premium status is required to use this feature.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
import * as program from "commander";
|
import * as program from "commander";
|
||||||
|
|
||||||
import { EnvironmentService } from "jslib-common/abstractions/environment.service";
|
|
||||||
import { SendService } from "jslib-common/abstractions/send.service";
|
import { SendService } from "jslib-common/abstractions/send.service";
|
||||||
import { UserService } from "jslib-common/abstractions/user.service";
|
import { StateService } from "jslib-common/abstractions/state.service";
|
||||||
|
|
||||||
import { SendType } from "jslib-common/enums/sendType";
|
import { SendType } from "jslib-common/enums/sendType";
|
||||||
import { Response } from "jslib-node/cli/models/response";
|
import { Response } from "jslib-node/cli/models/response";
|
||||||
|
@ -15,7 +14,7 @@ import { SendGetCommand } from "./get.command";
|
||||||
export class SendEditCommand {
|
export class SendEditCommand {
|
||||||
constructor(
|
constructor(
|
||||||
private sendService: SendService,
|
private sendService: SendService,
|
||||||
private userService: UserService,
|
private stateService: StateService,
|
||||||
private getCommand: SendGetCommand
|
private getCommand: SendGetCommand
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
|
@ -52,7 +51,7 @@ export class SendEditCommand {
|
||||||
return Response.badRequest("Cannot change a Send's type");
|
return Response.badRequest("Cannot change a Send's type");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (send.type === SendType.File && !(await this.userService.canAccessPremium())) {
|
if (send.type === SendType.File && !(await this.stateService.getCanAccessPremium())) {
|
||||||
return Response.error("Premium status is required to use this feature.");
|
return Response.error("Premium status is required to use this feature.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
import * as program from "commander";
|
import * as program from "commander";
|
||||||
|
|
||||||
import { EnvironmentService } from "jslib-common/abstractions/environment.service";
|
import { EnvironmentService } from "jslib-common/abstractions/environment.service";
|
||||||
|
import { StateService } from "jslib-common/abstractions/state.service";
|
||||||
import { SyncService } from "jslib-common/abstractions/sync.service";
|
import { SyncService } from "jslib-common/abstractions/sync.service";
|
||||||
import { UserService } from "jslib-common/abstractions/user.service";
|
|
||||||
import { VaultTimeoutService } from "jslib-common/abstractions/vaultTimeout.service";
|
import { VaultTimeoutService } from "jslib-common/abstractions/vaultTimeout.service";
|
||||||
|
|
||||||
import { Response } from "jslib-node/cli/models/response";
|
import { Response } from "jslib-node/cli/models/response";
|
||||||
|
@ -13,7 +13,7 @@ export class StatusCommand {
|
||||||
constructor(
|
constructor(
|
||||||
private envService: EnvironmentService,
|
private envService: EnvironmentService,
|
||||||
private syncService: SyncService,
|
private syncService: SyncService,
|
||||||
private userService: UserService,
|
private stateService: StateService,
|
||||||
private vaultTimeoutService: VaultTimeoutService
|
private vaultTimeoutService: VaultTimeoutService
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
|
@ -22,8 +22,8 @@ export class StatusCommand {
|
||||||
const baseUrl = this.baseUrl();
|
const baseUrl = this.baseUrl();
|
||||||
const status = await this.status();
|
const status = await this.status();
|
||||||
const lastSync = await this.syncService.getLastSync();
|
const lastSync = await this.syncService.getLastSync();
|
||||||
const userId = await this.userService.getUserId();
|
const userId = await this.stateService.getUserId();
|
||||||
const email = await this.userService.getEmail();
|
const email = await this.stateService.getEmail();
|
||||||
|
|
||||||
return Response.success(
|
return Response.success(
|
||||||
new TemplateResponse({
|
new TemplateResponse({
|
||||||
|
@ -44,7 +44,7 @@ export class StatusCommand {
|
||||||
}
|
}
|
||||||
|
|
||||||
private async status(): Promise<string> {
|
private async status(): Promise<string> {
|
||||||
const authed = await this.userService.isAuthenticated();
|
const authed = await this.stateService.getIsAuthenticated();
|
||||||
if (!authed) {
|
if (!authed) {
|
||||||
return "unauthenticated";
|
return "unauthenticated";
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,7 @@ import * as inquirer from "inquirer";
|
||||||
import { ApiService } from "jslib-common/abstractions/api.service";
|
import { ApiService } from "jslib-common/abstractions/api.service";
|
||||||
import { CryptoService } from "jslib-common/abstractions/crypto.service";
|
import { CryptoService } from "jslib-common/abstractions/crypto.service";
|
||||||
import { CryptoFunctionService } from "jslib-common/abstractions/cryptoFunction.service";
|
import { CryptoFunctionService } from "jslib-common/abstractions/cryptoFunction.service";
|
||||||
import { UserService } from "jslib-common/abstractions/user.service";
|
import { StateService } from "jslib-common/abstractions/state.service";
|
||||||
|
|
||||||
import { Response } from "jslib-node/cli/models/response";
|
import { Response } from "jslib-node/cli/models/response";
|
||||||
import { MessageResponse } from "jslib-node/cli/models/response/messageResponse";
|
import { MessageResponse } from "jslib-node/cli/models/response/messageResponse";
|
||||||
|
@ -20,7 +20,7 @@ import { ConsoleLogService } from "jslib-common/services/consoleLog.service";
|
||||||
export class UnlockCommand {
|
export class UnlockCommand {
|
||||||
constructor(
|
constructor(
|
||||||
private cryptoService: CryptoService,
|
private cryptoService: CryptoService,
|
||||||
private userService: UserService,
|
private stateService: StateService,
|
||||||
private cryptoFunctionService: CryptoFunctionService,
|
private cryptoFunctionService: CryptoFunctionService,
|
||||||
private apiService: ApiService,
|
private apiService: ApiService,
|
||||||
private logService: ConsoleLogService
|
private logService: ConsoleLogService
|
||||||
|
@ -59,9 +59,9 @@ export class UnlockCommand {
|
||||||
}
|
}
|
||||||
|
|
||||||
this.setNewSessionKey();
|
this.setNewSessionKey();
|
||||||
const email = await this.userService.getEmail();
|
const email = await this.stateService.getEmail();
|
||||||
const kdf = await this.userService.getKdf();
|
const kdf = await this.stateService.getKdfType();
|
||||||
const kdfIterations = await this.userService.getKdfIterations();
|
const kdfIterations = await this.stateService.getKdfIterations();
|
||||||
const key = await this.cryptoService.makeKey(password, email, kdf, kdfIterations);
|
const key = await this.cryptoService.makeKey(password, email, kdf, kdfIterations);
|
||||||
const storedKeyHash = await this.cryptoService.getKeyHash();
|
const storedKeyHash = await this.cryptoService.getKeyHash();
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,7 @@ const writeLn = CliUtils.writeLn;
|
||||||
|
|
||||||
export class Program extends BaseProgram {
|
export class Program extends BaseProgram {
|
||||||
constructor(protected main: Main) {
|
constructor(protected main: Main) {
|
||||||
super(main.userService, writeLn);
|
super(main.stateService, writeLn);
|
||||||
}
|
}
|
||||||
|
|
||||||
async register() {
|
async register() {
|
||||||
|
@ -117,7 +117,7 @@ export class Program extends BaseProgram {
|
||||||
"Path to a file containing your password as its first line"
|
"Path to a file containing your password as its first line"
|
||||||
)
|
)
|
||||||
.option("--check", "Check login status.", async () => {
|
.option("--check", "Check login status.", async () => {
|
||||||
const authed = await this.main.userService.isAuthenticated();
|
const authed = await this.main.stateService.getIsAuthenticated();
|
||||||
if (authed) {
|
if (authed) {
|
||||||
const res = new MessageResponse("You are logged in!", null);
|
const res = new MessageResponse("You are logged in!", null);
|
||||||
this.processResponse(Response.success(res), true);
|
this.processResponse(Response.success(res), true);
|
||||||
|
@ -151,7 +151,7 @@ export class Program extends BaseProgram {
|
||||||
this.main.environmentService,
|
this.main.environmentService,
|
||||||
this.main.passwordGenerationService,
|
this.main.passwordGenerationService,
|
||||||
this.main.platformUtilsService,
|
this.main.platformUtilsService,
|
||||||
this.main.userService,
|
this.main.stateService,
|
||||||
this.main.cryptoService,
|
this.main.cryptoService,
|
||||||
this.main.policyService,
|
this.main.policyService,
|
||||||
this.main.keyConnectorService,
|
this.main.keyConnectorService,
|
||||||
|
@ -251,7 +251,7 @@ export class Program extends BaseProgram {
|
||||||
await this.exitIfNotAuthed();
|
await this.exitIfNotAuthed();
|
||||||
const command = new UnlockCommand(
|
const command = new UnlockCommand(
|
||||||
this.main.cryptoService,
|
this.main.cryptoService,
|
||||||
this.main.userService,
|
this.main.stateService,
|
||||||
this.main.cryptoFunctionService,
|
this.main.cryptoFunctionService,
|
||||||
this.main.apiService,
|
this.main.apiService,
|
||||||
this.main.logService
|
this.main.logService
|
||||||
|
@ -454,7 +454,7 @@ export class Program extends BaseProgram {
|
||||||
const command = new StatusCommand(
|
const command = new StatusCommand(
|
||||||
this.main.environmentService,
|
this.main.environmentService,
|
||||||
this.main.syncService,
|
this.main.syncService,
|
||||||
this.main.userService,
|
this.main.stateService,
|
||||||
this.main.vaultTimeoutService
|
this.main.vaultTimeoutService
|
||||||
);
|
);
|
||||||
const response = await command.run();
|
const response = await command.run();
|
||||||
|
@ -488,7 +488,7 @@ export class Program extends BaseProgram {
|
||||||
} else {
|
} else {
|
||||||
const command = new UnlockCommand(
|
const command = new UnlockCommand(
|
||||||
this.main.cryptoService,
|
this.main.cryptoService,
|
||||||
this.main.userService,
|
this.main.stateService,
|
||||||
this.main.cryptoFunctionService,
|
this.main.cryptoFunctionService,
|
||||||
this.main.apiService,
|
this.main.apiService,
|
||||||
this.main.logService
|
this.main.logService
|
||||||
|
|
|
@ -152,11 +152,10 @@ export class SendProgram extends Program {
|
||||||
this.main.totpService,
|
this.main.totpService,
|
||||||
this.main.auditService,
|
this.main.auditService,
|
||||||
this.main.cryptoService,
|
this.main.cryptoService,
|
||||||
this.main.userService,
|
this.main.stateService,
|
||||||
this.main.searchService,
|
this.main.searchService,
|
||||||
this.main.apiService,
|
this.main.apiService,
|
||||||
this.main.sendService,
|
this.main.organizationService
|
||||||
this.main.environmentService
|
|
||||||
);
|
);
|
||||||
const response = await cmd.run("template", object, null);
|
const response = await cmd.run("template", object, null);
|
||||||
this.processResponse(response);
|
this.processResponse(response);
|
||||||
|
@ -263,7 +262,7 @@ export class SendProgram extends Program {
|
||||||
this.main.searchService,
|
this.main.searchService,
|
||||||
this.main.cryptoService
|
this.main.cryptoService
|
||||||
);
|
);
|
||||||
const cmd = new SendEditCommand(this.main.sendService, this.main.userService, getCmd);
|
const cmd = new SendEditCommand(this.main.sendService, this.main.stateService, getCmd);
|
||||||
const response = await cmd.run(encodedJson, options);
|
const response = await cmd.run(encodedJson, options);
|
||||||
this.processResponse(response);
|
this.processResponse(response);
|
||||||
});
|
});
|
||||||
|
@ -330,7 +329,7 @@ export class SendProgram extends Program {
|
||||||
await this.exitIfLocked();
|
await this.exitIfLocked();
|
||||||
const cmd = new SendCreateCommand(
|
const cmd = new SendCreateCommand(
|
||||||
this.main.sendService,
|
this.main.sendService,
|
||||||
this.main.userService,
|
this.main.stateService,
|
||||||
this.main.environmentService
|
this.main.environmentService
|
||||||
);
|
);
|
||||||
return await cmd.run(encodedJson, options);
|
return await cmd.run(encodedJson, options);
|
||||||
|
|
|
@ -118,7 +118,7 @@ export class VaultProgram extends Program {
|
||||||
this.main.cipherService,
|
this.main.cipherService,
|
||||||
this.main.folderService,
|
this.main.folderService,
|
||||||
this.main.collectionService,
|
this.main.collectionService,
|
||||||
this.main.userService,
|
this.main.organizationService,
|
||||||
this.main.searchService,
|
this.main.searchService,
|
||||||
this.main.apiService
|
this.main.apiService
|
||||||
);
|
);
|
||||||
|
@ -190,11 +190,10 @@ export class VaultProgram extends Program {
|
||||||
this.main.totpService,
|
this.main.totpService,
|
||||||
this.main.auditService,
|
this.main.auditService,
|
||||||
this.main.cryptoService,
|
this.main.cryptoService,
|
||||||
this.main.userService,
|
this.main.stateService,
|
||||||
this.main.searchService,
|
this.main.searchService,
|
||||||
this.main.apiService,
|
this.main.apiService,
|
||||||
this.main.sendService,
|
this.main.organizationService
|
||||||
this.main.environmentService
|
|
||||||
);
|
);
|
||||||
const response = await command.run(object, id, cmd);
|
const response = await command.run(object, id, cmd);
|
||||||
this.processResponse(response);
|
this.processResponse(response);
|
||||||
|
@ -232,7 +231,7 @@ export class VaultProgram extends Program {
|
||||||
const command = new CreateCommand(
|
const command = new CreateCommand(
|
||||||
this.main.cipherService,
|
this.main.cipherService,
|
||||||
this.main.folderService,
|
this.main.folderService,
|
||||||
this.main.userService,
|
this.main.stateService,
|
||||||
this.main.cryptoService,
|
this.main.cryptoService,
|
||||||
this.main.apiService
|
this.main.apiService
|
||||||
);
|
);
|
||||||
|
@ -318,7 +317,7 @@ export class VaultProgram extends Program {
|
||||||
const command = new DeleteCommand(
|
const command = new DeleteCommand(
|
||||||
this.main.cipherService,
|
this.main.cipherService,
|
||||||
this.main.folderService,
|
this.main.folderService,
|
||||||
this.main.userService,
|
this.main.stateService,
|
||||||
this.main.apiService
|
this.main.apiService
|
||||||
);
|
);
|
||||||
const response = await command.run(object, id, cmd);
|
const response = await command.run(object, id, cmd);
|
||||||
|
@ -440,7 +439,7 @@ export class VaultProgram extends Program {
|
||||||
})
|
})
|
||||||
.action(async (format, filepath, options) => {
|
.action(async (format, filepath, options) => {
|
||||||
await this.exitIfLocked();
|
await this.exitIfLocked();
|
||||||
const command = new ImportCommand(this.main.importService, this.main.userService);
|
const command = new ImportCommand(this.main.importService, this.main.organizationService);
|
||||||
const response = await command.run(format, filepath, options);
|
const response = await command.run(format, filepath, options);
|
||||||
this.processResponse(response);
|
this.processResponse(response);
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue