diff --git a/src/app/_services/auth.service.ts b/src/app/_services/auth.service.ts index 2acd2bd..f1337f8 100644 --- a/src/app/_services/auth.service.ts +++ b/src/app/_services/auth.service.ts @@ -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); diff --git a/src/app/auth/auth.component.ts b/src/app/auth/auth.component.ts index 1588653..ad33f49 100644 --- a/src/app/auth/auth.component.ts +++ b/src/app/auth/auth.component.ts @@ -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 { 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 { this.keyFormSubmitted = true; @@ -66,10 +70,14 @@ export class AuthComponent implements OnInit { async onPasswordInput(): Promise { 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 { diff --git a/src/assets/js/hoba-pgp.js b/src/assets/js/hoba-pgp.js index 717b527..5fa68a0 100644 --- a/src/assets/js/hoba-pgp.js +++ b/src/assets/js/hoba-pgp.js @@ -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;