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.
The potpack npm package is a utility for packing rectangles into a single bin. It is useful for tasks such as packing images into a texture atlas or arranging elements in a confined space efficiently.
Rectangle Packing
This feature allows you to pack a list of rectangles into a single bin. The function returns the width and height of the bin and the fill rate. The input rectangles are modified to include their x and y positions in the bin.
const potpack = require('potpack');
const rectangles = [
{ w: 100, h: 200 },
{ w: 300, h: 100 },
{ w: 50, h: 50 }
];
const { w, h, fill } = potpack(rectangles);
console.log(`Packed width: ${w}, height: ${h}, fill: ${fill}`);
console.log('Rectangles:', rectangles);
The bin-pack package provides similar functionality for packing rectangles into a bin. It offers a more flexible API with support for different packing algorithms. Compared to potpack, bin-pack may offer more options but could be more complex to use.
A tiny JavaScript library for packing 2D rectangles into a near-square container, which is useful for generating CSS sprites and WebGL textures. Similar to shelf-pack, but static (you can't add items once a layout is generated), and aims for maximal space utilization.
A variation of algorithms used in rectpack2D and bin-pack, which are in turn based on this article by Blackpawn.
import potpack from 'potpack';
const boxes = [
{w: 300, h: 50},
{w: 100, h: 200},
...
];
const {w, h, fill} = potpack(boxes);
// w and h are resulting container's width and height;
// fill is the space utilization value (0 to 1), higher is better
// potpack mutates the boxes array: it's sorted by height,
// and box objects are augmented with x, y coordinates:
boxes[0]; // {w: 300, h: 50, x: 100, y: 0}
boxes[1]; // {w: 100, h: 200, x: 0, y: 0}
Install with NPM: npm install potpack
.
Potpack is provided as a ES module, so it's only supported on modern browsers, excluding IE:
<script type="module">
import potpack from 'https://cdn.skypack.dev/potpack';
...
</script>
In Node, you can't use require
— only import
in ESM-capable versions (v12.15+):
import potpack from 'potpack';
FAQs
A tiny library for packing 2D rectangles (for sprite layouts)
The npm package potpack receives a total of 1,274,287 weekly downloads. As such, potpack popularity was classified as popular.
We found that potpack 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.