Skip to content

[Feature] Allow Node elements to be used as AttributeValue #97

@mandalornl

Description

@mandalornl

Hi! 👋

Firstly, thanks for your work on this project! 🙂

Today I used patch-package to patch saml@3.0.1 for the project I'm working on.

I needed to add some Node elements with specific attributes as AttributeValue in order to create a certain assertion and the current version only allows for textContent to be used. Here is the diff that solved my problem:

diff --git a/node_modules/saml/lib/saml20.js b/node_modules/saml/lib/saml20.js
index 9db8141..1ff00f4 100644
--- a/node_modules/saml/lib/saml20.js
+++ b/node_modules/saml/lib/saml20.js
@@ -216,7 +216,11 @@ function createAssertion(options, strategies, callback) {
           // Ignore undefined values in Array
           var valueElement = doc.createElementNS(NAMESPACE, 'saml:AttributeValue');
           valueElement.setAttribute('xsi:type', options.typedAttributes ? getAttributeType(value) : 'xs:anyType');
-          valueElement.textContent = value;
+          if ('nodeType' in Object(value)) {
+            valueElement.appendChild(value);
+          } else {
+            valueElement.textContent = value;
+          }
           attributeElement.appendChild(valueElement);
         }
       });

This issue body was partially generated by patch-package.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions