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

Adding scope to the parsed hash object #434

Merged
merged 2 commits into from May 16, 2017
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/web-auth/index.js
Expand Up @@ -167,7 +167,8 @@ function buildParseHashResponse(qsParams, appStatus, token) {
refreshToken: qsParams.refresh_token || null,
state: qsParams.state || null,
expiresIn: qsParams.expires_in ? parseInt(qsParams.expires_in, 10) : null,
tokenType: qsParams.token_type || null
tokenType: qsParams.token_type || null,
scope: qsParams.scope || null
};
}

Expand Down
6 changes: 4 additions & 2 deletions test/plugins/cordova.test.js
Expand Up @@ -155,7 +155,8 @@ describe('auth0.plugins.cordova', function () {
refreshToken: 'kajshdgfkasdjhgfas',
state: 'theState',
expiresIn: null,
tokenType: 'Bearer'
tokenType: 'Bearer',
scope: null
});
expect(_this.events).to.eql({});
done();
Expand All @@ -178,7 +179,8 @@ describe('auth0.plugins.cordova', function () {
refreshToken: null,
state: 'theState',
expiresIn: null,
tokenType: 'Bearer'
tokenType: 'Bearer',
scope: null
});
expect(_this.events).to.eql({});
done();
Expand Down
20 changes: 13 additions & 7 deletions test/web-auth/web-auth.test.js
Expand Up @@ -133,7 +133,7 @@ describe('auth0.WebAuth', function () {

var data = webAuth.parseHash({
nonce: 'asfd',
hash: '#access_token=VjubIMBmpgQ2W2&id_token=eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsImtpZCI6IlF6RTROMFpCTTBWRFF6RTJSVVUwTnpJMVF6WTFNelE0UVRrMU16QXdNRUk0UkRneE56RTRSZyJ9.eyJpc3MiOiJodHRwczovL3dwdGVzdC5hdXRoMC5jb20vIiwic3ViIjoiYXV0aDB8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SXoOJLbeBszfrVDCmPhpHKGGMPL1N6HV-3EEF77L34YNAi2JQ-b70nFK_dnYmmv0cYTGUxtGTHkl64UEDLi3u7bV-kbGky3iOOCzXKzDDY6BBKpCRTc2KlbrkO2A2PuDn27WVv1QCNEFHvJN7HxiDDzXOsaUmjrQ3sfrHhzD7S9BcCRkekRfD9g95SKD5J0Fj8NA&token_type=Bearer&state=theState&refresh_token=kajshdgfkasdjhgfas&scope=foo'
}, function(err, data) {
expect(err).to.be(null);
expect(data).to.eql({
Expand All @@ -151,7 +151,8 @@ describe('auth0.WebAuth', function () {
refreshToken: 'kajshdgfkasdjhgfas',
state: 'theState',
expiresIn: null,
tokenType: 'Bearer'
tokenType: 'Bearer',
scope: 'foo'
});

expect(TransactionManager.prototype.getStoredTransaction.calledOnce).to.be.ok();
Expand Down Expand Up @@ -188,7 +189,8 @@ describe('auth0.WebAuth', function () {
refreshToken: 'kajshdgfkasdjhgfas',
state: 'theState',
expiresIn: null,
tokenType: 'Bearer'
tokenType: 'Bearer',
scope: null
});

expect(TransactionManager.prototype.getStoredTransaction.calledOnce).to.be.ok();
Expand Down Expand Up @@ -223,7 +225,8 @@ describe('auth0.WebAuth', function () {
refreshToken: 'kajshdgfkasdjhgfas',
state: 'theState',
expiresIn: null,
tokenType: 'Bearer'
tokenType: 'Bearer',
scope: null
});

expect(TransactionManager.prototype.getStoredTransaction.calledOnce).to.be.ok();
Expand Down Expand Up @@ -251,7 +254,8 @@ describe('auth0.WebAuth', function () {
refreshToken: 'kajshdgfkasdjhgfas',
state: 'theState',
expiresIn: null,
tokenType: 'Bearer'
tokenType: 'Bearer',
scope: null
});

expect(TransactionManager.prototype.getStoredTransaction.calledOnce).to.be.ok();
Expand Down Expand Up @@ -448,7 +452,8 @@ describe('auth0.WebAuth', function () {
refreshToken: null,
state: null,
expiresIn: null,
tokenType: null
tokenType: null,
scope: null
});

expect(TransactionManager.prototype.getStoredTransaction.calledTwice).to.be.ok();
Expand Down Expand Up @@ -509,7 +514,8 @@ describe('auth0.WebAuth', function () {
refreshToken: null,
state: null,
expiresIn: null,
tokenType: null
tokenType: null,
scope: null
});
done();
});
Expand Down