@ngrok/ngrok 0.0.12 → 0.1.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.
@@ -23,7 +23,7 @@
23
23
  <ul class="tsd-hierarchy">
24
24
  <li><span class="target">NgrokTlsTunnelBuilder</span></li></ul></section><aside class="tsd-sources">
25
25
  <ul>
26
- <li>Defined in <a href="https://github.com/ngrok/ngrok-js/blob/6f1b224/index.d.ts#L367">index.d.ts:367</a></li></ul></aside>
26
+ <li>Defined in <a href="https://github.com/ngrok/ngrok-js/blob/b3dca65/index.d.ts#L398">index.d.ts:398</a></li></ul></aside>
27
27
  <section class="tsd-panel-group tsd-index-group">
28
28
  <section class="tsd-panel tsd-index-panel">
29
29
  <details class="tsd-index-content tsd-index-accordion" open><summary class="tsd-accordion-summary tsd-index-summary">
@@ -70,7 +70,7 @@ Call multiple times to add additional CIDR ranges.</p>
70
70
  <h5>cidr: <span class="tsd-signature-type">string</span></h5></li></ul></div>
71
71
  <h4 class="tsd-returns-title">Returns <a href="NgrokTlsTunnelBuilder.html" class="tsd-signature-type" data-tsd-kind="Class">NgrokTlsTunnelBuilder</a></h4><aside class="tsd-sources">
72
72
  <ul>
73
- <li>Defined in <a href="https://github.com/ngrok/ngrok-js/blob/6f1b224/index.d.ts#L382">index.d.ts:382</a></li></ul></aside></li></ul></section>
73
+ <li>Defined in <a href="https://github.com/ngrok/ngrok-js/blob/b3dca65/index.d.ts#L413">index.d.ts:413</a></li></ul></aside></li></ul></section>
74
74
  <section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class"><a id="denyCidr" class="tsd-anchor"></a>
75
75
  <h3 class="tsd-anchor-link"><span>deny<wbr/>Cidr</span><a href="#denyCidr" aria-label="Permalink" class="tsd-anchor-icon"><svg class="icon icon-tabler icon-tabler-link" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"><use href="#icon-anchor-a"></use><use href="#icon-anchor-b"></use><use href="#icon-anchor-c"></use></svg></a></h3>
76
76
  <ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class">
@@ -86,7 +86,7 @@ Call multiple times to add additional CIDR ranges.</p>
86
86
  <h5>cidr: <span class="tsd-signature-type">string</span></h5></li></ul></div>
87
87
  <h4 class="tsd-returns-title">Returns <a href="NgrokTlsTunnelBuilder.html" class="tsd-signature-type" data-tsd-kind="Class">NgrokTlsTunnelBuilder</a></h4><aside class="tsd-sources">
88
88
  <ul>
89
- <li>Defined in <a href="https://github.com/ngrok/ngrok-js/blob/6f1b224/index.d.ts#L387">index.d.ts:387</a></li></ul></aside></li></ul></section>
89
+ <li>Defined in <a href="https://github.com/ngrok/ngrok-js/blob/b3dca65/index.d.ts#L418">index.d.ts:418</a></li></ul></aside></li></ul></section>
90
90
  <section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class"><a id="domain" class="tsd-anchor"></a>
91
91
  <h3 class="tsd-anchor-link"><span>domain</span><a href="#domain" aria-label="Permalink" class="tsd-anchor-icon"><svg class="icon icon-tabler icon-tabler-link" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"><use href="#icon-anchor-a"></use><use href="#icon-anchor-b"></use><use href="#icon-anchor-c"></use></svg></a></h3>
92
92
  <ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class">
@@ -101,7 +101,7 @@ Call multiple times to add additional CIDR ranges.</p>
101
101
  <h5>domain: <span class="tsd-signature-type">string</span></h5></li></ul></div>
102
102
  <h4 class="tsd-returns-title">Returns <a href="NgrokTlsTunnelBuilder.html" class="tsd-signature-type" data-tsd-kind="Class">NgrokTlsTunnelBuilder</a></h4><aside class="tsd-sources">
103
103
  <ul>
104
- <li>Defined in <a href="https://github.com/ngrok/ngrok-js/blob/6f1b224/index.d.ts#L369">index.d.ts:369</a></li></ul></aside></li></ul></section>
104
+ <li>Defined in <a href="https://github.com/ngrok/ngrok-js/blob/b3dca65/index.d.ts#L400">index.d.ts:400</a></li></ul></aside></li></ul></section>
105
105
  <section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class"><a id="forwardsTo" class="tsd-anchor"></a>
106
106
  <h3 class="tsd-anchor-link"><span>forwards<wbr/>To</span><a href="#forwardsTo" aria-label="Permalink" class="tsd-anchor-icon"><svg class="icon icon-tabler icon-tabler-link" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"><use href="#icon-anchor-a"></use><use href="#icon-anchor-b"></use><use href="#icon-anchor-c"></use></svg></a></h3>
107
107
  <ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class">
@@ -117,7 +117,7 @@ bearing on tunnel behavior.</p>
117
117
  <h5>forwardsTo: <span class="tsd-signature-type">string</span></h5></li></ul></div>
