Code Monkey home page Code Monkey logo

ziti-sdk-js's Introduction

ziti-sdk-js

A JavaScript-based SDK for delivering secure browser-based web applications over a Ziti Network

Learn about Ziti at ziti.dev

Build Issues Known Vulnerabilities License npm version LOC PRs Welcome Contributor Covenant CodeSee

Motivation

tbd

Features

tbd

Installing via NPM

If you want to embed ziti-sdk-js in your build, it is available through npm. Simply run the following command:

npm i @openziti/ziti-sdk-js

You can then use ziti-sdk-js as a regular module:

const ziti = require('@openziti/ziti-sdk-js');

Installing via jsDelivr CDN

If you want to use ziti-sdk-js directly from the jsDelivr CDN, simply include this in your html:

For latest version:

<script src="https://cdn.jsdelivr.net/npm/@openziti/ziti-sdk-js@latest/dist/ziti.min.js"></script>

For specific version (e.g. 0.4.8):

<script src="https://cdn.jsdelivr.net/npm/@openziti/[email protected]/dist/ziti.min.js"></script>

The above bundles will synchronously create a global ziti object that you can call.

Installing via unpkg CDN

If you want to use ziti-sdk-js directly from the unpkg CDN, simply include this in your html:

For latest version:

<script src="https://unpkg.com/@openziti/ziti-sdk-js@latest/dist/ziti.min.js"></script>

For specific version (e.g. 0.4.8):

<script src="https://unpkg.com/@openziti/[email protected]/dist/ziti.min.js"></script>

The above bundles will synchronously create a global ziti object that you can call.

Configuration

tbd

License

Apache 2.0

ziti-sdk-js's People

Contributors

biki-das avatar dependabot[bot] avatar dovholuknf avatar rentallect avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

ziti-sdk-js's Issues

HeartbeatRequest

After a successful TLS handshake, leverage the (experimental) Forge prepareHeartbeatRequest mechanisms to cause pings to be sent from client to server. This is aimed at ensuring the websocket-based channel stays viable during periods when the webapp/user may be idle.

Exception: Can't send data because WebSocket is not opened

If a webapp is left idle over night, the websockets typically get closed. When the webapp attempt to send traffic the next day, we should just spin up a fresh channel to the edge router... but something currently goes awry, as shown here:

Uncaught (in promise) TypeError: Can't send data because WebSocket is not opened.
    at exports.throwIf (ziti.js:152980)
    at ZitiWebSocket.send (ziti.js:153687)
    at Object.tlsDataReady (ziti.js:132461)
    at Object.tls.flush (ziti.js:74391)
    at Object.c.prepare (ziti.js:75013)
    at ZitiTLSConnection.prepare (ziti.js:132527)
    at ZitiChannel._sendMarshaled (ziti.js:130366)
    at ziti.js:130292
    at PromiseController._callFn (ziti.js:119945)
    at PromiseController.call (ziti.js:119846)
    at Messages._createNewMessage (ziti.js:132134)
    at Messages.create (ziti.js:132106)
    at ZitiChannel.sendMessage (ziti.js:130291)
    at ziti.js:129984

Handle websocket close

If edge router closes websocket, we need to gracefully shut down the channel on JS-side, and then attempt to re-open a fresh channel.

Enrollment fails on Safari browser

ziti-sdk-js uses the browser/web API Blob.text() in its rest-client impl used to do REST calls to the Controller. e.g. to call the /.well-known/est/cacerts endpoint during enrollment operations.

The text() method in the Blob interface returns a Promise that resolves with a string containing the contents of the blob, interpreted as UTF-8.

The problem is... Safari doesn't support Blob.text() 👎
(as shown here: https://developer.mozilla.org/en-US/docs/Web/API/Blob/text)

I need to refactor this area with an eye towards using web APIs supported by all of the big three browsers.

Add tlsConn.verify support

Ensure that the CN in the server-side cert of the edge router we are doing the TLS handshake with is indeed the same edge router we are attempting to connect with based on hostname extracted from the network session we created on the controller.

Use the verify mechanism provided on the Forge tls.connection.

Support non-encrypted Services

Today, we expect/assume that all services want/require encryption. Add support for connecting to non-encrypted services.

Need to surface error, if TLS connect attempts repeatedly fail

It is (currently) possible to configure the controller with a edge.wsapi section, but with that section lacking the identity,servercert or key. In this scenario, the JS-SDK will loop endlessly trying to get TLS connections over the websocket.

We need to detect this situation, and surface the problem for the user of the webapp.

Handle Connection close

When connections get closed, they are not being removed from the connections list maintained by the channel.

Firefox: Short read; Could not decrypt record or bad MAC

Seeing different behavior depending on which browser is used (with ziti-sdk-js 0.6.3+)

Although the tmdb web-app test-mule runs very solidly under Chrome (87.0.4280.67), it intermittently fails under Firefox (83.0) on a Macbook.

The problem manifests on the edge router as:

ERROR [foundation/channel2.(*channelImpl).rxer [ch{edge}->u{classic}->i{ORXE}] rx error (short read)

The edge router is attempting to read the 4-byte magic number for the edge-protocol message, but gets zero bytes instead. The error is unrecoverable on edge router side, so it closes the channel.

The client side then gets confused, and the attempt to decrypt incoming traffic/responses, manifests an error:

Could not decrypt record or bad MAC

There seems to be some kind of async/timing differences, or websocket data-chunking differences, concerning how things operate on these two browsers while running the exact same code.

Need to surface error, and fail enrollment, if controller lacks `edge.wsapi` config

If we are attempting to enroll with a Controller that does not have an edge.wsapi configured, we will receive incomplete data from the /protocols call. This eventually leads to corrupt coordinates of the WS listener on the controller, and an inability to make Ziti connections.

We need to fail the enrollment in this case, and make it obvious to the user what is going on.

Use smaller envInfo.os

We currently send entire userAgent as the envInfo.os value during /authenticate requests to Controller.

Instead, let's send only the last "portion" of the UA.

e.g., instead of:

5.0 (Macintosh; Intel Mac OS X 10_15_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36
let's try to send only:

Chrome/87.0.4280.88

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.