@prosopo/cli 3.6.48 → 3.6.49

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.
@@ -1,5 +1,5 @@
1
1
 
2
- > @prosopo/cli@3.6.48 build:cjs
2
+ > @prosopo/cli@3.6.49 build:cjs
3
3
  > NODE_ENV=${NODE_ENV:-development}; vite build --config vite.cjs.config.ts --mode $NODE_ENV
4
4
 
5
5
  ViteCommonJSConfig: .
@@ -1,8 +1,8 @@
1
1
 
2
- > @prosopo/cli@3.6.48 build:tsc
2
+ > @prosopo/cli@3.6.49 build:tsc
3
3
  > tsc --build --verbose
4
4
 
5
- 3:25:42 PM - Projects in this build:
5
+ 10:33:46 PM - Projects in this build:
6
6
  * ../../dev/config/tsconfig.json
7
7
  * ../locale/tsconfig.json
8
8
  * ../util/tsconfig.json
@@ -28,53 +28,53 @@
28
28
  * ../../dev/workspace/tsconfig.json
29
29
  * tsconfig.json
30
30
 
31
- 3:25:42 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'
31
+ 10:33:47 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'
32
32
 
33
- 3:25:42 PM - Project '../locale/tsconfig.json' is up to date because newest input '../locale/src/translationKey.ts' is older than output '../locale/tsconfig.tsbuildinfo'
33
+ 10:33:47 PM - Project '../locale/tsconfig.json' is up to date because newest input '../locale/src/translationKey.ts' is older than output '../locale/tsconfig.tsbuildinfo'
34
34
 
35
- 3:25:42 PM - Project '../util/tsconfig.json' is up to date because newest input '../util/src/url.ts' is older than output '../util/tsconfig.tsbuildinfo'
35
+ 10:33:47 PM - Project '../util/tsconfig.json' is up to date because newest input '../util/src/url.ts' is older than output '../util/tsconfig.tsbuildinfo'
36
36
 
37
- 3:25:42 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'
37
+ 10:33:47 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'
38
38
 
39
- 3:25:42 PM - Project '../types/tsconfig.json' is up to date because newest input '../types/src/procaptcha/api.ts' is older than output '../types/tsconfig.tsbuildinfo'
39
+ 10:33:47 PM - Project '../types/tsconfig.json' is up to date because newest input '../types/src/provider/api.ts' is older than output '../types/tsconfig.tsbuildinfo'
40
40
 
41
- 3:25:42 PM - Project '../api/tsconfig.json' is up to date because newest input '../api/src/index.ts' is older than output '../api/tsconfig.tsbuildinfo'
41
+ 10:33:47 PM - Project '../api/tsconfig.json' is up to date because newest input '../api/src/index.ts' is older than output '../api/tsconfig.tsbuildinfo'
42
42
 
43
- 3:25:42 PM - Project '../logger/tsconfig.json' is up to date because newest input '../logger/src/index.ts' is older than output '../logger/tsconfig.tsbuildinfo'
43
+ 10:33:47 PM - Project '../logger/tsconfig.json' is up to date because newest input '../logger/src/logger.ts' is older than output '../logger/tsconfig.tsbuildinfo'
44
44
 
45
- 3:25:42 PM - Project '../common/tsconfig.json' is up to date because newest input '../common/src/error.ts' is older than output '../common/tsconfig.tsbuildinfo'
45
+ 10:33:47 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'
46
46
 
47
- 3:25:42 PM - Project '../dotenv/tsconfig.json' is up to date because newest input '../dotenv/src/env.ts' is older than output '../dotenv/tsconfig.tsbuildinfo'
47
+ 10:33:47 PM - Project '../dotenv/tsconfig.json' is up to date because newest input '../dotenv/src/env.ts' is older than output '../dotenv/tsconfig.tsbuildinfo'
48
48
 
