Compare commits

..

108 Commits

Author SHA1 Message Date
Johan Eliasson
4107287c8e Merge pull request #741 from nhost/changeset-release/main
chore: update versions
2022-06-22 14:16:59 +02:00
github-actions[bot]
651c481874 chore: update versions 2022-06-22 12:10:47 +00:00
Nuno Pato
b54b0c0743 Merge pull request #601 from nhost/feat/add-cdn-support-nhost-js
Add `subdomain` and `region` as options to `NhostClient`
2022-06-22 12:09:12 +00:00
Johan Eliasson
d07373d255 updated parameters for NhostClient 2022-06-22 13:46:13 +02:00
Nuno Pato
73c8fa1fb2 fix typo 2022-06-22 10:47:35 +00:00
Pilou
67f2622642 Merge pull request #739 from nhost/docs/move-hasura-auth
Remove hasura-auth from the reference documentation
2022-06-22 12:40:08 +02:00
Pierre-Louis Mercereau
780f95d950 chore: update versions 2022-06-22 12:34:31 +02:00
Pierre-Louis Mercereau
cb84db7688 docs: remove hasura-auth from reference documentation 2022-06-22 12:31:24 +02:00
Johan Eliasson
67d76ebbb6 Merge pull request #737 from nhost/elitan-patch-2
Added ROSS Index badge
2022-06-22 10:11:26 +02:00
Johan Eliasson
48af3fb4d1 Update README.md 2022-06-22 09:26:21 +02:00
Johan Eliasson
e5adc515d4 Update README.md 2022-06-22 09:25:12 +02:00
Pilou
5f4b16f2f9 Merge pull request #716 from nhost/docs-algolio-fix
Fix Algolia full page search
2022-06-21 19:02:15 +02:00
Nuno Pato
be50d4ad1d Merge branch 'main' into feat/add-cdn-support-nhost-js 2022-06-21 15:09:07 +00:00
Nuno Pato
d40afbb744 Fix messaging 2022-06-21 15:04:35 +00:00
Nuno Pato
7e0035a856 Merge pull request #733 from nhost/chore/bump-all-versions
Bump all versions of hasura, hasura auth, and hasura storage
2022-06-21 14:12:56 +02:00
Pilou
2fec74e501 Merge pull request #717 from nhost/changeset-release/main
chore: update versions
2022-06-21 14:10:10 +02:00
Pierre-Louis Mercereau
e94b28b3bc chore: avoid major bumps of peer dependencies 2022-06-21 13:54:06 +02:00
github-actions[bot]
f591f76256 chore: update versions 2022-06-21 11:42:44 +00:00
Pilou
58fb955dc6 Merge pull request #720 from nhost/docs/vue-use-reset-password
docs(vue): correct useResetPassword inline example
2022-06-21 13:41:33 +02:00
Nuno Pato
5826baa57e Update missing packages 2022-06-21 10:26:25 +00:00
Nuno Pato
3c789629a4 Bump all versions of hasura, hasura auth, and hasura storage 2022-06-21 09:47:24 +00:00
Johan Eliasson
f472d42ae9 Merge pull request #732 from nhost/contributors-readme-action-RQTOlQZRpc
contributors readme action update
2022-06-21 07:39:06 +02:00
github-actions[bot]
9993bea7ab contrib-readme-action has updated readme 2022-06-21 05:22:34 +00:00
Johan Eliasson
6f33fc6ce6 Merge pull request #728 from nhost/contributors-readme-action-0KCGh0rhTk
contributors readme action update
2022-06-21 07:22:16 +02:00
Johan Eliasson
b6858c5638 Merge pull request #731 from nhost/contributors-readme-action-yVNIRBZEXT
contributors readme action update
2022-06-21 07:20:27 +02:00
github-actions[bot]
9b01c3ba93 contrib-readme-action has updated readme 2022-06-21 05:19:56 +00:00
Johan Eliasson
fcfd6a9c13 Merge pull request #729 from kylehayes/patch-1
Clarifying how to open Hasura Console
2022-06-21 07:19:41 +02:00
Kyle Hayes
e4daefe637 Clarifying how to open Hasura Console
Updating the documentation to reflect the new location of the button to open Hasura Console.
2022-06-20 17:45:07 -07:00
Guido Curcio
59a5fe97b1 chore: change from types to inferface; fix example; add test missing region test. 2022-06-20 11:20:27 -03:00
github-actions[bot]
a0bcbb6269 contrib-readme-action has updated readme 2022-06-20 13:16:03 +00:00
Pilou
1ec1004507 Merge pull request #727 from muttenzer/docs/permission-variables
Correct permission variables section
2022-06-20 15:15:40 +02:00
Pierre-Louis Mercereau
756d996096 chore: changeset 2022-06-20 12:16:30 +02:00
Timo
c0f1d03c3c Correct permission variables section
Mention how Nhost prefixes the custom JWT claims locally and correct example path.
2022-06-19 16:52:43 +02:00
Pilou
af55789d07 Merge pull request #723 from nhost/contributors-readme-action-IeghAq7Be4
contributors readme action update
2022-06-18 08:11:22 +02:00
Pilou
cb28676895 Merge pull request #722 from nhost/contributors-readme-action-8WdPB9amrq
contributors readme action update
2022-06-18 08:10:11 +02:00
github-actions[bot]
939a3d1090 contrib-readme-action has updated readme 2022-06-18 06:08:16 +00:00
Pilou
0163d0588b Merge pull request #721 from nhost/contributors-readme-action--AZAZ22Nlk
contributors readme action update
2022-06-18 08:08:02 +02:00
github-actions[bot]
c4124f22b0 contrib-readme-action has updated readme 2022-06-18 06:06:29 +00:00
Pilou
7188b0971c Merge pull request #718 from nhost/remove-build-script-dashes
chore: remove build script dashes
2022-06-18 08:06:16 +02:00
github-actions[bot]
6ac969320c contrib-readme-action has updated readme 2022-06-18 05:56:16 +00:00
Johan Eliasson
414bc2e75b Merge pull request #719 from muttenzer/docs/permission-variables
Update permission variables section
2022-06-18 07:56:00 +02:00
Pierre-Louis Mercereau
6862e1e24d docs(vue): correct useResetPassword inline example 2022-06-18 07:04:33 +02:00
muttenzer
4b9deaa2f7 Update permission variables section
Further instructions of how to handle custom permission variables in development.
2022-06-17 23:53:05 +02:00
Pierre-Louis Mercereau
cf366cef35 chore: remove build script dashes 2022-06-17 21:02:44 +02:00
Pilou
00d041f6b4 Merge pull request #714 from nhost/test/anonymous
test: anonymous sign-in and deanonymisation
2022-06-17 19:53:50 +02:00
Pierre-Louis Mercereau
da06fef64e refactor: use aria-label 2022-06-17 15:07:51 +02:00
Pierre-Louis Mercereau
09be9582f8 Merge branch 'main' into test/anonymous 2022-06-17 15:02:50 +02:00
Pilou
6b26fed8ae Merge pull request #713 from nhost/complete-mfa
Complete email+password sign-in with MFA
2022-06-17 15:02:08 +02:00
Pierre-Louis Mercereau
5a62c66fc4 Merge branch 'main' into test/anonymous 2022-06-17 14:26:17 +02:00
Pilou
17e0e6d116 Merge pull request #711 from nhost/test/change-email-password
test: change email and password
2022-06-17 14:22:02 +02:00
Pierre-Louis Mercereau
938000e61b test: don't accept an invalid email/password 2022-06-17 11:53:47 +02:00
Pierre-Louis Mercereau
d700107222 test: add apollo tests 2022-06-17 11:12:13 +02:00
Johan Eliasson
7f1b8a5881 config update 2022-06-17 08:38:17 +02:00
Johan Eliasson
7fd5f0fedf added initialIndexSettings 2022-06-17 08:33:14 +02:00
Johan Eliasson
bf551fe705 update 2022-06-17 08:24:00 +02:00
Pierre-Louis Mercereau
69d9e40187 chore: chore 2022-06-16 15:40:55 +02:00
Pierre-Louis Mercereau
fc5b18fdf0 test: add item to todo list when anonymous 2022-06-15 20:55:37 +02:00
Pierre-Louis Mercereau
fa3eb980a0 feat: allow anonymous users to use the todo list 2022-06-15 19:03:47 +02:00
Pierre-Louis Mercereau
efad3a2b08 chore: add comment 2022-06-15 17:20:42 +02:00
Pierre-Louis Mercereau
563fa4fe9b test: anonymous sign-in and deanonymisation 2022-06-15 17:19:09 +02:00
Pierre-Louis Mercereau
6f0a30059a feat: complete email+password sign-in with MFA 2022-06-15 13:37:52 +02:00
Pierre-Louis Mercereau
47cda5d716 chore: order 2022-06-15 10:08:09 +02:00
Pierre-Louis Mercereau
3f625ce9e1 test: change email and password 2022-06-15 10:03:23 +02:00
Pilou
38d2609249 Merge pull request #710 from nhost/roles-docs
Info about allowed roles
2022-06-15 09:10:56 +02:00
Pilou
030243cd45 Merge pull request #691 from nhost/e2e-react-tests
test: passwordless email, sign-in with token, sign-out
2022-06-15 09:08:32 +02:00
Johan Eliasson
c1905243d0 roles info 2022-06-14 22:40:15 +02:00
Johan Eliasson
37627cc50e info about allowed roles 2022-06-14 21:44:14 +02:00
Pierre-Louis Mercereau
009f68d500 test: should get a session from localStorage 2022-06-14 17:44:35 +02:00
Pierre-Louis Mercereau
b752cc2be8 test: add assertions 2022-06-13 18:35:43 +02:00
Pierre-Louis Mercereau
72fc7d4e44 Merge branch 'main' into e2e-react-tests 2022-06-13 09:31:26 +02:00
Pilou
80ef14e50a Merge pull request #700 from nhost/react-example-todo-list
docs: replace the `books` table by a `todos` table
2022-06-13 08:23:55 +02:00
Pilou
543ea2a0e7 Merge pull request #706 from nhost/changeset-release/main
chore: update versions
2022-06-12 21:58:05 +02:00
github-actions[bot]
6764d476fd chore: update versions 2022-06-12 19:42:37 +00:00
Pilou
7bed0eadc9 Merge pull request #704 from nhost/fix/vue-nested-unref
Correct use of ref values in action options
2022-06-12 21:41:41 +02:00
Pierre-Louis Mercereau
c7644ace34 test: should return the same value when not a ref 2022-06-11 22:05:41 +02:00
Pierre-Louis Mercereau
49cdb2843e test: add one test 2022-06-11 21:58:03 +02:00
Pierre-Louis Mercereau
6f45856c46 fix: nestedUnref 2022-06-11 21:54:21 +02:00
Pierre-Louis Mercereau
61e719eea0 refactor: use findByRole 2022-06-10 18:37:13 +02:00
Pilou
208bdbba2d Merge pull request #703 from nhost/docs/fix-dependency
Use internal `*` dependencies in examples
2022-06-10 17:31:19 +02:00
Pierre-Louis Mercereau
cd62e1e833 docs: use internal * dependencies in examples 2022-06-10 16:47:32 +02:00
Pierre-Louis Mercereau
1dfb11d7e8 Merge branch 'e2e-react-tests' into react-example-todo-list 2022-06-10 14:30:07 +02:00
Pierre-Louis Mercereau
8b5c4ed443 refactor: make tests independent from each other 2022-06-10 14:28:03 +02:00
Pierre-Louis Mercereau
6bd5c96ed5 chore: modify autogenerated down migration 2022-06-10 11:58:52 +02:00
Pierre-Louis Mercereau
6b8762a62e chore: add missing change 2022-06-10 11:56:37 +02:00
Pierre-Louis Mercereau
ddeff7cbd6 refactor: rename index name 2022-06-10 11:55:17 +02:00
Pierre-Louis Mercereau
ed952c1251 perf: add index 2022-06-10 11:53:30 +02:00
Pierre-Louis Mercereau
34e73f18bd chore: remove .vscode directory 2022-06-10 11:44:12 +02:00
Pierre-Louis Mercereau
84262a24f1 docs: replace the books table by a todos table
adapt the Apollo page to add a todo item, add permissions so the connected user only sees its own
todos, add cypress test, use GraphQL codegen
2022-06-10 11:33:12 +02:00
Pierre-Louis Mercereau
ec2a88d69c chore: remove useless line 2022-06-09 11:40:22 +02:00
Pierre-Louis Mercereau
fe1049df6b test: token should be refresh on time 2022-06-09 11:39:18 +02:00
Pierre-Louis Mercereau
a924d21815 Merge remote-tracking branch 'origin/main' into e2e-react-tests 2022-06-09 09:09:03 +02:00
Pierre-Louis Mercereau
4405535d4a chore: adjustments 2022-06-09 08:43:08 +02:00
Pierre-Louis Mercereau
af15771517 test: simulate network errors on sign-un and sign-in 2022-06-08 16:01:09 +02:00
Pierre-Louis Mercereau
c066ea5b75 ci: tranform package name into a valid file name 2022-06-08 14:05:11 +02:00
Pierre-Louis Mercereau
80e42b939b make it fail 2022-06-08 13:36:19 +02:00
Pierre-Louis Mercereau
3ea6f685e2 Merge remote-tracking branch 'origin/main' into e2e-react-tests 2022-06-08 13:27:57 +02:00
Pierre-Louis Mercereau
ac77f427c3 Merge remote-tracking branch 'origin/main' into e2e-react-tests 2022-06-08 13:01:46 +02:00
Pierre-Louis Mercereau
0f95ee5bb4 chore: rename 2022-06-08 11:26:41 +02:00
Pierre-Louis Mercereau
47406d3617 test: passwordless email, sign-in with token, sign-out 2022-06-08 11:24:18 +02:00
Pierre-Louis Mercereau
125bc9a749 test: passwordless email, sign-in with token, sign-out 2022-06-08 11:14:50 +02:00
Nuno Pato
b8f4b75b0c Add changeset 2022-05-31 17:43:45 +02:00
Nuno Pato
5227c84820 Merge branch 'main' into feat/add-cdn-support-nhost-js 2022-05-31 17:32:47 +02:00
Nuno Pato
04aadb6fa4 Add missing https 2022-05-25 19:04:22 +02:00
Nuno Pato
e08a08973d Test urlFromParams util function 2022-05-25 18:36:16 +02:00
Nuno Pato
3b11caf3bc Introduce types for backendUrl and subdomain 2022-05-25 17:11:01 +02:00
Nuno Pato
049f67e54a Improve messaging 2022-05-25 00:45:41 +02:00
Nuno Pato
6da1f90bc3 Add subdomain alongside backendUrl 2022-05-25 00:03:14 +02:00
Nuno Pato
59fd68dee3 Add region to the NhostClient constructor 2022-05-24 12:56:02 +02:00
177 changed files with 2448 additions and 1674 deletions

