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

@codevibe_technology/sign-aadhaar

v0.1.1

Published

Aadhaar eSign through a licensed eSign provider, with your own provider account.

Readme

@codevibe_technology/sign-aadhaar

Aadhaar eSign for Codevibe Sign, through an eSign provider you hold an account with. It defines a small EsignProvider interface and ships an adapter for Leegality.

The Codevibe Sign server runs it for you: pass a provider as the server's esign option and a recipient with auth: 'aadhaar' is sent to the provider, the callback is verified, the signed file is kept and sealed, and the audit trail records it (see "Aadhaar eSign" in the server README). The web app does the same from its settings. You can also call the provider from your own backend, as shown below, and store the signed file yourself.

What Aadhaar eSign is

Under the Information Technology Act, 2000, an electronic record can be authenticated with an electronic signature using a technique listed in the Second Schedule (s.3A). The Second Schedule lists e-authentication using Aadhaar e-KYC: the signer proves who they are with an Aadhaar OTP or biometric, and an eSign Service Provider (ESP) issues a short-lived signing certificate and signs the document hash with it.

ESPs are Certifying Authorities licensed by the Controller of Certifying Authorities (CCA). Most products reach them through an Application Service Provider such as Leegality, which runs the signing page and talks to the ESP.

Use this when a law asks for a document to be "signed" in the statutory sense. For offer letters, policies, NDAs and most business documents, the built-in electronic signature in Codevibe Sign (IT Act s.10A, with its audit trail) is usually enough.

This is not legal advice. Ask your own counsel which documents need which kind of signature.

You need a provider account

This package talks to the provider with the API credentials you give it, and each eSign is billed to that account. When you run the server yourself, that is your own account with the provider. The hosted Codevibe Sign app can also sign through Codevibe's account with prepaid credits.

Install

pnpm add @codevibe_technology/sign-aadhaar @codevibe_technology/sign-core

Node 22 or later. The package uses fetch and node:crypto.

How the flow works

  1. Your server calls createRequest with the PDF and the signer. The provider returns a providerRef and a signUrl.
  2. You send the signer to signUrl. They review the document and sign with Aadhaar OTP on the provider's page.
  3. The provider calls your webhook. parseWebhook verifies it and returns { providerRef, status }, where status is signed, declined, expired or failed.
  4. When the status is signed, fetchSignedDocument(providerRef) returns the signed PDF. Store it and record the event in the envelope's audit trail. fetchAuditTrail(providerRef) returns the provider's own audit trail PDF, to keep as evidence next to it.

The signed PDF carries the provider's digital signature. Do not draw on it or add pages to it afterwards: any change other than another signature breaks that signature. To seal it, use countersign from @codevibe_technology/sign-pdf.

Usage

import { createLeegalityProvider } from '@codevibe_technology/sign-aadhaar';

const esign = createLeegalityProvider({
  environment: 'sandbox',
  authToken: process.env.LEEGALITY_API_KEY!,
  privateSalt: process.env.LEEGALITY_PRIVATE_SALT!,
  profileId: process.env.LEEGALITY_WORKFLOW_ID!,
});

const { providerRef, signUrl } = await esign.createRequest({
  envelopeId: envelope.id,
  recipient: { name: 'Asha Rao', email: '[email protected]' },
  documentBytes: pdf,
  documentName: 'Appointment letter.pdf',
  callbackUrl: 'https://sign.example.com/hooks/leegality',
  redirectUrl: 'https://sign.example.com/done',
});

// In your webhook route, pass the raw body exactly as received.
const event = await esign.parseWebhook(request.headers, rawBody);
if (event?.status === 'signed') {
  const signed = await esign.fetchSignedDocument(event.providerRef);
  const providerAuditTrail = await esign.fetchAuditTrail?.(event.providerRef);
}

API

| Export | What it is | | ---------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------- | | EsignProvider | createRequest, parseWebhook, fetchSignedDocument, and optionally fetchAuditTrail, webhookRef and checkCredentials. Implement it to add a provider. | | EsignRequest | envelopeId, reference, recipient, documentBytes, documentName, callbackUrl, redirectUrl, optional signaturePositions. | | EsignEvent | { providerRef, status, signerName?, signedAt? }. | | createLeegalityProvider | The Leegality adapter. Options below. | | computeLeegalityMac | The webhook mac for a document id, for tests and tooling. | | leegalityWebhookRef | The provider reference a Leegality webhook body names (document id, or v4:<packId>:<documentId>), read without verifying it. | | SignaturePosition, PageBox | { page, rect, pageBox? }; pageBox is the page's crop box in user space and its rotation. | | leegalityV4WorkflowFromPayload | The workflow id and part ids from a v4 workflow's downloaded API payload (object or JSON text). | | toLeegalityRect | The v4 rect for a position under a LeegalityCoordinateMapping. | | parseLeegalityCoordinateUnits, parseLeegalityCoordinateOrigin, describeLeegalityCoordinates, LEEGALITY_DEFAULT_COORDINATES | Read and show the coordinate setting (points or pixels@<dpi>; bottom-left or top-left). |

