
Security Fundamentals
Turtles, Clams, and Cyber Threat Actors: Shell Usage
The Socket Threat Research Team uncovers how threat actors weaponize shell techniques across npm, PyPI, and Go ecosystems to maintain persistence and exfiltrate data.
inversify-token
Advanced tools
Source: https://github.com/mscharley/inversify-token
Author: Matthew Scharley
Contributors: See contributors on GitHub
Bugs/Support: Github Issues
Copyright: 2021
License: MIT license
Status: Active
This library provides simpler, more type-safe options for injecting values using Inversify.
$ npm i inversify-token
Modified from the InversifyJS readme.
// Declare your interfaces as normal.
// file types.ts
import { Token, TokenType } from "inversify-token";
import { Warrior, Weapon, ThrowableWeapon } from "./interfaces";
const WarriorToken = new Token<Warrior>(Symbol.for("Warrior"));
type WarriorToken = TokenType<typeof WarriorToken>;
const WeaponToken = new Token<Weapon>(Symbol.for("Weapon"));
type WeaponToken = TokenType<typeof WeaponToken>;
const ThrowableWeaponToken = new Token<ThrowableWeapon>(
Symbol.for("ThrowableWeapon")
);
type ThrowableWeaponToken = TokenType<typeof ThrowableWeaponToken>;
export {
WarriorToken as Warrior,
WeaponToken as Weapon,
ThrowableWeaponToken as ThrowableWeapon,
};
// file entities.ts
import { injectable } from "inversify";
import { injectToken } from "inversify-token";
import * as TYPES from "./types";
@injectable()
class Ninja implements Warrior {
public constructor(
@injectToken(TYPES.Weapon) private _katana: TYPES.Weapon,
@injectToken(TYPES.ThrowableWeapon) private _shuriken: TYPES.ThrowableWeapon
) {}
public fight() {
return this._katana.hit();
}
public sneak() {
return this._shuriken.throw();
}
}
// file inversify.config.ts
import { getToken, tokenBinder } from "inversify-token";
const myContainer = new Container();
const bindToken = tokenBinder(myContainer.bind.bind(myContainer));
bindToken(TYPES.Warrior).to(Ninja);
bindToken(TYPES.Weapon).to(Katana);
bindToken(TYPES.ThrowableWeapon).to(Shuriken);
const warrior = getToken(container, TYPES.Warrior);
// file inversify.module.ts
import { getToken, TokenContainerModule } from "inversify-token";
const myContainer = new Container();
const module = new TokenContainerModule((bindToken) => {
bindToken(TYPES.Warrior).to(Ninja);
bindToken(TYPES.Weapon).to(Katana);
bindToken(TYPES.ThrowableWeapon).to(Shuriken);
});
myContainer.load(module);
const warrior = getToken(container, TYPES.Warrior);
FAQs
Token-based injection for InversifyJS
The npm package inversify-token receives a total of 330 weekly downloads. As such, inversify-token popularity was classified as not popular.
We found that inversify-token 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 Fundamentals
The Socket Threat Research Team uncovers how threat actors weaponize shell techniques across npm, PyPI, and Go ecosystems to maintain persistence and exfiltrate data.
Security News
At VulnCon 2025, NIST scrapped its NVD consortium plans, admitted it can't keep up with CVEs, and outlined automation efforts amid a mounting backlog.
Product
We redesigned our GitHub PR comments to deliver clear, actionable security insights without adding noise to your workflow.