clean up code and logs (#1809)

abstract base64 functions and clean up console logs
This commit is contained in:
Matt Hill
2022-09-19 12:59:41 -06:00
committed by GitHub
parent f04b90d9c6
commit 1150f4c438
13 changed files with 27 additions and 32 deletions

View File

@@ -104,7 +104,6 @@ export class SuccessPage {
checkBottom() {
const bottomDiv = document.getElementById('bottom-div')
console.error(bottomDiv)
this.isOnBottom =
!!bottomDiv &&
bottomDiv.getBoundingClientRect().top - 192 < window.innerHeight

View File

@@ -1,5 +1,6 @@
import { Injectable } from '@angular/core'
import {
encodeBase64,
HttpService,
isRpcError,
RpcError,
@@ -48,21 +49,13 @@ export class LiveApiService implements ApiService {
async getSecret() {
const keystore = jose.JWK.createKeyStore()
const key = await keystore.generate('EC', 'P-256')
// const { privateKey, publicKey } =
// jose.generateKeyPair('ECDH-ES', {
// extractable: true,
// })
console.log({ publicKey: key.toJSON() })
const response: string = await this.rpcRequest({
method: 'setup.get-secret',
params: { pubkey: key.toJSON() },
})
// const { plaintext } = await jose.compactDecrypt(response, privateKey)
const decrypted = await jose.JWE.createDecrypt(key).decrypt(response)
const decoded = new TextDecoder().decode(decrypted.plaintext)
console.log({ decoded })
return decoded
}
@@ -106,7 +99,7 @@ export class LiveApiService implements ApiService {
return {
...res,
'root-ca': btoa(res['root-ca']),
'root-ca': encodeBase64(res['root-ca']),
}
}
@@ -124,7 +117,7 @@ export class LiveApiService implements ApiService {
return {
...res,
'root-ca': btoa(res['root-ca']),
'root-ca': encodeBase64(res['root-ca']),
}
}
@@ -136,7 +129,7 @@ export class LiveApiService implements ApiService {
return {
...res,
'root-ca': btoa(res['root-ca']),
'root-ca': encodeBase64(res['root-ca']),
}
}

View File

@@ -1,5 +1,5 @@
import { Injectable } from '@angular/core'
import { pauseFor } from '@start9labs/shared'
import { encodeBase64, pauseFor } from '@start9labs/shared'
import {
ApiService,
CifsRecoverySource,
@@ -131,7 +131,7 @@ YJidaq7je6k18AdgPA0Kh8y1XtfUH3fTaVw4
const setupRes = {
'tor-address': 'http://asdafsadasdasasdasdfasdfasdf.onion',
'lan-address': 'https://embassy-abcdefgh.local',
'root-ca': btoa(rootCA),
'root-ca': encodeBase64(rootCA),
}
const disks = [

View File

@@ -37,10 +37,6 @@ export class RPCEncryptedService {
},
})
.then(res => AES_CTR.decryptPbkdf2(this.secret || '', res.body))
.then(x => {
console.log(`Network: ${x}`)
return x
})
.then(res => JSON.parse(res))
.catch(e => {
if (!e.status && !e.statusText) {

View File

@@ -8,5 +8,6 @@ if (environment.production) {
enableProdMode()
}
platformBrowserDynamic().bootstrapModule(AppModule)
.catch(err => console.log(err))
platformBrowserDynamic()
.bootstrapModule(AppModule)
.catch(err => console.error(err))