Skip to content

Commit

Permalink
Add logs for config in init method
Browse files Browse the repository at this point in the history
  • Loading branch information
deepjyoti30-st committed Sep 26, 2024
1 parent b939861 commit 8e3f253
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
16 changes: 16 additions & 0 deletions lib/src/supertokens.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import 'package:supertokens_flutter/src/front-token.dart';
import 'package:supertokens_flutter/src/utilities.dart';
import 'package:http/http.dart' as http;
import 'package:supertokens_flutter/src/supertokens-http-client.dart';
import 'package:supertokens_flutter/src/logger.dart';

enum Eventype {
SIGN_OUT,
Expand Down Expand Up @@ -48,11 +49,19 @@ class SuperTokens {
Function(Eventype)? eventHandler,
http.Request Function(APIAction, http.Request)? preAPIHook,
Function(APIAction, http.Request, http.Response)? postAPIHook,
debug? bool,
}) {
if (SuperTokens.isInitCalled) {
return;
}

// Enable debug mode if that is specified by the user.
if (debug) {
enableLogging()
}

logDebugMessage("Started SuperTokens with debug logging (supertokens.init called)");

SuperTokens.config = NormalisedInputType.normaliseInputType(
apiDomain,
apiBasePath,
Expand All @@ -65,11 +74,18 @@ class SuperTokens {
postAPIHook,
);

logDebugMessage('config: ${jsonEncode(config.toJson())}');

SuperTokens.refreshTokenUrl =
config.apiDomain + (config.apiBasePath ?? '') + "/session/refresh";
SuperTokens.signOutUrl =
config.apiDomain + (config.apiBasePath ?? '') + "/signout";
SuperTokens.rid = "session";

logDebugMessage('refreshTokenUrl: ${refreshTokenUrl}')
logDebugMessage('signOutUrl: ${signOutUrl}')
logDebugMessage('rid: ${rid}')

SuperTokens.isInitCalled = true;
}

Expand Down
12 changes: 12 additions & 0 deletions lib/src/utilities.dart
Original file line number Diff line number Diff line change
Expand Up @@ -456,4 +456,16 @@ class NormalisedInputType {
throw SuperTokensException("Please provide a valid SessionScope");
}
}

Map<String, dynamic> toJson() {
return {
'apiDomain': apiDomain,
'apiBasePath': apiBasePath,
'sessionExpiredStatusCode': sessionExpiredStatusCode,
'maxRetryAttemptsForSessionRefresh': maxRetryAttemptsForSessionRefresh,
'sessionTokenBackendDomain': sessionTokenBackendDomain,
'tokenTransferMethod': tokenTransferMethod.getValue(),
'userDefaultSuiteName': userDefaultSuiteName,
};
}
}

0 comments on commit 8e3f253

Please sign in to comment.