Compare commits

..

42 Commits

Author SHA1 Message Date
Pilou
5ff6876aea Merge pull request #918 from nhost/changeset-release/main
chore: update versions
2022-09-05 10:54:49 +02:00
github-actions[bot]
d392ed86fb chore: update versions 2022-09-05 08:27:06 +00:00
Pilou
3bbe09c4b1 Merge pull request #917 from nhost/fix-passwordless-email-options
fix: add options to `nhost.auth.signIn({ email, options })`
2022-09-05 10:25:30 +02:00
Pierre-Louis Mercereau
a47ce29173 fix: add options to nhost.auth.signIn({ email, options }) 2022-09-05 09:57:46 +02:00
Pilou
42fba7a095 Merge pull request #907 from nhost/core-typings
fix: improve typings
2022-08-30 11:24:13 +02:00
Pierre-Louis Mercereau
0ff633760a Merge branch 'main' into core-typings 2022-08-30 11:09:05 +02:00
Pilou
6c51571182 Merge pull request #909 from nhost/bump-storage-version-0.2.4
ci: bump hasura-storage version to 0.2.4
2022-08-30 11:08:44 +02:00
Pierre-Louis Mercereau
3825a09aed ci: bump hasura-storage version to 0.2.4 2022-08-30 10:25:57 +02:00
Pierre-Louis Mercereau
1768b1e069 docs: comment types & interfaces 2022-08-30 09:23:53 +02:00
Pierre-Louis Mercereau
fba5c819ce fix: improve typings 2022-08-29 21:39:26 +02:00
Johan Eliasson
9dea25ebe1 Merge pull request #900 from nhost/changeset-release/main
chore: update versions
2022-08-25 10:58:02 +02:00
github-actions[bot]
9b063abe32 chore: update versions 2022-08-25 07:53:20 +00:00
Johan Eliasson
cea97ba333 Merge pull request #898 from nhost/changeset-iasgd9ad
adding changeset for storage upload
2022-08-25 09:52:09 +02:00
Johan Eliasson
607c457f9d adding changeset for storage upload 2022-08-25 09:14:56 +02:00
Johan Eliasson
6ea9ed69ce Merge pull request #893 from nhost/fix/storage-in-node
Make @nhost/storage-js work on non-browser environments
2022-08-25 09:03:16 +02:00
Johan Eliasson
6450dcc02e overloading 2022-08-25 08:20:31 +02:00
Johan Eliasson
0b18704d5b updates 2022-08-24 18:04:07 +02:00
Johan Eliasson
0c53f9034e adding empty functions folder for nhost-js 2022-08-24 15:07:52 +02:00
Johan Eliasson
0c90292779 adding correct health check endpoints and new vite config files where needed 2022-08-24 15:05:24 +02:00
Johan Eliasson
2333aeb0c8 no tests 2022-08-24 14:58:13 +02:00
Johan Eliasson
3b686a231b use GET request 2022-08-24 14:47:01 +02:00
Johan Eliasson
136b85c5fb add empty package.json in the functions folder 2022-08-24 13:53:30 +02:00
Johan Eliasson
3d715d5f95 wait for hasura console to be up' 2022-08-24 10:38:34 +02:00
Johan Eliasson
6d5295aeca exclude is not needed as we're using include 2022-08-24 10:29:26 +02:00
Johan Eliasson
45f6285249 vite config for storage-js 2022-08-24 10:21:02 +02:00
Pierre-Louis Mercereau
01fb999c7d ci: remove chown 2022-08-24 10:14:52 +02:00
Johan Eliasson
8b8412d5fa exclude paths for vitest 2022-08-24 10:11:51 +02:00
Pierre-Louis Mercereau
0f1311c5b0 ci: correct gh expression 2022-08-24 10:09:34 +02:00
Pierre-Louis Mercereau
6b197aa886 ci: chown package folder 2022-08-24 10:05:14 +02:00
Pierre-Louis Mercereau
0353c6648e ci: change permissions 2022-08-24 09:58:55 +02:00
Johan Eliasson
978b8f8f68 install cli as sudo 2022-08-24 09:37:06 +02:00
Johan Eliasson
3643449a9a update 2022-08-24 07:59:04 +02:00
Johan Eliasson
8e25971e7d move nhost folder 2022-08-24 07:44:24 +02:00
Johan Eliasson
5cf05c8731 correct config 2022-08-23 13:51:48 +02:00
Johan Eliasson
4da70abcfb cleanup 2022-08-23 13:50:31 +02:00
Johan Eliasson
2d5203872c delete test functions folder 2022-08-23 13:49:31 +02:00
Johan Eliasson
882f1531ab update types and docs 2022-08-23 13:47:48 +02:00
Johan Eliasson
6126d77b01 updated tests 2022-08-23 13:47:48 +02:00
Johan Eliasson
09debbd746 Merge branch 'main' into fix/storage-in-node 2022-08-23 12:12:51 +02:00
Johan Eliasson
604ed6b314 readme update 2022-08-23 12:12:11 +02:00
Johan Eliasson
2f1fec1dcf new tests 2022-08-23 12:07:19 +02:00
Johan Eliasson
70f537841f make storage work on server 2022-08-23 08:01:28 +02:00
198 changed files with 1923 additions and 852 deletions

View File

@@ -4,7 +4,7 @@ title: signUp()
sidebar_label: signUp()
slug: /reference/javascript/auth/sign-up
description: Use `nhost.auth.signUp` to sign up a user using email and password. If you want to sign up a user using passwordless email (Magic Link), SMS, or an OAuth provider, use the `signIn` function instead.
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L103
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L102
---
# `signUp()`

View File

@@ -4,7 +4,7 @@ title: signIn()
sidebar_label: signIn()
slug: /reference/javascript/auth/sign-in
description: Use `nhost.auth.signIn` to sign in a user using email and password, passwordless (email or sms) or an external provider. `signIn` can be used to sign in a user in various ways depending on the parameters.
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L146
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L145
---
# `signIn()`

View File

@@ -4,7 +4,7 @@ title: signOut()
sidebar_label: signOut()
slug: /reference/javascript/auth/sign-out
description: Use `nhost.auth.signOut` to sign out the user.
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L231
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L233
---
# `signOut()`

View File

@@ -4,7 +4,7 @@ title: resetPassword()
sidebar_label: resetPassword()
slug: /reference/javascript/auth/reset-password
description: Use `nhost.auth.resetPassword` to reset the password for a user. This will send a reset-password link in an email to the user. When the user clicks the reset-password link the user is automatically signed-in. Once signed-in, the user can change their password using `nhost.auth.changePassword()`.
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L247
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L249
---
# `resetPassword()`

View File

@@ -4,7 +4,7 @@ title: changePassword()
sidebar_label: changePassword()
slug: /reference/javascript/auth/change-password
description: Use `nhost.auth.changePassword` to change the password for the signed-in user. The old password is not needed. In case the user is not signed-in, a password reset ticket needs to be provided.
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L263
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L265
---
# `changePassword()`

View File

@@ -4,7 +4,7 @@ title: sendVerificationEmail()
sidebar_label: sendVerificationEmail()
slug: /reference/javascript/auth/send-verification-email
description: Use `nhost.auth.sendVerificationEmail` to send a verification email to the specified email. The email contains a verification-email link. When the user clicks the verification-email link their email is verified.
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L279
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L284
---
# `sendVerificationEmail()`

View File

