diff options
Diffstat (limited to 'packages/taler-wallet-embedded/src/index.ts')
-rw-r--r-- | packages/taler-wallet-embedded/src/index.ts | 28 |
1 files changed, 13 insertions, 15 deletions
diff --git a/packages/taler-wallet-embedded/src/index.ts b/packages/taler-wallet-embedded/src/index.ts index b505a2d9d..e0a13390d 100644 --- a/packages/taler-wallet-embedded/src/index.ts +++ b/packages/taler-wallet-embedded/src/index.ts @@ -18,27 +18,25 @@ * Imports. */ import { + createNativeWalletHost, DefaultNodeWalletArgs, - getDefaultNodeWallet, - getErrorDetailFromException, handleWorkerError, handleWorkerMessage, - Headers, - HttpRequestLibrary, - HttpRequestOptions, - HttpResponse, - NodeHttpLib, OpenedPromise, openPromise, Wallet, - WALLET_EXCHANGE_PROTOCOL_VERSION, - WALLET_MERCHANT_PROTOCOL_VERSION, } from "@gnu-taler/taler-wallet-core"; import { CoreApiMessageEnvelope, CoreApiResponse, CoreApiResponseSuccess, + createPlatformHttpLib, + getErrorDetailFromException, + Headers, + HttpRequestLibrary, + HttpRequestOptions, + HttpResponse, Logger, WalletNotification, } from "@gnu-taler/taler-util"; @@ -51,7 +49,7 @@ const logger = new Logger("taler-wallet-embedded/index.ts"); export class NativeHttpLib implements HttpRequestLibrary { useNfcTunnel = false; - private nodeHttpLib: HttpRequestLibrary = new NodeHttpLib(); + private httpLib: HttpRequestLibrary = createPlatformHttpLib(); private requestId = 1; @@ -62,7 +60,7 @@ export class NativeHttpLib implements HttpRequestLibrary { constructor(private sendMessage: (m: string) => void) {} fetch(url: string, opt?: HttpRequestOptions): Promise<HttpResponse> { - return this.nodeHttpLib.fetch(url, opt); + return this.httpLib.fetch(url, opt); } get(url: string, opt?: HttpRequestOptions): Promise<HttpResponse> { @@ -83,7 +81,7 @@ export class NativeHttpLib implements HttpRequestLibrary { ); return p.promise; } else { - return this.nodeHttpLib.get(url, opt); + return this.httpLib.get(url, opt); } } @@ -106,7 +104,7 @@ export class NativeHttpLib implements HttpRequestLibrary { ); return p.promise; } else { - return this.nodeHttpLib.postJson(url, body, opt); + return this.httpLib.postJson(url, body, opt); } } @@ -158,7 +156,7 @@ class NativeWalletMessageHandler { walletArgs: DefaultNodeWalletArgs | undefined; maybeWallet: Wallet | undefined; wp = openPromise<Wallet>(); - httpLib = new NodeHttpLib(); + httpLib = createPlatformHttpLib(); /** * Handle a request from the native wallet. @@ -181,7 +179,7 @@ class NativeWalletMessageHandler { const reinit = async () => { logger.info("in reinit"); - const w = await getDefaultNodeWallet(this.walletArgs); + const w = await createNativeWalletHost(this.walletArgs); this.maybeWallet = w; const resp = await w.handleCoreApiRequest( "initWallet", |