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.
An highly experimental Entity Component System written in Javascript.
Designed aiming to achieve a "pure" ECS implementation, following two main rules:
world
instanceworld
npm install --save ecsy
Warning: Highly experimental API subject to change every day :)
import {World, System, ReactiveSystem} from 'ecs';
// Rotating component
class Rotating {
constructor() {
this.rotatingSpeed = 0.1;
this.decreasingSpeed = 0.001;
}
}
// Transform component
class Transform {
constructor() {
this.rotation = { x: 0, y: 0, z: 0 };
this.position = { x: 0, y: 0, z: 0 };
this.scale = { x: 1, y: 1, z: 1 };
}
}
// Mouse component (to be used as singleton)
class MouseState {
constructor() {
this.mouseDown = false;
}
}
// Create a TestSystem to modify Transform components
class RotatingSystem extends System {
init() {
return {
entities: [Rotating, Transform]
};
}
execute(delta) {
let entities = this.queries.entities;
for (var i = 0; i < entities.length; i++) {
var entity = entities[i];
var rotating = entity.getComponent(Rotating);
var rotatingSpeed = rotating.rotatingSpeed;
var transform = entity.getMutableComponent(Transform);
transform.rotation.x += rotatingSpeed;
}
}
}
// Create a TestSystem
class MouseSystem extends System {
init() {
var mouseState = this.world.components.mouseState;
window.addEventListener('mousedown', () => {
mouseState.mouseDown = true;
});
window.addEventListener('mouseup', () => {
mouseState.mouseDown = false;
});
}
}
// Create a reactive system
class ReactiveSystem extends System {
init() {
return {
entities: [Transform]
};
}
onEntitiesAdded(entities) {
console.log('OnAdded', this.queries.entities.added);
}
onEntitiesRemoved(entities) {
console.log('OnRemoved', this.queries.entities.removed);
}
onEntitiesChanged(entities) {
console.log('OnChanged entities', this.queries.entities.changed);
}
onComponentChanged(entities, component) {
console.log('OnChanged components', entities, component);
}
}
// Create a world and register all the elements on it
var world = new World();
world
.registerComponent(Rotating)
.registerComponent(Transform)
.registerSingletonComponent(MouseState);
world
.registerSystem(RotatingSystem)
.registerSystem(MouseSystem);
var entity = world.createEntity();
entity
.addComponent(Rotating, {rotationSpeed: 0.2})
.addComponent(Transform);
// Update systems per frame
var previousTime = performance.now();
function update() {
var time = performance.now();
var delta = time - previousTime;
previousTime = time;
world.execute(delta, time);
requestAnimationFrame(update);
}
requestAnimationFrame(update);
FAQs
Entity Component System in JS
The npm package ecsy receives a total of 189 weekly downloads. As such, ecsy popularity was classified as not popular.
We found that ecsy demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 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.
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.