Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
@algolia/transporter
Advanced tools
Promise-based transporter layer with embedded retry strategy.
@algolia/transporter is a low-level HTTP client for making requests to Algolia's API. It provides a set of utilities to handle retries, timeouts, and other network-related concerns, making it easier to interact with Algolia's services.
Basic Request
This code demonstrates how to create a basic transporter instance and make a GET request to list all indexes in an Algolia application.
const { createTransporter } = require('@algolia/transporter');
const transporter = createTransporter({
hosts: [{ url: 'https://your-algolia-instance.algolia.net' }],
headers: { 'X-Algolia-API-Key': 'your-api-key', 'X-Algolia-Application-Id': 'your-app-id' }
});
transporter.read({ method: 'GET', path: '/1/indexes' }).then(response => {
console.log(response);
});
Handling Retries
This code shows how to configure the transporter to handle retries with specific timeout settings and retry policies.
const { createTransporter } = require('@algolia/transporter');
const transporter = createTransporter({
hosts: [{ url: 'https://your-algolia-instance.algolia.net' }],
headers: { 'X-Algolia-API-Key': 'your-api-key', 'X-Algolia-Application-Id': 'your-app-id' },
timeouts: { connect: 1, read: 2, write: 30 },
retry: { maxRetries: 3, delay: 1000 }
});
transporter.read({ method: 'GET', path: '/1/indexes' }).then(response => {
console.log(response);
});
Custom Headers
This example demonstrates how to add custom headers to the transporter instance for making requests.
const { createTransporter } = require('@algolia/transporter');
const transporter = createTransporter({
hosts: [{ url: 'https://your-algolia-instance.algolia.net' }],
headers: { 'X-Algolia-API-Key': 'your-api-key', 'X-Algolia-Application-Id': 'your-app-id', 'Custom-Header': 'custom-value' }
});
transporter.read({ method: 'GET', path: '/1/indexes' }).then(response => {
console.log(response);
});
Axios is a promise-based HTTP client for the browser and Node.js. It provides a simple API for making HTTP requests and handling responses, including support for interceptors, automatic JSON transformation, and more. Compared to @algolia/transporter, Axios is more general-purpose and not specifically tailored for Algolia's API.
Node-fetch is a lightweight module that brings `window.fetch` to Node.js. It allows you to make HTTP requests in a similar way to the Fetch API in the browser. While it is more low-level compared to @algolia/transporter, it can be used to interact with any HTTP API, including Algolia's.
Request-promise-native is a simplified HTTP request client for Node.js with Promise support. It is built on top of the `request` library and provides a more modern API for making HTTP requests. Like Axios, it is more general-purpose and not specifically designed for Algolia's API.
FAQs
Promise-based transporter layer with embedded retry strategy.
The npm package @algolia/transporter receives a total of 1,323,924 weekly downloads. As such, @algolia/transporter popularity was classified as popular.
We found that @algolia/transporter 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.
Security News
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.