eimzo-ts

eimzo-ts: TypeScript client for E-IMZO

Let a web page use E-IMZO, the desktop application for electronic digital signatures in Uzbekistan (ЭЦП / ERI): list the user's keys, create PKCS#7 signatures, and log users in with their digital signature.

Unofficial library. Not affiliated with the developers of E-IMZO.

What it is

eimzo-ts is a browser library with a typed, Promise-based API and zero runtime dependencies. It replaces e-imzo.js and e-imzo-client.js from the official E-IMZO example: no global variables and no changes to built-in prototypes. ESM, CommonJS and a <script> build (global EimzoClient) are included, with TypeScript declarations.

How it works

  1. The page connects to E-IMZO on the user's computer over WebSocket: ws://127.0.0.1:64646 for http pages, wss://127.0.0.1:64443 for https.
  2. E-IMZO shows its own password window. The page never sees the password.
  3. E-IMZO returns a PKCS#7 (CMS) signature as base64.
  4. Your backend verifies the signature with e-imzo-server. This library does not verify signatures.

Install

npm install eimzo-ts

Quick start

import { createEimzo, createFetchBackend, DEV_API_KEYS } from 'eimzo-ts';

const eimzo = createEimzo({
  apiKeys: { ...DEV_API_KEYS, 'my-site.uz': 'API key for my-site.uz' },
  backend: createFetchBackend({
    challengeUrl: '/api/eimzo/challenge',
    loginUrl: '/api/eimzo/login',
    timestampUrl: '/api/eimzo/timestamp',
  }),
});

const keys = await eimzo.listKeys();                // the user's keys
const user = await eimzo.login(keys[0]);            // E-IMZO asks for the password
const pkcs7 = await eimzo.signDocument('document'); // signature + timestamp

Use cases

Features

Compatibility

Runs in modern browsers (ES2020). It is framework-agnostic, so it can be used from Angular, React, Vue, Svelte or plain JavaScript. With server-side rendering (Next.js, Nuxt, Angular SSR) call it only on the client, because E-IMZO runs on the user's computer. Requires E-IMZO 4.86 or newer by default.

When not to use it

More in the FAQ. Try the live demo; it works without E-IMZO, using mock keys.