@ngrok/ngrok 1.0.0 → 1.1.1

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/CHANGELOG.md CHANGED
@@ -1,3 +1,11 @@
1
+ ## 1.1.1:
2
+
3
+ - Add `appProtocol(string)` to the labeled listener builder. Setting this to "http2" will enable HTTP/2 support to the backend application.
4
+
5
+ ## 1.1.0:
6
+
7
+ - Add `appProtocol(string)` to http listener builder, and `app_protocol: string` as a `ngrok.forward()` argument. Setting this to "http2" will enable HTTP/2 support to the backend application.
8
+
1
9
  ## 1.0.0:
2
10
 
3
11
  - Add policy support to Listener builders and `ngrok.forward`
package/README.md CHANGED
@@ -69,7 +69,7 @@ A quickstart guide and a full API reference are included in the [ngrok-javascrip
69
69
 
70
70
  ### Authorization
71
71
 
72
- To use most of ngrok's features, you'll need an authtoken. To obtain one, sign up for free at [ngrok.com](https://dashboard.ngrok.com/signup) and retrieve it from the [authtoken page of your ngrok dashboard](https://dashboard.ngrok.com/get-started/your-authtoken). Once you have copied your authtoken, you can reference it in several ways.
72
+ To use ngrok you'll need an authtoken. To obtain one, sign up for free at [ngrok.com](https://dashboard.ngrok.com/signup) and retrieve it from the [authtoken page of your ngrok dashboard](https://dashboard.ngrok.com/get-started/your-authtoken). Once you have copied your authtoken, you can reference it in several ways.
73
73
 
74
74
  You can set it in the `NGROK_AUTHTOKEN` environment variable and pass `authtoken_from_env: true` to the [forward](https://ngrok.github.io/ngrok-javascript/functions/forward.html) method:
75
75
 
@@ -230,6 +230,7 @@ const listener = await ngrok.forward({
230
230
  proxy_proto: "", // One of: "", "1", "2"
231
231
  schemes: ["HTTPS"],
232
232
  labels: "edge:edghts_2G...", // Along with proto="labeled"
233
+ app_protocol: "http2",
233
234
  // module configuration
234
235
  basic_auth: ["ngrok:online1line"],
235
236
  circuit_breaker: 0.1,
package/index.d.ts CHANGED
@@ -14,6 +14,8 @@ export interface Config {
14
14
  * Examples: "80", "localhost:8080", "https://192.168.1.100:8443", "unix:/tmp/my.sock", "pipe://./my-pipe"
15
15
  */
16
16
  addr?: number|string
17
+ /** The L7 application protocol to use for this edge, e.g. "http2" or "http1". */
18
+ app_protocol?: string
17
19
  auth?: string|Array<string>
18
20
  /**
19
21
  * Configures the session to authenticate with the provided authtoken. You
@@ -396,6 +398,8 @@ export class HttpListenerBuilder {
396
398
  * "HTTPS" or "HTTP", defaults to "HTTPS".
397
399
  */
398
400
  scheme(scheme: string): this
401
+ /** The L7 application protocol to use for this edge, e.g. "http2" or "http1". */
402
+ appProtocol(appProtocol: string): this
399
403
  /**
400
404
  * The domain to request for this edge, any valid domain or hostname that you have
401
405
  * previously registered with ngrok. If using a custom domain, this requires
@@ -700,6 +704,8 @@ export class LabeledListenerBuilder {
700
704
  * [Using Labels]: https://ngrok.com/docs/guides/using-labels-within-ngrok/
701
705
  */
702
706
  label(label: string, value: string): this
707
+ /** Set the L7 application portocol for this listener, i.e. "http1" or "http2" (defaults "http1") */
708
+ appProtocol(appProtocol: string): this
703
709
  }
704
710
  /**
705
711
  * The builder for an ngrok session.
package/index.js CHANGED
@@ -501,28 +501,31 @@ async function ngrokLinkPipe(listener, server) {
501
501
  }
502
502
 
503
503
  // protect against multiple calls, for instance from npm
504
- var sigintRan = false;
504
+ var sigHandlerRan = false;
505
505
 
506
506
  function registerCleanup(listener, socket) {
507
- process.on("SIGINT", function () {
508
- if (sigintRan) return;
509
- sigintRan = true;
507
+ for (const signal of ["SIGINT", "SIGTERM"]) {
508
+ process.on(signal, function () {
509
+ if (process.listenerCount(signal) > 1) {
510
+ // user has registered a handler, abort this one
511
+ return;
512
+ }
510
513
 
511
- if (process.listenerCount("SIGINT") > 1) {
512
- // user has registered a handler, abort this one
513
- return;
514
- }
515
- // close listener
516
- if (listener) {
517
- listener.close().catch((err) => {
518
- console.error(`Error closing listener: ${err}`);
519
- });
520
- }
521
- // close webserver's socket
522
- if (socket) socket.close();
523
- // unregister any logging callback
524
- loggingCallback();
525
- });
514
+ if (sigHandlerRan) return;
515
+ sigHandlerRan = true;
516
+
517
+ // close listener
518
+ if (listener) {
519
+ listener.close().catch((err) => {
520
+ console.error(`Error closing listener: ${err}`);
521
+ });
522
+ }
523
+ // close webserver's socket
524
+ if (socket) socket.close();
525
+ // unregister any logging callback
526
+ loggingCallback();
527
+ });
528
+ }
526
529
  }
527
530
 
528
531
  function consoleLog(level) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ngrok/ngrok",
3
- "version": "1.0.0",
3
+ "version": "1.1.1",
4
4
  "main": "index.js",
5
5
  "types": "index.d.ts",
6
6
  "files": [
@@ -76,18 +76,18 @@
76
76
  "url": "https://github.com/ngrok/ngrok-javascript.git"
77
77
  },
78
78
  "optionalDependencies": {
79
- "@ngrok/ngrok-win32-x64-msvc": "1.0.0",
80
- "@ngrok/ngrok-darwin-x64": "1.0.0",
81
- "@ngrok/ngrok-linux-x64-gnu": "1.0.0",
82
- "@ngrok/ngrok-darwin-arm64": "1.0.0",
83
- "@ngrok/ngrok-android-arm64": "1.0.0",
84
- "@ngrok/ngrok-linux-arm64-gnu": "1.0.0",
85
- "@ngrok/ngrok-linux-arm64-musl": "1.0.0",
86
- "@ngrok/ngrok-linux-arm-gnueabihf": "1.0.0",
87
- "@ngrok/ngrok-linux-x64-musl": "1.0.0",
88
- "@ngrok/ngrok-freebsd-x64": "1.0.0",
89
- "@ngrok/ngrok-win32-ia32-msvc": "1.0.0",
90
- "@ngrok/ngrok-android-arm-eabi": "1.0.0",
91
- "@ngrok/ngrok-darwin-universal": "1.0.0"
79
+ "@ngrok/ngrok-win32-x64-msvc": "1.1.1",
80
+ "@ngrok/ngrok-darwin-x64": "1.1.1",
81
+ "@ngrok/ngrok-linux-x64-gnu": "1.1.1",
82
+ "@ngrok/ngrok-darwin-arm64": "1.1.1",
83
+ "@ngrok/ngrok-android-arm64": "1.1.1",
84
+ "@ngrok/ngrok-linux-arm64-gnu": "1.1.1",
85
+ "@ngrok/ngrok-linux-arm64-musl": "1.1.1",
86
+ "@ngrok/ngrok-linux-arm-gnueabihf": "1.1.1",
87
+ "@ngrok/ngrok-linux-x64-musl": "1.1.1",
88
+ "@ngrok/ngrok-freebsd-x64": "1.1.1",
89
+ "@ngrok/ngrok-win32-ia32-msvc": "1.1.1",
90
+ "@ngrok/ngrok-android-arm-eabi": "1.1.1",
91
+ "@ngrok/ngrok-darwin-universal": "1.1.1"
92
92
  }
93
93
  }