Skip to main content

SecondFactorProvider

@webda/core


Interface: SecondFactorProvider

Defined in: packages/core/src/models/mfa.model.ts:112

A second factor method implemented by a service (TOTP, SMS...), available once registered

Properties​

method​

readonly method: string

Defined in: packages/core/src/models/mfa.model.ts:114

Method name: key in MFA.factors and amr value, e.g. "totp"


recoveryCodeCount?​

readonly optional recoveryCodeCount?: number

Defined in: packages/core/src/models/mfa.model.ts:118

Recovery codes issued with the first enabled factor (default 10, 0 disables them)


throttle?​

readonly optional throttle?: ThrottleParameters

Defined in: packages/core/src/models/mfa.model.ts:116

Throttle of the attempts checked with this method

Methods​

challenge()?​

optional challenge(mfa, owner): Promise<any>

Defined in: packages/core/src/models/mfa.model.ts:134

Send a new code for a pending or enabled factor (e.g. by SMS); the caller saves the owner. Methods whose codes are generated by the user (TOTP) do not implement it

Parameters​

mfa​

MFA

the MFA behavior

owner​

any

the object holding it

Returns​

Promise<any>

the challenge data for the client, never the secret or code


check()​

check(mfa, code): Promise<boolean>

Defined in: packages/core/src/models/mfa.model.ts:141

Check a code against the factor data, recording its single use; the caller saves the owner

Parameters​

mfa​

MFA

the MFA behavior

code​

string

submitted code

Returns​

Promise<boolean>

true when the code is valid


startEnrollment()​

startEnrollment(mfa, owner, input?): Promise<any>

Defined in: packages/core/src/models/mfa.model.ts:126

Store the pending factor data in mfa.factors[method]; the caller saves the owner

Parameters​

mfa​

MFA

the MFA behavior

owner​

any

the object holding it

input?​

any

factor-specific enrollment input

Returns​

Promise<any>

the enrollment data for the client (e.g. TOTP secret and URI)