PrivMX Endpoint Web
A JavaScript wrapper library that aims to simplify working with PrivMX native WASM library in Web environments.
Initial Requirements
To start developing end-to-end encrypted applications using PrivMX Endpoint you need:
-
A PrivMX Bridge instance, you can find installation guide here. To connect it to your environment you will need these API keys:
SolutionID
- created inside your Organization;Bridge URL
- unique for your Instance;ContextID
- there can be one or more depending on the use case.
-
A server for managing users. It can be new or existing, depending on the specific requirements. For more information about how PrivMX Endpoint integrates into your stack check our getting started guide.
Installation
Our JS client is a npm package that contains all the necessary assets and helpers to get started with PrivMX Endpoint.
- Install
@simplito/privmx-endpoint-web-sdk
from our npm repository:
npm install @simplito/privmx-endpoint-web-sdk --registry https://npm.simplito.com
- Run setup script:
npx @simplito/privmx-endpoint-web-sdk
The script will place all the necessary assets in your /public/wasmAssets/
folder.
It will also add the required <script/>
tags to your app's entry file, which are needed for initialization.
Server Configuration
To properly integrate our library, it's crucial to configure your server. This will ensure the library functions correctly and maintain security. You need to set up specific HTTP headers:
- set
Cross-Origin-Embedder-Policy
torequire-corp
; - set
Cross-Origin-Opener-Policy
tosame-origin
.
These headers are essential to prevent potential cross-origin attacks and to maintain a secure execution environment.
For detailed instructions on how to configure these headers in different environments like Vite, Next.js, Express, and Nginx, refer to our Server Configuration page.
Connecting to PrivMX Bridge
To use any of the library's elements, you must first connect to PrivMX Bridge. Use the API keys mentioned earlier:
import { Endpoint} from '@simplito/privmx-endpoint-web-sdk'
const solutionID = "SOLUTION_ID"
const bridgeUrl = "BRIDGE_URL"
const privKey = "PRIVATE_KEY"
await Endpoint.connect({
privKey,
solutionID,
bridgeUrl
})
You can have multiple connections simultaneously. To access a connection you can use the Endpoint.connection("label")
function.
When no param is given to the previously mentioned function it returns the newest connection.
Next Steps
With everything ready to go, now it's time to start using all the Bridge's capabilities.
Learn how to use: