Compare commits
13 Commits
@blitzjs/n
...
eslint
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e68d69813b | ||
|
|
9529dbd6f4 | ||
|
|
00fd00f082 | ||
|
|
645b2fc5ba | ||
|
|
e898c8bf05 | ||
|
|
a8c96b7713 | ||
|
|
12d0acb595 | ||
|
|
6bc1472edf | ||
|
|
f443118b9d | ||
|
|
e228ba5dee | ||
|
|
430f0b52dd | ||
|
|
6e88a847fe | ||
|
|
1db963a8ca |
@@ -3837,6 +3837,16 @@
|
||||
"contributions": [
|
||||
"code"
|
||||
]
|
||||
},
|
||||
{
|
||||
"login": "exKAZUu",
|
||||
"name": "Sakamoto, Kazunori",
|
||||
"avatar_url": "https://avatars.githubusercontent.com/u/436237?v=4",
|
||||
"profile": "https://github.com/exKAZUu",
|
||||
"contributions": [
|
||||
"doc",
|
||||
"code"
|
||||
]
|
||||
}
|
||||
],
|
||||
"contributorsPerLine": 7,
|
||||
|
||||
5
.changeset/chatty-fireants-leave.md
Normal file
5
.changeset/chatty-fireants-leave.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@blitzjs/generator": patch
|
||||
---
|
||||
|
||||
Fix a type error in reset password templates.
|
||||
20
.changeset/four-radios-tickle.md
Normal file
20
.changeset/four-radios-tickle.md
Normal file
@@ -0,0 +1,20 @@
|
||||
---
|
||||
"@blitzjs/auth": major
|
||||
"@blitzjs/codemod": minor
|
||||
---
|
||||
|
||||
## ⚠️ Breaking Changes for Blitz Auth
|
||||
|
||||
Automatically upgrade using codemod
|
||||
(Make sure to git commit before running this command to avoid losing changes)
|
||||
|
||||
```bash
|
||||
npx @blitz/codemod secure-password
|
||||
```
|
||||
|
||||
Introduce a new import path for the Blitz wrapper `SecurePassword` to fully decouple the library from `@blitzjs/auth`
|
||||
|
||||
```diff
|
||||
- import {SecurePassword} from "@blitzjs/auth"
|
||||
+ import {SecurePassword} from "@blitzjs/auth/secure-password"
|
||||
```
|
||||
18
.changeset/khaki-wombats-exercise.md
Normal file
18
.changeset/khaki-wombats-exercise.md
Normal file
@@ -0,0 +1,18 @@
|
||||
---
|
||||
"eslint-config-blitz-next": major
|
||||
"@blitzjs/next": major
|
||||
---
|
||||
|
||||
Moves the eslint config from the `@blitzjs/next` package to a separate package to allow easier use and extension of eslint configuration.
|
||||
|
||||
```diff
|
||||
- module.exports = require("@blitzjs/next/eslint")
|
||||
|
||||
+ module.exports = {
|
||||
+ "extends": "blitz-next",
|
||||
+ "rules": {
|
||||
+ // enable additional rules
|
||||
+
|
||||
+ }
|
||||
+}
|
||||
```
|
||||
5
.changeset/mean-ears-speak.md
Normal file
5
.changeset/mean-ears-speak.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@blitzjs/generator": patch
|
||||
---
|
||||
|
||||
For new applications, update Prisma (`prisma` and `@prisma/client`) from `4.6.0` to `4.6.1` to solve enum issue with postgresql https://github.com/prisma/prisma/issues/16180
|
||||
5
.changeset/strong-chicken-study.md
Normal file
5
.changeset/strong-chicken-study.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@blitzjs/auth": patch
|
||||
---
|
||||
|
||||
Fixed security vulnerabilities in passport-adapter by upgrading `passport` and `jsonwebtoken`
|
||||
46
README.md
46
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-405-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-406-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">
|
||||
@@ -135,7 +135,15 @@ Your financial contributions help ensure Blitz continues to be developed and mai
|
||||
<table>
|
||||
<tr>
|
||||
<td align="center"><a href="https://twitter.com/flybayer"><img src="https://avatars3.githubusercontent.com/u/8813276?v=4" width="100px;" alt=""/><br /><sub><b>Brandon Bayer</b></sub></a><br />Creator</td>
|
||||
<td align="center"><a href="http://twitter.com/dillonraphael"><img src="https://avatars.githubusercontent.com/u/3496193?v=4" width="100px;" alt=""/><br /><sub><b>Dillon Raphael</b></sub></a><br />Lead Maintainer</td>
|
||||
<td align="center"><a href="http://twitter.com/dillonraphael"><img src="https://avatars.githubusercontent.com/u/3496193?v=4" width="100px;" alt=""/><br /><sub><b>Dillon Raphael</b></sub></a><br /></td>
|
||||
<td align="center">
|
||||
<a href="https://siddharthsuresh.vercel.app/">
|
||||
<img src="https://avatars.githubusercontent.com/u/83594610?v=4" width="100px;" alt="Siddharth Suresh avatar" /><br />
|
||||
<sub>
|
||||
<b>Siddharth Suresh</b>
|
||||
</sub>
|
||||
</a>
|
||||
</td>
|
||||
|
||||
</tr>
|
||||
</table>
|
||||
@@ -155,7 +163,6 @@ _Code ownership, pull request approvals and merging, etc_ (see [Maintainers L2](
|
||||
<tr>
|
||||
<td align="center"><a href="http://simonknott.de"><img src="https://avatars1.githubusercontent.com/u/14912729?v=4" width="100px;" alt=""/><br /><sub><b>Simon Knott</b></sub></a><br />SuperJSON</td>
|
||||
<td align="center"><a href="http://jins.dev"><img src="https://avatars.githubusercontent.com/u/39466936?v=4" width="100px;" alt=""/><br /><sub><b>JH.Lee</b></sub></a><br />SuperJSON</td>
|
||||
<td align="center"><a href="https://juanm04.com"><img src="https://avatars0.githubusercontent.com/u/16712703?v=4" width="100px;" alt=""/><br /><sub><b>Juan Martín Seery</b></sub></a><br />Website/Docs</td>
|
||||
</tr>
|
||||
</table>
|
||||
<!-- markdownlint-enable -->
|
||||
@@ -173,38 +180,6 @@ _Issue triage, pull request triage, community encouragement and moderation, etc_
|
||||
<table>
|
||||
<tr>
|
||||
<td align="center"><a href="http://jeremyliberman.com/"><img src="https://avatars3.githubusercontent.com/u/2754163?v=4" width="100px;" alt=""/><br /><sub><b>Jeremy Liberman</b></td>
|
||||
<td align="center">
|
||||
<a href="https://mina.ca">
|
||||
<img src="https://avatars.githubusercontent.com/mabadir" width="100px;" alt="Mina Abadir avatar" /><br />
|
||||
<sub>
|
||||
<b>Mina Abadir</b>
|
||||
</sub>
|
||||
</a>
|
||||
</td>
|
||||
<td align="center">
|
||||
<a href="https://builtforfifty.com">
|
||||
<img src="https://avatars.githubusercontent.com/abuuzayr" width="100px;" alt="Abu Uzayr avatar" /><br />
|
||||
<sub>
|
||||
<b>Abu Uzayr</b>
|
||||
</sub>
|
||||
</a>
|
||||
</td>
|
||||
<td align="center">
|
||||
<a href="https://damilolarandolph.com/">
|
||||
<img src="https://avatars.githubusercontent.com/damilolarandolph" width="100px;" alt="Damilola Randolph avatar" /><br />
|
||||
<sub>
|
||||
<b>Damilola Randolph</b>
|
||||
</sub>
|
||||
</a>
|
||||
</td>
|
||||
<td align="center">
|
||||
<a href="https://siddharthsuresh.vercel.app/">
|
||||
<img src="https://avatars.githubusercontent.com/u/83594610?v=4" width="100px;" alt="Siddharth Suresh avatar" /><br />
|
||||
<sub>
|
||||
<b>Siddharth Suresh</b>
|
||||
</sub>
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<!-- markdownlint-enable -->
|
||||
@@ -741,6 +716,7 @@ Thanks to these wonderful people ([emoji key](https://allcontributors.org/docs/e
|
||||
<td align="center"><a href="https://twitter.com/trensik"><img src="https://avatars.githubusercontent.com/u/18584155?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Dawid Urbaniak</b></sub></a><br /><a href="https://github.com/blitz-js/blitz/commits?author=Trancever" title="Documentation">📖</a> <a href="https://github.com/blitz-js/blitz/commits?author=Trancever" title="Code">💻</a></td>
|
||||
<td align="center"><a href="https://github.com/jhonnymichel"><img src="https://avatars.githubusercontent.com/u/7006387?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Jhonny Michel</b></sub></a><br /><a href="https://github.com/blitz-js/blitz/commits?author=jhonnymichel" title="Documentation">📖</a> <a href="https://github.com/blitz-js/blitz/commits?author=jhonnymichel" title="Code">💻</a> <a href="https://github.com/blitz-js/blitz/commits?author=jhonnymichel" title="Tests">⚠️</a></td>
|
||||
<td align="center"><a href="sweetliquid.me"><img src="https://avatars.githubusercontent.com/u/18693190?v=4?s=100" width="100px;" alt=""/><br /><sub><b>sweetliquid</b></sub></a><br /><a href="https://github.com/blitz-js/blitz/commits?author=sweetliquid" title="Code">💻</a></td>
|
||||
<td align="center"><a href="https://github.com/exKAZUu"><img src="https://avatars.githubusercontent.com/u/436237?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Sakamoto, Kazunori</b></sub></a><br /><a href="https://github.com/blitz-js/blitz/commits?author=exKAZUu" title="Documentation">📖</a> <a href="https://github.com/blitz-js/blitz/commits?author=exKAZUu" title="Code">💻</a></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
|
||||
@@ -1 +1,6 @@
|
||||
module.exports = require("@blitzjs/next/eslint")
|
||||
module.exports = {
|
||||
extends: "blitz-next",
|
||||
rules: {
|
||||
// enable additional rules
|
||||
},
|
||||
}
|
||||
|
||||
@@ -29,11 +29,12 @@
|
||||
"@blitzjs/rpc": "workspace:*",
|
||||
"@hookform/error-message": "2.0.0",
|
||||
"@hookform/resolvers": "2.9.10",
|
||||
"@prisma/client": "4.6.0",
|
||||
"@prisma/client": "4.6.1",
|
||||
"blitz": "workspace:2.0.0-beta.23",
|
||||
"eslint-config-blitz-next": "workspace:2.0.0-beta.23",
|
||||
"next": "12.2.5",
|
||||
"openid-client": "5.2.1",
|
||||
"prisma": "4.6.0",
|
||||
"prisma": "4.6.1",
|
||||
"react": "18.2.0",
|
||||
"react-dom": "18.2.0",
|
||||
"react-hook-form": "7.39.1",
|
||||
|
||||
@@ -3,7 +3,7 @@ import db from "db"
|
||||
import { authenticateUser } from "./login"
|
||||
import { ChangePassword } from "../validations"
|
||||
import { resolver } from "@blitzjs/rpc"
|
||||
import { SecurePassword } from "@blitzjs/auth"
|
||||
import { SecurePassword } from "@blitzjs/auth/secure-password"
|
||||
|
||||
export default resolver.pipe(
|
||||
resolver.zod(ChangePassword),
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { SecurePassword } from "@blitzjs/auth"
|
||||
import { SecurePassword } from "@blitzjs/auth/secure-password"
|
||||
import { resolver } from "@blitzjs/rpc"
|
||||
import { AuthenticationError } from "blitz"
|
||||
import db from "db"
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { SecurePassword, hash256 } from "@blitzjs/auth"
|
||||
import { hash256 } from "@blitzjs/auth"
|
||||
import { SecurePassword } from "@blitzjs/auth/secure-password"
|
||||
import db from "db"
|
||||
import { ResetPassword } from "../validations"
|
||||
import login from "./login"
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import db from "db"
|
||||
import { SecurePassword } from "@blitzjs/auth"
|
||||
import { SecurePassword } from "@blitzjs/auth/secure-password"
|
||||
import { Role } from "types"
|
||||
|
||||
export default async function signup(input, ctx) {
|
||||
|
||||
@@ -1 +1,7 @@
|
||||
module.exports = require("@blitzjs/next/eslint")
|
||||
module.exports = {
|
||||
"extends": "blitz-next",
|
||||
"rules": {
|
||||
// enable additional rules
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,10 +30,11 @@
|
||||
"@blitzjs/rpc": "workspace:*",
|
||||
"@hookform/error-message": "2.0.0",
|
||||
"@hookform/resolvers": "2.9.10",
|
||||
"@prisma/client": "4.6.0",
|
||||
"@prisma/client": "4.6.1",
|
||||
"blitz": "workspace:2.0.0-beta.23",
|
||||
"eslint-config-blitz-next": "workspace:2.0.0-beta.23",
|
||||
"next": "12.2.5",
|
||||
"prisma": "4.6.0",
|
||||
"prisma": "4.6.1",
|
||||
"react": "18.2.0",
|
||||
"react-dom": "18.2.0",
|
||||
"react-hook-form": "7.39.1",
|
||||
|
||||
@@ -3,7 +3,7 @@ import db from "db"
|
||||
import { authenticateUser } from "./login"
|
||||
import { ChangePassword } from "../validations"
|
||||
import { resolver } from "@blitzjs/rpc"
|
||||
import { SecurePassword } from "@blitzjs/auth"
|
||||
import { SecurePassword } from "@blitzjs/auth/secure-password"
|
||||
|
||||
export default resolver.pipe(
|
||||
resolver.zod(ChangePassword),
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { SecurePassword } from "@blitzjs/auth"
|
||||
import { SecurePassword } from "@blitzjs/auth/secure-password"
|
||||
import { resolver } from "@blitzjs/rpc"
|
||||
import { AuthenticationError } from "blitz"
|
||||
import db from "db"
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
import { vi, describe, it, beforeEach, expect } from "vitest"
|
||||
import resetPassword from "./resetPassword"
|
||||
import db from "db"
|
||||
import { SecurePassword, hash256 } from "@blitzjs/auth"
|
||||
import { hash256 } from "@blitzjs/auth"
|
||||
import { SecurePassword } from "@blitzjs/auth/secure-password"
|
||||
|
||||
beforeEach(async () => {
|
||||
await db.$reset()
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { SecurePassword, hash256 } from "@blitzjs/auth"
|
||||
import { hash256 } from "@blitzjs/auth"
|
||||
import { SecurePassword } from "@blitzjs/auth/secure-password"
|
||||
import db from "db"
|
||||
import { ResetPassword } from "../validations"
|
||||
import login from "./login"
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import db from "db"
|
||||
import { SecurePassword } from "@blitzjs/auth"
|
||||
import { SecurePassword } from "@blitzjs/auth/secure-password"
|
||||
import { Role } from "types"
|
||||
|
||||
export default async function signup(input, ctx) {
|
||||
|
||||
@@ -1 +1,6 @@
|
||||
module.exports = require("@blitzjs/config/eslint")
|
||||
module.exports = {
|
||||
extends: "blitz-next",
|
||||
rules: {
|
||||
// enable additional rules
|
||||
},
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
"@blitzjs/config": "workspace:*",
|
||||
"@blitzjs/next": "workspace:*",
|
||||
"@blitzjs/rpc": "workspace:*",
|
||||
"@prisma/client": "4.6.0",
|
||||
"@prisma/client": "4.6.1",
|
||||
"@types/jest": "29.2.2",
|
||||
"@types/passport-twitter": "1.0.37",
|
||||
"blitz": "workspace:*",
|
||||
@@ -29,7 +29,7 @@
|
||||
"next": "12.2.5",
|
||||
"passport-mock-strategy": "2.0.0",
|
||||
"passport-twitter": "1.0.4",
|
||||
"prisma": "4.6.0",
|
||||
"prisma": "4.6.1",
|
||||
"react": "18.2.0",
|
||||
"react-dom": "18.2.0",
|
||||
"ts-node": "10.9.1"
|
||||
@@ -38,6 +38,7 @@
|
||||
"@next/bundle-analyzer": "12.0.8",
|
||||
"@types/react": "18.0.25",
|
||||
"eslint": "8.27.0",
|
||||
"eslint-config-blitz-next": "workspace:2.0.0-beta.23",
|
||||
"typescript": "^4.8.4"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import {api} from "src/blitz-server"
|
||||
import db from "db"
|
||||
import {SecurePassword} from "@blitzjs/auth"
|
||||
import {SecurePassword} from "@blitzjs/auth/secure-password"
|
||||
|
||||
export const authenticateUser = async (email: string, password: string) => {
|
||||
const user = await db.user.findFirst({where: {email}})
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import {api} from "src/blitz-server"
|
||||
import db from "db"
|
||||
import {SecurePassword} from "@blitzjs/auth"
|
||||
import {SecurePassword} from "@blitzjs/auth/secure-password"
|
||||
|
||||
export default api(async (req, res, ctx) => {
|
||||
const blitzContext = ctx
|
||||
|
||||
@@ -1 +1,6 @@
|
||||
module.exports = require("@blitzjs/next/eslint")
|
||||
module.exports = {
|
||||
extends: "blitz-next",
|
||||
rules: {
|
||||
// enable additional rules
|
||||
},
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import prisma from "./index"
|
||||
import {SecurePassword} from "@blitzjs/auth"
|
||||
import {SecurePassword} from "@blitzjs/auth/secure-password"
|
||||
|
||||
const seed = async () => {
|
||||
const hashedPassword = await SecurePassword.hash("abcd1234")
|
||||
|
||||
@@ -23,11 +23,12 @@
|
||||
"@blitzjs/rpc": "workspace:2.0.0-beta.23",
|
||||
"@hookform/error-message": "2.0.0",
|
||||
"@hookform/resolvers": "2.9.10",
|
||||
"@prisma/client": "4.6.0",
|
||||
"@prisma/client": "4.6.1",
|
||||
"blitz": "workspace:2.0.0-beta.23",
|
||||
"delay": "5.0.0",
|
||||
"eslint-config-blitz-next": "workspace:2.0.0-beta.23",
|
||||
"next": "12.2.5",
|
||||
"prisma": "4.6.0",
|
||||
"prisma": "4.6.1",
|
||||
"react": "18.2.0",
|
||||
"react-dom": "18.2.0",
|
||||
"react-hook-form": "7.39.1",
|
||||
|
||||
@@ -1 +1,6 @@
|
||||
module.exports = require("@blitzjs/config/eslint")
|
||||
module.exports = {
|
||||
extends: "blitz-next",
|
||||
rules: {
|
||||
// enable additional rules
|
||||
},
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import prisma from "./index"
|
||||
import {SecurePassword} from "@blitzjs/auth"
|
||||
import {SecurePassword} from "@blitzjs/auth/secure-password"
|
||||
|
||||
const seed = async () => {
|
||||
const hashedPassword = await SecurePassword.hash("abcd1234")
|
||||
|
||||
@@ -20,13 +20,16 @@
|
||||
"@blitzjs/auth": "workspace:2.0.0-beta.23",
|
||||
"@blitzjs/config": "workspace:2.0.0-beta.23",
|
||||
"@blitzjs/next": "workspace:2.0.0-beta.23",
|
||||
"@prisma/client": "4.6.0",
|
||||
"@prisma/client": "4.6.1",
|
||||
"blitz": "workspace:2.0.0-beta.23",
|
||||
"eslint-config-blitz-next": "workspace:2.0.0-beta.23",
|
||||
"lowdb": "3.0.0",
|
||||
"next": "12.2.5",
|
||||
"prisma": "4.6.0",
|
||||
"prisma": "4.6.1",
|
||||
"react": "18.2.0",
|
||||
"react-dom": "18.2.0"
|
||||
"react-dom": "18.2.0",
|
||||
"secure-password": "4.0.0",
|
||||
"wait-port": "1.0.4"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@next/bundle-analyzer": "12.0.8",
|
||||
@@ -40,6 +43,7 @@
|
||||
"fs-extra": "10.0.1",
|
||||
"get-port": "6.1.2",
|
||||
"node-fetch": "3.2.3",
|
||||
"playwright": "1.28.0",
|
||||
"ts-node": "10.9.1",
|
||||
"typescript": "^4.8.4"
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import {api} from "../../app/blitz-server"
|
||||
import prisma from "../../db/index"
|
||||
import {SecurePassword} from "@blitzjs/auth"
|
||||
import {SecurePassword} from "@blitzjs/auth/secure-password"
|
||||
import {Role} from "../../types"
|
||||
|
||||
export const authenticateUser = async (email: string, password: string) => {
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
import {describe, it, expect, beforeAll, afterAll} from "vitest"
|
||||
import waitPort from "wait-port"
|
||||
import {
|
||||
killApp,
|
||||
findPort,
|
||||
launchApp,
|
||||
nextBuild,
|
||||
nextStart,
|
||||
runBlitzCommand,
|
||||
blitzLaunchApp,
|
||||
blitzBuild,
|
||||
@@ -12,15 +10,11 @@ import {
|
||||
} from "../../utils/next-test-utils"
|
||||
import webdriver from "../../utils/next-webdriver"
|
||||
|
||||
import {join} from "path"
|
||||
import fetch from "node-fetch"
|
||||
import {fromBase64} from "b64-lite"
|
||||
import seed from "../db/seed"
|
||||
import prisma from "../db"
|
||||
|
||||
let app: any
|
||||
let appPort: number
|
||||
const appDir = join(__dirname, "../")
|
||||
const HEADER_CSRF = "anti-csrf"
|
||||
const COOKIE_PUBLIC_DATA_TOKEN = "auth-tests-cookie-prefix_sPublicDataToken"
|
||||
const COOKIE_SESSION_TOKEN = "auth-tests-cookie-prefix_sSessionToken"
|
||||
@@ -45,6 +39,7 @@ const runTests = (mode?: string) => {
|
||||
it(
|
||||
"should render error for protected query",
|
||||
async () => {
|
||||
await waitPort({port: appPort})
|
||||
const browser = await webdriver(appPort, "/authenticated-page")
|
||||
let errorMsg = await browser.elementById(`error`).text()
|
||||
expect(errorMsg).toMatch(/Error: You are not authenticated/)
|
||||
@@ -134,7 +129,7 @@ const runTests = (mode?: string) => {
|
||||
}
|
||||
|
||||
describe("Auth Tests", () => {
|
||||
describe("dev mode", () => {
|
||||
describe("dev mode", async () => {
|
||||
beforeAll(async () => {
|
||||
try {
|
||||
await runBlitzCommand(["prisma", "migrate", "reset", "--force"])
|
||||
@@ -144,24 +139,25 @@ describe("Auth Tests", () => {
|
||||
console.log(error)
|
||||
}
|
||||
}, 5000 * 60 * 2)
|
||||
afterAll(async () => await killApp(app))
|
||||
afterAll(async () => {
|
||||
await killApp(app)
|
||||
})
|
||||
runTests()
|
||||
})
|
||||
|
||||
describe("server mode", () => {
|
||||
beforeAll(async () => {
|
||||
try {
|
||||
await runBlitzCommand(["prisma", "generate"])
|
||||
await runBlitzCommand(["prisma", "migrate", "deploy"])
|
||||
await blitzBuild()
|
||||
appPort = await findPort()
|
||||
app = await blitzStart(appPort, {cwd: process.cwd()})
|
||||
} catch (err) {
|
||||
console.log(err)
|
||||
}
|
||||
}, 5000 * 60 * 2)
|
||||
afterAll(async () => await killApp(app))
|
||||
|
||||
runTests()
|
||||
})
|
||||
// describe("server mode", () => {
|
||||
// beforeAll(async () => {
|
||||
// try {
|
||||
// await runBlitzCommand(["prisma", "generate"])
|
||||
// await runBlitzCommand(["prisma", "migrate", "deploy"])
|
||||
// await blitzBuild()
|
||||
// // appPort = await findPort()
|
||||
// app = await blitzStart(appPort, {cwd: process.cwd()})
|
||||
// } catch (err) {
|
||||
// console.log(err)
|
||||
// }
|
||||
// }, 5000 * 60 * 2)
|
||||
// afterAll(async () => await killApp(app))
|
||||
// runTests()
|
||||
// })
|
||||
})
|
||||
|
||||
@@ -1 +1,6 @@
|
||||
module.exports = require("@blitzjs/config/eslint")
|
||||
module.exports = {
|
||||
extends: "blitz-next",
|
||||
rules: {
|
||||
// enable additional rules
|
||||
},
|
||||
}
|
||||
|
||||
@@ -19,11 +19,12 @@
|
||||
"@blitzjs/auth": "workspace:2.0.0-beta.23",
|
||||
"@blitzjs/next": "workspace:2.0.0-beta.23",
|
||||
"@blitzjs/rpc": "workspace:2.0.0-beta.23",
|
||||
"@prisma/client": "4.6.0",
|
||||
"@prisma/client": "4.6.1",
|
||||
"blitz": "workspace:2.0.0-beta.23",
|
||||
"eslint-config-blitz-next": "workspace:2.0.0-beta.23",
|
||||
"lowdb": "3.0.0",
|
||||
"next": "12.2.5",
|
||||
"prisma": "4.6.0",
|
||||
"prisma": "4.6.1",
|
||||
"react": "18.2.0",
|
||||
"react-dom": "18.2.0"
|
||||
},
|
||||
|
||||
@@ -1 +1,6 @@
|
||||
module.exports = require("@blitzjs/config/eslint")
|
||||
module.exports = {
|
||||
extends: "blitz-next",
|
||||
rules: {
|
||||
// enable additional rules
|
||||
},
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
"@blitzjs/next": "workspace:2.0.0-beta.23",
|
||||
"@blitzjs/rpc": "workspace:2.0.0-beta.23",
|
||||
"blitz": "workspace:2.0.0-beta.23",
|
||||
"eslint-config-blitz-next": "workspace:2.0.0-beta.23",
|
||||
"next": "12.2.5",
|
||||
"react": "18.2.0",
|
||||
"react-dom": "18.2.0"
|
||||
|
||||
@@ -1 +1,6 @@
|
||||
module.exports = require("@blitzjs/config/eslint")
|
||||
module.exports = {
|
||||
extends: "blitz-next",
|
||||
rules: {
|
||||
// enable additional rules
|
||||
},
|
||||
}
|
||||
|
||||
@@ -19,11 +19,12 @@
|
||||
"@blitzjs/auth": "workspace:2.0.0-beta.23",
|
||||
"@blitzjs/next": "workspace:2.0.0-beta.23",
|
||||
"@blitzjs/rpc": "workspace:2.0.0-beta.23",
|
||||
"@prisma/client": "4.6.0",
|
||||
"@prisma/client": "4.6.1",
|
||||
"blitz": "workspace:2.0.0-beta.23",
|
||||
"eslint-config-blitz-next": "workspace:2.0.0-beta.23",
|
||||
"lowdb": "3.0.0",
|
||||
"next": "12.2.5",
|
||||
"prisma": "4.6.0",
|
||||
"prisma": "4.6.1",
|
||||
"react": "18.2.0",
|
||||
"react-dom": "18.2.0"
|
||||
},
|
||||
|
||||
@@ -1 +1,6 @@
|
||||
module.exports = require("@blitzjs/config/eslint")
|
||||
module.exports = {
|
||||
extends: "blitz-next",
|
||||
rules: {
|
||||
// enable additional rules
|
||||
},
|
||||
}
|
||||
|
||||
@@ -12,11 +12,12 @@
|
||||
"@blitzjs/config": "workspace:2.0.0-beta.23",
|
||||
"@blitzjs/next": "workspace:2.0.0-beta.23",
|
||||
"@blitzjs/rpc": "workspace:2.0.0-beta.23",
|
||||
"@prisma/client": "4.6.0",
|
||||
"@prisma/client": "4.6.1",
|
||||
"@tanstack/react-query": "4.0.10",
|
||||
"blitz": "workspace:2.0.0-beta.23",
|
||||
"eslint-config-blitz-next": "workspace:2.0.0-beta.23",
|
||||
"next": "12.2.5",
|
||||
"prisma": "4.6.0",
|
||||
"prisma": "4.6.1",
|
||||
"react": "18.2.0",
|
||||
"react-dom": "18.2.0"
|
||||
},
|
||||
|
||||
@@ -1 +1,6 @@
|
||||
module.exports = require("@blitzjs/config/eslint")
|
||||
module.exports = {
|
||||
extends: "blitz-next",
|
||||
rules: {
|
||||
// enable additional rules
|
||||
},
|
||||
}
|
||||
|
||||
@@ -18,11 +18,12 @@
|
||||
"dependencies": {
|
||||
"@blitzjs/next": "workspace:2.0.0-beta.23",
|
||||
"@blitzjs/rpc": "workspace:2.0.0-beta.23",
|
||||
"@prisma/client": "4.6.0",
|
||||
"@prisma/client": "4.6.1",
|
||||
"blitz": "workspace:2.0.0-beta.23",
|
||||
"eslint-config-blitz-next": "workspace:2.0.0-beta.23",
|
||||
"lowdb": "3.0.0",
|
||||
"next": "12.2.5",
|
||||
"prisma": "4.6.0",
|
||||
"prisma": "4.6.1",
|
||||
"react": "18.2.0",
|
||||
"react-dom": "18.2.0"
|
||||
},
|
||||
|
||||
@@ -1 +1,6 @@
|
||||
module.exports = require("@blitzjs/config/eslint")
|
||||
module.exports = {
|
||||
extends: "blitz-next",
|
||||
rules: {
|
||||
// enable additional rules
|
||||
},
|
||||
}
|
||||
|
||||
@@ -19,11 +19,12 @@
|
||||
"@blitzjs/auth": "workspace:2.0.0-beta.23",
|
||||
"@blitzjs/next": "workspace:2.0.0-beta.23",
|
||||
"@blitzjs/rpc": "workspace:2.0.0-beta.23",
|
||||
"@prisma/client": "4.6.0",
|
||||
"@prisma/client": "4.6.1",
|
||||
"blitz": "workspace:2.0.0-beta.23",
|
||||
"eslint-config-blitz-next": "workspace:2.0.0-beta.23",
|
||||
"lowdb": "3.0.0",
|
||||
"next": "12.2.5",
|
||||
"prisma": "4.6.0",
|
||||
"prisma": "4.6.1",
|
||||
"react": "18.2.0",
|
||||
"react-dom": "18.2.0"
|
||||
},
|
||||
|
||||
@@ -1 +1,6 @@
|
||||
module.exports = require("@blitzjs/config/eslint")
|
||||
module.exports = {
|
||||
extends: "blitz-next",
|
||||
rules: {
|
||||
// enable additional rules
|
||||
},
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import {BuildConfig} from "unbuild"
|
||||
|
||||
const config: BuildConfig = {
|
||||
entries: ["./src/index-browser", "./src/index-server"],
|
||||
entries: ["./src/index-browser", "./src/index-server","./src/server/secure-password"],
|
||||
externals: ["index-browser.cjs", "index-browser.mjs", "react"],
|
||||
declaration: true,
|
||||
rollup: {
|
||||
|
||||
@@ -22,7 +22,8 @@
|
||||
"sideEffects": false,
|
||||
"license": "MIT",
|
||||
"files": [
|
||||
"dist/**"
|
||||
"dist/**",
|
||||
"secure-password.*"
|
||||
],
|
||||
"dependencies": {
|
||||
"@types/b64-lite": "1.3.0",
|
||||
@@ -35,9 +36,9 @@
|
||||
"cookie-session": "2.0.0",
|
||||
"debug": "4.3.3",
|
||||
"http": "0.0.1-security",
|
||||
"jsonwebtoken": "8.5.1",
|
||||
"jsonwebtoken": "9.0.0",
|
||||
"nanoid": "3.2.0",
|
||||
"passport": "0.5.2",
|
||||
"passport": "0.6.0",
|
||||
"path": "0.12.7",
|
||||
"supports-color": "8.1.1",
|
||||
"url": "0.11.0"
|
||||
@@ -61,6 +62,7 @@
|
||||
"@types/react": "18.0.25",
|
||||
"@types/react-dom": "17.0.14",
|
||||
"blitz": "2.0.0-beta.23",
|
||||
"eslint-config-blitz-next": "workspace:2.0.0-beta.23",
|
||||
"react": "18.2.0",
|
||||
"react-dom": "18.2.0",
|
||||
"secure-password": "4.0.0",
|
||||
|
||||
1
packages/blitz-auth/secure-password.d.ts
vendored
Normal file
1
packages/blitz-auth/secure-password.d.ts
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export * from "./dist/secure-password"
|
||||
1
packages/blitz-auth/secure-password.js
Normal file
1
packages/blitz-auth/secure-password.js
Normal file
@@ -0,0 +1 @@
|
||||
module.exports = require("./dist/secure-password.cjs")
|
||||
@@ -2,4 +2,3 @@ export * from "./auth-sessions"
|
||||
export * from "./auth-utils"
|
||||
export * from "./auth-plugin"
|
||||
export * from "./passport-adapter"
|
||||
export * from "./secure-password"
|
||||
|
||||
@@ -1 +1,6 @@
|
||||
module.exports = require("@blitzjs/config/eslint")
|
||||
module.exports = {
|
||||
extends: "blitz-next",
|
||||
rules: {
|
||||
// enable additional rules
|
||||
},
|
||||
}
|
||||
|
||||
@@ -56,6 +56,7 @@
|
||||
"@types/testing-library__react-hooks": "4.0.0",
|
||||
"blitz": "2.0.0-beta.23",
|
||||
"cross-spawn": "7.0.3",
|
||||
"eslint-config-blitz-next": "workspace:2.0.0-beta.23",
|
||||
"find-up": "4.1.0",
|
||||
"next": "12.2.5",
|
||||
"react": "18.2.0",
|
||||
|
||||
@@ -1 +1,6 @@
|
||||
module.exports = require("@blitzjs/config/eslint")
|
||||
module.exports = {
|
||||
extends: "blitz-next",
|
||||
rules: {
|
||||
// enable additional rules
|
||||
},
|
||||
}
|
||||
|
||||
@@ -46,6 +46,7 @@
|
||||
"@types/react": "18.0.25",
|
||||
"@types/react-dom": "17.0.14",
|
||||
"blitz": "2.0.0-beta.23",
|
||||
"eslint-config-blitz-next": "workspace:2.0.0-beta.23",
|
||||
"next": "12.2.5",
|
||||
"react": "18.2.0",
|
||||
"react-dom": "18.2.0",
|
||||
|
||||
@@ -1 +1,6 @@
|
||||
module.exports = require("@blitzjs/config/eslint")
|
||||
module.exports = {
|
||||
extends: "blitz-next",
|
||||
rules: {
|
||||
// enable additional rules
|
||||
},
|
||||
}
|
||||
|
||||
@@ -97,6 +97,7 @@
|
||||
"@types/react-dom": "17.0.14",
|
||||
"@types/test-listen": "1.1.0",
|
||||
"@types/watchpack": "1.1.1",
|
||||
"eslint-config-blitz-next": "workspace:2.0.0-beta.23",
|
||||
"express": "4.17.3",
|
||||
"react": "18.2.0",
|
||||
"test-listen": "1.1.0",
|
||||
|
||||
@@ -1 +1,6 @@
|
||||
module.exports = require("@blitzjs/config/eslint")
|
||||
module.exports = {
|
||||
extends: "blitz-next",
|
||||
rules: {
|
||||
// enable additional rules
|
||||
},
|
||||
}
|
||||
|
||||
@@ -42,6 +42,7 @@
|
||||
"@types/jscodeshift": "0.11.2",
|
||||
"@types/node": "18.11.9",
|
||||
"ast-types": "0.14.2",
|
||||
"eslint-config-blitz-next": "workspace:2.0.0-beta.23",
|
||||
"unbuild": "0.7.6",
|
||||
"watch": "1.0.2"
|
||||
},
|
||||
|
||||
186
packages/codemod/src/eslint.ts
Normal file
186
packages/codemod/src/eslint.ts
Normal file
@@ -0,0 +1,186 @@
|
||||
import j, {
|
||||
Identifier,
|
||||
MemberExpression,
|
||||
ObjectExpression,
|
||||
ObjectProperty,
|
||||
StringLiteral,
|
||||
} from "jscodeshift"
|
||||
import * as fs from "fs-extra"
|
||||
import path from "path"
|
||||
import {findImport, getAllFiles, getCollectionFromSource} from "./utils"
|
||||
import {log} from "blitz"
|
||||
|
||||
class ExpectedError extends Error {
|
||||
constructor(message: string) {
|
||||
super(message)
|
||||
this.name = "Expected Error"
|
||||
}
|
||||
}
|
||||
|
||||
type Step = {name: string; action: (stepIndex: number) => Promise<void>}
|
||||
const eslintBreakingChange = async () => {
|
||||
const appDir = path.resolve("src")
|
||||
let failedAt =
|
||||
fs.existsSync(path.resolve(".migration.json")) && fs.readJSONSync("./.migration.json").failedAt
|
||||
let collectedErrors: {message: string; step: number}[] = []
|
||||
let steps: Step[] = []
|
||||
|
||||
// Add steps in order
|
||||
steps.push({
|
||||
name: "update .eslintrc.js configuration",
|
||||
action: async (stepIndex) => {
|
||||
if (fs.existsSync(path.resolve(".eslintrc.js"))) {
|
||||
const program = getCollectionFromSource(".eslintrc.js")
|
||||
const parsedProgram = program.get()
|
||||
let hasExtends = false
|
||||
// check the value of the right side of the assignment of module.exports
|
||||
const moduleExports = program.find(j.AssignmentExpression, {
|
||||
left: {
|
||||
type: "MemberExpression",
|
||||
object: {
|
||||
type: "Identifier",
|
||||
name: "module",
|
||||
},
|
||||
property: {
|
||||
type: "Identifier",
|
||||
name: "exports",
|
||||
},
|
||||
},
|
||||
})
|
||||
if (moduleExports.length) {
|
||||
const moduleExportsValue: ObjectExpression = moduleExports.get().value.right
|
||||
if (moduleExportsValue.type === "ObjectExpression") {
|
||||
const rules = moduleExportsValue.properties.find(
|
||||
(p) => ((p as ObjectProperty).key as StringLiteral).value === "extends",
|
||||
) as ObjectProperty
|
||||
if (rules) {
|
||||
const rulesValue = rules.value
|
||||
if (
|
||||
rulesValue.type === "CallExpression" &&
|
||||
(rulesValue.callee as MemberExpression).property.type === "Identifier" &&
|
||||
(rulesValue.arguments[0] as StringLiteral).value === "@blitzjs/next/eslint"
|
||||
) {
|
||||
moduleExportsValue.properties.splice(
|
||||
moduleExportsValue.properties.indexOf(rules),
|
||||
1,
|
||||
)
|
||||
moduleExportsValue.properties.unshift(
|
||||
j.objectProperty(j.stringLiteral("extends"), j.stringLiteral("blitz-next")),
|
||||
)
|
||||
hasExtends = true
|
||||
} else if (rulesValue.type === "ArrayExpression") {
|
||||
const rulesValueElements = rulesValue.elements
|
||||
const requireResolve = rulesValueElements.find((e) => {
|
||||
if (e?.type === "CallExpression") {
|
||||
const callee = e.callee
|
||||
if (
|
||||
callee.type === "MemberExpression" &&
|
||||
(callee.object as Identifier).name === "require"
|
||||
) {
|
||||
const property = callee.property
|
||||
if (property.type === "Identifier" && property.name === "resolve") {
|
||||
const args = e.arguments
|
||||
if (args.length === 1 && args[0]?.type === "StringLiteral") {
|
||||
const arg = args[0]
|
||||
if (arg.value === "@blitzjs/next/eslint") {
|
||||
return true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false
|
||||
})
|
||||
if (requireResolve) {
|
||||
rulesValueElements.splice(rulesValueElements.indexOf(requireResolve), 1)
|
||||
rulesValueElements.push(j.stringLiteral("blitz-next"))
|
||||
hasExtends = true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!hasExtends) {
|
||||
parsedProgram.value.program.body = []
|
||||
const moduleExport = j.expressionStatement(
|
||||
j.assignmentExpression(
|
||||
"=",
|
||||
j.memberExpression(j.identifier("module"), j.identifier("exports")),
|
||||
j.objectExpression([
|
||||
j.objectProperty(j.stringLiteral("extends"), j.stringLiteral("blitz-next")),
|
||||
j.objectProperty(j.stringLiteral("rules"), j.objectExpression([])),
|
||||
]),
|
||||
),
|
||||
)
|
||||
parsedProgram.value.program.body.push(moduleExport)
|
||||
}
|
||||
console.log("Program", program.toSource())
|
||||
fs.writeFileSync(".eslintrc.js", program.toSource())
|
||||
throw new Error("For testing")
|
||||
} else {
|
||||
collectedErrors.push({
|
||||
message: ".eslintrc.js does not exist",
|
||||
step: stepIndex,
|
||||
})
|
||||
}
|
||||
}
|
||||
},
|
||||
})
|
||||
// Loop through steps and run the action
|
||||
if ((failedAt && failedAt < steps.length) || failedAt !== "SUCCESS") {
|
||||
for (let [index, step] of steps.entries()) {
|
||||
// Ignore previous steps and continue at step that was failed
|
||||
if (failedAt && index + 1 < failedAt) {
|
||||
continue
|
||||
}
|
||||
const spinner = log.spinner(log.withBrand(`Running ${step.name}...`)).start()
|
||||
try {
|
||||
await step.action(index)
|
||||
if (collectedErrors.filter((e) => e.step === index).length) {
|
||||
// Soft stored error
|
||||
spinner.fail(`${step.name}`)
|
||||
} else {
|
||||
spinner.succeed(`Successfully ran ${step.name}`)
|
||||
}
|
||||
} catch (err) {
|
||||
// Hard exit error
|
||||
const error = err as {code: string} | string
|
||||
spinner.fail(`${step.name}`)
|
||||
log.error(error as string)
|
||||
|
||||
if (error && typeof error === "object" && error.code === "BABEL_PARSE_ERROR") {
|
||||
log.error(
|
||||
log.withBrand(
|
||||
"Don't panic, go to the file with the error & manually fix it. Then run the codemod again. It will continue where it left off.",
|
||||
),
|
||||
)
|
||||
} else if (!(err instanceof ExpectedError)) {
|
||||
log.error(
|
||||
log.withBrand(
|
||||
"This is an unexpected error. Please ask for help in the discord #general-help channel. https://discord.blitzjs.com",
|
||||
),
|
||||
)
|
||||
}
|
||||
failedAt = index + 1
|
||||
fs.writeJsonSync(".migration.json", {
|
||||
failedAt,
|
||||
})
|
||||
process.exit(1)
|
||||
}
|
||||
}
|
||||
if (collectedErrors.length) {
|
||||
for (const error of collectedErrors) {
|
||||
log.error(`⚠️ ${error.message}`)
|
||||
}
|
||||
}
|
||||
fs.writeJsonSync(".migration.json", {
|
||||
failedAt: "SUCCESS",
|
||||
})
|
||||
} else {
|
||||
if (failedAt === "SUCCESS") {
|
||||
log.withBrand("Migration already successful")
|
||||
process.exit(0)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export {eslintBreakingChange}
|
||||
@@ -14,6 +14,8 @@ const args = arg(commonArgs, {
|
||||
|
||||
const commands: {[command: string]: () => Promise<() => void>} = {
|
||||
"upgrade-legacy": () => import("./upgrade-legacy").then((i) => i.upgradeLegacy),
|
||||
"eslint": () => import("./eslint").then((i) => i.eslintBreakingChange),
|
||||
"secure-password": () => import("./secure-password").then((i) => i.securePasswordBreakingChange),
|
||||
}
|
||||
|
||||
const foundCommand = Boolean(commands[args._[0] as string])
|
||||
|
||||
124
packages/codemod/src/secure-password.ts
Normal file
124
packages/codemod/src/secure-password.ts
Normal file
@@ -0,0 +1,124 @@
|
||||
import j from "jscodeshift"
|
||||
import * as fs from "fs-extra"
|
||||
import path from "path"
|
||||
import {findImport, getAllFiles, getCollectionFromSource} from "./utils"
|
||||
import {log} from "blitz"
|
||||
|
||||
class ExpectedError extends Error {
|
||||
constructor(message: string) {
|
||||
super(message)
|
||||
this.name = "Expected Error"
|
||||
}
|
||||
}
|
||||
|
||||
type Step = {name: string; action: (stepIndex: number) => Promise<void>}
|
||||
const securePasswordBreakingChange = async () => {
|
||||
const appDir = path.resolve("src")
|
||||
let failedAt =
|
||||
fs.existsSync(path.resolve(".migration.json")) && fs.readJSONSync("./.migration.json").failedAt
|
||||
let collectedErrors: {message: string; step: number}[] = []
|
||||
let steps: Step[] = []
|
||||
|
||||
// Add steps in order
|
||||
steps.push({
|
||||
name: "update secure-password import",
|
||||
action: async () => {
|
||||
getAllFiles(appDir, [], [], [".ts", ".tsx", ".js", ".jsx"]).forEach((file) => {
|
||||
try {
|
||||
// convert import {SecurePassword} from "@blitzjs/auth" to import {SecurePassword} from "@blitzjs/auth/secure-password"
|
||||
const program = getCollectionFromSource(file)
|
||||
|
||||
const securePasswordImport = j.importDeclaration(
|
||||
[j.importSpecifier(j.identifier("SecurePassword"))],
|
||||
j.stringLiteral("@blitzjs/auth/secure-password"),
|
||||
)
|
||||
|
||||
const findImports = program.find(j.ImportDeclaration, (node) => node)
|
||||
const securePasswordImportExists = findImports.find(j.ImportSpecifier, {
|
||||
imported: {name: "SecurePassword"},
|
||||
})
|
||||
|
||||
if (securePasswordImportExists.length) {
|
||||
//remove the existing import
|
||||
securePasswordImportExists.remove()
|
||||
|
||||
//check if import "@blitzjs/auth" exists
|
||||
const authImportExists = findImports.find(j.ImportDeclaration, {
|
||||
source: {value: "@blitzjs/auth"},
|
||||
})
|
||||
if (authImportExists.length) {
|
||||
//remove the existing import
|
||||
authImportExists.remove()
|
||||
}
|
||||
findImports.at(0).insertBefore(securePasswordImport)
|
||||
fs.writeFileSync(path.join(path.resolve(file)), program.toSource())
|
||||
}
|
||||
} catch (e) {
|
||||
log.error(`Error in updating secure-password imports in the ${file}`)
|
||||
if (typeof e === "string") {
|
||||
throw new Error(e)
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
})
|
||||
|
||||
// Loop through steps and run the action
|
||||
if ((failedAt && failedAt < steps.length) || failedAt !== "SUCCESS") {
|
||||
for (let [index, step] of steps.entries()) {
|
||||
// Ignore previous steps and continue at step that was failed
|
||||
if (failedAt && index + 1 < failedAt) {
|
||||
continue
|
||||
}
|
||||
const spinner = log.spinner(log.withBrand(`Running ${step.name}...`)).start()
|
||||
try {
|
||||
await step.action(index)
|
||||
if (collectedErrors.filter((e) => e.step === index).length) {
|
||||
// Soft stored error
|
||||
spinner.fail(`${step.name}`)
|
||||
} else {
|
||||
spinner.succeed(`Successfully ran ${step.name}`)
|
||||
}
|
||||
} catch (err) {
|
||||
// Hard exit error
|
||||
const error = err as {code: string} | string
|
||||
spinner.fail(`${step.name}`)
|
||||
log.error(error as string)
|
||||
|
||||
if (error && typeof error === "object" && error.code === "BABEL_PARSE_ERROR") {
|
||||
log.error(
|
||||
log.withBrand(
|
||||
"Don't panic, go to the file with the error & manually fix it. Then run the codemod again. It will continue where it left off.",
|
||||
),
|
||||
)
|
||||
} else if (!(err instanceof ExpectedError)) {
|
||||
log.error(
|
||||
log.withBrand(
|
||||
"This is an unexpected error. Please ask for help in the discord #general-help channel. https://discord.blitzjs.com",
|
||||
),
|
||||
)
|
||||
}
|
||||
failedAt = index + 1
|
||||
fs.writeJsonSync(".migration.json", {
|
||||
failedAt,
|
||||
})
|
||||
process.exit(1)
|
||||
}
|
||||
}
|
||||
if (collectedErrors.length) {
|
||||
for (const error of collectedErrors) {
|
||||
log.error(`⚠️ ${error.message}`)
|
||||
}
|
||||
}
|
||||
fs.writeJsonSync(".migration.json", {
|
||||
failedAt: "SUCCESS",
|
||||
})
|
||||
} else {
|
||||
if (failedAt === "SUCCESS") {
|
||||
log.withBrand("Migration already successful")
|
||||
process.exit(0)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export {securePasswordBreakingChange}
|
||||
@@ -1,29 +0,0 @@
|
||||
module.exports = {
|
||||
extends: ["eslint-config-next", "prettier"],
|
||||
ignorePatterns: ["*.d.ts"],
|
||||
settings: {
|
||||
next: {
|
||||
rootDir: ["./apps/*/", "./packages/*/"],
|
||||
},
|
||||
},
|
||||
rules: {
|
||||
"@next/next/no-html-link-for-pages": "off",
|
||||
},
|
||||
overrides: [
|
||||
{
|
||||
files: ["**/*.ts?(x)"],
|
||||
plugins: ["@typescript-eslint"],
|
||||
parserOptions: {
|
||||
project: "./tsconfig.json",
|
||||
},
|
||||
rules: {
|
||||
"@typescript-eslint/no-floating-promises": "error",
|
||||
"no-use-before-define": "off",
|
||||
"@typescript-eslint/no-use-before-define": ["off"],
|
||||
"no-redeclare": "off",
|
||||
"@typescript-eslint/no-redeclare": ["error"],
|
||||
"react/display-name": "off",
|
||||
},
|
||||
},
|
||||
],
|
||||
}
|
||||
@@ -5,9 +5,7 @@
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@typescript-eslint/eslint-plugin": "5.42.1",
|
||||
"@typescript-eslint/parser": "5.9.1",
|
||||
"eslint-config-next": "12.3.1",
|
||||
"eslint-config-prettier": "8.5.0"
|
||||
"@typescript-eslint/parser": "5.9.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"typescript": "^4.8.4"
|
||||
|
||||
13
packages/eslint-config-blitz-next/package.json
Normal file
13
packages/eslint-config-blitz-next/package.json
Normal file
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"name": "eslint-config-blitz-next",
|
||||
"version": "2.0.0-beta.23",
|
||||
"main": "index.js",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"eslint-config-next": "latest",
|
||||
"eslint-config-prettier": "^8.3.0"
|
||||
},
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
}
|
||||
}
|
||||
@@ -1 +1,6 @@
|
||||
module.exports = require("@blitzjs/config/eslint")
|
||||
module.exports = {
|
||||
extends: "blitz-next",
|
||||
rules: {
|
||||
// enable additional rules
|
||||
},
|
||||
}
|
||||
|
||||
@@ -70,6 +70,7 @@
|
||||
"babylon": "6.18.0",
|
||||
"debug": "4.3.3",
|
||||
"eslint": "8.27.0",
|
||||
"eslint-config-blitz-next": "workspace:2.0.0-beta.23",
|
||||
"react": "18.2.0",
|
||||
"typescript": "^4.8.4",
|
||||
"unbuild": "0.6.9",
|
||||
|
||||
@@ -1 +1,7 @@
|
||||
module.exports = require("@blitzjs/next/eslint")
|
||||
module.exports = {
|
||||
"extends": "blitz-next",
|
||||
"rules": {
|
||||
// enable additional rules
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,10 +25,10 @@
|
||||
"@blitzjs/auth": "latest",
|
||||
"@blitzjs/next": "latest",
|
||||
"@blitzjs/rpc": "latest",
|
||||
"@prisma/client": "4.6.0",
|
||||
"@prisma/client": "4.6.1",
|
||||
"blitz": "latest",
|
||||
"next": "13.1",
|
||||
"prisma": "4.6.0",
|
||||
"prisma": "4.6.1",
|
||||
"react": "18.2.0",
|
||||
"react-dom": "18.2.0",
|
||||
"secure-password": "4.0.0",
|
||||
|
||||
@@ -25,10 +25,10 @@
|
||||
"@blitzjs/auth": "latest",
|
||||
"@blitzjs/next": "latest",
|
||||
"@blitzjs/rpc": "latest",
|
||||
"@prisma/client": "4.6.0",
|
||||
"@prisma/client": "4.6.1",
|
||||
"blitz": "latest",
|
||||
"next": "13.1",
|
||||
"prisma": "4.6.0",
|
||||
"prisma": "4.6.1",
|
||||
"react": "18.2.0",
|
||||
"react-dom": "18.2.0",
|
||||
"secure-password": "4.0.0",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { NotFoundError, AuthenticationError } from 'blitz'
|
||||
import { resolver } from '@blitzjs/rpc'
|
||||
import { SecurePassword } from '@blitzjs/auth'
|
||||
import { SecurePassword } from "@blitzjs/auth/secure-password"
|
||||
import db from 'db'
|
||||
import { authenticateUser } from './login'
|
||||
import { ChangePassword } from '../validations'
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { SecurePassword } from "@blitzjs/auth"
|
||||
import { SecurePassword } from "@blitzjs/auth/secure-password"
|
||||
import { resolver } from "@blitzjs/rpc"
|
||||
import { AuthenticationError } from "blitz"
|
||||
import db from "db"
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
import { vi, describe, it, beforeEach, expect } from "vitest"
|
||||
import resetPassword from "./resetPassword"
|
||||
import db from "db"
|
||||
import { SecurePassword, hash256 } from "@blitzjs/auth"
|
||||
import { hash256 } from "@blitzjs/auth"
|
||||
import { SecurePassword } from "@blitzjs/auth/secure-password"
|
||||
|
||||
beforeEach(async () => {
|
||||
await db.$reset()
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { SecurePassword, hash256 } from "@blitzjs/auth"
|
||||
import { hash256 } from "@blitzjs/auth"
|
||||
import { SecurePassword } from "@blitzjs/auth/secure-password"
|
||||
import { resolver } from "@blitzjs/rpc"
|
||||
import db from "db"
|
||||
import { ResetPassword } from "../validations"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { SecurePassword } from "@blitzjs/auth"
|
||||
import { SecurePassword } from "@blitzjs/auth/secure-password"
|
||||
import { resolver } from "@blitzjs/rpc"
|
||||
import db from "db"
|
||||
import { Role } from "types"
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import { useEffect, useState } from "react"
|
||||
import Layout from "src/core/layouts/Layout"
|
||||
import { LabeledTextField } from "src/core/components/LabeledTextField"
|
||||
import { Form, FORM_ERROR } from "src/core/components/Form"
|
||||
@@ -8,6 +7,7 @@ import { BlitzPage, Routes } from "@blitzjs/next"
|
||||
import { useRouter } from "next/router"
|
||||
import { useMutation } from "@blitzjs/rpc"
|
||||
import Link from "next/link"
|
||||
import { assert } from "blitz"
|
||||
|
||||
const ResetPasswordPage: BlitzPage = () => {
|
||||
const router = useRouter()
|
||||
@@ -36,6 +36,7 @@ const ResetPasswordPage: BlitzPage = () => {
|
||||
}}
|
||||
onSubmit={async (values) => {
|
||||
try {
|
||||
assert(token, "token is required.")
|
||||
await resetPasswordMutation({ ...values, token })
|
||||
} catch (error: any) {
|
||||
if (error.name === "ResetPasswordError") {
|
||||
|
||||
@@ -1 +1,7 @@
|
||||
module.exports = require("@blitzjs/next/eslint")
|
||||
module.exports = {
|
||||
"extends": "blitz-next",
|
||||
"rules": {
|
||||
// enable additional rules
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1 +1,6 @@
|
||||
module.exports = require("@blitzjs/config/eslint")
|
||||
module.exports = {
|
||||
extends: "blitz-next",
|
||||
rules: {
|
||||
// enable additional rules
|
||||
},
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
"@blitzjs/config": "2.0.0-beta.23",
|
||||
"@types/react": "18.0.25",
|
||||
"@types/react-dom": "17.0.14",
|
||||
"eslint-config-blitz-next": "workspace:2.0.0-beta.23",
|
||||
"react": "18.2.0",
|
||||
"typescript": "^4.8.4",
|
||||
"unbuild": "0.7.6",
|
||||
|
||||
540
pnpm-lock.yaml
generated
540
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user