@ngrok/ngrok 0.7.1 → 0.9.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 +19 -10
- package/Cargo.toml +2 -2
- package/README.md +48 -32
- package/RELEASE.md +1 -1
- package/docs/assets/highlight.css +19 -12
- 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 +8 -4
- package/examples/ngrok-connect-minimal.js +2 -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 +511 -266
- 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 +38 -32
- 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,22 @@ use tracing::warn;
|
|
|
9
9
|
|
|
10
10
|
use crate::{
|
|
11
11
|
config::Config,
|
|
12
|
+
listener::{
|
|
13
|
+
self,
|
|
14
|
+
Listener,
|
|
15
|
+
TCP_PREFIX,
|
|
16
|
+
},
|
|
12
17
|
logging::logging_callback,
|
|
13
18
|
napi_err,
|
|
14
19
|
session::{
|
|
15
|
-
|
|
16
|
-
|
|
20
|
+
Session,
|
|
21
|
+
SessionBuilder,
|
|
17
22
|
},
|
|
18
|
-
tunnel,
|
|
19
|
-
tunnel::TCP_PREFIX,
|
|
20
23
|
};
|
|
21
24
|
|
|
22
25
|
lazy_static! {
|
|
23
26
|
// Save a user-facing NgrokSession to use for connect use cases
|
|
24
|
-
pub(crate) static ref SESSION: Mutex<Option<
|
|
27
|
+
pub(crate) static ref SESSION: Mutex<Option<Session>> = Mutex::new(None);
|
|
25
28
|
}
|
|
26
29
|
|
|
27
30
|
/// Single string configuration
|
|
@@ -81,7 +84,7 @@ macro_rules! plumb_vec {
|
|
|
81
84
|
};
|
|
82
85
|
}
|
|
83
86
|
|
|
84
|
-
/// All non-labeled
|
|
87
|
+
/// All non-labeled listeners have these common configuration options
|
|
85
88
|
macro_rules! config_common {
|
|
86
89
|
($builder:tt, $config:tt) => {
|
|
87
90
|
plumb!($builder, $config, metadata);
|
|
@@ -92,10 +95,10 @@ macro_rules! config_common {
|
|
|
92
95
|
};
|
|
93
96
|
}
|
|
94
97
|
|
|
95
|
-
/// Transform a json object configuration into a
|
|
98
|
+
/// Transform a json object configuration into a listener
|
|
96
99
|
#[napi(
|
|
97
100
|
ts_args_type = "config: Config|string|number",
|
|
98
|
-
ts_return_type = "Promise<
|
|
101
|
+
ts_return_type = "Promise<Listener>"
|
|
99
102
|
)]
|
|
100
103
|
#[allow(dead_code)]
|
|
101
104
|
pub fn connect(
|
|
@@ -113,7 +116,7 @@ pub fn connect(
|
|
|
113
116
|
set_defaults(&mut cfg);
|
|
114
117
|
|
|
115
118
|
// session configuration
|
|
116
|
-
let mut s_builder =
|
|
119
|
+
let mut s_builder = SessionBuilder::new();
|
|
117
120
|
plumb!(s_builder, cfg, authtoken);
|
|
118
121
|
plumb_bool!(s_builder, cfg, authtoken_from_env);
|
|
119
122
|
plumb!(s_builder, cfg, metadata, session_metadata);
|
|
@@ -124,12 +127,12 @@ pub fn connect(
|
|
|
124
127
|
s_builder.handle_disconnection(env, func);
|
|
125
128
|
}
|
|
126
129
|
|
|
127
|
-
// no longer need Env, hand off to async for
|
|
130
|
+
// no longer need Env, hand off to async for listener creation, returning the promise to nodejs.
|
|
128
131
|
env.spawn_future(async_connect(s_builder, cfg))
|
|
129
132
|
}
|
|
130
133
|
|
|
131
|
-
/// Connect the session, configure and start the
|
|
132
|
-
async fn async_connect(s_builder:
|
|
134
|
+
/// Connect the session, configure and start the listener
|
|
135
|
+
async fn async_connect(s_builder: SessionBuilder, config: Config) -> Result<Listener> {
|
|
133
136
|
// Using a singleton session for connect use cases
|
|
134
137
|
let mut opt = SESSION.lock().await;
|
|
135
138
|
if opt.is_none() {
|
|
@@ -137,31 +140,30 @@ async fn async_connect(s_builder: NgrokSessionBuilder, config: Config) -> Result
|
|
|
137
140
|
}
|
|
138
141
|
let session = opt.as_ref().unwrap();
|
|
139
142
|
|
|
140
|
-
//
|
|
143
|
+
// listener configuration dispatch
|
|
141
144
|
let proto = config.proto.as_ref().unwrap();
|
|
142
145
|
let id = match proto.as_str() {
|
|
143
146
|
"http" => http_endpoint(session, &config).await?,
|
|
144
147
|
"tcp" => tcp_endpoint(session, &config).await?,
|
|
145
148
|
"tls" => tls_endpoint(session, &config).await?,
|
|
146
|
-
"labeled" =>
|
|
149
|
+
"labeled" => labeled_listener(session, &config).await?,
|
|
147
150
|
_ => return Err(napi_err(format!("unhandled protocol {proto}"))),
|
|
148
151
|
};
|
|
149
152
|
|
|
150
|
-
let
|
|
153
|
+
let listener = listener::get_listener(id.clone())
|
|
151
154
|
.await
|
|
152
|
-
.
|
|
153
|
-
.unwrap_or(id.clone());
|
|
155
|
+
.ok_or(napi_err("failed to start listener".to_string()))?;
|
|
154
156
|
|
|
155
157
|
// move forwarding to another task
|
|
156
158
|
if let Some(addr) = config.addr {
|
|
157
|
-
tokio::spawn(async move {
|
|
159
|
+
tokio::spawn(async move { listener::forward(&id, addr).await });
|
|
158
160
|
}
|
|
159
161
|
|
|
160
|
-
Ok(
|
|
162
|
+
Ok(listener)
|
|
161
163
|
}
|
|
162
164
|
|
|
163
|
-
/// HTTP
|
|
164
|
-
async fn http_endpoint(session: &
|
|
165
|
+
/// HTTP Listener configuration
|
|
166
|
+
async fn http_endpoint(session: &Session, cfg: &Config) -> Result<String> {
|
|
165
167
|
let mut bld = session.http_endpoint();
|
|
166
168
|
config_common!(bld, cfg);
|
|
167
169
|
plumb_vec!(bld, cfg, scheme, schemes);
|
|
@@ -175,6 +177,8 @@ async fn http_endpoint(session: &NgrokSession, cfg: &Config) -> Result<String> {
|
|
|
175
177
|
plumb_vec!(bld, cfg, remove_request_header, request_header_remove);
|
|
176
178
|
plumb_vec!(bld, cfg, remove_response_header, response_header_remove);
|
|
177
179
|
plumb_vec!(bld, cfg, basic_auth, basic_auth, ":");
|
|
180
|
+
plumb_vec!(bld, cfg, allow_user_agent, allow_user_agent);
|
|
181
|
+
plumb_vec!(bld, cfg, deny_user_agent, deny_user_agent);
|
|
178
182
|
// circuit breaker
|
|
179
183
|
if let Some(circuit_breaker) = cfg.circuit_breaker {
|
|
180
184
|
bld.circuit_breaker(circuit_breaker);
|
|
@@ -186,6 +190,8 @@ async fn http_endpoint(session: &NgrokSession, cfg: &Config) -> Result<String> {
|
|
|
186
190
|
cfg.oauth_allow_emails.clone(),
|
|
187
191
|
cfg.oauth_allow_domains.clone(),
|
|
188
192
|
cfg.oauth_scopes.clone(),
|
|
193
|
+
cfg.oauth_client_id.clone(),
|
|
194
|
+
cfg.oauth_client_secret.clone(),
|
|
189
195
|
);
|
|
190
196
|
}
|
|
191
197
|
// oidc
|
|
@@ -216,16 +222,16 @@ async fn http_endpoint(session: &NgrokSession, cfg: &Config) -> Result<String> {
|
|
|
216
222
|
Ok(bld.listen(None).await?.id())
|
|
217
223
|
}
|
|
218
224
|
|
|
219
|
-
/// TCP
|
|
220
|
-
async fn tcp_endpoint(session: &
|
|
225
|
+
/// TCP Listener configuration
|
|
226
|
+
async fn tcp_endpoint(session: &Session, cfg: &Config) -> Result<String> {
|
|
221
227
|
let mut bld = session.tcp_endpoint();
|
|
222
228
|
config_common!(bld, cfg);
|
|
223
229
|
plumb!(bld, cfg, remote_addr);
|
|
224
230
|
Ok(bld.listen(None).await?.id())
|
|
225
231
|
}
|
|
226
232
|
|
|
227
|
-
/// TLS
|
|
228
|
-
async fn tls_endpoint(session: &
|
|
233
|
+
/// TLS Listener configuration
|
|
234
|
+
async fn tls_endpoint(session: &Session, cfg: &Config) -> Result<String> {
|
|
229
235
|
let mut bld = session.tls_endpoint();
|
|
230
236
|
config_common!(bld, cfg);
|
|
231
237
|
plumb!(bld, cfg, domain, hostname); // synonym for domain
|
|
@@ -244,9 +250,9 @@ async fn tls_endpoint(session: &NgrokSession, cfg: &Config) -> Result<String> {
|
|
|
244
250
|
Ok(bld.listen(None).await?.id())
|
|
245
251
|
}
|
|
246
252
|
|
|
247
|
-
/// Labeled
|
|
248
|
-
async fn
|
|
249
|
-
let mut bld = session.
|
|
253
|
+
/// Labeled Listener configuration
|
|
254
|
+
async fn labeled_listener(session: &Session, cfg: &Config) -> Result<String> {
|
|
255
|
+
let mut bld = session.labeled_listener();
|
|
250
256
|
plumb!(bld, cfg, metadata);
|
|
251
257
|
plumb_vec!(bld, cfg, label, labels, ":");
|
|
252
258
|
Ok(bld.listen(None).await?.id())
|
|
@@ -314,13 +320,13 @@ fn warn_unused(config: &Config) {
|
|
|
314
320
|
}
|
|
315
321
|
}
|
|
316
322
|
|
|
317
|
-
/// Close a
|
|
323
|
+
/// Close a listener with the given url, or all listeners if no url is defined.
|
|
318
324
|
#[napi]
|
|
319
325
|
#[allow(dead_code)]
|
|
320
326
|
pub async fn disconnect(url: Option<String>) -> Result<()> {
|
|
321
|
-
|
|
327
|
+
listener::close_url(url.clone()).await?;
|
|
322
328
|
|
|
323
|
-
// if closing every
|
|
329
|
+
// if closing every listener, remove any stored session
|
|
324
330
|
if url.as_ref().is_none() {
|
|
325
331
|
SESSION.lock().await.take();
|
|
326
332
|
}
|
|
@@ -328,7 +334,7 @@ pub async fn disconnect(url: Option<String>) -> Result<()> {
|
|
|
328
334
|
Ok(())
|
|
329
335
|
}
|
|
330
336
|
|
|
331
|
-
/// Close all
|
|
337
|
+
/// Close all listeners.
|
|
332
338
|
#[napi]
|
|
333
339
|
#[allow(dead_code)]
|
|
334
340
|
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())
|