@biojoule/onfleet-webhook-lambda-handler
v0.2.0
Published
Simple wrapper to perform onfleet webhook validation and authentication in AWS Lambda
Readme
onfleet-webhook-lambda-handler
A helpful wrapper for AWS Lambda functions called by Onfleet webhooks, providing transparent webhook verification and signature authentication.
Description
Onfleet validation
This handler will respond to GET validation requests with:
{
statusCode: 200,
body: event.queryStringParameters?.check,
}Signature verification
It will verify the integrity of POST requests using the event.headers["x-onfleet-signature"] and your Onfleet API secret.
Getting Started
Installing
# npm (one of the below, depending on your package manager)
npx jsr add @biojoule/onfleet-webhook-lambda-handler
yarn dlx jsr add @biojoule/onfleet-webhook-lambda-handler
pnpm dlx jsr add @biojoule/onfleet-webhook-lambda-handler
bunx jsr add @biojoule/onfleet-webhook-lambda-handler
# deno
deno add @biojoule/onfleet-webhook-lambda-handlerUsage
JavaScript
The inner handler uses the modern AWS Lambda async signature (event, context) => Promise<result> (arity of 2). The legacy callback argument is no longer supported.
JavaScript
const { webhookHandler } = require("@biojoule/onfleet-webhook-lambda-handler");
const secret = process.env.ONFLEET_WEBHOOK_SECRET
exports.handler = webhookHandler(
secret,
async (event, context) => {
return {
statusCode: 200,
body: "Hello, Onfleet!"
}
}
)TypeScript
import { webhookHandler } from "@biojoule/onfleet-webhook-lambda-handler";
const secret = process.env.ONFLEET_WEBHOOK_SECRET
export const handler = webhookHandler(
secret,
async (event, context) => {
return {
statusCode: 200,
body: "Hello, Onfleet!"
}
}
)Runtime support
Requires Node.js 22 or newer (AWS Lambda nodejs22.x and nodejs24.x runtimes).
Contributors
Version History
- 0.2.0
- Breaking: inner handler signature changed to 2-arity
(event, context) => Promise<result>— the legacycallbackargument is no longer passed. - Exported a new
OnfleetWebhookHandlertype. - Require Node.js 22+ (supports AWS Lambda
nodejs22.xandnodejs24.xruntimes). - Bumped
@types/nodeto 22.x.
- Breaking: inner handler signature changed to 2-arity
- 0.1.4
- Update dependencies.
- 0.1.3
- Pinned dependencies to safe and cooled down versions.
- 0.1.2
- Moved
@types/aws-lambdato thedependenciesas per the installation instructions.
- Moved
- 0.1.0
- Migration to TypeScript.
- Addition of unit tests.
- Publication to JSR.
- 0.0.3
- Minor fix.
- 0.0.2
- Addition of the Onfleet API secret as a parameter.
- 0.0.1
- Initial Release.
License
This project is licensed under the MIT License - see the LICENSE.txt file for details.
