forked from
npmx.dev/npmx.dev
[READ-ONLY]
a fast, modern browser for the npm registry
1import { createHash } from 'node:crypto'
2import { fetchUserEmail } from '#server/utils/npm'
3
4export async function getGravatarFromUsername(username: string): Promise<string | null> {
5 const handle = username.trim()
6 if (!handle) return null
7
8 const email = await fetchUserEmail(handle)
9 if (!email) return null
10
11 const trimmedEmail = email.trim().toLowerCase()
12 return createHash('md5').update(trimmedEmail).digest('hex')
13}