🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more

@bunpmjs/json-webtoken

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@bunpmjs/json-webtoken

### Exemple

0.1.0
latest
Version published
Maintainers
0
Created

json-webtoken

Exemple

import { webToken } from "@bunpmjs/json-webtoken"
interface _User {
  username: string;
}

Bun.serve({
  fetch(req) {
    const cookie = new webToken<_User>(req, {
      cookieName: "customName",
    });
    const session = cookie.session();
    if (!session) {
      cookie.setData({
        username: "shpaw415",
      });
      return cookie.setCookie(new Response("not logged"), {
        expire: 3000,
        httpOnly: false,
        secure: true,
      });
    } else {
      return new Response(`Logged as ${session.username}`);
    }
  },
  port: 3000,
});

ENV

  • WEB_TOKEN_SECRET = Random 32 length String for securing the data (must be strong!)
  • WEB_TOKEN_IV = Random string for radomize encryption (more secure but not mendatory)

FAQs

Package last updated on 10 Dec 2024

Did you know?

Socket

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.

Install

Related posts