Initial commit

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01F22Ms5Cxam5UHyxaCrtZzu
This commit is contained in:
Rami Bitar
2026-07-29 11:02:40 -04:00
co-authored by Claude Fable 5
commit f23332e42c
88 changed files with 7947 additions and 0 deletions
+15
View File
@@ -0,0 +1,15 @@
const FIRST_FORWARDED_IP_INDEX = 0;
export const BUYER_IP_HEADERS = ["oxygen-buyer-ip", "cf-connecting-ip", "x-forwarded-for"] as const;
export const DEVELOPMENT_BUYER_IP = "127.0.0.1";
export function getBuyerIp(headers: Pick<Headers, "get">): string {
for (const header of BUYER_IP_HEADERS) {
const buyerIp = headers.get(header)?.split(",")[FIRST_FORWARDED_IP_INDEX]?.trim();
if (buyerIp) return buyerIp;
}
if (process.env.NODE_ENV !== "production") return DEVELOPMENT_BUYER_IP;
throw new Error(`${BUYER_IP_HEADERS.join(", ")} is required for private Storefront API clients`);
}