Skip to content

Instantly share code, notes, and snippets.

@ctrl-freak
Last active April 8, 2024 07:41
Show Gist options
  • Save ctrl-freak/42dc5f5402e8107045c382688550a4c1 to your computer and use it in GitHub Desktop.
Save ctrl-freak/42dc5f5402e8107045c382688550a4c1 to your computer and use it in GitHub Desktop.
Gatekeeper Webhook Challenge Response in NodeJS (on PipeDream)
// https://www.gatekeeperhq.com/
// The Vendor & Contract Lifecycle Management (VCLM) Platform
// Webhook 'documentation' on Settings page is for Ruby, incomplete and does not include that the crc_response is to be base64 encoded.
// Video on Knowledgebase contains Python script which shows this is the case:
// https://knowledge.gatekeeperhq.com/en/docs/webhooks
import * as crypto from "crypto";
export default defineComponent({
async run({ steps, $ }) {
let response;
if (steps.trigger.event.method == 'GET'
&& steps.trigger.event.query.crc_token) {
let crc_token = steps.trigger.event.query.crc_token
let secure_token = 'b36f3eef78bcb91e28342a8e875dbf4d1bdbea1462167934'; // Webhook Secure Token
let algorithm = 'sha256';
let hmac = crypto.createHmac(algorithm, secure_token);
hmac.write(crc_token);
hmac.end();
let crc_response = Buffer.from(hmac.read('binary')).toString('base64');
response = {
status: 200,
headers: {},
body: JSON.stringify({crc_response: crc_response }),
}
} else {
response = {
status: 200,
headers: {},
body: '',
}
}
await $.respond(response);
},
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment