1
0
mirror of https://github.com/bitwarden/jslib synced 2025-12-18 17:23:30 +00:00

Run Prettier

This commit is contained in:
Thomas Rittson
2021-12-20 14:20:58 +10:00
parent 54b4154c02
commit 1f11b7cc3b
11 changed files with 65 additions and 58 deletions

View File

@@ -93,7 +93,12 @@ export class LoginComponent extends CaptchaProtectedComponent implements OnInit
}
try {
this.formPromise = this.authService.logIn(this.email, this.masterPassword, null, this.captchaToken);
this.formPromise = this.authService.logIn(
this.email,
this.masterPassword,
null,
this.captchaToken
);
const response = await this.formPromise;
if (this.rememberEmail) {
await this.stateService.setRememberedEmail(this.email);

View File

@@ -6,7 +6,7 @@ import { TwoFactorProviderType } from "jslib-common/enums/twoFactorProviderType"
import { AuthService } from "jslib-common/abstractions/auth.service";
import { I18nService } from "jslib-common/abstractions/i18n.service";
import { PlatformUtilsService } from "jslib-common/abstractions/platformUtils.service";
import { TwoFactorService } from 'jslib-common/abstractions/twoFactor.service';
import { TwoFactorService } from "jslib-common/abstractions/twoFactor.service";
@Directive()
export class TwoFactorOptionsComponent implements OnInit {

View File

@@ -192,13 +192,11 @@ export class TwoFactorComponent implements OnInit, OnDestroy {
}
async doSubmit() {
this.formPromise = this.authService.logInTwoFactor(
{
provider: this.selectedProviderType,
token: this.token,
remember: this.remember
}
);
this.formPromise = this.authService.logInTwoFactor({
provider: this.selectedProviderType,
token: this.token,
remember: this.remember,
});
const response: AuthResult = await this.formPromise;
const disableFavicon = await this.stateService.getDisableFavicon();
await this.stateService.setDisableFavicon(!!disableFavicon);

View File

@@ -1,20 +1,27 @@
import { AuthResult } from "../models/domain/authResult";
import { SymmetricCryptoKey } from "../models/domain/symmetricCryptoKey";
import { TwoFactorData } from '../models/request/identityToken/tokenRequest';
import { TwoFactorData } from "../models/request/identityToken/tokenRequest";
export abstract class AuthService {
logIn: (email: string, masterPassword: string, twoFactor?: TwoFactorData, captchaToken?: string) => Promise<AuthResult>;
logIn: (
email: string,
masterPassword: string,
twoFactor?: TwoFactorData,
captchaToken?: string
) => Promise<AuthResult>;
logInSso: (
code: string,
codeVerifier: string,
redirectUrl: string,
orgId: string,
twoFactor?: TwoFactorData,
twoFactor?: TwoFactorData
) => Promise<AuthResult>;
logInApiKey: (clientId: string, clientSecret: string, twoFactor?: TwoFactorData) => Promise<AuthResult>;
logInTwoFactor: (
twoFactor: TwoFactorData
logInApiKey: (
clientId: string,
clientSecret: string,
twoFactor?: TwoFactorData
) => Promise<AuthResult>;
logInTwoFactor: (twoFactor: TwoFactorData) => Promise<AuthResult>;
logOut: (callback: Function) => void;
makePreloginKey: (masterPassword: string, email: string) => Promise<SymmetricCryptoKey>;
authingWithApiKey: () => boolean;

View File

@@ -6,7 +6,12 @@ export abstract class KeyConnectorService {
getUsesKeyConnector: () => Promise<boolean>;
migrateUser: () => Promise<void>;
userNeedsMigration: () => Promise<boolean>;
convertNewSsoUserToKeyConnector: (kdf: number, kdfIterations: number, url: string, orgId: string) => void;
convertNewSsoUserToKeyConnector: (
kdf: number,
kdfIterations: number,
url: string,
orgId: string
) => void;
setUsesKeyConnector: (enabled: boolean) => Promise<void>;
setConvertAccountRequired: (status: boolean) => Promise<void>;
getConvertAccountRequired: () => Promise<boolean>;

View File

@@ -1,6 +1,6 @@
import { TokenRequest, TwoFactorData } from "./tokenRequest";
import { CaptchaProtectedRequest } from '../captchaProtectedRequest';
import { CaptchaProtectedRequest } from "../captchaProtectedRequest";
import { DeviceRequest } from "../deviceRequest";
import { Utils } from "../../../misc/utils";

View File

@@ -12,10 +12,7 @@ export interface TwoFactorData {
export abstract class TokenRequest {
protected device?: DeviceRequest;
constructor(
protected twoFactor: TwoFactorData,
device?: DeviceRequest
) {
constructor(protected twoFactor: TwoFactorData, device?: DeviceRequest) {
this.device = device != null ? device : null;
}
@@ -46,7 +43,7 @@ export abstract class TokenRequest {
// Implemented in subclass if required
}
setTwoFactor(twoFactor: TwoFactorData) {
this.twoFactor = twoFactor;
}
setTwoFactor(twoFactor: TwoFactorData) {
this.twoFactor = twoFactor;
}
}

View File

@@ -264,7 +264,7 @@ export class AuthService implements AuthServiceAbstraction {
private async processTokenResponse(
response: IdentityTokenResponse | IdentityTwoFactorResponse | IdentityCaptchaResponse,
newSsoUser: boolean = false,
newSsoUser: boolean = false
): Promise<AuthResult> {
this.clearState();
const result = new AuthResult();

View File

@@ -1,6 +1,6 @@
import { ApiService } from "../abstractions/api.service";
import { CryptoService } from "../abstractions/crypto.service";
import { CryptoFunctionService } from '../abstractions/cryptoFunction.service';
import { CryptoFunctionService } from "../abstractions/cryptoFunction.service";
import { KeyConnectorService as KeyConnectorServiceAbstraction } from "../abstractions/keyConnector.service";
import { LogService } from "../abstractions/log.service";
import { OrganizationService } from "../abstractions/organization.service";
@@ -12,10 +12,10 @@ import { OrganizationUserType } from "../enums/organizationUserType";
import { Utils } from "../misc/utils";
import { SymmetricCryptoKey } from "../models/domain/symmetricCryptoKey";
import { SetKeyConnectorKeyRequest } from '../models/request/account/setKeyConnectorKeyRequest';
import { SetKeyConnectorKeyRequest } from "../models/request/account/setKeyConnectorKeyRequest";
import { KeyConnectorUserKeyRequest } from "../models/request/keyConnectorUserKeyRequest";
import { KeysRequest } from '../models/request/keysRequest';
import { KeysRequest } from "../models/request/keysRequest";
export class KeyConnectorService implements KeyConnectorServiceAbstraction {
constructor(
@@ -25,7 +25,7 @@ export class KeyConnectorService implements KeyConnectorServiceAbstraction {
private tokenService: TokenService,
private logService: LogService,
private organizationService: OrganizationService,
private cryptoFunctionService: CryptoFunctionService,
private cryptoFunctionService: CryptoFunctionService
) {}
setUsesKeyConnector(usesKeyConnector: boolean) {
@@ -84,7 +84,12 @@ export class KeyConnectorService implements KeyConnectorServiceAbstraction {
);
}
async convertNewSsoUserToKeyConnector(kdf: number, kdfIterations: number, url: string, orgId: string) {
async convertNewSsoUserToKeyConnector(
kdf: number,
kdfIterations: number,
url: string,
orgId: string
) {
const password = await this.cryptoFunctionService.randomBytes(64);
const k = await this.cryptoService.makeKey(
@@ -102,10 +107,7 @@ export class KeyConnectorService implements KeyConnectorServiceAbstraction {
const [pubKey, privKey] = await this.cryptoService.makeKeyPair();
try {
await this.apiService.postUserKeyToKeyConnector(
url,
keyConnectorRequest
);
await this.apiService.postUserKeyToKeyConnector(url, keyConnectorRequest);
} catch (e) {
throw new Error("Unable to reach key connector");
}

View File

@@ -157,37 +157,29 @@ export class LoginCommand {
let response: AuthResult = null;
if (clientId != null && clientSecret != null) {
response = await this.authService.logInApiKey(
clientId,
clientSecret,
{
provider: twoFactorMethod,
token: twoFactorToken,
remember: false
}
);
response = await this.authService.logInApiKey(clientId, clientSecret, {
provider: twoFactorMethod,
token: twoFactorToken,
remember: false,
});
} else if (ssoCode != null && ssoCodeVerifier != null) {
response = await this.authService.logInSso(
ssoCode,
ssoCodeVerifier,
this.ssoRedirectUri,
orgIdentifier,
{
provider: twoFactorMethod,
token: twoFactorToken,
remember: false
}
);
} else {
response = await this.authService.logIn(
email,
password,
{
provider: twoFactorMethod,
token: twoFactorToken,
remember: false,
}
);
} else {
response = await this.authService.logIn(email, password, {
provider: twoFactorMethod,
token: twoFactorToken,
remember: false,
});
}
if (response.captchaSiteKey) {
const badCaptcha = Response.badRequest(

View File

@@ -507,7 +507,9 @@ describe("Cipher Service", () => {
const result = await authService.logInSso(ssoCode, ssoCodeVerifier, ssoRedirectUrl, ssoOrgId);
commonSuccessAssertions();
keyConnectorService.received(1).convertNewSsoUserToKeyConnector(kdf, kdfIterations, keyConnectorUrl, ssoOrgId);
keyConnectorService
.received(1)
.convertNewSsoUserToKeyConnector(kdf, kdfIterations, keyConnectorUrl, ssoOrgId);
});
// API
@@ -534,11 +536,10 @@ describe("Cipher Service", () => {
})
);
// Sets local environment:
stateService.received(1).setApiKeyClientId(apiClientId);
stateService.received(1).setApiKeyClientSecret(apiClientSecret);
commonSuccessAssertions();
stateService.received(1).setApiKeyClientId(apiClientId);
stateService.received(1).setApiKeyClientSecret(apiClientSecret);
commonSuccessAssertions();
cryptoService.received(1).setEncKey(encKey);
cryptoService.received(1).setEncPrivateKey(privateKey);