Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

saml2-js

Package Overview
Dependencies
Maintainers
5
Versions
60
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

saml2-js - npm Package Compare versions

Comparing version 1.11.1 to 1.12.1

210

lib-js/saml2.js

@@ -1,7 +0,7 @@

// Generated by CoffeeScript 1.7.1
var IdentityProvider, SAMLError, ServiceProvider, SignedXml, XMLNS, add_namespaces_to_child_assertions, async, certificate_to_keyinfo, check_saml_signature, check_status_success, create_authn_request, create_logout_request, create_logout_response, create_metadata, crypto, debug, decrypt_assertion, extract_certificate_data, format_pem, get_attribute_value, get_name_id, get_session_info, get_signed_data, get_status, parseString, parse_assertion_attributes, parse_authn_response, parse_logout_request, parse_response_header, pretty_assertion_attributes, set_option_defaults, sign_authn_request, sign_request, to_error, url, util, xmlbuilder, xmlcrypto, xmldom, xmlenc, zlib, _,
__hasProp = {}.hasOwnProperty,
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
__slice = [].slice,
__bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
// Generated by CoffeeScript 1.12.7
var IdentityProvider, SAMLError, ServiceProvider, SignedXml, XMLNS, _, add_namespaces_to_child_assertions, async, certificate_to_keyinfo, check_saml_signature, check_status_success, create_authn_request, create_logout_request, create_logout_response, create_metadata, crypto, debug, decrypt_assertion, extract_certificate_data, format_pem, get_attribute_value, get_name_id, get_session_info, get_signed_data, get_status, parseString, parse_assertion_attributes, parse_authn_response, parse_logout_request, parse_response_header, pretty_assertion_attributes, set_option_defaults, sign_authn_request, sign_request, to_error, url, util, xmlbuilder, xmlcrypto, xmldom, xmlenc, zlib,
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
hasProp = {}.hasOwnProperty,
slice = [].slice,
bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };

@@ -43,4 +43,4 @@ _ = require('underscore');

