{"id":20216761,"url":"https://github.com/hygraph/hygraph-utils","last_synced_at":"2025-04-10T15:13:40.183Z","repository":{"id":40345508,"uuid":"405011294","full_name":"hygraph/hygraph-utils","owner":"hygraph","description":null,"archived":false,"fork":false,"pushed_at":"2023-01-30T17:51:27.000Z","size":102,"stargazers_count":1,"open_issues_count":2,"forks_count":4,"subscribers_count":21,"default_branch":"main","last_synced_at":"2025-04-03T01:58:13.064Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hygraph.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-09-10T08:33:14.000Z","updated_at":"2023-01-30T17:13:37.000Z","dependencies_parsed_at":"2024-11-14T06:39:50.645Z","dependency_job_id":null,"html_url":"https://github.com/hygraph/hygraph-utils","commit_stats":null,"previous_names":["hygraph/graphcms-utils"],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hygraph%2Fhygraph-utils","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hygraph%2Fhygraph-utils/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hygraph%2Fhygraph-utils/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hygraph%2Fhygraph-utils/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hygraph","download_url":"https://codeload.github.com/hygraph/hygraph-utils/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248243213,"owners_count":21071054,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-14T06:29:39.051Z","updated_at":"2025-04-10T15:13:40.162Z","avatar_url":"https://github.com/hygraph.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Hygraph Utils\n\n## Install\n\n```bash\nnpm i @hygraph/utils\n```\n\n## Usage\n\n### `verifyWebhookSignature`\n\nYou'll need the request body and headers to pass to `verifyWebhookSignature`.\n\nIf `isValid` is truthy then you can safely execute your webhook handler code knowing the request is genuine, otherwise you should abort any further action.\n\n```js\nconst { verifyWebhookSignature } = require(\"@hygraph/utils\");\n\nconst secret = \"rCNwyiloY3oJYYkxgpBXaleIiUv5MYlx\";\n\nconst body = {}; // Typically req.body\nconst signature = \"...\"; // Typically req.headers['gcms-signature']\n\nconst isValid = verifyWebhookSignature({ body, signature, secret });\n```\n\n`verifyWebhookSignature` also accepts a `rawPayload` in the case that the body\nhas not yet been parsed.\n\n```js\nconst { verifyWebhookSignature } = require(\"@hygraph/utils\");\n\nconst secret = \"rCNwyiloY3oJYYkxgpBXaleIiUv5MYlx\";\n\nconst rawPayload = '{\"hello\":\"world\"}';\nconst signature = \"...\"; // Typically req.headers['gcms-signature']\n\nconst isValid = verifyWebhookSignature({ rawPayload, signature, secret });\n```\n\n[Learn more about Webhooks](https://hygraph.com/docs/api-reference/basics/webhooks).\n\n### `generateWebhookSignature`\n\nThis is useful for testing signed webhooks. You can generate a Hygraph webhook signature, and then use it to test your webhook.\n\n```js\nconst { generateWebhookSignature } = require(\"@hygraph/utils\");\n\nconst secret = \"rCNwyiloY3oJYYkxgpBXaleIiUv5MYlx\";\n\nconst body = {\n  hello: \"world\",\n};\n\nconst signature = generateWebhookSignature({ body, secret });\n```\n\n[Learn more about Webhooks](https://hygraph.com/docs/api-reference/basics/webhooks).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhygraph%2Fhygraph-utils","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhygraph%2Fhygraph-utils","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhygraph%2Fhygraph-utils/lists"}