guardian-risk-redis 0.1.0

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 ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Guardian Contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,38 @@
1
+ # guardian-risk-redis
2
+
3
+ > **Requires:** [`guardian-risk`](https://www.npmjs.com/package/guardian-risk) (core)
4
+
5
+ ```bash
6
+ npm install guardian-risk guardian-risk-redis
7
+ ```
8
+
9
+ > **Stub package** — API may change before `1.0.0`.
10
+
11
+ Redis integration for [guardian-risk](https://www.npmjs.com/package/guardian-risk). Stores events and exposes session-based counters as signals.
12
+
13
+ ## Planned signals
14
+
15
+ | Signal | Source |
16
+ |--------|--------|
17
+ | `requestsPerMinute` | Sliding window counter |
18
+ | `sessionAge` | First-seen timestamp |
19
+ | `failedLoginCount` | Incremented on auth failures |
20
+ | `uniqueIpsPerSession` | HyperLogLog or set cardinality |
21
+
22
+ ## Usage (stub)
23
+
24
+ ```typescript
25
+ import { Guardian } from 'guardian-risk';
26
+ import { redisPlugin, loadSessionSignals } from 'guardian-risk-redis';
27
+
28
+ const guardian = new Guardian().use(
29
+ redisPlugin({ url: process.env.REDIS_URL, keyPrefix: 'app:risk:' }),
30
+ );
31
+
32
+ await loadSessionSignals('session-123', guardian);
33
+ const report = guardian.analyze();
34
+ ```
35
+
36
+ ## Status
37
+
38
+ Not yet published. Implementation in progress.
package/dist/index.cjs ADDED
@@ -0,0 +1,19 @@
1
+ 'use strict';
2
+
3
+ // src/index.ts
4
+ function redisPlugin(options = {}) {
5
+ const { url = "redis://localhost:6379", keyPrefix = "guardian:" } = options;
6
+ return {
7
+ name: "guardian-risk-redis",
8
+ install(_guardian) {
9
+ }
10
+ };
11
+ }
12
+ async function loadSessionSignals(_sessionId, guardian) {
13
+ return guardian.signal("signalSource", "redis").signal("redisPlugin", "stub");
14
+ }
15
+
16
+ exports.loadSessionSignals = loadSessionSignals;
17
+ exports.redisPlugin = redisPlugin;
18
+ //# sourceMappingURL=index.cjs.map
19
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts"],"names":[],"mappings":";;;AAgBO,SAAS,WAAA,CAAY,OAAA,GAA8B,EAAC,EAAW;AACpE,EAAA,MAAM,EAAE,GAAA,GAAM,wBAAA,EAA0B,SAAA,GAAY,aAAY,GAAI,OAAA;AAEpE,EAAA,OAAO;AAAA,IACL,IAAA,EAAM,qBAAA;AAAA,IACN,QAAQ,SAAA,EAAW;AAEZ,IAEP;AAAA,GACF;AACF;AAKA,eAAsB,kBAAA,CACpB,YACA,QAAA,EAC2C;AAC3C,EAAA,OAAO,SACJ,MAAA,CAAO,cAAA,EAAgB,OAAO,CAAA,CAC9B,MAAA,CAAO,eAAe,MAAM,CAAA;AACjC","file":"index.cjs","sourcesContent":["import type { Plugin } from 'guardian-risk';\n\n/** Options for the Redis plugin (stub). */\nexport interface RedisPluginOptions {\n /** Redis connection URL. */\n readonly url?: string;\n /** Key prefix for Guardian counters. */\n readonly keyPrefix?: string;\n}\n\n/**\n * Redis plugin for guardian-risk.\n *\n * @stub Future versions will read/write session counters in Redis and\n * expose signals like `requestsPerMinute` and `sessionAge`.\n */\nexport function redisPlugin(options: RedisPluginOptions = {}): Plugin {\n const { url = 'redis://localhost:6379', keyPrefix = 'guardian:' } = options;\n\n return {\n name: 'guardian-risk-redis',\n install(_guardian) {\n void url;\n void keyPrefix;\n // Stub: will connect to Redis and sync counters into signals\n },\n };\n}\n\n/**\n * @stub Future helper to load session counters from Redis into signals.\n */\nexport async function loadSessionSignals(\n _sessionId: string,\n guardian: import('guardian-risk').Guardian,\n): Promise<import('guardian-risk').Guardian> {\n return guardian\n .signal('signalSource', 'redis')\n .signal('redisPlugin', 'stub');\n}\n"]}
@@ -0,0 +1,23 @@
1
+ import * as guardian_risk from 'guardian-risk';
2
+ import { Plugin } from 'guardian-risk';
3
+
4
+ /** Options for the Redis plugin (stub). */
5
+ interface RedisPluginOptions {
6
+ /** Redis connection URL. */
7
+ readonly url?: string;
8
+ /** Key prefix for Guardian counters. */
9
+ readonly keyPrefix?: string;
10
+ }
11
+ /**
12
+ * Redis plugin for guardian-risk.
13
+ *
14
+ * @stub Future versions will read/write session counters in Redis and
15
+ * expose signals like `requestsPerMinute` and `sessionAge`.
16
+ */
17
+ declare function redisPlugin(options?: RedisPluginOptions): Plugin;
18
+ /**
19
+ * @stub Future helper to load session counters from Redis into signals.
20
+ */
21
+ declare function loadSessionSignals(_sessionId: string, guardian: guardian_risk.Guardian): Promise<guardian_risk.Guardian>;
22
+
23
+ export { type RedisPluginOptions, loadSessionSignals, redisPlugin };
@@ -0,0 +1,23 @@
1
+ import * as guardian_risk from 'guardian-risk';
2
+ import { Plugin } from 'guardian-risk';
3
+
4
+ /** Options for the Redis plugin (stub). */
5
+ interface RedisPluginOptions {
6
+ /** Redis connection URL. */
7
+ readonly url?: string;
8
+ /** Key prefix for Guardian counters. */
9
+ readonly keyPrefix?: string;
10
+ }
11
+ /**
12
+ * Redis plugin for guardian-risk.
13
+ *
14
+ * @stub Future versions will read/write session counters in Redis and
15
+ * expose signals like `requestsPerMinute` and `sessionAge`.
16
+ */
17
+ declare function redisPlugin(options?: RedisPluginOptions): Plugin;
18
+ /**
19
+ * @stub Future helper to load session counters from Redis into signals.
20
+ */
21
+ declare function loadSessionSignals(_sessionId: string, guardian: guardian_risk.Guardian): Promise<guardian_risk.Guardian>;
22
+
23
+ export { type RedisPluginOptions, loadSessionSignals, redisPlugin };
package/dist/index.js ADDED
@@ -0,0 +1,16 @@
1
+ // src/index.ts
2
+ function redisPlugin(options = {}) {
3
+ const { url = "redis://localhost:6379", keyPrefix = "guardian:" } = options;
4
+ return {
5
+ name: "guardian-risk-redis",
6
+ install(_guardian) {
7
+ }
8
+ };
9
+ }
10
+ async function loadSessionSignals(_sessionId, guardian) {
11
+ return guardian.signal("signalSource", "redis").signal("redisPlugin", "stub");
12
+ }
13
+
14
+ export { loadSessionSignals, redisPlugin };
15
+ //# sourceMappingURL=index.js.map
16
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts"],"names":[],"mappings":";AAgBO,SAAS,WAAA,CAAY,OAAA,GAA8B,EAAC,EAAW;AACpE,EAAA,MAAM,EAAE,GAAA,GAAM,wBAAA,EAA0B,SAAA,GAAY,aAAY,GAAI,OAAA;AAEpE,EAAA,OAAO;AAAA,IACL,IAAA,EAAM,qBAAA;AAAA,IACN,QAAQ,SAAA,EAAW;AAEZ,IAEP;AAAA,GACF;AACF;AAKA,eAAsB,kBAAA,CACpB,YACA,QAAA,EAC2C;AAC3C,EAAA,OAAO,SACJ,MAAA,CAAO,cAAA,EAAgB,OAAO,CAAA,CAC9B,MAAA,CAAO,eAAe,MAAM,CAAA;AACjC","file":"index.js","sourcesContent":["import type { Plugin } from 'guardian-risk';\n\n/** Options for the Redis plugin (stub). */\nexport interface RedisPluginOptions {\n /** Redis connection URL. */\n readonly url?: string;\n /** Key prefix for Guardian counters. */\n readonly keyPrefix?: string;\n}\n\n/**\n * Redis plugin for guardian-risk.\n *\n * @stub Future versions will read/write session counters in Redis and\n * expose signals like `requestsPerMinute` and `sessionAge`.\n */\nexport function redisPlugin(options: RedisPluginOptions = {}): Plugin {\n const { url = 'redis://localhost:6379', keyPrefix = 'guardian:' } = options;\n\n return {\n name: 'guardian-risk-redis',\n install(_guardian) {\n void url;\n void keyPrefix;\n // Stub: will connect to Redis and sync counters into signals\n },\n };\n}\n\n/**\n * @stub Future helper to load session counters from Redis into signals.\n */\nexport async function loadSessionSignals(\n _sessionId: string,\n guardian: import('guardian-risk').Guardian,\n): Promise<import('guardian-risk').Guardian> {\n return guardian\n .signal('signalSource', 'redis')\n .signal('redisPlugin', 'stub');\n}\n"]}
package/package.json ADDED
@@ -0,0 +1,69 @@
1
+ {
2
+ "name": "guardian-risk-redis",
3
+ "version": "0.1.0",
4
+ "description": "Redis plugin for guardian-risk — session counters and event history",
5
+ "type": "module",
6
+ "main": "./dist/index.cjs",
7
+ "module": "./dist/index.js",
8
+ "types": "./dist/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "import": {
12
+ "types": "./dist/index.d.ts",
13
+ "default": "./dist/index.js"
14
+ },
15
+ "require": {
16
+ "types": "./dist/index.d.cts",
17
+ "default": "./dist/index.cjs"
18
+ }
19
+ }
20
+ },
21
+ "sideEffects": false,
22
+ "files": [
23
+ "dist",
24
+ "README.md",
25
+ "LICENSE"
26
+ ],
27
+ "engines": {
28
+ "node": ">=20"
29
+ },
30
+ "keywords": [
31
+ "guardian-risk",
32
+ "guardian-risk-redis",
33
+ "redis",
34
+ "session",
35
+ "rate-limit",
36
+ "risk"
37
+ ],
38
+ "license": "MIT",
39
+ "repository": {
40
+ "type": "git",
41
+ "url": "git+https://github.com/himanshu6306singh/guardian-risk.git",
42
+ "directory": "packages/redis"
43
+ },
44
+ "homepage": "https://github.com/himanshu6306singh/guardian-risk/tree/main/packages/redis#readme",
45
+ "bugs": {
46
+ "url": "https://github.com/himanshu6306singh/guardian-risk/issues"
47
+ },
48
+ "publishConfig": {
49
+ "access": "public"
50
+ },
51
+ "peerDependencies": {
52
+ "guardian-risk": "^0.2.0",
53
+ "ioredis": ">=5"
54
+ },
55
+ "peerDependenciesMeta": {
56
+ "ioredis": {
57
+ "optional": true
58
+ }
59
+ },
60
+ "devDependencies": {
61
+ "tsup": "^8.3.5",
62
+ "typescript": "^5.7.2",
63
+ "guardian-risk": "0.2.0"
64
+ },
65
+ "scripts": {
66
+ "build": "tsup",
67
+ "typecheck": "tsc --noEmit"
68
+ }
69
+ }