🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

@zenginehq/backend-webhooks

Package Overview
Dependencies
Maintainers
3
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@zenginehq/backend-webhooks

Helper library for working with Webhooks in Zengine backend plugins.

1.1.0
Source
npm
Version published
Weekly downloads
4
33.33%
Maintainers
3
Weekly downloads
 
Created
Source

Backend Webhooks

Helper module for working with Webhooks in Zengine backend Plugins.

Installation

npm i @zenginehq/backend-webhooks --save

Usage

var $webhook = require('@zenginehq/backend-webhooks');
var $firebase = require('@zenginehq/backend-firebase');
var $api = require('@zenginehq/backend-http');

// Load settings from firebase.
$firebase.load(workspaceId).then(function (settings) {
  if (!$webhook.validateSecret(settings, eventData.request)) {
    return eventData.response.status(403).send('Invalid Webhook Key');
  }

  // Load activity.
  return $api.getActivity(activity.id).then(function (fullActivity) {
    if ($webhook.activityFolders(fullActivity, settings.submittedFolder)) {
      // Do something.
}
  });
});

Methods

validateSecret(settings, request)

Returns whether the webhook id and secret match what's stored in settings.

Out of the box expects the id to be stored in settings.webhookId and the key in settings.webhookKey.

You can customize this by calling $webhook.setIdField('myIdField) and $webhook.setKeyField('myKeyField').

activityFolders(activity, toFolder, [fromFolder])

Returns whether the given activity is a move to the specified folder and optionally filter by whether it came from a certain folder too.

Keywords

zn-plugin

FAQs

Package last updated on 29 Jun 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts