Module

useAuth

Members

# inner constant ACTIONS

Define the actions that can be dispatched These represent the different state changes that the auth state can be in

View Source hooks/useAuth.js, line 34

# inner constant authContext

This is the context that will be used to provide the auth state to its consumers

View Source hooks/useAuth.js, line 88

# inner constant initialState

Define the initial state of the auth state

View Source hooks/useAuth.js, line 72

# inner constant STALE_CHECK_STATES

Define the states that the stale check can be in

View Source hooks/useAuth.js, line 53

# inner constant VALID_LOGIN_STATES

Valid states that allow logins to occur If the auth state is not in this list, we will not allow logins This will, for example, not allow someone to attempt to log in while already logged in

View Source hooks/useAuth.js, line 64

Methods

# inner authReducer(nextState, action) → {object}

Reducer hook method for the auth state
Parameters:
Name Type Description
nextState *
action *

View Source hooks/useAuth.js, line 700

object

# inner clearRefreshTokenInSession()

This function will clear the refresh token from session storage

View Source hooks/useAuth.js, line 976

# async inner clearSubjectCookie()

This will clear the subject cookie

View Source hooks/useAuth.js, line 987

# inner deprecated(event)

This function handles messages posted to the window We expect the message to come from the same origin We then make sure that the event type is 'oauth-token'
Parameters:
Name Type Description
event * the event that was posted to the window from the oAuth tab

View Source hooks/useAuth.js, line 600

# inner getActiveBearerToken() → {String}

Get the active bearer token

View Source hooks/useAuth.js, line 680

the active bearer token
String

# async inner getBootTokenFromSession() → {String}

This function will attempt to get the boot token from session storage When we authenticate, if we are given a refresh token, we will store it in session storage This way we can use it to get a new access token when the page is reloaded or the user navigates to a new page

View Source hooks/useAuth.js, line 875

the boot token
String

# async inner getBootUserFromSession()

This function will attempt to get the bootUser from session storage When we authenticate, if we are given a refresh token, we will store it in session storage This way we can use it to get a new access token when the page is reloaded or the user navigates to a new page

View Source hooks/useAuth.js, line 894

# async inner getRefreshTokenFromSession() → {String}

This function will attempt to get the refresh token from session storage When we authenticate, if we are given a refresh token, we will store it in session storage This way we can use it to get a new access token when the page is reloaded or the user navigates to a new page

View Source hooks/useAuth.js, line 827

the refresh token
String

# async inner getSubjectFromCookie() → {String}

This will attempt to get the subject from the cookie

View Source hooks/useAuth.js, line 844

the subject
String

# inner isValidConfig(config) → {boolean}

Checks to see if the config object is valid
Parameters:
Name Type Description
config object

View Source hooks/useAuth.js, line 916

true if the all the required bits of config are present
boolean

# inner ProvideAuth(props) → {React.Context}

Wrap the hook with a provider Use cookieReference to differentiate between multiple apps using the same cookie *
Parameters:
Name Type Attributes Description
props object The props for the component
config object The config object
config.cookieReference string <optional>
The cookie reference
whitelist array <optional>
The whitelist array
options object <optional>
Additional options
options.staleCheckSeconds number <optional>
The stale check seconds
children object <optional>
The children

View Source hooks/useAuth.js, line 101

The auth context provider
React.Context

# inner setActiveBearerToken(bearerToken)

set the active bearer token
Parameters:
Name Type Description
bearerToken string

View Source hooks/useAuth.js, line 689

# inner setRefreshTokenInSession(refreshToken)

This function will store the refresh token in session storage Later on we can retrieve it and use it to get a new access token
Parameters:
Name Type Description
refreshToken String

View Source hooks/useAuth.js, line 935

# inner setSubjectInCookie(subject)

This function will set the subject in the cookie
Parameters:
Name Type Description
subject String

View Source hooks/useAuth.js, line 944

# inner useAuth() → {object}

This hook provides the auth state and methods to its consumers It is used to manage the auth state and provide the auth state to its consumers

View Source hooks/useAuth.js, line 133

The auth object
object

# inner useProvideAuth(config, whitelistopt, optionsopt) → {AuthContext}

These are the properties and methods that the "useAuth" hook provides to its consumers We are providing the auth state, login, and logout methods
Parameters:
Name Type Attributes Description
config object The configuration for the component
whitelist Array.<String> <optional>
The whitelist array
options object <optional>
Additional options

View Source hooks/useAuth.js, line 156

The auth context object
AuthContext