windsurf-webhooks-events
Windsurfのウェブフック署名検証とイベントハンドリングを実装できます。ウェブフックエンドポイントの設定、署名検証の実装、またはWindsurfのイベント通知を安全に処理する際に使用します。「windsurf webhook」「windsurf events」「windsurf webhook signature」「handle windsurf events」「windsurf notifications」といったフレーズで起動できます。
description の原文を見る
Implement Windsurf webhook signature validation and event handling. Use when setting up webhook endpoints, implementing signature verification, or handling Windsurf event notifications securely. Trigger with phrases like "windsurf webhook", "windsurf events", "windsurf webhook signature", "handle windsurf events", "windsurf notifications".
SKILL.md 本文
Windsurf ウェブフック & イベント
概要
署名検証とリプレイ攻撃対策を備えた Windsurf ウェブフックを安全に処理します。
前提条件
- Windsurf ウェブフックシークレットの設定
- インターネットからアクセス可能な HTTPS エンドポイント
- 暗号化署名の理解
- Redis またはデータベース(任意・べき等性のため)
ウェブフックエンドポイント設定
Express.js
import express from 'express';
import crypto from 'crypto';
const app = express();
// IMPORTANT: Raw body needed for signature verification
app.post('/webhooks/windsurf',
express.raw({ type: 'application/json' }),
async (req, res) => {
const signature = req.headers['x-windsurf-signature'] as string;
const timestamp = req.headers['x-windsurf-timestamp'] as string;
if (!verifyWindsurfSignature(req.body, signature, timestamp)) {
return res.status(401).json({ error: 'Invalid signature' });
}
const event = JSON.parse(req.body.toString());
await handleWindsurfEvent(event);
res.status(200).json({ received: true });
}
);
署名検証
function verifyWindsurfSignature(
payload: Buffer,
signature: string,
timestamp: string
): boolean {
const secret = process.env.WINDSURF_WEBHOOK_SECRET!;
// Reject old timestamps (replay attack protection)
const timestampAge = Date.now() - parseInt(timestamp) * 1000;
if (timestampAge > 300000) { // 5 minutes
console.error('Webhook timestamp too old');
return false;
}
// Compute expected signature
const signedPayload = `${timestamp}.${payload.toString()}`;
const expectedSignature = crypto
.createHmac('sha256', secret)
.update(signedPayload)
.digest('hex');
// Timing-safe comparison
return crypto.timingSafeEqual(
Buffer.from(signature),
Buffer.from(expectedSignature)
);
}
イベントハンドラーパターン
type WindsurfEventType = 'resource.created' | 'resource.updated' | 'resource.deleted';
interface WindsurfEvent {
id: string;
type: WindsurfEventType;
data: Record<string, any>;
created: string;
}
const eventHandlers: Record<WindsurfEventType, (data: any) => Promise<void>> = {
'resource.created': async (data) => { /* handle */ },
'resource.updated': async (data) => { /* handle */ },
'resource.deleted': async (data) => { /* handle */ }
};
async function handleWindsurfEvent(event: WindsurfEvent): Promise<void> {
const handler = eventHandlers[event.type];
if (!handler) {
console.log(`Unhandled event type: ${event.type}`);
return;
}
try {
await handler(event.data);
console.log(`Processed ${event.type}: ${event.id}`);
} catch (error) {
console.error(`Failed to process ${event.type}: ${event.id}`, error);
throw error; // Rethrow to trigger retry
}
}
べき等性処理
import { Redis } from 'ioredis';
const redis = new Redis(process.env.REDIS_URL);
async function isEventProcessed(eventId: string): Promise<boolean> {
const key = `windsurf:event:${eventId}`;
const exists = await redis.exists(key);
return exists === 1;
}
async function markEventProcessed(eventId: string): Promise<void> {
const key = `windsurf:event:${eventId}`;
await redis.set(key, '1', 'EX', 86400 * 7); // 7 days TTL
}
ウェブフックテスト
# Windsurf CLI を使用してテストイベントを送信
windsurf webhooks trigger resource.created --url http://localhost:3000/webhooks/windsurf
# またはデバッグ用に webhook.site を使用
curl -X POST https://webhook.site/your-uuid \
-H "Content-Type: application/json" \
-d '{"type": "resource.created", "data": {}}'
実装手順
ステップ 1: ウェブフックエンドポイント登録
Windsurf ダッシュボードでウェブフック URL を設定します。
ステップ 2: 署名検証実装
署名検証コードを使用して受信ウェブフックを検証します。
ステップ 3: イベント処理
アプリケーションが必要とする各イベントタイプのハンドラーを実装します。
ステップ 4: べき等性追加
イベント ID トラッキングで重複処理を防止します。
出力
- セキュアなウェブフックエンドポイント
- 署名検証有効
- イベントハンドラー実装
- リプレイ攻撃対策有効
エラー処理
| 問題 | 原因 | 解決方法 |
|---|---|---|
| 無効な署名 | 間違ったシークレット | ウェブフックシークレット確認 |
| タイムスタンプ拒否 | クロックドリフト | サーバー時刻同期確認 |
| 重複イベント | べき等性なし | イベント ID トラッキング実装 |
| ハンドラータイムアウト | 処理遅延 | 非同期キュー使用 |
例
ローカルでのウェブフックテスト
# ngrok を使用してローカルサーバーを公開
ngrok http 3000
# テストウェブフック送信
curl -X POST https://your-ngrok-url/webhooks/windsurf \
-H "Content-Type: application/json" \
-d '{"type": "test", "data": {}}'
リソース
次のステップ
パフォーマンス最適化については windsurf-performance-tuning を参照してください。
ライセンス: MIT(寛容ライセンスのため全文を引用しています) · 原本リポジトリ
詳細情報
- 作者
- Brmbobo
- リポジトリ
- Brmbobo/Web2podcast
- ライセンス
- MIT
- 最終更新
- 2026/1/26
Source: https://github.com/Brmbobo/Web2podcast / ライセンス: MIT
関連スキル
doubt-driven-development
重要な判断はすべて、本番環境への展開前に新しい視点から対抗的レビューを実施します。速度より正確性が重要な場合、不慣れなコードを扱う場合、本番環境・セキュリティに関わるロジック・取り消し不可の操作など影響度が高い場合、または後でバグを修正するよりも今検証する方が効率的な場合に活用してください。
apprun-skills
TypeScriptを使用したAppRunアプリケーションのMVU設計に関する総合的なガイダンスが得られます。コンポーネントパターン、イベントハンドリング、状態管理(非同期ジェネレータを含む)、パラメータと保護機能を備えたルーティング・ナビゲーション、vistestを使用したテストに対応しています。AppRunコンポーネントの設計・レビュー、ルートの配線、状態フローの管理、AppRunテストの作成時に活用してください。
desloppify
コードベースのヘルスチェックと技術負債の追跡ツールです。コード品質、技術負債、デッドコード、大規模ファイル、ゴッドクラス、重複関数、コードスメル、命名規則の問題、インポートサイクル、結合度の問題についてユーザーが質問した場合に使用してください。また、ヘルススコアの確認、次の改善項目の提案、クリーンアップ計画の作成をリクエストされた際にも対応します。29言語に対応しています。
debugging-and-error-recovery
テストが失敗したり、ビルドが壊れたり、動作が期待と異なったり、予期しないエラーが発生したりした場合に、体系的な根本原因デバッグをガイドします。推測ではなく、根本原因を見つけて修正するための体系的なアプローチが必要な場合に使用してください。
test-driven-development
テスト駆動開発により実装を進めます。ロジックの実装、バグの修正、動作の変更など、あらゆる場面で活用できます。コードが正常に動作することを証明する必要がある場合、バグ報告を受けた場合、既存機能を修正する予定がある場合に使用してください。
incremental-implementation
変更を段階的に実施します。複数のファイルに影響する機能や変更を実装する場合に使用してください。大量のコードを一度に書こうとしている場合や、タスクが一度では完結できないほど大きい場合に活用します。