
Research
Two Malicious Rust Crates Impersonate Popular Logger to Steal Wallet Keys
Socket uncovers malicious Rust crates impersonating fast_log to steal Solana and Ethereum wallet keys from source code.
@iipekolict/wormhole
Advanced tools
Library for handle backend state between middlewares in Express / Express-based frameworks
TypeScript library for handle backend state between middlewares in Express / Express-based frameworks using Request object
npm install @iipekolict/wormhole
Configuring dynamic wormhole based on initial state object (highly recommended)
import { WormholeService, DynamicWormholeClass } from '@iipekolict/wormhole';
type State = {
todos: object[];
posts: object[];
missing?: boolean;
};
// initial state object
const state: State = {
todos: [],
posts: [],
};
// create dynamic wormhole class with utility methods based on initial state object
const Wormhole: DynamicWormholeClass<State> = WormholeService.create(state);
Then use it inside middlewares and endpoints for set / get state fields
import { WormholeService, DynamicWormhole, DynamicWormholeClass } from '@iipekolict/wormhole';
import express, { Request, Response, NextFunction } from 'express';
import { fetchTodos } from 'project'
// ...previous example
const app = express();
app.use(async (request: Request, response: Response, next: NextFunction) => {
const wormhole: DynamicWormhole<State> = new Wormhole(request);
const todos: object[] = await fetchTodos();
wormhole.set({ todos }); // set todos field in backend state
wormhole.setTodos(todos); // same as previous, method generates dynamically based on initial state object
next();
});
app.use(async (request: Request, response: Response, next: NextFunction) => {
const wormhole: DynamicWormhole<State> = new Wormhole(request);
console.log(wormhole.get('todos')); // [...todos]
console.log(wormhole.getTodos()); // [...todos]
console.log(wormhole.get('posts')); // []
console.log(wormhole.getPosts()); // []
next();
});
app.get('/', async (request: Request, response: Response, next: NextFunction) => {
// wormhole factory, same as new Wormhole()
const wormhole: DynamicWormhole<State> = WormholeService.getInstance<State>(request);
console.log(wormhole.get('missing')); // undefined
response.json({ todos: wormhole.getTodos() });
});
app.listen(5000);
Creating custom setter
const wormhole: DynamicWormhole<State> = new Wormhole(request);
const setter = wormhole.createSetter((state: State, todo: object) => {
return { todos: [...state.todos, todo] };
});
setter({ text: 'some text' });
Creating custom spread setter
const wormhole: DynamicWormhole<State> = new Wormhole(request);
const spreadSetter = wormhole.createSpreadSetter((state: State, ...posts: Post[]) => {
return { posts: [...state.posts, ...posts] };
});
spreadSetter({ text: 'some text' }, { text: 'another text' });
FAQs
Library for handle backend state between middlewares in Express / Express-based frameworks
We found that @iipekolict/wormhole 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
Socket uncovers malicious Rust crates impersonating fast_log to steal Solana and Ethereum wallet keys from source code.
Research
A malicious package uses a QR code as steganography in an innovative technique.
Research
/Security News
Socket identified 80 fake candidates targeting engineering roles, including suspected North Korean operators, exposing the new reality of hiring as a security function.