Skip to content

Commit 31a85c9

Browse files
committed
🔧 fix: set minimum elysia to 0.7.20
1 parent 62d3e0f commit 31a85c9

File tree

5 files changed

+75
-67
lines changed

5 files changed

+75
-67
lines changed

CHANGELOG.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
1-
# Changelog
1+
# 0.7.1 - 15 Dec 2023
2+
- Minimum support for TypeScript to >= 5.0
3+
- Minimum support for Elysia >= 0.7.20
4+
5+
# 0.7.0 - 20 Sep 2023
6+
- Add support for Elysia 0.7
7+
8+
# 0.7.0-beta.0 - 18 Sep 2023
9+
- Add support for Elysia 0.7
210

311
## 0.6.4 - 11 Sep 2023
412
-[#11](https://github.com/elysiajs/elysia-jwt/pull/11) Remove unused imports

bun.lockb

2.51 KB
Binary file not shown.

example/index.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import { Elysia, t } from 'elysia'
2-
import { cookie } from '@elysiajs/cookie'
32
import { jwt } from '../src'
43

54
const app = new Elysia()
65
.use(
76
jwt({
7+
name: 'jwt2',
88
secret: 'aawdaowdoj',
99
sub: 'auth',
1010
iss: 'saltyaom.com',
@@ -14,17 +14,17 @@ const app = new Elysia()
1414
})
1515
})
1616
)
17-
.use(cookie())
18-
.get('/sign/:name', async ({ jwt, cookie, setCookie, params }) => {
19-
setCookie('auth', await jwt.sign(params), {
17+
.get('/sign/:name', async ({ jwt2, cookie: { auth }, params }) => {
18+
auth.set({
19+
value: await jwt2.sign(params),
2020
httpOnly: true,
2121
maxAge: 7 * 86400
2222
})
2323

24-
return `Sign in as ${cookie.auth}`
24+
return `Sign in as ${auth.value}`
2525
})
26-
.get('/profile', async ({ jwt, set, cookie: { auth } }) => {
27-
const profile = await jwt.verify(auth)
26+
.get('/profile', async ({ jwt2, set, cookie: { auth } }) => {
27+
const profile = await jwt2.verify(auth.value)
2828

2929
if (!profile) {
3030
set.status = 401

package.json

Lines changed: 55 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,56 @@
11
{
2-
"name": "@elysiajs/jwt",
3-
"description": "Plugin for Elysia for using JWT Authentication",
4-
"version": "0.6.4",
5-
"author": {
6-
"name": "saltyAom",
7-
"url": "https://github.com/SaltyAom",
8-
"email": "saltyaom@gmail.com"
9-
},
10-
"repository": {
11-
"type": "git",
12-
"url": "https://github.com/elysiajs/elysia-jwt"
13-
},
14-
"main": "./dist/index.js",
15-
"exports": {
16-
"bun": "./dist/index.js",
17-
"node": "./dist/cjs/index.js",
18-
"require": "./dist/cjs/index.js",
19-
"import": "./dist/index.js",
20-
"default": "./dist/index.js"
21-
},
22-
"types": "./dist/index.d.ts",
23-
"bugs": "https://github.com/elysiajs/elysia-jwt/issues",
24-
"homepage": "https://github.com/elysiajs/elysia-jwt",
25-
"keywords": [
26-
"elysia",
27-
"jwt",
28-
"auth",
29-
"authentication"
30-
],
31-
"license": "MIT",
32-
"scripts": {
33-
"dev": "bun run --hot example/index.ts",
34-
"test": "bun test && npm run test:node",
35-
"test:node": "npm install --prefix ./test/node/cjs/ && npm install --prefix ./test/node/esm/ && node ./test/node/cjs/index.js && node ./test/node/esm/index.js",
36-
"build": "rimraf dist && tsc --project tsconfig.esm.json && tsc --project tsconfig.cjs.json",
37-
"release": "npm run build && npm run test && npm publish --access public"
38-
},
39-
"dependencies": {
40-
"jose": "^4.14.4"
41-
},
42-
"devDependencies": {
43-
"@elysiajs/cookie": "^0.3.0",
44-
"@sinclair/typebox": "^0.30.4",
45-
"@types/node": "^20.1.4",
46-
"@typescript-eslint/eslint-plugin": "^6.6.0",
47-
"@typescript-eslint/parser": "^6.6.0",
48-
"bun-types": "^0.5.8",
49-
"elysia": "0.6.6",
50-
"eslint": "^8.40.0",
51-
"rimraf": "4.3",
52-
"typescript": "^5.1.6"
53-
},
54-
"peerDependencies": {
55-
"elysia": ">= 0.6.0"
56-
}
57-
}
2+
"name": "@elysiajs/jwt",
3+
"description": "Plugin for Elysia for using JWT Authentication",
4+
"version": "0.7.1",
5+
"author": {
6+
"name": "saltyAom",
7+
"url": "https://github.com/SaltyAom",
8+
"email": "saltyaom@gmail.com"
9+
},
10+
"repository": {
11+
"type": "git",
12+
"url": "https://github.com/elysiajs/elysia-jwt"
13+
},
14+
"main": "./dist/index.js",
15+
"exports": {
16+
"bun": "./dist/index.js",
17+
"node": "./dist/cjs/index.js",
18+
"require": "./dist/cjs/index.js",
19+
"import": "./dist/index.js",
20+
"default": "./dist/index.js"
21+
},
22+
"types": "./dist/index.d.ts",
23+
"bugs": "https://github.com/elysiajs/elysia-jwt/issues",
24+
"homepage": "https://github.com/elysiajs/elysia-jwt",
25+
"keywords": [
26+
"elysia",
27+
"jwt",
28+
"auth",
29+
"authentication"
30+
],
31+
"license": "MIT",
32+
"scripts": {
33+
"dev": "bun run --hot example/index.ts",
34+
"test": "bun test && npm run test:node",
35+
"test:node": "npm install --prefix ./test/node/cjs/ && npm install --prefix ./test/node/esm/ && node ./test/node/cjs/index.js && node ./test/node/esm/index.js",
36+
"build": "rimraf dist && tsc --project tsconfig.esm.json && tsc --project tsconfig.cjs.json",
37+
"release": "npm run build && npm run test && npm publish --access public"
38+
},
39+
"dependencies": {
40+
"jose": "^4.14.4"
41+
},
42+
"devDependencies": {
43+
"@elysiajs/cookie": "^0.3.0",
44+
"@types/node": "^20.1.4",
45+
"@typescript-eslint/eslint-plugin": "^6.6.0",
46+
"@typescript-eslint/parser": "^6.6.0",
47+
"bun-types": "^0.5.8",
48+
"elysia": "0.7.30",
49+
"eslint": "^8.40.0",
50+
"rimraf": "4.3",
51+
"typescript": "^5.1.6"
52+
},
53+
"peerDependencies": {
54+
"elysia": ">= 0.7.20"
55+
}
56+
}

src/index.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,8 @@ export interface JWTOption<
7575
}
7676

7777
export const jwt = <
78-
Name extends string = 'jwt',
79-
Schema extends TSchema | undefined = undefined
78+
const Name extends string = 'jwt',
79+
const Schema extends TSchema | undefined = undefined
8080
>({
8181
name = 'jwt' as Name,
8282
secret,
@@ -151,7 +151,8 @@ JWTOption<Name, Schema>) => {
151151
verify: async (
152152
jwt?: string
153153
): Promise<
154-
| (UnwrapSchema<Schema, Record<string, string | number>> & JWTPayloadSpec)
154+
| (UnwrapSchema<Schema, Record<string, string | number>> &
155+
JWTPayloadSpec)
155156
| false
156157
> => {
157158
if (!jwt) return false

0 commit comments

Comments
 (0)