Skip to content

AI Agents & MCPs & AI Workflow Automation • (~400 MCP servers for AI agents) • AI Automation / AI Agent with MCPs • AI Workflows & AI Agents • MCPs for AI Agents

483 B
Raw Blame
import { randomInt, randomUUID } from 'node:crypto'
import { OtpType } from '@activepieces/shared'

export const otpGenerator = {
    generate({ type }: GenerateParams): string {
        if (type !== OtpType.EMAIL_LOGIN) {
            return randomUUID()
        }
        const upperBound = 10 ** LOGIN_CODE_LENGTH
        return randomInt(0, upperBound).toString().padStart(LOGIN_CODE_LENGTH, '0')
    },
}

const LOGIN_CODE_LENGTH = 6

type GenerateParams = {
    type: OtpType
}