0.0.22 • Published 2 months ago

@bunpmjs/json-webtoken v0.0.22

Weekly downloads
-
License
-
Repository
-
Last release
2 months ago

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)
0.0.22

2 months ago

0.0.21

4 months ago

0.0.2

4 months ago

0.0.1

4 months ago