@openziti/ziti-sdk-nodejs 0.13.2 → 0.13.3

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.
@@ -13,7 +13,7 @@ on:
13
13
 
14
14
  jobs:
15
15
  mattermost-ziti-webhook:
16
- runs-on: macos-latest
16
+ runs-on: ubuntu-latest
17
17
  name: POST Webhook
18
18
  env:
19
19
  ZITI_LOG: 99
@@ -0,0 +1,10 @@
1
+
2
+ # API Reference
3
+ {{#module name="@openziti/ziti-sdk-nodejs"}}
4
+ {{>body~}}
5
+ {{>member-index~}}
6
+ {{>separator~}}
7
+ {{>members~}}
8
+ {{/module}}
9
+
10
+ * * *
@@ -0,0 +1,268 @@
1
+
2
+ # API Reference
3
+ OpenZiti SDK for Node.js
4
+
5
+
6
+ * [@openziti/ziti-sdk-nodejs](#module_@openziti/ziti-sdk-nodejs)
7
+ * [~close(conn)](#module_@openziti/ziti-sdk-nodejs..close) ⇒ <code>void</code>
8
+ * [~dial(serviceName, isWebSocket, onConnect, onData)](#module_@openziti/ziti-sdk-nodejs..dial) ⇒ <code>void</code>
9
+ * [~express(express, serviceName)](#module_@openziti/ziti-sdk-nodejs..express) ⇒ <code>\*</code>
10
+ * [~httpRequest(serviceName, schemeHostPort, method, path, headers, onRequest, onResponse, onResponseData)](#module_@openziti/ziti-sdk-nodejs..httpRequest) ⇒ <code>void</code>
11
+ * [~httpRequestData(req, data, onRequestData)](#module_@openziti/ziti-sdk-nodejs..httpRequestData) ⇒ <code>void</code>
12
+ * [~httpRequestEnd(req)](#module_@openziti/ziti-sdk-nodejs..httpRequestEnd) ⇒ <code>void</code>
13
+ * [~init(identityPath)](#module_@openziti/ziti-sdk-nodejs..init) ⇒ <code>number</code>
14
+ * [~setLogLevel(level)](#module_@openziti/ziti-sdk-nodejs..setLogLevel) ⇒ <code>void</code>
15
+ * [~serviceAvailable(serviceName, onServiceAvailable)](#module_@openziti/ziti-sdk-nodejs..serviceAvailable) ⇒ <code>void</code>
16
+ * [~write(conn, data, onWrite)](#module_@openziti/ziti-sdk-nodejs..write) ⇒ <code>void</code>
17
+ * [~onDataCallback](#module_@openziti/ziti-sdk-nodejs..onDataCallback) : <code>function</code>
18
+ * [~onConnectCallback](#module_@openziti/ziti-sdk-nodejs..onConnectCallback) ⇒ <code>void</code>
19
+ * [~onRequestCallback](#module_@openziti/ziti-sdk-nodejs..onRequestCallback) ⇒ <code>void</code>
20
+ * [~onResonseCallback](#module_@openziti/ziti-sdk-nodejs..onResonseCallback) ⇒ <code>void</code>
21
+ * [~onResonseDataCallback](#module_@openziti/ziti-sdk-nodejs..onResonseDataCallback) ⇒ <code>void</code>
22
+ * [~onRequestDataCallback](#module_@openziti/ziti-sdk-nodejs..onRequestDataCallback) ⇒ <code>void</code>
23
+ * [~onServiceAvailableCallback](#module_@openziti/ziti-sdk-nodejs..onServiceAvailableCallback) ⇒ <code>void</code>
24
+ * [~onWriteCallback](#module_@openziti/ziti-sdk-nodejs..onWriteCallback) ⇒ <code>void</code>
25
+
26
+ <a name="module_@openziti/ziti-sdk-nodejs..close"></a>
27
+
28
+ ### @openziti/ziti-sdk-nodejs~close(conn) ⇒ <code>void</code>
29
+ Close a Ziti connection.
30
+
31
+ **Kind**: inner method of [<code>@openziti/ziti-sdk-nodejs</code>](#module_@openziti/ziti-sdk-nodejs)
32
+ **Returns**: <code>void</code> - No return value.
33
+
34
+ | Param | Type | Description |
35
+ | --- | --- | --- |
36
+ | conn | <code>number</code> | A Ziti connection handle. |
37
+
38
+ <a name="module_@openziti/ziti-sdk-nodejs..dial"></a>
39
+
40
+ ### @openziti/ziti-sdk-nodejs~dial(serviceName, isWebSocket, onConnect, onData) ⇒ <code>void</code>
41
+ Create a connection to Ziti Service.
42
+
43
+ **Kind**: inner method of [<code>@openziti/ziti-sdk-nodejs</code>](#module_@openziti/ziti-sdk-nodejs)
44
+ **Returns**: <code>void</code> - No return value.
45
+
46
+ | Param | Type | Description |
47
+ | --- | --- | --- |
48
+ | serviceName | <code>string</code> | The name of the Ziti Service to connect to |
49
+ | isWebSocket | <code>boolean</code> | True or False indicator concerning whether this connection if bi-directional. |
50
+ | onConnect | <code>onConnectCallback</code> | The callback that receives the connection handle. |
51
+ | onData | <code>onDataCallback</code> | The callback that receives incoming data from the connection. |
52
+
53
+ <a name="module_@openziti/ziti-sdk-nodejs..express"></a>
54
+
55
+ ### @openziti/ziti-sdk-nodejs~express(express, serviceName) ⇒ <code>\*</code>
56
+ Wrap ExpressJS to facilitate hosting (listening) on a Ziti Service instead of a TCP port.
57
+
58
+ **Kind**: inner method of [<code>@openziti/ziti-sdk-nodejs</code>](#module_@openziti/ziti-sdk-nodejs)
59
+ **Returns**: <code>\*</code> - The wrapped express() object.
60
+
61
+ | Param | Type | Description |
62
+ | --- | --- | --- |
63
+ | express | <code>\*</code> | The express() object. |
64
+ | serviceName | <code>string</code> | The name of the Ziti Service being served (hosted). |
65
+
66
+ <a name="module_@openziti/ziti-sdk-nodejs..httpRequest"></a>
67
+
68
+ ### @openziti/ziti-sdk-nodejs~httpRequest(serviceName, schemeHostPort, method, path, headers, onRequest, onResponse, onResponseData) ⇒ <code>void</code>
69
+ Initiate an HTTP request to a Ziti Service.
70
+
71
+ **Kind**: inner method of [<code>@openziti/ziti-sdk-nodejs</code>](#module_@openziti/ziti-sdk-nodejs)
72
+ **Returns**: <code>void</code> - No return value.
73
+
74
+ | Param | Type | Description |
75
+ | --- | --- | --- |
76
+ | serviceName | <code>string</code> | The name of the Ziti Service to send the request. (mutually exclusive with url) |
77
+ | schemeHostPort | <code>string</code> | The scheme/host/port (e.g. http://myserver.ziti:8080) of a Ziti service-config/intercept to send the request. (mutually exclusive with serviceName) |
78
+ | method | <code>string</code> | The REST verb to use (e.g. `GET`, `POST`). |
79
+ | path | <code>string</code> | The URL PATH to use on the request (can include HTTP query parms). |
80
+ | headers | <code>Array.&lt;string&gt;</code> | The HTTP Headers to use on the request. |
81
+ | onRequest | <code>onRequestCallback</code> | The callback that receives the request handle. |
82
+ | onResponse | <code>onResonseCallback</code> | The callback that receives the HTTP Response. |
83
+ | onResponseData | <code>onResonseDataCallback</code> | The callback that receives the HTTP Response data. |
84
+
85
+ <a name="module_@openziti/ziti-sdk-nodejs..httpRequestData"></a>
86
+
87
+ ### @openziti/ziti-sdk-nodejs~httpRequestData(req, data, onRequestData) ⇒ <code>void</code>
88
+ Send payload data for HTTP POST request to a Ziti Service.
89
+
90
+ **Kind**: inner method of [<code>@openziti/ziti-sdk-nodejs</code>](#module_@openziti/ziti-sdk-nodejs)
91
+ **Returns**: <code>void</code> - No return value.
92
+
93
+ | Param | Type | Description |
94
+ | --- | --- | --- |
95
+ | req | <code>number</code> | A Ziti HttpRequest handle. |
96
+ | data | <code>Buffer</code> | The HTTP payload data to send. |
97
+ | onRequestData | <code>onRequestDataCallback</code> | The callback that acknowleges the send. |
98
+
99
+ <a name="module_@openziti/ziti-sdk-nodejs..httpRequestEnd"></a>
100
+
101
+ ### @openziti/ziti-sdk-nodejs~httpRequestEnd(req) ⇒ <code>void</code>
102
+ Terminate payload data transmission for HTTP POST request to a Ziti Service.
103
+
104
+ **Kind**: inner method of [<code>@openziti/ziti-sdk-nodejs</code>](#module_@openziti/ziti-sdk-nodejs)
105
+ **Returns**: <code>void</code> - No return value.
106
+
107
+ | Param | Type | Description |
108
+ | --- | --- | --- |
109
+ | req | <code>number</code> | A Ziti HttpRequest handle. |
110
+
111
+ <a name="module_@openziti/ziti-sdk-nodejs..init"></a>
112
+
113
+ ### @openziti/ziti-sdk-nodejs~init(identityPath) ⇒ <code>number</code>
114
+ Initialize the Ziti session and authenticate with control plane.
115
+
116
+ **Kind**: inner method of [<code>@openziti/ziti-sdk-nodejs</code>](#module_@openziti/ziti-sdk-nodejs)
117
+ **Returns**: <code>number</code> - A status value ranging from 0 to 255.
118
+
119
+ | Param | Type | Description |
120
+ | --- | --- | --- |
121
+ | identityPath | <code>string</code> | File system path to the identity file. |
122
+
123
+ <a name="module_@openziti/ziti-sdk-nodejs..setLogLevel"></a>
124
+
125
+ ### @openziti/ziti-sdk-nodejs~setLogLevel(level) ⇒ <code>void</code>
126
+ Set the logging level.
127
+
128
+ **Kind**: inner method of [<code>@openziti/ziti-sdk-nodejs</code>](#module_@openziti/ziti-sdk-nodejs)
129
+ **Returns**: <code>void</code> - No return value.
130
+
131
+ | Param | Type | Description |
132
+ | --- | --- | --- |
133
+ | level | <code>number</code> | 0=NONE, 1=ERROR, 2=WARN, 3=INFO, 4=DEBUG, 5=TRACE |
134
+
135
+ <a name="module_@openziti/ziti-sdk-nodejs..serviceAvailable"></a>
136
+
137
+ ### @openziti/ziti-sdk-nodejs~serviceAvailable(serviceName, onServiceAvailable) ⇒ <code>void</code>
138
+ Set the logging level.
139
+
140
+ **Kind**: inner method of [<code>@openziti/ziti-sdk-nodejs</code>](#module_@openziti/ziti-sdk-nodejs)
141
+ **Returns**: <code>void</code> - No return value.
142
+
143
+ | Param | Type | Description |
144
+ | --- | --- | --- |
145
+ | serviceName | <code>string</code> | The name of the Ziti Service being queried. |
146
+ | onServiceAvailable | <code>onServiceAvailableCallback</code> | The callback that returns results of the query. |
147
+
148
+ <a name="module_@openziti/ziti-sdk-nodejs..write"></a>
149
+
150
+ ### @openziti/ziti-sdk-nodejs~write(conn, data, onWrite) ⇒ <code>void</code>
151
+ write data to a Ziti connection.
152
+
153
+ **Kind**: inner method of [<code>@openziti/ziti-sdk-nodejs</code>](#module_@openziti/ziti-sdk-nodejs)
154
+ **Returns**: <code>void</code> - No return value.
155
+
156
+ | Param | Type | Description |
157
+ | --- | --- | --- |
158
+ | conn | <code>number</code> | A Ziti connection handle. |
159
+ | data | <code>Buffer</code> | The data to send. |
160
+ | onWrite | <code>onWriteCallback</code> | The callback that returns status of the write. |
161
+
162
+ <a name="module_@openziti/ziti-sdk-nodejs..onDataCallback"></a>
163
+
164
+ ### @openziti/ziti-sdk-nodejs~onDataCallback : <code>function</code>
165
+ This callback is part of the `dial` API.
166
+
167
+ **Kind**: inner typedef of [<code>@openziti/ziti-sdk-nodejs</code>](#module_@openziti/ziti-sdk-nodejs)
168
+
169
+ | Param | Type | Description |
170
+ | --- | --- | --- |
171
+ | conn | <code>number</code> | A Ziti connection handle. |
172
+
173
+ <a name="module_@openziti/ziti-sdk-nodejs..onConnectCallback"></a>
174
+
175
+ ### @openziti/ziti-sdk-nodejs~onConnectCallback ⇒ <code>void</code>
176
+ This callback is part of the `dial` API.
177
+
178
+ **Kind**: inner typedef of [<code>@openziti/ziti-sdk-nodejs</code>](#module_@openziti/ziti-sdk-nodejs)
179
+ **Returns**: <code>void</code> - No return value.
180
+
181
+ | Param | Type | Description |
182
+ | --- | --- | --- |
183
+ | data | <code>Buffer</code> | Incoming data from the Ziti connection. |
184
+
185
+ <a name="module_@openziti/ziti-sdk-nodejs..onRequestCallback"></a>
186
+
187
+ ### @openziti/ziti-sdk-nodejs~onRequestCallback ⇒ <code>void</code>
188
+ This callback is part of the `httpRequest` API.
189
+
190
+ **Kind**: inner typedef of [<code>@openziti/ziti-sdk-nodejs</code>](#module_@openziti/ziti-sdk-nodejs)
191
+ **Returns**: <code>void</code> - No return value.
192
+
193
+ | Param | Type | Description |
194
+ | --- | --- | --- |
195
+ | req | <code>number</code> | A Ziti HttpRequest handle. |
196
+
197
+ <a name="module_@openziti/ziti-sdk-nodejs..onResonseCallback"></a>
198
+
199
+ ### @openziti/ziti-sdk-nodejs~onResonseCallback ⇒ <code>void</code>
200
+ This callback is part of the `httpRequest` API.
201
+
202
+ **Kind**: inner typedef of [<code>@openziti/ziti-sdk-nodejs</code>](#module_@openziti/ziti-sdk-nodejs)
203
+ **Returns**: <code>void</code> - No return value.
204
+
205
+ | Param | Description |
206
+ | --- | --- |
207
+ | resp | Incoming response from the HTTP request. |
208
+ | resp.req | The request handle. |
209
+ | resp.code | The HTTP status code. |
210
+ | resp.headers | The HTTP Headers on the response. |
211
+
212
+ <a name="module_@openziti/ziti-sdk-nodejs..onResonseDataCallback"></a>
213
+
214
+ ### @openziti/ziti-sdk-nodejs~onResonseDataCallback ⇒ <code>void</code>
215
+ This callback is part of the `httpRequest` API.
216
+
217
+ **Kind**: inner typedef of [<code>@openziti/ziti-sdk-nodejs</code>](#module_@openziti/ziti-sdk-nodejs)
218
+ **Returns**: <code>void</code> - No return value.
219
+
220
+ | Param | Description |
221
+ | --- | --- |
222
+ | respData | Incoming response data from the HTTP request. |
223
+ | respData.req | The request handle. |
224
+ | respData.len | The length of the response body. |
225
+ | respData.body | The response body. |
226
+
227
+ <a name="module_@openziti/ziti-sdk-nodejs..onRequestDataCallback"></a>
228
+
229
+ ### @openziti/ziti-sdk-nodejs~onRequestDataCallback ⇒ <code>void</code>
230
+ This callback is part of the `httpRequestData` API.
231
+
232
+ **Kind**: inner typedef of [<code>@openziti/ziti-sdk-nodejs</code>](#module_@openziti/ziti-sdk-nodejs)
233
+ **Returns**: <code>void</code> - No return value.
234
+
235
+ | Param | Description |
236
+ | --- | --- |
237
+ | reqData | Incoming status data from the HTTP request. |
238
+ | respData.req | The request handle. |
239
+ | respData.status | positive value indicates successful transmit. |
240
+
241
+ <a name="module_@openziti/ziti-sdk-nodejs..onServiceAvailableCallback"></a>
242
+
243
+ ### @openziti/ziti-sdk-nodejs~onServiceAvailableCallback ⇒ <code>void</code>
244
+ This callback is part of the `serviceAvailable` API.
245
+
246
+ **Kind**: inner typedef of [<code>@openziti/ziti-sdk-nodejs</code>](#module_@openziti/ziti-sdk-nodejs)
247
+ **Returns**: <code>void</code> - No return value.
248
+
249
+ | Param | Description |
250
+ | --- | --- |
251
+ | availability | results of the query. |
252
+ | availability.status | 0 means `available and OK`, <0 means `unavailable` |
253
+ | availability.permissions | 1 means the identity can dial, 2 means the identity can bind |
254
+
255
+ <a name="module_@openziti/ziti-sdk-nodejs..onWriteCallback"></a>
256
+
257
+ ### @openziti/ziti-sdk-nodejs~onWriteCallback ⇒ <code>void</code>
258
+ This callback is part of the `write` API.
259
+
260
+ **Kind**: inner typedef of [<code>@openziti/ziti-sdk-nodejs</code>](#module_@openziti/ziti-sdk-nodejs)
261
+ **Returns**: <code>void</code> - No return value.
262
+
263
+ | Param | Description |
264
+ | --- | --- |
265
+ | status | 0 means success, <0 means failure. |
266
+
267
+
268
+ * * *
package/README.hbs ADDED
@@ -0,0 +1,227 @@
1
+ <p align="center" width="100%">
2
+ OpenZiti is a free and open source project focused on bringing zero trust to any application.
3
+ <br>
4
+ The project provides all the pieces required to implement or integrate zero trust into your solutions.
5
+ <br/>
6
+ <br/>
7
+ Please star us.
8
+ <br/>
9
+ <a href="https://github.com/openziti/ziti/stargazers"><img src="https://img.shields.io/github/stars/openziti/ziti?style=flat" ></a>
10
+ <br/>
11
+ <br>
12
+ </p>
13
+
14
+ <p align="center" width="100%">
15
+ <a href="https://openziti.io"><img src="ziti.png" width="100"></a>
16
+ </p>
17
+
18
+ <p align="center">
19
+ <b>
20
+ <a>@openziti/ziti-sdk-nodejs</a>
21
+ <br>
22
+ <br>
23
+ <b>
24
+ This repo hosts the OpenZiti SDK for NodeJS, and is designed to help you deliver secure applications over a <a href="https://openziti.io">OpenZiti Network</a>
25
+ <br>
26
+ <br>
27
+ <b>Part of the <a href="https://openziti.io/about">OpenZiti</a> ecosystem</b>
28
+ </p>
29
+
30
+ <p align="center">
31
+ <br>
32
+ <b>Are you interested in knowing how to easily embed programmable, high performance, zero trust networking into your NodeJS app, on any internet connection, without VPNs?
33
+ <br>
34
+ Learn more about our <a href="https://openziti.io/about">OpenZiti</a> project.</b>
35
+ <br>
36
+ </p>
37
+
38
+ ---
39
+ [![Build Status](https://github.com/openziti/ziti-sdk-nodejs/workflows/Build/badge.svg?branch=main)]()
40
+ [![Issues](https://img.shields.io/github/issues-raw/openziti/ziti-sdk-nodejs)]()
41
+ [![npm version](https://badge.fury.io/js/@openziti%2Fziti-sdk-nodejs.svg)](https://badge.fury.io/js/@openziti%2Fziti-sdk-nodejs.svg)
42
+ [![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
43
+ [![LOC](https://img.shields.io/tokei/lines/github/openziti/ziti-sdk-nodejs)]()
44
+ [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=rounded)](CONTRIBUTING.md)
45
+ [![Contributor Covenant](https://img.shields.io/badge/Contributor%20Covenant-v2.0%20adopted-ff69b4.svg)](CODE_OF_CONDUCT.md)
46
+
47
+ ---
48
+
49
+ # Associated Article(s)
50
+ For more context on this SDK, you may be interested in this
51
+ [article concerning how to secure NodeJS applications](https://openziti.io/securing-nodejs-applications)
52
+
53
+
54
+
55
+ # Supported platforms
56
+
57
+ The `@openziti/ziti-sdk-nodejs` module works with the following Node.js versions:
58
+ - v12.x
59
+ - v13.x
60
+ - v14.x
61
+ - v15.x
62
+ - v16.x
63
+ - v17.x
64
+ - v18.x
65
+
66
+ Binaries for most Node versions and platforms are provided by default via [@mapbox/node-pre-gyp](https://github.com/mapbox/node-pre-gyp).
67
+
68
+ # Installing
69
+
70
+ NPM
71
+ ``` js
72
+ npm i @openziti/ziti-sdk-nodejs
73
+ ```
74
+ or Yarn
75
+ ``` js
76
+ yarn add @openziti/ziti-sdk-nodejs
77
+ ```
78
+
79
+ Special note on previous package:
80
+
81
+ On June 7, 2020 @openziti/ziti-sdk-nodejs@0.6.0 was released. Older, unscoped versions that are not part of the @openziti org are deprecated and only @openziti/ziti-sdk-nodejs will see updates going forward. To upgrade to the new package do:
82
+
83
+ ``` js
84
+ npm uninstall ziti-sdk-nodejs --save
85
+ npm install @openziti/ziti-sdk-nodejs --save
86
+ ```
87
+
88
+ # Usage
89
+
90
+ **Note:** the module must be [installed](#installing) before use.
91
+
92
+ ESM example (client-side)
93
+ ``` js
94
+ import ziti from '@openziti/ziti-sdk-nodejs';
95
+
96
+ // Somehow provide path to identity file, e.g. via env var
97
+ const zitiIdentityFile = process.env.ZITI_IDENTITY_FILE;
98
+ // Authenticate ourselves onto the Ziti network
99
+ await ziti.init( zitiIdentityFile ).catch(( err ) => { /* probably exit */ });
100
+
101
+ const on_resp_data = ( obj ) => {
102
+ console.log(`response is: ${obj.body.toString('utf8')}`);
103
+ };
104
+
105
+ // Perform an HTTP GET request to a dark OpenZiti web service
106
+ ziti.httpRequest(
107
+ 'myDarkWebService', // OpenZiti Service name or HTTP origin part of the URL
108
+ 'GET',
109
+ '/', // path part of the URL including query params
110
+ ['Accept: application/json' ], // headers
111
+ undefined, // optional on_req cb
112
+ undefined, // optional on_req_data cb
113
+ on_resp_data // optional on_resp_data cb
114
+ );
115
+
116
+ ```
117
+
118
+ ESM example (server-side ExpressJS)
119
+ ``` js
120
+ import ziti from '@openziti/ziti-sdk-nodejs';
121
+ import express from 'express';
122
+ let app = ziti.express( express, zitiServiceName );
123
+ app.listen(ignored, function() { ... }
124
+
125
+ /**
126
+
127
+ That's right.
128
+
129
+ With only a single-line code change (the ziti.express call), your web server is now capable
130
+ of being invisible to malicious attackers on the internet, and only accessible to your
131
+ trusted remote users.
132
+
133
+ Nothing else in your existing ExpressJS web server code needs to change!
134
+
135
+ Existing routing, middleware, etc., all operates the same as it always did...
136
+ but now you enjoy the comfort of knowing that if a connection comes in, it is from
137
+ a trusted identity on the client side.
138
+
139
+ No malicious actors can see your dark web server, and thus, no malicious actors can attack it.
140
+
141
+ */
142
+ ```
143
+
144
+ CJS example (client-side)
145
+ ``` js
146
+ var ziti = require('@openziti/ziti-sdk-nodejs');
147
+
148
+ const ziti_init = async (identity) => {
149
+ return new Promise((resolve) => {
150
+ ziti.ziti_init(identity, () => {
151
+ resolve();
152
+ });
153
+ });
154
+ };
155
+
156
+ const ziti_service_available = (service) => {
157
+ return new Promise((resolve) => {
158
+ ziti.ziti_service_available(service, (status) => {
159
+ resolve(status);
160
+ });
161
+ });
162
+ };
163
+
164
+ function ziti_dial(service) {
165
+ return new Promise((resolve, reject) => {
166
+ ziti.ziti_dial(
167
+ service,
168
+ (conn) => {
169
+ resolve(conn);
170
+ },
171
+ (data) => {
172
+ // Do something with data...
173
+ },
174
+ );
175
+ });
176
+ }
177
+
178
+ const ziti_write = (conn, data) => {
179
+ return new Promise((resolve) => {
180
+ ziti.ziti_write(conn, data, () => {
181
+ resolve();
182
+ });
183
+ });
184
+ };
185
+
186
+ (async () => {
187
+
188
+ await ziti_init(LOCATION_OF_IDENTITY_FILE);
189
+
190
+ let status = await ziti_service_available(YOUR_SERVICE_NAME);
191
+
192
+ if (status === 0) {
193
+
194
+ const conn = await ziti_dial(YOUR_SERVICE_NAME);
195
+
196
+ let data = SOME_KIND_OF_DATA;
197
+
198
+ let buffer = Buffer.from(data);
199
+
200
+ await ziti_write(conn, buffer);
201
+
202
+ ...etc
203
+ }
204
+
205
+ })();
206
+ ```
207
+
208
+ # API Reference
209
+ {{#module name="@openziti/ziti-sdk-nodejs"}}
210
+ {{>body~}}
211
+ {{>member-index~}}
212
+ {{>separator~}}
213
+ {{>members~}}
214
+ {{/module}}
215
+
216
+ * * *
217
+
218
+ Getting Help
219
+ ------------
220
+ Please use these community resources for getting help. We use GitHub [issues](https://github.com/openziti/ziti-sdk-nodejs/issues)
221
+ for tracking bugs and feature requests and have limited bandwidth to address them.
222
+
223
+ - Read the [docs](https://openziti.github.io/ziti/overview.html)
224
+ - Participate in discussion on [Discourse](https://openziti.discourse.group/)
225
+
226
+
227
+ Copyright&copy; NetFoundry, Inc.
package/README.md CHANGED
@@ -205,33 +205,9 @@ const ziti_write = (conn, data) => {
205
205
  })();
206
206
  ```
207
207
 
208
-
209
- # Ziti NodeJS SDK - Setup for Development
210
-
211
- NOTE: You don't need to compile this SDK in order to use it (we publish pre-built binaries for your OS, NodeJS version, and CPU architecture).
212
- The following information applies only if you are doing development on the SDK itself.
213
-
214
- The following steps should get your NodeJS SDK for Ziti building. The Ziti NodeJS SDK is a native addon for Node JS,
215
- and is written in C. C development is specific to your operating system and tool chain used. These steps should work
216
- properly for you but if your OS has variations you may need to adapt these steps accordingly.
217
-
218
-
219
- ## Prerequisites
220
-
221
- ### Build
222
-
223
- * [Cmake (3.12+)](https://cmake.org/install/)
224
-
225
-
226
- ## Build
227
-
228
- ### Linux/MacOS
229
-
230
- Building the NodeJS SDK on linux/mac can be accomplished with:
231
-
232
- ```bash
233
- $ npm run build
234
- ```
208
+ # API Reference
209
+ For doc concerning API's contained in this SDK, you may be interested in this
210
+ [SDK API Reference](API_REFERENCE.md)
235
211
 
236
212
 
237
213
  Getting Help
package/jsdoc.json ADDED
@@ -0,0 +1,24 @@
1
+ {
2
+ "tags": {
3
+ "allowUnknownTags": false
4
+ },
5
+ "source": {
6
+ "include": "./lib",
7
+ "includePattern": "\\.js$",
8
+ "excludePattern": "(node_modules/|docs)"
9
+ },
10
+ "plugins": [
11
+ "plugins/markdown"
12
+ ],
13
+ "opts": {
14
+ "template": "node_modules/docdash",
15
+ "encoding": "utf8",
16
+ "destination": "docs/",
17
+ "recurse": true,
18
+ "verbose": true
19
+ },
20
+ "templates": {
21
+ "cleverLinks": false,
22
+ "monospaceLinks": false
23
+ }
24
+ }
package/lib/close.js CHANGED
@@ -20,7 +20,7 @@ limitations under the License.
20
20
  *
21
21
  * @param {*} conn
22
22
  */
23
- const close = ( conn, ) => {
23
+ const close = ( conn ) => {
24
24
 
25
25
  ziti.ziti_close( conn );
26
26
 
@@ -85,7 +85,6 @@ Server.prototype.on_listen = ( status ) => {
85
85
  /**
86
86
  *
87
87
  * @param {*} args
88
- * @returns
89
88
  */
90
89
  function normalizeArgs(args) {
91
90
  let arr;
@@ -46,9 +46,7 @@ const on_resp_data = ( obj ) => {
46
46
 
47
47
  };
48
48
 
49
- const httpRequest = ( url, method, path, headers, on_req_cb, on_resp_cb, on_resp_data_cb ) => {
50
-
51
- console.log(`httpRequest entered: httpOrigin|serviceName: "${url}", method: "${method}", path: "${path}", headers: "${headers}"`);
49
+ const httpRequest = ( serviceName, schemeHostPort, method, path, headers, on_req_cb, on_resp_cb, on_resp_data_cb ) => {
52
50
 
53
51
  let _on_req_cb;
54
52
  let _on_resp_cb;
@@ -72,7 +70,7 @@ const httpRequest = ( url, method, path, headers, on_req_cb, on_resp_cb, on_resp
72
70
  _on_resp_data_cb = on_resp_data_cb;
73
71
  }
74
72
 
75
- ziti.Ziti_http_request( url, method, path, headers, _on_req_cb, _on_resp_cb, _on_resp_data_cb );
73
+ ziti.Ziti_http_request( serviceName, schemeHostPort, method, path, headers, _on_req_cb, _on_resp_cb, _on_resp_data_cb );
76
74
 
77
75
  };
78
76
 
@@ -0,0 +1,23 @@
1
+ /*
2
+ Copyright Netfoundry, Inc.
3
+
4
+ Licensed under the Apache License, Version 2.0 (the "License");
5
+ you may not use this file except in compliance with the License.
6
+ You may obtain a copy of the License at
7
+
8
+ https://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software
11
+ distributed under the License is distributed on an "AS IS" BASIS,
12
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ See the License for the specific language governing permissions and
14
+ limitations under the License.
15
+ */
16
+
17
+
18
+ const httpRequestEnd = ( req ) => {
19
+ ziti.Ziti_http_request_end( req );
20
+ };
21
+
22
+ exports.httpRequestEnd = httpRequestEnd;
23
+
package/lib/init.js CHANGED
@@ -15,13 +15,7 @@ limitations under the License.
15
15
  */
16
16
 
17
17
 
18
- /**
19
- * init()
20
- *
21
- * @param {*} identityPath
22
- * @returns
23
- */
24
- const init = ( identityPath ) => {
18
+ const init = ( identityPath ) => {
25
19
 
26
20
  return new Promise((resolve, reject) => {
27
21
 
package/lib/listen.js CHANGED
@@ -19,7 +19,6 @@ limitations under the License.
19
19
  * listen()
20
20
  *
21
21
  * @param {*} identityPath
22
- * @returns
23
22
  */
24
23
  const listen = ( serviceName, js_arb_data, on_listen, on_listen_client, on_client_connect, on_client_data ) => {
25
24
 
package/lib/ziti.js CHANGED
@@ -14,6 +14,13 @@ See the License for the specific language governing permissions and
14
14
  limitations under the License.
15
15
  */
16
16
 
17
+ /**
18
+ * OpenZiti SDK for Node.js
19
+ *
20
+ * @module @openziti/ziti-sdk-nodejs
21
+ *
22
+ */
23
+
17
24
  var binding;
18
25
 
19
26
  function importAll (r) {
@@ -43,13 +50,160 @@ ziti = module.exports = exports = binding;
43
50
  /**
44
51
  * Attach the external, app-facing, API to the 'ziti' object
45
52
  */
53
+
54
+ /**
55
+ * Close a Ziti connection.
56
+ * @function close
57
+ * @param {number} conn - A Ziti connection handle.
58
+ * @returns {void} No return value.
59
+ */
46
60
  exports.close = require('./close').close;
61
+
62
+ /**
63
+ * Create a connection to Ziti Service.
64
+ * @async
65
+ * @function dial
66
+ * @param {string} serviceName - The name of the Ziti Service to connect to
67
+ * @param {boolean} isWebSocket - True or False indicator concerning whether this connection if bi-directional.
68
+ * @param {onConnectCallback} onConnect - The callback that receives the connection handle.
69
+ * @param {onDataCallback} onData - The callback that receives incoming data from the connection.
70
+ * @returns {void} No return value.
71
+ */
72
+ /**
73
+ * This callback is part of the `dial` API.
74
+ * @callback onDataCallback - The callback that receives the connection handle.
75
+ * @param {number} conn - A Ziti connection handle.
76
+ */
77
+ /**
78
+ * This callback is part of the `dial` API.
79
+ * @callback onConnectCallback - The callback that receives incoming data from the connection.
80
+ * @param {Buffer} data - Incoming data from the Ziti connection.
81
+ * @returns {void} No return value.
82
+ */
47
83
  exports.dial = require('./dial').dial;
84
+
85
+ /**
86
+ * Wrap ExpressJS to facilitate hosting (listening) on a Ziti Service instead of a TCP port.
87
+ * @function express
88
+ * @param {*} express - The express() object.
89
+ * @param {string} serviceName - The name of the Ziti Service being served (hosted).
90
+ * @returns {*} The wrapped express() object.
91
+ */
48
92
  exports.express = require('./express').express;
93
+
94
+ /**
95
+ * Initiate an HTTP request to a Ziti Service.
96
+ * @function httpRequest
97
+ * @param {string} serviceName - The name of the Ziti Service to send the request. (mutually exclusive with url)
98
+ * @param {string} schemeHostPort - The scheme/host/port (e.g. http://myserver.ziti:8080) of a Ziti service-config/intercept to send the request. (mutually exclusive with serviceName)
99
+ * @param {string} method - The REST verb to use (e.g. `GET`, `POST`).
100
+ * @param {string} path - The URL PATH to use on the request (can include HTTP query parms).
101
+ * @param {string[]} headers - The HTTP Headers to use on the request.
102
+ * @param {onRequestCallback} onRequest - The callback that receives the request handle.
103
+ * @param {onResonseCallback} onResponse - The callback that receives the HTTP Response.
104
+ * @param {onResonseDataCallback} onResponseData - The callback that receives the HTTP Response data.
105
+ * @returns {void} No return value.
106
+ */
107
+ /**
108
+ * This callback is part of the `httpRequest` API.
109
+ * @callback onRequestCallback - The callback that receives the request handle.
110
+ * @param {number} req - A Ziti HttpRequest handle.
111
+ * @returns {void} No return value.
112
+ */
113
+ /**
114
+ * This callback is part of the `httpRequest` API.
115
+ * @callback onResonseCallback - The callback that receives response from the request.
116
+ * @param resp - Incoming response from the HTTP request.
117
+ * @param resp.req - The request handle.
118
+ * @param resp.code - The HTTP status code.
119
+ * @param resp.headers - The HTTP Headers on the response.
120
+ * @returns {void} No return value.
121
+ */
122
+ /**
123
+ * This callback is part of the `httpRequest` API.
124
+ * @callback onResonseDataCallback - The callback that receives incoming data from the request.
125
+ * @param respData - Incoming response data from the HTTP request.
126
+ * @param respData.req - The request handle.
127
+ * @param respData.len - The length of the response body.
128
+ * @param respData.body - The response body.
129
+ * @returns {void} No return value.
130
+ */
49
131
  exports.httpRequest = require('./httpRequest').httpRequest;
50
- exports.httpRequestData = require('./httpRequestData').httpRequestData;
132
+
133
+ /**
134
+ * Send payload data for HTTP POST request to a Ziti Service.
135
+ * @function httpRequestData
136
+ * @param {number} req - A Ziti HttpRequest handle.
137
+ * @param {Buffer} data - The HTTP payload data to send.
138
+ * @param {onRequestDataCallback} onRequestData - The callback that acknowleges the send.
139
+ * @returns {void} No return value.
140
+ */
141
+ /**
142
+ * This callback is part of the `httpRequestData` API.
143
+ * @callback onRequestDataCallback - The callback that acknowleges the send.
144
+ * @param reqData - Incoming status data from the HTTP request.
145
+ * @param respData.req - The request handle.
146
+ * @param respData.status - positive value indicates successful transmit.
147
+ * @returns {void} No return value.
148
+ */
149
+ exports.httpRequestData = require('./httpRequestData').httpRequestData;
150
+
151
+ /**
152
+ * Terminate payload data transmission for HTTP POST request to a Ziti Service.
153
+ * @function httpRequestEnd
154
+ * @param {number} req - A Ziti HttpRequest handle.
155
+ * @returns {void} No return value.
156
+ */
157
+ exports.httpRequestEnd = require('./httpRequestEnd').httpRequestEnd;
158
+
159
+ /**
160
+ * Initialize the Ziti session and authenticate with control plane.
161
+ * @function init
162
+ * @param {string} identityPath - File system path to the identity file.
163
+ * @returns {number} A status value ranging from 0 to 255.
164
+ */
51
165
  exports.init = require('./init').init;
166
+
167
+ // Internal use only
52
168
  exports.listen = require('./listen').listen;
169
+
170
+ /**
171
+ * Set the logging level.
172
+ * @function setLogLevel
173
+ * @param {number} level - 0=NONE, 1=ERROR, 2=WARN, 3=INFO, 4=DEBUG, 5=TRACE
174
+ * @returns {void} No return value.
175
+ */
53
176
  exports.setLogLevel = require('./setLogLevel').setLogLevel;
177
+
178
+ /**
179
+ * Set the logging level.
180
+ * @function serviceAvailable
181
+ * @param {string} serviceName - The name of the Ziti Service being queried.
182
+ * @param {onServiceAvailableCallback} onServiceAvailable - The callback that returns results of the query.
183
+ * @returns {void} No return value.
184
+ */
185
+ /**
186
+ * This callback is part of the `serviceAvailable` API.
187
+ * @callback onServiceAvailableCallback - The callback that returns results of the query.
188
+ * @param availability - results of the query.
189
+ * @param availability.status - 0 means `available and OK`, <0 means `unavailable`
190
+ * @param availability.permissions - 1 means the identity can dial, 2 means the identity can bind
191
+ * @returns {void} No return value.
192
+ */
54
193
  exports.serviceAvailable = require('./serviceAvailable').serviceAvailable;
55
- exports.write = require('./write').write;
194
+
195
+ /**
196
+ * write data to a Ziti connection.
197
+ * @function write
198
+ * @param {number} conn - A Ziti connection handle.
199
+ * @param {Buffer} data - The data to send.
200
+ * @param {onWriteCallback} onWrite - The callback that returns status of the write.
201
+ * @returns {void} No return value.
202
+ */
203
+ /**
204
+ * This callback is part of the `write` API.
205
+ * @callback onWriteCallback - The callback that returns results of the v.
206
+ * @param status - 0 means success, <0 means failure.
207
+ * @returns {void} No return value.
208
+ */
209
+ exports.write = require('./write').write;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@openziti/ziti-sdk-nodejs",
3
3
  "description": "A NodeJS-based SDK for delivering secure applications over a Ziti Network",
4
- "version": "0.13.2",
4
+ "version": "0.13.3",
5
5
  "main": "./lib/ziti",
6
6
  "scripts": {
7
7
  "build": "npm run build:init; npm run build:c-sdk; npm install --build-from-source --clang=1",
@@ -16,7 +16,8 @@
16
16
  "start": "node main.js ./config/identity.json chapel-hill",
17
17
  "install": "node-pre-gyp install --fallback-to-build",
18
18
  "install-dbg": "npm install --build-from-source --clang=1 --debug",
19
- "publish": "node-pre-gyp package publish"
19
+ "publish": "node-pre-gyp package publish",
20
+ "docs": "jsdoc2md -t API_REFERENCE.hbs lib/*.js > API_REFERENCE.md"
20
21
  },
21
22
  "repository": {
22
23
  "type": "git",
@@ -48,7 +49,10 @@
48
49
  "url": "http://netfoundry.io"
49
50
  },
50
51
  "devDependencies": {
51
- "aws-sdk": "^2.823.0"
52
+ "aws-sdk": "^2.823.0",
53
+ "docdash": "^1.2.0",
54
+ "jsdoc": "^3.6.11",
55
+ "jsdoc-to-markdown": "^7.1.1"
52
56
  },
53
57
  "dependencies": {
54
58
  "@mapbox/node-pre-gyp": "^1.0.8"
@@ -750,15 +750,15 @@ napi_value _Ziti_http_request(napi_env env, const napi_callback_info info) {
750
750
  HttpsClientListMap = newListMap();
751
751
  }
752
752
 
753
- size_t argc = 7;
754
- napi_value args[7];
753
+ size_t argc = 8;
754
+ napi_value args[8];
755
755
  status = napi_get_cb_info(env, info, &argc, args, NULL, NULL);
756
756
  if (status != napi_ok) {
757
757
  napi_throw_error(env, NULL, "Failed to parse arguments");
758
758
  return NULL;
759
759
  }
760
760
 
761
- if (argc < 7) {
761
+ if (argc < 8) {
762
762
  napi_throw_error(env, "EINVAL", "Too few arguments");
763
763
  return NULL;
764
764
  }
@@ -767,39 +767,86 @@ napi_value _Ziti_http_request(napi_env env, const napi_callback_info info) {
767
767
  ZITI_NODEJS_LOG(DEBUG, "allocated addon_data : %p", addon_data);
768
768
  addon_data->env = env;
769
769
 
770
- // Obtain serviceName length
771
- size_t serviceName_len;
772
- status = napi_get_value_string_utf8(env, args[0], NULL, 0, &serviceName_len);
773
- if (status != napi_ok) {
774
- napi_throw_error(env, "EINVAL", "serviceName is not a string");
775
- return NULL;
770
+ bool serviceNameSpecified = false;
771
+
772
+ // Determine if the serviceName arg was specified
773
+ napi_valuetype valuetype;
774
+ status = napi_typeof(env, args[0], &valuetype);
775
+ if (valuetype != napi_undefined) {
776
+ ZITI_NODEJS_LOG(DEBUG, "serviceName is specified");
777
+ serviceNameSpecified = true;
776
778
  }
777
779
 
778
- // Obtain serviceName
779
- char* serviceName = calloc(1, serviceName_len+2);
780
- status = napi_get_value_string_utf8(env, args[0], serviceName, serviceName_len+1, &result);
781
- if (status != napi_ok) {
782
- napi_throw_error(env, "EINVAL", "Failed to obtain serviceName");
780
+ bool schemeHostPortSpecified = false;
781
+
782
+ // Determine if the schemeHostPort arg was specified
783
+ status = napi_typeof(env, args[1], &valuetype);
784
+ if (valuetype != napi_undefined) {
785
+ ZITI_NODEJS_LOG(DEBUG, "schemeHostPort is specified");
786
+ schemeHostPortSpecified = true;
787
+ }
788
+
789
+ if (serviceNameSpecified && schemeHostPortSpecified) {
790
+ napi_throw_error(env, "EINVAL", "both serviceName and schemeHostPort were specified; they are mutually exclusive");
791
+ return NULL;
792
+ }
793
+ if (!serviceNameSpecified && !schemeHostPortSpecified) {
794
+ napi_throw_error(env, "EINVAL", "both serviceName and schemeHostPort were unspecified; must specify one");
783
795
  return NULL;
784
796
  }
785
797
 
786
- bool haveURL = false;
787
- struct http_parser_url url_parse = {0};
788
- rc = http_parser_parse_url(serviceName, strlen(serviceName), false, &url_parse);
789
- if (rc == 0) {
790
- haveURL = true;
791
- ZITI_NODEJS_LOG(DEBUG, "serviceName IS a URL");
792
- } else {
793
- ZITI_NODEJS_LOG(DEBUG, "serviceName is NOT a URL");
798
+ char* serviceName;
799
+
800
+ if (serviceNameSpecified) {
801
+ // Obtain serviceName length
802
+ size_t serviceName_len;
803
+ status = napi_get_value_string_utf8(env, args[0], NULL, 0, &serviceName_len);
804
+ if (status != napi_ok) {
805
+ napi_throw_error(env, "EINVAL", "serviceName is not a string");
806
+ return NULL;
807
+ }
808
+
809
+ // Obtain serviceName
810
+ serviceName = calloc(1, serviceName_len+2);
811
+ status = napi_get_value_string_utf8(env, args[0], serviceName, serviceName_len+1, &result);
812
+ if (status != napi_ok) {
813
+ napi_throw_error(env, "EINVAL", "Failed to obtain serviceName");
814
+ return NULL;
815
+ }
794
816
  }
795
817
 
796
- struct hostname_port* hostname_port = NULL;
818
+ char* schemeHostPort;
797
819
 
798
- if (haveURL) {
820
+ if (schemeHostPortSpecified) {
821
+ // Obtain schemeHostPort length
822
+ size_t schemeHostPort_len;
823
+ status = napi_get_value_string_utf8(env, args[1], NULL, 0, &schemeHostPort_len);
824
+ if (status != napi_ok) {
825
+ napi_throw_error(env, "EINVAL", "schemeHostPort is not a string");
826
+ return NULL;
827
+ }
799
828
 
800
- addon_data->scheme_host_port = strdup(serviceName);
829
+ // Obtain schemeHostPort
830
+ schemeHostPort = calloc(1, schemeHostPort_len+2);
831
+ status = napi_get_value_string_utf8(env, args[1], schemeHostPort, schemeHostPort_len+1, &result);
832
+ if (status != napi_ok) {
833
+ napi_throw_error(env, "EINVAL", "Failed to obtain schemeHostPort");
834
+ return NULL;
835
+ }
836
+
837
+ struct http_parser_url url_parse = {0};
838
+ rc = http_parser_parse_url(schemeHostPort, strlen(schemeHostPort), false, &url_parse);
839
+ if (rc != 0) {
840
+ napi_throw_error(env, "EINVAL", "schemeHostPort is not a valid URL");
841
+ return NULL;
842
+ }
801
843
 
802
- } else {
844
+ addon_data->scheme_host_port = strdup(schemeHostPort);
845
+ addon_data->haveURL = true;
846
+
847
+ } else if (serviceNameSpecified) {
848
+
849
+ struct hostname_port* hostname_port = NULL;
803
850
 
804
851
  hostname_port = getHostnamePortForService(serviceName);
805
852
  if (NULL == hostname_port) {
@@ -825,20 +872,18 @@ napi_value _Ziti_http_request(napi_env env, const napi_callback_info info) {
825
872
  }
826
873
  }
827
874
 
828
- addon_data->haveURL = haveURL;
829
-
830
- ZITI_NODEJS_LOG(DEBUG, "scheme_host_port: %s, haveURL: %d", addon_data->scheme_host_port, haveURL);
875
+ ZITI_NODEJS_LOG(DEBUG, "scheme_host_port: %s, haveURL: %d", addon_data->scheme_host_port, addon_data->haveURL);
831
876
 
832
877
  // Obtain method length
833
878
  size_t method_len;
834
- status = napi_get_value_string_utf8(env, args[1], NULL, 0, &method_len);
879
+ status = napi_get_value_string_utf8(env, args[2], NULL, 0, &method_len);
835
880
  if (status != napi_ok) {
836
881
  napi_throw_error(env, "EINVAL", "method is not a string");
837
882
  return NULL;
838
883
  }
839
884
  // Obtain method
840
885
  addon_data->method = calloc(1, method_len+2);
841
- status = napi_get_value_string_utf8(env, args[1], addon_data->method, method_len+1, &result);
886
+ status = napi_get_value_string_utf8(env, args[2], addon_data->method, method_len+1, &result);
842
887
  if (status != napi_ok) {
843
888
  napi_throw_error(env, "EINVAL", "Failed to obtain method");
844
889
  return NULL;
@@ -848,14 +893,14 @@ napi_value _Ziti_http_request(napi_env env, const napi_callback_info info) {
848
893
 
849
894
  // Obtain path length
850
895
  size_t path_len;
851
- status = napi_get_value_string_utf8(env, args[2], NULL, 0, &path_len);
896
+ status = napi_get_value_string_utf8(env, args[3], NULL, 0, &path_len);
852
897
  if (status != napi_ok) {
853
898
  napi_throw_error(env, "EINVAL", "path is not a string");
854
899
  return NULL;
855
900
  }
856
901
  // Obtain path
857
902
  addon_data->path = calloc(1, path_len+2);
858
- status = napi_get_value_string_utf8(env, args[2], addon_data->path, path_len+1, &result);
903
+ status = napi_get_value_string_utf8(env, args[3], addon_data->path, path_len+1, &result);
859
904
  if (status != napi_ok) {
860
905
  napi_throw_error(env, "EINVAL", "Failed to obtain path");
861
906
  return NULL;
@@ -864,7 +909,7 @@ napi_value _Ziti_http_request(napi_env env, const napi_callback_info info) {
864
909
  ZITI_NODEJS_LOG(DEBUG, "path: %s", addon_data->path);
865
910
 
866
911
  // Obtain ptr to JS on_req callback function
867
- napi_value js_cb = args[4];
912
+ napi_value js_cb = args[5];
868
913
  napi_value work_name;
869
914
 
870
915
 
@@ -901,7 +946,7 @@ napi_value _Ziti_http_request(napi_env env, const napi_callback_info info) {
901
946
  ZITI_NODEJS_LOG(DEBUG, "napi_create_threadsafe_function addon_data->tsfn_on_req() : %p", addon_data->tsfn_on_req);
902
947
 
903
948
  // Obtain ptr to JS on_resp callback function
904
- napi_value js_cb2 = args[5];
949
+ napi_value js_cb2 = args[6];
905
950
 
906
951
  // Create a string to describe this asynchronous operation.
907
952
  rc = napi_create_string_utf8(env, "on_resp", NAPI_AUTO_LENGTH, &work_name);
@@ -933,7 +978,7 @@ napi_value _Ziti_http_request(napi_env env, const napi_callback_info info) {
933
978
 
934
979
 
935
980
  // Obtain ptr to JS on_resp_data callback function
936
- napi_value js_cb3 = args[6];
981
+ napi_value js_cb3 = args[7];
937
982
 
938
983
  // Create a string to describe this asynchronous operation.
939
984
  rc = napi_create_string_utf8(env, "on_resp_data", NAPI_AUTO_LENGTH, &work_name);
@@ -967,7 +1012,7 @@ napi_value _Ziti_http_request(napi_env env, const napi_callback_info info) {
967
1012
  // Capture headers
968
1013
  //
969
1014
  uint32_t i;
970
- status = napi_get_array_length(env, args[3], &addon_data->headers_array_length);
1015
+ status = napi_get_array_length(env, args[4], &addon_data->headers_array_length);
971
1016
  if (status != napi_ok) {
972
1017
  napi_throw_error(env, "EINVAL", "Failed to obtain headers array");
973
1018
  return NULL;
@@ -976,7 +1021,7 @@ napi_value _Ziti_http_request(napi_env env, const napi_callback_info info) {
976
1021
  for (i = 0; i < addon_data->headers_array_length; i++) {
977
1022
 
978
1023
  napi_value headers_array_element;
979
- status = napi_get_element(env, args[3], i, &headers_array_element);
1024
+ status = napi_get_element(env, args[4], i, &headers_array_element);
980
1025
  if (status != napi_ok) {
981
1026
  napi_throw_error(env, "EINVAL", "Failed to obtain headers element");
982
1027
  return NULL;