diff options
39 files changed, 209 insertions, 162 deletions
diff --git a/packages/taler-integrationtests/src/denomStructures.ts b/packages/taler-integrationtests/src/denomStructures.ts index ee175a478..5ab9aca00 100644 --- a/packages/taler-integrationtests/src/denomStructures.ts +++ b/packages/taler-integrationtests/src/denomStructures.ts @@ -124,7 +124,6 @@ const coinCheapCommon = (curr: string) => ({ feeWithdraw: `${curr}:0.2`, }); - export function makeNoFeeCoinConfig(curr: string): CoinConfig[] { const cc: CoinConfig[] = []; diff --git a/packages/taler-integrationtests/src/harness.ts b/packages/taler-integrationtests/src/harness.ts index 2ac4c3d0e..1dd6c7c6f 100644 --- a/packages/taler-integrationtests/src/harness.ts +++ b/packages/taler-integrationtests/src/harness.ts @@ -908,9 +908,7 @@ export class ExchangeService implements ExchangeServiceInterface { addCoinConfigList(ccs: CoinConfig[]) { const config = Configuration.load(this.configFilename); - ccs.forEach((cc) => - setCoin(config, cc), - ); + ccs.forEach((cc) => setCoin(config, cc)); config.write(this.configFilename); } @@ -1545,8 +1543,9 @@ export class WalletCli { throw new OperationFailedError(resp.error); } - - async abortFailedPayWithRefund(req: AbortPayWithRefundRequest): Promise<void> { + async abortFailedPayWithRefund( + req: AbortPayWithRefundRequest, + ): Promise<void> { const resp = await this.apiRequest("abortFailedPayWithRefund", req); if (resp.type === "response") { return; diff --git a/packages/taler-integrationtests/src/merchantApiTypes.ts b/packages/taler-integrationtests/src/merchantApiTypes.ts index a7d0ea2cb..6782391a2 100644 --- a/packages/taler-integrationtests/src/merchantApiTypes.ts +++ b/packages/taler-integrationtests/src/merchantApiTypes.ts @@ -107,11 +107,13 @@ export const codecForCheckPaymentUnpaidResponse = (): Codec< .property("already_paid_order_id", codecOptional(codecForString())) .build("CheckPaymentPaidResponse"); -export const codecForCheckPaymentClaimedResponse = (): Codec<CheckPaymentClaimedResponse> => +export const codecForCheckPaymentClaimedResponse = (): Codec< + CheckPaymentClaimedResponse +> => buildCodecForObject<CheckPaymentClaimedResponse>() - .property("order_status", codecForConstString("claimed")) - .property("contract_terms", codecForContractTerms()) - .build("CheckPaymentClaimedResponse"); + .property("order_status", codecForConstString("claimed")) + .property("contract_terms", codecForContractTerms()) + .build("CheckPaymentClaimedResponse"); export const codecForMerchantOrderPrivateStatusResponse = (): Codec< MerchantOrderPrivateStatusResponse @@ -133,7 +135,7 @@ export interface CheckPaymentClaimedResponse { order_status: "claimed"; contract_terms: ContractTerms; -} +} export interface CheckPaymentPaidResponse { // did the customer pay for this contract @@ -179,7 +181,6 @@ export interface CheckPaymentPaidResponse { order_status_url: string; } - export interface CheckPaymentUnpaidResponse { order_status: "unpaid"; @@ -275,7 +276,6 @@ export interface ReserveStatusEntry { active: boolean; } - export interface TipCreateConfirmation { // Unique tip identifier for the tip that was created. tip_id: string; diff --git a/packages/taler-integrationtests/src/test-bank-api.ts b/packages/taler-integrationtests/src/test-bank-api.ts index b6dd3f1b9..08991e279 100644 --- a/packages/taler-integrationtests/src/test-bank-api.ts +++ b/packages/taler-integrationtests/src/test-bank-api.ts @@ -116,7 +116,9 @@ runTest(async (t: GlobalTestState) => { // Check that we got the sign-up bonus. t.assertAmountEquals(balResp.balance.amount, "TESTKUDOS:100"); - t.assertTrue(balResp.balance.credit_debit_indicator === CreditDebitIndicator.Credit); + t.assertTrue( + balResp.balance.credit_debit_indicator === CreditDebitIndicator.Credit, + ); const res = createEddsaKeyPair(); @@ -129,5 +131,7 @@ runTest(async (t: GlobalTestState) => { balResp = await BankAccessApi.getAccountBalance(bank, bankUser); t.assertAmountEquals(balResp.balance.amount, "TESTKUDOS:15"); - t.assertTrue(balResp.balance.credit_debit_indicator === CreditDebitIndicator.Debit); + t.assertTrue( + balResp.balance.credit_debit_indicator === CreditDebitIndicator.Debit, + ); }); diff --git a/packages/taler-integrationtests/src/test-claim-loop.ts b/packages/taler-integrationtests/src/test-claim-loop.ts index da8f7d45d..8c4df8740 100644 --- a/packages/taler-integrationtests/src/test-claim-loop.ts +++ b/packages/taler-integrationtests/src/test-claim-loop.ts @@ -24,11 +24,11 @@ import { WalletCli, } from "./harness"; import { createSimpleTestkudosEnvironment, withdrawViaBank } from "./helpers"; -import { URL } from "url" +import { URL } from "url"; /** * Run test for the merchant's order lifecycle. - * + * * FIXME: Is this test still necessary? We initially wrote if to confirm/document * assumptions about how the merchant should work. */ @@ -50,27 +50,33 @@ runTest(async (t: GlobalTestState) => { summary: "Buy me!", amount: "TESTKUDOS:5", fulfillment_url: "taler://fulfillment-success/thx", - } + }, }); - + // Query private order status before claiming it. - let orderStatusBefore = await MerchantPrivateApi.queryPrivateOrderStatus(merchant, { - orderId: orderResp.order_id, - }); + let orderStatusBefore = await MerchantPrivateApi.queryPrivateOrderStatus( + merchant, + { + orderId: orderResp.order_id, + }, + ); t.assertTrue(orderStatusBefore.order_status === "unpaid"); let statusUrlBefore = new URL(orderStatusBefore.order_status_url); // Make wallet claim the unpaid order. - t.assertTrue(orderStatusBefore.order_status === "unpaid"); + t.assertTrue(orderStatusBefore.order_status === "unpaid"); const talerPayUri = orderStatusBefore.taler_pay_uri; const y = await wallet.preparePay({ - talerPayUri + talerPayUri, }); // Query private order status after claiming it. - let orderStatusAfter = await MerchantPrivateApi.queryPrivateOrderStatus(merchant, { - orderId: orderResp.order_id, - }); + let orderStatusAfter = await MerchantPrivateApi.queryPrivateOrderStatus( + merchant, + { + orderId: orderResp.order_id, + }, + ); t.assertTrue(orderStatusAfter.order_status === "claimed"); await t.shutdown(); diff --git a/packages/taler-integrationtests/src/test-fee-regression.ts b/packages/taler-integrationtests/src/test-fee-regression.ts index 304744697..7b3193df2 100644 --- a/packages/taler-integrationtests/src/test-fee-regression.ts +++ b/packages/taler-integrationtests/src/test-fee-regression.ts @@ -17,15 +17,22 @@ /** * Imports. */ -import { defaultCoinConfig } from './denomStructures'; -import { runTest, GlobalTestState, BankService, ExchangeService, MerchantService, setupDb, WalletCli } from "./harness"; +import { defaultCoinConfig } from "./denomStructures"; +import { + runTest, + GlobalTestState, + BankService, + ExchangeService, + MerchantService, + setupDb, + WalletCli, +} from "./harness"; import { withdrawViaBank, makeTestPayment, SimpleTestEnvironment, } from "./helpers"; - /** * Run a test case with a simple TESTKUDOS Taler environment, consisting * of one exchange, one bank and one merchant. @@ -83,42 +90,42 @@ export async function createMyTestkudosEnvironment( { ...coinCommon, name: "c1", - value: "TESTKUDOS:1.28" + value: "TESTKUDOS:1.28", }, { ...coinCommon, name: "c2", - value: "TESTKUDOS:0.64" + value: "TESTKUDOS:0.64", }, { ...coinCommon, name: "c3", - value: "TESTKUDOS:0.32" + value: "TESTKUDOS:0.32", }, { ...coinCommon, name: "c4", - value: "TESTKUDOS:0.16" + value: "TESTKUDOS:0.16", }, { ...coinCommon, name: "c5", - value: "TESTKUDOS:0.08" + value: "TESTKUDOS:0.08", }, { ...coinCommon, name: "c5", - value: "TESTKUDOS:0.04" + value: "TESTKUDOS:0.04", }, { ...coinCommon, name: "c6", - value: "TESTKUDOS:0.02" + value: "TESTKUDOS:0.02", }, { ...coinCommon, name: "c7", - value: "TESTKUDOS:0.01" + value: "TESTKUDOS:0.01", }, ]); @@ -171,7 +178,12 @@ runTest(async (t: GlobalTestState) => { // Withdraw digital cash into the wallet. - await withdrawViaBank(t, { wallet, bank, exchange, amount: "TESTKUDOS:1.92" }); + await withdrawViaBank(t, { + wallet, + bank, + exchange, + amount: "TESTKUDOS:1.92", + }); const coins = await wallet.dumpCoins(); diff --git a/packages/taler-integrationtests/src/test-pay-abort.ts b/packages/taler-integrationtests/src/test-pay-abort.ts index 1d01c6f75..566500091 100644 --- a/packages/taler-integrationtests/src/test-pay-abort.ts +++ b/packages/taler-integrationtests/src/test-pay-abort.ts @@ -39,11 +39,7 @@ import { FaultInjectionRequestContext, FaultInjectionResponseContext, } from "./faultInjection"; -import { - PreparePayResultType, - URL, - TalerErrorCode, -} from "taler-wallet-core"; +import { PreparePayResultType, URL, TalerErrorCode } from "taler-wallet-core"; import { defaultCoinConfig } from "./denomStructures"; import { withdrawViaBank, makeTestPayment } from "./helpers"; diff --git a/packages/taler-integrationtests/src/test-pay-paid.ts b/packages/taler-integrationtests/src/test-pay-paid.ts index b5dd6bd79..40f7d014f 100644 --- a/packages/taler-integrationtests/src/test-pay-paid.ts +++ b/packages/taler-integrationtests/src/test-pay-paid.ts @@ -34,7 +34,7 @@ import { FaultInjectionRequestContext } from "./faultInjection"; /** * Run test for the wallets repurchase detection mechanism * based on the fulfillment URL. - * + * * FIXME: This test is now almost the same as test-paywall-flow, * since we can't initiate payment via a "claimed" private order status * response. @@ -150,7 +150,10 @@ runTest(async (t: GlobalTestState) => { sessionId: "mysession-two", }); - console.log("order status under mysession-two:", JSON.stringify(orderStatus, undefined, 2)); + console.log( + "order status under mysession-two:", + JSON.stringify(orderStatus, undefined, 2), + ); // Should be claimed (not paid!) because of a new session ID t.assertTrue(orderStatus.order_status === "claimed"); @@ -169,7 +172,6 @@ runTest(async (t: GlobalTestState) => { }, }); - let orderRespTwo = await MerchantPrivateApi.createOrder(merchant, "default", { order: { summary: "Buy me!", @@ -178,10 +180,13 @@ runTest(async (t: GlobalTestState) => { }, }); - let orderStatusTwo = await MerchantPrivateApi.queryPrivateOrderStatus(merchant, { - orderId: orderRespTwo.order_id, - sessionId: "mysession-two", - }); + let orderStatusTwo = await MerchantPrivateApi.queryPrivateOrderStatus( + merchant, + { + orderId: orderRespTwo.order_id, + sessionId: "mysession-two", + }, + ); t.assertTrue(orderStatusTwo.order_status === "unpaid"); diff --git a/packages/taler-integrationtests/src/test-payment-multiple.ts b/packages/taler-integrationtests/src/test-payment-multiple.ts index 8dad515c6..c6a0868af 100644 --- a/packages/taler-integrationtests/src/test-payment-multiple.ts +++ b/packages/taler-integrationtests/src/test-payment-multiple.ts @@ -25,7 +25,6 @@ import { ExchangeService, MerchantService, WalletCli, - MerchantPrivateApi, } from "./harness"; import { withdrawViaBank } from "./helpers"; diff --git a/packages/taler-integrationtests/src/test-payment-transient.ts b/packages/taler-integrationtests/src/test-payment-transient.ts index e79913298..dc7ebbb1d 100644 --- a/packages/taler-integrationtests/src/test-payment-transient.ts +++ b/packages/taler-integrationtests/src/test-payment-transient.ts @@ -32,7 +32,10 @@ import { TalerErrorCode, } from "taler-wallet-core"; import axios from "axios"; -import { FaultInjectionRequestContext, FaultInjectionResponseContext } from "./faultInjection"; +import { + FaultInjectionRequestContext, + FaultInjectionResponseContext, +} from "./faultInjection"; /** * Run test for a payment where the merchant has a transient @@ -134,7 +137,7 @@ runTest(async (t: GlobalTestState) => { }; ctx.responseBody = Buffer.from(JSON.stringify(err)); ctx.statusCode = 500; - } + }, }); const confirmPayResp = await wallet.confirmPay({ diff --git a/packages/taler-integrationtests/src/test-refund-auto.ts b/packages/taler-integrationtests/src/test-refund-auto.ts index 91051b22d..1a7055fd4 100644 --- a/packages/taler-integrationtests/src/test-refund-auto.ts +++ b/packages/taler-integrationtests/src/test-refund-auto.ts @@ -48,7 +48,7 @@ runTest(async (t: GlobalTestState) => { d_ms: 3000, }, }, - refund_delay: durationFromSpec({ minutes: 5}), + refund_delay: durationFromSpec({ minutes: 5 }), }); let orderStatus = await MerchantPrivateApi.queryPrivateOrderStatus(merchant, { diff --git a/packages/taler-integrationtests/src/test-refund-incremental.ts b/packages/taler-integrationtests/src/test-refund-incremental.ts index d83fda470..7ad406daf 100644 --- a/packages/taler-integrationtests/src/test-refund-incremental.ts +++ b/packages/taler-integrationtests/src/test-refund-incremental.ts @@ -51,7 +51,7 @@ runTest(async (t: GlobalTestState) => { amount: "TESTKUDOS:10", fulfillment_url: "taler://fulfillment-success/thx", }, - refund_delay: durationFromSpec({ minutes: 5}), + refund_delay: durationFromSpec({ minutes: 5 }), }); let orderStatus = await MerchantPrivateApi.queryPrivateOrderStatus(merchant, { diff --git a/packages/taler-integrationtests/src/test-refund.ts b/packages/taler-integrationtests/src/test-refund.ts index 40fadd5de..908136518 100644 --- a/packages/taler-integrationtests/src/test-refund.ts +++ b/packages/taler-integrationtests/src/test-refund.ts @@ -17,7 +17,7 @@ /** * Imports. */ -import { durationFromSpec } from 'taler-wallet-core'; +import { durationFromSpec } from "taler-wallet-core"; import { runTest, GlobalTestState, MerchantPrivateApi } from "./harness"; import { createSimpleTestkudosEnvironment, withdrawViaBank } from "./helpers"; @@ -46,7 +46,7 @@ runTest(async (t: GlobalTestState) => { amount: "TESTKUDOS:5", fulfillment_url: "taler://fulfillment-success/thx", }, - refund_delay: durationFromSpec({ minutes: 5}), + refund_delay: durationFromSpec({ minutes: 5 }), }); let orderStatus = await MerchantPrivateApi.queryPrivateOrderStatus(merchant, { diff --git a/packages/taler-wallet-android/src/index.ts b/packages/taler-wallet-android/src/index.ts index bfda8ab71..698a170ad 100644 --- a/packages/taler-wallet-android/src/index.ts +++ b/packages/taler-wallet-android/src/index.ts @@ -126,7 +126,9 @@ export class AndroidHttpLib implements HttpRequestLibrary { requestMethod: "FIXME", json: async () => JSON.parse(msg.responseText), text: async () => msg.responseText, - bytes: async () => { throw Error("bytes() not supported for tunnel response") }, + bytes: async () => { + throw Error("bytes() not supported for tunnel response"); + }, }; p.resolve(resp); } else { diff --git a/packages/taler-wallet-cli/src/index.ts b/packages/taler-wallet-cli/src/index.ts index 936ce4851..e8e09f8fa 100644 --- a/packages/taler-wallet-cli/src/index.ts +++ b/packages/taler-wallet-cli/src/index.ts @@ -654,8 +654,8 @@ testCli.subcommand("vectors", "vectors").action(async (args) => { async function read(stream: NodeJS.ReadStream) { const chunks = []; - for await (const chunk of stream) chunks.push(chunk); - return Buffer.concat(chunks).toString('utf8'); + for await (const chunk of stream) chunks.push(chunk); + return Buffer.concat(chunks).toString("utf8"); } testCli.subcommand("tvgcheck", "tvgcheck").action(async (args) => { @@ -667,7 +667,7 @@ testCli.subcommand("tvgcheck", "tvgcheck").action(async (args) => { throw Error("can't split lines"); } - const vals: Record<string, string> = {} + const vals: Record<string, string> = {}; let inBlindSigningSection = false; @@ -684,7 +684,7 @@ testCli.subcommand("tvgcheck", "tvgcheck").action(async (args) => { const m = line.match(/ (\w+) (\w+)/); if (!m) { console.log("bad format"); - process.exit(2) + process.exit(2); } vals[m[1]] = m[2]; } @@ -697,7 +697,7 @@ testCli.subcommand("tvgcheck", "tvgcheck").action(async (args) => { throw Error(`no value for ${k}`); } return decodeCrock(vals[k]); - } + }; const myBm = rsaBlind( req("message_hash"), diff --git a/packages/taler-wallet-core/src/TalerErrorCode.ts b/packages/taler-wallet-core/src/TalerErrorCode.ts index a662e2720..a78b04f25 100644 --- a/packages/taler-wallet-core/src/TalerErrorCode.ts +++ b/packages/taler-wallet-core/src/TalerErrorCode.ts @@ -22,8 +22,6 @@ */ export enum TalerErrorCode { - - /** * Special code to indicate success (no error). * Returned with an HTTP status code of #MHD_HTTP_UNINITIALIZED (0). @@ -1668,5 +1666,4 @@ export enum TalerErrorCode { * (A value of 0 indicates that the error is generated client-side). */ END = 9999, - } diff --git a/packages/taler-wallet-core/src/crypto/talerCrypto-test.ts b/packages/taler-wallet-core/src/crypto/talerCrypto-test.ts index fb8d2a40f..99a0e12c0 100644 --- a/packages/taler-wallet-core/src/crypto/talerCrypto-test.ts +++ b/packages/taler-wallet-core/src/crypto/talerCrypto-test.ts @@ -187,4 +187,3 @@ test("taler-exchange-tvg eddsa_ecdh #2", (t) => { ); t.deepEqual(encodeCrock(myKm2), key_material); }); - diff --git a/packages/taler-wallet-core/src/db.ts b/packages/taler-wallet-core/src/db.ts index 6f5b6b453..b13abac57 100644 --- a/packages/taler-wallet-core/src/db.ts +++ b/packages/taler-wallet-core/src/db.ts @@ -76,7 +76,10 @@ export function openTalerDatabase( if ((si as any)[indexName] instanceof Index) { const ii: Index<string, string, any, any> = (si as any)[indexName]; const indexVersionAdded = ii.options?.versionAdded ?? 0; - if (indexVersionAdded > oldVersion || storeVersionAdded > oldVersion) { + if ( + indexVersionAdded > oldVersion || + storeVersionAdded > oldVersion + ) { s.createIndex(ii.indexName, ii.keyPath, ii.options); } } diff --git a/packages/taler-wallet-core/src/headless/NodeHttpLib.ts b/packages/taler-wallet-core/src/headless/NodeHttpLib.ts index 5eefb24f9..68a549274 100644 --- a/packages/taler-wallet-core/src/headless/NodeHttpLib.ts +++ b/packages/taler-wallet-core/src/headless/NodeHttpLib.ts @@ -31,7 +31,7 @@ import { OperationFailedError, makeErrorDetails } from "../operations/errors"; import { TalerErrorCode } from "../TalerErrorCode"; import { URL } from "../util/url"; import { Logger } from "../util/logging"; -import { bytesToString } from '../crypto/talerCrypto'; +import { bytesToString } from "../crypto/talerCrypto"; const logger = new Logger("NodeHttpLib.ts"); @@ -92,10 +92,10 @@ export class NodeHttpLib implements HttpRequestLibrary { ); } - const makeText = async(): Promise<string> => { + const makeText = async (): Promise<string> => { const respText = new Uint8Array(resp.data); return bytesToString(respText); - } + }; const makeJson = async (): Promise<any> => { let responseJson; @@ -152,7 +152,6 @@ export class NodeHttpLib implements HttpRequestLibrary { json: makeJson, bytes: makeBytes, }; - } async get(url: string, opt?: HttpRequestOptions): Promise<HttpResponse> { return this.fetch(url, { diff --git a/packages/taler-wallet-core/src/headless/helpers.ts b/packages/taler-wallet-core/src/headless/helpers.ts index 09f0ca906..30b670032 100644 --- a/packages/taler-wallet-core/src/headless/helpers.ts +++ b/packages/taler-wallet-core/src/headless/helpers.ts @@ -64,8 +64,7 @@ export interface DefaultNodeWalletArgs { */ function makeId(length: number): string { let result = ""; - const characters = - "abcdefghijklmnopqrstuvwxyz0123456789"; + const characters = "abcdefghijklmnopqrstuvwxyz0123456789"; for (let i = 0; i < length; i++) { result += characters.charAt(Math.floor(Math.random() * characters.length)); } @@ -129,7 +128,9 @@ export async function getDefaultNodeWallet( const myVersionChange = (): Promise<void> => { logger.error("version change requested, should not happen"); - throw Error("BUG: wallet DB version change event can't happen with memory IDB"); + throw Error( + "BUG: wallet DB version change event can't happen with memory IDB", + ); }; shimIndexedDB(myBridgeIdbFactory); diff --git a/packages/taler-wallet-core/src/operations/backup.ts b/packages/taler-wallet-core/src/operations/backup.ts index 6c497b305..f609d4354 100644 --- a/packages/taler-wallet-core/src/operations/backup.ts +++ b/packages/taler-wallet-core/src/operations/backup.ts @@ -120,7 +120,7 @@ async function provideBackupState( key: WALLET_BACKUP_STATE_KEY, value: { deviceId, - clocks: { [deviceId]: 1}, + clocks: { [deviceId]: 1 }, walletRootPub: k.pub, walletRootPriv: k.priv, lastBackupHash: undefined, @@ -152,7 +152,9 @@ export async function exportBackup( const exchanges: BackupExchange[] = []; const coinsByDenom: { [dph: string]: BackupCoin[] } = {}; - const denominationsByExchange: { [url: string]: BackupDenomination[] } = {}; + const denominationsByExchange: { + [url: string]: BackupDenomination[]; + } = {}; const reservesByExchange: { [url: string]: BackupReserve[] } = {}; await tx.iter(Stores.coins).forEach((coin) => { @@ -193,7 +195,9 @@ export async function exportBackup( }); await tx.iter(Stores.denominations).forEach((denom) => { - const backupDenoms = (denominationsByExchange[denom.exchangeBaseUrl] ??= []); + const backupDenoms = (denominationsByExchange[ + denom.exchangeBaseUrl + ] ??= []); backupDenoms.push({ coins: coinsByDenom[denom.denomPubHash] ?? [], denom_pub: denom.denomPub, @@ -401,7 +405,7 @@ export async function runBackupCycle(ws: InternalWalletState): Promise<void> { if (resp.status === HttpResponseStatus.PaymentRequired) { logger.trace("payment required for backup"); - logger.trace(`headers: ${j2s(resp.headers)}`) + logger.trace(`headers: ${j2s(resp.headers)}`); return; } diff --git a/packages/taler-wallet-core/src/operations/errors.ts b/packages/taler-wallet-core/src/operations/errors.ts index 4eeda898b..8ec8468a1 100644 --- a/packages/taler-wallet-core/src/operations/errors.ts +++ b/packages/taler-wallet-core/src/operations/errors.ts @@ -36,7 +36,9 @@ export class OperationFailedAndReportedError extends Error { message: string, details: Record<string, unknown>, ): OperationFailedAndReportedError { - return new OperationFailedAndReportedError(makeErrorDetails(ec, message, details)); + return new OperationFailedAndReportedError( + makeErrorDetails(ec, message, details), + ); } constructor(public operationError: TalerErrorDetails) { diff --git a/packages/taler-wallet-core/src/operations/exchanges.ts b/packages/taler-wallet-core/src/operations/exchanges.ts index b82700365..b6865cccc 100644 --- a/packages/taler-wallet-core/src/operations/exchanges.ts +++ b/packages/taler-wallet-core/src/operations/exchanges.ts @@ -289,24 +289,21 @@ async function updateExchangeFinalize( if (exchange.updateStatus != ExchangeUpdateStatus.FinalizeUpdate) { return; } - await ws.db.runWithWriteTransaction( - [Stores.exchanges], - async (tx) => { - const r = await tx.get(Stores.exchanges, exchangeBaseUrl); - if (!r) { - return; - } - if (r.updateStatus != ExchangeUpdateStatus.FinalizeUpdate) { - return; - } - r.addComplete = true; - r.updateStatus = ExchangeUpdateStatus.Finished; - // Reset time to next auto refresh check, - // as now new denominations might be available. - r.nextRefreshCheck = undefined; - await tx.put(Stores.exchanges, r); - }, - ); + await ws.db.runWithWriteTransaction([Stores.exchanges], async (tx) => { + const r = await tx.get(Stores.exchanges, exchangeBaseUrl); + if (!r) { + return; + } + if (r.updateStatus != ExchangeUpdateStatus.FinalizeUpdate) { + return; + } + r.addComplete = true; + r.updateStatus = ExchangeUpdateStatus.Finished; + // Reset time to next auto refresh check, + // as now new denominations might be available. + r.nextRefreshCheck = undefined; + await tx.put(Stores.exchanges, r); + }); } async function updateExchangeWithTermsOfService( @@ -547,7 +544,9 @@ export async function getExchangeTrust( ); if (currencyRecord) { for (const trustedExchange of currencyRecord.exchanges) { - if (trustedExchange.exchangeMasterPub === exchangeDetails.masterPublicKey) { + if ( + trustedExchange.exchangeMasterPub === exchangeDetails.masterPublicKey + ) { isTrusted = true; break; } diff --git a/packages/taler-wallet-core/src/operations/pay.ts b/packages/taler-wallet-core/src/operations/pay.ts index ad970129f..52f0c4510 100644 --- a/packages/taler-wallet-core/src/operations/pay.ts +++ b/packages/taler-wallet-core/src/operations/pay.ts @@ -435,7 +435,9 @@ async function recordConfirmPay( } else { sessionId = proposal.downloadSessionId; } - logger.trace(`recording payment on ${proposal.orderId} with session ID ${sessionId}`); + logger.trace( + `recording payment on ${proposal.orderId} with session ID ${sessionId}`, + ); const payCostInfo = await getTotalPaymentCost(ws, coinSelection); const t: PurchaseRecord = { abortStatus: AbortStatus.None, @@ -943,7 +945,10 @@ async function submitPay( session_id: purchase.lastSessionId, }; - logger.trace("making pay request ... ", JSON.stringify(reqBody, undefined, 2)); + logger.trace( + "making pay request ... ", + JSON.stringify(reqBody, undefined, 2), + ); const resp = await ws.runSequentialized([EXCHANGE_COINS_LOCK], () => ws.http.postJson(payUrl, reqBody, { @@ -971,7 +976,7 @@ async function submitPay( lastError: err, }; } - + const merchantResp = await readSuccessResponseJsonOrThrow( resp, codecForMerchantPayResponse(), @@ -1208,10 +1213,7 @@ export async function confirmPay( throw Error("proposal is in invalid state"); } - let purchase = await ws.db.get( - Stores.purchases, - proposalId, - ); + let purchase = await ws.db.get(Stores.purchases, proposalId); if (purchase) { if ( diff --git a/packages/taler-wallet-core/src/operations/recoup.ts b/packages/taler-wallet-core/src/operations/recoup.ts index 585c91a09..7bbac8a99 100644 --- a/packages/taler-wallet-core/src/operations/recoup.ts +++ b/packages/taler-wallet-core/src/operations/recoup.ts @@ -38,10 +38,7 @@ import { import { codecForRecoupConfirmation } from "../types/talerTypes"; import { NotificationType } from "../types/notifications"; -import { - getReserveRequestTimeout, - processReserve, -} from "./reserves"; +import { getReserveRequestTimeout, processReserve } from "./reserves"; import { Amounts } from "../util/amounts"; import { createRefreshGroup, processRefreshGroup } from "./refresh"; diff --git a/packages/taler-wallet-core/src/operations/refund.ts b/packages/taler-wallet-core/src/operations/refund.ts index e0d060376..36b21b232 100644 --- a/packages/taler-wallet-core/src/operations/refund.ts +++ b/packages/taler-wallet-core/src/operations/refund.ts @@ -286,7 +286,10 @@ async function storeFailedRefund( } if (contrib) { coin.currentAmount = Amounts.add(coin.currentAmount, contrib).amount; - coin.currentAmount = Amounts.sub(coin.currentAmount, denom.feeRefund).amount; + coin.currentAmount = Amounts.sub( + coin.currentAmount, + denom.feeRefund, + ).amount; } refreshCoinsMap[coin.coinPub] = { coinPub: coin.coinPub }; await tx.put(Stores.coins, coin); @@ -325,7 +328,8 @@ async function acceptRefunds( const isPermanentFailure = refundStatus.type === "failure" && - refundStatus.exchange_status >= 400 && refundStatus.exchange_status < 500 ; + refundStatus.exchange_status >= 400 && + refundStatus.exchange_status < 500; // Already failed. if (existingRefundInfo?.type === RefundState.Failed) { @@ -536,7 +540,7 @@ export async function applyRefund( fulfillmentMessage: purchase.contractData.fulfillmentMessage, summary_i18n: purchase.contractData.summaryI18n, fulfillmentMessage_i18n: purchase.contractData.fulfillmentMessageI18n, - } + }, }; } diff --git a/packages/taler-wallet-core/src/operations/tip.ts b/packages/taler-wallet-core/src/operations/tip.ts index bf565b9b2..a57963824 100644 --- a/packages/taler-wallet-core/src/operations/tip.ts +++ b/packages/taler-wallet-core/src/operations/tip.ts @@ -40,7 +40,10 @@ import { getRandomBytes, encodeCrock } from "../crypto/talerCrypto"; import { guardOperationException, makeErrorDetails } from "./errors"; import { NotificationType } from "../types/notifications"; import { getTimestampNow } from "../util/time"; -import { getHttpResponseErrorDetails, readSuccessResponseJsonOrThrow } from "../util/http"; +import { + getHttpResponseErrorDetails, + readSuccessResponseJsonOrThrow, +} from "../util/http"; import { URL } from "../util/url"; import { Logger } from "../util/logging"; import { checkDbInvariant } from "../util/invariants"; diff --git a/packages/taler-wallet-core/src/operations/withdraw.ts b/packages/taler-wallet-core/src/operations/withdraw.ts index d09903cbb..a3bb9724c 100644 --- a/packages/taler-wallet-core/src/operations/withdraw.ts +++ b/packages/taler-wallet-core/src/operations/withdraw.ts @@ -43,7 +43,10 @@ import { InternalWalletState } from "./state"; import { parseWithdrawUri } from "../util/taleruri"; import { Logger } from "../util/logging"; import { updateExchangeFromUrl, getExchangeTrust } from "./exchanges"; -import { WALLET_EXCHANGE_PROTOCOL_VERSION, WALLET_BANK_INTEGRATION_PROTOCOL_VERSION } from "./versions"; +import { + WALLET_EXCHANGE_PROTOCOL_VERSION, + WALLET_BANK_INTEGRATION_PROTOCOL_VERSION, +} from "./versions"; import * as LibtoolVersion from "../util/libtoolVersion"; import { @@ -155,10 +158,7 @@ export async function getBankWithdrawalInfo( throw Error(`can't parse URL ${talerWithdrawUri}`); } - const configReqUrl = new URL( - "config", - uriResult.bankIntegrationApiBaseUrl, - ) + const configReqUrl = new URL("config", uriResult.bankIntegrationApiBaseUrl); const configResp = await ws.http.get(configReqUrl.href); const config = await readSuccessResponseJsonOrThrow( @@ -166,7 +166,10 @@ export async function getBankWithdrawalInfo( codecForTalerConfigResponse(), ); - const versionRes = compare(WALLET_BANK_INTEGRATION_PROTOCOL_VERSION, config.version); + const versionRes = compare( + WALLET_BANK_INTEGRATION_PROTOCOL_VERSION, + config.version, + ); if (versionRes?.compatible != true) { const opErr = makeErrorDetails( TalerErrorCode.WALLET_BANK_INTEGRATION_PROTOCOL_VERSION_INCOMPATIBLE, diff --git a/packages/taler-wallet-core/src/types/backupTypes.ts b/packages/taler-wallet-core/src/types/backupTypes.ts index 247a4d398..daf2fbe5a 100644 --- a/packages/taler-wallet-core/src/types/backupTypes.ts +++ b/packages/taler-wallet-core/src/types/backupTypes.ts @@ -23,6 +23,7 @@ * Current limitations: * 1. Exchange/auditor trust isn't exported yet * (see https://bugs.gnunet.org/view.php?id=6448) + * 2. Reports to the auditor (cryptographic proofs and/or diagnostics) aren't exported yet * * General considerations / decisions: * 1. Information about previously occurring errors and @@ -196,7 +197,7 @@ export interface WalletBackupContentV1 { /** * Interning table for forgettable values of contract terms. - * + * * Used to reduce storage space, as many forgettable items (product image, * addresses, etc.) might be shared among many contract terms. */ @@ -205,7 +206,7 @@ export interface WalletBackupContentV1 { /** * Trust declaration for an auditor. - * + * * The trust applies based on the public key of * the auditor, irrespective of what base URL the exchange * is referencing. @@ -223,7 +224,7 @@ export interface BackupTrustAuditor { /** * Clock when the auditor trust has been added. - * + * * Can be undefined if this entry represents a removal delta * from the wallet's defaults. */ @@ -237,7 +238,7 @@ export interface BackupTrustAuditor { /** * Trust declaration for an exchange. - * + * * The trust only applies for the combination of base URL * and public key. If the master public key changes while the base * URL stays the same, the exchange has to be re-added by a wallet update @@ -256,12 +257,12 @@ export interface BackupTrustExchange { /** * Clock when the exchange trust has been added. - * + * * Can be undefined if this entry represents a removal delta * from the wallet's defaults. */ clock_added?: ClockValue; - + /** * Clock for when the exchange trust has been removed. */ diff --git a/packages/taler-wallet-core/src/types/notifications.ts b/packages/taler-wallet-core/src/types/notifications.ts index 7faf730ef..533223cc0 100644 --- a/packages/taler-wallet-core/src/types/notifications.ts +++ b/packages/taler-wallet-core/src/types/notifications.ts @@ -223,7 +223,7 @@ export interface ReserveRegisteredWithBankNotification { /** * Notification sent when a pay (or pay replay) operation succeeded. - * + * * We send this notification because the confirmPay request can return * a "confirmed" response that indicates that the payment has been confirmed * by the user, but we're still waiting for the payment to succeed or fail. diff --git a/packages/taler-wallet-core/src/types/types-test.ts b/packages/taler-wallet-core/src/types/types-test.ts index 183122ef7..19c9b5aa6 100644 --- a/packages/taler-wallet-core/src/types/types-test.ts +++ b/packages/taler-wallet-core/src/types/types-test.ts @@ -54,7 +54,6 @@ test("contract terms validation", (t) => { t.fail(); }); - test("contract terms validation (locations)", (t) => { const c = { nonce: "123123123", @@ -69,7 +68,7 @@ test("contract terms validation (locations)", (t) => { name: "Foo", address: { country: "DE", - } + }, }, order_id: "test_order", pay_deadline: { t_ms: 42 }, @@ -83,7 +82,7 @@ test("contract terms validation (locations)", (t) => { delivery_location: { country: "FR", town: "Rennes", - } + }, }; const r = codecForContractTerms().decode(c); diff --git a/packages/taler-wallet-core/src/types/walletTypes.ts b/packages/taler-wallet-core/src/types/walletTypes.ts index ab7d3b4db..d0e72b289 100644 --- a/packages/taler-wallet-core/src/types/walletTypes.ts +++ b/packages/taler-wallet-core/src/types/walletTypes.ts @@ -365,13 +365,13 @@ export interface PrepareTipResult { * Amount that the merchant gave. */ tipAmountRaw: AmountString; - + /** * Amount that arrived at the wallet. * Might be lower than the raw amount due to fees. */ tipAmountEffective: AmountString; - + /** * Base URL of the merchant backend giving then tip. */ @@ -382,7 +382,7 @@ export interface PrepareTipResult { * Determined by the merchant, the wallet/user has no choice here. */ exchangeBaseUrl: string; - + /** * Time when the tip will expire. After it expired, it can't be picked * up anymore. @@ -392,13 +392,13 @@ export interface PrepareTipResult { export const codecForPrepareTipResult = (): Codec<PrepareTipResult> => buildCodecForObject<PrepareTipResult>() - .property("accepted", codecForBoolean()) - .property("tipAmountRaw", codecForAmountString()) - .property("tipAmountEffective", codecForAmountString()) - .property("exchangeBaseUrl", codecForString()) - .property("merchantBaseUrl", codecForString()) - .property("expirationTimestamp", codecForTimestamp) - .property("walletTipId", codecForString()) + .property("accepted", codecForBoolean()) + .property("tipAmountRaw", codecForAmountString()) + .property("tipAmountEffective", codecForAmountString()) + .property("exchangeBaseUrl", codecForString()) + .property("merchantBaseUrl", codecForString()) + .property("expirationTimestamp", codecForTimestamp) + .property("walletTipId", codecForString()) .build("PrepareTipResult"); export interface BenchmarkResult { @@ -974,7 +974,9 @@ export interface AbortPayWithRefundRequest { proposalId: string; } -export const codecForAbortPayWithRefundRequest = (): Codec<AbortPayWithRefundRequest> => +export const codecForAbortPayWithRefundRequest = (): Codec< + AbortPayWithRefundRequest +> => buildCodecForObject<AbortPayWithRefundRequest>() .property("proposalId", codecForString()) .build("AbortPayWithRefundRequest"); diff --git a/packages/taler-wallet-core/src/util/RequestThrottler.ts b/packages/taler-wallet-core/src/util/RequestThrottler.ts index 8c9f304e0..0bdd7cab7 100644 --- a/packages/taler-wallet-core/src/util/RequestThrottler.ts +++ b/packages/taler-wallet-core/src/util/RequestThrottler.ts @@ -21,7 +21,11 @@ /** * Imports. */ -import { getTimestampNow, timestampDifference, timestampCmp } from "../util/time"; +import { + getTimestampNow, + timestampDifference, + timestampCmp, +} from "../util/time"; import { URL } from "./url"; import { Logger } from "./logging"; diff --git a/packages/taler-wallet-core/src/util/helpers.ts b/packages/taler-wallet-core/src/util/helpers.ts index 570df441d..3d8999ed5 100644 --- a/packages/taler-wallet-core/src/util/helpers.ts +++ b/packages/taler-wallet-core/src/util/helpers.ts @@ -149,4 +149,4 @@ export function strcmp(s1: string, s2: string): number { export function j2s(x: any): string { return JSON.stringify(x, undefined, 2); -}
\ No newline at end of file +} diff --git a/packages/taler-wallet-core/src/util/http.ts b/packages/taler-wallet-core/src/util/http.ts index 1ec9c2f50..4b0a8e75a 100644 --- a/packages/taler-wallet-core/src/util/http.ts +++ b/packages/taler-wallet-core/src/util/http.ts @@ -17,7 +17,7 @@ /** * Helpers for doing XMLHttpRequest-s that are based on ES6 promises. * Allows for easy mocking for test cases. - * + * * The API is inspired by the HTML5 fetch API. */ @@ -91,7 +91,7 @@ export class Headers { toJSON(): any { const m: Record<string, string> = {}; - this.headerMap.forEach((v, k) => m[k] = v); + this.headerMap.forEach((v, k) => (m[k] = v)); return m; } } @@ -120,10 +120,7 @@ export interface HttpRequestLibrary { /** * Make an HTTP POST request with a JSON body. */ - fetch( - url: string, - opt?: HttpRequestOptions, - ): Promise<HttpResponse>; + fetch(url: string, opt?: HttpRequestOptions): Promise<HttpResponse>; } type TalerErrorResponse = { diff --git a/packages/taler-wallet-core/src/util/query.ts b/packages/taler-wallet-core/src/util/query.ts index beb14cad0..e1a23b168 100644 --- a/packages/taler-wallet-core/src/util/query.ts +++ b/packages/taler-wallet-core/src/util/query.ts @@ -25,7 +25,6 @@ */ import { openPromise } from "./promiseUtils"; import { - IDBObjectStoreParameters, IDBRequest, IDBTransaction, IDBValidKey, @@ -574,7 +573,7 @@ export class Database { async get<N extends string, T>( store: Store<N, T>, - key: any, + key: IDBValidKey, ): Promise<T | undefined> { const tx = this.db.transaction([store.name], "readonly"); const req = tx.objectStore(store.name).get(key); @@ -585,7 +584,7 @@ export class Database { async getIndexed<Ind extends Index<string, string, any, any>>( index: InferIndex<Ind>, - key: any, + key: IDBValidKey, ): Promise<IndexRecord<Ind> | undefined> { const tx = this.db.transaction([index.storeName], "readonly"); const req = tx.objectStore(index.storeName).index(index.indexName).get(key); @@ -597,7 +596,7 @@ export class Database { async put<St extends Store<string, any>>( store: St, value: StoreContent<St>, - key?: any, + key?: IDBValidKey, ): Promise<any> { const tx = this.db.transaction([store.name], "readwrite"); const req = tx.objectStore(store.name).put(value, key); @@ -608,7 +607,7 @@ export class Database { async mutate<N extends string, T>( store: Store<N, T>, - key: any, + key: IDBValidKey, f: (x: T) => T | undefined, ): Promise<void> { const tx = this.db.transaction([store.name], "readwrite"); diff --git a/packages/taler-wallet-core/src/util/retries.ts b/packages/taler-wallet-core/src/util/retries.ts index f3a5e7d80..8be78cfc8 100644 --- a/packages/taler-wallet-core/src/util/retries.ts +++ b/packages/taler-wallet-core/src/util/retries.ts @@ -89,4 +89,4 @@ export function initRetryInfo( }; updateRetryInfoTimeout(info, p); return info; -}
\ No newline at end of file +} diff --git a/packages/taler-wallet-core/src/util/taleruri.ts b/packages/taler-wallet-core/src/util/taleruri.ts index ee055a32f..d8366fd0f 100644 --- a/packages/taler-wallet-core/src/util/taleruri.ts +++ b/packages/taler-wallet-core/src/util/taleruri.ts @@ -14,7 +14,7 @@ GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/> */ -import { canonicalizeBaseUrl } from './helpers'; +import { canonicalizeBaseUrl } from "./helpers"; import { URLSearchParams } from "./url"; export interface PayUriResult { diff --git a/packages/taler-wallet-core/src/wallet.ts b/packages/taler-wallet-core/src/wallet.ts index 4491a167b..07af32bb8 100644 --- a/packages/taler-wallet-core/src/wallet.ts +++ b/packages/taler-wallet-core/src/wallet.ts @@ -132,7 +132,11 @@ import { PendingOperationType, } from "./types/pending"; import { WalletNotification, NotificationType } from "./types/notifications"; -import { processPurchaseQueryRefund, applyRefund, abortFailedPayWithRefund } from "./operations/refund"; +import { + processPurchaseQueryRefund, + applyRefund, + abortFailedPayWithRefund, +} from "./operations/refund"; import { durationMin, Duration } from "./util/time"; import { processRecoupGroup } from "./operations/recoup"; import { @@ -152,7 +156,12 @@ import { testPay, } from "./operations/testing"; import { TalerErrorCode } from "."; -import { addBackupProvider, codecForAddBackupProviderRequest, runBackupCycle, exportBackup } from './operations/backup'; +import { + addBackupProvider, + codecForAddBackupProviderRequest, + runBackupCycle, + exportBackup, +} from "./operations/backup"; const builtinCurrencies: CurrencyRecord[] = [ { @@ -721,9 +730,7 @@ export class Wallet { * Accept a refund, return the contract hash for the contract * that was involved in the refund. */ - async applyRefund( - talerRefundUri: string, - ): Promise<ApplyRefundResponse> { + async applyRefund(talerRefundUri: string): Promise<ApplyRefundResponse> { return applyRefund(this.ws, talerRefundUri); } |