View File

@@ -67,12 +67,18 @@ jobs:
# * Run the `ci` script of the current package of the matrix. Dependencies build is cached by Turborepo
- name: Run e2e test
run: pnpm run e2e -- --filter="${{ matrix.package.name }}"
- id: file-name
if: ${{ failure() }}
name: Tranform package name into a valid file name
run: |
PACKAGE_FILE_NAME=$(echo "${{ matrix.package.name }}" | sed 's/@//g; s/\//-/g')
echo "::set-output name=fileName::$PACKAGE_FILE_NAME"
# * Run this step only if the previous step failed, and some Cypress screenshots/videos exist
- name: Upload Cypress videos and screenshots
if: ${{ failure() && hashFiles(format('{0}/cypress/screenshots/**', matrix.package.path), format('{0}/cypress/videos/**', matrix.package.path)) != ''}}
uses: actions/upload-artifact@v3
with:
name: cypress-${{ matrix.package.name }}
name: cypress-${{ steps.file-name.outputs.fileName }}
path: |
${{format('{0}/cypress/screenshots/**', matrix.package.path)}}
${{format('{0}/cypress/videos/**', matrix.package.path)}}

View File

@@ -67,7 +67,8 @@ Install the `@nhost/nhost-js` package and start build your app:
import { NhostClient } from '@nhost/nhost-js'
const nhost = new NhostClient({
backendUrl: 'https://awesome-app.nhost.run'
subdomain: '<your-subdomain>',
region: '<your-region>'
})
await nhost.auth.signIn({ email: 'elon@musk.com', password: 'spaceX' })
@@ -115,6 +116,10 @@ Also, follow Nhost on [GitHub Discussions](https://github.com/nhost/nhost/discus
This repository, and most of our other open source projects, are licensed under the MIT license.
<a href="https://runacap.com/ross-index/q1-2022/" target="_blank" rel="noopener">
<img style="width: 260px; height: 56px" src="https://runacap.com/wp-content/uploads/2022/06/ROSS_badge_black_Q1_2022.svg" alt="ROSS Index - Fastest Growing Open-Source Startups in Q1 2022 | Runa Capital" width="260" height="56" />
</a>
### How to contribute
Here are some ways of contributing to making Nhost better:
@@ -285,21 +290,28 @@ Here are some ways of contributing to making Nhost better:
<sub><b>Savin Vadim</b></sub>
</a>
</td>
<td align="center">
<a href="https://github.com/muttenzer">
<img src="https://avatars.githubusercontent.com/u/49474412?v=4" width="100;" alt="muttenzer"/>
<br />
<sub><b>Muttenzer</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></tr>
<tr>
<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></tr>
<tr>
</td>
<td align="center">
<a href="https://github.com/Sonichigo">
<img src="https://avatars.githubusercontent.com/u/53110238?v=4" width="100;" alt="Sonichigo"/>
@@ -334,15 +346,15 @@ Here are some ways of contributing to making Nhost better:
<br />
<sub><b>Helio Alves</b></sub>
</a>
</td>
</td></tr>
<tr>
<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></tr>
<tr>
</td>
<td align="center">
<a href="https://github.com/MelodicCrypter">
<img src="https://avatars.githubusercontent.com/u/18341500?v=4" width="100;" alt="MelodicCrypter"/>
@@ -357,6 +369,13 @@ Here are some ways of contributing to making Nhost better:
<sub><b>Jacob Duval</b></sub>
</a>
</td>
<td align="center">
<a href="https://github.com/kylehayes">
<img src="https://avatars.githubusercontent.com/u/509932?v=4" width="100;" alt="kylehayes"/>
<br />
<sub><b>Kyle Hayes</b></sub>
</a>
</td>
<td align="center">
<a href="https://github.com/leothorp">
<img src="https://avatars.githubusercontent.com/u/12928449?v=4" width="100;" alt="leothorp"/>
@@ -370,7 +389,8 @@ Here are some ways of contributing to making Nhost better:
<br />
<sub><b>Max Reynolds</b></sub>
</a>
</td>
</td></tr>
<tr>
<td align="center">
<a href="https://github.com/ghoshnirmalya">
<img src="https://avatars.githubusercontent.com/u/6391763?v=4" width="100;" alt="ghoshnirmalya"/>
@@ -384,8 +404,7 @@ Here are some ways of contributing to making Nhost better:
<br />
<sub><b>Quentin Decré</b></sub>
</a>
</td></tr>
<tr>
</td>
<td align="center">
<a href="https://github.com/atapas">
<img src="https://avatars.githubusercontent.com/u/3633137?v=4" width="100;" alt="atapas"/>

View File

@@ -20,7 +20,8 @@ module.exports = {
'tests/**/*.ts',
'tests/**/*.d.ts'
],
plugins: ['@typescript-eslint', 'simple-import-sort'],
plugins: ['@typescript-eslint', 'simple-import-sort', 'cypress'],
extends: ['plugin:cypress/recommended'],
parserOptions: {
ecmaVersion: 2020,
sourceType: 'module'
@@ -60,13 +61,5 @@ module.exports = {
allowAnonymousFunction: true
}
]
},
overrides: [
{
files: ['*.test.js', '*.spec.js', '*.test.ts', '*.spec.ts', '*.cy.js', '*.cy.ts'],
rules: {
'@typescript-eslint/no-unused-expressions': 'off'
}
}
]
}
}

View File

@@ -1,6 +1,12 @@
const base = require('./.eslint.base')
module.exports = {
...base,
extends: ['react-app', 'plugin:react/recommended', 'plugin:react-hooks/recommended'],
extends: [
...base.extends,
'react-app',
'plugin:react/recommended',
'plugin:react-hooks/recommended',
'plugin:react/jsx-runtime'
],
plugins: [...base.plugins, 'react', 'react-hooks']
}

View File

@@ -1,7 +1,7 @@
const base = require('./.eslint.base')
module.exports = {
...base,
extends: ['plugin:import/recommended', 'plugin:import/typescript'],
extends: [...base.extends, 'plugin:import/recommended', 'plugin:import/typescript'],
parser: 'vue-eslint-parser',
parserOptions: {
...base.parserOptions,

View File

@@ -60,11 +60,35 @@ The default role is used when no role is specified in the GraphQL request. By de
### Allowed Roles
Allowed roles are roles the user is allowed to use when making a GraphQL request. Usually you would change the role from `user` (the default role) to some other role because you want Hasura to use a different role to resolve permissions for a particular GraphQL request.
By default, users have two allowed roles:
- `user`
- `me`
You can manage what allowed roles users should get when they sign up under **Users** -> **Roles & Permissions**.
:::info
You must also add the roles manually to the `auth.roles` table.
:::
It's also possible to give users a subset of allowed roles during signup.
**Example:** Only give the `user` role (without the `me` role) for the user's allowed roles:
```js
await nhost.auth.signUp({
email: 'joe@example.com',
password: 'secret-password'
options: {
allowedRoles: ['user']
}
})
```
### Public Role
The `public` role is used to resolve GraphQL permissions for unauthenticated users.

View File

@@ -21,7 +21,10 @@ The database is managed via the Hasura Console where you can manage the database
Hasura Console is where you manage your database. This is where you create and manage tables, schemas, and data.
Open the Hasura Console by clicking on **Data** in the top menu in the Nhost Dashboard, copy the **admin secret**, and click **Open Hasura**. Use the **admin secret** to sign in.
1) Open the Hasura Console by clicking on **GraphQL** in the top menu in the Nhost Dashboard.
2) Click **Open Hasura Console** at the top right of the page.
3) Copy the **admin secret**, and click **Open Hasura**.
4) Use the **admin secret** to sign in.
<video width="99%" autoPlay muted loop controls="true">
<source src="/videos/open-hasura-console.mp4" type="video/mp4" />

View File

