Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
@castore/event-bridge-message-bus-adapter
Advanced tools
DRY Castore MessageBus definition using AWS EventBridge
DRY Castore MessageBus
definition using AWS EventBridge.
# npm
npm install @castore/event-bridge-message-bus-adapter
# yarn
yarn add @castore/event-bridge-message-bus-adapter
This package has @castore/core
and @aws-sdk/client-eventbridge
(above v3) as peer dependencies, so you will have to install them as well:
# npm
npm install @castore/core @aws-sdk/client-eventbridge
# yarn
yarn add @castore/core @aws-sdk/client-eventbridge
import { EventBridgeClient } from '@aws-sdk/client-eventbridge';
import { EventBridgeMessageBusAdapter } from '@castore/event-bridge-message-bus-adapter';
const eventBridgeClient = new EventBridgeClient({});
const messageBusAdapter = new EventBridgeMessageBusAdapter({
eventBusName: 'my-event-bus-name',
eventBridgeClient,
});
// 👇 Alternatively, provide a getter
const messageBusAdapter = new EventBridgeMessageBusAdapter({
eventBusName: () => process.env.MY_EVENT_BUS_NAME,
eventBridgeClient,
});
const appMessageBus = new NotificationMessageBus({
...
messageBusAdapter
})
This will directly plug your MessageBus to EventBridge 🙌
When publishing a message, its eventStoreId
is used as the message source
and its event type
is used as detail-type
(except for AggregateExistsMessageBus
for which a constant is used). The whole message is passed to the detail
property.
// 👇 Aggregate exists
{
"source": "POKEMONS", // <= eventStoreId
"detail-type": "__AGGREGATE_EXISTS__", // <= constant
"detail": {
"eventStoreId": "POKEMONS",
"aggregateId": "123",
},
... // <= Other technical EventBridge properties
}
// 👇 Notification
{
"source": "POKEMONS",
"detail-type": "POKEMON_APPEARED", // <= event type
"detail": {
"eventStoreId": "POKEMONS",
"event": {
"aggregateId": "123",
"version": 1,
"type": "POKEMON_APPEARED",
"timestamp": ...
...
},
},
...
}
// 👇 State-carrying
{
"source": "POKEMONS",
"detail-type": "POKEMON_APPEARED",
"detail": {
"eventStoreId": "POKEMONS",
"event": {
"aggregateId": "123",
...
},
"aggregate": { ... } // <= aggregate
},
...
}
If the replay
option is set to true
when publishing a notification or state-carrying message, the "detail-type"
will be set to "__REPLAYED__"
. This makes sure that any subscription to replayed events is opt-in:
// 👇 Replayed notification message
{
"source": "POKEMONS",
"detail-type": "__REPLAYED__",
"detail": {
"eventStoreId": "POKEMONS",
"event": {
"aggregateId": "123",
"type": "POKEMON_APPEARED", // <= event type still available
...
},
},
...
}
On the listeners side, you can use the EventBridgeMessageBusMessage
TS type to type your argument:
import type { EventBridgeMessageBusMessage } from '@castore/event-bridge-message-bus-adapter';
const listener = async (
message: EventBridgeMessageBusMessage<typeof appMessageBus>,
) => {
// 🙌 Correctly typed!
const { eventStoreId, event } = message.detail;
};
You can provide event store ids and event types if you listener only listens to specific event types:
import type { EventBridgeMessageBusMessage } from '@castore/event-bridge-message-bus-adapter';
const listener = async (
message: EventBridgeMessageBusMessage<
typeof appMessageBus,
'POKEMONS', // <= Only listen to the 'POKEMONS' event store events (optional)
'POKEMON_APPEARED' // <= Only listen to 'POKEMON_APPEARED' events (optional)
>,
) => {
// 🙌 Correctly typed!
const { eventStoreId, event } = message.detail;
};
The publishMessage
method requires the events:PutEvents
IAM permission on the provided event bus.
FAQs
DRY Castore MessageBus definition using AWS EventBridge
The npm package @castore/event-bridge-message-bus-adapter receives a total of 195 weekly downloads. As such, @castore/event-bridge-message-bus-adapter popularity was classified as not popular.
We found that @castore/event-bridge-message-bus-adapter demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 4 open source maintainers 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
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.