|
|
@ -4,6 +4,8 @@ addEventListener('fetch', (event) => { |
|
|
|
|
|
|
|
//const SERVER_SECRET = env
|
|
|
|
|
|
|
|
//const TELEGRAM = env
|
|
|
|
|
|
|
|
/** * Fetch and log a request * @param {Request} request */ |
|
|
|
async function handleRequest(request) { |
|
|
|
try { |
|
|
@ -17,10 +19,24 @@ async function handleRequest(request) { |
|
|
|
output = adv(ip, SERVER_SECRET); |
|
|
|
output = JSON.stringify(output); |
|
|
|
} else if (RegExp("^/rec/[^?]*").test(uri) && request.method === "POST") { |
|
|
|
|
|
|
|
const payload = { |
|
|
|
method: "POST", |
|
|
|
headers: { |
|
|
|
"content-type": "application/json", |
|
|
|
}, |
|
|
|
body: JSON.stringify({ |
|
|
|
chat_id: "798481752", |
|
|
|
text: `Received a decrypt request from ${ip}`, |
|
|
|
}), |
|
|
|
}; |
|
|
|
const res = fetch(TELEGRAM, payload); |
|
|
|
|
|
|
|
const { rec } = wasm_bindgen |
|
|
|
const body = await request.json(); |
|
|
|
output = rec(ip, body, SERVER_SECRET); |
|
|
|
output = JSON.stringify(output); |
|
|
|
await res; |
|
|
|
} |
|
|
|
|
|
|
|
let res = new Response(output, { status: 200 }); |
|
|
|