diff --git a/frontend/.prettierrc b/frontend/.prettierrc index f40419ad7..1091b889e 100644 --- a/frontend/.prettierrc +++ b/frontend/.prettierrc @@ -2,5 +2,6 @@ "singleQuote": true, "semi": false, "arrowParens": "avoid", - "trailingComma": "all" + "trailingComma": "all", + "htmlWhitespaceSensitivity": "ignore" } diff --git a/frontend/projects/ui/src/app/services/api/embassy-api.service.ts b/frontend/projects/ui/src/app/services/api/embassy-api.service.ts index 1c19d6a2e..0a729a133 100644 --- a/frontend/projects/ui/src/app/services/api/embassy-api.service.ts +++ b/frontend/projects/ui/src/app/services/api/embassy-api.service.ts @@ -4,20 +4,24 @@ import { RR, Encrypted } from './api.types' import { DataModel } from 'src/app/services/patch-db/data-model' import { Log } from '@start9labs/shared' import { WebSocketSubjectConfig } from 'rxjs/webSocket' -import * as jose from 'node-jose' +import type { JWK } from 'node-jose' export abstract class ApiService { + protected readonly jose = import('node-jose') + readonly patchStream$ = new BehaviorSubject[]>([]) - pubkey?: jose.JWK.Key + pubkey?: JWK.Key async encrypt(toEncrypt: string): Promise { - if (!this.pubkey) throw new Error('No pubkey found!') - const encrypted = await jose.JWE.createEncrypt(this.pubkey!) - .update(toEncrypt) - .final() - return { - encrypted, - } + const { pubkey } = this + + if (!pubkey) throw new Error('No pubkey found!') + + const encrypted = await this.jose.then(jose => + jose.JWE.createEncrypt(pubkey).update(toEncrypt).final(), + ) + + return { encrypted } } // http diff --git a/frontend/projects/ui/src/app/services/api/embassy-mock-api.service.ts b/frontend/projects/ui/src/app/services/api/embassy-mock-api.service.ts index 531c85e1f..18c0c41ac 100644 --- a/frontend/projects/ui/src/app/services/api/embassy-mock-api.service.ts +++ b/frontend/projects/ui/src/app/services/api/embassy-mock-api.service.ts @@ -38,7 +38,6 @@ import { WebSocketSubjectConfig } from 'rxjs/webSocket' import { AuthService } from '../auth.service' import { ConnectionService } from '../connection.service' import { StoreInfo } from '@start9labs/marketplace' -import * as jose from 'node-jose' const PROGRESS: InstallProgress = { size: 120, @@ -122,12 +121,14 @@ export class MockApiService extends ApiService { // this.pubkey = await keystore.generate('EC', 'P-256') // generated from backend - this.pubkey = await jose.JWK.asKey({ - kty: 'EC', - crv: 'P-256', - x: 'yHTDYSfjU809fkSv9MmN4wuojf5c3cnD7ZDN13n-jz4', - y: '8Mpkn744A5KDag0DmX2YivB63srjbugYZzWc3JOpQXI', - }) + this.pubkey = await this.jose.then(jose => + jose.JWK.asKey({ + kty: 'EC', + crv: 'P-256', + x: 'yHTDYSfjU809fkSv9MmN4wuojf5c3cnD7ZDN13n-jz4', + y: '8Mpkn744A5KDag0DmX2YivB63srjbugYZzWc3JOpQXI', + }), + ) } async login(params: RR.LoginReq): Promise {