
Research
SANDWORM_MODE: Shai-Hulud-Style npm Worm Hijacks CI Workflows and Poisons AI Toolchains
An emerging npm supply chain attack that infects repos, steals CI secrets, and targets developer AI toolchains for further compromise.
@socaity/media-toolkit
Advanced tools
Web-ready standardized file processing and serialization. Read, write, convert and send files. Including image, audio, video and any other file. Easily convert between base64, bytes, numpy and more. Create browser elements or use in node.js
We @socaity.ai designed media-toolkit to work in a standardized way with all kind of media files across node.js, browser, and python environments. This SDK is designed to simplify the process of loading, manipulating, and exporting media files, making it an essential tool for developers working with multimedia content.
We use it to offer a simple unified approach for interacting with the socaity APIs for generative AI. Check-out our SDKs socaity-js and socaity-python to learn more about it.
Install the SDK via npm:
npm install @socaity/media-toolkit
This section covers how to effectively work with files when using the SDK.
import { MediaFile, ImageFile, AudioFile, VideoFile } from '@socaity/media-toolkit';
Or in browser environments
<script src="media-toolkit.umd.js" />
The SDK supports loading files from various sources:
// From a local file path (Node.js only)
const imageFile = await MediaFile.create("./path/to/image.jpg");
// From a URL
const imageFromUrl = await MediaFile.create("https://example.com/image.jpg");
// From base64 data
const imageFromBase64 = await MediaFile.create("data:image/jpeg;base64,/9j/4AAQ...");
// From binary data (ArrayBuffer, Buffer, or Uint8Array)
const buffer = fs.readFileSync("./image.jpg");
const imageFromBuffer = await MediaFile.create(buffer);
After receiving results from Socaity APIs, you can easily save or export them:
// Convert to different formats
const mf = await MediaFile.create("..")
const base64String = mf.toBase64(); // Returns data URI by default
const arrayBuffer = mf.toArrayBuffer();
const uint8Array = mf.toUint8Array();
const buffer = mf.toBuffer(); // In Node.js environments
const blob = mf.toBlob(); // In browser environments
For web applications, you can easily embed generated content. We imply that you have the socaity SDK installed
// Generate an image with Socaity API
const generatedImage = await socaity.text2img("A futuristic city");
// Create an image and append it to an element. This creates an <img src=".." > element.
document.getElementById('myImg').append(generatedImage.toImageElement())
// Or use in an existing HTML img
const imgElement = document.getElementById('myImg');
imgElement.src = generatedImage.toBase64();
Retrieve and modify file metadata:
// Get file information
const fileInfo = mediaFile.getInfo();
console.log(`Filename: ${fileInfo.fileName}`);
console.log(`Content type: ${fileInfo.contentType}`);
console.log(`Size: ${fileInfo.size} bytes`);
console.log(`Extension: ${fileInfo.extension}`);
// Check file size in different units
const sizeInKB = mediaFile.fileSize('kb');
const sizeInMB = mediaFile.fileSize('mb');
// Modify file metadata
mediaFile.setFileName("renamed_file.png");
mediaFile.setContentType("image/png");
Once you have a MediaFile object, you can use it directly with any Socaity API endpoint:
// Use with face swap API
const swappedFace = await socaity.swapImg2Img(sourceImage, targetImage);
// Use with text-to-image API for image-to-image processing
const prompt = "Transform this into a cyberpunk scene";
const enhancedImage = await socaity.text2img(prompt, "flux-schnell", {
init_image: sourceImage,
strength: 0.75
});
We welcome contributions from the community. Please read our contributing guidelines to get started.
This project is licensed under the MIT License. See the LICENSE file for details.
For support or inquiries, please contact us at support@socaity.ai.
Stay updated with our latest news and releases by following us on Twitter and LinkedIn.
Happy coding!
FAQs
Web-ready standardized file processing and serialization. Read, write, convert and send files. Including image, audio, video and any other file. Easily convert between base64, bytes, numpy and more. Create browser elements or use in node.js
We found that @socaity/media-toolkit 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.

Research
An emerging npm supply chain attack that infects repos, steals CI secrets, and targets developer AI toolchains for further compromise.

Company News
Socket is proud to join the OpenJS Foundation as a Silver Member, deepening our commitment to the long-term health and security of the JavaScript ecosystem.

Security News
npm now links to Socket's security analysis on every package page. Here's what you'll find when you click through.