@trillboards/edge-sdk 0.2.20 → 0.2.24
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/deploy/macos/scripts/setup-litertlm.sh +30 -0
- package/deploy/windows/e2e/test-enterprise-trust-store.ps1 +341 -0
- package/deploy/windows/setup-litertlm.ps1 +49 -1
- package/dist/AudienceAnalyzeClient.d.ts +32 -1
- package/dist/AudienceAnalyzeClient.d.ts.map +1 -1
- package/dist/AudienceAnalyzeClient.js +34 -5
- package/dist/AudienceAnalyzeClient.js.map +1 -1
- package/dist/CloudSensingManager.d.ts +40 -0
- package/dist/CloudSensingManager.d.ts.map +1 -1
- package/dist/CloudSensingManager.js +117 -1
- package/dist/CloudSensingManager.js.map +1 -1
- package/dist/EdgeAgent.js +1 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +60 -0
- package/dist/cli.js.map +1 -1
- package/dist/diagnose.d.ts +37 -4
- package/dist/diagnose.d.ts.map +1 -1
- package/dist/diagnose.js +155 -6
- package/dist/diagnose.js.map +1 -1
- package/dist/enterpriseNetwork.d.ts +130 -0
- package/dist/enterpriseNetwork.d.ts.map +1 -0
- package/dist/enterpriseNetwork.js +568 -0
- package/dist/enterpriseNetwork.js.map +1 -0
- package/dist/enterpriseProxy.d.ts +73 -0
- package/dist/enterpriseProxy.d.ts.map +1 -0
- package/dist/enterpriseProxy.js +406 -0
- package/dist/enterpriseProxy.js.map +1 -0
- package/dist/enterpriseTrust.d.ts +188 -0
- package/dist/enterpriseTrust.d.ts.map +1 -0
- package/dist/enterpriseTrust.js +615 -0
- package/dist/enterpriseTrust.js.map +1 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +29 -1
- package/dist/index.js.map +1 -1
- package/dist/localNetworkAccess.d.ts +166 -0
- package/dist/localNetworkAccess.d.ts.map +1 -0
- package/dist/localNetworkAccess.js +490 -0
- package/dist/localNetworkAccess.js.map +1 -0
- package/dist/sensingRunMode.d.ts +36 -0
- package/dist/sensingRunMode.d.ts.map +1 -1
- package/dist/sensingRunMode.js +78 -1
- package/dist/sensingRunMode.js.map +1 -1
- package/dist/transportFailure.d.ts +118 -0
- package/dist/transportFailure.d.ts.map +1 -0
- package/dist/transportFailure.js +267 -0
- package/dist/transportFailure.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import * as http from 'http';
|
|
2
|
+
import * as https from 'https';
|
|
3
|
+
import * as net from 'net';
|
|
4
|
+
import * as tls from 'tls';
|
|
5
|
+
import type { Duplex } from 'stream';
|
|
6
|
+
import { type TrustAnchorReadOptions, type TrustAnchorResolution } from './enterpriseTrust';
|
|
7
|
+
import { type ProxyReadOptions, type ProxyResolution } from './enterpriseProxy';
|
|
8
|
+
import { TransportFailure } from './transportFailure';
|
|
9
|
+
export interface NetworkPosture {
|
|
10
|
+
trust: TrustAnchorResolution;
|
|
11
|
+
/** Proxy decision for the API base, which is the one an operator cares about. */
|
|
12
|
+
proxy: ProxyResolution;
|
|
13
|
+
/** The two lines an operator should see at startup and in `diagnose`. */
|
|
14
|
+
lines: string[];
|
|
15
|
+
}
|
|
16
|
+
export interface EnterpriseNetworkOptions extends TrustAnchorReadOptions, ProxyReadOptions {
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Cached `resolveProxyForUrl`. The cache exists because resolving costs a
|
|
20
|
+
* subprocess on Windows and macOS and the answer is a per-machine constant that
|
|
21
|
+
* changes on the timescale of an IT ticket, not a request.
|
|
22
|
+
*
|
|
23
|
+
* The cache is keyed on the TARGET only, so it is valid exactly while the
|
|
24
|
+
* environment is a process-wide constant — which it is in production and is
|
|
25
|
+
* NOT when a caller injects one. An injected `env`/`platform`/`exec` therefore
|
|
26
|
+
* bypasses the cache in both directions: it neither reads a decision taken
|
|
27
|
+
* under a different environment nor publishes its own for someone else to
|
|
28
|
+
* read. Without that, two agents built with different proxies in the same
|
|
29
|
+
* process silently share the first one's answer.
|
|
30
|
+
*/
|
|
31
|
+
export declare function resolveProxyCached(targetUrl: string, opts?: EnterpriseNetworkOptions): ProxyResolution;
|
|
32
|
+
/** Drop every cached network decision. Used by tests and by `diagnose`. */
|
|
33
|
+
export declare function resetEnterpriseNetworkCaches(): void;
|
|
34
|
+
/**
|
|
35
|
+
* Re-read the trust store after a certificate failure, at most once a minute.
|
|
36
|
+
*
|
|
37
|
+
* The point of the whole runtime-resolution design: an operator on the phone
|
|
38
|
+
* with IT gets the root installed, and the connector picks it up on the next
|
|
39
|
+
* cadence tick instead of needing a restart nobody is present to perform.
|
|
40
|
+
* Returns whether a re-read was actually armed, so the caller can say so.
|
|
41
|
+
*/
|
|
42
|
+
export declare function refreshTrustAnchorsAfterFailure(now?: number): boolean;
|
|
43
|
+
/**
|
|
44
|
+
* The shape `http.Agent` calls `createConnection` with. `stream` is typed as a
|
|
45
|
+
* `Duplex` in @types/node because a custom agent may return any duplex; ours is
|
|
46
|
+
* always a socket.
|
|
47
|
+
*/
|
|
48
|
+
type AgentConnectCallback = (err: Error | null, stream: Duplex) => void;
|
|
49
|
+
type ConnectCallback = (err: Error | null, socket?: net.Socket) => void;
|
|
50
|
+
/**
|
|
51
|
+
* An `https.Agent` that decides, per connection, whether to tunnel.
|
|
52
|
+
*
|
|
53
|
+
* Per-connection and not per-agent because `NO_PROXY` is a per-host rule: one
|
|
54
|
+
* process talks to `api.trillboards.com` (proxied) and `127.0.0.1:9379` (never
|
|
55
|
+
* proxied), and a single agent has to get both right.
|
|
56
|
+
*/
|
|
57
|
+
export declare class EnterpriseHttpsAgent extends https.Agent {
|
|
58
|
+
private readonly netOptions;
|
|
59
|
+
constructor(options: https.AgentOptions, netOptions?: EnterpriseNetworkOptions);
|
|
60
|
+
createConnection(options: http.ClientRequestArgs, cb?: AgentConnectCallback): Duplex | null | undefined;
|
|
61
|
+
}
|
|
62
|
+
interface ProxyConnectArgs {
|
|
63
|
+
target: {
|
|
64
|
+
host: string;
|
|
65
|
+
port: number;
|
|
66
|
+
servername: string;
|
|
67
|
+
};
|
|
68
|
+
proxyUrl: string;
|
|
69
|
+
proxySource: string;
|
|
70
|
+
tlsOptions: tls.ConnectionOptions;
|
|
71
|
+
callback: ConnectCallback;
|
|
72
|
+
/** Override the CONNECT deadline. Tests only; production uses the constant. */
|
|
73
|
+
connectTimeoutMs?: number;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Open a CONNECT tunnel and start TLS inside it.
|
|
77
|
+
*
|
|
78
|
+
* Hand-rolled because the SDK ships with no third-party HTTP dependency at all
|
|
79
|
+
* (`package.json` has jpeg-js/jsqr/pngjs and nothing network-facing) and is
|
|
80
|
+
* bundled into a self-contained tree; adding `proxy-agent` would pull a
|
|
81
|
+
* dependency graph into a signed customer artifact for ~90 lines of protocol.
|
|
82
|
+
*
|
|
83
|
+
* `rejectUnauthorized` is never touched here. The tunnel changes WHO carries
|
|
84
|
+
* the bytes; it does not change who we are willing to believe at the other end.
|
|
85
|
+
*/
|
|
86
|
+
export declare function connectThroughProxy(args: ProxyConnectArgs): void;
|
|
87
|
+
/**
|
|
88
|
+
* Build (without installing) the agent for a set of resolved anchors.
|
|
89
|
+
* Exposed so a test can hold one without touching process globals.
|
|
90
|
+
*/
|
|
91
|
+
export declare function createEnterpriseAgent(anchors: TrustAnchorResolution, netOptions?: EnterpriseNetworkOptions, base?: https.AgentOptions): EnterpriseHttpsAgent;
|
|
92
|
+
/**
|
|
93
|
+
* The process-wide agent. Built on first use and reused forever after — an
|
|
94
|
+
* agent owns a socket pool, so returning a fresh one per call would defeat
|
|
95
|
+
* keep-alive and leak a pool per request.
|
|
96
|
+
*/
|
|
97
|
+
export declare function getEnterpriseAgent(netOptions?: EnterpriseNetworkOptions): EnterpriseHttpsAgent;
|
|
98
|
+
/** What the connector resolved, for a startup line and for `diagnose`. */
|
|
99
|
+
export declare function describeNetworkPosture(apiBaseUrl: string, netOptions?: EnterpriseNetworkOptions): NetworkPosture;
|
|
100
|
+
/**
|
|
101
|
+
* Install the enterprise agent as `https.globalAgent` and report what it found.
|
|
102
|
+
*
|
|
103
|
+
* Idempotent. Returns the posture so the caller can print it — printing is the
|
|
104
|
+
* caller's job because the CLI, the supervisor and `diagnose` each have their
|
|
105
|
+
* own output channel.
|
|
106
|
+
*/
|
|
107
|
+
export declare function installEnterpriseNetworking(apiBaseUrl: string, netOptions?: EnterpriseNetworkOptions): NetworkPosture;
|
|
108
|
+
/** Undo the install. Tests only — production installs once and never removes it. */
|
|
109
|
+
export declare function uninstallEnterpriseNetworking(original?: https.Agent): void;
|
|
110
|
+
/**
|
|
111
|
+
* The one place a caught transport error becomes a diagnosis.
|
|
112
|
+
*
|
|
113
|
+
* Also arms a trust-store re-read when the failure was a trust failure, so the
|
|
114
|
+
* recovery path described in `enterpriseTrust` actually fires.
|
|
115
|
+
*/
|
|
116
|
+
export declare function diagnoseTransportError(err: unknown, targetUrl: string): TransportFailure;
|
|
117
|
+
/**
|
|
118
|
+
* Rewrite request options so a PLAIN-HTTP target goes through the proxy.
|
|
119
|
+
*
|
|
120
|
+
* http through a forward proxy is absolute-form, not a tunnel: connect to the
|
|
121
|
+
* proxy and put the whole URL in the request line. Returns the options
|
|
122
|
+
* unchanged when no proxy applies. `https` never comes through here — it goes
|
|
123
|
+
* through the agent above.
|
|
124
|
+
*/
|
|
125
|
+
export declare function applyHttpProxy(url: string, options: http.RequestOptions, netOptions?: EnterpriseNetworkOptions): {
|
|
126
|
+
options: http.RequestOptions;
|
|
127
|
+
proxyUrl: string | null;
|
|
128
|
+
};
|
|
129
|
+
export {};
|
|
130
|
+
//# sourceMappingURL=enterpriseNetwork.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"enterpriseNetwork.d.ts","sourceRoot":"","sources":["../src/enterpriseNetwork.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC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