@@ -4,7 +4,7 @@ title: changeEmail()
sidebar_label: changeEmail()
slug: /reference/javascript/auth/change-email
description: Use `nhost.auth.changeEmail` to change a user's email. This will send a confirm-email-change link in an email to the new email. Once the user clicks on the confirm-email-change link the email will be change to the new email.
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L298
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L303
---
# `changeEmail()`

View File

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

View File

@@ -4,7 +4,7 @@ title: onTokenChanged()
sidebar_label: onTokenChanged()
slug: /reference/javascript/auth/on-token-changed
description: Use `nhost.auth.onTokenChanged` to add a custom function that runs every time the access or refresh token is changed.
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L357
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L362
---
# `onTokenChanged()`

View File

@@ -4,7 +4,7 @@ title: onAuthStateChanged()
sidebar_label: onAuthStateChanged()
slug: /reference/javascript/auth/on-auth-state-changed
description: Use `nhost.auth.onAuthStateChanged` to add a custom function that runs every time the authentication status of the user changes. E.g. add a custom function that runs every time the authentication status changes from signed-in to signed-out.
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L392
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L397
---
# `onAuthStateChanged()`

View File

@@ -4,7 +4,7 @@ title: isAuthenticated()
sidebar_label: isAuthenticated()
slug: /reference/javascript/auth/is-authenticated
description: Use `nhost.auth.isAuthenticated` to check if the user is authenticated or not.
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L434
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L439
---
# `isAuthenticated()`

View File

@@ -4,7 +4,7 @@ title: isAuthenticatedAsync()
sidebar_label: isAuthenticatedAsync()
slug: /reference/javascript/auth/is-authenticated-async
description: Use `nhost.auth.isAuthenticatedAsync` to wait (await) for any internal authentication network requests to finish and then return the authentication status.
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L452
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L457
---
# `isAuthenticatedAsync()`

View File

@@ -4,7 +4,7 @@ title: getAuthenticationStatus()
sidebar_label: getAuthenticationStatus()
slug: /reference/javascript/auth/get-authentication-status
description: Use `nhost.auth.getAuthenticationStatus` to get the authentication status of the user.
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L478
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L483
---
# `getAuthenticationStatus()`

View File

@@ -4,7 +4,7 @@ title: getAccessToken()
sidebar_label: getAccessToken()
slug: /reference/javascript/auth/get-access-token
description: Use `nhost.auth.getAccessToken` to get the access token of the user.
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L508
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L513
---
# `getAccessToken()`

View File

@@ -4,7 +4,7 @@ title: getDecodedAccessToken()
sidebar_label: getDecodedAccessToken()
slug: /reference/javascript/auth/get-decoded-access-token
description: Use `nhost.auth.getDecodedAccessToken` to get the decoded access token of the user.
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L523
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L528
---
# `getDecodedAccessToken()`

View File

@@ -4,7 +4,7 @@ title: getHasuraClaims()
sidebar_label: getHasuraClaims()
slug: /reference/javascript/auth/get-hasura-claims
description: Use `nhost.auth.getHasuraClaims` to get the Hasura claims of the user.
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L540
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L545
---
# `getHasuraClaims()`

View File

@@ -4,7 +4,7 @@ title: getHasuraClaim()
sidebar_label: getHasuraClaim()
slug: /reference/javascript/auth/get-hasura-claim
description: Use `nhost.auth.getHasuraClaim` to get the value of a specific Hasura claim of the user.
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L558
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L563
---
# `getHasuraClaim()`

View File

@@ -4,7 +4,7 @@ title: refreshSession()
sidebar_label: refreshSession()
slug: /reference/javascript/auth/refresh-session
description: Use `nhost.auth.refreshSession` to refresh the session with either the current internal refresh token or an external refresh token.
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L581
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L586
---
# `refreshSession()`

View File

@@ -4,7 +4,7 @@ title: getSession()
sidebar_label: getSession()
slug: /reference/javascript/auth/get-session
description: Use `nhost.auth.getSession()` to get the session of the user.
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L625
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L627
---
# `getSession()`

View File

@@ -4,7 +4,7 @@ title: getUser()
sidebar_label: getUser()
slug: /reference/javascript/auth/get-user
description: Use `nhost.auth.getUser()` to get the signed-in user.
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L640
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L642
---
# `getUser()`

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

View File

@@ -1,18 +0,0 @@
---
# ⚠️ AUTO-GENERATED CONTENT. DO NOT EDIT THIS FILE DIRECTLY! ⚠️
title: ApiChangeEmailResponse
sidebar_label: ApiChangeEmailResponse
description: No description provided.
displayed_sidebar: referenceSidebar
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/utils/types.ts#L182
---
# `ApiChangeEmailResponse`
## Parameters
---
**<span className="parameter-name">error</span>** <span className="optional-status">required</span> `null` | `ErrorPayload`
---

View File

@@ -1,18 +0,0 @@
---
# ⚠️ AUTO-GENERATED CONTENT. DO NOT EDIT THIS FILE DIRECTLY! ⚠️
title: ApiChangePasswordResponse
sidebar_label: ApiChangePasswordResponse
description: No description provided.
displayed_sidebar: referenceSidebar
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/utils/types.ts#L174
---
# `ApiChangePasswordResponse`
## Parameters
---
**<span className="parameter-name">error</span>** <span className="optional-status">required</span> `null` | `ErrorPayload`
---

View File

@@ -1,18 +0,0 @@
---
# ⚠️ AUTO-GENERATED CONTENT. DO NOT EDIT THIS FILE DIRECTLY! ⚠️
title: ApiDeanonymizeResponse
sidebar_label: ApiDeanonymizeResponse
description: No description provided.
displayed_sidebar: referenceSidebar
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/utils/types.ts#L186
---
# `ApiDeanonymizeResponse`
## Parameters
---
**<span className="parameter-name">error</span>** <span className="optional-status">required</span> `null` | `ErrorPayload`
---

View File

@@ -1,16 +0,0 @@
---
# ⚠️ AUTO-GENERATED CONTENT. DO NOT EDIT THIS FILE DIRECTLY! ⚠️
title: ApiRefreshTokenResponse
sidebar_label: ApiRefreshTokenResponse
description: No description provided.
displayed_sidebar: referenceSidebar
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/utils/types.ts#L162
---
# `ApiRefreshTokenResponse`
```ts
type ApiRefreshTokenResponse =
| { session: null; error: ErrorPayload }
| { session: Session; error: null }
```

View File

@@ -1,18 +0,0 @@
---
# ⚠️ AUTO-GENERATED CONTENT. DO NOT EDIT THIS FILE DIRECTLY! ⚠️
title: ApiResetPasswordResponse
sidebar_label: ApiResetPasswordResponse
description: No description provided.
displayed_sidebar: referenceSidebar
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/utils/types.ts#L170
---
# `ApiResetPasswordResponse`
## Parameters
---
**<span className="parameter-name">error</span>** <span className="optional-status">required</span> `null` | `ErrorPayload`
---

View File

@@ -1,18 +0,0 @@
---
# ⚠️ AUTO-GENERATED CONTENT. DO NOT EDIT THIS FILE DIRECTLY! ⚠️
title: ApiSendVerificationEmailResponse
sidebar_label: ApiSendVerificationEmailResponse
description: No description provided.
displayed_sidebar: referenceSidebar
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/utils/types.ts#L178
---
# `ApiSendVerificationEmailResponse`
## Parameters
---
**<span className="parameter-name">error</span>** <span className="optional-status">required</span> `null` | `ErrorPayload`
---

