Compare commits

..

16 Commits

Author SHA1 Message Date
Pilou
1035639850 Merge pull request #544 from nhost/changeset-release/main
chore: update versions
2022-05-11 13:33:54 +02:00
github-actions[bot]
0e96e7329e chore: update versions 2022-05-11 11:13:25 +00:00
Szilárd Dóró
19ccc5ab0d Merge pull request #548 from nhost/axios-version-bump
Bump `axios` and set correct `Content-Type` for file upload
2022-05-11 13:12:16 +02:00
Szilárd Dóró
e094e682ce bump axios and fix file upload Content-Type
chore: bump axios from 0.26.0 to 0.27.2
fix: add Content-Type to file upload request headers
2022-05-11 12:45:52 +02:00
Pilou
74eb71f8f0 Merge pull request #543 from nhost/fix/signup-states
Fix/signup states
2022-05-11 08:59:41 +02:00
Pierre-Louis Mercereau
a931c15073 Merge main and fix wrong negation 2022-05-11 08:30:40 +02:00
Pilou
9ae5e485e6 Merge pull request #520 from nhost/feat/improve-errors
Improve the handling of authentication errors
2022-05-10 10:39:57 +02:00
Pierre-Louis Mercereau
2965a7bf5b chore: update lockfile 2022-05-10 10:12:52 +02:00
Pierre-Louis Mercereau
236ce72bb3 fix: correct email verification states and useSignUpEmailPassword loading state 2022-05-10 10:12:03 +02:00
Pierre-Louis Mercereau
5ad5832e41 docs: minor improvements in the examples 2022-05-10 10:08:54 +02:00
Pierre-Louis Mercereau
e1383106d9 Merge remote-tracking branch 'origin/main' into feat/improve-errors 2022-05-09 21:16:33 +02:00
Pierre-Louis Mercereau
4eac3101c9 refactor: deprecated the use of isError when it is the negation of isSuccess 2022-05-09 13:01:54 +02:00
Pierre-Louis Mercereau
80bd938336 Merge remote-tracking branch 'origin/main' into feat/improve-errors 2022-05-09 10:50:43 +02:00
Pierre-Louis Mercereau
8a79a7102f Merge remote-tracking branch 'origin/main' into feat/improve-errors 2022-05-09 10:11:40 +02:00
Pierre-Louis Mercereau
de3257ca7a Merge branch 'main' into feat/improve-errors 2022-05-06 14:46:14 +02:00
Pierre-Louis Mercereau
9d32314065 feat: improve the handling of authentication errors 2022-05-06 14:44:54 +02:00
111 changed files with 451 additions and 308 deletions

View File

@@ -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 `signUp` to sign up users using email an password. description: Use `signUp` to sign up users using email an password.
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L106 custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L93
--- ---
# `signUp()` # `signUp()`

View File

@@ -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 `signIn` to sign in users using email and password, passwordless (email or sms) or an external provider. `signIn` can be used in various ways depending on the parameters. description: Use `signIn` to sign in users using email and password, passwordless (email or sms) or an external provider. `signIn` can be used 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#L171 custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L153
--- ---
# `signIn()` # `signIn()`

View File

@@ -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 `signOut` to sign out a user description: Use `signOut` to sign out a user
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L343 custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L328
--- ---
# `signOut()` # `signOut()`

View File

@@ -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 `resetPassword` to reset a user's password. description: Use `resetPassword` to reset a user's password.
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L370 custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L355
--- ---
# `resetPassword()` # `resetPassword()`

View File

@@ -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 `changePassword` to change a user's password. description: Use `changePassword` to change a user's password.
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L395 custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L380
--- ---
# `changePassword()` # `changePassword()`

View File

@@ -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 `sendVerificationEmail` to send a verification email to the specified email. description: Use `sendVerificationEmail` to send a verification email to the specified email.
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L421 custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L406
--- ---
# `sendVerificationEmail()` # `sendVerificationEmail()`

View File

@@ -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 `changeEmail` to change a user's email description: Use `changeEmail` to change a user's email
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L448 custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L433
--- ---
# `changeEmail()` # `changeEmail()`

View File

@@ -4,7 +4,7 @@ title: deanonymize()
sidebar_label: deanonymize() sidebar_label: deanonymize()
slug: /reference/javascript/auth/deanonymize slug: /reference/javascript/auth/deanonymize
description: Use `deanonymize` to deanonymize a user description: Use `deanonymize` to deanonymize a user
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L473 custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L458
--- ---
# `deanonymize()` # `deanonymize()`

View File

@@ -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 `onTokenChanged` to add a custom function that will trigger whenever the access and refresh token is changed. description: Use `onTokenChanged` to add a custom function that will trigger whenever the access and refresh token is changed.
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L507 custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L492
--- ---
# `onTokenChanged()` # `onTokenChanged()`

View File

@@ -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 `onAuthStateChanged` to add a custom function that will trigger whenever the state of the user changed. Ex from signed in to signed out or vice versa. description: Use `onAuthStateChanged` to add a custom function that will trigger whenever the state of the user changed. Ex from signed in to signed out or vice versa.
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L544 custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L529
--- ---
# `onAuthStateChanged()` # `onAuthStateChanged()`

View File

@@ -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 `isAuthenticated` to check if the user is authenticated or not. description: Use `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#L584 custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L569
--- ---
# `isAuthenticated()` # `isAuthenticated()`

View File

@@ -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 `isAuthenticatedAsync` to wait and check if the user is authenticated or not. description: Use `isAuthenticatedAsync` to wait and 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#L602 custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L587
--- ---
# `isAuthenticatedAsync()` # `isAuthenticatedAsync()`

View File

@@ -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 `getAuthenticationStatus` to get the authentication status of the user. description: Use `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#L629 custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L614
--- ---
# `getAuthenticationStatus()` # `getAuthenticationStatus()`

View File

@@ -5,7 +5,7 @@ sidebar_label: getJWTToken()
slug: /reference/javascript/auth/get-jwt-token slug: /reference/javascript/auth/get-jwt-token
sidebar_class_name: deprecated sidebar_class_name: deprecated
description: No description provided. description: No description provided.
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L643 custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L628
--- ---
# `getJWTToken()` # `getJWTToken()`

View File

@@ -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 `getAccessToken` to get the logged in user's access token. description: Use `getAccessToken` to get the logged in user's access token.
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L657 custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L642
--- ---
# `getAccessToken()` # `getAccessToken()`

View File

@@ -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: Decode the current decoded access token (JWT), or return `null` if the user is not authenticated (no token) description: Decode the current decoded access token (JWT), or return `null` if the user is not authenticated (no token)
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L665 custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L650
--- ---
# `getDecodedAccessToken()` # `getDecodedAccessToken()`

View File

@@ -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: Decode the Hasura claims from the current access token (JWT) located in the `https://hasura.io/jwt/claims` namespace, or return `null` if the user is not authenticated (no token) description: Decode the Hasura claims from the current access token (JWT) located in the `https://hasura.io/jwt/claims` namespace, or return `null` if the user is not authenticated (no token)
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L675 custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L660
--- ---
# `getHasuraClaims()` # `getHasuraClaims()`

View File

@@ -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: Get the value of a given Hasura claim in the current access token (JWT). Returns null if the user is not authenticated, or if the claim is not in the token. Return `null` if the user is not authenticated (no token) description: Get the value of a given Hasura claim in the current access token (JWT). Returns null if the user is not authenticated, or if the claim is not in the token. Return `null` if the user is not authenticated (no token)
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L685 custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L670
--- ---
# `getHasuraClaim()` # `getHasuraClaim()`

View File

@@ -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 `refreshSession()` to refresh the current session or refresh the session with an provided `refreshToken`. description: Use `refreshSession()` to refresh the current session or refresh the session with an provided `refreshToken`.
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L704 custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L689
--- ---
# `refreshSession()` # `refreshSession()`

View File

@@ -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 `getSession()` to get the current session. description: Use `getSession()` to get the current session.
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L747 custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L733
--- ---
# `getSession()` # `getSession()`

View File

@@ -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 `getUser()` to get the current user. description: Use `getUser()` to get the current user.
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L762 custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L748
--- ---
# `getUser()` # `getUser()`

View File

@@ -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#L64 custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L51
--- ---
# `HasuraAuthClient` # `HasuraAuthClient`

View File

@@ -4,7 +4,7 @@ title: ApiChangeEmailResponse
sidebar_label: ApiChangeEmailResponse sidebar_label: ApiChangeEmailResponse
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#L170 custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/utils/types.ts#L166
--- ---
# `ApiChangeEmailResponse` # `ApiChangeEmailResponse`
@@ -13,6 +13,6 @@ custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-j
--- ---
**<span className="parameter-name">error</span>** <span className="optional-status">required</span> `null` | [`ApiError`](/reference/docgen/javascript/auth/types/api-error) **<span className="parameter-name">error</span>** <span className="optional-status">required</span> `null` | `ErrorPayload`
--- ---

View File

@@ -4,7 +4,7 @@ title: ApiChangePasswordResponse
sidebar_label: ApiChangePasswordResponse sidebar_label: ApiChangePasswordResponse
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#L162 custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/utils/types.ts#L158
--- ---
# `ApiChangePasswordResponse` # `ApiChangePasswordResponse`
@@ -13,6 +13,6 @@ custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-j
--- ---
**<span className="parameter-name">error</span>** <span className="optional-status">required</span> `null` | [`ApiError`](/reference/docgen/javascript/auth/types/api-error) **<span className="parameter-name">error</span>** <span className="optional-status">required</span> `null` | `ErrorPayload`
--- ---

View File

@@ -4,7 +4,7 @@ title: ApiDeanonymizeResponse
sidebar_label: ApiDeanonymizeResponse sidebar_label: ApiDeanonymizeResponse
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#L174 custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/utils/types.ts#L170
--- ---
# `ApiDeanonymizeResponse` # `ApiDeanonymizeResponse`
@@ -13,6 +13,6 @@ custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-j
--- ---
**<span className="parameter-name">error</span>** <span className="optional-status">required</span> `null` | [`ApiError`](/reference/docgen/javascript/auth/types/api-error) **<span className="parameter-name">error</span>** <span className="optional-status">required</span> `null` | `ErrorPayload`
--- ---

View File

@@ -1,22 +0,0 @@
---
# ⚠️ AUTO-GENERATED CONTENT. DO NOT EDIT THIS FILE DIRECTLY! ⚠️
title: ApiError
sidebar_label: ApiError
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#L27
---
# `ApiError`
## Parameters
---
**<span className="parameter-name">message</span>** <span className="optional-status">required</span> `string`
---
**<span className="parameter-name">status</span>** <span className="optional-status">required</span> `number`
---

View File

@@ -4,13 +4,13 @@ title: ApiRefreshTokenResponse
sidebar_label: ApiRefreshTokenResponse sidebar_label: ApiRefreshTokenResponse
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#L150 custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/utils/types.ts#L146
--- ---
# `ApiRefreshTokenResponse` # `ApiRefreshTokenResponse`
```ts ```ts
type ApiRefreshTokenResponse = type ApiRefreshTokenResponse =
| { session: null; error: ApiError } | { session: null; error: ErrorPayload }
| { session: Session; error: null } | { session: Session; error: null }
``` ```

View File

@@ -4,7 +4,7 @@ title: ApiResetPasswordResponse
sidebar_label: ApiResetPasswordResponse sidebar_label: ApiResetPasswordResponse
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#L158 custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/utils/types.ts#L154
--- ---
# `ApiResetPasswordResponse` # `ApiResetPasswordResponse`
@@ -13,6 +13,6 @@ custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-j
--- ---
**<span className="parameter-name">error</span>** <span className="optional-status">required</span> `null` | [`ApiError`](/reference/docgen/javascript/auth/types/api-error) **<span className="parameter-name">error</span>** <span className="optional-status">required</span> `null` | `ErrorPayload`
--- ---

View File

@@ -4,7 +4,7 @@ title: ApiSendVerificationEmailResponse
sidebar_label: ApiSendVerificationEmailResponse sidebar_label: ApiSendVerificationEmailResponse
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#L166 custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/utils/types.ts#L162
--- ---
# `ApiSendVerificationEmailResponse` # `ApiSendVerificationEmailResponse`
@@ -13,6 +13,6 @@ custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-j
--- ---
**<span className="parameter-name">error</span>** <span className="optional-status">required</span> `null` | [`ApiError`](/reference/docgen/javascript/auth/types/api-error) **<span className="parameter-name">error</span>** <span className="optional-status">required</span> `null` | `ErrorPayload`
--- ---

View File

@@ -4,7 +4,7 @@ title: ApiSignInData
sidebar_label: ApiSignInData sidebar_label: ApiSignInData
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#L135
--- ---
# `ApiSignInData` # `ApiSignInData`

View File

@@ -4,7 +4,7 @@ title: ApiSignInResponse
sidebar_label: ApiSignInResponse sidebar_label: ApiSignInResponse
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#L143 custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/utils/types.ts#L139
--- ---
# `ApiSignInResponse` # `ApiSignInResponse`
@@ -12,5 +12,5 @@ custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-j
```ts ```ts
type ApiSignInResponse = type ApiSignInResponse =
| { data: ApiSignInData; error: null } | { data: ApiSignInData; error: null }
| { data: null; error: ApiError } | { data: null; error: ErrorPayload }
``` ```

View File

@@ -4,7 +4,7 @@ title: ApiSignOutResponse
sidebar_label: ApiSignOutResponse sidebar_label: ApiSignOutResponse
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#L154 custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/utils/types.ts#L150
--- ---
# `ApiSignOutResponse` # `ApiSignOutResponse`
@@ -13,6 +13,6 @@ custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-j
--- ---
**<span className="parameter-name">error</span>** <span className="optional-status">required</span> `null` | [`ApiError`](/reference/docgen/javascript/auth/types/api-error) **<span className="parameter-name">error</span>** <span className="optional-status">required</span> `null` | `ErrorPayload`
--- ---

View File

