UNPKG

@alexssmusica/emissao-nota-fiscal

Version:
20 lines (19 loc) 893 B
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.setupLoadCertificateFromPath = void 0; const fs_1 = __importDefault(require("fs")); const errors_1 = require("../errors"); const load_certificate_1 = require("./load-certificate"); const setupLoadCertificateFromPath = () => (input) => { if (!fs_1.default.existsSync(input.path)) { throw new errors_1.CertificateNotFoundError(); } const pfx = fs_1.default.readFileSync(input.path); const p12buffer = pfx.toString('base64'); const load = (0, load_certificate_1.setupLoadCertificate)(); return load({ password: input.password, buffer: p12buffer }); }; exports.setupLoadCertificateFromPath = setupLoadCertificateFromPath;