View File

@@ -1,29 +0,0 @@
---
# ⚠️ AUTO-GENERATED CONTENT. DO NOT EDIT THIS FILE DIRECTLY! ⚠️
title: ApiSignInData
sidebar_label: ApiSignInData
description: No description provided.
displayed_sidebar: referenceSidebar
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/utils/types.ts#L151
---
# `ApiSignInData`
## Parameters
---
**<span className="parameter-name">session</span>** <span className="optional-status">required</span> [`Session`](/reference/docgen/javascript/auth/types/session)
| Property | Type | Required | Notes |
| :------------------------------------------------------------------------------------------------------- | :--------------------------------------------------------------- | :------: | :---- |
| <span className="parameter-name"><span className="light-grey">session.</span>user</span> | `null` \| [`User`](/reference/docgen/javascript/auth/types/user) | ✔️ | |
| <span className="parameter-name"><span className="light-grey">session.</span>refreshToken</span> | `string` | ✔️ | |
| <span className="parameter-name"><span className="light-grey">session.</span>accessTokenExpiresIn</span> | `number` | ✔️ | |
| <span className="parameter-name"><span className="light-grey">session.</span>accessToken</span> | `string` | ✔️ | |
---
**<span className="parameter-name">mfa</span>** <span className="optional-status">required</span> `null` | [`Mfa`](/reference/docgen/javascript/auth/types/mfa)
---

View File

@@ -1,16 +0,0 @@
---
# ⚠️ AUTO-GENERATED CONTENT. DO NOT EDIT THIS FILE DIRECTLY! ⚠️
title: ApiSignInResponse
sidebar_label: ApiSignInResponse
description: No description provided.
displayed_sidebar: referenceSidebar
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/utils/types.ts#L155
---
# `ApiSignInResponse`
```ts
type ApiSignInResponse =
| { data: ApiSignInData; error: null }
| { data: null; error: ErrorPayload }
```

View File

@@ -1,18 +0,0 @@
---
# ⚠️ AUTO-GENERATED CONTENT. DO NOT EDIT THIS FILE DIRECTLY! ⚠️
title: ApiSignOutResponse
sidebar_label: ApiSignOutResponse
description: No description provided.
displayed_sidebar: referenceSidebar
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/utils/types.ts#L166
---
# `ApiSignOutResponse`
## Parameters
---
**<span className="parameter-name">error</span>** <span className="optional-status">required</span> `null` | `ErrorPayload`
---

View File

@@ -1,16 +0,0 @@
---
# ⚠️ AUTO-GENERATED CONTENT. DO NOT EDIT THIS FILE DIRECTLY! ⚠️
title: ApiSignUpEmailPasswordResponse
sidebar_label: ApiSignUpEmailPasswordResponse
description: No description provided.
displayed_sidebar: referenceSidebar
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/utils/types.ts#L147
---
# `ApiSignUpEmailPasswordResponse`
```ts
type ApiSignUpEmailPasswordResponse =
| { session: null; error: ErrorPayload }
| { session: Session; error: null }
```

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#L135
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/utils/types.ts#L100
---
# `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#L137
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/utils/types.ts#L102
---
# `AuthChangedFunction`
@@ -12,6 +12,6 @@ custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-j
```ts
type AuthChangedFunction = () => (
event: AuthChangeEvent,
session: Session | null
session: NhostSession | null
) => void
```

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#L106
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/utils/types.ts#L82
---
# `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#L96
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/utils/types.ts#L72
---
# `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#L111
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/utils/types.ts#L87
---
# `DeanonymizeParams`

View File

@@ -1,18 +0,0 @@
---
# ⚠️ AUTO-GENERATED CONTENT. DO NOT EDIT THIS FILE DIRECTLY! ⚠️
title: Headers
sidebar_label: Headers
description: No description provided.
displayed_sidebar: referenceSidebar
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/utils/types.ts#L140
---
# `Headers`
## Parameters
---
**<span className="parameter-name">Authorization</span>** <span className="optional-status">optional</span> `string`
---

View File

@@ -1,18 +0,0 @@
---
# ⚠️ AUTO-GENERATED CONTENT. DO NOT EDIT THIS FILE DIRECTLY! ⚠️
title: Mfa
sidebar_label: Mfa
description: No description provided.
displayed_sidebar: referenceSidebar
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/utils/types.ts#L143
---
# `Mfa`
## Parameters
---
**<span className="parameter-name">ticket</span>** <span className="optional-status">required</span> `string`
---

View File

@@ -4,11 +4,11 @@ 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#L139
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/utils/types.ts#L104
---
# `OnTokenChangedFunction`
```ts
type OnTokenChangedFunction = () => (session: Session | null) => void
type OnTokenChangedFunction = () => (session: NhostSession | null) => void
```

View File

@@ -4,7 +4,7 @@ title: Provider
sidebar_label: Provider
description: No description provided.
displayed_sidebar: referenceSidebar
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/core/src/types.ts#L140
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/core/src/types.ts#L141
---
# `Provider`

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

View File

@@ -1,30 +0,0 @@
---
# ⚠️ AUTO-GENERATED CONTENT. DO NOT EDIT THIS FILE DIRECTLY! ⚠️
title: Session
sidebar_label: Session
description: No description provided.
displayed_sidebar: referenceSidebar
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/utils/types.ts#L23
---
# `Session`
## Parameters
---
**<span className="parameter-name">accessToken</span>** <span className="optional-status">required</span> `string`
---
**<span className="parameter-name">accessTokenExpiresIn</span>** <span className="optional-status">required</span> `number`
---
**<span className="parameter-name">refreshToken</span>** <span className="optional-status">required</span> `string`
---
**<span className="parameter-name">user</span>** <span className="optional-status">required</span> `null` | [`User`](/reference/docgen/javascript/auth/types/user)
---

View File

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

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#L54
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/utils/types.ts#L30
---
# `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#L83
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/utils/types.ts#L59
---
# `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#L64
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/utils/types.ts#L40
---
# `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#L74
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/utils/types.ts#L50
---
# `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#L69
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/utils/types.ts#L45
---
# `SignInPasswordlessSmsParams`

View File

@@ -1,34 +0,0 @@
---
# ⚠️ AUTO-GENERATED CONTENT. DO NOT EDIT THIS FILE DIRECTLY! ⚠️
title: SignInReponse
sidebar_label: SignInReponse
description: No description provided.
displayed_sidebar: referenceSidebar
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/utils/types.ts#L124
---
# `SignInReponse`
## Parameters
---
**<span className="parameter-name">session</span>** <span className="optional-status">required</span> `null` | [`Session`](/reference/docgen/javascript/auth/types/session)
---
**<span className="parameter-name">error</span>** <span className="optional-status">required</span> `null` | `ErrorPayload`
---
**<span className="parameter-name">mfa</span>** <span className="optional-status">optional</span> `{ enabled: boolean, ticket: string }`
---
**<span className="parameter-name">providerUrl</span>** <span className="optional-status">optional</span> `string`
---
**<span className="parameter-name">provider</span>** <span className="optional-status">optional</span> `string`
---

View File

