Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
}},
constructAssertion(sp, idp, inResponseTo, nameID, attributes, now, destinationURL)
]
})
.end();
// encrypt if necessary
if (sp.requireEncryptedResponses || idp.encryptAllResponses) {
const encryptCredential = credentials.getCredentialsFromEntity(sp, "encryption")[0];
if (!encryptCredential) {
throw new errors.ProtocolError("Unable to encrypt assertion; no credential provided");
}
// re-parse with xmldom, encrypt (not fast, but not heinous), serialize
const doc = new xmldom.DOMParser().parseFromString(xml);
encryption.encryptAssertion(doc, encryptCredential);
xml = new xmldom.DOMSerializer().serializeToString(doc);
}
return Promise.resolve(xml);
}