{
    "algorithm": "v1 = hex(HMAC_SHA256(key = secret as UTF-8 bytes, message = t + \"\\n\" + METHOD + \"\\n\" + path_and_query + \"\\n\" + hex(SHA256(raw body))))",
    "window_seconds": 300,
    "secret": "wf_fs_test_AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8",
    "key_id": "fs_test_01",
    "vectors": [
        {
            "name": "GET catalog search with query string",
            "t": 1762424100,
            "method": "GET",
            "path_and_query": "/waforge/catalog/search?q=black%20shoes&limit=5",
            "body": "",
            "body_sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
            "base_string": "1762424100\nGET\n/waforge/catalog/search?q=black%20shoes&limit=5\ne3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
            "v1": "1b9f80ee3e072d71b0e68494a5fb4a588d4ef6b1969060d87b814a2b5d4f43e2",
            "header": "t=1762424100,kid=fs_test_01,v1=1b9f80ee3e072d71b0e68494a5fb4a588d4ef6b1969060d87b814a2b5d4f43e2"
        },
        {
            "name": "GET product by id (empty body)",
            "t": 1762424100,
            "method": "GET",
            "path_and_query": "/waforge/products/p_1001",
            "body": "",
            "body_sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
            "base_string": "1762424100\nGET\n/waforge/products/p_1001\ne3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
            "v1": "6c63ecb90276a74ce04464bb48a32370d92561062a348c2e114b7601c9164d01",
            "header": "t=1762424100,kid=fs_test_01,v1=6c63ecb90276a74ce04464bb48a32370d92561062a348c2e114b7601c9164d01"
        },
        {
            "name": "POST availability JSON body",
            "t": 1762424160,
            "method": "POST",
            "path_and_query": "/waforge/availability",
            "body": "{\"items\":[{\"product_id\":\"p_1001\",\"variant_id\":\"v_42\",\"quantity\":2}]}",
            "body_sha256": "08ddd28d177661bf93e4dbef212132abebf28d551d6910ce6f10f0009868fd3c",
            "base_string": "1762424160\nPOST\n/waforge/availability\n08ddd28d177661bf93e4dbef212132abebf28d551d6910ce6f10f0009868fd3c",
            "v1": "6938bbcd2127c333d5c8e5febd5184b14cd3c17edec4accbe8760337a84bb44e",
            "header": "t=1762424160,kid=fs_test_01,v1=6938bbcd2127c333d5c8e5febd5184b14cd3c17edec4accbe8760337a84bb44e"
        },
        {
            "name": "POST order lookup with UTF-8 body",
            "t": 1762424200,
            "method": "POST",
            "path_and_query": "/waforge/orders/lookup",
            "body": "{\"order_number\":\"CMD-2041\",\"phone\":\"+213550123456\",\"note\":\"طلب\"}",
            "body_sha256": "83b2c31350cdc7bbde8298e5bedf1f74b2cd07602911a39c8aed682f22f91c6c",
            "base_string": "1762424200\nPOST\n/waforge/orders/lookup\n83b2c31350cdc7bbde8298e5bedf1f74b2cd07602911a39c8aed682f22f91c6c",
            "v1": "20ca176e6622519070ea72e04e78a9eda5901f7d1f231e6f886e5bc01ddb20b7",
            "header": "t=1762424200,kid=fs_test_01,v1=20ca176e6622519070ea72e04e78a9eda5901f7d1f231e6f886e5bc01ddb20b7"
        },
        {
            "name": "PHP drop-in route in the query string",
            "t": 1762424300,
            "method": "GET",
            "path_and_query": "/waforge-feed.php?r=products/by-sku/TS-RED-M",
            "body": "",
            "body_sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
            "base_string": "1762424300\nGET\n/waforge-feed.php?r=products/by-sku/TS-RED-M\ne3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
            "v1": "148b524d75f0ba6359eba5440a1e762b04c98b3ddb1f0ef5871e7f559fb65ab0",
            "header": "t=1762424300,kid=fs_test_01,v1=148b524d75f0ba6359eba5440a1e762b04c98b3ddb1f0ef5871e7f559fb65ab0"
        },
        {
            "name": "Event pushed to WaForge",
            "t": 1762424400,
            "method": "POST",
            "path_and_query": "/api/v1/connect/events",
            "body": "{\"id\":\"evt_123\",\"type\":\"stock.changed\",\"occurred_at\":\"2026-11-06T10:15:00Z\",\"data\":{\"product_id\":\"p1\",\"variant_id\":\"v1\",\"quantity_available\":0,\"status\":\"out_of_stock\"}}",
            "body_sha256": "0de5cc27cdd9c779c70f3898d498ee959737b0311598e87d4f3d85de60e8fc2b",
            "base_string": "1762424400\nPOST\n/api/v1/connect/events\n0de5cc27cdd9c779c70f3898d498ee959737b0311598e87d4f3d85de60e8fc2b",
            "v1": "3f0f25cfe0d1ebc7c492139eebb6f905bebdbc44275f4a9e9840b541485e5511",
            "header": "t=1762424400,kid=fs_test_01,v1=3f0f25cfe0d1ebc7c492139eebb6f905bebdbc44275f4a9e9840b541485e5511"
        }
    ],
    "invalid": [
        {
            "name": "wrong secret",
            "header": "t=1762424160,kid=fs_test_01,v1=8d9dff443a253a1ea2d4099c0819d70c52c041dd8e00dc32e59df947ff1cea72",
            "now": 1762424160,
            "method": "POST",
            "path_and_query": "/waforge/availability",
            "body": "{\"items\":[{\"product_id\":\"p_1001\",\"variant_id\":\"v_42\",\"quantity\":2}]}",
            "reason": "signature mismatch"
        },
        {
            "name": "body changed by one byte",
            "header": "t=1762424160,kid=fs_test_01,v1=6938bbcd2127c333d5c8e5febd5184b14cd3c17edec4accbe8760337a84bb44e",
            "now": 1762424160,
            "method": "POST",
            "path_and_query": "/waforge/availability",
            "body": "{\"items\":[{\"product_id\":\"p_1001\",\"variant_id\":\"v_42\",\"quantity\":3}]}",
            "reason": "signature mismatch"
        },
        {
            "name": "timestamp 301 s in the past",
            "header": "t=1762424160,kid=fs_test_01,v1=6938bbcd2127c333d5c8e5febd5184b14cd3c17edec4accbe8760337a84bb44e",
            "now": 1762424461,
            "method": "POST",
            "path_and_query": "/waforge/availability",
            "body": "{\"items\":[{\"product_id\":\"p_1001\",\"variant_id\":\"v_42\",\"quantity\":2}]}",
            "reason": "outside 300 s window"
        },
        {
            "name": "timestamp 301 s in the future",
            "header": "t=1762424160,kid=fs_test_01,v1=6938bbcd2127c333d5c8e5febd5184b14cd3c17edec4accbe8760337a84bb44e",
            "now": 1762423859,
            "method": "POST",
            "path_and_query": "/waforge/availability",
            "body": "{\"items\":[{\"product_id\":\"p_1001\",\"variant_id\":\"v_42\",\"quantity\":2}]}",
            "reason": "outside 300 s window"
        },
        {
            "name": "path differs (query dropped)",
            "header": "t=1762424100,kid=fs_test_01,v1=1b9f80ee3e072d71b0e68494a5fb4a588d4ef6b1969060d87b814a2b5d4f43e2",
            "now": 1762424100,
            "method": "GET",
            "path_and_query": "/waforge/catalog/search",
            "body": "",
            "reason": "signature mismatch"
        },
        {
            "name": "timestamp with a leading zero (non-canonical t)",
            "header": "t=01762424160,kid=fs_test_01,v1=6938bbcd2127c333d5c8e5febd5184b14cd3c17edec4accbe8760337a84bb44e",
            "now": 1762424160,
            "method": "POST",
            "path_and_query": "/waforge/availability",
            "body": "{\"items\":[{\"product_id\":\"p_1001\",\"variant_id\":\"v_42\",\"quantity\":2}]}",
            "reason": "t must match ^[1-9][0-9]*$"
        },
        {
            "name": "signature in upper case (non-canonical v1)",
            "header": "t=1762424160,kid=fs_test_01,v1=6938BBCD2127C333D5C8E5FEBD5184B14CD3C17EDEC4ACCBE8760337A84BB44E",
            "now": 1762424160,
            "method": "POST",
            "path_and_query": "/waforge/availability",
            "body": "{\"items\":[{\"product_id\":\"p_1001\",\"variant_id\":\"v_42\",\"quantity\":2}]}",
            "reason": "v1 must match ^[0-9a-f]{64}$"
        },
        {
            "name": "upper case key name V1",
            "header": "t=1762424160,kid=fs_test_01,V1=6938bbcd2127c333d5c8e5febd5184b14cd3c17edec4accbe8760337a84bb44e",
            "now": 1762424160,
            "method": "POST",
            "path_and_query": "/waforge/availability",
            "body": "{\"items\":[{\"product_id\":\"p_1001\",\"variant_id\":\"v_42\",\"quantity\":2}]}",
            "reason": "the key is v1, lower case"
        }
    ],
    "edge": {
        "valid_at_exactly_300_seconds": {
            "header": "t=1762424160,kid=fs_test_01,v1=6938bbcd2127c333d5c8e5febd5184b14cd3c17edec4accbe8760337a84bb44e",
            "now": 1762424460,
            "expect": true
        }
    },
    "canonical": {
        "t": "^[1-9][0-9]*$",
        "v1": "^[0-9a-f]{64}$",
        "replay_key": "(int)t + \":\" + expected_v1, remembered 600 s with an atomic add"
    }
}
