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.
parse-data-uri
Advanced tools
The parse-data-uri npm package is used to parse data URIs into their constituent parts, such as media type, data, and parameters. This can be useful for handling data URIs in web applications, particularly when dealing with inline data in HTML or CSS.
Parse a data URI
This feature allows you to parse a data URI string and extract its components, such as media type, data, and parameters. The code sample demonstrates how to use the parse-data-uri package to parse a simple text data URI.
const parseDataUri = require('parse-data-uri');
const dataUri = 'data:text/plain;base64,SGVsbG8sIFdvcmxkIQ==';
const parsed = parseDataUri(dataUri);
console.log(parsed);
Handle different media types
This feature shows how the package can handle different media types, such as images. The code sample demonstrates parsing a data URI that contains a base64-encoded PNG image.
const parseDataUri = require('parse-data-uri');
const imageDataUri = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUA...';
const parsedImage = parseDataUri(imageDataUri);
console.log(parsedImage);
Extract base64 data
This feature allows you to extract the base64-encoded data from a data URI. The code sample demonstrates how to parse a data URI and then extract the base64 data from the parsed result.
const parseDataUri = require('parse-data-uri');
const dataUri = 'data:text/plain;base64,SGVsbG8sIFdvcmxkIQ==';
const parsed = parseDataUri(dataUri);
const base64Data = parsed.data;
console.log(base64Data);
The datauri package provides similar functionality to parse-data-uri, allowing you to parse and generate data URIs. It also includes additional features for working with file paths and streams, making it a more versatile option for handling data URIs in various contexts.
parse a data uri into mime type and buffer
var parseDataUri = require('parse-data-uri')
var dataUri = 'data:image/jpeg;base64,23423423...'
var parsed = parseDataUri(dataUri)
console.log(parsed)
// {
// mimeType: 'image/jpeg',
// data: Buffer < 00 00 00 ... >
// }
###parseDataUri : ( dataUri: String ) => {mimeType: String, data: Buffer}
$ npm install parse-data-uri
From package root:
$ npm install
$ npm test
Special thanks to @tootallnate for writing data-uri-to-buffer
ISC. (c) MMXIV jden jason@denizac.org. See LICENSE.md
FAQs
parse a data uri into mime type and buffer
The npm package parse-data-uri receives a total of 183,968 weekly downloads. As such, parse-data-uri popularity was classified as popular.
We found that parse-data-uri 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.
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.