49
- 3:25:42 PM - Project '../ipinfo/tsconfig.json' is up to date because newest input '../ipinfo/src/IpInfoService.ts' is older than output '../ipinfo/tsconfig.tsbuildinfo'
49
+ 10:33:47 PM - Project '../ipinfo/tsconfig.json' is up to date because newest input '../ipinfo/src/IpInfoService.ts' is older than output '../ipinfo/tsconfig.tsbuildinfo'
50
50
 
51
- 3:25:42 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'
51
+ 10:33:47 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'
52
52
 
53
- 3:25:42 PM - Project '../redis-client/tsconfig.json' is up to date because newest input '../redis-client/src/redisClient.ts' is older than output '../redis-client/tsconfig.tsbuildinfo'
53
+ 10:33:47 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'
54
54
 
55
- 3:25:42 PM - Project '../user-access-policy/tsconfig.json' is up to date because newest input '../user-access-policy/src/ruleRecord.ts' is older than output '../user-access-policy/tsconfig.tsbuildinfo'
55
+ 10:33:47 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'
56
56
 
57
- 3:25:42 PM - Project '../types-database/tsconfig.json' is up to date because newest input '../types-database/src/types/captcha.ts' is older than output '../types-database/tsconfig.tsbuildinfo'
57
+ 10:33:47 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'
58
58
 
59
- 3:25:42 PM - Project '../database/tsconfig.json' is up to date because newest input '../database/src/tests/unit/databases/centralDbStreamer.unit.test.ts' is older than output '../database/tsconfig.tsbuildinfo'
59
+ 10:33:47 PM - Project '../database/tsconfig.json' is up to date because newest input '../database/src/tests/mongoGlobalSetup.ts' is older than output '../database/tsconfig.tsbuildinfo'
60
60
 
61
- 3:25:42 PM - Project '../keyring/tsconfig.json' is up to date because newest input '../keyring/src/index.ts' is older than output '../keyring/tsconfig.tsbuildinfo'
61
+ 10:33:47 PM - Project '../keyring/tsconfig.json' is up to date because newest input '../keyring/src/keyring/keyring.ts' is older than output '../keyring/tsconfig.tsbuildinfo'
62
62
 
63
- 3:25:42 PM - Project '../types-env/tsconfig.json' is up to date because newest input '../types-env/src/env.ts' is older than output '../types-env/tsconfig.tsbuildinfo'
63
+ 10:33:47 PM - Project '../types-env/tsconfig.json' is up to date because newest input '../types-env/src/env.ts' is older than output '../types-env/tsconfig.tsbuildinfo'
64
64
 
65
- 3:25:42 PM - Project '../env/tsconfig.json' is up to date because newest input '../env/src/env.ts' is older than output '../env/tsconfig.tsbuildinfo'
65
+ 10:33:47 PM - Project '../env/tsconfig.json' is up to date because newest input '../env/src/env.ts' is older than output '../env/tsconfig.tsbuildinfo'
66
66
 
67
- 3:25:42 PM - Project '../api-express-router/tsconfig.json' is up to date because newest input '../api-express-router/src/errorHandler.ts' is older than output '../api-express-router/tsconfig.tsbuildinfo'
67
+ 10:33:47 PM - Project '../api-express-router/tsconfig.json' is up to date because newest input '../api-express-router/src/tests/unit/errorHandler.unit.test.ts' is older than output '../api-express-router/tsconfig.tsbuildinfo'
68
68
 
69
- 3:25:42 PM - Project '../datasets/tsconfig.json' is up to date because newest input '../datasets/src/tests/mocks/data/captchas.ts' is older than output '../datasets/tsconfig.tsbuildinfo'
69
+ 10:33:47 PM - Project '../datasets/tsconfig.json' is up to date because newest input '../datasets/src/tests/dataset.unit.test.ts' is older than output '../datasets/tsconfig.tsbuildinfo'
70
70
 
71
- 3:25:42 PM - Project '../load-balancer/tsconfig.json' is up to date because newest input '../load-balancer/src/balancer.ts' is older than output '../load-balancer/tsconfig.tsbuildinfo'
71
+ 10:33:47 PM - Project '../load-balancer/tsconfig.json' is up to date because newest input '../load-balancer/src/index.ts' is older than output '../load-balancer/tsconfig.tsbuildinfo'
72
72
 
