Private
baseURLPrivate
clientPrivate
Optional
clientPrivate
cryptoPrivate
Optional
encryptionPrivate
fetchOptional
init: RequestInitOptional
init: RequestInitPrivate
Optional
jwksPrivate
Optional
openIDConfigurationPrivate
Optional
requestReturn a FiefTokenResponse and FiefUserInfo in exchange of an authorization code.
The authorization code.
The exact same redirectURI
you passed to the authorization URL.
Optional
codeVerifier: stringThe raw PKCE code used to generate the code challenge during authorization.
Optional
requestInit: RequestInitAdditional fetch init options. Mostly useful to control fetch cache.
A token response and user information.
const [tokens, userinfo] = await fief.authCallback('CODE', 'http://localhost:8000/callback');
Return fresh FiefTokenResponse and FiefUserInfo in exchange of a refresh token.
A valid refresh token.
Optional
scope: string[]Optional list of scopes to ask for. If not provided, the access token will share the same list of scopes as requested the first time. Otherwise, it should be a subset of the original list of scopes.
Optional
requestInit: RequestInitAdditional fetch init options. Mostly useful to control fetch cache.
A token response and user information.
const [tokens, userinfo] = await fief.authRefreshToken('REFRESH_TOKEN');
Changes the user password with the Fief API using a valid access token.
An access token with an ACR of at least level 1 is required.
A valid access token.
The new password.
Optional
requestInit: RequestInitAdditional fetch init options. Mostly useful to control fetch cache.
Updated user information.
userinfo = await fief.changePassword('ACCESS_TOKEN', 'herminetincture')
Private
decodeIDTokenOptional
accessOptional
code?: stringRequests an email change with the Fief API using a valid access token.
The user will receive a verification code on this new email address. It shall be used with the method emailVerify to complete the modification.
An access token with an ACR of at least level 1 is required.
A valid access token.
Optional
requestInit: RequestInitAdditional fetch init options. Mostly useful to control fetch cache.
Updated user information.
userinfo = await fief.emailChange('ACCESS_TOKEN', 'anne@nantes.city')
Verifies the user email with the Fief API using a valid access token and verification code.
An access token with an ACR of at least level 1 is required.
A valid access token.
Optional
requestInit: RequestInitAdditional fetch init options. Mostly useful to control fetch cache.
Updated user information.
userinfo = await fief.emailVerify('ACCESS_TOKEN', 'ABCDE')
Return an authorization URL.
Optional
codeOptional code challenge for PKCE process.
Optional
codeMethod used to hash the PKCE code challenge.
Optional
extrasOptional object containing specific parameters.
Optional
lang?: stringOptional parameter to set the user locale.
Should be a valid RFC 3066 language identifier, like fr
or pt-PT
.
Your callback URI where the user will be redirected after Fief authentication.
Optional
scope?: string[]Optional list of scopes to ask for.
Optional
state?: stringOptional string that will be returned back in the callback parameters to allow you to retrieve state information.
The authorization URL.
const authURL = await fief.getAuthURL({
redirectURI: 'http://localhost:8000/callback',
scope: ['openid'],
);
Private
getJWKSReturns a logout URL. If you redirect the user to this page, Fief will clear the session stored on its side.
You're still responsible for clearing your own session mechanism if any.
A valid URL where the user will be redirected after the logout process.
The logout URL.
const logoutURL = await fief.getLogoutURL({
redirectURI: 'http://localhost:8000',
});
Private
getUpdates user information with the Fief API using a valid access token.
A valid access token.
An object containing the data to update.
Optional
requestInit: RequestInitAdditional fetch init options. Mostly useful to control fetch cache.
Updated user information.
To update user field values,
you need to nest them into a fields
object, indexed by their slug.
userinfo = await fief.update_profile('ACCESS_TOKEN', { fields: { first_name: 'Anne' } })
Return fresh FiefUserInfo from the Fief API using a valid access token.
A valid access token.
Optional
requestInit: RequestInitAdditional fetch init options. Mostly useful to control fetch cache.
Fresh user information.
userinfo = await fief.userinfo('ACCESS_TOKEN');
Check if an access token is valid and optionally that it has a required list of scopes, or a required list of permissions.
The access token to validate.
Optional
requiredScopes: string[]Optional list of scopes to check for.
Optional
requiredACR: FiefACROptional minimum ACR level required. Read more: https://docs.fief.dev/going-further/acr/
Optional
requiredPermissions: string[]Optional list of permissions to check for.
FiefAccessTokenInvalid if the access token is invalid.
FiefAccessTokenExpired if the access token is expired.
FiefAccessTokenMissingScope if a scope is missing.
FiefAccessTokenMissingPermission if a permission is missing.
try {
accessTokenInfo = await fief.validateAccessToken('ACCESS_TOKEN', ['required_scope']);
console.log(accessTokenInfo);
} catch (err) {
if (err instanceof FiefAccessTokenInvalid) {
console.error('Invalid access token');
} else if (err instanceof FiefAccessTokenExpired) {
console.error('Expired access token');
} else if (err instanceof FiefAccessTokenMissingScope) {
console.error('Missing required scope');
}
}
Static
Private
handle
Fief authentication client.
Example