Compare commits

...

8 Commits

Author SHA1 Message Date
Pilou
dee93bb873 Merge pull request #526 from nhost/changeset-release/main
chore: update versions
2022-05-06 22:29:55 +02:00
github-actions[bot]
173b587802 chore: update versions 2022-05-06 20:24:16 +00:00
Pilou
30ef1660b4 Merge pull request #525 from nhost/fix/cookie-mode
fix: correct cookie storage type
2022-05-06 22:23:12 +02:00
Pierre-Louis Mercereau
a613aa9f0c refactor: unnest if block 2022-05-06 22:12:50 +02:00
Pierre-Louis Mercereau
3c03b9b46f refactor: remove dead code 2022-05-06 22:09:51 +02:00
Pierre-Louis Mercereau
65a3061146 fix: correct cookie storage type 2022-05-06 22:01:38 +02:00
Pilou
55864eac30 Merge pull request #522 from nhost/event-triggers-syntax-error
fixed syntax error in Event Triggers docs
2022-05-06 19:59:46 +02:00
Szilárd Dóró
28494d6c1f fixed syntax error in Event Triggers docs 2022-05-06 19:09:51 +02:00
17 changed files with 88 additions and 53 deletions

View File

@@ -43,7 +43,7 @@ In your serverless function, you need to make sure the request actually comes fr
- Check the header in the serverless function. It should match the environment variable `NHOST_WEBHOOK_SECRET`.
```js
export default function async handler(req, res) {
export default async function handler(req, res) {
// Check webhook secret to make sure the request is valid
if (

View File

@@ -1,5 +1,12 @@
# @nhost/apollo
## 0.5.2
### Patch Changes
- Updated dependencies [65a3061]
- @nhost/core@0.5.2
## 0.5.1
### Patch Changes

View File

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

View File

@@ -1,5 +1,11 @@
# @nhost/core
## 0.5.2
### Patch Changes
- 65a3061: correct cookie storage type
## 0.5.1
### Patch Changes

View File

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

View File

@@ -29,39 +29,13 @@ const defaultClientStorageSetter: StorageSetter = (key, value) => {
}
}
// TODO see https://github.com/nhost/nhost/pull/507#discussion_r865873389
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const checkStorageAccessors = (
clientStorage: ClientStorage,
accessors: Array<keyof ClientStorage>
) => {
accessors.forEach((key) => {
if (typeof clientStorage[key] !== 'function') {
console.error(`clientStorage.${key} is not a function`)
}
})
}
export const localStorageGetter = (
clientStorageType: ClientStorageType,
clientStorage?: ClientStorage
): StorageGetter => {
if (!clientStorage || clientStorageType === 'localStorage' || clientStorageType === 'web') {
if (clientStorageType === 'localStorage' || clientStorageType === 'web') {
return defaultClientStorageGetter
}
if (clientStorageType === 'react-native') {
// checkStorageAccessors(clientStorage, ['getItem'])
return (key) => clientStorage.getItem?.(key)
}
if (clientStorageType === 'capacitor') {
// checkStorageAccessors(clientStorage, ['get'])
return (key) => clientStorage.get?.({ key })
}
if (clientStorageType === 'expo-secure-storage') {
// checkStorageAccessors(clientStorage, ['getItemAsync'])
return (key) => clientStorage.getItemAsync?.(key)
}
if (clientStorageType === 'cookie') {
return (key) => {
if (isBrowser) {
@@ -71,6 +45,20 @@ export const localStorageGetter = (
}
}
}
if (!clientStorage) {
throw Error(
`clientStorageType is set to '${clientStorageType}' but no clienStorage has been given`
)
}
if (clientStorageType === 'react-native') {
return (key) => clientStorage.getItem?.(key)
}
if (clientStorageType === 'capacitor') {
return (key) => clientStorage.get?.({ key })
}
if (clientStorageType === 'expo-secure-storage') {
return (key) => clientStorage.getItemAsync?.(key)
}
if (clientStorageType === 'custom') {
if (clientStorage.getItem && clientStorage.removeItem) {
return clientStorage.getItem
@@ -89,25 +77,9 @@ export const localStorageSetter = (
clientStorageType: ClientStorageType,
clientStorage?: ClientStorage
): StorageSetter => {
if (!clientStorage || clientStorageType === 'localStorage' || clientStorageType === 'web') {
if (clientStorageType === 'localStorage' || clientStorageType === 'web') {
return defaultClientStorageSetter
}
if (clientStorageType === 'react-native') {
// checkStorageAccessors(clientStorage, ['setItem', 'removeItem'])
return (key, value) =>
value ? clientStorage.setItem?.(key, value) : clientStorage.removeItem?.(key)
}
if (clientStorageType === 'capacitor') {
// checkStorageAccessors(clientStorage, ['set', 'remove'])
return (key, value) =>
value ? clientStorage.set?.({ key, value }) : clientStorage.remove?.({ key })
}
if (clientStorageType === 'expo-secure-storage') {
// checkStorageAccessors(clientStorage, ['setItemAsync', 'deleteItemAsync'])
return async (key, value) =>
value ? clientStorage.setItemAsync?.(key, value) : clientStorage.deleteItemAsync?.(key)
}
if (clientStorageType === 'cookie') {
return (key, value) => {
if (isBrowser) {
@@ -119,6 +91,23 @@ export const localStorageSetter = (
}
}
}
if (!clientStorage) {
throw Error(
`clientStorageType is set to '${clientStorageType}' but no clienStorage has been given`
)
}
if (clientStorageType === 'react-native') {
return (key, value) =>
value ? clientStorage.setItem?.(key, value) : clientStorage.removeItem?.(key)
}
if (clientStorageType === 'capacitor') {
return (key, value) =>
value ? clientStorage.set?.({ key, value }) : clientStorage.remove?.({ key })
}
if (clientStorageType === 'expo-secure-storage') {
return async (key, value) =>
value ? clientStorage.setItemAsync?.(key, value) : clientStorage.deleteItemAsync?.(key)
}
if (clientStorageType === 'custom') {
if (!clientStorage.removeItem) {
throw Error(

View File

@@ -1,5 +1,12 @@
# @nhost/hasura-auth-js
## 1.1.4
### Patch Changes
- Updated dependencies [65a3061]
- @nhost/core@0.5.2
## 1.1.3
### Patch Changes

View File

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

View File

@@ -1,5 +1,12 @@
# @nhost/nextjs
## 1.2.2
### Patch Changes
- @nhost/nhost-js@1.1.9
- @nhost/react@0.7.2
## 1.2.1
### Patch Changes

View File

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

View File

@@ -45,7 +45,7 @@ export const getNhostSession = async (
backendUrl: string,
context: GetServerSidePropsContext
): Promise<NhostSession | null> => {
const nhost = await createServerSideClient(backendUrl, context as any)
const nhost = await createServerSideClient(backendUrl, context)
const { accessToken, refreshToken, user } = nhost.auth.client.interpreter!.state.context
return nhost.auth.isAuthenticated()
? {

View File

@@ -1,5 +1,11 @@
# @nhost/nhost-js
## 1.1.9
### Patch Changes
- @nhost/hasura-auth-js@1.1.4
## 1.1.8
### Patch Changes

View File

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

View File

@@ -1,5 +1,12 @@
# @nhost/react-apollo
## 4.2.2
### Patch Changes
- @nhost/apollo@0.5.2
- @nhost/react@0.7.2
## 4.2.1
### Patch Changes

View File

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

View File

@@ -1,5 +1,11 @@
# @nhost/react
## 0.7.2
### Patch Changes
- @nhost/nhost-js@1.1.9
## 0.7.1
### Patch Changes

View File

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