This repository contains a Node.js server created with Express which allows mocked users to authorize, generate keypair, and encrypt requested (or default) file.
- Node.js => 12
- npm (with yarn)
Follow the below steps.
git clone https://github.com/goniszewski/zdlnjs.git
cd zdlnj
In terminal execute yarn
and wait for it to finalize the installation process.
Execute command yarn start
. Server has started on port <NUMBER>
message should appear.
Accepts JSON with user credentials (example below) and returns token.
{
"email": "<EMAIL>",
"password": "<PASSWORD>"
}
Output:
{
"authToken": "<TOKEN>"
}
Returns JSON response with pair of public and private keys (example below).
{
"privKey": "-----BEGIN ENCRYPTED PRIVATE KEY----- ...",
"pubKey": "-----BEGIN PUBLIC KEY---- ..."
}
Returns encrypted file's details (encrypted file and encrypted key) needed to decrypt the file (with privKey
). Needs the keys to be previously generated for the user using /api/generate-key-pair
endpoint.
This endpoint accepts optional URL parameter ?url=
which requires a http://...
link to a choosen (and publicly available) file.
NOTE: if not used, the sample file's URL will be used (http://www.africau.edu/images/default/sample.pdf
by default).
Use default configuration (check src/env/env.js
) or specify your own by creating a .env
file based on provided .env_sample
(located in src/env/
).
For purpose of this server a mocked users data is provided. Head to src/mockup-data/index.js
to see user defails (passwords are hashed).
To sign in to server use [POST] /api/sign-in
endpoint, and use credentials for one of the users:
{
"email": "test@test.pl",
"password": "test1"
}
{
"email": "test2@test.pl",
"password": "test2"
}