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

maple-esign

v0.1.0

Published

TypeScript client for the Maple eSign REST API: templates, documents, bulk send, webhooks and embedded signing.

Readme

Maple eSign for JavaScript and TypeScript

A typed client for the Maple eSign v1 REST API: templates, documents, bulk send, field detection, embedded signing and sending, audit trails, sealed PDFs and webhooks. It has no runtime dependencies and runs anywhere with fetch: Node.js 20 or later, Deno, Bun, edge workers and browsers. It ships ES modules and CommonJS, with TypeScript types for both.

Install

npm install maple-esign

First request

Create an API token in the Maple eSign console. A test token (ssk_test_...) works in the sandbox.

import { MapleClient } from 'maple-esign';

const maple = new MapleClient({ token: process.env.MAPLE_API_TOKEN! });

const documents = await maple.listDocuments({ limit: 10 });
for (const d of documents) console.log(d.title, d.status);

CommonJS works the same way: const { MapleClient } = require('maple-esign');

The client calls https://sign.mapleesign.ca unless you pass baseUrl.

Send an agreement from a template

const doc = await maple.useTemplate(
  'tpl_123',
  {
    recipients: { client: { name: 'Ada Lovelace', email: '[email protected]', locale: 'fr-CA' } },
    title: 'Mutual NDA for Ada',
  },
  { idempotencyKey: 'order-1234' }, // a retry with the same key returns the same document
);
const sent = await maple.sendDocument(doc.id);
console.log(sent.signingLinks[0]?.signingUrl);

createDocument does the same from a PDF you upload. Both take an idempotencyKey, so a retry after a timeout never makes a second agreement.

When everyone has signed, downloadArtifact(id) returns the sealed PDF. It throws a 409 until then.

Test and live tokens

| Token | What it reaches | |---|---| | ssk_test_... | The sandbox. It sees and makes only test agreements. A test send emails only your own verified address and your organization's verified sending domains; any other address is refused with 422 test_recipient_not_allowed. Sealed PDFs are marked as tests, and webhook payloads carry test: true. | | ssk_live_... | Production agreements. | | oat_... | An OAuth access token acting for one member. |

All three use the same base URL. tokenEnvironment(token) returns 'test', 'live' or 'oauth', read from the prefix.

Errors

Every refusal throws MapleApiError with status, code, message and requestId. Quote the requestId when you contact support. Some refusals carry more in details. For example, test_recipient_not_allowed lists the recipients it refused and the domains you may use. A 429 sets retryAfterSeconds.

import { MapleApiError } from 'maple-esign';

try {
  await maple.sendDocument(doc.id);
} catch (e) {
  if (e instanceof MapleApiError && e.status === 429) {
    // wait e.retryAfterSeconds, then try again
  }
  throw e;
}

The status codes are 401 (not signed in), 403 (not allowed), 404 (not found, including another team's records), 409 (wrong state, such as downloading before sealing), 422 (validation), 429 (rate limited) and 503 (a feature this deployment has turned off).

Webhooks

createWebhook returns the endpoint's secret once, so store it. Each delivery is signed with that secret in the X-Stalwart-Signature header. Verify it against the raw body, exactly as it arrived:

import express from 'express';
import { verifyWebhookSignature, type WebhookPayload } from 'maple-esign';

const app = express();
app.post('/maple/webhooks', express.raw({ type: 'application/json' }), async (req, res) => {
  const ok = await verifyWebhookSignature(
    process.env.MAPLE_WEBHOOK_SECRET!,
    req.get('x-stalwart-signature'),
    req.body, // the raw bytes; a re-serialised object will not verify
  );
  if (!ok) return res.sendStatus(400);
  const event = JSON.parse(req.body.toString('utf8')) as WebhookPayload;
  res.sendStatus(200);
  // A delivery is a nudge: re-read the document before acting on it.
  if ('documentId' in event) await maple.getDocument(event.documentId);
});

Signatures older than five minutes are refused, so a captured delivery cannot be replayed. Change that with { toleranceSeconds }.

Embedded signing

Create the document with delivery: 'embedded' on the recipient, send it, then mint a short lived signing link from your server for one of your registered embed origins:

const { url } = await maple.createEmbedSigningToken(doc.id, {
  recipientId: doc.recipients[0]!.id,
  origin: 'https://app.example.ca',
});

Frame url in your page. isMapleSigningEvent and mapleOriginOf read the frame's postMessage events.

Paging

listDocuments answers one page, newest first: 50 by default and up to 100 with limit. Pass offset to read on until a page comes back short. It also filters by status, q, folder, tag and hideExpired.

Requirements

  • Node.js 20 or later, or any runtime with fetch and Web Crypto (crypto.subtle, used only to verify webhooks).
  • TypeScript 5.0 or later for the types.

Licence

Apache License 2.0. The full text is in the LICENSE file that comes with the package.