SAMLError = (function(_super) {
__extends(SAMLError, _super);
SAMLError = (function(superClass) {
extend(SAMLError, superClass);

@@ -107,24 +107,24 @@ function SAMLError(message, extra) {

signing_cert_descriptors = (function() {
var _i, _len, _ref, _results;
_ref = signing_certificates || [];
_results = [];
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
signing_certificate = _ref[_i];
_results.push({
var j, len, ref1, results;
ref1 = signing_certificates || [];
results = [];
for (j = 0, len = ref1.length; j < len; j++) {
signing_certificate = ref1[j];
results.push({
'md:KeyDescriptor': certificate_to_keyinfo('signing', signing_certificate)
});
}
return _results;
return results;
})();
encryption_cert_descriptors = (function() {
var _i, _len, _ref, _results;
_ref = encryption_certificates || [];
_results = [];
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
encryption_certificate = _ref[_i];
_results.push({
var j, len, ref1, results;
ref1 = encryption_certificates || [];
results = [];
for (j = 0, len = ref1.length; j < len; j++) {
encryption_certificate = ref1[j];
results.push({
'md:KeyDescriptor': certificate_to_keyinfo('encryption', encryption_certificate)
});
}
return _results;
return results;
})();

@@ -216,3 +216,3 @@ return xmlbuilder.create({

action = response ? "SAMLResponse" : "SAMLRequest";
data = ("" + action + "=") + encodeURIComponent(saml_request);
data = (action + "=") + encodeURIComponent(saml_request);
if (relay_state) {

@@ -222,3 +222,3 @@ data += "&RelayState=" + encodeURIComponent(relay_state);

data += "&SigAlg=" + encodeURIComponent('http://www.w3.org/2001/04/xmldsig-more#rsa-sha256');
saml_request_data = ("" + action + "=") + encodeURIComponent(saml_request);
saml_request_data = (action + "=") + encodeURIComponent(saml_request);
relay_state_data = relay_state != null ? "&RelayState=" + encodeURIComponent(relay_state) : "";

@@ -288,3 +288,3 @@ sigalg_data = "&SigAlg=" + encodeURIComponent('http://www.w3.org/2001/04/xmldsig-more#rsa-sha256');

return _.map(references, function(ref) {
var elem, idAttribute, uri, _i, _len, _ref;
var elem, idAttribute, j, len, ref1, uri;
uri = ref.uri;

@@ -298,5 +298,5 @@ if (uri[0] === '#') {

} else {
_ref = ["Id", "ID"];
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
idAttribute = _ref[_i];
ref1 = ["Id", "ID"];
for (j = 0, len = ref1.length; j < len; j++) {
idAttribute = ref1[j];
elem = xmlcrypto.xpath(doc, "//*[@*[local-name(.)='" + idAttribute + "']='" + uri + "']");

@@ -316,3 +316,3 @@ if (elem.length > 0) {

check_status_success = function(dom) {
var status, status_code, _i, _len, _ref;
var j, len, ref1, status, status_code;
status = dom.getElementsByTagNameNS(XMLNS.SAMLP, 'Status');

@@ -322,5 +322,5 @@ if (status.length !== 1) {

}
_ref = status[0].childNodes || [];
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
status_code = _ref[_i];
ref1 = status[0].childNodes || [];
for (j = 0, len = ref1.length; j < len; j++) {
status_code = ref1[j];
if (status_code.attributes != null) {

@@ -335,3 +335,3 @@ status = get_attribute_value(status_code, 'Value');

get_status = function(dom) {
var status, status_code, status_list, sub_status_code, top_status, _i, _j, _len, _len1, _ref, _ref1;
var j, l, len, len1, ref1, ref2, status, status_code, status_list, sub_status_code, top_status;
status_list = {};

@@ -342,5 +342,5 @@ status = dom.getElementsByTagNameNS(XMLNS.SAMLP, 'Status');

}
_ref = status[0].childNodes || [];
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
status_code = _ref[_i];
ref1 = status[0].childNodes || [];
for (j = 0, len = ref1.length; j < len; j++) {
status_code = ref1[j];
if (status_code.attributes != null) {

@@ -352,5 +352,5 @@ top_status = get_attribute_value(status_code, 'Value');

}
_ref1 = status_code.childNodes || [];
for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) {
sub_status_code = _ref1[_j];
ref2 = status_code.childNodes || [];
for (l = 0, len1 = ref2.length; l < len1; l++) {
sub_status_code = ref2[l];
if ((sub_status_code != null ? sub_status_code.attributes : void 0) != null) {

@@ -379,5 +379,5 @@ status = get_attribute_value(sub_status_code, 'Value');

var args, err, fn;
fn = arguments[0], err = arguments[1], args = 3 <= arguments.length ? __slice.call(arguments, 2) : [];
fn = arguments[0], err = arguments[1], args = 3 <= arguments.length ? slice.call(arguments, 2) : [];
return setTimeout((function() {
return fn.apply(null, [to_error(err)].concat(__slice.call(args)));
return fn.apply(null, [to_error(err)].concat(slice.call(args)));
}), 0);

@@ -412,4 +412,4 @@ });

});
} catch (_error) {
err = _error;
} catch (error) {
err = error;
return cb(new Error("Decrypt failed: " + (util.inspect(err))));

@@ -420,6 +420,6 @@ }

parse_response_header = function(dom) {
var response, response_header, response_type, version, _i, _len, _ref;
_ref = ['Response', 'LogoutResponse', 'LogoutRequest'];
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
response_type = _ref[_i];
var j, len, ref1, response, response_header, response_type, version;
ref1 = ['Response', 'LogoutResponse', 'LogoutRequest'];
for (j = 0, len = ref1.length; j < len; j++) {
response_type = ref1[j];
response = dom.getElementsByTagNameNS(XMLNS.SAMLP, response_type);

@@ -447,3 +447,3 @@ if (response.length > 0) {

get_name_id = function(dom) {
var assertion, nameid, subject, _ref;
var assertion, nameid, ref1, subject;
assertion = dom.getElementsByTagNameNS(XMLNS.SAML, 'Assertion');

@@ -461,7 +461,7 @@ if (assertion.length !== 1) {

}
return (_ref = nameid[0].firstChild) != null ? _ref.data : void 0;
return (ref1 = nameid[0].firstChild) != null ? ref1.data : void 0;
};
get_attribute_value = function(node, attributeName) {
var attribute, attributes, _ref;
var attribute, attributes, ref1;
attributes = node.attributes || [];

@@ -471,3 +471,3 @@ attribute = _.filter(attributes, function(attr) {

});
return (_ref = attribute[0]) != null ? _ref.value : void 0;
return (ref1 = attribute[0]) != null ? ref1.value : void 0;
};

@@ -499,3 +499,3 @@

parse_assertion_attributes = function(dom) {
var assertion, assertion_attributes, attribute, attribute_name, attribute_statement, attribute_values, _i, _len, _ref;
var assertion, assertion_attributes, attribute, attribute_name, attribute_statement, attribute_values, j, len, ref1;
assertion = dom.getElementsByTagNameNS(XMLNS.SAML, 'Assertion');

@@ -513,5 +513,5 @@ if (assertion.length !== 1) {

assertion_attributes = {};
_ref = attribute_statement[0].getElementsByTagNameNS(XMLNS.SAML, 'Attribute');
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
attribute = _ref[_i];
ref1 = attribute_statement[0].getElementsByTagNameNS(XMLNS.SAML, 'Attribute');
for (j = 0, len = ref1.length; j < len; j++) {
attribute = ref1[j];
attribute_name = get_attribute_value(attribute, 'Name');

@@ -523,4 +523,4 @@ if (attribute_name == null) {

assertion_attributes[attribute_name] = _(attribute_values).map(function(attribute_value) {
var _ref1;
return ((_ref1 = attribute_value.childNodes[0]) != null ? _ref1.data : void 0) || '';
var ref2;
return ((ref2 = attribute_value.childNodes[0]) != null ? ref2.data : void 0) || '';
});

@@ -553,9 +553,9 @@ }

};
return _(assertion_attributes).chain().pairs().filter(function(_arg) {
return _(assertion_attributes).chain().pairs().filter(function(arg) {
var k, v;
k = _arg[0], v = _arg[1];
k = arg[0], v = arg[1];
return (claim_map[k] != null) && v.length > 0;
}).map(function(_arg) {
}).map(function(arg) {
var k, v;
k = _arg[0], v = _arg[1];
k = arg[0], v = arg[1];
return [claim_map[k], v[0]];

@@ -566,3 +566,3 @@ }).object().value();

add_namespaces_to_child_assertions = function(xml_string) {
var assertion_element, assertion_elements, attr, doc, inclusive_namespaces, namespaces, new_attribute, ns, prefixList, response_element, response_elements, _i, _len, _ref;
var assertion_element, assertion_elements, attr, doc, inclusive_namespaces, j, len, namespaces, new_attribute, ns, prefixList, ref1, response_element, response_elements;
doc = new xmldom.DOMParser().parseFromString(xml_string);

@@ -580,25 +580,25 @@ response_elements = doc.getElementsByTagNameNS(XMLNS.SAMLP, 'Response');

inclusive_namespaces = assertion_element.getElementsByTagNameNS(XMLNS.EXC_C14N, 'InclusiveNamespaces')[0];
namespaces = inclusive_namespaces && (prefixList = (_ref = inclusive_namespaces.getAttribute('PrefixList')) != null ? _ref.trim() : void 0) ? (function() {
var _i, _len, _ref1, _results;
_ref1 = prefixList.split(' ');
_results = [];
for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
ns = _ref1[_i];
_results.push("xmlns:" + ns);
namespaces = inclusive_namespaces && (prefixList = (ref1 = inclusive_namespaces.getAttribute('PrefixList')) != null ? ref1.trim() : void 0) ? (function() {
var j, len, ref2, results;
ref2 = prefixList.split(' ');
results = [];
for (j = 0, len = ref2.length; j < len; j++) {
ns = ref2[j];
results.push("xmlns:" + ns);
}
return _results;
return results;
})() : (function() {
var _i, _len, _ref1, _results;
_ref1 = response_element.attributes;
_results = [];
for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
attr = _ref1[_i];
var j, len, ref2, results;
ref2 = response_element.attributes;
results = [];
for (j = 0, len = ref2.length; j < len; j++) {
attr = ref2[j];
if (attr.name.match(/^xmlns:/)) {
_results.push(attr.name);
results.push(attr.name);
}
}
return _results;
return results;
})();
for (_i = 0, _len = namespaces.length; _i < _len; _i++) {
ns = namespaces[_i];
for (j = 0, len = namespaces.length; j < len; j++) {
ns = namespaces[j];
if (response_element.getAttribute(ns) && !assertion_element.getAttribute(ns)) {

@@ -633,3 +633,3 @@ new_attribute = doc.createAttribute(ns);

}, function(result, cb_wf) {
var assertion, cert, ex, i, saml_response_str, sd, signed_data, signed_dom, _i, _j, _len, _len1, _ref;
var assertion, cert, ex, i, j, l, len, len1, ref1, saml_response_str, sd, signed_data, signed_dom;
debug(result);

@@ -640,9 +640,9 @@ if (ignore_signature) {

saml_response_str = saml_response.toString();
_ref = idp_certificates || [];
for (i = _i = 0, _len = _ref.length; _i < _len; i = ++_i) {
cert = _ref[i];
ref1 = idp_certificates || [];
for (i = j = 0, len = ref1.length; j < len; i = ++j) {
cert = ref1[i];
try {
signed_data = check_saml_signature(result, cert) || check_saml_signature(saml_response_str, cert);
} catch (_error) {
ex = _error;
} catch (error) {
ex = error;
return cb_wf(new Error("SAML Assertion signature check failed! (Certificate \#" + (i + 1) + " may be invalid. " + ex.message));

@@ -653,4 +653,4 @@ }

}
for (_j = 0, _len1 = signed_data.length; _j < _len1; _j++) {
sd = signed_data[_j];
for (l = 0, len1 = signed_data.length; l < len1; l++) {
sd = signed_data[l];
signed_dom = (new xmldom.DOMParser()).parseFromString(sd);

@@ -682,4 +682,4 @@ assertion = signed_dom.getElementsByTagNameNS(XMLNS.SAML, 'Assertion');

});
} catch (_error) {
err = _error;
} catch (error) {
err = error;
return cb_wf(err);

@@ -692,3 +692,3 @@ }

parse_logout_request = function(dom) {
var issuer, name_id, request, session_index, _ref, _ref1, _ref2;
var issuer, name_id, ref1, ref2, ref3, request, session_index;
request = dom.getElementsByTagNameNS(XMLNS.SAMLP, "LogoutRequest");

@@ -701,11 +701,11 @@ if (request.length !== 1) {

if (issuer.length === 1) {
request.issuer = (_ref = issuer[0].firstChild) != null ? _ref.data : void 0;
request.issuer = (ref1 = issuer[0].firstChild) != null ? ref1.data : void 0;
}
name_id = dom.getElementsByTagNameNS(XMLNS.SAML, 'NameID');
if (name_id.length === 1) {
request.name_id = (_ref1 = name_id[0].firstChild) != null ? _ref1.data : void 0;
request.name_id = (ref2 = name_id[0].firstChild) != null ? ref2.data : void 0;
}
session_index = dom.getElementsByTagNameNS(XMLNS.SAMLP, 'SessionIndex');
if (session_index.length === 1) {
request.session_index = (_ref2 = session_index[0].firstChild) != null ? _ref2.data : void 0;
request.session_index = (ref3 = session_index[0].firstChild) != null ? ref3.data : void 0;
}

@@ -721,4 +721,4 @@ return request;

function ServiceProvider(options) {
this.create_metadata = __bind(this.create_metadata, this);
this.create_logout_request_url = __bind(this.create_logout_request_url, this);
this.create_metadata = bind(this.create_metadata, this);
this.create_logout_request_url = bind(this.create_logout_request_url, this);
this.entity_id = options.entity_id, this.private_key = options.private_key, this.certificate = options.certificate, this.assert_endpoint = options.assert_endpoint, this.alt_private_keys = options.alt_private_keys, this.alt_certs = options.alt_certs;

@@ -731,5 +731,5 @@ this.alt_private_keys = [].concat(this.alt_private_keys || []);

ServiceProvider.prototype.create_login_request_url = function(identity_provider, options, cb) {
var id, xml, _ref;
var id, ref1, xml;
options = set_option_defaults(options, identity_provider.shared_options, this.shared_options);
_ref = create_authn_request(this.entity_id, this.assert_endpoint, identity_provider.sso_login_url, options.force_authn, options.auth_context, options.nameid_format), id = _ref.id, xml = _ref.xml;
ref1 = create_authn_request(this.entity_id, this.assert_endpoint, identity_provider.sso_login_url, options.force_authn, options.auth_context, options.nameid_format), id = ref1.id, xml = ref1.xml;
return zlib.deflateRaw(xml, (function(_this) {

@@ -757,5 +757,5 @@ return function(err, deflated) {

ServiceProvider.prototype.create_authn_request_xml = function(identity_provider, options) {
var id, xml, _ref;
var id, ref1, xml;
options = set_option_defaults(options, identity_provider.shared_options, this.shared_options);
_ref = create_authn_request(this.entity_id, this.assert_endpoint, identity_provider.sso_login_url, options.force_authn, options.auth_context, options.nameid_format), id = _ref.id, xml = _ref.xml;
ref1 = create_authn_request(this.entity_id, this.assert_endpoint, identity_provider.sso_login_url, options.force_authn, options.auth_context, options.nameid_format), id = ref1.id, xml = ref1.xml;
return sign_authn_request(xml, this.private_key, options);

@@ -785,4 +785,4 @@ };

ServiceProvider.prototype._assert = function(identity_provider, options, cb) {
var response, saml_response, _ref, _ref1;
if (!((((_ref = options.request_body) != null ? _ref.SAMLResponse : void 0) != null) || (((_ref1 = options.request_body) != null ? _ref1.SAMLRequest : void 0) != null))) {
var ref1, ref2, response, saml_response;
if (!((((ref1 = options.request_body) != null ? ref1.SAMLResponse : void 0) != null) || (((ref2 = options.request_body) != null ? ref2.SAMLRequest : void 0) != null))) {
return setImmediate(cb, new Error("Request body does not contain SAMLResponse or SAMLRequest."));

@@ -810,4 +810,4 @@ }

};
} catch (_error) {
err = _error;
} catch (error) {
err = error;
return cb(err);

@@ -845,3 +845,3 @@ }

ServiceProvider.prototype.create_logout_request_url = function(identity_provider, options, cb) {
var id, xml, _ref;
var id, ref1, xml;
if (_.isString(identity_provider)) {

@@ -854,3 +854,3 @@ identity_provider = {

options = set_option_defaults(options, identity_provider.shared_options, this.shared_options);
_ref = create_logout_request(this.entity_id, options.name_id, options.session_index, identity_provider.sso_logout_url), id = _ref.id, xml = _ref.xml;
ref1 = create_logout_request(this.entity_id, options.name_id, options.session_index, identity_provider.sso_logout_url), id = ref1.id, xml = ref1.xml;
return zlib.deflateRaw(xml, (function(_this) {

@@ -857,0 +857,0 @@ return function(err, deflated) {

{
"name": "saml2-js",
"version": "1.11.1",
"version": "1.12.1",
"description": "SAML 2.0 node helpers",

@@ -27,15 +27,15 @@ "author": "Clever",

"devDependencies": {
"mocha": "~1.17.1",
"coffee-script": "~1.7.1"
"mocha": "^3.5.0",
"coffee-script": "^1.12.0"
},
"dependencies": {
"async": "~1.5.2",
"debug": "^2.6.x",
"underscore": "~1.6.0",
"xml-crypto": "^0.8.1",
"xml-encryption": "^0.9.0",
"xml2js": "~0.4.1",
"xmlbuilder": "~2.1.0",
"xmldom": "~0.1.19"
"async": "^2.5.0",
"debug": "^2.6.0",
"underscore": "^1.8.0",
"xml-crypto": "^0.10.0",
"xml-encryption": "^0.11.0",
"xml2js": "^0.4.0",
"xmlbuilder": "~2.2.0",
"xmldom": "^0.1.0"
}
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc