1.0.4 • Published 8 months ago

@treasure-dev/auth v1.0.4

Weekly downloads
-
License
-
Repository
github
Last release
8 months ago

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: "engineering@treasure.lol",
  });
} 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); // engineering@treasure.lol
} 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.

1.0.4

8 months ago

1.0.3

9 months ago

1.0.2

10 months ago

1.0.1

10 months ago

1.0.0

10 months ago