
Research
Supply Chain Attack on Axios Pulls Malicious Dependency from npm
A supply chain attack on Axios introduced a malicious dependency, plain-crypto-js@4.2.1, published minutes earlier and absent from the project’s GitHub releases.
@labeg/tfetch
Advanced tools
A small library for sending serialized data and receiving deserialized data with strict data type checking.
A small library for sending serialized data and receiving deserialized data with strict data type checking. This library is built on top of the Fetch API and provides additional features like caching, error handling, and support for serializable classes.
You can use the following command to install this package:
npm install @labeg/tfetch
import { tfetch } from "@labeg/tfetch";
// Example with primitive types
const fetchNumber = async () => {
const result: number = await tfetch({
url: "https://example.com/number",
returnType: 0
});
console.log(result); // Logs the number fetched from the API
};
fetchNumber();
To use automatic deserialization with classes, you need to use the ts-serializable library to define your models:
import { tfetch } from "@labeg/tfetch";
import { Serializable, jsonProperty } from "ts-serializable";
class User extends Serializable {
@jsonProperty(String)
public name: string = "";
@jsonProperty(String)
public email: string = "";
@jsonProperty(Number)
public age: number = 0;
}
const fetchUser = async () => {
const result: User = await tfetch({
url: "https://example.com/api/user/1",
returnType: User
});
console.log(result instanceof User); // true
console.log(result.name); // Properly deserialized
};
fetchUser();
import { tfetch } from "@labeg/tfetch";
const createUser = async () => {
const result = await tfetch({
method: "POST",
url: "https://example.com/api/users",
body: {
name: "John Doe",
email: "john@example.com"
},
returnType: Object
});
console.log(result);
};
createUser();
import { tfetch } from "@labeg/tfetch";
const fetchWithHeaders = async () => {
const result = await tfetch({
method: "GET",
url: "https://example.com/api/data",
headers: {
"Authorization": "Bearer your-token-here",
"X-Custom-Header": "custom-value"
},
returnType: Object
});
console.log(result);
};
fetchWithHeaders();
import { tfetch } from "@labeg/tfetch";
// GET request
const getData = async () => {
return await tfetch({
method: "GET",
url: "https://example.com/api/resource",
returnType: Object
});
};
// POST request
const postData = async () => {
return await tfetch({
method: "POST",
url: "https://example.com/api/resource",
body: { data: "value" },
returnType: Object
});
};
// PUT request
const updateData = async () => {
return await tfetch({
method: "PUT",
url: "https://example.com/api/resource/1",
body: { data: "updated value" }
});
};
// DELETE request
const deleteData = async () => {
return await tfetch({
method: "DELETE",
url: "https://example.com/api/resource/1"
});
};
You can pass any standard Fetch API options:
import { tfetch } from "@labeg/tfetch";
const advancedRequest = async () => {
const result = await tfetch({
method: "POST",
url: "https://example.com/api/data",
body: { key: "value" },
returnType: Object,
// Standard Fetch API options
cache: "no-cache",
credentials: "include",
mode: "cors",
redirect: "follow",
referrerPolicy: "no-referrer",
signal: AbortSignal.timeout(5000), // 5 second timeout
});
console.log(result);
};
advancedRequest();
import { tfetch } from "@labeg/tfetch";
const uploadFile = async (file: File) => {
const formData = new FormData();
formData.append("file", file);
formData.append("description", "My file");
const result = await tfetch({
method: "POST",
url: "https://example.com/api/upload",
body: formData,
returnType: Object
});
console.log(result);
};
CrudHttpRepositoryimport { CrudHttpRepository } from "@labeg/tfetch";
import { TestClass } from "./fixtures/TestClass";
class TestRepository extends CrudHttpRepository<TestClass> {
protected apiRoot = "https://example.com/api";
protected modelConstructor = TestClass;
}
const repository = new TestRepository();
const fetchData = async () => {
const item = await repository.getById(1);
console.log(item);
};
fetchData();
The library provides custom error classes for handling network and backend errors:
import { tfetch } from "@labeg/tfetch";
const fetchWithErrorHandling = async () => {
try {
await tfetch({
url: "https://example.com/error"
});
} catch (error) {
console.error(error);
}
};
fetchWithErrorHandling();
GET and HEAD requests are cached automatically to improve performance. The cache is cleared when an error occurs or when the request completes successfully.
FAQs
A small library for sending serialized data and receiving deserialized data with strict data type checking.
We found that @labeg/tfetch 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.

Research
A supply chain attack on Axios introduced a malicious dependency, plain-crypto-js@4.2.1, published minutes earlier and absent from the project’s GitHub releases.

Research
Malicious versions of the Telnyx Python SDK on PyPI delivered credential-stealing malware via a multi-stage supply chain attack.

Security News
TeamPCP is partnering with ransomware group Vect to turn open source supply chain attacks on tools like Trivy and LiteLLM into large-scale ransomware operations.