@prosopo/load-balancer 2.8.17 → 2.9.11

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/load-balancer@2.8.17 build:cjs
2
+ > @prosopo/load-balancer@2.9.11 build:cjs
3
3
  > NODE_ENV=${NODE_ENV:-development}; vite build --config vite.cjs.config.ts --mode $NODE_ENV
4
4
 
5
5
  ViteCommonJSConfig: .
@@ -7,8 +7,9 @@ ViteCommonJSConfig: .
7
7
  tsConfigPaths: [
8
8
  '/home/runner/work/captcha/captcha/packages/common/tsconfig.json',
9
9
  '/home/runner/work/captcha/captcha/packages/locale/tsconfig.json',
10
- '/home/runner/work/captcha/captcha/packages/types/tsconfig.json',
10
+ '/home/runner/work/captcha/captcha/packages/logger/tsconfig.json',
11
11
  '/home/runner/work/captcha/captcha/packages/util/tsconfig.json',
12
+ '/home/runner/work/captcha/captcha/packages/types/tsconfig.json',
12
13
  '/home/runner/work/captcha/captcha/packages/util-crypto/tsconfig.json'
13
14
  ]
14
15
  }
@@ -16,8 +17,9 @@ ViteCommonJSConfig: .
16
17
  externals: [
17
18
  '@prosopo/common',
18
19
  '@prosopo/locale',
19
- '@prosopo/types',
20
+ '@prosopo/logger',
20
21
  '@prosopo/util',
22
+ '@prosopo/types',
21
23
  '@prosopo/util-crypto'
22
24
  ]
23
25
  }
@@ -27,7 +29,7 @@ transforming...
27
29
  Build end
28
30
  ✓ 3 modules transformed.
29
31
  rendering chunks...
30
- dist/cjs/index.cjs 0.53 kB
31
- dist/cjs/providers.cjs 1.39 kB
32
+ dist/cjs/index.cjs 0.64 kB
32
33
  dist/cjs/balancer.cjs 1.67 kB
33
- ✓ built in 187ms
34
+ dist/cjs/providers.cjs 2.10 kB
35
+ ✓ built in 125ms
@@ -1,29 +1,32 @@
1
1
 
2
- > @prosopo/load-balancer@2.8.17 build:tsc
2
+ > @prosopo/load-balancer@2.9.11 build:tsc
3
3
  > tsc --build --verbose
4
4
 
5
- 4:56:53 PM - Projects in this build:
5
+ 10:13:15 AM - Projects in this build:
6
6
  * ../../dev/config/tsconfig.json
7
7
  * ../locale/tsconfig.json
8
8
  * ../util/tsconfig.json
9
+ * ../logger/tsconfig.json
9
10
  * ../util-crypto/tsconfig.json
10
11
  * ../types/tsconfig.json
11
12
  * ../common/tsconfig.json
12
13
  * tsconfig.json
13
14
 
14
- 4:56:53 PM - Project '../../dev/config/tsconfig.json' is up to date because newest input '../../dev/config/src/dependencies.ts' is older than output '../../dev/config/tsconfig.tsbuildinfo'
15
+ 10:13:15 AM - 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'
15
16
 
16
- 4:56:53 PM - Project '../locale/tsconfig.json' is up to date because newest input '../locale/src/translationKey.ts' is older than output '../locale/tsconfig.tsbuildinfo'
17
+ 10:13:15 AM - Project '../locale/tsconfig.json' is up to date because newest input '../locale/src/util.ts' is older than output '../locale/tsconfig.tsbuildinfo'
17
18
 
18
- 4:56:53 PM - Project '../util/tsconfig.json' is up to date because newest input '../util/src/verifyRecency.ts' is older than output '../util/tsconfig.tsbuildinfo'
19
+ 10:13:15 AM - Project '../util/tsconfig.json' is up to date because newest input '../util/src/url.ts' is older than output '../util/tsconfig.tsbuildinfo'
19
20
 
