
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.
一个简单的 Ajax 客服端
用法:
npm install ereq --save
import Ereq from 'ereq'
var globOpts = { baseUrl: 'http://xxx.xx.com' }
var handlers = {
successHandler: function (resText, resolve, reject) {
var res = null
try {
res = JSON.parse(resText)
} catch (e) {
reject(buildErrInfo('PARSE ERROR'))
return
}
if (res.cood === 200) {
resolve(res.data)
} else {
reject(buildErrInfo(res.msg))
}
}
}
var req = Ereq(globOpts, handlers)
var options = {
method: 'post',
url: 'api/xxxx/xxx',
params: { name: 'xxx', arg: 'xxxx' }
}
req(options)
.then(res => { console.log('ok', res)})
.catch(err => {console.log('err', err)})
默认的一些请求处理函数
var DEFAULT_HANDLERS = {
successHandler: function (resText, resolve, reject) {
var res = null
try {
res = JSON.parse(resText)
} catch (e) {
reject(buildErrInfo('PARSE ERROR'))
return
}
resolve(res)
},
errorHandler: function (xhr, reject) {
reject(buildErrInfo('REQUEST ERROR', xhr))
},
timeoutHandler: function (xhr, reject) {
reject(buildErrInfo('TIMEOUT', xhr))
}
}
可以在 Ereq(opionts, handlers) 通过 handlers 进行覆盖
默认的配置项
var DEFAULT_OPTIONS = {
baseUrl: '',
timeout: 0,
method: 'get'
}
额,代码没几行,看源码来得明白~
FAQs
一个简单的 Ajax 客服端
The npm package ereq receives a total of 0 weekly downloads. As such, ereq popularity was classified as not popular.
We found that ereq demonstrated a not healthy version release cadence and project activity because the last version was released 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.