Skip to content

Latest commit

 

History

History

auth

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 

Treasure Auth

Authentication token utilities for the Treasure ecosystem

Prerequisites

Installation

pnpm add @treasure-dev/auth

Usage

Generate JWT

import { createAuth } from "@treasure-dev/auth";

const auth = createAuth({ kmsKey: "arn:kms-auth" });

try {
  const token = await auth.generateJWT("engineer1", {
    email: "[email protected]",
  });
} catch (err) {
  console.error("Error generating JWT:", err);
}

Verify JWT

import { createAuth } from "@treasure-dev/auth";

type User = {
  email: string;
};

const auth = createAuth({ kmsKey: "arn:kms-auth" });

try {
  const user = await auth.verifyJWT<User>("ey...");
  console.log(user.ctx.email); // [email protected]
} catch (err) {
  console.error("Error verifying JWT:", err);
}

Deployment

Merge changeset-bot's versioning PR to the main branch to push a new package version to npm.