
Research
PyPI Package Disguised as Instagram Growth Tool Harvests User Credentials
A deceptive PyPI package posing as an Instagram growth tool collects user credentials and sends them to third-party bot services.
@vepler/http-client
Advanced tools
A flexible and extensible API service library for making HTTP requests with built-in authentication support for bearer tokens and API keys.
A flexible and extensible API service library for making HTTP requests with built-in authentication support for bearer tokens and API keys.
npm install @vepler/http-client
import ApiService from '@vepler/http-client';
// Create an instance of the API service
const api = ApiService.create({
host: 'https://api.example.com',
timeout: 5000,
logLevel: 'info',
headers: {
'Content-Type': 'application/json',
},
});
// Make a GET request
const response = await api.get('users', '123', {
token: 'your-bearer-token',
apiKey: 'your-api-key',
});
// Make a POST request
const newUser = await api.post('users', {
name: 'John Doe',
email: 'john@example.com',
}, {
token: 'your-bearer-token',
apiKey: 'your-api-key',
});
// Make a PUT request
const updatedUser = await api.put('users/123', {
name: 'John Doe',
email: 'john.doe@example.com',
}, {
token: 'your-bearer-token',
apiKey: 'your-api-key',
});
// Make a DELETE request
await api.delete('users', '123', {
token: 'your-bearer-token',
apiKey: 'your-api-key',
});
The create method of the ApiService accepts an options object with the following properties:
The API service supports authentication using bearer tokens and API keys. You can pass the token and apiKey properties as part of the queryParams object when making requests.
The API service includes built-in request and response interceptors for logging and error handling. You can customize or extend these interceptors by modifying the logRequest, interceptorResponseSuccess, and interceptorResponseError functions.
The API service includes a comprehensive error handling system that provides detailed information about errors. All HTTP errors are converted to typed error classes that extend the base HttpError
class, making it easy to handle different types of errors in your application.
HttpError
: The base error class for all HTTP errorsClientError
: For 4xx series errors (client errors)ServerError
: For 5xx series errors (server errors)NetworkError
: For network connectivity issuesAuthError
: For authentication failures (401, 403)TimeoutError
: For request timeoutsRateLimitError
: For rate limiting errors (429)ValidationError
: For validation errors (400 with details)All error classes include the following properties:
status
: The HTTP status codestatusText
: The HTTP status textendpoint
: The endpoint that was requestedmethod
: The HTTP method usedurl
: The full URL that was requesteddata
: The response data from the servermessage
: A detailed error messageSpecialized error classes include additional properties:
AuthError
includes credentials
(with sensitive data redacted)RateLimitError
includes retryAfter
(for retry-after header)ValidationError
includes validationErrors
(field-level errors)import ApiService, { HttpError, AuthError } from '@vepler/http-client';
try {
const result = await api.get('users', '123');
} catch (error) {
if (error instanceof AuthError) {
// Handle authentication errors
console.error(`Auth failed: ${error.status} ${error.message}`);
// Redirect to login page
} else if (error instanceof HttpError) {
// Handle other HTTP errors
console.error(`API Error: ${error.status} ${error.message}`);
} else {
// Handle other errors
console.error(`Unknown error: ${error.message}`);
}
}
The error handling system also automatically redacts sensitive information like API keys and tokens, while still providing enough context for debugging.
This project is licensed under the MIT License.
FAQs
A flexible and extensible API service library for making HTTP requests with built-in authentication support for bearer tokens and API keys.
We found that @vepler/http-client demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 3 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
A deceptive PyPI package posing as an Instagram growth tool collects user credentials and sends them to third-party bot services.
Product
Socket now supports pylock.toml, enabling secure, reproducible Python builds with advanced scanning and full alignment with PEP 751's new standard.
Security News
Research
Socket uncovered two npm packages that register hidden HTTP endpoints to delete all files on command.