73
- 3:25:42 PM - Project '../provider/tsconfig.json' is up to date because newest input '../provider/src/util.ts' is older than output '../provider/tsconfig.tsbuildinfo'
73
+ 10:33:47 PM - Project '../provider/tsconfig.json' is up to date because newest input '../provider/src/utils/dns.ts' is older than output '../provider/tsconfig.tsbuildinfo'
74
74
 
75
- 3:25:42 PM - Project '../../dev/workspace/tsconfig.json' is up to date because newest input '../../dev/workspace/src/index.ts' is older than output '../../dev/workspace/tsconfig.tsbuildinfo'
75
+ 10:33:47 PM - Project '../../dev/workspace/tsconfig.json' is up to date because newest input '../../dev/workspace/src/index.ts' is older than output '../../dev/workspace/tsconfig.tsbuildinfo'
76
76
 
77
- 3:25:42 PM - Project 'tsconfig.json' is out of date because output file 'tsconfig.tsbuildinfo' does not exist
77
+ 10:33:47 PM - Project 'tsconfig.json' is out of date because output file 'tsconfig.tsbuildinfo' does not exist
78
78
 
79
- 3:25:42 PM - Building project '/home/runner/work/captcha/captcha/packages/cli/tsconfig.json'...
79
+ 10:33:47 PM - Building project '/home/runner/work/captcha/captcha/packages/cli/tsconfig.json'...
80
80
 
@@ -1,9 +1,9 @@
1
1
 
2
- > @prosopo/cli@3.6.48 build
2
+ > @prosopo/cli@3.6.49 build
3
3
  > npm run build:cross-env -- --mode ${NODE_ENV:-development}
4
4
 
5
5
 
6
- > @prosopo/cli@3.6.48 build:cross-env
6
+ > @prosopo/cli@3.6.49 build:cross-env
7
7
  > vite build --config vite.esm.config.ts --mode production
8
8
 
9
9
  ViteEsmConfig: .
@@ -83,4 +83,4 @@ rendering chunks...
83
83
  dist/commands/siteKeyRegister.js 3.67 kB
84
84
  dist/prosopo.config.js 4.91 kB
85
85
  dist/RateLimiter.js 5.25 kB
86
- ✓ built in 346ms
86
+ ✓ built in 360ms
package/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # @prosopo/cli
2
2
 
3
+ ## 3.6.49
4
+ ### Patch Changes
5
+
6
+ - Updated dependencies [ec363e9]
7
+ - @prosopo/provider@4.13.1
8
+ - @prosopo/env@3.6.2
9
+
3
10
  ## 3.6.48
4
11
  ### Patch Changes
5
12
 
@@ -1758,7 +1758,7 @@ function zr(e, t, r) {
1758
1758
  throw new Error(`Index ${t} smaller than 0`);
1759
1759
  return e[t];
1760
1760
  }
1761
- const yMe = typeof process < "u" ? "3.6.48" : void 0, Ave = yMe || "dev", k6 = new Array(256), bve = new Array(256 * 256);
1761
+ const yMe = typeof process < "u" ? "3.6.49" : void 0, Ave = yMe || "dev", k6 = new Array(256), bve = new Array(256 * 256);
1762
1762
  for (let e = 0; e < 256; e++)
1763
1763
  k6[e] = e.toString(16).padStart(2, "0");
1764
1764
  for (let e = 0; e < 256; e++) {
@@ -95293,6 +95293,87 @@ class I2e {
95293
95293
  })), null;
95294
95294
  }
95295
95295
  }
