
Research
Malicious fezbox npm Package Steals Browser Passwords from Cookies via Innovative QR Code Steganographic Technique
A malicious package uses a QR code as steganography in an innovative technique.
@victor141516/pledge
Advanced tools
A TypeScript library for streaming objects containing promises over HTTP using JSON Lines format. This enables progressive data loading where you can start working with skeleton data immediately while async operations complete in the background.
A TypeScript library for streaming objects containing promises over HTTP using JSON Lines format. This enables progressive data loading where you can start working with skeleton data immediately while async operations complete in the background.
Server Side: Objects containing promises are processed:
$1$
, $2$
, etc.)Client Side: The stream is reconstructed:
npm install @victor141516/pledge
import { pledgeMiddleware } from "@victor141516/pledge/adapters/express";
import express from "express";
const sleep = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms));
const createDataWithPromises = () => {
return {
immediate: "This data is available right away",
delayed5s: sleep(5000).then(() => "Resolved after 5s"),
nested: {
delayed1s: sleep(1000).then(() => "Nested resolved after 1s"),
deeplyNested: sleep(0).then(() => "Deeply nested resolved immediately"),
nestedPromises: sleep(1000).then(() => ({
alsoWork: sleep(1000).then(() => "Also nested promises work"),
})),
},
} as const;
};
const app = express();
// Add the pledge middleware
app.use(pledgeMiddleware);
app.get("/data", (req, res) => {
res.setHeader("Access-Control-Allow-Origin", "*");
// Send object with promises - they'll be streamed as they resolve
res.sendPledge(createDataWithPromises());
});
app.listen(3000, () => {
console.log("Server running on http://localhost:3000");
});
import { readResponse } from "@victor141516/pledge/client";
async function fetchStreamingData() {
const response = await fetch("http://localhost:3000/data");
// readResponse returns the reconstructed object with promises
const data = await readResponse<ReturnType<typeof createDataWithPromises>>(
response
);
console.log("Root object received immediately:", data);
console.log("Immediate values:", data.immediate);
// These promises will resolve as data streams in
data.delayed5s.then((value) => console.log("delayed5s resolved:", value));
data.nested.delayed1s.then((value) =>
console.log("nested.delayed1s resolved:", value)
);
data.nested.deeplyNested.then((value) =>
console.log("nested.deeplyNested resolved:", value)
);
data.nested.nestedPromises.then(({ alsoWork }) =>
alsoWork.then((value) =>
console.log("nested.nestedPromises.alsoWork resolved:", value)
)
);
}
fetchStreamingData();
Contributions are welcome! Please feel free to submit a Pull Request.📄
MIT License - see LICENSE file for details.
FAQs
A TypeScript library for streaming objects containing promises over HTTP using JSON Lines format. This enables progressive data loading where you can start working with skeleton data immediately while async operations complete in the background.
The npm package @victor141516/pledge receives a total of 1 weekly downloads. As such, @victor141516/pledge popularity was classified as not popular.
We found that @victor141516/pledge 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 malicious package uses a QR code as steganography in an innovative technique.
Research
/Security News
Socket identified 80 fake candidates targeting engineering roles, including suspected North Korean operators, exposing the new reality of hiring as a security function.
Application Security
/Research
/Security News
Socket detected multiple compromised CrowdStrike npm packages, continuing the "Shai-Hulud" supply chain attack that has now impacted nearly 500 packages.