
Security News
/Research
Wallet-Draining npm Package Impersonates Nodemailer to Hijack Crypto Transactions
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
threejs-imageloader-mock
Advanced tools
Enables to mock/intercept image downloading with THREE.ImageLoader
on node/mocha.
It enables to:
THREE.ImageLoader
and its related components as THREE.TextureLoader
etc, injecting mock class instead of image object.Since THREE.ImageLoader
makes use of lazy loading feature of <img>
tag, in other words since it does not depend on XMLHttpRequest
, its loading cannot be intercepted by usual tools like nock. This module enables to intercept image downloading by overriding document.createElementNS()
.
Requires node.
npm i -D threejs-imageloader-mock
First require the module, then call success()
or fail()
method (usually in before
clause).
const THREE = require('three');
const imgMock = require('threejs-imageloader-mock');
const assert = require('assert');
describe('App test', () => {
it('Can mock image loading', ( done ) => {
imgMock.success();
const onLoad = ( texture ) => {
console.log(texture); // Prints Mock object
assert.equal(texture.src, 'http://0.0.0.0/foo/bar');
assert.equal(texture.constructor.name, 'ImageElementMock');
done();
};
// Without mock, this line results timeout.
new THREE.ImageLoader().load('http://0.0.0.0/foo/bar', onLoad);
});
it('Can intercept with error', ( done ) => {
imgMock.fail();
const onLoad = () => {
assert.fail();
};
const onError = ( error ) => {
console.log(error); // THREE.ImageLoader will call onError callback.
done();
};
// You must specify onError callback.
new THREE.ImageLoader().load('http://0.0.0.0/foo/bar', onLoad, null, onError);
});
});
After "successful" loading, ImageElementMock
object in THREE.Texture.map
property, replacing <img>
element.
ImageElementMock {
trigger: 'load', // please ignore this property
crossOrigin: 'anonymous',
src: 'http://0.0.0.0/foo/bar'
}
src
and crossOrigin
property will be added by THREE.ImageLoader.load()
method, which can be made use of test.
This module does not ensure valid function of your WebGL program. Please make sure that it can cause some problems.
MIT
FAQs
Mocking THREE.ImageLoader (WIP)
The npm package threejs-imageloader-mock receives a total of 0 weekly downloads. As such, threejs-imageloader-mock popularity was classified as not popular.
We found that threejs-imageloader-mock 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
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
Security News
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.
Security News
/Research
Malicious Nx npm versions stole secrets and wallet info using AI CLI tools; Socket’s AI scanner detected the supply chain attack and flagged the malware.