@@ -4,13 +4,13 @@ title: ApiSignUpEmailPasswordResponse
sidebar_label: ApiSignUpEmailPasswordResponse sidebar_label: ApiSignUpEmailPasswordResponse
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#L131
--- ---
# `ApiSignUpEmailPasswordResponse` # `ApiSignUpEmailPasswordResponse`
```ts ```ts
type ApiSignUpEmailPasswordResponse = type ApiSignUpEmailPasswordResponse =
| { session: null; error: ApiError } | { session: null; error: ErrorPayload }
| { session: Session; error: null } | { session: Session; error: null }
``` ```

View File

@@ -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#L117 custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/utils/types.ts#L113
--- ---
# `AuthChangeEvent` # `AuthChangeEvent`

View File

@@ -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#L119 custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/utils/types.ts#L115
--- ---
# `AuthChangedFunction` # `AuthChangedFunction`

View File

@@ -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#L91 custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/utils/types.ts#L87
--- ---
# `ChangeEmailParams` # `ChangeEmailParams`

View File

@@ -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#L82 custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/utils/types.ts#L78
--- ---
# `ChangePasswordParams` # `ChangePasswordParams`

View File

@@ -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#L97 custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/utils/types.ts#L93
--- ---
# `DeanonymizeParams` # `DeanonymizeParams`

View File

@@ -4,7 +4,7 @@ title: Headers
sidebar_label: Headers sidebar_label: Headers
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#L128 custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/utils/types.ts#L124
--- ---
# `Headers` # `Headers`

View File

@@ -4,7 +4,7 @@ title: LoginData
sidebar_label: LoginData sidebar_label: LoginData
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#L123 custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/utils/types.ts#L119
--- ---
# `LoginData` # `LoginData`

View File

@@ -4,7 +4,7 @@ title: Mfa
sidebar_label: Mfa sidebar_label: Mfa
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#L131 custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/utils/types.ts#L127
--- ---
# `Mfa` # `Mfa`

View File

@@ -4,7 +4,7 @@ title: NhostAuthConstructorParams
sidebar_label: NhostAuthConstructorParams sidebar_label: NhostAuthConstructorParams
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#L14 custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/utils/types.ts#L15
--- ---
# `NhostAuthConstructorParams` # `NhostAuthConstructorParams`

View File

@@ -4,7 +4,7 @@ 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#L121 custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/utils/types.ts#L117
--- ---
# `OnTokenChangedFunction` # `OnTokenChangedFunction`

View File

@@ -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#L77 custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/utils/types.ts#L73
--- ---
# `ResetPasswordParams` # `ResetPasswordParams`

View File

@@ -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#L86 custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/utils/types.ts#L82
--- ---
# `SendVerificationEmailParams` # `SendVerificationEmailParams`

View File

@@ -4,7 +4,7 @@ title: Session
sidebar_label: Session sidebar_label: Session
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#L21 custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/utils/types.ts#L22
--- ---
# `Session` # `Session`

View File

@@ -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#L46 custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/utils/types.ts#L42
--- ---
# `SignInEmailPasswordParams` # `SignInEmailPasswordParams`

View File

@@ -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#L70 custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/utils/types.ts#L66
--- ---
# `SignInParams` # `SignInParams`

View File

@@ -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#L51 custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/utils/types.ts#L47
--- ---
# `SignInPasswordlessEmailParams` # `SignInPasswordlessEmailParams`

View File

@@ -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#L61 custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/utils/types.ts#L57
--- ---
# `SignInPasswordlessSmsOtpParams` # `SignInPasswordlessSmsOtpParams`

View File

@@ -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#L56 custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/utils/types.ts#L52
--- ---
# `SignInPasswordlessSmsParams` # `SignInPasswordlessSmsParams`

View File

@@ -4,7 +4,7 @@ title: SignInReponse
sidebar_label: SignInReponse sidebar_label: SignInReponse
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#L102
--- ---
# `SignInReponse` # `SignInReponse`
@@ -17,7 +17,7 @@ custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-j
--- ---
**<span className="parameter-name">error</span>** <span className="optional-status">required</span> `null` | [`ApiError`](/reference/docgen/javascript/auth/types/api-error) **<span className="parameter-name">error</span>** <span className="optional-status">required</span> `null` | `ErrorPayload`
--- ---

View File

@@ -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#L65 custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/utils/types.ts#L61
--- ---
# `SignInWithProviderOptions` # `SignInWithProviderOptions`

View File

@@ -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#L33 custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/utils/types.ts#L29
--- ---
# `SignUpEmailPasswordParams` # `SignUpEmailPasswordParams`

View File

@@ -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#L39 custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/utils/types.ts#L35
--- ---
# `SignUpParams` # `SignUpParams`

View File

@@ -4,13 +4,13 @@ title: SignUpResponse
sidebar_label: SignUpResponse sidebar_label: SignUpResponse
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#L41 custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/utils/types.ts#L37
--- ---
# `SignUpResponse` # `SignUpResponse`
```ts ```ts
type SignUpResponse = type SignUpResponse =
| { session: null; error: ApiError } | { session: null; error: ErrorPayload }
| { session: Session | null; error: null } | { session: Session | null; error: null }
``` ```

View File

@@ -4,7 +4,7 @@ title: useAccessToken()
sidebar_label: useAccessToken() sidebar_label: useAccessToken()
slug: /reference/nextjs/use-access-token slug: /reference/nextjs/use-access-token
description: Get the JWT access token description: Get the JWT access token
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/react/src/hooks/common.ts#L119 custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/react/src/hooks/common.ts#L122
--- ---
# `useAccessToken()` # `useAccessToken()`

View File

@@ -5,7 +5,7 @@ sidebar_label: useAuthLoading()
slug: /reference/nextjs/use-auth-loading slug: /reference/nextjs/use-auth-loading
sidebar_class_name: deprecated sidebar_class_name: deprecated
description: No description provided. description: No description provided.
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/react/src/hooks/common.ts#L59 custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/react/src/hooks/common.ts#L62
--- ---
# `useAuthLoading()` # `useAuthLoading()`

View File

@@ -4,7 +4,7 @@ title: useAuthenticated()
sidebar_label: useAuthenticated() sidebar_label: useAuthenticated()
slug: /reference/nextjs/use-authenticated slug: /reference/nextjs/use-authenticated
description: No description provided. description: No description provided.
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/react/src/hooks/common.ts#L101 custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/react/src/hooks/common.ts#L104
--- ---
# `useAuthenticated()` # `useAuthenticated()`

View File

@@ -4,7 +4,7 @@ title: useAuthenticationStatus()
sidebar_label: useAuthenticationStatus() sidebar_label: useAuthenticationStatus()
slug: /reference/nextjs/use-authentication-status slug: /reference/nextjs/use-authentication-status
description: The Nhost client may need some initial steps to determine the authentication status during startup, like fetching a new JWT from an existing refresh token. description: The Nhost client may need some initial steps to determine the authentication status during startup, like fetching a new JWT from an existing refresh token.
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/react/src/hooks/common.ts#L87 custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/react/src/hooks/common.ts#L90
--- ---
# `useAuthenticationStatus()` # `useAuthenticationStatus()`

View File

@@ -4,7 +4,7 @@ title: useNhostBackendUrl()
sidebar_label: useNhostBackendUrl() sidebar_label: useNhostBackendUrl()
slug: /reference/nextjs/use-nhost-backend-url slug: /reference/nextjs/use-nhost-backend-url
description: No description provided. description: No description provided.
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/react/src/hooks/common.ts#L45 custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/react/src/hooks/common.ts#L48
--- ---
# `useNhostBackendUrl()` # `useNhostBackendUrl()`

