Skip to content

Commit

Permalink
Merge branch 'main' into ds-fix-page-generator-router-regex
Browse files Browse the repository at this point in the history
  • Loading branch information
Tobbe authored Feb 13, 2023
2 parents 8c71a8a + 9e95de1 commit 9c6f75b
Show file tree
Hide file tree
Showing 37 changed files with 384 additions and 352 deletions.
36 changes: 14 additions & 22 deletions docs/docs/cors.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,14 +136,17 @@ In order to be able accept cookies from another domain we'll need to make a chan

### GraphQL XHR Credentials

Next we need to tell the GraphQL client to include credentials (the dbAuth cookie) in any requests. This config goes in `web/src/App.js`:
Next we need to tell the GraphQL client to include credentials (the dbAuth cookie) in any requests. This config goes in `web/src/App.{ts,js}`:

```jsx {7-12}
import { AuthProvider, useAuth } from 'src/auth'

```jsx {5-9}
const App = () => (
<FatalErrorBoundary page={FatalErrorPage}>
<RedwoodProvider titleTemplate="%PageTitle | %AppTitle">
<AuthProvider type="dbAuth">
<RedwoodApolloProvider
useAuth={useAuth}
graphQLClientConfig={{
httpLinkConfig: { credentials: 'include' },
}}
Expand All @@ -158,27 +161,16 @@ const App = () => (

### Auth XHR Credentials

Finally, we need to tell dbAuth to include credentials in its own XHR requests:
Finally, we need to tell dbAuth to include credentials in its own XHR requests. We'll do this within `web/src/auth.{ts,js}` when creating the `AuthProvider`:

```jsx {4-7}
const App = () => (
<FatalErrorBoundary page={FatalErrorPage}>
<RedwoodProvider titleTemplate="%PageTitle | %AppTitle">
<AuthProvider
type="dbAuth"
config={{ fetchConfig: { credentials: 'include' } }}
>
<RedwoodApolloProvider
graphQLClientConfig={{
httpLinkConfig: { credentials: 'include' },
}}
>
<Routes />
</RedwoodApolloProvider>
</AuthProvider>
</RedwoodProvider>
</FatalErrorBoundary>
)
```jsx {3-5}
import { createDbAuthClient, createAuth } from '@redwoodjs/auth-dbauth-web'

const dbAuthClient = createDbAuthClient({
fetchConfig: { credentials: 'include' },
})

export const { AuthProvider, useAuth } = createAuth(dbAuthClient)
```

## Testing CORS Locally
Expand Down
2 changes: 1 addition & 1 deletion docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"clsx": "1.2.1",
"react": "17.0.2",
"react-dom": "17.0.2",
"react-player": "2.11.0"
"react-player": "2.11.2"
},
"devDependencies": {
"@docusaurus/module-type-aliases": "2.3.1",
Expand Down
10 changes: 5 additions & 5 deletions docs/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4658,7 +4658,7 @@ __metadata:
clsx: 1.2.1
react: 17.0.2
react-dom: 17.0.2
react-player: 2.11.0
react-player: 2.11.2
typescript: 4.9.5
languageName: unknown
linkType: soft
Expand Down Expand Up @@ -8550,9 +8550,9 @@ __metadata:
languageName: node
linkType: hard

"react-player@npm:2.11.0":
version: 2.11.0
resolution: "react-player@npm:2.11.0"
"react-player@npm:2.11.2":
version: 2.11.2
resolution: "react-player@npm:2.11.2"
dependencies:
deepmerge: ^4.0.0
load-script: ^1.0.0
Expand All @@ -8561,7 +8561,7 @@ __metadata:
react-fast-compare: ^3.0.1
peerDependencies:
react: ">=16.6.0"
checksum: 9e6dda0ecfe323d0620c55cd9f550ba15325c5817e1297f24422f8052903b646359539236a770675c662915504628a1fc2f89a4b25b7ef2af103a4f3a5c63eb8
checksum: 5138f4865677ddaeb74f4ef9f469e54b77163dece1918414a2b75feed2e41a3e8d5432593d0fdfc1a8078d1cd951003e57fd37731a6988df673bd957a298942f
languageName: node
linkType: hard

Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
"@npmcli/arborist": "6.2.2",
"@nrwl/nx-cloud": "15.0.3",
"@playwright/test": "1.30.0",
"@replayio/playwright": "0.3.19",
"@replayio/playwright": "0.3.20",
"@testing-library/jest-dom": "5.16.5",
"@testing-library/react": "13.4.0",
"@testing-library/user-event": "14.4.3",
Expand All @@ -73,7 +73,7 @@
"core-js": "3.27.2",
"cypress": "12.5.1",
"cypress-wait-until": "1.7.2",
"eslint": "8.33.0",
"eslint": "8.34.0",
"fast-glob": "3.2.12",
"fs-extra": "11.1.0",
"is-port-reachable": "3.1.0",
Expand Down
4 changes: 2 additions & 2 deletions packages/api-server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@
"@babel/plugin-transform-runtime": "7.19.6",
"@babel/runtime-corejs3": "7.20.13",
"@fastify/http-proxy": "8.4.0",
"@fastify/static": "6.8.0",
"@fastify/static": "6.9.0",
"@fastify/url-data": "5.2.0",
"ansi-colors": "4.1.3",
"chalk": "4.1.2",
"chokidar": "3.5.3",
"core-js": "3.27.2",
"fast-json-parse": "1.0.3",
"fastify": "4.12.0",
"fastify": "4.13.0",
"fastify-raw-body": "4.2.0",
"lodash.escape": "4.0.1",
"pretty-bytes": "5.6.0",
Expand Down
6 changes: 3 additions & 3 deletions packages/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@
},
"dependencies": {
"@babel/runtime-corejs3": "7.20.13",
"@prisma/client": "4.10.0",
"@whatwg-node/fetch": "0.7.0",
"@prisma/client": "4.10.1",
"@whatwg-node/fetch": "0.8.1",
"core-js": "3.27.2",
"humanize-string": "2.1.0",
"jsonwebtoken": "9.0.0",
"pascalcase": "1.0.0",
"pino": "8.9.0",
"pino": "8.10.0",
"title-case": "3.0.3"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/auth-providers/auth0/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"@auth0/auth0-spa-js": "1.22.6",
"@babel/cli": "7.20.7",
"@babel/core": "7.20.12",
"@types/react": "18.0.27",
"@types/react": "18.0.28",
"jest": "29.4.2",
"react": "18.2.0",
"typescript": "4.9.5"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"@babel/cli": "7.20.7",
"@babel/core": "7.20.12",
"@types/netlify-identity-widget": "1.9.3",
"@types/react": "18.0.27",
"@types/react": "18.0.28",
"jest": "29.4.2",
"react": "18.2.0",
"typescript": "4.9.5"
Expand Down
2 changes: 1 addition & 1 deletion packages/auth-providers/clerk/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
},
"dependencies": {
"@babel/runtime-corejs3": "7.20.13",
"@clerk/clerk-sdk-node": "4.7.1",
"@clerk/clerk-sdk-node": "4.7.2",
"core-js": "3.27.2"
},
"devDependencies": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { useEffect } from 'react'

import { ClerkLoaded, ClerkProvider, useUser } from '@clerk/clerk-react'
import { ClerkProvider, useUser } from '@clerk/clerk-react'

import { createAuth } from '@redwoodjs/auth-clerk-web'
import { navigate } from '@redwoodjs/router'
Expand Down Expand Up @@ -40,7 +40,7 @@ export const AuthProvider = ({ children }: Props) => {
return (
<ClerkProvider {...clerkOptions} navigate={(to) => navigate(to)}>
<ClerkRwAuthProvider>
<ClerkLoaded>{children}</ClerkLoaded>
{children}
<ClerkStatusUpdater />
</ClerkRwAuthProvider>
</ClerkProvider>
Expand Down
8 changes: 4 additions & 4 deletions packages/auth-providers/clerk/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,15 @@
"devDependencies": {
"@babel/cli": "7.20.7",
"@babel/core": "7.20.12",
"@clerk/clerk-react": "4.11.1",
"@clerk/types": "3.26.1",
"@types/react": "18.0.27",
"@clerk/clerk-react": "4.11.2",
"@clerk/types": "3.27.0",
"@types/react": "18.0.28",
"jest": "29.4.2",
"react": "18.2.0",
"typescript": "4.9.5"
},
"peerDependencies": {
"@clerk/clerk-react": "4.11.1"
"@clerk/clerk-react": "4.11.2"
},
"gitHead": "3905ed045508b861b495f8d5630d76c7a157d8f1"
}
3 changes: 3 additions & 0 deletions packages/auth-providers/clerk/web/src/clerk.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,5 +64,8 @@ function createAuthImplementation() {
const clerk = (window as any).Clerk as Clerk
return clerk?.user
},
clientHasLoaded: () => {
return (window as any).Clerk !== undefined
},
}
}
2 changes: 1 addition & 1 deletion packages/auth-providers/dbAuth/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"@babel/cli": "7.20.7",
"@babel/core": "7.20.12",
"@simplewebauthn/typescript-types": "6.2.1",
"@types/react": "18.0.27",
"@types/react": "18.0.28",
"jest": "29.4.2",
"react": "18.2.0",
"typescript": "4.9.5"
Expand Down
2 changes: 1 addition & 1 deletion packages/auth-providers/firebase/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"devDependencies": {
"@babel/cli": "7.20.7",
"@babel/core": "7.20.12",
"@types/react": "18.0.27",
"@types/react": "18.0.28",
"firebase": "9.17.1",
"jest": "29.4.2",
"react": "18.2.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/auth-providers/netlify/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"@babel/cli": "7.20.7",
"@babel/core": "7.20.12",
"@types/netlify-identity-widget": "1.9.3",
"@types/react": "18.0.27",
"@types/react": "18.0.28",
"jest": "29.4.2",
"react": "18.2.0",
"typescript": "4.9.5"
Expand Down
2 changes: 1 addition & 1 deletion packages/auth-providers/supabase/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"@babel/cli": "7.20.7",
"@babel/core": "7.20.12",
"@supabase/supabase-js": "1.35.7",
"@types/react": "18.0.27",
"@types/react": "18.0.28",
"jest": "29.4.2",
"react": "18.2.0",
"typescript": "4.9.5"
Expand Down
2 changes: 1 addition & 1 deletion packages/auth-providers/supertokens/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"devDependencies": {
"@babel/cli": "7.20.7",
"@babel/core": "7.20.12",
"@types/react": "18.0.27",
"@types/react": "18.0.28",
"jest": "29.4.2",
"react": "18.2.0",
"supertokens-auth-react": "0.31.0",
Expand Down
1 change: 1 addition & 0 deletions packages/auth/src/AuthImplementation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export interface AuthImplementation<
forgotPassword?(username: string): Promise<TForgotPassword>
resetPassword?(options?: unknown): Promise<TResetPassword>
validateResetToken?(token: string | null): Promise<TValidateResetToken>
clientHasLoaded?(): boolean

/**
* The user's data from the AuthProvider
Expand Down
9 changes: 8 additions & 1 deletion packages/auth/src/AuthProvider/useReauthenticate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const notAuthenticatedState = {
userMetadata: null,
loading: false,
hasError: false,
}
} as const

export const useReauthenticate = <TUser>(
authImplementation: AuthImplementation<TUser>,
Expand All @@ -29,8 +29,15 @@ export const useReauthenticate = <TUser>(
const userMetadata = await authImplementation.getUserMetadata()

if (!userMetadata) {
let loading = false

if (authImplementation.clientHasLoaded) {
loading = !authImplementation.clientHasLoaded()
}

setAuthProviderState({
...notAuthenticatedState,
loading,
client: authImplementation.client,
})
} else {
Expand Down
4 changes: 2 additions & 2 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
},
"dependencies": {
"@babel/runtime-corejs3": "7.20.13",
"@prisma/internals": "4.10.0",
"@prisma/internals": "4.10.1",
"@redwoodjs/api-server": "4.0.0",
"@redwoodjs/cli-helpers": "4.0.0",
"@redwoodjs/internal": "4.0.0",
Expand Down Expand Up @@ -60,7 +60,7 @@
"pluralize": "8.0.0",
"portfinder": "1.0.32",
"prettier": "2.8.4",
"prisma": "4.10.0",
"prisma": "4.10.1",
"prompts": "2.4.2",
"rimraf": "3.0.2",
"secure-random-password": "0.2.3",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,8 @@ export const flightcontrolConfig = {
id: 'redwood-web',
name: 'Redwood Web',
type: 'static',
buildType: 'nixpacks',
singlePageApp: true,
installCommand:
'yarn set version stable && NODE_ENV=development yarn install',
buildCommand: 'yarn rw deploy flightcontrol web',
outputDirectory: 'web/dist',
envVariables: {
Expand Down
2 changes: 1 addition & 1 deletion packages/codemods/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"@babel/runtime-corejs3": "7.20.13",
"@iarna/toml": "2.2.5",
"@vscode/ripgrep": "1.14.2",
"@whatwg-node/fetch": "0.7.0",
"@whatwg-node/fetch": "0.8.1",
"core-js": "3.27.2",
"deepmerge": "4.3.0",
"execa": "5.1.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
"css-loader": "6.7.3",
"css-minimizer-webpack-plugin": "4.2.2",
"dotenv-webpack": "8.0.1",
"esbuild": "0.17.6",
"esbuild": "0.17.8",
"fast-glob": "3.2.12",
"file-loader": "6.2.0",
"graphql": "16.6.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/eslint-config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"@redwoodjs/internal": "4.0.0",
"@typescript-eslint/eslint-plugin": "5.51.0",
"@typescript-eslint/parser": "5.51.0",
"eslint": "8.33.0",
"eslint": "8.34.0",
"eslint-config-prettier": "8.6.0",
"eslint-import-resolver-babel-module": "5.3.2",
"eslint-plugin-babel": "5.3.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/forms/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"@testing-library/react": "13.4.0",
"@testing-library/user-event": "14.4.3",
"@types/pascalcase": "1.0.1",
"@types/react": "18.0.27",
"@types/react": "18.0.28",
"@types/react-dom": "18.0.10",
"@types/testing-library__jest-dom": "5.14.5",
"graphql": "16.6.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/graphql-server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
"@types/lodash.merge": "4.6.7",
"@types/lodash.omitby": "4.6.7",
"@types/uuid": "9.0.0",
"@whatwg-node/fetch": "0.7.0",
"@whatwg-node/fetch": "0.8.1",
"aws-lambda": "1.0.7",
"jest": "29.4.2",
"jsonwebtoken": "9.0.0",
Expand Down
4 changes: 2 additions & 2 deletions packages/internal/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
"chalk": "4.1.2",
"core-js": "3.27.2",
"deepmerge": "4.3.0",
"esbuild": "0.17.6",
"esbuild": "0.17.8",
"fast-glob": "3.2.12",
"findup-sync": "5.0.0",
"fs-extra": "11.1.0",
Expand All @@ -57,7 +57,7 @@
"prettier": "2.8.4",
"rimraf": "3.0.2",
"string-env-interpolation": "1.0.1",
"systeminformation": "5.17.8",
"systeminformation": "5.17.9",
"terminal-link": "2.1.1",
"ts-node": "10.9.1",
"typescript": "4.9.5"
Expand Down
Loading

0 comments on commit 9c6f75b

Please sign in to comment.