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

@accounts/client

Package Overview
Dependencies
Maintainers
5
Versions
201
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@accounts/client - npm Package Compare versions

Comparing version 0.0.7 to 0.0.8

20

lib/AccountsClient.js

@@ -475,6 +475,8 @@ 'use strict';

res = _context9.sent;
_context9.next = 11;
this.store.dispatch((0, _module.loggingIn)(false));
_context9.next = 12;
return this.storeTokens(res);
case 11:
case 12:
this.store.dispatch((0, _module.setUser)(res.user));

@@ -485,9 +487,10 @@ this.options.onSignedInHook();

}
_context9.next = 20;
_context9.next = 22;
break;
case 16:
_context9.prev = 16;
case 17:
_context9.prev = 17;
_context9.t0 = _context9['catch'](5);
this.store.dispatch((0, _module.loggingIn)(false));
if (callback && (0, _lodash.isFunction)(callback)) {

@@ -498,6 +501,3 @@ callback(_context9.t0);

case 20:
this.store.dispatch((0, _module.loggingIn)(false), user);
case 21:
case 22:
case 'end':

@@ -507,3 +507,3 @@ return _context9.stop();

}
}, _callee9, this, [[5, 16]]);
}, _callee9, this, [[5, 17]]);
}));

@@ -510,0 +510,0 @@

@@ -434,4 +434,5 @@ 'use strict';

expect(callback.mock.calls.length).toEqual(1);
expect(_AccountsClient2.default.loggingIn()).toBe(false);
case 6:
case 7:
case 'end':

