Members
# inner constant ACTIONS
Define the actions that can be dispatched
These represent the different state changes that the auth state can be in
# inner constant authContext
This is the context that will be used to provide the auth state to its consumers
# inner constant initialState
Define the initial state of the auth state
# inner constant STALE_CHECK_STATES
Define the states that the stale check can be in
# 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
Methods
# inner authReducer(nextState, action) → {object}
Reducer hook method for the auth state
Parameters:
Name | Type | Description |
---|---|---|
nextState |
*
|
|
action |
*
|
object
# inner clearRefreshTokenInSession()
This function will clear the refresh token from session storage
# async inner clearSubjectCookie()
This will clear the subject cookie
# 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 |
# inner getActiveBearerToken() → {String}
Get the active bearer token
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
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
# 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
the refresh token
String
# async inner getSubjectFromCookie() → {String}
This will attempt to get the subject from the cookie
the subject
String
# inner isValidConfig(config) → {boolean}
Checks to see if the config object is valid
Parameters:
Name | Type | Description |
---|---|---|
config |
object
|
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 |
The auth context provider
React.Context
# inner setActiveBearerToken(bearerToken)
set the active bearer token
Parameters:
Name | Type | Description |
---|---|---|
bearerToken |
string
|
# 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
|
# inner setSubjectInCookie(subject)
This function will set the subject in the cookie
Parameters:
Name | Type | Description |
---|---|---|
subject |
String
|
# 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
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 |
The auth context object