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/taler-types.ts | |
parent | 990b056071fd0b3879d4366ff3dd625aa3265738 (diff) | |
download | wallet-core-9a412260f3b0a53b1508e2db8724a0c58ce080cf.tar.xz |
adapt to merchant API breaking changes
Diffstat (limited to 'packages/taler-util/src/taler-types.ts')
-rw-r--r-- | packages/taler-util/src/taler-types.ts | 67 |
1 files changed, 67 insertions, 0 deletions
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"); |