aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Dold <florian@dold.me>2022-10-19 15:44:28 +0200
committerFlorian Dold <florian@dold.me>2022-10-19 15:44:28 +0200
commitc2e7510cecf4a0cf12fb8419a3f25173f2452be8 (patch)
treeccf6d35587fe8d7afa0ab9f3ff5cac6cf7c4fe7e
parentec7a3c81332f2e1254bf2c362ffcdd3977041b09 (diff)
embedded wallet: improve 'init' request
Allow specifying crypto worker type, pass through version info from 'initWallet'.
-rw-r--r--packages/taler-wallet-core/src/headless/helpers.ts1
-rw-r--r--packages/taler-wallet-embedded/src/index.ts30
2 files changed, 21 insertions, 10 deletions
diff --git a/packages/taler-wallet-core/src/headless/helpers.ts b/packages/taler-wallet-core/src/headless/helpers.ts
index df4474271..cef7c94d9 100644
--- a/packages/taler-wallet-core/src/headless/helpers.ts
+++ b/packages/taler-wallet-core/src/headless/helpers.ts
@@ -174,6 +174,7 @@ export async function getDefaultNodeWallet2(
const worker_threads = module[_r]("worker_threads");
// require("worker_threads");
workerFactory = new NodeThreadCryptoWorkerFactory();
+ logger.info("using node thread crypto worker");
} catch (e) {
logger.warn(
"worker threads not available, falling back to synchronous workers",
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": {