20
- 4:56:53 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'
21
+ 10:13:15 AM - Project '../logger/tsconfig.json' is up to date because newest input '../logger/src/index.ts' is older than output '../logger/tsconfig.tsbuildinfo'
21
22
 
22
- 4:56:53 PM - Project '../types/tsconfig.json' is up to date because newest input '../types/src/procaptcha/api.ts' is older than output '../types/tsconfig.tsbuildinfo'
23
+ 10:13:15 AM - 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'
23
24
 
24
- 4:56:53 PM - Project '../common/tsconfig.json' is up to date because newest input '../common/src/logger.ts' is older than output '../common/tsconfig.tsbuildinfo'
25
+ 10:13:15 AM - Project '../types/tsconfig.json' is up to date because newest input '../types/src/procaptcha/api.ts' is older than output '../types/tsconfig.tsbuildinfo'
25
26
 
26
- 4:56:53 PM - Project 'tsconfig.json' is out of date because output file 'tsconfig.tsbuildinfo' does not exist
27
+ 10:13:15 AM - Project '../common/tsconfig.json' is up to date because newest input '../common/src/index.ts' is older than output '../common/tsconfig.tsbuildinfo'
27
28
 
28
- 4:56:53 PM - Building project '/home/runner/work/captcha/captcha/packages/load-balancer/tsconfig.json'...
29
+ 10:13:15 AM - Project 'tsconfig.json' is out of date because output file 'tsconfig.tsbuildinfo' does not exist
30
+
31
+ 10:13:15 AM - Building project '/home/runner/work/captcha/captcha/packages/load-balancer/tsconfig.json'...
29
32
 
@@ -1,9 +1,9 @@
1
1
 
2
- > @prosopo/load-balancer@2.8.17 build
2
+ > @prosopo/load-balancer@2.9.11 build
3
3
  > npm run build:cross-env -- --mode ${NODE_ENV:-development}
4
4
 
5
5
 
6
- > @prosopo/load-balancer@2.8.17 build:cross-env
6
+ > @prosopo/load-balancer@2.9.11 build:cross-env
7
7
  > vite build --config vite.esm.config.ts --mode production
8
8
 
9
9
  ViteEsmConfig: .
@@ -11,8 +11,9 @@ ViteEsmConfig: .
11
11
  tsConfigPaths: [
12
12
  '/home/runner/work/captcha/captcha/packages/common/tsconfig.json',
13
13
  '/home/runner/work/captcha/captcha/packages/locale/tsconfig.json',
14
- '/home/runner/work/captcha/captcha/packages/types/tsconfig.json',
14
+ '/home/runner/work/captcha/captcha/packages/logger/tsconfig.json',
15
15
  '/home/runner/work/captcha/captcha/packages/util/tsconfig.json',
16
+ '/home/runner/work/captcha/captcha/packages/types/tsconfig.json',
16
17
  '/home/runner/work/captcha/captcha/packages/util-crypto/tsconfig.json'
17
18
  ]
18
19
  }
@@ -20,8 +21,9 @@ ViteEsmConfig: .
20
21
  externals: [
21
22
  '@prosopo/common',
22
23
  '@prosopo/locale',
23
- '@prosopo/types',
24
+ '@prosopo/logger',
24
25
  '@prosopo/util',
26
+ '@prosopo/types',
25
27
  '@prosopo/util-crypto'
26
28
  ]
27
29
  }
@@ -31,7 +33,7 @@ transforming...
31
33
  Build end
32
34
  ✓ 3 modules transformed.
33
35
  rendering chunks...
34
- dist/index.js 0.33 kB
35
- dist/providers.js 1.22 kB
36
+ dist/index.js 0.41 kB
36
37
  dist/balancer.js 1.50 kB
37
- ✓ built in 150ms
38
+ dist/providers.js 1.88 kB
39
+ ✓ built in 168ms
package/CHANGELOG.md CHANGED
@@ -1,5 +1,282 @@
1
1
  # @prosopo/load-balancer
2
2
 
