Compare commits

..

64 Commits

Author SHA1 Message Date
Pilou
3bd1aa4d53 Merge pull request #357 from nhost/changeset-release/main
chore: update versions
2022-04-10 08:51:47 +01:00
github-actions[bot]
f3cca4997b chore: update versions 2022-04-10 07:44:55 +00:00
Pilou
0fd7a487d6 Merge pull request #382 from nhost/fix/sync-auth-state
Keep authentication status and access token in sync
2022-04-10 08:44:15 +01:00
Pierre-Louis Mercereau
1bb032c1e7 chore: remove console.log and add explaination 2022-04-09 20:48:00 +01:00
Pierre-Louis Mercereau
2c97db68b5 fix: sync auth state with all the nhost sub-clients 2022-04-09 20:44:38 +01:00
Johan Eliasson
714f2872ee Merge pull request #380 from nhost/contributors-readme-action-nMk7JwQ8hY
contributors readme action update
2022-04-09 16:19:05 +02:00
github-actions[bot]
65fc26a0e8 contrib-readme-action has updated readme 2022-04-09 14:11:13 +00:00
Johan Eliasson
86a56f28c1 Merge pull request #379 from Savinvadim1312/patch-1
Fix a type in react documentation
2022-04-09 16:10:55 +02:00
Savin Vadim
6e8abe28d6 Fix a type in react documentation
Fix a typo in the `nhsot/react` documentation in the code example. 

The imported hook had a wrong name
2022-04-09 13:41:56 +01:00
Szilárd Dóró
39925ff5ca Merge pull request #376 from nhost/fix/documentation-react-router
React Router example upgraded to v6
2022-04-08 16:03:09 +02:00
Szilárd Dóró
583a77ed0d build fix and sitemap updates 2022-04-08 15:12:34 +02:00
Szilárd Dóró
e704831500 upgraded AuthGate example documentation to use react-router v6 2022-04-08 15:03:31 +02:00
Johan Eliasson
95948dd5b9 Merge pull request #372 from nhost/contributors-readme-action-9bzNZt6pM9
contributors readme action update
2022-04-08 07:24:40 +02:00
github-actions[bot]
247b69c952 contrib-readme-action has updated readme 2022-04-08 05:24:23 +00:00
Johan Eliasson
7d15b76402 Merge pull request #359 from nhost/contributors-readme-action-txEVhnQt0i
contributors readme action update
2022-04-08 07:24:11 +02:00
github-actions[bot]
b1ae65fd72 contrib-readme-action has updated readme 2022-04-07 18:55:02 +00:00
Pilou
0063fd1840 Merge pull request #358 from Savinvadim1312/patch-1
Fix a typo in the React docs
2022-04-07 19:54:48 +01:00
Savin Vadim
743a7e6507 Fix a typo in the React docs
Changed from `clientStorageGetter` to `clientStorageSetter` on the line referencing the setter function
2022-04-07 19:43:30 +01:00
Pilou
078652861f Merge pull request #345 from nhost/fix/dont-remove-ts-comments
fix: don't remove comments so they are present in the built .d.ts
2022-04-07 19:27:39 +01:00
Pilou
39840cfd95 Merge pull request #347 from nhost/docs/update-examples
Update examples to bump versions & hooks syntax, and fix dead link in react-apollo readme
2022-04-07 19:26:49 +01:00
Johan Eliasson
940a36a68f Merge pull request #352 from nhost/contributors-readme-action-YMeH8uC8qa
contributors readme action update
2022-04-07 13:23:41 +02:00
github-actions[bot]
77b109b3df contrib-readme-action has updated readme 2022-04-07 11:22:27 +00:00
Johan Eliasson
15907d65e6 Merge pull request #351 from nhost/contr-test-1
readme update
2022-04-07 13:22:12 +02:00
Johan Eliasson
7d7d16fa71 readme update 2022-04-07 13:21:56 +02:00
Johan Eliasson
3f39e48cbd Merge pull request #349 from nhost/contributors
contr init
2022-04-07 13:18:57 +02:00
Johan Eliasson
97ade32869 contr init 2022-04-07 13:18:22 +02:00
Pierre-Louis Mercereau
8583af8290 chore: changeset 2022-04-07 09:34:46 +02:00
Pierre-Louis Mercereau
a28193a6ba docs: correct link to documentation 2022-04-07 09:30:15 +02:00
Pierre-Louis Mercereau
9d6c64430a chore: remove rsuite toaster workaround 2022-04-06 15:44:57 +02:00
Pierre-Louis Mercereau
519d1bf5cb chore: prettier and lint fix 2022-04-06 15:39:29 +02:00
Pierre-Louis Mercereau
5ffb0320b5 docs: update examples to bump versions and to match the recommended hooks syntax 2022-04-06 15:31:58 +02:00
Pierre-Louis Mercereau
6607e73cc2 fix: don't remove comments so they are present in the built .d.ts 2022-04-06 15:07:37 +02:00
Pilou
b4bac161a5 Merge pull request #344 from timpratim/patch-2
Separated the commands for installation
2022-04-06 12:56:28 +02:00
Pratim
37d15377c8 Separated the commands for installation
Separated the commands for installation according to the package managers.
2022-04-06 15:33:45 +05:30
Pilou
8ee1df3be4 Merge pull request #343 from nhost/changeset-release/main
chore: update versions
2022-04-06 10:50:29 +02:00
Pilou
47ffca945e Update package.json 2022-04-06 10:46:11 +02:00
Pilou
d60f5e623c Update CHANGELOG.md 2022-04-06 10:45:41 +02:00
Pilou
6f80643ee0 Update package.json 2022-04-06 10:45:10 +02:00
Pilou
8d5084725d Update CHANGELOG.md 2022-04-06 10:44:56 +02:00
Pilou
693498dd09 Update CHANGELOG.md 2022-04-06 10:37:39 +02:00
Pilou
4d36a966ea Update CHANGELOG.md 2022-04-06 10:37:02 +02:00
Pilou
239a075f1d Update CHANGELOG.md 2022-04-06 10:36:37 +02:00
github-actions[bot]
931194812e chore: update versions 2022-04-06 08:33:17 +00:00
Pilou
c8f80c58f3 Merge pull request #335 from nhost/refactor/correct-react-hook-signature
React hook signature & add promises to hook action results
2022-04-06 10:32:33 +02:00
Pilou
7fdb5aee0a Merge pull request #334 from nhost/docs/bump-version-examples
docs: bump dependencies of react-apollo and nextjs examples
2022-04-05 20:52:12 +02:00
Pilou
1710808fef Merge pull request #321 from nhost/docs/correct-hljs
docs: pass language to react-syntax-highlighter
2022-04-05 20:52:00 +02:00
Pilou
696815d4a8 Merge pull request #311 from nhost/306-the-useuserdata-hook-does-not-return-the-emailverified-or-phonenumberverified-user-properties
Add `emailVerified`, `phoneNumber`, `phoneNumberVerified`, and `activeMfaType` to User type, and add missing providers types
2022-04-05 20:51:42 +02:00
Pilou
5cc9be00b6 Merge pull request #341 from nhost/changeset-release/main
chore: update versions
2022-04-05 16:14:26 +02:00
github-actions[bot]
28dae23a91 chore: update versions 2022-04-05 14:02:46 +00:00
Pilou
7819e20cf4 Merge pull request #340 from nhost/elitan-patch-1
Correct OAuth provider link
2022-04-05 16:01:42 +02:00
Johan Eliasson
6be3758668 Create ninety-eels-lick.md 2022-04-05 15:56:18 +02:00
Johan Eliasson
658c67faf4 Update hasura-auth-client.ts 2022-04-05 15:54:39 +02:00
Pierre-Louis Mercereau
e7f3a5f6e0 chore: ellaborate changesets 2022-04-05 10:50:55 +02:00
Pierre-Louis Mercereau
7135aee78b chore: add changeset 2022-04-05 10:42:44 +02:00
Pierre-Louis Mercereau
587eaff734 feat: add promise with the current context to hooks actions 2022-04-04 20:45:12 +02:00
Pierre-Louis Mercereau
7cf875f4b8 refactor: deprecate the use of values end as hook parameters 2022-04-04 16:56:46 +02:00
Pierre-Louis Mercereau
657cfb91c5 docs: update corresponding swagger api 2022-04-04 10:42:09 +02:00
Pierre-Louis Mercereau
103dd6e98e Merge branch 'main' into 306-the-useuserdata-hook-does-not-return-the-emailverified-or-phonenumberverified-user-properties 2022-04-04 10:40:05 +02:00
Pierre-Louis Mercereau
3c8caa680b docs: bump dependencies of react-apollo and nextjs examples
and remove workaround related to https://github.com/rsuite/rsuite/issues/2336
2022-04-03 23:45:06 +02:00
Pilou
1bcee357fe Merge pull request #325 from nhost/docs/auth-refresh-expiration
docs: change default refresh token expiration to 30 days
2022-04-03 22:32:21 +02:00
Pierre-Louis Mercereau
b729aa9290 ci: fix pnpm/npm/changeset 2022-04-03 22:26:58 +02:00
Pierre-Louis Mercereau
9b840f7c4a docs: change default refresh token expiration to 30 days 2022-04-01 21:15:40 +02:00
Pierre-Louis Mercereau
83d3c90f43 docs: pass language to react-syntax-highlighter 2022-03-31 21:57:40 +02:00
Pierre-Louis Mercereau
058956bdcb feat: update types 2022-03-31 12:27:47 +02:00
69 changed files with 1567 additions and 691 deletions

View File

@@ -30,6 +30,9 @@ jobs:
with:
node-version: '17.8.0'
cache: 'pnpm'
- name: Pick the right npm version
# * See: https://github.com/pnpm/pnpm/issues/4348
run: npm install --global npm@8.4
- name: Install dependencies
run: pnpm install
- name: Create PR or Publish release
@@ -39,7 +42,7 @@ jobs:
version: pnpm run ci:version
commit: 'chore: update versions'
title: 'chore: update versions'
publish: pnpm run ci:publish
publish: pnpm run release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

15
.github/workflows/contributors.yaml vendored Normal file
View File

@@ -0,0 +1,15 @@
name: Add contributors
on:
push:
branches:
- main
jobs:
contrib-readme-job:
runs-on: ubuntu-latest
name: A job to automate contrib in readme
steps:
- name: Contribute List
uses: akhilmhdh/contributors-readme-action@v2.3.4
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

181
README.md
View File

