Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@ciscospark/plugin-authorization-browser

Package Overview
Dependencies
Maintainers
3
Versions
138
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ciscospark/plugin-authorization-browser - npm Package Compare versions

Comparing version 1.50.16 to 1.50.17

21

dist/authorization.js

@@ -155,2 +155,3 @@ 'use strict';

var ret = (0, _apply2.default)(_sparkCore.SparkPlugin.prototype.initialize, this, [attrs, options]);
// Reminder, we can't do parse based on config, because config is not

@@ -161,10 +162,15 @@ // available until nextTick and we want to be able to throw errors found in

this.ready = true;
return ret;
}
var location = _url2.default.parse(this.spark.getWindow().location.href, true);
this._checkForErrors(location);
var hash = location.hash;
if (!hash) {
this.ready = true;
return ret;

@@ -180,2 +186,3 @@ }

var tokenData = this._parseHash(location);
if (!tokenData) {

@@ -214,2 +221,3 @@ return ret;

}
return this.initiateImplicitGrant(options);

@@ -229,2 +237,3 @@ },

this.spark.getWindow().location = this.spark.credentials.buildLoginUrl((0, _assign2.default)({ response_type: 'token' }, options));
return _promise2.default.resolve();

@@ -244,2 +253,3 @@ },

this.spark.getWindow().location = this.spark.credentials.buildLoginUrl((0, _assign2.default)({ response_type: 'code' }, options));
return _promise2.default.resolve();

@@ -317,4 +327,7 @@ },

var query = location.query;
if (query && query.error) {
var ErrorConstructor = _sparkCore.grantErrors.select(query.error);
throw new ErrorConstructor(query);

@@ -364,3 +377,5 @@ }

var token = _uuid2.default.v4();
this.spark.getWindow().sessionStorage.setItem('oauth2-csrf-token', token);
return token;

@@ -380,2 +395,3 @@ },

var hash = (0, _cloneDeep3.default)(location.hash);
if (hash) {

@@ -386,2 +402,3 @@ this._verifySecurityToken(hash);

this.ready = true;
return undefined;

@@ -395,2 +412,3 @@ }

}
return hash;

@@ -411,2 +429,3 @@ },

var sessionToken = this.spark.getWindow().sessionStorage.getItem(OAUTH2_CSRF_TOKEN);
this.spark.getWindow().sessionStorage.removeItem(OAUTH2_CSRF_TOKEN);

@@ -431,3 +450,3 @@ if (!sessionToken) {

},
version: '1.50.16'
version: '1.50.17'
}, (_applyDecoratedDescriptor(_obj, 'initiateImplicitGrant', [_dec], (0, _getOwnPropertyDescriptor2.default)(_obj, 'initiateImplicitGrant'), _obj), _applyDecoratedDescriptor(_obj, 'initiateAuthorizationCodeGrant', [_dec2], (0, _getOwnPropertyDescriptor2.default)(_obj, 'initiateAuthorizationCodeGrant'), _obj), _applyDecoratedDescriptor(_obj, 'requestAccessTokenFromJwt', [_common.oneFlight], (0, _getOwnPropertyDescriptor2.default)(_obj, 'requestAccessTokenFromJwt'), _obj)), _obj)));

@@ -434,0 +453,0 @@

8

package.json
{
"name": "@ciscospark/plugin-authorization-browser",
"version": "1.50.16",
"version": "1.50.17",
"description": "",

@@ -21,8 +21,8 @@ "license": "MIT",

"lodash": "^4.17.11",
"@ciscospark/common": "1.50.16",
"@ciscospark/spark-core": "1.50.16",
"@ciscospark/common": "1.50.17",
"@ciscospark/spark-core": "1.50.17",
"uuid": "^3.2.1",
"@ciscospark/internal-plugin-wdm": "1.50.16",
"@ciscospark/internal-plugin-wdm": "1.50.17",
"envify": "^4.1.0"
}
}

@@ -71,2 +71,3 @@ /*!

const ret = Reflect.apply(SparkPlugin.prototype.initialize, this, [attrs, options]);
// Reminder, we can't do parse based on config, because config is not

@@ -77,10 +78,14 @@ // available until nextTick and we want to be able to throw errors found in

this.ready = true;
return ret;
}
const location = url.parse(this.spark.getWindow().location.href, true);
this._checkForErrors(location);
let hash = location.hash;
let {hash} = location;
if (!hash) {
this.ready = true;
return ret;

@@ -96,2 +101,3 @@ }

const tokenData = this._parseHash(location);
if (!tokenData) {

@@ -127,2 +133,3 @@ return ret;

}
return this.initiateImplicitGrant(options);

@@ -143,2 +150,3 @@ },

this.spark.getWindow().location = this.spark.credentials.buildLoginUrl(Object.assign({response_type: 'token'}, options));
return Promise.resolve();

@@ -159,2 +167,3 @@ },

this.spark.getWindow().location = this.spark.credentials.buildLoginUrl(Object.assign({response_type: 'code'}, options));
return Promise.resolve();

@@ -223,5 +232,7 @@ },

_checkForErrors(location) {
const query = location.query;
const {query} = location;
if (query && query.error) {
const ErrorConstructor = grantErrors.select(query.error);
throw new ErrorConstructor(query);

@@ -274,3 +285,5 @@ }

const token = uuid.v4();
this.spark.getWindow().sessionStorage.setItem('oauth2-csrf-token', token);
return token;

@@ -289,2 +302,3 @@ },

const hash = cloneDeep(location.hash);
if (hash) {

@@ -295,2 +309,3 @@ this._verifySecurityToken(hash);

this.ready = true;
return undefined;

@@ -304,2 +319,3 @@ }

}
return hash;

@@ -319,2 +335,3 @@ },

const sessionToken = this.spark.getWindow().sessionStorage.getItem(OAUTH2_CSRF_TOKEN);
this.spark.getWindow().sessionStorage.removeItem(OAUTH2_CSRF_TOKEN);

@@ -321,0 +338,0 @@ if (!sessionToken) {

@@ -65,2 +65,3 @@ /*!

let accessToken = '';
return browser

@@ -73,2 +74,3 @@ .waitForElementByCssSelector('#access-token:not(:empty)')

assert.isAbove(accessToken.length, 0);
return browser;

@@ -87,2 +89,3 @@ })

assert.notEqual(text, accessToken);
return browser;

@@ -89,0 +92,0 @@ });

@@ -18,5 +18,7 @@ /*!

const displayName = `test-${userId}`;
return createUser({displayName, userId})
.then(({jwt}) => {
const spark = new CiscoSpark();
return spark.authorization.requestAccessTokenFromJwt({jwt})

@@ -33,2 +35,3 @@ .then(() => assert.isTrue(spark.canAuthorize));

const displayName = `test-${userId}`;
return createUser({displayName, userId})

@@ -47,2 +50,3 @@ .then(({jwt}) => {

let token;
return spark.authorization.requestAccessTokenFromJwt({jwt})

@@ -49,0 +53,0 @@ .then(() => {

@@ -167,2 +167,3 @@ /*!

const spark = makeSpark('http://example.com');
assert.isTrue(spark.authorization.ready);

@@ -205,4 +206,5 @@ assert.isFalse(spark.credentials.canAuthorize);

assert.include(spark.getWindow().location, 'response_type=token');
const query = url.parse(spark.getWindow().location, true).query;
let state = query.state;
const {query} = url.parse(spark.getWindow().location, true);
let {state} = query;
state = JSON.parse(base64.decode(state));

@@ -248,4 +250,5 @@ assert.property(state, 'csrf_token');

assert.include(spark.getWindow().location, 'response_type=code');
const query = url.parse(spark.getWindow().location, true).query;
let state = query.state;
const {query} = url.parse(spark.getWindow().location, true);
let {state} = query;
state = JSON.parse(base64.decode(state));

@@ -270,3 +273,5 @@ assert.property(state, 'csrf_token');

const p = spark.authorization.initiateLogin();
assert.isTrue(spark.authorization.isAuthorizing);
return p.then(() => assert.isFalse(spark.authorization.isAuthorizing));

@@ -284,3 +289,5 @@ });

const p = spark.authorization.initiateLogin();
assert.isTrue(spark.authorization.isAuthenticating);
return p.then(() => assert.isFalse(spark.authorization.isAuthenticating));

@@ -297,5 +304,7 @@ });

});
sinon.spy(spark.authorization, '_cleanUrl');
[{}, {state: {}}].forEach((hash) => {
const location = {hash};
spark.authorization._cleanUrl(location);

@@ -312,2 +321,3 @@ assert.equal(spark.getWindow().location.href, '');

});
sinon.spy(spark.authorization, '_cleanUrl');

@@ -321,2 +331,3 @@ const location = {

};
spark.authorization._cleanUrl(location);

@@ -340,5 +351,7 @@ assert.equal(spark.getWindow().location.href, '');

};
sinon.spy(spark.authorization, '_cleanUrl');
spark.authorization._cleanUrl(location);
const href = spark.getWindow().location.href;
const {href} = spark.getWindow().location;
assert.isDefined(href);

@@ -345,0 +358,0 @@ assert.equal(href, `#state=${base64.encode(JSON.stringify({key: 'value'}))}`);

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