@ngrok/ngrok 0.9.0 → 0.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/CONTRIBUTING.md +4 -4
- package/README.md +174 -142
- package/index.d.ts +70 -15
- package/index.js +8 -6
- package/package.json +37 -16
- package/.envrc +0 -1
- package/.gitattributes +0 -3
- package/.prettierrc.json +0 -3
- package/.yarnrc.yml +0 -3
- package/Cargo.toml +0 -34
- package/RELEASE.md +0 -26
- package/build.rs +0 -5
- package/docs/.nojekyll +0 -1
- package/docs/assets/highlight.css +0 -92
- package/docs/assets/main.js +0 -58
- package/docs/assets/search.js +0 -1
- package/docs/assets/style.css +0 -1367
- package/docs/classes/HttpListenerBuilder.html +0 -594
- package/docs/classes/LabeledListenerBuilder.html +0 -206
- package/docs/classes/Listener.html +0 -241
- package/docs/classes/Session.html +0 -207
- package/docs/classes/SessionBuilder.html +0 -465
- package/docs/classes/TcpListenerBuilder.html +0 -281
- package/docs/classes/TlsListenerBuilder.html +0 -322
- package/docs/classes/UpdateRequest.html +0 -131
- package/docs/functions/authtoken.html +0 -89
- package/docs/functions/connect.html +0 -89
- package/docs/functions/consoleLog.html +0 -90
- package/docs/functions/disconnect.html +0 -89
- package/docs/functions/getListener.html +0 -89
- package/docs/functions/getListenerByUrl.html +0 -89
- package/docs/functions/kill.html +0 -84
- package/docs/functions/listen.html +0 -92
- package/docs/functions/listenable.html +0 -85
- package/docs/functions/listeners.html +0 -84
- package/docs/functions/loggingCallback.html +0 -108
- package/docs/index.html +0 -292
- package/docs/interfaces/Config.html +0 -734
- package/docs/modules.html +0 -106
- package/examples/domain.crt +0 -18
- package/examples/domain.key +0 -27
- package/examples/express/ngrok-express-quickstart.js +0 -11
- package/examples/express/ngrok-express.js +0 -28
- package/examples/express/package.json +0 -7
- package/examples/fastify/ngrok-fastify.js +0 -26
- package/examples/fastify/package.json +0 -7
- package/examples/hapi/ngrok-hapi.js +0 -35
- package/examples/hapi/package.json +0 -7
- package/examples/koa/ngrok-koa.js +0 -12
- package/examples/koa/package.json +0 -7
- package/examples/nestjs/.eslintrc.js +0 -25
- package/examples/nestjs/.prettierrc +0 -4
- package/examples/nestjs/README.md +0 -73
- package/examples/nestjs/nest-cli.json +0 -8
- package/examples/nestjs/package.json +0 -70
- package/examples/nestjs/src/app.controller.spec.ts +0 -22
- package/examples/nestjs/src/app.controller.ts +0 -12
- package/examples/nestjs/src/app.module.ts +0 -10
- package/examples/nestjs/src/app.service.ts +0 -8
- package/examples/nestjs/src/main.ts +0 -17
- package/examples/nestjs/test/app.e2e-spec.ts +0 -24
- package/examples/nestjs/test/jest-e2e.json +0 -9
- package/examples/nestjs/tsconfig.build.json +0 -4
- package/examples/nestjs/tsconfig.json +0 -21
- package/examples/nextjs/README.md +0 -3
- package/examples/nextjs/next.config.js +0 -12
- package/examples/nextjs/ngrok.config.js +0 -23
- package/examples/nextjs/package.json +0 -6
- package/examples/nextjs/pages/index.js +0 -5
- package/examples/ngrok-connect-full.js +0 -67
- package/examples/ngrok-connect-minimal.js +0 -17
- package/examples/ngrok-http-full.js +0 -81
- package/examples/ngrok-http-minimum.js +0 -18
- package/examples/ngrok-labeled.js +0 -43
- package/examples/ngrok-listen.js +0 -11
- package/examples/ngrok-tcp.js +0 -37
- package/examples/ngrok-tls.js +0 -40
- package/examples/ngrok-typescript.ts +0 -69
- package/examples/ngrok-windows-pipe.js +0 -25
- package/examples/ngrok-winston.js +0 -24
- package/examples/package.json +0 -15
- package/examples/remix/.eslintrc.js +0 -4
- package/examples/remix/README.md +0 -53
- package/examples/remix/app/entry.client.tsx +0 -18
- package/examples/remix/app/entry.server.tsx +0 -101
- package/examples/remix/app/root.tsx +0 -20
- package/examples/remix/app/routes/_index.tsx +0 -30
- package/examples/remix/ngrok.config.js +0 -16
- package/examples/remix/package.json +0 -30
- package/examples/remix/public/favicon.ico +0 -0
- package/examples/remix/remix.config.js +0 -16
- package/examples/remix/remix.env.d.ts +0 -2
- package/examples/remix/tsconfig.json +0 -22
- package/examples/svelte/README.md +0 -38
- package/examples/svelte/jsconfig.json +0 -17
- package/examples/svelte/ngrok.config.cjs +0 -20
- package/examples/svelte/package.json +0 -22
- package/examples/svelte/src/app.d.ts +0 -12
- package/examples/svelte/src/app.html +0 -12
- package/examples/svelte/src/routes/+page.svelte +0 -2
- package/examples/svelte/static/favicon.png +0 -0
- package/examples/svelte/svelte.config.js +0 -14
- package/examples/svelte/vite.config.js +0 -6
- package/examples/vue/.vscode/extensions.json +0 -3
- package/examples/vue/README.md +0 -40
- package/examples/vue/env.d.ts +0 -1
- package/examples/vue/index.html +0 -13
- package/examples/vue/ngrok.config.ts +0 -18
- package/examples/vue/package.json +0 -25
- package/examples/vue/public/favicon.ico +0 -0
- package/examples/vue/src/App.vue +0 -47
- package/examples/vue/src/assets/base.css +0 -74
- package/examples/vue/src/assets/logo.svg +0 -1
- package/examples/vue/src/assets/main.css +0 -35
- package/examples/vue/src/components/HelloWorld.vue +0 -40
- package/examples/vue/src/components/TheWelcome.vue +0 -86
- package/examples/vue/src/components/WelcomeItem.vue +0 -86
- package/examples/vue/src/components/icons/IconCommunity.vue +0 -7
- package/examples/vue/src/components/icons/IconDocumentation.vue +0 -7
- package/examples/vue/src/components/icons/IconEcosystem.vue +0 -7
- package/examples/vue/src/components/icons/IconSupport.vue +0 -7
- package/examples/vue/src/components/icons/IconTooling.vue +0 -19
- package/examples/vue/src/main.ts +0 -6
- package/examples/vue/tsconfig.json +0 -16
- package/examples/vue/tsconfig.node.json +0 -8
- package/examples/vue/vite.config.ts +0 -15
- package/flake.lock +0 -82
- package/flake.nix +0 -111
- package/post-build.js +0 -45
- package/scripts/gc-node-drop.js +0 -49
- package/scripts/gc-rust-drop.js +0 -53
- package/src/config.rs +0 -285
- package/src/connect.rs +0 -342
- package/src/http.rs +0 -244
- package/src/lib.rs +0 -39
- package/src/listener.rs +0 -495
- package/src/listener_builder.rs +0 -204
- package/src/logging.rs +0 -140
- package/src/session.rs +0 -551
- package/src/tcp.rs +0 -18
- package/src/tls.rs +0 -44
- package/trailer.d.ts +0 -15
- package/trailer.js +0 -382
- package/tsconfig.json +0 -8
- package/typedoc.json +0 -3
package/src/http.rs
DELETED
|
@@ -1,244 +0,0 @@
|
|
|
1
|
-
use std::str::FromStr;
|
|
2
|
-
|
|
3
|
-
use bytes::Bytes;
|
|
4
|
-
use napi::bindgen_prelude::Uint8Array;
|
|
5
|
-
use napi_derive::napi;
|
|
6
|
-
use ngrok::config::{
|
|
7
|
-
OauthOptions,
|
|
8
|
-
OidcOptions,
|
|
9
|
-
Scheme,
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
use crate::listener_builder::HttpListenerBuilder;
|
|
13
|
-
|
|
14
|
-
#[napi]
|
|
15
|
-
#[allow(dead_code)]
|
|
16
|
-
impl HttpListenerBuilder {
|
|
17
|
-
/// The scheme that this edge should use.
|
|
18
|
-
/// "HTTPS" or "HTTP", defaults to "HTTPS".
|
|
19
|
-
#[napi]
|
|
20
|
-
pub fn scheme(&mut self, scheme: String) -> &Self {
|
|
21
|
-
let mut builder = self.listener_builder.lock();
|
|
22
|
-
builder.scheme(
|
|
23
|
-
Scheme::from_str(scheme.as_str())
|
|
24
|
-
.unwrap_or_else(|_| panic!("Unknown scheme: {scheme:?}")),
|
|
25
|
-
);
|
|
26
|
-
self
|
|
27
|
-
}
|
|
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
|
|
33
|
-
#[napi]
|
|
34
|
-
pub fn domain(&mut self, domain: String) -> &Self {
|
|
35
|
-
let mut builder = self.listener_builder.lock();
|
|
36
|
-
builder.domain(domain);
|
|
37
|
-
self
|
|
38
|
-
}
|
|
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/
|
|
43
|
-
#[napi]
|
|
44
|
-
pub fn mutual_tlsca(&mut self, mutual_tlsca: Uint8Array) -> &Self {
|
|
45
|
-
let mut builder = self.listener_builder.lock();
|
|
46
|
-
builder.mutual_tlsca(Bytes::from(mutual_tlsca.to_vec()));
|
|
47
|
-
self
|
|
48
|
-
}
|
|
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/
|
|
53
|
-
#[napi]
|
|
54
|
-
pub fn compression(&mut self) -> &Self {
|
|
55
|
-
let mut builder = self.listener_builder.lock();
|
|
56
|
-
builder.compression();
|
|
57
|
-
self
|
|
58
|
-
}
|
|
59
|
-
/// Convert incoming websocket connections to TCP-like streams.
|
|
60
|
-
#[napi]
|
|
61
|
-
pub fn websocket_tcp_conversion(&mut self) -> &Self {
|
|
62
|
-
let mut builder = self.listener_builder.lock();
|
|
63
|
-
builder.websocket_tcp_conversion();
|
|
64
|
-
self
|
|
65
|
-
}
|
|
66
|
-
/// Reject requests when 5XX responses exceed this ratio.
|
|
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/
|
|
71
|
-
#[napi]
|
|
72
|
-
pub fn circuit_breaker(&mut self, circuit_breaker: f64) -> &Self {
|
|
73
|
-
let mut builder = self.listener_builder.lock();
|
|
74
|
-
builder.circuit_breaker(circuit_breaker);
|
|
75
|
-
self
|
|
76
|
-
}
|
|
77
|
-
|
|
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/
|
|
82
|
-
#[napi]
|
|
83
|
-
pub fn request_header(&mut self, name: String, value: String) -> &Self {
|
|
84
|
-
let mut builder = self.listener_builder.lock();
|
|
85
|
-
builder.request_header(name, value);
|
|
86
|
-
self
|
|
87
|
-
}
|
|
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/
|
|
92
|
-
#[napi]
|
|
93
|
-
pub fn response_header(&mut self, name: String, value: String) -> &Self {
|
|
94
|
-
let mut builder = self.listener_builder.lock();
|
|
95
|
-
builder.response_header(name, value);
|
|
96
|
-
self
|
|
97
|
-
}
|
|
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/
|
|
102
|
-
#[napi]
|
|
103
|
-
pub fn remove_request_header(&mut self, name: String) -> &Self {
|
|
104
|
-
let mut builder = self.listener_builder.lock();
|
|
105
|
-
builder.remove_request_header(name);
|
|
106
|
-
self
|
|
107
|
-
}
|
|
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/
|
|
112
|
-
#[napi]
|
|
113
|
-
pub fn remove_response_header(&mut self, name: String) -> &Self {
|
|
114
|
-
let mut builder = self.listener_builder.lock();
|
|
115
|
-
builder.remove_response_header(name);
|
|
116
|
-
self
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
/// Credentials for basic authentication.
|
|
120
|
-
/// If not called, basic authentication is disabled.
|
|
121
|
-
#[napi]
|
|
122
|
-
pub fn basic_auth(&mut self, username: String, password: String) -> &Self {
|
|
123
|
-
let mut builder = self.listener_builder.lock();
|
|
124
|
-
builder.basic_auth(username, password);
|
|
125
|
-
self
|
|
126
|
-
}
|
|
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
|
-
|
|
153
|
-
/// OAuth configuration.
|
|
154
|
-
/// If not called, OAuth is disabled.
|
|
155
|
-
/// See [OAuth] in the ngrok docs for additional details.
|
|
156
|
-
///
|
|
157
|
-
/// [OAuth]: https://ngrok.com/docs/cloud-edge/modules/oauth/
|
|
158
|
-
#[napi]
|
|
159
|
-
pub fn oauth(
|
|
160
|
-
&mut self,
|
|
161
|
-
provider: String,
|
|
162
|
-
allow_emails: Option<Vec<String>>,
|
|
163
|
-
allow_domains: Option<Vec<String>>,
|
|
164
|
-
scopes: Option<Vec<String>>,
|
|
165
|
-
client_id: Option<String>,
|
|
166
|
-
client_secret: Option<String>,
|
|
167
|
-
) -> &Self {
|
|
168
|
-
let mut oauth = OauthOptions::new(provider);
|
|
169
|
-
if let Some(allow_emails) = allow_emails {
|
|
170
|
-
allow_emails.iter().for_each(|v| {
|
|
171
|
-
oauth.allow_email(v);
|
|
172
|
-
});
|
|
173
|
-
}
|
|
174
|
-
if let Some(allow_domains) = allow_domains {
|
|
175
|
-
allow_domains.iter().for_each(|v| {
|
|
176
|
-
oauth.allow_domain(v);
|
|
177
|
-
});
|
|
178
|
-
}
|
|
179
|
-
if let Some(scopes) = scopes {
|
|
180
|
-
scopes.iter().for_each(|v| {
|
|
181
|
-
oauth.scope(v);
|
|
182
|
-
});
|
|
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
|
-
}
|
|
190
|
-
|
|
191
|
-
let mut builder = self.listener_builder.lock();
|
|
192
|
-
builder.oauth(oauth);
|
|
193
|
-
self
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
/// OIDC configuration.
|
|
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/
|
|
201
|
-
#[napi]
|
|
202
|
-
pub fn oidc(
|
|
203
|
-
&mut self,
|
|
204
|
-
issuer_url: String,
|
|
205
|
-
client_id: String,
|
|
206
|
-
client_secret: String,
|
|
207
|
-
allow_emails: Option<Vec<String>>,
|
|
208
|
-
allow_domains: Option<Vec<String>>,
|
|
209
|
-
scopes: Option<Vec<String>>,
|
|
210
|
-
) -> &Self {
|
|
211
|
-
let mut oidc = OidcOptions::new(issuer_url, client_id, client_secret);
|
|
212
|
-
if let Some(allow_emails) = allow_emails {
|
|
213
|
-
allow_emails.iter().for_each(|v| {
|
|
214
|
-
oidc.allow_email(v);
|
|
215
|
-
});
|
|
216
|
-
}
|
|
217
|
-
if let Some(allow_domains) = allow_domains {
|
|
218
|
-
allow_domains.iter().for_each(|v| {
|
|
219
|
-
oidc.allow_domain(v);
|
|
220
|
-
});
|
|
221
|
-
}
|
|
222
|
-
if let Some(scopes) = scopes {
|
|
223
|
-
scopes.iter().for_each(|v| {
|
|
224
|
-
oidc.scope(v);
|
|
225
|
-
});
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
let mut builder = self.listener_builder.lock();
|
|
229
|
-
builder.oidc(oidc);
|
|
230
|
-
self
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
/// WebhookVerification configuration.
|
|
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/
|
|
238
|
-
#[napi]
|
|
239
|
-
pub fn webhook_verification(&mut self, provider: String, secret: String) -> &Self {
|
|
240
|
-
let mut builder = self.listener_builder.lock();
|
|
241
|
-
builder.webhook_verification(provider, secret);
|
|
242
|
-
self
|
|
243
|
-
}
|
|
244
|
-
}
|
package/src/lib.rs
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
use napi::{
|
|
2
|
-
Error,
|
|
3
|
-
Status,
|
|
4
|
-
};
|
|
5
|
-
use ngrok::prelude::Error as NgrokError;
|
|
6
|
-
|
|
7
|
-
pub mod config;
|
|
8
|
-
pub mod connect;
|
|
9
|
-
pub mod http;
|
|
10
|
-
pub mod listener;
|
|
11
|
-
pub mod listener_builder;
|
|
12
|
-
pub mod logging;
|
|
13
|
-
pub mod session;
|
|
14
|
-
pub mod tcp;
|
|
15
|
-
pub mod tls;
|
|
16
|
-
|
|
17
|
-
pub(crate) fn napi_err(message: impl Into<String>) -> Error {
|
|
18
|
-
Error::new(Status::GenericFailure, message.into())
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
pub(crate) fn napi_ngrok_err(message: impl Into<String>, err: &impl NgrokError) -> Error {
|
|
22
|
-
let py_err = if let Some(error_code) = err.error_code() {
|
|
23
|
-
Error::new(
|
|
24
|
-
Status::GenericFailure,
|
|
25
|
-
format!(
|
|
26
|
-
"{}: {} error_code: {}",
|
|
27
|
-
message.into(),
|
|
28
|
-
err.msg(),
|
|
29
|
-
error_code
|
|
30
|
-
),
|
|
31
|
-
)
|
|
32
|
-
} else {
|
|
33
|
-
Error::new(
|
|
34
|
-
Status::GenericFailure,
|
|
35
|
-
format!("{}: {}", message.into(), err.msg()),
|
|
36
|
-
)
|
|
37
|
-
};
|
|
38
|
-
py_err
|
|
39
|
-
}
|