@@ -507,3 +508,3 @@ return _context11.stop();

})));
it('stores tokens in local storage', _asyncToGenerator(regeneratorRuntime.mark(function _callee14() {
it('sets loggingIn flag to false on failed login', _asyncToGenerator(regeneratorRuntime.mark(function _callee14() {
var transport;

@@ -516,2 +517,35 @@ return regeneratorRuntime.wrap(function _callee14$(_context14) {

loginWithPassword: function loginWithPassword() {
return Promise.reject('error');
}
};
_AccountsClient2.default.config({ history: history }, transport);
_context14.prev = 2;
_context14.next = 5;
return _AccountsClient2.default.loginWithPassword('username', 'password');
case 5:
throw new Error();
case 8:
_context14.prev = 8;
_context14.t0 = _context14['catch'](2);
expect(_AccountsClient2.default.loggingIn()).toBe(false);
case 11:
case 'end':
return _context14.stop();
}
}
}, _callee14, undefined, [[2, 8]]);
})));
it('stores tokens in local storage', _asyncToGenerator(regeneratorRuntime.mark(function _callee15() {
var transport;
return regeneratorRuntime.wrap(function _callee15$(_context15) {
while (1) {
switch (_context15.prev = _context15.next) {
case 0:
transport = {
loginWithPassword: function loginWithPassword() {
return Promise.resolve(loggedInUser);

@@ -522,3 +556,3 @@ }

_AccountsClient2.default.config({ history: history }, transport);
_context14.next = 4;
_context15.next = 4;
return _AccountsClient2.default.loginWithPassword('username', 'password');

@@ -532,13 +566,13 @@

case 'end':
return _context14.stop();
return _context15.stop();
}
}
}, _callee14, undefined);
}, _callee15, undefined);
})));
it('fetch tokens from storage when storage is async', _asyncToGenerator(regeneratorRuntime.mark(function _callee15() {
it('fetch tokens from storage when storage is async', _asyncToGenerator(regeneratorRuntime.mark(function _callee16() {
var transport, tokens;
return regeneratorRuntime.wrap(function _callee15$(_context15) {
return regeneratorRuntime.wrap(function _callee16$(_context16) {
while (1) {
switch (_context15.prev = _context15.next) {
switch (_context16.prev = _context16.next) {
case 0:

@@ -561,7 +595,7 @@ transport = {

_context15.next = 4;
_context16.next = 4;
return _AccountsClient2.default.tokens();
case 4:
tokens = _context15.sent;
tokens = _context16.sent;

@@ -573,13 +607,13 @@ expect(tokens.accessToken).toBe('testValue');

case 'end':
return _context15.stop();
return _context16.stop();
}
}
}, _callee15, undefined);
}, _callee16, undefined);
})));
it('fetch tokens from storage when storage is sync', _asyncToGenerator(regeneratorRuntime.mark(function _callee16() {
it('fetch tokens from storage when storage is sync', _asyncToGenerator(regeneratorRuntime.mark(function _callee17() {
var transport, tokens;
return regeneratorRuntime.wrap(function _callee16$(_context16) {
return regeneratorRuntime.wrap(function _callee17$(_context17) {
while (1) {
switch (_context16.prev = _context16.next) {
switch (_context17.prev = _context17.next) {
case 0:

@@ -602,7 +636,7 @@ transport = {

_context16.next = 4;
_context17.next = 4;
return _AccountsClient2.default.tokens();
case 4:
tokens = _context16.sent;
tokens = _context17.sent;

@@ -614,13 +648,13 @@ expect(tokens.accessToken).toBe('testValue');

case 'end':
return _context16.stop();
return _context17.stop();
}
}
}, _callee16, undefined);
}, _callee17, undefined);
})));
it('stores user in redux', _asyncToGenerator(regeneratorRuntime.mark(function _callee17() {
it('stores user in redux', _asyncToGenerator(regeneratorRuntime.mark(function _callee18() {
var transport;
return regeneratorRuntime.wrap(function _callee17$(_context17) {
return regeneratorRuntime.wrap(function _callee18$(_context18) {
while (1) {
switch (_context17.prev = _context17.next) {
switch (_context18.prev = _context18.next) {
case 0:

@@ -634,3 +668,3 @@ transport = {

_AccountsClient2.default.config({ history: history }, transport);
_context17.next = 4;
_context18.next = 4;
return _AccountsClient2.default.loginWithPassword('username', 'password');

@@ -643,14 +677,14 @@

case 'end':
return _context17.stop();
return _context18.stop();
}
}
}, _callee17, undefined);
}, _callee18, undefined);
})));
});
describe('logout', function () {
it('calls callback on successful logout', _asyncToGenerator(regeneratorRuntime.mark(function _callee18() {
it('calls callback on successful logout', _asyncToGenerator(regeneratorRuntime.mark(function _callee19() {
var transport, callback;
return regeneratorRuntime.wrap(function _callee18$(_context18) {
return regeneratorRuntime.wrap(function _callee19$(_context19) {
while (1) {
switch (_context18.prev = _context18.next) {
switch (_context19.prev = _context19.next) {
case 0:

@@ -665,3 +699,3 @@ transport = {

callback = jest.fn();
_context18.next = 5;
_context19.next = 5;
return _AccountsClient2.default.logout(callback);

@@ -674,12 +708,12 @@

case 'end':
return _context18.stop();
return _context19.stop();
}
}
}, _callee18, undefined);
}, _callee19, undefined);
})));
it('calls onLogout on successful logout', _asyncToGenerator(regeneratorRuntime.mark(function _callee19() {
it('calls onLogout on successful logout', _asyncToGenerator(regeneratorRuntime.mark(function _callee20() {
var onSignedOutHook, transport;
return regeneratorRuntime.wrap(function _callee19$(_context19) {
return regeneratorRuntime.wrap(function _callee20$(_context20) {
while (1) {
switch (_context19.prev = _context19.next) {
switch (_context20.prev = _context20.next) {
case 0:

@@ -694,3 +728,3 @@ onSignedOutHook = jest.fn();

_AccountsClient2.default.config({ history: history, onSignedOutHook: onSignedOutHook }, transport);
_context19.next = 5;
_context20.next = 5;
return _AccountsClient2.default.logout();

@@ -703,13 +737,13 @@

case 'end':
return _context19.stop();
return _context20.stop();
}
}
}, _callee19, undefined);
}, _callee20, undefined);
})));
it('calls callback on failure with error message', _asyncToGenerator(regeneratorRuntime.mark(function _callee20() {
it('calls callback on failure with error message', _asyncToGenerator(regeneratorRuntime.mark(function _callee21() {
var transport, callback;
return regeneratorRuntime.wrap(function _callee20$(_context20) {
return regeneratorRuntime.wrap(function _callee21$(_context21) {
while (1) {
switch (_context20.prev = _context20.next) {
switch (_context21.prev = _context21.next) {
case 0:

@@ -725,4 +759,4 @@ transport = {

callback = jest.fn();
_context20.prev = 4;
_context20.next = 7;
_context21.prev = 4;
_context21.next = 7;
return _AccountsClient2.default.logout(callback);

@@ -734,6 +768,6 @@

case 10:
_context20.prev = 10;
_context20.t0 = _context20['catch'](4);
_context21.prev = 10;
_context21.t0 = _context21['catch'](4);
expect(_context20.t0.message).toEqual('error message');
expect(_context21.t0.message).toEqual('error message');
expect(callback.mock.calls.length).toEqual(1);

@@ -744,18 +778,18 @@ expect(callback.mock.calls[0][0]).toEqual({ message: 'error message' });

case 'end':
return _context20.stop();
return _context21.stop();
}
}
}, _callee20, undefined, [[4, 10]]);
}, _callee21, undefined, [[4, 10]]);
})));
});
describe('refreshSession', _asyncToGenerator(regeneratorRuntime.mark(function _callee23() {
return regeneratorRuntime.wrap(function _callee23$(_context23) {
describe('refreshSession', _asyncToGenerator(regeneratorRuntime.mark(function _callee24() {
return regeneratorRuntime.wrap(function _callee24$(_context24) {
while (1) {
switch (_context23.prev = _context23.next) {
switch (_context24.prev = _context24.next) {
case 0:
// TODO test that user and tokens are cleared if refreshToken is expired
it('clears tokens and user if tokens are not set', _asyncToGenerator(regeneratorRuntime.mark(function _callee21() {
return regeneratorRuntime.wrap(function _callee21$(_context21) {
it('clears tokens and user if tokens are not set', _asyncToGenerator(regeneratorRuntime.mark(function _callee22() {
return regeneratorRuntime.wrap(function _callee22$(_context22) {
while (1) {
switch (_context21.prev = _context21.next) {
switch (_context22.prev = _context22.next) {
case 0:

@@ -769,15 +803,15 @@ _AccountsClient2.default.config({}, {});

});
_context21.prev = 3;
_context21.next = 6;
_context22.prev = 3;
_context22.next = 6;
return _AccountsClient2.default.refreshSession();
case 6:
_context21.next = 13;
_context22.next = 13;
break;
case 8:
_context21.prev = 8;
_context21.t0 = _context21['catch'](3);
_context22.prev = 8;
_context22.t0 = _context22['catch'](3);
expect(_context21.t0.message).toEqual('no tokens provided');
expect(_context22.t0.message).toEqual('no tokens provided');
expect(_AccountsClient2.default.instance.clearTokens.mock.calls.length).toEqual(1);

@@ -788,12 +822,12 @@ expect(_AccountsClient2.default.instance.clearUser.mock.calls.length).toEqual(1);

case 'end':
return _context21.stop();
return _context22.stop();
}
}
}, _callee21, undefined, [[3, 8]]);
}, _callee22, undefined, [[3, 8]]);
})));
it('clears tokens, users and throws error if bad refresh token provided', _asyncToGenerator(regeneratorRuntime.mark(function _callee22() {
it('clears tokens, users and throws error if bad refresh token provided', _asyncToGenerator(regeneratorRuntime.mark(function _callee23() {
var message;
return regeneratorRuntime.wrap(function _callee22$(_context22) {
return regeneratorRuntime.wrap(function _callee23$(_context23) {
while (1) {
switch (_context22.prev = _context22.next) {
switch (_context23.prev = _context23.next) {
case 0:

@@ -809,4 +843,4 @@ _AccountsClient2.default.config({}, {});

});
_context22.prev = 5;
_context22.next = 8;
_context23.prev = 5;
_context23.next = 8;
return _AccountsClient2.default.refreshSession();

@@ -818,5 +852,5 @@

case 11:
_context22.prev = 11;
_context22.t0 = _context22['catch'](5);
message = _context22.t0.message;
_context23.prev = 11;
_context23.t0 = _context23['catch'](5);
message = _context23.t0.message;

@@ -827,6 +861,6 @@ expect(message).toEqual('falsy token provided');

case 'end':
return _context22.stop();
return _context23.stop();
}
}
}, _callee22, undefined, [[5, 11]]);
}, _callee23, undefined, [[5, 11]]);
})));

@@ -870,7 +904,7 @@ // it('requests a new token pair, sets the tokens and the user', async () => {

case 'end':
return _context23.stop();
return _context24.stop();
}
}
}, _callee23, undefined);
}, _callee24, undefined);
})));
});
{
"name": "@accounts/client",
"version": "0.0.7",
"version": "0.0.8",
"description": "Fullstack authentication and accounts-management",

@@ -67,3 +67,3 @@ "main": "lib/index.js",

"dependencies": {
"@accounts/common": "next",
"@accounts/common": "^0.0.7",
"immutable": "^3.8.1",

@@ -70,0 +70,0 @@ "jwt-decode": "^2.1.0",

Sorry, the diff of this file is not supported yet

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