@jakuta-inc/auth
v0.3.1
Published
TypeScript auth lifecycle primitives for Jakuta-family web apps.
Downloads
3,641
Readme
@jakuta-inc/auth
TypeScript auth lifecycle primitives for Jakuta-family web apps.
The package mirrors the Dart jakuta_auth boundary: auth state and lifecycle outcomes are sealed unions, token storage is injected through @jakuta-inc/token-storage, and login/restore/logout return named branches instead of nullable session values.
import { JakutaAuthController } from "@jakuta-inc/auth";
import { MemoryJakutaTokenStorage, bearerTokenFromText } from "@jakuta-inc/token-storage";
const token = bearerTokenFromText("session-token");
if (token.kind === "accepted") {
const auth = new JakutaAuthController({
tokenStorage: new MemoryJakutaTokenStorage(),
restoreUserFromToken: async () => ({ kind: "restored", authenticatedUser: { id: "1" } }),
loginForToken: async () => ({ kind: "accepted", bearerToken: token.bearerToken }),
registerForToken: async () => ({ kind: "accepted", bearerToken: token.bearerToken }),
});
}