Skip to content

Commit 68d0bbf

Browse files
committed
v2.0.8
- update README
1 parent c6a3f5a commit 68d0bbf

File tree

3 files changed

+20
-20
lines changed

3 files changed

+20
-20
lines changed

README.md

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,9 @@ yarn add @bepalo/jwt
6363
```ts
6464
Import directly using the URL:
6565

66-
import { Time } from "npm:@bepalo/jwt";
66+
import { JWT } from "npm:@bepalo/jwt";
6767
// or
68-
import { Time } from "jsr:@bepalo/jwt";
68+
import { JWT } from "jsr:@bepalo/jwt";
6969
```
7070

7171
## 🚀 Quick Start
@@ -75,20 +75,20 @@ import { Time } from "jsr:@bepalo/jwt";
7575
```ts
7676
import { JWT } from "@bepalo/jwt";
7777

78-
// 🏁 1. Generate a key
78+
// 1. Generate a key
7979
const secret = JWT.genHmac("HS256");
8080

81-
// 🏁 2. Store the generated key somewhere safe like in a .env file
81+
// 2. Store the generated key somewhere safe like in a .env file
8282
console.log(secret);
8383

84-
// 🏁 3. Load that key from where it was stored
84+
// 3. Load that key from where it was stored
8585
const signKey = process.env.SECRET;
8686
const verifyKey = process.env.SECRET;
8787

88-
// 🏁 4. Create a JWT instance for signing
88+
// 4. Create a JWT instance for signing
8989
const jwtSign = JWT.createSymmetric(signKey, "HS256");
9090

91-
// 🏁 5. Sign a payload
91+
// 5. Sign a payload
9292
const token = jwtSign.signSync({
9393
userId: 123,
9494
role: "admin",
@@ -99,16 +99,16 @@ const token = jwtSign.signSync({
9999
// ...
100100
});
101101

102-
// 🏁 6. Create another JWT instance for verifying. *optional*
102+
// 6. Create another JWT instance for verifying. *optional*
103103
const jwtVerify = JWT.createSymmetric(verifyKey, "HS256");
104104

105-
// 🏁 7. Verify and decode the token
105+
// 7. Verify and decode the token
106106
const { valid, payload, error } = jwtVerify.verifySync(token, {
107107
jti: "tid-1234",
108108
nbfLeeway: JWT.for(5).Seconds
109109
});
110110

111-
// 🏁 8. Deal with errors or use the payload
111+
// 8. Deal with errors or use the payload
112112
console.log(valid); // true
113113
console.log(payload); // { userId: 123, role: "admin", ... }
114114
console.log(error); // undefined
@@ -119,22 +119,22 @@ console.log(error); // undefined
119119
```ts
120120
import { JWT } from "@bepalo/jwt";
121121

122-
// 🏁 1. Generate a key
122+
// 1. Generate a key
123123
const key = JWT.genKey("ES256");
124124

125-
// 🏁 2. Store the generated key somewhere safe like in a .env file
125+
// 2. Store the generated key somewhere safe like in a .env file
126126
const { alg, publicKey, privateKey } = key;
127127
console.log(JSON.stringify({ alg, publicKey }));
128128
console.log(JSON.stringify({ alg, privateKey }));
129129

130-
// 🏁 3. Load that key from where it was stored
130+
// 3. Load that key from where it was stored
131131
const signKey = JSON.parse(process.env.PRIVATE_KEY ?? "null");
132132
const verifyKey = JSON.parse(process.env.PUBLIC_KEY ?? "null");
133133

134-
// 🏁 4. Create a JWT instance for signing
134+
// 4. Create a JWT instance for signing
135135
const jwtSign = JWT.create(signKey);
136136

137-
// 🏁 5. Sign a payload
137+
// 5. Sign a payload
138138
const token = jwtSign.signSync({
139139
userId: 123,
140140
role: "admin",
@@ -145,16 +145,16 @@ const token = jwtSign.signSync({
145145
// ...
146146
});
147147

148-
// 🏁 6. Create a JWT instance for verifying
148+
// 6. Create a JWT instance for verifying
149149
const jwtVerify = JWT.create(verifyKey);
150150

151-
// 🏁 7. Verify and decode the token
151+
// 7. Verify and decode the token
152152
const { valid, payload, error } = jwtVerify.verifySync(token, {
153153
jti: "tid-1234",
154154
nbfLeeway: JWT.for(5).Seconds
155155
});
156156

157-
// 🏁 8. Deal with errors or use the payload
157+
// 8. Deal with errors or use the payload
158158
console.log(valid); // true
159159
console.log(payload); // { userId: 123, role: "admin", ... }
160160
console.log(error); // undefined

deno.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@bepalo/jwt",
3-
"version": "2.0.7",
3+
"version": "2.0.8",
44
"exports": {
55
"./mod.ts": "./mod.ts"
66
},

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@bepalo/jwt",
3-
"version": "2.0.7",
3+
"version": "2.0.8",
44
"description": "A secure and tested json-web-token class-based utility library for generating keys, signing, verifying, and decoding JWT payloads for use with your high-security demanding projects.",
55
"author": "Natnael Eshetu",
66
"license": "MIT",

0 commit comments

Comments
 (0)