Global

Members

# Cryptr Context

Context that gives you the current Cryptr state and possible hooks

View Source CryptrContext.tsx, line 21

# Cryptr Hooks

Tools to handle your Cryptr context

Properties:
Name Type Description
isAuthenticated function

Returns true if there is an active session

isLoading boolean

Returns true if there is a Cryptr authentication process in progress

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 ky)

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

View Source useCryptr.tsx, line 34

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

View Source components/CryptrLogOutButton.tsx, line 5

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

View Source components/CryptrSignInWithDomainButton.tsx, line 5

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

View Source components/CryptrSignInWithEmailButton.tsx, line 5

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

View Source initialCryptrState.tsx, line 21

Methods

# DEFAULT_LOGOUT_CALLBACK()

The default action after successful logout:

Popup alert informing user is logged out + reload the page

View Source CryptrProvider.tsx, line 27

# DEFAULT_REDIRECT_CALLBACK()

The default action to perform after authentication:

Removes query params from history state

View Source CryptrProvider.tsx, line 13

# DecoratedRequestFunction(url, kyOptionsopt, nullable)

Parameters:
Name Type Attributes Description
url string

endpoint of the request to decorate

kyOptions KyOptions <optional>
<nullable>

ky options for the request (ex: additional headers, specific method ...)

View Source useCryptr.tsx, line 12

# 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

View Source useCryptr.tsx, line 4

# 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

View Source useCryptr.tsx, line 26

# 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

View Source useCryptr.tsx, line 19

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 false if you want to display even session is live

targetUrl string <optional>

Desired url after url

sloAfterRevoke boolean <optional>

Set to trueif you want also a SLO request among token revokation

locale string <optional>

Define the component's text to if not provided

View Source components/CryptrLogOutButton.tsx, line 49

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 false if you do not want to hide it when live session

options SsoSignOptsAttrs <optional>

Any other useful option such as locale

View Source components/CryptrSignInWithDomainButton.tsx, line 59

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 false if you do not want to hide it when live session

options SsoSignOptsAttrs <optional>

Any other useful option such as locale

View Source components/CryptrSignInWithEmailButton.tsx, line 50