95296
+ /**
95297
+ * Cache an origin → escalation sessionId mapping for the post-PoW
95298
+ * escalation flow.
95299
+ *
95300
+ * Background: when the routing machine returns image/puzzle from the
95301
+ * postPow phase, `buildEscalation` (`api/captcha/submitPoWCaptchaSolution.ts`)
95302
+ * mints a new session with a fresh `sessionId` and returns it on the
95303
+ * `escalation` field. A widget that handles the escalation cleanly
95304
+ * mounts the next captcha with the new sessionId. But there are
95305
+ * several real-world paths where the widget keeps using the original
95306
+ * sessionId for the follow-up `/captcha/{type}` request — bundled SDK
95307
+ * versions that predate the escalation handler, dapps that hand-roll
95308
+ * the wrapper, network-glitch retries, or browser-tab races. The
95309
+ * original session has been consumed and soft-deleted by the
95310
+ * preceding `/captcha/pow`, so the follow-up gets
95311
+ * `CAPTCHA.NO_SESSION_FOUND` and the user sees an inline error → FAQ.
95312
+ *
95313
+ * This mapping lets `isValidRequest` resolve the original sessionId
95314
+ * forward to the live escalation session and proceed normally.
95315
+ *
95316
+ * TTL is short on purpose: escalation handoffs complete in seconds
95317
+ * (the user solves the follow-up immediately) and a stale mapping
95318
+ * pointing at a long-gone session would just produce a different
95319
+ * shape of NO_SESSION_FOUND.
95320
+ */
95321
+ async cacheSessionEscalation(t, r, n = 600) {
95322
+ const i = await this.getClient();
95323
+ if (!i)
95324
+ return !1;
95325
+ try {
95326
+ const s = `cache:session:escalation:${t}`;
95327
+ return await i.set(s, r, { EX: n }), !0;
95328
+ } catch (s) {
95329
+ return this.logger.warn(() => ({
95330
+ msg: "Failed to cache session escalation mapping in Redis",
95331
+ err: s,
95332
+ originSessionId: t,
95333
+ escalationSessionId: r
95334
+ })), !1;
95335
+ }
95336
+ }
95337
+ /**
95338
+ * Resolve an original sessionId to its escalation sessionId, if one was
95339
+ * recorded. Returns null when there is no mapping (either no escalation
95340
+ * happened, or the TTL has elapsed).
95341
+ */
95342
+ async getCachedSessionEscalation(t) {
95343
+ const r = await this.getClient();
95344
+ if (!r)
95345
+ return null;
95346
+ try {
95347
+ const n = `cache:session:escalation:${t}`;
95348
+ return await r.get(n);
95349
+ } catch (n) {
95350
+ return this.logger.warn(() => ({
95351
+ msg: "Failed to get cached session escalation mapping from Redis",
95352
+ err: n,
95353
+ originSessionId: t
95354
+ })), null;
95355
+ }
95356
+ }
95357
+ /**
95358
+ * Invalidate an escalation mapping. Called when the escalation session
95359
+ * itself is consumed so subsequent retries on the origin sessionId fall
95360
+ * through to the standard NO_SESSION_FOUND path rather than chasing a
95361
+ * second-hand stale pointer.
95362
+ */
95363
+ async invalidateCachedSessionEscalation(t) {
95364
+ const r = await this.getClient();
95365
+ if (r)
95366
+ try {
95367
+ const n = `cache:session:escalation:${t}`;
95368
+ await r.del(n);
95369
+ } catch (n) {
95370
+ this.logger.warn(() => ({
95371
+ msg: "Failed to invalidate cached session escalation mapping",
95372
+ err: n,
95373
+ originSessionId: t
95374
+ }));
95375
+ }
95376
+ }
95296
95377
  // ── Session write queue ─────────────────────────────────────────────
