Introducing Socket Firewall: Free, Proactive Protection for Your Software Supply Chain.Learn More
Socket
Book a DemoInstallSign in
Socket

@graphcms/utils

Package Overview
Dependencies
Maintainers
9
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@graphcms/utils

Collection of useful GraphCMS utilities for building GraphQL powered apps.

npmnpm
Version
1.1.0
Version published
Weekly downloads
307
35.84%
Maintainers
9
Weekly downloads
 
Created
Source

graphcms-utils

Install

npm i @graphcms/utils

Usage

verifyWebhookSignature

const { verifyWebhookSignature } = require("@graphcms/utils");

const secret = "rCNwyiloY3oJYYkxgpBXaleIiUv5MYlx";

const body = {}; // Typically req.body
const signature = "..."; // Typically req.headers['gcms-signature']

const isValid = verifyWebhookSignature({ body, signature, secret });

verifyWebhookSignature also accepts a rawPayload in the case that the body has not yet been parsed.

const { verifyWebhookSignature } = require("@graphcms/utils");

const secret = "rCNwyiloY3oJYYkxgpBXaleIiUv5MYlx";

const rawPayload = '{"hello":"world"}';
const signature = "..."; // Typically req.headers['gcms-signature']

const isValid = verifyWebhookSignature({ rawPayload, signature, secret });

Learn more about webhooks

generateWebhookSignature

This is useful for testing signed webhooks. You can generate a GraphCMS webhook signature, and then use it to test your webhook.

const { generateWebhookSignature } = require("@graphcms/utils");

const secret = "rCNwyiloY3oJYYkxgpBXaleIiUv5MYlx";

const body = {
  hello: "world",
};

const signature = generateWebhookSignature({ body, secret });

Learn more about webhooks

FAQs

Package last updated on 07 Dec 2021

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