init static method

void init(
  1. {required String apiDomain,
  2. String? apiBasePath,
  3. int sessionExpiredStatusCode = 401,
  4. String? sessionTokenBackendDomain,
  5. SuperTokensTokenTransferMethod? tokenTransferMethod,
  6. dynamic eventHandler(
    1. Eventype
    )?,
  7. dynamic preAPIHook(
    1. APIAction,
    2. dynamic
    )?,
  8. dynamic postAPIHook(
    1. APIAction,
    2. dynamic,
    3. dynamic
    )?}
)

Implementation

static void init({
  required String apiDomain,
  String? apiBasePath,
  int sessionExpiredStatusCode = 401,
  String? sessionTokenBackendDomain,
  SuperTokensTokenTransferMethod? tokenTransferMethod,
  Function(Eventype)? eventHandler,
  http.Request Function(APIAction, http.Request)? preAPIHook,
  Function(APIAction, http.Request, http.Response)? postAPIHook,
}) {
  if (SuperTokens.isInitCalled) {
    return;
  }

  SuperTokens.config = NormalisedInputType.normaliseInputType(
    apiDomain,
    apiBasePath,
    sessionExpiredStatusCode,
    sessionTokenBackendDomain,
    tokenTransferMethod,
    eventHandler,
    preAPIHook,
    postAPIHook,
  );

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