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

@liip/npm-icons

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@liip/npm-icons - npm Package Compare versions

Comparing version 0.2.2 to 0.2.3

30

bin/add.js

@@ -12,3 +12,6 @@ // ***********

getIconsTypes,
getIconsJsonUrl, getIconsSvgBaseUrl,
getIconsJsonUrl,
getIconsSvgBaseUrl,
getUsername,
getPassword,
} from './getConfiguration.js';

@@ -23,2 +26,5 @@

const iconTypes = getIconsTypes();
const username = getUsername();
const password = getPassword();
let axiosInstance = axios;

@@ -30,6 +36,23 @@ export const getIconSvgUrl = (icon) => `${icon.path}/${icon.file}`;

export const getAllIcons = async () => {
const { data } = await axios(iconsJsonUrl);
const { data } = await axiosInstance(iconsJsonUrl);
return data;
};
const verifyIconAccess = async () => {
try {
if (username && password) {
const token = Buffer.from(`${username}:${password}`, 'utf8').toString('base64');
axiosInstance = axios.create({
headers: {
Authorization: `Basic ${token}`,
},
});
}
await axiosInstance(iconsJsonUrl);
} catch (e) {
console.log(chalk.bgRed.whiteBright('Unauthorized to access'), iconsJsonUrl);
process.exit(1);
}
};
export const validateTypeOption = (options) => {

@@ -68,3 +91,3 @@ if (options.type && !iconTypes.includes(options.type)) {

try {
const { data } = await axios(`${iconsSvgBaseUrl}/${iconType}/${iconPath}`);
const { data } = await axiosInstance(`${iconsSvgBaseUrl}/${iconType}/${iconPath}`);
return data;

@@ -215,2 +238,3 @@ } catch (err) {

export default async (name, options) => {
await verifyIconAccess();
validateTypeOption(options);

@@ -217,0 +241,0 @@ const icon = await getIcon(name, options);

@@ -8,2 +8,4 @@ import path from 'path';

let iconsTypes = ['regular', 'light'];
let username = null;
let password = null;

@@ -15,2 +17,3 @@ const explorer = cosmiconfigSync('npm-icons');

const iconsTypesConfig = explorer.search('iconsTypes');
const authorizationConfig = explorer.search('authorization');

@@ -29,2 +32,6 @@ if (iconsPathConfig) {

}
if (authorizationConfig) {
username = authorizationConfig.config.authorization.username;
password = authorizationConfig.config.authorization.password;
}

@@ -35,1 +42,3 @@ export const getIconsPath = () => iconsPath;

export const getIconsTypes = () => iconsTypes;
export const getUsername = () => username;
export const getPassword = () => password;

2

package.json
{
"name": "@liip/npm-icons",
"version": "0.2.2",
"version": "0.2.3",
"description": "Import svg icons using cli",

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

@@ -25,3 +25,7 @@ ## [Official Documentation](https://liip.github.io/npm-icons/website)

"iconsJsonUrl": "https://icons.liip.ch/icons.json",
"iconsTypes": ["regular", "light"]
"iconsTypes": ["regular", "light"],
"authorization": {
"username": null,
"password": null
}
}

@@ -28,0 +32,0 @@ ```

Sorry, the diff of this file is not supported yet

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