
Security News
/Research
npm Phishing Email Targets Developers with Typosquatted Domain
A phishing attack targeted developers using a typosquatted npm domain (npnjs.com) to steal credentials via fake login pages - watch out for similar scams.
lambda-websocket
Advanced tools
npm install lambda-websocket
or
yarn add lambda-websocket
To create a lambda-websocket, import the library and create a new instance of the LambdaWebSocket. Add event listener methods as you wish and then call createHandler
to export the result as your lambdas handler.
import LambdaWebSocket from 'lambda-websocket';
const lambdaSocket = new LambdaWebSocket();
lambdaSocket.on('connect', async (context) => {
console.log('Client requested connection', context);
const { headers } = context;
// basic authorization header check
if (!headers.Authorization) {
return {
statusCode: "401"
}
}
});
lambdaSocket.on('message', async ({ send, message }) => {
console.log('Client sent message', message);
// send message to client
await send({ message: 'hello' })
// The lambda will automatically return a 200,
// but to override that return a response here.
// We will pretend that in this response we have created
// something.
return {
statusCode: "201",
};
});
lambdaSocket.on('close', async (context) => {
console.log('Client went away');
});
export default lambdaSocket.createHandler();
Event | Params | Description |
---|---|---|
connect | Context | Client is requesting a connection |
close | Context | Client was disconnected or requested a close |
message | Context | Normal client communication |
Name | Type | Defaults | Description |
---|---|---|---|
headers | Object | {} | The headers passed from the client |
message | Object | {} | The message sent from the client, will try to auto-parse JSON |
connectionID | String | The ID needed to connect to ApiGatewayManagementApi | |
endpoint | String | constructed | The endpoint needed to connect to ApiGatewayManagementApi |
domain | String | ||
stage | String | ||
type | String | Api Gateway eventType: DISCONNECTED, CONNECTED, MESSAGE | |
send | Function | Send messages to the client. Non-Buffer items will be stringified |
This library should be used in conjunction with the library serverless-websockets-plugin with a full example project here. It is not a complete websocket implementation and relies on the plugin to handle the API Gateway configuration.
FAQs
An API Gateway Lambda wrapper that mimics server websockets
The npm package lambda-websocket receives a total of 4 weekly downloads. As such, lambda-websocket popularity was classified as not popular.
We found that lambda-websocket 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 News
/Research
A phishing attack targeted developers using a typosquatted npm domain (npnjs.com) to steal credentials via fake login pages - watch out for similar scams.
Security News
Knip hits 500 releases with v5.62.0, refining TypeScript config detection and updating plugins as monthly npm downloads approach 12M.
Security News
The EU Cyber Resilience Act is prompting compliance requests that open source maintainers may not be obligated or equipped to handle.