@kavachos/svelte 0.0.3

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 KavachOS
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,98 @@
1
+ import { Readable } from 'svelte/store';
2
+
3
+ interface KavachUser {
4
+ id: string;
5
+ email?: string;
6
+ name?: string;
7
+ image?: string;
8
+ }
9
+ interface KavachSession {
10
+ token: string;
11
+ user: KavachUser;
12
+ expiresAt?: string;
13
+ }
14
+ interface KavachAgent {
15
+ id: string;
16
+ ownerId: string;
17
+ name: string;
18
+ type: "autonomous" | "delegated" | "service";
19
+ token: string;
20
+ permissions: KavachPermission[];
21
+ status: "active" | "revoked" | "expired";
22
+ expiresAt: string | null;
23
+ createdAt: string;
24
+ updatedAt: string;
25
+ }
26
+ interface KavachPermission {
27
+ resource: string;
28
+ actions: string[];
29
+ constraints?: {
30
+ maxCallsPerHour?: number;
31
+ allowedArgPatterns?: string[];
32
+ requireApproval?: boolean;
33
+ timeWindow?: {
34
+ start: string;
35
+ end: string;
36
+ };
37
+ ipAllowlist?: string[];
38
+ };
39
+ }
40
+ interface CreateAgentInput {
41
+ ownerId: string;
42
+ name: string;
43
+ type: "autonomous" | "delegated" | "service";
44
+ permissions: KavachPermission[];
45
+ expiresAt?: string;
46
+ metadata?: Record<string, unknown>;
47
+ }
48
+ type ActionResult<T = void> = {
49
+ success: true;
50
+ data: T;
51
+ } | {
52
+ success: false;
53
+ error: string;
54
+ };
55
+
56
+ interface KavachClientOptions {
57
+ basePath?: string;
58
+ }
59
+ interface KavachClient {
60
+ session: Readable<KavachSession | null>;
61
+ user: Readable<KavachUser | null>;
62
+ isAuthenticated: Readable<boolean>;
63
+ isLoading: Readable<boolean>;
64
+ signIn: (email: string, password: string) => Promise<ActionResult>;
65
+ signUp: (email: string, password: string, name?: string) => Promise<ActionResult>;
66
+ signOut: () => Promise<void>;
67
+ refresh: () => Promise<void>;
68
+ }
69
+ /**
70
+ * Creates a self-contained auth client backed by Svelte stores.
71
+ *
72
+ * Call this once (e.g. in a module or Svelte context) and spread or
73
+ * pass the returned object to whatever components need it.
74
+ */
75
+ declare function createKavachClient(options?: KavachClientOptions): KavachClient;
76
+ interface AgentStoreOptions {
77
+ basePath?: string;
78
+ /** Pass the user store from a KavachClient to enable auto-load. */
79
+ user?: Readable<KavachUser | null>;
80
+ }
81
+ interface AgentStore {
82
+ agents: Readable<KavachAgent[]>;
83
+ isLoading: Readable<boolean>;
84
+ error: Readable<string | null>;
85
+ load: (userId: string) => Promise<void>;
86
+ create: (input: CreateAgentInput) => Promise<ActionResult<KavachAgent>>;
87
+ revoke: (agentId: string) => Promise<ActionResult>;
88
+ rotate: (agentId: string) => Promise<ActionResult<KavachAgent>>;
89
+ }
90
+ /**
91
+ * Creates a store for managing agent identity records.
92
+ *
93
+ * Pass `user` from a `KavachClient` to have the store load automatically
94
+ * whenever a user is present. Otherwise call `load(userId)` manually.
95
+ */
96
+ declare function createAgentStore(options?: AgentStoreOptions): AgentStore;
97
+
98
+ export { type ActionResult, type AgentStore, type AgentStoreOptions, type CreateAgentInput, type KavachAgent, type KavachClient, type KavachClientOptions, type KavachPermission, type KavachSession, type KavachUser, createAgentStore, createKavachClient };
package/dist/index.js ADDED
@@ -0,0 +1,217 @@
1
+ // src/stores.ts
2
+ import { derived, writable } from "svelte/store";
3
+ function extractError(body, fallback) {
4
+ if (body !== null && typeof body === "object" && "error" in body && body.error !== null && typeof body.error === "object" && "message" in body.error && typeof body.error.message === "string") {
5
+ return body.error.message;
6
+ }
7
+ return fallback;
8
+ }
9
+ function createKavachClient(options) {
10
+ const basePath = options?.basePath ?? "/api/kavach";
11
+ const session = writable(null);
12
+ const isLoading = writable(true);
13
+ const user = derived(session, ($session) => $session?.user ?? null);
14
+ const isAuthenticated = derived(session, ($session) => $session !== null);
15
+ async function fetchSession() {
16
+ isLoading.set(true);
17
+ try {
18
+ const res = await fetch(`${basePath}/session`, { credentials: "include" });
19
+ if (res.ok) {
20
+ const json = await res.json();
21
+ session.set(json.data ?? null);
22
+ } else {
23
+ session.set(null);
24
+ }
25
+ } catch {
26
+ session.set(null);
27
+ } finally {
28
+ isLoading.set(false);
29
+ }
30
+ }
31
+ async function signIn(email, password) {
32
+ try {
33
+ const res = await fetch(`${basePath}/sign-in/email`, {
34
+ method: "POST",
35
+ credentials: "include",
36
+ headers: { "Content-Type": "application/json" },
37
+ body: JSON.stringify({ email, password })
38
+ });
39
+ const json = await res.json();
40
+ if (!res.ok) {
41
+ return { success: false, error: extractError(json, `Sign-in failed (${res.status})`) };
42
+ }
43
+ session.set(json.data);
44
+ return { success: true, data: void 0 };
45
+ } catch (err) {
46
+ return {
47
+ success: false,
48
+ error: err instanceof Error ? err.message : "Network error"
49
+ };
50
+ }
51
+ }
52
+ async function signUp(email, password, name) {
53
+ try {
54
+ const res = await fetch(`${basePath}/sign-up/email`, {
55
+ method: "POST",
56
+ credentials: "include",
57
+ headers: { "Content-Type": "application/json" },
58
+ body: JSON.stringify({ email, password, name })
59
+ });
60
+ const json = await res.json();
61
+ if (!res.ok) {
62
+ return { success: false, error: extractError(json, `Sign-up failed (${res.status})`) };
63
+ }
64
+ session.set(json.data);
65
+ return { success: true, data: void 0 };
66
+ } catch (err) {
67
+ return {
68
+ success: false,
69
+ error: err instanceof Error ? err.message : "Network error"
70
+ };
71
+ }
72
+ }
73
+ async function signOut() {
74
+ try {
75
+ await fetch(`${basePath}/sign-out`, { method: "POST", credentials: "include" });
76
+ } finally {
77
+ session.set(null);
78
+ }
79
+ }
80
+ if (typeof window !== "undefined") {
81
+ void fetchSession();
82
+ } else {
83
+ isLoading.set(false);
84
+ }
85
+ return {
86
+ session: { subscribe: session.subscribe },
87
+ user,
88
+ isAuthenticated,
89
+ isLoading: { subscribe: isLoading.subscribe },
90
+ signIn,
91
+ signUp,
92
+ signOut,
93
+ refresh: fetchSession
94
+ };
95
+ }
96
+ function createAgentStore(options) {
97
+ const basePath = options?.basePath ?? "/api/kavach";
98
+ const agents = writable([]);
99
+ const isLoading = writable(false);
100
+ const error = writable(null);
101
+ async function load(userId) {
102
+ isLoading.set(true);
103
+ error.set(null);
104
+ try {
105
+ const res = await fetch(`${basePath}/agents?userId=${encodeURIComponent(userId)}`, {
106
+ credentials: "include"
107
+ });
108
+ const json = await res.json();
109
+ if (!res.ok) {
110
+ error.set(extractError(json, `Failed to load agents (${res.status})`));
111
+ return;
112
+ }
113
+ agents.set(json.data);
114
+ } catch (err) {
115
+ error.set(err instanceof Error ? err.message : "Network error");
116
+ } finally {
117
+ isLoading.set(false);
118
+ }
119
+ }
120
+ async function create(input) {
121
+ try {
122
+ const res = await fetch(`${basePath}/agents`, {
123
+ method: "POST",
124
+ credentials: "include",
125
+ headers: { "Content-Type": "application/json" },
126
+ body: JSON.stringify(input)
127
+ });
128
+ const json = await res.json();
129
+ if (!res.ok) {
130
+ return {
131
+ success: false,
132
+ error: extractError(json, `Failed to create agent (${res.status})`)
133
+ };
134
+ }
135
+ const agent = json.data;
136
+ await load(input.ownerId);
137
+ return { success: true, data: agent };
138
+ } catch (err) {
139
+ return {
140
+ success: false,
141
+ error: err instanceof Error ? err.message : "Network error"
142
+ };
143
+ }
144
+ }
145
+ async function revoke(agentId) {
146
+ try {
147
+ const res = await fetch(`${basePath}/agents/${encodeURIComponent(agentId)}`, {
148
+ method: "DELETE",
149
+ credentials: "include"
150
+ });
151
+ if (!res.ok && res.status !== 204) {
152
+ const json = await res.json().catch(() => null);
153
+ return {
154
+ success: false,
155
+ error: extractError(json, `Failed to revoke agent (${res.status})`)
156
+ };
157
+ }
158
+ agents.update((prev) => prev.filter((a) => a.id !== agentId));
159
+ return { success: true, data: void 0 };
160
+ } catch (err) {
161
+ return {
162
+ success: false,
163
+ error: err instanceof Error ? err.message : "Network error"
164
+ };
165
+ }
166
+ }
167
+ async function rotate(agentId) {
168
+ try {
169
+ const res = await fetch(`${basePath}/agents/${encodeURIComponent(agentId)}/rotate`, {
170
+ method: "POST",
171
+ credentials: "include"
172
+ });
173
+ const json = await res.json();
174
+ if (!res.ok) {
175
+ return {
176
+ success: false,
177
+ error: extractError(json, `Failed to rotate agent token (${res.status})`)
178
+ };
179
+ }
180
+ const agent = json.data;
181
+ agents.update((prev) => prev.map((a) => a.id === agentId ? agent : a));
182
+ return { success: true, data: agent };
183
+ } catch (err) {
184
+ return {
185
+ success: false,
186
+ error: err instanceof Error ? err.message : "Network error"
187
+ };
188
+ }
189
+ }
190
+ if (typeof window !== "undefined" && options?.user) {
191
+ let initialised = false;
192
+ options.user.subscribe((u) => {
193
+ if (u && !initialised) {
194
+ initialised = true;
195
+ void load(u.id);
196
+ }
197
+ if (!u) {
198
+ initialised = false;
199
+ agents.set([]);
200
+ }
201
+ });
202
+ }
203
+ return {
204
+ agents: { subscribe: agents.subscribe },
205
+ isLoading: { subscribe: isLoading.subscribe },
206
+ error: { subscribe: error.subscribe },
207
+ load,
208
+ create,
209
+ revoke,
210
+ rotate
211
+ };
212
+ }
213
+ export {
214
+ createAgentStore,
215
+ createKavachClient
216
+ };
217
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/stores.ts"],"sourcesContent":["import type { Readable } from \"svelte/store\";\nimport { derived, writable } from \"svelte/store\";\nimport type {\n\tActionResult,\n\tCreateAgentInput,\n\tKavachAgent,\n\tKavachSession,\n\tKavachUser,\n} from \"./types.js\";\n\n// ─── Internal helpers ─────────────────────────────────────────────────────────\n\ninterface AgentApiResponse {\n\tdata: KavachAgent[];\n}\n\ninterface AgentSingleApiResponse {\n\tdata: KavachAgent;\n}\n\ninterface ApiErrorResponse {\n\terror: {\n\t\tcode: string;\n\t\tmessage: string;\n\t};\n}\n\nfunction extractError(body: unknown, fallback: string): string {\n\tif (\n\t\tbody !== null &&\n\t\ttypeof body === \"object\" &&\n\t\t\"error\" in body &&\n\t\tbody.error !== null &&\n\t\ttypeof body.error === \"object\" &&\n\t\t\"message\" in body.error &&\n\t\ttypeof (body as ApiErrorResponse).error.message === \"string\"\n\t) {\n\t\treturn (body as ApiErrorResponse).error.message;\n\t}\n\treturn fallback;\n}\n\n// ─── createKavachClient ───────────────────────────────────────────────────────\n\nexport interface KavachClientOptions {\n\tbasePath?: string;\n}\n\nexport interface KavachClient {\n\tsession: Readable<KavachSession | null>;\n\tuser: Readable<KavachUser | null>;\n\tisAuthenticated: Readable<boolean>;\n\tisLoading: Readable<boolean>;\n\tsignIn: (email: string, password: string) => Promise<ActionResult>;\n\tsignUp: (email: string, password: string, name?: string) => Promise<ActionResult>;\n\tsignOut: () => Promise<void>;\n\trefresh: () => Promise<void>;\n}\n\n/**\n * Creates a self-contained auth client backed by Svelte stores.\n *\n * Call this once (e.g. in a module or Svelte context) and spread or\n * pass the returned object to whatever components need it.\n */\nexport function createKavachClient(options?: KavachClientOptions): KavachClient {\n\tconst basePath = options?.basePath ?? \"/api/kavach\";\n\n\tconst session = writable<KavachSession | null>(null);\n\tconst isLoading = writable(true);\n\n\tconst user = derived(session, ($session) => $session?.user ?? null);\n\tconst isAuthenticated = derived(session, ($session) => $session !== null);\n\n\tasync function fetchSession(): Promise<void> {\n\t\tisLoading.set(true);\n\t\ttry {\n\t\t\tconst res = await fetch(`${basePath}/session`, { credentials: \"include\" });\n\t\t\tif (res.ok) {\n\t\t\t\tconst json: unknown = await res.json();\n\t\t\t\tsession.set((json as { data: KavachSession }).data ?? null);\n\t\t\t} else {\n\t\t\t\tsession.set(null);\n\t\t\t}\n\t\t} catch {\n\t\t\tsession.set(null);\n\t\t} finally {\n\t\t\tisLoading.set(false);\n\t\t}\n\t}\n\n\tasync function signIn(email: string, password: string): Promise<ActionResult> {\n\t\ttry {\n\t\t\tconst res = await fetch(`${basePath}/sign-in/email`, {\n\t\t\t\tmethod: \"POST\",\n\t\t\t\tcredentials: \"include\",\n\t\t\t\theaders: { \"Content-Type\": \"application/json\" },\n\t\t\t\tbody: JSON.stringify({ email, password }),\n\t\t\t});\n\t\t\tconst json: unknown = await res.json();\n\t\t\tif (!res.ok) {\n\t\t\t\treturn { success: false, error: extractError(json, `Sign-in failed (${res.status})`) };\n\t\t\t}\n\t\t\tsession.set((json as { data: KavachSession }).data);\n\t\t\treturn { success: true, data: undefined };\n\t\t} catch (err) {\n\t\t\treturn {\n\t\t\t\tsuccess: false,\n\t\t\t\terror: err instanceof Error ? err.message : \"Network error\",\n\t\t\t};\n\t\t}\n\t}\n\n\tasync function signUp(email: string, password: string, name?: string): Promise<ActionResult> {\n\t\ttry {\n\t\t\tconst res = await fetch(`${basePath}/sign-up/email`, {\n\t\t\t\tmethod: \"POST\",\n\t\t\t\tcredentials: \"include\",\n\t\t\t\theaders: { \"Content-Type\": \"application/json\" },\n\t\t\t\tbody: JSON.stringify({ email, password, name }),\n\t\t\t});\n\t\t\tconst json: unknown = await res.json();\n\t\t\tif (!res.ok) {\n\t\t\t\treturn { success: false, error: extractError(json, `Sign-up failed (${res.status})`) };\n\t\t\t}\n\t\t\tsession.set((json as { data: KavachSession }).data);\n\t\t\treturn { success: true, data: undefined };\n\t\t} catch (err) {\n\t\t\treturn {\n\t\t\t\tsuccess: false,\n\t\t\t\terror: err instanceof Error ? err.message : \"Network error\",\n\t\t\t};\n\t\t}\n\t}\n\n\tasync function signOut(): Promise<void> {\n\t\ttry {\n\t\t\tawait fetch(`${basePath}/sign-out`, { method: \"POST\", credentials: \"include\" });\n\t\t} finally {\n\t\t\tsession.set(null);\n\t\t}\n\t}\n\n\t// Fetch session on creation — guard for SSR environments\n\tif (typeof window !== \"undefined\") {\n\t\tvoid fetchSession();\n\t} else {\n\t\tisLoading.set(false);\n\t}\n\n\treturn {\n\t\tsession: { subscribe: session.subscribe } as Readable<KavachSession | null>,\n\t\tuser: user as Readable<KavachUser | null>,\n\t\tisAuthenticated: isAuthenticated as Readable<boolean>,\n\t\tisLoading: { subscribe: isLoading.subscribe } as Readable<boolean>,\n\t\tsignIn,\n\t\tsignUp,\n\t\tsignOut,\n\t\trefresh: fetchSession,\n\t};\n}\n\n// ─── createAgentStore ─────────────────────────────────────────────────────────\n\nexport interface AgentStoreOptions {\n\tbasePath?: string;\n\t/** Pass the user store from a KavachClient to enable auto-load. */\n\tuser?: Readable<KavachUser | null>;\n}\n\nexport interface AgentStore {\n\tagents: Readable<KavachAgent[]>;\n\tisLoading: Readable<boolean>;\n\terror: Readable<string | null>;\n\tload: (userId: string) => Promise<void>;\n\tcreate: (input: CreateAgentInput) => Promise<ActionResult<KavachAgent>>;\n\trevoke: (agentId: string) => Promise<ActionResult>;\n\trotate: (agentId: string) => Promise<ActionResult<KavachAgent>>;\n}\n\n/**\n * Creates a store for managing agent identity records.\n *\n * Pass `user` from a `KavachClient` to have the store load automatically\n * whenever a user is present. Otherwise call `load(userId)` manually.\n */\nexport function createAgentStore(options?: AgentStoreOptions): AgentStore {\n\tconst basePath = options?.basePath ?? \"/api/kavach\";\n\n\tconst agents = writable<KavachAgent[]>([]);\n\tconst isLoading = writable(false);\n\tconst error = writable<string | null>(null);\n\n\tasync function load(userId: string): Promise<void> {\n\t\tisLoading.set(true);\n\t\terror.set(null);\n\t\ttry {\n\t\t\tconst res = await fetch(`${basePath}/agents?userId=${encodeURIComponent(userId)}`, {\n\t\t\t\tcredentials: \"include\",\n\t\t\t});\n\t\t\tconst json: unknown = await res.json();\n\t\t\tif (!res.ok) {\n\t\t\t\terror.set(extractError(json, `Failed to load agents (${res.status})`));\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tagents.set((json as AgentApiResponse).data);\n\t\t} catch (err) {\n\t\t\terror.set(err instanceof Error ? err.message : \"Network error\");\n\t\t} finally {\n\t\t\tisLoading.set(false);\n\t\t}\n\t}\n\n\tasync function create(input: CreateAgentInput): Promise<ActionResult<KavachAgent>> {\n\t\ttry {\n\t\t\tconst res = await fetch(`${basePath}/agents`, {\n\t\t\t\tmethod: \"POST\",\n\t\t\t\tcredentials: \"include\",\n\t\t\t\theaders: { \"Content-Type\": \"application/json\" },\n\t\t\t\tbody: JSON.stringify(input),\n\t\t\t});\n\t\t\tconst json: unknown = await res.json();\n\t\t\tif (!res.ok) {\n\t\t\t\treturn {\n\t\t\t\t\tsuccess: false,\n\t\t\t\t\terror: extractError(json, `Failed to create agent (${res.status})`),\n\t\t\t\t};\n\t\t\t}\n\t\t\tconst agent = (json as AgentSingleApiResponse).data;\n\t\t\tawait load(input.ownerId);\n\t\t\treturn { success: true, data: agent };\n\t\t} catch (err) {\n\t\t\treturn {\n\t\t\t\tsuccess: false,\n\t\t\t\terror: err instanceof Error ? err.message : \"Network error\",\n\t\t\t};\n\t\t}\n\t}\n\n\tasync function revoke(agentId: string): Promise<ActionResult> {\n\t\ttry {\n\t\t\tconst res = await fetch(`${basePath}/agents/${encodeURIComponent(agentId)}`, {\n\t\t\t\tmethod: \"DELETE\",\n\t\t\t\tcredentials: \"include\",\n\t\t\t});\n\t\t\tif (!res.ok && res.status !== 204) {\n\t\t\t\tconst json: unknown = await res.json().catch(() => null);\n\t\t\t\treturn {\n\t\t\t\t\tsuccess: false,\n\t\t\t\t\terror: extractError(json, `Failed to revoke agent (${res.status})`),\n\t\t\t\t};\n\t\t\t}\n\t\t\t// Refresh by reloading current agents from the server\n\t\t\t// Optimistically remove from local state while reload is in flight\n\t\t\tagents.update((prev) => prev.filter((a) => a.id !== agentId));\n\t\t\treturn { success: true, data: undefined };\n\t\t} catch (err) {\n\t\t\treturn {\n\t\t\t\tsuccess: false,\n\t\t\t\terror: err instanceof Error ? err.message : \"Network error\",\n\t\t\t};\n\t\t}\n\t}\n\n\tasync function rotate(agentId: string): Promise<ActionResult<KavachAgent>> {\n\t\ttry {\n\t\t\tconst res = await fetch(`${basePath}/agents/${encodeURIComponent(agentId)}/rotate`, {\n\t\t\t\tmethod: \"POST\",\n\t\t\t\tcredentials: \"include\",\n\t\t\t});\n\t\t\tconst json: unknown = await res.json();\n\t\t\tif (!res.ok) {\n\t\t\t\treturn {\n\t\t\t\t\tsuccess: false,\n\t\t\t\t\terror: extractError(json, `Failed to rotate agent token (${res.status})`),\n\t\t\t\t};\n\t\t\t}\n\t\t\tconst agent = (json as AgentSingleApiResponse).data;\n\t\t\t// Update the rotated agent in place\n\t\t\tagents.update((prev) => prev.map((a) => (a.id === agentId ? agent : a)));\n\t\t\treturn { success: true, data: agent };\n\t\t} catch (err) {\n\t\t\treturn {\n\t\t\t\tsuccess: false,\n\t\t\t\terror: err instanceof Error ? err.message : \"Network error\",\n\t\t\t};\n\t\t}\n\t}\n\n\t// Auto-load when user store is provided and user becomes available (browser only)\n\tif (typeof window !== \"undefined\" && options?.user) {\n\t\tlet initialised = false;\n\t\toptions.user.subscribe((u) => {\n\t\t\tif (u && !initialised) {\n\t\t\t\tinitialised = true;\n\t\t\t\tvoid load(u.id);\n\t\t\t}\n\t\t\tif (!u) {\n\t\t\t\tinitialised = false;\n\t\t\t\tagents.set([]);\n\t\t\t}\n\t\t});\n\t}\n\n\treturn {\n\t\tagents: { subscribe: agents.subscribe } as Readable<KavachAgent[]>,\n\t\tisLoading: { subscribe: isLoading.subscribe } as Readable<boolean>,\n\t\terror: { subscribe: error.subscribe } as Readable<string | null>,\n\t\tload,\n\t\tcreate,\n\t\trevoke,\n\t\trotate,\n\t};\n}\n"],"mappings":";AACA,SAAS,SAAS,gBAAgB;AA0BlC,SAAS,aAAa,MAAe,UAA0B;AAC9D,MACC,SAAS,QACT,OAAO,SAAS,YAChB,WAAW,QACX,KAAK,UAAU,QACf,OAAO,KAAK,UAAU,YACtB,aAAa,KAAK,SAClB,OAAQ,KAA0B,MAAM,YAAY,UACnD;AACD,WAAQ,KAA0B,MAAM;AAAA,EACzC;AACA,SAAO;AACR;AAyBO,SAAS,mBAAmB,SAA6C;AAC/E,QAAM,WAAW,SAAS,YAAY;AAEtC,QAAM,UAAU,SAA+B,IAAI;AACnD,QAAM,YAAY,SAAS,IAAI;AAE/B,QAAM,OAAO,QAAQ,SAAS,CAAC,aAAa,UAAU,QAAQ,IAAI;AAClE,QAAM,kBAAkB,QAAQ,SAAS,CAAC,aAAa,aAAa,IAAI;AAExE,iBAAe,eAA8B;AAC5C,cAAU,IAAI,IAAI;AAClB,QAAI;AACH,YAAM,MAAM,MAAM,MAAM,GAAG,QAAQ,YAAY,EAAE,aAAa,UAAU,CAAC;AACzE,UAAI,IAAI,IAAI;AACX,cAAM,OAAgB,MAAM,IAAI,KAAK;AACrC,gBAAQ,IAAK,KAAiC,QAAQ,IAAI;AAAA,MAC3D,OAAO;AACN,gBAAQ,IAAI,IAAI;AAAA,MACjB;AAAA,IACD,QAAQ;AACP,cAAQ,IAAI,IAAI;AAAA,IACjB,UAAE;AACD,gBAAU,IAAI,KAAK;AAAA,IACpB;AAAA,EACD;AAEA,iBAAe,OAAO,OAAe,UAAyC;AAC7E,QAAI;AACH,YAAM,MAAM,MAAM,MAAM,GAAG,QAAQ,kBAAkB;AAAA,QACpD,QAAQ;AAAA,QACR,a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UAAI,CAAC,IAAI,IAAI;AACZ,eAAO;AAAA,UACN,SAAS;AAAA,UACT,OAAO,aAAa,MAAM,iCAAiC,IAAI,MAAM,GAAG;AAAA,QACzE;AAAA,MACD;AACA,YAAM,QAAS,KAAgC;AAE/C,aAAO,OAAO,CAAC,SAAS,KAAK,IAAI,CAAC,MAAO,EAAE,OAAO,UAAU,QAAQ,CAAE,CAAC;AACvE,aAAO,EAAE,SAAS,MAAM,MAAM,MAAM;AAAA,IACrC,SAAS,KAAK;AACb,aAAO;AAAA,QACN,SAAS;AAAA,QACT,OAAO,eAAe,QAAQ,IAAI,UAAU;AAAA,MAC7C;AAAA,IACD;AAAA,EACD;AAGA,MAAI,OAAO,WAAW,eAAe,SAAS,MAAM;AACnD,QAAI,cAAc;AAClB,YAAQ,KAAK,UAAU,CAAC,MAAM;AAC7B,UAAI,KAAK,CAAC,aAAa;AACtB,sBAAc;AACd,aAAK,KAAK,EAAE,EAAE;AAAA,MACf;AACA,UAAI,CAAC,GAAG;AACP,sBAAc;AACd,eAAO,IAAI,CAAC,CAAC;AAAA,MACd;AAAA,IACD,CAAC;AAAA,EACF;AAEA,SAAO;AAAA,IACN,QAAQ,EAAE,WAAW,OAAO,UAAU;AAAA,IACtC,WAAW,EAAE,WAAW,UAAU,UAAU;AAAA,IAC5C,OAAO,EAAE,WAAW,MAAM,UAAU;AAAA,IACpC;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD;AACD;","names":[]}
package/package.json ADDED
@@ -0,0 +1,36 @@
1
+ {
2
+ "name": "@kavachos/svelte",
3
+ "version": "0.0.3",
4
+ "description": "Svelte stores for KavachOS auth",
5
+ "type": "module",
6
+ "main": "dist/index.js",
7
+ "types": "dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.js"
12
+ }
13
+ },
14
+ "files": [
15
+ "dist"
16
+ ],
17
+ "license": "MIT",
18
+ "author": "KavachOS <hello@kavachos.com>",
19
+ "repository": {
20
+ "type": "git",
21
+ "url": "https://github.com/kavachos/kavachos.git",
22
+ "directory": "packages/svelte"
23
+ },
24
+ "peerDependencies": {
25
+ "svelte": ">=4.0.0"
26
+ },
27
+ "devDependencies": {
28
+ "svelte": "^5.0.0",
29
+ "tsup": "^8.4.0",
30
+ "typescript": "^5.8.0"
31
+ },
32
+ "scripts": {
33
+ "build": "tsup",
34
+ "typecheck": "tsc --noEmit"
35
+ }
36
+ }