3
+ ## 2.9.11
4
+ ### Patch Changes
5
+
6
+ - Updated dependencies [b03dad1]
7
+ - @prosopo/types@4.3.1
8
+
9
+ ## 2.9.10
10
+ ### Patch Changes
11
+
12
+ - Updated dependencies [a1d60db]
13
+ - Updated dependencies [2392aaf]
14
+ - @prosopo/types@4.3.0
15
+ - @prosopo/common@3.1.38
16
+
17
+ ## 2.9.9
18
+ ### Patch Changes
19
+
20
+ - Updated dependencies [6c26669]
21
+ - Updated dependencies [f7f9ec5]
22
+ - @prosopo/types@4.2.1
23
+
24
+ ## 2.9.8
25
+ ### Patch Changes
26
+
27
+ - Updated dependencies [0fd81af]
28
+ - @prosopo/common@3.1.37
29
+
30
+ ## 2.9.7
31
+ ### Patch Changes
32
+
33
+ - Updated dependencies [20cae63]
34
+ - Updated dependencies [4d9923e]
35
+ - @prosopo/types@4.2.0
36
+
37
+ ## 2.9.6
38
+ ### Patch Changes
39
+
40
+ - Updated dependencies [d351362]
41
+ - @prosopo/types@4.1.4
42
+
43
+ ## 2.9.5
44
+ ### Patch Changes
45
+
46
+ - Updated dependencies [e2711ae]
47
+ - Updated dependencies [5786629]
48
+ - @prosopo/types@4.1.3
49
+ - @prosopo/common@3.1.36
50
+
51
+ ## 2.9.4
52
+ ### Patch Changes
53
+
54
+ - @prosopo/types@4.1.2
55
+
56
+ ## 2.9.3
57
+ ### Patch Changes
58
+
59
+ - Updated dependencies [91958da]
60
+ - @prosopo/types@4.1.1
61
+ - @prosopo/common@3.1.35
62
+
63
+ ## 2.9.2
64
+ ### Patch Changes
65
+
66
+ - Updated dependencies [6a741ce]
67
+ - @prosopo/types@4.1.0
68
+
69
+ ## 2.9.1
70
+ ### Patch Changes
71
+
72
+ - 4aae4e6: Pull the frictionless POST critical path down by ~340ms on the test
73
+ hardware via four focused changes:
74
+
75
+ - **Inline Signer.** `@polkadot/extension-base/page/Signer` is now a
76
+ static import in `ExtensionWeb2`. It's 0.5KB on disk but its dynamic
77
+ import was costing ~190ms of network round-trip; inlining removes
78
+ one separate chunk fetch + parse from the critical path.
79
+
80
+ - **Pre-warm the CryptoWorker.** `CryptoWorkerManager` gains a public
81
+ `prewarm()` that actually spawns the Worker and lets its script
82
+ parse during chunk-load time. Previously the call at module load
83
+ only instantiated the manager class; the worker itself spun up
84
+ lazily on the first `runTask`, putting the ~500ms worker module-eval
85
+ inside the first `createAccount()` call. Now it overlaps with chunk
86
+ loading and is hot by the time it's needed.
87
+
88
+ - **Prefetch providers at module load with an env-keyed cache.**
89
+ `prefetchProviders` and `getRandomActiveProvider` share an in-flight
90
+ `Promise<HardcodedProvider[]>` keyed by environment, so a module-load
91
+ prefetch and the later `customDetectBot` Promise.all reuse the same
92
+ network call. `procaptcha-frictionless` triggers the prefetch from
93
+ module-import time using `PROSOPO_DEFAULT_ENVIRONMENT` (browser-safe
94
+ `typeof process` guard + `EnvironmentTypesSchema.safeParse`), so the
95
+ HTTP fetch overlaps with chunk download instead of running as part
96
+ of the detection Promise.all.
97
+
98
+ - **Lazy-load the three captcha solvers.** `ProcaptchaFrictionless`
99
+ no longer statically imports `Procaptcha`, `ProcaptchaPuzzle`, and
100
+ `ProcaptchaPow`; each is `await import(...)` at the point the
101
+ frictionless response picks a type. Two of the three wrappers used
102
+ to be dead weight in the initial bundle; now only the chosen solver
103
+ is downloaded, after the frictionless POST has fired. Pulls ~64KB
104
+ of solver UI (chosen wrapper + Emotion dev runtime + builder + lazy
105
+ shim) out of the initial captchaRenderer chunk.
106
+
107
+ Combined with the earlier worker-related changes, the frictionless POST
108
+ on the puzzle-implicit test page is now ~1290ms vs ~1630ms before this
109
+ batch, and ~6500ms in the original baseline. The remaining floor is
110
+ dominated by the BotScoreWorker's obfuscated bundle parse + run.
111
+ - Updated dependencies [3c0be68]
112
+ - Updated dependencies [f9ea09d]
113
+ - Updated dependencies [d865319]
114
+ - Updated dependencies [753304b]
115
+ - Updated dependencies [8bb7286]
116
+ - Updated dependencies [f9ea09d]
117
+ - Updated dependencies [4aae4e6]
118
+ - Updated dependencies [4993813]
119
+ - @prosopo/types@4.0.0
120
+ - @prosopo/common@3.1.34
121
+
122
+ ## 2.9.0
123
+ ### Minor Changes
124
+
125
+ - 33a6c57: Provider speed ups
126
+
127
+ ### Patch Changes
128
+
129
+ - Updated dependencies [819ed95]
130
+ - @prosopo/types@3.16.1
131
+
132
+ ## 2.8.40
133
+ ### Patch Changes
134
+
135
+ - Updated dependencies [f6a4402]
136
+ - Updated dependencies [99dfb44]
137
+ - @prosopo/types@3.16.0
138
+
139
+ ## 2.8.39
140
+ ### Patch Changes
141
+
142
+ - Updated dependencies [3e54c0a]
143
+ - @prosopo/types@3.15.0
144
+
145
+ ## 2.8.38
146
+ ### Patch Changes
147
+
148
+ - Updated dependencies [946a8ba]
149
+ - Updated dependencies [5614814]
150
+ - @prosopo/types@3.14.1
151
+ - @prosopo/common@3.1.33
152
+
153
+ ## 2.8.37
154
+ ### Patch Changes
155
+
156
+ - Updated dependencies [fc514dd]
157
+ - Updated dependencies [42650db]
158
+ - @prosopo/types@3.14.0
159
+ - @prosopo/common@3.1.32
160
+
161
+ ## 2.8.36
162
+ ### Patch Changes
163
+
164
+ - Updated dependencies [4a9c518]
165
+ - @prosopo/common@3.1.31
166
+
167
+ ## 2.8.35
168
+ ### Patch Changes
169
+
170
+ - @prosopo/types@3.13.3
171
+
172
+ ## 2.8.34
173
+ ### Patch Changes
174
+
175
+ - @prosopo/types@3.13.2
176
+
177
+ ## 2.8.33
178
+ ### Patch Changes
179
+
180
+ - @prosopo/types@3.13.1
181
+
182
+ ## 2.8.32
183
+ ### Patch Changes
184
+
185
+ - Updated dependencies [e6d9553]
186
+ - @prosopo/types@3.13.0
187
+
188
+ ## 2.8.31
189
+ ### Patch Changes
190
+
191
+ - 730c61e: Speed up captcha
192
+ - Updated dependencies [d5082a9]
193
+ - Updated dependencies [e1ea65f]
194
+ - Updated dependencies [c316257]
195
+ - @prosopo/types@3.12.3
196
+
197
+ ## 2.8.30
198
+ ### Patch Changes
199
+
200
+ - Updated dependencies [adb89a6]
201
+ - @prosopo/types@3.12.2
202
+ - @prosopo/common@3.1.30
203
+
204
+ ## 2.8.29
205
+ ### Patch Changes
206
+
207
+ - Updated dependencies [c5ee492]
208
+ - Updated dependencies [a90eb54]
209
+ - @prosopo/common@3.1.29
210
+ - @prosopo/types@3.12.1
211
+
212
+ ## 2.8.28
213
+ ### Patch Changes
214
+
215
+ - 676c5f2: Use HTTPS in developmentwq
216
+ - Updated dependencies [676c5f2]
217
+ - Updated dependencies [feaca02]
218
+ - @prosopo/types@3.12.0
219
+
220
+ ## 2.8.27
221
+ ### Patch Changes
222
+
223
+ - Updated dependencies [8148587]
224
+ - @prosopo/types@3.11.1
225
+
226
+ ## 2.8.26
227
+ ### Patch Changes
228
+
229
+ - Updated dependencies [7f6ffc5]
230
+ - @prosopo/types@3.11.0
231
+
232
+ ## 2.8.25
233
+ ### Patch Changes
234
+
235
+ - Updated dependencies [93fa086]
236
+ - @prosopo/types@3.10.2
237
+
238
+ ## 2.8.24
239
+ ### Patch Changes
240
+
241
+ - Updated dependencies [cde7550]
242
+ - @prosopo/types@3.10.1
243
+
244
+ ## 2.8.23
245
+ ### Patch Changes
246
+
247
+ - Updated dependencies [ad6d622]
248
+ - @prosopo/types@3.10.0
249
+
250
+ ## 2.8.22
251
+ ### Patch Changes
252
+
253
+ - Updated dependencies [ff58a70]
254
+ - @prosopo/types@3.9.0
255
+
256
+ ## 2.8.21
257
+ ### Patch Changes
258
+
259
+ - Updated dependencies [d2431cd]
260
+ - @prosopo/types@3.8.4
261
+
262
+ ## 2.8.20
263
+ ### Patch Changes
264
+
265
+ - Updated dependencies [bd6995b]
266
+ - @prosopo/types@3.8.3
267
+
268
+ ## 2.8.19
269
+ ### Patch Changes
270
+
271
+ - Updated dependencies [9633e58]
272
+ - @prosopo/types@3.8.2
273
+
274
+ ## 2.8.18
275
+ ### Patch Changes
276
+
277
+ - Updated dependencies [f52a5c1]
278
+ - @prosopo/types@3.8.1
279
+
3
280
  ## 2.8.17
