latest build

This commit is contained in:
Sharon Kennedy
2020-07-25 19:07:08 -04:00
parent d6651b7437
commit abcc417d78
3 changed files with 253 additions and 42 deletions

View File

@@ -1,15 +1,9 @@
const { Crypto } = require("node-webcrypto-ossl");
const crypto = new Crypto();
// this is from https://github.com/matrix-org/browser-encrypt-attachment
// which is the library used by matrix-reack-sdk to encrypt and decrypt attachments
// just dropped in node-webcrypto-ossl to replace window.crypto
// and Buffer for base64 encoding/decoding instead of window.btoa/window.atob
/**
* Encrypt an attachment.
* @param {ArrayBuffer} plaintextBuffer The attachment data buffer.
@@ -17,6 +11,10 @@ const crypto = new Crypto();
* The object has a "data" key with an ArrayBuffer of encrypted data and an "info" key
* with an object containing the info needed to decrypt the data.
*/
const { Crypto } = require("node-webcrypto-ossl");
const crypto = new Crypto();
function encryptAttachment(plaintextBuffer) {
var cryptoKey; // The AES key object.
var exportedKey; // The AES key exported as JWK.