View File

@@ -4,7 +4,7 @@ title: useNhostClient()
sidebar_label: useNhostClient() sidebar_label: useNhostClient()
slug: /reference/nextjs/use-nhost-client slug: /reference/nextjs/use-nhost-client
description: No description provided. description: No description provided.
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/react/src/hooks/common.ts#L32 custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/react/src/hooks/common.ts#L35
--- ---
# `useNhostClient()` # `useNhostClient()`

View File

@@ -4,7 +4,7 @@ title: useProviderLink()
sidebar_label: useProviderLink() sidebar_label: useProviderLink()
slug: /reference/nextjs/use-provider-link slug: /reference/nextjs/use-provider-link
description: Hook that returns OAuth provider URLs description: Hook that returns OAuth provider URLs
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/react/src/hooks/authentication.ts#L450 custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/react/src/hooks/authentication.ts#L485
--- ---
# `useProviderLink()` # `useProviderLink()`

View File

@@ -4,7 +4,7 @@ title: useSignInAnonymous()
sidebar_label: useSignInAnonymous() sidebar_label: useSignInAnonymous()
slug: /reference/nextjs/use-sign-in-anonymous slug: /reference/nextjs/use-sign-in-anonymous
description: No description provided. description: No description provided.
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/react/src/hooks/authentication.ts#L370 custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/react/src/hooks/authentication.ts#L399
--- ---
# `useSignInAnonymous()` # `useSignInAnonymous()`

View File

@@ -4,7 +4,7 @@ title: useSignInEmailPasswordless()
sidebar_label: useSignInEmailPasswordless() sidebar_label: useSignInEmailPasswordless()
slug: /reference/nextjs/use-sign-in-email-passwordless slug: /reference/nextjs/use-sign-in-email-passwordless
description: Passwordless email authentication hook description: Passwordless email authentication hook
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/react/src/hooks/authentication.ts#L292 custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/react/src/hooks/authentication.ts#L308
--- ---
# `useSignInEmailPasswordless()` # `useSignInEmailPasswordless()`

View File

@@ -4,7 +4,7 @@ title: useSignOut()
sidebar_label: useSignOut() sidebar_label: useSignOut()
slug: /reference/nextjs/use-sign-out slug: /reference/nextjs/use-sign-out
description: Sign out The `useSignOut` hook accepts an `all` argument that will be used when the `signOut` method will be called. This value can be overriden in calling `signOut(allValue)`. description: Sign out The `useSignOut` hook accepts an `all` argument that will be used when the `signOut` method will be called. This value can be overriden in calling `signOut(allValue)`.
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/react/src/hooks/common.ts#L154 custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/react/src/hooks/common.ts#L157
--- ---
# `useSignOut()` # `useSignOut()`

View File

@@ -4,7 +4,7 @@ title: useSignUpEmailPassword()
sidebar_label: useSignUpEmailPassword() sidebar_label: useSignUpEmailPassword()
slug: /reference/nextjs/use-sign-up-email-password slug: /reference/nextjs/use-sign-up-email-password
description: Email and Password Sign-Up description: Email and Password Sign-Up
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/react/src/hooks/registration.ts#L104 custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/react/src/hooks/registration.ts#L102
--- ---
# `useSignUpEmailPassword()` # `useSignUpEmailPassword()`

View File

@@ -13,14 +13,6 @@ custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/react/src/hoo
--- ---
**<span className="parameter-name">isError</span>** <span className="optional-status">required</span> `boolean`
**`@returns`**
`true` if an error occurred
---
**<span className="parameter-name">error</span>** <span className="optional-status">required</span> `null` | `ErrorPayload` **<span className="parameter-name">error</span>** <span className="optional-status">required</span> `null` | `ErrorPayload`
Provides details about the error Provides details about the error
@@ -40,3 +32,11 @@ Provides details about the error
Returns `true` if the action is successful. Returns `true` if the action is successful.
--- ---
**<span className="parameter-name">isError</span>** <span className="optional-status">required</span> `boolean`
**`@depreacted`**
use `!isSuccess` or `!!error` instead
---

View File

@@ -4,7 +4,7 @@ title: useAccessToken()
sidebar_label: useAccessToken() sidebar_label: useAccessToken()
slug: /reference/react/use-access-token slug: /reference/react/use-access-token
description: Get the JWT access token description: Get the JWT access token
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/react/src/hooks/common.ts#L119 custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/react/src/hooks/common.ts#L122
--- ---
# `useAccessToken()` # `useAccessToken()`

View File

@@ -5,7 +5,7 @@ sidebar_label: useAuthLoading()
slug: /reference/react/use-auth-loading slug: /reference/react/use-auth-loading
sidebar_class_name: deprecated sidebar_class_name: deprecated
description: No description provided. description: No description provided.
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/react/src/hooks/common.ts#L59 custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/react/src/hooks/common.ts#L62
--- ---
# `useAuthLoading()` # `useAuthLoading()`

View File

@@ -4,7 +4,7 @@ title: useAuthenticated()
sidebar_label: useAuthenticated() sidebar_label: useAuthenticated()
slug: /reference/react/use-authenticated slug: /reference/react/use-authenticated
description: No description provided. description: No description provided.
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/react/src/hooks/common.ts#L101 custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/react/src/hooks/common.ts#L104
--- ---
# `useAuthenticated()` # `useAuthenticated()`

View File

@@ -4,7 +4,7 @@ title: useAuthenticationStatus()
sidebar_label: useAuthenticationStatus() sidebar_label: useAuthenticationStatus()
slug: /reference/react/use-authentication-status slug: /reference/react/use-authentication-status
description: The Nhost client may need some initial steps to determine the authentication status during startup, like fetching a new JWT from an existing refresh token. description: The Nhost client may need some initial steps to determine the authentication status during startup, like fetching a new JWT from an existing refresh token.
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/react/src/hooks/common.ts#L87 custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/react/src/hooks/common.ts#L90
--- ---
# `useAuthenticationStatus()` # `useAuthenticationStatus()`

View File

@@ -4,7 +4,7 @@ title: useNhostBackendUrl()
sidebar_label: useNhostBackendUrl() sidebar_label: useNhostBackendUrl()
slug: /reference/react/use-nhost-backend-url slug: /reference/react/use-nhost-backend-url
description: No description provided. description: No description provided.
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/react/src/hooks/common.ts#L45 custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/react/src/hooks/common.ts#L48
--- ---
# `useNhostBackendUrl()` # `useNhostBackendUrl()`

View File

@@ -4,7 +4,7 @@ title: useNhostClient()
sidebar_label: useNhostClient() sidebar_label: useNhostClient()
slug: /reference/react/use-nhost-client slug: /reference/react/use-nhost-client
description: No description provided. description: No description provided.
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/react/src/hooks/common.ts#L32 custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/react/src/hooks/common.ts#L35
--- ---
# `useNhostClient()` # `useNhostClient()`

View File

