Authentication token utilities for the Treasure ecosystem
pnpm add @treasure-dev/auth
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);
}
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);
}
Merge changeset-bot's versioning PR to the main
branch to push a new package version to npm.