API Reference
Rockets Core API
nestjs-password
classes
PasswordCreationService

Class: PasswordCreationService

Service with functions related to password creation to check if password is strong, and the number of attempts user can do to update a password

Implements

Constructors

new PasswordCreationService()

new PasswordCreationService(settings, passwordStorageService, passwordValidationService, passwordStrengthService): PasswordCreationService

Constructor

Parameters

ParameterType
settingsPasswordSettingsInterface
passwordStorageServicePasswordStorageService
passwordValidationServicePasswordValidationService
passwordStrengthServicePasswordStrengthService

Returns

PasswordCreationService

Defined in

packages/nestjs-password/src/services/password-creation.service.ts:26 (opens in a new tab)

Properties

PropertyModifierType
passwordStorageServicereadonlyPasswordStorageService
passwordStrengthServicereadonlyPasswordStrengthService
passwordValidationServicereadonlyPasswordValidationService
settingsreadonlyPasswordSettingsInterface

Methods

checkAttempt()

checkAttempt(numOfAttempts): boolean

Check if number of current attempt is allowed based on the amount of attempts left if the number of attempts left is greater then

Parameters

ParameterTypeDefault value
numOfAttemptsnumber0

Returns

boolean

Number of attempts user has to try

Implementation of

PasswordCreationServiceInterface.checkAttempt

Defined in

packages/nestjs-password/src/services/password-creation.service.ts:155 (opens in a new tab)


checkAttemptLeft()

checkAttemptLeft(numOfAttempts): number

Check number of attempts of using password

Parameters

ParameterTypeDefault valueDescription
numOfAttemptsnumber0number of attempts

Returns

number

Implementation of

PasswordCreationServiceInterface.checkAttemptLeft

Defined in

packages/nestjs-password/src/services/password-creation.service.ts:164 (opens in a new tab)


createObject()

Create password for an object.

Param

An object containing the new password to hash.

Param

Password create options.

createObject(object, options)

createObject<T>(object, options?): Promise<Omit<T, "password"> & PasswordStorageInterface>

Create password for an object.

Type Parameters
Type Parameter
T extends PasswordPlainInterface
Parameters
ParameterTypeDescription
objectTAn object containing the new password to hash.
options?PasswordCreateObjectOptionsInterfacePassword create options.
Returns

Promise<Omit<T, "password"> & PasswordStorageInterface>

A new object with the password hashed, with salt added.

Implementation of

PasswordCreationServiceInterface.createObject

Defined in

packages/nestjs-password/src/services/password-creation.service.ts:41 (opens in a new tab)

createObject(object, options)

createObject<T>(object, options?): Promise<Omit<T, "password"> | Omit<T, "password"> & Partial<PasswordStorageInterface>>

Create password for an object.

Type Parameters
Type Parameter
T extends Partial<PasswordPlainInterface>
Parameters
ParameterTypeDescription
objectTAn object containing the new password to hash.
options?PasswordCreateObjectOptionsInterfacePassword create options.
Returns

Promise<Omit<T, "password"> | Omit<T, "password"> & Partial<PasswordStorageInterface>>

A new object with the password hashed, with salt added.

Implementation of

PasswordCreationServiceInterface.createObject

Defined in

packages/nestjs-password/src/services/password-creation.service.ts:53 (opens in a new tab)


validateCurrent()

validateCurrent(options): Promise<boolean>

Validate the current password for the targeted object.

Parameters

ParameterTypeDescription
optionsPartial<PasswordCurrentPasswordInterface>Validate current options.

Returns

Promise<boolean>

boolean

Implementation of

PasswordCreationServiceInterface.validateCurrent

Defined in

packages/nestjs-password/src/services/password-creation.service.ts:89 (opens in a new tab)


validateHistory()

validateHistory(options): Promise<boolean>

Validate the array of password stores to check for previous usage.

Parameters

ParameterTypeDescription
optionsPartial<PasswordHistoryPasswordInterface>Validate history options.

Returns

Promise<boolean>

boolean Returns true if password has NOT been used withing configured range.

Implementation of

PasswordCreationServiceInterface.validateHistory

Defined in

packages/nestjs-password/src/services/password-creation.service.ts:114 (opens in a new tab)