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

ura-prn

v1.0.0

Published

A TypeScript package to generate a PRN, generate access token, check PRN status and check TIN validity.

Readme

🔐 ura-prn

A lightweight Node.js library for encrypting and signing credentials using URA certificates (.cer) and private keys from PKCS12 keystores (.pfx).
Ideal for integrations that require secure payload delivery to Uganda Revenue Authority (URA) or similar services using public key encryption and digital signatures.


✨ Features

  • 🔒 RSA encryption using X.509 .cer certificate
  • ✍️ SHA1withRSA digital signature using .pfx (PKCS12) private keys
  • 🧩 Fully configurable: bring your own files, credentials, and alias
  • ✅ Error codes and descriptive messages for robust integrations

📦 Installation

npm install ura-prn

Requires Node.js 14+ and node-forge as a peer dependency:

npm install node-forge

🚀 Quick Start

import { URAPrn } from 'ura-prn';

const ura = new URAPrn({
  certPath: './storage/ura.cer',
  pfxPath: './storage/ncdc.pfx',
  keystorePassword: '',
  alias: 'ncdc',
});

const result = ura.encryptAndSign('YOURCREDENTIALS');

console.log(result);
// {
//   encryption: '...',
//   signature: '...'
// }

🧰 API Reference

constructor(config: URAPrnConfig)

| Param | Type | Description | |-------------------|----------|--------------------------------------------| | certPath | string | Absolute or relative path to .cer file | | pfxPath | string | Absolute or relative path to .pfx file | | keystorePassword | string | Password to unlock the PFX keystore | | alias (optional) | string | Alias (friendly name) for the private key |


encrypt(plainText: string): string

Encrypts a string using the public key from the .cer file.

ura.encrypt('mySecret');

generateSignature(encryptedText: string): string

Generates a digital signature of the encrypted string using the private key in the .pfx.

ura.generateSignature(encryptedText);

encryptAndSign(plainText: string): { encryption: string; signature: string }

Encrypts and signs in one go.

const result = ura.encryptAndSign('password123');

🛑 Error Codes

When something goes wrong, the library throws an error of type URAPrnError with a structured code and message.

| Code | Message | When it happens | |----------|--------------------------------------------------|-----------------| | ERROR001 | Failed to load or parse the certificate file. | .cer file missing or malformed | | ERROR002 | Failed to encrypt the provided plaintext. | Public key encryption failed | | ERROR003 | Failed to load or parse the PFX keystore. | Bad password or corrupted .pfx | | ERROR004 | Private key not found in keystore. | No key found for alias | | ERROR005 | Failed to generate digital signature. | Signing operation failed |

Catching Errors Example

try {
  ura.encryptAndSign('data');
} catch (err: any) {
  if (err.code) {
    console.error(`Error (${err.code}): ${err.message}`);
  }
}

🔒 Security Notes

  • Always keep your .pfx file and passwords secure.
  • Never hardcode credentials or file paths in production.
  • Consider loading secrets from environment variables or a secure vault.

👥 Contributing

Issues and PRs are welcome! Please include relevant tests or examples.


📄 License

MIT