Last active
May 20, 2024 17:22
-
-
Save HubSpotHanevold/9e55b079fbf0af82e4887bc9a1085962 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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