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

@accounts/password

Package Overview
Dependencies
Maintainers
3
Versions
139
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@accounts/password - npm Package Compare versions

Comparing version 0.32.2 to 1.0.0-alpha-20231022085748-0910b9e1

lib/types/AccountsPasswordConfig.symbol.d.ts

10

lib/accounts-password.d.ts

@@ -1,2 +0,2 @@

import { User, TokenRecord, DatabaseInterface, AuthenticationService, ConnectionInformations, LoginResult, CreateUserServicePassword, LoginUserPasswordService } from '@accounts/types';
import { User, TokenRecord, DatabaseInterface, AuthenticationService, ConnectionInformations, LoginResult, CreateUserServicePassword, LoginUserPasswordService, DatabaseInterfaceSessions, DatabaseInterfaceUser } from '@accounts/types';
import { TwoFactor, AccountsTwoFactorOptions } from '@accounts/two-factor';

@@ -92,3 +92,3 @@ import { AccountsServer } from '@accounts/server';

}
export default class AccountsPassword<CustomUser extends User = User> implements AuthenticationService {
export default class AccountsPassword<CustomUser extends User = User> implements AuthenticationService<CustomUser> {
serviceName: string;

@@ -99,4 +99,6 @@ server: AccountsServer;

private db;
constructor(options?: AccountsPasswordOptions);
setStore(store: DatabaseInterface<CustomUser>): void;
private dbSessions;
constructor(options?: AccountsPasswordOptions, db?: DatabaseInterface<CustomUser> | DatabaseInterfaceUser<CustomUser>, dbSessions?: DatabaseInterfaceSessions, server?: AccountsServer);
setUserStore(store: DatabaseInterfaceUser<CustomUser>): void;
setSessionsStore(store?: DatabaseInterfaceSessions): void;
authenticate(params: LoginUserPasswordService): Promise<CustomUser>;

@@ -103,0 +105,0 @@ /**

36

lib/accounts-password.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
const two_factor_1 = require("@accounts/two-factor");
const server_1 = require("@accounts/server");
const utils_1 = require("./utils");
const types_1 = require("./types");
const errors_1 = require("./errors");
const validation_1 = require("./utils/validation");
const graphql_modules_1 = require("graphql-modules");
const defaultOptions = {

@@ -46,12 +49,22 @@ // 3 days - 3 * 24 * 60 * 60 * 1000

};
class AccountsPassword {
constructor(options = {}) {
let AccountsPassword = class AccountsPassword {
constructor(options = {}, db, dbSessions, server) {
this.serviceName = 'password';
this.options = { ...defaultOptions, ...options };
this.twoFactor = new two_factor_1.TwoFactor(options.twoFactor);
if (db) {
this.db = db;
this.dbSessions = dbSessions !== null && dbSessions !== void 0 ? dbSessions : db;
}
if (server) {
this.server = server;
}
}
setStore(store) {
setUserStore(store) {
this.db = store;
this.twoFactor.setStore(store);
this.twoFactor.setUserStore(store);
}
setSessionsStore(store) {
this.dbSessions = store !== null && store !== void 0 ? store : this.db;
}
async authenticate(params) {

@@ -183,3 +196,3 @@ const { user, password, code } = params;

if (this.options.invalidateAllSessionsAfterPasswordReset) {
await this.db.invalidateAllSessions(user.id);
await this.dbSessions.invalidateAllSessions(user.id);
}

@@ -227,3 +240,3 @@ if (this.options.notifyUserAfterPasswordChanged) {

if (this.options.invalidateAllSessionsAfterPasswordChanged) {
await this.db.invalidateAllSessions(user.id);
await this.dbSessions.invalidateAllSessions(user.id);
}

@@ -418,4 +431,13 @@ if (this.options.removeAllResetPasswordTokensAfterPasswordChanged) {

}
}
};
AccountsPassword = tslib_1.__decorate([
(0, graphql_modules_1.Injectable)({
global: true,
}),
tslib_1.__param(0, (0, graphql_modules_1.Inject)(types_1.AccountsPasswordConfigToken)),
tslib_1.__param(1, (0, graphql_modules_1.Inject)(server_1.DatabaseInterfaceUserToken)),
tslib_1.__param(2, (0, graphql_modules_1.Inject)(server_1.DatabaseInterfaceSessionsToken)),
tslib_1.__metadata("design:paramtypes", [Object, Object, Object, server_1.AccountsServer])
], AccountsPassword);
exports.default = AccountsPassword;
//# sourceMappingURL=accounts-password.js.map

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

CreateUserErrors["UsernameAlreadyExists"] = "UsernameAlreadyExists";
})(CreateUserErrors = exports.CreateUserErrors || (exports.CreateUserErrors = {}));
})(CreateUserErrors || (exports.CreateUserErrors = CreateUserErrors = {}));
var AddEmailErrors;

@@ -59,3 +59,3 @@ (function (AddEmailErrors) {

AddEmailErrors["InvalidEmail"] = "InvalidEmail";
})(AddEmailErrors = exports.AddEmailErrors || (exports.AddEmailErrors = {}));
})(AddEmailErrors || (exports.AddEmailErrors = AddEmailErrors = {}));
var VerifyEmailErrors;

@@ -75,3 +75,3 @@ (function (VerifyEmailErrors) {

VerifyEmailErrors["VerifyEmailLinkUnknownAddress"] = "VerifyEmailLinkUnknownAddress";
})(VerifyEmailErrors = exports.VerifyEmailErrors || (exports.VerifyEmailErrors = {}));
})(VerifyEmailErrors || (exports.VerifyEmailErrors = VerifyEmailErrors = {}));
var ResetPasswordErrors;

@@ -99,3 +99,3 @@ (function (ResetPasswordErrors) {

ResetPasswordErrors["NoEmailSet"] = "NoEmailSet";
})(ResetPasswordErrors = exports.ResetPasswordErrors || (exports.ResetPasswordErrors = {}));
})(ResetPasswordErrors || (exports.ResetPasswordErrors = ResetPasswordErrors = {}));
var PasswordAuthenticatorErrors;

@@ -107,3 +107,3 @@ (function (PasswordAuthenticatorErrors) {

PasswordAuthenticatorErrors["NoPasswordSet"] = "NoPasswordSet";
})(PasswordAuthenticatorErrors = exports.PasswordAuthenticatorErrors || (exports.PasswordAuthenticatorErrors = {}));
})(PasswordAuthenticatorErrors || (exports.PasswordAuthenticatorErrors = PasswordAuthenticatorErrors = {}));
var AuthenticateErrors;

@@ -118,3 +118,3 @@ (function (AuthenticateErrors) {

AuthenticateErrors["NoPasswordSet"] = "NoPasswordSet";
})(AuthenticateErrors = exports.AuthenticateErrors || (exports.AuthenticateErrors = {}));
})(AuthenticateErrors || (exports.AuthenticateErrors = AuthenticateErrors = {}));
var ChangePasswordErrors;

@@ -135,3 +135,3 @@ (function (ChangePasswordErrors) {

ChangePasswordErrors["NoPasswordSet"] = "NoPasswordSet";
})(ChangePasswordErrors = exports.ChangePasswordErrors || (exports.ChangePasswordErrors = {}));
})(ChangePasswordErrors || (exports.ChangePasswordErrors = ChangePasswordErrors = {}));
var SendVerificationEmailErrors;

@@ -148,3 +148,3 @@ (function (SendVerificationEmailErrors) {

SendVerificationEmailErrors["UserNotFound"] = "UserNotFound";
})(SendVerificationEmailErrors = exports.SendVerificationEmailErrors || (exports.SendVerificationEmailErrors = {}));
})(SendVerificationEmailErrors || (exports.SendVerificationEmailErrors = SendVerificationEmailErrors = {}));
var SendResetPasswordEmailErrors;

@@ -161,3 +161,3 @@ (function (SendResetPasswordEmailErrors) {

SendResetPasswordEmailErrors["UserNotFound"] = "UserNotFound";
})(SendResetPasswordEmailErrors = exports.SendResetPasswordEmailErrors || (exports.SendResetPasswordEmailErrors = {}));
})(SendResetPasswordEmailErrors || (exports.SendResetPasswordEmailErrors = SendResetPasswordEmailErrors = {}));
var SendEnrollmentEmailErrors;

@@ -174,3 +174,3 @@ (function (SendEnrollmentEmailErrors) {

SendEnrollmentEmailErrors["UserNotFound"] = "UserNotFound";
})(SendEnrollmentEmailErrors = exports.SendEnrollmentEmailErrors || (exports.SendEnrollmentEmailErrors = {}));
})(SendEnrollmentEmailErrors || (exports.SendEnrollmentEmailErrors = SendEnrollmentEmailErrors = {}));
//# sourceMappingURL=errors.js.map

@@ -1,5 +0,5 @@

import AccountsPassword from './accounts-password';
import AccountsPassword, { AccountsPasswordOptions } from './accounts-password';
export * from './types';
export { AddEmailErrors, ChangePasswordErrors, CreateUserErrors, ResetPasswordErrors, SendVerificationEmailErrors, SendResetPasswordEmailErrors, VerifyEmailErrors, } from './errors';
export default AccountsPassword;
export { AccountsPassword };
export { AccountsPassword, AccountsPasswordOptions };

@@ -5,5 +5,5 @@ "use strict";

const tslib_1 = require("tslib");
const accounts_password_1 = (0, tslib_1.__importDefault)(require("./accounts-password"));
const accounts_password_1 = tslib_1.__importDefault(require("./accounts-password"));
exports.AccountsPassword = accounts_password_1.default;
(0, tslib_1.__exportStar)(require("./types"), exports);
tslib_1.__exportStar(require("./types"), exports);
var errors_1 = require("./errors");

@@ -10,0 +10,0 @@ Object.defineProperty(exports, "AddEmailErrors", { enumerable: true, get: function () { return errors_1.AddEmailErrors; } });

export { ErrorMessages } from './error-messages';
export * from './AccountsPasswordConfig.symbol';
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
tslib_1.__exportStar(require("./AccountsPasswordConfig.symbol"), exports);
//# sourceMappingURL=index.js.map

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

export declare const isEmail: (email?: string | undefined) => boolean;
export declare const isEmail: (email?: string) => boolean;
{
"name": "@accounts/password",
"version": "0.32.2",
"version": "1.0.0-alpha-20231022085748-0910b9e1",
"license": "MIT",
"main": "lib/index.js",
"typings": "lib/index.d.ts",
"scripts": {
"clean": "yarn run -T rimraf lib",
"start": "yarn run -T tsc --watch",
"precompile": "yarn run clean",
"compile": "yarn run -T tsc",
"prepublishOnly": "yarn run compile",
"testonly": "yarn run -T jest",
"coverage": "yarn run -T jest --coverage"
},
"files": [

@@ -16,30 +25,21 @@ "src",

"dependencies": {
"@accounts/two-factor": "^0.32.4",
"bcryptjs": "^2.4.3",
"tslib": "2.3.1"
"@accounts/two-factor": "1.0.0-alpha-20231022085748-0910b9e1",
"bcryptjs": "2.4.3",
"tslib": "2.6.2"
},
"devDependencies": {
"@accounts/server": "^0.33.1",
"@accounts/types": "^0.33.1",
"@types/bcryptjs": "2.4.2",
"@types/jest": "27.0.2",
"@types/lodash.set": "4.3.6",
"@types/node": "16.11.7",
"jest": "27.3.1",
"@accounts/server": "1.0.0-alpha-20231022085748-0910b9e1",
"@accounts/types": "1.0.0-alpha-20231022085748-0910b9e1",
"@types/bcryptjs": "2.4.5",
"@types/lodash.set": "4.3.8",
"graphql": "16.8.1",
"graphql-modules": "3.0.0-alpha-20231018163544-36199b68",
"lodash.set": "4.3.2",
"rimraf": "3.0.2",
"ts-jest": "27.0.7"
"reflect-metadata": "0.1.13"
},
"peerDependencies": {
"@accounts/server": "^0.32.0 || ^0.33.0"
},
"scripts": {
"clean": "rimraf lib",
"start": "tsc --watch",
"precompile": "pnpm run clean",
"compile": "tsc",
"testonly": "jest --coverage",
"coverage": "jest --coverage"
},
"readme": "# @accounts/password\n\n[![npm](https://img.shields.io/npm/v/@accounts/password)](https://www.npmjs.com/package/@accounts/password)\n[![npm downloads](https://img.shields.io/npm/dm/@accounts/password)](https://www.npmjs.com/package/@accounts/password)\n[![codecov](https://img.shields.io/codecov/c/github/accounts-js/accounts)](https://codecov.io/gh/accounts-js/accounts)\n[![License](https://img.shields.io/github/license/accounts-js/accounts)](https://github.com/accounts-js/accounts/blob/master/LICENSE)\n\n## Documentation\n\n- [Website documentation](https://www.accountsjs.com/docs/strategies/password)\n- [API documentation](https://www.accountsjs.com/docs/api/password/globals)\n\n## Installation\n\n```\nyarn add @accounts/password\n```\n\n## Contributing\n\nAny contribution is very welcome, read our [contributing guide](https://github.com/accounts-js/accounts/blob/master/CONTRIBUTING.md) to see how to locally setup the repository and see our development process.\n"
}
"@accounts/server": "1.0.0-alpha-20231022085748-0910b9e1",
"graphql": "^16.0.0",
"graphql-modules": "^3.0.0"
}
}

@@ -12,2 +12,4 @@ import {

LoginUserPasswordService,
DatabaseInterfaceSessions,
DatabaseInterfaceUser,
} from '@accounts/types';

@@ -20,2 +22,4 @@ import { TwoFactor, AccountsTwoFactorOptions, getUserTwoFactorService } from '@accounts/two-factor';

AccountsJsError,
DatabaseInterfaceUserToken,
DatabaseInterfaceSessionsToken,
} from '@accounts/server';

@@ -29,3 +33,3 @@ import {

} from './utils';
import { ErrorMessages } from './types';
import { AccountsPasswordConfigToken, ErrorMessages } from './types';
import {

@@ -45,2 +49,3 @@ errors,

import { isObject, isString } from './utils/validation';
import { Inject, Injectable } from 'graphql-modules';

@@ -178,4 +183,7 @@ export interface AccountsPasswordOptions {

@Injectable({
global: true,
})
export default class AccountsPassword<CustomUser extends User = User>
implements AuthenticationService
implements AuthenticationService<CustomUser>
{

@@ -186,14 +194,32 @@ public serviceName = 'password';

private options: AccountsPasswordOptions & typeof defaultOptions;
private db!: DatabaseInterface<CustomUser>;
private db!: DatabaseInterfaceUser<CustomUser>;
private dbSessions!: DatabaseInterfaceSessions;
constructor(options: AccountsPasswordOptions = {}) {
constructor(
@Inject(AccountsPasswordConfigToken) options: AccountsPasswordOptions = {},
@Inject(DatabaseInterfaceUserToken)
db?: DatabaseInterface<CustomUser> | DatabaseInterfaceUser<CustomUser>,
@Inject(DatabaseInterfaceSessionsToken) dbSessions?: DatabaseInterfaceSessions,
server?: AccountsServer
) {
this.options = { ...defaultOptions, ...options };
this.twoFactor = new TwoFactor(options.twoFactor);
if (db) {
this.db = db;
this.dbSessions = dbSessions ?? (db as DatabaseInterfaceSessions);
}
if (server) {
this.server = server;
}
}
public setStore(store: DatabaseInterface<CustomUser>) {
public setUserStore(store: DatabaseInterfaceUser<CustomUser>) {
this.db = store;
this.twoFactor.setStore(store);
this.twoFactor.setUserStore(store);
}
public setSessionsStore(store?: DatabaseInterfaceSessions) {
this.dbSessions = store ?? (this.db as unknown as DatabaseInterfaceSessions);
}
public async authenticate(params: LoginUserPasswordService): Promise<CustomUser> {

@@ -377,3 +403,3 @@ const { user, password, code } = params;

if (this.options.invalidateAllSessionsAfterPasswordReset) {
await this.db.invalidateAllSessions(user.id);
await this.dbSessions.invalidateAllSessions(user.id);
}

@@ -444,3 +470,3 @@

if (this.options.invalidateAllSessionsAfterPasswordChanged) {
await this.db.invalidateAllSessions(user.id);
await this.dbSessions.invalidateAllSessions(user.id);
}

@@ -447,0 +473,0 @@

@@ -1,2 +0,2 @@

import AccountsPassword from './accounts-password';
import AccountsPassword, { AccountsPasswordOptions } from './accounts-password';
export * from './types';

@@ -14,2 +14,2 @@ export {

export default AccountsPassword;
export { AccountsPassword };
export { AccountsPassword, AccountsPasswordOptions };
export { ErrorMessages } from './error-messages';
export * from './AccountsPasswordConfig.symbol';

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

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