
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
@brika/events
Advanced tools
A fully typed event system with Zod schemas and declarative actions.
once, waitFor, and raceplugin.*) and custom matchersbun add @brika/events
import { z } from 'zod';
import { defineActions, type ActionsUnion } from '@brika/events';
// Define actions with Zod schemas
export const PluginActions = defineActions('plugin', {
loaded: z.object({
uid: z.string(),
name: z.string(),
version: z.string(),
pid: z.number().optional(),
}),
unloaded: z.object({
uid: z.string(),
name: z.string(),
}),
error: z.object({
uid: z.string(),
error: z.string(),
}),
});
// Type union auto-generated - zero boilerplate!
export type PluginAction = ActionsUnion<typeof PluginActions>;
import { EventSystem } from '@brika/events';
const events = new EventSystem();
// Dispatch with automatic validation
events.dispatch(PluginActions.loaded.create({
uid: 'abc123',
name: '@brika/plugin-timer',
version: '1.0.0',
pid: 12345,
}, 'hub'));
// Subscribe with pattern matching
events.subscribe('plugin.*', (action: PluginAction) => {
if (action.type === 'plugin.loaded') {
// TypeScript knows the payload type
console.log(action.payload.uid);
}
});
// Subscribe with custom matcher
events.subscribe((action) => action.type.startsWith('plugin.'), handler);
// Wait for a single action
const action = await events.once('plugin.loaded', { timeout: 5000 });
// Wait with predicate
const action = await events.waitFor(
'plugin.*',
(action) => action.payload.uid === 'specific-uid',
{ timeout: 10000 }
);
// Race - wait for first matching action
const action = await events.race(
['plugin.loaded', 'plugin.error'],
{ timeout: 5000 }
);
defineActions(namespace, actions)Defines a namespace of actions with Zod schemas.
Parameters:
namespace: String namespace (e.g., 'plugin')actions: Record of action names to Zod schemasReturns: Object with action creators and schemas
ActionsUnion<T>Type helper to extract union of all actions from a namespace.
EventSystemMain event system class.
Methods:
dispatch(action): Dispatch an action to all subscriberssubscribe(pattern, handler): Subscribe to actions matching patternonce(pattern, options?): Wait for a single action (Promise)waitFor(pattern, predicate, options?): Wait for action matching predicate (Promise)race(patterns, options?): Wait for first matching action (Promise)clear(): Clear all subscriptions and pending promises'plugin.loaded' - Exact match'plugin.*' - All plugin actions'*.loaded' - All actions ending with .loadedRegExp - Custom regex pattern(action) => boolean - Custom function matcherSee src/__tests__/example.test.ts for complete examples.
FAQs
Unknown package
We found that @brika/events demonstrated a healthy version release cadence and project activity because the last version was released less than 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
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.