kavachos 0.0.2 → 0.0.4

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.
@@ -1,52 +0,0 @@
1
- /**
2
- * Core types for the human auth adapter system.
3
- */
4
- /**
5
- * A resolved human user identity. All fields except `id` are optional
6
- * because different providers expose different levels of profile data.
7
- */
8
- interface ResolvedUser {
9
- /** Stable user ID (from the auth provider). */
10
- id: string;
11
- email?: string;
12
- name?: string;
13
- image?: string;
14
- /** Any additional claims / metadata from the auth provider. */
15
- metadata?: Record<string, unknown>;
16
- }
17
- /**
18
- * Plug KavachOS into an existing auth system by implementing this interface.
19
- *
20
- * Only `resolveUser` is required – it is called for every inbound request that
21
- * needs a human identity. The optional helpers (`getUser`, `syncUser`) are
22
- * called by higher-level KavachOS flows when they need to fetch or persist user
23
- * data.
24
- */
25
- interface AuthAdapter {
26
- /**
27
- * Resolve a human user from an incoming HTTP `Request`.
28
- *
29
- * Inspect cookies, session tokens, `Authorization` headers, etc. and return
30
- * the matching `ResolvedUser`. Return `null` when the request carries no
31
- * recognisable credential.
32
- */
33
- resolveUser(request: Request): Promise<ResolvedUser | null>;
34
- /**
35
- * Fetch a user by their ID from the auth provider.
36
- *
37
- * Used when KavachOS needs to verify that a user still exists (e.g. before
38
- * creating an agent on their behalf). Return `null` when the user is not
39
- * found or has been deleted.
40
- */
41
- getUser?(userId: string): Promise<ResolvedUser | null>;
42
- /**
43
- * Persist / update user data from the auth provider into the KavachOS
44
- * `kavach_users` table.
45
- *
46
- * Called after a successful `resolveUser` when user data should be kept in
47
- * sync with an external provider.
48
- */
49
- syncUser?(user: ResolvedUser): Promise<void>;
50
- }
51
-
52
- export type { AuthAdapter as A, ResolvedUser as R };