Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/simplito/privmx-webendpoint

JavaScript library designed to work in browser environment, used by PrivMX communication channels
https://github.com/simplito/privmx-webendpoint

communication cryptography end-to-end-encryption privacy web zero-knowledge

Last synced: about 12 hours ago
JSON representation

JavaScript library designed to work in browser environment, used by PrivMX communication channels

Awesome Lists containing this project

README

        

## PrivMX Web Endpoint
PrivMX Web Endpoint is a JavaScript library designed to work in browser environment. It is used by applications and devices which are the ends of PrivMX secure communication channels. It encrypts and decrypts data, manages network connections and provides a functional API on the top of the WebAssembly build made of the native PrivMX Endpoint library written in C++. This allows applications to build their E2EE communication channels based on a few universal, client-side encrypted tools: Threads, Stores, and Inboxes.

Initialization of the application’s Endpoint requires providing an address of the application’s Bridge and the user's private key.

### Sample usage
The sample code below is an example of how you can start using low-level PrivMX Web Endpoint library and its API.

### Initial requirements for connecting with Web Endpoint to PrivMX Bridge

To use the library's elements in a JS app, you have to provide:

1. PrivMX Web Endpoint address (platformUrl):

```
https://
```

2. SolutionId:

```
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
```

3. Make PrivMX Web Endpoint library's assets available for your application:
```
driver-web-context.js
endpoint-wasm-module.wasm
endpoint-wasm-module.worker.js
endpoint-wasm-module.js
privmx-endpoint-web.js
```

#### You must also ensure that:

1. There is an appropriate context with assigned users on the Bridge Server side.

2. The users have pairs of public and private keys (`Pubkey` and `PrivKey`) and the user's private key is known in the app.

3. Public keys of all the users are added to the `Context`.

### `sample.js`:

``` js
let listenForEventsPromise;

const runSample = (async () => {
const userPrivKey = "";
const userPubKey = " {return {publicMeta: uInt8ToStr(x.publicMeta), privateMeta: uInt8ToStr(x.privateMeta), data: uInt8ToStr(x.data)}}));
});

window.addEventListener('libInitialized', () => runSample());

// helpers
function listenForEvents(eventQueue) {
if (!listenForEventsPromise) {
listenForEventsPromise = eventQueue.waitEvent();
listenForEventsPromise.then(result => {
console.log("onEvent", result);
listenForEventsPromise = null;
listenForEvents(eventQueue);
})
}
}

function strToUInt8(text) {
return (new TextEncoder()).encode(text);
}

function uInt8ToStr(arr) {
return (new TextDecoder()).decode(arr);
}
```
A complete project that uses the above code example can be found [here](https://github.com/simplito/privmx-webendpoint/tree/main/examples/minimal).

For more detailed information about API functions, visit https://docs.privmx.dev.