API Reference
Rockets Core API
nestjs-otp
classes
OtpService

Class: OtpService

Implements

  • OtpServiceInterface

Constructors

new OtpService()

new OtpService(allOtpRepos, settings): OtpService

Parameters

ParameterType
allOtpReposRecord<string, Repository<OtpInterface>>
settingsOtpSettingsInterface

Returns

OtpService

Defined in

packages/nestjs-otp/src/services/otp.service.ts:31 (opens in a new tab)

Properties

PropertyModifierType
settingsreadonlyOtpSettingsInterface

Methods

clear()

clear(assignment, otp, queryOptions?): Promise<void>

Clear all otps for assign in given category.

Parameters

ParameterTypeDescription
assignmentstringThe assignment of the repository
otpPick<OtpInterface, "category" | "assignee">The otp to clear
queryOptions?QueryOptionsInterface-

Returns

Promise<void>

Implementation of

OtpServiceInterface.clear

Defined in

packages/nestjs-otp/src/services/otp.service.ts:141 (opens in a new tab)


create()

create(assignment, otp, queryOptions?): Promise<OtpInterface>

Create a otp with a for the given assignee.

Parameters

ParameterTypeDescription
assignmentstringThe otp assignment
otpOtpCreatableInterfaceThe data to create
queryOptions?QueryOptionsInterface-

Returns

Promise<OtpInterface>

Implementation of

OtpServiceInterface.create

Defined in

packages/nestjs-otp/src/services/otp.service.ts:44 (opens in a new tab)


delete()

delete(assignment, otp, queryOptions?): Promise<void>

Delete a otp based on params

Parameters

ParameterTypeDescription
assignmentstringThe otp assignment
otpPick<OtpInterface, "category" | "assignee" | "passcode">The otp to delete
queryOptions?QueryOptionsInterface-

Returns

Promise<void>

Implementation of

OtpServiceInterface.delete

Defined in

packages/nestjs-otp/src/services/otp.service.ts:122 (opens in a new tab)


deleteOtp()

protected deleteOtp(assignment, id, queryOptions?): Promise<void>

Internal

Delete OTP based on assignment

Parameters

ParameterTypeDescription
assignmentstringThe assignment to delete id from
idstring | string[]The id or ids to delete
queryOptions?QueryOptionsInterface-

Returns

Promise<void>

Defined in

packages/nestjs-otp/src/services/otp.service.ts:167 (opens in a new tab)


getAssignedOtps()

protected getAssignedOtps(assignment, otp, queryOptions?): Promise<OtpInterface[]>

Get all OTPs for assignee.

Parameters

ParameterTypeDescription
assignmentstringThe assignment of the check
otpPick<OtpInterface, "category" | "assignee">The otp to get assignments
queryOptions?QueryOptionsInterface-

Returns

Promise<OtpInterface[]>

Defined in

packages/nestjs-otp/src/services/otp.service.ts:191 (opens in a new tab)


getAssignmentRepo()

protected getAssignmentRepo(assignment): Repository<OtpInterface>

Internal

Get the assignment repo for the given assignment.

Parameters

ParameterTypeDescription
assignmentstringThe otp assignment

Returns

Repository<OtpInterface>

Defined in

packages/nestjs-otp/src/services/otp.service.ts:261 (opens in a new tab)


getByPasscode()

protected getByPasscode(assignment, otp, queryOptions?): Promise<null | OtpInterface>

Parameters

ParameterType
assignmentstring
otpPick<OtpInterface, "category" | "passcode">
queryOptions?QueryOptionsInterface

Returns

Promise<null | OtpInterface>

Defined in

packages/nestjs-otp/src/services/otp.service.ts:223 (opens in a new tab)


validate()

validate(assignment, otp, deleteIfValid, queryOptions?): Promise<null | ReferenceAssigneeInterface<ReferenceIdInterface<string>>>

Check if otp is valid

Parameters

ParameterTypeDefault valueDescription
assignmentstringundefinedThe otp assignment
otpPick<OtpInterface, "category" | "passcode">undefinedThe otp to validate
deleteIfValidbooleanfalseIf true, delete the otp if it is valid
queryOptions?QueryOptionsInterfaceundefined-

Returns

Promise<null | ReferenceAssigneeInterface<ReferenceIdInterface<string>>>

Implementation of

OtpServiceInterface.validate

Defined in

packages/nestjs-otp/src/services/otp.service.ts:92 (opens in a new tab)


validateDto()

protected validateDto<T>(type, data): Promise<T>

Type Parameters

Type Parameter
T extends DeepPartial<OtpInterface>

Parameters

ParameterType
typeType<T>
dataT

Returns

Promise<T>

Defined in

packages/nestjs-otp/src/services/otp.service.ts:275 (opens in a new tab)