var xmldom = require('xmldom')
  , xpath = require('xpath')
  , saml2json = {}
  ;

saml2json.parse = function(response){

  var xml = new Buffer(response, 'base64').toString('ascii')
    , doc = new xmldom.DOMParser().parseFromString(xml)
    , profile = {}, attributes
    ;

  attributes = xpath.select('//*[local-name() = "AttributeStatement"]/*', doc);
  attributes.forEach(function(attribute){
    var name = xpath.select('string(@Name)', attribute).toLowerCase();    
    profile[name] = xpath.select('string(*[local-name() = "AttributeValue"]/text())', attribute);
  });

  return profile;
  
};

module.exports = saml2json;

@@ -1,12 +1,145 @@
+// Saml2js%0A// =======%0A// A library for parsing SAML attributes%0A// into a POJO (Plain Old JavaScript Object)%0A%0A// Require dependencies%0A
 var xmldom =
@@ -137,16 +137,19 @@
  xmldom 
+   
 = requir
@@ -163,19 +163,24 @@
 om')
+,
 %0A  
-,
+ 
  xpath 
+    
 = re
@@ -197,71 +197,520 @@
 th')
+,
 %0A  
-, saml2json = %7B%7D%0A  ;%0A%0Asaml2json.parse = function(response)%7B%0A
+  _         = require('lodash'),%0A    profile   = %7B%7D,%0A    attributes;%0A%0A%0A// Saml2js%0A// -------%0A// Constructor function. Saves a copy%0A// of the raw SAML you pass to it and %0A// a copy that's parsed into a JS object.%0A//%0A// %60response%60 %5BString%5D - A SAML response string%0Afunction Saml2js (response) %7B%0A  this.rawSaml    = response;%0A  this.parsedSaml = this.parse(response);%0A%7D%0A%0A// Saml2js.parse%0A// -------------%0A// Private function.%0A// Parses raw SAML assertion to JS object.%0ASaml2js.prototype.parse = function(saml) %7B
 %0A  v
@@ -716,16 +716,22 @@
 var xml 
+      
 = new Bu
@@ -735,24 +735,20 @@
  Buffer(
-response
+saml
 , 'base6
@@ -772,19 +772,26 @@
 ii')
+,
 %0A    
-,
+ 
  doc 
+      
 = ne
@@ -835,44 +835,8 @@
 xml)
-%0A    , profile = %7B%7D, attributes%0A    
 ;%0A%0A 
@@ -1015,22 +1015,8 @@
 ute)
-.toLowerCase()
 ;   
@@ -1029,20 +1029,33 @@
 profile%5B
+_.camelCase(
 name
+)
 %5D = xpat
@@ -1157,39 +1157,1049 @@
 le;%0A
-  %0A%7D;%0A%0Amodule.exports = saml2json
+%7D;%0A%0A%0A// Saml2js.toJSON%0A// --------------%0A// Returns parsed SAML as a JSON string.%0A// (Basically just an alias to %60JSON.stringify()%60).%0ASaml2js.prototype.toJSON = function(obj) %7B%0A  return JSON.stringify(obj);%0A%7D;%0A%0A// Saml2js.get%0A// -----------%0A// Get the value of a SAML attribute by using its%0A// original SAML attribute Name from the raw XML.%0A//%0A// %60key%60 %5BString%5D - The attribute name as it appears in the raw SAML%0A//%0A// Example:%0A//     // Given the following SAML/XML%0A//     // %3Csaml2:Attribute Name=%22First Name%22%3E%0A//     //   %3Csaml2:AttributeValue%3EJohn%3C/saml2:AttributeValue%3E%0A//     // %3C/saml2:Attribute%3E%0A//     console.log(parser.get('first name')); //=%3E John%0ASaml2js.prototype.get = function(key) %7B%0A  return this.parsedSaml%5B_.camelCase(key)%5D;%0A%7D;%0A%0A// Saml2js.toObject%0A// ----------------%0A// Returns the parsed SAML as a JS object.%0A// This does not do any further processing, it%0A// just returns the object's internal value%0A// of %60this.parsedSaml%60.%0ASaml2js.prototype.toObject = function() %7B%0A  return this.parsedSaml;%0A%7D;%0A%0Amodule.exports = Saml2js
 ;%0A

Refactor and add additional methods to the saml2json library. This breaks compatibility with upstream and should now be considered a totally different module.