@@ -4,7 +4,7 @@ title: useProviderLink()
sidebar_label: useProviderLink() sidebar_label: useProviderLink()
slug: /reference/react/use-provider-link slug: /reference/react/use-provider-link
description: Hook that returns OAuth provider URLs description: Hook that returns OAuth provider URLs
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/react/src/hooks/authentication.ts#L450 custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/react/src/hooks/authentication.ts#L485
--- ---
# `useProviderLink()` # `useProviderLink()`

View File

@@ -4,7 +4,7 @@ title: useSignInAnonymous()
sidebar_label: useSignInAnonymous() sidebar_label: useSignInAnonymous()
slug: /reference/react/use-sign-in-anonymous slug: /reference/react/use-sign-in-anonymous
description: No description provided. description: No description provided.
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/react/src/hooks/authentication.ts#L370 custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/react/src/hooks/authentication.ts#L399
--- ---
# `useSignInAnonymous()` # `useSignInAnonymous()`

View File

@@ -4,7 +4,7 @@ title: useSignInEmailPasswordless()
sidebar_label: useSignInEmailPasswordless() sidebar_label: useSignInEmailPasswordless()
slug: /reference/react/use-sign-in-email-passwordless slug: /reference/react/use-sign-in-email-passwordless
description: Passwordless email authentication hook description: Passwordless email authentication hook
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/react/src/hooks/authentication.ts#L292 custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/react/src/hooks/authentication.ts#L308
--- ---
# `useSignInEmailPasswordless()` # `useSignInEmailPasswordless()`

View File

@@ -4,7 +4,7 @@ title: useSignOut()
sidebar_label: useSignOut() sidebar_label: useSignOut()
slug: /reference/react/use-sign-out slug: /reference/react/use-sign-out
description: Sign out The `useSignOut` hook accepts an `all` argument that will be used when the `signOut` method will be called. This value can be overriden in calling `signOut(allValue)`. description: Sign out The `useSignOut` hook accepts an `all` argument that will be used when the `signOut` method will be called. This value can be overriden in calling `signOut(allValue)`.
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/react/src/hooks/common.ts#L154 custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/react/src/hooks/common.ts#L157
--- ---
# `useSignOut()` # `useSignOut()`

View File

@@ -4,7 +4,7 @@ title: useSignUpEmailPassword()
sidebar_label: useSignUpEmailPassword() sidebar_label: useSignUpEmailPassword()
slug: /reference/react/use-sign-up-email-password slug: /reference/react/use-sign-up-email-password
description: Email and Password Sign-Up description: Email and Password Sign-Up
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/react/src/hooks/registration.ts#L104 custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/react/src/hooks/registration.ts#L102
--- ---
# `useSignUpEmailPassword()` # `useSignUpEmailPassword()`

View File

@@ -13,14 +13,6 @@ custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/react/src/hoo
--- ---
**<span className="parameter-name">isError</span>** <span className="optional-status">required</span> `boolean`
**`@returns`**
`true` if an error occurred
---
**<span className="parameter-name">error</span>** <span className="optional-status">required</span> `null` | `ErrorPayload` **<span className="parameter-name">error</span>** <span className="optional-status">required</span> `null` | `ErrorPayload`
Provides details about the error Provides details about the error
@@ -40,3 +32,11 @@ Provides details about the error
Returns `true` if the action is successful. Returns `true` if the action is successful.
--- ---
**<span className="parameter-name">isError</span>** <span className="optional-status">required</span> `boolean`
**`@depreacted`**
use `!isSuccess` or `!!error` instead
---

View File

