-
Notifications
You must be signed in to change notification settings - Fork 19
API Reference
- listen(cb)
-
Set up a function that will be called whenever the user state is changed.
- signOut()
-
Sign out the currently signed in user. Removes all data stored in the localStorage that's associated with the user.
- authorizedRequest(resource, init)
-
Uses native fetch, but adds authorization headers otherwise the API is exactly the same as native fetch.
- signInWithCustomToken(token)
-
Signs in or signs up a user by exchanging a custom Auth token.
- signInWithProvider(options)
-
Start auth flow of a federated Id provider. Will redirect the page to the federated login page.
- handleSignInRedirect()
-
Handles all sign in flows that complete via redirects. Fails silently if no redirect was detected.
- signUp([email], [password])
-
Signs up with email and password or anonymously when no arguments are passed. Automatically signs the user in on completion.
- signIn(email, password)
-
Signs in a user with email and password.
-
sendOobCode(requestType, [email]) ⇒
Promise -
Sends an out-of-band confirmation code for an account. Can be used to reset a password, to verify an email address and send a Sign-in email link. The
emailargument is not needed only when verifying an email(In that case it will be completely ignored, even if specified), otherwise it is required. -
resetPassword(code) ⇒
string -
Sets a new password by using a reset code. Can also be used to very oobCode by not passing a password.
-
fetchProvidersForEmail(email) ⇒
ProvidersForEmailResponse -
Returns info about all providers associated with a specified email.
- fetchProfile([tokenManager])
-
Gets the user data from the server, and updates the local caches.
- updateProfile(newData)
-
Update user's profile.
- deleteAccount()
-
Deletes the currently logged in account and logs out.
-
ProviderOptions :
Object -
Settings object for an IDP(Identity Provider).
-
ProvidersForEmailResponse :
Object -
Object response from a "fetchProvidersForEmail" request.
-
oauthFlowOptions :
Object -
Setting object for the "startOauthFlow" method.
Set up a function that will be called whenever the user state is changed.
Kind: global function
| Param | Type | Description |
|---|---|---|
| cb | function |
The function to call when the event is triggered. |
Sign out the currently signed in user. Removes all data stored in the localStorage that's associated with the user.
Uses native fetch, but adds authorization headers otherwise the API is exactly the same as native fetch.
Kind: global function
| Param | Type | Description |
|---|---|---|
| resource |
Request | Object | string
|
the resource to send the request to, or an options object. |
| init | Object |
an options object. |
Signs in or signs up a user by exchanging a custom Auth token.
Kind: global function
| Param | Type | Description |
|---|---|---|
| token | string |
The custom token. |
Start auth flow of a federated Id provider. Will redirect the page to the federated login page.
Kind: global function
| Param | Type | Description |
|---|---|---|
| options |
oauthFlowOptions | string
|
An options object, or a string with the name of the provider. |
Handles all sign in flows that complete via redirects. Fails silently if no redirect was detected.
Signs up with email and password or anonymously when no arguments are passed. Automatically signs the user in on completion.
Kind: global function
| Param | Type | Description |
|---|---|---|
| [email] | string |
The email for the user to create. |
| [password] | string |
The password for the user to create. |
Signs in a user with email and password.
Kind: global function
| Param | Type |
|---|---|
string |
|
| password | string |
Sends an out-of-band confirmation code for an account.
Can be used to reset a password, to verify an email address and send a Sign-in email link.
The email argument is not needed only when verifying an email(In that case it will be completely ignored, even if specified), otherwise it is required.
Kind: global function
| Param | Type | Description |
|---|---|---|
| requestType |
'PASSWORD_RESET' | 'VERIFY_EMAIL' | 'EMAIL_SIGNIN'
|
The type of out-of-band (OOB) code to send. |
| [email] | string |
When the requestType is PASSWORD_RESET you need to provide an email address, else it will be ignored. |
Sets a new password by using a reset code. Can also be used to very oobCode by not passing a password.
Kind: global function
Returns: string - The email of the account to which the code was issued.
| Param | Type |
|---|---|
| code | string |
fetchProvidersForEmail(email) ⇒ ProvidersForEmailResponse
Returns info about all providers associated with a specified email.
Kind: global function
| Param | Type | Description |
|---|---|---|
string |
The user's email address. |
Gets the user data from the server, and updates the local caches.
Kind: global function Throws:
- Will throw if the user is not signed in.
| Param | Type | Description |
|---|---|---|
| [tokenManager] | Object |
Only when not logged in. |
Update user's profile.
Kind: global function Throws:
- Will throw if the user is not signed in.
| Param | Type | Description |
|---|---|---|
| newData | Object |
An object with the new data to overwrite. |
Deletes the currently logged in account and logs out.
Kind: global function Throws:
- Will throw if the user is not signed in.
Settings object for an IDP(Identity Provider).
Kind: global typedef Properties
| Name | Type | Description |
|---|---|---|
| options.name | string |
The name of the provider in lowercase. |
| [options.scope] | string |
The scopes for the IDP, this is optional and defaults to "openid email". |
Object response from a "fetchProvidersForEmail" request.
Kind: global typedef Properties
| Name | Type | Description |
|---|---|---|
| allProviders | Array.<string> |
All providers the user has once used to do federated login |
| registered | boolean |
All sign-in methods this user has used. |
| sessionId | string |
Session ID which should be passed in the following verifyAssertion request |
| signinMethods | Array.<string> |
All sign-in methods this user has used. |
Setting object for the "startOauthFlow" method.
Kind: global typedef Properties
| Name | Type | Default | Description |
|---|---|---|---|
| provider | string |
Name of the provider to use. | |
| [context] | string |
A string that will be returned after the Oauth flow is finished, should be used to retain context. | |
| [linkAccount] | boolean |
false |
Whether to link this oauth account with the current account. defaults to false. |