Fix/encryption (#1811)

* change encryption to use pubkey and only encrypt specific fields

* adjust script names for convenience

* remove unused fn

* fix build script name

* augment mocks

* remove log

* fix prod build

* feat: backend keys

* fix: Using the correct name with the public key

* chore: Fix the type for the encrypted

* chore: Add some tracing

* remove aes-js from package lock file

Co-authored-by: BluJ <mogulslayer@gmail.com>
This commit is contained in:
Lucy C
2022-09-21 14:03:05 -06:00
committed by GitHub
parent f8ea2ebf62
commit 28f9fa35e5
15 changed files with 213 additions and 463 deletions

View File

@@ -30,7 +30,7 @@ export class StateService {
cert = ''
constructor(
private readonly apiService: ApiService,
private readonly api: ApiService,
private readonly errorToastService: ErrorToastService,
) {}
@@ -45,7 +45,7 @@ export class StateService {
let progress
try {
progress = await this.apiService.getRecoveryStatus()
progress = await this.api.getRecoveryStatus()
} catch (e: any) {
this.errorToastService.present({
message: `${e.message}\n\nRestart Embassy to try again.`,
@@ -67,9 +67,9 @@ export class StateService {
}
async importDrive(guid: string, password: string): Promise<void> {
const ret = await this.apiService.importDrive({
const ret = await this.api.importDrive({
guid,
'embassy-password': password,
'embassy-password': await this.api.encrypt(password),
})
this.torAddress = ret['tor-address']
this.lanAddress = ret['lan-address']
@@ -80,11 +80,13 @@ export class StateService {
storageLogicalname: string,
password: string,
): Promise<void> {
const ret = await this.apiService.setupEmbassy({
const ret = await this.api.setupEmbassy({
'embassy-logicalname': storageLogicalname,
'embassy-password': password,
'embassy-password': await this.api.encrypt(password),
'recovery-source': this.recoverySource || null,
'recovery-password': this.recoveryPassword || null,
'recovery-password': this.recoveryPassword
? await this.api.encrypt(this.recoveryPassword)
: null,
})
this.torAddress = ret['tor-address']
this.lanAddress = ret['lan-address']
@@ -92,7 +94,7 @@ export class StateService {
}
async completeEmbassy(): Promise<void> {
const ret = await this.apiService.setupComplete()
const ret = await this.api.setupComplete()
this.torAddress = ret['tor-address']
this.lanAddress = ret['lan-address']
this.cert = ret['root-ca']