body-cryptor
v1.1.4
Published
Downloads
3
Readme
body-cryptor
new BodyCryptor
const media = fs.readFileSync(`${__dirname}/media-private.pem`);
const bodyCryptor = new BodyCryptor({ media });
signature on url
const app = express();
app.get("/:hash", bodyCryptor.url(), handler);
const payload = { id: "10" };
const hash = bodyCryptor.signedUrl(payload, "media");
const result = await axios.get(`/${hash}`);
signature on body
// application/json
const app = express();
app.post("/paths", bodyParser.json(), bodyCryptor.body(), handler);
// multipart/form-data
const upload = multer();
const app = express();
app.post("/paths", upload.any(), bodyCryptor.body(), handler);
const payload = { id: "10" };
const ciphertext = bodyCryptor.signedBody(payload, "media");
const result = await axios.post("/paths", { ciphertext });