init static method
void
init(- {required String apiDomain,
- String? apiBasePath,
- int? maxRetryAttemptsForSessionRefresh,
- int sessionExpiredStatusCode = 401,
- String? sessionTokenBackendDomain,
- SuperTokensTokenTransferMethod? tokenTransferMethod,
- dynamic eventHandler(
- Eventype
)?,
- dynamic preAPIHook(
- APIAction,
- dynamic
)?,
- dynamic postAPIHook(
- APIAction,
- dynamic,
- dynamic
)?,
- bool? enableDebugLogs}
)
Implementation
static void init({
required String apiDomain,
String? apiBasePath,
int? maxRetryAttemptsForSessionRefresh,
int sessionExpiredStatusCode = 401,
String? sessionTokenBackendDomain,
SuperTokensTokenTransferMethod? tokenTransferMethod,
Function(Eventype)? eventHandler,
http.Request Function(APIAction, http.Request)? preAPIHook,
Function(APIAction, http.Request, http.Response)? postAPIHook,
bool? enableDebugLogs,
}) {
if (SuperTokens.isInitCalled) {
return;
}
// Enable debug mode if that is specified by the user.
if (enableDebugLogs != null && enableDebugLogs) {
enableLogging();
}
logDebugMessage("SuperTokens.init: Started SuperTokens with debug logging (supertokens.init called)");
SuperTokens.config = NormalisedInputType.normaliseInputType(
apiDomain,
apiBasePath,
sessionExpiredStatusCode,
maxRetryAttemptsForSessionRefresh,
sessionTokenBackendDomain,
tokenTransferMethod,
eventHandler,
preAPIHook,
postAPIHook,
);
logDebugMessage('SuperTokens.init: config: ${jsonEncode(config.toJson())}');
SuperTokens.refreshTokenUrl =
config.apiDomain + (config.apiBasePath ?? '') + "/session/refresh";
SuperTokens.signOutUrl =
config.apiDomain + (config.apiBasePath ?? '') + "/signout";
SuperTokens.rid = "session";
logDebugMessage('SuperTokens.init: refreshTokenUrl: ${refreshTokenUrl}');
logDebugMessage('SuperTokens.init: signOutUrl: ${signOutUrl}');
logDebugMessage('SuperTokens.init: rid: ${rid}');
SuperTokens.isInitCalled = true;
}