Socket
Socket
Sign inDemoInstall

@adaptive-recognition/vehicle-detector-agent-webhook-middleware

Package Overview
Dependencies
4
Maintainers
3
Versions
2
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @adaptive-recognition/vehicle-detector-agent-webhook-middleware

Express middleware for parsing Vehicle Detector Agent webhook requests and verifying their signature.


Version published
Maintainers
3
Created

Readme

Source

Vehicle Detector Agent Webhook Middleware

Express middleware for parsing Vehicle Detector Agent webhook requests and verifying their signature.

How to Install

npm install --save @arcloud/vehicle-detector-agent-webhook-middleware

Usage

TypeScript

import express, { Express, Request, Response } from 'express';
import { WebhookEvent, webhookSignatureValidator } from "@arcloud/vehicle-detector-agent-webhook-middleware";

const app: Express = express();
const port = 8080;

const signatureValidator = webhookSignatureValidator({
  algorithm: "RS256",
  publicKeyPath: "/path/to/RS256.public.pem"
});

app.get('/', (req: Request, res: Response) => {
  res.send('OK');
});

// This endpoint uses the middleware - requests with an invalid signature 
// will be rejected.
app.post('/webhook', signatureValidator, (req: Request, res: Response) => {
  const event: WebhookEvent = req.body; // req.body contains the parsed event
  console.log("Detected At: ", event.detectedAt);
  console.log("Unicode Text:", event.event.plate.unicodeText);
  res.send('OK');
});

app.listen(port, () => {
  console.log(`⚡️[server]: Server is running at https://localhost:${port}`);
});

JavaScript

const express = require("express");
const { webhookSignatureValidator } = require("@arcloud/vehicle-detector-agent-webhook-middleware");

const app = express();
const port = 8080;

const signatureValidator = webhookSignatureValidator({
  algorithm: "RS256",
  publicKeyPath: "/path/to/RS256.public.pem"
});

// This endpoint uses the middleware - requests with an invalid signature 
// will be rejected.
app.post('/webhook', signatureValidator, (req, res) => {
  const event = req.body; // req.body contains the parsed event
  console.log("Detected At: ", event.detectedAt);
  console.log("Unicode Text:", event.event.plate.unicodeText);
  res.send('OK');
});

app.listen(port, () => {
  console.log(`⚡️[server]: Server is running at https://localhost:${port}`);
});

Keywords

FAQs

Last updated on 27 Feb 2023

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc