nsekit 0.3.9 → 0.3.10
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/dist/index.js
CHANGED
|
@@ -20631,11 +20631,13 @@ class ZerodhaInstruments {
|
|
|
20631
20631
|
}
|
|
20632
20632
|
|
|
20633
20633
|
// src/shared/egress-ip.ts
|
|
20634
|
-
import { Agent } from "undici";
|
|
20634
|
+
import { Agent, Pool } from "undici";
|
|
20635
20635
|
function egressDispatcher(egressIp) {
|
|
20636
20636
|
if (!egressIp)
|
|
20637
20637
|
return;
|
|
20638
|
-
return new Agent({
|
|
20638
|
+
return new Agent({
|
|
20639
|
+
factory: (origin, opts) => new Pool(origin, { ...opts, localAddress: egressIp })
|
|
20640
|
+
});
|
|
20639
20641
|
}
|
|
20640
20642
|
function wsEgressOptions(egressIp) {
|
|
20641
20643
|
return egressIp ? { localAddress: egressIp } : {};
|
|
@@ -2,7 +2,20 @@ import { type Dispatcher } from 'undici';
|
|
|
2
2
|
export type { Dispatcher };
|
|
3
3
|
/** Undici dispatcher bound to `egressIp` as the outbound source address.
|
|
4
4
|
* Returns undefined when `egressIp` is not set — pass through to native
|
|
5
|
-
* fetch's default dispatcher (OS default route).
|
|
5
|
+
* fetch's default dispatcher (OS default route).
|
|
6
|
+
*
|
|
7
|
+
* Implementation note — the obvious `new Agent({ connect: { localAddress } })`
|
|
8
|
+
* form is silently ignored by undici v8: the option flows into an Agent
|
|
9
|
+
* layer that never propagates it to the underlying `net.connect()`, so
|
|
10
|
+
* outbound packets leave via the OS default route regardless. Verified
|
|
11
|
+
* in production: Shoonya rejected every OAuth exchange with
|
|
12
|
+
* `Invalid Input : INVALID_IP` even with the value set correctly.
|
|
13
|
+
*
|
|
14
|
+
* A `Pool` (or `Client`) with top-level `localAddress` DOES bind
|
|
15
|
+
* correctly. So build the Agent with a `factory` that creates a
|
|
16
|
+
* per-origin `Pool` and hands it the local address there — bypasses
|
|
17
|
+
* the broken `connect: { localAddress }` shape while keeping the
|
|
18
|
+
* fetch(url, { dispatcher }) call sites unchanged. */
|
|
6
19
|
export declare function egressDispatcher(egressIp: string | undefined): Dispatcher | undefined;
|
|
7
20
|
/** WebSocket constructor options snippet for `localAddress` binding.
|
|
8
21
|
* Returns {} when `egressIp` is not set — spread safely regardless. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"egress-ip.d.ts","sourceRoot":"","sources":["../../src/shared/egress-ip.ts"],"names":[],"mappings":"AAoBA,OAAO,
|
|
1
|
+
{"version":3,"file":"egress-ip.d.ts","sourceRoot":"","sources":["../../src/shared/egress-ip.ts"],"names":[],"mappings":"AAoBA,OAAO,EAAe,KAAK,UAAU,EAAE,MAAM,QAAQ,CAAC;AAEtD,YAAY,EAAE,UAAU,EAAE,CAAC;AAE3B;;;;;;;;;;;;;;;uDAeuD;AACvD,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,GAAG,UAAU,GAAG,SAAS,CAKrF;AAED;wEACwE;AACxE,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,GAAG;IAAE,YAAY,CAAC,EAAE,MAAM,CAAA;CAAE,CAEvF"}
|