diff options
author | Sebastian <sebasjm@gmail.com> | 2021-09-13 15:32:06 -0300 |
---|---|---|
committer | Sebastian <sebasjm@gmail.com> | 2021-09-13 15:32:15 -0300 |
commit | 9f009873809d5b7e8d1d95d77f009862724c577b (patch) | |
tree | cd424abc49b290c684f9947daa759a9a6fb28150 /packages/taler-wallet-core/src/operations/exchanges.ts | |
parent | 57b6cd42692584063819ccac3c2218f1283332a4 (diff) | |
download | wallet-core-9f009873809d5b7e8d1d95d77f009862724c577b.tar.xz |
added integration with the wallet-core to get info about the last tos approved
Diffstat (limited to 'packages/taler-wallet-core/src/operations/exchanges.ts')
-rw-r--r-- | packages/taler-wallet-core/src/operations/exchanges.ts | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/packages/taler-wallet-core/src/operations/exchanges.ts b/packages/taler-wallet-core/src/operations/exchanges.ts index cf52e00b6..9cd20c673 100644 --- a/packages/taler-wallet-core/src/operations/exchanges.ts +++ b/packages/taler-wallet-core/src/operations/exchanges.ts @@ -127,20 +127,22 @@ function getExchangeRequestTimeout(e: ExchangeRecord): Duration { return { d_ms: 5000 }; } -interface ExchangeTosDownloadResult { +export interface ExchangeTosDownloadResult { tosText: string; tosEtag: string; + tosContentType: string; } -async function downloadExchangeWithTermsOfService( +export async function downloadExchangeWithTermsOfService( exchangeBaseUrl: string, http: HttpRequestLibrary, timeout: Duration, + contentType: string, ): Promise<ExchangeTosDownloadResult> { const reqUrl = new URL("terms", exchangeBaseUrl); reqUrl.searchParams.set("cacheBreaker", WALLET_CACHE_BREAKER_CLIENT_VERSION); const headers = { - Accept: "text/plain", + Accept: contentType, }; const resp = await http.get(reqUrl.href, { @@ -149,8 +151,9 @@ async function downloadExchangeWithTermsOfService( }); const tosText = await readSuccessResponseTextOrThrow(resp); const tosEtag = resp.headers.get("etag") || "unknown"; + const tosContentType = resp.headers.get("content-type") || "text/plain"; - return { tosText, tosEtag }; + return { tosText, tosEtag, tosContentType }; } /** @@ -469,6 +472,7 @@ async function updateExchangeFromUrlImpl( baseUrl, ws.http, timeout, + "text/plain" ); let recoupGroupId: string | undefined = undefined; @@ -506,6 +510,7 @@ async function updateExchangeFromUrlImpl( wireInfo, termsOfServiceText: tosDownload.tosText, termsOfServiceAcceptedEtag: undefined, + termsOfServiceContentType: tosDownload.tosContentType, termsOfServiceLastEtag: tosDownload.tosEtag, termsOfServiceAcceptedTimestamp: getTimestampNow(), }; |