diff --git a/lib/saml11.js b/lib/saml11.js index 48c5988..40457b6 100644 --- a/lib/saml11.js +++ b/lib/saml11.js @@ -1,4 +1,3 @@ -var path = require('path'); var utils = require('./utils'); var Parser = require('@xmldom/xmldom').DOMParser; var xmlenc = require('xml-encryption'); @@ -9,7 +8,31 @@ var crypto = require('crypto'); var EncryptXml = require('./xml/encrypt'); var SignXml = require('./xml/sign'); -var newSaml11Document = utils.factoryForNode(path.join(__dirname, 'saml11.template')); +var template = ` + + + + + + + + urn:oasis:names:tc:SAML:1.0:cm:bearer + + + + + + + + + urn:oasis:names:tc:SAML:1.0:cm:bearer + + + +`; + +var newSaml11Document = utils.factoryForNode(template); var NAMESPACE = 'urn:oasis:names:tc:SAML:1.0:assertion'; diff --git a/lib/saml11.template b/lib/saml11.template deleted file mode 100644 index 531f3a7..0000000 --- a/lib/saml11.template +++ /dev/null @@ -1,23 +0,0 @@ - - - - - - - - - urn:oasis:names:tc:SAML:1.0:cm:bearer - - - - - - - - - urn:oasis:names:tc:SAML:1.0:cm:bearer - - - - diff --git a/lib/saml20.js b/lib/saml20.js index 9db8141..5b99390 100644 --- a/lib/saml20.js +++ b/lib/saml20.js @@ -1,4 +1,3 @@ -var path = require('path'); var async = require('async'); var moment = require('moment'); var xmlNameValidator = require('xml-name-validator'); @@ -8,7 +7,23 @@ var EncryptXml = require('./xml/encrypt'); var SignXml = require('./xml/sign'); var utils = require('./utils'); -var newSaml20Document = utils.factoryForNode(path.join(__dirname, 'saml20.template')); +const template = ` + + + + + + + + + + + urn:oasis:names:tc:SAML:2.0:ac:classes:unspecified + + +`; + +var newSaml20Document = utils.factoryForNode(template); var NAMESPACE = 'urn:oasis:names:tc:SAML:2.0:assertion'; diff --git a/lib/saml20.template b/lib/saml20.template deleted file mode 100644 index cd81289..0000000 --- a/lib/saml20.template +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - - - - urn:oasis:names:tc:SAML:2.0:ac:classes:unspecified - - - diff --git a/lib/utils.js b/lib/utils.js index fc425e0..2adf94b 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -67,8 +67,7 @@ function getRandomInt(min, max) { * @param {string} pathToTemplate an absolute path to a template file * @return {function(): Node} */ -exports.factoryForNode = function factoryForNode(pathToTemplate) { - const template = fs.readFileSync(pathToTemplate); +exports.factoryForNode = function factoryForNode(template) { const prototypeDoc = new Parser().parseFromString(template.toString()); return function () {