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

passport-saml-metadata

Package Overview
Dependencies
Maintainers
1
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

passport-saml-metadata - npm Package Compare versions

Comparing version 2.0.1 to 2.1.0

5

CHANGELOG.md
# Change Log
## [v2.0.1](https://github.com/compwright/passport-saml-metadata/tree/v2.0.1) (2019-08-17)
[Full Changelog](https://github.com/compwright/passport-saml-metadata/compare/v2.0.0...v2.0.1)
## [v2.0.0](https://github.com/compwright/passport-saml-metadata/tree/v2.0.0) (2019-08-17)

@@ -24,2 +27,3 @@ [Full Changelog](https://github.com/compwright/passport-saml-metadata/compare/v1.6.0...v2.0.0)

- Update superagent to the latest version 🚀 [\#10](https://github.com/compwright/passport-saml-metadata/pull/10) ([greenkeeper[bot]](https://github.com/apps/greenkeeper))
- toPassportConfig: use entryPoint for passport-saml [\#1](https://github.com/compwright/passport-saml-metadata/pull/1) ([leachiM2k](https://github.com/leachiM2k))

@@ -66,3 +70,2 @@ ## [v1.5.2](https://github.com/compwright/passport-saml-metadata/tree/v1.5.2) (2018-09-11)

- Updating Dependencies \(\#2\) [\#3](https://github.com/compwright/passport-saml-metadata/pull/3) ([TigerC10](https://github.com/TigerC10))
- toPassportConfig: use entryPoint for passport-saml [\#1](https://github.com/compwright/passport-saml-metadata/pull/1) ([leachiM2k](https://github.com/leachiM2k))

@@ -69,0 +72,0 @@ ## [v1.3.0](https://github.com/compwright/passport-saml-metadata/tree/v1.3.0) (2018-02-05)

{
"name": "passport-saml-metadata",
"version": "2.0.1",
"version": "2.1.0",
"description": "SAML2 metadata loader",

@@ -61,6 +61,6 @@ "author": {

"dependencies": {
"axios": "^0.19.0",
"debug": "^4.1.1",
"lodash": "^4.17.15",
"passport-saml": "^1.1.0",
"superagent": "^5.1.0",
"xmldom": "^0.1.27",

@@ -70,2 +70,3 @@ "xpath": "0.0.27"

"devDependencies": {
"axios-mock-adapter": "^1.17.0",
"eslint": "^6.1.0",

@@ -72,0 +73,0 @@ "mocha": "^6.2.0",

6

README.md
# passport-saml-metadata
[![Build Status](https://travis-ci.org/compwright/passport-saml-metadata.svg?branch=master)](https://travis-ci.org/compwright/passport-saml-metadata) [![Greenkeeper badge](https://badges.greenkeeper.io/compwright/passport-saml-metadata.svg)](https://greenkeeper.io/)
[![Build Status](https://travis-ci.org/compwright/passport-saml-metadata.svg?branch=master)](https://travis-ci.org/compwright/passport-saml-metadata)
[![Greenkeeper badge](https://badges.greenkeeper.io/compwright/passport-saml-metadata.svg)](https://greenkeeper.io/)

@@ -55,2 +56,3 @@ Utilities for reading configuration from SAML 2.0 Metadata XML files, such as those generated by Active Directory Federation Services (ADFS).

* `client` [Axios](https://www.npmjs.com/package/axios) instance
* `url` (required) Metadata XML file URL

@@ -60,2 +62,4 @@ * `timeout` Time to wait before falling back to the `backupStore`, in ms (default = `2000`)

Additional configuration options supported: https://github.com/axios/axios#request-config
Returns a promise which resolves, if successful, to an instance of `MetadataReader`.

@@ -62,0 +66,0 @@

const assert = require('assert');
const request = require('superagent');
const axios = require('axios');
const debug = require('debug')('passport-saml-metadata');
const defaults = {
client: axios,
responseType: 'text',
timeout: 2000,

@@ -10,4 +12,9 @@ backupStore: new Map()

module.exports = (config = {}) => {
const { url, timeout, backupStore } = Object.assign({}, defaults, config);
module.exports = async function(config = {}) {
const {
client,
url,
backupStore,
...params
} = Object.assign({}, defaults, config);

@@ -19,37 +26,37 @@ assert.ok(url, 'url is required');

debug('Loading metadata', url, timeout, backupStore);
debug('Loading metadata', url, params.timeout, backupStore);
return request.get(url)
.timeout(timeout)
.buffer(true)
.then((res) => {
debug('Metadata loaded', res.text.length);
backupStore.set(url, res.text);
return res.text;
})
.catch((err) => {
let error = err;
try {
const res = await client.get(url, params);
debug('Metadata loaded', res.headers['content-length']);
backupStore.set(url, res.data); // Save in backup store
return res.data;
} catch (err) {
let error;
if (err.response) {
error = new Error(err.response.data);
error.status = err.response.status;
} else if (err.request) {
error = new Error('Error during request, no response');
} else {
error = err;
}
// Superagent emits errors with error.response instead of error.message
if (err.response) {
error = err.response.error || new Error(err.response.body.message);
error.status = err.response.status;
debug('Metadata request failed, attempting backup store', error);
try {
// Try from backup store
const data = await Promise.resolve(backupStore.get(url));
if (data) {
debug('Metadata loaded from backupStore', data.length);
return data;
} else {
debug('Backup store was empty');
throw error;
}
debug('Metadata request failed, attempting backup store', err);
return Promise.resolve(backupStore.get(url))
.then((data) => {
if (!data) {
debug('Backup store was empty');
return Promise.reject(error);
}
debug('Metadata loaded from backupStore', data.length);
return data;
})
.catch((err) => {
debug('Backup store request error', err);
return Promise.reject(error);
});
});
} catch(err) {
debug('Backup store request error', err);
throw error;
}
}
};
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