Compare commits
60 Commits
fix-javasc
...
siddharth/
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
95617216f7 | ||
|
|
8b01175b47 | ||
|
|
e40872efbb | ||
|
|
f76eab6bf6 | ||
|
|
8c7c7a8055 | ||
|
|
0f1beb55b7 | ||
|
|
82649f3415 | ||
|
|
231c2ff5ab | ||
|
|
47c6b62dcb | ||
|
|
61d03b6724 | ||
|
|
cf393786c0 | ||
|
|
33c1252b62 | ||
|
|
b55cbcfa65 | ||
|
|
875b34fcb8 | ||
|
|
47d10c8595 | ||
|
|
8d29b8afa9 | ||
|
|
f8bf8af28f | ||
|
|
5a88801e75 | ||
|
|
cae963ec7d | ||
|
|
6544d052bd | ||
|
|
857ede3445 | ||
|
|
3d8a8d87ae | ||
|
|
5a52fa76d9 | ||
|
|
9a6525fff7 | ||
|
|
87afb00289 | ||
|
|
8ad4dfd0eb | ||
|
|
9ee73fe3d5 | ||
|
|
5bd03a7dfa | ||
|
|
5ab010f289 | ||
|
|
bd3694a103 | ||
|
|
2dc401436d | ||
|
|
4b23aa4f8b | ||
|
|
8255172940 | ||
|
|
90f1741dac | ||
|
|
df3265b854 | ||
|
|
0ba2f4e77a | ||
|
|
da76acc90a | ||
|
|
c5572bec6e | ||
|
|
727734955a | ||
|
|
831a493ab6 | ||
|
|
b6b9a1c5a4 | ||
|
|
61888d1a30 | ||
|
|
7aef610d85 | ||
|
|
b266254247 | ||
|
|
67e00d9108 | ||
|
|
d25c965bc8 | ||
|
|
1bb3a65566 | ||
|
|
28b0ffeb5f | ||
|
|
c7ac86b857 | ||
|
|
5166e5e037 | ||
|
|
2533caf484 | ||
|
|
85a71ffef9 | ||
|
|
803f533a3d | ||
|
|
63ee9423a9 | ||
|
|
89446b3656 | ||
|
|
5a64f1c39c | ||
|
|
fa30de4599 | ||
|
|
3d004dc415 | ||
|
|
08fbede75e | ||
|
|
eda14fa8aa |
@@ -3896,6 +3896,85 @@
|
||||
"doc",
|
||||
"code"
|
||||
]
|
||||
},
|
||||
{
|
||||
"login": "dbrxnds",
|
||||
"name": "David",
|
||||
"avatar_url": "https://avatars.githubusercontent.com/u/32268383?v=4",
|
||||
"profile": "https://github.com/dbrxnds",
|
||||
"contributions": [
|
||||
"doc",
|
||||
"code",
|
||||
"test"
|
||||
]
|
||||
},
|
||||
{
|
||||
"login": "gjmoed",
|
||||
"name": "G.J. Moed",
|
||||
"avatar_url": "https://avatars.githubusercontent.com/u/4458993?v=4",
|
||||
"profile": "https://github.com/gjmoed",
|
||||
"contributions": [
|
||||
"doc",
|
||||
"code"
|
||||
]
|
||||
},
|
||||
{
|
||||
"login": "GHKEN",
|
||||
"name": "Tetsuya Fukuda",
|
||||
"avatar_url": "https://avatars.githubusercontent.com/u/5304351?v=4",
|
||||
"profile": "https://ghken.com",
|
||||
"contributions": [
|
||||
"doc",
|
||||
"code"
|
||||
]
|
||||
},
|
||||
{
|
||||
"login": "nerixim",
|
||||
"name": "Nikita Kamaev",
|
||||
"avatar_url": "https://avatars.githubusercontent.com/u/26106502?v=4",
|
||||
"profile": "https://github.com/nerixim",
|
||||
"contributions": [
|
||||
"doc"
|
||||
]
|
||||
},
|
||||
{
|
||||
"login": "nikola-wd",
|
||||
"name": "Nikola Ivanov",
|
||||
"avatar_url": "https://avatars.githubusercontent.com/u/11588823?v=4",
|
||||
"profile": "https://webredone.com/",
|
||||
"contributions": [
|
||||
"doc"
|
||||
]
|
||||
},
|
||||
{
|
||||
"login": "jayu",
|
||||
"name": "Jakub Mazurek",
|
||||
"avatar_url": "https://avatars.githubusercontent.com/u/11561585?v=4",
|
||||
"profile": "jayu.dev",
|
||||
"contributions": [
|
||||
"doc",
|
||||
"code"
|
||||
]
|
||||
},
|
||||
{
|
||||
"login": "maciej-ka",
|
||||
"name": "Maciej Kasprzyk",
|
||||
"avatar_url": "https://avatars.githubusercontent.com/u/5403694?v=4",
|
||||
"profile": "https://github.com/maciej-ka",
|
||||
"contributions": [
|
||||
"doc",
|
||||
"code"
|
||||
]
|
||||
},
|
||||
{
|
||||
"login": "justinsmid",
|
||||
"name": "Justin Smid",
|
||||
"avatar_url": "https://avatars.githubusercontent.com/u/34271675?v=4",
|
||||
"profile": "https://github.com/justinsmid",
|
||||
"contributions": [
|
||||
"doc",
|
||||
"code"
|
||||
]
|
||||
}
|
||||
],
|
||||
"contributorsPerLine": 7,
|
||||
|
||||
9
.changeset/big-turtles-tease.md
Normal file
9
.changeset/big-turtles-tease.md
Normal file
@@ -0,0 +1,9 @@
|
||||
---
|
||||
"@blitzjs/auth": patch
|
||||
"@blitzjs/next": patch
|
||||
"@blitzjs/rpc": patch
|
||||
"blitz": patch
|
||||
"@blitzjs/generator": patch
|
||||
---
|
||||
|
||||
(feat) upgrade tslog to v4.8.2
|
||||
6
.changeset/chatty-gifts-whisper.md
Normal file
6
.changeset/chatty-gifts-whisper.md
Normal file
@@ -0,0 +1,6 @@
|
||||
---
|
||||
"@blitzjs/next": minor
|
||||
"@blitzjs/rpc": minor
|
||||
---
|
||||
|
||||
Add ability to format the error on the server before returning it to the client.
|
||||
5
.changeset/chilly-jeans-fix.md
Normal file
5
.changeset/chilly-jeans-fix.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@blitzjs/generator": patch
|
||||
---
|
||||
|
||||
Update examples of generate all in docs to include one column in model.
|
||||
9
.changeset/clever-hornets-talk.md
Normal file
9
.changeset/clever-hornets-talk.md
Normal file
@@ -0,0 +1,9 @@
|
||||
---
|
||||
"blitz": patch
|
||||
"@blitzjs/next": patch
|
||||
"@blitzjs/generator": patch
|
||||
---
|
||||
|
||||
Upgrade tslog to `4.9.0`.
|
||||
|
||||
This due a [tslog issue](https://github.com/fullstack-build/tslog/issues/227) that causes tslog to crash when attempting to log an error whose constructor expects more than one argument.
|
||||
6
.changeset/curvy-drinks-perform.md
Normal file
6
.changeset/curvy-drinks-perform.md
Normal file
@@ -0,0 +1,6 @@
|
||||
---
|
||||
"@blitzjs/auth": patch
|
||||
"blitz": patch
|
||||
---
|
||||
|
||||
blitz-auth: Fix webpack from following next-auth
|
||||
5
.changeset/few-elephants-approve.md
Normal file
5
.changeset/few-elephants-approve.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@blitzjs/rpc": patch
|
||||
---
|
||||
|
||||
Fix return type of `requestMiddlewares` in `RpcServerPlugin`
|
||||
8
.changeset/fifty-drinks-cry.md
Normal file
8
.changeset/fifty-drinks-cry.md
Normal file
@@ -0,0 +1,8 @@
|
||||
---
|
||||
"@blitzjs/auth": patch
|
||||
"blitz": patch
|
||||
---
|
||||
|
||||
blitz-auth: Support for Prisma v5
|
||||
|
||||
Internal: Make `handle` a required paramter while updating the `session` modal.
|
||||
5
.changeset/fresh-camels-return.md
Normal file
5
.changeset/fresh-camels-return.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@blitzjs/auth": patch
|
||||
---
|
||||
|
||||
Updated `useAuthenticatedBlitzContext` to now return `AuthenticatedCtx`
|
||||
5
.changeset/fresh-crews-chew.md
Normal file
5
.changeset/fresh-crews-chew.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@blitzjs/next": minor
|
||||
---
|
||||
|
||||
Fix the DYNAMIC_SERVER_USAGE error for Next.js 13.3.1+
|
||||
26
.changeset/good-oranges-pretend.md
Normal file
26
.changeset/good-oranges-pretend.md
Normal file
@@ -0,0 +1,26 @@
|
||||
---
|
||||
"@blitzjs/rpc": patch
|
||||
---
|
||||
|
||||
Fixes enormous memory consumption of the dev server by changing the default import strategy to "require" instead of "import" which in webpack causes multiple chunks to be created for each import.
|
||||
|
||||
## Blitz Configuration
|
||||
|
||||
To configure this behaviour, you can add the following to your next.config.js:
|
||||
|
||||
```js
|
||||
/**
|
||||
* @type {import('@blitzjs/next').BlitzConfig}
|
||||
**/
|
||||
const config = {
|
||||
blitz: {
|
||||
resolversDynamicImport: true,
|
||||
},
|
||||
}
|
||||
```
|
||||
|
||||
When `resolversDynamicImport` is set to `true`, the import strategy will be "import" instead of "require".
|
||||
|
||||
### On Vercel
|
||||
|
||||
If you are using Vercel, `resolversDynamicImport` will be set to `true` by default, since it is better for the separate chunks to be create for serverless lambdas.
|
||||
5
.changeset/large-hairs-battle.md
Normal file
5
.changeset/large-hairs-battle.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@blitzjs/generator": patch
|
||||
---
|
||||
|
||||
Make Next.js version stick to 13.4.5 when generating a new app
|
||||
5
.changeset/moody-crews-travel.md
Normal file
5
.changeset/moody-crews-travel.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@blitzjs/auth": minor
|
||||
---
|
||||
|
||||
Stop exporting `useAuthenticatedBlitzContext` from `@blitzjs/auth` this must be imported from `app/blitz-server.ts` file in order to work correctly
|
||||
6
.changeset/polite-papayas-joke.md
Normal file
6
.changeset/polite-papayas-joke.md
Normal file
@@ -0,0 +1,6 @@
|
||||
---
|
||||
"@blitzjs/auth": major
|
||||
"blitz": patch
|
||||
---
|
||||
|
||||
Migrate `next-auth` adapter to use `@auth/core`
|
||||
5
.changeset/poor-crabs-drum.md
Normal file
5
.changeset/poor-crabs-drum.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"blitz": patch
|
||||
---
|
||||
|
||||
blitz-rpc: Cleanup Event Listeners - Fix potential memory leak by cleaning up any residual event listeners set by blitz.
|
||||
@@ -55,6 +55,7 @@
|
||||
"afraid-ears-repair",
|
||||
"big-boats-lay",
|
||||
"big-phones-bow",
|
||||
"big-turtles-tease",
|
||||
"blue-flowers-peel",
|
||||
"blue-pigs-tan",
|
||||
"brave-zebras-deny",
|
||||
@@ -70,6 +71,7 @@
|
||||
"calm-papayas-protect",
|
||||
"calm-tomatoes-drive",
|
||||
"chatty-fireants-leave",
|
||||
"chatty-gifts-whisper",
|
||||
"chilled-carrots-own",
|
||||
"chilly-candles-care",
|
||||
"chilly-nails-nail",
|
||||
@@ -84,6 +86,7 @@
|
||||
"curly-rules-speak",
|
||||
"curly-seas-serve",
|
||||
"curvy-days-attend",
|
||||
"curvy-drinks-perform",
|
||||
"cyan-bulldogs-heal",
|
||||
"cyan-cars-greet",
|
||||
"dirty-monkeys-greet",
|
||||
@@ -108,8 +111,10 @@
|
||||
"fast-toys-wash",
|
||||
"fast-trainers-kneel",
|
||||
"few-dogs-fetch",
|
||||
"few-elephants-approve",
|
||||
"few-hounds-worry",
|
||||
"few-shrimps-leave",
|
||||
"fifty-drinks-cry",
|
||||
"flat-bees-approve",
|
||||
"fluffy-coats-flow",
|
||||
"fluffy-mangos-begin",
|
||||
@@ -119,6 +124,7 @@
|
||||
"four-meals-fry",
|
||||
"four-radios-tickle",
|
||||
"four-sheep-judge",
|
||||
"fresh-crews-chew",
|
||||
"funny-cups-pay",
|
||||
"fuzzy-bees-warn",
|
||||
"fuzzy-dots-cross",
|
||||
@@ -131,6 +137,7 @@
|
||||
"gold-horses-punch",
|
||||
"good-apes-drum",
|
||||
"good-insects-wink",
|
||||
"good-oranges-pretend",
|
||||
"gorgeous-birds-warn",
|
||||
"gorgeous-buses-scream",
|
||||
"gorgeous-games-obey",
|
||||
@@ -160,6 +167,7 @@
|
||||
"khaki-ducks-cheer",
|
||||
"khaki-pens-rest",
|
||||
"kind-walls-suffer",
|
||||
"large-hairs-battle",
|
||||
"late-steaks-give",
|
||||
"lazy-maps-sort",
|
||||
"lemon-games-press",
|
||||
@@ -185,6 +193,7 @@
|
||||
"modern-games-dream",
|
||||
"modern-ligers-behave",
|
||||
"moody-bags-walk",
|
||||
"moody-crews-travel",
|
||||
"moody-spoons-rhyme",
|
||||
"moody-squids-cheer",
|
||||
"nasty-suns-wash",
|
||||
@@ -195,6 +204,7 @@
|
||||
"nice-boxes-travel",
|
||||
"nice-deers-dream",
|
||||
"nice-starfishes-live",
|
||||
"nine-bags-rhyme",
|
||||
"nine-birds-confess",
|
||||
"nine-onions-admire",
|
||||
"ninety-lies-press",
|
||||
@@ -216,6 +226,7 @@
|
||||
"plenty-gifts-provide",
|
||||
"plenty-kiwis-greet",
|
||||
"polite-lizards-love",
|
||||
"poor-crabs-drum",
|
||||
"poor-peas-lick",
|
||||
"poor-penguins-look",
|
||||
"poor-shrimps-think",
|
||||
@@ -251,11 +262,13 @@
|
||||
"silly-peas-work",
|
||||
"silly-shoes-agree",
|
||||
"six-apricots-kick",
|
||||
"sixty-rockets-count",
|
||||
"slimy-humans-impress",
|
||||
"slimy-needles-taste",
|
||||
"slow-impalas-tap",
|
||||
"slow-walls-camp",
|
||||
"slow-walls-poke",
|
||||
"small-monkeys-battle",
|
||||
"small-socks-confess",
|
||||
"smooth-planets-admire",
|
||||
"smooth-rice-clap",
|
||||
@@ -285,6 +298,7 @@
|
||||
"tall-radios-clean",
|
||||
"tame-keys-reply",
|
||||
"tame-pumpkins-nail",
|
||||
"tame-rocks-unite",
|
||||
"tasty-maps-fetch",
|
||||
"tasty-news-collect",
|
||||
"tasty-squids-sin",
|
||||
@@ -322,7 +336,9 @@
|
||||
"wicked-rings-walk",
|
||||
"wise-eels-visit",
|
||||
"wise-frogs-give",
|
||||
"wise-lies-relate",
|
||||
"wise-rabbits-complain",
|
||||
"yellow-numbers-serve",
|
||||
"young-birds-talk"
|
||||
]
|
||||
}
|
||||
|
||||
68
.changeset/sixty-rockets-count.md
Normal file
68
.changeset/sixty-rockets-count.md
Normal file
@@ -0,0 +1,68 @@
|
||||
---
|
||||
"@blitzjs/rpc": patch
|
||||
"blitz": patch
|
||||
---
|
||||
|
||||
### Now we can configure Blitz RPC in the following way,
|
||||
|
||||
In your `[[...blitz]].ts` api file you can see the following settings
|
||||
```ts
|
||||
logging?: {
|
||||
/**
|
||||
* allowList Represents the list of routes for which logging should be enabled
|
||||
* If whiteList is defined then only those routes will be logged
|
||||
*/
|
||||
allowList?: string[]
|
||||
/**
|
||||
* blockList Represents the list of routes for which logging should be disabled
|
||||
* If blockList is defined then all routes except those will be logged
|
||||
*/
|
||||
blockList?: string[]
|
||||
/**
|
||||
* verbose Represents the flag to enable/disable logging
|
||||
* If verbose is true then Blitz RPC will log the input and output of each resolver
|
||||
*/
|
||||
verbose?: boolean
|
||||
/**
|
||||
* disablelevel Represents the flag to enable/disable logging for a particular level
|
||||
*/
|
||||
disablelevel?: "debug" | "info"
|
||||
}
|
||||
```
|
||||
```ts
|
||||
import { rpcHandler } from "@blitzjs/rpc"
|
||||
import { api } from "src/blitz-server"
|
||||
|
||||
export default api(
|
||||
rpcHandler({
|
||||
onError: console.log,
|
||||
formatError: (error) => {
|
||||
error.message = `FormatError handler: ${error.message}`
|
||||
return error
|
||||
},
|
||||
logging: {
|
||||
...
|
||||
}
|
||||
})
|
||||
)
|
||||
```
|
||||
|
||||
Example:
|
||||
```ts
|
||||
export default api(
|
||||
rpcHandler({
|
||||
onError: console.log,
|
||||
formatError: (error) => {
|
||||
error.message = `FormatError handler: ${error.message}`
|
||||
return error
|
||||
},
|
||||
logging: {
|
||||
verbose: true,
|
||||
blockList: ["getCurrentUser", ...], //just write the resolver name [which is the resolver file name]
|
||||
},
|
||||
})
|
||||
)
|
||||
```
|
||||
|
||||
This is enable verbose blitz rpc logging for all resolvers except the resolvers `getCurrentUser` and others mentioned in the `blockList`
|
||||
|
||||
6
.changeset/small-monkeys-battle.md
Normal file
6
.changeset/small-monkeys-battle.md
Normal file
@@ -0,0 +1,6 @@
|
||||
---
|
||||
"@blitzjs/auth": patch
|
||||
"blitz": patch
|
||||
---
|
||||
|
||||
Fix Next-Auth integration: `Unable to use next-auth with provider: Error [ERR_PACKAGE_PATH_NOT_EXPORTED]`
|
||||
5
.changeset/tame-rocks-unite.md
Normal file
5
.changeset/tame-rocks-unite.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"blitz": patch
|
||||
---
|
||||
|
||||
Fix log formatting to not show the path of blitz rpc
|
||||
5
.changeset/yellow-numbers-serve.md
Normal file
5
.changeset/yellow-numbers-serve.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@blitzjs/recipe-tailwind": minor
|
||||
---
|
||||
|
||||
support both directory style in tailwind recipe
|
||||
26
.github/workflows/main.yml
vendored
26
.github/workflows/main.yml
vendored
@@ -7,8 +7,8 @@ on:
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
env:
|
||||
|
||||
env:
|
||||
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1
|
||||
|
||||
jobs:
|
||||
@@ -17,9 +17,9 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: pnpm/action-setup@646cdf48217256a3d0b80361c5a50727664284f2
|
||||
- uses: pnpm/action-setup@v2.2.4
|
||||
with:
|
||||
version: 7.11.0
|
||||
version: 8.6.5
|
||||
- name: Setup node
|
||||
uses: actions/setup-node@v2
|
||||
with:
|
||||
@@ -38,9 +38,9 @@ jobs:
|
||||
name: Build
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: pnpm/action-setup@646cdf48217256a3d0b80361c5a50727664284f2
|
||||
- uses: pnpm/action-setup@v2.2.4
|
||||
with:
|
||||
version: 7.11.0
|
||||
version: 8.6.5
|
||||
- name: Setup node
|
||||
uses: actions/setup-node@v2
|
||||
with:
|
||||
@@ -68,9 +68,9 @@ jobs:
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Setup PNPM
|
||||
uses: pnpm/action-setup@646cdf48217256a3d0b80361c5a50727664284f2
|
||||
uses: pnpm/action-setup@v2.2.4
|
||||
with:
|
||||
version: 7.11.0
|
||||
version: 8.6.5
|
||||
|
||||
- name: Setup node@16
|
||||
uses: actions/setup-node@v2
|
||||
@@ -127,14 +127,14 @@ jobs:
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Setup PNPM
|
||||
uses: pnpm/action-setup@646cdf48217256a3d0b80361c5a50727664284f2
|
||||
uses: pnpm/action-setup@v2.2.4
|
||||
with:
|
||||
version: 7.11.0
|
||||
version: 8.6.5
|
||||
|
||||
- name: Setup node@${{ matrix.NODE_VERSION }}
|
||||
- name: Setup node@18
|
||||
uses: actions/setup-node@v2
|
||||
with:
|
||||
node-version: ${{ matrix.NODE_VERSION }}
|
||||
node-version: 18
|
||||
cache: "pnpm"
|
||||
|
||||
- name: Install dependencies
|
||||
@@ -143,7 +143,7 @@ jobs:
|
||||
|
||||
- name: Install playwright
|
||||
run: |
|
||||
pnpx playwright@1.28.0 install --with-deps
|
||||
pnpx playwright@1.28.0 install --with-deps
|
||||
shell: bash
|
||||
|
||||
- name: Build
|
||||
|
||||
@@ -2,5 +2,5 @@
|
||||
. "$(dirname "$0")/_/husky.sh"
|
||||
|
||||
pnpm manypkg check
|
||||
pnpm lint
|
||||
# pnpm lint
|
||||
pnpm pretty-quick --staged
|
||||
|
||||
1
.npmrc
1
.npmrc
@@ -1,4 +1,5 @@
|
||||
save-exact=true
|
||||
dedupe-peer-dependents=true
|
||||
strict-peer-dependencies=false
|
||||
|
||||
public-hoist-pattern[]=secure-password
|
||||
|
||||
17
README.md
17
README.md
@@ -6,7 +6,7 @@
|
||||
<img alt="" src="https://img.shields.io/badge/Join%20our%20community-6700EB.svg?style=for-the-badge&labelColor=000000&logoWidth=20&logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAIAAAACACAYAAADDPmHLAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAQ9SURBVHgB7d3dVdtAEIbhcSpICUoH0IEogQqSVBBSAU4FSSpIOoAORAfQgSghHXzZ1U/YcMD4R9rZmf2ec3y448LyiNf27iLiGIAmPLrweC9Un3DhrzG6EarLNP09nlwJ1SOZ/lQr5N80/S/p2QMVCBf5N17XCfm1Y/rBHqjAG9PPHvBsz+mf9WAP+HLA9M/YA14cOP2payH7jpj+VCtk1wnTP+vj7xCy6cTpn7EHLMLp059iD1iD8eveJbVCNsSLheX1YA/YgOWnf8YeKB3Wmf7Ud6Fy4f/FHmtpxbl3YlC4MJ/Cj0bWdwPnPbARg+L0S54XQHS32WwuxClzd4CM0z9rPfeAuTtA5ulPXYQ7wZ04Y+oOoDD9KZc9YOoOoDj9s4dwFzgXR6w1wIPoOvPWA9buAHEJ173o3gWiy3AnuBUHLEbgmYwvAk1/wuM8vAgexThzbwPDkx7/DHwVXfFOxP2GmsKd4Ab6zPeAyU8CI7AHFmH2BRCBPXAyk18GzUrqAXCTiR4ssyj0VFw/oCU8+e+RZ33AWz6KMaYbIIWxB+JSLs1bsbkeMN0AqakHvoku9oA2sAfqBvbAQdw0QArsgb25aYBUQT3QgT2gB+yBuqGcHij2UCqXDZACe2Anlw2QYg/QAOyBuoE98CL3DZDCuK4/rh/Q7oGL6U+TOvcNkJoijN8X1C48+T+g75eQDrAH/qmqAVJgDwyqaoAUe4AGYA/UDZX3QLUNkEIZPRCd5+6BahsgVUgPROwBTSijB7jpVAvGHriHvmw9wAZ4BpX1ABvgmakHtPcbRuwBTWAPULgAV9D/jKDY9YRvwvgEaurD44uQHvAol7qBW7WKluVtIHiUS7GyvA0s6CiXDnxrpQfsgbqBS7GKk/2jYHCrVlGyfxTMrVo0ALdq1Q3sgSKofh0M9oA61a+D2QM0AHugbmAPqClmSRjK2apVVQ8UsySsoK1aHdgDesCtWnUDeyCrIpeFg1u3sylyWTi3btMA7IG6gT2wuuK3hoE9sKrit4YVslWLPaAN7IG6ocKt2zmY2h4O9sDiTG0PZw/QANy6XTewBxZj9ogYVHy025LMHhEz9cBn0We6B0yfERReBLfhx0/R1YQHPx/QBPbA0VwcEwf2wNFcHBPHHjiem3MC2QPHcXdSaJjA+KfgTPQ8hhfjBzHC40mhlzJ+Xq9lK4a4PCs43AVaGTed5mZq+iOXZwWHi3AnOj2wFWNcnxYe7gTxLtBKHuamP/J+Wnh8a5irB7ZC5Yk9gPX1QuXC+usHWqGyhYvUYR0a7zboUOFCNVhnk0krZAOW7wFOvzXhom2xnEbIHizTA1wEYhWW6YFGyC6c1gOcfg9wfA80Qj7g8B7g9HuCww+haIR8wf49wOn3Cvv9k8tGyC/s7gFOv3fY3QONkH+v9MBWqB7PeqDn9FcIT//kcitUn6kHOu/T/xfWzlQy3dEHhwAAAABJRU5ErkJggg==">
|
||||
</a>
|
||||
<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
|
||||
<a aria-label="All Contributors" href="#contributors-"><img alt="" src="https://img.shields.io/badge/all_contributors-411-17BB8A.svg?style=for-the-badge&labelColor=000000"></a>
|
||||
<a aria-label="All Contributors" href="#contributors-"><img alt="" src="https://img.shields.io/badge/all_contributors-419-17BB8A.svg?style=for-the-badge&labelColor=000000"></a>
|
||||
<!-- ALL-CONTRIBUTORS-BADGE:END -->
|
||||
<a aria-label="License" href="https://github.com/blitz-js/blitz/blob/main/LICENSE">
|
||||
<img alt="" src="https://img.shields.io/npm/l/blitz.svg?style=for-the-badge&labelColor=000000&color=blue">
|
||||
@@ -94,6 +94,11 @@ Your financial contributions help ensure Blitz continues to be developed and mai
|
||||
<td><a aria-label="Boostry" href="https://boostry.co.jp/?utm_source=BlitzJS&utm_medium=sponsorship&utm_campaign=BlitzJS_Sponsorship_2021">
|
||||
<img alt="" src="https://raw.githubusercontent.com/blitz-js/blitz/main/assets/boostry.svg" width="200px">
|
||||
</a></td>
|
||||
<td>
|
||||
<a aria-label="Byteflow" href="https://byteflow.app/?ref=blitzjs">
|
||||
<img alt="" src="https://raw.githubusercontent.com/blitz-js/blitz/main/assets/Byteflow.png" width="70px">
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
@@ -724,6 +729,16 @@ Thanks to these wonderful people ([emoji key](https://allcontributors.org/docs/e
|
||||
<td align="center"><a href="https://maotoramm.com"><img src="https://avatars.githubusercontent.com/u/5174884?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Maotora ᕙ(⇀‸↼‶)ᕗ</b></sub></a><br /><a href="https://github.com/blitz-js/blitz/commits?author=maotora" title="Documentation">📖</a> <a href="https://github.com/blitz-js/blitz/commits?author=maotora" title="Code">💻</a></td>
|
||||
<td align="center"><a href="https://github.com/vitaliemiron"><img src="https://avatars.githubusercontent.com/u/45145592?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Vitalie</b></sub></a><br /><a href="https://github.com/blitz-js/blitz/commits?author=vitaliemiron" title="Documentation">📖</a> <a href="https://github.com/blitz-js/blitz/commits?author=vitaliemiron" title="Code">💻</a></td>
|
||||
<td align="center"><a href="https://estevao.org"><img src="https://avatars.githubusercontent.com/u/19409687?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Nelson Estevão</b></sub></a><br /><a href="https://github.com/blitz-js/blitz/commits?author=nelsonmestevao" title="Documentation">📖</a> <a href="https://github.com/blitz-js/blitz/commits?author=nelsonmestevao" title="Code">💻</a></td>
|
||||
<td align="center"><a href="https://github.com/dbrxnds"><img src="https://avatars.githubusercontent.com/u/32268383?v=4?s=100" width="100px;" alt=""/><br /><sub><b>David</b></sub></a><br /><a href="https://github.com/blitz-js/blitz/commits?author=dbrxnds" title="Documentation">📖</a> <a href="https://github.com/blitz-js/blitz/commits?author=dbrxnds" title="Code">💻</a> <a href="https://github.com/blitz-js/blitz/commits?author=dbrxnds" title="Tests">⚠️</a></td>
|
||||
<td align="center"><a href="https://github.com/gjmoed"><img src="https://avatars.githubusercontent.com/u/4458993?v=4?s=100" width="100px;" alt=""/><br /><sub><b>G.J. Moed</b></sub></a><br /><a href="https://github.com/blitz-js/blitz/commits?author=gjmoed" title="Documentation">📖</a> <a href="https://github.com/blitz-js/blitz/commits?author=gjmoed" title="Code">💻</a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="center"><a href="https://ghken.com"><img src="https://avatars.githubusercontent.com/u/5304351?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Tetsuya Fukuda</b></sub></a><br /><a href="https://github.com/blitz-js/blitz/commits?author=GHKEN" title="Documentation">📖</a> <a href="https://github.com/blitz-js/blitz/commits?author=GHKEN" title="Code">💻</a></td>
|
||||
<td align="center"><a href="https://github.com/nerixim"><img src="https://avatars.githubusercontent.com/u/26106502?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Nikita Kamaev</b></sub></a><br /><a href="https://github.com/blitz-js/blitz/commits?author=nerixim" title="Documentation">📖</a></td>
|
||||
<td align="center"><a href="https://webredone.com/"><img src="https://avatars.githubusercontent.com/u/11588823?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Nikola Ivanov</b></sub></a><br /><a href="https://github.com/blitz-js/blitz/commits?author=nikola-wd" title="Documentation">📖</a></td>
|
||||
<td align="center"><a href="jayu.dev"><img src="https://avatars.githubusercontent.com/u/11561585?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Jakub Mazurek</b></sub></a><br /><a href="https://github.com/blitz-js/blitz/commits?author=jayu" title="Documentation">📖</a> <a href="https://github.com/blitz-js/blitz/commits?author=jayu" title="Code">💻</a></td>
|
||||
<td align="center"><a href="https://github.com/maciej-ka"><img src="https://avatars.githubusercontent.com/u/5403694?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Maciej Kasprzyk</b></sub></a><br /><a href="https://github.com/blitz-js/blitz/commits?author=maciej-ka" title="Documentation">📖</a> <a href="https://github.com/blitz-js/blitz/commits?author=maciej-ka" title="Code">💻</a></td>
|
||||
<td align="center"><a href="https://github.com/justinsmid"><img src="https://avatars.githubusercontent.com/u/34271675?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Justin Smid</b></sub></a><br /><a href="https://github.com/blitz-js/blitz/commits?author=justinsmid" title="Documentation">📖</a> <a href="https://github.com/blitz-js/blitz/commits?author=justinsmid" title="Code">💻</a></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
|
||||
@@ -1,5 +1,68 @@
|
||||
# next-blitz-auth
|
||||
|
||||
## 0.1.1-beta.7
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [90f1741da]
|
||||
- Updated dependencies [df3265b85]
|
||||
- @blitzjs/auth@2.0.0-beta.31
|
||||
- blitz@2.0.0-beta.31
|
||||
- @blitzjs/rpc@2.0.0-beta.31
|
||||
- @blitzjs/next@2.0.0-beta.31
|
||||
- @blitzjs/config@2.0.0-beta.31
|
||||
|
||||
## 0.1.1-beta.6
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [c5572bec6]
|
||||
- Updated dependencies [727734955]
|
||||
- @blitzjs/auth@2.0.0-beta.30
|
||||
- blitz@2.0.0-beta.30
|
||||
- @blitzjs/rpc@2.0.0-beta.30
|
||||
- @blitzjs/next@2.0.0-beta.30
|
||||
- @blitzjs/config@2.0.0-beta.30
|
||||
|
||||
## 0.1.1-beta.5
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [b6b9a1c5a]
|
||||
- Updated dependencies [61888d1a3]
|
||||
- @blitzjs/auth@2.0.0-beta.29
|
||||
- blitz@2.0.0-beta.29
|
||||
- @blitzjs/rpc@2.0.0-beta.29
|
||||
- @blitzjs/next@2.0.0-beta.29
|
||||
- @blitzjs/config@2.0.0-beta.29
|
||||
|
||||
## 0.1.1-beta.4
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [5166e5e03]
|
||||
- Updated dependencies [2533caf48]
|
||||
- Updated dependencies [c7ac86b85]
|
||||
- Updated dependencies [1bb3a6556]
|
||||
- @blitzjs/auth@2.0.0-beta.28
|
||||
- @blitzjs/next@2.0.0-beta.28
|
||||
- @blitzjs/rpc@2.0.0-beta.28
|
||||
- blitz@2.0.0-beta.28
|
||||
- @blitzjs/config@2.0.0-beta.28
|
||||
|
||||
## 0.1.1-beta.3
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [eda14fa8a]
|
||||
- Updated dependencies [3d004dc41]
|
||||
- Updated dependencies [29c2b029a]
|
||||
- @blitzjs/next@2.0.0-beta.27
|
||||
- @blitzjs/rpc@2.0.0-beta.27
|
||||
- @blitzjs/auth@2.0.0-beta.27
|
||||
- blitz@2.0.0-beta.27
|
||||
- @blitzjs/config@2.0.0-beta.27
|
||||
|
||||
## 0.1.1-beta.2
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "next-blitz-auth",
|
||||
"version": "0.1.1-beta.2",
|
||||
"version": "0.1.1-beta.7",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"blitz:dev": "next dev",
|
||||
@@ -9,15 +9,15 @@
|
||||
"lint": "next lint"
|
||||
},
|
||||
"dependencies": {
|
||||
"@blitzjs/auth": "workspace:*",
|
||||
"@blitzjs/config": "workspace:*",
|
||||
"@blitzjs/next": "workspace:*",
|
||||
"@blitzjs/rpc": "workspace:*",
|
||||
"@blitzjs/auth": "2.0.0-beta.31",
|
||||
"@blitzjs/config": "2.0.0-beta.31",
|
||||
"@blitzjs/next": "2.0.0-beta.31",
|
||||
"@blitzjs/rpc": "2.0.0-beta.31",
|
||||
"@hookform/error-message": "2.0.0",
|
||||
"@hookform/resolvers": "2.9.10",
|
||||
"@prisma/client": "^4.5.0",
|
||||
"@tanstack/react-query": "4.0.10",
|
||||
"blitz": "workspace:*",
|
||||
"blitz": "2.0.0-beta.31",
|
||||
"flatted": "3.2.7",
|
||||
"next": "13.3.0",
|
||||
"prisma": "^4.5.0",
|
||||
|
||||
@@ -23,14 +23,14 @@
|
||||
]
|
||||
},
|
||||
"dependencies": {
|
||||
"@blitzjs/auth": "workspace:*",
|
||||
"@blitzjs/config": "workspace:*",
|
||||
"@blitzjs/next": "workspace:*",
|
||||
"@blitzjs/rpc": "workspace:*",
|
||||
"@blitzjs/auth": "2.0.0-beta.31",
|
||||
"@blitzjs/config": "2.0.0-beta.31",
|
||||
"@blitzjs/next": "2.0.0-beta.31",
|
||||
"@blitzjs/rpc": "2.0.0-beta.31",
|
||||
"@hookform/error-message": "2.0.0",
|
||||
"@hookform/resolvers": "2.9.10",
|
||||
"@prisma/client": "4.6.1",
|
||||
"blitz": "workspace:2.0.0-beta.26",
|
||||
"blitz": "2.0.0-beta.31",
|
||||
"next": "13.3.0",
|
||||
"openid-client": "5.2.1",
|
||||
"prisma": "4.6.1",
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
const { withNextAuthAdapter } = require("@blitzjs/auth/next-auth")
|
||||
const { withBlitz } = require("@blitzjs/next")
|
||||
|
||||
/**
|
||||
* @type {import('@blitzjs/next').BlitzConfig}
|
||||
* @type {import('next').NextConfig}
|
||||
**/
|
||||
const config = {
|
||||
reactStrictMode: true,
|
||||
blitz: {
|
||||
resolversDynamicImport: true,
|
||||
},
|
||||
}
|
||||
|
||||
module.exports = withBlitz(withNextAuthAdapter(config))
|
||||
module.exports = withBlitz(config)
|
||||
|
||||
@@ -24,16 +24,16 @@
|
||||
]
|
||||
},
|
||||
"dependencies": {
|
||||
"@blitzjs/auth": "workspace:*",
|
||||
"@blitzjs/config": "workspace:*",
|
||||
"@blitzjs/next": "workspace:*",
|
||||
"@blitzjs/rpc": "workspace:*",
|
||||
"@auth/core": "0.10.0",
|
||||
"@blitzjs/auth": "2.0.0-beta.31",
|
||||
"@blitzjs/config": "2.0.0-beta.31",
|
||||
"@blitzjs/next": "2.0.0-beta.31",
|
||||
"@blitzjs/rpc": "2.0.0-beta.31",
|
||||
"@hookform/error-message": "2.0.0",
|
||||
"@hookform/resolvers": "2.9.10",
|
||||
"@prisma/client": "4.6.1",
|
||||
"blitz": "workspace:2.0.0-beta.26",
|
||||
"blitz": "2.0.0-beta.31",
|
||||
"next": "13.3.0",
|
||||
"next-auth": "4.18.7",
|
||||
"prisma": "4.6.1",
|
||||
"react": "18.2.0",
|
||||
"react-dom": "18.2.0",
|
||||
|
||||
@@ -10,6 +10,7 @@ type SignupFormProps = {
|
||||
|
||||
export const SignupForm = (props: SignupFormProps) => {
|
||||
const [signupMutation] = useMutation(signup)
|
||||
|
||||
return (
|
||||
<div>
|
||||
<h1>Create an Account</h1>
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import db from "db"
|
||||
import { SecurePassword } from "@blitzjs/auth/secure-password"
|
||||
import { Role } from "types"
|
||||
|
||||
export default async function signup(input, ctx) {
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
import type { BlitzCliConfig } from "blitz"
|
||||
import { setupBlitzServer } from "@blitzjs/next"
|
||||
import { AuthServerPlugin, PrismaStorage } from "@blitzjs/auth"
|
||||
import db from "db"
|
||||
import { simpleRolesIsAuthorized } from "@blitzjs/auth"
|
||||
import { BlitzLogger } from "blitz"
|
||||
import { setupBlitzServer } from "@blitzjs/next"
|
||||
import { AuthServerPlugin, PrismaStorage, simpleRolesIsAuthorized } from "@blitzjs/auth"
|
||||
import db from "db"
|
||||
|
||||
export const cliConfig: BlitzCliConfig = {
|
||||
customTemplates: "src/templates",
|
||||
@@ -27,6 +26,9 @@ const { gSSP, gSP, api } = setupBlitzServer({
|
||||
isAuthorized: simpleRolesIsAuthorized,
|
||||
}),
|
||||
],
|
||||
formatError: (error) => {
|
||||
return new Error("Formatted error" + error.message)
|
||||
},
|
||||
logger: BlitzLogger({}),
|
||||
})
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { api } from "src/blitz-server"
|
||||
import GithubProvider from "next-auth/providers/github"
|
||||
import { NextAuthAdapter, BlitzNextAuthOptions } from "@blitzjs/auth/next-auth"
|
||||
import GithubProvider from "@auth/core/providers/github"
|
||||
import { AuthAdapter } from "@blitzjs/auth/adapters/authjs"
|
||||
import db, { User } from "db"
|
||||
import { Role } from "types"
|
||||
|
||||
@@ -13,20 +13,23 @@ const providers = [
|
||||
]
|
||||
|
||||
export default api(
|
||||
NextAuthAdapter({
|
||||
AuthAdapter({
|
||||
successRedirectUrl: "/",
|
||||
errorRedirectUrl: "/error",
|
||||
providers,
|
||||
trustHost: true,
|
||||
secret: process.env.AUTH_SECRET,
|
||||
callback: async (user, account, profile, session) => {
|
||||
console.log("USER SIDE PROFILE_DATA", { user, account, profile })
|
||||
let newUser: User
|
||||
if (!user) throw new Error("No user found")
|
||||
try {
|
||||
newUser = await db.user.findFirstOrThrow({ where: { name: { equals: user.name } } })
|
||||
} catch (e) {
|
||||
newUser = await db.user.create({
|
||||
data: {
|
||||
email: user.email as string,
|
||||
name: user.name as string,
|
||||
email: user.email ?? "",
|
||||
name: user.name ?? "",
|
||||
role: "USER",
|
||||
},
|
||||
})
|
||||
|
||||
@@ -1,4 +1,16 @@
|
||||
import { rpcHandler } from "@blitzjs/rpc"
|
||||
import { api } from "src/blitz-server"
|
||||
|
||||
export default api(rpcHandler({ onError: console.log }))
|
||||
export default api(
|
||||
rpcHandler({
|
||||
onError: console.log,
|
||||
formatError: (error) => {
|
||||
error.message = `FormatError handler: ${error.message}`
|
||||
return error
|
||||
},
|
||||
// logging: {
|
||||
// verbose: true,
|
||||
// blockList: ["/getCurrentUser"],
|
||||
// },
|
||||
})
|
||||
)
|
||||
|
||||
@@ -5,7 +5,6 @@ import { useCurrentUser } from "src/users/hooks/useCurrentUser"
|
||||
import logout from "src/auth/mutations/logout"
|
||||
import { useMutation } from "@blitzjs/rpc"
|
||||
import { BlitzPage } from "@blitzjs/next"
|
||||
import { Routes } from ".blitz"
|
||||
import styles from "src/styles/Home.module.css"
|
||||
|
||||
/*
|
||||
@@ -32,23 +31,25 @@ const UserInfo = () => {
|
||||
User id: <code>{currentUser.id}</code>
|
||||
<br />
|
||||
User role: <code>{currentUser.role}</code>
|
||||
<br />
|
||||
User email: <code>{currentUser.email}</code>
|
||||
</div>
|
||||
</>
|
||||
)
|
||||
} else {
|
||||
return (
|
||||
<>
|
||||
<Link href={Routes.SignupPage()} className={styles.button}>
|
||||
<Link href={"/signup"} className={styles.button}>
|
||||
<strong>Sign Up</strong>
|
||||
</Link>
|
||||
<Link href={Routes.LoginPage()} className={styles.loginButton}>
|
||||
<Link href={"/login"} className={styles.loginButton}>
|
||||
<strong>Login</strong>
|
||||
</Link>
|
||||
<Link href="/api/auth/github/login" passHref>
|
||||
<a className="button small">
|
||||
<a href="/api/auth/github/signin">
|
||||
<p className="button small">
|
||||
<strong>Sign in with GitHub</strong>
|
||||
</a>
|
||||
</Link>
|
||||
</p>
|
||||
</a>
|
||||
</>
|
||||
)
|
||||
}
|
||||
@@ -79,8 +80,6 @@ const Home: BlitzPage = () => {
|
||||
|
||||
<h1>Your database & authentication is ready. Try it by signing up.</h1>
|
||||
|
||||
{/* Auth */}
|
||||
|
||||
<div className={styles.buttonContainer}>
|
||||
<Suspense fallback="Loading...">
|
||||
<UserInfo />
|
||||
@@ -99,7 +98,7 @@ const Home: BlitzPage = () => {
|
||||
<div className={styles.code}>
|
||||
<span>1</span>
|
||||
<pre>
|
||||
<code>blitz generate all project</code>
|
||||
<code>blitz generate all project name:string</code>
|
||||
</pre>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ import { useQuery } from "@blitzjs/rpc"
|
||||
import getCurrentUser from "src/users/queries/getCurrentUser"
|
||||
|
||||
export const useCurrentUser = () => {
|
||||
console.log("useCurrentUser")
|
||||
const [user] = useQuery(getCurrentUser, null)
|
||||
return user
|
||||
}
|
||||
|
||||
@@ -16,14 +16,14 @@
|
||||
"schema": "./db/schema.prisma"
|
||||
},
|
||||
"dependencies": {
|
||||
"@blitzjs/auth": "workspace:*",
|
||||
"@blitzjs/config": "workspace:*",
|
||||
"@blitzjs/next": "workspace:*",
|
||||
"@blitzjs/rpc": "workspace:*",
|
||||
"@blitzjs/auth": "2.0.0-beta.31",
|
||||
"@blitzjs/config": "2.0.0-beta.31",
|
||||
"@blitzjs/next": "2.0.0-beta.31",
|
||||
"@blitzjs/rpc": "2.0.0-beta.31",
|
||||
"@prisma/client": "4.6.1",
|
||||
"@types/jest": "29.2.2",
|
||||
"@types/passport-twitter": "1.0.37",
|
||||
"blitz": "workspace:*",
|
||||
"blitz": "2.0.0-beta.31",
|
||||
"jest": "29.3.0",
|
||||
"jest-environment-jsdom": "29.3.0",
|
||||
"next": "13.3.0",
|
||||
|
||||
@@ -13,7 +13,6 @@ const {gSSP, gSP, api} = setupBlitzServer({
|
||||
}),
|
||||
],
|
||||
logger: BlitzLogger({
|
||||
colorizePrettyLogs: true,
|
||||
prefix: ["[blitz]>>>>>"],
|
||||
}),
|
||||
})
|
||||
|
||||
BIN
assets/Byteflow.png
Normal file
BIN
assets/Byteflow.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 23 KiB |
61
flake.lock
generated
Normal file
61
flake.lock
generated
Normal file
@@ -0,0 +1,61 @@
|
||||
{
|
||||
"nodes": {
|
||||
"flake-utils": {
|
||||
"inputs": {
|
||||
"systems": "systems"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1687709756,
|
||||
"narHash": "sha256-Y5wKlQSkgEK2weWdOu4J3riRd+kV/VCgHsqLNTTWQ/0=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "dbabf0ca0c0c4bce6ea5eaf65af5cb694d2082c7",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1688221086,
|
||||
"narHash": "sha256-cdW6qUL71cNWhHCpMPOJjlw0wzSRP0pVlRn2vqX/VVg=",
|
||||
"owner": "nixos",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "cd99c2b3c9f160cd004318e0697f90bbd5960825",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nixos",
|
||||
"ref": "nixpkgs-unstable",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"flake-utils": "flake-utils",
|
||||
"nixpkgs": "nixpkgs"
|
||||
}
|
||||
},
|
||||
"systems": {
|
||||
"locked": {
|
||||
"lastModified": 1681028828,
|
||||
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"type": "github"
|
||||
}
|
||||
}
|
||||
},
|
||||
"root": "root",
|
||||
"version": 7
|
||||
}
|
||||
39
flake.nix
Normal file
39
flake.nix
Normal file
@@ -0,0 +1,39 @@
|
||||
{
|
||||
description = "The Blitzjs Monorepo";
|
||||
nixConfig.bash-prompt = "\[nix:blitz\]$ ";
|
||||
|
||||
inputs = {
|
||||
nixpkgs = {
|
||||
url = "github:nixos/nixpkgs/nixpkgs-unstable";
|
||||
};
|
||||
|
||||
flake-utils = {
|
||||
url = "github:numtide/flake-utils";
|
||||
};
|
||||
};
|
||||
|
||||
outputs = {
|
||||
nixpkgs,
|
||||
flake-utils,
|
||||
...
|
||||
}:
|
||||
flake-utils.lib.eachDefaultSystem (system: let
|
||||
pkgs = nixpkgs.legacyPackages.${system};
|
||||
in {
|
||||
formatter = pkgs.alejandra;
|
||||
|
||||
devShells = {
|
||||
default = pkgs.mkShell {
|
||||
buildInputs = with pkgs; [
|
||||
nodejs-18_x
|
||||
];
|
||||
|
||||
shellHook = ''
|
||||
mkdir -p $out/bin
|
||||
${pkgs.nodejs-18_x}/bin/corepack enable --install-directory $out/bin
|
||||
export PATH="$out/bin:$PATH"
|
||||
'';
|
||||
};
|
||||
};
|
||||
});
|
||||
}
|
||||
@@ -17,14 +17,14 @@
|
||||
"prisma:studio": "prisma studio"
|
||||
},
|
||||
"dependencies": {
|
||||
"@blitzjs/auth": "workspace:2.0.0-beta.26",
|
||||
"@blitzjs/config": "workspace:2.0.0-beta.26",
|
||||
"@blitzjs/next": "workspace:2.0.0-beta.26",
|
||||
"@blitzjs/rpc": "workspace:2.0.0-beta.26",
|
||||
"@blitzjs/auth": "2.0.0-beta.31",
|
||||
"@blitzjs/config": "2.0.0-beta.31",
|
||||
"@blitzjs/next": "2.0.0-beta.31",
|
||||
"@blitzjs/rpc": "2.0.0-beta.31",
|
||||
"@hookform/error-message": "2.0.0",
|
||||
"@hookform/resolvers": "2.9.10",
|
||||
"@prisma/client": "4.6.1",
|
||||
"blitz": "workspace:2.0.0-beta.26",
|
||||
"blitz": "2.0.0-beta.31",
|
||||
"delay": "5.0.0",
|
||||
"next": "13.3.0",
|
||||
"prisma": "4.6.1",
|
||||
|
||||
@@ -1,21 +1,21 @@
|
||||
import {describe, it, expect, beforeAll, afterAll} from "vitest"
|
||||
import {afterAll, beforeAll, describe, expect, it} from "vitest"
|
||||
import {
|
||||
killApp,
|
||||
findPort,
|
||||
runBlitzCommand,
|
||||
blitzLaunchApp,
|
||||
blitzBuild,
|
||||
blitzLaunchApp,
|
||||
blitzStart,
|
||||
findPort,
|
||||
killApp,
|
||||
runBlitzCommand,
|
||||
waitFor,
|
||||
} from "../../utils/next-test-utils"
|
||||
import webdriver from "../../utils/next-webdriver"
|
||||
|
||||
let app: any
|
||||
let appPort: number
|
||||
let appPort: number = 3000
|
||||
|
||||
const runTests = () => {
|
||||
describe("Auth", () => {
|
||||
/* TODO - Add a non flaky Integration Test for custom plugin
|
||||
/* TODO - Add a non flaky Integration Test for custom plugin
|
||||
describe("custom plugin", () => {
|
||||
it("custom plugin - events", async () => {
|
||||
const browser = await webdriver(appPort, "/custom-plugin")
|
||||
@@ -263,7 +263,7 @@ describe("Auth Tests", () => {
|
||||
describe("dev mode", () => {
|
||||
beforeAll(async () => {
|
||||
try {
|
||||
await runBlitzCommand(["prisma", "migrate", "reset", "--force"])
|
||||
await runBlitzCommand(["prisma", "migrate", "reset", "--force"])
|
||||
appPort = await findPort()
|
||||
app = await blitzLaunchApp(appPort, {cwd: process.cwd()})
|
||||
} catch (error) {
|
||||
|
||||
@@ -17,11 +17,11 @@
|
||||
"prisma:studio": "prisma studio"
|
||||
},
|
||||
"dependencies": {
|
||||
"@blitzjs/auth": "workspace:2.0.0-beta.26",
|
||||
"@blitzjs/config": "workspace:2.0.0-beta.26",
|
||||
"@blitzjs/next": "workspace:2.0.0-beta.26",
|
||||
"@blitzjs/auth": "2.0.0-beta.31",
|
||||
"@blitzjs/config": "2.0.0-beta.31",
|
||||
"@blitzjs/next": "2.0.0-beta.31",
|
||||
"@prisma/client": "4.6.1",
|
||||
"blitz": "workspace:2.0.0-beta.26",
|
||||
"blitz": "2.0.0-beta.31",
|
||||
"lowdb": "3.0.0",
|
||||
"next": "13.3.0",
|
||||
"prisma": "4.6.1",
|
||||
|
||||
@@ -14,7 +14,7 @@ import fetch from "node-fetch"
|
||||
import {fromBase64} from "b64-lite"
|
||||
|
||||
let app: any
|
||||
let appPort: number
|
||||
let appPort: number = 3000
|
||||
const HEADER_CSRF = "anti-csrf"
|
||||
const COOKIE_PUBLIC_DATA_TOKEN = "auth-tests-cookie-prefix_sPublicDataToken"
|
||||
const COOKIE_SESSION_TOKEN = "auth-tests-cookie-prefix_sSessionToken"
|
||||
@@ -43,7 +43,7 @@ const runTests = (mode?: string) => {
|
||||
const browser = await webdriver(appPort, "/authenticated-page")
|
||||
let errorMsg = await browser.elementById(`error`).text()
|
||||
expect(errorMsg).toMatch(/Error: You are not authenticated/)
|
||||
if (browser) browser.close()
|
||||
if (browser) void browser.close()
|
||||
},
|
||||
5000 * 60 * 2,
|
||||
)
|
||||
@@ -132,7 +132,7 @@ describe("Auth Tests", () => {
|
||||
describe("dev mode", async () => {
|
||||
beforeAll(async () => {
|
||||
try {
|
||||
await runBlitzCommand(["prisma", "migrate", "reset", "--force"])
|
||||
await runBlitzCommand(["prisma", "migrate", "reset", "--force"])
|
||||
appPort = await findPort()
|
||||
app = await blitzLaunchApp(appPort, {cwd: process.cwd()})
|
||||
} catch (error) {
|
||||
|
||||
@@ -16,11 +16,11 @@
|
||||
"schema": "db/schema.prisma"
|
||||
},
|
||||
"dependencies": {
|
||||
"@blitzjs/auth": "workspace:2.0.0-beta.26",
|
||||
"@blitzjs/next": "workspace:2.0.0-beta.26",
|
||||
"@blitzjs/rpc": "workspace:2.0.0-beta.26",
|
||||
"@blitzjs/auth": "2.0.0-beta.31",
|
||||
"@blitzjs/next": "2.0.0-beta.31",
|
||||
"@blitzjs/rpc": "2.0.0-beta.31",
|
||||
"@prisma/client": "4.6.1",
|
||||
"blitz": "workspace:2.0.0-beta.26",
|
||||
"blitz": "2.0.0-beta.31",
|
||||
"lowdb": "3.0.0",
|
||||
"next": "13.3.0",
|
||||
"prisma": "4.6.1",
|
||||
@@ -28,7 +28,7 @@
|
||||
"react-dom": "18.2.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@blitzjs/config": "workspace:2.0.0-beta.26",
|
||||
"@blitzjs/config": "2.0.0-beta.31",
|
||||
"@next/bundle-analyzer": "12.0.8",
|
||||
"@types/express": "4.17.13",
|
||||
"@types/fs-extra": "9.0.13",
|
||||
|
||||
@@ -15,7 +15,7 @@ import webdriver from "../../utils/next-webdriver"
|
||||
import {join} from "path"
|
||||
|
||||
let app: any
|
||||
let appPort: number
|
||||
let appPort: number = 3000
|
||||
const appDir = join(__dirname, "../")
|
||||
|
||||
const runTests = (mode?: string) => {
|
||||
@@ -50,7 +50,7 @@ describe("getInitialProps Tests", () => {
|
||||
describe("dev mode", () => {
|
||||
beforeAll(async () => {
|
||||
try {
|
||||
await runBlitzCommand(["prisma", "migrate", "reset", "--force"])
|
||||
await runBlitzCommand(["prisma", "migrate", "reset", "--force"])
|
||||
appPort = await findPort()
|
||||
app = await blitzLaunchApp(appPort, {cwd: process.cwd()})
|
||||
} catch (error) {
|
||||
|
||||
@@ -11,10 +11,10 @@
|
||||
"clean": "rm -rf .turbo && rm -rf node_modules && rm -rf .next"
|
||||
},
|
||||
"dependencies": {
|
||||
"@blitzjs/config": "workspace:2.0.0-beta.26",
|
||||
"@blitzjs/next": "workspace:2.0.0-beta.26",
|
||||
"@blitzjs/rpc": "workspace:2.0.0-beta.26",
|
||||
"blitz": "workspace:2.0.0-beta.26",
|
||||
"@blitzjs/config": "2.0.0-beta.31",
|
||||
"@blitzjs/next": "2.0.0-beta.31",
|
||||
"@blitzjs/rpc": "2.0.0-beta.31",
|
||||
"blitz": "2.0.0-beta.31",
|
||||
"next": "13.3.0",
|
||||
"react": "18.2.0",
|
||||
"react-dom": "18.2.0"
|
||||
|
||||
@@ -13,7 +13,7 @@ import {
|
||||
import {join} from "path"
|
||||
|
||||
let app: any
|
||||
let appPort: number
|
||||
let appPort: number = 3000
|
||||
const appDir = join(__dirname, "../")
|
||||
|
||||
const runTests = () => {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
/// <reference types="next" />
|
||||
/// <reference types="next/image-types/global" />
|
||||
/// <reference types="next/navigation-types/compat/navigation" />
|
||||
|
||||
// NOTE: This file should not be edited
|
||||
// see https://nextjs.org/docs/basic-features/typescript for more information.
|
||||
|
||||
@@ -17,12 +17,12 @@
|
||||
"prisma:studio": "prisma studio"
|
||||
},
|
||||
"dependencies": {
|
||||
"@blitzjs/auth": "workspace:2.0.0-beta.26",
|
||||
"@blitzjs/config": "workspace:2.0.0-beta.26",
|
||||
"@blitzjs/next": "workspace:2.0.0-beta.26",
|
||||
"@blitzjs/rpc": "workspace:2.0.0-beta.26",
|
||||
"@blitzjs/auth": "2.0.0-beta.31",
|
||||
"@blitzjs/config": "2.0.0-beta.31",
|
||||
"@blitzjs/next": "2.0.0-beta.31",
|
||||
"@blitzjs/rpc": "2.0.0-beta.31",
|
||||
"@prisma/client": "4.6.1",
|
||||
"blitz": "workspace:2.0.0-beta.26",
|
||||
"blitz": "2.0.0-beta.31",
|
||||
"lowdb": "3.0.0",
|
||||
"next": "13.3.0",
|
||||
"prisma": "4.6.1",
|
||||
|
||||
@@ -1,20 +1,13 @@
|
||||
import {describe, it, expect, beforeAll, afterAll} from "vitest"
|
||||
import {afterAll, beforeAll, describe, expect, it} from "vitest"
|
||||
import waitPort from "wait-port"
|
||||
import {
|
||||
killApp,
|
||||
findPort,
|
||||
runBlitzCommand,
|
||||
blitzLaunchApp,
|
||||
blitzBuild,
|
||||
blitzStart,
|
||||
} from "../../utils/next-test-utils"
|
||||
import {blitzLaunchApp, findPort, killApp, runBlitzCommand} from "../../utils/next-test-utils"
|
||||
import webdriver from "../../utils/next-webdriver"
|
||||
|
||||
import fetch from "node-fetch"
|
||||
import {fromBase64} from "b64-lite"
|
||||
|
||||
let app: any
|
||||
let appPort: number
|
||||
let appPort: number = 3000
|
||||
const HEADER_CSRF = "anti-csrf"
|
||||
const COOKIE_PUBLIC_DATA_TOKEN = "auth-tests-cookie-prefix_sPublicDataToken"
|
||||
const COOKIE_SESSION_TOKEN = "auth-tests-cookie-prefix_sSessionToken"
|
||||
@@ -43,7 +36,7 @@ const runTests = (mode?: string) => {
|
||||
const browser = await webdriver(appPort, "/authenticated-client")
|
||||
let errorMsg = await browser.elementById(`error`).text()
|
||||
expect(errorMsg).toMatch(/Error: You are not authenticated/)
|
||||
if (browser) browser.close()
|
||||
if (browser) await browser.close()
|
||||
},
|
||||
5000 * 60 * 2,
|
||||
)
|
||||
@@ -55,7 +48,7 @@ const runTests = (mode?: string) => {
|
||||
const browser = await webdriver(appPort, "/authenticated-server")
|
||||
let errorMsg = await browser.elementById(`error`).text()
|
||||
expect(errorMsg).toMatch(/Error: You are not authenticated/)
|
||||
if (browser) browser.close()
|
||||
if (browser) await browser.close()
|
||||
},
|
||||
5000 * 60 * 2,
|
||||
)
|
||||
@@ -163,7 +156,7 @@ describe("Auth Tests", () => {
|
||||
describe("dev mode", async () => {
|
||||
beforeAll(async () => {
|
||||
try {
|
||||
await runBlitzCommand(["prisma", "migrate", "reset", "--force"])
|
||||
await runBlitzCommand(["prisma", "migrate", "reset", "--force"])
|
||||
appPort = await findPort()
|
||||
app = await blitzLaunchApp(appPort, {cwd: process.cwd()})
|
||||
} catch (error) {
|
||||
|
||||
@@ -9,7 +9,8 @@
|
||||
{
|
||||
"name": "next"
|
||||
}
|
||||
]
|
||||
],
|
||||
"strictNullChecks": true
|
||||
},
|
||||
"exclude": ["node_modules"],
|
||||
"baseUrl": "."
|
||||
|
||||
@@ -16,11 +16,11 @@
|
||||
"prisma:studio": "prisma studio"
|
||||
},
|
||||
"dependencies": {
|
||||
"@blitzjs/auth": "workspace:2.0.0-beta.26",
|
||||
"@blitzjs/next": "workspace:2.0.0-beta.26",
|
||||
"@blitzjs/rpc": "workspace:2.0.0-beta.26",
|
||||
"@blitzjs/auth": "2.0.0-beta.31",
|
||||
"@blitzjs/next": "2.0.0-beta.31",
|
||||
"@blitzjs/rpc": "2.0.0-beta.31",
|
||||
"@prisma/client": "4.6.1",
|
||||
"blitz": "workspace:2.0.0-beta.26",
|
||||
"blitz": "2.0.0-beta.31",
|
||||
"lowdb": "3.0.0",
|
||||
"next": "13.3.0",
|
||||
"prisma": "4.6.1",
|
||||
@@ -28,7 +28,7 @@
|
||||
"react-dom": "18.2.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@blitzjs/config": "workspace:2.0.0-beta.26",
|
||||
"@blitzjs/config": "2.0.0-beta.31",
|
||||
"@next/bundle-analyzer": "12.0.8",
|
||||
"@types/express": "4.17.13",
|
||||
"@types/fs-extra": "9.0.13",
|
||||
|
||||
@@ -15,7 +15,7 @@ import webdriver from "../../utils/next-webdriver"
|
||||
import {join} from "path"
|
||||
|
||||
let app: any
|
||||
let appPort: number
|
||||
let appPort: number = 3000
|
||||
const appDir = join(__dirname, "../")
|
||||
|
||||
const runTests = (mode?: string) => {
|
||||
@@ -40,7 +40,7 @@ describe("No Suspense Tests", () => {
|
||||
describe("dev mode", () => {
|
||||
beforeAll(async () => {
|
||||
try {
|
||||
await runBlitzCommand(["prisma", "migrate", "reset", "--force"])
|
||||
await runBlitzCommand(["prisma", "migrate", "reset", "--force"])
|
||||
appPort = await findPort()
|
||||
app = await blitzLaunchApp(appPort, {cwd: process.cwd()})
|
||||
} catch (error) {
|
||||
|
||||
@@ -8,13 +8,13 @@
|
||||
"clean": "rm -rf .turbo && rm -rf node_modules"
|
||||
},
|
||||
"dependencies": {
|
||||
"@blitzjs/auth": "workspace:2.0.0-beta.26",
|
||||
"@blitzjs/config": "workspace:2.0.0-beta.26",
|
||||
"@blitzjs/next": "workspace:2.0.0-beta.26",
|
||||
"@blitzjs/rpc": "workspace:2.0.0-beta.26",
|
||||
"@blitzjs/auth": "2.0.0-beta.31",
|
||||
"@blitzjs/config": "2.0.0-beta.31",
|
||||
"@blitzjs/next": "2.0.0-beta.31",
|
||||
"@blitzjs/rpc": "2.0.0-beta.31",
|
||||
"@prisma/client": "4.6.1",
|
||||
"@tanstack/react-query": "4.0.10",
|
||||
"blitz": "workspace:2.0.0-beta.26",
|
||||
"blitz": "2.0.0-beta.31",
|
||||
"next": "13.3.0",
|
||||
"prisma": "4.6.1",
|
||||
"react": "18.2.0",
|
||||
|
||||
@@ -16,10 +16,10 @@
|
||||
"schema": "db/schema.prisma"
|
||||
},
|
||||
"dependencies": {
|
||||
"@blitzjs/next": "workspace:2.0.0-beta.26",
|
||||
"@blitzjs/rpc": "workspace:2.0.0-beta.26",
|
||||
"@blitzjs/next": "2.0.0-beta.31",
|
||||
"@blitzjs/rpc": "2.0.0-beta.31",
|
||||
"@prisma/client": "4.6.1",
|
||||
"blitz": "workspace:2.0.0-beta.26",
|
||||
"blitz": "2.0.0-beta.31",
|
||||
"lowdb": "3.0.0",
|
||||
"next": "13.3.0",
|
||||
"prisma": "4.6.1",
|
||||
@@ -27,7 +27,7 @@
|
||||
"react-dom": "18.2.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@blitzjs/config": "workspace:2.0.0-beta.26",
|
||||
"@blitzjs/config": "2.0.0-beta.31",
|
||||
"@next/bundle-analyzer": "12.0.8",
|
||||
"@types/express": "4.17.13",
|
||||
"@types/fs-extra": "9.0.13",
|
||||
|
||||
@@ -10,7 +10,7 @@ import {
|
||||
import webdriver from "../../utils/next-webdriver"
|
||||
|
||||
let app: any
|
||||
let appPort: number
|
||||
let appPort: number = 3000
|
||||
|
||||
const runTests = () => {
|
||||
describe("get query data", () => {
|
||||
@@ -114,7 +114,7 @@ describe("React Query Utils Tests", () => {
|
||||
describe("dev mode", () => {
|
||||
beforeAll(async () => {
|
||||
try {
|
||||
await runBlitzCommand(["prisma", "migrate", "reset", "--force"])
|
||||
await runBlitzCommand(["prisma", "migrate", "reset", "--force"])
|
||||
appPort = await findPort()
|
||||
app = await blitzLaunchApp(appPort, {cwd: process.cwd()})
|
||||
} catch (error) {
|
||||
|
||||
@@ -7,10 +7,10 @@
|
||||
"clean": "rm -rf .turbo && rm -rf node_modules && rm -rf .next"
|
||||
},
|
||||
"dependencies": {
|
||||
"@blitzjs/config": "workspace:2.0.0-beta.26",
|
||||
"@blitzjs/next": "workspace:2.0.0-beta.26",
|
||||
"@blitzjs/rpc": "workspace:2.0.0-beta.26",
|
||||
"blitz": "workspace:2.0.0-beta.26",
|
||||
"@blitzjs/config": "2.0.0-beta.31",
|
||||
"@blitzjs/next": "2.0.0-beta.31",
|
||||
"@blitzjs/rpc": "2.0.0-beta.31",
|
||||
"blitz": "2.0.0-beta.31",
|
||||
"next": "13.3.0",
|
||||
"react": "18.2.0",
|
||||
"react-dom": "18.2.0"
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
class ErrorWithStatusCode extends Error {
|
||||
statusCode
|
||||
|
||||
constructor(message, statusCode) {
|
||||
super(message)
|
||||
this.statusCode = statusCode
|
||||
}
|
||||
}
|
||||
|
||||
export default async function getCustomStatusCodeFailure() {
|
||||
throw new ErrorWithStatusCode("Error with custom status code for test", 418)
|
||||
}
|
||||
@@ -7,10 +7,10 @@
|
||||
"clean": "rm -rf .turbo && rm -rf node_modules && rm -rf .next"
|
||||
},
|
||||
"dependencies": {
|
||||
"@blitzjs/config": "workspace:2.0.0-beta.26",
|
||||
"@blitzjs/next": "workspace:2.0.0-beta.26",
|
||||
"@blitzjs/rpc": "workspace:2.0.0-beta.26",
|
||||
"blitz": "workspace:2.0.0-beta.26",
|
||||
"@blitzjs/config": "2.0.0-beta.31",
|
||||
"@blitzjs/next": "2.0.0-beta.31",
|
||||
"@blitzjs/rpc": "2.0.0-beta.31",
|
||||
"blitz": "2.0.0-beta.31",
|
||||
"next": "13.3.0",
|
||||
"react": "18.2.0",
|
||||
"react-dom": "18.2.0"
|
||||
|
||||
@@ -1,14 +1,13 @@
|
||||
import {describe, it, expect, beforeAll, afterAll} from "vitest"
|
||||
import fs from "fs-extra"
|
||||
import {afterAll, beforeAll, describe, expect, it} from "vitest"
|
||||
import {join} from "path"
|
||||
import {
|
||||
killApp,
|
||||
findPort,
|
||||
launchApp,
|
||||
fetchViaHTTP,
|
||||
findPort,
|
||||
killApp,
|
||||
launchApp,
|
||||
nextBuild,
|
||||
nextStart,
|
||||
nextExport,
|
||||
nextStart,
|
||||
} from "../../utils/next-test-utils"
|
||||
|
||||
// jest.setTimeout(1000 * 60 * 2)
|
||||
|
||||
@@ -16,11 +16,11 @@
|
||||
"schema": "db/schema.prisma"
|
||||
},
|
||||
"dependencies": {
|
||||
"@blitzjs/auth": "workspace:2.0.0-beta.26",
|
||||
"@blitzjs/next": "workspace:2.0.0-beta.26",
|
||||
"@blitzjs/rpc": "workspace:2.0.0-beta.26",
|
||||
"@blitzjs/auth": "2.0.0-beta.31",
|
||||
"@blitzjs/next": "2.0.0-beta.31",
|
||||
"@blitzjs/rpc": "2.0.0-beta.31",
|
||||
"@prisma/client": "4.6.1",
|
||||
"blitz": "workspace:2.0.0-beta.26",
|
||||
"blitz": "2.0.0-beta.31",
|
||||
"lowdb": "3.0.0",
|
||||
"next": "13.3.0",
|
||||
"prisma": "4.6.1",
|
||||
@@ -28,7 +28,7 @@
|
||||
"react-dom": "18.2.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@blitzjs/config": "workspace:2.0.0-beta.26",
|
||||
"@blitzjs/config": "2.0.0-beta.31",
|
||||
"@next/bundle-analyzer": "12.0.8",
|
||||
"@types/express": "4.17.13",
|
||||
"@types/fs-extra": "9.0.13",
|
||||
|
||||
@@ -15,7 +15,7 @@ import webdriver from "../../utils/next-webdriver"
|
||||
import {join} from "path"
|
||||
|
||||
let app: any
|
||||
let appPort: number
|
||||
let appPort: number = 3000
|
||||
const appDir = join(__dirname, "../")
|
||||
|
||||
const runTests = (mode?: string) => {
|
||||
@@ -39,7 +39,7 @@ describe("Trailing Slash Tests", () => {
|
||||
describe("dev mode", () => {
|
||||
beforeAll(async () => {
|
||||
try {
|
||||
await runBlitzCommand(["prisma", "migrate", "reset", "--force"])
|
||||
await runBlitzCommand(["prisma", "migrate", "reset", "--force"])
|
||||
appPort = await findPort()
|
||||
app = await blitzLaunchApp(appPort, {cwd: process.cwd()})
|
||||
} catch (error) {
|
||||
|
||||
11
package.json
11
package.json
@@ -13,7 +13,7 @@
|
||||
"prepare": "husky install",
|
||||
"build": "turbo run build",
|
||||
"build:apps": "turbo run buildapp --concurrency=1",
|
||||
"dev": "turbo run dev --no-cache --parallel",
|
||||
"dev": "turbo run dev --filter='./packages/*'",
|
||||
"lint": "turbo run lint",
|
||||
"test": "turbo run test",
|
||||
"clean": "turbo run clean && rm -rf node_modules",
|
||||
@@ -34,15 +34,20 @@
|
||||
"prettier": "^2.7.1",
|
||||
"prettier-plugin-prisma": "4.4.0",
|
||||
"pretty-quick": "3.1.3",
|
||||
"turbo": "1.4.2",
|
||||
"turbo": "1.10.7",
|
||||
"vitest": "0.25.3",
|
||||
"wait-on": "6.0.1"
|
||||
},
|
||||
"npmClient": "pnpm",
|
||||
"packageManager": "pnpm@7.11.0",
|
||||
"packageManager": "pnpm@8.6.6",
|
||||
"manypkg": {
|
||||
"ignoredRules": [
|
||||
"EXTERNAL_MISMATCH"
|
||||
]
|
||||
},
|
||||
"pnpm": {
|
||||
"patchedDependencies": {
|
||||
"@auth/core@0.10.0": "patches/@auth__core@0.10.0.patch"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
1
packages/blitz-auth/.gitignore
vendored
Normal file
1
packages/blitz-auth/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
adapters
|
||||
@@ -1,5 +1,54 @@
|
||||
# @blitzjs/auth
|
||||
|
||||
## 2.0.0-beta.31
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 90f1741da: blitz-auth: Support for Prisma v5
|
||||
|
||||
Internal: Make `handle` a required paramter while updating the `session` modal.
|
||||
|
||||
- Updated dependencies [90f1741da]
|
||||
- Updated dependencies [df3265b85]
|
||||
- blitz@2.0.0-beta.31
|
||||
|
||||
## 2.0.0-beta.30
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- c5572bec6: blitz-auth: Fix webpack from following next-auth
|
||||
- Updated dependencies [c5572bec6]
|
||||
- Updated dependencies [727734955]
|
||||
- blitz@2.0.0-beta.30
|
||||
|
||||
## 2.0.0-beta.29
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- b6b9a1c5a: Fix Next-Auth integration: `Unable to use next-auth with provider: Error [ERR_PACKAGE_PATH_NOT_EXPORTED]`
|
||||
- Updated dependencies [b6b9a1c5a]
|
||||
- Updated dependencies [61888d1a3]
|
||||
- blitz@2.0.0-beta.29
|
||||
|
||||
## 2.0.0-beta.28
|
||||
|
||||
### Minor Changes
|
||||
|
||||
- 1bb3a6556: Stop exporting `useAuthenticatedBlitzContext` from `@blitzjs/auth` this must be imported from `app/blitz-server.ts` file in order to work correctly
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 5166e5e03: (feat) upgrade tslog to v4.8.2
|
||||
- Updated dependencies [5166e5e03]
|
||||
- blitz@2.0.0-beta.28
|
||||
|
||||
## 2.0.0-beta.27
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 29c2b029a: Fix: Add missing entry to expose next-auth adapter in Blitz Auth
|
||||
- blitz@2.0.0-beta.27
|
||||
|
||||
## 2.0.0-beta.26
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -5,7 +5,11 @@ const config: BuildConfig = {
|
||||
"./src/index-browser",
|
||||
"./src/index-server",
|
||||
"./src/server/secure-password",
|
||||
"./src/server/adapters/next-auth",
|
||||
{
|
||||
builder: "mkdist",
|
||||
input: "./src/adapters/",
|
||||
outDir: "./adapters",
|
||||
},
|
||||
],
|
||||
externals: ["index-browser.cjs", "index-browser.mjs", "react"],
|
||||
declaration: true,
|
||||
|
||||
1
packages/blitz-auth/next-auth.d.ts
vendored
1
packages/blitz-auth/next-auth.d.ts
vendored
@@ -1 +0,0 @@
|
||||
export * from "./dist/next-auth"
|
||||
@@ -1 +0,0 @@
|
||||
module.exports = require("./dist/next-auth.cjs")
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@blitzjs/auth",
|
||||
"version": "2.0.0-beta.26",
|
||||
"version": "2.0.0-beta.31",
|
||||
"homepage": "https://blitzjs.com/",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
@@ -24,7 +24,7 @@
|
||||
"files": [
|
||||
"dist/**",
|
||||
"secure-password.*",
|
||||
"next-auth.*"
|
||||
"adapters/**"
|
||||
],
|
||||
"dependencies": {
|
||||
"@types/b64-lite": "1.3.0",
|
||||
@@ -37,6 +37,7 @@
|
||||
"cookie": "0.4.1",
|
||||
"cookie-session": "2.0.0",
|
||||
"debug": "4.3.3",
|
||||
"find-up": "4.1.0",
|
||||
"http": "0.0.1-security",
|
||||
"jsonwebtoken": "9.0.0",
|
||||
"nanoid": "3.2.0",
|
||||
@@ -44,13 +45,14 @@
|
||||
"openid-client": "5.2.1",
|
||||
"passport": "0.6.0",
|
||||
"path": "0.12.7",
|
||||
"resolve-from": "5.0.0",
|
||||
"supports-color": "8.1.1",
|
||||
"url": "0.11.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"blitz": "2.0.0-beta.26",
|
||||
"@auth/core": "*",
|
||||
"blitz": "2.0.0-beta.31",
|
||||
"next": "*",
|
||||
"next-auth": "*",
|
||||
"secure-password": "4.0.0"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
@@ -60,12 +62,13 @@
|
||||
"secure-password": {
|
||||
"optional": true
|
||||
},
|
||||
"next-auth": {
|
||||
"@auth/core": {
|
||||
"optional": true
|
||||
}
|
||||
},
|
||||
"devDependencies": {
|
||||
"@blitzjs/config": "workspace:2.0.0-beta.26",
|
||||
"@auth/core": "0.10.0",
|
||||
"@blitzjs/config": "2.0.0-beta.31",
|
||||
"@testing-library/react": "13.4.0",
|
||||
"@testing-library/react-hooks": "8.0.1",
|
||||
"@types/cookie": "0.4.1",
|
||||
@@ -73,9 +76,8 @@
|
||||
"@types/jsonwebtoken": "8.5.8",
|
||||
"@types/react": "18.0.25",
|
||||
"@types/react-dom": "17.0.14",
|
||||
"blitz": "2.0.0-beta.26",
|
||||
"blitz": "2.0.0-beta.31",
|
||||
"next": "13.3.0",
|
||||
"next-auth": "4.18.7",
|
||||
"react": "18.2.0",
|
||||
"react-dom": "18.2.0",
|
||||
"secure-password": "4.0.0",
|
||||
|
||||
1
packages/blitz-auth/src/.gitignore
vendored
Normal file
1
packages/blitz-auth/src/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
!adapters
|
||||
2
packages/blitz-auth/src/adapters/authjs.ts
Normal file
2
packages/blitz-auth/src/adapters/authjs.ts
Normal file
@@ -0,0 +1,2 @@
|
||||
export * from "./authjs/adapter"
|
||||
export * from "./authjs/types"
|
||||
@@ -11,23 +11,26 @@ import {
|
||||
secureProxyMiddleware,
|
||||
truncateString,
|
||||
} from "blitz"
|
||||
import {isLocalhost, SessionContext} from "../../../index-server"
|
||||
|
||||
// next-auth internals
|
||||
import {toInternalRequest, toResponse} from "./internals/utils/web"
|
||||
import {getBody, getURL, setHeaders} from "./internals/utils/node"
|
||||
import type {RequestInternal, AuthOptions, User} from "next-auth"
|
||||
import type {Cookie} from "next-auth/core/lib/cookie"
|
||||
import type {AuthAction, InternalOptions} from "./internals/core/types"
|
||||
|
||||
import type {
|
||||
ApiHandlerIncomingMessage,
|
||||
BlitzNextAuthApiHandler,
|
||||
BlitzNextAuthOptions,
|
||||
} from "./types"
|
||||
import {Provider} from "next-auth/providers"
|
||||
import {isLocalhost} from "../utils"
|
||||
|
||||
export {withNextAuthAdapter} from "./webpack"
|
||||
// next-auth internals
|
||||
import {getBody, getURL, setHeaders} from "./internals/core/node"
|
||||
import type {AuthAction, InternalOptions, RequestInternal} from "./internals/core/types"
|
||||
import type {OAuthConfig} from "@auth/core/providers"
|
||||
import type {Cookie} from "@auth/core/lib/cookie"
|
||||
|
||||
import {init} from "@auth/core/lib/init"
|
||||
import emailSignIn from "@auth/core/lib/email/signin"
|
||||
import {getAuthorizationUrl} from "@auth/core/lib/oauth/authorization-url"
|
||||
import {handleOAuth} from "@auth/core/lib/oauth/callback"
|
||||
import {handleState} from "@auth/core/lib/oauth/handle-state"
|
||||
import {toInternalRequest, toResponse} from "@auth/core/lib/web"
|
||||
import {assertConfig} from "@auth/core/lib/assert"
|
||||
|
||||
const INTERNAL_REDIRECT_URL_KEY = "_redirectUrl"
|
||||
|
||||
@@ -40,41 +43,38 @@ function switchURL(callbackUrl: string) {
|
||||
return `${url.protocol}//${url.host}${switchPathNameString}${url.search}${url.hash}`
|
||||
}
|
||||
|
||||
export function NextAuthAdapter<P extends Provider[]>(
|
||||
export function AuthAdapter<P extends OAuthConfig<any>[]>(
|
||||
config: BlitzNextAuthOptions<P>,
|
||||
): BlitzNextAuthApiHandler {
|
||||
return async function authHandler(req, res) {
|
||||
assert(
|
||||
req.query.nextauth,
|
||||
"req.query.nextauth is not defined. Page must be named [...auth].ts/js.",
|
||||
"req.query.nextauth is not defined. Page must be named [...nextauth].ts/js.",
|
||||
)
|
||||
assert(
|
||||
Array.isArray(req.query.nextauth),
|
||||
"req.query.nextauth must be an array. Page must be named [...auth].ts/js.",
|
||||
"req.query.nextauth must be an array. Page must be named [...nextauth].ts/js.",
|
||||
)
|
||||
if (!req.query.nextauth?.length) {
|
||||
return res.status(404).end()
|
||||
}
|
||||
const action = req.query.nextauth[1] as AuthAction
|
||||
if (!action || !["login", "callback"].includes(action)) {
|
||||
if (!action || !["signin", "callback"].includes(action)) {
|
||||
return res.status(404).end()
|
||||
}
|
||||
|
||||
const cookieSessionMiddleware = cookieSession({
|
||||
secret: process.env.SESSION_SECRET_KEY || "default-dev-secret",
|
||||
secure: process.env.NODE_ENV === "production" && !isLocalhost(req),
|
||||
})
|
||||
|
||||
const middleware: RequestMiddleware<ApiHandlerIncomingMessage, MiddlewareResponse<Ctx>>[] = [
|
||||
connectMiddleware(cookieSessionMiddleware as RequestMiddleware),
|
||||
]
|
||||
|
||||
if (config.secureProxy) {
|
||||
middleware.push(secureProxyMiddleware)
|
||||
}
|
||||
|
||||
const headers = new Headers(req.headers as any)
|
||||
const url = getURL(req.url, headers)
|
||||
log.debug("NEXT_AUTH_URL", url)
|
||||
if (url instanceof Error) {
|
||||
if (process.env.NODE_ENV !== "production") throw url
|
||||
const errorLogger = config.logger?.error ?? console.error
|
||||
@@ -90,38 +90,46 @@ export function NextAuthAdapter<P extends Provider[]>(
|
||||
method: req.method,
|
||||
...getBody(req),
|
||||
})
|
||||
|
||||
log.debug("NEXT_AUTH_REQUEST")
|
||||
const internalRequest = await toInternalRequest(request)
|
||||
log.debug("NEXT_AUTH_INTERNAL_REQUEST", internalRequest)
|
||||
if (internalRequest instanceof Error) {
|
||||
console.error((request as any).code, request)
|
||||
return new Response(`Error: This action with HTTP ${request.method} is not supported.`, {
|
||||
status: 400,
|
||||
return res.status(500).json({
|
||||
message:
|
||||
"There was a problem with the server configuration. Check the server logs for more information.",
|
||||
})
|
||||
}
|
||||
let {providerId} = internalRequest
|
||||
if (providerId?.includes("?")) {
|
||||
providerId = providerId.split("?")[0]
|
||||
const assertionResult = assertConfig(internalRequest, config)
|
||||
if (Array.isArray(assertionResult)) {
|
||||
assertionResult.forEach(log.error)
|
||||
} else if (assertionResult instanceof Error) {
|
||||
// Bail out early if there's an error in the user config
|
||||
log.error(assertionResult.message)
|
||||
return res.status(500).json({
|
||||
message:
|
||||
"There was a problem with the server configuration. Check the server logs for more information.",
|
||||
code: assertionResult.name,
|
||||
})
|
||||
}
|
||||
const {init} = await import("next-auth/core/init").then((m) => m)
|
||||
const callbackUrl = req.body?.callbackUrl ?? req.query?.callbackUrl?.toString()
|
||||
const {options, cookies} = await init({
|
||||
// @ts-ignore
|
||||
url: new URL(
|
||||
// @ts-ignore
|
||||
internalRequest.url!,
|
||||
internalRequest.url,
|
||||
process.env.APP_ORIGIN || process.env.BLITZ_DEV_SERVER_ORIGIN,
|
||||
),
|
||||
authOptions: config as unknown as AuthOptions,
|
||||
authOptions: config,
|
||||
action,
|
||||
providerId,
|
||||
callbackUrl: req.body?.callbackUrl ?? (req.query?.callbackUrl as string),
|
||||
providerId: internalRequest.providerId.includes("?")
|
||||
? internalRequest.providerId.split("?")[0]
|
||||
: internalRequest.providerId,
|
||||
callbackUrl,
|
||||
cookies: internalRequest.cookies,
|
||||
isPost: req.method === "POST",
|
||||
csrfDisabled: config.csrf?.enabled ?? false,
|
||||
})
|
||||
|
||||
options.provider.callbackUrl = switchURL(options.provider.callbackUrl)
|
||||
|
||||
log.debug("NEXT_AUTH_INTERNAL_OPTIONS", options)
|
||||
|
||||
await AuthHandler(middleware, config, internalRequest, action, options, cookies)
|
||||
.then(async ({middleware}) => {
|
||||
await handleRequestWithMiddleware<ApiHandlerIncomingMessage, MiddlewareResponse<Ctx>>(
|
||||
@@ -144,7 +152,14 @@ export function NextAuthAdapter<P extends Provider[]>(
|
||||
}
|
||||
}
|
||||
|
||||
async function AuthHandler<P extends Provider[]>(
|
||||
function defaultNormalizer(email?: string) {
|
||||
if (!email) throw new Error("Missing email from request body.")
|
||||
let [local, domain] = email.toLowerCase().trim().split("@")
|
||||
domain = domain?.split(",")[0]
|
||||
return `${local}@${domain}`
|
||||
}
|
||||
|
||||
export async function AuthHandler<P extends OAuthConfig<any>[]>(
|
||||
middleware: RequestMiddleware<ApiHandlerIncomingMessage, MiddlewareResponse<Ctx>>[],
|
||||
config: BlitzNextAuthOptions<P>,
|
||||
internalRequest: RequestInternal,
|
||||
@@ -155,26 +170,34 @@ async function AuthHandler<P extends Provider[]>(
|
||||
if (!options.provider) {
|
||||
throw new OAuthError("MISSING_PROVIDER_ERROR")
|
||||
}
|
||||
if (action === "login") {
|
||||
middleware.push(async (req, res, next) => {
|
||||
if (action === "signin") {
|
||||
middleware.push(async (req, res, _next) => {
|
||||
try {
|
||||
const getAuthorizationUrl = await import("next-auth/core/lib/oauth/authorization-url").then(
|
||||
(m) => m.default,
|
||||
)
|
||||
const _signin = await getAuthorizationUrl({options: options, query: req.query})
|
||||
if (_signin.cookies) cookies.push(..._signin.cookies)
|
||||
const session = res.blitzCtx.session as SessionContext
|
||||
assert(session, "Missing Blitz sessionMiddleware!")
|
||||
await session.$setPublicData({
|
||||
[INTERNAL_REDIRECT_URL_KEY]: _signin.redirect,
|
||||
} as any)
|
||||
const response = toResponse(_signin)
|
||||
setHeaders(response.headers, res)
|
||||
res.setHeader("Location", _signin.redirect)
|
||||
res.statusCode = 302
|
||||
res.end()
|
||||
if (options.provider.type === "oauth" || options.provider.type === "oidc") {
|
||||
const _signin = await getAuthorizationUrl(req.query, options)
|
||||
log.debug("NEXT_AUTH_SIGNIN", _signin)
|
||||
if (_signin.cookies) cookies.push(..._signin.cookies)
|
||||
await res.blitzCtx.session.$setPublicData({
|
||||
[INTERNAL_REDIRECT_URL_KEY]: _signin.redirect,
|
||||
} as any)
|
||||
const response = toResponse(_signin)
|
||||
setHeaders(response.headers, res)
|
||||
log.debug("NEXT_AUTH_SIGNIN_REDIRECT", _signin.redirect)
|
||||
res.setHeader("Location", _signin.redirect)
|
||||
res.statusCode = 302
|
||||
res.end()
|
||||
} else if (options.provider.type === "email") {
|
||||
const normalizer = options.provider.normalizeIdentifier ?? defaultNormalizer
|
||||
const email = normalizer(internalRequest.body?.email)
|
||||
const redirect = await emailSignIn(email, options, internalRequest)
|
||||
res.setHeader("Location", redirect)
|
||||
res.statusCode = 302
|
||||
res.end()
|
||||
} else {
|
||||
throw new OAuthError("UNSUPPORTED_PROVIDER_ERROR")
|
||||
}
|
||||
} catch (e) {
|
||||
log.error("OAUTH_SIGNIN_Error in NextAuthAdapter " + (e as Error).toString())
|
||||
log.error("OAUTH_SIGNIN_Error in AuthAdapter " + (e as Error).toString())
|
||||
console.log(e)
|
||||
const authErrorQueryStringKey = config.errorRedirectUrl.includes("?")
|
||||
? "&authError="
|
||||
@@ -189,22 +212,27 @@ async function AuthHandler<P extends Provider[]>(
|
||||
return {middleware}
|
||||
} else if (action === "callback") {
|
||||
middleware.push(
|
||||
// eslint-disable-next-line no-shadow
|
||||
connectMiddleware(async (req, res, next) => {
|
||||
const oAuthCallback = await import("next-auth/core/lib/oauth/callback").then(
|
||||
(m) => m.default,
|
||||
)
|
||||
connectMiddleware(async (req, res, _next) => {
|
||||
try {
|
||||
const {profile, account, OAuthProfile} = await oAuthCallback({
|
||||
query: internalRequest.query,
|
||||
body: internalRequest.body || {code: req.query.code, state: req.query.state},
|
||||
method: "POST",
|
||||
options: options as any,
|
||||
cookies: internalRequest.cookies,
|
||||
})
|
||||
const session = res.blitzCtx.session as SessionContext
|
||||
assert(session, "Missing Blitz sessionMiddleware!")
|
||||
const callback = await config.callback(profile as User, account, OAuthProfile!, session)
|
||||
const {proxyRedirect, randomState} = handleState(
|
||||
req.query,
|
||||
options.provider,
|
||||
options.isOnRedirectProxy,
|
||||
)
|
||||
if (proxyRedirect) {
|
||||
log.debug("proxy redirect", {proxyRedirect, randomState})
|
||||
res.setHeader("Location", proxyRedirect)
|
||||
res.statusCode = 302
|
||||
res.end()
|
||||
}
|
||||
const {cookies, profile, account, user} = await handleOAuth(
|
||||
req.query,
|
||||
internalRequest.cookies,
|
||||
options,
|
||||
)
|
||||
log.debug("NEXT_AUTH_CALLBACK", {cookies, profile, account, user})
|
||||
const session = res.blitzCtx.session
|
||||
const callback = await config.callback(user, account, profile as any, session)
|
||||
let _redirect = config.successRedirectUrl
|
||||
if (callback instanceof Object) {
|
||||
_redirect = callback.redirectUrl
|
||||
@@ -213,13 +241,12 @@ async function AuthHandler<P extends Provider[]>(
|
||||
redirect: _redirect,
|
||||
cookies: cookies,
|
||||
})
|
||||
|
||||
setHeaders(response.headers, res)
|
||||
res.setHeader("Location", _redirect)
|
||||
res.statusCode = 302
|
||||
res.end()
|
||||
} catch (e) {
|
||||
log.error("OAUTH_CALLBACK_Error in NextAuthAdapter " + (e as Error).toString())
|
||||
log.error("OAUTH_CALLBACK_Error in AuthAdapter " + (e as Error).toString())
|
||||
console.log(e)
|
||||
const authErrorQueryStringKey = config.errorRedirectUrl.includes("?")
|
||||
? "&authError="
|
||||
@@ -0,0 +1,3 @@
|
||||
# Auth Core Internals for Blitz
|
||||
|
||||
This directory contains the internals of the Auth Core being used by the blitz adapter.
|
||||
@@ -1,6 +1,7 @@
|
||||
import type {CallbacksOptions, CookiesOptions, EventCallbacks} from "next-auth"
|
||||
import type {Adapter} from "next-auth/adapters"
|
||||
import type {JWTOptions} from "next-auth/jwt"
|
||||
import type {AuthConfig} from "@auth/core"
|
||||
import {EventCallbacks, PagesOptions, CookiesOptions, CallbacksOptions} from "@auth/core/types"
|
||||
import type {Adapter} from "@auth/core/adapters"
|
||||
import type {JWTOptions} from "@auth/core/jwt"
|
||||
import type {
|
||||
OAuthConfig,
|
||||
ProviderType,
|
||||
@@ -9,7 +10,7 @@ import type {
|
||||
AuthorizationEndpointHandler,
|
||||
EmailConfig,
|
||||
CredentialsConfig,
|
||||
} from "next-auth/providers"
|
||||
} from "@auth/core/providers"
|
||||
|
||||
export interface OAuthConfigInternal<P>
|
||||
extends Omit<OAuthConfig<P>, "authorization" | "token" | "userinfo"> {
|
||||
@@ -33,7 +34,7 @@ export type AuthAction =
|
||||
| "providers"
|
||||
| "session"
|
||||
| "csrf"
|
||||
| "login"
|
||||
| "signin"
|
||||
| "signout"
|
||||
| "callback"
|
||||
| "verify-request"
|
||||
@@ -61,26 +62,40 @@ export interface LoggerInstance extends Record<string, Function> {
|
||||
debug: (code: string, metadata: unknown) => void
|
||||
}
|
||||
|
||||
export interface InternalOptions<
|
||||
TProviderType = ProviderType,
|
||||
WithVerificationToken = TProviderType extends "email" ? true : false,
|
||||
> {
|
||||
export interface RequestInternal {
|
||||
url: URL
|
||||
method: "GET" | "POST"
|
||||
cookies?: Partial<Record<string, string>>
|
||||
headers?: Record<string, any>
|
||||
query?: Record<string, any>
|
||||
body?: Record<string, any>
|
||||
action: AuthAction
|
||||
providerId?: string
|
||||
error?: string
|
||||
}
|
||||
|
||||
export interface InternalOptions<TProviderType = ProviderType> {
|
||||
providers: InternalProvider[]
|
||||
url: URL
|
||||
action: AuthAction
|
||||
provider: InternalProvider<TProviderType>
|
||||
csrfToken?: string
|
||||
csrfTokenVerified?: boolean
|
||||
secret: string
|
||||
theme: Theme
|
||||
debug: boolean
|
||||
logger: LoggerInstance
|
||||
session: Required<LoggerInstance>
|
||||
pages: any
|
||||
session: NonNullable<Required<AuthConfig["session"]>>
|
||||
pages: Partial<PagesOptions>
|
||||
jwt: JWTOptions
|
||||
events: Partial<EventCallbacks>
|
||||
adapter: WithVerificationToken extends true
|
||||
? Adapter<WithVerificationToken>
|
||||
: Adapter<WithVerificationToken> | undefined
|
||||
adapter: Required<Adapter> | undefined
|
||||
callbacks: CallbacksOptions
|
||||
cookies: CookiesOptions
|
||||
callbackUrl: string
|
||||
/**
|
||||
* If true, the OAuth callback is being proxied by the server to the original URL.
|
||||
* See also {@link OAuthConfigInternal.redirectProxyUrl}.
|
||||
*/
|
||||
isOnRedirectProxy: boolean
|
||||
}
|
||||
@@ -1,19 +1,22 @@
|
||||
import type {Ctx, MiddlewareResponse} from "blitz"
|
||||
import type {IncomingMessage} from "http"
|
||||
import type {AuthOptions, Profile, User} from "next-auth"
|
||||
import {SessionContext} from "../../../index-server"
|
||||
import oAuthCallback from "next-auth/core/lib/oauth/callback"
|
||||
import {OAuthConfig, Provider} from "next-auth/providers"
|
||||
import type {Account, Profile, User} from "@auth/core/types"
|
||||
import type {AuthConfig} from "@auth/core"
|
||||
import type {SessionContext} from "../../index-server"
|
||||
import type {OAuthConfig} from "@auth/core/providers"
|
||||
|
||||
export type BlitzNextAuthOptions<P extends Provider[]> = Omit<AuthOptions, "providers"> & {
|
||||
export type BlitzNextAuthOptions<P extends OAuthConfig<any>[]> = Omit<AuthConfig, "providers"> & {
|
||||
providers: P
|
||||
successRedirectUrl: string
|
||||
errorRedirectUrl: string
|
||||
secureProxy?: boolean
|
||||
csrf?: {
|
||||
enabled: boolean
|
||||
}
|
||||
callback: (
|
||||
user: User,
|
||||
account: Awaited<ReturnType<typeof oAuthCallback>>["account"],
|
||||
profile: P[0] extends OAuthConfig<any> ? Parameters<P[0]["profile"]>[0] : Profile,
|
||||
user: User | undefined,
|
||||
account: Account | undefined,
|
||||
profile: P[number] extends OAuthConfig<infer T> ? T : Profile,
|
||||
session: SessionContext,
|
||||
) => Promise<void | {redirectUrl: string}>
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
/* @eslint-disable no-redeclare */
|
||||
import cookieSession from "cookie-session"
|
||||
import passport from "passport"
|
||||
import {isLocalhost} from "../../index"
|
||||
import {isLocalhost} from "../utils"
|
||||
import {
|
||||
assert,
|
||||
connectMiddleware,
|
||||
@@ -12,7 +12,7 @@ import {
|
||||
secureProxyMiddleware,
|
||||
truncateString,
|
||||
} from "blitz"
|
||||
import {SessionContext} from "../../../shared"
|
||||
import type {SessionContext} from "../../shared"
|
||||
import {
|
||||
BlitzPassportConfig,
|
||||
ApiHandler,
|
||||
@@ -1,6 +1,6 @@
|
||||
import type {AuthenticateOptions, Strategy} from "passport"
|
||||
import type {IncomingMessage, ServerResponse} from "http"
|
||||
import type {PublicData} from "../../../shared"
|
||||
import type {PublicData} from "../../shared"
|
||||
import type {Ctx, MiddlewareResponse} from "blitz"
|
||||
|
||||
export interface BlitzPassportConfigCallbackParams {
|
||||
9
packages/blitz-auth/src/adapters/utils/index.ts
Normal file
9
packages/blitz-auth/src/adapters/utils/index.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
export function isLocalhost(req: any): boolean {
|
||||
let {host} = req.headers
|
||||
let localhost = false
|
||||
if (host) {
|
||||
host = host.split(":")[0]
|
||||
localhost = host === "localhost"
|
||||
}
|
||||
return localhost
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
import "./global"
|
||||
|
||||
export * from "./adapters"
|
||||
export * from "./index-browser"
|
||||
export * from "./server"
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
export * from "./next-auth/adapter"
|
||||
export * from "./next-auth/types"
|
||||
export * from "./next-auth/webpack"
|
||||
@@ -1,3 +0,0 @@
|
||||
# Next-auth Internals
|
||||
|
||||
This directory contains the internals of the Next-auth being used by the blitz adapter.
|
||||
@@ -1,39 +0,0 @@
|
||||
export interface InternalUrl {
|
||||
/** @default "http://localhost:3000" */
|
||||
origin: string
|
||||
/** @default "localhost:3000" */
|
||||
host: string
|
||||
/** @default "/api/auth" */
|
||||
path: string
|
||||
/** @default "http://localhost:3000/api/auth" */
|
||||
base: string
|
||||
/** @default "http://localhost:3000/api/auth" */
|
||||
toString: () => string
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO: Can we remove this?
|
||||
* Returns an `URL` like object to make requests/redirects from server-side
|
||||
*/
|
||||
export default function parseUrl(url?: string | URL): InternalUrl {
|
||||
const defaultUrl = new URL("http://localhost:3000/api/auth")
|
||||
|
||||
if (url && !url.toString().startsWith("http")) {
|
||||
url = `https://${url}`
|
||||
}
|
||||
|
||||
const _url = new URL(url ?? defaultUrl)
|
||||
const path = (_url.pathname === "/" ? defaultUrl.pathname : _url.pathname)
|
||||
// Remove trailing slash
|
||||
.replace(/\/$/, "")
|
||||
|
||||
const base = `${_url.origin}${path}`
|
||||
|
||||
return {
|
||||
origin: _url.origin,
|
||||
host: _url.host,
|
||||
path,
|
||||
base,
|
||||
toString: () => base,
|
||||
}
|
||||
}
|
||||
@@ -1,115 +0,0 @@
|
||||
import {OAuthError} from "blitz"
|
||||
import {serialize, parse as parseCookie} from "cookie"
|
||||
import type {ResponseInternal, RequestInternal} from "next-auth/core"
|
||||
import type {AuthAction} from "next-auth/core/types"
|
||||
|
||||
const decoder = new TextDecoder()
|
||||
|
||||
async function streamToString(stream: any): Promise<string> {
|
||||
const chunks: Uint8Array[] = []
|
||||
return await new Promise((resolve, reject) => {
|
||||
stream.on("data", (chunk: WithImplicitCoercion<ArrayBuffer | SharedArrayBuffer>) =>
|
||||
chunks.push(Buffer.from(chunk)),
|
||||
)
|
||||
stream.on("error", (err: any) => reject(err))
|
||||
stream.on("end", () => resolve(Buffer.concat(chunks).toString("utf8")))
|
||||
})
|
||||
}
|
||||
|
||||
async function readJSONBody(
|
||||
body: ReadableStream | Buffer,
|
||||
): Promise<Record<string, any> | undefined> {
|
||||
try {
|
||||
if ("getReader" in body) {
|
||||
const reader = body.getReader()
|
||||
const bytes: number[] = []
|
||||
while (true) {
|
||||
const {value, done} = await reader.read()
|
||||
if (done) break
|
||||
bytes.push(...value)
|
||||
}
|
||||
const b = new Uint8Array(bytes)
|
||||
return JSON.parse(decoder.decode(b))
|
||||
}
|
||||
|
||||
// node-fetch
|
||||
|
||||
if (typeof Buffer !== "undefined" && Buffer.isBuffer(body)) {
|
||||
return JSON.parse(body.toString("utf8"))
|
||||
}
|
||||
|
||||
return JSON.parse(await streamToString(body))
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
}
|
||||
}
|
||||
|
||||
// prettier-ignore
|
||||
const actions = [ "providers", "session", "csrf", "login", "signout", "callback", "verify-request", "error", "_log"]
|
||||
|
||||
export async function toInternalRequest(req: Request): Promise<RequestInternal | Error> {
|
||||
try {
|
||||
// TODO: url.toString() should not include action and providerId
|
||||
// see init.ts
|
||||
const url = new URL(req.url.replace(/\/$/, ""))
|
||||
const {pathname} = url
|
||||
|
||||
const action = actions.find((a) => pathname.includes(a)) as AuthAction | undefined
|
||||
if (!action) {
|
||||
throw new OAuthError("Cannot detect action.")
|
||||
}
|
||||
|
||||
const providerIdOrAction = pathname.split("/").pop()
|
||||
let providerId
|
||||
if (
|
||||
providerIdOrAction &&
|
||||
!action.includes(providerIdOrAction) &&
|
||||
["login", "callback"].includes(action)
|
||||
) {
|
||||
providerId = providerIdOrAction
|
||||
}
|
||||
|
||||
return {
|
||||
//@ts-ignore
|
||||
url,
|
||||
action,
|
||||
providerId,
|
||||
method: req.method ?? "GET",
|
||||
headers: Object.fromEntries(req.headers),
|
||||
body: req.body ? await readJSONBody(req.body) : undefined,
|
||||
cookies: parseCookie(req.headers.get("cookie") ?? "") ?? {},
|
||||
error: url.searchParams.get("error") ?? undefined,
|
||||
query: Object.fromEntries(url.searchParams),
|
||||
}
|
||||
} catch (error) {
|
||||
return error as Error
|
||||
}
|
||||
}
|
||||
|
||||
export function toResponse(res: ResponseInternal): Response {
|
||||
const headers = new Headers(res.headers as unknown as HeadersInit)
|
||||
|
||||
res.cookies?.forEach((cookie) => {
|
||||
const {name, value, options} = cookie
|
||||
const cookieHeader = serialize(name, value, options)
|
||||
if (headers.has("Set-Cookie")) {
|
||||
headers.append("Set-Cookie", cookieHeader)
|
||||
} else {
|
||||
headers.set("Set-Cookie", cookieHeader)
|
||||
}
|
||||
})
|
||||
|
||||
const body =
|
||||
headers.get("content-type") === "application/json" ? JSON.stringify(res.body) : res.body
|
||||
|
||||
const response = new Response(body, {
|
||||
headers,
|
||||
status: res.redirect ? 302 : res.status ?? 200,
|
||||
})
|
||||
|
||||
if (res.redirect) {
|
||||
response.headers.set("Location", res.redirect)
|
||||
}
|
||||
|
||||
return response
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
//@ts-nocheck
|
||||
export function withNextAuthAdapter(nextConfig) {
|
||||
const config = Object.assign({}, nextConfig)
|
||||
config.webpack = (config) => {
|
||||
//add a required resolve alias
|
||||
config.resolve.alias["next-auth/core/lib/oauth/callback"] =
|
||||
process.cwd() + "/node_modules/next-auth/core/lib/oauth/callback.js"
|
||||
config.resolve.alias["next-auth/core/lib/oauth/authorization-url"] =
|
||||
process.cwd() + "/node_modules/next-auth/core/lib/oauth/authorization-url.js"
|
||||
config.resolve.alias["next-auth/core/init"] =
|
||||
process.cwd() + "/node_modules/next-auth/core/init.js"
|
||||
return config
|
||||
}
|
||||
return config
|
||||
}
|
||||
@@ -31,7 +31,7 @@ interface PrismaClientWithSession {
|
||||
}): Promise<SessionModel>
|
||||
update(args: {
|
||||
data: Partial<SessionModel>
|
||||
where: {handle?: SessionModel["handle"]}
|
||||
where: {handle: SessionModel["handle"]}
|
||||
}): Promise<SessionModel>
|
||||
delete(args: {where: {handle?: SessionModel["handle"]}}): Promise<SessionModel>
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@ import {
|
||||
log,
|
||||
baseLogger,
|
||||
chalk,
|
||||
AuthenticatedCtx,
|
||||
} from "blitz"
|
||||
import {
|
||||
EmptyPublicData,
|
||||
@@ -189,7 +190,7 @@ export async function getBlitzContext(): Promise<Ctx> {
|
||||
const req = new IncomingMessage(new Socket()) as IncomingMessage & {
|
||||
cookies: {[key: string]: string}
|
||||
}
|
||||
req.headers = Object.fromEntries(headers())
|
||||
req.headers = Object.fromEntries(headers() as any)
|
||||
const csrfToken = cookies().get(COOKIE_CSRF_TOKEN())
|
||||
if (csrfToken) {
|
||||
req.headers[HEADER_CSRF] = csrfToken.value
|
||||
@@ -219,8 +220,8 @@ export async function useAuthenticatedBlitzContext({
|
||||
redirectTo?: string | RouteUrlObject
|
||||
redirectAuthenticatedTo?: string | RouteUrlObject | ((ctx: Ctx) => string | RouteUrlObject)
|
||||
role?: string | string[]
|
||||
}): Promise<void> {
|
||||
const log = baseLogger().getChildLogger()
|
||||
}): Promise<AuthenticatedCtx> {
|
||||
const log = baseLogger().getSubLogger({name: "useAuthenticatedBlitzContext"})
|
||||
const customChalk = new chalk.Instance({
|
||||
level: log.settings.type === "json" ? 0 : chalk.level,
|
||||
})
|
||||
@@ -268,6 +269,7 @@ export async function useAuthenticatedBlitzContext({
|
||||
redirect(redirectTo)
|
||||
}
|
||||
}
|
||||
return ctx as AuthenticatedCtx
|
||||
}
|
||||
|
||||
const makeProxyToPublicData = <T extends SessionContextClass>(ctxClass: T): T => {
|
||||
|
||||
@@ -1,4 +1,14 @@
|
||||
export * from "./auth-sessions"
|
||||
export * from "./auth-utils"
|
||||
export * from "./auth-plugin"
|
||||
export * from "./adapters"
|
||||
export {
|
||||
SessionContextClass,
|
||||
getAllSessionHandlesForUser,
|
||||
getCookieParser,
|
||||
getSession,
|
||||
isLocalhost,
|
||||
setPublicDataForUser,
|
||||
setCookie,
|
||||
simpleRolesIsAuthorized,
|
||||
getBlitzContext,
|
||||
} from "./auth-sessions"
|
||||
export type {AnonymousSessionPayload, SimpleRolesIsAuthorized} from "./auth-sessions"
|
||||
|
||||
@@ -82,7 +82,7 @@ declare module "blitz" {
|
||||
export interface Ctx {
|
||||
session: SessionContext
|
||||
}
|
||||
export interface AuthenticatedMiddlewareCtx extends Omit<Ctx, "session"> {
|
||||
export interface AuthenticatedCtx extends Omit<Ctx, "session"> {
|
||||
session: AuthenticatedSessionContext
|
||||
}
|
||||
}
|
||||
|
||||
11
packages/blitz-auth/turbo.json
Normal file
11
packages/blitz-auth/turbo.json
Normal file
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"$schema": "https://turbo.build/schema.json",
|
||||
"extends": ["//"],
|
||||
"pipeline": {
|
||||
"dev": {
|
||||
"dependsOn": ["blitz#build"],
|
||||
"persistent": true,
|
||||
"cache": false
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,56 @@
|
||||
# @blitzjs/next
|
||||
|
||||
## 2.0.0-beta.31
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [90f1741da]
|
||||
- Updated dependencies [df3265b85]
|
||||
- blitz@2.0.0-beta.31
|
||||
- @blitzjs/rpc@2.0.0-beta.31
|
||||
|
||||
## 2.0.0-beta.30
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [c5572bec6]
|
||||
- Updated dependencies [727734955]
|
||||
- blitz@2.0.0-beta.30
|
||||
- @blitzjs/rpc@2.0.0-beta.30
|
||||
|
||||
## 2.0.0-beta.29
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [b6b9a1c5a]
|
||||
- Updated dependencies [61888d1a3]
|
||||
- blitz@2.0.0-beta.29
|
||||
- @blitzjs/rpc@2.0.0-beta.29
|
||||
|
||||
## 2.0.0-beta.28
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 5166e5e03: (feat) upgrade tslog to v4.8.2
|
||||
- Updated dependencies [5166e5e03]
|
||||
- Updated dependencies [2533caf48]
|
||||
- Updated dependencies [c7ac86b85]
|
||||
- @blitzjs/rpc@2.0.0-beta.28
|
||||
- blitz@2.0.0-beta.28
|
||||
|
||||
## 2.0.0-beta.27
|
||||
|
||||
### Minor Changes
|
||||
|
||||
- eda14fa8a: Add ability to format the error on the server before returning it to the client.
|
||||
- 3d004dc41: Fix the DYNAMIC_SERVER_USAGE error for Next.js 13.3.1+
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [eda14fa8a]
|
||||
- @blitzjs/rpc@2.0.0-beta.27
|
||||
- blitz@2.0.0-beta.27
|
||||
|
||||
## 2.0.0-beta.26
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@blitzjs/next",
|
||||
"version": "2.0.0-beta.26",
|
||||
"version": "2.0.0-beta.31",
|
||||
"homepage": "https://blitzjs.com/",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
@@ -29,7 +29,7 @@
|
||||
"eslint.js"
|
||||
],
|
||||
"dependencies": {
|
||||
"@blitzjs/rpc": "2.0.0-beta.26",
|
||||
"@blitzjs/rpc": "2.0.0-beta.31",
|
||||
"@types/hoist-non-react-statics": "3.3.1",
|
||||
"debug": "4.3.3",
|
||||
"fs-extra": "10.0.1",
|
||||
@@ -38,22 +38,24 @@
|
||||
"supports-color": "8.1.1"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"blitz": "2.0.0-beta.26",
|
||||
"blitz": "2.0.0-beta.31",
|
||||
"next": "*",
|
||||
"react": "*"
|
||||
"react": "*",
|
||||
"tslog": "*"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@blitzjs/config": "workspace:2.0.0-beta.26",
|
||||
"@blitzjs/config": "2.0.0-beta.31",
|
||||
"@testing-library/dom": "8.13.0",
|
||||
"@testing-library/jest-dom": "5.16.3",
|
||||
"@testing-library/react": "13.4.0",
|
||||
"@testing-library/react-hooks": "8.0.1",
|
||||
"@testing-library/user-event": "13.5.0",
|
||||
"@types/debug": "4.1.7",
|
||||
"@types/node": "18.11.9",
|
||||
"@types/react": "18.0.25",
|
||||
"@types/react-dom": "17.0.14",
|
||||
"@types/testing-library__react-hooks": "4.0.0",
|
||||
"blitz": "2.0.0-beta.26",
|
||||
"blitz": "2.0.0-beta.31",
|
||||
"cross-spawn": "7.0.3",
|
||||
"find-up": "4.1.0",
|
||||
"next": "13.3.0",
|
||||
@@ -62,6 +64,7 @@
|
||||
"react-dom": "18.2.0",
|
||||
"resolve-from": "5.0.0",
|
||||
"ts-jest": "27.1.4",
|
||||
"tslog": "4.9.0",
|
||||
"typescript": "^4.8.4",
|
||||
"unbuild": "0.7.6",
|
||||
"watch": "1.0.2"
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user