diff options
Diffstat (limited to 'packages/taler-wallet-core/src/operations/backup/index.ts')
-rw-r--r-- | packages/taler-wallet-core/src/operations/backup/index.ts | 165 |
1 files changed, 79 insertions, 86 deletions
diff --git a/packages/taler-wallet-core/src/operations/backup/index.ts b/packages/taler-wallet-core/src/operations/backup/index.ts index 7a2771c57..e4e4e43f6 100644 --- a/packages/taler-wallet-core/src/operations/backup/index.ts +++ b/packages/taler-wallet-core/src/operations/backup/index.ts @@ -30,12 +30,10 @@ import { AttentionType, BackupRecovery, Codec, - DenomKeyType, EddsaKeyPair, HttpStatusCode, Logger, PreparePayResult, - PreparePayResultType, RecoveryLoadRequest, RecoveryMergeStrategy, TalerError, @@ -61,11 +59,9 @@ import { encodeCrock, getRandomBytes, hash, - hashDenomPub, j2s, kdf, notEmpty, - rsaBlind, secretbox, secretbox_open, stringToBytes, @@ -75,7 +71,6 @@ import { readTalerErrorResponse, } from "@gnu-taler/taler-util/http"; import { gunzipSync, gzipSync } from "fflate"; -import { TalerCryptoInterface } from "../../crypto/cryptoImplementation.js"; import { BackupProviderRecord, BackupProviderState, @@ -84,25 +79,23 @@ import { ConfigRecord, ConfigRecordKey, WalletBackupConfState, + WalletStoresV1, timestampOptionalPreciseFromDb, - timestampPreciseFromDb, timestampPreciseToDb, } from "../../db.js"; import { InternalWalletState } from "../../internal-wallet-state.js"; -import { assertUnreachable } from "../../util/assertUnreachable.js"; import { checkDbInvariant, checkLogicInvariant, } from "../../util/invariants.js"; +import { GetReadOnlyAccess } from "../../util/query.js"; import { addAttentionRequest, removeAttentionRequest } from "../attention.js"; import { + TaskIdentifiers, TaskRunResult, TaskRunResultType, - TaskIdentifiers, } from "../common.js"; -import { checkPaymentByProposalId, preparePayForUri } from "../pay-merchant.js"; -import { WalletStoresV1 } from "../../db.js"; -import { GetReadOnlyAccess } from "../../util/query.js"; +import { preparePayForUri } from "../pay-merchant.js"; const logger = new Logger("operations/backup.ts"); @@ -318,9 +311,10 @@ async function runBackupCycleForProvider( await tx.backupProviders.put(prov); }); - return { - type: TaskRunResultType.Pending, - }; + throw Error("not implemented"); + // return { + // type: TaskRunResultType.Pending, + // }; } const result = res; @@ -352,9 +346,10 @@ async function runBackupCycleForProvider( provider.baseUrl, ); - return { - type: TaskRunResultType.Pending, - }; + throw Error("not implemented"); + // return { + // type: TaskRunResultType.Pending, + // }; } if (resp.status === HttpStatusCode.NoContent) { @@ -658,30 +653,27 @@ async function runFirstBackupCycleForProvider( ws: InternalWalletState, args: BackupForProviderArgs, ): Promise<AddBackupProviderResponse> { - const resp = await runBackupCycleForProvider(ws, args); - switch (resp.type) { - case TaskRunResultType.Error: - throw TalerError.fromDetail( - TalerErrorCode.WALLET_UNEXPECTED_EXCEPTION, - resp.errorDetail as any, //FIXME create an error for backup problems - ); - case TaskRunResultType.Finished: - return { - status: "ok", - }; - case TaskRunResultType.Longpoll: - throw Error( - "unexpected runFirstBackupCycleForProvider result (longpoll)", - ); - case TaskRunResultType.Pending: - return { - status: "payment-required", - talerUri: "FIXME", - //talerUri: resp.result.talerUri, - }; - default: - assertUnreachable(resp); - } + throw Error("not implemented"); + // const resp = await runBackupCycleForProvider(ws, args); + // switch (resp.type) { + // case TaskRunResultType.Error: + // throw TalerError.fromDetail( + // TalerErrorCode.WALLET_UNEXPECTED_EXCEPTION, + // resp.errorDetail as any, //FIXME create an error for backup problems + // ); + // case TaskRunResultType.Finished: + // return { + // status: "ok", + // }; + // case TaskRunResultType.Pending: + // return { + // status: "payment-required", + // talerUri: "FIXME", + // //talerUri: resp.result.talerUri, + // }; + // default: + // assertUnreachable(resp); + // } } export async function restoreFromRecoverySecret(): Promise<void> { @@ -780,51 +772,52 @@ async function getProviderPaymentInfo( ws: InternalWalletState, provider: BackupProviderRecord, ): Promise<ProviderPaymentStatus> { - if (!provider.currentPaymentProposalId) { - return { - type: ProviderPaymentType.Unpaid, - }; - } - const status = await checkPaymentByProposalId( - ws, - provider.currentPaymentProposalId, - ).catch(() => undefined); - - if (!status) { - return { - type: ProviderPaymentType.Unpaid, - }; - } - - switch (status.status) { - case PreparePayResultType.InsufficientBalance: - return { - type: ProviderPaymentType.InsufficientBalance, - amount: status.amountRaw, - }; - case PreparePayResultType.PaymentPossible: - return { - type: ProviderPaymentType.Pending, - talerUri: status.talerUri, - }; - case PreparePayResultType.AlreadyConfirmed: - if (status.paid) { - return { - type: ProviderPaymentType.Paid, - paidUntil: AbsoluteTime.addDuration( - AbsoluteTime.fromProtocolTimestamp(status.contractTerms.timestamp), - durationFromSpec({ years: 1 }), //FIXME: take this from the contract term - ), - }; - } else { - return { - type: ProviderPaymentType.Pending, - talerUri: status.talerUri, - }; - } - default: - assertUnreachable(status); - } + throw Error("not implemented"); + // if (!provider.currentPaymentProposalId) { + // return { + // type: ProviderPaymentType.Unpaid, + // }; + // } + // const status = await checkPaymentByProposalId( + // ws, + // provider.currentPaymentProposalId, + // ).catch(() => undefined); + + // if (!status) { + // return { + // type: ProviderPaymentType.Unpaid, + // }; + // } + + // switch (status.status) { + // case PreparePayResultType.InsufficientBalance: + // return { + // type: ProviderPaymentType.InsufficientBalance, + // amount: status.amountRaw, + // }; + // case PreparePayResultType.PaymentPossible: + // return { + // type: ProviderPaymentType.Pending, + // talerUri: status.talerUri, + // }; + // case PreparePayResultType.AlreadyConfirmed: + // if (status.paid) { + // return { + // type: ProviderPaymentType.Paid, + // paidUntil: AbsoluteTime.addDuration( + // AbsoluteTime.fromProtocolTimestamp(status.contractTerms.timestamp), + // durationFromSpec({ years: 1 }), //FIXME: take this from the contract term + // ), + // }; + // } else { + // return { + // type: ProviderPaymentType.Pending, + // talerUri: status.talerUri, + // }; + // } + // default: + // assertUnreachable(status); + // } } /** |