jwt-auths 1.0.0 → 1.0.2

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.
Files changed (2) hide show
  1. package/README.md +51 -1
  2. package/package.json +3 -2
package/README.md CHANGED
@@ -1 +1,51 @@
1
- #jwt-auth
1
+ # @brang/jwt-auth
2
+
3
+ A simple and secure JWT authentication library for Node.js, providing functions to create access tokens and refresh tokens.
4
+
5
+ ## 🚀 Features
6
+ - Generate access tokens with a secret key.
7
+ - Refresh tokens for extended authentication sessions.
8
+ - Secure and easy to use.
9
+
10
+ ## 📦 Installation
11
+ ```sh
12
+ npm install @brang/jwt-auth
13
+ ```
14
+
15
+ ## 🔧 Usage
16
+ ### Import the package
17
+ ```js
18
+ const jwtAuth = require('@brang/jwt-auth');
19
+ ```
20
+
21
+ ### Create an Access Token
22
+ ```js
23
+ const accessToken = jwtAuth.createAccessToken({ userId: 123 }, 'your-secret-key', '1h');
24
+ console.log(accessToken);
25
+ ```
26
+ **Parameters:**
27
+ - `payload` (Object) - User data to encode in the token.
28
+ - `secretKey` (String) - Secret key for signing the token.
29
+ - `expiresIn` (String) - Expiration time (e.g., `"1h"`, `"7d"`).
30
+
31
+ ### Refresh Token
32
+ ```js
33
+ const newAccessToken = jwtAuth.refreshToken(oldToken, 'your-secret-key', '1h');
34
+ console.log(newAccessToken);
35
+ ```
36
+ **Parameters:**
37
+ - `oldToken` (String) - Expired or near-expired token.
38
+ - `secretKey` (String) - Secret key used for verification.
39
+ - `expiresIn` (String) - Expiration time for the new token.
40
+
41
+ ## 🛡️ Security Best Practices
42
+ - Use strong secret keys and store them securely (e.g., environment variables).
43
+ - Set appropriate expiration times for tokens.
44
+ - Always verify tokens before processing requests.
45
+
46
+ ## 📜 License
47
+ MIT License © 2025 [Brang Tsawm Aung]
48
+
49
+ ## 🤝 Contributing
50
+ Pull requests and issues are welcome! 😊
51
+
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jwt-auths",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "description": "A fully functional JWT authentication library for securely generating, verifying, and managing JSON Web Tokens.",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
@@ -36,6 +36,7 @@
36
36
  "access": "public"
37
37
  },
38
38
  "dependencies": {
39
- "@types/jsonwebtoken": "^9.0.8"
39
+ "@types/jsonwebtoken": "^9.0.8",
40
+ "jsonwebtoken": "^9.0.2"
40
41
  }
41
42
  }