118
118
  <h4 class="tsd-returns-title">Returns <a href="NgrokTlsTunnelBuilder.html" class="tsd-signature-type" data-tsd-kind="Class">NgrokTlsTunnelBuilder</a></h4><aside class="tsd-sources">
119
119
  <ul>
120
- <li>Defined in <a href="https://github.com/ngrok/ngrok-js/blob/6f1b224/index.d.ts#L394">index.d.ts:394</a></li></ul></aside></li></ul></section>
120
+ <li>Defined in <a href="https://github.com/ngrok/ngrok-js/blob/b3dca65/index.d.ts#L425">index.d.ts:425</a></li></ul></aside></li></ul></section>
121
121
  <section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class"><a id="listen" class="tsd-anchor"></a>
122
122
  <h3 class="tsd-anchor-link"><span>listen</span><a href="#listen" aria-label="Permalink" class="tsd-anchor-icon"><svg class="icon icon-tabler icon-tabler-link" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"><use href="#icon-anchor-a"></use><use href="#icon-anchor-b"></use><use href="#icon-anchor-c"></use></svg></a></h3>
123
123
  <ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class">
@@ -132,7 +132,7 @@ bearing on tunnel behavior.</p>
132
132
  <h5><code class="tsd-tag ts-flagOptional">Optional</code> bind: <span class="tsd-signature-type">boolean</span></h5></li></ul></div>
133
133
  <h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol">&lt;</span><a href="NgrokTlsTunnel.html" class="tsd-signature-type" data-tsd-kind="Class">NgrokTlsTunnel</a><span class="tsd-signature-symbol">&gt;</span></h4><aside class="tsd-sources">
134
134
  <ul>
135
- <li>Defined in <a href="https://github.com/ngrok/ngrok-js/blob/6f1b224/index.d.ts#L377">index.d.ts:377</a></li></ul></aside></li></ul></section>
135
+ <li>Defined in <a href="https://github.com/ngrok/ngrok-js/blob/b3dca65/index.d.ts#L408">index.d.ts:408</a></li></ul></aside></li></ul></section>
136
136
  <section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class"><a id="metadata" class="tsd-anchor"></a>
137
137
  <h3 class="tsd-anchor-link"><span>metadata</span><a href="#metadata" aria-label="Permalink" class="tsd-anchor-icon"><svg class="icon icon-tabler icon-tabler-link" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"><use href="#icon-anchor-a"></use><use href="#icon-anchor-b"></use><use href="#icon-anchor-c"></use></svg></a></h3>
138
138
  <ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class">
@@ -147,7 +147,7 @@ bearing on tunnel behavior.</p>
147
147
  <h5>metadata: <span class="tsd-signature-type">string</span></h5></li></ul></div>
148
148
  <h4 class="tsd-returns-title">Returns <a href="NgrokTlsTunnelBuilder.html" class="tsd-signature-type" data-tsd-kind="Class">NgrokTlsTunnelBuilder</a></h4><aside class="tsd-sources">
149
149
  <ul>
150
- <li>Defined in <a href="https://github.com/ngrok/ngrok-js/blob/6f1b224/index.d.ts#L375">index.d.ts:375</a></li></ul></aside></li></ul></section>
150
+ <li>Defined in <a href="https://github.com/ngrok/ngrok-js/blob/b3dca65/index.d.ts#L406">index.d.ts:406</a></li></ul></aside></li></ul></section>
151
151
  <section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class"><a id="mutualTlsca" class="tsd-anchor"></a>
152
152
  <h3 class="tsd-anchor-link"><span>mutual<wbr/>Tlsca</span><a href="#mutualTlsca" aria-label="Permalink" class="tsd-anchor-icon"><svg class="icon icon-tabler icon-tabler-link" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"><use href="#icon-anchor-a"></use><use href="#icon-anchor-b"></use><use href="#icon-anchor-c"></use></svg></a></h3>
153
153
  <ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class">
@@ -162,7 +162,7 @@ bearing on tunnel behavior.</p>
162
162
  <h5>mutualTlsca: <span class="tsd-signature-type">Uint8Array</span></h5></li></ul></div>
163
163
  <h4 class="tsd-returns-title">Returns <a href="NgrokTlsTunnelBuilder.html" class="tsd-signature-type" data-tsd-kind="Class">NgrokTlsTunnelBuilder</a></h4><aside class="tsd-sources">
164
164
  <ul>
165
- <li>Defined in <a href="https://github.com/ngrok/ngrok-js/blob/6f1b224/index.d.ts#L371">index.d.ts:371</a></li></ul></aside></li></ul></section>
165
+ <li>Defined in <a href="https://github.com/ngrok/ngrok-js/blob/b3dca65/index.d.ts#L402">index.d.ts:402</a></li></ul></aside></li></ul></section>
166
166
  <section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class"><a id="proxyProto" class="tsd-anchor"></a>
167
167
  <h3 class="tsd-anchor-link"><span>proxy<wbr/>Proto</span><a href="#proxyProto" aria-label="Permalink" class="tsd-anchor-icon"><svg class="icon icon-tabler icon-tabler-link" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"><use href="#icon-anchor-a"></use><use href="#icon-anchor-b"></use><use href="#icon-anchor-c"></use></svg></a></h3>
168
168
  <ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class">
@@ -177,7 +177,7 @@ bearing on tunnel behavior.</p>
177
177
  <h5>proxyProto: <span class="tsd-signature-type">string</span></h5></li></ul></div>
178
178
  <h4 class="tsd-returns-title">Returns <a href="NgrokTlsTunnelBuilder.html" class="tsd-signature-type" data-tsd-kind="Class">NgrokTlsTunnelBuilder</a></h4><aside class="tsd-sources">
179
179
  <ul>
180
- <li>Defined in <a href="https://github.com/ngrok/ngrok-js/blob/6f1b224/index.d.ts#L389">index.d.ts:389</a></li></ul></aside></li></ul></section>
180
+ <li>Defined in <a href="https://github.com/ngrok/ngrok-js/blob/b3dca65/index.d.ts#L420">index.d.ts:420</a></li></ul></aside></li></ul></section>
181
181
  <section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class"><a id="termination" class="tsd-anchor"></a>
182
182
  <h3 class="tsd-anchor-link"><span>termination</span><a href="#termination" aria-label="Permalink" class="tsd-anchor-icon"><svg class="icon icon-tabler icon-tabler-link" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"><use href="#icon-anchor-a"></use><use href="#icon-anchor-b"></use><use href="#icon-anchor-c"></use></svg></a></h3>
183
183
  <ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class">
@@ -194,7 +194,7 @@ bearing on tunnel behavior.</p>
194
194
  <h5>keyPem: <span class="tsd-signature-type">Uint8Array</span></h5></li></ul></div>
195
195
  <h4 class="tsd-returns-title">Returns <a href="NgrokTlsTunnelBuilder.html" class="tsd-signature-type" data-tsd-kind="Class">NgrokTlsTunnelBuilder</a></h4><aside class="tsd-sources">
196
196
  <ul>
197
- <li>Defined in <a href="https://github.com/ngrok/ngrok-js/blob/6f1b224/index.d.ts#L373">index.d.ts:373</a></li></ul></aside></li></ul></section></section></div>
197
+ <li>Defined in <a href="https://github.com/ngrok/ngrok-js/blob/b3dca65/index.d.ts#L404">index.d.ts:404</a></li></ul></aside></li></ul></section></section></div>
198
198
  <div class="col-4 col-menu menu-sticky-wrap menu-highlight">
199
199
  <div class="tsd-navigation settings">
200
200
  <details class="tsd-index-accordion"><summary class="tsd-accordion-summary">
@@ -20,7 +20,7 @@
20
20
  <ul class="tsd-hierarchy">
21
21
  <li><span class="target">UpdateRequest</span></li></ul></section><aside class="tsd-sources">
22
22
  <ul>
23
- <li>Defined in <a href="https://github.com/ngrok/ngrok-js/blob/6f1b224/index.d.ts#L130">index.d.ts:130</a></li></ul></aside>
23
+ <li>Defined in <a href="https://github.com/ngrok/ngrok-js/blob/b3dca65/index.d.ts#L161">index.d.ts:161</a></li></ul></aside>
24
24
  <section class="tsd-panel-group tsd-index-group">
25
25
  <section class="tsd-panel tsd-index-panel">
26
26
  <details class="tsd-index-content tsd-index-accordion" open><summary class="tsd-accordion-summary tsd-index-summary">
@@ -51,14 +51,14 @@
51
51
  <div class="tsd-comment tsd-typography"><p>Whether or not updating to the same major version is sufficient.</p>
52
52
  </div><aside class="tsd-sources">
53
53
  <ul>
54
- <li>Defined in <a href="https://github.com/ngrok/ngrok-js/blob/6f1b224/index.d.ts#L134">index.d.ts:134</a></li></ul></aside></section>
54
+ <li>Defined in <a href="https://github.com/ngrok/ngrok-js/blob/b3dca65/index.d.ts#L165">index.d.ts:165</a></li></ul></aside></section>
55
55
  <section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-class"><a id="version" class="tsd-anchor"></a>
56
56
  <h3 class="tsd-anchor-link"><span>version</span><a href="#version" aria-label="Permalink" class="tsd-anchor-icon"><svg class="icon icon-tabler icon-tabler-link" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"><use href="#icon-anchor-a"></use><use href="#icon-anchor-b"></use><use href="#icon-anchor-c"></use></svg></a></h3>
57
57
  <div class="tsd-signature">version<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">string</span></div>
58
58
  <div class="tsd-comment tsd-typography"><p>The version that the agent is requested to update to.</p>
59
59
  </div><aside class="tsd-sources">
60
60
  <ul>
61
- <li>Defined in <a href="https://github.com/ngrok/ngrok-js/blob/6f1b224/index.d.ts#L132">index.d.ts:132</a></li></ul></aside></section></section></div>
61
+ <li>Defined in <a href="https://github.com/ngrok/ngrok-js/blob/b3dca65/index.d.ts#L163">index.d.ts:163</a></li></ul></aside></section></section></div>
62
62
  <div class="col-4 col-menu menu-sticky-wrap menu-highlight">
63
63
  <div class="tsd-navigation settings">
64
64
  <details class="tsd-index-accordion"><summary class="tsd-accordion-summary">
