-
Notifications
You must be signed in to change notification settings - Fork 190
Open
Description
The callback handler is invoked twice when there is an unhandled exception in the callback, eg:
const { SignedXml } = require("xml-crypto");
const crypto = require("crypto");
const xml = `<x xmlns:wsu='http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd' Id='_1'></x>`;
const sig = new SignedXml();
sig.privateKey = crypto.generateKeyPairSync("rsa", {
modulusLength: 2048,
privateKeyEncoding: {
type: "pkcs1",
format: "pem"
}
}).privateKey;
sig.canonicalizationAlgorithm = "http://www.w3.org/2001/10/xml-exc-c14n#";
sig.signatureAlgorithm = "http://www.w3.org/2000/09/xmldsig#rsa-sha1";
sig.computeSignature(xml, (err, result) => {
console.log("Callback invoked", !!err, !!result);
throw new Error('Error Thrown');
});
// Results in:
// Callback invoked false true
// Callback invoked true false
// Error: Error ThrownThe callback should only be invoked a single time, eg:
require('fs').readdir(".", (err, files) => {
console.log("Callback invoked", !!err, !!files);
throw new Error('Error Thrown');
});
// Results in:
// Callback invoked false true
// Error: Error ThrownI believe the problem is the synchronous execution of the callback in https://github.com/node-saml/xml-crypto/blob/master/src/types.ts#L259
Metadata
Metadata
Assignees
Labels
No labels