Compare commits

..

4 Commits

Author SHA1 Message Date
github-actions[bot]
257815d519 chore: update versions (#2888)
This PR was opened by the [Changesets
release](https://github.com/changesets/action) GitHub action. When
you're ready to do a release, you can merge this and the packages will
be published to npm automatically. If you're not ready to do a release
yet, that's fine, whenever you add more changesets to main, this PR will
be updated.


# Releases
## @nhost/hasura-auth-js@2.6.0

### Minor Changes

- 55d8bb5: feat: support custom headers in sign-up and deanonymize
requests

## @nhost/react@3.6.0

### Minor Changes

- 55d8bb5: feat: add `requestOptions` to `signUpEmailPassword` to allow
passing extra headers with the signup request

### Patch Changes

-   @nhost/nhost-js@3.1.10

## @nhost/apollo@7.1.7

### Patch Changes

-   @nhost/nhost-js@3.1.10

## @nhost/react-apollo@13.0.0

### Patch Changes

-   Updated dependencies [55d8bb5]
    -   @nhost/react@3.6.0
    -   @nhost/apollo@7.1.7

## @nhost/react-urql@10.0.0

### Patch Changes

-   Updated dependencies [55d8bb5]
    -   @nhost/react@3.6.0

## @nhost/nextjs@2.1.22

### Patch Changes

-   Updated dependencies [55d8bb5]
    -   @nhost/react@3.6.0

## @nhost/nhost-js@3.1.10

### Patch Changes

-   Updated dependencies [55d8bb5]
    -   @nhost/hasura-auth-js@2.6.0

## @nhost/vue@2.6.7

### Patch Changes

-   @nhost/nhost-js@3.1.10

## @nhost/dashboard@1.29.0

### Minor Changes

-   55d8bb5: feat: integrate turnstile for signup verification
-   2a2e54c: fix: update docs url in run services form tooltip
- 18f942f: fix: display long error messages in error toast without
overflow

### Patch Changes

-   @nhost/react-apollo@13.0.0
-   @nhost/nextjs@2.1.22

## @nhost-examples/cli@0.3.12

### Patch Changes

-   @nhost/nhost-js@3.1.10

## @nhost-examples/codegen-react-apollo@0.4.13

### Patch Changes

-   Updated dependencies [55d8bb5]
    -   @nhost/react@3.6.0
    -   @nhost/react-apollo@13.0.0

## @nhost-examples/codegen-react-query@0.4.13

### Patch Changes

-   Updated dependencies [55d8bb5]
    -   @nhost/react@3.6.0

## @nhost-examples/codegen-react-urql@0.3.13

### Patch Changes

-   Updated dependencies [55d8bb5]
    -   @nhost/react@3.6.0
    -   @nhost/react-urql@10.0.0

## @nhost-examples/multi-tenant-one-to-many@2.2.13

### Patch Changes

-   @nhost/nhost-js@3.1.10

## @nhost-examples/nextjs@0.3.13

### Patch Changes

-   Updated dependencies [55d8bb5]
    -   @nhost/react@3.6.0
    -   @nhost/react-apollo@13.0.0
    -   @nhost/nextjs@2.1.22

## @nhost-examples/node-storage@0.2.12

### Patch Changes

-   @nhost/nhost-js@3.1.10

## @nhost-examples/nextjs-server-components@0.4.14

### Patch Changes

-   @nhost/nhost-js@3.1.10

## @nhost-examples/react-apollo@1.0.2

### Patch Changes

-   Updated dependencies [55d8bb5]
    -   @nhost/react@3.6.0
    -   @nhost/react-apollo@13.0.0

## @nhost-examples/react-gqty@1.2.13

### Patch Changes

-   Updated dependencies [55d8bb5]
    -   @nhost/react@3.6.0

## @nhost-examples/react-native@0.0.6

### Patch Changes

-   Updated dependencies [55d8bb5]
    -   @nhost/react@3.6.0
    -   @nhost/react-apollo@13.0.0

## @nhost-examples/vue-apollo@0.6.13

### Patch Changes

-   @nhost/nhost-js@3.1.10
-   @nhost/apollo@7.1.7
-   @nhost/vue@2.6.7

## @nhost-examples/vue-quickstart@0.2.13

### Patch Changes

-   @nhost/apollo@7.1.7
-   @nhost/vue@2.6.7

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2024-09-25 16:23:50 +01:00
Hassan Ben Jobrane
55d8bb5a89 feat: turnstile (#2895)
### **PR Type**
Enhancement


___

### **Description**
- Integrated Cloudflare Turnstile for signup verification in the
dashboard
- Added support for custom headers in authentication requests
- Updated signup page to include Turnstile component and handle
verification
- Modified authentication machine and fetch utilities to support extra
headers
- Added Turnstile site key to environment variables
- Included react-turnstile package as a new dependency


___



### **Changes walkthrough** 📝
<table><thead><tr><th></th><th align="left">Relevant
files</th></tr></thead><tbody><tr><td><strong>Enhancement</strong></td><td><table>
<tr>
  <td>
    <details>
<summary><strong>signup.tsx</strong><dd><code>Integrate Turnstile for
signup verification</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary>
<hr>

dashboard/src/pages/signup.tsx

<li>Integrated Turnstile for signup verification<br> <li> Added state
management for Turnstile response<br> <li> Updated signUpEmailPassword
function to include Turnstile response in <br>headers<br> <li> Added
Turnstile component to the signup form<br>


</details>


  </td>
<td><a
href="https://github.com/nhost/nhost/pull/2895/files#diff-fc2b5989e3bbafda1d3d8b2317d24c39ef2b8cec0c4dc410170fa2da13464f68">+29/-5</a>&nbsp;
&nbsp; </td>

</tr>                    

<tr>
  <td>
    <details>
<summary><strong>machine.ts</strong><dd><code>Add header support for
authentication requests</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary>
<hr>

packages/hasura-auth-js/src/machines/authentication/machine.ts

<li>Modified postRequest function to accept headers parameter<br> <li>
Updated signUpEmailPassword action to include headers in the request<br>


</details>


  </td>
<td><a
href="https://github.com/nhost/nhost/pull/2895/files#diff-a8fdfee087ad5a72ea0a64667e2a0c7f25baa84eaaf73ebfee3f5a5a1b7584d1">+18/-9</a>&nbsp;
&nbsp; </td>

</tr>                    

<tr>
  <td>
    <details>
<summary><strong>options.ts</strong><dd><code>Add headers option to
registration interface</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary>
<hr>

packages/hasura-auth-js/src/types/options.ts

- Added headers property to RegistrationOptions interface



</details>


  </td>
<td><a
href="https://github.com/nhost/nhost/pull/2895/files#diff-087479bfe46a1294bc277b5497fbd3f7638853290b8f521ed5e5cb374786812f">+5/-0</a>&nbsp;
&nbsp; &nbsp; </td>

</tr>                    

<tr>
  <td>
    <details>
<summary><strong>fetch.ts</strong><dd><code>Enhance fetch utilities with
extra headers support</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; </dd></summary>
<hr>

packages/hasura-auth-js/src/utils/fetch.ts

<li>Modified fetchWrapper function to accept and merge extra headers<br>
<li> Updated postFetch function to include extraHeaders parameter<br>


</details>


  </td>
<td><a
href="https://github.com/nhost/nhost/pull/2895/files#diff-b1af9daf6c51514d5d514540f2318d87e926c5e8a57079b6e2c258b98a1163a2">+13/-4</a>&nbsp;
&nbsp; </td>

</tr>                    
</table></td></tr><tr><td><strong>Configuration
changes</strong></td><td><table>
<tr>
  <td>
    <details>
<summary><strong>.env.example</strong><dd><code>Add Turnstile site key
to environment variables</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; </dd></summary>
<hr>

dashboard/.env.example

- Added NEXT_PUBLIC_TURNSTILE_SITE_KEY variable



</details>


  </td>
<td><a
href="https://github.com/nhost/nhost/pull/2895/files#diff-b47cf46119af2f0298d96e5657e53e57161833e8b02d87526ac5c1ed9393d477">+1/-0</a>&nbsp;
&nbsp; &nbsp; </td>

</tr>                    
</table></td></tr><tr><td><strong>Dependencies</strong></td><td><table>
<tr>
  <td>
    <details>
<summary><strong>package.json</strong><dd><code>Add Turnstile React
component dependency</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; </dd></summary>
<hr>

dashboard/package.json

- Added @marsidev/react-turnstile dependency



</details>


  </td>
<td><a
href="https://github.com/nhost/nhost/pull/2895/files#diff-2d8d55c799cd71f1b35e831f075f8178ed1734c4820a2ad548b4dd24d6938d7c">+1/-0</a>&nbsp;
&nbsp; &nbsp; </td>

</tr>                    
</table></td></tr></tr></tbody></table>

___

> 💡 **PR-Agent usage**: Comment `/help "your question"` on any pull
request to receive relevant information
2024-09-25 16:01:40 +01:00
David BM
18f942f464 fix (dashboard): long error message in error toast overflow (#2892) 2024-09-23 13:42:41 -04:00
David BM
2a2e54c4d8 fix (dashboard): update url to docs in run services tooltip (#2886) 2024-09-21 11:16:21 -04:00
57 changed files with 857 additions and 757 deletions

View File

@@ -24,3 +24,4 @@ NEXT_PUBLIC_ZENDESK_USER_EMAIL=
CODEGEN_GRAPHQL_URL=https://local.graphql.nhost.run/v1 CODEGEN_GRAPHQL_URL=https://local.graphql.nhost.run/v1
CODEGEN_HASURA_ADMIN_SECRET=nhost-admin-secret CODEGEN_HASURA_ADMIN_SECRET=nhost-admin-secret
NEXT_PUBLIC_TURNSTILE_SITE_KEY=FIXME

View File

@@ -1,5 +1,18 @@
# @nhost/dashboard # @nhost/dashboard
## 1.29.0
### Minor Changes
- 55d8bb5: feat: integrate turnstile for signup verification
- 2a2e54c: fix: update docs url in run services form tooltip
- 18f942f: fix: display long error messages in error toast without overflow
### Patch Changes
- @nhost/react-apollo@13.0.0
- @nhost/nextjs@2.1.22
## 1.28.2 ## 1.28.2
### Patch Changes ### Patch Changes

View File

@@ -1,6 +1,6 @@
{ {
"name": "@nhost/dashboard", "name": "@nhost/dashboard",
"version": "1.28.2", "version": "1.29.0",
"private": true, "private": true,
"scripts": { "scripts": {
"preinstall": "npx only-allow pnpm", "preinstall": "npx only-allow pnpm",
@@ -35,6 +35,7 @@
"@heroicons/react": "^1.0.6", "@heroicons/react": "^1.0.6",
"@hookform/resolvers": "^3.3.4", "@hookform/resolvers": "^3.3.4",
"@iarna/toml": "^2.2.5", "@iarna/toml": "^2.2.5",
"@marsidev/react-turnstile": "^1.0.2",
"@mui/base": "5.0.0-beta.31", "@mui/base": "5.0.0-beta.31",
"@mui/material": "^5.15.14", "@mui/material": "^5.15.14",
"@mui/system": "^5.15.14", "@mui/system": "^5.15.14",

View File

@@ -112,18 +112,24 @@ export default function ErrorToast({
bounce: 0.1, bounce: 0.1,
}} }}
> >
<div className="flex w-full flex-row items-center justify-between space-x-4"> <div className="flex w-full flex-row items-center justify-between gap-4">
<button onClick={close} type="button" aria-label="Close"> <button
className="flex-shrink-0"
onClick={close}
type="button"
aria-label="Close"
>
<XIcon className="h-4 w-4 text-white" /> <XIcon className="h-4 w-4 text-white" />
</button> </button>
<span> <span className="flex-grow overflow-hidden break-words">
{msg ?? 'An unkown error has occured, please try again later!'} {msg ?? 'An unkown error has occured, please try again later!'}
</span> </span>
<button <button
type="button" type="button"
onClick={() => setShowInfo(!showInfo)} onClick={() => setShowInfo(!showInfo)}
className="flex flex-row items-center justify-center space-x-2 text-white" className="flex flex-shrink-0 flex-row items-center justify-center space-x-2 text-white"
aria-label="Show error details"
> >
<span>Info</span> <span>Info</span>
{showInfo ? ( {showInfo ? (

View File

@@ -70,7 +70,7 @@ export default function ComputeFormSection({
<a <a
target="_blank" target="_blank"
rel="noopener noreferrer" rel="noopener noreferrer"
href="https://docs.nhost.io/run/resources" href="https://docs.nhost.io/guides/run/resources"
className="underline" className="underline"
> >
resources resources

View File

@@ -35,7 +35,7 @@ export default function ReplicasFormSection() {
<a <a
target="_blank" target="_blank"
rel="noopener noreferrer" rel="noopener noreferrer"
href="https://docs.nhost.io/run/resources" href="https://docs.nhost.io/guides/run/resources"
className="underline" className="underline"
> >
resources resources

View File

@@ -10,6 +10,7 @@ import { Text } from '@/components/ui/v2/Text';
import { getToastStyleProps } from '@/utils/constants/settings'; import { getToastStyleProps } from '@/utils/constants/settings';
import { nhost } from '@/utils/nhost'; import { nhost } from '@/utils/nhost';
import { yupResolver } from '@hookform/resolvers/yup'; import { yupResolver } from '@hookform/resolvers/yup';
import { Turnstile } from '@marsidev/react-turnstile';
import { styled } from '@mui/material'; import { styled } from '@mui/material';
import { useSignUpEmailPassword } from '@nhost/nextjs'; import { useSignUpEmailPassword } from '@nhost/nextjs';
import { useRouter } from 'next/router'; import { useRouter } from 'next/router';
@@ -39,6 +40,9 @@ export default function SignUpPage() {
const [loading, setLoading] = useState(false); const [loading, setLoading] = useState(false);
const router = useRouter(); const router = useRouter();
// x-cf-turnstile-response
const [turnstileResponse, setTurnstileResponse] = useState(null);
const form = useForm<SignUpFormValues>({ const form = useForm<SignUpFormValues>({
reValidateMode: 'onSubmit', reValidateMode: 'onSubmit',
defaultValues: { defaultValues: {
@@ -66,11 +70,27 @@ export default function SignUpPage() {
password, password,
displayName, displayName,
}: SignUpFormValues) { }: SignUpFormValues) {
if (!turnstileResponse) {
toast.error(
'Please complete the signup verification challenge to continue.',
getToastStyleProps(),
);
return;
}
try { try {
const { needsEmailVerification } = await signUpEmailPassword( const { needsEmailVerification } = await signUpEmailPassword(
email, email,
password, password,
{ displayName }, {
displayName,
},
{
headers: {
'x-cf-turnstile-response': turnstileResponse,
},
},
); );
if (needsEmailVerification) { if (needsEmailVerification) {
@@ -94,7 +114,7 @@ export default function SignUpPage() {
Sign Up Sign Up
</Text> </Text>
<Box className="grid grid-flow-row gap-4 rounded-md border bg-transparent p-6 lg:p-12"> <Box className="grid grid-flow-row gap-4 p-6 bg-transparent border rounded-md lg:p-12">
<Button <Button
variant="borderless" variant="borderless"
className="!bg-white !text-black hover:ring-2 hover:ring-white hover:ring-opacity-50 disabled:!text-black disabled:!text-opacity-60" className="!bg-white !text-black hover:ring-2 hover:ring-white hover:ring-opacity-50 disabled:!text-black disabled:!text-opacity-60"
@@ -122,7 +142,7 @@ export default function SignUpPage() {
<div className="relative py-2"> <div className="relative py-2">
<Text <Text
className="absolute left-0 right-0 top-1/2 mx-auto w-12 -translate-y-1/2 bg-black px-2 text-center text-sm" className="absolute left-0 right-0 w-12 px-2 mx-auto text-sm text-center -translate-y-1/2 bg-black top-1/2"
color="disabled" color="disabled"
> >
OR OR
@@ -172,6 +192,12 @@ export default function SignUpPage() {
helperText={formState.errors.password?.message} helperText={formState.errors.password?.message}
/> />
<Turnstile
siteKey={process.env.NEXT_PUBLIC_TURNSTILE_SITE_KEY}
options={{ theme: 'dark', size: 'flexible' }}
onSuccess={setTurnstileResponse}
/>
<Button <Button
variant="outlined" variant="outlined"
color="secondary" color="secondary"
@@ -188,7 +214,7 @@ export default function SignUpPage() {
<Divider className="!my-2" /> <Divider className="!my-2" />
<Text color="secondary" className="text-center text-sm"> <Text color="secondary" className="text-sm text-center">
By signing up, you agree to our{' '} By signing up, you agree to our{' '}
<NavLink <NavLink
href="https://nhost.io/legal/terms-of-service" href="https://nhost.io/legal/terms-of-service"
@@ -212,7 +238,7 @@ export default function SignUpPage() {
</Text> </Text>
</Box> </Box>
<Text color="secondary" className="text-center text-base lg:text-lg"> <Text color="secondary" className="text-base text-center lg:text-lg">
Already have an account?{' '} Already have an account?{' '}
<NavLink href="/signin" color="white" className="font-medium"> <NavLink href="/signin" color="white" className="font-medium">
Sign In Sign In

View File

@@ -1,5 +1,11 @@
# @nhost-examples/cli # @nhost-examples/cli
## 0.3.12
### Patch Changes
- @nhost/nhost-js@3.1.10
## 0.3.11 ## 0.3.11
### Patch Changes ### Patch Changes

View File

@@ -1,6 +1,6 @@
{ {
"name": "@nhost-examples/cli", "name": "@nhost-examples/cli",
"version": "0.3.11", "version": "0.3.12",
"main": "src/index.mjs", "main": "src/index.mjs",
"private": true, "private": true,
"scripts": { "scripts": {

View File

@@ -1,5 +1,13 @@
# @nhost-examples/codegen-react-apollo # @nhost-examples/codegen-react-apollo
## 0.4.13
### Patch Changes
- Updated dependencies [55d8bb5]
- @nhost/react@3.6.0
- @nhost/react-apollo@13.0.0
## 0.4.12 ## 0.4.12
### Patch Changes ### Patch Changes

View File

@@ -1,6 +1,6 @@
{ {
"name": "@nhost-examples/codegen-react-apollo", "name": "@nhost-examples/codegen-react-apollo",
"version": "0.4.12", "version": "0.4.13",
"private": true, "private": true,
"scripts": { "scripts": {
"codegen": "graphql-codegen", "codegen": "graphql-codegen",

View File

@@ -1,5 +1,12 @@
# @nhost-examples/codegen-react-query # @nhost-examples/codegen-react-query
## 0.4.13
### Patch Changes
- Updated dependencies [55d8bb5]
- @nhost/react@3.6.0
## 0.4.12 ## 0.4.12
### Patch Changes ### Patch Changes

View File

@@ -1,6 +1,6 @@
{ {
"name": "@nhost-examples/codegen-react-query", "name": "@nhost-examples/codegen-react-query",
"version": "0.4.12", "version": "0.4.13",
"private": true, "private": true,
"scripts": { "scripts": {
"codegen": "graphql-codegen", "codegen": "graphql-codegen",

View File

@@ -1,5 +1,13 @@
# @nhost-examples/react-urql # @nhost-examples/react-urql
## 0.3.13
### Patch Changes
- Updated dependencies [55d8bb5]
- @nhost/react@3.6.0
- @nhost/react-urql@10.0.0
## 0.3.12 ## 0.3.12
### Patch Changes ### Patch Changes

View File

@@ -1,7 +1,7 @@
{ {
"name": "@nhost-examples/codegen-react-urql", "name": "@nhost-examples/codegen-react-urql",
"private": true, "private": true,
"version": "0.3.12", "version": "0.3.13",
"scripts": { "scripts": {
"dev": "vite", "dev": "vite",
"build": "tsc && vite build", "build": "tsc && vite build",

View File

@@ -1,5 +1,11 @@
# @nhost-examples/multi-tenant-one-to-many # @nhost-examples/multi-tenant-one-to-many
## 2.2.13
### Patch Changes
- @nhost/nhost-js@3.1.10
## 2.2.12 ## 2.2.12
### Patch Changes ### Patch Changes

View File

@@ -1,7 +1,7 @@
{ {
"name": "@nhost-examples/multi-tenant-one-to-many", "name": "@nhost-examples/multi-tenant-one-to-many",
"private": true, "private": true,
"version": "2.2.12", "version": "2.2.13",
"description": "", "description": "",
"main": "index.js", "main": "index.js",
"scripts": {}, "scripts": {},

View File

@@ -1,5 +1,14 @@
# @nhost-examples/nextjs # @nhost-examples/nextjs
## 0.3.13
### Patch Changes
- Updated dependencies [55d8bb5]
- @nhost/react@3.6.0
- @nhost/react-apollo@13.0.0
- @nhost/nextjs@2.1.22
## 0.3.12 ## 0.3.12
### Patch Changes ### Patch Changes

View File

@@ -1,6 +1,6 @@
{ {
"name": "@nhost-examples/nextjs", "name": "@nhost-examples/nextjs",
"version": "0.3.12", "version": "0.3.13",
"private": true, "private": true,
"scripts": { "scripts": {
"dev": "next dev", "dev": "next dev",

View File

@@ -1,5 +1,11 @@
# @nhost-examples/node-storage # @nhost-examples/node-storage
## 0.2.12
### Patch Changes
- @nhost/nhost-js@3.1.10
## 0.2.11 ## 0.2.11
### Patch Changes ### Patch Changes

View File

@@ -1,6 +1,6 @@
{ {
"name": "@nhost-examples/node-storage", "name": "@nhost-examples/node-storage",
"version": "0.2.11", "version": "0.2.12",
"private": true, "private": true,
"description": "This is an example of how to use the Storage with Node.js", "description": "This is an example of how to use the Storage with Node.js",
"main": "src/index.mjs", "main": "src/index.mjs",

View File

@@ -1,5 +1,11 @@
# @nhost-examples/nextjs-server-components # @nhost-examples/nextjs-server-components
## 0.4.14
### Patch Changes
- @nhost/nhost-js@3.1.10
## 0.4.13 ## 0.4.13
### Patch Changes ### Patch Changes

View File

@@ -1,6 +1,6 @@
{ {
"name": "@nhost-examples/nextjs-server-components", "name": "@nhost-examples/nextjs-server-components",
"version": "0.4.13", "version": "0.4.14",
"private": true, "private": true,
"scripts": { "scripts": {
"dev": "next dev", "dev": "next dev",

View File

@@ -1,5 +1,13 @@
# @nhost-examples/react-apollo # @nhost-examples/react-apollo
## 1.0.2
### Patch Changes
- Updated dependencies [55d8bb5]
- @nhost/react@3.6.0
- @nhost/react-apollo@13.0.0
## 1.0.1 ## 1.0.1
### Patch Changes ### Patch Changes

View File

@@ -1,6 +1,6 @@
{ {
"name": "@nhost-examples/react-apollo", "name": "@nhost-examples/react-apollo",
"version": "1.0.1", "version": "1.0.2",
"private": true, "private": true,
"type": "module", "type": "module",
"scripts": { "scripts": {

View File

@@ -1,5 +1,12 @@
# @nhost-examples/react-gqty # @nhost-examples/react-gqty
## 1.2.13
### Patch Changes
- Updated dependencies [55d8bb5]
- @nhost/react@3.6.0
## 1.2.12 ## 1.2.12
### Patch Changes ### Patch Changes

View File

@@ -1,7 +1,7 @@
{ {
"name": "@nhost-examples/react-gqty", "name": "@nhost-examples/react-gqty",
"private": true, "private": true,
"version": "1.2.12", "version": "1.2.13",
"type": "module", "type": "module",
"scripts": { "scripts": {
"dev": "vite", "dev": "vite",

View File

@@ -1,5 +1,13 @@
# @nhost-examples/react-native # @nhost-examples/react-native
## 0.0.6
### Patch Changes
- Updated dependencies [55d8bb5]
- @nhost/react@3.6.0
- @nhost/react-apollo@13.0.0
## 0.0.5 ## 0.0.5
### Patch Changes ### Patch Changes

View File

@@ -1,6 +1,6 @@
{ {
"name": "@nhost-examples/react-native", "name": "@nhost-examples/react-native",
"version": "0.0.5", "version": "0.0.6",
"private": true, "private": true,
"scripts": { "scripts": {
"android": "react-native run-android", "android": "react-native run-android",

View File

@@ -1,5 +1,13 @@
# @nhost-examples/vue-apollo # @nhost-examples/vue-apollo
## 0.6.13
### Patch Changes
- @nhost/nhost-js@3.1.10
- @nhost/apollo@7.1.7
- @nhost/vue@2.6.7
## 0.6.12 ## 0.6.12
### Patch Changes ### Patch Changes

View File

@@ -1,7 +1,7 @@
{ {
"name": "@nhost-examples/vue-apollo", "name": "@nhost-examples/vue-apollo",
"private": true, "private": true,
"version": "0.6.12", "version": "0.6.13",
"scripts": { "scripts": {
"dev": "vite", "dev": "vite",
"build": "vite build", "build": "vite build",

View File

@@ -1,5 +1,12 @@
# @nhost-examples/vue-quickstart # @nhost-examples/vue-quickstart
## 0.2.13
### Patch Changes
- @nhost/apollo@7.1.7
- @nhost/vue@2.6.7
## 0.2.12 ## 0.2.12
### Patch Changes ### Patch Changes

View File

@@ -1,6 +1,6 @@
{ {
"name": "@nhost-examples/vue-quickstart", "name": "@nhost-examples/vue-quickstart",
"version": "0.2.12", "version": "0.2.13",
"private": true, "private": true,
"scripts": { "scripts": {
"build": "vite build", "build": "vite build",

View File

@@ -1,5 +1,11 @@
# @nhost/apollo # @nhost/apollo
## 7.1.7
### Patch Changes
- @nhost/nhost-js@3.1.10
## 7.1.6 ## 7.1.6
### Patch Changes ### Patch Changes

View File

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

View File

@@ -1,5 +1,13 @@
# @nhost/react-apollo # @nhost/react-apollo
## 13.0.0
### Patch Changes
- Updated dependencies [55d8bb5]
- @nhost/react@3.6.0
- @nhost/apollo@7.1.7
## 12.0.6 ## 12.0.6
### Patch Changes ### Patch Changes

View File

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

View File

@@ -1,5 +1,12 @@
# @nhost/react-urql # @nhost/react-urql
## 10.0.0
### Patch Changes
- Updated dependencies [55d8bb5]
- @nhost/react@3.6.0
## 9.0.6 ## 9.0.6
### Patch Changes ### Patch Changes

View File

@@ -1,6 +1,6 @@
{ {
"name": "@nhost/react-urql", "name": "@nhost/react-urql",
"version": "9.0.6", "version": "10.0.0",
"description": "Nhost React URQL client", "description": "Nhost React URQL client",
"license": "MIT", "license": "MIT",
"keywords": [ "keywords": [

View File

@@ -156,7 +156,8 @@
"react-dom": "18.2.0", "react-dom": "18.2.0",
"@graphiql/react": "^0.22.3", "@graphiql/react": "^0.22.3",
"send": "^0.19.0", "send": "^0.19.0",
"dset": "^3.1.4" "dset": "^3.1.4",
"rollup": "^4.22.4"
} }
} }
} }

View File

@@ -1,5 +1,11 @@
# @nhost/hasura-auth-js # @nhost/hasura-auth-js
## 2.6.0
### Minor Changes
- 55d8bb5: feat: support custom headers in sign-up and deanonymize requests
## 2.5.6 ## 2.5.6
### Patch Changes ### Patch Changes

View File

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

View File

@@ -1,6 +1,7 @@
import type { import type {
NhostSession, NhostSession,
PasswordlessOptions, PasswordlessOptions,
RequestOptions,
SignUpOptions, SignUpOptions,
SignUpSecurityKeyOptions SignUpSecurityKeyOptions
} from '../../types' } from '../../types'
@@ -23,7 +24,13 @@ export type AuthEvents =
options?: PasswordlessOptions options?: PasswordlessOptions
} }
| { type: 'PASSWORDLESS_SMS_OTP'; phoneNumber?: string; otp?: string } | { type: 'PASSWORDLESS_SMS_OTP'; phoneNumber?: string; otp?: string }
| { type: 'SIGNUP_EMAIL_PASSWORD'; email?: string; password?: string; options?: SignUpOptions } | {
type: 'SIGNUP_EMAIL_PASSWORD'
email?: string
password?: string
options?: SignUpOptions
requestOptions?: RequestOptions
}
| { type: 'SIGNUP_SECURITY_KEY'; email?: string; options?: SignUpSecurityKeyOptions } | { type: 'SIGNUP_SECURITY_KEY'; email?: string; options?: SignUpSecurityKeyOptions }
| { type: 'SIGNOUT'; all?: boolean } | { type: 'SIGNOUT'; all?: boolean }
| { type: 'SIGNIN_MFA_TOTP'; ticket?: string; otp?: string } | { type: 'SIGNIN_MFA_TOTP'; ticket?: string; otp?: string }

View File

@@ -34,6 +34,7 @@ import {
PasswordlessSmsOtpResponse, PasswordlessSmsOtpResponse,
PasswordlessSmsResponse, PasswordlessSmsResponse,
RefreshSessionResponse, RefreshSessionResponse,
RequestOptions,
SignInAnonymousResponse, SignInAnonymousResponse,
SignInMfaTotpResponse, SignInMfaTotpResponse,
SignInPATResponse, SignInPATResponse,
@@ -92,9 +93,10 @@ export const createAuthMachine = ({
const postRequest = async <T = any, D = any>( const postRequest = async <T = any, D = any>(
url: string, url: string,
data?: D, data?: D,
token?: string | null token?: string | null,
headers?: Record<string, string>
): Promise<T> => { ): Promise<T> => {
const result = await postFetch<T>(`${backendUrl}${url}`, data, token) const result = await postFetch<T>(`${backendUrl}${url}`, data, token, headers)
return result.data return result.data
} }
@@ -910,13 +912,14 @@ export const createAuthMachine = ({
return signOutResponse return signOutResponse
}, },
signUpEmailPassword: async (context, { email, password, options }) => { signUpEmailPassword: async (context, { email, password, options, requestOptions }) => {
if (!isValidEmail(email)) { if (!isValidEmail(email)) {
return Promise.reject<SignUpResponse>({ error: INVALID_EMAIL_ERROR }) return Promise.reject<SignUpResponse>({ error: INVALID_EMAIL_ERROR })
} }
if (!isValidPassword(password)) { if (!isValidPassword(password)) {
return Promise.reject<SignUpResponse>({ error: INVALID_PASSWORD_ERROR }) return Promise.reject<SignUpResponse>({ error: INVALID_PASSWORD_ERROR })
} }
if (context.user?.isAnonymous) { if (context.user?.isAnonymous) {
return postRequest<SignUpResponse>( return postRequest<SignUpResponse>(
'/user/deanonymize', '/user/deanonymize',
@@ -926,14 +929,20 @@ export const createAuthMachine = ({
password, password,
options: rewriteRedirectTo(clientUrl, options) options: rewriteRedirectTo(clientUrl, options)
}, },
context.accessToken.value context.accessToken.value,
requestOptions?.headers
) )
} else { } else {
return postRequest<SignUpResponse>('/signup/email-password', { return postRequest<SignUpResponse>(
email, '/signup/email-password',
password, {
options: rewriteRedirectTo(clientUrl, options) email,
}) password,
options: rewriteRedirectTo(clientUrl, options)
},
null,
requestOptions?.headers
)
} }
}, },
signUpSecurityKey: async (_, { email, options }) => { signUpSecurityKey: async (_, { email, options }) => {

View File

@@ -1,6 +1,6 @@
import { USER_ALREADY_SIGNED_IN } from '../errors' import { USER_ALREADY_SIGNED_IN } from '../errors'
import { AuthInterpreter } from '../machines' import { AuthInterpreter } from '../machines'
import { SignUpOptions } from '../types' import { RequestOptions, SignUpOptions } from '../types'
import { import {
AuthActionLoadingState, AuthActionLoadingState,
@@ -20,13 +20,15 @@ export const signUpEmailPasswordPromise = (
interpreter: AuthInterpreter, interpreter: AuthInterpreter,
email: string, email: string,
password: string, password: string,
options?: SignUpOptions options?: SignUpOptions,
requestOptions?: RequestOptions
): Promise<SignUpEmailPasswordHandlerResult> => ): Promise<SignUpEmailPasswordHandlerResult> =>
new Promise<SignUpEmailPasswordHandlerResult>((resolve) => { new Promise<SignUpEmailPasswordHandlerResult>((resolve) => {
const { changed, context } = interpreter.send('SIGNUP_EMAIL_PASSWORD', { const { changed, context } = interpreter.send('SIGNUP_EMAIL_PASSWORD', {
email, email,
password, password,
options options,
requestOptions
}) })
if (!changed) { if (!changed) {
return resolve({ return resolve({

View File

@@ -57,3 +57,8 @@ export interface WorkOsOptions extends CommonProviderOptions {
provider?: string provider?: string
} }
export interface ProviderOptions extends CommonProviderOptions, WorkOsOptions {} export interface ProviderOptions extends CommonProviderOptions, WorkOsOptions {}
export interface RequestOptions {
// optional extra headers to be sent with request (ex: x-cf-turnstile-response)
headers?: Record<string, string>
}

View File

@@ -17,7 +17,11 @@ if (typeof EdgeRuntime !== 'string') {
const fetchWrapper = async <T>( const fetchWrapper = async <T>(
url: string, url: string,
method: 'GET' | 'POST', method: 'GET' | 'POST',
{ token, body }: { token?: string | null; body?: any } = {} {
token,
body,
extraHeaders
}: { token?: string | null; body?: any; extraHeaders?: HeadersInit } = {}
): Promise<FetcResponse<T>> => { ): Promise<FetcResponse<T>> => {
const headers: HeadersInit = { const headers: HeadersInit = {
'Content-Type': 'application/json', 'Content-Type': 'application/json',
@@ -26,9 +30,12 @@ const fetchWrapper = async <T>(
if (token) { if (token) {
headers['Authorization'] = `Bearer ${token}` headers['Authorization'] = `Bearer ${token}`
} }
const mergedHeaders = { ...headers, ...extraHeaders }
const options: RequestInit = { const options: RequestInit = {
method, method,
headers headers: mergedHeaders
} }
if (body) { if (body) {
options.body = JSON.stringify(body) options.body = JSON.stringify(body)
@@ -59,8 +66,9 @@ const fetchWrapper = async <T>(
export const postFetch = async <T>( export const postFetch = async <T>(
url: string, url: string,
body: any, body: any,
token?: string | null token?: string | null,
): Promise<FetcResponse<T>> => fetchWrapper<T>(url, 'POST', { token, body }) extraHeaders?: HeadersInit
): Promise<FetcResponse<T>> => fetchWrapper<T>(url, 'POST', { token, body, extraHeaders })
export const getFetch = <T>(url: string, token?: string | null): Promise<FetcResponse<T>> => export const getFetch = <T>(url: string, token?: string | null): Promise<FetcResponse<T>> =>
fetchWrapper<T>(url, 'GET', { token }) fetchWrapper<T>(url, 'GET', { token })

View File

@@ -1,5 +1,12 @@
# @nhost/nextjs # @nhost/nextjs
## 2.1.22
### Patch Changes
- Updated dependencies [55d8bb5]
- @nhost/react@3.6.0
## 2.1.21 ## 2.1.21
### Patch Changes ### Patch Changes

View File

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

View File

@@ -1,5 +1,12 @@
# @nhost/nhost-js # @nhost/nhost-js
## 3.1.10
### Patch Changes
- Updated dependencies [55d8bb5]
- @nhost/hasura-auth-js@2.6.0
## 3.1.9 ## 3.1.9
### Patch Changes ### Patch Changes

View File

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

View File

@@ -1,5 +1,15 @@
# @nhost/react # @nhost/react
## 3.6.0
### Minor Changes
- 55d8bb5: feat: add `requestOptions` to `signUpEmailPassword` to allow passing extra headers with the signup request
### Patch Changes
- @nhost/nhost-js@3.1.10
## 3.5.6 ## 3.5.6
### Patch Changes ### Patch Changes

View File

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

View File

@@ -1,7 +1,8 @@
import { import {
signUpEmailPasswordPromise, signUpEmailPasswordPromise,
SignUpEmailPasswordState, SignUpEmailPasswordState,
SignUpOptions SignUpOptions,
RequestOptions
} from '@nhost/nhost-js' } from '@nhost/nhost-js'
import { useSelector } from '@xstate/react' import { useSelector } from '@xstate/react'
import { useAuthInterpreter } from './useAuthInterpreter' import { useAuthInterpreter } from './useAuthInterpreter'
@@ -12,7 +13,8 @@ interface SignUpEmailPasswordHandler {
( (
email: string, email: string,
password: string, password: string,
options?: SignUpOptions options?: SignUpOptions,
requestOptions?: RequestOptions
): Promise<SignUpEmailPasswordHandlerResult> ): Promise<SignUpEmailPasswordHandlerResult>
} }
@@ -69,8 +71,9 @@ export const useSignUpEmailPassword: SignUpEmailPasswordHook = (options) => {
const signUpEmailPassword: SignUpEmailPasswordHandler = ( const signUpEmailPassword: SignUpEmailPasswordHandler = (
email, email,
password, password,
valueOptions = options valueOptions = options,
) => signUpEmailPasswordPromise(service, email, password as string, valueOptions) requestOptions
) => signUpEmailPasswordPromise(service, email, password as string, valueOptions, requestOptions)
const user = useSelector( const user = useSelector(
service, service,

View File

@@ -1,5 +1,11 @@
# @nhost/vue # @nhost/vue
## 2.6.7
### Patch Changes
- @nhost/nhost-js@3.1.10
## 2.6.6 ## 2.6.6
### Patch Changes ### Patch Changes

View File

@@ -1,6 +1,6 @@
{ {
"name": "@nhost/vue", "name": "@nhost/vue",
"version": "2.6.6", "version": "2.6.7",
"description": "Nhost Vue library", "description": "Nhost Vue library",
"license": "MIT", "license": "MIT",
"keywords": [ "keywords": [

1271
pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff