
Research
/Security News
Toptal’s GitHub Organization Hijacked: 10 Malicious Packages Published
Threat actors hijacked Toptal’s GitHub org, publishing npm packages with malicious payloads that steal tokens and attempt to wipe victim systems.
simple-http-request-builder
Advanced tools
A simple HTTP request interface written in TypeScript
This library provides:
Using NPM:
npm install simple-http-request-builder
Using Yarn:
yarn add simple-http-request-builder
An HTTP client is something that takes an HTTP request as a parameter and returns something.
It can be a Promise
, an Object
or whatever.
Usage example using an HTTP client:
const response: Promise<Response> = new HttpRequest<Promise<Response>>(
httpClient,
'http://localhost/api',
HttpMethod.GET,
'/session',
)
.queryParams([['username', 'test'], ['password', 'azerty']])
.execute();
The HttpRequest
creation process should generally be made using a dedicated class.
Examples can be found:
In a browser environment, the base URL can be built using the window.location
object: ${window.location.protocol}//${window.location.host}/api
This sample is from Simple HTTP REST Client library.
const httpClient = (httpRequest: HttpRequest<unknown>): Promise<Response> => {
const timeoutHandle = setTimeout(
() => httpRequest.optionValues.timeoutAbortController.abort(),
httpRequest.optionValues.timeoutInMillis,
);
return fetch(
httpRequest.buildUrl(),
{
headers: httpRequest.headersValue,
method: httpRequest.method,
body: httpRequest.bodyValue,
credentials: httpRequest.credentials,
signal: httpRequest.optionValues.timeoutAbortController.signal,
},
)
.finally(() => clearTimeout(timeoutHandle));
};
By default, the request global timeout is 20 seconds (connect + wait + read). This can be configured using the request options
method:
const response: Promise<Response> = new HttpRequest<...>(...)
.queryParams(...)
// 60 seconds timeout
.options({ timeoutInMillis: 60000 })
.execute();
To cancel the request manually, it is also possible to specify the AbortController
as an option:
const abortController = new AbortController();
const response: Promise<Response> = new HttpRequest<...>(...)
.queryParams(...)
// 60 seconds timeout
.options({ timeoutAbortController: abortController })
.execute();
// then later, the promise can be manually stopped if it hasn't been resolved
abortController.abort(); // the promise is now cancelled
FAQs
A simple HTTP request interface written in TypeScript
The npm package simple-http-request-builder receives a total of 247 weekly downloads. As such, simple-http-request-builder popularity was classified as not popular.
We found that simple-http-request-builder 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
Threat actors hijacked Toptal’s GitHub org, publishing npm packages with malicious payloads that steal tokens and attempt to wipe victim systems.
Research
/Security News
Socket researchers investigate 4 malicious npm and PyPI packages with 56,000+ downloads that install surveillance malware.
Security News
The ongoing npm phishing campaign escalates as attackers hijack the popular 'is' package, embedding malware in multiple versions.