@nitrotool/jwt 0.0.8 → 0.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -3
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -6,14 +6,22 @@ Lightweight JWT utilities for Nitro/UnJS environments with optional h3 helpers.
|
|
|
6
6
|
- Helpers that read `jwtSecret` from your Nitro runtime config
|
|
7
7
|
- h3 utilities to extract tokens from requests and enforce authentication
|
|
8
8
|
|
|
9
|
+
Learn more about JWT and how it works here:
|
|
10
|
+
- [What is a JWT?](https://www.jwt.io/introduction#what-is-json-web-token)
|
|
11
|
+
- [JWT.io](https://jwt.io/)
|
|
12
|
+
|
|
9
13
|
## Installation
|
|
10
14
|
|
|
15
|
+
```bash
|
|
16
|
+
pnpm install @nitrotool/jwt
|
|
17
|
+
```
|
|
18
|
+
|
|
11
19
|
```bash
|
|
12
20
|
npm install @nitrotool/jwt
|
|
13
21
|
```
|
|
14
22
|
|
|
15
23
|
Peer dependency:
|
|
16
|
-
- `h3` is required
|
|
24
|
+
- `h3` is required.
|
|
17
25
|
|
|
18
26
|
## Importing
|
|
19
27
|
|
|
@@ -24,7 +32,7 @@ You can import from the main entry or subpath exports:
|
|
|
24
32
|
import { encodeJwt, verifyJwt, decodeJwt } from '@nitrotool/jwt';
|
|
25
33
|
|
|
26
34
|
// Subpath (JWT-only)
|
|
27
|
-
import { encodeJwtRaw, verifyJwtRaw, decodeJwtRaw } from '@nitrotool/jwt/
|
|
35
|
+
import { encodeJwtRaw, verifyJwtRaw, decodeJwtRaw } from '@nitrotool/jwt/core';
|
|
28
36
|
|
|
29
37
|
// Subpath (h3 helpers)
|
|
30
38
|
import { extractApiToken, requireApiToken } from '@nitrotool/jwt/h3';
|
|
@@ -167,7 +175,7 @@ Types:
|
|
|
167
175
|
- `extractBearerToken(event): string | undefined`
|
|
168
176
|
- Reads `Authorization` header and returns the token without `Bearer `.
|
|
169
177
|
|
|
170
|
-
- `extractQueryToken(event): string | undefined`
|
|
178
|
+
- `extractQueryToken(event, key = 'token'): string | undefined`
|
|
171
179
|
- Reads `token` from the query string.
|
|
172
180
|
|
|
173
181
|
- `extractApiToken(event): string | undefined`
|
package/package.json
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nitrotool/jwt",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.9",
|
|
4
4
|
"main": "dist/index.mjs",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
7
7
|
".": "./dist/index.mjs",
|
|
8
|
-
"./
|
|
8
|
+
"./core": "./dist/jwt.mjs",
|
|
9
9
|
"./h3": "./dist/h3.mjs"
|
|
10
10
|
},
|
|
11
11
|
"types": "./dist/index.d.ts",
|
|
12
12
|
"dependencies": {
|
|
13
13
|
"@tsndr/cloudflare-worker-jwt": "^3.2.0",
|
|
14
|
-
"@nitrotool/errors": "0.0.
|
|
14
|
+
"@nitrotool/errors": "0.0.9"
|
|
15
15
|
},
|
|
16
16
|
"peerDependencies": {
|
|
17
17
|
"h3": "^1.15.3"
|