🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

@isoftdata/file-service

Package Overview
Dependencies
Maintainers
13
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@isoftdata/file-service - npm Package Compare versions

Comparing version
7.0.1
to
7.0.2
+20
-7
dist/utilities/transform-image.js

@@ -5,5 +5,17 @@ import debugModule from 'debug';

export const transformImage = async (file, options) => {
const width = options.width ? (Number.isInteger(parseInt(options.width, 10)) ? parseInt(options.width, 10) : null) : null;
const height = options.height ? (Number.isInteger(parseInt(options.height, 10)) ? parseInt(options.height, 10) : null) : null;
const backgroundNumber = options.background ? (Number.isInteger(parseInt(options.background, 10)) ? parseInt(options.background, 10) : 255) : 255;
const width = options.width
? Number.isInteger(parseInt(options.width, 10))
? parseInt(options.width, 10)
: null
: null;
const height = options.height
? Number.isInteger(parseInt(options.height, 10))
? parseInt(options.height, 10)
: null
: null;
const backgroundNumber = options.background
? Number.isInteger(parseInt(options.background, 10))
? parseInt(options.background, 10)
: 255
: 255;
const background = { r: backgroundNumber, g: backgroundNumber, b: backgroundNumber, alpha: 1 };

@@ -42,7 +54,7 @@ // This is an IIFE to set 'fit' to the correct sharp object, when undefined (default), sharp will use 'cover'

// eslint-disable-next-line @typescript-eslint/await-thenable
const transformedSharpImage = await image.rotate().resize(width, height, { fit, background, withoutEnlargement: options.withoutEnlargement });
const transformedSharpImage = await image
.rotate()
.resize(width, height, { fit, background, withoutEnlargement: options.withoutEnlargement });
const transformedImage = ((fileSaveExtension, transformedSharpImage) => {
switch (fileSaveExtension) {
case 'jpeg':
return transformedSharpImage.jpeg().toBuffer();
case 'png':

@@ -52,4 +64,5 @@ return transformedSharpImage.png().toBuffer();

return transformedSharpImage.webp().toBuffer();
case 'jpeg':
default:
return transformedSharpImage.jpeg().toBuffer();
return transformedSharpImage.flatten({ background }).jpeg().toBuffer();
}

@@ -56,0 +69,0 @@ })(fileSaveExtension, transformedSharpImage);

{
"name": "@isoftdata/file-service",
"version": "7.0.1",
"version": "7.0.2",
"description": "A generic files service for any ISoft platform.",

@@ -5,0 +5,0 @@ "type": "module",

/**
* A verifier-selector string is a concatenation of two things:
* 1. verifier: a string of n length to qualify the resource
* 2. selector: a number to indicate where the resource is located (typically a table row id)
*
* Example usage: for a file server, we want to allow unauthenticated GET request to get files. But, if the file url
* path is predictable (using row id or even file name), a bad actor could brute force download all of a company's
* files. Using a verifier string (for files we use the md5 checksum), a requester must first know an unpredictable
* string before hand for the request to be verified.
*
* THIS IS NOT SECURITY. What VerifierSelector gets us is a level of obfuscation that prevents brute downloaders.
*/
export declare const VerifierSelector: {
/**
* This method will parse a verifier-selector string into it's constituent parts.
* If invalid, the function will return null.
* @param verifierSelector
* @param verifierLength
*/
parse: (verifierSelector: string, verifierLength?: number) => {
verifier: string;
selector: number;
} | null;
};
export default VerifierSelector;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.VerifierSelector = void 0;
/**
* A verifier-selector string is a concatenation of two things:
* 1. verifier: a string of n length to qualify the resource
* 2. selector: a number to indicate where the resource is located (typically a table row id)
*
* Example usage: for a file server, we want to allow unauthenticated GET request to get files. But, if the file url
* path is predictable (using row id or even file name), a bad actor could brute force download all of a company's
* files. Using a verifier string (for files we use the md5 checksum), a requester must first know an unpredictable
* string before hand for the request to be verified.
*
* THIS IS NOT SECURITY. What VerifierSelector gets us is a level of obfuscation that prevents brute downloaders.
*/
exports.VerifierSelector = {
/**
* This method will parse a verifier-selector string into it's constituent parts.
* If invalid, the function will return null.
* @param verifierSelector
* @param verifierLength
*/
parse: (verifierSelector, verifierLength = 32) => {
const verifier = verifierSelector.slice(0, verifierLength).toLowerCase();
const selector = parseInt(verifierSelector.slice(verifierLength), 10);
if ((verifier.length !== verifierLength) || isNaN(selector)) {
return null;
}
return { verifier, selector };
},
};
exports.default = exports.VerifierSelector;