Socket
Socket
Sign inDemoInstall

@ndustrial/contxt-sdk

Package Overview
Dependencies
Maintainers
9
Versions
123
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ndustrial/contxt-sdk - npm Package Compare versions

Comparing version 0.0.29 to 0.0.30

7

CHANGELOG.md

@@ -0,1 +1,8 @@

## [v0.0.30](http://github.com/ndustrialio/contxt-sdk-js/tree/v0.0.30) (2018-08-20)
**Changed**
* Started normalizing Silent Authentication errors from Auth0 in the Auth0WebAuth session type to match Axios errors.
* Additionally, started logging the user out when one of these errors is encountered.
## [v0.0.29](http://github.com/ndustrialio/contxt-sdk-js/tree/v0.0.29) (2018-08-16)

@@ -2,0 +9,0 @@

2

package.json
{
"name": "@ndustrial/contxt-sdk",
"version": "0.0.29",
"version": "0.0.30",
"description": "",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

@@ -323,4 +323,5 @@ import auth0 from 'auth0-js';

/**
* Gets up to date session info. Will get an updated session/tokens if the previous session has
* already expired.
* Gets up to date session info. Will get an updated session/tokens if the
* previous session has already expired. Will log the user out if an error
* from Auth0 indicates the session cannot continue without re-authentication.
*

@@ -343,13 +344,31 @@ * @returns {Promise}

.catch((err) => {
if (!(err.response && err.response.status)) {
const wrapperError = new Error(
let errorToThrow = err;
if (
err.error &&
[
'consent_required',
'interaction_required',
'login_required'
].indexOf(err.error) > -1
) {
errorToThrow = new Error('Unauthorized');
errorToThrow.response = {
data: {
...err,
code: 401
},
status: 401
};
this.logOut();
} else if (!(err.response && err.response.status)) {
errorToThrow = new Error(
'There was a problem getting new session info. Please check your configuration settings.'
);
wrapperError.fromSdk = true;
wrapperError.originalError = err;
throw wrapperError;
errorToThrow.fromSdk = true;
errorToThrow.originalError = err;
}
throw err;
throw errorToThrow;
});

@@ -356,0 +375,0 @@ }

@@ -906,6 +906,48 @@ import auth0 from 'auth0-js';

context('when there is an error getting the session info', function() {
let logOut;
beforeEach(function() {
this.sandbox.stub(Auth0WebAuth.prototype, '_loadSession');
logOut = this.sandbox.stub(Auth0WebAuth.prototype, 'logOut');
});
it('throws a 401 and logs the user out if Auth0 requires the session to be re-authenticated', function() {
const errorType = faker.random.arrayElement([
'consent_required',
'interaction_required',
'login_required'
]);
const originalError = {
error: errorType,
error_description: {
consent_required: 'Consent required',
interaction_required: 'Interaction required',
login_required: 'Login required'
}[errorType]
};
const expectedError = new Error('Unauthorized');
expectedError.response = {
data: {
code: 401,
error: originalError.error,
error_description: originalError.error_description
},
status: 401
};
this.sandbox
.stub(Auth0WebAuth.prototype, '_checkSession')
.rejects(originalError);
const auth0WebAuth = new Auth0WebAuth(sdk);
const promise = auth0WebAuth._getUpdatedSessionInfo();
return promise.then(expect.fail).catch((error) => {
expect(error.message).to.equal('Unauthorized');
expect(error.response).to.deep.equal(expectedError.response);
expect(logOut).to.be.calledOnce;
});
});
it('throws a human readable error when unable to reach the server', function() {

@@ -912,0 +954,0 @@ const originalError = new Error(faker.hacker.phrase());

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc