
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
idl2js – Anchor IDL → Pure JavaScript SDK
项目概述
主要特性
programId(亦可手动指定)。ora 与 chalk 的友好终端 UI。@coral-xyz/anchor 生成代码与 esbuild 转译。安装
# 推荐全局安装便于命令行使用
npm install -g idl2js
# 或在项目内局部安装
npm install idl2js --save-dev
快速上手
# 在包含 idl.json 的目录下
idl2js # 默认读取 ./idl.json 并输出到 ./sdk-js
# 指定 IDL 与输出格式
idl2js ./my_idl.json -j ./client -f cjs
CLI 选项
| 短标记 | 长标记 / 参数 | 说明 | 默认值 |
|---|---|---|---|
| -p | --program-id | 手动指定 Program ID | 自动推断 |
| -j | --js-out | JavaScript 输出目录 | ./sdk-js |
| -f | --format <esm|cjs> | 输出模块格式 | esm |
| -t | --ts-out | 临时 TypeScript 目录(调试用) | ./.tmp-ts |
| -v | --verbose | 显示详细日志 | false |
| -i | --interactive | 交互式提问模式 | false |
编程式调用
import { generateJsSdk } from 'idl2js';
await generateJsSdk({
idlPath: './idl.json',
programId: 'YourProgramPubkey',
jsOutDir: './sdk',
format: 'esm'
});
生成后如何使用
ESM 项目:
import { MyProgram } from './sdk';
const program = new MyProgram(connection, wallet);
CommonJS 项目:
const { MyProgram } = require('./sdk');
常见问题
CARGO_NET_GIT_FETCH_WITH_CLI=true。es2022,可通过 --target es2020 降级。若需 polyfill,请在打包器中注入 buffer、stream 等浏览器替代。esbuild、ora、chalk 等优秀开源项目FAQs
将 Anchor IDL 转换为纯 JavaScript SDK,无需 TypeScript 编译
We found that idl2js 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.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.