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()
slug: /reference/javascript/auth/sign-up
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()`

View File

@@ -4,7 +4,7 @@ title: signIn()
sidebar_label: signIn()
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.
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()`

View File

@@ -4,7 +4,7 @@ title: signOut()
sidebar_label: signOut()
slug: /reference/javascript/auth/sign-out
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()`

View File

@@ -4,7 +4,7 @@ title: resetPassword()
sidebar_label: resetPassword()
slug: /reference/javascript/auth/reset-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()`

View File

@@ -4,7 +4,7 @@ title: changePassword()
sidebar_label: changePassword()
slug: /reference/javascript/auth/change-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()`

View File

@@ -4,7 +4,7 @@ title: sendVerificationEmail()
sidebar_label: sendVerificationEmail()
slug: /reference/javascript/auth/send-verification-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()`

View File

@@ -4,7 +4,7 @@ title: changeEmail()
sidebar_label: changeEmail()
slug: /reference/javascript/auth/change-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()`

View File

@@ -4,7 +4,7 @@ title: deanonymize()
sidebar_label: deanonymize()
slug: /reference/javascript/auth/deanonymize
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()`

View File

@@ -4,7 +4,7 @@ title: onTokenChanged()
sidebar_label: onTokenChanged()
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.
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()`

View File

@@ -4,7 +4,7 @@ title: onAuthStateChanged()
sidebar_label: onAuthStateChanged()
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.
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()`

View File

@@ -4,7 +4,7 @@ title: isAuthenticated()
sidebar_label: isAuthenticated()
slug: /reference/javascript/auth/is-authenticated
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()`

View File

@@ -4,7 +4,7 @@ title: isAuthenticatedAsync()
sidebar_label: isAuthenticatedAsync()
slug: /reference/javascript/auth/is-authenticated-async
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()`

View File

@@ -4,7 +4,7 @@ title: getAuthenticationStatus()
sidebar_label: getAuthenticationStatus()
slug: /reference/javascript/auth/get-authentication-status
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()`

View File

@@ -5,7 +5,7 @@ sidebar_label: getJWTToken()
slug: /reference/javascript/auth/get-jwt-token
sidebar_class_name: deprecated
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()`

View File

@@ -4,7 +4,7 @@ title: getAccessToken()
sidebar_label: getAccessToken()
slug: /reference/javascript/auth/get-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()`

View File

@@ -4,7 +4,7 @@ title: getDecodedAccessToken()
sidebar_label: getDecodedAccessToken()
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)
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()`

View File

@@ -4,7 +4,7 @@ title: getHasuraClaims()
sidebar_label: getHasuraClaims()
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)
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()`

View File

@@ -4,7 +4,7 @@ title: getHasuraClaim()
sidebar_label: getHasuraClaim()
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)
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()`

View File

@@ -4,7 +4,7 @@ title: refreshSession()
sidebar_label: refreshSession()
slug: /reference/javascript/auth/refresh-session
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()`

View File

@@ -4,7 +4,7 @@ title: getSession()
sidebar_label: getSession()
slug: /reference/javascript/auth/get-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()`

View File

@@ -4,7 +4,7 @@ title: getUser()
sidebar_label: getUser()
slug: /reference/javascript/auth/get-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()`

View File

@@ -4,7 +4,7 @@ title: HasuraAuthClient
sidebar_label: Auth
description: No description provided.
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`

View File

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

View File

@@ -4,7 +4,7 @@ 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#L158
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/utils/types.ts#L154
---
# `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
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
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/utils/types.ts#L162
---
# `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
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#L139
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/utils/types.ts#L135
---
# `ApiSignInData`

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -4,7 +4,7 @@ title: useAccessToken()
sidebar_label: useAccessToken()
slug: /reference/nextjs/use-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()`

View File

@@ -5,7 +5,7 @@ sidebar_label: useAuthLoading()
slug: /reference/nextjs/use-auth-loading
sidebar_class_name: deprecated
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()`

View File

@@ -4,7 +4,7 @@ title: useAuthenticated()
sidebar_label: useAuthenticated()
slug: /reference/nextjs/use-authenticated
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()`

View File

@@ -4,7 +4,7 @@ title: useAuthenticationStatus()
sidebar_label: useAuthenticationStatus()
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.
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()`

View File

@@ -4,7 +4,7 @@ title: useNhostBackendUrl()
sidebar_label: useNhostBackendUrl()
slug: /reference/nextjs/use-nhost-backend-url
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()`

View File

@@ -4,7 +4,7 @@ title: useNhostClient()
sidebar_label: useNhostClient()
slug: /reference/nextjs/use-nhost-client
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()`

