@jitsi/js-utils
Advanced tools
Comparing version 1.0.2 to 1.0.3
import md5 from 'js-md5'; | ||
/** | ||
* Returns the Avatar URL to be used for the participant. | ||
* | ||
* @param {string} [participant.avatarID] - Participant's avatar ID. | ||
* @param {string} [participant.email] - Participant's e-mail address. | ||
* @param {string} [participant.id] - Participant's ID. | ||
* @param {string} [avatarService.urlPrefix] - URL Prefix of the avatar service. | ||
* @param {string} [avatarService.urlSuffix] - URL Suffix of the avatar service. | ||
* @returns {string} - Avatar URL. | ||
*/ | ||
export function getAvatarURL(participant, avatarService = {}) { | ||
const { avatarID, email, id } = participant; | ||
const { urlPrefix = 'https://abotars.jitsi.net/meeple/', urlSuffix = '' } = avatarService; | ||
return getGravatarURL(email) | ||
|| generateAvatarURL(avatarID || id, urlPrefix, urlSuffix); | ||
} | ||
/** | ||
* Returns the Avatar URL generated from the given avatar service. | ||
* | ||
* @param {string} key - Key using which avatar has to be generated. | ||
* @param {string} urlPrefix - URL Prefix of the avatar service to be used. | ||
* @param {string} urlSuffix - URL Suffix of the avatar service to be used. | ||
* @returns {string} | ||
*/ | ||
function generateAvatarURL(key, urlPrefix, urlSuffix) { | ||
return urlPrefix + md5.hex(key.trim().toLowerCase()) + urlSuffix; | ||
} | ||
/** | ||
* Returns the Gravatar URL of a given email id. | ||
* | ||
* @param {string} key - Email or id for which we need gravatar url. | ||
* @param {string} key - Email or id for which we need gravatar URL. | ||
* @param {string} baseURL - Base Gravatar URL. | ||
* @returns {string} - Gravatar URL. | ||
*/ | ||
export function getGravatarURL(key) { | ||
const urlPrefix = 'https://www.gravatar.com/avatar/'; | ||
export function getGravatarURL(key, baseURL = 'https://seccdn.libravatar.org/avatar/') { | ||
const urlSuffix = '?d=404&size=200'; | ||
@@ -46,3 +16,3 @@ | ||
return `${urlPrefix}${avatarKey}${urlSuffix}`; | ||
return `${baseURL}${avatarKey}${urlSuffix}`; | ||
} | ||
@@ -49,0 +19,0 @@ |
{ | ||
"name": "@jitsi/js-utils", | ||
"version": "1.0.2", | ||
"version": "1.0.3", | ||
"description": "Utilities for Jitsi JS projects", | ||
@@ -5,0 +5,0 @@ "repository": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
0
135030
2674