This SDK documentation is outdated. Please do not refer to it, and instead visit the User Guides section.

Skip to main content
Version: 0.15.X

Functions

interface RecipeInterface {
/*
* Calling during init, this function is supposed to add fetch interceptors that
* add and save session tokens to the request.
*
* @params: originalFetch this is to be used in your interceptor
* config is the config provided by the user when calling the init function of this recipe
*
* @returns: a modified fetch function
*/
addFetchInterceptorsAndReturnModifiedFetch: (originalFetch: any, config: NormalisedInputType) => typeof fetch;

/*
* Called by the user. This is supposed to add interceptor functions to axios that
* add and save session tokens to the request.
*
* @params: axiosInstance is the instance to add the interceptor functions to.
* config is the config provided by the user when calling the init function of this recipe
*
* @returns: void
*/
addAxiosInterceptors: (axiosInstance: any, config: NormalisedInputType) => void;

/*
* If a session exists, return the userId of the user who is logged in, else throw an error
*
* @params: config is the config provided by the user when calling the init function of this recipe
*
* @returns: the userId (string)
*/
getUserId: (config: NormalisedInputType) => Promise<string>;

/*
* If a session exists, return the JWT payload (if applicable), else throw an error
*
* @params: config is the config provided by the user when calling the init function of this recipe
*
* @returns: the JWT payload in a JS object form.
*/
getJWTPayloadSecurely: (config: NormalisedInputType) => Promise<any>;

/*
* Is called to know if a session exists or not
*
* @params: config is the config provided by the user when calling the init function of this recipe
*
* @returns: true if a session exists, else false
*/
doesSessionExist: (config: NormalisedInputType) => Promise<boolean>;

/*
* Called when the user clicks the sign out button. This function should
* clear the session and logout the user. In case of a 401, it should treat
* it as success. The user should not be navigated by this function.
*
* @params: config is the config provided by the user when calling the init function of this recipe
*
* @returns: void
*/
signOut: (config: NormalisedInputType) => Promise<void>;
}
Looking for older versions of the documentation?
Which UI do you use?
Custom UI
Pre built UI