
Research
Malicious npm Packages Impersonate Flashbots SDKs, Targeting Ethereum Wallet Credentials
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
Auto dependency injector for typescript.
This is a proof of concept project, it may not be stable.
$ npm install autoinject
import {autoInject, dependencyInjection} from 'autoinject';
class User {
test = 'It works fine';
}
@autoInject
class Db {
user: User;
constructor(user: User) {
this.user = user;
}
}
@autoInject
class MyClass {
db: Db;
constructor(db: Db) {
this.db = db;
}
}
const myClass = dependencyInjection(MyClass);
console.log(myClass.db.user.test);
All dependencies are stored on a static prototype on the target object.
import {autoInject} from 'autoinject';
import {Db} from 'db';
@autoInject
class Controller {
constructor(db: Db) {}
}
console.log(Controller.inject); // [ Db ]
You can also auto instantiate a class
import {autoInject, autoInstantiate} from 'autoinject';
class User {
test = 'It works fine';
}
@autoInjecte
class Db {
constructor(public user: User) {}
}
@autoInstantiate
class MyClass {
constructor(public db?: Db) {}
}
var k = new MyClass();
console.log(k.db.user.test); // output: "It works fine"
You can always override the inject (for testing purpose)
// http.ts
class Http {
get(url: string) {
// some logic
}
}
export {Http};
// image-repository.ts
import {autoInject} from 'autoinject';
import {Http} from './http';
@autoInjecte
class ImageRepository {
http: Http;
constructor(http: Http) {
this.http = http;
}
getImage() {
return this.http.get('/image');
}
}
export {ImageRepository};
// test.ts
import {dependencyInjection} from 'autoinject';
import {ImageRepository} from './image-repository';
const httpMock = {
get() {
return 'Nice';
}
};
ImageRepository.inject = [httpMock];
const imageRepository = dependencyInjection(ImageRepository);
console.assert(imageRepository.getImage(), 'Nice');
Include the typing with:
"moduleResolution": "node"
in your tsconfig.json
FAQs
Autoinject classes
The npm package autoinject receives a total of 2 weekly downloads. As such, autoinject popularity was classified as not popular.
We found that autoinject 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.
Research
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
Security News
Ruby maintainers from Bundler and rbenv teams are building rv to bring Python uv's speed and unified tooling approach to Ruby development.
Security News
Following last week’s supply chain attack, Nx published findings on the GitHub Actions exploit and moved npm publishing to Trusted Publishers.