authula 0.3.1 → 0.3.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/README.md CHANGED
@@ -143,7 +143,7 @@ const authulaClient = createClient({
143
143
 
144
144
  ```typescript
145
145
  // Create a new role
146
- await authulaClient.accessControl.createRole({
146
+ const createdRole = await authulaClient.accessControl.createRole({
147
147
  name: "Admin",
148
148
  description: "Administrator role",
149
149
  isSystem: false,
@@ -152,24 +152,27 @@ await authulaClient.accessControl.createRole({
152
152
  // Get all roles
153
153
  const allRoles = await authulaClient.accessControl.getAllRoles();
154
154
 
155
+ // Look up a role by name
156
+ const roleByName = await authulaClient.accessControl.getRoleByName("Admin");
157
+
155
158
  // Get a specific role
156
- const role = await authulaClient.accessControl.getRoleById("role-id");
159
+ const roleDetails = await authulaClient.accessControl.getRoleById("role-id");
157
160
 
158
161
  // Update a role
159
- await authulaClient.accessControl.updateRole("role-id", {
162
+ const updatedRole = await authulaClient.accessControl.updateRole("role-id", {
160
163
  name: "Updated name",
161
164
  description: "Updated description",
162
165
  });
163
166
 
164
167
  // Delete a role
165
- await authulaClient.accessControl.deleteRole("role-id");
168
+ const deleteRoleResult = await authulaClient.accessControl.deleteRole("role-id");
166
169
  ```
167
170
 
168
171
  #### Permission Management
169
172
 
170
173
  ```typescript
171
174
  // Create a new permission
172
- await authulaClient.accessControl.createPermission({
175
+ const createdPermission = await authulaClient.accessControl.createPermission({
173
176
  key: "users.create",
174
177
  description: "Create new users",
175
178
  isSystem: false,
@@ -178,20 +181,23 @@ await authulaClient.accessControl.createPermission({
178
181
  // Get all permissions
179
182
  const allPermissions = await authulaClient.accessControl.getAllPermissions();
180
183
 
184
+ // Get a specific permission
185
+ const permission = await authulaClient.accessControl.getPermissionById("permission-id");
186
+
181
187
  // Update a permission
182
- await authulaClient.accessControl.updatePermission("permission-id", {
188
+ const updatedPermission = await authulaClient.accessControl.updatePermission("permission-id", {
183
189
  description: "Updated permission description",
184
190
  });
185
191
 
186
192
  // Delete a permission
187
- await authulaClient.accessControl.deletePermission("permission-id");
193
+ const deletePermissionResult = await authulaClient.accessControl.deletePermission("permission-id");
188
194
  ```
189
195
 
190
196
  #### Role-Permission Management
191
197
 
192
198
  ```typescript
193
199
  // Add a permission to a role
194
- await authulaClient.accessControl.addRolePermission("role-id", {
200
+ const addPermissionResult = await authulaClient.accessControl.addRolePermission("role-id", {
195
201
  permissionId: "permission-id",
196
202
  });
197
203
 
@@ -201,12 +207,12 @@ const rolePermissions = await authulaClient.accessControl.getRolePermissions(
201
207
  );
202
208
 
203
209
  // Replace all permissions for a role
204
- await authulaClient.accessControl.replaceRolePermissions("role-id", {
210
+ const replaceRolePermissionsResult = await authulaClient.accessControl.replaceRolePermissions("role-id", {
205
211
  permissionIds: ["permission-id-1", "permission-id-2", "permission-id-3"],
206
212
  });
207
213
 
208
214
  // Remove a permission from a role
209
- await authulaClient.accessControl.removeRolePermission(
215
+ const removeRolePermissionResult = await authulaClient.accessControl.removeRolePermission(
210
216
  "role-id",
211
217
  "permission-id",
212
218
  );
@@ -219,25 +225,30 @@ await authulaClient.accessControl.removeRolePermission(
219
225
  const userRoles = await authulaClient.accessControl.getUserRoles("user-id");
220
226
 
221
227
  // Assign a role to a user
222
- await authulaClient.accessControl.assignUserRole("user-id", {
228
+ const assignUserRoleResult = await authulaClient.accessControl.assignUserRole("user-id", {
223
229
  roleId: "role-id",
224
230
  expiresAt: new Date("2025-12-31"), // Optional: role expiration date
225
231
  });
226
232
 
227
233
  // Replace all roles for a user
228
- await authulaClient.accessControl.replaceUserRoles("user-id", {
234
+ const replaceUserRolesResult = await authulaClient.accessControl.replaceUserRoles("user-id", {
229
235
  roleIds: ["role-id-1", "role-id-2"],
230
236
  });
231
237
 
232
238
  // Remove a role from a user
233
- await authulaClient.accessControl.removeUserRole("user-id", "role-id");
239
+ const removeUserRoleResult = await authulaClient.accessControl.removeUserRole("user-id", "role-id");
234
240
  ```
235
241
 
236
242
  #### User Permission Management
237
243
 
238
244
  ```typescript
239
245
  // Get all effective permissions for a user (from all assigned roles)
240
- const userPermissions = await authulaClient.accessControl.getUserEffectivePermissions("user-id");
246
+ const effectivePermissions = await authulaClient.accessControl.getUserPermissions("user-id");
247
+
248
+ // Check whether the user has all requested permissions
249
+ const permissionCheck = await authulaClient.accessControl.checkUserPermissions("user-id", {
250
+ permissionKeys: ["users.create", "users.update"],
251
+ });
241
252
  ```
242
253
 
243
254
  ---
@@ -174,6 +174,155 @@ const impersonationSchema = zod.z.object({
174
174
  updatedAt: zod.z.iso.datetime()
175
175
  });
176
176
 
177
+ //#endregion
178
+ //#region src/plugins/access-control/plugin.ts
179
+ var AccessControlPlugin = class {
180
+ id = "accessControl";
181
+ constructor() {}
182
+ init(client) {
183
+ return {
184
+ createRole: async (data) => {
185
+ return require_fetch.wrappedFetch(client, `/access-control/roles`, {
186
+ method: "POST",
187
+ body: data
188
+ });
189
+ },
190
+ getAllRoles: async () => {
191
+ return require_fetch.wrappedFetch(client, `/access-control/roles`, { method: "GET" });
192
+ },
193
+ getRoleByName: async (roleName) => {
194
+ return require_fetch.wrappedFetch(client, `/access-control/roles/by-name/${roleName}`, { method: "GET" });
195
+ },
196
+ getRoleById: async (roleId) => {
197
+ return require_fetch.wrappedFetch(client, `/access-control/roles/${roleId}`, { method: "GET" });
198
+ },
199
+ updateRole: async (roleId, data) => {
200
+ return require_fetch.wrappedFetch(client, `/access-control/roles/${roleId}`, {
201
+ method: "PATCH",
202
+ body: data
203
+ });
204
+ },
205
+ deleteRole: async (roleId) => {
206
+ return require_fetch.wrappedFetch(client, `/access-control/roles/${roleId}`, { method: "DELETE" });
207
+ },
208
+ createPermission: async (data) => {
209
+ return require_fetch.wrappedFetch(client, `/access-control/permissions`, {
210
+ method: "POST",
211
+ body: data
212
+ });
213
+ },
214
+ getAllPermissions: async () => {
215
+ return require_fetch.wrappedFetch(client, `/access-control/permissions`, { method: "GET" });
216
+ },
217
+ getPermissionById: async (permissionId) => {
218
+ return require_fetch.wrappedFetch(client, `/access-control/permissions/${permissionId}`, { method: "GET" });
219
+ },
220
+ updatePermission: async (permissionId, data) => {
221
+ return require_fetch.wrappedFetch(client, `/access-control/permissions/${permissionId}`, {
222
+ method: "PATCH",
223
+ body: data
224
+ });
225
+ },
226
+ deletePermission: async (permissionId) => {
227
+ return require_fetch.wrappedFetch(client, `/access-control/permissions/${permissionId}`, { method: "DELETE" });
228
+ },
229
+ addRolePermission: async (roleId, data) => {
230
+ return require_fetch.wrappedFetch(client, `/access-control/roles/${roleId}/permissions`, {
231
+ method: "POST",
232
+ body: data
233
+ });
234
+ },
235
+ getRolePermissions: async (roleId) => {
236
+ return require_fetch.wrappedFetch(client, `/access-control/roles/${roleId}/permissions`, { method: "GET" });
237
+ },
238
+ replaceRolePermissions: async (roleId, data) => {
239
+ return require_fetch.wrappedFetch(client, `/access-control/roles/${roleId}/permissions`, {
240
+ method: "PUT",
241
+ body: data
242
+ });
243
+ },
244
+ removeRolePermission: async (roleId, permissionId) => {
245
+ return require_fetch.wrappedFetch(client, `/access-control/roles/${roleId}/permissions/${permissionId}`, { method: "DELETE" });
246
+ },
247
+ getUserRoles: async (userId) => {
248
+ return require_fetch.wrappedFetch(client, `/access-control/users/${userId}/roles`, { method: "GET" });
249
+ },
250
+ assignUserRole: async (userId, data) => {
251
+ return require_fetch.wrappedFetch(client, `/access-control/users/${userId}/roles`, {
252
+ method: "POST",
253
+ body: data
254
+ });
255
+ },
256
+ replaceUserRoles: async (userId, data) => {
257
+ return require_fetch.wrappedFetch(client, `/access-control/users/${userId}/roles`, {
258
+ method: "PUT",
259
+ body: data
260
+ });
261
+ },
262
+ removeUserRole: async (userId, roleId) => {
263
+ return require_fetch.wrappedFetch(client, `/access-control/users/${userId}/roles/${roleId}`, { method: "DELETE" });
264
+ },
265
+ getUserPermissions: async (userId) => {
266
+ return require_fetch.wrappedFetch(client, `/access-control/users/${userId}/permissions`, { method: "GET" });
267
+ },
268
+ checkUserPermissions: async (userId, data) => {
269
+ return require_fetch.wrappedFetch(client, `/access-control/users/${userId}/permissions/check`, {
270
+ method: "POST",
271
+ body: data
272
+ });
273
+ }
274
+ };
275
+ }
276
+ };
277
+
278
+ //#endregion
279
+ //#region src/plugins/access-control/types.ts
280
+ const roleSchema = zod.z.object({
281
+ id: zod.z.string().nonempty(),
282
+ name: zod.z.string().nonempty(),
283
+ description: zod.z.string().nullish(),
284
+ weight: zod.z.number(),
285
+ isSystem: zod.z.boolean(),
286
+ createdAt: zod.z.iso.datetime(),
287
+ updatedAt: zod.z.iso.datetime()
288
+ });
289
+ const permissionSchema = zod.z.object({
290
+ id: zod.z.string().nonempty(),
291
+ key: zod.z.string().nonempty(),
292
+ description: zod.z.string().nullish(),
293
+ isSystem: zod.z.boolean(),
294
+ createdAt: zod.z.iso.datetime(),
295
+ updatedAt: zod.z.iso.datetime()
296
+ });
297
+ const permissionGrantSourceSchema = zod.z.object({
298
+ roleId: zod.z.string().nonempty(),
299
+ roleName: zod.z.string().nonempty(),
300
+ grantedByUserId: zod.z.string().nullish(),
301
+ grantedAt: zod.z.iso.datetime().nullish()
302
+ });
303
+ const userPermissionInfoSchema = zod.z.object({
304
+ permissionId: zod.z.string().nonempty(),
305
+ permissionKey: zod.z.string().nonempty(),
306
+ permissionDescription: zod.z.string().nullish(),
307
+ grantedByUserId: zod.z.string().nullish(),
308
+ grantedAt: zod.z.iso.datetime().nullish(),
309
+ sources: zod.z.array(permissionGrantSourceSchema).optional()
310
+ });
311
+ const userRoleInfoSchema = zod.z.object({
312
+ roleId: zod.z.string().nonempty(),
313
+ roleName: zod.z.string().nonempty(),
314
+ roleDescription: zod.z.string().nullish(),
315
+ assignedByUserId: zod.z.string().nullish(),
316
+ assignedAt: zod.z.iso.datetime().nullish(),
317
+ expiresAt: zod.z.iso.datetime().nullish()
318
+ });
319
+ const roleDetailsSchema = zod.z.object({
320
+ role: roleSchema,
321
+ permissions: zod.z.array(userPermissionInfoSchema)
322
+ });
323
+ const getUserPermissionsResponseSchema = zod.z.object({ permissions: zod.z.array(userPermissionInfoSchema) });
324
+ const checkUserPermissionsResponseSchema = zod.z.object({ hasPermissions: zod.z.boolean() });
325
+
177
326
  //#endregion
178
327
  //#region src/plugins/bearer/plugin.ts
179
328
  var BearerPlugin = class {
@@ -408,6 +557,7 @@ var TOTPPlugin = class {
408
557
  };
409
558
 
410
559
  //#endregion
560
+ exports.AccessControlPlugin = AccessControlPlugin;
411
561
  exports.AdminPlugin = AdminPlugin;
412
562
  exports.BearerPlugin = BearerPlugin;
413
563
  exports.CSRFPlugin = CSRFPlugin;
@@ -419,5 +569,13 @@ exports.TOTPPlugin = TOTPPlugin;
419
569
  exports.adminSessionStateSchema = adminSessionStateSchema;
420
570
  exports.adminUserSessionSchema = adminUserSessionSchema;
421
571
  exports.adminUserStateSchema = adminUserStateSchema;
572
+ exports.checkUserPermissionsResponseSchema = checkUserPermissionsResponseSchema;
573
+ exports.getUserPermissionsResponseSchema = getUserPermissionsResponseSchema;
422
574
  exports.impersonationSchema = impersonationSchema;
575
+ exports.permissionGrantSourceSchema = permissionGrantSourceSchema;
576
+ exports.permissionSchema = permissionSchema;
577
+ exports.roleDetailsSchema = roleDetailsSchema;
578
+ exports.roleSchema = roleSchema;
579
+ exports.userPermissionInfoSchema = userPermissionInfoSchema;
580
+ exports.userRoleInfoSchema = userRoleInfoSchema;
423
581
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","names":["wrappedFetch","z","sessionSchema","cookie","wrappedFetch","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","../../src/plugins/totp/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> => {\n return wrappedFetch(\n client,\n `/oauth2/authorize/${data.provider}?redirect_to=${data.redirectTo}`,\n {\n method: \"GET\",\n },\n );\n },\n };\n }\n}\n","import type { AuthulaClient } from \"@/client\";\nimport { wrappedFetch } from \"@/fetch\";\nimport type { Plugin } from \"@/types/plugins\";\nimport type {\n DisableResponse,\n EnableResponse,\n GenerateBackupCodesResponse,\n GetTOTPURIResponse,\n VerifyBackupCodeRequest,\n VerifyBackupCodeResponse,\n VerifyTOTPRequest,\n VerifyTOTPResponse,\n} from \"./types\";\n\nexport class TOTPPlugin implements Plugin {\n public readonly id = \"totp\";\n\n public init(client: AuthulaClient) {\n return {\n enable: async (): Promise<EnableResponse> => {\n return wrappedFetch(client, \"/totp/enable\", {\n method: \"POST\",\n });\n },\n disable: async (): Promise<DisableResponse> => {\n return wrappedFetch(client, \"/totp/disable\", {\n method: \"POST\",\n });\n },\n getUri: async (): Promise<GetTOTPURIResponse> => {\n return wrappedFetch(client, \"/totp/get-uri\", {\n method: \"GET\",\n });\n },\n verify: async (data: VerifyTOTPRequest): Promise<VerifyTOTPResponse> => {\n return wrappedFetch(client, \"/totp/verify\", {\n method: \"POST\",\n body: data,\n });\n },\n verifyBackupCode: async (\n data: VerifyBackupCodeRequest,\n ): Promise<VerifyBackupCodeResponse> => {\n return wrappedFetch(client, \"/totp/verify-backup-code\", {\n method: \"POST\",\n body: data,\n });\n },\n generateBackupCodes: async (): Promise<GenerateBackupCodesResponse> => {\n return wrappedFetch(client, \"/totp/generate-backup-codes\", {\n method: \"POST\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Q;KACR,MAAM;KACP,CAAC;;GAEJ,qBAAqB,YAAkD;AACrE,WAAOA,2BAAa,QAAQ,+BAA+B,EACzD,QAAQ,QACT,CAAC;;GAEL"}
1
+ {"version":3,"file":"index.cjs","names":["wrappedFetch","z","sessionSchema","wrappedFetch","z","cookie","wrappedFetch","wrappedFetch","wrappedFetch","wrappedFetch","wrappedFetch"],"sources":["../../src/plugins/admin/plugin.ts","../../src/plugins/admin/types.ts","../../src/plugins/access-control/plugin.ts","../../src/plugins/access-control/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","../../src/plugins/totp/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 { AuthulaClient } from \"@/client\";\nimport { wrappedFetch } from \"@/fetch\";\nimport type { Plugin } from \"@/types\";\nimport type {\n AddRolePermissionRequest,\n AddRolePermissionResponse,\n AssignUserRoleRequest,\n AssignUserRoleResponse,\n CheckUserPermissionsRequest,\n CheckUserPermissionsResponse,\n CreatePermissionRequest,\n CreatePermissionResponse,\n CreateRoleRequest,\n CreateRoleResponse,\n DeletePermissionResponse,\n DeleteRoleResponse,\n GetUserPermissionsResponse,\n RoleDetails,\n Permission,\n UserPermissionInfo,\n UserRoleInfo,\n RemoveRolePermissionResponse,\n RemoveUserRoleResponse,\n ReplaceRolePermissionResponse,\n ReplaceRolePermissionsRequest,\n ReplaceUserRolesRequest,\n ReplaceUserRolesResponse,\n Role,\n UpdatePermissionRequest,\n UpdatePermissionResponse,\n UpdateRoleRequest,\n UpdateRoleResponse,\n} from \"./types\";\n\nexport class AccessControlPlugin implements Plugin {\n public readonly id = \"accessControl\";\n\n constructor() {}\n\n public init(client: AuthulaClient) {\n return {\n // Roles\n createRole: async (\n data: CreateRoleRequest,\n ): Promise<CreateRoleResponse> => {\n return wrappedFetch(client, `/access-control/roles`, {\n method: \"POST\",\n body: data,\n });\n },\n getAllRoles: async (): Promise<Role[]> => {\n return wrappedFetch(client, `/access-control/roles`, {\n method: \"GET\",\n });\n },\n getRoleByName: async (roleName: string): Promise<Role> => {\n return wrappedFetch(\n client,\n `/access-control/roles/by-name/${roleName}`,\n {\n method: \"GET\",\n },\n );\n },\n getRoleById: async (roleId: string): Promise<RoleDetails> => {\n return wrappedFetch(client, `/access-control/roles/${roleId}`, {\n method: \"GET\",\n });\n },\n updateRole: async (\n roleId: string,\n data: UpdateRoleRequest,\n ): Promise<UpdateRoleResponse> => {\n return wrappedFetch(client, `/access-control/roles/${roleId}`, {\n method: \"PATCH\",\n body: data,\n });\n },\n deleteRole: async (roleId: string): Promise<DeleteRoleResponse> => {\n return wrappedFetch(client, `/access-control/roles/${roleId}`, {\n method: \"DELETE\",\n });\n },\n\n // Permissions\n createPermission: async (\n data: CreatePermissionRequest,\n ): Promise<CreatePermissionResponse> => {\n return wrappedFetch(client, `/access-control/permissions`, {\n method: \"POST\",\n body: data,\n });\n },\n getAllPermissions: async (): Promise<Permission[]> => {\n return wrappedFetch(client, `/access-control/permissions`, {\n method: \"GET\",\n });\n },\n getPermissionById: async (permissionId: string): Promise<Permission> => {\n return wrappedFetch(\n client,\n `/access-control/permissions/${permissionId}`,\n {\n method: \"GET\",\n },\n );\n },\n updatePermission: async (\n permissionId: string,\n data: UpdatePermissionRequest,\n ): Promise<UpdatePermissionResponse> => {\n return wrappedFetch(\n client,\n `/access-control/permissions/${permissionId}`,\n {\n method: \"PATCH\",\n body: data,\n },\n );\n },\n deletePermission: async (\n permissionId: string,\n ): Promise<DeletePermissionResponse> => {\n return wrappedFetch(\n client,\n `/access-control/permissions/${permissionId}`,\n {\n method: \"DELETE\",\n },\n );\n },\n\n // Role Permissions\n addRolePermission: async (\n roleId: string,\n data: AddRolePermissionRequest,\n ): Promise<AddRolePermissionResponse> => {\n return wrappedFetch(\n client,\n `/access-control/roles/${roleId}/permissions`,\n {\n method: \"POST\",\n body: data,\n },\n );\n },\n getRolePermissions: async (\n roleId: string,\n ): Promise<UserPermissionInfo[]> => {\n return wrappedFetch(\n client,\n `/access-control/roles/${roleId}/permissions`,\n {\n method: \"GET\",\n },\n );\n },\n replaceRolePermissions: async (\n roleId: string,\n data: ReplaceRolePermissionsRequest,\n ): Promise<ReplaceRolePermissionResponse> => {\n return wrappedFetch(\n client,\n `/access-control/roles/${roleId}/permissions`,\n {\n method: \"PUT\",\n body: data,\n },\n );\n },\n removeRolePermission: async (\n roleId: string,\n permissionId: string,\n ): Promise<RemoveRolePermissionResponse> => {\n return wrappedFetch(\n client,\n `/access-control/roles/${roleId}/permissions/${permissionId}`,\n {\n method: \"DELETE\",\n },\n );\n },\n\n // User Roles\n getUserRoles: async (userId: string): Promise<UserRoleInfo[]> => {\n return wrappedFetch(client, `/access-control/users/${userId}/roles`, {\n method: \"GET\",\n });\n },\n assignUserRole: async (\n userId: string,\n data: AssignUserRoleRequest,\n ): Promise<AssignUserRoleResponse> => {\n return wrappedFetch(client, `/access-control/users/${userId}/roles`, {\n method: \"POST\",\n body: data,\n });\n },\n replaceUserRoles: async (\n userId: string,\n data: ReplaceUserRolesRequest,\n ): Promise<ReplaceUserRolesResponse> => {\n return wrappedFetch(client, `/access-control/users/${userId}/roles`, {\n method: \"PUT\",\n body: data,\n });\n },\n removeUserRole: async (\n userId: string,\n roleId: string,\n ): Promise<RemoveUserRoleResponse> => {\n return wrappedFetch(\n client,\n `/access-control/users/${userId}/roles/${roleId}`,\n {\n method: \"DELETE\",\n },\n );\n },\n\n // User Permissions\n getUserPermissions: async (\n userId: string,\n ): Promise<GetUserPermissionsResponse> => {\n return wrappedFetch(\n client,\n `/access-control/users/${userId}/permissions`,\n {\n method: \"GET\",\n },\n );\n },\n checkUserPermissions: async (\n userId: string,\n data: CheckUserPermissionsRequest,\n ): Promise<CheckUserPermissionsResponse> => {\n return wrappedFetch(\n client,\n `/access-control/users/${userId}/permissions/check`,\n {\n method: \"POST\",\n body: data,\n },\n );\n },\n };\n }\n}\n","import { z } from \"zod\";\n\nimport type { User } from \"@/types\";\n\nexport const roleSchema = z.object({\n id: z.string().nonempty(),\n name: z.string().nonempty(),\n description: z.string().nullish(),\n weight: z.number(),\n isSystem: z.boolean(),\n createdAt: z.iso.datetime(),\n updatedAt: z.iso.datetime(),\n});\nexport type Role = z.infer<typeof roleSchema>;\n\nexport const permissionSchema = z.object({\n id: z.string().nonempty(),\n key: z.string().nonempty(),\n description: z.string().nullish(),\n isSystem: z.boolean(),\n createdAt: z.iso.datetime(),\n updatedAt: z.iso.datetime(),\n});\nexport type Permission = z.infer<typeof permissionSchema>;\n\nexport const permissionGrantSourceSchema = z.object({\n roleId: z.string().nonempty(),\n roleName: z.string().nonempty(),\n grantedByUserId: z.string().nullish(),\n grantedAt: z.iso.datetime().nullish(),\n});\nexport type PermissionGrantSource = z.infer<typeof permissionGrantSourceSchema>;\n\nexport const userPermissionInfoSchema = z.object({\n permissionId: z.string().nonempty(),\n permissionKey: z.string().nonempty(),\n permissionDescription: z.string().nullish(),\n grantedByUserId: z.string().nullish(),\n grantedAt: z.iso.datetime().nullish(),\n sources: z.array(permissionGrantSourceSchema).optional(),\n});\nexport type UserPermissionInfo = z.infer<typeof userPermissionInfoSchema>;\n\nexport const userRoleInfoSchema = z.object({\n roleId: z.string().nonempty(),\n roleName: z.string().nonempty(),\n roleDescription: z.string().nullish(),\n assignedByUserId: z.string().nullish(),\n assignedAt: z.iso.datetime().nullish(),\n expiresAt: z.iso.datetime().nullish(),\n});\nexport type UserRoleInfo = z.infer<typeof userRoleInfoSchema>;\n\nexport const roleDetailsSchema = z.object({\n role: roleSchema,\n permissions: z.array(userPermissionInfoSchema),\n});\nexport type RoleDetails = z.infer<typeof roleDetailsSchema>;\n\nexport const getUserPermissionsResponseSchema = z.object({\n permissions: z.array(userPermissionInfoSchema),\n});\nexport type GetUserPermissionsResponse = z.infer<\n typeof getUserPermissionsResponseSchema\n>;\n\nexport const checkUserPermissionsResponseSchema = z.object({\n hasPermissions: z.boolean(),\n});\nexport type CheckUserPermissionsResponse = z.infer<\n typeof checkUserPermissionsResponseSchema\n>;\n\nexport type CreateRoleRequest = {\n name: string;\n description?: string | null;\n weight?: number;\n isSystem: boolean;\n};\n\nexport type CreateRoleResponse = {\n role: Role;\n};\n\nexport type UpdateRoleRequest = {\n name?: string | null;\n description?: string | null;\n weight?: number;\n};\n\nexport type UpdateRoleResponse = {\n role: Role;\n};\n\nexport type DeleteRoleResponse = {\n message: string;\n};\n\nexport type CreatePermissionRequest = {\n key: string;\n description?: string | null;\n isSystem: boolean;\n};\n\nexport type CreatePermissionResponse = {\n permission: Permission;\n};\n\nexport type UpdatePermissionRequest = {\n description?: string | null;\n};\n\nexport type UpdatePermissionResponse = {\n permission: Permission;\n};\n\nexport type DeletePermissionResponse = {\n message: string;\n};\n\nexport type AddRolePermissionRequest = {\n permissionId: string;\n};\n\nexport type AddRolePermissionResponse = {\n message: string;\n};\n\nexport type ReplaceRolePermissionsRequest = {\n permissionIds: string[];\n};\n\nexport type ReplaceRolePermissionResponse = {\n message: string;\n};\n\nexport type RemoveRolePermissionResponse = {\n message: string;\n};\n\nexport type AssignUserRoleRequest = {\n roleId: string;\n expiresAt?: string | null;\n};\n\nexport type ReplaceUserRolesRequest = {\n roleIds: string[];\n};\n\nexport type ReplaceUserRolesResponse = {\n message: string;\n};\n\nexport type AssignUserRoleResponse = {\n message: string;\n};\n\nexport type RemoveUserRoleResponse = {\n message: string;\n};\n\nexport type CheckUserPermissionsRequest = {\n permissionKeys: string[];\n};\n\nexport type UserWithPermissions = {\n user: User;\n permissions: UserPermissionInfo[];\n};\n\nexport type UserAuthorizationProfile = {\n user: User;\n roles: UserRoleInfo[];\n permissions: UserPermissionInfo[];\n};\n\nexport type UserWithRoles = {\n user: User;\n roles: UserRoleInfo[];\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> => {\n return wrappedFetch(\n client,\n `/oauth2/authorize/${data.provider}?redirect_to=${data.redirectTo}`,\n {\n method: \"GET\",\n },\n );\n },\n };\n }\n}\n","import type { AuthulaClient } from \"@/client\";\nimport { wrappedFetch } from \"@/fetch\";\nimport type { Plugin } from \"@/types/plugins\";\nimport type {\n DisableResponse,\n EnableResponse,\n GenerateBackupCodesResponse,\n GetTOTPURIResponse,\n VerifyBackupCodeRequest,\n VerifyBackupCodeResponse,\n VerifyTOTPRequest,\n VerifyTOTPResponse,\n} from \"./types\";\n\nexport class TOTPPlugin implements Plugin {\n public readonly id = \"totp\";\n\n public init(client: AuthulaClient) {\n return {\n enable: async (): Promise<EnableResponse> => {\n return wrappedFetch(client, \"/totp/enable\", {\n method: \"POST\",\n });\n },\n disable: async (): Promise<DisableResponse> => {\n return wrappedFetch(client, \"/totp/disable\", {\n method: \"POST\",\n });\n },\n getUri: async (): Promise<GetTOTPURIResponse> => {\n return wrappedFetch(client, \"/totp/get-uri\", {\n method: \"GET\",\n });\n },\n verify: async (data: VerifyTOTPRequest): Promise<VerifyTOTPResponse> => {\n return wrappedFetch(client, \"/totp/verify\", {\n method: \"POST\",\n body: data,\n });\n },\n verifyBackupCode: async (\n data: VerifyBackupCodeRequest,\n ): Promise<VerifyBackupCodeResponse> => {\n return wrappedFetch(client, \"/totp/verify-backup-code\", {\n method: \"POST\",\n body: data,\n });\n },\n generateBackupCodes: async (): Promise<GenerateBackupCodesResponse> => {\n return wrappedFetch(client, \"/totp/generate-backup-codes\", {\n method: \"POST\",\n });\n },\n };\n }\n}\n"],"mappings":";;;;;;AA6CA,IAAa,cAAb,MAA2C;CACzC,AAAgB,KAAK;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