@@ -1,34 +0,0 @@
---
# ⚠️ AUTO-GENERATED CONTENT. DO NOT EDIT THIS FILE DIRECTLY! ⚠️
title: SignInResponse
sidebar_label: SignInResponse
description: No description provided.
displayed_sidebar: referenceSidebar
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/utils/types.ts#L45
---
# `SignInResponse`
## Parameters
---
**<span className="parameter-name">session</span>** <span className="optional-status">required</span> `null` | [`Session`](/reference/docgen/javascript/auth/types/session)
---
**<span className="parameter-name">mfa</span>** <span className="optional-status">required</span> `null` | `{ ticket: string }`
---
**<span className="parameter-name">error</span>** <span className="optional-status">required</span> `null` | `ErrorPayload`
---
**<span className="parameter-name">providerUrl</span>** <span className="optional-status">optional</span> `string`
---
**<span className="parameter-name">provider</span>** <span className="optional-status">optional</span> `string`
---

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#L78
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/utils/types.ts#L54
---
# `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#L31
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/utils/types.ts#L23
---
# `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#L37
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/utils/types.ts#L29
---
# `SignUpParams`

View File

@@ -1,16 +0,0 @@
---
# ⚠️ AUTO-GENERATED CONTENT. DO NOT EDIT THIS FILE DIRECTLY! ⚠️
title: SignUpResponse
sidebar_label: SignUpResponse
description: No description provided.
displayed_sidebar: referenceSidebar
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/utils/types.ts#L39
---
# `SignUpResponse`
```ts
type SignUpResponse =
| { session: null; error: ErrorPayload }
| { session: Session | null; error: null }
```

View File

@@ -4,7 +4,7 @@ title: User
sidebar_label: User
description: User information
displayed_sidebar: referenceSidebar
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/core/src/types.ts#L93
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/core/src/types.ts#L94
---
# `User`

View File

