@nauth-toolkit/storage-database 0.1.14 → 0.1.18
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/dist/database-storage.adapter.d.ts +179 -0
- package/dist/database-storage.adapter.d.ts.map +1 -1
- package/dist/database-storage.adapter.js +259 -14
- package/dist/database-storage.adapter.js.map +1 -1
- package/dist/index.d.ts +20 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +20 -0
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
|
@@ -1,35 +1,214 @@
|
|
|
1
1
|
import { Repository } from 'typeorm';
|
|
2
2
|
import { StorageAdapter, LoggerService, BaseRateLimit, BaseStorageLock } from '@nauth-toolkit/core';
|
|
3
|
+
/**
|
|
4
|
+
* Database Storage Adapter
|
|
5
|
+
*
|
|
6
|
+
* Implements StorageAdapter interface using TypeORM repositories for persistent storage.
|
|
7
|
+
* Stores transient state (rate limits, locks, token reuse tracking) in database tables.
|
|
8
|
+
*
|
|
9
|
+
* **Key Features:**
|
|
10
|
+
* - Multi-server compatible (all servers share same database)
|
|
11
|
+
* - Atomic operations via database-level increment/decrement
|
|
12
|
+
* - TTL support via expiresAt column with scheduled cleanup
|
|
13
|
+
* - Hash and list operations stored as JSON
|
|
14
|
+
* - Seamlessly integrates with existing TypeORM DataSource
|
|
15
|
+
*
|
|
16
|
+
* **Database Tables:**
|
|
17
|
+
* - `nauth_rate_limits`: Key-value pairs with expiration
|
|
18
|
+
* - `nauth_storage_locks`: Distributed locks with expiration
|
|
19
|
+
*
|
|
20
|
+
* **Usage:**
|
|
21
|
+
* ```typescript
|
|
22
|
+
* import { DatabaseStorageAdapter } from '@nauth-toolkit/storage-database';
|
|
23
|
+
*
|
|
24
|
+
* AuthModule.forRoot({
|
|
25
|
+
* storageAdapter: new DatabaseStorageAdapter(), // Uses injected repositories
|
|
26
|
+
* });
|
|
27
|
+
* ```
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* ```typescript
|
|
31
|
+
* const adapter = new DatabaseStorageAdapter();
|
|
32
|
+
* await adapter.initialize();
|
|
33
|
+
* await adapter.set('key', 'value', 60); // Set with 60 second TTL
|
|
34
|
+
* const value = await adapter.get('key');
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
3
37
|
export declare class DatabaseStorageAdapter implements StorageAdapter {
|
|
4
38
|
private rateLimitRepo;
|
|
5
39
|
private storageLockRepo;
|
|
6
40
|
private logger?;
|
|
41
|
+
/**
|
|
42
|
+
* Creates a new DatabaseStorageAdapter instance
|
|
43
|
+
*
|
|
44
|
+
* @param rateLimitRepo - TypeORM repository for rate limit storage (injected)
|
|
45
|
+
* @param storageLockRepo - TypeORM repository for distributed locks (injected)
|
|
46
|
+
* @param logger - Logger service for error and debug logging
|
|
47
|
+
* @throws {NAuthException} If repositories are not provided (entities not registered in TypeORM)
|
|
48
|
+
*/
|
|
7
49
|
constructor(rateLimitRepo: Repository<BaseRateLimit> | null, storageLockRepo: Repository<BaseStorageLock> | null, logger?: LoggerService | undefined);
|
|
50
|
+
/**
|
|
51
|
+
* Set repositories after construction (for factory-created adapters)
|
|
52
|
+
* This method is called by the auth module when repositories become available
|
|
53
|
+
*
|
|
54
|
+
* @param rateLimitRepo - TypeORM repository for rate limit storage
|
|
55
|
+
* @param storageLockRepo - TypeORM repository for distributed locks
|
|
56
|
+
*/
|
|
8
57
|
setRepositories(rateLimitRepo: Repository<BaseRateLimit>, storageLockRepo: Repository<BaseStorageLock>): void;
|
|
58
|
+
/**
|
|
59
|
+
* Determine which repository to use based on key prefix
|
|
60
|
+
* Locks and token reuse tracking go to storageLockRepo
|
|
61
|
+
* Rate limits and other data go to rateLimitRepo
|
|
62
|
+
*
|
|
63
|
+
* @param key - The storage key
|
|
64
|
+
* @returns The appropriate repository
|
|
65
|
+
*/
|
|
9
66
|
private getRepositoryForKey;
|
|
67
|
+
/**
|
|
68
|
+
* Initialize the storage adapter
|
|
69
|
+
* Performs health check to ensure repositories are accessible
|
|
70
|
+
*
|
|
71
|
+
* @throws {Error} If repositories are not available
|
|
72
|
+
*/
|
|
10
73
|
initialize(): Promise<void>;
|
|
74
|
+
/**
|
|
75
|
+
* Check if the storage adapter is healthy and operational
|
|
76
|
+
* @returns True if repositories are available, false otherwise
|
|
77
|
+
*/
|
|
11
78
|
isHealthy(): Promise<boolean>;
|
|
79
|
+
/**
|
|
80
|
+
* Get a value by key
|
|
81
|
+
* @param key - The key to retrieve
|
|
82
|
+
* @returns The stored value or null if not found/expired
|
|
83
|
+
*/
|
|
12
84
|
get(key: string): Promise<string | null>;
|
|
85
|
+
/**
|
|
86
|
+
* Set a key-value pair with optional TTL (time to live)
|
|
87
|
+
*
|
|
88
|
+
* @param key - The key to store
|
|
89
|
+
* @param value - The value to store
|
|
90
|
+
* @param ttlSeconds - Time to live in seconds (optional)
|
|
91
|
+
* @param options - Additional options like nx (set if not exists)
|
|
92
|
+
*/
|
|
13
93
|
set(key: string, value: string, ttlSeconds?: number, options?: {
|
|
14
94
|
nx?: boolean;
|
|
15
95
|
}): Promise<string | null>;
|
|
96
|
+
/**
|
|
97
|
+
* Delete a key from storage
|
|
98
|
+
* @param key - The key to delete
|
|
99
|
+
*/
|
|
16
100
|
del(key: string): Promise<void>;
|
|
101
|
+
/**
|
|
102
|
+
* Check if a key exists
|
|
103
|
+
* @param key - The key to check
|
|
104
|
+
* @returns True if the key exists and is not expired, false otherwise
|
|
105
|
+
*/
|
|
17
106
|
exists(key: string): Promise<boolean>;
|
|
107
|
+
/**
|
|
108
|
+
* Increment a counter stored at key
|
|
109
|
+
* Uses TypeORM transaction with pessimistic locking for thread-safety
|
|
110
|
+
* Automatically resets to 1 if the record is expired (treats as new window)
|
|
111
|
+
*
|
|
112
|
+
* @param key - The key to increment
|
|
113
|
+
* @param ttlSeconds - Optional TTL in seconds to set when creating a new record (defaults to 24 hours)
|
|
114
|
+
* @returns The new value after incrementing
|
|
115
|
+
*/
|
|
18
116
|
incr(key: string, ttlSeconds?: number): Promise<number>;
|
|
117
|
+
/**
|
|
118
|
+
* Decrement a counter stored at key
|
|
119
|
+
* Uses TypeORM transaction with pessimistic locking for thread-safety
|
|
120
|
+
*
|
|
121
|
+
* @param key - The key to decrement
|
|
122
|
+
* @returns The new value after decrementing (minimum 0)
|
|
123
|
+
*/
|
|
19
124
|
decr(key: string): Promise<number>;
|
|
125
|
+
/**
|
|
126
|
+
* Set expiration time for a key
|
|
127
|
+
* @param key - The key to set expiration for
|
|
128
|
+
* @param ttlSeconds - Time to live in seconds
|
|
129
|
+
* @throws {Error} If expiration cannot be set (key doesn't exist or update fails)
|
|
130
|
+
*/
|
|
20
131
|
expire(key: string, ttlSeconds: number): Promise<void>;
|
|
132
|
+
/**
|
|
133
|
+
* Build a DB-specific expression for NOW() + seconds
|
|
134
|
+
* Ensures createdAt and expiresAt are in the same time base (database-side).
|
|
135
|
+
*/
|
|
21
136
|
private getDbNowPlusSecondsExpression;
|
|
137
|
+
/**
|
|
138
|
+
* Get the time-to-live for a key in seconds
|
|
139
|
+
* @param key - The key to check
|
|
140
|
+
* @returns TTL in seconds, or -1 if key doesn't exist, or -2 if no expiration
|
|
141
|
+
*/
|
|
22
142
|
ttl(key: string): Promise<number>;
|
|
143
|
+
/**
|
|
144
|
+
* Set a field in a hash stored at key
|
|
145
|
+
* @param key - The hash key
|
|
146
|
+
* @param field - The field name
|
|
147
|
+
* @param value - The field value
|
|
148
|
+
*/
|
|
23
149
|
hset(key: string, field: string, value: string): Promise<void>;
|
|
150
|
+
/**
|
|
151
|
+
* Get a field from a hash stored at key
|
|
152
|
+
* @param key - The hash key
|
|
153
|
+
* @param field - The field name
|
|
154
|
+
* @returns The field value or null if not found
|
|
155
|
+
*/
|
|
24
156
|
hget(key: string, field: string): Promise<string | null>;
|
|
157
|
+
/**
|
|
158
|
+
* Get all fields and values from a hash stored at key
|
|
159
|
+
* @param key - The hash key
|
|
160
|
+
* @returns Object with all field-value pairs
|
|
161
|
+
*/
|
|
25
162
|
hgetall(key: string): Promise<Record<string, string>>;
|
|
163
|
+
/**
|
|
164
|
+
* Delete fields from a hash stored at key
|
|
165
|
+
* @param key - The hash key
|
|
166
|
+
* @param fields - The field names to delete
|
|
167
|
+
* @returns The number of fields that were removed
|
|
168
|
+
*/
|
|
26
169
|
hdel(key: string, ...fields: string[]): Promise<number>;
|
|
170
|
+
/**
|
|
171
|
+
* Push a value to the left (beginning) of a list stored at key
|
|
172
|
+
* @param key - The list key
|
|
173
|
+
* @param value - The value to push
|
|
174
|
+
*/
|
|
27
175
|
lpush(key: string, value: string): Promise<void>;
|
|
176
|
+
/**
|
|
177
|
+
* Get a range of elements from a list stored at key
|
|
178
|
+
* @param key - The list key
|
|
179
|
+
* @param start - Start index (0-based)
|
|
180
|
+
* @param stop - End index (inclusive, -1 for end)
|
|
181
|
+
* @returns Array of elements in the specified range
|
|
182
|
+
*/
|
|
28
183
|
lrange(key: string, start: number, stop: number): Promise<string[]>;
|
|
184
|
+
/**
|
|
185
|
+
* Get the length of a list stored at key
|
|
186
|
+
* @param key - The list key
|
|
187
|
+
* @returns The length of the list
|
|
188
|
+
*/
|
|
29
189
|
llen(key: string): Promise<number>;
|
|
190
|
+
/**
|
|
191
|
+
* Find keys matching a pattern
|
|
192
|
+
* @param pattern - Glob pattern to match keys against
|
|
193
|
+
* @returns Array of matching keys
|
|
194
|
+
*/
|
|
30
195
|
keys(pattern: string): Promise<string[]>;
|
|
196
|
+
/**
|
|
197
|
+
* Scan for keys matching a pattern (simplified version)
|
|
198
|
+
* @param cursor - Cursor for pagination (unused in this implementation)
|
|
199
|
+
* @param pattern - Pattern to match
|
|
200
|
+
* @param count - Maximum number of keys to return
|
|
201
|
+
* @returns [nextCursor, keys] tuple
|
|
202
|
+
*/
|
|
31
203
|
scan(cursor: number, pattern: string, count: number): Promise<[number, string[]]>;
|
|
204
|
+
/**
|
|
205
|
+
* Clean up expired keys (called periodically by background task)
|
|
206
|
+
* Cleans both rate limit and storage lock tables
|
|
207
|
+
*/
|
|
32
208
|
cleanup(): Promise<void>;
|
|
209
|
+
/**
|
|
210
|
+
* Disconnect from storage (no-op for database adapter)
|
|
211
|
+
*/
|
|
33
212
|
disconnect(): Promise<void>;
|
|
34
213
|
}
|
|
35
214
|
//# sourceMappingURL=database-storage.adapter.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"database-storage.adapter.d.ts","sourceRoot":"","sources":["../src/database-storage.adapter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAY,MAAM,SAAS,CAAC;AAC/C,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"database-storage.adapter.d.ts","sourceRoot":"","sources":["../src/database-storage.adapter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAY,MAAM,SAAS,CAAC;AAC/C,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAIpG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAEH,qBAAa,sBAAuB,YAAW,cAAc;IAUzD,OAAO,CAAC,aAAa;IACrB,OAAO,CAAC,eAAe;IACvB,OAAO,CAAC,MAAM,CAAC;IAXjB;;;;;;;OAOG;gBAEO,aAAa,EAAE,UAAU,CAAC,aAAa,CAAC,GAAG,IAAI,EAC/C,eAAe,EAAE,UAAU,CAAC,eAAe,CAAC,GAAG,IAAI,EACnD,MAAM,CAAC,EAAE,aAAa,YAAA;IAOhC;;;;;;OAMG;IACH,eAAe,CAAC,aAAa,EAAE,UAAU,CAAC,aAAa,CAAC,EAAE,eAAe,EAAE,UAAU,CAAC,eAAe,CAAC,GAAG,IAAI;IAK7G;;;;;;;OAOG;IACH,OAAO,CAAC,mBAAmB;IAS3B;;;;;OAKG;IACG,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAUjC;;;OAGG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O,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAoB3D;;;;;OAKG;IACG,IAAI,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC;IAuC7D;;;;OAIG;IACG,KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IA4BtD;;;;;;OAMG;IACG,MAAM,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IAoCzE;;;;OAIG;IACG,IAAI,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAyBxC;;;;OAIG;IACG,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IAmC9C;;;;;;OAMG;IACG,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;IAevF;;;OAGG;IACG,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAc9B;;OAEG;IACG,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;CAGlC"}
|
|
@@ -2,25 +2,93 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.DatabaseStorageAdapter = void 0;
|
|
4
4
|
const typeorm_1 = require("typeorm");
|
|
5
|
+
/**
|
|
6
|
+
* Database Storage Adapter
|
|
7
|
+
*
|
|
8
|
+
* Implements StorageAdapter interface using TypeORM repositories for persistent storage.
|
|
9
|
+
* Stores transient state (rate limits, locks, token reuse tracking) in database tables.
|
|
10
|
+
*
|
|
11
|
+
* **Key Features:**
|
|
12
|
+
* - Multi-server compatible (all servers share same database)
|
|
13
|
+
* - Atomic operations via database-level increment/decrement
|
|
14
|
+
* - TTL support via expiresAt column with scheduled cleanup
|
|
15
|
+
* - Hash and list operations stored as JSON
|
|
16
|
+
* - Seamlessly integrates with existing TypeORM DataSource
|
|
17
|
+
*
|
|
18
|
+
* **Database Tables:**
|
|
19
|
+
* - `nauth_rate_limits`: Key-value pairs with expiration
|
|
20
|
+
* - `nauth_storage_locks`: Distributed locks with expiration
|
|
21
|
+
*
|
|
22
|
+
* **Usage:**
|
|
23
|
+
* ```typescript
|
|
24
|
+
* import { DatabaseStorageAdapter } from '@nauth-toolkit/storage-database';
|
|
25
|
+
*
|
|
26
|
+
* AuthModule.forRoot({
|
|
27
|
+
* storageAdapter: new DatabaseStorageAdapter(), // Uses injected repositories
|
|
28
|
+
* });
|
|
29
|
+
* ```
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* ```typescript
|
|
33
|
+
* const adapter = new DatabaseStorageAdapter();
|
|
34
|
+
* await adapter.initialize();
|
|
35
|
+
* await adapter.set('key', 'value', 60); // Set with 60 second TTL
|
|
36
|
+
* const value = await adapter.get('key');
|
|
37
|
+
* ```
|
|
38
|
+
*/
|
|
5
39
|
class DatabaseStorageAdapter {
|
|
6
40
|
rateLimitRepo;
|
|
7
41
|
storageLockRepo;
|
|
8
42
|
logger;
|
|
43
|
+
/**
|
|
44
|
+
* Creates a new DatabaseStorageAdapter instance
|
|
45
|
+
*
|
|
46
|
+
* @param rateLimitRepo - TypeORM repository for rate limit storage (injected)
|
|
47
|
+
* @param storageLockRepo - TypeORM repository for distributed locks (injected)
|
|
48
|
+
* @param logger - Logger service for error and debug logging
|
|
49
|
+
* @throws {NAuthException} If repositories are not provided (entities not registered in TypeORM)
|
|
50
|
+
*/
|
|
9
51
|
constructor(rateLimitRepo, storageLockRepo, logger) {
|
|
10
52
|
this.rateLimitRepo = rateLimitRepo;
|
|
11
53
|
this.storageLockRepo = storageLockRepo;
|
|
12
54
|
this.logger = logger;
|
|
55
|
+
// Repositories validation deferred to initialize() because:
|
|
56
|
+
// - Factory-created adapters won't have repositories injected yet
|
|
57
|
+
// - Repositories will be available when adapter is used as a provider
|
|
13
58
|
}
|
|
59
|
+
/**
|
|
60
|
+
* Set repositories after construction (for factory-created adapters)
|
|
61
|
+
* This method is called by the auth module when repositories become available
|
|
62
|
+
*
|
|
63
|
+
* @param rateLimitRepo - TypeORM repository for rate limit storage
|
|
64
|
+
* @param storageLockRepo - TypeORM repository for distributed locks
|
|
65
|
+
*/
|
|
14
66
|
setRepositories(rateLimitRepo, storageLockRepo) {
|
|
15
67
|
this.rateLimitRepo = rateLimitRepo;
|
|
16
68
|
this.storageLockRepo = storageLockRepo;
|
|
17
69
|
}
|
|
70
|
+
/**
|
|
71
|
+
* Determine which repository to use based on key prefix
|
|
72
|
+
* Locks and token reuse tracking go to storageLockRepo
|
|
73
|
+
* Rate limits and other data go to rateLimitRepo
|
|
74
|
+
*
|
|
75
|
+
* @param key - The storage key
|
|
76
|
+
* @returns The appropriate repository
|
|
77
|
+
*/
|
|
18
78
|
getRepositoryForKey(key) {
|
|
79
|
+
// Keys starting with these prefixes are locks/tokens (distributed locking)
|
|
19
80
|
if (key.startsWith('refresh-lock:') || key.startsWith('used-token:') || key.startsWith('session-refresh:')) {
|
|
20
81
|
return this.storageLockRepo;
|
|
21
82
|
}
|
|
83
|
+
// All other keys are rate limits or general storage (e.g., nauth:ratelimit:, phone-verification:)
|
|
22
84
|
return this.rateLimitRepo;
|
|
23
85
|
}
|
|
86
|
+
/**
|
|
87
|
+
* Initialize the storage adapter
|
|
88
|
+
* Performs health check to ensure repositories are accessible
|
|
89
|
+
*
|
|
90
|
+
* @throws {Error} If repositories are not available
|
|
91
|
+
*/
|
|
24
92
|
async initialize() {
|
|
25
93
|
if (!this.rateLimitRepo || !this.storageLockRepo) {
|
|
26
94
|
throw new Error('DatabaseStorageAdapter requires RateLimit and StorageLock repositories to be registered. ' +
|
|
@@ -28,9 +96,21 @@ class DatabaseStorageAdapter {
|
|
|
28
96
|
'entities: [...getNAuthEntities(), ...getNAuthTransientStorageEntities()]');
|
|
29
97
|
}
|
|
30
98
|
}
|
|
99
|
+
/**
|
|
100
|
+
* Check if the storage adapter is healthy and operational
|
|
101
|
+
* @returns True if repositories are available, false otherwise
|
|
102
|
+
*/
|
|
31
103
|
async isHealthy() {
|
|
32
104
|
return !!(this.rateLimitRepo && this.storageLockRepo);
|
|
33
105
|
}
|
|
106
|
+
// ============================================================================
|
|
107
|
+
// Basic Key-Value Operations
|
|
108
|
+
// ============================================================================
|
|
109
|
+
/**
|
|
110
|
+
* Get a value by key
|
|
111
|
+
* @param key - The key to retrieve
|
|
112
|
+
* @returns The stored value or null if not found/expired
|
|
113
|
+
*/
|
|
34
114
|
async get(key) {
|
|
35
115
|
try {
|
|
36
116
|
const repo = this.getRepositoryForKey(key);
|
|
@@ -40,8 +120,10 @@ class DatabaseStorageAdapter {
|
|
|
40
120
|
if (!record) {
|
|
41
121
|
return null;
|
|
42
122
|
}
|
|
123
|
+
// Check if expired
|
|
43
124
|
const expiresAt = record.expiresAt;
|
|
44
125
|
if (expiresAt && expiresAt < new Date()) {
|
|
126
|
+
// Clean up expired record
|
|
45
127
|
await repo.delete({ key });
|
|
46
128
|
return null;
|
|
47
129
|
}
|
|
@@ -52,13 +134,29 @@ class DatabaseStorageAdapter {
|
|
|
52
134
|
return null;
|
|
53
135
|
}
|
|
54
136
|
}
|
|
137
|
+
/**
|
|
138
|
+
* Set a key-value pair with optional TTL (time to live)
|
|
139
|
+
*
|
|
140
|
+
* @param key - The key to store
|
|
141
|
+
* @param value - The value to store
|
|
142
|
+
* @param ttlSeconds - Time to live in seconds (optional)
|
|
143
|
+
* @param options - Additional options like nx (set if not exists)
|
|
144
|
+
*/
|
|
55
145
|
async set(key, value, ttlSeconds, options) {
|
|
56
146
|
const now = new Date();
|
|
57
147
|
const expiresAt = ttlSeconds ? new Date(now.getTime() + ttlSeconds * 1000) : null;
|
|
58
148
|
try {
|
|
59
149
|
const repo = this.getRepositoryForKey(key);
|
|
60
150
|
if (options?.nx) {
|
|
151
|
+
// For NX operation, we need to handle the case where the key doesn't exist yet
|
|
152
|
+
// Since pessimistic locking can't lock a non-existent row, we use a different approach:
|
|
153
|
+
// 1. Try to insert directly - rely on unique constraint to prevent duplicates
|
|
154
|
+
// 2. If duplicate key error, check if the existing key is expired
|
|
155
|
+
// 3. If expired, delete and retry insert
|
|
156
|
+
// This ensures atomicity through the database unique constraint
|
|
61
157
|
try {
|
|
158
|
+
// First attempt: Try to insert directly
|
|
159
|
+
// If key doesn't exist, this succeeds immediately (fast path)
|
|
62
160
|
await repo
|
|
63
161
|
.createQueryBuilder()
|
|
64
162
|
.insert()
|
|
@@ -69,23 +167,29 @@ class DatabaseStorageAdapter {
|
|
|
69
167
|
expiresAt,
|
|
70
168
|
})
|
|
71
169
|
.execute();
|
|
72
|
-
return value;
|
|
170
|
+
return value; // Success - key was set
|
|
73
171
|
}
|
|
74
172
|
catch (error) {
|
|
173
|
+
// Insert failed - check if it's a duplicate key error
|
|
75
174
|
const dbError = error;
|
|
76
175
|
const isDuplicateKey = dbError.code === 'ER_DUP_ENTRY' ||
|
|
77
176
|
dbError.code === '23505' ||
|
|
78
177
|
dbError.message?.includes('duplicate key') ||
|
|
79
178
|
dbError.message?.includes('UNIQUE constraint failed');
|
|
179
|
+
// If not a duplicate key error, re-throw immediately
|
|
80
180
|
if (!isDuplicateKey) {
|
|
81
181
|
throw error;
|
|
82
182
|
}
|
|
183
|
+
// Duplicate key detected - start transaction IMMEDIATELY (no gap) to check expiration
|
|
184
|
+
// This minimizes race condition window between error detection and lock acquisition
|
|
83
185
|
return await repo.manager.transaction(async (transactionalEntityManager) => {
|
|
186
|
+
// Lock the existing row to prevent other transactions from modifying it
|
|
84
187
|
const existing = await transactionalEntityManager.findOne(repo.target, {
|
|
85
188
|
where: { key },
|
|
86
189
|
lock: { mode: 'pessimistic_write' },
|
|
87
190
|
});
|
|
88
191
|
if (!existing) {
|
|
192
|
+
// Row was deleted between our insert attempt and this check - try insert again
|
|
89
193
|
try {
|
|
90
194
|
await transactionalEntityManager.insert(repo.target, {
|
|
91
195
|
key,
|
|
@@ -100,13 +204,15 @@ class DatabaseStorageAdapter {
|
|
|
100
204
|
retryDbError.code === '23505' ||
|
|
101
205
|
retryDbError.message?.includes('duplicate key') ||
|
|
102
206
|
retryDbError.message?.includes('UNIQUE constraint failed')) {
|
|
103
|
-
return null;
|
|
207
|
+
return null; // Another request inserted it
|
|
104
208
|
}
|
|
105
209
|
throw retryError;
|
|
106
210
|
}
|
|
107
211
|
}
|
|
212
|
+
// Check if expired
|
|
108
213
|
const existingExpiresAt = existing.expiresAt;
|
|
109
214
|
if (existingExpiresAt && existingExpiresAt < now) {
|
|
215
|
+
// Expired - delete and insert
|
|
110
216
|
await transactionalEntityManager.delete(repo.target, { key });
|
|
111
217
|
await transactionalEntityManager.insert(repo.target, {
|
|
112
218
|
key,
|
|
@@ -115,11 +221,13 @@ class DatabaseStorageAdapter {
|
|
|
115
221
|
});
|
|
116
222
|
return value;
|
|
117
223
|
}
|
|
224
|
+
// Key exists and is not expired - NX operation fails
|
|
118
225
|
return null;
|
|
119
226
|
});
|
|
120
227
|
}
|
|
121
228
|
}
|
|
122
229
|
else {
|
|
230
|
+
// Regular upsert operation
|
|
123
231
|
await repo.upsert({
|
|
124
232
|
key,
|
|
125
233
|
value,
|
|
@@ -133,6 +241,10 @@ class DatabaseStorageAdapter {
|
|
|
133
241
|
return null;
|
|
134
242
|
}
|
|
135
243
|
}
|
|
244
|
+
/**
|
|
245
|
+
* Delete a key from storage
|
|
246
|
+
* @param key - The key to delete
|
|
247
|
+
*/
|
|
136
248
|
async del(key) {
|
|
137
249
|
try {
|
|
138
250
|
const repo = this.getRepositoryForKey(key);
|
|
@@ -142,20 +254,40 @@ class DatabaseStorageAdapter {
|
|
|
142
254
|
this.logger?.error?.(`Failed to delete key ${key}:`, error);
|
|
143
255
|
}
|
|
144
256
|
}
|
|
257
|
+
/**
|
|
258
|
+
* Check if a key exists
|
|
259
|
+
* @param key - The key to check
|
|
260
|
+
* @returns True if the key exists and is not expired, false otherwise
|
|
261
|
+
*/
|
|
145
262
|
async exists(key) {
|
|
146
263
|
const value = await this.get(key);
|
|
147
264
|
return value !== null;
|
|
148
265
|
}
|
|
266
|
+
// ============================================================================
|
|
267
|
+
// Atomic Operations (for counters and rate limiting)
|
|
268
|
+
// ============================================================================
|
|
269
|
+
/**
|
|
270
|
+
* Increment a counter stored at key
|
|
271
|
+
* Uses TypeORM transaction with pessimistic locking for thread-safety
|
|
272
|
+
* Automatically resets to 1 if the record is expired (treats as new window)
|
|
273
|
+
*
|
|
274
|
+
* @param key - The key to increment
|
|
275
|
+
* @param ttlSeconds - Optional TTL in seconds to set when creating a new record (defaults to 24 hours)
|
|
276
|
+
* @returns The new value after incrementing
|
|
277
|
+
*/
|
|
149
278
|
async incr(key, ttlSeconds) {
|
|
150
279
|
const repo = this.getRepositoryForKey(key);
|
|
151
280
|
return await repo.manager.transaction(async (transactionalEntityManager) => {
|
|
281
|
+
// Lock the row for update to ensure atomicity
|
|
152
282
|
const record = await transactionalEntityManager.findOne(repo.target, {
|
|
153
283
|
where: { key },
|
|
154
284
|
lock: { mode: 'pessimistic_write' },
|
|
155
285
|
});
|
|
286
|
+
// Check if record exists and is expired
|
|
156
287
|
const now = new Date();
|
|
157
288
|
const isExpired = record && record.expiresAt && record.expiresAt < now;
|
|
158
289
|
if (record && !isExpired) {
|
|
290
|
+
// Update existing non-expired record
|
|
159
291
|
const currentValue = parseInt(record.value, 10) || 0;
|
|
160
292
|
const newValue = currentValue + 1;
|
|
161
293
|
await transactionalEntityManager.update(repo.target, { key }, {
|
|
@@ -164,10 +296,14 @@ class DatabaseStorageAdapter {
|
|
|
164
296
|
return newValue;
|
|
165
297
|
}
|
|
166
298
|
else {
|
|
299
|
+
// Key doesn't exist OR is expired - create/reset with value 1
|
|
300
|
+
// Delete expired record first if it exists
|
|
167
301
|
if (record) {
|
|
168
302
|
await transactionalEntityManager.delete(repo.target, { key });
|
|
169
303
|
}
|
|
170
|
-
|
|
304
|
+
// Use provided TTL or default to 24 hours to prevent orphaned counters
|
|
305
|
+
const ttlToUse = ttlSeconds !== undefined ? ttlSeconds : 24 * 60 * 60; // Default 24 hours
|
|
306
|
+
// Compute expiration on the database side to avoid timezone discrepancies
|
|
171
307
|
const dbExpr = this.getDbNowPlusSecondsExpression(repo, ttlToUse);
|
|
172
308
|
await transactionalEntityManager
|
|
173
309
|
.createQueryBuilder()
|
|
@@ -185,22 +321,32 @@ class DatabaseStorageAdapter {
|
|
|
185
321
|
}
|
|
186
322
|
});
|
|
187
323
|
}
|
|
324
|
+
/**
|
|
325
|
+
* Decrement a counter stored at key
|
|
326
|
+
* Uses TypeORM transaction with pessimistic locking for thread-safety
|
|
327
|
+
*
|
|
328
|
+
* @param key - The key to decrement
|
|
329
|
+
* @returns The new value after decrementing (minimum 0)
|
|
330
|
+
*/
|
|
188
331
|
async decr(key) {
|
|
189
332
|
const repo = this.getRepositoryForKey(key);
|
|
190
333
|
return await repo.manager.transaction(async (transactionalEntityManager) => {
|
|
334
|
+
// Lock the row for update to ensure atomicity
|
|
191
335
|
const record = await transactionalEntityManager.findOne(repo.target, {
|
|
192
336
|
where: { key },
|
|
193
337
|
lock: { mode: 'pessimistic_write' },
|
|
194
338
|
});
|
|
195
339
|
if (record) {
|
|
340
|
+
// Update existing record
|
|
196
341
|
const currentValue = parseInt(record.value, 10) || 0;
|
|
197
|
-
const newValue = Math.max(0, currentValue - 1);
|
|
342
|
+
const newValue = Math.max(0, currentValue - 1); // Ensure minimum 0
|
|
198
343
|
await transactionalEntityManager.update(repo.target, { key }, {
|
|
199
344
|
value: newValue.toString(),
|
|
200
345
|
});
|
|
201
346
|
return newValue;
|
|
202
347
|
}
|
|
203
348
|
else {
|
|
349
|
+
// Key doesn't exist - create with value 0
|
|
204
350
|
const defaultExpiration = new Date(Date.now() + 24 * 60 * 60 * 1000);
|
|
205
351
|
await transactionalEntityManager.save(repo.target, {
|
|
206
352
|
key,
|
|
@@ -211,9 +357,16 @@ class DatabaseStorageAdapter {
|
|
|
211
357
|
}
|
|
212
358
|
});
|
|
213
359
|
}
|
|
360
|
+
/**
|
|
361
|
+
* Set expiration time for a key
|
|
362
|
+
* @param key - The key to set expiration for
|
|
363
|
+
* @param ttlSeconds - Time to live in seconds
|
|
364
|
+
* @throws {Error} If expiration cannot be set (key doesn't exist or update fails)
|
|
365
|
+
*/
|
|
214
366
|
async expire(key, ttlSeconds) {
|
|
215
367
|
try {
|
|
216
368
|
const repo = this.getRepositoryForKey(key);
|
|
369
|
+
// Compute expiration on the database side to avoid timezone discrepancies
|
|
217
370
|
const dbExpr = this.getDbNowPlusSecondsExpression(repo, ttlSeconds);
|
|
218
371
|
const result = await repo
|
|
219
372
|
.createQueryBuilder()
|
|
@@ -231,9 +384,15 @@ class DatabaseStorageAdapter {
|
|
|
231
384
|
catch (error) {
|
|
232
385
|
const errorMessage = error instanceof Error ? error.message : 'Unknown error';
|
|
233
386
|
this.logger?.error?.(`Failed to set expiration for key ${key}: ${errorMessage}`, { error, ttlSeconds });
|
|
387
|
+
// Don't throw - expiration failures shouldn't break the calling code
|
|
234
388
|
}
|
|
235
389
|
}
|
|
390
|
+
/**
|
|
391
|
+
* Build a DB-specific expression for NOW() + seconds
|
|
392
|
+
* Ensures createdAt and expiresAt are in the same time base (database-side).
|
|
393
|
+
*/
|
|
236
394
|
getDbNowPlusSecondsExpression(repo, seconds) {
|
|
395
|
+
// TypeORM v0.3: DataSource is available at manager.connection (or dataSource)
|
|
237
396
|
const dataSource = repo.manager.connection ?? repo.manager.dataSource;
|
|
238
397
|
const type = dataSource?.options?.type;
|
|
239
398
|
if (type === 'postgres') {
|
|
@@ -245,8 +404,14 @@ class DatabaseStorageAdapter {
|
|
|
245
404
|
if (type === 'sqlite' || type === 'better-sqlite3') {
|
|
246
405
|
return `DATETIME('now', '+${seconds} seconds')`;
|
|
247
406
|
}
|
|
407
|
+
// Fallback (PostgreSQL syntax)
|
|
248
408
|
return `NOW() + INTERVAL '${seconds} seconds'`;
|
|
249
409
|
}
|
|
410
|
+
/**
|
|
411
|
+
* Get the time-to-live for a key in seconds
|
|
412
|
+
* @param key - The key to check
|
|
413
|
+
* @returns TTL in seconds, or -1 if key doesn't exist, or -2 if no expiration
|
|
414
|
+
*/
|
|
250
415
|
async ttl(key) {
|
|
251
416
|
try {
|
|
252
417
|
const repo = this.getRepositoryForKey(key);
|
|
@@ -254,39 +419,57 @@ class DatabaseStorageAdapter {
|
|
|
254
419
|
where: { key },
|
|
255
420
|
});
|
|
256
421
|
if (!record) {
|
|
257
|
-
return -1;
|
|
422
|
+
return -1; // Key doesn't exist
|
|
258
423
|
}
|
|
259
424
|
const expiresAt = record.expiresAt;
|
|
260
425
|
if (!expiresAt) {
|
|
261
|
-
return -2;
|
|
426
|
+
return -2; // No expiration set
|
|
262
427
|
}
|
|
263
428
|
const ttlMs = expiresAt.getTime() - Date.now();
|
|
264
|
-
return Math.max(0, Math.ceil(ttlMs / 1000));
|
|
429
|
+
return Math.max(0, Math.ceil(ttlMs / 1000)); // Convert to seconds, minimum 0
|
|
265
430
|
}
|
|
266
431
|
catch (error) {
|
|
267
432
|
this.logger?.error?.(`Failed to get TTL for key ${key}:`, error);
|
|
268
433
|
return -1;
|
|
269
434
|
}
|
|
270
435
|
}
|
|
436
|
+
// ============================================================================
|
|
437
|
+
// Hash Operations (for complex data structures)
|
|
438
|
+
// ============================================================================
|
|
439
|
+
/**
|
|
440
|
+
* Set a field in a hash stored at key
|
|
441
|
+
* @param key - The hash key
|
|
442
|
+
* @param field - The field name
|
|
443
|
+
* @param value - The field value
|
|
444
|
+
*/
|
|
271
445
|
async hset(key, field, value) {
|
|
272
446
|
try {
|
|
273
447
|
const hashKey = `hash:${key}`;
|
|
274
448
|
let hashData = {};
|
|
449
|
+
// Get existing hash data
|
|
275
450
|
const existing = await this.get(hashKey);
|
|
276
451
|
if (existing) {
|
|
277
452
|
try {
|
|
278
453
|
hashData = JSON.parse(existing);
|
|
279
454
|
}
|
|
280
455
|
catch {
|
|
456
|
+
// Invalid JSON, start fresh
|
|
281
457
|
}
|
|
282
458
|
}
|
|
283
459
|
hashData[field] = value;
|
|
460
|
+
// Store updated hash
|
|
284
461
|
await this.set(hashKey, JSON.stringify(hashData));
|
|
285
462
|
}
|
|
286
463
|
catch (error) {
|
|
287
464
|
this.logger?.error?.(`Failed to hset ${key} ${field}:`, error);
|
|
288
465
|
}
|
|
289
466
|
}
|
|
467
|
+
/**
|
|
468
|
+
* Get a field from a hash stored at key
|
|
469
|
+
* @param key - The hash key
|
|
470
|
+
* @param field - The field name
|
|
471
|
+
* @returns The field value or null if not found
|
|
472
|
+
*/
|
|
290
473
|
async hget(key, field) {
|
|
291
474
|
try {
|
|
292
475
|
const hashKey = `hash:${key}`;
|
|
@@ -299,7 +482,7 @@ class DatabaseStorageAdapter {
|
|
|
299
482
|
return hashData[field] || null;
|
|
300
483
|
}
|
|
301
484
|
catch {
|
|
302
|
-
return null;
|
|
485
|
+
return null; // Invalid JSON
|
|
303
486
|
}
|
|
304
487
|
}
|
|
305
488
|
catch (error) {
|
|
@@ -307,6 +490,11 @@ class DatabaseStorageAdapter {
|
|
|
307
490
|
return null;
|
|
308
491
|
}
|
|
309
492
|
}
|
|
493
|
+
/**
|
|
494
|
+
* Get all fields and values from a hash stored at key
|
|
495
|
+
* @param key - The hash key
|
|
496
|
+
* @returns Object with all field-value pairs
|
|
497
|
+
*/
|
|
310
498
|
async hgetall(key) {
|
|
311
499
|
try {
|
|
312
500
|
const hashKey = `hash:${key}`;
|
|
@@ -318,7 +506,7 @@ class DatabaseStorageAdapter {
|
|
|
318
506
|
return JSON.parse(hashDataStr);
|
|
319
507
|
}
|
|
320
508
|
catch {
|
|
321
|
-
return {};
|
|
509
|
+
return {}; // Invalid JSON
|
|
322
510
|
}
|
|
323
511
|
}
|
|
324
512
|
catch (error) {
|
|
@@ -326,6 +514,12 @@ class DatabaseStorageAdapter {
|
|
|
326
514
|
return {};
|
|
327
515
|
}
|
|
328
516
|
}
|
|
517
|
+
/**
|
|
518
|
+
* Delete fields from a hash stored at key
|
|
519
|
+
* @param key - The hash key
|
|
520
|
+
* @param fields - The field names to delete
|
|
521
|
+
* @returns The number of fields that were removed
|
|
522
|
+
*/
|
|
329
523
|
async hdel(key, ...fields) {
|
|
330
524
|
try {
|
|
331
525
|
const hashKey = `hash:${key}`;
|
|
@@ -338,7 +532,7 @@ class DatabaseStorageAdapter {
|
|
|
338
532
|
hashData = JSON.parse(hashDataStr);
|
|
339
533
|
}
|
|
340
534
|
catch {
|
|
341
|
-
return 0;
|
|
535
|
+
return 0; // Invalid JSON
|
|
342
536
|
}
|
|
343
537
|
let deletedCount = 0;
|
|
344
538
|
for (const field of fields) {
|
|
@@ -357,10 +551,19 @@ class DatabaseStorageAdapter {
|
|
|
357
551
|
return 0;
|
|
358
552
|
}
|
|
359
553
|
}
|
|
554
|
+
// ============================================================================
|
|
555
|
+
// List Operations (for ordered collections)
|
|
556
|
+
// ============================================================================
|
|
557
|
+
/**
|
|
558
|
+
* Push a value to the left (beginning) of a list stored at key
|
|
559
|
+
* @param key - The list key
|
|
560
|
+
* @param value - The value to push
|
|
561
|
+
*/
|
|
360
562
|
async lpush(key, value) {
|
|
361
563
|
try {
|
|
362
564
|
const listKey = `list:${key}`;
|
|
363
565
|
let listData = [];
|
|
566
|
+
// Get existing list data
|
|
364
567
|
const existing = await this.get(listKey);
|
|
365
568
|
if (existing) {
|
|
366
569
|
try {
|
|
@@ -370,15 +573,25 @@ class DatabaseStorageAdapter {
|
|
|
370
573
|
}
|
|
371
574
|
}
|
|
372
575
|
catch {
|
|
576
|
+
// Invalid JSON, start fresh
|
|
373
577
|
}
|
|
374
578
|
}
|
|
579
|
+
// Add to beginning of list
|
|
375
580
|
listData.unshift(value);
|
|
581
|
+
// Store updated list
|
|
376
582
|
await this.set(listKey, JSON.stringify(listData));
|
|
377
583
|
}
|
|
378
584
|
catch (error) {
|
|
379
585
|
this.logger?.error?.(`Failed to lpush ${key}:`, error);
|
|
380
586
|
}
|
|
381
587
|
}
|
|
588
|
+
/**
|
|
589
|
+
* Get a range of elements from a list stored at key
|
|
590
|
+
* @param key - The list key
|
|
591
|
+
* @param start - Start index (0-based)
|
|
592
|
+
* @param stop - End index (inclusive, -1 for end)
|
|
593
|
+
* @returns Array of elements in the specified range
|
|
594
|
+
*/
|
|
382
595
|
async lrange(key, start, stop) {
|
|
383
596
|
try {
|
|
384
597
|
const listKey = `list:${key}`;
|
|
@@ -394,8 +607,9 @@ class DatabaseStorageAdapter {
|
|
|
394
607
|
}
|
|
395
608
|
}
|
|
396
609
|
catch {
|
|
397
|
-
return [];
|
|
610
|
+
return []; // Invalid JSON
|
|
398
611
|
}
|
|
612
|
+
// Handle negative indices
|
|
399
613
|
const len = listData.length;
|
|
400
614
|
if (start < 0)
|
|
401
615
|
start = Math.max(0, len + start);
|
|
@@ -413,6 +627,11 @@ class DatabaseStorageAdapter {
|
|
|
413
627
|
return [];
|
|
414
628
|
}
|
|
415
629
|
}
|
|
630
|
+
/**
|
|
631
|
+
* Get the length of a list stored at key
|
|
632
|
+
* @param key - The list key
|
|
633
|
+
* @returns The length of the list
|
|
634
|
+
*/
|
|
416
635
|
async llen(key) {
|
|
417
636
|
try {
|
|
418
637
|
const listKey = `list:${key}`;
|
|
@@ -425,7 +644,7 @@ class DatabaseStorageAdapter {
|
|
|
425
644
|
return Array.isArray(listData) ? listData.length : 0;
|
|
426
645
|
}
|
|
427
646
|
catch {
|
|
428
|
-
return 0;
|
|
647
|
+
return 0; // Invalid JSON
|
|
429
648
|
}
|
|
430
649
|
}
|
|
431
650
|
catch (error) {
|
|
@@ -433,11 +652,21 @@ class DatabaseStorageAdapter {
|
|
|
433
652
|
return 0;
|
|
434
653
|
}
|
|
435
654
|
}
|
|
655
|
+
// ============================================================================
|
|
656
|
+
// Utility Operations
|
|
657
|
+
// ============================================================================
|
|
658
|
+
/**
|
|
659
|
+
* Find keys matching a pattern
|
|
660
|
+
* @param pattern - Glob pattern to match keys against
|
|
661
|
+
* @returns Array of matching keys
|
|
662
|
+
*/
|
|
436
663
|
async keys(pattern) {
|
|
437
664
|
try {
|
|
665
|
+
// Convert glob pattern to SQL LIKE pattern
|
|
438
666
|
const likePattern = pattern
|
|
439
|
-
.replace(/\*/g, '%')
|
|
440
|
-
.replace(/\?/g, '_');
|
|
667
|
+
.replace(/\*/g, '%') // * becomes %
|
|
668
|
+
.replace(/\?/g, '_'); // ? becomes _
|
|
669
|
+
// Query both repositories: rate limits and storage locks
|
|
441
670
|
const now = new Date();
|
|
442
671
|
const rateLimitKeysPromise = this.rateLimitRepo.createQueryBuilder('record')
|
|
443
672
|
.where('record.key LIKE :pattern', { pattern: likePattern })
|
|
@@ -462,6 +691,13 @@ class DatabaseStorageAdapter {
|
|
|
462
691
|
return [];
|
|
463
692
|
}
|
|
464
693
|
}
|
|
694
|
+
/**
|
|
695
|
+
* Scan for keys matching a pattern (simplified version)
|
|
696
|
+
* @param cursor - Cursor for pagination (unused in this implementation)
|
|
697
|
+
* @param pattern - Pattern to match
|
|
698
|
+
* @param count - Maximum number of keys to return
|
|
699
|
+
* @returns [nextCursor, keys] tuple
|
|
700
|
+
*/
|
|
465
701
|
async scan(cursor, pattern, count) {
|
|
466
702
|
try {
|
|
467
703
|
const keys = await this.keys(pattern);
|
|
@@ -476,8 +712,13 @@ class DatabaseStorageAdapter {
|
|
|
476
712
|
return [0, []];
|
|
477
713
|
}
|
|
478
714
|
}
|
|
715
|
+
/**
|
|
716
|
+
* Clean up expired keys (called periodically by background task)
|
|
717
|
+
* Cleans both rate limit and storage lock tables
|
|
718
|
+
*/
|
|
479
719
|
async cleanup() {
|
|
480
720
|
try {
|
|
721
|
+
// Clean expired keys from both repositories
|
|
481
722
|
await this.rateLimitRepo.delete({
|
|
482
723
|
expiresAt: (0, typeorm_1.LessThan)(new Date()),
|
|
483
724
|
});
|
|
@@ -489,7 +730,11 @@ class DatabaseStorageAdapter {
|
|
|
489
730
|
this.logger?.error?.('Failed to cleanup expired keys:', error);
|
|
490
731
|
}
|
|
491
732
|
}
|
|
733
|
+
/**
|
|
734
|
+
* Disconnect from storage (no-op for database adapter)
|
|
735
|
+
*/
|
|
492
736
|
async disconnect() {
|
|
737
|
+
// Database connection is managed by TypeORM, no explicit disconnect needed
|
|
493
738
|
}
|
|
494
739
|
}
|
|
495
740
|
exports.DatabaseStorageAdapter = DatabaseStorageAdapter;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"database-storage.adapter.js","sourceRoot":"","sources":["../src/database-storage.adapter.ts"],"names":[],"mappings":";;;AAAA,qCAA+C;AAwC/C,MAAa,sBAAsB;IAUvB;IACA;IACA;IAHV,YACU,aAA+C,EAC/C,eAAmD,EACnD,MAAsB;QAFtB,kBAAa,GAAb,aAAa,CAAkC;QAC/C,oBAAe,GAAf,eAAe,CAAoC;QACnD,WAAM,GAAN,MAAM,CAAgB;IAKhC,CAAC;IASD,eAAe,CAAC,aAAwC,EAAE,eAA4C;QACpG,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;QACnC,IAAI,CAAC,eAAe,GAAG,eAAe,CAAC;IACzC,CAAC;IAUO,mBAAmB,CAAC,GAAW;QAErC,IAAI,GAAG,CAAC,UAAU,CAAC,eAAe,CAAC,IAAI,GAAG,CAAC,UAAU,CAAC,aAAa,CAAC,IAAI,GAAG,CAAC,UAAU,CAAC,kBAAkB,CAAC,EAAE,CAAC;YAC3G,OAAO,IAAI,CAAC,eAAgB,CAAC;QAC/B,CAAC;QAED,OAAO,IAAI,CAAC,aAAc,CAAC;IAC7B,CAAC;IAQD,KAAK,CAAC,UAAU;QACd,IAAI,CAAC,IAAI,CAAC,aAAa,IAAI,CAAC,IAAI,CAAC,eAAe,EAAE,CAAC;YACjD,MAAM,IAAI,KAAK,CACb,2FAA2F;gBACzF,8DAA8D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CAAC,eAAgB,CAAC,MAAM,CAAC;gBACjC,SAAS,EAAE,IAAA,kBAAQ,EAAC,IAAI,IAAI,EAAE,CAAC;aAChC,CAAC,CAAC;QACL,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,CAAC,MAAM,EAAE,KAAK,EAAE,CAAC,iCAAiC,EAAE,KAAK,CAAC,CAAC;QACjE,CAAC;IACH,CAAC;IAKD,KAAK,CAAC,UAAU;IAEhB,CAAC;CACF;AA1vBD,wDA0vBC"}
|
|
1
|
+
{"version":3,"file":"database-storage.adapter.js","sourceRoot":"","sources":["../src/database-storage.adapter.ts"],"names":[],"mappings":";;;AAAA,qCAA+C;AAK/C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAEH,MAAa,sBAAsB;IAUvB;IACA;IACA;IAXV;;;;;;;OAOG;IACH,YACU,aAA+C,EAC/C,eAAmD,EACnD,MAAsB;QAFtB,kBAAa,GAAb,aAAa,CAAkC;QAC/C,oBAAe,GAAf,eAAe,CAAoC;QACnD,WAAM,GAAN,MAAM,CAAgB;QAE9B,4DAA4D;QAC5D,kEAAkE;QAClE,sEAAsE;IACxE,CAAC;IAED;;;;;;OAMG;IACH,eAAe,CAAC,aAAwC,EAAE,eAA4C;QACpG,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;QACnC,IAAI,CAAC,eAAe,GAAG,eAAe,CAAC;IACzC,CAAC;IAED;;;;;;;OAOG;IACK,mBAAmB,CAAC,GAAW;QACrC,2EAA2E;QAC3E,IAAI,GAAG,CAAC,UAAU,CAAC,eAAe,CAAC,IAAI,GAAG,CAAC,UAAU,CAAC,aAAa,CAAC,IAAI,GAAG,CAAC,UAAU,CAAC,kBAAkB,CAAC,EAAE,CAAC;YAC3G,OAAO,IAAI,CAAC,eAAgB,CAAC;QAC/B,CAAC;QACD,kGAAkG;QAClG,OAAO,IAAI,CAAC,aAAc,CAAC;IAC7B,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAA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,CAAC,CAAC;YACvE,OAAO,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;QACjB,CAAC;IACH,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,OAAO;QACX,IAAI,CAAC;YACH,4CAA4C;YAC5C,MAAM,IAAI,CAAC,aAAc,CAAC,MAAM,CAAC;gBAC/B,SAAS,EAAE,IAAA,kBAAQ,EAAC,IAAI,IAAI,EAAE,CAAC;aAChC,CAAC,CAAC;YACH,MAAM,IAAI,CAAC,eAAgB,CAAC,MAAM,CAAC;gBACjC,SAAS,EAAE,IAAA,kBAAQ,EAAC,IAAI,IAAI,EAAE,CAAC;aAChC,CAAC,CAAC;QACL,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,CAAC,MAAM,EAAE,KAAK,EAAE,CAAC,iCAAiC,EAAE,KAAK,CAAC,CAAC;QACjE,CAAC;IACH,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,UAAU;QACd,2EAA2E;IAC7E,CAAC;CACF;AA1vBD,wDA0vBC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,2 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Database Storage Adapter Package
|
|
3
|
+
*
|
|
4
|
+
* Provides DatabaseStorageAdapter for persistent storage of transient state
|
|
5
|
+
* (rate limits, locks, token reuse tracking) using TypeORM repositories.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* import { DatabaseStorageAdapter } from '@nauth-toolkit/storage-database';
|
|
10
|
+
* import { getNAuthEntities, getNAuthTransientStorageEntities } from '@nauth-toolkit/database-typeorm-postgres';
|
|
11
|
+
*
|
|
12
|
+
* TypeOrmModule.forRoot({
|
|
13
|
+
* entities: [...getNAuthEntities(), ...getNAuthTransientStorageEntities()],
|
|
14
|
+
* });
|
|
15
|
+
*
|
|
16
|
+
* AuthModule.forRoot({
|
|
17
|
+
* storageAdapter: new DatabaseStorageAdapter(), // Uses injected repositories
|
|
18
|
+
* });
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
1
21
|
export { DatabaseStorageAdapter } from './database-storage.adapter';
|
|
2
22
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,24 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Database Storage Adapter Package
|
|
4
|
+
*
|
|
5
|
+
* Provides DatabaseStorageAdapter for persistent storage of transient state
|
|
6
|
+
* (rate limits, locks, token reuse tracking) using TypeORM repositories.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* import { DatabaseStorageAdapter } from '@nauth-toolkit/storage-database';
|
|
11
|
+
* import { getNAuthEntities, getNAuthTransientStorageEntities } from '@nauth-toolkit/database-typeorm-postgres';
|
|
12
|
+
*
|
|
13
|
+
* TypeOrmModule.forRoot({
|
|
14
|
+
* entities: [...getNAuthEntities(), ...getNAuthTransientStorageEntities()],
|
|
15
|
+
* });
|
|
16
|
+
*
|
|
17
|
+
* AuthModule.forRoot({
|
|
18
|
+
* storageAdapter: new DatabaseStorageAdapter(), // Uses injected repositories
|
|
19
|
+
* });
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
2
22
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
23
|
exports.DatabaseStorageAdapter = void 0;
|
|
4
24
|
var database_storage_adapter_1 = require("./database-storage.adapter");
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;GAmBG;;;AAEH,uEAAoE;AAA3D,kIAAA,sBAAsB,OAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nauth-toolkit/storage-database",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.18",
|
|
4
4
|
"description": "Database storage adapter for nauth-toolkit using TypeORM",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"format:check": "prettier --check \"src/**/*.ts\""
|
|
15
15
|
},
|
|
16
16
|
"peerDependencies": {
|
|
17
|
-
"@nauth-toolkit/core": "^0.1.
|
|
17
|
+
"@nauth-toolkit/core": "^0.1.18",
|
|
18
18
|
"typeorm": "^0.3.0"
|
|
19
19
|
},
|
|
20
20
|
"devDependencies": {
|