mirror of
https://github.com/zarzet/SpotiFLAC-Mobile.git
synced 2026-09-13 21:38:58 +02:00
fix(extensions): shorten verification timeout
This commit is contained in:
@@ -70,7 +70,7 @@ type PendingAuthRequest struct {
|
||||
|
||||
// Challenge URLs are short-lived; serving one past this age sends the user
|
||||
// to an already-expired verification page.
|
||||
const pendingAuthRequestTTL = 5 * time.Minute
|
||||
const pendingAuthRequestTTL = 3 * time.Minute
|
||||
|
||||
var (
|
||||
pendingAuthRequests = make(map[string]*PendingAuthRequest)
|
||||
|
||||
@@ -15,6 +15,12 @@ import (
|
||||
"github.com/dop251/goja"
|
||||
)
|
||||
|
||||
func TestPendingAuthRequestExpiresAfterThreeMinutes(t *testing.T) {
|
||||
if pendingAuthRequestTTL != 3*time.Minute {
|
||||
t.Fatalf("pending auth request TTL = %v", pendingAuthRequestTTL)
|
||||
}
|
||||
}
|
||||
|
||||
func TestExtensionRuntimeAuthAndPolyfills(t *testing.T) {
|
||||
vm := goja.New()
|
||||
runtime := &extensionRuntime{
|
||||
|
||||
@@ -12,6 +12,8 @@ import 'package:url_launcher/url_launcher.dart';
|
||||
|
||||
final _log = AppLogger('ExtensionAuthLauncher');
|
||||
|
||||
const extensionVerificationGrantTimeout = Duration(minutes: 3);
|
||||
|
||||
bool isExtensionVerificationRequired(Object error) {
|
||||
final message = error.toString().toLowerCase();
|
||||
return message.contains('verify_required') ||
|
||||
@@ -160,7 +162,7 @@ Timer? scheduleExtensionVerificationHelpDialog(
|
||||
});
|
||||
}
|
||||
|
||||
/// Opens a pending extension verification challenge and waits (up to 5
|
||||
/// Opens a pending extension verification challenge and waits (up to 3
|
||||
/// minutes) for its grant result, returning whether it succeeded. When
|
||||
/// [cancellationSignal] completes, all local waiting resources are released
|
||||
/// and the method returns false without waiting for the timeout.
|
||||
@@ -220,7 +222,7 @@ Future<bool> openVerificationAndAwaitGrant(
|
||||
final event = await _awaitVerificationStepOrCancellation(
|
||||
grantCompleter.future,
|
||||
cancellationSignal,
|
||||
).timeout(const Duration(minutes: 5));
|
||||
).timeout(extensionVerificationGrantTimeout);
|
||||
if (event == null) {
|
||||
_log.i('Stopped waiting for verification grant: $normalizedExtensionId');
|
||||
return false;
|
||||
|
||||
@@ -4,6 +4,10 @@ import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:spotiflac_android/utils/extension_auth_launcher.dart';
|
||||
|
||||
void main() {
|
||||
test('verification challenge expires after three minutes', () {
|
||||
expect(extensionVerificationGrantTimeout, const Duration(minutes: 3));
|
||||
});
|
||||
|
||||
test('extracts the extension that raised a verification challenge', () {
|
||||
expect(
|
||||
extensionIdFromVerificationError(
|
||||
|
||||
Reference in New Issue
Block a user