@@ -110,7 +110,7 @@ First and foremost: **Star and watch this repository** to stay up-to-date.
Also, follow Nhost on [GitHub Discussions](https://github.com/nhost/nhost/discussions), our [Blog](https://nhost.io/blog), and on [Twitter](https://twitter.com/nhostio). You can chat with the team and other members on [Discord](https://discord.com/invite/9V7Qb2U) and follow our tutorials and other video material at [YouTube](https://www.youtube.com/channel/UCJ7irtvV9Y0EQMxpabb6ntg?view_as=subscriber).
## Nhost is Open Source
### Nhost is Open Source
This repository, and most of our other open source projects, are licensed under the MIT license.
@@ -122,6 +122,181 @@ Here are some ways of contributing to making Nhost better:
- Join our [Discord](https://discord.com/invite/9V7Qb2U) and connect with other members to share and learn from.
- Send a pull request to any of our [open source repositories](https://github.com/nhost) on Github. Check our [contribution guide](https://github.com/nhost/nhost/blob/main/CONTRIBUTING.md) for more details about how to contribute. We're looking forward to your contribution!
## Security
### Contributors
If you discover a security vulnerability within Nhost, please e-mail [security@nhost.io](mailto:security@nhost.io). All security vulnerabilities will be promptly addressed.
<!-- readme: contributors -start -->
<table>
<tr>
<td align="center">
<a href="https://github.com/plmercereau">
<img src="https://avatars.githubusercontent.com/u/24897252?v=4" width="100;" alt="plmercereau"/>
<br />
<sub><b>Pilou</b></sub>
</a>
</td>
<td align="center">
<a href="https://github.com/elitan">
<img src="https://avatars.githubusercontent.com/u/331818?v=4" width="100;" alt="elitan"/>
<br />
<sub><b>Johan Eliasson</b></sub>
</a>
</td>
<td align="center">
<a href="https://github.com/szilarddoro">
<img src="https://avatars.githubusercontent.com/u/310881?v=4" width="100;" alt="szilarddoro"/>
<br />
<sub><b>Szilárd Dóró</b></sub>
</a>
</td>
<td align="center">
<a href="https://github.com/nunopato">
<img src="https://avatars.githubusercontent.com/u/1523504?v=4" width="100;" alt="nunopato"/>
<br />
<sub><b>Nuno Pato</b></sub>
</a>
</td>
<td align="center">
<a href="https://github.com/subatuba21">
<img src="https://avatars.githubusercontent.com/u/34824571?v=4" width="100;" alt="subatuba21"/>
<br />
<sub><b>Subha Das</b></sub>
</a>
</td>
<td align="center">
<a href="https://github.com/guicurcio">
<img src="https://avatars.githubusercontent.com/u/20285232?v=4" width="100;" alt="guicurcio"/>
<br />
<sub><b>Guido Curcio</b></sub>
</a>
</td></tr>
<tr>
<td align="center">
<a href="https://github.com/sebagudelo">
<img src="https://avatars.githubusercontent.com/u/43288271?v=4" width="100;" alt="sebagudelo"/>
<br />
<sub><b>Sebagudelo</b></sub>
</a>
</td>
<td align="center">
<a href="https://github.com/mrinalwahal">
<img src="https://avatars.githubusercontent.com/u/9859731?v=4" width="100;" alt="mrinalwahal"/>
<br />
<sub><b>Mrinal Wahal</b></sub>
</a>
</td>
<td align="center">
<a href="https://github.com/FuzzyReason">
<img src="https://avatars.githubusercontent.com/u/62517920?v=4" width="100;" alt="FuzzyReason"/>
<br />
<sub><b>Vadim Smirnov</b></sub>
</a>
</td>
<td align="center">
<a href="https://github.com/subhendukundu">
<img src="https://avatars.githubusercontent.com/u/20059141?v=4" width="100;" alt="subhendukundu"/>
<br />
<sub><b>Subhendu Kundu</b></sub>
</a>
</td>
<td align="center">
<a href="https://github.com/chrtze">
<img src="https://avatars.githubusercontent.com/u/3797215?v=4" width="100;" alt="chrtze"/>
<br />
<sub><b>Christopher Möller</b></sub>
</a>
</td>
<td align="center">
<a href="https://github.com/jerryjappinen">
<img src="https://avatars.githubusercontent.com/u/1101002?v=4" width="100;" alt="jerryjappinen"/>
<br />
<sub><b>Jerry Jäppinen</b></sub>
</a>
</td></tr>
<tr>
<td align="center">
<a href="https://github.com/mustafa-hanif">
<img src="https://avatars.githubusercontent.com/u/30019262?v=4" width="100;" alt="mustafa-hanif"/>
<br />
<sub><b>Mustafa Hanif</b></sub>
</a>
</td>
<td align="center">
<a href="https://github.com/Savinvadim1312">
<img src="https://avatars.githubusercontent.com/u/16936043?v=4" width="100;" alt="Savinvadim1312"/>
<br />
<sub><b>Savin Vadim</b></sub>
</a>
</td>
<td align="center">
<a href="https://github.com/ahmic">
<img src="https://avatars.githubusercontent.com/u/13452362?v=4" width="100;" alt="ahmic"/>
<br />
<sub><b>Amir Ahmic</b></sub>
</a>
</td>
<td align="center">
<a href="https://github.com/akd-io">
<img src="https://avatars.githubusercontent.com/u/30059155?v=4" width="100;" alt="akd-io"/>
<br />
<sub><b>Anders Kjær Damgaard</b></sub>
</a>
</td>
<td align="center">
<a href="https://github.com/rustyb">
<img src="https://avatars.githubusercontent.com/u/53086?v=4" width="100;" alt="rustyb"/>
<br />
<sub><b>Colin Broderick</b></sub>
</a>
</td>
<td align="center">
<a href="https://github.com/dohomi">
<img src="https://avatars.githubusercontent.com/u/489221?v=4" width="100;" alt="dohomi"/>
<br />
<sub><b>Dominic Garms</b></sub>
</a>
</td></tr>
<tr>
<td align="center">
<a href="https://github.com/alveshelio">
<img src="https://avatars.githubusercontent.com/u/8176422?v=4" width="100;" alt="alveshelio"/>
<br />
<sub><b>Helio Alves</b></sub>
</a>
</td>
<td align="center">
<a href="https://github.com/nkhdo">
<img src="https://avatars.githubusercontent.com/u/26102306?v=4" width="100;" alt="nkhdo"/>
<br />
<sub><b>Hoang Do</b></sub>
</a>
</td>
<td align="center">
<a href="https://github.com/ghoshnirmalya">
<img src="https://avatars.githubusercontent.com/u/6391763?v=4" width="100;" alt="ghoshnirmalya"/>
<br />
<sub><b>Nirmalya Ghosh</b></sub>
</a>
</td>
<td align="center">
<a href="https://github.com/timpratim">
<img src="https://avatars.githubusercontent.com/u/32492961?v=4" width="100;" alt="timpratim"/>
<br />
<sub><b>Pratim</b></sub>
</a>
</td>
<td align="center">
<a href="https://github.com/quentin-decre">
<img src="https://avatars.githubusercontent.com/u/1137511?v=4" width="100;" alt="quentin-decre"/>
<br />
<sub><b>Quentin Decré</b></sub>
</a>
</td>
<td align="center">
<a href="https://github.com/komninoschat">
<img src="https://avatars.githubusercontent.com/u/29049104?v=4" width="100;" alt="komninoschat"/>
<br />
<sub><b>Komninos</b></sub>
</a>
</td></tr>
</table>
<!-- readme: contributors -end -->

View File

@@ -2,15 +2,15 @@ import { lightNhostTheme } from '@/data/lightTheme'
import { useState } from 'react'
import { Light as SyntaxHighlighter } from 'react-syntax-highlighter'
import js from 'react-syntax-highlighter/dist/cjs/languages/hljs/javascript'
import ts from 'react-syntax-highlighter/dist/cjs/languages/hljs/typescript'
import Check from '../icons/Check'
import Copy from '../icons/Copy'
// @ts-ignore -> add to types
// @ts-ignore -> add to types
SyntaxHighlighter.registerLanguage('js', js)
SyntaxHighlighter.registerLanguage('language-js', js)
SyntaxHighlighter.registerLanguage('language-ts', ts)
// TODO highlight JSX
SyntaxHighlighter.registerLanguage('jsx', js)
SyntaxHighlighter.registerLanguage('language-jsx', js)
export interface CodeEditorProps {
code: string
@@ -24,7 +24,7 @@ export interface CodeEditorProps {
}
const CodeEditor = (props: CodeEditorProps) => {
const { children, url } = props
const { children, className } = props
const [copied, setCopied] = useState(false)
return (
@@ -53,6 +53,7 @@ const CodeEditor = (props: CodeEditorProps) => {
</button>
</div>
<SyntaxHighlighter
language={className}
style={lightNhostTheme}
wrapLongLines={true}
wrapLines={true}

View File

@@ -18,9 +18,14 @@ In this guide, we'll keep the example simple. We're not using a frontend framewo
Create a new folder called `nhost-todos`, and initialize a new JavaScript app there:
Using npm package manager
```sh
npm init -y
# or
```
or
Using Yarn package manager
```sh
yarn init -y
```
@@ -28,9 +33,13 @@ yarn init -y
Install Nhost JavaScript SDK:
Using npm package manager
```sh
npm install @nhost/nhost-js
# or
```
or
Using Yarn package manager
```sh
yarn add @nhost/nhost-js
```

View File

@@ -45,10 +45,10 @@ title: Environment Variables
| AUTH_SMS_TWILIO_FROM | | |
| AUTH_EMAIL_SIGNIN_EMAIL_VERIFIED_REQUIRED | When enabled, any email-based authentication requires emails to be verified by a link sent to this email. | `true` |
| AUTH_ACCESS_CONTROL_ALLOWED_REDIRECT_URLS | | |
| AUTH_MFA_ENABLED | Enables users to use Multi Factor Authentication | `false` |
| AUTH_MFA_ENABLED | Enables users to use Multi Factor Authentication. | `false` |
| AUTH_MFA_TOTP_ISSUER | The name of the One Time Password (OTP) issuer. Probably your app's name. | `hasura-auth` |
| AUTH_ACCESS_TOKEN_EXPIRES_IN | | `900`(15 minutes) |
| AUTH_REFRESH_TOKEN_EXPIRES_IN | | `43200` (12 hours) |
| AUTH_ACCESS_TOKEN_EXPIRES_IN | Number of seconds before the access token (JWT) expires. | `900`(15 minutes) |
| AUTH_REFRESH_TOKEN_EXPIRES_IN | Number of seconds before the refresh token expires. | `2592000` (30 days) |
| AUTH_EMAIL_TEMPLATE_FETCH_URL | | |
| AUTH_JWT_CUSTOM_CLAIMS | | |

View File

@@ -8,23 +8,25 @@ title: 'Hooks'
```js
const { signUpEmailPassword, isLoading, isSuccess, needsEmailVerification, isError, error } =
useSignUpEmailPassword(email?: string, password?: string, options?: Options )
useSignUpEmailPassword(options?: Options)
```
| Name | Type | Notes |
| ------------------------ | ------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `signUpEmailPassword` | (email?: string, password?: string) => void | Used for a new user to sign up. The email/password arguments will take precedence over the possible state values used when creating the hook. |
| `isLoading` | boolean | Returns `true` when the action is executing, `false` when it finished its execution. |
| `needsEmailVerification` | boolean | Returns `true` if the sign-up has been accepted, but a verificaiton email has been sent and is awaiting. |
| `isSuccess` | boolean | Returns `true` if the sign-up suceeded. Returns `false` if the new email needs to be verified first, or if an error occurred. |
| `isError` | boolean | Returns `true` if an error occurred. |
| `error` | {status: number, error: string, message: string} \| undefined | Provides details about the error. |
| `options.locale` | string \| undefined | Locale of the user, in two digits, for instance `en`. |
| `options.allowedRoles` | string[] \| undefined | Allowed roles of the user. Must be a subset of the default allowed roles defined in Hasura Auth. |
| `options.defaultRole` | string \| undefined | Default role of the user. Must be part of the default allowed roles defined in Hasura Auth. |
| `options.displayName` | string \| undefined | |
| `options.metadata` | Record<string, unknown> \| undefined | Custom additional user information stored in the `metadata` column. Can be any JSON object. |
| `options.redirectTo` | string \| undefined | redirection path in the client application that will be used in the link in the verification email. For instance, if you want to redirect to `https://myapp.com/success`, the `redirectTo` value is `'/success'`. |
| Name | Type | Notes |
| ------------------------ | -------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `signUpEmailPassword` | (email?: string, password?: string) => void | Used for a new user to sign up. Returns a promise with the current context |
| `isLoading` | boolean | Returns `true` when the action is executing, `false` when it finished its execution. |
| `needsEmailVerification` | boolean | Returns `true` if the sign-up has been accepted, but a verificaiton email has been sent and is awaiting. |
| `isSuccess` | boolean | Returns `true` if the sign-up suceeded. Returns `false` if the new email needs to be verified first, or if an error occurred. |
| `isError` | boolean | Returns `true` if an error occurred. |
| `error` | {status: number, error: string, message: string} \| null | Provides details about the error. |
| `user` | User \| null | User information |
| `accessToken` | string \| null | Access token (JWT) |
| `options.locale` | string \| undefined | Locale of the user, in two digits, for instance `en`. |
| `options.allowedRoles` | string[] \| undefined | Allowed roles of the user. Must be a subset of the default allowed roles defined in Hasura Auth. |
| `options.defaultRole` | string \| undefined | Default role of the user. Must be part of the default allowed roles defined in Hasura Auth. |
| `options.displayName` | string \| undefined | |
| `options.metadata` | Record<string, unknown> \| undefined | Custom additional user information stored in the `metadata` column. Can be any JSON object. |
| `options.redirectTo` | string \| undefined | redirection path in the client application that will be used in the link in the verification email. For instance, if you want to redirect to `https://myapp.com/success`, the `redirectTo` value is `'/success'`. |
#### Usage
@@ -36,7 +38,7 @@ const Component = () => {
const [email, setEmail] = useState('')
const [password, setPassword] = useState('')
const { signUpEmailPassword, isLoading, isSuccess, needsEmailVerification, isError, error } =
useSignUpEmailPassword(email, password)
useSignUpEmailPassword()
return (
<div>
<input value={email} onChange={(event) => setEmail(event.target.value)} placeholder="Email" />
@@ -45,7 +47,7 @@ const Component = () => {
onChange={(event) => setPassword(event.target.value)}
placeholder="Password"
/>
<button onClick={signUpEmailPassword}>Register</button>
<button onClick={() => signUpEmailPassword(email, password)}>Register</button>
{isSuccess && <div>Your account have beed created! You are now authenticated</div>}
{needsEmailVerification && (
<div>Please check your mailbox and follow the verification link to verify your email</div>
@@ -58,20 +60,31 @@ const Component = () => {
### Email and Password Sign-In
```js
const { signInEmailPassword, isLoading, needsEmailVerification, needsMfaOtp, sendMfaOtp, isSuccess, isError, error } =
useSignInEmailPassword(email?: string, password?: string)
const {
signInEmailPassword,
isLoading,
needsEmailVerification,
needsMfaOtp,
sendMfaOtp,
isSuccess,
isError,
error,
user
} = useSignInEmailPassword()
```
| Name | Type | Notes |
| ------------------------ | ------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------- |
| `signInEmailPassword` | (email?: string, password?: string) => void | Will try to authenticate. The email/password arguments will take precedence over the possible state values used when creating the hook. |
| `isLoading` | boolean | Returns `true` when the action is executing, `false` when it finished its execution. |
| `needsEmailVerification` | boolean | Returns `true` if the user email is still pending email verification. |
| `needsMfaOtp` | boolean | Returns `true` if the server is awaiting an MFA one-time password to complete the authentication. |
| `sendMfaOtp` | (otp: string) => void | Sends MFA One-time password. Will turn either `isSuccess` or `isError` to true, and store potential error in `error`. |
| `isSuccess` | boolean | Returns `true` if the user has successfully authenticated. Returns `false` in case or error or if the new email needs to be verified first. |
| `isError` | boolean | Returns `true` if an error occurred. |
| `error` | {status: number, error: string, message: string} \| undefined | Provides details about the error. |
| Name | Type | Notes |
| ------------------------ | -------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------- |
| `signInEmailPassword` | (email?: string, password?: string) | Will try to authenticate. Returns a promise with the current context |
| `isLoading` | boolean | Returns `true` when the action is executing, `false` when it finished its execution. |
| `needsEmailVerification` | boolean | Returns `true` if the user email is still pending email verification. |
| `needsMfaOtp` | boolean | Returns `true` if the server is awaiting an MFA one-time password to complete the authentication. |
| `sendMfaOtp` | (otp: string) => void | Sends MFA One-time password. Will turn either `isSuccess` or `isError` to true, and store potential error in `error`. |
| `isSuccess` | boolean | Returns `true` if the user has successfully authenticated. Returns `false` in case or error or if the new email needs to be verified first. |
| `isError` | boolean | Returns `true` if an error occurred. |
| `error` | {status: number, error: string, message: string} \| null | Provides details about the error. |
| `user` | User \| null | User information |
| `accessToken` | string \| null | Access token (JWT) |
#### Usage
@@ -83,7 +96,7 @@ const Component = () => {
const [email, setEmail] = useState('')
const [password, setPassword] = useState('')
const { signInEmailPassword, isLoading, isSuccess, needsEmailVerification, isError, error } =
useSignInEmailPassword(email, password)
useSignInEmailPassword()
return (
<div>
<input value={email} onChange={(event) => setEmail(event.target.value)} placeholder="Email" />
@@ -92,7 +105,7 @@ const Component = () => {
onChange={(event) => setPassword(event.target.value)}
placeholder="Password"
/>
<button onClick={signInEmailPassword}>Register</button>
<button onClick={() => signInEmailPassword(email, password)}>Register</button>
{isSuccess && <div>Authentication suceeded</div>}
{needsEmailVerification && (
<div>
@@ -139,12 +152,12 @@ const Component = () => {
```js
const { signInEmailPasswordless, isLoading, isSuccess, isError, error } =
useSignInEmailPasswordless(email?: string, options?: Options)
useSignInEmailPasswordless(options?: Options)
```
| Name | Type | Notes |
| ------------------------- | ------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `signInEmailPasswordless` | (email?: string) => void | Sends a magic link to the given email The email argument will take precedence over the the possible state value used when creating the hook. |
| `signInEmailPasswordless` | (email?: string) => void | Sends a magic link to the given email. |
| `isLoading` | boolean | Returns `true` when the action is executing, `false` when it finished its execution. |
| `isSuccess` | boolean | Returns `true` if the magic link email user has successfully send. |
| `isError` | boolean | Returns `true` if an error occurred. |
@@ -165,11 +178,11 @@ import { useSignInEmailPasswordless } from '@nhost/react'
const Component = () => {
const [email, setEmail] = useState('')
const { signInEmailPasswordless, isLoading, isSuccess, isError, error } =
useSignInEmailPasswordless(email)
useSignInEmailPasswordless()
return (
<div>
<input value={email} onChange={(event) => setEmail(event.target.value)} placeholder="Email" />
<button onClick={signInEmailPasswordless}>Authenticate</button>
<button onClick={() => signInEmailPasswordless(email)}>Authenticate</button>
{isSuccess && (
<div>
An email has been sent to {email}. Please check your mailbox and click on the
@@ -253,17 +266,17 @@ const accessToken = useAccessToken()
```js
const { changeEmail, isLoading, isSuccess, needsEmailVerification, isError, error } =
useChangeEmail(email?: string, options?: { redirectTo?: string })
useChangeEmail(options?: { redirectTo?: string })
```
| Name | Type | Notes |
| ------------------------ | ------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `changeEmail` | (email?: string) => void | Requests the email change. The arguement password will take precedence over the the possible state value used when creating the hook. |
| `isLoading` | boolean | Returns `true` when the action is executing, `false` when it finished its execution. |
| `needsEmailVerification` | boolean | Returns `true` if the email change has been requested, but that a email has been sent to the user to verify the new email. |
| `isError` | boolean | Returns `true` if an error occurred. |
| `error` | {status: number, error: string, message: string} \| undefined | Provides details about the error. |
| `redirectTo` | string \| undefined | Redirection path in the client application that will be used in the link in the verification email. For instance, if you want to redirect to `https://myapp.com/success`, the `redirectTo` value is `'/success'`. |
| Name | Type | Notes |
| ------------------------ | -------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `changeEmail` | (email?: string) => void | Requests the email change. Returns a promise with the current context |
| `isLoading` | boolean | Returns `true` when the action is executing, `false` when it finished its execution. |
| `needsEmailVerification` | boolean | Returns `true` if the email change has been requested, but that a email has been sent to the user to verify the new email. |
| `isError` | boolean | Returns `true` if an error occurred. |
| `error` | {status: number, error: string, message: string} \| null | Provides details about the error. |
| `redirectTo` | string \| undefined | Redirection path in the client application that will be used in the link in the verification email. For instance, if you want to redirect to `https://myapp.com/success`, the `redirectTo` value is `'/success'`. |
#### Usage
@@ -273,12 +286,11 @@ import { useChangeEmail } from '@nhost/react'
const Component = () => {
const [email, setEmail] = useState('')
const { changeEmail, isLoading, needsEmailVerification, isError, error } =
useChangeEmail(password)
const { changeEmail, isLoading, needsEmailVerification, isError, error } = useChangeEmail()
return (
<div>
<input value={email} onChange={(event) => setEmail(event.target.value)} />
<button onClick={changeEmail}>Change password</button>
<button onClick={() => changeEmail(email)}>Change email</button>
{needsEmailVerification && (
<div>
Please check your mailbox and follow the verification link to confirm your new email
@@ -292,16 +304,16 @@ const Component = () => {
### Change password
```js
const { changePassword, isLoading, isSuccess, isError, error } = useChangePassword(password?: string)
const { changePassword, isLoading, isSuccess, isError, error } = useChangePassword()
```
| Name | Type | Notes |
| ---------------- | ------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------- |
| `changePassword` | (password?: string) => void | Requests the password change. The arguement password will take precedence over the the possible state value used when creating the hook. |
| `isLoading` | boolean | Returns `true` when the action is executing, `false` when it finished its execution. |
| `isSuccess` | boolean | Returns `true` if the password has beed successfully changed. |
| `isError` | boolean | Returns `true` if an error occurred. |
| `error` | {status: number, error: string, message: string} \| undefined | Provides details about the error. |
| Name | Type | Notes |
| ---------------- | -------------------------------------------------------- | ------------------------------------------------------------------------------------ |
| `changePassword` | (password?: string) | Requests the password change. Returns a promise with the current context |
| `isLoading` | boolean | Returns `true` when the action is executing, `false` when it finished its execution. |
| `isSuccess` | boolean | Returns `true` if the password has beed successfully changed. |
| `isError` | boolean | Returns `true` if an error occurred. |
| `error` | {status: number, error: string, message: string} \| null | Provides details about the error. |
#### Usage
@@ -311,11 +323,11 @@ import { useChangePassword } from '@nhost/react'
const Component = () => {
const [password, setPassword] = useState('')
const { changePassword, isLoading, isSuccess, isError, error } = useChangePassword(password)
const { changePassword, isLoading, isSuccess, isError, error } = useChangePassword()
return (
<div>
<input value={password} onChange={(event) => setPassword(event.target.value)} />
<button onClick={changePassword}>Change password</button>
<button onClick={() => changePassword(password)}>Change password</button>
</div>
)
}
@@ -326,17 +338,17 @@ const Component = () => {
If a user loses their password, we can resend them an email to authenticate so that they can change it to a new one:
```js
const { resetPassword, isLoading, isSent, isError, error } = useResetPassword(email?: string, options?: { redirectTo?: string })
const { resetPassword, isLoading, isSent, isError, error } = useResetPassword(options?: { redirectTo?: string })
```
| Name | Type | Notes |
| --------------- | ------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `resetPassword` | (email?: string) => void | Sends an email with a temporary connection link. The arguement email will take precedence over the the possible state value used when creating the hook. |
| `isLoading` | boolean | Returns `true` when the action is executing, `false` when it finished its execution. |
| `isSent` | boolean | Returns `true` when the email has been successfully sent. |
| `isError` | boolean | Returns `true` if an error occurred. |
| `error` | {status: number, error: string, message: string} \| undefined | Provides details about the error. |
| `redirectTo` | string \| undefined | Redirection path in the client application that will be used in the link in the verification email. For instance, if you want to redirect to `https://myapp.com/success`, the `redirectTo` value is `'/success'`. |
| Name | Type | Notes |
| --------------- | -------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `resetPassword` | (email?: string) | Sends an email with a temporary connection link. Returns a promise with the current context |
| `isLoading` | boolean | Returns `true` when the action is executing, `false` when it finished its execution. |
| `isSent` | boolean | Returns `true` when the email has been successfully sent. |
| `isError` | boolean | Returns `true` if an error occurred. |
| `error` | {status: number, error: string, message: string} \| null | Provides details about the error. |
| `redirectTo` | string \| undefined | Redirection path in the client application that will be used in the link in the verification email. For instance, if you want to redirect to `https://myapp.com/success`, the `redirectTo` value is `'/success'`. |
#### Usage
@@ -345,12 +357,12 @@ import { useState } from 'react'
import { useResetPassword } from '@nhost/react'
const Component = () => {
const [email, setEamil] = useState('')
const { resetPassword, isLoading, isSent, isError, error } = useResetPassword(email?: string)
const [email, setEmail] = useState('')
const { resetPassword, isLoading, isSent, isError, error } = useResetPassword()
return (
<div>
<input value={email} onChange={(event) => setEmail(event.target.value)} />
<button onClick={resetPassword}>Send reset link</button>
<button onClick={() => resetPassword(email)}>Send reset link</button>
</div>
)
}
@@ -360,17 +372,17 @@ const Component = () => {
```js
const { sendEmail, isLoading, isSent, isError, error } =
useSendVerificationEmail(email?: string, options?: { redirectTo?: string })
useSendVerificationEmail(options?: { redirectTo?: string })
```
| Name | Type | Notes |
| ------------ | ------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `sendEmail` | (email?: string) => void | Resend the verification email. |
| `isLoading` | boolean | Returns `true` when the action is executing, `false` when it finished its execution. |
| `isSent` | boolean | Returns `true` if the verification email has been sent |
| `isError` | boolean | Returns `true` if an error occurred. |
| `error` | {status: number, error: string, message: string} \| undefined | Provides details about the error. |
| `redirectTo` | string \| undefined | Redirection path in the client application that will be used in the link in the verification email. For instance, if you want to redirect to `https://myapp.com/success`, the `redirectTo` value is `'/success'`. |
| Name | Type | Notes |
| ------------ | -------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `sendEmail` | (email?: string) | Resend the verification email. Returns a promise with the current context |
| `isLoading` | boolean | Returns `true` when the action is executing, `false` when it finished its execution. |
| `isSent` | boolean | Returns `true` if the verification email has been sent |
| `isError` | boolean | Returns `true` if an error occurred. |
| `error` | {status: number, error: string, message: string} \| null | Provides details about the error. |
| `redirectTo` | string \| undefined | Redirection path in the client application that will be used in the link in the verification email. For instance, if you want to redirect to `https://myapp.com/success`, the `redirectTo` value is `'/success'`. |
#### Usage
@@ -380,11 +392,11 @@ import { useSendVerificationEmail } from '@nhost/react'
const Component = () => {
const [email, setEmail] = useState('')
const { sendEmail, isLoading, isSent, isError, error } = useSendVerificationEmail(email)
const { sendEmail, isLoading, isSent, isError, error } = useSendVerificationEmail()
return (
<div>
<input value={email} onChange={(event) => setEmail(event.target.value)} />
<button onClick={sendEmail}>Send email verification</button>
<button onClick={() => sendEmail(email)}>Send email verification</button>
{isSent && (
<div>Please check your mailbox and follow the verification link to confirm your email</div>
)}
@@ -433,7 +445,7 @@ const Avatar = () => {
### Display name
```jsx
import { displayName } from '@nhost/react'
import { useDisplayName } from '@nhost/react'
const Avatar = () => {
const displayName = useDisplayName()

View File

@@ -64,5 +64,5 @@ const nhost = new NhostClient({
| `autoLogin` | boolean | `true` | If set to `true`, the client will detect credentials in the current URL that could have been sent during an email verification or an Oauth authentication. It will also automatically authenticate all the active tabs in the current browser. |
| `autoRefreshToken` | boolean | `true` | If set to `true`, the JWT (access token) will be automatically refreshed before it expires. |
| `clientStorageGetter` | (key:string) => string \| null | use localStorage | Nhost stores a refresh token in `localStorage` so the session can be restored when starting the browser. |
| `clientStorageGetter` | (key: string, value: string \| null | use localStorage | |
| `clientStorageSetter` | (key: string, value: string \| null | use localStorage | |
| `refreshIntervalTime` | | |

View File

@@ -7,10 +7,10 @@ title: 'Protecting routes'
You can protect routes by creating an `AuthGate` component when using `@nhost/react` with [React Router](https://reactrouter.com/web/guides/quick-start).
```jsx
import { Redirect } from 'react-router-dom'
import { useAuthenticationStatus } from '@nhost/react'
import { Redirect } from 'react-router-dom'
export function AuthGate(children) {
export function AuthGate({ children }) {
const { isLoading, isAuthenticated } = useAuthenticationStatus()
if (isLoading) {
@@ -28,16 +28,25 @@ export function AuthGate(children) {
Then, in your React Router, wrap the `AuthGate` component around the routes you want to protect:
```jsx
<Router>
<Switch>
<Route path="/login">
<Login />
</Route>
<Route path="/" exact>
<AuthGate> // <--- Use AuthGate component like this
<div>My protected dashboard</div>
</AuthGate>
</Route>
</Switch>
</Router>
import { AuthGate } from 'components/AuthGate'
import { BrowserRouter, Routes, Route } from 'react-router-dom'
export function App() {
return (
<BrowserRouter>
<Routes>
<Route path="/login">
<Login />
</Route>
<Route path="/" exact>
{/* Use AuthGate component like this */}
<AuthGate>
<div>My protected dashboard</div>
</AuthGate>
</Route>
</Routes>
</BrowserRouter>
)
}
```

View File

@@ -2,7 +2,6 @@
"name": "nhost-documentation",
"private": true,
"version": "0.0.1",
"scripts": {
"dev": "next",
"build:next": "next build",
@@ -38,6 +37,7 @@
"swagger-ui-react": "^4.5.2"
},
"devDependencies": {
"@types/node": "^17.0.21",
"@types/react": "^17.0.37",
"autoprefixer": "^10.4.0",
"next-sitemap": "^1.6.203",

View File

@@ -668,6 +668,23 @@
"additionalProperties": false,
"example": { "firstName": "John", "lastName": "Smith" },
"default": {}
},
"activeMfaType": {
"anyOf": [
{ "type": "string", "enum": [""] },
{ "type": "string", "enum": ["totp"] }
],
"description": "Multi-factor authentication type. A null value deactivates MFA",
"example": "totp"
},
"emailVerified": { "type": "boolean", "default": false },
"phoneNumber": { "type": "string" },
"phoneNumberVerified": { "type": "boolean", "default": false },
"roles": {
"type": "array",
"items": { "oneOf": [{ "enum": ["me"] }, { "enum": ["user"] }] },
"example": ["me", "user"],
"default": ["me", "user"]
}
},
"required": [
@@ -678,7 +695,12 @@
"email",
"isAnonymous",
"defaultRole",
"metadata"
"metadata",
"activeMfaType",
"emailVerified",
"phoneNumber",
"phoneNumberVerified",
"roles"
],
"additionalProperties": false
},

View File

@@ -1,46 +1,57 @@
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:news="http://www.google.com/schemas/sitemap-news/0.9" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:mobile="http://www.google.com/schemas/sitemap-mobile/1.0" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1" xmlns:video="http://www.google.com/schemas/sitemap-video/1.1">
<url><loc>https://docs.nhost.io</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2022-02-21T10:17:26.089Z</lastmod></url>
<url><loc>https://docs.nhost.io/get-started</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2022-02-21T10:17:26.089Z</lastmod></url>
<url><loc>https://docs.nhost.io/platform</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2022-02-21T10:17:26.089Z</lastmod></url>
<url><loc>https://docs.nhost.io/reference</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2022-02-21T10:17:26.089Z</lastmod></url>
<url><loc>https://docs.nhost.io/get-started/authentication</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2022-02-21T10:17:26.089Z</lastmod></url>
<url><loc>https://docs.nhost.io/get-started/cli-workflow</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2022-02-21T10:17:26.089Z</lastmod></url>
<url><loc>https://docs.nhost.io/get-started/quick-start</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2022-02-21T10:17:26.089Z</lastmod></url>
<url><loc>https://docs.nhost.io/get-started/upgrade</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2022-02-21T10:17:26.089Z</lastmod></url>
<url><loc>https://docs.nhost.io/platform/authentication</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2022-02-21T10:17:26.089Z</lastmod></url>
<url><loc>https://docs.nhost.io/platform/database</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2022-02-21T10:17:26.089Z</lastmod></url>
<url><loc>https://docs.nhost.io/platform/nhost</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2022-02-21T10:17:26.089Z</lastmod></url>
<url><loc>https://docs.nhost.io/platform/serverless-functions</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2022-02-21T10:17:26.089Z</lastmod></url>
<url><loc>https://docs.nhost.io/platform/storage</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2022-02-21T10:17:26.089Z</lastmod></url>
<url><loc>https://docs.nhost.io/reference/cli</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2022-02-21T10:17:26.089Z</lastmod></url>
<url><loc>https://docs.nhost.io/reference/nextjs</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2022-02-21T10:17:26.089Z</lastmod></url>
<url><loc>https://docs.nhost.io/reference/react</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2022-02-21T10:17:26.089Z</lastmod></url>
<url><loc>https://docs.nhost.io/reference/sdk</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2022-02-21T10:17:26.089Z</lastmod></url>
<url><loc>https://docs.nhost.io/reference/supporting-libraries</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2022-02-21T10:17:26.089Z</lastmod></url>
<url><loc>https://docs.nhost.io/get-started/cli-workflow/install-cli</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2022-02-21T10:17:26.089Z</lastmod></url>
<url><loc>https://docs.nhost.io/get-started/cli-workflow/local-changes</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2022-02-21T10:17:26.089Z</lastmod></url>
<url><loc>https://docs.nhost.io/get-started/cli-workflow/metadata-and-serverless-functions</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2022-02-21T10:17:26.089Z</lastmod></url>
<url><loc>https://docs.nhost.io/get-started/cli-workflow/workflow-setup</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2022-02-21T10:17:26.089Z</lastmod></url>
<url><loc>https://docs.nhost.io/get-started/quick-start/javascript-client</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2022-02-21T10:17:26.089Z</lastmod></url>
<url><loc>https://docs.nhost.io/get-started/quick-start/permissions</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2022-02-21T10:17:26.089Z</lastmod></url>
<url><loc>https://docs.nhost.io/get-started/quick-start/schema</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2022-02-21T10:17:26.089Z</lastmod></url>
<url><loc>https://docs.nhost.io/platform/authentication/sign-in-methods</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2022-02-21T10:17:26.089Z</lastmod></url>
<url><loc>https://docs.nhost.io/platform/authentication/social-login</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2022-02-21T10:17:26.089Z</lastmod></url>
<url><loc>https://docs.nhost.io/platform/authentication/user-management</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2022-02-21T10:17:26.089Z</lastmod></url>
<url><loc>https://docs.nhost.io/platform/database/graphql</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2022-02-21T10:17:26.089Z</lastmod></url>
<url><loc>https://docs.nhost.io/platform/database/permissions</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2022-02-21T10:17:26.089Z</lastmod></url>
<url><loc>https://docs.nhost.io/platform/nhost/environment-variables</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2022-02-21T10:17:26.089Z</lastmod></url>
<url><loc>https://docs.nhost.io/platform/nhost/github-integration</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2022-02-21T10:17:26.089Z</lastmod></url>
<url><loc>https://docs.nhost.io/platform/nhost/local-development</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2022-02-21T10:17:26.089Z</lastmod></url>
<url><loc>https://docs.nhost.io/platform/serverless-functions/event-triggers</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2022-02-21T10:17:26.089Z</lastmod></url>
<url><loc>https://docs.nhost.io/reference/nextjs/server-side</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2022-02-21T10:17:26.089Z</lastmod></url>
<url><loc>https://docs.nhost.io/reference/react/apollo</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2022-02-21T10:17:26.089Z</lastmod></url>
<url><loc>https://docs.nhost.io/reference/react/hooks</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2022-02-21T10:17:26.089Z</lastmod></url>
<url><loc>https://docs.nhost.io/reference/sdk/authentication</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2022-02-21T10:17:26.089Z</lastmod></url>
<url><loc>https://docs.nhost.io/reference/sdk/functions</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2022-02-21T10:17:26.089Z</lastmod></url>
<url><loc>https://docs.nhost.io/reference/sdk/graphql</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2022-02-21T10:17:26.089Z</lastmod></url>
<url><loc>https://docs.nhost.io/reference/sdk/storage</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2022-02-21T10:17:26.089Z</lastmod></url>
<url><loc>https://docs.nhost.io/reference/supporting-libraries/react-apollo</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2022-02-21T10:17:26.089Z</lastmod></url>
<url><loc>https://docs.nhost.io/reference/supporting-libraries/react-auth</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2022-02-21T10:17:26.089Z</lastmod></url>
<url><loc>https://docs.nhost.io</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2022-04-08T13:10:11.648Z</lastmod></url>
<url><loc>https://docs.nhost.io/get-started</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2022-04-08T13:10:11.648Z</lastmod></url>
<url><loc>https://docs.nhost.io/platform</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2022-04-08T13:10:11.648Z</lastmod></url>
<url><loc>https://docs.nhost.io/reference</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2022-04-08T13:10:11.648Z</lastmod></url>
<url><loc>https://docs.nhost.io/get-started/authentication</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2022-04-08T13:10:11.648Z</lastmod></url>
<url><loc>https://docs.nhost.io/get-started/cli-workflow</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2022-04-08T13:10:11.648Z</lastmod></url>
<url><loc>https://docs.nhost.io/get-started/quick-start</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2022-04-08T13:10:11.648Z</lastmod></url>
<url><loc>https://docs.nhost.io/get-started/upgrade</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2022-04-08T13:10:11.648Z</lastmod></url>
<url><loc>https://docs.nhost.io/platform/authentication</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2022-04-08T13:10:11.648Z</lastmod></url>
<url><loc>https://docs.nhost.io/platform/database</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2022-04-08T13:10:11.648Z</lastmod></url>
<url><loc>https://docs.nhost.io/platform/nhost</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2022-04-08T13:10:11.648Z</lastmod></url>
<url><loc>https://docs.nhost.io/platform/serverless-functions</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2022-04-08T13:10:11.648Z</lastmod></url>
<url><loc>https://docs.nhost.io/platform/storage</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2022-04-08T13:10:11.648Z</lastmod></url>
<url><loc>https://docs.nhost.io/reference/cli</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2022-04-08T13:10:11.648Z</lastmod></url>
<url><loc>https://docs.nhost.io/reference/hasura-auth</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2022-04-08T13:10:11.648Z</lastmod></url>
<url><loc>https://docs.nhost.io/reference/nextjs</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2022-04-08T13:10:11.648Z</lastmod></url>
<url><loc>https://docs.nhost.io/reference/react</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2022-04-08T13:10:11.649Z</lastmod></url>
<url><loc>https://docs.nhost.io/reference/sdk</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2022-04-08T13:10:11.649Z</lastmod></url>
<url><loc>https://docs.nhost.io/get-started/cli-workflow/install-cli</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2022-04-08T13:10:11.649Z</lastmod></url>
<url><loc>https://docs.nhost.io/get-started/cli-workflow/local-changes</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2022-04-08T13:10:11.649Z</lastmod></url>
<url><loc>https://docs.nhost.io/get-started/cli-workflow/metadata-and-serverless-functions</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2022-04-08T13:10:11.649Z</lastmod></url>
<url><loc>https://docs.nhost.io/get-started/cli-workflow/workflow-setup</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2022-04-08T13:10:11.649Z</lastmod></url>
<url><loc>https://docs.nhost.io/get-started/quick-start/javascript-client</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2022-04-08T13:10:11.649Z</lastmod></url>
<url><loc>https://docs.nhost.io/get-started/quick-start/permissions</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2022-04-08T13:10:11.649Z</lastmod></url>
<url><loc>https://docs.nhost.io/get-started/quick-start/schema</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2022-04-08T13:10:11.649Z</lastmod></url>
<url><loc>https://docs.nhost.io/platform/authentication/email-templates</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2022-04-08T13:10:11.649Z</lastmod></url>
<url><loc>https://docs.nhost.io/platform/authentication/sign-in-methods</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2022-04-08T13:10:11.649Z</lastmod></url>
<url><loc>https://docs.nhost.io/platform/authentication/sign-in-with-facebook</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2022-04-08T13:10:11.649Z</lastmod></url>
<url><loc>https://docs.nhost.io/platform/authentication/sign-in-with-github</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2022-04-08T13:10:11.649Z</lastmod></url>
<url><loc>https://docs.nhost.io/platform/authentication/sign-in-with-google</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2022-04-08T13:10:11.649Z</lastmod></url>
<url><loc>https://docs.nhost.io/platform/authentication/sign-in-with-linkedin</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2022-04-08T13:10:11.649Z</lastmod></url>
<url><loc>https://docs.nhost.io/platform/authentication/sign-in-with-spotify</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2022-04-08T13:10:11.649Z</lastmod></url>
<url><loc>https://docs.nhost.io/platform/authentication/social-sign-in</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2022-04-08T13:10:11.649Z</lastmod></url>
<url><loc>https://docs.nhost.io/platform/authentication/user-management</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2022-04-08T13:10:11.649Z</lastmod></url>
<url><loc>https://docs.nhost.io/platform/database/graphql</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2022-04-08T13:10:11.649Z</lastmod></url>
<url><loc>https://docs.nhost.io/platform/database/permissions</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2022-04-08T13:10:11.649Z</lastmod></url>
<url><loc>https://docs.nhost.io/platform/nhost/environment-variables</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2022-04-08T13:10:11.649Z</lastmod></url>
<url><loc>https://docs.nhost.io/platform/nhost/github-integration</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2022-04-08T13:10:11.649Z</lastmod></url>
<url><loc>https://docs.nhost.io/platform/nhost/local-development</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2022-04-08T13:10:11.649Z</lastmod></url>
<url><loc>https://docs.nhost.io/platform/serverless-functions/event-triggers</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2022-04-08T13:10:11.649Z</lastmod></url>
<url><loc>https://docs.nhost.io/reference/hasura-auth/api-reference</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2022-04-08T13:10:11.649Z</lastmod></url>
<url><loc>https://docs.nhost.io/reference/hasura-auth/configuration</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2022-04-08T13:10:11.649Z</lastmod></url>
<url><loc>https://docs.nhost.io/reference/hasura-auth/environment-variables</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2022-04-08T13:10:11.649Z</lastmod></url>
<url><loc>https://docs.nhost.io/reference/hasura-auth/installation</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2022-04-08T13:10:11.649Z</lastmod></url>
<url><loc>https://docs.nhost.io/reference/hasura-auth/schema</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2022-04-08T13:10:11.649Z</lastmod></url>
<url><loc>https://docs.nhost.io/reference/nextjs/configuration</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2022-04-08T13:10:11.649Z</lastmod></url>
<url><loc>https://docs.nhost.io/reference/nextjs/protecting-routes</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2022-04-08T13:10:11.649Z</lastmod></url>
<url><loc>https://docs.nhost.io/reference/react/apollo</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2022-04-08T13:10:11.649Z</lastmod></url>
<url><loc>https://docs.nhost.io/reference/react/hooks</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2022-04-08T13:10:11.649Z</lastmod></url>
<url><loc>https://docs.nhost.io/reference/react/protecting-routes</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2022-04-08T13:10:11.649Z</lastmod></url>
<url><loc>https://docs.nhost.io/reference/sdk/authentication</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2022-04-08T13:10:11.649Z</lastmod></url>
<url><loc>https://docs.nhost.io/reference/sdk/functions</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2022-04-08T13:10:11.649Z</lastmod></url>
<url><loc>https://docs.nhost.io/reference/sdk/graphql</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2022-04-08T13:10:11.649Z</lastmod></url>
<url><loc>https://docs.nhost.io/reference/sdk/storage</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2022-04-08T13:10:11.649Z</lastmod></url>
</urlset>

View File

@@ -10,9 +10,9 @@
},
"dependencies": {
"@apollo/client": "^3.5.10",
"@nhost/nextjs": "^1.0.0",
"@nhost/react": "^0.3.0",
"@nhost/react-apollo": "^4.0.0",
"@nhost/nextjs": "^1.0.10",
"@nhost/react": "^0.5.0",
"@nhost/react-apollo": "^4.0.10",
"graphql": "^16.3.0",
"next": "12.1.0",
"react": "17.0.2",

View File

@@ -25,11 +25,11 @@ const Home: NextPage = () => {
const [newPassword, setNewPassword] = useState('')
const accessToken = useAccessToken()
const { signOut } = useSignOut()
const { signUpEmailPassword, ...signUpResult } = useSignUpEmailPassword(email, password)
const { signInEmailPassword } = useSignInEmailPassword(email, password)
const { signInEmailPasswordless } = useSignInEmailPasswordless(email)
const { changeEmail, ...changeEmailResult } = useChangeEmail(newEmail)
const { changePassword, ...changePasswordResult } = useChangePassword(newPassword)
const { signUpEmailPassword, ...signUpResult } = useSignUpEmailPassword()
const { signInEmailPassword } = useSignInEmailPassword()
const { signInEmailPasswordless } = useSignInEmailPasswordless()
const { changeEmail, ...changeEmailResult } = useChangeEmail()
const { changePassword, ...changePasswordResult } = useChangePassword()
const { loading, data, error } = useAuthQuery(BOOKS_QUERY)
return (
<div>
@@ -37,20 +37,24 @@ const Home: NextPage = () => {
<>
<button onClick={signOut}>Logout</button>
<input value={newEmail} onChange={(e) => setNewEmail(e.target.value)} />
<button onClick={changeEmail}>Change email</button>
<button onClick={() => changeEmail(email)}>Change email</button>
<div>{JSON.stringify(changeEmailResult)}</div>
<button onClick={changePassword}>Change password</button>
<button onClick={() => changePassword(password)}>Change password</button>
<input value={newPassword} onChange={(e) => setNewPassword(e.target.value)} />
<div>{JSON.stringify(changePasswordResult)}</div>
</>
) : (
<>
<input value={email} onChange={(e) => setEmail(e.target.value)} />
<button onClick={signInEmailPasswordless}>Passwordless signin</button>
<button onClick={() => signInEmailPasswordless(email)}>Passwordless signin</button>
<div>{JSON.stringify(signUpResult)}</div>
<input value={password} onChange={(e) => setPassword(e.target.value)} type="password" />
<button onClick={signUpEmailPassword}>Email + password sign-up</button>
<button onClick={signInEmailPassword}>Email + password sign-in</button>
<button onClick={() => signUpEmailPassword(email, password)}>
Email + password sign-up
</button>
<button onClick={() => signInEmailPassword(email, password)}>
Email + password sign-in
</button>
</>
)}

View File

@@ -136,71 +136,71 @@
resolved "https://registry.yarnpkg.com/@next/swc-win32-x64-msvc/-/swc-win32-x64-msvc-12.1.0.tgz#d27e7e76c87a460a4da99c5bfdb1618dcd6cd064"
integrity sha512-aBvcbMwuanDH4EMrL2TthNJy+4nP59Bimn8egqv6GHMVj0a44cU6Au4PjOhLNqEh9l+IpRGBqMTzec94UdC5xg==
"@nhost/apollo@0.3.0":
version "0.3.0"
resolved "https://registry.yarnpkg.com/@nhost/apollo/-/apollo-0.3.0.tgz#89a66e97aa6af4de6045bf0c780e8b9590c06d9b"
integrity sha512-97DSycgPEnQQtzAWPB36yENAuQFDEl8c7qLB9xOzSnplImv5NGces40XMAkTDEWam0eD//PtXP9zi+TYNeMNjw==
"@nhost/apollo@^0.3.7":
version "0.3.7"
resolved "https://registry.yarnpkg.com/@nhost/apollo/-/apollo-0.3.7.tgz#761d3d60519df60caaa7220909ab11bd2c629e3a"
integrity sha512-NH1WCC5D6K/Ft8/EXYIgeAhOBq5Gt1OtX9U9RzV2IqmVRGigDw+YlXr8P5GRPAzBeZUVWrM1wvBt+oBk8zw/7g==
dependencies:
"@nhost/core" "0.3.0"
"@nhost/core" "^0.3.8"
graphql "16"
subscriptions-transport-ws "^0.11.0"
"@nhost/core@0.3.0":
version "0.3.0"
resolved "https://registry.yarnpkg.com/@nhost/core/-/core-0.3.0.tgz#fa630afef50840cd7b8415e17894c7765cda273f"
integrity sha512-wEdq+BLOHH7bOhBvF5gql9vtWuEtlLWvw65AtpstfX8pAUY8ce2yqamV6Z8kxr/RSYXZA+aLsKwig50qSZa99w==
"@nhost/core@^0.3.8":
version "0.3.8"
resolved "https://registry.yarnpkg.com/@nhost/core/-/core-0.3.8.tgz#0269ab5daa36b1bdd2b2864c174809a86d4d2a7a"
integrity sha512-6mOv23H16n0YN0voXdXSGS18rUELe1YI2+HXMRlaeksCib4BvSf28lsideEOjFnyfHA3Y4wAX1SMxnyaEj1qaQ==
dependencies:
axios "^0.25.0"
broadcast-channel "^4.10.0"
js-cookie "^3.0.1"
xstate "^4.30.5"
"@nhost/hasura-auth-js@1.0.0":
version "1.0.0"
resolved "https://registry.yarnpkg.com/@nhost/hasura-auth-js/-/hasura-auth-js-1.0.0.tgz#0f3c267614ca328c944797f33a1921c8103dd3e5"
integrity sha512-hENPB1aMdekYxfDejthPAdoj9JarqaVkBKNRa+jun247Un1X6eFGDPo52Y2tZfP44pJEUK4EqTqkWH3DwT4uXg==
"@nhost/hasura-auth-js@^1.0.9":
version "1.0.9"
resolved "https://registry.yarnpkg.com/@nhost/hasura-auth-js/-/hasura-auth-js-1.0.9.tgz#7e5cfe7a59b18778352dd6d2bef368c765ce9886"
integrity sha512-d0UDfakzUO9N0/4RRy9NptoOLgpcRmr2F5XxVVzqLYX67+XzZoqT+LMhOF8spKP4+JqFlKFgqbNulmuRRc5FfA==
dependencies:
"@nhost/core" "0.3.0"
"@nhost/core" "^0.3.8"
"@nhost/hasura-storage-js@0.2.0":
"@nhost/hasura-storage-js@^0.2.0":
version "0.2.0"
resolved "https://registry.yarnpkg.com/@nhost/hasura-storage-js/-/hasura-storage-js-0.2.0.tgz#e8c127d883d231313cd262553732da3b0dccb858"
integrity sha512-JumgUhnScU6Bv8SBmN2F4sY+LbrD3i25Ppr30Zjbv4MvbUguBclx9zzAwqub/P2n/azc7bjjRvYl2n2/jjKRXw==
dependencies:
axios "^0.21.1"
"@nhost/nextjs@^1.0.0":
version "1.0.0"
resolved "https://registry.yarnpkg.com/@nhost/nextjs/-/nextjs-1.0.0.tgz#2e91cce4352ec7c521099c8f9fccd5fef94ec902"
integrity sha512-yrRXd3796wcLjabeqIbBgZ/IdD40xpC9LhBA9LoXHqHfNaqZ4ujtcMnSc7IZWJv45P5rDO3T8kKKk+Sm6vTAvQ==
"@nhost/nextjs@^1.0.10":
version "1.0.10"
resolved "https://registry.yarnpkg.com/@nhost/nextjs/-/nextjs-1.0.10.tgz#ac78e1b32b6a89e6379179108c49d71cf23aeed8"
integrity sha512-BTNe4KHhWLbRKd8XfppYncLIohXZ0C+oCTZApVwwgVexqdQ5dxhObw0nQin2K7TlP2Mis+Ldzjjn3SO/hcb3xw==
dependencies:
"@nhost/nhost-js" "1.0.0"
"@nhost/nhost-js" "^1.0.9"
cookies "^0.8.0"
"@nhost/nhost-js@1.0.0":
version "1.0.0"
resolved "https://registry.yarnpkg.com/@nhost/nhost-js/-/nhost-js-1.0.0.tgz#d57aa66c889922926b9bde6278d35000729f884c"
integrity sha512-ve5+TqYGcQbRwDqxVDMCJKZQlj5BFCsTzqEhIAUnLP6Gu8YlNVeUQL3Bbc19j71OkHDNhw8TAJbE2zcFUBT2Fw==
"@nhost/nhost-js@^1.0.9":
version "1.0.9"
resolved "https://registry.yarnpkg.com/@nhost/nhost-js/-/nhost-js-1.0.9.tgz#a1b0bc0c35e15ade2867da4d211b1f81f3bc5e28"
integrity sha512-/SZLk3Be560scVAbUswcRSE4RMwf6M7xanbNLqGUuI/sr1Ir253WPhaD2YWXZChP1v2LBzONhdJNI2g7u1NzoA==
dependencies:
"@nhost/hasura-auth-js" "1.0.0"
"@nhost/hasura-storage-js" "0.2.0"
"@nhost/hasura-auth-js" "^1.0.9"
"@nhost/hasura-storage-js" "^0.2.0"
axios "^0.23.0"
jwt-decode "^3.1.2"
query-string "^7.0.1"
"@nhost/react-apollo@^4.0.0":
version "4.0.0"
resolved "https://registry.yarnpkg.com/@nhost/react-apollo/-/react-apollo-4.0.0.tgz#08be35946eadbb746f27435c3fc72cd092a97b61"
integrity sha512-ZmFgBgHFJE2Z2ZBYx3U4Gry9TprUOb4NXw/K5lSKv11zPeEaclfpqn+aeQbtCj02oCnzRe+MJLsJenpcuhQRuw==
"@nhost/react-apollo@^4.0.10":
version "4.0.10"
resolved "https://registry.yarnpkg.com/@nhost/react-apollo/-/react-apollo-4.0.10.tgz#d28819019f35aff7fb69a3b485489ab0492643e1"
integrity sha512-MTIBk9aQVCIfVR17eEKM6ssELadpDhIAh2ERjaZY8+i9KMgVyjEt0s4842nl1Bwq7OFIXf5GRykr3RtTjuT/Ug==
dependencies:
"@nhost/apollo" "0.3.0"
"@nhost/apollo" "^0.3.7"
"@nhost/react@^0.3.0":
version "0.3.0"
resolved "https://registry.yarnpkg.com/@nhost/react/-/react-0.3.0.tgz#5401922dce91bb66db5d575de1869df00fabbb8e"
integrity sha512-jxyt4dYfphgv3bf6jvV7qDKnV5qUArFvdTYExKlBA9tsBQYta0heawMsJk0rEarEZGUw1iioiUYFKdZyl2Qi5Q==
"@nhost/react@^0.5.0":
version "0.5.0"
resolved "https://registry.yarnpkg.com/@nhost/react/-/react-0.5.0.tgz#5276ae7e13691f32ceaa0e6ca2460ef2605820f6"
integrity sha512-d89I3Q1Y6+9QJ6jP9yU9xrEJv8dCvTwll7tctd7emqZyPWGgInLpmZ9OA+/xrannowck5MsgaBdz0zxQ9bjJBA==
dependencies:
"@nhost/nhost-js" "1.0.0"
"@nhost/nhost-js" "^1.0.9"
"@xstate/react" "^2.0.1"
immer "^9.0.12"

View File

@@ -1,16 +1,13 @@
<!DOCTYPE html>
<html lang="en">
<head>
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/src/favicon.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Nhost React+Apollo demo</title>
</head>
<body>
<title>Vite App</title>
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>
</body>
</html>
</body>
</html>

View File

@@ -2,8 +2,6 @@ table:
name: provider_requests
schema: auth
configuration:
custom_column_names:
redirect_url: redirectUrl
custom_name: authProviderRequests
custom_root_fields:
delete: deleteAuthProviderRequests

View File

@@ -1,19 +1,21 @@
{
"name": "@nhost-examples/react-apollo",
"version": "0.2.0",
"version": "0.0.1",
"private": true,
"dependencies": {
"@apollo/client": "^3.5.10",
"@nhost/react": "^0.3.0",
"@nhost/react-apollo": "^4.0.0",
"@nhost/react": "^0.5.0",
"@nhost/react-apollo": "^4.0.10",
"@rsuite/icons": "^1.0.2",
"jwt-decode": "^3.1.2",
"less": "^4.1.2",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-icons": "^4.3.1",
"react-json-view": "^1.21.3",
"react-router-dom": "^6.2.1",
"rsuite": "^5.6.2"
"react-router": "^6.3.0",
"react-router-dom": "^6.3.0",
"rsuite": "^5.7.1"
},
"scripts": {
"dev": "vite",
@@ -38,14 +40,10 @@
]
},
"devDependencies": {
"@types/react": "^17.0.39",
"@types/react-dom": "^17.0.11",
"@vitejs/plugin-react": "^1.2.0",
"@xstate/inspect": "^0.6.2",
"graphql": "15.7.2",
"less": "^4.1.2",
"typescript": "^4.5.5",
"vite": "^2.8.5",
"ws": "^8.5.0"
"@types/react": "^17.0.43",
"@types/react-dom": "^17.0.14",
"@vitejs/plugin-react": "^1.3.0",
"typescript": "^4.6.3",
"vite": "^2.9.1"
}
}

View File

@@ -1,3 +1,4 @@
import React from 'react'
import { Link } from 'react-router-dom'
import { Panel } from 'rsuite'
@@ -19,11 +20,11 @@ export const AboutPage: React.FC = () => (
<li>React</li>
<li>React-router</li>
<li>RSuite</li>
<li>...and of course, the Nhost React client</li>
<li>and of course, the Nhost React client</li>
</ul>
</div>
<div>
Noew let's go to the <Link to="/">index page</Link>
Noew let&apos;s go to the <Link to="/">index page</Link>
</div>
</Panel>
)

View File

@@ -1,17 +1,20 @@
import './App.css'
/* eslint-disable react/react-in-jsx-scope */
import { useEffect } from 'react'
import { Link, Route, Routes, useLocation, useNavigate } from 'react-router-dom'
import { Container, Content, Header, Nav, Navbar } from 'rsuite'
import { useAuthenticated, useSignOut } from '@nhost/react'
import ExitIcon from '@rsuite/icons/Exit'
import { Routes, Route, Link, useNavigate, useLocation } from 'react-router-dom'
import { Container, Header, Navbar, Content, Nav } from 'rsuite'
import { useEffect } from 'react'
import { SignInPage } from './sign-in'
import { AuthGate, PublicGate } from './components/auth-gates'
import { AboutPage } from './About'
import { ApolloPage } from './apollo'
import Home from './Home'
import { ProfilePage } from './profile'
import { ApolloPage } from './apollo'
import { SignInPage } from './sign-in'
import { SignUpPage } from './sign-up'
import { AboutPage } from './About'
import './App.css'
function App() {
const isAuthenticated = useAuthenticated()

View File

@@ -1,3 +1,4 @@
import React from 'react'
import { Panel } from 'rsuite'
const HomePage: React.FC = () => {

View File

@@ -1,5 +1,7 @@
import { gql } from '@apollo/client'
import React from 'react'
import { Panel, Table } from 'rsuite'
import { gql } from '@apollo/client'
import { useAuthQuery } from '@nhost/react-apollo'
const GET_BOOKS = gql`

View File

@@ -1,4 +1,6 @@
import React from 'react'
import { Navigate, useLocation } from 'react-router-dom'
import { useAuthenticationStatus } from '@nhost/react'
export const AuthGate: React.FC = ({ children }) => {

View File

@@ -1,12 +1,13 @@
import { Button, Input, Message } from 'rsuite'
import React, { useEffect, useState } from 'react'
import { useNavigate } from 'react-router-dom'
import { Button, Input, Message } from 'rsuite'
import { useSignInEmailPasswordless } from '@nhost/react'
import React, { useState, useEffect } from 'react'
export const EmailPasswordlessForm: React.FC = () => {
const [email, setEmail] = useState('')
const navigate = useNavigate()
const { signInEmailPasswordless, isError, isSuccess, error } = useSignInEmailPasswordless(email, {
const { signInEmailPasswordless, isError, isSuccess, error } = useSignInEmailPasswordless({
redirectTo: '/profile'
})
const [showError, setShowError] = useState(true)
@@ -42,7 +43,7 @@ export const EmailPasswordlessForm: React.FC = () => {
style={{ marginTop: '0.5em' }}
onClick={() => {
setShowError(true)
signInEmailPasswordless()
signInEmailPasswordless(email)
}}
>
Continue with email

View File

@@ -1,7 +1,9 @@
/* eslint-disable react/react-in-jsx-scope */
import { FaFacebook, FaGithub, FaGoogle } from 'react-icons/fa'
import { IconButton } from 'rsuite'
import { FaGithub, FaGoogle, FaFacebook } from 'react-icons/fa'
import { Icon } from '@rsuite/icons'
import { useProviderLink } from '@nhost/react'
import { Icon } from '@rsuite/icons'
export const OAuthLinks: React.FC = () => {
// TODO show how to use options

View File

@@ -1,10 +1,10 @@
/// <reference types="vite/client" />
interface ImportMetaEnv {
readonly VITE_NHOST_URL: string
// more env variables...
}
interface ImportMeta {
readonly env: ImportMetaEnv
}
readonly VITE_NHOST_URL: string
// more env variables...
}
interface ImportMeta {
readonly env: ImportMetaEnv
}

View File

@@ -1,11 +1,13 @@
import React from 'react'
import ReactDOM from 'react-dom'
import App from './App'
import { BrowserRouter } from 'react-router-dom'
import { NhostClient, NhostReactProvider } from '@nhost/react'
import { NhostApolloProvider } from '@nhost/react-apollo'
import 'rsuite/styles/index.less' // or 'rsuite/dist/rsuite.min.css'
import { BrowserRouter } from 'react-router-dom'
import { NhostApolloProvider } from '@nhost/react-apollo'
import App from './App'
const nhost = new NhostClient({
backendUrl: import.meta.env.VITE_NHOST_URL || 'http://localhost:1337'

View File

@@ -1,11 +1,13 @@
import { useChangeEmail, useEmail } from '@nhost/react'
/* eslint-disable react/react-in-jsx-scope */
import { useEffect, useState } from 'react'
import { Button, FlexboxGrid, Input, Message, Panel, toaster, Notification } from 'rsuite'
import { Button, FlexboxGrid, Input, Message, Notification, Panel, toaster } from 'rsuite'
import { useChangeEmail, useEmail } from '@nhost/react'
export const ChangeEmail: React.FC = () => {
const [newEmail, setNewEmail] = useState('')
const email = useEmail()
const { changeEmail, error, needsEmailVerification } = useChangeEmail(newEmail, {
const { changeEmail, error, needsEmailVerification } = useChangeEmail({
redirectTo: '/profile'
})
const [errorMessage, setErrorMessage] = useState('')
@@ -45,7 +47,7 @@ export const ChangeEmail: React.FC = () => {
<Input value={newEmail} onChange={setNewEmail} placeholder="New email" />
</FlexboxGrid.Item>
<FlexboxGrid.Item colspan={12}>
<Button onClick={changeEmail} block appearance="primary">
<Button onClick={() => changeEmail(email)} block appearance="primary">
Change
</Button>
</FlexboxGrid.Item>

View File

@@ -1,10 +1,12 @@
import { useChangePassword } from '@nhost/react'
import React from 'react'
import { useEffect, useState } from 'react'
import { Button, FlexboxGrid, Input, Message, Panel, toaster, Notification } from 'rsuite'
import { Button, FlexboxGrid, Input, Message, Notification, Panel, toaster } from 'rsuite'
import { useChangePassword } from '@nhost/react'
export const ChangePassword: React.FC = () => {
const [password, setPassword] = useState('')
const { changePassword, isSuccess, error } = useChangePassword(password)
const { changePassword, isSuccess, error } = useChangePassword()
const [errorMessage, setErrorMessage] = useState('')
// * See https://github.com/rsuite/rsuite/issues/2336
@@ -44,7 +46,7 @@ export const ChangePassword: React.FC = () => {
/>
</FlexboxGrid.Item>
<FlexboxGrid.Item colspan={12}>
<Button onClick={changePassword} block appearance="primary">
<Button onClick={() => changePassword(password)} block appearance="primary">
Change
</Button>
</FlexboxGrid.Item>

View File

@@ -1,6 +1,8 @@
import decode from 'jwt-decode'
import React from 'react'
import ReactJson from 'react-json-view'
import { Button, Col, Panel, Row } from 'rsuite'
import { useAccessToken, useNhostClient, useUserData } from '@nhost/react'
import { ChangeEmail } from './change-email'

View File

@@ -1,11 +1,12 @@
import { useConfigMfa } from '@nhost/react'
import React from 'react'
import { useState } from 'react'
import { Button, Input, Panel } from 'rsuite'
import { useConfigMfa } from '@nhost/react'
export const Mfa: React.FC = () => {
const [code, setCode] = useState('')
const { generateQrCode, activateMfa, isActivated, isGenerated, qrCodeDataUrl } =
useConfigMfa(code)
const { generateQrCode, activateMfa, isActivated, isGenerated, qrCodeDataUrl } = useConfigMfa()
return (
<Panel header="Activate 2-step verification" bordered>
@@ -18,7 +19,7 @@ export const Mfa: React.FC = () => {
<div>
<img alt="qrcode" src={qrCodeDataUrl} />
<Input value={code} onChange={setCode} placeholder="Enter activation code" />
<Button block appearance="primary" onClick={activateMfa}>
<Button block appearance="primary" onClick={() => activateMfa(code)}>
Activate
</Button>
</div>

View File

@@ -1,7 +1,8 @@
import { Button, Divider, Input, Message } from 'rsuite'
import { useSignInEmailPassword } from '@nhost/react'
import React, { useEffect, useState } from 'react'
import { NavLink } from 'react-router-dom'
import { Button, Divider, Input, Message } from 'rsuite'
import { useSignInEmailPassword } from '@nhost/react'
const Footer: React.FC = () => (
<div>
@@ -80,7 +81,14 @@ export const EmailPassword: React.FC = () => {
</Message>
)}
<Button appearance="primary" onClick={signInEmailPassword} block>
<Button
appearance="primary"
onClick={async () => {
const result = await signInEmailPassword(email, password)
console.log(result)
}}
block
>
Sign in
</Button>
<Button as={NavLink} block to="/sign-in/forgot-password">

View File

@@ -1,6 +1,7 @@
import { Button } from 'rsuite'
import { NavLink } from 'react-router-dom'
import React from 'react'
import { NavLink } from 'react-router-dom'
import { Button } from 'rsuite'
import { EmailPasswordlessForm } from '../components/email-passwordless-form'
export const EmailPasswordless: React.FC = () => {
return (

View File

@@ -1,11 +1,12 @@
import { Button, Divider, Input, Message, Notification, toaster } from 'rsuite'
import { useResetPassword } from '@nhost/react'
import React, { useEffect, useState } from 'react'
import { NavLink } from 'react-router-dom'
import { Button, Divider, Input, Message, Notification, toaster } from 'rsuite'
import { useResetPassword } from '@nhost/react'
export const ForgotPassword: React.FC = () => {
const [email, setEmail] = useState('')
const { resetPassword, isSent, error } = useResetPassword(email, { redirectTo: '/profile' })
const { resetPassword, isSent, error } = useResetPassword({ redirectTo: '/profile' })
const [errorMessage, setErrorMessage] = useState('')
// * Set error message from the authentication hook errors
@@ -16,16 +17,12 @@ export const ForgotPassword: React.FC = () => {
useEffect(() => {
setErrorMessage('')
}, [email])
// * See https://github.com/rsuite/rsuite/issues/2336
useEffect(() => {
toaster.push(<div />)
}, [])
useEffect(() => {
if (isSent) {
toaster.push(
<Notification type="info" header="Info" closable>
An email has been sent with a passwordless authentication link, so you'll be able to
An email has been sent with a passwordless authentication link, so you will be able to
authenticate and change your password.
</Notification>
)
@@ -48,7 +45,7 @@ export const ForgotPassword: React.FC = () => {
</Message>
)}
<Button appearance="primary" onClick={resetPassword} block>
<Button appearance="primary" onClick={() => resetPassword(email)} block>
Reset your password
</Button>
<Divider />

View File

@@ -1,14 +1,16 @@
/* eslint-disable jsx-a11y/anchor-is-valid */
import React from 'react'
import { FaLock } from 'react-icons/fa'
import { Link, NavLink, Route, Routes } from 'react-router-dom'
import { Button, Divider, FlexboxGrid, IconButton, Panel } from 'rsuite'
import { Icon } from '@rsuite/icons'
import { FaLock } from 'react-icons/fa'
import { OAuthLinks } from '../components'
import { VerificationEmailSent } from '../verification-email-sent'
import { EmailPassword } from './email-password'
import { ForgotPassword } from './forgot-password'
import { EmailPasswordless } from './email-passwordless'
import { ForgotPassword } from './forgot-password'
// import { useSignInAnonymous } from '@nhost/react'
const Index: React.FC = () => (
@@ -48,7 +50,7 @@ export const SignInPage: React.FC = () => {
</FlexboxGrid.Item>
</FlexboxGrid>
<Divider />
Don't have an account? <Link to="/sign-up">Sign up</Link>
Don&lsquo;t have an account? <Link to="/sign-up">Sign up</Link>
{/* or{' '}
<a href="#" onClick={signIn}>
enter the app anonymously

View File

@@ -1,7 +1,9 @@
import { Button, Input, Message } from 'rsuite'
import { useSignUpEmailPassword } from '@nhost/react'
/* eslint-disable react/react-in-jsx-scope */
import { useEffect, useMemo, useState } from 'react'
import { NavLink, useNavigate } from 'react-router-dom'
import { Button, Input, Message } from 'rsuite'
import { useSignUpEmailPassword } from '@nhost/react'
export const EmailPassword: React.FC = () => {
const [email, setEmail] = useState('')
@@ -14,11 +16,8 @@ export const EmailPassword: React.FC = () => {
)
const navigate = useNavigate()
const [confirmPassword, setConfirmPassword] = useState('')
const { signUpEmailPassword, error, needsEmailVerification, isSuccess } = useSignUpEmailPassword(
email,
password,
options
)
const { signUpEmailPassword, error, needsEmailVerification, isSuccess } =
useSignUpEmailPassword(options)
const [errorMessage, setErrorMessage] = useState('')
useEffect(() => {
if (needsEmailVerification) navigate('/sign-up/verification-email-sent')
@@ -89,9 +88,10 @@ export const EmailPassword: React.FC = () => {
<Button
appearance="primary"
onClick={() => {
onClick={async () => {
setErrorMessage('')
signUpEmailPassword()
const result = await signUpEmailPassword(email, password)
console.log(result)
}}
block
>

View File

@@ -1,6 +1,7 @@
import { Button } from 'rsuite'
import { NavLink } from 'react-router-dom'
import React from 'react'
import { NavLink } from 'react-router-dom'
import { Button } from 'rsuite'
import { EmailPasswordlessForm } from '../components/email-passwordless-form'
export const EmailPasswordless: React.FC = () => {
return (

View File

@@ -1,9 +1,13 @@
import { Icon } from '@rsuite/icons'
import React from 'react'
import { FaLock } from 'react-icons/fa'
import { Button, Divider, FlexboxGrid, IconButton, Panel } from 'rsuite'
import { Link, NavLink, Route, Routes } from 'react-router-dom'
import { Button, Divider, FlexboxGrid, IconButton, Panel } from 'rsuite'
import { Icon } from '@rsuite/icons'
import { OAuthLinks } from '../components'
import { VerificationEmailSent } from '../verification-email-sent'
import { EmailPassword } from './email-password'
import { EmailPasswordless } from './email-passwordless'

View File

@@ -1,7 +1,8 @@
import { useAuthenticated } from '@nhost/react'
import React, { useEffect } from 'react'
import { useNavigate } from 'react-router-dom'
import { useAuthenticated } from '@nhost/react'
export const VerificationEmailSent: React.FC = () => {
const isAuthenticated = useAuthenticated()
const navigate = useNavigate()

View File

@@ -39,7 +39,7 @@
resolved "https://registry.yarnpkg.com/@babel/compat-data/-/compat-data-7.17.7.tgz#078d8b833fbbcc95286613be8c716cef2b519fa2"
integrity sha512-p8pdE6j0a29TNGebNm7NzYZWB3xVZJBZ7XGs42uAKzQo8VQ3F0By/cQCtUEABwIqw5zo6WA4NbmxsfzADzMKnQ==
"@babel/core@^7.16.12":
"@babel/core@^7.17.8":
version "7.17.8"
resolved "https://registry.yarnpkg.com/@babel/core/-/core-7.17.8.tgz#3dac27c190ebc3a4381110d46c80e77efe172e1a"
integrity sha512-OdQDV/7cRBtJHLSOBqqbYNkOcydOgnX59TZx4puf41fzcVtN3e/4yqY8lMQsK+5X2lJtAdmA+6OHqsj1hBJ4IQ==
@@ -217,7 +217,7 @@
dependencies:
"@babel/helper-plugin-utils" "^7.16.7"
"@babel/plugin-transform-react-jsx@^7.16.7":
"@babel/plugin-transform-react-jsx@^7.16.7", "@babel/plugin-transform-react-jsx@^7.17.3":
version "7.17.3"
resolved "https://registry.yarnpkg.com/@babel/plugin-transform-react-jsx/-/plugin-transform-react-jsx-7.17.3.tgz#eac1565da176ccb1a715dae0b4609858808008c1"
integrity sha512-9tjBm4O07f7mzKSIlEmPdiE6ub7kfIe6Cd+w+oQebpATfTQMAgW+YOuWxogbKVTulA+MEO7byMeIUtQ1z+z+ZQ==
@@ -296,67 +296,67 @@
resolved "https://registry.yarnpkg.com/@juggle/resize-observer/-/resize-observer-3.3.1.tgz#b50a781709c81e10701004214340f25475a171a0"
integrity sha512-zMM9Ds+SawiUkakS7y94Ymqx+S0ORzpG3frZirN3l+UlXUmSUR7hF4wxCVqW+ei94JzV5kt0uXBcoOEAuiydrw==
"@nhost/apollo@0.3.0":
version "0.3.0"
resolved "https://registry.yarnpkg.com/@nhost/apollo/-/apollo-0.3.0.tgz#89a66e97aa6af4de6045bf0c780e8b9590c06d9b"
integrity sha512-97DSycgPEnQQtzAWPB36yENAuQFDEl8c7qLB9xOzSnplImv5NGces40XMAkTDEWam0eD//PtXP9zi+TYNeMNjw==
"@nhost/apollo@^0.3.7":
version "0.3.7"
resolved "https://registry.yarnpkg.com/@nhost/apollo/-/apollo-0.3.7.tgz#761d3d60519df60caaa7220909ab11bd2c629e3a"
integrity sha512-NH1WCC5D6K/Ft8/EXYIgeAhOBq5Gt1OtX9U9RzV2IqmVRGigDw+YlXr8P5GRPAzBeZUVWrM1wvBt+oBk8zw/7g==
dependencies:
"@nhost/core" "0.3.0"
"@nhost/core" "^0.3.8"
graphql "16"
subscriptions-transport-ws "^0.11.0"
"@nhost/core@0.3.0":
version "0.3.0"
resolved "https://registry.yarnpkg.com/@nhost/core/-/core-0.3.0.tgz#fa630afef50840cd7b8415e17894c7765cda273f"
integrity sha512-wEdq+BLOHH7bOhBvF5gql9vtWuEtlLWvw65AtpstfX8pAUY8ce2yqamV6Z8kxr/RSYXZA+aLsKwig50qSZa99w==
"@nhost/core@^0.3.8":
version "0.3.8"
resolved "https://registry.yarnpkg.com/@nhost/core/-/core-0.3.8.tgz#0269ab5daa36b1bdd2b2864c174809a86d4d2a7a"
integrity sha512-6mOv23H16n0YN0voXdXSGS18rUELe1YI2+HXMRlaeksCib4BvSf28lsideEOjFnyfHA3Y4wAX1SMxnyaEj1qaQ==
dependencies:
axios "^0.25.0"
broadcast-channel "^4.10.0"
js-cookie "^3.0.1"
xstate "^4.30.5"
"@nhost/hasura-auth-js@1.0.0":
version "1.0.0"
resolved "https://registry.yarnpkg.com/@nhost/hasura-auth-js/-/hasura-auth-js-1.0.0.tgz#0f3c267614ca328c944797f33a1921c8103dd3e5"
integrity sha512-hENPB1aMdekYxfDejthPAdoj9JarqaVkBKNRa+jun247Un1X6eFGDPo52Y2tZfP44pJEUK4EqTqkWH3DwT4uXg==
"@nhost/hasura-auth-js@^1.0.9":
version "1.0.9"
resolved "https://registry.yarnpkg.com/@nhost/hasura-auth-js/-/hasura-auth-js-1.0.9.tgz#7e5cfe7a59b18778352dd6d2bef368c765ce9886"
integrity sha512-d0UDfakzUO9N0/4RRy9NptoOLgpcRmr2F5XxVVzqLYX67+XzZoqT+LMhOF8spKP4+JqFlKFgqbNulmuRRc5FfA==
dependencies:
"@nhost/core" "0.3.0"
"@nhost/core" "^0.3.8"
"@nhost/hasura-storage-js@0.2.0":
"@nhost/hasura-storage-js@^0.2.0":
version "0.2.0"
resolved "https://registry.yarnpkg.com/@nhost/hasura-storage-js/-/hasura-storage-js-0.2.0.tgz#e8c127d883d231313cd262553732da3b0dccb858"
integrity sha512-JumgUhnScU6Bv8SBmN2F4sY+LbrD3i25Ppr30Zjbv4MvbUguBclx9zzAwqub/P2n/azc7bjjRvYl2n2/jjKRXw==
dependencies:
axios "^0.21.1"
"@nhost/nhost-js@1.0.0":
version "1.0.0"
resolved "https://registry.yarnpkg.com/@nhost/nhost-js/-/nhost-js-1.0.0.tgz#d57aa66c889922926b9bde6278d35000729f884c"
integrity sha512-ve5+TqYGcQbRwDqxVDMCJKZQlj5BFCsTzqEhIAUnLP6Gu8YlNVeUQL3Bbc19j71OkHDNhw8TAJbE2zcFUBT2Fw==
"@nhost/nhost-js@^1.0.9":
version "1.0.9"
resolved "https://registry.yarnpkg.com/@nhost/nhost-js/-/nhost-js-1.0.9.tgz#a1b0bc0c35e15ade2867da4d211b1f81f3bc5e28"
integrity sha512-/SZLk3Be560scVAbUswcRSE4RMwf6M7xanbNLqGUuI/sr1Ir253WPhaD2YWXZChP1v2LBzONhdJNI2g7u1NzoA==
dependencies:
"@nhost/hasura-auth-js" "1.0.0"
"@nhost/hasura-storage-js" "0.2.0"
"@nhost/hasura-auth-js" "^1.0.9"
"@nhost/hasura-storage-js" "^0.2.0"
axios "^0.23.0"
jwt-decode "^3.1.2"
query-string "^7.0.1"
"@nhost/react-apollo@^4.0.0":
version "4.0.0"
resolved "https://registry.yarnpkg.com/@nhost/react-apollo/-/react-apollo-4.0.0.tgz#08be35946eadbb746f27435c3fc72cd092a97b61"
integrity sha512-ZmFgBgHFJE2Z2ZBYx3U4Gry9TprUOb4NXw/K5lSKv11zPeEaclfpqn+aeQbtCj02oCnzRe+MJLsJenpcuhQRuw==
"@nhost/react-apollo@^4.0.10":
version "4.0.10"
resolved "https://registry.yarnpkg.com/@nhost/react-apollo/-/react-apollo-4.0.10.tgz#d28819019f35aff7fb69a3b485489ab0492643e1"
integrity sha512-MTIBk9aQVCIfVR17eEKM6ssELadpDhIAh2ERjaZY8+i9KMgVyjEt0s4842nl1Bwq7OFIXf5GRykr3RtTjuT/Ug==
dependencies:
"@nhost/apollo" "0.3.0"
"@nhost/apollo" "^0.3.7"
"@nhost/react@^0.3.0":
version "0.3.0"
resolved "https://registry.yarnpkg.com/@nhost/react/-/react-0.3.0.tgz#5401922dce91bb66db5d575de1869df00fabbb8e"
integrity sha512-jxyt4dYfphgv3bf6jvV7qDKnV5qUArFvdTYExKlBA9tsBQYta0heawMsJk0rEarEZGUw1iioiUYFKdZyl2Qi5Q==
"@nhost/react@^0.5.0":
version "0.5.0"
resolved "https://registry.yarnpkg.com/@nhost/react/-/react-0.5.0.tgz#5276ae7e13691f32ceaa0e6ca2460ef2605820f6"
integrity sha512-d89I3Q1Y6+9QJ6jP9yU9xrEJv8dCvTwll7tctd7emqZyPWGgInLpmZ9OA+/xrannowck5MsgaBdz0zxQ9bjJBA==
dependencies:
"@nhost/nhost-js" "1.0.0"
"@nhost/nhost-js" "^1.0.9"
"@xstate/react" "^2.0.1"
immer "^9.0.12"
"@rollup/pluginutils@^4.1.2":
"@rollup/pluginutils@^4.2.0":
version "4.2.0"
resolved "https://registry.yarnpkg.com/@rollup/pluginutils/-/pluginutils-4.2.0.tgz#a14bbd058fdbba0a5647143b16ed0d86fb60bd08"
integrity sha512-2WUyJNRkyH5p487pGnn4tWAsxhEFKN/pT8CMgHshd5H+IXkOnKvKZwsz5ZWz+YCXkleZRAU5kwbfgF8CPfDRqA==
@@ -394,7 +394,7 @@
resolved "https://registry.yarnpkg.com/@types/prop-types/-/prop-types-15.7.4.tgz#fcf7205c25dff795ee79af1e30da2c9790808f11"
integrity sha512-rZ5drC/jWjrArrS8BR6SIr4cWpW09RNTYt9AMZo3Jwwif+iacXAqgVjm0B0Bv/S1jhDXKHqRVNCbACkJ89RAnQ==
"@types/react-dom@^17.0.11":
"@types/react-dom@^17.0.14":
version "17.0.14"
resolved "https://registry.yarnpkg.com/@types/react-dom/-/react-dom-17.0.14.tgz#c8f917156b652ddf807711f5becbd2ab018dea9f"
integrity sha512-H03xwEP1oXmSfl3iobtmQ/2dHF5aBHr8aUMwyGZya6OW45G+xtdzmq6HkncefiBt5JU8DVyaWl/nWZbjZCnzAQ==
@@ -409,7 +409,7 @@
"@types/prop-types" "*"
"@types/react" "*"
"@types/react@*", "@types/react@^17.0.39":
"@types/react@*", "@types/react@^17.0.43":
version "17.0.43"
resolved "https://registry.yarnpkg.com/@types/react/-/react-17.0.43.tgz#4adc142887dd4a2601ce730bc56c3436fdb07a55"
integrity sha512-8Q+LNpdxf057brvPu1lMtC5Vn7J119xrP1aq4qiaefNioQUYANF/CYeK4NsKorSZyUGJ66g0IM+4bbjwx45o2A==
@@ -423,17 +423,17 @@
resolved "https://registry.yarnpkg.com/@types/scheduler/-/scheduler-0.16.2.tgz#1a62f89525723dde24ba1b01b092bf5df8ad4d39"
integrity sha512-hppQEBDmlwhFAXKJX2KnWLYu5yMfi91yazPb2l+lbJiwW+wdo1gNeRA+3RgNSO39WYX2euey41KEwnqesU2Jew==
"@vitejs/plugin-react@^1.2.0":
version "1.2.0"
resolved "https://registry.yarnpkg.com/@vitejs/plugin-react/-/plugin-react-1.2.0.tgz#4cfb4c0475e93885e56d66ff15e12ef4c34b0af0"
integrity sha512-Rywwt0IXXg6yQ0hv3cMT3mtdDcGIw31mGaa+MMMAT651LhoXLF2yFy4LrakiTs7UKs7RPBo9eNgaS8pgl2A6Qw==
"@vitejs/plugin-react@^1.3.0":
version "1.3.0"
resolved "https://registry.yarnpkg.com/@vitejs/plugin-react/-/plugin-react-1.3.0.tgz#efd4b4383edc12780cd8d230c2daa9d266690bb9"
integrity sha512-H+yIupjUE4a+E4oeWUv4xUJIMR0DWBIMUG/DYgvj0J9Vu1rdHAlJ5JdbI+N1KDUD7Ee2fZ1DMPZ/NBg6mXtoCw==
dependencies:
"@babel/core" "^7.16.12"
"@babel/plugin-transform-react-jsx" "^7.16.7"
"@babel/core" "^7.17.8"
"@babel/plugin-transform-react-jsx" "^7.17.3"
"@babel/plugin-transform-react-jsx-development" "^7.16.7"
"@babel/plugin-transform-react-jsx-self" "^7.16.7"
"@babel/plugin-transform-react-jsx-source" "^7.16.7"
"@rollup/pluginutils" "^4.1.2"
"@rollup/pluginutils" "^4.2.0"
react-refresh "^0.11.0"
resolve "^1.22.0"
@@ -458,13 +458,6 @@
dependencies:
tslib "^2.3.0"
"@xstate/inspect@^0.6.2":
version "0.6.4"
resolved "https://registry.yarnpkg.com/@xstate/inspect/-/inspect-0.6.4.tgz#dd12abb30375dcb0471b81e8db3b81377cd00be6"
integrity sha512-2Gz5wu/RdpeLEpQ93qWQe/lDybJHQq8NzgWyB/EmDUBhOggCeZu4JqJCT7/RsQ7FNSEenZILFbNTftOY00Kg4A==
dependencies:
fast-safe-stringify "^2.0.7"
"@xstate/react@^2.0.1":
version "2.0.1"
resolved "https://registry.yarnpkg.com/@xstate/react/-/react-2.0.1.tgz#2b4717369d419e78a6c67f2dfcd1a3be9abce2d9"
@@ -682,131 +675,131 @@ errno@^0.1.1:
dependencies:
prr "~1.0.1"
esbuild-android-64@0.14.27:
version "0.14.27"
resolved "https://registry.yarnpkg.com/esbuild-android-64/-/esbuild-android-64-0.14.27.tgz#b868bbd9955a92309c69df628d8dd1945478b45c"
integrity sha512-LuEd4uPuj/16Y8j6kqy3Z2E9vNY9logfq8Tq+oTE2PZVuNs3M1kj5Qd4O95ee66yDGb3isaOCV7sOLDwtMfGaQ==
esbuild-android-64@0.14.32:
version "0.14.32"
resolved "https://registry.yarnpkg.com/esbuild-android-64/-/esbuild-android-64-0.14.32.tgz#cf23a9c6052bb48901f5541c7e5a4168495fca36"
integrity sha512-q1qjB2UcoWehR9Yp9dO2RdJUeLLrXAYsbOU4tkYa+GmJzxTwuvOrMdvaemsXYqb7F4STVTca9KpfqGicEChtUg==
esbuild-android-arm64@0.14.27:
version "0.14.27"
resolved "https://registry.yarnpkg.com/esbuild-android-arm64/-/esbuild-android-arm64-0.14.27.tgz#e7d6430555e8e9c505fd87266bbc709f25f1825c"
integrity sha512-E8Ktwwa6vX8q7QeJmg8yepBYXaee50OdQS3BFtEHKrzbV45H4foMOeEE7uqdjGQZFBap5VAqo7pvjlyA92wznQ==
esbuild-android-arm64@0.14.32:
version "0.14.32"
resolved "https://registry.yarnpkg.com/esbuild-android-arm64/-/esbuild-android-arm64-0.14.32.tgz#5840407c8d8b577eea847eecce8df9610c0f58fd"
integrity sha512-bs1uu+RuM15f8yjFc0FhPDE/6NID4fKl7beDVsGCme6Q8ld2IzRXmp5QaHurlcH93PFyQnUgVvdahIWgtK2QZw==
esbuild-darwin-64@0.14.27:
version "0.14.27"
resolved "https://registry.yarnpkg.com/esbuild-darwin-64/-/esbuild-darwin-64-0.14.27.tgz#4dc7484127564e89b4445c0a560a3cb50b3d68e1"
integrity sha512-czw/kXl/1ZdenPWfw9jDc5iuIYxqUxgQ/Q+hRd4/3udyGGVI31r29LCViN2bAJgGvQkqyLGVcG03PJPEXQ5i2g==
esbuild-darwin-64@0.14.32:
version "0.14.32"
resolved "https://registry.yarnpkg.com/esbuild-darwin-64/-/esbuild-darwin-64-0.14.32.tgz#c6defc12a60f27408f1a30bb233c9d0e66ea2a55"
integrity sha512-6MekflAld28wYtzanwZTxQlxMPeYw/yv1ToFG2hpo3LGxOIE2mBD5IJaMCcyy1//EYvGnGToO3p6XKdbS8E1QQ==
esbuild-darwin-arm64@0.14.27:
version "0.14.27"
resolved "https://registry.yarnpkg.com/esbuild-darwin-arm64/-/esbuild-darwin-arm64-0.14.27.tgz#469e59c665f84a8ed323166624c5e7b9b2d22ac1"
integrity sha512-BEsv2U2U4o672oV8+xpXNxN9bgqRCtddQC6WBh4YhXKDcSZcdNh7+6nS+DM2vu7qWIWNA4JbRG24LUUYXysimQ==
esbuild-darwin-arm64@0.14.32:
version "0.14.32"
resolved "https://registry.yarnpkg.com/esbuild-darwin-arm64/-/esbuild-darwin-arm64-0.14.32.tgz#fc878496516a90fc4982ee7cf8f2d2f484dbd64a"
integrity sha512-BHYIjiPDYQTD+4zwqdqRo+I2bbg3fn9mah/gZm4SCCy+7uwTTYOYobIunHT7wVCgxnFCr50PJUdaMrEoCImRbw==
esbuild-freebsd-64@0.14.27:
version "0.14.27"
resolved "https://registry.yarnpkg.com/esbuild-freebsd-64/-/esbuild-freebsd-64-0.14.27.tgz#895df03bf5f87094a56c9a5815bf92e591903d70"
integrity sha512-7FeiFPGBo+ga+kOkDxtPmdPZdayrSzsV9pmfHxcyLKxu+3oTcajeZlOO1y9HW+t5aFZPiv7czOHM4KNd0tNwCA==
esbuild-freebsd-64@0.14.32:
version "0.14.32"
resolved "https://registry.yarnpkg.com/esbuild-freebsd-64/-/esbuild-freebsd-64-0.14.32.tgz#c136e8e8bab8e7ea95a7fbe4b689d2c940bf48f2"
integrity sha512-6BOBhtfAf9AlfjL1AvtfVOxwY82tHPfYrA0lskJpFjfiEMGTLU6e0vdOwb4+4x++gGz49azuGK0woYqdfL03uw==
esbuild-freebsd-arm64@0.14.27:
version "0.14.27"
resolved "https://registry.yarnpkg.com/esbuild-freebsd-arm64/-/esbuild-freebsd-arm64-0.14.27.tgz#0b72a41a6b8655e9a8c5608f2ec1afdcf6958441"
integrity sha512-8CK3++foRZJluOWXpllG5zwAVlxtv36NpHfsbWS7TYlD8S+QruXltKlXToc/5ZNzBK++l6rvRKELu/puCLc7jA==
esbuild-freebsd-arm64@0.14.32:
version "0.14.32"
resolved "https://registry.yarnpkg.com/esbuild-freebsd-arm64/-/esbuild-freebsd-arm64-0.14.32.tgz#46668a10e5a51665ed800b10a02b757bf6bc6fbf"
integrity sha512-zIRR4gKQW56p/xLM8TlpxVBNiX0w3VoR9ZxfH4nrfJ7QiL0SYHRy8YPL5C7zMWRjSze2WxQRHfS9bHKdVrVXBw==
esbuild-linux-32@0.14.27:
version "0.14.27"
resolved "https://registry.yarnpkg.com/esbuild-linux-32/-/esbuild-linux-32-0.14.27.tgz#43b8ba3803b0bbe7f051869c6a8bf6de1e95de28"
integrity sha512-qhNYIcT+EsYSBClZ5QhLzFzV5iVsP1YsITqblSaztr3+ZJUI+GoK8aXHyzKd7/CKKuK93cxEMJPpfi1dfsOfdw==
esbuild-linux-32@0.14.32:
version "0.14.32"
resolved "https://registry.yarnpkg.com/esbuild-linux-32/-/esbuild-linux-32-0.14.32.tgz#ac51a64f26f638618ff62a1a966babe065bc54cc"
integrity sha512-kn0AkGtPvzA6xiv93/mavvZ7DVinu/ewh2F2S0/8mE8/PXi3D4+svZ6V3beV5DIH7vcHVuGhoooWav8HPF04tg==
esbuild-linux-64@0.14.27:
version "0.14.27"
resolved "https://registry.yarnpkg.com/esbuild-linux-64/-/esbuild-linux-64-0.14.27.tgz#dc8072097327ecfadba1735562824ce8c05dd0bd"
integrity sha512-ESjck9+EsHoTaKWlFKJpPZRN26uiav5gkI16RuI8WBxUdLrrAlYuYSndxxKgEn1csd968BX/8yQZATYf/9+/qg==
esbuild-linux-64@0.14.32:
version "0.14.32"
resolved "https://registry.yarnpkg.com/esbuild-linux-64/-/esbuild-linux-64-0.14.32.tgz#a3dfeb772f339fb34f0ff61df753a70a01be243a"
integrity sha512-Ie+PMvrPj/HCOmSc0QubKttDxP2iBtPzDu+b+V3HGDGwkGmVpDkyXx1NXp5LjkIphIay2QekMwy1dSw3KDqCew==
esbuild-linux-arm64@0.14.27:
version "0.14.27"
resolved "https://registry.yarnpkg.com/esbuild-linux-arm64/-/esbuild-linux-arm64-0.14.27.tgz#c52b58cbe948426b1559910f521b0a3f396f10b8"
integrity sha512-no6Mi17eV2tHlJnqBHRLekpZ2/VYx+NfGxKcBE/2xOMYwctsanCaXxw4zapvNrGE9X38vefVXLz6YCF8b1EHiQ==
esbuild-linux-arm64@0.14.32:
version "0.14.32"
resolved "https://registry.yarnpkg.com/esbuild-linux-arm64/-/esbuild-linux-arm64-0.14.32.tgz#df2fead5c0d9228eede866359f35b3e0eef4e192"
integrity sha512-ykoqKaxX95nB+lk2K/+qxr0ke+BxkeVi0yKOnymCR5Ive7IZDHa4BJX53NEGSBKLfWPwKE6SXTz8qcEewSntoA==
esbuild-linux-arm@0.14.27:
version "0.14.27"
resolved "https://registry.yarnpkg.com/esbuild-linux-arm/-/esbuild-linux-arm-0.14.27.tgz#df869dbd67d4ee3a04b3c7273b6bd2b233e78a18"
integrity sha512-JnnmgUBdqLQO9hoNZQqNHFWlNpSX82vzB3rYuCJMhtkuaWQEmQz6Lec1UIxJdC38ifEghNTBsF9bbe8dFilnCw==
esbuild-linux-arm@0.14.32:
version "0.14.32"
resolved "https://registry.yarnpkg.com/esbuild-linux-arm/-/esbuild-linux-arm-0.14.32.tgz#64633aa6491e91d935324cf041795ebce18c071b"
integrity sha512-R/Bvn/YQNDyvfN0SERh/I7hKPqN+nSSruQdVeiYEJ+jc3fUi73jXYAscpTQgIBeER/yXnEsgJGU/UQ9+sscr7A==
esbuild-linux-mips64le@0.14.27:
version "0.14.27"
resolved "https://registry.yarnpkg.com/esbuild-linux-mips64le/-/esbuild-linux-mips64le-0.14.27.tgz#a2b646d9df368b01aa970a7b8968be6dd6b01d19"
integrity sha512-NolWP2uOvIJpbwpsDbwfeExZOY1bZNlWE/kVfkzLMsSgqeVcl5YMen/cedRe9mKnpfLli+i0uSp7N+fkKNU27A==
esbuild-linux-mips64le@0.14.32:
version "0.14.32"
resolved "https://registry.yarnpkg.com/esbuild-linux-mips64le/-/esbuild-linux-mips64le-0.14.32.tgz#f0a7a083e8fdfb6e4edffb93ec27de2c5d732f01"
integrity sha512-IilnlBexpHpt/5po0cle/L/S6CYnwaq23UuAqWzxp+opHLOCNnyANpC1jOoP551aRx4JuZ7z3xZZ7bYQZB147w==
esbuild-linux-ppc64le@0.14.27:
version "0.14.27"
resolved "https://registry.yarnpkg.com/esbuild-linux-ppc64le/-/esbuild-linux-ppc64le-0.14.27.tgz#9a21af766a0292578a3009c7408b8509cac7cefd"
integrity sha512-/7dTjDvXMdRKmsSxKXeWyonuGgblnYDn0MI1xDC7J1VQXny8k1qgNp6VmrlsawwnsymSUUiThhkJsI+rx0taNA==
esbuild-linux-ppc64le@0.14.32:
version "0.14.32"
resolved "https://registry.yarnpkg.com/esbuild-linux-ppc64le/-/esbuild-linux-ppc64le-0.14.32.tgz#dc22b766dd4ddd20c28febe36e8b92b9c11faa63"
integrity sha512-TR6l5nWZbfq7jSY+1vsiQjT4m67NWplNhbX6GBieZq6DBt0nTx1XgTZAdKROF7jTuaK7YrCYlPXtfO3w86Mysw==
esbuild-linux-riscv64@0.14.27:
version "0.14.27"
resolved "https://registry.yarnpkg.com/esbuild-linux-riscv64/-/esbuild-linux-riscv64-0.14.27.tgz#344a27f91568056a5903ad5841b447e00e78d740"
integrity sha512-D+aFiUzOJG13RhrSmZgrcFaF4UUHpqj7XSKrIiCXIj1dkIkFqdrmqMSOtSs78dOtObWiOrFCDDzB24UyeEiNGg==
esbuild-linux-riscv64@0.14.32:
version "0.14.32"
resolved "https://registry.yarnpkg.com/esbuild-linux-riscv64/-/esbuild-linux-riscv64-0.14.32.tgz#0ae09eee847de5993cbe1529591d5ca17c7303c5"
integrity sha512-aSOcUzTeIAslfri8e+bMpyzQuxhcIiNhWyuCGGXum2PtxwYiUqR8/UCMYfwYtYkhr1yABOFOfs83mm9KBy5qCQ==
esbuild-linux-s390x@0.14.27:
version "0.14.27"
resolved "https://registry.yarnpkg.com/esbuild-linux-s390x/-/esbuild-linux-s390x-0.14.27.tgz#73a7309bd648a07ef58f069658f989a5096130db"
integrity sha512-CD/D4tj0U4UQjELkdNlZhQ8nDHU5rBn6NGp47Hiz0Y7/akAY5i0oGadhEIg0WCY/HYVXFb3CsSPPwaKcTOW3bg==
esbuild-linux-s390x@0.14.32:
version "0.14.32"
resolved "https://registry.yarnpkg.com/esbuild-linux-s390x/-/esbuild-linux-s390x-0.14.32.tgz#1297f9f130cd93495e7ce25c63a79dab223b89de"
integrity sha512-dNlip+EvexxKjRZitFCWCd7DVk64c7R5ySr8aFEMHCb/RriNiyDxYJGzYWm4EMJsMRMupMUHlMY64BAa3Op9FA==
esbuild-netbsd-64@0.14.27:
version "0.14.27"
resolved "https://registry.yarnpkg.com/esbuild-netbsd-64/-/esbuild-netbsd-64-0.14.27.tgz#482a587cdbd18a6c264a05136596927deb46c30a"
integrity sha512-h3mAld69SrO1VoaMpYl3a5FNdGRE/Nqc+E8VtHOag4tyBwhCQXxtvDDOAKOUQexBGca0IuR6UayQ4ntSX5ij1Q==
esbuild-netbsd-64@0.14.32:
version "0.14.32"
resolved "https://registry.yarnpkg.com/esbuild-netbsd-64/-/esbuild-netbsd-64-0.14.32.tgz#902bf5ba7c54db9c7274f019c4d006b1b963fb7d"
integrity sha512-Pa3QByYqxzlBFQQQhjYBPg3WUfSjwibqzh1hC6mPDRUHnCeUcrLoBuIiG4xqOYEpQM9/kDowIBsrGIQEVWWdQA==
esbuild-openbsd-64@0.14.27:
version "0.14.27"
resolved "https://registry.yarnpkg.com/esbuild-openbsd-64/-/esbuild-openbsd-64-0.14.27.tgz#e99f8cdc63f1628747b63edd124d53cf7796468d"
integrity sha512-xwSje6qIZaDHXWoPpIgvL+7fC6WeubHHv18tusLYMwL+Z6bEa4Pbfs5IWDtQdHkArtfxEkIZz77944z8MgDxGw==
esbuild-openbsd-64@0.14.32:
version "0.14.32"
resolved "https://registry.yarnpkg.com/esbuild-openbsd-64/-/esbuild-openbsd-64-0.14.32.tgz#0fbfbdf555deeb05a8915daf0b71168d09773437"
integrity sha512-uWKKqpCjkMY8TCIobFvaSETonQY3OrmgnoTCC3tF+lvMoneYjppB6akx7L5Xv0kP+1tnSbrIof1ca8PfqGUyjw==
esbuild-sunos-64@0.14.27:
version "0.14.27"
resolved "https://registry.yarnpkg.com/esbuild-sunos-64/-/esbuild-sunos-64-0.14.27.tgz#8611d825bcb8239c78d57452e83253a71942f45c"
integrity sha512-/nBVpWIDjYiyMhuqIqbXXsxBc58cBVH9uztAOIfWShStxq9BNBik92oPQPJ57nzWXRNKQUEFWr4Q98utDWz7jg==
esbuild-sunos-64@0.14.32:
version "0.14.32"
resolved "https://registry.yarnpkg.com/esbuild-sunos-64/-/esbuild-sunos-64-0.14.32.tgz#d493ca5222703dd0b8c489324d1517cd622618e8"
integrity sha512-Ar+u3mBk0oVV4Fwv/qlinJZNIPPtTBSG+1W42o8lOaVxJ+rJgecDoeUN+5uyd9at0BK1SVrQ1qZ4wjHKB0qFpQ==
esbuild-windows-32@0.14.27:
version "0.14.27"
resolved "https://registry.yarnpkg.com/esbuild-windows-32/-/esbuild-windows-32-0.14.27.tgz#c06374206d4d92dd31d4fda299b09f51a35e82f6"
integrity sha512-Q9/zEjhZJ4trtWhFWIZvS/7RUzzi8rvkoaS9oiizkHTTKd8UxFwn/Mm2OywsAfYymgUYm8+y2b+BKTNEFxUekw==
esbuild-windows-32@0.14.32:
version "0.14.32"
resolved "https://registry.yarnpkg.com/esbuild-windows-32/-/esbuild-windows-32-0.14.32.tgz#c6b0f4cf952c6f562a32fe763acab9fb8cb3912a"
integrity sha512-rLMsbflMY6Hjh3rmQnCDVZahJQ7n+XfT6o1+no5pHRpDlMh38MHthgGh35q+EcOMgrGP3ppnw70rhJq80SaYTQ==
esbuild-windows-64@0.14.27:
version "0.14.27"
resolved "https://registry.yarnpkg.com/esbuild-windows-64/-/esbuild-windows-64-0.14.27.tgz#756631c1d301dfc0d1a887deed2459ce4079582f"
integrity sha512-b3y3vTSl5aEhWHK66ngtiS/c6byLf6y/ZBvODH1YkBM+MGtVL6jN38FdHUsZasCz9gFwYs/lJMVY9u7GL6wfYg==
esbuild-windows-64@0.14.32:
version "0.14.32"
resolved "https://registry.yarnpkg.com/esbuild-windows-64/-/esbuild-windows-64-0.14.32.tgz#2ad9322a963fd26bb4818ad1c0ee7acde63ebb81"
integrity sha512-OHnMMxYufVgLXIMnwLynLMKguHMrsVnWcehieSP9i6ZX31KEsOFYWrorcnTWOn4rbZVLSL10ofxLuVIgRW3SWw==
esbuild-windows-arm64@0.14.27:
version "0.14.27"
resolved "https://registry.yarnpkg.com/esbuild-windows-arm64/-/esbuild-windows-arm64-0.14.27.tgz#ad7e187193dcd18768b16065a950f4441d7173f4"
integrity sha512-I/reTxr6TFMcR5qbIkwRGvldMIaiBu2+MP0LlD7sOlNXrfqIl9uNjsuxFPGEG4IRomjfQ5q8WT+xlF/ySVkqKg==
esbuild-windows-arm64@0.14.32:
version "0.14.32"
resolved "https://registry.yarnpkg.com/esbuild-windows-arm64/-/esbuild-windows-arm64-0.14.32.tgz#bb589106c0fd5d582cce62bd7995a6e5db52e7b4"
integrity sha512-ddavy6IPUBySMfqDfG243TgtuqwQBNJQJPVaA4DaavmMfpBsUxFrSV+HzBWXTKU3I9EcuoEvIATLuQ7NJKxjwg==
esbuild@^0.14.14:
version "0.14.27"
resolved "https://registry.yarnpkg.com/esbuild/-/esbuild-0.14.27.tgz#41fe0f1b6b68b9f77cac025009bc54bb96e616f1"
integrity sha512-MZQt5SywZS3hA9fXnMhR22dv0oPGh6QtjJRIYbgL1AeqAoQZE+Qn5ppGYQAoHv/vq827flj4tIJ79Mrdiwk46Q==
esbuild@^0.14.27:
version "0.14.32"
resolved "https://registry.yarnpkg.com/esbuild/-/esbuild-0.14.32.tgz#f55245ccd4b820707147ac4cc69a2c3e1a76af03"
integrity sha512-RuzVUP/bkStmnVHK6Gh3gjaMjfXNLqBqvYVDiS9JKl5KdRdRLUeW5Wo8NrbL7cL6CW7Cyak7SvACqyPOBuA8vA==
optionalDependencies:
esbuild-android-64 "0.14.27"
esbuild-android-arm64 "0.14.27"
esbuild-darwin-64 "0.14.27"
esbuild-darwin-arm64 "0.14.27"
esbuild-freebsd-64 "0.14.27"
esbuild-freebsd-arm64 "0.14.27"
esbuild-linux-32 "0.14.27"
esbuild-linux-64 "0.14.27"
esbuild-linux-arm "0.14.27"
esbuild-linux-arm64 "0.14.27"
esbuild-linux-mips64le "0.14.27"
esbuild-linux-ppc64le "0.14.27"
esbuild-linux-riscv64 "0.14.27"
esbuild-linux-s390x "0.14.27"
esbuild-netbsd-64 "0.14.27"
esbuild-openbsd-64 "0.14.27"
esbuild-sunos-64 "0.14.27"
esbuild-windows-32 "0.14.27"
esbuild-windows-64 "0.14.27"
esbuild-windows-arm64 "0.14.27"
esbuild-android-64 "0.14.32"
esbuild-android-arm64 "0.14.32"
esbuild-darwin-64 "0.14.32"
esbuild-darwin-arm64 "0.14.32"
esbuild-freebsd-64 "0.14.32"
esbuild-freebsd-arm64 "0.14.32"
esbuild-linux-32 "0.14.32"
esbuild-linux-64 "0.14.32"
esbuild-linux-arm "0.14.32"
esbuild-linux-arm64 "0.14.32"
esbuild-linux-mips64le "0.14.32"
esbuild-linux-ppc64le "0.14.32"
esbuild-linux-riscv64 "0.14.32"
esbuild-linux-s390x "0.14.32"
esbuild-netbsd-64 "0.14.32"
esbuild-openbsd-64 "0.14.32"
esbuild-sunos-64 "0.14.32"
esbuild-windows-32 "0.14.32"
esbuild-windows-64 "0.14.32"
esbuild-windows-arm64 "0.14.32"
escalade@^3.1.1:
version "3.1.1"
@@ -833,11 +826,6 @@ eventemitter3@^4.0.4:
resolved "https://registry.yarnpkg.com/eventemitter3/-/eventemitter3-4.0.7.tgz#2de9b68f6528d5644ef5c59526a1b4a07306169f"
integrity sha512-8guHBZCwKnFhYdHr2ysuRWErTwhoN2X8XELRlrRwpmfeY2jjuUN4taQMsULKUVo1K4DvZl+0pgfyoysHxvmvEw==
fast-safe-stringify@^2.0.7:
version "2.1.1"
resolved "https://registry.yarnpkg.com/fast-safe-stringify/-/fast-safe-stringify-2.1.1.tgz#c406a83b6e70d9e35ce3b30a81141df30aeba884"
integrity sha512-W+KJc2dmILlPplD/H4K9l9LcAHAfPtP6BY84uVLXQ6Evcz9Lcg33Y2z1IVblT6xdY54PXYVHEv+0Wpq8Io6zkA==
fbemitter@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/fbemitter/-/fbemitter-3.0.0.tgz#00b2a1af5411254aab416cd75f9e6289bee4bff3"
@@ -930,11 +918,6 @@ graphql-tag@^2.12.3:
dependencies:
tslib "^2.1.0"
graphql@15.7.2:
version "15.7.2"
resolved "https://registry.yarnpkg.com/graphql/-/graphql-15.7.2.tgz#85ab0eeb83722977151b3feb4d631b5f2ab287ef"
integrity sha512-AnnKk7hFQFmU/2I9YSQf3xw44ctnSFCfp3zE0N6W174gqe9fWG/2rKaKxROK7CcI3XtERpjEKFqts8o319Kf7A==
graphql@16:
version "16.3.0"
resolved "https://registry.yarnpkg.com/graphql/-/graphql-16.3.0.tgz#a91e24d10babf9e60c706919bb182b53ccdffc05"
@@ -1225,7 +1208,7 @@ pify@^4.0.1:
resolved "https://registry.yarnpkg.com/pify/-/pify-4.0.1.tgz#4b2cd25c50d598735c50292224fd8c6df41e3231"
integrity sha512-uB80kBFb/tfd68bVleG9T5GGsGPjJrLAUpR5PZIrhBnIaRTQRjqdJSsIKkOP6OAIFbj7GOrcudc5pNjZ+geV2g==
postcss@^8.4.6:
postcss@^8.4.12:
version "8.4.12"
resolved "https://registry.yarnpkg.com/postcss/-/postcss-8.4.12.tgz#1e7de78733b28970fa4743f7da6f3763648b1905"
integrity sha512-lg6eITwYe9v6Hr5CncVbK70SoioNQIq81nsaG86ev5hAidQvmOeETBqs7jm43K2F5/Ley3ytDtriImV6TpNiSg==
@@ -1324,18 +1307,18 @@ react-refresh@^0.11.0:
resolved "https://registry.yarnpkg.com/react-refresh/-/react-refresh-0.11.0.tgz#77198b944733f0f1f1a90e791de4541f9f074046"
integrity sha512-F27qZr8uUqwhWZboondsPx8tnC3Ct3SxZA3V5WyEvujRyyNv0VYPhoBg1gZ8/MV5tubQp76Trw8lTv9hzRBa+A==
react-router-dom@^6.2.1:
version "6.2.2"
resolved "https://registry.yarnpkg.com/react-router-dom/-/react-router-dom-6.2.2.tgz#f1a2c88365593c76b9612ae80154a13fcb72e442"
integrity sha512-AtYEsAST7bDD4dLSQHDnk/qxWLJdad5t1HFa1qJyUrCeGgEuCSw0VB/27ARbF9Fi/W5598ujvJOm3ujUCVzuYQ==
react-router-dom@^6.3.0:
version "6.3.0"
resolved "https://registry.yarnpkg.com/react-router-dom/-/react-router-dom-6.3.0.tgz#a0216da813454e521905b5fa55e0e5176123f43d"
integrity sha512-uaJj7LKytRxZNQV8+RbzJWnJ8K2nPsOOEuX7aQstlMZKQT0164C+X2w6bnkqU3sjtLvpd5ojrezAyfZ1+0sStw==
dependencies:
history "^5.2.0"
react-router "6.2.2"
react-router "6.3.0"
react-router@6.2.2:
version "6.2.2"
resolved "https://registry.yarnpkg.com/react-router/-/react-router-6.2.2.tgz#495e683a0c04461eeb3d705fe445d6cf42f0c249"
integrity sha512-/MbxyLzd7Q7amp4gDOGaYvXwhEojkJD5BtExkuKmj39VEE0m3l/zipf6h2WIB2jyAO0lI6NGETh4RDcktRm4AQ==
react-router@6.3.0, react-router@^6.3.0:
version "6.3.0"
resolved "https://registry.yarnpkg.com/react-router/-/react-router-6.3.0.tgz#3970cc64b4cb4eae0c1ea5203a80334fdd175557"
integrity sha512-7Wh1DzVQ+tlFjkeo+ujvjSqSJmkt1+8JO+T5xklPlgrh70y7ogx75ODRW0ThWhY7S+6yEDks8TYrtQe/aoboBQ==
dependencies:
history "^5.2.0"
@@ -1409,10 +1392,10 @@ rsuite-table@^5.3.6:
lodash "^4.17.21"
react-is "^17.0.2"
rsuite@^5.6.2:
version "5.6.6"
resolved "https://registry.yarnpkg.com/rsuite/-/rsuite-5.6.6.tgz#03b97ec32a24212aaa95e3d14e5e85db2255175a"
integrity sha512-N4xnfnOpbxkEQ4+6GP/ll76XC8motkCQUNy1WL5wayZGgmOjzbVLbOUUHn9iGN32sBLyH8/d3Lo/WxfAjprj3g==
rsuite@^5.7.1:
version "5.7.1"
resolved "https://registry.yarnpkg.com/rsuite/-/rsuite-5.7.1.tgz#2c50161e568cbf0074b42e7b65592b25a3b9412d"
integrity sha512-vvqBadf9vJ49CW4gboFpj+Ol7M5sK7a72irwQxgxBxHBD2YEWUx9LQp137RIJV6w/nXg1P5yaObZULb5n77QoA==
dependencies:
"@babel/runtime" "^7.8.4"
"@juggle/resize-observer" "^3.3.1"
@@ -1555,7 +1538,7 @@ tslib@^2.1.0, tslib@^2.3.0:
resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.3.1.tgz#e8a335add5ceae51aa261d32a490158ef042ef01"
integrity sha512-77EbyPPpMz+FRFRuAFlWMtmgUWGe9UOG2Z25NqCwiIjRhOf5iKGuzSe5P2w1laq+FkRy4p+PCuVkJSGkzTEKVw==
typescript@^4.5.5:
typescript@^4.6.3:
version "4.6.3"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.6.3.tgz#eefeafa6afdd31d725584c67a0eaba80f6fc6c6c"
integrity sha512-yNIatDa5iaofVozS/uQJEl3JRWLKKGJKh6Yaiv0GLGSuhpFJe7P3SbHZ8/yjAHRQwKRoA6YZqlfjXWmVzoVSMw==
@@ -1597,13 +1580,13 @@ use-subscription@^1.3.0:
dependencies:
object-assign "^4.1.1"
vite@^2.8.5:
version "2.8.6"
resolved "https://registry.yarnpkg.com/vite/-/vite-2.8.6.tgz#32d50e23c99ca31b26b8ccdc78b1d72d4d7323d3"
integrity sha512-e4H0QpludOVKkmOsRyqQ7LTcMUDF3mcgyNU4lmi0B5JUbe0ZxeBBl8VoZ8Y6Rfn9eFKYtdXNPcYK97ZwH+K2ug==
vite@^2.9.1:
version "2.9.1"
resolved "https://registry.yarnpkg.com/vite/-/vite-2.9.1.tgz#84bce95fae210a7beb566a0af06246748066b48f"
integrity sha512-vSlsSdOYGcYEJfkQ/NeLXgnRv5zZfpAsdztkIrs7AZHV8RCMZQkwjo4DS5BnrYTqoWqLoUe1Cah4aVO4oNNqCQ==
dependencies:
esbuild "^0.14.14"
postcss "^8.4.6"
esbuild "^0.14.27"
postcss "^8.4.12"
resolve "^1.22.0"
rollup "^2.59.0"
optionalDependencies:
@@ -1632,11 +1615,6 @@ wrappy@1:
resolved "https://registry.yarnpkg.com/ws/-/ws-7.5.7.tgz#9e0ac77ee50af70d58326ecff7e85eb3fa375e67"
integrity sha512-KMvVuFzpKBuiIXW3E4u3mySRO2/mCHSyZDJQM5NQ9Q9KHWHWh0NHgfbRMLLrceUK5qAL4ytALJbpRMjixFZh8A==
ws@^8.5.0:
version "8.5.0"
resolved "https://registry.yarnpkg.com/ws/-/ws-8.5.0.tgz#bfb4be96600757fe5382de12c670dab984a1ed4f"
integrity sha512-BWX0SWVgLPzYwF8lTzEy1egjhS4S4OEAHfsO8o65WOVsrnSRGaSiUaa9e0ggGlkMTtBlmOpEXiie9RUcBO86qg==
xstate@^4.30.5:
version "4.30.6"
resolved "https://registry.yarnpkg.com/xstate/-/xstate-4.30.6.tgz#62b6dea37a500e0e1c0ff7c553a801eea5119554"

View File

@@ -28,8 +28,10 @@
"prettier:fix": "prettier --write .",
"lint": "pnpm turbo run lint --stream",
"lint:fix": "pnpm turbo run lint:fix --stream",
"prerelease": "pnpm clean && pnpm install && pnpm build",
"release": "pnpm run prerelease && changeset publish",
"snapshot": "pnpm prerelease && changeset version --snapshot preview && pnpm install && changeset publish --tag preview",
"test": "pnpm turbo run test --scope='@nhost/*' --no-deps --include-dependencies",
"ci:publish": "pnpm run build && changeset tag && git push --follow-tags && pnpm -r publish && git status",
"changeset": "changeset",
"wait": "wait-on http://localhost:1337/v1/auth/healthz -i 500 -t 120000"
},

View File

@@ -1,6 +1,21 @@
# @nhost/apollo
## 0.3.4
## 0.3.8
### Patch Changes
- Updated dependencies [2c97db6]
- @nhost/core@0.3.9
## 0.3.7
### Patch Changes
- Updated dependencies [058956b]
- Updated dependencies [7cf875f]
- @nhost/core@0.3.8
## 0.3.5
### Patch Changes
@@ -39,7 +54,6 @@
### Patch Changes
- Updated dependencies [744fd69]
- Updated dependencies [744fd69]
- @nhost/core@0.3.0

View File

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

View File

@@ -1,6 +1,27 @@
# @nhost/core
## 0.3.4
## 0.3.9
### Patch Changes
- 2c97db6: Keep authentication status and access token in sync
The authentication events where not set correctly, leading the main Nhost client not to update internal states of storage/graphql/functions sub-clients when using non-react clients.
The use of private fields (`#`) is also avoided as they conflict with the use of proxies in Vue, leading to errors in the upcoming Vue library.
Fixes #373 and #378
## 0.3.8
### Patch Changes
- 058956b: Add missing provider types
`strava`, `gitlab`, and `bitbucket` were missing from the list of providers in Typescript and are now available.
- 058956b: Add `emailVerified`, `phoneNumber`, `phoneNumberVerified`, and `activeMfaType` to User type
Some information is missing in the `User` payload (see [this issue](https://github.com/nhost/nhost/issues/306)). The above properties have been added in the Typescript `User` type and are available when using Hasura Auth versions from [this pull request](https://github.com/nhost/hasura-auth/pull/128) (tentative version number: `0.5.1`)
- 7cf875f: Export error code payloads and type
## 0.3.7
### Patch Changes

View File

@@ -1,6 +1,6 @@
{
"name": "@nhost/core",
"version": "0.3.4",
"version": "0.3.9",
"description": "Nhost core client library",
"license": "MIT",
"keywords": [

View File

@@ -12,9 +12,9 @@ export class AuthClient {
readonly backendUrl: string
readonly clientUrl: string
readonly machine: AuthMachine
#interpreter?: AuthInterpreter
#channel?: BroadcastChannel
#subscriptions: Set<(client: AuthClient) => void> = new Set()
private _interpreter?: AuthInterpreter
private _channel?: BroadcastChannel
private _subscriptions: Set<(client: AuthClient) => void> = new Set()
constructor({
backendUrl,
@@ -45,8 +45,8 @@ export class AuthClient {
}
if (typeof window !== 'undefined' && autoSignIn) {
this.#channel = new BroadcastChannel<string>('nhost')
this.#channel.addEventListener('message', (token) => {
this._channel = new BroadcastChannel<string>('nhost')
this._channel.addEventListener('message', (token) => {
const existingToken = this.interpreter?.state.context.refreshToken
if (this.interpreter && token !== existingToken) {
this.interpreter.send({ type: 'TRY_TOKEN', token })
@@ -56,16 +56,23 @@ export class AuthClient {
}
get interpreter(): AuthInterpreter | undefined {
return this.#interpreter
return this._interpreter
}
set interpreter(interpreter: AuthInterpreter | undefined) {
this.#interpreter = interpreter
this._interpreter = interpreter
if (interpreter) {
this.#subscriptions.forEach((fn) => fn(this))
this._subscriptions.forEach((fn) => fn(this))
}
}
onStart(fn: (interpreter: AuthClient) => void) {
this.#subscriptions.add(fn)
onStart(fn: (client: AuthClient) => void) {
if (this.interpreter) {
// * The interpreter is already available: we can add the listener straight ahead
fn(this)
} else {
// * The interpreter is not yet available: we add the listener to a queue that will be started when setting the interpreter
// * Note: in React, the Xstate interpreter does not start from the global state, but from the root component
this._subscriptions.add(fn)
}
}
}

View File

@@ -2,6 +2,7 @@ export type { NhostClientOptions } from './client'
export { AuthClient } from './client'
export * from './constants'
export { AuthClientSSR } from './coookie-client'
export * from './errors'
export * from './machines'
export * from './storage'
export * from './types'

View File

@@ -71,6 +71,7 @@ export const createChangeEmailMachine = ({ backendUrl, clientUrl, interpreter }:
error: (_, { data: { error } }: any) => error
}),
reportError: send((ctx) => ({ type: 'ERROR', error: ctx.error })),
// TODO change email in the main machine (context.user.email)
reportSuccess: send('SUCCESS')
},
guards: {

View File

@@ -14,7 +14,7 @@ type RegistrationOptions = {
metadata?: Record<string, unknown>
}
type RedirectOption = {
export type RedirectOption = {
redirectTo?: string
}
@@ -26,6 +26,7 @@ export type SendVerificationEmailOptions = RedirectOption
export type DeanonymizeOptions = { email?: string; password?: string } & RegistrationOptions
export type ProviderOptions = RegistrationOptions & RedirectOption
// TODO share with hasura-auth
export type User = {
id: string
createdAt: string
@@ -37,9 +38,13 @@ export type User = {
defaultRole: string
roles: string[]
metadata: Record<string, unknown>
emailVerified: boolean
phoneNumber: string | null
phoneNumberVerified: boolean
activeMfaType: 'totp' | null
}
// ! copy-paste from hasura-auth
// TODO share with hasura-auth
export type NhostSession = {
accessToken: string
accessTokenExpiresIn: number
@@ -51,6 +56,7 @@ export type Mfa = {
ticket: string
}
// TODO share with hasura-auth
export type Provider =
| 'apple'
| 'facebook'
@@ -60,3 +66,6 @@ export type Provider =
| 'spotify'
| 'twitter'
| 'windowslive'
| 'strava'
| 'gitlab'
| 'bitbucket'

View File

@@ -1,6 +1,37 @@
# @nhost/hasura-auth-js
## 1.0.5
## 1.0.10
### Patch Changes
- 2c97db6: Keep authentication status and access token in sync
The authentication events where not set correctly, leading the main Nhost client not to update internal states of storage/graphql/functions sub-clients when using non-react clients.
The use of private fields (`#`) is also avoided as they conflict with the use of proxies in Vue, leading to errors in the upcoming Vue library.
Fixes #373 and #378
- Updated dependencies [2c97db6]
- @nhost/core@0.3.9
## 1.0.9
### Patch Changes
- 058956b: Add missing provider types
`strava`, `gitlab`, and `bitbucket` were missing from the list of providers in Typescript and are now available.
- 058956b: Add `emailVerified`, `phoneNumber`, `phoneNumberVerified`, and `activeMfaType` to User type
Some information is missing in the `User` payload (see [this issue](https://github.com/nhost/nhost/issues/306)). The above properties have been added in the Typescript `User` type and are available when using Hasura Auth versions from [this pull request](https://github.com/nhost/hasura-auth/pull/128) (tentative version number: `0.5.1`)
- Updated dependencies [058956b]
- Updated dependencies [7cf875f]
- @nhost/core@0.3.8
## 1.0.8
### Patch Changes
- 6be3758: bug: Correct OAuth provider link.
## 1.0.7
### Patch Changes
@@ -62,7 +93,6 @@
2. hasura-auth validates the link, attaches the token and redirects to the frontend
3. the sdk gets the refresh token from the url
4. the sdk consumes the refresh token
- Updated dependencies [744fd69]
- Updated dependencies [744fd69]
- @nhost/core@0.3.0

View File

@@ -1,6 +1,6 @@
{
"name": "@nhost/hasura-auth-js",
"version": "1.0.5",
"version": "1.0.10",
"description": "Hasura-auth client",
"license": "MIT",
"keywords": [

View File

@@ -53,7 +53,7 @@ const EMAIL_NEEDS_VERIFICATION: ApiError = {
status: 102
}
export class HasuraAuthClient {
#client: AuthClient
private _client: AuthClient
private onTokenChangedSubscriptions: Set<AuthInterpreter> = new Set()
private onAuthStateChangedSubscriptions: Set<AuthInterpreter> = new Set()
@@ -69,7 +69,7 @@ export class HasuraAuthClient {
start = true,
Client = AuthClient
}: NhostAuthConstructorParams) {
this.#client = new Client({
this._client = new Client({
backendUrl: url,
autoRefreshToken,
autoSignIn: autoLogin,
@@ -157,8 +157,8 @@ export class HasuraAuthClient {
if ('provider' in params) {
const { provider, options } = params
const providerUrl = encodeQueryParameters(
`${this.#client.backendUrl}/v1/auth/signin/provider/${provider}`,
rewriteRedirectTo(this.#client.clientUrl, options)
`${this._client.backendUrl}/signin/provider/${provider}`,
rewriteRedirectTo(this._client.clientUrl, options)
)
if (isBrowser()) {
window.location.href = providerUrl
@@ -301,7 +301,7 @@ export class HasuraAuthClient {
*/
async resetPassword({ email, options }: ResetPasswordParams): Promise<ApiResetPasswordResponse> {
return new Promise((resolve) => {
const service = interpret(createResetPasswordMachine(this.#client))
const service = interpret(createResetPasswordMachine(this._client))
service.onTransition(({ event }) => {
if (event.type === 'ERROR') return resolve({ error: event.error })
else if (event.type === 'SUCCESS') return resolve({ error: null })
@@ -321,7 +321,7 @@ export class HasuraAuthClient {
*/
async changePassword(params: ChangePasswordParams): Promise<ApiChangePasswordResponse> {
return new Promise((resolve) => {
const service = interpret(createChangePasswordMachine(this.#client))
const service = interpret(createChangePasswordMachine(this._client))
service.onTransition(({ event }) => {
if (event.type === 'ERROR') return resolve({ error: event.error })
else if (event.type === 'SUCCESS') return resolve({ error: null })
@@ -344,7 +344,7 @@ export class HasuraAuthClient {
params: SendVerificationEmailParams
): Promise<ApiSendVerificationEmailResponse> {
return new Promise((resolve) => {
const service = interpret(createSendVerificationEmailMachine(this.#client))
const service = interpret(createSendVerificationEmailMachine(this._client))
service.onTransition(({ event }) => {
if (event.type === 'ERROR') return resolve({ error: event.error })
else if (event.type === 'SUCCESS') return resolve({ error: null })
@@ -364,7 +364,7 @@ export class HasuraAuthClient {
*/
async changeEmail({ newEmail, options }: ChangeEmailParams): Promise<ApiChangeEmailResponse> {
return new Promise((resolve) => {
const service = interpret(createChangeEmailMachine(this.#client))
const service = interpret(createChangeEmailMachine(this._client))
service.onTransition(({ event }) => {
if (event.type === 'ERROR') return resolve({ error: event.error })
else if (event.type === 'SUCCESS') return resolve({ error: null })
@@ -414,9 +414,9 @@ export class HasuraAuthClient {
* @docs https://docs.nhost.io/TODO
*/
onTokenChanged(fn: OnTokenChangedFunction): Function {
if (this.#client.interpreter)
if (this._client.interpreter)
this.onTokenChangedSubscriptions.add(
this.#client.interpreter?.onTransition(({ event, context }) => {
this._client.interpreter?.onTransition(({ event, context }) => {
if (event.type === 'TOKEN_CHANGED') fn(getSession(context))
})
)
@@ -441,9 +441,9 @@ export class HasuraAuthClient {
* @docs https://docs.nhost.io/reference/sdk/authentication#nhost-auth-onauthstatechangedevent,-session
*/
onAuthStateChanged(fn: AuthChangedFunction): Function {
if (this.#client.interpreter)
if (this._client.interpreter)
this.onAuthStateChangedSubscriptions.add(
this.#client.interpreter?.onTransition(({ event, context }) => {
this._client.interpreter?.onTransition(({ event, context }) => {
if (event.type === 'SIGNED_IN') fn('SIGNED_IN', getSession(context))
else if (event.type === 'SIGNED_OUT') fn('SIGNED_OUT', getSession(context))
})
@@ -474,7 +474,7 @@ export class HasuraAuthClient {
* @docs https://docs.nhost.io/TODO
*/
isAuthenticated(): boolean {
return !!this.#client.interpreter?.state.matches({ authentication: 'signedIn' })
return !!this._client.interpreter?.state.matches({ authentication: 'signedIn' })
}
/**
@@ -543,7 +543,7 @@ export class HasuraAuthClient {
* @docs https://docs.nhost.io/TODO
*/
getAccessToken(): string | undefined {
return this.#client.interpreter?.state.context.accessToken.value ?? undefined
return this._client.interpreter?.state.context.accessToken.value ?? undefined
}
/**
@@ -590,7 +590,7 @@ export class HasuraAuthClient {
* @docs https://docs.nhost.io/TODO
*/
getSession() {
return getSession(this.#client.interpreter?.state?.context)
return getSession(this._client.interpreter?.state?.context)
}
/**
@@ -604,7 +604,7 @@ export class HasuraAuthClient {
* @docs https://docs.nhost.io/reference/sdk/authentication#nhost-auth-getuser
*/
getUser() {
return this.#client.interpreter?.state?.context?.user || null
return this._client.interpreter?.state?.context?.user || null
}
/**
@@ -613,7 +613,7 @@ export class HasuraAuthClient {
*/
private waitUntilReady(): Promise<AuthInterpreter> {
const TIMEOUT_IN_SECONS = 15
const interpreter = this.#client.interpreter
const interpreter = this._client.interpreter
if (!interpreter) {
throw Error('Auth interpreter not set')
}
@@ -633,10 +633,10 @@ export class HasuraAuthClient {
}
private isReady() {
return !!this.#client.interpreter?.state?.hasTag('ready')
return !!this._client.interpreter?.state?.hasTag('ready')
}
get client() {
return this.#client
return this._client
}
}

View File

@@ -1,5 +1,15 @@
import { AuthClient, StorageGetter, StorageSetter, User } from '@nhost/core'
import {
AuthClient,
PasswordlessOptions,
Provider,
ProviderOptions,
RedirectOption,
SignUpOptions,
StorageGetter,
StorageSetter,
User
} from '@nhost/core'
export type { AuthClient, Provider, StorageGetter, StorageSetter, User }
export interface NhostAuthConstructorParams {
url: string
refreshIntervalTime?: number
@@ -30,14 +40,7 @@ export interface ApiError {
export interface SignUpEmailPasswordParams {
email: string
password: string
options?: {
locale?: string
allowedRoles?: string[]
defaultRole?: string
displayName?: string
redirectTo?: string
metadata?: Record<string, unknown>
}
options?: SignUpOptions
}
export type SignUpParams = SignUpEmailPasswordParams
@@ -54,55 +57,21 @@ export interface SignInEmailPasswordParams {
export interface SignInPasswordlessEmailParams {
email: string
options?: {
locale?: string
allowedRoles?: string[]
defaultRole?: string
displayName?: string
redirectTo?: string
metadata?: Record<string, unknown>
}
options?: PasswordlessOptions
}
export interface SignInPasswordlessSmsParams {
phoneNumber: string
options?: {
locale?: string
allowedRoles?: string[]
defaultRole?: string
displayName?: string
redirectTo?: string
metadata?: Record<string, unknown>
}
options?: PasswordlessOptions
}
export interface SignInPasswordlessSmsOtpParams {
phoneNumber: string
otp: string
}
export type Provider =
| 'facebook'
| 'github'
| 'google'
| 'linkedin'
| 'spotify'
| 'discord'
| 'twitch'
| 'apple'
| 'twitter'
| 'windowslive'
export interface SignInWithProviderOptions {
provider: Provider
options?: {
locale?: string
allowedRoles?: string[]
defaultRole?: string
displayName?: string
redirectTo?: string
metadata?: Record<string, unknown>
}
options?: ProviderOptions
}
export type SignInParams =
@@ -125,18 +94,15 @@ export interface ChangePasswordParams {
export interface SendVerificationEmailParams {
email: string
options?: {
redirectTo?: string
}
options?: RedirectOption
}
export interface ChangeEmailParams {
newEmail: string
options?: {
redirectTo?: string
}
options?: RedirectOption
}
// TODO define type in @nhost/core
export interface DeanonymizeParams {
signInMethod: 'email-password' | 'passwordless'
email: string

View File

@@ -1,6 +1,31 @@
# @nhost/nextjs
## 1.0.6
## 1.0.11
### Patch Changes
- Updated dependencies [2c97db6]
- @nhost/nhost-js@1.0.10
- @nhost/react@0.5.1
## 1.0.10
### Patch Changes
- Updated dependencies [7cf875f]
- Updated dependencies [7135aee]
- Updated dependencies [587eaff]
- @nhost/react@0.5.0
- @nhost/nhost-js@1.0.9
## 1.0.9
### Patch Changes
- @nhost/nhost-js@1.0.8
- @nhost/react@0.4.7
## 1.0.8
### Patch Changes

View File

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

View File

@@ -1,6 +1,31 @@
# @nhost/nhost-js
## 1.0.5
## 1.0.10
### Patch Changes
- 2c97db6: Keep authentication status and access token in sync
The authentication events where not set correctly, leading the main Nhost client not to update internal states of storage/graphql/functions sub-clients when using non-react clients.
The use of private fields (`#`) is also avoided as they conflict with the use of proxies in Vue, leading to errors in the upcoming Vue library.
Fixes #373 and #378
- Updated dependencies [2c97db6]
- @nhost/hasura-auth-js@1.0.10
## 1.0.9
### Patch Changes
- Updated dependencies [058956b]
- @nhost/hasura-auth-js@1.0.9
## 1.0.8
### Patch Changes
- Updated dependencies [6be3758]
- @nhost/hasura-auth-js@1.0.8
## 1.0.7
### Patch Changes
@@ -52,8 +77,6 @@
### Patch Changes
- Updated dependencies [744fd69]
- Updated dependencies [744fd69]
- Updated dependencies [744fd69]
- @nhost/hasura-auth-js@1.0.0
- @nhost/hasura-storage-js@0.2.0
@@ -73,7 +96,6 @@
Some systems based on older versions of Webpack or Babel don't support the current esbuild configuration e.g, [this issue](https://github.com/nhost/nhost/issues/275).
- Updated dependencies [e688600]
- Updated dependencies [8f7643a]
- Updated dependencies [e688600]
- Updated dependencies [50b9d76]
- @nhost/hasura-auth-js@0.1.15
- @nhost/hasura-storage-js@0.0.12

View File

@@ -1,6 +1,6 @@
{
"name": "@nhost/nhost-js",
"version": "1.0.5",
"version": "1.0.10",
"description": "Nhost JavaScript SDK",
"license": "MIT",
"keywords": [

View File

@@ -60,20 +60,22 @@ export class NhostClient {
url: `${backendUrl}/v1/graphql`
})
// set current token if token is already accessable
// * Set current token if token is already accessable
this.storage.setAccessToken(this.auth.getAccessToken())
this.functions.setAccessToken(this.auth.getAccessToken())
this.graphql.setAccessToken(this.auth.getAccessToken())
this.auth.client.onStart(() => {
// update access token for clients
// * Set access token when signing out
this.auth.onAuthStateChanged((_event, session) => {
this.storage.setAccessToken(session?.accessToken)
this.functions.setAccessToken(session?.accessToken)
this.graphql.setAccessToken(session?.accessToken)
if (_event === 'SIGNED_OUT') {
this.storage.setAccessToken(undefined)
this.functions.setAccessToken(undefined)
this.graphql.setAccessToken(undefined)
}
})
// update access token for clients
// * Update access token for clients, including when signin in
this.auth.onTokenChanged((session) => {
this.storage.setAccessToken(session?.accessToken)
this.functions.setAccessToken(session?.accessToken)

View File

@@ -1,6 +1,31 @@
# @nhost/react-apollo
## 4.0.6
## 4.0.11
### Patch Changes
- 8583af8: correct documentation link in readme
- @nhost/apollo@0.3.8
- @nhost/react@0.5.1
## 4.0.10
### Patch Changes
- Updated dependencies [7cf875f]
- Updated dependencies [7135aee]
- Updated dependencies [587eaff]
- @nhost/react@0.5.0
- @nhost/apollo@0.3.7
## 4.0.9
### Patch Changes
- @nhost/react@0.4.7
- @nhost/apollo@0.3.6
## 4.0.8
### Patch Changes

View File

@@ -38,4 +38,4 @@ ReactDOM.render(
## Documentation
[https://docs.nhost.io/reference/supporting-libraries/react-apollo](https://docs.nhost.io/reference/supporting-libraries/react-apollo)
[https://docs.nhost.io/reference/react/apollo](https://docs.nhost.io/reference/react/apollo)

View File

@@ -1,6 +1,6 @@
{
"name": "@nhost/react-apollo",
"version": "4.0.6",
"version": "4.0.11",
"description": "Nhost React Apollo client",
"license": "MIT",
"keywords": [

View File

@@ -1,6 +1,71 @@
# @nhost/react
## 0.4.4
## 0.5.1
### Patch Changes
- Updated dependencies [2c97db6]
- @nhost/nhost-js@1.0.10
## 0.5.0
### Minor Changes
- 7135aee: Add user and accessToken to authentication hooks
Hooks that can complete a successful authentication now have two additional `user` and `accessToken` exported states:
- `useSignInEmailPassword`
- `useSignInAnonymous`
- `useSignUpEmailPassword`
- 587eaff: Return a promise with the current context to hooks actions
It is now possible to get the result of an action. Hook handlers return the action context in a promise.
```jsx
const { signInEmailPasswordless, isError } = useSignInEmailPasswordless()
const MyComponent = () => {
return <div>
<button onClick={async () => {
const { isSuccess, isError, error } = await signInEmailPasswordless('johan@ikea.se')
if (isError) {
console.log(error)
}}}/>
{isError && <div>an error occurred</div>}
<div>
}
```
### Patch Changes
- 7cf875f: Deprecate the use of values sent as hook parameters
Although handlers parameters of authentication hooks can be given when creating the hook, it is recommended to use them when executing the handler. For instance, instead of:
```js
const { signInEmailPasswordless } = useSignInEmailPasswordless('nuno@fcporto.pt')
signInEmailPasswordless()
```
It is recommended to use the following syntax:
```js
const { signInEmailPasswordless } = useSignInEmailPasswordless()
signInEmailPasswordless('nuno@fcporto.pt')
```
No breaking change has been introduced. For instance, `useSignUpEmailPassword('szilard@brussels.be','1234', options)` will appear as deprecated but will work, while `useSignUpEmailPassword(options)` will work too.
- @nhost/nhost-js@1.0.9
## 0.4.7
### Patch Changes
- @nhost/nhost-js@1.0.8
## 0.4.6
### Patch Changes

View File

@@ -1,6 +1,6 @@
{
"name": "@nhost/react",
"version": "0.4.4",
"version": "0.5.1",
"description": "Nhost React library",
"license": "MIT",
"keywords": [

View File

@@ -5,35 +5,123 @@ import {
PasswordlessOptions,
Provider,
ProviderOptions,
rewriteRedirectTo
rewriteRedirectTo,
User
} from '@nhost/core'
import { useSelector } from '@xstate/react'
import { NhostReactContext } from '../provider'
import { useAuthenticated, useAuthInterpreter } from './common'
import { ActionHookState, useAuthenticated, useAuthInterpreter } from './common'
export const useSignInEmailPassword = (
type SignInEmailPasswordHookState = ActionHookState & {
needsMfaOtp: boolean
needsEmailVerification: boolean
user: User | null
accessToken: string | null
}
type SignInEmailPasswordHandlerResult = Omit<SignInEmailPasswordHookState, 'isLoading'>
type SignInEmailPasswordHandler = {
(email: string, password: string): Promise<SignInEmailPasswordHandlerResult>
/** @deprecated */
(email?: unknown, password?: string): Promise<SignInEmailPasswordHandlerResult>
}
type SendMfaOtpHander = {
(otp: string): void
/** @deprecated */
(otp?: unknown): void
}
type SignInEmailPasswordHookResult = {
signInEmailPassword: SignInEmailPasswordHandler
sendMfaOtp: SendMfaOtpHander
} & SignInEmailPasswordHookState
type SignInEmailPasswordHook = {
(): SignInEmailPasswordHookResult
/** @deprecated */
(email?: string, password?: string, otp?: string): SignInEmailPasswordHookResult
}
export const useSignInEmailPassword: SignInEmailPasswordHook = (
stateEmail?: string,
statePassword?: string,
stateOtp?: string
) => {
const service = useAuthInterpreter()
const signInEmailPassword = (valueEmail?: string | unknown, valuePassword?: string | unknown) =>
service.send({
type: 'SIGNIN_PASSWORD',
email: typeof valueEmail === 'string' ? valueEmail : stateEmail,
password: typeof valuePassword === 'string' ? valuePassword : statePassword
const signInEmailPassword: SignInEmailPasswordHandler = (
valueEmail?: string | unknown,
valuePassword?: string
) =>
new Promise<SignInEmailPasswordHandlerResult>((resolve) => {
service.send({
type: 'SIGNIN_PASSWORD',
email: typeof valueEmail === 'string' ? valueEmail : stateEmail,
password: typeof valuePassword === 'string' ? valuePassword : statePassword
})
service.onTransition((state) => {
if (state.matches({ authentication: { signedOut: 'needsEmailVerification' } })) {
resolve({
accessToken: null,
error: null,
isError: false,
isSuccess: false,
needsEmailVerification: true,
needsMfaOtp: false,
user: null
})
} else if (state.matches({ authentication: { signedOut: 'needsMfa' } })) {
resolve({
accessToken: null,
error: null,
isError: false,
isSuccess: false,
needsEmailVerification: false,
needsMfaOtp: true,
user: null
})
} else if (state.matches({ authentication: { signedOut: 'failed' } })) {
resolve({
accessToken: null,
error: state.context.errors.authentication || null,
isError: true,
isSuccess: false,
needsEmailVerification: false,
needsMfaOtp: false,
user: null
})
} else if (state.matches({ authentication: 'signedIn' })) {
resolve({
accessToken: state.context.accessToken.value,
error: null,
isError: false,
isSuccess: true,
needsEmailVerification: false,
needsMfaOtp: false,
user: state.context.user
})
}
})
})
const sendMfaOtp = (valueOtp?: string | unknown) => {
const sendMfaOtp: SendMfaOtpHander = (valueOtp?: string | unknown) => {
service.send({
type: 'SIGNIN_MFA_TOTP',
otp: typeof valueOtp === 'string' ? valueOtp : stateOtp
})
}
const user = useSelector(
service,
(state) => state.context.user,
(a, b) => a?.id === b?.id
)
const accessToken = useSelector(service, (state) => state.context.accessToken.value)
const error = useSelector(
service,
(state) => state.context.errors.authentication,
(state) => state.context.errors.authentication || null,
(a, b) => a?.error === b?.error
)
const isSuccess = useAuthenticated()
@@ -59,32 +147,70 @@ export const useSignInEmailPassword = (
)
return {
signInEmailPassword,
accessToken,
error,
isError,
isLoading,
isSuccess,
needsEmailVerification,
needsMfaOtp,
sendMfaOtp,
isError,
error
signInEmailPassword,
user
}
}
export const useSignInEmailPasswordless = (
stateEmail?: string,
stateOptions?: PasswordlessOptions
type SignInEmailPasswordlessHandlerResult = Omit<ActionHookState, 'isLoading'>
type SignInEmailPasswordlessHandler = {
(email: string, options?: PasswordlessOptions): Promise<SignInEmailPasswordlessHandlerResult>
/** @deprecated */
(email?: unknown, options?: PasswordlessOptions): Promise<SignInEmailPasswordlessHandlerResult>
}
type SignInEmailPasswordlessHookResult = {
signInEmailPasswordless: SignInEmailPasswordlessHandler
} & ActionHookState
type SignInEmailPasswordlessdHook = {
(options?: PasswordlessOptions): SignInEmailPasswordlessHookResult
/** @deprecated */
(email?: string, options?: PasswordlessOptions): SignInEmailPasswordlessHookResult
}
export const useSignInEmailPasswordless: SignInEmailPasswordlessdHook = (
a?: string | PasswordlessOptions,
b?: PasswordlessOptions
) => {
const stateEmail = typeof a === 'string' ? a : undefined
const stateOptions = typeof a === 'string' ? b : a
const service = useAuthInterpreter()
const signInEmailPasswordless = (valueEmail?: string | unknown, valueOptions = stateOptions) =>
service.send({
type: 'SIGNIN_PASSWORDLESS_EMAIL',
email: typeof valueEmail === 'string' ? valueEmail : stateEmail,
options: valueOptions
const signInEmailPasswordless: SignInEmailPasswordlessHandler = (
valueEmail?: string | unknown,
valueOptions = stateOptions
) =>
new Promise<SignInEmailPasswordlessHandlerResult>((resolve) => {
service.send({
type: 'SIGNIN_PASSWORDLESS_EMAIL',
email: typeof valueEmail === 'string' ? valueEmail : stateEmail,
options: valueOptions
})
service.onTransition((state) => {
if (state.matches({ authentication: { signedOut: 'failed' } })) {
resolve({
error: state.context.errors.authentication || null,
isError: true,
isSuccess: false
})
} else if (state.matches({ authentication: { signedOut: 'needsEmailVerification' } })) {
resolve({ error: null, isError: false, isSuccess: true })
}
})
})
const error = useSelector(
service,
(state) => state.context.errors.authentication,
(state) => state.context.errors.authentication || null,
(a, b) => a?.error === b?.error
)
const isLoading =
@@ -93,9 +219,9 @@ export const useSignInEmailPasswordless = (
const isSuccess =
!!service.status &&
service.state.matches({ authentication: { signedOut: 'needsEmailVerification' } })
const isError =
!!service.status && service.state.matches({ authentication: { signedOut: 'failed' } })
return { signInEmailPasswordless, isLoading, isSuccess, isError, error }
}
@@ -115,7 +241,13 @@ export const useSignInAnonymous = () => {
const isSuccess = useAuthenticated()
const isError =
!!service.status && service.state.matches({ authentication: { signedOut: 'failed' } })
return { signInAnonymous, isLoading, isSuccess, isError, error }
const user = useSelector(
service,
(state) => state.context.user,
(a, b) => a?.id === b?.id
)
const accessToken = useSelector(service, (state) => state.context.accessToken.value)
return { accessToken, error, isError, isLoading, isSuccess, signInAnonymous, user }
}
export const useProviderLink = (options?: ProviderOptions) => {

View File

@@ -1,12 +1,19 @@
import { useContext, useEffect, useState } from 'react'
import { InterpreterFrom } from 'xstate'
import { AuthMachine } from '@nhost/core'
import { AuthMachine, ErrorPayload } from '@nhost/core'
import { NhostClient } from '@nhost/nhost-js'
import { useSelector } from '@xstate/react'
import { NhostReactContext } from '../provider'
export type ActionHookState<T extends string = 'isSuccess'> = {
isLoading: boolean
isError: boolean
error: ErrorPayload | null
} & Record<T, boolean>
export const useNhostClient = (): NhostClient => {
const nhost = useContext(NhostReactContext)
return nhost

View File

@@ -1,21 +1,55 @@
import { useMemo } from 'react'
import { SignUpOptions } from '@nhost/core'
import { SignUpOptions, User } from '@nhost/core'
import { useSelector } from '@xstate/react'
import { useAuthenticationStatus, useAuthInterpreter } from './common'
import { ActionHookState, useAuthenticationStatus, useAuthInterpreter } from './common'
export const useSignUpEmailPassword = (
stateEmail?: string,
statePassword?: string,
stateOptions?: SignUpOptions
type SignUpEmailPasswordHookState = ActionHookState & {
needsEmailVerification: boolean
user: User | null
accessToken: string | null
}
type SignUpEmailPasswordHandlerResult = Omit<SignUpEmailPasswordHookState, 'isLoading'>
type SignUpEmailPasswordHandler = {
(
email: string,
password: string,
options?: SignUpOptions
): Promise<SignUpEmailPasswordHandlerResult>
/** @deprecated */
(
email?: unknown,
password?: string,
options?: SignUpOptions
): Promise<SignUpEmailPasswordHandlerResult>
}
type SignUpEmailPasswordHookResult = {
signUpEmailPassword: SignUpEmailPasswordHandler
} & SignUpEmailPasswordHookState
type SignUpEmailPasswordHook = {
(options?: SignUpOptions): SignUpEmailPasswordHookResult
/** @deprecated */
(email?: string, password?: string, options?: SignUpOptions): SignUpEmailPasswordHookResult
}
export const useSignUpEmailPassword: SignUpEmailPasswordHook = (
a?: string | SignUpOptions,
b?: string,
c?: SignUpOptions
) => {
const stateEmail: string | undefined = typeof a === 'string' ? a : undefined
const statePassword: string | undefined = typeof b === 'string' ? b : undefined
const stateOptions = c || (typeof a !== 'string' ? a : undefined)
const service = useAuthInterpreter()
const isError =
!!service.status && service.state.matches({ authentication: { signedOut: 'failed' } })
const error = useSelector(
service,
(state) => state.context.errors.registration,
(state) => state.context.errors.registration || null,
(a, b) => a?.error === b?.error
)
const { isLoading: loading, isAuthenticated: isSuccess } = useAuthenticationStatus()
@@ -24,23 +58,65 @@ export const useSignUpEmailPassword = (
!!service.status &&
service.state.matches({ authentication: { signedOut: 'needsEmailVerification' } })
const signUpEmailPassword = (
const signUpEmailPassword: SignUpEmailPasswordHandler = (
valueEmail?: string | unknown,
valuePassword = statePassword,
valueOptions = stateOptions
) =>
service.send({
type: 'SIGNUP_EMAIL_PASSWORD',
email: typeof valueEmail === 'string' ? valueEmail : stateEmail,
password: valuePassword,
options: valueOptions
new Promise<SignUpEmailPasswordHandlerResult>((resolve) => {
service.send({
type: 'SIGNUP_EMAIL_PASSWORD',
email: typeof valueEmail === 'string' ? valueEmail : stateEmail,
password: valuePassword,
options: valueOptions
})
service.onTransition((state) => {
if (state.matches({ authentication: { signedOut: 'failed' } })) {
resolve({
accessToken: null,
error: state.context.errors.registration || null,
isError: true,
isSuccess: false,
needsEmailVerification: false,
user: null
})
} else if (state.matches({ authentication: { signedOut: 'needsEmailVerification' } })) {
resolve({
accessToken: null,
error: null,
isError: false,
isSuccess: false,
needsEmailVerification: true,
user: null
})
} else if (state.matches({ authentication: 'signedIn' })) {
resolve({
accessToken: state.context.accessToken.value,
error: null,
isError: false,
isSuccess: true,
needsEmailVerification: false,
user: state.context.user
})
}
})
})
const user = useSelector(
service,
(state) => state.context.user,
(a, b) => a?.id === b?.id
)
const accessToken = useSelector(service, (state) => state.context.accessToken.value)
return {
signUpEmailPassword,
accessToken,
error,
isError,
isLoading,
isSuccess,
isError,
error,
needsEmailVerification
needsEmailVerification,
signUpEmailPassword,
user
}
}

View File

@@ -1,4 +1,4 @@
import { useMemo } from 'react'
import { useMemo, useState } from 'react'
import {
ChangeEmailOptions,
@@ -7,64 +7,171 @@ import {
createEnableMfaMachine,
createResetPasswordMachine,
createSendVerificationEmailMachine,
ErrorPayload,
ResetPasswordOptions,
SendVerificationEmailOptions
} from '@nhost/core'
import { useMachine, useSelector } from '@xstate/react'
import { useAuthInterpreter, useNhostClient } from './common'
import { ActionHookState, useAuthInterpreter, useNhostClient } from './common'
export const useChangeEmail = (stateEmail?: string, stateOptions?: ChangeEmailOptions) => {
type ChangeEmailHookState = ActionHookState<'needsEmailVerification'>
type ChangeEmailHandlerResult = Omit<ChangeEmailHookState, 'isLoading'>
type ChangeEmailHandler = {
(email: string, options?: ChangeEmailOptions): Promise<ChangeEmailHandlerResult>
/** @deprecated */
(email?: unknown, options?: ChangeEmailOptions): Promise<ChangeEmailHandlerResult>
}
type ChangeEmailHookResult = {
changeEmail: ChangeEmailHandler
} & ChangeEmailHookState
type ChangeEmailHook = {
(options?: ChangeEmailOptions): ChangeEmailHookResult
/** @deprecated */
(email?: string, options?: ChangeEmailOptions): ChangeEmailHookResult
}
export const useChangeEmail: ChangeEmailHook = (
a?: string | ChangeEmailOptions,
b?: ChangeEmailOptions
) => {
const stateEmail = typeof a === 'string' ? a : undefined
const stateOptions = typeof a !== 'string' ? a : b
const nhost = useNhostClient()
const machine = useMemo(() => createChangeEmailMachine(nhost.auth.client), [nhost])
const [current, send] = useMachine(machine)
const isError = current.matches({ idle: 'error' })
const needsEmailVerification = current.matches({ idle: 'success' })
const error = current.context.error
const isLoading = current.matches('requesting')
const changeEmail = (valueEmail?: string | unknown, valueOptions = stateOptions) =>
send({
type: 'REQUEST',
email: typeof valueEmail === 'string' ? valueEmail : stateEmail,
options: valueOptions
const [, send, service] = useMachine(machine)
const [isError, setIsError] = useState(false)
const [needsEmailVerification, setNeedsEmailVerification] = useState(false)
const [error, setError] = useState<ErrorPayload | null>(null)
const [isLoading, setIsLoading] = useState(false)
const changeEmail: ChangeEmailHandler = async (
valueEmail?: string | unknown,
valueOptions = stateOptions
) =>
new Promise<ChangeEmailHandlerResult>((resolve) => {
send({
type: 'REQUEST',
email: typeof valueEmail === 'string' ? valueEmail : stateEmail,
options: valueOptions
})
service.onTransition((state) => {
if (state.matches({ idle: 'error' })) {
const error = state.context.error
setIsError(true)
setError(error)
setIsLoading(false)
resolve({ isError: true, error, needsEmailVerification })
} else if (state.matches('requesting')) {
setIsLoading(true)
} else if (state.matches({ idle: 'success' })) {
setIsError(false)
setError(null)
setIsLoading(false)
setNeedsEmailVerification(true)
resolve({ isError: false, error: null, needsEmailVerification: true })
}
})
})
return { changeEmail, isLoading, needsEmailVerification, isError, error }
}
export const useChangePassword = (statePassword?: string) => {
type ChangePasswordHandlerResult = Omit<ActionHookState, 'isLoading'>
type ChangePasswordHandler = {
(password: string): Promise<ChangePasswordHandlerResult>
/** @deprecated */
(password?: unknown): Promise<ChangePasswordHandlerResult>
}
type ChangePasswordHookResult = {
changePassword: ChangePasswordHandler
} & ActionHookState
type ChangePasswordHook = {
(): ChangePasswordHookResult
/** @deprecated */
(email?: string): ChangePasswordHookResult
}
export const useChangePassword: ChangePasswordHook = (statePassword?: string) => {
const nhost = useNhostClient()
const machine = useMemo(() => createChangePasswordMachine(nhost.auth.client), [nhost])
const [current, send] = useMachine(machine)
const [current, send, service] = useMachine(machine)
const isError = current.matches({ idle: 'error' })
const isSuccess = current.matches({ idle: 'success' })
const error = current.context.error
const isLoading = current.matches('requesting')
const changePassword = (valuePassword?: string | unknown) =>
send({
type: 'REQUEST',
password: typeof valuePassword === 'string' ? valuePassword : statePassword
const changePassword: ChangePasswordHandler = (valuePassword?: string | unknown) =>
new Promise<ChangePasswordHandlerResult>((resolve) => {
send({
type: 'REQUEST',
password: typeof valuePassword === 'string' ? valuePassword : statePassword
})
service.onTransition((state) => {
if (state.matches({ idle: 'error' })) {
resolve({ error: state.context.error, isError: true, isSuccess: false })
} else if (state.matches({ idle: 'success' })) {
resolve({ error: null, isError: false, isSuccess: true })
}
})
})
return { changePassword, isLoading, isSuccess, isError, error }
}
export const useResetPassword = (stateEmail?: string, stateOptions?: ResetPasswordOptions) => {
type ResetPasswordHandlerResult = Omit<ResetPasswordHookState, 'isLoading'>
type ResetPasswordHandler = {
(email: string, options?: ResetPasswordOptions): Promise<ResetPasswordHandlerResult>
/** @deprecated */
(email?: unknown, options?: ResetPasswordOptions): Promise<ResetPasswordHandlerResult>
}
type ResetPasswordHookState = ActionHookState<'isSent'>
type ResetPasswordHookResult = {
resetPassword: ResetPasswordHandler
} & ResetPasswordHookState
type ResetPasswordHook = {
(options?: ResetPasswordOptions): ResetPasswordHookResult
/** @deprecated */
(email?: string, options?: ResetPasswordOptions): ResetPasswordHookResult
}
export const useResetPassword: ResetPasswordHook = (
a?: string | ResetPasswordOptions,
b?: ResetPasswordOptions
) => {
const stateEmail = typeof a === 'string' ? a : undefined
const stateOptions = typeof a !== 'string' ? a : b
const nhost = useNhostClient()
const machine = useMemo(() => createResetPasswordMachine(nhost.auth.client), [nhost])
const [current, send] = useMachine(machine)
const [current, send, service] = useMachine(machine)
const isError = current.matches({ idle: 'error' })
const isSent = current.matches({ idle: 'success' })
const error = current.context.error
const isLoading = current.matches('requesting')
const resetPassword = (valueEmail?: string | unknown, valueOptions = stateOptions) =>
send({
type: 'REQUEST',
email: typeof valueEmail === 'string' ? valueEmail : stateEmail,
options: valueOptions
const resetPassword: ResetPasswordHandler = (
valueEmail?: string | unknown,
valueOptions = stateOptions
) =>
new Promise<ResetPasswordHandlerResult>((resolve) => {
send({
type: 'REQUEST',
email: typeof valueEmail === 'string' ? valueEmail : stateEmail,
options: valueOptions
})
service.onTransition((state) => {
if (state.matches({ idle: 'error' })) {
resolve({ error: state.context.error, isError: true, isSent: false })
} else if (state.matches({ idle: 'success' })) {
resolve({ error: null, isError: false, isSent: true })
}
})
})
return { resetPassword, isLoading, isSent, isError, error }
}
@@ -150,37 +257,103 @@ export const useUserRoles = () => {
)
}
export const useSendVerificationEmail = (
stateEmail?: string,
stateOptions?: SendVerificationEmailOptions
type SendVerificationEmailHandlerResult = Omit<SendVerificationEmailHookState, 'isLoading'>
type SendVerificationEmailHandler = {
(
email: string,
options?: SendVerificationEmailOptions
): Promise<SendVerificationEmailHandlerResult>
/** @deprecated */
(
email?: unknown,
options?: SendVerificationEmailOptions
): Promise<SendVerificationEmailHandlerResult>
}
type SendVerificationEmailHookState = ActionHookState<'isSent'>
type SendVerificationEmailHookResult = {
sendEmail: SendVerificationEmailHandler
} & SendVerificationEmailHookState
type SendVerificationEmailHook = {
(options?: SendVerificationEmailOptions): SendVerificationEmailHookResult
/** @deprecated */
(email?: string, options?: SendVerificationEmailOptions): SendVerificationEmailHookResult
}
export const useSendVerificationEmail: SendVerificationEmailHook = (
a?: string | SendVerificationEmailOptions,
b?: SendVerificationEmailOptions
) => {
const stateEmail = typeof a === 'string' ? a : undefined
const stateOptions = typeof a !== 'string' ? a : b
const nhost = useNhostClient()
const machine = useMemo(() => createSendVerificationEmailMachine(nhost.auth.client), [nhost])
const [current, send] = useMachine(machine)
const [current, send, service] = useMachine(machine)
const isError = current.matches({ idle: 'error' })
const isSent = current.matches({ idle: 'success' })
const error = current.context.error
const isLoading = current.matches('requesting')
const sendEmail = (valueEmail?: string | unknown, valueOptions = stateOptions) =>
send({
type: 'REQUEST',
email: typeof valueEmail === 'string' ? valueEmail : stateEmail,
options: valueOptions
const sendEmail: SendVerificationEmailHandler = (
valueEmail?: string | unknown,
valueOptions = stateOptions
) =>
new Promise<SendVerificationEmailHandlerResult>((resolve) => {
send({
type: 'REQUEST',
email: typeof valueEmail === 'string' ? valueEmail : stateEmail,
options: valueOptions
})
service.onTransition((state) => {
if (state.matches({ idle: 'error' })) {
resolve({ error: state.context.error, isError: true, isSent: false })
} else if (state.matches({ idle: 'success' })) {
resolve({ error: null, isError: false, isSent: true })
}
})
})
return { sendEmail, isLoading, isSent, isError, error }
}
type ActivateMfaHookState = {
isActivating: boolean
isActivated: boolean
isError: boolean
error: ErrorPayload | null
}
type GenerateQrCodeHookState = {
qrCodeDataUrl: string
isGenerating: boolean
isGenerated: boolean
isError: boolean
error: ErrorPayload | null
}
type ActivateMfaHandlerResult = Omit<ActivateMfaHookState, 'isActivating'>
type ActivateMfaHandler = (code: string) => Promise<ActivateMfaHandlerResult>
type GenerateQrCodeHandlerResult = Omit<GenerateQrCodeHookState, 'isGenerating'>
type GenerateQrCodeHandler = () => Promise<GenerateQrCodeHandlerResult>
type ConfigMfaHookState = ActivateMfaHookState &
GenerateQrCodeHookState & {
generateQrCode: GenerateQrCodeHandler
activateMfa: ActivateMfaHandler
}
type ConfigMfaHook = () => ConfigMfaHookState
// TODO documentation when available in Nhost Cloud - see changelog
export const useConfigMfa = (stateCode?: string) => {
export const useConfigMfa: ConfigMfaHook = () => {
const nhost = useNhostClient()
const machine = useMemo(() => createEnableMfaMachine(nhost.auth.client), [nhost])
const [current, send] = useMachine(machine)
const [current, send, service] = useMachine(machine)
const isError = useMemo(() => {
current.matches({ idle: 'error' }) || current.matches({ generated: { idle: 'error' } })
}, [current])
const isError = useMemo(
() => current.matches({ idle: 'error' }) || current.matches({ generated: { idle: 'error' } }),
[current]
)
const isGenerating = current.matches('generating')
const isGenerated = current.matches('generated')
const isActivating = current.matches({ generated: 'activating' })
@@ -188,12 +361,41 @@ export const useConfigMfa = (stateCode?: string) => {
const error = current.context.error
const qrCodeDataUrl = current.context.imageUrl || ''
const generateQrCode = () => send('GENERATE')
const activateMfa = (valueCode?: string | unknown) =>
send({
type: 'ACTIVATE',
activeMfaType: 'totp',
code: typeof valueCode === 'string' ? valueCode : stateCode
const generateQrCode: GenerateQrCodeHandler = () =>
new Promise<GenerateQrCodeHandlerResult>((resolve) => {
send('GENERATE')
service.onTransition((state) => {
if (state.matches('generated')) {
resolve({
error: null,
isError: false,
isGenerated: true,
qrCodeDataUrl: state.context.imageUrl || ''
})
} else if (state.matches({ idle: 'error' })) {
resolve({
error: state.context.error || null,
isError: true,
isGenerated: false,
qrCodeDataUrl: ''
})
}
})
})
const activateMfa: ActivateMfaHandler = (code: string) =>
new Promise<ActivateMfaHandlerResult>((resolve) => {
send({
type: 'ACTIVATE',
activeMfaType: 'totp',
code
})
service.onTransition((state) => {
if (state.matches({ generated: 'activated' })) {
resolve({ error: null, isActivated: true, isError: false })
} else if (state.matches({ generated: { idle: 'error' } })) {
resolve({ error: state.context.error, isActivated: false, isError: true })
}
})
})
return {
generateQrCode,

2
pnpm-lock.yaml generated
View File

@@ -83,6 +83,7 @@ importers:
specifiers:
'@heroicons/react': ^1.0.5
'@mailchimp/mailchimp_marketing': ^3.0.74
'@types/node': ^17.0.21
'@types/react': ^17.0.37
autoprefixer: ^10.4.0
axios: ^0.24.0
@@ -135,6 +136,7 @@ importers:
react-syntax-highlighter: 15.4.5_react@17.0.2
swagger-ui-react: 4.8.0_react-dom@17.0.2+react@17.0.2
devDependencies:
'@types/node': 17.0.21
'@types/react': 17.0.40
autoprefixer: 10.4.2_postcss@8.4.8
next-sitemap: 1.9.12_next@12.1.0

View File

@@ -2,7 +2,7 @@
"compilerOptions": {
"declaration": true,
"noImplicitAny": false,
"removeComments": true,
"removeComments": false,
"noLib": false,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,