authula 0.2.0 → 0.3.1
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 +48 -0
- package/dist/plugins/index.cjs +35 -0
- package/dist/plugins/index.cjs.map +1 -1
- package/dist/plugins/index.d.cts +46 -2
- package/dist/plugins/index.d.ts +46 -2
- package/dist/plugins/index.js +35 -1
- package/dist/plugins/index.js.map +1 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -7,6 +7,13 @@
|
|
|
7
7
|
This Node.js SDK provides seamless integration with an Authula server for both client-side and server-side applications and is framework agnostic.
|
|
8
8
|
</p>
|
|
9
9
|
|
|
10
|
+
|
|
11
|
+
<div align="center">
|
|
12
|
+
<a href="https://www.npmjs.com/package/authula" target="_parent">
|
|
13
|
+
<img src="https://img.shields.io/npm/dm/authula.svg" alt="Node.js SDK downloads" />
|
|
14
|
+
</a>
|
|
15
|
+
</div>
|
|
16
|
+
|
|
10
17
|
---
|
|
11
18
|
|
|
12
19
|
## Features
|
|
@@ -537,6 +544,47 @@ await authulaClient.magicLink.exchange({
|
|
|
537
544
|
});
|
|
538
545
|
```
|
|
539
546
|
|
|
547
|
+
---
|
|
548
|
+
|
|
549
|
+
### TOTP Plugin
|
|
550
|
+
|
|
551
|
+
Provides time-based one-time password (TOTP) two-factor authentication flows.
|
|
552
|
+
|
|
553
|
+
```typescript
|
|
554
|
+
import { TOTPPlugin } from "authula/plugins";
|
|
555
|
+
|
|
556
|
+
const authulaClient = createClient({
|
|
557
|
+
url: "http://localhost:8080/auth",
|
|
558
|
+
plugins: [new TOTPPlugin()],
|
|
559
|
+
});
|
|
560
|
+
|
|
561
|
+
// Enable TOTP for the current user
|
|
562
|
+
await authulaClient.totp.enable();
|
|
563
|
+
|
|
564
|
+
// Disable TOTP for the current user
|
|
565
|
+
await authulaClient.totp.disable();
|
|
566
|
+
|
|
567
|
+
// Get the TOTP URI for QR code generation
|
|
568
|
+
await authulaClient.totp.getUri();
|
|
569
|
+
|
|
570
|
+
// Verify a TOTP code
|
|
571
|
+
await authulaClient.totp.verify({
|
|
572
|
+
code: "123456",
|
|
573
|
+
trustDevice: true,
|
|
574
|
+
});
|
|
575
|
+
|
|
576
|
+
// Verify a backup code
|
|
577
|
+
await authulaClient.totp.verifyBackupCode({
|
|
578
|
+
code: "AbcXyz",
|
|
579
|
+
trustDevice: true,
|
|
580
|
+
});
|
|
581
|
+
|
|
582
|
+
// Generate fresh backup codes
|
|
583
|
+
await authulaClient.totp.generateBackupCodes();
|
|
584
|
+
```
|
|
585
|
+
|
|
586
|
+
---
|
|
587
|
+
|
|
540
588
|
## Advanced Configuration
|
|
541
589
|
|
|
542
590
|
### Fetch Options
|
package/dist/plugins/index.cjs
CHANGED
|
@@ -373,6 +373,40 @@ var OAuth2Plugin = class {
|
|
|
373
373
|
}
|
|
374
374
|
};
|
|
375
375
|
|
|
376
|
+
//#endregion
|
|
377
|
+
//#region src/plugins/totp/plugin.ts
|
|
378
|
+
var TOTPPlugin = class {
|
|
379
|
+
id = "totp";
|
|
380
|
+
init(client) {
|
|
381
|
+
return {
|
|
382
|
+
enable: async () => {
|
|
383
|
+
return require_fetch.wrappedFetch(client, "/totp/enable", { method: "POST" });
|
|
384
|
+
},
|
|
385
|
+
disable: async () => {
|
|
386
|
+
return require_fetch.wrappedFetch(client, "/totp/disable", { method: "POST" });
|
|
387
|
+
},
|
|
388
|
+
getUri: async () => {
|
|
389
|
+
return require_fetch.wrappedFetch(client, "/totp/get-uri", { method: "GET" });
|
|
390
|
+
},
|
|
391
|
+
verify: async (data) => {
|
|
392
|
+
return require_fetch.wrappedFetch(client, "/totp/verify", {
|
|
393
|
+
method: "POST",
|
|
394
|
+
body: data
|
|
395
|
+
});
|
|
396
|
+
},
|
|
397
|
+
verifyBackupCode: async (data) => {
|
|
398
|
+
return require_fetch.wrappedFetch(client, "/totp/verify-backup-code", {
|
|
399
|
+
method: "POST",
|
|
400
|
+
body: data
|
|
401
|
+
});
|
|
402
|
+
},
|
|
403
|
+
generateBackupCodes: async () => {
|
|
404
|
+
return require_fetch.wrappedFetch(client, "/totp/generate-backup-codes", { method: "POST" });
|
|
405
|
+
}
|
|
406
|
+
};
|
|
407
|
+
}
|
|
408
|
+
};
|
|
409
|
+
|
|
376
410
|
//#endregion
|
|
377
411
|
exports.AdminPlugin = AdminPlugin;
|
|
378
412
|
exports.BearerPlugin = BearerPlugin;
|
|
@@ -381,6 +415,7 @@ exports.EmailPasswordPlugin = EmailPasswordPlugin;
|
|
|
381
415
|
exports.JWTPlugin = JWTPlugin;
|
|
382
416
|
exports.MagicLinkPlugin = MagicLinkPlugin;
|
|
383
417
|
exports.OAuth2Plugin = OAuth2Plugin;
|
|
418
|
+
exports.TOTPPlugin = TOTPPlugin;
|
|
384
419
|
exports.adminSessionStateSchema = adminSessionStateSchema;
|
|
385
420
|
exports.adminUserSessionSchema = adminUserSessionSchema;
|
|
386
421
|
exports.adminUserStateSchema = adminUserStateSchema;
|
|
@@ -1 +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> => {\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"],"mappings":";;;;;;AA6CA,IAAa,cAAb,MAA2C;CACzC,AAAgB,KAAK;CAErB,cAAc;CAEd,AAAO,KAAK,QAAuB;AACjC,SAAO;GAGL,YAAY,OACV,SACgC;AAChC,WAAOA,2BAAa,QAAQ,gBAAgB;KAC1C,QAAQ;KACR,MAAM;KACP,CAAC;;GAEJ,aAAa,OAAO,UAAiD;IACnE,MAAM,kBAAkB,IAAI,iBAAiB;AAC7C,QAAI,MACF,iBAAgB,OAAO,SAAS,MAAM,UAAU,CAAC;AAKnD,WAAOA,2BAAa,QAAQ,eAHb,gBAAgB,UAAU,GACrC,IAAI,gBAAgB,UAAU,KAC9B,MACiD,EACnD,QAAQ,OACT,CAAC;;GAEJ,aAAa,OAAO,WAAiD;AACnE,WAAOA,2BAAa,QAAQ,gBAAgB,UAAU,EACpD,QAAQ,OACT,CAAC;;GAEJ,YAAY,OACV,QACA,SACgC;AAChC,WAAOA,2BAAa,QAAQ,gBAAgB,UAAU;KACpD,QAAQ;KACR,MAAM;KACP,CAAC;;GAEJ,YAAY,OAAO,WAAgD;AACjE,WAAOA,2BAAa,QAAQ,gBAAgB,UAAU,EACpD,QAAQ,UACT,CAAC;;GAKJ,eAAe,OACb,QACA,SACmC;AACnC,WAAOA,2BAAa,QAAQ,gBAAgB,OAAO,YAAY;KAC7D,QAAQ;KACR,MAAM;KACP,CAAC;;GAEJ,iBAAiB,OACf,WACqC;AACrC,WAAOA,2BAAa,QAAQ,gBAAgB,OAAO,YAAY,EAC7D,QAAQ,OACT,CAAC;;GAEJ,gBAAgB,OAAO,OAAgD;AACrE,WAAOA,2BAAa,QAAQ,mBAAmB,MAAM,EACnD,QAAQ,OACT,CAAC;;GAEJ,eAAe,OACb,IACA,SACmC;AACnC,WAAOA,2BAAa,QAAQ,mBAAmB,MAAM;K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a,YAAqC;AAChD,WAAOA,2BAAa,QAAQ,0BAA0B,EACpD,QAAQ,OACT,CAAC;;GAEL;;;;;;AClBL,IAAa,kBAAb,MAA+C;CAC7C,AAAgB,KAAK;CAErB,cAAc;CAEd,AAAO,KAAK,QAAuB;AACjC,SAAO;GACL,QAAQ,OACN,SACqC;AACrC,WAAOC,2BAAa,QAAQ,uBAAuB;KACjD,QAAQ;KACR,MAAM;KACP,CAAC;;GAEJ,QAAQ,OACN,SACqC;IACrC,MAAM,eAAe,IAAI,iBAAiB;AAC1C,iBAAa,OAAO,SAAS,KAAK,MAAM;AACxC,QAAI,KAAK,YACP,cAAa,OAAO,gBAAgB,KAAK,YAAY;AAEvD,WAAOA,2BACL,QACA,sBAAsB,aAAa,UAAU,IAC7C,EACE,QAAQ,OACT,CACF;;GAEH,UAAU,OAAU,SAA+C;AACjE,WAAOA,2BAAa,QAAQ,wBAAwB;KAClD,QAAQ;KACR,MAAM;KACP,CAAC;;GAEL;;;;;;ACxCL,IAAa,eAAb,MAA4C;CAC1C,AAAgB,KAAK;CAErB,AAAO,KAAK,QAAuB;AACjC,SAAO,EACL,QAAQ,OACN,SACsC;AACtC,UAAOC,2BACL,QACA,qBAAqB,KAAK,SAAS,eAAe,KAAK,cACvD,EACE,QAAQ,OACT,CACF;KAEJ"}
|
|
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\",\n });\n },\n };\n }\n}\n"],"mappings":";;;;;;AA6CA,IAAa,cAAb,MAA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A,2BAAa,QAAQ,+BAA+B,EACzD,QAAQ,QACT,CAAC;;GAEL"}
|
package/dist/plugins/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { h as User, l as Plugin, p as Account, t as ClientWithPlugins, u as AuthulaClient } from "../sdk-DV73pbRH.cjs";
|
|
1
|
+
import { h as User, l as Plugin, m as Session, p as Account, t as ClientWithPlugins, u as AuthulaClient } from "../sdk-DV73pbRH.cjs";
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
|
|
4
4
|
//#region src/plugins/admin/types.d.ts
|
|
@@ -413,5 +413,49 @@ declare class OAuth2Plugin implements Plugin {
|
|
|
413
413
|
};
|
|
414
414
|
}
|
|
415
415
|
//#endregion
|
|
416
|
-
|
|
416
|
+
//#region src/plugins/totp/types.d.ts
|
|
417
|
+
type EnableResponse = {
|
|
418
|
+
totpUri: string;
|
|
419
|
+
backupCodes: string[];
|
|
420
|
+
};
|
|
421
|
+
type DisableResponse = {
|
|
422
|
+
message: string;
|
|
423
|
+
};
|
|
424
|
+
type GetTOTPURIResponse = {
|
|
425
|
+
totpUri: string;
|
|
426
|
+
};
|
|
427
|
+
type VerifyTOTPRequest = {
|
|
428
|
+
code: string;
|
|
429
|
+
trustDevice?: boolean;
|
|
430
|
+
};
|
|
431
|
+
type VerifyTOTPResponse = {
|
|
432
|
+
user: User;
|
|
433
|
+
session: Session;
|
|
434
|
+
};
|
|
435
|
+
type VerifyBackupCodeRequest = {
|
|
436
|
+
code: string;
|
|
437
|
+
trustDevice?: boolean;
|
|
438
|
+
};
|
|
439
|
+
type VerifyBackupCodeResponse = {
|
|
440
|
+
user: User;
|
|
441
|
+
session: Session;
|
|
442
|
+
};
|
|
443
|
+
type GenerateBackupCodesResponse = {
|
|
444
|
+
backupCodes: string[];
|
|
445
|
+
};
|
|
446
|
+
//#endregion
|
|
447
|
+
//#region src/plugins/totp/plugin.d.ts
|
|
448
|
+
declare class TOTPPlugin implements Plugin {
|
|
449
|
+
readonly id = "totp";
|
|
450
|
+
init(client: AuthulaClient): {
|
|
451
|
+
enable: () => Promise<EnableResponse>;
|
|
452
|
+
disable: () => Promise<DisableResponse>;
|
|
453
|
+
getUri: () => Promise<GetTOTPURIResponse>;
|
|
454
|
+
verify: (data: VerifyTOTPRequest) => Promise<VerifyTOTPResponse>;
|
|
455
|
+
verifyBackupCode: (data: VerifyBackupCodeRequest) => Promise<VerifyBackupCodeResponse>;
|
|
456
|
+
generateBackupCodes: () => Promise<GenerateBackupCodesResponse>;
|
|
457
|
+
};
|
|
458
|
+
}
|
|
459
|
+
//#endregion
|
|
460
|
+
export { AdminPlugin, AdminSessionState, AdminUserSession, AdminUserState, BanUserRequest, BanUserResponse, BearerPlugin, BearerPluginOptions, CSRFPlugin, CSRFPluginOptions, ChangePasswordRequest, CreateAccountRequest, CreateAccountResponse, CreateSessionStateRequest, CreateSessionStateResponse, CreateUserRequest, CreateUserResponse, CreateUserStateRequest, CreateUserStateResponse, DeleteAccountResponse, DeleteSessionStateResponse, DeleteUserResponse, DeleteUserStateResponse, DisableResponse, EmailPasswordPlugin, EnableResponse, GenerateBackupCodesResponse, GetAccountByIdResponse, GetAllImpersonationsResponse, GetAllUsersResponse, GetBannedUserStatesResponse, GetImpersonationByIdResponse, GetRevokedSessionStatesResponse, GetSessionStateResponse, GetTOTPURIResponse, GetUserAccountsResponse, GetUserAdminSessionsResponse, GetUserByIdResponse, GetUserStateResponse, Impersonation, JWKSKey, JWTAlgorithm, JWTPlugin, JWTTokensResponse, MagicLinkExchangeRequest, MagicLinkPlugin, MagicLinkSignInRequest, MagicLinkSignInResponse, MagicLinkVerifyRequest, MagicLinkVerifyResponse, OAuth2Plugin, OAuth2ProviderType, RequestEmailChangeRequest, RequestPasswordResetRequest, RevokeSessionRequest, RevokeSessionResponse, SendEmailVerificationRequest, SignInRequest, SignInWithOAuth2Request, SignInWithOAuth2Response, SignUpRequest, StartImpersonationRequest, StartImpersonationResponse, StopImpersonationResponse, TOTPPlugin, TokenRefreshRequest, TokenRefreshResponse, UnbanUserResponse, UpdateAccountRequest, UpdateAccountResponse, UpdateSessionStateRequest, UpdateSessionStateResponse, UpdateUserRequest, UpdateUserResponse, UpdateUserStateRequest, UpdateUserStateResponse, VerifyBackupCodeRequest, VerifyBackupCodeResponse, VerifyEmailRequest, VerifyTOTPRequest, VerifyTOTPResponse, adminSessionStateSchema, adminUserSessionSchema, adminUserStateSchema, impersonationSchema };
|
|
417
461
|
//# sourceMappingURL=index.d.cts.map
|
package/dist/plugins/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { h as User, l as Plugin, p as Account, t as ClientWithPlugins, u as AuthulaClient } from "../sdk-BWoai6MP.js";
|
|
1
|
+
import { h as User, l as Plugin, m as Session, p as Account, t as ClientWithPlugins, u as AuthulaClient } from "../sdk-BWoai6MP.js";
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
|
|
4
4
|
//#region src/plugins/admin/types.d.ts
|
|
@@ -413,5 +413,49 @@ declare class OAuth2Plugin implements Plugin {
|
|
|
413
413
|
};
|
|
414
414
|
}
|
|
415
415
|
//#endregion
|
|
416
|
-
|
|
416
|
+
//#region src/plugins/totp/types.d.ts
|
|
417
|
+
type EnableResponse = {
|
|
418
|
+
totpUri: string;
|
|
419
|
+
backupCodes: string[];
|
|
420
|
+
};
|
|
421
|
+
type DisableResponse = {
|
|
422
|
+
message: string;
|
|
423
|
+
};
|
|
424
|
+
type GetTOTPURIResponse = {
|
|
425
|
+
totpUri: string;
|
|
426
|
+
};
|
|
427
|
+
type VerifyTOTPRequest = {
|
|
428
|
+
code: string;
|
|
429
|
+
trustDevice?: boolean;
|
|
430
|
+
};
|
|
431
|
+
type VerifyTOTPResponse = {
|
|
432
|
+
user: User;
|
|
433
|
+
session: Session;
|
|
434
|
+
};
|
|
435
|
+
type VerifyBackupCodeRequest = {
|
|
436
|
+
code: string;
|
|
437
|
+
trustDevice?: boolean;
|
|
438
|
+
};
|
|
439
|
+
type VerifyBackupCodeResponse = {
|
|
440
|
+
user: User;
|
|
441
|
+
session: Session;
|
|
442
|
+
};
|
|
443
|
+
type GenerateBackupCodesResponse = {
|
|
444
|
+
backupCodes: string[];
|
|
445
|
+
};
|
|
446
|
+
//#endregion
|
|
447
|
+
//#region src/plugins/totp/plugin.d.ts
|
|
448
|
+
declare class TOTPPlugin implements Plugin {
|
|
449
|
+
readonly id = "totp";
|
|
450
|
+
init(client: AuthulaClient): {
|
|
451
|
+
enable: () => Promise<EnableResponse>;
|
|
452
|
+
disable: () => Promise<DisableResponse>;
|
|
453
|
+
getUri: () => Promise<GetTOTPURIResponse>;
|
|
454
|
+
verify: (data: VerifyTOTPRequest) => Promise<VerifyTOTPResponse>;
|
|
455
|
+
verifyBackupCode: (data: VerifyBackupCodeRequest) => Promise<VerifyBackupCodeResponse>;
|
|
456
|
+
generateBackupCodes: () => Promise<GenerateBackupCodesResponse>;
|
|
457
|
+
};
|
|
458
|
+
}
|
|
459
|
+
//#endregion
|
|
460
|
+
export { AdminPlugin, AdminSessionState, AdminUserSession, AdminUserState, BanUserRequest, BanUserResponse, BearerPlugin, BearerPluginOptions, CSRFPlugin, CSRFPluginOptions, ChangePasswordRequest, CreateAccountRequest, CreateAccountResponse, CreateSessionStateRequest, CreateSessionStateResponse, CreateUserRequest, CreateUserResponse, CreateUserStateRequest, CreateUserStateResponse, DeleteAccountResponse, DeleteSessionStateResponse, DeleteUserResponse, DeleteUserStateResponse, DisableResponse, EmailPasswordPlugin, EnableResponse, GenerateBackupCodesResponse, GetAccountByIdResponse, GetAllImpersonationsResponse, GetAllUsersResponse, GetBannedUserStatesResponse, GetImpersonationByIdResponse, GetRevokedSessionStatesResponse, GetSessionStateResponse, GetTOTPURIResponse, GetUserAccountsResponse, GetUserAdminSessionsResponse, GetUserByIdResponse, GetUserStateResponse, Impersonation, JWKSKey, JWTAlgorithm, JWTPlugin, JWTTokensResponse, MagicLinkExchangeRequest, MagicLinkPlugin, MagicLinkSignInRequest, MagicLinkSignInResponse, MagicLinkVerifyRequest, MagicLinkVerifyResponse, OAuth2Plugin, OAuth2ProviderType, RequestEmailChangeRequest, RequestPasswordResetRequest, RevokeSessionRequest, RevokeSessionResponse, SendEmailVerificationRequest, SignInRequest, SignInWithOAuth2Request, SignInWithOAuth2Response, SignUpRequest, StartImpersonationRequest, StartImpersonationResponse, StopImpersonationResponse, TOTPPlugin, TokenRefreshRequest, TokenRefreshResponse, UnbanUserResponse, UpdateAccountRequest, UpdateAccountResponse, UpdateSessionStateRequest, UpdateSessionStateResponse, UpdateUserRequest, UpdateUserResponse, UpdateUserStateRequest, UpdateUserStateResponse, VerifyBackupCodeRequest, VerifyBackupCodeResponse, VerifyEmailRequest, VerifyTOTPRequest, VerifyTOTPResponse, adminSessionStateSchema, adminUserSessionSchema, adminUserStateSchema, impersonationSchema };
|
|
417
461
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/plugins/index.js
CHANGED
|
@@ -373,5 +373,39 @@ var OAuth2Plugin = class {
|
|
|
373
373
|
};
|
|
374
374
|
|
|
375
375
|
//#endregion
|
|
376
|
-
|
|
376
|
+
//#region src/plugins/totp/plugin.ts
|
|
377
|
+
var TOTPPlugin = class {
|
|
378
|
+
id = "totp";
|
|
379
|
+
init(client) {
|
|
380
|
+
return {
|
|
381
|
+
enable: async () => {
|
|
382
|
+
return wrappedFetch(client, "/totp/enable", { method: "POST" });
|
|
383
|
+
},
|
|
384
|
+
disable: async () => {
|
|
385
|
+
return wrappedFetch(client, "/totp/disable", { method: "POST" });
|
|
386
|
+
},
|
|
387
|
+
getUri: async () => {
|
|
388
|
+
return wrappedFetch(client, "/totp/get-uri", { method: "GET" });
|
|
389
|
+
},
|
|
390
|
+
verify: async (data) => {
|
|
391
|
+
return wrappedFetch(client, "/totp/verify", {
|
|
392
|
+
method: "POST",
|
|
393
|
+
body: data
|
|
394
|
+
});
|
|
395
|
+
},
|
|
396
|
+
verifyBackupCode: async (data) => {
|
|
397
|
+
return wrappedFetch(client, "/totp/verify-backup-code", {
|
|
398
|
+
method: "POST",
|
|
399
|
+
body: data
|
|
400
|
+
});
|
|
401
|
+
},
|
|
402
|
+
generateBackupCodes: async () => {
|
|
403
|
+
return wrappedFetch(client, "/totp/generate-backup-codes", { method: "POST" });
|
|
404
|
+
}
|
|
405
|
+
};
|
|
406
|
+
}
|
|
407
|
+
};
|
|
408
|
+
|
|
409
|
+
//#endregion
|
|
410
|
+
export { AdminPlugin, BearerPlugin, CSRFPlugin, EmailPasswordPlugin, JWTPlugin, MagicLinkPlugin, OAuth2Plugin, TOTPPlugin, adminSessionStateSchema, adminUserSessionSchema, adminUserStateSchema, impersonationSchema };
|
|
377
411
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"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> => {\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"],"mappings":";;;;;AA6CA,IAAa,cAAb,MAA2C;CACzC,AAAgB,KAAK;CAErB,cAAc;CAEd,AAAO,KAAK,QAAuB;AACjC,SAAO;GAGL,YAAY,O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AK,MAAM;AACxC,QAAI,KAAK,YACP,cAAa,OAAO,gBAAgB,KAAK,YAAY;AAEvD,WAAO,aACL,QACA,sBAAsB,aAAa,UAAU,IAC7C,EACE,QAAQ,OACT,CACF;;GAEH,UAAU,OAAU,SAA+C;AACjE,WAAO,aAAa,QAAQ,wBAAwB;KAClD,QAAQ;KACR,MAAM;KACP,CAAC;;GAEL;;;;;;ACxCL,IAAa,eAAb,MAA4C;CAC1C,AAAgB,KAAK;CAErB,AAAO,KAAK,QAAuB;AACjC,SAAO,EACL,QAAQ,OACN,SACsC;AACtC,UAAO,aACL,QACA,qBAAqB,KAAK,SAAS,eAAe,KAAK,cACvD,EACE,QAAQ,OACT,CACF;KAEJ"}
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"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\",\n });\n },\n };\n }\n}\n"],"mappings":";;;;;AA6CA,IAAa,cAAb,MAA2C;CACzC,AAAgB,KAAK;CAErB,cAAc;CAEd,AAAO,KAAK,QAAuB;AACjC,SAAO;GAGL,YAAY,OACV,SACgC;AAChC,WAAO,aAAa,QAAQ,gBAAgB;KAC1C,QAAQ;KACR,MAAM;KACP,CAAC;;GAEJ,aAAa,OAAO,UAAiD;IACnE,MAAM,kBAAkB,IAAI,iBAAiB;AAC7C,QAAI,MACF,iBAAgB,OAAO,SAAS,MAAM,UAAU,CAAC;AAKnD,WAAO,aAAa,QAAQ,eAHb,gBAAgB,UAAU,GACrC,IAAI,gBAAgB,UAAU,KAC9B,MACiD,EACnD,QAAQ,OACT,CAAC;;GAEJ,aAAa,OAAO,WAAiD;AACnE,WAAO,aAAa,QAAQ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AAO,aACL,QACA,qBAAqB,KAAK,SAAS,eAAe,KAAK,cACvD,EACE,QAAQ,OACT,CACF;KAEJ;;;;;;ACVL,IAAa,aAAb,MAA0C;CACxC,AAAgB,KAAK;CAErB,AAAO,KAAK,QAAuB;AACjC,SAAO;GACL,QAAQ,YAAqC;AAC3C,WAAO,aAAa,QAAQ,gBAAgB,EAC1C,QAAQ,QACT,CAAC;;GAEJ,SAAS,YAAsC;AAC7C,WAAO,aAAa,QAAQ,iBAAiB,EAC3C,QAAQ,QACT,CAAC;;GAEJ,QAAQ,YAAyC;AAC/C,WAAO,aAAa,QAAQ,iBAAiB,EAC3C,QAAQ,OACT,CAAC;;GAEJ,QAAQ,OAAO,SAAyD;AACtE,WAAO,aAAa,QAAQ,gBAAgB;KAC1C,QAAQ;KACR,MAAM;KACP,CAAC;;GAEJ,kBAAkB,OAChB,SACsC;AACtC,WAAO,aAAa,QAAQ,4BAA4B;KACtD,QAAQ;KACR,MAAM;KACP,CAAC;;GAEJ,qBAAqB,YAAkD;AACrE,WAAO,aAAa,QAAQ,+BAA+B,EACzD,QAAQ,QACT,CAAC;;GAEL"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "authula",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.3.1",
|
|
5
5
|
"description": "Official SDK for Authula.",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"homepage": "https://github.com/Authula/authula-node-sdk#readme",
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"@types/node": "^25.5.0",
|
|
47
47
|
"bumpp": "^11.0.1",
|
|
48
48
|
"tsdown": "^0.21.4",
|
|
49
|
-
"typescript": "^
|
|
50
|
-
"vitest": "^4.1.
|
|
49
|
+
"typescript": "^6.0.2",
|
|
50
|
+
"vitest": "^4.1.1"
|
|
51
51
|
}
|
|
52
52
|
}
|