Compare commits

..

28 Commits

Author SHA1 Message Date
Pilou
024f026241 Merge pull request #839 from nhost/changeset-release/main
chore: update versions
2022-07-19 10:43:17 +02:00
Pierre-Louis Mercereau
a422a4850d chore: correct peer deps bumps 2022-07-19 09:54:46 +02:00
github-actions[bot]
a7e67979fe chore: update versions 2022-07-19 07:48:08 +00:00
Pilou
1dcbf268db Merge pull request #820 from nhost/feat/sms-hook-and-composable
feat: useSignInSmsPasswordless
2022-07-19 09:47:05 +02:00
Pilou
5c5d489740 Merge pull request #841 from nhost/contributors-readme-action-mLUJqJcCpL
contributors readme action update
2022-07-19 09:46:51 +02:00
github-actions[bot]
a2559e3482 contrib-readme-action has updated readme 2022-07-19 07:46:19 +00:00
Pilou
bbef104a85 Merge pull request #840 from nhost/contributors-readme-action-MWLllvW8wS
contributors readme action update
2022-07-19 09:46:05 +02:00
github-actions[bot]
7843b1aec1 contrib-readme-action has updated readme 2022-07-19 07:41:45 +00:00
Pilou
4711bfa8ec Merge pull request #679 from Svarto/feat/changePassword-with-ticket
included an optional ticket in changePassword function to allow for c…
2022-07-19 09:41:27 +02:00
Pilou
6f3f8a5020 Merge pull request #838 from nhost/fix-providers
added twitch as provider
2022-07-19 09:38:32 +02:00
Pilou
a120bcc8fc Merge pull request #828 from dminkovsky/dminkovsky/fix-react-native-build
Fix React Native build
2022-07-19 09:36:02 +02:00
Johan Eliasson
53e20e87f3 Revert "Create stale-bags-design.md"
This reverts commit 9479aeb596.
2022-07-19 09:18:24 +02:00
Johan Eliasson
9479aeb596 Create stale-bags-design.md 2022-07-19 09:10:25 +02:00
Pilou
c4f11af072 Merge pull request #837 from nhost/contributors-readme-action-ZK2-b_IYkd
contributors readme action update
2022-07-19 09:07:47 +02:00
Johan Eliasson
747aa96914 Create dry-radios-allow.md 2022-07-19 09:07:43 +02:00
Johan Eliasson
5682d92592 added twitch as provider 2022-07-19 09:06:51 +02:00
github-actions[bot]
2cf6556499 contrib-readme-action has updated readme 2022-07-19 07:06:07 +00:00
Johan Eliasson
89553fcaf6 Merge pull request #830 from QuestGiverOrg/main
Add discord to provider types
2022-07-19 09:05:48 +02:00
Johan Eliasson
10beea7246 Create nine-students-design.md 2022-07-19 09:03:06 +02:00
Johan Eliasson
1334ddb693 added package.json export for all npm packages 2022-07-19 09:02:23 +02:00
Gavan Wilhite
302c28b202 Merge pull request #1 from QuestGiverOrg/Adding-discord-to-provider-type
Added discord to provider type
2022-07-15 13:28:45 -07:00
Gavan Wilhite
f3f760b987 Added discord to provider type 2022-07-15 13:24:32 -07:00
Dmitry Minkovsky
34470ff6e0 Fix React Native build fail 2022-07-15 12:11:18 -04:00
Pierre-Louis Mercereau
4e4600d769 refactor: improve readability 2022-07-14 09:13:55 +02:00
Pierre-Louis Mercereau
44d57d4b89 refactor: from comments 2022-07-14 09:04:16 +02:00
Pierre-Louis Mercereau
84ba29dd7f feat: useSignInSmsPasswordless 2022-07-13 20:39:17 +02:00
Svarto
18ac56d097 added changeset for hasura-auth-js 2022-06-06 21:38:53 +02:00
Svarto
366fc2403d included an optional ticket in changePassword function to allow for changeing password of logged out users, matches hasura-auth #186 2022-06-06 21:27:44 +02:00
46 changed files with 818 additions and 32 deletions

View File

@@ -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">

View File

@@ -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

View File

@@ -22,4 +22,6 @@ type Provider =
| 'strava' | 'strava'
| 'gitlab' | 'gitlab'
| 'bitbucket' | 'bitbucket'
| 'discord'
| 'twitch'
``` ```

View File

@@ -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`
---

View File

@@ -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`

View File

@@ -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)
---

View File

@@ -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`

View File

@@ -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`
---

View File

@@ -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`

View File

@@ -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)
---

View File

@@ -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`

View File

@@ -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>`
---

View File

@@ -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)
---

View File

@@ -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`

View File

@@ -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`

View File

@@ -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",

View File

@@ -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

View File

@@ -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",

View File

@@ -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

View File

@@ -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",

View File

@@ -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}`

View File

@@ -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' })) {

View File

@@ -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 {
/** /**

View File

@@ -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 {

View File

@@ -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

View File

@@ -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",

View File

@@ -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 }
} }

View File

@@ -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 {

View File

@@ -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

View File

@@ -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",

View File

@@ -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

View File

@@ -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"
} }
} }

View File

@@ -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

View File

@@ -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",

View File

@@ -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

View File

@@ -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"
} }
} }

View File

@@ -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

View File

@@ -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"
} }
} }

View File

@@ -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

View File

@@ -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",

View File

@@ -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'

View 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 }
}

View File

@@ -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

View File

@@ -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",

View File

@@ -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'

View 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 }
}