change taler-wallet-android to taler-wallet-embedded

This commit is contained in:
Jonathan Buchanan 2021-07-07 02:42:55 -04:00
parent 678a90934c
commit ff09c98f3b
No known key found for this signature in database
GPG Key ID: 476CBCAEE3E1096C
5 changed files with 96 additions and 97 deletions

View File

@ -1,5 +1,5 @@
{ {
"name": "@gnu-taler/taler-wallet-android", "name": "@gnu-taler/taler-wallet-embedded",
"version": "0.8.0", "version": "0.8.0",
"description": "", "description": "",
"engines": { "engines": {
@ -9,7 +9,7 @@
"type": "git", "type": "git",
"url": "git://git.taler.net/wallet-core.git" "url": "git://git.taler.net/wallet-core.git"
}, },
"main": "dist/taler-wallet-android.js", "main": "dist/taler-wallet-embedded.js",
"author": "Florian Dold", "author": "Florian Dold",
"license": "GPL-3.0", "license": "GPL-3.0",
"scripts": { "scripts": {

View File

@ -46,7 +46,7 @@ import {
export { handleWorkerError, handleWorkerMessage }; export { handleWorkerError, handleWorkerMessage };
export class AndroidHttpLib implements HttpRequestLibrary { export class NativeHttpLib implements HttpRequestLibrary {
useNfcTunnel = false; useNfcTunnel = false;
private nodeHttpLib: HttpRequestLibrary = new NodeHttpLib(); private nodeHttpLib: HttpRequestLibrary = new NodeHttpLib();
@ -138,12 +138,12 @@ export class AndroidHttpLib implements HttpRequestLibrary {
} }
} }
function sendAkonoMessage(ev: CoreApiEnvelope): void { function sendNativeMessage(ev: CoreApiEnvelope): void {
// @ts-ignore // @ts-ignore
const sendMessage = globalThis.__akono_sendMessage; const sendMessage = globalThis.__native_sendMessage;
if (typeof sendMessage !== "function") { if (typeof sendMessage !== "function") {
const errMsg = const errMsg =
"FATAL: cannot install android wallet listener: akono functions missing"; "FATAL: cannot install native wallet listener: native functions missing";
console.error(errMsg); console.error(errMsg);
throw new Error(errMsg); throw new Error(errMsg);
} }
@ -152,14 +152,14 @@ function sendAkonoMessage(ev: CoreApiEnvelope): void {
sendMessage(m); sendMessage(m);
} }
class AndroidWalletMessageHandler { class NativeWalletMessageHandler {
walletArgs: DefaultNodeWalletArgs | undefined; walletArgs: DefaultNodeWalletArgs | undefined;
maybeWallet: Wallet | undefined; maybeWallet: Wallet | undefined;
wp = openPromise<Wallet>(); wp = openPromise<Wallet>();
httpLib = new NodeHttpLib(); httpLib = new NodeHttpLib();
/** /**
* Handle a request from the Android wallet. * Handle a request from the native wallet.
*/ */
async handleMessage( async handleMessage(
operation: string, operation: string,
@ -178,7 +178,7 @@ class AndroidWalletMessageHandler {
const reinit = async () => { const reinit = async () => {
const w = await getDefaultNodeWallet(this.walletArgs); const w = await getDefaultNodeWallet(this.walletArgs);
this.maybeWallet = w; this.maybeWallet = w;
await w.handleCoreApiRequest("initWallet", "akono-init", {}); await w.handleCoreApiRequest("initWallet", "native-init", {});
w.runRetryLoop().catch((e) => { w.runRetryLoop().catch((e) => {
console.error("Error during wallet retry loop", e); console.error("Error during wallet retry loop", e);
}); });
@ -189,7 +189,7 @@ class AndroidWalletMessageHandler {
case "init": { case "init": {
this.walletArgs = { this.walletArgs = {
notifyHandler: async (notification: WalletNotification) => { notifyHandler: async (notification: WalletNotification) => {
sendAkonoMessage({ type: "notification", payload: notification }); sendNativeMessage({ type: "notification", payload: notification });
}, },
persistentStoragePath: args.persistentStoragePath, persistentStoragePath: args.persistentStoragePath,
httpLib: this.httpLib, httpLib: this.httpLib,
@ -241,8 +241,8 @@ class AndroidWalletMessageHandler {
} }
} }
export function installAndroidWalletListener(): void { export function installNativeWalletListener(): void {
const handler = new AndroidWalletMessageHandler(); const handler = new NativeWalletMessageHandler();
const onMessage = async (msgStr: any): Promise<void> => { const onMessage = async (msgStr: any): Promise<void> => {
if (typeof msgStr !== "string") { if (typeof msgStr !== "string") {
console.error("expected string as message"); console.error("expected string as message");
@ -252,19 +252,19 @@ export function installAndroidWalletListener(): void {
const operation = msg.operation; const operation = msg.operation;
if (typeof operation !== "string") { if (typeof operation !== "string") {
console.error( console.error(
"message to android wallet helper must contain operation of type string", "message to native wallet helper must contain operation of type string",
); );
return; return;
} }
const id = msg.id; const id = msg.id;
console.log(`android listener: got request for ${operation} (${id})`); console.log(`native listener: got request for ${operation} (${id})`);
try { try {
const respMsg = await handler.handleMessage(operation, id, msg.args); const respMsg = await handler.handleMessage(operation, id, msg.args);
console.log( console.log(
`android listener: sending success response for ${operation} (${id})`, `native listener: sending success response for ${operation} (${id})`,
); );
sendAkonoMessage(respMsg); sendNativeMessage(respMsg);
} catch (e) { } catch (e) {
const respMsg: CoreApiResponse = { const respMsg: CoreApiResponse = {
type: "error", type: "error",
@ -276,13 +276,13 @@ export function installAndroidWalletListener(): void {
{}, {},
), ),
}; };
sendAkonoMessage(respMsg); sendNativeMessage(respMsg);
return; return;
} }
}; };
// @ts-ignore // @ts-ignore
globalThis.__akono_onMessage = onMessage; globalThis.__native_onMessage = onMessage;
console.log("android wallet listener installed"); console.log("native wallet listener installed");
} }

View File

@ -62,37 +62,6 @@ importers:
rimraf: 3.0.2 rimraf: 3.0.2
typescript: 4.2.3 typescript: 4.2.3
packages/taler-wallet-android:
specifiers:
'@gnu-taler/taler-wallet-core': workspace:*
'@rollup/plugin-commonjs': ^17.0.0
'@rollup/plugin-json': ^4.1.0
'@rollup/plugin-node-resolve': ^11.1.0
'@rollup/plugin-replace': ^2.3.4
'@types/node': ^14.14.22
prettier: ^2.2.1
rimraf: ^3.0.2
rollup: ^2.43.0
rollup-plugin-sourcemaps: ^0.6.3
rollup-plugin-terser: ^7.0.2
tslib: ^2.1.0
typescript: ^4.2.3
dependencies:
'@gnu-taler/taler-wallet-core': link:../taler-wallet-core
tslib: 2.1.0
devDependencies:
'@rollup/plugin-commonjs': 17.0.0_rollup@2.43.0
'@rollup/plugin-json': 4.1.0_rollup@2.43.0
'@rollup/plugin-node-resolve': 11.1.0_rollup@2.43.0
'@rollup/plugin-replace': 2.3.4_rollup@2.43.0
'@types/node': 14.14.22
prettier: 2.2.1
rimraf: 3.0.2
rollup: 2.43.0
rollup-plugin-sourcemaps: 0.6.3_79665b55c550dd6b792bac22e5c7c20e
rollup-plugin-terser: 7.0.2_rollup@2.43.0
typescript: 4.2.3
packages/taler-wallet-cli: packages/taler-wallet-cli:
specifiers: specifiers:
'@gnu-taler/taler-util': workspace:* '@gnu-taler/taler-util': workspace:*
@ -203,6 +172,37 @@ importers:
typedoc: 0.20.16_typescript@4.1.3 typedoc: 0.20.16_typescript@4.1.3
typescript: 4.1.3 typescript: 4.1.3
packages/taler-wallet-embedded:
specifiers:
'@gnu-taler/taler-wallet-core': workspace:*
'@rollup/plugin-commonjs': ^17.0.0
'@rollup/plugin-json': ^4.1.0
'@rollup/plugin-node-resolve': ^11.1.0
'@rollup/plugin-replace': ^2.3.4
'@types/node': ^14.14.22
prettier: ^2.2.1
rimraf: ^3.0.2
rollup: ^2.43.0
rollup-plugin-sourcemaps: ^0.6.3
rollup-plugin-terser: ^7.0.2
tslib: ^2.1.0
typescript: ^4.2.3
dependencies:
'@gnu-taler/taler-wallet-core': link:../taler-wallet-core
tslib: 2.2.0
devDependencies:
'@rollup/plugin-commonjs': 17.1.0_rollup@2.43.0
'@rollup/plugin-json': 4.1.0_rollup@2.43.0
'@rollup/plugin-node-resolve': 11.2.0_rollup@2.43.0
'@rollup/plugin-replace': 2.4.2_rollup@2.43.0
'@types/node': 14.17.1
prettier: 2.2.1
rimraf: 3.0.2
rollup: 2.43.0
rollup-plugin-sourcemaps: 0.6.3_6efbbae6640434994627e0ab519821c6
rollup-plugin-terser: 7.0.2_rollup@2.43.0
typescript: 4.2.3
packages/taler-wallet-webextension: packages/taler-wallet-webextension:
specifiers: specifiers:
'@babel/core': ^7.14.0 '@babel/core': ^7.14.0
@ -3252,22 +3252,6 @@ packages:
rollup: 2.37.1 rollup: 2.37.1
dev: true dev: true
/@rollup/plugin-commonjs/17.0.0_rollup@2.43.0:
resolution: {integrity: sha512-/omBIJG1nHQc+bgkYDuLpb/V08QyutP9amOrJRUSlYJZP+b/68gM//D8sxJe3Yry2QnYIr3QjR3x4AlxJEN3GA==}
engines: {node: '>= 8.0.0'}
peerDependencies:
rollup: ^2.30.0
dependencies:
'@rollup/pluginutils': 3.1.0_rollup@2.43.0
commondir: 1.0.1
estree-walker: 2.0.2
glob: 7.1.6
is-reference: 1.2.1
magic-string: 0.25.7
resolve: 1.19.0
rollup: 2.43.0
dev: true
/@rollup/plugin-commonjs/17.1.0_rollup@2.37.1: /@rollup/plugin-commonjs/17.1.0_rollup@2.37.1:
resolution: {integrity: sha512-PoMdXCw0ZyvjpCMT5aV4nkL0QywxP29sODQsSGeDpr/oI49Qq9tRtAsb/LbYbDzFlOydVEqHmmZWFtXJEAX9ew==} resolution: {integrity: sha512-PoMdXCw0ZyvjpCMT5aV4nkL0QywxP29sODQsSGeDpr/oI49Qq9tRtAsb/LbYbDzFlOydVEqHmmZWFtXJEAX9ew==}
engines: {node: '>= 8.0.0'} engines: {node: '>= 8.0.0'}
@ -3284,6 +3268,22 @@ packages:
rollup: 2.37.1 rollup: 2.37.1
dev: true dev: true
/@rollup/plugin-commonjs/17.1.0_rollup@2.43.0:
resolution: {integrity: sha512-PoMdXCw0ZyvjpCMT5aV4nkL0QywxP29sODQsSGeDpr/oI49Qq9tRtAsb/LbYbDzFlOydVEqHmmZWFtXJEAX9ew==}
engines: {node: '>= 8.0.0'}
peerDependencies:
rollup: ^2.30.0
dependencies:
'@rollup/pluginutils': 3.1.0_rollup@2.43.0
commondir: 1.0.1
estree-walker: 2.0.2
glob: 7.1.6
is-reference: 1.2.1
magic-string: 0.25.7
resolve: 1.20.0
rollup: 2.43.0
dev: true
/@rollup/plugin-image/2.0.6_rollup@2.37.1: /@rollup/plugin-image/2.0.6_rollup@2.37.1:
resolution: {integrity: sha512-bB+spXogbPiFjhBS7i8ajUOgOnVwWK3bnJ6VroxKey/q8/EPRkoSh+4O1qPCw97qMIDspF4TlzXVBhZ7nojIPw==} resolution: {integrity: sha512-bB+spXogbPiFjhBS7i8ajUOgOnVwWK3bnJ6VroxKey/q8/EPRkoSh+4O1qPCw97qMIDspF4TlzXVBhZ7nojIPw==}
engines: {node: '>= 8.0.0'} engines: {node: '>= 8.0.0'}
@ -3328,21 +3328,6 @@ packages:
rollup: 2.37.1 rollup: 2.37.1
dev: true dev: true
/@rollup/plugin-node-resolve/11.1.0_rollup@2.43.0:
resolution: {integrity: sha512-ouBBppRdWJKCllDXGzJ7ZIkYbaq+5TmyP0smt1vdJCFfoZhLi31vhpmjLhyo8lreHf4RoeSNllaWrvSqHpHRog==}
engines: {node: '>= 10.0.0'}
peerDependencies:
rollup: ^1.20.0||^2.0.0
dependencies:
'@rollup/pluginutils': 3.1.0_rollup@2.43.0
'@types/resolve': 1.17.1
builtin-modules: 3.2.0
deepmerge: 4.2.2
is-module: 1.0.0
resolve: 1.19.0
rollup: 2.43.0
dev: true
/@rollup/plugin-node-resolve/11.2.0_rollup@2.37.1: /@rollup/plugin-node-resolve/11.2.0_rollup@2.37.1:
resolution: {integrity: sha512-qHjNIKYt5pCcn+5RUBQxK8krhRvf1HnyVgUCcFFcweDS7fhkOLZeYh0mhHK6Ery8/bb9tvN/ubPzmfF0qjDCTA==} resolution: {integrity: sha512-qHjNIKYt5pCcn+5RUBQxK8krhRvf1HnyVgUCcFFcweDS7fhkOLZeYh0mhHK6Ery8/bb9tvN/ubPzmfF0qjDCTA==}
engines: {node: '>= 10.0.0'} engines: {node: '>= 10.0.0'}
@ -3358,6 +3343,21 @@ packages:
rollup: 2.37.1 rollup: 2.37.1
dev: true dev: true
/@rollup/plugin-node-resolve/11.2.0_rollup@2.43.0:
resolution: {integrity: sha512-qHjNIKYt5pCcn+5RUBQxK8krhRvf1HnyVgUCcFFcweDS7fhkOLZeYh0mhHK6Ery8/bb9tvN/ubPzmfF0qjDCTA==}
engines: {node: '>= 10.0.0'}
peerDependencies:
rollup: ^1.20.0||^2.0.0
dependencies:
'@rollup/pluginutils': 3.1.0_rollup@2.43.0
'@types/resolve': 1.17.1
builtin-modules: 3.2.0
deepmerge: 4.2.2
is-module: 1.0.0
resolve: 1.20.0
rollup: 2.43.0
dev: true
/@rollup/plugin-node-resolve/7.1.3_rollup@1.32.1: /@rollup/plugin-node-resolve/7.1.3_rollup@1.32.1:
resolution: {integrity: sha512-RxtSL3XmdTAE2byxekYLnx+98kEUOrPHF/KRVjLH+DEIHy6kjIw7YINQzn+NXiH/NTrQLAwYs0GWB+csWygA9Q==} resolution: {integrity: sha512-RxtSL3XmdTAE2byxekYLnx+98kEUOrPHF/KRVjLH+DEIHy6kjIw7YINQzn+NXiH/NTrQLAwYs0GWB+csWygA9Q==}
engines: {node: '>= 8.0.0'} engines: {node: '>= 8.0.0'}
@ -3382,16 +3382,6 @@ packages:
rollup: 2.37.1 rollup: 2.37.1
dev: true dev: true
/@rollup/plugin-replace/2.3.4_rollup@2.43.0:
resolution: {integrity: sha512-waBhMzyAtjCL1GwZes2jaE9MjuQ/DQF2BatH3fRivUF3z0JBFrU0U6iBNC/4WR+2rLKhaAhPWDNPYp4mI6RqdQ==}
peerDependencies:
rollup: ^1.20.0 || ^2.0.0
dependencies:
'@rollup/pluginutils': 3.1.0_rollup@2.43.0
magic-string: 0.25.7
rollup: 2.43.0
dev: true
/@rollup/plugin-replace/2.4.2_rollup@1.32.1: /@rollup/plugin-replace/2.4.2_rollup@1.32.1:
resolution: {integrity: sha512-IGcu+cydlUMZ5En85jxHH4qj2hta/11BHq95iHEyb2sbgiN0eCdzvUcHw5gt9pBL5lTi4JDYJ1acCoMGpTvEZg==} resolution: {integrity: sha512-IGcu+cydlUMZ5En85jxHH4qj2hta/11BHq95iHEyb2sbgiN0eCdzvUcHw5gt9pBL5lTi4JDYJ1acCoMGpTvEZg==}
peerDependencies: peerDependencies:
@ -3402,6 +3392,16 @@ packages:
rollup: 1.32.1 rollup: 1.32.1
dev: true dev: true
/@rollup/plugin-replace/2.4.2_rollup@2.43.0:
resolution: {integrity: sha512-IGcu+cydlUMZ5En85jxHH4qj2hta/11BHq95iHEyb2sbgiN0eCdzvUcHw5gt9pBL5lTi4JDYJ1acCoMGpTvEZg==}
peerDependencies:
rollup: ^1.20.0 || ^2.0.0
dependencies:
'@rollup/pluginutils': 3.1.0_rollup@2.43.0
magic-string: 0.25.7
rollup: 2.43.0
dev: true
/@rollup/pluginutils/3.1.0_rollup@1.32.1: /@rollup/pluginutils/3.1.0_rollup@1.32.1:
resolution: {integrity: sha512-GksZ6pr6TpIjHm8h9lSQ8pi8BE9VeubNT0OMJ3B5uZJ8pz73NPiqOtCog/x2/QzM1ENChPKxMDhiQuRHsqc+lg==} resolution: {integrity: sha512-GksZ6pr6TpIjHm8h9lSQ8pi8BE9VeubNT0OMJ3B5uZJ8pz73NPiqOtCog/x2/QzM1ENChPKxMDhiQuRHsqc+lg==}
engines: {node: '>= 8.0.0'} engines: {node: '>= 8.0.0'}
@ -12052,7 +12052,7 @@ packages:
resolution: {integrity: sha512-KWYVV1c4i+jbMpaBC+U++4Va0cp8OisU185o73T1vo99hqi7w8tSJfUXYswwqqrjzwxa6KpRK54WhPvwf5w6PQ==} resolution: {integrity: sha512-KWYVV1c4i+jbMpaBC+U++4Va0cp8OisU185o73T1vo99hqi7w8tSJfUXYswwqqrjzwxa6KpRK54WhPvwf5w6PQ==}
engines: {node: '>= 10.13.0'} engines: {node: '>= 10.13.0'}
dependencies: dependencies:
'@types/node': 14.14.22 '@types/node': 14.17.1
merge-stream: 2.0.0 merge-stream: 2.0.0
supports-color: 7.2.0 supports-color: 7.2.0
dev: true dev: true
@ -15767,7 +15767,7 @@ packages:
source-map-resolve: 0.6.0 source-map-resolve: 0.6.0
dev: true dev: true
/rollup-plugin-sourcemaps/0.6.3_79665b55c550dd6b792bac22e5c7c20e: /rollup-plugin-sourcemaps/0.6.3_6efbbae6640434994627e0ab519821c6:
resolution: {integrity: sha512-paFu+nT1xvuO1tPFYXGe+XnQvg4Hjqv/eIhG8i5EspfYYPBKL57X7iVbfv55aNVASg3dzWvES9dmWsL2KhfByw==} resolution: {integrity: sha512-paFu+nT1xvuO1tPFYXGe+XnQvg4Hjqv/eIhG8i5EspfYYPBKL57X7iVbfv55aNVASg3dzWvES9dmWsL2KhfByw==}
engines: {node: '>=10.0.0'} engines: {node: '>=10.0.0'}
peerDependencies: peerDependencies:
@ -15778,7 +15778,7 @@ packages:
optional: true optional: true
dependencies: dependencies:
'@rollup/pluginutils': 3.1.0_rollup@2.43.0 '@rollup/pluginutils': 3.1.0_rollup@2.43.0
'@types/node': 14.14.22 '@types/node': 14.17.1
rollup: 2.43.0 rollup: 2.43.0
source-map-resolve: 0.6.0 source-map-resolve: 0.6.0
dev: true dev: true
@ -15801,7 +15801,7 @@ packages:
peerDependencies: peerDependencies:
rollup: ^2.0.0 rollup: ^2.0.0
dependencies: dependencies:
'@babel/code-frame': 7.10.4 '@babel/code-frame': 7.12.13
jest-worker: 26.6.2 jest-worker: 26.6.2
rollup: 2.37.1 rollup: 2.37.1
serialize-javascript: 4.0.0 serialize-javascript: 4.0.0
@ -15813,7 +15813,7 @@ packages:
peerDependencies: peerDependencies:
rollup: ^2.0.0 rollup: ^2.0.0
dependencies: dependencies:
'@babel/code-frame': 7.10.4 '@babel/code-frame': 7.12.13
jest-worker: 26.6.2 jest-worker: 26.6.2
rollup: 2.43.0 rollup: 2.43.0
serialize-javascript: 4.0.0 serialize-javascript: 4.0.0
@ -17257,7 +17257,6 @@ packages:
/tslib/2.2.0: /tslib/2.2.0:
resolution: {integrity: sha512-gS9GVHRU+RGn5KQM2rllAlR3dU6m7AcpJKdtH8gFvQiC4Otgk98XnmMU+nZenHt/+VhnBPWwgrJsyrdcw6i23w==} resolution: {integrity: sha512-gS9GVHRU+RGn5KQM2rllAlR3dU6m7AcpJKdtH8gFvQiC4Otgk98XnmMU+nZenHt/+VhnBPWwgrJsyrdcw6i23w==}
dev: true
/tsutils/3.19.1_typescript@4.1.3: /tsutils/3.19.1_typescript@4.1.3:
resolution: {integrity: sha512-GEdoBf5XI324lu7ycad7s6laADfnAqCw6wLGI+knxvw9vsIYBaJfYdmeCEG3FMMUiSm3OGgNb+m6utsWf5h9Vw==} resolution: {integrity: sha512-GEdoBf5XI324lu7ycad7s6laADfnAqCw6wLGI+knxvw9vsIYBaJfYdmeCEG3FMMUiSm3OGgNb+m6utsWf5h9Vw==}