@treasure-dev/auth
v1.0.3
Published
Authentication token utilities for the Treasure ecosystem
Downloads
278
Keywords
Readme
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.