{"id":19924373,"url":"https://github.com/kontent-ai/webhook-helper-js","last_synced_at":"2025-08-01T17:34:24.934Z","repository":{"id":42919636,"uuid":"247026983","full_name":"kontent-ai/webhook-helper-js","owner":"kontent-ai","description":"Utility for working with Kontent.ai webhooks","archived":false,"fork":false,"pushed_at":"2025-02-04T11:29:46.000Z","size":597,"stargazers_count":3,"open_issues_count":0,"forks_count":5,"subscribers_count":13,"default_branch":"master","last_synced_at":"2025-07-24T09:13:37.361Z","etag":null,"topics":["kontent-ai","kontent-ai-tool","kontent-javascript","kontent-sdk"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kontent-ai.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2020-03-13T08:53:33.000Z","updated_at":"2025-02-04T11:29:49.000Z","dependencies_parsed_at":"2024-03-25T12:46:54.681Z","dependency_job_id":"6fc38f32-4d27-487f-9b1a-581d91dafb4c","html_url":"https://github.com/kontent-ai/webhook-helper-js","commit_stats":{"total_commits":44,"total_committers":8,"mean_commits":5.5,"dds":"0.34090909090909094","last_synced_commit":"0f548dca853470cbfadfd3f78e1f4292d9fdaff9"},"previous_names":["enngage/kontent-webhook-helper","kentico/kontent-webhook-helper-js"],"tags_count":13,"template":false,"template_full_name":null,"purl":"pkg:github/kontent-ai/webhook-helper-js","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kontent-ai%2Fwebhook-helper-js","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kontent-ai%2Fwebhook-helper-js/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kontent-ai%2Fwebhook-helper-js/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kontent-ai%2Fwebhook-helper-js/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kontent-ai","download_url":"https://codeload.github.com/kontent-ai/webhook-helper-js/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kontent-ai%2Fwebhook-helper-js/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268266887,"owners_count":24222749,"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","status":"online","status_checked_at":"2025-08-01T02:00:08.611Z","response_time":67,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["kontent-ai","kontent-ai-tool","kontent-javascript","kontent-sdk"],"created_at":"2024-11-12T22:17:11.658Z","updated_at":"2025-08-01T17:34:24.894Z","avatar_url":"https://github.com/kontent-ai.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![npm version](https://badge.fury.io/js/%40kontent-ai%2Fwebhook-helper.svg)](https://badge.fury.io/js/%40kontent-ai%2Fwebhook-helper)\n[![Build](https://github.com/kontent-ai/webhook-helper-js/actions/workflows/test.yml/badge.svg)](https://github.com/kontent-ai/webhook-helper-js/actions/workflows/test.yml)\n\n# Kontent.ai Webhook helper\n\nThis package aims to help you with Webhooks received from Kontent.ai projects. Currently, it: \n\n* Helps with [signature verification](https://kontent.ai/learn/docs/webhooks/webhooks/javascript#a-validate-received-notifications) \n* Provides types for webhook response (only for `Typescript`)\n\n## Installation\n\nInstall package:\n\n`npm i --save-dev @kontent-ai/webhook-helper`\n\n### Signature verification\n\nTo verify whether a signature is valid use:\n\n```typescript\nimport { signatureHelper } from '@kontent-ai/webhook-helper';\n\nconst isValid = signatureHelper.isValidSignatureFromString(\n    payload, // the original string payload \n    secret, // secret can be obtained from Webhook definition in Kontent.ai project\n    signature // can be obtained from 'x-kc-signature' header present in webhook request;\n```\n\nKeep in mind that the contents of **payload** have to be exactly the same (including whitespaces) as the original webhook body, otherwise, the validation will fail. \nIf you already parsed the payload into an object, you should be able to transform it back to the way it originaly was with these settings:\n\n```typescript\nconst payload: string = JSON.stringify(jsonPayload,null,2);\n```\n\nThe stringify method can sometimes add Windows line breaks which cause the resulting payload to mismatch the webhook body. In this instance there is an included method you can use:\n\n```typescript\npayload = signatureHelper.replaceLinebreaks(payload);\n```\n\n### Generate hash\n\n```typescript\nimport { signatureHelper } from '@kontent-ai/webhook-helper';\n\nconst hash = signatureHelper.getHashFromString(payload, secret);\n```\n\n### Response model types\n\nIf you are using `Typescript` you may use provided interfaces to access webhook properties in a strongly typed manner. \n\n#### Webhook response\n\n```typescript\nimport { WebhookResponse } from '@kontent-ai/webhook-helper';\n\nconst rawResponse: WebhookResponse = {\n    notifications: [\n        {\n        data: {\n            system: {\n            id: \"aa7f127f-1920-4454-a89a-0609aba8ea6f\",\n            name: \"This changes everything!\",\n            codename: \"this_changes_everything_\",\n            collection: \"marketing\",\n            workflow: \"default\",\n            workflow_step: \"published\",\n            language: \"default\",\n            type: \"product_update\",\n            last_modified: \"2024-03-25T07:55:57.0563735Z\",\n            },\n        },\n        message: {\n            environment_id: \"0f5b6cb2-ea82-014e-ac74-f71e7e8b6aee\",\n            object_type: \"content_item\",\n            action: \"published\",\n            delivery_slot: \"published\",\n        },\n        },\n    ],\n};\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkontent-ai%2Fwebhook-helper-js","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkontent-ai%2Fwebhook-helper-js","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkontent-ai%2Fwebhook-helper-js/lists"}