agentleFS
roedyrustamroedyrustam/doku-gemini-mcp/skills/webhook-receiver/SKILL.md

webhook-receiver

Skill2 starsChanged 9 days agoMITView on GitHub

Scaffold HTTP webhook notification listener endpoint with cryptographic HMAC-SHA256 & SNAP signature verification, replay attack prevention, and atomic database updates / Buat handler webhook notifikasi dengan verifikator signature HMAC-SHA256 & SNAP dan anti-replay guard.

  • Reads credentials

2 other projects use a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

1 rule. About 0 are common, 0 are distinctive, and 1 is very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈0

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 1

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    MANDATORY: When testing in Sandbox mode and needing to access the Payment Simulator, the AI Agent MUST use this exact URL: …

    line 109

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Webhook Receiver / Handler Webhook Notifikasi DOKU

English | Bahasa Indonesia


<a name="english"></a>

English

Description

Scaffolds a production-ready HTTP webhook handler endpoint for receiving payment notifications from DOKU. Includes mandatory HMAC-SHA256 & SNAP X-SIGNATURE verification, rejection of unverified requests (401 Unauthorized), idempotency checks against duplicate notifications, and atomic database transaction updates.

Trigger Conditions

Activate this skill when the user says:

  • "add DOKU webhook"
  • "handle DOKU callbacks"
  • "create DOKU notification listener"

Step-by-Step Implementation Template (TypeScript / Express)

import crypto from 'crypto';
import { Request, Response } from 'express';

/**
 * Validates Jokul API v2 Webhook Signature (Client-Id, Request-Id, Request-Timestamp, Request-Target, Digest, Signature)
 */
export function verifyDokuNotificationSignature(req: Request, secretKey: string): boolean {
  const clientId = req.headers['client-id'] as string;
  const requestId = req.headers['request-id'] as string;
  const timestamp = req.headers['request-timestamp'] as string;
  const targetPath = req.originalUrl || req.url;
  const receivedSignature = req.headers['signature'] as string;

  if (!clientId || !requestId || !timestamp || !receivedSignature) {
    return false;
  }

  const rawBody = typeof req.body === 'string' ? req.body : JSON.stringify(req.body);
  const digest = crypto.createHash('sha256').update(rawBody, 'utf8').digest('base64');

  const component = `Client-Id:${clientId}\nRequest-Id:${requestId}\nRequest-Timestamp:${timestamp}\nRequest-Target:${targetPath}\nDigest:${digest}`;
  
  const calculatedHmac = crypto
    .createHmac('sha256', secretKey)
    .update(component)
    .digest('base64');

  const expectedSignature = `HMACSHA256=${calculatedHmac}`;

  return crypto.timingSafeEqual(
    Buffer.from(receivedSignature),
    Buffer.from(expectedSignature)
  );
}

export async function handleDokuWebhook(req: Request, res: Response) {
  const secretKey = process.env.DOKU_SECRET_KEY || '';

  // 1. Mandatory Cryptographic Signature Verification
  if (!verifyDokuNotificationSignature(req, secretKey)) {
    return res.status(401).json({ status: 'UNAUTHORIZED', message: 'Invalid notification signature' });
  }

  const { order, transaction } = req.body;
  const invoiceNumber = order?.invoice_number;
  const status = transaction?.status;

  // 2. Idempotency Check & Atomic DB Update
  const isProcessed = await checkExistingTransactionStatus(invoiceNumber);
  if (isProcessed) {
    return res.status(200).json({ status: 'SUCCESS', message: 'Already processed' });
  }

  await updateOrderStatusAtomic(invoiceNumber, status);

  return res.status(200).json({ status: 'SUCCESS' });
}

<a name="bahasa-indonesia"></a>

Bahasa Indonesia

Deskripsi

Membuat endpoint webhook HTTP siap produksi untuk menerima notifikasi status pembayaran dari DOKU. Mencakup verifikasi signature HMAC-SHA256 & SNAP wajib, penolakan permintaan yang tidak terverifikasi (401 Unauthorized), pemeriksaan idempotensi terhadap notifikasi duplikat, serta pembaruan transaksi database secara atomik.

Kondisi Pemicu

Aktifkan skill ini ketika pengguna mengatakan:

  • "add DOKU webhook"
  • "handle DOKU callbacks"
  • "buat listener notifikasi DOKU"

🚨 SNAP Integration Mandate (CRITICAL)

MANDATORY: The AI Agent MUST automatically apply the SNAP API v1.0 standard (Standard Nasional Open API Pembayaran) for all DOKU integrations, instead of the legacy Jokul API v2, unless the user explicitly requests otherwise. All generated signatures, headers, and endpoints MUST follow the SNAP BI standard.

🧪 DOKU Sandbox Simulator

MANDATORY: When testing in Sandbox mode and needing to access the Payment Simulator, the AI Agent MUST use this exact URL: https://sandbox.doku.com/gtw-config-v2/simulator.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.