Compare commits
28 Commits
@nhost/rea
...
@nhost/rea
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
024f026241 | ||
|
|
a422a4850d | ||
|
|
a7e67979fe | ||
|
|
1dcbf268db | ||
|
|
5c5d489740 | ||
|
|
a2559e3482 | ||
|
|
bbef104a85 | ||
|
|
7843b1aec1 | ||
|
|
4711bfa8ec | ||
|
|
6f3f8a5020 | ||
|
|
a120bcc8fc | ||
|
|
53e20e87f3 | ||
|
|
9479aeb596 | ||
|
|
c4f11af072 | ||
|
|
747aa96914 | ||
|
|
5682d92592 | ||
|
|
2cf6556499 | ||
|
|
89553fcaf6 | ||
|
|
10beea7246 | ||
|
|
1334ddb693 | ||
|
|
302c28b202 | ||
|
|
f3f760b987 | ||
|
|
34470ff6e0 | ||
|
|
4e4600d769 | ||
|
|
44d57d4b89 | ||
|
|
84ba29dd7f | ||
|
|
18ac56d097 | ||
|
|
366fc2403d |
20
README.md
20
README.md
@@ -204,21 +204,28 @@ Here are some ways of contributing to making Nhost better:
|
|||||||
<sub><b>Szilárd Dóró</b></sub>
|
<sub><b>Szilárd Dóró</b></sub>
|
||||||
</a>
|
</a>
|
||||||
</td>
|
</td>
|
||||||
|
<td align="center">
|
||||||
|
<a href="https://github.com/GavanWilhite">
|
||||||
|
<img src="https://avatars.githubusercontent.com/u/2085119?v=4" width="100;" alt="GavanWilhite"/>
|
||||||
|
<br />
|
||||||
|
<sub><b>Gavan Wilhite</b></sub>
|
||||||
|
</a>
|
||||||
|
</td>
|
||||||
<td align="center">
|
<td align="center">
|
||||||
<a href="https://github.com/FuzzyReason">
|
<a href="https://github.com/FuzzyReason">
|
||||||
<img src="https://avatars.githubusercontent.com/u/62517920?v=4" width="100;" alt="FuzzyReason"/>
|
<img src="https://avatars.githubusercontent.com/u/62517920?v=4" width="100;" alt="FuzzyReason"/>
|
||||||
<br />
|
<br />
|
||||||
<sub><b>Vadim Smirnov</b></sub>
|
<sub><b>Vadim Smirnov</b></sub>
|
||||||
</a>
|
</a>
|
||||||
</td>
|
</td></tr>
|
||||||
|
<tr>
|
||||||
<td align="center">
|
<td align="center">
|
||||||
<a href="https://github.com/macmac49">
|
<a href="https://github.com/macmac49">
|
||||||
<img src="https://avatars.githubusercontent.com/u/831190?v=4" width="100;" alt="macmac49"/>
|
<img src="https://avatars.githubusercontent.com/u/831190?v=4" width="100;" alt="macmac49"/>
|
||||||
<br />
|
<br />
|
||||||
<sub><b>Macmac49</b></sub>
|
<sub><b>Macmac49</b></sub>
|
||||||
</a>
|
</a>
|
||||||
</td></tr>
|
</td>
|
||||||
<tr>
|
|
||||||
<td align="center">
|
<td align="center">
|
||||||
<a href="https://github.com/subhendukundu">
|
<a href="https://github.com/subhendukundu">
|
||||||
<img src="https://avatars.githubusercontent.com/u/20059141?v=4" width="100;" alt="subhendukundu"/>
|
<img src="https://avatars.githubusercontent.com/u/20059141?v=4" width="100;" alt="subhendukundu"/>
|
||||||
@@ -253,13 +260,6 @@ Here are some ways of contributing to making Nhost better:
|
|||||||
<br />
|
<br />
|
||||||
<sub><b>Filip Hájek</b></sub>
|
<sub><b>Filip Hájek</b></sub>
|
||||||
</a>
|
</a>
|
||||||
</td>
|
|
||||||
<td align="center">
|
|
||||||
<a href="https://github.com/GavanWilhite">
|
|
||||||
<img src="https://avatars.githubusercontent.com/u/2085119?v=4" width="100;" alt="GavanWilhite"/>
|
|
||||||
<br />
|
|
||||||
<sub><b>Gavan Wilhite</b></sub>
|
|
||||||
</a>
|
|
||||||
</td></tr>
|
</td></tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td align="center">
|
<td align="center">
|
||||||
|
|||||||
@@ -1,5 +1,11 @@
|
|||||||
# @nhost/docs
|
# @nhost/docs
|
||||||
|
|
||||||
|
## 0.0.2
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- 747aa969: fix: added twitch and discord as provider
|
||||||
|
|
||||||
## 0.0.1
|
## 0.0.1
|
||||||
|
|
||||||
### Patch Changes
|
### Patch Changes
|
||||||
|
|||||||
@@ -22,4 +22,6 @@ type Provider =
|
|||||||
| 'strava'
|
| 'strava'
|
||||||
| 'gitlab'
|
| 'gitlab'
|
||||||
| 'bitbucket'
|
| 'bitbucket'
|
||||||
|
| 'discord'
|
||||||
|
| 'twitch'
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -0,0 +1,50 @@
|
|||||||
|
---
|
||||||
|
# ⚠️ AUTO-GENERATED CONTENT. DO NOT EDIT THIS FILE DIRECTLY! ⚠️
|
||||||
|
title: useSignInSmsPasswordless()
|
||||||
|
sidebar_label: useSignInSmsPasswordless()
|
||||||
|
slug: /reference/nextjs/use-sign-in-sms-passwordless
|
||||||
|
description: Use the hook `useSignInSmsPasswordless` to sign in a user with a one-time password sent via SMS to a phone.
|
||||||
|
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/react/src/useSignInSmsPasswordless.ts#L57
|
||||||
|
---
|
||||||
|
|
||||||
|
# `useSignInSmsPasswordless()`
|
||||||
|
|
||||||
|
Use the hook `useSignInSmsPasswordless` to sign in a user with a one-time password sent via SMS to a phone.
|
||||||
|
|
||||||
|
1. The `signInSmsPasswordless` action sends a one-time password to the given phone number.
|
||||||
|
2. The client is then awaiting the OTP. `needsOtp` equals true.
|
||||||
|
3. After the code is received by SMS, the client sends the code with `sendOtp`. On success, the client is authenticated, and `isSuccess` equals `true`.
|
||||||
|
|
||||||
|
Any error is monitored through `isError` and `error`. While the `signInSmsPasswordless` and `sendOtp` actions are running, `isLoading` equals `true`.
|
||||||
|
|
||||||
|
```tsx
|
||||||
|
const {
|
||||||
|
signInSmsPasswordless,
|
||||||
|
sendOtp,
|
||||||
|
needsOtp,
|
||||||
|
isLoading,
|
||||||
|
isSuccess,
|
||||||
|
isError,
|
||||||
|
error
|
||||||
|
} = useSignInSmsPasswordless()
|
||||||
|
|
||||||
|
console.log({ isLoading, isSuccess, isError, error })
|
||||||
|
|
||||||
|
const askCode = async (e) => {
|
||||||
|
e.preventDefault()
|
||||||
|
await signInSmsPasswordless('+32455555555')
|
||||||
|
}
|
||||||
|
|
||||||
|
const sendCode = async (e) => {
|
||||||
|
e.preventDefault()
|
||||||
|
await sendOtp('123456')
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
## Parameters
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
**<span className="parameter-name">stateOptions</span>** <span className="optional-status">optional</span> `PasswordlessOptions`
|
||||||
|
|
||||||
|
---
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
---
|
||||||
|
# ⚠️ AUTO-GENERATED CONTENT. DO NOT EDIT THIS FILE DIRECTLY! ⚠️
|
||||||
|
title: SignInSmsPasswordlessHandler
|
||||||
|
sidebar_label: SignInSmsPasswordlessHandler
|
||||||
|
description: No description provided.
|
||||||
|
displayed_sidebar: referenceSidebar
|
||||||
|
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/react/src/useSignInSmsPasswordless.ts#L14
|
||||||
|
---
|
||||||
|
|
||||||
|
# `SignInSmsPasswordlessHandler`
|
||||||
@@ -0,0 +1,62 @@
|
|||||||
|
---
|
||||||
|
# ⚠️ AUTO-GENERATED CONTENT. DO NOT EDIT THIS FILE DIRECTLY! ⚠️
|
||||||
|
title: SignInSmsPasswordlessHookResult
|
||||||
|
sidebar_label: SignInSmsPasswordlessHookResult
|
||||||
|
description: No description provided.
|
||||||
|
displayed_sidebar: referenceSidebar
|
||||||
|
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/react/src/useSignInSmsPasswordless.ts#L23
|
||||||
|
---
|
||||||
|
|
||||||
|
# `SignInSmsPasswordlessHookResult`
|
||||||
|
|
||||||
|
## Parameters
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
**<span className="parameter-name">needsOtp</span>** <span className="optional-status">required</span> `boolean`
|
||||||
|
|
||||||
|
Returns true when the one-time password has been sent over by SMS, and the user needs to send it back to complete sign-in.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
**<span className="parameter-name">isError</span>** <span className="optional-status">required</span> `boolean`
|
||||||
|
|
||||||
|
**`@returns`**
|
||||||
|
|
||||||
|
`true` if an error occurred
|
||||||
|
|
||||||
|
**`@depreacted`**
|
||||||
|
|
||||||
|
use `!isSuccess` or `!!error` instead
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
**<span className="parameter-name">error</span>** <span className="optional-status">required</span> `null` | `ErrorPayload`
|
||||||
|
|
||||||
|
Provides details about the error
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
**<span className="parameter-name">isLoading</span>** <span className="optional-status">required</span> `boolean`
|
||||||
|
|
||||||
|
**`@returns`**
|
||||||
|
|
||||||
|
`true` when the action is executing, `false` when it finished its execution.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
**<span className="parameter-name">isSuccess</span>** <span className="optional-status">required</span> `boolean`
|
||||||
|
|
||||||
|
Returns `true` if the action is successful.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
**<span className="parameter-name">signInSmsPasswordless</span>** <span className="optional-status">required</span> [`SignInSmsPasswordlessHandler`](/reference/docgen/nextjs/types/sign-in-sms-passwordless-handler)
|
||||||
|
|
||||||
|
Sends a one-time code to the given phoneNumber
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
**<span className="parameter-name">sendOtp</span>** <span className="optional-status">required</span> [`SignInSmsPasswordlessOtpHandler`](/reference/docgen/nextjs/types/sign-in-sms-passwordless-otp-handler)
|
||||||
|
|
||||||
|
---
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
---
|
||||||
|
# ⚠️ AUTO-GENERATED CONTENT. DO NOT EDIT THIS FILE DIRECTLY! ⚠️
|
||||||
|
title: SignInSmsPasswordlessOtpHandler
|
||||||
|
sidebar_label: SignInSmsPasswordlessOtpHandler
|
||||||
|
description: No description provided.
|
||||||
|
displayed_sidebar: referenceSidebar
|
||||||
|
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/react/src/useSignInSmsPasswordless.ts#L18
|
||||||
|
---
|
||||||
|
|
||||||
|
# `SignInSmsPasswordlessOtpHandler`
|
||||||
@@ -0,0 +1,50 @@
|
|||||||
|
---
|
||||||
|
# ⚠️ AUTO-GENERATED CONTENT. DO NOT EDIT THIS FILE DIRECTLY! ⚠️
|
||||||
|
title: useSignInSmsPasswordless()
|
||||||
|
sidebar_label: useSignInSmsPasswordless()
|
||||||
|
slug: /reference/react/use-sign-in-sms-passwordless
|
||||||
|
description: Use the hook `useSignInSmsPasswordless` to sign in a user with a one-time password sent via SMS to a phone.
|
||||||
|
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/react/src/useSignInSmsPasswordless.ts#L57
|
||||||
|
---
|
||||||
|
|
||||||
|
# `useSignInSmsPasswordless()`
|
||||||
|
|
||||||
|
Use the hook `useSignInSmsPasswordless` to sign in a user with a one-time password sent via SMS to a phone.
|
||||||
|
|
||||||
|
1. The `signInSmsPasswordless` action sends a one-time password to the given phone number.
|
||||||
|
2. The client is then awaiting the OTP. `needsOtp` equals true.
|
||||||
|
3. After the code is received by SMS, the client sends the code with `sendOtp`. On success, the client is authenticated, and `isSuccess` equals `true`.
|
||||||
|
|
||||||
|
Any error is monitored through `isError` and `error`. While the `signInSmsPasswordless` and `sendOtp` actions are running, `isLoading` equals `true`.
|
||||||
|
|
||||||
|
```tsx
|
||||||
|
const {
|
||||||
|
signInSmsPasswordless,
|
||||||
|
sendOtp,
|
||||||
|
needsOtp,
|
||||||
|
isLoading,
|
||||||
|
isSuccess,
|
||||||
|
isError,
|
||||||
|
error
|
||||||
|
} = useSignInSmsPasswordless()
|
||||||
|
|
||||||
|
console.log({ isLoading, isSuccess, isError, error })
|
||||||
|
|
||||||
|
const askCode = async (e) => {
|
||||||
|
e.preventDefault()
|
||||||
|
await signInSmsPasswordless('+32455555555')
|
||||||
|
}
|
||||||
|
|
||||||
|
const sendCode = async (e) => {
|
||||||
|
e.preventDefault()
|
||||||
|
await sendOtp('123456')
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
## Parameters
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
**<span className="parameter-name">stateOptions</span>** <span className="optional-status">optional</span> `PasswordlessOptions`
|
||||||
|
|
||||||
|
---
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
---
|
||||||
|
# ⚠️ AUTO-GENERATED CONTENT. DO NOT EDIT THIS FILE DIRECTLY! ⚠️
|
||||||
|
title: SignInSmsPasswordlessHandler
|
||||||
|
sidebar_label: SignInSmsPasswordlessHandler
|
||||||
|
description: No description provided.
|
||||||
|
displayed_sidebar: referenceSidebar
|
||||||
|
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/react/src/useSignInSmsPasswordless.ts#L14
|
||||||
|
---
|
||||||
|
|
||||||
|
# `SignInSmsPasswordlessHandler`
|
||||||
@@ -0,0 +1,62 @@
|
|||||||
|
---
|
||||||
|
# ⚠️ AUTO-GENERATED CONTENT. DO NOT EDIT THIS FILE DIRECTLY! ⚠️
|
||||||
|
title: SignInSmsPasswordlessHookResult
|
||||||
|
sidebar_label: SignInSmsPasswordlessHookResult
|
||||||
|
description: No description provided.
|
||||||
|
displayed_sidebar: referenceSidebar
|
||||||
|
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/react/src/useSignInSmsPasswordless.ts#L23
|
||||||
|
---
|
||||||
|
|
||||||
|
# `SignInSmsPasswordlessHookResult`
|
||||||
|
|
||||||
|
## Parameters
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
**<span className="parameter-name">needsOtp</span>** <span className="optional-status">required</span> `boolean`
|
||||||
|
|
||||||
|
Returns true when the one-time password has been sent over by SMS, and the user needs to send it back to complete sign-in.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
**<span className="parameter-name">isError</span>** <span className="optional-status">required</span> `boolean`
|
||||||
|
|
||||||
|
**`@returns`**
|
||||||
|
|
||||||
|
`true` if an error occurred
|
||||||
|
|
||||||
|
**`@depreacted`**
|
||||||
|
|
||||||
|
use `!isSuccess` or `!!error` instead
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
**<span className="parameter-name">error</span>** <span className="optional-status">required</span> `null` | `ErrorPayload`
|
||||||
|
|
||||||
|
Provides details about the error
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
**<span className="parameter-name">isLoading</span>** <span className="optional-status">required</span> `boolean`
|
||||||
|
|
||||||
|
**`@returns`**
|
||||||
|
|
||||||
|
`true` when the action is executing, `false` when it finished its execution.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
**<span className="parameter-name">isSuccess</span>** <span className="optional-status">required</span> `boolean`
|
||||||
|
|
||||||
|
Returns `true` if the action is successful.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
**<span className="parameter-name">signInSmsPasswordless</span>** <span className="optional-status">required</span> [`SignInSmsPasswordlessHandler`](/reference/docgen/react/types/sign-in-sms-passwordless-handler)
|
||||||
|
|
||||||
|
Sends a one-time code to the given phoneNumber
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
**<span className="parameter-name">sendOtp</span>** <span className="optional-status">required</span> [`SignInSmsPasswordlessOtpHandler`](/reference/docgen/react/types/sign-in-sms-passwordless-otp-handler)
|
||||||
|
|
||||||
|
---
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
---
|
||||||
|
# ⚠️ AUTO-GENERATED CONTENT. DO NOT EDIT THIS FILE DIRECTLY! ⚠️
|
||||||
|
title: SignInSmsPasswordlessOtpHandler
|
||||||
|
sidebar_label: SignInSmsPasswordlessOtpHandler
|
||||||
|
description: No description provided.
|
||||||
|
displayed_sidebar: referenceSidebar
|
||||||
|
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/react/src/useSignInSmsPasswordless.ts#L18
|
||||||
|
---
|
||||||
|
|
||||||
|
# `SignInSmsPasswordlessOtpHandler`
|
||||||
@@ -0,0 +1,50 @@
|
|||||||
|
---
|
||||||
|
# ⚠️ AUTO-GENERATED CONTENT. DO NOT EDIT THIS FILE DIRECTLY! ⚠️
|
||||||
|
title: useSignInSmsPasswordless()
|
||||||
|
sidebar_label: useSignInSmsPasswordless()
|
||||||
|
slug: /reference/vue/use-sign-in-sms-passwordless
|
||||||
|
description: Use the composable `useSignInSmsPasswordless` to sign in a user with a one-time password sent via SMS to a phone.
|
||||||
|
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/vue/src/useSignInSmsPasswordless.ts#L65
|
||||||
|
---
|
||||||
|
|
||||||
|
# `useSignInSmsPasswordless()`
|
||||||
|
|
||||||
|
Use the composable `useSignInSmsPasswordless` to sign in a user with a one-time password sent via SMS to a phone.
|
||||||
|
|
||||||
|
1. The `signInSmsPasswordless` action sends a one-time password to the given phone number.
|
||||||
|
2. The client is then awaiting the OTP. `needsOtp` equals true.
|
||||||
|
3. After the code is received by SMS, the client sends the code with `sendOtp`. On success, the client is authenticated, and `isSuccess` equals `true`.
|
||||||
|
|
||||||
|
Any error is monitored through `isError` and `error`. While the `signInSmsPasswordless` and `sendOtp` actions are running, `isLoading` equals `true`.
|
||||||
|
|
||||||
|
```tsx
|
||||||
|
const {
|
||||||
|
signInSmsPasswordless,
|
||||||
|
sendOtp,
|
||||||
|
needsOtp,
|
||||||
|
isLoading,
|
||||||
|
isSuccess,
|
||||||
|
isError,
|
||||||
|
error
|
||||||
|
} = useSignInSmsPasswordless()
|
||||||
|
|
||||||
|
console.log({ isLoading, isSuccess, isError, error })
|
||||||
|
|
||||||
|
const askCode = async (e) => {
|
||||||
|
e.preventDefault()
|
||||||
|
await signInSmsPasswordless('+32455555555')
|
||||||
|
}
|
||||||
|
|
||||||
|
const sendCode = async (e) => {
|
||||||
|
e.preventDefault()
|
||||||
|
await sendOtp('123456')
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
## Parameters
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
**<span className="parameter-name">stateOptions</span>** <span className="optional-status">optional</span> `NestedRefOfValue<undefined | PasswordlessOptions>`
|
||||||
|
|
||||||
|
---
|
||||||
@@ -0,0 +1,62 @@
|
|||||||
|
---
|
||||||
|
# ⚠️ AUTO-GENERATED CONTENT. DO NOT EDIT THIS FILE DIRECTLY! ⚠️
|
||||||
|
title: SignInSmsPasswordlessComposableResult
|
||||||
|
sidebar_label: SignInSmsPasswordlessComposableResult
|
||||||
|
description: No description provided.
|
||||||
|
displayed_sidebar: referenceSidebar
|
||||||
|
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/vue/src/useSignInSmsPasswordless.ts#L31
|
||||||
|
---
|
||||||
|
|
||||||
|
# `SignInSmsPasswordlessComposableResult`
|
||||||
|
|
||||||
|
## Parameters
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
**<span className="parameter-name">needsOtp</span>** <span className="optional-status">required</span> `Ref<boolean>`
|
||||||
|
|
||||||
|
Returns true when the one-time password has been sent over by SMS, and the user needs to send it back to complete sign-in.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
**<span className="parameter-name">isError</span>** <span className="optional-status">required</span> `Ref<boolean>`
|
||||||
|
|
||||||
|
**`@returns`**
|
||||||
|
|
||||||
|
`true` if an error occurred
|
||||||
|
|
||||||
|
**`@depreacted`**
|
||||||
|
|
||||||
|
use `!isSuccess` or `!!error` instead
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
**<span className="parameter-name">error</span>** <span className="optional-status">required</span> `Ref<null | ErrorPayload>`
|
||||||
|
|
||||||
|
Provides details about the error
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
**<span className="parameter-name">isLoading</span>** <span className="optional-status">required</span> `Ref<boolean>`
|
||||||
|
|
||||||
|
**`@returns`**
|
||||||
|
|
||||||
|
`true` when the action is executing, `false` when it finished its execution.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
**<span className="parameter-name">isSuccess</span>** <span className="optional-status">required</span> `Ref<boolean>`
|
||||||
|
|
||||||
|
Returns `true` if the action is successful.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
**<span className="parameter-name">signInSmsPasswordless</span>** <span className="optional-status">required</span> [`SignInSmsPasswordlessHandler`](/reference/docgen/vue/types/sign-in-sms-passwordless-handler)
|
||||||
|
|
||||||
|
Sends a one-time code to the given phoneNumber
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
**<span className="parameter-name">sendOtp</span>** <span className="optional-status">required</span> [`SignInSmsPasswordlessOtpHandler`](/reference/docgen/vue/types/sign-in-sms-passwordless-otp-handler)
|
||||||
|
|
||||||
|
---
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
---
|
||||||
|
# ⚠️ AUTO-GENERATED CONTENT. DO NOT EDIT THIS FILE DIRECTLY! ⚠️
|
||||||
|
title: SignInSmsPasswordlessHandler
|
||||||
|
sidebar_label: SignInSmsPasswordlessHandler
|
||||||
|
description: No description provided.
|
||||||
|
displayed_sidebar: referenceSidebar
|
||||||
|
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/vue/src/useSignInSmsPasswordless.ts#L16
|
||||||
|
---
|
||||||
|
|
||||||
|
# `SignInSmsPasswordlessHandler`
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
---
|
||||||
|
# ⚠️ AUTO-GENERATED CONTENT. DO NOT EDIT THIS FILE DIRECTLY! ⚠️
|
||||||
|
title: SignInSmsPasswordlessOtpHandler
|
||||||
|
sidebar_label: SignInSmsPasswordlessOtpHandler
|
||||||
|
description: No description provided.
|
||||||
|
displayed_sidebar: referenceSidebar
|
||||||
|
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/vue/src/useSignInSmsPasswordless.ts#L23
|
||||||
|
---
|
||||||
|
|
||||||
|
# `SignInSmsPasswordlessOtpHandler`
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@nhost/docs",
|
"name": "@nhost/docs",
|
||||||
"version": "0.0.1",
|
"version": "0.0.2",
|
||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"docusaurus": "docusaurus",
|
"docusaurus": "docusaurus",
|
||||||
|
|||||||
@@ -1,5 +1,13 @@
|
|||||||
# @nhost/apollo
|
# @nhost/apollo
|
||||||
|
|
||||||
|
## 0.5.24
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- 10beea72: Fix React Native build: Export `package.json` for all npm packages.
|
||||||
|
- Updated dependencies [10beea72]
|
||||||
|
- @nhost/nhost-js@1.4.7
|
||||||
|
|
||||||
## 0.5.23
|
## 0.5.23
|
||||||
|
|
||||||
### Patch Changes
|
### Patch Changes
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@nhost/apollo",
|
"name": "@nhost/apollo",
|
||||||
"version": "0.5.23",
|
"version": "0.5.24",
|
||||||
"description": "Nhost Apollo Client library",
|
"description": "Nhost Apollo Client library",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
@@ -31,6 +31,7 @@
|
|||||||
"README.md"
|
"README.md"
|
||||||
],
|
],
|
||||||
"exports": {
|
"exports": {
|
||||||
|
"./package.json": "./package.json",
|
||||||
".": {
|
".": {
|
||||||
"import": {
|
"import": {
|
||||||
"node": "./dist/index.cjs.js",
|
"node": "./dist/index.cjs.js",
|
||||||
|
|||||||
@@ -1,5 +1,12 @@
|
|||||||
# @nhost/core
|
# @nhost/core
|
||||||
|
|
||||||
|
## 0.7.6
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- 747aa969: fix: added twitch and discord as provider
|
||||||
|
- 10beea72: Fix React Native build: Export `package.json` for all npm packages.
|
||||||
|
|
||||||
## 0.7.5
|
## 0.7.5
|
||||||
|
|
||||||
### Patch Changes
|
### Patch Changes
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@nhost/core",
|
"name": "@nhost/core",
|
||||||
"version": "0.7.5",
|
"version": "0.7.6",
|
||||||
"description": "Nhost core client library",
|
"description": "Nhost core client library",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
@@ -30,6 +30,7 @@
|
|||||||
"README.md"
|
"README.md"
|
||||||
],
|
],
|
||||||
"exports": {
|
"exports": {
|
||||||
|
"./package.json": "./package.json",
|
||||||
".": {
|
".": {
|
||||||
"import": {
|
"import": {
|
||||||
"node": "./dist/index.cjs.js",
|
"node": "./dist/index.cjs.js",
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ export type ChangePasswordEvents =
|
|||||||
| {
|
| {
|
||||||
type: 'REQUEST'
|
type: 'REQUEST'
|
||||||
password?: string
|
password?: string
|
||||||
|
ticket?: string
|
||||||
}
|
}
|
||||||
| { type: 'SUCCESS' }
|
| { type: 'SUCCESS' }
|
||||||
| { type: 'ERROR'; error: ErrorPayload | null }
|
| { type: 'ERROR'; error: ErrorPayload | null }
|
||||||
@@ -75,10 +76,10 @@ export const createChangePasswordMachine = ({ backendUrl, interpreter }: AuthCli
|
|||||||
invalidPassword: (_, { password }) => !isValidPassword(password)
|
invalidPassword: (_, { password }) => !isValidPassword(password)
|
||||||
},
|
},
|
||||||
services: {
|
services: {
|
||||||
requestChange: (_, { password }) =>
|
requestChange: (_, { password, ticket }) =>
|
||||||
api.post<string, { data: { error?: ErrorPayload } }>(
|
api.post<string, { data: { error?: ErrorPayload } }>(
|
||||||
'/user/password',
|
'/user/password',
|
||||||
{ newPassword: password },
|
{ newPassword: password, ticket: ticket },
|
||||||
{
|
{
|
||||||
headers: {
|
headers: {
|
||||||
authorization: `Bearer ${interpreter?.state.context.accessToken.value}`
|
authorization: `Bearer ${interpreter?.state.context.accessToken.value}`
|
||||||
|
|||||||
@@ -10,11 +10,12 @@ export interface ChangePasswordHandlerResult extends ActionErrorState, ActionSuc
|
|||||||
|
|
||||||
export const changePasswordPromise = async (
|
export const changePasswordPromise = async (
|
||||||
interpreter: InterpreterFrom<ChangePasswordMachine>,
|
interpreter: InterpreterFrom<ChangePasswordMachine>,
|
||||||
password: string
|
password: string,
|
||||||
|
ticket?: string
|
||||||
): Promise<ChangePasswordHandlerResult> =>
|
): Promise<ChangePasswordHandlerResult> =>
|
||||||
new Promise<ChangePasswordHandlerResult>((resolve) => {
|
new Promise<ChangePasswordHandlerResult>((resolve) => {
|
||||||
interpreter.send('REQUEST', {
|
interpreter.send('REQUEST', {
|
||||||
password
|
password, ticket
|
||||||
})
|
})
|
||||||
interpreter.onTransition((state) => {
|
interpreter.onTransition((state) => {
|
||||||
if (state.matches({ idle: 'error' })) {
|
if (state.matches({ idle: 'error' })) {
|
||||||
|
|||||||
@@ -1,7 +1,11 @@
|
|||||||
import { USER_ALREADY_SIGNED_IN } from '../errors'
|
import { USER_ALREADY_SIGNED_IN } from '../errors'
|
||||||
import { AuthInterpreter, PasswordlessOptions } from '../types'
|
import { AuthInterpreter, PasswordlessOptions } from '../types'
|
||||||
|
|
||||||
import { ActionErrorState, ActionSuccessState } from './types'
|
import { ActionErrorState, ActionLoadingState, ActionSuccessState } from './types'
|
||||||
|
|
||||||
|
export interface SignInSmsPasswordlessState
|
||||||
|
extends SignInSmsPasswordlessHandlerResult,
|
||||||
|
ActionLoadingState {}
|
||||||
|
|
||||||
export interface SignInSmsPasswordlessHandlerResult extends ActionErrorState, ActionSuccessState {
|
export interface SignInSmsPasswordlessHandlerResult extends ActionErrorState, ActionSuccessState {
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -149,6 +149,8 @@ export type Provider =
|
|||||||
| 'strava'
|
| 'strava'
|
||||||
| 'gitlab'
|
| 'gitlab'
|
||||||
| 'bitbucket'
|
| 'bitbucket'
|
||||||
|
| 'discord'
|
||||||
|
| 'twitch'
|
||||||
|
|
||||||
// TODO share with hasura-auth
|
// TODO share with hasura-auth
|
||||||
export interface JWTHasuraClaims {
|
export interface JWTHasuraClaims {
|
||||||
|
|||||||
@@ -1,5 +1,18 @@
|
|||||||
# @nhost/hasura-auth-js
|
# @nhost/hasura-auth-js
|
||||||
|
|
||||||
|
## 1.4.0
|
||||||
|
|
||||||
|
### Minor Changes
|
||||||
|
|
||||||
|
- 18ac56d0: added option to include ticket in changePassword to allow for changing password without the user being signed in
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- 10beea72: Fix React Native build: Export `package.json` for all npm packages.
|
||||||
|
- Updated dependencies [747aa969]
|
||||||
|
- Updated dependencies [10beea72]
|
||||||
|
- @nhost/core@0.7.6
|
||||||
|
|
||||||
## 1.3.4
|
## 1.3.4
|
||||||
|
|
||||||
### Patch Changes
|
### Patch Changes
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@nhost/hasura-auth-js",
|
"name": "@nhost/hasura-auth-js",
|
||||||
"version": "1.3.4",
|
"version": "1.4.0",
|
||||||
"description": "Hasura-auth client",
|
"description": "Hasura-auth client",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
@@ -29,6 +29,7 @@
|
|||||||
"README.md"
|
"README.md"
|
||||||
],
|
],
|
||||||
"exports": {
|
"exports": {
|
||||||
|
"./package.json": "./package.json",
|
||||||
".": {
|
".": {
|
||||||
"import": {
|
"import": {
|
||||||
"node": "./dist/index.cjs.js",
|
"node": "./dist/index.cjs.js",
|
||||||
|
|||||||
@@ -251,7 +251,7 @@ export class HasuraAuthClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Use `nhost.auth.changePassword` to change the password for the user. The old password is not needed.
|
* Use `nhost.auth.changePassword` to change the password for the signed-in user. The old password is not needed. In case the user is not signed-in, a password reset ticket needs to be provided.
|
||||||
*
|
*
|
||||||
* @example
|
* @example
|
||||||
* ```ts
|
* ```ts
|
||||||
@@ -260,9 +260,9 @@ export class HasuraAuthClient {
|
|||||||
*
|
*
|
||||||
* @docs https://docs.nhost.io/reference/javascript/auth/change-password
|
* @docs https://docs.nhost.io/reference/javascript/auth/change-password
|
||||||
*/
|
*/
|
||||||
async changePassword({ newPassword }: ChangePasswordParams): Promise<ApiChangePasswordResponse> {
|
async changePassword({ newPassword, ticket }: ChangePasswordParams): Promise<ApiChangePasswordResponse> {
|
||||||
const service = interpret(createChangePasswordMachine(this._client)).start()
|
const service = interpret(createChangePasswordMachine(this._client)).start()
|
||||||
const { error } = await changePasswordPromise(service, newPassword)
|
const { error } = await changePasswordPromise(service, newPassword, ticket)
|
||||||
return { error }
|
return { error }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -95,6 +95,7 @@ export interface ResetPasswordParams {
|
|||||||
|
|
||||||
export interface ChangePasswordParams {
|
export interface ChangePasswordParams {
|
||||||
newPassword: string
|
newPassword: string
|
||||||
|
ticket?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface SendVerificationEmailParams {
|
export interface SendVerificationEmailParams {
|
||||||
|
|||||||
@@ -1,5 +1,14 @@
|
|||||||
# @nhost/hasura-storage-js
|
# @nhost/hasura-storage-js
|
||||||
|
|
||||||
|
## 0.5.3
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- 10beea72: Fix React Native build: Export `package.json` for all npm packages.
|
||||||
|
- Updated dependencies [747aa969]
|
||||||
|
- Updated dependencies [10beea72]
|
||||||
|
- @nhost/core@0.7.6
|
||||||
|
|
||||||
## 0.5.2
|
## 0.5.2
|
||||||
|
|
||||||
### Patch Changes
|
### Patch Changes
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@nhost/hasura-storage-js",
|
"name": "@nhost/hasura-storage-js",
|
||||||
"version": "0.5.2",
|
"version": "0.5.3",
|
||||||
"description": "Hasura-storage client",
|
"description": "Hasura-storage client",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
@@ -27,6 +27,7 @@
|
|||||||
"README.md"
|
"README.md"
|
||||||
],
|
],
|
||||||
"exports": {
|
"exports": {
|
||||||
|
"./package.json": "./package.json",
|
||||||
".": {
|
".": {
|
||||||
"import": {
|
"import": {
|
||||||
"node": "./dist/index.cjs.js",
|
"node": "./dist/index.cjs.js",
|
||||||
|
|||||||
@@ -1,5 +1,17 @@
|
|||||||
# @nhost/nextjs
|
# @nhost/nextjs
|
||||||
|
|
||||||
|
## 1.7.0
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- 10beea72: Fix React Native build: Export `package.json` for all npm packages.
|
||||||
|
- Updated dependencies [747aa969]
|
||||||
|
- Updated dependencies [10beea72]
|
||||||
|
- Updated dependencies [84ba29dd]
|
||||||
|
- @nhost/core@0.7.6
|
||||||
|
- @nhost/nhost-js@1.4.7
|
||||||
|
- @nhost/react@0.12.0
|
||||||
|
|
||||||
## 1.6.2
|
## 1.6.2
|
||||||
|
|
||||||
### Patch Changes
|
### Patch Changes
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@nhost/nextjs",
|
"name": "@nhost/nextjs",
|
||||||
"version": "1.6.2",
|
"version": "1.7.0",
|
||||||
"description": "Nhost NextJS library",
|
"description": "Nhost NextJS library",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
@@ -33,6 +33,7 @@
|
|||||||
"README.md"
|
"README.md"
|
||||||
],
|
],
|
||||||
"exports": {
|
"exports": {
|
||||||
|
"./package.json": "./package.json",
|
||||||
".": {
|
".": {
|
||||||
"import": {
|
"import": {
|
||||||
"node": "./dist/index.cjs.js",
|
"node": "./dist/index.cjs.js",
|
||||||
@@ -82,4 +83,4 @@
|
|||||||
"react": "^17.0.2",
|
"react": "^17.0.2",
|
||||||
"react-dom": "^17.0.2"
|
"react-dom": "^17.0.2"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,15 @@
|
|||||||
# @nhost/nhost-js
|
# @nhost/nhost-js
|
||||||
|
|
||||||
|
## 1.4.7
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- 10beea72: Fix React Native build: Export `package.json` for all npm packages.
|
||||||
|
- Updated dependencies [18ac56d0]
|
||||||
|
- Updated dependencies [10beea72]
|
||||||
|
- @nhost/hasura-auth-js@1.4.0
|
||||||
|
- @nhost/hasura-storage-js@0.5.3
|
||||||
|
|
||||||
## 1.4.6
|
## 1.4.6
|
||||||
|
|
||||||
### Patch Changes
|
### Patch Changes
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@nhost/nhost-js",
|
"name": "@nhost/nhost-js",
|
||||||
"version": "1.4.6",
|
"version": "1.4.7",
|
||||||
"description": "Nhost JavaScript SDK",
|
"description": "Nhost JavaScript SDK",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
@@ -30,6 +30,7 @@
|
|||||||
"README.md"
|
"README.md"
|
||||||
],
|
],
|
||||||
"exports": {
|
"exports": {
|
||||||
|
"./package.json": "./package.json",
|
||||||
".": {
|
".": {
|
||||||
"import": {
|
"import": {
|
||||||
"node": "./dist/index.cjs.js",
|
"node": "./dist/index.cjs.js",
|
||||||
|
|||||||
@@ -1,5 +1,15 @@
|
|||||||
# @nhost/react-apollo
|
# @nhost/react-apollo
|
||||||
|
|
||||||
|
## 4.7.0
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- 10beea72: Fix React Native build: Export `package.json` for all npm packages.
|
||||||
|
- Updated dependencies [10beea72]
|
||||||
|
- Updated dependencies [84ba29dd]
|
||||||
|
- @nhost/apollo@0.5.24
|
||||||
|
- @nhost/react@0.12.0
|
||||||
|
|
||||||
## 4.6.3
|
## 4.6.3
|
||||||
|
|
||||||
### Patch Changes
|
### Patch Changes
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@nhost/react-apollo",
|
"name": "@nhost/react-apollo",
|
||||||
"version": "4.6.3",
|
"version": "4.7.0",
|
||||||
"description": "Nhost React Apollo client",
|
"description": "Nhost React Apollo client",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
@@ -32,6 +32,7 @@
|
|||||||
"README.md"
|
"README.md"
|
||||||
],
|
],
|
||||||
"exports": {
|
"exports": {
|
||||||
|
"./package.json": "./package.json",
|
||||||
".": {
|
".": {
|
||||||
"import": {
|
"import": {
|
||||||
"node": "./dist/index.cjs.js",
|
"node": "./dist/index.cjs.js",
|
||||||
@@ -76,4 +77,4 @@
|
|||||||
"react": "^18.1.0",
|
"react": "^18.1.0",
|
||||||
"react-dom": "^18.1.0"
|
"react-dom": "^18.1.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,16 @@
|
|||||||
# @nhost/react-auth
|
# @nhost/react-auth
|
||||||
|
|
||||||
|
## 3.5.0
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- 10beea72: Fix React Native build: Export `package.json` for all npm packages.
|
||||||
|
- Updated dependencies [18ac56d0]
|
||||||
|
- Updated dependencies [10beea72]
|
||||||
|
- Updated dependencies [84ba29dd]
|
||||||
|
- @nhost/hasura-auth-js@1.4.0
|
||||||
|
- @nhost/react@0.12.0
|
||||||
|
|
||||||
## 3.4.2
|
## 3.4.2
|
||||||
|
|
||||||
### Patch Changes
|
### Patch Changes
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@nhost/react-auth",
|
"name": "@nhost/react-auth",
|
||||||
"version": "3.4.2",
|
"version": "3.5.0",
|
||||||
"description": "Nhost React client",
|
"description": "Nhost React client",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
@@ -31,6 +31,7 @@
|
|||||||
"README.md"
|
"README.md"
|
||||||
],
|
],
|
||||||
"exports": {
|
"exports": {
|
||||||
|
"./package.json": "./package.json",
|
||||||
".": {
|
".": {
|
||||||
"import": {
|
"import": {
|
||||||
"node": "./dist/index.cjs.js",
|
"node": "./dist/index.cjs.js",
|
||||||
@@ -71,4 +72,4 @@
|
|||||||
"react": "^17.0.2",
|
"react": "^17.0.2",
|
||||||
"react-dom": "^17.0.2"
|
"react-dom": "^17.0.2"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,38 @@
|
|||||||
# @nhost/react
|
# @nhost/react
|
||||||
|
|
||||||
|
## 0.12.0
|
||||||
|
|
||||||
|
### Minor Changes
|
||||||
|
|
||||||
|
- 84ba29dd: Introduce `useSignInSmsPasswordless`
|
||||||
|
|
||||||
|
```ts
|
||||||
|
const {
|
||||||
|
signInSmsPasswordless,
|
||||||
|
sendOtp,
|
||||||
|
needsOtp,
|
||||||
|
isLoading,
|
||||||
|
isSuccess,
|
||||||
|
isError,
|
||||||
|
error
|
||||||
|
} = useSignInSmsPasswordless()
|
||||||
|
```
|
||||||
|
|
||||||
|
1. The `signInSmsPasswordless` action will send a one-time password to the given phone number.
|
||||||
|
2. The client is then awaiting the OTP. `needsOtp` equals true
|
||||||
|
3. After the code is received by SMS, the client sends the code with `sendOtp`. On success, the client is authenticated, and `isSuccess` equals `true`.
|
||||||
|
|
||||||
|
Any error is monitored through `isError` and `error`. While the `signInSmsPasswordless` and `sendOtp` actions are running, `isLoading` equals `true`
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- 10beea72: Fix React Native build: Export `package.json` for all npm packages.
|
||||||
|
- Updated dependencies [747aa969]
|
||||||
|
- Updated dependencies [10beea72]
|
||||||
|
- @nhost/core@0.7.6
|
||||||
|
- @nhost/hasura-storage-js@0.5.3
|
||||||
|
- @nhost/nhost-js@1.4.7
|
||||||
|
|
||||||
## 0.11.2
|
## 0.11.2
|
||||||
|
|
||||||
### Patch Changes
|
### Patch Changes
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@nhost/react",
|
"name": "@nhost/react",
|
||||||
"version": "0.11.2",
|
"version": "0.12.0",
|
||||||
"description": "Nhost React library",
|
"description": "Nhost React library",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
@@ -31,6 +31,7 @@
|
|||||||
"README.md"
|
"README.md"
|
||||||
],
|
],
|
||||||
"exports": {
|
"exports": {
|
||||||
|
"./package.json": "./package.json",
|
||||||
".": {
|
".": {
|
||||||
"import": {
|
"import": {
|
||||||
"node": "./dist/index.cjs.js",
|
"node": "./dist/index.cjs.js",
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ export * from './useSendVerificationEmail'
|
|||||||
export * from './useSignInAnonymous'
|
export * from './useSignInAnonymous'
|
||||||
export * from './useSignInEmailPassword'
|
export * from './useSignInEmailPassword'
|
||||||
export * from './useSignInEmailPasswordless'
|
export * from './useSignInEmailPasswordless'
|
||||||
|
export * from './useSignInSmsPasswordless'
|
||||||
export * from './useSignOut'
|
export * from './useSignOut'
|
||||||
export * from './useSignUpEmailPassword'
|
export * from './useSignUpEmailPassword'
|
||||||
export * from './useUserAvatarUrl'
|
export * from './useUserAvatarUrl'
|
||||||
|
|||||||
101
packages/react/src/useSignInSmsPasswordless.ts
Normal file
101
packages/react/src/useSignInSmsPasswordless.ts
Normal file
@@ -0,0 +1,101 @@
|
|||||||
|
import { useState } from 'react'
|
||||||
|
|
||||||
|
import {
|
||||||
|
PasswordlessOptions,
|
||||||
|
SignInSmsPasswordlessHandlerResult,
|
||||||
|
SignInSmsPasswordlessOtpHandlerResult,
|
||||||
|
SignInSmsPasswordlessState
|
||||||
|
} from '@nhost/core'
|
||||||
|
import { signInSmsPasswordlessOtpPromise, signInSmsPasswordlessPromise } from '@nhost/core'
|
||||||
|
import { useSelector } from '@xstate/react'
|
||||||
|
|
||||||
|
import { useAuthInterpreter } from './useAuthInterpreter'
|
||||||
|
|
||||||
|
export interface SignInSmsPasswordlessHandler {
|
||||||
|
(phoneNumber: string, options?: PasswordlessOptions): Promise<SignInSmsPasswordlessHandlerResult>
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface SignInSmsPasswordlessOtpHandler {
|
||||||
|
(code: string): Promise<SignInSmsPasswordlessOtpHandlerResult>
|
||||||
|
(phoneNumber: string, code: string): Promise<SignInSmsPasswordlessOtpHandlerResult>
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface SignInSmsPasswordlessHookResult extends SignInSmsPasswordlessState {
|
||||||
|
/** Sends a one-time code to the given phoneNumber */
|
||||||
|
signInSmsPasswordless: SignInSmsPasswordlessHandler
|
||||||
|
sendOtp: SignInSmsPasswordlessOtpHandler
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Use the hook `useSignInSmsPasswordless` to sign in a user with a one-time password sent via SMS to a phone.
|
||||||
|
*
|
||||||
|
* 1. The `signInSmsPasswordless` action sends a one-time password to the given phone number.
|
||||||
|
* 2. The client is then awaiting the OTP. `needsOtp` equals true.
|
||||||
|
* 3. After the code is received by SMS, the client sends the code with `sendOtp`. On success, the client is authenticated, and `isSuccess` equals `true`.
|
||||||
|
*
|
||||||
|
* Any error is monitored through `isError` and `error`. While the `signInSmsPasswordless` and `sendOtp` actions are running, `isLoading` equals `true`.
|
||||||
|
*
|
||||||
|
* @example
|
||||||
|
* ```tsx
|
||||||
|
* const { signInSmsPasswordless, sendOtp, needsOtp, isLoading, isSuccess, isError, error } = useSignInSmsPasswordless()
|
||||||
|
*
|
||||||
|
* console.log({ isLoading, isSuccess, isError, error });
|
||||||
|
*
|
||||||
|
* const askCode = async (e) => {
|
||||||
|
* e.preventDefault();
|
||||||
|
* await signInSmsPasswordless('+32455555555');
|
||||||
|
* }
|
||||||
|
*
|
||||||
|
* const sendCode = async (e) => {
|
||||||
|
* e.preventDefault();
|
||||||
|
* await sendOtp('123456');
|
||||||
|
* }
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* @docs https://docs.nhost.io/reference/react/use-sign-in-sms-passwordless
|
||||||
|
*/
|
||||||
|
export function useSignInSmsPasswordless(
|
||||||
|
stateOptions?: PasswordlessOptions
|
||||||
|
): SignInSmsPasswordlessHookResult {
|
||||||
|
const service = useAuthInterpreter()
|
||||||
|
const [_phoneNumber, setPhoneNumber] = useState('')
|
||||||
|
|
||||||
|
const signInSmsPasswordless: SignInSmsPasswordlessHandler = (
|
||||||
|
phoneNumber: string,
|
||||||
|
valueOptions = stateOptions
|
||||||
|
) => {
|
||||||
|
setPhoneNumber(phoneNumber)
|
||||||
|
return signInSmsPasswordlessPromise(service, phoneNumber, valueOptions)
|
||||||
|
}
|
||||||
|
|
||||||
|
const sendOtp: SignInSmsPasswordlessOtpHandler = async (...args: string[]) => {
|
||||||
|
if (args.length === 2) {
|
||||||
|
const [phoneNumber, code] = args
|
||||||
|
return signInSmsPasswordlessOtpPromise(service, phoneNumber, code)
|
||||||
|
}
|
||||||
|
const [code] = args
|
||||||
|
return signInSmsPasswordlessOtpPromise(service, _phoneNumber, code)
|
||||||
|
}
|
||||||
|
|
||||||
|
const error = useSelector(
|
||||||
|
service,
|
||||||
|
(state) => state.context.errors.registration || null,
|
||||||
|
(a, b) => a?.error === b?.error
|
||||||
|
)
|
||||||
|
const isLoading = useSelector(
|
||||||
|
service,
|
||||||
|
(state) =>
|
||||||
|
state.matches('registration.passwordlessSms') ||
|
||||||
|
state.matches('registration.passwordlessSmsOtp')
|
||||||
|
)
|
||||||
|
|
||||||
|
const isSuccess = useSelector(service, (state) => state.matches('authentication.signedIn'))
|
||||||
|
|
||||||
|
const needsOtp = useSelector(service, (state) =>
|
||||||
|
state.matches('registration.incomplete.needsOtp')
|
||||||
|
)
|
||||||
|
|
||||||
|
const isError = useSelector(service, (state) => state.matches('registration.incomplete.failed'))
|
||||||
|
|
||||||
|
return { signInSmsPasswordless, sendOtp, isLoading, isSuccess, needsOtp, isError, error }
|
||||||
|
}
|
||||||
@@ -1,5 +1,37 @@
|
|||||||
# @nhost/vue
|
# @nhost/vue
|
||||||
|
|
||||||
|
## 0.4.0
|
||||||
|
|
||||||
|
### Minor Changes
|
||||||
|
|
||||||
|
- 84ba29dd: Introduce `useSignInSmsPasswordless`
|
||||||
|
|
||||||
|
```ts
|
||||||
|
const {
|
||||||
|
signInSmsPasswordless,
|
||||||
|
sendOtp,
|
||||||
|
needsOtp,
|
||||||
|
isLoading,
|
||||||
|
isSuccess,
|
||||||
|
isError,
|
||||||
|
error
|
||||||
|
} = useSignInSmsPasswordless()
|
||||||
|
```
|
||||||
|
|
||||||
|
1. The `signInSmsPasswordless` action will send a one-time password to the given phone number.
|
||||||
|
2. The client is then awaiting the OTP. `needsOtp` equals true
|
||||||
|
3. After the code is received by SMS, the client sends the code with `sendOtp`. On success, the client is authenticated, and `isSuccess` equals `true`.
|
||||||
|
|
||||||
|
Any error is monitored through `isError` and `error`. While the `signInSmsPasswordless` and `sendOtp` actions are running, `isLoading` equals `true`
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- 10beea72: Fix React Native build: Export `package.json` for all npm packages.
|
||||||
|
- Updated dependencies [747aa969]
|
||||||
|
- Updated dependencies [10beea72]
|
||||||
|
- @nhost/core@0.7.6
|
||||||
|
- @nhost/nhost-js@1.4.7
|
||||||
|
|
||||||
## 0.3.7
|
## 0.3.7
|
||||||
|
|
||||||
### Patch Changes
|
### Patch Changes
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@nhost/vue",
|
"name": "@nhost/vue",
|
||||||
"version": "0.3.7",
|
"version": "0.4.0",
|
||||||
"description": "Nhost Vue library",
|
"description": "Nhost Vue library",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
@@ -31,6 +31,7 @@
|
|||||||
"README.md"
|
"README.md"
|
||||||
],
|
],
|
||||||
"exports": {
|
"exports": {
|
||||||
|
"./package.json": "./package.json",
|
||||||
".": {
|
".": {
|
||||||
"import": {
|
"import": {
|
||||||
"node": "./dist/index.cjs.js",
|
"node": "./dist/index.cjs.js",
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ export * from './useSendVerificationEmail'
|
|||||||
export * from './useSignInAnonymous'
|
export * from './useSignInAnonymous'
|
||||||
export * from './useSignInEmailPassword'
|
export * from './useSignInEmailPassword'
|
||||||
export * from './useSignInEmailPasswordless'
|
export * from './useSignInEmailPasswordless'
|
||||||
|
export * from './useSignInSmsPasswordless'
|
||||||
export * from './useSignOut'
|
export * from './useSignOut'
|
||||||
export * from './useSignUpEmailPassword'
|
export * from './useSignUpEmailPassword'
|
||||||
export * from './useUserAvatarUrl'
|
export * from './useUserAvatarUrl'
|
||||||
|
|||||||
115
packages/vue/src/useSignInSmsPasswordless.ts
Normal file
115
packages/vue/src/useSignInSmsPasswordless.ts
Normal file
@@ -0,0 +1,115 @@
|
|||||||
|
import { ref, ToRefs, unref } from 'vue'
|
||||||
|
|
||||||
|
import {
|
||||||
|
PasswordlessOptions,
|
||||||
|
SignInSmsPasswordlessHandlerResult,
|
||||||
|
SignInSmsPasswordlessOtpHandlerResult,
|
||||||
|
signInSmsPasswordlessOtpPromise,
|
||||||
|
signInSmsPasswordlessPromise,
|
||||||
|
SignInSmsPasswordlessState
|
||||||
|
} from '@nhost/core'
|
||||||
|
import { useSelector } from '@xstate/vue'
|
||||||
|
|
||||||
|
import { NestedRefOfValue, nestedUnref, RefOrValue } from './helpers'
|
||||||
|
import { useAuthInterpreter } from './useAuthInterpreter'
|
||||||
|
|
||||||
|
export interface SignInSmsPasswordlessHandler {
|
||||||
|
(
|
||||||
|
phoneNumber: RefOrValue<string>,
|
||||||
|
options?: NestedRefOfValue<PasswordlessOptions | undefined>
|
||||||
|
): Promise<SignInSmsPasswordlessHandlerResult>
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface SignInSmsPasswordlessOtpHandler {
|
||||||
|
(code: RefOrValue<string>): Promise<SignInSmsPasswordlessOtpHandlerResult>
|
||||||
|
(
|
||||||
|
phoneNumber: RefOrValue<string>,
|
||||||
|
code: RefOrValue<string>
|
||||||
|
): Promise<SignInSmsPasswordlessOtpHandlerResult>
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface SignInSmsPasswordlessComposableResult extends ToRefs<SignInSmsPasswordlessState> {
|
||||||
|
/** Sends a one-time code to the given phoneNumber */
|
||||||
|
signInSmsPasswordless: SignInSmsPasswordlessHandler
|
||||||
|
sendOtp: SignInSmsPasswordlessOtpHandler
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Use the composable `useSignInSmsPasswordless` to sign in a user with a one-time password sent via SMS to a phone.
|
||||||
|
*
|
||||||
|
* 1. The `signInSmsPasswordless` action sends a one-time password to the given phone number.
|
||||||
|
* 2. The client is then awaiting the OTP. `needsOtp` equals true.
|
||||||
|
* 3. After the code is received by SMS, the client sends the code with `sendOtp`. On success, the client is authenticated, and `isSuccess` equals `true`.
|
||||||
|
*
|
||||||
|
* Any error is monitored through `isError` and `error`. While the `signInSmsPasswordless` and `sendOtp` actions are running, `isLoading` equals `true`.
|
||||||
|
*
|
||||||
|
* @example
|
||||||
|
* ```tsx
|
||||||
|
* const { signInSmsPasswordless, sendOtp, needsOtp, isLoading, isSuccess, isError, error } = useSignInSmsPasswordless()
|
||||||
|
*
|
||||||
|
* console.log({ isLoading, isSuccess, isError, error });
|
||||||
|
*
|
||||||
|
* const askCode = async (e) => {
|
||||||
|
* e.preventDefault();
|
||||||
|
* await signInSmsPasswordless('+32455555555');
|
||||||
|
* }
|
||||||
|
*
|
||||||
|
* const sendCode = async (e) => {
|
||||||
|
* e.preventDefault();
|
||||||
|
* await sendOtp('123456');
|
||||||
|
* }
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* @docs https://docs.nhost.io/reference/vue/use-sign-in-sms-passwordless
|
||||||
|
*/
|
||||||
|
export function useSignInSmsPasswordless(
|
||||||
|
stateOptions?: NestedRefOfValue<PasswordlessOptions | undefined>
|
||||||
|
): SignInSmsPasswordlessComposableResult {
|
||||||
|
const service = useAuthInterpreter()
|
||||||
|
const _phoneNumber = ref('')
|
||||||
|
|
||||||
|
const signInSmsPasswordless: SignInSmsPasswordlessHandler = (
|
||||||
|
phoneNumber: RefOrValue<string>,
|
||||||
|
valueOptions = stateOptions
|
||||||
|
) => {
|
||||||
|
_phoneNumber.value = unref(phoneNumber)
|
||||||
|
return signInSmsPasswordlessPromise(
|
||||||
|
service.value,
|
||||||
|
unref(phoneNumber),
|
||||||
|
nestedUnref(valueOptions)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
const sendOtp: SignInSmsPasswordlessOtpHandler = async (...args: Array<RefOrValue<string>>) => {
|
||||||
|
if (args.length === 2) {
|
||||||
|
const [phoneNumber, code] = args
|
||||||
|
return signInSmsPasswordlessOtpPromise(service.value, unref(phoneNumber), unref(code))
|
||||||
|
}
|
||||||
|
const [code] = args
|
||||||
|
return signInSmsPasswordlessOtpPromise(service.value, unref(_phoneNumber), unref(code))
|
||||||
|
}
|
||||||
|
|
||||||
|
const error = useSelector(
|
||||||
|
service.value,
|
||||||
|
(state) => state.context.errors.registration || null,
|
||||||
|
(a, b) => a?.error === b?.error
|
||||||
|
)
|
||||||
|
const isLoading = useSelector(
|
||||||
|
service.value,
|
||||||
|
(state) =>
|
||||||
|
state.matches('registration.passwordlessSms') ||
|
||||||
|
state.matches('registration.passwordlessSmsOtp')
|
||||||
|
)
|
||||||
|
|
||||||
|
const isSuccess = useSelector(service.value, (state) => state.matches('authentication.signedIn'))
|
||||||
|
|
||||||
|
const needsOtp = useSelector(service.value, (state) =>
|
||||||
|
state.matches('registration.incomplete.needsOtp')
|
||||||
|
)
|
||||||
|
|
||||||
|
const isError = useSelector(service.value, (state) =>
|
||||||
|
state.matches('registration.incomplete.failed')
|
||||||
|
)
|
||||||
|
|
||||||
|
return { signInSmsPasswordless, sendOtp, isLoading, isSuccess, needsOtp, isError, error }
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user