@openziti/ziti-sdk-nodejs 0.13.0 → 0.13.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +69 -6
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
<p align="center" width="100%">
|
|
2
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.
|
|
3
5
|
<br/>
|
|
4
6
|
<br/>
|
|
5
7
|
Please star us.
|
|
@@ -7,8 +9,6 @@ Please star us.
|
|
|
7
9
|
<a href="https://github.com/openziti/ziti/stargazers"><img src="https://img.shields.io/github/stars/openziti/ziti?style=flat" ></a>
|
|
8
10
|
<br/>
|
|
9
11
|
<br>
|
|
10
|
-
The project provides all the pieces required to implement or integrate zero trust into your solutions.
|
|
11
|
-
<br>
|
|
12
12
|
</p>
|
|
13
13
|
|
|
14
14
|
<p align="center" width="100%">
|
|
@@ -21,7 +21,7 @@ The project provides all the pieces required to implement or integrate zero trus
|
|
|
21
21
|
<br>
|
|
22
22
|
<br>
|
|
23
23
|
<b>
|
|
24
|
-
|
|
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
25
|
<br>
|
|
26
26
|
<br>
|
|
27
27
|
<b>Part of the <a href="https://openziti.io/about">OpenZiti</a> ecosystem</b>
|
|
@@ -46,6 +46,9 @@ The project provides all the pieces required to implement or integrate zero trus
|
|
|
46
46
|
|
|
47
47
|
---
|
|
48
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)
|
|
49
52
|
|
|
50
53
|
|
|
51
54
|
|
|
@@ -64,9 +67,14 @@ Binaries for most Node versions and platforms are provided by default via [@mapb
|
|
|
64
67
|
|
|
65
68
|
# Installing
|
|
66
69
|
|
|
70
|
+
NPM
|
|
67
71
|
``` js
|
|
68
72
|
npm i @openziti/ziti-sdk-nodejs
|
|
69
73
|
```
|
|
74
|
+
or Yarn
|
|
75
|
+
``` js
|
|
76
|
+
yarn add @openziti/ziti-sdk-nodejs
|
|
77
|
+
```
|
|
70
78
|
|
|
71
79
|
Special note on previous package:
|
|
72
80
|
|
|
@@ -81,6 +89,59 @@ npm install @openziti/ziti-sdk-nodejs --save
|
|
|
81
89
|
|
|
82
90
|
**Note:** the module must be [installed](#installing) before use.
|
|
83
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',
|
|
108
|
+
'GET',
|
|
109
|
+
'/', // path
|
|
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)
|
|
84
145
|
``` js
|
|
85
146
|
var ziti = require('@openziti/ziti-sdk-nodejs');
|
|
86
147
|
|
|
@@ -147,6 +208,9 @@ const ziti_write = (conn, data) => {
|
|
|
147
208
|
|
|
148
209
|
# Ziti NodeJS SDK - Setup for Development
|
|
149
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
|
+
|
|
150
214
|
The following steps should get your NodeJS SDK for Ziti building. The Ziti NodeJS SDK is a native addon for Node JS,
|
|
151
215
|
and is written in C. C development is specific to your operating system and tool chain used. These steps should work
|
|
152
216
|
properly for you but if your OS has variations you may need to adapt these steps accordingly.
|
|
@@ -172,11 +236,10 @@ $ npm run build
|
|
|
172
236
|
|
|
173
237
|
Getting Help
|
|
174
238
|
------------
|
|
175
|
-
Please use these community resources for getting help. We use GitHub [issues](https://github.com/
|
|
239
|
+
Please use these community resources for getting help. We use GitHub [issues](https://github.com/openziti/ziti-sdk-nodejs/issues)
|
|
176
240
|
for tracking bugs and feature requests and have limited bandwidth to address them.
|
|
177
241
|
|
|
178
|
-
- Read the [docs](https://
|
|
179
|
-
- Join our [Developer Community](https://developer.netfoundry.io)
|
|
242
|
+
- Read the [docs](https://openziti.github.io/ziti/overview.html)
|
|
180
243
|
- Participate in discussion on [Discourse](https://openziti.discourse.group/)
|
|
181
244
|
|
|
182
245
|
|
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.
|
|
4
|
+
"version": "0.13.1",
|
|
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",
|