@suluk/better-auth 0.2.1 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@suluk/better-auth",
3
- "version": "0.2.1",
3
+ "version": "0.2.2",
4
4
  "description": "Official Better-Auth-on-Hono support for Suluk: auth methods -> v4 securitySchemes; ingest Better Auth's OpenAPI 3.0 -> v4; session -> principal for per-viewer docs. CANDIDATE tooling.",
5
5
  "publishConfig": {
6
6
  "access": "public"
package/src/index.ts CHANGED
@@ -11,7 +11,7 @@ export { authSecuritySchemes, type AuthMethods, type AuthSecurity } from "./secu
11
11
  export { normalizeOas30, ingestAuthOpenAPI, mergeAuth, type IngestOptions } from "./ingest";
12
12
  export {
13
13
  principalFromSession, MFA_SCOPE, mcpConnectionKeyId, orgScope, parseOrgScope,
14
- type Principal, type SessionLike, type PrincipalOptions,
14
+ type Principal, type SessionLike, type PrincipalOptions, type AppVars,
15
15
  } from "./principal";
16
16
  export { mountAuth, type AuthHandlerLike, type HonoLike, type MountAuthOptions } from "./mount";
17
17
  // scope-aware API-key verification (Phase 0): wraps Better Auth's verifyApiKey to return a { scopes } Principal,
package/src/principal.ts CHANGED
@@ -8,6 +8,16 @@ export interface Principal {
8
8
  scopes: string[];
9
9
  }
10
10
 
11
+ /** The Hono context Variables the auth middleware POPULATES per `/api/*` request — the resolved caller (`c.get("user")`,
12
+ * `c.var.scopes`, and the api-key id/name for a keyed caller). A module that READS the auth-set principal (e.g. `mcp`)
13
+ * types its context off THIS shared shape instead of importing the app's `../auth` — so it needs no sibling import. */
14
+ export interface AppVars {
15
+ user?: { id: string; email?: string };
16
+ scopes?: string[];
17
+ keyId?: string;
18
+ keyName?: string;
19
+ }
20
+
11
21
  /** A minimal view of a Better Auth session (duck-typed; works with the real Session shape). */
12
22
  export interface SessionLike {
13
23
  user?: { role?: string | string[]; scopes?: string[] } | null;