reference is your own id for one request, sent to Leegality as the irn; it defaults to envelopeId. Give each attempt its own when a signer can start again.

webhookRef(rawBody) reads the provider reference from a callback without checking anything. A server that holds several provider accounts uses it to find whose credentials must verify the callback; never act on it before parseWebhook has accepted the same body.

checkCredentials() makes one read-only call and resolves when the provider accepts the credentials. The Leegality adapter asks for the status of a document id that cannot exist: an account Leegality recognises is told there is no such document, and any other answer throws SignError('PROVIDER_ERROR').

parseWebhook throws SignError('WEBHOOK_INVALID') for any body it cannot verify, and returns null for a verified callback that does not change the signer's status (such as a reviewer approval). Provider failures throw SignError('PROVIDER_ERROR') with details.reason (timeout, network, unauthorized, unavailable, rejected, not_found, ...) and details.retryable; HTTP 429 throws RATE_LIMITED. Errors never contain the document or your credentials, and the package does not log.

Limits: webhook bodies over 256 KB are refused before parsing, provider JSON responses over 2 MB and signed files over maxSignedDocumentBytes are cut off while streaming, and a signing link that is not https is treated as missing. Webhooks are not replay-protected by Leegality, so make your handler idempotent on (providerRef, status).

Leegality options

