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

@travetto/asset

Package Overview
Dependencies
Maintainers
1
Versions
310
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@travetto/asset - npm Package Compare versions

Comparing version 4.0.6 to 4.0.7

2

package.json
{
"name": "@travetto/asset",
"version": "4.0.6",
"version": "4.0.7",
"description": "Modular library for storing and retrieving binary assets",

@@ -5,0 +5,0 @@ "keywords": [

@@ -11,2 +11,3 @@ import fs from 'node:fs/promises';

import { StreamMeta } from '@travetto/model';
import { AppError } from '@travetto/base';

@@ -135,2 +136,25 @@ import { Asset } from './types';

}
/**
* Compute hash from a url
*/
static async hashUrl(url: string, byteLimit = -1): Promise<string> {
const hasher = crypto.createHash('sha256').setEncoding('hex');
const str = await fetch(url);
if (!str.ok) {
throw new AppError('Invalid url for hashing', 'data');
}
const body = Readable.fromWeb(str.body!);
let count = 0;
for await (const chunk of body) {
if (Buffer.isBuffer(chunk) || typeof chunk === 'string') {
count += chunk?.length ?? 0;
hasher.update(chunk);
}
if (count > byteLimit && byteLimit > 0) {
body.destroy();
}
}
return hasher.end().read().toString();
}
}
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