Skip to content

Instantly share code, notes, and snippets.

@HubSpotHanevold
Last active May 20, 2024 17:22
Show Gist options
  • Save HubSpotHanevold/9e55b079fbf0af82e4887bc9a1085962 to your computer and use it in GitHub Desktop.
Save HubSpotHanevold/9e55b079fbf0af82e4887bc9a1085962 to your computer and use it in GitHub Desktop.
const axios = require('axios');
const crypto = require('crypto');
exports.main = async ({ body }, sendResponse) => {
if(body.event == 'endpoint.url_validation'){
try {
sendResponse({ body: {encryptedToken: crypto.createHmac('sha256', 'TOKEN ADDED HERE').update(body.payload.plainToken).digest('hex'), plainToken: body.payload.plainToken}, statusCode: 200 });
} catch(e){
sendResponse({ body: e, statusCode: 200 });
}
} else {
axios.post('WORKFLOW WEBHOOK ENDPOINT', body);
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment