@openziti/ziti-sdk-nodejs 0.14.2 → 0.16.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.
@@ -57,6 +57,11 @@ jobs:
57
57
  submodules: 'recursive'
58
58
  # token: ${{ secrets.ZITI_CI_GH_TOKEN }}
59
59
 
60
+ - name: Setup PkgConfig (Windows)
61
+ if: matrix.config.target == 'windows'
62
+ run: |
63
+ choco install pkgconfiglite
64
+
60
65
  - name: Get crossbuild tools
61
66
  if: matrix.config.target == 'linux' && matrix.config.arch != 'x64'
62
67
  run: |
package/README.md CHANGED
@@ -50,7 +50,7 @@ Please star us.
50
50
 
51
51
  # Associated Article(s)
52
52
  For more context on this SDK, you may be interested in this
53
- [article concerning how to secure NodeJS applications](https://openziti.io/securing-nodejs-applications)
53
+ [article concerning how to secure NodeJS applications](https://blog.openziti.io/securing-nodejs-applications)
54
54
 
55
55
 
56
56
 
package/lib/close.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright Netfoundry, Inc.
2
+ Copyright NetFoundry Inc.
3
3
 
4
4
  Licensed under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License.
package/lib/dial.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright Netfoundry, Inc.
2
+ Copyright NetFoundry Inc.
3
3
 
4
4
  Licensed under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright Netfoundry, Inc.
2
+ Copyright NetFoundry Inc.
3
3
 
4
4
  Licensed under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License.
package/lib/express.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright Netfoundry, Inc.
2
+ Copyright NetFoundry Inc.
3
3
 
4
4
  Licensed under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright Netfoundry, Inc.
2
+ Copyright NetFoundry Inc.
3
3
 
4
4
  Licensed under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright Netfoundry, Inc.
2
+ Copyright NetFoundry Inc.
3
3
 
4
4
  Licensed under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright Netfoundry, Inc.
2
+ Copyright NetFoundry Inc.
3
3
 
4
4
  Licensed under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License.
package/lib/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright Netfoundry, Inc.
2
+ Copyright NetFoundry Inc.
3
3
 
4
4
  Licensed under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License.
package/lib/init.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright Netfoundry, Inc.
2
+ Copyright NetFoundry Inc.
3
3
 
4
4
  Licensed under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License.
package/lib/listen.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright Netfoundry, Inc.
2
+ Copyright NetFoundry Inc.
3
3
 
4
4
  Licensed under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright Netfoundry, Inc.
2
+ Copyright NetFoundry Inc.
3
3
 
4
4
  Licensed under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License.
@@ -0,0 +1,28 @@
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
+ /**
19
+ * servicesRefresh()
20
+ *
21
+ */
22
+ const servicesRefresh = () => {
23
+
24
+ ziti.ziti_services_refresh();
25
+
26
+ };
27
+
28
+ exports.servicesRefresh = servicesRefresh;
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright Netfoundry, Inc.
2
+ Copyright NetFoundry Inc.
3
3
 
4
4
  Licensed under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License.
package/lib/write.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright Netfoundry, Inc.
2
+ Copyright NetFoundry Inc.
3
3
 
4
4
  Licensed under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright Netfoundry, Inc.
2
+ Copyright NetFoundry Inc.
3
3
 
4
4
  Licensed under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License.
package/lib/ziti.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright Netfoundry, Inc.
2
+ Copyright NetFoundry Inc.
3
3
 
4
4
  Licensed under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License.
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.14.2",
4
+ "version": "0.16.0",
5
5
  "main": "./lib/ziti",
6
6
  "scripts": {
7
7
  "build": "npm run build:init && npm run build:configure && npm run build:make",
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright Netfoundry, Inc.
2
+ Copyright NetFoundry Inc.
3
3
 
4
4
  Licensed under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright Netfoundry, Inc.
2
+ Copyright NetFoundry Inc.
3
3
 
4
4
  Licensed under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright Netfoundry, Inc.
2
+ Copyright NetFoundry Inc.
3
3
 
4
4
  Licensed under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright Netfoundry, Inc.
2
+ Copyright NetFoundry Inc.
3
3
 
4
4
  Licensed under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License.
package/src/utils.c CHANGED
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright Netfoundry, Inc.
2
+ Copyright NetFoundry Inc.
3
3
 
4
4
  Licensed under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License.
package/src/utils.h CHANGED
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright Netfoundry, Inc.
2
+ Copyright NetFoundry Inc.
3
3
 
4
4
  Licensed under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License.
package/src/ziti-add-on.c CHANGED
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright Netfoundry, Inc.
2
+ Copyright NetFoundry Inc.
3
3
 
4
4
  Licensed under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License.
@@ -76,6 +76,7 @@ napi_value Init(napi_env env, napi_value exports) {
76
76
  expose_ziti_init(env, exports);
77
77
  expose_ziti_listen(env, exports);
78
78
  expose_ziti_service_available(env, exports);
79
+ expose_ziti_services_refresh(env, exports);
79
80
  expose_ziti_shutdown(env, exports);
80
81
  expose_ziti_write(env, exports);
81
82
 
package/src/ziti-nodejs.h CHANGED
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright NetFoundry, Inc.
2
+ Copyright NetFoundry Inc.
3
3
 
4
4
  Licensed under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License.
@@ -207,6 +207,7 @@ extern void expose_ziti_sdk_version(napi_env env, napi_value exports);
207
207
  extern void expose_ziti_init(napi_env env, napi_value exports);
208
208
  extern void expose_ziti_listen(napi_env env, napi_value exports);
209
209
  extern void expose_ziti_service_available(napi_env env, napi_value exports);
210
+ extern void expose_ziti_services_refresh(napi_env env, napi_value exports);
210
211
  extern void expose_ziti_set_log_level(napi_env env, napi_value exports);
211
212
  extern void expose_ziti_shutdown(napi_env env, napi_value exports);
212
213
  extern void expose_ziti_write(napi_env env, napi_value exports);
package/src/ziti_close.c CHANGED
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright Netfoundry, Inc.
2
+ Copyright NetFoundry Inc.
3
3
 
4
4
  Licensed under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License.
package/src/ziti_dial.c CHANGED
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright Netfoundry, Inc.
2
+ Copyright NetFoundry Inc.
3
3
 
4
4
  Licensed under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License.
@@ -328,8 +328,6 @@ napi_value _ziti_dial(napi_env env, const napi_callback_info info) {
328
328
  napi_throw_error(env, NULL, "Unable to napi_create_threadsafe_function");
329
329
  }
330
330
 
331
- ziti_set_timeout(ztx, 5*1000);
332
-
333
331
  // Init a Ziti connection object, and attach our add-on data to it so we can
334
332
  // pass context around between our callbacks, as propagate it all the way out
335
333
  // to the JavaScript callbacks
package/src/ziti_enroll.c CHANGED
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright Netfoundry, Inc.
2
+ Copyright NetFoundry Inc.
3
3
 
4
4
  Licensed under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License.
package/src/ziti_init.c CHANGED
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright Netfoundry, Inc.
2
+ Copyright NetFoundry Inc.
3
3
 
4
4
  Licensed under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License.
@@ -31,6 +31,12 @@ static const char *ALL_CONFIG_TYPES[] = {
31
31
  NULL
32
32
  };
33
33
 
34
+ #define ZROK_PROXY_CFG_V1 "zrok.proxy.v1"
35
+ #define ZROK_PROXY_CFG_V1_MODEL(XX, ...) \
36
+ XX(auth_scheme, string, none, auth_scheme, __VA_ARGS__) \
37
+ XX(basic_auth, string, none, basic_auth, __VA_ARGS__) \
38
+ XX(oauth, string, none, oauth, __VA_ARGS__)
39
+ DECLARE_MODEL(zrok_proxy_cfg_v1, ZROK_PROXY_CFG_V1_MODEL)
34
40
 
35
41
  /**
36
42
  * This function is responsible for calling the JavaScript callback function
@@ -86,12 +92,6 @@ void on_ziti_init(ziti_context _ztx, int status, void* ctx) {
86
92
  // Set the global ztx context variable
87
93
  ztx = _ztx;
88
94
 
89
- if (status == ZITI_OK) {
90
-
91
- ziti_set_timeout(ztx, 5*1000);
92
-
93
- }
94
-
95
95
  AddonData* addon_data = (AddonData*)ctx;
96
96
 
97
97
  // Initiate the call into the JavaScript callback.
@@ -136,18 +136,21 @@ static void on_ziti_event(ziti_context _ztx, const ziti_event_t *event) {
136
136
  if (event->event.service.removed != NULL) {
137
137
  for (ziti_service **sp = event->event.service.removed; *sp != NULL; sp++) {
138
138
  // service_check_cb(ztx, *sp, ZITI_SERVICE_UNAVAILABLE, app_ctx);
139
+ ZITI_NODEJS_LOG(INFO, "Service removed [%s]", (*sp)->name);
139
140
  }
140
141
  }
141
142
 
142
143
  if (event->event.service.added != NULL) {
143
144
  for (ziti_service **sp = event->event.service.added; *sp != NULL; sp++) {
144
145
  // service_check_cb(ztx, *sp, ZITI_OK, app_ctx);
146
+ ZITI_NODEJS_LOG(INFO, "Service added [%s]", (*sp)->name);
145
147
  }
146
148
  }
147
149
 
148
150
  if (event->event.service.changed != NULL) {
149
151
  for (ziti_service **sp = event->event.service.changed; *sp != NULL; sp++) {
150
152
  // service_check_cb(ztx, *sp, ZITI_OK, app_ctx);
153
+ ZITI_NODEJS_LOG(INFO, "Service changed [%s]", (*sp)->name);
151
154
  }
152
155
  }
153
156
 
@@ -160,6 +163,11 @@ static void on_ziti_event(ziti_context _ztx, const ziti_event_t *event) {
160
163
  .hostname = {0},
161
164
  .port = 0
162
165
  };
166
+ zrok_proxy_cfg_v1 zrok_cfg = {
167
+ .auth_scheme = "",
168
+ .basic_auth = "",
169
+ .oauth = ""
170
+ };
163
171
 
164
172
  if (ziti_service_get_config(s, ZITI_INTERCEPT_CFG_V1, intercept, (int (*)(void *, const char *, size_t))parse_ziti_intercept_cfg_v1) == ZITI_OK) {
165
173
 
@@ -177,6 +185,9 @@ static void on_ziti_event(ziti_context _ztx, const ziti_event_t *event) {
177
185
 
178
186
  } else if (ziti_service_get_config(s, ZITI_CLIENT_CFG_V1, &clt_cfg, (int (*)(void *, const char *, unsigned long))parse_ziti_client_cfg_v1) == ZITI_OK) {
179
187
  track_service_to_hostname(s->name, clt_cfg.hostname.addr.hostname, clt_cfg.port);
188
+
189
+ } else if (ziti_service_get_config(s, ZROK_PROXY_CFG_V1, &zrok_cfg, (int (*)(void *, const char *, unsigned long))parse_ziti_client_cfg_v1) == ZITI_OK) {
190
+ track_service_to_hostname(s->name, s->name, 80);
180
191
  }
181
192
 
182
193
  free_ziti_intercept_cfg_v1(intercept);
package/src/ziti_listen.c CHANGED
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright Netfoundry, Inc.
2
+ Copyright NetFoundry Inc.
3
3
 
4
4
  Licensed under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright Netfoundry, Inc.
2
+ Copyright NetFoundry Inc.
3
3
 
4
4
  Licensed under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright Netfoundry, Inc.
2
+ Copyright NetFoundry Inc.
3
3
 
4
4
  Licensed under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License.
@@ -0,0 +1,62 @@
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
+ #include "ziti-nodejs.h"
18
+ #include <time.h>
19
+
20
+ void ziti_services_refresh(ziti_context ztx, bool now);
21
+
22
+
23
+ /**
24
+ *
25
+ */
26
+ napi_value _ziti_services_refresh(napi_env env, const napi_callback_info info) {
27
+ napi_status status;
28
+ napi_value jsRetval;
29
+
30
+ ZITI_NODEJS_LOG(INFO, "ziti_services_refresh initiated");
31
+
32
+ // Now, call the C-SDK to refresh the services list
33
+ ziti_services_refresh(ztx, true);
34
+
35
+ status = napi_create_int32(env, 0 /* always succeed here */, &jsRetval);
36
+ if (status != napi_ok) {
37
+ napi_throw_error(env, NULL, "Unable to create return value");
38
+ }
39
+
40
+ return jsRetval;
41
+ }
42
+
43
+
44
+ /**
45
+ *
46
+ */
47
+ void expose_ziti_services_refresh(napi_env env, napi_value exports) {
48
+ napi_status status;
49
+ napi_value fn;
50
+
51
+ status = napi_create_function(env, NULL, 0, _ziti_services_refresh, NULL, &fn);
52
+ if (status != napi_ok) {
53
+ napi_throw_error(env, NULL, "Unable to wrap native function '_ziti_services_refresh");
54
+ }
55
+
56
+ status = napi_set_named_property(env, exports, "ziti_services_refresh", fn);
57
+ if (status != napi_ok) {
58
+ napi_throw_error(env, NULL, "Unable to populate exports for 'ziti_services_refresh");
59
+ }
60
+
61
+ }
62
+
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright Netfoundry, Inc.
2
+ Copyright NetFoundry Inc.
3
3
 
4
4
  Licensed under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright Netfoundry, Inc.
2
+ Copyright NetFoundry Inc.
3
3
 
4
4
  Licensed under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright Netfoundry, Inc.
2
+ Copyright NetFoundry Inc.
3
3
 
4
4
  Licensed under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright Netfoundry, Inc.
2
+ Copyright NetFoundry Inc.
3
3
 
4
4
  Licensed under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License.
package/src/ziti_write.c CHANGED
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright Netfoundry, Inc.
2
+ Copyright NetFoundry Inc.
3
3
 
4
4
  Licensed under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License.
package/vcpkg.json CHANGED
@@ -10,9 +10,11 @@
10
10
  "openssl",
11
11
  "zlib",
12
12
  "llhttp",
13
- "libsodium"
13
+ "libsodium",
14
+ "json-c",
15
+ "protobuf-c"
14
16
  ],
15
17
  "features": {
16
18
  },
17
19
  "builtin-baseline": "f14984af3738e69f197bf0e647a8dca12de92996"
18
- }
20
+ }