summaryrefslogtreecommitdiff
path: root/packages/taler-wallet-core/src/util/http.ts
diff options
context:
space:
mode:
authorFlorian Dold <florian@dold.me>2022-03-18 15:32:41 +0100
committerFlorian Dold <florian@dold.me>2022-03-21 19:20:48 +0100
commitf8d12f7b0d4af1b1769b89e80c87f9c169678564 (patch)
tree2478696c7bc1efc6d090b93aa340de542a7dccd9 /packages/taler-wallet-core/src/util/http.ts
parent32cd54e11d80bde0274b3c0238f8f5bd00ff83cb (diff)
downloadwallet-core-f8d12f7b0d4af1b1769b89e80c87f9c169678564.tar.gz
wallet-core-f8d12f7b0d4af1b1769b89e80c87f9c169678564.tar.bz2
wallet-core-f8d12f7b0d4af1b1769b89e80c87f9c169678564.zip
wallet: t_s/d_us migration
Diffstat (limited to 'packages/taler-wallet-core/src/util/http.ts')
-rw-r--r--packages/taler-wallet-core/src/util/http.ts17
1 files changed, 7 insertions, 10 deletions
diff --git a/packages/taler-wallet-core/src/util/http.ts b/packages/taler-wallet-core/src/util/http.ts
index 43fe29bba..79afd5707 100644
--- a/packages/taler-wallet-core/src/util/http.ts
+++ b/packages/taler-wallet-core/src/util/http.ts
@@ -28,10 +28,7 @@ import { OperationFailedError, makeErrorDetails } from "../errors.js";
import {
Logger,
Duration,
- Timestamp,
- getTimestampNow,
- timestampAddDuration,
- timestampMax,
+ AbsoluteTime,
TalerErrorDetails,
Codec,
j2s,
@@ -314,24 +311,24 @@ export async function readSuccessResponseTextOrThrow<T>(
/**
* Get the timestamp at which the response's content is considered expired.
*/
-export function getExpiryTimestamp(
+export function getExpiry(
httpResponse: HttpResponse,
opt: { minDuration?: Duration },
-): Timestamp {
+): AbsoluteTime {
const expiryDateMs = new Date(
httpResponse.headers.get("expiry") ?? "",
).getTime();
- let t: Timestamp;
+ let t: AbsoluteTime;
if (Number.isNaN(expiryDateMs)) {
- t = getTimestampNow();
+ t = AbsoluteTime.now();
} else {
t = {
t_ms: expiryDateMs,
};
}
if (opt.minDuration) {
- const t2 = timestampAddDuration(getTimestampNow(), opt.minDuration);
- return timestampMax(t, t2);
+ const t2 = AbsoluteTime.addDuration(AbsoluteTime.now(), opt.minDuration);
+ return AbsoluteTime.max(t, t2);
}
return t;
}