
Research
/Security News
Weaponizing Discord for Command and Control Across npm, PyPI, and RubyGems.org
Socket researchers uncover how threat actors weaponize Discord across the npm, PyPI, and RubyGems ecosystems to exfiltrate sensitive data.
@bytecodealliance/jco-transpile
Advanced tools
WebAssembly Component transpilation functionality for Jco
@bytecodealliance/jco-transpile
This @bytecodealliance/jco
sub-project enables transpilation of WebAssembly Components into ES modules
that can be run in Javascript environments like NodeJS and the browser (experimental).
@bytecodealliance/jco-transpile
is used primarily when only transpilation functionality of jco
is needed,
and jco
derives it's use of transpilation from this library.
[!WARNING] Browser support is considered experimental, and not currently suitable for production applications.
To use @bytecodealliance/jco-transpile
as a library in your own code, you can use some of the exported functions.
To transpile an existing WebAssembly component (path on disk, Buffer
):
import { dirname } from "node:path";
import { mkdir, writeFile } from "node:fs/promises";
import { transpile } from '@bytecodealliance/jco-transpile';
async function example() {
const { files, imports, exports } = await transpile('path/to/component.wasm', { outDir: 'path/to/output/dir' });
// NOTE: Files is a serialization of the files produced of the following type:
// type FileBytes = { [filepath: string]: Uint8Array; };
//
// You can use the code below to write out all files to a given directory
await Promise.all(
Object.entries(files).map(async ([filePath, bytes]) => {
await mkdir(dirname(filePath), { recursive: true });
await writeFile(filePath, bytes);
})
);
}
[!NOTE]
transpile
takes many options -- consulttranspile.d.ts
for more detailed type information.
outDir
controls the prefix of generated file paths, so it is specified, despite the fact that no files are actually written to disk.
To generate host types:
import { dirname } from "node:path";
import { mkdir, writeFile } from "node:fs/promises";
import { generateHostTypes } from '@bytecodealliance/jco-transpile';
async function example() {
const files = await generateHostTypes('path/to/wit/dir-or-file, { outDir: 'path/to/output/dir' });
// NOTE: Files is a serialization of the files produced of the following type:
// type FileBytes = { [filepath: string]: Uint8Array; };
//
// You can use the code below to write out all files to a given directory
await Promise.all(
Object.entries(files).map(async ([filePath, bytes]) => {
await mkdir(dirname(filePath), { recursive: true });
await writeFile(filePath, bytes);
})
);
}
Host types are the implementations of WIT interfaces that are used by post-transpilation JS code, i.e. on the "host" (NodeJS + V8 or the browser), to make platform imports work.
For a given import in a WIT world, this type generation would enable implementation of the interface.
To generate guest types:
import { dirname } from "node:path";
import { mkdir, writeFile } from "node:fs/promises";
import { generateGuestTypes } from '@bytecodealliance/jco-transpile';
async function example() {
const files = await generateGuestTypes('path/to/wit/dir-or-file, { outDir: 'path/to/output/dir' });
// NOTE: Files is a serialization of the files produced of the following type:
// type FileBytes = { [filepath: string]: Uint8Array; };
//
// You can use the code below to write out all files to a given directory
await Promise.all(
Object.entries(files).map(async ([filePath, bytes]) => {
await mkdir(dirname(filePath), { recursive: true });
await writeFile(filePath, bytes);
})
);
}
Guest types are the implementations of WIT interfaces that are used by JS components -- i.e. JS code that is
turned into a component (by jco componentize
/componentize-js
) and performing useful work.
For a given import in a WIT world, this type generation would enable calling/using the interface.
This project is licensed under the Apache 2.0 license with the LLVM exception. See LICENSE for more details.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this project by you, as defined in the Apache-2.0 license, shall be licensed as above, without any additional terms or conditions.
FAQs
WebAssembly Component transpilation functionality for Jco
We found that @bytecodealliance/jco-transpile demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 4 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
Socket researchers uncover how threat actors weaponize Discord across the npm, PyPI, and RubyGems ecosystems to exfiltrate sensitive data.
Security News
Socket now integrates with Bun 1.3’s Security Scanner API to block risky packages at install time and enforce your organization’s policies in local dev and CI.
Research
The Socket Threat Research Team is tracking weekly intrusions into the npm registry that follow a repeatable adversarial playbook used by North Korean state-sponsored actors.