@wazobiatech/auth-middleware 1.0.5 → 1.0.7
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/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/utils/index.d.ts +2 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +18 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/redis.connection.d.ts +5 -2
- package/dist/utils/redis.connection.d.ts.map +1 -1
- package/dist/utils/redis.connection.js +45 -7
- package/dist/utils/redis.connection.js.map +1 -1
- package/package.json +15 -1
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,qBAAqB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,qBAAqB,CAAC;AACpC,cAAc,0BAA0B,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -16,4 +16,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./middlewares"), exports);
|
|
18
18
|
__exportStar(require("./types/jwt-payload"), exports);
|
|
19
|
+
__exportStar(require("./utils/redis.connection"), exports);
|
|
19
20
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,gDAA8B;AAC9B,sDAAoC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,gDAA8B;AAC9B,sDAAoC;AACpC,2DAAwC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./redis.connection"), exports);
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,qDAAmC"}
|
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { createClient } from "redis";
|
|
2
|
+
import "dotenv/config";
|
|
3
|
+
type RedisClient = ReturnType<typeof createClient>;
|
|
2
4
|
declare class RedisConnectionManager {
|
|
3
5
|
private static instance;
|
|
6
|
+
private static connecting;
|
|
4
7
|
private constructor();
|
|
5
|
-
static getInstance(): Promise<
|
|
8
|
+
static getInstance(): Promise<RedisClient>;
|
|
6
9
|
static closeConnection(): Promise<void>;
|
|
7
10
|
}
|
|
8
11
|
export default RedisConnectionManager;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"redis.connection.d.ts","sourceRoot":"","sources":["../../src/utils/redis.connection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"redis.connection.d.ts","sourceRoot":"","sources":["../../src/utils/redis.connection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AACrC,OAAO,eAAe,CAAC;AAEvB,KAAK,WAAW,GAAG,UAAU,CAAC,OAAO,YAAY,CAAC,CAAC;AAEnD,cAAM,sBAAsB;IAC1B,OAAO,CAAC,MAAM,CAAC,QAAQ,CAA4B;IACnD,OAAO,CAAC,MAAM,CAAC,UAAU,CAAqC;IAE9D,OAAO;WAEa,WAAW,IAAI,OAAO,CAAC,WAAW,CAAC;WAyDnC,eAAe,IAAI,OAAO,CAAC,IAAI,CAAC;CAOrD;AAED,eAAe,sBAAsB,CAAC"}
|
|
@@ -1,27 +1,65 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const redis_1 = require("redis");
|
|
4
|
+
require("dotenv/config");
|
|
4
5
|
class RedisConnectionManager {
|
|
5
6
|
constructor() { }
|
|
6
7
|
static async getInstance() {
|
|
7
|
-
|
|
8
|
-
|
|
8
|
+
// If already connected, return immediately
|
|
9
|
+
if (RedisConnectionManager.instance) {
|
|
10
|
+
return RedisConnectionManager.instance;
|
|
11
|
+
}
|
|
12
|
+
// If currently connecting, wait for that connection
|
|
13
|
+
if (RedisConnectionManager.connecting) {
|
|
14
|
+
return RedisConnectionManager.connecting;
|
|
15
|
+
}
|
|
16
|
+
// Start new connection
|
|
17
|
+
RedisConnectionManager.connecting = (async () => {
|
|
18
|
+
const client = (0, redis_1.createClient)({
|
|
9
19
|
url: process.env.REDIS_URL,
|
|
20
|
+
socket: {
|
|
21
|
+
// Add connection timeout
|
|
22
|
+
connectTimeout: 10000,
|
|
23
|
+
// Keep alive to prevent idle disconnections
|
|
24
|
+
keepAlive: true,
|
|
25
|
+
// Reconnect strategy
|
|
26
|
+
reconnectStrategy: (retries) => {
|
|
27
|
+
if (retries > 10) {
|
|
28
|
+
console.error("Redis: Too many retries, giving up");
|
|
29
|
+
return new Error("Too many retries");
|
|
30
|
+
}
|
|
31
|
+
return Math.min(retries * 100, 3000);
|
|
32
|
+
},
|
|
33
|
+
},
|
|
10
34
|
});
|
|
11
|
-
|
|
12
|
-
|
|
35
|
+
client.on("error", (error) => {
|
|
36
|
+
console.error("Redis connection error:", error);
|
|
13
37
|
});
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
38
|
+
client.on("connect", () => {
|
|
39
|
+
console.log("Redis client connected");
|
|
40
|
+
});
|
|
41
|
+
client.on("ready", () => {
|
|
42
|
+
console.log("Redis client ready");
|
|
43
|
+
});
|
|
44
|
+
client.on("reconnecting", () => {
|
|
45
|
+
console.log("Redis client reconnecting");
|
|
46
|
+
});
|
|
47
|
+
await client.connect();
|
|
48
|
+
RedisConnectionManager.instance = client;
|
|
49
|
+
RedisConnectionManager.connecting = null;
|
|
50
|
+
return client;
|
|
51
|
+
})();
|
|
52
|
+
return RedisConnectionManager.connecting;
|
|
17
53
|
}
|
|
18
54
|
static async closeConnection() {
|
|
19
55
|
if (RedisConnectionManager.instance) {
|
|
20
56
|
await RedisConnectionManager.instance.quit();
|
|
21
57
|
RedisConnectionManager.instance = null;
|
|
58
|
+
RedisConnectionManager.connecting = null;
|
|
22
59
|
}
|
|
23
60
|
}
|
|
24
61
|
}
|
|
25
62
|
RedisConnectionManager.instance = null;
|
|
63
|
+
RedisConnectionManager.connecting = null;
|
|
26
64
|
exports.default = RedisConnectionManager;
|
|
27
65
|
//# sourceMappingURL=redis.connection.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"redis.connection.js","sourceRoot":"","sources":["../../src/utils/redis.connection.ts"],"names":[],"mappings":";;AAAA,
|
|
1
|
+
{"version":3,"file":"redis.connection.js","sourceRoot":"","sources":["../../src/utils/redis.connection.ts"],"names":[],"mappings":";;AAAA,iCAAqC;AACrC,yBAAuB;AAIvB,MAAM,sBAAsB;IAI1B,gBAAuB,CAAC;IAEjB,MAAM,CAAC,KAAK,CAAC,WAAW;QAC7B,2CAA2C;QAC3C,IAAI,sBAAsB,CAAC,QAAQ,EAAE,CAAC;YACpC,OAAO,sBAAsB,CAAC,QAAQ,CAAC;QACzC,CAAC;QAED,oDAAoD;QACpD,IAAI,sBAAsB,CAAC,UAAU,EAAE,CAAC;YACtC,OAAO,sBAAsB,CAAC,UAAU,CAAC;QAC3C,CAAC;QAED,uBAAuB;QACvB,sBAAsB,CAAC,UAAU,GAAG,CAAC,KAAK,IAAI,EAAE;YAC9C,MAAM,MAAM,GAAG,IAAA,oBAAY,EAAC;gBAC1B,GAAG,EAAE,OAAO,CAAC,GAAG,CAAC,SAAmB;gBACpC,MAAM,EAAE;oBACN,yBAAyB;oBACzB,cAAc,EAAE,KAAK;oBACrB,4CAA4C;oBAC5C,SAAS,EAAE,IAAI;oBACf,qBAAqB;oBACrB,iBAAiB,EAAE,CAAC,OAAO,EAAE,EAAE;wBAC7B,IAAI,OAAO,GAAG,EAAE,EAAE,CAAC;4BACjB,OAAO,CAAC,KAAK,CAAC,oCAAoC,CAAC,CAAC;4BACpD,OAAO,IAAI,KAAK,CAAC,kBAAkB,CAAC,CAAC;wBACvC,CAAC;wBACD,OAAO,IAAI,CAAC,GAAG,CAAC,OAAO,GAAG,GAAG,EAAE,IAAI,CAAC,CAAC;oBACvC,CAAC;iBACF;aACF,CAAC,CAAC;YAEH,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,K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
|
4
4
|
"description": "Framework-agnostic JWT authentication library for Wazobia microservices platform",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -65,6 +65,14 @@
|
|
|
65
65
|
"./nestjs": {
|
|
66
66
|
"types": "./dist/nestjs/index.d.ts",
|
|
67
67
|
"default": "./dist/nestjs/index.js"
|
|
68
|
+
},
|
|
69
|
+
"./utils": {
|
|
70
|
+
"types": "./dist/utils/index.d.ts",
|
|
71
|
+
"default": "./dist/utils/index.js"
|
|
72
|
+
},
|
|
73
|
+
"./utils/redis.connection": {
|
|
74
|
+
"types": "./dist/utils/redis.connection.d.ts",
|
|
75
|
+
"default": "./dist/utils/redis.connection.js"
|
|
68
76
|
}
|
|
69
77
|
},
|
|
70
78
|
"typesVersions": {
|
|
@@ -74,6 +82,12 @@
|
|
|
74
82
|
],
|
|
75
83
|
"nestjs": [
|
|
76
84
|
"dist/nestjs/index.d.ts"
|
|
85
|
+
],
|
|
86
|
+
"utils": [
|
|
87
|
+
"dist/utils/index.d.ts"
|
|
88
|
+
],
|
|
89
|
+
"utils/redis.connection": [
|
|
90
|
+
"dist/utils/redis.connection.d.ts"
|
|
77
91
|
]
|
|
78
92
|
}
|
|
79
93
|
},
|