@trustforge-protocol/iron-session
v0.1.5
Published
TrustForge authentication and policy enforcement adapter for Iron session. Seamlessly integrate zero-trust verifiable actions into your Iron session application.
Maintainers
Readme
@trustforge-protocol/iron-session
Wraps iron-session's getIronSession so every read of the cookie-backed
session also projects the session into a TrustForge actor + capabilities.
Status
Draft. Part of TrustForge Phase D. Not production ready.
Install
bun add @trustforge-protocol/iron-session @trustforge-protocol/sdk iron-sessionUsage
import { getIronSession } from "iron-session";
import { trustforgeForIronSession } from "@trustforge-protocol/iron-session";
const sessionOptions = {
cookieName: "myapp_session",
password: process.env.SESSION_SECRET!,
};
export const getSession = trustforgeForIronSession(getIronSession, {
daemonUrl: "http://127.0.0.1:7616",
sessionOptions,
identityField: "userId",
});
// In a handler:
const session = await getSession(req, res);
if (session.tfActor) { /* allowed user */ }Per-route enforcement
import { tfRequireIron } from "@trustforge-protocol/iron-session";
const requireWrite = tfRequireIron(
{ daemonUrl: "http://127.0.0.1:7616" },
"fs.write",
);
const verdict = await requireWrite(session);