Skip to content

Commit

Permalink
fix: log sensitive data at level finer
Browse files Browse the repository at this point in the history
  • Loading branch information
Vinzent03 committed Oct 3, 2024
1 parent df07430 commit 8d5ce7e
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 8 deletions.
4 changes: 3 additions & 1 deletion packages/gotrue/lib/src/broadcast_web.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import 'package:gotrue/src/types/types.dart';
import 'package:logging/logging.dart';

final _log = Logger('supabase.gotrue');

BroadcastChannel getBroadcastChannel(String broadcastKey) {
final broadcast = html.BroadcastChannel(broadcastKey);
return (
Expand All @@ -17,7 +18,8 @@ BroadcastChannel getBroadcastChannel(String broadcastKey) {
return json.decode(json.encode(dataMap));
}),
postMessage: (message) {
_log.fine('Broadcasting message: $message');
_log.finer('Broadcasting message: $message');
_log.fine('Broadcasting event: ${message['event']}');
final jsMessage = js_util.jsify(message);
broadcast.postMessage(jsMessage);
},
Expand Down
8 changes: 5 additions & 3 deletions packages/gotrue/lib/src/gotrue_client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1147,13 +1147,14 @@ class GoTrueClient {

/// set currentSession and currentUser
void _saveSession(Session session) {
_log.fine('Save session: $session');
_log.finer('Saving session: $session');
_log.fine('Saving session');
_currentSession = session;
_currentUser = session.user;
}

void _removeSession() {
_log.fine('Remove session');
_log.fine('Removing session');
_currentSession = null;
_currentUser = null;
}
Expand All @@ -1170,8 +1171,9 @@ class GoTrueClient {
_broadcastChannel = web.getBroadcastChannel(broadcastKey);
_broadcastChannelSubscription =
_broadcastChannel?.onMessage.listen((messageEvent) {
_log.info('Received broadcast message: $messageEvent');
final rawEvent = messageEvent['event'];
_log.finer('Received broadcast message: $messageEvent');
_log.info('Received broadcast event: $rawEvent');
final event = switch (rawEvent) {
// This library sends the js name of the event to be comptabile with
// the js library, so we need to convert it back to the dart name
Expand Down
4 changes: 2 additions & 2 deletions packages/postgrest/lib/src/postgrest.dart
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class PostgrestClient {
}

PostgrestClient setAuth(String? token) {
_log.fine("setAuth with: $token");
_log.finer("setAuth with: $token");
if (token != null) {
headers['Authorization'] = 'Bearer $token';
} else {
Expand Down Expand Up @@ -98,7 +98,7 @@ class PostgrestClient {
}

Future<void> dispose() async {
_log.fine("dispose client");
_log.fine("dispose PostgrestClient");
if (!_hasCustomIsolate) {
return _isolate.dispose();
}
Expand Down
5 changes: 3 additions & 2 deletions packages/postgrest/lib/src/postgrest_builder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ class PostgrestBuilder<T, S, R> implements Future<T> {
message: 'JSON object requested, multiple (or no) rows returned',
);

_log.fine('$exception for request $_url');
_log.finer('$exception for request $_url');
throw exception;
} else if (body.length == 1) {
body = body.first;
Expand Down Expand Up @@ -293,7 +293,8 @@ class PostgrestBuilder<T, S, R> implements Future<T> {
);
}

_log.fine('$error for request $_url');
_log.finer('$error from request: $_url');
_log.fine('$error from request');

throw error;
}
Expand Down

0 comments on commit 8d5ce7e

Please sign in to comment.