View File

@@ -4,7 +4,7 @@ title: useProviderLink()
sidebar_label: useProviderLink()
slug: /reference/nextjs/use-provider-link
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()`

View File

@@ -4,7 +4,7 @@ title: useSignInAnonymous()
sidebar_label: useSignInAnonymous()
slug: /reference/nextjs/use-sign-in-anonymous
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()`

View File

@@ -4,7 +4,7 @@ title: useSignInEmailPasswordless()
sidebar_label: useSignInEmailPasswordless()
slug: /reference/nextjs/use-sign-in-email-passwordless
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()`

View File

@@ -4,7 +4,7 @@ title: useSignOut()
sidebar_label: useSignOut()
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)`.
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()`

View File

@@ -4,7 +4,7 @@ title: useSignUpEmailPassword()
sidebar_label: useSignUpEmailPassword()
slug: /reference/nextjs/use-sign-up-email-password
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()`

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`
Provides details about the error
@@ -40,3 +32,11 @@ Provides details about the error
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()
slug: /reference/react/use-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()`

View File

@@ -5,7 +5,7 @@ sidebar_label: useAuthLoading()
slug: /reference/react/use-auth-loading
sidebar_class_name: deprecated
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()`

View File

@@ -4,7 +4,7 @@ title: useAuthenticated()
sidebar_label: useAuthenticated()
slug: /reference/react/use-authenticated
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()`

View File

@@ -4,7 +4,7 @@ title: useAuthenticationStatus()
sidebar_label: useAuthenticationStatus()
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.
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()`

View File

@@ -4,7 +4,7 @@ title: useNhostBackendUrl()
sidebar_label: useNhostBackendUrl()
slug: /reference/react/use-nhost-backend-url
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()`

View File

@@ -4,7 +4,7 @@ title: useNhostClient()
sidebar_label: useNhostClient()
slug: /reference/react/use-nhost-client
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()`

View File

@@ -4,7 +4,7 @@ title: useProviderLink()
sidebar_label: useProviderLink()
slug: /reference/react/use-provider-link
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()`

View File

@@ -4,7 +4,7 @@ title: useSignInAnonymous()
sidebar_label: useSignInAnonymous()
slug: /reference/react/use-sign-in-anonymous
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()`

View File

@@ -4,7 +4,7 @@ title: useSignInEmailPasswordless()
sidebar_label: useSignInEmailPasswordless()
slug: /reference/react/use-sign-in-email-passwordless
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()`

View File

@@ -4,7 +4,7 @@ title: useSignOut()
sidebar_label: useSignOut()
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)`.
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()`

View File