@@ -26,7 +26,8 @@ export const SignInPasswordPage: NextPage = () => {
showNotification({ showNotification({
color: 'red', color: 'red',
title: 'Error', title: 'Error',
message: 'Email is not verified' message:
'You need to verify your email first. Please check your mailbox and follow the confirmation link to complete the registration.'
}) })
} else { } else {
router.replace('/') router.replace('/')

View File

@@ -1,8 +1,5 @@
/* eslint-disable react/react-in-jsx-scope */ /* eslint-disable react/react-in-jsx-scope */
import { useEffect } from 'react' import { Route, Routes } from 'react-router-dom'
import { Route, Routes, useLocation, useNavigate } from 'react-router-dom'
import { useAuthenticated, useSignOut } from '@nhost/react'
import { AuthGate, PublicGate } from './components/auth-gates' import { AuthGate, PublicGate } from './components/auth-gates'
import { AboutPage } from './About' import { AboutPage } from './About'
@@ -19,15 +16,6 @@ import { NotificationsProvider } from '@mantine/notifications'
const title = 'Nhost with React and Apollo' const title = 'Nhost with React and Apollo'
function App() { function App() {
const isAuthenticated = useAuthenticated()
const { signOut, isSuccess: signedOut } = useSignOut()
const navigate = useNavigate()
const location = useLocation()
useEffect(() => {
if (signedOut) navigate('/')
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [signedOut])
return ( return (
<MantineProvider <MantineProvider
withGlobalStyles withGlobalStyles

View File

@@ -55,7 +55,7 @@ export const EmailPassword: React.FC = () => {
return ( return (
<> <>
<Modal <Modal
title="Verification email sent" title="Awaiting email verification"
transition="fade" transition="fade"
centered centered
transitionDuration={600} transitionDuration={600}
@@ -64,8 +64,8 @@ export const EmailPassword: React.FC = () => {
setEmailVerificationToggle(false) setEmailVerificationToggle(false)
}} }}
> >
A email has been sent to {email}. Please follow the link to verify your email address and You need to verify your email first. Please check your mailbox and follow the confirmation
to complete your registration. link to complete the registration.
</Modal> </Modal>
<TextInput <TextInput
value={email} value={email}

View File

@@ -1,5 +1,12 @@
# @nhost/apollo # @nhost/apollo
## 0.5.4
### Patch Changes
- Updated dependencies [e094e68]
- @nhost/nhost-js@1.1.11
## 0.5.3 ## 0.5.3
### Patch Changes ### Patch Changes

View File

@@ -1,6 +1,6 @@
{ {
"name": "@nhost/apollo", "name": "@nhost/apollo",
"version": "0.5.3", "version": "0.5.4",
"description": "Nhost Apollo Client library", "description": "Nhost Apollo Client library",
"license": "MIT", "license": "MIT",
"keywords": [ "keywords": [

View File

@@ -1,5 +1,16 @@
# @nhost/core # @nhost/core
## 0.5.4
### Patch Changes
- 9d32314: Improve error codes
The errors of `signUp`, `signIn`, `signOut`, and `refreshSession` now always include an `error` field that contains a machine-readable error code.
- e094e68: chore: bump axios from 0.26.0 to 0.27.2
fix: add Content-Type to file upload request headers
- 236ce72: Correct email verification states
email verification returns `false` when the client has started and it is still undetermined
## 0.5.3 ## 0.5.3
### Patch Changes ### Patch Changes

View File

@@ -1,6 +1,6 @@
{ {
"name": "@nhost/core", "name": "@nhost/core",
"version": "0.5.3", "version": "0.5.4",
"description": "Nhost core client library", "description": "Nhost core client library",
"license": "MIT", "license": "MIT",
"keywords": [ "keywords": [
@@ -52,7 +52,7 @@
"verify:fix": "run-p prettier:fix lint:fix" "verify:fix": "run-p prettier:fix lint:fix"
}, },
"dependencies": { "dependencies": {
"axios": "^0.26.0", "axios": "^0.27.2",
"js-cookie": "^3.0.1", "js-cookie": "^3.0.1",
"xstate": "^4.31.0" "xstate": "^4.31.0"
}, },

View File

@@ -10,6 +10,7 @@ export type ErrorPayload = {
export type ValidationErrorPayload = ErrorPayload & { status: typeof VALIDATION_ERROR_CODE } export type ValidationErrorPayload = ErrorPayload & { status: typeof VALIDATION_ERROR_CODE }
// TODO share with hasura-auth
export const INVALID_EMAIL_ERROR: ValidationErrorPayload = { export const INVALID_EMAIL_ERROR: ValidationErrorPayload = {
status: VALIDATION_ERROR_CODE, status: VALIDATION_ERROR_CODE,
error: 'invalid-email', error: 'invalid-email',
@@ -52,3 +53,39 @@ export const TOKEN_REFRESHER_RUNNING_ERROR: ErrorPayload = {
message: message:
'The token refresher is already running. You must wait until is has finished before submitting a new token.' 'The token refresher is already running. You must wait until is has finished before submitting a new token.'
} }
export const USER_ALREADY_SIGNED_IN: ErrorPayload = {
status: STATE_ERROR_CODE,
error: 'already-signed-in',
message: 'User is already signed in'
}
export const USER_UNAUTHENTICATED: ErrorPayload = {
status: STATE_ERROR_CODE,
error: 'unauthenticated-user',
message: 'User is not authenticated'
}
export const USER_NOT_ANONYMOUS: ErrorPayload = {
status: STATE_ERROR_CODE,
error: 'user-not-anonymous',
message: 'User is not anonymous'
}
export const EMAIL_NEEDS_VERIFICATION: ErrorPayload = {
status: STATE_ERROR_CODE,
error: 'unverified-user',
message: 'Email needs verification'
}
export const INVALID_AUTHENTICATION_METHOD = {
status: VALIDATION_ERROR_CODE,
error: 'invalid-authentication-method',
message: 'Incorrect parameters'
}
export const INVALID_REFRESH_TOKEN = {
status: VALIDATION_ERROR_CODE,
error: 'invalid-refresh-token',
message: 'Invalid or expired refresh token'
}

View File

@@ -447,7 +447,7 @@ export const createAuthMachine = ({
} }
}, },
email: { email: {
initial: 'awaitingVerification', initial: 'unknown',
on: { on: {
SIGNED_IN: [ SIGNED_IN: [
{ {
@@ -456,10 +456,11 @@ export const createAuthMachine = ({
}, },
'.valid' '.valid'
], ],
SIGNOUT: '.awaitingVerification', SIGNOUT: '.unknown',
AWAIT_EMAIL_VERIFICATION: '.awaitingVerification' AWAIT_EMAIL_VERIFICATION: '.awaitingVerification'
}, },
states: { states: {
unknown: {},
awaitingVerification: {}, awaitingVerification: {},
valid: {} valid: {}
} }

View File

@@ -269,6 +269,7 @@ export interface Typegen0 {
| 'token.idle.error' | 'token.idle.error'
| 'token.running' | 'token.running'
| 'email' | 'email'
| 'email.unknown'
| 'email.awaitingVerification' | 'email.awaitingVerification'
| 'email.valid' | 'email.valid'
| { | {
@@ -314,7 +315,7 @@ export interface Typegen0 {
} }
} }
token?: 'idle' | 'running' | { idle?: 'noErrors' | 'error' } token?: 'idle' | 'running' | { idle?: 'noErrors' | 'error' }
email?: 'awaitingVerification' | 'valid' email?: 'unknown' | 'awaitingVerification' | 'valid'
} }
tags: 'loading' tags: 'loading'
} }

View File

@@ -1,5 +1,18 @@
# @nhost/hasura-auth-js # @nhost/hasura-auth-js
## 1.1.6
### Patch Changes
- 9d32314: Improve error codes
The errors of `signUp`, `signIn`, `signOut`, and `refreshSession` now always include an `error` field that contains a machine-readable error code.
- e094e68: chore: bump axios from 0.26.0 to 0.27.2
fix: add Content-Type to file upload request headers
- Updated dependencies [9d32314]
- Updated dependencies [e094e68]
- Updated dependencies [236ce72]
- @nhost/core@0.5.4
## 1.1.5 ## 1.1.5
### Patch Changes ### Patch Changes

View File

@@ -1,6 +1,6 @@
{ {
"name": "@nhost/hasura-auth-js", "name": "@nhost/hasura-auth-js",
"version": "1.1.5", "version": "1.1.6",
"description": "Hasura-auth client", "description": "Hasura-auth client",
"license": "MIT", "license": "MIT",
"keywords": [ "keywords": [
@@ -60,7 +60,7 @@
"devDependencies": { "devDependencies": {
"@nhost/docgen": "workspace:*", "@nhost/docgen": "workspace:*",
"@types/faker": "5", "@types/faker": "5",
"axios": "^0.26.0", "axios": "^0.27.2",
"faker": "5", "faker": "5",
"html-urls": "^2.4.27", "html-urls": "^2.4.27",
"mailhog": "^4.16.0" "mailhog": "^4.16.0"

View File

@@ -8,12 +8,19 @@ import {
createChangePasswordMachine, createChangePasswordMachine,
createResetPasswordMachine, createResetPasswordMachine,
createSendVerificationEmailMachine, createSendVerificationEmailMachine,
EMAIL_NEEDS_VERIFICATION,
encodeQueryParameters, encodeQueryParameters,
ErrorPayload,
INVALID_AUTHENTICATION_METHOD,
INVALID_REFRESH_TOKEN,
JWTClaims, JWTClaims,
JWTHasuraClaims, JWTHasuraClaims,
NO_REFRESH_TOKEN, NO_REFRESH_TOKEN,
rewriteRedirectTo, rewriteRedirectTo,
TOKEN_REFRESHER_RUNNING_ERROR TOKEN_REFRESHER_RUNNING_ERROR,
USER_ALREADY_SIGNED_IN,
USER_NOT_ANONYMOUS,
USER_UNAUTHENTICATED
} from '@nhost/core' } from '@nhost/core'
import { getSession, isBrowser } from './utils/helpers' import { getSession, isBrowser } from './utils/helpers'
@@ -21,7 +28,6 @@ import {
ApiChangeEmailResponse, ApiChangeEmailResponse,
ApiChangePasswordResponse, ApiChangePasswordResponse,
ApiDeanonymizeResponse, ApiDeanonymizeResponse,
ApiError,
ApiResetPasswordResponse, ApiResetPasswordResponse,
ApiSendVerificationEmailResponse, ApiSendVerificationEmailResponse,
ApiSignOutResponse, ApiSignOutResponse,
@@ -39,25 +45,6 @@ import {
SignUpResponse SignUpResponse
} from './utils/types' } from './utils/types'
const USER_ALREADY_SIGNED_IN: ApiError = {
message: 'User is already signed in',
status: 100
}
const USER_UNAUTHENTICATED: ApiError = {
message: 'User is not authenticated',
status: 101
}
const USER_NOT_ANONYMOUS: ApiError = {
message: 'User is not anonymous',
status: 101
}
const EMAIL_NEEDS_VERIFICATION: ApiError = {
message: 'Email needs verification',
status: 102
}
/** /**
* @alias Auth * @alias Auth
*/ */
@@ -108,16 +95,11 @@ export class HasuraAuthClient {
const { email, password, options } = params const { email, password, options } = params
// * Raise an error if the user is already authenticated
if (this.isAuthenticated()) {
return {
session: null,
error: USER_ALREADY_SIGNED_IN
}
}
return new Promise((resolve) => { return new Promise((resolve) => {
interpreter.send('SIGNUP_EMAIL_PASSWORD', { email, password, options }) const { changed } = interpreter.send('SIGNUP_EMAIL_PASSWORD', { email, password, options })
if (!changed) {
return resolve({ session: null, error: USER_ALREADY_SIGNED_IN })
}
interpreter.onTransition((state) => { interpreter.onTransition((state) => {
if ( if (
state.matches({ state.matches({
@@ -173,21 +155,12 @@ export class HasuraAuthClient {
mfa: { mfa: {
ticket: string ticket: string
} | null } | null
error: ApiError | null error: ErrorPayload | null
providerUrl?: string providerUrl?: string
provider?: string provider?: string
}> { }> {
const interpreter = await this.waitUntilReady() const interpreter = await this.waitUntilReady()
// * Raise an error if the user is already authenticated
if (this.isAuthenticated()) {
return {
session: null,
mfa: null,
error: USER_ALREADY_SIGNED_IN
}
}
if ('provider' in params) { if ('provider' in params) {
const { provider, options } = params const { provider, options } = params
const providerUrl = encodeQueryParameters( const providerUrl = encodeQueryParameters(
@@ -203,7 +176,10 @@ export class HasuraAuthClient {
// email password // email password
if ('email' in params && 'password' in params) { if ('email' in params && 'password' in params) {
return new Promise((resolve) => { return new Promise((resolve) => {
interpreter.send('SIGNIN_PASSWORD', params) const { changed } = interpreter.send('SIGNIN_PASSWORD', params)
if (!changed) {
return resolve({ session: null, mfa: null, error: USER_ALREADY_SIGNED_IN })
}
interpreter.onTransition((state) => { interpreter.onTransition((state) => {
if (state.matches({ authentication: 'signedIn' })) { if (state.matches({ authentication: 'signedIn' })) {
resolve({ resolve({
@@ -242,7 +218,10 @@ export class HasuraAuthClient {
// passwordless Email (magic link) // passwordless Email (magic link)
if ('email' in params && !('otp' in params)) { if ('email' in params && !('otp' in params)) {
return new Promise((resolve) => { return new Promise((resolve) => {
interpreter.send('SIGNIN_PASSWORDLESS_EMAIL', params) const { changed } = interpreter.send('SIGNIN_PASSWORDLESS_EMAIL', params)
if (!changed) {
return resolve({ session: null, mfa: null, error: USER_ALREADY_SIGNED_IN })
}
interpreter.onTransition((state) => { interpreter.onTransition((state) => {
if ( if (
state.matches({ state.matches({
@@ -269,7 +248,10 @@ export class HasuraAuthClient {
// passwordless SMS // passwordless SMS
if ('phoneNumber' in params && !('otp' in params)) { if ('phoneNumber' in params && !('otp' in params)) {
return new Promise((resolve) => { return new Promise((resolve) => {
interpreter.send('SIGNIN_PASSWORDLESS_SMS', params) const { changed } = interpreter.send('SIGNIN_PASSWORDLESS_SMS', params)
if (!changed) {
return resolve({ session: null, mfa: null, error: USER_ALREADY_SIGNED_IN })
}
interpreter.onTransition((state) => { interpreter.onTransition((state) => {
if (state.matches({ authentication: { signedOut: 'needsSmsOtp' } })) { if (state.matches({ authentication: { signedOut: 'needsSmsOtp' } })) {
resolve({ resolve({
@@ -291,7 +273,10 @@ export class HasuraAuthClient {
// sign in using SMS OTP // sign in using SMS OTP
if ('otp' in params) { if ('otp' in params) {
return new Promise((resolve) => { return new Promise((resolve) => {
interpreter.send('SIGNIN_PASSWORDLESS_SMS_OTP', params) const { changed } = interpreter.send('SIGNIN_PASSWORDLESS_SMS_OTP', params)
if (!changed) {
return resolve({ session: null, mfa: null, error: USER_ALREADY_SIGNED_IN })
}
interpreter.onTransition((state) => { interpreter.onTransition((state) => {
if (state.matches({ authentication: 'signedIn' })) { if (state.matches({ authentication: 'signedIn' })) {
resolve({ resolve({
@@ -312,7 +297,7 @@ export class HasuraAuthClient {
// * Anonymous sign-in // * Anonymous sign-in
const { changed } = interpreter.send('SIGNIN_ANONYMOUS') const { changed } = interpreter.send('SIGNIN_ANONYMOUS')
if (!changed) { if (!changed) {
return { session: null, mfa: null, error: { message: 'already signed in', status: 1 } } return { session: null, mfa: null, error: INVALID_AUTHENTICATION_METHOD }
} }
return new Promise((resolve) => { return new Promise((resolve) => {
interpreter.onTransition((state) => { interpreter.onTransition((state) => {
@@ -342,11 +327,11 @@ export class HasuraAuthClient {
*/ */
async signOut(params?: { all?: boolean }): Promise<ApiSignOutResponse> { async signOut(params?: { all?: boolean }): Promise<ApiSignOutResponse> {
const interpreter = await this.waitUntilReady() const interpreter = await this.waitUntilReady()
if (!this.isAuthenticated()) {
return { error: USER_UNAUTHENTICATED }
}
return new Promise((resolve) => { return new Promise((resolve) => {
interpreter.send('SIGNOUT', { all: params?.all }) const { event } = interpreter.send('SIGNOUT', { all: params?.all })
if (event.type !== 'SIGNED_OUT') {
return resolve({ error: USER_UNAUTHENTICATED })
}
interpreter.onTransition((state) => { interpreter.onTransition((state) => {
if (state.matches({ authentication: { signedOut: 'success' } })) { if (state.matches({ authentication: { signedOut: 'success' } })) {
resolve({ error: null }) resolve({ error: null })
@@ -703,25 +688,25 @@ export class HasuraAuthClient {
*/ */
async refreshSession(refreshToken?: string): Promise<{ async refreshSession(refreshToken?: string): Promise<{
session: Session | null session: Session | null
error: ApiError | null error: ErrorPayload | null
}> { }> {
try { try {
const interpreter = await this.waitUntilReady() const interpreter = await this.waitUntilReady()
if (!interpreter.state.matches({ token: 'idle' })) {
return { session: null, error: TOKEN_REFRESHER_RUNNING_ERROR }
}
return new Promise((resolve) => { return new Promise((resolve) => {
const token = refreshToken || interpreter.state.context.refreshToken.value const token = refreshToken || interpreter.state.context.refreshToken.value
if (!token) { if (!token) {
return resolve({ session: null, error: NO_REFRESH_TOKEN }) return resolve({ session: null, error: NO_REFRESH_TOKEN })
} }
interpreter.send('TRY_TOKEN', { token }) const { changed } = interpreter.send('TRY_TOKEN', { token })
if (!changed) {
return resolve({ session: null, error: TOKEN_REFRESHER_RUNNING_ERROR })
}
interpreter?.onTransition((state) => { interpreter?.onTransition((state) => {
if (state.matches({ token: { idle: 'error' } })) { if (state.matches({ token: { idle: 'error' } })) {
resolve({ resolve({
session: null, session: null,
// * TODO get the error from xstate once it is implemented // * TODO get the error from xstate once it is implemented
error: { status: 400, message: 'Invalid refresh token' } error: INVALID_REFRESH_TOKEN
}) })
} else if (state.event.type === 'TOKEN_CHANGED') { } else if (state.event.type === 'TOKEN_CHANGED') {
resolve({ session: getSession(state.context), error: null }) resolve({ session: getSession(state.context), error: null })
@@ -729,6 +714,7 @@ export class HasuraAuthClient {
}) })
}) })
} catch (error: any) { } catch (error: any) {
// TODO return error in the correct format
return { session: null, error: error.message } return { session: null, error: error.message }
} }
} }

View File

@@ -1,6 +1,7 @@
import { import {
AuthClient, AuthClient,
AuthOptions, AuthOptions,
ErrorPayload,
PasswordlessOptions, PasswordlessOptions,
Provider, Provider,
ProviderOptions, ProviderOptions,
@@ -24,11 +25,6 @@ export interface Session {
refreshToken: string refreshToken: string
user: User | null user: User | null
} }
export interface ApiError {
message: string
status: number
}
// Sign Up // Sign Up
export interface SignUpEmailPasswordParams { export interface SignUpEmailPasswordParams {
email: string email: string
@@ -39,7 +35,7 @@ export interface SignUpEmailPasswordParams {
export type SignUpParams = SignUpEmailPasswordParams export type SignUpParams = SignUpEmailPasswordParams
export type SignUpResponse = export type SignUpResponse =
| { session: null; error: ApiError } | { session: null; error: ErrorPayload }
| { session: Session | null; error: null } | { session: Session | null; error: null }
// Sign In // Sign In
@@ -105,7 +101,7 @@ export interface DeanonymizeParams {
export interface SignInReponse { export interface SignInReponse {
session: Session | null session: Session | null
error: ApiError | null error: ErrorPayload | null
mfa?: { mfa?: {
enabled: boolean enabled: boolean
ticket: string ticket: string
@@ -133,7 +129,7 @@ export interface Mfa {
} }
export type ApiSignUpEmailPasswordResponse = export type ApiSignUpEmailPasswordResponse =
| { session: null; error: ApiError } | { session: null; error: ErrorPayload }
| { session: Session; error: null } | { session: Session; error: null }
export interface ApiSignInData { export interface ApiSignInData {
@@ -145,32 +141,32 @@ export type ApiSignInResponse =
data: ApiSignInData data: ApiSignInData
error: null error: null
} }
| { data: null; error: ApiError } | { data: null; error: ErrorPayload }
export type ApiRefreshTokenResponse = export type ApiRefreshTokenResponse =
| { session: null; error: ApiError } | { session: null; error: ErrorPayload }
| { session: Session; error: null } | { session: Session; error: null }
export interface ApiSignOutResponse { export interface ApiSignOutResponse {
error: ApiError | null error: ErrorPayload | null
} }
export interface ApiResetPasswordResponse { export interface ApiResetPasswordResponse {
error: ApiError | null error: ErrorPayload | null
} }
export interface ApiChangePasswordResponse { export interface ApiChangePasswordResponse {
error: ApiError | null error: ErrorPayload | null
} }
export interface ApiSendVerificationEmailResponse { export interface ApiSendVerificationEmailResponse {
error: ApiError | null error: ErrorPayload | null
} }
export interface ApiChangeEmailResponse { export interface ApiChangeEmailResponse {
error: ApiError | null error: ErrorPayload | null
} }
export interface ApiDeanonymizeResponse { export interface ApiDeanonymizeResponse {
error: ApiError | null error: ErrorPayload | null
} }

View File

@@ -1,5 +1,12 @@
# @nhost/hasura-storage-js # @nhost/hasura-storage-js
## 0.2.2
### Patch Changes
- e094e68: chore: bump axios from 0.26.0 to 0.27.2
fix: add Content-Type to file upload request headers
## 0.2.1 ## 0.2.1
### Patch Changes ### Patch Changes

View File

@@ -1,6 +1,6 @@
{ {
"name": "@nhost/hasura-storage-js", "name": "@nhost/hasura-storage-js",
"version": "0.2.1", "version": "0.2.2",
"description": "Hasura-storage client", "description": "Hasura-storage client",
"license": "MIT", "license": "MIT",
"keywords": [ "keywords": [
@@ -51,7 +51,7 @@
"docgen": "pnpm typedoc && docgen --config ./storage.docgen.json" "docgen": "pnpm typedoc && docgen --config ./storage.docgen.json"
}, },
"dependencies": { "dependencies": {
"axios": "^0.26.0" "axios": "^0.27.2"
}, },
"devDependencies": { "devDependencies": {
"@nhost/docgen": "workspace:*" "@nhost/docgen": "workspace:*"

View File

@@ -34,7 +34,8 @@ export class HasuraStorageApi {
const res = await this.httpClient.post('/files', params.file, { const res = await this.httpClient.post('/files', params.file, {
headers: { headers: {
...this.generateUploadHeaders(params), ...this.generateUploadHeaders(params),
...this.generateAuthHeaders() ...this.generateAuthHeaders(),
'Content-Type': 'multipart/form-data'
} }
}) })

View File

@@ -1,5 +1,21 @@
# @nhost/nextjs # @nhost/nextjs
## 1.2.5
### Patch Changes
- 9d32314: Return an error when trying sign to in/up/out from hooks while in the wrong authentication status
The actions of the authentication hooks were not resolving the promise when executed from the wrong authentication status.
They now return an error.
- Updated dependencies [9d32314]
- Updated dependencies [9d32314]
- Updated dependencies [236ce72]
- Updated dependencies [e094e68]
- Updated dependencies [236ce72]
- @nhost/react@0.7.5
- @nhost/core@0.5.4
- @nhost/nhost-js@1.1.11
## 1.2.4 ## 1.2.4
### Patch Changes ### Patch Changes

View File

@@ -1,6 +1,6 @@
{ {
"name": "@nhost/nextjs", "name": "@nhost/nextjs",
"version": "1.2.4", "version": "1.2.5",
"description": "Nhost NextJS library", "description": "Nhost NextJS library",
"license": "MIT", "license": "MIT",
"keywords": [ "keywords": [

View File

@@ -1,5 +1,16 @@
# @nhost/nhost-js # @nhost/nhost-js
## 1.1.11
### Patch Changes
- e094e68: chore: bump axios from 0.26.0 to 0.27.2
fix: add Content-Type to file upload request headers
- Updated dependencies [9d32314]
- Updated dependencies [e094e68]
- @nhost/hasura-auth-js@1.1.6
- @nhost/hasura-storage-js@0.2.2
## 1.1.10 ## 1.1.10
### Patch Changes ### Patch Changes

Some files were not shown because too many files have changed in this diff Show More