guardian-risk-express 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 +21 -0
- package/README.md +39 -0
- package/dist/index.cjs +19 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +22 -0
- package/dist/index.d.ts +22 -0
- package/dist/index.js +16 -0
- package/dist/index.js.map +1 -0
- package/package.json +69 -0
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,39 @@
|
|
|
1
|
+
# guardian-risk-express
|
|
2
|
+
|
|
3
|
+
> **Requires:** [`guardian-risk`](https://www.npmjs.com/package/guardian-risk) (core)
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
npm install guardian-risk guardian-risk-express
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
> **Stub package** — API may change before `1.0.0`.
|
|
10
|
+
|
|
11
|
+
Express integration for [guardian-risk](https://www.npmjs.com/package/guardian-risk). Reads HTTP request data and adds risk signals.
|
|
12
|
+
|
|
13
|
+
## Planned signals
|
|
14
|
+
|
|
15
|
+
| Signal | Source |
|
|
16
|
+
|--------|--------|
|
|
17
|
+
| `clientIp` | `req.ip` / forwarded headers |
|
|
18
|
+
| `userAgent` | `User-Agent` header |
|
|
19
|
+
| `requestMethod` | `req.method` |
|
|
20
|
+
| `requestsPerMinute` | Rate counter (with Redis plugin) |
|
|
21
|
+
|
|
22
|
+
## Usage (stub)
|
|
23
|
+
|
|
24
|
+
```typescript
|
|
25
|
+
import { Guardian } from 'guardian-risk';
|
|
26
|
+
import { expressPlugin, fromRequest } from 'guardian-risk-express';
|
|
27
|
+
|
|
28
|
+
const guardian = new Guardian().use(expressPlugin({ trustProxy: true }));
|
|
29
|
+
|
|
30
|
+
// Future: per-request signal injection
|
|
31
|
+
// app.use((req, res, next) => {
|
|
32
|
+
// fromRequest(req, guardian);
|
|
33
|
+
// next();
|
|
34
|
+
// });
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Status
|
|
38
|
+
|
|
39
|
+
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 expressPlugin(options = {}) {
|
|
5
|
+
const { trustProxy = false } = options;
|
|
6
|
+
return {
|
|
7
|
+
name: "guardian-risk-express",
|
|
8
|
+
install(_guardian) {
|
|
9
|
+
}
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
function fromRequest(_req, guardian) {
|
|
13
|
+
return guardian.signal("requestSource", "express").signal("expressPlugin", "stub");
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
exports.expressPlugin = expressPlugin;
|
|
17
|
+
exports.fromRequest = fromRequest;
|
|
18
|
+
//# sourceMappingURL=index.cjs.map
|
|
19
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"names":[],"mappings":";;;AAeO,SAAS,aAAA,CAAc,OAAA,GAAgC,EAAC,EAAW;AACxE,EAAA,MAAM,EAAE,UAAA,GAAa,KAAA,EAAM,GAAI,OAAA;AAE/B,EAAA,OAAO;AAAA,IACL,IAAA,EAAM,uBAAA;AAAA,IACN,QAAQ,SAAA,EAAW;AACZ,IAEP;AAAA,GACF;AACF;AAKO,SAAS,WAAA,CACd,MACA,QAAA,EACkC;AAClC,EAAA,OAAO,SACJ,MAAA,CAAO,eAAA,EAAiB,SAAS,CAAA,CACjC,MAAA,CAAO,iBAAiB,MAAM,CAAA;AACnC","file":"index.cjs","sourcesContent":["import type { Plugin } from 'guardian-risk';\n\n/** Options for the Express plugin (stub). */\nexport interface ExpressPluginOptions {\n /** Trust X-Forwarded-* headers when reading client IP. */\n readonly trustProxy?: boolean;\n}\n\n/**\n * Express plugin for guardian-risk.\n *\n * @stub This plugin is a stub. Future versions will read Express requests\n * and add signals such as `clientIp`, `userAgent`, `requestMethod`, and\n * `requestsPerMinute`.\n */\nexport function expressPlugin(options: ExpressPluginOptions = {}): Plugin {\n const { trustProxy = false } = options;\n\n return {\n name: 'guardian-risk-express',\n install(_guardian) {\n void trustProxy;\n // Stub: middleware will attach signals from req before analyze()\n },\n };\n}\n\n/**\n * @stub Future middleware that enriches a Guardian instance from an Express request.\n */\nexport function fromRequest(\n _req: unknown,\n guardian: import('guardian-risk').Guardian,\n): import('guardian-risk').Guardian {\n return guardian\n .signal('requestSource', 'express')\n .signal('expressPlugin', 'stub');\n}\n"]}
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import * as guardian_risk from 'guardian-risk';
|
|
2
|
+
import { Plugin } from 'guardian-risk';
|
|
3
|
+
|
|
4
|
+
/** Options for the Express plugin (stub). */
|
|
5
|
+
interface ExpressPluginOptions {
|
|
6
|
+
/** Trust X-Forwarded-* headers when reading client IP. */
|
|
7
|
+
readonly trustProxy?: boolean;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Express plugin for guardian-risk.
|
|
11
|
+
*
|
|
12
|
+
* @stub This plugin is a stub. Future versions will read Express requests
|
|
13
|
+
* and add signals such as `clientIp`, `userAgent`, `requestMethod`, and
|
|
14
|
+
* `requestsPerMinute`.
|
|
15
|
+
*/
|
|
16
|
+
declare function expressPlugin(options?: ExpressPluginOptions): Plugin;
|
|
17
|
+
/**
|
|
18
|
+
* @stub Future middleware that enriches a Guardian instance from an Express request.
|
|
19
|
+
*/
|
|
20
|
+
declare function fromRequest(_req: unknown, guardian: guardian_risk.Guardian): guardian_risk.Guardian;
|
|
21
|
+
|
|
22
|
+
export { type ExpressPluginOptions, expressPlugin, fromRequest };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import * as guardian_risk from 'guardian-risk';
|
|
2
|
+
import { Plugin } from 'guardian-risk';
|
|
3
|
+
|
|
4
|
+
/** Options for the Express plugin (stub). */
|
|
5
|
+
interface ExpressPluginOptions {
|
|
6
|
+
/** Trust X-Forwarded-* headers when reading client IP. */
|
|
7
|
+
readonly trustProxy?: boolean;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Express plugin for guardian-risk.
|
|
11
|
+
*
|
|
12
|
+
* @stub This plugin is a stub. Future versions will read Express requests
|
|
13
|
+
* and add signals such as `clientIp`, `userAgent`, `requestMethod`, and
|
|
14
|
+
* `requestsPerMinute`.
|
|
15
|
+
*/
|
|
16
|
+
declare function expressPlugin(options?: ExpressPluginOptions): Plugin;
|
|
17
|
+
/**
|
|
18
|
+
* @stub Future middleware that enriches a Guardian instance from an Express request.
|
|
19
|
+
*/
|
|
20
|
+
declare function fromRequest(_req: unknown, guardian: guardian_risk.Guardian): guardian_risk.Guardian;
|
|
21
|
+
|
|
22
|
+
export { type ExpressPluginOptions, expressPlugin, fromRequest };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// src/index.ts
|
|
2
|
+
function expressPlugin(options = {}) {
|
|
3
|
+
const { trustProxy = false } = options;
|
|
4
|
+
return {
|
|
5
|
+
name: "guardian-risk-express",
|
|
6
|
+
install(_guardian) {
|
|
7
|
+
}
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
function fromRequest(_req, guardian) {
|
|
11
|
+
return guardian.signal("requestSource", "express").signal("expressPlugin", "stub");
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export { expressPlugin, fromRequest };
|
|
15
|
+
//# sourceMappingURL=index.js.map
|
|
16
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"names":[],"mappings":";AAeO,SAAS,aAAA,CAAc,OAAA,GAAgC,EAAC,EAAW;AACxE,EAAA,MAAM,EAAE,UAAA,GAAa,KAAA,EAAM,GAAI,OAAA;AAE/B,EAAA,OAAO;AAAA,IACL,IAAA,EAAM,uBAAA;AAAA,IACN,QAAQ,SAAA,EAAW;AACZ,IAEP;AAAA,GACF;AACF;AAKO,SAAS,WAAA,CACd,MACA,QAAA,EACkC;AAClC,EAAA,OAAO,SACJ,MAAA,CAAO,eAAA,EAAiB,SAAS,CAAA,CACjC,MAAA,CAAO,iBAAiB,MAAM,CAAA;AACnC","file":"index.js","sourcesContent":["import type { Plugin } from 'guardian-risk';\n\n/** Options for the Express plugin (stub). */\nexport interface ExpressPluginOptions {\n /** Trust X-Forwarded-* headers when reading client IP. */\n readonly trustProxy?: boolean;\n}\n\n/**\n * Express plugin for guardian-risk.\n *\n * @stub This plugin is a stub. Future versions will read Express requests\n * and add signals such as `clientIp`, `userAgent`, `requestMethod`, and\n * `requestsPerMinute`.\n */\nexport function expressPlugin(options: ExpressPluginOptions = {}): Plugin {\n const { trustProxy = false } = options;\n\n return {\n name: 'guardian-risk-express',\n install(_guardian) {\n void trustProxy;\n // Stub: middleware will attach signals from req before analyze()\n },\n };\n}\n\n/**\n * @stub Future middleware that enriches a Guardian instance from an Express request.\n */\nexport function fromRequest(\n _req: unknown,\n guardian: import('guardian-risk').Guardian,\n): import('guardian-risk').Guardian {\n return guardian\n .signal('requestSource', 'express')\n .signal('expressPlugin', 'stub');\n}\n"]}
|
package/package.json
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "guardian-risk-express",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Express middleware plugin for guardian-risk — adds request signals",
|
|
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-express",
|
|
33
|
+
"express",
|
|
34
|
+
"middleware",
|
|
35
|
+
"risk",
|
|
36
|
+
"security"
|
|
37
|
+
],
|
|
38
|
+
"license": "MIT",
|
|
39
|
+
"repository": {
|
|
40
|
+
"type": "git",
|
|
41
|
+
"url": "git+https://github.com/himanshu6306singh/guardian-risk.git",
|
|
42
|
+
"directory": "packages/express"
|
|
43
|
+
},
|
|
44
|
+
"homepage": "https://github.com/himanshu6306singh/guardian-risk/tree/main/packages/express#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
|
+
"express": ">=4"
|
|
54
|
+
},
|
|
55
|
+
"peerDependenciesMeta": {
|
|
56
|
+
"express": {
|
|
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
|
+
}
|