
Security News
/Research
Wallet-Draining npm Package Impersonates Nodemailer to Hijack Crypto Transactions
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
@resourge/http-service
Advanced tools
[](LICENSE)
http-service
is a comprehensive package that provides essential services for web applications. This package includes BaseHttpService
for making HTTP requests to servers and LoadingService
for managing loading indicators. Together, these services offer a robust solution for handling asynchronous operations and displaying loading feedback.
Install using Yarn:
yarn add @resourge/http-service
or NPM:
npm install @resourge/http-service
BaseHttpService
is a main service for making requests to a server. It serves as a simple wrapper around the Fetch API, with added features such as request throttling for GET
requests and support for file uploads.
import { BaseHttpService } from '@resourge/http-service'
const HttpService = new BaseHttpService({
baseUrl: 'https://api.example.com',
headers: {
'Authorization': 'Bearer token123'
}
});
GET Request
HttpService.get('/posts/1')
.then(response => console.log(response))
.catch(error => console.error(error));
POST Request
const postData = {
title: 'New Post',
body: 'Lorem ipsum...',
userId: 1
};
HttpService.post('/posts', postData)
.then(response => console.log(response))
.catch(error => console.error(error));
PUT Request
const updateData = {
title: 'Updated Post',
body: 'Updated content'
};
HttpService.put('/posts/1', updateData)
.then(response => console.log(response))
.catch(error => console.error(error));
DELETE Request
HttpService.delete('/posts/1')
.then(response => console.log(response))
.catch(error => console.error(error));
PATCH Request
const patchData = {
body: 'Patched content'
};
HttpService.patch('/posts/1', patchData)
.then(response => console.log(response))
.catch(error => console.error(error));
File Upload
const files = [file1, file2];
const formData = {
description: 'File description'
};
HttpService.upload('POST', '/files', files, formData)
.then(response => console.log(response))
.catch(error => console.error(error));
Interceptors can be used to modify request or response configurations:
HttpService.setToken(config => {
// Modify request headers
config.headers['Authorization'] = 'New Token';
return config;
});
// Add a request interceptor
HttpService.interceptors.request.use(
response => {
// Modify response data or handle it
return response;
},
error => {
// Handle errors or modify error responses
return Promise.reject(error);
}
);
// Add a response interceptor
HttpService.interceptors.response.use(
response => {
// Modify response data or handle it
return response;
},
error => {
// Handle errors or modify error responses
return Promise.reject(error);
}
);
You can extend BaseHttpService
to create a specialized service with additional methods or custom configurations:
class CustomHttpService extends BaseHttpService {
constructor() {
super({
baseUrl: 'https://api.example.com',
headers: {
'Authorization': 'Bearer token123'
}
});
}
// Add custom methods
public customMethod() {
// Custom logic here
}
}
const CustomService = new CustomHttpService();
CustomService.customMethod();
LoadingService
is a simple service designed to manage the state of loading indicators in your application. It provides methods to show or hide loading indicators and allows components to listen for changes in loading state.
import { LoadingService } from '@resourge/http-service';
// Show loading indicator
LoadingService.show();
// Show loading indicator with custom loaderId
LoadingService.show('myLoaderId');
// Hide loading indicator
LoadingService.hide();
// Hide loading indicator with custom loaderId
LoadingService.hide('myLoaderId');
// Add an event listener for the default loader
const removeListener = LoadingService.addListener(() => {
// Handle loading state change
console.log('Loading state changed!');
});
// Add an event listener for a specific loaderId
const removeCustomListener = LoadingService.addListener('myLoaderId', () => {
// Handle loading state change for custom loaderId
console.log('Custom Loading state changed!');
});
// To remove the listener later
removeListener(); // or removeCustomListener();
getLoading(loaderId?: string): boolean
addListener(loaderId?: string, onEmit: () => void): () => void
show(loaderId?: string): void
hide(loaderId?: string): void
For comprehensive documentation and usage examples, visit the Http Service documentation.
Contributions to @resourge/http-service
are welcome! To contribute, please follow the contributing guidelines.
Fetch is licensed under the MIT License.
For questions or support, please contact the maintainers:
FAQs
[](LICENSE)
The npm package @resourge/http-service receives a total of 140 weekly downloads. As such, @resourge/http-service popularity was classified as not popular.
We found that @resourge/http-service demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer 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
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
Security News
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.
Security News
/Research
Malicious Nx npm versions stole secrets and wallet info using AI CLI tools; Socket’s AI scanner detected the supply chain attack and flagged the malware.