Registry / database / mongodb-crypt-library-version

mongodb-crypt-library-version

JSON →
library2.0.1jsnpmunverified

A utility to extract the version string from a MongoDB Crypt shared library (e.g., mongo_crypt_v1.so). v2.0.1 is the current stable release; it provides both a programmatic API and a CLI. Ships TypeScript types. Useful for verifying or logging the crypt library version in applications using MongoDB's client-side encryption. Lightweight with no runtime dependencies.

npm install mongodb-crypt-library-version
INSTALL
IMPORT
SIG · MONGODB-CRYPT-LIBR
M
mongodb-crypt-library-version
databasejavascriptv2.0.1
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

getCryptLibraryVersion
import { getCryptLibraryVersion } from 'mongodb-crypt-library-version'
const getCryptLibraryVersion = require('mongodb-crypt-library-version').getCryptLibraryVersion
ESM-only; named export.
main (CLI)
npx mongodb-crypt-library-version lib/mongo_crypt_v1.so
npx mongodb-crypt-library-version -f lib/mongo_crypt_v1.so
CLI expects path as first positional argument, not a flag.
TypeScript type
import type { CryptLibraryVersion } from 'mongodb-crypt-library-version'
Type is exported for TypeScript users.

Reads a MongoDB Crypt shared library file and extracts its version string using the programmatic API.

import { getCryptLibraryVersion } from 'mongodb-crypt-library-version'; import { readFile } from 'node:fs/promises'; async function main() { const buffer = await readFile('/path/to/mongo_crypt_v1.so'); const version = getCryptLibraryVersion(buffer); console.log(version); } main().catch(console.error);
Debug
Known issues
gotchaVersion detection relies on the shared library's embedded version string; incorrectly built libraries may return undefined.
fix
Ensure the library was built with proper version metadata (e.g., from the MongoDB driver package).
affects: all
gotchaThe input must be a Buffer containing the raw library bytes; passing a file path will not work.
fix
Read the file with fs.readFile or similar before calling getCryptLibraryVersion.
affects: all
gotchaRequires Node.js 14 or higher due to ESM and modern JavaScript features.
fix
Use Node.js 14+ or consider older versions (v1.x) if needed.
affects: all
Errors
Common errors & fixes
Error: Cannot find module 'mongodb-crypt-library-version'
Package not installed or not in node_modules.
fix
Run 'npm install mongodb-crypt-library-version' or 'yarn add mongodb-crypt-library-version'.
TypeError: getCryptLibraryVersion is not a function
Default import used instead of named import (ESM vs CJS).
fix
Use named import: import { getCryptLibraryVersion } from 'mongodb-crypt-library-version'.
Error: Expected a Buffer, got string
Passing a file path instead of file contents.
fix
Read file contents first: const buffer = fs.readFileSync('path'); getCryptLibraryVersion(buffer);
Upgrade
Version history
2.0.1latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
9 hits · last 30 days
node
8
Resources
mongodb-crypt-library-version — npm install mongodb-crypt-library-version · libregistry