@@ -4,7 +4,7 @@ title: useSignUpEmailPassword()
sidebar_label: useSignUpEmailPassword()
slug: /reference/react/use-sign-up-email-password
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()`

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`
Provides details about the error
@@ -40,3 +32,11 @@ Provides details about the error
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({
color: 'red',
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 {
router.replace('/')

View File

@@ -1,8 +1,5 @@
/* eslint-disable react/react-in-jsx-scope */
import { useEffect } from 'react'
import { Route, Routes, useLocation, useNavigate } from 'react-router-dom'
import { useAuthenticated, useSignOut } from '@nhost/react'
import { Route, Routes } from 'react-router-dom'
import { AuthGate, PublicGate } from './components/auth-gates'
import { AboutPage } from './About'
@@ -19,15 +16,6 @@ import { NotificationsProvider } from '@mantine/notifications'
const title = 'Nhost with React and Apollo'
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 (
<MantineProvider
withGlobalStyles

View File

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

View File

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

View File

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

View File

@@ -1,5 +1,16 @@
# @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
### Patch Changes

View File

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

View File

@@ -10,6 +10,7 @@ export type ErrorPayload = {
export type ValidationErrorPayload = ErrorPayload & { status: typeof VALIDATION_ERROR_CODE }
// TODO share with hasura-auth
export const INVALID_EMAIL_ERROR: ValidationErrorPayload = {
status: VALIDATION_ERROR_CODE,
error: 'invalid-email',
@@ -52,3 +53,39 @@ export const TOKEN_REFRESHER_RUNNING_ERROR: ErrorPayload = {
message:
'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: {
initial: 'awaitingVerification',
initial: 'unknown',
on: {
SIGNED_IN: [
{
@@ -456,10 +456,11 @@ export const createAuthMachine = ({
},
'.valid'
],
SIGNOUT: '.awaitingVerification',
SIGNOUT: '.unknown',
AWAIT_EMAIL_VERIFICATION: '.awaitingVerification'
},
states: {
unknown: {},
awaitingVerification: {},
valid: {}
}

View File

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

View File

@@ -1,5 +1,18 @@
# @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
### Patch Changes

View File

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

View File

@@ -8,12 +8,19 @@ import {
createChangePasswordMachine,
createResetPasswordMachine,
createSendVerificationEmailMachine,
EMAIL_NEEDS_VERIFICATION,
encodeQueryParameters,
ErrorPayload,
INVALID_AUTHENTICATION_METHOD,
INVALID_REFRESH_TOKEN,
JWTClaims,
JWTHasuraClaims,
NO_REFRESH_TOKEN,
rewriteRedirectTo,
TOKEN_REFRESHER_RUNNING_ERROR
TOKEN_REFRESHER_RUNNING_ERROR,
USER_ALREADY_SIGNED_IN,
USER_NOT_ANONYMOUS,
USER_UNAUTHENTICATED
} from '@nhost/core'
import { getSession, isBrowser } from './utils/helpers'
@@ -21,7 +28,6 @@ import {
ApiChangeEmailResponse,
ApiChangePasswordResponse,
ApiDeanonymizeResponse,
ApiError,
ApiResetPasswordResponse,
ApiSendVerificationEmailResponse,
ApiSignOutResponse,
@@ -39,25 +45,6 @@ import {
SignUpResponse
} 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
*/
@@ -108,16 +95,11 @@ export class HasuraAuthClient {
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) => {
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) => {
if (
state.matches({
@@ -173,21 +155,12 @@ export class HasuraAuthClient {
mfa: {
ticket: string
} | null
error: ApiError | null
error: ErrorPayload | null
providerUrl?: string
provider?: string
}> {
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) {
const { provider, options } = params
const providerUrl = encodeQueryParameters(
@@ -203,7 +176,10 @@ export class HasuraAuthClient {
// email password
if ('email' in params && 'password' in params) {
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) => {
if (state.matches({ authentication: 'signedIn' })) {
resolve({
@@ -242,7 +218,10 @@ export class HasuraAuthClient {
// passwordless Email (magic link)
if ('email' in params && !('otp' in params)) {
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) => {
if (
state.matches({
@@ -269,7 +248,10 @@ export class HasuraAuthClient {
// passwordless SMS
if ('phoneNumber' in params && !('otp' in params)) {
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) => {
if (state.matches({ authentication: { signedOut: 'needsSmsOtp' } })) {
resolve({
@@ -291,7 +273,10 @@ export class HasuraAuthClient {
// sign in using SMS OTP
if ('otp' in params) {
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) => {
if (state.matches({ authentication: 'signedIn' })) {
resolve({
@@ -312,7 +297,7 @@ export class HasuraAuthClient {
// * Anonymous sign-in
const { changed } = interpreter.send('SIGNIN_ANONYMOUS')
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) => {
interpreter.onTransition((state) => {
@@ -342,11 +327,11 @@ export class HasuraAuthClient {
*/
async signOut(params?: { all?: boolean }): Promise<ApiSignOutResponse> {
const interpreter = await this.waitUntilReady()
if (!this.isAuthenticated()) {
return { error: USER_UNAUTHENTICATED }
}
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) => {
if (state.matches({ authentication: { signedOut: 'success' } })) {
resolve({ error: null })
@@ -703,25 +688,25 @@ export class HasuraAuthClient {
*/
async refreshSession(refreshToken?: string): Promise<{
session: Session | null
error: ApiError | null
error: ErrorPayload | null
}> {
try {
const interpreter = await this.waitUntilReady()
if (!interpreter.state.matches({ token: 'idle' })) {
return { session: null, error: TOKEN_REFRESHER_RUNNING_ERROR }
}
return new Promise((resolve) => {
const token = refreshToken || interpreter.state.context.refreshToken.value
if (!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) => {
if (state.matches({ token: { idle: 'error' } })) {
resolve({
session: null,
// * 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') {
resolve({ session: getSession(state.context), error: null })
@@ -729,6 +714,7 @@ export class HasuraAuthClient {
})
})
} catch (error: any) {
// TODO return error in the correct format
return { session: null, error: error.message }
}
}

View File

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

View File

@@ -1,5 +1,12 @@
# @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
### Patch Changes

View File

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

View File

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

View File

@@ -1,5 +1,21 @@
# @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
### Patch Changes

View File

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

View File

@@ -1,5 +1,16 @@
# @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
### Patch Changes

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