Lint code.

This commit is contained in:
Spencer Ofwiti 2021-06-07 18:49:15 +03:00
parent 159cedc86e
commit 8e96b070a5
3 changed files with 36 additions and 18 deletions

View File

@ -102,8 +102,11 @@ export class AuthService {
await this.loginResponse(o, password);
return true;
} catch (error) {
this.loggingService.sendErrorLevelMessage(`Login challenge failed: Error ${error.status} - ${error.statusText}`,
this, {error});
this.loggingService.sendErrorLevelMessage(
`Login challenge failed: Error ${error.status} - ${error.statusText}`,
this,
{ error }
);
}
return false;
}
@ -114,8 +117,11 @@ export class AuthService {
this.getWithToken();
return true;
} catch (error) {
this.loggingService.sendErrorLevelMessage(`Login token failed: Error ${error.status} - ${error.statusText}`,
this, {error});
this.loggingService.sendErrorLevelMessage(
`Login token failed: Error ${error.status} - ${error.statusText}`,
this,
{ error }
);
}
}
return false;
@ -162,9 +168,11 @@ export class AuthService {
if (!isValidKeyCheck) {
throw Error('The private key is invalid');
}
const isEncryptedKeyCheck = await this.mutableKeyStore.isEncryptedPrivateKey(privateKeyArmored);
const isEncryptedKeyCheck = await this.mutableKeyStore.isEncryptedPrivateKey(
privateKeyArmored
);
if (!isEncryptedKeyCheck) {
throw Error('The private key doesn\'t have a password!');
throw Error('The private key does not have a password!');
}
const key = await this.mutableKeyStore.importPrivateKey(privateKeyArmored);
localStorage.setItem(btoa('CICADA_PRIVATE_KEY'), privateKeyArmored);

View File

@ -23,8 +23,8 @@ export class AuthComponent implements OnInit {
private authService: AuthService,
private formBuilder: FormBuilder,
private router: Router,
private cdr: ChangeDetectorRef,
) { }
private cdr: ChangeDetectorRef
) {}
async ngOnInit(): Promise<void> {
this.keyForm = this.formBuilder.group({
@ -44,8 +44,12 @@ export class AuthComponent implements OnInit {
}
}
get keyFormStub(): any { return this.keyForm.controls; }
get passwordFormStub(): any { return this.passwordForm.controls; }
get keyFormStub(): any {
return this.keyForm.controls;
}
get passwordFormStub(): any {
return this.passwordForm.controls;
}
async onSubmit(): Promise<void> {
this.keyFormSubmitted = true;
@ -66,10 +70,14 @@ export class AuthComponent implements OnInit {
async onPasswordInput(): Promise<void> {
this.passwordFormSubmitted = true;
if (this.passwordForm.invalid) { return; }
if (this.passwordForm.invalid) {
return;
}
this.passwordFormLoading = true;
const passwordLogin = await this.authService.passwordLogin(this.passwordFormStub.password.value);
const passwordLogin = await this.authService.passwordLogin(
this.passwordFormStub.password.value
);
if (passwordLogin) {
this.loginView();
}
@ -95,7 +103,9 @@ export class AuthComponent implements OnInit {
passwordInput(): void {
this.authService.sessionToken = undefined;
this.switchWindows(false, true, false);
this.setPasswordState('Enter Password to log in with PGP key ' + this.authService.mutableKeyStore.getPrivateKeyId());
this.setPasswordState(
'Enter Password to log in with PGP key ' + this.authService.mutableKeyStore.getPrivateKeyId()
);
}
loginView(): void {

View File

@ -3,9 +3,9 @@ import { hobaResult, hobaToSign } from '@src/assets/js/hoba.js';
const alg = '969';
export async function signChallenge(challenge, realm, origin, keyStore, password) {
const fingerprint = keyStore.getFingerprint();
const nonce_array = new Uint8Array(32);
crypto.getRandomValues(nonce_array);
const fingerprint = keyStore.getFingerprint();
const nonce_array = new Uint8Array(32);
crypto.getRandomValues(nonce_array);
const kid_array = fingerprint;
@ -14,8 +14,8 @@ export async function signChallenge(challenge, realm, origin, keyStore, password
const a_challenge = btoa(challenge);
const message = hobaToSign(a_nonce, a_kid, a_challenge, realm, origin, alg);
const signature = await keyStore.sign(message, password);
const a_signature = btoa(signature);
const signature = await keyStore.sign(message, password);
const a_signature = btoa(signature);
const result = hobaResult(a_nonce, a_kid, a_challenge, a_signature);
return result;