Download the PHP package olmed/databus-webhook-helpers without Composer
On this page you can find all versions of the php package olmed/databus-webhook-helpers. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package databus-webhook-helpers
Olmed DataBus Webhook Helpers
A PHP library for secure webhook payload encryption, decryption and verification using AES-256-CBC encryption and HMAC-SHA256 signatures.
Requirements
- PHP >= 7.0
- OpenSSL extension
- JSON extension
Installation
Install via Composer:
Usage
Basic Example
Complete Webhook Endpoint Example
How It Works
Encryption Format
The payload is encrypted using AES-256-CBC with the following structure:
- A random 16-byte Initialization Vector (IV) is generated
- The data is encrypted using AES-256-CBC
- The IV is prepended to the encrypted data
- The combined data (IV + encrypted) is base64-encoded
Verification Process
- The base64 payload is decoded
- The IV (first 16 bytes) is extracted
- The remaining data is decrypted using AES-256-CBC
- A JSON structure is reconstructed:
{"guid":"...","webhookType":"...","webhookData":{...}} - An HMAC-SHA256 signature is computed for this JSON
- The computed signature is compared with the provided signature
Security Features
- AES-256-CBC encryption - Industry-standard encryption
- HMAC-SHA256 signatures - Prevents tampering and ensures authenticity
- Timing-attack safe comparison - Uses
hash_equals()for signature verification - 32-byte keys required - Enforces strong key lengths
Key Generation
To generate secure 32-byte keys, you can use:
Or use OpenSSL from command line:
API Reference
SecureWebhookHelper
Constructor
Parameters:
$encryptionKey- 32-byte encryption key$hmacKey- 32-byte HMAC key
Throws:
InvalidArgumentException- If keys are not exactly 32 bytes
tryDecryptAndVerifyWithIvPrefix
Parameters:
$guid- Webhook GUID$webhookType- Type of webhook$base64PayloadWithIv- Base64-encoded encrypted payload with IV prefix$signature- HMAC-SHA256 signature (hex string)$decryptedJson- Output parameter containing decrypted JSON on success
Returns:
trueif decryption and verification succeededfalseif decryption failed or signature is invalid
Local Development (Laravel)
If you want to develop and test this package locally in your Laravel project before publishing to Packagist, you can load it directly via autoload.
-
Edit your Laravel project's
composer.jsonand add to theautoload-devsection: -
Reload the autoloader:
- Now you can use the class in your Laravel application:
Any changes you make to the source files in /absolute/path/to/PHP_OlmedDataBus.Webhooks/src/ will be immediately available in your Laravel project.
Note: Remember to remove this entry from autoload-dev and install the package normally via Composer once it's published to Packagist.
All versions of databus-webhook-helpers with dependencies
ext-openssl Version *
ext-json Version *