express-meshblu-auth is an Express.js middleware library designed to handle all authentication styles for the Meshblu IoT platform. It simplifies the process of integrating Meshblu device authentication into Express applications by supporting various methods including cookies (meshblu_auth_uuid, meshblu_auth_token), HTTP headers (using the same cookie names), Basic authentication, and Bearer tokens. The library provides middleware functions like `auth()`, `get()`, `gateway()`, `gatewayDevice()`, and `gatewayRedirect()` to retrieve, validate, and attach Meshblu credentials and device information to the request object, or enforce access control. The current stable version is 9.2.1. While there isn't a strict release cadence, the project has seen several updates within major version 9 and a jump from v8 to v9, indicating active maintenance. Its primary differentiation lies in its specific integration with the Meshblu ecosystem, offering out-of-the-box support for its authentication paradigms.
npm install express-meshblu-authVerified import paths — ran on the pinned version, not inferred.
Demonstrates how to initialize the MeshbluAuth middleware and apply its core authentication (`auth()`), device retrieval (`get()`), and access control (`gateway()`, `gatewayDevice()`, `gatewayRedirect()`) functions to an Express application. It showcases how to access authenticated Meshblu UUID and token from the request object.
Review your configuration for `patchGlobal` and refactor to remove its usage, as it's no longer supported.
Ensure that `app.use(meshbluAuth.auth())` or `app.use(meshbluAuth.get())` appears before any `gateway()` or `gatewayDevice()` calls in your Express middleware setup.
Thoroughly test your application when upgrading to v8.0.0 or higher. Consult the `meshblu-http` package's release notes for potential breaking changes relevant to its API.
Verify that `meshbluAuth.auth()` or `meshbluAuth.get()` is correctly placed and executed in the Express middleware chain prior to any code attempting to access `request.meshbluAuth`.
For ESM, use `import MeshbluAuth from 'express-meshblu-auth';`. For CommonJS, use `const MeshbluAuth = require('express-meshblu-auth');`.Ensure `meshbluAuth.gatewayDevice()` is called with a valid string representing the UUID, e.g., `app.use(meshbluAuth.gatewayDevice('your-device-uuid'));`