JSPM

@lovable.dev/webhooks-js

0.0.1
    • ESM via JSPM
    • ES Module Entrypoint
    • Export Map
    • Keywords
    • License
    • Repository URL
    • TypeScript Types
    • README
    • Created
    • Published
    • Downloads 45654
    • Score
      100M100P100Q160847F
    • License MIT

    Lovable Webhooks JS

    Package Exports

    • @lovable.dev/webhooks-js
    • @lovable.dev/webhooks-js/dist/index.cjs
    • @lovable.dev/webhooks-js/dist/index.js

    This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@lovable.dev/webhooks-js) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

    Readme

    @lovable.dev/webhooks-js

    Webhook signature utilities for Lovable integrations.

    Installation

    npm install @lovable.dev/webhooks-js

    Usage

    import {
      verifyWebhookRequest,
      verifyWebhookSignature,
      type EmailWebhookPayload,
    } from "@lovable.dev/webhooks-js";
    
    const body = await req.text();
    const signature = req.headers.get("x-lovable-signature");
    const timestamp = req.headers.get("x-lovable-timestamp") ?? "";
    const isValid = await verifyWebhookSignature({
      signedPayload: `${timestamp}.${body}`,
      signature,
      secret: Deno.env.get("LOVABLE_API_KEY") ?? "",
    });
    
    if (!isValid) {
      throw new Error("Invalid signature");
    }
    
    // Or verify the request and parse JSON in one step
    const { payload } = await verifyWebhookRequest<EmailWebhookPayload>({
      req,
      secret: Deno.env.get("LOVABLE_API_KEY") ?? "",
    });
    
    // Or pass a custom parser
    const { payload: rawPayload } = await verifyWebhookRequest({
      req,
      secret: Deno.env.get("LOVABLE_API_KEY") ?? "",
      parser: (body) => ({ raw: body }),
    });