Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
ws-connector.js
Advanced tools
一个轻量级的 websocket 连接器,简单易用
import Connector from 'ws-connector.js';
//获取实例,传入配置
const connector = Connector.getInstance({
url: 'wss://examplate.ws.com',
heartBeat: {
enable: true,
sendMessage: 'ping',
receiveMessage: {
handle: 'pong',
receivingStrategy: 'match',
regExp: /^pong/
},
duration: 5000
}
});
//设置消息
connector.setMessage({
sub: 'add',
type: 'quotes'
});
//开始发送
connector.start(receiver /* 接收器 */, () => sendLog('') /* ws中断回调 */);
//接收器
const receiver = ({ data }) => {
console.log(data);
};
配置名称 | 配置说明 | 可选值 | 类型 |
---|---|---|---|
url | websocket url | / | string |
warning | 是否显示警告 | / | boolean |
heartBeat | 心跳机制配置 | 详见心跳机制配置 | object |
配置名称 | 配置说明 | 可选值 | 类型 |
---|---|---|---|
enable | 是否启用心跳 | / | boolean |
sendMessage | 发送的心跳信息 | / | boolean |
receiveMessage | 接收心跳信息的配置 | / | 详见接收心跳信息的配置 |
duration | 心跳周期,以 ms 为单位,默认为 1000ms | / | number |
breakOffHandler | 心跳断开的回调 | / | Function |
配置名称 | 配置说明 | 可选值 | 类型 |
---|---|---|---|
handle | 接收句柄 | / | string |
receivingStrategy | 匹配策略 | match(使用正则匹配句柄),contain(是否包含句柄),absolutely(完全匹配句柄),startsWidth(收到的心跳消息是否以句柄开头),endsWidth(收到的心跳消息是否以句柄结尾) | string |
regExp | 匹配正则,只有在匹配策略为"match"时有效 ,默认为/\*/ | / | string |
Connector.getInstance
创建ws-connector.js
实例
connector.setMessage
设置接下来要发送的信息
connector.start
开始接收信息
FAQs
一个轻量级的websocket连接器插件
We found that ws-connector.js demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers 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
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.