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

@mcal/core-node-sdk

v0.0.0

Published

Production-grade SDK for consuming MCAL third-party outputs in Node.js.

Readme

@mcal/core-node-sdk

Production-grade SDK for consuming MCAL third-party outputs in Node.js.

This SDK is built for engineering teams integrating event delivery through HTTP webhooks and MQTT over mutual TLS. It provides a consistent, secure, and operationally friendly integration surface for both models.

Introduction

@mcal/core-node-sdk standardizes how external systems consume MCAL outputs. Instead of dealing with transport-level details in every project, teams can use one SDK API for webhook validation, MQTT connection handling, and lifecycle events.

The same integration principles will be reused across SDKs in other languages (for example Java), so integration behavior remains predictable across ecosystems.

Installation

Install from npm:

npm install @mcal/core-node-sdk

Install from a local tarball:

npm install /absolute/path/core-node-sdk.tgz

Delivery Channels

MCAL supports two transport channels:

  • HTTP Webhook for server-to-server push
  • MQTT over mTLS for topic-based event streaming

You can implement either transport independently, or both together.

HTTP Integration

The HTTP module is designed to verify webhook authenticity before your business logic executes.

Important behavior

Any non-2xx response from your webhook endpoint is treated as a failed relay by MCAL.

Initialize

const {SDKNodeIntegrations} = require('@mcal/core-node-sdk');

const sdk = new SDKNodeIntegrations();

const http = sdk.initialize.http({
    webhookKey: 'wsc_...'
});

Validate incoming requests

// Option A: explicit payload
const result = http.validate({
    headers: req.headers,
    body: req.body
});

// Option B: request object directly if shape is compatible
// const result = http.validate(req);

if (!result.ok) {
    return res.status(401).json({error: 'invalid webhook signature'});
}

handleEvent(result.body);
return res.status(200).end();

If you prefer fail-fast behavior, use http.assert(...) instead of http.validate(...). It throws when validation fails.

Security model

MCAL sends the per-channel webhook secret in the header:

x-mcal-webhook-key

The SDK validates this value using timing-safe comparison. Failed validation must be treated as unauthorized traffic.

MQTT Integration

The MQTT module is certificate-based and AWS IoT compatible.

Initialize

const session = await sdk.initialize.mqtt({
    endpoint: 'provided in integration settings',
    topic: 'provided in integration settings',
    caPath: '/path/to/AmazonRootCA1.pem',
    certPath: '/path/to/certificate.pem.crt',
    keyPath: '/path/to/private.pem.key',
    qos: 1
});

Returned session:

  • clientId: effective MQTT client id used by the connection
  • topics: topics subscribed by the SDK
  • disconnect(): graceful disconnect helper

Event listeners

sdk.on('mqtt:connect', () => console.log('[MQTT] connected'));
sdk.on('mqtt:message', (msg) => {
    console.log('[MQTT] topic:', msg.topic);
    console.log('[MQTT] payload:', msg.text);
});
sdk.on('mqtt:error', (err) => console.error('[MQTT] error:', err));

MQTT event map

  1. mqtt:connect
    Fired when the MQTT client establishes a connection.
  2. mqtt:reconnect
    Fired when the client starts a reconnect attempt after an interruption.
  3. mqtt:subscribed
    Fired after topic subscription succeeds. Payload:
    { topics: string[], qos: 0 | 1 }
  4. mqtt:message
    Fired when a message is received on a subscribed topic. Payload:
    { topic: string, payload: Buffer, text: string }
  5. mqtt:error
    Fired on MQTT client errors. Payload is typically an Error.
  6. mqtt:close
    Fired when the MQTT connection closes.
  7. mqtt:disconnect
    Fired when disconnection is explicitly triggered via SDK shutdown (disconnect() or dispose()).

Operational Recommendations

For production environments, keep webhook keys and certificate files in a secure secret manager, not in source control. Rotate credentials according to your policy and monitor integration logs with structured logging.

Webhook and MQTT consumers should be idempotent. Event-driven systems can deliver duplicates under retry/recovery scenarios.

Graceful shutdown

const shutdown = async () => {
    await sdk.dispose();
    process.exit(0);
};

process.on('SIGINT', shutdown);
process.on('SIGTERM', shutdown);