Introduction

@jx_code/rsimzo-client A lightweight JavaScript client for interacting with the RsImzo provider β€” allowing you to authenticate users, retrieve certificates, and sign documents using EDS keys.

@jx_code/rsimzo-client

A lightweight JavaScript client for interacting with the RsImzo provider β€” allowing you to authenticate users, retrieve certificates, and sign content using EDS keys through secure popup and iframe communication.


πŸ“¦ Installation

# with npm
npm install @jx_code/rsimzo-client

# or with pnpm
pnpm add @jx_code/rsimzo-client

# or with yarn
yarn add @jx_code/rsimzo-client

πŸš€ Getting Started

1. Import and Initialize

import { RsimzoClient } from "@jx_code/rsimzo-client";

const rsimzo = new RsimzoClient({
  publicKey: "YOUR_PUBLIC_KEY",
  locale: "uz", // optional, defaults to 'uz'
});

⚠️ publicKey is required when creating a new instance.
If not provided, the constructor throws an error.


🧩 API Reference

new RsimzoClient(options)

Parameters:

OptionTypeRequiredDefaultDescription
publicKeystringβœ… Yesβ€”The public key provided by RsImzo
locale'uz' | 'ru' | 'en'❌ No'uz'Language used for popup interfaces

Example:

const rsimzo = new RsimzoClient({ publicKey: "ABC123", locale: "ru" });

getCertificates(options?)

Retrieves the list of available EDS certificates from the RsImzo provider using an invisible iframe.

Parameters:

OptionTypeRequiredDefaultDescription
locale'uz' | 'ru' | 'en'❌current instance localeLocale for the provider interface

Returns:

Promise<RsPostMessageResult<{ serialNumber: string; owner: string }[]>>;

Example:

const result = await rsimzo.getCertificates();
console.log(result);

sign(serialNumber, content, options?)

Opens a popup for signing a given piece of content using a certificate.

Parameters:

NameTypeRequiredDefaultDescription
serialNumberstringβœ… Yesβ€”The certificate serial number to use
contentstringβœ… Yesβ€”The content (e.g., base64 string) to sign
options.locale'uz' | 'ru' | 'en'❌ Noinstance localeLanguage of the signing popup
options.attachedboolean❌ NotrueWhether the signature should be attached

Returns:

Promise<RsPostMessageResult<string>>;

Example:

const signed = await rsimzo.sign("123456789", "Hello world!");
console.log(signed);

auth(options?)

Performs an authentication flow using RsImzo, returning an identity token or user data.

Parameters:

OptionTypeRequiredDefaultDescription
locale'uz' | 'ru' | 'en'❌instance localeLocale for the authentication popup

Returns:

Promise<RsPostMessageResult<string>>;

Example:

const authResult = await rsimzo.auth();
console.log(authResult);

βš™οΈ Error Handling

Every method returns a standard structure:

type RsPostMessageResult<T> = {
  data: T | null;
  error?: {
    errorCode: number;
    errorMessage: string;
  };
};
CodeMessageDescription
13Incorrect passwordWrong password entered during signing
10001Window closedThe popup was closed by the user
10002Fetch token errorFailed to fetch or validate token
10003No resultAction completed with no result
10004Certificate not foundNo matching EDS certificate found
10005Invalid tokenToken validation failed
10006Invalid parametersMissing or invalid input parameters
10008TimeoutOperation took longer than 60 seconds
10009Popup blockedBrowser prevented opening popup window

🌐 Example Integration

import { RsimzoClient } from "@jx_code/rsimzo-client";

const rsimzo = new RsimzoClient({ publicKey: "ABC123", locale: "uz" });

async function run() {
  const auth = await rsimzo.auth();
  if (auth.error) return console.error(auth.error);

  const certs = await rsimzo.getCertificates();
  if (certs.error) return console.error(certs.error);

  const signed = await rsimzo.sign(certs.data[0].serialNumber, "text-to-sign");
  console.log("Signed data:", signed);
}

run();