{
  "description": "v0.1 DRAFT. Webhook signatures produced by Borrou's own signing code. Test values only: the secret signs nothing real. Each case gives the Borrou-Signature header (null: absent), the raw body as received (UTF-8), the receiver's clock in unix seconds, and the expected outcome with a 300-second tolerance: ok, missing, malformed, stale or mismatch.",
  "secret": "whsec_5d8a04f02615a141dbca8d9fbf3bcd647103a7dbff7a976e7d9857131d472973",
  "tolerance_seconds": 300,
  "cases": [
    {
      "name": "a delivery as Borrou signs it",
      "header": "t=1790000000,v1=164f53a860451de0ae382c591fdfc39ecdc53464f62f515f9dae02c4981afee2",
      "body": "{\"id\":\"0199a6b2-6f00-7c4e-8a3b-5d2f1e0c9b11\",\"type\":\"loan.activated\",\"api_version\":\"v1\",\"occurred_at\":\"2026-09-21T14:13:20.000Z\",\"created_at\":\"2026-09-21T14:13:20.000Z\",\"data\":{\"loan\":{\"id\":\"0199a6b0-1a2b-7c3d-9e4f-5a6b7c8d9e0f\",\"reference\":\"LN-0042\"},\"from_status\":\"COLLATERAL_DEPOSITED\",\"status\":\"ACTIVE\"}}",
      "now": 1790000010,
      "expected": "ok"
    },
    {
      "name": "300 seconds after it was signed: still inside the tolerance",
      "header": "t=1790000000,v1=164f53a860451de0ae382c591fdfc39ecdc53464f62f515f9dae02c4981afee2",
      "body": "{\"id\":\"0199a6b2-6f00-7c4e-8a3b-5d2f1e0c9b11\",\"type\":\"loan.activated\",\"api_version\":\"v1\",\"occurred_at\":\"2026-09-21T14:13:20.000Z\",\"created_at\":\"2026-09-21T14:13:20.000Z\",\"data\":{\"loan\":{\"id\":\"0199a6b0-1a2b-7c3d-9e4f-5a6b7c8d9e0f\",\"reference\":\"LN-0042\"},\"from_status\":\"COLLATERAL_DEPOSITED\",\"status\":\"ACTIVE\"}}",
      "now": 1790000300,
      "expected": "ok"
    },
    {
      "name": "301 seconds after: too old",
      "header": "t=1790000000,v1=164f53a860451de0ae382c591fdfc39ecdc53464f62f515f9dae02c4981afee2",
      "body": "{\"id\":\"0199a6b2-6f00-7c4e-8a3b-5d2f1e0c9b11\",\"type\":\"loan.activated\",\"api_version\":\"v1\",\"occurred_at\":\"2026-09-21T14:13:20.000Z\",\"created_at\":\"2026-09-21T14:13:20.000Z\",\"data\":{\"loan\":{\"id\":\"0199a6b0-1a2b-7c3d-9e4f-5a6b7c8d9e0f\",\"reference\":\"LN-0042\"},\"from_status\":\"COLLATERAL_DEPOSITED\",\"status\":\"ACTIVE\"}}",
      "now": 1790000301,
      "expected": "stale"
    },
    {
      "name": "301 seconds before: from the future",
      "header": "t=1790000000,v1=164f53a860451de0ae382c591fdfc39ecdc53464f62f515f9dae02c4981afee2",
      "body": "{\"id\":\"0199a6b2-6f00-7c4e-8a3b-5d2f1e0c9b11\",\"type\":\"loan.activated\",\"api_version\":\"v1\",\"occurred_at\":\"2026-09-21T14:13:20.000Z\",\"created_at\":\"2026-09-21T14:13:20.000Z\",\"data\":{\"loan\":{\"id\":\"0199a6b0-1a2b-7c3d-9e4f-5a6b7c8d9e0f\",\"reference\":\"LN-0042\"},\"from_status\":\"COLLATERAL_DEPOSITED\",\"status\":\"ACTIVE\"}}",
      "now": 1789999699,
      "expected": "stale"
    },
    {
      "name": "the body changed by one character",
      "header": "t=1790000000,v1=164f53a860451de0ae382c591fdfc39ecdc53464f62f515f9dae02c4981afee2",
      "body": "{\"id\":\"0199a6b2-6f00-7c4e-8a3b-5d2f1e0c9b11\",\"type\":\"loan.activated\",\"api_version\":\"v1\",\"occurred_at\":\"2026-09-21T14:13:20.000Z\",\"created_at\":\"2026-09-21T14:13:20.000Z\",\"data\":{\"loan\":{\"id\":\"0199a6b0-1a2b-7c3d-9e4f-5a6b7c8d9e0f\",\"reference\":\"LN-0043\"},\"from_status\":\"COLLATERAL_DEPOSITED\",\"status\":\"ACTIVE\"}}",
      "now": 1790000000,
      "expected": "mismatch"
    },
    {
      "name": "the body re-serialised with a trailing space",
      "header": "t=1790000000,v1=164f53a860451de0ae382c591fdfc39ecdc53464f62f515f9dae02c4981afee2",
      "body": "{\"id\":\"0199a6b2-6f00-7c4e-8a3b-5d2f1e0c9b11\",\"type\":\"loan.activated\",\"api_version\":\"v1\",\"occurred_at\":\"2026-09-21T14:13:20.000Z\",\"created_at\":\"2026-09-21T14:13:20.000Z\",\"data\":{\"loan\":{\"id\":\"0199a6b0-1a2b-7c3d-9e4f-5a6b7c8d9e0f\",\"reference\":\"LN-0042\"},\"from_status\":\"COLLATERAL_DEPOSITED\",\"status\":\"ACTIVE\"}} ",
      "now": 1790000000,
      "expected": "mismatch"
    },
    {
      "name": "signed with another subscription's secret",
      "header": "t=1790000000,v1=2a97b35d936ce90ae6cc09ac99accaa8a2e721063e28bdc3e60b8e95c1282fea",
      "body": "{\"id\":\"0199a6b2-6f00-7c4e-8a3b-5d2f1e0c9b11\",\"type\":\"loan.activated\",\"api_version\":\"v1\",\"occurred_at\":\"2026-09-21T14:13:20.000Z\",\"created_at\":\"2026-09-21T14:13:20.000Z\",\"data\":{\"loan\":{\"id\":\"0199a6b0-1a2b-7c3d-9e4f-5a6b7c8d9e0f\",\"reference\":\"LN-0042\"},\"from_status\":\"COLLATERAL_DEPOSITED\",\"status\":\"ACTIVE\"}}",
      "now": 1790000000,
      "expected": "mismatch"
    },
    {
      "name": "the timestamp moved forward: it is inside the MAC",
      "header": "t=1790000600,v1=164f53a860451de0ae382c591fdfc39ecdc53464f62f515f9dae02c4981afee2",
      "body": "{\"id\":\"0199a6b2-6f00-7c4e-8a3b-5d2f1e0c9b11\",\"type\":\"loan.activated\",\"api_version\":\"v1\",\"occurred_at\":\"2026-09-21T14:13:20.000Z\",\"created_at\":\"2026-09-21T14:13:20.000Z\",\"data\":{\"loan\":{\"id\":\"0199a6b0-1a2b-7c3d-9e4f-5a6b7c8d9e0f\",\"reference\":\"LN-0042\"},\"from_status\":\"COLLATERAL_DEPOSITED\",\"status\":\"ACTIVE\"}}",
      "now": 1790000600,
      "expected": "mismatch"
    },
    {
      "name": "two v1 entries, one matches (as while a signing secret rotates)",
      "header": "t=1790000000,v1=2a97b35d936ce90ae6cc09ac99accaa8a2e721063e28bdc3e60b8e95c1282fea,v1=164f53a860451de0ae382c591fdfc39ecdc53464f62f515f9dae02c4981afee2",
      "body": "{\"id\":\"0199a6b2-6f00-7c4e-8a3b-5d2f1e0c9b11\",\"type\":\"loan.activated\",\"api_version\":\"v1\",\"occurred_at\":\"2026-09-21T14:13:20.000Z\",\"created_at\":\"2026-09-21T14:13:20.000Z\",\"data\":{\"loan\":{\"id\":\"0199a6b0-1a2b-7c3d-9e4f-5a6b7c8d9e0f\",\"reference\":\"LN-0042\"},\"from_status\":\"COLLATERAL_DEPOSITED\",\"status\":\"ACTIVE\"}}",
      "now": 1790000000,
      "expected": "ok"
    },
    {
      "name": "a non-ASCII body, hashed as UTF-8 bytes",
      "header": "t=1790000000,v1=78561c024d44c4a7956ea9a9a29c6c22b43f71baae3dc5135d50906647e191dd",
      "body": "{\"id\":\"0199a6b2-6f00-7c4e-8a3b-5d2f1e0c9b12\",\"type\":\"loan.closed\",\"api_version\":\"v1\",\"note\":\"Préstamo cerrado ✓\",\"data\":{}}",
      "now": 1790000000,
      "expected": "ok"
    },
    {
      "name": "spaces after the commas",
      "header": "t=1790000000, v1=164f53a860451de0ae382c591fdfc39ecdc53464f62f515f9dae02c4981afee2",
      "body": "{\"id\":\"0199a6b2-6f00-7c4e-8a3b-5d2f1e0c9b11\",\"type\":\"loan.activated\",\"api_version\":\"v1\",\"occurred_at\":\"2026-09-21T14:13:20.000Z\",\"created_at\":\"2026-09-21T14:13:20.000Z\",\"data\":{\"loan\":{\"id\":\"0199a6b0-1a2b-7c3d-9e4f-5a6b7c8d9e0f\",\"reference\":\"LN-0042\"},\"from_status\":\"COLLATERAL_DEPOSITED\",\"status\":\"ACTIVE\"}}",
      "now": 1790000000,
      "expected": "ok"
    },
    {
      "name": "no header",
      "header": null,
      "body": "{\"id\":\"0199a6b2-6f00-7c4e-8a3b-5d2f1e0c9b11\",\"type\":\"loan.activated\",\"api_version\":\"v1\",\"occurred_at\":\"2026-09-21T14:13:20.000Z\",\"created_at\":\"2026-09-21T14:13:20.000Z\",\"data\":{\"loan\":{\"id\":\"0199a6b0-1a2b-7c3d-9e4f-5a6b7c8d9e0f\",\"reference\":\"LN-0042\"},\"from_status\":\"COLLATERAL_DEPOSITED\",\"status\":\"ACTIVE\"}}",
      "now": 1790000000,
      "expected": "missing"
    },
    {
      "name": "an empty header",
      "header": "",
      "body": "{\"id\":\"0199a6b2-6f00-7c4e-8a3b-5d2f1e0c9b11\",\"type\":\"loan.activated\",\"api_version\":\"v1\",\"occurred_at\":\"2026-09-21T14:13:20.000Z\",\"created_at\":\"2026-09-21T14:13:20.000Z\",\"data\":{\"loan\":{\"id\":\"0199a6b0-1a2b-7c3d-9e4f-5a6b7c8d9e0f\",\"reference\":\"LN-0042\"},\"from_status\":\"COLLATERAL_DEPOSITED\",\"status\":\"ACTIVE\"}}",
      "now": 1790000000,
      "expected": "missing"
    },
    {
      "name": "no timestamp",
      "header": "v1=164f53a860451de0ae382c591fdfc39ecdc53464f62f515f9dae02c4981afee2",
      "body": "{\"id\":\"0199a6b2-6f00-7c4e-8a3b-5d2f1e0c9b11\",\"type\":\"loan.activated\",\"api_version\":\"v1\",\"occurred_at\":\"2026-09-21T14:13:20.000Z\",\"created_at\":\"2026-09-21T14:13:20.000Z\",\"data\":{\"loan\":{\"id\":\"0199a6b0-1a2b-7c3d-9e4f-5a6b7c8d9e0f\",\"reference\":\"LN-0042\"},\"from_status\":\"COLLATERAL_DEPOSITED\",\"status\":\"ACTIVE\"}}",
      "now": 1790000000,
      "expected": "malformed"
    },
    {
      "name": "no signature",
      "header": "t=1790000000",
      "body": "{\"id\":\"0199a6b2-6f00-7c4e-8a3b-5d2f1e0c9b11\",\"type\":\"loan.activated\",\"api_version\":\"v1\",\"occurred_at\":\"2026-09-21T14:13:20.000Z\",\"created_at\":\"2026-09-21T14:13:20.000Z\",\"data\":{\"loan\":{\"id\":\"0199a6b0-1a2b-7c3d-9e4f-5a6b7c8d9e0f\",\"reference\":\"LN-0042\"},\"from_status\":\"COLLATERAL_DEPOSITED\",\"status\":\"ACTIVE\"}}",
      "now": 1790000000,
      "expected": "malformed"
    },
    {
      "name": "a signature that is not 64 hex digits",
      "header": "t=1790000000,v1=zz",
      "body": "{\"id\":\"0199a6b2-6f00-7c4e-8a3b-5d2f1e0c9b11\",\"type\":\"loan.activated\",\"api_version\":\"v1\",\"occurred_at\":\"2026-09-21T14:13:20.000Z\",\"created_at\":\"2026-09-21T14:13:20.000Z\",\"data\":{\"loan\":{\"id\":\"0199a6b0-1a2b-7c3d-9e4f-5a6b7c8d9e0f\",\"reference\":\"LN-0042\"},\"from_status\":\"COLLATERAL_DEPOSITED\",\"status\":\"ACTIVE\"}}",
      "now": 1790000000,
      "expected": "malformed"
    },
    {
      "name": "not a signature header at all",
      "header": "garbage",
      "body": "{\"id\":\"0199a6b2-6f00-7c4e-8a3b-5d2f1e0c9b11\",\"type\":\"loan.activated\",\"api_version\":\"v1\",\"occurred_at\":\"2026-09-21T14:13:20.000Z\",\"created_at\":\"2026-09-21T14:13:20.000Z\",\"data\":{\"loan\":{\"id\":\"0199a6b0-1a2b-7c3d-9e4f-5a6b7c8d9e0f\",\"reference\":\"LN-0042\"},\"from_status\":\"COLLATERAL_DEPOSITED\",\"status\":\"ACTIVE\"}}",
      "now": 1790000000,
      "expected": "malformed"
    }
  ]
}
