Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Uniqhtt is a versatile Node.js library designed for handling HTTP requests and responses with advanced cookie management, HTML parsing, and CSS processing capabilities. It leverages powerful tools like jsdom, fetch-cookie, and postcss to provide a robust
Welcome to Uniqhtt, a powerful and versatile Node.js library designed to handle advanced HTTP requests, response processing, and web automation. This library stands out with its comprehensive support for cookie management, HTML parsing, CSS transformation, and Wget-like recursive website cloning features. Uniqhtt provides a solid solution for web scraping, data extraction, and automation tasks, making it a valuable tool for developers working in diverse environments ranging from Node.js to serverless platforms and browsers.
Uniqhtt brings a suite of robust features to empower your HTTP requests and web automation workflows:
tough-cookies
for sophisticated session handling, making it easy to manage and persist cookies.jsdom
, enabling developers to parse and manipulate HTML structures with ease.postcss
.To install Uniqhtt, use npm or yarn:
npm install uniqhtt
Or, using yarn:
yarn add uniqhtt
This will install Uniqhtt along with its dependencies, including jsdom
, fetch-cookie
, and postcss
.
Uniqhtt provides a simplified API for making HTTP requests similar to popular libraries like Axios, while offering advanced features for handling cookies, scraping, and cloning websites.
const uniqhtt = require('uniqhtt');
uniqhtt.get('https://example.com')
.then(response => {
console.log(response.data); // HTML or JSON response
})
.catch(error => {
console.error('Error occurred:', error);
});
uniqhtt.post('https://example.com/login', {
data: {
username: 'user',
password: 'pass',
},
cookies: true
})
.then(response => {
console.log('Login successful:', response.data);
})
.catch(error => {
console.error('Login failed:', error);
});
For a comprehensive guide on using Uniqhtt, keep reading the detailed documentation below.
Uniqhtt supports all major HTTP methods, enabling it to cover a wide range of use cases for interacting with RESTful APIs or handling custom HTTP interactions.
Uniqhtt's request options mirror the popular Axios-like structure, making it easy for developers familiar with other libraries to integrate.
GET
).username
and password
).json
, text
, arraybuffer
, etc.).uniqhtt.get('https://api.example.com/data', {
headers: {
'Authorization': 'Bearer token',
'Content-Type': 'application/json'
}
})
.then(response => console.log(response.data));
For secure communication, Uniqhtt offers flexible HTTPS options to handle advanced scenarios, such as mutual TLS.
Uniqhtt integrates tough-cookies for advanced cookie handling, making it a great tool for web scraping or interacting with stateful HTTP sessions.
uniqhtt.setCookies([{ name: 'session', value: 'abc123', domain: 'example.com' }]);
uniqhtt.get('https://example.com/dashboard')
.then(response => {
console.log('Dashboard data:', response.data);
});
Uniqhtt can emulate Wget functionality, enabling recursive website downloading, link rewriting, and local storage of complete websites.
uniqhtt.clone('https://example.com', {
recursive: true,
level: 3,
convertLinks: true,
outputDirectory: './website_clone'
})
.then(() => console.log('Website cloned successfully!'))
.catch(error => console.error('Error while cloning website:', error));
Uniqhtt supports various storage options to fit different needs for persisting downloaded content.
bucket
, region
, accessKeyId
, and secretAccessKey
.host
, port
, user
, and password
.Uniqhtt offers several advanced features to enhance its capabilities:
createUniqhtt()
function.Uniqhtt provides comprehensive error handling, ensuring developers have access to all necessary details when something goes wrong:
RequestError
might include details about the failed HTTP request, while a ResponseError
could provide insight into the server response that caused the failure.uniqhtt.get('https://example.com/data', {
retryAttempts: 3, // Retry up to 3 times
retryDelay: 1000 // Wait 1 second between retries
})
.then(response => {
console.log('Data received:', response.data);
})
.catch(error => {
if (error.isRetryError) {
console.error('Request failed after multiple retries:', error);
} else {
console.error('An unexpected error occurred:', error);
}
});
Uniqhtt is fully compatible with TypeScript, offering a strong typing system that enhances developer experience by catching errors at compile time and providing better IntelliSense support. TypeScript definitions are bundled with the package, ensuring you don’t need to install additional typings.
import uniqhtt from 'uniqhtt';
uniqhtt.get('https://example.com')
.then((response: uniqhtt.UniqhttResponse<string>) => {
console.log(response.data); // Data typed as string
})
.catch((error: uniqhtt.UniqhttError) => {
console.error('Error occurred:', error.message);
});
By utilizing TypeScript, Uniqhtt ensures that developers can take full advantage of type safety, making it easier to spot errors early in the development process and ensuring higher quality code.
We welcome contributions to Uniqhtt! Whether you're fixing bugs, improving documentation, or adding new features, your input is valuable.
Before submitting, make sure your code passes all tests and linting checks to ensure consistency and quality.
Uniqhtt is a comprehensive, advanced HTTP client for Node.js, offering a range of features designed to handle everything from basic HTTP requests to complex web scraping and automation tasks. Its support for cookie management, recursive website cloning, parallel downloads, flexible storage, and advanced error handling makes it a powerful tool for developers working on a wide variety of projects.
Whether you're building a scraping engine, an API client, or an automated testing tool, Uniqhtt provides the tools you need in a simple, highly customizable package. With features like TypeScript support, retry mechanisms, and seamless cookie handling, Uniqhtt is designed to handle modern web interactions efficiently and securely.
For more detailed examples, head over to the [official documentation] and start exploring all that Uniqhtt has to offer!
Happy coding! 🎉
Uniqhtt is released under the MIT License. See the LICENSE file for more details.
FAQs
Uniqhtt is a versatile Node.js library designed for handling HTTP requests and responses with advanced cookie management, HTML parsing, and CSS processing capabilities. It leverages powerful tools like jsdom, fetch-cookie, and postcss to provide a robust
The npm package uniqhtt receives a total of 58 weekly downloads. As such, uniqhtt popularity was classified as not popular.
We found that uniqhtt demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
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.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.