{"version":3,"sources":["jsdelivr-header.js","/npm/nodejs-openssl-smime@0.0.1/index.js"],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA,ACNA,IAAI,KAAO,QAAQ,QACf,MAAQ,QAAQ,iBAAiB,MACjC,QAAU,QAAQ,WAoBtB,SAAS,KAAK,EAAS,GACrB,OAAO,IAAI,SAAQ,SAAU,EAAS,GAGpC,KAFA,EAAU,GAAW,CAAC,GAET,QACX,MAAM,IAAI,MAAM,oBAElB,IAAK,EAAQ,IACX,MAAM,IAAI,MAAM,gBAElB,IAAK,EAAQ,KACX,MAAM,IAAI,MAAM,wBAElB,IAAI,EAAU,KAAK,OACjB,6FACA,EAAQ,KACR,EAAQ,IACR,EAAQ,IAGN,EAAQ,WACV,GAAW,KAAK,OAAO,mBAAoB,EAAQ,WAErD,IAAI,EAAO,EAAQ,MAAM,KACrB,EAAQ,MAAM,EAAK,GAAI,EAAK,OAAO,IAEnC,EAAM,GAEV,EAAM,OAAO,GAAG,QAAQ,SAAU,GAChC,EAAI,KAAK,EACX,IAEA,EAAM,GAAG,SAAS,SAAU,GACb,IAAT,EACF,EAAO,IAAI,MAAM,oBAEjB,EAAQ,CACN,MAAO,EACP,IAAK,OAAO,OAAO,IAEzB,IAEA,EAAQ,QAAQ,KAAK,EAAM,MAC7B,IACC,QAAQ,EACX,CA9DA,QAAQ,KAAO","file":"/npm/nodejs-openssl-smime@0.0.1/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/nodejs-openssl-smime@0.0.1/index.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","var util = require('util');\nvar spawn = require('child_process').spawn;\nvar Promise = require('promise');\n\n// Expose methods.\nexports.sign = sign;\n\n/**\n * Sign a file.\n *\n * @param {object} options Options\n * @param {stream.Readable} options.content Content stream\n * @param {string} options.key Key path\n * @param {string} options.cert Cert path\n  * @param {string} options.ca CA Cert path\n * @param {string} [options.password] Key password\n * @param {function} [cb] Optional callback\n * @returns {object} result Result\n * @returns {string} result.der Der signature\n * @returns {ChildProcess} result.child Child process\n */\n\nfunction sign(options, cb) {\n  return new Promise(function (resolve, reject) {\n    options = options || {};\n\n    if (!options.content)\n      throw new Error('Invalid content.');\n\n    if (!options.key)\n      throw new Error('Invalid key.');\n\n    if (!options.cert)\n      throw new Error('Invalid certificate.');\n\n    var command = util.format(\n      'openssl smime -sign -text -signer %s -inkey %s -certfile %s -nodetach -outform der -binary',\n      options.cert,\n      options.key,\n      options.ca\n    );\n\n    if (options.password)\n      command += util.format(' -passin pass:%s', options.password);\n\n    var args = command.split(' ');\n    var child = spawn(args[0], args.splice(1));\n\n    var der = [];\n\n    child.stdout.on('data', function (chunk) {\n      der.push(chunk);\n    });\n\n    child.on('close', function (code) {\n      if (code !== 0)\n        reject(new Error('Process failed.'));\n      else\n        resolve({\n          child: child,\n          der: Buffer.concat(der)\n        });\n    });\n\n    options.content.pipe(child.stdin);\n  })\n  .nodeify(cb);\n}"]}