eas-cli 24.0.0 → 24.1.0

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.
@@ -0,0 +1,121 @@
1
+ import { LocalEgressConfig } from './utils';
2
+ /**
3
+ * Local egress client. Two pieces run on the developer's machine for the life of
4
+ * a simulator session started with `--egress local`:
5
+ *
6
+ * 1. An HTTP proxy on loopback that forwards the requests it receives to the
7
+ * internet from this machine. It supports CONNECT tunnels (HTTPS, WSS), plain
8
+ * HTTP requests with absolute URLs, and HTTP upgrades (WS). It refuses
9
+ * destinations on this machine's local networks: the requests it forwards
10
+ * come from code running in the remote simulator, not from the developer.
11
+ * 2. A chisel client that connects out to the session's tunnel server and asks it
12
+ * to listen on the device host's loopback proxy port, forwarding every
13
+ * connection back to the local proxy. The device host's system proxy points at
14
+ * that port, so requests that honor it (WebKit, URLSession and other CFNetwork
15
+ * clients) arrive here. Requests from libraries that bypass the system proxy
16
+ * never reach this client and exit from the device host instead.
17
+ *
18
+ * `--egress-allow host:port` names destinations on the developer's machine or
19
+ * network that the proxy may connect to despite the local-network refusal, so a
20
+ * dev server on `localhost:3000` is reachable from the remote simulator the way
21
+ * it is from a local one. Entries are exact host and port pairs, never ranges.
22
+ */
23
+ export declare const LOCAL_EGRESS_PROXY_HOST = "127.0.0.1";
24
+ /** Username in the worker's chisel authfile; the session token is its password. */
25
+ export declare const LOCAL_EGRESS_USERNAME = "eas";
26
+ export declare function readLocalEgressConfigFromEnv(env: NodeJS.ProcessEnv): LocalEgressConfig;
27
+ export declare class EgressPolicyError extends Error {
28
+ constructor(host: string, address?: string);
29
+ }
30
+ /** True for any address the egress client must never connect to. */
31
+ export declare function isForbiddenEgressAddress(address: string): boolean;
32
+ export type EgressTargetResolver = (hostname: string, port: number) => Promise<string[]>;
33
+ /**
34
+ * IPv4 first. Developer networks often have broken or slow IPv6, and a hung
35
+ * first attempt would stall the simulator's request for the whole timeout.
36
+ */
37
+ export declare function orderEgressAddresses(addresses: {
38
+ address: string;
39
+ family: number;
40
+ }[]): string[];
41
+ /**
42
+ * Resolve a destination hostname to the addresses the proxy may connect to,
43
+ * refusing anything local. Every address the name resolves to is checked, so a
44
+ * name that mixes public and private records is refused as a whole, and
45
+ * connections are made to the returned addresses rather than by re-resolving.
46
+ */
47
+ export declare const resolveEgressTargetAsync: EgressTargetResolver;
48
+ /**
49
+ * Parse one `--egress-allow` value into its normalized `host:port` form. Only an
50
+ * exact host and port pair is accepted. Web pages and SDKs inside the simulator
51
+ * can use the proxy too, so nothing here opens a range or a wildcard.
52
+ */
53
+ export declare function parseEgressAllowEntry(entry: string): string;
54
+ export declare function parseEgressAllowList(entries: readonly string[]): string[];
55
+ /**
56
+ * Wrap the default destination policy with the `--egress-allow` list. A listed
57
+ * destination connects to this machine's loopback or network exactly as named;
58
+ * every other destination keeps the default refusals. `localhost` maps to the
59
+ * loopback addresses directly and never goes through DNS.
60
+ */
61
+ export declare function createEgressTargetResolver({ allow, onAllowed, }: {
62
+ allow: readonly string[];
63
+ onAllowed?: (destination: string) => void;
64
+ }): EgressTargetResolver;
65
+ export type LocalEgressProxyStats = {
66
+ active: number;
67
+ total: number;
68
+ refused: number;
69
+ };
70
+ export type LocalEgressProxyServer = {
71
+ port: number;
72
+ getStats: () => LocalEgressProxyStats;
73
+ closeAsync: () => Promise<void>;
74
+ };
75
+ export declare function startLocalEgressProxyServerAsync({ host, port, resolveTargetAsync, }: {
76
+ host?: string;
77
+ port: number;
78
+ resolveTargetAsync?: EgressTargetResolver;
79
+ }): Promise<LocalEgressProxyServer>;
80
+ export declare function getChiselAssetName({ platform, arch, }: {
81
+ platform: NodeJS.Platform;
82
+ arch: string;
83
+ }): string;
84
+ export declare function ensureChiselBinaryAsync({ platform, arch, signal, }?: {
85
+ platform?: NodeJS.Platform;
86
+ arch?: string;
87
+ signal?: AbortSignal;
88
+ }): Promise<string>;
89
+ export declare function buildChiselClientArgs({ url, fingerprint, port, localPort, forwardPorts, }: {
90
+ url: string;
91
+ fingerprint: string;
92
+ /** Port the tunnel server listens on, on the device host. */
93
+ port: number;
94
+ /** Port the proxy listens on here; independent of the worker's listening port. */
95
+ localPort?: number;
96
+ /**
97
+ * Loopback ports to forward from the device host to the same port here, one
98
+ * reverse remote each; see getLoopbackForwardPlan.
99
+ */
100
+ forwardPorts?: readonly number[];
101
+ }): string[];
102
+ /**
103
+ * The device host refuses a reverse remote it does not permit, or one whose
104
+ * port is already in use there. chisel then drops the whole connection and
105
+ * retries, so proxied requests stay unavailable until the entry is removed.
106
+ */
107
+ export declare function isChiselRemoteRejectionLine(line: string): boolean;
108
+ export declare function classifyChiselClientLogLine(line: string): 'connected' | 'disconnected' | 'other';
109
+ /**
110
+ * Run the egress client until `signal` aborts. Rejects if the tunnel client exits
111
+ * on its own, which means proxied HTTP(S) requests have lost their tunnel.
112
+ */
113
+ export declare function runLocalEgressAsync({ url, token, fingerprint, port, allow, localPort, signal, onConnected, onDisconnected, }: Omit<LocalEgressConfig, 'allow'> & {
114
+ /** Normalized `--egress-allow` destinations; see createEgressTargetResolver. */
115
+ allow?: readonly string[];
116
+ /** Defaults to an available ephemeral port; the remote worker port stays fixed. */
117
+ localPort?: number;
118
+ signal: AbortSignal;
119
+ onConnected?: () => void;
120
+ onDisconnected?: (line: string) => void;
121
+ }): Promise<void>;