@ngrok/ngrok 0.7.0 → 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 +19 -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 +7 -3
  37. package/examples/ngrok-http-full.js +9 -6
  38. package/examples/ngrok-http-minimum.js +6 -6
  39. package/examples/ngrok-labeled.js +7 -7
  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 +511 -266
  50. package/index.js +81 -75
  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 +114 -11
  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 +69 -63
  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.js CHANGED
@@ -17,7 +17,7 @@ function isMusl() {
17
17
  // For Node 10
18
18
  if (!process.report || typeof process.report.getReport !== 'function') {
19
19
  try {
20
- const lddPath = require('child_process').execSync('which ldd').toString().trim();
20
+ const lddPath = require('child_process').execSync('which ldd').toString().trim()
21
21
  return readFileSync(lddPath, 'utf8').includes('musl')
22
22
  } catch (e) {
23
23
  return true
@@ -252,24 +252,24 @@ if (!nativeBinding) {
252
252
  throw new Error(`Failed to load native binding`)
253
253
  }
254
254
 
255
- const { connect, disconnect, kill, loggingCallback, authtoken, NgrokSessionBuilder, NgrokSession, UpdateRequest, NgrokTunnel, tunnels, getTunnel, getTunnelByUrl, NgrokHttpTunnelBuilder, NgrokTcpTunnelBuilder, NgrokTlsTunnelBuilder, NgrokLabeledTunnelBuilder } = nativeBinding
255
+ const { connect, disconnect, kill, Listener, listeners, getListener, getListenerByUrl, HttpListenerBuilder, TcpListenerBuilder, TlsListenerBuilder, LabeledListenerBuilder, loggingCallback, authtoken, SessionBuilder, Session, UpdateRequest } = nativeBinding
256
256
 
257
257
  module.exports.connect = connect
258
258
  module.exports.disconnect = disconnect
259
259
  module.exports.kill = kill
260
+ module.exports.Listener = Listener
261
+ module.exports.listeners = listeners
262
+ module.exports.getListener = getListener
263
+ module.exports.getListenerByUrl = getListenerByUrl
264
+ module.exports.HttpListenerBuilder = HttpListenerBuilder
265
+ module.exports.TcpListenerBuilder = TcpListenerBuilder
266
+ module.exports.TlsListenerBuilder = TlsListenerBuilder
267
+ module.exports.LabeledListenerBuilder = LabeledListenerBuilder
260
268
  module.exports.loggingCallback = loggingCallback
261
269
  module.exports.authtoken = authtoken
262
- module.exports.NgrokSessionBuilder = NgrokSessionBuilder
263
- module.exports.NgrokSession = NgrokSession
270
+ module.exports.SessionBuilder = SessionBuilder
271
+ module.exports.Session = Session
264
272
  module.exports.UpdateRequest = UpdateRequest
265
- module.exports.NgrokTunnel = NgrokTunnel
266
- module.exports.tunnels = tunnels
267
- module.exports.getTunnel = getTunnel
268
- module.exports.getTunnelByUrl = getTunnelByUrl
269
- module.exports.NgrokHttpTunnelBuilder = NgrokHttpTunnelBuilder
270
- module.exports.NgrokTcpTunnelBuilder = NgrokTcpTunnelBuilder
271
- module.exports.NgrokTlsTunnelBuilder = NgrokTlsTunnelBuilder
272
- module.exports.NgrokLabeledTunnelBuilder = NgrokLabeledTunnelBuilder
273
273
  //
274
274
  // javascript trailer
275
275
  //
@@ -280,24 +280,24 @@ const os = require("os");
280
280
  const path = require("path");
281
281
 
282
282
  // wrap connect with the code for extending exception with error code
283
- NgrokSessionBuilder.prototype._connect = NgrokSessionBuilder.prototype.connect;
284
- NgrokSessionBuilder.prototype.connect = ngrokSessionConnect;
283
+ SessionBuilder.prototype._connect = SessionBuilder.prototype.connect;
284
+ SessionBuilder.prototype.connect = ngrokSessionConnect;
285
285
 
286
286
  // wrap listen with the bind code for passing to net.Server.listen()
287
- NgrokHttpTunnelBuilder.prototype._listen = NgrokHttpTunnelBuilder.prototype.listen;
288
- NgrokTcpTunnelBuilder.prototype._listen = NgrokTcpTunnelBuilder.prototype.listen;
289
- NgrokTlsTunnelBuilder.prototype._listen = NgrokTlsTunnelBuilder.prototype.listen;
290
- NgrokLabeledTunnelBuilder.prototype._listen = NgrokLabeledTunnelBuilder.prototype.listen;
287
+ HttpListenerBuilder.prototype._listen = HttpListenerBuilder.prototype.listen;
288
+ TcpListenerBuilder.prototype._listen = TcpListenerBuilder.prototype.listen;
289
+ TlsListenerBuilder.prototype._listen = TlsListenerBuilder.prototype.listen;
290
+ LabeledListenerBuilder.prototype._listen = LabeledListenerBuilder.prototype.listen;
291
291
 
292
- NgrokHttpTunnelBuilder.prototype.listen = ngrokBind;
293
- NgrokTcpTunnelBuilder.prototype.listen = ngrokBind;
294
- NgrokTlsTunnelBuilder.prototype.listen = ngrokBind;
295
- NgrokLabeledTunnelBuilder.prototype.listen = ngrokBind;
292
+ HttpListenerBuilder.prototype.listen = ngrokBind;
293
+ TcpListenerBuilder.prototype.listen = ngrokBind;
294
+ TlsListenerBuilder.prototype.listen = ngrokBind;
295
+ LabeledListenerBuilder.prototype.listen = ngrokBind;
296
296
 
297
- NgrokHttpTunnelBuilder.prototype.listenAndServe = listenAndServe;
298
- NgrokTcpTunnelBuilder.prototype.listenAndServe = listenAndServe;
299
- NgrokTlsTunnelBuilder.prototype.listenAndServe = listenAndServe;
300
- NgrokLabeledTunnelBuilder.prototype.listenAndServe = listenAndServe;
297
+ HttpListenerBuilder.prototype.listenAndServe = listenAndServe;
298
+ TcpListenerBuilder.prototype.listenAndServe = listenAndServe;
299
+ TlsListenerBuilder.prototype.listenAndServe = listenAndServe;
300
+ LabeledListenerBuilder.prototype.listenAndServe = listenAndServe;
301
301
 
302
302
  // Wrap session connect to fill in exception's errorCode
303
303
  async function ngrokSessionConnect() {
@@ -309,29 +309,29 @@ async function ngrokSessionConnect() {
309
309
  }
310
310
  }
311
311
 
312
- // Begin listening for new connections on this tunnel,
313
- // and bind to a local socket so this tunnel can be
312
+ // Begin listening for new connections on this listener,
313
+ // and bind to a local socket so this listener can be
314
314
  // passed into net.Server.listen().
315
315
  async function ngrokBind(bind) {
316
316
  try {
317
- const tunnel = await this._listen();
317
+ const listener = await this._listen();
318
318
  if (bind !== false) {
319
319
  const socket = await randomTcpSocket();
320
- tunnel.socket = socket;
321
- defineTunnelHandle(tunnel, socket);
320
+ listener.socket = socket;
321
+ defineListenerHandle(listener, socket);
322
322
  }
323
- return tunnel;
323
+ return listener;
324
324
  } catch (err) {
325
325
  populateErrorCode(err);
326
326
  throw err;
327
327
  }
328
328
  }
329
329
 
330
- /// Begin listening for new connections on this tunnel and forwarding them to the given server.
330
+ /// Begin listening for new connections on this listener and forwarding them to the given server.
331
331
  async function listenAndServe(server) {
332
- const tunnel = await this._listen();
333
- tunnel.socket = await ngrokListen(server, tunnel);
334
- return tunnel;
332
+ const listener = await this._listen();
333
+ listener.socket = await ngrokListen(server, listener);
334
+ return listener;
335
335
  }
336
336
 
337
337
  function populateErrorCode(err) {
@@ -344,15 +344,15 @@ function populateErrorCode(err) {
344
344
  }
345
345
  }
346
346
 
347
- // add a 'handle' getter to the tunnel so it can be
347
+ // add a 'handle' getter to the listener so it can be
348
348
  // passed into net.Server.listen().
349
- function defineTunnelHandle(tunnel, socket) {
349
+ function defineListenerHandle(listener, socket) {
350
350
  // NodeJS net.Server asks passed-in object for 'handle',
351
351
  // Return the native TCP object so the pre-existing socket is used.
352
- Object.defineProperty(tunnel, "handle", {
352
+ Object.defineProperty(listener, "handle", {
353
353
  get: function () {
354
354
  // turn on forwarding now that it has been requested
355
- tunnel.forward("localhost:" + socket.address().port);
355
+ listener.forward("localhost:" + socket.address().port);
356
356
  return socket._handle;
357
357
  },
358
358
  });
@@ -378,61 +378,61 @@ function asyncListen(server, options) {
378
378
  }
379
379
 
380
380
  // Make a session using NGROK_AUTHTOKEN from the environment,
381
- // and then return a listening HTTP tunnel.
382
- async function defaultTunnel(bind) {
383
- // set up a default session and tunnel
384
- var builder = new NgrokSessionBuilder();
381
+ // and then return a listening HTTP listener.
382
+ async function defaultListener(bind) {
383
+ // set up a default session and listener
384
+ var builder = new SessionBuilder();
385
385
  builder.authtokenFromEnv();
386
386
  var session = await builder.connect();
387
- var tunnel = await session.httpEndpoint().listen(bind);
388
- tunnel.session = session; // surface to caller
389
- return tunnel;
387
+ var listener = await session.httpEndpoint().listen(bind);
388
+ listener.session = session; // surface to caller
389
+ return listener;
390
390
  }
391
391
 
392
- // Get a listenable ngrok tunnel, suitable for passing to net.Server.listen().
392
+ // Get a listenable ngrok listener, suitable for passing to net.Server.listen().
393
393
  // Uses the NGROK_AUTHTOKEN environment variable to authenticate.
394
394
  async function listenable() {
395
- return await defaultTunnel();
395
+ return await defaultListener();
396
396
  }
397
397
 
398
- // Bind a server to a new ngrok tunnel, optionally passing in a pre-existing tunnel instead.
399
- // Uses the NGROK_AUTHTOKEN environment variable to authenticate if a new tunnel is created.
400
- async function ngrokListen(server, tunnel) {
401
- if (tunnel && tunnel.socket) {
398
+ // Bind a server to a new ngrok listener, optionally passing in a pre-existing listener instead.
399
+ // Uses the NGROK_AUTHTOKEN environment variable to authenticate if a new listener is created.
400
+ async function ngrokListen(server, listener) {
401
+ if (listener && listener.socket) {
402
402
  // close the default bound port
403
- tunnel.socket.close();
403
+ listener.socket.close();
404
404
  }
405
- if (!tunnel) {
405
+ if (!listener) {
406
406
  // turn off automatic bind
407
- tunnel = await defaultTunnel(false);
407
+ listener = await defaultListener(false);
408
408
  }
409
409
 
410
410
  // attempt pipe socket
411
411
  try {
412
- socket = await ngrokLinkPipe(tunnel, server);
412
+ socket = await ngrokLinkPipe(listener, server);
413
413
  } catch (err) {
414
414
  console.debug("Using TCP socket. " + err);
415
415
  // fallback to tcp socket
416
- socket = await ngrokLinkTcp(tunnel, server);
416
+ socket = await ngrokLinkTcp(listener, server);
417
417
  }
418
- registerCleanup(tunnel, socket);
418
+ registerCleanup(listener, socket);
419
419
 
420
- server.tunnel = tunnel; // surface to caller
421
- socket.tunnel = tunnel; // surface to caller
420
+ server.listener = listener; // surface to caller
421
+ socket.listener = listener; // surface to caller
422
422
  // return the newly created net.Server, which will be different in the express case
423
423
  return socket;
424
424
  }
425
425
 
426
- async function ngrokLinkTcp(tunnel, server) {
426
+ async function ngrokLinkTcp(listener, server) {
427
427
  // random local port
428
428
  const socket = await asyncListen(server, { host: "localhost", port: 0 });
429
429
  // forward to socket
430
- tunnel.forward("localhost:" + socket.address().port);
430
+ listener.forward("localhost:" + socket.address().port);
431
431
  return socket;
432
432
  }
433
433
 
434
- function generatePipeFilename(tunnel, server) {
435
- var proposed = "tun-" + tunnel.id() + ".sock";
434
+ function generatePipeFilename(listener, server) {
435
+ var proposed = "tun-" + listener.id() + ".sock";
436
436
 
437
437
  // windows leaves little choice
438
438
  if (platform == "win32") {
@@ -475,8 +475,8 @@ function generatePipeFilename(tunnel, server) {
475
475
  return proposed;
476
476
  }
477
477
 
478
- async function ngrokLinkPipe(tunnel, server) {
479
- var filename = generatePipeFilename(tunnel);
478
+ async function ngrokLinkPipe(listener, server) {
479
+ var filename = generatePipeFilename(listener);
480
480
  // begin listening
481
481
  const socket = await asyncListen(server, { path: filename });
482
482
  // tighten permissions
@@ -487,9 +487,13 @@ async function ngrokLinkPipe(tunnel, server) {
487
487
  } catch (err) {
488
488
  console.debug("Cannot change permissions of file: " + filename);
489
489
  }
490
- // forward tunnel
491
- const proto = platform == "win32" ? "pipe:" : "unix:";
492
- tunnel.forward(proto + filename);
490
+ // forward listener
491
+ var addr = "unix:" + filename;
492
+ if (platform == "win32") {
493
+ // convert pipe path to url
494
+ addr = "pipe:" + filename.replace("\\\\.\\pipe\\", "//./");
495
+ }
496
+ listener.forward(addr);
493
497
  socket.path = filename; // surface to caller
494
498
 
495
499
  return socket;
@@ -498,7 +502,7 @@ async function ngrokLinkPipe(tunnel, server) {
498
502
  // protect against multiple calls, for instance from npm
499
503
  var sigintRan = false;
500
504
 
501
- function registerCleanup(tunnel, socket) {
505
+ function registerCleanup(listener, socket) {
502
506
  process.on("SIGINT", function () {
503
507
  if (sigintRan) return;
504
508
  sigintRan = true;
@@ -507,10 +511,10 @@ function registerCleanup(tunnel, socket) {
507
511
  // user has registered a handler, abort this one
508
512
  return;
509
513
  }
510
- // close tunnel
511
- if (tunnel) {
512
- tunnel.close().catch((err) => {
513
- console.error(`Error closing tunnel: ${err}`);
514
+ // close listener
515
+ if (listener) {
516
+ listener.close().catch((err) => {
517
+ console.error(`Error closing listener: ${err}`);
514
518
  });
515
519
  }
516
520
  // close webserver's socket
@@ -542,8 +546,10 @@ async function ngrokConnect(config) {
542
546
  if (Number.isInteger(addr)) config["addr"] = "localhost:" + String(config["addr"]);
543
547
  // convert scalar values to arrays to meet what napi-rs expects
544
548
  [
549
+ "allow_user_agent",
545
550
  "auth",
546
551
  "basic_auth",
552
+ "deny_user_agent",
547
553
  "ip_restriction.allow_cidrs",
548
554
  "ip_restriction.deny_cidrs",
549
555
  "labels",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ngrok/ngrok",
3
- "version": "0.7.0",
3
+ "version": "0.8.0",
4
4
  "main": "index.js",
5
5
  "types": "index.d.ts",
6
6
  "napi": {
@@ -55,18 +55,18 @@
55
55
  "description": "The ngrok agent in library form, suitable for integrating directly into your NodeJS application.",
56
56
  "repository": "https://github.com/ngrok/ngrok-nodejs",
57
57
  "optionalDependencies": {
58
- "@ngrok/ngrok-win32-x64-msvc": "0.7.0",
59
- "@ngrok/ngrok-darwin-x64": "0.7.0",
60
- "@ngrok/ngrok-linux-x64-gnu": "0.7.0",
61
- "@ngrok/ngrok-darwin-arm64": "0.7.0",
62
- "@ngrok/ngrok-android-arm64": "0.7.0",
63
- "@ngrok/ngrok-linux-arm64-gnu": "0.7.0",
64
- "@ngrok/ngrok-linux-arm64-musl": "0.7.0",
65
- "@ngrok/ngrok-linux-arm-gnueabihf": "0.7.0",
66
- "@ngrok/ngrok-linux-x64-musl": "0.7.0",
67
- "@ngrok/ngrok-freebsd-x64": "0.7.0",
68
- "@ngrok/ngrok-win32-ia32-msvc": "0.7.0",
69
- "@ngrok/ngrok-android-arm-eabi": "0.7.0",
70
- "@ngrok/ngrok-darwin-universal": "0.7.0"
58
+ "@ngrok/ngrok-win32-x64-msvc": "0.8.0",
59
+ "@ngrok/ngrok-darwin-x64": "0.8.0",
60
+ "@ngrok/ngrok-linux-x64-gnu": "0.8.0",
61
+ "@ngrok/ngrok-darwin-arm64": "0.8.0",
62
+ "@ngrok/ngrok-android-arm64": "0.8.0",
63
+ "@ngrok/ngrok-linux-arm64-gnu": "0.8.0",
64
+ "@ngrok/ngrok-linux-arm64-musl": "0.8.0",
65
+ "@ngrok/ngrok-linux-arm-gnueabihf": "0.8.0",
66
+ "@ngrok/ngrok-linux-x64-musl": "0.8.0",
67
+ "@ngrok/ngrok-freebsd-x64": "0.8.0",
68
+ "@ngrok/ngrok-win32-ia32-msvc": "0.8.0",
69
+ "@ngrok/ngrok-android-arm-eabi": "0.8.0",
70
+ "@ngrok/ngrok-darwin-universal": "0.8.0"
71
71
  }
72
72
  }
@@ -20,25 +20,25 @@ var ngrok = require("..");
20
20
  // turn on debug
21
21
  ngrok.consoleLog();
22
22
 
23
- new ngrok.NgrokSessionBuilder()
23
+ new ngrok.SessionBuilder()
24
24
  .authtokenFromEnv()
25
25
  .connect()
26
26
  .then((session) => {
27
27
  session
28
28
  .httpEndpoint()
29
29
  .listen()
30
- .then((tunnel) => {
31
- tunnel.forward("localhost:8081").await;
32
- console.log("tunnel: " + tunnel.url() + " id: " + tunnel.id());
30
+ .then((listener) => {
31
+ listener.forward("localhost:8081").await;
32
+ console.log("listener: " + listener.url() + " id: " + listener.id());
33
33
  setTimeout(function () {
34
34
  console.log("\n\n=====> running gc");
35
35
  global.gc();
36
36
  }, 2000);
37
37
 
38
38
  setTimeout(function () {
39
- console.log("\n\n=====> closing and nulling tunnel");
40
- tunnel.close().await;
41
- tunnel = null;
39
+ console.log("\n\n=====> closing and nulling listener");
40
+ listener.close().await;
41
+ listener = null;
42
42
  }, 4000);
43
43
 
44
44
  setTimeout(function () {
@@ -20,19 +20,19 @@ var ngrok = require("..");
20
20
  // turn on debug
21
21
  ngrok.consoleLog();
22
22
 
23
- new ngrok.NgrokSessionBuilder()
23
+ new ngrok.SessionBuilder()
24
24
  .authtokenFromEnv()
25
25
  .connect()
26
26
  .then((session) => {
27
27
  session
28
28
  .httpEndpoint()
29
29
  .listen()
30
- .then((tunnel) => {
31
- tunnel.forward("localhost:8081").await;
32
- const tun_id = tunnel.id();
33
- console.log("tunnel: " + tunnel.url() + " id: " + tun_id);
34
- console.log("\n\n=====> nulling tunnel");
35
- tunnel = null; // nodejs can gc
30
+ .then((listener) => {
31
+ listener.forward("localhost:8081").await;
32
+ const tun_id = listener.id();
33
+ console.log("listener: " + listener.url() + " id: " + tun_id);
34
+ console.log("\n\n=====> nulling listener");
35
+ listener = null; // nodejs can gc
36
36
 
37
37
  setTimeout(function () {
38
38
  console.log("\n\n=====> running gc");
@@ -40,8 +40,8 @@ new ngrok.NgrokSessionBuilder()
40
40
  }, 2000);
41
41
 
42
42
  setTimeout(function () {
43
- console.log("\n\n=====> closing tunnel");
44
- session.closeTunnel(tun_id).await;
43
+ console.log("\n\n=====> closing listener");
44
+ session.closeListener(tun_id).await;
45
45
  }, 4000);
46
46
 
47
47
  setTimeout(function () {
package/src/config.rs CHANGED
@@ -7,7 +7,7 @@ use napi_derive::napi;
7
7
  #[derive(Default)]
8
8
  pub struct Config {
9
9
  /// Port, network address, or named pipe. Defaults to 80.
10
- /// Examples: "80", "localhost:8080", "pipe:/tmp/my.sock"
10
+ /// Examples: "80", "localhost:8080", "unix:/tmp/my.sock", "pipe://./my-pipe"
11
11
  #[napi(ts_type = "number|string")]
12
12
  pub addr: Option<String>,
13
13
  // Synonym for basic_auth
@@ -34,25 +34,38 @@ pub struct Config {
34
34
  pub bin_path: Option<String>,
35
35
  /// Reject requests when 5XX responses exceed this ratio.
36
36
  /// Disabled when 0.
37
+ /// See [Circuit Breaker] in the ngrok docs for additional details.
38
+ ///
39
+ /// [Circuit Breaker]: https://ngrok.com/docs/cloud-edge/modules/circuit-breaker/
37
40
  #[napi(js_name = "circuit_breaker")]
38
41
  pub circuit_breaker: Option<f64>,
39
42
  /// Enable gzip compression for HTTP responses.
43
+ /// See [Compression] in the ngrok docs for additional details.
44
+ ///
45
+ /// [Compression]: https://ngrok.com/docs/cloud-edge/modules/compression/
40
46
  pub compression: Option<bool>,
41
47
  /// Unused, will warn and be ignored
42
48
  pub config_path: Option<String>,
43
49
  /// The certificate to use for TLS termination at the ngrok edge in PEM format.
44
50
  /// Only used if "proto" is "tls".
51
+ /// See [TLS Termination] in the ngrok docs for additional details.
52
+ ///
53
+ /// [TLS Termination]: https://ngrok.com/docs/cloud-edge/modules/tls-termination/
45
54
  pub crt: Option<String>,
46
- /// The domain to request for this edge.
55
+ /// The domain to request for this edge, any valid domain or hostname that you have
56
+ /// previously registered with ngrok. If using a custom domain, this requires
57
+ /// registering in the [ngrok dashboard] and setting a DNS CNAME value.
58
+ ///
59
+ /// [ngrok dashboard]: https://dashboard.ngrok.com/cloud-edge/domains
47
60
  pub domain: Option<String>,
48
61
  /// Returns a human-readable string presented in the ngrok dashboard
49
- /// and the Tunnels API.
62
+ /// and the API.
50
63
  #[napi(js_name = "forwards_to")]
51
64
  pub forwards_to: Option<String>,
52
65
  /// Unused, will warn and be ignored
53
66
  #[napi(js_name = "host_header")]
54
67
  pub host_header: Option<String>,
55
- /// The hostname for the tunnel to forward to.
68
+ /// The hostname for the listener to forward to.
56
69
  /// Only used if addr is not defined.
57
70
  pub host: Option<String>,
58
71
  /// Synonym for domain
@@ -71,84 +84,168 @@ pub struct Config {
71
84
  ts_type = "string|Array<string>"
72
85
  )]
73
86
  pub deny_cidr: Option<Vec<String>>,
87
+
88
+ /// A set of regular expressions used to match User-Agents that will be allowed.
89
+ /// On request, the User Agent Filter module will check the incoming User-Agent header value
90
+ /// against the list of defined allow and deny regular expression rules.
91
+ /// See `User Agent Filter`_ in the ngrok docs for additional details.
92
+ ///
93
+ /// .. _User Agent Filter: https://ngrok.com/docs/cloud-edge/modules/user-agent-filter/
94
+ #[napi(js_name = "allow_user_agent", ts_type = "string|Array<string>")]
95
+ pub allow_user_agent: Option<Vec<String>>,
96
+ /// A set of regular expressions used to match User-Agents that will be denied.
97
+ /// On request, the User Agent Filter module will check the incoming User-Agent header value
98
+ /// against the list of defined allow and deny regular expression rules.
99
+ /// See `User Agent Filter`_ in the ngrok docs for additional details.
100
+ ///
101
+ /// .. _User Agent Filter: https://ngrok.com/docs/cloud-edge/modules/user-agent-filter/
102
+ #[napi(js_name = "deny_user_agent", ts_type = "string|Array<string>")]
103
+ pub deny_user_agent: Option<Vec<String>>,
104
+
74
105
  /// The certificate to use for TLS termination at the ngrok edge in PEM format.
75
106
  /// Only used if "proto" is "tls".
107
+ /// See [TLS Termination] in the ngrok docs for additional details.
108
+ ///
109
+ /// [TLS Termination]: https://ngrok.com/docs/cloud-edge/modules/tls-termination/
76
110
  pub key: Option<String>,
77
- /// Add label, value pairs for this tunnel, colon separated.
111
+ /// Add label, value pairs for this listener, colon separated.
78
112
  #[napi(ts_type = "string|Array<string>")]
79
113
  pub labels: Option<Vec<String>>,
80
- /// Tunnel-specific opaque metadata. Viewable via the API.
114
+ /// Listener-specific opaque metadata. Viewable via the API.
81
115
  pub metadata: Option<String>,
82
116
  /// Certificates to use for client authentication at the ngrok edge.
83
117
  /// Only used if "proto" is "tls" or "http".
118
+ /// See [Mutual TLS] in the ngrok docs for additional details.
119
+ ///
120
+ /// [Mutual TLS]: https://ngrok.com/docs/cloud-edge/modules/mutual-tls/
84
121
  #[napi(js_name = "mutual_tls_cas", ts_type = "string|Array<string>")]
85
122
  pub mutual_tls_cas: Option<Vec<String>>,
86
123
  /// Unused, will warn and be ignored
87
124
  pub name: Option<String>,
125
+
88
126
  /// OAuth configuration of domains to allow.
127
+ /// See [OAuth] in the ngrok docs for additional details.
128
+ ///
129
+ /// [OAuth]: https://ngrok.com/docs/cloud-edge/modules/oauth/
89
130
  #[napi(js_name = "oauth_allow_domains", ts_type = "string|Array<string>")]
90
131
  pub oauth_allow_domains: Option<Vec<String>>,
91
132
  /// OAuth configuration of email addresses to allow.
133
+ /// See [OAuth] in the ngrok docs for additional details.
134
+ ///
135
+ /// [OAuth]: https://ngrok.com/docs/cloud-edge/modules/oauth/
92
136
  #[napi(js_name = "oauth_allow_emails", ts_type = "string|Array<string>")]
93
137
  pub oauth_allow_emails: Option<Vec<String>>,
94
138
  /// OAuth configuration of scopes.
139
+ /// See [OAuth] in the ngrok docs for additional details.
140
+ ///
141
+ /// [OAuth]: https://ngrok.com/docs/cloud-edge/modules/oauth/
95
142
  #[napi(js_name = "oauth_scopes", ts_type = "string|Array<string>")]
96
143
  pub oauth_scopes: Option<Vec<String>>,
97
144
  /// OAuth configuration of the provider, e.g. "google".
98
- /// https://ngrok.com/docs/cloud-edge/modules/oauth/
145
+ /// See [OAuth] in the ngrok docs for additional details.
146
+ ///
147
+ /// [OAuth]: https://ngrok.com/docs/cloud-edge/modules/oauth/
99
148
  #[napi(js_name = "oauth_provider")]
100
149
  pub oauth_provider: Option<String>,
150
+ /// OAuth configuration of client ID. Required for scopes.
151
+ /// See [OAuth] in the ngrok docs for additional details.
152
+ ///
153
+ /// [OAuth]: https://ngrok.com/docs/cloud-edge/modules/oauth/
154
+ #[napi(js_name = "oauth_client_id")]
155
+ pub oauth_client_id: Option<String>,
156
+ /// OAuth configuration of client secret. Required for scopes.
157
+ /// See [OAuth] in the ngrok docs for additional details.
158
+ ///
159
+ /// [OAuth]: https://ngrok.com/docs/cloud-edge/modules/oauth/
160
+ #[napi(js_name = "oauth_client_secret")]
161
+ pub oauth_client_secret: Option<String>,
162
+
101
163
  /// OIDC configuration of client ID.
164
+ /// See [OpenID Connect] in the ngrok docs for additional details.
165
+ ///
166
+ /// [OpenID Connect]: https://ngrok.com/docs/cloud-edge/modules/openid-connect/
102
167
  #[napi(js_name = "oidc_client_id")]
103
168
  pub oidc_client_id: Option<String>,
104
169
  /// OIDC configuration of client secret.
170
+ /// See [OpenID Connect] in the ngrok docs for additional details.
171
+ ///
172
+ /// [OpenID Connect]: https://ngrok.com/docs/cloud-edge/modules/openid-connect/
105
173
  #[napi(js_name = "oidc_client_secret")]
106
174
  pub oidc_client_secret: Option<String>,
107
175
  /// OIDC configuration of scopes.
176
+ /// See [OpenID Connect] in the ngrok docs for additional details.
177
+ ///
178
+ /// [OpenID Connect]: https://ngrok.com/docs/cloud-edge/modules/openid-connect/
108
179
  #[napi(js_name = "oidc_scopes", ts_type = "string|Array<string>")]
109
180
  pub oidc_scopes: Option<Vec<String>>,
110
181
  /// OIDC configuration of the issuer URL.
182
+ /// See [OpenID Connect] in the ngrok docs for additional details.
183
+ ///
184
+ /// [OpenID Connect]: https://ngrok.com/docs/cloud-edge/modules/openid-connect/
111
185
  #[napi(js_name = "oidc_issuer_url")]
112
186
  pub oidc_issuer_url: Option<String>,
113
187
  /// OIDC configuration of domains to allow.
188
+ /// See [OpenID Connect] in the ngrok docs for additional details.
189
+ ///
190
+ /// [OpenID Connect]: https://ngrok.com/docs/cloud-edge/modules/openid-connect/
114
191
  #[napi(js_name = "oidc_allow_domains", ts_type = "string|Array<string>")]
115
192
  pub oidc_allow_domains: Option<Vec<String>>,
116
193
  /// OIDC configuration of email addresses to allow.
194
+ /// See [OpenID Connect] in the ngrok docs for additional details.
195
+ ///
196
+ /// [OpenID Connect]: https://ngrok.com/docs/cloud-edge/modules/openid-connect/
117
197
  #[napi(js_name = "oidc_allow_emails", ts_type = "string|Array<string>")]
118
198
  pub oidc_allow_emails: Option<Vec<String>>,
199
+
119
200
  /// Returns log messages from the ngrok library.
120
201
  #[napi(ts_type = "(data: string) => void")]
121
202
  pub on_log_event: Option<bool>,
122
203
  /// 'closed' - connection is lost, 'connected' - reconnected
123
204
  #[napi(ts_type = "(status: string) => void")]
124
205
  pub on_status_change: Option<bool>,
125
- /// The port for the tunnel to forward to.
206
+ /// The port for the listener to forward to.
126
207
  /// Only used if addr is not defined.
127
208
  pub port: Option<u32>,
128
- /// The type of tunnel to use, one of http|tcp|tls|labeled, defaults to http.
209
+ /// The type of listener to use, one of http|tcp|tls|labeled, defaults to http.
129
210
  pub proto: Option<String>,
130
- /// The version of PROXY protocol to use with this tunnel "1", "2", or "" if not using.
211
+ /// The version of PROXY protocol to use with this listener "1", "2", or "" if not using.
131
212
  #[napi(js_name = "proxy_proto")]
132
213
  pub proxy_proto: Option<String>,
133
214
  /// Adds a header to all requests to this edge.
215
+ /// See [Request Headers] in the ngrok docs for additional details.
216
+ ///
217
+ /// [Request Headers]: https://ngrok.com/docs/cloud-edge/modules/request-headers/
134
218
  #[napi(js_name = "request_header_add", ts_type = "string|Array<string>")]
135
219
  pub request_header_add: Option<Vec<String>>,
136
220
  /// Removes a header from requests to this edge.
221
+ /// See [Request Headers] in the ngrok docs for additional details.
222
+ ///
223
+ /// [Request Headers]: https://ngrok.com/docs/cloud-edge/modules/request-headers/
137
224
  #[napi(js_name = "request_header_remove", ts_type = "string|Array<string>")]
138
225
  pub request_header_remove: Option<Vec<String>>,
139
226
  /// Adds a header to all responses coming from this edge.
227
+ /// See [Response Headers] in the ngrok docs for additional details.
228
+ ///
229
+ /// [Response Headers]: https://ngrok.com/docs/cloud-edge/modules/response-headers/
140
230
  #[napi(js_name = "response_header_add", ts_type = "string|Array<string>")]
141
231
  pub response_header_add: Option<Vec<String>>,
142
232
  /// Removes a header from responses from this edge.
233
+ /// See [Response Headers] in the ngrok docs for additional details.
234
+ ///
235
+ /// [Response Headers]: https://ngrok.com/docs/cloud-edge/modules/response-headers/
143
236
  #[napi(js_name = "response_header_remove", ts_type = "string|Array<string>")]
144
237
  pub response_header_remove: Option<Vec<String>>,
145
238
  /// Unused, will warn and be ignored
146
239
  pub region: Option<String>,
147
240
  /// The TCP address to request for this edge.
241
+ /// These addresses can be reserved in the [ngrok dashboard] to use across sessions. For example: remote_addr("2.tcp.ngrok.io:21746")
148
242
  /// Only used if proto is "tcp".
243
+ ///
244
+ /// [ngrok dashboard]: https://dashboard.ngrok.com/cloud-edge/tcp-addresses
149
245
  #[napi(js_name = "remote_addr")]
150
246
  pub remote_addr: Option<String>,
151
- /// The scheme that this edge should use, defaults to "https".
247
+ /// The scheme that this edge should use.
248
+ /// "HTTPS" or "HTTP", defaults to "HTTPS".
152
249
  /// If multiple are given only the last one is used.
153
250
  #[napi(ts_type = "string|Array<string>")]
154
251
  pub schemes: Option<Vec<String>>,
@@ -168,9 +265,15 @@ pub struct Config {
168
265
  #[napi(js_name = "terminate_at")]
169
266
  pub terminate_at: Option<String>,
170
267
  /// WebhookVerification configuration, the provider to use.
268
+ /// See [Webhook Verification] in the ngrok docs for additional details.
269
+ ///
270
+ /// [Webhook Verification]: https://ngrok.com/docs/cloud-edge/modules/webhook-verification/
171
271
  #[napi(js_name = "verify_webhook_provider")]
172
272
  pub verify_webhook_provider: Option<String>,
173
273
  /// WebhookVerification configuration, the secret to use.
274
+ /// See [Webhook Verification] in the ngrok docs for additional details.
275
+ ///
276
+ /// [Webhook Verification]: https://ngrok.com/docs/cloud-edge/modules/webhook-verification/
174
277
  #[napi(js_name = "verify_webhook_secret")]
175
278
  pub verify_webhook_secret: Option<String>,
176
279
  /// Unused, will warn and be ignored