diff options
Diffstat (limited to 'packages/taler-wallet-embedded')
-rw-r--r-- | packages/taler-wallet-embedded/src/wallet-qjs.ts | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/packages/taler-wallet-embedded/src/wallet-qjs.ts b/packages/taler-wallet-embedded/src/wallet-qjs.ts index c4178e596..f7b73711c 100644 --- a/packages/taler-wallet-embedded/src/wallet-qjs.ts +++ b/packages/taler-wallet-embedded/src/wallet-qjs.ts @@ -37,6 +37,7 @@ import { CoreApiMessageEnvelope, CoreApiResponse, CoreApiResponseSuccess, + InitRequest, j2s, Logger, setGlobalLogLevelFromString, @@ -265,6 +266,7 @@ export async function getWallet(args: DefaultNodeWalletArgs = {}): Promise<{ class NativeWalletMessageHandler { walletArgs: DefaultNodeWalletArgs | undefined; + initRequest: InitRequest = {}; maybeWallet: Wallet | undefined; wp = openPromise<Wallet>(); httpLib = new NativeHttpLib(); @@ -293,11 +295,9 @@ class NativeWalletMessageHandler { const wR = await getWallet(this.walletArgs); const w = wR.wallet; this.maybeWallet = w; - const resp = await w.handleCoreApiRequest( - "initWallet", - "native-init", - {...this.walletArgs}, - ); + const resp = await w.handleCoreApiRequest("initWallet", "native-init", { + ...this.initRequest, + }); initResponse = resp.type == "response" ? resp.result : resp.error; w.runTaskLoop().catch((e) => { logger.error( @@ -309,8 +309,10 @@ class NativeWalletMessageHandler { switch (operation) { case "init": { - this.walletArgs = { + this.initRequest = { ...args, + }; + this.walletArgs = { notifyHandler: async (notification: WalletNotification) => { sendNativeMessage({ type: "notification", payload: notification }); }, @@ -318,6 +320,10 @@ class NativeWalletMessageHandler { httpLib: this.httpLib, cryptoWorkerType: args.cryptoWorkerType, }; + const logLevel = args.logLevel; + if (logLevel) { + setGlobalLogLevelFromString(logLevel); + } await reinit(); return wrapResponse({ ...initResponse, @@ -383,7 +389,11 @@ export function installNativeWalletListener(): void { logger.info(`native listener: got request for ${operation} (${id})`); try { - const respMsg = await handler.handleMessage(operation, id, msg.args ?? {}); + const respMsg = await handler.handleMessage( + operation, + id, + msg.args ?? {}, + ); logger.info( `native listener: sending success response for ${operation} (${id})`, ); @@ -400,7 +410,7 @@ export function installNativeWalletListener(): void { } }; - qjsOs.setMessageFromHostHandler((m) => onMessage(m)) + qjsOs.setMessageFromHostHandler((m) => onMessage(m)); logger.info("native wallet listener installed"); } |