2.0.1 • Published 6 months ago

metadata-saml2 v2.0.1

Weekly downloads
-
License
MIT
Repository
-
Last release
6 months ago

metadata-saml2

Parse SAML metadata.xml files with minimal dependencies

Installation

npm install --save metadata-saml2

Or

yarn add metadata-saml2

Usage

Parsing from an XML file:

const { parseIDPMetadataFromFile } = require('metadata-saml2')

const metadata = await parseIDPMetadataFromFile('metadata.xml')
console.log(metadata)
/*
  Output:
  {
    entityId: 'https://sts.windows.net/12345678-1234-1234-1234-123456789012/',
    X509Certificates: ['example-cert'],
    HTTPRedirect: 'https://login.microsoftonline.com/12345678-1234-1234-1234-123456789012/saml2',
    HTTPPost: 'https://login.microsoftonline.com/12345678-1234-1234-1234-123456789012/saml2'
  }
 */

Parsing from an XML string:

const { parseIDPMetadataFromString } = require('metadata-saml2')

const xmlString = 'read the xml from a file or stream'  
const metadata = await parseIDPMetadataFromString(xmlString)
console.log(metadata)
/*
  Output:
  {
    entityId: 'https://sts.windows.net/12345678-1234-1234-1234-123456789012/',
    X509Certificates: ['example-cert'],
    HTTPRedirect: 'https://login.microsoftonline.com/12345678-1234-1234-1234-123456789012/saml2',
    HTTPPost: 'https://login.microsoftonline.com/12345678-1234-1234-1234-123456789012/saml2'
  }
 */

Parsing the certificate:

const { parseCertificate } = require('metadata-saml2')

const certString = 'read the xml from a file or stream'  
const cert = parseCertificate(certString)
console.log(cert)
/*
  Output:
  {
    issuer: {
      C: 'AU',
      O: 'Internet Widgits Pty Ltd',
      ST: 'Some-State'
    },
    subject: {
      C: 'AU',
      O: 'Internet Widgits Pty Ltd',
      ST: 'Some-State'
    },
    valid_from: 'Aug  1 13:44:57 2018 GMT',
    valid_to: 'Aug  1 13:44:57 2019 GMT'
  }
*/
2.0.1

6 months ago

2.0.0

3 years ago

1.0.0

3 years ago