omari.mohamed
  • Joined on 2025-08-05

@taxi/crypto-utils (0.1.0)

Published 2025-09-12 08:27:08 +00:00 by omari.mohamed

Installation

@taxi:registry=
npm install @taxi/crypto-utils@0.1.0
"@taxi/crypto-utils": "0.1.0"

About this package

@taxi/crypto-utils

Shared crypto utilities for Taxi apps.

Features:

  • Password hashing with bcryptjs
  • TOTP generation/verification with otplib
  • AES-GCM symmetric encryption/decryption using Web Crypto API

Install (local monorepo)

Add to an app package.json dependencies:

"@taxi/crypto-utils": "file:../packages/crypto-utils"

Then install in that app folder:

npm install

Usage

import { hashPassword, comparePassword, generateTotpSecret, generateTotpToken, verifyTotpToken, otpauthURL, encrypt, decrypt } from '@taxi/crypto-utils';

// Passwords
const hash = await hashPassword('secret');
const ok = await comparePassword('secret', hash);

// TOTP
const secret = generateTotpSecret();
const token = generateTotpToken(secret);
const valid = verifyTotpToken(token, secret);
const url = otpauthURL(secret, 'user@example.com', 'Taxi');

// Symmetric
const payload = await encrypt('hello', 'passphrase');
const plain = await decrypt(payload, 'passphrase');

Notes:

  • AES-GCM helpers rely on the global Web Crypto API (globalThis.crypto), available in modern Node (>=18). In older environments, consider a polyfill or use Node's crypto module directly.

Dependencies

Dependencies

ID Version
bcryptjs ^3.0.2
otplib ^12.0.1

Development Dependencies

ID Version
@types/bcryptjs ^2.4.6
@types/node ^20
rimraf ^6.0.1
tsup ^8.3.5
typescript ^5.6.3
Details
npm
2025-09-12 08:27:08 +00:00
2
MIT
4.5 KiB
Assets (1)
Versions (4) View all
0.2.3 2025-09-12
0.2.1 2025-09-12
0.2.0 2025-09-12
0.1.0 2025-09-12