@ngrok/ngrok 1.2.0 → 1.4.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.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,14 @@
1
+ ## 1.4.0
2
+
3
+ - Rename `policy` to `traffic_policy`
4
+ - Fix quickstart example in README
5
+ - Add Microsoft Visual C++ Redistributable requirement for Windows to documentation
6
+
7
+ ## 1.3.0:
8
+
9
+ - Add `rootCas` to session builder and `root_cas` to `ngrok.forward`. Setting this to `host` will use the host's trusted certificates to connect for the ngrok session.
10
+ - Add `session_ca_cert` and `server_addr` to `ngrok.forward`, which correspond to the same functions in the session builder.
11
+
1
12
  ## 1.2.0:
2
13
 
3
14
  - Add `verifyUpstreamTls` to listener builders and `verify_upstream_tls` to `ngrok.forward`. Setting this to false will skip verification of the upstream application's TLS certificate.
package/README.md CHANGED
@@ -56,6 +56,8 @@ pnpm add @ngrok/ngrok
56
56
  // Output ngrok url to console
57
57
  console.log(`Ingress established at: ${listener.url()}`);
58
58
  })();
59
+
60
+ process.stdin.resume();
59
61
  ```
60
62
 
61
63
  That's it! Your application should now be available through the url output in your terminal.
@@ -185,7 +187,7 @@ As of version `0.7.0` there is backend TLS connection support, validated by a fi
185
187
  await ngrok.forward({ addr: "https://127.0.0.1:3000", authtoken_from_env: true });
186
188
  ```
187
189
 
188
- If the service is using certs not trusted by the OS, such as self-signed certificates, add an environment variable like this before running: `SSL_CERT_FILE=/path/to/ca.crt`.
190
+ If the service is using certs not trusted by the OS, such as self-signed certificates, add an environment variable like this before running: `SSL_CERT_FILE=/path/to/ca.crt`. There is also a `verify_upstream_tls: false` option to disable certification verification.
189
191
 
190
192
  ### Async Programming
191
193
 
