authula 0.2.0

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.
@@ -0,0 +1,388 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ const require_fetch = require('../fetch-q98rEoAp.cjs');
3
+ let zod = require("zod");
4
+ let cookie = require("cookie");
5
+
6
+ //#region src/plugins/admin/plugin.ts
7
+ var AdminPlugin = class {
8
+ id = "admin";
9
+ constructor() {}
10
+ init(client) {
11
+ return {
12
+ createUser: async (data) => {
13
+ return require_fetch.wrappedFetch(client, "/admin/users", {
14
+ method: "POST",
15
+ body: data
16
+ });
17
+ },
18
+ getAllUsers: async (limit) => {
19
+ const urlSearchParams = new URLSearchParams();
20
+ if (limit) urlSearchParams.append("limit", limit.toString());
21
+ return require_fetch.wrappedFetch(client, `/admin/users${urlSearchParams.toString() ? `?${urlSearchParams.toString()}` : ""}`, { method: "GET" });
22
+ },
23
+ getUserById: async (userId) => {
24
+ return require_fetch.wrappedFetch(client, `/admin/users/${userId}`, { method: "GET" });
25
+ },
26
+ updateUser: async (userId, data) => {
27
+ return require_fetch.wrappedFetch(client, `/admin/users/${userId}`, {
28
+ method: "PATCH",
29
+ body: data
30
+ });
31
+ },
32
+ deleteUser: async (userId) => {
33
+ return require_fetch.wrappedFetch(client, `/admin/users/${userId}`, { method: "DELETE" });
34
+ },
35
+ createAccount: async (userId, data) => {
36
+ return require_fetch.wrappedFetch(client, `/admin/users/${userId}/accounts`, {
37
+ method: "POST",
38
+ body: data
39
+ });
40
+ },
41
+ getUserAccounts: async (userId) => {
42
+ return require_fetch.wrappedFetch(client, `/admin/users/${userId}/accounts`, { method: "GET" });
43
+ },
44
+ getAccountById: async (id) => {
45
+ return require_fetch.wrappedFetch(client, `/admin/accounts/${id}`, { method: "GET" });
46
+ },
47
+ updateAccount: async (id, data) => {
48
+ return require_fetch.wrappedFetch(client, `/admin/accounts/${id}`, {
49
+ method: "PATCH",
50
+ body: data
51
+ });
52
+ },
53
+ deleteAccount: async (id) => {
54
+ return require_fetch.wrappedFetch(client, `/admin/accounts/${id}`, { method: "DELETE" });
55
+ },
56
+ getUserState: async (userId) => {
57
+ return require_fetch.wrappedFetch(client, `/admin/users/${userId}/state`, { method: "GET" });
58
+ },
59
+ createUserState: async (userId, data) => {
60
+ return require_fetch.wrappedFetch(client, `/admin/users/${userId}/state`, {
61
+ method: "POST",
62
+ body: data
63
+ });
64
+ },
65
+ updateUserState: async (userId, data) => {
66
+ return require_fetch.wrappedFetch(client, `/admin/users/${userId}/state`, {
67
+ method: "PATCH",
68
+ body: data
69
+ });
70
+ },
71
+ deleteUserState: async (userId) => {
72
+ return require_fetch.wrappedFetch(client, `/admin/users/${userId}/state`, { method: "DELETE" });
73
+ },
74
+ getBannedUserStates: async () => {
75
+ return require_fetch.wrappedFetch(client, `/admin/users/states/banned`, { method: "GET" });
76
+ },
77
+ banUser: async (userId, data) => {
78
+ return require_fetch.wrappedFetch(client, `/admin/users/${userId}/ban`, {
79
+ method: "POST",
80
+ body: data
81
+ });
82
+ },
83
+ unbanUser: async (userId) => {
84
+ return require_fetch.wrappedFetch(client, `/admin/users/${userId}/unban`, { method: "POST" });
85
+ },
86
+ getUserAdminSessions: async (userId) => {
87
+ return require_fetch.wrappedFetch(client, `/admin/users/${userId}/sessions`, { method: "GET" });
88
+ },
89
+ getSessionState: async (sessionId) => {
90
+ return require_fetch.wrappedFetch(client, `/admin/sessions/${sessionId}/state`, { method: "GET" });
91
+ },
92
+ createSessionState: async (sessionId, data) => {
93
+ return require_fetch.wrappedFetch(client, `/admin/sessions/${sessionId}/state`, {
94
+ method: "POST",
95
+ body: data
96
+ });
97
+ },
98
+ updateSessionState: async (sessionId, data) => {
99
+ return require_fetch.wrappedFetch(client, `/admin/sessions/${sessionId}/state`, {
100
+ method: "PATCH",
101
+ body: data
102
+ });
103
+ },
104
+ deleteSessionState: async (sessionId) => {
105
+ return require_fetch.wrappedFetch(client, `/admin/sessions/${sessionId}/state`, { method: "DELETE" });
106
+ },
107
+ getRevokedSessionStates: async () => {
108
+ return require_fetch.wrappedFetch(client, `/admin/sessions/states/revoked`, { method: "GET" });
109
+ },
110
+ revokeSession: async (sessionId, data) => {
111
+ return require_fetch.wrappedFetch(client, `/admin/sessions/${sessionId}/revoke`, {
112
+ method: "POST",
113
+ body: data
114
+ });
115
+ },
116
+ getAllImpersonations: async () => {
117
+ return require_fetch.wrappedFetch(client, "/admin/impersonations", { method: "GET" });
118
+ },
119
+ getImpersonationById: async (impersonationId) => {
120
+ return require_fetch.wrappedFetch(client, `/admin/impersonations/${impersonationId}`, { method: "GET" });
121
+ },
122
+ startImpersonation: async (data) => {
123
+ return require_fetch.wrappedFetch(client, "/admin/impersonations", {
124
+ method: "POST",
125
+ body: data
126
+ });
127
+ },
128
+ stopImpersonation: async (impersonationId) => {
129
+ return require_fetch.wrappedFetch(client, `/admin/impersonations/${impersonationId}/stop`, { method: "POST" });
130
+ }
131
+ };
132
+ }
133
+ };
134
+
135
+ //#endregion
136
+ //#region src/plugins/admin/types.ts
137
+ const adminUserStateSchema = zod.z.object({
138
+ userId: zod.z.string().nonempty(),
139
+ isBanned: zod.z.boolean(),
140
+ bannedAt: zod.z.iso.datetime().nullable(),
141
+ bannedUntil: zod.z.iso.datetime().nullable(),
142
+ bannedReason: zod.z.string().nullable(),
143
+ bannedByUserId: zod.z.string().nullable(),
144
+ createdAt: zod.z.iso.datetime(),
145
+ updatedAt: zod.z.iso.datetime()
146
+ });
147
+ const adminSessionStateSchema = zod.z.object({
148
+ sessionId: zod.z.string().nonempty(),
149
+ revokedAt: zod.z.iso.datetime().nullable(),
150
+ revokedReason: zod.z.string().nullable(),
151
+ revokedByUserId: zod.z.string().nullable(),
152
+ impersonatorUserId: zod.z.string().nullable(),
153
+ impersonationReason: zod.z.string().nullable(),
154
+ impersonationExpiresAt: zod.z.iso.datetime().nullable(),
155
+ createdAt: zod.z.iso.datetime(),
156
+ updatedAt: zod.z.iso.datetime()
157
+ });
158
+ const adminUserSessionSchema = zod.z.object({
159
+ session: require_fetch.sessionSchema,
160
+ state: adminSessionStateSchema.nullable()
161
+ });
162
+ const impersonationSchema = zod.z.object({
163
+ id: zod.z.string().nonempty(),
164
+ actorUserId: zod.z.string().nonempty(),
165
+ targetUserId: zod.z.string().nonempty(),
166
+ actorSessionId: zod.z.string().nullable(),
167
+ impersonationSessionId: zod.z.string().nullable(),
168
+ reason: zod.z.string().nonempty(),
169
+ startedAt: zod.z.iso.datetime(),
170
+ expiresAt: zod.z.iso.datetime(),
171
+ endedAt: zod.z.iso.datetime().nullable(),
172
+ endedByUserId: zod.z.string().nullable(),
173
+ createdAt: zod.z.iso.datetime(),
174
+ updatedAt: zod.z.iso.datetime()
175
+ });
176
+
177
+ //#endregion
178
+ //#region src/plugins/bearer/plugin.ts
179
+ var BearerPlugin = class {
180
+ id = "bearer";
181
+ refreshPromise = null;
182
+ constructor(options) {
183
+ this.options = options;
184
+ }
185
+ init(client) {
186
+ client.registerBeforeFetch(async (ctx) => {
187
+ if (typeof document === "undefined") return;
188
+ const headerName = this.options?.headerName ?? "Authorization";
189
+ const token = localStorage.getItem("accessToken");
190
+ if (token) ctx.init.headers = {
191
+ ...ctx.init.headers,
192
+ [headerName]: `Bearer ${token}`
193
+ };
194
+ });
195
+ client.registerAfterFetch(async (ctx, res) => {
196
+ if (typeof document === "undefined") return;
197
+ if (res.status !== 401) return;
198
+ if (ctx.meta.retry) return;
199
+ const refreshToken = localStorage.getItem("refreshToken");
200
+ if (!refreshToken) return;
201
+ if (!client.jwt) {
202
+ console.warn("JWT Plugin is required for Bearer token refresh.");
203
+ return;
204
+ }
205
+ if (!this.refreshPromise) this.refreshPromise = (async () => {
206
+ try {
207
+ const response = await client.jwt.refreshToken({ refreshToken });
208
+ if (!response) return null;
209
+ localStorage.setItem("accessToken", response.accessToken);
210
+ localStorage.setItem("refreshToken", response.refreshToken);
211
+ return response;
212
+ } finally {
213
+ this.refreshPromise = null;
214
+ }
215
+ })();
216
+ const refreshed = await this.refreshPromise;
217
+ if (!refreshed) return;
218
+ const headerName = this.options?.headerName ?? "Authorization";
219
+ ctx.init.headers = {
220
+ ...ctx.init.headers,
221
+ [headerName]: `Bearer ${refreshed.accessToken}`
222
+ };
223
+ return "retry";
224
+ });
225
+ return {};
226
+ }
227
+ };
228
+
229
+ //#endregion
230
+ //#region src/plugins/csrf/plugin.ts
231
+ var CSRFPlugin = class {
232
+ id = "csrf";
233
+ constructor(options) {
234
+ this.options = options;
235
+ }
236
+ init(client) {
237
+ client.registerBeforeFetch(async (ctx) => {
238
+ if (typeof document !== "undefined") {
239
+ if ([
240
+ "OPTIONS",
241
+ "HEAD",
242
+ "GET"
243
+ ].includes(ctx.init.method || "GET")) return;
244
+ const value = (0, cookie.parse)(document.cookie)[this.options.cookieName];
245
+ if (!value) return;
246
+ ctx.init.headers = new Headers(ctx.init.headers);
247
+ ctx.init.headers.set(this.options.headerName, value);
248
+ return;
249
+ }
250
+ if (this.cookies) {
251
+ if ([
252
+ "OPTIONS",
253
+ "HEAD",
254
+ "GET"
255
+ ].includes(ctx.init.method || "GET")) return;
256
+ const cookie$1 = (await this.cookies()).get(this.options.cookieName);
257
+ if (!cookie$1) return;
258
+ ctx.init.headers = new Headers(ctx.init.headers);
259
+ ctx.init.headers.set(this.options.headerName, cookie$1.value);
260
+ }
261
+ });
262
+ return {};
263
+ }
264
+ cookies;
265
+ attachCookies(fn) {
266
+ this.cookies = fn;
267
+ }
268
+ };
269
+
270
+ //#endregion
271
+ //#region src/plugins/email-password/plugin.ts
272
+ var EmailPasswordPlugin = class {
273
+ id = "emailPassword";
274
+ init(client) {
275
+ return {
276
+ signUp: async (data) => {
277
+ return require_fetch.wrappedFetch(client, "/sign-up", {
278
+ method: "POST",
279
+ body: data
280
+ });
281
+ },
282
+ signIn: async (data) => {
283
+ return require_fetch.wrappedFetch(client, "/sign-in", {
284
+ method: "POST",
285
+ body: data
286
+ });
287
+ },
288
+ sendEmailVerification: async (data) => {
289
+ return require_fetch.wrappedFetch(client, `/send-email-verification`, {
290
+ method: "POST",
291
+ body: data
292
+ });
293
+ },
294
+ requestPasswordReset: async (data) => {
295
+ return require_fetch.wrappedFetch(client, `/request-password-reset`, {
296
+ method: "POST",
297
+ body: data
298
+ });
299
+ },
300
+ changePassword: async (data) => {
301
+ return require_fetch.wrappedFetch(client, `/change-password`, {
302
+ method: "POST",
303
+ body: data
304
+ });
305
+ },
306
+ requestEmailChange: async (data) => {
307
+ return require_fetch.wrappedFetch(client, `/request-email-change`, {
308
+ method: "POST",
309
+ body: data
310
+ });
311
+ }
312
+ };
313
+ }
314
+ };
315
+
316
+ //#endregion
317
+ //#region src/plugins/jwt/plugin.ts
318
+ var JWTPlugin = class {
319
+ id = "jwt";
320
+ constructor() {}
321
+ init(client) {
322
+ return {
323
+ refreshToken: async (data) => {
324
+ return require_fetch.wrappedFetch(client, "/token/refresh", {
325
+ method: "POST",
326
+ body: data
327
+ });
328
+ },
329
+ getJWKSKeys: async () => {
330
+ return require_fetch.wrappedFetch(client, "/.well-known/jwks.json", { method: "GET" });
331
+ }
332
+ };
333
+ }
334
+ };
335
+
336
+ //#endregion
337
+ //#region src/plugins/magic-link/plugin.ts
338
+ var MagicLinkPlugin = class {
339
+ id = "magicLink";
340
+ constructor() {}
341
+ init(client) {
342
+ return {
343
+ signIn: async (data) => {
344
+ return require_fetch.wrappedFetch(client, "/magic-link/sign-in", {
345
+ method: "POST",
346
+ body: data
347
+ });
348
+ },
349
+ verify: async (data) => {
350
+ const searchParams = new URLSearchParams();
351
+ searchParams.append("token", data.token);
352
+ if (data.callbackUrl) searchParams.append("callback_url", data.callbackUrl);
353
+ return require_fetch.wrappedFetch(client, `/magic-link/verify?${searchParams.toString()}`, { method: "GET" });
354
+ },
355
+ exchange: async (data) => {
356
+ return require_fetch.wrappedFetch(client, "/magic-link/exchange", {
357
+ method: "POST",
358
+ body: data
359
+ });
360
+ }
361
+ };
362
+ }
363
+ };
364
+
365
+ //#endregion
366
+ //#region src/plugins/oauth2/plugin.ts
367
+ var OAuth2Plugin = class {
368
+ id = "oauth2";
369
+ init(client) {
370
+ return { signIn: async (data) => {
371
+ return require_fetch.wrappedFetch(client, `/oauth2/authorize/${data.provider}?redirect_to=${data.redirectTo}`, { method: "GET" });
372
+ } };
373
+ }
374
+ };
375
+
376
+ //#endregion
377
+ exports.AdminPlugin = AdminPlugin;
378
+ exports.BearerPlugin = BearerPlugin;
379
+ exports.CSRFPlugin = CSRFPlugin;
380
+ exports.EmailPasswordPlugin = EmailPasswordPlugin;
381
+ exports.JWTPlugin = JWTPlugin;
382
+ exports.MagicLinkPlugin = MagicLinkPlugin;
383
+ exports.OAuth2Plugin = OAuth2Plugin;
384
+ exports.adminSessionStateSchema = adminSessionStateSchema;
385
+ exports.adminUserSessionSchema = adminUserSessionSchema;
386
+ exports.adminUserStateSchema = adminUserStateSchema;
387
+ exports.impersonationSchema = impersonationSchema;
388
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs","names":["wrappedFetch","z","sessionSchema","cookie","wrappedFetch","wrappedFetch","wrappedFetch","wrappedFetch"],"sources":["../../src/plugins/admin/plugin.ts","../../src/plugins/admin/types.ts","../../src/plugins/bearer/plugin.ts","../../src/plugins/csrf/plugin.ts","../../src/plugins/email-password/plugin.ts","../../src/plugins/jwt/plugin.ts","../../src/plugins/magic-link/plugin.ts","../../src/plugins/oauth2/plugin.ts"],"sourcesContent":["import type { AuthulaClient } from \"@/client\";\nimport { wrappedFetch } from \"@/fetch\";\nimport type { Plugin } from \"@/types\";\nimport type {\n BanUserRequest,\n BanUserResponse,\n CreateUserRequest,\n CreateUserResponse,\n DeleteSessionStateResponse,\n DeleteUserStateResponse,\n StopImpersonationResponse,\n GetAllImpersonationsResponse,\n GetAllUsersResponse,\n GetBannedUserStatesResponse,\n GetImpersonationByIdResponse,\n GetRevokedSessionStatesResponse,\n GetSessionStateResponse,\n GetUserAdminSessionsResponse,\n GetUserByIdResponse,\n GetUserStateResponse,\n RevokeSessionRequest,\n RevokeSessionResponse,\n StartImpersonationRequest,\n StartImpersonationResponse,\n UnbanUserResponse,\n UpdateUserRequest,\n UpdateUserResponse,\n DeleteUserResponse,\n CreateAccountRequest,\n CreateAccountResponse,\n GetUserAccountsResponse,\n GetAccountByIdResponse,\n UpdateAccountRequest,\n UpdateAccountResponse,\n DeleteAccountResponse,\n CreateUserStateRequest,\n CreateUserStateResponse,\n UpdateUserStateRequest,\n UpdateUserStateResponse,\n CreateSessionStateRequest,\n CreateSessionStateResponse,\n UpdateSessionStateRequest,\n UpdateSessionStateResponse,\n} from \"./types\";\n\nexport class AdminPlugin implements Plugin {\n public readonly id = \"admin\";\n\n constructor() {}\n\n public init(client: AuthulaClient) {\n return {\n // User management\n\n createUser: async (\n data: CreateUserRequest,\n ): Promise<CreateUserResponse> => {\n return wrappedFetch(client, \"/admin/users\", {\n method: \"POST\",\n body: data,\n });\n },\n getAllUsers: async (limit?: number): Promise<GetAllUsersResponse> => {\n const urlSearchParams = new URLSearchParams();\n if (limit) {\n urlSearchParams.append(\"limit\", limit.toString());\n }\n const params = urlSearchParams.toString()\n ? `?${urlSearchParams.toString()}`\n : \"\";\n return wrappedFetch(client, `/admin/users${params}`, {\n method: \"GET\",\n });\n },\n getUserById: async (userId: string): Promise<GetUserByIdResponse> => {\n return wrappedFetch(client, `/admin/users/${userId}`, {\n method: \"GET\",\n });\n },\n updateUser: async (\n userId: string,\n data: UpdateUserRequest,\n ): Promise<UpdateUserResponse> => {\n return wrappedFetch(client, `/admin/users/${userId}`, {\n method: \"PATCH\",\n body: data,\n });\n },\n deleteUser: async (userId: string): Promise<DeleteUserResponse> => {\n return wrappedFetch(client, `/admin/users/${userId}`, {\n method: \"DELETE\",\n });\n },\n\n // Account management\n\n createAccount: async (\n userId: string,\n data: CreateAccountRequest,\n ): Promise<CreateAccountResponse> => {\n return wrappedFetch(client, `/admin/users/${userId}/accounts`, {\n method: \"POST\",\n body: data,\n });\n },\n getUserAccounts: async (\n userId: string,\n ): Promise<GetUserAccountsResponse> => {\n return wrappedFetch(client, `/admin/users/${userId}/accounts`, {\n method: \"GET\",\n });\n },\n getAccountById: async (id: string): Promise<GetAccountByIdResponse> => {\n return wrappedFetch(client, `/admin/accounts/${id}`, {\n method: \"GET\",\n });\n },\n updateAccount: async (\n id: string,\n data: UpdateAccountRequest,\n ): Promise<UpdateAccountResponse> => {\n return wrappedFetch(client, `/admin/accounts/${id}`, {\n method: \"PATCH\",\n body: data,\n });\n },\n deleteAccount: async (id: string): Promise<DeleteAccountResponse> => {\n return wrappedFetch(client, `/admin/accounts/${id}`, {\n method: \"DELETE\",\n });\n },\n\n // User state management\n\n getUserState: async (userId: string): Promise<GetUserStateResponse> => {\n return wrappedFetch(client, `/admin/users/${userId}/state`, {\n method: \"GET\",\n });\n },\n createUserState: async (\n userId: string,\n data: CreateUserStateRequest,\n ): Promise<CreateUserStateResponse> => {\n return wrappedFetch(client, `/admin/users/${userId}/state`, {\n method: \"POST\",\n body: data,\n });\n },\n updateUserState: async (\n userId: string,\n data: UpdateUserStateRequest,\n ): Promise<UpdateUserStateResponse> => {\n return wrappedFetch(client, `/admin/users/${userId}/state`, {\n method: \"PATCH\",\n body: data,\n });\n },\n deleteUserState: async (\n userId: string,\n ): Promise<DeleteUserStateResponse> => {\n return wrappedFetch(client, `/admin/users/${userId}/state`, {\n method: \"DELETE\",\n });\n },\n getBannedUserStates: async (): Promise<GetBannedUserStatesResponse> => {\n return wrappedFetch(client, `/admin/users/states/banned`, {\n method: \"GET\",\n });\n },\n banUser: async (\n userId: string,\n data: BanUserRequest,\n ): Promise<BanUserResponse> => {\n return wrappedFetch(client, `/admin/users/${userId}/ban`, {\n method: \"POST\",\n body: data,\n });\n },\n unbanUser: async (userId: string): Promise<UnbanUserResponse> => {\n return wrappedFetch(client, `/admin/users/${userId}/unban`, {\n method: \"POST\",\n });\n },\n getUserAdminSessions: async (\n userId: string,\n ): Promise<GetUserAdminSessionsResponse> => {\n return wrappedFetch(client, `/admin/users/${userId}/sessions`, {\n method: \"GET\",\n });\n },\n\n // Session state management\n\n getSessionState: async (\n sessionId: string,\n ): Promise<GetSessionStateResponse> => {\n return wrappedFetch(client, `/admin/sessions/${sessionId}/state`, {\n method: \"GET\",\n });\n },\n createSessionState: async (\n sessionId: string,\n data: CreateSessionStateRequest,\n ): Promise<CreateSessionStateResponse> => {\n return wrappedFetch(client, `/admin/sessions/${sessionId}/state`, {\n method: \"POST\",\n body: data,\n });\n },\n updateSessionState: async (\n sessionId: string,\n data: UpdateSessionStateRequest,\n ): Promise<UpdateSessionStateResponse> => {\n return wrappedFetch(client, `/admin/sessions/${sessionId}/state`, {\n method: \"PATCH\",\n body: data,\n });\n },\n deleteSessionState: async (\n sessionId: string,\n ): Promise<DeleteSessionStateResponse> => {\n return wrappedFetch(client, `/admin/sessions/${sessionId}/state`, {\n method: \"DELETE\",\n });\n },\n getRevokedSessionStates:\n async (): Promise<GetRevokedSessionStatesResponse> => {\n return wrappedFetch(client, `/admin/sessions/states/revoked`, {\n method: \"GET\",\n });\n },\n revokeSession: async (\n sessionId: string,\n data: RevokeSessionRequest,\n ): Promise<RevokeSessionResponse> => {\n return wrappedFetch(client, `/admin/sessions/${sessionId}/revoke`, {\n method: \"POST\",\n body: data,\n });\n },\n\n // Impersonations\n\n getAllImpersonations: async (): Promise<GetAllImpersonationsResponse> => {\n return wrappedFetch(client, \"/admin/impersonations\", {\n method: \"GET\",\n });\n },\n getImpersonationById: async (\n impersonationId: string,\n ): Promise<GetImpersonationByIdResponse> => {\n return wrappedFetch(\n client,\n `/admin/impersonations/${impersonationId}`,\n {\n method: \"GET\",\n },\n );\n },\n startImpersonation: async (\n data: StartImpersonationRequest,\n ): Promise<StartImpersonationResponse> => {\n return wrappedFetch(client, \"/admin/impersonations\", {\n method: \"POST\",\n body: data,\n });\n },\n stopImpersonation: async (\n impersonationId: string,\n ): Promise<StopImpersonationResponse> => {\n return wrappedFetch(\n client,\n `/admin/impersonations/${impersonationId}/stop`,\n {\n method: \"POST\",\n },\n );\n },\n };\n }\n}\n","import { z } from \"zod\";\n\nimport { sessionSchema, type Account, type User } from \"@/types\";\n\n// ------------------------------\n// SCHEMAS\n// ------------------------------\n\nexport const adminUserStateSchema = z.object({\n userId: z.string().nonempty(),\n isBanned: z.boolean(),\n bannedAt: z.iso.datetime().nullable(),\n bannedUntil: z.iso.datetime().nullable(),\n bannedReason: z.string().nullable(),\n bannedByUserId: z.string().nullable(),\n createdAt: z.iso.datetime(),\n updatedAt: z.iso.datetime(),\n});\nexport type AdminUserState = z.infer<typeof adminUserStateSchema>;\n\nexport const adminSessionStateSchema = z.object({\n sessionId: z.string().nonempty(),\n revokedAt: z.iso.datetime().nullable(),\n revokedReason: z.string().nullable(),\n revokedByUserId: z.string().nullable(),\n impersonatorUserId: z.string().nullable(),\n impersonationReason: z.string().nullable(),\n impersonationExpiresAt: z.iso.datetime().nullable(),\n createdAt: z.iso.datetime(),\n updatedAt: z.iso.datetime(),\n});\nexport type AdminSessionState = z.infer<typeof adminSessionStateSchema>;\n\nexport const adminUserSessionSchema = z.object({\n session: sessionSchema,\n state: adminSessionStateSchema.nullable(),\n});\nexport type AdminUserSession = z.infer<typeof adminUserSessionSchema>;\n\nexport const impersonationSchema = z.object({\n id: z.string().nonempty(),\n actorUserId: z.string().nonempty(),\n targetUserId: z.string().nonempty(),\n actorSessionId: z.string().nullable(),\n impersonationSessionId: z.string().nullable(),\n reason: z.string().nonempty(),\n startedAt: z.iso.datetime(),\n expiresAt: z.iso.datetime(),\n endedAt: z.iso.datetime().nullable(),\n endedByUserId: z.string().nullable(),\n createdAt: z.iso.datetime(),\n updatedAt: z.iso.datetime(),\n});\nexport type Impersonation = z.infer<typeof impersonationSchema>;\n\n// ------------------------------\n// API response types\n// ------------------------------\n\n// User management\n\nexport type CreateUserRequest = {\n name: string;\n email: string;\n emailVerified?: boolean;\n image?: string;\n metadata?: Record<string, unknown>;\n};\n\nexport type CreateUserResponse = {\n user: User;\n};\n\nexport type GetAllUsersResponse = {\n users: Array<User>;\n nextCursor?: string | null;\n};\n\nexport type GetUserByIdResponse = {\n user: User;\n};\n\nexport type UpdateUserRequest = {\n name?: string;\n email?: string;\n emailVerified?: boolean;\n image?: string;\n metadata?: Record<string, unknown>;\n};\n\nexport type UpdateUserResponse = {\n user: User;\n};\n\nexport type DeleteUserResponse = {\n message: string;\n};\n\n// Account management\n\nexport type CreateAccountRequest = {\n providerId: string;\n accountId: string;\n accessToken?: string;\n refreshToken?: string;\n idToken?: string;\n accessTokenExpiresAt?: string;\n refreshTokenExpiresAt?: string;\n scope?: string;\n password?: string;\n};\n\nexport type CreateAccountResponse = {\n account: Account;\n};\n\nexport type GetUserAccountsResponse = {\n accounts: Array<Account>;\n};\n\nexport type GetAccountByIdResponse = {\n account: Account;\n};\n\nexport type UpdateAccountRequest = {\n providerId?: string;\n accountId?: string;\n accessToken?: string;\n refreshToken?: string;\n idToken?: string;\n accessTokenExpiresAt?: string;\n refreshTokenExpiresAt?: string;\n scope?: string;\n password?: string;\n};\n\nexport type UpdateAccountResponse = {\n account: Account;\n};\n\nexport type DeleteAccountResponse = {\n message: string;\n};\n\n// User state management\n\nexport type GetUserStateResponse = {\n state: AdminUserState;\n};\n\nexport type CreateUserStateRequest = {\n banned: boolean;\n bannedUntil?: string;\n bannedReason?: string;\n};\n\nexport type UpdateUserStateRequest = {\n banned: boolean;\n bannedUntil?: string;\n bannedReason?: string;\n};\n\nexport type CreateUserStateResponse = {\n userState: AdminUserState;\n};\n\nexport type UpdateUserStateResponse = {\n userState: AdminUserState;\n};\n\nexport type DeleteUserStateResponse = {\n message: string;\n};\n\nexport type GetBannedUserStatesResponse = Array<AdminUserState>;\n\nexport type BanUserRequest = {\n bannedUntil?: string;\n reason?: string;\n};\n\nexport type BanUserResponse = {\n state: AdminUserState;\n};\n\nexport type UnbanUserResponse = {\n state: AdminUserState;\n};\n\nexport type GetUserAdminSessionsResponse = Array<AdminUserSession>;\n\n// Session state management\n\nexport type GetSessionStateResponse = {\n state: AdminSessionState;\n};\n\nexport type CreateSessionStateRequest = {\n revoke: boolean;\n revokedReason?: string;\n impersonatorUserId?: string;\n impersonationReason?: string;\n impersonationExpiresAt?: string;\n};\n\nexport type UpdateSessionStateRequest = {\n revoke: boolean;\n revokedReason?: string;\n impersonatorUserId?: string;\n impersonationReason?: string;\n impersonationExpiresAt?: string;\n};\n\nexport type CreateSessionStateResponse = {\n state: AdminSessionState;\n};\n\nexport type UpdateSessionStateResponse = {\n state: AdminSessionState;\n};\n\nexport type DeleteSessionStateResponse = {\n message: string;\n};\n\nexport type GetRevokedSessionStatesResponse = Array<AdminSessionState>;\n\nexport type RevokeSessionRequest = {\n reason?: string;\n};\n\nexport type RevokeSessionResponse = {\n sessionState: AdminSessionState;\n};\n\n// Impersonation\n\nexport type GetAllImpersonationsResponse = Array<Impersonation>;\n\nexport type GetImpersonationByIdResponse = {\n impersonation: Impersonation;\n};\n\nexport type StartImpersonationRequest = {\n targetUserId: string;\n reason: string;\n expiresInSeconds?: number;\n};\n\nexport type StartImpersonationResponse = {\n impersonation: Impersonation;\n};\n\nexport type StopImpersonationResponse = {\n message: string;\n};\n","import type { FetchContext, Plugin } from \"@/types\";\nimport type { BearerPluginOptions } from \"./types\";\nimport type { JWTPlugin } from \"../jwt/plugin\";\nimport type { ClientWithPlugins } from \"@/sdk\";\n\nexport class BearerPlugin implements Plugin {\n public readonly id = \"bearer\";\n private refreshPromise: Promise<any> | null = null;\n\n constructor(private readonly options?: BearerPluginOptions) {}\n\n public init(client: ClientWithPlugins<[JWTPlugin]>) {\n client.registerBeforeFetch(async (ctx: FetchContext) => {\n if (typeof document === \"undefined\") {\n return;\n }\n\n const headerName = this.options?.headerName ?? \"Authorization\";\n const token = localStorage.getItem(\"accessToken\");\n if (token) {\n ctx.init.headers = {\n ...ctx.init.headers,\n [headerName]: `Bearer ${token}`,\n };\n }\n });\n\n client.registerAfterFetch(async (ctx: FetchContext, res: Response) => {\n if (typeof document === \"undefined\") {\n return;\n }\n if (res.status !== 401) {\n return;\n }\n if (ctx.meta.retry) {\n return;\n }\n\n const refreshToken = localStorage.getItem(\"refreshToken\");\n if (!refreshToken) {\n return;\n }\n\n if (!client.jwt) {\n console.warn(\"JWT Plugin is required for Bearer token refresh.\");\n return;\n }\n\n // 🔒 SINGLE FLIGHT REFRESH\n if (!this.refreshPromise) {\n this.refreshPromise = (async () => {\n try {\n const response = await client.jwt.refreshToken({\n refreshToken: refreshToken,\n });\n if (!response) {\n return null;\n }\n\n localStorage.setItem(\"accessToken\", response.accessToken);\n localStorage.setItem(\"refreshToken\", response.refreshToken);\n\n return response;\n } finally {\n this.refreshPromise = null;\n }\n })();\n }\n\n const refreshed = await this.refreshPromise;\n if (!refreshed) {\n return;\n }\n\n const headerName = this.options?.headerName ?? \"Authorization\";\n ctx.init.headers = {\n ...ctx.init.headers,\n [headerName]: `Bearer ${refreshed.accessToken}`,\n };\n\n return \"retry\";\n });\n\n return {};\n }\n}\n","import { parse } from \"cookie\";\n\nimport type { FetchContext, Plugin } from \"@/types\";\nimport type { CSRFPluginOptions } from \"./types\";\nimport type { AuthulaClient } from \"@/client\";\n\nexport class CSRFPlugin implements Plugin {\n public readonly id = \"csrf\";\n\n constructor(private readonly options: CSRFPluginOptions) {}\n\n public init(client: AuthulaClient) {\n client.registerBeforeFetch(async (ctx: FetchContext) => {\n // Client-side\n if (typeof document !== \"undefined\") {\n if ([\"OPTIONS\", \"HEAD\", \"GET\"].includes(ctx.init.method || \"GET\")) {\n return;\n }\n\n const cookies = parse(document.cookie);\n const value = cookies[this.options.cookieName];\n\n if (!value) return;\n\n ctx.init.headers = new Headers(ctx.init.headers);\n ctx.init.headers.set(this.options.headerName, value);\n return;\n }\n\n // SSR\n if (this.cookies) {\n if ([\"OPTIONS\", \"HEAD\", \"GET\"].includes(ctx.init.method || \"GET\")) {\n return;\n }\n\n const store = await this.cookies();\n const cookie = store.get(this.options.cookieName);\n\n if (!cookie) return;\n\n ctx.init.headers = new Headers(ctx.init.headers);\n ctx.init.headers.set(this.options.headerName, cookie.value);\n }\n });\n\n return {};\n }\n\n // Injected by client\n private cookies?: () => Promise<any>;\n attachCookies(fn: () => Promise<any>) {\n this.cookies = fn;\n }\n}\n","import type { AuthulaClient } from \"@/client\";\nimport { wrappedFetch } from \"@/fetch\";\nimport type { Plugin } from \"@/types\";\nimport type {\n ChangePasswordRequest,\n RequestEmailChangeRequest,\n RequestPasswordResetRequest,\n SendEmailVerificationRequest,\n SignInRequest,\n SignUpRequest,\n} from \"./types\";\n\nexport class EmailPasswordPlugin implements Plugin {\n public readonly id = \"emailPassword\";\n\n public init(client: AuthulaClient) {\n return {\n signUp: async <T>(data: SignUpRequest): Promise<T> => {\n return wrappedFetch<T>(client, \"/sign-up\", {\n method: \"POST\",\n body: data,\n });\n },\n signIn: async <T>(data: SignInRequest): Promise<T> => {\n return wrappedFetch<T>(client, \"/sign-in\", {\n method: \"POST\",\n body: data,\n });\n },\n sendEmailVerification: async (\n data: SendEmailVerificationRequest,\n ): Promise<void> => {\n return wrappedFetch(client, `/send-email-verification`, {\n method: \"POST\",\n body: data,\n });\n },\n requestPasswordReset: async (\n data: RequestPasswordResetRequest,\n ): Promise<void> => {\n return wrappedFetch(client, `/request-password-reset`, {\n method: \"POST\",\n body: data,\n });\n },\n changePassword: async (data: ChangePasswordRequest): Promise<void> => {\n return wrappedFetch(client, `/change-password`, {\n method: \"POST\",\n body: data,\n });\n },\n requestEmailChange: async (\n data: RequestEmailChangeRequest,\n ): Promise<void> => {\n return wrappedFetch(client, `/request-email-change`, {\n method: \"POST\",\n body: data,\n });\n },\n };\n }\n}\n","import type { AuthulaClient } from \"@/client\";\nimport { wrappedFetch } from \"@/fetch\";\nimport type { Plugin } from \"@/types\";\nimport type {\n JWKSKey,\n TokenRefreshRequest,\n TokenRefreshResponse,\n} from \"./types\";\n\nexport class JWTPlugin implements Plugin {\n public readonly id = \"jwt\";\n\n constructor() {}\n\n public init(client: AuthulaClient) {\n return {\n refreshToken: async (\n data: TokenRefreshRequest,\n ): Promise<TokenRefreshResponse> => {\n return wrappedFetch(client, \"/token/refresh\", {\n method: \"POST\",\n body: data,\n });\n },\n getJWKSKeys: async (): Promise<Array<JWKSKey>> => {\n return wrappedFetch(client, \"/.well-known/jwks.json\", {\n method: \"GET\",\n });\n },\n };\n }\n}\n","import type { AuthulaClient } from \"@/client\";\nimport { wrappedFetch } from \"@/fetch\";\nimport type { Plugin } from \"@/types\";\nimport type {\n MagicLinkSignInRequest,\n MagicLinkSignInResponse,\n MagicLinkExchangeRequest,\n MagicLinkVerifyRequest,\n MagicLinkVerifyResponse,\n} from \"./types\";\n\nexport class MagicLinkPlugin implements Plugin {\n public readonly id = \"magicLink\";\n\n constructor() {}\n\n public init(client: AuthulaClient) {\n return {\n signIn: async (\n data: MagicLinkSignInRequest,\n ): Promise<MagicLinkSignInResponse> => {\n return wrappedFetch(client, \"/magic-link/sign-in\", {\n method: \"POST\",\n body: data,\n });\n },\n verify: async (\n data: MagicLinkVerifyRequest,\n ): Promise<MagicLinkVerifyResponse> => {\n const searchParams = new URLSearchParams();\n searchParams.append(\"token\", data.token);\n if (data.callbackUrl) {\n searchParams.append(\"callback_url\", data.callbackUrl);\n }\n return wrappedFetch(\n client,\n `/magic-link/verify?${searchParams.toString()}`,\n {\n method: \"GET\",\n },\n );\n },\n exchange: async <T>(data: MagicLinkExchangeRequest): Promise<T> => {\n return wrappedFetch(client, \"/magic-link/exchange\", {\n method: \"POST\",\n body: data,\n });\n },\n };\n }\n}\n","import type { AuthulaClient } from \"@/client\";\nimport { wrappedFetch } from \"@/fetch\";\nimport type { Plugin } from \"@/types/plugins\";\nimport type {\n SignInWithOAuth2Request,\n SignInWithOAuth2Response,\n} from \"./types\";\n\nexport class OAuth2Plugin implements Plugin {\n public readonly id = \"oauth2\";\n\n public init(client: AuthulaClient) {\n return {\n signIn: async (\n data: SignInWithOAuth2Request,\n ): Promise<SignInWithOAuth2Response>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