1.3.2 • Published 1 year ago

taggstar-digest-auth v1.3.2

Weekly downloads
-
License
ISC
Repository
-
Last release
1 year ago

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>`);
});
1.3.2

1 year ago

1.3.1

1 year ago

1.3.0

1 year ago