[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-wallet-core] 05/06: wallet-core-embedded: add initial states to A
From: |
gnunet |
Subject: |
[taler-wallet-core] 05/06: wallet-core-embedded: add initial states to Anastasis handler |
Date: |
Wed, 26 Jul 2023 20:10:50 +0200 |
This is an automated email from the git hooks/post-receive script.
ivan-avalos pushed a commit to branch master
in repository wallet-core.
commit 0f6310bba423dc910a89693509038b62c85f35b4
Author: Iván Ávalos <avalos@disroot.org>
AuthorDate: Wed Jul 5 11:14:31 2023 -0600
wallet-core-embedded: add initial states to Anastasis handler
---
packages/taler-wallet-embedded/src/wallet-qjs.ts | 39 ++++++++++++++++--------
1 file changed, 26 insertions(+), 13 deletions(-)
diff --git a/packages/taler-wallet-embedded/src/wallet-qjs.ts
b/packages/taler-wallet-embedded/src/wallet-qjs.ts
index db0aeacb6..0a252f514 100644
--- a/packages/taler-wallet-embedded/src/wallet-qjs.ts
+++ b/packages/taler-wallet-embedded/src/wallet-qjs.ts
@@ -43,6 +43,8 @@ import {
} from "@gnu-taler/taler-wallet-core";
import {
reduceAction,
+ getBackupStartState,
+ getRecoveryStartState,
ReducerState,
} from "@gnu-taler/anastasis-core";
@@ -177,19 +179,32 @@ class NativeWalletMessageHandler {
* Handle an Anastasis request from the native app.
*/
async function handleAnastasisRequest(
- state: ReducerState,
- action: string,
+ operation: string,
id: string,
args: any,
): Promise<CoreApiResponse> {
- // For now, this will return "success" even if the wrapped Anastasis
- // response is a ReducerStateError.
- return {
- type: "response",
- id,
- operation: "anastasis",
- result: await reduceAction(state, action, args),
+ const wrapSuccessResponse = (result: unknown): CoreApiResponseSuccess => {
+ return {
+ type: "response",
+ id,
+ operation,
+ result,
+ };
};
+
+ switch (operation) {
+ case "anastasisReduce":
+ // TODO: do some input validation here
+ let req = args ?? {};
+ let res = await reduceAction(req.state, req.action, req.args ?? {});
+ // For now, this will return "success" even if the wrapped Anastasis
+ // response is a ReducerStateError.
+ return wrapSuccessResponse(res);
+ case "anastasisStartBackup":
+ return wrapSuccessResponse(await getBackupStartState());
+ case "anastasisStartRecovery":
+ return wrapSuccessResponse(await getRecoveryStartState());
+ }
}
export function installNativeWalletListener(): void {
@@ -213,10 +228,8 @@ export function installNativeWalletListener(): void {
let respMsg: CoreApiResponse;
try {
- if (msg.operation === "anastasis") {
- // TODO: do some input validation here
- let req = msg.args ?? {};
- respMsg = await handleAnastasisRequest(req.state, req.action, id,
req.args ?? {});
+ if (msg.operation.startsWith("anastasis")) {
+ respMsg = await handleAnastasisRequest(operation, id, msg.args ?? {});
} else {
respMsg = await handler.handleMessage(operation, id, msg.args ?? {});
}
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
- [taler-wallet-core] branch master updated (0b6060283 -> 0ac5dba08), gnunet, 2023/07/26
- [taler-wallet-core] 02/06: taler-util: import hash-wasm only when building for Node, gnunet, 2023/07/26
- [taler-wallet-core] 01/06: WIP: initial work for Anastasis in qtart, gnunet, 2023/07/26
- [taler-wallet-core] 03/06: anastasis-core: tsconfig, gnunet, 2023/07/26
- [taler-wallet-core] 05/06: wallet-core-embedded: add initial states to Anastasis handler,
gnunet <=
- [taler-wallet-core] 04/06: Move anastasis CLI into separate package, gnunet, 2023/07/26
- [taler-wallet-core] 06/06: taler-wallet-embedded: add argon2id test, gnunet, 2023/07/26