npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@bmap-analytics/node

v0.12.0

Published

BMAP server SDK — mint embed tokens and manage applications from your backend.

Readme

@bmap-analytics/node

Mint BMAP embed tokens from your backend.

npm install @bmap-analytics/node

Quick start

import { Bmap } from "@bmap-analytics/node";

const bmap = new Bmap({
  apiKey: process.env.BMAP_API_KEY!,
  baseUrl: "https://analytics.acme.com",
});

// Express, Fastify, Next route handler — anything.
app.get("/api/bmap-token", async (req, res) => {
  const session = await bmap.embed.createToken({
    dashboardId: req.query.dashboard as string,
    // Resolved from YOUR session. Never from the request body.
    context: { region: req.user.region, accountId: req.user.accountId },
    ttlSeconds: 600,
  });
  res.json({ token: session.token, expiresAt: session.expiresAt });
});

Hand token to the browser and nothing else. @bmap-analytics/react takes it from there.

This package must not run in a browser

The constructor throws if it detects one. It holds your API key, and an API key in a browser lets any viewer mint a token with any security context they like — which is the one thing embedding exists to prevent.

The check looks for a window with a document, so a server runtime that resembles a browser — an Electron main process, Deno — trips it. allowBrowser: true is the escape hatch for exactly that, and for nothing else: a real browser with the flag set is still a browser holding your API key.

API

bmap.embed.createToken(params)

| Param | | | |---|---|---| | dashboardId | required | Must be published, and granted to this application. | | context | | The viewer's security context. Sealed into the signed token. | | ttlSeconds | | Default 600. Short by design; the client SDK refreshes silently. | | origin | | Pin the token to one origin. Presented elsewhere, it is refused. |

Returns { token, sessionId, dashboardId, expiresAt }.

bmap.embed.listSessions({ applicationId? })

Every token minted, for audit. contextHash is a hash — BMAP never stores the context values themselves, because these rows are retained and would otherwise accumulate your customers' identifiers.

bmap.embed.revokeSession(sessionId)

Cuts a viewer off on their next request, not at token expiry — so it is usable during an incident rather than being a ten-minute wait.

bmap.dashboards.list({ grantedTo?, status? })

The menu behind a dashboard picker: which dashboards this integration may actually show.

const dashboards = await bmap.dashboards.list({ grantedTo: process.env.BMAP_APPLICATION_ID });
// [{ id, name, description, status, currentVersionId }, …]

With grantedTo, the list is narrowed to what createToken will accept — granted to that application and published. Both halves matter: a grant without a published version is a menu item that mints nothing, and a published dashboard nobody granted you is not yours to show. Without grantedTo you get every dashboard in the tenant, which is the right call for an internal admin screen and the wrong one for a customer-facing picker.

This talks to BMAP directly. You do not need a route of your own in front of it — a forwarding endpoint between your server and BMAP would transform nothing.

Errors

Every failure is a BmapError with a code:

import { BmapError } from "@bmap-analytics/node";

try {
  await bmap.embed.createToken({ dashboardId });
} catch (error) {
  if (error instanceof BmapError && error.code === "forbidden") {
    // Usually: this application has no grant for that dashboard.
  }
}

Setup checklist

Each is enforced when you mint, so a missing one produces a clear 403 rather than a puzzling empty dashboard:

  1. An application — POST /v1/developer/applications
  2. An API key for it — the secret is shown once
  3. A grant for the dashboard — an allow-list, so a leaked key reaches only what you shared
  4. The dashboard is published

Node 18+ (needs a global fetch), ESM and CJS, TypeScript declarations, source maps.