HSM - Hardware Secure Module
The goal of this package is to provide a secure, consistent, and scalable communication layer between applications using NodeJS technology and the HSMs (Hardware Cryptographic Module) manufactured by DINAMO. This layer provides primitive cryptographic functions (signature, encryption) as well as functions from the HSM's specialized modules: Blockchain, XML signing for NFe (electronic invoice), SPB (Brazilian Payment System), and EFT (Electronic Funds Transfer).
APIs
Details of the package's APIs are available in the Javascript HSM API Documentation.
Installation
npm i @dinamonetworks/hsm-dinamo
For APIs that operate functions with smart cards, a complete installation of the HSM software is required, along with the Remote option, as well as a certified USB reader and compatible cards.
Settings
Information about logging configuration is available on the Documentation Setup Page.
Use
// Imports Dinamo HSM APIs
const { hsm } = require("@dinamonetworks/hsm-dinamo");
// Defines the connection parameters to the HSM.
const options = {
host: "127.0.0.1",
authUsernamePassword: {
username: "master",
password: "12345678",
},
};
// You can also connect using environment variables:
// HSM_HOST - HSM IP Address
// HSM_PORT - HSM Port (tcp 4433)
// HSM_USERNAME - HSM user name
// HSM_PASSWORD - HSM user password credential
async function hsmConnect() {
// Connect to HSM
const conn = await hsm.connect(options);
// Connection established
console.log("HSM connected");
// Disconnect from HSM
await conn.disconnect();
}
// Execute the hsmConnect function.
hsmConnect();
Connection Pool
For scenarios with multiple concurrent operations, use connectPooled() instead of connect(). It manages a pool of HSM sessions automatically, enabling parallel cryptographic operations without serializing on a single connection. See the Session Pool documentation for details and configuration.
Examples
Several examples using the package's APIs can be found on the Examples Page in the documentation.
Release Notes
Information regarding software versions is available in the Release Notes Page.
HSM Documentation
The complete technical documentation for the HSM (configuration, administration, integration etc) can be found in the HSM Documentation.