@agentuity/auth 0.0.108 → 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,172 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Auth types for @agentuity/auth.
|
|
3
|
+
*
|
|
4
|
+
* @module agentuity/types
|
|
5
|
+
*/
|
|
6
|
+
import type { Session as BetterAuthSession, User as BetterAuthUser } from 'better-auth';
|
|
7
|
+
import type { AgentuityAuth } from '../types';
|
|
8
|
+
/**
|
|
9
|
+
* Canonical authenticated user type for Agentuity Auth.
|
|
10
|
+
*
|
|
11
|
+
* This is an alias for BetterAuth's `User` type and represents the shape of
|
|
12
|
+
* the `user` object you receive from:
|
|
13
|
+
*
|
|
14
|
+
* - `AuthInterface#getUser()` / `c.var.auth.getUser()` on the server
|
|
15
|
+
* - `c.var.user` in Hono route handlers
|
|
16
|
+
* - React hooks and context (`useAuth().user`) in `@agentuity/auth/react`
|
|
17
|
+
*
|
|
18
|
+
* Common fields include:
|
|
19
|
+
* - `id` – Stable user identifier
|
|
20
|
+
* - `email` – Primary email address
|
|
21
|
+
* - `name` – Display name
|
|
22
|
+
* - `image` – Avatar URL (if configured)
|
|
23
|
+
* - `createdAt` / `updatedAt` – Timestamps
|
|
24
|
+
*
|
|
25
|
+
* The exact fields are defined by BetterAuth and may be extended by plugins.
|
|
26
|
+
*
|
|
27
|
+
* @remarks
|
|
28
|
+
* Prefer using this `AuthUser` alias instead of referring to BetterAuth's
|
|
29
|
+
* `User` type directly so your code stays aligned with Agentuity's auth
|
|
30
|
+
* abstractions.
|
|
31
|
+
*/
|
|
32
|
+
export type AuthUser = BetterAuthUser;
|
|
33
|
+
/**
|
|
34
|
+
* Auth session type.
|
|
35
|
+
* Extends BetterAuth's Session with organization plugin fields.
|
|
36
|
+
*/
|
|
37
|
+
export type AuthSession = BetterAuthSession & {
|
|
38
|
+
/** Active organization ID from the organization plugin */
|
|
39
|
+
activeOrganizationId?: string;
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* Auth context containing user, session, and org data.
|
|
43
|
+
* This is the full auth context available on AgentContext.auth and c.var.auth.
|
|
44
|
+
* Session may be null for API key authentication.
|
|
45
|
+
*/
|
|
46
|
+
export interface AuthContext<TUser = AuthUser, TSession = AuthSession | null> {
|
|
47
|
+
user: TUser;
|
|
48
|
+
session: TSession;
|
|
49
|
+
org: AuthOrgContext | null;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Organization context from the organization plugin.
|
|
53
|
+
*/
|
|
54
|
+
export interface AuthOrgContext {
|
|
55
|
+
/** Organization ID */
|
|
56
|
+
id: string;
|
|
57
|
+
/** Organization slug (URL-friendly identifier) */
|
|
58
|
+
slug?: string | null;
|
|
59
|
+
/** Organization display name */
|
|
60
|
+
name?: string | null;
|
|
61
|
+
/** Member's role in this organization (e.g., 'owner', 'admin', 'member') */
|
|
62
|
+
role?: string | null;
|
|
63
|
+
/** Member ID for this user in this organization */
|
|
64
|
+
memberId?: string | null;
|
|
65
|
+
/** Organization metadata (if enabled) */
|
|
66
|
+
metadata?: unknown;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* API key permissions format.
|
|
70
|
+
* Maps resource names to arrays of allowed actions.
|
|
71
|
+
*
|
|
72
|
+
* @example
|
|
73
|
+
* ```typescript
|
|
74
|
+
* const permissions: AuthApiKeyPermissions = {
|
|
75
|
+
* project: ['read', 'write'],
|
|
76
|
+
* user: ['read'],
|
|
77
|
+
* admin: ['*'], // wildcard - all actions
|
|
78
|
+
* };
|
|
79
|
+
* ```
|
|
80
|
+
*/
|
|
81
|
+
export type AuthApiKeyPermissions = Record<string, string[]>;
|
|
82
|
+
/**
|
|
83
|
+
* API key context when request is authenticated via API key.
|
|
84
|
+
*/
|
|
85
|
+
export interface AuthApiKeyContext {
|
|
86
|
+
/** API key ID */
|
|
87
|
+
id: string;
|
|
88
|
+
/** Display name of the API key */
|
|
89
|
+
name?: string | null;
|
|
90
|
+
/** Permissions associated with this API key */
|
|
91
|
+
permissions: AuthApiKeyPermissions;
|
|
92
|
+
/** User ID the API key belongs to */
|
|
93
|
+
userId?: string | null;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Authentication method used for the current request.
|
|
97
|
+
*/
|
|
98
|
+
export type AuthMethod = 'session' | 'api-key' | 'bearer';
|
|
99
|
+
/**
|
|
100
|
+
* Organization helpers available on the auth context.
|
|
101
|
+
*/
|
|
102
|
+
export interface AuthOrgHelpers {
|
|
103
|
+
/** Active organization context if available, null otherwise */
|
|
104
|
+
org: AuthOrgContext | null;
|
|
105
|
+
/** Returns active org or null (never throws) */
|
|
106
|
+
getOrg(): Promise<AuthOrgContext | null>;
|
|
107
|
+
/** Convenience accessor for the member's role on the active org */
|
|
108
|
+
getOrgRole(): Promise<string | null>;
|
|
109
|
+
/** True if the current member's role is one of the provided roles */
|
|
110
|
+
hasOrgRole(...roles: string[]): Promise<boolean>;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* API key helpers available on the auth context.
|
|
114
|
+
*/
|
|
115
|
+
export interface AuthApiKeyHelpers {
|
|
116
|
+
/** How this request was authenticated */
|
|
117
|
+
authMethod: AuthMethod;
|
|
118
|
+
/** API key context when request is authenticated via API key, null otherwise */
|
|
119
|
+
apiKey: AuthApiKeyContext | null;
|
|
120
|
+
/**
|
|
121
|
+
* Check if the API key has the required permissions.
|
|
122
|
+
* All specified actions must be present for the resource.
|
|
123
|
+
* Supports '*' wildcard which matches any action.
|
|
124
|
+
*
|
|
125
|
+
* @param resource - The resource to check (e.g., 'project', 'user')
|
|
126
|
+
* @param actions - Actions required (e.g., 'read', 'write')
|
|
127
|
+
* @returns true if all actions are permitted, false otherwise
|
|
128
|
+
*
|
|
129
|
+
* @example
|
|
130
|
+
* ```typescript
|
|
131
|
+
* // Check for specific permission
|
|
132
|
+
* if (c.var.auth.hasPermission('project', 'write')) { ... }
|
|
133
|
+
*
|
|
134
|
+
* // Check for multiple permissions (all required)
|
|
135
|
+
* if (c.var.auth.hasPermission('project', 'read', 'write')) { ... }
|
|
136
|
+
* ```
|
|
137
|
+
*/
|
|
138
|
+
hasPermission(resource: string, ...actions: string[]): boolean;
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Full authentication interface available on `c.var.auth` and `ctx.auth`.
|
|
142
|
+
*
|
|
143
|
+
* This is the primary interface you'll use to access authentication data
|
|
144
|
+
* in your route handlers and agents. It provides:
|
|
145
|
+
*
|
|
146
|
+
* - User data via `getUser()`
|
|
147
|
+
* - Organization helpers via `getOrg()`, `getOrgRole()`, `hasOrgRole()`
|
|
148
|
+
* - API key helpers via `apiKey`, `hasPermission()`
|
|
149
|
+
* - Token access via `getToken()`
|
|
150
|
+
*
|
|
151
|
+
* @example Route handler
|
|
152
|
+
* ```typescript
|
|
153
|
+
* app.get('/api/profile', async (c) => {
|
|
154
|
+
* const user = await c.var.auth.getUser();
|
|
155
|
+
* const org = await c.var.auth.getOrg();
|
|
156
|
+
* return c.json({ user, org });
|
|
157
|
+
* });
|
|
158
|
+
* ```
|
|
159
|
+
*
|
|
160
|
+
* @example Agent handler
|
|
161
|
+
* ```typescript
|
|
162
|
+
* handler: async (ctx, input) => {
|
|
163
|
+
* if (!ctx.auth) return { error: 'Unauthorized' };
|
|
164
|
+
* const user = await ctx.auth.getUser();
|
|
165
|
+
* return { message: `Hello, ${user.email}!` };
|
|
166
|
+
* }
|
|
167
|
+
* ```
|
|
168
|
+
*
|
|
169
|
+
* @typeParam TUser - User type (defaults to AuthUser)
|
|
170
|
+
*/
|
|
171
|
+
export type AuthInterface<TUser = AuthUser> = AgentuityAuth<TUser, AuthContext> & AuthOrgHelpers & AuthApiKeyHelpers;
|
|
172
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/agentuity/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,OAAO,IAAI,iBAAiB,EAAE,IAAI,IAAI,cAAc,EAAE,MAAM,aAAa,CAAC;AACxF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAM9C;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,MAAM,QAAQ,GAAG,cAAc,CAAC;AAEtC;;;GAGG;AACH,MAAM,MAAM,WAAW,GAAG,iBAAiB,GAAG;IAC7C,0DAA0D;IAC1D,oBAAoB,CAAC,EAAE,MAAM,CAAC;CAC9B,CAAC;AAEF;;;;GAIG;AACH,MAAM,WAAW,WAAW,CAAC,KAAK,GAAG,QAAQ,EAAE,QAAQ,GAAG,WAAW,GAAG,IAAI;IAC3E,IAAI,EAAE,KAAK,CAAC;IACZ,OAAO,EAAE,QAAQ,CAAC;IAClB,GAAG,EAAE,cAAc,GAAG,IAAI,CAAC;CAC3B;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC9B,sBAAsB;IACtB,EAAE,EAAE,MAAM,CAAC;IACX,kDAAkD;IAClD,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,gCAAgC;IAChC,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,4EAA4E;IAC5E,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,mDAAmD;IACnD,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,yCAAyC;IACzC,QAAQ,CAAC,EAAE,OAAO,CAAC;CACnB;AAMD;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,qBAAqB,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;AAE7D;;GAEG;AACH,MAAM,WAAW,iBAAiB;IACjC,iBAAiB;IACjB,EAAE,EAAE,MAAM,CAAC;IACX,kCAAkC;IAClC,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,+CAA+C;IAC/C,WAAW,EAAE,qBAAqB,CAAC;IACnC,qCAAqC;IACrC,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACvB;AAED;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG,SAAS,GAAG,SAAS,GAAG,QAAQ,CAAC;AAM1D;;GAEG;AACH,MAAM,WAAW,cAAc;IAC9B,+DAA+D;IAC/D,GAAG,EAAE,cAAc,GAAG,IAAI,CAAC;IAE3B,gDAAgD;IAChD,MAAM,IAAI,OAAO,CAAC,cAAc,GAAG,IAAI,CAAC,CAAC;IAEzC,mEAAmE;IACnE,UAAU,IAAI,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IAErC,qEAAqE;IACrE,UAAU,CAAC,GAAG,KAAK,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CACjD;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IACjC,yCAAyC;IACzC,UAAU,EAAE,UAAU,CAAC;IAEvB,gFAAgF;IAChF,MAAM,EAAE,iBAAiB,GAAG,IAAI,CAAC;IAEjC;;;;;;;;;;;;;;;;;OAiBG;IACH,aAAa,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,OAAO,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC;CAC/D;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,MAAM,MAAM,aAAa,CAAC,KAAK,GAAG,QAAQ,IAAI,aAAa,CAAC,KAAK,EAAE,WAAW,CAAC,GAC9E,cAAc,GACd,iBAAiB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/agentuity/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,18 +1,41 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @agentuity/auth - Authentication
|
|
2
|
+
* @agentuity/auth - Authentication for Agentuity projects
|
|
3
3
|
*
|
|
4
|
-
*
|
|
4
|
+
* Provides first-class authentication powered by BetterAuth.
|
|
5
5
|
*
|
|
6
|
-
*
|
|
6
|
+
* This is the server-only entry point. For React components, import from '@agentuity/auth/react'.
|
|
7
|
+
*
|
|
8
|
+
* @example Server-side setup
|
|
7
9
|
* ```typescript
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
+
* import { createAuth, createSessionMiddleware, mountAuthRoutes } from '@agentuity/auth';
|
|
11
|
+
*
|
|
12
|
+
* const auth = createAuth({
|
|
13
|
+
* connectionString: process.env.DATABASE_URL,
|
|
14
|
+
* });
|
|
15
|
+
*
|
|
16
|
+
* api.on(['GET', 'POST'], '/api/auth/*', mountAuthRoutes(auth));
|
|
17
|
+
* api.use('/api/*', createSessionMiddleware(auth));
|
|
18
|
+
* ```
|
|
19
|
+
*
|
|
20
|
+
* @example Client-side setup
|
|
21
|
+
* ```tsx
|
|
22
|
+
* import { createAuthClient, AuthProvider } from '@agentuity/auth/react';
|
|
23
|
+
*
|
|
24
|
+
* const authClient = createAuthClient();
|
|
10
25
|
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
26
|
+
* <AgentuityProvider>
|
|
27
|
+
* <AuthProvider authClient={authClient}>
|
|
28
|
+
* <App />
|
|
29
|
+
* </AuthProvider>
|
|
30
|
+
* </AgentuityProvider>
|
|
13
31
|
* ```
|
|
14
32
|
*
|
|
15
33
|
* @module @agentuity/auth
|
|
16
34
|
*/
|
|
17
|
-
export
|
|
35
|
+
export { createAuth, getDefaultPlugins, DEFAULT_API_KEY_OPTIONS } from './agentuity/config';
|
|
36
|
+
export type { AuthOptions, AuthInstance, AuthBase, ApiKeyPluginOptions, OrganizationApiMethods, ApiKeyApiMethods, JwtApiMethods, DefaultPluginApiMethods, } from './agentuity/config';
|
|
37
|
+
export { createSessionMiddleware, createApiKeyMiddleware, mountAuthRoutes, } from './agentuity/server';
|
|
38
|
+
export type { AuthMiddlewareOptions, ApiKeyMiddlewareOptions, AuthEnv, OtelSpansConfig, MountAuthRoutesOptions, } from './agentuity/server';
|
|
39
|
+
export type { AuthContext, AuthOrgContext, AuthApiKeyContext, AuthApiKeyPermissions, AuthMethod, AuthOrgHelpers, AuthApiKeyHelpers, AuthInterface, AuthUser, AuthSession, } from './agentuity/types';
|
|
40
|
+
export type { AgentuityAuth } from './types';
|
|
18
41
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAMH,OAAO,EAAE,UAAU,EAAE,iBAAiB,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;AAC5F,YAAY,EACX,WAAW,EACX,YAAY,EACZ,QAAQ,EACR,mBAAmB,EACnB,sBAAsB,EACtB,gBAAgB,EAChB,aAAa,EACb,uBAAuB,GACvB,MAAM,oBAAoB,CAAC;AAM5B,OAAO,EACN,uBAAuB,EACvB,sBAAsB,EACtB,eAAe,GACf,MAAM,oBAAoB,CAAC;AAC5B,YAAY,EACX,qBAAqB,EACrB,uBAAuB,EACvB,OAAO,EACP,eAAe,EACf,sBAAsB,GACtB,MAAM,oBAAoB,CAAC;AAM5B,YAAY,EACX,WAAW,EACX,cAAc,EACd,iBAAiB,EACjB,qBAAqB,EACrB,UAAU,EACV,cAAc,EACd,iBAAiB,EACjB,aAAa,EACb,QAAQ,EACR,WAAW,GACX,MAAM,mBAAmB,CAAC;AAE3B,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,18 +1,43 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @agentuity/auth - Authentication
|
|
2
|
+
* @agentuity/auth - Authentication for Agentuity projects
|
|
3
3
|
*
|
|
4
|
-
*
|
|
4
|
+
* Provides first-class authentication powered by BetterAuth.
|
|
5
5
|
*
|
|
6
|
-
*
|
|
6
|
+
* This is the server-only entry point. For React components, import from '@agentuity/auth/react'.
|
|
7
|
+
*
|
|
8
|
+
* @example Server-side setup
|
|
7
9
|
* ```typescript
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
+
* import { createAuth, createSessionMiddleware, mountAuthRoutes } from '@agentuity/auth';
|
|
11
|
+
*
|
|
12
|
+
* const auth = createAuth({
|
|
13
|
+
* connectionString: process.env.DATABASE_URL,
|
|
14
|
+
* });
|
|
15
|
+
*
|
|
16
|
+
* api.on(['GET', 'POST'], '/api/auth/*', mountAuthRoutes(auth));
|
|
17
|
+
* api.use('/api/*', createSessionMiddleware(auth));
|
|
18
|
+
* ```
|
|
19
|
+
*
|
|
20
|
+
* @example Client-side setup
|
|
21
|
+
* ```tsx
|
|
22
|
+
* import { createAuthClient, AuthProvider } from '@agentuity/auth/react';
|
|
23
|
+
*
|
|
24
|
+
* const authClient = createAuthClient();
|
|
10
25
|
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
26
|
+
* <AgentuityProvider>
|
|
27
|
+
* <AuthProvider authClient={authClient}>
|
|
28
|
+
* <App />
|
|
29
|
+
* </AuthProvider>
|
|
30
|
+
* </AgentuityProvider>
|
|
13
31
|
* ```
|
|
14
32
|
*
|
|
15
33
|
* @module @agentuity/auth
|
|
16
34
|
*/
|
|
17
|
-
|
|
35
|
+
// =============================================================================
|
|
36
|
+
// Config
|
|
37
|
+
// =============================================================================
|
|
38
|
+
export { createAuth, getDefaultPlugins, DEFAULT_API_KEY_OPTIONS } from './agentuity/config';
|
|
39
|
+
// =============================================================================
|
|
40
|
+
// Server (Hono middleware and handlers)
|
|
41
|
+
// =============================================================================
|
|
42
|
+
export { createSessionMiddleware, createApiKeyMiddleware, mountAuthRoutes, } from './agentuity/server';
|
|
18
43
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAEH,gFAAgF;AAChF,SAAS;AACT,gFAAgF;AAEhF,OAAO,EAAE,UAAU,EAAE,iBAAiB,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;AAY5F,gFAAgF;AAChF,wCAAwC;AACxC,gFAAgF;AAEhF,OAAO,EACN,uBAAuB,EACvB,sBAAsB,EACtB,eAAe,GACf,MAAM,oBAAoB,CAAC"}
|