@@ -54,6 +54,18 @@ query {
}
```
### Local Custom Permission Variables
To use custom permission variables locally, add your claims to the `config.yml` as following:
```
auth:
jwt:
custom_claims: '{"organisation-id":"profile.organisation.id"}'
```
Your custom claim will be automatically prefixed with `x-hasura-`, therefore, the example above results in a custom permission variable named `x-hasura-organisation-id`.
## Roles
Every GraphQL request is resolved based on a **single role**. Roles are added in the Hasura Console when selecting a table and clicking **Permisisons**.

View File

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

View File

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

View File

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

View File

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

View File

@@ -4,7 +4,7 @@ title: changePassword()
sidebar_label: changePassword()
slug: /reference/javascript/auth/change-password
description: Use `nhost.auth.changePassword` to change the password for the user. The old password is not needed.
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L254
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L262
---
# `changePassword()`

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -4,7 +4,7 @@ title: HasuraAuthClient
sidebar_label: Auth
description: No description provided.
slug: /reference/javascript/auth
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L59
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/hasura-auth-client.ts#L60
---
# `HasuraAuthClient`

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -4,7 +4,7 @@ title: SignInParams
sidebar_label: SignInParams
description: No description provided.
displayed_sidebar: referenceSidebar
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/utils/types.ts#L78
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/utils/types.ts#L83
---
# `SignInParams`
@@ -12,6 +12,7 @@ custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-j
```ts
type SignInParams =
| SignInEmailPasswordParams
| SignInEmailPasswordOtpParams
| SignInPasswordlessEmailParams
| SignInPasswordlessSmsOtpParams
| SignInPasswordlessSmsParams

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -4,7 +4,7 @@ title: createClient()
sidebar_label: createClient()
slug: /reference/javascript/nhost-js/create-client
description: No description provided.
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/nhost-js/src/index.ts#L3
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/nhost-js/src/index.ts#L4
---
# `createClient()`
@@ -15,16 +15,18 @@ custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/nhost-js/src/
**<span className="parameter-name">config</span>** <span className="optional-status">required</span> [`NhostClientConstructorParams`](/reference/docgen/javascript/nhost-js/types/nhost-client-constructor-params)
| Property | Type | Required | Notes |
| :----------------------------------------------------------------------------------------------------- | :------------------ | :------: | :----------------------------------------------------------------------------------------------------------------------------------- |
| <span className="parameter-name"><span className="light-grey">config.</span>backendUrl</span> | `string` | ✔️ | Nhost backend URL. |
| <span className="parameter-name"><span className="light-grey">config.</span>refreshIntervalTime</span> | `number` | | Time interval until token refreshes, in seconds |
| <span className="parameter-name"><span className="light-grey">config.</span>clientStorageType</span> | `ClientStorageType` | | Define a way to get information about the refresh token and its exipration date. |
| <span className="parameter-name"><span className="light-grey">config.</span>clientStorage</span> | `ClientStorage` | | Object where the refresh token will be persisted and read locally. |
| <span className="parameter-name"><span className="light-grey">config.</span>autoRefreshToken</span> | `boolean` | | When set to true, will automatically refresh token before it expires |
| <span className="parameter-name"><span className="light-grey">config.</span>autoSignIn</span> | `boolean` | | When set to true, will parse the url on startup to check if it contains a refresh token to start the session with |
| <span className="parameter-name"><span className="light-grey">config.</span>devTools</span> | `boolean` | | Activate devTools e.g. the ability to connect to the xstate inspector |
| <span className="parameter-name"><span className="light-grey">config.</span>start</span> | `boolean` | | |
| <span className="parameter-name"><span className="light-grey">config.</span>adminSecret</span> | `string` | | Admin secret. When set, it is sent as an `x-hasura-admin-secret` header for all GraphQL, Storage, and Serverless Functions requests. |
| Property | Type | Required | Notes |
| :----------------------------------------------------------------------------------------------------- | :------------------ | :------: | :---------------------------------------------------------------------------------------------------------------------------- |
| <span className="parameter-name"><span className="light-grey">config.</span>refreshIntervalTime</span> | `number` | | Time interval until token refreshes, in seconds |
| <span className="parameter-name"><span className="light-grey">config.</span>clientStorageType</span> | `ClientStorageType` | | Define a way to get information about the refresh token and its exipration date. |
| <span className="parameter-name"><span className="light-grey">config.</span>clientStorage</span> | `ClientStorage` | | Object where the refresh token will be persisted and read locally. |
| <span className="parameter-name"><span className="light-grey">config.</span>autoRefreshToken</span> | `boolean` | | When set to true, will automatically refresh token before it expires |
| <span className="parameter-name"><span className="light-grey">config.</span>autoSignIn</span> | `boolean` | | When set to true, will parse the url on startup to check if it contains a refresh token to start the session with |
| <span className="parameter-name"><span className="light-grey">config.</span>devTools</span> | `boolean` | | Activate devTools e.g. the ability to connect to the xstate inspector |
| <span className="parameter-name"><span className="light-grey">config.</span>start</span> | `boolean` | | |
| <span className="parameter-name"><span className="light-grey">config.</span>backendUrl</span> | `string` | | Nhost backend URL Should only be used when self-hosting |
| <span className="parameter-name"><span className="light-grey">config.</span>adminSecret</span> | `string` | | When set, the admin secret is sent as a header, `x-hasura-admin-secret`, for all requests to GraphQL, Storage, and Functions. |
| <span className="parameter-name"><span className="light-grey">config.</span>subdomain</span> | `string` | | App subdomain (e.g, ieingiwnginwnfnegqwvdqwdwq) Should be used when using the Nhost platform Use "localhost" in development |
| <span className="parameter-name"><span className="light-grey">config.</span>region</span> | `string` | | App region (e.g., eu-central-1) Not required in development (when `subdomain` is "localhost") |
---

View File

@@ -4,29 +4,35 @@ title: NhostClient
sidebar_label: NhostClient
description: No description provided.
slug: /reference/javascript/nhost-js/nhost-client
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/nhost-js/src/core/nhost-client.ts#L19
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/nhost-js/src/core/nhost-client.ts#L9
---
# `NhostClient`
Nhost Client
```ts
const nhost = new NhostClient({ subdomain, region })
```
## Parameters
---
**<span className="parameter-name">\_\_namedParameters</span>** <span className="optional-status">required</span> [`NhostClientConstructorParams`](/reference/docgen/javascript/nhost-js/types/nhost-client-constructor-params)
| Property | Type | Required | Notes |
| :------------------------------------------------------------------------------------------------------------------ | :------------------ | :------: | :----------------------------------------------------------------------------------------------------------------------------------- |
| <span className="parameter-name"><span className="light-grey">\_\_namedParameters.</span>backendUrl</span> | `string` | ✔️ | Nhost backend URL. |
| <span className="parameter-name"><span className="light-grey">\_\_namedParameters.</span>adminSecret</span> | `string` | | Admin secret. When set, it is sent as an `x-hasura-admin-secret` header for all GraphQL, Storage, and Serverless Functions requests. |
| <span className="parameter-name"><span className="light-grey">\_\_namedParameters.</span>start</span> | `boolean` | | |
| <span className="parameter-name"><span className="light-grey">\_\_namedParameters.</span>devTools</span> | `boolean` | | Activate devTools e.g. the ability to connect to the xstate inspector |
| <span className="parameter-name"><span className="light-grey">\_\_namedParameters.</span>autoSignIn</span> | `boolean` | | When set to true, will parse the url on startup to check if it contains a refresh token to start the session with |
| <span className="parameter-name"><span className="light-grey">\_\_namedParameters.</span>autoRefreshToken</span> | `boolean` | | When set to true, will automatically refresh token before it expires |
| <span className="parameter-name"><span className="light-grey">\_\_namedParameters.</span>clientStorage</span> | `ClientStorage` | | Object where the refresh token will be persisted and read locally. |
| <span className="parameter-name"><span className="light-grey">\_\_namedParameters.</span>clientStorageType</span> | `ClientStorageType` | | Define a way to get information about the refresh token and its exipration date. |
| <span className="parameter-name"><span className="light-grey">\_\_namedParameters.</span>refreshIntervalTime</span> | `number` | | Time interval until token refreshes, in seconds |
| Property | Type | Required | Notes |
| :------------------------------------------------------------------------------------------------------------------ | :------------------ | :------: | :---------------------------------------------------------------------------------------------------------------------------- |
| <span className="parameter-name"><span className="light-grey">\_\_namedParameters.</span>region</span> | `string` | | App region (e.g., eu-central-1) Not required in development (when `subdomain` is "localhost") |
| <span className="parameter-name"><span className="light-grey">\_\_namedParameters.</span>subdomain</span> | `string` | | App subdomain (e.g, ieingiwnginwnfnegqwvdqwdwq) Should be used when using the Nhost platform Use "localhost" in development |
| <span className="parameter-name"><span className="light-grey">\_\_namedParameters.</span>adminSecret</span> | `string` | | When set, the admin secret is sent as a header, `x-hasura-admin-secret`, for all requests to GraphQL, Storage, and Functions. |
| <span className="parameter-name"><span className="light-grey">\_\_namedParameters.</span>backendUrl</span> | `string` | | Nhost backend URL Should only be used when self-hosting |
| <span className="parameter-name"><span className="light-grey">\_\_namedParameters.</span>start</span> | `boolean` | | |
| <span className="parameter-name"><span className="light-grey">\_\_namedParameters.</span>devTools</span> | `boolean` | | Activate devTools e.g. the ability to connect to the xstate inspector |
| <span className="parameter-name"><span className="light-grey">\_\_namedParameters.</span>autoSignIn</span> | `boolean` | | When set to true, will parse the url on startup to check if it contains a refresh token to start the session with |
| <span className="parameter-name"><span className="light-grey">\_\_namedParameters.</span>autoRefreshToken</span> | `boolean` | | When set to true, will automatically refresh token before it expires |
| <span className="parameter-name"><span className="light-grey">\_\_namedParameters.</span>clientStorage</span> | `ClientStorage` | | Object where the refresh token will be persisted and read locally. |
| <span className="parameter-name"><span className="light-grey">\_\_namedParameters.</span>clientStorageType</span> | `ClientStorageType` | | Define a way to get information about the refresh token and its exipration date. |
| <span className="parameter-name"><span className="light-grey">\_\_namedParameters.</span>refreshIntervalTime</span> | `number` | | Time interval until token refreshes, in seconds |
---

View File

@@ -0,0 +1,14 @@
---
# ⚠️ AUTO-GENERATED CONTENT. DO NOT EDIT THIS FILE DIRECTLY! ⚠️
title: BackendOrSubdomain
sidebar_label: BackendOrSubdomain
description: No description provided.
displayed_sidebar: referenceSidebar
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/nhost-js/src/utils/types.ts#L40
---
# `BackendOrSubdomain`
```ts
type BackendOrSubdomain = BackendUrl | Subdomain
```

View File

@@ -0,0 +1,14 @@
---
# ⚠️ AUTO-GENERATED CONTENT. DO NOT EDIT THIS FILE DIRECTLY! ⚠️
title: BackendUrl
sidebar_label: BackendUrl
description: No description provided.
displayed_sidebar: referenceSidebar
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/nhost-js/src/utils/types.ts#L7
---
# `BackendUrl`
```ts
type BackendUrl = () => { backendUrl: string; adminSecret: string }
```

View File

@@ -0,0 +1,16 @@
---
# ⚠️ AUTO-GENERATED CONTENT. DO NOT EDIT THIS FILE DIRECTLY! ⚠️
title: FunctionCallResponse
sidebar_label: FunctionCallResponse
description: No description provided.
displayed_sidebar: referenceSidebar
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/nhost-js/src/utils/types.ts#L57
---
# `FunctionCallResponse`
```ts
type FunctionCallResponse =
| { res: AxiosResponse<T>; error: null }
| { res: null; error: Error }
```

View File

@@ -0,0 +1,16 @@
---
# ⚠️ AUTO-GENERATED CONTENT. DO NOT EDIT THIS FILE DIRECTLY! ⚠️
title: GraphqlRequestResponse
sidebar_label: GraphqlRequestResponse
description: No description provided.
displayed_sidebar: referenceSidebar
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/nhost-js/src/utils/types.ts#L47
---
# `GraphqlRequestResponse`
```ts
type GraphqlRequestResponse =
| { data: null; error: Error | object | Array<object> }
| { data: T; error: null }
```

View File

@@ -0,0 +1,22 @@
---
# ⚠️ AUTO-GENERATED CONTENT. DO NOT EDIT THIS FILE DIRECTLY! ⚠️
title: GraphqlResponse
sidebar_label: GraphqlResponse
description: No description provided.
displayed_sidebar: referenceSidebar
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/nhost-js/src/utils/types.ts#L67
---
# `GraphqlResponse`
## Parameters
---
**<span className="parameter-name">errors</span>** <span className="optional-status">optional</span> `Array<object>`
---
**<span className="parameter-name">data</span>** <span className="optional-status">optional</span> `T`
---

View File

@@ -0,0 +1,74 @@
---
# ⚠️ AUTO-GENERATED CONTENT. DO NOT EDIT THIS FILE DIRECTLY! ⚠️
title: NhostAuthConstructorParams
sidebar_label: NhostAuthConstructorParams
description: No description provided.
displayed_sidebar: referenceSidebar
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-auth-js/src/utils/types.ts#L15
---
# `NhostAuthConstructorParams`
## Parameters
---
**<span className="parameter-name">refreshIntervalTime</span>** <span className="optional-status">optional</span> `number`
Time interval until token refreshes, in seconds
---
**<span className="parameter-name">clientStorageType</span>** <span className="optional-status">optional</span> `ClientStorageType`
Define a way to get information about the refresh token and its exipration date.
**`@default`**
`web`
---
**<span className="parameter-name">clientStorage</span>** <span className="optional-status">optional</span> `ClientStorage`
Object where the refresh token will be persisted and read locally.
Recommended values:
- `'web'` and `'cookies'`: no value is required
- `'react-native'`: `import Storage from @react-native-async-storage/async-storage`
- `'cookies'`: `localStorage`
- `'custom'`: an object that defines the following methods:
- `setItem` or `setItemAsync`
- `getItem` or `getItemAsync`
- `removeItem`
- `'capacitor'`: `import { Storage } from @capacitor/storage`
- `'expo-secure-store'`: `import * as SecureStore from 'expo-secure-store'`
---
**<span className="parameter-name">autoRefreshToken</span>** <span className="optional-status">optional</span> `boolean`
When set to true, will automatically refresh token before it expires
---
**<span className="parameter-name">autoSignIn</span>** <span className="optional-status">optional</span> `boolean`
When set to true, will parse the url on startup to check if it contains a refresh token to start the session with
---
**<span className="parameter-name">devTools</span>** <span className="optional-status">optional</span> `boolean`
Activate devTools e.g. the ability to connect to the xstate inspector
---
**<span className="parameter-name">url</span>** <span className="optional-status">required</span> `string`
---
**<span className="parameter-name">start</span>** <span className="optional-status">optional</span> `boolean`
---

