setup complete fix and minor copy changes

return SetupResult on setup.complete
This commit is contained in:
Drew Ansbacher
2022-02-27 19:07:43 -07:00
committed by Aiden McClelland
parent df16943502
commit 61ee46f289
21 changed files with 456 additions and 406 deletions

View File

@@ -1,16 +1,16 @@
export abstract class ApiService {
// unencrypted
abstract getStatus (): Promise<GetStatusRes> // setup.status
abstract getDrives (): Promise<DiskListResponse> // setup.disk.list
abstract set02XDrive (logicalname: string): Promise<void> // setup.recovery.v2.set
abstract getRecoveryStatus (): Promise<RecoveryStatusRes> // setup.recovery.status
abstract getStatus(): Promise<GetStatusRes> // setup.status
abstract getDrives(): Promise<DiskListResponse> // setup.disk.list
abstract set02XDrive(logicalname: string): Promise<void> // setup.recovery.v2.set
abstract getRecoveryStatus(): Promise<RecoveryStatusRes> // setup.recovery.status
// encrypted
abstract verifyCifs (cifs: CifsRecoverySource): Promise<EmbassyOSRecoveryInfo> // setup.cifs.verify
abstract verifyProductKey (): Promise<void> // echo - throws error if invalid
abstract importDrive (guid: string): Promise<SetupEmbassyRes> // setup.execute
abstract setupEmbassy (setupInfo: SetupEmbassyReq): Promise<SetupEmbassyRes> // setup.execute
abstract setupComplete (): Promise<void> // setup.complete
abstract verifyCifs(cifs: CifsRecoverySource): Promise<EmbassyOSRecoveryInfo> // setup.cifs.verify
abstract verifyProductKey(): Promise<void> // echo - throws error if invalid
abstract importDrive(guid: string): Promise<SetupEmbassyRes> // setup.execute
abstract setupEmbassy(setupInfo: SetupEmbassyReq): Promise<SetupEmbassyRes> // setup.execute
abstract setupComplete(): Promise<SetupEmbassyRes> // setup.complete
}
export interface GetStatusRes {
@@ -75,12 +75,12 @@ export interface CifsRecoverySource {
}
export interface DiskInfo {
logicalname: string,
vendor: string | null,
model: string | null,
partitions: PartitionInfo[],
capacity: number,
guid: string | null, // cant back up if guid exists
logicalname: string
vendor: string | null
model: string | null
partitions: PartitionInfo[]
capacity: number
guid: string | null // cant back up if guid exists
}
export interface RecoveryStatusRes {
@@ -90,9 +90,9 @@ export interface RecoveryStatusRes {
}
export interface PartitionInfo {
logicalname: string,
label: string | null,
capacity: number,
used: number | null,
'embassy-os': EmbassyOSRecoveryInfo | null,
logicalname: string
label: string | null
capacity: number
used: number | null
'embassy-os': EmbassyOSRecoveryInfo | null
}

View File

@@ -1,49 +1,71 @@
import { Injectable } from '@angular/core'
import { ApiService, CifsRecoverySource, DiskInfo, DiskListResponse, DiskRecoverySource, EmbassyOSRecoveryInfo, GetStatusRes, RecoveryStatusRes, SetupEmbassyReq, SetupEmbassyRes } from './api.service'
import {
ApiService,
CifsRecoverySource,
DiskInfo,
DiskListResponse,
DiskRecoverySource,
EmbassyOSRecoveryInfo,
GetStatusRes,
RecoveryStatusRes,
SetupEmbassyReq,
SetupEmbassyRes,
} from './api.service'
import { HttpService } from './http.service'
@Injectable({
providedIn: 'root',
})
export class LiveApiService extends ApiService {
constructor (
private readonly http: HttpService,
) { super() }
constructor(private readonly http: HttpService) {
super()
}
// ** UNENCRYPTED **
async getStatus () {
return this.http.rpcRequest<GetStatusRes>({
method: 'setup.status',
params: { },
}, false)
async getStatus() {
return this.http.rpcRequest<GetStatusRes>(
{
method: 'setup.status',
params: {},
},
false,
)
}
async getDrives () {
return this.http.rpcRequest<DiskListResponse>({
method: 'setup.disk.list',
params: { },
}, false)
async getDrives() {
return this.http.rpcRequest<DiskListResponse>(
{
method: 'setup.disk.list',
params: {},
},
false,
)
}
async set02XDrive (logicalname) {
return this.http.rpcRequest<void>({
method: 'setup.recovery.v2.set',
params: { logicalname },
}, false)
async set02XDrive(logicalname) {
return this.http.rpcRequest<void>(
{
method: 'setup.recovery.v2.set',
params: { logicalname },
},
false,
)
}
async getRecoveryStatus () {
return this.http.rpcRequest<RecoveryStatusRes>({
method: 'setup.recovery.status',
params: { },
}, false)
async getRecoveryStatus() {
return this.http.rpcRequest<RecoveryStatusRes>(
{
method: 'setup.recovery.status',
params: {},
},
false,
)
}
// ** ENCRYPTED **
async verifyCifs (source: CifsRecoverySource) {
async verifyCifs(source: CifsRecoverySource) {
source.path = source.path.replace('/\\/g', '/')
return this.http.rpcRequest<EmbassyOSRecoveryInfo>({
method: 'setup.cifs.verify',
@@ -51,14 +73,14 @@ export class LiveApiService extends ApiService {
})
}
async verifyProductKey () {
async verifyProductKey() {
return this.http.rpcRequest<void>({
method: 'echo',
params: { 'message': 'hello' },
params: { message: 'hello' },
})
}
async importDrive (guid: string) {
async importDrive(guid: string) {
const res = await this.http.rpcRequest<SetupEmbassyRes>({
method: 'setup.attach',
params: { guid },
@@ -70,9 +92,11 @@ export class LiveApiService extends ApiService {
}
}
async setupEmbassy (setupInfo: SetupEmbassyReq) {
async setupEmbassy(setupInfo: SetupEmbassyReq) {
if (isCifsSource(setupInfo['recovery-source'])) {
setupInfo['recovery-source'].path = setupInfo['recovery-source'].path.replace('/\\/g', '/')
setupInfo['recovery-source'].path = setupInfo[
'recovery-source'
].path.replace('/\\/g', '/')
}
const res = await this.http.rpcRequest<SetupEmbassyRes>({
@@ -86,14 +110,16 @@ export class LiveApiService extends ApiService {
}
}
async setupComplete () {
await this.http.rpcRequest<SetupEmbassyRes>({
async setupComplete() {
return this.http.rpcRequest<SetupEmbassyRes>({
method: 'setup.complete',
params: { },
params: {},
})
}
}
function isCifsSource (source: CifsRecoverySource | DiskRecoverySource | undefined): source is CifsRecoverySource {
function isCifsSource(
source: CifsRecoverySource | DiskRecoverySource | undefined,
): source is CifsRecoverySource {
return !!(source as CifsRecoverySource)?.hostname
}

View File

@@ -96,6 +96,7 @@ export class MockApiService extends ApiService {
async setupComplete() {
await pauseFor(1000)
return setupRes
}
}

View File

@@ -91,4 +91,11 @@ export class StateService {
this.lanAddress = ret['lan-address']
this.cert = ret['root-ca']
}
async completeEmbassy(): Promise<void> {
const ret = await this.apiService.setupComplete()
this.torAddress = ret['tor-address']
this.lanAddress = ret['lan-address']
this.cert = ret['root-ca']
}
}