@ngrok/ngrok 0.0.6

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/flake.lock ADDED
@@ -0,0 +1,82 @@
1
+ {
2
+ "nodes": {
3
+ "fenix-flake": {
4
+ "inputs": {
5
+ "nixpkgs": [
6
+ "nixpkgs"
7
+ ],
8
+ "rust-analyzer-src": "rust-analyzer-src"
9
+ },
10
+ "locked": {
11
+ "lastModified": 1674541370,
12
+ "narHash": "sha256-L62dKDX6fIUQhlna9R8PKSAEGZ7ueU5gRGxZzZs/Zx8=",
13
+ "owner": "nix-community",
14
+ "repo": "fenix",
15
+ "rev": "4435f8e9da13581e51ba1f92a25d7d54c776ad94",
16
+ "type": "github"
17
+ },
18
+ "original": {
19
+ "owner": "nix-community",
20
+ "repo": "fenix",
21
+ "type": "github"
22
+ }
23
+ },
24
+ "flake-utils": {
25
+ "locked": {
26
+ "lastModified": 1667395993,
27
+ "narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=",
28
+ "owner": "numtide",
29
+ "repo": "flake-utils",
30
+ "rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f",
31
+ "type": "github"
32
+ },
33
+ "original": {
34
+ "owner": "numtide",
35
+ "repo": "flake-utils",
36
+ "type": "github"
37
+ }
38
+ },
39
+ "nixpkgs": {
40
+ "locked": {
41
+ "lastModified": 1674457414,
42
+ "narHash": "sha256-HGoDKtOXIKvU72/4gL3VUYla/YExhS0oPoiIuDjlTrg=",
43
+ "owner": "nixos",
44
+ "repo": "nixpkgs",
45
+ "rev": "f32319e7ba8f03ea2f1c66a5ffe43b4e771108f5",
46
+ "type": "github"
47
+ },
48
+ "original": {
49
+ "owner": "nixos",
50
+ "ref": "nixpkgs-unstable",
51
+ "repo": "nixpkgs",
52
+ "type": "github"
53
+ }
54
+ },
55
+ "root": {
56
+ "inputs": {
57
+ "fenix-flake": "fenix-flake",
58
+ "flake-utils": "flake-utils",
59
+ "nixpkgs": "nixpkgs"
60
+ }
61
+ },
62
+ "rust-analyzer-src": {
63
+ "flake": false,
64
+ "locked": {
65
+ "lastModified": 1674491573,
66
+ "narHash": "sha256-1hMPOn2dlMfWRWvuaWcSxNquKpvjGVXq2rVw6UJy75Q=",
67
+ "owner": "rust-lang",
68
+ "repo": "rust-analyzer",
69
+ "rev": "c552e5a55f13b2f08d506bb46fb74dbc11702d0d",
70
+ "type": "github"
71
+ },
72
+ "original": {
73
+ "owner": "rust-lang",
74
+ "ref": "nightly",
75
+ "repo": "rust-analyzer",
76
+ "type": "github"
77
+ }
78
+ }
79
+ },
80
+ "root": "root",
81
+ "version": 7
82
+ }
package/flake.nix ADDED
@@ -0,0 +1,111 @@
1
+ {
2
+ description = "ngrok agent library for NodeJS";
3
+
4
+ inputs = {
5
+ nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
6
+
7
+ # Note: fenix packages are cached via cachix:
8
+ # cachix use nix-community
9
+ fenix-flake = {
10
+ url = "github:nix-community/fenix";
11
+ inputs.nixpkgs.follows = "nixpkgs";
12
+ };
13
+
14
+ flake-utils = {
15
+ url = "github:numtide/flake-utils";
16
+ inputs.nixpkgs.follows = "nixpkgs";
17
+ };
18
+ };
19
+
20
+ outputs = { self, nixpkgs, fenix-flake, flake-utils }:
21
+ flake-utils.lib.eachDefaultSystem (system:
22
+ let
23
+ pkgs = import nixpkgs {
24
+ inherit system;
25
+ overlays = [
26
+ fenix-flake.overlays.default
27
+ ];
28
+ };
29
+ toolchain = pkgs.fenix.complete.withComponents [
30
+ "cargo"
31
+ "clippy"
32
+ "rust-src"
33
+ "rustc"
34
+ "rustfmt"
35
+ ];
36
+ node-toolchain = with pkgs; [
37
+ nodejs
38
+ yarn
39
+ ];
40
+ fix-n-fmt = pkgs.writeShellScriptBin "fix-n-fmt" ''
41
+ set -euf -o pipefail
42
+ ${toolchain}/bin/cargo clippy --fix --allow-staged --allow-dirty --all-targets --all-features
43
+ ${toolchain}/bin/cargo fmt
44
+ '';
45
+ pre-commit = pkgs.writeShellScript "pre-commit" ''
46
+ cargo clippy --workspace --all-targets --all-features -- -D warnings
47
+ result=$?
48
+
49
+ if [[ ''${result} -ne 0 ]] ; then
50
+ cat <<\EOF
51
+ There are some linting issues, try `fix-n-fmt` to fix.
52
+ EOF
53
+ exit 1
54
+ fi
55
+
56
+ # Use a dedicated sub-target-dir for udeps. For some reason, it fights with clippy over the cache.
57
+ CARGO_TARGET_DIR=$(git rev-parse --show-toplevel)/target/udeps cargo udeps --workspace --all-targets --all-features
58
+ result=$?
59
+
60
+ if [[ ''${result} -ne 0 ]] ; then
61
+ cat <<\EOF
62
+ There are some unused dependencies.
63
+ EOF
64
+ exit 1
65
+ fi
66
+
67
+ diff=$(cargo fmt -- --check)
68
+ result=$?
69
+
70
+ if [[ ''${result} -ne 0 ]] ; then
71
+ cat <<\EOF
72
+ There are some code style issues, run `fix-n-fmt` first.
73
+ EOF
74
+ exit 1
75
+ fi
76
+
77
+ exit 0
78
+ '';
79
+ setup-hooks = pkgs.writeShellScriptBin "setup-hooks" ''
80
+ repo_root=$(git rev-parse --git-dir)
81
+
82
+ ${toString (map (h: ''
83
+ ln -sf ${h} ''${repo_root}/hooks/${h.name}
84
+ '') [
85
+ pre-commit
86
+ ])}
87
+ '';
88
+ in
89
+ {
90
+ devShell = pkgs.mkShell {
91
+ CHALK_OVERFLOW_DEPTH = 3000;
92
+ CHALK_SOLVER_MAX_SIZE = 1500;
93
+ OPENSSL_LIB_DIR = "${pkgs.openssl.out}/lib";
94
+ OPENSSL_INCLUDE_DIR = "${pkgs.openssl.dev}/include";
95
+ shellHook = ''
96
+ export PATH="$PATH:node_modules/.bin"
97
+ '';
98
+ buildInputs = with pkgs; [
99
+ toolchain
100
+ node-toolchain
101
+ fix-n-fmt
102
+ setup-hooks
103
+ cargo-udeps
104
+ ] ++ lib.optionals stdenv.isDarwin [
105
+ # nix darwin stdenv has broken libiconv: https://github.com/NixOS/nixpkgs/issues/158331
106
+ libiconv
107
+ pkgs.darwin.apple_sdk.frameworks.Security
108
+ ];
109
+ };
110
+ });
111
+ }
package/index.d.ts ADDED
@@ -0,0 +1,245 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+
4
+ /* auto-generated by NAPI-RS */
5
+
6
+ /**
7
+ * turn on tracing subscriber which obeys NGROK_LOG env variable, e.g.:
8
+ * process.env.NGROK_LOG = 'ngrok=debug';
9
+ * ngrok.tracingSubscriber();
10
+ */
11
+ export function tracingSubscriber(): void
12
+ /** The builder for an ngrok session. */
13
+ export class NgrokSessionBuilder {
14
+ /** Create a new session builder */
15
+ constructor()
16
+ /** Authenticate the ngrok session with the given authtoken. */
17
+ authtoken(authtoken: string): this
18
+ /**
19
+ * Authenticate using the authtoken in the `NGROK_AUTHTOKEN` environment
20
+ * variable.
21
+ */
22
+ authtokenFromEnv(): this
23
+ /**
24
+ * Set the heartbeat interval for the session.
25
+ * This value determines how often we send application level
26
+ * heartbeats to the server go check connection liveness.
27
+ */
28
+ heartbeatInterval(heartbeatInterval: number): this
29
+ /**
30
+ * Set the heartbeat tolerance for the session.
31
+ * If the session's heartbeats are outside of their interval by this duration,
32
+ * the server will assume the session is dead and close it.
33
+ */
34
+ heartbeatTolerance(heartbeatTolerance: number): this
35
+ /**
36
+ * Use the provided opaque metadata string for this session.
37
+ * Viewable from the ngrok dashboard or API.
38
+ */
39
+ metadata(metadata: string): this
40
+ /** Connect to the provided ngrok server address. */
41
+ serverAddr(addr: string): this
42
+ /** Attempt to establish an ngrok session using the current configuration. */
43
+ connect(): Promise<NgrokSession>
44
+ }
45
+ /** An ngrok session. */
46
+ export class NgrokSession {
47
+ /** Start building a tunnel backing an HTTP endpoint. */
48
+ httpEndpoint(): NgrokHttpTunnelBuilder
49
+ /** Start building a tunnel backing a TCP endpoint. */
50
+ tcpEndpoint(): NgrokTcpTunnelBuilder
51
+ /** Start building a tunnel backing a TLS endpoint. */
52
+ tlsEndpoint(): NgrokTlsTunnelBuilder
53
+ /** Start building a labeled tunnel. */
54
+ labeledTunnel(): NgrokLabeledTunnelBuilder
55
+ }
56
+ /**r" An ngrok tunnel backing an HTTP endpoint. */
57
+ export class NgrokHttpTunnel {
58
+ /** The URL that this tunnel backs. */
59
+ url(): string
60
+ /** The protocol of the endpoint that this tunnel backs. */
61
+ proto(): string
62
+ /** The ID of this tunnel, assigned by the remote server. */
63
+ id(): string
64
+ /** Forward incoming tunnel connections to the provided TCP address. */
65
+ forwardTcp(addr: string): Promise<void>
66
+ /** Forward incoming tunnel connections to the provided Unix socket path. */
67
+ forwardUnix(addr: string): Promise<void>
68
+ }
69
+ /**r" An ngrok tunnel backing a TCP endpoint. */
70
+ export class NgrokTcpTunnel {
71
+ /** The URL that this tunnel backs. */
72
+ url(): string
73
+ /** The protocol of the endpoint that this tunnel backs. */
74
+ proto(): string
75
+ /** The ID of this tunnel, assigned by the remote server. */
76
+ id(): string
77
+ /** Forward incoming tunnel connections to the provided TCP address. */
78
+ forwardTcp(addr: string): Promise<void>
79
+ /** Forward incoming tunnel connections to the provided Unix socket path. */
80
+ forwardUnix(addr: string): Promise<void>
81
+ }
82
+ /**r" An ngrok tunnel bcking a TLS endpoint. */
83
+ export class NgrokTlsTunnel {
84
+ /** The URL that this tunnel backs. */
85
+ url(): string
86
+ /** The protocol of the endpoint that this tunnel backs. */
87
+ proto(): string
88
+ /** The ID of this tunnel, assigned by the remote server. */
89
+ id(): string
90
+ /** Forward incoming tunnel connections to the provided TCP address. */
91
+ forwardTcp(addr: string): Promise<void>
92
+ /** Forward incoming tunnel connections to the provided Unix socket path. */
93
+ forwardUnix(addr: string): Promise<void>
94
+ }
95
+ /**r" A labeled ngrok tunnel. */
96
+ export class NgrokLabeledTunnel {
97
+ /** The labels this tunnel was started with. */
98
+ labels(): Record<string, string>
99
+ /** The ID of this tunnel, assigned by the remote server. */
100
+ id(): string
101
+ /** Forward incoming tunnel connections to the provided TCP address. */
102
+ forwardTcp(addr: string): Promise<void>
103
+ /** Forward incoming tunnel connections to the provided Unix socket path. */
104
+ forwardUnix(addr: string): Promise<void>
105
+ }
106
+ /**r" An ngrok tunnel backing an HTTP endpoint. */
107
+ export class NgrokHttpTunnelBuilder {
108
+ /**
109
+ * The scheme that this edge should use.
110
+ * Defaults to [Scheme::HTTPS].
111
+ */
112
+ scheme(scheme: string): this
113
+ /** The domain to request for this edge. */
114
+ domain(domain: string): this
115
+ /** Certificates to use for client authentication at the ngrok edge. */
116
+ mutualTlsca(mutualTlsca: Uint8Array): this
117
+ /** Enable gzip compression for HTTP responses. */
118
+ compression(): this
119
+ /** Convert incoming websocket connections to TCP-like streams. */
120
+ websocketTcpConversion(): this
121
+ /**
122
+ * Reject requests when 5XX responses exceed this ratio.
123
+ * Disabled when 0.
124
+ */
125
+ circuitBreaker(circuitBreaker: number): this
126
+ /** with_request_header adds a header to all requests to this edge. */
127
+ requestHeader(name: string, value: string): this
128
+ /** with_response_header adds a header to all responses coming from this edge. */
129
+ responseHeader(name: string, value: string): this
130
+ /** with_remove_request_header removes a header from requests to this edge. */
131
+ removeRequestHeader(name: string): this
132
+ /** with_remove_response_header removes a header from responses from this edge. */
133
+ removeResponseHeader(name: string): this
134
+ /**
135
+ * Credentials for basic authentication.
136
+ * If not called, basic authentication is disabled.
137
+ */
138
+ basicAuth(username: string, password: string): this
139
+ /**
140
+ * OAuth configuration.
141
+ * If not called, OAuth is disabled.
142
+ */
143
+ oauth(provider: string, allowEmails: Array<string>, allowDomains: Array<string>, scopes: Array<string>): this
144
+ /**
145
+ * OIDC configuration.
146
+ * If not called, OIDC is disabled.
147
+ */
148
+ oidc(issuerUrl: string, clientId: string, clientSecret: string, allowEmails: Array<string>, allowDomains: Array<string>, scopes: Array<string>): this
149
+ /**
150
+ * WebhookVerification configuration.
151
+ * If not called, WebhookVerification is disabled.
152
+ */
153
+ webhookVerification(provider: string, secret: string): this
154
+ /** Tunnel-specific opaque metadata. Viewable via the API. */
155
+ metadata(metadata: string): this
156
+ /** Begin listening for new connections on this tunnel. */
157
+ listen(): Promise<NgrokHttpTunnel>
158
+ /**
159
+ * Restriction placed on the origin of incoming connections to the edge to only allow these CIDR ranges.
160
+ * Call multiple times to add additional CIDR ranges.
161
+ */
162
+ allowCidrString(cidr: string): this
163
+ /**
164
+ * Restriction placed on the origin of incoming connections to the edge to deny these CIDR ranges.
165
+ * Call multiple times to add additional CIDR ranges.
166
+ */
167
+ denyCidrString(cidr: string): this
168
+ /** The version of PROXY protocol to use with this tunnel, None if not using. */
169
+ proxyProto(proxyProto: string): this
170
+ /**
171
+ * Tunnel backend metadata. Viewable via the dashboard and API, but has no
172
+ * bearing on tunnel behavior.
173
+ */
174
+ forwardsTo(forwardsTo: string): this
175
+ }
176
+ /**r" An ngrok tunnel backing a TCP endpoint. */
177
+ export class NgrokTcpTunnelBuilder {
178
+ /** The TCP address to request for this edge. */
179
+ remoteAddr(remoteAddr: string): this
180
+ /** Tunnel-specific opaque metadata. Viewable via the API. */
181
+ metadata(metadata: string): this
182
+ /** Begin listening for new connections on this tunnel. */
183
+ listen(): Promise<NgrokTcpTunnel>
184
+ /**
185
+ * Restriction placed on the origin of incoming connections to the edge to only allow these CIDR ranges.
186
+ * Call multiple times to add additional CIDR ranges.
187
+ */
188
+ allowCidrString(cidr: string): this
189
+ /**
190
+ * Restriction placed on the origin of incoming connections to the edge to deny these CIDR ranges.
191
+ * Call multiple times to add additional CIDR ranges.
192
+ */
193
+ denyCidrString(cidr: string): this
194
+ /** The version of PROXY protocol to use with this tunnel, None if not using. */
195
+ proxyProto(proxyProto: string): this
196
+ /**
197
+ * Tunnel backend metadata. Viewable via the dashboard and API, but has no
198
+ * bearing on tunnel behavior.
199
+ */
200
+ forwardsTo(forwardsTo: string): this
201
+ }
202
+ /**r" An ngrok tunnel backing a TLS endpoint. */
203
+ export class NgrokTlsTunnelBuilder {
204
+ /** The domain to request for this edge. */
205
+ domain(domain: string): this
206
+ /** Certificates to use for client authentication at the ngrok edge. */
207
+ mutualTlsca(mutualTlsca: Uint8Array): this
208
+ /** The key to use for TLS termination at the ngrok edge in PEM format. */
209
+ keyPem(keyPem: Uint8Array): this
210
+ /**
211
+ * The certificate to use for TLS termination at the ngrok edge in PEM
212
+ * format.
213
+ */
214
+ certPem(certPem: Uint8Array): this
215
+ /** Tunnel-specific opaque metadata. Viewable via the API. */
216
+ metadata(metadata: string): this
217
+ /** Begin listening for new connections on this tunnel. */
218
+ listen(): Promise<NgrokTlsTunnel>
219
+ /**
220
+ * Restriction placed on the origin of incoming connections to the edge to only allow these CIDR ranges.
221
+ * Call multiple times to add additional CIDR ranges.
222
+ */
223
+ allowCidrString(cidr: string): this
224
+ /**
225
+ * Restriction placed on the origin of incoming connections to the edge to deny these CIDR ranges.
226
+ * Call multiple times to add additional CIDR ranges.
227
+ */
228
+ denyCidrString(cidr: string): this
229
+ /** The version of PROXY protocol to use with this tunnel, None if not using. */
230
+ proxyProto(proxyProto: string): this
231
+ /**
232
+ * Tunnel backend metadata. Viewable via the dashboard and API, but has no
233
+ * bearing on tunnel behavior.
234
+ */
235
+ forwardsTo(forwardsTo: string): this
236
+ }
237
+ /**r" A labeled ngrok tunnel. */
238
+ export class NgrokLabeledTunnelBuilder {
239
+ /** Tunnel-specific opaque metadata. Viewable via the API. */
240
+ metadata(metadata: string): this
241
+ /** Begin listening for new connections on this tunnel. */
242
+ listen(): Promise<NgrokLabeledTunnel>
243
+ /** Add a label, value pair for this tunnel. */
244
+ label(label: string, value: string): this
245
+ }