diff options
author | Florian Dold <florian@dold.me> | 2022-10-19 15:44:28 +0200 |
---|---|---|
committer | Florian Dold <florian@dold.me> | 2022-10-19 15:44:28 +0200 |
commit | c2e7510cecf4a0cf12fb8419a3f25173f2452be8 (patch) | |
tree | ccf6d35587fe8d7afa0ab9f3ff5cac6cf7c4fe7e /packages/taler-wallet-embedded/src/index.ts | |
parent | ec7a3c81332f2e1254bf2c362ffcdd3977041b09 (diff) | |
download | wallet-core-c2e7510cecf4a0cf12fb8419a3f25173f2452be8.tar.xz |
embedded wallet: improve 'init' request
Allow specifying crypto worker type, pass through version info from
'initWallet'.
Diffstat (limited to 'packages/taler-wallet-embedded/src/index.ts')
-rw-r--r-- | packages/taler-wallet-embedded/src/index.ts | 30 |
1 files changed, 20 insertions, 10 deletions
diff --git a/packages/taler-wallet-embedded/src/index.ts b/packages/taler-wallet-embedded/src/index.ts index 64b12f63c..a4de23151 100644 --- a/packages/taler-wallet-embedded/src/index.ts +++ b/packages/taler-wallet-embedded/src/index.ts @@ -18,31 +18,30 @@ * Imports. */ import { - getDefaultNodeWallet, DefaultNodeWalletArgs, - NodeHttpLib, + getDefaultNodeWallet, + getErrorDetailFromException, handleWorkerError, handleWorkerMessage, + Headers, HttpRequestLibrary, - OpenedPromise, - HttpResponse, HttpRequestOptions, + HttpResponse, + NodeHttpLib, + OpenedPromise, openPromise, - Headers, + Wallet, WALLET_EXCHANGE_PROTOCOL_VERSION, WALLET_MERCHANT_PROTOCOL_VERSION, - Wallet, - getErrorDetailFromException, } from "@gnu-taler/taler-wallet-core"; -import fs from "fs"; import { CoreApiEnvelope, CoreApiResponse, CoreApiResponseSuccess, WalletNotification, - TalerErrorCode, } from "@gnu-taler/taler-util"; +import fs from "fs"; export { handleWorkerError, handleWorkerMessage }; @@ -175,10 +174,17 @@ class NativeWalletMessageHandler { }; }; + let initResponse: any = {}; + const reinit = async () => { const w = await getDefaultNodeWallet(this.walletArgs); this.maybeWallet = w; - await w.handleCoreApiRequest("initWallet", "native-init", {}); + const resp = await w.handleCoreApiRequest( + "initWallet", + "native-init", + {}, + ); + initResponse = resp.type == "response" ? resp.result : resp.error; w.runTaskLoop().catch((e) => { console.error("Error during wallet retry loop", e); }); @@ -193,13 +199,17 @@ class NativeWalletMessageHandler { }, persistentStoragePath: args.persistentStoragePath, httpLib: this.httpLib, + cryptoWorkerType: args.cryptoWorkerType, }; await reinit(); return wrapResponse({ + // FIXME: Only for Android compatibility, should be removed + // once changed on Android. supported_protocol_versions: { exchange: WALLET_EXCHANGE_PROTOCOL_VERSION, merchant: WALLET_MERCHANT_PROTOCOL_VERSION, }, + ...initResponse, }); } case "startTunnel": { |