Skip to content

Commit

Permalink
updating a0js with impersonation and token validatino changes (#1308)
Browse files Browse the repository at this point in the history
  • Loading branch information
luisrudge authored Mar 22, 2018
1 parent 81a0207 commit c1c8c1f
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 16 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
"zuul-ngrok": "4.0.0"
},
"dependencies": {
"auth0-js": "^9.3.3",
"auth0-js": "^9.4.0",
"blueimp-md5": "2.3.1",
"fbjs": "^0.3.1",
"immutable": "^3.7.3",
Expand Down
20 changes: 16 additions & 4 deletions src/__tests__/core/web_api/__snapshots__/p2_api.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,10 @@ Object {
}
`;

exports[`Auth0APIClient parseHash should pass __enableImpersonation when options._enableImpersonation===true 1`] = `
exports[`Auth0APIClient parseHash should pass __enableIdPInitiatedLogin when options._enableIdPInitiatedLogin===true 1`] = `
Array [
Object {
"__enableImpersonation": true,
"__enableIdPInitiatedLogin": true,
"hash": "hash",
"nonce": undefined,
"state": undefined,
Expand All @@ -81,10 +81,22 @@ Array [
]
`;

exports[`Auth0APIClient parseHash should pass __enableImpersonation:false when options._enableImpersonation is not present 1`] = `
exports[`Auth0APIClient parseHash should pass __enableIdPInitiatedLogin when options._enableImpersonation===true 1`] = `
Array [
Object {
"__enableImpersonation": false,
"__enableIdPInitiatedLogin": true,
"hash": "hash",
"nonce": undefined,
"state": undefined,
},
"cb",
]
`;

exports[`Auth0APIClient parseHash should pass __enableIdPInitiatedLogin:false when options._enableImpersonation and options._enableIdPInitiatedLogin are not present 1`] = `
Array [
Object {
"__enableIdPInitiatedLogin": false,
"hash": "hash",
"nonce": undefined,
"state": undefined,
Expand Down
12 changes: 10 additions & 2 deletions src/__tests__/core/web_api/p2_api.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,21 +160,29 @@ describe('Auth0APIClient', () => {
expect(mock.calls[0]).toMatchSnapshot();
});
describe('parseHash', () => {
it('should pass __enableImpersonation:false when options._enableImpersonation is not present', () => {
it('should pass __enableIdPInitiatedLogin:false when options._enableImpersonation and options._enableIdPInitiatedLogin are not present', () => {
const client = getClient({});
client.parseHash('hash', 'cb');
const mock = getAuth0ClientMock();
const parseHashMock = mock.WebAuth.mock.instances[0].parseHash.mock;
expect(parseHashMock.calls.length).toBe(1);
expect(parseHashMock.calls[0]).toMatchSnapshot();
});
it('should pass __enableImpersonation when options._enableImpersonation===true', () => {
it('should pass __enableIdPInitiatedLogin when options._enableImpersonation===true', () => {
const client = getClient({ _enableImpersonation: true });
client.parseHash('hash', 'cb');
const mock = getAuth0ClientMock();
const parseHashMock = mock.WebAuth.mock.instances[0].parseHash.mock;
expect(parseHashMock.calls.length).toBe(1);
expect(parseHashMock.calls[0]).toMatchSnapshot();
});
it('should pass __enableIdPInitiatedLogin when options._enableIdPInitiatedLogin===true', () => {
const client = getClient({ _enableIdPInitiatedLogin: true });
client.parseHash('hash', 'cb');
const mock = getAuth0ClientMock();
const parseHashMock = mock.WebAuth.mock.instances[0].parseHash.mock;
expect(parseHashMock.calls.length).toBe(1);
expect(parseHashMock.calls[0]).toMatchSnapshot();
});
});
});
4 changes: 2 additions & 2 deletions src/core/web_api/p2_api.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class Auth0APIClient {
this.authOpt = null;
this.domain = domain;
this.isUniversalLogin = window.location.host === domain;
this._enableImpersonation = !!opts._enableImpersonation;
this._enableIdPInitiatedLogin = !!(opts._enableIdPInitiatedLogin || opts._enableImpersonation);

const default_telemetry = {
name: 'lock.js',
Expand Down Expand Up @@ -94,7 +94,7 @@ class Auth0APIClient {
parseHash(hash = '', cb) {
return this.client.parseHash(
{
__enableImpersonation: this._enableImpersonation,
__enableIdPInitiatedLogin: this._enableIdPInitiatedLogin,
hash,
nonce: this.authOpt.nonce,
state: this.authOpt.state
Expand Down
14 changes: 7 additions & 7 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -392,12 +392,12 @@ atob@~1.1.0:
version "1.1.3"
resolved "https://registry.yarnpkg.com/atob/-/atob-1.1.3.tgz#95f13629b12c3a51a5d215abdce2aa9f32f80773"

auth0-js@^9.3.3:
version "9.3.3"
resolved "https://registry.yarnpkg.com/auth0-js/-/auth0-js-9.3.3.tgz#c4573ffefba102171982d4a2044eade73baa1b8d"
auth0-js@^9.4.0:
version "9.4.0"
resolved "https://registry.yarnpkg.com/auth0-js/-/auth0-js-9.4.0.tgz#ec157fa6e799eb49e72e14335f335988e732541a"
dependencies:
base64-js "^1.2.0"
idtoken-verifier "^1.1.2"
idtoken-verifier "^1.2.0"
qs "^6.4.0"
superagent "^3.8.2"
url-join "^1.1.0"
Expand Down Expand Up @@ -4149,9 +4149,9 @@ icss-replace-symbols@^1.0.2:
version "1.0.2"
resolved "https://registry.yarnpkg.com/icss-replace-symbols/-/icss-replace-symbols-1.0.2.tgz#cb0b6054eb3af6edc9ab1d62d01933e2d4c8bfa5"

idtoken-verifier@^1.1.2:
version "1.1.2"
resolved "https://registry.yarnpkg.com/idtoken-verifier/-/idtoken-verifier-1.1.2.tgz#bd5125aaccc221c1e0c57c9393dc68c0f7134b69"
idtoken-verifier@^1.2.0:
version "1.2.0"
resolved "https://registry.yarnpkg.com/idtoken-verifier/-/idtoken-verifier-1.2.0.tgz#4654f1f07ab7a803fc9b1b8b36057e2a87ad8b09"
dependencies:
base64-js "^1.2.0"
crypto-js "^3.1.9-1"
Expand Down

0 comments on commit c1c8c1f

Please sign in to comment.