summaryrefslogtreecommitdiff
path: root/packages/taler-wallet-core/src/backup
diff options
context:
space:
mode:
authorFlorian Dold <florian@dold.me>2024-02-19 20:07:37 +0100
committerFlorian Dold <florian@dold.me>2024-02-19 20:07:45 +0100
commit194eeea6aaf4ab401825aa07073b3e0a4f9d3c1b (patch)
tree2ac2ff60c526153a8b53bac84989fa65278a6079 /packages/taler-wallet-core/src/backup
parente1a7bf4825162b4b95669ae6b4552589f4a64217 (diff)
downloadwallet-core-194eeea6aaf4ab401825aa07073b3e0a4f9d3c1b.tar.gz
wallet-core-194eeea6aaf4ab401825aa07073b3e0a4f9d3c1b.tar.bz2
wallet-core-194eeea6aaf4ab401825aa07073b3e0a4f9d3c1b.zip
restructure
Diffstat (limited to 'packages/taler-wallet-core/src/backup')
-rw-r--r--packages/taler-wallet-core/src/backup/index.ts127
1 files changed, 10 insertions, 117 deletions
diff --git a/packages/taler-wallet-core/src/backup/index.ts b/packages/taler-wallet-core/src/backup/index.ts
index 13bf95026..919e92c5a 100644
--- a/packages/taler-wallet-core/src/backup/index.ts
+++ b/packages/taler-wallet-core/src/backup/index.ts
@@ -26,7 +26,6 @@
*/
import {
AbsoluteTime,
- AmountString,
AttentionType,
BackupRecovery,
Codec,
@@ -34,11 +33,12 @@ import {
HttpStatusCode,
Logger,
PreparePayResult,
+ ProviderInfo,
+ ProviderPaymentStatus,
RecoveryLoadRequest,
RecoveryMergeStrategy,
TalerError,
TalerErrorCode,
- TalerErrorDetail,
TalerPreciseTimestamp,
URL,
buildCodecForObject,
@@ -46,12 +46,11 @@ import {
bytesToString,
canonicalJson,
canonicalizeBaseUrl,
- codecForAmountString,
codecForBoolean,
codecForConstString,
codecForList,
- codecForNumber,
codecForString,
+ codecForSyncTermsOfServiceResponse,
codecOptional,
decodeCrock,
durationFromSpec,
@@ -71,11 +70,16 @@ import {
readTalerErrorResponse,
} from "@gnu-taler/taler-util/http";
import { gunzipSync, gzipSync } from "fflate";
+import { addAttentionRequest, removeAttentionRequest } from "../attention.js";
+import {
+ TaskIdentifiers,
+ TaskRunResult,
+ TaskRunResultType,
+} from "../common.js";
import {
BackupProviderRecord,
BackupProviderState,
BackupProviderStateTag,
- BackupProviderTerms,
ConfigRecord,
ConfigRecordKey,
WalletBackupConfState,
@@ -84,17 +88,8 @@ import {
timestampPreciseToDb,
} from "../db.js";
import { InternalWalletState } from "../internal-wallet-state.js";
-import {
- checkDbInvariant,
- checkLogicInvariant,
-} from "../util/invariants.js";
-import { addAttentionRequest, removeAttentionRequest } from "../attention.js";
-import {
- TaskIdentifiers,
- TaskRunResult,
- TaskRunResultType,
-} from "../common.js";
import { preparePayForUri } from "../pay-merchant.js";
+import { checkDbInvariant, checkLogicInvariant } from "../util/invariants.js";
const logger = new Logger("operations/backup.ts");
@@ -496,26 +491,6 @@ export async function runBackupCycle(
}
}
-export interface SyncTermsOfServiceResponse {
- // maximum backup size supported
- storage_limit_in_megabytes: number;
-
- // Fee for an account, per year.
- annual_fee: AmountString;
-
- // protocol version supported by the server,
- // for now always "0.0".
- version: string;
-}
-
-export const codecForSyncTermsOfServiceResponse =
- (): Codec<SyncTermsOfServiceResponse> =>
- buildCodecForObject<SyncTermsOfServiceResponse>()
- .property("storage_limit_in_megabytes", codecForNumber())
- .property("annual_fee", codecForAmountString())
- .property("version", codecForString())
- .build("SyncTermsOfServiceResponse");
-
export interface AddBackupProviderRequest {
backupProviderBaseUrl: string;
@@ -664,94 +639,12 @@ export async function restoreFromRecoverySecret(): Promise<void> {
return;
}
-/**
- * Information about one provider.
- *
- * We don't store the account key here,
- * as that's derived from the wallet root key.
- */
-export interface ProviderInfo {
- active: boolean;
- syncProviderBaseUrl: string;
- name: string;
- terms?: BackupProviderTerms;
- /**
- * Last communication issue with the provider.
- */
- lastError?: TalerErrorDetail;
- lastSuccessfulBackupTimestamp?: TalerPreciseTimestamp;
- lastAttemptedBackupTimestamp?: TalerPreciseTimestamp;
- paymentProposalIds: string[];
- backupProblem?: BackupProblem;
- paymentStatus: ProviderPaymentStatus;
-}
-
-export type BackupProblem =
- | BackupUnreadableProblem
- | BackupConflictingDeviceProblem;
-
-export interface BackupUnreadableProblem {
- type: "backup-unreadable";
-}
-
-export interface BackupUnreadableProblem {
- type: "backup-unreadable";
-}
-
-export interface BackupConflictingDeviceProblem {
- type: "backup-conflicting-device";
- otherDeviceId: string;
- myDeviceId: string;
- backupTimestamp: AbsoluteTime;
-}
-
-export type ProviderPaymentStatus =
- | ProviderPaymentTermsChanged
- | ProviderPaymentPaid
- | ProviderPaymentInsufficientBalance
- | ProviderPaymentUnpaid
- | ProviderPaymentPending;
-
export interface BackupInfo {
walletRootPub: string;
deviceId: string;
providers: ProviderInfo[];
}
-export enum ProviderPaymentType {
- Unpaid = "unpaid",
- Pending = "pending",
- InsufficientBalance = "insufficient-balance",
- Paid = "paid",
- TermsChanged = "terms-changed",
-}
-
-export interface ProviderPaymentUnpaid {
- type: ProviderPaymentType.Unpaid;
-}
-
-export interface ProviderPaymentInsufficientBalance {
- type: ProviderPaymentType.InsufficientBalance;
- amount: AmountString;
-}
-
-export interface ProviderPaymentPending {
- type: ProviderPaymentType.Pending;
- talerUri?: string;
-}
-
-export interface ProviderPaymentPaid {
- type: ProviderPaymentType.Paid;
- paidUntil: AbsoluteTime;
-}
-
-export interface ProviderPaymentTermsChanged {
- type: ProviderPaymentType.TermsChanged;
- paidUntil: AbsoluteTime;
- oldTerms: BackupProviderTerms;
- newTerms: BackupProviderTerms;
-}
-
async function getProviderPaymentInfo(
ws: InternalWalletState,
provider: BackupProviderRecord,