View File

@@ -4,7 +4,7 @@ title: NhostClientConstructorParams
sidebar_label: NhostClientConstructorParams
description: No description provided.
displayed_sidebar: referenceSidebar
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/nhost-js/src/core/nhost-client.ts#L7
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/nhost-js/src/utils/types.ts#L42
---
# `NhostClientConstructorParams`
@@ -13,12 +13,6 @@ custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/nhost-js/src/
---
**<span className="parameter-name">backendUrl</span>** <span className="optional-status">required</span> `string`
Nhost backend URL.
---
**<span className="parameter-name">refreshIntervalTime</span>** <span className="optional-status">optional</span> `number`
Time interval until token refreshes, in seconds
@@ -75,9 +69,31 @@ Activate devTools e.g. the ability to connect to the xstate inspector
---
**<span className="parameter-name">adminSecret</span>** <span className="optional-status">optional</span> `string`
**<span className="parameter-name">backendUrl</span>** <span className="optional-status">optional</span> `string`
Admin secret. When set, it is sent as an `x-hasura-admin-secret` header for all
GraphQL, Storage, and Serverless Functions requests.
Nhost backend URL
Should only be used when self-hosting
---
**<span className="parameter-name">adminSecret</span>** <span className="optional-status">optional</span> `string`
When set, the admin secret is sent as a header, `x-hasura-admin-secret`,
for all requests to GraphQL, Storage, and Functions.
---
**<span className="parameter-name">subdomain</span>** <span className="optional-status">optional</span> `string`
App subdomain (e.g, ieingiwnginwnfnegqwvdqwdwq)
Should be used when using the Nhost platform
Use "localhost" in development
---
**<span className="parameter-name">region</span>** <span className="optional-status">optional</span> `string`
App region (e.g., eu-central-1)
Not required in development (when `subdomain` is "localhost")
---

View File

@@ -0,0 +1,18 @@
---
# ⚠️ AUTO-GENERATED CONTENT. DO NOT EDIT THIS FILE DIRECTLY! ⚠️
title: Subdomain
sidebar_label: Subdomain
description: No description provided.
displayed_sidebar: referenceSidebar
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/nhost-js/src/utils/types.ts#L20
---
# `Subdomain`
```ts
type Subdomain = () => {
subdomain: string
region: string
adminSecret: string
}
```

View File

@@ -4,7 +4,7 @@ title: NhostClient
sidebar_label: NhostClient
description: No description provided.
slug: /reference/nextjs/nhost-client
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/nextjs/src/index.ts#L17
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/nextjs/src/index.ts#L30
---
# `NhostClient`
@@ -15,13 +15,15 @@ custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/nextjs/src/in
**<span className="parameter-name">params</span>** <span className="optional-status">required</span> [`NhostNextClientConstructorParams`](/reference/docgen/nextjs/types/nhost-next-client-constructor-params)
| Property | Type | Required | Notes |
| :----------------------------------------------------------------------------------------------------- | :-------- | :------: | :----------------------------------------------------------------------------------------------------------------------------------- |
| <span className="parameter-name"><span className="light-grey">params.</span>backendUrl</span> | `string` | ✔️ | Nhost backend URL. |
| <span className="parameter-name"><span className="light-grey">params.</span>adminSecret</span> | `string` | | Admin secret. When set, it is sent as an `x-hasura-admin-secret` header for all GraphQL, Storage, and Serverless Functions requests. |
| <span className="parameter-name"><span className="light-grey">params.</span>devTools</span> | `boolean` | | Activate devTools e.g. the ability to connect to the xstate inspector |
| <span className="parameter-name"><span className="light-grey">params.</span>autoSignIn</span> | `boolean` | | When set to true, will parse the url on startup to check if it contains a refresh token to start the session with |
| <span className="parameter-name"><span className="light-grey">params.</span>autoRefreshToken</span> | `boolean` | | When set to true, will automatically refresh token before it expires |
| <span className="parameter-name"><span className="light-grey">params.</span>refreshIntervalTime</span> | `number` | | Time interval until token refreshes, in seconds |
| Property | Type | Required | Notes |
| :----------------------------------------------------------------------------------------------------- | :-------- | :------: | :---------------------------------------------------------------------------------------------------------------------------- |
| <span className="parameter-name"><span className="light-grey">params.</span>region</span> | `string` | | App region (e.g., eu-central-1) Not required in development (when `subdomain` is "localhost") |
| <span className="parameter-name"><span className="light-grey">params.</span>subdomain</span> | `string` | | App subdomain (e.g, ieingiwnginwnfnegqwvdqwdwq) Should be used when using the Nhost platform Use "localhost" in development |
| <span className="parameter-name"><span className="light-grey">params.</span>adminSecret</span> | `string` | | When set, the admin secret is sent as a header, `x-hasura-admin-secret`, for all requests to GraphQL, Storage, and Functions. |
| <span className="parameter-name"><span className="light-grey">params.</span>backendUrl</span> | `string` | | Nhost backend URL Should only be used when self-hosting |
| <span className="parameter-name"><span className="light-grey">params.</span>devTools</span> | `boolean` | | Activate devTools e.g. the ability to connect to the xstate inspector |
| <span className="parameter-name"><span className="light-grey">params.</span>autoSignIn</span> | `boolean` | | When set to true, will parse the url on startup to check if it contains a refresh token to start the session with |
| <span className="parameter-name"><span className="light-grey">params.</span>autoRefreshToken</span> | `boolean` | | When set to true, will automatically refresh token before it expires |
| <span className="parameter-name"><span className="light-grey">params.</span>refreshIntervalTime</span> | `number` | | Time interval until token refreshes, in seconds |
---

View File

@@ -4,7 +4,7 @@ title: useSignInEmailPassword()
sidebar_label: useSignInEmailPassword()
slug: /reference/nextjs/use-sign-in-email-password
description: Use the hook `useSignInEmailPassword` to sign in a user using email and password.
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/react/src/useSignInEmailPassword.ts#L49
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/react/src/useSignInEmailPassword.ts#L54
---
# `useSignInEmailPassword()`

View File

@@ -4,7 +4,7 @@ title: NhostNextClientConstructorParams
sidebar_label: NhostNextClientConstructorParams
description: No description provided.
displayed_sidebar: referenceSidebar
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/nextjs/src/index.ts#L11
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/nextjs/src/index.ts#L16
---
# `NhostNextClientConstructorParams`
@@ -13,16 +13,32 @@ custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/nextjs/src/in
---
**<span className="parameter-name">backendUrl</span>** <span className="optional-status">required</span> `string`
**<span className="parameter-name">region</span>** <span className="optional-status">optional</span> `string`
Nhost backend URL.
App region (e.g., eu-central-1)
Not required in development (when `subdomain` is "localhost")
---
**<span className="parameter-name">subdomain</span>** <span className="optional-status">optional</span> `string`
App subdomain (e.g, ieingiwnginwnfnegqwvdqwdwq)
Should be used when using the Nhost platform
Use "localhost" in development
---
**<span className="parameter-name">adminSecret</span>** <span className="optional-status">optional</span> `string`
Admin secret. When set, it is sent as an `x-hasura-admin-secret` header for all
GraphQL, Storage, and Serverless Functions requests.
When set, the admin secret is sent as a header, `x-hasura-admin-secret`,
for all requests to GraphQL, Storage, and Functions.
---
**<span className="parameter-name">backendUrl</span>** <span className="optional-status">optional</span> `string`
Nhost backend URL
Should only be used when self-hosting
---

View File

@@ -4,7 +4,7 @@ title: NhostReactClientConstructorParams
sidebar_label: NhostReactClientConstructorParams
description: No description provided.
displayed_sidebar: referenceSidebar
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/react/src/client.ts#L3
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/react/src/client.ts#L5
---
# `NhostReactClientConstructorParams`
@@ -65,15 +65,31 @@ Activate devTools e.g. the ability to connect to the xstate inspector
---
**<span className="parameter-name">backendUrl</span>** <span className="optional-status">required</span> `string`
**<span className="parameter-name">backendUrl</span>** <span className="optional-status">optional</span> `string`
Nhost backend URL.
Nhost backend URL
Should only be used when self-hosting
---
**<span className="parameter-name">adminSecret</span>** <span className="optional-status">optional</span> `string`
Admin secret. When set, it is sent as an `x-hasura-admin-secret` header for all
GraphQL, Storage, and Serverless Functions requests.
When set, the admin secret is sent as a header, `x-hasura-admin-secret`,
for all requests to GraphQL, Storage, and Functions.
---
**<span className="parameter-name">subdomain</span>** <span className="optional-status">optional</span> `string`
App subdomain (e.g, ieingiwnginwnfnegqwvdqwdwq)
Should be used when using the Nhost platform
Use "localhost" in development
---
**<span className="parameter-name">region</span>** <span className="optional-status">optional</span> `string`
App region (e.g., eu-central-1)
Not required in development (when `subdomain` is "localhost")
---

View File

@@ -4,7 +4,7 @@ title: SignInEmailPasswordHookResult
sidebar_label: SignInEmailPasswordHookResult
description: No description provided.
displayed_sidebar: referenceSidebar
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/react/src/useSignInEmailPassword.ts#L19
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/react/src/useSignInEmailPassword.ts#L24
---
# `SignInEmailPasswordHookResult`

View File

@@ -4,7 +4,7 @@ title: NhostClient
sidebar_label: NhostClient
description: No description provided.
slug: /reference/react/nhost-client
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/react/src/client.ts#L6
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/react/src/client.ts#L10
---
# `NhostClient`
@@ -15,15 +15,17 @@ custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/react/src/cli
**<span className="parameter-name">params</span>** <span className="optional-status">required</span> [`NhostReactClientConstructorParams`](/reference/docgen/react/types/nhost-react-client-constructor-params)
| Property | Type | Required | Notes |
| :----------------------------------------------------------------------------------------------------- | :------------------ | :------: | :----------------------------------------------------------------------------------------------------------------------------------- |
| <span className="parameter-name"><span className="light-grey">params.</span>backendUrl</span> | `string` | ✔️ | Nhost backend URL. |
| <span className="parameter-name"><span className="light-grey">params.</span>adminSecret</span> | `string` | | Admin secret. When set, it is sent as an `x-hasura-admin-secret` header for all GraphQL, Storage, and Serverless Functions requests. |
| <span className="parameter-name"><span className="light-grey">params.</span>devTools</span> | `boolean` | | Activate devTools e.g. the ability to connect to the xstate inspector |
| <span className="parameter-name"><span className="light-grey">params.</span>autoSignIn</span> | `boolean` | | When set to true, will parse the url on startup to check if it contains a refresh token to start the session with |
| <span className="parameter-name"><span className="light-grey">params.</span>autoRefreshToken</span> | `boolean` | | When set to true, will automatically refresh token before it expires |
| <span className="parameter-name"><span className="light-grey">params.</span>clientStorage</span> | `ClientStorage` | | Object where the refresh token will be persisted and read locally. |
| <span className="parameter-name"><span className="light-grey">params.</span>clientStorageType</span> | `ClientStorageType` | | Define a way to get information about the refresh token and its exipration date. |
| <span className="parameter-name"><span className="light-grey">params.</span>refreshIntervalTime</span> | `number` | | Time interval until token refreshes, in seconds |
| Property | Type | Required | Notes |
| :----------------------------------------------------------------------------------------------------- | :------------------ | :------: | :---------------------------------------------------------------------------------------------------------------------------- |
| <span className="parameter-name"><span className="light-grey">params.</span>region</span> | `string` | | App region (e.g., eu-central-1) Not required in development (when `subdomain` is "localhost") |
| <span className="parameter-name"><span className="light-grey">params.</span>subdomain</span> | `string` | | App subdomain (e.g, ieingiwnginwnfnegqwvdqwdwq) Should be used when using the Nhost platform Use "localhost" in development |
| <span className="parameter-name"><span className="light-grey">params.</span>adminSecret</span> | `string` | | When set, the admin secret is sent as a header, `x-hasura-admin-secret`, for all requests to GraphQL, Storage, and Functions. |
| <span className="parameter-name"><span className="light-grey">params.</span>backendUrl</span> | `string` | | Nhost backend URL Should only be used when self-hosting |
| <span className="parameter-name"><span className="light-grey">params.</span>devTools</span> | `boolean` | | Activate devTools e.g. the ability to connect to the xstate inspector |
| <span className="parameter-name"><span className="light-grey">params.</span>autoSignIn</span> | `boolean` | | When set to true, will parse the url on startup to check if it contains a refresh token to start the session with |
| <span className="parameter-name"><span className="light-grey">params.</span>autoRefreshToken</span> | `boolean` | | When set to true, will automatically refresh token before it expires |
| <span className="parameter-name"><span className="light-grey">params.</span>clientStorage</span> | `ClientStorage` | | Object where the refresh token will be persisted and read locally. |
| <span className="parameter-name"><span className="light-grey">params.</span>clientStorageType</span> | `ClientStorageType` | | Define a way to get information about the refresh token and its exipration date. |
| <span className="parameter-name"><span className="light-grey">params.</span>refreshIntervalTime</span> | `number` | | Time interval until token refreshes, in seconds |
---

