Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace querystring implementation with qs module #382

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions plugins/cordova/popup-handler.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
var windowHandler = require('../../src/helper/window');
var qs = require('../../src/helper/qs');
var qs = require('qs');
var urljoin = require('url-join');

function PopupHandler(webAuth) {
Expand All @@ -19,7 +19,10 @@ PopupHandler.prototype.preload = function (options) {
delete popupOptions.width;
delete popupOptions.height;

var windowFeatures = qs.build(popupOptions, ',', false);
var windowFeatures = qs.stringify(popupOptions, {
encode: false,
delimiter: ','
});

if (this._current_popup && !this._current_popup.closed) {
return this._current_popup;
Expand Down
8 changes: 4 additions & 4 deletions src/authentication/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
var urljoin = require('url-join');

var RequestBuilder = require('../helper/request-builder');
var qs = require('../helper/qs');
var qs = require('qs');
var objectHelper = require('../helper/object');
var assert = require('../helper/assert');
var responseHandler = require('../helper/response-handler');
Expand Down Expand Up @@ -103,7 +103,7 @@ Authentication.prototype.buildAuthorizeUrl = function (options) {
params = objectHelper.toSnakeCase(params, ['auth0Client']);
params = parametersWhitelist.oauthAuthorizeParams(this.warn, params);

qString = qs.build(params);
qString = qs.stringify(params);

return urljoin(this.baseOptions.rootUrl, 'authorize', '?' + qString);
};
Expand Down Expand Up @@ -134,7 +134,7 @@ Authentication.prototype.buildLogoutUrl = function (options) {

params = objectHelper.toSnakeCase(params, ['auth0Client', 'returnTo']);

qString = qs.build(params);
qString = qs.stringify(params);

return urljoin(this.baseOptions.rootUrl, 'v2', 'logout', '?' + qString);
};
Expand Down Expand Up @@ -297,7 +297,7 @@ Authentication.prototype.getSSOData = function (withActiveDirectories, cb) {
assert.check(cb, { type: 'function', message: 'cb parameter is not valid' });

if (withActiveDirectories) {
params = '?' + qs.build({
params = '?' + qs.stringify({
ldaps: 1,
client_id: this.baseOptions.clientID
});
Expand Down
4 changes: 2 additions & 2 deletions src/authentication/passwordless-authentication.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ var urljoin = require('url-join');

var objectHelper = require('../helper/object');
var assert = require('../helper/assert');
var qs = require('../helper/qs');
var qs = require('qs');
var responseHandler = require('../helper/response-handler');

function PasswordlessAuthentication(request, options) {
Expand Down Expand Up @@ -48,7 +48,7 @@ PasswordlessAuthentication.prototype.buildVerifyUrl = function (options) {

params = objectHelper.toSnakeCase(params, ['auth0Client']);

qString = qs.build(params);
qString = qs.stringify(params);

return urljoin(this.baseOptions.rootUrl, 'passwordless', 'verify_redirect', '?' + qString);
};
Expand Down
12 changes: 9 additions & 3 deletions src/helper/popup-handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ var WinChan = require('winchan');

var windowHandler = require('./window');
var objectHelper = require('./object');
var qs = require('./qs');
var qs = require('qs');

function PopupHandler() {
this._current_popup = null;
Expand Down Expand Up @@ -38,7 +38,10 @@ PopupHandler.prototype.preload = function (options) {
var popupPosition = this.calculatePosition(options.popupOptions || {});
var popupOptions = objectHelper.merge(popupPosition).with(options.popupOptions);
var url = options.url || 'about:blank';
var windowFeatures = qs.build(popupOptions, ',', false);
var windowFeatures = qs.stringify(popupOptions, {
encode: false,
delimiter: ','
});

if (this._current_popup && !this._current_popup.closed) {
return this._current_popup;
Expand All @@ -62,7 +65,10 @@ PopupHandler.prototype.load = function (url, relayUrl, options, cb) {
var winchanOptions = objectHelper.merge({
url: url,
relay_url: relayUrl,
window_features: qs.build(popupOptions, ',', false),
window_features: qs.stringify(popupOptions, {
delimiter: ',',
encode: false
}),
popup: this._current_popup
}).with(options);

Expand Down
24 changes: 0 additions & 24 deletions src/helper/qs.js

This file was deleted.

2 changes: 1 addition & 1 deletion src/web-auth/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ var IdTokenVerifier = require('idtoken-verifier');

var assert = require('../helper/assert');
var error = require('../helper/error');
var qs = require('../helper/qs');
var qs = require('qs');
var PluginHandler = require('../helper/plugins');
var windowHelper = require('../helper/window');
var objectHelper = require('../helper/object');
Expand Down
2 changes: 1 addition & 1 deletion test/helper/iframe-handler.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ describe('helpers iframeHandler', function () {

expect(err).to.eql({
error:'some_error',
errorDescription: 'the+error+description'
errorDescription: 'the error description'
});

setTimeout(done, 100);
Expand Down
15 changes: 1 addition & 14 deletions test/helper/popup-handler.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ var expect = require('expect.js');
var stub = require('sinon').stub;
var WinChan = require('winchan');

var qs = require('../../src/helper/qs');
var qs = require('qs');
var PopupHandler = require('../../src/helper/popup-handler');

describe('helpers popupHandler', function () {
Expand Down Expand Up @@ -80,19 +80,6 @@ describe('helpers popupHandler', function () {
});
});

describe('stringifies the window properties', function () {

it('using the options received', function () {
var str = qs.build({
attr1: 'attribute 1',
attr2: 'attribute 2',
attr3: 'attribute 3'
}, ',', false);
expect(str).to.eql('attr1=attribute 1,attr2=attribute 2,attr3=attribute 3');
});

});

describe('should open the popup', function () {
before(function(){
global.window = {};
Expand Down
51 changes: 0 additions & 51 deletions test/helper/qs.test.js

This file was deleted.