You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
> This diagram shows the complete JWT workflow from data input to output. The **Sign** process creates encrypted tokens and stores them in cache, while **Verify** operations check cache first for 1,600x performance boost. **Decode** extracts raw data without verification, and **Cache Management** ensures memory efficiency with LRU eviction and TTL expiration.
6
+
7
+
```mermaid
8
+
graph TD
9
+
A[User Data] --> B[Sign Request]
10
+
B --> C[Create Payload]
11
+
C --> D[Multi Algorithm Encryption]
12
+
D --> E[Generate Token]
13
+
E --> F[Store in Cache]
14
+
F --> G[Return Token]
15
+
16
+
H[Token Verification] --> I{Cache Hit?}
17
+
I -->|Yes| J[Return Cached Data]
18
+
I -->|No| K[Decrypt Token]
19
+
K --> L[Validate Integrity]
20
+
L --> M[Store in Cache]
21
+
M --> N[Return Decoded Data]
22
+
23
+
O[Token Decode] --> P[Extract Payload]
24
+
P --> Q[Return Raw Data]
25
+
26
+
R[Cache Management] --> S[LRU Eviction]
27
+
S --> T[TTL Expiration]
28
+
T --> U[Memory Limit 10K]
29
+
30
+
style A fill:#e1f5fe,color:#000
31
+
style G fill:#c8e6c9,color:#000
32
+
style J fill:#c8e6c9,color:#000
33
+
style N fill:#c8e6c9,color:#000
34
+
style Q fill:#c8e6c9,color:#000
35
+
style I fill:#fff9c4,color:#000
36
+
style F fill:#e8f5e8,color:#000
37
+
style M fill:#e8f5e8,color:#000
38
+
style R fill:#f3e5f5,color:#000
39
+
```
40
+
41
+
---
42
+
43
+
### 🔐 JWT Encoding Process
44
+
45
+
> This diagram details the token creation process with **multi-algorithm encryption**. Each token gets a **random IV** for uniqueness, **version-based AAD** for compatibility, and **authentication tags** for tamper detection. The **caching system** stores encrypted tokens for instant retrieval, providing massive performance improvements for repeated verifications.
46
+
47
+
```mermaid
48
+
graph TD
49
+
A[User Data] --> B[Create Payload]
50
+
B --> C[Add Timestamps & Version]
51
+
C --> D[JSON Stringify Payload]
52
+
D --> E[Generate Random IV]
53
+
E --> F[Multi Algorithm Encryption]
54
+
F --> G[Create Token Structure]
55
+
G --> H[Base64 Encode]
56
+
H --> I[Secure JWT Token]
57
+
I --> J[Store in Cache]
58
+
J --> K[LRU Eviction Check]
59
+
K --> L[TTL Expiration]
60
+
61
+
M[Secret Key] --> N[Key Preparation]
62
+
N --> F
63
+
O[Random Salt] --> N
64
+
65
+
P[Version] --> Q[Additional
66
+
Authenticated Data]
67
+
Q --> F
68
+
69
+
F --> R[Authentication Tag]
70
+
R --> G
71
+
72
+
S[Cache Hit?] --> T[Return Cached Data]
73
+
S --> U[Decrypt & Cache]
74
+
U --> V[Return Decrypted Data]
75
+
76
+
style A fill:#e1f5fe,color:#000
77
+
style I fill:#c8e6c9,color:#000
78
+
style F fill:#fff3e0,color:#000
79
+
style M fill:#fce4ec,color:#000
80
+
style J fill:#e8f5e8,color:#000
81
+
style S fill:#fff9c4,color:#000
82
+
```
83
+
84
+
---
85
+
86
+
### 🛡️ Security Layers
87
+
88
+
> This diagram illustrates the security-focused verification process. **Cache validation** provides the first security layer, preventing DoS attacks through performance optimization. **Decryption** uses the secret key and random IV, while **integrity checks** verify authentication tags. The **caching system** acts as both a performance and security feature, ensuring fast and secure token validation.
-`secret: string` - Secret key (8-255 chars, required for security)
174
164
-`expireIn: string` - Token expiration time (required for security)
175
165
-`version?: string` - Token version (default: '1.0.0')
@@ -218,122 +208,10 @@ try {
218
208
---
219
209
220
210
## 🏗️ Architecture
211
+
For detailed architecture diagrams and technical implementation details, see [ARCHITECTURE.md](ARCHITECTURE.md).
221
212
222
-
### 🔄 Complete Data Flow
223
-
224
-
> This diagram shows the complete JWT workflow from data input to output. The **Sign** process creates encrypted tokens and stores them in cache, while **Verify** operations check cache first for 1,600x performance boost. **Decode** extracts raw data without verification, and **Cache Management** ensures memory efficiency with LRU eviction and TTL expiration.
225
-
226
-
```mermaid
227
-
graph TD
228
-
A[User Data] --> B[Sign Request]
229
-
B --> C[Create Payload]
230
-
C --> D[Multi Algorithm Encryption]
231
-
D --> E[Generate Token]
232
-
E --> F[Store in Cache]
233
-
F --> G[Return Token]
234
-
235
-
H[Token Verification] --> I{Cache Hit?}
236
-
I -->|Yes| J[Return Cached Data]
237
-
I -->|No| K[Decrypt Token]
238
-
K --> L[Validate Integrity]
239
-
L --> M[Store in Cache]
240
-
M --> N[Return Decoded Data]
241
-
242
-
O[Token Decode] --> P[Extract Payload]
243
-
P --> Q[Return Raw Data]
244
-
245
-
R[Cache Management] --> S[LRU Eviction]
246
-
S --> T[TTL Expiration]
247
-
T --> U[Memory Limit 10K]
248
-
249
-
style A fill:#e1f5fe,color:#000
250
-
style G fill:#c8e6c9,color:#000
251
-
style J fill:#c8e6c9,color:#000
252
-
style N fill:#c8e6c9,color:#000
253
-
style Q fill:#c8e6c9,color:#000
254
-
style I fill:#fff9c4,color:#000
255
-
style F fill:#e8f5e8,color:#000
256
-
style M fill:#e8f5e8,color:#000
257
-
style R fill:#f3e5f5,color:#000
258
-
```
259
-
260
-
---
261
-
262
-
### 🔐 JWT Encoding Process
263
-
264
-
> This diagram details the token creation process with **multi-algorithm encryption**. Each token gets a **random IV** for uniqueness, **version-based AAD** for compatibility, and **authentication tags** for tamper detection. The **caching system** stores encrypted tokens for instant retrieval, providing massive performance improvements for repeated verifications.
265
-
266
-
```mermaid
267
-
graph TD
268
-
A[User Data] --> B[Create Payload]
269
-
B --> C[Add Timestamps & Version]
270
-
C --> D[JSON Stringify Payload]
271
-
D --> E[Generate Random IV]
272
-
E --> F[Multi Algorithm Encryption]
273
-
F --> G[Create Token Structure]
274
-
G --> H[Base64 Encode]
275
-
H --> I[Secure JWT Token]
276
-
I --> J[Store in Cache]
277
-
J --> K[LRU Eviction Check]
278
-
K --> L[TTL Expiration]
279
-
280
-
M[Secret Key] --> N[Key Preparation]
281
-
N --> F
282
-
O[Random Salt] --> N
283
-
284
-
P[Version] --> Q[Additional
285
-
Authenticated Data]
286
-
Q --> F
287
-
288
-
F --> R[Authentication Tag]
289
-
R --> G
290
-
291
-
S[Cache Hit?] --> T[Return Cached Data]
292
-
S --> U[Decrypt & Cache]
293
-
U --> V[Return Decrypted Data]
294
-
295
-
style A fill:#e1f5fe,color:#000
296
-
style I fill:#c8e6c9,color:#000
297
-
style F fill:#fff3e0,color:#000
298
-
style M fill:#fce4ec,color:#000
299
-
style J fill:#e8f5e8,color:#000
300
-
style S fill:#fff9c4,color:#000
301
-
```
302
-
303
-
---
304
-
305
-
### 🛡️ Security Layers
306
-
307
-
> This diagram illustrates the security-focused verification process. **Cache validation** provides the first security layer, preventing DoS attacks through performance optimization. **Decryption** uses the secret key and random IV, while **integrity checks** verify authentication tags. The **caching system** acts as both a performance and security feature, ensuring fast and secure token validation.
308
-
309
-
```mermaid
310
-
graph LR
311
-
A[Input Token] --> B[Cache Validation]
312
-
B --> C[Validation Layer]
313
-
C --> D[Decryption Layer]
314
-
D --> E[Integrity Check]
315
-
E --> F[Decoded Data]
316
-
317
-
B --> G[Cache Hit]
318
-
G --> F
319
-
320
-
H[Cache Miss] --> C
321
-
C --> I[Store in Cache]
322
-
I --> F
323
-
324
-
J[Secret Key] --> D
325
-
K[Random IV] --> D
326
-
L[Version AAD] --> D
327
-
M[Auth Tag] --> E
328
-
329
-
style B fill:#e8f5e8,color:#000
330
-
style C fill:#ffebee,color:#000
331
-
style D fill:#fff3e0,color:#000
332
-
style E fill:#f3e5f5,color:#000
333
-
style F fill:#e1f5fe,color:#000
334
-
style G fill:#c8e6c9,color:#000
335
-
style I fill:#fff9c4,color:#000
336
-
```
213
+
## ⚡ Performance
214
+
For detailed benchmark results and performance metrics, see [BENCHMARK.md](BENCHMARK.md).
0 commit comments