View File

@@ -4,7 +4,7 @@ title: useSignInEmailPassword()
sidebar_label: useSignInEmailPassword()
slug: /reference/react/use-sign-in-email-password
description: Use the hook `useSignInEmailPassword` to sign in a user using email and password.
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/react/src/useSignInEmailPassword.ts#L49
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/react/src/useSignInEmailPassword.ts#L54
---
# `useSignInEmailPassword()`

View File

@@ -4,7 +4,7 @@ title: NhostReactClientConstructorParams
sidebar_label: NhostReactClientConstructorParams
description: No description provided.
displayed_sidebar: referenceSidebar
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/react/src/client.ts#L3
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/react/src/client.ts#L5
---
# `NhostReactClientConstructorParams`
@@ -13,16 +13,32 @@ custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/react/src/cli
---
**<span className="parameter-name">backendUrl</span>** <span className="optional-status">required</span> `string`
**<span className="parameter-name">region</span>** <span className="optional-status">optional</span> `string`
Nhost backend URL.
App region (e.g., eu-central-1)
Not required in development (when `subdomain` is "localhost")
---
**<span className="parameter-name">subdomain</span>** <span className="optional-status">optional</span> `string`
App subdomain (e.g, ieingiwnginwnfnegqwvdqwdwq)
Should be used when using the Nhost platform
Use "localhost" in development
---
**<span className="parameter-name">adminSecret</span>** <span className="optional-status">optional</span> `string`
Admin secret. When set, it is sent as an `x-hasura-admin-secret` header for all
GraphQL, Storage, and Serverless Functions requests.
When set, the admin secret is sent as a header, `x-hasura-admin-secret`,
for all requests to GraphQL, Storage, and Functions.
---
**<span className="parameter-name">backendUrl</span>** <span className="optional-status">optional</span> `string`
Nhost backend URL
Should only be used when self-hosting
---

View File

@@ -4,7 +4,7 @@ title: SignInEmailPasswordHookResult
sidebar_label: SignInEmailPasswordHookResult
description: No description provided.
displayed_sidebar: referenceSidebar
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/react/src/useSignInEmailPassword.ts#L19
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/react/src/useSignInEmailPassword.ts#L24
---
# `SignInEmailPasswordHookResult`

View File

@@ -4,7 +4,7 @@ title: NhostClient
sidebar_label: NhostClient
description: No description provided.
slug: /reference/vue/nhost-client
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/vue/src/client.ts#L10
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/vue/src/client.ts#L18
---
# `NhostClient`
@@ -15,15 +15,17 @@ custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/vue/src/clien
**<span className="parameter-name">params</span>** <span className="optional-status">required</span> [`NhostVueClientConstructorParams`](/reference/docgen/vue/types/nhost-vue-client-constructor-params)
| Property | Type | Required | Notes |
| :----------------------------------------------------------------------------------------------------- | :------------------ | :------: | :----------------------------------------------------------------------------------------------------------------------------------- |
| <span className="parameter-name"><span className="light-grey">params.</span>backendUrl</span> | `string` | ✔️ | Nhost backend URL. |
| <span className="parameter-name"><span className="light-grey">params.</span>adminSecret</span> | `string` | | Admin secret. When set, it is sent as an `x-hasura-admin-secret` header for all GraphQL, Storage, and Serverless Functions requests. |
| <span className="parameter-name"><span className="light-grey">params.</span>devTools</span> | `boolean` | | Activate devTools e.g. the ability to connect to the xstate inspector |
| <span className="parameter-name"><span className="light-grey">params.</span>autoSignIn</span> | `boolean` | | When set to true, will parse the url on startup to check if it contains a refresh token to start the session with |
| <span className="parameter-name"><span className="light-grey">params.</span>autoRefreshToken</span> | `boolean` | | When set to true, will automatically refresh token before it expires |
| <span className="parameter-name"><span className="light-grey">params.</span>clientStorage</span> | `ClientStorage` | | Object where the refresh token will be persisted and read locally. |
| <span className="parameter-name"><span className="light-grey">params.</span>clientStorageType</span> | `ClientStorageType` | | Define a way to get information about the refresh token and its exipration date. |
| <span className="parameter-name"><span className="light-grey">params.</span>refreshIntervalTime</span> | `number` | | Time interval until token refreshes, in seconds |
| Property | Type | Required | Notes |
| :----------------------------------------------------------------------------------------------------- | :------------------ | :------: | :---------------------------------------------------------------------------------------------------------------------------- |
| <span className="parameter-name"><span className="light-grey">params.</span>region</span> | `string` | | App region (e.g., eu-central-1) Not required in development (when `subdomain` is "localhost") |
| <span className="parameter-name"><span className="light-grey">params.</span>subdomain</span> | `string` | | App subdomain (e.g, ieingiwnginwnfnegqwvdqwdwq) Should be used when using the Nhost platform Use "localhost" in development |
| <span className="parameter-name"><span className="light-grey">params.</span>adminSecret</span> | `string` | | When set, the admin secret is sent as a header, `x-hasura-admin-secret`, for all requests to GraphQL, Storage, and Functions. |
| <span className="parameter-name"><span className="light-grey">params.</span>backendUrl</span> | `string` | | Nhost backend URL Should only be used when self-hosting |
| <span className="parameter-name"><span className="light-grey">params.</span>devTools</span> | `boolean` | | Activate devTools e.g. the ability to connect to the xstate inspector |
| <span className="parameter-name"><span className="light-grey">params.</span>autoSignIn</span> | `boolean` | | When set to true, will parse the url on startup to check if it contains a refresh token to start the session with |
| <span className="parameter-name"><span className="light-grey">params.</span>autoRefreshToken</span> | `boolean` | | When set to true, will automatically refresh token before it expires |
| <span className="parameter-name"><span className="light-grey">params.</span>clientStorage</span> | `ClientStorage` | | Object where the refresh token will be persisted and read locally. |
| <span className="parameter-name"><span className="light-grey">params.</span>clientStorageType</span> | `ClientStorageType` | | Define a way to get information about the refresh token and its exipration date. |
| <span className="parameter-name"><span className="light-grey">params.</span>refreshIntervalTime</span> | `number` | | Time interval until token refreshes, in seconds |
---

View File

@@ -12,7 +12,9 @@ custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/vue/src/useRe
Use the composable `useResetPassword` to reset the password for a user. This will send a reset password link in an email to the user. When the user clicks on the reset-password link the user is automatically signed in and can change their password using the composable `useChangePassword`.
```tsx
const { resetPassword, isLoading, isSent, isError, error } = useResetPassword()
const { resetPassword, isLoading, isSent, isError, error } = useResetPassword({
redirectTo: 'http://localhost:3000/settings/change-password'
})
watchEffect(() => {
console.log(isLoading.value, isSent.value, isError.value, error.value)
@@ -21,9 +23,7 @@ watchEffect(() => {
const handleFormSubmit = async (e) => {
e.preventDefault()
await resetPassword('joe@example.com', {
redirectTo: 'http://localhost:3000/settings/change-password'
})
await resetPassword('joe@example.com')
}
```

View File

@@ -4,7 +4,7 @@ title: useSignInEmailPassword()
sidebar_label: useSignInEmailPassword()
slug: /reference/vue/use-sign-in-email-password
description: Use the composable `useSignInEmailPassword` to sign in a user using email and password.
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/vue/src/useSignInEmailPassword.ts#L44
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/vue/src/useSignInEmailPassword.ts#L46
---
# `useSignInEmailPassword()`

View File

@@ -4,7 +4,7 @@ title: NhostVueClientConstructorParams
sidebar_label: NhostVueClientConstructorParams
description: No description provided.
displayed_sidebar: referenceSidebar
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/vue/src/client.ts#L7
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/vue/src/client.ts#L13
---
# `NhostVueClientConstructorParams`
@@ -13,16 +13,32 @@ custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/vue/src/clien
---
**<span className="parameter-name">backendUrl</span>** <span className="optional-status">required</span> `string`
**<span className="parameter-name">region</span>** <span className="optional-status">optional</span> `string`
Nhost backend URL.
App region (e.g., eu-central-1)
Not required in development (when `subdomain` is "localhost")
---
**<span className="parameter-name">subdomain</span>** <span className="optional-status">optional</span> `string`
App subdomain (e.g, ieingiwnginwnfnegqwvdqwdwq)
Should be used when using the Nhost platform
Use "localhost" in development
---
**<span className="parameter-name">adminSecret</span>** <span className="optional-status">optional</span> `string`
Admin secret. When set, it is sent as an `x-hasura-admin-secret` header for all
GraphQL, Storage, and Serverless Functions requests.
When set, the admin secret is sent as a header, `x-hasura-admin-secret`,
for all requests to GraphQL, Storage, and Functions.
---
**<span className="parameter-name">backendUrl</span>** <span className="optional-status">optional</span> `string`
Nhost backend URL
Should only be used when self-hosting
---

View File

@@ -1,4 +0,0 @@
{
"label": "Hasura Auth",
"position": 5
}

View File

@@ -1,8 +0,0 @@
---
title: 'API Reference'
sidebar_position: 5
---
import { Swagger } from '@site/src/components/Swagger';
<Swagger spec="hasura-auth.json" />

View File

