Compare commits
10 Commits
@nhost/rea
...
@nhost/rea
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5ff6876aea | ||
|
|
d392ed86fb | ||
|
|
3bbe09c4b1 | ||
|
|
a47ce29173 | ||
|
|
42fba7a095 | ||
|
|
0ff633760a | ||
|
|
6c51571182 | ||
|
|
3825a09aed | ||
|
|
1768b1e069 | ||
|
|
fba5c819ce |
@@ -4,7 +4,7 @@ title: signUp()
|
|||||||
sidebar_label: signUp()
|
sidebar_label: signUp()
|
||||||
slug: /reference/javascript/auth/sign-up
|
slug: /reference/javascript/auth/sign-up
|
||||||
description: Use `nhost.auth.signUp` to sign up a user using email and password. If you want to sign up a user using passwordless email (Magic Link), SMS, or an OAuth provider, use the `signIn` function instead.
|
description: Use `nhost.auth.signUp` to sign up a user using email and password. If you want to sign up a user using passwordless email (Magic Link), SMS, or an OAuth provider, use the `signIn` function instead.
|
||||||
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L103
|
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L102
|
||||||
---
|
---
|
||||||
|
|
||||||
# `signUp()`
|
# `signUp()`
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ title: signIn()
|
|||||||
sidebar_label: signIn()
|
sidebar_label: signIn()
|
||||||
slug: /reference/javascript/auth/sign-in
|
slug: /reference/javascript/auth/sign-in
|
||||||
description: Use `nhost.auth.signIn` to sign in a user using email and password, passwordless (email or sms) or an external provider. `signIn` can be used to sign in a user in various ways depending on the parameters.
|
description: Use `nhost.auth.signIn` to sign in a user using email and password, passwordless (email or sms) or an external provider. `signIn` can be used to sign in a user in various ways depending on the parameters.
|
||||||
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L146
|
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L145
|
||||||
---
|
---
|
||||||
|
|
||||||
# `signIn()`
|
# `signIn()`
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ title: signOut()
|
|||||||
sidebar_label: signOut()
|
sidebar_label: signOut()
|
||||||
slug: /reference/javascript/auth/sign-out
|
slug: /reference/javascript/auth/sign-out
|
||||||
description: Use `nhost.auth.signOut` to sign out the user.
|
description: Use `nhost.auth.signOut` to sign out the user.
|
||||||
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L231
|
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L233
|
||||||
---
|
---
|
||||||
|
|
||||||
# `signOut()`
|
# `signOut()`
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ title: resetPassword()
|
|||||||
sidebar_label: resetPassword()
|
sidebar_label: resetPassword()
|
||||||
slug: /reference/javascript/auth/reset-password
|
slug: /reference/javascript/auth/reset-password
|
||||||
description: Use `nhost.auth.resetPassword` to reset the password for a user. This will send a reset-password link in an email to the user. When the user clicks the reset-password link the user is automatically signed-in. Once signed-in, the user can change their password using `nhost.auth.changePassword()`.
|
description: Use `nhost.auth.resetPassword` to reset the password for a user. This will send a reset-password link in an email to the user. When the user clicks the reset-password link the user is automatically signed-in. Once signed-in, the user can change their password using `nhost.auth.changePassword()`.
|
||||||
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L247
|
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L249
|
||||||
---
|
---
|
||||||
|
|
||||||
# `resetPassword()`
|
# `resetPassword()`
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ title: changePassword()
|
|||||||
sidebar_label: changePassword()
|
sidebar_label: changePassword()
|
||||||
slug: /reference/javascript/auth/change-password
|
slug: /reference/javascript/auth/change-password
|
||||||
description: Use `nhost.auth.changePassword` to change the password for the signed-in user. The old password is not needed. In case the user is not signed-in, a password reset ticket needs to be provided.
|
description: Use `nhost.auth.changePassword` to change the password for the signed-in user. The old password is not needed. In case the user is not signed-in, a password reset ticket needs to be provided.
|
||||||
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L263
|
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L265
|
||||||
---
|
---
|
||||||
|
|
||||||
# `changePassword()`
|
# `changePassword()`
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ title: sendVerificationEmail()
|
|||||||
sidebar_label: sendVerificationEmail()
|
sidebar_label: sendVerificationEmail()
|
||||||
slug: /reference/javascript/auth/send-verification-email
|
slug: /reference/javascript/auth/send-verification-email
|
||||||
description: Use `nhost.auth.sendVerificationEmail` to send a verification email to the specified email. The email contains a verification-email link. When the user clicks the verification-email link their email is verified.
|
description: Use `nhost.auth.sendVerificationEmail` to send a verification email to the specified email. The email contains a verification-email link. When the user clicks the verification-email link their email is verified.
|
||||||
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L279
|
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L284
|
||||||
---
|
---
|
||||||
|
|
||||||
# `sendVerificationEmail()`
|
# `sendVerificationEmail()`
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ title: changeEmail()
|
|||||||
sidebar_label: changeEmail()
|
sidebar_label: changeEmail()
|
||||||
slug: /reference/javascript/auth/change-email
|
slug: /reference/javascript/auth/change-email
|
||||||
description: Use `nhost.auth.changeEmail` to change a user's email. This will send a confirm-email-change link in an email to the new email. Once the user clicks on the confirm-email-change link the email will be change to the new email.
|
description: Use `nhost.auth.changeEmail` to change a user's email. This will send a confirm-email-change link in an email to the new email. Once the user clicks on the confirm-email-change link the email will be change to the new email.
|
||||||
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L298
|
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L303
|
||||||
---
|
---
|
||||||
|
|
||||||
# `changeEmail()`
|
# `changeEmail()`
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ title: deanonymize()
|
|||||||
sidebar_label: deanonymize()
|
sidebar_label: deanonymize()
|
||||||
slug: /reference/javascript/auth/deanonymize
|
slug: /reference/javascript/auth/deanonymize
|
||||||
description: Use `nhost.auth.deanonymize` to deanonymize a user.
|
description: Use `nhost.auth.deanonymize` to deanonymize a user.
|
||||||
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L314
|
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L319
|
||||||
---
|
---
|
||||||
|
|
||||||
# `deanonymize()`
|
# `deanonymize()`
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ title: onTokenChanged()
|
|||||||
sidebar_label: onTokenChanged()
|
sidebar_label: onTokenChanged()
|
||||||
slug: /reference/javascript/auth/on-token-changed
|
slug: /reference/javascript/auth/on-token-changed
|
||||||
description: Use `nhost.auth.onTokenChanged` to add a custom function that runs every time the access or refresh token is changed.
|
description: Use `nhost.auth.onTokenChanged` to add a custom function that runs every time the access or refresh token is changed.
|
||||||
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L357
|
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L362
|
||||||
---
|
---
|
||||||
|
|
||||||
# `onTokenChanged()`
|
# `onTokenChanged()`
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ title: onAuthStateChanged()
|
|||||||
sidebar_label: onAuthStateChanged()
|
sidebar_label: onAuthStateChanged()
|
||||||
slug: /reference/javascript/auth/on-auth-state-changed
|
slug: /reference/javascript/auth/on-auth-state-changed
|
||||||
description: Use `nhost.auth.onAuthStateChanged` to add a custom function that runs every time the authentication status of the user changes. E.g. add a custom function that runs every time the authentication status changes from signed-in to signed-out.
|
description: Use `nhost.auth.onAuthStateChanged` to add a custom function that runs every time the authentication status of the user changes. E.g. add a custom function that runs every time the authentication status changes from signed-in to signed-out.
|
||||||
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L392
|
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L397
|
||||||
---
|
---
|
||||||
|
|
||||||
# `onAuthStateChanged()`
|
# `onAuthStateChanged()`
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ title: isAuthenticated()
|
|||||||
sidebar_label: isAuthenticated()
|
sidebar_label: isAuthenticated()
|
||||||
slug: /reference/javascript/auth/is-authenticated
|
slug: /reference/javascript/auth/is-authenticated
|
||||||
description: Use `nhost.auth.isAuthenticated` to check if the user is authenticated or not.
|
description: Use `nhost.auth.isAuthenticated` to check if the user is authenticated or not.
|
||||||
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L434
|
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L439
|
||||||
---
|
---
|
||||||
|
|
||||||
# `isAuthenticated()`
|
# `isAuthenticated()`
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ title: isAuthenticatedAsync()
|
|||||||
sidebar_label: isAuthenticatedAsync()
|
sidebar_label: isAuthenticatedAsync()
|
||||||
slug: /reference/javascript/auth/is-authenticated-async
|
slug: /reference/javascript/auth/is-authenticated-async
|
||||||
description: Use `nhost.auth.isAuthenticatedAsync` to wait (await) for any internal authentication network requests to finish and then return the authentication status.
|
description: Use `nhost.auth.isAuthenticatedAsync` to wait (await) for any internal authentication network requests to finish and then return the authentication status.
|
||||||
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L452
|
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L457
|
||||||
---
|
---
|
||||||
|
|
||||||
# `isAuthenticatedAsync()`
|
# `isAuthenticatedAsync()`
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ title: getAuthenticationStatus()
|
|||||||
sidebar_label: getAuthenticationStatus()
|
sidebar_label: getAuthenticationStatus()
|
||||||
slug: /reference/javascript/auth/get-authentication-status
|
slug: /reference/javascript/auth/get-authentication-status
|
||||||
description: Use `nhost.auth.getAuthenticationStatus` to get the authentication status of the user.
|
description: Use `nhost.auth.getAuthenticationStatus` to get the authentication status of the user.
|
||||||
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L478
|
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L483
|
||||||
---
|
---
|
||||||
|
|
||||||
# `getAuthenticationStatus()`
|
# `getAuthenticationStatus()`
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ title: getAccessToken()
|
|||||||
sidebar_label: getAccessToken()
|
sidebar_label: getAccessToken()
|
||||||
slug: /reference/javascript/auth/get-access-token
|
slug: /reference/javascript/auth/get-access-token
|
||||||
description: Use `nhost.auth.getAccessToken` to get the access token of the user.
|
description: Use `nhost.auth.getAccessToken` to get the access token of the user.
|
||||||
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L508
|
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L513
|
||||||
---
|
---
|
||||||
|
|
||||||
# `getAccessToken()`
|
# `getAccessToken()`
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ title: getDecodedAccessToken()
|
|||||||
sidebar_label: getDecodedAccessToken()
|
sidebar_label: getDecodedAccessToken()
|
||||||
slug: /reference/javascript/auth/get-decoded-access-token
|
slug: /reference/javascript/auth/get-decoded-access-token
|
||||||
description: Use `nhost.auth.getDecodedAccessToken` to get the decoded access token of the user.
|
description: Use `nhost.auth.getDecodedAccessToken` to get the decoded access token of the user.
|
||||||
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L523
|
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L528
|
||||||
---
|
---
|
||||||
|
|
||||||
# `getDecodedAccessToken()`
|
# `getDecodedAccessToken()`
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ title: getHasuraClaims()
|
|||||||
sidebar_label: getHasuraClaims()
|
sidebar_label: getHasuraClaims()
|
||||||
slug: /reference/javascript/auth/get-hasura-claims
|
slug: /reference/javascript/auth/get-hasura-claims
|
||||||
description: Use `nhost.auth.getHasuraClaims` to get the Hasura claims of the user.
|
description: Use `nhost.auth.getHasuraClaims` to get the Hasura claims of the user.
|
||||||
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L540
|
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L545
|
||||||
---
|
---
|
||||||
|
|
||||||
# `getHasuraClaims()`
|
# `getHasuraClaims()`
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ title: getHasuraClaim()
|
|||||||
sidebar_label: getHasuraClaim()
|
sidebar_label: getHasuraClaim()
|
||||||
slug: /reference/javascript/auth/get-hasura-claim
|
slug: /reference/javascript/auth/get-hasura-claim
|
||||||
description: Use `nhost.auth.getHasuraClaim` to get the value of a specific Hasura claim of the user.
|
description: Use `nhost.auth.getHasuraClaim` to get the value of a specific Hasura claim of the user.
|
||||||
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L558
|
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L563
|
||||||
---
|
---
|
||||||
|
|
||||||
# `getHasuraClaim()`
|
# `getHasuraClaim()`
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ title: refreshSession()
|
|||||||
sidebar_label: refreshSession()
|
sidebar_label: refreshSession()
|
||||||
slug: /reference/javascript/auth/refresh-session
|
slug: /reference/javascript/auth/refresh-session
|
||||||
description: Use `nhost.auth.refreshSession` to refresh the session with either the current internal refresh token or an external refresh token.
|
description: Use `nhost.auth.refreshSession` to refresh the session with either the current internal refresh token or an external refresh token.
|
||||||
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L581
|
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L586
|
||||||
---
|
---
|
||||||
|
|
||||||
# `refreshSession()`
|
# `refreshSession()`
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ title: getSession()
|
|||||||
sidebar_label: getSession()
|
sidebar_label: getSession()
|
||||||
slug: /reference/javascript/auth/get-session
|
slug: /reference/javascript/auth/get-session
|
||||||
description: Use `nhost.auth.getSession()` to get the session of the user.
|
description: Use `nhost.auth.getSession()` to get the session of the user.
|
||||||
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L625
|
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L627
|
||||||
---
|
---
|
||||||
|
|
||||||
# `getSession()`
|
# `getSession()`
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ title: getUser()
|
|||||||
sidebar_label: getUser()
|
sidebar_label: getUser()
|
||||||
slug: /reference/javascript/auth/get-user
|
slug: /reference/javascript/auth/get-user
|
||||||
description: Use `nhost.auth.getUser()` to get the signed-in user.
|
description: Use `nhost.auth.getUser()` to get the signed-in user.
|
||||||
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L640
|
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L642
|
||||||
---
|
---
|
||||||
|
|
||||||
# `getUser()`
|
# `getUser()`
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ title: HasuraAuthClient
|
|||||||
sidebar_label: Auth
|
sidebar_label: Auth
|
||||||
description: No description provided.
|
description: No description provided.
|
||||||
slug: /reference/javascript/auth
|
slug: /reference/javascript/auth
|
||||||
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L60
|
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L59
|
||||||
---
|
---
|
||||||
|
|
||||||
# `HasuraAuthClient`
|
# `HasuraAuthClient`
|
||||||
|
|||||||
@@ -1,18 +0,0 @@
|
|||||||
---
|
|
||||||
# ⚠️ AUTO-GENERATED CONTENT. DO NOT EDIT THIS FILE DIRECTLY! ⚠️
|
|
||||||
title: ApiChangeEmailResponse
|
|
||||||
sidebar_label: ApiChangeEmailResponse
|
|
||||||
description: No description provided.
|
|
||||||
displayed_sidebar: referenceSidebar
|
|
||||||
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/utils/types.ts#L182
|
|
||||||
---
|
|
||||||
|
|
||||||
# `ApiChangeEmailResponse`
|
|
||||||
|
|
||||||
## Parameters
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
**<span className="parameter-name">error</span>** <span className="optional-status">required</span> `null` | `ErrorPayload`
|
|
||||||
|
|
||||||
---
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
---
|
|
||||||
# ⚠️ AUTO-GENERATED CONTENT. DO NOT EDIT THIS FILE DIRECTLY! ⚠️
|
|
||||||
title: ApiChangePasswordResponse
|
|
||||||
sidebar_label: ApiChangePasswordResponse
|
|
||||||
description: No description provided.
|
|
||||||
displayed_sidebar: referenceSidebar
|
|
||||||
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/utils/types.ts#L174
|
|
||||||
---
|
|
||||||
|
|
||||||
# `ApiChangePasswordResponse`
|
|
||||||
|
|
||||||
## Parameters
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
**<span className="parameter-name">error</span>** <span className="optional-status">required</span> `null` | `ErrorPayload`
|
|
||||||
|
|
||||||
---
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
---
|
|
||||||
# ⚠️ AUTO-GENERATED CONTENT. DO NOT EDIT THIS FILE DIRECTLY! ⚠️
|
|
||||||
title: ApiDeanonymizeResponse
|
|
||||||
sidebar_label: ApiDeanonymizeResponse
|
|
||||||
description: No description provided.
|
|
||||||
displayed_sidebar: referenceSidebar
|
|
||||||
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/utils/types.ts#L186
|
|
||||||
---
|
|
||||||
|
|
||||||
# `ApiDeanonymizeResponse`
|
|
||||||
|
|
||||||
## Parameters
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
**<span className="parameter-name">error</span>** <span className="optional-status">required</span> `null` | `ErrorPayload`
|
|
||||||
|
|
||||||
---
|
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
---
|
|
||||||
# ⚠️ AUTO-GENERATED CONTENT. DO NOT EDIT THIS FILE DIRECTLY! ⚠️
|
|
||||||
title: ApiRefreshTokenResponse
|
|
||||||
sidebar_label: ApiRefreshTokenResponse
|
|
||||||
description: No description provided.
|
|
||||||
displayed_sidebar: referenceSidebar
|
|
||||||
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/utils/types.ts#L162
|
|
||||||
---
|
|
||||||
|
|
||||||
# `ApiRefreshTokenResponse`
|
|
||||||
|
|
||||||
```ts
|
|
||||||
type ApiRefreshTokenResponse =
|
|
||||||
| { session: null; error: ErrorPayload }
|
|
||||||
| { session: Session; error: null }
|
|
||||||
```
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
---
|
|
||||||
# ⚠️ AUTO-GENERATED CONTENT. DO NOT EDIT THIS FILE DIRECTLY! ⚠️
|
|
||||||
title: ApiResetPasswordResponse
|
|
||||||
sidebar_label: ApiResetPasswordResponse
|
|
||||||
description: No description provided.
|
|
||||||
displayed_sidebar: referenceSidebar
|
|
||||||
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/utils/types.ts#L170
|
|
||||||
---
|
|
||||||
|
|
||||||
# `ApiResetPasswordResponse`
|
|
||||||
|
|
||||||
## Parameters
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
**<span className="parameter-name">error</span>** <span className="optional-status">required</span> `null` | `ErrorPayload`
|
|
||||||
|
|
||||||
---
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
---
|
|
||||||
# ⚠️ AUTO-GENERATED CONTENT. DO NOT EDIT THIS FILE DIRECTLY! ⚠️
|
|
||||||
title: ApiSendVerificationEmailResponse
|
|
||||||
sidebar_label: ApiSendVerificationEmailResponse
|
|
||||||
description: No description provided.
|
|
||||||
displayed_sidebar: referenceSidebar
|
|
||||||
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/utils/types.ts#L178
|
|
||||||
---
|
|
||||||
|
|
||||||
# `ApiSendVerificationEmailResponse`
|
|
||||||
|
|
||||||
## Parameters
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
**<span className="parameter-name">error</span>** <span className="optional-status">required</span> `null` | `ErrorPayload`
|
|
||||||
|
|
||||||
---
|
|
||||||
@@ -1,29 +0,0 @@
|
|||||||
---
|
|
||||||
# ⚠️ AUTO-GENERATED CONTENT. DO NOT EDIT THIS FILE DIRECTLY! ⚠️
|
|
||||||
title: ApiSignInData
|
|
||||||
sidebar_label: ApiSignInData
|
|
||||||
description: No description provided.
|
|
||||||
displayed_sidebar: referenceSidebar
|
|
||||||
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/utils/types.ts#L151
|
|
||||||
---
|
|
||||||
|
|
||||||
# `ApiSignInData`
|
|
||||||
|
|
||||||
## Parameters
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
**<span className="parameter-name">session</span>** <span className="optional-status">required</span> [`Session`](/reference/docgen/javascript/auth/types/session)
|
|
||||||
|
|
||||||
| Property | Type | Required | Notes |
|
|
||||||
| :------------------------------------------------------------------------------------------------------- | :--------------------------------------------------------------- | :------: | :---- |
|
|
||||||
| <span className="parameter-name"><span className="light-grey">session.</span>user</span> | `null` \| [`User`](/reference/docgen/javascript/auth/types/user) | ✔️ | |
|
|
||||||
| <span className="parameter-name"><span className="light-grey">session.</span>refreshToken</span> | `string` | ✔️ | |
|
|
||||||
| <span className="parameter-name"><span className="light-grey">session.</span>accessTokenExpiresIn</span> | `number` | ✔️ | |
|
|
||||||
| <span className="parameter-name"><span className="light-grey">session.</span>accessToken</span> | `string` | ✔️ | |
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
**<span className="parameter-name">mfa</span>** <span className="optional-status">required</span> `null` | [`Mfa`](/reference/docgen/javascript/auth/types/mfa)
|
|
||||||
|
|
||||||
---
|
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
---
|
|
||||||
# ⚠️ AUTO-GENERATED CONTENT. DO NOT EDIT THIS FILE DIRECTLY! ⚠️
|
|
||||||
title: ApiSignInResponse
|
|
||||||
sidebar_label: ApiSignInResponse
|
|
||||||
description: No description provided.
|
|
||||||
displayed_sidebar: referenceSidebar
|
|
||||||
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/utils/types.ts#L155
|
|
||||||
---
|
|
||||||
|
|
||||||
# `ApiSignInResponse`
|
|
||||||
|
|
||||||
```ts
|
|
||||||
type ApiSignInResponse =
|
|
||||||
| { data: ApiSignInData; error: null }
|
|
||||||
| { data: null; error: ErrorPayload }
|
|
||||||
```
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
---
|
|
||||||
# ⚠️ AUTO-GENERATED CONTENT. DO NOT EDIT THIS FILE DIRECTLY! ⚠️
|
|
||||||
title: ApiSignOutResponse
|
|
||||||
sidebar_label: ApiSignOutResponse
|
|
||||||
description: No description provided.
|
|
||||||
displayed_sidebar: referenceSidebar
|
|
||||||
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/utils/types.ts#L166
|
|
||||||
---
|
|
||||||
|
|
||||||
# `ApiSignOutResponse`
|
|
||||||
|
|
||||||
## Parameters
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
**<span className="parameter-name">error</span>** <span className="optional-status">required</span> `null` | `ErrorPayload`
|
|
||||||
|
|
||||||
---
|
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
---
|
|
||||||
# ⚠️ AUTO-GENERATED CONTENT. DO NOT EDIT THIS FILE DIRECTLY! ⚠️
|
|
||||||
title: ApiSignUpEmailPasswordResponse
|
|
||||||
sidebar_label: ApiSignUpEmailPasswordResponse
|
|
||||||
description: No description provided.
|
|
||||||
displayed_sidebar: referenceSidebar
|
|
||||||
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/utils/types.ts#L147
|
|
||||||
---
|
|
||||||
|
|
||||||
# `ApiSignUpEmailPasswordResponse`
|
|
||||||
|
|
||||||
```ts
|
|
||||||
type ApiSignUpEmailPasswordResponse =
|
|
||||||
| { session: null; error: ErrorPayload }
|
|
||||||
| { session: Session; error: null }
|
|
||||||
```
|
|
||||||
@@ -4,7 +4,7 @@ title: AuthChangeEvent
|
|||||||
sidebar_label: AuthChangeEvent
|
sidebar_label: AuthChangeEvent
|
||||||
description: No description provided.
|
description: No description provided.
|
||||||
displayed_sidebar: referenceSidebar
|
displayed_sidebar: referenceSidebar
|
||||||
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/utils/types.ts#L135
|
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/utils/types.ts#L100
|
||||||
---
|
---
|
||||||
|
|
||||||
# `AuthChangeEvent`
|
# `AuthChangeEvent`
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ title: AuthChangedFunction
|
|||||||
sidebar_label: AuthChangedFunction
|
sidebar_label: AuthChangedFunction
|
||||||
description: No description provided.
|
description: No description provided.
|
||||||
displayed_sidebar: referenceSidebar
|
displayed_sidebar: referenceSidebar
|
||||||
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/utils/types.ts#L137
|
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/utils/types.ts#L102
|
||||||
---
|
---
|
||||||
|
|
||||||
# `AuthChangedFunction`
|
# `AuthChangedFunction`
|
||||||
@@ -12,6 +12,6 @@ custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-j
|
|||||||
```ts
|
```ts
|
||||||
type AuthChangedFunction = () => (
|
type AuthChangedFunction = () => (
|
||||||
event: AuthChangeEvent,
|
event: AuthChangeEvent,
|
||||||
session: Session | null
|
session: NhostSession | null
|
||||||
) => void
|
) => void
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ title: ChangeEmailParams
|
|||||||
sidebar_label: ChangeEmailParams
|
sidebar_label: ChangeEmailParams
|
||||||
description: No description provided.
|
description: No description provided.
|
||||||
displayed_sidebar: referenceSidebar
|
displayed_sidebar: referenceSidebar
|
||||||
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/utils/types.ts#L106
|
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/utils/types.ts#L82
|
||||||
---
|
---
|
||||||
|
|
||||||
# `ChangeEmailParams`
|
# `ChangeEmailParams`
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ title: ChangePasswordParams
|
|||||||
sidebar_label: ChangePasswordParams
|
sidebar_label: ChangePasswordParams
|
||||||
description: No description provided.
|
description: No description provided.
|
||||||
displayed_sidebar: referenceSidebar
|
displayed_sidebar: referenceSidebar
|
||||||
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/utils/types.ts#L96
|
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/utils/types.ts#L72
|
||||||
---
|
---
|
||||||
|
|
||||||
# `ChangePasswordParams`
|
# `ChangePasswordParams`
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ title: DeanonymizeParams
|
|||||||
sidebar_label: DeanonymizeParams
|
sidebar_label: DeanonymizeParams
|
||||||
description: No description provided.
|
description: No description provided.
|
||||||
displayed_sidebar: referenceSidebar
|
displayed_sidebar: referenceSidebar
|
||||||
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/utils/types.ts#L111
|
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/utils/types.ts#L87
|
||||||
---
|
---
|
||||||
|
|
||||||
# `DeanonymizeParams`
|
# `DeanonymizeParams`
|
||||||
|
|||||||
@@ -1,18 +0,0 @@
|
|||||||
---
|
|
||||||
# ⚠️ AUTO-GENERATED CONTENT. DO NOT EDIT THIS FILE DIRECTLY! ⚠️
|
|
||||||
title: Headers
|
|
||||||
sidebar_label: Headers
|
|
||||||
description: No description provided.
|
|
||||||
displayed_sidebar: referenceSidebar
|
|
||||||
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/utils/types.ts#L140
|
|
||||||
---
|
|
||||||
|
|
||||||
# `Headers`
|
|
||||||
|
|
||||||
## Parameters
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
**<span className="parameter-name">Authorization</span>** <span className="optional-status">optional</span> `string`
|
|
||||||
|
|
||||||
---
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
---
|
|
||||||
# ⚠️ AUTO-GENERATED CONTENT. DO NOT EDIT THIS FILE DIRECTLY! ⚠️
|
|
||||||
title: Mfa
|
|
||||||
sidebar_label: Mfa
|
|
||||||
description: No description provided.
|
|
||||||
displayed_sidebar: referenceSidebar
|
|
||||||
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/utils/types.ts#L143
|
|
||||||
---
|
|
||||||
|
|
||||||
# `Mfa`
|
|
||||||
|
|
||||||
## Parameters
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
**<span className="parameter-name">ticket</span>** <span className="optional-status">required</span> `string`
|
|
||||||
|
|
||||||
---
|
|
||||||
@@ -4,11 +4,11 @@ title: OnTokenChangedFunction
|
|||||||
sidebar_label: OnTokenChangedFunction
|
sidebar_label: OnTokenChangedFunction
|
||||||
description: No description provided.
|
description: No description provided.
|
||||||
displayed_sidebar: referenceSidebar
|
displayed_sidebar: referenceSidebar
|
||||||
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/utils/types.ts#L139
|
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/utils/types.ts#L104
|
||||||
---
|
---
|
||||||
|
|
||||||
# `OnTokenChangedFunction`
|
# `OnTokenChangedFunction`
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
type OnTokenChangedFunction = () => (session: Session | null) => void
|
type OnTokenChangedFunction = () => (session: NhostSession | null) => void
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ title: Provider
|
|||||||
sidebar_label: Provider
|
sidebar_label: Provider
|
||||||
description: No description provided.
|
description: No description provided.
|
||||||
displayed_sidebar: referenceSidebar
|
displayed_sidebar: referenceSidebar
|
||||||
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/core/src/types.ts#L140
|
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/core/src/types.ts#L141
|
||||||
---
|
---
|
||||||
|
|
||||||
# `Provider`
|
# `Provider`
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ title: ResetPasswordParams
|
|||||||
sidebar_label: ResetPasswordParams
|
sidebar_label: ResetPasswordParams
|
||||||
description: No description provided.
|
description: No description provided.
|
||||||
displayed_sidebar: referenceSidebar
|
displayed_sidebar: referenceSidebar
|
||||||
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/utils/types.ts#L91
|
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/utils/types.ts#L67
|
||||||
---
|
---
|
||||||
|
|
||||||
# `ResetPasswordParams`
|
# `ResetPasswordParams`
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ title: SendVerificationEmailParams
|
|||||||
sidebar_label: SendVerificationEmailParams
|
sidebar_label: SendVerificationEmailParams
|
||||||
description: No description provided.
|
description: No description provided.
|
||||||
displayed_sidebar: referenceSidebar
|
displayed_sidebar: referenceSidebar
|
||||||
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/utils/types.ts#L101
|
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/utils/types.ts#L77
|
||||||
---
|
---
|
||||||
|
|
||||||
# `SendVerificationEmailParams`
|
# `SendVerificationEmailParams`
|
||||||
|
|||||||
@@ -1,30 +0,0 @@
|
|||||||
---
|
|
||||||
# ⚠️ AUTO-GENERATED CONTENT. DO NOT EDIT THIS FILE DIRECTLY! ⚠️
|
|
||||||
title: Session
|
|
||||||
sidebar_label: Session
|
|
||||||
description: No description provided.
|
|
||||||
displayed_sidebar: referenceSidebar
|
|
||||||
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/utils/types.ts#L23
|
|
||||||
---
|
|
||||||
|
|
||||||
# `Session`
|
|
||||||
|
|
||||||
## Parameters
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
**<span className="parameter-name">accessToken</span>** <span className="optional-status">required</span> `string`
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
**<span className="parameter-name">accessTokenExpiresIn</span>** <span className="optional-status">required</span> `number`
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
**<span className="parameter-name">refreshToken</span>** <span className="optional-status">required</span> `string`
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
**<span className="parameter-name">user</span>** <span className="optional-status">required</span> `null` | [`User`](/reference/docgen/javascript/auth/types/user)
|
|
||||||
|
|
||||||
---
|
|
||||||
@@ -4,7 +4,7 @@ title: SignInEmailPasswordOtpParams
|
|||||||
sidebar_label: SignInEmailPasswordOtpParams
|
sidebar_label: SignInEmailPasswordOtpParams
|
||||||
description: No description provided.
|
description: No description provided.
|
||||||
displayed_sidebar: referenceSidebar
|
displayed_sidebar: referenceSidebar
|
||||||
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/utils/types.ts#L59
|
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/utils/types.ts#L35
|
||||||
---
|
---
|
||||||
|
|
||||||
# `SignInEmailPasswordOtpParams`
|
# `SignInEmailPasswordOtpParams`
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ title: SignInEmailPasswordParams
|
|||||||
sidebar_label: SignInEmailPasswordParams
|
sidebar_label: SignInEmailPasswordParams
|
||||||
description: No description provided.
|
description: No description provided.
|
||||||
displayed_sidebar: referenceSidebar
|
displayed_sidebar: referenceSidebar
|
||||||
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/utils/types.ts#L54
|
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/utils/types.ts#L30
|
||||||
---
|
---
|
||||||
|
|
||||||
# `SignInEmailPasswordParams`
|
# `SignInEmailPasswordParams`
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ title: SignInParams
|
|||||||
sidebar_label: SignInParams
|
sidebar_label: SignInParams
|
||||||
description: No description provided.
|
description: No description provided.
|
||||||
displayed_sidebar: referenceSidebar
|
displayed_sidebar: referenceSidebar
|
||||||
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/utils/types.ts#L83
|
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/utils/types.ts#L59
|
||||||
---
|
---
|
||||||
|
|
||||||
# `SignInParams`
|
# `SignInParams`
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ title: SignInPasswordlessEmailParams
|
|||||||
sidebar_label: SignInPasswordlessEmailParams
|
sidebar_label: SignInPasswordlessEmailParams
|
||||||
description: No description provided.
|
description: No description provided.
|
||||||
displayed_sidebar: referenceSidebar
|
displayed_sidebar: referenceSidebar
|
||||||
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/utils/types.ts#L64
|
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/utils/types.ts#L40
|
||||||
---
|
---
|
||||||
|
|
||||||
# `SignInPasswordlessEmailParams`
|
# `SignInPasswordlessEmailParams`
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ title: SignInPasswordlessSmsOtpParams
|
|||||||
sidebar_label: SignInPasswordlessSmsOtpParams
|
sidebar_label: SignInPasswordlessSmsOtpParams
|
||||||
description: No description provided.
|
description: No description provided.
|
||||||
displayed_sidebar: referenceSidebar
|
displayed_sidebar: referenceSidebar
|
||||||
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/utils/types.ts#L74
|
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/utils/types.ts#L50
|
||||||
---
|
---
|
||||||
|
|
||||||
# `SignInPasswordlessSmsOtpParams`
|
# `SignInPasswordlessSmsOtpParams`
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ title: SignInPasswordlessSmsParams
|
|||||||
sidebar_label: SignInPasswordlessSmsParams
|
sidebar_label: SignInPasswordlessSmsParams
|
||||||
description: No description provided.
|
description: No description provided.
|
||||||
displayed_sidebar: referenceSidebar
|
displayed_sidebar: referenceSidebar
|
||||||
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/utils/types.ts#L69
|
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/utils/types.ts#L45
|
||||||
---
|
---
|
||||||
|
|
||||||
# `SignInPasswordlessSmsParams`
|
# `SignInPasswordlessSmsParams`
|
||||||
|
|||||||
@@ -1,34 +0,0 @@
|
|||||||
---
|
|
||||||
# ⚠️ AUTO-GENERATED CONTENT. DO NOT EDIT THIS FILE DIRECTLY! ⚠️
|
|
||||||
title: SignInReponse
|
|
||||||
sidebar_label: SignInReponse
|
|
||||||
description: No description provided.
|
|
||||||
displayed_sidebar: referenceSidebar
|
|
||||||
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/utils/types.ts#L124
|
|
||||||
---
|
|
||||||
|
|
||||||
# `SignInReponse`
|
|
||||||
|
|
||||||
## Parameters
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
**<span className="parameter-name">session</span>** <span className="optional-status">required</span> `null` | [`Session`](/reference/docgen/javascript/auth/types/session)
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
**<span className="parameter-name">error</span>** <span className="optional-status">required</span> `null` | `ErrorPayload`
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
**<span className="parameter-name">mfa</span>** <span className="optional-status">optional</span> `{ enabled: boolean, ticket: string }`
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
**<span className="parameter-name">providerUrl</span>** <span className="optional-status">optional</span> `string`
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
**<span className="parameter-name">provider</span>** <span className="optional-status">optional</span> `string`
|
|
||||||
|
|
||||||
---
|
|
||||||
@@ -1,34 +0,0 @@
|
|||||||
---
|
|
||||||
# ⚠️ AUTO-GENERATED CONTENT. DO NOT EDIT THIS FILE DIRECTLY! ⚠️
|
|
||||||
title: SignInResponse
|
|
||||||
sidebar_label: SignInResponse
|
|
||||||
description: No description provided.
|
|
||||||
displayed_sidebar: referenceSidebar
|
|
||||||
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/utils/types.ts#L45
|
|
||||||
---
|
|
||||||
|
|
||||||
# `SignInResponse`
|
|
||||||
|
|
||||||
## Parameters
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
**<span className="parameter-name">session</span>** <span className="optional-status">required</span> `null` | [`Session`](/reference/docgen/javascript/auth/types/session)
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
**<span className="parameter-name">mfa</span>** <span className="optional-status">required</span> `null` | `{ ticket: string }`
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
**<span className="parameter-name">error</span>** <span className="optional-status">required</span> `null` | `ErrorPayload`
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
**<span className="parameter-name">providerUrl</span>** <span className="optional-status">optional</span> `string`
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
**<span className="parameter-name">provider</span>** <span className="optional-status">optional</span> `string`
|
|
||||||
|
|
||||||
---
|
|
||||||
@@ -4,7 +4,7 @@ title: SignInWithProviderOptions
|
|||||||
sidebar_label: SignInWithProviderOptions
|
sidebar_label: SignInWithProviderOptions
|
||||||
description: No description provided.
|
description: No description provided.
|
||||||
displayed_sidebar: referenceSidebar
|
displayed_sidebar: referenceSidebar
|
||||||
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/utils/types.ts#L78
|
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/utils/types.ts#L54
|
||||||
---
|
---
|
||||||
|
|
||||||
# `SignInWithProviderOptions`
|
# `SignInWithProviderOptions`
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ title: SignUpEmailPasswordParams
|
|||||||
sidebar_label: SignUpEmailPasswordParams
|
sidebar_label: SignUpEmailPasswordParams
|
||||||
description: No description provided.
|
description: No description provided.
|
||||||
displayed_sidebar: referenceSidebar
|
displayed_sidebar: referenceSidebar
|
||||||
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/utils/types.ts#L31
|
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/utils/types.ts#L23
|
||||||
---
|
---
|
||||||
|
|
||||||
# `SignUpEmailPasswordParams`
|
# `SignUpEmailPasswordParams`
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ title: SignUpParams
|
|||||||
sidebar_label: SignUpParams
|
sidebar_label: SignUpParams
|
||||||
description: No description provided.
|
description: No description provided.
|
||||||
displayed_sidebar: referenceSidebar
|
displayed_sidebar: referenceSidebar
|
||||||
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/utils/types.ts#L37
|
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/utils/types.ts#L29
|
||||||
---
|
---
|
||||||
|
|
||||||
# `SignUpParams`
|
# `SignUpParams`
|
||||||
|
|||||||
@@ -1,16 +0,0 @@
|
|||||||
---
|
|
||||||
# ⚠️ AUTO-GENERATED CONTENT. DO NOT EDIT THIS FILE DIRECTLY! ⚠️
|
|
||||||
title: SignUpResponse
|
|
||||||
sidebar_label: SignUpResponse
|
|
||||||
description: No description provided.
|
|
||||||
displayed_sidebar: referenceSidebar
|
|
||||||
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/utils/types.ts#L39
|
|
||||||
---
|
|
||||||
|
|
||||||
# `SignUpResponse`
|
|
||||||
|
|
||||||
```ts
|
|
||||||
type SignUpResponse =
|
|
||||||
| { session: null; error: ErrorPayload }
|
|
||||||
| { session: Session | null; error: null }
|
|
||||||
```
|
|
||||||
@@ -4,7 +4,7 @@ title: User
|
|||||||
sidebar_label: User
|
sidebar_label: User
|
||||||
description: User information
|
description: User information
|
||||||
displayed_sidebar: referenceSidebar
|
displayed_sidebar: referenceSidebar
|
||||||
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/core/src/types.ts#L93
|
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/core/src/types.ts#L94
|
||||||
---
|
---
|
||||||
|
|
||||||
# `User`
|
# `User`
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ title: NhostSession
|
|||||||
sidebar_label: NhostSession
|
sidebar_label: NhostSession
|
||||||
description: No description provided.
|
description: No description provided.
|
||||||
displayed_sidebar: referenceSidebar
|
displayed_sidebar: referenceSidebar
|
||||||
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/core/src/types.ts#L128
|
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/core/src/types.ts#L129
|
||||||
---
|
---
|
||||||
|
|
||||||
# `NhostSession`
|
# `NhostSession`
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ services:
|
|||||||
auth:
|
auth:
|
||||||
image: nhost/hasura-auth:0.10.0
|
image: nhost/hasura-auth:0.10.0
|
||||||
storage:
|
storage:
|
||||||
image: nhost/hasura-storage:0.2.3
|
image: nhost/hasura-storage:0.2.4
|
||||||
auth:
|
auth:
|
||||||
access_control:
|
access_control:
|
||||||
email:
|
email:
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ services:
|
|||||||
auth:
|
auth:
|
||||||
image: nhost/hasura-auth:0.10.0
|
image: nhost/hasura-auth:0.10.0
|
||||||
storage:
|
storage:
|
||||||
image: nhost/hasura-storage:0.2.3
|
image: nhost/hasura-storage:0.2.4
|
||||||
auth:
|
auth:
|
||||||
access_control:
|
access_control:
|
||||||
email:
|
email:
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ services:
|
|||||||
auth:
|
auth:
|
||||||
image: nhost/hasura-auth:0.10.0
|
image: nhost/hasura-auth:0.10.0
|
||||||
storage:
|
storage:
|
||||||
image: nhost/hasura-storage:0.2.3
|
image: nhost/hasura-storage:0.2.4
|
||||||
auth:
|
auth:
|
||||||
access_control:
|
access_control:
|
||||||
email:
|
email:
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ services:
|
|||||||
auth:
|
auth:
|
||||||
image: nhost/hasura-auth:0.10.0
|
image: nhost/hasura-auth:0.10.0
|
||||||
storage:
|
storage:
|
||||||
image: nhost/hasura-storage:0.2.3
|
image: nhost/hasura-storage:0.2.4
|
||||||
auth:
|
auth:
|
||||||
access_control:
|
access_control:
|
||||||
email:
|
email:
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ services:
|
|||||||
auth:
|
auth:
|
||||||
image: nhost/hasura-auth:0.10.0
|
image: nhost/hasura-auth:0.10.0
|
||||||
storage:
|
storage:
|
||||||
image: nhost/hasura-storage:0.2.3
|
image: nhost/hasura-storage:0.2.4
|
||||||
auth:
|
auth:
|
||||||
access_control:
|
access_control:
|
||||||
email:
|
email:
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ services:
|
|||||||
auth:
|
auth:
|
||||||
image: nhost/hasura-auth:0.10.0
|
image: nhost/hasura-auth:0.10.0
|
||||||
storage:
|
storage:
|
||||||
image: nhost/hasura-storage:0.2.3
|
image: nhost/hasura-storage:0.2.4
|
||||||
auth:
|
auth:
|
||||||
access_control:
|
access_control:
|
||||||
email:
|
email:
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ services:
|
|||||||
auth:
|
auth:
|
||||||
image: nhost/hasura-auth:0.10.0
|
image: nhost/hasura-auth:0.10.0
|
||||||
storage:
|
storage:
|
||||||
image: nhost/hasura-storage:0.2.3
|
image: nhost/hasura-storage:0.2.4
|
||||||
auth:
|
auth:
|
||||||
access_control:
|
access_control:
|
||||||
email:
|
email:
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
# Docker image versions used in the cloud
|
# Docker image versions used in the cloud
|
||||||
hasura: v2.10.1
|
hasura: v2.10.1
|
||||||
auth: 0.10.0
|
auth: 0.10.0
|
||||||
storage: 0.2.3
|
storage: 0.2.4
|
||||||
|
|||||||
@@ -1,5 +1,11 @@
|
|||||||
# @nhost/apollo
|
# @nhost/apollo
|
||||||
|
|
||||||
|
## 0.5.28
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- @nhost/nhost-js@1.4.11
|
||||||
|
|
||||||
## 0.5.27
|
## 0.5.27
|
||||||
|
|
||||||
### Patch Changes
|
### Patch Changes
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@nhost/apollo",
|
"name": "@nhost/apollo",
|
||||||
"version": "0.5.27",
|
"version": "0.5.28",
|
||||||
"description": "Nhost Apollo Client library",
|
"description": "Nhost Apollo Client library",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import { assign, createMachine, send } from 'xstate'
|
|||||||
import { AuthClient } from '../client'
|
import { AuthClient } from '../client'
|
||||||
import { ErrorPayload, INVALID_EMAIL_ERROR } from '../errors'
|
import { ErrorPayload, INVALID_EMAIL_ERROR } from '../errors'
|
||||||
import { nhostApiClient } from '../hasura-auth'
|
import { nhostApiClient } from '../hasura-auth'
|
||||||
import { ChangeEmailOptions } from '../types'
|
import { ChangeEmailOptions, ChangeEmailResponse } from '../types'
|
||||||
import { rewriteRedirectTo } from '../utils'
|
import { rewriteRedirectTo } from '../utils'
|
||||||
import { isValidEmail } from '../validators'
|
import { isValidEmail } from '../validators'
|
||||||
|
|
||||||
@@ -20,6 +20,10 @@ export type ChangeEmailEvents =
|
|||||||
| { type: 'SUCCESS' }
|
| { type: 'SUCCESS' }
|
||||||
| { type: 'ERROR'; error: ErrorPayload | null }
|
| { type: 'ERROR'; error: ErrorPayload | null }
|
||||||
|
|
||||||
|
export type ChangeEmailServices = {
|
||||||
|
request: { data: ChangeEmailResponse }
|
||||||
|
}
|
||||||
|
|
||||||
export type ChangeEmailMachine = ReturnType<typeof createChangeEmailMachine>
|
export type ChangeEmailMachine = ReturnType<typeof createChangeEmailMachine>
|
||||||
|
|
||||||
export const createChangeEmailMachine = ({ backendUrl, clientUrl, interpreter }: AuthClient) => {
|
export const createChangeEmailMachine = ({ backendUrl, clientUrl, interpreter }: AuthClient) => {
|
||||||
@@ -28,7 +32,8 @@ export const createChangeEmailMachine = ({ backendUrl, clientUrl, interpreter }:
|
|||||||
{
|
{
|
||||||
schema: {
|
schema: {
|
||||||
context: {} as ChangeEmailContext,
|
context: {} as ChangeEmailContext,
|
||||||
events: {} as ChangeEmailEvents
|
events: {} as ChangeEmailEvents,
|
||||||
|
services: {} as ChangeEmailServices
|
||||||
},
|
},
|
||||||
tsTypes: {} as import('./change-email.typegen').Typegen0,
|
tsTypes: {} as import('./change-email.typegen').Typegen0,
|
||||||
preserveActionOrder: true,
|
preserveActionOrder: true,
|
||||||
@@ -70,6 +75,7 @@ export const createChangeEmailMachine = ({ backendUrl, clientUrl, interpreter }:
|
|||||||
actions: {
|
actions: {
|
||||||
saveInvalidEmailError: assign({ error: (_) => INVALID_EMAIL_ERROR }),
|
saveInvalidEmailError: assign({ error: (_) => INVALID_EMAIL_ERROR }),
|
||||||
saveRequestError: assign({
|
saveRequestError: assign({
|
||||||
|
// * Untyped action payload. See https://github.com/statelyai/xstate/issues/3037
|
||||||
error: (_, { data: { error } }: any) => error
|
error: (_, { data: { error } }: any) => error
|
||||||
}),
|
}),
|
||||||
reportError: send((ctx) => ({ type: 'ERROR', error: ctx.error })),
|
reportError: send((ctx) => ({ type: 'ERROR', error: ctx.error })),
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import { assign, createMachine, send } from 'xstate'
|
|||||||
import { AuthClient } from '../client'
|
import { AuthClient } from '../client'
|
||||||
import { ErrorPayload, INVALID_PASSWORD_ERROR } from '../errors'
|
import { ErrorPayload, INVALID_PASSWORD_ERROR } from '../errors'
|
||||||
import { nhostApiClient } from '../hasura-auth'
|
import { nhostApiClient } from '../hasura-auth'
|
||||||
|
import { ChangePasswordResponse } from '../types'
|
||||||
import { isValidPassword } from '../validators'
|
import { isValidPassword } from '../validators'
|
||||||
|
|
||||||
export type ChangePasswordContext = {
|
export type ChangePasswordContext = {
|
||||||
@@ -17,6 +18,10 @@ export type ChangePasswordEvents =
|
|||||||
| { type: 'SUCCESS' }
|
| { type: 'SUCCESS' }
|
||||||
| { type: 'ERROR'; error: ErrorPayload | null }
|
| { type: 'ERROR'; error: ErrorPayload | null }
|
||||||
|
|
||||||
|
export type ChangePasswordServices = {
|
||||||
|
requestChange: { data: ChangePasswordResponse }
|
||||||
|
}
|
||||||
|
|
||||||
export type ChangePasswordMachine = ReturnType<typeof createChangePasswordMachine>
|
export type ChangePasswordMachine = ReturnType<typeof createChangePasswordMachine>
|
||||||
|
|
||||||
export const createChangePasswordMachine = ({ backendUrl, interpreter }: AuthClient) => {
|
export const createChangePasswordMachine = ({ backendUrl, interpreter }: AuthClient) => {
|
||||||
@@ -25,7 +30,8 @@ export const createChangePasswordMachine = ({ backendUrl, interpreter }: AuthCli
|
|||||||
{
|
{
|
||||||
schema: {
|
schema: {
|
||||||
context: {} as ChangePasswordContext,
|
context: {} as ChangePasswordContext,
|
||||||
events: {} as ChangePasswordEvents
|
events: {} as ChangePasswordEvents,
|
||||||
|
services: {} as ChangePasswordServices
|
||||||
},
|
},
|
||||||
tsTypes: {} as import('./change-password.typegen').Typegen0,
|
tsTypes: {} as import('./change-password.typegen').Typegen0,
|
||||||
preserveActionOrder: true,
|
preserveActionOrder: true,
|
||||||
@@ -67,6 +73,7 @@ export const createChangePasswordMachine = ({ backendUrl, interpreter }: AuthCli
|
|||||||
actions: {
|
actions: {
|
||||||
saveInvalidPasswordError: assign({ error: (_) => INVALID_PASSWORD_ERROR }),
|
saveInvalidPasswordError: assign({ error: (_) => INVALID_PASSWORD_ERROR }),
|
||||||
saveRequestError: assign({
|
saveRequestError: assign({
|
||||||
|
// * Untyped action payload. See https://github.com/statelyai/xstate/issues/3037
|
||||||
error: (_, { data: { error } }: any) => error
|
error: (_, { data: { error } }: any) => error
|
||||||
}),
|
}),
|
||||||
reportError: send((ctx) => ({ type: 'ERROR', error: ctx.error })),
|
reportError: send((ctx) => ({ type: 'ERROR', error: ctx.error })),
|
||||||
@@ -77,7 +84,7 @@ export const createChangePasswordMachine = ({ backendUrl, interpreter }: AuthCli
|
|||||||
},
|
},
|
||||||
services: {
|
services: {
|
||||||
requestChange: (_, { password, ticket }) =>
|
requestChange: (_, { password, ticket }) =>
|
||||||
api.post<string, { data: { error?: ErrorPayload } }>(
|
api.post<string, ChangePasswordResponse>(
|
||||||
'/user/password',
|
'/user/password',
|
||||||
{ newPassword: password, ticket: ticket },
|
{ newPassword: password, ticket: ticket },
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import type { AxiosRequestConfig, AxiosResponse } from 'axios'
|
import type { AxiosRequestConfig } from 'axios'
|
||||||
import { assign, createMachine, send } from 'xstate'
|
import { assign, createMachine, send } from 'xstate'
|
||||||
|
|
||||||
import {
|
import {
|
||||||
@@ -18,7 +18,21 @@ import {
|
|||||||
} from '../errors'
|
} from '../errors'
|
||||||
import { nhostApiClient } from '../hasura-auth'
|
import { nhostApiClient } from '../hasura-auth'
|
||||||
import { localStorageGetter, localStorageSetter } from '../storage'
|
import { localStorageGetter, localStorageSetter } from '../storage'
|
||||||
import { AuthOptions, Mfa, NhostSession } from '../types'
|
import {
|
||||||
|
AuthOptions,
|
||||||
|
DeanonymizeResponse,
|
||||||
|
NhostSession,
|
||||||
|
NhostSessionResponse,
|
||||||
|
PasswordlessEmailResponse,
|
||||||
|
PasswordlessSmsOtpResponse,
|
||||||
|
PasswordlessSmsResponse,
|
||||||
|
RefreshSessionResponse,
|
||||||
|
SignInAnonymousResponse,
|
||||||
|
SignInMfaTotpResponse,
|
||||||
|
SignInResponse,
|
||||||
|
SignOutResponse,
|
||||||
|
SignUpResponse
|
||||||
|
} from '../types'
|
||||||
import { getParameterByName, removeParameterFromWindow, rewriteRedirectTo } from '../utils'
|
import { getParameterByName, removeParameterFromWindow, rewriteRedirectTo } from '../utils'
|
||||||
import { isValidEmail, isValidPassword, isValidPhoneNumber, isValidTicket } from '../validators'
|
import { isValidEmail, isValidPassword, isValidPhoneNumber, isValidTicket } from '../validators'
|
||||||
|
|
||||||
@@ -40,6 +54,18 @@ export interface AuthMachineOptions extends AuthOptions {
|
|||||||
|
|
||||||
export type AuthMachine = ReturnType<typeof createAuthMachine>
|
export type AuthMachine = ReturnType<typeof createAuthMachine>
|
||||||
|
|
||||||
|
type AuthServices = {
|
||||||
|
signInPassword: { data: SignInResponse }
|
||||||
|
passwordlessSms: { data: PasswordlessSmsResponse | DeanonymizeResponse }
|
||||||
|
passwordlessSmsOtp: { data: PasswordlessSmsOtpResponse }
|
||||||
|
passwordlessEmail: { data: PasswordlessEmailResponse | DeanonymizeResponse }
|
||||||
|
signInAnonymous: { data: SignInAnonymousResponse }
|
||||||
|
signInMfaTotp: { data: SignInMfaTotpResponse }
|
||||||
|
refreshToken: { data: NhostSessionResponse }
|
||||||
|
signout: { data: SignOutResponse }
|
||||||
|
signUpEmailPassword: { data: SignUpResponse }
|
||||||
|
importRefreshToken: { data: NhostSessionResponse }
|
||||||
|
}
|
||||||
// TODO actions typings
|
// TODO actions typings
|
||||||
|
|
||||||
export const createAuthMachine = ({
|
export const createAuthMachine = ({
|
||||||
@@ -56,19 +82,21 @@ export const createAuthMachine = ({
|
|||||||
const storageGetter = clientStorageGetter || localStorageGetter(clientStorageType, clientStorage)
|
const storageGetter = clientStorageGetter || localStorageGetter(clientStorageType, clientStorage)
|
||||||
const storageSetter = clientStorageSetter || localStorageSetter(clientStorageType, clientStorage)
|
const storageSetter = clientStorageSetter || localStorageSetter(clientStorageType, clientStorage)
|
||||||
const api = nhostApiClient(backendUrl)
|
const api = nhostApiClient(backendUrl)
|
||||||
const postRequest = async <T = any, R = AxiosResponse<T>, D = any>(
|
const postRequest = async <T = any, D = any>(
|
||||||
url: string,
|
url: string,
|
||||||
data?: D,
|
data?: D,
|
||||||
config?: AxiosRequestConfig<D>
|
config?: AxiosRequestConfig<D>
|
||||||
): Promise<R> => {
|
): Promise<T> => {
|
||||||
const result = await api.post(url, data, config)
|
const result = await api.post(url, data, config)
|
||||||
|
|
||||||
return result.data
|
return result.data
|
||||||
}
|
}
|
||||||
return createMachine(
|
return createMachine(
|
||||||
{
|
{
|
||||||
schema: {
|
schema: {
|
||||||
context: {} as AuthContext,
|
context: {} as AuthContext,
|
||||||
events: {} as AuthEvents
|
events: {} as AuthEvents,
|
||||||
|
services: {} as AuthServices
|
||||||
},
|
},
|
||||||
tsTypes: {} as import('./index.typegen').Typegen0,
|
tsTypes: {} as import('./index.typegen').Typegen0,
|
||||||
context: INITIAL_MACHINE_CONTEXT,
|
context: INITIAL_MACHINE_CONTEXT,
|
||||||
@@ -429,33 +457,37 @@ export const createAuthMachine = ({
|
|||||||
|
|
||||||
// * Save session in the context, and persist the refresh token and the jwt expiration outside of the machine
|
// * Save session in the context, and persist the refresh token and the jwt expiration outside of the machine
|
||||||
saveSession: assign({
|
saveSession: assign({
|
||||||
user: (_, { data }: any) => data?.session?.user,
|
user: (_, { data }) => data?.session?.user || null,
|
||||||
accessToken: (_, { data }: any) => {
|
accessToken: (_, { data }) => {
|
||||||
if (data.session.accessTokenExpiresIn) {
|
if (data.session) {
|
||||||
const nextRefresh = new Date(
|
const { accessTokenExpiresIn, accessToken } = data.session
|
||||||
Date.now() + data.session.accessTokenExpiresIn * 1_000
|
const nextRefresh = new Date(Date.now() + accessTokenExpiresIn * 1_000)
|
||||||
).toISOString()
|
storageSetter(NHOST_JWT_EXPIRES_AT_KEY, nextRefresh.toISOString())
|
||||||
storageSetter(NHOST_JWT_EXPIRES_AT_KEY, nextRefresh)
|
return {
|
||||||
} else {
|
value: accessToken,
|
||||||
storageSetter(NHOST_JWT_EXPIRES_AT_KEY, null)
|
expiresAt: nextRefresh
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
storageSetter(NHOST_JWT_EXPIRES_AT_KEY, null)
|
||||||
return {
|
return {
|
||||||
value: data?.session?.accessToken,
|
value: null,
|
||||||
expiresAt: new Date(Date.now() + data?.session?.accessTokenExpiresIn * 1_000)
|
expiresAt: null
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
refreshToken: (_, { data }: any) => {
|
refreshToken: (_, { data }) => {
|
||||||
storageSetter(NHOST_REFRESH_TOKEN_KEY, data.session.refreshToken)
|
const refreshToken = data.session?.refreshToken || null
|
||||||
|
if (refreshToken) {
|
||||||
return { value: data?.session?.refreshToken }
|
storageSetter(NHOST_REFRESH_TOKEN_KEY, refreshToken)
|
||||||
|
}
|
||||||
|
return { value: refreshToken }
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
saveMfaTicket: assign({
|
saveMfaTicket: assign({
|
||||||
mfa: (_, e: any) => e.data?.mfa
|
mfa: (_, e) => e.data?.mfa
|
||||||
}),
|
}),
|
||||||
|
|
||||||
resetTimer: assign({
|
resetTimer: assign({
|
||||||
refreshTimer: (ctx, e) => ({
|
refreshTimer: (_) => ({
|
||||||
startedAt: new Date(),
|
startedAt: new Date(),
|
||||||
attempts: 0,
|
attempts: 0,
|
||||||
lastAttempt: null
|
lastAttempt: null
|
||||||
@@ -472,12 +504,17 @@ export const createAuthMachine = ({
|
|||||||
|
|
||||||
// * Authentication errors
|
// * Authentication errors
|
||||||
saveAuthenticationError: assign({
|
saveAuthenticationError: assign({
|
||||||
errors: ({ errors }, { data: { error } }: any) => ({ ...errors, authentication: error })
|
// * Untyped action payload. See https://github.com/statelyai/xstate/issues/3037
|
||||||
|
errors: ({ errors }, { data: { error } }: any) => ({
|
||||||
|
...errors,
|
||||||
|
authentication: error
|
||||||
|
})
|
||||||
}),
|
}),
|
||||||
resetErrors: assign({
|
resetErrors: assign({
|
||||||
errors: (_) => ({})
|
errors: (_) => ({})
|
||||||
}),
|
}),
|
||||||
saveRegistrationError: assign({
|
saveRegistrationError: assign({
|
||||||
|
// * Untyped action payload. See https://github.com/statelyai/xstate/issues/3037
|
||||||
errors: ({ errors }, { data: { error } }: any) => ({ ...errors, registration: error })
|
errors: ({ errors }, { data: { error } }: any) => ({ ...errors, registration: error })
|
||||||
}),
|
}),
|
||||||
destroyRefreshToken: assign({
|
destroyRefreshToken: assign({
|
||||||
@@ -541,14 +578,15 @@ export const createAuthMachine = ({
|
|||||||
return remaining <= 0
|
return remaining <= 0
|
||||||
},
|
},
|
||||||
// * Authentication errors
|
// * Authentication errors
|
||||||
|
// * Untyped action payload. See https://github.com/statelyai/xstate/issues/3037
|
||||||
unverified: (_, { data: { error } }: any) =>
|
unverified: (_, { data: { error } }: any) =>
|
||||||
error.status === 401 &&
|
error.status === 401 &&
|
||||||
// * legacy: don't use the message contents to determine if the email is unverified, but the error type (error.error)
|
// * legacy: don't use the message contents to determine if the email is unverified, but the error type (error.error)
|
||||||
(error.message === 'Email is not verified' || error.error === 'unverified-user'),
|
(error.message === 'Email is not verified' || error.error === 'unverified-user'),
|
||||||
|
|
||||||
// * Event guards
|
// * Event guards
|
||||||
hasSession: (_, e: any) => !!e.data?.session,
|
hasSession: (_, e) => !!e.data?.session,
|
||||||
hasMfaTicket: (_, e: any) => !!e.data?.mfa
|
hasMfaTicket: (_, e) => !!e.data?.mfa
|
||||||
},
|
},
|
||||||
|
|
||||||
services: {
|
services: {
|
||||||
@@ -559,7 +597,7 @@ export const createAuthMachine = ({
|
|||||||
if (!isValidPassword(password)) {
|
if (!isValidPassword(password)) {
|
||||||
return Promise.reject({ error: INVALID_PASSWORD_ERROR })
|
return Promise.reject({ error: INVALID_PASSWORD_ERROR })
|
||||||
}
|
}
|
||||||
return postRequest('/signin/email-password', {
|
return postRequest<SignInResponse>('/signin/email-password', {
|
||||||
email,
|
email,
|
||||||
password
|
password
|
||||||
})
|
})
|
||||||
@@ -632,7 +670,7 @@ export const createAuthMachine = ({
|
|||||||
},
|
},
|
||||||
signInAnonymous: (_) => postRequest('/signin/anonymous'),
|
signInAnonymous: (_) => postRequest('/signin/anonymous'),
|
||||||
signInMfaTotp: (context, data) => {
|
signInMfaTotp: (context, data) => {
|
||||||
const ticket = data.ticket || context.mfa?.ticket
|
const ticket: string | undefined = data.ticket || context.mfa?.ticket
|
||||||
if (!ticket) {
|
if (!ticket) {
|
||||||
return Promise.reject({ error: NO_MFA_TICKET_ERROR })
|
return Promise.reject({ error: NO_MFA_TICKET_ERROR })
|
||||||
}
|
}
|
||||||
@@ -640,20 +678,17 @@ export const createAuthMachine = ({
|
|||||||
return Promise.reject({ error: INVALID_MFA_TICKET_ERROR })
|
return Promise.reject({ error: INVALID_MFA_TICKET_ERROR })
|
||||||
}
|
}
|
||||||
|
|
||||||
return postRequest<
|
return postRequest('/signin/mfa/totp', {
|
||||||
{ mfa: Mfa | null; session: NhostSession | null },
|
|
||||||
{ mfa: Mfa | null; session: NhostSession | null }
|
|
||||||
>('/signin/mfa/totp', {
|
|
||||||
ticket,
|
ticket,
|
||||||
otp: data.otp
|
otp: data.otp
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
refreshToken: async (ctx, event) => {
|
refreshToken: async (ctx, event) => {
|
||||||
const refreshToken = event.type === 'TRY_TOKEN' ? event.token : ctx.refreshToken.value
|
const refreshToken = event.type === 'TRY_TOKEN' ? event.token : ctx.refreshToken.value
|
||||||
const session = await postRequest('/token', {
|
const session = await postRequest<RefreshSessionResponse>('/token', {
|
||||||
refreshToken
|
refreshToken
|
||||||
})
|
})
|
||||||
return { session }
|
return { session, error: null }
|
||||||
},
|
},
|
||||||
signout: (ctx, e) =>
|
signout: (ctx, e) =>
|
||||||
postRequest('/signout', {
|
postRequest('/signout', {
|
||||||
@@ -662,13 +697,13 @@ export const createAuthMachine = ({
|
|||||||
}),
|
}),
|
||||||
signUpEmailPassword: async (context, { email, password, options }) => {
|
signUpEmailPassword: async (context, { email, password, options }) => {
|
||||||
if (!isValidEmail(email)) {
|
if (!isValidEmail(email)) {
|
||||||
return Promise.reject({ error: INVALID_EMAIL_ERROR })
|
return Promise.reject<SignUpResponse>({ error: INVALID_EMAIL_ERROR })
|
||||||
}
|
}
|
||||||
if (!isValidPassword(password)) {
|
if (!isValidPassword(password)) {
|
||||||
return Promise.reject({ error: INVALID_PASSWORD_ERROR })
|
return Promise.reject<SignUpResponse>({ error: INVALID_PASSWORD_ERROR })
|
||||||
}
|
}
|
||||||
if (context.user?.isAnonymous) {
|
if (context.user?.isAnonymous) {
|
||||||
return postRequest(
|
return postRequest<SignUpResponse>(
|
||||||
'/user/deanonymize',
|
'/user/deanonymize',
|
||||||
{
|
{
|
||||||
signInMethod: 'email-password',
|
signInMethod: 'email-password',
|
||||||
@@ -683,7 +718,7 @@ export const createAuthMachine = ({
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
return postRequest('/signup/email-password', {
|
return postRequest<SignUpResponse>('/signup/email-password', {
|
||||||
email,
|
email,
|
||||||
password,
|
password,
|
||||||
options: rewriteRedirectTo(clientUrl, options)
|
options: rewriteRedirectTo(clientUrl, options)
|
||||||
@@ -697,17 +732,18 @@ export const createAuthMachine = ({
|
|||||||
const urlToken = getParameterByName('refreshToken') || null
|
const urlToken = getParameterByName('refreshToken') || null
|
||||||
if (urlToken) {
|
if (urlToken) {
|
||||||
try {
|
try {
|
||||||
const session = await postRequest('/token', {
|
const session = await postRequest<NhostSession>('/token', {
|
||||||
refreshToken: urlToken
|
refreshToken: urlToken
|
||||||
})
|
})
|
||||||
return { session }
|
return { session, error: null }
|
||||||
} catch (exception) {
|
} catch (exception) {
|
||||||
error = (exception as { error: ValidationErrorPayload }).error
|
error = (exception as { error: ValidationErrorPayload }).error
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
const error = getParameterByName('error')
|
const error = getParameterByName('error')
|
||||||
if (error) {
|
if (error) {
|
||||||
return Promise.reject<{ error: ValidationErrorPayload }>({
|
return Promise.reject<NhostSessionResponse>({
|
||||||
|
session: null,
|
||||||
error: {
|
error: {
|
||||||
status: VALIDATION_ERROR_CODE,
|
status: VALIDATION_ERROR_CODE,
|
||||||
error,
|
error,
|
||||||
@@ -720,16 +756,15 @@ export const createAuthMachine = ({
|
|||||||
const storageToken = await storageGetter(NHOST_REFRESH_TOKEN_KEY)
|
const storageToken = await storageGetter(NHOST_REFRESH_TOKEN_KEY)
|
||||||
if (storageToken) {
|
if (storageToken) {
|
||||||
try {
|
try {
|
||||||
const session = await postRequest('/token', {
|
const session = await postRequest<NhostSession>('/token', {
|
||||||
refreshToken: storageToken
|
refreshToken: storageToken
|
||||||
})
|
})
|
||||||
return { session }
|
return { session, error: null }
|
||||||
} catch (exception) {
|
} catch (exception) {
|
||||||
error = (exception as { error: ValidationErrorPayload }).error
|
error = (exception as { error: ValidationErrorPayload }).error
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return Promise.reject<NhostSessionResponse>({ error })
|
||||||
return Promise.reject<{ error: ValidationErrorPayload }>({ error })
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import { assign, createMachine, send } from 'xstate'
|
|||||||
import { AuthClient } from '../client'
|
import { AuthClient } from '../client'
|
||||||
import { ErrorPayload, INVALID_EMAIL_ERROR } from '../errors'
|
import { ErrorPayload, INVALID_EMAIL_ERROR } from '../errors'
|
||||||
import { nhostApiClient } from '../hasura-auth'
|
import { nhostApiClient } from '../hasura-auth'
|
||||||
import { ResetPasswordOptions } from '../types'
|
import { ResetPasswordOptions, ResetPasswordResponse } from '../types'
|
||||||
import { rewriteRedirectTo } from '../utils'
|
import { rewriteRedirectTo } from '../utils'
|
||||||
import { isValidEmail } from '../validators'
|
import { isValidEmail } from '../validators'
|
||||||
|
|
||||||
@@ -19,6 +19,10 @@ export type ResetPasswordEvents =
|
|||||||
| { type: 'SUCCESS' }
|
| { type: 'SUCCESS' }
|
||||||
| { type: 'ERROR'; error: ErrorPayload | null }
|
| { type: 'ERROR'; error: ErrorPayload | null }
|
||||||
|
|
||||||
|
export type ResetPasswordServices = {
|
||||||
|
requestChange: { data: ResetPasswordResponse }
|
||||||
|
}
|
||||||
|
|
||||||
export type ResetPasswordMachine = ReturnType<typeof createResetPasswordMachine>
|
export type ResetPasswordMachine = ReturnType<typeof createResetPasswordMachine>
|
||||||
|
|
||||||
export const createResetPasswordMachine = ({ backendUrl, clientUrl }: AuthClient) => {
|
export const createResetPasswordMachine = ({ backendUrl, clientUrl }: AuthClient) => {
|
||||||
@@ -27,7 +31,8 @@ export const createResetPasswordMachine = ({ backendUrl, clientUrl }: AuthClient
|
|||||||
{
|
{
|
||||||
schema: {
|
schema: {
|
||||||
context: {} as ResetPasswordContext,
|
context: {} as ResetPasswordContext,
|
||||||
events: {} as ResetPasswordEvents
|
events: {} as ResetPasswordEvents,
|
||||||
|
services: {} as ResetPasswordServices
|
||||||
},
|
},
|
||||||
tsTypes: {} as import('./reset-password.typegen').Typegen0,
|
tsTypes: {} as import('./reset-password.typegen').Typegen0,
|
||||||
preserveActionOrder: true,
|
preserveActionOrder: true,
|
||||||
@@ -69,6 +74,7 @@ export const createResetPasswordMachine = ({ backendUrl, clientUrl }: AuthClient
|
|||||||
actions: {
|
actions: {
|
||||||
saveInvalidEmailError: assign({ error: (_) => INVALID_EMAIL_ERROR }),
|
saveInvalidEmailError: assign({ error: (_) => INVALID_EMAIL_ERROR }),
|
||||||
saveRequestError: assign({
|
saveRequestError: assign({
|
||||||
|
// * Untyped action payload. See https://github.com/statelyai/xstate/issues/3037
|
||||||
error: (_, { data: { error } }: any) => error
|
error: (_, { data: { error } }: any) => error
|
||||||
}),
|
}),
|
||||||
reportError: send((ctx) => ({ type: 'ERROR', error: ctx.error })),
|
reportError: send((ctx) => ({ type: 'ERROR', error: ctx.error })),
|
||||||
@@ -79,7 +85,7 @@ export const createResetPasswordMachine = ({ backendUrl, clientUrl }: AuthClient
|
|||||||
},
|
},
|
||||||
services: {
|
services: {
|
||||||
requestChange: (_, { email, options }) =>
|
requestChange: (_, { email, options }) =>
|
||||||
api.post<string, { data: { error?: ErrorPayload } }>('/user/password/reset', {
|
api.post<string, ResetPasswordResponse>('/user/password/reset', {
|
||||||
email,
|
email,
|
||||||
options: rewriteRedirectTo(clientUrl, options)
|
options: rewriteRedirectTo(clientUrl, options)
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import { assign, createMachine, send } from 'xstate'
|
|||||||
import { AuthClient } from '../client'
|
import { AuthClient } from '../client'
|
||||||
import { ErrorPayload, INVALID_EMAIL_ERROR } from '../errors'
|
import { ErrorPayload, INVALID_EMAIL_ERROR } from '../errors'
|
||||||
import { nhostApiClient } from '../hasura-auth'
|
import { nhostApiClient } from '../hasura-auth'
|
||||||
import { SendVerificationEmailOptions } from '../types'
|
import { SendVerificationEmailOptions, SendVerificationEmailResponse } from '../types'
|
||||||
import { rewriteRedirectTo } from '../utils'
|
import { rewriteRedirectTo } from '../utils'
|
||||||
import { isValidEmail } from '../validators'
|
import { isValidEmail } from '../validators'
|
||||||
|
|
||||||
@@ -20,6 +20,10 @@ export type SendVerificationEmailEvents =
|
|||||||
| { type: 'SUCCESS' }
|
| { type: 'SUCCESS' }
|
||||||
| { type: 'ERROR'; error: ErrorPayload | null }
|
| { type: 'ERROR'; error: ErrorPayload | null }
|
||||||
|
|
||||||
|
export type SendVerificationEmailServices = {
|
||||||
|
request: { data: SendVerificationEmailResponse }
|
||||||
|
}
|
||||||
|
|
||||||
export type SendVerificationEmailMachine = ReturnType<typeof createSendVerificationEmailMachine>
|
export type SendVerificationEmailMachine = ReturnType<typeof createSendVerificationEmailMachine>
|
||||||
export const createSendVerificationEmailMachine = ({ backendUrl, clientUrl }: AuthClient) => {
|
export const createSendVerificationEmailMachine = ({ backendUrl, clientUrl }: AuthClient) => {
|
||||||
const api = nhostApiClient(backendUrl)
|
const api = nhostApiClient(backendUrl)
|
||||||
@@ -27,7 +31,8 @@ export const createSendVerificationEmailMachine = ({ backendUrl, clientUrl }: Au
|
|||||||
{
|
{
|
||||||
schema: {
|
schema: {
|
||||||
context: {} as SendVerificationEmailContext,
|
context: {} as SendVerificationEmailContext,
|
||||||
events: {} as SendVerificationEmailEvents
|
events: {} as SendVerificationEmailEvents,
|
||||||
|
services: {} as SendVerificationEmailServices
|
||||||
},
|
},
|
||||||
tsTypes: {} as import('./send-verification-email.typegen').Typegen0,
|
tsTypes: {} as import('./send-verification-email.typegen').Typegen0,
|
||||||
preserveActionOrder: true,
|
preserveActionOrder: true,
|
||||||
@@ -69,6 +74,7 @@ export const createSendVerificationEmailMachine = ({ backendUrl, clientUrl }: Au
|
|||||||
actions: {
|
actions: {
|
||||||
saveInvalidEmailError: assign({ error: (_) => INVALID_EMAIL_ERROR }),
|
saveInvalidEmailError: assign({ error: (_) => INVALID_EMAIL_ERROR }),
|
||||||
saveRequestError: assign({
|
saveRequestError: assign({
|
||||||
|
// * Untyped action payload. See https://github.com/statelyai/xstate/issues/3037
|
||||||
error: (_, { data: { error } }: any) => error
|
error: (_, { data: { error } }: any) => error
|
||||||
}),
|
}),
|
||||||
reportError: send((ctx) => ({ type: 'ERROR', error: ctx.error })),
|
reportError: send((ctx) => ({ type: 'ERROR', error: ctx.error })),
|
||||||
@@ -79,10 +85,13 @@ export const createSendVerificationEmailMachine = ({ backendUrl, clientUrl }: Au
|
|||||||
},
|
},
|
||||||
services: {
|
services: {
|
||||||
request: async (_, { email, options }) => {
|
request: async (_, { email, options }) => {
|
||||||
const res = await api.post('/user/email/send-verification-email', {
|
const res = await api.post<SendVerificationEmailResponse>(
|
||||||
email,
|
'/user/email/send-verification-email',
|
||||||
options: rewriteRedirectTo(clientUrl, options)
|
{
|
||||||
})
|
email,
|
||||||
|
options: rewriteRedirectTo(clientUrl, options)
|
||||||
|
}
|
||||||
|
)
|
||||||
return res.data
|
return res.data
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
import { InterpreterFrom } from 'xstate'
|
import { InterpreterFrom } from 'xstate'
|
||||||
|
|
||||||
|
import { ErrorPayload } from './errors'
|
||||||
import { AuthMachine } from './machines'
|
import { AuthMachine } from './machines'
|
||||||
import { StorageGetter, StorageSetter } from './storage'
|
import { StorageGetter, StorageSetter } from './storage'
|
||||||
|
|
||||||
@@ -207,3 +208,61 @@ export type ClientStorageType =
|
|||||||
| 'react-native'
|
| 'react-native'
|
||||||
| 'web'
|
| 'web'
|
||||||
| 'cookie'
|
| 'cookie'
|
||||||
|
|
||||||
|
// Hasura-auth API response types
|
||||||
|
interface NullableErrorResponse {
|
||||||
|
error: ErrorPayload | null
|
||||||
|
}
|
||||||
|
|
||||||
|
/** session payload from common hasura-auth responses */
|
||||||
|
export type NhostSessionResponse =
|
||||||
|
| { session: null; error: ErrorPayload }
|
||||||
|
| { session: NhostSession | null; error: null }
|
||||||
|
|
||||||
|
/** payload from hasura-auth endpoint /signin/email-password */
|
||||||
|
export interface SignInResponse {
|
||||||
|
session: NhostSession | null
|
||||||
|
mfa: {
|
||||||
|
ticket: string
|
||||||
|
} | null
|
||||||
|
error: ErrorPayload | null
|
||||||
|
}
|
||||||
|
|
||||||
|
/** payload from hasura-auth endpoint /signup/email-password */
|
||||||
|
export type SignUpResponse = NhostSessionResponse
|
||||||
|
|
||||||
|
/** payload from hasura-auth endpoint /token */
|
||||||
|
export type RefreshSessionResponse = NhostSession
|
||||||
|
|
||||||
|
/** payload from hasura-auth endpoint /signout */
|
||||||
|
export interface SignOutResponse extends NullableErrorResponse {}
|
||||||
|
|
||||||
|
/** payload from hasura-auth endpoint /user/password/reset */
|
||||||
|
export interface ResetPasswordResponse extends NullableErrorResponse {}
|
||||||
|
|
||||||
|
/** payload from hasura-auth endpoint /user/password */
|
||||||
|
export interface ChangePasswordResponse extends NullableErrorResponse {}
|
||||||
|
|
||||||
|
/** payload from hasura-auth endpoint /user/email/send-verification-email */
|
||||||
|
export interface SendVerificationEmailResponse extends NullableErrorResponse {}
|
||||||
|
|
||||||
|
/** payload from hasura-auth endpoint /user/email/change */
|
||||||
|
export interface ChangeEmailResponse extends NullableErrorResponse {}
|
||||||
|
|
||||||
|
/** payload from hasura-auth endpoint /user/deanonymize */
|
||||||
|
export interface DeanonymizeResponse extends NullableErrorResponse {}
|
||||||
|
|
||||||
|
/** payload from hasura-auth endpoint /signin/passwordless/email */
|
||||||
|
export interface PasswordlessEmailResponse extends NullableErrorResponse {}
|
||||||
|
|
||||||
|
/** payload from hasura-auth endpoint /signin/passwordless/sms */
|
||||||
|
export interface PasswordlessSmsResponse extends NullableErrorResponse {}
|
||||||
|
|
||||||
|
/** payload from hasura-auth endpoint /signin/anonymous */
|
||||||
|
export type SignInAnonymousResponse = NhostSessionResponse
|
||||||
|
|
||||||
|
/** payload from hasura-auth endpoint /signin/anonymous */
|
||||||
|
export type PasswordlessSmsOtpResponse = NhostSessionResponse
|
||||||
|
|
||||||
|
/** payload from hasura-auth endpoint /signin/mfa/totp */
|
||||||
|
export type SignInMfaTotpResponse = NhostSessionResponse
|
||||||
|
|||||||
@@ -1,5 +1,11 @@
|
|||||||
# @nhost/hasura-auth-js
|
# @nhost/hasura-auth-js
|
||||||
|
|
||||||
|
## 1.4.2
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- a47ce291: Add options to `nhost.auth.signIn({ email, options })`
|
||||||
|
|
||||||
## 1.4.1
|
## 1.4.1
|
||||||
|
|
||||||
### Patch Changes
|
### Patch Changes
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ services:
|
|||||||
auth:
|
auth:
|
||||||
image: nhost/hasura-auth:0.10.0
|
image: nhost/hasura-auth:0.10.0
|
||||||
storage:
|
storage:
|
||||||
image: nhost/hasura-storage:0.2.3
|
image: nhost/hasura-storage:0.2.4
|
||||||
auth:
|
auth:
|
||||||
access_control:
|
access_control:
|
||||||
email:
|
email:
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@nhost/hasura-auth-js",
|
"name": "@nhost/hasura-auth-js",
|
||||||
"version": "1.4.1",
|
"version": "1.4.2",
|
||||||
"description": "Hasura-auth client",
|
"description": "Hasura-auth client",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
|
|||||||
@@ -5,40 +5,42 @@ import {
|
|||||||
AuthClient,
|
AuthClient,
|
||||||
AuthInterpreter,
|
AuthInterpreter,
|
||||||
changeEmailPromise,
|
changeEmailPromise,
|
||||||
|
ChangeEmailResponse,
|
||||||
changePasswordPromise,
|
changePasswordPromise,
|
||||||
|
ChangePasswordResponse,
|
||||||
createChangeEmailMachine,
|
createChangeEmailMachine,
|
||||||
createChangePasswordMachine,
|
createChangePasswordMachine,
|
||||||
createResetPasswordMachine,
|
createResetPasswordMachine,
|
||||||
createSendVerificationEmailMachine,
|
createSendVerificationEmailMachine,
|
||||||
|
DeanonymizeResponse,
|
||||||
EMAIL_NEEDS_VERIFICATION,
|
EMAIL_NEEDS_VERIFICATION,
|
||||||
encodeQueryParameters,
|
encodeQueryParameters,
|
||||||
ErrorPayload,
|
|
||||||
INVALID_REFRESH_TOKEN,
|
INVALID_REFRESH_TOKEN,
|
||||||
JWTClaims,
|
JWTClaims,
|
||||||
JWTHasuraClaims,
|
JWTHasuraClaims,
|
||||||
|
NhostSessionResponse,
|
||||||
NO_REFRESH_TOKEN,
|
NO_REFRESH_TOKEN,
|
||||||
resetPasswordPromise,
|
resetPasswordPromise,
|
||||||
|
ResetPasswordResponse,
|
||||||
rewriteRedirectTo,
|
rewriteRedirectTo,
|
||||||
sendVerificationEmailPromise,
|
sendVerificationEmailPromise,
|
||||||
|
SendVerificationEmailResponse,
|
||||||
signInAnonymousPromise,
|
signInAnonymousPromise,
|
||||||
signInEmailPasswordlessPromise,
|
signInEmailPasswordlessPromise,
|
||||||
signInEmailPasswordPromise,
|
signInEmailPasswordPromise,
|
||||||
signInMfaTotpPromise,
|
signInMfaTotpPromise,
|
||||||
|
SignInResponse,
|
||||||
signInSmsPasswordlessOtpPromise,
|
signInSmsPasswordlessOtpPromise,
|
||||||
signInSmsPasswordlessPromise,
|
signInSmsPasswordlessPromise,
|
||||||
signOutPromise,
|
signOutPromise,
|
||||||
|
SignOutResponse,
|
||||||
signUpEmailPasswordPromise,
|
signUpEmailPasswordPromise,
|
||||||
|
SignUpResponse,
|
||||||
TOKEN_REFRESHER_RUNNING_ERROR
|
TOKEN_REFRESHER_RUNNING_ERROR
|
||||||
} from '@nhost/core'
|
} from '@nhost/core'
|
||||||
|
|
||||||
import { getAuthenticationResult, getSession, isBrowser } from './utils/helpers'
|
import { getAuthenticationResult, getSession, isBrowser } from './utils/helpers'
|
||||||
import {
|
import {
|
||||||
ApiChangeEmailResponse,
|
|
||||||
ApiChangePasswordResponse,
|
|
||||||
ApiDeanonymizeResponse,
|
|
||||||
ApiResetPasswordResponse,
|
|
||||||
ApiSendVerificationEmailResponse,
|
|
||||||
ApiSignOutResponse,
|
|
||||||
AuthChangedFunction,
|
AuthChangedFunction,
|
||||||
ChangeEmailParams,
|
ChangeEmailParams,
|
||||||
ChangePasswordParams,
|
ChangePasswordParams,
|
||||||
@@ -47,11 +49,8 @@ import {
|
|||||||
OnTokenChangedFunction,
|
OnTokenChangedFunction,
|
||||||
ResetPasswordParams,
|
ResetPasswordParams,
|
||||||
SendVerificationEmailParams,
|
SendVerificationEmailParams,
|
||||||
Session,
|
|
||||||
SignInParams,
|
SignInParams,
|
||||||
SignInResponse,
|
SignUpParams
|
||||||
SignUpParams,
|
|
||||||
SignUpResponse
|
|
||||||
} from './utils/types'
|
} from './utils/types'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -143,7 +142,9 @@ export class HasuraAuthClient {
|
|||||||
*
|
*
|
||||||
* @docs https://docs.nhost.io/reference/javascript/auth/sign-in
|
* @docs https://docs.nhost.io/reference/javascript/auth/sign-in
|
||||||
*/
|
*/
|
||||||
async signIn(params: SignInParams): Promise<SignInResponse> {
|
async signIn(
|
||||||
|
params: SignInParams
|
||||||
|
): Promise<SignInResponse & { providerUrl?: string; provider?: string }> {
|
||||||
const interpreter = await this.waitUntilReady()
|
const interpreter = await this.waitUntilReady()
|
||||||
|
|
||||||
// * Sign in with a social provider (OAuth)
|
// * Sign in with a social provider (OAuth)
|
||||||
@@ -177,7 +178,8 @@ export class HasuraAuthClient {
|
|||||||
|
|
||||||
// * Passwordless Email (magic link)
|
// * Passwordless Email (magic link)
|
||||||
if ('email' in params) {
|
if ('email' in params) {
|
||||||
const { error } = await signInEmailPasswordlessPromise(interpreter, params.email)
|
const { email, options } = params
|
||||||
|
const { error } = await signInEmailPasswordlessPromise(interpreter, email, options)
|
||||||
return {
|
return {
|
||||||
session: null,
|
session: null,
|
||||||
mfa: null,
|
mfa: null,
|
||||||
@@ -228,7 +230,7 @@ export class HasuraAuthClient {
|
|||||||
*
|
*
|
||||||
* @docs https://docs.nhost.io/reference/javascript/auth/sign-out
|
* @docs https://docs.nhost.io/reference/javascript/auth/sign-out
|
||||||
*/
|
*/
|
||||||
async signOut(params?: { all?: boolean }): Promise<ApiSignOutResponse> {
|
async signOut(params?: { all?: boolean }): Promise<SignOutResponse> {
|
||||||
const interpreter = await this.waitUntilReady()
|
const interpreter = await this.waitUntilReady()
|
||||||
const { error } = await signOutPromise(interpreter, params?.all)
|
const { error } = await signOutPromise(interpreter, params?.all)
|
||||||
return { error }
|
return { error }
|
||||||
@@ -244,7 +246,7 @@ export class HasuraAuthClient {
|
|||||||
*
|
*
|
||||||
* @docs https://docs.nhost.io/reference/javascript/auth/reset-password
|
* @docs https://docs.nhost.io/reference/javascript/auth/reset-password
|
||||||
*/
|
*/
|
||||||
async resetPassword({ email, options }: ResetPasswordParams): Promise<ApiResetPasswordResponse> {
|
async resetPassword({ email, options }: ResetPasswordParams): Promise<ResetPasswordResponse> {
|
||||||
const service = interpret(createResetPasswordMachine(this._client)).start()
|
const service = interpret(createResetPasswordMachine(this._client)).start()
|
||||||
const { error } = await resetPasswordPromise(service, email, options)
|
const { error } = await resetPasswordPromise(service, email, options)
|
||||||
return { error }
|
return { error }
|
||||||
@@ -260,7 +262,10 @@ export class HasuraAuthClient {
|
|||||||
*
|
*
|
||||||
* @docs https://docs.nhost.io/reference/javascript/auth/change-password
|
* @docs https://docs.nhost.io/reference/javascript/auth/change-password
|
||||||
*/
|
*/
|
||||||
async changePassword({ newPassword, ticket }: ChangePasswordParams): Promise<ApiChangePasswordResponse> {
|
async changePassword({
|
||||||
|
newPassword,
|
||||||
|
ticket
|
||||||
|
}: ChangePasswordParams): Promise<ChangePasswordResponse> {
|
||||||
const service = interpret(createChangePasswordMachine(this._client)).start()
|
const service = interpret(createChangePasswordMachine(this._client)).start()
|
||||||
const { error } = await changePasswordPromise(service, newPassword, ticket)
|
const { error } = await changePasswordPromise(service, newPassword, ticket)
|
||||||
return { error }
|
return { error }
|
||||||
@@ -279,7 +284,7 @@ export class HasuraAuthClient {
|
|||||||
async sendVerificationEmail({
|
async sendVerificationEmail({
|
||||||
email,
|
email,
|
||||||
options
|
options
|
||||||
}: SendVerificationEmailParams): Promise<ApiSendVerificationEmailResponse> {
|
}: SendVerificationEmailParams): Promise<SendVerificationEmailResponse> {
|
||||||
const service = interpret(createSendVerificationEmailMachine(this._client)).start()
|
const service = interpret(createSendVerificationEmailMachine(this._client)).start()
|
||||||
const { error } = await sendVerificationEmailPromise(service, email, options)
|
const { error } = await sendVerificationEmailPromise(service, email, options)
|
||||||
return { error }
|
return { error }
|
||||||
@@ -295,7 +300,7 @@ export class HasuraAuthClient {
|
|||||||
*
|
*
|
||||||
* @docs https://docs.nhost.io/reference/javascript/auth/change-email
|
* @docs https://docs.nhost.io/reference/javascript/auth/change-email
|
||||||
*/
|
*/
|
||||||
async changeEmail({ newEmail, options }: ChangeEmailParams): Promise<ApiChangeEmailResponse> {
|
async changeEmail({ newEmail, options }: ChangeEmailParams): Promise<ChangeEmailResponse> {
|
||||||
const service = interpret(createChangeEmailMachine(this._client)).start()
|
const service = interpret(createChangeEmailMachine(this._client)).start()
|
||||||
const { error } = await changeEmailPromise(service, newEmail, options)
|
const { error } = await changeEmailPromise(service, newEmail, options)
|
||||||
return { error }
|
return { error }
|
||||||
@@ -311,7 +316,7 @@ export class HasuraAuthClient {
|
|||||||
*
|
*
|
||||||
* @docs https://docs.nhost.io/reference/javascript/auth/deanonymize
|
* @docs https://docs.nhost.io/reference/javascript/auth/deanonymize
|
||||||
*/
|
*/
|
||||||
async deanonymize(params: DeanonymizeParams): Promise<ApiDeanonymizeResponse> {
|
async deanonymize(params: DeanonymizeParams): Promise<DeanonymizeResponse> {
|
||||||
const interpreter = await this.waitUntilReady()
|
const interpreter = await this.waitUntilReady()
|
||||||
if (params.signInMethod === 'passwordless') {
|
if (params.signInMethod === 'passwordless') {
|
||||||
if (params.connection === 'email') {
|
if (params.connection === 'email') {
|
||||||
@@ -578,10 +583,7 @@ export class HasuraAuthClient {
|
|||||||
*
|
*
|
||||||
* @docs https://docs.nhost.io/reference/javascript/auth/refresh-session
|
* @docs https://docs.nhost.io/reference/javascript/auth/refresh-session
|
||||||
*/
|
*/
|
||||||
async refreshSession(refreshToken?: string): Promise<{
|
async refreshSession(refreshToken?: string): Promise<NhostSessionResponse> {
|
||||||
session: Session | null
|
|
||||||
error: ErrorPayload | null
|
|
||||||
}> {
|
|
||||||
try {
|
try {
|
||||||
const interpreter = await this.waitUntilReady()
|
const interpreter = await this.waitUntilReady()
|
||||||
return new Promise((resolve) => {
|
return new Promise((resolve) => {
|
||||||
|
|||||||
@@ -1,10 +1,8 @@
|
|||||||
import { AuthContext, SessionActionHandlerResult } from '@nhost/core'
|
import { AuthContext, NhostSession, SessionActionHandlerResult, SignUpResponse } from '@nhost/core'
|
||||||
|
|
||||||
import { Session, SignUpResponse } from './types'
|
|
||||||
|
|
||||||
export const isBrowser = () => typeof window !== 'undefined'
|
export const isBrowser = () => typeof window !== 'undefined'
|
||||||
|
|
||||||
export const getSession = (context?: AuthContext): Session | null => {
|
export const getSession = (context?: AuthContext): NhostSession | null => {
|
||||||
if (
|
if (
|
||||||
!context ||
|
!context ||
|
||||||
!context.accessToken.value ||
|
!context.accessToken.value ||
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import {
|
import {
|
||||||
AuthClient,
|
AuthClient,
|
||||||
AuthOptions,
|
AuthOptions,
|
||||||
ErrorPayload,
|
NhostSession,
|
||||||
PasswordlessOptions,
|
PasswordlessOptions,
|
||||||
Provider,
|
Provider,
|
||||||
ProviderOptions,
|
ProviderOptions,
|
||||||
@@ -19,14 +19,6 @@ export interface NhostAuthConstructorParams extends AuthOptions {
|
|||||||
autoLogin?: boolean
|
autoLogin?: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO remove and use NhostSession instead
|
|
||||||
export interface Session {
|
|
||||||
accessToken: string
|
|
||||||
accessTokenExpiresIn: number
|
|
||||||
refreshToken: string
|
|
||||||
user: User | null
|
|
||||||
}
|
|
||||||
|
|
||||||
// Sign Up
|
// Sign Up
|
||||||
export interface SignUpEmailPasswordParams {
|
export interface SignUpEmailPasswordParams {
|
||||||
email: string
|
email: string
|
||||||
@@ -35,22 +27,6 @@ export interface SignUpEmailPasswordParams {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export type SignUpParams = SignUpEmailPasswordParams
|
export type SignUpParams = SignUpEmailPasswordParams
|
||||||
|
|
||||||
export type SignUpResponse =
|
|
||||||
| { session: null; error: ErrorPayload }
|
|
||||||
| { session: Session | null; error: null }
|
|
||||||
|
|
||||||
// Sign In
|
|
||||||
|
|
||||||
export interface SignInResponse {
|
|
||||||
session: Session | null
|
|
||||||
mfa: {
|
|
||||||
ticket: string
|
|
||||||
} | null
|
|
||||||
error: ErrorPayload | null
|
|
||||||
providerUrl?: string
|
|
||||||
provider?: string
|
|
||||||
}
|
|
||||||
export interface SignInEmailPasswordParams {
|
export interface SignInEmailPasswordParams {
|
||||||
email: string
|
email: string
|
||||||
password: string
|
password: string
|
||||||
@@ -121,68 +97,8 @@ export type DeanonymizeParams =
|
|||||||
connection: 'sms'
|
connection: 'sms'
|
||||||
} & SignInPasswordlessSmsParams)
|
} & SignInPasswordlessSmsParams)
|
||||||
|
|
||||||
export interface SignInReponse {
|
|
||||||
session: Session | null
|
|
||||||
error: ErrorPayload | null
|
|
||||||
mfa?: {
|
|
||||||
enabled: boolean
|
|
||||||
ticket: string
|
|
||||||
}
|
|
||||||
providerUrl?: string
|
|
||||||
provider?: string
|
|
||||||
}
|
|
||||||
|
|
||||||
export type AuthChangeEvent = 'SIGNED_IN' | 'SIGNED_OUT'
|
export type AuthChangeEvent = 'SIGNED_IN' | 'SIGNED_OUT'
|
||||||
|
|
||||||
export type AuthChangedFunction = (event: AuthChangeEvent, session: Session | null) => void
|
export type AuthChangedFunction = (event: AuthChangeEvent, session: NhostSession | null) => void
|
||||||
|
|
||||||
export type OnTokenChangedFunction = (session: Session | null) => void
|
export type OnTokenChangedFunction = (session: NhostSession | null) => void
|
||||||
export interface Headers {
|
|
||||||
Authorization?: string
|
|
||||||
}
|
|
||||||
export interface Mfa {
|
|
||||||
ticket: string
|
|
||||||
}
|
|
||||||
|
|
||||||
export type ApiSignUpEmailPasswordResponse =
|
|
||||||
| { session: null; error: ErrorPayload }
|
|
||||||
| { session: Session; error: null }
|
|
||||||
|
|
||||||
export interface ApiSignInData {
|
|
||||||
session: Session
|
|
||||||
mfa: Mfa | null
|
|
||||||
}
|
|
||||||
export type ApiSignInResponse =
|
|
||||||
| {
|
|
||||||
data: ApiSignInData
|
|
||||||
error: null
|
|
||||||
}
|
|
||||||
| { data: null; error: ErrorPayload }
|
|
||||||
|
|
||||||
export type ApiRefreshTokenResponse =
|
|
||||||
| { session: null; error: ErrorPayload }
|
|
||||||
| { session: Session; error: null }
|
|
||||||
|
|
||||||
export interface ApiSignOutResponse {
|
|
||||||
error: ErrorPayload | null
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface ApiResetPasswordResponse {
|
|
||||||
error: ErrorPayload | null
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface ApiChangePasswordResponse {
|
|
||||||
error: ErrorPayload | null
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface ApiSendVerificationEmailResponse {
|
|
||||||
error: ErrorPayload | null
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface ApiChangeEmailResponse {
|
|
||||||
error: ErrorPayload | null
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface ApiDeanonymizeResponse {
|
|
||||||
error: ErrorPayload | null
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ services:
|
|||||||
auth:
|
auth:
|
||||||
image: nhost/hasura-auth:0.10.0
|
image: nhost/hasura-auth:0.10.0
|
||||||
storage:
|
storage:
|
||||||
image: nhost/hasura-storage:0.2.3
|
image: nhost/hasura-storage:0.2.4
|
||||||
auth:
|
auth:
|
||||||
access_control:
|
access_control:
|
||||||
email:
|
email:
|
||||||
|
|||||||
@@ -1,5 +1,12 @@
|
|||||||
# @nhost/nextjs
|
# @nhost/nextjs
|
||||||
|
|
||||||
|
## 1.7.4
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- @nhost/nhost-js@1.4.11
|
||||||
|
- @nhost/react@0.12.4
|
||||||
|
|
||||||
## 1.7.3
|
## 1.7.3
|
||||||
|
|
||||||
### Patch Changes
|
### Patch Changes
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@nhost/nextjs",
|
"name": "@nhost/nextjs",
|
||||||
"version": "1.7.3",
|
"version": "1.7.4",
|
||||||
"description": "Nhost NextJS library",
|
"description": "Nhost NextJS library",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
|
|||||||
@@ -1,5 +1,12 @@
|
|||||||
# @nhost/nhost-js
|
# @nhost/nhost-js
|
||||||
|
|
||||||
|
## 1.4.11
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Updated dependencies [a47ce291]
|
||||||
|
- @nhost/hasura-auth-js@1.4.2
|
||||||
|
|
||||||
## 1.4.10
|
## 1.4.10
|
||||||
|
|
||||||
### Patch Changes
|
### Patch Changes
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ services:
|
|||||||
auth:
|
auth:
|
||||||
image: nhost/hasura-auth:0.10.0
|
image: nhost/hasura-auth:0.10.0
|
||||||
storage:
|
storage:
|
||||||
image: nhost/hasura-storage:0.2.3
|
image: nhost/hasura-storage:0.2.4
|
||||||
auth:
|
auth:
|
||||||
access_control:
|
access_control:
|
||||||
email:
|
email:
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@nhost/nhost-js",
|
"name": "@nhost/nhost-js",
|
||||||
"version": "1.4.10",
|
"version": "1.4.11",
|
||||||
"description": "Nhost JavaScript SDK",
|
"description": "Nhost JavaScript SDK",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
|
|||||||
@@ -1,5 +1,12 @@
|
|||||||
# @nhost/react-apollo
|
# @nhost/react-apollo
|
||||||
|
|
||||||
|
## 4.7.4
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- @nhost/apollo@0.5.28
|
||||||
|
- @nhost/react@0.12.4
|
||||||
|
|
||||||
## 4.7.3
|
## 4.7.3
|
||||||
|
|
||||||
### Patch Changes
|
### Patch Changes
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@nhost/react-apollo",
|
"name": "@nhost/react-apollo",
|
||||||
"version": "4.7.3",
|
"version": "4.7.4",
|
||||||
"description": "Nhost React Apollo client",
|
"description": "Nhost React Apollo client",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
|
|||||||
@@ -1,5 +1,13 @@
|
|||||||
# @nhost/react-auth
|
# @nhost/react-auth
|
||||||
|
|
||||||
|
## 3.5.4
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Updated dependencies [a47ce291]
|
||||||
|
- @nhost/hasura-auth-js@1.4.2
|
||||||
|
- @nhost/react@0.12.4
|
||||||
|
|
||||||
## 3.5.3
|
## 3.5.3
|
||||||
|
|
||||||
### Patch Changes
|
### Patch Changes
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@nhost/react-auth",
|
"name": "@nhost/react-auth",
|
||||||
"version": "3.5.3",
|
"version": "3.5.4",
|
||||||
"description": "Nhost React client",
|
"description": "Nhost React client",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
|
|||||||
@@ -1,5 +1,11 @@
|
|||||||
# @nhost/react
|
# @nhost/react
|
||||||
|
|
||||||
|
## 0.12.4
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- @nhost/nhost-js@1.4.11
|
||||||
|
|
||||||
## 0.12.3
|
## 0.12.3
|
||||||
|
|
||||||
### Patch Changes
|
### Patch Changes
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@nhost/react",
|
"name": "@nhost/react",
|
||||||
"version": "0.12.3",
|
"version": "0.12.4",
|
||||||
"description": "Nhost React library",
|
"description": "Nhost React library",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
|
|||||||
@@ -1,5 +1,11 @@
|
|||||||
# @nhost/vue
|
# @nhost/vue
|
||||||
|
|
||||||
|
## 0.4.4
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- @nhost/nhost-js@1.4.11
|
||||||
|
|
||||||
## 0.4.3
|
## 0.4.3
|
||||||
|
|
||||||
### Patch Changes
|
### Patch Changes
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@nhost/vue",
|
"name": "@nhost/vue",
|
||||||
"version": "0.4.3",
|
"version": "0.4.4",
|
||||||
"description": "Nhost Vue library",
|
"description": "Nhost Vue library",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
|
|||||||
Reference in New Issue
Block a user