taggstar-digest-auth
v1.3.2
Published
Generate secure authentication cookie contents for pages and orders
Downloads
5
Readme
Taggstar Digest Auth
Installation
npm install taggstar-digest-auth
Usage
First, import the TaggstarDigestAuth class and create an instance:
const { TaggstarDigestAuth } = require("taggstar-digest-auth");
const secretKey = "your-secret-key";
const accessKey = "your-access-key";
const digestAuth = new TaggstarDigestAuth(secretKey, accessKey);
app.get("/product", (req, res) => {
const userId = "user123";
const authContent = digestAuth.generateAuth(userId);
res.cookie("_taggstar_auth", authContent, { httpOnly: true, secure: true });
res.set("Content-Type", "text/html");
res.status(200).send(`<h1>Product Page</h1><pre>${authContent}</pre>`);
});
app.get("/conversion", (req, res) => {
const userId = "user123";
const orderJson = {
id: "order123",
orderItems: [
{ id: "item1", quantity: 2, unitPrice: 49.99 },
{ id: "item2", quantity: 1, unitPrice: 29.99 }
]
};
const authContent = digestAuth.generateOrderAuth(userId, orderJson);
res.cookie("_taggstar_auth_order", authContent, { httpOnly: true, secure: true });
res.set("Content-Type", "text/html");
res.status(200).send(`<h1>Order Conversion Page</h1><pre>${authContent}</pre>`);
});