95297
95378
  /**
95298
95379
  * Queue a session record for batched insertion into MongoDB.
@@ -101011,7 +101092,22 @@ class Og {
101011
101092
  this.writeQueue?.invalidateCachedSession(i),
101012
101093
  u ? this.writeQueue?.invalidateCachedSessionByHash(u) : Promise.resolve()
101013
101094
  ]);
101014
- const c = await this.db.checkAndRemoveSession(i);
101095
+ let c = await this.db.checkAndRemoveSession(i), l = i;
101096
+ if (!c && this.writeQueue) {
101097
+ const f = await this.writeQueue.getCachedSessionEscalation(i);
101098
+ if (f && f !== i) {
101099
+ this.logger.info(() => ({
101100
+ msg: "Resolving origin sessionId to escalation",
101101
+ data: {
101102
+ account: t.account,
101103
+ originSessionId: i,
101104
+ escalationSessionId: f
101105
+ }
101106
+ }));
101107
+ const d = await this.db.checkAndRemoveSession(f);
101108
+ d && (c = d, l = f), await this.writeQueue.invalidateCachedSessionEscalation(i);
101109
+ }
101110
+ }
101015
101111
  if (!c) {
101016
101112
  if (this.logger.warn(() => ({
101017
101113
  msg: "No session found",
@@ -101020,10 +101116,10 @@ class Og {
101020
101116
  sessionId: i
101021
101117
  }
101022
101118
  })), this.writeQueue) {
101023
- const l = typeof a?.userSitekeyIpHash == "string" ? a.userSitekeyIpHash : void 0;
101119
+ const f = typeof a?.userSitekeyIpHash == "string" ? a.userSitekeyIpHash : void 0;
101024
101120
  await Promise.all([
101025
101121
  this.writeQueue.invalidateCachedSession(i),
101026
- l ? this.writeQueue.invalidateCachedSessionByHash(l) : Promise.resolve()
101122
+ f ? this.writeQueue.invalidateCachedSessionByHash(f) : Promise.resolve()
101027
101123
  ]);
101028
101124
  }
101029
101125
  return {
@@ -101032,21 +101128,21 @@ class Og {
101032
101128
  type: r
101033
101129
  };
101034
101130
  }
101035
- if (this.writeQueue && await Promise.all([
101131
+ if (i = l, this.writeQueue && await Promise.all([
101036
101132
  this.writeQueue.invalidateCachedSession(i),
101037
101133
  c.userSitekeyIpHash ? this.writeQueue.invalidateCachedSessionByHash(
101038
101134
  c.userSitekeyIpHash
101039
101135
  ) : Promise.resolve()
101040
101136
  ]), o) {
101041
- const l = await this.validateSessionIP(
101137
+ const f = await this.validateSessionIP(
101042
101138
  c,
101043
101139
  o,
101044
101140
  n
101045
101141
  );
101046
- if (!l.valid)
101142
+ if (!f.valid)
101047
101143
  return {
101048
101144
  valid: !1,
101049
- reason: l.reason,
101145
+ reason: f.reason,
101050
101146
  type: r
101051
101147
  };
101052
101148
  }
@@ -120529,7 +120625,10 @@ const Xot = async (e, t) => {
120529
120625
  s.mode,
120530
120626
  s.simdReadings
120531
120627
  );
120532
- return {
120628
+ return e.writeQueue && await e.writeQueue.cacheSessionEscalation(
120629
+ i.sessionId,
120630
+ u.sessionId
120631
+ ), {
120533
120632
  captchaType: o.captchaType,
120534
120633
  sessionId: u.sessionId
120535
120634
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prosopo/cli",
3
- "version": "3.6.48",
3
+ "version": "3.6.49",
4
4
  "description": "CLI for Prosopo Provider",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -36,10 +36,10 @@
36
36
  "@prosopo/common": "3.1.41",
37
37
  "@prosopo/logger": "2.0.0",
38
38
  "@prosopo/dotenv": "3.0.46",
39
- "@prosopo/env": "3.6.1",
39
+ "@prosopo/env": "3.6.2",
40
40
  "@prosopo/keyring": "2.9.47",
41
41
  "@prosopo/locale": "3.2.5",
42
- "@prosopo/provider": "4.13.0",
42
+ "@prosopo/provider": "4.13.1",
43
43
  "@prosopo/types": "4.9.0",
44
44
  "@prosopo/util": "3.3.2",
45
45
  "@prosopo/workspace": "3.1.20",