summaryrefslogtreecommitdiff
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.ts140
1 files changed, 100 insertions, 40 deletions
diff --git a/packages/taler-util/src/http-client/types.ts b/packages/taler-util/src/http-client/types.ts
index b0d4deca1..f43a0a3a1 100644
--- a/packages/taler-util/src/http-client/types.ts
+++ b/packages/taler-util/src/http-client/types.ts
@@ -1,3 +1,4 @@
+import { deprecate } from "util";
import { codecForAmountString } from "../amounts.js";
import {
Codec,
@@ -280,8 +281,8 @@ export const codecForCoreBankConfig = (): Codec<TalerCorebankApi.Config> =>
.property("currency_specification", codecForCurrencySpecificiation())
.property("currency", codecForString())
.property("supported_tan_channels", codecForList(codecForEither(
- codecForConstString(TanChannel.SMS),
- codecForConstString(TanChannel.EMAIL),
+ codecForConstString(TalerCorebankApi.TanChannel.SMS),
+ codecForConstString(TalerCorebankApi.TanChannel.EMAIL),
)))
.build("TalerCorebankApi.Config");
@@ -434,8 +435,8 @@ export const codecForBankAccountCreateWithdrawalResponse =
.build("TalerCorebankApi.BankAccountCreateWithdrawalResponse");
export const codecForCashoutPending =
- (): Codec<TalerCorebankApi.CashoutPending> =>
- buildCodecForObject<TalerCorebankApi.CashoutPending>()
+ (): Codec<TalerCorebankApi.CashoutResponse> =>
+ buildCodecForObject<TalerCorebankApi.CashoutResponse>()
.property("cashout_id", codecForNumber())
.build("TalerCorebankApi.CashoutPending");
@@ -463,11 +464,12 @@ export const codecForCashoutInfo = (): Codec<TalerCorebankApi.CashoutInfo> =>
.property("cashout_id", codecForNumber())
.property(
"status",
- codecForEither(
- codecForConstString("pending"),
- codecForConstString("aborted"),
- codecForConstString("confirmed"),
- ),
+ codecOptional(
+ codecForEither(
+ codecForConstString("pending"),
+ codecForConstString("aborted"),
+ codecForConstString("confirmed"),
+ )),
)
.build("TalerCorebankApi.CashoutInfo");
@@ -484,11 +486,12 @@ export const codecForGlobalCashoutInfo =
.property("username", codecForString())
.property(
"status",
- codecForEither(
- codecForConstString("pending"),
- codecForConstString("aborted"),
- codecForConstString("confirmed"),
- ),
+ codecOptional(
+ codecForEither(
+ codecForConstString("pending"),
+ codecForConstString("aborted"),
+ codecForConstString("confirmed"),
+ )),
)
.build("TalerCorebankApi.GlobalCashoutInfo");
@@ -497,26 +500,25 @@ export const codecForCashoutStatusResponse =
buildCodecForObject<TalerCorebankApi.CashoutStatusResponse>()
.property("amount_credit", codecForAmountString())
.property("amount_debit", codecForAmountString())
- .property("confirmation_time", codecOptional(codecForTimestamp))
.property("creation_time", codecForTimestamp)
- // .property("credit_payto_uri", codecForPaytoString())
+ .property(
+ "tan_channel",
+ codecOptional(codecForEither(
+ codecForConstString(TalerCorebankApi.TanChannel.SMS),
+ codecForConstString(TalerCorebankApi.TanChannel.EMAIL),
+ )),
+ )
+ .property("subject", codecForString())
+ .property("confirmation_time", codecOptional(codecForTimestamp))
.property(
"status",
- codecForEither(
+ codecOptional(codecForEither(
codecForConstString("pending"),
codecForConstString("aborted"),
codecForConstString("confirmed"),
- ),
+ )),
)
- .property(
- "tan_channel",
- codecForEither(
- codecForConstString(TanChannel.SMS),
- codecForConstString(TanChannel.EMAIL),
- ),
- )
- .property("subject", codecForString())
- .property("tan_info", codecForString())
+ .property("tan_info", codecOptional(codecForString()))
.build("TalerCorebankApi.CashoutStatusResponse");
export const codecForConversionRatesResponse =
@@ -735,6 +737,22 @@ export const codecForAmlDecisionDetail =
.property("decider_pub", codecForString())
.build("TalerExchangeApi.AmlDecisionDetail");
+export const codecForChallenge =
+ (): Codec<TalerCorebankApi.Challenge> =>
+ buildCodecForObject<TalerCorebankApi.Challenge>()
+ .property("challenge_id", codecForString())
+ .build("TalerCorebankApi.Challenge");
+
+export const codecForTanTransmission =
+ (): Codec<TalerCorebankApi.TanTransmission> =>
+ buildCodecForObject<TalerCorebankApi.TanTransmission>()
+ .property("tan_channel", codecForEither(
+ codecForConstString(TalerCorebankApi.TanChannel.SMS),
+ codecForConstString(TalerCorebankApi.TanChannel.EMAIL),
+ ))
+ .property("tan_info", codecForString())
+ .build("TalerCorebankApi.TanTransmission");
+
interface KycDetail {
provider_section: string;
attributes?: Object;
@@ -894,10 +912,6 @@ const codecForLibtoolVersion = codecForString;
const codecForCurrencyName = codecForString;
const codecForDecimalNumber = codecForString;
-enum TanChannel {
- SMS = "sms",
- EMAIL = "email",
-}
export type WithdrawalOperationStatus =
| "pending"
| "selected"
@@ -1442,10 +1456,6 @@ export namespace TalerCorebankApi {
is_taler_exchange?: boolean;
// Addresses where to send the TAN for transactions.
- // Currently only used for cashouts.
- // If missing, cashouts will fail.
- // In the future, might be used for other transactions
- // as well.
contact_data?: ChallengeContactData;
// 'payto' address of a fiat bank account.
@@ -1497,6 +1507,10 @@ export namespace TalerCorebankApi {
// If present, change the max debit allowed for this user
// Only admin can change this property.
debit_threshold?: AmountString;
+
+ // If present, enables 2FA and set the TAN channel used for challenges
+ tan_channel?: TanChannel;
+
}
export interface AccountPasswordChange {
@@ -1579,6 +1593,9 @@ export namespace TalerCorebankApi {
// Is this a taler exchange account?
is_taler_exchange: boolean;
+
+ // Is 2FA enabled and what channel is used for challenges?
+ tan_channel?: TanChannel;
}
export interface CashoutRequest {
@@ -1613,15 +1630,20 @@ export namespace TalerCorebankApi {
// this field is missing, it defaults to SMS.
// The default choice prefers to change the communication
// channel respect to the one used to issue this request.
+ /**
+ * @deprecated since 4, use 2fa
+ */
tan_channel?: TanChannel;
}
- export interface CashoutPending {
+ export interface CashoutResponse {
// ID identifying the operation being created
- // and now waiting for the TAN confirmation.
cashout_id: number;
}
+ /**
+ * @deprecated since 4, use 2fa
+ */
export interface CashoutConfirmRequest {
// the TAN that confirms $CASHOUT_ID.
tan: string;
@@ -1634,7 +1656,10 @@ export namespace TalerCorebankApi {
export interface CashoutInfo {
cashout_id: number;
- status: "pending" | "aborted" | "confirmed";
+ /**
+ * @deprecated since 4, use new 2fa
+ */
+ status?: "pending" | "aborted" | "confirmed";
}
export interface GlobalCashouts {
// Every string represents a cash-out operation ID.
@@ -1643,11 +1668,13 @@ export namespace TalerCorebankApi {
export interface GlobalCashoutInfo {
cashout_id: number;
username: string;
- status: "pending" | "aborted" | "confirmed";
+ /**
+ * @deprecated since 4, use new 2fa
+ */
+ status?: "pending" | "aborted" | "confirmed";
}
export interface CashoutStatusResponse {
- status: "pending" | "aborted" | "confirmed";
// Amount debited to the internal
// regional currency bank account.
@@ -1666,16 +1693,30 @@ export namespace TalerCorebankApi {
// Time when the cashout was created.
creation_time: Timestamp;
+ /**
+ * @deprecated since 4, use new 2fa
+ */
+ status?: "pending" | "aborted" | "confirmed";
+
// Time when the cashout was confirmed via its TAN.
// Missing when the operation wasn't confirmed yet.
+ /**
+ * @deprecated since 4, use new 2fa
+ */
confirmation_time?: Timestamp;
// Channel of the last successful transmission of the TAN challenge.
// Missing when all transmissions failed.
+ /**
+ * @deprecated since 4, use new 2fa
+ */
tan_channel?: TanChannel;
// Info of the last successful transmission of the TAN challenge.
// Missing when all transmissions failed.
+ /**
+ * @deprecated since 4, use new 2fa
+ */
tan_info?: string;
}
@@ -1767,6 +1808,25 @@ export namespace TalerCorebankApi {
// exchange to another bank account.
talerOutVolume: AmountString;
}
+ export interface TanTransmission {
+ // Channel of the last successful transmission of the TAN challenge.
+ tan_channel: TanChannel;
+
+ // Info of the last successful transmission of the TAN challenge.
+ tan_info: string;
+ }
+
+ export interface Challenge {
+ // Unique identifier of the challenge to solve to run this protected
+ // operation.
+ challenge_id: string;
+ }
+
+ export enum TanChannel {
+ SMS = "sms",
+ EMAIL = "email"
+ }
+
}
export namespace TalerExchangeApi {