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

@bunpmjs/json-webtoken

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@bunpmjs/json-webtoken

### Exemple

0.0.1
npm
Version published
Weekly downloads
1
Maintainers
1
Weekly downloads
 
Created
Source

json-webtoken

Exemple

import { webToken } from "bunpm/"
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 01 Feb 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