@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.
- package/CHANGELOG.md +15 -10
- package/Cargo.toml +2 -2
- package/README.md +37 -21
- package/docs/assets/highlight.css +10 -10
- package/docs/assets/search.js +1 -1
- package/docs/classes/HttpListenerBuilder.html +594 -0
- package/docs/classes/LabeledListenerBuilder.html +206 -0
- package/docs/classes/Listener.html +241 -0
- package/docs/classes/Session.html +207 -0
- package/docs/classes/SessionBuilder.html +465 -0
- package/docs/classes/TcpListenerBuilder.html +281 -0
- package/docs/classes/TlsListenerBuilder.html +322 -0
- package/docs/classes/UpdateRequest.html +46 -43
- package/docs/functions/authtoken.html +30 -29
- package/docs/functions/connect.html +31 -30
- package/docs/functions/consoleLog.html +30 -29
- package/docs/functions/disconnect.html +31 -30
- package/docs/functions/getListener.html +89 -0
- package/docs/functions/getListenerByUrl.html +89 -0
- package/docs/functions/kill.html +31 -30
- package/docs/functions/listen.html +33 -32
- package/docs/functions/listenable.html +31 -30
- package/docs/functions/listeners.html +84 -0
- package/docs/functions/loggingCallback.html +30 -29
- package/docs/index.html +66 -58
- package/docs/interfaces/Config.html +445 -319
- package/docs/modules.html +48 -48
- package/examples/express/ngrok-express-quickstart.js +1 -1
- package/examples/express/ngrok-express.js +6 -6
- package/examples/fastify/ngrok-fastify.js +4 -4
- package/examples/hapi/ngrok-hapi.js +4 -4
- package/examples/koa/ngrok-koa.js +1 -1
- package/examples/nestjs/src/main.ts +5 -5
- package/examples/nextjs/README.md +3 -0
- package/examples/nextjs/ngrok.config.js +7 -7
- package/examples/ngrok-connect-full.js +6 -2
- package/examples/ngrok-http-full.js +9 -6
- package/examples/ngrok-http-minimum.js +6 -6
- package/examples/ngrok-labeled.js +6 -6
- package/examples/ngrok-listen.js +1 -1
- package/examples/ngrok-tcp.js +5 -5
- package/examples/ngrok-tls.js +5 -5
- package/examples/ngrok-typescript.ts +12 -12
- package/examples/ngrok-windows-pipe.js +4 -4
- package/examples/ngrok-winston.js +2 -2
- package/examples/remix/ngrok.config.js +4 -4
- package/examples/svelte/ngrok.config.cjs +4 -4
- package/examples/vue/ngrok.config.ts +4 -4
- package/index.d.ts +510 -265
- package/index.js +75 -73
- package/package.json +14 -14
- package/scripts/gc-node-drop.js +7 -7
- package/scripts/gc-rust-drop.js +9 -9
- package/src/config.rs +113 -10
- package/src/connect.rs +32 -28
- package/src/http.rs +89 -23
- package/src/lib.rs +2 -2
- package/src/{tunnel.rs → listener.rs} +134 -134
- package/src/{tunnel_builder.rs → listener_builder.rs} +63 -54
- package/src/session.rs +57 -49
- package/src/tcp.rs +6 -3
- package/src/tls.rs +17 -7
- package/trailer.d.ts +5 -5
- package/trailer.js +64 -62
- package/typedoc.json +1 -1
- package/docs/classes/NgrokHttpTunnelBuilder.html +0 -510
- package/docs/classes/NgrokLabeledTunnelBuilder.html +0 -199
- package/docs/classes/NgrokSession.html +0 -199
- package/docs/classes/NgrokSessionBuilder.html +0 -449
- package/docs/classes/NgrokTcpTunnelBuilder.html +0 -268
- package/docs/classes/NgrokTlsTunnelBuilder.html +0 -304
- package/docs/classes/NgrokTunnel.html +0 -231
- package/docs/functions/getTunnel.html +0 -88
- package/docs/functions/getTunnelByUrl.html +0 -88
- package/docs/functions/tunnels.html +0 -83
package/src/connect.rs
CHANGED
|
@@ -9,19 +9,19 @@ use tracing::warn;
|
|
|
9
9
|
|
|
10
10
|
use crate::{
|
|
11
11
|
config::Config,
|
|
12
|
+
listener,
|
|
13
|
+
listener::TCP_PREFIX,
|
|
12
14
|
logging::logging_callback,
|
|
13
15
|
napi_err,
|
|
14
16
|
session::{
|
|
15
|
-
|
|
16
|
-
|
|
17
|
+
Session,
|
|
18
|
+
SessionBuilder,
|
|
17
19
|
},
|
|
18
|
-
tunnel,
|
|
19
|
-
tunnel::TCP_PREFIX,
|
|
20
20
|
};
|
|
21
21
|
|
|
22
22
|
lazy_static! {
|
|
23
23
|
// Save a user-facing NgrokSession to use for connect use cases
|
|
24
|
-
pub(crate) static ref SESSION: Mutex<Option<
|
|
24
|
+
pub(crate) static ref SESSION: Mutex<Option<Session>> = Mutex::new(None);
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
/// Single string configuration
|
|
@@ -81,7 +81,7 @@ macro_rules! plumb_vec {
|
|
|
81
81
|
};
|
|
82
82
|
}
|
|
83
83
|
|
|
84
|
-
/// All non-labeled
|
|
84
|
+
/// All non-labeled listeners have these common configuration options
|
|
85
85
|
macro_rules! config_common {
|
|
86
86
|
($builder:tt, $config:tt) => {
|
|
87
87
|
plumb!($builder, $config, metadata);
|
|
@@ -92,7 +92,7 @@ macro_rules! config_common {
|
|
|
92
92
|
};
|
|
93
93
|
}
|
|
94
94
|
|
|
95
|
-
/// Transform a json object configuration into a
|
|
95
|
+
/// Transform a json object configuration into a listener
|
|
96
96
|
#[napi(
|
|
97
97
|
ts_args_type = "config: Config|string|number",
|
|
98
98
|
ts_return_type = "Promise<string>"
|
|
@@ -113,7 +113,7 @@ pub fn connect(
|
|
|
113
113
|
set_defaults(&mut cfg);
|
|
114
114
|
|
|
115
115
|
// session configuration
|
|
116
|
-
let mut s_builder =
|
|
116
|
+
let mut s_builder = SessionBuilder::new();
|
|
117
117
|
plumb!(s_builder, cfg, authtoken);
|
|
118
118
|
plumb_bool!(s_builder, cfg, authtoken_from_env);
|
|
119
119
|
plumb!(s_builder, cfg, metadata, session_metadata);
|
|
@@ -124,12 +124,12 @@ pub fn connect(
|
|
|
124
124
|
s_builder.handle_disconnection(env, func);
|
|
125
125
|
}
|
|
126
126
|
|
|
127
|
-
// no longer need Env, hand off to async for
|
|
127
|
+
// no longer need Env, hand off to async for listener creation, returning the promise to nodejs.
|
|
128
128
|
env.spawn_future(async_connect(s_builder, cfg))
|
|
129
129
|
}
|
|
130
130
|
|
|
131
|
-
/// Connect the session, configure and start the
|
|
132
|
-
async fn async_connect(s_builder:
|
|
131
|
+
/// Connect the session, configure and start the listener
|
|
132
|
+
async fn async_connect(s_builder: SessionBuilder, config: Config) -> Result<String> {
|
|
133
133
|
// Using a singleton session for connect use cases
|
|
134
134
|
let mut opt = SESSION.lock().await;
|
|
135
135
|
if opt.is_none() {
|
|
@@ -137,31 +137,31 @@ async fn async_connect(s_builder: NgrokSessionBuilder, config: Config) -> Result
|
|
|
137
137
|
}
|
|
138
138
|
let session = opt.as_ref().unwrap();
|
|
139
139
|
|
|
140
|
-
//
|
|
140
|
+
// listener configuration dispatch
|
|
141
141
|
let proto = config.proto.as_ref().unwrap();
|
|
142
142
|
let id = match proto.as_str() {
|
|
143
143
|
"http" => http_endpoint(session, &config).await?,
|
|
144
144
|
"tcp" => tcp_endpoint(session, &config).await?,
|
|
145
145
|
"tls" => tls_endpoint(session, &config).await?,
|
|
146
|
-
"labeled" =>
|
|
146
|
+
"labeled" => labeled_listener(session, &config).await?,
|
|
147
147
|
_ => return Err(napi_err(format!("unhandled protocol {proto}"))),
|
|
148
148
|
};
|
|
149
149
|
|
|
150
|
-
let url =
|
|
150
|
+
let url = listener::get_listener(id.clone())
|
|
151
151
|
.await
|
|
152
152
|
.and_then(|t| t.url())
|
|
153
153
|
.unwrap_or(id.clone());
|
|
154
154
|
|
|
155
155
|
// move forwarding to another task
|
|
156
156
|
if let Some(addr) = config.addr {
|
|
157
|
-
tokio::spawn(async move {
|
|
157
|
+
tokio::spawn(async move { listener::forward(&id, addr).await });
|
|
158
158
|
}
|
|
159
159
|
|
|
160
160
|
Ok(url)
|
|
161
161
|
}
|
|
162
162
|
|
|
163
|
-
/// HTTP
|
|
164
|
-
async fn http_endpoint(session: &
|
|
163
|
+
/// HTTP Listener configuration
|
|
164
|
+
async fn http_endpoint(session: &Session, cfg: &Config) -> Result<String> {
|
|
165
165
|
let mut bld = session.http_endpoint();
|
|
166
166
|
config_common!(bld, cfg);
|
|
167
167
|
plumb_vec!(bld, cfg, scheme, schemes);
|
|
@@ -175,6 +175,8 @@ async fn http_endpoint(session: &NgrokSession, cfg: &Config) -> Result<String> {
|
|
|
175
175
|
plumb_vec!(bld, cfg, remove_request_header, request_header_remove);
|
|
176
176
|
plumb_vec!(bld, cfg, remove_response_header, response_header_remove);
|
|
177
177
|
plumb_vec!(bld, cfg, basic_auth, basic_auth, ":");
|
|
178
|
+
plumb_vec!(bld, cfg, allow_user_agent, allow_user_agent);
|
|
179
|
+
plumb_vec!(bld, cfg, deny_user_agent, deny_user_agent);
|
|
178
180
|
// circuit breaker
|
|
179
181
|
if let Some(circuit_breaker) = cfg.circuit_breaker {
|
|
180
182
|
bld.circuit_breaker(circuit_breaker);
|
|
@@ -186,6 +188,8 @@ async fn http_endpoint(session: &NgrokSession, cfg: &Config) -> Result<String> {
|
|
|
186
188
|
cfg.oauth_allow_emails.clone(),
|
|
187
189
|
cfg.oauth_allow_domains.clone(),
|
|
188
190
|
cfg.oauth_scopes.clone(),
|
|
191
|
+
cfg.oauth_client_id.clone(),
|
|
192
|
+
cfg.oauth_client_secret.clone(),
|
|
189
193
|
);
|
|
190
194
|
}
|
|
191
195
|
// oidc
|
|
@@ -216,16 +220,16 @@ async fn http_endpoint(session: &NgrokSession, cfg: &Config) -> Result<String> {
|
|
|
216
220
|
Ok(bld.listen(None).await?.id())
|
|
217
221
|
}
|
|
218
222
|
|
|
219
|
-
/// TCP
|
|
220
|
-
async fn tcp_endpoint(session: &
|
|
223
|
+
/// TCP Listener configuration
|
|
224
|
+
async fn tcp_endpoint(session: &Session, cfg: &Config) -> Result<String> {
|
|
221
225
|
let mut bld = session.tcp_endpoint();
|
|
222
226
|
config_common!(bld, cfg);
|
|
223
227
|
plumb!(bld, cfg, remote_addr);
|
|
224
228
|
Ok(bld.listen(None).await?.id())
|
|
225
229
|
}
|
|
226
230
|
|
|
227
|
-
/// TLS
|
|
228
|
-
async fn tls_endpoint(session: &
|
|
231
|
+
/// TLS Listener configuration
|
|
232
|
+
async fn tls_endpoint(session: &Session, cfg: &Config) -> Result<String> {
|
|
229
233
|
let mut bld = session.tls_endpoint();
|
|
230
234
|
config_common!(bld, cfg);
|
|
231
235
|
plumb!(bld, cfg, domain, hostname); // synonym for domain
|
|
@@ -244,9 +248,9 @@ async fn tls_endpoint(session: &NgrokSession, cfg: &Config) -> Result<String> {
|
|
|
244
248
|
Ok(bld.listen(None).await?.id())
|
|
245
249
|
}
|
|
246
250
|
|
|
247
|
-
/// Labeled
|
|
248
|
-
async fn
|
|
249
|
-
let mut bld = session.
|
|
251
|
+
/// Labeled Listener configuration
|
|
252
|
+
async fn labeled_listener(session: &Session, cfg: &Config) -> Result<String> {
|
|
253
|
+
let mut bld = session.labeled_listener();
|
|
250
254
|
plumb!(bld, cfg, metadata);
|
|
251
255
|
plumb_vec!(bld, cfg, label, labels, ":");
|
|
252
256
|
Ok(bld.listen(None).await?.id())
|
|
@@ -314,13 +318,13 @@ fn warn_unused(config: &Config) {
|
|
|
314
318
|
}
|
|
315
319
|
}
|
|
316
320
|
|
|
317
|
-
/// Close a
|
|
321
|
+
/// Close a listener with the given url, or all listeners if no url is defined.
|
|
318
322
|
#[napi]
|
|
319
323
|
#[allow(dead_code)]
|
|
320
324
|
pub async fn disconnect(url: Option<String>) -> Result<()> {
|
|
321
|
-
|
|
325
|
+
listener::close_url(url.clone()).await?;
|
|
322
326
|
|
|
323
|
-
// if closing every
|
|
327
|
+
// if closing every listener, remove any stored session
|
|
324
328
|
if url.as_ref().is_none() {
|
|
325
329
|
SESSION.lock().await.take();
|
|
326
330
|
}
|
|
@@ -328,7 +332,7 @@ pub async fn disconnect(url: Option<String>) -> Result<()> {
|
|
|
328
332
|
Ok(())
|
|
329
333
|
}
|
|
330
334
|
|
|
331
|
-
/// Close all
|
|
335
|
+
/// Close all listeners.
|
|
332
336
|
#[napi]
|
|
333
337
|
#[allow(dead_code)]
|
|
334
338
|
pub async fn kill() -> Result<()> {
|
package/src/http.rs
CHANGED
|
@@ -9,84 +9,109 @@ use ngrok::config::{
|
|
|
9
9
|
Scheme,
|
|
10
10
|
};
|
|
11
11
|
|
|
12
|
-
use crate::
|
|
12
|
+
use crate::listener_builder::HttpListenerBuilder;
|
|
13
13
|
|
|
14
14
|
#[napi]
|
|
15
15
|
#[allow(dead_code)]
|
|
16
|
-
impl
|
|
16
|
+
impl HttpListenerBuilder {
|
|
17
17
|
/// The scheme that this edge should use.
|
|
18
|
-
///
|
|
18
|
+
/// "HTTPS" or "HTTP", defaults to "HTTPS".
|
|
19
19
|
#[napi]
|
|
20
20
|
pub fn scheme(&mut self, scheme: String) -> &Self {
|
|
21
|
-
let mut builder = self.
|
|
21
|
+
let mut builder = self.listener_builder.lock();
|
|
22
22
|
builder.scheme(
|
|
23
23
|
Scheme::from_str(scheme.as_str())
|
|
24
24
|
.unwrap_or_else(|_| panic!("Unknown scheme: {scheme:?}")),
|
|
25
25
|
);
|
|
26
26
|
self
|
|
27
27
|
}
|
|
28
|
-
/// The domain to request for this edge
|
|
28
|
+
/// The domain to request for this edge, any valid domain or hostname that you have
|
|
29
|
+
/// previously registered with ngrok. If using a custom domain, this requires
|
|
30
|
+
/// registering in the [ngrok dashboard] and setting a DNS CNAME value.
|
|
31
|
+
///
|
|
32
|
+
/// [ngrok dashboard]: https://dashboard.ngrok.com/cloud-edge/domains
|
|
29
33
|
#[napi]
|
|
30
34
|
pub fn domain(&mut self, domain: String) -> &Self {
|
|
31
|
-
let mut builder = self.
|
|
35
|
+
let mut builder = self.listener_builder.lock();
|
|
32
36
|
builder.domain(domain);
|
|
33
37
|
self
|
|
34
38
|
}
|
|
35
39
|
/// Certificates to use for client authentication at the ngrok edge.
|
|
40
|
+
/// See [Mutual TLS] in the ngrok docs for additional details.
|
|
41
|
+
///
|
|
42
|
+
/// [Mutual TLS]: https://ngrok.com/docs/cloud-edge/modules/mutual-tls/
|
|
36
43
|
#[napi]
|
|
37
44
|
pub fn mutual_tlsca(&mut self, mutual_tlsca: Uint8Array) -> &Self {
|
|
38
|
-
let mut builder = self.
|
|
45
|
+
let mut builder = self.listener_builder.lock();
|
|
39
46
|
builder.mutual_tlsca(Bytes::from(mutual_tlsca.to_vec()));
|
|
40
47
|
self
|
|
41
48
|
}
|
|
42
49
|
/// Enable gzip compression for HTTP responses.
|
|
50
|
+
/// See [Compression] in the ngrok docs for additional details.
|
|
51
|
+
///
|
|
52
|
+
/// [Compression]: https://ngrok.com/docs/cloud-edge/modules/compression/
|
|
43
53
|
#[napi]
|
|
44
54
|
pub fn compression(&mut self) -> &Self {
|
|
45
|
-
let mut builder = self.
|
|
55
|
+
let mut builder = self.listener_builder.lock();
|
|
46
56
|
builder.compression();
|
|
47
57
|
self
|
|
48
58
|
}
|
|
49
59
|
/// Convert incoming websocket connections to TCP-like streams.
|
|
50
60
|
#[napi]
|
|
51
61
|
pub fn websocket_tcp_conversion(&mut self) -> &Self {
|
|
52
|
-
let mut builder = self.
|
|
62
|
+
let mut builder = self.listener_builder.lock();
|
|
53
63
|
builder.websocket_tcp_conversion();
|
|
54
64
|
self
|
|
55
65
|
}
|
|
56
66
|
/// Reject requests when 5XX responses exceed this ratio.
|
|
57
67
|
/// Disabled when 0.
|
|
68
|
+
/// See [Circuit Breaker] in the ngrok docs for additional details.
|
|
69
|
+
///
|
|
70
|
+
/// [Circuit Breaker]: https://ngrok.com/docs/cloud-edge/modules/circuit-breaker/
|
|
58
71
|
#[napi]
|
|
59
72
|
pub fn circuit_breaker(&mut self, circuit_breaker: f64) -> &Self {
|
|
60
|
-
let mut builder = self.
|
|
73
|
+
let mut builder = self.listener_builder.lock();
|
|
61
74
|
builder.circuit_breaker(circuit_breaker);
|
|
62
75
|
self
|
|
63
76
|
}
|
|
64
77
|
|
|
65
|
-
///
|
|
78
|
+
/// Adds a header to all requests to this edge.
|
|
79
|
+
/// See [Request Headers] in the ngrok docs for additional details.
|
|
80
|
+
///
|
|
81
|
+
/// [Request Headers]: https://ngrok.com/docs/cloud-edge/modules/request-headers/
|
|
66
82
|
#[napi]
|
|
67
83
|
pub fn request_header(&mut self, name: String, value: String) -> &Self {
|
|
68
|
-
let mut builder = self.
|
|
84
|
+
let mut builder = self.listener_builder.lock();
|
|
69
85
|
builder.request_header(name, value);
|
|
70
86
|
self
|
|
71
87
|
}
|
|
72
|
-
///
|
|
88
|
+
/// Adds a header to all responses coming from this edge.
|
|
89
|
+
/// See [Response Headers] in the ngrok docs for additional details.
|
|
90
|
+
///
|
|
91
|
+
/// [Response Headers]: https://ngrok.com/docs/cloud-edge/modules/response-headers/
|
|
73
92
|
#[napi]
|
|
74
93
|
pub fn response_header(&mut self, name: String, value: String) -> &Self {
|
|
75
|
-
let mut builder = self.
|
|
94
|
+
let mut builder = self.listener_builder.lock();
|
|
76
95
|
builder.response_header(name, value);
|
|
77
96
|
self
|
|
78
97
|
}
|
|
79
|
-
///
|
|
98
|
+
/// Removes a header from requests to this edge.
|
|
99
|
+
/// See [Request Headers] in the ngrok docs for additional details.
|
|
100
|
+
///
|
|
101
|
+
/// [Request Headers]: https://ngrok.com/docs/cloud-edge/modules/request-headers/
|
|
80
102
|
#[napi]
|
|
81
103
|
pub fn remove_request_header(&mut self, name: String) -> &Self {
|
|
82
|
-
let mut builder = self.
|
|
104
|
+
let mut builder = self.listener_builder.lock();
|
|
83
105
|
builder.remove_request_header(name);
|
|
84
106
|
self
|
|
85
107
|
}
|
|
86
|
-
///
|
|
108
|
+
/// Removes a header from responses from this edge.
|
|
109
|
+
/// See [Response Headers] in the ngrok docs for additional details.
|
|
110
|
+
///
|
|
111
|
+
/// [Response Headers]: https://ngrok.com/docs/cloud-edge/modules/response-headers/
|
|
87
112
|
#[napi]
|
|
88
113
|
pub fn remove_response_header(&mut self, name: String) -> &Self {
|
|
89
|
-
let mut builder = self.
|
|
114
|
+
let mut builder = self.listener_builder.lock();
|
|
90
115
|
builder.remove_response_header(name);
|
|
91
116
|
self
|
|
92
117
|
}
|
|
@@ -95,14 +120,41 @@ impl NgrokHttpTunnelBuilder {
|
|
|
95
120
|
/// If not called, basic authentication is disabled.
|
|
96
121
|
#[napi]
|
|
97
122
|
pub fn basic_auth(&mut self, username: String, password: String) -> &Self {
|
|
98
|
-
let mut builder = self.
|
|
123
|
+
let mut builder = self.listener_builder.lock();
|
|
99
124
|
builder.basic_auth(username, password);
|
|
100
125
|
self
|
|
101
126
|
}
|
|
102
127
|
|
|
128
|
+
/// A set of regular expressions used to match User-Agents that will be allowed.
|
|
129
|
+
/// On request, the User Agent Filter module will check the incoming User-Agent header value
|
|
130
|
+
/// against the list of defined allow and deny regular expression rules.
|
|
131
|
+
/// See [User Agent Filter] in the ngrok docs for additional details.
|
|
132
|
+
///
|
|
133
|
+
/// .. [User Agent Filter]: https://ngrok.com/docs/cloud-edge/modules/user-agent-filter/
|
|
134
|
+
#[napi]
|
|
135
|
+
pub fn allow_user_agent(&mut self, regex: String) -> &Self {
|
|
136
|
+
let mut builder = self.listener_builder.lock();
|
|
137
|
+
builder.allow_user_agent(regex);
|
|
138
|
+
self
|
|
139
|
+
}
|
|
140
|
+
/// A set of regular expressions used to match User-Agents that will be denied.
|
|
141
|
+
/// On request, the User Agent Filter module will check the incoming User-Agent header value
|
|
142
|
+
/// against the list of defined allow and deny regular expression rules.
|
|
143
|
+
/// See [User Agent Filter] in the ngrok docs for additional details.
|
|
144
|
+
///
|
|
145
|
+
/// .. [User Agent Filter]: https://ngrok.com/docs/cloud-edge/modules/user-agent-filter/
|
|
146
|
+
#[napi]
|
|
147
|
+
pub fn deny_user_agent(&mut self, regex: String) -> &Self {
|
|
148
|
+
let mut builder = self.listener_builder.lock();
|
|
149
|
+
builder.deny_user_agent(regex);
|
|
150
|
+
self
|
|
151
|
+
}
|
|
152
|
+
|
|
103
153
|
/// OAuth configuration.
|
|
104
154
|
/// If not called, OAuth is disabled.
|
|
105
|
-
///
|
|
155
|
+
/// See [OAuth] in the ngrok docs for additional details.
|
|
156
|
+
///
|
|
157
|
+
/// [OAuth]: https://ngrok.com/docs/cloud-edge/modules/oauth/
|
|
106
158
|
#[napi]
|
|
107
159
|
pub fn oauth(
|
|
108
160
|
&mut self,
|
|
@@ -110,6 +162,8 @@ impl NgrokHttpTunnelBuilder {
|
|
|
110
162
|
allow_emails: Option<Vec<String>>,
|
|
111
163
|
allow_domains: Option<Vec<String>>,
|
|
112
164
|
scopes: Option<Vec<String>>,
|
|
165
|
+
client_id: Option<String>,
|
|
166
|
+
client_secret: Option<String>,
|
|
113
167
|
) -> &Self {
|
|
114
168
|
let mut oauth = OauthOptions::new(provider);
|
|
115
169
|
if let Some(allow_emails) = allow_emails {
|
|
@@ -127,14 +181,23 @@ impl NgrokHttpTunnelBuilder {
|
|
|
127
181
|
oauth.scope(v);
|
|
128
182
|
});
|
|
129
183
|
}
|
|
184
|
+
if let Some(client_id) = client_id {
|
|
185
|
+
oauth.client_id(client_id);
|
|
186
|
+
}
|
|
187
|
+
if let Some(client_secret) = client_secret {
|
|
188
|
+
oauth.client_secret(client_secret);
|
|
189
|
+
}
|
|
130
190
|
|
|
131
|
-
let mut builder = self.
|
|
191
|
+
let mut builder = self.listener_builder.lock();
|
|
132
192
|
builder.oauth(oauth);
|
|
133
193
|
self
|
|
134
194
|
}
|
|
135
195
|
|
|
136
196
|
/// OIDC configuration.
|
|
137
197
|
/// If not called, OIDC is disabled.
|
|
198
|
+
/// See [OpenID Connect] in the ngrok docs for additional details.
|
|
199
|
+
///
|
|
200
|
+
/// [OpenID Connect]: https://ngrok.com/docs/cloud-edge/modules/openid-connect/
|
|
138
201
|
#[napi]
|
|
139
202
|
pub fn oidc(
|
|
140
203
|
&mut self,
|
|
@@ -162,16 +225,19 @@ impl NgrokHttpTunnelBuilder {
|
|
|
162
225
|
});
|
|
163
226
|
}
|
|
164
227
|
|
|
165
|
-
let mut builder = self.
|
|
228
|
+
let mut builder = self.listener_builder.lock();
|
|
166
229
|
builder.oidc(oidc);
|
|
167
230
|
self
|
|
168
231
|
}
|
|
169
232
|
|
|
170
233
|
/// WebhookVerification configuration.
|
|
171
234
|
/// If not called, WebhookVerification is disabled.
|
|
235
|
+
/// See [Webhook Verification] in the ngrok docs for additional details.
|
|
236
|
+
///
|
|
237
|
+
/// [Webhook Verification]: https://ngrok.com/docs/cloud-edge/modules/webhook-verification/
|
|
172
238
|
#[napi]
|
|
173
239
|
pub fn webhook_verification(&mut self, provider: String, secret: String) -> &Self {
|
|
174
|
-
let mut builder = self.
|
|
240
|
+
let mut builder = self.listener_builder.lock();
|
|
175
241
|
builder.webhook_verification(provider, secret);
|
|
176
242
|
self
|
|
177
243
|
}
|
package/src/lib.rs
CHANGED
|
@@ -7,12 +7,12 @@ use ngrok::prelude::Error as NgrokError;
|
|
|
7
7
|
pub mod config;
|
|
8
8
|
pub mod connect;
|
|
9
9
|
pub mod http;
|
|
10
|
+
pub mod listener;
|
|
11
|
+
pub mod listener_builder;
|
|
10
12
|
pub mod logging;
|
|
11
13
|
pub mod session;
|
|
12
14
|
pub mod tcp;
|
|
13
15
|
pub mod tls;
|
|
14
|
-
pub mod tunnel;
|
|
15
|
-
pub mod tunnel_builder;
|
|
16
16
|
|
|
17
17
|
pub(crate) fn napi_err(message: impl Into<String>) -> Error {
|
|
18
18
|
Error::new(Status::GenericFailure, message.into())
|