@biojoule/onfleet-webhook-lambda-handler
v0.1.2
Published
Simple wrapper to perform onfleet webhook validation and authentication in AWS Lambda
Downloads
19
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-handler
Usage
JavaScript
const { webhookHandler } = require("@biojoule/onfleet-webhook-lambda-handler");
const secret = process.env.ONFLEET_WEBHOOK_SECRET
exports.handler = webhookHandler(
secret,
async (event, ctx) => {
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, ctx) => {
return {
statusCode: 200,
body: "Hello, Onfleet!"
}
}
)
Contributors
Version History
- 0.1.2
- Moved
@types/aws-lambda
to thedependencies
as 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.