JSPM

dsa-middleware-bb

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

CommonJs + TypeScript SDK for Data Security Agent Middleware.

Package Exports

  • dsa-middleware-bb
  • dsa-middleware-bb/dist/cjs/index.js
  • dsa-middleware-bb/dist/esm/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 (dsa-middleware-bb) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

🧩 DSA Middleware BB

npm version npm downloads license GitHub issues GitHub stars

A lightweight and secure middleware for integrating Data Security Agent (DSA) capabilities into your Node.js or NestJS applications.

DSA (Data Security Agent) is a lightweight, plug-and-play middleware designed to automatically protect sensitive data in your API responses and files before they leave your server.

It intelligently scans and masks sensitive information such as emails, phone numbers, credit card details, and personal identifiers based on your configured agent rules β€” ensuring data privacy and compliance without changing your application logic.

πŸ”’ Key Features

  • 🧩 Universal Middleware β€” works with Express, NestJS, and other Node.js frameworks.
  • βš™οΈ Plug-and-Play Setup β€” integrate in seconds with a single app.use() call.
  • 🧠 Smart Detection Engine β€” masks sensitive information dynamically before sending a response.
  • πŸ“„ Supports Multiple Formats β€” compatible with JSON, XML, and even DOCX files.
  • 🧾 Custom Rules β€” define your own masking logic per agent/account for flexible security policies.

🧰 Use Cases

  • βœ… Mask personal data (email, phone, card numbers) before returning API responses.
  • βœ… Sanitize downloadable files like .docx or .xml automatically.
  • βœ… Enforce organization-wide data security rules centrally.

🧱 How It Works

  • The middleware intercepts every HTTP response before it’s sent to the client.
  • It scans response bodies or file buffers for sensitive data patterns.
  • Matches are masked or replaced according to your DSA agent configuration.
  • The cleaned, privacy-safe data is then delivered to the end user.

πŸš€ Installation

npm install dsa-middleware-bb
# or
yarn add dsa-middleware-bb

βš™οΈ Usage in Node.js (CommonJS)

const express = require("express");
const { dsaMiddleware } = require("dsa-middleware-bb");

const app = express();

app.use(
  dsaMiddleware({
    accountId: "<YOUR_ACCOUNT_ID>",
    agentId: "<YOUR_AGENT_ID>",
    email: "<YOUR_EMAIL>",
    password: "<YOUR_PASSWORD>",
    debug: true, // optional: logs internal activity
  })
);

app.get("/", (req, res) => {
  res.send("βœ… DSA Middleware Active!");
});

app.listen(3000, () => console.log("Server running on http://localhost:3000"));

βš™οΈ Usage in TypeScript / NestJS

1️⃣ Install

npm install dsa-middleware-bb

2️⃣ Register Middleware in main.ts

import { NestFactory } from "@nestjs/core";
import { AppModule } from "./app.module";
import { dsaMiddleware } from "dsa-middleware-bb";

async function bootstrap() {
  const app = await NestFactory.create(AppModule);

  app.use(
    dsaMiddleware({
      accountId: "<YOUR_ACCOUNT_ID>",
      agentId: "<YOUR_AGENT_ID>",
      email: "<YOUR_EMAIL>",
      password: "<YOUR_PASSWORD>",
    })
  );

  await app.listen(3000);
  console.log("πŸš€ NestJS App running on http://localhost:3000");
}

bootstrap();

βš™οΈ Configuration Options

Option Type Required Description
accountId string βœ… Yes Unique account identifier
agentId string βœ… Yes Registered agent ID
email string βœ… Yes Login email for agent authentication
password string βœ… Yes Login password for agent authentication
debug boolean ❌ No Enables detailed console logs for debugging

🧠 Middleware Behavior

Once applied, dsaMiddleware will:

  • Secure and hide sesitive information in each response.
  • Information like Card numbers, Mobile numbers, emails, etc.
  • Everything is masked based on defined rules.

🧩 Example Output (Debug Mode)

βœ… Agent registration and authentication successful
 > Scheduling Re-Authentication
 > Re-Authentication Scheduled every 3 minutes
 > Report Sync Scheduled every 1 minutes

πŸ“¦ Latest Version

Version: 0.0.1
(Always check the npm registry for the latest release.)


🧰 Troubleshooting

Issue Possible Cause Solution
Invalid credentials Wrong email/password Verify your credentials
Unauthorized agent Invalid agentId Check your agent registration
Request blocked Missing middleware Ensure app.use(dsaMiddleware(...)) is placed before your routes

πŸ“œ License

MIT Β© [Your Organization or Name]


πŸ’¬ Support

For issues, suggestions, or contributions:
πŸ‘‰ Open a GitHub Issue


πŸ’‘ Pro Tip

Use environment variables to keep your credentials secure:

ACCOUNT_ID=acc_12345
AGENT_ID=agent_56789
AGENT_EMAIL=agent@example.com
AGENT_PASSWORD=supersecret
app.use(
  dsaMiddleware({
    accountId: process.env.ACCOUNT_ID,
    agentId: process.env.AGENT_ID,
    email: process.env.AGENT_EMAIL,
    password: process.env.AGENT_PASSWORD,
  })
);

🧩 Simple. Secure. Smart β€” That’s DSA Middleware.

πŸ“œ Changelog

See full details in CHANGELOG.md