@ngrok/ngrok 0.0.10 → 0.0.12
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 +13 -0
- package/Cargo.toml +4 -4
- package/docs/assets/search.js +1 -1
- package/docs/classes/NgrokHttpTunnel.html +21 -19
- package/docs/classes/NgrokHttpTunnelBuilder.html +21 -21
- package/docs/classes/NgrokLabeledTunnel.html +20 -18
- package/docs/classes/NgrokLabeledTunnelBuilder.html +4 -4
- package/docs/classes/NgrokSession.html +6 -6
- package/docs/classes/NgrokSessionBuilder.html +12 -12
- package/docs/classes/NgrokTcpTunnel.html +21 -19
- package/docs/classes/NgrokTcpTunnelBuilder.html +8 -8
- package/docs/classes/NgrokTlsTunnel.html +21 -19
- package/docs/classes/NgrokTlsTunnelBuilder.html +10 -10
- package/docs/classes/UpdateRequest.html +3 -3
- package/docs/functions/consoleLog.html +1 -1
- package/docs/functions/listen.html +1 -1
- package/docs/functions/listenable.html +1 -1
- package/docs/functions/loggingCallback.html +1 -1
- package/docs/index.html +67 -0
- package/examples/ngrok-express-quickstart.js +11 -0
- package/examples/ngrok-express.js +18 -3
- package/index.d.ts +2 -0
- package/index.js +14 -1
- package/package.json +17 -16
- package/src/logging.rs +8 -2
- package/src/session.rs +53 -50
- package/trailer.js +8 -1
|
@@ -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/
|
|
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>
|
|
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/
|
|
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>
|
|
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/
|
|
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>
|
|
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/
|
|
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>
|
|
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/
|
|
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>
|
|
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"><</span><a href="NgrokTlsTunnel.html" class="tsd-signature-type" data-tsd-kind="Class">NgrokTlsTunnel</a><span class="tsd-signature-symbol">></span></h4><aside class="tsd-sources">
|
|
134
134
|
<ul>
|
|
135
|
-
<li>Defined in <a href="https://github.com/ngrok/ngrok-js/blob/
|
|
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>
|
|
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/
|
|
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>
|
|
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/
|
|
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>
|
|
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/
|
|
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>
|
|
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/
|
|
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>
|
|
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/
|
|
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>
|
|
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/
|
|
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>
|
|
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/
|
|
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>
|
|
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/
|
|
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>
|
|
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/
|
|
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>
|
|
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/
|
|
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>
|
|
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/
|
|
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>
|
|
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
|
@@ -37,6 +37,11 @@ to manage.</p>
|
|
|
37
37
|
<pre><code class="language-shell"><span class="hl-0">npm </span><span class="hl-1">install</span><span class="hl-0"> </span><span class="hl-1">@ngrok/ngrok</span>
|
|
38
38
|
</code></pre>
|
|
39
39
|
|
|
40
|
+
<a href="#documentation" id="documentation" style="color: inherit; text-decoration: none;">
|
|
41
|
+
<h1>Documentation</h1>
|
|
42
|
+
</a>
|
|
43
|
+
<p>A quickstart guide and a full API reference are included in the <a href="https://ngrok.github.io/ngrok-js/">ngrok-js TypeScript API documentation</a>.</p>
|
|
44
|
+
|
|
40
45
|
<a href="#quickstart" id="quickstart" style="color: inherit; text-decoration: none;">
|
|
41
46
|
<h1>Quickstart</h1>
|
|
42
47
|
</a>
|
|
@@ -62,6 +67,68 @@ which can be caught and dealt with using standard then/catch semantics.</p>
|
|
|
62
67
|
<pre><code class="language-jsx"><span class="hl-2">new</span><span class="hl-0"> </span><span class="hl-5">ngrok</span><span class="hl-0">.</span><span class="hl-4">NgrokSessionBuilder</span><span class="hl-0">().</span><span class="hl-4">authtokenFromEnv</span><span class="hl-0">().</span><span class="hl-4">connect</span><span class="hl-0">()</span><br/><span class="hl-0"> .</span><span class="hl-4">then</span><span class="hl-0">((</span><span class="hl-5">session</span><span class="hl-0">) </span><span class="hl-2">=></span><span class="hl-0"> {</span><br/><span class="hl-0"> </span><span class="hl-5">session</span><span class="hl-0">.</span><span class="hl-4">httpEndpoint</span><span class="hl-0">().</span><span class="hl-4">listen</span><span class="hl-0">()</span><br/><span class="hl-0"> .</span><span class="hl-4">then</span><span class="hl-0">((</span><span class="hl-5">tun</span><span class="hl-0">) </span><span class="hl-2">=></span><span class="hl-0"> {})</span><br/><span class="hl-0"> .</span><span class="hl-4">catch</span><span class="hl-0">(</span><span class="hl-5">err</span><span class="hl-0"> </span><span class="hl-2">=></span><span class="hl-0"> </span><span class="hl-5">console</span><span class="hl-0">.</span><span class="hl-4">log</span><span class="hl-0">(</span><span class="hl-1">'tunnel setup error: '</span><span class="hl-0"> + </span><span class="hl-5">err</span><span class="hl-0">))</span><br/><span class="hl-0"> })</span><br/><span class="hl-0"> .</span><span class="hl-4">catch</span><span class="hl-0">(</span><span class="hl-5">err</span><span class="hl-0"> </span><span class="hl-2">=></span><span class="hl-0"> </span><span class="hl-5">console</span><span class="hl-0">.</span><span class="hl-4">log</span><span class="hl-0">(</span><span class="hl-1">'session setup error: '</span><span class="hl-0"> + </span><span class="hl-5">err</span><span class="hl-0">))</span><br/><span class="hl-0"> .</span><span class="hl-5">await</span><span class="hl-0">;</span>
|
|
63
68
|
</code></pre>
|
|
64
69
|
|
|
70
|
+
<a href="#platform-support" id="platform-support" style="color: inherit; text-decoration: none;">
|
|
71
|
+
<h1>Platform Support</h1>
|
|
72
|
+
</a>
|
|
73
|
+
<p>Pre-built binaries are provided on NPM for the following platforms:</p>
|
|
74
|
+
<table>
|
|
75
|
+
<thead>
|
|
76
|
+
<tr>
|
|
77
|
+
<th>OS</th>
|
|
78
|
+
<th>i686</th>
|
|
79
|
+
<th>x64</th>
|
|
80
|
+
<th>aarch64</th>
|
|
81
|
+
<th>arm</th>
|
|
82
|
+
</tr>
|
|
83
|
+
</thead>
|
|
84
|
+
<tbody><tr>
|
|
85
|
+
<td>Windows</td>
|
|
86
|
+
<td>✓</td>
|
|
87
|
+
<td>✓</td>
|
|
88
|
+
<td>*</td>
|
|
89
|
+
<td></td>
|
|
90
|
+
</tr>
|
|
91
|
+
<tr>
|
|
92
|
+
<td>MacOS</td>
|
|
93
|
+
<td></td>
|
|
94
|
+
<td>✓</td>
|
|
95
|
+
<td>✓</td>
|
|
96
|
+
<td></td>
|
|
97
|
+
</tr>
|
|
98
|
+
<tr>
|
|
99
|
+
<td>Linux</td>
|
|
100
|
+
<td></td>
|
|
101
|
+
<td>✓</td>
|
|
102
|
+
<td>✓</td>
|
|
103
|
+
<td>✓</td>
|
|
104
|
+
</tr>
|
|
105
|
+
<tr>
|
|
106
|
+
<td>Linux musl</td>
|
|
107
|
+
<td></td>
|
|
108
|
+
<td>✓</td>
|
|
109
|
+
<td>✓</td>
|
|
110
|
+
<td></td>
|
|
111
|
+
</tr>
|
|
112
|
+
<tr>
|
|
113
|
+
<td>FreeBSD</td>
|
|
114
|
+
<td></td>
|
|
115
|
+
<td>✓</td>
|
|
116
|
+
<td></td>
|
|
117
|
+
<td></td>
|
|
118
|
+
</tr>
|
|
119
|
+
<tr>
|
|
120
|
+
<td>Android</td>
|
|
121
|
+
<td></td>
|
|
122
|
+
<td></td>
|
|
123
|
+
<td>✓</td>
|
|
124
|
+
<td>✓</td>
|
|
125
|
+
</tr>
|
|
126
|
+
</tbody></table>
|
|
127
|
+
<p>ngrok-js, and <a href="https://github.com/ngrok/ngrok-rs/">ngrok-rs</a> which it depends on, are open source, so it may be possible to build them for other platforms.</p>
|
|
128
|
+
<ul>
|
|
129
|
+
<li>Windows-aarch64 will be supported after the next release of <a href="https://github.com/briansmith/ring/issues/1167">Ring</a>.</li>
|
|
130
|
+
</ul>
|
|
131
|
+
|
|
65
132
|
<a href="#dependencies" id="dependencies" style="color: inherit; text-decoration: none;">
|
|
66
133
|
<h1>Dependencies</h1>
|
|
67
134
|
</a>
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
const express = require('express')
|
|
2
|
+
const ngrok = require('@ngrok/ngrok')
|
|
3
|
+
const app = express()
|
|
4
|
+
|
|
5
|
+
app.get('/', (req, res) => {
|
|
6
|
+
res.send('Hello World!')
|
|
7
|
+
})
|
|
8
|
+
|
|
9
|
+
ngrok.listen(app).then(() => {
|
|
10
|
+
console.log("established tunnel at: " + app.tunnel.url());
|
|
11
|
+
});
|
|
@@ -6,6 +6,21 @@ app.get('/', (req, res) => {
|
|
|
6
6
|
res.send('Hello World!')
|
|
7
7
|
})
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
async function setup() {
|
|
10
|
+
// create session
|
|
11
|
+
const session = await new ngrok.NgrokSessionBuilder()
|
|
12
|
+
.authtokenFromEnv()
|
|
13
|
+
.metadata("Online in One Line")
|
|
14
|
+
.connect();
|
|
15
|
+
// create tunnel
|
|
16
|
+
const tunnel = await session.httpEndpoint()
|
|
17
|
+
.allowCidr("0.0.0.0/0")
|
|
18
|
+
.oauth("google")
|
|
19
|
+
.requestHeader("X-Req-Yup", "true")
|
|
20
|
+
.listen();
|
|
21
|
+
console.log("tunnel established at: " + tunnel.url());
|
|
22
|
+
// link tunnel to app
|
|
23
|
+
ngrok.listen(app, tunnel)
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
setup();
|
package/index.d.ts
CHANGED
|
@@ -126,6 +126,8 @@ export class NgrokSession {
|
|
|
126
126
|
labeledTunnel(): NgrokLabeledTunnelBuilder
|
|
127
127
|
/** Close a tunnel with the given ID. */
|
|
128
128
|
closeTunnel(id: string): Promise<void>
|
|
129
|
+
/** Close the ngrok session. */
|
|
130
|
+
close(): Promise<void>
|
|
129
131
|
}
|
|
130
132
|
export class UpdateRequest {
|
|
131
133
|
/** The version that the agent is requested to update to. */
|
package/index.js
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
/* prettier-ignore */
|
|
4
|
+
|
|
5
|
+
/* auto-generated by NAPI-RS */
|
|
6
|
+
|
|
1
7
|
const { existsSync, readFileSync } = require('fs')
|
|
2
8
|
const { join } = require('path')
|
|
3
9
|
|
|
@@ -286,6 +292,7 @@ async function ngrokBind(bind) {
|
|
|
286
292
|
const tunnel = await this._listen();
|
|
287
293
|
if (bind !== false) {
|
|
288
294
|
const socket = await randomTcpSocket();
|
|
295
|
+
tunnel.socket = socket;
|
|
289
296
|
defineTunnelHandle(tunnel, socket);
|
|
290
297
|
}
|
|
291
298
|
return tunnel;
|
|
@@ -336,12 +343,18 @@ async function defaultTunnel(bind) {
|
|
|
336
343
|
}
|
|
337
344
|
|
|
338
345
|
// Get a listenable ngrok tunnel, suitable for passing to net.Server.listen().
|
|
346
|
+
// Uses the NGROK_AUTHTOKEN environment variable to authenticate.
|
|
339
347
|
async function listenable() {
|
|
340
348
|
return await defaultTunnel();
|
|
341
349
|
}
|
|
342
350
|
|
|
343
|
-
// Bind a server to a ngrok tunnel, optionally passing in a pre-existing tunnel
|
|
351
|
+
// Bind a server to a new ngrok tunnel, optionally passing in a pre-existing tunnel instead.
|
|
352
|
+
// Uses the NGROK_AUTHTOKEN environment variable to authenticate if a new tunnel is created.
|
|
344
353
|
async function ngrokListen(server, tunnel) {
|
|
354
|
+
if (tunnel && tunnel.socket) {
|
|
355
|
+
// close the default bound port
|
|
356
|
+
tunnel.socket.close();
|
|
357
|
+
}
|
|
345
358
|
if (!tunnel) {
|
|
346
359
|
// turn off automatic bind
|
|
347
360
|
tunnel = await defaultTunnel(false);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ngrok/ngrok",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.12",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"types": "index.d.ts",
|
|
6
6
|
"napi": {
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
},
|
|
24
24
|
"license": "MIT",
|
|
25
25
|
"devDependencies": {
|
|
26
|
-
"@napi-rs/cli": "^2.
|
|
26
|
+
"@napi-rs/cli": "^2.15.1",
|
|
27
27
|
"@types/node": "^18.13.0",
|
|
28
28
|
"ava": "^4.3.3",
|
|
29
29
|
"axios": "^1.3.3",
|
|
@@ -44,6 +44,7 @@
|
|
|
44
44
|
"artifacts": "napi artifacts",
|
|
45
45
|
"build": "napi build --platform --release --js gen.js --dts gen.d.ts --pipe 'node post-build.js trailer index'",
|
|
46
46
|
"build:debug": "napi build --platform",
|
|
47
|
+
"clean": "rm -rf node_modules/ target/",
|
|
47
48
|
"docs": "mv trailer.d.ts trailer.d.hidden; npx typedoc index.d.ts; mv trailer.d.hidden trailer.d.ts",
|
|
48
49
|
"prepublishOnly": "napi prepublish -t npm",
|
|
49
50
|
"test": "ava",
|
|
@@ -54,19 +55,19 @@
|
|
|
54
55
|
"description": "The ngrok agent in library form, suitable for integrating directly into your NodeJS application.",
|
|
55
56
|
"repository": "https://github.com/ngrok/ngrok-js",
|
|
56
57
|
"optionalDependencies": {
|
|
57
|
-
"@ngrok/ngrok-win32-x64-msvc": "0.0.
|
|
58
|
-
"@ngrok/ngrok-darwin-x64": "0.0.
|
|
59
|
-
"@ngrok/ngrok-linux-x64-gnu": "0.0.
|
|
60
|
-
"@ngrok/ngrok-darwin-arm64": "0.0.
|
|
61
|
-
"@ngrok/ngrok-android-arm64": "0.0.
|
|
62
|
-
"@ngrok/ngrok-linux-arm64-gnu": "0.0.
|
|
63
|
-
"@ngrok/ngrok-linux-arm64-musl": "0.0.
|
|
64
|
-
"@ngrok/ngrok-win32-arm64-msvc": "0.0.
|
|
65
|
-
"@ngrok/ngrok-linux-arm-gnueabihf": "0.0.
|
|
66
|
-
"@ngrok/ngrok-linux-x64-musl": "0.0.
|
|
67
|
-
"@ngrok/ngrok-freebsd-x64": "0.0.
|
|
68
|
-
"@ngrok/ngrok-win32-ia32-msvc": "0.0.
|
|
69
|
-
"@ngrok/ngrok-android-arm-eabi": "0.0.
|
|
70
|
-
"@ngrok/ngrok-darwin-universal": "0.0.
|
|
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"
|
|
71
72
|
}
|
|
72
73
|
}
|
package/src/logging.rs
CHANGED
|
@@ -86,7 +86,11 @@ pub fn log_to_callback(level: String, target: String, message: String) -> Result
|
|
|
86
86
|
#[napi(
|
|
87
87
|
ts_args_type = "callback?: (level: string, target: string, message: string) => void, level?: string"
|
|
88
88
|
)]
|
|
89
|
-
pub fn logging_callback(
|
|
89
|
+
pub fn logging_callback(
|
|
90
|
+
env: Env,
|
|
91
|
+
callback: Option<JsFunction>,
|
|
92
|
+
level: Option<String>,
|
|
93
|
+
) -> Result<()> {
|
|
90
94
|
if callback.is_none() {
|
|
91
95
|
// clear out any registered callback
|
|
92
96
|
GLOBAL_DATA.lock().take();
|
|
@@ -94,7 +98,7 @@ pub fn logging_callback(callback: Option<JsFunction>, level: Option<String>) ->
|
|
|
94
98
|
}
|
|
95
99
|
|
|
96
100
|
// create the threadsafe function wrapper
|
|
97
|
-
let tsfn: ThreadsafeFunction<Vec<String>, ErrorStrategy::Fatal> = callback
|
|
101
|
+
let mut tsfn: ThreadsafeFunction<Vec<String>, ErrorStrategy::Fatal> = callback
|
|
98
102
|
.unwrap()
|
|
99
103
|
.create_threadsafe_function(0, |ctx: ThreadSafeCallContext<Vec<String>>| {
|
|
100
104
|
Ok(ctx
|
|
@@ -103,6 +107,8 @@ pub fn logging_callback(callback: Option<JsFunction>, level: Option<String>) ->
|
|
|
103
107
|
.map(|s| ctx.env.create_string_from_std(s.clone()))
|
|
104
108
|
.collect())
|
|
105
109
|
})?;
|
|
110
|
+
// tell the runtime it can exit while this callback exists
|
|
111
|
+
tsfn.unref(&env)?;
|
|
106
112
|
|
|
107
113
|
// store the global callback
|
|
108
114
|
let _ = GLOBAL_DATA.lock().insert(tsfn);
|
package/src/session.rs
CHANGED
|
@@ -158,21 +158,14 @@ impl NgrokSessionBuilder {
|
|
|
158
158
|
/// stop operation to time out. Do not call [std::process::exit] inside this
|
|
159
159
|
/// callback, it will also cause the operation to time out.
|
|
160
160
|
#[napi(ts_args_type = "handler: () => void")]
|
|
161
|
-
pub fn handle_stop_command(&mut self, handler: JsFunction) -> &Self {
|
|
161
|
+
pub fn handle_stop_command(&mut self, env: Env, handler: JsFunction) -> &Self {
|
|
162
162
|
// create threadsafe function
|
|
163
|
-
let tsfn =
|
|
163
|
+
let tsfn = create_tsfn(env, handler);
|
|
164
164
|
// register stop handler
|
|
165
165
|
let mut builder = self.raw_builder.lock();
|
|
166
|
-
*builder = builder
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
tsfn.clone()
|
|
170
|
-
.lock()
|
|
171
|
-
.await
|
|
172
|
-
.call((), ThreadsafeFunctionCallMode::NonBlocking);
|
|
173
|
-
Ok(())
|
|
174
|
-
}
|
|
175
|
-
});
|
|
166
|
+
*builder = builder
|
|
167
|
+
.clone()
|
|
168
|
+
.handle_stop_command(move |_req| call_tsfn(tsfn.clone(), ()));
|
|
176
169
|
self
|
|
177
170
|
}
|
|
178
171
|
|
|
@@ -188,21 +181,14 @@ impl NgrokSessionBuilder {
|
|
|
188
181
|
/// stop operation to time out. Do not call [std::process::exit] inside this
|
|
189
182
|
/// callback, it will also cause the operation to time out.
|
|
190
183
|
#[napi(ts_args_type = "handler: () => void")]
|
|
191
|
-
pub fn handle_restart_command(&mut self, handler: JsFunction) -> &Self {
|
|
184
|
+
pub fn handle_restart_command(&mut self, env: Env, handler: JsFunction) -> &Self {
|
|
192
185
|
// create threadsafe function
|
|
193
|
-
let tsfn =
|
|
186
|
+
let tsfn = create_tsfn(env, handler);
|
|
194
187
|
// register restart handler
|
|
195
188
|
let mut builder = self.raw_builder.lock();
|
|
196
|
-
*builder = builder
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
tsfn.clone()
|
|
200
|
-
.lock()
|
|
201
|
-
.await
|
|
202
|
-
.call((), ThreadsafeFunctionCallMode::NonBlocking);
|
|
203
|
-
Ok(())
|
|
204
|
-
}
|
|
205
|
-
});
|
|
189
|
+
*builder = builder
|
|
190
|
+
.clone()
|
|
191
|
+
.handle_restart_command(move |_req| call_tsfn(tsfn.clone(), ()));
|
|
206
192
|
self
|
|
207
193
|
}
|
|
208
194
|
|
|
@@ -218,32 +204,17 @@ impl NgrokSessionBuilder {
|
|
|
218
204
|
/// stop operation to time out. Do not call [std::process::exit] inside this
|
|
219
205
|
/// callback, it will also cause the operation to time out.
|
|
220
206
|
#[napi(ts_args_type = "handler: (update: UpdateRequest) => void")]
|
|
221
|
-
pub fn handle_update_command(&mut self, handler: JsFunction) -> &Self {
|
|
207
|
+
pub fn handle_update_command(&mut self, env: Env, handler: JsFunction) -> &Self {
|
|
222
208
|
// create threadsafe function
|
|
223
|
-
let tsfn
|
|
224
|
-
Arc::new(Mutex::new(
|
|
225
|
-
handler
|
|
226
|
-
.create_threadsafe_function(0, |ctx: ThreadSafeCallContext<UpdateRequest>| {
|
|
227
|
-
Ok(vec![ctx.value])
|
|
228
|
-
})
|
|
229
|
-
.expect("Failed to create update callback function"),
|
|
230
|
-
));
|
|
209
|
+
let tsfn = create_tsfn(env, handler);
|
|
231
210
|
// register update handler
|
|
232
211
|
let mut builder = self.raw_builder.lock();
|
|
233
212
|
*builder = builder.clone().handle_update_command(move |req: Update| {
|
|
234
|
-
let tsfn = tsfn.clone();
|
|
235
213
|
let update = UpdateRequest {
|
|
236
214
|
version: req.version,
|
|
237
215
|
permit_major_version: req.permit_major_version,
|
|
238
216
|
};
|
|
239
|
-
|
|
240
|
-
async move {
|
|
241
|
-
tsfn.clone()
|
|
242
|
-
.lock()
|
|
243
|
-
.await
|
|
244
|
-
.call(update, ThreadsafeFunctionCallMode::NonBlocking);
|
|
245
|
-
Ok(())
|
|
246
|
-
}
|
|
217
|
+
call_tsfn(tsfn.clone(), update)
|
|
247
218
|
});
|
|
248
219
|
self
|
|
249
220
|
}
|
|
@@ -323,6 +294,16 @@ impl NgrokSession {
|
|
|
323
294
|
}
|
|
324
295
|
res
|
|
325
296
|
}
|
|
297
|
+
|
|
298
|
+
/// Close the ngrok session.
|
|
299
|
+
#[napi]
|
|
300
|
+
pub async fn close(&self) -> Result<()> {
|
|
301
|
+
let mut session = self.raw_session.lock().clone();
|
|
302
|
+
session
|
|
303
|
+
.close()
|
|
304
|
+
.await
|
|
305
|
+
.map_err(|e| napi_err(format!("failed to close tunnel, {e:?}")))
|
|
306
|
+
}
|
|
326
307
|
}
|
|
327
308
|
|
|
328
309
|
impl ObjectFinalize for NgrokSession {
|
|
@@ -341,12 +322,34 @@ pub struct UpdateRequest {
|
|
|
341
322
|
pub permit_major_version: bool,
|
|
342
323
|
}
|
|
343
324
|
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
325
|
+
/// Create a threadsafe function that has the given argument type and no return value.
|
|
326
|
+
pub(crate) fn create_tsfn<A>(
|
|
327
|
+
env: Env,
|
|
328
|
+
handler: JsFunction,
|
|
329
|
+
) -> Arc<Mutex<ThreadsafeFunction<A, ErrorStrategy::Fatal>>>
|
|
330
|
+
where
|
|
331
|
+
A: ToNapiValue,
|
|
332
|
+
{
|
|
333
|
+
Arc::new(Mutex::new({
|
|
334
|
+
let mut tsfn = handler
|
|
335
|
+
.create_threadsafe_function(0, |ctx: ThreadSafeCallContext<A>| Ok(vec![ctx.value]))
|
|
336
|
+
.expect("Failed to create update callback function");
|
|
337
|
+
// tell the runtime it can exit while this callback exists
|
|
338
|
+
tsfn.unref(&env).expect("Failed to unref callback function");
|
|
339
|
+
tsfn
|
|
340
|
+
}))
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
/// Call a threadsafe function that has the given argument type and no return value.
|
|
344
|
+
pub(crate) async fn call_tsfn<A>(
|
|
345
|
+
tsfn: Arc<Mutex<ThreadsafeFunction<A, ErrorStrategy::Fatal>>>,
|
|
346
|
+
arg: A,
|
|
347
|
+
) -> core::result::Result<(), String>
|
|
348
|
+
where
|
|
349
|
+
A: ToNapiValue,
|
|
350
|
+
{
|
|
351
|
+
tsfn.lock()
|
|
352
|
+
.await
|
|
353
|
+
.call(arg, ThreadsafeFunctionCallMode::NonBlocking);
|
|
354
|
+
Ok(())
|
|
352
355
|
}
|
package/trailer.js
CHANGED
|
@@ -24,6 +24,7 @@ async function ngrokBind(bind) {
|
|
|
24
24
|
const tunnel = await this._listen();
|
|
25
25
|
if (bind !== false) {
|
|
26
26
|
const socket = await randomTcpSocket();
|
|
27
|
+
tunnel.socket = socket;
|
|
27
28
|
defineTunnelHandle(tunnel, socket);
|
|
28
29
|
}
|
|
29
30
|
return tunnel;
|
|
@@ -74,12 +75,18 @@ async function defaultTunnel(bind) {
|
|
|
74
75
|
}
|
|
75
76
|
|
|
76
77
|
// Get a listenable ngrok tunnel, suitable for passing to net.Server.listen().
|
|
78
|
+
// Uses the NGROK_AUTHTOKEN environment variable to authenticate.
|
|
77
79
|
async function listenable() {
|
|
78
80
|
return await defaultTunnel();
|
|
79
81
|
}
|
|
80
82
|
|
|
81
|
-
// Bind a server to a ngrok tunnel, optionally passing in a pre-existing tunnel
|
|
83
|
+
// Bind a server to a new ngrok tunnel, optionally passing in a pre-existing tunnel instead.
|
|
84
|
+
// Uses the NGROK_AUTHTOKEN environment variable to authenticate if a new tunnel is created.
|
|
82
85
|
async function ngrokListen(server, tunnel) {
|
|
86
|
+
if (tunnel && tunnel.socket) {
|
|
87
|
+
// close the default bound port
|
|
88
|
+
tunnel.socket.close();
|
|
89
|
+
}
|
|
83
90
|
if (!tunnel) {
|
|
84
91
|
// turn off automatic bind
|
|
85
92
|
tunnel = await defaultTunnel(false);
|