Enroll users in multi-factor authentication for an additional layer of security. MFA can be enabled via the Authentication page in the WorkOS dashboard.
Represents an authentication factor.
const factor = { object: 'authentication_factor', id: 'auth_factor_01FVYZ5QM8N98T9ME5BCB2BBMJ', createdAt: '2022-02-15T15:14:19.392Z', updatedAt: '2022-02-15T15:14:19.392Z', type: 'totp', totp: { issuer: 'Foo Corp', user: 'alan.turing@example.com', qrCode: 'data:image/png;base64,{base64EncodedPng}', secret: 'NAGCCFS3EYRB422HNAKAKY3XDUORMSRF', uri: 'otpauth://totp/FooCorp:alan.turing@example.com?secret=NAGCCFS3EYRB422HNAKAKY3XDUORMSRF&issuer=FooCorp', }, userId: 'user_01FVYZ5QM8N98T9ME5BCB2BBMJ', };
interface FactorRepresents a challenge of an authentication factor.
const challenge = { object: 'authentication_challenge', id: 'auth_challenge_01FVYZWQTZQ5VB6BC5MPG2EYC5', createdAt: '2022-02-15T15:26:53.274Z', updatedAt: '2022-02-15T15:26:53.274Z', expiresAt: '2022-02-15T15:36:53.279Z', authenticationFactorId: 'auth_factor_01FVYZ5QM8N98T9ME5BCB2BBMJ', };
interface ChallengeEnrolls a user in a new authentication factor.
import { WorkOS } from '@workos-inc/node'; const workos = new WorkOS('sk_example_123456789'); const { authenticationFactor, authenticationChallenge } = await workos.userManagement.enrollAuthFactor({ userId: 'user_01E4ZCR3C56J083X43JQXF3JK5', type: 'totp', totpIssuer: 'WorkOS', totpUser: 'bob@example.com', });
userManagement .enrollAuthFactor()Parameters objectReturns objectLists the authentication factors for a user.
import { WorkOS } from '@workos-inc/node'; const workos = new WorkOS('sk_example_123456789'); const authFactors = await workos.userManagement.listAuthFactors({ userId: 'user_01E4ZCR3C56J083X43JQXF3JK5', }); console.log(authFactors.data);
userManagement .listAuthFactors()Parameters Returns object