diff options
author | Florian Dold <florian@dold.me> | 2023-05-05 14:56:28 +0200 |
---|---|---|
committer | Florian Dold <florian@dold.me> | 2023-05-05 14:56:33 +0200 |
commit | 9a412260f3b0a53b1508e2db8724a0c58ce080cf (patch) | |
tree | 40c495c9ec97ab8e2631076eeec2c8165a561d88 /packages/taler-util/src | |
parent | 990b056071fd0b3879d4366ff3dd625aa3265738 (diff) | |
download | wallet-core-9a412260f3b0a53b1508e2db8724a0c58ce080cf.tar.xz |
adapt to merchant API breaking changes
Diffstat (limited to 'packages/taler-util/src')
-rw-r--r-- | packages/taler-util/src/merchant-api-types.ts | 32 | ||||
-rw-r--r-- | packages/taler-util/src/taler-types.ts | 67 |
2 files changed, 92 insertions, 7 deletions
diff --git a/packages/taler-util/src/merchant-api-types.ts b/packages/taler-util/src/merchant-api-types.ts index 61002191a..d7a5cf576 100644 --- a/packages/taler-util/src/merchant-api-types.ts +++ b/packages/taler-util/src/merchant-api-types.ts @@ -44,6 +44,9 @@ import { TalerProtocolDuration, codecForTimestamp, TalerProtocolTimestamp, + WireAccount, + codecForWireAccount, + codecForList, } from "@gnu-taler/taler-util"; export interface MerchantPostOrderRequest { @@ -75,11 +78,12 @@ export interface MerchantPostOrderResponse { token?: ClaimToken; } -export const codecForMerchantPostOrderResponse = (): Codec<MerchantPostOrderResponse> => - buildCodecForObject<MerchantPostOrderResponse>() - .property("order_id", codecForString()) - .property("token", codecOptional(codecForString())) - .build("PostOrderResponse"); +export const codecForMerchantPostOrderResponse = + (): Codec<MerchantPostOrderResponse> => + buildCodecForObject<MerchantPostOrderResponse>() + .property("order_id", codecForString()) + .property("token", codecOptional(codecForString())) + .build("PostOrderResponse"); export const codecForMerchantRefundDetails = (): Codec<RefundDetails> => buildCodecForObject<RefundDetails>() @@ -351,7 +355,6 @@ export interface MerchantTemplateContractDetails { } export interface MerchantTemplateAddDetails { - // Template ID to use. template_id: string; @@ -365,4 +368,19 @@ export interface MerchantTemplateAddDetails { // Additional information in a separate template. template_contract: MerchantTemplateContractDetails; -}
\ No newline at end of file +} + +export interface MerchantReserveCreateConfirmation { + // Public key identifying the reserve. + reserve_pub: EddsaPublicKeyString; + + // Wire accounts of the exchange where to transfer the funds. + accounts: WireAccount[]; +} + +export const codecForMerchantReserveCreateConfirmation = + (): Codec<MerchantReserveCreateConfirmation> => + buildCodecForObject<MerchantReserveCreateConfirmation>() + .property("accounts", codecForList(codecForWireAccount())) + .property("reserve_pub", codecForString()) + .build("MerchantReserveCreateConfirmation"); diff --git a/packages/taler-util/src/taler-types.ts b/packages/taler-util/src/taler-types.ts index 56184a598..570e64d7c 100644 --- a/packages/taler-util/src/taler-types.ts +++ b/packages/taler-util/src/taler-types.ts @@ -2165,3 +2165,70 @@ export const codecForExchangeRefundSuccessResponse = .property("exchange_pub", codecForString()) .property("exchange_sig", codecForString()) .build("ExchangeRefundSuccessResponse"); + +export type AccountRestriction = + | RegexAccountRestriction + | DenyAllAccountRestriction; + +export interface DenyAllAccountRestriction { + type: "deny"; +} + +// Accounts interacting with this type of account +// restriction must have a payto://-URI matching +// the given regex. +export interface RegexAccountRestriction { + type: "regex"; + + // Regular expression that the payto://-URI of the + // partner account must follow. The regular expression + // should follow posix-egrep, but without support for character + // classes, GNU extensions, back-references or intervals. See + // https://www.gnu.org/software/findutils/manual/html_node/find_html/posix_002degrep-regular-expression-syntax.html + // for a description of the posix-egrep syntax. Applications + // may support regexes with additional features, but exchanges + // must not use such regexes. + payto_regex: string; + + // Hint for a human to understand the restriction + // (that is hopefully easier to comprehend than the regex itself). + human_hint: string; + + // Map from IETF BCP 47 language tags to localized + // human hints. + human_hint_i18n?: InternationalizedString; +} + +export interface WireAccount { + // payto:// URI identifying the account and wire method + payto_uri: string; + + // URI to convert amounts from or to the currency used by + // this wire account of the exchange. Missing if no + // conversion is applicable. + conversion_url?: string; + + // Restrictions that apply to bank accounts that would send + // funds to the exchange (crediting this exchange bank account). + // Optional, empty array for unrestricted. + credit_restrictions: AccountRestriction[]; + + // Restrictions that apply to bank accounts that would receive + // funds from the exchange (debiting this exchange bank account). + // Optional, empty array for unrestricted. + debit_restrictions: AccountRestriction[]; + + // Signature using the exchange's offline key over + // a TALER_MasterWireDetailsPS + // with purpose TALER_SIGNATURE_MASTER_WIRE_DETAILS. + master_sig: EddsaSignatureString; +} + +export const codecForWireAccount = (): Codec<WireAccount> => + buildCodecForObject<WireAccount>() + .property("conversion_url", codecOptional(codecForString())) + .property("credit_restrictions", codecForList(codecForAny())) + .property("debit_restrictions", codecForList(codecForAny())) + .property("master_sig", codecForString()) + .property("payto_uri", codecForString()) + .build("WireAccount"); |