From ffd2a62c3f7df94365980302fef3bc3376b48182 Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Mon, 3 Aug 2020 13:00:48 +0530 Subject: modularize repo, use pnpm, improve typechecking --- .../src/types/ReserveStatus.d.ts.map | 1 + .../taler-wallet-core/src/types/ReserveStatus.ts | 57 + .../src/types/ReserveTransaction.d.ts.map | 1 + .../src/types/ReserveTransaction.ts | 250 +++ .../taler-wallet-core/src/types/dbTypes.d.ts.map | 1 + packages/taler-wallet-core/src/types/dbTypes.ts | 1819 ++++++++++++++++++++ .../src/types/notifications.d.ts.map | 1 + .../taler-wallet-core/src/types/notifications.ts | 255 +++ .../taler-wallet-core/src/types/pending.d.ts.map | 1 + packages/taler-wallet-core/src/types/pending.ts | 258 +++ packages/taler-wallet-core/src/types/schemacore.ts | 58 + .../src/types/talerTypes.d.ts.map | 1 + packages/taler-wallet-core/src/types/talerTypes.ts | 1272 ++++++++++++++ .../src/types/transactions.d.ts.map | 1 + .../taler-wallet-core/src/types/transactions.ts | 314 ++++ packages/taler-wallet-core/src/types/types-test.ts | 55 + .../src/types/walletTypes.d.ts.map | 1 + .../taler-wallet-core/src/types/walletTypes.ts | 516 ++++++ 18 files changed, 4862 insertions(+) create mode 100644 packages/taler-wallet-core/src/types/ReserveStatus.d.ts.map create mode 100644 packages/taler-wallet-core/src/types/ReserveStatus.ts create mode 100644 packages/taler-wallet-core/src/types/ReserveTransaction.d.ts.map create mode 100644 packages/taler-wallet-core/src/types/ReserveTransaction.ts create mode 100644 packages/taler-wallet-core/src/types/dbTypes.d.ts.map create mode 100644 packages/taler-wallet-core/src/types/dbTypes.ts create mode 100644 packages/taler-wallet-core/src/types/notifications.d.ts.map create mode 100644 packages/taler-wallet-core/src/types/notifications.ts create mode 100644 packages/taler-wallet-core/src/types/pending.d.ts.map create mode 100644 packages/taler-wallet-core/src/types/pending.ts create mode 100644 packages/taler-wallet-core/src/types/schemacore.ts create mode 100644 packages/taler-wallet-core/src/types/talerTypes.d.ts.map create mode 100644 packages/taler-wallet-core/src/types/talerTypes.ts create mode 100644 packages/taler-wallet-core/src/types/transactions.d.ts.map create mode 100644 packages/taler-wallet-core/src/types/transactions.ts create mode 100644 packages/taler-wallet-core/src/types/types-test.ts create mode 100644 packages/taler-wallet-core/src/types/walletTypes.d.ts.map create mode 100644 packages/taler-wallet-core/src/types/walletTypes.ts (limited to 'packages/taler-wallet-core/src/types') diff --git a/packages/taler-wallet-core/src/types/ReserveStatus.d.ts.map b/packages/taler-wallet-core/src/types/ReserveStatus.d.ts.map new file mode 100644 index 000000000..6b84dde85 --- /dev/null +++ b/packages/taler-wallet-core/src/types/ReserveStatus.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"ReserveStatus.d.ts","sourceRoot":"","sources":["ReserveStatus.ts"],"names":[],"mappings":"AAgBA;;GAEG;AAEH;;GAEG;AACH,OAAO,EAIL,KAAK,EACN,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EACL,kBAAkB,EAEnB,MAAM,sBAAsB,CAAC;AAE9B;;;;GAIG;AACH,MAAM,WAAW,aAAa;IAC5B;;OAEG;IACH,OAAO,EAAE,YAAY,CAAC;IAEtB;;OAEG;IACH,OAAO,EAAE,kBAAkB,EAAE,CAAC;CAC/B;AAED,eAAO,MAAM,qBAAqB,QAAO,KAAK,CAAC,aAAa,CAIjC,CAAC"} \ No newline at end of file diff --git a/packages/taler-wallet-core/src/types/ReserveStatus.ts b/packages/taler-wallet-core/src/types/ReserveStatus.ts new file mode 100644 index 000000000..18601b9a7 --- /dev/null +++ b/packages/taler-wallet-core/src/types/ReserveStatus.ts @@ -0,0 +1,57 @@ +/* + 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 + */ + +/** + * @author Florian Dold + */ + +/** + * Imports. + */ +import { + codecForString, + makeCodecForObject, + makeCodecForList, + Codec, +} from "../util/codec"; +import { AmountString } from "./talerTypes"; +import { + ReserveTransaction, + codecForReserveTransaction, +} from "./ReserveTransaction"; + +/** + * Status of a reserve. + * + * Schema type for the exchange's response to "/reserve/status". + */ +export interface ReserveStatus { + /** + * Balance left in the reserve. + */ + balance: AmountString; + + /** + * Transaction history for the reserve. + */ + history: ReserveTransaction[]; +} + +export const codecForReserveStatus = (): Codec => + makeCodecForObject() + .property("balance", codecForString) + .property("history", makeCodecForList(codecForReserveTransaction())) + .build("ReserveStatus"); diff --git a/packages/taler-wallet-core/src/types/ReserveTransaction.d.ts.map b/packages/taler-wallet-core/src/types/ReserveTransaction.d.ts.map new file mode 100644 index 000000000..c4672bc45 --- /dev/null +++ b/packages/taler-wallet-core/src/types/ReserveTransaction.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"ReserveTransaction.d.ts","sourceRoot":"","sources":["ReserveTransaction.ts"],"names":[],"mappings":"AAgBA;;GAEG;AAEH;;GAEG;AACH,OAAO,EAKL,KAAK,EACN,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,YAAY,EACZ,YAAY,EACZ,oBAAoB,EACpB,oBAAoB,EACpB,mBAAmB,EACpB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,SAAS,EAAqB,MAAM,cAAc,CAAC;AAE5D,0BAAkB,sBAAsB;IACtC,QAAQ,aAAa;IACrB,MAAM,WAAW;IACjB,MAAM,WAAW;IACjB,OAAO,YAAY;CACpB;AAED,MAAM,WAAW,0BAA0B;IACzC,IAAI,EAAE,sBAAsB,CAAC,QAAQ,CAAC;IAEtC;;OAEG;IACH,MAAM,EAAE,YAAY,CAAC;IAErB;;OAEG;IACH,WAAW,EAAE,Y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A0B,CASY,CAAC;AAEzC,eAAO,MAAM,gCAAgC,QAAO,KAAK,CACvD,wBAAwB,CAQY,CAAC;AAEvC,eAAO,MAAM,iCAAiC,QAAO,KAAK,CACxD,yBAAyB,CAWY,CAAC;AAExC,eAAO,MAAM,gCAAgC,QAAO,KAAK,CACvD,wBAAwB,CASY,CAAC;AAEvC,eAAO,MAAM,0BAA0B,QAAO,KAAK,CAAC,kBAAkB,CAmBlB,CAAC"} \ No newline at end of file diff --git a/packages/taler-wallet-core/src/types/ReserveTransaction.ts b/packages/taler-wallet-core/src/types/ReserveTransaction.ts new file mode 100644 index 000000000..bdd9b0f93 --- /dev/null +++ b/packages/taler-wallet-core/src/types/ReserveTransaction.ts @@ -0,0 +1,250 @@ +/* + 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 + */ + +/** + * @author Florian Dold + */ + +/** + * Imports. + */ +import { + codecForString, + makeCodecForObject, + makeCodecForConstString, + makeCodecForUnion, + Codec, +} from "../util/codec"; +import { + AmountString, + Base32String, + EddsaSignatureString, + EddsaPublicKeyString, + CoinPublicKeyString, +} from "./talerTypes"; +import { Timestamp, codecForTimestamp } from "../util/time"; + +export const enum ReserveTransactionType { + Withdraw = "WITHDRAW", + Credit = "CREDIT", + Recoup = "RECOUP", + Closing = "CLOSING", +} + +export interface ReserveWithdrawTransaction { + type: ReserveTransactionType.Withdraw; + + /** + * Amount withdrawn. + */ + amount: AmountString; + + /** + * Hash of the denomination public key of the coin. + */ + h_denom_pub: Base32String; + + /** + * Hash of the blinded coin to be signed + */ + h_coin_envelope: Base32String; + + /** + * Signature of 'TALER_WithdrawRequestPS' created with the reserves's + * private key. + */ + reserve_sig: EddsaSignatureString; + + /** + * Fee that is charged for withdraw. + */ + withdraw_fee: AmountString; +} + +export interface ReserveCreditTransaction { + type: ReserveTransactionType.Credit; + + /** + * Amount withdrawn. + */ + amount: AmountString; + + /** + * Sender account payto://-URL + */ + sender_account_url: string; + + /** + * Transfer details uniquely identifying the transfer. + */ + wire_reference: string; + + /** + * Timestamp of the incoming wire transfer. + */ + timestamp: Timestamp; +} + +export interface ReserveClosingTransaction { + type: ReserveTransactionType.Closing; + + /** + * Closing balance. + */ + amount: AmountString; + + /** + * Closing fee charged by the exchange. + */ + closing_fee: AmountString; + + /** + * Wire transfer subject. + */ + wtid: string; + + /** + * Hash of the wire account into which the funds were returned to. + */ + h_wire: string; + + /** + * This is a signature over a + * struct TALER_ReserveCloseConfirmationPS with purpose + * TALER_SIGNATURE_EXCHANGE_RESERVE_CLOSED. + */ + exchange_sig: EddsaSignatureString; + + /** + * Public key used to create exchange_sig. + */ + exchange_pub: EddsaPublicKeyString; + + /** + * Time when the reserve was closed. + */ + timestamp: Timestamp; +} + +export interface ReserveRecoupTransaction { + type: ReserveTransactionType.Recoup; + + /** + * Amount paid back. + */ + amount: AmountString; + + /** + * This is a signature over + * a struct TALER_PaybackConfirmationPS with purpose + * TALER_SIGNATURE_EXCHANGE_CONFIRM_PAYBACK. + */ + exchange_sig: EddsaSignatureString; + + /** + * Public key used to create exchange_sig. + */ + exchange_pub: EddsaPublicKeyString; + + /** + * Time when the funds were paid back into the reserve. + */ + timestamp: Timestamp; + + /** + * Public key of the coin that was paid back. + */ + coin_pub: CoinPublicKeyString; +} + +/** + * Format of the exchange's transaction history for a reserve. + */ +export type ReserveTransaction = + | ReserveWithdrawTransaction + | ReserveCreditTransaction + | ReserveClosingTransaction + | ReserveRecoupTransaction; + +export const codecForReserveWithdrawTransaction = (): Codec< + ReserveWithdrawTransaction +> => + makeCodecForObject() + .property("amount", codecForString) + .property("h_coin_envelope", codecForString) + .property("h_denom_pub", codecForString) + .property("reserve_sig", codecForString) + .property("type", makeCodecForConstString(ReserveTransactionType.Withdraw)) + .property("withdraw_fee", codecForString) + .build("ReserveWithdrawTransaction"); + +export const codecForReserveCreditTransaction = (): Codec< + ReserveCreditTransaction +> => + makeCodecForObject() + .property("amount", codecForString) + .property("sender_account_url", codecForString) + .property("timestamp", codecForTimestamp) + .property("wire_reference", codecForString) + .property("type", makeCodecForConstString(ReserveTransactionType.Credit)) + .build("ReserveCreditTransaction"); + +export const codecForReserveClosingTransaction = (): Codec< + ReserveClosingTransaction +> => + makeCodecForObject() + .property("amount", codecForString) + .property("closing_fee", codecForString) + .property("exchange_pub", codecForString) + .property("exchange_sig", codecForString) + .property("h_wire", codecForString) + .property("timestamp", codecForTimestamp) + .property("type", makeCodecForConstString(ReserveTransactionType.Closing)) + .property("wtid", codecForString) + .build("ReserveClosingTransaction"); + +export const codecForReserveRecoupTransaction = (): Codec< + ReserveRecoupTransaction +> => + makeCodecForObject() + .property("amount", codecForString) + .property("coin_pub", codecForString) + .property("exchange_pub", codecForString) + .property("exchange_sig", codecForString) + .property("timestamp", codecForTimestamp) + .property("type", makeCodecForConstString(ReserveTransactionType.Recoup)) + .build("ReserveRecoupTransaction"); + +export const codecForReserveTransaction = (): Codec => + makeCodecForUnion() + .discriminateOn("type") + .alternative( + ReserveTransactionType.Withdraw, + codecForReserveWithdrawTransaction(), + ) + .alternative( + ReserveTransactionType.Closing, + codecForReserveClosingTransaction(), + ) + .alternative( + ReserveTransactionType.Recoup, + codecForReserveRecoupTransaction(), + ) + .alternative( + ReserveTransactionType.Credit, + codecForReserveCreditTransaction(), + ) + .build("ReserveTransaction"); diff --git a/packages/taler-wallet-core/src/types/dbTypes.d.ts.map b/packages/taler-wallet-core/src/types/dbTypes.d.ts.map new file mode 100644 index 000000000..7b89c4de4 --- /dev/null +++ b/packages/taler-wallet-core/src/types/dbTypes.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"dbTypes.d.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AC;IACpC,MAAM,CAAC,MAAM,WAAW,kBAAyB,CAAC;IAClD,MAAM,CAAC,MAAM,gBAAgB,uBAA8B,CAAC;IAC5D,MAAM,CAAC,MAAM,SAAS,gBAAuB,CAAC;IAC9C,MAAM,CAAC,MAAM,gBAAgB,uBAA8B,CAAC;IAC5D,MAAM,CAAC,MAAM,YAAY,mBAA0B,CAAC;IACpD,MAAM,CAAC,MAAM,SAAS,gBAAuB,CAAC;IAC9C,MAAM,CAAC,MAAM,oBAAoB,2BAAkC,CAAC;IACpE,MAAM,CAAC,MAAM,qBAAqB,4BAAmC,CAAC;IACtE,MAAM,CAAC,MAAM,aAAa,oBAA2B,CAAC;;CACvD"} \ No newline at end of file diff --git a/packages/taler-wallet-core/src/types/dbTypes.ts b/packages/taler-wallet-core/src/types/dbTypes.ts new file mode 100644 index 000000000..3e1fdfe25 --- /dev/null +++ b/packages/taler-wallet-core/src/types/dbTypes.ts @@ -0,0 +1,1819 @@ +/* + This file is part of GNU Taler + (C) 2018-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 + */ + +/** + * Types for records stored in the wallet's database. + * + * Types for the objects in the database should end in "-Record". + */ + +/** + * Imports. + */ +import { AmountJson } from "../util/amounts"; +import { + Auditor, + CoinDepositPermission, + TipResponse, + ExchangeSignKeyJson, + MerchantInfo, + Product, +} from "./talerTypes"; + +import { Index, Store } from "../util/query"; +import { OperationErrorDetails, RefreshReason } from "./walletTypes"; +import { + ReserveTransaction, + ReserveCreditTransaction, + ReserveWithdrawTransaction, + ReserveClosingTransaction, + ReserveRecoupTransaction, +} from "./ReserveTransaction"; +import { Timestamp, Duration, getTimestampNow } from "../util/time"; +import { PayCoinSelection, PayCostInfo } from "../operations/pay"; +import { idbtypes } from "idb-bridge"; + +export enum ReserveRecordStatus { + /** + * Reserve must be registered with the bank. + */ + REGISTERING_BANK = "registering-bank", + + /** + * We've registered reserve's information with the bank + * and are now waiting for the user to confirm the withdraw + * with the bank (typically 2nd factor auth). + */ + WAIT_CONFIRM_BANK = "wait-confirm-bank", + + /** + * Querying reserve status with the exchange. + */ + QUERYING_STATUS = "querying-status", + + /** + * Status is queried, the wallet must now select coins + * and start withdrawing. + */ + WITHDRAWING = "withdrawing", + + /** + * The corresponding withdraw record has been created. + * No further processing is done, unless explicitly requested + * by the user. + */ + DORMANT = "dormant", +} + +export interface RetryInfo { + firstTry: Timestamp; + nextRetry: Timestamp; + retryCounter: number; + active: boolean; +} + +export interface RetryPolicy { + readonly backoffDelta: Duration; + readonly backoffBase: number; +} + +const defaultRetryPolicy: RetryPolicy = { + backoffBase: 1.5, + backoffDelta: { d_ms: 200 }, +}; + +export function updateRetryInfoTimeout( + r: RetryInfo, + p: RetryPolicy = defaultRetryPolicy, +): void { + const now = getTimestampNow(); + if (now.t_ms === "never") { + throw Error("assertion failed"); + } + if (p.backoffDelta.d_ms === "forever") { + r.nextRetry = { t_ms: "never" }; + return; + } + const t = + now.t_ms + p.backoffDelta.d_ms * Math.pow(p.backoffBase, r.retryCounter); + r.nextRetry = { t_ms: t }; +} + +export function initRetryInfo( + active = true, + p: RetryPolicy = defaultRetryPolicy, +): RetryInfo { + if (!active) { + return { + active: false, + firstTry: { t_ms: Number.MAX_SAFE_INTEGER }, + nextRetry: { t_ms: Number.MAX_SAFE_INTEGER }, + retryCounter: 0, + }; + } + const info = { + firstTry: getTimestampNow(), + active: true, + nextRetry: { t_ms: 0 }, + retryCounter: 0, + }; + updateRetryInfoTimeout(info, p); + return info; +} + +export const enum WalletReserveHistoryItemType { + Credit = "credit", + Withdraw = "withdraw", + Closing = "closing", + Recoup = "recoup", +} + +export interface WalletReserveHistoryCreditItem { + type: WalletReserveHistoryItemType.Credit; + + /** + * Amount we expect to see credited. + */ + expectedAmount?: AmountJson; + + /** + * Item from the reserve transaction history that this + * wallet reserve history item matches up with. + */ + matchedExchangeTransaction?: ReserveCreditTransaction; +} + +export interface WalletReserveHistoryWithdrawItem { + expectedAmount?: AmountJson; + + /** + * Hash of the blinded coin. + * + * When this value is set, it indicates that a withdrawal is active + * in the wallet for the + */ + expectedCoinEvHash?: string; + + type: WalletReserveHistoryItemType.Withdraw; + + /** + * Item from the reserve transaction history that this + * wallet reserve history item matches up with. + */ + matchedExchangeTransaction?: ReserveWithdrawTransaction; +} + +export interface WalletReserveHistoryClosingItem { + type: WalletReserveHistoryItemType.Closing; + + /** + * Item from the reserve transaction history that this + * wallet reserve history item matches up with. + */ + matchedExchangeTransaction?: ReserveClosingTransaction; +} + +export interface WalletReserveHistoryRecoupItem { + type: WalletReserveHistoryItemType.Recoup; + + /** + * Amount we expect to see recouped. + */ + expectedAmount?: AmountJson; + + /** + * Item from the reserve transaction history that this + * wallet reserve history item matches up with. + */ + matchedExchangeTransaction?: ReserveRecoupTransaction; +} + +export type WalletReserveHistoryItem = + | WalletReserveHistoryCreditItem + | WalletReserveHistoryWithdrawItem + | WalletReserveHistoryRecoupItem + | WalletReserveHistoryClosingItem; + +export interface ReserveHistoryRecord { + reservePub: string; + reserveTransactions: WalletReserveHistoryItem[]; +} + +export interface ReserveBankInfo { + /** + * Status URL that the wallet will use to query the status + * of the Taler withdrawal operation on the bank's side. + */ + statusUrl: string; + + confirmUrl?: string; + + /** + * Exchange payto URI that the bank will use to fund the reserve. + */ + exchangePaytoUri: string; +} + +/** + * A reserve record as stored in the wallet's database. + */ +export interface ReserveRecord { + /** + * The reserve public key. + */ + reservePub: string; + + /** + * The reserve private key. + */ + reservePriv: string; + + /** + * The exchange base URL. + */ + exchangeBaseUrl: string; + + /** + * Currency of the reserve. + */ + currency: string; + + /** + * Time when the reserve was created. + */ + timestampCreated: Timestamp; + + /** + * Time when the information about this reserve was posted to the bank. + * + * Only applies if bankWithdrawStatusUrl is defined. + * + * Set to 0 if that hasn't happened yet. + */ + timestampReserveInfoPosted: Timestamp | undefined; + + /** + * Time when the reserve was confirmed by the bank. + * + * Set to undefined if not confirmed yet. + */ + timestampBankConfirmed: Timestamp | undefined; + + /** + * Wire information (as payto URI) for the bank account that + * transfered funds for this reserve. + */ + senderWire?: string; + + /** + * Amount that was sent by the user to fund the reserve. + */ + instructedAmount: AmountJson; + + /** + * Extra state for when this is a withdrawal involving + * a Taler-integrated bank. + */ + bankInfo?: ReserveBankInfo; + + initialWithdrawalGroupId: string; + + /** + * Did we start the first withdrawal for this reserve? + * + * We only report a pending withdrawal for the reserve before + * the first withdrawal has started. + */ + initialWithdrawalStarted: boolean; + initialDenomSel: DenomSelectionState; + + reserveStatus: ReserveRecordStatus; + + /** + * Time of the last successful status query. + */ + lastSuccessfulStatusQuery: Timestamp | undefined; + + /** + * Retry info. This field is present even if no retry is scheduled, + * because we need it to be present for the index on the object store + * to work. + */ + retryInfo: RetryInfo; + + /** + * Last error that happened in a reserve operation + * (either talking to the bank or the exchange). + */ + lastError: OperationErrorDetails | undefined; +} + +/** + * Auditor record as stored with currencies in the exchange database. + */ +export interface AuditorRecord { + /** + * Base url of the auditor. + */ + baseUrl: string; + /** + * Public signing key of the auditor. + */ + auditorPub: string; + /** + * Time when the auditing expires. + */ + expirationStamp: number; +} + +/** + * Exchange for currencies as stored in the wallet's currency + * information database. + */ +export interface ExchangeForCurrencyRecord { + /** + * FIXME: unused? + */ + exchangePub: string; + /** + * Base URL of the exchange. + */ + baseUrl: string; +} + +/** + * Information about a currency as displayed in the wallet's database. + */ +export interface CurrencyRecord { + /** + * Name of the currency. + */ + name: string; + /** + * Number of fractional digits to show when rendering the currency. + */ + fractionalDigits: number; + /** + * Auditors that the wallet trusts for this currency. + */ + auditors: AuditorRecord[]; + /** + * Exchanges that the wallet trusts for this currency. + */ + exchanges: ExchangeForCurrencyRecord[]; +} + +/** + * Status of a denomination. + */ +export enum DenominationStatus { + /** + * Verification was delayed. + */ + Unverified, + /** + * Verified as valid. + */ + VerifiedGood, + /** + * Verified as invalid. + */ + VerifiedBad, +} + +/** + * Denomination record as stored in the wallet's database. + */ +export interface DenominationRecord { + /** + * Value of one coin of the denomination. + */ + value: AmountJson; + + /** + * The denomination public key. + */ + denomPub: string; + + /** + * Hash of the denomination public key. + * Stored in the database for faster lookups. + */ + denomPubHash: string; + + /** + * Fee for withdrawing. + */ + feeWithdraw: AmountJson; + + /** + * Fee for depositing. + */ + feeDeposit: AmountJson; + + /** + * Fee for refreshing. + */ + feeRefresh: AmountJson; + + /** + * Fee for refunding. + */ + feeRefund: AmountJson; + + /** + * Validity start date of the denomination. + */ + stampStart: Timestamp; + + /** + * Date after which the currency can't be withdrawn anymore. + */ + stampExpireWithdraw: Timestamp; + + /** + * Date after the denomination officially doesn't exist anymore. + */ + stampExpireLegal: Timestamp; + + /** + * Data after which coins of this denomination can't be deposited anymore. + */ + stampExpireDeposit: Timestamp; + + /** + * Signature by the exchange's master key over the denomination + * information. + */ + masterSig: string; + + /** + * Did we verify the signature on the denomination? + * + * FIXME: Rename to "verificationStatus"? + */ + status: DenominationStatus; + + /** + * Was this denomination still offered by the exchange the last time + * we checked? + * Only false when the exchange redacts a previously published denomination. + */ + isOffered: boolean; + + /** + * Did the exchange revoke the denomination? + * When this field is set to true in the database, the same transaction + * should also mark all affected coins as revoked. + */ + isRevoked: boolean; + + /** + * Base URL of the exchange. + */ + exchangeBaseUrl: string; +} + +/** + * Details about the exchange that we only know after + * querying /keys and /wire. + */ +export interface ExchangeDetails { + /** + * Master public key of the exchange. + */ + masterPublicKey: string; + + /** + * Auditors (partially) auditing the exchange. + */ + auditors: Auditor[]; + + /** + * Currency that the exchange offers. + */ + currency: string; + + /** + * Last observed protocol version. + */ + protocolVersion: string; + + /** + * Signing keys we got from the exchange, can also contain + * older signing keys that are not returned by /keys anymore. + */ + signingKeys: ExchangeSignKeyJson[]; + + /** + * Timestamp for last update. + */ + lastUpdateTime: Timestamp; +} + +export const enum ExchangeUpdateStatus { + FetchKeys = "fetch-keys", + FetchWire = "fetch-wire", + FetchTerms = "fetch-terms", + FinalizeUpdate = "finalize-update", + Finished = "finished", +} + +export interface ExchangeBankAccount { + payto_uri: string; +} + +export interface ExchangeWireInfo { + feesForType: { [wireMethod: string]: WireFee[] }; + accounts: ExchangeBankAccount[]; +} + +/** + * Summary of updates to the exchange. + */ +// eslint-disable-next-line @typescript-eslint/no-empty-interface +export interface ExchangeUpdateDiff { + // FIXME: implement! +} + +export const enum ExchangeUpdateReason { + Initial = "initial", + Forced = "forced", + Scheduled = "scheduled", +} + +/** + * Exchange record as stored in the wallet's database. + */ +export interface ExchangeRecord { + /** + * Base url of the exchange. + */ + baseUrl: string; + + /** + * Did we finish adding the exchange? + */ + addComplete: boolean; + + /** + * Is this a permanent or temporary exchange record? + */ + permanent: boolean; + + /** + * Was the exchange added as a built-in exchange? + */ + builtIn: boolean; + + /** + * Details, once known. + */ + details: ExchangeDetails | undefined; + + /** + * Mapping from wire method type to the wire fee. + */ + wireInfo: ExchangeWireInfo | undefined; + + /** + * When was the exchange added to the wallet? + */ + timestampAdded: Timestamp; + + /** + * Terms of service text or undefined if not downloaded yet. + */ + termsOfServiceText: string | undefined; + + /** + * ETag for last terms of service download. + */ + termsOfServiceLastEtag: string | undefined; + + /** + * ETag for last terms of service download. + */ + termsOfServiceAcceptedEtag: string | undefined; + + /** + * ETag for last terms of service download. + */ + termsOfServiceAcceptedTimestamp: Timestamp | undefined; + + /** + * Time when the update to the exchange has been started or + * undefined if no update is in progress. + */ + updateStarted: Timestamp | undefined; + + /** + * Status of updating the info about the exchange. + */ + updateStatus: ExchangeUpdateStatus; + + updateReason?: ExchangeUpdateReason; + + /** + * Update diff, will be incorporated when the update is finalized. + */ + updateDiff: ExchangeUpdateDiff | undefined; + + lastError?: OperationErrorDetails; +} + +/** + * A coin that isn't yet signed by an exchange. + */ +export interface PlanchetRecord { + /** + * Public key of the coin. + */ + coinPub: string; + + /** + * Private key of the coin. + */ + coinPriv: string; + + /** + * Withdrawal group that this planchet belongs to + * (or the empty string). + */ + withdrawalGroupId: string; + + /** + * Index within the withdrawal group (or -1). + */ + coinIdx: number; + + withdrawalDone: boolean; + + /** + * Public key of the reserve, this might be a reserve not + * known to the wallet if the planchet is from a tip. + */ + reservePub: string; + denomPubHash: string; + denomPub: string; + blindingKey: string; + withdrawSig: string; + coinEv: string; + coinEvHash: string; + coinValue: AmountJson; + isFromTip: boolean; +} + +/** + * Planchet for a coin during refrehs. + */ +export interface RefreshPlanchetRecord { + /** + * Public key for the coin. + */ + publicKey: string; + /** + * Private key for the coin. + */ + privateKey: string; + /** + * Blinded public key. + */ + coinEv: string; + /** + * Blinding key used. + */ + blindingKey: string; +} + +/** + * Status of a coin. + */ +export const enum CoinStatus { + /** + * Withdrawn and never shown to anybody. + */ + Fresh = "fresh", + /** + * A coin that has been spent and refreshed. + */ + Dormant = "dormant", +} + +export const enum CoinSourceType { + Withdraw = "withdraw", + Refresh = "refresh", + Tip = "tip", +} + +export interface WithdrawCoinSource { + type: CoinSourceType.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 RefreshCoinSource { + type: CoinSourceType.Refresh; + oldCoinPub: string; +} + +export interface TipCoinSource { + type: CoinSourceType.Tip; +} + +export type CoinSource = WithdrawCoinSource | RefreshCoinSource | TipCoinSource; + +/** + * CoinRecord as stored in the "coins" data store + * of the wallet database. + */ +export interface CoinRecord { + /** + * Where did the coin come from? Used for recouping coins. + */ + coinSource: CoinSource; + + /** + * Public key of the coin. + */ + coinPub: string; + + /** + * Private key to authorize operations on the coin. + */ + coinPriv: string; + + /** + * Key used by the exchange used to sign the coin. + */ + denomPub: string; + + /** + * Hash of the public key that signs the coin. + */ + denomPubHash: string; + + /** + * Unblinded signature by the exchange. + */ + denomSig: string; + + /** + * Amount that's left on the coin. + */ + currentAmount: AmountJson; + + /** + * Base URL that identifies the exchange from which we got the + * coin. + */ + exchangeBaseUrl: string; + + /** + * The coin is currently suspended, and will not be used for payments. + */ + suspended: boolean; + + /** + * Blinding key used when withdrawing the coin. + * Potentionally sed again during payback. + */ + blindingKey: string; + + /** + * Status of the coin. + */ + status: CoinStatus; +} + +export const enum ProposalStatus { + /** + * Not downloaded yet. + */ + DOWNLOADING = "downloading", + /** + * Proposal downloaded, but the user needs to accept/reject it. + */ + PROPOSED = "proposed", + /** + * The user has accepted the proposal. + */ + ACCEPTED = "accepted", + /** + * The user has rejected the proposal. + */ + REFUSED = "refused", + /** + * Downloaded proposal was detected as a re-purchase. + */ + REPURCHASE = "repurchase", +} + +export interface ProposalDownload { + /** + * The contract that was offered by the merchant. + */ + contractTermsRaw: string; + + contractData: WalletContractData; +} + +/** + * Record for a downloaded order, stored in the wallet's database. + */ +export interface ProposalRecord { + orderId: string; + + merchantBaseUrl: string; + + /** + * Downloaded data from the merchant. + */ + download: ProposalDownload | undefined; + + /** + * Unique ID when the order is stored in the wallet DB. + */ + proposalId: string; + + /** + * Timestamp (in ms) of when the record + * was created. + */ + timestamp: Timestamp; + + /** + * Private key for the nonce. + */ + noncePriv: string; + + /** + * Public key for the nonce. + */ + noncePub: string; + + claimToken: string | undefined; + + proposalStatus: ProposalStatus; + + repurchaseProposalId: string | undefined; + + /** + * Session ID we got when downloading the contract. + */ + downloadSessionId?: string; + + /** + * Retry info, even present when the operation isn't active to allow indexing + * on the next retry timestamp. + */ + retryInfo: RetryInfo; + + lastError: OperationErrorDetails | undefined; +} + +/** + * Status of a tip we got from a merchant. + */ +export interface TipRecord { + lastError: OperationErrorDetails | undefined; + + /** + * Has the user accepted the tip? Only after the tip has been accepted coins + * withdrawn from the tip may be used. + */ + acceptedTimestamp: Timestamp | undefined; + + /** + * Has the user rejected the tip? + */ + rejectedTimestamp: Timestamp | undefined; + + /** + * Have we picked up the tip record from the merchant already? + */ + pickedUp: boolean; + + /** + * The tipped amount. + */ + amount: AmountJson; + + totalFees: AmountJson; + + /** + * Timestamp, the tip can't be picked up anymore after this deadline. + */ + deadline: Timestamp; + + /** + * The exchange that will sign our coins, chosen by the merchant. + */ + exchangeUrl: string; + + /** + * Base URL of the merchant that is giving us the tip. + */ + merchantBaseUrl: string; + + /** + * Planchets, the members included in TipPlanchetDetail will be sent to the + * merchant. + */ + planchets?: TipPlanchet[]; + + denomsSel: DenomSelectionState; + + /** + * Response if the merchant responded, + * undefined otherwise. + */ + response?: TipResponse[]; + + /** + * Tip ID chosen by the wallet. + */ + tipId: string; + + /** + * The merchant's identifier for this tip. + */ + merchantTipId: string; + + /** + * URL to go to once the tip has been accepted. + */ + nextUrl?: string; + + createdTimestamp: Timestamp; + + /** + * Retry info, even present when the operation isn't active to allow indexing + * on the next retry timestamp. + */ + retryInfo: RetryInfo; +} + +export interface RefreshGroupRecord { + /** + * Retry info, even present when the operation isn't active to allow indexing + * on the next retry timestamp. + */ + retryInfo: RetryInfo; + + lastError: OperationErrorDetails | undefined; + + lastErrorPerCoin: { [coinIndex: number]: OperationErrorDetails }; + + refreshGroupId: string; + + reason: RefreshReason; + + oldCoinPubs: string[]; + + refreshSessionPerCoin: (RefreshSessionRecord | undefined)[]; + + /** + * Flag for each coin whether refreshing finished. + * If a coin can't be refreshed (remaining value too small), + * it will be marked as finished, but no refresh session will + * be created. + */ + finishedPerCoin: boolean[]; + + /** + * Timestamp when the refresh session finished. + */ + timestampFinished: Timestamp | undefined; +} + +/** + * Ongoing refresh + */ +export interface RefreshSessionRecord { + lastError: OperationErrorDetails | undefined; + + /** + * Public key that's being melted in this session. + */ + meltCoinPub: string; + + /** + * How much of the coin's value is melted away + * with this refresh session? + */ + amountRefreshInput: AmountJson; + + /** + * Sum of the value of denominations we want + * to withdraw in this session, without fees. + */ + amountRefreshOutput: AmountJson; + + /** + * Signature to confirm the melting. + */ + confirmSig: string; + + /** + * Hased denominations of the newly requested coins. + */ + newDenomHashes: string[]; + + /** + * Denominations of the newly requested coins. + */ + newDenoms: string[]; + + /** + * Planchets for each cut-and-choose instance. + */ + planchetsForGammas: RefreshPlanchetRecord[][]; + + /** + * The transfer keys, kappa of them. + */ + transferPubs: string[]; + + /** + * Private keys for the transfer public keys. + */ + transferPrivs: string[]; + + /** + * The no-reveal-index after we've done the melting. + */ + norevealIndex?: number; + + /** + * Hash of the session. + */ + hash: string; + + /** + * Timestamp when the refresh session finished. + */ + finishedTimestamp: Timestamp | undefined; + + /** + * When has this refresh session been created? + */ + timestampCreated: Timestamp; + + /** + * Base URL for the exchange we're doing the refresh with. + */ + exchangeBaseUrl: string; +} + +/** + * Tipping planchet stored in the database. + */ +export interface TipPlanchet { + blindingKey: string; + coinEv: string; + coinPriv: string; + coinPub: string; + coinValue: AmountJson; + denomPubHash: string; + denomPub: string; +} + +/** + * Wire fee for one wire method as stored in the + * wallet's database. + */ +export interface WireFee { + /** + * Fee for wire transfers. + */ + wireFee: AmountJson; + + /** + * Fees to close and refund a reserve. + */ + closingFee: AmountJson; + + /** + * Start date of the fee. + */ + startStamp: Timestamp; + + /** + * End date of the fee. + */ + endStamp: Timestamp; + + /** + * Signature made by the exchange master key. + */ + sig: string; +} + +/** + * Record to store information about a refund event. + * + * All information about a refund is stored with the purchase, + * this event is just for the history. + * + * The event is only present for completed refunds. + */ +export interface RefundEventRecord { + timestamp: Timestamp; + merchantExecutionTimestamp: Timestamp; + refundGroupId: string; + proposalId: string; +} + +export const enum RefundState { + Failed = "failed", + Applied = "applied", + Pending = "pending", +} + +/** + * State of one refund from the merchant, maintained by the wallet. + */ +export type WalletRefundItem = + | WalletRefundFailedItem + | WalletRefundPendingItem + | WalletRefundAppliedItem; + +export interface WalletRefundItemCommon { + executionTime: Timestamp; + refundAmount: AmountJson; + refundFee: AmountJson; + + /** + * Upper bound on the refresh cost incurred by + * applying this refund. + * + * Might be lower in practice when two refunds on the same + * coin are refreshed in the same refresh operation. + */ + totalRefreshCostBound: AmountJson; +} + +/** + * Failed refund, either because the merchant did + * something wrong or it expired. + */ +export interface WalletRefundFailedItem extends WalletRefundItemCommon { + type: RefundState.Failed; +} + +export interface WalletRefundPendingItem extends WalletRefundItemCommon { + type: RefundState.Pending; +} + +export interface WalletRefundAppliedItem extends WalletRefundItemCommon { + type: RefundState.Applied; +} + +export const enum RefundReason { + /** + * Normal refund given by the merchant. + */ + NormalRefund = "normal-refund", + /** + * Refund from an aborted payment. + */ + AbortRefund = "abort-pay-refund", +} + +/** + * Record stored for every time we successfully submitted + * a payment to the merchant (both first time and re-play). + */ +export interface PayEventRecord { + proposalId: string; + sessionId: string | undefined; + isReplay: boolean; + timestamp: Timestamp; +} + +export interface ExchangeUpdatedEventRecord { + exchangeBaseUrl: string; + timestamp: Timestamp; +} + +export interface ReserveUpdatedEventRecord { + amountReserveBalance: string; + amountExpected: string; + reservePub: string; + timestamp: Timestamp; + reserveUpdateId: string; + newHistoryTransactions: ReserveTransaction[]; +} + +export interface AllowedAuditorInfo { + auditorBaseUrl: string; + auditorPub: string; +} + +export interface AllowedExchangeInfo { + exchangeBaseUrl: string; + exchangePub: string; +} + +/** + * Data extracted from the contract terms that is relevant for payment + * processing in the wallet. + */ +export interface WalletContractData { + products?: Product[]; + summaryI18n: { [lang_tag: string]: string } | undefined; + fulfillmentUrl: string; + contractTermsHash: string; + merchantSig: string; + merchantPub: string; + merchant: MerchantInfo; + amount: AmountJson; + orderId: string; + merchantBaseUrl: string; + summary: string; + autoRefund: Duration | undefined; + maxWireFee: AmountJson; + wireFeeAmortization: number; + payDeadline: Timestamp; + refundDeadline: Timestamp; + allowedAuditors: AllowedAuditorInfo[]; + allowedExchanges: AllowedExchangeInfo[]; + timestamp: Timestamp; + wireMethod: string; + wireInfoHash: string; + maxDepositFee: AmountJson; +} + +/** + * Record that stores status information about one purchase, starting from when + * the customer accepts a proposal. Includes refund status if applicable. + */ +export interface PurchaseRecord { + /** + * Proposal ID for this purchase. Uniquely identifies the + * purchase and the proposal. + */ + proposalId: string; + + /** + * Contract terms we got from the merchant. + */ + contractTermsRaw: string; + + contractData: WalletContractData; + + /** + * Deposit permissions, available once the user has accepted the payment. + */ + coinDepositPermissions: CoinDepositPermission[]; + + payCoinSelection: PayCoinSelection; + + payCostInfo: PayCostInfo; + + /** + * Timestamp of the first time that sending a payment to the merchant + * for this purchase was successful. + */ + timestampFirstSuccessfulPay: Timestamp | undefined; + + /** + * When was the purchase made? + * Refers to the time that the user accepted. + */ + timestampAccept: Timestamp; + + /** + * Pending refunds for the purchase. A refund is pending + * when the merchant reports a transient error from the exchange. + */ + refunds: { [refundKey: string]: WalletRefundItem }; + + /** + * When was the last refund made? + * Set to 0 if no refund was made on the purchase. + */ + timestampLastRefundStatus: Timestamp | undefined; + + /** + * Last session signature that we submitted to /pay (if any). + */ + lastSessionId: string | undefined; + + /** + * Set for the first payment, or on re-plays. + */ + paymentSubmitPending: boolean; + + /** + * Do we need to query the merchant for the refund status + * of the payment? + */ + refundStatusRequested: boolean; + + /** + * An abort (with refund) was requested for this (incomplete!) purchase. + */ + abortRequested: boolean; + + /** + * The abort (with refund) was completed for this (incomplete!) purchase. + */ + abortDone: boolean; + + payRetryInfo: RetryInfo; + + lastPayError: OperationErrorDetails | undefined; + + /** + * Retry information for querying the refund status with the merchant. + */ + refundStatusRetryInfo: RetryInfo; + + /** + * Last error (or undefined) for querying the refund status with the merchant. + */ + lastRefundStatusError: OperationErrorDetails | undefined; + + /** + * Continue querying the refund status until this deadline has expired. + */ + autoRefundDeadline: Timestamp | undefined; +} + +/** + * Information about wire information for bank accounts we withdrew coins from. + */ +export interface SenderWireRecord { + paytoUri: string; +} + +/** + * Configuration key/value entries to configure + * the wallet. + */ +export interface ConfigRecord { + key: string; + value: any; +} + +/** + * Coin that we're depositing ourselves. + */ +export interface DepositCoin { + coinPaySig: CoinDepositPermission; + + /** + * Undefined if coin not deposited, otherwise signature + * from the exchange confirming the deposit. + */ + depositedSig?: string; +} + +/** + * Record stored in the wallet's database when the user sends coins back to + * their own bank account. Stores the status of coins that are deposited to + * the wallet itself, where the wallet acts as a "merchant" for the customer. + */ +export interface CoinsReturnRecord { + contractTermsRaw: string; + + contractData: WalletContractData; + + /** + * Private key where corresponding + * public key is used in the contract terms + * as merchant pub. + */ + merchantPriv: string; + + coins: DepositCoin[]; + + /** + * Exchange base URL to deposit coins at. + */ + exchange: string; + + /** + * Our own wire information for the deposit. + */ + wire: any; +} + +export const enum WithdrawalSourceType { + Tip = "tip", + Reserve = "reserve", +} + +export interface WithdrawalSourceTip { + type: WithdrawalSourceType.Tip; + tipId: string; +} + +export interface WithdrawalSourceReserve { + type: WithdrawalSourceType.Reserve; + reservePub: string; +} + +export type WithdrawalSource = WithdrawalSourceTip | WithdrawalSourceReserve; + +export interface DenominationSelectionInfo { + totalCoinValue: AmountJson; + totalWithdrawCost: AmountJson; + selectedDenoms: { + /** + * How many times do we withdraw this denomination? + */ + count: number; + denom: DenominationRecord; + }[]; +} + +export interface DenomSelectionState { + totalCoinValue: AmountJson; + totalWithdrawCost: AmountJson; + selectedDenoms: { + denomPubHash: string; + count: number; + }[]; +} + +/** + * Group of withdrawal operations that need to be executed. + * (Either for a normal withdrawal or from a tip.) + * + * The withdrawal group record is only created after we know + * the coin selection we want to withdraw. + */ +export interface WithdrawalGroupRecord { + withdrawalGroupId: string; + + /** + * Withdrawal source. Fields that don't apply to the respective + * withdrawal source type must be null (i.e. can't be absent), + * otherwise the IndexedDB indexing won't like us. + */ + source: WithdrawalSource; + + exchangeBaseUrl: string; + + /** + * When was the withdrawal operation started started? + * Timestamp in milliseconds. + */ + timestampStart: Timestamp; + + /** + * When was the withdrawal operation completed? + */ + timestampFinish?: Timestamp; + + /** + * Amount including fees (i.e. the amount subtracted from the + * reserve to withdraw all coins in this withdrawal session). + */ + rawWithdrawalAmount: AmountJson; + + denomsSel: DenomSelectionState; + + /** + * Retry info, always present even on completed operations so that indexing works. + */ + retryInfo: RetryInfo; + + /** + * Last error per coin/planchet, or undefined if no error occured for + * the coin/planchet. + */ + lastErrorPerCoin: { [coinIndex: number]: OperationErrorDetails }; + + lastError: OperationErrorDetails | undefined; +} + +export interface BankWithdrawUriRecord { + /** + * The withdraw URI we got from the bank. + */ + talerWithdrawUri: string; + + /** + * Reserve that was created for the withdraw URI. + */ + reservePub: string; +} + +/** + * Status of recoup operations that were grouped together. + * + * The remaining amount of involved coins should be set to zero + * in the same transaction that inserts the RecoupGroupRecord. + */ +export interface RecoupGroupRecord { + /** + * Unique identifier for the recoup group record. + */ + recoupGroupId: string; + + timestampStarted: Timestamp; + + timestampFinished: Timestamp | undefined; + + /** + * Public keys that identify the coins being recouped + * as part of this session. + * + * (Structured like this to enable multiEntry indexing in IndexedDB.) + */ + coinPubs: string[]; + + /** + * Array of flags to indicate whether the recoup finished on each individual coin. + */ + recoupFinishedPerCoin: boolean[]; + + /** + * We store old amount (i.e. before recoup) of recouped coins here, + * as the balance of a recouped coin is set to zero when the + * recoup group is created. + */ + oldAmountPerCoin: AmountJson[]; + + /** + * Public keys of coins that should be scheduled for refreshing + * after all individual recoups are done. + */ + scheduleRefreshCoins: string[]; + + /** + * Retry info. + */ + retryInfo: RetryInfo; + + /** + * Last error that occured, if any. + */ + lastError: OperationErrorDetails | undefined; +} + +export const enum ImportPayloadType { + CoreSchema = "core-schema", +} + +/** + * Record to keep track of data imported into the wallet. + */ +export class WalletImportRecord { + /** + * Unique ID to reference this import record. + */ + walletImportId: string; + + /** + * When was the data imported? + */ + timestampImportStarted: Timestamp; + + timestampImportFinished: Timestamp | undefined; + + payloadType: ImportPayloadType; + + /** + * The actual data to import. + */ + payload: any; +} + +/* tslint:disable:completed-docs */ + +class ExchangesStore extends Store { + constructor() { + super("exchanges", { keyPath: "baseUrl" }); + } +} + +class CoinsStore extends Store { + constructor() { + super("coins", { keyPath: "coinPub" }); + } + + exchangeBaseUrlIndex = new Index( + this, + "exchangeBaseUrl", + "exchangeBaseUrl", + ); + denomPubIndex = new Index( + this, + "denomPubIndex", + "denomPub", + ); + denomPubHashIndex = new Index( + this, + "denomPubHashIndex", + "denomPubHash", + ); +} + +class ProposalsStore extends Store { + constructor() { + super("proposals", { keyPath: "proposalId" }); + } + urlAndOrderIdIndex = new Index(this, "urlIndex", [ + "merchantBaseUrl", + "orderId", + ]); +} + +class PurchasesStore extends Store { + constructor() { + super("purchases", { keyPath: "proposalId" }); + } + + fulfillmentUrlIndex = new Index( + this, + "fulfillmentUrlIndex", + "contractData.fulfillmentUrl", + ); + orderIdIndex = new Index(this, "orderIdIndex", [ + "contractData.merchantBaseUrl", + "contractData.orderId", + ]); +} + +class DenominationsStore extends Store { + constructor() { + // cast needed because of bug in type annotations + super("denominations", { + keyPath: (["exchangeBaseUrl", "denomPub"] as any) as idbtypes.IDBKeyPath, + }); + } + + denomPubHashIndex = new Index( + this, + "denomPubHashIndex", + "denomPubHash", + ); + exchangeBaseUrlIndex = new Index( + this, + "exchangeBaseUrlIndex", + "exchangeBaseUrl", + ); + denomPubIndex = new Index( + this, + "denomPubIndex", + "denomPub", + ); +} + +class CurrenciesStore extends Store { + constructor() { + super("currencies", { keyPath: "name" }); + } +} + +class ConfigStore extends Store { + constructor() { + super("config", { keyPath: "key" }); + } +} + +class ReservesStore extends Store { + constructor() { + super("reserves", { keyPath: "reservePub" }); + } +} + +class ReserveHistoryStore extends Store { + constructor() { + super("reserveHistory", { keyPath: "reservePub" }); + } +} + +class TipsStore extends Store { + constructor() { + super("tips", { keyPath: "tipId" }); + } +} + +class SenderWiresStore extends Store { + constructor() { + super("senderWires", { keyPath: "paytoUri" }); + } +} + +class WithdrawalGroupsStore extends Store { + constructor() { + super("withdrawals", { keyPath: "withdrawalGroupId" }); + } +} + +class PlanchetsStore extends Store { + constructor() { + super("planchets", { keyPath: "coinPub" }); + } + byGroupAndIndex = new Index( + this, + "withdrawalGroupAndCoinIdxIndex", + ["withdrawalGroupId", "coinIdx"], + ); + byGroup = new Index( + this, + "withdrawalGroupIndex", + "withdrawalGroupId", + ); +} + +class RefundEventsStore extends Store { + constructor() { + super("refundEvents", { keyPath: "refundGroupId" }); + } +} + +class PayEventsStore extends Store { + constructor() { + super("payEvents", { keyPath: "proposalId" }); + } +} + +class ExchangeUpdatedEventsStore extends Store { + constructor() { + super("exchangeUpdatedEvents", { keyPath: "exchangeBaseUrl" }); + } +} + +class ReserveUpdatedEventsStore extends Store { + constructor() { + super("reserveUpdatedEvents", { keyPath: "reservePub" }); + } +} + +class BankWithdrawUrisStore extends Store { + constructor() { + super("bankWithdrawUris", { keyPath: "talerWithdrawUri" }); + } +} + +class WalletImportsStore extends Store { + constructor() { + super("walletImports", { keyPath: "walletImportId" }); + } +} + +/** + * The stores and indices for the wallet database. + */ + +export const Stores = { + coins: new CoinsStore(), + coinsReturns: new Store("coinsReturns", { + keyPath: "contractTermsHash", + }), + config: new ConfigStore(), + currencies: new CurrenciesStore(), + denominations: new DenominationsStore(), + exchanges: new ExchangesStore(), + proposals: new ProposalsStore(), + refreshGroups: new Store("refreshGroups", { + keyPath: "refreshGroupId", + }), + recoupGroups: new Store("recoupGroups", { + keyPath: "recoupGroupId", + }), + reserves: new ReservesStore(), + reserveHistory: new ReserveHistoryStore(), + purchases: new PurchasesStore(), + tips: new TipsStore(), + senderWires: new SenderWiresStore(), + withdrawalGroups: new WithdrawalGroupsStore(), + planchets: new PlanchetsStore(), + bankWithdrawUris: new BankWithdrawUrisStore(), + refundEvents: new RefundEventsStore(), + payEvents: new PayEventsStore(), + reserveUpdatedEvents: new ReserveUpdatedEventsStore(), + exchangeUpdatedEvents: new ExchangeUpdatedEventsStore(), + walletImports: new WalletImportsStore(), +}; + +/* tslint:enable:completed-docs */ diff --git a/packages/taler-wallet-core/src/types/notifications.d.ts.map b/packages/taler-wallet-core/src/types/notifications.d.ts.map new file mode 100644 index 000000000..f1b3318d5 --- /dev/null +++ b/packages/taler-wallet-core/src/types/notifications.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"notifications.d.ts","sourceRoot":"","sources":["notifications.ts"],"names":[],"mappings":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AC,oBAAoB,CAAC;IAC5C,KAAK,EAAE,qBAAqB,CAAC;CAC9B;AAED,MAAM,WAAW,iCAAiC;IAChD,IAAI,EAAE,gBAAgB,CAAC,qBAAqB,CAAC;IAC7C,KAAK,EAAE,qBAAqB,CAAC;CAC9B;AAED,MAAM,WAAW,0BAA0B;IACzC,IAAI,EAAE,gBAAgB,CAAC,cAAc,CAAC;IACtC,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,qCAAqC;IACpD,IAAI,EAAE,gBAAgB,CAAC,yBAAyB,CAAC;CAClD;AAED,MAAM,WAAW,2BAA2B;IAC1C,IAAI,EAAE,gBAAgB,CAAC,eAAe,CAAC;CACxC;AAED,MAAM,WAAW,qCAAqC;IACpD,IAAI,EAAE,gBAAgB,CAAC,yBAAyB,CAAC;CAClD;AAED,oBAAY,kBAAkB,GAC1B,kCAAkC,GAClC,iCAAiC,GACjC,kCAAkC,GAClC,iCAAiC,GACjC,sCAAsC,GACtC,qCAAqC,GACrC,kCAAkC,GAClC,6BAA6B,GAC7B,6BAA6B,GAC7B,4BAA4B,GAC5B,8BAA8B,GAC9B,4BAA4B,GAC5B,yBAAyB,GACzB,0BAA0B,GAC1B,yBAAyB,GACzB,2BAA2B,GAC3B,0BAA0B,GAC1B,0BAA0B,GAC1B,0BAA0B,GAC1B,0BAA0B,GAC1B,4BAA4B,GAC5B,mCAAmC,GACnC,2BAA2B,GAC3B,yBAAyB,GACzB,0BAA0B,GAC1B,yBAAyB,GACzB,kCAAkC,GAClC,yBAAyB,GACzB,gCAAgC,GAChC,yBAAyB,GACzB,qCAAqC,GACrC,2BAA2B,GAC3B,qCAAqC,GACrC,8BAA8B,CAAC"} \ No newline at end of file diff --git a/packages/taler-wallet-core/src/types/notifications.ts b/packages/taler-wallet-core/src/types/notifications.ts new file mode 100644 index 000000000..945b86eea --- /dev/null +++ b/packages/taler-wallet-core/src/types/notifications.ts @@ -0,0 +1,255 @@ +/* + This file is part of GNU Taler + (C) 2019 GNUnet e.V. + + 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 + */ + +/** + * Type and schema definitions for notifications from the wallet to clients + * of the wallet. + */ + +/** + * Imports. + */ +import { OperationErrorDetails } from "./walletTypes"; +import { WithdrawalSource } from "./dbTypes"; + +export const enum NotificationType { + CoinWithdrawn = "coin-withdrawn", + ProposalAccepted = "proposal-accepted", + ProposalDownloaded = "proposal-downloaded", + RefundsSubmitted = "refunds-submitted", + RecoupStarted = "recoup-started", + RecoupFinished = "recoup-finished", + RefreshRevealed = "refresh-revealed", + RefreshMelted = "refresh-melted", + RefreshStarted = "refresh-started", + RefreshUnwarranted = "refresh-unwarranted", + ReserveUpdated = "reserve-updated", + ReserveConfirmed = "reserve-confirmed", + ReserveCreated = "reserve-created", + WithdrawGroupCreated = "withdraw-group-created", + WithdrawGroupFinished = "withdraw-group-finished", + WaitingForRetry = "waiting-for-retry", + RefundStarted = "refund-started", + RefundQueried = "refund-queried", + RefundFinished = "refund-finished", + ExchangeOperationError = "exchange-operation-error", + RefreshOperationError = "refresh-operation-error", + RecoupOperationError = "recoup-operation-error", + RefundApplyOperationError = "refund-apply-error", + RefundStatusOperationError = "refund-status-error", + ProposalOperationError = "proposal-error", + TipOperationError = "tip-error", + PayOperationError = "pay-error", + WithdrawOperationError = "withdraw-error", + ReserveNotYetFound = "reserve-not-yet-found", + ReserveOperationError = "reserve-error", + InternalError = "internal-error", + PendingOperationProcessed = "pending-operation-processed", + ProposalRefused = "proposal-refused", + ReserveRegisteredWithBank = "reserve-registered-with-bank", +} + +export interface ProposalAcceptedNotification { + type: NotificationType.ProposalAccepted; + proposalId: string; +} + +export interface InternalErrorNotification { + type: NotificationType.InternalError; + message: string; + exception: any; +} + +export interface ReserveNotYetFoundNotification { + type: NotificationType.ReserveNotYetFound; + reservePub: string; +} + +export interface CoinWithdrawnNotification { + type: NotificationType.CoinWithdrawn; +} + +export interface RefundStartedNotification { + type: NotificationType.RefundStarted; +} + +export interface RefundQueriedNotification { + type: NotificationType.RefundQueried; +} + +export interface ProposalDownloadedNotification { + type: NotificationType.ProposalDownloaded; + proposalId: string; +} + +export interface RefundsSubmittedNotification { + type: NotificationType.RefundsSubmitted; + proposalId: string; +} + +export interface RecoupStartedNotification { + type: NotificationType.RecoupStarted; +} + +export interface RecoupFinishedNotification { + type: NotificationType.RecoupFinished; +} + +export interface RefreshMeltedNotification { + type: NotificationType.RefreshMelted; +} + +export interface RefreshRevealedNotification { + type: NotificationType.RefreshRevealed; +} + +export interface RefreshStartedNotification { + type: NotificationType.RefreshStarted; +} + +export interface RefreshRefusedNotification { + type: NotificationType.RefreshUnwarranted; +} + +export interface ReserveUpdatedNotification { + type: NotificationType.ReserveUpdated; +} + +export interface ReserveConfirmedNotification { + type: NotificationType.ReserveConfirmed; +} + +export interface WithdrawalGroupCreatedNotification { + type: NotificationType.WithdrawGroupCreated; + withdrawalGroupId: string; +} + +export interface WithdrawalGroupFinishedNotification { + type: NotificationType.WithdrawGroupFinished; + withdrawalSource: WithdrawalSource; +} + +export interface WaitingForRetryNotification { + type: NotificationType.WaitingForRetry; + numPending: number; + numGivingLiveness: number; +} + +export interface RefundFinishedNotification { + type: NotificationType.RefundFinished; +} + +export interface ExchangeOperationErrorNotification { + type: NotificationType.ExchangeOperationError; + error: OperationErrorDetails; +} + +export interface RefreshOperationErrorNotification { + type: NotificationType.RefreshOperationError; + error: OperationErrorDetails; +} + +export interface RefundStatusOperationErrorNotification { + type: NotificationType.RefundStatusOperationError; + error: OperationErrorDetails; +} + +export interface RefundApplyOperationErrorNotification { + type: NotificationType.RefundApplyOperationError; + error: OperationErrorDetails; +} + +export interface PayOperationErrorNotification { + type: NotificationType.PayOperationError; + error: OperationErrorDetails; +} + +export interface ProposalOperationErrorNotification { + type: NotificationType.ProposalOperationError; + error: OperationErrorDetails; +} + +export interface TipOperationErrorNotification { + type: NotificationType.TipOperationError; +} + +export interface WithdrawOperationErrorNotification { + type: NotificationType.WithdrawOperationError; + error: OperationErrorDetails; +} + +export interface RecoupOperationErrorNotification { + type: NotificationType.RecoupOperationError; + error: OperationErrorDetails; +} + +export interface ReserveOperationErrorNotification { + type: NotificationType.ReserveOperationError; + error: OperationErrorDetails; +} + +export interface ReserveCreatedNotification { + type: NotificationType.ReserveCreated; + reservePub: string; +} + +export interface PendingOperationProcessedNotification { + type: NotificationType.PendingOperationProcessed; +} + +export interface ProposalRefusedNotification { + type: NotificationType.ProposalRefused; +} + +export interface ReserveRegisteredWithBankNotification { + type: NotificationType.ReserveRegisteredWithBank; +} + +export type WalletNotification = + | WithdrawOperationErrorNotification + | ReserveOperationErrorNotification + | ExchangeOperationErrorNotification + | RefreshOperationErrorNotification + | RefundStatusOperationErrorNotification + | RefundApplyOperationErrorNotification + | ProposalOperationErrorNotification + | PayOperationErrorNotification + | TipOperationErrorNotification + | ProposalAcceptedNotification + | ProposalDownloadedNotification + | RefundsSubmittedNotification + | RecoupStartedNotification + | RecoupFinishedNotification + | RefreshMeltedNotification + | RefreshRevealedNotification + | RefreshStartedNotification + | RefreshRefusedNotification + | ReserveUpdatedNotification + | ReserveCreatedNotification + | ReserveConfirmedNotification + | WithdrawalGroupFinishedNotification + | WaitingForRetryNotification + | RefundStartedNotification + | RefundFinishedNotification + | RefundQueriedNotification + | WithdrawalGroupCreatedNotification + | CoinWithdrawnNotification + | RecoupOperationErrorNotification + | InternalErrorNotification + | PendingOperationProcessedNotification + | ProposalRefusedNotification + | ReserveRegisteredWithBankNotification + | ReserveNotYetFoundNotification; diff --git a/packages/taler-wallet-core/src/types/pending.d.ts.map b/packages/taler-wallet-core/src/types/pending.d.ts.map new file mode 100644 index 000000000..2f88198fa --- /dev/null +++ b/packages/taler-wallet-core/src/types/pending.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"pending.d.ts","sourceRoot":"","sources":["pending.ts"],"names":[],"mappings":"AAgBA;;GAEG;AAEH;;GAEG;AACH,OAAO,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACxE,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAC7E,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAEnD,0BAAkB,oBAAoB;IACpC,GAAG,QAAQ;IACX,cAAc,oBAAoB;IAClC,GAAG,QAAQ;IACX,cAAc,oBAAoB;IAClC,gBAAgB,sBAAsB;IACtC,OAAO,YAAY;IACnB,OAAO,YAAY;IACnB,MAAM,WAAW;IACjB,WAAW,iBAAiB;IAC5B,SAAS,eAAe;IACxB,SAAS,eAAe;IACxB,QAAQ,aAAa;CACtB;AAED;;GAEG;AACH,oBAAY,oBAAoB,GAAG,0BAA0B,GAC3D,CACI,mBAAmB,GACnB,8BAA8B,GAC9B,mBAAmB,GACnB,8BAA8B,GAC9B,gCAAgC,GAChC,uBAAuB,GACvB,2BAA2B,GAC3B,uBAAuB,GACvB,yBAAyB,GACzB,yBAAyB,GACzB,wBAAwB,GACxB,sBAAsB,CACzB,CAAC;AAEJ;;GAEG;AACH,MAAM,WAAW,8BAA8B;IAC7C,IAAI,EAAE,oBAAoB,CAAC,cAAc,CAAC;IAC1C,KAAK,EAAE,4BAA4B,CAAC;IACpC,MAAM,EAAE,MAAM,CAAC;IACf,eAAe,EAAE,MAAM,CAAC;IACxB,SAAS,EAAE,qBAAqB,GAAG,SAAS,CAAC;CAC9C;AAED;;;;GAIG;AACH,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE,oBAAoB,CAAC,GAAG,CAAC;IAC/B,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,GAAG,CAAC;CACd;AAED;;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EAAE,oBAAoB,CAAC;IAE3B;;;OAGG;IACH,aAAa,EAAE,OAAO,CAAC;CACxB;AAED;;GAEG;AACH,MAAM,WAAW,yBAAyB;IACxC;;OAEG;IACH,iBAAiB,EAAE,oBAAoB,EAAE,CAAC;IAE1C;;OAEG;IACH,aAAa,EAAE,gBAAgB,CAAC;IAEhC;;OAEG;IACH,cAAc,EAAE,QAAQ,CAAC;IAEzB;;;OAGG;IACH,OAAO,EAAE,OAAO,CAAC;CAClB"} \ No newline at end of file diff --git a/packages/taler-wallet-core/src/types/pending.ts b/packages/taler-wallet-core/src/types/pending.ts new file mode 100644 index 000000000..85f7585c5 --- /dev/null +++ b/packages/taler-wallet-core/src/types/pending.ts @@ -0,0 +1,258 @@ +/* + This file is part of GNU Taler + (C) 2019 GNUnet e.V. + + 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 + */ + +/** + * Type and schema definitions for pending operations in the wallet. + */ + +/** + * Imports. + */ +import { OperationErrorDetails, BalancesResponse } from "./walletTypes"; +import { WithdrawalSource, RetryInfo, ReserveRecordStatus } from "./dbTypes"; +import { Timestamp, Duration } from "../util/time"; + +export const enum PendingOperationType { + Bug = "bug", + ExchangeUpdate = "exchange-update", + Pay = "pay", + ProposalChoice = "proposal-choice", + ProposalDownload = "proposal-download", + Refresh = "refresh", + Reserve = "reserve", + Recoup = "recoup", + RefundQuery = "refund-query", + TipChoice = "tip-choice", + TipPickup = "tip-pickup", + Withdraw = "withdraw", +} + +/** + * Information about a pending operation. + */ +export type PendingOperationInfo = PendingOperationInfoCommon & + ( + | PendingBugOperation + | PendingExchangeUpdateOperation + | PendingPayOperation + | PendingProposalChoiceOperation + | PendingProposalDownloadOperation + | PendingRefreshOperation + | PendingRefundQueryOperation + | PendingReserveOperation + | PendingTipChoiceOperation + | PendingTipPickupOperation + | PendingWithdrawOperation + | PendingRecoupOperation + ); + +/** + * The wallet is currently updating information about an exchange. + */ +export interface PendingExchangeUpdateOperation { + type: PendingOperationType.ExchangeUpdate; + stage: ExchangeUpdateOperationStage; + reason: string; + exchangeBaseUrl: string; + lastError: OperationErrorDetails | undefined; +} + +/** + * Some interal error happened in the wallet. This pending operation + * should *only* be reported for problems in the wallet, not when + * a problem with a merchant/exchange/etc. occurs. + */ +export interface PendingBugOperation { + type: PendingOperationType.Bug; + message: string; + details: any; +} + +/** + * Current state of an exchange update operation. + */ +export const enum ExchangeUpdateOperationStage { + FetchKeys = "fetch-keys", + FetchWire = "fetch-wire", + FinalizeUpdate = "finalize-update", +} + +export const enum ReserveType { + /** + * Manually created. + */ + Manual = "manual", + /** + * Withdrawn from a bank that has "tight" Taler integration + */ + TalerBankWithdraw = "taler-bank-withdraw", +} + +/** + * Status of processing a reserve. + * + * Does *not* include the withdrawal operation that might result + * from this. + */ +export interface PendingReserveOperation { + type: PendingOperationType.Reserve; + retryInfo: RetryInfo | undefined; + stage: ReserveRecordStatus; + timestampCreated: Timestamp; + reserveType: ReserveType; + reservePub: string; + bankWithdrawConfirmUrl?: string; +} + +/** + * Status of an ongoing withdrawal operation. + */ +export interface PendingRefreshOperation { + type: PendingOperationType.Refresh; + lastError?: OperationErrorDetails; + refreshGroupId: string; + finishedPerCoin: boolean[]; + retryInfo: RetryInfo; +} + +/** + * Status of downloading signed contract terms from a merchant. + */ +export interface PendingProposalDownloadOperation { + type: PendingOperationType.ProposalDownload; + merchantBaseUrl: string; + proposalTimestamp: Timestamp; + proposalId: string; + orderId: string; + lastError?: OperationErrorDetails; + retryInfo: RetryInfo; +} + +/** + * User must choose whether to accept or reject the merchant's + * proposed contract terms. + */ +export interface PendingProposalChoiceOperation { + type: PendingOperationType.ProposalChoice; + merchantBaseUrl: string; + proposalTimestamp: Timestamp; + proposalId: string; +} + +/** + * The wallet is picking up a tip that the user has accepted. + */ +export interface PendingTipPickupOperation { + type: PendingOperationType.TipPickup; + tipId: string; + merchantBaseUrl: string; + merchantTipId: string; +} + +/** + * The wallet has been offered a tip, and the user now needs to + * decide whether to accept or reject the tip. + */ +export interface PendingTipChoiceOperation { + type: PendingOperationType.TipChoice; + tipId: string; + merchantBaseUrl: string; + merchantTipId: string; +} + +/** + * The wallet is signing coins and then sending them to + * the merchant. + */ +export interface PendingPayOperation { + type: PendingOperationType.Pay; + proposalId: string; + isReplay: boolean; + retryInfo: RetryInfo; + lastError: OperationErrorDetails | undefined; +} + +/** + * The wallet is querying the merchant about whether any refund + * permissions are available for a purchase. + */ +export interface PendingRefundQueryOperation { + type: PendingOperationType.RefundQuery; + proposalId: string; + retryInfo: RetryInfo; + lastError: OperationErrorDetails | undefined; +} + +export interface PendingRecoupOperation { + type: PendingOperationType.Recoup; + recoupGroupId: string; + retryInfo: RetryInfo; + lastError: OperationErrorDetails | undefined; +} + +/** + * Status of an ongoing withdrawal operation. + */ +export interface PendingWithdrawOperation { + type: PendingOperationType.Withdraw; + source: WithdrawalSource; + lastError: OperationErrorDetails | undefined; + withdrawalGroupId: string; + numCoinsWithdrawn: number; + numCoinsTotal: number; +} + +/** + * Fields that are present in every pending operation. + */ +export interface PendingOperationInfoCommon { + /** + * Type of the pending operation. + */ + type: PendingOperationType; + + /** + * Set to true if the operation indicates that something is really in progress, + * as opposed to some regular scheduled operation or a permanent failure. + */ + givesLifeness: boolean; +} + +/** + * Response returned from the pending operations API. + */ +export interface PendingOperationsResponse { + /** + * List of pending operations. + */ + pendingOperations: PendingOperationInfo[]; + + /** + * Current wallet balance, including pending balances. + */ + walletBalance: BalancesResponse; + + /** + * When is the next pending operation due to be re-tried? + */ + nextRetryDelay: Duration; + + /** + * Does this response only include pending operations that + * are due to be executed right now? + */ + onlyDue: boolean; +} diff --git a/packages/taler-wallet-core/src/types/schemacore.ts b/packages/taler-wallet-core/src/types/schemacore.ts new file mode 100644 index 000000000..820f68d18 --- /dev/null +++ b/packages/taler-wallet-core/src/types/schemacore.ts @@ -0,0 +1,58 @@ +/* + 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 + */ + +/** + * 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/talerTypes.d.ts.map b/packages/taler-wallet-core/src/types/talerTypes.d.ts.map new file mode 100644 index 000000000..0419ea14f --- /dev/null +++ b/packages/taler-wallet-core/src/types/talerTypes.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"talerTypes.d.ts","sourceRoot":"","sources":["talerTypes.ts"],"names":[],"mappings":"AAgBA;;;;;;;GAOG;AAEH;;GAEG;AAEH,OAAO,EASL,KAAK,EAIN,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,SAAS,EAET,QAAQ,EAET,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAE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AA0B,QAAO,KAAK,CAAC,kBAAkB,CAGtC,CAAC;AAEjC,eAAO,MAAM,8BAA8B,QAAO,KAAK,CACrD,sBAAsB,CAIY,CAAC;AAErC,eAAO,MAAM,uCAAuC,QAAO,KAAK,CAC9D,+BAA+B,CAWY,CAAC;AAE9C,eAAO,MAAM,uCAAuC,QAAO,KAAK,CAC9D,+BAA+B,CAWY,CAAC;AAE9C,eAAO,MAAM,gCAAgC,QAAO,KAAK,CACvD,wBAAwB,CAMY,CAAC;AAEvC,eAAO,MAAM,+BAA+B,QAAO,KAAK,CACtD,uBAAuB,CAOY,CAAC;AAEtC,eAAO,MAAM,iCAAiC,QAAO,KAAK,CACxD,yBAAyB,CAKY,CAAC"} \ No newline at end of file diff --git a/packages/taler-wallet-core/src/types/talerTypes.ts b/packages/taler-wallet-core/src/types/talerTypes.ts new file mode 100644 index 000000000..acebbda95 --- /dev/null +++ b/packages/taler-wallet-core/src/types/talerTypes.ts @@ -0,0 +1,1272 @@ +/* + This file is part of GNU Taler + (C) 2019 GNUnet e.V. + + 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 + */ + +/** + * Type and schema definitions and helpers for the core GNU Taler protocol. + * + * All types here should be "@Checkable". + * + * Even though the rest of the wallet uses camelCase for fields, use snake_case + * here, since that's the convention for the Taler JSON+HTTP API. + */ + +/** + * Imports. + */ + +import { + makeCodecForObject, + codecForString, + makeCodecForList, + makeCodecOptional, + codecForAny, + codecForNumber, + codecForBoolean, + makeCodecForMap, + Codec, + makeCodecForConstNumber, + makeCodecForUnion, + makeCodecForConstString, +} from "../util/codec"; +import { + Timestamp, + codecForTimestamp, + Duration, + codecForDuration, +} from "../util/time"; +import { ExchangeListItem } from "./walletTypes"; + +/** + * Denomination as found in the /keys response from the exchange. + */ +export class Denomination { + /** + * Value of one coin of the denomination. + */ + value: string; + + /** + * Public signing key of the denomination. + */ + denom_pub: string; + + /** + * Fee for withdrawing. + */ + fee_withdraw: string; + + /** + * Fee for depositing. + */ + fee_deposit: string; + + /** + * Fee for refreshing. + */ + fee_refresh: string; + + /** + * Fee for refunding. + */ + fee_refund: string; + + /** + * Start date from which withdraw is allowed. + */ + stamp_start: Timestamp; + + /** + * End date for withdrawing. + */ + stamp_expire_withdraw: Timestamp; + + /** + * Expiration date after which the exchange can forget about + * the currency. + */ + stamp_expire_legal: Timestamp; + + /** + * Date after which the coins of this denomination can't be + * deposited anymore. + */ + stamp_expire_deposit: Timestamp; + + /** + * Signature over the denomination information by the exchange's master + * signing key. + */ + master_sig: string; +} + +/** + * Signature by the auditor that a particular denomination key is audited. + */ +export class AuditorDenomSig { + /** + * Denomination public key's hash. + */ + denom_pub_h: string; + + /** + * The signature. + */ + auditor_sig: string; +} + +/** + * Auditor information as given by the exchange in /keys. + */ +export class Auditor { + /** + * Auditor's public key. + */ + auditor_pub: string; + + /** + * Base URL of the auditor. + */ + auditor_url: string; + + /** + * List of signatures for denominations by the auditor. + */ + denomination_keys: AuditorDenomSig[]; +} + +/** + * Request that we send to the exchange to get a payback. + */ +export interface RecoupRequest { + /** + * Hashed enomination public key of the coin we want to get + * paid back. + */ + denom_pub_hash: string; + + /** + * Signature over the coin public key by the denomination. + */ + denom_sig: string; + + /** + * Coin public key of the coin we want to refund. + */ + coin_pub: string; + + /** + * Blinding key that was used during withdraw, + * used to prove that we were actually withdrawing the coin. + */ + coin_blind_key_secret: string; + + /** + * Signature made by the coin, authorizing the payback. + */ + coin_sig: string; + + /** + * Was the coin refreshed (and thus the recoup should go to the old coin)? + */ + refreshed: boolean; +} + +/** + * Response that we get from the exchange for a payback request. + */ +export class RecoupConfirmation { + /** + * Public key of the reserve that will receive the payback. + */ + reserve_pub?: string; + + /** + * Public key of the old coin that will receive the recoup, + * provided if refreshed was true. + */ + old_coin_pub?: string; +} + +/** + * Deposit permission for a single coin. + */ +export interface CoinDepositPermission { + /** + * Signature by the coin. + */ + coin_sig: string; + /** + * Public key of the coin being spend. + */ + coin_pub: string; + /** + * Signature made by the denomination public key. + */ + ub_sig: string; + /** + * The denomination public key associated with this coin. + */ + h_denom: string; + /** + * The amount that is subtracted from this coin with this payment. + */ + contribution: string; + + /** + * URL of the exchange this coin was withdrawn from. + */ + exchange_url: string; +} + +/** + * Information about an exchange as stored inside a + * merchant's contract terms. + */ +export class ExchangeHandle { + /** + * Master public signing key of the exchange. + */ + master_pub: string; + + /** + * Base URL of the exchange. + */ + url: string; +} + +export class AuditorHandle { + /** + * Official name of the auditor. + */ + name: string; + + /** + * Master public signing key of the auditor. + */ + master_pub: string; + + /** + * Base URL of the auditor. + */ + url: string; +} + +export interface MerchantInfo { + name: string; + jurisdiction: string | undefined; + address: string | undefined; +} + +export interface Tax { + // the name of the tax + name: string; + + // amount paid in tax + tax: AmountString; +} + +export interface Product { + // merchant-internal identifier for the product. + product_id?: string; + + // Human-readable product description. + description: string; + + // Map from IETF BCP 47 language tags to localized descriptions + description_i18n?: { [lang_tag: string]: string }; + + // The number of units of the product to deliver to the customer. + quantity?: number; + + // The unit in which the product is measured (liters, kilograms, packages, etc.) + unit?: string; + + // The price of the product; this is the total price for quantity times unit of this product. + price?: AmountString; + + // An optional base64-encoded product image + image?: string; + + // a list of taxes paid by the merchant for this product. Can be empty. + taxes?: Tax[]; + + // time indicating when this product should be delivered + delivery_date?: Timestamp; + + // where to deliver this product. This may be an URL for online delivery + // (i.e. 'http://example.com/download' or 'mailto:customer@example.com'), + // or a location label defined inside the proposition's 'locations'. + // The presence of a colon (':') indicates the use of an URL. + delivery_location?: string; +} + +/** + * Contract terms from a merchant. + */ +export class ContractTerms { + /** + * Hash of the merchant's wire details. + */ + h_wire: string; + + /** + * Hash of the merchant's wire details. + */ + auto_refund?: Duration; + + /** + * Wire method the merchant wants to use. + */ + wire_method: string; + + /** + * Human-readable short summary of the contract. + */ + summary: string; + + summary_i18n?: { [lang_tag: string]: string }; + + /** + * Nonce used to ensure freshness. + */ + nonce: string; + + /** + * Total amount payable. + */ + amount: string; + + /** + * Auditors accepted by the merchant. + */ + auditors: AuditorHandle[]; + + /** + * Deadline to pay for the contract. + */ + pay_deadline: Timestamp; + + /** + * Delivery locations. + */ + locations: any; + + /** + * Maximum deposit fee covered by the merchant. + */ + max_fee: string; + + /** + * Information about the merchant. + */ + merchant: MerchantInfo; + + /** + * Public key of the merchant. + */ + merchant_pub: string; + + /** + * List of accepted exchanges. + */ + exchanges: ExchangeHandle[]; + + /** + * Products that are sold in this contract. + */ + products?: Product[]; + + /** + * Deadline for refunds. + */ + refund_deadline: Timestamp; + + /** + * Deadline for the wire transfer. + */ + wire_transfer_deadline: Timestamp; + + /** + * Time when the contract was generated by the merchant. + */ + timestamp: Timestamp; + + /** + * Order id to uniquely identify the purchase within + * one merchant instance. + */ + order_id: string; + + /** + * Base URL of the merchant's backend. + */ + merchant_base_url: string; + + /** + * Fulfillment URL to view the product or + * delivery status. + */ + fulfillment_url: string; + + /** + * Share of the wire fee that must be settled with one payment. + */ + wire_fee_amortization?: number; + + /** + * Maximum wire fee that the merchant agrees to pay for. + */ + max_wire_fee?: string; + + /** + * Extra data, interpreted by the mechant only. + */ + extra: any; +} + +/** + * Refund permission in the format that the merchant gives it to us. + */ +export class MerchantAbortPayRefundDetails { + /** + * Amount to be refunded. + */ + refund_amount: string; + + /** + * Fee for the refund. + */ + refund_fee: string; + + /** + * Public key of the coin being refunded. + */ + coin_pub: string; + + /** + * Refund transaction ID between merchant and exchange. + */ + rtransaction_id: number; + + /** + * Exchange's key used for the signature. + */ + exchange_pub?: string; + + /** + * Exchange's signature to confirm the refund. + */ + exchange_sig?: string; + + /** + * Error replay from the exchange (if any). + */ + exchange_reply?: any; + + /** + * Error code from the exchange (if any). + */ + exchange_code?: number; + + /** + * HTTP status code of the exchange's response + * to the merchant's refund request. + */ + exchange_http_status: number; +} + +/** + * Response for a refund pickup or a /pay in abort mode. + */ +export class MerchantRefundResponse { + /** + * Public key of the merchant + */ + merchant_pub: string; + + /** + * Contract terms hash of the contract that + * is being refunded. + */ + h_contract_terms: string; + + /** + * The signed refund permissions, to be sent to the exchange. + */ + refunds: MerchantAbortPayRefundDetails[]; +} + +/** + * Planchet detail sent to the merchant. + */ +export interface TipPlanchetDetail { + /** + * Hashed denomination public key. + */ + denom_pub_hash: string; + + /** + * Coin's blinded public key. + */ + coin_ev: string; +} + +/** + * Request sent to the merchant to pick up a tip. + */ +export interface TipPickupRequest { + /** + * Identifier of the tip. + */ + tip_id: string; + + /** + * List of planchets the wallet wants to use for the tip. + */ + planchets: TipPlanchetDetail[]; +} + +/** + * Reserve signature, defined as separate class to facilitate + * schema validation with "@Checkable". + */ +export class ReserveSigSingleton { + /** + * Reserve signature. + */ + reserve_sig: string; +} + +/** + * Response of the merchant + * to the TipPickupRequest. + */ +export class TipResponse { + /** + * Public key of the reserve + */ + reserve_pub: string; + + /** + * The order of the signatures matches the planchets list. + */ + reserve_sigs: ReserveSigSingleton[]; +} + +/** + * Element of the payback list that the + * exchange gives us in /keys. + */ +export class Recoup { + /** + * The hash of the denomination public key for which the payback is offered. + */ + h_denom_pub: string; +} + +/** + * Structure of one exchange signing key in the /keys response. + */ +export class ExchangeSignKeyJson { + stamp_start: Timestamp; + stamp_expire: Timestamp; + stamp_end: Timestamp; + key: EddsaPublicKeyString; + master_sig: EddsaSignatureString; +} + +/** + * Structure that the exchange gives us in /keys. + */ +export class ExchangeKeysJson { + /** + * List of offered denominations. + */ + denoms: Denomination[]; + + /** + * The exchange's master public key. + */ + master_public_key: string; + + /** + * The list of auditors (partially) auditing the exchange. + */ + auditors: Auditor[]; + + /** + * Timestamp when this response was issued. + */ + list_issue_date: Timestamp; + + /** + * List of revoked denominations. + */ + recoup?: Recoup[]; + + /** + * Short-lived signing keys used to sign online + * responses. + */ + signkeys: ExchangeSignKeyJson[]; + + /** + * Protocol version. + */ + version: string; +} + +/** + * Wire fees as anounced by the exchange. + */ +export class WireFeesJson { + /** + * Cost of a wire transfer. + */ + wire_fee: string; + + /** + * Cost of clising a reserve. + */ + closing_fee: string; + + /** + * Signature made with the exchange's master key. + */ + sig: string; + + /** + * Date from which the fee applies. + */ + start_date: Timestamp; + + /** + * Data after which the fee doesn't apply anymore. + */ + end_date: Timestamp; +} + +export class AccountInfo { + payto_uri: string; + master_sig: string; +} + +export class ExchangeWireJson { + accounts: AccountInfo[]; + fees: { [methodName: string]: WireFeesJson[] }; +} + +/** + * Proposal returned from the contract URL. + */ +export class Proposal { + /** + * Contract terms for the propoal. + * Raw, un-decoded JSON object. + */ + contract_terms: any; + + /** + * Signature over contract, made by the merchant. The public key used for signing + * must be contract_terms.merchant_pub. + */ + sig: string; +} + +/** + * Response from the internal merchant API. + */ +export class CheckPaymentResponse { + order_status: string; + refunded: boolean | undefined; + refunded_amount: string | undefined; + contract_terms: any | undefined; + taler_pay_uri: string | undefined; + contract_url: string | undefined; +} + +/** + * Response from the bank. + */ +export class WithdrawOperationStatusResponse { + selection_done: boolean; + + transfer_done: boolean; + + amount: string; + + sender_wire?: string; + + suggested_exchange?: string; + + confirm_transfer_url?: string; + + wire_types: string[]; +} + +/** + * Response from the merchant. + */ +export class TipPickupGetResponse { + extra: any; + + amount: string; + + amount_left: string; + + exchange_url: string; + + stamp_expire: Timestamp; + + stamp_created: Timestamp; +} + +export class WithdrawResponse { + ev_sig: string; +} + +/** + * Easy to process format for the public data of coins + * managed by the wallet. + */ +export interface CoinDumpJson { + coins: Array<{ + /** + * The coin's denomination's public key. + */ + denom_pub: string; + /** + * Hash of denom_pub. + */ + denom_pub_hash: string; + /** + * Value of the denomination (without any fees). + */ + denom_value: string; + /** + * Public key of the coin. + */ + coin_pub: string; + /** + * Base URL of the exchange for the coin. + */ + exchange_base_url: string; + /** + * Remaining value on the coin, to the knowledge of + * the wallet. + */ + remaining_value: string; + /** + * Public key of the parent coin. + * Only present if this coin was obtained via refreshing. + */ + refresh_parent_coin_pub: string | undefined; + /** + * Public key of the reserve for this coin. + * Only present if this coin was obtained via refreshing. + */ + withdrawal_reserve_pub: string | undefined; + /** + * Is the coin suspended? + * Suspended coins are not considered for payments. + */ + coin_suspended: boolean; + }>; +} + +export interface MerchantPayResponse { + sig: string; +} + +export interface ExchangeMeltResponse { + /** + * Which of the kappa indices does the client not have to reveal. + */ + noreveal_index: number; + + /** + * Signature of TALER_RefreshMeltConfirmationPS whereby the exchange + * affirms the successful melt and confirming the noreveal_index + */ + exchange_sig: EddsaSignatureString; + + /* + * public EdDSA key of the exchange that was used to generate the signature. + * Should match one of the exchange's signing keys from /keys. Again given + * explicitly as the client might otherwise be confused by clock skew as to + * which signing key was used. + */ + exchange_pub: EddsaPublicKeyString; + + /* + * Base URL to use for operations on the refresh context + * (so the reveal operation). If not given, + * the base URL is the same as the one used for this request. + * Can be used if the base URL for /refreshes/ differs from that + * for /coins/, i.e. for load balancing. Clients SHOULD + * respect the refresh_base_url if provided. Any HTTP server + * belonging to an exchange MUST generate a 307 or 308 redirection + * to the correct base URL should a client uses the wrong base + * URL, or if the base URL has changed since the melt. + * + * When melting the same coin twice (technically allowed + * as the response might have been lost on the network), + * the exchange may return different values for the refresh_base_url. + */ + refresh_base_url?: string; +} + +export interface ExchangeRevealItem { + ev_sig: string; +} + +export interface ExchangeRevealResponse { + // List of the exchange's blinded RSA signatures on the new coins. + ev_sigs: ExchangeRevealItem[]; +} + +interface MerchantOrderStatusPaid { + /** + * Was the payment refunded (even partially, via refund or abort)? + */ + refunded: boolean; + + /** + * Amount that was refunded in total. + */ + refund_amount: AmountString; + + /** + * Successful refunds for this payment, empty array for none. + */ + refunds: MerchantCoinRefundStatus[]; + + /** + * Public key of the merchant. + */ + merchant_pub: EddsaPublicKeyString; +} + +export type MerchantCoinRefundStatus = + | MerchantCoinRefundSuccessStatus + | MerchantCoinRefundFailureStatus; + +export interface MerchantCoinRefundSuccessStatus { + type: "success"; + + // HTTP status of the exchange request, 200 (integer) required for refund confirmations. + exchange_status: 200; + + // the EdDSA :ref:signature (binary-only) with purpose + // TALER_SIGNATURE_EXCHANGE_CONFIRM_REFUND using a current signing key of the + // exchange affirming the successful refund + exchange_sig: EddsaSignatureString; + + // public EdDSA key of the exchange that was used to generate the signature. + // Should match one of the exchange's signing keys from /keys. It is given + // explicitly as the client might otherwise be confused by clock skew as to + // which signing key was used. + exchange_pub: EddsaPublicKeyString; + + // Refund transaction ID. + rtransaction_id: number; + + // public key of a coin that was refunded + coin_pub: EddsaPublicKeyString; + + // Amount that was refunded, including refund fee charged by the exchange + // to the customer. + refund_amount: AmountString; + + execution_time: Timestamp; +} + +export interface MerchantCoinRefundFailureStatus { + type: "failure"; + + // HTTP status of the exchange request, must NOT be 200. + exchange_status: number; + + // Taler error code from the exchange reply, if available. + exchange_code?: number; + + // If available, HTTP reply from the exchange. + exchange_reply?: any; + + // Refund transaction ID. + rtransaction_id: number; + + // public key of a coin that was refunded + coin_pub: EddsaPublicKeyString; + + // Amount that was refunded, including refund fee charged by the exchange + // to the customer. + refund_amount: AmountString; + + execution_time: Timestamp; +} + +export interface MerchantOrderStatusUnpaid { + /** + * URI that the wallet must process to complete the payment. + */ + taler_pay_uri: string; + + /** + * Alternative order ID which was paid for already in the same session. + * + * Only given if the same product was purchased before in the same session. + */ + already_paid_order_id?: string; +} + +export interface WithdrawUriInfoResponse { + amount: AmountString; + defaultExchangeBaseUrl?: string; + possibleExchanges: ExchangeListItem[]; +} + +/** + * Response body for the following endpoint: + * + * POST {talerBankIntegrationApi}/withdrawal-operation/{wopid} + */ +export interface BankWithdrawalOperationPostResponse { + transfer_done: boolean; +} + +export const codecForBankWithdrawalOperationPostResponse = (): Codec< + BankWithdrawalOperationPostResponse +> => + makeCodecForObject() + .property("transfer_done", codecForBoolean) + .build("BankWithdrawalOperationPostResponse"); + +export type AmountString = string; +export type Base32String = string; +export type EddsaSignatureString = string; +export type EddsaPublicKeyString = string; +export type CoinPublicKeyString = string; + +export const codecForDenomination = (): Codec => + makeCodecForObject() + .property("value", codecForString) + .property("denom_pub", codecForString) + .property("fee_withdraw", codecForString) + .property("fee_deposit", codecForString) + .property("fee_refresh", codecForString) + .property("fee_refund", codecForString) + .property("stamp_start", codecForTimestamp) + .property("stamp_expire_withdraw", codecForTimestamp) + .property("stamp_expire_legal", codecForTimestamp) + .property("stamp_expire_deposit", codecForTimestamp) + .property("master_sig", codecForString) + .build("Denomination"); + +export const codecForAuditorDenomSig = (): Codec => + makeCodecForObject() + .property("denom_pub_h", codecForString) + .property("auditor_sig", codecForString) + .build("AuditorDenomSig"); + +export const codecForAuditor = (): Codec => + makeCodecForObject() + .property("auditor_pub", codecForString) + .property("auditor_url", codecForString) + .property("denomination_keys", makeCodecForList(codecForAuditorDenomSig())) + .build("Auditor"); + +export const codecForExchangeHandle = (): Codec => + makeCodecForObject() + .property("master_pub", codecForString) + .property("url", codecForString) + .build("ExchangeHandle"); + +export const codecForAuditorHandle = (): Codec => + makeCodecForObject() + .property("name", codecForString) + .property("master_pub", codecForString) + .property("url", codecForString) + .build("AuditorHandle"); + +export const codecForMerchantInfo = (): Codec => + makeCodecForObject() + .property("name", codecForString) + .property("address", makeCodecOptional(codecForString)) + .property("jurisdiction", makeCodecOptional(codecForString)) + .build("MerchantInfo"); + +export const codecForTax = (): Codec => + makeCodecForObject() + .property("name", codecForString) + .property("tax", codecForString) + .build("Tax"); + +export const codecForI18n = (): Codec<{ [lang_tag: string]: string }> => + makeCodecForMap(codecForString); + +export const codecForProduct = (): Codec => + makeCodecForObject() + .property("product_id", makeCodecOptional(codecForString)) + .property("description", codecForString) + .property("description_i18n", makeCodecOptional(codecForI18n())) + .property("quantity", makeCodecOptional(codecForNumber)) + .property("unit", makeCodecOptional(codecForString)) + .property("price", makeCodecOptional(codecForString)) + .property("delivery_date", makeCodecOptional(codecForTimestamp)) + .property("delivery_location", makeCodecOptional(codecForString)) + .build("Tax"); + +export const codecForContractTerms = (): Codec => + makeCodecForObject() + .property("order_id", codecForString) + .property("fulfillment_url", codecForString) + .property("merchant_base_url", codecForString) + .property("h_wire", codecForString) + .property("auto_refund", makeCodecOptional(codecForDuration)) + .property("wire_method", codecForString) + .property("summary", codecForString) + .property("summary_i18n", makeCodecOptional(codecForI18n())) + .property("nonce", codecForString) + .property("amount", codecForString) + .property("auditors", makeCodecForList(codecForAuditorHandle())) + .property("pay_deadline", codecForTimestamp) + .property("refund_deadline", codecForTimestamp) + .property("wire_transfer_deadline", codecForTimestamp) + .property("timestamp", codecForTimestamp) + .property("locations", codecForAny) + .property("max_fee", codecForString) + .property("max_wire_fee", makeCodecOptional(codecForString)) + .property("merchant", codecForMerchantInfo()) + .property("merchant_pub", codecForString) + .property("exchanges", makeCodecForList(codecForExchangeHandle())) + .property( + "products", + makeCodecOptional(makeCodecForList(codecForProduct())), + ) + .property("extra", codecForAny) + .build("ContractTerms"); + +export const codecForMerchantRefundPermission = (): Codec< + MerchantAbortPayRefundDetails +> => + makeCodecForObject() + .property("refund_amount", codecForString) + .property("refund_fee", codecForString) + .property("coin_pub", codecForString) + .property("rtransaction_id", codecForNumber) + .property("exchange_http_status", codecForNumber) + .property("exchange_code", makeCodecOptional(codecForNumber)) + .property("exchange_reply", makeCodecOptional(codecForAny)) + .property("exchange_sig", makeCodecOptional(codecForString)) + .property("exchange_pub", makeCodecOptional(codecForString)) + .build("MerchantRefundPermission"); + +export const codecForMerchantRefundResponse = (): Codec< + MerchantRefundResponse +> => + makeCodecForObject() + .property("merchant_pub", codecForString) + .property("h_contract_terms", codecForString) + .property("refunds", makeCodecForList(codecForMerchantRefundPermission())) + .build("MerchantRefundResponse"); + +export const codecForReserveSigSingleton = (): Codec => + makeCodecForObject() + .property("reserve_sig", codecForString) + .build("ReserveSigSingleton"); + +export const codecForTipResponse = (): Codec => + makeCodecForObject() + .property("reserve_pub", codecForString) + .property("reserve_sigs", makeCodecForList(codecForReserveSigSingleton())) + .build("TipResponse"); + +export const codecForRecoup = (): Codec => + makeCodecForObject() + .property("h_denom_pub", codecForString) + .build("Recoup"); + +export const codecForExchangeSigningKey = (): Codec => + makeCodecForObject() + .property("key", codecForString) + .property("master_sig", codecForString) + .property("stamp_end", codecForTimestamp) + .property("stamp_start", codecForTimestamp) + .property("stamp_expire", codecForTimestamp) + .build("ExchangeSignKeyJson"); + +export const codecForExchangeKeysJson = (): Codec => + makeCodecForObject() + .property("denoms", makeCodecForList(codecForDenomination())) + .property("master_public_key", codecForString) + .property("auditors", makeCodecForList(codecForAuditor())) + .property("list_issue_date", codecForTimestamp) + .property("recoup", makeCodecOptional(makeCodecForList(codecForRecoup()))) + .property("signkeys", makeCodecForList(codecForExchangeSigningKey())) + .property("version", codecForString) + .build("KeysJson"); + +export const codecForWireFeesJson = (): Codec => + makeCodecForObject() + .property("wire_fee", codecForString) + .property("closing_fee", codecForString) + .property("sig", codecForString) + .property("start_date", codecForTimestamp) + .property("end_date", codecForTimestamp) + .build("WireFeesJson"); + +export const codecForAccountInfo = (): Codec => + makeCodecForObject() + .property("payto_uri", codecForString) + .property("master_sig", codecForString) + .build("AccountInfo"); + +export const codecForExchangeWireJson = (): Codec => + makeCodecForObject() + .property("accounts", makeCodecForList(codecForAccountInfo())) + .property("fees", makeCodecForMap(makeCodecForList(codecForWireFeesJson()))) + .build("ExchangeWireJson"); + +export const codecForProposal = (): Codec => + makeCodecForObject() + .property("contract_terms", codecForAny) + .property("sig", codecForString) + .build("Proposal"); + +export const codecForCheckPaymentResponse = (): Codec => + makeCodecForObject() + .property("order_status", codecForString) + .property("refunded", makeCodecOptional(codecForBoolean)) + .property("refunded_amount", makeCodecOptional(codecForString)) + .property("contract_terms", makeCodecOptional(codecForAny)) + .property("taler_pay_uri", makeCodecOptional(codecForString)) + .property("contract_url", makeCodecOptional(codecForString)) + .build("CheckPaymentResponse"); + +export const codecForWithdrawOperationStatusResponse = (): Codec< + WithdrawOperationStatusResponse +> => + makeCodecForObject() + .property("selection_done", codecForBoolean) + .property("transfer_done", codecForBoolean) + .property("amount", codecForString) + .property("sender_wire", makeCodecOptional(codecForString)) + .property("suggested_exchange", makeCodecOptional(codecForString)) + .property("confirm_transfer_url", makeCodecOptional(codecForString)) + .property("wire_types", makeCodecForList(codecForString)) + .build("WithdrawOperationStatusResponse"); + +export const codecForTipPickupGetResponse = (): Codec => + makeCodecForObject() + .property("extra", codecForAny) + .property("amount", codecForString) + .property("amount_left", codecForString) + .property("exchange_url", codecForString) + .property("stamp_expire", codecForTimestamp) + .property("stamp_created", codecForTimestamp) + .build("TipPickupGetResponse"); + +export const codecForRecoupConfirmation = (): Codec => + makeCodecForObject() + .property("reserve_pub", makeCodecOptional(codecForString)) + .property("old_coin_pub", makeCodecOptional(codecForString)) + .build("RecoupConfirmation"); + +export const codecForWithdrawResponse = (): Codec => + makeCodecForObject() + .property("ev_sig", codecForString) + .build("WithdrawResponse"); + +export const codecForMerchantPayResponse = (): Codec => + makeCodecForObject() + .property("sig", codecForString) + .build("MerchantPayResponse"); + +export const codecForExchangeMeltResponse = (): Codec => + makeCodecForObject() + .property("exchange_pub", codecForString) + .property("exchange_sig", codecForString) + .property("noreveal_index", codecForNumber) + .property("refresh_base_url", makeCodecOptional(codecForString)) + .build("ExchangeMeltResponse"); + +export const codecForExchangeRevealItem = (): Codec => + makeCodecForObject() + .property("ev_sig", codecForString) + .build("ExchangeRevealItem"); + +export const codecForExchangeRevealResponse = (): Codec< + ExchangeRevealResponse +> => + makeCodecForObject() + .property("ev_sigs", makeCodecForList(codecForExchangeRevealItem())) + .build("ExchangeRevealResponse"); + +export const codecForMerchantCoinRefundSuccessStatus = (): Codec< + MerchantCoinRefundSuccessStatus +> => + makeCodecForObject() + .property("type", makeCodecForConstString("success")) + .property("coin_pub", codecForString) + .property("exchange_status", makeCodecForConstNumber(200)) + .property("exchange_sig", codecForString) + .property("rtransaction_id", codecForNumber) + .property("refund_amount", codecForString) + .property("exchange_pub", codecForString) + .property("execution_time", codecForTimestamp) + .build("MerchantCoinRefundSuccessStatus"); + +export const codecForMerchantCoinRefundFailureStatus = (): Codec< + MerchantCoinRefundFailureStatus +> => + makeCodecForObject() + .property("type", makeCodecForConstString("failure")) + .property("coin_pub", codecForString) + .property("exchange_status", makeCodecForConstNumber(200)) + .property("rtransaction_id", codecForNumber) + .property("refund_amount", codecForString) + .property("exchange_code", makeCodecOptional(codecForNumber)) + .property("exchange_reply", makeCodecOptional(codecForAny)) + .property("execution_time", codecForTimestamp) + .build("MerchantCoinRefundSuccessStatus"); + +export const codecForMerchantCoinRefundStatus = (): Codec< + MerchantCoinRefundStatus +> => + makeCodecForUnion() + .discriminateOn("type") + .alternative("success", codecForMerchantCoinRefundSuccessStatus()) + .alternative("failure", codecForMerchantCoinRefundFailureStatus()) + .build("MerchantCoinRefundStatus"); + +export const codecForMerchantOrderStatusPaid = (): Codec< + MerchantOrderStatusPaid +> => + makeCodecForObject() + .property("merchant_pub", codecForString) + .property("refund_amount", codecForString) + .property("refunded", codecForBoolean) + .property("refunds", makeCodecForList(codecForMerchantCoinRefundStatus())) + .build("MerchantOrderStatusPaid"); + +export const codecForMerchantOrderStatusUnpaid = (): Codec< + MerchantOrderStatusUnpaid +> => + makeCodecForObject() + .property("taler_pay_uri", codecForString) + .property("already_paid_order_id", makeCodecOptional(codecForString)) + .build("MerchantOrderStatusUnpaid"); diff --git a/packages/taler-wallet-core/src/types/transactions.d.ts.map b/packages/taler-wallet-core/src/types/transactions.d.ts.map new file mode 100644 index 000000000..95e19a21c --- /dev/null +++ b/packages/taler-wallet-core/src/types/transactions.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"transactions.d.ts","sourceRoot":"","sources":["transactions.ts"],"names":[],"mappings":"AAgBA;;;;;GAKG;AAEH;;GAEG;AACH,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,EAAE,KAAK,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EAAE,YAAY,CAAC;IAG5B,SAAS,EAAE,YAAY,CAAC;IAGxB,eAAe,EAAE,YAAY,CAAC;CAC/B;AAED,UAAU,cAAe,SAAQ,iBAAiB;IAChD,IAAI,EAAE,eAAe,CAAC,GAAG,CAAC;IAG1B,OAAO,EAAE,OAAO,CAAC;IAGjB,QAAQ,EAAE,OAAO,CAAC;IAGlB,eAAe,EAAE,MAAM,CAAC;IAGxB,QAAQ,EAAE,GAAG,CAAC;IAGd,SAAS,EAAE,YAAY,CAAC;IAGxB,eAAe,EAAE,YAAY,CAAC;CAC/B;AAKD,UAAU,kBAAmB,SAAQ,iBAAiB;IACpD,IAAI,EAAE,eAAe,CAAC,OAAO,CAAC;IAG9B,eAAe,EAAE,MAAM,CAAC;IAGxB,SAAS,EAAE,YAAY,CAAC;IAGxB,eAAe,EAAE,YAAY,CAAC;CAC/B;AAGD,eAAO,MAAM,2BAA2B,QAAO,KAAK,CAAC,mBAAmB,CAIvC,CAAC"} \ No newline at end of file diff --git a/packages/taler-wallet-core/src/types/transactions.ts b/packages/taler-wallet-core/src/types/transactions.ts new file mode 100644 index 000000000..de378f51a --- /dev/null +++ b/packages/taler-wallet-core/src/types/transactions.ts @@ -0,0 +1,314 @@ +/* + 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 + */ + +/** + * Type and schema definitions for the wallet's transaction list. + * + * @author Florian Dold + * @author Torsten Grote + */ + +/** + * Imports. + */ +import { Timestamp } from "../util/time"; +import { AmountString, Product } from "./talerTypes"; +import { + Codec, + makeCodecForObject, + makeCodecOptional, + codecForString, +} from "../util/codec"; + +export interface TransactionsRequest { + /** + * return only transactions in the given currency + */ + currency?: string; + + /** + * if present, results will be limited to transactions related to the given search string + */ + search?: string; +} + +export interface TransactionsResponse { + // a list of past and pending transactions sorted by pending, timestamp and transactionId. + // In case two events are both pending and have the same timestamp, + // they are sorted by the transactionId + // (lexically ascending and locale-independent comparison). + transactions: Transaction[]; +} + +interface TransactionError { + /** + * TALER_EC_* unique error code. + * The action(s) offered and message displayed on the transaction item depend on this code. + */ + ec: number; + + /** + * English-only error hint, if available. + */ + hint?: string; + + /** + * Error details specific to "ec", if applicable/available + */ + details?: any; +} + +export interface TransactionCommon { + // opaque unique ID for the transaction, used as a starting point for paginating queries + // and for invoking actions on the transaction (e.g. deleting/hiding it from the history) + transactionId: string; + + // the type of the transaction; different types might provide additional information + type: TransactionType; + + // main timestamp of the transaction + timestamp: Timestamp; + + // true if the transaction is still pending, false otherwise + // If a transaction is not longer pending, its timestamp will be updated, + // but its transactionId will remain unchanged + pending: boolean; + + // Raw amount of the transaction (exclusive of fees or other extra costs) + amountRaw: AmountString; + + // Amount added or removed from the wallet's balance (including all fees and other costs) + amountEffective: AmountString; + + error?: TransactionError; +} + +export type Transaction = + | TransactionWithdrawal + | TransactionPayment + | TransactionRefund + | TransactionTip + | TransactionRefresh; + +export const enum TransactionType { + Withdrawal = "withdrawal", + Payment = "payment", + Refund = "refund", + Refresh = "refresh", + Tip = "tip", +} + +export const enum WithdrawalType { + TalerBankIntegrationApi = "taler-bank-integration-api", + ManualTransfer = "manual-transfer", +} + +export type WithdrawalDetails = + | WithdrawalDetailsForManualTransfer + | WithdrawalDetailsForTalerBankIntegrationApi; + +interface WithdrawalDetailsForManualTransfer { + type: WithdrawalType.ManualTransfer; + + /** + * Payto URIs that the exchange supports. + * + * Already contains the amount and message. + */ + exchangePaytoUris: string[]; +} + +interface WithdrawalDetailsForTalerBankIntegrationApi { + type: WithdrawalType.TalerBankIntegrationApi; + + /** + * Set to true if the bank has confirmed the withdrawal, false if not. + * An unconfirmed withdrawal usually requires user-input and should be highlighted in the UI. + * See also bankConfirmationUrl below. + */ + confirmed: boolean; + + /** + * If the withdrawal is unconfirmed, this can include a URL for user + * initiated confirmation. + */ + bankConfirmationUrl?: string; +} + +// This should only be used for actual withdrawals +// and not for tips that have their own transactions type. +interface TransactionWithdrawal extends TransactionCommon { + type: TransactionType.Withdrawal; + + /** + * Exchange of the withdrawal. + */ + exchangeBaseUrl: string; + + /** + * Amount that got subtracted from the reserve balance. + */ + amountRaw: AmountString; + + /** + * Amount that actually was (or will be) added to the wallet's balance. + */ + amountEffective: AmountString; + + withdrawalDetails: WithdrawalDetails; +} + +export const enum PaymentStatus { + /** + * Explicitly aborted after timeout / failure + */ + Aborted = "aborted", + + /** + * Payment failed, wallet will auto-retry. + * User should be given the option to retry now / abort. + */ + Failed = "failed", + + /** + * Paid successfully + */ + Paid = "paid", + + /** + * User accepted, payment is processing. + */ + Accepted = "accepted", +} + +export interface TransactionPayment extends TransactionCommon { + type: TransactionType.Payment; + + /** + * Additional information about the payment. + */ + info: PaymentShortInfo; + + /** + * How far did the wallet get with processing the payment? + */ + status: PaymentStatus; + + /** + * Amount that must be paid for the contract + */ + amountRaw: AmountString; + + /** + * Amount that was paid, including deposit, wire and refresh fees. + */ + amountEffective: AmountString; +} + +interface PaymentShortInfo { + /** + * Order ID, uniquely identifies the order within a merchant instance + */ + orderId: string; + + /** + * More information about the merchant + */ + merchant: any; + + /** + * Summary of the order, given by the merchant + */ + summary: string; + + /** + * Map from IETF BCP 47 language tags to localized summaries + */ + summary_i18n?: { [lang_tag: string]: string }; + + /** + * List of products that are part of the order + */ + products: Product[] | undefined; + + /** + * URL of the fulfillment, given by the merchant + */ + fulfillmentUrl: string; +} + +interface TransactionRefund extends TransactionCommon { + type: TransactionType.Refund; + + // ID for the transaction that is refunded + refundedTransactionId: string; + + // Additional information about the refunded payment + info: PaymentShortInfo; + + // Part of the refund that couldn't be applied because the refund permissions were expired + amountInvalid: AmountString; + + // Amount that has been refunded by the merchant + amountRaw: AmountString; + + // Amount will be added to the wallet's balance after fees and refreshing + amountEffective: AmountString; +} + +interface TransactionTip extends TransactionCommon { + type: TransactionType.Tip; + + // true if the user still needs to accept/decline this tip + waiting: boolean; + + // true if the user has accepted this top, false otherwise + accepted: boolean; + + // Exchange that the tip will be (or was) withdrawn from + exchangeBaseUrl: string; + + // More information about the merchant that sent the tip + merchant: any; + + // Raw amount of the tip, without extra fees that apply + amountRaw: AmountString; + + // Amount will be (or was) added to the wallet's balance after fees and refreshing + amountEffective: AmountString; +} + +// A transaction shown for refreshes that are not associated to other transactions +// such as a refresh necessary before coin expiration. +// It should only be returned by the API if the effective amount is different from zero. +interface TransactionRefresh extends TransactionCommon { + type: TransactionType.Refresh; + + // Exchange that the coins are refreshed with + exchangeBaseUrl: string; + + // Raw amount that is refreshed + amountRaw: AmountString; + + // Amount that will be paid as fees for the refresh + amountEffective: AmountString; +} + +export const codecForTransactionsRequest = (): Codec => + makeCodecForObject() + .property("currency", makeCodecOptional(codecForString)) + .property("search", makeCodecOptional(codecForString)) + .build("TransactionsRequest"); diff --git a/packages/taler-wallet-core/src/types/types-test.ts b/packages/taler-wallet-core/src/types/types-test.ts new file mode 100644 index 000000000..afdc01844 --- /dev/null +++ b/packages/taler-wallet-core/src/types/types-test.ts @@ -0,0 +1,55 @@ +/* + This file is part of TALER + (C) 2017 Inria and GNUnet e.V. + + 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. + + 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 + TALER; see the file COPYING. If not, see + */ + +import test from "ava"; +import { codecForContractTerms } from "./talerTypes"; + +test("contract terms validation", (t) => { + const c = { + nonce: "123123123", + h_wire: "123", + amount: "EUR:1.5", + auditors: [], + exchanges: [{ master_pub: "foo", url: "foo" }], + fulfillment_url: "foo", + max_fee: "EUR:1.5", + merchant_pub: "12345", + merchant: { name: "Foo" }, + order_id: "test_order", + pay_deadline: { t_ms: 42 }, + wire_transfer_deadline: { t_ms: 42 }, + merchant_base_url: "https://example.com/pay", + products: [], + refund_deadline: { t_ms: 42 }, + summary: "hello", + timestamp: { t_ms: 42 }, + wire_method: "test", + }; + + codecForContractTerms().decode(c); + + const c1 = JSON.parse(JSON.stringify(c)); + c1.pay_deadline = "foo"; + + try { + codecForContractTerms().decode(c1); + } catch (e) { + t.pass(); + return; + } + + t.fail(); +}); diff --git a/packages/taler-wallet-core/src/types/walletTypes.d.ts.map b/packages/taler-wallet-core/src/types/walletTypes.d.ts.map new file mode 100644 index 000000000..d802110fd --- /dev/null +++ b/packages/taler-wallet-core/src/types/walletTypes.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"walletTypes.d.ts","sourceRoot":"","sources":["walletTypes.ts"],"names":[],"mappings":"AAgBA;;;;;;;;GAQG;AAEH;;GAEG;AACH,OAAO,EAAE,UAAU,EAAsB,MAAM,iBAAiB,CAAC;AACjE,OAAO,KAAK,cAAc,MAAM,wBAAwB,CAAC;AACzD,OAAO,EACL,cAAc,EACd,gBAAgB,EAChB,yBAAyB,EAC1B,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAIL,KAAK,EACN,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAE5C;;GAEG;AACH,qBAAa,qBAAqB;IAChC;;;OAGG;IACH,QAAQ,EAAE,MAAM,CAAC;IAEjB;;OAEG;IACH,UAAU,EAAE,MAAM,CAAC;CACpB;AAED;;;;GAIG;AACH,MAAM,WAAW,uBAAuB;IACtC;;OAEG;IACH,YAAY,EAAE,cAAc,CAAC;IAE7B;;OAEG;IACH,oBAAoB,EAAE,MAAM,EAAE,CAAC;IAE/B;;OAEG;IACH,cAAc,EAAE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AAM,WAAW,oBAAoB;IACnC;;OAEG;IACH,GAAG,EAAE,MAAM,CAAC;IAEZ;;OAEG;IACH,WAAW,EAAE,MAAM,CAAC;IAEpB;;;OAGG;IACH,YAAY,EAAE,MAAM,GAAG,SAAS,CAAC;CAClC"} \ No newline at end of file diff --git a/packages/taler-wallet-core/src/types/walletTypes.ts b/packages/taler-wallet-core/src/types/walletTypes.ts new file mode 100644 index 000000000..04f50f29a --- /dev/null +++ b/packages/taler-wallet-core/src/types/walletTypes.ts @@ -0,0 +1,516 @@ +/* + This file is part of GNU Taler + (C) 2015-2020 Taler Systems SA + + 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. + + 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 + TALER; see the file COPYING. If not, see + */ + +/** + * Types used by clients of the wallet. + * + * These types are defined in a separate file make tree shaking easier, since + * some components use these types (via RPC) but do not depend on the wallet + * code directly. + * + * @author Florian Dold + */ + +/** + * Imports. + */ +import { AmountJson, codecForAmountJson } from "../util/amounts"; +import * as LibtoolVersion from "../util/libtoolVersion"; +import { + ExchangeRecord, + ExchangeWireInfo, + DenominationSelectionInfo, +} from "./dbTypes"; +import { Timestamp } from "../util/time"; +import { + makeCodecForObject, + codecForString, + makeCodecOptional, + Codec, +} from "../util/codec"; +import { AmountString } from "./talerTypes"; + +/** + * Response for the create reserve request to the wallet. + */ +export class CreateReserveResponse { + /** + * Exchange URL where the bank should create the reserve. + * The URL is canonicalized in the response. + */ + exchange: string; + + /** + * Reserve public key of the newly created reserve. + */ + reservePub: string; +} + +/** + * Information about what will happen when creating a reserve. + * + * Sent to the wallet frontend to be rendered and shown to the user. + */ +export interface ExchangeWithdrawDetails { + /** + * Exchange that the reserve will be created at. + */ + exchangeInfo: ExchangeRecord; + + /** + * Filtered wire info to send to the bank. + */ + exchangeWireAccounts: string[]; + + /** + * Selected denominations for withdraw. + */ + selectedDenoms: DenominationSelectionInfo; + + /** + * Fees for withdraw. + */ + withdrawFee: AmountJson; + + /** + * Remaining balance that is too small to be withdrawn. + */ + overhead: AmountJson; + + /** + * Wire fees from the exchange. + */ + wireFees: ExchangeWireInfo; + + /** + * Does the wallet know about an auditor for + * the exchange that the reserve. + */ + isAudited: boolean; + + /** + * Did the user already accept the current terms of service for the exchange? + */ + termsOfServiceAccepted: boolean; + + /** + * The exchange is trusted directly. + */ + isTrusted: boolean; + + /** + * The earliest deposit expiration of the selected coins. + */ + earliestDepositExpiration: Timestamp; + + /** + * Number of currently offered denominations. + */ + numOfferedDenoms: number; + + /** + * Public keys of trusted auditors for the currency we're withdrawing. + */ + trustedAuditorPubs: string[]; + + /** + * Result of checking the wallet's version + * against the exchange's version. + * + * Older exchanges don't return version information. + */ + versionMatch: LibtoolVersion.VersionMatchResult | undefined; + + /** + * Libtool-style version string for the exchange or "unknown" + * for older exchanges. + */ + exchangeVersion: string; + + /** + * Libtool-style version string for the wallet. + */ + walletVersion: string; +} + +export interface Balance { + available: AmountString; + pendingIncoming: AmountString; + pendingOutgoing: AmountString; + + // Does the balance for this currency have a pending + // transaction? + hasPendingTransactions: boolean; + + // Is there a pending transaction that would affect the balance + // and requires user input? + requiresUserInput: boolean; +} + +export interface BalancesResponse { + balances: Balance[]; +} + +/** + * For terseness. + */ +export function mkAmount( + value: number, + fraction: number, + currency: string, +): AmountJson { + return { value, fraction, currency }; +} + +/** + * Result for confirmPay + */ +export interface ConfirmPayResult { + nextUrl: string; +} + +/** + * Information about all sender wire details known to the wallet, + * as well as exchanges that accept these wire types. + */ +export interface SenderWireInfos { + /** + * Mapping from exchange base url to list of accepted + * wire types. + */ + exchangeWireTypes: { [exchangeBaseUrl: string]: string[] }; + + /** + * Sender wire information stored in the wallet. + */ + senderWires: string[]; +} + +/** + * Request to create a reserve. + */ +export interface CreateReserveRequest { + /** + * The initial amount for the reserve. + */ + amount: AmountJson; + + /** + * Exchange URL where the bank should create the reserve. + */ + exchange: string; + + /** + * Payto URI that identifies the exchange's account that the funds + * for this reserve go into. + */ + exchangePaytoUri?: string; + + /** + * Wire details (as a payto URI) for the bank account that sent the funds to + * the exchange. + */ + senderWire?: string; + + /** + * URL to fetch the withdraw status from the bank. + */ + bankWithdrawStatusUrl?: string; +} + +export const codecForCreateReserveRequest = (): Codec => + makeCodecForObject() + .property("amount", codecForAmountJson()) + .property("exchange", codecForString) + .property("exchangePaytoUri", codecForString) + .property("senderWire", makeCodecOptional(codecForString)) + .property("bankWithdrawStatusUrl", makeCodecOptional(codecForString)) + .build("CreateReserveRequest"); + +/** + * Request to mark a reserve as confirmed. + */ +export interface ConfirmReserveRequest { + /** + * Public key of then reserve that should be marked + * as confirmed. + */ + reservePub: string; +} + +export const codecForConfirmReserveRequest = (): Codec => + makeCodecForObject() + .property("reservePub", codecForString) + .build("ConfirmReserveRequest"); + +/** + * Wire coins to the user's own bank account. + */ +export class ReturnCoinsRequest { + /** + * The amount to wire. + */ + amount: AmountJson; + + /** + * The exchange to take the coins from. + */ + exchange: string; + + /** + * Wire details for the bank account of the customer that will + * receive the funds. + */ + senderWire?: string; + + /** + * Verify that a value matches the schema of this class and convert it into a + * member. + */ + static checked: (obj: any) => ReturnCoinsRequest; +} + +/** + * Status of processing a tip. + */ +export interface TipStatus { + accepted: boolean; + amount: AmountJson; + amountLeft: AmountJson; + nextUrl: string; + exchangeUrl: string; + tipId: string; + merchantTipId: string; + merchantOrigin: string; + expirationTimestamp: Timestamp; + timestamp: Timestamp; + totalFees: AmountJson; +} + +export interface BenchmarkResult { + time: { [s: string]: number }; + repetitions: number; +} + +/** + * Cached next URL for a particular session id. + */ +export interface NextUrlResult { + nextUrl: string; + lastSessionId: string | undefined; +} + +export const enum PreparePayResultType { + PaymentPossible = "payment-possible", + InsufficientBalance = "insufficient-balance", + AlreadyConfirmed = "already-confirmed", +} + +export type PreparePayResult = + | PreparePayResultInsufficientBalance + | PreparePayResultAlreadyConfirmed + | PreparePayResultPaymentPossible; + +export interface PreparePayResultPaymentPossible { + status: PreparePayResultType.PaymentPossible; + proposalId: string; + contractTerms: Record; + amountRaw: string; + amountEffective: string; +} + +export interface PreparePayResultInsufficientBalance { + status: PreparePayResultType.InsufficientBalance; + proposalId: string; + contractTerms: Record; +} + +export interface PreparePayResultAlreadyConfirmed { + status: PreparePayResultType.AlreadyConfirmed; + contractTerms: Record; + paid: boolean; + // Only specified if paid. + nextUrl?: string; +} + +export interface BankWithdrawDetails { + selectionDone: boolean; + transferDone: boolean; + amount: AmountJson; + senderWire?: string; + suggestedExchange?: string; + confirmTransferUrl?: string; + wireTypes: string[]; + extractedStatusUrl: string; +} + +export interface AcceptWithdrawalResponse { + reservePub: string; + confirmTransferUrl?: string; +} + +/** + * Details about a purchase, including refund status. + */ +export interface PurchaseDetails { + contractTerms: Record; + hasRefund: boolean; + totalRefundAmount: AmountJson; + totalRefundAndRefreshFees: AmountJson; +} + +export interface WalletDiagnostics { + walletManifestVersion: string; + walletManifestDisplayVersion: string; + errors: string[]; + firefoxIdbProblem: boolean; + dbOutdated: boolean; +} + +export interface OperationErrorDetails { + talerErrorCode: number; + talerErrorHint: string; + message: string; + details: unknown; +} + +export interface PlanchetCreationResult { + coinPub: string; + coinPriv: string; + reservePub: string; + denomPubHash: string; + denomPub: string; + blindingKey: string; + withdrawSig: string; + coinEv: string; + coinValue: AmountJson; + coinEvHash: string; +} + +export interface PlanchetCreationRequest { + value: AmountJson; + feeWithdraw: AmountJson; + denomPub: string; + reservePub: string; + reservePriv: string; +} + +/** + * Reasons for why a coin is being refreshed. + */ +export const enum RefreshReason { + Manual = "manual", + Pay = "pay", + Refund = "refund", + AbortPay = "abort-pay", + Recoup = "recoup", + BackupRestored = "backup-restored", +} + +/** + * Wrapper for coin public keys. + */ +export interface CoinPublicKey { + readonly coinPub: string; +} + +/** + * Wrapper for refresh group IDs. + */ +export interface RefreshGroupId { + readonly refreshGroupId: string; +} + +/** + * Private data required to make a deposit permission. + */ +export interface DepositInfo { + exchangeBaseUrl: string; + contractTermsHash: string; + coinPub: string; + coinPriv: string; + spendAmount: AmountJson; + timestamp: Timestamp; + refundDeadline: Timestamp; + merchantPub: string; + feeDeposit: AmountJson; + wireInfoHash: string; + denomPubHash: string; + denomSig: string; +} + +export interface ExchangesListRespose { + exchanges: ExchangeListItem[]; +} + +export interface ExchangeListItem { + exchangeBaseUrl: string; + currency: string; + paytoUris: string[]; +} + +export interface AcceptManualWithdrawalResult { + /** + * Payto URIs that can be used to fund the withdrawal. + */ + exchangePaytoUris: string[]; + + /** + * Public key of the newly created reserve. + */ + reservePub: string; +} + +export interface ManualWithdrawalDetails { + /** + * Did the user accept the current version of the exchange's + * terms of service? + */ + tosAccepted: boolean; + + /** + * Amount that the user will transfer to the exchange. + */ + amountRaw: AmountString; + + /** + * Amount that will be added to the user's wallet balance. + */ + amountEffective: AmountString; + + /** + * Ways to pay the exchange. + */ + paytoUris: string[]; +} + +export interface GetExchangeTosResult { + /** + * Markdown version of the current ToS. + */ + tos: string; + + /** + * Version tag of the current ToS. + */ + currentEtag: string; + + /** + * Version tag of the last ToS that the user has accepted, + * if any. + */ + acceptedEtag: string | undefined; +} -- cgit v1.2.3