New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@swing.xyz/cross-chain-api

Package Overview
Dependencies
Maintainers
3
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@swing.xyz/cross-chain-api - npm Package Compare versions

Comparing version 0.0.5 to 0.0.6

6

CHANGELOG.md
# @swing.xyz/cross-chain-api
## 0.0.6
### Patch Changes
- ee5d25b: Provide default headers to the API client
## 0.0.5

@@ -4,0 +10,0 @@

2

dist/index.js

@@ -1,2 +0,2 @@

var R={"Content-Type":"application/json"};function g(t={}){let{fetch:e=globalThis.fetch,querySerializer:n,bodySerializer:s,...r}=t,a=r.baseUrl??"";a.endsWith("/")&&(a=a.slice(0,-1));async function f(o,i){let{fetch:x=e,headers:I,body:b,params:w={},parseAs:d="json",querySerializer:T=n??U,bodySerializer:O=s??z,...j}=i||{},C=$(o,{baseUrl:a,params:w,querySerializer:T}),A=H(R,t?.headers,I,w.header),u={redirect:"follow",...r,...j,headers:A};b&&(u.body=O(b)),u.body instanceof FormData&&A.delete("Content-Type");let c=await x(C,u);if(c.status===204||c.headers.get("Content-Length")==="0")return c.ok?{data:{},response:c}:{error:{},response:c};if(c.ok){let l;if(d!=="stream"){let y=c.clone();l=typeof y[d]=="function"?await y[d]():await y.text()}else l=c.clone().body;return{data:l,response:c}}let p={};try{p=await c.clone().json()}catch{p=await c.clone().text()}return{error:p,response:c}}return{async GET(o,...i){return f(o,{...i[0],method:"GET"})},async PUT(o,...i){return f(o,{...i[0],method:"PUT"})},async POST(o,...i){return f(o,{...i[0],method:"POST"})},async DELETE(o,...i){return f(o,{...i[0],method:"DELETE"})},async OPTIONS(o,...i){return f(o,{...i[0],method:"OPTIONS"})},async HEAD(o,...i){return f(o,{...i[0],method:"HEAD"})},async PATCH(o,...i){return f(o,{...i[0],method:"PATCH"})},async TRACE(o,...i){return f(o,{...i[0],method:"TRACE"})}}}function U(t){let e=[];if(t&&typeof t=="object")for(let[n,s]of Object.entries(t)){let r=m([n],s);r&&e.push(r)}return e.join("&")}function m(t,e){if(e!=null){if(typeof e=="string")return`${h(t)}=${encodeURIComponent(e)}`;if(typeof e=="number"||typeof e=="boolean")return`${h(t)}=${String(e)}`;if(Array.isArray(e)){if(!e.length)return;let n=[];for(let s of e){let r=m(t,s);r!==void 0&&n.push(r)}return n.join("&")}if(typeof e=="object"){if(!Object.keys(e).length)return;let n=[];for(let[s,r]of Object.entries(e))if(r!=null){let a=m([...t,s],r);a!==void 0&&n.push(a)}return n.join("&")}return encodeURIComponent(`${h(t)}=${String(e)}`)}}function h(t){let e=t[0];for(let n of t.slice(1))e+=`[${n}]`;return e}function z(t){return JSON.stringify(t)}function $(t,e){let n=`${e.baseUrl}${t}`;if(e.params.path)for(let[r,a]of Object.entries(e.params.path))n=n.replace(`{${r}}`,encodeURIComponent(String(a)));let s=e.querySerializer(e.params.query??{});return s&&(n+=`?${s}`),n}function H(...t){let e=new Headers;for(let n of t){if(!n||typeof n!="object")continue;let s=n instanceof Headers?n.entries():Object.entries(n);for(let[r,a]of s)a===null?e.delete(r):a!==void 0&&e.set(r,a)}return e}var P={environment:"production",headers:{}},S={production:"https://swap.prod.swing.xyz",development:"https://swap.dev.swing.xyz",testnet:"https://swap-testnet.dev.swing.xyz"},E=new WeakMap;function k({environment:t=P.environment,headers:e}=P){if(!(t in S))if(t==="dev")t="development";else throw new Error(`Invalid environment: ${t}. Valid options are ${Object.keys(S).join(", ")}.`);let n=E.get({environment:t,headers:e});return n||(n={...g({baseUrl:S[t]}),environment:t},E.set({environment:t,headers:e},n)),n}export{k as getSwingAPI};
var C={"Content-Type":"application/json"};function g(t={}){let{fetch:e=globalThis.fetch,querySerializer:n,bodySerializer:o,...r}=t,a=r.baseUrl??"";a.endsWith("/")&&(a=a.slice(0,-1));async function f(i,s){let{fetch:E=e,headers:I,body:b,params:w={},parseAs:d="json",querySerializer:O=n??R,bodySerializer:T=o??U,...v}=s||{},j=z(i,{baseUrl:a,params:w,querySerializer:O}),A=$(C,t?.headers,I,w.header),p={redirect:"follow",...r,...v,headers:A};b&&(p.body=T(b)),p.body instanceof FormData&&A.delete("Content-Type");let c=await E(j,p);if(c.status===204||c.headers.get("Content-Length")==="0")return c.ok?{data:{},response:c}:{error:{},response:c};if(c.ok){let l;if(d!=="stream"){let m=c.clone();l=typeof m[d]=="function"?await m[d]():await m.text()}else l=c.clone().body;return{data:l,response:c}}let u={};try{u=await c.clone().json()}catch{u=await c.clone().text()}return{error:u,response:c}}return{async GET(i,...s){return f(i,{...s[0],method:"GET"})},async PUT(i,...s){return f(i,{...s[0],method:"PUT"})},async POST(i,...s){return f(i,{...s[0],method:"POST"})},async DELETE(i,...s){return f(i,{...s[0],method:"DELETE"})},async OPTIONS(i,...s){return f(i,{...s[0],method:"OPTIONS"})},async HEAD(i,...s){return f(i,{...s[0],method:"HEAD"})},async PATCH(i,...s){return f(i,{...s[0],method:"PATCH"})},async TRACE(i,...s){return f(i,{...s[0],method:"TRACE"})}}}function R(t){let e=[];if(t&&typeof t=="object")for(let[n,o]of Object.entries(t)){let r=y([n],o);r&&e.push(r)}return e.join("&")}function y(t,e){if(e!=null){if(typeof e=="string")return`${h(t)}=${encodeURIComponent(e)}`;if(typeof e=="number"||typeof e=="boolean")return`${h(t)}=${String(e)}`;if(Array.isArray(e)){if(!e.length)return;let n=[];for(let o of e){let r=y(t,o);r!==void 0&&n.push(r)}return n.join("&")}if(typeof e=="object"){if(!Object.keys(e).length)return;let n=[];for(let[o,r]of Object.entries(e))if(r!=null){let a=y([...t,o],r);a!==void 0&&n.push(a)}return n.join("&")}return encodeURIComponent(`${h(t)}=${String(e)}`)}}function h(t){let e=t[0];for(let n of t.slice(1))e+=`[${n}]`;return e}function U(t){return JSON.stringify(t)}function z(t,e){let n=`${e.baseUrl}${t}`;if(e.params.path)for(let[r,a]of Object.entries(e.params.path))n=n.replace(`{${r}}`,encodeURIComponent(String(a)));let o=e.querySerializer(e.params.query??{});return o&&(n+=`?${o}`),n}function $(...t){let e=new Headers;for(let n of t){if(!n||typeof n!="object")continue;let o=n instanceof Headers?n.entries():Object.entries(n);for(let[r,a]of o)a===null?e.delete(r):a!==void 0&&e.set(r,a)}return e}var P={environment:"production",headers:{}},S={production:"https://swap.prod.swing.xyz",development:"https://swap.dev.swing.xyz",testnet:"https://swap-testnet.dev.swing.xyz"},x=new WeakMap;function D({environment:t=P.environment,headers:e}=P){let n={environment:t,headers:e};if(!(n.environment in S))if(n.environment==="dev")n.environment="development";else throw new Error(`Invalid environment: ${n.environment}. Valid options are ${Object.keys(S).join(", ")}.`);let o=x.get(n);return o||(o={...g({baseUrl:S[n.environment],headers:{...n.headers,"x-swing-environment":n.environment}}),environment:n.environment},x.set(n,o)),o}export{D as getSwingAPI};
//# sourceMappingURL=index.js.map
{
"name": "@swing.xyz/cross-chain-api",
"version": "0.0.5",
"version": "0.0.6",
"publishConfig": {

@@ -5,0 +5,0 @@ "access": "public"

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc