aboutsummaryrefslogtreecommitdiff
path: root/packages/taler-util/src/http-client/types.ts
diff options
context:
space:
mode:
Diffstat (limited to 'packages/taler-util/src/http-client/types.ts')
-rw-r--r--packages/taler-util/src/http-client/types.ts197
1 files changed, 135 insertions, 62 deletions
diff --git a/packages/taler-util/src/http-client/types.ts b/packages/taler-util/src/http-client/types.ts
index 153cb340c..d9cc8ec90 100644
--- a/packages/taler-util/src/http-client/types.ts
+++ b/packages/taler-util/src/http-client/types.ts
@@ -264,6 +264,7 @@ export const codecForIntegrationBankConfig =
.property("name", codecForConstString("taler-bank-integration"))
.property("version", codecForString())
.property("currency", codecForString())
+ .property("currency_specification", codecForCurrencySpecificiation())
.build("TalerCorebankApi.IntegrationConfig");
export const codecForCoreBankConfig = (): Codec<TalerCorebankApi.Config> =>
@@ -353,6 +354,12 @@ export const codecForChallengeContactData =
.property("phone", codecOptional(codecForString()))
.build("TalerCorebankApi.ChallengeContactData");
+export const codecForWithdrawalPublicInfo =
+ (): Codec<TalerCorebankApi.WithdrawalPublicInfo> =>
+ buildCodecForObject<TalerCorebankApi.WithdrawalPublicInfo>()
+ .property("username", codecForString(),)
+ .build("TalerCorebankApi.WithdrawalPublicInfo");
+
export const codecForBankAccountTransactionsResponse =
(): Codec<TalerCorebankApi.BankAccountTransactionsResponse> =>
buildCodecForObject<TalerCorebankApi.BankAccountTransactionsResponse>()
@@ -381,6 +388,12 @@ export const codecForBankAccountTransactionInfo =
.build("TalerCorebankApi.BankAccountTransactionInfo");
+export const codecForCreateTransactionResponse =
+ (): Codec<TalerCorebankApi.CreateTransactionResponse> =>
+ buildCodecForObject<TalerCorebankApi.CreateTransactionResponse>()
+ .property("row_id", codecForNumber())
+ .build("TalerCorebankApi.CreateTransactionResponse");
+
export const codecForRegisterAccountResponse =
(): Codec<TalerCorebankApi.RegisterAccountResponse> =>
buildCodecForObject<TalerCorebankApi.RegisterAccountResponse>()
@@ -395,19 +408,19 @@ export const codecForBankAccountCreateWithdrawalResponse =
.property("withdrawal_id", codecForString())
.build("TalerCorebankApi.BankAccountCreateWithdrawalResponse");
-export const codecForBankAccountGetWithdrawalResponse =
- (): Codec<TalerCorebankApi.BankAccountGetWithdrawalResponse> =>
- buildCodecForObject<TalerCorebankApi.BankAccountGetWithdrawalResponse>()
- .property("amount", codecForAmountString())
- .property("aborted", codecForBoolean())
- .property("confirmation_done", codecForBoolean())
- .property(
- "selected_exchange_account",
- codecOptional(codecForPaytoString()),
- )
- .property("selected_reserve_pub", codecOptional(codecForString()))
- .property("selection_done", codecForBoolean())
- .build("TalerCorebankApi.BankAccountGetWithdrawalResponse");
+// export const codecForBankAccountGetWithdrawalResponse =
+// (): Codec<TalerCorebankApi.BankAccountGetWithdrawalResponse> =>
+// buildCodecForObject<TalerCorebankApi.BankAccountGetWithdrawalResponse>()
+// .property("amount", codecForAmountString())
+// .property("aborted", codecForBoolean())
+// .property("confirmation_done", codecForBoolean())
+// .property(
+// "selected_exchange_account",
+// codecOptional(codecForPaytoString()),
+// )
+// .property("selected_reserve_pub", codecOptional(codecForString()))
+// .property("selection_done", codecForBoolean())
+// .build("TalerCorebankApi.BankAccountGetWithdrawalResponse");
export const codecForCashoutPending =
(): Codec<TalerCorebankApi.CashoutPending> =>
@@ -484,7 +497,15 @@ export const codecForCashoutStatusResponse =
codecForConstString("confirmed"),
),
)
+ .property(
+ "tan_channel",
+ codecForEither(
+ codecForConstString(TanChannel.SMS),
+ codecForConstString(TanChannel.EMAIL),
+ ),
+ )
.property("subject", codecForString())
+ .property("tan_info", codecForString())
.build("TalerCorebankApi.CashoutStatusResponse");
export const codecForConversionRatesResponse =
@@ -542,21 +563,30 @@ export const codecForBankVersion =
export const codecForBankWithdrawalOperationStatus =
(): Codec<TalerBankIntegrationApi.BankWithdrawalOperationStatus> =>
buildCodecForObject<TalerBankIntegrationApi.BankWithdrawalOperationStatus>()
- .property("aborted", codecForBoolean())
- .property("selection_done", codecForBoolean())
- .property("transfer_done", codecForBoolean())
+ .property("status", codecForEither(
+ codecForConstString("pending"),
+ codecForConstString("selected"),
+ codecForConstString("aborted"),
+ codecForConstString("confirmed")
+ ))
.property("amount", codecForAmountString())
.property("sender_wire", codecOptional(codecForPaytoString()))
.property("suggested_exchange", codecOptional(codecForString()))
.property("confirm_transfer_url", codecOptional(codecForURL()))
.property("wire_types", codecForList(codecForString()))
+ .property("selected_reserve_pub", codecOptional(codecForString()))
+ .property("selected_exchange_account", codecOptional(codecForString()))
.build("TalerBankIntegrationApi.BankWithdrawalOperationStatus");
export const codecForBankWithdrawalOperationPostResponse =
(): Codec<TalerBankIntegrationApi.BankWithdrawalOperationPostResponse> =>
buildCodecForObject<TalerBankIntegrationApi.BankWithdrawalOperationPostResponse>()
+ .property("status", codecForEither(
+ codecForConstString("selected"),
+ codecForConstString("aborted"),
+ codecForConstString("confirmed")
+ ))
.property("confirm_transfer_url", codecOptional(codecForURL()))
- .property("transfer_done", codecForBoolean())
.build("TalerBankIntegrationApi.BankWithdrawalOperationPostResponse");
export const codecForMerchantIncomingHistory =
@@ -890,7 +920,9 @@ export namespace TalerWireGatewayApi {
// This must be one of the exchange's bank accounts.
// Credit account is shared by all incoming transactions
// as per the nature of the request.
- credit_account: PaytoString;
+
+ // undefined if incoming transaction is empty
+ credit_account?: PaytoString;
}
// Union discriminated by the "type" field.
@@ -951,7 +983,9 @@ export namespace TalerWireGatewayApi {
// This must be one of the exchange's bank accounts.
// Credit account is shared by all incoming transactions
// as per the nature of the request.
- debit_account: PaytoString;
+
+ // undefined if outgoing transactions is empty
+ debit_account?: PaytoString;
}
export interface OutgoingBankTransaction {
@@ -1113,6 +1147,40 @@ export namespace TalerBankConversionApi {
// bank account, according to 'amount_debit'.
amount_credit: AmountString;
}
+
+ export type RoundingMode = "zero" | "up" | "nearest";
+
+ export interface ConversionRate {
+ // Exchange rate to buy regional currency from fiat
+ cashin_ratio: DecimalNumber;
+
+ // Fee to subtract after applying the cashin ratio.
+ cashin_fee: AmountString;
+
+ // Minimum amount authorised for cashin, in fiat before conversion
+ cashin_min_amount: AmountString;
+
+ // Smallest possible regional amount, converted amount is rounded to this amount
+ cashin_tiny_amount: AmountString;
+
+ // Rounding mode used during cashin conversion
+ cashin_rounding_mode: RoundingMode;
+
+ // Exchange rate to sell regional currency for fiat
+ cashout_ratio: DecimalNumber;
+
+ // Fee to subtract after applying the cashout ratio.
+ cashout_fee: AmountString;
+
+ // Minimum amount authorised for cashout, in regional before conversion
+ cashout_min_amount: AmountString;
+
+ // Smallest possible fiat amount, converted amount is rounded to this amount
+ cashout_tiny_amount: AmountString;
+
+ // Rounding mode used during cashout conversion
+ cashout_rounding_mode: RoundingMode;
+ }
}
export namespace TalerBankIntegrationApi {
export interface BankVersion {
@@ -1131,18 +1199,15 @@ export namespace TalerBankIntegrationApi {
name: "taler-bank-integration";
}
+ export type WithdrawalOperationStatus = "pending" | "selected" | "aborted" | "confirmed"
export interface BankWithdrawalOperationStatus {
- // Indicates whether the withdrawal was aborted.
- aborted: boolean;
-
- // Has the wallet selected parameters for the withdrawal operation
- // (exchange and reserve public key) and successfully sent it
- // to the bank?
- selection_done: boolean;
+ // Current status of the operation
+ // pending: the operation is pending parameters selection (exchange and reserve public key)
+ // selected: the operations has been selected and is pending confirmation
+ // aborted: the operation has been aborted
+ // confirmed: the transfer has been confirmed and registered by the bank
+ status: WithdrawalOperationStatus;
- // The transfer has been confirmed and registered by the bank.
- // Does not guarantee that the funds have arrived at the exchange already.
- transfer_done: boolean;
// Amount that will be withdrawn with this operation
// (raw amount without fee considerations).
@@ -1162,6 +1227,14 @@ export namespace TalerBankIntegrationApi {
// Wire transfer types supported by the bank.
wire_types: string[];
+
+ // Reserve public key selected by the exchange,
+ // only non-null if status is selected or confirmed.
+ selected_reserve_pub?: string;
+
+ // Exchange account selected by the wallet
+ // only non-null if status is selected or confirmed.
+ selected_exchange_account?: string;
}
export interface BankWithdrawalOperationPostRequest {
@@ -1173,14 +1246,17 @@ export namespace TalerBankIntegrationApi {
}
export interface BankWithdrawalOperationPostResponse {
- // The transfer has been confirmed and registered by the bank.
- // Does not guarantee that the funds have arrived at the exchange already.
- transfer_done: boolean;
+ // Current status of the operation
+ // pending: the operation is pending parameters selection (exchange and reserve public key)
+ // selected: the operations has been selected and is pending confirmation
+ // aborted: the operation has been aborted
+ // confirmed: the transfer has been confirmed and registered by the bank
+ status: Omit<"pending", WithdrawalOperationStatus>;
// URL that the user needs to navigate to in order to
// complete some final confirmation (e.g. 2FA).
//
- // Only applicable when transfer_done is false.
+ // Only applicable when status is selected.
// It may contain withdrawal operation id
confirm_transfer_url?: string;
}
@@ -1192,7 +1268,10 @@ export namespace TalerCorebankApi {
// The format is "current:revision:age".
version: string;
- currency: String;
+ currency: string;
+
+ // How the bank SPA should render this currency.
+ currency_specification: CurrencySpecification;
// Name of the API.
name: "taler-bank-integration";
@@ -1235,31 +1314,12 @@ export namespace TalerCorebankApi {
// URI that can be passed to the wallet to initiate the withdrawal.
taler_withdraw_uri: TalerActionString;
}
- export interface BankAccountGetWithdrawalResponse {
- // Amount that will be withdrawn with this withdrawal operation.
- amount: AmountString;
-
- // Was the withdrawal aborted?
- aborted: boolean;
-
- // Has the withdrawal been confirmed by the bank?
- // The wire transfer for a withdrawal is only executed once
- // both confirmation_done is true and selection_done is true.
- confirmation_done: boolean;
-
- // Did the wallet select reserve details?
- selection_done: boolean;
-
- // Reserve public key selected by the exchange,
- // only non-null if selection_done is true.
- selected_reserve_pub: string | undefined;
-
- // Exchange account selected by the wallet, or by the bank
- // (with the default exchange) in case the wallet did not provide one
- // through the Integration API.
- selected_exchange_account: PaytoString | undefined;
+ export interface WithdrawalPublicInfo {
+ // Account username
+ username: string;
}
+
export interface BankAccountTransactionsResponse {
transactions: BankAccountTransactionInfo[];
}
@@ -1279,7 +1339,7 @@ export namespace TalerCorebankApi {
date: Timestamp;
}
- export interface CreateBankAccountTransactionCreate {
+ export interface CreateTransactionRequest {
// Address in the Payto format of the wire transfer receiver.
// It needs at least the 'message' query string parameter.
payto_uri: PaytoString;
@@ -1291,6 +1351,11 @@ export namespace TalerCorebankApi {
amount?: AmountString;
}
+ export interface CreateTransactionResponse {
+ // ID identifying the transaction being created
+ row_id: Integer;
+ }
+
export interface RegisterAccountResponse {
// Internal payto URI of this bank account.
internal_payto_uri: PaytoString;
@@ -1324,17 +1389,17 @@ export namespace TalerCorebankApi {
// as well.
challenge_contact_data?: ChallengeContactData;
- // 'payto' address pointing a bank account
- // external to the libeufin-bank.
+ // 'payto' address of a fiat bank account.
// Payments will be sent to this bank account
- // when the user wants to convert the local currency
- // back to fiat currency outside libeufin-bank.
+ // when the user wants to convert the regional currency
+ // back to fiat currency outside bank.
cashout_payto_uri?: PaytoString;
// Internal payto URI of this bank account.
// Used mostly for testing.
internal_payto_uri?: PaytoString;
}
+
export interface ChallengeContactData {
// E-Mail address
email?: EmailAddress;
@@ -1525,6 +1590,14 @@ export namespace TalerCorebankApi {
// Time when the cashout was confirmed via its TAN.
// Missing when the operation wasn't confirmed yet.
confirmation_time?: Timestamp;
+
+ // Channel of the last successful transmission of the TAN challenge.
+ // Missing when all transmissions failed.
+ tan_channel?: TanChannel;
+
+ // Info of the last successful transmission of the TAN challenge.
+ // Missing when all transmissions failed.
+ tan_info?: string;
}
export interface ConversionRatesResponse {