mirror of
https://github.com/Yubico/yubioath-flutter.git
synced 2024-12-23 18:22:39 +03:00
Desktop: Add 10s to time for manually calculated codes.
This ensures the newly calculated code doesn't immediately expire when manually triggering calculate (for require touch).
This commit is contained in:
parent
5c7f4ba826
commit
715229c5ac
@ -240,6 +240,11 @@ class _DesktopCredentialListNotifier extends OathCredentialListNotifier {
|
||||
@override
|
||||
Future<OathCode> calculate(OathCredential credential,
|
||||
{bool update = true}) async {
|
||||
var now = DateTime.now().millisecondsSinceEpoch ~/ 1000;
|
||||
if (update) {
|
||||
// Manually triggered, need to pad timer to avoid immediate expiration
|
||||
now += 10;
|
||||
}
|
||||
final OathCode code;
|
||||
final signaler = Signaler();
|
||||
UserInteractionController? controller;
|
||||
@ -256,7 +261,7 @@ class _DesktopCredentialListNotifier extends OathCredentialListNotifier {
|
||||
}
|
||||
});
|
||||
if (credential.isSteam) {
|
||||
final timeStep = DateTime.now().millisecondsSinceEpoch ~/ 30000;
|
||||
final timeStep = now ~/ 30;
|
||||
var result = await _session.command('calculate',
|
||||
target: ['accounts', credential.id],
|
||||
params: {
|
||||
@ -266,8 +271,12 @@ class _DesktopCredentialListNotifier extends OathCredentialListNotifier {
|
||||
code = OathCode(_formatSteam(result['response']), timeStep * 30,
|
||||
(timeStep + 1) * 30);
|
||||
} else {
|
||||
var result = await _session.command('code',
|
||||
target: ['accounts', credential.id], signal: signaler);
|
||||
var result = await _session.command(
|
||||
'code',
|
||||
target: ['accounts', credential.id],
|
||||
params: {'timestamp': now},
|
||||
signal: signaler,
|
||||
);
|
||||
code = OathCode.fromJson(result);
|
||||
}
|
||||
_log.debug('Calculate', jsonEncode(code));
|
||||
|
Loading…
Reference in New Issue
Block a user