@@ -3,25 +3,25 @@
title: upload()
sidebar_label: upload()
slug: /reference/javascript/storage/upload
description: Use `nhost.storage.upload` to upload a file. The `file` must be of type [`File`](https://developer.mozilla.org/en-US/docs/Web/API/File).
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-storage-js/src/packages/hasura-storage-js/src/hasura-storage-client.ts#L52
description: Use `nhost.storage.upload` to upload a file.
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-storage-js/src/packages/hasura-storage-js/src/hasura-storage-client.ts#L76
---
# `upload()`
Use `nhost.storage.upload` to upload a file. The `file` must be of type [`File`](https://developer.mozilla.org/en-US/docs/Web/API/File).
## Overload 1 of 2
If no `bucket` is specified the `default` bucket will be used.
Use `nhost.storage.upload` to upload a file.
```ts
await nhost.storage.upload({ file })
```
It's possible to use [`File`](https://developer.mozilla.org/en-US/docs/Web/API/File) or [`FormData`](https://developer.mozilla.org/en-US/docs/Web/API/FormData) to upload a file. The `File` instance is only available in the browser while `FormData` with [`form-data`](https://www.npmjs.com/package/form-data) works both in the browser and in NodeJS (server).
## Parameters
If no `bucketId` is specified the bucket `default` is used.
### Parameters
---
**<span className="parameter-name">params</span>** <span className="optional-status">required</span> [`StorageUploadParams`](/reference/docgen/javascript/storage/types/storage-upload-params)
**<span className="parameter-name">params</span>** <span className="optional-status">required</span> [`StorageUploadFileParams`](/reference/docgen/javascript/storage/types/storage-upload-file-params)
| Property | Type | Required | Notes |
| :------------------------------------------------------------------------------------------ | :------- | :------: | :---- |
@@ -32,12 +32,44 @@ await nhost.storage.upload({ file })
---
## Examples
### Examples
Upload a file from a browser using `File`.
```ts
await nhost.storage.upload({ file })
```
Upload a file from a browser using `File` to a specific Bucket.
```ts
await nhost.storage.upload({ file, bucketId: '<Bucket-ID>' })
```
Upload a file from a server using `FormData` with [`form-data`](https://www.npmjs.com/package/form-data).
```ts
const fd = new FormData()
fd.append('file', fs.createReadStream('./tests/assets/sample.pdf'))
await storage.upload({
formData: fd
})
```
## Overload 2 of 2
### Parameters
---
**<span className="parameter-name">params</span>** <span className="optional-status">required</span> [`StorageUploadFormDataParams`](/reference/docgen/javascript/storage/types/storage-upload-form-data-params)
| Property | Type | Required | Notes |
| :------------------------------------------------------------------------------------------ | :--------- | :------: | :---- |
| <span className="parameter-name"><span className="light-grey">params.</span>formData</span> | `FormData` | ✔️ | |
| <span className="parameter-name"><span className="light-grey">params.</span>bucketId</span> | `string` | | |
| <span className="parameter-name"><span className="light-grey">params.</span>name</span> | `string` | | |
| <span className="parameter-name"><span className="light-grey">params.</span>id</span> | `string` | | |
---

View File

@@ -5,7 +5,7 @@ sidebar_label: getUrl()
slug: /reference/javascript/storage/get-url
sidebar_class_name: deprecated
description: No description provided.
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-storage-js/src/packages/hasura-storage-js/src/hasura-storage-client.ts#L74
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-storage-js/src/packages/hasura-storage-js/src/hasura-storage-client.ts#L106
---
# `getUrl()`

View File

@@ -4,7 +4,7 @@ title: getPublicUrl()
sidebar_label: getPublicUrl()
slug: /reference/javascript/storage/get-public-url
description: Use `nhost.storage.getPublicUrl` to get the public URL of a file. The public URL can be used for un-authenticated users to access files. To access public files the `public` role must have permissions to select the file in the `storage.files` table.
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-storage-js/src/packages/hasura-storage-js/src/hasura-storage-client.ts#L88
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-storage-js/src/packages/hasura-storage-js/src/hasura-storage-client.ts#L120
---
# `getPublicUrl()`

View File

@@ -4,7 +4,7 @@ title: getPresignedUrl()
sidebar_label: getPresignedUrl()
slug: /reference/javascript/storage/get-presigned-url
description: Use `nhost.storage.getPresignedUrl` to get a presigned URL of a file. To get a presigned URL the user must have permission to select the file in the `storage.files` table.
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-storage-js/src/packages/hasura-storage-js/src/hasura-storage-client.ts#L110
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-storage-js/src/packages/hasura-storage-js/src/hasura-storage-client.ts#L142
---
# `getPresignedUrl()`

View File

@@ -4,7 +4,7 @@ title: delete()
sidebar_label: delete()
slug: /reference/javascript/storage/delete
description: Use `nhost.storage.delete` to delete a file. To delete a file the user must have permissions to delete the file in the `storage.files` table. Deleting the file using `nhost.storage.delete()` will delete both the file and its metadata.
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-storage-js/src/packages/hasura-storage-js/src/hasura-storage-client.ts#L135
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-storage-js/src/packages/hasura-storage-js/src/hasura-storage-client.ts#L167
---
# `delete()`

View File

@@ -4,7 +4,7 @@ title: setAccessToken()
sidebar_label: setAccessToken()
slug: /reference/javascript/storage/set-access-token
description: Use `nhost.storage.setAccessToken` to a set an access token to be used in subsequent storage requests. Note that if you're signin in users with `nhost.auth.signIn()` the access token will be set automatically.
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-storage-js/src/packages/hasura-storage-js/src/hasura-storage-client.ts#L156
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-storage-js/src/packages/hasura-storage-js/src/hasura-storage-client.ts#L188
---
# `setAccessToken()`

View File

@@ -4,7 +4,7 @@ title: setAdminSecret()
sidebar_label: setAdminSecret()
slug: /reference/javascript/storage/set-admin-secret
description: Use `nhost.storage.adminSecret` to set the admin secret to be used for subsequent storage requests. This is useful if you want to run storage in "admin mode".
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-storage-js/src/packages/hasura-storage-js/src/hasura-storage-client.ts#L174
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-storage-js/src/packages/hasura-storage-js/src/hasura-storage-client.ts#L206
---
# `setAdminSecret()`

View File

@@ -4,7 +4,7 @@ title: HasuraStorageClient
sidebar_label: Storage
description: No description provided.
slug: /reference/javascript/storage
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-storage-js/src/packages/hasura-storage-js/src/hasura-storage-client.ts#L25
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-storage-js/src/packages/hasura-storage-js/src/hasura-storage-client.ts#L29
---
# `HasuraStorageClient`

View File

@@ -27,6 +27,6 @@ custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-storag
---
**<span className="parameter-name">params</span>** <span className="optional-status">required</span> `Partial<StorageUploadParams>`
**<span className="parameter-name">params</span>** <span className="optional-status">required</span> `Partial<StorageUploadFileParams>`
---

View File

@@ -4,7 +4,7 @@ title: ApiDeleteParams
sidebar_label: ApiDeleteParams
description: No description provided.
displayed_sidebar: referenceSidebar
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-storage-js/src/packages/hasura-storage-js/src/utils/types.ts#L69
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-storage-js/src/packages/hasura-storage-js/src/utils/types.ts#L84
---
# `ApiDeleteParams`

View File

@@ -4,7 +4,7 @@ title: ApiDeleteResponse
sidebar_label: ApiDeleteResponse
description: No description provided.
displayed_sidebar: referenceSidebar
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-storage-js/src/packages/hasura-storage-js/src/utils/types.ts#L73
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-storage-js/src/packages/hasura-storage-js/src/utils/types.ts#L88
---
# `ApiDeleteResponse`

View File

@@ -4,7 +4,7 @@ title: ApiGetPresignedUrlParams
sidebar_label: ApiGetPresignedUrlParams
description: No description provided.
displayed_sidebar: referenceSidebar
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-storage-js/src/packages/hasura-storage-js/src/utils/types.ts#L61
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-storage-js/src/packages/hasura-storage-js/src/utils/types.ts#L76
---
# `ApiGetPresignedUrlParams`

View File

@@ -4,7 +4,7 @@ title: ApiGetPresignedUrlResponse
sidebar_label: ApiGetPresignedUrlResponse
description: No description provided.
displayed_sidebar: referenceSidebar
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-storage-js/src/packages/hasura-storage-js/src/utils/types.ts#L65
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-storage-js/src/packages/hasura-storage-js/src/utils/types.ts#L80
---
# `ApiGetPresignedUrlResponse`

View File

@@ -4,7 +4,7 @@ title: ApiUploadParams
sidebar_label: ApiUploadParams
description: No description provided.
displayed_sidebar: referenceSidebar
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-storage-js/src/packages/hasura-storage-js/src/utils/types.ts#L50
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-storage-js/src/packages/hasura-storage-js/src/utils/types.ts#L65
---
# `ApiUploadParams`
@@ -13,7 +13,7 @@ custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-storag
---
**<span className="parameter-name">file</span>** <span className="optional-status">required</span> `FormData`
**<span className="parameter-name">formData</span>** <span className="optional-status">required</span> `FormData`
---

View File

@@ -4,7 +4,7 @@ title: ApiUploadResponse
sidebar_label: ApiUploadResponse
description: No description provided.
displayed_sidebar: referenceSidebar
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-storage-js/src/packages/hasura-storage-js/src/utils/types.ts#L57
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-storage-js/src/packages/hasura-storage-js/src/utils/types.ts#L72
---
# `ApiUploadResponse`

View File

@@ -4,7 +4,7 @@ title: NhostClientReturnType
sidebar_label: NhostClientReturnType
description: No description provided.
displayed_sidebar: referenceSidebar
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-storage-js/src/packages/hasura-storage-js/src/utils/types.ts#L4
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-storage-js/src/packages/hasura-storage-js/src/utils/types.ts#L6
---
# `NhostClientReturnType`

View File

@@ -4,7 +4,7 @@ title: StorageDeleteParams
sidebar_label: StorageDeleteParams
description: No description provided.
displayed_sidebar: referenceSidebar
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-storage-js/src/packages/hasura-storage-js/src/utils/types.ts#L32
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-storage-js/src/packages/hasura-storage-js/src/utils/types.ts#L47
---
# `StorageDeleteParams`

View File

@@ -4,7 +4,7 @@ title: StorageDeleteResponse
sidebar_label: StorageDeleteResponse
description: No description provided.
displayed_sidebar: referenceSidebar
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-storage-js/src/packages/hasura-storage-js/src/utils/types.ts#L36
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-storage-js/src/packages/hasura-storage-js/src/utils/types.ts#L51
---
# `StorageDeleteResponse`

View File

@@ -4,7 +4,7 @@ title: StorageGetPresignedUrlParams
sidebar_label: StorageGetPresignedUrlParams
description: No description provided.
displayed_sidebar: referenceSidebar
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-storage-js/src/packages/hasura-storage-js/src/utils/types.ts#L24
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-storage-js/src/packages/hasura-storage-js/src/utils/types.ts#L39
---
# `StorageGetPresignedUrlParams`

View File

@@ -4,7 +4,7 @@ title: StorageGetPresignedUrlResponse
sidebar_label: StorageGetPresignedUrlResponse
description: No description provided.
displayed_sidebar: referenceSidebar
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-storage-js/src/packages/hasura-storage-js/src/utils/types.ts#L28
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-storage-js/src/packages/hasura-storage-js/src/utils/types.ts#L43
---
# `StorageGetPresignedUrlResponse`

View File

@@ -4,7 +4,7 @@ title: StorageGetUrlParams
sidebar_label: StorageGetUrlParams
description: No description provided.
displayed_sidebar: referenceSidebar
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-storage-js/src/packages/hasura-storage-js/src/utils/types.ts#L20
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-storage-js/src/packages/hasura-storage-js/src/utils/types.ts#L35
---
# `StorageGetUrlParams`

View File

@@ -0,0 +1,30 @@
---
# ⚠️ AUTO-GENERATED CONTENT. DO NOT EDIT THIS FILE DIRECTLY! ⚠️
title: StorageUploadFileParams
sidebar_label: StorageUploadFileParams
description: No description provided.
displayed_sidebar: referenceSidebar
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-storage-js/src/packages/hasura-storage-js/src/utils/types.ts#L13
---
# `StorageUploadFileParams`
## Parameters
---
**<span className="parameter-name">file</span>** <span className="optional-status">required</span> `File`
---
**<span className="parameter-name">bucketId</span>** <span className="optional-status">optional</span> `string`
---
**<span className="parameter-name">name</span>** <span className="optional-status">optional</span> `string`
---
**<span className="parameter-name">id</span>** <span className="optional-status">optional</span> `string`
---

View File

@@ -0,0 +1,30 @@
---
# ⚠️ AUTO-GENERATED CONTENT. DO NOT EDIT THIS FILE DIRECTLY! ⚠️
title: StorageUploadFormDataParams
sidebar_label: StorageUploadFormDataParams
description: No description provided.
displayed_sidebar: referenceSidebar
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-storage-js/src/packages/hasura-storage-js/src/utils/types.ts#L21
---
# `StorageUploadFormDataParams`
## Parameters
---
**<span className="parameter-name">formData</span>** <span className="optional-status">required</span> `FormData`
---
**<span className="parameter-name">bucketId</span>** <span className="optional-status">optional</span> `string`
---
**<span className="parameter-name">name</span>** <span className="optional-status">optional</span> `string`
---
**<span className="parameter-name">id</span>** <span className="optional-status">optional</span> `string`
---

View File

@@ -4,27 +4,11 @@ title: StorageUploadParams
sidebar_label: StorageUploadParams
description: No description provided.
displayed_sidebar: referenceSidebar
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-storage-js/src/packages/hasura-storage-js/src/utils/types.ts#L9
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-storage-js/src/packages/hasura-storage-js/src/utils/types.ts#L29
---
# `StorageUploadParams`
## Parameters
---
**<span className="parameter-name">file</span>** <span className="optional-status">required</span> `File`
---
**<span className="parameter-name">bucketId</span>** <span className="optional-status">optional</span> `string`
---
**<span className="parameter-name">name</span>** <span className="optional-status">optional</span> `string`
---
**<span className="parameter-name">id</span>** <span className="optional-status">optional</span> `string`
---
```ts
type StorageUploadParams = StorageUploadFileParams | StorageUploadFormDataParams
```

View File

@@ -4,7 +4,7 @@ title: StorageUploadResponse
sidebar_label: StorageUploadResponse
description: No description provided.
displayed_sidebar: referenceSidebar
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-storage-js/src/packages/hasura-storage-js/src/utils/types.ts#L16
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-storage-js/src/packages/hasura-storage-js/src/utils/types.ts#L31
---
# `StorageUploadResponse`

View File

@@ -4,7 +4,7 @@ title: UploadHeaders
sidebar_label: UploadHeaders
description: No description provided.
displayed_sidebar: referenceSidebar
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-storage-js/src/packages/hasura-storage-js/src/utils/types.ts#L77
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-storage-js/src/packages/hasura-storage-js/src/utils/types.ts#L92
---
# `UploadHeaders`

View File

@@ -67,11 +67,11 @@ Returns the name of the file.
---
**<span className="parameter-name">add</span>** <span className="optional-status">required</span> `(params: StorageUploadParams) => void`
**<span className="parameter-name">add</span>** <span className="optional-status">required</span> `(params: StorageUploadFileParams) => void`
---
**<span className="parameter-name">upload</span>** <span className="optional-status">required</span> `(params: Partial<StorageUploadParams>) => Promise<UploadFileHandlerResult>`
**<span className="parameter-name">upload</span>** <span className="optional-status">required</span> `(params: Partial<StorageUploadFileParams>) => Promise<UploadFileHandlerResult>`
---

View File

@@ -4,7 +4,7 @@ title: NhostSession
sidebar_label: NhostSession
description: No description provided.
displayed_sidebar: referenceSidebar
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/core/src/types.ts#L128
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/core/src/types.ts#L129
---
# `NhostSession`

View File

@@ -67,11 +67,11 @@ Returns the name of the file.
---
**<span className="parameter-name">add</span>** <span className="optional-status">required</span> `(params: StorageUploadParams) => void`
**<span className="parameter-name">add</span>** <span className="optional-status">required</span> `(params: StorageUploadFileParams) => void`
---
**<span className="parameter-name">upload</span>** <span className="optional-status">required</span> `(params: Partial<StorageUploadParams>) => Promise<UploadFileHandlerResult>`
**<span className="parameter-name">upload</span>** <span className="optional-status">required</span> `(params: Partial<StorageUploadFileParams>) => Promise<UploadFileHandlerResult>`
---

View File

@@ -7,7 +7,7 @@ services:
auth:
image: nhost/hasura-auth:0.10.0
storage:
image: nhost/hasura-storage:0.2.3
image: nhost/hasura-storage:0.2.4
auth:
access_control:
email:

View File

@@ -7,7 +7,7 @@ services:
auth:
image: nhost/hasura-auth:0.10.0
storage:
image: nhost/hasura-storage:0.2.3
image: nhost/hasura-storage:0.2.4
auth:
access_control:
email:

View File

@@ -7,7 +7,7 @@ services:
auth:
image: nhost/hasura-auth:0.10.0
storage:
image: nhost/hasura-storage:0.2.3
image: nhost/hasura-storage:0.2.4
auth:
access_control:
email:

View File

@@ -7,7 +7,7 @@ services:
auth:
image: nhost/hasura-auth:0.10.0
storage:
image: nhost/hasura-storage:0.2.3
image: nhost/hasura-storage:0.2.4
auth:
access_control:
email:

View File

@@ -7,7 +7,7 @@ services:
auth:
image: nhost/hasura-auth:0.10.0
storage:
image: nhost/hasura-storage:0.2.3
image: nhost/hasura-storage:0.2.4
auth:
access_control:
email:

View File

@@ -7,7 +7,7 @@ services:
auth:
image: nhost/hasura-auth:0.10.0
storage:
image: nhost/hasura-storage:0.2.3
image: nhost/hasura-storage:0.2.4
auth:
access_control:
email:

View File

@@ -24,7 +24,7 @@
"generate": "graphql-codegen --config graphql.config.yaml",
"cypress": "cypress open",
"test": "cypress run",
"e2e": "start-test e2e:backend :1337/v1/auth/healthz e2e:frontend 3000 test",
"e2e": "start-test e2e:backend http-get://localhost:9695 e2e:frontend 3000 test",
"e2e:backend": "nhost dev --no-browser",
"e2e:frontend": "run-s build preview",
"build": "vite build",

View File

@@ -7,7 +7,7 @@ services:
auth:
image: nhost/hasura-auth:0.10.0
storage:
image: nhost/hasura-storage:0.2.3
image: nhost/hasura-storage:0.2.4
auth:
access_control:
email:

View File

@@ -1,4 +1,4 @@
# Docker image versions used in the cloud
hasura: v2.10.1
auth: 0.10.0
storage: 0.2.3
storage: 0.2.4

View File

@@ -1,5 +1,17 @@
# @nhost/apollo
## 0.5.28
### Patch Changes
- @nhost/nhost-js@1.4.11
## 0.5.27
### Patch Changes
- @nhost/nhost-js@1.4.10
## 0.5.26
### Patch Changes

View File

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

View File

@@ -3,7 +3,7 @@ import { assign, createMachine, send } from 'xstate'
import { AuthClient } from '../client'
import { ErrorPayload, INVALID_EMAIL_ERROR } from '../errors'
import { nhostApiClient } from '../hasura-auth'
import { ChangeEmailOptions } from '../types'
import { ChangeEmailOptions, ChangeEmailResponse } from '../types'
import { rewriteRedirectTo } from '../utils'
import { isValidEmail } from '../validators'
@@ -20,6 +20,10 @@ export type ChangeEmailEvents =
| { type: 'SUCCESS' }
| { type: 'ERROR'; error: ErrorPayload | null }
export type ChangeEmailServices = {
request: { data: ChangeEmailResponse }
}
export type ChangeEmailMachine = ReturnType<typeof createChangeEmailMachine>
export const createChangeEmailMachine = ({ backendUrl, clientUrl, interpreter }: AuthClient) => {
@@ -28,7 +32,8 @@ export const createChangeEmailMachine = ({ backendUrl, clientUrl, interpreter }:
{
schema: {
context: {} as ChangeEmailContext,
events: {} as ChangeEmailEvents
events: {} as ChangeEmailEvents,
services: {} as ChangeEmailServices
},
tsTypes: {} as import('./change-email.typegen').Typegen0,
preserveActionOrder: true,
@@ -70,6 +75,7 @@ export const createChangeEmailMachine = ({ backendUrl, clientUrl, interpreter }:
actions: {
saveInvalidEmailError: assign({ error: (_) => INVALID_EMAIL_ERROR }),
saveRequestError: assign({
// * Untyped action payload. See https://github.com/statelyai/xstate/issues/3037
error: (_, { data: { error } }: any) => error
}),
reportError: send((ctx) => ({ type: 'ERROR', error: ctx.error })),

View File

@@ -3,6 +3,7 @@ import { assign, createMachine, send } from 'xstate'
import { AuthClient } from '../client'
import { ErrorPayload, INVALID_PASSWORD_ERROR } from '../errors'
import { nhostApiClient } from '../hasura-auth'
import { ChangePasswordResponse } from '../types'
import { isValidPassword } from '../validators'
export type ChangePasswordContext = {
@@ -17,6 +18,10 @@ export type ChangePasswordEvents =
| { type: 'SUCCESS' }
| { type: 'ERROR'; error: ErrorPayload | null }
export type ChangePasswordServices = {
requestChange: { data: ChangePasswordResponse }
}
export type ChangePasswordMachine = ReturnType<typeof createChangePasswordMachine>
export const createChangePasswordMachine = ({ backendUrl, interpreter }: AuthClient) => {
@@ -25,7 +30,8 @@ export const createChangePasswordMachine = ({ backendUrl, interpreter }: AuthCli
{
schema: {
context: {} as ChangePasswordContext,
events: {} as ChangePasswordEvents
events: {} as ChangePasswordEvents,
services: {} as ChangePasswordServices
},
tsTypes: {} as import('./change-password.typegen').Typegen0,
preserveActionOrder: true,
@@ -67,6 +73,7 @@ export const createChangePasswordMachine = ({ backendUrl, interpreter }: AuthCli
actions: {
saveInvalidPasswordError: assign({ error: (_) => INVALID_PASSWORD_ERROR }),
saveRequestError: assign({
// * Untyped action payload. See https://github.com/statelyai/xstate/issues/3037
error: (_, { data: { error } }: any) => error
}),
reportError: send((ctx) => ({ type: 'ERROR', error: ctx.error })),
@@ -77,7 +84,7 @@ export const createChangePasswordMachine = ({ backendUrl, interpreter }: AuthCli
},
services: {
requestChange: (_, { password, ticket }) =>
api.post<string, { data: { error?: ErrorPayload } }>(
api.post<string, ChangePasswordResponse>(
'/user/password',
{ newPassword: password, ticket: ticket },
{

View File

@@ -1,4 +1,4 @@
import type { AxiosRequestConfig, AxiosResponse } from 'axios'
import type { AxiosRequestConfig } from 'axios'
import { assign, createMachine, send } from 'xstate'
import {
@@ -18,7 +18,21 @@ import {
} from '../errors'
import { nhostApiClient } from '../hasura-auth'
import { localStorageGetter, localStorageSetter } from '../storage'
import { AuthOptions, Mfa, NhostSession } from '../types'
import {
AuthOptions,
DeanonymizeResponse,
NhostSession,
NhostSessionResponse,
PasswordlessEmailResponse,
PasswordlessSmsOtpResponse,
PasswordlessSmsResponse,
RefreshSessionResponse,
SignInAnonymousResponse,
SignInMfaTotpResponse,
SignInResponse,
SignOutResponse,
SignUpResponse
} from '../types'
import { getParameterByName, removeParameterFromWindow, rewriteRedirectTo } from '../utils'
import { isValidEmail, isValidPassword, isValidPhoneNumber, isValidTicket } from '../validators'
@@ -40,6 +54,18 @@ export interface AuthMachineOptions extends AuthOptions {
export type AuthMachine = ReturnType<typeof createAuthMachine>
type AuthServices = {
signInPassword: { data: SignInResponse }
passwordlessSms: { data: PasswordlessSmsResponse | DeanonymizeResponse }
passwordlessSmsOtp: { data: PasswordlessSmsOtpResponse }
passwordlessEmail: { data: PasswordlessEmailResponse | DeanonymizeResponse }
signInAnonymous: { data: SignInAnonymousResponse }
signInMfaTotp: { data: SignInMfaTotpResponse }
refreshToken: { data: NhostSessionResponse }
signout: { data: SignOutResponse }
signUpEmailPassword: { data: SignUpResponse }
importRefreshToken: { data: NhostSessionResponse }
}
// TODO actions typings
export const createAuthMachine = ({
@@ -56,19 +82,21 @@ export const createAuthMachine = ({
const storageGetter = clientStorageGetter || localStorageGetter(clientStorageType, clientStorage)
const storageSetter = clientStorageSetter || localStorageSetter(clientStorageType, clientStorage)
const api = nhostApiClient(backendUrl)
const postRequest = async <T = any, R = AxiosResponse<T>, D = any>(
const postRequest = async <T = any, D = any>(
url: string,
data?: D,
config?: AxiosRequestConfig<D>
): Promise<R> => {
): Promise<T> => {
const result = await api.post(url, data, config)
return result.data
}
return createMachine(
{
schema: {
context: {} as AuthContext,
events: {} as AuthEvents
events: {} as AuthEvents,
services: {} as AuthServices
},
tsTypes: {} as import('./index.typegen').Typegen0,
context: INITIAL_MACHINE_CONTEXT,
@@ -429,33 +457,37 @@ export const createAuthMachine = ({
// * Save session in the context, and persist the refresh token and the jwt expiration outside of the machine
saveSession: assign({
user: (_, { data }: any) => data?.session?.user,
accessToken: (_, { data }: any) => {
if (data.session.accessTokenExpiresIn) {
const nextRefresh = new Date(
Date.now() + data.session.accessTokenExpiresIn * 1_000
).toISOString()
storageSetter(NHOST_JWT_EXPIRES_AT_KEY, nextRefresh)
} else {
storageSetter(NHOST_JWT_EXPIRES_AT_KEY, null)
user: (_, { data }) => data?.session?.user || null,
accessToken: (_, { data }) => {
if (data.session) {
const { accessTokenExpiresIn, accessToken } = data.session
const nextRefresh = new Date(Date.now() + accessTokenExpiresIn * 1_000)
storageSetter(NHOST_JWT_EXPIRES_AT_KEY, nextRefresh.toISOString())
return {
value: accessToken,
expiresAt: nextRefresh
}
}
storageSetter(NHOST_JWT_EXPIRES_AT_KEY, null)
return {
value: data?.session?.accessToken,
expiresAt: new Date(Date.now() + data?.session?.accessTokenExpiresIn * 1_000)
value: null,
expiresAt: null
}
},
refreshToken: (_, { data }: any) => {
storageSetter(NHOST_REFRESH_TOKEN_KEY, data.session.refreshToken)
return { value: data?.session?.refreshToken }
refreshToken: (_, { data }) => {
const refreshToken = data.session?.refreshToken || null
if (refreshToken) {
storageSetter(NHOST_REFRESH_TOKEN_KEY, refreshToken)
}
return { value: refreshToken }
}
}),
saveMfaTicket: assign({
mfa: (_, e: any) => e.data?.mfa
mfa: (_, e) => e.data?.mfa
}),
resetTimer: assign({
refreshTimer: (ctx, e) => ({
refreshTimer: (_) => ({
startedAt: new Date(),
attempts: 0,
lastAttempt: null
@@ -472,12 +504,17 @@ export const createAuthMachine = ({
// * Authentication errors
saveAuthenticationError: assign({
errors: ({ errors }, { data: { error } }: any) => ({ ...errors, authentication: error })
// * Untyped action payload. See https://github.com/statelyai/xstate/issues/3037
errors: ({ errors }, { data: { error } }: any) => ({
...errors,
authentication: error
})
}),
resetErrors: assign({
errors: (_) => ({})
}),
saveRegistrationError: assign({
// * Untyped action payload. See https://github.com/statelyai/xstate/issues/3037
errors: ({ errors }, { data: { error } }: any) => ({ ...errors, registration: error })
}),
destroyRefreshToken: assign({
@@ -541,14 +578,15 @@ export const createAuthMachine = ({
return remaining <= 0
},
// * Authentication errors
// * Untyped action payload. See https://github.com/statelyai/xstate/issues/3037
unverified: (_, { data: { error } }: any) =>
error.status === 401 &&
// * legacy: don't use the message contents to determine if the email is unverified, but the error type (error.error)
(error.message === 'Email is not verified' || error.error === 'unverified-user'),
// * Event guards
hasSession: (_, e: any) => !!e.data?.session,
hasMfaTicket: (_, e: any) => !!e.data?.mfa
hasSession: (_, e) => !!e.data?.session,
hasMfaTicket: (_, e) => !!e.data?.mfa
},
services: {
@@ -559,7 +597,7 @@ export const createAuthMachine = ({
if (!isValidPassword(password)) {
return Promise.reject({ error: INVALID_PASSWORD_ERROR })
}
return postRequest('/signin/email-password', {
return postRequest<SignInResponse>('/signin/email-password', {
email,
password
})
@@ -632,7 +670,7 @@ export const createAuthMachine = ({
},
signInAnonymous: (_) => postRequest('/signin/anonymous'),
signInMfaTotp: (context, data) => {
const ticket = data.ticket || context.mfa?.ticket
const ticket: string | undefined = data.ticket || context.mfa?.ticket
if (!ticket) {
return Promise.reject({ error: NO_MFA_TICKET_ERROR })
}
@@ -640,20 +678,17 @@ export const createAuthMachine = ({
return Promise.reject({ error: INVALID_MFA_TICKET_ERROR })
}
return postRequest<
{ mfa: Mfa | null; session: NhostSession | null },
{ mfa: Mfa | null; session: NhostSession | null }
>('/signin/mfa/totp', {
return postRequest('/signin/mfa/totp', {
ticket,
otp: data.otp
})
},
refreshToken: async (ctx, event) => {
const refreshToken = event.type === 'TRY_TOKEN' ? event.token : ctx.refreshToken.value
const session = await postRequest('/token', {
const session = await postRequest<RefreshSessionResponse>('/token', {
refreshToken
})
return { session }
return { session, error: null }
},
signout: (ctx, e) =>
postRequest('/signout', {
@@ -662,13 +697,13 @@ export const createAuthMachine = ({
}),
signUpEmailPassword: async (context, { email, password, options }) => {
if (!isValidEmail(email)) {
return Promise.reject({ error: INVALID_EMAIL_ERROR })
return Promise.reject<SignUpResponse>({ error: INVALID_EMAIL_ERROR })
}
if (!isValidPassword(password)) {
return Promise.reject({ error: INVALID_PASSWORD_ERROR })
return Promise.reject<SignUpResponse>({ error: INVALID_PASSWORD_ERROR })
}
if (context.user?.isAnonymous) {
return postRequest(
return postRequest<SignUpResponse>(
'/user/deanonymize',
{
signInMethod: 'email-password',
@@ -683,7 +718,7 @@ export const createAuthMachine = ({
}
)
} else {
return postRequest('/signup/email-password', {
return postRequest<SignUpResponse>('/signup/email-password', {
email,
password,
options: rewriteRedirectTo(clientUrl, options)
@@ -697,17 +732,18 @@ export const createAuthMachine = ({
const urlToken = getParameterByName('refreshToken') || null
if (urlToken) {
try {
const session = await postRequest('/token', {
const session = await postRequest<NhostSession>('/token', {
refreshToken: urlToken
})
return { session }
return { session, error: null }
} catch (exception) {
error = (exception as { error: ValidationErrorPayload }).error
}
} else {
const error = getParameterByName('error')
if (error) {
return Promise.reject<{ error: ValidationErrorPayload }>({
return Promise.reject<NhostSessionResponse>({
session: null,
error: {
status: VALIDATION_ERROR_CODE,
error,
@@ -720,16 +756,15 @@ export const createAuthMachine = ({
const storageToken = await storageGetter(NHOST_REFRESH_TOKEN_KEY)
if (storageToken) {
try {
const session = await postRequest('/token', {
const session = await postRequest<NhostSession>('/token', {
refreshToken: storageToken
})
return { session }
return { session, error: null }
} catch (exception) {
error = (exception as { error: ValidationErrorPayload }).error
}
}
return Promise.reject<{ error: ValidationErrorPayload }>({ error })
return Promise.reject<NhostSessionResponse>({ error })
}
}
}

View File

@@ -3,7 +3,7 @@ import { assign, createMachine, send } from 'xstate'
import { AuthClient } from '../client'
import { ErrorPayload, INVALID_EMAIL_ERROR } from '../errors'
import { nhostApiClient } from '../hasura-auth'
import { ResetPasswordOptions } from '../types'
import { ResetPasswordOptions, ResetPasswordResponse } from '../types'
import { rewriteRedirectTo } from '../utils'
import { isValidEmail } from '../validators'
@@ -19,6 +19,10 @@ export type ResetPasswordEvents =
| { type: 'SUCCESS' }
| { type: 'ERROR'; error: ErrorPayload | null }
export type ResetPasswordServices = {
requestChange: { data: ResetPasswordResponse }
}
export type ResetPasswordMachine = ReturnType<typeof createResetPasswordMachine>
export const createResetPasswordMachine = ({ backendUrl, clientUrl }: AuthClient) => {
@@ -27,7 +31,8 @@ export const createResetPasswordMachine = ({ backendUrl, clientUrl }: AuthClient
{
schema: {
context: {} as ResetPasswordContext,
events: {} as ResetPasswordEvents
events: {} as ResetPasswordEvents,
services: {} as ResetPasswordServices
},
tsTypes: {} as import('./reset-password.typegen').Typegen0,
preserveActionOrder: true,
@@ -69,6 +74,7 @@ export const createResetPasswordMachine = ({ backendUrl, clientUrl }: AuthClient
actions: {
saveInvalidEmailError: assign({ error: (_) => INVALID_EMAIL_ERROR }),
saveRequestError: assign({
// * Untyped action payload. See https://github.com/statelyai/xstate/issues/3037
error: (_, { data: { error } }: any) => error
}),
reportError: send((ctx) => ({ type: 'ERROR', error: ctx.error })),
@@ -79,7 +85,7 @@ export const createResetPasswordMachine = ({ backendUrl, clientUrl }: AuthClient
},
services: {
requestChange: (_, { email, options }) =>
api.post<string, { data: { error?: ErrorPayload } }>('/user/password/reset', {
api.post<string, ResetPasswordResponse>('/user/password/reset', {
email,
options: rewriteRedirectTo(clientUrl, options)
})

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