@ngrok/ngrok 0.7.1 → 0.8.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.
Files changed (75) hide show
  1. package/CHANGELOG.md +15 -10
  2. package/Cargo.toml +2 -2
  3. package/README.md +37 -21
  4. package/docs/assets/highlight.css +10 -10
  5. package/docs/assets/search.js +1 -1
  6. package/docs/classes/HttpListenerBuilder.html +594 -0
  7. package/docs/classes/LabeledListenerBuilder.html +206 -0
  8. package/docs/classes/Listener.html +241 -0
  9. package/docs/classes/Session.html +207 -0
  10. package/docs/classes/SessionBuilder.html +465 -0
  11. package/docs/classes/TcpListenerBuilder.html +281 -0
  12. package/docs/classes/TlsListenerBuilder.html +322 -0
  13. package/docs/classes/UpdateRequest.html +46 -43
  14. package/docs/functions/authtoken.html +30 -29
  15. package/docs/functions/connect.html +31 -30
  16. package/docs/functions/consoleLog.html +30 -29
  17. package/docs/functions/disconnect.html +31 -30
  18. package/docs/functions/getListener.html +89 -0
  19. package/docs/functions/getListenerByUrl.html +89 -0
  20. package/docs/functions/kill.html +31 -30
  21. package/docs/functions/listen.html +33 -32
  22. package/docs/functions/listenable.html +31 -30
  23. package/docs/functions/listeners.html +84 -0
  24. package/docs/functions/loggingCallback.html +30 -29
  25. package/docs/index.html +66 -58
  26. package/docs/interfaces/Config.html +445 -319
  27. package/docs/modules.html +48 -48
  28. package/examples/express/ngrok-express-quickstart.js +1 -1
  29. package/examples/express/ngrok-express.js +6 -6
  30. package/examples/fastify/ngrok-fastify.js +4 -4
  31. package/examples/hapi/ngrok-hapi.js +4 -4
  32. package/examples/koa/ngrok-koa.js +1 -1
  33. package/examples/nestjs/src/main.ts +5 -5
  34. package/examples/nextjs/README.md +3 -0
  35. package/examples/nextjs/ngrok.config.js +7 -7
  36. package/examples/ngrok-connect-full.js +6 -2
  37. package/examples/ngrok-http-full.js +9 -6
  38. package/examples/ngrok-http-minimum.js +6 -6
  39. package/examples/ngrok-labeled.js +6 -6
  40. package/examples/ngrok-listen.js +1 -1
  41. package/examples/ngrok-tcp.js +5 -5
  42. package/examples/ngrok-tls.js +5 -5
  43. package/examples/ngrok-typescript.ts +12 -12
  44. package/examples/ngrok-windows-pipe.js +4 -4
  45. package/examples/ngrok-winston.js +2 -2
  46. package/examples/remix/ngrok.config.js +4 -4
  47. package/examples/svelte/ngrok.config.cjs +4 -4
  48. package/examples/vue/ngrok.config.ts +4 -4
  49. package/index.d.ts +510 -265
  50. package/index.js +75 -73
  51. package/package.json +14 -14
  52. package/scripts/gc-node-drop.js +7 -7
  53. package/scripts/gc-rust-drop.js +9 -9
  54. package/src/config.rs +113 -10
  55. package/src/connect.rs +32 -28
  56. package/src/http.rs +89 -23
  57. package/src/lib.rs +2 -2
  58. package/src/{tunnel.rs → listener.rs} +134 -134
  59. package/src/{tunnel_builder.rs → listener_builder.rs} +63 -54
  60. package/src/session.rs +57 -49
  61. package/src/tcp.rs +6 -3
  62. package/src/tls.rs +17 -7
  63. package/trailer.d.ts +5 -5
  64. package/trailer.js +64 -62
  65. package/typedoc.json +1 -1
  66. package/docs/classes/NgrokHttpTunnelBuilder.html +0 -510
  67. package/docs/classes/NgrokLabeledTunnelBuilder.html +0 -199
  68. package/docs/classes/NgrokSession.html +0 -199
  69. package/docs/classes/NgrokSessionBuilder.html +0 -449
  70. package/docs/classes/NgrokTcpTunnelBuilder.html +0 -268
  71. package/docs/classes/NgrokTlsTunnelBuilder.html +0 -304
  72. package/docs/classes/NgrokTunnel.html +0 -231
  73. package/docs/functions/getTunnel.html +0 -88
  74. package/docs/functions/getTunnelByUrl.html +0 -88
  75. package/docs/functions/tunnels.html +0 -83
