-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Kamil Żurański
committed
Nov 4, 2024
1 parent
680b5c4
commit f26f78e
Showing
101 changed files
with
14,964 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
.vscode/ | ||
emsdk/ | ||
src/poco* | ||
src/gmp* | ||
out/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
image: gitlab.simplito.com:5050/pmxcpp/devtools/docker/builder-gcc11:latest | ||
|
||
build (manual): | ||
stage: build | ||
rules: | ||
- when: manual | ||
script: | ||
- git submodule set-url src/pson-cpp https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.simplito.com/platform/privmx/endpoint/libs/pson-cpp | ||
- git submodule set-url src/privmx-core https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.simplito.com/platform/privmx/endpoint/privmx-core | ||
- git submodule set-url src/endpoint-web-api https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.simplito.com/platform/privmx/endpoint/endpoint-web-api | ||
- git submodule set-url src/driver-web-context https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.simplito.com/platform/privmx/endpoint/driver-web-context | ||
- git submodule set-url src/privmxdrv-crypto-web https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.simplito.com/platform/privmx/endpoint/privmxdrv-crypto-web | ||
- git submodule set-url src/privmxdrv-ecc-web https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.simplito.com/platform/privmx/endpoint/privmxdrv-ecc-web | ||
- git submodule set-url src/privmxdrv-net-web https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.simplito.com/platform/privmx/endpoint/privmxdrv-net-web | ||
- git submodule update --init --recursive | ||
- ./build.sh | ||
- mv out privmx-endpoint-web-${CI_COMMIT_SHORT_SHA} | ||
- zip -r privmx-endpoint-web-${CI_COMMIT_SHORT_SHA}.zip privmx-endpoint-web-${CI_COMMIT_SHORT_SHA} | ||
artifacts: | ||
paths: | ||
- privmx-endpoint-web-${CI_COMMIT_SHORT_SHA}.zip | ||
|
||
build (tag): | ||
stage: build | ||
rules: | ||
- if: $CI_COMMIT_TAG | ||
script: | ||
- git submodule set-url src/pson-cpp https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.simplito.com/platform/privmx/endpoint/libs/pson-cpp | ||
- git submodule set-url src/privmx-core https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.simplito.com/platform/privmx/endpoint/privmx-core | ||
- git submodule set-url src/endpoint-web-api https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.simplito.com/platform/privmx/endpoint/endpoint-web-api | ||
- git submodule set-url src/driver-web-context https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.simplito.com/platform/privmx/endpoint/driver-web-context | ||
- git submodule set-url src/privmxdrv-crypto-web https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.simplito.com/platform/privmx/endpoint/privmxdrv-crypto-web | ||
- git submodule set-url src/privmxdrv-ecc-web https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.simplito.com/platform/privmx/endpoint/privmxdrv-ecc-web | ||
- git submodule set-url src/privmxdrv-net-web https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.simplito.com/platform/privmx/endpoint/privmxdrv-net-web | ||
- git submodule update --init --recursive | ||
- ./build.sh | ||
- mv out privmx-endpoint-web-${CI_COMMIT_TAG} | ||
- zip -r privmx-endpoint-web-${CI_COMMIT_TAG}.zip privmx-endpoint-web-${CI_COMMIT_TAG} | ||
artifacts: | ||
paths: | ||
- privmx-endpoint-web-${CI_COMMIT_TAG}.zip | ||
|
||
deploy (manual): | ||
stage: deploy | ||
needs: [build (manual)] | ||
before_script: | ||
- eval $(ssh-agent -s) | ||
- chmod 400 "$DEPLOY_SCRIPT_KEY" | ||
- ssh-add "$DEPLOY_SCRIPT_KEY" | ||
- mkdir -p ~/.ssh | ||
- chmod 700 ~/.ssh | ||
- cp "$SSH_KNOWN_HOSTS" ~/.ssh/known_hosts | ||
- chmod 644 ~/.ssh/known_hosts | ||
- git clone https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.simplito.com/platform/privmx/tools/builds-deployer.git ./deployer | ||
- sed -i 's/java_deployer/deployer/g' ./deployer/client-side/config.sh | ||
script: | ||
- ./deployer/client-side/deploy --publish --package=privmx-endpoint-web-${CI_COMMIT_SHORT_SHA}.zip --src=privmx-endpoint-web-${CI_COMMIT_SHORT_SHA}.zip --channel=dev | ||
|
||
deploy (tag): | ||
stage: deploy | ||
needs: [build (tag)] | ||
rules: | ||
- if: $CI_COMMIT_TAG | ||
before_script: | ||
- eval $(ssh-agent -s) | ||
- chmod 400 "$DEPLOY_SCRIPT_KEY" | ||
- ssh-add "$DEPLOY_SCRIPT_KEY" | ||
- mkdir -p ~/.ssh | ||
- chmod 700 ~/.ssh | ||
- cp "$SSH_KNOWN_HOSTS" ~/.ssh/known_hosts | ||
- chmod 644 ~/.ssh/known_hosts | ||
- git clone https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.simplito.com/platform/privmx/tools/builds-deployer.git ./deployer | ||
- sed -i 's/java_deployer/deployer/g' ./deployer/client-side/config.sh | ||
script: | ||
- ./deployer/client-side/deploy --publish --package=privmx-endpoint-web-${CI_COMMIT_TAG}.zip --src=privmx-endpoint-web-${CI_COMMIT_TAG}.zip --channel=staging |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
[submodule "src/pson-cpp"] | ||
path = src/pson-cpp | ||
url = ssh://git@gitlab.simplito.com:1022/platform/privmx/endpoint/libs/pson-cpp.git | ||
branch = master | ||
[submodule "src/privmx-core"] | ||
path = src/privmx-core | ||
url = ssh://git@gitlab.simplito.com:1022/platform/privmx/endpoint/privmx-core.git | ||
branch = main | ||
[submodule "src/endpoint-web-api"] | ||
path = src/endpoint-web-api | ||
url = ssh://git@gitlab.simplito.com:1022/platform/privmx/endpoint/endpoint-web-api.git | ||
branch = main | ||
[submodule "src/driver-web-context"] | ||
path = src/driver-web-context | ||
url = ssh://git@gitlab.simplito.com:1022/platform/privmx/endpoint/driver-web-context.git | ||
branch = main | ||
[submodule "src/privmxdrv-crypto-web"] | ||
path = src/privmxdrv-crypto-web | ||
url = ssh://git@gitlab.simplito.com:1022/platform/privmx/endpoint/privmxdrv-crypto-web.git | ||
branch = main | ||
[submodule "src/privmxdrv-ecc-web"] | ||
path = src/privmxdrv-ecc-web | ||
url = ssh://git@gitlab.simplito.com:1022/platform/privmx/endpoint/privmxdrv-ecc-web.git | ||
branch = main | ||
[submodule "src/privmxdrv-net-web"] | ||
path = src/privmxdrv-net-web | ||
url = ssh://git@gitlab.simplito.com:1022/platform/privmx/endpoint/privmxdrv-net-web.git | ||
branch = main |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
|
||
# PrivMX Free License | ||
|
||
ver. 1.0, 18.10.2024 | ||
|
||
This document contains information about the legal rules of using PrivMX Software. It is a binding agreement, which means that as a User of PrivMX Software, you are obliged to comply with it. | ||
|
||
In this document, we use the term PrivMX Software – a general name describing a software system created by us, consisting of, among others, PrivMX Bridge and PrivMX Endpoint. PrivMX Bridge is a server-side component which is used together with PrivMX Endpoint - programming libraries and tools which are the client-side part of the PrivMX Software. | ||
|
||
The license document also uses the concept of PrivMX Solution, which is a PrivMX Bridge runtime structure, enabling one programming solution (e.g., one application) to use PrivMX Software functions. | ||
|
||
## The contract is concluded between us, that is: | ||
|
||
Simplito sp. z o.o. with its registered office in Toruń, Republic of Poland, address: Grudziądzka 1-3, 87-100 Toruń, entered into the Register of Entrepreneurs of the National Court Registry by the District Court in Toruń, VIIth Commercial Division of the National Court Registry under KRS number: 0000305883, | ||
|
||
and any User of PrivMX Software – you become one if you download, install, or use PrivMX Software. This includes, in particular, installing PrivMX Software within your own IT infrastructure in order to use it. You are also a User when you access source code of PrivMX Software or integrate it with other solutions. | ||
|
||
## Using PrivMX Software within an Organization | ||
|
||
If you perform any of these activities involving PrivMX Software, in connection with your activity in an Organization, then the User, and therefore a party to the license agreement, is that Organization. If we use the term Organization in this agreement, we mean any legal person, organized group of people, or organizational unit (whether in form of national government, local government, or private entity) – e.g., enterprise, company, governmental authority, foundation, religious association, nongovernmental organization, school, or scientific organization. | ||
|
||
In this case, by accepting the terms of this license agreement, you state that you are authorized to enter into this license agreement on behalf of your Organization. | ||
|
||
By activity within the Organization, we mean in particular the use of PrivMX Software in the creation or development of IT solutions used in the Organization, the creation of other commercial solutions utilizing PrivMX Software, testing PrivMX Software due to its potential use within the Organization, conducting research activities with PrivMX Software within the Organization. | ||
|
||
If in this agreement we use terms such as we, us, our, ours, it refers to Simplito sp. z o.o. | ||
|
||
If in this agreement we use terms such as you, your, yours, etc., it refers to the User who is a party to this license agreement – either an individual or an Organization. | ||
|
||
## What you can do with PrivMX Software | ||
|
||
As part of the license granted to you to use PrivMX Software, you may use it for your permissible personal use. This means that you have the right, acting as an individual, to use PrivMX Software for your own personal purposes, e.g. to create solutions aimed at contacting family or friends, or to test PrivMX Software functions in regards to your personal interests, knowledge development or individual research activities. | ||
|
||
You may modify PrivMX Software and its source code for your own needs. | ||
|
||
You can use multiple PrivMX Solutions under the terms of this license, however you are obliged to meet the requirements of the license in each case. | ||
|
||
## What you can’t do with PrivMX Software | ||
|
||
With the exception described below in the next paragraph, you may not use PrivMX Software for commercial purposes. We understand commercial purposes as any activities related to PrivMX Software that meet at least one of the following criteria: | ||
* are aimed at making profit – e.g., creation of your own IT solutions using PrivMX Software and offering them to third parties, | ||
* are used for the internal needs of the Organization – e.g., for communication within the Organization, communication with its customers or other people who interact with the Organization in any way, | ||
* they are used to achieve other objectives of the Organization – e.g., development and research activities, including the creation of its own products or services. | ||
|
||
If you want to use PrivMX Software commercially, you are obliged to purchase a separate commercial license. Detailed information regarding this matter can be found at privmx.com. | ||
|
||
As the User of PrivMX Software, you may not rent, license, distribute, transfer to public repositories, copy for sale, or publish PrivMX Software, its source code and any related materials, derivative works, modified versions and rights. | ||
|
||
You may also not provide PrivMX Software hosting services to third parties. | ||
|
||
## Exception | ||
|
||
You or your Organization can use PrivMX Software in order to carry out research or development activities related to the creation of your original IT solutions at the stage of development and internal testing. You may do so only until making a given solution production-ready - public or available to customers, members of your own staff, or other end users and 3rd parties. | ||
|
||
## Copyright notice | ||
|
||
We have full copyright to PrivMX Software. We have the right to decide on its distribution, modification, development, or licensing. | ||
|
||
## Responsibility | ||
|
||
Unless otherwise required by applicable law or otherwise agreed upon in writing, PrivMX Software is provided on an "as is" basis. | ||
|
||
Other than as provided in this agreement, we make no other warranties, express or implied, and hereby disclaim all implied warranties, including the ones regarding the operation of PrivMX Software. | ||
|
||
You are solely responsible for evaluating whether your use of PrivMX Software is fit for your particular purposes. | ||
|
||
Our liability for damages resulting from the use of PrivMX Software is excluded to the maximum extent permitted by applicable law. Accordingly, we will not be liable to you under any circumstances for any damages, including actual damages or lost profits, that result from the use of PrivMX Software (including damages resulting from damage to the reputation of the company, errors of other computer programs, malfunction of IT systems), even if we have been advised of the possibility of such damages. | ||
|
||
## Other provisions | ||
|
||
The license indicated in this agreement is granted without territorial limitations, in a non-exclusive, free, and indefinite period. | ||
|
||
We have the right to conduct activities aimed at verifying that your use of PrivMX Software is in accordance with the content of the license granted to you. | ||
|
||
The license is governed by the laws of the Republic of Poland. The license is subject to the jurisdiction of Polish courts. Any disputes related to the license will be resolved by the common courts having jurisdiction over the registered office of our company, unless specific provisions of law say otherwise. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
## 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://<your_instance_of_bridge_server:port> | ||
``` | ||
|
||
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 = "<context_user_priv_key>"; | ||
const userPubKey = "<context_user_pub_key"; | ||
const platformUrl = "http://localhost:9111"; | ||
const solutionId = "<solution_id>"; | ||
|
||
const defaultListQuery = {skip:0, limit: 100, sortOrder: "desc"}; | ||
|
||
// listening for events | ||
const eventQueue = await EndpointFactory.getEventQueue(); | ||
listenForEvents(eventQueue); | ||
|
||
// initialize Endpoint connection and Threads API | ||
const connection = await EndpointFactory.platformConnect(userPrivKey, solutionId, platformUrl); | ||
const threadsApi = await EndpointFactory.createThreadApi(connection); | ||
|
||
const contexts = await connection.listContexts(defaultListQuery); | ||
const contextId = contexts.readItems[0].contextId; | ||
|
||
// get available threads | ||
const threads = await threadsApi.listThreads(contextId, defaultListQuery); | ||
console.log("threads", threads); | ||
const threadId = threads.readItems[0].threadId; | ||
|
||
// subscribe for events in the selected thread and send a sample message to that thread | ||
await threadsApi.subscribeForMessageEvents(threadId); | ||
await threadsApi.sendMessage(threadId, strToUInt8("some public meta-data"), strToUInt8("some private meta-data"), strToUInt8("message_"+String(Math.random()))); | ||
|
||
// get thread's messages | ||
const messages = await threadsApi.listMessages(threadId, defaultListQuery); | ||
console.log("messages", messages); | ||
console.log("messages in human-readable format", messages.readItems.map(x => {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/examples/minimal). | ||
|
||
For more detailed information about API functions, visit https://docs.privmx.dev. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
SCRIPT_PATH=$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd ) | ||
|
||
"$SCRIPT_PATH/scripts/get_emsdk" | ||
"$SCRIPT_PATH/scripts/build_gmp" | ||
"$SCRIPT_PATH/scripts/build_poco" | ||
"$SCRIPT_PATH/scripts/build_pson" | ||
"$SCRIPT_PATH/scripts/build_webdrivers" | ||
"$SCRIPT_PATH/scripts/build_privmx_core" | ||
"$SCRIPT_PATH/scripts/build_driver_web_context" | ||
"$SCRIPT_PATH/scripts/build_api" | ||
"$SCRIPT_PATH/scripts/install" | ||
|
||
echo "=============" | ||
echo "BUILD SUCCESS" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
dist/ | ||
node_modules/ | ||
out/ |
Oops, something went wrong.