rasuvaeff/yii3-webhooks-db
Composer 安装命令:
composer require rasuvaeff/yii3-webhooks-db
包简介
Database-backed delivery and nonce storage for rasuvaeff/yii3-webhooks
README 文档
README
Database-backed delivery and nonce storage for rasuvaeff/yii3-webhooks.
It provides production storage for delivery attempts and atomic replay protection.
Using an AI coding assistant? llms.txt has a compact API reference you can use.
Requirements
- PHP 8.3+
rasuvaeff/yii3-webhooks^1.0yiisoft/db^2.0yiisoft/db-migration^2.0psr/clock^1.0
Installation
composer require rasuvaeff/yii3-webhooks-db
Usage
Run M260612000000CreateWebhookTables to create webhook_deliveries and webhook_nonces.
use Psr\Clock\ClockInterface; use Rasuvaeff\Yii3Webhooks\WebhookDelivery; use Rasuvaeff\Yii3WebhooksDb\DbNonceStorage; use Rasuvaeff\Yii3WebhooksDb\DbWebhookDeliveryStorage; $deliveries = new DbWebhookDeliveryStorage(db: $db); $nonces = new DbNonceStorage(db: $db, clock: $clock); $delivery = WebhookDelivery::create(event: $event, endpoint: $endpoint); $deliveries->save(delivery: $delivery); $accepted = $nonces->add(nonce: $signature->getValue());
With yiisoft/config, this package binds only WebhookDeliveryStorage and NonceStorage.
API reference
DbWebhookDeliveryStorage
| Method | Description |
|---|---|
save(delivery) |
Inserts or updates a delivery row |
findPending(limit) |
Returns pending deliveries ordered by creation time |
markDelivered(delivery) |
Stores the delivery as delivered |
markFailed(delivery) |
Stores the delivery as failed |
getById(id) |
Loads a delivery by ID |
DbNonceStorage
| Method | Description |
|---|---|
has(nonce) |
Checks whether a nonce exists |
add(nonce) |
Atomic insert; returns false on duplicate |
deleteOlderThan(threshold) |
Deletes old nonces for retention cleanup |
Security
DbNonceStorage::add()relies on the primary key and catches duplicate-key errors.DbWebhookDeliveryStoragepersists onlyWebhookDeliverydata, never endpoint secrets.- Keep nonce rows at least as long as your webhook timestamp tolerance window.
Examples
See examples/ for a runnable SQLite example.
Development
make install
make build
make cs-fix
make test
make test-coverage
make mutation
make release-check
License
BSD-3-Clause. See LICENSE.md.
统计信息
- 总下载量: 0
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 3
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: BSD-3-Clause
- 更新时间: 2026-06-19