@imgproxy/imgproxy-node
Version:
Official node url-builder lib for imgproxy - fast and secure standalone server for resizing and converting remote images
17 lines (16 loc) • 468 B
JavaScript
const SALT = process.env.IMGPROXY_SALT;
const KEY = process.env.IMGPROXY_KEY;
const isPair = (arr) => arr.every(Boolean);
const getSignedPair = (pair) => {
let wipPair = [pair.key, pair.salt];
if (!isPair(wipPair)) {
wipPair = [KEY, SALT];
if (!isPair(wipPair))
return undefined;
}
return {
salt: wipPair[1].split(",")[0].trim(),
key: wipPair[0].split(",")[0].trim(),
};
};
export default getSignedPair;