@ndustrial/contxt-sdk
Advanced tools
Comparing version 2.12.0 to 2.13.0
@@ -57,2 +57,3 @@ <a name="Auth0WebAuth"></a> | ||
clientId: '<client id>', | ||
onAuthenticate: (auth0WebAuthSessionInfo) => handleSuccessfulAuth(auth0WebAuthSessionInfo), | ||
onRedirect: (pathname) => history.push(pathname) | ||
@@ -59,0 +60,0 @@ } |
@@ -39,2 +39,3 @@ <a name="ContxtSdk"></a> | ||
env: 'staging', | ||
onAuthenticate: (auth0WebAuthSessionInfo) => handleSuccessfulAuth(auth0WebAuthSessionInfo), | ||
onRedirect: (pathname) => history.push(pathname) | ||
@@ -41,0 +42,0 @@ } |
@@ -194,3 +194,3 @@ <a name="Asset"></a> | ||
| --- | --- | --- | | ||
| config.clientId | <code>string</code> | Client Id provided by Auth0 for the environment you are trying to communicate with | | ||
| config.clientId | <code>string</code> | Client Id provided by Auth0 for the environment you are trying to communicate with | | ||
| config.host | <code>string</code> | Hostname for the API that corresponds with the clientId provided | | ||
@@ -220,3 +220,3 @@ | [config.webSocket] | <code>string</code> | WebSocket URL for the API that corresponds with the clientId provided | | ||
| --- | --- | --- | | ||
| interceptor.fulfilled | <code>function</code> | A function that is run on every successful request or response | | ||
| interceptor.fulfilled | <code>function</code> | A function that is run on every successful request or response | | ||
| interceptor.rejected | <code>function</code> | A function that is run on every failed request or response | | ||
@@ -712,4 +712,4 @@ | ||
| --- | --- | --- | | ||
| config.clientId | <code>string</code> | Client Id provided by Auth0 for the environment you are trying to communicate with. Can be a `null` value if the value is not needed. Some SessionType adapters (currently, just the MachineAuth adapter) require a value other than `null` if the built-in `request` module is used since they acquire contxt tokens based on a single clientId. | | ||
| config.host | <code>string</code> | Hostname for the API that corresponds with the clientId provided. Can be a `null` value if the value is not needed. | | ||
| config.clientId | <code>string</code> | Client Id provided by Auth0 for the environment you are trying to communicate with. Can be a `null` value if the value is not needed. Some SessionType adapters (currently, just the MachineAuth adapter) require a value other than `null` if the built-in `request` module is used since they acquire contxt tokens based on a single clientId. | | ||
| config.host | <code>string</code> | Hostname for the API that corresponds with the clientId provided. Can be a `null` value if the value is not needed. | | ||
| config.module | <code>function</code> | The module that will be decorated into the SDK | | ||
@@ -1249,10 +1249,11 @@ | ||
| auth | <code>Object</code> | | User assigned configurations specific for their authentication methods | | ||
| [auth.authorizationPath] | <code>string</code> | | Path Auth0WebAuth process should redirect to after a successful sign in attempt | | ||
| [auth.authorizationPath] | <code>string</code> | | Path Auth0WebAuth process should redirect to after a successful sign in attempt | | ||
| auth.clientId | <code>string</code> | | Client Id provided by Auth0 for this application | | ||
| [auth.clientSecret] | <code>string</code> | | Client secret provided by Auth0 for this application. This is optional for the auth0WebAuth SessionType, but required for the machineAuth SessionType | | ||
| [auth.customModuleConfigs] | <code>Object.<string, CustomAudience></code> | | Custom environment setups for individual modules. Requires clientId/host or env | | ||
| [auth.env] | <code>string</code> | <code>"'production'"</code> | The environment that every module should use for their clientId and host | | ||
| [auth.onRedirect] | <code>function</code> | <code>(pathname) => { window.location = pathname; }</code> | A redirect method used for navigating through Auth0 callbacks in Web applications | | ||
| [auth.tokenExpiresAtBufferMs] | <code>number</code> | <code>300000</code> | The time (in milliseconds) before a token truly expires that we consider it expired (i.e. the token's expiresAt - this = calculated expiresAt). Defaults to 5 minutes. | | ||
| [interceptors] | <code>Object</code> | | Axios interceptors that can transform requests and responses. More information at [axios Interceptors](https://github.com/axios/axios#interceptors) | | ||
| [auth.clientSecret] | <code>string</code> | | Client secret provided by Auth0 for this application. This is optional for the auth0WebAuth SessionType, but required for the machineAuth SessionType | | ||
| [auth.customModuleConfigs] | <code>Object.<string, CustomAudience></code> | | Custom environment setups for individual modules. Requires clientId/host or env | | ||
| [auth.env] | <code>string</code> | <code>"'production'"</code> | The environment that every module should use for their clientId and host | | ||
| [auth.onAuthenticate] | <code>function</code> | <code>(auth0WebAuthSessionInfo) => handleSuccessfulAuth(auth0WebAuthSessionInfo);</code> | An optional hook for handling a successful authentication request or overriding returned values. | | ||
| [auth.onRedirect] | <code>function</code> | <code>(pathname) => { window.location = pathname; }</code> | A redirect method used for navigating through Auth0 callbacks in Web applications | | ||
| [auth.tokenExpiresAtBufferMs] | <code>number</code> | <code>300000</code> | The time (in milliseconds) before a token truly expires that we consider it expired (i.e. the token's expiresAt - this = calculated expiresAt). Defaults to 5 minutes. | | ||
| [interceptors] | <code>Object</code> | | Axios interceptors that can transform requests and responses. More information at [axios Interceptors](https://github.com/axios/axios#interceptors) | | ||
| [interceptors.request] | [<code>Array.<AxiosInterceptor></code>](#AxiosInterceptor) | | Interceptors that act on every request | | ||
@@ -1259,0 +1260,0 @@ | [intercepotrs.response] | [<code>Array.<AxiosInterceptor></code>](#AxiosInterceptor) | | Intereptors that act on every response | |
@@ -17,3 +17,3 @@ var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; | ||
* @param {string} config.clientId Client Id provided by Auth0 for the environment you are | ||
* trying to communicate with | ||
* trying to communicate with | ||
* @param {string} config.host Hostname for the API that corresponds with the clientId provided | ||
@@ -49,7 +49,7 @@ * @param {string} [config.webSocket] WebSocket URL for the API that corresponds with the clientId provided | ||
* @param {string} config.clientId Client Id provided by Auth0 for the environment you are | ||
* trying to communicate with. Can be a `null` value if the value is not needed. Some SessionType | ||
* adapters (currently, just the MachineAuth adapter) require a value other than `null` if the | ||
* built-in `request` module is used since they acquire contxt tokens based on a single clientId. | ||
* trying to communicate with. Can be a `null` value if the value is not needed. Some SessionType | ||
* adapters (currently, just the MachineAuth adapter) require a value other than `null` if the | ||
* built-in `request` module is used since they acquire contxt tokens based on a single clientId. | ||
* @param {string} config.host Hostname for the API that corresponds with the clientId provided. | ||
* Can be a `null` value if the value is not needed. | ||
* Can be a `null` value if the value is not needed. | ||
* @param {function} config.module The module that will be decorated into the SDK | ||
@@ -64,3 +64,3 @@ */ | ||
* @param {function} interceptor.fulfilled A function that is run on every successful request or | ||
* response | ||
* response | ||
* @param {function} interceptor.rejected A function that is run on every failed request or response | ||
@@ -75,17 +75,19 @@ */ | ||
* @property {string} [auth.authorizationPath] Path Auth0WebAuth process should redirect to after a | ||
* successful sign in attempt | ||
* successful sign in attempt | ||
* @property {string} auth.clientId Client Id provided by Auth0 for this application | ||
* @property {string} [auth.clientSecret] Client secret provided by Auth0 for this application. This | ||
* is optional for the auth0WebAuth SessionType, but required for the machineAuth SessionType | ||
* is optional for the auth0WebAuth SessionType, but required for the machineAuth SessionType | ||
* @property {Object.<string, CustomAudience>} [auth.customModuleConfigs] Custom environment setups | ||
* for individual modules. Requires clientId/host or env | ||
* for individual modules. Requires clientId/host or env | ||
* @property {string} [auth.env = 'production'] The environment that every module should use for | ||
* their clientId and host | ||
* their clientId and host | ||
* @property {function} [auth.onAuthenticate = (auth0WebAuthSessionInfo) => handleSuccessfulAuth(auth0WebAuthSessionInfo); ] An optional | ||
* hook for handling a successful authentication request or overriding returned values. | ||
* @property {function} [auth.onRedirect = (pathname) => { window.location = pathname; }] A redirect | ||
* method used for navigating through Auth0 callbacks in Web applications | ||
* method used for navigating through Auth0 callbacks in Web applications | ||
* @property {number} [auth.tokenExpiresAtBufferMs = 300000] The time (in milliseconds) before a | ||
* token truly expires that we consider it expired (i.e. the token's expiresAt - this = calculated | ||
* expiresAt). Defaults to 5 minutes. | ||
* token truly expires that we consider it expired (i.e. the token's expiresAt - this = calculated | ||
* expiresAt). Defaults to 5 minutes. | ||
* @property {Object} [interceptors] Axios interceptors that can transform requests and responses. | ||
* More information at {@link https://github.com/axios/axios#interceptors axios Interceptors} | ||
* More information at {@link https://github.com/axios/axios#interceptors axios Interceptors} | ||
* @property {AxiosInterceptor[]} [interceptors.request] Interceptors that act on every request | ||
@@ -92,0 +94,0 @@ * @property {AxiosInterceptor[]} [intercepotrs.response] Intereptors that act on every response |
@@ -59,2 +59,3 @@ var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); | ||
* env: 'staging', | ||
* onAuthenticate: (auth0WebAuthSessionInfo) => handleSuccessfulAuth(auth0WebAuthSessionInfo), | ||
* onRedirect: (pathname) => history.push(pathname) | ||
@@ -61,0 +62,0 @@ * } |
@@ -56,2 +56,3 @@ var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; | ||
* clientId: '<client id>', | ||
* onAuthenticate: (auth0WebAuthSessionInfo) => handleSuccessfulAuth(auth0WebAuthSessionInfo), | ||
* onRedirect: (pathname) => history.push(pathname) | ||
@@ -88,2 +89,3 @@ * } | ||
this._onAuthenticate = this._sdk.config.auth.onAuthenticate || this._defaultOnAuthenticate; | ||
this._onRedirect = this._sdk.config.auth.onRedirect || this._defaultOnRedirect; | ||
@@ -232,3 +234,3 @@ this._sessionInfo = this._getStoredSession(); | ||
return this._parseHash().then(function (authResult) { | ||
return this._parseHash().then(this._onAuthenticate).then(function (authResult) { | ||
_this3._storeSession(authResult); | ||
@@ -349,2 +351,15 @@ _this3._scheduleSessionRefresh(); | ||
/** | ||
* Default method used for intercepting a successful authentication result. Overridden | ||
* by `onAuthenticate` in the auth config | ||
* | ||
* @private | ||
*/ | ||
}, { | ||
key: '_defaultOnAuthenticate', | ||
value: function _defaultOnAuthenticate(authResult) { | ||
return authResult; | ||
} | ||
/** | ||
* Grabs a stored redirect pathname that may have been stored in another part | ||
@@ -351,0 +366,0 @@ * of the web application |
@@ -30,3 +30,3 @@ 'use strict'; | ||
* @param {string} config.clientId Client Id provided by Auth0 for the environment you are | ||
* trying to communicate with | ||
* trying to communicate with | ||
* @param {string} config.host Hostname for the API that corresponds with the clientId provided | ||
@@ -62,7 +62,7 @@ * @param {string} [config.webSocket] WebSocket URL for the API that corresponds with the clientId provided | ||
* @param {string} config.clientId Client Id provided by Auth0 for the environment you are | ||
* trying to communicate with. Can be a `null` value if the value is not needed. Some SessionType | ||
* adapters (currently, just the MachineAuth adapter) require a value other than `null` if the | ||
* built-in `request` module is used since they acquire contxt tokens based on a single clientId. | ||
* trying to communicate with. Can be a `null` value if the value is not needed. Some SessionType | ||
* adapters (currently, just the MachineAuth adapter) require a value other than `null` if the | ||
* built-in `request` module is used since they acquire contxt tokens based on a single clientId. | ||
* @param {string} config.host Hostname for the API that corresponds with the clientId provided. | ||
* Can be a `null` value if the value is not needed. | ||
* Can be a `null` value if the value is not needed. | ||
* @param {function} config.module The module that will be decorated into the SDK | ||
@@ -77,3 +77,3 @@ */ | ||
* @param {function} interceptor.fulfilled A function that is run on every successful request or | ||
* response | ||
* response | ||
* @param {function} interceptor.rejected A function that is run on every failed request or response | ||
@@ -88,17 +88,19 @@ */ | ||
* @property {string} [auth.authorizationPath] Path Auth0WebAuth process should redirect to after a | ||
* successful sign in attempt | ||
* successful sign in attempt | ||
* @property {string} auth.clientId Client Id provided by Auth0 for this application | ||
* @property {string} [auth.clientSecret] Client secret provided by Auth0 for this application. This | ||
* is optional for the auth0WebAuth SessionType, but required for the machineAuth SessionType | ||
* is optional for the auth0WebAuth SessionType, but required for the machineAuth SessionType | ||
* @property {Object.<string, CustomAudience>} [auth.customModuleConfigs] Custom environment setups | ||
* for individual modules. Requires clientId/host or env | ||
* for individual modules. Requires clientId/host or env | ||
* @property {string} [auth.env = 'production'] The environment that every module should use for | ||
* their clientId and host | ||
* their clientId and host | ||
* @property {function} [auth.onAuthenticate = (auth0WebAuthSessionInfo) => handleSuccessfulAuth(auth0WebAuthSessionInfo); ] An optional | ||
* hook for handling a successful authentication request or overriding returned values. | ||
* @property {function} [auth.onRedirect = (pathname) => { window.location = pathname; }] A redirect | ||
* method used for navigating through Auth0 callbacks in Web applications | ||
* method used for navigating through Auth0 callbacks in Web applications | ||
* @property {number} [auth.tokenExpiresAtBufferMs = 300000] The time (in milliseconds) before a | ||
* token truly expires that we consider it expired (i.e. the token's expiresAt - this = calculated | ||
* expiresAt). Defaults to 5 minutes. | ||
* token truly expires that we consider it expired (i.e. the token's expiresAt - this = calculated | ||
* expiresAt). Defaults to 5 minutes. | ||
* @property {Object} [interceptors] Axios interceptors that can transform requests and responses. | ||
* More information at {@link https://github.com/axios/axios#interceptors axios Interceptors} | ||
* More information at {@link https://github.com/axios/axios#interceptors axios Interceptors} | ||
* @property {AxiosInterceptor[]} [interceptors.request] Interceptors that act on every request | ||
@@ -105,0 +107,0 @@ * @property {AxiosInterceptor[]} [intercepotrs.response] Intereptors that act on every response |
@@ -101,2 +101,3 @@ 'use strict'; | ||
* env: 'staging', | ||
* onAuthenticate: (auth0WebAuthSessionInfo) => handleSuccessfulAuth(auth0WebAuthSessionInfo), | ||
* onRedirect: (pathname) => history.push(pathname) | ||
@@ -103,0 +104,0 @@ * } |
@@ -73,2 +73,3 @@ 'use strict'; | ||
* clientId: '<client id>', | ||
* onAuthenticate: (auth0WebAuthSessionInfo) => handleSuccessfulAuth(auth0WebAuthSessionInfo), | ||
* onRedirect: (pathname) => history.push(pathname) | ||
@@ -104,2 +105,3 @@ * } | ||
this._onAuthenticate = this._sdk.config.auth.onAuthenticate || this._defaultOnAuthenticate; | ||
this._onRedirect = this._sdk.config.auth.onRedirect || this._defaultOnRedirect; | ||
@@ -248,3 +250,3 @@ this._sessionInfo = this._getStoredSession(); | ||
return this._parseHash().then(function (authResult) { | ||
return this._parseHash().then(this._onAuthenticate).then(function (authResult) { | ||
_this3._storeSession(authResult); | ||
@@ -365,2 +367,15 @@ _this3._scheduleSessionRefresh(); | ||
/** | ||
* Default method used for intercepting a successful authentication result. Overridden | ||
* by `onAuthenticate` in the auth config | ||
* | ||
* @private | ||
*/ | ||
}, { | ||
key: '_defaultOnAuthenticate', | ||
value: function _defaultOnAuthenticate(authResult) { | ||
return authResult; | ||
} | ||
/** | ||
* Grabs a stored redirect pathname that may have been stored in another part | ||
@@ -367,0 +382,0 @@ * of the web application |
{ | ||
"name": "@ndustrial/contxt-sdk", | ||
"version": "2.12.0", | ||
"version": "2.13.0", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -9,3 +9,3 @@ import defaultAudiences from './audiences'; | ||
* @param {string} config.clientId Client Id provided by Auth0 for the environment you are | ||
* trying to communicate with | ||
* trying to communicate with | ||
* @param {string} config.host Hostname for the API that corresponds with the clientId provided | ||
@@ -41,7 +41,7 @@ * @param {string} [config.webSocket] WebSocket URL for the API that corresponds with the clientId provided | ||
* @param {string} config.clientId Client Id provided by Auth0 for the environment you are | ||
* trying to communicate with. Can be a `null` value if the value is not needed. Some SessionType | ||
* adapters (currently, just the MachineAuth adapter) require a value other than `null` if the | ||
* built-in `request` module is used since they acquire contxt tokens based on a single clientId. | ||
* trying to communicate with. Can be a `null` value if the value is not needed. Some SessionType | ||
* adapters (currently, just the MachineAuth adapter) require a value other than `null` if the | ||
* built-in `request` module is used since they acquire contxt tokens based on a single clientId. | ||
* @param {string} config.host Hostname for the API that corresponds with the clientId provided. | ||
* Can be a `null` value if the value is not needed. | ||
* Can be a `null` value if the value is not needed. | ||
* @param {function} config.module The module that will be decorated into the SDK | ||
@@ -56,3 +56,3 @@ */ | ||
* @param {function} interceptor.fulfilled A function that is run on every successful request or | ||
* response | ||
* response | ||
* @param {function} interceptor.rejected A function that is run on every failed request or response | ||
@@ -67,17 +67,19 @@ */ | ||
* @property {string} [auth.authorizationPath] Path Auth0WebAuth process should redirect to after a | ||
* successful sign in attempt | ||
* successful sign in attempt | ||
* @property {string} auth.clientId Client Id provided by Auth0 for this application | ||
* @property {string} [auth.clientSecret] Client secret provided by Auth0 for this application. This | ||
* is optional for the auth0WebAuth SessionType, but required for the machineAuth SessionType | ||
* is optional for the auth0WebAuth SessionType, but required for the machineAuth SessionType | ||
* @property {Object.<string, CustomAudience>} [auth.customModuleConfigs] Custom environment setups | ||
* for individual modules. Requires clientId/host or env | ||
* for individual modules. Requires clientId/host or env | ||
* @property {string} [auth.env = 'production'] The environment that every module should use for | ||
* their clientId and host | ||
* their clientId and host | ||
* @property {function} [auth.onAuthenticate = (auth0WebAuthSessionInfo) => handleSuccessfulAuth(auth0WebAuthSessionInfo); ] An optional | ||
* hook for handling a successful authentication request or overriding returned values. | ||
* @property {function} [auth.onRedirect = (pathname) => { window.location = pathname; }] A redirect | ||
* method used for navigating through Auth0 callbacks in Web applications | ||
* method used for navigating through Auth0 callbacks in Web applications | ||
* @property {number} [auth.tokenExpiresAtBufferMs = 300000] The time (in milliseconds) before a | ||
* token truly expires that we consider it expired (i.e. the token's expiresAt - this = calculated | ||
* expiresAt). Defaults to 5 minutes. | ||
* token truly expires that we consider it expired (i.e. the token's expiresAt - this = calculated | ||
* expiresAt). Defaults to 5 minutes. | ||
* @property {Object} [interceptors] Axios interceptors that can transform requests and responses. | ||
* More information at {@link https://github.com/axios/axios#interceptors axios Interceptors} | ||
* More information at {@link https://github.com/axios/axios#interceptors axios Interceptors} | ||
* @property {AxiosInterceptor[]} [interceptors.request] Interceptors that act on every request | ||
@@ -84,0 +86,0 @@ * @property {AxiosInterceptor[]} [intercepotrs.response] Intereptors that act on every response |
@@ -53,2 +53,3 @@ import Assets from './assets'; | ||
* env: 'staging', | ||
* onAuthenticate: (auth0WebAuthSessionInfo) => handleSuccessfulAuth(auth0WebAuthSessionInfo), | ||
* onRedirect: (pathname) => history.push(pathname) | ||
@@ -55,0 +56,0 @@ * } |
@@ -50,2 +50,3 @@ import auth0 from 'auth0-js'; | ||
* clientId: '<client id>', | ||
* onAuthenticate: (auth0WebAuthSessionInfo) => handleSuccessfulAuth(auth0WebAuthSessionInfo), | ||
* onRedirect: (pathname) => history.push(pathname) | ||
@@ -79,2 +80,4 @@ * } | ||
this._onAuthenticate = | ||
this._sdk.config.auth.onAuthenticate || this._defaultOnAuthenticate; | ||
this._onRedirect = | ||
@@ -210,2 +213,3 @@ this._sdk.config.auth.onRedirect || this._defaultOnRedirect; | ||
return this._parseHash() | ||
.then(this._onAuthenticate) | ||
.then((authResult) => { | ||
@@ -314,2 +318,12 @@ this._storeSession(authResult); | ||
/** | ||
* Default method used for intercepting a successful authentication result. Overridden | ||
* by `onAuthenticate` in the auth config | ||
* | ||
* @private | ||
*/ | ||
_defaultOnAuthenticate(authResult) { | ||
return authResult; | ||
} | ||
/** | ||
* Grabs a stored redirect pathname that may have been stored in another part | ||
@@ -316,0 +330,0 @@ * of the web application |
@@ -81,2 +81,8 @@ import auth0 from 'auth0-js'; | ||
it('sets the default onAuthenticate method to the class instance', function() { | ||
expect(auth0WebAuth._onAuthenticate).to.equal( | ||
Auth0WebAuth.prototype._defaultOnAuthenticate | ||
); | ||
}); | ||
it('sets the default onRedirect method to the class instance', function() { | ||
@@ -131,2 +137,3 @@ expect(auth0WebAuth._onRedirect).to.equal( | ||
let expectedAuthorizationPath; | ||
let expectedOnAuthenticate; | ||
let expectedOnRedirect; | ||
@@ -136,4 +143,7 @@ | ||
expectedAuthorizationPath = faker.hacker.adjective(); | ||
expectedOnAuthenticate = sinon.stub().returns(); | ||
expectedOnRedirect = sinon.stub(); | ||
sdk.config.auth.authorizationPath = expectedAuthorizationPath; | ||
sdk.config.auth.onAuthenticate = expectedOnAuthenticate; | ||
sdk.config.auth.onRedirect = expectedOnRedirect; | ||
@@ -144,2 +154,6 @@ | ||
it('sets the custom onAuthenticate method to the class instance', function() { | ||
expect(auth0WebAuth._onAuthenticate).to.equal(expectedOnAuthenticate); | ||
}); | ||
it('sets the custom onRedirect method to the class instance', function() { | ||
@@ -573,2 +587,3 @@ expect(auth0WebAuth._onRedirect).to.equal(expectedOnRedirect); | ||
let getRedirectPathname; | ||
let onAuthenticate; | ||
let onRedirect; | ||
@@ -580,8 +595,4 @@ let parseHash; | ||
beforeEach(function() { | ||
const currentDate = new Date(); | ||
expectedHash = { | ||
accessToken: faker.internet.password(), | ||
expiresIn: | ||
(faker.date.future().getTime() - currentDate.getTime()) / 1000 | ||
}; | ||
expectedHash = fixture.build('Auth0WebAuthSessionInfo'); | ||
expectedRedirectPathname = `/${faker.hacker.adjective()}/${faker.hacker.adjective()}`; | ||
@@ -595,2 +606,3 @@ | ||
.resolves(expectedHash); | ||
onAuthenticate = sinon.stub().returns(expectedHash); | ||
onRedirect = sinon.stub(); | ||
@@ -600,2 +612,3 @@ storeSession = sinon.stub(Auth0WebAuth.prototype, '_storeSession'); | ||
const auth0WebAuth = new Auth0WebAuth(sdk); | ||
auth0WebAuth._onAuthenticate = onAuthenticate; | ||
auth0WebAuth._onRedirect = onRedirect; | ||
@@ -631,2 +644,8 @@ scheduleSessionRefresh.reset(); | ||
it('calls the onAuthenticate hook', function() { | ||
return promise.then(() => { | ||
expect(onAuthenticate).to.be.calledWith(expectedHash); | ||
}); | ||
}); | ||
it("assigns the new redirect url to the browsers's location", function() { | ||
@@ -860,2 +879,13 @@ return promise.then(() => { | ||
describe('_defaultOnAuthenticate', function() { | ||
it('it returns the original AuthResult', function() { | ||
const expectedAuthResult = fixture.build('Auth0WebAuthSessionInfo'); | ||
const result = Auth0WebAuth.prototype._defaultOnAuthenticate( | ||
expectedAuthResult | ||
); | ||
expect(result).to.equal(expectedAuthResult); | ||
}); | ||
}); | ||
describe('_defaultOnRedirect', function() { | ||
@@ -862,0 +892,0 @@ let expectedPathname; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
2914763
426
47465