@arche-cms/auth
v0.1.5
Published
Authentication package for Arche CMS. Provides JWT-based auth with login, register, token refresh, and password reset flows.
Readme
@arche-cms/auth
Authentication package for Arche CMS. Provides JWT-based auth with login, register, token refresh, and password reset flows.
Installation
yarn add @arche-cms/authUsage
Auth Service
import { AuthService } from "@arche-cms/auth";
const auth = new AuthService(adapter, {
secret: "your-jwt-secret",
accessTokenExpiresIn: "15m",
refreshTokenExpiresIn: "7d",
});
const { accessToken, refreshToken } = await auth.register({
email: "[email protected]",
password: "secure-password",
});
const { accessToken, refreshToken } = await auth.login({
email: "[email protected]",
password: "secure-password",
});
const user = await auth.verifyToken(accessToken);JWT Utilities
import { generateTokens, verifyToken } from "@arche-cms/auth";
const { accessToken, refreshToken } = await generateTokens(
{ id: "1", email: "[email protected]" },
{ secret: "jwt-secret", accessExpiresIn: "15m", refreshExpiresIn: "7d" },
);
const payload = await verifyToken(accessToken, "jwt-secret");Password Handling
import { hashPassword, verifyPassword } from "@arche-cms/auth";
const hash = await hashPassword("my-password");
const match = await verifyPassword("my-password", hash);