ValSession

https://val.town/v/tmcw/thankfulTurquoiseParrot

Create short lived session (1hr) with your Val Town token so that you can safely authenticate with other services!

import { ValSession } from "https://esm.town/v/tmcw/thankfulTurquoiseParrot";

// Generate a token from your valtown api key.
const token = await ValSession.new(Deno.env.get("valtown"));

// Other services can use it to authenticate
const user = await ValSession.validate(token);

// user =>  {
//   id: "418c1e39-eb48-4f2f-8c97-122ece94631c",
//   bio: "🕳️",
//   username: "maxm",
//   profileImageUrl: "...",
//   url: "https://www.val.town/u/maxm",
//   tier: "pro",
//   email: "max.t.mcdonnell@gmail.com",
//   iat: 1732382035,
//   exp: 1732385635
// }