const { hsm } = require("@dinamonetworks/hsm-dinamo");

// Define os parâmetros de conexão com o HSM
const options = {
host: "127.0.0.1",
authUsernamePassword: {
username: "master",
password: "12345678",
},
};

async function getScLabel() {
let conn;

try {
// Conecta ao HSM
conn = await hsm.connect(options);

// Obtém o lable do smartcard
const info = await conn.management.getScLabel("12345678");

// Exibe as informações
console.log(`Smart Card Label: ${info}`);
} catch (error) {
const errorMessage = error instanceof Error ? error.message : "An unknown error occurred.";

console.error(`An error occurred: ${errorMessage}`, error);
} finally {
if (conn) {
await conn.disconnect();
}
}
}

getScLabel();