@glassly/auth
v0.1.0-dev.0
Published
Verify Glassly Local Runtime auth tokens (JWKS) in miniapp backends.
Readme
@glassly/auth
Helpers for miniapp backends that need to verify Local Runtime auto-auth tokens.
import {createAuthService, type AuthVariables} from "@glassly/auth";
import {Hono} from "hono";
const glasslyAuth = createAuthService({
packageName: "com.example.miniapp",
});
const app = new Hono<{ Variables: AuthVariables }>();
app.use("/api/*", glasslyAuth.hono());
app.post("/api/endpoint", async (c) => {
const session = c.get("glasslyAuth");
return c.json({userId: session.glasslyUserId});
});Defaults:
packageName: required, or setGLASSLY_PACKAGE_NAME,MINIAPP_PACKAGE_NAME, orPACKAGE_NAME.jwksUrl:GLASSLY_AUTH_JWKS_URL, falling back tohttps://core.glassly.ai/.well-known/jwks.json.issuer:GLASSLY_AUTH_ISSUERSas a comma-separated list, orGLASSLY_AUTH_ISSUERas one value, falling back tocloud-core.
Use jwksUrl for local, staging, test, or self-hosted Core deployments:
const glasslyAuth = createAuthService({
packageName: "com.example.miniapp",
jwksUrl: "http://localhost:3000/.well-known/jwks.json",
});Lower-level helpers are available when a framework middleware is not enough:
await glasslyAuth.verifyToken(token);
await glasslyAuth.verifyAuthHeader(header);
await glasslyAuth.verifyRequest(request);