UNPKG

shora-ai-payment-sdk

Version:

The first open-source payment SDK designed specifically for AI agents and chatbots - ACP Compatible

34 lines (33 loc) 1.33 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.createAxiosInstance = createAxiosInstance; const axios_1 = __importDefault(require("axios")); function createAxiosInstance(baseURL, apiKey) { const client = axios_1.default.create({ baseURL, timeout: 30000 }); if (apiKey) { if (apiKey.startsWith('sk_') || apiKey.startsWith('Bearer ')) { client.defaults.headers.common['Authorization'] = `Bearer ${apiKey.replace('Bearer ', '')}`; } else { client.defaults.headers.common['X-API-Key'] = apiKey; client.defaults.headers.common['Authorization'] = `Bearer ${apiKey}`; } } client.interceptors.response.use((r) => { const headers = r.headers || {}; const dep = headers['deprecation'] || headers['Deprecation']; const sunset = headers['sunset'] || headers['Sunset']; const link = headers['link'] || headers['Link']; if (dep === 'true' || sunset) { console.warn(`[Shora-SDK] Deprecation warning: sunset=${sunset} link=${link}`); } return r; }, (e) => Promise.reject(e)); return client; }