4
281
  ### Patch Changes
5
282
 
package/dist/balancer.js CHANGED
@@ -31,8 +31,8 @@ const loadBalancer = async (environment) => {
31
31
  return [
32
32
  {
33
33
  address: "5EjTA28bKSbFPPyMbUjNtArxyqjwq38r1BapVmLZShaqEedV",
34
- url: "http://localhost:9229",
35
- datasetId: "0x9f460e81ac9c71b486f796a21bb36e2263694756a6621134d110da217fd3ef25",
34
+ url: "https://localhost:9229",
35
+ datasetId: "0x7984714b92d61fd92fd6a7bc9b56b729481470bcc771c19c382ec679acf02e67",
36
36
  weight: 1
37
37
  }
38
38
  ];
@@ -1 +1 @@
1
- {"version":3,"file":"balancer.js","sourceRoot":"","sources":["../src/balancer.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAElD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,uBAAuB,GAAG,CAAC,CAAC,MAAM,CAAC;IACxC,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE;IACnB,GAAG,EAAE,CAAC,CAAC,MAAM,EAAE;IACf,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE;IACrB,MAAM,EAAE,CAAC;SACP,MAAM,EAAE;SACR,QAAQ,EA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C;IACF,OAAO,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;AAC7D,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,WAA6B,EAAU,EAAE;IAC3E,IAAI,WAAW,KAAK,YAAY,EAAE,CAAC;QAClC,OAAO,mCAAmC,CAAC;IAC5C,CAAC;IACD,IAAI,WAAW,KAAK,SAAS,EAAE,CAAC;QAC/B,OAAO,+CAA+C,CAAC;IACxD,CAAC;IACD,MAAM,IAAI,eAAe,CAAC,4BAA4B,EAAE;QACvD,OAAO,EAAE,EAAE,WAAW,EAAE;KACxB,CAAC,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,YAAY,GAAG,KAAK,EAChC,WAA6B,EACE,EAAE;IACjC,IAAI,WAAW,KAAK,aAAa,EAAE,CAAC;QACnC,OAAO;YACN;gBACC,OAAO,EAAE,kDAAkD;gBAC3D,GAAG,EAAE,wBAAwB;gBAC7B,SAAS,EACR,oEAAoE;gBACrE,MAAM,EAAE,CAAC;aACT;SACD,CAAC;IACH,CAAC;IAED,MAAM,SAAS,GAAoB,MAAM,KAAK,CAC7C,kBAAkB,CAAC,WAAW,CAAC,EAC/B;QACC,MAAM,EAAE,KAAK;QACb,IAAI,EAAE,MAAM;KACZ,CACD,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC;IAC5B,OAAO,qBAAqB,CAAC,SAAS,CAAC,CAAC;AACzC,CAAC,CAAC"}
@@ -33,8 +33,8 @@ const loadBalancer = async (environment) => {
33
33
  return [
34
34
  {
35
35
  address: "5EjTA28bKSbFPPyMbUjNtArxyqjwq38r1BapVmLZShaqEedV",
36
- url: "http://localhost:9229",
37
- datasetId: "0x9f460e81ac9c71b486f796a21bb36e2263694756a6621134d110da217fd3ef25",
36
+ url: "https://localhost:9229",
37
+ datasetId: "0x7984714b92d61fd92fd6a7bc9b56b729481470bcc771c19c382ec679acf02e67",
38
38
  weight: 1
39
39
  }
40
40
  ];
@@ -4,7 +4,9 @@ const providers = require("./providers.cjs");
4
4
  const balancer = require("./balancer.cjs");
5
5
  exports._resetCache = providers._resetCache;
6
6
  exports.getRandomActiveProvider = providers.getRandomActiveProvider;
7
+ exports.prefetchProviders = providers.prefetchProviders;
7
8
  exports.selectWeightedProvider = providers.selectWeightedProvider;
9
+ exports.setProviderLoader = providers.setProviderLoader;
8
10
  exports.convertHostedProvider = balancer.convertHostedProvider;
9
11
  exports.getLoadBalancerUrl = balancer.getLoadBalancerUrl;
10
12
  exports.loadBalancer = balancer.loadBalancer;
@@ -2,9 +2,13 @@
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  require("./index.cjs");
4
4
  const balancer = require("./balancer.cjs");
5
- let cachedProviders = [];
5
+ const providerPromiseCache = /* @__PURE__ */ new Map();
6
+ let customProviderLoader = null;
7
+ function setProviderLoader(loader) {
8
+ customProviderLoader = loader;
9
+ }
6
10
  function _resetCache() {
7
- cachedProviders = [];
11
+ providerPromiseCache.clear();
8
12
  }
9
13
  function selectWeightedProvider(providers, entropy) {
10
14
  if (providers.length === 0) {
@@ -25,11 +29,28 @@ function selectWeightedProvider(providers, entropy) {
25
29
  }
26
30
  return selectedProvider;
27
31
  }
28
- const getRandomActiveProvider = async (env, entropy) => {
29
- if (cachedProviders.length === 0) {
30
- cachedProviders = await balancer.loadBalancer(env);
32
+ const loadProviders = async (env) => {
33
+ if (customProviderLoader) {
34
+ return customProviderLoader(env);
31
35
  }
32
- const randomProviderObj = selectWeightedProvider(cachedProviders, entropy);
36
+ return balancer.loadBalancer(env);
37
+ };
38
+ const getProvidersPromise = (env) => {
39
+ const existing = providerPromiseCache.get(env);
40
+ if (existing) return existing;
41
+ const promise = loadProviders(env).catch((err) => {
42
+ providerPromiseCache.delete(env);
43
+ throw err;
44
+ });
45
+ providerPromiseCache.set(env, promise);
46
+ return promise;
47
+ };
48
+ const prefetchProviders = async (env) => {
49
+ await getProvidersPromise(env);
50
+ };
51
+ const getRandomActiveProvider = async (env, entropy) => {
52
+ const providers = await getProvidersPromise(env);
53
+ const randomProviderObj = selectWeightedProvider(providers, entropy);
33
54
  return {
34
55
  providerAccount: randomProviderObj.address,
35
56
  provider: {
@@ -40,4 +61,6 @@ const getRandomActiveProvider = async (env, entropy) => {
40
61
  };
41
62
  exports._resetCache = _resetCache;
42
63
  exports.getRandomActiveProvider = getRandomActiveProvider;
64
+ exports.prefetchProviders = prefetchProviders;
43
65
  exports.selectWeightedProvider = selectWeightedProvider;
66
+ exports.setProviderLoader = setProviderLoader;
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { _resetCache, getRandomActiveProvider, selectWeightedProvider } from "./providers.js";
1
+ import { _resetCache, getRandomActiveProvider, prefetchProviders, selectWeightedProvider, setProviderLoader } from "./providers.js";
2
2
  import { convertHostedProvider, getLoadBalancerUrl, loadBalancer } from "./balancer.js";
3
3
  export {
4
4
  _resetCache,
@@ -6,5 +6,7 @@ export {
6
6
  getLoadBalancerUrl,
7
7
  getRandomActiveProvider,
8
8
  loadBalancer,
9
- selectWeightedProvider
9
+ prefetchProviders,
10
+ selectWeightedProvider,
11
+ setProviderLoader
10
12
  };
@@ -1,6 +1,8 @@
1
1
  import type { EnvironmentTypes, RandomProvider } from "@prosopo/types";
2
2
  import { type HardcodedProvider } from "./index.js";
3
+ export declare function setProviderLoader(loader: (env: EnvironmentTypes) => Promise<HardcodedProvider[]>): void;
3
4
  export declare function _resetCache(): void;
4
5
  export declare function selectWeightedProvider(providers: HardcodedProvider[], entropy: number): HardcodedProvider;
6
+ export declare const prefetchProviders: (env: EnvironmentTypes) => Promise<void>;
5
7
  export declare const getRandomActiveProvider: (env: EnvironmentTypes, entropy: number) => Promise<RandomProvider>;
6
8
  //# sourceMappingURL=providers.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"providers.d.ts","sourceRoot":"","sources":["../src/providers.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AACvE,OAAO,EAAE,KAAK,iBAAiB,EAAgB,MAAM,YAAY,CAAC;AAIlE,wBAAgB,WAAW,SAE1B;AAUD,wBAAgB,sBAAsB,CACrC,SAAS,EAAE,iBAAiB,EAAE,EAC9B,OAAO,EAAE,MAAM,GACb,iBAAiB,CAyBnB;AAED,eAAO,MAAM,uBAAuB,QAC9B,gBAAgB,WACZ,MAAM,KACb,OAAO,CAAC,cAAc,CAexB,CAAC"}
1
+ {"version":3,"file":"providers.d.ts","sourceRoot":"","sources":["../src/providers.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AACvE,OAAO,EAAE,KAAK,iBAAiB,EAAgB,MAAM,YAAY,CAAC;AAkBlE,wBAAgB,iBAAiB,CAChC,MAAM,EAAE,CAAC,GAAG,EAAE,gBAAgB,KAAK,OAAO,CAAC,iBAAiB,EAAE,CAAC,GAC7D,IAAI,CAEN;AAED,wBAAgB,WAAW,SAE1B;AAUD,wBAAgB,sBAAsB,CACrC,SAAS,EAAE,iBAAiB,EAAE,EAC9B,OAAO,EAAE,MAAM,GACb,iBAAiB,CAyBnB;AA+BD,eAAO,MAAM,iBAAiB,QACxB,gBAAgB,KACnB,OAAO,CAAC,IAAI,CAEd,CAAC;AAEF,eAAO,MAAM,uBAAuB,QAC9B,gBAAgB,WACZ,MAAM,KACb,OAAO,CAAC,cAAc,CAWxB,CAAC"}
package/dist/providers.js CHANGED
@@ -1,8 +1,12 @@
1
1
  import "./index.js";
2
2
  import { loadBalancer } from "./balancer.js";
3
- let cachedProviders = [];
3
+ const providerPromiseCache = /* @__PURE__ */ new Map();
4
+ let customProviderLoader = null;
5
+ function setProviderLoader(loader) {
6
+ customProviderLoader = loader;
7
+ }
4
8
  function _resetCache() {
5
- cachedProviders = [];
9
+ providerPromiseCache.clear();
6
10
  }
7
11
  function selectWeightedProvider(providers, entropy) {
8
12
  if (providers.length === 0) {
@@ -23,11 +27,28 @@ function selectWeightedProvider(providers, entropy) {
23
27
  }
24
28
  return selectedProvider;
25
29
  }
26
- const getRandomActiveProvider = async (env, entropy) => {
27
- if (cachedProviders.length === 0) {
28
- cachedProviders = await loadBalancer(env);
30
+ const loadProviders = async (env) => {
31
+ if (customProviderLoader) {
32
+ return customProviderLoader(env);
29
33
  }
30
- const randomProviderObj = selectWeightedProvider(cachedProviders, entropy);
34
+ return loadBalancer(env);
35
+ };
36
+ const getProvidersPromise = (env) => {
37
+ const existing = providerPromiseCache.get(env);
38
+ if (existing) return existing;
39
+ const promise = loadProviders(env).catch((err) => {
40
+ providerPromiseCache.delete(env);
41
+ throw err;
42
+ });
43
+ providerPromiseCache.set(env, promise);
44
+ return promise;
45
+ };
46
+ const prefetchProviders = async (env) => {
47
+ await getProvidersPromise(env);
48
+ };
49
+ const getRandomActiveProvider = async (env, entropy) => {
50
+ const providers = await getProvidersPromise(env);
51
+ const randomProviderObj = selectWeightedProvider(providers, entropy);
31
52
  return {
32
53
  providerAccount: randomProviderObj.address,
33
54
  provider: {
@@ -39,5 +60,7 @@ const getRandomActiveProvider = async (env, entropy) => {
39
60
  export {
40
61
  _resetCache,
41
62
  getRandomActiveProvider,
42
- selectWeightedProvider
63
+ prefetchProviders,
64
+ selectWeightedProvider,
65
+ setProviderLoader
43
66
  };
@@ -1 +1 @@
1
- {"version":3,"file":"providers.js","sourceRoot":"","sources":["../src/providers.ts"],"names":[],"mappings":"AAeA,OAAO,EAA0B,YAAY,EAAE,MAAM,YAAY,CAAC;AAElE,IAAI,eAAe,GAAwB,EAAE,CAAC;AAE9C,MAAM,UAAU,WAAW;IAC1B,eAAe,GAAG,EAAE,CAAC;AACtB,CAAC;AAUD,MAAM,UAAU,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- "version": "2.8.17",
3
+ "version": "2.9.11",
4
4
  "description": "Provider load balancer",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -27,7 +27,8 @@
27
27
  },
28
28
  "repository": {
29
29
  "type": "git",
30
- "url": "git+ssh://git@github.com/prosopo/captcha.git"
30
+ "url": "git+https://github.com/prosopo/captcha.git",
31
+ "directory": "packages/load-balancer"
31
32
  },
32
33
  "author": "Prosopo Limited",
33
34
  "license": "Apache-2.0",
@@ -36,12 +37,12 @@
36
37
  },
37
38
  "homepage": "https://github.com/prosopo/captcha#readme",
38
39
  "dependencies": {
39
- "@prosopo/common": "3.1.28",
40
- "@prosopo/types": "3.8.0",
40
+ "@prosopo/common": "3.1.38",
41
+ "@prosopo/types": "4.3.1",
41
42
  "zod": "3.23.8"
42
43
  },
43
44
  "devDependencies": {
44
- "@prosopo/config": "3.3.0",
45
+ "@prosopo/config": "3.3.1",
45
46
  "@types/node": "22.10.2",
46
47
  "@vitest/coverage-v8": "3.2.4",
47
48
  "concurrently": "9.0.1",