
Research
Malicious npm Packages Impersonate Flashbots SDKs, Targeting Ethereum Wallet Credentials
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
类 Axios 语法的原生 fetch API 请求封装库
Fetch based HTTP client with similar API to axios for browser and Node.js
fetch + axios = fexios (Just a joke)
fexios.post()
)index.umd.cjs 8.51 kB │ gzip: 3.48 kB │ map: 31.96 kB
包管理器 Using package manager
# Node Package Manager
npm install fexios
# Why not pnpm
pnpm add fexios
# Or yarn?
yarn add fexios
Then import the library and enjoy:
import fexios, { createFexios, Fexios } from 'fexios'
// Using directly
fexios.get('https://zh.moegirl.org.cn/api.php')
// With options
const fexios = createFexios(/* options */)
const fexios = new Fexios(/* options */)
const fexios = Fexios.create(/* options */)
在浏览器中直接使用 Use directly in the browser
import('https://unpkg.com/fexios?module').then(({ createFexios }) => {
const fexios = createFexios(/* options */)
})
<script src="https://unpkg.com/fexios"></script>
<script>
// Using directly
fexios.get('https://zh.moegirl.org.cn/api.php')
// With options
const { createFexios } = Fexios
const fexios = createFexios(/* options */)
</script>
Refer: https://developer.mozilla.org/docs/Web/API/Fetch_API
Chrome | Edge | Firefox | Opera | Safari | Node.js |
---|---|---|---|---|---|
42 | 14 | 39 | 29 | 10.1 (iOS 10.3) | ^16.15.0 || >=18.0.0 |
* Abort signal requires higher version.
You can find some sample code snippets here.
export type FexiosConfigs = {
baseURL: string
query: Record<string, string | number | boolean> | URLSearchParams
headers: Record<string, string> | Headers
credentials: 'omit' | 'same-origin' | 'include'
responseType: 'json' | 'blob' | 'text'
}
const DEFAULT_CONFIGS = {
baseURL: '',
credentials: 'same-origin',
headers: {
'content-type': 'application/json; charset=UTF-8',
},
query: {},
responseType: 'json',
}
fexios.request<T>(config): Promise<FexiosResponse<T>>
export interface FexiosRequestOptions {
baseURL?: string
method?: FexiosMethods
credentials?: 'omit' | 'same-origin' | 'include'
headers?: Record<string, string> | Headers
query?: Record<string, string | number | boolean> | URLSearchParams
body?: Record<string, any> | string | FormData | URLSearchParams
responseType?: 'json' | 'blob' | 'text'
}
returns {FexiosFinalContext}
export type FexiosFinalContext<T = any> = Omit<
FexiosContext<T>,
'rawResponse' | 'response' | 'data' | 'headers'
> & {
rawResponse: Response
response: FexiosResponse<T>
headers: Headers
data: T
}
export type FexiosResponse<T = any> = {
rawResponse: Response
ok: boolean
status: number
statusText: string
headers: Headers
isGood: boolean
data: T
}
And common request methods aliases:
You can modify context in hooks' callback then return it as a brand new context™.
Return false
to abort request immediately.
export type FexiosHook<C = unknown> = (context: C) => AwaitAble<C | false>
export interface FexiosContext<T = any> extends FexiosRequestOptions {
url: string // may changes after beforeInit
rawRequest?: Request // provide in beforeRequest
rawResponse?: Response // provide in afterRequest
response?: FexiosResponse // provide in afterRequest
data?: T // provide in afterRequest
}
const fexios = new Fexios()
fexios.on('beforeRequest', async (ctx) => {
const url = new URL(ctx.url)
if (url.searchParams.has('foo')) {
return false
} else {
url.searchParams.set('foo', 'bar')
ctx.url = '' + url
return ctx
}
})
All context passed as is. You can do custom conversions here.
Pre-converted done.
At this time, ctx.url
has been converted to final URL string. You cannot modify the ctx.query
or ctx.baseURL
to change ctx.url
. Please modify ctx.url
directly.
ctx.url
{string}
full URL string converted from url, baseURL and ctx.queryctx.query
{Record<string, string>}
merged from url, requestOptions, baseOptionsctx.headers
{Record<string, string>}
merged from requestOptions, baseOptionsJSON body has been transformed to JSON string. Content-Type
header has been set to body's type.
ctx.body
{string|URLSearchParams|FormData|Blob}
The Request instance has been generated.
At this time, you cannot modify the ctx.url
, ctx.query
, ctx.headers
or ctx.body
(etc.) anymore. Unless you pass a brand new Request
to replace ctx.rawRequest
.
ctx.rawRequest
{Request}
The FexiosFinalContext
will be passed
Oh, this is mimicked from axios. Just sweet sugar.
// They are the same
fexios.on('beforeRequest', async (ctx) => {})
fexios.interceptors.request.use((ctx) => {})
// Bro, they're just the same
fexios.on('afterResponse', async (ctx) => {})
fexios.interceptors.response.use((ctx) => {})
MIT License
Copyright (c) 2023 机智的小鱼君 (A.K.A. Dragon-Fish)
FAQs
Fetch based HTTP client with similar API to axios for browser and Node.js
The npm package fexios receives a total of 35 weekly downloads. As such, fexios popularity was classified as not popular.
We found that fexios demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
Security News
Ruby maintainers from Bundler and rbenv teams are building rv to bring Python uv's speed and unified tooling approach to Ruby development.
Security News
Following last week’s supply chain attack, Nx published findings on the GitHub Actions exploit and moved npm publishing to Trusted Publishers.