package/index.d.ts CHANGED
@@ -39,28 +39,45 @@ export interface Config {
39
39
  /**
40
40
  * Reject requests when 5XX responses exceed this ratio.
41
41
  * Disabled when 0.
42
+ * See [Circuit Breaker] in the ngrok docs for additional details.
43
+ *
44
+ * [Circuit Breaker]: https://ngrok.com/docs/cloud-edge/modules/circuit-breaker/
42
45
  */
43
46
  circuit_breaker?: number
44
- /** Enable gzip compression for HTTP responses. */
47
+ /**
48
+ * Enable gzip compression for HTTP responses.
49
+ * See [Compression] in the ngrok docs for additional details.
50
+ *
51
+ * [Compression]: https://ngrok.com/docs/cloud-edge/modules/compression/
52
+ */
45
53
  compression?: boolean
46
54
  /** Unused, will warn and be ignored */
47
55
  configPath?: string
48
56
  /**
49
57
  * The certificate to use for TLS termination at the ngrok edge in PEM format.
50
58
  * Only used if "proto" is "tls".
59
+ * See [TLS Termination] in the ngrok docs for additional details.
60
+ *
61
+ * [TLS Termination]: https://ngrok.com/docs/cloud-edge/modules/tls-termination/
51
62
  */
52
63
  crt?: string
53
- /** The domain to request for this edge. */
64
+ /**
65
+ * The domain to request for this edge, any valid domain or hostname that you have
66
+ * previously registered with ngrok. If using a custom domain, this requires
67
+ * registering in the [ngrok dashboard] and setting a DNS CNAME value.
68
+ *
69
+ * [ngrok dashboard]: https://dashboard.ngrok.com/cloud-edge/domains
70
+ */
54
71
  domain?: string
55
72
  /**
56
73
  * Returns a human-readable string presented in the ngrok dashboard
57
- * and the Tunnels API.
74
+ * and the API.
58
75
  */
59
76
  forwards_to?: string
60
77
  /** Unused, will warn and be ignored */
61
78
  host_header?: string
62
79
  /**
63
- * The hostname for the tunnel to forward to.
80
+ * The hostname for the listener to forward to.
64
81
  * Only used if addr is not defined.
65
82
  */
66
83
  host?: string
@@ -72,75 +89,184 @@ export interface Config {
72
89
  ip_restriction_allow_cidrs?: string|Array<string>
73
90
  /** Restriction placed on the origin of incoming connections to the edge to deny these CIDR ranges. */
74
91
  ip_restriction_deny_cidrs?: string|Array<string>
92
+ /**
93
+ * A set of regular expressions used to match User-Agents that will be allowed.
94
+ * On request, the User Agent Filter module will check the incoming User-Agent header value
95
+ * against the list of defined allow and deny regular expression rules.
96
+ * See `User Agent Filter`_ in the ngrok docs for additional details.
97
+ *
98
+ * .. _User Agent Filter: https://ngrok.com/docs/cloud-edge/modules/user-agent-filter/
99
+ */
100
+ allow_user_agent?: string|Array<string>
101
+ /**
102
+ * A set of regular expressions used to match User-Agents that will be denied.
103
+ * On request, the User Agent Filter module will check the incoming User-Agent header value
104
+ * against the list of defined allow and deny regular expression rules.
105
+ * See `User Agent Filter`_ in the ngrok docs for additional details.
106
+ *
107
+ * .. _User Agent Filter: https://ngrok.com/docs/cloud-edge/modules/user-agent-filter/
108
+ */
109
+ deny_user_agent?: string|Array<string>
75
110
  /**
76
111
  * The certificate to use for TLS termination at the ngrok edge in PEM format.
77
112
  * Only used if "proto" is "tls".
113
+ * See [TLS Termination] in the ngrok docs for additional details.
114
+ *
115
+ * [TLS Termination]: https://ngrok.com/docs/cloud-edge/modules/tls-termination/
78
116
  */
79
117
  key?: string
80
- /** Add label, value pairs for this tunnel, colon separated. */
118
+ /** Add label, value pairs for this listener, colon separated. */
81
119
  labels?: string|Array<string>
82
- /** Tunnel-specific opaque metadata. Viewable via the API. */
120
+ /** Listener-specific opaque metadata. Viewable via the API. */
83
121
  metadata?: string
84
122
  /**
85
123
  * Certificates to use for client authentication at the ngrok edge.
86
124
  * Only used if "proto" is "tls" or "http".
125
+ * See [Mutual TLS] in the ngrok docs for additional details.
126
+ *
127
+ * [Mutual TLS]: https://ngrok.com/docs/cloud-edge/modules/mutual-tls/
87
128
  */
88
129
  mutual_tls_cas?: string|Array<string>
89
130
  /** Unused, will warn and be ignored */
90
131
  name?: string
91
- /** OAuth configuration of domains to allow. */
132
+ /**
133
+ * OAuth configuration of domains to allow.
134
+ * See [OAuth] in the ngrok docs for additional details.
135
+ *
136
+ * [OAuth]: https://ngrok.com/docs/cloud-edge/modules/oauth/
137
+ */
92
138
  oauth_allow_domains?: string|Array<string>
93
- /** OAuth configuration of email addresses to allow. */
139
+ /**
140
+ * OAuth configuration of email addresses to allow.
141
+ * See [OAuth] in the ngrok docs for additional details.
142
+ *
143
+ * [OAuth]: https://ngrok.com/docs/cloud-edge/modules/oauth/
144
+ */
94
145
  oauth_allow_emails?: string|Array<string>
95
- /** OAuth configuration of scopes. */
146
+ /**
147
+ * OAuth configuration of scopes.
148
+ * See [OAuth] in the ngrok docs for additional details.
149
+ *
150
+ * [OAuth]: https://ngrok.com/docs/cloud-edge/modules/oauth/
151
+ */
96
152
  oauth_scopes?: string|Array<string>
97
153
  /**
98
154
  * OAuth configuration of the provider, e.g. "google".
99
- * https://ngrok.com/docs/cloud-edge/modules/oauth/
155
+ * See [OAuth] in the ngrok docs for additional details.
156
+ *
157
+ * [OAuth]: https://ngrok.com/docs/cloud-edge/modules/oauth/
100
158
  */
101
159
  oauth_provider?: string
102
- /** OIDC configuration of client ID. */
160
+ /**
161
+ * OAuth configuration of client ID. Required for scopes.
162
+ * See [OAuth] in the ngrok docs for additional details.
163
+ *
164
+ * [OAuth]: https://ngrok.com/docs/cloud-edge/modules/oauth/
165
+ */
166
+ oauth_client_id?: string
167
+ /**
168
+ * OAuth configuration of client secret. Required for scopes.
169
+ * See [OAuth] in the ngrok docs for additional details.
170
+ *
171
+ * [OAuth]: https://ngrok.com/docs/cloud-edge/modules/oauth/
172
+ */
173
+ oauth_client_secret?: string
174
+ /**
175
+ * OIDC configuration of client ID.
176
+ * See [OpenID Connect] in the ngrok docs for additional details.
177
+ *
178
+ * [OpenID Connect]: https://ngrok.com/docs/cloud-edge/modules/openid-connect/
179
+ */
103
180
  oidc_client_id?: string
104
- /** OIDC configuration of client secret. */
181
+ /**
182
+ * OIDC configuration of client secret.
183
+ * See [OpenID Connect] in the ngrok docs for additional details.
184
+ *
185
+ * [OpenID Connect]: https://ngrok.com/docs/cloud-edge/modules/openid-connect/
186
+ */
105
187
  oidc_client_secret?: string
106
- /** OIDC configuration of scopes. */
188
+ /**
189
+ * OIDC configuration of scopes.
190
+ * See [OpenID Connect] in the ngrok docs for additional details.
191
+ *
192
+ * [OpenID Connect]: https://ngrok.com/docs/cloud-edge/modules/openid-connect/
193
+ */
107
194
  oidc_scopes?: string|Array<string>
108
- /** OIDC configuration of the issuer URL. */
195
+ /**
196
+ * OIDC configuration of the issuer URL.
197
+ * See [OpenID Connect] in the ngrok docs for additional details.
198
+ *
199
+ * [OpenID Connect]: https://ngrok.com/docs/cloud-edge/modules/openid-connect/
200
+ */
109
201
  oidc_issuer_url?: string
110
- /** OIDC configuration of domains to allow. */
202
+ /**
203
+ * OIDC configuration of domains to allow.
204
+ * See [OpenID Connect] in the ngrok docs for additional details.
205
+ *
206
+ * [OpenID Connect]: https://ngrok.com/docs/cloud-edge/modules/openid-connect/
207
+ */
111
208
  oidc_allow_domains?: string|Array<string>
112
- /** OIDC configuration of email addresses to allow. */
209
+ /**
210
+ * OIDC configuration of email addresses to allow.
211
+ * See [OpenID Connect] in the ngrok docs for additional details.
212
+ *
213
+ * [OpenID Connect]: https://ngrok.com/docs/cloud-edge/modules/openid-connect/
214
+ */
113
215
  oidc_allow_emails?: string|Array<string>
114
216
  /** Returns log messages from the ngrok library. */
115
217
  onLogEvent?: (data: string) => void
116
218
  /** 'closed' - connection is lost, 'connected' - reconnected */
117
219
  onStatusChange?: (status: string) => void
118
220
  /**
119
- * The port for the tunnel to forward to.
221
+ * The port for the listener to forward to.
120
222
  * Only used if addr is not defined.
121
223
  */
122
224
  port?: number
123
- /** The type of tunnel to use, one of http|tcp|tls|labeled, defaults to http. */
225
+ /** The type of listener to use, one of http|tcp|tls|labeled, defaults to http. */
124
226
  proto?: string
125
- /** The version of PROXY protocol to use with this tunnel "1", "2", or "" if not using. */
227
+ /** The version of PROXY protocol to use with this listener "1", "2", or "" if not using. */
126
228
  proxy_proto?: string
127
- /** Adds a header to all requests to this edge. */
229
+ /**
230
+ * Adds a header to all requests to this edge.
231
+ * See [Request Headers] in the ngrok docs for additional details.
232
+ *
233
+ * [Request Headers]: https://ngrok.com/docs/cloud-edge/modules/request-headers/
234
+ */
128
235
  request_header_add?: string|Array<string>
129
- /** Removes a header from requests to this edge. */
236
+ /**
237
+ * Removes a header from requests to this edge.
238
+ * See [Request Headers] in the ngrok docs for additional details.
239
+ *
240
+ * [Request Headers]: https://ngrok.com/docs/cloud-edge/modules/request-headers/
241
+ */
130
242
  request_header_remove?: string|Array<string>
131
- /** Adds a header to all responses coming from this edge. */
243
+ /**
244
+ * Adds a header to all responses coming from this edge.
245
+ * See [Response Headers] in the ngrok docs for additional details.
246
+ *
247
+ * [Response Headers]: https://ngrok.com/docs/cloud-edge/modules/response-headers/
248
+ */
132
249
  response_header_add?: string|Array<string>
133
- /** Removes a header from responses from this edge. */
250
+ /**
251
+ * Removes a header from responses from this edge.
252
+ * See [Response Headers] in the ngrok docs for additional details.
253
+ *
254
+ * [Response Headers]: https://ngrok.com/docs/cloud-edge/modules/response-headers/
255
+ */
134
256
  response_header_remove?: string|Array<string>
135
257
  /** Unused, will warn and be ignored */
136
258
  region?: string
137
259
  /**
138
260
  * The TCP address to request for this edge.
261
+ * These addresses can be reserved in the [ngrok dashboard] to use across sessions. For example: remote_addr("2.tcp.ngrok.io:21746")
139
262
  * Only used if proto is "tcp".
263
+ *
264
+ * [ngrok dashboard]: https://dashboard.ngrok.com/cloud-edge/tcp-addresses
140
265
  */
141
266
  remote_addr?: string
142
267
  /**
143
- * The scheme that this edge should use, defaults to "https".
268
+ * The scheme that this edge should use.
269
+ * "HTTPS" or "HTTP", defaults to "HTTPS".
144
270
  * If multiple are given only the last one is used.
145
271
  */
146
272
  schemes?: string|Array<string>
@@ -159,21 +285,37 @@ export interface Config {
159
285
  subdomain?: string
160
286
  /** Unused, will warn and be ignored */
161
287
  terminate_at?: string
162
- /** WebhookVerification configuration, the provider to use. */
288
+ /**
289
+ * WebhookVerification configuration, the provider to use.
290
+ * See [Webhook Verification] in the ngrok docs for additional details.
291
+ *
292
+ * [Webhook Verification]: https://ngrok.com/docs/cloud-edge/modules/webhook-verification/
293
+ */
163
294
  verify_webhook_provider?: string
164
- /** WebhookVerification configuration, the secret to use. */
295
+ /**
296
+ * WebhookVerification configuration, the secret to use.
297
+ * See [Webhook Verification] in the ngrok docs for additional details.
298
+ *
299
+ * [Webhook Verification]: https://ngrok.com/docs/cloud-edge/modules/webhook-verification/
300
+ */
165
301
  verify_webhook_secret?: string
166
302
  /** Unused, will warn and be ignored */
167
303
  web_addr?: string
168
304
  /** Convert incoming websocket connections to TCP-like streams. */
169
305
  websocket_tcp_converter?: boolean
170
306
  }
171
- /** Transform a json object configuration into a tunnel */
307
+ /** Transform a json object configuration into a listener */
172
308
  export function connect(config: Config|string|number): Promise<string>
173
- /** Close a tunnel with the given url, or all tunnels if no url is defined. */
309
+ /** Close a listener with the given url, or all listeners if no url is defined. */
174
310
  export function disconnect(url?: string | undefined | null): Promise<void>
175
- /** Close all tunnels. */
311
+ /** Close all listeners. */
176
312
  export function kill(): Promise<void>
313
+ /** Retrieve a list of non-closed listeners, in no particular order. */
314
+ export function listeners(): Promise<Array<Listener>>
315
+ /** Retrieve listener using the id */
316
+ export function getListener(id: string): Promise<Listener | null>
317
+ /** Retrieve listener using the url */
318
+ export function getListenerByUrl(url: string): Promise<Listener | null>
177
319
  /**
178
320
  * Register a callback function that will receive logging event information.
179
321
  * An absent callback will unregister an existing callback function.
@@ -182,18 +324,329 @@ export function kill(): Promise<void>
182
324
  export function loggingCallback(callback?: (level: string, target: string, message: string) => void, level?: string): void
183
325
  /** Set the default auth token to use for any future sessions. */
184
326
  export function authtoken(authtoken: string): Promise<void>
185
- /** Retrieve a list of non-closed tunnels, in no particular order. */
186
- export function tunnels(): Promise<Array<NgrokTunnel>>
187
- /** Retrieve tunnel using the id */
188
- export function getTunnel(id: string): Promise<NgrokTunnel | null>
189
- /** Retrieve tunnel using the url */
190
- export function getTunnelByUrl(url: string): Promise<NgrokTunnel | null>
327
+ /**
328
+ * An ngrok listener.
329
+ *
330
+ * @group Listener and Sessions
331
+ */
332
+ export class Listener {
333
+ /** The URL that this listener backs. */
334
+ url(): string | null
335
+ /** The protocol of the endpoint that this listener backs. */
336
+ proto(): string | null
337
+ /** The labels this listener was started with. */
338
+ labels(): Record<string, string>
339
+ /** Returns a listener's unique ID. */
340
+ id(): string
341
+ /**
342
+ * Returns a human-readable string presented in the ngrok dashboard
343
+ * and the API. Use the [HttpListenerBuilder::forwards_to],
344
+ * [TcpListenerBuilder::forwards_to], etc. to set this value
345
+ * explicitly.
346
+ */
347
+ forwardsTo(): string
348
+ /** Returns the arbitrary metadata string for this listener. */
349
+ metadata(): string
350
+ /**
351
+ * Forward incoming listener connections. This can be either a TCP address or a file socket path.
352
+ * For file socket paths on Linux/Darwin, addr can be a unix domain socket path, e.g. "/tmp/ngrok.sock"
353
+ * On Windows, addr can be a named pipe, e.e. "\\\\.\\pipe\\an_ngrok_pipe
354
+ */
355
+ forward(addr: string): Promise<void>
356
+ /** Wait for the forwarding task to exit. */
357
+ join(): Promise<void>
358
+ /**
359
+ * Close the listener.
360
+ *
361
+ * This is an RPC call that must be `.await`ed.
362
+ * It is equivalent to calling `Session::close_listener` with this
363
+ * listener's ID.
364
+ */
365
+ close(): Promise<void>
366
+ }
367
+ /**
368
+ *r" An ngrok listener backing an HTTP endpoint.
369
+ *r"
370
+ *r" @group Listener Builders
371
+ */
372
+ export class HttpListenerBuilder {
373
+ /**
374
+ * The scheme that this edge should use.
375
+ * "HTTPS" or "HTTP", defaults to "HTTPS".
376
+ */
377
+ scheme(scheme: string): this
378
+ /**
379
+ * The domain to request for this edge, any valid domain or hostname that you have
380
+ * previously registered with ngrok. If using a custom domain, this requires
381
+ * registering in the [ngrok dashboard] and setting a DNS CNAME value.
382
+ *
383
+ * [ngrok dashboard]: https://dashboard.ngrok.com/cloud-edge/domains
384
+ */
385
+ domain(domain: string): this
386
+ /**
387
+ * Certificates to use for client authentication at the ngrok edge.
388
+ * See [Mutual TLS] in the ngrok docs for additional details.
389
+ *
390
+ * [Mutual TLS]: https://ngrok.com/docs/cloud-edge/modules/mutual-tls/
391
+ */
392
+ mutualTlsca(mutualTlsca: Uint8Array): this
393
+ /**
394
+ * Enable gzip compression for HTTP responses.
395
+ * See [Compression] in the ngrok docs for additional details.
396
+ *
397
+ * [Compression]: https://ngrok.com/docs/cloud-edge/modules/compression/
398
+ */
399
+ compression(): this
400
+ /** Convert incoming websocket connections to TCP-like streams. */
401
+ websocketTcpConversion(): this
402
+ /**
403
+ * Reject requests when 5XX responses exceed this ratio.
404
+ * Disabled when 0.
405
+ * See [Circuit Breaker] in the ngrok docs for additional details.
406
+ *
407
+ * [Circuit Breaker]: https://ngrok.com/docs/cloud-edge/modules/circuit-breaker/
408
+ */
409
+ circuitBreaker(circuitBreaker: number): this
410
+ /**
411
+ * Adds a header to all requests to this edge.
412
+ * See [Request Headers] in the ngrok docs for additional details.
413
+ *
414
+ * [Request Headers]: https://ngrok.com/docs/cloud-edge/modules/request-headers/
415
+ */
416
+ requestHeader(name: string, value: string): this
417
+ /**
418
+ * Adds a header to all responses coming from this edge.
419
+ * See [Response Headers] in the ngrok docs for additional details.
420
+ *
421
+ * [Response Headers]: https://ngrok.com/docs/cloud-edge/modules/response-headers/
422
+ */
423
+ responseHeader(name: string, value: string): this
424
+ /**
425
+ * Removes a header from requests to this edge.
426
+ * See [Request Headers] in the ngrok docs for additional details.
427
+ *
428
+ * [Request Headers]: https://ngrok.com/docs/cloud-edge/modules/request-headers/
429
+ */
430
+ removeRequestHeader(name: string): this
431
+ /**
432
+ * Removes a header from responses from this edge.
433
+ * See [Response Headers] in the ngrok docs for additional details.
434
+ *
435
+ * [Response Headers]: https://ngrok.com/docs/cloud-edge/modules/response-headers/
436
+ */
437
+ removeResponseHeader(name: string): this
438
+ /**
439
+ * Credentials for basic authentication.
440
+ * If not called, basic authentication is disabled.
441
+ */
442
+ basicAuth(username: string, password: string): this
443
+ /**
444
+ * A set of regular expressions used to match User-Agents that will be allowed.
445
+ * On request, the User Agent Filter module will check the incoming User-Agent header value
446
+ * against the list of defined allow and deny regular expression rules.
447
+ * See [User Agent Filter] in the ngrok docs for additional details.
448
+ *
449
+ * .. [User Agent Filter]: https://ngrok.com/docs/cloud-edge/modules/user-agent-filter/
450
+ */
451
+ allowUserAgent(regex: string): this
452
+ /**
453
+ * A set of regular expressions used to match User-Agents that will be denied.
454
+ * On request, the User Agent Filter module will check the incoming User-Agent header value
455
+ * against the list of defined allow and deny regular expression rules.
456
+ * See [User Agent Filter] in the ngrok docs for additional details.
457
+ *
458
+ * .. [User Agent Filter]: https://ngrok.com/docs/cloud-edge/modules/user-agent-filter/
459
+ */
460
+ denyUserAgent(regex: string): this
461
+ /**
462
+ * OAuth configuration.
463
+ * If not called, OAuth is disabled.
464
+ * See [OAuth] in the ngrok docs for additional details.
465
+ *
466
+ * [OAuth]: https://ngrok.com/docs/cloud-edge/modules/oauth/
467
+ */
468
+ oauth(provider: string, allowEmails?: Array<string> | undefined | null, allowDomains?: Array<string> | undefined | null, scopes?: Array<string> | undefined | null, clientId?: string | undefined | null, clientSecret?: string | undefined | null): this
469
+ /**
470
+ * OIDC configuration.
471
+ * If not called, OIDC is disabled.
472
+ * See [OpenID Connect] in the ngrok docs for additional details.
473
+ *
474
+ * [OpenID Connect]: https://ngrok.com/docs/cloud-edge/modules/openid-connect/
475
+ */
476
+ oidc(issuerUrl: string, clientId: string, clientSecret: string, allowEmails?: Array<string> | undefined | null, allowDomains?: Array<string> | undefined | null, scopes?: Array<string> | undefined | null): this
477
+ /**
478
+ * WebhookVerification configuration.
479
+ * If not called, WebhookVerification is disabled.
480
+ * See [Webhook Verification] in the ngrok docs for additional details.
481
+ *
482
+ * [Webhook Verification]: https://ngrok.com/docs/cloud-edge/modules/webhook-verification/
483
+ */
484
+ webhookVerification(provider: string, secret: string): this
485
+ /** Listener-specific opaque metadata. Viewable via the API. */
486
+ metadata(metadata: string): this
487
+ /** Begin listening for new connections on this listener. */
488
+ listen(bind?: boolean | undefined | null): Promise<Listener>
489
+ /** Begin listening for new connections on this listener and forwarding them to the given url. */
490
+ listenAndForward(toUrl: string): Promise<Listener>
491
+ /** Begin listening for new connections on this listener and forwarding them to the given server. */
492
+ listenAndServe(server: any): Promise<Listener>
493
+ /**
494
+ * Restriction placed on the origin of incoming connections to the edge to only allow these CIDR ranges.
495
+ * Call multiple times to add additional CIDR ranges.
496
+ * See [IP restrictions] in the ngrok docs for additional details.
497
+ *
498
+ * [IP restrictions]: https://ngrok.com/docs/cloud-edge/modules/ip-restrictions/
499
+ */
500
+ allowCidr(cidr: string): this
501
+ /**
502
+ * Restriction placed on the origin of incoming connections to the edge to deny these CIDR ranges.
503
+ * Call multiple times to add additional CIDR ranges.
504
+ * See [IP restrictions] in the ngrok docs for additional details.
505
+ *
506
+ * [IP restrictions]: https://ngrok.com/docs/cloud-edge/modules/ip-restrictions/
507
+ */
508
+ denyCidr(cidr: string): this
509
+ /** The version of PROXY protocol to use with this listener "1", "2", or "" if not using. */
510
+ proxyProto(proxyProto: string): this
511
+ /**
512
+ * Listener backend metadata. Viewable via the dashboard and API, but has no
513
+ * bearing on listener behavior.
514
+ */
515
+ forwardsTo(forwardsTo: string): this
516
+ }
517
+ /**
518
+ *r" An ngrok listener backing a TCP endpoint.
519
+ *r"
520
+ *r" @group Listener Builders
521
+ */
522
+ export class TcpListenerBuilder {
523
+ /** Listener-specific opaque metadata. Viewable via the API. */
524
+ metadata(metadata: string): this
525
+ /** Begin listening for new connections on this listener. */
526
+ listen(bind?: boolean | undefined | null): Promise<Listener>
527
+ /** Begin listening for new connections on this listener and forwarding them to the given url. */
528
+ listenAndForward(toUrl: string): Promise<Listener>
529
+ /** Begin listening for new connections on this listener and forwarding them to the given server. */
530
+ listenAndServe(server: any): Promise<Listener>
531
+ /**
532
+ * Restriction placed on the origin of incoming connections to the edge to only allow these CIDR ranges.
533
+ * Call multiple times to add additional CIDR ranges.
534
+ * See [IP restrictions] in the ngrok docs for additional details.
535
+ *
536
+ * [IP restrictions]: https://ngrok.com/docs/cloud-edge/modules/ip-restrictions/
537
+ */
538
+ allowCidr(cidr: string): this
539
+ /**
540
+ * Restriction placed on the origin of incoming connections to the edge to deny these CIDR ranges.
541
+ * Call multiple times to add additional CIDR ranges.
542
+ * See [IP restrictions] in the ngrok docs for additional details.
543
+ *
544
+ * [IP restrictions]: https://ngrok.com/docs/cloud-edge/modules/ip-restrictions/
545
+ */
546
+ denyCidr(cidr: string): this
547
+ /** The version of PROXY protocol to use with this listener "1", "2", or "" if not using. */
548
+ proxyProto(proxyProto: string): this
549
+ /**
550
+ * Listener backend metadata. Viewable via the dashboard and API, but has no
551
+ * bearing on listener behavior.
552
+ */
553
+ forwardsTo(forwardsTo: string): this
554
+ /**
555
+ * The TCP address to request for this edge.
556
+ * These addresses can be reserved in the [ngrok dashboard] to use across sessions. For example: remote_addr("2.tcp.ngrok.io:21746")
557
+ *
558
+ * [ngrok dashboard]: https://dashboard.ngrok.com/cloud-edge/tcp-addresses
559
+ */
560
+ remoteAddr(remoteAddr: string): this
561
+ }
562
+ /**
563
+ *r" An ngrok listener backing a TLS endpoint.
564
+ *r"
565
+ *r" @group Listener Builders
566
+ */
567
+ export class TlsListenerBuilder {
568
+ /** Listener-specific opaque metadata. Viewable via the API. */
569
+ metadata(metadata: string): this
570
+ /** Begin listening for new connections on this listener. */
571
+ listen(bind?: boolean | undefined | null): Promise<Listener>
572
+ /** Begin listening for new connections on this listener and forwarding them to the given url. */
573
+ listenAndForward(toUrl: string): Promise<Listener>
574
+ /** Begin listening for new connections on this listener and forwarding them to the given server. */
575
+ listenAndServe(server: any): Promise<Listener>
576
+ /**
577
+ * Restriction placed on the origin of incoming connections to the edge to only allow these CIDR ranges.
578
+ * Call multiple times to add additional CIDR ranges.
579
+ * See [IP restrictions] in the ngrok docs for additional details.
580
+ *
581
+ * [IP restrictions]: https://ngrok.com/docs/cloud-edge/modules/ip-restrictions/
582
+ */
583
+ allowCidr(cidr: string): this
584
+ /**
585
+ * Restriction placed on the origin of incoming connections to the edge to deny these CIDR ranges.
586
+ * Call multiple times to add additional CIDR ranges.
587
+ * See [IP restrictions] in the ngrok docs for additional details.
588
+ *
589
+ * [IP restrictions]: https://ngrok.com/docs/cloud-edge/modules/ip-restrictions/
590
+ */
591
+ denyCidr(cidr: string): this
592
+ /** The version of PROXY protocol to use with this listener "1", "2", or "" if not using. */
593
+ proxyProto(proxyProto: string): this
594
+ /**
595
+ * Listener backend metadata. Viewable via the dashboard and API, but has no
596
+ * bearing on listener behavior.
597
+ */
598
+ forwardsTo(forwardsTo: string): this
599
+ /**
600
+ * The domain to request for this edge, any valid domain or hostname that you have
601
+ * previously registered with ngrok. If using a custom domain, this requires
602
+ * registering in the [ngrok dashboard] and setting a DNS CNAME value.
603
+ *
604
+ * [ngrok dashboard]: https://dashboard.ngrok.com/cloud-edge/domains
605
+ */
606
+ domain(domain: string): this
607
+ /**
608
+ * Certificates to use for client authentication at the ngrok edge.
609
+ * See [Mutual TLS] in the ngrok docs for additional details.
610
+ *
611
+ * [Mutual TLS]: https://ngrok.com/docs/cloud-edge/modules/mutual-tls/
612
+ */
613
+ mutualTlsca(mutualTlsca: Uint8Array): this
614
+ /**
615
+ * The key to use for TLS termination at the ngrok edge in PEM format.
616
+ * See [TLS Termination] in the ngrok docs for additional details.
617
+ *
618
+ * [TLS Termination]: https://ngrok.com/docs/cloud-edge/modules/tls-termination/
619
+ */
620
+ termination(certPem: Uint8Array, keyPem: Uint8Array): this
621
+ }
622
+ /**
623
+ *r" A labeled ngrok listener.
624
+ *r"
625
+ *r" @group Listener Builders
626
+ */
627
+ export class LabeledListenerBuilder {
628
+ /** Listener-specific opaque metadata. Viewable via the API. */
629
+ metadata(metadata: string): this
630
+ /** Begin listening for new connections on this listener. */
631
+ listen(bind?: boolean | undefined | null): Promise<Listener>
632
+ /** Begin listening for new connections on this listener and forwarding them to the given url. */
633
+ listenAndForward(toUrl: string): Promise<Listener>
634
+ /** Begin listening for new connections on this listener and forwarding them to the given server. */
635
+ listenAndServe(server: any): Promise<Listener>
636
+ /**
637
+ * Add a label, value pair for this listener.
638
+ * See [Using Labels] in the ngrok docs for additional details.
639
+ *
640
+ * [Using Labels]: https://ngrok.com/docs/guides/using-labels-within-ngrok/
641
+ */
642
+ label(label: string, value: string): this
643
+ }
191
644
  /**
192
645
  * The builder for an ngrok session.
193
646
  *
194
- * @group Tunnel and Sessions
647
+ * @group Listener and Sessions
195
648
  */
196
- export class NgrokSessionBuilder {
649
+ export class SessionBuilder {
197
650
  /** Create a new session builder */
198
651
  constructor()
199
652
  /**
@@ -336,26 +789,26 @@ export class NgrokSessionBuilder {
336
789
  */
337
790
  handleHeartbeat(handler: (latency: number) => void): this
338
791
  /** Attempt to establish an ngrok session using the current configuration. */
339
- connect(): Promise<NgrokSession>
792
+ connect(): Promise<Session>
340
793
  }
341
794
  /**
342
795
  * An ngrok session.
343
796
  *
344
- * @group Tunnel and Sessions
797
+ * @group Listener and Sessions
345
798
  */
346
- export class NgrokSession {
347
- /** Start building a tunnel backing an HTTP endpoint. */
348
- httpEndpoint(): NgrokHttpTunnelBuilder
349
- /** Start building a tunnel backing a TCP endpoint. */
350
- tcpEndpoint(): NgrokTcpTunnelBuilder
351
- /** Start building a tunnel backing a TLS endpoint. */
352
- tlsEndpoint(): NgrokTlsTunnelBuilder
353
- /** Start building a labeled tunnel. */
354
- labeledTunnel(): NgrokLabeledTunnelBuilder
355
- /** Retrieve a list of this session's non-closed tunnels, in no particular order. */
356
- tunnels(): Promise<Array<NgrokTunnel>>
357
- /** Close a tunnel with the given ID. */
358
- closeTunnel(id: string): Promise<void>
799
+ export class Session {
800
+ /** Start building a listener backing an HTTP endpoint. */
801
+ httpEndpoint(): HttpListenerBuilder
802
+ /** Start building a listener backing a TCP endpoint. */
803
+ tcpEndpoint(): TcpListenerBuilder
804
+ /** Start building a listener backing a TLS endpoint. */
805
+ tlsEndpoint(): TlsListenerBuilder
806
+ /** Start building a labeled listener. */
807
+ labeledListener(): LabeledListenerBuilder
808
+ /** Retrieve a list of this session's non-closed listeners, in no particular order. */
809
+ listeners(): Promise<Array<Listener>>
810
+ /** Close a listener with the given ID. */
811
+ closeListener(id: string): Promise<void>
359
812
  /** Close the ngrok session. */
360
813
  close(): Promise<void>
361
814
  }
@@ -367,223 +820,15 @@ export class UpdateRequest {
367
820
  permitMajorVersion: boolean
368
821
  }
369
822
  /**
370
- * An ngrok tunnel.
371
- *
372
- * @group Tunnel and Sessions
373
- */
374
- export class NgrokTunnel {
375
- /** The URL that this tunnel backs. */
376
- url(): string | null
377
- /** The protocol of the endpoint that this tunnel backs. */
378
- proto(): string | null
379
- /** The labels this tunnel was started with. */
380
- labels(): Record<string, string>
381
- /** Returns a tunnel's unique ID. */
382
- id(): string
383
- /**
384
- * Returns a human-readable string presented in the ngrok dashboard
385
- * and the Tunnels API. Use the [HttpTunnelBuilder::forwards_to],
386
- * [TcpTunnelBuilder::forwards_to], etc. to set this value
387
- * explicitly.
388
- */
389
- forwardsTo(): string
390
- /** Returns the arbitrary metadata string for this tunnel. */
391
- metadata(): string
392
- /**
393
- * Forward incoming tunnel connections. This can be either a TCP address or a file socket path.
394
- * For file socket paths on Linux/Darwin, addr can be a unix domain socket path, e.g. "/tmp/ngrok.sock"
395
- * On Windows, addr can be a named pipe, e.e. "\\\\.\\pipe\\an_ngrok_pipe
396
- */
397
- forward(addr: string): Promise<void>
398
- /** Wait for the forwarding task to exit. */
399
- join(): Promise<void>
400
- /**
401
- * Close the tunnel.
402
- *
403
- * This is an RPC call that must be `.await`ed.
404
- * It is equivalent to calling `Session::close_tunnel` with this
405
- * tunnel's ID.
406
- */
407
- close(): Promise<void>
408
- }
409
- /**
410
- *r" An ngrok tunnel backing an HTTP endpoint.
411
- *r"
412
- *r" @group Tunnel Builders
413
- */
414
- export class NgrokHttpTunnelBuilder {
415
- /**
416
- * The scheme that this edge should use.
417
- * Defaults to [Scheme::HTTPS].
418
- */
419
- scheme(scheme: string): this
420
- /** The domain to request for this edge. */
421
- domain(domain: string): this
422
- /** Certificates to use for client authentication at the ngrok edge. */
423
- mutualTlsca(mutualTlsca: Uint8Array): this
424
- /** Enable gzip compression for HTTP responses. */
425
- compression(): this
426
- /** Convert incoming websocket connections to TCP-like streams. */
427
- websocketTcpConversion(): this
428
- /**
429
- * Reject requests when 5XX responses exceed this ratio.
430
- * Disabled when 0.
431
- */
432
- circuitBreaker(circuitBreaker: number): this
433
- /** request_header adds a header to all requests to this edge. */
434
- requestHeader(name: string, value: string): this
435
- /** response_header adds a header to all responses coming from this edge. */
436
- responseHeader(name: string, value: string): this
437
- /** remove_request_header removes a header from requests to this edge. */
438
- removeRequestHeader(name: string): this
439
- /** remove_response_header removes a header from responses from this edge. */
440
- removeResponseHeader(name: string): this
441
- /**
442
- * Credentials for basic authentication.
443
- * If not called, basic authentication is disabled.
444
- */
445
- basicAuth(username: string, password: string): this
446
- /**
447
- * OAuth configuration.
448
- * If not called, OAuth is disabled.
449
- * https://ngrok.com/docs/cloud-edge/modules/oauth/
450
- */
451
- oauth(provider: string, allowEmails?: Array<string> | undefined | null, allowDomains?: Array<string> | undefined | null, scopes?: Array<string> | undefined | null): this
452
- /**
453
- * OIDC configuration.
454
- * If not called, OIDC is disabled.
455
- */
456
- oidc(issuerUrl: string, clientId: string, clientSecret: string, allowEmails?: Array<string> | undefined | null, allowDomains?: Array<string> | undefined | null, scopes?: Array<string> | undefined | null): this
457
- /**
458
- * WebhookVerification configuration.
459
- * If not called, WebhookVerification is disabled.
460
- */
461
- webhookVerification(provider: string, secret: string): this
462
- /** Tunnel-specific opaque metadata. Viewable via the API. */
463
- metadata(metadata: string): this
464
- /** Begin listening for new connections on this tunnel. */
465
- listen(bind?: boolean | undefined | null): Promise<NgrokTunnel>
466
- /** Begin listening for new connections on this tunnel and forwarding them to the given url. */
467
- listenAndForward(toUrl: string): Promise<NgrokTunnel>
468
- /** Begin listening for new connections on this tunnel and forwarding them to the given server. */
469
- listenAndServe(server: any): Promise<NgrokTunnel>
470
- /**
471
- * Restriction placed on the origin of incoming connections to the edge to only allow these CIDR ranges.
472
- * Call multiple times to add additional CIDR ranges.
473
- */
474
- allowCidr(cidr: string): this
475
- /**
476
- * Restriction placed on the origin of incoming connections to the edge to deny these CIDR ranges.
477
- * Call multiple times to add additional CIDR ranges.
478
- */
479
- denyCidr(cidr: string): this
480
- /** The version of PROXY protocol to use with this tunnel "1", "2", or "" if not using. */
481
- proxyProto(proxyProto: string): this
482
- /**
483
- * Tunnel backend metadata. Viewable via the dashboard and API, but has no
484
- * bearing on tunnel behavior.
485
- */
486
- forwardsTo(forwardsTo: string): this
487
- }
488
- /**
489
- *r" An ngrok tunnel backing a TCP endpoint.
490
- *r"
491
- *r" @group Tunnel Builders
492
- */
493
- export class NgrokTcpTunnelBuilder {
494
- /** The TCP address to request for this edge. */
495
- remoteAddr(remoteAddr: string): this
496
- /** Tunnel-specific opaque metadata. Viewable via the API. */
497
- metadata(metadata: string): this
498
- /** Begin listening for new connections on this tunnel. */
499
- listen(bind?: boolean | undefined | null): Promise<NgrokTunnel>
500
- /** Begin listening for new connections on this tunnel and forwarding them to the given url. */
501
- listenAndForward(toUrl: string): Promise<NgrokTunnel>
502
- /** Begin listening for new connections on this tunnel and forwarding them to the given server. */
503
- listenAndServe(server: any): Promise<NgrokTunnel>
504
- /**
505
- * Restriction placed on the origin of incoming connections to the edge to only allow these CIDR ranges.
506
- * Call multiple times to add additional CIDR ranges.
507
- */
508
- allowCidr(cidr: string): this
509
- /**
510
- * Restriction placed on the origin of incoming connections to the edge to deny these CIDR ranges.
511
- * Call multiple times to add additional CIDR ranges.
512
- */
513
- denyCidr(cidr: string): this
514
- /** The version of PROXY protocol to use with this tunnel "1", "2", or "" if not using. */
515
- proxyProto(proxyProto: string): this
516
- /**
517
- * Tunnel backend metadata. Viewable via the dashboard and API, but has no
518
- * bearing on tunnel behavior.
519
- */
520
- forwardsTo(forwardsTo: string): this
521
- }
522
- /**
523
- *r" An ngrok tunnel backing a TLS endpoint.
524
- *r"
525
- *r" @group Tunnel Builders
526
- */
527
- export class NgrokTlsTunnelBuilder {
528
- /** The domain to request for this edge. */
529
- domain(domain: string): this
530
- /** Certificates to use for client authentication at the ngrok edge. */
531
- mutualTlsca(mutualTlsca: Uint8Array): this
532
- /** The certificate and key to use for TLS termination at the ngrok edge in PEM format. */
533
- termination(certPem: Uint8Array, keyPem: Uint8Array): this
534
- /** Tunnel-specific opaque metadata. Viewable via the API. */
535
- metadata(metadata: string): this
536
- /** Begin listening for new connections on this tunnel. */
537
- listen(bind?: boolean | undefined | null): Promise<NgrokTunnel>
538
- /** Begin listening for new connections on this tunnel and forwarding them to the given url. */
539
- listenAndForward(toUrl: string): Promise<NgrokTunnel>
540
- /** Begin listening for new connections on this tunnel and forwarding them to the given server. */
541
- listenAndServe(server: any): Promise<NgrokTunnel>
542
- /**
543
- * Restriction placed on the origin of incoming connections to the edge to only allow these CIDR ranges.
544
- * Call multiple times to add additional CIDR ranges.
545
- */
546
- allowCidr(cidr: string): this
547
- /**
548
- * Restriction placed on the origin of incoming connections to the edge to deny these CIDR ranges.
549
- * Call multiple times to add additional CIDR ranges.
550
- */
551
- denyCidr(cidr: string): this
552
- /** The version of PROXY protocol to use with this tunnel "1", "2", or "" if not using. */
553
- proxyProto(proxyProto: string): this
554
- /**
555
- * Tunnel backend metadata. Viewable via the dashboard and API, but has no
556
- * bearing on tunnel behavior.
557
- */
558
- forwardsTo(forwardsTo: string): this
559
- }
560
- /**
561
- *r" A labeled ngrok tunnel.
562
- *r"
563
- *r" @group Tunnel Builders
564
- */
565
- export class NgrokLabeledTunnelBuilder {
566
- /** Tunnel-specific opaque metadata. Viewable via the API. */
567
- metadata(metadata: string): this
568
- /** Begin listening for new connections on this tunnel. */
569
- listen(bind?: boolean | undefined | null): Promise<NgrokTunnel>
570
- /** Begin listening for new connections on this tunnel and forwarding them to the given url. */
571
- listenAndForward(toUrl: string): Promise<NgrokTunnel>
572
- /** Begin listening for new connections on this tunnel and forwarding them to the given server. */
573
- listenAndServe(server: any): Promise<NgrokTunnel>
574
- /** Add a label, value pair for this tunnel. */
575
- label(label: string, value: string): this
576
- }
577
- /**
578
- * Get a listenable ngrok tunnel, suitable for passing to net.Server.listen().
823
+ * Get a listenable ngrok listener, suitable for passing to net.Server.listen().
579
824
  * Uses the NGROK_AUTHTOKEN environment variable to authenticate.
580
825
  */
581
- export function listenable(): NgrokTunnel;
826
+ export function listenable(): Listener;
582
827
  /**
583
- * Start the given net.Server listening to a generated, or passed in, tunnel.
584
- * Uses the NGROK_AUTHTOKEN environment variable to authenticate if a new tunnel is created.
828
+ * Start the given net.Server listening to a generated, or passed in, listener.
829
+ * Uses the NGROK_AUTHTOKEN environment variable to authenticate if a new listener is created.
585
830
  */
586
- export function listen(server: import("net").Server, tunnel?: NgrokTunnel): NgrokTunnel;
831
+ export function listen(server: import("net").Server, listener?: Listener): Listener;
587
832
  /**
588
833
  * Register a console.log callback for ngrok INFO logging.
589
834
  * Optionally set the logging level to one of ERROR, WARN, INFO, DEBUG, or TRACE.