All files / src/services index.ts

100% Statements 36/36
50% Branches 1/2
100% Functions 15/15
100% Lines 36/36

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 861x 1x   1x   1x   1x 1x 1x 1x 1x 1x 1x 1x 1x 1x   1x               1x                               2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x     1x   1x     150x                           1x 809x   809x       1x 1x    
import _cloneDeep from 'lodash/cloneDeep';
import _pick from 'lodash/pick';
 
import { AuthenticationManagementService } from './AuthenticationManagementService';
 
import { CheckUniqueService } from './CheckUniqueService';
 
import { IdentityChangeService } from './IdentityChangeService';
import { PasswordChangeService } from './PasswordChangeService';
import { ResendVerifySignupService } from './ResendVerifySignupService';
import { ResetPwdLongService } from './ResetPwdLongService';
import { ResetPwdShortService } from './ResetPwdShortService';
import { SendResetPwdService } from './SendResetPwdService';
import { VerifySignupLongService } from './VerifySignupLongService';
import { VerifySignupSetPasswordLongService } from './VerifySignupSetPasswordLongService';
import { VerifySignupSetPasswordShortService } from './VerifySignupSetPasswordShortService';
import { VerifySignupShortService } from './VerifySignupShort';
 
import sanitizeUserForClient from '../helpers/sanitize-user-for-client';
 
import type {
  AuthenticationManagementServiceOptionsDefault,
  NotificationType,
  User
} from '../types';
 
const services = {
  AuthenticationManagementService,
  IdentityChangeService,
  PasswordChangeService,
  ResendVerifySignupService,
  ResetPwdLongService,
  ResetPwdShortService,
  SendResetPwdService,
  VerifySignupLongService,
  VerifySignupSetPasswordLongService,
  VerifySignupSetPasswordShortService,
  VerifySignupShortService,
  CheckUniqueService
};
 
export {
  AuthenticationManagementService,
  IdentityChangeService,
  PasswordChangeService,
  ResendVerifySignupService,
  ResetPwdLongService,
  ResetPwdShortService,
  SendResetPwdService,
  VerifySignupLongService,
  VerifySignupSetPasswordLongService,
  VerifySignupSetPasswordShortService,
  VerifySignupShortService,
  CheckUniqueService
};
 
export default services;
 
export const optionsDefault: AuthenticationManagementServiceOptionsDefault = {
  service: '/users', // need exactly this for test suite
  // eslint-disable-next-line @typescript-eslint/no-empty-function
  notifier: async (type: NotificationType, user: User, notifierOptions) => {},
  longTokenLen: 15, // token's length will be twice this
  shortTokenLen: 6,
  shortTokenDigits: true,
  resetDelay: 1000 * 60 * 60 * 2, // 2 hours
  delay: 1000 * 60 * 60 * 24 * 5, // 5 days
  resetAttempts: 0,
  reuseResetToken: false,
  identifyUserProps: ['email'],
  sanitizeUserForClient,
  skipIsVerifiedCheck: false,
  passwordField: 'password'
};
 
export function makeDefaultOptions<K extends keyof AuthenticationManagementServiceOptionsDefault> (keys: K[]): Pick<AuthenticationManagementServiceOptionsDefault, K> {
  const options = _cloneDeep(optionsDefault);
  // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
  return _pick(options, keys);
}
 
// commonjs
Eif (typeof module !== 'undefined') {
  module.exports = Object.assign(services, module.exports);
}