Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@stendahls/libravatar-server

Package Overview
Dependencies
Maintainers
3
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@stendahls/libravatar-server - npm Package Compare versions

Comparing version 1.0.0 to 1.1.0

2

package.json
{
"name": "@stendahls/libravatar-server",
"version": "1.0.0",
"version": "1.1.0",
"description": "A node implementation of the Libravatar API",

@@ -5,0 +5,0 @@ "main": "server.js",

@@ -10,2 +10,4 @@ const fs = require( 'fs' );

const cache = {};
module.exports = async ( emailHash, targetSize ) => {

@@ -28,3 +30,6 @@ await elvisClient.login( process.env.ELVIS_PROVIDER_USER, process.env.ELVIS_PROVIDER_PASSWORD );

if ( emailHash.length === 64 ) {
hashes[ hash.sha256( email ) ] = searchResult.previewUrl;
hashes[ hash.sha256( email ) ] = {
url: searchResult.previewUrl,
assetModified: searchResult.metadata.assetModified.value,
};

@@ -34,3 +39,6 @@ return true;

hashes[ hash.md5( email ) ] = searchResult.previewUrl;
hashes[ hash.md5( email ) ] = {
url: searchResult.previewUrl,
assetModified: searchResult.metadata.assetModified.value,
};

@@ -45,4 +53,11 @@ return true;

let chunks = [];
const readStream = elvisClient.stream( hashes[ emailHash ] );
if ( cache[ emailHash ] && cache[ emailHash ].assetModified >= hashes[ emailHash ].assetModified ) {
return sharp( cache[ emailHash ].data )
.resize( targetSize, targetSize )
.toBuffer();
}
const readStream = elvisClient.stream( hashes[ emailHash ].url );
readStream.on( 'data', ( chunk ) => {

@@ -54,3 +69,8 @@ chunks.push( chunk );

readStream.on( 'end', () => {
const avatarImage = sharp( Buffer.concat( chunks ) )
cache[ emailHash ] = {
assetModified: hashes[ emailHash ].assetModified,
data: Buffer.concat( chunks ),
};
const avatarImage = sharp( cache[ emailHash ].data )
.resize( targetSize, targetSize )

@@ -57,0 +77,0 @@ .toBuffer();

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc