@ngrok/ngrok 0.9.0 → 1.0.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 (146) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/CONTRIBUTING.md +4 -4
  3. package/README.md +176 -142
  4. package/index.d.ts +75 -15
  5. package/index.js +8 -6
  6. package/package.json +37 -16
  7. package/.envrc +0 -1
  8. package/.gitattributes +0 -3
  9. package/.prettierrc.json +0 -3
  10. package/.yarnrc.yml +0 -3
  11. package/Cargo.toml +0 -34
  12. package/RELEASE.md +0 -26
  13. package/build.rs +0 -5
  14. package/docs/.nojekyll +0 -1
  15. package/docs/assets/highlight.css +0 -92
  16. package/docs/assets/main.js +0 -58
  17. package/docs/assets/search.js +0 -1
  18. package/docs/assets/style.css +0 -1367
  19. package/docs/classes/HttpListenerBuilder.html +0 -594
  20. package/docs/classes/LabeledListenerBuilder.html +0 -206
  21. package/docs/classes/Listener.html +0 -241
  22. package/docs/classes/Session.html +0 -207
  23. package/docs/classes/SessionBuilder.html +0 -465
  24. package/docs/classes/TcpListenerBuilder.html +0 -281
  25. package/docs/classes/TlsListenerBuilder.html +0 -322
  26. package/docs/classes/UpdateRequest.html +0 -131
  27. package/docs/functions/authtoken.html +0 -89
  28. package/docs/functions/connect.html +0 -89
  29. package/docs/functions/consoleLog.html +0 -90
  30. package/docs/functions/disconnect.html +0 -89
  31. package/docs/functions/getListener.html +0 -89
  32. package/docs/functions/getListenerByUrl.html +0 -89
  33. package/docs/functions/kill.html +0 -84
  34. package/docs/functions/listen.html +0 -92
  35. package/docs/functions/listenable.html +0 -85
  36. package/docs/functions/listeners.html +0 -84
  37. package/docs/functions/loggingCallback.html +0 -108
  38. package/docs/index.html +0 -292
  39. package/docs/interfaces/Config.html +0 -734
  40. package/docs/modules.html +0 -106
  41. package/examples/domain.crt +0 -18
  42. package/examples/domain.key +0 -27
  43. package/examples/express/ngrok-express-quickstart.js +0 -11
  44. package/examples/express/ngrok-express.js +0 -28
  45. package/examples/express/package.json +0 -7
  46. package/examples/fastify/ngrok-fastify.js +0 -26
  47. package/examples/fastify/package.json +0 -7
  48. package/examples/hapi/ngrok-hapi.js +0 -35
  49. package/examples/hapi/package.json +0 -7
  50. package/examples/koa/ngrok-koa.js +0 -12
  51. package/examples/koa/package.json +0 -7
  52. package/examples/nestjs/.eslintrc.js +0 -25
  53. package/examples/nestjs/.prettierrc +0 -4
  54. package/examples/nestjs/README.md +0 -73
  55. package/examples/nestjs/nest-cli.json +0 -8
  56. package/examples/nestjs/package.json +0 -70
  57. package/examples/nestjs/src/app.controller.spec.ts +0 -22
  58. package/examples/nestjs/src/app.controller.ts +0 -12
  59. package/examples/nestjs/src/app.module.ts +0 -10
  60. package/examples/nestjs/src/app.service.ts +0 -8
  61. package/examples/nestjs/src/main.ts +0 -17
  62. package/examples/nestjs/test/app.e2e-spec.ts +0 -24
  63. package/examples/nestjs/test/jest-e2e.json +0 -9
  64. package/examples/nestjs/tsconfig.build.json +0 -4
  65. package/examples/nestjs/tsconfig.json +0 -21
  66. package/examples/nextjs/README.md +0 -3
  67. package/examples/nextjs/next.config.js +0 -12
  68. package/examples/nextjs/ngrok.config.js +0 -23
  69. package/examples/nextjs/package.json +0 -6
  70. package/examples/nextjs/pages/index.js +0 -5
  71. package/examples/ngrok-connect-full.js +0 -67
  72. package/examples/ngrok-connect-minimal.js +0 -17
  73. package/examples/ngrok-http-full.js +0 -81
  74. package/examples/ngrok-http-minimum.js +0 -18
  75. package/examples/ngrok-labeled.js +0 -43
  76. package/examples/ngrok-listen.js +0 -11
  77. package/examples/ngrok-tcp.js +0 -37
  78. package/examples/ngrok-tls.js +0 -40
  79. package/examples/ngrok-typescript.ts +0 -69
  80. package/examples/ngrok-windows-pipe.js +0 -25
  81. package/examples/ngrok-winston.js +0 -24
  82. package/examples/package.json +0 -15
  83. package/examples/remix/.eslintrc.js +0 -4
  84. package/examples/remix/README.md +0 -53
  85. package/examples/remix/app/entry.client.tsx +0 -18
  86. package/examples/remix/app/entry.server.tsx +0 -101
  87. package/examples/remix/app/root.tsx +0 -20
  88. package/examples/remix/app/routes/_index.tsx +0 -30
  89. package/examples/remix/ngrok.config.js +0 -16
  90. package/examples/remix/package.json +0 -30
  91. package/examples/remix/public/favicon.ico +0 -0
  92. package/examples/remix/remix.config.js +0 -16
  93. package/examples/remix/remix.env.d.ts +0 -2
  94. package/examples/remix/tsconfig.json +0 -22
  95. package/examples/svelte/README.md +0 -38
  96. package/examples/svelte/jsconfig.json +0 -17
  97. package/examples/svelte/ngrok.config.cjs +0 -20
  98. package/examples/svelte/package.json +0 -22
  99. package/examples/svelte/src/app.d.ts +0 -12
  100. package/examples/svelte/src/app.html +0 -12
  101. package/examples/svelte/src/routes/+page.svelte +0 -2
  102. package/examples/svelte/static/favicon.png +0 -0
  103. package/examples/svelte/svelte.config.js +0 -14
  104. package/examples/svelte/vite.config.js +0 -6
  105. package/examples/vue/.vscode/extensions.json +0 -3
  106. package/examples/vue/README.md +0 -40
  107. package/examples/vue/env.d.ts +0 -1
  108. package/examples/vue/index.html +0 -13
  109. package/examples/vue/ngrok.config.ts +0 -18
  110. package/examples/vue/package.json +0 -25
  111. package/examples/vue/public/favicon.ico +0 -0
  112. package/examples/vue/src/App.vue +0 -47
  113. package/examples/vue/src/assets/base.css +0 -74
  114. package/examples/vue/src/assets/logo.svg +0 -1
  115. package/examples/vue/src/assets/main.css +0 -35
  116. package/examples/vue/src/components/HelloWorld.vue +0 -40
  117. package/examples/vue/src/components/TheWelcome.vue +0 -86
  118. package/examples/vue/src/components/WelcomeItem.vue +0 -86
  119. package/examples/vue/src/components/icons/IconCommunity.vue +0 -7
  120. package/examples/vue/src/components/icons/IconDocumentation.vue +0 -7
  121. package/examples/vue/src/components/icons/IconEcosystem.vue +0 -7
  122. package/examples/vue/src/components/icons/IconSupport.vue +0 -7
  123. package/examples/vue/src/components/icons/IconTooling.vue +0 -19
  124. package/examples/vue/src/main.ts +0 -6
  125. package/examples/vue/tsconfig.json +0 -16
  126. package/examples/vue/tsconfig.node.json +0 -8
  127. package/examples/vue/vite.config.ts +0 -15
  128. package/flake.lock +0 -82
  129. package/flake.nix +0 -111
  130. package/post-build.js +0 -45
  131. package/scripts/gc-node-drop.js +0 -49
  132. package/scripts/gc-rust-drop.js +0 -53
  133. package/src/config.rs +0 -285
  134. package/src/connect.rs +0 -342
  135. package/src/http.rs +0 -244
  136. package/src/lib.rs +0 -39
  137. package/src/listener.rs +0 -495
  138. package/src/listener_builder.rs +0 -204
  139. package/src/logging.rs +0 -140
  140. package/src/session.rs +0 -551
  141. package/src/tcp.rs +0 -18
  142. package/src/tls.rs +0 -44
  143. package/trailer.d.ts +0 -15
  144. package/trailer.js +0 -382
  145. package/tsconfig.json +0 -8
  146. package/typedoc.json +0 -3
