UNPKG

teddi-x

Version:

Teddi (teddi-x) is a Node package that extends security to vertical agents., applications, and tooling built on, for, or with AI.

32 lines (26 loc) 935 B
const secureFetch = async(input, init = {}) => { const originalUrl = typeof input === "string" ? input : input.url; const method = init.method || "GET"; const body = init.body || null; const headers = init.headers || {}; const teddiHash = init.teddiHash; const integrationId = init.integrationId; const proxyUrl = "https://teddi-3503aabcbe73.herokuapp.com/proxy-api"; // always this endpoint const payload = { originalUrl, // this is where "/rest/v1/users" or full URL lives method, body, headers, }; const requestHeaders = { "Content-Type": "application/json", ...(teddiHash && { "X-Teddi-Hash": teddiHash }), ...(integrationId && { integrationid: integrationId }), }; return fetch(proxyUrl, { method: "POST", headers: requestHeaders, body: JSON.stringify(payload), }); }; export { secureFetch };