This package has been deprecated

Author message:

This package will no longer receive support. Please use @hygraph/utils instead.

@graphcms/utils
TypeScript icon, indicating that this package has built-in type declarations

1.2.0 • Public • Published

Hygraph 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 Hygraph 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

Readme

Keywords

none

Package Sidebar

Install

npm i @graphcms/utils

Weekly Downloads

473

Version

1.2.0

License

MIT

Unpacked Size

10.3 kB

Total Files

8

Last publish

Collaborators

  • rajatsharma
  • mahaveergcms
  • harish027
  • graphcms-owner
  • somus
  • jpedroschmitz