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.1.0-alpha.42868044 to 0.1.0-alpha.04203cca

11

lib/accounts-client.d.ts
import { Map } from 'immutable';
import { CreateUserType, LoginUserIdentityType, LoginReturnType, UserObjectType, TokensType, ImpersonateReturnType } from '@accounts/common';
import { CreateUserType, LoginReturnType, UserObjectType, TokensType, ImpersonateReturnType } from '@accounts/common';
import { AccountsClientConfiguration } from './config';

@@ -29,3 +29,6 @@ import { TransportInterface } from './transport-interface';

refreshSession(): Promise<void>;
createUser(user: CreateUserType, callback?: (err?: Error) => void): Promise<void>;
createUser(user: CreateUserType): Promise<void>;
loginWithService(service: string, credentials: {
[key: string]: string | object;
}): Promise<LoginReturnType>;
loggingIn(): boolean;

@@ -43,3 +46,5 @@ isLoading(): boolean;

createUser(user: CreateUserType, callback?: (err?: Error) => void): Promise<void>;
loginWithPassword(user: LoginUserIdentityType, password: string, callback?: (err?: Error, res?: LoginReturnType) => void): Promise<void>;
loginWithService(service: string, credentials: {
[key: string]: string | object;
}): Promise<LoginReturnType>;
loggingIn(): boolean;

@@ -46,0 +51,0 @@ isLoading(): boolean;

@@ -66,3 +66,3 @@ "use strict";

function AccountsClient(options, transport) {
this.options = options;
this.options = __assign({}, config_1.default, options);
this.storage = options.tokenStorage || config_1.default.tokenStorage;

@@ -198,3 +198,2 @@ if (!transport) {

this.store.dispatch(module_1.setTokens(res.tokens));
this.store.dispatch(module_1.setUser(res.user));
return [2, res];

@@ -364,3 +363,2 @@ }

this.store.dispatch(module_1.setTokens(refreshedSession.tokens));
this.store.dispatch(module_1.setUser(refreshedSession.user));
_b.label = 6;

@@ -384,3 +382,3 @@ case 6: return [3, 8];

};
AccountsClient.prototype.createUser = function (user, callback) {
AccountsClient.prototype.createUser = function (user) {
return __awaiter(this, void 0, void 0, function () {

@@ -410,5 +408,2 @@ var hashAlgorithm, userToCreate, userId, onUserCreated, err_3, err_4;

onUserCreated = this.options.onUserCreated;
if (callback && lodash_1.isFunction(callback)) {
callback();
}
if (!lodash_1.isFunction(onUserCreated)) return [3, 6];

@@ -429,5 +424,2 @@ _a.label = 3;

err_4 = _a.sent();
if (callback && lodash_1.isFunction(callback)) {
callback(err_4);
}
throw new common_1.AccountsError(err_4.message);

@@ -439,2 +431,48 @@ case 8: return [2];

};
AccountsClient.prototype.loginWithService = function (service, credentials) {
return __awaiter(this, void 0, void 0, function () {
var response, onSignedInHook, err_5, err_6;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
if (!lodash_1.isString(service)) {
throw new common_1.AccountsError('Unrecognized options for login request');
}
_a.label = 1;
case 1:
_a.trys.push([1, 8, , 9]);
this.store.dispatch(module_1.loggingIn(true));
return [4, this.transport.loginWithService(service, credentials)];
case 2:
response = _a.sent();
this.store.dispatch(module_1.loggingIn(false));
return [4, this.storeTokens(response.tokens)];
case 3:
_a.sent();
this.store.dispatch(module_1.setTokens(response.tokens));
onSignedInHook = this.options.onSignedInHook;
if (!lodash_1.isFunction(onSignedInHook)) return [3, 7];
_a.label = 4;
case 4:
_a.trys.push([4, 6, , 7]);
return [4, onSignedInHook(response)];
case 5:
_a.sent();
return [3, 7];
case 6:
err_5 = _a.sent();
console.error(err_5);
return [3, 7];
case 7: return [2, response];
case 8:
err_6 = _a.sent();
this.clearTokens();
this.store.dispatch(module_1.clearUser());
this.store.dispatch(module_1.loggingIn(false));
throw new common_1.AccountsError(err_6.message);
case 9: return [2];
}
});
});
};
AccountsClient.prototype.loggingIn = function () {

@@ -448,3 +486,3 @@ return this.getState().get('loggingIn');

return __awaiter(this, void 0, void 0, function () {
var accessToken, err_5;
var accessToken, err_7;
return __generator(this, function (_a) {

@@ -473,9 +511,9 @@ switch (_a.label) {

case 4:
err_5 = _a.sent();
err_7 = _a.sent();
this.clearTokens();
this.store.dispatch(module_1.clearUser());
if (callback && lodash_1.isFunction(callback)) {
callback(err_5);
callback(err_7);
}
throw new common_1.AccountsError(err_5.message);
throw new common_1.AccountsError(err_7.message);
case 5: return [2];

@@ -488,3 +526,3 @@ }

return __awaiter(this, void 0, void 0, function () {
var err_6;
var err_8;
return __generator(this, function (_a) {

@@ -499,4 +537,4 @@ switch (_a.label) {

case 2:
err_6 = _a.sent();
throw new common_1.AccountsError(err_6.message);
err_8 = _a.sent();
throw new common_1.AccountsError(err_8.message);
case 3: return [2];

@@ -539,4 +577,4 @@ }

},
loginWithPassword: function (user, password, callback) {
return this.instance.loginWithPassword(user, password, callback);
loginWithService: function (service, credentials) {
return this.instance.loginWithService(service, credentials);
},

@@ -543,0 +581,0 @@ loggingIn: function () {

@@ -61,7 +61,2 @@ import { AccountsCommonConfiguration, HookListener, PasswordSignupFields } from '@accounts/common';

signOutPath: string;
onEnrollAccountHook: () => number;
onResetPasswordHook: () => number;
onVerifyEmailHook: () => number;
onSignedInHook: () => number;
onSignedOutHook: () => number;
loginOnSignUp: boolean;

@@ -68,0 +63,0 @@ persistImpersonation: boolean;

@@ -12,4 +12,2 @@ "use strict";

var common_1 = require("@accounts/common");
var accounts_client_1 = require("./accounts-client");
var redirect_1 = require("./redirect");
var localStorageToTokenStorage = function () {

@@ -31,9 +29,3 @@ return {

};
exports.default = __assign({}, common_1.config, { store: null, reduxLogger: null, reduxStoreKey: 'accounts', tokenStorage: localStorageToTokenStorage(), server: '', tokenStoragePrefix: '', title: '', requestPermissions: [], requestOfflineToken: {}, forceApprovalPrompt: {}, requireEmailVerification: false, loginPath: '/', signUpPath: null, resetPasswordPath: null, profilePath: '/', changePasswordPath: null, homePath: '/', signOutPath: '/', onEnrollAccountHook: function () {
return redirect_1.default(accounts_client_1.default.options().loginPath || '/');
}, onResetPasswordHook: function () {
return redirect_1.default(accounts_client_1.default.options().loginPath || '/');
}, onVerifyEmailHook: function () {
return redirect_1.default(accounts_client_1.default.options().profilePath || '/');
}, onSignedInHook: function () { return redirect_1.default(accounts_client_1.default.options().homePath || '/'); }, onSignedOutHook: function () { return redirect_1.default(accounts_client_1.default.options().signOutPath || '/'); }, loginOnSignUp: true, persistImpersonation: true });
exports.default = __assign({}, common_1.config, { store: null, reduxLogger: null, reduxStoreKey: 'accounts', tokenStorage: localStorageToTokenStorage(), server: '', tokenStoragePrefix: '', title: '', requestPermissions: [], requestOfflineToken: {}, forceApprovalPrompt: {}, requireEmailVerification: false, loginPath: '/', signUpPath: null, resetPasswordPath: null, profilePath: '/', changePasswordPath: null, homePath: '/', signOutPath: '/', loginOnSignUp: true, persistImpersonation: true });
//# sourceMappingURL=config.js.map
import { CreateUserType, LoginReturnType, ImpersonateReturnType } from '@accounts/common';
export interface TransportInterface {
createUser(user: CreateUserType): Promise<string>;
loginWithService(service: string, authenticateParams: {
[key: string]: string | object;
}): Promise<LoginReturnType>;
logout(accessToken: string): Promise<void>;

@@ -5,0 +8,0 @@ refreshTokens(accessToken: string, refreshToken: string): Promise<LoginReturnType>;

{
"name": "@accounts/client",
"version": "0.1.0-alpha.42868044",
"version": "0.1.0-alpha.04203cca",
"description": "Fullstack authentication and accounts-management",

@@ -15,6 +15,7 @@ "main": "lib/index.js",

"compile": "tsc",
"prepublish": "npm run compile",
"prepublishOnly": "npm run compile",
"test": "npm run testonly",
"test-ci": "npm lint && npm coverage",
"testonly": "jest",
"test:watch": "jest --watch",
"coverage": "npm run testonly -- --coverage",

@@ -54,3 +55,2 @@ "coveralls": "cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js && rm -rf ./coverage"

"coveralls": "^2.11.14",
"flow-bin": "0.41.0",
"jest": "^20.0.4",

@@ -64,3 +64,3 @@ "jsonwebtoken": "^7.4.1",

"dependencies": {
"@accounts/common": "^0.1.0-alpha.42868044",
"@accounts/common": "^0.1.0-alpha.04203cca",
"crypto-js": "^3.1.9-1",

@@ -67,0 +67,0 @@ "immutable": "^3.8.1",

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