diff --git a/src/server.js b/src/server.js index 58e2091c..c55393d6 100644 --- a/src/server.js +++ b/src/server.js @@ -73,11 +73,11 @@ const server = program => { } const dataHash = hashData(args[0]).slice(-8) - res.set('ETag', dataHash) + res.set('shock-cache-hash', dataHash) - logger.debug('ETag:', req.headers.etag) + logger.debug('shock-cache-hash:', req.headers['shock-cache-hash']) logger.debug('Data Hash:', dataHash) - if (req.headers.etag === dataHash) { + if (req.headers['shock-cache-hash'] === dataHash) { logger.debug('Same Hash Detected!') args[0] = null res.status(304) diff --git a/utils/encryptionStore.js b/utils/encryptionStore.js index a946bc2f..c3df0ec1 100644 --- a/utils/encryptionStore.js +++ b/utils/encryptionStore.js @@ -38,6 +38,7 @@ const Encryption = { }, data ) + return encryptedData.toString('base64') }, /** @@ -62,7 +63,7 @@ const Encryption = { /** * @param {{ deviceId: string , message: any , metadata?: any}} arg0 */ - encryptMessage: ({ deviceId, message, metadata }) => { + encryptMessage: ({ deviceId, message, metadata = {} }) => { const parsedMessage = typeof message === 'object' ? JSON.stringify(message) : message const data = Buffer.from(parsedMessage) @@ -79,7 +80,14 @@ const Encryption = { Buffer.from(cipher.final()) ]) const encryptedData = encryptedBuffer.toString('base64') - return { encryptedData, encryptedKey, iv: iv.toString('hex'), metadata } + const encryptedMessage = { + encryptedData, + encryptedKey, + iv: iv.toString('hex'), + metadata + } + + return encryptedMessage }, /** * @param {{ message: string , key: string , iv: string }} arg0