Skip to content

Commit

Permalink
Merge branch 'main' of github.com:redwoodjs/redwood into feat/server-…
Browse files Browse the repository at this point in the history
…auth-provider-p1

* 'main' of github.com:redwoodjs/redwood:
  fix(middleware): Handle POST requests in middleware router too (redwoodjs#10418)
  chore(ci): get ci running on next (redwoodjs#10432)
  RSC: Explain noExternal vite config option (redwoodjs#10429)
  chore(web): Fix .d.ts overwrite build issue (redwoodjs#10431)
  chore(web): .js imports to prep for ESM (redwoodjs#10430)
  chore(refactor): Split rwjs/forms up into several smaller logical units (redwoodjs#10428)
  chore(rsc): simplify `noExternals` config (redwoodjs#10220)
  chore(deps): Update vite to 5.2.8 (redwoodjs#10427)
  chore(auth): Convert `@redwoodjs/auth` to ESM+CJS dual build (redwoodjs#10417)
  chore(framework-tools): Warn about missing metafile (redwoodjs#10426)
  chore(test): Switch rwjs/auth over to vitest (redwoodjs#10423)
  chore(whatwg-fetch): Switch to importing instead of requiring (redwoodjs#10424)
  chore(deps): bump undici from 5.28.3 to 5.28.4 in /.github/actions/check_changesets (redwoodjs#10421)
  chore(route-manifest): Add relativeFilePath to route manifest (redwoodjs#10416)
  • Loading branch information
dac09 committed Apr 9, 2024
2 parents 0698fda + e192cef commit 603ad8c
Show file tree
Hide file tree
Showing 79 changed files with 1,542 additions and 1,185 deletions.
3 changes: 3 additions & 0 deletions .changesets/10418.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
- fix(middleware): Handle POST requests in middleware router too (#10418) by @dac09

Fixes issue with middleware router not accepted POST requests.
6 changes: 3 additions & 3 deletions .github/actions/check_changesets/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -205,11 +205,11 @@ __metadata:
linkType: hard

"undici@npm:^5.25.4":
version: 5.28.3
resolution: "undici@npm:5.28.3"
version: 5.28.4
resolution: "undici@npm:5.28.4"
dependencies:
"@fastify/busboy": "npm:^2.0.0"
checksum: 10c0/3c559ae50ef3104b7085251445dda6f4de871553b9e290845649d2f80b06c0c9cfcdf741b0029c6b20d36c82e6a74dc815b139fa9a26757d70728074ca6d6f5c
checksum: 10c0/08d0f2596553aa0a54ca6e8e9c7f45aef7d042c60918564e3a142d449eda165a80196f6ef19ea2ef2e6446959e293095d8e40af1236f0d67223b06afac5ecad7
languageName: node
linkType: hard

Expand Down
2 changes: 1 addition & 1 deletion .github/actions/detect-changes/detectChanges.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ async function main() {

// If there's no branch, we're not in a pull request.
if (!branch) {
core.setOutput('code', false)
core.setOutput('code', true)
core.setOutput('rsc', false)
core.setOutput('ssr', false)
return
Expand Down
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
"memfs",
"opentelemetry",
"pino",
"Pistorius",
"redwoodjs",
"RWJS",
"tailwindcss",
Expand Down
1 change: 1 addition & 0 deletions packages/auth-providers/supabase/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
},
"dependencies": {
"@babel/runtime-corejs3": "7.24.1",
"@redwoodjs/auth": "workspace:*",
"core-js": "3.36.1"
},
"devDependencies": {
Expand Down
1 change: 0 additions & 1 deletion packages/auth/.babelrc.js

This file was deleted.

36 changes: 36 additions & 0 deletions packages/auth/build.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { renameSync, writeFileSync } from 'node:fs'

import { build, defaultBuildOptions } from '@redwoodjs/framework-tools'

// ESM build
await build({
buildOptions: {
...defaultBuildOptions,
tsconfig: 'tsconfig.build-esm.json',
format: 'esm',
outdir: 'dist/esm',
packages: 'external',
},
})

// CJS build
await build({
buildOptions: {
...defaultBuildOptions,
tsconfig: 'tsconfig.build.json',
packages: 'external',
},
})

// Because the package.json files has `type: module` the CJS entry file can't
// be named `index.js` because in that case it would be treated as an ESM file.
// By changing it to .cjs it will be treated as a CommonJS file.
renameSync('dist/index.js', 'dist/index.cjs')

// Place a package.json file with `type: commonjs` in the dist folder so that
// all .js files are treated as CommonJS files.
writeFileSync('dist/package.json', JSON.stringify({ type: 'commonjs' }))

// Place a package.json file with `type: module` in the dist/esm folder so that
// all .js files are treated as ES Module files.
writeFileSync('dist/esm/package.json', JSON.stringify({ type: 'module' }))
5 changes: 0 additions & 5 deletions packages/auth/jest.config.js

This file was deleted.

1 change: 1 addition & 0 deletions packages/auth/modules.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
declare module 'whatwg-fetch'
26 changes: 14 additions & 12 deletions packages/auth/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,35 +7,37 @@
"directory": "packages/auth"
},
"license": "MIT",
"main": "./dist/index.js",
"type": "module",
"exports": {
"types": "./dist/esm/index.d.ts",
"import": "./dist/esm/index.js",
"default": "./dist/index.cjs"
},
"types": "./dist/index.d.ts",
"files": [
"dist"
],
"scripts": {
"build": "yarn build:js && yarn build:types",
"build:js": "babel src -d dist --extensions \".js,.jsx,.ts,.tsx\"",
"build": "tsx ./build.ts && yarn build:types",
"build:pack": "yarn pack -o redwoodjs-auth.tgz",
"build:types": "tsc --build --verbose",
"build:types": "tsc --build --verbose tsconfig.build.json && tsc --build --verbose tsconfig.build-esm.json",
"build:watch": "nodemon --watch src --ext \"js,jsx,ts,tsx\" --ignore dist --exec \"yarn build\"",
"prepublishOnly": "NODE_ENV=production yarn build",
"test": "jest src",
"test:watch": "yarn test --watch"
"test": "vitest run",
"test:watch": "vitest watch"
},
"dependencies": {
"@babel/runtime-corejs3": "7.24.1",
"core-js": "3.36.1",
"react": "18.3.0-canary-a870b2d54-20240314"
},
"devDependencies": {
"@babel/cli": "7.24.1",
"@babel/core": "^7.22.20",
"@redwoodjs/framework-tools": "workspace:*",
"@testing-library/jest-dom": "6.4.2",
"@testing-library/react": "14.2.2",
"jest": "29.7.0",
"jest-environment-jsdom": "29.7.0",
"msw": "1.3.3",
"typescript": "5.4.3"
"tsx": "4.7.1",
"typescript": "5.4.3",
"vitest": "1.4.0"
},
"gitHead": "3905ed045508b861b495f8d5630d76c7a157d8f1"
}
32 changes: 16 additions & 16 deletions packages/auth/src/AuthProvider/AuthProvider.tsx
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
import type { ReactNode } from 'react'
import React, { useContext, useEffect, useState } from 'react'

import type { AuthContextInterface, CurrentUser } from '../AuthContext'
import type { AuthImplementation } from '../AuthImplementation'

import type { AuthProviderState } from './AuthProviderState'
import { defaultAuthProviderState } from './AuthProviderState'
import { ServerAuthContext } from './ServerAuthProvider'
import { useCurrentUser } from './useCurrentUser'
import { useForgotPassword } from './useForgotPassword'
import { useHasRole } from './useHasRole'
import { useLogIn } from './useLogIn'
import { useLogOut } from './useLogOut'
import { useReauthenticate } from './useReauthenticate'
import { useResetPassword } from './useResetPassword'
import { useSignUp } from './useSignUp'
import { useToken } from './useToken'
import { useValidateResetToken } from './useValidateResetToken'
import type { AuthContextInterface, CurrentUser } from '../AuthContext.js'
import type { AuthImplementation } from '../AuthImplementation.js'

import type { AuthProviderState } from './AuthProviderState.js'
import { defaultAuthProviderState } from './AuthProviderState.js'
import { ServerAuthContext } from './ServerAuthProvider.js'
import { useCurrentUser } from './useCurrentUser.js'
import { useForgotPassword } from './useForgotPassword.js'
import { useHasRole } from './useHasRole.js'
import { useLogIn } from './useLogIn.js'
import { useLogOut } from './useLogOut.js'
import { useReauthenticate } from './useReauthenticate.js'
import { useResetPassword } from './useResetPassword.js'
import { useSignUp } from './useSignUp.js'
import { useToken } from './useToken.js'
import { useValidateResetToken } from './useValidateResetToken.js'

export interface AuthProviderProps {
children: ReactNode
Expand Down
2 changes: 1 addition & 1 deletion packages/auth/src/AuthProvider/AuthProviderState.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { CurrentUser } from '../AuthContext'
import type { CurrentUser } from '../AuthContext.js'

export type AuthProviderState<TUser, TClient = unknown> = {
loading: boolean
Expand Down
4 changes: 2 additions & 2 deletions packages/auth/src/AuthProvider/ServerAuthProvider.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import type { ReactNode } from 'react'
import React from 'react'

import type { AuthProviderState } from './AuthProviderState'
import { defaultAuthProviderState } from './AuthProviderState'
import type { AuthProviderState } from './AuthProviderState.js'
import { defaultAuthProviderState } from './AuthProviderState.js'

export type ServerAuthState = AuthProviderState<never> & {
cookieHeader?: string
Expand Down
4 changes: 2 additions & 2 deletions packages/auth/src/AuthProvider/useCurrentUser.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { useCallback } from 'react'

import type { AuthImplementation } from '../AuthImplementation'
import type { AuthImplementation } from '../AuthImplementation.js'

import { useToken } from './useToken'
import { useToken } from './useToken.js'

export const useCurrentUser = (authImplementation: AuthImplementation) => {
const getToken = useToken(authImplementation)
Expand Down
2 changes: 1 addition & 1 deletion packages/auth/src/AuthProvider/useForgotPassword.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useCallback } from 'react'

import type { AuthImplementation } from '../AuthImplementation'
import type { AuthImplementation } from '../AuthImplementation.js'

export const useForgotPassword = <
TUser,
Expand Down
2 changes: 1 addition & 1 deletion packages/auth/src/AuthProvider/useHasRole.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useCallback } from 'react'

import type { CurrentUser } from '../AuthContext'
import type { CurrentUser } from '../AuthContext.js'

export const useHasRole = (currentUser: CurrentUser | null) => {
/**
Expand Down
10 changes: 5 additions & 5 deletions packages/auth/src/AuthProvider/useLogIn.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { useCallback } from 'react'

import type { AuthImplementation } from '../AuthImplementation'
import type { AuthImplementation } from '../AuthImplementation.js'

import type { AuthProviderState } from './AuthProviderState'
import { defaultAuthProviderState } from './AuthProviderState'
import type { useCurrentUser } from './useCurrentUser'
import { useReauthenticate } from './useReauthenticate'
import type { AuthProviderState } from './AuthProviderState.js'
import { defaultAuthProviderState } from './AuthProviderState.js'
import type { useCurrentUser } from './useCurrentUser.js'
import { useReauthenticate } from './useReauthenticate.js'

export const useLogIn = <
TUser,
Expand Down
4 changes: 2 additions & 2 deletions packages/auth/src/AuthProvider/useLogOut.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { useCallback } from 'react'

import type { AuthImplementation } from '../AuthImplementation'
import type { AuthImplementation } from '../AuthImplementation.js'

import type { AuthProviderState } from './AuthProviderState'
import type { AuthProviderState } from './AuthProviderState.js'

export const useLogOut = <
TUser,
Expand Down
8 changes: 4 additions & 4 deletions packages/auth/src/AuthProvider/useReauthenticate.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { useCallback } from 'react'

import type { AuthImplementation } from '../AuthImplementation'
import type { AuthImplementation } from '../AuthImplementation.js'

import type { AuthProviderState } from './AuthProviderState'
import type { useCurrentUser } from './useCurrentUser'
import { useToken } from './useToken'
import type { AuthProviderState } from './AuthProviderState.js'
import type { useCurrentUser } from './useCurrentUser.js'
import { useToken } from './useToken.js'

const notAuthenticatedState = {
isAuthenticated: false,
Expand Down
2 changes: 1 addition & 1 deletion packages/auth/src/AuthProvider/useResetPassword.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useCallback } from 'react'

import type { AuthImplementation } from '../AuthImplementation'
import type { AuthImplementation } from '../AuthImplementation.js'

export const useResetPassword = <
TUser,
Expand Down
8 changes: 4 additions & 4 deletions packages/auth/src/AuthProvider/useSignUp.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { useCallback } from 'react'

import type { AuthImplementation } from '../AuthImplementation'
import type { AuthImplementation } from '../AuthImplementation.js'

import type { AuthProviderState } from './AuthProviderState'
import type { useCurrentUser } from './useCurrentUser'
import { useReauthenticate } from './useReauthenticate'
import type { AuthProviderState } from './AuthProviderState.js'
import type { useCurrentUser } from './useCurrentUser.js'
import { useReauthenticate } from './useReauthenticate.js'

export const useSignUp = <
TUser,
Expand Down
2 changes: 1 addition & 1 deletion packages/auth/src/AuthProvider/useToken.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useCallback } from 'react'

import type { AuthImplementation } from '../AuthImplementation'
import type { AuthImplementation } from '../AuthImplementation.js'

export const useToken = (authImplementation: AuthImplementation) => {
return useCallback(async () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/auth/src/AuthProvider/useValidateResetToken.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useCallback } from 'react'

import type { AuthImplementation } from '../AuthImplementation'
import type { AuthImplementation } from '../AuthImplementation.js'

export const useValidateResetToken = <
TUser,
Expand Down
Loading

0 comments on commit 603ad8c

Please sign in to comment.