@riavzon/bot-detector 1.0.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 +202 -0
- package/README.md +512 -0
- package/dist/_data-sources/suffix.json +98 -0
- package/dist/chunk-C0xms8kb.cjs +34 -0
- package/dist/index.mjs +776 -0
- package/dist/index.mjs.map +1 -0
- package/dist/main.cjs +3236 -0
- package/dist/main.cjs.map +1 -0
- package/dist/main.d.cts +1606 -0
- package/dist/main.d.cts.map +1 -0
- package/dist/main.d.mts +1607 -0
- package/dist/main.d.mts.map +1 -0
- package/dist/main.mjs +3210 -0
- package/dist/main.mjs.map +1 -0
- package/dist/mysqlPoolConnector-9PtXF5E7.mjs +49 -0
- package/dist/mysqlPoolConnector-9PtXF5E7.mjs.map +1 -0
- package/dist/mysqlPoolConnector-D1eVEhRK.cjs +51 -0
- package/dist/mysqlPoolConnector-D1eVEhRK.cjs.map +1 -0
- package/package.json +104 -0
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
const require_chunk = require('./chunk-C0xms8kb.cjs');
|
|
2
|
+
let mysql2_promise = require("mysql2/promise");
|
|
3
|
+
mysql2_promise = require_chunk.__toESM(mysql2_promise);
|
|
4
|
+
let db0_connectors__internal_statement = require("db0/connectors/_internal/statement");
|
|
5
|
+
|
|
6
|
+
//#region src/botDetector/config/mysqlPoolConnector.ts
|
|
7
|
+
function mysqlPoolConnector(opts) {
|
|
8
|
+
let _pool;
|
|
9
|
+
const getPool = () => {
|
|
10
|
+
if (_pool) return _pool;
|
|
11
|
+
_pool = mysql2_promise.default.createPool({ ...opts });
|
|
12
|
+
return _pool;
|
|
13
|
+
};
|
|
14
|
+
const query = async (sql, params) => {
|
|
15
|
+
return (await getPool().query(sql, params))[0];
|
|
16
|
+
};
|
|
17
|
+
return {
|
|
18
|
+
name: "mysql-pool",
|
|
19
|
+
dialect: "mysql",
|
|
20
|
+
getInstance: () => getPool(),
|
|
21
|
+
exec: (sql) => query(sql),
|
|
22
|
+
prepare: (sql) => new StatementWrapper(sql, query),
|
|
23
|
+
dispose: async () => {
|
|
24
|
+
await _pool?.end();
|
|
25
|
+
_pool = void 0;
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
var StatementWrapper = class extends db0_connectors__internal_statement.BoundableStatement {
|
|
30
|
+
#query;
|
|
31
|
+
#sql;
|
|
32
|
+
constructor(sql, query) {
|
|
33
|
+
super();
|
|
34
|
+
this.#sql = sql;
|
|
35
|
+
this.#query = query;
|
|
36
|
+
}
|
|
37
|
+
async all(...params) {
|
|
38
|
+
return await this.#query(this.#sql, params);
|
|
39
|
+
}
|
|
40
|
+
async run(...params) {
|
|
41
|
+
await this.#query(this.#sql, params);
|
|
42
|
+
return { success: true };
|
|
43
|
+
}
|
|
44
|
+
async get(...params) {
|
|
45
|
+
return (await this.#query(this.#sql, params))[0];
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
//#endregion
|
|
50
|
+
exports.default = mysqlPoolConnector;
|
|
51
|
+
//# sourceMappingURL=mysqlPoolConnector-D1eVEhRK.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mysqlPoolConnector-D1eVEhRK.cjs","names":["mysql","BoundableStatement","#sql","#query"],"sources":["../src/botDetector/config/mysqlPoolConnector.ts"],"sourcesContent":["import mysql from 'mysql2/promise';\nimport type { Connector, Primitive } from \"db0\";\nimport { BoundableStatement } from 'db0/connectors/_internal/statement';\n\nexport type ConnectorOptions = mysql.PoolOptions;\n\ntype InternalQuery = (\n sql: string,\n params?: unknown[],\n) => Promise<mysql.QueryResult>;\n\nexport default function mysqlPoolConnector(opts: ConnectorOptions): Connector<mysql.Pool> {\n let _pool: mysql.Pool | undefined;\n\n const getPool = () => {\n if (_pool) {\n return _pool;\n }\n\n _pool = mysql.createPool({\n ...opts,\n });\n\n return _pool;\n };\n\nconst query: InternalQuery = async (sql, params) => {\n const p = getPool();\n const res = await p.query(sql, params);\n return res[0];\n};\n\n return {\n name: \"mysql-pool\",\n dialect: \"mysql\",\n getInstance: () => getPool(),\n exec: (sql) => query(sql),\n prepare: (sql) => new StatementWrapper(sql, query),\n dispose: async () => {\n await _pool?.end();\n _pool = undefined;\n },\n };\n}\n\nclass StatementWrapper extends BoundableStatement<void> {\n #query: InternalQuery;\n #sql: string;\n\n constructor(sql: string, query: InternalQuery) {\n super();\n this.#sql = sql;\n this.#query = query;\n }\n\n async all(...params: Primitive[]) {\n const res = (await this.#query(this.#sql, params)) as mysql.RowDataPacket[];\n return res;\n }\n\n async run(...params: Primitive[]) {\n await this.#query(this.#sql, params);\n return { success: true };\n }\n\n async get(...params: Primitive[]) {\n const res = (await this.#query(this.#sql, params)) as mysql.RowDataPacket[];\n return res[0];\n }\n}"],"mappings":";;;;;;AAWA,SAAwB,mBAAmB,MAA+C;CACxF,IAAI;CAEF,MAAM,gBAAgB;AAClB,MAAI,MACJ,QAAO;AAGP,UAAQA,uBAAM,WAAW,EACzB,GAAG,MACF,CAAC;AAEF,SAAO;;CAGf,MAAM,QAAuB,OAAO,KAAK,WAAW;AAGhD,UADY,MADF,SAAS,CACC,MAAM,KAAK,OAAO,EAC3B;;AAGb,QAAO;EACL,MAAM;EACN,SAAS;EACT,mBAAmB,SAAS;EAC5B,OAAO,QAAQ,MAAM,IAAI;EACzB,UAAU,QAAQ,IAAI,iBAAiB,KAAK,MAAM;EAClD,SAAS,YAAY;AACnB,SAAM,OAAO,KAAK;AAClB,WAAQ;;EAEX;;AAGH,IAAM,mBAAN,cAA+BC,sDAAyB;CACtD;CACA;CAEA,YAAY,KAAa,OAAsB;AAC7C,SAAO;AACP,QAAKC,MAAO;AACZ,QAAKC,QAAS;;CAGhB,MAAM,IAAI,GAAG,QAAqB;AAEhC,SADa,MAAM,MAAKA,MAAO,MAAKD,KAAM,OAAO;;CAInD,MAAM,IAAI,GAAG,QAAqB;AAChC,QAAM,MAAKC,MAAO,MAAKD,KAAM,OAAO;AACpC,SAAO,EAAE,SAAS,MAAM;;CAG1B,MAAM,IAAI,GAAG,QAAqB;AAEhC,UADa,MAAM,MAAKC,MAAO,MAAKD,KAAM,OAAO,EACtC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@riavzon/bot-detector",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"main": "./dist/main.cjs",
|
|
6
|
+
"types": "./dist/main.d.cts",
|
|
7
|
+
"author": "Sergio contact@riavzon.com",
|
|
8
|
+
"license": "Apache-2.0",
|
|
9
|
+
"description": "Express middleware for multi layered bot detection. Runs a two-phase pipeline of 17 pluggable checkers with a cumulative scoring system, pluggable cache, and multi DB/storage support.",
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "https://github.com/Sergo706/botDetector"
|
|
13
|
+
},
|
|
14
|
+
"homepage": "https://github.com/Sergo706/botDetector#readme",
|
|
15
|
+
"bugs": {
|
|
16
|
+
"url": "https://github.com/Sergo706/botDetector/issues"
|
|
17
|
+
},
|
|
18
|
+
"keywords": [
|
|
19
|
+
"bot-detection",
|
|
20
|
+
"express-middleware",
|
|
21
|
+
"security",
|
|
22
|
+
"geoip",
|
|
23
|
+
"geolocation",
|
|
24
|
+
"threat-intelligence",
|
|
25
|
+
"mmdb",
|
|
26
|
+
"bot detector",
|
|
27
|
+
"detect bots"
|
|
28
|
+
],
|
|
29
|
+
"bin": {
|
|
30
|
+
"bot-detector": "./dist/index.mjs"
|
|
31
|
+
},
|
|
32
|
+
"files": [
|
|
33
|
+
"dist"
|
|
34
|
+
],
|
|
35
|
+
"exports": {
|
|
36
|
+
".": {
|
|
37
|
+
"import": {
|
|
38
|
+
"types": "./dist/main.d.mts",
|
|
39
|
+
"default": "./dist/main.mjs"
|
|
40
|
+
},
|
|
41
|
+
"require": {
|
|
42
|
+
"types": "./dist/main.d.cts",
|
|
43
|
+
"default": "./dist/main.cjs"
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
"scripts": {
|
|
48
|
+
"build": "tsdown",
|
|
49
|
+
"lint": "eslint .",
|
|
50
|
+
"build:tables": "node ./dist/botDetector/db/schema.js",
|
|
51
|
+
"test:exs": "SKIP_STRESS=1 vitest run",
|
|
52
|
+
"test": "vitest run --coverage",
|
|
53
|
+
"postinstall": "node scripts/postinstall.mjs",
|
|
54
|
+
"prepublishOnly": "npm run build",
|
|
55
|
+
"docs:markdown": "typedoc --options ./typedoc.json"
|
|
56
|
+
},
|
|
57
|
+
"dependencies": {
|
|
58
|
+
"@riavzon/shield-base": "^2.0.3",
|
|
59
|
+
"@riavzon/utils": "^1.0.5",
|
|
60
|
+
"citty": "0.2.1",
|
|
61
|
+
"consola": "3.4.2",
|
|
62
|
+
"db0": "0.3.4",
|
|
63
|
+
"magic-regexp": "0.11.0",
|
|
64
|
+
"maxmind": "5.0.5",
|
|
65
|
+
"pino": "9.7.0",
|
|
66
|
+
"ua-parser-js": "2.0.3",
|
|
67
|
+
"unstorage": "1.17.4",
|
|
68
|
+
"zod": "^4.3.6"
|
|
69
|
+
},
|
|
70
|
+
"peerDependencies": {
|
|
71
|
+
"cookie-parser": "^1.4.7",
|
|
72
|
+
"express": "^5.1.0",
|
|
73
|
+
"mysql2": ">=3.0.0"
|
|
74
|
+
},
|
|
75
|
+
"peerDependenciesMeta": {
|
|
76
|
+
"mysql2": {
|
|
77
|
+
"optional": true
|
|
78
|
+
}
|
|
79
|
+
},
|
|
80
|
+
"devDependencies": {
|
|
81
|
+
"@arethetypeswrong/core": "^0.18.2",
|
|
82
|
+
"@planetscale/database": "^1.19.0",
|
|
83
|
+
"@types/better-sqlite3": "^7.6.13",
|
|
84
|
+
"@types/cookie-parser": "^1.4.8",
|
|
85
|
+
"@types/date-fns": "^2.5.3",
|
|
86
|
+
"@types/express": "^5.0.3",
|
|
87
|
+
"@types/node": "^24.5.2",
|
|
88
|
+
"@types/pg": "^8.18.0",
|
|
89
|
+
"@types/supertest": "^7.2.0",
|
|
90
|
+
"@vitest/coverage-v8": "^4.1.0",
|
|
91
|
+
"better-sqlite3": "^12.8.0",
|
|
92
|
+
"eslint": "^10.1.0",
|
|
93
|
+
"mysql2": "^3.14.0",
|
|
94
|
+
"pg": "^8.20.0",
|
|
95
|
+
"publint": "^0.3.18",
|
|
96
|
+
"supertest": "^7.2.2",
|
|
97
|
+
"tsdown": "^0.21.4",
|
|
98
|
+
"typedoc": "^0.28.9",
|
|
99
|
+
"typedoc-plugin-markdown": "^4.8.0",
|
|
100
|
+
"typescript": "^5.4.0",
|
|
101
|
+
"typescript-eslint": "^8.57.1",
|
|
102
|
+
"vitest": "^4.1.0"
|
|
103
|
+
}
|
|
104
|
+
}
|