aboutsummaryrefslogtreecommitdiff
path: root/packages/taler-wallet-cli
diff options
context:
space:
mode:
authorFlorian Dold <florian@dold.me>2021-01-08 13:30:29 +0100
committerFlorian Dold <florian@dold.me>2021-01-08 13:30:29 +0100
commit8921a5e8f2f47c113eeeaa1bf14937c5b6cfb0ac (patch)
tree956d493e976b9316b23332cab6e3057933db2a3a /packages/taler-wallet-cli
parent324f44ae6954ef7a75a67838a7f0cbf2a6dc6d76 (diff)
implement import of backup recovery document
Diffstat (limited to 'packages/taler-wallet-cli')
-rw-r--r--packages/taler-wallet-cli/src/index.ts38
1 files changed, 35 insertions, 3 deletions
diff --git a/packages/taler-wallet-cli/src/index.ts b/packages/taler-wallet-cli/src/index.ts
index 87e0e00d1..87a51f30d 100644
--- a/packages/taler-wallet-cli/src/index.ts
+++ b/packages/taler-wallet-cli/src/index.ts
@@ -36,6 +36,8 @@ import {
NodeThreadCryptoWorkerFactory,
CryptoApi,
rsaBlind,
+ RecoveryMergeStrategy,
+ stringToBytes,
} from "taler-wallet-core";
import * as clk from "./clk";
import { deepStrictEqual } from "assert";
@@ -453,19 +455,49 @@ backupCli.subcommand("run", "run").action(async (args) => {
});
});
+backupCli.subcommand("status", "status").action(async (args) => {
+ await withWallet(args, async (wallet) => {
+ const status = await wallet.getBackupStatus();
+ console.log(JSON.stringify(status, undefined, 2));
+ });
+});
+
backupCli
.subcommand("recoveryLoad", "load-recovery")
- .action(async (args) => {});
-
-backupCli.subcommand("status", "status").action(async (args) => {});
+ .maybeOption("strategy", ["--strategy"], clk.STRING, {
+ help:
+ "Strategy for resolving a conflict with the existing wallet key ('theirs' or 'ours')",
+ })
+ .action(async (args) => {
+ await withWallet(args, async (wallet) => {
+ const data = JSON.parse(await read(process.stdin));
+ let strategy: RecoveryMergeStrategy | undefined;
+ const stratStr = args.recoveryLoad.strategy;
+ if (stratStr) {
+ if (stratStr === "theirs") {
+ strategy = RecoveryMergeStrategy.Theirs;
+ } else if (stratStr === "ours") {
+ strategy = RecoveryMergeStrategy.Theirs;
+ } else {
+ throw Error("invalid recovery strategy");
+ }
+ }
+ await wallet.loadBackupRecovery({
+ recovery: data,
+ strategy,
+ });
+ });
+ });
backupCli
.subcommand("addProvider", "add-provider")
.requiredArgument("url", clk.STRING)
+ .flag("activate", ["--activate"])
.action(async (args) => {
await withWallet(args, async (wallet) => {
wallet.addBackupProvider({
backupProviderBaseUrl: args.addProvider.url,
+ activate: args.addProvider.activate,
});
});
});