npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

saml-sp

v1.0.3

Published

SAML-SP is a simple node.js library that allows for easy SAML service provider entity creation along with its RSA key-pairs and the decryption of assertions.

Readme

SAML-SP

SAML Service Provider Node.js Library

SAML-SP is a simple node.js library that allows for easy SAML service provider entity creation along with its RSA key-pairs and the decryption of assertions.

Features

  • Generate RSA key-pairs or use existing ones.
  • Create the service provider metadata file to be uploaded to the Identity provider.
  • Formats and decrypts the assertions from the SAML response.

Installation

npm i saml-sp

Examples

1. Configure the Service provider

const SAML = require("saml-sp");
const assertionEndpoint = "http://localhost:8888/saml/consume";

let sp = new SAML.ServiceProvider({
    assertionEndpoint: assertionEndpoint
});

sp.saveRSAKeys(); // this will save the private key and certificate in the current directory
sp.createMetaData(); // this will save the metadata.xml file in the current directory

2. Reading the SAMLResponse

const SAML     = require("saml-sp");
const express  = require('express');
let app        = express();

const IDP_URL = "https://[IDP]/sso/saml"; // Okta or AWS

app.get('/login', function(req, res){
    let SAMLRequest     = new SAML.Request(IDP_URL, REDIRECT_URI);
    let authNRequestURL = SAMLRequest.createAuthNURL();

    // if okta then do not use the authNRequest URL
    res.redirect(IDP_URL);

    /* if authenticating against AWS SSO then use the authNRequestURL
        res.redirect(authNRequestURL);
    */
});

app.post('/saml/consume', function(req, res, next){
    let SAMLResponse = new SAML.Response(req);
    SAMLResponse.decryptAssertions().then((decrypted_assertions) => {
        console.log(decrypted_assertions);
    });
});

app.get('/saml/consume', function(req,res){
    res.redirect("/login");
});

app.listen(8888);

Library Components

The library exposes three different classes each one is used for a different phase of the SAML implementation as follows:

1. Service provider Class

let sp = new SAML.ServiceProvider(options); The options is an object that can have the following attributes: | Attrbute | note | | ------ | ------ | | assertionEndpoint (*Required*) | The redirect URI after a successful authentication with the IDP | | encyptionKeyLength | The length of the encryption key. default=1024 | | certificate | Supply a PEM certificate if you already have one, otherwise one will be created for you. | | privateKey | Supply a PEM Private Key if you already have one, otherwise one will be created for you. | | entityID | An optional entity ID to be added to your SAML requests. |

2. Request Class

let sp = new SAML.Request(IDP_URL, ASSERTION_ENDPOINT);
let authNRequestURL = SAMLRequest.createAuthNURL();

Used to create the AuthNRequest for Identity providers such as AWS SSO, please note that some Identity providers like okta do not expect a SAML request in the URL therefore the user should be redirected to the SSO url without using this option.

| Attrbute | note | | ------ | ------ | | IDP_URL (*Required*) | The SSO URL given to you by the Identity provider, this is where users go to authenticate. | | ASSERTION_ENDPOINT (*Required*) | The redirect URI after a successful authentication with the IDP |

3. Response Class

let SAMLResponse = new SAML.Response(req);
SAMLResponse.decryptAssertions().then((decrypted_assertion) => {
    console.log(decrypted_assertion);
});

This class is used to interpret the SAMLResponse and decrypt the assertions. | Attrbute | note | | ------ | ------ | | req (*Required*) | The req object given by express js POST route. |

License

MIT