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
async function encrypt(fileName){ | |
const encryptParams = new Virtru.EncryptParamsBuilder() | |
.withFileSource(`./encrypt-in/${fileName}`) | |
.withDisplayFilename(fileName) | |
.build(); | |
ct = await client.encrypt(encryptParams); | |
var ctString = await ct.toString(); | |
} |
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
function virtruStart(auth) { | |
promises = fs.readdirSync('./encrypt-in/').filter(function(x) { | |
return x !== '.DS_Store'; | |
}).map(fileName => encrypt(fileName, auth)); // calling encrypt() on each file. | |
Promise.all(promises).then(() => | |
console.log(`Encrypted & Uploaded:`)); | |
} | |
// *** Google Auth *** | |
// Load client secrets from a local file. |
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
const Virtru = require('virtru-sdk'); | |
var fs = require('fs'); | |
const email = 'some-email'; | |
const appId = 'some-appid'; | |
const sourceDir = 'some-input-dir'; | |
const destDir = 'some-output-dir'; | |
// Initialize the client. | |
const client = new Virtru.Client({email, appId}); |
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
//const SCOPES = ['https://www.googleapis.com/auth/drive.metadata.readonly']; | |
const SCOPES = ['https://www.googleapis.com/auth/drive']; | |
//function listFiles(auth) {...} | |
function upload(auth) { | |
var fileMetadata = { | |
'name': 'photo.jpg' | |
}; | |
var media = { | |
mimeType: 'image/jpeg', |
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
var fileMetadata = { | |
'name': 'photo.jpg' | |
}; | |
var media = { | |
mimeType: 'image/jpeg', | |
body: fs.createReadStream('files/photo.jpg') | |
}; | |
drive.files.create({ | |
resource: fileMetadata, | |
media: media, |
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
const fs = require('fs'); | |
const readline = require('readline'); | |
const {google} = require('googleapis'); | |
// If modifying these scopes, delete token.json. | |
const SCOPES = ['https://www.googleapis.com/auth/drive.metadata.readonly']; | |
// The file token.json stores the user's access and refresh tokens, and is | |
// created automatically when the authorization flow completes for the first | |
// time. | |
const TOKEN_PATH = 'token.json'; |
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
function sendEmail(cipherText, recipients, userMessage) { | |
// Get email address of file owner and assign attachment title. | |
var fileOwner = Session.getActiveUser().getEmail(); | |
var fileName = DocumentApp.getActiveDocument().getName() + ".pdf.tdf3.html"; | |
// Provide a basic email body for recipients who do not support HTML. | |
var emailBody = fileOwner + " has shared the encrypted file " + fileName + | |
" with you.\r\n\r\nIt\'s attached below; please download to open in" + | |
" Virtru\'s Secure Reader."; |
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
const client = new Virtru.Client({email}); | |
const encryptParams = new Virtru.EncryptParamsBuilder() | |
.withArrayBufferSource(arrayBuffer) | |
.withDisplayFilename(`${docTitle}.pdf`) | |
.withPolicy(policy) | |
.withUsersWithAccess(authorizedUsers) | |
.build(); | |
const ct = await client.encrypt(encryptParams); | |
var ctString = await ct.toString(); // Encrypt to string rather than to file | |
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
const encryptParams = new Virtru.EncryptParamsBuilder() | |
.withArrayBufferSource(arrayBuffer) | |
.withDisplayFilename(`${docTitle}.pdf`) | |
.withPolicy(policy) | |
.withUsersWithAccess(authorizedUsers) | |
.build(); |
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
/* | |
* Builds policy according to user inputs. | |
* | |
* @param {Array} authUsers The list of authorized users for this piece of content. | |
* @return {Policy} The policy for this piece of content. | |
*/ | |
function buildPolicy() { | |
var policy = new Virtru.PolicyBuilder(); | |
if ($('#watermark-toggle').is(":checked")) { |