From 6e11b69cf5beb25fec1dfdff281877a76bf195a4 Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Mon, 14 Jun 2021 11:21:29 +0200 Subject: allow changing the wallet device ID --- packages/taler-wallet-core/src/db.ts | 42 +++++++++++++++++++++++++++++++----- 1 file changed, 37 insertions(+), 5 deletions(-) (limited to 'packages/taler-wallet-core/src/db.ts') diff --git a/packages/taler-wallet-core/src/db.ts b/packages/taler-wallet-core/src/db.ts index 5e2a3fefa..349a40427 100644 --- a/packages/taler-wallet-core/src/db.ts +++ b/packages/taler-wallet-core/src/db.ts @@ -1358,13 +1358,40 @@ export interface PurchaseRecord { autoRefundDeadline: Timestamp | undefined; } +export const WALLET_BACKUP_STATE_KEY = "walletBackupState"; + /** * Configuration key/value entries to configure * the wallet. + * */ -export interface ConfigRecord { - key: string; - value: T; +export type ConfigRecord = + | { + key: typeof WALLET_BACKUP_STATE_KEY; + value: WalletBackupConfState; + } + | { key: "currencyDefaultsApplied"; value: boolean }; + +export interface WalletBackupConfState { + deviceId: string; + walletRootPub: string; + walletRootPriv: string; + + /** + * Last hash of the canonicalized plain-text backup. + */ + lastBackupPlainHash?: string; + + /** + * Timestamp stored in the last backup. + */ + lastBackupTimestamp?: Timestamp; + + /** + * Last time we tried to do a backup. + */ + lastBackupCheckTimestamp?: Timestamp; + lastBackupNonce?: string; } /** @@ -1671,7 +1698,7 @@ export const WalletStoresV1 = { }, ), config: describeStore( - describeContents>("config", { keyPath: "key" }), + describeContents("config", { keyPath: "key" }), {}, ), auditorTrust: describeStore( @@ -1817,9 +1844,14 @@ export const WalletStoresV1 = { ), }; +export interface MetaConfigRecord { + key: string; + value: any; +} + export const walletMetadataStore = { metaConfig: describeStore( - describeContents>("metaConfig", { keyPath: "key" }), + describeContents("metaConfig", { keyPath: "key" }), {}, ), }; -- cgit v1.2.3