@@ -29,7 +29,7 @@ Optionally set the logging level to one of ERROR, WARN, INFO, DEBUG, or TRACE.</
29
29
  <h5><code class="tsd-tag ts-flagOptional">Optional</code> level: <span class="tsd-signature-type">String</span></h5></li></ul></div>
30
30
  <h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">any</span></h4><aside class="tsd-sources">
31
31
  <ul>
32
- <li>Defined in <a href="https://github.com/ngrok/ngrok-js/blob/6f1b224/index.d.ts#L413">index.d.ts:413</a></li></ul></aside></li></ul></section></div>
32
+ <li>Defined in <a href="https://github.com/ngrok/ngrok-js/blob/b3dca65/index.d.ts#L444">index.d.ts:444</a></li></ul></aside></li></ul></section></div>
33
33
  <div class="col-4 col-menu menu-sticky-wrap menu-highlight">
34
34
  <div class="tsd-navigation settings">
35
35
  <details class="tsd-index-accordion"><summary class="tsd-accordion-summary">
@@ -30,7 +30,7 @@
30
30
  <h5><code class="tsd-tag ts-flagOptional">Optional</code> tunnel: <a href="../classes/NgrokHttpTunnel.html" class="tsd-signature-type" data-tsd-kind="Class">NgrokHttpTunnel</a><span class="tsd-signature-symbol"> | </span><a href="../classes/NgrokTcpTunnel.html" class="tsd-signature-type" data-tsd-kind="Class">NgrokTcpTunnel</a><span class="tsd-signature-symbol"> | </span><a href="../classes/NgrokTlsTunnel.html" class="tsd-signature-type" data-tsd-kind="Class">NgrokTlsTunnel</a><span class="tsd-signature-symbol"> | </span><a href="../classes/NgrokLabeledTunnel.html" class="tsd-signature-type" data-tsd-kind="Class">NgrokLabeledTunnel</a></h5></li></ul></div>
31
31
  <h4 class="tsd-returns-title">Returns <a href="../classes/NgrokHttpTunnel.html" class="tsd-signature-type" data-tsd-kind="Class">NgrokHttpTunnel</a><span class="tsd-signature-symbol"> | </span><a href="../classes/NgrokTcpTunnel.html" class="tsd-signature-type" data-tsd-kind="Class">NgrokTcpTunnel</a><span class="tsd-signature-symbol"> | </span><a href="../classes/NgrokTlsTunnel.html" class="tsd-signature-type" data-tsd-kind="Class">NgrokTlsTunnel</a><span class="tsd-signature-symbol"> | </span><a href="../classes/NgrokLabeledTunnel.html" class="tsd-signature-type" data-tsd-kind="Class">NgrokLabeledTunnel</a></h4><aside class="tsd-sources">
32
32
  <ul>
33
- <li>Defined in <a href="https://github.com/ngrok/ngrok-js/blob/6f1b224/index.d.ts#L408">index.d.ts:408</a></li></ul></aside></li></ul></section></div>
33
+ <li>Defined in <a href="https://github.com/ngrok/ngrok-js/blob/b3dca65/index.d.ts#L439">index.d.ts:439</a></li></ul></aside></li></ul></section></div>
34
34
  <div class="col-4 col-menu menu-sticky-wrap menu-highlight">
35
35
  <div class="tsd-navigation settings">
36
36
  <details class="tsd-index-accordion"><summary class="tsd-accordion-summary">
@@ -28,7 +28,7 @@
28
28
  <h5><code class="tsd-tag ts-flagOptional">Optional</code> tunnel: <a href="../classes/NgrokHttpTunnel.html" class="tsd-signature-type" data-tsd-kind="Class">NgrokHttpTunnel</a><span class="tsd-signature-symbol"> | </span><a href="../classes/NgrokTcpTunnel.html" class="tsd-signature-type" data-tsd-kind="Class">NgrokTcpTunnel</a><span class="tsd-signature-symbol"> | </span><a href="../classes/NgrokTlsTunnel.html" class="tsd-signature-type" data-tsd-kind="Class">NgrokTlsTunnel</a><span class="tsd-signature-symbol"> | </span><a href="../classes/NgrokLabeledTunnel.html" class="tsd-signature-type" data-tsd-kind="Class">NgrokLabeledTunnel</a></h5></li></ul></div>
29
29
  <h4 class="tsd-returns-title">Returns <a href="../classes/NgrokHttpTunnel.html" class="tsd-signature-type" data-tsd-kind="Class">NgrokHttpTunnel</a><span class="tsd-signature-symbol"> | </span><a href="../classes/NgrokTcpTunnel.html" class="tsd-signature-type" data-tsd-kind="Class">NgrokTcpTunnel</a><span class="tsd-signature-symbol"> | </span><a href="../classes/NgrokTlsTunnel.html" class="tsd-signature-type" data-tsd-kind="Class">NgrokTlsTunnel</a><span class="tsd-signature-symbol"> | </span><a href="../classes/NgrokLabeledTunnel.html" class="tsd-signature-type" data-tsd-kind="Class">NgrokLabeledTunnel</a></h4><aside class="tsd-sources">
30
30
  <ul>
