Skip to content

Repository files navigation

onfleet-webhook-lambda-handler

Contributors Forks Stargazers Issues MIT License

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

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 legacy callback argument is no longer passed.
    • Exported a new OnfleetWebhookHandler type.
    • Require Node.js 22+ (supports AWS Lambda nodejs22.x and nodejs24.x runtimes).
    • Bumped @types/node to 22.x.
  • 0.1.4
    • Update dependencies.
  • 0.1.3
    • Pinned dependencies to safe and cooled down versions.
  • 0.1.2
  • 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.

Acknowledgments

Onfleet node SDK

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages