Skip to content

Commit

Permalink
#274 Export without default
Browse files Browse the repository at this point in the history
  • Loading branch information
tngan committed Jun 25, 2019
1 parent 183a49f commit 23ad029
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 35 deletions.
13 changes: 9 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,15 @@ Starting from v2.6, multiple schema validators are now supported. You can simply

```js
import samlify = require('samlify');
import validator from '@authenio/samlify-xsd-schema-validator';
// import validator from '@authenio/samlify-validate-with-xmllint';
// import validator from '@authenio/samlify-node-xmllint';
// import validator from '@authenio/samlify-libxml-xsd'; // only support for version of nodejs <= 8
import * as validator from '@authenio/samlify-xsd-schema-validator';
// import * as validator from '@authenio/samlify-validate-with-xmllint';
// import * as validator from '@authenio/samlify-node-xmllint';
// import * as validator from '@authenio/samlify-libxml-xsd'; // only support for version of nodejs <= 8

// const validator = require('@authenio/samlify-xsd-schema-validator');
// const validator = require('@authenio/samlify-validate-with-xmllint');
// const validator = require('@authenio/samlify-node-xmllint');
// const validator = require('@authenio/samlify-libxml-xsd');

samlify.setSchemaValidator(validator);
```
Expand Down
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "samlify",
"version": "2.6.0-rc1",
"version": "2.6.0-rc2",
"description": "High-level API for Single Sign On (SAML 2.0)",
"main": "build/index.js",
"keywords": [
Expand Down Expand Up @@ -46,10 +46,10 @@
"xpath": "^0.0.27"
},
"devDependencies": {
"@authenio/samlify-xsd-schema-validator": "^1.0.1",
"@authenio/samlify-validate-with-xmllint": "^1.0.0",
"@authenio/samlify-node-xmllint": "^1.0.0",
"@authenio/samlify-libxml-xsd": "^1.0.0",
"@authenio/samlify-xsd-schema-validator": "^1.0.2",
"@authenio/samlify-validate-with-xmllint": "^1.0.1",
"@authenio/samlify-node-xmllint": "^1.0.1",
"@authenio/samlify-libxml-xsd": "^1.0.1",
"@types/camelcase": "^5.2.0",
"@types/node": "^11.11.3",
"@types/node-forge": "^0.7.4",
Expand Down
4 changes: 2 additions & 2 deletions src/libsaml.ts
Original file line number Diff line number Diff line change
Expand Up @@ -235,8 +235,8 @@ const libSaml = () => {
*/
attributeStatementBuilder(attributes: LoginResponseAttribute[]): string {
const attr = attributes.map(({ name, nameFormat, valueTag, valueXsiType, valueXmlnsXs, valueXmlnsXsi }) => {
const defaultValueXmlnsXs = 'http://www.w3.org/2001/XMLSchema'
const defaultValueXmlnsXsi = 'http://www.w3.org/2001/XMLSchema-instance'
const defaultValueXmlnsXs = 'http://www.w3.org/2001/XMLSchema';
const defaultValueXmlnsXsi = 'http://www.w3.org/2001/XMLSchema-instance';
return `<saml:Attribute Name="${name}" NameFormat="${nameFormat}"><saml:AttributeValue xmlns:xs="${valueXmlnsXs ? valueXmlnsXs : defaultValueXmlnsXs}" xmlns:xsi="${valueXmlnsXsi ? valueXmlnsXsi : defaultValueXmlnsXsi}" xsi:type="${valueXsiType}">{${tagging('attr', valueTag)}}</saml:AttributeValue></saml:Attribute>`;
}).join('');
return `<saml:AttributeStatement>${attr}</saml:AttributeStatement>`;
Expand Down
17 changes: 12 additions & 5 deletions test/flow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,16 @@ import { PostBindingContext } from '../src/entity';
import * as uuid from 'uuid';
import * as url from 'url';
import util from '../src/utility';
import validator from '@authenio/samlify-xsd-schema-validator';
// import validator from '@authenio/samlify-validate-with-xmllint';
// import validator from '@authenio/samlify-node-xmllint';
// import validator from '@authenio/samlify-libxml-xsd';

import * as validator from '@authenio/samlify-xsd-schema-validator';
// import * as validator from '@authenio/samlify-validate-with-xmllint';
// import * as validator from '@authenio/samlify-node-xmllint';
// import * as validator from '@authenio/samlify-libxml-xsd';

// const validator = require('@authenio/samlify-xsd-schema-validator');
// const validator = require('@authenio/samlify-validate-with-xmllint');
// const validator = require('@authenio/samlify-node-xmllint');
// const validator = require('@authenio/samlify-libxml-xsd');

esaml2.setSchemaValidator(validator);

Expand All @@ -33,6 +39,8 @@ const loginResponseTemplate = {
],
};

const failedResponse: string = String(readFileSync('./test/misc/failed_response.xml'));

const createTemplateCallback = (_idp, _sp, user) => template => {
const _id = '_8e8dc5f69a98cc4c1ff3427e5ce34606fd672f91e6';
const now = new Date();
Expand Down Expand Up @@ -659,7 +667,6 @@ test('should reject signature wrapped response - case 2', async t => {
});

test('should throw two-tiers code error when the response does not return success status', async t => {
const failedResponse: string = String(readFileSync('./test/misc/failed_response.xml'));
try {
const _result = await sp.parseLoginResponse(idpNoEncrypt, 'post', { body: { SAMLResponse: utility.base64Encode(failedResponse) } });
} catch (e) {
Expand Down
3 changes: 2 additions & 1 deletion tslint.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@
"ordered-imports": false,
"quotemark": [true, "single", "avoid-escape", "avoid-template"],
"variable-name": [true, "ban-keywords", "check-format", "allow-leading-underscore", "allow-pascal-case"],
"interface-over-type-literal": false
"interface-over-type-literal": false,
"no-var-requires": false
},
"jsRules": {}
}
30 changes: 12 additions & 18 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,27 @@
# yarn lockfile v1


"@authenio/samlify-libxml-xsd@^1.0.0":
version "1.0.0"
resolved "https://registry.yarnpkg.com/@authenio/samlify-libxml-xsd/-/samlify-libxml-xsd-1.0.0.tgz#0795248729ec4c1fb7bb259d859ce4be4343b830"
"@authenio/samlify-libxml-xsd@^1.0.1":
version "1.0.1"
resolved "https://registry.yarnpkg.com/@authenio/samlify-libxml-xsd/-/samlify-libxml-xsd-1.0.1.tgz#4d15fc66ac76c4b852d1985f07c3d765fd6d497e"
dependencies:
libxml-xsd "^0.5.2"

"@authenio/samlify-node-xmllint@^1.0.0":
version "1.0.0"
resolved "https://registry.yarnpkg.com/@authenio/samlify-node-xmllint/-/samlify-node-xmllint-1.0.0.tgz#1633baae0f8c749e62bf2dc2365cca9610b68031"
"@authenio/samlify-node-xmllint@^1.0.1":
version "1.0.1"
resolved "https://registry.yarnpkg.com/@authenio/samlify-node-xmllint/-/samlify-node-xmllint-1.0.1.tgz#325659eed8b561fcdc2a15e187b8f052fbb7c172"
dependencies:
node-xmllint "^1.0.0"

"@authenio/samlify-validate-with-xmllint@^1.0.0":
version "1.0.0"
resolved "https://registry.yarnpkg.com/@authenio/samlify-validate-with-xmllint/-/samlify-validate-with-xmllint-1.0.0.tgz#6ea47cacc234963769bed21388df48fec45962f6"
"@authenio/samlify-validate-with-xmllint@^1.0.1":
version "1.0.1"
resolved "https://registry.yarnpkg.com/@authenio/samlify-validate-with-xmllint/-/samlify-validate-with-xmllint-1.0.1.tgz#9fdf4e44e657e6863e32acc33bdeaff59276459a"
dependencies:
validate-with-xmllint "^1.0.2"

"@authenio/samlify-xsd-schema-validator@^1.0.1":
version "1.0.1"
resolved "https://registry.yarnpkg.com/@authenio/samlify-xsd-schema-validator/-/samlify-xsd-schema-validator-1.0.1.tgz#940d641cf6b4959e0dc9a850c789c10edbe9d1dd"
"@authenio/samlify-xsd-schema-validator@^1.0.2":
version "1.0.2"
resolved "https://registry.yarnpkg.com/@authenio/samlify-xsd-schema-validator/-/samlify-xsd-schema-validator-1.0.2.tgz#ba150e1e04cce71093941c715a873f4d0b76e606"
dependencies:
"@authenio/xsd-schema-validator" "^0.7.1"

Expand Down Expand Up @@ -987,7 +987,6 @@ commander@^2.12.1:
commander@~2.20.0:
version "2.20.0"
resolved "https://registry.yarnpkg.com/commander/-/commander-2.20.0.tgz#d58bb2b5c1ee8f87b0d340027e9e94e222c5a422"
integrity sha512-7j2y+40w61zy6YC2iRNpUe/NwhNyoXrYpHMrSunaMG64nRnaf96zO/KMQR4OyN/UnE5KLyEBnKHd4aG3rskjpQ==

common-path-prefix@^1.0.0:
version "1.0.0"
Expand Down Expand Up @@ -1655,7 +1654,6 @@ graceful-fs@^4.1.11, graceful-fs@^4.1.15, graceful-fs@^4.1.2:
handlebars@^4.0.3:
version "4.1.2"
resolved "https://registry.yarnpkg.com/handlebars/-/handlebars-4.1.2.tgz#b6b37c1ced0306b221e094fc7aca3ec23b131b67"
integrity sha512-nvfrjqvt9xQ8Z/w0ijewdD/vvWDTOweBUm96NTr66Wfvo1mJenBLwcYmPs3TIBP5ruzYGD7Hx/DaM9RmhroGPw==
dependencies:
neo-async "^2.6.0"
optimist "^0.6.1"
Expand Down Expand Up @@ -2130,7 +2128,6 @@ js-tokens@^3.0.2:
js-yaml@^3.10.0, js-yaml@^3.11.0, js-yaml@^3.7.0:
version "3.13.1"
resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.13.1.tgz#aff151b30bfdfa8e49e05da22e7415e9dfa37847"
integrity sha512-YfbcO7jXDdyj0DGxYVSlSeQNHbD7XPWvrVWeVUujrQEoZzWJIRrCPoyk6kL6IAjAG2IolMK4T0hNUe0HOUs5Jw==
dependencies:
argparse "^1.0.7"
esprima "^4.0.0"
Expand Down Expand Up @@ -2591,7 +2588,6 @@ needle@^2.2.1:
neo-async@^2.6.0:
version "2.6.1"
resolved "https://registry.yarnpkg.com/neo-async/-/neo-async-2.6.1.tgz#ac27ada66167fa8849a6addd837f6b189ad2081c"
integrity sha512-iyam8fBuCUpWeKPGpaNMetEocMt364qkCsfL9JuhjXX6dRnguRVOfk2GZaDpPjcOKiiXCPINZC1GczQ7iTq3Zw==

node-forge@^0.7.4, node-forge@^0.7.5:
version "0.7.6"
Expand Down Expand Up @@ -3722,7 +3718,6 @@ typescript@^3.4.5:
uglify-js@^3.1.4:
version "3.6.0"
resolved "https://registry.yarnpkg.com/uglify-js/-/uglify-js-3.6.0.tgz#704681345c53a8b2079fb6cec294b05ead242ff5"
integrity sha512-W+jrUHJr3DXKhrsS7NUVxn3zqMOFn0hL/Ei6v0anCIMoKC93TjcflTagwIHLW7SfMFfiQuktQyFVCFHGUE0+yg==
dependencies:
commander "~2.20.0"
source-map "~0.6.1"
Expand Down Expand Up @@ -3841,7 +3836,6 @@ validate-npm-package-license@^3.0.1:
validate-with-xmllint@^1.0.2:
version "1.0.2"
resolved "https://registry.yarnpkg.com/validate-with-xmllint/-/validate-with-xmllint-1.0.2.tgz#7cf0010fa58d74ffffbd13f388a54210eaf2322b"
integrity sha512-CvyrXE7y0fxqWDXbo4y2lsa1hLnD6j/ojDxVW6+FzBN0hr8agl71tznsVHpyNqmaB9k6Akxx/GzEe8WSl3zxnw==

[email protected]:
version "1.10.0"
Expand Down

0 comments on commit 23ad029

Please sign in to comment.