@prosopo/database 3.15.0 → 3.15.2
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/.turbo/turbo-build$colon$cjs.log +8 -7
- package/.turbo/turbo-build$colon$tsc.log +16 -16
- package/.turbo/turbo-build.log +9 -8
- package/CHANGELOG.md +33 -0
- package/dist/base/mongo.d.ts.map +1 -1
- package/dist/base/mongo.js +14 -8
- package/dist/base/mongo.js.map +1 -1
- package/dist/cjs/base/mongo.cjs +14 -8
- package/dist/cjs/databases/captcha.cjs +3 -4
- package/dist/cjs/index.cjs +3 -0
- package/dist/cjs/mongooseOptions.cjs +67 -0
- package/dist/cjs/redisCache.cjs +88 -0
- package/dist/databases/captcha.js +1 -1
- package/dist/databases/captcha.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -1
- package/dist/index.js.map +1 -1
- package/dist/mongooseOptions.d.ts +11 -0
- package/dist/mongooseOptions.d.ts.map +1 -0
- package/dist/mongooseOptions.js +67 -0
- package/dist/mongooseOptions.js.map +1 -0
- package/dist/redisCache.d.ts +3 -0
- package/dist/redisCache.d.ts.map +1 -1
- package/dist/redisCache.js +88 -0
- package/dist/redisCache.js.map +1 -1
- package/dist/tests/mongoGlobalSetup.d.ts +2 -0
- package/dist/tests/mongoGlobalSetup.d.ts.map +1 -0
- package/dist/tests/mongoGlobalSetup.js +5 -0
- package/dist/tests/mongoGlobalSetup.js.map +1 -0
- package/dist/tests/mongooseOptions.unit.test.d.ts +2 -0
- package/dist/tests/mongooseOptions.unit.test.d.ts.map +1 -0
- package/dist/tests/mongooseOptions.unit.test.js +157 -0
- package/dist/tests/mongooseOptions.unit.test.js.map +1 -0
- package/dist/tests/unit/redisCacheEscalation.unit.test.d.ts +2 -0
- package/dist/tests/unit/redisCacheEscalation.unit.test.d.ts.map +1 -0
- package/dist/tests/unit/redisCacheEscalation.unit.test.js +128 -0
- package/dist/tests/unit/redisCacheEscalation.unit.test.js.map +1 -0
- package/package.json +9 -9
- package/vite.test.config.ts +12 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
> @prosopo/database@3.15.
|
|
2
|
+
> @prosopo/database@3.15.2 build:cjs
|
|
3
3
|
> NODE_ENV=${NODE_ENV:-development}; vite build --config vite.cjs.config.ts --mode $NODE_ENV
|
|
4
4
|
|
|
5
5
|
ViteCommonJSConfig: .
|
|
@@ -37,16 +37,17 @@ ViteCommonJSConfig: .
|
|
|
37
37
|
Bundle build started
|
|
38
38
|
transforming...
|
|
39
39
|
Build end
|
|
40
|
-
[32m✓[39m
|
|
40
|
+
[32m✓[39m 11 modules transformed.
|
|
41
41
|
rendering chunks...
|
|
42
42
|
[2mdist/cjs/[22m[36mbase/index.cjs [39m[1m[2m 0.28 kB[22m[1m[22m
|
|
43
43
|
[2mdist/cjs/[22m[36mbase/mongoMemory.cjs [39m[1m[2m 0.71 kB[22m[1m[22m
|
|
44
|
-
[2mdist/cjs/[22m[36mindex.cjs [39m[1m[2m 1.02 kB[22m[1m[22m
|
|
45
44
|
[2mdist/cjs/[22m[36mdatabases/index.cjs [39m[1m[2m 1.02 kB[22m[1m[22m
|
|
45
|
+
[2mdist/cjs/[22m[36mindex.cjs [39m[1m[2m 1.22 kB[22m[1m[22m
|
|
46
46
|
[2mdist/cjs/[22m[36mdatabases/client.cjs [39m[1m[2m 1.91 kB[22m[1m[22m
|
|
47
|
+
[2mdist/cjs/[22m[36mmongooseOptions.cjs [39m[1m[2m 2.42 kB[22m[1m[22m
|
|
47
48
|
[2mdist/cjs/[22m[36mdatabases/centralDbStreamer.cjs [39m[1m[2m 4.20 kB[22m[1m[22m
|
|
48
|
-
[2mdist/cjs/[22m[36mbase/mongo.cjs [39m[1m[2m 4.
|
|
49
|
-
[2mdist/cjs/[22m[36mdatabases/captcha.cjs [39m[1m[2m 7.
|
|
50
|
-
[2mdist/cjs/[22m[36mredisCache.cjs [39m[1m[
|
|
49
|
+
[2mdist/cjs/[22m[36mbase/mongo.cjs [39m[1m[2m 4.79 kB[22m[1m[22m
|
|
50
|
+
[2mdist/cjs/[22m[36mdatabases/captcha.cjs [39m[1m[2m 7.54 kB[22m[1m[22m
|
|
51
|
+
[2mdist/cjs/[22m[36mredisCache.cjs [39m[1m[2m15.68 kB[22m[1m[22m
|
|
51
52
|
[2mdist/cjs/[22m[36mdatabases/provider.cjs [39m[1m[2m69.92 kB[22m[1m[22m
|
|
52
|
-
[32m✓ built in
|
|
53
|
+
[32m✓ built in 528ms[39m
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
|
|
2
|
-
> @prosopo/database@3.15.
|
|
2
|
+
> @prosopo/database@3.15.2 build:tsc
|
|
3
3
|
> tsc --build --verbose
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
10:33:05 PM - Projects in this build:
|
|
6
6
|
* ../../dev/config/tsconfig.json
|
|
7
7
|
* ../locale/tsconfig.json
|
|
8
8
|
* ../util/tsconfig.json
|
|
@@ -17,31 +17,31 @@
|
|
|
17
17
|
* ../types-database/tsconfig.json
|
|
18
18
|
* tsconfig.json
|
|
19
19
|
|
|
20
|
-
|
|
20
|
+
10:33:05 PM - Project '../../dev/config/tsconfig.json' is up to date because newest input '../../dev/config/src/vite/NodejsPolarsNativeFilePlugin.ts' is older than output '../../dev/config/tsconfig.tsbuildinfo'
|
|
21
21
|
|
|
22
|
-
|
|
22
|
+
10:33:05 PM - Project '../locale/tsconfig.json' is up to date because newest input '../locale/src/translationKey.ts' is older than output '../locale/tsconfig.tsbuildinfo'
|
|
23
23
|
|
|
24
|
-
|
|
24
|
+
10:33:05 PM - Project '../util/tsconfig.json' is up to date because newest input '../util/src/url.ts' is older than output '../util/tsconfig.tsbuildinfo'
|
|
25
25
|
|
|
26
|
-
|
|
26
|
+
10:33:05 PM - Project '../logger/tsconfig.json' is up to date because newest input '../logger/src/logger.ts' is older than output '../logger/tsconfig.tsbuildinfo'
|
|
27
27
|
|
|
28
|
-
|
|
28
|
+
10:33:05 PM - Project '../util-crypto/tsconfig.json' is up to date because newest input '../util-crypto/src/types.ts' is older than output '../util-crypto/tsconfig.tsbuildinfo'
|
|
29
29
|
|
|
30
|
-
|
|
30
|
+
10:33:05 PM - Project '../types/tsconfig.json' is up to date because newest input '../types/src/provider/api.ts' is older than output '../types/tsconfig.tsbuildinfo'
|
|
31
31
|
|
|
32
|
-
|
|
32
|
+
10:33:05 PM - Project '../common/tsconfig.json' is up to date because newest input '../common/src/tests/utils/batches.unit.test.ts' is older than output '../common/tsconfig.tsbuildinfo'
|
|
33
33
|
|
|
34
|
-
|
|
34
|
+
10:33:05 PM - Project '../api-route/tsconfig.json' is up to date because newest input '../api-route/src/apiRoutes.ts' is older than output '../api-route/tsconfig.tsbuildinfo'
|
|
35
35
|
|
|
36
|
-
|
|
36
|
+
10:33:05 PM - Project '../redis-client/tsconfig.json' is up to date because newest input '../redis-client/src/index.ts' is older than output '../redis-client/tsconfig.tsbuildinfo'
|
|
37
37
|
|
|
38
|
-
|
|
38
|
+
10:33:05 PM - Project '../api/tsconfig.json' is up to date because newest input '../api/src/index.ts' is older than output '../api/tsconfig.tsbuildinfo'
|
|
39
39
|
|
|
40
|
-
|
|
40
|
+
10:33:05 PM - Project '../user-access-policy/tsconfig.json' is up to date because newest input '../user-access-policy/src/transformRule.ts' is older than output '../user-access-policy/tsconfig.tsbuildinfo'
|
|
41
41
|
|
|
42
|
-
|
|
42
|
+
10:33:05 PM - Project '../types-database/tsconfig.json' is up to date because newest input '../types-database/src/index.ts' is older than output '../types-database/tsconfig.tsbuildinfo'
|
|
43
43
|
|
|
44
|
-
|
|
44
|
+
10:33:05 PM - Project 'tsconfig.json' is out of date because output file 'tsconfig.tsbuildinfo' does not exist
|
|
45
45
|
|
|
46
|
-
|
|
46
|
+
10:33:05 PM - Building project '/home/runner/work/captcha/captcha/packages/database/tsconfig.json'...
|
|
47
47
|
|
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
|
|
2
|
-
> @prosopo/database@3.15.
|
|
2
|
+
> @prosopo/database@3.15.2 build
|
|
3
3
|
> npm run build:cross-env -- --mode ${NODE_ENV:-development}
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
> @prosopo/database@3.15.
|
|
6
|
+
> @prosopo/database@3.15.2 build:cross-env
|
|
7
7
|
> vite build --config vite.esm.config.ts --mode production
|
|
8
8
|
|
|
9
9
|
ViteEsmConfig: .
|
|
@@ -41,16 +41,17 @@ ViteEsmConfig: .
|
|
|
41
41
|
Bundle build started
|
|
42
42
|
transforming...
|
|
43
43
|
Build end
|
|
44
|
-
[32m✓[39m
|
|
44
|
+
[32m✓[39m 11 modules transformed.
|
|
45
45
|
rendering chunks...
|
|
46
46
|
[2mdist/[22m[36mbase/index.js [39m[1m[2m 0.15 kB[22m[1m[22m
|
|
47
47
|
[2mdist/[22m[36mbase/mongoMemory.js [39m[1m[2m 0.59 kB[22m[1m[22m
|
|
48
|
-
[2mdist/[22m[36mindex.js [39m[1m[2m 0.70 kB[22m[1m[22m
|
|
49
48
|
[2mdist/[22m[36mdatabases/index.js [39m[1m[2m 0.75 kB[22m[1m[22m
|
|
49
|
+
[2mdist/[22m[36mindex.js [39m[1m[2m 0.84 kB[22m[1m[22m
|
|
50
50
|
[2mdist/[22m[36mdatabases/client.js [39m[1m[2m 1.79 kB[22m[1m[22m
|
|
51
|
+
[2mdist/[22m[36mmongooseOptions.js [39m[1m[2m 2.28 kB[22m[1m[22m
|
|
51
52
|
[2mdist/[22m[36mdatabases/centralDbStreamer.js [39m[1m[2m 4.09 kB[22m[1m[22m
|
|
52
|
-
[2mdist/[22m[36mbase/mongo.js [39m[1m[2m 4.
|
|
53
|
-
[2mdist/[22m[36mdatabases/captcha.js [39m[1m[2m 7.
|
|
54
|
-
[2mdist/[22m[36mredisCache.js [39m[1m[
|
|
53
|
+
[2mdist/[22m[36mbase/mongo.js [39m[1m[2m 4.34 kB[22m[1m[22m
|
|
54
|
+
[2mdist/[22m[36mdatabases/captcha.js [39m[1m[2m 7.46 kB[22m[1m[22m
|
|
55
|
+
[2mdist/[22m[36mredisCache.js [39m[1m[2m15.58 kB[22m[1m[22m
|
|
55
56
|
[2mdist/[22m[36mdatabases/provider.js [39m[1m[2m69.72 kB[22m[1m[22m
|
|
56
|
-
[32m✓ built in
|
|
57
|
+
[32m✓ built in 502ms[39m
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,38 @@
|
|
|
1
1
|
# @prosopo/database
|
|
2
2
|
|
|
3
|
+
## 3.15.2
|
|
4
|
+
### Patch Changes
|
|
5
|
+
|
|
6
|
+
- ec363e9: fix(provider): resolve origin sessionId to escalation when post-PoW route() escalates to image/puzzle
|
|
7
|
+
|
|
8
|
+
When the decision machine's route() phase escalates the user from PoW to an image/puzzle captcha, `buildEscalation` mints a fresh session — but the originating session has already been consumed by the preceding /captcha/pow request. Widgets that didn't switch to the escalation sessionId on the next /captcha/* call (older bundled SDKs, hand-rolled wrappers, network-retry races, tab races) landed on NO_SESSION_FOUND. Production deploy of R1/R2 escalations at 18:39 UTC caused a 4.6× spike in CAPTCHA.NO_SESSION_FOUND (363/hr → 1,668/hr); rate dropped immediately once the routing artifact was deleted.
|
|
9
|
+
|
|
10
|
+
Records an origin → escalation sessionId mapping in Redis at the moment `buildEscalation` creates the new session. On the next /captcha/* request, `isValidRequest` falls back to that mapping when `checkAndRemoveSession` returns null for the supplied sessionId, then invalidates the mapping (single-use). When Redis is unavailable the escalation still returns to the client unchanged — those deployments accept the widget must handle the new sessionId on its own.
|
|
11
|
+
|
|
12
|
+
## 3.15.1
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- 9fe3c06: make util fn for mongoose connection config, standardise mongoose connections
|
|
16
|
+
- 11f1e8c: Replace vague logger scopes (empty strings, import.meta.url, generic "CLI") with structured colon-delimited names following the convention package:subsystem:action.
|
|
17
|
+
- Updated dependencies [dfb0c53]
|
|
18
|
+
- Updated dependencies [7ebb78f]
|
|
19
|
+
- Updated dependencies [7daea2e]
|
|
20
|
+
- Updated dependencies [849af99]
|
|
21
|
+
- Updated dependencies [a5ba27b]
|
|
22
|
+
- Updated dependencies [948d36b]
|
|
23
|
+
- Updated dependencies [41e0e11]
|
|
24
|
+
- Updated dependencies [11f1e8c]
|
|
25
|
+
- Updated dependencies [3c80664]
|
|
26
|
+
- Updated dependencies [b166037]
|
|
27
|
+
- Updated dependencies [1111ff2]
|
|
28
|
+
- @prosopo/common@3.1.41
|
|
29
|
+
- @prosopo/logger@2.0.0
|
|
30
|
+
- @prosopo/user-access-policy@3.10.9
|
|
31
|
+
- @prosopo/util@3.3.2
|
|
32
|
+
- @prosopo/types@4.9.0
|
|
33
|
+
- @prosopo/redis-client@1.0.26
|
|
34
|
+
- @prosopo/types-database@4.11.1
|
|
35
|
+
|
|
3
36
|
## 3.15.0
|
|
4
37
|
### Minor Changes
|
|
5
38
|
|
package/dist/base/mongo.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mongo.d.ts","sourceRoot":"","sources":["../../src/base/mongo.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"mongo.d.ts","sourceRoot":"","sources":["../../src/base/mongo.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,KAAK,MAAM,EAAa,MAAM,iBAAiB,CAAC;AACzD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACzD,OAAO,QAAQ,EAAE,EAAE,KAAK,UAAU,EAAE,MAAM,UAAU,CAAC;AAcrD,qBAAa,aAAc,YAAW,SAAS;IAC9C,SAAS,CAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAChC,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,UAAS;IAClB,OAAO,CAAC,UAAU,CAAC,CAAgB;gBAGlC,GAAG,EAAE,MAAM,EACX,MAAM,CAAC,EAAE,MAAM,EACf,UAAU,CAAC,EAAE,MAAM,EACnB,MAAM,CAAC,EAAE,MAAM;IAgBhB,IAAI,GAAG,IAAI,MAAM,CAEhB;IAED,aAAa,IAAI,QAAQ,CAAC,UAAU;IAa9B,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IA8GxB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAO5B"}
|
package/dist/base/mongo.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import { fileURLToPath } from "node:url";
|
|
1
2
|
import { ProsopoDBError } from "@prosopo/common";
|
|
2
3
|
import { getLogger } from "@prosopo/logger";
|
|
3
|
-
import { ServerApiVersion } from "mongodb";
|
|
4
4
|
import mongoose from "mongoose";
|
|
5
|
+
import { getMongoConnectionOptions } from "../mongooseOptions.js";
|
|
5
6
|
mongoose.set("strictQuery", false);
|
|
6
7
|
const DEFAULT_ENDPOINT = "mongodb://127.0.0.1:27017";
|
|
7
8
|
class MongoDatabase {
|
|
@@ -18,7 +19,7 @@ class MongoDatabase {
|
|
|
18
19
|
this._url = parsedUrl.toString();
|
|
19
20
|
this.safeURL = this.url.replace(/\w+:\w+/, "<Credentials>");
|
|
20
21
|
this.dbname = dbname || parsedUrl.pathname.replace("/", "");
|
|
21
|
-
this.logger = logger || getLogger("info",
|
|
22
|
+
this.logger = logger || getLogger("info", "database:mongo");
|
|
22
23
|
}
|
|
23
24
|
get url() {
|
|
24
25
|
return this._url;
|
|
@@ -56,12 +57,17 @@ class MongoDatabase {
|
|
|
56
57
|
return this.connecting;
|
|
57
58
|
}
|
|
58
59
|
this.connecting = new Promise((resolve, reject) => {
|
|
59
|
-
const
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
60
|
+
const appName = fileURLToPath(import.meta.url);
|
|
61
|
+
const connection = mongoose.createConnection(
|
|
62
|
+
this.url,
|
|
63
|
+
getMongoConnectionOptions({
|
|
64
|
+
url: this.url,
|
|
65
|
+
appName,
|
|
66
|
+
dbName: this.dbname,
|
|
67
|
+
maxPoolSize: 50,
|
|
68
|
+
minPoolSize: 5
|
|
69
|
+
})
|
|
70
|
+
);
|
|
65
71
|
const onConnected = () => {
|
|
66
72
|
this.logger.debug(() => ({
|
|
67
73
|
data: { mongoUrl: this.safeURL },
|
package/dist/base/mongo.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mongo.js","sourceRoot":"","sources":["../../src/base/mongo.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"mongo.js","sourceRoot":"","sources":["../../src/base/mongo.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EAAe,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAEzD,OAAO,QAA6B,MAAM,UAAU,CAAC;AACrD,OAAO,EAAE,yBAAyB,EAAE,MAAM,uBAAuB,CAAC;AAElE,QAAQ,CAAC,GAAG,CAAC,aAAa,EAAE,KAAK,CAAC,CAAC;AAGnC,MAAM,gBAAgB,GAAG,2BAA2B,CAAC;AAQrD,MAAM,OAAO,aAAa;IASzB,YACC,GAAW,EACX,MAAe,EACf,UAAmB,EACnB,MAAe;QAPhB,cAAS,GAAG,KAAK,CAAC;QASjB,MAAM,YAAY,GAAG,GAAG,IAAI,gBAAgB,CAAC;QAC7C,MAAM,SAAS,GAAG,IAAI,GAAG,CAAC,YAAY,CAAC,CAAC;QACxC,IAAI,MAAM,EAAE,CAAC;YACZ,SAAS,CAAC,QAAQ,GAAG,MAAM,CAAC;QAC7B,CAAC;QACD,IAAI,UAAU,EAAE,CAAC;YAChB,SAAS,CAAC,YAAY,CAAC,GAAG,CAAC,YAAY,EAAE,UAAU,CAAC,CAAC;QACtD,CAAC;QACD,IAAI,C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C;gBAEH,UAAU,CAAC,EAAE,CAAC,WAAW,EAAE,GAAG,EAAE;oBAC/B,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;oBACtB,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC;wBACxB,IAAI,EAAE,EAAE,QAAQ,EAAE,IAAI,CAAC,OAAO,EAAE;wBAChC,GAAG,EAAE,oCAAoC;qBACzC,CAAC,CAAC,CAAC;gBACL,CAAC,CAAC,CAAC;YACJ,CAAC,CAAC,CAAC;YAEH,OAAO,IAAI,CAAC,UAAU,CAAC;QACxB,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACZ,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC;gBACxB,GAAG,EAAE,CAAC;gBACN,IAAI,EAAE,EAAE,QAAQ,EAAE,IAAI,CAAC,OAAO,EAAE;gBAChC,GAAG,EAAE,2BAA2B;aAChC,CAAC,CAAC,CAAC;YACJ,MAAM,CAAC,CAAC;QACT,CAAC;IACF,CAAC;IAGD,KAAK,CAAC,KAAK;QACV,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC;YACxB,IAAI,EAAE,EAAE,QAAQ,EAAE,IAAI,CAAC,OAAO,EAAE;YAChC,GAAG,EAAE,oBAAoB;SACzB,CAAC,CAAC,CAAC;QACJ,MAAM,IAAI,CAAC,UAAU,EAAE,KAAK,EAAE,CAAC;IAChC,CAAC;CACD"}
|
package/dist/cjs/base/mongo.cjs
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const node_url = require("node:url");
|
|
3
4
|
const common = require("@prosopo/common");
|
|
4
5
|
const logger = require("@prosopo/logger");
|
|
5
|
-
const mongodb = require("mongodb");
|
|
6
6
|
const mongoose = require("mongoose");
|
|
7
|
+
const mongooseOptions = require("../mongooseOptions.cjs");
|
|
7
8
|
var _documentCurrentScript = typeof document !== "undefined" ? document.currentScript : null;
|
|
8
9
|
mongoose.set("strictQuery", false);
|
|
9
10
|
const DEFAULT_ENDPOINT = "mongodb://127.0.0.1:27017";
|
|
@@ -21,7 +22,7 @@ class MongoDatabase {
|
|
|
21
22
|
this._url = parsedUrl.toString();
|
|
22
23
|
this.safeURL = this.url.replace(/\w+:\w+/, "<Credentials>");
|
|
23
24
|
this.dbname = dbname || parsedUrl.pathname.replace("/", "");
|
|
24
|
-
this.logger = logger$1 || logger.getLogger("info",
|
|
25
|
+
this.logger = logger$1 || logger.getLogger("info", "database:mongo");
|
|
25
26
|
}
|
|
26
27
|
get url() {
|
|
27
28
|
return this._url;
|
|
@@ -59,12 +60,17 @@ class MongoDatabase {
|
|
|
59
60
|
return this.connecting;
|
|
60
61
|
}
|
|
61
62
|
this.connecting = new Promise((resolve, reject) => {
|
|
62
|
-
const
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
63
|
+
const appName = node_url.fileURLToPath(typeof document === "undefined" ? require("url").pathToFileURL(__filename).href : _documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === "SCRIPT" && _documentCurrentScript.src || new URL("base/mongo.cjs", document.baseURI).href);
|
|
64
|
+
const connection = mongoose.createConnection(
|
|
65
|
+
this.url,
|
|
66
|
+
mongooseOptions.getMongoConnectionOptions({
|
|
67
|
+
url: this.url,
|
|
68
|
+
appName,
|
|
69
|
+
dbName: this.dbname,
|
|
70
|
+
maxPoolSize: 50,
|
|
71
|
+
minPoolSize: 5
|
|
72
|
+
})
|
|
73
|
+
);
|
|
68
74
|
const onConnected = () => {
|
|
69
75
|
this.logger.debug(() => ({
|
|
70
76
|
data: { mongoUrl: this.safeURL },
|
|
@@ -6,9 +6,8 @@ const typesDatabase = require("@prosopo/types-database");
|
|
|
6
6
|
const bson = require("bson");
|
|
7
7
|
require("../base/index.cjs");
|
|
8
8
|
const mongo = require("../base/mongo.cjs");
|
|
9
|
-
var _documentCurrentScript = typeof document !== "undefined" ? document.currentScript : null;
|
|
10
9
|
const isBsonLong = (value) => typeof value === "object" && value !== null && "_bsontype" in value && value._bsontype === "Long";
|
|
11
|
-
const logger = logger$1.getLogger("info",
|
|
10
|
+
const logger = logger$1.getLogger("info", "database:captcha");
|
|
12
11
|
var TableNames = /* @__PURE__ */ ((TableNames2) => {
|
|
13
12
|
TableNames2["frictionlessToken"] = "frictionlessToken";
|
|
14
13
|
TableNames2["session"] = "session";
|
|
@@ -133,8 +132,8 @@ class CaptchaDatabase extends mongo.MongoDatabase {
|
|
|
133
132
|
await this.connect();
|
|
134
133
|
if (sessionEvents.length) {
|
|
135
134
|
const result = await this.tables.session.bulkWrite(
|
|
136
|
-
sessionEvents.map((
|
|
137
|
-
const { _id, ...safeDoc } =
|
|
135
|
+
sessionEvents.map((document) => {
|
|
136
|
+
const { _id, ...safeDoc } = document;
|
|
138
137
|
return {
|
|
139
138
|
insertOne: {
|
|
140
139
|
document: CaptchaDatabase.normaliseDocCompositeIps(safeDoc)
|
package/dist/cjs/index.cjs
CHANGED
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
|
3
3
|
const makeDir = require("make-dir");
|
|
4
4
|
require("./base/index.cjs");
|
|
5
5
|
const index = require("./databases/index.cjs");
|
|
6
|
+
const mongooseOptions = require("./mongooseOptions.cjs");
|
|
6
7
|
const redisCache = require("./redisCache.cjs");
|
|
7
8
|
const mongo = require("./base/mongo.cjs");
|
|
8
9
|
const mongoMemory = require("./base/mongoMemory.cjs");
|
|
@@ -12,6 +13,8 @@ const centralDbStreamer = require("./databases/centralDbStreamer.cjs");
|
|
|
12
13
|
const client = require("./databases/client.cjs");
|
|
13
14
|
console.debug(makeDir);
|
|
14
15
|
exports.Databases = index.Databases;
|
|
16
|
+
exports.getMongoCompressors = mongooseOptions.getMongoCompressors;
|
|
17
|
+
exports.getMongoConnectionOptions = mongooseOptions.getMongoConnectionOptions;
|
|
15
18
|
exports.RedisWriteQueue = redisCache.RedisWriteQueue;
|
|
16
19
|
exports.MongoDatabase = mongo.MongoDatabase;
|
|
17
20
|
exports.MongoMemoryDatabase = mongoMemory.MongoMemoryDatabase;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const mongodb = require("mongodb");
|
|
4
|
+
const DEFAULT_COMPRESSORS = [
|
|
5
|
+
"zstd",
|
|
6
|
+
"snappy",
|
|
7
|
+
"zlib",
|
|
8
|
+
"none"
|
|
9
|
+
];
|
|
10
|
+
const getMongoCompressors = (url, compressors = DEFAULT_COMPRESSORS) => {
|
|
11
|
+
try {
|
|
12
|
+
const protocolIndex = url.indexOf("://");
|
|
13
|
+
const urlWithoutProtocol = protocolIndex !== -1 ? url.slice(protocolIndex + 3) : url;
|
|
14
|
+
if (urlWithoutProtocol.trim() === "") {
|
|
15
|
+
return [];
|
|
16
|
+
}
|
|
17
|
+
const parsedUrl = new URL(`mongodb://${urlWithoutProtocol}`);
|
|
18
|
+
const hostname = parsedUrl.hostname;
|
|
19
|
+
const isLocalhost = hostname === "localhost" || hostname === "127.0.0.1" || hostname === "[::1]" || hostname === "::1";
|
|
20
|
+
if (isLocalhost) {
|
|
21
|
+
return [];
|
|
22
|
+
}
|
|
23
|
+
return hostname.includes(".") || hostname.includes(":") ? [...compressors] : [];
|
|
24
|
+
} catch {
|
|
25
|
+
return [...compressors];
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
const getMongoConnectionOptions = (options) => {
|
|
29
|
+
const { url, appName, maxPoolSize = 10, minPoolSize = 0, dbName } = options;
|
|
30
|
+
if (!url || url.trim() === "") {
|
|
31
|
+
throw new Error(
|
|
32
|
+
"MongoDB connection URL is required and cannot be empty or whitespace-only"
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
const compressors = getMongoCompressors(url);
|
|
36
|
+
const connectionOptions = {
|
|
37
|
+
serverApi: {
|
|
38
|
+
version: mongodb.ServerApiVersion.v1,
|
|
39
|
+
// strict mode rejects any command outside the Stable API; leave it
|
|
40
|
+
// off so non-stable operations (index/admin commands etc.) keep working.
|
|
41
|
+
strict: false,
|
|
42
|
+
deprecationErrors: false
|
|
43
|
+
},
|
|
44
|
+
maxPoolSize,
|
|
45
|
+
// allow up to N connections at any given time. >1 connection allows parallel db operations
|
|
46
|
+
minPoolSize,
|
|
47
|
+
// pool may close idle connections down to this amount (0 = close all idle past maxIdleTimeMS)
|
|
48
|
+
maxConnecting: 2,
|
|
49
|
+
// maximum number of concurrent connection attempts
|
|
50
|
+
connectTimeoutMS: 1e4,
|
|
51
|
+
// max time to connect to the database
|
|
52
|
+
socketTimeoutMS: 3e4,
|
|
53
|
+
// max time to wait for a response from the database when doing an operation
|
|
54
|
+
maxIdleTimeMS: 3e5,
|
|
55
|
+
// max time spent idle before closing the connection
|
|
56
|
+
appName,
|
|
57
|
+
serverSelectionTimeoutMS: 2e4,
|
|
58
|
+
// max time to wait for a response from the database
|
|
59
|
+
compressors
|
|
60
|
+
};
|
|
61
|
+
if (dbName) {
|
|
62
|
+
connectionOptions.dbName = dbName;
|
|
63
|
+
}
|
|
64
|
+
return connectionOptions;
|
|
65
|
+
};
|
|
66
|
+
exports.getMongoCompressors = getMongoCompressors;
|
|
67
|
+
exports.getMongoConnectionOptions = getMongoConnectionOptions;
|
package/dist/cjs/redisCache.cjs
CHANGED
|
@@ -194,6 +194,94 @@ class RedisWriteQueue {
|
|
|
194
194
|
return null;
|
|
195
195
|
}
|
|
196
196
|
}
|
|
197
|
+
/**
|
|
198
|
+
* Cache an origin → escalation sessionId mapping for the post-PoW
|
|
199
|
+
* escalation flow.
|
|
200
|
+
*
|
|
201
|
+
* Background: when the routing machine returns image/puzzle from the
|
|
202
|
+
* postPow phase, `buildEscalation` (`api/captcha/submitPoWCaptchaSolution.ts`)
|
|
203
|
+
* mints a new session with a fresh `sessionId` and returns it on the
|
|
204
|
+
* `escalation` field. A widget that handles the escalation cleanly
|
|
205
|
+
* mounts the next captcha with the new sessionId. But there are
|
|
206
|
+
* several real-world paths where the widget keeps using the original
|
|
207
|
+
* sessionId for the follow-up `/captcha/{type}` request — bundled SDK
|
|
208
|
+
* versions that predate the escalation handler, dapps that hand-roll
|
|
209
|
+
* the wrapper, network-glitch retries, or browser-tab races. The
|
|
210
|
+
* original session has been consumed and soft-deleted by the
|
|
211
|
+
* preceding `/captcha/pow`, so the follow-up gets
|
|
212
|
+
* `CAPTCHA.NO_SESSION_FOUND` and the user sees an inline error → FAQ.
|
|
213
|
+
*
|
|
214
|
+
* This mapping lets `isValidRequest` resolve the original sessionId
|
|
215
|
+
* forward to the live escalation session and proceed normally.
|
|
216
|
+
*
|
|
217
|
+
* TTL is short on purpose: escalation handoffs complete in seconds
|
|
218
|
+
* (the user solves the follow-up immediately) and a stale mapping
|
|
219
|
+
* pointing at a long-gone session would just produce a different
|
|
220
|
+
* shape of NO_SESSION_FOUND.
|
|
221
|
+
*/
|
|
222
|
+
async cacheSessionEscalation(originSessionId, escalationSessionId, ttlSeconds = 600) {
|
|
223
|
+
const client = await this.getClient();
|
|
224
|
+
if (!client) {
|
|
225
|
+
return false;
|
|
226
|
+
}
|
|
227
|
+
try {
|
|
228
|
+
const key = `cache:session:escalation:${originSessionId}`;
|
|
229
|
+
await client.set(key, escalationSessionId, { EX: ttlSeconds });
|
|
230
|
+
return true;
|
|
231
|
+
} catch (error) {
|
|
232
|
+
this.logger.warn(() => ({
|
|
233
|
+
msg: "Failed to cache session escalation mapping in Redis",
|
|
234
|
+
err: error,
|
|
235
|
+
originSessionId,
|
|
236
|
+
escalationSessionId
|
|
237
|
+
}));
|
|
238
|
+
return false;
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
/**
|
|
242
|
+
* Resolve an original sessionId to its escalation sessionId, if one was
|
|
243
|
+
* recorded. Returns null when there is no mapping (either no escalation
|
|
244
|
+
* happened, or the TTL has elapsed).
|
|
245
|
+
*/
|
|
246
|
+
async getCachedSessionEscalation(originSessionId) {
|
|
247
|
+
const client = await this.getClient();
|
|
248
|
+
if (!client) {
|
|
249
|
+
return null;
|
|
250
|
+
}
|
|
251
|
+
try {
|
|
252
|
+
const key = `cache:session:escalation:${originSessionId}`;
|
|
253
|
+
return await client.get(key);
|
|
254
|
+
} catch (error) {
|
|
255
|
+
this.logger.warn(() => ({
|
|
256
|
+
msg: "Failed to get cached session escalation mapping from Redis",
|
|
257
|
+
err: error,
|
|
258
|
+
originSessionId
|
|
259
|
+
}));
|
|
260
|
+
return null;
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
/**
|
|
264
|
+
* Invalidate an escalation mapping. Called when the escalation session
|
|
265
|
+
* itself is consumed so subsequent retries on the origin sessionId fall
|
|
266
|
+
* through to the standard NO_SESSION_FOUND path rather than chasing a
|
|
267
|
+
* second-hand stale pointer.
|
|
268
|
+
*/
|
|
269
|
+
async invalidateCachedSessionEscalation(originSessionId) {
|
|
270
|
+
const client = await this.getClient();
|
|
271
|
+
if (!client) {
|
|
272
|
+
return;
|
|
273
|
+
}
|
|
274
|
+
try {
|
|
275
|
+
const key = `cache:session:escalation:${originSessionId}`;
|
|
276
|
+
await client.del(key);
|
|
277
|
+
} catch (error) {
|
|
278
|
+
this.logger.warn(() => ({
|
|
279
|
+
msg: "Failed to invalidate cached session escalation mapping",
|
|
280
|
+
err: error,
|
|
281
|
+
originSessionId
|
|
282
|
+
}));
|
|
283
|
+
}
|
|
284
|
+
}
|
|
197
285
|
// ── Session write queue ─────────────────────────────────────────────
|
|
198
286
|
/**
|
|
199
287
|
* Queue a session record for batched insertion into MongoDB.
|
|
@@ -5,7 +5,7 @@ import { Decimal128, Long } from "bson";
|
|
|
5
5
|
import "../base/index.js";
|
|
6
6
|
import { MongoDatabase } from "../base/mongo.js";
|
|
7
7
|
const isBsonLong = (value) => typeof value === "object" && value !== null && "_bsontype" in value && value._bsontype === "Long";
|
|
8
|
-
const logger = getLogger("info",
|
|
8
|
+
const logger = getLogger("info", "database:captcha");
|
|
9
9
|
var TableNames = /* @__PURE__ */ ((TableNames2) => {
|
|
10
10
|
TableNames2["frictionlessToken"] = "frictionlessToken";
|
|
11
11
|
TableNames2["session"] = "session";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"captcha.js","sourceRoot":"","sources":["../../src/databases/captcha.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EAAe,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACzD,OAAO,EAIN,4BAA4B,EAE5B,yBAAyB,EACzB,gCAAgC,GAGhC,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAOxC,MAAM,UAAU,GAAG,CAAC,KAAc,EAAW,EAAE,CAC9C,OAAO,KAAK,KAAK,QAAQ;IACzB,KAAK,KAAK,IAAI;IACd,WAAW,IAAI,KAAK;IACnB,KAA+B,CAAC,SAAS,KAAK,MAAM,CAAC;AAEvD,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEjD,MAAM,MAAM,GAAG,SAAS,CAAC,MAAM,EAAE,
|
|
1
|
+
{"version":3,"file":"captcha.js","sourceRoot":"","sources":["../../src/databases/captcha.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EAAe,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACzD,OAAO,EAIN,4BAA4B,EAE5B,yBAAyB,EACzB,gCAAgC,GAGhC,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAOxC,MAAM,UAAU,GAAG,CAAC,KAAc,EAAW,EAAE,CAC9C,OAAO,KAAK,KAAK,QAAQ;IACzB,KAA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BACpD,IAAI,CAAC,MAAM,CAAC;iBACZ,KAAK,CAAC,KAAK,CAAC;iBACZ,IAAI,EAA0B,CAAC;YAEjC,MAAM,iBAAiB,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,UAAU;iBACpD,IAAI,CAAC,MAAM,CAAC;iBACZ,KAAK,CAAC,KAAK,CAAC;iBACZ,IAAI,EAAsB,CAAC;YAE7B,OAAO;gBACN,qBAAqB,EAAE,iBAAiB;gBACxC,iBAAiB,EAAE,iBAAiB;aACpC,CAAC;QACH,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YAChB,MAAM,IAAI,cAAc,CAAC,sBAAsB,EAAE;gBAChD,OAAO,EAAE;oBACR,KAAK;oBACL,MAAM;oBACN,KAAK;oBACL,cAAc,EAAE,IAAI,CAAC,WAAW,CAAC,IAAI;iBACrC;gBACD,MAAM,EAAE,IAAI,CAAC,MAAM;aACnB,CAAC,CAAC;QACJ,CAAC;gBAAS,CAAC;YACV,MAAM,IAAI,CAAC,KAAK,EAAE,CAAC;QACpB,CAAC;IACF,CAAC;CACD"}
|
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":"AAgBA,cAAc,iBAAiB,CAAC;AAChC,cAAc,sBAAsB,CAAC;AACrC,cAAc,iBAAiB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAgBA,cAAc,iBAAiB,CAAC;AAChC,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,iBAAiB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import makeDir from "make-dir";
|
|
2
2
|
import "./base/index.js";
|
|
3
3
|
import { Databases } from "./databases/index.js";
|
|
4
|
+
import { getMongoCompressors, getMongoConnectionOptions } from "./mongooseOptions.js";
|
|
4
5
|
import { RedisWriteQueue } from "./redisCache.js";
|
|
5
6
|
import { MongoDatabase } from "./base/mongo.js";
|
|
6
7
|
import { MongoMemoryDatabase } from "./base/mongoMemory.js";
|
|
@@ -17,5 +18,7 @@ export {
|
|
|
17
18
|
MongoDatabase,
|
|
18
19
|
MongoMemoryDatabase,
|
|
19
20
|
ProviderDatabase,
|
|
20
|
-
RedisWriteQueue
|
|
21
|
+
RedisWriteQueue,
|
|
22
|
+
getMongoCompressors,
|
|
23
|
+
getMongoConnectionOptions
|
|
21
24
|
};
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAaA,OAAO,OAAO,MAAM,UAAU,CAAC;AAE/B,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;AACvB,cAAc,iBAAiB,CAAC;AAChC,cAAc,sBAAsB,CAAC;AACrC,cAAc,iBAAiB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAaA,OAAO,OAAO,MAAM,UAAU,CAAC;AAE/B,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;AACvB,cAAc,iBAAiB,CAAC;AAChC,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { ConnectOptions } from "mongoose";
|
|
2
|
+
export type MongoCompressor = "zstd" | "none" | "snappy" | "zlib";
|
|
3
|
+
export declare const getMongoCompressors: (url: string, compressors?: MongoCompressor[]) => MongoCompressor[];
|
|
4
|
+
export declare const getMongoConnectionOptions: (options: {
|
|
5
|
+
url: string;
|
|
6
|
+
appName: string;
|
|
7
|
+
maxPoolSize?: number;
|
|
8
|
+
minPoolSize?: number;
|
|
9
|
+
dbName?: string;
|
|
10
|
+
}) => ConnectOptions;
|
|
11
|
+
//# sourceMappingURL=mongooseOptions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mongooseOptions.d.ts","sourceRoot":"","sources":["../src/mongooseOptions.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAE/C,MAAM,MAAM,eAAe,GAAG,MAAM,GAAG,MAAM,GAAG,QAAQ,GAAG,MAAM,CAAC;AAoBlE,eAAO,MAAM,mBAAmB,QAC1B,MAAM,gBACE,eAAe,EAAE,KAC5B,eAAe,EAuCjB,CAAC;AAaF,eAAO,MAAM,yBAAyB,YAAa;IAClD,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,CAAC;CAChB,KAAG,cAmCH,CAAC"}
|