
Research
/Security News
Weaponizing Discord for Command and Control Across npm, PyPI, and RubyGems.org
Socket researchers uncover how threat actors weaponize Discord across the npm, PyPI, and RubyGems ecosystems to exfiltrate sensitive data.
Minimalistic and cute Service Provider for server environment (node.js, bun) and for clients (browser, native).
The service provider pattern - also called service locator pattern.
Advantages over Dependency Injection:
node.js or bun usage
import { provide } from "provi/server"
class Db { /* ... */ }
// Define dependencies using "provide" function
export class App {
db = provide(Db)
// ...
start() {
this.db.init()
// ...
}
}
browser or native usage
import { provide } from "provi/client"
// Define dependencies using "provide" function
class Auth {
// user = sharedUser()
// ...
logout() {
if (sharedUser().isAnonymous) return
// ...
}
}
export const sharedAuth = () => provide(Auth)
in both ways you can use plain javascript functions as dependency constructor
import { provide } from "provi/client"
const User = () => {
// ...
return {
get isAnonymous() {
return true;
}
}
}
export const sharedUser = () => provide(User)
Isolation of async scopes (only in node environment)
Run your app in isolated Service Provider scope. All instances cached for this will be isolated from all cached instances in other scopes. Useful for implementing SSR.
import { isolate } from "provi/ssr"
const html = await isolate(async () => {
const { run } = provide(Logic); // Isolated instance of app logic
await run();
// ...
return ReactDOMServer.renderToString(<App />);
});
Each isolated instance will be destroyed at the end of the isolated asynchronous function.
Installation
npm install provi
Enjoy your code!
FAQs
Minimalistic and cute Service Provider
We found that provi 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
/Security News
Socket researchers uncover how threat actors weaponize Discord across the npm, PyPI, and RubyGems ecosystems to exfiltrate sensitive data.
Security News
Socket now integrates with Bun 1.3’s Security Scanner API to block risky packages at install time and enforce your organization’s policies in local dev and CI.
Research
The Socket Threat Research Team is tracking weekly intrusions into the npm registry that follow a repeatable adversarial playbook used by North Korean state-sponsored actors.