@nauth-toolkit/storage-redis 0.1.3
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/LICENSE +90 -0
- package/README.md +276 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -0
- package/dist/redis-client.interface.d.ts +22 -0
- package/dist/redis-client.interface.d.ts.map +1 -0
- package/dist/redis-client.interface.js +3 -0
- package/dist/redis-client.interface.js.map +1 -0
- package/dist/redis-storage.adapter.d.ts +34 -0
- package/dist/redis-storage.adapter.d.ts.map +1 -0
- package/dist/redis-storage.adapter.js +209 -0
- package/dist/redis-storage.adapter.js.map +1 -0
- package/package.json +47 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
NAUTH TOOLKIT EARLY ACCESS LICENSE
|
|
2
|
+
Version 1.0 (December 2025)
|
|
3
|
+
|
|
4
|
+
================================================================================
|
|
5
|
+
FUTURE OPEN SOURCE NOTICE
|
|
6
|
+
================================================================================
|
|
7
|
+
NAuth Toolkit will transition to an open-source license (MIT or Apache 2.0) for
|
|
8
|
+
core authentication features once the project reaches production readiness.
|
|
9
|
+
|
|
10
|
+
This Early Access License is temporary and designed to:
|
|
11
|
+
• Allow developers to build with nauth-toolkit during preview/beta
|
|
12
|
+
• Provide clear expectations during the pre-release phase
|
|
13
|
+
• Enable feedback and real-world testing before GA
|
|
14
|
+
|
|
15
|
+
We're committed to keeping core auth free and open source. Premium features
|
|
16
|
+
(enterprise SSO, advanced compliance, hosted options) will be offered separately
|
|
17
|
+
under fair commercial terms.
|
|
18
|
+
|
|
19
|
+
================================================================================
|
|
20
|
+
EARLY ACCESS LICENSE TERMS
|
|
21
|
+
================================================================================
|
|
22
|
+
|
|
23
|
+
1. Grant of Use
|
|
24
|
+
You are granted a free, non-exclusive, non-transferable license to:
|
|
25
|
+
- Install and use nauth-toolkit packages in development, testing, staging,
|
|
26
|
+
and production environments
|
|
27
|
+
- Modify the code for your own internal use
|
|
28
|
+
- Deploy applications using nauth-toolkit to serve your users
|
|
29
|
+
|
|
30
|
+
You may NOT:
|
|
31
|
+
- Redistribute NAuth Toolkit as a standalone product or service
|
|
32
|
+
- Sell, sublicense, or offer NAuth Toolkit as part of a competing auth
|
|
33
|
+
platform or toolkit
|
|
34
|
+
- Remove or alter copyright notices
|
|
35
|
+
|
|
36
|
+
2. No Fees During Early Access
|
|
37
|
+
There are no license fees, subscription costs, or usage charges during the
|
|
38
|
+
Early Access period. You may use nauth-toolkit freely for commercial and
|
|
39
|
+
non-commercial purposes within the terms of this license.
|
|
40
|
+
|
|
41
|
+
3. Production Use
|
|
42
|
+
Production use is permitted but comes with standard early-access caveats:
|
|
43
|
+
- Features and APIs may change between preview releases
|
|
44
|
+
- Support is community-based (GitHub issues/discussions)
|
|
45
|
+
- No SLA or guaranteed uptime (you run it on your infrastructure)
|
|
46
|
+
|
|
47
|
+
We recommend thorough testing and having rollback plans for critical systems.
|
|
48
|
+
|
|
49
|
+
4. Future Transition
|
|
50
|
+
When nauth-toolkit releases v1.0 GA:
|
|
51
|
+
- Core packages will adopt an open-source license (MIT or Apache 2.0)
|
|
52
|
+
- Your existing deployments will continue to work
|
|
53
|
+
- Premium features (if any) will be clearly documented with separate licensing
|
|
54
|
+
- No forced upgrades or surprise fees
|
|
55
|
+
|
|
56
|
+
5. Ownership
|
|
57
|
+
NAuth Toolkit is developed and maintained by Noorix Digital Solutions.
|
|
58
|
+
You retain full ownership of your applications and data.
|
|
59
|
+
|
|
60
|
+
6. Data and Privacy
|
|
61
|
+
NAuth Toolkit runs in YOUR infrastructure and database. You control all data.
|
|
62
|
+
You are responsible for compliance with applicable data protection laws.
|
|
63
|
+
|
|
64
|
+
7. Disclaimer of Warranty
|
|
65
|
+
THE SOFTWARE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
66
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
67
|
+
FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
|
|
68
|
+
|
|
69
|
+
8. Limitation of Liability
|
|
70
|
+
IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY INDIRECT, INCIDENTAL,
|
|
71
|
+
SPECIAL, CONSEQUENTIAL, OR EXEMPLARY DAMAGES, INCLUDING BUT NOT LIMITED TO LOSS
|
|
72
|
+
OF PROFITS, REVENUE, DATA, OR USE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
|
|
73
|
+
DAMAGES.
|
|
74
|
+
|
|
75
|
+
9. Termination
|
|
76
|
+
This license remains in effect until:
|
|
77
|
+
- You stop using nauth-toolkit, or
|
|
78
|
+
- The project transitions to open source (at which point the new license applies)
|
|
79
|
+
|
|
80
|
+
If you breach these terms, your license terminates and you must stop using the
|
|
81
|
+
software.
|
|
82
|
+
|
|
83
|
+
10. Contact and Support
|
|
84
|
+
- Documentation: https://nauth.dev
|
|
85
|
+
- Issues/Discussions: GitHub (when public repository launches)
|
|
86
|
+
- Commercial inquiries: Contact admin@noorix.com
|
|
87
|
+
|
|
88
|
+
================================================================================
|
|
89
|
+
Thank you for being an early adopter. Your feedback shapes the future of NAuth.
|
|
90
|
+
================================================================================
|
package/README.md
ADDED
|
@@ -0,0 +1,276 @@
|
|
|
1
|
+
# @nauth-toolkit/storage-redis
|
|
2
|
+
|
|
3
|
+
Redis storage adapter for nauth-toolkit using the `redis` package (node-redis).
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
`RedisStorageAdapter` implements the `StorageAdapter` interface using the `redis` package (node-redis). Supports both single-instance Redis and Redis Cluster for high-availability production deployments.
|
|
8
|
+
|
|
9
|
+
## Features
|
|
10
|
+
|
|
11
|
+
- ✅ **Uses node-redis** - Official Redis client for Node.js
|
|
12
|
+
- ✅ **Redis Cluster Support** - Production-ready high-availability deployments
|
|
13
|
+
- ✅ **Multi-server compatible** - Shared Redis instance/cluster across all servers
|
|
14
|
+
- ✅ **High performance** - Optimized for transient state management
|
|
15
|
+
- ✅ **Automatic key prefixing** - All keys prefixed with `nauth_` to avoid collisions
|
|
16
|
+
- ✅ **TTL support** - Native Redis EXPIRE for automatic expiration
|
|
17
|
+
- ✅ **Production-ready** - Automatic topology discovery, command routing, and failover
|
|
18
|
+
|
|
19
|
+
## Installation
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
yarn add @nauth-toolkit/storage-redis redis
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Usage
|
|
26
|
+
|
|
27
|
+
### With Factory Functions (Recommended)
|
|
28
|
+
|
|
29
|
+
```typescript
|
|
30
|
+
import { createRedisStorageAdapter, createRedisClusterAdapter } from '@nauth-toolkit/nestjs';
|
|
31
|
+
|
|
32
|
+
// Single-instance Redis
|
|
33
|
+
AuthModule.forRoot({
|
|
34
|
+
jwt: { ... },
|
|
35
|
+
storageAdapter: createRedisStorageAdapter(process.env.REDIS_URL),
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
// Redis Cluster (for high-availability production)
|
|
39
|
+
AuthModule.forRoot({
|
|
40
|
+
jwt: { ... },
|
|
41
|
+
storageAdapter: createRedisClusterAdapter([
|
|
42
|
+
{ url: 'redis://redis-node-1:6379' },
|
|
43
|
+
{ url: 'redis://redis-node-2:6379' },
|
|
44
|
+
{ url: 'redis://redis-node-3:6379' },
|
|
45
|
+
]),
|
|
46
|
+
});
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
### With Manual Client Creation
|
|
50
|
+
|
|
51
|
+
```typescript
|
|
52
|
+
import { createClient, createCluster } from 'redis';
|
|
53
|
+
import { RedisStorageAdapter } from '@nauth-toolkit/storage-redis';
|
|
54
|
+
|
|
55
|
+
// Single-instance Redis
|
|
56
|
+
const redisClient = createClient({
|
|
57
|
+
url: process.env.NAUTH_REDIS_URL || 'redis://localhost:6379',
|
|
58
|
+
});
|
|
59
|
+
await redisClient.connect();
|
|
60
|
+
|
|
61
|
+
AuthModule.forRoot({
|
|
62
|
+
jwt: { ... },
|
|
63
|
+
storageAdapter: new RedisStorageAdapter(redisClient),
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
// Redis Cluster
|
|
67
|
+
const clusterClient = createCluster({
|
|
68
|
+
rootNodes: [
|
|
69
|
+
{ url: 'redis://redis-node-1:6379' },
|
|
70
|
+
{ url: 'redis://redis-node-2:6379' },
|
|
71
|
+
{ url: 'redis://redis-node-3:6379' },
|
|
72
|
+
],
|
|
73
|
+
});
|
|
74
|
+
await clusterClient.connect();
|
|
75
|
+
|
|
76
|
+
AuthModule.forRoot({
|
|
77
|
+
jwt: { ... },
|
|
78
|
+
storageAdapter: new RedisStorageAdapter(clusterClient),
|
|
79
|
+
});
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
### URL Format Support
|
|
83
|
+
|
|
84
|
+
Supports authentication in URL format:
|
|
85
|
+
- `redis://localhost:6379` (no auth)
|
|
86
|
+
- `redis://:password@localhost:6379` (password only)
|
|
87
|
+
- `redis://username:password@localhost:6379` (username + password)
|
|
88
|
+
- `rediss://localhost:6379` (TLS/SSL, with optional auth)
|
|
89
|
+
|
|
90
|
+
### Complete Example with Factory Functions
|
|
91
|
+
|
|
92
|
+
```typescript
|
|
93
|
+
import { Module } from '@nestjs/common';
|
|
94
|
+
import { createRedisStorageAdapter } from '@nauth-toolkit/nestjs';
|
|
95
|
+
import { AuthModule } from '@nauth-toolkit/nestjs';
|
|
96
|
+
|
|
97
|
+
@Module({
|
|
98
|
+
imports: [
|
|
99
|
+
AuthModule.forRoot({
|
|
100
|
+
jwt: {
|
|
101
|
+
accessToken: {
|
|
102
|
+
secret: process.env.JWT_SECRET,
|
|
103
|
+
expiresIn: '15m',
|
|
104
|
+
},
|
|
105
|
+
refreshToken: {
|
|
106
|
+
secret: process.env.JWT_REFRESH_SECRET,
|
|
107
|
+
expiresIn: '7d',
|
|
108
|
+
},
|
|
109
|
+
},
|
|
110
|
+
storageAdapter: createRedisStorageAdapter(process.env.REDIS_URL),
|
|
111
|
+
}),
|
|
112
|
+
],
|
|
113
|
+
})
|
|
114
|
+
export class AppModule {}
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
### With Dragonfly
|
|
118
|
+
|
|
119
|
+
Dragonfly is Redis-protocol compatible, so it works with the same clients:
|
|
120
|
+
|
|
121
|
+
```typescript
|
|
122
|
+
import { createClient } from 'redis';
|
|
123
|
+
import { RedisStorageAdapter } from '@nauth-toolkit/storage-redis';
|
|
124
|
+
|
|
125
|
+
// Dragonfly uses same protocol as Redis
|
|
126
|
+
const dragonflyClient = createClient({
|
|
127
|
+
url: 'dragonfly://localhost:6379', // or your Dragonfly URL
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
await dragonflyClient.connect();
|
|
131
|
+
|
|
132
|
+
AuthModule.forRoot({
|
|
133
|
+
jwt: { ... },
|
|
134
|
+
storageAdapter: new RedisStorageAdapter(dragonflyClient),
|
|
135
|
+
});
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
## Key Prefixing
|
|
139
|
+
|
|
140
|
+
All keys are automatically prefixed with `nauth_` to avoid collisions with other application keys:
|
|
141
|
+
|
|
142
|
+
- `ratelimit:user:123` → `nauth_:ratelimit:user:123`
|
|
143
|
+
- `refresh-lock:token-hash` → `nauth_:refresh-lock:token-hash`
|
|
144
|
+
- `used-token:hash` → `nauth_:used-token:hash`
|
|
145
|
+
|
|
146
|
+
## Client Requirements
|
|
147
|
+
|
|
148
|
+
The adapter validates that your Redis client has the following methods:
|
|
149
|
+
|
|
150
|
+
- `get(key)` - Get value
|
|
151
|
+
- `set(key, value, options?)` - Set value (with optional `{ EX: seconds }`)
|
|
152
|
+
- `del(key)` - Delete key
|
|
153
|
+
- `incr(key)` - Increment counter
|
|
154
|
+
- `decr(key)` - Decrement counter
|
|
155
|
+
- `expire(key, seconds)` - Set expiration
|
|
156
|
+
- `exists(key)` - Check existence
|
|
157
|
+
- `ttl(key)` - Get time to live
|
|
158
|
+
- `hget(key, field)` - Hash get
|
|
159
|
+
- `hset(key, field, value)` - Hash set
|
|
160
|
+
- `hgetall(key)` - Hash get all
|
|
161
|
+
- `hdel(key, ...fields)` - Hash delete
|
|
162
|
+
- `lpush(key, value)` - List push
|
|
163
|
+
- `lrange(key, start, stop)` - List range
|
|
164
|
+
- `llen(key)` - List length
|
|
165
|
+
- `ping()` - Health check
|
|
166
|
+
|
|
167
|
+
The `redis` package (node-redis) satisfies these requirements.
|
|
168
|
+
|
|
169
|
+
## Error Handling
|
|
170
|
+
|
|
171
|
+
The adapter includes connection health checks:
|
|
172
|
+
|
|
173
|
+
```typescript
|
|
174
|
+
const adapter = new RedisStorageAdapter(redisClient);
|
|
175
|
+
|
|
176
|
+
// Health check
|
|
177
|
+
const healthy = await adapter.isHealthy(); // Uses PING command
|
|
178
|
+
|
|
179
|
+
// Initialize (performs health check)
|
|
180
|
+
await adapter.initialize();
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
## Comparison with Other Adapters
|
|
184
|
+
|
|
185
|
+
| Feature | MemoryStorageAdapter | DatabaseStorageAdapter | RedisStorageAdapter |
|
|
186
|
+
|---------|---------------------|------------------------|---------------------|
|
|
187
|
+
| Multi-server | ❌ | ✅ | ✅ |
|
|
188
|
+
| Persistence | ❌ | ✅ | ✅ (optional) |
|
|
189
|
+
| Performance | ⚡⚡⚡ | ⚡⚡ | ⚡⚡⚡ |
|
|
190
|
+
| External dependency | ❌ | ❌ | ✅ (Redis) |
|
|
191
|
+
| Setup complexity | 🟢 Low | 🟡 Medium | 🟡 Medium |
|
|
192
|
+
| Redis Cluster | N/A | N/A | ✅ (high-availability) |
|
|
193
|
+
|
|
194
|
+
## Production Considerations
|
|
195
|
+
|
|
196
|
+
### Connection Pooling
|
|
197
|
+
|
|
198
|
+
The adapter doesn't manage connection pooling - your Redis client does. Configure pooling in your client:
|
|
199
|
+
|
|
200
|
+
**node-redis:**
|
|
201
|
+
```typescript
|
|
202
|
+
const redisClient = createClient({
|
|
203
|
+
url: process.env.NAUTH_REDIS_URL || 'redis://localhost:6379',
|
|
204
|
+
socket: {
|
|
205
|
+
reconnectStrategy: (retries) => {
|
|
206
|
+
if (retries > 10) return new Error('Too many retries');
|
|
207
|
+
return Math.min(retries * 100, 3000);
|
|
208
|
+
},
|
|
209
|
+
},
|
|
210
|
+
});
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
**node-redis with reconnection:**
|
|
214
|
+
```typescript
|
|
215
|
+
const redisClient = createClient({
|
|
216
|
+
url: process.env.NAUTH_REDIS_URL || 'redis://localhost:6379',
|
|
217
|
+
socket: {
|
|
218
|
+
reconnectStrategy: (retries) => {
|
|
219
|
+
if (retries > 10) return new Error('Too many retries');
|
|
220
|
+
return Math.min(retries * 100, 3000);
|
|
221
|
+
},
|
|
222
|
+
},
|
|
223
|
+
});
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
### TLS/SSL
|
|
227
|
+
|
|
228
|
+
Configure TLS in your Redis client:
|
|
229
|
+
|
|
230
|
+
```typescript
|
|
231
|
+
// TLS/SSL with authentication in URL
|
|
232
|
+
const redisClient = createClient({
|
|
233
|
+
url: process.env.NAUTH_REDIS_URL, // e.g., 'rediss://:password@host:6380'
|
|
234
|
+
socket: {
|
|
235
|
+
tls: true,
|
|
236
|
+
rejectUnauthorized: false, // Set to true in production with proper certs
|
|
237
|
+
},
|
|
238
|
+
});
|
|
239
|
+
|
|
240
|
+
// Or use rediss:// protocol in URL (TLS automatically enabled)
|
|
241
|
+
const redisClient = createClient({
|
|
242
|
+
url: 'rediss://:password@localhost:6380', // rediss:// = TLS enabled
|
|
243
|
+
});
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
### High Availability
|
|
247
|
+
|
|
248
|
+
For production, use Redis Cluster for high-availability:
|
|
249
|
+
|
|
250
|
+
```typescript
|
|
251
|
+
import { createRedisClusterAdapter } from '@nauth-toolkit/nestjs';
|
|
252
|
+
|
|
253
|
+
AuthModule.forRoot({
|
|
254
|
+
jwt: { ... },
|
|
255
|
+
storageAdapter: createRedisClusterAdapter([
|
|
256
|
+
{ url: 'redis://redis-node-1:6379' },
|
|
257
|
+
{ url: 'redis://redis-node-2:6379' },
|
|
258
|
+
{ url: 'redis://redis-node-3:6379' },
|
|
259
|
+
]),
|
|
260
|
+
});
|
|
261
|
+
```
|
|
262
|
+
|
|
263
|
+
The cluster client automatically handles:
|
|
264
|
+
- Topology discovery
|
|
265
|
+
- Command routing based on key hash slots
|
|
266
|
+
- Node failures and redirects (MOVED/ASK errors)
|
|
267
|
+
- High availability and horizontal scaling
|
|
268
|
+
|
|
269
|
+
**Other Options:**
|
|
270
|
+
- **Redis Sentinel** - Automatic failover (use with single-instance Redis client)
|
|
271
|
+
- **Dragonfly** - Drop-in Redis replacement with better performance (works with same client)
|
|
272
|
+
|
|
273
|
+
## License
|
|
274
|
+
|
|
275
|
+
MIT
|
|
276
|
+
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAqBA,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAC9D,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RedisStorageAdapter = void 0;
|
|
4
|
+
var redis_storage_adapter_1 = require("./redis-storage.adapter");
|
|
5
|
+
Object.defineProperty(exports, "RedisStorageAdapter", { enumerable: true, get: function () { return redis_storage_adapter_1.RedisStorageAdapter; } });
|
|
6
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAqBA,iEAA8D;AAArD,4HAAA,mBAAmB,OAAA"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export interface RedisClientLike {
|
|
2
|
+
get(key: string): Promise<string | null>;
|
|
3
|
+
set(key: string, value: string, options?: {
|
|
4
|
+
EX?: number;
|
|
5
|
+
NX?: boolean;
|
|
6
|
+
}): Promise<string | void>;
|
|
7
|
+
del(key: string): Promise<number>;
|
|
8
|
+
incr(key: string): Promise<number>;
|
|
9
|
+
decr(key: string): Promise<number>;
|
|
10
|
+
expire(key: string, seconds: number): Promise<boolean | number>;
|
|
11
|
+
exists(key: string): Promise<number | boolean>;
|
|
12
|
+
ttl(key: string): Promise<number>;
|
|
13
|
+
hget(key: string, field: string): Promise<string | null>;
|
|
14
|
+
hset(key: string, field: string, value: string): Promise<number>;
|
|
15
|
+
hgetall(key: string): Promise<Record<string, string>>;
|
|
16
|
+
hdel(key: string, ...fields: string[]): Promise<number>;
|
|
17
|
+
lpush(key: string, value: string): Promise<number>;
|
|
18
|
+
lrange(key: string, start: number, stop: number): Promise<string[]>;
|
|
19
|
+
llen(key: string): Promise<number>;
|
|
20
|
+
ping(): Promise<string>;
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=redis-client.interface.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"redis-client.interface.d.ts","sourceRoot":"","sources":["../src/redis-client.interface.ts"],"names":[],"mappings":"AAYA,MAAM,WAAW,eAAe;IAI9B,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IAMzC,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;QAAE,EAAE,CAAC,EAAE,MAAM,CAAC;QAAC,EAAE,CAAC,EAAE,OAAO,CAAA;KAAE,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IAKjG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IAAI,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC;CACzB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"redis-client.interface.js","sourceRoot":"","sources":["../src/redis-client.interface.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { StorageAdapter, LoggerService } from '@nauth-toolkit/core';
|
|
2
|
+
export declare class RedisStorageAdapter implements StorageAdapter {
|
|
3
|
+
private readonly redisClient;
|
|
4
|
+
private logger?;
|
|
5
|
+
private readonly keyPrefix;
|
|
6
|
+
constructor(redisClient: unknown, logger?: LoggerService | undefined);
|
|
7
|
+
private validateClient;
|
|
8
|
+
setLogger(logger: LoggerService): void;
|
|
9
|
+
private getPrefixedKey;
|
|
10
|
+
initialize(): Promise<void>;
|
|
11
|
+
isHealthy(): Promise<boolean>;
|
|
12
|
+
get(key: string): Promise<string | null>;
|
|
13
|
+
set(key: string, value: string, ttlSeconds?: number, options?: {
|
|
14
|
+
nx?: boolean;
|
|
15
|
+
}): Promise<string | null>;
|
|
16
|
+
del(key: string): Promise<void>;
|
|
17
|
+
exists(key: string): Promise<boolean>;
|
|
18
|
+
incr(key: string, ttlSeconds?: number): Promise<number>;
|
|
19
|
+
decr(key: string): Promise<number>;
|
|
20
|
+
expire(key: string, ttl: number): Promise<void>;
|
|
21
|
+
ttl(key: string): Promise<number>;
|
|
22
|
+
hget(key: string, field: string): Promise<string | null>;
|
|
23
|
+
hset(key: string, field: string, value: string): Promise<void>;
|
|
24
|
+
hgetall(key: string): Promise<Record<string, string>>;
|
|
25
|
+
hdel(key: string, ...fields: string[]): Promise<number>;
|
|
26
|
+
lpush(key: string, value: string): Promise<void>;
|
|
27
|
+
lrange(key: string, start: number, stop: number): Promise<string[]>;
|
|
28
|
+
llen(key: string): Promise<number>;
|
|
29
|
+
keys(pattern: string): Promise<string[]>;
|
|
30
|
+
scan(cursor: number, pattern: string, count: number): Promise<[number, string[]]>;
|
|
31
|
+
cleanup(): Promise<void>;
|
|
32
|
+
disconnect(): Promise<void>;
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=redis-storage.adapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"redis-storage.adapter.d.ts","sourceRoot":"","sources":["../src/redis-storage.adapter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAiC,aAAa,EAAE,MAAM,qBAAqB,CAAC;AA6CnG,qBAAa,mBAAoB,YAAW,cAAc;IAWtD,OAAO,CAAC,QAAQ,CAAC,WAAW;IAC5B,OAAO,CAAC,MAAM,CAAC;IAXjB,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAY;gBAUnB,WAAW,EAAE,OAAO,EAC7B,MAAM,CAAC,EAAE,aAAa,YAAA;IAmBhC,OAAO,CAAC,cAAc;IA4CtB,SAAS,CAAC,MAAM,EAAE,aAAa,GAAG,IAAI;IAUtC,OAAO,CAAC,cAAc;IAWhB,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IA8C3B,SAAS,IAAI,OAAO,CAAC,OAAO,CAAC;IAuB7B,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IAcxC,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;QAAE,EAAE,CAAC,EAAE,OAAO,CAAA;KAAE,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IAiCxG,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAW/B,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAoBrC,IAAI,CAAC,GAAG,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAuBvD,IAAI,CAAC,GAAG,EAAE,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 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RedisStorageAdapter = void 0;
|
|
4
|
+
const core_1 = require("@nauth-toolkit/core");
|
|
5
|
+
class RedisStorageAdapter {
|
|
6
|
+
redisClient;
|
|
7
|
+
logger;
|
|
8
|
+
keyPrefix = 'nauth_';
|
|
9
|
+
constructor(redisClient, logger) {
|
|
10
|
+
this.redisClient = redisClient;
|
|
11
|
+
this.logger = logger;
|
|
12
|
+
}
|
|
13
|
+
validateClient(client) {
|
|
14
|
+
if (!client || typeof client !== 'object') {
|
|
15
|
+
throw new core_1.NAuthException(core_1.AuthErrorCode.VALIDATION_FAILED, 'Redis client must be an object instance');
|
|
16
|
+
}
|
|
17
|
+
const clientObj = client;
|
|
18
|
+
const hasSendCommand = typeof clientObj.sendCommand === 'function';
|
|
19
|
+
const hasPing = typeof clientObj.ping === 'function';
|
|
20
|
+
const hasGet = typeof clientObj.get === 'function';
|
|
21
|
+
if (!hasSendCommand && !hasPing && !hasGet) {
|
|
22
|
+
const hasConnect = typeof clientObj.connect === 'function';
|
|
23
|
+
const hasCommand = typeof clientObj.command === 'function';
|
|
24
|
+
if (!hasConnect && !hasCommand) {
|
|
25
|
+
throw new core_1.NAuthException(core_1.AuthErrorCode.VALIDATION_FAILED, 'Invalid Redis client. Expected a node-redis client instance. ' +
|
|
26
|
+
'Client should have methods like sendCommand, ping, get, or connect. ' +
|
|
27
|
+
`Received: ${clientObj.constructor?.name || typeof client}. ` +
|
|
28
|
+
'Use createClient from the "redis" package or createRedisStorageAdapter() factory function.');
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
setLogger(logger) {
|
|
33
|
+
this.logger = logger;
|
|
34
|
+
}
|
|
35
|
+
getPrefixedKey(key) {
|
|
36
|
+
return `${this.keyPrefix}${key}`;
|
|
37
|
+
}
|
|
38
|
+
async initialize() {
|
|
39
|
+
this.validateClient(this.redisClient);
|
|
40
|
+
try {
|
|
41
|
+
const client = this.redisClient;
|
|
42
|
+
if (client.connect && typeof client.connect === 'function') {
|
|
43
|
+
try {
|
|
44
|
+
if (this.logger?.debug) {
|
|
45
|
+
this.logger.debug('Connecting Redis client...');
|
|
46
|
+
}
|
|
47
|
+
await client.connect();
|
|
48
|
+
}
|
|
49
|
+
catch (connectError) {
|
|
50
|
+
const errorMsg = connectError instanceof Error ? connectError.message : String(connectError);
|
|
51
|
+
if (!errorMsg.includes('already') && !errorMsg.includes('connected')) {
|
|
52
|
+
throw connectError;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
const healthy = await this.isHealthy();
|
|
57
|
+
if (!healthy) {
|
|
58
|
+
throw new core_1.NAuthException(core_1.AuthErrorCode.VALIDATION_FAILED, 'Redis connection health check failed');
|
|
59
|
+
}
|
|
60
|
+
if (this.logger) {
|
|
61
|
+
this.logger.log('RedisStorageAdapter initialized successfully');
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
catch (error) {
|
|
65
|
+
if (this.logger) {
|
|
66
|
+
this.logger.error('Failed to initialize RedisStorageAdapter', error);
|
|
67
|
+
}
|
|
68
|
+
throw error;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
async isHealthy() {
|
|
72
|
+
try {
|
|
73
|
+
const client = this.redisClient;
|
|
74
|
+
await client.ping();
|
|
75
|
+
return true;
|
|
76
|
+
}
|
|
77
|
+
catch (error) {
|
|
78
|
+
if (this.logger) {
|
|
79
|
+
this.logger.error('RedisStorageAdapter health check failed', error);
|
|
80
|
+
}
|
|
81
|
+
return false;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
async get(key) {
|
|
85
|
+
const client = this.redisClient;
|
|
86
|
+
return await client.get(this.getPrefixedKey(key));
|
|
87
|
+
}
|
|
88
|
+
async set(key, value, ttlSeconds, options) {
|
|
89
|
+
const client = this.redisClient;
|
|
90
|
+
const prefixedKey = this.getPrefixedKey(key);
|
|
91
|
+
if (options?.nx) {
|
|
92
|
+
const setOptions = { NX: true };
|
|
93
|
+
if (ttlSeconds) {
|
|
94
|
+
setOptions.EX = ttlSeconds;
|
|
95
|
+
}
|
|
96
|
+
const result = await client.set(prefixedKey, value, setOptions);
|
|
97
|
+
return result === 'OK' ? value : null;
|
|
98
|
+
}
|
|
99
|
+
else {
|
|
100
|
+
if (ttlSeconds) {
|
|
101
|
+
await client.set(prefixedKey, value, { EX: ttlSeconds });
|
|
102
|
+
}
|
|
103
|
+
else {
|
|
104
|
+
await client.set(prefixedKey, value);
|
|
105
|
+
}
|
|
106
|
+
return value;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
async del(key) {
|
|
110
|
+
const client = this.redisClient;
|
|
111
|
+
await client.del(this.getPrefixedKey(key));
|
|
112
|
+
}
|
|
113
|
+
async exists(key) {
|
|
114
|
+
const client = this.redisClient;
|
|
115
|
+
const result = await client.exists(this.getPrefixedKey(key));
|
|
116
|
+
return typeof result === 'boolean' ? result : result > 0;
|
|
117
|
+
}
|
|
118
|
+
async incr(key, ttlSeconds) {
|
|
119
|
+
const client = this.redisClient;
|
|
120
|
+
const prefixedKey = this.getPrefixedKey(key);
|
|
121
|
+
const exists = await client.exists(prefixedKey);
|
|
122
|
+
const value = await client.incr(prefixedKey);
|
|
123
|
+
if (ttlSeconds !== undefined && exists === 0 && value === 1) {
|
|
124
|
+
await client.expire(prefixedKey, ttlSeconds);
|
|
125
|
+
}
|
|
126
|
+
return value;
|
|
127
|
+
}
|
|
128
|
+
async decr(key) {
|
|
129
|
+
const client = this.redisClient;
|
|
130
|
+
return await client.decr(this.getPrefixedKey(key));
|
|
131
|
+
}
|
|
132
|
+
async expire(key, ttl) {
|
|
133
|
+
const client = this.redisClient;
|
|
134
|
+
await client.expire(this.getPrefixedKey(key), ttl);
|
|
135
|
+
}
|
|
136
|
+
async ttl(key) {
|
|
137
|
+
const client = this.redisClient;
|
|
138
|
+
return await client.ttl(this.getPrefixedKey(key));
|
|
139
|
+
}
|
|
140
|
+
async hget(key, field) {
|
|
141
|
+
const client = this.redisClient;
|
|
142
|
+
return await client.hget(this.getPrefixedKey(key), field);
|
|
143
|
+
}
|
|
144
|
+
async hset(key, field, value) {
|
|
145
|
+
const client = this.redisClient;
|
|
146
|
+
await client.hset(this.getPrefixedKey(key), field, value);
|
|
147
|
+
}
|
|
148
|
+
async hgetall(key) {
|
|
149
|
+
const client = this.redisClient;
|
|
150
|
+
return await client.hgetall(this.getPrefixedKey(key));
|
|
151
|
+
}
|
|
152
|
+
async hdel(key, ...fields) {
|
|
153
|
+
const client = this.redisClient;
|
|
154
|
+
return await client.hdel(this.getPrefixedKey(key), ...fields);
|
|
155
|
+
}
|
|
156
|
+
async lpush(key, value) {
|
|
157
|
+
const client = this.redisClient;
|
|
158
|
+
await client.lpush(this.getPrefixedKey(key), value);
|
|
159
|
+
}
|
|
160
|
+
async lrange(key, start, stop) {
|
|
161
|
+
const client = this.redisClient;
|
|
162
|
+
return await client.lrange(this.getPrefixedKey(key), start, stop);
|
|
163
|
+
}
|
|
164
|
+
async llen(key) {
|
|
165
|
+
const client = this.redisClient;
|
|
166
|
+
return await client.llen(this.getPrefixedKey(key));
|
|
167
|
+
}
|
|
168
|
+
async keys(pattern) {
|
|
169
|
+
const allKeys = [];
|
|
170
|
+
let cursor = 0;
|
|
171
|
+
const countPerScan = 1000;
|
|
172
|
+
do {
|
|
173
|
+
const [nextCursor, keys] = await this.scan(cursor, pattern, countPerScan);
|
|
174
|
+
cursor = nextCursor;
|
|
175
|
+
if (keys && keys.length > 0) {
|
|
176
|
+
allKeys.push(...keys);
|
|
177
|
+
}
|
|
178
|
+
} while (cursor !== 0);
|
|
179
|
+
return allKeys;
|
|
180
|
+
}
|
|
181
|
+
async scan(cursor, pattern, count) {
|
|
182
|
+
const client = this.redisClient;
|
|
183
|
+
const prefixedPattern = `${this.keyPrefix}${pattern}`;
|
|
184
|
+
const result = await client.scan(cursor, 'MATCH', prefixedPattern, 'COUNT', count);
|
|
185
|
+
let newCursor;
|
|
186
|
+
let keys;
|
|
187
|
+
if (Array.isArray(result)) {
|
|
188
|
+
[newCursor, keys] = result;
|
|
189
|
+
}
|
|
190
|
+
else {
|
|
191
|
+
newCursor = result.cursor;
|
|
192
|
+
keys = result.keys || [];
|
|
193
|
+
}
|
|
194
|
+
const unprefixedKeys = keys.map((key) => key.replace(new RegExp(`^${this.keyPrefix}`), ''));
|
|
195
|
+
return [newCursor, unprefixedKeys];
|
|
196
|
+
}
|
|
197
|
+
async cleanup() {
|
|
198
|
+
if (this.logger?.debug) {
|
|
199
|
+
this.logger.debug('RedisStorageAdapter cleanup: expiration handled automatically by Redis');
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
async disconnect() {
|
|
203
|
+
if (this.logger?.debug) {
|
|
204
|
+
this.logger.debug('RedisStorageAdapter disconnected');
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
exports.RedisStorageAdapter = RedisStorageAdapter;
|
|
209
|
+
//# sourceMappingURL=redis-storage.adapter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"redis-storage.adapter.js","sourceRoot":"","sources":["../src/redis-storage.adapter.ts"],"names":[],"mappings":";;;AAAA,8CAAmG;AA6CnG,MAAa,mBAAmB;IAWX;IACT;IAXO,SAAS,GAAG,QAAQ,CAAC;IAStC,YACmB,WAAoB,EAC7B,MAAsB;QADb,gBAAW,GAAX,WAAW,CAAS;QAC7B,WAAM,GAAN,MAAM,CAAgB;IAMhC,CAAC;IAaO,cAAc,CAAC,MAAe;QACpC,IAAI,CAAC,MAAM,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE,CAAC;YAC1C,MAAM,IAAI,qBAAc,CAAC,oBAAa,CAAC,iBAAiB,EAAE,yCAAyC,CAAC,CAAC;QACvG,CAAC;QAED,MAAM,SAAS,GAAG,MAAiC,CAAC;QAOpD,MAAM,cAAc,GAAG,OAAO,SAAS,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M,EAAE,OAAO,EAAE,eAAe,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;QAG5F,IAAI,SAAiB,CAAC;QACtB,IAAI,IAAc,CAAC;QAEnB,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;YAC1B,CAAC,SAAS,EAAE,IAAI,CAAC,GAAG,MAAM,CAAC;QAC7B,CAAC;aAAM,CAAC;YACN,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC;YAC1B,IAAI,GAAG,MAAM,CAAC,IAAI,IAAI,EAAE,CAAC;QAC3B,CAAC;QAGD,MAAM,cAAc,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,GAAW,EAAE,EAAE,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,MAAM,CAAC,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC;QAEpG,OAAO,CAAC,SAAS,EAAE,cAAc,CAAC,CAAC;IACrC,CAAC;IAUD,KAAK,CAAC,OAAO;QAGX,IAAI,IAAI,CAAC,MAAM,EAAE,KAAK,EAAE,CAAC;YACvB,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,wEAAwE,CAAC,CAAC;QAC9F,CAAC;IACH,CAAC;IAMD,KAAK,CAAC,UAAU;QAGd,IAAI,IAAI,CAAC,MAAM,EAAE,KAAK,EAAE,CAAC;YACvB,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,kCAAkC,CAAC,CAAC;QACxD,CAAC;IACH,CAAC;CACF;AAvdD,kDAudC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@nauth-toolkit/storage-redis",
|
|
3
|
+
"version": "0.1.3",
|
|
4
|
+
"description": "Redis storage adapter for nauth-toolkit using the redis package (node-redis)",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"build": "tsc -b",
|
|
9
|
+
"clean": "rm -rf dist *.tsbuildinfo",
|
|
10
|
+
"test": "jest",
|
|
11
|
+
"lint": "eslint src --ext .ts",
|
|
12
|
+
"lint:fix": "eslint src --ext .ts --fix",
|
|
13
|
+
"format": "prettier --write \"src/**/*.ts\"",
|
|
14
|
+
"format:check": "prettier --check \"src/**/*.ts\""
|
|
15
|
+
},
|
|
16
|
+
"peerDependencies": {
|
|
17
|
+
"@nauth-toolkit/core": "^0.1.3",
|
|
18
|
+
"redis": "^4.6.0 || ^5.0.0"
|
|
19
|
+
},
|
|
20
|
+
"devDependencies": {
|
|
21
|
+
"@types/jest": "^29.5.0",
|
|
22
|
+
"@types/node": "^22.0.0",
|
|
23
|
+
"jest": "^29.7.0",
|
|
24
|
+
"ts-jest": "^29.2.0",
|
|
25
|
+
"typescript": "^5.5.0"
|
|
26
|
+
},
|
|
27
|
+
"engines": {
|
|
28
|
+
"node": ">=22.0.0"
|
|
29
|
+
},
|
|
30
|
+
"publishConfig": {
|
|
31
|
+
"access": "public",
|
|
32
|
+
"tag": "preview"
|
|
33
|
+
},
|
|
34
|
+
"license": "UNLICENSED",
|
|
35
|
+
"keywords": [
|
|
36
|
+
"nestjs",
|
|
37
|
+
"authentication",
|
|
38
|
+
"storage",
|
|
39
|
+
"redis",
|
|
40
|
+
"dragonfly"
|
|
41
|
+
],
|
|
42
|
+
"files": [
|
|
43
|
+
"dist",
|
|
44
|
+
"LICENSE",
|
|
45
|
+
"README.md"
|
|
46
|
+
]
|
|
47
|
+
}
|