@@ -1,222 +0,0 @@
---
title: Configuration
sidebar_position: 2
---
## Email configuration
Hasura Auth automatically sends transactional emails to manage the following operations:
- Sign up
- Password reset
- Email change
- Passwordless with emails
### SMTP settings
```bash
AUTH_SMTP_HOST=smtp.example.com
AUTH_SMTP_PORT=1025
AUTH_SMTP_USER=user
AUTH_SMTP_PASS=password
AUTH_SMTP_SENDER=hasura-auth@example.com
```
See the [environment variables](/reference/hasura-auth/environment-variables) for additional information about how to connnect to an SMTP server.
### Email templates
You can create your own templates to customize the emails that will be sent to the users. You can have a look at the [official email templates](https://github.com/nhost/hasura-auth/tree/main/email-templates) to understand how they are structured.
#### With Docker
When using Docker, you can mount your own email templates from the local file system. You can have a look at this [docker-compose example](https://github.com/nhost/hasura-auth/blob/16df3e84b6c9a4f888b2ff07bd85afc34f8ed051/docker-compose-example.yaml#L41) to see how to set it up.
#### Remote email templates
When running Hasura Auth in its own infrastructure, it is possible to mount a volume with custom `email-templates` directory. However, in some cases, we may want to fetch templates from an external HTTP endpoint. Hence the introduction of a new `AUTH_EMAIL_TEMPLATE_FETCH_URL` environment variable:
```bash
AUTH_EMAIL_TEMPLATE_FETCH_URL=https://github.com/nhost/nhost/tree/custom-email-templates-example/examples/custom-email-templates
```
In the above example, on every email creation, the server will use this URL to fetch its templates, depending on the locale, email type and field.
For instance, the template for english verification email body will the fetched in [https://raw.githubusercontent.com/nhost/nhost/main/examples/custom-email-templates/en/email-verify/body.html](https://raw.githubusercontent.com/nhost/nhost/main/examples/custom-email-templates/en/email-verify/body.html).
See the [example in the main nhost/nhost repository](https://github.com/nhost/nhost/tree/main/examples/custom-email-templates).
The context variables in email templates have been simplified: the `${link}` variable contains the entire redirection url the recipient needs to follow.
---
## Redirections
Some authentication operations redirects the users to the frontend application:
- After an OAuth provider completes or fails authentication, the user is redirected to the frontend
- Every email sent to the user (passwordless with email, password/email change, password reset) contains a link, that redirects the user to the frontend
In order to achieve that, you need to set the `AUTH_CLIENT_URL` environment variable, for instance:
```bash
AUTH_CLIENT_URL=https://my-app.vercel.com
```
---
## Email + password authentication
### Email checks
You can specify a list of allowed emails or domains with `AUTH_ACCESS_CONTROL_ALLOWED_EMAILS` and `AUTH_ACCESS_CONTROL_ALLOWED_EMAIL_DOMAINS`.
As an example, the following environment variables will only allow `@nhost.io`, `@example.com` and `bob@smith.com` to register to the application:
```bash
AUTH_ACCESS_CONTROL_ALLOWED_EMAILS=bob@smith.com
AUTH_ACCESS_CONTROL_ALLOWED_EMAIL_DOMAINS=nhost.io,example.com
```
In the above example, users with the following emails would be able to register `bob@smith.com`, `emma@example.com`, `john@nhost.io`, whereas `mary@firebase.com` won't.
Similarly, it is possible to provide a list of forbidden emails or domains with `AUTH_ACCESS_CONTROL_BLOCKED_EMAILS` and `AUTH_ACCESS_CONTROL_BLOCKED_EMAIL_DOMAINS`.
### Password checks
Hasura auth does not accepts passwords with less than three characters. This limit can be changed in changing the `AUTH_PASSWORD_MIN_LENGTH` environment variable.
It is also possible to only allow [passwords that have not been pwned](https://haveibeenpwned.com/) in setting `AUTH_PASSWORD_HIBP_ENABLED` to `true`.
<!-- TODO ### Change -->
<!-- TODO ### Reset email -->
<!-- TODO ### Reset password -->
<!-- ---
TODO ## Anonymous users -->
---
## Multi-factor authentication
Hasura Auth supports different types of Multi-Factor Authentication (MFA): passwordless with emails (magic links), passwordless with SMS, and Time-based one-time passwords.
### Passwordless with emails (magic links)
Hasura Auth supports email [passwordless authentication](https://en.wikipedia.org/wiki/Passwordless_authentication). It requires [SMTP](#email-configuration) to be configured properly.
Set `AUTH_EMAIL_PASSWORDLESS_ENABLED` to `true` to enable passwordless authentication.
<!-- TODO ### Passwordless with SMS -->
### Time-based one-time password (TOTP)
It is possible to add a step to authentication with email and password authentication. Once users registered, they can activate MFA TOTP:
1. Users generate a QR Code, that is then scanned in an authentication app such as [Authy](https://authy.com/) or [Google Authenticator](https://en.wikipedia.org/wiki/Google_Authenticator).
2. They then send the TOTP code to Hasura Auth. MFA is now activated
3. Next time they authenticate, Hasura Auth will first expect their email and password, but then, instead of completing authentication, Hasura Auth will expect the TOTP in order to return the refresh and the access tokens.
In order for users to be able to activate MFA TOTP, `AUTH_MFA_ENABLED` must be set to `true`.
<!-- ---
TODO ## OAuth authentication -->
---
## Gravatar
Hasura Auth stores the avatar URL of users in `auth.users.avatar_url`. By default, it will look for the Gravatar linked to the email, and store it into this field.
It is possible to deactivate the use of Gravatar in setting the `AUTH_GRAVATAR_ENABLED` environment variable to `false`.
---
## Extending user schema
Adding columns to the user tables may be tempting. However, all the tables and columns have a specific purpose, and changing the structure of the `auth` schema will very likely end in breaking the functionning of Hasura Auth. It's, therefore, **highly recommended** not to modify the database schema for any tables in the `auth` schema.
Instead, we recommend adding extra user information in the following ways:
- to store information in the `auth.users.metadata` column
- to store information in a separate table located in the `public` PostgreSQL schema, and to point to `auth.users.id` through a foreign key.
### `metadata` user field
The `auth.users.metadata` field is a JSON column, that can be used as an option on registration:
```json
{
"email": "bob@bob.com",
"passord": "12345678",
"options": {
"metadata": {
"first_name": "Bob"
}
}
}
```
### Additional user information in the `public` schema
As previously explained, the alteration of the `auth` schema may seriously hamper the functionning of Hasura Auth. The `metadata` field in the `auth.users` table may tackle some use cases, but in some other cases, we want to keep a certain level of structure in the way data is structured.
In that case, it is possible to create a dedicated table in the `public` schema, with a `user_id` foreign key column that would point to the `auth.users.id` column. It is then possible to add an Hasura object relationship that would join the two tables together.
<!-- TODO hooks on the metadata field -->
---
## Custom Hasura JWT claims
Hasura comes with a [powerful authorisation system](https://hasura.io/docs/latest/graphql/core/auth/authorization/index.html). Hasura Auth is already configured to add `x-hasura-user-id`, `x-hasura-allowed-roles`, and `x-hasura-user-isAnonymous` to the JSON Web Tokens it generates.
In Hasura Auth, it is possible to define custom claims to add to the JWT, so they can be used by Hasura to determine the permissions of the received GraphQL operation.
Each custom claim is defined by a pair of a key and a value:
- The key determines the name of the claim, prefixed by `x-hasura`. For instance, `organisation-id` will become `x-hasura-organisation-id`.
- The value is a representation of the path to look at to determine the value of the claim. For instance `profile.organisation.id` will look for the `user.profile` Hasura relationship, and the `profile.organisation` Hasura relationship. Array values are transformed into Postgres syntax so Hasura can interpret them. See the official Hasura documentation to understand the [session variables format](https://hasura.io/docs/latest/graphql/core/auth/authorization/roles-variables.html#format-of-session-variables).
```bash
AUTH_JWT_CUSTOM_CLAIMS={"organisation-id":"profile.organisation.id", "project-ids":"profile.contributesTo.project.id"}
```
Will automatically generate and fetch the following GraphQL query:
```graphql
{
user(id: "<user-id>") {
profile {
organisation {
id
}
contributesTo {
project {
id
}
}
}
}
}
```
It will then use the same expressions e.g. `profile.contributesTo.project.id` to evaluate the result with [JSONata](https://jsonata.org/), and possibly transform arrays into Hasura-readable, PostgreSQL arrays.Finally, it adds the custom claims to the JWT in the `https://hasura.io/jwt/claims` namespace:
```json
{
"https://hasura.io/jwt/claims": {
"x-hasura-organisation-id": "8bdc4f57-7d64-4146-a663-6bcb05ea2ac1",
"x-hasura-project-ids": "{\"3af1b33f-fd0f-425e-92e2-0db09c8b2e29\",\"979cb94c-d873-4d5b-8ee0-74527428f58f\"}",
"x-hasura-allowed-roles": [ "me", "user" ],
"x-hasura-default-role": "user",
"x-hasura-user-id": "121bbea4-908e-4540-ac5d-52c7f6f93bec",
"x-hasura-user-isAnonymous": "false"
}
"sub": "f8776768-4bbd-46f8-bae1-3c40da4a89ff",
"iss": "hasura-auth",
"iat": 1643040189,
"exp": 1643041089
}
```

View File

@@ -1,107 +0,0 @@
---
title: Environment variables
sidebar_position: 3
---
## General environment variables
| Name (a star**\*** means the variable is required) | Description | Default value |
| -------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ---------------------------- |
| HASURA_GRAPHQL_JWT_SECRET**\*** | Key used for generating JWTs. Must be `HMAC-SHA`-based and the same as configured in Hasura. [More info](https://hasura.io/docs/latest/graphql/core/auth/authentication/jwt.html#running-with-jwt) | |
| HASURA_GRAPHQL_DATABASE_URL**\*** | [PostgreSQL connection URI](https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-CONNSTRING). Required to inject the `auth` schema into the database. | |
| HASURA_GRAPHQL_GRAPHQL_URL**\*** | Hasura GraphQL endpoint. Required to manipulate account data. For instance: `https://graphql-engine:8080/v1/graphql` | |
| HASURA_GRAPHQL_ADMIN_SECRET**\*** | Hasura GraphQL Admin Secret. Required to manipulate account data. | |
| AUTH_HOST | Server host. This option is available until Hasura-auth `v0.6.0`. [Docs](http://expressjs.com/en/5x/api.html#app.listen) | `0.0.0.0` |
| AUTH_PORT | Server port. [Docs](http://expressjs.com/en/5x/api.html#app.listen) | `4000` |
| AUTH_SERVER_URL | Server URL of where Hasura Backend Plus is running. This value is to used as a callback in email templates and for the OAuth authentication process. | |
| AUTH_CLIENT_URL | URL of your frontend application. Used to redirect users to the right page once actions based on emails or OAuth succeed. | |
| AUTH_SMTP_HOST | SMTP server hostname used for sending emails | |
| AUTH_SMTP_PORT | SMTP port | `587` |
| AUTH_SMTP_USER | Username to use to authenticate on the SMTP server | |
| AUTH_SMTP_PASS | Password to use to authenticate on the SMTP server | |
| AUTH_SMTP_SENDER | Email to use in the `From` field of the email | |
| AUTH_SMTP_AUTH_METHOD | SMTP authentication method | `PLAIN` |
| AUTH_SMTP_SECURE | Enables SSL. [More info](https://nodemailer.com/smtp/#tls-options). | `false` |
| AUTH_GRAVATAR_ENABLED | | `true` |
| AUTH_GRAVATAR_DEFAULT | | `blank` |
| AUTH_GRAVATAR_RATING | | `g` |
| AUTH_ANONYMOUS_USERS_ENABLED | Enables users to register as an anonymous user. | `false` |
| AUTH_DISABLE_NEW_USERS | If set, new users will be disabled after finishing registration and won't be able to connect. | `false` |
| AUTH_ACCESS_CONTROL_ALLOWED_EMAILS | Comma-separated list of emails that are allowed to register. | |
| AUTH_ACCESS_CONTROL_ALLOWED_EMAIL_DOMAINS | Comma-separated list of email domains that are allowed to register. If `ALLOWED_EMAIL_DOMAINS` is `tesla.com,ikea.se`, only emails from tesla.com and ikea.se would be allowed to register an account. | `` (allow all email domains) |
| AUTH_ACCESS_CONTROL_BLOCKED_EMAILS | Comma-separated list of emails that cannot register. | |
| AUTH_ACCESS_CONTROL_BLOCKED_EMAIL_DOMAINS | Comma-separated list of email domains that cannot register. | |
| AUTH_PASSWORD_MIN_LENGTH | Minimum password length. | `3` |
| AUTH_PASSWORD_HIBP_ENABLED | User's password is checked against [Pwned Passwords](https://haveibeenpwned.com/Passwords). | `false` |
| AUTH_USER_DEFAULT_ROLE | Default user role for registered users. | `user` |
| AUTH_USER_DEFAULT_ALLOWED_ROLES | Comma-separated list of default allowed user roles. | `me,$AUTH_USER_DEFAULT_ROLE` |
| AUTH_LOCALE_DEFAULT | | `en` |
| AUTH_LOCALE_ALLOWED_LOCALES | | `en` |
| AUTH_EMAIL_PASSWORDLESS_ENABLED | Enables passwordless authentication by email. The SMTP server must then be configured. | `false` |
| AUTH_SMS_PASSWORDLESS_ENABLED | Enables passwordless authentication by SMS. An SMS provider must then be configured. | `false` |
| AUTH_SMS_PROVIDER | SMS provider name. Only `twilio` is possible as an option for now. | |
| AUTH_SMS_TWILIO_ACCOUNT_SID | | |
| AUTH_SMS_TWILIO_AUTH_TOKEN | | |
| AUTH_SMS_TWILIO_MESSAGING_SERVICE_ID | | |
| 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_TOTP_ISSUER | The name of the One Time Password (OTP) issuer. Probably your app's name. | `hasura-auth` |
| 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 | | |
## OAuth environment variables
| Name (a star**\*** means the variable is required when the provider is enabled) | Default value |
| ------------------------------------------------------------------------------- | ----------------------------------- |
| AUTH_PROVIDER_GITHUB_ENABLED | `false` |
| AUTH_PROVIDER_GITHUB_CLIENT_ID**\*** | |
| AUTH_PROVIDER_GITHUB_CLIENT_SECRET**\*** | |
| AUTH_PROVIDER_GITHUB_AUTHORIZATION_URL | |
| AUTH_PROVIDER_GITHUB_TOKEN_URL | |
| AUTH_PROVIDER_GITHUB_USER_PROFILE_URL | |
| AUTH_PROVIDER_GITHUB_SCOPE | `user:email ` |
| AUTH_PROVIDER_GOOGLE_ENABLED | `false` |
| AUTH_PROVIDER_GOOGLE_CLIENT_ID**\*** | |
| AUTH_PROVIDER_GOOGLE_CLIENT_SECRET**\*** | |
| AUTH_PROVIDER_GOOGLE_SCOPE | `email,profile` |
| AUTH_PROVIDER_FACEBOOK_ENABLED | `false` |
| AUTH_PROVIDER_FACEBOOK_CLIENT_ID**\*** | |
| AUTH_PROVIDER_FACEBOOK_CLIENT_SECRET**\*** | |
| AUTH_PROVIDER_FACEBOOK_PROFILE_FIELDS | `email,photos,displayName` |
| AUTH_PROVIDER_FACEBOOK_SCOPE | `email` |
| AUTH_PROVIDER_TWITTER_ENABLED | `false` |
| AUTH_PROVIDER_TWITTER_CONSUMER_KEY**\*** | |
| AUTH_PROVIDER_TWITTER_CONSUMER_SECRET**\*** | |
| AUTH_PROVIDER_LINKEDIN_ENABLED | |
| AUTH_PROVIDER_LINKEDIN_CLIENT_ID**\*** | |
| AUTH_PROVIDER_LINKEDIN_CLIENT_SECRET**\*** | |
| AUTH_PROVIDER_LINKEDIN_SCOPE | `r_emailaddress,r_liteprofile` |
| AUTH_PROVIDER_APPLE_ENABLED | `false` |
| AUTH_PROVIDER_APPLE_CLIENT_ID**\*** | |
| AUTH_PROVIDER_APPLE_TEAM_ID**\*** | |
| AUTH_PROVIDER_APPLE_KEY_ID**\*** | |
| AUTH_PROVIDER_APPLE_PRIVATE_KEY**\*** | Base64 format |
| AUTH_PROVIDER_APPLE_SCOPE | `name,email` |
| AUTH_PROVIDER_WINDOWS_LIVE_ENABLED | `false` |
| AUTH_PROVIDER_WINDOWS_LIVE_CLIENT_ID**\*** | |
| AUTH_PROVIDER_WINDOWS_LIVE_CLIENT_SECRET**\*** | |
| AUTH_PROVIDER_WINDOWS_LIVE_SCOPE | `wl.basic,wl.emails` |
| AUTH_PROVIDER_SPOTIFY_ENABLED | `false` |
| AUTH_PROVIDER_SPOTIFY_CLIENT_ID**\*** | |
| AUTH_PROVIDER_SPOTIFY_CLIENT_SECRET**\*** | |
| AUTH_PROVIDER_SPOTIFY_SCOPE | `user-read-email,user-read-private` |
| AUTH_PROVIDER_GITLAB_ENABLED | `false` |
| AUTH_PROVIDER_GITLAB_CLIENT_ID**\*** | |
| AUTH_PROVIDER_GITLAB_CLIENT_SECRET**\*** | |
| AUTH_PROVIDER_GITLAB_BASE_URL | |
| AUTH_PROVIDER_GITLAB_SCOPE | `read_user` |
| AUTH_PROVIDER_BITBUCKET_ENABLED | `false` |
| AUTH_PROVIDER_BITBUCKET_CLIENT_ID**\*** | |
| AUTH_PROVIDER_BITBUCKET_CLIENT_SECRET**\*** | |
| AUTH_PROVIDER_STRAVA_ENABLED | `false` |
| AUTH_PROVIDER_STRAVA_CLIENT_ID**\*** | |
| AUTH_PROVIDER_STRAVA_CLIENT_SECRET**\*** | |
| AUTH_PROVIDER_STRAVA_SCOPE | `profile:read_all` |

View File

@@ -1,41 +0,0 @@
---
title: 'Overview'
---
Hasura Auth handles **authentication** for [Hasura](https://github.com/hasura/graphql-engine).
Hasura Auth runs in a separate Docker container alongside Postgres and Hasura.
## Features
- 🧑‍🤝‍🧑 Users are stored in Postgres and accessed via GraphQL
- 🔑 Multiple sign-in methods
- ✨ Integrates with GraphQL and Hasura Permissions
- 🔐 JWT tokens and Refresh Tokens.
- 📧 Emails sent on various operations
<!-- - ✅ Optional checking for Pwned Passwords. -->
- 🛡️ Two-factor authentication support.
- 👨‍💻 Written 100% in TypeScript.
### Authentication methods
- **Email and Password**: simple email and password method.
- **Email**, also called **passwordless email** or **magic link**.
- **SMS**, also called **passwordless sms**.
- **Anonymous**: sign in users without any method. Anonymous users can be
converted to _regular_ users at a later stage.
- **OAuth providers**: Facebook, Google, GitHub, Twitter, Apple, LinkedIn, Windows Live, Spotify, Strave, GitLab, BitBucket
## Integration with Hasura
Hasura Auth's final purpose is to securely provide a JSON Web Token that can be added as an authorization header to GraphQL operation sent to Hasura.
Hasura auth automatically generates and manages two kinds of tokens:
- An access token (JWT), that will be used to authenticate the GraphQL operations in Hasura, and that has a limited expiration limit (15 minutes by default)
- A refresh token, that is used to ask Hasura Auth for a new access token, and that can be consummed only once.
Access tokens generated by Hasura Auth contains information and user id, its default role, and the roles they actually have. In addition, it is possible since version `0.2.0` to extend JWT claims with custom information such as organisation or project ownership, so your application can leverage the capabilities of the [Hasura permissions layer](https://hasura.io/docs/latest/graphql/core/auth/authorization/index.html).
<!-- - Users and accounts are saved in the database. -->
You can read further information about JWT and Hasura in the [official Hasura documentation](https://hasura.io/docs/latest/graphql/core/auth/authentication/jwt.html).

View File

@@ -1,25 +0,0 @@
---
title: Installation
sidebar_position: 1
---
Hasura Auth runs in a container alongside Postgres and Hasura.
## Nhost (recommended)
The recommended way to start using Hasura Auth is by using Nhost. With Nhost, you will get a complete backend ready in seconds with Hasura, authentication, storage and serverless functions.
Go to [Nhost](https://nhost.io) and start building your app now.
## Docker-compose
```sh
git clone https://github.com/nhost/hasura-auth.git
cd hasura-auth
cp .env.example .env
docker-compose -f docker-compose-example.yaml up
```
Hasura Auth comes with plenty of options. They are explained in the [configuration section](/reference/hasura-auth/configuration).
If you are already familiar with the application, you can also have a look at the [environment variables](/reference/hasura-auth/environment-variables) that can be passed on to your docker container.

View File

@@ -1,86 +0,0 @@
---
title: 'Schema'
sidebar_position: 4
---
Hasura Auth stores all its data in a dedicated `auth` PostgreSQL schema. When Hasura Auth starts, it checks if the `auth` schema exists, then automatically syncs the following tables and their corresponding Hasura metadata:
```mermaid
erDiagram
migrations {
integer id PK
varchar name
varchar hash
timestamp executed_at "CURRENT_TIMESTAMP"
}
users ||--o{ user_roles : roles
user_roles }o--|| roles: role
users }o--|| roles: role
users ||--o{ refresh_tokens: refreshTokens
users ||--o{ user_providers: provider
providers ||--o{ user_providers: user
provider_requests {
uuid id PK "gen_random_uuid()"
test redirect_url
}
refresh_tokens {
uuid refresh_token PK
uuid user_id FK
timestamptz created_at "now()"
timestamptz expires_at
}
providers {
text id PK
}
user_providers {
uuid id PK "gen_random_uuid()"
timestamptz created_at "now()"
timestamptz updated_at "now()"
uuid user_id FK
text access_token
text refresh_token
text provider_id FK
text provider_user_id
}
user_roles {
uuid id PK "gen_random_uuid()"
timestamptz created_at "now()"
uuid user_id FK
text role FK
}
users {
uuid id PK "gen_random_uuid()"
timestamptz created_at "now()"
timestamptz updated_at "now()"
timestamptz last_seen "nullable"
boolean disabled "false"
text display_name "''"
text avatar_url "''"
varchar locale
email email "nullable"
text phone_number "nullable"
text password_hash "nullable"
boolean email_verified "false"
boolean phone_number_verified "false"
email new_email "nullable"
text otp_method_last_used "nullable"
text otp_hash "nullable"
timestamptz opt_hash_expires_at "now()"
text default_role FK "user"
boolean is_anonymous "false"
text totp_secret "nullable"
text active_mfa_type "nullable"
text ticket "nullable"
timestamptz ticket_expires_at "now()"
jsonb metadata "nullable"
}
roles {
text roles PK
}
```

View File

@@ -34,12 +34,3 @@ In this section:
### Nhost CLI
- [CLI overview](/reference/cli)
### Hasura Auth
- [Overview](/reference/hasura-auth)
- [Installation](/reference/hasura-auth/installation)
- [Configuration](/reference/hasura-auth/configuration)
- [Environment variables](/reference/hasura-auth/environment-variables)
- [Schema](/reference/hasura-auth/schema)
- [API](/reference/hasura-auth/api-reference)

View File

@@ -42,7 +42,8 @@ Initialize a single `nhost` instance using your Nhost backend URL:
import { NhostClient } from '@nhost/nhost-js'
const nhost = new NhostClient({
backendUrl: '<Your Nhost Backend URL>'
subdomain: '<your-subdomain>',
region: '<your-region>'
})
```

View File

@@ -39,7 +39,8 @@ import type { AppProps } from 'next/app'
import { NhostClient, NhostNextProvider } from '@nhost/nextjs'
const nhost = new NhostClient({
backendUrl: '<Your Nhost Backend URL>'
subdomain: '<your-subdomain>',
region: '<your-region>'
})
function MyApp({ Component, pageProps }: AppProps) {
@@ -139,7 +140,8 @@ import { NhostClient, NhostNextProvider } from '@nhost/nextjs'
import { NhostApolloProvider } from '@nhost/react-apollo'
const nhost = new NhostClient({
backendUrl: '<Your Nhost Backend URL>'
subdomain: '<your-subdomain>',
region: '<your-region>'
})
function MyApp({ Component, pageProps }: AppProps) {

View File

@@ -36,7 +36,8 @@ After installation, initialize a single Nhost Client (`nhost`) under `src/lib/nh
```jsx title=src/lib/nhost.js
import { NhostClient } from '@nhost/react'
const nhost = new NhostClient({
backendUrl: '<Your Nhost Backend URL>'
subdomain: '<your-subdomain>',
region: '<your-region>'
})
export { nhost }
```
@@ -63,8 +64,6 @@ ReactDOM.render(
export { nhost }
```
:::info
The `nhost` instance created with the `NhostClient` above is the same as the [JavaScript Nhost client](/reference/javascript).

View File

@@ -74,7 +74,8 @@ Where `nhost` comes from `lib/nhost.js` like this:
import { NhostClient } from '@nhost/react'
const nhost = new NhostClient({
backendUrl: '<Your Nhost Backend URL>'
subdomain: '<your-subdomain>',
region: '<your-region>'
})
export { nhost }

View File

@@ -40,7 +40,8 @@ import { DefaultApolloClient } from '@vue/apollo-composable'
import App from './App.vue'
const nhost = new NhostClient({
backendUrl: import.meta.env.VITE_NHOST_URL
subdomain: '<your-subdomain>',
region: '<your-region>'
})
const apolloClient = createApolloClient({ nhost })

View File

@@ -40,7 +40,8 @@ import { NhostClient } from '@nhost/vue'
import App from './App.vue'
const nhost = new NhostClient({
backendUrl: '<Your Nhost Backend URL>'
subdomain: '<your-subdomain>',
region: '<your-region>'
})
createApp(App).use(nhost).mount('#app')

View File

@@ -20,7 +20,8 @@ import { NhostClient } from '@nhost/vue'
import App from './App.vue'
const nhost = new NhostClient({
backendUrl: '<Your Nhost Backend URL>'
subdomain: '<your-subdomain>',
region: '<your-region>'
})
const router = createRouter({

View File

@@ -26,7 +26,7 @@ const config = {
favicon: 'img/favicon.png',
organizationName: 'nhost',
projectName: 'docs',
plugins: [require.resolve("docusaurus-plugin-image-zoom")],
plugins: [require.resolve('docusaurus-plugin-image-zoom')],
presets: [
[
'classic',
@@ -179,7 +179,7 @@ const config = {
appId: '3A3MJQTKHU',
apiKey: 'a76361eaed8ebcd4cf5d9ae2f0c9e746',
indexName: 'nhost',
contextualSearch: false
contextualSearch: true
},
zoom: {
selector: '.markdown :not(em) > img',

View File

@@ -25,13 +25,11 @@
"mermaid": "^8.14.0",
"prism-react-renderer": "^1.3.1",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"swagger-ui-react": "^4.10.3"
"react-dom": "^17.0.2"
},
"devDependencies": {
"@docusaurus/module-type-aliases": "2.0.0-beta.20",
"@tsconfig/docusaurus": "^1.0.5",
"@types/swagger-ui-react": "^4.1.1",
"typescript": "^4.6.3"
},
"browserslist": {

View File

@@ -142,18 +142,6 @@ const sidebars = {
'reference/cli/logs',
'reference/cli/global-flags'
]
},
{
type: 'category',
label: 'Hasura Auth',
link: { type: 'doc', id: 'reference/hasura-auth/index' },
items: [
'reference/hasura-auth/installation',
'reference/hasura-auth/configuration',
'reference/hasura-auth/environment-variables',
'reference/hasura-auth/schema',
'reference/hasura-auth/api-reference'
]
}
]
}

View File

@@ -1,40 +0,0 @@
import SwaggerUI from 'swagger-ui-react';
import React from 'react';
import 'swagger-ui-react/swagger-ui.css';
const OperationsLayout = (props) => {
const { getComponent } = props;
const Operations = getComponent('operations', true);
let SvgAssets = getComponent('SvgAssets');
return (
<div className="swagger-ui">
<SvgAssets />
<Operations />
</div>
);
};
const OperationsLayoutPlugin = () => ({
components: {
OperationsLayout,
},
});
type SwaggerProps = {
/**
* OpenAPI specification.
*/
spec: string;
};
export function Swagger({ spec }: SwaggerProps) {
return (
<SwaggerUI
url={`/openapi/${spec}`}
plugins={[OperationsLayoutPlugin]}
layout="OperationsLayout"
supportedSubmitMethods={[]}
/>
);
}

View File

@@ -40,6 +40,16 @@
"source": "/reference/react/hooks",
"destination": "/reference/react",
"permanent": true
},
{
"source": "/reference/hasura-auth",
"destination": "https://github.com/nhost/hasura-auth",
"permanent": true
},
{
"source": "/reference/hasura-auth/:path*",
"destination": "https://github.com/nhost/hasura-auth",
"permanent": true
}
]
}

View File

@@ -3,11 +3,13 @@ services:
mailhog:
port: 8025
hasura:
version: v2.2.0
version: v2.8.0
environment:
hasura_graphql_enable_remote_schema_permissions: false
auth:
version: 0.7.1
version: 0.9.1
storage:
version: 0.2.2
auth:
access_control:
email:

View File

@@ -20,9 +20,9 @@
"@mantine/hooks": "^4.2.2",
"@mantine/next": "^4.2.2",
"@mantine/notifications": "^4.2.2",
"@nhost/nextjs": "workspace:*",
"@nhost/react": "workspace:*",
"@nhost/react-apollo": "workspace:*",
"@nhost/nextjs": "*",
"@nhost/react": "*",
"@nhost/react-apollo": "*",
"graphql": "^16.3.0",
"next": "12.1.6",
"react": "18.1.0",

View File

@@ -1,8 +1,13 @@
metadata_directory: metadata
services:
hasura:
version: v2.8.0
environment:
hasura_graphql_enable_remote_schema_permissions: true
auth:
version: 0.9.1
storage:
version: 0.2.2
auth:
access_control:
email:

View File

@@ -6,8 +6,8 @@
"@apollo/client": "^3.5.10",
"@headlessui/react": "^1.5.0",
"@heroicons/react": "^1.0.6",
"@nhost/react": "workspace:*",
"@nhost/react-apollo": "workspace:*",
"@nhost/react": "*",
"@nhost/react-apollo": "*",
"@tailwindcss/forms": "^0.5.0",
"classnames": "^2.3.1",
"date-fns": "^2.28.0",

View File

@@ -6,6 +6,9 @@ export default defineConfig({
chromeWebSecurity: false,
// * for some reason, the mailhog API is not systematically available
// * when using `localhost` instead of `127.0.0.1`
mailHogUrl: 'http://127.0.0.1:8025'
mailHogUrl: 'http://127.0.0.1:8025',
env: {
backendUrl: 'http://localhost:1337'
}
}
} as Cypress.ConfigOptions)

View File

@@ -1,12 +0,0 @@
import { faker } from '@faker-js/faker'
context('Failed attempt to sign up with an email already present in the database', () => {
it('shoud raise an error when trying to sign up with an existing email', () => {
const email = faker.internet.email()
const password = faker.internet.password(10)
cy.signUpEmailPassword(email, password)
cy.contains('Verification email sent').should('be.visible')
cy.signUpEmailPassword(email, password)
cy.contains('Email already in use').should('be.visible')
})
})

View File

@@ -1,16 +0,0 @@
import { faker } from '@faker-js/faker'
context('Successful email+password sign-up', () => {
it('should redirect to /sign-in when not authenticated', () => {
cy.visit('/')
cy.location('pathname').should('equal', '/sign-in')
})
it('should sign-up with email and password', () => {
const email = faker.internet.email()
cy.signUpEmailPassword(email, faker.internet.password())
cy.contains('Verification email sent').should('be.visible')
cy.confirmEmail(email)
cy.contains('You are authenticated')
})
})

View File

@@ -0,0 +1,8 @@
context('Authentication guards', () => {
it('should redirect to /sign-in when not authenticated', () => {
cy.visit('/')
cy.location('pathname').should('equal', '/sign-in')
cy.visit('/apollo')
cy.location('pathname').should('equal', '/sign-in')
})
})

View File

@@ -0,0 +1,51 @@
import { faker } from '@faker-js/faker'
context('Anonymous users', () => {
beforeEach(() => {
cy.signInAnonymous()
})
it('should sign-up anonymously', () => {
cy.contains('You signed in anonymously')
})
it('should deanonymise with email+password', () => {
cy.fetchUserData()
.its('id')
.then((id) => {
const email = faker.internet.email()
const password = faker.internet.password()
cy.signUpEmailPassword(email, password)
cy.contains('Verification email sent').should('be.visible')
cy.confirmEmail(email)
cy.contains('You signed in anonymously').should('not.exist')
cy.fetchUserData().then((user) => {
cy.wrap(user).its('id').should('equal', id)
cy.wrap(user).its('email').should('equal', email)
})
})
})
it('should deanonymise with passwordless email', () => {
cy.fetchUserData()
.its('id')
.then((id) => {
const email = faker.internet.email()
cy.signUpEmailPasswordless(email)
cy.contains('Verification email sent').should('be.visible')
cy.confirmEmail(email)
cy.goToHomePage()
cy.contains('You signed in anonymously').should('not.exist')
cy.fetchUserData().then((user) => {
cy.wrap(user).its('id').should('equal', id)
cy.wrap(user).its('email').should('equal', email)
})
})
})
// TODO implement deanonymisation with Oauth?
// TODO forbid email/password change, MFA activation, and password reset when the following PR is released
// * https://github.com/nhost/hasura-auth/pull/190
})

View File

@@ -0,0 +1,28 @@
import { faker } from '@faker-js/faker'
context('Sign up with email+password', () => {
it('should sign-up with email and password', () => {
const email = faker.internet.email()
const password = faker.internet.password()
cy.signUpEmailPassword(email, password)
cy.contains('Verification email sent').should('be.visible')
cy.confirmEmail(email)
cy.contains('You are authenticated')
})
it('shoud raise an error when trying to sign up with an existing email', () => {
const email = faker.internet.email()
const password = faker.internet.password(10)
cy.signUpEmailPassword(email, password)
cy.contains('Verification email sent').should('be.visible')
cy.signUpEmailPassword(email, password)
cy.contains('Email already in use').should('be.visible')
})
// TODO implement in the UI
it.skip('should fail when network is not available', () => {
cy.disconnectBackend()
cy.signUpEmailPassword(faker.internet.email(), faker.internet.password())
cy.contains('Error').should('be.visible')
})
})

View File

@@ -0,0 +1,17 @@
import { faker } from '@faker-js/faker'
context('Sign up with passwordless email', () => {
it('should sign-up with passwordless email', () => {
const email = faker.internet.email()
cy.signUpEmailPasswordless(email)
cy.contains('Verification email sent').should('be.visible')
cy.confirmEmail(email)
cy.contains('Profile page')
})
it('should fail when network is not available', () => {
cy.disconnectBackend()
cy.signUpEmailPasswordless(faker.internet.email())
cy.contains('Error').should('be.visible')
})
})

View File

@@ -0,0 +1,78 @@
import totp from 'totp-generator'
import faker from '@faker-js/faker'
import { Decoder } from '@nuintun/qrcode'
context('Sign in with email+password', () => {
it('should sign-in with email and password', () => {
const email = faker.internet.email()
const password = faker.internet.password()
cy.signUpEmailPassword(email, password)
cy.contains('Verification email sent').should('be.visible')
cy.confirmEmail(email)
cy.signOut()
cy.contains('Log in to the Application').should('be.visible')
cy.signInEmailPassword(email, password)
cy.contains('You are authenticated')
})
// TODO implement in the UI
it.skip('should fail when network is not available', () => {
const email = faker.internet.email()
const password = faker.internet.password()
cy.disconnectBackend()
cy.signInEmailPassword(email, password)
cy.contains('Error').should('be.visible')
})
it('should activate and sign-in with MFA', () => {
// * Sign-up with email+password
const email = faker.internet.email()
const password = faker.internet.email()
cy.signUpEmailPassword(email, password)
cy.contains('Verification email sent').should('be.visible')
cy.confirmEmail(email)
cy.getNavBar()
.findByRole('button', { name: /Profile/i })
.click()
cy.findByText(/Activate 2-step verification/i)
.parent()
.findByRole('button')
.click()
cy.findByText(/Activate 2-step verification/i)
.get('img')
.then(async (img) => {
// * Activate MFA
const result = await new Decoder().scan(img.prop('src'))
const [, params] = result.data.split('?')
const { secret, algorithm, digits, period } = Object.fromEntries(
new URLSearchParams(params)
)
const code = totp(secret, {
algorithm: algorithm.replace('SHA1', 'SHA-1'),
digits: parseInt(digits),
period: parseInt(period)
})
cy.findByPlaceholderText('Enter activation code').type(code)
cy.findByRole('button', { name: /Activate/i }).click()
cy.contains('MFA has been activated!!!')
cy.signOut()
// * Sign-in with MFA
cy.visit('/sign-in')
cy.findByRole('button', { name: /Continue with email \+ password/i }).click()
cy.findByPlaceholderText('Email Address').type(email)
cy.findByPlaceholderText('Password').type(password)
cy.findByRole('button', { name: /Sign in/i }).click()
cy.contains('Send 2-step verification code')
const newCode = totp(secret, { timestamp: Date.now() })
cy.findByPlaceholderText('One-time password').type(newCode)
cy.findByRole('button', { name: /Send 2-step verification code/i }).click()
cy.contains('You are authenticated')
})
})
})

View File

@@ -0,0 +1,22 @@
context('Sign in with a refresh token', () => {
it('should sign-in with a refresh token', () => {
cy.signUpAndConfirmEmail()
cy.contains('Profile page')
cy.clearLocalStorage()
cy.reload()
cy.contains('Log in to the Application')
cy.visitPathWithRefreshToken('/profile')
cy.contains('Profile page')
})
it('should fail authentication when network is not available', () => {
cy.signUpAndConfirmEmail()
cy.contains('Profile page')
cy.disconnectBackend()
cy.clearLocalStorage()
cy.reload()
cy.contains('Log in to the Application')
cy.visitPathWithRefreshToken('/profile')
cy.location('pathname').should('equal', '/sign-in')
})
})

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