@prosopo/database 4.2.7 → 4.2.9
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 +13 -12
- package/.turbo/turbo-build$colon$tsc.log +16 -16
- package/.turbo/turbo-build.log +13 -12
- package/CHANGELOG.md +68 -0
- package/dist/base/mongo.d.ts.map +1 -1
- package/dist/base/mongo.js +6 -4
- package/dist/base/mongo.js.map +1 -1
- package/dist/cjs/base/mongo.cjs +5 -3
- package/dist/cjs/databases/captcha.cjs +10 -7
- package/dist/cjs/databases/client.cjs +5 -3
- package/dist/cjs/databases/clientRecordCache.cjs +43 -0
- package/dist/cjs/databases/provider.cjs +338 -185
- package/dist/cjs/redisCache.cjs +1 -1
- package/dist/databases/captcha.d.ts.map +1 -1
- package/dist/databases/captcha.js +11 -8
- package/dist/databases/captcha.js.map +1 -1
- package/dist/databases/client.d.ts.map +1 -1
- package/dist/databases/client.js +6 -4
- package/dist/databases/client.js.map +1 -1
- package/dist/databases/clientRecordCache.d.ts +11 -0
- package/dist/databases/clientRecordCache.d.ts.map +1 -0
- package/dist/databases/clientRecordCache.js +42 -0
- package/dist/databases/clientRecordCache.js.map +1 -0
- package/dist/databases/provider.d.ts.map +1 -1
- package/dist/databases/provider.js +339 -186
- package/dist/databases/provider.js.map +1 -1
- package/dist/errorSites.d.ts +57 -0
- package/dist/errorSites.d.ts.map +1 -0
- package/dist/errorSites.js +2 -0
- package/dist/errorSites.js.map +1 -0
- package/dist/redisCache.js +1 -1
- package/dist/tests/integration/clientRecordCache.integration.test.d.ts +2 -0
- package/dist/tests/integration/clientRecordCache.integration.test.d.ts.map +1 -0
- package/dist/tests/integration/clientRecordCache.integration.test.js +87 -0
- package/dist/tests/integration/clientRecordCache.integration.test.js.map +1 -0
- package/package.json +13 -13
|
@@ -3,11 +3,11 @@ ViteCommonJSConfig: .
|
|
|
3
3
|
{
|
|
4
4
|
tsConfigPaths: [
|
|
5
5
|
'/home/runner/work/captcha/captcha/packages/common/tsconfig.json',
|
|
6
|
+
'/home/runner/work/captcha/captcha/packages/types/tsconfig.json',
|
|
6
7
|
'/home/runner/work/captcha/captcha/packages/locale/tsconfig.json',
|
|
7
8
|
'/home/runner/work/captcha/captcha/packages/util/tsconfig.json',
|
|
8
|
-
'/home/runner/work/captcha/captcha/packages/logger/tsconfig.json',
|
|
9
|
-
'/home/runner/work/captcha/captcha/packages/types/tsconfig.json',
|
|
10
9
|
'/home/runner/work/captcha/captcha/packages/util-crypto/tsconfig.json',
|
|
10
|
+
'/home/runner/work/captcha/captcha/packages/logger/tsconfig.json',
|
|
11
11
|
'/home/runner/work/captcha/captcha/packages/types-database/tsconfig.json',
|
|
12
12
|
'/home/runner/work/captcha/captcha/packages/user-access-policy/tsconfig.json',
|
|
13
13
|
'/home/runner/work/captcha/captcha/packages/api-route/tsconfig.json',
|
|
@@ -18,11 +18,11 @@ ViteCommonJSConfig: .
|
|
|
18
18
|
{
|
|
19
19
|
externals: [
|
|
20
20
|
'@prosopo/common',
|
|
21
|
+
'@prosopo/types',
|
|
21
22
|
'@prosopo/locale',
|
|
22
23
|
'@prosopo/util',
|
|
23
|
-
'@prosopo/logger',
|
|
24
|
-
'@prosopo/types',
|
|
25
24
|
'@prosopo/util-crypto',
|
|
25
|
+
'@prosopo/logger',
|
|
26
26
|
'@prosopo/types-database',
|
|
27
27
|
'@prosopo/user-access-policy',
|
|
28
28
|
'@prosopo/api-route',
|
|
@@ -31,23 +31,24 @@ ViteCommonJSConfig: .
|
|
|
31
31
|
]
|
|
32
32
|
}
|
|
33
33
|
[33mThe plugin "vite-tsconfig-paths" is detected. Vite now supports tsconfig paths resolution natively via the [1mresolve.tsconfigPaths[22m option. You can remove the plugin and set [1mresolve.tsconfigPaths: true[22m in your Vite config instead.[39m
|
|
34
|
-
[36mvite v8.1.
|
|
34
|
+
[36mvite v8.1.6 [32mbuilding ssr environment for production...[36m[39m
|
|
35
35
|
Bundle build started
|
|
36
36
|
[2K
|
|
37
|
-
✓
|
|
37
|
+
✓ 13 modules transformed.
|
|
38
38
|
rendering chunks...
|
|
39
39
|
computing gzip size...
|
|
40
40
|
dist/cjs/base/index.cjs 0.22 kB │ gzip: 0.10 kB
|
|
41
41
|
dist/cjs/base/mongoMemory.cjs 0.66 kB │ gzip: 0.32 kB
|
|
42
42
|
dist/cjs/_virtual/_rolldown/runtime.cjs 1.00 kB │ gzip: 0.50 kB
|
|
43
43
|
dist/cjs/databases/index.cjs 1.14 kB │ gzip: 0.32 kB
|
|
44
|
+
dist/cjs/databases/clientRecordCache.cjs 1.45 kB │ gzip: 0.69 kB
|
|
44
45
|
dist/cjs/index.cjs 1.66 kB │ gzip: 0.49 kB
|
|
45
|
-
dist/cjs/databases/client.cjs 1.
|
|
46
|
+
dist/cjs/databases/client.cjs 1.82 kB │ gzip: 0.79 kB
|
|
46
47
|
dist/cjs/mongooseOptions.cjs 3.74 kB │ gzip: 1.56 kB
|
|
47
|
-
dist/cjs/base/mongo.cjs 4.
|
|
48
|
+
dist/cjs/base/mongo.cjs 4.29 kB │ gzip: 1.42 kB
|
|
48
49
|
dist/cjs/databases/centralDbStreamer.cjs 6.40 kB │ gzip: 1.52 kB
|
|
49
|
-
dist/cjs/databases/captcha.cjs 8.
|
|
50
|
-
dist/cjs/redisCache.cjs 14.
|
|
51
|
-
dist/cjs/databases/provider.cjs
|
|
50
|
+
dist/cjs/databases/captcha.cjs 8.23 kB │ gzip: 2.38 kB
|
|
51
|
+
dist/cjs/redisCache.cjs 14.30 kB │ gzip: 4.45 kB
|
|
52
|
+
dist/cjs/databases/provider.cjs 70.62 kB │ gzip: 13.47 kB
|
|
52
53
|
|
|
53
|
-
[32m✓ built in
|
|
54
|
+
[32m✓ built in 65ms[39m
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
$ tsc --build --verbose
|
|
2
|
-
|
|
2
|
+
7:40:57 PM - Projects in this build:
|
|
3
3
|
* ../../dev/config/tsconfig.json
|
|
4
4
|
* ../util/tsconfig.json
|
|
5
5
|
* ../locale/tsconfig.json
|
|
6
|
-
* ../logger/tsconfig.json
|
|
7
6
|
* ../util-crypto/tsconfig.json
|
|
8
7
|
* ../types/tsconfig.json
|
|
9
8
|
* ../common/tsconfig.json
|
|
9
|
+
* ../logger/tsconfig.json
|
|
10
10
|
* ../api-route/tsconfig.json
|
|
11
11
|
* ../redis-client/tsconfig.json
|
|
12
12
|
* ../api/tsconfig.json
|
|
@@ -14,31 +14,31 @@ $ tsc --build --verbose
|
|
|
14
14
|
* ../types-database/tsconfig.json
|
|
15
15
|
* tsconfig.json
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
7:40:57 PM - Project '../../dev/config/tsconfig.json' is up to date because newest input '../../dev/config/src/webpack/webpack.config.ts' is older than output '../../dev/config/tsconfig.tsbuildinfo'
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
7:40:57 PM - Project '../util/tsconfig.json' is up to date because newest input '../util/src/url.ts' is older than output '../util/tsconfig.tsbuildinfo'
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
7:40:57 PM - Project '../locale/tsconfig.json' is up to date because newest input '../locale/src/process.ts' is older than output '../locale/tsconfig.tsbuildinfo'
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
7:40:57 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'
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
7:40:57 PM - Project '../types/tsconfig.json' is up to date because newest input '../types/src/types.test-d.ts' is older than output '../types/tsconfig.tsbuildinfo'
|
|
26
26
|
|
|
27
|
-
|
|
27
|
+
7:40:57 PM - Project '../common/tsconfig.json' is up to date because newest input '../common/src/tests/utils/objectUtils.unit.test.ts' is older than output '../common/tsconfig.tsbuildinfo'
|
|
28
28
|
|
|
29
|
-
|
|
29
|
+
7:40:57 PM - Project '../logger/tsconfig.json' is up to date because newest input '../logger/src/tests/loggerBrowser.unit.test.ts' is older than output '../logger/tsconfig.tsbuildinfo'
|
|
30
30
|
|
|
31
|
-
|
|
31
|
+
7:40:57 PM - Project '../api-route/tsconfig.json' is up to date because newest input '../api-route/src/tests/apiRoute.unit.test.ts' is older than output '../api-route/tsconfig.tsbuildinfo'
|
|
32
32
|
|
|
33
|
-
|
|
33
|
+
7:40:57 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'
|
|
34
34
|
|
|
35
|
-
|
|
35
|
+
7:40:57 PM - Project '../api/tsconfig.json' is up to date because newest input '../api/src/index.ts' is older than output '../api/tsconfig.tsbuildinfo'
|
|
36
36
|
|
|
37
|
-
|
|
37
|
+
7:40:57 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'
|
|
38
38
|
|
|
39
|
-
|
|
39
|
+
7:40:57 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'
|
|
40
40
|
|
|
41
|
-
|
|
41
|
+
7:40:57 PM - Project 'tsconfig.json' is out of date because output file 'tsconfig.tsbuildinfo' does not exist
|
|
42
42
|
|
|
43
|
-
|
|
43
|
+
7:40:57 PM - Building project '/home/runner/work/captcha/captcha/packages/database/tsconfig.json'...
|
|
44
44
|
|
package/.turbo/turbo-build.log
CHANGED
|
@@ -4,11 +4,11 @@ ViteEsmConfig: .
|
|
|
4
4
|
{
|
|
5
5
|
tsConfigPaths: [
|
|
6
6
|
'/home/runner/work/captcha/captcha/packages/common/tsconfig.json',
|
|
7
|
+
'/home/runner/work/captcha/captcha/packages/types/tsconfig.json',
|
|
7
8
|
'/home/runner/work/captcha/captcha/packages/locale/tsconfig.json',
|
|
8
9
|
'/home/runner/work/captcha/captcha/packages/util/tsconfig.json',
|
|
9
|
-
'/home/runner/work/captcha/captcha/packages/logger/tsconfig.json',
|
|
10
|
-
'/home/runner/work/captcha/captcha/packages/types/tsconfig.json',
|
|
11
10
|
'/home/runner/work/captcha/captcha/packages/util-crypto/tsconfig.json',
|
|
11
|
+
'/home/runner/work/captcha/captcha/packages/logger/tsconfig.json',
|
|
12
12
|
'/home/runner/work/captcha/captcha/packages/types-database/tsconfig.json',
|
|
13
13
|
'/home/runner/work/captcha/captcha/packages/user-access-policy/tsconfig.json',
|
|
14
14
|
'/home/runner/work/captcha/captcha/packages/api-route/tsconfig.json',
|
|
@@ -19,11 +19,11 @@ ViteEsmConfig: .
|
|
|
19
19
|
{
|
|
20
20
|
externals: [
|
|
21
21
|
'@prosopo/common',
|
|
22
|
+
'@prosopo/types',
|
|
22
23
|
'@prosopo/locale',
|
|
23
24
|
'@prosopo/util',
|
|
24
|
-
'@prosopo/logger',
|
|
25
|
-
'@prosopo/types',
|
|
26
25
|
'@prosopo/util-crypto',
|
|
26
|
+
'@prosopo/logger',
|
|
27
27
|
'@prosopo/types-database',
|
|
28
28
|
'@prosopo/user-access-policy',
|
|
29
29
|
'@prosopo/api-route',
|
|
@@ -32,10 +32,10 @@ ViteEsmConfig: .
|
|
|
32
32
|
]
|
|
33
33
|
}
|
|
34
34
|
[33mThe plugin "vite-tsconfig-paths" is detected. Vite now supports tsconfig paths resolution natively via the [1mresolve.tsconfigPaths[22m option. You can remove the plugin and set [1mresolve.tsconfigPaths: true[22m in your Vite config instead.[39m
|
|
35
|
-
[36mvite v8.1.
|
|
35
|
+
[36mvite v8.1.6 [32mbuilding ssr environment for production...[36m[39m
|
|
36
36
|
Bundle build started
|
|
37
37
|
[2K
|
|
38
|
-
✓
|
|
38
|
+
✓ 13 modules transformed.
|
|
39
39
|
rendering chunks...
|
|
40
40
|
computing gzip size...
|
|
41
41
|
dist/_virtual/_rolldown/runtime.js 0.04 kB │ gzip: 0.06 kB
|
|
@@ -43,12 +43,13 @@ dist/base/index.js 0.14 kB │ gzip: 0.08 kB
|
|
|
43
43
|
dist/base/mongoMemory.js 0.60 kB │ gzip: 0.30 kB
|
|
44
44
|
dist/databases/index.js 0.77 kB │ gzip: 0.27 kB
|
|
45
45
|
dist/index.js 1.07 kB │ gzip: 0.38 kB
|
|
46
|
-
dist/databases/
|
|
46
|
+
dist/databases/clientRecordCache.js 1.40 kB │ gzip: 0.68 kB
|
|
47
|
+
dist/databases/client.js 1.73 kB │ gzip: 0.77 kB
|
|
47
48
|
dist/mongooseOptions.js 3.58 kB │ gzip: 1.53 kB
|
|
48
|
-
dist/base/mongo.js 4.
|
|
49
|
+
dist/base/mongo.js 4.04 kB │ gzip: 1.33 kB
|
|
49
50
|
dist/databases/centralDbStreamer.js 6.33 kB │ gzip: 1.51 kB
|
|
50
|
-
dist/databases/captcha.js 8.
|
|
51
|
-
dist/redisCache.js 14.
|
|
52
|
-
dist/databases/provider.js
|
|
51
|
+
dist/databases/captcha.js 8.17 kB │ gzip: 2.38 kB
|
|
52
|
+
dist/redisCache.js 14.25 kB │ gzip: 4.43 kB
|
|
53
|
+
dist/databases/provider.js 68.90 kB │ gzip: 13.47 kB
|
|
53
54
|
|
|
54
|
-
[32m✓ built in
|
|
55
|
+
[32m✓ built in 140ms[39m
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,73 @@
|
|
|
1
1
|
# @prosopo/database
|
|
2
2
|
|
|
3
|
+
## 4.2.9
|
|
4
|
+
### Patch Changes
|
|
5
|
+
|
|
6
|
+
- @prosopo/types@5.17.1
|
|
7
|
+
- @prosopo/types-database@5.11.1
|
|
8
|
+
- @prosopo/common@3.3.0
|
|
9
|
+
- @prosopo/user-access-policy@3.15.6
|
|
10
|
+
|
|
11
|
+
## 4.2.8
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- 46b97b7: Roll up the open Dependabot updates: express 5 (with `@types/express` 5), dotenv 18, undici 8, geolib 4, vitest 5, vite 8.1.6 everywhere, 17 minor and patch bumps (Babel, mongoose, i18next, ip-address, turbo and others), `@angular/router` in the Angular demo, and a GitHub Actions bump.
|
|
15
|
+
|
|
16
|
+
The whole vitest family moves to 5.0.4, including `@vitest/coverage-v8`, because `@vitest/browser-playwright` 5 only works with vitest 5. The `@types/express-serve-static-core` override moves to 5.1.3 to match `@types/express` 5.
|
|
17
|
+
|
|
18
|
+
`@prosopo/dotenv` now loads env files with `quiet: true`. Since dotenv 17, every load prints an "injected env" line to stderr unless told not to.
|
|
19
|
+
- d2148c8: Errors now carry a fixed code and a site instead of a translation key.
|
|
20
|
+
|
|
21
|
+
Every error is a `ProsopoError` with a `code` from one list in
|
|
22
|
+
`@prosopo/common` (`ERROR_CODES`) and an `errorSite` such as `PROV-12`, which
|
|
23
|
+
names the one place it was thrown. Together they make the `errorId`, e.g.
|
|
24
|
+
`SITE_KEY_INVALID:PROV-31`, which the widget shows after the message so a
|
|
25
|
+
screenshot is enough to find the throw.
|
|
26
|
+
|
|
27
|
+
What a client sees:
|
|
28
|
+
|
|
29
|
+
- A public error (bad site key, blocked network, and so on) sends its code,
|
|
30
|
+
English message, data and errorId.
|
|
31
|
+
- Anything else sends only `BACKEND_ERROR:<site>` (or `FRONTEND_ERROR:<site>`
|
|
32
|
+
from the widget) and a status. Internal details never leave the server.
|
|
33
|
+
|
|
34
|
+
The provider no longer translates errors. The widget looks up
|
|
35
|
+
`ERRORS.<CODE>` in its catalogue and falls back to the English message. The
|
|
36
|
+
old error classes (`ProsopoApiError`, `ProsopoEnvError` and the rest), the
|
|
37
|
+
`key`/`messageEn` fields and `localiseErrorMessage` are gone.
|
|
38
|
+
|
|
39
|
+
Other changes in behaviour:
|
|
40
|
+
|
|
41
|
+
- An error with no specific code is a hidden 500.
|
|
42
|
+
- Errors no longer log themselves when they are created. The server logs each
|
|
43
|
+
unhandled one once: 5xx as errors, 4xx at debug.
|
|
44
|
+
- An invalid PoW signature is a 401 instead of a 500.
|
|
45
|
+
- `stringifyBigInts` returns a copy instead of changing its input, so frozen
|
|
46
|
+
error context can be logged.
|
|
47
|
+
- The provider's last hand-written error replies now use the same error body.
|
|
48
|
+
These were the missing-header 401s, the access-policy block, autoBan, the
|
|
49
|
+
metrics 401/403 and the rate limiter. The rate limiter answers with a new
|
|
50
|
+
public `RATE_LIMITED` (429) code.
|
|
51
|
+
- 860948c: Server-side verify (what siteverify calls) now does far less waiting. A PoW verify used to make about 19 database and ip-lookup calls one after another; it now makes about 6, and a rejected verify fewer. Changes:
|
|
52
|
+
|
|
53
|
+
- The ip lookup that runs on every request is skipped on verify routes. Nothing on verify used it, and the caller there is the site's server, not the user.
|
|
54
|
+
- The session record is read once instead of twice, and the client record once instead of twice.
|
|
55
|
+
- DNS enrichment and the user's ip lookup run alongside the access-rule check instead of after it. The ip lookup is skipped once a check has already failed.
|
|
56
|
+
- The verify answers without waiting for its two bookkeeping writes, unless 500 are already waiting, so a slow database cannot pile them up in memory. The single-use claim is still made before anything else, so a token still verifies only once.
|
|
57
|
+
- Decision-machine artifacts are cached per process. They were cached per request, so every verify read them from Mongo. Saving or deleting a machine clears the cache.
|
|
58
|
+
- Client records are cached for 30 seconds and the cache is cleared by every client-record write in the process.
|
|
59
|
+
- Successful ip lookups are cached for 10 minutes, so an address is not looked up twice in one verify, or again at verify after the challenge looked it up.
|
|
60
|
+
- Updated dependencies [46b97b7]
|
|
61
|
+
- Updated dependencies [d2148c8]
|
|
62
|
+
- Updated dependencies [2bcf2fe]
|
|
63
|
+
- @prosopo/common@3.3.0
|
|
64
|
+
- @prosopo/logger@2.1.5
|
|
65
|
+
- @prosopo/redis-client@1.0.42
|
|
66
|
+
- @prosopo/types@5.17.0
|
|
67
|
+
- @prosopo/types-database@5.11.0
|
|
68
|
+
- @prosopo/user-access-policy@3.15.5
|
|
69
|
+
- @prosopo/util@3.3.16
|
|
70
|
+
|
|
3
71
|
## 4.2.7
|
|
4
72
|
### Patch Changes
|
|
5
73
|
|
package/dist/base/mongo.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mongo.d.ts","sourceRoot":"","sources":["../../src/base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BAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,wBAAwB,CAAC,EAAE,MAAM,CAAC;CAClC;AAQD,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;IACnC,SAAS,CAAC,QAAQ,CAAC,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC7C,SAAS,CAAC,QAAQ,CAAC,wBAAwB,CAAC,EAAE,MAAM,CAAC;gBAGpD,GAAG,EAAE,MAAM,EACX,MAAM,CAAC,EAAE,MAAM,EACf,UAAU,CAAC,EAAE,MAAM,EACnB,MAAM,CAAC,EAAE,MAAM,EACf,QAAQ,CAAC,EAAE,uBAAuB;IAoBnC,IAAI,GAAG,IAAI,MAAM,CAEhB;IAED,aAAa,IAAI,QAAQ,CAAC,UAAU;IAe9B,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAyIxB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAM5B"}
|
package/dist/base/mongo.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { getMongoConnectionOptions } from "../mongooseOptions.js";
|
|
2
2
|
import { fileURLToPath } from "node:url";
|
|
3
|
-
import {
|
|
3
|
+
import { ProsopoError } from "@prosopo/common";
|
|
4
4
|
import { getLogger } from "@prosopo/logger";
|
|
5
5
|
import mongoose from "mongoose";
|
|
6
6
|
//#region src/base/mongo.ts
|
|
@@ -29,9 +29,11 @@ var MongoDatabase = class {
|
|
|
29
29
|
return this._url;
|
|
30
30
|
}
|
|
31
31
|
getConnection() {
|
|
32
|
-
if (!this.connection) throw new
|
|
33
|
-
|
|
34
|
-
|
|
32
|
+
if (!this.connection) throw new ProsopoError({
|
|
33
|
+
code: "DB_UNAVAILABLE",
|
|
34
|
+
errorSite: "DBSE-1",
|
|
35
|
+
message: "Connection undefined",
|
|
36
|
+
context: { failedFuncName: this.getConnection.name }
|
|
35
37
|
});
|
|
36
38
|
return this.connection;
|
|
37
39
|
}
|
package/dist/base/mongo.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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,
|
|
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,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,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;AAiBrD,MAAM,OAAO,aAAa;IAWzB,YACC,GAAW,EACX,MAAe,EACf,UAAmB,EACnB,MAAe,EACf,QAAkC;QAVnC,cAAS,GAAG,KAAK,CAAC;QAYjB,IAAI,CAAC,gBAAgB,GAAG,QAAQ,EAAE,gBAAgB,CAAC;QACnD,IAAI,CAAC,wBAAwB,GAAG,QAAQ,EAAE,wBAAwB,CAAC;QACnE,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;QAC7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AE,GAAG,EAAE;oBAC3B,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC;oBACvB,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC;wBACxB,GAAG,EAAE,4BAA4B;qBACjC,CAAC,CAAC,CAAC;gBACL,CAAC,CAAC,CAAC;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,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,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,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
|
@@ -31,9 +31,11 @@ var MongoDatabase = class {
|
|
|
31
31
|
return this._url;
|
|
32
32
|
}
|
|
33
33
|
getConnection() {
|
|
34
|
-
if (!this.connection) throw new _prosopo_common.
|
|
35
|
-
|
|
36
|
-
|
|
34
|
+
if (!this.connection) throw new _prosopo_common.ProsopoError({
|
|
35
|
+
code: "DB_UNAVAILABLE",
|
|
36
|
+
errorSite: "DBSE-1",
|
|
37
|
+
message: "Connection undefined",
|
|
38
|
+
context: { failedFuncName: this.getConnection.name }
|
|
37
39
|
});
|
|
38
40
|
return this.connection;
|
|
39
41
|
}
|
|
@@ -51,9 +51,11 @@ var CaptchaDatabase = class CaptchaDatabase extends require_mongo.MongoDatabase
|
|
|
51
51
|
});
|
|
52
52
|
}
|
|
53
53
|
getTables() {
|
|
54
|
-
if (!this.tables) throw new _prosopo_common.
|
|
55
|
-
|
|
56
|
-
|
|
54
|
+
if (!this.tables) throw new _prosopo_common.ProsopoError({
|
|
55
|
+
code: "DB_UNAVAILABLE",
|
|
56
|
+
errorSite: "DBSE-2",
|
|
57
|
+
message: "Tables undefined",
|
|
58
|
+
context: { failedFuncName: this.getTables.name }
|
|
57
59
|
});
|
|
58
60
|
return this.tables;
|
|
59
61
|
}
|
|
@@ -220,14 +222,15 @@ var CaptchaDatabase = class CaptchaDatabase extends require_mongo.MongoDatabase
|
|
|
220
222
|
iconOrderCaptchaRecords: await this.tables.iconordercaptcha.find(filter).limit(limit).lean()
|
|
221
223
|
};
|
|
222
224
|
} catch (error) {
|
|
223
|
-
throw new _prosopo_common.
|
|
225
|
+
throw new _prosopo_common.ProsopoError({
|
|
226
|
+
code: "DB_QUERY_FAILED",
|
|
227
|
+
errorSite: "DBSE-3",
|
|
228
|
+
cause: error,
|
|
224
229
|
context: {
|
|
225
|
-
error,
|
|
226
230
|
filter,
|
|
227
231
|
limit,
|
|
228
232
|
failedFuncName: this.getCaptchas.name
|
|
229
|
-
}
|
|
230
|
-
logger: this.logger
|
|
233
|
+
}
|
|
231
234
|
});
|
|
232
235
|
} finally {
|
|
233
236
|
await this.close();
|
|
@@ -19,9 +19,11 @@ var ClientDatabase = class extends require_mongo.MongoDatabase {
|
|
|
19
19
|
});
|
|
20
20
|
}
|
|
21
21
|
getTables() {
|
|
22
|
-
if (!this.tables) throw new _prosopo_common.
|
|
23
|
-
|
|
24
|
-
|
|
22
|
+
if (!this.tables) throw new _prosopo_common.ProsopoError({
|
|
23
|
+
code: "DB_UNAVAILABLE",
|
|
24
|
+
errorSite: "DBSE-4",
|
|
25
|
+
message: "Tables undefined",
|
|
26
|
+
context: { failedFuncName: this.getTables.name }
|
|
25
27
|
});
|
|
26
28
|
return this.tables;
|
|
27
29
|
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
//#region src/databases/clientRecordCache.ts
|
|
2
|
+
/**
|
|
3
|
+
* Every client-record write in this process clears the cache, so the TTL only
|
|
4
|
+
* bounds staleness from writes made outside it, such as a hand edit in Mongo.
|
|
5
|
+
* Settings already take minutes to reach a provider through the client-list
|
|
6
|
+
* sync, so 30s is well inside what operators see today.
|
|
7
|
+
*/
|
|
8
|
+
var CLIENT_RECORD_CACHE_TTL_MS = 3e4;
|
|
9
|
+
var CLIENT_RECORD_CACHE_MAX_ENTRIES = 5e4;
|
|
10
|
+
/**
|
|
11
|
+
* Shared by every database instance in the process, because the client-list
|
|
12
|
+
* scheduler writes through its own instance and those writes must clear the
|
|
13
|
+
* entries the request path reads. Missing records are never cached, so a site
|
|
14
|
+
* key registered elsewhere is found as soon as it lands.
|
|
15
|
+
*/
|
|
16
|
+
var ClientRecordCache = class {
|
|
17
|
+
constructor() {
|
|
18
|
+
this.entries = /* @__PURE__ */ new Map();
|
|
19
|
+
}
|
|
20
|
+
get(key) {
|
|
21
|
+
const entry = this.entries.get(key);
|
|
22
|
+
if (!entry) return void 0;
|
|
23
|
+
if (entry.expiresAt <= Date.now()) {
|
|
24
|
+
this.entries.delete(key);
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
return structuredClone(entry.record);
|
|
28
|
+
}
|
|
29
|
+
set(key, record) {
|
|
30
|
+
if (this.entries.size >= CLIENT_RECORD_CACHE_MAX_ENTRIES) this.entries.clear();
|
|
31
|
+
this.entries.set(key, {
|
|
32
|
+
record: structuredClone(record),
|
|
33
|
+
expiresAt: Date.now() + CLIENT_RECORD_CACHE_TTL_MS
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
clear() {
|
|
37
|
+
this.entries.clear();
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
var clientRecordCache = new ClientRecordCache();
|
|
41
|
+
//#endregion
|
|
42
|
+
exports.CLIENT_RECORD_CACHE_TTL_MS = CLIENT_RECORD_CACHE_TTL_MS;
|
|
43
|
+
exports.clientRecordCache = clientRecordCache;
|