diff options
author | Christian Blättler <blatc2@bfh.ch> | 2024-06-13 11:35:52 +0200 |
---|---|---|
committer | Christian Blättler <blatc2@bfh.ch> | 2024-06-13 11:35:52 +0200 |
commit | eb964dfae0a12f9a90eb066d610f627538f8997c (patch) | |
tree | 26a6cd74c9a29edce05b2dcd51cf497374bf8e30 /packages/taler-util/src | |
parent | 9d0fc80a905e02a0a0b63dd547daac6e7b17fb52 (diff) | |
parent | f9d4ff5b43e48a07ac81d7e7ef800ddb12f5f90a (diff) | |
download | wallet-core-eb964dfae0a12f9a90eb066d610f627538f8997c.tar.xz |
Merge branch 'master' into feature/tokens
Diffstat (limited to 'packages/taler-util/src')
-rw-r--r-- | packages/taler-util/src/CancellationToken.ts | 2 | ||||
-rw-r--r-- | packages/taler-util/src/bank-api-client.ts | 2 | ||||
-rw-r--r-- | packages/taler-util/src/errors.ts | 5 | ||||
-rw-r--r-- | packages/taler-util/src/http-client/bank-integration.ts | 8 | ||||
-rw-r--r-- | packages/taler-util/src/http-client/bank-revenue.ts | 4 | ||||
-rw-r--r-- | packages/taler-util/src/http-client/types.ts | 141 | ||||
-rw-r--r-- | packages/taler-util/src/http-impl.qtart.ts | 6 | ||||
-rw-r--r-- | packages/taler-util/src/invariants.ts | 2 | ||||
-rw-r--r-- | packages/taler-util/src/notifications.ts | 2 | ||||
-rw-r--r-- | packages/taler-util/src/payto.ts | 20 | ||||
-rw-r--r-- | packages/taler-util/src/qtart.ts | 5 | ||||
-rw-r--r-- | packages/taler-util/src/taler-error-codes.ts | 148 | ||||
-rw-r--r-- | packages/taler-util/src/taler-types.ts | 4 | ||||
-rw-r--r-- | packages/taler-util/src/transactions-types.ts | 7 | ||||
-rw-r--r-- | packages/taler-util/src/wallet-types.ts | 54 |
15 files changed, 317 insertions, 93 deletions
diff --git a/packages/taler-util/src/CancellationToken.ts b/packages/taler-util/src/CancellationToken.ts index 3aa576d77..5f38f0c7b 100644 --- a/packages/taler-util/src/CancellationToken.ts +++ b/packages/taler-util/src/CancellationToken.ts @@ -172,7 +172,7 @@ class CancellationToken { } = CancellationToken.create(); let timer: NodeJS.Timeout | null; - timer = setTimeout(() => originalCancel(CancellationToken.timeout), ms); + timer = setTimeout(() => originalCancel(`CancellationToken.timeout ${ms}`), ms); const disposeTimer = () => { if (timer == null) return; clearTimeout(timer); diff --git a/packages/taler-util/src/bank-api-client.ts b/packages/taler-util/src/bank-api-client.ts index e9f442af6..e1409087f 100644 --- a/packages/taler-util/src/bank-api-client.ts +++ b/packages/taler-util/src/bank-api-client.ts @@ -385,7 +385,7 @@ export class TalerCorebankApiClient { async createWithdrawalOperation( user: string, - amount: string, + amount: string | undefined, ): Promise<WithdrawalOperationInfo> { const url = new URL(`accounts/${user}/withdrawals`, this.baseUrl); const resp = await this.httpLib.fetch(url.href, { diff --git a/packages/taler-util/src/errors.ts b/packages/taler-util/src/errors.ts index 9378d25e8..d68177e4e 100644 --- a/packages/taler-util/src/errors.ts +++ b/packages/taler-util/src/errors.ts @@ -166,6 +166,11 @@ export interface DetailsMap { [TalerErrorCode.WALLET_DB_UNAVAILABLE]: { innerError: TalerErrorDetail | undefined; }; + [TalerErrorCode.WALLET_EXCHANGE_TOS_NOT_ACCEPTED]: { + exchangeBaseUrl: string; + tosStatus: string; + currentEtag: string | undefined; + }; } type ErrBody<Y> = Y extends keyof DetailsMap ? DetailsMap[Y] : empty; diff --git a/packages/taler-util/src/http-client/bank-integration.ts b/packages/taler-util/src/http-client/bank-integration.ts index 75e6a627a..23740328b 100644 --- a/packages/taler-util/src/http-client/bank-integration.ts +++ b/packages/taler-util/src/http-client/bank-integration.ts @@ -50,7 +50,9 @@ export type TalerBankIntegrationErrorsByMethod< * The API is used by the wallets. */ export class TalerBankIntegrationHttpClient { - public readonly PROTOCOL_VERSION = "2:0:2"; + public static readonly PROTOCOL_VERSION = "2:0:1"; + public readonly PROTOCOL_VERSION = + TalerBankIntegrationHttpClient.PROTOCOL_VERSION; httpLib: HttpRequestLibrary; @@ -147,6 +149,10 @@ export class TalerBankIntegrationHttpClient { return opKnownTalerFailure(details.code, details); case TalerErrorCode.BANK_ACCOUNT_IS_NOT_EXCHANGE: return opKnownTalerFailure(details.code, details); + case TalerErrorCode.BANK_AMOUNT_DIFFERS: + return opKnownTalerFailure(details.code, details); + case TalerErrorCode.BANK_AMOUNT_REQUIRED: + return opKnownTalerFailure(details.code, details); default: return opUnknownFailure(resp, details); } diff --git a/packages/taler-util/src/http-client/bank-revenue.ts b/packages/taler-util/src/http-client/bank-revenue.ts index 34afe7d86..8331856a9 100644 --- a/packages/taler-util/src/http-client/bank-revenue.ts +++ b/packages/taler-util/src/http-client/bank-revenue.ts @@ -25,6 +25,7 @@ import { LibtoolVersion } from "../libtool-version.js"; import { FailCasesByMethod, ResultByMethod, + opFixedSuccess, opKnownHttpFailure, opSuccessFromHttp, opUnknownFailure, @@ -117,6 +118,9 @@ export class TalerRevenueHttpClient { switch (resp.status) { case HttpStatusCode.Ok: return opSuccessFromHttp(resp, codecForRevenueIncomingHistory()); + // FIXME: missing in docs + case HttpStatusCode.NoContent: + return opFixedSuccess({incoming_transactions: [], credit_account: "" }); case HttpStatusCode.BadRequest: return opKnownHttpFailure(resp.status, resp); case HttpStatusCode.Unauthorized: diff --git a/packages/taler-util/src/http-client/types.ts b/packages/taler-util/src/http-client/types.ts index edddf7d94..3e6d857cb 100644 --- a/packages/taler-util/src/http-client/types.ts +++ b/packages/taler-util/src/http-client/types.ts @@ -360,6 +360,7 @@ export const codecForCoreBankConfig = (): Codec<TalerCorebankApi.Config> => ), ) .property("wire_type", codecOptionalDefault(codecForString(), "iban")) + .property("wire_transfer_fees", codecOptional(codecForAmountString())) .build("TalerCorebankApi.Config"); //FIXME: implement this codec @@ -902,7 +903,6 @@ export const codecForTemplateDetails = .property("template_description", codecForString()) .property("otp_id", codecOptional(codecForString())) .property("template_contract", codecForTemplateContractDetails()) - .property("required_currency", codecOptional(codecForString())) .property( "editable_defaults", codecOptional(codecForTemplateContractDetailsDefaults()), @@ -931,7 +931,6 @@ export const codecForWalletTemplateDetails = (): Codec<TalerMerchantApi.WalletTemplateDetails> => buildCodecForObject<TalerMerchantApi.WalletTemplateDetails>() .property("template_contract", codecForTemplateContractDetails()) - .property("required_currency", codecOptional(codecForString())) .property( "editable_defaults", codecOptional(codecForTemplateContractDetailsDefaults()), @@ -1311,9 +1310,12 @@ export const codecForBankWithdrawalOperationStatus = codecForConstString("confirmed"), ), ) - .property("amount", codecForAmountString()) + .property("amount", codecOptional(codecForAmountString())) + .property("currency", codecOptional(codecForCurrencyName())) + .property("suggested_amount", codecOptional(codecForAmountString())) + .property("card_fees", codecOptional(codecForAmountString())) .property("sender_wire", codecOptional(codecForPaytoString())) - .property("suggested_exchange", codecOptional(codecForString())) + .property("suggested_exchange", codecOptional(codecForURL())) .property("confirm_transfer_url", codecOptional(codecForURL())) .property("wire_types", codecForList(codecForString())) .property("selected_reserve_pub", codecOptional(codecForString())) @@ -2028,20 +2030,53 @@ export namespace TalerBankIntegrationApi { // confirmed: the transfer has been confirmed and registered by the bank status: WithdrawalOperationStatus; - // Amount that will be withdrawn with this operation - // (raw amount without fee considerations). - amount: AmountString; + // Currency used for the withdrawal. + // MUST be present when amount is absent. + // @since v2, may become mandatory in the future. + currency?: string; - // Bank account of the customer that is withdrawing, as a - // payto URI. + // Amount that will be withdrawn with this operation + // (raw amount without fee considerations). Only + // given once the amount is fixed and cannot be changed. + // Optional since **vC2EC**. + amount?: AmountString | undefined; + + // Suggestion for the amount to be withdrawn with this + // operation. Given if a suggestion was made but the + // user may still change the amount. + // Optional since **vC2EC**. + suggested_amount?: AmountString | undefined; + + // Maximum amount that the wallet can choose to withdraw. + // Only applicable when the amount is not fixed. + // @since **vC2EC**. + max_amount?: AmountString | undefined; + + // The non-Taler card fees the customer will have + // to pay to the bank / payment service provider + // they are using to make the withdrawal. + // @since **vC2EC** + card_fees?: AmountString | undefined; + + // Bank account of the customer that is debiting, as an + // RFC 8905 payto URI. sender_wire?: PaytoString; - // Suggestion for an exchange given by the bank. + // Base URL of the suggested exchange. The bank may have + // neither a suggestion nor a requirement for the exchange. + // This value is typically set in the bank's configuration. suggested_exchange?: string; + // Base URL of an exchange that must be used. Optional, + // not given *unless* a particular exchange is mandatory. + // This value is typically set in the bank's configuration. + // @since **vC2EC** + required_exchange?: string; + // URL that the user needs to navigate to in order to // complete some final confirmation (e.g. 2FA). - // It may contain withdrawal operation id + // Only applicable when status is selected or pending. + // It may contain the withdrawal operation id. confirm_transfer_url?: string; // Wire transfer types supported by the bank. @@ -2051,17 +2086,24 @@ export namespace TalerBankIntegrationApi { // only non-null if status is selected or confirmed. selected_reserve_pub?: string; - // Exchange account selected by the wallet + // Exchange account selected by the wallet; // only non-null if status is selected or confirmed. + // @since **v1** selected_exchange_account?: string; } export interface BankWithdrawalOperationPostRequest { - // Reserve public key. + // Reserve public key that should become the wire transfer + // subject to fund the withdrawal. reserve_pub: string; // Payto address of the exchange selected for the withdrawal. selected_exchange: PaytoString; + + // Selected amount to be transferred. Optional if the + // backend already knows the amount. + // @since **vC2EC** + amount?: AmountString | undefined; } export interface BankWithdrawalOperationPostResponse { @@ -2075,7 +2117,7 @@ export namespace TalerBankIntegrationApi { // URL that the user needs to navigate to in order to // complete some final confirmation (e.g. 2FA). // - // Only applicable when status is selected. + // Only applicable when status is selected or pending. // It may contain withdrawal operation id confirm_transfer_url?: string; } @@ -2150,12 +2192,31 @@ export namespace TalerCorebankApi { // Default to 'iban' is missing // @since v4, may become mandatory in the future. wire_type: string; + + // Wire transfer execution fees. + // @since v4, will become mandatory in the next version. + wire_transfer_fees?: AmountString; } export interface BankAccountCreateWithdrawalRequest { - // Amount to withdraw. - amount: AmountString; + // Amount to withdraw. If given, the wallet + // cannot change the amount. + // Optional since **vC2EC**. + amount?: AmountString; + + // Suggested amount to withdraw. The wallet can + // still change the suggestion. + // @since **vC2EC** + suggested_amount?: AmountString; + + // The non-Taler card fees the customer will have + // to pay to the account owner, bank and/or + // payment service provider + // they are using to make this withdrawal. + // @since **vC2EC** + card_fees?: AmountString; } + export interface BankAccountCreateWithdrawalResponse { // ID of the withdrawal, can be used to view/modify the withdrawal operation. withdrawal_id: string; @@ -2498,10 +2559,6 @@ export namespace TalerCorebankApi { export interface CashoutInfo { cashout_id: number; - /** - * @deprecated since 4, use new 2fa - */ - status?: "pending" | "aborted" | "confirmed"; } export interface GlobalCashouts { // Every string represents a cash-out operation ID. @@ -4693,17 +4750,6 @@ export namespace TalerMerchantApi { // user-editable defaults for this template. // Since protocol **v13**. editable_defaults?: TemplateContractDetailsDefaults; - - // Required currency for payments. Useful if no - // amount is specified in the template_contract - // but the user should be required to pay in a - // particular currency anyway. Merchant backends - // may reject requests if the template_contract - // or editable_defaults do - // specify an amount in a different currency. - // This parameter is optional. - // Since protocol **v13**. - required_currency?: string; } export interface TemplateContractDetails { // Human-readable summary for the template. @@ -4755,17 +4801,6 @@ export namespace TalerMerchantApi { // user-editable defaults for this template. // Since protocol **v13**. editable_defaults?: TemplateContractDetailsDefaults; - - // Required currency for payments. Useful if no - // amount is specified in the template_contract - // but the user should be required to pay in a - // particular currency anyway. Merchant backends - // may reject requests if the template_contract - // or editable_defaults do - // specify an amount in a different currency. - // This parameter is optional. - // Since protocol **v13**. - required_currency?: string; } export interface TemplateSummaryResponse { @@ -4791,17 +4826,6 @@ export namespace TalerMerchantApi { // user-editable defaults for this template. // Since protocol **v13**. editable_defaults?: TemplateContractDetailsDefaults; - - // Required currency for payments. Useful if no - // amount is specified in the template_contract - // but the user should be required to pay in a - // particular currency anyway. Merchant backends - // may reject requests if the template_contract - // or editable_defaults do - // specify an amount in a different currency. - // This parameter is optional. - // Since protocol **v13**. - required_currency?: string; } export interface TemplateDetails { @@ -4820,17 +4844,6 @@ export namespace TalerMerchantApi { // user-editable defaults for this template. // Since protocol **v13**. editable_defaults?: TemplateContractDetailsDefaults; - - // Required currency for payments. Useful if no - // amount is specified in the template_contract - // but the user should be required to pay in a - // particular currency anyway. Merchant backends - // may reject requests if the template_contract - // or editable_defaults do - // specify an amount in a different currency. - // This parameter is optional. - // Since protocol **v13**. - required_currency?: string; } export interface UsingTemplateDetails { // Summary of the template diff --git a/packages/taler-util/src/http-impl.qtart.ts b/packages/taler-util/src/http-impl.qtart.ts index b4e4ebbe7..f60c82fc3 100644 --- a/packages/taler-util/src/http-impl.qtart.ts +++ b/packages/taler-util/src/http-impl.qtart.ts @@ -118,7 +118,10 @@ export class HttpLibImpl implements HttpRequestLibrary { // Just like WHATWG fetch(), the qjs http client doesn't // really support cancellation, so cancellation here just // means that the result is ignored! - const fetchProm = qjsOs.fetchHttp(url, { + const { + promise: fetchProm, + cancelFn + } = qjsOs.fetchHttp(url, { method, data, headers: headersList, @@ -135,6 +138,7 @@ export class HttpLibImpl implements HttpRequestLibrary { if (opt?.cancellationToken) { cancelCancelledHandler = opt.cancellationToken.onCancelled(() => { + cancelFn(); cancelPromCap.reject(new RequestCancelledError()); }); } diff --git a/packages/taler-util/src/invariants.ts b/packages/taler-util/src/invariants.ts index c6e9b8113..113d697c3 100644 --- a/packages/taler-util/src/invariants.ts +++ b/packages/taler-util/src/invariants.ts @@ -33,7 +33,7 @@ export class InvariantViolatedError extends Error { * * A violation of this invariant means that the database is inconsistent. */ -export function checkDbInvariant(b: boolean, m?: string): asserts b { +export function checkDbInvariant(b: boolean, m: string): asserts b { if (!b) { if (m) { throw Error(`BUG: database invariant failed (${m})`); diff --git a/packages/taler-util/src/notifications.ts b/packages/taler-util/src/notifications.ts index d4dfe7589..a8a8c3299 100644 --- a/packages/taler-util/src/notifications.ts +++ b/packages/taler-util/src/notifications.ts @@ -128,7 +128,7 @@ export enum ObservabilityEventType { TaskStart = "task-start", TaskStop = "task-stop", TaskReset = "task-reset", - ShepherdTaskResult = "sheperd-task-result", + ShepherdTaskResult = "shepherd-task-result", DeclareTaskDependency = "declare-task-dependency", CryptoStart = "crypto-start", CryptoFinishSuccess = "crypto-finish-success", diff --git a/packages/taler-util/src/payto.ts b/packages/taler-util/src/payto.ts index a471d0b87..39c25cffd 100644 --- a/packages/taler-util/src/payto.ts +++ b/packages/taler-util/src/payto.ts @@ -15,7 +15,7 @@ */ import { generateFakeSegwitAddress } from "./bitcoin.js"; -import { Codec, Context, DecodingError, renderContext } from "./codec.js"; +import { Codec, Context, DecodingError, buildCodecForObject, codecForStringURL, renderContext } from "./codec.js"; import { URLSearchParams } from "./url.js"; export type PaytoUri = @@ -291,3 +291,21 @@ export function talerPaytoFromExchangeReserve( return `payto://${proto}/${url.host}${url.pathname}${reservePub}`; } + +/** + * The account letter is all the information + * the merchant backend requires from the + * bank account to check transfer. + * + */ +export type AccountLetter = { + accountURI: PaytoString; + infoURL: string; +}; + +export const codecForAccountLetter = + (): Codec<AccountLetter> => + buildCodecForObject<AccountLetter>() + .property("infoURL", codecForStringURL(true)) + .property("accountURI", codecForPaytoString()) + .build("AccountLetter"); diff --git a/packages/taler-util/src/qtart.ts b/packages/taler-util/src/qtart.ts index e298a157c..6a5984973 100644 --- a/packages/taler-util/src/qtart.ts +++ b/packages/taler-util/src/qtart.ts @@ -17,7 +17,10 @@ export interface QjsHttpOptions { } export interface QjsOsLib { - fetchHttp(url: string, options?: QjsHttpOptions): Promise<QjsHttpResp>; + fetchHttp(url: string, options?: QjsHttpOptions): { + promise: Promise<QjsHttpResp>, + cancelFn: () => number, + }; postMessageToHost(s: string): void; setMessageFromHostHandler(h: (s: string) => void): void; rename(oldPath: string, newPath: string): number; diff --git a/packages/taler-util/src/taler-error-codes.ts b/packages/taler-util/src/taler-error-codes.ts index 9985e74b3..f77357407 100644 --- a/packages/taler-util/src/taler-error-codes.ts +++ b/packages/taler-util/src/taler-error-codes.ts @@ -354,7 +354,7 @@ export enum TalerErrorCode { /** * The backend could not locate a required template to generate an HTML reply. The system administrator should check if the resource files are installed in the correct location and are readable to the service. - * Returned with an HTTP status code of #MHD_HTTP_INTERNAL_SERVER_ERROR (500). + * Returned with an HTTP status code of #MHD_HTTP_NOT_ACCEPTABLE (406). * (A value of 0 indicates that the error is generated client-side). */ GENERIC_FAILED_TO_LOAD_TEMPLATE = 74, @@ -1945,7 +1945,7 @@ export enum TalerErrorCode { /** - * The payto-URI hash did not match. Hence the request was denied. + * The KYC authorization signature was invalid. Hence the request was denied. * Returned with an HTTP status code of #MHD_HTTP_FORBIDDEN (403). * (A value of 0 indicates that the error is generated client-side). */ @@ -2017,6 +2017,22 @@ export enum TalerErrorCode { /** + * The exchange is unaware of the given requirement row. + * Returned with an HTTP status code of #MHD_HTTP_NOT_FOUND (404). + * (A value of 0 indicates that the error is generated client-side). + */ + EXCHANGE_KYC_CHECK_REQUEST_UNKNOWN = 1939, + + + /** + * The exchange has no account public key to check the KYC authorization signature against. Hence the request was denied. The user should do a wire transfer to the exchange with the KYC authorization key in the subject. + * Returned with an HTTP status code of #MHD_HTTP_CONFLICT (409). + * (A value of 0 indicates that the error is generated client-side). + */ + EXCHANGE_KYC_CHECK_AUTHORIZATION_KEY_UNKNOWN = 1940, + + + /** * The exchange does not know a contract under the given contract public key. * Returned with an HTTP status code of #MHD_HTTP_NOT_FOUND (404). * (A value of 0 indicates that the error is generated client-side). @@ -2105,6 +2121,14 @@ export enum TalerErrorCode { /** + * The product category is not known to the backend. + * Returned with an HTTP status code of #MHD_HTTP_NOT_FOUND (404). + * (A value of 0 indicates that the error is generated client-side). + */ + MERCHANT_GENERIC_CATEGORY_UNKNOWN = 2003, + + + /** * The proposal is not known to the backend. * Returned with an HTTP status code of #MHD_HTTP_NOT_FOUND (404). * (A value of 0 indicates that the error is generated client-side). @@ -2561,6 +2585,14 @@ export enum TalerErrorCode { /** + * Invalid token because it was already used, is expired or not yet valid. + * Returned with an HTTP status code of #MHD_HTTP_CONFLICT (409). + * (A value of 0 indicates that the error is generated client-side). + */ + MERCHANT_POST_ORDERS_ID_PAY_TOKEN_INVALID = 2183, + + + /** * The contract hash does not match the given order ID. * Returned with an HTTP status code of #MHD_HTTP_BAD_REQUEST (400). * (A value of 0 indicates that the error is generated client-side). @@ -2921,6 +2953,14 @@ export enum TalerErrorCode { /** + * A token family referenced in this order is either expired or not valid yet. + * Returned with an HTTP status code of #MHD_HTTP_CONFLICT (409). + * (A value of 0 indicates that the error is generated client-side). + */ + MERCHANT_PRIVATE_POST_ORDERS_TOKEN_FAMILY_NOT_VALID = 2534, + + + /** * The exchange says it does not know this transfer. * Returned with an HTTP status code of #MHD_HTTP_BAD_GATEWAY (502). * (A value of 0 indicates that the error is generated client-side). @@ -3057,6 +3097,14 @@ export enum TalerErrorCode { /** + * A category with the same name exists already. + * Returned with an HTTP status code of #MHD_HTTP_CONFLICT (409). + * (A value of 0 indicates that the error is generated client-side). + */ + MERCHANT_PRIVATE_POST_CATEGORIES_CONFLICT_CATEGORY_EXISTS = 2651, + + + /** * The update would have reduced the total amount of product lost, which is not allowed. * Returned with an HTTP status code of #MHD_HTTP_CONFLICT (409). * (A value of 0 indicates that the error is generated client-side). @@ -3233,6 +3281,22 @@ export enum TalerErrorCode { /** + * The auditor refused the connection due to a lack of authorization. + * Returned with an HTTP status code of #MHD_HTTP_UNAUTHORIZED (401). + * (A value of 0 indicates that the error is generated client-side). + */ + AUDITOR_GENERIC_UNAUTHORIZED = 3001, + + + /** + * This method is not allowed here. + * Returned with an HTTP status code of #MHD_HTTP_METHOD_NOT_ALLOWED (405). + * (A value of 0 indicates that the error is generated client-side). + */ + AUDITOR_GENERIC_METHOD_NOT_ALLOWED = 3002, + + + /** * The signature from the exchange on the deposit confirmation is invalid. * Returned with an HTTP status code of #MHD_HTTP_FORBIDDEN (403). * (A value of 0 indicates that the error is generated client-side). @@ -3633,6 +3697,22 @@ export enum TalerErrorCode { /** + * Specified amount will not work for this withdrawal. + * Returned with an HTTP status code of #MHD_HTTP_CONFLICT (409). + * (A value of 0 indicates that the error is generated client-side). + */ + BANK_AMOUNT_DIFFERS = 5148, + + + /** + * The backend requires an amount to be specified. + * Returned with an HTTP status code of #MHD_HTTP_CONFLICT (409). + * (A value of 0 indicates that the error is generated client-side). + */ + BANK_AMOUNT_REQUIRED = 5149, + + + /** * The sync service failed find the account in its database. * Returned with an HTTP status code of #MHD_HTTP_NOT_FOUND (404). * (A value of 0 indicates that the error is generated client-side). @@ -4049,6 +4129,14 @@ export enum TalerErrorCode { /** + * A wallet-core request failed because the user needs to first accept the exchange's terms of service. + * Returned with an HTTP status code of #MHD_HTTP_UNINITIALIZED (0). + * (A value of 0 indicates that the error is generated client-side). + */ + WALLET_EXCHANGE_TOS_NOT_ACCEPTED = 7037, + + + /** * We encountered a timeout with our payment backend. * Returned with an HTTP status code of #MHD_HTTP_GATEWAY_TIMEOUT (504). * (A value of 0 indicates that the error is generated client-side). @@ -4609,6 +4697,62 @@ export enum TalerErrorCode { /** + * The Donau is not aware of the donation unit requested for the operation. + * Returned with an HTTP status code of #MHD_HTTP_NOT_FOUND (404). + * (A value of 0 indicates that the error is generated client-side). + */ + DONAU_GENERIC_DONATION_UNIT_UNKNOWN = 8611, + + + /** + * The Donau failed to talk to the process responsible for its private donation unit keys or the helpers had no donation units (properly) configured. + * Returned with an HTTP status code of #MHD_HTTP_BAD_GATEWAY (502). + * (A value of 0 indicates that the error is generated client-side). + */ + DONAU_DONATION_UNIT_HELPER_UNAVAILABLE = 8612, + + + /** + * The Donau failed to talk to the process responsible for its private signing keys. + * Returned with an HTTP status code of #MHD_HTTP_BAD_GATEWAY (502). + * (A value of 0 indicates that the error is generated client-side). + */ + DONAU_SIGNKEY_HELPER_UNAVAILABLE = 8613, + + + /** + * The response from the online signing key helper process was malformed. + * Returned with an HTTP status code of #MHD_HTTP_INTERNAL_SERVER_ERROR (500). + * (A value of 0 indicates that the error is generated client-side). + */ + DONAU_SIGNKEY_HELPER_BUG = 8614, + + + /** + * The number of segments included in the URI does not match the number of segments expected by the endpoint. + * Returned with an HTTP status code of #MHD_HTTP_NOT_FOUND (404). + * (A value of 0 indicates that the error is generated client-side). + */ + DONAU_GENERIC_WRONG_NUMBER_OF_SEGMENTS = 8615, + + + /** + * The signature of the donation receipt is not valid. + * Returned with an HTTP status code of #MHD_HTTP_FORBIDDEN (403). + * (A value of 0 indicates that the error is generated client-side). + */ + DONAU_DONATION_RECEIPT_SIGNATURE_INVALID = 8616, + + + /** + * The client re-used a unique donor identifier nonce, which is not allowed. + * Returned with an HTTP status code of #MHD_HTTP_CONFLICT (409). + * (A value of 0 indicates that the error is generated client-side). + */ + DONAU_DONOR_IDENTIFIER_NONCE_REUSE = 8617, + + + /** * A generic error happened in the LibEuFin nexus. See the enclose details JSON for more information. * Returned with an HTTP status code of #MHD_HTTP_UNINITIALIZED (0). * (A value of 0 indicates that the error is generated client-side). diff --git a/packages/taler-util/src/taler-types.ts b/packages/taler-util/src/taler-types.ts index e2536b74a..66f98ea9a 100644 --- a/packages/taler-util/src/taler-types.ts +++ b/packages/taler-util/src/taler-types.ts @@ -978,7 +978,7 @@ export class WithdrawOperationStatusResponse { aborted: boolean; - amount: string; + amount: string | undefined; sender_wire?: string; @@ -1557,7 +1557,7 @@ export const codecForWithdrawOperationStatusResponse = .property("selection_done", codecForBoolean()) .property("transfer_done", codecForBoolean()) .property("aborted", codecForBoolean()) - .property("amount", codecForString()) + .property("amount", codecOptional(codecForString())) .property("sender_wire", codecOptional(codecForString())) .property("suggested_exchange", codecOptional(codecForString())) .property("confirm_transfer_url", codecOptional(codecForString())) diff --git a/packages/taler-util/src/transactions-types.ts b/packages/taler-util/src/transactions-types.ts index cee3de9fa..a6ac5aec6 100644 --- a/packages/taler-util/src/transactions-types.ts +++ b/packages/taler-util/src/transactions-types.ts @@ -105,8 +105,11 @@ export enum TransactionMajorState { Done = "done", Aborting = "aborting", Aborted = "aborted", - Suspended = "suspended", Dialog = "dialog", + Finalizing = "finalizing", + // Plain suspended is always a suspended pending state. + Suspended = "suspended", + SuspendedFinalizing = "suspended-finalizing", SuspendedAborting = "suspended-aborting", Failed = "failed", Expired = "expired", @@ -324,7 +327,7 @@ export interface TransactionWithdrawal extends TransactionCommon { /** * Exchange of the withdrawal. */ - exchangeBaseUrl: string; + exchangeBaseUrl: string | undefined; /** * Amount that got subtracted from the reserve balance. diff --git a/packages/taler-util/src/wallet-types.ts b/packages/taler-util/src/wallet-types.ts index d472af187..d23780145 100644 --- a/packages/taler-util/src/wallet-types.ts +++ b/packages/taler-util/src/wallet-types.ts @@ -54,7 +54,7 @@ import { canonicalizeBaseUrl, } from "./index.js"; import { VersionMatchResult } from "./libtool-version.js"; -import { PaytoUri } from "./payto.js"; +import { PaytoString, PaytoUri, codecForPaytoString } from "./payto.js"; import { AgeCommitmentProof } from "./taler-crypto.js"; import { TalerErrorCode } from "./taler-error-codes.js"; import { @@ -229,11 +229,13 @@ interface GetPlanForWalletInitiatedOperation { export interface ConvertAmountRequest { amount: AmountString; type: TransactionAmountMode; + depositPaytoUri: PaytoString; } export const codecForConvertAmountRequest = buildCodecForObject<ConvertAmountRequest>() .property("amount", codecForAmountString()) + .property("depositPaytoUri", codecForPaytoString()) .property( "type", codecForEither( @@ -663,11 +665,11 @@ export interface CoinDumpJson { withdrawal_reserve_pub: string | undefined; coin_status: CoinStatus; spend_allocation: - | { - id: string; - amount: AmountString; - } - | undefined; + | { + id: string; + amount: AmountString; + } + | undefined; /** * Information about the age restriction */ @@ -801,7 +803,7 @@ export const codecForPreparePayResultPaymentPossible = ) .build("PreparePayResultPaymentPossible"); -export interface BalanceDetails { } +export interface BalanceDetails {} /** * Detailed reason for why the wallet's balance is insufficient. @@ -984,9 +986,14 @@ export interface PreparePayResultAlreadyConfirmed { export interface BankWithdrawDetails { status: WithdrawalOperationStatus; - amount: AmountJson; + currency: string; + amount: AmountJson | undefined; + editableAmount: boolean; + maxAmount: AmountJson | undefined; + wireFee: AmountJson | undefined; senderWire?: string; - suggestedExchange?: string; + exchange?: string; + editableExchange: boolean; confirmTransferUrl?: string; wireTypes: string[]; operationId: string; @@ -1331,6 +1338,7 @@ export enum ExchangeTosStatus { Pending = "pending", Proposed = "proposed", Accepted = "accepted", + MissingTos = "missing-tos", } export enum ExchangeEntryStatus { @@ -1846,18 +1854,16 @@ export interface GetWithdrawalDetailsForAmountRequest { export interface PrepareBankIntegratedWithdrawalRequest { talerWithdrawUri: string; - selectedExchange?: string; } export const codecForPrepareBankIntegratedWithdrawalRequest = (): Codec<PrepareBankIntegratedWithdrawalRequest> => buildCodecForObject<PrepareBankIntegratedWithdrawalRequest>() .property("talerWithdrawUri", codecForString()) - .property("selectedExchange", codecOptional(codecForString())) .build("PrepareBankIntegratedWithdrawalRequest"); export interface PrepareBankIntegratedWithdrawalResponse { - transactionId?: string; + transactionId: TransactionIdStr; info: WithdrawUriInfoResponse; } @@ -1883,6 +1889,13 @@ export interface AcceptBankIntegratedWithdrawalRequest { talerWithdrawUri: string; exchangeBaseUrl: string; forcedDenomSel?: ForcedDenomSel; + /** + * Amount to withdraw. + * If the bank's withdrawal operation uses a fixed amount, + * this field must either be left undefined or its value must match + * the amount from the withdrawal operation. + */ + amount?: AmountString; restrictAge?: number; } @@ -1892,6 +1905,7 @@ export const codecForAcceptBankIntegratedWithdrawalRequest = .property("exchangeBaseUrl", codecForCanonBaseUrl()) .property("talerWithdrawUri", codecForString()) .property("forcedDenomSel", codecForAny()) + .property("amount", codecOptional(codecForAmountString())) .property("restrictAge", codecOptional(codecForNumber())) .build("AcceptBankIntegratedWithdrawalRequest"); @@ -2047,7 +2061,7 @@ export interface CheckPayTemplateRequest { export type CheckPayTemplateReponse = { templateDetails: TalerMerchantApi.WalletTemplateDetails; supportedCurrencies: string[]; -} +}; export const codecForCheckPayTemplateRequest = (): Codec<CheckPayTemplateRequest> => @@ -2352,8 +2366,13 @@ export interface WithdrawUriInfoResponse { operationId: string; status: WithdrawalOperationStatus; confirmTransferUrl?: string; - amount: AmountString; + currency: string; + amount: AmountString | undefined; + editableAmount: boolean; + maxAmount: AmountString | undefined; + wireFee: AmountString | undefined; defaultExchangeBaseUrl?: string; + editableExchange: boolean; possibleExchanges: ExchangeListItem[]; } @@ -2371,7 +2390,12 @@ export const codecForWithdrawUriInfoResponse = codecForConstString("confirmed"), ), ) - .property("amount", codecForAmountString()) + .property("amount", codecOptional(codecForAmountString())) + .property("maxAmount", codecOptional(codecForAmountString())) + .property("wireFee", codecOptional(codecForAmountString())) + .property("currency", codecForString()) + .property("editableAmount", codecForBoolean()) + .property("editableExchange", codecForBoolean()) .property("defaultExchangeBaseUrl", codecOptional(codecForCanonBaseUrl())) .property("possibleExchanges", codecForList(codecForExchangeListItem())) .build("WithdrawUriInfoResponse"); |