31
- <li>Defined in <a href="https://github.com/ngrok/ngrok-js/blob/6f1b224/index.d.ts#L406">index.d.ts:406</a></li></ul></aside></li></ul></section></div>
31
+ <li>Defined in <a href="https://github.com/ngrok/ngrok-js/blob/b3dca65/index.d.ts#L437">index.d.ts:437</a></li></ul></aside></li></ul></section></div>
32
32
  <div class="col-4 col-menu menu-sticky-wrap menu-highlight">
33
33
  <div class="tsd-navigation settings">
34
34
  <details class="tsd-index-accordion"><summary class="tsd-accordion-summary">
@@ -47,7 +47,7 @@ The log level defaults to INFO, it can be set to one of ERROR, WARN, INFO, DEBUG
47
47
  <h5><code class="tsd-tag ts-flagOptional">Optional</code> level: <span class="tsd-signature-type">string</span></h5></li></ul></div>
48
48
  <h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">void</span></h4><aside class="tsd-sources">
49
49
  <ul>
50
- <li>Defined in <a href="https://github.com/ngrok/ngrok-js/blob/6f1b224/index.d.ts#L11">index.d.ts:11</a></li></ul></aside></li></ul></section></div>
50
+ <li>Defined in <a href="https://github.com/ngrok/ngrok-js/blob/b3dca65/index.d.ts#L11">index.d.ts:11</a></li></ul></aside></li></ul></section></div>
51
51
  <div class="col-4 col-menu menu-sticky-wrap menu-highlight">
52
52
  <div class="tsd-navigation settings">
53
53
  <details class="tsd-index-accordion"><summary class="tsd-accordion-summary">
package/docs/index.html CHANGED
@@ -20,9 +20,8 @@
20
20
  <a href="https://github.com/ngrok/ngrok-rs/blob/main/LICENSE-MIT"><img src="https://img.shields.io/badge/license-MIT-blue.svg" alt="MIT licensed"></a>
21
21
  <a href="https://github.com/ngrok/ngrok-rs/blob/main/LICENSE-APACHE"><img src="https://img.shields.io/badge/license-Apache_2.0-blue.svg" alt="Apache-2.0 licensed"></a>
22
22
  <a href="https://github.com/ngrok/ngrok-js/actions/workflows/ci.yml"><img src="https://github.com/ngrok/ngrok-js/actions/workflows/ci.yml/badge.svg" alt="Continuous integration"></a></p>
23
- <p><a href="https://ngrok.com">Website</a></p>
24
23
  <p><strong>Note: This is alpha-quality software. Interfaces are subject to change without warning.</strong></p>
25
- <p>ngrok is a globally distributed reverse proxy commonly used for quickly getting a public URL to a
24
+ <p><a href="https://ngrok.com">ngrok</a> is a globally distributed reverse proxy commonly used for quickly getting a public URL to a
26
25
  service running inside a private network, such as on your local laptop. The ngrok agent is usually
27
26
  deployed inside a private network and is used to communicate with the ngrok cloud service.</p>
28
27
  <p>This is the ngrok agent in library form, suitable for integrating directly into NodeJS
@@ -15,12 +15,15 @@ console.log('Node.js web server at ' + UNIX_SOCKET + ' is running..');
15
15
  // setup ngrok
16
16
  var ngrok = require('@ngrok/ngrok');
17
17
  // import ngrok from '@ngrok/ngrok' // if inside a module
18
- ngrok.consoleLog(); // turn on debug logging
18
+ ngrok.consoleLog('INFO'); // turn on info logging
19
+
19
20
  builder = new ngrok.NgrokSessionBuilder();
20
21
  builder
21
22
  // .authtoken("<authtoken>")
22
23
  .authtokenFromEnv()
23
24
  .metadata("Online in One Line")
25
+ // .caCert(fs.readFileSync('ca.crt'))
26
+ // .serverAddr('192.168.1.1:443')
24
27
  .handleStopCommand(() => {
25
28
  console.log("stop command");
26
29
  })
@@ -30,6 +33,13 @@ builder
30
33
  .handleUpdateCommand((update) => {
31
34
  console.log("update command, version: " + update.version
32
35
  + " permitMajorVersion: " + update.permitMajorVersion);
36
+ })
37
+ .handleHeartbeat((latency) => {
38
+ console.log("heartbeat, latency: " + latency + " milliseconds");
39
+ })
40
+ .handleDisconnection((addr, error) => {
41
+ console.log("disconnected, addr: " + addr
42
+ + " error: " + error);
33
43
  });
34
44
 
