diff --git a/EncryptDecrypt-v2.js b/EncryptDecrypt-v2.js index 80030c4..df125dc 100644 --- a/EncryptDecrypt-v2.js +++ b/EncryptDecrypt-v2.js @@ -16,51 +16,58 @@ let privateKeyPath = './keys/privateKey.key' // Calling generateKeyPair() method // with its parameters exports.generateKeys = () => { - generateKeyPair('rsa', { - modulusLength: 2048, // options - publicExponent: 0x10101, - publicKeyEncoding: { - type: 'pkcs1', - format: 'pem' - }, - privateKeyEncoding: { - type: 'pkcs8', - format: 'pem', - cipher: 'aes-192-cbc', - passphrase: 'sse' - } - }, (err, PublicKey, PrivateKey) => { // Callback function - if(!err) - { - fs.writeFile(publicKeyPath, PublicKey.toString('hex'), (er) => { - if (er) console.log(er); - console.log("Key Successfully Saved."); - }); - - fs.writeFile(privateKeyPath, PrivateKey.toString('hex'), (er) => { - if (er) console.log(er); - console.log("Key Successfully Saved."); - }); - - } - else - { - // Prints error if any - console.log("Errr is: ", err); - } - }); + + return new Promise( (resolve, reject) => { + + generateKeyPair('rsa', { + modulusLength: 2048, // options + publicExponent: 0x10101, + publicKeyEncoding: { + type: 'pkcs1', + format: 'pem' + }, + privateKeyEncoding: { + type: 'pkcs8', + format: 'pem', + cipher: 'aes-192-cbc', + passphrase: 'sse' + } + }, (err, PublicKey, PrivateKey) => { // Callback function + if(!err) + { + fs.writeFile(publicKeyPath, PublicKey.toString('hex'), (er) => { + if (er) console.log(er); + console.log("Key Successfully Saved."); + }); + + fs.writeFile(privateKeyPath, PrivateKey.toString('hex'), (er) => { + if (er) console.log(er); + console.log("Key Successfully Saved."); + }); + resolve(); + + } + else + { + // Prints error if any + console.log("Errr is: ", err); + reject(); + } + }); + + }) + }; exports.getKeywordHash = (keyword) => { - keyword_hash = crypto.createHmac('sha256', indexKey) + let keyword_hash = crypto.createHmac('sha256', indexKey) .update(keyword) .digest('hex') return keyword_hash }; -exports.getEncryptionKeyword = (pbKey, keyword) => { //send publickey as a parameter - //Store publicKey.key as key file +exports.getEncryptionKeyword = (pbKey, keyword) => { //Also pass publicKey.key the file here as a parameter //let pbKey = fs.readFileSync('./keys/publicKey.key'); @@ -96,10 +103,10 @@ exports.getDecryptionKeyword = (encryptedKeyword) => { return keyword.toString(); }; -exports.getEncryptFile = (/* pbKey, */filePath) => { +exports.getEncryptFile = (pbKey, filePath) => { //Store publicKey.key as key file //Also pass publicKey.key the file here as a parameter - let pbKey = fs.readFileSync('./keys/publicKey.key'); + //let pbKey = fs.readFileSync('./keys/publicKey.key'); fs.readFile(filePath, "utf-8", (err, data) => { @@ -121,56 +128,147 @@ exports.getEncryptFile = (/* pbKey, */filePath) => { }); }; -exports.getEncryptFileV2 = (pbKey, filePath) => { - //Store publicKey.key as key file - //Also pass publicKey.key the file here as a parameter - //let pbKey = fs.readFileSync('./keys/publicKey.key'); - - fs.readFile(filePath, "utf-8", (err, data) => { +//It is for encrypting owner's file data with requester's public key -also output is in HEX +exports.getEncryptFileV2 = (pbKey, filePath ) => { + return new Promise( (resolve) => { - const encryptedData = crypto.publicEncrypt( - { - key: pbKey, - padding: crypto.constants.RSA_PKCS1_OAEP_PADDING, - oaepHash: "sha256", - }, + //Store publicKey.key as key file + //Also pass publicKey.key the file here as a parameter + //let pbKey = fs.readFileSync('./keys/publicKey.key'); + let againEncryptedfileP = './temp-file/againEncryptFile.txt'; + console.log("Inside encryptFileV2: "); + console.log("file data: ", fs.readFileSync(filePath).toString('hex')); + fs.readFile(filePath, "utf-8" , (err, data) => { - Buffer.from(data) - ) - fs.writeFile(filePath, encryptedData, (error) => { - if (error) console.log(error); - //console.log(encryptedData); - console.log("File Successfully Encrypted."); + + const encryptedData = crypto.publicEncrypt( + { + key: pbKey, + padding: crypto.constants.RSA_PKCS1_OAEP_PADDING, + oaepHash: "sha256", + }, + + Buffer.from(data) + ) + + fs.writeFile(againEncryptedfileP, encryptedData.toString('hex'), (error) => { + if (error) console.log(error); + console.log("File Successfully Encrypted."); + resolve(againEncryptedfileP); + }); + //resolve(againEncryptedfileP); }); }); }; exports.getDecryptFile = (filePath) => { - let prKey = fs.readFileSync('./keys/privateKey.key'); - const plainDataFilePath = './temp-file/decryptedFile.txt'; + return new Promise( (resolve) => { + + const plainDataFileP = './temp-file/decryptedFile.txt'; + //let prKey = fs.readFileSync('./keys/privateKey.key'); //toString?? + fs.readFile('./keys/privateKey.key', 'utf8', (err, prKey)=> { + + console.log('In the getDecryptFile(). '); + console.log(filePath); + + const tempPath = './public/files/'+ filePath; + + fs.readFile(tempPath, (err, encryptedData) => { + + const decryptedData = crypto.privateDecrypt( + { + key: prKey, + passphrase: 'sse', + padding: crypto.constants.RSA_PKCS8_OAEP_PADDING, + oaepHash: "sha256", + }, + encryptedData + ) + fs.writeFile(plainDataFileP, decryptedData , (error) => { + console.log('In the getDecryptFile(). writeFile '); + if (error) console.log(error); + console.log(decryptedData); + console.log("Successfully decrypted."); + resolve(plainDataFileP); + }); + //resolve(plainDataFileP); + }); + }); + }); + //return plainDataFilePath; +}; + +exports.getDecryptFileContent = (fileContent) => { + return new Promise((resolve)=> { + console.log("File Content: "+ fileContent); + fs.readFile('./keys/privateKey.key', 'utf8', (err, prKey) => { + console.log('prKey = ', prKey, typeof(prKey)); + + const plainData = crypto.privateDecrypt( + { + key: prKey, + passphrase: 'sse', + padding: crypto.constants.RSA_PKCS8_OAEP_PADDING, + oaepHash: "sha256", + }, + Buffer.from(fileContent,'hex') + ) + + //console.log("decrypted data: ", keyword.toString()); + resolve(plainData.toString() ); + }) + }); +}; - console.log(filePath); - console.log(fs.readFileSync('./public/files/'+filePath)); //its wrong completely - const tempPath = './public/files/'+ filePath; - fs.readFile(tempPath, (err, encryptedData) => { - const decryptedData = crypto.privateDecrypt( +exports.generateNonce = () => { + return new Promise((resolve)=> { + + crypto.randomInt(0, 1000000, (err, n) => { + if (err) throw err; + + resolve(n.toString()); + }) + }); +}; + +exports.getEncryptNonce = (pbKey, plainNonce) => { + return new Promise( (resolve) => { + console.log("At Nonce Encrypt: plainNonce: " + plainNonce +" tpy: "+ typeof(plainNonce)); + + const encryptedNonce = crypto.publicEncrypt( { - key: prKey, - passphrase: 'sse', - padding: crypto.constants.RSA_PKCS8_OAEP_PADDING, + key: pbKey, + padding: crypto.constants.RSA_PKCS1_OAEP_PADDING, oaepHash: "sha256", }, - encryptedData + + Buffer.from(plainNonce) ) - fs.writeFile(plainDataFilePath, decryptedData , (error) => { - if (error) console.log(error); - console.log(decryptedData); - console.log("Successfully decrypted."); - }); - - }); - - return plainDataFilePath; + console.log("At Nonce Encrypt: encryptNonce: ", encryptedNonce.toString('hex') + " typ: " + typeof(encryptedNonce.toString('hex'))); + resolve(encryptedNonce.toString('hex')); + }); }; + +exports.getDecryptNonce = (encryptedNonce) => { + return new Promise( (resolve) => { + console.log("At Nonce decrypt: encryptedNonce: " + encryptedNonce +" tpy: "+ typeof(encryptedNonce)); + console.log("At Nonce decrypt: encryptedNonce: buffer convert " + Buffer.from(encryptedNonce, 'hex') +" tpy: "+ typeof(Buffer.from(encryptedNonce, 'hex'))); + + fs.readFile('./keys/privateKey.key', 'utf8', (err, prKey)=> { + + const decryptedNonce = crypto.privateDecrypt( + { + key: prKey, + passphrase: 'sse', + padding: crypto.constants.RSA_PKCS8_OAEP_PADDING, + oaepHash: "sha256", + }, + Buffer.from(encryptedNonce, 'hex') //should use buffer??? + ) + console.log("At Nonce decrypt: decryptedNonce: " + decryptedNonce.toString() +" tpy: "+ typeof(decryptedNonce.toString())); + resolve(decryptedNonce.toString()); + }); + }); +} \ No newline at end of file diff --git a/app.js b/app.js index cc5052f..7c42ac0 100644 --- a/app.js +++ b/app.js @@ -20,6 +20,7 @@ const User = require('./models/user'); const encDec = require('./EncryptDecrypt-v2'); +const fs = require('fs'); const fileStorage = multer.diskStorage({ diff --git a/controllers/index.js b/controllers/index.js index 2dccefd..5605b9b 100644 --- a/controllers/index.js +++ b/controllers/index.js @@ -92,6 +92,7 @@ exports.postLogin = (req,res, next) => { .catch(err => console.log(err)); } + exports.getSignup = (req,res, next) => { let message = req.flash('error'); if (message.length > 0) { @@ -113,6 +114,16 @@ exports.getSignup = (req,res, next) => { }); } +// Make a function in index.js controller. +function fudai(){ + return new Promise((resolve, reject) => { + fs.readFile('./keys/publicKey.key', 'utf8', (err, data)=> { + console.log('Inside fudai.'); + resolve(data); + }); + }); +} + exports.postSignup = async (req,res, next) => { const email = req.body.email; const password = req.body.password; @@ -138,9 +149,12 @@ exports.postSignup = async (req,res, next) => { // If no error, encrypt the password, and save the user into database. const hashedPassword = await bcrypt.hash(password, 12); - encDec.generateKeys(); + await encDec.generateKeys(); + + let pbKey = await fudai(); + //let pbKey = await encDec.generateKeys(); - let pbKey = await fs.readFileSync('./keys/publicKey.key'); + console.log(pbKey, typeof(pbKey) ); // This is buffer Object const user = new User({ email: email, diff --git a/controllers/userShowReq.js b/controllers/userShowReq.js index d48ffe5..45d2429 100644 --- a/controllers/userShowReq.js +++ b/controllers/userShowReq.js @@ -7,6 +7,7 @@ const fs = require('fs'); const encDec = require('../EncryptDecrypt-v2'); const { ObjectID } = require('bson'); +const documents = require('../controllers/userUpDownDel').getDocuments(); exports.showFileById = (req, res, next) =>{ const fileId = req.params.myFileId; @@ -35,11 +36,12 @@ exports.showFileById = (req, res, next) =>{ exports.requestFile = async (req, res, next) =>{ const ownerId = req.params.ownerId; - const fileName = req.params.fileName; - + const fileName = req.params.fileName; // the file path actually (without /public/files.) console.log("requesting file begins"); - console.log(ownerId, fileName); - + + + + //If it is his file. if(req.user._id == ownerId){ return res.render('updown/searchResult', { pageTitle: "Search result", @@ -48,19 +50,43 @@ exports.requestFile = async (req, res, next) =>{ errorMessage: "This is your file man! " }); } - + + const theFile = await File.findOne({filePath: fileName}); - const owner = await User.findOne({_id: ownerId}); + + + + + //here is pushing nonce --starts + let nonce = await encDec.generateNonce(); //use random number or string -- but output must be in string + const updatedRequestedItems = [...req.user.dcart.allRequests]; + updatedRequestedItems.push({ + isAccept: 0, + ownerId: ownerId, + requestedFileId: theFile._id, + noncePlain: encDec.getKeywordHash(nonce), + fileContent: null, + nonceGet: null + }); + const updatedAllReqs = { + allRequests: updatedRequestedItems + }; + //console.log(updatedAllReqs); + req.user.dcart = updatedAllReqs; + await req.user.save(); + //here is pushing nonce --ends + + + // Update the Owner's notification array. const updatedNotificationItems = [...owner.reqs.notifications]; - console.log("theFile = ", theFile, "owner = ", owner, "updatedNoti = ", updatedNotificationItems); - updatedNotificationItems.push({ requesterId: req.user._id, requestedFileId: theFile._id, - decided: false + decided: false, + nonce: await encDec.getEncryptNonce(owner.publicKey, nonce) }); const updatedReqs = { notifications: updatedNotificationItems @@ -68,8 +94,12 @@ exports.requestFile = async (req, res, next) =>{ console.log("updated noti = ", updatedNotificationItems, "updated reqs = ", updatedReqs); owner.reqs = updatedReqs; await owner.save(); + + + console.log('Done with reques file.'); + // Show the search results to the User. res.render('updown/searchResult', { pageTitle: "Search result", path: "/user/searchResult", @@ -77,69 +107,195 @@ exports.requestFile = async (req, res, next) =>{ errorMessage: "Requset has been sent to the DataOwner. " }); } - + +function fudai(p){ + return new Promise((resolve, reject) => { + fs.readFile(p, (err, data)=> { //can not be utf8 + console.log('Inside fudai.. data:'+ data.toString()); + resolve(data); + }); + }); +} + +function findNonce(notifications,requesterId,requestedFileId){ + return new Promise((resolve) => { + for(let item of notifications){ + console.log('item -> ', item); + if(item.requesterId.equals(requesterId) && item.requestedFileId.equals(requestedFileId) && item.decided == false){ + console.log('Nonce -> ', item.nonce); + resolve(item.nonce); + } + } + }); +} exports.grantPermission = async (req, res, next) =>{ const requesterId = req.params.requesterId; const requestedFileId = req.params.requestedFileId; - const theFile = await File.findOne({_id: requestedFileId}); const requester = await User.findOne({_id: requesterId}); + console.log("theFile = ", theFile, "requester = ", requester, "requester public key = ", requester.publicKey); - console.log("theFile = ", theFile, "owner = ", requester); + + + //const plainDataFilePath = await encDec.getDecryptFile(theFile.filePath); + //await encDec.getEncryptFileV2(requester.publicKey.toString(), plainDataFilePath); + const plainDataFilePath = await encDec.getDecryptFile(theFile.filePath); + const fpath = await encDec.getEncryptFileV2(requester.publicKey, plainDataFilePath); - const plainDataFilePath = await encDec.getDecryptFile(theFile.filePath); //return output dont write - await encDec.getEncryptFileV2(requester.publicKey, plainDataFilePath); + + //let encryptedContent = await fudai(fpath); + + //for nonce + //just for test: + //let N = await encDec.getDecryptNonce(await encDec.getEncryptNonce(req.user.publicKey, "122")); + //console.log("Nonce Testing: " + N); + let currentUser = await User.findOne({_id: req.user._id}); + const notifications = [...currentUser.reqs.notifications]; + const nonce = await findNonce(notifications, requesterId, requestedFileId); + + let againEncryptedNonce = await encDec.getEncryptNonce(requester.publicKey, await encDec.getDecryptNonce(nonce)); + + //object already EXISTS......Dont push UPDATE::::STARTS + const queryRequest = { + 'dcart.allRequests': { + $elemMatch: { + isAccept: 0, + ownerId: req.user._id, + requestedFileId: requestedFileId + } + } + }; + console.log("Result for queryRequest: ", await User.findOne(queryRequest)); + await User.update(queryRequest, {$set: { + 'dcart.allRequests.$.isAccept': 2, + 'dcart.allRequests.$.fileContent': await fudai(fpath), + 'dcart.allRequests.$.nonceGet': againEncryptedNonce + }} ); +//object already EXISTS......Dont push UPDATE::::ENDS - let filePath = plainDataFilePath.split('/')[2]; - //console.log(filePath); - const updatedRequestedItems = [...requester.dcart.allRequests]; + +//cmnt starts here for nonce addinf purpose +/* const updatedRequestedItems = [...requester.dcart.allRequests]; updatedRequestedItems.push({ - isAccept: true, + isAccept: 2, ownerId: req.user._id, requestedFileId: theFile._id, - fileContent: filePath + nonceSent: againEncryptedNonce, + fileContent: await fudai(fpath) //encryptedContent }); - //console.log(updatedRequestedItems); const updatedAllReqs = { allRequests: updatedRequestedItems }; //console.log(updatedAllReqs); requester.dcart = updatedAllReqs; await requester.save(); + */ +//cmt ends here --- for nonce adding purpuse + + console.log(requester); //need to change + + /* + let currentUser = await User.findOne({_id: req.user._id}); + const updatedNotificationItems = [...currentUser.reqs.notifications]; + let itemToBeSaved; + for(let item of updatedNotificationItems){ + console.log('item -> ', item); + if(item.requesterId.equals(requesterId) && item.requestedFileId.equals(requestedFileId)){ + item.decided = true; + itemToBeSaved = item; + break; + } + } + */ + + const query = { + 'reqs.notifications': { + $elemMatch: { + requesterId: requesterId, + requestedFileId: requestedFileId + } + } + }; + + + await User.updateOne(query, {$set: { + 'reqs.notifications.$.decided': true + }} ); + console.log('Done with Grant Permission.'); res.redirect('/user/notification'); } exports.denyPermission = async (req, res, next) =>{ const requesterId = req.params.requesterId; + const requestedFileId = req.params.requestedFileId; const requester = await User.findOne({_id: requesterId}); const updatedRequestedItems = [...requester.dcart.allRequests]; + //for nonce + let currentUser = await User.findOne({_id: req.user._id}); + const notifications = [...currentUser.reqs.notifications]; + const nonce = await findNonce(notifications, requesterId, requestedFileId); + + let againEncryptedNonce = await encDec.getEncryptNonce(requester.publicKey, await encDec.getDecryptNonce(nonce)); + + //object already EXISTS......Dont push UPDATE::::STARTS + const queryRequest = { + 'dcart.allRequests': { + $elemMatch: { + isAccept: 0, + ownerId: req.user._id, + requestedFileId: requestedFileId + } + } + }; + console.log("Result for queryRequest: ", await User.findOne(queryRequest)); + await User.update(queryRequest, {$set: { + 'dcart.allRequests.$.isAccept': 1, + 'dcart.allRequests.$.nonceGet': againEncryptedNonce + }} ); + //object already EXISTS......Dont push UPDATE::::ENDS + + // For using Nonce - we dont push already added object - we update it -- start //console.log(updatedRequestedItems); - updatedRequestedItems.push({ - isAccept: false, - ownerId: req.user._id - //requestedFileId: , - //fileContent: +/* updatedRequestedItems.push({ + isAccept: 1, + ownerId: req.user._id, + nonceSent: againEncryptedNonce }); const updatedAllReqs = { allRequests: updatedRequestedItems }; requester.dcart = updatedAllReqs; - await requester.save(); + await requester.save(); */ + // For using Nonce - we dont push already added object - we update it -- end + + console.log('\n', requester, '\n'); //need to change - console.log('Done with Grant Permission.'); + const query = { + 'reqs.notifications': { + $elemMatch: { + requesterId: requesterId, + requestedFileId: requestedFileId + } + } + }; + await User.updateOne(query, {$set: { + 'reqs.notifications.$.decided': true + }} ); + + console.log('Done with Deny Permission.'); res.redirect('/user/notification'); } @@ -167,7 +323,31 @@ exports.getAllRequests = (req, res, next) =>{ }) } -exports.showDecryptedFileContent = (req, res, next) =>{ +function verifyNonce(noncePlain, plainNonce){ + let verify = false; + if(JSON.stringify(noncePlain) == JSON.stringify(encDec.getKeywordHash(plainNonce))){ + verify = true; + } + return verify; +} + +exports.showDecryptedFileContent = async(req, res, next) =>{ const content = req.params.fileContent; - res.redirect('/user/notification'); + const noncePlain = req.params.noncePlain; + const nonceGet = req.params.nonceGet; + //console.log(fs.readFileSync('./public/files/rosalind.txt').toString()); + //console.log(nonceGet); + + let plainNonce = await encDec.getDecryptNonce(nonceGet); + let verify = verifyNonce(noncePlain, plainNonce); + console.log(verify); + + const plainData = await encDec.getDecryptFileContent(content); + + res.render("updown/showDecryptedContent",{ + pageTitle: "File Content", + path: "/user/request", + documents: plainData, + verification: verify + }) } \ No newline at end of file diff --git a/controllers/userUpDownDel.js b/controllers/userUpDownDel.js index 33e80d0..9dabfba 100644 --- a/controllers/userUpDownDel.js +++ b/controllers/userUpDownDel.js @@ -40,9 +40,10 @@ exports.postUploadFile = async (req, res, next) =>{ // encrypt the file, store it to the same path - encDec.getEncryptFile(/* req.user.publicKey, */ tempPath); + encDec.getEncryptFile(req.user.publicKey, tempPath); tempPath = file.path.split('/')[2]; // this is to store in the user.cart.myFiles + console.log("Here in PostUplod public key of owner: " + req.user.publicKey); let encryptedKeyword = encDec.getEncryptionKeyword(req.user.publicKey, keyword); let space_separated_keywords = keyword.split(' '); @@ -229,6 +230,8 @@ async function calculate1(space_separated_keywords){ } } +let sortable = []; +let documents = []; // It makes the array sorted in descending order. To show more matched files before the less matched files. function calculate2(){ sortable = []; @@ -353,3 +356,6 @@ exports.deleteFile = async (req, res, next) => { } +exports.getDocuments = function(){ + return documents; +} \ No newline at end of file diff --git a/keys/privateKey.key b/keys/privateKey.key index c11da68..576fb7a 100644 --- a/keys/privateKey.key +++ b/keys/privateKey.key @@ -1,30 +1,30 @@ -----BEGIN ENCRYPTED P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NdJbdOO3VS5Y89rgzElA4S5CBH +5WI7N73RK8XUZR1jd8lfchExF05eKyr6LKo0ix7NX0AjhhxYgrShPLSxGZP/4+5T +JJzYlQK5iFmZU9Dx0E2Jn2r4NE7/Aic79d7YheZL+9WMjv3HNRotqK/pEl17JpSC +pMtfuIUZxihWFSGsn+qcBtn60/UClyxo8iDXLdzs72S0dOPf0rCRsQX4tKJa9vFb +cJPwwQfLdNTee4afps/CEIAby4Vf6oZoihFVhPfW/wS4TajSKzZf5hAnYE/U06oP +T7newaSlAeRtgIjoCs1MSX63zWy8yzbcBlzOb5T50/Q0wBjnVbPYrL2OEC/K0peV +uUw31h1HRdyNlQcIFpNPXcRDO0rh7Q77HOjgbiQTUk8p -----END ENCRYPTED PRIVATE KEY----- diff --git a/keys/publicKey.key b/keys/publicKey.key index 5adf090..c981a08 100644 --- a/keys/publicKey.key +++ b/keys/publicKey.key @@ -1,8 +1,8 @@ -----BEGIN RSA PUBLIC KEY----- -MIIBCgKCAQEArLBKpZnTjSz+QOrdwXzlS32lMR4+adEWXGXgvTMHl3inrU+kZbp8 -4RmQQOHWv/7j5B56sBOil2KjSBg7R6v4LTy4x2iWbCJpzl8KoFJjnsJXrz34aZnb -a2UzbZHBqxDl1bC1MjxTweQCKctxSpCwQJyJlDAqD3KGfMfbyEyhLLJBRr/nAIaX -3RmE95DZWukdmXu2nBw58aOZfO0Sjui3evLpIkz0MJhf7P2aBFCnia9zcCriRKgt -YfpMfjWpUcJGtUq9+xxPfFCvQBf5JIzfl0t3xZ3G//c74f8gAdnMEunV2ibR1pdh -XBRVuL3oP2+a6Yz+K8ojrdkr/S++y4rggwIDAQEB +MIIBCgKCAQEAs4ut2eKB5XWIdYxTdTV/2FsrqOcfvLeWWkPGUQe3mtS+hbzZEzah +gM26eVgRRt2jft6W44IjE6ZaMqljcQ0hN517UDMld3fh1dHX4ITWiljnw7MGwMl4 +WEELO0Z0ouwQZ2BPwgenkJkxIhTcKu13BmspPk63+YouWjMZuKnjoeXvMPTB+GRt +P2nrmrrS0CeLJPfwgMEp1C7uLPT/qk7/op4eadtfHiXOIXWNjXu0fJPGbIalu7kF +xhtQ1kW3Ah3aTQWjub9KLBDL5HA1W93lMlSKjrmgOYHIKlOcdkkvSIkj3+LghH7D +7nWiZV4n3XQufuE0spmPe9yVXHrDOHqlIwIDAQEB -----END RSA PUBLIC KEY----- diff --git a/models/user.js b/models/user.js index 8e35042..467319a 100644 --- a/models/user.js +++ b/models/user.js @@ -32,17 +32,20 @@ const userSchema = new Schema({ { requesterId: {type: Schema.Types.ObjectId, required: true}, requestedFileId: {type: Schema.Types.ObjectId, required: true}, - decided: {type: Boolean, required: true} + decided: {type: Boolean, required: true}, + nonce: {type: String, required: false}, } ] }, dcart: { allRequests: [ { - isAccept: {type: Boolean, required: true}, + isAccept: {type: Number, required: true}, ownerId: {type: Schema.Types.ObjectId, required: false}, requestedFileId: {type: Schema.Types.ObjectId, required: false}, - fileContent: {type: String, required: false} + fileContent: {type: String, required: false}, + noncePlain: {type: String, required: false}, //plain random number as string + nonceGet: {type: String, required: false} } ] } diff --git a/node_modules/.package-lock.json b/node_modules/.package-lock.json index 7898377..dfc64ae 100644 --- a/node_modules/.package-lock.json +++ b/node_modules/.package-lock.json @@ -449,6 +449,7 @@ "dependencies": { "anymatch": "~3.1.1", "braces": "~3.0.2", + "fsevents": "~2.3.1", "glob-parent": "~5.1.0", "is-binary-path": "~2.1.0", "is-glob": "~4.0.1", @@ -976,6 +977,19 @@ "resolved": "https://registry.npmjs.org/fs/-/fs-0.0.1-security.tgz", "integrity": "sha1-invTcYa23d84E/I4WLV+yq9eQdQ=" }, + "node_modules/fsevents": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz", + "integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==", + "hasInstallScript": true, + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^8.16.0 || ^10.6.0 || >=11.0.0" + } + }, "node_modules/generate-function": { "version": "2.3.1", "resolved": "https://registry.npmjs.org/generate-function/-/generate-function-2.3.1.tgz", @@ -1456,7 +1470,8 @@ "bson": "^1.1.4", "denque": "^1.4.1", "optional-require": "^1.0.3", - "safe-buffer": "^5.1.2" + "safe-buffer": "^5.1.2", + "saslprep": "^1.0.0" }, "engines": { "node": ">=4" @@ -1486,9 +1501,9 @@ } }, "node_modules/mongoose": { - "version": "5.12.11", - "resolved": "https://registry.npmjs.org/mongoose/-/mongoose-5.12.11.tgz", - "integrity": "sha512-16TVqYhHQdZNR8RTis/8iiTPy+nJPq0UhKyBFTucLLU3PWcDLY2gAGv6aOk0LygTNhEfgNnENgUUHhjVqTuh8w==", + "version": "5.12.12", + "resolved": "https://registry.npmjs.org/mongoose/-/mongoose-5.12.12.tgz", + "integrity": "sha512-n+ZmGApaL5x/r92w6S4pb+c075i+YKzg1F9YWkznSzQMtvetj/2dSjj2cqsITpd6z60k3K7ZaosIl6hzHwUA9g==", "dependencies": { "@types/mongodb": "^3.5.27", "bson": "^1.1.4", @@ -1528,7 +1543,8 @@ "bson": "^1.1.4", "denque": "^1.4.1", "optional-require": "^1.0.3", - "safe-buffer": "^5.1.2" + "safe-buffer": "^5.1.2", + "saslprep": "^1.0.0" }, "engines": { "node": ">=4" @@ -1755,9 +1771,6 @@ }, "bin": { "nopt": "bin/nopt.js" - }, - "engines": { - "node": "*" } }, "node_modules/normalize-path": { diff --git a/node_modules/mongoose/History.md b/node_modules/mongoose/History.md index 20223c9..c235fda 100644 --- a/node_modules/mongoose/History.md +++ b/node_modules/mongoose/History.md @@ -1,3 +1,9 @@ +5.12.12 / 2021-05-28 +==================== + * fix(documentarray): retain atomics when setting to a new array #10272 + * fix(query+model): fix deprecation warning for `returnOriginal` with `findOneAndUpdate()` #10298 #10297 #10292 #10285 [IslandRhythms](https://github.com/IslandRhythms) + * fix(index.d.ts): make `map()` result an array if used over an array #10288 [quantumsheep](https://github.com/quantumsheep) + 5.12.11 / 2021-05-24 ==================== * fix(populate): skip applying setters when casting arrays for populate() to avoid issues with arrays of immutable elements #10264 diff --git a/node_modules/mongoose/dist/browser.umd.js b/node_modules/mongoose/dist/browser.umd.js index 7213d27..4b8fd35 100644 --- a/node_modules/mongoose/dist/browser.umd.js +++ b/node_modules/mongoose/dist/browser.umd.js @@ -1319,11 +1319,11 @@ a._checkRequired=function(t){return!0===t||!1===t},a.checkRequired=o.checkRequir t.exports=a},function(t,e,r){"use strict"; /*! * Module dependencies. - */var n,o,i=r(56),s=r(13),a=r(19).EventEmitter,u=r(159),c=r(6),l=r(31),f=r(92),p=r(3),h=r(93),y=r(4),d=r(1),_=r(94),v=r(0).arrayPathSymbol,m=r(0).documentArrayParent;function g(t,e,r,n){null!=n&&null!=n._id?e=h(e,n):null!=r&&null!=r._id&&(e=h(e,r));var o=b(e,r);o.prototype.$basePath=t,i.call(this,t,o,r),this.schema=e,this.schemaOptions=n||{},this.$isMongooseDocumentArray=!0,this.Constructor=o,o.base=e.base;var s=this.defaultValue;"defaultValue"in this&&void 0===s||this.default((function(){var t=s.call(this);return Array.isArray(t)||(t=[t]),t}));var a=this;this.$embeddedSchemaType=new c(t+".$",{required:p(this,"schemaOptions.required",!1)}),this.$embeddedSchemaType.cast=function(t,e,r){return a.cast(t,e,r)[0]},this.$embeddedSchemaType.$isMongooseDocumentArrayElement=!0,this.$embeddedSchemaType.caster=this.Constructor,this.$embeddedSchemaType.schema=this.schema} + */var n,o,i=r(56),s=r(13),a=r(19).EventEmitter,u=r(159),c=r(6),l=r(31),f=r(92),p=r(3),h=r(93),y=r(4),d=r(1),_=r(94),v=r(0).arrayAtomicsSymbol,m=r(0).arrayPathSymbol,g=r(0).documentArrayParent;function b(t,e,r,n){null!=n&&null!=n._id?e=h(e,n):null!=r&&null!=r._id&&(e=h(e,r));var o=w(e,r);o.prototype.$basePath=t,i.call(this,t,o,r),this.schema=e,this.schemaOptions=n||{},this.$isMongooseDocumentArray=!0,this.Constructor=o,o.base=e.base;var s=this.defaultValue;"defaultValue"in this&&void 0===s||this.default((function(){var t=s.call(this);return Array.isArray(t)||(t=[t]),t}));var a=this;this.$embeddedSchemaType=new c(t+".$",{required:p(this,"schemaOptions.required",!1)}),this.$embeddedSchemaType.cast=function(t,e,r){return a.cast(t,e,r)[0]},this.$embeddedSchemaType.$isMongooseDocumentArrayElement=!0,this.$embeddedSchemaType.caster=this.Constructor,this.$embeddedSchemaType.schema=this.schema} /*! * Ignore */ -function b(t,e,n){function i(){o.apply(this,arguments),this.$session(this.ownerDocument().$session())}o||(o=r(26));var s=null!=n?n.prototype:o.prototype;for(var u in i.prototype=Object.create(s),i.prototype.$__setSchema(t),i.schema=t,i.prototype.constructor=i,i.$isArraySubdocument=!0,i.events=new a,t.methods)i.prototype[u]=t.methods[u];for(var c in t.statics)i[c]=t.statics[c];for(var l in a.prototype)i[l]=a.prototype[l];return i.options=e,i} +function w(t,e,n){function i(){o.apply(this,arguments),this.$session(this.ownerDocument().$session())}o||(o=r(26));var s=null!=n?n.prototype:o.prototype;for(var u in i.prototype=Object.create(s),i.prototype.$__setSchema(t),i.schema=t,i.prototype.constructor=i,i.$isArraySubdocument=!0,i.events=new a,t.methods)i.prototype[u]=t.methods[u];for(var c in t.statics)i[c]=t.statics[c];for(var l in a.prototype)i[l]=a.prototype[l];return i.options=e,i} /*! * Scopes paths selected in a query to this array. * Necessary for proper default application of subdocument values. @@ -1332,27 +1332,27 @@ function b(t,e,n){function i(){o.apply(this,arguments),this.$session(this.ownerD * @param {Object|undefined} fields - the root fields selected in the query * @param {Boolean|undefined} init - if we are being created part of a query result */ -function w(t,e,r){if(r&&e){for(var n,o,i,s=t.path+".",a=Object.keys(e),u=a.length,c={};u--;)if((o=a[u]).startsWith(s)){if("$"===(i=o.substring(s.length)))continue;i.startsWith("$.")&&(i=i.substr(2)),n||(n=!0),c[i]=e[o]}return n&&c||void 0}}g.schemaName="DocumentArray",g.options={castNonArrays:!0}, +function O(t,e,r){if(r&&e){for(var n,o,i,s=t.path+".",a=Object.keys(e),u=a.length,c={};u--;)if((o=a[u]).startsWith(s)){if("$"===(i=o.substring(s.length)))continue;i.startsWith("$.")&&(i=i.substr(2)),n||(n=!0),c[i]=e[o]}return n&&c||void 0}}b.schemaName="DocumentArray",b.options={castNonArrays:!0}, /*! * Inherits from ArrayType. */ -g.prototype=Object.create(i.prototype),g.prototype.constructor=g,g.prototype.OptionsConstructor=u,g.prototype.discriminator=function(t,e,r){"function"==typeof t&&(t=d.getFunctionName(t));var n=b(e=f(this.casterConstructor,t,e,r),null,this.casterConstructor);n.baseCasterConstructor=this.casterConstructor;try{Object.defineProperty(n,"name",{value:t})}catch(t){}return this.casterConstructor.discriminators[t]=n,this.casterConstructor.discriminators[t]},g.prototype.doValidate=function(t,e,i,s){n||(n=r(18));var a=this;try{c.prototype.doValidate.call(this,t,(function(r){if(r)return r.$isArrayValidatorError=!0,e(r);var u,c=t&&t.length;if(!c)return e();if(s&&s.updateValidator)return e();t.isMongooseDocumentArray||(t=new n(t,a.path,i));function f(t){null!=t&&((u=t)instanceof l||(u.$isArrayValidatorError=!0)),--c||e(u)}for(var p=0,h=c;p = Query & THelpers; @@ -2096,7 +2100,7 @@ declare module 'mongoose' { * Runs a function `fn` and treats the return value of `fn` as the new value * for the query to resolve to. */ - map(fn: (doc: DocType) => MappedType): QueryWithHelpers; + map(fn: (doc: DocType) => MappedType): QueryWithHelpers; /** Specifies an `$maxDistance` query condition. When called with one argument, the most recent path passed to `where()` is used. */ maxDistance(val: number): this; diff --git a/node_modules/mongoose/lib/query.js b/node_modules/mongoose/lib/query.js index da5be86..8b83f30 100644 --- a/node_modules/mongoose/lib/query.js +++ b/node_modules/mongoose/lib/query.js @@ -3109,7 +3109,7 @@ Query.prototype.findOneAndUpdate = function(criteria, doc, options, callback) { const returnOriginal = get(this, 'model.base.options.returnOriginal'); - if (options.returnOriginal == null && returnOriginal != null) { + if (options.new == null && options.returnDocument == null && options.returnOriginal == null && returnOriginal != null) { options.returnOriginal = returnOriginal; } @@ -3435,10 +3435,9 @@ Query.prototype.findOneAndReplace = function(filter, replacement, options, callb options = options || {}; const returnOriginal = get(this, 'model.base.options.returnOriginal'); - if (options.returnOriginal == null && returnOriginal != null) { + if (options.new == null && options.returnDocument == null && options.returnOriginal == null && returnOriginal != null) { options.returnOriginal = returnOriginal; } - this.setOptions(options); this.setOptions({ overwrite: true }); @@ -3468,7 +3467,7 @@ Query.prototype._findOneAndReplace = wrapThunk(function(callback) { const filter = this._conditions; const options = this._optionsForExec(); - convertNewToReturnOriginal(options); + convertNewToReturnDocument(options); let fields = null; let castedDoc = new this.model(this._update, null, true); @@ -3510,11 +3509,15 @@ Query.prototype._findOneAndReplace = wrapThunk(function(callback) { * compat. */ -function convertNewToReturnOriginal(options) { +function convertNewToReturnDocument(options) { if ('new' in options) { - options.returnOriginal = !options['new']; + options.returnDocument = options['new'] ? 'after' : 'before'; delete options['new']; } + if ('returnOriginal' in options) { + options.returnDocument = options['returnOriginal'] ? 'before' : 'after'; + delete options['returnOriginal']; + } } /*! @@ -3669,7 +3672,7 @@ Query.prototype._findAndModify = function(type, callback) { if (useFindAndModify === false) { // Bypass mquery const collection = _this._collection.collection; - convertNewToReturnOriginal(opts); + convertNewToReturnDocument(opts); if (type === 'remove') { collection.findOneAndDelete(castedQuery, opts, _wrapThunkCallback(_this, function(error, res) { diff --git a/node_modules/mongoose/lib/schema/documentarray.js b/node_modules/mongoose/lib/schema/documentarray.js index 29baf23..509c7bf 100644 --- a/node_modules/mongoose/lib/schema/documentarray.js +++ b/node_modules/mongoose/lib/schema/documentarray.js @@ -18,6 +18,7 @@ const util = require('util'); const utils = require('../utils'); const getConstructor = require('../helpers/discriminator/getConstructor'); +const arrayAtomicsSymbol = require('../helpers/symbols').arrayAtomicsSymbol; const arrayPathSymbol = require('../helpers/symbols').arrayPathSymbol; const documentArrayParent = require('../helpers/symbols').documentArrayParent; @@ -401,6 +402,10 @@ DocumentArrayPath.prototype.cast = function(value, doc, init, prev, options) { value = new MongooseDocumentArray(value, this.path, doc); } + if (prev != null) { + value[arrayAtomicsSymbol] = prev[arrayAtomicsSymbol] || {}; + } + if (options.arrayPathIndex != null) { value[arrayPathSymbol] = this.path + '.' + options.arrayPathIndex; } diff --git a/node_modules/mongoose/lib/schematype.js b/node_modules/mongoose/lib/schematype.js index 8c87fdb..03ea4b9 100644 --- a/node_modules/mongoose/lib/schematype.js +++ b/node_modules/mongoose/lib/schematype.js @@ -1097,7 +1097,6 @@ SchemaType.prototype._castNullish = function _castNullish(v) { SchemaType.prototype.applySetters = function(value, scope, init, priorVal, options) { let v = this._applySetters(value, scope, init, priorVal, options); - if (v == null) { return this._castNullish(v); } diff --git a/node_modules/mongoose/package.json b/node_modules/mongoose/package.json index 6297c7b..f6153b8 100644 --- a/node_modules/mongoose/package.json +++ b/node_modules/mongoose/package.json @@ -1,7 +1,7 @@ { "name": "mongoose", "description": "Mongoose MongoDB ODM", - "version": "5.12.11", + "version": "5.12.12", "author": "Guillermo Rauch ", "keywords": [ "mongodb", diff --git a/package-lock.json b/package-lock.json index 0bad81f..979d600 100644 --- a/package-lock.json +++ b/package-lock.json @@ -471,6 +471,7 @@ "dependencies": { "anymatch": "~3.1.1", "braces": "~3.0.2", + "fsevents": "~2.3.1", "glob-parent": "~5.1.0", "is-binary-path": "~2.1.0", "is-glob": "~4.0.1", @@ -1491,7 +1492,8 @@ "bson": "^1.1.4", "denque": "^1.4.1", "optional-require": "^1.0.3", - "safe-buffer": "^5.1.2" + "safe-buffer": "^5.1.2", + "saslprep": "^1.0.0" }, "engines": { "node": ">=4" @@ -1521,9 +1523,9 @@ } }, "node_modules/mongoose": { - "version": "5.12.11", - "resolved": "https://registry.npmjs.org/mongoose/-/mongoose-5.12.11.tgz", - "integrity": "sha512-16TVqYhHQdZNR8RTis/8iiTPy+nJPq0UhKyBFTucLLU3PWcDLY2gAGv6aOk0LygTNhEfgNnENgUUHhjVqTuh8w==", + "version": "5.12.12", + "resolved": "https://registry.npmjs.org/mongoose/-/mongoose-5.12.12.tgz", + "integrity": "sha512-n+ZmGApaL5x/r92w6S4pb+c075i+YKzg1F9YWkznSzQMtvetj/2dSjj2cqsITpd6z60k3K7ZaosIl6hzHwUA9g==", "dependencies": { "@types/mongodb": "^3.5.27", "bson": "^1.1.4", @@ -1563,7 +1565,8 @@ "bson": "^1.1.4", "denque": "^1.4.1", "optional-require": "^1.0.3", - "safe-buffer": "^5.1.2" + "safe-buffer": "^5.1.2", + "saslprep": "^1.0.0" }, "engines": { "node": ">=4" @@ -1790,9 +1793,6 @@ }, "bin": { "nopt": "bin/nopt.js" - }, - "engines": { - "node": "*" } }, "node_modules/normalize-path": { @@ -3733,9 +3733,9 @@ } }, "mongoose": { - "version": "5.12.11", - "resolved": "https://registry.npmjs.org/mongoose/-/mongoose-5.12.11.tgz", - "integrity": "sha512-16TVqYhHQdZNR8RTis/8iiTPy+nJPq0UhKyBFTucLLU3PWcDLY2gAGv6aOk0LygTNhEfgNnENgUUHhjVqTuh8w==", + "version": "5.12.12", + "resolved": "https://registry.npmjs.org/mongoose/-/mongoose-5.12.12.tgz", + "integrity": "sha512-n+ZmGApaL5x/r92w6S4pb+c075i+YKzg1F9YWkznSzQMtvetj/2dSjj2cqsITpd6z60k3K7ZaosIl6hzHwUA9g==", "requires": { "@types/mongodb": "^3.5.27", "bson": "^1.1.4", diff --git a/public/files/2021-05-26T07:46:36.514Z-*-random.txt b/public/files/2021-05-26T07:46:36.514Z-*-random.txt deleted file mode 100644 index 3d5f50b..0000000 --- a/public/files/2021-05-26T07:46:36.514Z-*-random.txt +++ /dev/null @@ -1 +0,0 @@ -04dd04e243beb318//f9e13f87275cba85f12377f97ae0039c9fd20d9120305b3c6c93d8f121001949 \ No newline at end of file diff --git a/public/files/2021-05-26T07:46:52.381Z-*-some.txt b/public/files/2021-05-26T07:46:52.381Z-*-some.txt deleted file mode 100644 index 59bc70c..0000000 --- a/public/files/2021-05-26T07:46:52.381Z-*-some.txt +++ /dev/null @@ -1 +0,0 @@ -7f93a085ea5af678//d6bfa95eb02cd02a92e3bc5a554d07685c3deb426c28f27d6119b309c13419bac22b7b57c0722750f9087fb03f892c46b70f6e63e4bc418cd5c7b337de58029bbea7936dadd391b1ab4d86cb252d28d137c5e3050a4e7b70978707d7869ca2c4905ca00c8ea7ec466e0c4104249dd131af31a4065f22dd70f8cac78a053254428d75fd16b94ba7f1c7d1e4505c89fa5162f8f3181f325d9a79746a06a07819366db19752784b17cbc615a4173b6ba182ba432ee2b80924fa0a460476b8d7afc87e8d8d32a6a05f8872016567996e0fa254b4f8dcec2347491ed852cf2c159713888ab6a1c84c0b745427688d3d39ac00e33e4e5ae13bd8a73d19ecb16ba02c9cd68a2bafaf3185c0c70f59f68ddf316e44b81ae9e1ee5c709196703b30ee70b1d71323e00134f0562932075e848a5b76c058d422d057fdf45a0a31541b8b82416006c2360880e5944272e7b564c5ca02283f2efec5e7443a70f276b659249a8e8fcce14ee06e5f886a2f455f834d350fa60811b4d542becd95c1d78b556e943b027bf08dd72e69df2defc33a9c124fc245e9e28326f3e53369c89979f25b2fe696f6b6fb6abd7a97c2feea43135d04e8c83946c4eb0cce20ed85beeff7949eada90a5f79b0c9a60bf8b278cacf481f4128e2e5212f14a678ddff9b8e1e626c62f8de7ffea40d0deb3b58f6c8104ab16030e97bf752703966ffb78dc40f8b0d2d0d0b2832c4d4d8027ff4d3159badd57f \ No newline at end of file diff --git a/public/files/2021-05-27T15:08:16.002Z-*-output140421.txt b/public/files/2021-05-27T15:08:16.002Z-*-output140421.txt deleted file mode 100644 index a5ec735..0000000 --- a/public/files/2021-05-27T15:08:16.002Z-*-output140421.txt +++ /dev/null @@ -1 +0,0 @@ -hello there. diff --git a/public/files/2021-05-27T15:09:51.952Z-*-output140421.txt b/public/files/2021-05-27T15:09:51.952Z-*-output140421.txt deleted file mode 100644 index 32337e3..0000000 Binary files a/public/files/2021-05-27T15:09:51.952Z-*-output140421.txt and /dev/null differ diff --git a/public/files/2021-05-27T15:35:29.199Z-*-rosalind.txt b/public/files/2021-05-27T15:35:29.199Z-*-rosalind.txt deleted file mode 100644 index 241712f..0000000 Binary files a/public/files/2021-05-27T15:35:29.199Z-*-rosalind.txt and /dev/null differ diff --git a/public/files/2021-05-27T18:12:13.436Z-*-test.txt b/public/files/2021-05-27T18:12:13.436Z-*-test.txt deleted file mode 100644 index 989f9fd..0000000 Binary files a/public/files/2021-05-27T18:12:13.436Z-*-test.txt and /dev/null differ diff --git a/public/files/2021-05-27T18:21:22.710Z-*-solive.txt b/public/files/2021-05-27T18:21:22.710Z-*-solive.txt deleted file mode 100644 index 128a41e..0000000 Binary files a/public/files/2021-05-27T18:21:22.710Z-*-solive.txt and /dev/null differ diff --git a/public/files/2021-05-27T18:55:36.388Z-*-sse solve.txt b/public/files/2021-05-27T18:55:36.388Z-*-sse solve.txt deleted file mode 100644 index b1c18f3..0000000 Binary files a/public/files/2021-05-27T18:55:36.388Z-*-sse solve.txt and /dev/null differ diff --git a/public/files/2021-05-27T20:32:59.762Z-*-sse last.txt b/public/files/2021-05-27T20:32:59.762Z-*-sse last.txt deleted file mode 100644 index 99f6c2b..0000000 Binary files a/public/files/2021-05-27T20:32:59.762Z-*-sse last.txt and /dev/null differ diff --git a/public/files/2021-05-28T08:08:07.912Z-*-3_papers.txt b/public/files/2021-05-28T08:08:07.912Z-*-3_papers.txt deleted file mode 100644 index e72b612..0000000 --- a/public/files/2021-05-28T08:08:07.912Z-*-3_papers.txt +++ /dev/null @@ -1,5 +0,0 @@ -1. A Blockchain-Based Framework for Data Sharing -With Fine-Grained Access Control in -Decentralized Storage Systems 2 -.ProvChainABlockchain-basedDataProvenanceArchitectureinCloud. 3 -.Blockchain-Based Public Integrity Verification for Cloud Storage against Procrastinating Auditors. diff --git a/public/files/2021-05-28T08:51:11.548Z-*-some.txt b/public/files/2021-05-28T08:51:11.548Z-*-some.txt deleted file mode 100644 index 159a08b..0000000 --- a/public/files/2021-05-28T08:51:11.548Z-*-some.txt +++ /dev/null @@ -1,26 +0,0 @@ -something - - const keyHash = encDec.getKeywordHash(tmpKey); - - KeywordIndex.findOne({index_hash: keyHash}).then(keyDoc => { - if(keyDoc){ - let myfiles = [...keyDoc.whereItIs.myFiles]; - - for(var fl in myFiles){ - var fp = fl.filePath; - console.log("Type = ", typeof(fp)); - - if(freqTable[fp]) {freqTable[fp]++; console.log("IN true.");} - else { freqTable[fp] = 1; console.log("In False. ", freqTable);} - } - - } - else{ - console.log("nothing.") - } - }); - - - - - diff --git a/public/files/2021-05-28T09:03:47.084Z-*-random.txt b/public/files/2021-05-28T09:03:47.084Z-*-random.txt deleted file mode 100644 index f30003b..0000000 Binary files a/public/files/2021-05-28T09:03:47.084Z-*-random.txt and /dev/null differ diff --git a/public/files/2021-05-28T09:04:09.026Z-*-3_papers.txt b/public/files/2021-05-28T09:04:09.026Z-*-3_papers.txt deleted file mode 100644 index 33a8380..0000000 Binary files a/public/files/2021-05-28T09:04:09.026Z-*-3_papers.txt and /dev/null differ diff --git a/public/files/2021-05-30T09:10:32.248Z-*-Thank Bob.txt b/public/files/2021-05-30T09:10:32.248Z-*-Thank Bob.txt new file mode 100644 index 0000000..7e4998f Binary files /dev/null and b/public/files/2021-05-30T09:10:32.248Z-*-Thank Bob.txt differ diff --git a/public/files/2021-05-30T15:26:42.220Z-*-Angry Bob.txt b/public/files/2021-05-30T15:26:42.220Z-*-Angry Bob.txt new file mode 100644 index 0000000..c421b45 Binary files /dev/null and b/public/files/2021-05-30T15:26:42.220Z-*-Angry Bob.txt differ diff --git a/public/files/2021-05-30T20:15:31.073Z-*-BobNew1.txt b/public/files/2021-05-30T20:15:31.073Z-*-BobNew1.txt new file mode 100644 index 0000000..951eb47 Binary files /dev/null and b/public/files/2021-05-30T20:15:31.073Z-*-BobNew1.txt differ diff --git a/public/files/2021-05-31T05:16:11.316Z-*-Management.txt b/public/files/2021-05-31T05:16:11.316Z-*-Management.txt new file mode 100644 index 0000000..9603e13 Binary files /dev/null and b/public/files/2021-05-31T05:16:11.316Z-*-Management.txt differ diff --git a/public/files/2021-05-31T05:18:32.110Z-*-Management-Repy.txt b/public/files/2021-05-31T05:18:32.110Z-*-Management-Repy.txt new file mode 100644 index 0000000..7ec135a Binary files /dev/null and b/public/files/2021-05-31T05:18:32.110Z-*-Management-Repy.txt differ diff --git a/public/files/rosalind.txt b/public/files/rosalind.txt deleted file mode 100644 index 70a58d0..0000000 --- a/public/files/rosalind.txt +++ /dev/null @@ -1 +0,0 @@ -rosalinf solutions!!! \ No newline at end of file diff --git a/routes/user.js b/routes/user.js index 03de055..f914453 100644 --- a/routes/user.js +++ b/routes/user.js @@ -30,7 +30,7 @@ router.get('/show-file/:myFileId', userController2.showFileById); router.get('/notification', userController2.getAllNotifications); -router.get('/show-decrypted-content/:request.fileContent', userController2.showDecryptedFileContent); +router.get('/show-decrypted-content/:fileContent/:noncePlain/:nonceGet', userController2.showDecryptedFileContent); router.get('/request', userController2.getAllRequests); @@ -40,6 +40,6 @@ router.post('/request-file/:ownerId/:fileName', userController2.requestFile); router.post('/grant-permission/:requesterId/:requestedFileId', userController2.grantPermission); -router.post('/deny-permission/:requesterId', userController2.denyPermission); +router.post('/deny-permission/:requesterId/:requestedFileId', userController2.denyPermission); module.exports = router; \ No newline at end of file diff --git a/temp-file/againEncryptFile.txt b/temp-file/againEncryptFile.txt new file mode 100644 index 0000000..bd70c3d --- /dev/null +++ b/temp-file/againEncryptFile.txt @@ -0,0 +1 @@ +993476bb14d374db67384a5ff58824e3ac7a6923b2183d1cf790e58d818f1de02fd45e3cd40300faaa24c79dabb51048748d1cf2247def209fe7ed9877d95179187b37caac85d9dc741ae4202861699cb4af894c9f3341c39ec52d8c36e246db5de5ee5b72f4fb1ef862329cab716d3a16bc80427d894b637115efc44a57294602e850905d50d06b4604623c78e1f966c87ca161add6b8112259fd751c86194114f5bd520040a9438fc577c1a4e26efe7b6a05540ecc50297a8e94a33d7314aa45b6a5ab111b1391c37e6ebee04cd4e79219f5e413f1afdded74b8fa28f1a92437f9c5c9da9bd6d0905a73bbabc2df8752f2f5bf3950f81e2aa372ac0930ffdd \ No newline at end of file diff --git a/temp-file/decryptedFile.txt b/temp-file/decryptedFile.txt index 480c849..9a098ab 100644 --- a/temp-file/decryptedFile.txt +++ b/temp-file/decryptedFile.txt @@ -1,3 +1 @@ -j #t&Xf I ʸ 12LePEF&֧Im -3n QT/:JC<T"3,y@2_5H='Xn!EbY3aڇ<¹Sm -퀃IO (|*b%&V߼s^'aId6&DvVnSLJxCu'_j6b C'&G8(Y# \ No newline at end of file +Thomas' signature recording was "Raindrops Keep Fallin' On My Head," a No. 1 pop hit. diff --git a/views/updown/notification.ejs b/views/updown/notification.ejs index 425baa9..7fc92a0 100644 --- a/views/updown/notification.ejs +++ b/views/updown/notification.ejs @@ -15,8 +15,12 @@