package/CHANGELOG.md CHANGED
@@ -1,3 +1,13 @@
1
+ ## 1.0.0:
2
+
3
+ - Add policy support to Listener builders and `ngrok.forward`
4
+
5
+ ## 0.9.1:
6
+
7
+ - Move to `ngrok.forward` from `ngrok.connect`, keeping an alias.
8
+ - Rename to `ngrok-javascript`.
9
+ - Smaller number of files packaged.
10
+
1
11
  ## 0.9.0:
2
12
 
3
13
  - `ngrok.connect` now returns the full `Listener` object.
package/CONTRIBUTING.md CHANGED
@@ -1,13 +1,13 @@
1
- # Contributing to ngrok-nodejs
1
+ # Contributing to ngrok-javascript
2
2
 
3
- Thank you for deciding to contribute to ngrok-nodejs!
3
+ Thank you for deciding to contribute to ngrok-javascript!
4
4
 
5
5
  ## Reporting a bug
6
6
 
7
- To report a bug, please [open a new issue](https://github.com/ngrok/ngrok-nodejs/issues/new) with clear reproduction steps. We will triage and investigate these issues at a regular interval.
7
+ To report a bug, please [open a new issue](https://github.com/ngrok/ngrok-javascript/issues/new) with clear reproduction steps. We will triage and investigate these issues at a regular interval.
8
8
 
9
9
  ## Contributing code
10
10
 
11
11
  Bugfixes and small improvements are always appreciated!
12
12
 
13
- For any larger changes or features, please [open a new issue](https://github.com/ngrok/ngrok-nodejs/issues/new) first to discuss whether the change makes sense. When in doubt, it's always okay to open an issue first.
13
+ For any larger changes or features, please [open a new issue](https://github.com/ngrok/ngrok-javascript/issues/new) first to discuss whether the change makes sense. When in doubt, it's always okay to open an issue first.
package/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # The ngrok Agent SDK for NodeJS
1
+ # Javascript SDK for ngrok
2
2
 
3
3
  [![npm.rs][npm-badge]][npm-url]
4
4
  [![MIT licensed][mit-badge]][mit-url]
@@ -11,119 +11,136 @@
11
11
  [mit-url]: https://github.com/ngrok/ngrok-rust/blob/main/LICENSE-MIT
12
12
  [apache-badge]: https://img.shields.io/badge/license-Apache_2.0-blue.svg
13
13
  [apache-url]: https://github.com/ngrok/ngrok-rust/blob/main/LICENSE-APACHE
14
- [ci-badge]: https://github.com/ngrok/ngrok-nodejs/actions/workflows/ci.yml/badge.svg
15
- [ci-url]: https://github.com/ngrok/ngrok-nodejs/actions/workflows/ci.yml
14
+ [ci-badge]: https://github.com/ngrok/ngrok-javascript/actions/workflows/ci.yml/badge.svg
15
+ [ci-url]: https://github.com/ngrok/ngrok-javascript/actions/workflows/ci.yml
16
16
 
17
- **Note: This is beta-quality software. Interfaces may change without warning.**
17
+ `ngrok-javascript` is the official Node.js SDK for ngrok that requires no binaries. Quickly enable secure production-ready connectivity to your applications and services directly from your code.
18
18
 
19
- [ngrok](https://ngrok.com) is a globally distributed reverse proxy commonly used for quickly getting a public URL to a
20
- service running inside a private network, such as on your local laptop. The ngrok agent is usually
21
- deployed inside a private network and is used to communicate with the ngrok cloud service.
19
+ [ngrok](https://ngrok.com) is a globally distributed gateway that provides secure connectivity for applications and services running in any environment.
22
20
 
23
- This is the ngrok agent in library form, suitable for integrating directly into NodeJS
24
- applications. This allows you to quickly build ngrok into your application with no separate process
25
- to manage.
21
+ # Installation
26
22
 
27
- # Documentation
23
+ Using npm:
28
24
 
29
- A quickstart guide and a full API reference are included in the [ngrok-nodejs API documentation](https://ngrok.github.io/ngrok-nodejs/).
25
+ ```shell
26
+ npm install @ngrok/ngrok
27
+ ```
30
28
 
31
- # Quickstart
29
+ Using yarn:
30
+
31
+ ```shell
32
+ yarn add @ngrok/ngrok
33
+ ```
32
34
 
33
- 1. Install the `ngrok-nodejs` package from
34
- [npm](https://www.npmjs.com/package/@ngrok/ngrok):
35
+ Using pnpm:
35
36
 
36
37
  ```shell
37
- npm install @ngrok/ngrok
38
+ pnpm add @ngrok/ngrok
38
39
  ```
39
40
 
40
- 2. After you've installed the package, you'll need an authtoken. Retrieve one on the
41
- [authtoken page of your ngrok dashboard](https://dashboard.ngrok.com/get-started/your-authtoken)
41
+ # Quickstart
42
42
 
43
- 3. Add the following code block using the [connect method](https://github.com/ngrok/ngrok-nodejs/blob/main/examples/ngrok-connect-minimal.js) to expose your nodejs application at port `8080` on `localhost`:
43
+ 1. [Install `@ngrok/ngrok`](#installation)
44
+ 2. Export your [authtoken from the ngrok dashboard](https://dashboard.ngrok.com/get-started/your-authtoken) as `NGROK_AUTHTOKEN` in your terminal
45
+ 3. Add the following code to your application to establish connectivity via the [forward method](https://github.com/ngrok/ngrok-javascript/blob/main/examples/ngrok-forward-minimal.js) through port `8080` over `localhost`:
46
+
47
+ ```jsx
48
+ // Require ngrok javascript sdk
49
+ const ngrok = require("@ngrok/ngrok");
50
+ // import ngrok from '@ngrok/ngrok' // if inside a module
51
+
52
+ (async function() {
53
+ // Establish connectivity
54
+ const listener = await ngrok.forward({ addr: 8080, authtoken_from_env: true });
55
+
56
+ // Output ngrok url to console
57
+ console.log(`Ingress established at: ${listener.url()}`);
58
+ })();
59
+ ```
60
+
61
+ That's it! Your application should now be available through the url output in your terminal.
62
+
63
+ > **Note**
64
+ > You can find more examples in [the examples directory](https://github.com/ngrok/ngrok-javascript/tree/main/examples).
44
65
 
45
- ```jsx
46
- const ngrok = require("@ngrok/ngrok");
47
- (async function() {
48
- const listener = await ngrok.connect({ addr: 8080, authtoken_from_env: true });
49
- console.log(`Ingress established at: ${listener.url()}`);
50
- })();
51
- ```
66
+ # Documentation
52
67
 
53
- You can find more examples in [the /examples directory](https://github.com/ngrok/ngrok-nodejs/tree/main/examples).
68
+ A quickstart guide and a full API reference are included in the [ngrok-javascript documentation](https://ngrok.github.io/ngrok-javascript/).
54
69
 
55
- ## Authorization
70
+ ### Authorization
56
71
 
57
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.
58
73
 
59
- You can set it in the `NGROK_AUTHTOKEN` environment variable and pass `authtoken_from_env: true` to the [connect](https://ngrok.github.io/ngrok-nodejs/functions/connect.html) method:
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:
60
75
 
61
76
  ```jsx
62
- await ngrok.connect({authtoken_from_env: true, ...});
77
+ await ngrok.forward({ authtoken_from_env: true, ... });
63
78
  ```
64
79
 
65
- Or pass the authtoken directly to the [connect](https://ngrok.github.io/ngrok-nodejs/functions/connect.html) method:
80
+ Or pass the authtoken directly to the [forward](https://ngrok.github.io/ngrok-javascript/functions/forward.html) method:
66
81
 
67
82
  ```jsx
68
- await ngrok.connect({authtoken: token, ...});
83
+ await ngrok.forward({ authtoken: token, ... });
69
84
  ```
70
85
 
71
- Or set it for all connections with the [authtoken](https://ngrok.github.io/ngrok-nodejs/functions/authtoken.html) method:
86
+ Or set it for all connections with the [authtoken](https://ngrok.github.io/ngrok-javascript/functions/authtoken.html) method:
72
87
 
73
88
  ```jsx
74
89
  await ngrok.authtoken(token);
75
90
  ```
76
91
 
77
- ## Connection
92
+ ### Connection
78
93
 
79
- The [connect](https://ngrok.github.io/ngrok-nodejs/functions/connect.html) method is the easiest way to start an ngrok session and establish a listener to a specified address. The [connect](https://ngrok.github.io/ngrok-nodejs/functions/connect.html) method returns a promise that resolves to the public URL of the listener.
94
+ The [forward](https://ngrok.github.io/ngrok-javascript/functions/forward.html) method is the easiest way to start an ngrok session and establish a listener to a specified address. The [forward](https://ngrok.github.io/ngrok-javascript/functions/forward.html) method returns a promise that resolves to the public URL of the listener.
80
95
 
81
- With no arguments the [connect](https://ngrok.github.io/ngrok-nodejs/functions/connect.html) method will start an HTTP listener to `localhost` port `80`:
96
+ With no arguments the [forward](https://ngrok.github.io/ngrok-javascript/functions/forward.html) method will start an HTTP listener to `localhost` port `80`:
82
97
 
83
98
  ```jsx
84
99
  const ngrok = require("@ngrok/ngrok");
100
+ // import ngrok from '@ngrok/ngrok' // if inside a module
101
+
85
102
  (async function() {
86
- console.log( (await ngrok.connect()).url() );
103
+ console.log( (await ngrok.forward()).url() );
87
104
  })();
88
105
  ```
89
106
 
90
107
  You can pass the port number to forward on `localhost`:
91
108
 
92
109
  ```jsx
93
- const listener = await ngrok.connect(4242);
110
+ const listener = await ngrok.forward(4242);
94
111
  ```
95
112
 
96
113
  Or you can specify the host and port via a string:
97
114
 
98
115
  ```jsx
99
- const listener = await ngrok.connect("localhost:4242");
116
+ const listener = await ngrok.forward("localhost:4242");
100
117
  ```
101
118
 
102
- More options can be passed to the `connect` method to customize the connection:
119
+ More options can be passed to the `forward` method to customize the connection:
103
120
 
104
121
  ```jsx
105
- const listener = await ngrok.connect({addr: 8080, basic_auth: "ngrok:online1line"});
106
- const listener = await ngrok.connect({addr: 8080, oauth_provider: "google", oauth_allow_domains: "example.com"});
122
+ const listener = await ngrok.forward({ addr: 8080, basic_auth: "ngrok:online1line" });
123
+ const listener = await ngrok.forward({ addr: 8080, oauth_provider: "google", oauth_allow_domains: "example.com" });
107
124
  ```
108
125
 
109
126
  The (optional) `proto` parameter is the listener type, which defaults to `http`. To create a TCP listener:
110
127
 
111
128
  ```jsx
112
- const listener = await ngrok.connect({proto: 'tcp', addr: 25565});
129
+ const listener = await ngrok.forward({ proto: 'tcp', addr: 25565 });
113
130
  ```
114
131
 
115
132
  See [Full Configuration](#full-configuration) for the list of possible configuration options.
116
133
 
117
- ## Disconnection
134
+ ### Disconnection
118
135
 
119
- The [close](https://ngrok.github.io/ngrok-nodejs/classes/Listener.html#close) method on a listener will shut it down, and also stop the ngrok session if it is no longer needed. This method returns a promise that resolves when the listener is closed.
136
+ The [close](https://ngrok.github.io/ngrok-javascript/classes/Listener.html#close) method on a listener will shut it down, and also stop the ngrok session if it is no longer needed. This method returns a promise that resolves when the listener is closed.
120
137
 
121
138
  ```jsx
122
139
  const listener = await ngrok.getListenerByUrl(url);
123
140
  await listener.close();
124
141
  ```
125
142
 
126
- Or use the [disconnect](https://ngrok.github.io/ngrok-nodejs/functions/disconnect.html) method with the `url()` of the listener to close (or id() for a Labeled Listener):
143
+ Or use the [disconnect](https://ngrok.github.io/ngrok-javascript/functions/disconnect.html) method with the `url()` of the listener to close (or id() for a Labeled Listener):
127
144
 
128
145
  ```jsx
129
146
  await ngrok.disconnect(listener.url());
@@ -135,20 +152,69 @@ Or omit the `url()` to close all listeners:
135
152
  await ngrok.disconnect();
136
153
  ```
137
154
 
138
- ## Listing Listeners
155
+ ### Listing Listeners
139
156
 
140
- To list all current non-closed listeners use the [listeners](https://ngrok.github.io/ngrok-nodejs/functions/listeners.html) method:
157
+ To list all current non-closed listeners use the [listeners](https://ngrok.github.io/ngrok-javascript/functions/listeners.html) method:
141
158
 
142
159
  ```jsx
143
160
  const listeners = await ngrok.listeners();
144
161
  ```
145
162
 
146
- # Full Configuration
163
+ ### Builders
164
+
165
+ For more control over Sessions and Listeners, the builder classes can be used.
166
+
167
+ A minimal example using the builder class looks like [the following](https://github.com/ngrok/ngrok-javascript/blob/main/examples/ngrok-http-minimum.js):
168
+
169
+ ```jsx
170
+ async function create_listener() {
171
+ const session = await new ngrok.NgrokSessionBuilder().authtokenFromEnv().connect();
172
+ const listener = await session.httpEndpoint().listen();
173
+ console.log("Ingress established at:", listener.url());
174
+ listener.forward("localhost:8081");
175
+ }
176
+ ```
177
+
178
+ See here for a [Full Configuration Example](https://github.com/ngrok/ngrok-javascript/blob/main/examples/ngrok-http-full.js)
179
+
180
+ ### TLS Backends
181
+
182
+ As of version `0.7.0` there is backend TLS connection support, validated by a filepath specified in the `SSL_CERT_FILE` environment variable, or falling back to the host OS installed trusted certificate authorities. So it is now possible to do this to forward:
183
+
184
+ ```jsx
185
+ await ngrok.forward({ addr: "https://127.0.0.1:3000", authtoken_from_env: true });
186
+ ```
187
+
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`.
189
+
190
+ ### Async Programming
191
+
192
+ All methods return a `Promise` and are suitable for use in asynchronous
193
+ programming. You can use callback chaining with `.then()` and `.catch()` syntax
194
+ or the `await` keyword to wait for completion of an API call.
195
+
196
+ #### Error Handling
197
+
198
+ All asynchronous functions will throw an error on failure to set up a session or listener,
199
+ which can be caught and dealt with using try/catch or then/catch statements:
200
+
201
+ ```jsx
202
+ new ngrok.NgrokSessionBuilder().authtokenFromEnv().connect()
203
+ .then((session) => {
204
+ session.httpEndpoint().listen()
205
+ .then((tun) => {})
206
+ .catch(err => console.log('listener setup error: ' + err))
207
+ })
208
+ .catch(err => console.log('session setup error: ' + err))
209
+ .await;
210
+ ```
211
+
212
+ ### Full Configuration
147
213
 
148
- This example shows [all the possible configuration items of ngrok.connect](https://github.com/ngrok/ngrok-nodejs/blob/main/examples/ngrok-connect-full.js):
214
+ This example shows [all the possible configuration items of ngrok.forward](https://github.com/ngrok/ngrok-javascript/blob/main/examples/ngrok-forward-full.js):
149
215
 
150
216
  ```jsx
151
- const listener = await ngrok.connect({
217
+ const listener = await ngrok.forward({
152
218
  // session configuration
153
219
  addr: `localhost:8080`, // or `8080` or `unix:${UNIX_SOCKET}`
154
220
  authtoken: "<authtoken>",
@@ -158,15 +224,22 @@ const listener = await ngrok.connect({
158
224
  },
159
225
  session_metadata: "Online in One Line",
160
226
  // listener configuration
161
- allow_user_agent: "^mozilla.*",
227
+ metadata: "example listener metadata from javascript",
228
+ domain: "<domain>",
229
+ proto: "http",
230
+ proxy_proto: "", // One of: "", "1", "2"
231
+ schemes: ["HTTPS"],
232
+ labels: "edge:edghts_2G...", // Along with proto="labeled"
233
+ // module configuration
162
234
  basic_auth: ["ngrok:online1line"],
163
235
  circuit_breaker: 0.1,
164
236
  compression: true,
237
+ allow_user_agent: "^mozilla.*",
165
238
  deny_user_agent: "^curl.*",
166
- domain: "<domain>",
167
239
  ip_restriction_allow_cidrs: ["0.0.0.0/0"],
168
240
  ip_restriction_deny_cidrs: ["10.1.1.1/32"],
169
- metadata: "example listener metadata from nodejs",
241
+ crt: fs.readFileSync("crt.pem", "utf8"),
242
+ key: fs.readFileSync("key.pem", "utf8"),
170
243
  mutual_tls_cas: [fs.readFileSync('ca.crt', 'utf8')],
171
244
  oauth_provider: "google",
172
245
  oauth_allow_domains: ["<domain>"],
@@ -180,103 +253,56 @@ const listener = await ngrok.connect({
180
253
  oidc_allow_domains: ["<domain>"],
181
254
  oidc_allow_emails: ["<email>"],
182
255
  oidc_scopes: ["<scope>"],
183
- proxy_proto: "", // One of: "", "1", "2"
256
+ policy: "<policy_json>",
184
257
  request_header_remove: ["X-Req-Nope"],
185
258
  response_header_remove: ["X-Res-Nope"],
186
259
  request_header_add: ["X-Req-Yup:true"],
187
260
  response_header_add: ["X-Res-Yup:true"],
188
- schemes: ["HTTPS"],
189
261
  verify_webhook_provider: "twilio",
190
262
  verify_webhook_secret: "asdf",
191
263
  websocket_tcp_converter: true,
192
264
  });
193
265
  ```
194
266
 
195
- The [Config](https://ngrok.github.io/ngrok-nodejs/interfaces/Config.html) interface also shows all the available options.
267
+ The [Config](https://ngrok.github.io/ngrok-javascript/interfaces/Config.html) interface also shows all the available options.
196
268
 
197
269
  # Examples
198
270
 
199
271
  Degit can be used for cloning and running an example directory like this:
200
272
  ```bash
201
- npx degit github:ngrok/ngrok-nodejs/examples/<example> <folder-name>
273
+ npx degit github:ngrok/ngrok-javascript/examples/<example> <folder-name>
202
274
  cd <folder-name>
203
275
  npm i
204
276
  ```
205
277
  For example:
206
278
  ```bash
207
- npx degit github:ngrok/ngrok-nodejs/examples/express express && cd express && npm i
208
- ```
209
-
210
- ## Frameworks
211
- * [AWS App Runner](https://aws.amazon.com/apprunner/) - See the [ngrok SDK Serverless Example](https://github.com/ngrok/ngrok-sdk-serverless-example) repository
212
- * [Express](https://expressjs.com/) - [Quickstart Example](https://github.com/ngrok/ngrok-nodejs/blob/main/examples/express/ngrok-express-quickstart.js), [Configuration Example](https://github.com/ngrok/ngrok-nodejs/blob/main/examples/express/ngrok-express.js)
213
- * [Fastify](https://www.fastify.io/) - [Example](https://github.com/ngrok/ngrok-nodejs/blob/main/examples/fastify/ngrok-fastify.js)
214
- * [Hapi](https://hapi.dev/) - [Example](https://github.com/ngrok/ngrok-nodejs/blob/main/examples/hapi/ngrok-hapi.js)
215
- * [Koa](https://koajs.com/) - [Example](https://github.com/ngrok/ngrok-nodejs/blob/main/examples/koa/ngrok-koa.js)
216
- * [Nest.js](https://nestjs.com/) - [Example main.ts](https://github.com/ngrok/ngrok-nodejs/blob/main/examples/nestjs/src/main.ts)
217
- * [Next.js](https://nextjs.org/) - [Example next.config.js](https://github.com/ngrok/ngrok-nodejs/blob/main/examples/nextjs/next.config.js) loading [ngrok.config.js](https://github.com/ngrok/ngrok-nodejs/blob/main/examples/nextjs/ngrok.config.js)
218
- * [Remix](https://remix.run/) - [Example remix.config.js](https://github.com/ngrok/ngrok-nodejs/blob/main/examples/remix/remix.config.js) loading [ngrok.config.js](https://github.com/ngrok/ngrok-nodejs/blob/main/examples/remix/ngrok.config.js)
219
- * [Svelte](https://svelte.dev/) - [Example svelte.config.js](https://github.com/ngrok/ngrok-nodejs/blob/main/examples/svelte/svelte.config.js) (works in vite.config.js too) loading [ngrok.config.cjs](https://github.com/ngrok/ngrok-nodejs/blob/main/examples/svelte/ngrok.config.cjs)
220
- * [Typescript](https://www.typescriptlang.org/) - [Example ts-node](https://github.com/ngrok/ngrok-nodejs/blob/main/examples/ngrok-typescript.ts)
221
- * [Vue](https://vuejs.org/) - [Example vite.config.ts](https://github.com/ngrok/ngrok-nodejs/blob/main/examples/vue/vite.config.ts) loading [ngrok.config.ts](https://github.com/ngrok/ngrok-nodejs/blob/main/examples/vue/ngrok.config.ts)
222
- * [Winston](https://github.com/winstonjs/winston#readme) Logging - [Example](https://github.com/ngrok/ngrok-nodejs/blob/main/examples/ngrok-winston.js)
223
-
224
- ## Listener Types
225
- * ngrok.connect - [ngrok.connect Minimal Example](https://github.com/ngrok/ngrok-nodejs/blob/main/examples/ngrok-connect-minimal.js), [Full ngrok.connect Example](https://github.com/ngrok/ngrok-nodejs/blob/main/examples/ngrok-connect-full.js)
226
- * HTTP - [ngrok.listen Example](https://github.com/ngrok/ngrok-nodejs/blob/main/examples/ngrok-listen.js), [Minimal Example](https://github.com/ngrok/ngrok-nodejs/blob/main/examples/ngrok-http-minimum.js), [Full Configuration Example](https://github.com/ngrok/ngrok-nodejs/blob/main/examples/ngrok-http-full.js)
227
- * Labeled - [Example](https://github.com/ngrok/ngrok-nodejs/blob/main/examples/ngrok-labeled.js)
228
- * TCP - [Example](https://github.com/ngrok/ngrok-nodejs/blob/main/examples/ngrok-tcp.js)
229
- * TLS - [Example](https://github.com/ngrok/ngrok-nodejs/blob/main/examples/ngrok-tls.js)
230
- * Windows Pipe - [Example](https://github.com/ngrok/ngrok-nodejs/blob/main/examples/ngrok-windows-pipe.js)
231
-
232
- # Builders
233
-
234
- For more control over Sessions and Listeners, the builder classes can be used.
235
-
236
- A minimal example using the builder class looks like [the following](https://github.com/ngrok/ngrok-nodejs/blob/main/examples/ngrok-http-minimum.js):
237
-
238
- ```jsx
239
- async function create_listener() {
240
- const session = await new ngrok.NgrokSessionBuilder().authtokenFromEnv().connect();
241
- const listener = await session.httpEndpoint().listen();
242
- console.log("Ingress established at:", listener.url());
243
- listener.forward("localhost:8081");
244
- }
245
- ```
246
-
247
- See here for a [Full Configuration Example](https://github.com/ngrok/ngrok-nodejs/blob/main/examples/ngrok-http-full.js)
248
-
249
- ## TLS Backends
250
-
251
- As of version `0.7.0` there is backend TLS connection support, validated by a filepath specified in the `SSL_CERT_FILE` environment variable, or falling back to the host OS installed trusted certificate authorities. So it is now possible to do this to connect:
252
-
253
- ```jsx
254
- await ngrok.connect({ addr: "https://127.0.0.1:3000", authtoken_from_env: true });
279
+ npx degit github:ngrok/ngrok-javascript/examples/express express && cd express && npm i
255
280
  ```
256
281
 
257
- 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`.
258
-
259
- # Async Programming
260
-
261
- All methods return a `Promise` and are suitable for use in asynchronous
262
- programming. You can use callback chaining with `.then()` and `.catch()` syntax
263
- or the `await` keyword to wait for completion of an API call.
264
-
265
- ### Error Handling
266
-
267
- The asynchronous functions will throw an error on failure to set up a session or listener,
268
- which can be caught and dealt with using standard then/catch semantics.
269
-
270
- ```jsx
271
- new ngrok.NgrokSessionBuilder().authtokenFromEnv().connect()
272
- .then((session) => {
273
- session.httpEndpoint().listen()
274
- .then((tun) => {})
275
- .catch(err => console.log('listener setup error: ' + err))
276
- })
277
- .catch(err => console.log('session setup error: ' + err))
278
- .await;
279
- ```
282
+ #### Frameworks
283
+ - [AWS App Runner](https://github.com/ngrok/ngrok-sdk-serverless-example)
284
+ - [Express](https://github.com/ngrok/ngrok-javascript/blob/main/examples/express)
285
+ - [Fastify Example](https://github.com/ngrok/ngrok-javascript/blob/main/examples/fastify)
286
+ - [Hapi Example](https://github.com/ngrok/ngrok-javascript/blob/main/examples/hapi)
287
+ - [Koa Example](https://github.com/ngrok/ngrok-javascript/blob/main/examples/koa)
288
+ - [Nest.js](https://github.com/ngrok/ngrok-javascript/blob/main/examples/nestjs)
289
+ - [Next.js](https://github.com/ngrok/ngrok-javascript/blob/main/examples/nextjs)
290
+ - [Remix](https://github.com/ngrok/ngrok-javascript/blob/main/examples/remix)
291
+ - [Svelte](https://github.com/ngrok/ngrok-javascript/blob/main/examples/svelte)
292
+ - [Typescript](https://github.com/ngrok/ngrok-javascript/blob/main/examples/ngrok-typescript.ts)
293
+ - [Vue](https://github.com/ngrok/ngrok-javascript/blob/main/examples/vue)
294
+ - [Winston (Logging)](https://github.com/ngrok/ngrok-javascript/blob/main/examples/ngrok-winston.js)
295
+
296
+ #### Listeners
297
+ * [ngrok.forward (minimal)](https://github.com/ngrok/ngrok-javascript/blob/main/examples/ngrok-forward-minimal.js)
298
+ * [ngrok.forward (full)](https://github.com/ngrok/ngrok-javascript/blob/main/examples/ngrok-forward-full.js)
299
+ * [HTTP (ngrok.listener)](https://github.com/ngrok/ngrok-javascript/blob/main/examples/ngrok-listen.js)
300
+ * [HTTP (SessionBuilder minimal)](https://github.com/ngrok/ngrok-javascript/blob/main/examples/ngrok-http-minimum.js)
301
+ * [HTTP (SessionBuilder full)](https://github.com/ngrok/ngrok-javascript/blob/main/examples/ngrok-http-full.js)
302
+ * [Labeled](https://github.com/ngrok/ngrok-javascript/blob/main/examples/ngrok-labeled.js)
303
+ * [TCP](https://github.com/ngrok/ngrok-javascript/blob/main/examples/ngrok-tcp.js)
304
+ * [TLS](https://github.com/ngrok/ngrok-javascript/blob/main/examples/ngrok-tls.js)
305
+ * [Windows Pipe](https://github.com/ngrok/ngrok-javascript/blob/main/examples/ngrok-windows-pipe.js)
280
306
 
281
307
  # Platform Support
282
308
 
@@ -291,27 +317,35 @@ Pre-built binaries are provided on NPM for the following platforms:
291
317
  | FreeBSD | | ✓ | | |
292
318
  | Android | | | ✓ | ✓ |
293
319
 
294
- ngrok-nodejs, 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.
295
-
296
- * Windows-aarch64 will be supported after the next release of [Ring](https://github.com/briansmith/ring/issues/1167).
320
+ > **Note**
321
+ > `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.
322
+ > * `Windows-aarch64` will be supported after the next release of [Ring](https://github.com/briansmith/ring/issues/1167).
297
323
 
298
324
  # Dependencies
299
325
 
300
- This project relies on [NAPI-RS](https://napi.rs/), an excellent system to ease development and building of Rust plugins for NodeJS.
326
+ - [NAPI-RS](https://napi.rs/), an excellent system to ease development and building of Rust plugins for NodeJS.
301
327
 
302
- # License
328
+ # Changelog
329
+
330
+ Changes to `ngrok-javascript` are tracked under [CHANGELOG.md](https://github.com/ngrok/ngrok-javascript/blob/main/CHANGELOG.md).
303
331
 
304
- This project is licensed under either of
305
332
 
306
- * Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or
307
- http://www.apache.org/licenses/LICENSE-2.0)
308
- * MIT license ([LICENSE-MIT](LICENSE-MIT) or
309
- http://opensource.org/licenses/MIT)
333
+ # Join the ngrok Community
334
+
335
+ - Check out [our official docs](https://docs.ngrok.com)
336
+ - Read about updates on [our blog](https://blog.ngrok.com)
337
+ - Open an [issue](https://github.com/ngrok/ngrok-javascript/issues) or [pull request](https://github.com/ngrok/ngrok-javascript/pulls)
338
+ - Join our [Slack community](https://ngrok.com/slack)
339
+ - Follow us on [X / Twitter (@ngrokHQ)](https://twitter.com/ngrokhq)
340
+ - Subscribe to our [Youtube channel (@ngrokHQ)](https://www.youtube.com/@ngrokhq)
341
+
342
+ # License
310
343
 
311
- at your option.
344
+ This work is dual-licensed under [Apache, Version 2.0](LICENSE-APACHE) and [MIT](LICENSE-MIT).
345
+ You can choose between one of them if you use this work.
312
346
 
313
- ### Contribution
347
+ ### Contributions
314
348
 
315
349
  Unless you explicitly state otherwise, any contribution intentionally submitted
316
- for inclusion in ngrok-nodejs by you, as defined in the Apache-2.0 license, shall be
350
+ for inclusion in `ngrok-javascript` by you, as defined in the Apache-2.0 license, shall be
317
351
  dual licensed as above, without any additional terms or conditions.