@effectstream/utils 0.104.0 → 0.104.3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@effectstream/utils",
3
- "version": "0.104.0",
3
+ "version": "0.104.3",
4
4
  "license": "(MIT OR Apache-2.0)",
5
5
  "homepage": "https://effectstream.github.io/docs/",
6
6
  "repository": {
@@ -17,7 +17,8 @@
17
17
  "./node-env": "./src/config.ts",
18
18
  "./runtime": "./src/runtime.ts",
19
19
  "./runtime-spawn": "./src/runtime-spawn.ts",
20
- "./fs": "./src/fs.ts"
20
+ "./fs": "./src/fs.ts",
21
+ "./polkadot-esm-cjs-warning": "./src/polkadot-esm-cjs-warning.ts"
21
22
  },
22
23
  "dependencies": {
23
24
  "@coderspirit/nominal": "^4.1.1",
package/src/config.ts CHANGED
@@ -207,6 +207,13 @@ const definitions: Record<string, ConfigDefinition> = {
207
207
  description:
208
208
  "Main Paima API Port. Used by developers custom endpoints and RPC endpoints. Example: '9999'",
209
209
  },
210
+ EFFECTSTREAM_TRUST_PROXY: {
211
+ key: "EFFECTSTREAM_TRUST_PROXY",
212
+ type: "string",
213
+ defaultValue: "true",
214
+ description:
215
+ "Whether the HTTP server trusts X-Forwarded-For / X-Forwarded-Proto from a reverse proxy in front of it, so request.ip is the client and not the proxy. 'true' (default, trust every hop), 'false' (never), or a comma-separated list of proxy IPs/CIDRs such as '127.0.0.1,10.0.0.0/8'. Mirrors Fastify's trustProxy option.",
216
+ },
210
217
  EFFECTSTREAM_EXPLORER_PORT: {
211
218
  key: "EFFECTSTREAM_EXPLORER_PORT",
212
219
  type: "number",
@@ -412,6 +419,9 @@ export class ENV {
412
419
  static get EFFECTSTREAM_API_PORT(): number {
413
420
  return ENV.getConfig(definitions.EFFECTSTREAM_API_PORT);
414
421
  }
422
+ static get EFFECTSTREAM_TRUST_PROXY(): string {
423
+ return ENV.getConfig(definitions.EFFECTSTREAM_TRUST_PROXY);
424
+ }
415
425
  static get RECAPTCHA_V3_FRONTEND(): string {
416
426
  return ENV.getConfig(definitions.RECAPTCHA_V3_FRONTEND);
417
427
  }
@@ -0,0 +1,39 @@
1
+ /**
2
+ * Side-effect-only module. Import it as the FIRST statement of any module that
3
+ * imports a `@polkadot/*` package (directly, or via a wrapper such as
4
+ * `avail-js-sdk`), and never import it lazily.
5
+ *
6
+ * Why: every `@polkadot/*` package registers itself in `globalThis.__polkadotjs`
7
+ * at load time and warns when it sees more than one entry for the same package.
8
+ * We load two entries — but of the same version, in two module formats:
9
+ *
10
+ * esm `@effectstream/crypto` ships raw TS, so Bun loads it as ESM, and
11
+ * `chains/polkadot.ts` pulls the ESM build of `@polkadot/util-crypto`.
12
+ * cjs `avail-js-sdk` is CommonJS-only, so its `require("@polkadot/api")`
13
+ * can only ever resolve the `cjs/` build.
14
+ *
15
+ * The result is six warnings ("@polkadot/util has multiple versions...") on
16
+ * every start, telling the user to pin or dedupe. There is nothing to dedupe:
17
+ * only one version of each package is installed. Setting the flag below is the
18
+ * escape hatch `@polkadot/util` provides for exactly this case — it suppresses
19
+ * the message only when every registered entry has the same version, so a
20
+ * genuine multi-version conflict still warns.
21
+ *
22
+ * To see the warnings again, set POLKADOTJS_DISABLE_ESM_CJS_WARNING=0 — an
23
+ * explicit value in the environment always wins over the default set here.
24
+ *
25
+ * Ordering matters: `@polkadot/util` reads this variable while it is being
26
+ * evaluated, i.e. during the first `@polkadot/*` import in the process. Setting
27
+ * it afterwards has no effect.
28
+ *
29
+ * See spec/00009-polkadot-package-conflicts.md in the organizer workspace for
30
+ * the captured stack traces behind the two loads.
31
+ */
32
+ const FLAG = "POLKADOTJS_DISABLE_ESM_CJS_WARNING";
33
+
34
+ // `process` is absent in browser/bundler builds; there is nothing to set there.
35
+ const env = globalThis.process?.env;
36
+
37
+ if (env && env[FLAG] === undefined) {
38
+ env[FLAG] = "1";
39
+ }