aboutsummaryrefslogtreecommitdiff
path: root/packages/taler-wallet-android
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2020-08-12 12:41:00 +0530
committerFlorian Dold <florian.dold@gmail.com>2020-08-12 12:41:00 +0530
commitf180d0580457e1e9bd502293df327dfe138dd422 (patch)
tree11b9eecb7a74acf7cfe36ccbc3366905718d8a1d /packages/taler-wallet-android
parent0050bf005a40cab3b4fdc43f2960025e8d52e176 (diff)
remove excessive namespacing, format
Diffstat (limited to 'packages/taler-wallet-android')
-rw-r--r--packages/taler-wallet-android/package.json3
-rw-r--r--packages/taler-wallet-android/src/index.ts76
2 files changed, 38 insertions, 41 deletions
diff --git a/packages/taler-wallet-android/package.json b/packages/taler-wallet-android/package.json
index 52d45fe3f..7fdafa251 100644
--- a/packages/taler-wallet-android/package.json
+++ b/packages/taler-wallet-android/package.json
@@ -14,7 +14,7 @@
"license": "GPL-3.0",
"scripts": {
"compile": "tsc && rollup -c",
- "pretty": "prettier --config ../../.prettierrc --write src",
+ "pretty": "prettier --write src",
"test": "tsc && ava",
"coverage": "tsc && nyc ava",
"clean": "rimraf lib dist"
@@ -33,6 +33,7 @@
"@rollup/plugin-node-resolve": "^8.4.0",
"@rollup/plugin-replace": "^2.3.3",
"@types/node": "^14.0.27",
+ "prettier": "^2.0.5",
"rimraf": "^3.0.2",
"rollup": "^2.23.0",
"rollup-plugin-sourcemaps": "^0.6.2",
diff --git a/packages/taler-wallet-android/src/index.ts b/packages/taler-wallet-android/src/index.ts
index c949a4773..4430848c3 100644
--- a/packages/taler-wallet-android/src/index.ts
+++ b/packages/taler-wallet-android/src/index.ts
@@ -21,42 +21,47 @@ import {
Wallet,
getDefaultNodeWallet,
DefaultNodeWalletArgs,
- versions,
- httpLib,
- nodeThreadWorker,
- promiseUtil,
NodeHttpLib,
- walletCoreApi,
- walletNotifications,
TalerErrorCode,
makeErrorDetails,
+ handleWorkerError,
+ handleWorkerMessage,
+ HttpRequestLibrary,
+ OpenedPromise,
+ HttpResponse,
+ HttpRequestOptions,
+ openPromise,
+ Headers,
+ CoreApiEnvelope,
+ CoreApiResponse,
+ CoreApiResponseSuccess,
+ WalletNotification,
+ WALLET_EXCHANGE_PROTOCOL_VERSION,
+ WALLET_MERCHANT_PROTOCOL_VERSION,
+ handleCoreApiRequest,
} from "taler-wallet-core";
import fs from "fs";
-export const handleWorkerError = nodeThreadWorker.handleWorkerError;
-export const handleWorkerMessage = nodeThreadWorker.handleWorkerMessage;
+export { handleWorkerError, handleWorkerMessage };
-export class AndroidHttpLib implements httpLib.HttpRequestLibrary {
+export class AndroidHttpLib implements HttpRequestLibrary {
useNfcTunnel = false;
- private nodeHttpLib: httpLib.HttpRequestLibrary = new NodeHttpLib();
+ private nodeHttpLib: HttpRequestLibrary = new NodeHttpLib();
private requestId = 1;
private requestMap: {
- [id: number]: promiseUtil.OpenedPromise<httpLib.HttpResponse>;
+ [id: number]: OpenedPromise<HttpResponse>;
} = {};
constructor(private sendMessage: (m: string) => void) {}
- get(
- url: string,
- opt?: httpLib.HttpRequestOptions,
- ): Promise<httpLib.HttpResponse> {
+ get(url: string, opt?: HttpRequestOptions): Promise<HttpResponse> {
if (this.useNfcTunnel) {
const myId = this.requestId++;
- const p = promiseUtil.openPromise<httpLib.HttpResponse>();
+ const p = openPromise<HttpResponse>();
this.requestMap[myId] = p;
const request = {
method: "get",
@@ -78,11 +83,11 @@ export class AndroidHttpLib implements httpLib.HttpRequestLibrary {
postJson(
url: string,
body: any,
- opt?: httpLib.HttpRequestOptions,
- ): Promise<httpLib.HttpResponse> {
+ opt?: HttpRequestOptions,
+ ): Promise<HttpResponse> {
if (this.useNfcTunnel) {
const myId = this.requestId++;
- const p = promiseUtil.openPromise<httpLib.HttpResponse>();
+ const p = openPromise<HttpResponse>();
this.requestMap[myId] = p;
const request = {
method: "postJson",
@@ -106,9 +111,9 @@ export class AndroidHttpLib implements httpLib.HttpRequestLibrary {
`no matching request for tunneled HTTP response, id=${myId}`,
);
}
- const headers = new httpLib.Headers();
+ const headers = new Headers();
if (msg.status != 0) {
- const resp: httpLib.HttpResponse = {
+ const resp: HttpResponse = {
// FIXME: pass through this URL
requestUrl: "",
headers,
@@ -125,7 +130,7 @@ export class AndroidHttpLib implements httpLib.HttpRequestLibrary {
}
}
-function sendAkonoMessage(ev: walletCoreApi.CoreApiEnvelope): void {
+function sendAkonoMessage(ev: CoreApiEnvelope): void {
// @ts-ignore
const sendMessage = globalThis.__akono_sendMessage;
if (typeof sendMessage !== "function") {
@@ -142,7 +147,7 @@ function sendAkonoMessage(ev: walletCoreApi.CoreApiEnvelope): void {
class AndroidWalletMessageHandler {
walletArgs: DefaultNodeWalletArgs | undefined;
maybeWallet: Wallet | undefined;
- wp = promiseUtil.openPromise<Wallet>();
+ wp = openPromise<Wallet>();
httpLib = new NodeHttpLib();
/**
@@ -152,10 +157,8 @@ class AndroidWalletMessageHandler {
operation: string,
id: string,
args: any,
- ): Promise<walletCoreApi.CoreApiResponse> {
- const wrapResponse = (
- result: unknown,
- ): walletCoreApi.CoreApiResponseSuccess => {
+ ): Promise<CoreApiResponse> {
+ const wrapResponse = (result: unknown): CoreApiResponseSuccess => {
return {
type: "response",
id,
@@ -166,9 +169,7 @@ class AndroidWalletMessageHandler {
switch (operation) {
case "init": {
this.walletArgs = {
- notifyHandler: async (
- notification: walletNotifications.WalletNotification,
- ) => {
+ notifyHandler: async (notification: WalletNotification) => {
sendAkonoMessage({ type: "notification", payload: notification });
},
persistentStoragePath: args.persistentStoragePath,
@@ -182,8 +183,8 @@ class AndroidWalletMessageHandler {
this.wp.resolve(w);
return wrapResponse({
supported_protocol_versions: {
- exchange: versions.WALLET_EXCHANGE_PROTOCOL_VERSION,
- merchant: versions.WALLET_MERCHANT_PROTOCOL_VERSION,
+ exchange: WALLET_EXCHANGE_PROTOCOL_VERSION,
+ merchant: WALLET_MERCHANT_PROTOCOL_VERSION,
},
});
}
@@ -216,7 +217,7 @@ class AndroidWalletMessageHandler {
}
const wallet = await this.wp.promise;
wallet.stop();
- this.wp = promiseUtil.openPromise<Wallet>();
+ this.wp = openPromise<Wallet>();
this.maybeWallet = undefined;
const w = await getDefaultNodeWallet(this.walletArgs);
this.maybeWallet = w;
@@ -228,12 +229,7 @@ class AndroidWalletMessageHandler {
}
default: {
const wallet = await this.wp.promise;
- return await walletCoreApi.handleCoreApiRequest(
- wallet,
- operation,
- id,
- args,
- );
+ return await handleCoreApiRequest(wallet, operation, id, args);
}
}
}
@@ -264,7 +260,7 @@ export function installAndroidWalletListener(): void {
);
sendAkonoMessage(respMsg);
} catch (e) {
- const respMsg: walletCoreApi.CoreApiResponse = {
+ const respMsg: CoreApiResponse = {
type: "error",
id,
operation,