From cc2e93721685039acb11ed7162b66a9ef99ac8bb Mon Sep 17 00:00:00 2001 From: Drew Ansbacher Date: Sun, 17 Oct 2021 18:33:46 -0600 Subject: [PATCH] lan address added --- .../src/app/pages/embassy/embassy.page.ts | 2 +- .../src/app/pages/success/success.page.html | 17 +++++++++++++++-- .../src/app/pages/success/success.page.ts | 4 ++-- .../src/app/services/api/api.service.ts | 7 ++++++- .../src/app/services/api/live-api.service.ts | 6 +++--- .../src/app/services/api/mock-api.service.ts | 5 ++++- setup-wizard/src/app/services/state.service.ts | 6 ++++-- 7 files changed, 35 insertions(+), 12 deletions(-) diff --git a/setup-wizard/src/app/pages/embassy/embassy.page.ts b/setup-wizard/src/app/pages/embassy/embassy.page.ts index 994209e7f..27c5ceeff 100644 --- a/setup-wizard/src/app/pages/embassy/embassy.page.ts +++ b/setup-wizard/src/app/pages/embassy/embassy.page.ts @@ -91,7 +91,7 @@ export class EmbassyPage { this.stateService.embassyPassword = ret.data.password try { - this.stateService.torAddress = (await this.stateService.setupEmbassy()).torAddress + await this.stateService.setupEmbassy() } catch (e) { this.errorToastService.present(`${e.message}: ${e.details}`) console.error(e.message) diff --git a/setup-wizard/src/app/pages/success/success.page.html b/setup-wizard/src/app/pages/success/success.page.html index 6c3b297c2..020025cc2 100644 --- a/setup-wizard/src/app/pages/success/success.page.html +++ b/setup-wizard/src/app/pages/success/success.page.html @@ -20,7 +20,7 @@

{{ stateService.torAddress }}

- + @@ -41,7 +41,7 @@
@@ -65,6 +65,19 @@

Download and trust your Embassy's Root Cert

+ +

LAN Address:

+ + + +

{{ stateService.lanAddress }}

+
+ + + + + +
diff --git a/setup-wizard/src/app/pages/success/success.page.ts b/setup-wizard/src/app/pages/success/success.page.ts index 647a6951d..844131739 100644 --- a/setup-wizard/src/app/pages/success/success.page.ts +++ b/setup-wizard/src/app/pages/success/success.page.ts @@ -16,9 +16,9 @@ export class SuccessPage { window = window lanInstructionsOpen = false - async copy (): Promise { + async copy (address: string): Promise { let message = '' - await this.copyToClipboard(this.stateService.torAddress) + await this.copyToClipboard(address) .then(success => message = success ? 'copied to clipboard!' : 'failed to copy') const toast = await this.toastCtrl.create({ diff --git a/setup-wizard/src/app/services/api/api.service.ts b/setup-wizard/src/app/services/api/api.service.ts index 620df2f64..f19a98922 100644 --- a/setup-wizard/src/app/services/api/api.service.ts +++ b/setup-wizard/src/app/services/api/api.service.ts @@ -8,7 +8,7 @@ export abstract class ApiService { // encrypted abstract verifyProductKey (): Promise // echo - throws error if invalid abstract verify03XPassword (logicalname: string, password: string): Promise // setup.recovery.test-password - abstract setupEmbassy (setupInfo: SetupEmbassyReq): Promise // setup.execute + abstract setupEmbassy (setupInfo: SetupEmbassyReq): Promise // setup.execute } export interface GetStatusRes { @@ -23,6 +23,11 @@ export interface SetupEmbassyReq { 'recovery-password'?: string } +export interface SetupEmbassyRes { + 'tor-address': string + 'lan-address': string +} + export interface DiskInfo { logicalname: string, vendor: string | null, diff --git a/setup-wizard/src/app/services/api/live-api.service.ts b/setup-wizard/src/app/services/api/live-api.service.ts index 8e08dfed6..1a1c63f87 100644 --- a/setup-wizard/src/app/services/api/live-api.service.ts +++ b/setup-wizard/src/app/services/api/live-api.service.ts @@ -1,5 +1,5 @@ import { Injectable } from '@angular/core' -import { ApiService, DiskInfo, GetStatusRes, RecoveryStatusRes, SetupEmbassyReq } from './api.service' +import { ApiService, DiskInfo, GetStatusRes, RecoveryStatusRes, SetupEmbassyReq, SetupEmbassyRes } from './api.service' import { HttpService } from './http.service' @Injectable({ @@ -46,7 +46,7 @@ export class LiveApiService extends ApiService { async verifyProductKey () { return this.http.rpcRequest({ method: 'echo', - params: { "message": "hello" }, + params: { 'message': 'hello' }, }) } @@ -58,7 +58,7 @@ export class LiveApiService extends ApiService { } async setupEmbassy (setupInfo: SetupEmbassyReq) { - return this.http.rpcRequest({ + return this.http.rpcRequest({ method: 'setup.execute', params: setupInfo as any, }) diff --git a/setup-wizard/src/app/services/api/mock-api.service.ts b/setup-wizard/src/app/services/api/mock-api.service.ts index 40f9582ad..3ca2a81a2 100644 --- a/setup-wizard/src/app/services/api/mock-api.service.ts +++ b/setup-wizard/src/app/services/api/mock-api.service.ts @@ -126,7 +126,10 @@ export class MockApiService extends ApiService { async setupEmbassy (setupInfo: SetupEmbassyReq) { await pauseFor(3000) - return 'asdfasdfasdf.onion' + return { + 'tor-address': 'asdfasdfasdf.onion', + 'lan-address': 'embassy-dfasdf.local', + } } async getRecoveryDrives () { diff --git a/setup-wizard/src/app/services/state.service.ts b/setup-wizard/src/app/services/state.service.ts index d39dc732b..2b6c013bf 100644 --- a/setup-wizard/src/app/services/state.service.ts +++ b/setup-wizard/src/app/services/state.service.ts @@ -21,6 +21,7 @@ export class StateService { dataProgSubject = new BehaviorSubject(this.dataProgress) torAddress: string + lanAddress: string constructor ( private readonly apiService: ApiService, @@ -56,14 +57,15 @@ export class StateService { this.pollDataTransferProgress(callback) } - async setupEmbassy () : Promise<{ torAddress: string }> { + async setupEmbassy () : Promise { const ret = await this.apiService.setupEmbassy({ 'embassy-logicalname': this.storageDrive.logicalname, 'embassy-password': this.embassyPassword, 'recovery-drive': this.recoveryDrive, 'recovery-password': this.recoveryPassword, }) - return { torAddress: ret } + this.torAddress = ret['tor-address'] + this.lanAddress = ret['lan-address'] } }