diff options
Diffstat (limited to 'packages/taler-wallet-embedded')
-rw-r--r-- | packages/taler-wallet-embedded/src/wallet-qjs.ts | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/packages/taler-wallet-embedded/src/wallet-qjs.ts b/packages/taler-wallet-embedded/src/wallet-qjs.ts index 9cf735b12..9d6a6c097 100644 --- a/packages/taler-wallet-embedded/src/wallet-qjs.ts +++ b/packages/taler-wallet-embedded/src/wallet-qjs.ts @@ -30,6 +30,7 @@ import { Logger, setGlobalLogLevelFromString, setPRNG, + TalerErrorCode, WalletNotification, } from "@gnu-taler/taler-util"; import { createPlatformHttpLib } from "@gnu-taler/taler-util/http"; @@ -74,7 +75,7 @@ class NativeWalletMessageHandler { id: string, args: any, ): Promise<CoreApiResponse> { - const wrapResponse = (result: unknown): CoreApiResponseSuccess => { + const wrapSuccessResponse = (result: unknown): CoreApiResponseSuccess => { return { type: "response", id, @@ -120,7 +121,7 @@ class NativeWalletMessageHandler { setGlobalLogLevelFromString(logLevel); } await reinit(); - return wrapResponse({ + return wrapSuccessResponse({ ...initResponse, }); } @@ -137,14 +138,22 @@ class NativeWalletMessageHandler { throw Error("not implemented"); } case "reset": { + logger.info("resetting wallet"); const oldArgs = this.walletArgs; this.walletArgs = { ...oldArgs }; if (oldArgs && oldArgs.persistentStoragePath) { - try { - logger.error("FIXME: reset not implemented"); - // fs.unlinkSync(oldArgs.persistentStoragePath); - } catch (e) { - logger.error("Error while deleting the wallet db:", e); + const ret = qjsOs.remove(oldArgs.persistentStoragePath); + if (ret != null) { + return { + type: "error", + id, + operation, + error: { + code: TalerErrorCode.GENERIC_UNEXPECTED_REQUEST_ERROR, + hint: `path ${oldArgs.persistentStoragePath}`, + message: "removing DB file failed", + }, + }; } // Prevent further storage! this.walletArgs.persistentStoragePath = undefined; @@ -154,7 +163,8 @@ class NativeWalletMessageHandler { this.wp = openPromise<Wallet>(); this.maybeWallet = undefined; await reinit(); - return wrapResponse({}); + logger.info("wallet re-initialized after reset"); + return wrapSuccessResponse({}); } default: { const wallet = await this.wp.promise; |