@@ -223,6 +225,10 @@ const listener = await ngrok.forward({
223
225
  console.log(`disconnected, addr ${addr} error: ${error}`);
224
226
  },
225
227
  session_metadata: "Online in One Line",
228
+ // advanced session connection configuration
229
+ server_addr: "example.com:443",
230
+ root_cas: "trusted",
231
+ session_ca_cert: fs.readFileSync("ca.pem", "utf8"),
226
232
  // listener configuration
227
233
  metadata: "example listener metadata from javascript",
228
234
  domain: "<domain>",
@@ -254,11 +260,12 @@ const listener = await ngrok.forward({
254
260
  oidc_allow_domains: ["<domain>"],
255
261
  oidc_allow_emails: ["<email>"],
256
262
  oidc_scopes: ["<scope>"],
257
- policy: "<policy_json>",
263
+ traffic_policy: "<policy_json>",
258
264
  request_header_remove: ["X-Req-Nope"],
259
265
  response_header_remove: ["X-Res-Nope"],
260
266
  request_header_add: ["X-Req-Yup:true"],
261
267
  response_header_add: ["X-Res-Yup:true"],
268
+ verify_upstream_tls: false,
262
269
  verify_webhook_provider: "twilio",
263
270
  verify_webhook_secret: "asdf",
264
271
  websocket_tcp_converter: true,
@@ -320,6 +327,8 @@ Pre-built binaries are provided on NPM for the following platforms:
320
327
 
321
328
  > **Note**
322
329
  > `ngrok-javascript`, and [ngrok-rust](https://github.com/ngrok/ngrok-rust/) which it depends on, are open source, so it may be possible to build them for other platforms.
330
+ >
331
+ > On Windows, ensure you have [Microsoft Visual C++ Redistributable](https://learn.microsoft.com/en-us/cpp/windows/latest-supported-vc-redist?view=msvc-170#latest-microsoft-visual-c-redistributable-version) installed.
323
332
  > * `Windows-aarch64` will be supported after the next release of [Ring](https://github.com/briansmith/ring/issues/1167).
324
333
 
325
334
  # Dependencies
package/index.d.ts CHANGED
@@ -76,6 +76,8 @@ export interface Config {
76
76
  * and the API.
77
77
  */
78
78
  forwards_to?: string
79
+ /** Force a new session connection to be made. */
80
+ force_new_session?: boolean
79
81
  /** Unused, will warn and be ignored */
80
82
  host_header?: string
81
83
  /**
@@ -219,7 +221,7 @@ export interface Config {
219
221
  onLogEvent?: (data: string) => void
220
222
  /** 'closed' - connection is lost, 'connected' - reconnected */
221
223
  onStatusChange?: (status: string) => void
222
- /** The Traffic Policy to use for this endpoint. */
224
+ /** DEPRECATED: use TrafficPolicy instead. */
223
225
  policy?: string
224
226
  /**
225
227
  * The port for the listener to forward to.
@@ -268,12 +270,35 @@ export interface Config {
268
270
  * [ngrok dashboard]: https://dashboard.ngrok.com/cloud-edge/tcp-addresses
269
271
  */
270
272
  remote_addr?: string
273
+ /**
274
+ * Sets the file path to a default certificate in PEM format to validate ngrok Session TLS connections.
275
+ * Setting to "trusted" is the default, using the ngrok CA certificate.
276
+ * Setting to "host" will verify using the certificates on the host operating system.
277
+ * A client config set via tls_config after calling root_cas will override this value.
278
+ *
279
+ * Corresponds to the [root_cas parameter in the ngrok docs]
280
+ *
281
+ * [root_cas parameter in the ngrok docs]: https://ngrok.com/docs/ngrok-agent/config#root_cas
282
+ */
283
+ root_cas?: string
271
284
  /**
272
285
  * The scheme that this edge should use.
273
286
  * "HTTPS" or "HTTP", defaults to "HTTPS".
274
287
  * If multiple are given only the last one is used.
275
288
  */
276
289
  schemes?: string|Array<string>
290
+ /**
291
+ * Configures the TLS certificate used to connect to the ngrok service while
292
+ * establishing the session. Use this option only if you are connecting through
293
+ * a man-in-the-middle or deep packet inspection proxy. Pass in the bytes of the certificate
294
+ * to be used to validate the connection, then override the address to connect to via
295
+ * the server_addr call.
296
+ *
297
+ * Roughly corresponds to the [root_cas parameter in the ngrok docs].
298
+ *
299
+ * [root_cas parameter in the ngrok docs]: https://ngrok.com/docs/ngrok-agent/config#root_cas
300
+ */
301
+ session_ca_cert?: string
277
302
  /**
278
303
  * Configures the opaque, machine-readable metadata string for this session.
279
304
  * Metadata is made available to you in the ngrok dashboard and the Agents API
@@ -285,10 +310,21 @@ export interface Config {
285
310
  * [metdata parameter in the ngrok docs]: https://ngrok.com/docs/ngrok-agent/config#metadata
286
311
  */
287
312
  session_metadata?: string
313
+ /**
314
+ * Configures the network address to dial to connect to the ngrok service.
315
+ * Use this option only if you are connecting to a custom agent ingress.
316
+ *
317
+ * See the [server_addr parameter in the ngrok docs] for additional details.
318
+ *
319
+ * [server_addr parameter in the ngrok docs]: https://ngrok.com/docs/ngrok-agent/config#server_addr
320
+ */
321
+ server_addr?: string
288
322
  /** Unused, use domain instead, will warn and be ignored */
289
323
  subdomain?: string
290
324
  /** Unused, will warn and be ignored */
291
325
  terminate_at?: string
326
+ /** The Traffic Policy to use for this endpoint. */
327
+ trafficPolicy?: string
292
328
  /** Whether to disable certificate verification for this listener */
293
329
  verify_upstream_tls?: boolean
294
330
  /**
@@ -315,7 +351,7 @@ export interface Config {
315
351
  *
316
352
  * See {@link forward} for the full set of options.
317
353
  */
318
- export function connect(config: Config|string|number): Promise<Listener>
354
+ export declare function connect(config: Config|string|number): Promise<Listener>
319
355
  /**
320
356
  * Transform a json object configuration into a listener.
321
357
  * See {@link Config} for the full set of options.
@@ -325,25 +361,25 @@ export function connect(config: Config|string|number): Promise<Listener>
325
361
  * listener = await ngrok.forward({addr: "https://localhost:8443", authtoken_from_env: true});<br>
326
362
  * listener = await ngrok.forward({addr: "unix:///path/to/unix.socket", basic_auth: "ngrok:online1line", authtoken_from_env: true});
327
363
  */
328
- export function forward(config: Config|string|number): Promise<Listener>
364
+ export declare function forward(config: Config|string|number): Promise<Listener>
329
365
  /** Close a listener with the given url, or all listeners if no url is defined. */
330
- export function disconnect(url?: string | undefined | null): Promise<void>
366
+ export declare function disconnect(url?: string | undefined | null): Promise<void>
331
367
  /** Close all listeners. */
332
- export function kill(): Promise<void>
368
+ export declare function kill(): Promise<void>
333
369
  /** Retrieve a list of non-closed listeners, in no particular order. */
334
- export function listeners(): Promise<Array<Listener>>
370
+ export declare function listeners(): Promise<Array<Listener>>
335
371
  /** Retrieve listener using the id */
336
- export function getListener(id: string): Promise<Listener | null>
372
+ export declare function getListener(id: string): Promise<Listener | null>
337
373
  /** Retrieve listener using the url */
338
- export function getListenerByUrl(url: string): Promise<Listener | null>
374
+ export declare function getListenerByUrl(url: string): Promise<Listener | null>
339
375
  /**
340
376
  * Register a callback function that will receive logging event information.
341
377
  * An absent callback will unregister an existing callback function.
342
378
  * The log level defaults to INFO, it can be set to one of ERROR, WARN, INFO, DEBUG, or TRACE.
343
379
  */
344
- export function loggingCallback(callback?: (level: string, target: string, message: string) => void, level?: string): void
380
+ export declare function loggingCallback(callback?: (level: string, target: string, message: string) => void, level?: string): void
345
381
  /** Set the default auth token to use for any future sessions. */
346
- export function authtoken(authtoken: string): Promise<void>
382
+ export declare function authtoken(authtoken: string): Promise<void>
347
383
  /**
348
384
  * An ngrok listener.
349
385
  *
@@ -553,6 +589,7 @@ export class HttpListenerBuilder {
553
589
  */
554
590
  forwardsTo(forwardsTo: string): this
555
591
  policy(policy: string): this
592
+ trafficPolicy(trafficPolicy: string): this
556
593
  }
557
594
  /**
558
595
  *r" An ngrok listener backing a TCP endpoint.
@@ -604,6 +641,7 @@ export class TcpListenerBuilder {
604
641
  */
605
642
  forwardsTo(forwardsTo: string): this
606
643
  policy(policy: string): this
644
+ trafficPolicy(trafficPolicy: string): this
607
645
  /**
608
646
  * The TCP address to request for this edge.
609
647
  * These addresses can be reserved in the [ngrok dashboard] to use across sessions. For example: remote_addr("2.tcp.ngrok.io:21746")
@@ -662,6 +700,7 @@ export class TlsListenerBuilder {
662
700
  */
663
701
  forwardsTo(forwardsTo: string): this
664
702
  policy(policy: string): this
703
+ trafficPolicy(trafficPolicy: string): this
665
704
  /**
666
705
  * The domain to request for this edge, any valid domain or hostname that you have
667
706
  * previously registered with ngrok. If using a custom domain, this requires
@@ -794,6 +833,17 @@ export class SessionBuilder {
794
833
  * [server_addr parameter in the ngrok docs]: https://ngrok.com/docs/ngrok-agent/config#server_addr
795
834
  */
796
835
  serverAddr(addr: string): this
836
+ /**
837
+ * Sets the file path to a default certificate in PEM format to validate ngrok Session TLS connections.
838
+ * Setting to "trusted" is the default, using the ngrok CA certificate.
839
+ * Setting to "host" will verify using the certificates on the host operating system.
840
+ * A client config set via tls_config after calling root_cas will override this value.
841
+ *
842
+ * Corresponds to the [root_cas parameter in the ngrok docs]
843
+ *
844
+ * [root_cas parameter in the ngrok docs]: https://ngrok.com/docs/ngrok-agent/config#root_cas
845
+ */
846
+ rootCas(rootCas: string): this
797
847
  /**
798
848
  * Configures the TLS certificate used to connect to the ngrok service while
799
849
  * establishing the session. Use this option only if you are connecting through
package/index.js CHANGED
@@ -545,6 +545,13 @@ async function ngrokForward(config) {
545
545
  }
546
546
  config = { addr: address };
547
547
  }
548
+ if (typeof config["port"] === "string" || config["port"] instanceof String) {
549
+ const num = parseInt(config["port"], 10);
550
+ if (isNaN(num)) {
551
+ throw new Error(`port must be a number: '${config["port"]}'`);
552
+ }
553
+ config["port"] = num;
554
+ }
548
555
  // Convert addr to string to allow for numeric port numbers
549
556
  const addr = config["addr"];
550
557
  if (Number.isInteger(addr)) config["addr"] = "localhost:" + String(config["addr"]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ngrok/ngrok",
3
- "version": "1.2.0",
3
+ "version": "1.4.0",
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.2.0",
80
- "@ngrok/ngrok-darwin-x64": "1.2.0",
81
- "@ngrok/ngrok-linux-x64-gnu": "1.2.0",
82
- "@ngrok/ngrok-darwin-arm64": "1.2.0",
83
- "@ngrok/ngrok-android-arm64": "1.2.0",
84
- "@ngrok/ngrok-linux-arm64-gnu": "1.2.0",
85
- "@ngrok/ngrok-linux-arm64-musl": "1.2.0",
86
- "@ngrok/ngrok-linux-arm-gnueabihf": "1.2.0",
87
- "@ngrok/ngrok-linux-x64-musl": "1.2.0",
88
- "@ngrok/ngrok-freebsd-x64": "1.2.0",
89
- "@ngrok/ngrok-win32-ia32-msvc": "1.2.0",
90
- "@ngrok/ngrok-android-arm-eabi": "1.2.0",
91
- "@ngrok/ngrok-darwin-universal": "1.2.0"
79
+ "@ngrok/ngrok-win32-x64-msvc": "1.4.0",
80
+ "@ngrok/ngrok-darwin-x64": "1.4.0",
81
+ "@ngrok/ngrok-linux-x64-gnu": "1.4.0",
82
+ "@ngrok/ngrok-darwin-arm64": "1.4.0",
83
+ "@ngrok/ngrok-android-arm64": "1.4.0",
84
+ "@ngrok/ngrok-linux-arm64-gnu": "1.4.0",
85
+ "@ngrok/ngrok-linux-arm64-musl": "1.4.0",
86
+ "@ngrok/ngrok-linux-arm-gnueabihf": "1.4.0",
87
+ "@ngrok/ngrok-linux-x64-musl": "1.4.0",
88
+ "@ngrok/ngrok-freebsd-x64": "1.4.0",
89
+ "@ngrok/ngrok-win32-ia32-msvc": "1.4.0",
90
+ "@ngrok/ngrok-android-arm-eabi": "1.4.0",
91
+ "@ngrok/ngrok-darwin-universal": "1.4.0"
92
92
  }
93
93
  }