authula 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,417 @@
1
+ import { h as User, l as Plugin, p as Account, t as ClientWithPlugins, u as AuthulaClient } from "../sdk-BWoai6MP.js";
2
+ import { z } from "zod";
3
+
4
+ //#region src/plugins/admin/types.d.ts
5
+ declare const adminUserStateSchema: z.ZodObject<{
6
+ userId: z.ZodString;
7
+ isBanned: z.ZodBoolean;
8
+ bannedAt: z.ZodNullable<z.ZodISODateTime>;
9
+ bannedUntil: z.ZodNullable<z.ZodISODateTime>;
10
+ bannedReason: z.ZodNullable<z.ZodString>;
11
+ bannedByUserId: z.ZodNullable<z.ZodString>;
12
+ createdAt: z.ZodISODateTime;
13
+ updatedAt: z.ZodISODateTime;
14
+ }, z.core.$strip>;
15
+ type AdminUserState = z.infer<typeof adminUserStateSchema>;
16
+ declare const adminSessionStateSchema: z.ZodObject<{
17
+ sessionId: z.ZodString;
18
+ revokedAt: z.ZodNullable<z.ZodISODateTime>;
19
+ revokedReason: z.ZodNullable<z.ZodString>;
20
+ revokedByUserId: z.ZodNullable<z.ZodString>;
21
+ impersonatorUserId: z.ZodNullable<z.ZodString>;
22
+ impersonationReason: z.ZodNullable<z.ZodString>;
23
+ impersonationExpiresAt: z.ZodNullable<z.ZodISODateTime>;
24
+ createdAt: z.ZodISODateTime;
25
+ updatedAt: z.ZodISODateTime;
26
+ }, z.core.$strip>;
27
+ type AdminSessionState = z.infer<typeof adminSessionStateSchema>;
28
+ declare const adminUserSessionSchema: z.ZodObject<{
29
+ session: z.ZodObject<{
30
+ id: z.ZodUUID;
31
+ userId: z.ZodString;
32
+ token: z.ZodString;
33
+ expiresAt: z.ZodISODateTime;
34
+ ipAddress: z.ZodOptional<z.ZodNullable<z.ZodString>>;
35
+ userAgent: z.ZodOptional<z.ZodNullable<z.ZodString>>;
36
+ createdAt: z.ZodISODateTime;
37
+ updatedAt: z.ZodISODateTime;
38
+ }, z.core.$strip>;
39
+ state: z.ZodNullable<z.ZodObject<{
40
+ sessionId: z.ZodString;
41
+ revokedAt: z.ZodNullable<z.ZodISODateTime>;
42
+ revokedReason: z.ZodNullable<z.ZodString>;
43
+ revokedByUserId: z.ZodNullable<z.ZodString>;
44
+ impersonatorUserId: z.ZodNullable<z.ZodString>;
45
+ impersonationReason: z.ZodNullable<z.ZodString>;
46
+ impersonationExpiresAt: z.ZodNullable<z.ZodISODateTime>;
47
+ createdAt: z.ZodISODateTime;
48
+ updatedAt: z.ZodISODateTime;
49
+ }, z.core.$strip>>;
50
+ }, z.core.$strip>;
51
+ type AdminUserSession = z.infer<typeof adminUserSessionSchema>;
52
+ declare const impersonationSchema: z.ZodObject<{
53
+ id: z.ZodString;
54
+ actorUserId: z.ZodString;
55
+ targetUserId: z.ZodString;
56
+ actorSessionId: z.ZodNullable<z.ZodString>;
57
+ impersonationSessionId: z.ZodNullable<z.ZodString>;
58
+ reason: z.ZodString;
59
+ startedAt: z.ZodISODateTime;
60
+ expiresAt: z.ZodISODateTime;
61
+ endedAt: z.ZodNullable<z.ZodISODateTime>;
62
+ endedByUserId: z.ZodNullable<z.ZodString>;
63
+ createdAt: z.ZodISODateTime;
64
+ updatedAt: z.ZodISODateTime;
65
+ }, z.core.$strip>;
66
+ type Impersonation = z.infer<typeof impersonationSchema>;
67
+ type CreateUserRequest = {
68
+ name: string;
69
+ email: string;
70
+ emailVerified?: boolean;
71
+ image?: string;
72
+ metadata?: Record<string, unknown>;
73
+ };
74
+ type CreateUserResponse = {
75
+ user: User;
76
+ };
77
+ type GetAllUsersResponse = {
78
+ users: Array<User>;
79
+ nextCursor?: string | null;
80
+ };
81
+ type GetUserByIdResponse = {
82
+ user: User;
83
+ };
84
+ type UpdateUserRequest = {
85
+ name?: string;
86
+ email?: string;
87
+ emailVerified?: boolean;
88
+ image?: string;
89
+ metadata?: Record<string, unknown>;
90
+ };
91
+ type UpdateUserResponse = {
92
+ user: User;
93
+ };
94
+ type DeleteUserResponse = {
95
+ message: string;
96
+ };
97
+ type CreateAccountRequest = {
98
+ providerId: string;
99
+ accountId: string;
100
+ accessToken?: string;
101
+ refreshToken?: string;
102
+ idToken?: string;
103
+ accessTokenExpiresAt?: string;
104
+ refreshTokenExpiresAt?: string;
105
+ scope?: string;
106
+ password?: string;
107
+ };
108
+ type CreateAccountResponse = {
109
+ account: Account;
110
+ };
111
+ type GetUserAccountsResponse = {
112
+ accounts: Array<Account>;
113
+ };
114
+ type GetAccountByIdResponse = {
115
+ account: Account;
116
+ };
117
+ type UpdateAccountRequest = {
118
+ providerId?: string;
119
+ accountId?: string;
120
+ accessToken?: string;
121
+ refreshToken?: string;
122
+ idToken?: string;
123
+ accessTokenExpiresAt?: string;
124
+ refreshTokenExpiresAt?: string;
125
+ scope?: string;
126
+ password?: string;
127
+ };
128
+ type UpdateAccountResponse = {
129
+ account: Account;
130
+ };
131
+ type DeleteAccountResponse = {
132
+ message: string;
133
+ };
134
+ type GetUserStateResponse = {
135
+ state: AdminUserState;
136
+ };
137
+ type CreateUserStateRequest = {
138
+ banned: boolean;
139
+ bannedUntil?: string;
140
+ bannedReason?: string;
141
+ };
142
+ type UpdateUserStateRequest = {
143
+ banned: boolean;
144
+ bannedUntil?: string;
145
+ bannedReason?: string;
146
+ };
147
+ type CreateUserStateResponse = {
148
+ userState: AdminUserState;
149
+ };
150
+ type UpdateUserStateResponse = {
151
+ userState: AdminUserState;
152
+ };
153
+ type DeleteUserStateResponse = {
154
+ message: string;
155
+ };
156
+ type GetBannedUserStatesResponse = Array<AdminUserState>;
157
+ type BanUserRequest = {
158
+ bannedUntil?: string;
159
+ reason?: string;
160
+ };
161
+ type BanUserResponse = {
162
+ state: AdminUserState;
163
+ };
164
+ type UnbanUserResponse = {
165
+ state: AdminUserState;
166
+ };
167
+ type GetUserAdminSessionsResponse = Array<AdminUserSession>;
168
+ type GetSessionStateResponse = {
169
+ state: AdminSessionState;
170
+ };
171
+ type CreateSessionStateRequest = {
172
+ revoke: boolean;
173
+ revokedReason?: string;
174
+ impersonatorUserId?: string;
175
+ impersonationReason?: string;
176
+ impersonationExpiresAt?: string;
177
+ };
178
+ type UpdateSessionStateRequest = {
179
+ revoke: boolean;
180
+ revokedReason?: string;
181
+ impersonatorUserId?: string;
182
+ impersonationReason?: string;
183
+ impersonationExpiresAt?: string;
184
+ };
185
+ type CreateSessionStateResponse = {
186
+ state: AdminSessionState;
187
+ };
188
+ type UpdateSessionStateResponse = {
189
+ state: AdminSessionState;
190
+ };
191
+ type DeleteSessionStateResponse = {
192
+ message: string;
193
+ };
194
+ type GetRevokedSessionStatesResponse = Array<AdminSessionState>;
195
+ type RevokeSessionRequest = {
196
+ reason?: string;
197
+ };
198
+ type RevokeSessionResponse = {
199
+ sessionState: AdminSessionState;
200
+ };
201
+ type GetAllImpersonationsResponse = Array<Impersonation>;
202
+ type GetImpersonationByIdResponse = {
203
+ impersonation: Impersonation;
204
+ };
205
+ type StartImpersonationRequest = {
206
+ targetUserId: string;
207
+ reason: string;
208
+ expiresInSeconds?: number;
209
+ };
210
+ type StartImpersonationResponse = {
211
+ impersonation: Impersonation;
212
+ };
213
+ type StopImpersonationResponse = {
214
+ message: string;
215
+ };
216
+ //#endregion
217
+ //#region src/plugins/admin/plugin.d.ts
218
+ declare class AdminPlugin implements Plugin {
219
+ readonly id = "admin";
220
+ constructor();
221
+ init(client: AuthulaClient): {
222
+ createUser: (data: CreateUserRequest) => Promise<CreateUserResponse>;
223
+ getAllUsers: (limit?: number) => Promise<GetAllUsersResponse>;
224
+ getUserById: (userId: string) => Promise<GetUserByIdResponse>;
225
+ updateUser: (userId: string, data: UpdateUserRequest) => Promise<UpdateUserResponse>;
226
+ deleteUser: (userId: string) => Promise<DeleteUserResponse>;
227
+ createAccount: (userId: string, data: CreateAccountRequest) => Promise<CreateAccountResponse>;
228
+ getUserAccounts: (userId: string) => Promise<GetUserAccountsResponse>;
229
+ getAccountById: (id: string) => Promise<GetAccountByIdResponse>;
230
+ updateAccount: (id: string, data: UpdateAccountRequest) => Promise<UpdateAccountResponse>;
231
+ deleteAccount: (id: string) => Promise<DeleteAccountResponse>;
232
+ getUserState: (userId: string) => Promise<GetUserStateResponse>;
233
+ createUserState: (userId: string, data: CreateUserStateRequest) => Promise<CreateUserStateResponse>;
234
+ updateUserState: (userId: string, data: UpdateUserStateRequest) => Promise<UpdateUserStateResponse>;
235
+ deleteUserState: (userId: string) => Promise<DeleteUserStateResponse>;
236
+ getBannedUserStates: () => Promise<GetBannedUserStatesResponse>;
237
+ banUser: (userId: string, data: BanUserRequest) => Promise<BanUserResponse>;
238
+ unbanUser: (userId: string) => Promise<UnbanUserResponse>;
239
+ getUserAdminSessions: (userId: string) => Promise<GetUserAdminSessionsResponse>;
240
+ getSessionState: (sessionId: string) => Promise<GetSessionStateResponse>;
241
+ createSessionState: (sessionId: string, data: CreateSessionStateRequest) => Promise<CreateSessionStateResponse>;
242
+ updateSessionState: (sessionId: string, data: UpdateSessionStateRequest) => Promise<UpdateSessionStateResponse>;
243
+ deleteSessionState: (sessionId: string) => Promise<DeleteSessionStateResponse>;
244
+ getRevokedSessionStates: () => Promise<GetRevokedSessionStatesResponse>;
245
+ revokeSession: (sessionId: string, data: RevokeSessionRequest) => Promise<RevokeSessionResponse>;
246
+ getAllImpersonations: () => Promise<GetAllImpersonationsResponse>;
247
+ getImpersonationById: (impersonationId: string) => Promise<GetImpersonationByIdResponse>;
248
+ startImpersonation: (data: StartImpersonationRequest) => Promise<StartImpersonationResponse>;
249
+ stopImpersonation: (impersonationId: string) => Promise<StopImpersonationResponse>;
250
+ };
251
+ }
252
+ //#endregion
253
+ //#region src/plugins/bearer/types.d.ts
254
+ type BearerPluginOptions = {
255
+ headerName?: string;
256
+ };
257
+ type JWTTokensResponse = {
258
+ accessToken: string;
259
+ refreshToken: string;
260
+ };
261
+ //#endregion
262
+ //#region src/plugins/jwt/types.d.ts
263
+ type TokenRefreshRequest = {
264
+ refreshToken: string;
265
+ };
266
+ type TokenRefreshResponse = {
267
+ accessToken: string;
268
+ refreshToken: string;
269
+ };
270
+ type JWTAlgorithm = "eddsa" | "rs256" | "ps256" | "es256" | "es512" | "ecdh-es";
271
+ type JWKSKey = {
272
+ alg: JWTAlgorithm;
273
+ crv: string;
274
+ kid: string;
275
+ kty: string;
276
+ x: string;
277
+ };
278
+ //#endregion
279
+ //#region src/plugins/jwt/plugin.d.ts
280
+ declare class JWTPlugin implements Plugin {
281
+ readonly id = "jwt";
282
+ constructor();
283
+ init(client: AuthulaClient): {
284
+ refreshToken: (data: TokenRefreshRequest) => Promise<TokenRefreshResponse>;
285
+ getJWKSKeys: () => Promise<Array<JWKSKey>>;
286
+ };
287
+ }
288
+ //#endregion
289
+ //#region src/plugins/bearer/plugin.d.ts
290
+ declare class BearerPlugin implements Plugin {
291
+ private readonly options?;
292
+ readonly id = "bearer";
293
+ private refreshPromise;
294
+ constructor(options?: BearerPluginOptions | undefined);
295
+ init(client: ClientWithPlugins<[JWTPlugin]>): {};
296
+ }
297
+ //#endregion
298
+ //#region src/plugins/csrf/types.d.ts
299
+ type CSRFPluginOptions = {
300
+ cookieName: string;
301
+ headerName: string;
302
+ };
303
+ //#endregion
304
+ //#region src/plugins/csrf/plugin.d.ts
305
+ declare class CSRFPlugin implements Plugin {
306
+ private readonly options;
307
+ readonly id = "csrf";
308
+ constructor(options: CSRFPluginOptions);
309
+ init(client: AuthulaClient): {};
310
+ private cookies?;
311
+ attachCookies(fn: () => Promise<any>): void;
312
+ }
313
+ //#endregion
314
+ //#region src/plugins/email-password/types.d.ts
315
+ type SignUpRequest = {
316
+ name: string;
317
+ email: string;
318
+ password: string;
319
+ callbackUrl?: string;
320
+ };
321
+ type SignInRequest = {
322
+ email: string;
323
+ password: string;
324
+ callbackUrl?: string;
325
+ };
326
+ type VerifyEmailRequest = {
327
+ token: string;
328
+ callbackUrl?: string;
329
+ };
330
+ type SendEmailVerificationRequest = {
331
+ email: string;
332
+ callbackUrl?: string;
333
+ };
334
+ type RequestPasswordResetRequest = {
335
+ email: string;
336
+ callbackUrl?: string;
337
+ };
338
+ type ChangePasswordRequest = {
339
+ token: string;
340
+ password: string;
341
+ };
342
+ type RequestEmailChangeRequest = {
343
+ email: string;
344
+ callbackUrl?: string;
345
+ };
346
+ //#endregion
347
+ //#region src/plugins/email-password/plugin.d.ts
348
+ declare class EmailPasswordPlugin implements Plugin {
349
+ readonly id = "emailPassword";
350
+ init(client: AuthulaClient): {
351
+ signUp: <T>(data: SignUpRequest) => Promise<T>;
352
+ signIn: <T>(data: SignInRequest) => Promise<T>;
353
+ sendEmailVerification: (data: SendEmailVerificationRequest) => Promise<void>;
354
+ requestPasswordReset: (data: RequestPasswordResetRequest) => Promise<void>;
355
+ changePassword: (data: ChangePasswordRequest) => Promise<void>;
356
+ requestEmailChange: (data: RequestEmailChangeRequest) => Promise<void>;
357
+ };
358
+ }
359
+ //#endregion
360
+ //#region src/plugins/magic-link/types.d.ts
361
+ type MagicLinkSignInRequest = {
362
+ email: string;
363
+ name?: string;
364
+ callbackUrl?: string;
365
+ };
366
+ type MagicLinkSignInResponse = {
367
+ message: string;
368
+ };
369
+ type MagicLinkVerifyRequest = {
370
+ token: string;
371
+ callbackUrl?: string;
372
+ };
373
+ type MagicLinkVerifyResponse = {
374
+ message: string;
375
+ token: string;
376
+ };
377
+ type MagicLinkExchangeRequest = {
378
+ token: string;
379
+ };
380
+ //#endregion
381
+ //#region src/plugins/magic-link/plugin.d.ts
382
+ declare class MagicLinkPlugin implements Plugin {
383
+ readonly id = "magicLink";
384
+ constructor();
385
+ init(client: AuthulaClient): {
386
+ signIn: (data: MagicLinkSignInRequest) => Promise<MagicLinkSignInResponse>;
387
+ verify: (data: MagicLinkVerifyRequest) => Promise<MagicLinkVerifyResponse>;
388
+ exchange: <T>(data: MagicLinkExchangeRequest) => Promise<T>;
389
+ };
390
+ }
391
+ //#endregion
392
+ //#region src/plugins/oauth2/types.d.ts
393
+ /**
394
+ * OAuth2 provider types supported by Authula
395
+ */
396
+ type OAuth2ProviderType = "discord" | "github" | "google";
397
+ /**
398
+ * OAuth2 authorization options
399
+ */
400
+ type SignInWithOAuth2Request = {
401
+ /** OAuth2 provider to use */provider: OAuth2ProviderType;
402
+ redirectTo?: string;
403
+ };
404
+ type SignInWithOAuth2Response = {
405
+ authUrl: string;
406
+ };
407
+ //#endregion
408
+ //#region src/plugins/oauth2/plugin.d.ts
409
+ declare class OAuth2Plugin implements Plugin {
410
+ readonly id = "oauth2";
411
+ init(client: AuthulaClient): {
412
+ signIn: (data: SignInWithOAuth2Request) => Promise<SignInWithOAuth2Response>;
413
+ };
414
+ }
415
+ //#endregion
416
+ export { AdminPlugin, AdminSessionState, AdminUserSession, AdminUserState, BanUserRequest, BanUserResponse, BearerPlugin, BearerPluginOptions, CSRFPlugin, CSRFPluginOptions, ChangePasswordRequest, CreateAccountRequest, CreateAccountResponse, CreateSessionStateRequest, CreateSessionStateResponse, CreateUserRequest, CreateUserResponse, CreateUserStateRequest, CreateUserStateResponse, DeleteAccountResponse, DeleteSessionStateResponse, DeleteUserResponse, DeleteUserStateResponse, EmailPasswordPlugin, GetAccountByIdResponse, GetAllImpersonationsResponse, GetAllUsersResponse, GetBannedUserStatesResponse, GetImpersonationByIdResponse, GetRevokedSessionStatesResponse, GetSessionStateResponse, 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, TokenRefreshRequest, TokenRefreshResponse, UnbanUserResponse, UpdateAccountRequest, UpdateAccountResponse, UpdateSessionStateRequest, UpdateSessionStateResponse, UpdateUserRequest, UpdateUserResponse, UpdateUserStateRequest, UpdateUserStateResponse, VerifyEmailRequest, adminSessionStateSchema, adminUserSessionSchema, adminUserStateSchema, impersonationSchema };
417
+ //# sourceMappingURL=index.d.ts.map