diff options
author | Florian Dold <florian@dold.me> | 2020-12-02 14:55:04 +0100 |
---|---|---|
committer | Florian Dold <florian@dold.me> | 2020-12-02 14:55:04 +0100 |
commit | 89f1a281fea66b986fc0a003dc10446f6ed6e4a2 (patch) | |
tree | 8ffe90d572bc6967ee86bdcffc1eb6dc1240d17c /packages/taler-wallet-core/src/types | |
parent | 0828e65f8845dc4b148c0d3b0697fb589b338239 (diff) | |
download | wallet-core-89f1a281fea66b986fc0a003dc10446f6ed6e4a2.tar.xz |
backup WIP
Diffstat (limited to 'packages/taler-wallet-core/src/types')
-rw-r--r-- | packages/taler-wallet-core/src/types/backupTypes.ts | 215 | ||||
-rw-r--r-- | packages/taler-wallet-core/src/types/dbTypes.ts | 48 | ||||
-rw-r--r-- | packages/taler-wallet-core/src/types/schemacore.ts | 58 | ||||
-rw-r--r-- | packages/taler-wallet-core/src/types/walletTypes.ts | 9 |
4 files changed, 269 insertions, 61 deletions
diff --git a/packages/taler-wallet-core/src/types/backupTypes.ts b/packages/taler-wallet-core/src/types/backupTypes.ts new file mode 100644 index 000000000..72d0486b1 --- /dev/null +++ b/packages/taler-wallet-core/src/types/backupTypes.ts @@ -0,0 +1,215 @@ +/* + This file is part of GNU Taler + (C) 2020 Taler Systems S.A. + + GNU Taler is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + + +/** + * Type declarations for backup. + * + * Contains some redundancy with the other type declarations, + * as the backup schema must be very stable. + * + * @author Florian Dold <dold@taler.net> + */ + +type BackupAmountString = string; + +/** + * Content of the backup. + * + * The contents of the wallet must be serialized in a deterministic + * way across implementations, so that the normalized backup content + * JSON is identical when the wallet's content is identical. + */ +export interface WalletBackupContentV1 { + schemaId: "gnu-taler-wallet-backup"; + + schemaVersion: 1; + + /** + * Monotonically increasing clock of the wallet, + * used to determine causality when merging backups. + */ + clock: number; + + walletRootPub: string; + + /** + * Per-exchange data sorted by exchange master public key. + */ + exchanges: BackupExchangeData[]; + + reserves: ReserveBackupData[]; + + coins: BackupCoin[]; + + planchets: BackupWithdrawalPlanchet[]; + + refreshSessions: BackupRefreshSession[]; +} + +export interface BackupRefreshSession { + +} + + +export interface BackupReserve { + reservePub: string; + reservePriv: string; + /** + * The exchange base URL. + */ + exchangeBaseUrl: string; + + bankConfirmUrl?: string; + + /** + * Wire information (as payto URI) for the bank account that + * transfered funds for this reserve. + */ + senderWire?: string; +} + +export interface ReserveBackupData { + /** + * The reserve public key. + */ + reservePub: string; + + /** + * The reserve private key. + */ + reservePriv: string; + + /** + * The exchange base URL. + */ + exchangeBaseUrl: string; + + instructedAmount: string; + + /** + * Wire information (as payto URI) for the bank account that + * transfered funds for this reserve. + */ + senderWire?: string; +} + +export interface BackupExchangeData { + exchangeBaseUrl: string; + exchangeMasterPub: string; + + /** + * ETag for last terms of service download. + */ + termsOfServiceAcceptedEtag: string | undefined; +} + + +export interface BackupWithdrawalPlanchet { + coinSource: BackupWithdrawCoinSource | BackupTipCoinSource; + blindingKey: string; + coinPriv: string; + coinPub: string; + denomPubHash: string; + + /** + * Base URL that identifies the exchange from which we are getting the + * coin. + */ + exchangeBaseUrl: string; +} + + +export enum BackupCoinSourceType { + Withdraw = "withdraw", + Refresh = "refresh", + Tip = "tip", +} + +export interface BackupWithdrawCoinSource { + type: BackupCoinSourceType.Withdraw; + withdrawalGroupId: string; + + /** + * Index of the coin in the withdrawal session. + */ + coinIndex: number; + + /** + * Reserve public key for the reserve we got this coin from. + */ + reservePub: string; +} + +export interface BackupRefreshCoinSource { + type: BackupCoinSourceType.Refresh; + oldCoinPub: string; +} + +export interface BackupTipCoinSource { + type: BackupCoinSourceType.Tip; + walletTipId: string; + coinIndex: number; +} + +export type BackupCoinSource = + | BackupWithdrawCoinSource + | BackupRefreshCoinSource + | BackupTipCoinSource; + +/** + * Coin that has been withdrawn and might have been + * (partially) spent. + */ +export interface BackupCoin { + /** + * Public key of the coin. + */ + coinPub: string; + + /** + * Private key of the coin. + */ + coinPriv: string; + + /** + * Where did the coin come from (withdrawal/refresh/tip)? + * Used for recouping coins. + */ + coinSource: BackupCoinSource; + + /** + * Is the coin still fresh + */ + fresh: boolean; + + /** + * Blinding key used when withdrawing the coin. + * Potentionally used again during payback. + */ + blindingKey: string; + + /** + * Amount that's left on the coin. + */ + currentAmount: BackupAmountString; + + /** + * Base URL that identifies the exchange from which we got the + * coin. + */ + exchangeBaseUrl: string; +} diff --git a/packages/taler-wallet-core/src/types/dbTypes.ts b/packages/taler-wallet-core/src/types/dbTypes.ts index 349713ebc..26400dd3a 100644 --- a/packages/taler-wallet-core/src/types/dbTypes.ts +++ b/packages/taler-wallet-core/src/types/dbTypes.ts @@ -31,6 +31,7 @@ import { MerchantInfo, Product, InternationalizedString, + AmountString, } from "./talerTypes"; import { Index, Store } from "../util/query"; @@ -706,6 +707,10 @@ export enum CoinSourceType { export interface WithdrawCoinSource { type: CoinSourceType.Withdraw; + + /** + * Can be the empty string for orphaned coins. + */ withdrawalGroupId: string; /** @@ -1395,9 +1400,9 @@ export interface PurchaseRecord { * Configuration key/value entries to configure * the wallet. */ -export interface ConfigRecord { +export interface ConfigRecord<T> { key: string; - value: any; + value: T; } export interface DenominationSelectionInfo { @@ -1531,6 +1536,30 @@ export enum ImportPayloadType { CoreSchema = "core-schema", } +export interface BackupProviderRecord { + baseUrl: string; + + supportedProtocolVersion: string; + + annualFee: AmountString; + + storageLimitInMegabytes: number; + + active: boolean; + + /** + * Hash of the last backup that we already + * merged. + */ + lastBackupHash?: string; + + /** + * Clock of the last backup that we already + * merged. + */ + lastBackupClock?: number; +} + class ExchangesStore extends Store<"exchanges", ExchangeRecord> { constructor() { super("exchanges", { keyPath: "baseUrl" }); @@ -1609,7 +1638,7 @@ class CurrenciesStore extends Store<"currencies", CurrencyRecord> { } } -class ConfigStore extends Store<"config", ConfigRecord> { +class ConfigStore extends Store<"config", ConfigRecord<any>> { constructor() { super("config", { keyPath: "key" }); } @@ -1690,6 +1719,18 @@ class BankWithdrawUrisStore extends Store< } } + +/** + */ +class BackupProvidersStore extends Store< + "backupProviders", + BackupProviderRecord +> { + constructor() { + super("backupProviders", { keyPath: "baseUrl", versionAdded: 3 }); + } +} + /** * The stores and indices for the wallet database. */ @@ -1716,4 +1757,5 @@ export const Stores = { withdrawalGroups: new WithdrawalGroupsStore(), planchets: new PlanchetsStore(), bankWithdrawUris: new BankWithdrawUrisStore(), + backupProviders: new BackupProvidersStore(), }; diff --git a/packages/taler-wallet-core/src/types/schemacore.ts b/packages/taler-wallet-core/src/types/schemacore.ts deleted file mode 100644 index 820f68d18..000000000 --- a/packages/taler-wallet-core/src/types/schemacore.ts +++ /dev/null @@ -1,58 +0,0 @@ -/* - This file is part of GNU Taler - (C) 2019 Taler Systems S.A. - - GNU Taler is free software; you can redistribute it and/or modify it under the - terms of the GNU General Public License as published by the Free Software - Foundation; either version 3, or (at your option) any later version. - - GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along with - GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/> - */ - -/** - * Core of the wallet's schema, used for painless export, import - * and schema migration. - * - * If this schema is extended, it must be extended in a completely - * backwards-compatible way. - */ - -interface CoreCoin { - exchangeBaseUrl: string; - coinPub: string; - coinPriv: string; - amountRemaining: string; -} - -interface CorePurchase { - noncePub: string; - noncePriv: string; - paySig: string; - contractTerms: any; -} - -interface CoreReserve { - reservePub: string; - reservePriv: string; - exchangeBaseUrl: string; -} - -interface SchemaCore { - coins: CoreCoin[]; - purchases: CorePurchase[]; - - /** - * Schema version (of full schema) of wallet that exported the core schema. - */ - versionExporter: number; - - /** - * Schema version of the database that has been exported to the core schema - */ - versionSourceDatabase: number; -} diff --git a/packages/taler-wallet-core/src/types/walletTypes.ts b/packages/taler-wallet-core/src/types/walletTypes.ts index 7940497a3..ab7d3b4db 100644 --- a/packages/taler-wallet-core/src/types/walletTypes.ts +++ b/packages/taler-wallet-core/src/types/walletTypes.ts @@ -885,6 +885,15 @@ export const withdrawTestBalanceDefaults = { exchangeBaseUrl: "https://exchange.test.taler.net/", }; +/** + * Request to the crypto worker to make a sync signature. + */ +export interface MakeSyncSignatureRequest { + accountPriv: string; + oldHash: string | undefined; + newHash: string; +} + export const codecForWithdrawTestBalance = (): Codec< WithdrawTestBalanceRequest > => |