Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
exports.handler = (event, context, callback) => {
console.log(`Event: ${JSON.stringify(event, null, 2)}`);
if (!BoxSDK.validateWebhookMessage(event.body, event.headers)) {
const response = { statusCode: 403, body: 'Message authenticity not verified' };
console.log(`Response: ${JSON.stringify(response, null, 2)}`);
callback(null, response);
return;
}
if (!event.body) {
const response = { statusCode: 403, body: 'Missing event body' };
console.log(`Response: ${JSON.stringify(response, null, 2)}`);
callback(null, response);
return;
}
// Parse the message body from the Lambda proxy
const body = JSON.parse(event.body);
console.log(`Event body: ${JSON.stringify(body, null, 2)}`);
exports.handler = function(event, context, callback) {
console.log(`Event: ${JSON.stringify(event, null, 2)}`);
//Check the event is signed and signature is valid
if (!BoxSDK.validateWebhookMessage(event.body, event.headers, primarySignatureKey, secondarySignatureKey)) {
const response = {
statusCode: 403,
body: 'Message authenticity not verified'
};
console.log(`Response: ${JSON.stringify(response, null, 2)}`);
callback(null, response);
return;
}
//Check if the event has body
if (!event.body) {
const response = {
statusCode: 400,
body: 'Missing event body'
};