Members
# Cryptr Context
Context that gives you the current Cryptr state and possible hooks
# Cryptr Hooks
Tools to handle your Cryptr context
Properties:
Name | Type | Description |
---|---|---|
isAuthenticated |
function
|
Returns |
isLoading |
boolean
|
Returns |
logOut |
LogOutFunction
|
Initiates the log out process |
user |
function
|
Function that returns a User if there is an active session |
signInWithEmail |
SignInWithEmailFunction
|
Initiates a sign in process while providing the user's email |
signInWithDomain |
SignInWithDomainFunction
|
Initiates a sign in process while providing the organization's domain if known |
decorateRequest |
DecoratedRequestFunction
|
Function that automatically decorate a request with the current session access token (based on |
config |
function
|
Function that returns the current config |
getCurrentAccessToken |
function
|
Function that returns the current access token if there is an active session. Usefull if you want to process your own decoration process with your back-end. |
getCurrentIdToken |
function
|
Function that returns the current id token if there is an active session |
Examples
import { useCryptr } from '@cryptr/cryptr-react'
Then when you want to connect user by his email
const { signInWithEmail } = useCryptr()
//...
signInWithEmail('john@company.com')
When you want to get current active session's access token
const { getCurrentAccessToken } = useCryptr()
//...
getCurrentAccessToken() // "eyJ..."
When you want to initiate a logout process
const { logOut } = useCryptr()
//...
logOut()
# LogOutButton
Component to log out your user from it's current session. Usable props LogoutProps
Examples
Simple logout button
return (
<LogOutButton />
)
When you want a specific text
return (
<LogOutButton text={'Sign out here'} />
)
When you want to keep visible even if no session
return (
<LogOutButton autoHide={false} />
)
When you want to do a SLO among token revokation
return (
<LogOutButton sloAfterRevoke={true} />
)
# SignInWithDomainButton
Component to sign in with a specific domain (if known). Usable props : SignInWithDomainProps
Examples
When you want user to type email by his own
return (
<SignInWithDomainButton />
)
When you know user by his organization's domain
return (
<SignInWithDomainButton domain={'blablabus'} />
)
When you want to specify a different locale
return (
<SignInWithDomainButton locale={'fr'} />
)
When you to keep the button even if there is an active session
return (
<SignInWithDomainButton autoHide={false} />
)
# SignInWithEmailButton
Components to sign in with a specific domain (if known). Usable props : SignInWithEmailProps
Examples
When you want to intiate a session knowing the user's email
return (
<SignInWithEmailButton email={'john@blablabus.fr'} />
)
When you want to also precise the locale
return (
<SignInWithEmailButton email={'john@blablabus.fr'} locale={'fr'} />
)
When you want to keep button visible even if there is an active session
return (
<SignInWithEmailButton email={'john@blablabus.fr'} autoHide={false} />
)
# constant initialCryptrState
The initial auth state.
Properties:
Name | Type | Default | Description |
---|---|---|---|
isAuthenticated |
boolean
|
false | If there is an active session |
isLoading |
boolean
|
false | If there is a Cryptr authentication process in progress |
user |
User
|
null | User representation if session active |
error |
unknown
|
null | Is there any error ongoing |
Methods
# DEFAULT_LOGOUT_CALLBACK()
The default action after successful logout:
Popup alert informing user is logged out + reload the page
# DEFAULT_REDIRECT_CALLBACK()
The default action to perform after authentication:
Removes query params from history state
# DecoratedRequestFunction(url, kyOptionsopt, nullable)
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
url |
string
|
endpoint of the request to decorate |
|
kyOptions |
KyOptions
|
<optional> <nullable> |
|
# async LogOutFunction(callbackopt, targetUrlopt, sloAfterRevokeopt)
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
callback |
function
|
<optional> |
Callback function executed when logout succeeded |
|
targetUrl |
string
|
<optional> |
Specific URL to redirect after logout |
|
sloAfterRevoke |
boolean
|
<optional> |
false | If you want to do or not the SLO process after token revokation |
# SignInWithDomainFunction(domainopt, optionsopt)
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
domain |
string
|
<optional> |
The domain of the organization you want to use for this authentication process |
options |
SsoSignOptsAttrs
|
<optional> |
Specific options if needed |
# SignInWithEmailFunction(email, optionsopt)
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
email |
string
|
The email of the User you want to authenticate |
|
options |
SsoSignOptsAttrs
|
<optional> |
Specific options if needed |
Type Definitions
Object
# LogOutProps
Properties:
Name | Type | Attributes | Description |
---|---|---|---|
text |
string
|
<optional> |
Desired text in your button |
callback |
function
|
<optional> |
Callback called after logout |
style |
CSSProperties
|
<optional> |
Desired style in your button |
className |
string
|
<optional> |
Desired class in your button |
autoHide |
boolean
|
<optional> |
Set to |
targetUrl |
string
|
<optional> |
Desired url after url |
sloAfterRevoke |
boolean
|
<optional> |
Set to |
locale |
string
|
<optional> |
Define the component's text to if not provided |
Object
# SignInWithDomainProps
Properties:
Name | Type | Attributes | Description |
---|---|---|---|
domain |
string
|
<optional> |
The (optional) Organization domain |
text |
string
|
<optional> |
Text you want for your button |
className |
string
|
<optional> |
Class you want for your button |
style |
CSSProperties
|
<optional> |
Style you want for your button |
autoHide |
boolean
|
<optional> |
Set to |
options |
SsoSignOptsAttrs
|
<optional> |
Any other useful option such as |
Props
# SignInWithEmailProps
Properties:
Name | Type | Attributes | Description |
---|---|---|---|
email |
string
|
Required user's email that you want to login |
|
text |
string
|
<optional> |
Text you want for your button |
className |
string
|
<optional> |
Class you want for your button |
style |
CSSProperties
|
<optional> |
Style you want for your button |
autoHide |
boolean
|
<optional> |
Set to |
options |
SsoSignOptsAttrs
|
<optional> |
Any other useful option such as |