mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-26 02:11:53 +00:00
clean up code and logs (#1809)
abstract base64 functions and clean up console logs
This commit is contained in:
@@ -4,8 +4,9 @@ import { AppModule } from './app/app.module'
|
||||
import { environment } from './environments/environment'
|
||||
|
||||
if (environment.production) {
|
||||
enableProdMode();
|
||||
enableProdMode()
|
||||
}
|
||||
|
||||
platformBrowserDynamic().bootstrapModule(AppModule)
|
||||
.catch(err => console.log(err));
|
||||
platformBrowserDynamic()
|
||||
.bootstrapModule(AppModule)
|
||||
.catch(err => console.error(err))
|
||||
|
||||
@@ -69,7 +69,6 @@ export class FilterPackagesPipe implements PipeTransform {
|
||||
}
|
||||
|
||||
const fuse = new Fuse(packages, options)
|
||||
console.log(fuse.search(query))
|
||||
return fuse.search(query).map(p => p.item)
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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']),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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 = [
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -8,5 +8,6 @@ if (environment.production) {
|
||||
enableProdMode()
|
||||
}
|
||||
|
||||
platformBrowserDynamic().bootstrapModule(AppModule)
|
||||
.catch(err => console.log(err))
|
||||
platformBrowserDynamic()
|
||||
.bootstrapModule(AppModule)
|
||||
.catch(err => console.error(err))
|
||||
|
||||
@@ -46,6 +46,7 @@ export * from './types/url'
|
||||
export * from './types/workspace-config'
|
||||
|
||||
export * from './util/copy-to-clipboard'
|
||||
export * from './util/base-64'
|
||||
export * from './util/get-pkg-id'
|
||||
export * from './util/misc.util'
|
||||
export * from './util/rpc.util'
|
||||
|
||||
@@ -11,7 +11,6 @@ export class DownloadHTMLService {
|
||||
.join(';')
|
||||
const styleString = entries ? `<style>html{${entries}}></style>` : ''
|
||||
|
||||
console.log('STYLES', styleString)
|
||||
html = styleString + html
|
||||
|
||||
const elem = this.document.createElement('a')
|
||||
|
||||
9
frontend/projects/shared/src/util/base-64.ts
Normal file
9
frontend/projects/shared/src/util/base-64.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
import * as Base64 from 'base64-js'
|
||||
|
||||
export function encodeBase64(text: string) {
|
||||
return Base64.fromByteArray(new TextEncoder().encode(text))
|
||||
}
|
||||
|
||||
export function decodeBase64(encoded: string) {
|
||||
return new TextDecoder().decode(Base64.toByteArray(encoded))
|
||||
}
|
||||
@@ -70,7 +70,6 @@ export class LogsComponent {
|
||||
url: `/rpc/${guid}`,
|
||||
openObserver: {
|
||||
next: () => {
|
||||
console.log('**** LOGS WEBSOCKET OPEN ****')
|
||||
this.websocketFail = false
|
||||
this.processJob()
|
||||
},
|
||||
|
||||
@@ -216,7 +216,7 @@ export class WifiPage {
|
||||
}
|
||||
} catch (e) {
|
||||
attempts++
|
||||
console.error(e)
|
||||
console.warn(e)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { Inject, Injectable } from '@angular/core'
|
||||
import {
|
||||
decodeBase64,
|
||||
HttpOptions,
|
||||
HttpService,
|
||||
isRpcError,
|
||||
@@ -18,7 +19,6 @@ import { AuthService } from '../auth.service'
|
||||
import { DOCUMENT } from '@angular/common'
|
||||
import { DataModel } from '../patch-db/data-model'
|
||||
import { PatchDB, Update } from 'patch-db-client'
|
||||
import * as Base64 from 'base64-js'
|
||||
|
||||
@Injectable()
|
||||
export class LiveApiService extends ApiService {
|
||||
@@ -420,15 +420,13 @@ export class LiveApiService extends ApiService {
|
||||
const encodedError = res.headers.get('x-patch-error')
|
||||
|
||||
if (encodedUpdates) {
|
||||
const decoded = new TextDecoder().decode(
|
||||
Base64.toByteArray(encodedUpdates),
|
||||
)
|
||||
const decoded = decodeBase64(encodedUpdates)
|
||||
const updates: Update<DataModel>[] = JSON.parse(decoded)
|
||||
this.patchStream$.next(updates)
|
||||
}
|
||||
|
||||
if (encodedError) {
|
||||
const error = new TextDecoder().decode(Base64.toByteArray(encodedError))
|
||||
const error = decodeBase64(encodedError)
|
||||
console.error(error)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user