jwtmoshiur 1.1.0 → 1.1.1
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/package.json +1 -1
- package/readme.md +28 -27
package/package.json
CHANGED
package/readme.md
CHANGED
|
@@ -9,16 +9,16 @@ A lightweight, zero-configuration npm package that automatically sets up JWT aut
|
|
|
9
9
|
|
|
10
10
|
## ✨ Features
|
|
11
11
|
|
|
12
|
-
-
|
|
13
|
-
-
|
|
14
|
-
-
|
|
15
|
-
-
|
|
16
|
-
-
|
|
17
|
-
-
|
|
18
|
-
-
|
|
19
|
-
-
|
|
12
|
+
- **Zero Configuration** - Automatic setup on installation
|
|
13
|
+
- **Auto Project Setup** - Generates `.env` and utility files
|
|
14
|
+
- **Generate Tokens** - Simple, intuitive token creation
|
|
15
|
+
- **Verify Tokens** - Built-in token validation
|
|
16
|
+
- **Secure** - Uses industry-standard `jsonwebtoken` library
|
|
17
|
+
- **Lightweight** - Minimal dependencies
|
|
18
|
+
- **TypeScript Ready** - Full TypeScript support
|
|
19
|
+
- **Easy Integration** - Works with any Node.js project
|
|
20
20
|
|
|
21
|
-
##
|
|
21
|
+
## Installation
|
|
22
22
|
|
|
23
23
|
```bash
|
|
24
24
|
npm install jwtmoshiur
|
|
@@ -29,12 +29,12 @@ npx jwtmoshiur
|
|
|
29
29
|
```
|
|
30
30
|
|
|
31
31
|
That's it! The package automatically:
|
|
32
|
-
-
|
|
33
|
-
-
|
|
34
|
-
-
|
|
35
|
-
-
|
|
32
|
+
- Creates a `.env` file with secure JWT configuration
|
|
33
|
+
- Generates `utils/generateToken.js` (or `.ts` for TypeScript projects)
|
|
34
|
+
- Generates `utils/verifyToken.js` (or `.ts`)
|
|
35
|
+
- Installs all required dependencies
|
|
36
36
|
|
|
37
|
-
##
|
|
37
|
+
## Quick Start
|
|
38
38
|
|
|
39
39
|
### 1. Generate a Token
|
|
40
40
|
|
|
@@ -65,7 +65,7 @@ try {
|
|
|
65
65
|
}
|
|
66
66
|
```
|
|
67
67
|
|
|
68
|
-
##
|
|
68
|
+
## Usage Examples
|
|
69
69
|
|
|
70
70
|
### Express.js Authentication Middleware
|
|
71
71
|
|
|
@@ -148,7 +148,7 @@ const shortToken = generateToken(
|
|
|
148
148
|
// Options: 1h, 7d, 30d, etc.
|
|
149
149
|
```
|
|
150
150
|
|
|
151
|
-
##
|
|
151
|
+
## Configuration
|
|
152
152
|
|
|
153
153
|
Edit your `.env` file to customize JWT settings:
|
|
154
154
|
|
|
@@ -165,9 +165,9 @@ JWT_EXPIRY=24h
|
|
|
165
165
|
| `JWT_SECRET` | Generated | Secret key for signing tokens (change this!) |
|
|
166
166
|
| `JWT_EXPIRY` | `24h` | Token expiration time (`1h`, `7d`, `30d`, etc.) |
|
|
167
167
|
|
|
168
|
-
|
|
168
|
+
** Important:** Always change `JWT_SECRET` to a strong, unique value in production!
|
|
169
169
|
|
|
170
|
-
##
|
|
170
|
+
## API Reference
|
|
171
171
|
|
|
172
172
|
### `generateToken(payload: object): string`
|
|
173
173
|
|
|
@@ -208,7 +208,7 @@ try {
|
|
|
208
208
|
}
|
|
209
209
|
```
|
|
210
210
|
|
|
211
|
-
##
|
|
211
|
+
## Manual Setup
|
|
212
212
|
|
|
213
213
|
If you need to re-run the setup process:
|
|
214
214
|
|
|
@@ -218,7 +218,7 @@ npx jwtmoshiur
|
|
|
218
218
|
|
|
219
219
|
This will regenerate the `.env` file and utility files if they don't exist.
|
|
220
220
|
|
|
221
|
-
##
|
|
221
|
+
## Project Structure
|
|
222
222
|
|
|
223
223
|
After installation, your project will have:
|
|
224
224
|
|
|
@@ -233,7 +233,7 @@ your-project/
|
|
|
233
233
|
└── package.json
|
|
234
234
|
```
|
|
235
235
|
|
|
236
|
-
##
|
|
236
|
+
## Security Best Practices
|
|
237
237
|
|
|
238
238
|
1. **Never commit `.env` to version control**
|
|
239
239
|
```bash
|
|
@@ -284,29 +284,30 @@ npm install jwtmoshiur@latest
|
|
|
284
284
|
### Issue: `.env` not created
|
|
285
285
|
**Solution:** Run `npx jwtmoshiur` to manually trigger setup
|
|
286
286
|
|
|
287
|
-
##
|
|
287
|
+
## Requirements
|
|
288
288
|
|
|
289
289
|
- Node.js >= 14.0.0
|
|
290
290
|
- npm >= 6.0.0
|
|
291
291
|
|
|
292
|
-
##
|
|
292
|
+
## Dependencies
|
|
293
293
|
|
|
294
294
|
- `jsonwebtoken` - JWT signing and verification
|
|
295
295
|
- `dotenv` - Environment variable management
|
|
296
296
|
|
|
297
|
-
##
|
|
297
|
+
## License
|
|
298
298
|
|
|
299
299
|
MIT License - see LICENSE file for details
|
|
300
300
|
|
|
301
|
-
##
|
|
301
|
+
## Author
|
|
302
302
|
|
|
303
303
|
Created by **Moshiur Rahman Deap**
|
|
304
|
+
Portfolio - (Moshiur Rahman Deap)[https://moshiurrahman.online]
|
|
304
305
|
|
|
305
|
-
##
|
|
306
|
+
## Contributing
|
|
306
307
|
|
|
307
308
|
Contributions are welcome! Feel free to submit issues and pull requests.
|
|
308
309
|
|
|
309
|
-
##
|
|
310
|
+
## Support
|
|
310
311
|
|
|
311
312
|
If you have any questions or issues, please open an issue on GitHub or contact the maintainer.
|
|
312
313
|
|