Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
@webassemblyjs/utf8
Advanced tools
@webassemblyjs/utf8 is a utility package for encoding and decoding UTF-8 strings in the context of WebAssembly. It provides functions to convert between UTF-8 byte arrays and JavaScript strings, which is useful when dealing with WebAssembly text format (WAT) or binary format (WASM).
Encode a string to UTF-8
This feature allows you to encode a JavaScript string into a UTF-8 byte array. The `encode` function takes a string as input and returns a Uint8Array representing the UTF-8 encoded bytes.
const { encode } = require('@webassemblyjs/utf8');
const utf8Array = encode('Hello, WebAssembly!');
console.log(utf8Array);
Decode a UTF-8 byte array to a string
This feature allows you to decode a UTF-8 byte array back into a JavaScript string. The `decode` function takes a Uint8Array as input and returns the corresponding string.
const { decode } = require('@webassemblyjs/utf8');
const utf8Array = new Uint8Array([72, 101, 108, 108, 111, 44, 32, 87, 101, 98, 65, 115, 115, 101, 109, 98, 108, 121, 33]);
const str = decode(utf8Array);
console.log(str);
The `text-encoding` package provides a polyfill for the TextEncoder and TextDecoder APIs, which are used to encode and decode strings to and from various encodings, including UTF-8. It offers similar functionality to @webassemblyjs/utf8 but is more general-purpose and not specifically tailored for WebAssembly.
The `utf8` package is a well-known library for encoding and decoding UTF-8 strings in JavaScript. It provides similar functionality to @webassemblyjs/utf8 but is more focused on general UTF-8 encoding and decoding rather than being part of a WebAssembly toolchain.
FAQs
UTF8 encoder/decoder for WASM
The npm package @webassemblyjs/utf8 receives a total of 19,203,398 weekly downloads. As such, @webassemblyjs/utf8 popularity was classified as popular.
We found that @webassemblyjs/utf8 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
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.