refactor: more logs

This commit is contained in:
cogwheel0
2025-09-25 23:22:48 +05:30
parent 9210b2155a
commit 3124bccfeb
20 changed files with 937 additions and 846 deletions

View File

@@ -2,11 +2,6 @@ import 'dart:convert';
import 'package:crypto/crypto.dart';
import '../utils/debug_logger.dart';
void debugPrint(String? message, {int? wrapWidth}) {
if (message == null) return;
DebugLogger.fromLegacy(message, scope: 'auth/token-validator');
}
/// JWT token validation utilities
class TokenValidator {
static const Duration _validationTimeout = Duration(seconds: 5);
@@ -68,8 +63,10 @@ class TokenValidator {
);
} catch (e) {
// If we can't decode JWT, treat as opaque token
debugPrint(
'DEBUG: Could not decode JWT payload, treating as opaque token: $e',
DebugLogger.warning(
'jwt-decode-failed',
scope: 'auth/token-validator',
data: {'error': e.toString()},
);
return TokenValidationResult.valid('Opaque token format valid');
}
@@ -153,7 +150,11 @@ class TokenValidator {
'iat': payload['iat'], // Issued at
};
} catch (e) {
debugPrint('DEBUG: Could not extract user info from token: $e');
DebugLogger.warning(
'token-user-info-failed',
scope: 'auth/token-validator',
data: {'error': e.toString()},
);
return null;
}
}