| Option | Required | Notes | | ------------------------ | -------- | ------------------------------------------------------------------------------------------------------------- | | environment | yes | sandbox (https://sandbox.leegality.com/api) or production (https://app1.leegality.com/api). | | authToken | yes | Dashboard, API Settings. Sent as X-Auth-Token. | | privateSalt | yes | Dashboard, API Settings. Verifies webhook mac. | | profileId | yes | The Workflow ID, or a function (request) => workflowId. | | confirmWebhooks | no | Default true. Confirms each webhook with the Check transaction status API. | | webhookHeader | no | { name, value } of a static header Leegality support adds to your webhooks. | | timeoutMs | no | Default 30 000, covering the response body as well. Whole milliseconds, at most 10 minutes. | | maxSignedDocumentBytes | no | Default 50 MB. | | positionApi | no | Which API places signaturePositions: v2.1 (default without v4), v4 (default with v4) or off. | | v4 | no | A v4 workflow (leegalityV4WorkflowFromPayload), for positionApi: 'v4'. | | coordinates | no | { units: 'points' \| { pixelsPerInch }, origin: 'bottom-left' \| 'top-left' }. Default points, bottom-left. | | baseUrl, fetch | no | Overrides for proxies and tests. baseUrl must be https (plain http only for localhost). |

Set up the Leegality workflow

Leegality's API runs a published Workflow; several settings live only in that workflow, not in the API request. In the Leegality dashboard, for the workflow you pass as profileId:

  • choose Aadhaar eSign as the signature type for the invitee;
  • place the signature box (if you need different layouts, create a workflow per layout and pass profileId as a function);
  • under the invitee's custom URLs and webhooks, set the Webhook and Error Webhook to your callbackUrl, choose webhook version 2.5, and set the Redirect URL to your redirectUrl.

Placing the signature per request (2.1)

Leegality's v3.0 request has no field for a signature position, but its 2.1 Create API takes one per invitee: "pass the eSign coordinates in the appearances array of the payload" (Coordinate Picker). By default (positionApi: 'v2.1') a request that carries signaturePositions goes to POST /api/v2.1/sign/request with the same Auth Token (the dashboard calls it the legacy Auth Token). The body follows the v2.1 OpenAPI schema (SignRequest, Invitee, Appearance; published copy at https://github.com/prakharmittal/leegality-apidocs/blob/master/api_2_1.json): the file, the irn, and one invitee with appearances (page from 1, x1/y1 lower-left and x2/y2 upper-right, whole numbers), signatures: [{ type: 'AADHAAR', config: { authTypes: ['OTP'] } }], webhook { success, failure, version: 2.5 } set to callbackUrl, and redirectUrl. The 2.1 API takes no workflow, so profileId is not sent and the workflow's other settings do not apply to such a request. The response is the usual wrapper with data.documentId and data.invitations[].signUrl; the document is then followed with the same v3.x status and download calls and verified Webhook 2.5 bodies as a v3.0 one, and providerRef is its document id.

Placing the signature per request (v4)

Leegality's v3.0 request has no field for a signature position. Its v4 Pack API has one: coordinates[] per invitee, with appearances[] of pageNo (from 1) and rect { x1Axis, y1Axis, x2Axis, y2Axis } (Send Pack for eSigning (Sync)). With the v4 option (and positionApi: 'v4', its default then), a request that carries signaturePositions is sent to POST /api/v4/pack/sync with the signer's appearances at those positions, its success and error webhooks set to callbackUrl with version 4.0, and redirectUrl as the invitee's redirect URL. Its providerRef is v4:<packId>:<documentId>. Webhook 4.0 bodies are verified with the same mac (HMAC-SHA1 of document.documentId) and confirmed with Check Pack Details; files come from Download files. Requests without positions keep using v3.0, so both kinds of providerRef work side by side.

The v4 API refers to the workflow's document, sub-document, signer and combination by UUID. leegalityV4WorkflowFromPayload(json) reads them, and the full workflow id, from the file the dashboard's Download API Payload gives (Download the v4 API payload); nothing else of the file is kept. Ids left out are generated per request.

A position is { page, rect, pageBox }: the zero-based page, the box in PDF points from the top-left of the page as displayed (as Field.rect), and the page's crop box in user space with its /Rotate. Leegality does not document the unit or origin of rect; the default, PDF points from the bottom-left of the unrotated page, follows its earlier API, which named the corners "lower-left" and "upper-right". toLeegalityRect(position, coordinates) gives the rectangle that is sent; check it once with a sandbox eSign and change coordinates if the seal lands elsewhere.

What Leegality's public documentation does not cover

The adapter only does what Leegality's published API reference confirms. These gaps are handled by configuration rather than guessed:

  • Signature positions, callback URL and redirect URL are not fields of the v3.0 Create eSigning request API. They come from the workflow (see above), so a v3.0 request sends none of them. Without coordinates in the workflow, Leegality puts the signature at the bottom left of every page. A v4 request sends all three.
  • Units and origin of v4 coordinates are not documented; see coordinates above.
  • Choosing Aadhaar per request is not documented; the workflow decides the eSign type.
  • Webhook authenticity: the documented mac is HMAC-SHA1 of the documentId only, keyed by the Private Salt. The rest of the body is not covered, and no timestamp or replay protection is documented. That is why confirmWebhooks is on by default. The hex encoding is taken from the documented examples.
  • Signing time: no webhook or status field gives the time of signing, so signedAt is not set. Record the time you received the verified event instead.
  • HTTP status codes: the reference says errors usually come back as HTTP 200 with status: 0. Other status codes and rate limits ("fair use limits may apply") are not specified, so they are mapped generically.
  • Response status on success: the published sample shows status: 0 beside a success message, so a returned documentId is treated as success.
  • Webhook versions: v3.0 requests rely on version 2.5 set in the workflow; v4 requests ask for 4.0 themselves.

Roadmap

eMudhra as a second provider is planned. The EsignProvider interface is what it will implement, so nothing in your code changes when you switch.

Docs

Guides and the full API reference are at sign.codevibe.in.

Licence

Apache-2.0 © Codevibe


The Codevibe Sign packages

| Package | What it does | Licence | | ---------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------- | ---------- | | codevibe-sign | The one library to install: API client, PDF tools, core rules, React components and a command line. | Apache-2.0 | | @codevibe_technology/sign-core | Envelopes, routing, reminders, expiry and a hash-chained audit log. No I/O. | Apache-2.0 | | @codevibe_technology/sign-pdf | Draws fields, appends the certificate page, seals with PAdES and verifies the seal. | Apache-2.0 | | @codevibe_technology/sign-client | Typed client for the HTTP API, signing sessions and webhook checks. No dependencies. | Apache-2.0 | | @codevibe_technology/sign-react | Signature pad, signing view and field placer for your own React app. | Apache-2.0 | | @codevibe_technology/sign-templates | Templates with roles and prefilled fields, and bulk send from CSV. | Apache-2.0 | | @codevibe_technology/sign-aadhaar | Aadhaar eSign through a licensed eSign provider (Leegality). Used by the server and the web app. | Apache-2.0 | | @codevibe_technology/sign-server | The HTTP API and runtime: storage, mail, one-time codes, webhooks and sealing. | AGPL-3.0 |

The web app, the Docker image and the docs live in the Codevibe Sign repository. Try it free at sign.codevibe.in, or self-host it with no limits.