How to use the box-node-sdk.validateWebhookMessage function in box-node-sdk

To help you get started, we’ve selected a few box-node-sdk examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github box / samples / box-node-webhook-to-lambda-sample / index.js View on Github external
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)}`);
github box / samples / box-node-rekognition-lambdas-sample / webhook / index.js View on Github external
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'
        };

box-node-sdk

Official SDK for Box Plaform APIs

Apache-2.0
Latest version published 5 months ago

Package Health Score

78 / 100
Full package analysis