
Security News
Crates.io Users Targeted by Phishing Emails
The Rust Security Response WG is warning of phishing emails from rustfoundation.dev targeting crates.io users.
@nexus-navigators/lambda-http-interceptor
Advanced tools
A Node.js http interceptor to invoke Lambda functions
Intercept HTTP calls that are intended to hit a Lambda that resolves API Gateway requests. Use cases include unit tests, integration tests, or connecting directly to a Lambda while bypassing API Gateway.
npm i --save @nexus-navigators/lambda-http-interceptor
import { enable, clear, registerIntercept } from '@nexus-navigators/lambda-http-interceptor'
const handler = (event: APIGatewayProxyEventV2) => {
console.log(event)
return {
status: 200,
body: { out: 'OK' },
}
}
enable()
registerIntercept({
eventType: 'apiGatewayProxyV1',
listenerType: 'handler',
eventHandler: handler,
hostMatch: /.*lambda-function\.com.*/,
eventParams: {
binaryTypes: [],
},
contextParams: {
functionName: 'testFunction',
timeout: 1,
}
})
const response = await fetch('https://lambda-function.com/test')
assert.equal(response.status, 200)
const json = await response.json()
assert.equal(json.out, 'OK')
Option | Description |
---|---|
eventType | The type of event to be sent to the Lambda function. Can be apiGatewayProxyV1 or apiGatewayProxyV2 . |
listenerType | The type of listener to be used for invoking the Lambda function. Can be handler or sdk . |
eventHandler | When listenerType is handler then a Lambda handler function must be provided |
hostMatch | A string or RegExp used to match hosts for requests. Can be blank if all HTTP requests should be sent to the function. |
eventParams | An object containing API Gateway parameters to be passed to the Lambda function. |
contextParams | An object containing Lambda context parameters to be passed to the Lambda function. Required when setting listenerType to handler |
Parameter | Description |
---|---|
binaryTypes | An array of binary types to be passed to the Lambda function. The interceptor will convert these kinds of requests to base64 and set the APIGateway event flag |
authorizer (optional) | Any authorization parameters that the API Gateway would have added to the event |
pathParameters (optional) | Any path parameters that the API Gateway would have added to the event |
stageVariables (optional) | Any query stage variables that the API Gateway would have added to the event |
resource (optional) | The resource value API gateway would have added to the event |
Context parameters are only used when listenerType
is handler
. These help fill out the context
parameter when executing the handler.
Parameter | Description |
---|---|
functionName (required) | The name of the Lambda function. |
timeout (optional) | The timeout for the Lambda function. |
awsRequestId (optional) | A requestID that is typically a UUID. |
memoryLimitInMB (optional) | The memory size for the Lambda function. |
functionVersion (optional) | The version of the Lambda function. |
logStreamName (optional) | A log stream name for CloudWatch Logs. |
invokedFunctionArn (optional) | The ARN for the function |
clientContext (optional) | Any clientContext that would be sent, matches ClientContext . |
identity (optional) | A CognitoIdentity object that would be set by Lambda. |
FAQs
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
The Rust Security Response WG is warning of phishing emails from rustfoundation.dev targeting crates.io users.
Product
Socket now lets you customize pull request alert headers, helping security teams share clear guidance right in PRs to speed reviews and reduce back-and-forth.
Product
Socket's Rust support is moving to Beta: all users can scan Cargo projects and generate SBOMs, including Cargo.toml-only crates, with Rust-aware supply chain checks.