commit 82e591c3d1444cd548d4dee82c4b55f9b51465f1
parent 67d4d19931a9db81cc015829d77aec6d27fc3940
Author: Florian Dold <dold@taler.net>
Date: Wed, 22 Jul 2026 10:49:39 +0200
wallet: check that a token covers the requested validity interval
The containment test was the wrong way round and asked whether the interval
covers the token instead. The vestigial fallback for the start of the
interval is gone, the parameter is not optional.
Diffstat:
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/packages/taler-wallet-core/src/tokenSelection.ts b/packages/taler-wallet-core/src/tokenSelection.ts
@@ -355,6 +355,10 @@ export function isTokenValid(tok: WalletToken): boolean {
);
}
+/**
+ * Check whether a token is valid for the whole interval `[start,end]`, i.e.
+ * whether its validity window contains that interval.
+ */
export function isTokenValidBetween(
tok: WalletToken,
start: TalerProtocolTimestamp,
@@ -362,16 +366,16 @@ export function isTokenValidBetween(
): boolean {
return (
AbsoluteTime.cmp(
- AbsoluteTime.fromProtocolTimestamp(start ?? TalerProtocolTimestamp.now()),
AbsoluteTime.fromProtocolTimestamp(
tok.tokenIssuePub.signature_validity_start,
),
+ AbsoluteTime.fromProtocolTimestamp(start),
) <= 0 &&
AbsoluteTime.cmp(
- AbsoluteTime.fromProtocolTimestamp(end),
AbsoluteTime.fromProtocolTimestamp(
tok.tokenIssuePub.signature_validity_end,
),
+ AbsoluteTime.fromProtocolTimestamp(end),
) >= 0
);
}