forked from tngan/samlify
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: encryption for @xmldom/xmldom 0.8.6
`@xmldom/xmldom` 0.8.6 included: fix: Properly check nodes before replacement. xmldom/xmldom#457 Which caused the `.replaceChild` calls in `encryptAssertion` and `decryptAssertion` to error with: > "Not found: child not in parent" The root cause is a subtle difference in `@xmldom/xmldom` `Document` vs `Element` instances. The previous code was asking xmldom to replace an element from a top-level Document with another top-level Document. The patch to xmldom 0.8.6 started the enforcement of `.replaceChild` being passed `Nodes` who share a common parent Node. e.g. in the case of `encryptAssertion`: `doc.replaceChild(encryptAssertionNode, rawAssertionNode)`. It's important to distinguish that neither `doc` nor `encryptAssertionNode` are `Element` nodes, but instead `Document` Nodes. Meaning `doc` does _not_ refer to the `<samlp:Response>` node, but instead a meta object one level up. To reference the Response tag, you instead use the `Document#documentElement` attribute. Changing that line to the following as the same intended affect using the correct node references. `doc.documentElement.replaceChild(encryptAssertionNode.documentElement, rawAssertionNode)` I renamed a few of the variables in an attempt to clarify which are `Documents`. Also fixes an issue where the `ERR_NO_ASSERTION` and `ERR_UNDEFINED_ENCRYPTED_ASSERTION` errors were not being thrown if exactly zero nodes were found. fixes: tngan#495
- Loading branch information
1 parent
49295a2
commit f04359d
Showing
3 changed files
with
36 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters