@agentuity/auth 0.0.109 → 0.0.110
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/AGENTS.md +82 -28
- package/README.md +259 -236
- package/dist/agentuity/config.d.ts +2386 -0
- package/dist/agentuity/config.d.ts.map +1 -0
- package/dist/agentuity/config.js +220 -0
- package/dist/agentuity/config.js.map +1 -0
- package/dist/agentuity/plugins/api-key.d.ts +152 -0
- package/dist/agentuity/plugins/api-key.d.ts.map +1 -0
- package/dist/agentuity/plugins/api-key.js +21 -0
- package/dist/agentuity/plugins/api-key.js.map +1 -0
- package/dist/agentuity/plugins/index.d.ts +23 -0
- package/dist/agentuity/plugins/index.d.ts.map +1 -0
- package/dist/agentuity/plugins/index.js +10 -0
- package/dist/agentuity/plugins/index.js.map +1 -0
- package/dist/agentuity/plugins/jwt.d.ts +34 -0
- package/dist/agentuity/plugins/jwt.d.ts.map +1 -0
- package/dist/agentuity/plugins/jwt.js +11 -0
- package/dist/agentuity/plugins/jwt.js.map +1 -0
- package/dist/agentuity/plugins/organization.d.ts +355 -0
- package/dist/agentuity/plugins/organization.d.ts.map +1 -0
- package/dist/agentuity/plugins/organization.js +12 -0
- package/dist/agentuity/plugins/organization.js.map +1 -0
- package/dist/agentuity/react.d.ts +1375 -0
- package/dist/agentuity/react.d.ts.map +1 -0
- package/dist/agentuity/react.js +206 -0
- package/dist/agentuity/react.js.map +1 -0
- package/dist/agentuity/server.d.ts +220 -0
- package/dist/agentuity/server.d.ts.map +1 -0
- package/dist/agentuity/server.js +505 -0
- package/dist/agentuity/server.js.map +1 -0
- package/dist/agentuity/types.d.ts +172 -0
- package/dist/agentuity/types.d.ts.map +1 -0
- package/dist/agentuity/types.js +7 -0
- package/dist/agentuity/types.js.map +1 -0
- package/dist/index.d.ts +31 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +33 -8
- package/dist/index.js.map +1 -1
- package/dist/schema.d.ts +2922 -0
- package/dist/schema.d.ts.map +1 -0
- package/dist/schema.js +223 -0
- package/dist/schema.js.map +1 -0
- package/dist/types.d.ts +14 -18
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +1 -1
- package/package.json +15 -39
- package/src/agentuity/config.ts +401 -0
- package/src/agentuity/plugins/api-key.ts +158 -0
- package/src/agentuity/plugins/index.ts +35 -0
- package/src/agentuity/plugins/jwt.ts +30 -0
- package/src/agentuity/plugins/organization.ts +345 -0
- package/src/agentuity/react.tsx +328 -0
- package/src/agentuity/server.ts +734 -0
- package/src/agentuity/types.ts +201 -0
- package/src/index.ts +76 -8
- package/src/schema.ts +270 -0
- package/src/types.ts +14 -22
- package/test/agentuity/config.test.ts +621 -0
- package/test/agentuity/server.test.ts +537 -0
- package/test/schema.test.ts +147 -0
- package/tsconfig.json +3 -2
- package/tsconfig.tsbuildinfo +1 -1
- package/dist/auth0/client.d.ts +0 -44
- package/dist/auth0/client.d.ts.map +0 -1
- package/dist/auth0/client.js +0 -79
- package/dist/auth0/client.js.map +0 -1
- package/dist/auth0/index.d.ts +0 -35
- package/dist/auth0/index.d.ts.map +0 -1
- package/dist/auth0/index.js +0 -38
- package/dist/auth0/index.js.map +0 -1
- package/dist/auth0/server.d.ts +0 -91
- package/dist/auth0/server.d.ts.map +0 -1
- package/dist/auth0/server.js +0 -237
- package/dist/auth0/server.js.map +0 -1
- package/dist/clerk/client.d.ts +0 -42
- package/dist/clerk/client.d.ts.map +0 -1
- package/dist/clerk/client.js +0 -65
- package/dist/clerk/client.js.map +0 -1
- package/dist/clerk/index.d.ts +0 -37
- package/dist/clerk/index.d.ts.map +0 -1
- package/dist/clerk/index.js +0 -35
- package/dist/clerk/index.js.map +0 -1
- package/dist/clerk/server.d.ts +0 -55
- package/dist/clerk/server.d.ts.map +0 -1
- package/dist/clerk/server.js +0 -111
- package/dist/clerk/server.js.map +0 -1
- package/docs/adding-providers.md +0 -261
- package/src/auth0/client.tsx +0 -109
- package/src/auth0/index.ts +0 -40
- package/src/auth0/server.ts +0 -378
- package/src/clerk/client.tsx +0 -86
- package/src/clerk/index.ts +0 -37
- package/src/clerk/server.ts +0 -168
- package/test/clerk-client.test.tsx +0 -21
- package/test/clerk-server.test.ts +0 -51
|
@@ -0,0 +1,1375 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Auth React integration for @agentuity/auth.
|
|
3
|
+
*
|
|
4
|
+
* All React-specific code for auth.
|
|
5
|
+
* Import from '@agentuity/auth/react' for React components and hooks.
|
|
6
|
+
*
|
|
7
|
+
* @module agentuity/react
|
|
8
|
+
*/
|
|
9
|
+
import React from 'react';
|
|
10
|
+
import { createAuthClient as createBetterAuthClient } from 'better-auth/react';
|
|
11
|
+
import type { BetterAuthClientPlugin } from 'better-auth/client';
|
|
12
|
+
import type { AuthSession, AuthUser } from './types';
|
|
13
|
+
/**
|
|
14
|
+
* Options for creating the auth client.
|
|
15
|
+
*
|
|
16
|
+
* @typeParam TPlugins - Array of BetterAuth client plugins for type inference
|
|
17
|
+
*/
|
|
18
|
+
export interface AuthClientOptions<TPlugins extends BetterAuthClientPlugin[] = BetterAuthClientPlugin[]> {
|
|
19
|
+
/**
|
|
20
|
+
* Base URL for auth API requests.
|
|
21
|
+
* Defaults to `window.location.origin` in browser environments.
|
|
22
|
+
*/
|
|
23
|
+
baseURL?: string;
|
|
24
|
+
/**
|
|
25
|
+
* Base path for auth endpoints.
|
|
26
|
+
* Defaults to '/api/auth' (Agentuity convention).
|
|
27
|
+
*/
|
|
28
|
+
basePath?: string;
|
|
29
|
+
/**
|
|
30
|
+
* Skip default plugins (organizationClient, apiKeyClient).
|
|
31
|
+
* Use this if you want full control over plugins.
|
|
32
|
+
*/
|
|
33
|
+
skipDefaultPlugins?: boolean;
|
|
34
|
+
/**
|
|
35
|
+
* Additional plugins to include.
|
|
36
|
+
* These are added after the default plugins (unless skipDefaultPlugins is true).
|
|
37
|
+
*
|
|
38
|
+
* Plugin types are inferred for full type safety.
|
|
39
|
+
*/
|
|
40
|
+
plugins?: TPlugins;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Get the default client plugins for auth.
|
|
44
|
+
*
|
|
45
|
+
* These mirror the server-side plugins:
|
|
46
|
+
* - organizationClient: Multi-tenancy support
|
|
47
|
+
* - apiKeyClient: Programmatic API key management
|
|
48
|
+
*
|
|
49
|
+
* Note: jwt() and bearer() are server-only plugins.
|
|
50
|
+
*/
|
|
51
|
+
export declare function getDefaultClientPlugins(): ({
|
|
52
|
+
id: "organization";
|
|
53
|
+
$InferServerPlugin: import("better-auth/plugins").OrganizationPlugin<{
|
|
54
|
+
ac: import("better-auth/plugins").AccessControl<{
|
|
55
|
+
readonly organization: readonly ["update", "delete"];
|
|
56
|
+
readonly member: readonly ["create", "update", "delete"];
|
|
57
|
+
readonly invitation: readonly ["create", "cancel"];
|
|
58
|
+
readonly team: readonly ["create", "update", "delete"];
|
|
59
|
+
readonly ac: readonly ["create", "read", "update", "delete"];
|
|
60
|
+
}>;
|
|
61
|
+
roles: {
|
|
62
|
+
admin: import("better-auth/plugins").Role;
|
|
63
|
+
member: import("better-auth/plugins").Role;
|
|
64
|
+
owner: import("better-auth/plugins").Role;
|
|
65
|
+
};
|
|
66
|
+
teams: {
|
|
67
|
+
enabled: false;
|
|
68
|
+
};
|
|
69
|
+
schema: {
|
|
70
|
+
organization?: {
|
|
71
|
+
additionalFields?: {
|
|
72
|
+
[key: string]: import("better-auth").DBFieldAttribute;
|
|
73
|
+
};
|
|
74
|
+
};
|
|
75
|
+
member?: {
|
|
76
|
+
additionalFields?: {
|
|
77
|
+
[key: string]: import("better-auth").DBFieldAttribute;
|
|
78
|
+
};
|
|
79
|
+
};
|
|
80
|
+
invitation?: {
|
|
81
|
+
additionalFields?: {
|
|
82
|
+
[key: string]: import("better-auth").DBFieldAttribute;
|
|
83
|
+
};
|
|
84
|
+
};
|
|
85
|
+
team?: {
|
|
86
|
+
additionalFields?: {
|
|
87
|
+
[key: string]: import("better-auth").DBFieldAttribute;
|
|
88
|
+
};
|
|
89
|
+
};
|
|
90
|
+
organizationRole?: {
|
|
91
|
+
additionalFields?: {
|
|
92
|
+
[key: string]: import("better-auth").DBFieldAttribute;
|
|
93
|
+
};
|
|
94
|
+
};
|
|
95
|
+
} | undefined;
|
|
96
|
+
dynamicAccessControl: {
|
|
97
|
+
enabled: false;
|
|
98
|
+
};
|
|
99
|
+
}>;
|
|
100
|
+
getActions: ($fetch: import("better-auth/react").BetterFetch, _$store: import("better-auth").ClientStore, co: import("better-auth").BetterAuthClientOptions | undefined) => {
|
|
101
|
+
$Infer: {
|
|
102
|
+
ActiveOrganization: {
|
|
103
|
+
members: {
|
|
104
|
+
id: string;
|
|
105
|
+
organizationId: string;
|
|
106
|
+
role: "member" | "admin" | "owner";
|
|
107
|
+
createdAt: Date;
|
|
108
|
+
userId: string;
|
|
109
|
+
user: {
|
|
110
|
+
id: string;
|
|
111
|
+
email: string;
|
|
112
|
+
name: string;
|
|
113
|
+
image?: string | undefined;
|
|
114
|
+
};
|
|
115
|
+
}[];
|
|
116
|
+
invitations: {
|
|
117
|
+
id: string;
|
|
118
|
+
organizationId: string;
|
|
119
|
+
email: string;
|
|
120
|
+
role: "member" | "admin" | "owner";
|
|
121
|
+
status: import("better-auth/plugins").InvitationStatus;
|
|
122
|
+
inviterId: string;
|
|
123
|
+
expiresAt: Date;
|
|
124
|
+
createdAt: Date;
|
|
125
|
+
}[];
|
|
126
|
+
} & {
|
|
127
|
+
id: string;
|
|
128
|
+
name: string;
|
|
129
|
+
slug: string;
|
|
130
|
+
createdAt: Date;
|
|
131
|
+
logo?: string | null | undefined | undefined;
|
|
132
|
+
metadata?: any;
|
|
133
|
+
};
|
|
134
|
+
Organization: {
|
|
135
|
+
id: string;
|
|
136
|
+
name: string;
|
|
137
|
+
slug: string;
|
|
138
|
+
createdAt: Date;
|
|
139
|
+
logo?: string | null | undefined;
|
|
140
|
+
metadata?: any;
|
|
141
|
+
};
|
|
142
|
+
Invitation: {
|
|
143
|
+
id: string;
|
|
144
|
+
organizationId: string;
|
|
145
|
+
email: string;
|
|
146
|
+
role: "member" | "admin" | "owner";
|
|
147
|
+
status: import("better-auth/plugins").InvitationStatus;
|
|
148
|
+
inviterId: string;
|
|
149
|
+
expiresAt: Date;
|
|
150
|
+
createdAt: Date;
|
|
151
|
+
};
|
|
152
|
+
Member: {
|
|
153
|
+
id: string;
|
|
154
|
+
organizationId: string;
|
|
155
|
+
role: "member" | "admin" | "owner";
|
|
156
|
+
createdAt: Date;
|
|
157
|
+
userId: string;
|
|
158
|
+
user: {
|
|
159
|
+
id: string;
|
|
160
|
+
email: string;
|
|
161
|
+
name: string;
|
|
162
|
+
image?: string | undefined;
|
|
163
|
+
};
|
|
164
|
+
};
|
|
165
|
+
Team: {
|
|
166
|
+
id: string;
|
|
167
|
+
name: string;
|
|
168
|
+
organizationId: string;
|
|
169
|
+
createdAt: Date;
|
|
170
|
+
updatedAt?: Date | undefined;
|
|
171
|
+
};
|
|
172
|
+
};
|
|
173
|
+
organization: {
|
|
174
|
+
checkRolePermission: <R extends "member" | "admin" | "owner">(data: ({
|
|
175
|
+
permission: {
|
|
176
|
+
readonly organization?: ("update" | "delete")[] | undefined;
|
|
177
|
+
readonly member?: ("create" | "update" | "delete")[] | undefined;
|
|
178
|
+
readonly invitation?: ("create" | "cancel")[] | undefined;
|
|
179
|
+
readonly team?: ("create" | "update" | "delete")[] | undefined;
|
|
180
|
+
readonly ac?: ("create" | "update" | "delete" | "read")[] | undefined;
|
|
181
|
+
};
|
|
182
|
+
permissions?: never | undefined;
|
|
183
|
+
} | {
|
|
184
|
+
permissions: {
|
|
185
|
+
readonly organization?: ("update" | "delete")[] | undefined;
|
|
186
|
+
readonly member?: ("create" | "update" | "delete")[] | undefined;
|
|
187
|
+
readonly invitation?: ("create" | "cancel")[] | undefined;
|
|
188
|
+
readonly team?: ("create" | "update" | "delete")[] | undefined;
|
|
189
|
+
readonly ac?: ("create" | "update" | "delete" | "read")[] | undefined;
|
|
190
|
+
};
|
|
191
|
+
permission?: never | undefined;
|
|
192
|
+
}) & {
|
|
193
|
+
role: R;
|
|
194
|
+
}) => boolean;
|
|
195
|
+
};
|
|
196
|
+
};
|
|
197
|
+
getAtoms: ($fetch: import("better-auth/react").BetterFetch) => {
|
|
198
|
+
$listOrg: import("better-auth/react").PreinitializedWritableAtom<boolean> & object;
|
|
199
|
+
$activeOrgSignal: import("better-auth/react").PreinitializedWritableAtom<boolean> & object;
|
|
200
|
+
$activeMemberSignal: import("better-auth/react").PreinitializedWritableAtom<boolean> & object;
|
|
201
|
+
$activeMemberRoleSignal: import("better-auth/react").PreinitializedWritableAtom<boolean> & object;
|
|
202
|
+
activeOrganization: import("better-auth/client").AuthQueryAtom<import("better-auth").Prettify<{
|
|
203
|
+
id: string;
|
|
204
|
+
name: string;
|
|
205
|
+
slug: string;
|
|
206
|
+
createdAt: Date;
|
|
207
|
+
logo?: string | null | undefined | undefined;
|
|
208
|
+
metadata?: any;
|
|
209
|
+
} & {
|
|
210
|
+
members: {
|
|
211
|
+
id: string;
|
|
212
|
+
organizationId: string;
|
|
213
|
+
role: "member" | "admin" | "owner";
|
|
214
|
+
createdAt: Date;
|
|
215
|
+
userId: string;
|
|
216
|
+
user: {
|
|
217
|
+
id: string;
|
|
218
|
+
email: string;
|
|
219
|
+
name: string;
|
|
220
|
+
image?: string | undefined;
|
|
221
|
+
};
|
|
222
|
+
}[];
|
|
223
|
+
invitations: {
|
|
224
|
+
id: string;
|
|
225
|
+
organizationId: string;
|
|
226
|
+
email: string;
|
|
227
|
+
role: "member" | "admin" | "owner";
|
|
228
|
+
status: import("better-auth/plugins").InvitationStatus;
|
|
229
|
+
inviterId: string;
|
|
230
|
+
expiresAt: Date;
|
|
231
|
+
createdAt: Date;
|
|
232
|
+
}[];
|
|
233
|
+
}>>;
|
|
234
|
+
listOrganizations: import("better-auth/client").AuthQueryAtom<{
|
|
235
|
+
id: string;
|
|
236
|
+
name: string;
|
|
237
|
+
slug: string;
|
|
238
|
+
createdAt: Date;
|
|
239
|
+
logo?: string | null | undefined | undefined;
|
|
240
|
+
metadata?: any;
|
|
241
|
+
}[]>;
|
|
242
|
+
activeMember: import("better-auth/client").AuthQueryAtom<{
|
|
243
|
+
id: string;
|
|
244
|
+
organizationId: string;
|
|
245
|
+
userId: string;
|
|
246
|
+
role: string;
|
|
247
|
+
createdAt: Date;
|
|
248
|
+
}>;
|
|
249
|
+
activeMemberRole: import("better-auth/client").AuthQueryAtom<{
|
|
250
|
+
role: string;
|
|
251
|
+
}>;
|
|
252
|
+
};
|
|
253
|
+
pathMethods: {
|
|
254
|
+
"/organization/get-full-organization": "GET";
|
|
255
|
+
"/organization/list-user-teams": "GET";
|
|
256
|
+
};
|
|
257
|
+
atomListeners: ({
|
|
258
|
+
matcher(path: string): path is "/organization/create" | "/organization/update" | "/organization/delete";
|
|
259
|
+
signal: "$listOrg";
|
|
260
|
+
} | {
|
|
261
|
+
matcher(path: string): boolean;
|
|
262
|
+
signal: "$activeOrgSignal";
|
|
263
|
+
} | {
|
|
264
|
+
matcher(path: string): boolean;
|
|
265
|
+
signal: "$sessionSignal";
|
|
266
|
+
} | {
|
|
267
|
+
matcher(path: string): boolean;
|
|
268
|
+
signal: "$activeMemberSignal";
|
|
269
|
+
} | {
|
|
270
|
+
matcher(path: string): boolean;
|
|
271
|
+
signal: "$activeMemberRoleSignal";
|
|
272
|
+
})[];
|
|
273
|
+
} | {
|
|
274
|
+
id: "api-key";
|
|
275
|
+
$InferServerPlugin: ReturnType<(options?: import("better-auth/plugins").ApiKeyOptions | undefined) => {
|
|
276
|
+
id: "api-key";
|
|
277
|
+
$ERROR_CODES: {
|
|
278
|
+
readonly INVALID_METADATA_TYPE: "metadata must be an object or undefined";
|
|
279
|
+
readonly REFILL_AMOUNT_AND_INTERVAL_REQUIRED: "refillAmount is required when refillInterval is provided";
|
|
280
|
+
readonly REFILL_INTERVAL_AND_AMOUNT_REQUIRED: "refillInterval is required when refillAmount is provided";
|
|
281
|
+
readonly USER_BANNED: "User is banned";
|
|
282
|
+
readonly UNAUTHORIZED_SESSION: "Unauthorized or invalid session";
|
|
283
|
+
readonly KEY_NOT_FOUND: "API Key not found";
|
|
284
|
+
readonly KEY_DISABLED: "API Key is disabled";
|
|
285
|
+
readonly KEY_EXPIRED: "API Key has expired";
|
|
286
|
+
readonly USAGE_EXCEEDED: "API Key has reached its usage limit";
|
|
287
|
+
readonly KEY_NOT_RECOVERABLE: "API Key is not recoverable";
|
|
288
|
+
readonly EXPIRES_IN_IS_TOO_SMALL: "The expiresIn is smaller than the predefined minimum value.";
|
|
289
|
+
readonly EXPIRES_IN_IS_TOO_LARGE: "The expiresIn is larger than the predefined maximum value.";
|
|
290
|
+
readonly INVALID_REMAINING: "The remaining count is either too large or too small.";
|
|
291
|
+
readonly INVALID_PREFIX_LENGTH: "The prefix length is either too large or too small.";
|
|
292
|
+
readonly INVALID_NAME_LENGTH: "The name length is either too large or too small.";
|
|
293
|
+
readonly METADATA_DISABLED: "Metadata is disabled.";
|
|
294
|
+
readonly RATE_LIMIT_EXCEEDED: "Rate limit exceeded.";
|
|
295
|
+
readonly NO_VALUES_TO_UPDATE: "No values to update.";
|
|
296
|
+
readonly KEY_DISABLED_EXPIRATION: "Custom key expiration values are disabled.";
|
|
297
|
+
readonly INVALID_API_KEY: "Invalid API key.";
|
|
298
|
+
readonly INVALID_USER_ID_FROM_API_KEY: "The user id from the API key is invalid.";
|
|
299
|
+
readonly INVALID_API_KEY_GETTER_RETURN_TYPE: "API Key getter returned an invalid key type. Expected string.";
|
|
300
|
+
readonly SERVER_ONLY_PROPERTY: "The property you're trying to set can only be set from the server auth instance only.";
|
|
301
|
+
readonly FAILED_TO_UPDATE_API_KEY: "Failed to update API key";
|
|
302
|
+
readonly NAME_REQUIRED: "API Key name is required.";
|
|
303
|
+
};
|
|
304
|
+
hooks: {
|
|
305
|
+
before: {
|
|
306
|
+
matcher: (ctx: import("better-auth").HookEndpointContext) => boolean;
|
|
307
|
+
handler: (inputContext: import("better-auth").MiddlewareInputContext<import("better-auth").MiddlewareOptions>) => Promise<{
|
|
308
|
+
user: {
|
|
309
|
+
id: string;
|
|
310
|
+
createdAt: Date;
|
|
311
|
+
updatedAt: Date;
|
|
312
|
+
email: string;
|
|
313
|
+
emailVerified: boolean;
|
|
314
|
+
name: string;
|
|
315
|
+
image?: string | null | undefined;
|
|
316
|
+
};
|
|
317
|
+
session: {
|
|
318
|
+
id: string;
|
|
319
|
+
token: string;
|
|
320
|
+
userId: string;
|
|
321
|
+
userAgent: string | null;
|
|
322
|
+
ipAddress: string | null;
|
|
323
|
+
createdAt: Date;
|
|
324
|
+
updatedAt: Date;
|
|
325
|
+
expiresAt: Date;
|
|
326
|
+
};
|
|
327
|
+
} | {
|
|
328
|
+
context: import("better-auth").MiddlewareContext<import("better-auth").MiddlewareOptions, import("better-auth").AuthContext & {
|
|
329
|
+
returned?: unknown | undefined;
|
|
330
|
+
responseHeaders?: Headers | undefined;
|
|
331
|
+
}>;
|
|
332
|
+
}>;
|
|
333
|
+
}[];
|
|
334
|
+
};
|
|
335
|
+
endpoints: {
|
|
336
|
+
createApiKey: import("better-auth").StrictEndpoint<"/api-key/create", {
|
|
337
|
+
method: "POST";
|
|
338
|
+
body: import("zod").ZodObject<{
|
|
339
|
+
name: import("zod").ZodOptional<import("zod").ZodString>;
|
|
340
|
+
expiresIn: import("zod").ZodDefault<import("zod").ZodNullable<import("zod").ZodOptional<import("zod").ZodNumber>>>;
|
|
341
|
+
userId: import("zod").ZodOptional<import("zod").ZodCoercedString<unknown>>;
|
|
342
|
+
prefix: import("zod").ZodOptional<import("zod").ZodString>;
|
|
343
|
+
remaining: import("zod").ZodDefault<import("zod").ZodNullable<import("zod").ZodOptional<import("zod").ZodNumber>>>;
|
|
344
|
+
metadata: import("zod").ZodOptional<import("zod").ZodAny>;
|
|
345
|
+
refillAmount: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
346
|
+
refillInterval: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
347
|
+
rateLimitTimeWindow: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
348
|
+
rateLimitMax: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
349
|
+
rateLimitEnabled: import("zod").ZodOptional<import("zod").ZodBoolean>;
|
|
350
|
+
permissions: import("zod").ZodOptional<import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodArray<import("zod").ZodString>>>;
|
|
351
|
+
}, import("better-auth").$strip>;
|
|
352
|
+
metadata: {
|
|
353
|
+
openapi: {
|
|
354
|
+
description: string;
|
|
355
|
+
responses: {
|
|
356
|
+
"200": {
|
|
357
|
+
description: string;
|
|
358
|
+
content: {
|
|
359
|
+
"application/json": {
|
|
360
|
+
schema: {
|
|
361
|
+
type: "object";
|
|
362
|
+
properties: {
|
|
363
|
+
id: {
|
|
364
|
+
type: string;
|
|
365
|
+
description: string;
|
|
366
|
+
};
|
|
367
|
+
createdAt: {
|
|
368
|
+
type: string;
|
|
369
|
+
format: string;
|
|
370
|
+
description: string;
|
|
371
|
+
};
|
|
372
|
+
updatedAt: {
|
|
373
|
+
type: string;
|
|
374
|
+
format: string;
|
|
375
|
+
description: string;
|
|
376
|
+
};
|
|
377
|
+
name: {
|
|
378
|
+
type: string;
|
|
379
|
+
nullable: boolean;
|
|
380
|
+
description: string;
|
|
381
|
+
};
|
|
382
|
+
prefix: {
|
|
383
|
+
type: string;
|
|
384
|
+
nullable: boolean;
|
|
385
|
+
description: string;
|
|
386
|
+
};
|
|
387
|
+
start: {
|
|
388
|
+
type: string;
|
|
389
|
+
nullable: boolean;
|
|
390
|
+
description: string;
|
|
391
|
+
};
|
|
392
|
+
key: {
|
|
393
|
+
type: string;
|
|
394
|
+
description: string;
|
|
395
|
+
};
|
|
396
|
+
enabled: {
|
|
397
|
+
type: string;
|
|
398
|
+
description: string;
|
|
399
|
+
};
|
|
400
|
+
expiresAt: {
|
|
401
|
+
type: string;
|
|
402
|
+
format: string;
|
|
403
|
+
nullable: boolean;
|
|
404
|
+
description: string;
|
|
405
|
+
};
|
|
406
|
+
userId: {
|
|
407
|
+
type: string;
|
|
408
|
+
description: string;
|
|
409
|
+
};
|
|
410
|
+
lastRefillAt: {
|
|
411
|
+
type: string;
|
|
412
|
+
format: string;
|
|
413
|
+
nullable: boolean;
|
|
414
|
+
description: string;
|
|
415
|
+
};
|
|
416
|
+
lastRequest: {
|
|
417
|
+
type: string;
|
|
418
|
+
format: string;
|
|
419
|
+
nullable: boolean;
|
|
420
|
+
description: string;
|
|
421
|
+
};
|
|
422
|
+
metadata: {
|
|
423
|
+
type: string;
|
|
424
|
+
nullable: boolean;
|
|
425
|
+
additionalProperties: boolean;
|
|
426
|
+
description: string;
|
|
427
|
+
};
|
|
428
|
+
rateLimitMax: {
|
|
429
|
+
type: string;
|
|
430
|
+
nullable: boolean;
|
|
431
|
+
description: string;
|
|
432
|
+
};
|
|
433
|
+
rateLimitTimeWindow: {
|
|
434
|
+
type: string;
|
|
435
|
+
nullable: boolean;
|
|
436
|
+
description: string;
|
|
437
|
+
};
|
|
438
|
+
remaining: {
|
|
439
|
+
type: string;
|
|
440
|
+
nullable: boolean;
|
|
441
|
+
description: string;
|
|
442
|
+
};
|
|
443
|
+
refillAmount: {
|
|
444
|
+
type: string;
|
|
445
|
+
nullable: boolean;
|
|
446
|
+
description: string;
|
|
447
|
+
};
|
|
448
|
+
refillInterval: {
|
|
449
|
+
type: string;
|
|
450
|
+
nullable: boolean;
|
|
451
|
+
description: string;
|
|
452
|
+
};
|
|
453
|
+
rateLimitEnabled: {
|
|
454
|
+
type: string;
|
|
455
|
+
description: string;
|
|
456
|
+
};
|
|
457
|
+
requestCount: {
|
|
458
|
+
type: string;
|
|
459
|
+
description: string;
|
|
460
|
+
};
|
|
461
|
+
permissions: {
|
|
462
|
+
type: string;
|
|
463
|
+
nullable: boolean;
|
|
464
|
+
additionalProperties: {
|
|
465
|
+
type: string;
|
|
466
|
+
items: {
|
|
467
|
+
type: string;
|
|
468
|
+
};
|
|
469
|
+
};
|
|
470
|
+
description: string;
|
|
471
|
+
};
|
|
472
|
+
};
|
|
473
|
+
required: string[];
|
|
474
|
+
};
|
|
475
|
+
};
|
|
476
|
+
};
|
|
477
|
+
};
|
|
478
|
+
};
|
|
479
|
+
};
|
|
480
|
+
};
|
|
481
|
+
}, {
|
|
482
|
+
key: string;
|
|
483
|
+
metadata: any;
|
|
484
|
+
permissions: any;
|
|
485
|
+
id: string;
|
|
486
|
+
name: string | null;
|
|
487
|
+
start: string | null;
|
|
488
|
+
prefix: string | null;
|
|
489
|
+
userId: string;
|
|
490
|
+
refillInterval: number | null;
|
|
491
|
+
refillAmount: number | null;
|
|
492
|
+
lastRefillAt: Date | null;
|
|
493
|
+
enabled: boolean;
|
|
494
|
+
rateLimitEnabled: boolean;
|
|
495
|
+
rateLimitTimeWindow: number | null;
|
|
496
|
+
rateLimitMax: number | null;
|
|
497
|
+
requestCount: number;
|
|
498
|
+
remaining: number | null;
|
|
499
|
+
lastRequest: Date | null;
|
|
500
|
+
expiresAt: Date | null;
|
|
501
|
+
createdAt: Date;
|
|
502
|
+
updatedAt: Date;
|
|
503
|
+
}>;
|
|
504
|
+
verifyApiKey: import("better-auth").StrictEndpoint<string, {
|
|
505
|
+
method: "POST";
|
|
506
|
+
body: import("zod").ZodObject<{
|
|
507
|
+
key: import("zod").ZodString;
|
|
508
|
+
permissions: import("zod").ZodOptional<import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodArray<import("zod").ZodString>>>;
|
|
509
|
+
}, import("better-auth").$strip>;
|
|
510
|
+
}, {
|
|
511
|
+
valid: boolean;
|
|
512
|
+
error: {
|
|
513
|
+
message: string | undefined;
|
|
514
|
+
code: string;
|
|
515
|
+
};
|
|
516
|
+
key: null;
|
|
517
|
+
} | {
|
|
518
|
+
valid: boolean;
|
|
519
|
+
error: null;
|
|
520
|
+
key: Omit<import("better-auth/plugins").ApiKey, "key"> | null;
|
|
521
|
+
}>;
|
|
522
|
+
getApiKey: import("better-auth").StrictEndpoint<"/api-key/get", {
|
|
523
|
+
method: "GET";
|
|
524
|
+
query: import("zod").ZodObject<{
|
|
525
|
+
id: import("zod").ZodString;
|
|
526
|
+
}, import("better-auth").$strip>;
|
|
527
|
+
use: ((inputContext: import("better-auth").MiddlewareInputContext<import("better-auth").MiddlewareOptions>) => Promise<{
|
|
528
|
+
session: {
|
|
529
|
+
session: Record<string, any> & {
|
|
530
|
+
id: string;
|
|
531
|
+
createdAt: Date;
|
|
532
|
+
updatedAt: Date;
|
|
533
|
+
userId: string;
|
|
534
|
+
expiresAt: Date;
|
|
535
|
+
token: string;
|
|
536
|
+
ipAddress?: string | null | undefined;
|
|
537
|
+
userAgent?: string | null | undefined;
|
|
538
|
+
};
|
|
539
|
+
user: Record<string, any> & {
|
|
540
|
+
id: string;
|
|
541
|
+
createdAt: Date;
|
|
542
|
+
updatedAt: Date;
|
|
543
|
+
email: string;
|
|
544
|
+
emailVerified: boolean;
|
|
545
|
+
name: string;
|
|
546
|
+
image?: string | null | undefined;
|
|
547
|
+
};
|
|
548
|
+
};
|
|
549
|
+
}>)[];
|
|
550
|
+
metadata: {
|
|
551
|
+
openapi: {
|
|
552
|
+
description: string;
|
|
553
|
+
responses: {
|
|
554
|
+
"200": {
|
|
555
|
+
description: string;
|
|
556
|
+
content: {
|
|
557
|
+
"application/json": {
|
|
558
|
+
schema: {
|
|
559
|
+
type: "object";
|
|
560
|
+
properties: {
|
|
561
|
+
id: {
|
|
562
|
+
type: string;
|
|
563
|
+
description: string;
|
|
564
|
+
};
|
|
565
|
+
name: {
|
|
566
|
+
type: string;
|
|
567
|
+
nullable: boolean;
|
|
568
|
+
description: string;
|
|
569
|
+
};
|
|
570
|
+
start: {
|
|
571
|
+
type: string;
|
|
572
|
+
nullable: boolean;
|
|
573
|
+
description: string;
|
|
574
|
+
};
|
|
575
|
+
prefix: {
|
|
576
|
+
type: string;
|
|
577
|
+
nullable: boolean;
|
|
578
|
+
description: string;
|
|
579
|
+
};
|
|
580
|
+
userId: {
|
|
581
|
+
type: string;
|
|
582
|
+
description: string;
|
|
583
|
+
};
|
|
584
|
+
refillInterval: {
|
|
585
|
+
type: string;
|
|
586
|
+
nullable: boolean;
|
|
587
|
+
description: string;
|
|
588
|
+
};
|
|
589
|
+
refillAmount: {
|
|
590
|
+
type: string;
|
|
591
|
+
nullable: boolean;
|
|
592
|
+
description: string;
|
|
593
|
+
};
|
|
594
|
+
lastRefillAt: {
|
|
595
|
+
type: string;
|
|
596
|
+
format: string;
|
|
597
|
+
nullable: boolean;
|
|
598
|
+
description: string;
|
|
599
|
+
};
|
|
600
|
+
enabled: {
|
|
601
|
+
type: string;
|
|
602
|
+
description: string;
|
|
603
|
+
default: boolean;
|
|
604
|
+
};
|
|
605
|
+
rateLimitEnabled: {
|
|
606
|
+
type: string;
|
|
607
|
+
description: string;
|
|
608
|
+
};
|
|
609
|
+
rateLimitTimeWindow: {
|
|
610
|
+
type: string;
|
|
611
|
+
nullable: boolean;
|
|
612
|
+
description: string;
|
|
613
|
+
};
|
|
614
|
+
rateLimitMax: {
|
|
615
|
+
type: string;
|
|
616
|
+
nullable: boolean;
|
|
617
|
+
description: string;
|
|
618
|
+
};
|
|
619
|
+
requestCount: {
|
|
620
|
+
type: string;
|
|
621
|
+
description: string;
|
|
622
|
+
};
|
|
623
|
+
remaining: {
|
|
624
|
+
type: string;
|
|
625
|
+
nullable: boolean;
|
|
626
|
+
description: string;
|
|
627
|
+
};
|
|
628
|
+
lastRequest: {
|
|
629
|
+
type: string;
|
|
630
|
+
format: string;
|
|
631
|
+
nullable: boolean;
|
|
632
|
+
description: string;
|
|
633
|
+
};
|
|
634
|
+
expiresAt: {
|
|
635
|
+
type: string;
|
|
636
|
+
format: string;
|
|
637
|
+
nullable: boolean;
|
|
638
|
+
description: string;
|
|
639
|
+
};
|
|
640
|
+
createdAt: {
|
|
641
|
+
type: string;
|
|
642
|
+
format: string;
|
|
643
|
+
description: string;
|
|
644
|
+
};
|
|
645
|
+
updatedAt: {
|
|
646
|
+
type: string;
|
|
647
|
+
format: string;
|
|
648
|
+
description: string;
|
|
649
|
+
};
|
|
650
|
+
metadata: {
|
|
651
|
+
type: string;
|
|
652
|
+
nullable: boolean;
|
|
653
|
+
additionalProperties: boolean;
|
|
654
|
+
description: string;
|
|
655
|
+
};
|
|
656
|
+
permissions: {
|
|
657
|
+
type: string;
|
|
658
|
+
nullable: boolean;
|
|
659
|
+
description: string;
|
|
660
|
+
};
|
|
661
|
+
};
|
|
662
|
+
required: string[];
|
|
663
|
+
};
|
|
664
|
+
};
|
|
665
|
+
};
|
|
666
|
+
};
|
|
667
|
+
};
|
|
668
|
+
};
|
|
669
|
+
};
|
|
670
|
+
}, {
|
|
671
|
+
permissions: {
|
|
672
|
+
[key: string]: string[];
|
|
673
|
+
} | null;
|
|
674
|
+
id: string;
|
|
675
|
+
name: string | null;
|
|
676
|
+
start: string | null;
|
|
677
|
+
prefix: string | null;
|
|
678
|
+
userId: string;
|
|
679
|
+
refillInterval: number | null;
|
|
680
|
+
refillAmount: number | null;
|
|
681
|
+
lastRefillAt: Date | null;
|
|
682
|
+
enabled: boolean;
|
|
683
|
+
rateLimitEnabled: boolean;
|
|
684
|
+
rateLimitTimeWindow: number | null;
|
|
685
|
+
rateLimitMax: number | null;
|
|
686
|
+
requestCount: number;
|
|
687
|
+
remaining: number | null;
|
|
688
|
+
lastRequest: Date | null;
|
|
689
|
+
expiresAt: Date | null;
|
|
690
|
+
createdAt: Date;
|
|
691
|
+
updatedAt: Date;
|
|
692
|
+
metadata: Record<string, any> | null;
|
|
693
|
+
}>;
|
|
694
|
+
updateApiKey: import("better-auth").StrictEndpoint<"/api-key/update", {
|
|
695
|
+
method: "POST";
|
|
696
|
+
body: import("zod").ZodObject<{
|
|
697
|
+
keyId: import("zod").ZodString;
|
|
698
|
+
userId: import("zod").ZodOptional<import("zod").ZodCoercedString<unknown>>;
|
|
699
|
+
name: import("zod").ZodOptional<import("zod").ZodString>;
|
|
700
|
+
enabled: import("zod").ZodOptional<import("zod").ZodBoolean>;
|
|
701
|
+
remaining: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
702
|
+
refillAmount: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
703
|
+
refillInterval: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
704
|
+
metadata: import("zod").ZodOptional<import("zod").ZodAny>;
|
|
705
|
+
expiresIn: import("zod").ZodNullable<import("zod").ZodOptional<import("zod").ZodNumber>>;
|
|
706
|
+
rateLimitEnabled: import("zod").ZodOptional<import("zod").ZodBoolean>;
|
|
707
|
+
rateLimitTimeWindow: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
708
|
+
rateLimitMax: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
709
|
+
permissions: import("zod").ZodNullable<import("zod").ZodOptional<import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodArray<import("zod").ZodString>>>>;
|
|
710
|
+
}, import("better-auth").$strip>;
|
|
711
|
+
metadata: {
|
|
712
|
+
openapi: {
|
|
713
|
+
description: string;
|
|
714
|
+
responses: {
|
|
715
|
+
"200": {
|
|
716
|
+
description: string;
|
|
717
|
+
content: {
|
|
718
|
+
"application/json": {
|
|
719
|
+
schema: {
|
|
720
|
+
type: "object";
|
|
721
|
+
properties: {
|
|
722
|
+
id: {
|
|
723
|
+
type: string;
|
|
724
|
+
description: string;
|
|
725
|
+
};
|
|
726
|
+
name: {
|
|
727
|
+
type: string;
|
|
728
|
+
nullable: boolean;
|
|
729
|
+
description: string;
|
|
730
|
+
};
|
|
731
|
+
start: {
|
|
732
|
+
type: string;
|
|
733
|
+
nullable: boolean;
|
|
734
|
+
description: string;
|
|
735
|
+
};
|
|
736
|
+
prefix: {
|
|
737
|
+
type: string;
|
|
738
|
+
nullable: boolean;
|
|
739
|
+
description: string;
|
|
740
|
+
};
|
|
741
|
+
userId: {
|
|
742
|
+
type: string;
|
|
743
|
+
description: string;
|
|
744
|
+
};
|
|
745
|
+
refillInterval: {
|
|
746
|
+
type: string;
|
|
747
|
+
nullable: boolean;
|
|
748
|
+
description: string;
|
|
749
|
+
};
|
|
750
|
+
refillAmount: {
|
|
751
|
+
type: string;
|
|
752
|
+
nullable: boolean;
|
|
753
|
+
description: string;
|
|
754
|
+
};
|
|
755
|
+
lastRefillAt: {
|
|
756
|
+
type: string;
|
|
757
|
+
format: string;
|
|
758
|
+
nullable: boolean;
|
|
759
|
+
description: string;
|
|
760
|
+
};
|
|
761
|
+
enabled: {
|
|
762
|
+
type: string;
|
|
763
|
+
description: string;
|
|
764
|
+
default: boolean;
|
|
765
|
+
};
|
|
766
|
+
rateLimitEnabled: {
|
|
767
|
+
type: string;
|
|
768
|
+
description: string;
|
|
769
|
+
};
|
|
770
|
+
rateLimitTimeWindow: {
|
|
771
|
+
type: string;
|
|
772
|
+
nullable: boolean;
|
|
773
|
+
description: string;
|
|
774
|
+
};
|
|
775
|
+
rateLimitMax: {
|
|
776
|
+
type: string;
|
|
777
|
+
nullable: boolean;
|
|
778
|
+
description: string;
|
|
779
|
+
};
|
|
780
|
+
requestCount: {
|
|
781
|
+
type: string;
|
|
782
|
+
description: string;
|
|
783
|
+
};
|
|
784
|
+
remaining: {
|
|
785
|
+
type: string;
|
|
786
|
+
nullable: boolean;
|
|
787
|
+
description: string;
|
|
788
|
+
};
|
|
789
|
+
lastRequest: {
|
|
790
|
+
type: string;
|
|
791
|
+
format: string;
|
|
792
|
+
nullable: boolean;
|
|
793
|
+
description: string;
|
|
794
|
+
};
|
|
795
|
+
expiresAt: {
|
|
796
|
+
type: string;
|
|
797
|
+
format: string;
|
|
798
|
+
nullable: boolean;
|
|
799
|
+
description: string;
|
|
800
|
+
};
|
|
801
|
+
createdAt: {
|
|
802
|
+
type: string;
|
|
803
|
+
format: string;
|
|
804
|
+
description: string;
|
|
805
|
+
};
|
|
806
|
+
updatedAt: {
|
|
807
|
+
type: string;
|
|
808
|
+
format: string;
|
|
809
|
+
description: string;
|
|
810
|
+
};
|
|
811
|
+
metadata: {
|
|
812
|
+
type: string;
|
|
813
|
+
nullable: boolean;
|
|
814
|
+
additionalProperties: boolean;
|
|
815
|
+
description: string;
|
|
816
|
+
};
|
|
817
|
+
permissions: {
|
|
818
|
+
type: string;
|
|
819
|
+
nullable: boolean;
|
|
820
|
+
description: string;
|
|
821
|
+
};
|
|
822
|
+
};
|
|
823
|
+
required: string[];
|
|
824
|
+
};
|
|
825
|
+
};
|
|
826
|
+
};
|
|
827
|
+
};
|
|
828
|
+
};
|
|
829
|
+
};
|
|
830
|
+
};
|
|
831
|
+
}, {
|
|
832
|
+
permissions: {
|
|
833
|
+
[key: string]: string[];
|
|
834
|
+
} | null;
|
|
835
|
+
id: string;
|
|
836
|
+
name: string | null;
|
|
837
|
+
start: string | null;
|
|
838
|
+
prefix: string | null;
|
|
839
|
+
userId: string;
|
|
840
|
+
refillInterval: number | null;
|
|
841
|
+
refillAmount: number | null;
|
|
842
|
+
lastRefillAt: Date | null;
|
|
843
|
+
enabled: boolean;
|
|
844
|
+
rateLimitEnabled: boolean;
|
|
845
|
+
rateLimitTimeWindow: number | null;
|
|
846
|
+
rateLimitMax: number | null;
|
|
847
|
+
requestCount: number;
|
|
848
|
+
remaining: number | null;
|
|
849
|
+
lastRequest: Date | null;
|
|
850
|
+
expiresAt: Date | null;
|
|
851
|
+
createdAt: Date;
|
|
852
|
+
updatedAt: Date;
|
|
853
|
+
metadata: Record<string, any> | null;
|
|
854
|
+
}>;
|
|
855
|
+
deleteApiKey: import("better-auth").StrictEndpoint<"/api-key/delete", {
|
|
856
|
+
method: "POST";
|
|
857
|
+
body: import("zod").ZodObject<{
|
|
858
|
+
keyId: import("zod").ZodString;
|
|
859
|
+
}, import("better-auth").$strip>;
|
|
860
|
+
use: ((inputContext: import("better-auth").MiddlewareInputContext<import("better-auth").MiddlewareOptions>) => Promise<{
|
|
861
|
+
session: {
|
|
862
|
+
session: Record<string, any> & {
|
|
863
|
+
id: string;
|
|
864
|
+
createdAt: Date;
|
|
865
|
+
updatedAt: Date;
|
|
866
|
+
userId: string;
|
|
867
|
+
expiresAt: Date;
|
|
868
|
+
token: string;
|
|
869
|
+
ipAddress?: string | null | undefined;
|
|
870
|
+
userAgent?: string | null | undefined;
|
|
871
|
+
};
|
|
872
|
+
user: Record<string, any> & {
|
|
873
|
+
id: string;
|
|
874
|
+
createdAt: Date;
|
|
875
|
+
updatedAt: Date;
|
|
876
|
+
email: string;
|
|
877
|
+
emailVerified: boolean;
|
|
878
|
+
name: string;
|
|
879
|
+
image?: string | null | undefined;
|
|
880
|
+
};
|
|
881
|
+
};
|
|
882
|
+
}>)[];
|
|
883
|
+
metadata: {
|
|
884
|
+
openapi: {
|
|
885
|
+
description: string;
|
|
886
|
+
requestBody: {
|
|
887
|
+
content: {
|
|
888
|
+
"application/json": {
|
|
889
|
+
schema: {
|
|
890
|
+
type: "object";
|
|
891
|
+
properties: {
|
|
892
|
+
keyId: {
|
|
893
|
+
type: string;
|
|
894
|
+
description: string;
|
|
895
|
+
};
|
|
896
|
+
};
|
|
897
|
+
required: string[];
|
|
898
|
+
};
|
|
899
|
+
};
|
|
900
|
+
};
|
|
901
|
+
};
|
|
902
|
+
responses: {
|
|
903
|
+
"200": {
|
|
904
|
+
description: string;
|
|
905
|
+
content: {
|
|
906
|
+
"application/json": {
|
|
907
|
+
schema: {
|
|
908
|
+
type: "object";
|
|
909
|
+
properties: {
|
|
910
|
+
success: {
|
|
911
|
+
type: string;
|
|
912
|
+
description: string;
|
|
913
|
+
};
|
|
914
|
+
};
|
|
915
|
+
required: string[];
|
|
916
|
+
};
|
|
917
|
+
};
|
|
918
|
+
};
|
|
919
|
+
};
|
|
920
|
+
};
|
|
921
|
+
};
|
|
922
|
+
};
|
|
923
|
+
}, {
|
|
924
|
+
success: boolean;
|
|
925
|
+
}>;
|
|
926
|
+
listApiKeys: import("better-auth").StrictEndpoint<"/api-key/list", {
|
|
927
|
+
method: "GET";
|
|
928
|
+
use: ((inputContext: import("better-auth").MiddlewareInputContext<import("better-auth").MiddlewareOptions>) => Promise<{
|
|
929
|
+
session: {
|
|
930
|
+
session: Record<string, any> & {
|
|
931
|
+
id: string;
|
|
932
|
+
createdAt: Date;
|
|
933
|
+
updatedAt: Date;
|
|
934
|
+
userId: string;
|
|
935
|
+
expiresAt: Date;
|
|
936
|
+
token: string;
|
|
937
|
+
ipAddress?: string | null | undefined;
|
|
938
|
+
userAgent?: string | null | undefined;
|
|
939
|
+
};
|
|
940
|
+
user: Record<string, any> & {
|
|
941
|
+
id: string;
|
|
942
|
+
createdAt: Date;
|
|
943
|
+
updatedAt: Date;
|
|
944
|
+
email: string;
|
|
945
|
+
emailVerified: boolean;
|
|
946
|
+
name: string;
|
|
947
|
+
image?: string | null | undefined;
|
|
948
|
+
};
|
|
949
|
+
};
|
|
950
|
+
}>)[];
|
|
951
|
+
metadata: {
|
|
952
|
+
openapi: {
|
|
953
|
+
description: string;
|
|
954
|
+
responses: {
|
|
955
|
+
"200": {
|
|
956
|
+
description: string;
|
|
957
|
+
content: {
|
|
958
|
+
"application/json": {
|
|
959
|
+
schema: {
|
|
960
|
+
type: "array";
|
|
961
|
+
items: {
|
|
962
|
+
type: string;
|
|
963
|
+
properties: {
|
|
964
|
+
id: {
|
|
965
|
+
type: string;
|
|
966
|
+
description: string;
|
|
967
|
+
};
|
|
968
|
+
name: {
|
|
969
|
+
type: string;
|
|
970
|
+
nullable: boolean;
|
|
971
|
+
description: string;
|
|
972
|
+
};
|
|
973
|
+
start: {
|
|
974
|
+
type: string;
|
|
975
|
+
nullable: boolean;
|
|
976
|
+
description: string;
|
|
977
|
+
};
|
|
978
|
+
prefix: {
|
|
979
|
+
type: string;
|
|
980
|
+
nullable: boolean;
|
|
981
|
+
description: string;
|
|
982
|
+
};
|
|
983
|
+
userId: {
|
|
984
|
+
type: string;
|
|
985
|
+
description: string;
|
|
986
|
+
};
|
|
987
|
+
refillInterval: {
|
|
988
|
+
type: string;
|
|
989
|
+
nullable: boolean;
|
|
990
|
+
description: string;
|
|
991
|
+
};
|
|
992
|
+
refillAmount: {
|
|
993
|
+
type: string;
|
|
994
|
+
nullable: boolean;
|
|
995
|
+
description: string;
|
|
996
|
+
};
|
|
997
|
+
lastRefillAt: {
|
|
998
|
+
type: string;
|
|
999
|
+
format: string;
|
|
1000
|
+
nullable: boolean;
|
|
1001
|
+
description: string;
|
|
1002
|
+
};
|
|
1003
|
+
enabled: {
|
|
1004
|
+
type: string;
|
|
1005
|
+
description: string;
|
|
1006
|
+
default: boolean;
|
|
1007
|
+
};
|
|
1008
|
+
rateLimitEnabled: {
|
|
1009
|
+
type: string;
|
|
1010
|
+
description: string;
|
|
1011
|
+
};
|
|
1012
|
+
rateLimitTimeWindow: {
|
|
1013
|
+
type: string;
|
|
1014
|
+
nullable: boolean;
|
|
1015
|
+
description: string;
|
|
1016
|
+
};
|
|
1017
|
+
rateLimitMax: {
|
|
1018
|
+
type: string;
|
|
1019
|
+
nullable: boolean;
|
|
1020
|
+
description: string;
|
|
1021
|
+
};
|
|
1022
|
+
requestCount: {
|
|
1023
|
+
type: string;
|
|
1024
|
+
description: string;
|
|
1025
|
+
};
|
|
1026
|
+
remaining: {
|
|
1027
|
+
type: string;
|
|
1028
|
+
nullable: boolean;
|
|
1029
|
+
description: string;
|
|
1030
|
+
};
|
|
1031
|
+
lastRequest: {
|
|
1032
|
+
type: string;
|
|
1033
|
+
format: string;
|
|
1034
|
+
nullable: boolean;
|
|
1035
|
+
description: string;
|
|
1036
|
+
};
|
|
1037
|
+
expiresAt: {
|
|
1038
|
+
type: string;
|
|
1039
|
+
format: string;
|
|
1040
|
+
nullable: boolean;
|
|
1041
|
+
description: string;
|
|
1042
|
+
};
|
|
1043
|
+
createdAt: {
|
|
1044
|
+
type: string;
|
|
1045
|
+
format: string;
|
|
1046
|
+
description: string;
|
|
1047
|
+
};
|
|
1048
|
+
updatedAt: {
|
|
1049
|
+
type: string;
|
|
1050
|
+
format: string;
|
|
1051
|
+
description: string;
|
|
1052
|
+
};
|
|
1053
|
+
metadata: {
|
|
1054
|
+
type: string;
|
|
1055
|
+
nullable: boolean;
|
|
1056
|
+
additionalProperties: boolean;
|
|
1057
|
+
description: string;
|
|
1058
|
+
};
|
|
1059
|
+
permissions: {
|
|
1060
|
+
type: string;
|
|
1061
|
+
nullable: boolean;
|
|
1062
|
+
description: string;
|
|
1063
|
+
};
|
|
1064
|
+
};
|
|
1065
|
+
required: string[];
|
|
1066
|
+
};
|
|
1067
|
+
};
|
|
1068
|
+
};
|
|
1069
|
+
};
|
|
1070
|
+
};
|
|
1071
|
+
};
|
|
1072
|
+
};
|
|
1073
|
+
};
|
|
1074
|
+
}, {
|
|
1075
|
+
permissions: {
|
|
1076
|
+
[key: string]: string[];
|
|
1077
|
+
} | null;
|
|
1078
|
+
id: string;
|
|
1079
|
+
name: string | null;
|
|
1080
|
+
start: string | null;
|
|
1081
|
+
prefix: string | null;
|
|
1082
|
+
userId: string;
|
|
1083
|
+
refillInterval: number | null;
|
|
1084
|
+
refillAmount: number | null;
|
|
1085
|
+
lastRefillAt: Date | null;
|
|
1086
|
+
enabled: boolean;
|
|
1087
|
+
rateLimitEnabled: boolean;
|
|
1088
|
+
rateLimitTimeWindow: number | null;
|
|
1089
|
+
rateLimitMax: number | null;
|
|
1090
|
+
requestCount: number;
|
|
1091
|
+
remaining: number | null;
|
|
1092
|
+
lastRequest: Date | null;
|
|
1093
|
+
expiresAt: Date | null;
|
|
1094
|
+
createdAt: Date;
|
|
1095
|
+
updatedAt: Date;
|
|
1096
|
+
metadata: Record<string, any> | null;
|
|
1097
|
+
}[]>;
|
|
1098
|
+
deleteAllExpiredApiKeys: import("better-auth").StrictEndpoint<string, {
|
|
1099
|
+
method: "POST";
|
|
1100
|
+
}, {
|
|
1101
|
+
success: boolean;
|
|
1102
|
+
error: unknown;
|
|
1103
|
+
}>;
|
|
1104
|
+
};
|
|
1105
|
+
schema: {
|
|
1106
|
+
apikey: {
|
|
1107
|
+
fields: {
|
|
1108
|
+
name: {
|
|
1109
|
+
type: "string";
|
|
1110
|
+
required: false;
|
|
1111
|
+
input: false;
|
|
1112
|
+
};
|
|
1113
|
+
start: {
|
|
1114
|
+
type: "string";
|
|
1115
|
+
required: false;
|
|
1116
|
+
input: false;
|
|
1117
|
+
};
|
|
1118
|
+
prefix: {
|
|
1119
|
+
type: "string";
|
|
1120
|
+
required: false;
|
|
1121
|
+
input: false;
|
|
1122
|
+
};
|
|
1123
|
+
key: {
|
|
1124
|
+
type: "string";
|
|
1125
|
+
required: true;
|
|
1126
|
+
input: false;
|
|
1127
|
+
index: true;
|
|
1128
|
+
};
|
|
1129
|
+
userId: {
|
|
1130
|
+
type: "string";
|
|
1131
|
+
references: {
|
|
1132
|
+
model: string;
|
|
1133
|
+
field: string;
|
|
1134
|
+
onDelete: "cascade";
|
|
1135
|
+
};
|
|
1136
|
+
required: true;
|
|
1137
|
+
input: false;
|
|
1138
|
+
index: true;
|
|
1139
|
+
};
|
|
1140
|
+
refillInterval: {
|
|
1141
|
+
type: "number";
|
|
1142
|
+
required: false;
|
|
1143
|
+
input: false;
|
|
1144
|
+
};
|
|
1145
|
+
refillAmount: {
|
|
1146
|
+
type: "number";
|
|
1147
|
+
required: false;
|
|
1148
|
+
input: false;
|
|
1149
|
+
};
|
|
1150
|
+
lastRefillAt: {
|
|
1151
|
+
type: "date";
|
|
1152
|
+
required: false;
|
|
1153
|
+
input: false;
|
|
1154
|
+
};
|
|
1155
|
+
enabled: {
|
|
1156
|
+
type: "boolean";
|
|
1157
|
+
required: false;
|
|
1158
|
+
input: false;
|
|
1159
|
+
defaultValue: true;
|
|
1160
|
+
};
|
|
1161
|
+
rateLimitEnabled: {
|
|
1162
|
+
type: "boolean";
|
|
1163
|
+
required: false;
|
|
1164
|
+
input: false;
|
|
1165
|
+
defaultValue: true;
|
|
1166
|
+
};
|
|
1167
|
+
rateLimitTimeWindow: {
|
|
1168
|
+
type: "number";
|
|
1169
|
+
required: false;
|
|
1170
|
+
input: false;
|
|
1171
|
+
defaultValue: number;
|
|
1172
|
+
};
|
|
1173
|
+
rateLimitMax: {
|
|
1174
|
+
type: "number";
|
|
1175
|
+
required: false;
|
|
1176
|
+
input: false;
|
|
1177
|
+
defaultValue: number;
|
|
1178
|
+
};
|
|
1179
|
+
requestCount: {
|
|
1180
|
+
type: "number";
|
|
1181
|
+
required: false;
|
|
1182
|
+
input: false;
|
|
1183
|
+
defaultValue: number;
|
|
1184
|
+
};
|
|
1185
|
+
remaining: {
|
|
1186
|
+
type: "number";
|
|
1187
|
+
required: false;
|
|
1188
|
+
input: false;
|
|
1189
|
+
};
|
|
1190
|
+
lastRequest: {
|
|
1191
|
+
type: "date";
|
|
1192
|
+
required: false;
|
|
1193
|
+
input: false;
|
|
1194
|
+
};
|
|
1195
|
+
expiresAt: {
|
|
1196
|
+
type: "date";
|
|
1197
|
+
required: false;
|
|
1198
|
+
input: false;
|
|
1199
|
+
};
|
|
1200
|
+
createdAt: {
|
|
1201
|
+
type: "date";
|
|
1202
|
+
required: true;
|
|
1203
|
+
input: false;
|
|
1204
|
+
};
|
|
1205
|
+
updatedAt: {
|
|
1206
|
+
type: "date";
|
|
1207
|
+
required: true;
|
|
1208
|
+
input: false;
|
|
1209
|
+
};
|
|
1210
|
+
permissions: {
|
|
1211
|
+
type: "string";
|
|
1212
|
+
required: false;
|
|
1213
|
+
input: false;
|
|
1214
|
+
};
|
|
1215
|
+
metadata: {
|
|
1216
|
+
type: "string";
|
|
1217
|
+
required: false;
|
|
1218
|
+
input: true;
|
|
1219
|
+
transform: {
|
|
1220
|
+
input(value: import("better-auth").DBPrimitive): string;
|
|
1221
|
+
output(value: import("better-auth").DBPrimitive): any;
|
|
1222
|
+
};
|
|
1223
|
+
};
|
|
1224
|
+
};
|
|
1225
|
+
};
|
|
1226
|
+
};
|
|
1227
|
+
options: import("better-auth/plugins").ApiKeyOptions | undefined;
|
|
1228
|
+
}>;
|
|
1229
|
+
pathMethods: {
|
|
1230
|
+
"/api-key/create": "POST";
|
|
1231
|
+
"/api-key/delete": "POST";
|
|
1232
|
+
"/api-key/delete-all-expired-api-keys": "POST";
|
|
1233
|
+
};
|
|
1234
|
+
})[];
|
|
1235
|
+
/**
|
|
1236
|
+
* Create a pre-configured Auth client.
|
|
1237
|
+
*
|
|
1238
|
+
* This factory provides sensible defaults for Agentuity projects:
|
|
1239
|
+
* - Uses `/api/auth` as the default base path
|
|
1240
|
+
* - Automatically uses `window.location.origin` as base URL in browsers
|
|
1241
|
+
* - Includes organization and API key plugins by default
|
|
1242
|
+
*
|
|
1243
|
+
* @example Basic usage (zero config)
|
|
1244
|
+
* ```typescript
|
|
1245
|
+
* import { createAuthClient } from '@agentuity/auth/react';
|
|
1246
|
+
*
|
|
1247
|
+
* export const authClient = createAuthClient();
|
|
1248
|
+
* export const { signIn, signUp, signOut, useSession, getSession } = authClient;
|
|
1249
|
+
* ```
|
|
1250
|
+
*
|
|
1251
|
+
* @example With custom base path
|
|
1252
|
+
* ```typescript
|
|
1253
|
+
* export const authClient = createAuthClient({
|
|
1254
|
+
* basePath: '/auth', // If mounted at /auth instead of /api/auth
|
|
1255
|
+
* });
|
|
1256
|
+
* ```
|
|
1257
|
+
*
|
|
1258
|
+
* @example With additional plugins
|
|
1259
|
+
* ```typescript
|
|
1260
|
+
* import { twoFactorClient } from 'better-auth/client/plugins';
|
|
1261
|
+
*
|
|
1262
|
+
* export const authClient = createAuthClient({
|
|
1263
|
+
* plugins: [twoFactorClient()],
|
|
1264
|
+
* });
|
|
1265
|
+
* ```
|
|
1266
|
+
*
|
|
1267
|
+
* @example With custom plugins only (no defaults)
|
|
1268
|
+
* ```typescript
|
|
1269
|
+
* import { organizationClient } from 'better-auth/client/plugins';
|
|
1270
|
+
*
|
|
1271
|
+
* export const authClient = createAuthClient({
|
|
1272
|
+
* skipDefaultPlugins: true,
|
|
1273
|
+
* plugins: [organizationClient()],
|
|
1274
|
+
* });
|
|
1275
|
+
* ```
|
|
1276
|
+
*/
|
|
1277
|
+
export declare function createAuthClient<TPlugins extends BetterAuthClientPlugin[] = []>(options?: AuthClientOptions<TPlugins>): ReturnType<typeof createBetterAuthClient<{
|
|
1278
|
+
plugins: TPlugins;
|
|
1279
|
+
}>>;
|
|
1280
|
+
/**
|
|
1281
|
+
* Type helper for the auth client return type.
|
|
1282
|
+
*/
|
|
1283
|
+
export type AuthClient = ReturnType<typeof createAuthClient>;
|
|
1284
|
+
/**
|
|
1285
|
+
* Context value for Auth.
|
|
1286
|
+
*/
|
|
1287
|
+
export interface AuthContextValue {
|
|
1288
|
+
/** The auth client instance */
|
|
1289
|
+
authClient: AuthClient;
|
|
1290
|
+
/** Current authenticated user, or null if not signed in */
|
|
1291
|
+
user: AuthUser | null;
|
|
1292
|
+
/** Current session object (if available) */
|
|
1293
|
+
session: AuthSession | null;
|
|
1294
|
+
/** Whether the auth state is still loading */
|
|
1295
|
+
isPending: boolean;
|
|
1296
|
+
/** Any error that occurred while fetching auth state */
|
|
1297
|
+
error: Error | null;
|
|
1298
|
+
/** Whether the user is authenticated */
|
|
1299
|
+
isAuthenticated: boolean;
|
|
1300
|
+
}
|
|
1301
|
+
export interface AuthProviderProps {
|
|
1302
|
+
/** React children to render */
|
|
1303
|
+
children: React.ReactNode;
|
|
1304
|
+
/**
|
|
1305
|
+
* The auth client instance created with createAuthClient().
|
|
1306
|
+
* Required for session management.
|
|
1307
|
+
*/
|
|
1308
|
+
authClient: AuthClient;
|
|
1309
|
+
/**
|
|
1310
|
+
* Token refresh interval in milliseconds.
|
|
1311
|
+
* Defaults to 60000 (1 minute).
|
|
1312
|
+
*/
|
|
1313
|
+
refreshInterval?: number;
|
|
1314
|
+
/**
|
|
1315
|
+
* Override the token endpoint path.
|
|
1316
|
+
* Defaults to '/token' (relative to the auth client's basePath).
|
|
1317
|
+
* Set to `false` to disable token fetching entirely.
|
|
1318
|
+
*
|
|
1319
|
+
* @example Custom token endpoint
|
|
1320
|
+
* ```tsx
|
|
1321
|
+
* <AuthProvider authClient={authClient} tokenEndpoint="/api/custom/jwt">
|
|
1322
|
+
* ```
|
|
1323
|
+
*
|
|
1324
|
+
* @example Disable token fetching
|
|
1325
|
+
* ```tsx
|
|
1326
|
+
* <AuthProvider authClient={authClient} tokenEndpoint={false}>
|
|
1327
|
+
* ```
|
|
1328
|
+
*/
|
|
1329
|
+
tokenEndpoint?: string | false;
|
|
1330
|
+
}
|
|
1331
|
+
/**
|
|
1332
|
+
* Auth provider component.
|
|
1333
|
+
*
|
|
1334
|
+
* This component integrates Auth with Agentuity's React context,
|
|
1335
|
+
* automatically injecting auth tokens into API calls via useAgent and useWebsocket.
|
|
1336
|
+
*
|
|
1337
|
+
* Must be a child of AgentuityProvider.
|
|
1338
|
+
*
|
|
1339
|
+
* @example
|
|
1340
|
+
* ```tsx
|
|
1341
|
+
* import { AgentuityProvider } from '@agentuity/react';
|
|
1342
|
+
* import { createAuthClient, AuthProvider } from '@agentuity/auth/react';
|
|
1343
|
+
*
|
|
1344
|
+
* const authClient = createAuthClient();
|
|
1345
|
+
*
|
|
1346
|
+
* <AgentuityProvider>
|
|
1347
|
+
* <AuthProvider authClient={authClient}>
|
|
1348
|
+
* <App />
|
|
1349
|
+
* </AuthProvider>
|
|
1350
|
+
* </AgentuityProvider>
|
|
1351
|
+
* ```
|
|
1352
|
+
*/
|
|
1353
|
+
export declare function AuthProvider({ children, authClient, refreshInterval, tokenEndpoint, }: AuthProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
1354
|
+
/**
|
|
1355
|
+
* Hook to access Auth state.
|
|
1356
|
+
*
|
|
1357
|
+
* This hook provides access to the current user and session.
|
|
1358
|
+
* Must be used within an AuthProvider.
|
|
1359
|
+
*
|
|
1360
|
+
* @example
|
|
1361
|
+
* ```tsx
|
|
1362
|
+
* import { useAuth } from '@agentuity/auth/react';
|
|
1363
|
+
*
|
|
1364
|
+
* function Profile() {
|
|
1365
|
+
* const { user, session, isPending, isAuthenticated } = useAuth();
|
|
1366
|
+
*
|
|
1367
|
+
* if (isPending) return <div>Loading...</div>;
|
|
1368
|
+
* if (!isAuthenticated) return <div>Not signed in</div>;
|
|
1369
|
+
*
|
|
1370
|
+
* return <div>Welcome, {user.name}!</div>;
|
|
1371
|
+
* }
|
|
1372
|
+
* ```
|
|
1373
|
+
*/
|
|
1374
|
+
export declare function useAuth(): AuthContextValue;
|
|
1375
|
+
//# sourceMappingURL=react.d.ts.map
|