diff options
Diffstat (limited to 'packages')
-rw-r--r-- | packages/taler-util/src/wallet-types.ts | 5 | ||||
-rw-r--r-- | packages/taler-wallet-core/src/operations/exchanges.ts | 59 |
2 files changed, 38 insertions, 26 deletions
diff --git a/packages/taler-util/src/wallet-types.ts b/packages/taler-util/src/wallet-types.ts index 52a272cfa..b54ee8c0a 100644 --- a/packages/taler-util/src/wallet-types.ts +++ b/packages/taler-util/src/wallet-types.ts @@ -1583,6 +1583,11 @@ export interface GetExchangeTosResult { */ contentLanguage: string | undefined; + /** + * Available languages as advertised by the exchange. + */ + tosAvailableLanguages: string[]; + tosStatus: ExchangeTosStatus; } diff --git a/packages/taler-wallet-core/src/operations/exchanges.ts b/packages/taler-wallet-core/src/operations/exchanges.ts index 6afafd9f5..88127b71f 100644 --- a/packages/taler-wallet-core/src/operations/exchanges.ts +++ b/packages/taler-wallet-core/src/operations/exchanges.ts @@ -27,27 +27,24 @@ import { AbsoluteTime, Amounts, CancellationToken, - canonicalizeBaseUrl, - codecForExchangeKeysJson, - DenominationPubKey, DenomKeyType, + DenomOperationMap, + DenominationInfo, + DenominationPubKey, Duration, - durationFromSpec, - encodeCrock, ExchangeAuditor, + ExchangeDetailedResponse, ExchangeGlobalFees, + ExchangeListItem, ExchangeSignKeyJson, - ExchangeEntryState, ExchangeWireAccount, + ExchangesListResponse, + FeeDescription, GetExchangeTosResult, GlobalFees, - hashDenomPub, - j2s, LibtoolVersion, Logger, - makeErrorDetail, NotificationType, - parsePaytoUri, Recoup, TalerError, TalerErrorCode, @@ -61,16 +58,18 @@ import { WireFeeMap, WireFeesJson, WireInfo, - FeeDescription, - DenomOperationMap, - DenominationInfo, - ExchangeDetailedResponse, - ExchangeListItem, - ExchangesListResponse, + canonicalizeBaseUrl, + codecForExchangeKeysJson, + durationFromSpec, + encodeCrock, + hashDenomPub, + j2s, + makeErrorDetail, + parsePaytoUri, } from "@gnu-taler/taler-util"; import { - getExpiry, HttpRequestLibrary, + getExpiry, readSuccessResponseJsonOrThrow, readSuccessResponseTextOrThrow, } from "@gnu-taler/taler-util/http"; @@ -82,32 +81,30 @@ import { WalletStoresV1, } from "../db.js"; import { - createTimeline, ExchangeEntryDbRecordStatus, ExchangeEntryDbUpdateStatus, - isWithdrawableDenom, OpenedPromise, + WalletDbReadWriteTransaction, + createTimeline, + isWithdrawableDenom, openPromise, selectBestForOverlappingDenominations, selectMinimumFee, timestampPreciseFromDb, timestampPreciseToDb, timestampProtocolToDb, - WalletDbReadWriteTransaction, } from "../index.js"; import { CancelFn, InternalWalletState } from "../internal-wallet-state.js"; import { checkDbInvariant } from "../util/invariants.js"; import { GetReadOnlyAccess, GetReadWriteAccess } from "../util/query.js"; import { WALLET_EXCHANGE_PROTOCOL_VERSION } from "../versions.js"; import { - getExchangeEntryStatusFromRecord, - getExchangeState, - getExchangeTosStatusFromRecord, - getExchangeUpdateStatusFromRecord, - makeExchangeListItem, TaskIdentifiers, TaskRunResult, TaskRunResultType, + getExchangeState, + getExchangeTosStatusFromRecord, + makeExchangeListItem, } from "./common.js"; const logger = new Logger("exchanges.ts"); @@ -123,6 +120,7 @@ interface ExchangeTosDownloadResult { tosEtag: string; tosContentType: string; tosContentLanguage: string | undefined; + tosAvailableLanguages: string[]; } async function downloadExchangeWithTermsOfService( @@ -153,8 +151,16 @@ async function downloadExchangeWithTermsOfService( const tosEtag = resp.headers.get("etag") || "unknown"; const tosContentLanguage = resp.headers.get("content-language") || undefined; const tosContentType = resp.headers.get("content-type") || "text/plain"; + const availLangStr = resp.headers.get("avail-languages") || ""; + const tosAvailableLanguages = availLangStr.split(",").map((x) => x.trim()); - return { tosText, tosEtag, tosContentType, tosContentLanguage }; + return { + tosText, + tosEtag, + tosContentType, + tosContentLanguage, + tosAvailableLanguages, + }; } /** @@ -1190,6 +1196,7 @@ export async function getExchangeTos( contentType: tosDownload.tosContentType, contentLanguage: tosDownload.tosContentLanguage, tosStatus: getExchangeTosStatusFromRecord(exchange), + tosAvailableLanguages: tosDownload.tosAvailableLanguages, }; } |