Requester Id : <%= notification.requesterId %>

+ + <% if(notification.decided == false) { %>
@@ -27,13 +31,19 @@
- + -
+ <% } else { %> + +
+

Already decided.

+
+ <% } %> + <% } %> diff --git a/views/updown/request.ejs b/views/updown/request.ejs index d36d0b9..58093fa 100644 --- a/views/updown/request.ejs +++ b/views/updown/request.ejs @@ -10,33 +10,32 @@ <% if (requests.length > 0) { %>
<% for (let request of requests) { %> - <% if (request.isAccept == true) { %> -
-
-

- <%= request.ownerId %> Accepted your request to access. -

-
- -
-
- - -
- -
- -
- <% } else { %> + <% if (request.isAccept != 0) { %> + <% if (request.isAccept == 2) { %>

- <%= request.ownerId %> denied your request to access. + <%= request.ownerId %> Accepted your request to access.

+ +
+ Show Content + +
+
+ <% } else { %> +
+
+

+ <%= request.ownerId %> denied your request to access. +

+
+
+ <% } %> <% } %> - <% } %> + <% } %>
<% } else { %>

Still No Requests!

diff --git a/views/updown/showDecryptedContent.ejs b/views/updown/showDecryptedContent.ejs index 85fd0b2..8938699 100644 --- a/views/updown/showDecryptedContent.ejs +++ b/views/updown/showDecryptedContent.ejs @@ -6,7 +6,12 @@ <%- include('../includes/navigation.ejs') %>
-

<%= fileContent %>

+ <% if (verification == true) { %> +

<%= documents %>

+ <% } else { %> +

ALART!!!

+

File is not received from the actual owner. File content can be compromised

+ <% } %>
<%- include('../includes/end.ejs') %> \ No newline at end of file