feat: enable strictNullChecks

feat: enable `noImplicitAny`

chore: remove sync data access

fix loading package data for affected dependencies

chore: properly get alt marketplace data

update patchdb client to allow for emit on undefined values
This commit is contained in:
waterplea
2022-05-26 18:20:31 +03:00
committed by Lucy C
parent 948fb795f2
commit 0390954a85
99 changed files with 674 additions and 535 deletions

View File

@@ -15,7 +15,7 @@ import { HttpError, RpcError } from '@start9labs/shared'
})
export class HttpService {
fullUrl: string
productKey: string
productKey?: string
constructor(private readonly http: HttpClient) {
const port = window.location.port
@@ -43,6 +43,8 @@ export class HttpService {
}
if (isRpcSuccess(res)) return res.result
throw new Error('Unknown RPC response')
}
async encryptedHttpRequest<T>(httpOpts: {
@@ -53,7 +55,7 @@ export class HttpService {
const url = urlIsRelative ? this.fullUrl + httpOpts.url : httpOpts.url
const encryptedBody = await AES_CTR.encryptPbkdf2(
this.productKey,
this.productKey || '',
encodeUtf8(JSON.stringify(httpOpts.body)),
)
const options = {
@@ -74,7 +76,7 @@ export class HttpService {
.toPromise()
.then(res =>
AES_CTR.decryptPbkdf2(
this.productKey,
this.productKey || '',
(res as any).body as ArrayBuffer,
),
)
@@ -206,7 +208,7 @@ type AES_CTR = {
secretKey: string,
messageBuffer: Uint8Array,
) => Promise<Uint8Array>
decryptPbkdf2: (secretKey, arr: ArrayBuffer) => Promise<string>
decryptPbkdf2: (secretKey: string, arr: ArrayBuffer) => Promise<string>
}
export const AES_CTR: AES_CTR = {
@@ -243,8 +245,10 @@ export const AES_CTR: AES_CTR = {
export const encode16 = (buffer: Uint8Array) =>
buffer.reduce((str, byte) => str + byte.toString(16).padStart(2, '0'), '')
export const decode16 = hexString =>
new Uint8Array(hexString.match(/.{1,2}/g).map(byte => parseInt(byte, 16)))
export const decode16 = (hexString: string) =>
new Uint8Array(
hexString.match(/.{1,2}/g)?.map(byte => parseInt(byte, 16)) || [],
)
export function encodeUtf8(str: string): Uint8Array {
const encoder = new TextEncoder()

View File

@@ -43,7 +43,7 @@ export class LiveApiService extends ApiService {
)
}
async set02XDrive(logicalname) {
async set02XDrive(logicalname: string) {
return this.http.rpcRequest<void>(
{
method: 'setup.recovery.v2.set',
@@ -124,7 +124,7 @@ export class LiveApiService extends ApiService {
}
function isCifsSource(
source: CifsRecoverySource | DiskRecoverySource | undefined,
source: CifsRecoverySource | DiskRecoverySource | null,
): source is CifsRecoverySource {
return !!(source as CifsRecoverySource)?.hostname
}

View File

@@ -18,7 +18,7 @@ export class StateService {
embassyLoaded = false
recoverySource: CifsRecoverySource | DiskRecoverySource
recoveryPassword: string
recoveryPassword?: string
dataTransferProgress: {
bytesTransferred: number