35
45
  builder.connect().then((session) => {
package/index.d.ts CHANGED
@@ -70,6 +70,27 @@ export class NgrokSessionBuilder {
70
70
  * [server_addr parameter in the ngrok docs]: https://ngrok.com/docs/ngrok-agent/config#server_addr
71
71
  */
72
72
  serverAddr(addr: string): this
73
+ /**
74
+ * Configures the TLS certificate used to connect to the ngrok service while
75
+ * establishing the session. Use this option only if you are connecting through
76
+ * a man-in-the-middle or deep packet inspection proxy. Pass in the bytes of the certificate
77
+ * to be used to validate the connection, then override the address to connect to via
78
+ * the server_addr call.
79
+ *
80
+ * Roughly corresponds to the [root_cas parameter in the ngrok docs].
81
+ *
82
+ * [root_cas parameter in the ngrok docs]: https://ngrok.com/docs/ngrok-agent/config#root_cas
83
+ */
84
+ caCert(certBytes: Uint8Array): this
85
+ /**
86
+ * Configures a function which is called to after a disconnection to the
87
+ * ngrok service. In the event of network disruptions, it will be called each time
88
+ * the session reconnects. The handler is given the address that will be used to
89
+ * connect the session to, e.g. "example.com:443", and the message from the error
90
+ * that occurred. Returning true from the handler will cause the session to
91
+ * reconnect, returning false will cause the Session to throw an uncaught error.
92
+ */
93
+ handleDisconnection(handler: (addr: string, error: string) => boolean): this
73
94
  /**
74
95
  * Configures a function which is called when the ngrok service requests that
75
96
  * this [Session] stops. Your application may choose to interpret this callback
@@ -111,6 +132,14 @@ export class NgrokSessionBuilder {
111
132
  * callback, it will also cause the operation to time out.
112
133
  */
113
134
  handleUpdateCommand(handler: (update: UpdateRequest) => void): this
135
+ /**
136
+ * Call the provided handler whenever a heartbeat response is received,
137
+ * with the latency in milliseconds.
138
+ *
139
+ * If the handler returns an error, the heartbeat task will exit, resulting
140
+ * in the session eventually dying as well.
141
+ */
142
+ handleHeartbeat(handler: (latency: number) => void): this
114
143
  /** Attempt to establish an ngrok session using the current configuration. */
115
144
  connect(): Promise<NgrokSession>
116
145
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ngrok/ngrok",
3
- "version": "0.0.12",
3
+ "version": "0.1.0",
4
4
  "main": "index.js",
5
5
  "types": "index.d.ts",
6
6
  "napi": {
@@ -28,7 +28,6 @@
28
28
  "ava": "^4.3.3",
29
29
  "axios": "^1.3.3",
30
30
  "express": "^4.18.2",
31
- "segfault-handler": "^1.3.0",
32
31
  "ts-node": "^10.9.1",
33
32
  "typedoc": "^0.23.26",
34
33
  "typescript": "^4.9.5",
@@ -55,19 +54,19 @@
55
54
  "description": "The ngrok agent in library form, suitable for integrating directly into your NodeJS application.",
56
55
  "repository": "https://github.com/ngrok/ngrok-js",
57
56
  "optionalDependencies": {
58
- "@ngrok/ngrok-win32-x64-msvc": "0.0.12",
59
- "@ngrok/ngrok-darwin-x64": "0.0.12",
60
- "@ngrok/ngrok-linux-x64-gnu": "0.0.12",
61
- "@ngrok/ngrok-darwin-arm64": "0.0.12",
62
- "@ngrok/ngrok-android-arm64": "0.0.12",
63
- "@ngrok/ngrok-linux-arm64-gnu": "0.0.12",
64
- "@ngrok/ngrok-linux-arm64-musl": "0.0.12",
65
- "@ngrok/ngrok-win32-arm64-msvc": "0.0.12",
66
- "@ngrok/ngrok-linux-arm-gnueabihf": "0.0.12",
67
- "@ngrok/ngrok-linux-x64-musl": "0.0.12",
68
- "@ngrok/ngrok-freebsd-x64": "0.0.12",
69
- "@ngrok/ngrok-win32-ia32-msvc": "0.0.12",
70
- "@ngrok/ngrok-android-arm-eabi": "0.0.12",
71
- "@ngrok/ngrok-darwin-universal": "0.0.12"
57
+ "@ngrok/ngrok-win32-x64-msvc": "0.1.0",
58
+ "@ngrok/ngrok-darwin-x64": "0.1.0",
59
+ "@ngrok/ngrok-linux-x64-gnu": "0.1.0",
60
+ "@ngrok/ngrok-darwin-arm64": "0.1.0",
61
+ "@ngrok/ngrok-android-arm64": "0.1.0",
62
+ "@ngrok/ngrok-linux-arm64-gnu": "0.1.0",
63
+ "@ngrok/ngrok-linux-arm64-musl": "0.1.0",
64
+ "@ngrok/ngrok-win32-arm64-msvc": "0.1.0",
65
+ "@ngrok/ngrok-linux-arm-gnueabihf": "0.1.0",
66
+ "@ngrok/ngrok-linux-x64-musl": "0.1.0",
67
+ "@ngrok/ngrok-freebsd-x64": "0.1.0",
68
+ "@ngrok/ngrok-win32-ia32-msvc": "0.1.0",
69
+ "@ngrok/ngrok-android-arm-eabi": "0.1.0",
70
+ "@ngrok/ngrok-darwin-universal": "0.1.0"
72
71
  }
73
72
  }
package/src/session.rs CHANGED
@@ -1,8 +1,13 @@
1
1
  use std::{
2
+ io,
2
3
  sync::Arc,
3
4
  time::Duration,
4
5
  };
5
6
 
7
+ use async_rustls::rustls::{
8
+ self,
9
+ ClientConfig,
10
+ };
6
11
  use napi::{
7
12
  bindgen_prelude::*,
8
13
  threadsafe_function::{
@@ -15,12 +20,16 @@ use napi::{
15
20
  use napi_derive::napi;
16
21
  use ngrok::{
17
22
  session::{
23
+ default_connect,
24
+ ConnectError,
18
25
  SessionBuilder,
19
26
  Update,
20
27
  },
28
+ tunnel::AcceptError,
21
29
  Session,
22
30
  };
23
31
  use parking_lot::Mutex as SyncMutex;
32
+ use rustls_pemfile::Item;
24
33
  use tokio::sync::Mutex;
25
34
  use tracing::{
26
35
  debug,
@@ -41,11 +50,16 @@ use crate::{
41
50
  const CLIENT_TYPE: &str = "library/official/nodejs";
42
51
  const VERSION: &str = env!("CARGO_PKG_VERSION");
43
52
 
53
+ // appease clippy
54
+ type TsfnOption = Option<Arc<Mutex<ThreadsafeFunction<Vec<String>, ErrorStrategy::Fatal>>>>;
55
+
44
56
  /// The builder for an ngrok session.
45
57
  #[napi]
46
58
  #[allow(dead_code)]
59
+ #[derive(Default)]
47
60
  struct NgrokSessionBuilder {
48
61
  raw_builder: Arc<SyncMutex<SessionBuilder>>,
62
+ disconnect_handler: TsfnOption,
49
63
  }
50
64
 
51
65
  #[napi]
@@ -59,6 +73,7 @@ impl NgrokSessionBuilder {
59
73
  raw_builder: Arc::new(SyncMutex::new(
60
74
  Session::builder().child_client(CLIENT_TYPE, VERSION),
61
75
  )),
76
+ ..Default::default()
62
77
  }
63
78
  }
64
79
 
@@ -147,6 +162,95 @@ impl NgrokSessionBuilder {
147
162
  self
148
163
  }
149
164
 
165
+ /// Configures the TLS certificate used to connect to the ngrok service while
166
+ /// establishing the session. Use this option only if you are connecting through
167
+ /// a man-in-the-middle or deep packet inspection proxy. Pass in the bytes of the certificate
168
+ /// to be used to validate the connection, then override the address to connect to via
169
+ /// the server_addr call.
170
+ ///
171
+ /// Roughly corresponds to the [root_cas parameter in the ngrok docs].
172
+ ///
173
+ /// [root_cas parameter in the ngrok docs]: https://ngrok.com/docs/ngrok-agent/config#root_cas
174
+ #[napi]
175
+ pub fn ca_cert(&mut self, cert_bytes: Uint8Array) -> &Self {
176
+ let mut root_store = rustls::RootCertStore::empty();
177
+ let mut cert_pem = io::Cursor::new(cert_bytes);
178
+ root_store.add_parsable_certificates(
179
+ rustls_pemfile::read_all(&mut cert_pem)
180
+ .expect("a valid root certificate")
181
+ .into_iter()
182
+ .filter_map(|it| match it {
183
+ Item::X509Certificate(bs) => Some(bs),
184
+ _ => None,
185
+ })
186
+ .collect::<Vec<_>>()
187
+ .as_slice(),
188
+ );
189
+
190
+ let tls_config = rustls::ClientConfig::builder()
191
+ .with_safe_defaults()
192
+ .with_root_certificates(root_store)
193
+ .with_no_client_auth();
194
+
195
+ let mut builder = self.raw_builder.lock();
196
+ *builder = builder.clone().tls_config(tls_config);
197
+ self
198
+ }
199
+
200
+ /// Configures a function which is called to after a disconnection to the
201
+ /// ngrok service. In the event of network disruptions, it will be called each time
202
+ /// the session reconnects. The handler is given the address that will be used to
203
+ /// connect the session to, e.g. "example.com:443", and the message from the error
204
+ /// that occurred. Returning true from the handler will cause the session to
205
+ /// reconnect, returning false will cause the Session to throw an uncaught error.
206
+ #[napi(ts_args_type = "handler: (addr: string, error: string) => boolean")]
207
+ pub fn handle_disconnection(&mut self, env: Env, handler: JsFunction) -> &Self {
208
+ // create threadsafe function
209
+ let tsfn = create_tsfn(env, handler);
210
+ self.disconnect_handler = Some(tsfn);
211
+ self.update_connector()
212
+ }
213
+
214
+ /// Update the connector callback in the upstream rust sdk.
215
+ fn update_connector(&mut self) -> &Self {
216
+ // register connect handler. this needs the return value, so cannot use call_tsfn().
217
+ let mut builder = self.raw_builder.lock();
218
+ // clone for move to connector function
219
+ let disconnect_handler = self.disconnect_handler.clone();
220
+ *builder = builder.clone().connector(
221
+ move |addr: String, tls_config: Arc<ClientConfig>, err: Option<AcceptError>| {
222
+ // clone for async move out of environment
223
+ let disconn_tsfn = disconnect_handler.clone();
224
+ async move {
225
+ // call disconnect javascript handler
226
+ if let Some(handler) = disconn_tsfn {
227
+ if let Some(err) = err.clone() {
228
+ // call javascript handler
229
+ let resp: Option<bool> = handler
230
+ .clone()
231
+ .lock()
232
+ .await
233
+ .call_async(vec![addr.clone(), err.to_string()])
234
+ .await
235
+ .map_err(|_e| ConnectError::Canceled)?;
236
+
237
+ if let Some(reconnect) = resp {
238
+ if !reconnect {
239
+ info!("Aborting connection to {addr}");
240
+ println!("Aborting connection to {addr}"); // still shown if this takes down the process
241
+ return Err(ConnectError::Canceled);
242
+ }
243
+ }
244
+ };
245
+ }
246
+ // call the upstream connector
247
+ default_connect(addr, tls_config, err).await
248
+ }
249
+ },
250
+ );
251
+ self
252
+ }
253
+
150
254
  /// Configures a function which is called when the ngrok service requests that
151
255
  /// this [Session] stops. Your application may choose to interpret this callback
152
256
  /// as a request to terminate the [Session] or the entire process.
@@ -165,7 +269,7 @@ impl NgrokSessionBuilder {
165
269
  let mut builder = self.raw_builder.lock();
166
270
  *builder = builder
167
271
  .clone()
168
- .handle_stop_command(move |_req| call_tsfn(tsfn.clone(), ()));
272
+ .handle_stop_command(move |_req| call_tsfn(tsfn.clone(), vec![()]));
169
273
  self
170
274
  }
171
275
 
@@ -188,7 +292,7 @@ impl NgrokSessionBuilder {
188
292
  let mut builder = self.raw_builder.lock();
189
293
  *builder = builder
190
294
  .clone()
191
- .handle_restart_command(move |_req| call_tsfn(tsfn.clone(), ()));
295
+ .handle_restart_command(move |_req| call_tsfn(tsfn.clone(), vec![()]));
192
296
  self
193
297
  }
194
298
 
@@ -214,14 +318,33 @@ impl NgrokSessionBuilder {
214
318
  version: req.version,
215
319
  permit_major_version: req.permit_major_version,
216
320
  };
217
- call_tsfn(tsfn.clone(), update)
321
+ call_tsfn(tsfn.clone(), vec![update])
218
322
  });
219
323
  self
220
324
  }
221
325
 
222
- // Omitting these configurations:
223
- // tls_config(&mut self, config: rustls::ClientConfig)
224
- // connector(&mut self, connect: ConnectFn)
326
+ /// Call the provided handler whenever a heartbeat response is received,
327
+ /// with the latency in milliseconds.
328
+ ///
329
+ /// If the handler returns an error, the heartbeat task will exit, resulting
330
+ /// in the session eventually dying as well.
331
+ #[napi(ts_args_type = "handler: (latency: number) => void")]
332
+ pub fn handle_heartbeat(&mut self, env: Env, handler: JsFunction) -> &Self {
333
+ // create threadsafe function
334
+ let tsfn = create_tsfn(env, handler);
335
+
336
+ // register heartbeat handler
337
+ let mut builder = self.raw_builder.lock();
338
+ *builder = builder
339
+ .clone()
340
+ .handle_heartbeat(move |latency: Option<Duration>| {
341
+ call_tsfn(
342
+ tsfn.clone(),
343
+ vec![latency.map(|d| u32::try_from(d.as_millis()).ok())],
344
+ )
345
+ });
346
+ self
347
+ }
225
348
 
226
349
  /// Attempt to establish an ngrok session using the current configuration.
227
350
  #[napi]
@@ -322,17 +445,16 @@ pub struct UpdateRequest {
322
445
  pub permit_major_version: bool,
323
446
  }
324
447
 
325
- /// Create a threadsafe function that has the given argument type and no return value.
326
448
  pub(crate) fn create_tsfn<A>(
327
449
  env: Env,
328
450
  handler: JsFunction,
329
- ) -> Arc<Mutex<ThreadsafeFunction<A, ErrorStrategy::Fatal>>>
451
+ ) -> Arc<Mutex<ThreadsafeFunction<Vec<A>, ErrorStrategy::Fatal>>>
330
452
  where
331
453
  A: ToNapiValue,
332
454
  {
333
455
  Arc::new(Mutex::new({
334
456
  let mut tsfn = handler
335
- .create_threadsafe_function(0, |ctx: ThreadSafeCallContext<A>| Ok(vec![ctx.value]))
457
+ .create_threadsafe_function(0, |ctx: ThreadSafeCallContext<Vec<A>>| Ok(ctx.value))
336
458
  .expect("Failed to create update callback function");
337
459
  // tell the runtime it can exit while this callback exists
338
460
  tsfn.unref(&env).expect("Failed to unref callback function");
@@ -341,10 +463,10 @@ where
341
463
  }
342
464
 
343
465
  /// Call a threadsafe function that has the given argument type and no return value.
344
- pub(crate) async fn call_tsfn<A>(
466
+ pub(crate) async fn call_tsfn<A, E>(
345
467
  tsfn: Arc<Mutex<ThreadsafeFunction<A, ErrorStrategy::Fatal>>>,
346
468
  arg: A,
347
- ) -> core::result::Result<(), String>
469
+ ) -> core::result::Result<(), E>
348
470
  where
349
471
  A: ToNapiValue,
350
472
  {