@absolutejs/auth 0.54.5 → 0.54.7

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/dist/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { Elysia } from 'elysia';
2
+ import { agentAuthPlugin } from './agents/routes';
2
3
  import { protectRoutePlugin } from './routes/protectRoute';
3
4
  import { stepUpPlugin } from './routes/stepUp';
4
5
  import { AuthConfig } from './types';
@@ -11,8 +12,8 @@ import { AuthConfig } from './types';
11
12
  * precise surface consumers actually use (`protectRoute((user) => …)` yields
12
13
  * `UserType`); the routes are reached by path at runtime / direct fetch. */
13
14
  type MergeAuthContext<Base, Extra> = Base extends Elysia<infer Path, infer Singleton, infer Definitions, infer Metadata, infer Routes, infer Ephemeral, infer Volatile> ? Extra extends Elysia<infer ExtraPath, infer ExtraSingleton, infer ExtraDefinitions, infer ExtraMetadata, infer ExtraRoutes, infer ExtraEphemeral, infer ExtraVolatile> ? Elysia<Path & ExtraPath, Singleton & ExtraSingleton, Definitions & ExtraDefinitions, Metadata & ExtraMetadata, Routes & ExtraRoutes, Ephemeral & ExtraEphemeral, Volatile & ExtraVolatile> : never : never;
14
- export type AuthInstance<UserType> = MergeAuthContext<ReturnType<typeof protectRoutePlugin<UserType>>, ReturnType<typeof stepUpPlugin<UserType>>>;
15
- export declare const auth: <UserType>({ providersConfiguration, authorizeRoute, cookieSecure, callbackRoute, profileRoute, signoutRoute, statusRoute, refreshRoute, revokeRoute, cleanupIntervalMs, maxSessions, sessionDurationMs, authSessionStore, audit, credentials, customProviders, mfa, passwordless, lockout, sessions, sso, scim, apikeys, oidc, organizations, roles, portal, authorization, compliance, webauthn, webhooks, htmx, tracing, resolveAuthIntent, onAuthorizeSuccess, onAuthorizeError, onProfileSuccess, onProfileError, onCallbackSuccess, onLinkIdentity, onLinkIdentityConflict, onLinkConnector, onCallbackError, onStatus, onRefreshSuccess, onRefreshError, onSignOut, onRevocationSuccess, onRevocationError, onSessionCleanup }: AuthConfig<UserType>) => Promise<Elysia<"", {
15
+ export type AuthInstance<UserType> = MergeAuthContext<MergeAuthContext<ReturnType<typeof protectRoutePlugin<UserType>>, ReturnType<typeof stepUpPlugin<UserType>>>, ReturnType<typeof agentAuthPlugin>>;
16
+ export declare const auth: <UserType>({ providersConfiguration, authorizeRoute, cookieSecure, callbackRoute, profileRoute, signoutRoute, statusRoute, refreshRoute, revokeRoute, cleanupIntervalMs, maxSessions, sessionDurationMs, authSessionStore, audit, credentials, customProviders, mfa, passwordless, lockout, sessions, sso, scim, apikeys, agentAuth, oidc, organizations, roles, portal, authorization, compliance, webauthn, webhooks, htmx, tracing, resolveAuthIntent, onAuthorizeSuccess, onAuthorizeError, onProfileSuccess, onProfileError, onCallbackSuccess, onLinkIdentity, onLinkIdentityConflict, onLinkConnector, onCallbackError, onStatus, onRefreshSuccess, onRefreshError, onSignOut, onRevocationSuccess, onRevocationError, onSessionCleanup }: AuthConfig<UserType>) => Promise<Elysia<"", {
16
17
  decorator: {};
17
18
  store: {
18
19
  session: import("./types").SessionRecord<UserType>;
@@ -41,6 +42,16 @@ export declare const auth: <UserType>({ providersConfiguration, authorizeRoute,
41
42
  }) => AuthFailReturn_1) | undefined) => Promise<import("elysia").ElysiaCustomStatusResponse<"Unauthorized", "Recent authentication required", 401> | AuthReturn | NonNullable<AuthFailReturn_1>>;
42
43
  };
43
44
  resolve: {};
45
+ } & {
46
+ decorator: {};
47
+ store: {};
48
+ derive: {
49
+ readonly protectAgent: <AuthReturn, AuthFailReturn_2>(requiredScopes: string[], handleAuth: (principal: import(".").AgentPrincipal) => AuthReturn | Promise<AuthReturn>, handleAuthFail?: (error: {
50
+ code: "Forbidden" | "Unauthorized";
51
+ message: "Agent is not authenticated" | "Insufficient agent scopes";
52
+ }) => AuthFailReturn_2 | Promise<AuthFailReturn_2>) => Promise<Response | AuthReturn | NonNullable<Awaited<AuthFailReturn_2>>>;
53
+ };
54
+ resolve: {};
44
55
  }, {
45
56
  typebox: {};
46
57
  error: {};
@@ -79,6 +90,18 @@ export declare const auth: <UserType>({ providersConfiguration, authorizeRoute,
79
90
  readonly message: "Recent authentication required";
80
91
  }) => AuthFailReturn_1) | undefined) => Promise<import("elysia").ElysiaCustomStatusResponse<"Unauthorized", "Recent authentication required", 401> | AuthReturn | NonNullable<AuthFailReturn_1>>;
81
92
  }>;
93
+ } & {
94
+ schema: {};
95
+ standaloneSchema: {};
96
+ macro: {};
97
+ macroFn: {};
98
+ parser: {};
99
+ response: import("elysia").ExtractErrorFromHandle<{
100
+ readonly protectAgent: <AuthReturn, AuthFailReturn_2>(requiredScopes: string[], handleAuth: (principal: import(".").AgentPrincipal) => AuthReturn | Promise<AuthReturn>, handleAuthFail?: (error: {
101
+ code: "Forbidden" | "Unauthorized";
102
+ message: "Agent is not authenticated" | "Insufficient agent scopes";
103
+ }) => AuthFailReturn_2 | Promise<AuthFailReturn_2>) => Promise<Response | AuthReturn | NonNullable<Awaited<AuthFailReturn_2>>>;
104
+ }>;
82
105
  }, {}, {
83
106
  derive: {};
84
107
  resolve: {};
@@ -91,6 +114,126 @@ export declare const auth: <UserType>({ providersConfiguration, authorizeRoute,
91
114
  schema: {};
92
115
  standaloneSchema: {};
93
116
  response: {};
117
+ }> | Elysia<"", {
118
+ decorator: {};
119
+ store: {
120
+ session: import("./types").SessionRecord<UserType>;
121
+ unregisteredSession: import("./types").UnregisteredSessionRecord;
122
+ };
123
+ derive: {
124
+ readonly protectRoute: <AuthReturn, AuthFailReturn>(handleAuth: (user: UserType) => AuthReturn | Promise<AuthReturn>, handleAuthFail?: ((error: {
125
+ readonly code: "Bad Request";
126
+ readonly message: "Cookies are missing";
127
+ } | {
128
+ readonly code: "Unauthorized";
129
+ readonly message: "User is not authenticated";
130
+ }) => AuthFailReturn) | undefined) => Promise<import("elysia").ElysiaCustomStatusResponse<"Bad Request", "Cookies are missing", 400> | import("elysia").ElysiaCustomStatusResponse<"Unauthorized", "User is not authenticated", 401> | AuthReturn | NonNullable<AuthFailReturn>>;
131
+ };
132
+ resolve: {};
133
+ } & {
134
+ decorator: {};
135
+ store: {
136
+ session: import("./types").SessionRecord<UserType>;
137
+ unregisteredSession: import("./types").UnregisteredSessionRecord;
138
+ };
139
+ derive: {
140
+ readonly requireRecentAuth: <AuthReturn, AuthFailReturn_1>(maxAgeMs: number, handleAuth: (user: UserType) => AuthReturn | Promise<AuthReturn>, handleAuthFail?: ((error: {
141
+ readonly code: "Unauthorized";
142
+ readonly message: "Recent authentication required";
143
+ }) => AuthFailReturn_1) | undefined) => Promise<import("elysia").ElysiaCustomStatusResponse<"Unauthorized", "Recent authentication required", 401> | AuthReturn | NonNullable<AuthFailReturn_1>>;
144
+ };
145
+ resolve: {};
146
+ } & {
147
+ decorator: {};
148
+ store: {};
149
+ derive: {
150
+ readonly protectAgent: <AuthReturn, AuthFailReturn_2>(requiredScopes: string[], handleAuth: (principal: import(".").AgentPrincipal) => AuthReturn | Promise<AuthReturn>, handleAuthFail?: (error: {
151
+ code: "Forbidden" | "Unauthorized";
152
+ message: "Agent is not authenticated" | "Insufficient agent scopes";
153
+ }) => AuthFailReturn_2 | Promise<AuthFailReturn_2>) => Promise<Response | AuthReturn | NonNullable<Awaited<AuthFailReturn_2>>>;
154
+ };
155
+ resolve: {};
156
+ }, {
157
+ typebox: {};
158
+ error: {};
159
+ }, {
160
+ schema: import("elysia").UnwrapRoute<{
161
+ cookie: import("@sinclair/typebox").TObject<{
162
+ user_session_id: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TTemplateLiteralSyntax<"${string}-${string}-${string}-${string}-${string}">>;
163
+ }>;
164
+ }, {}, "">;
165
+ standaloneSchema: {};
166
+ macro: {};
167
+ macroFn: {};
168
+ parser: {};
169
+ response: import("elysia").ExtractErrorFromHandle<{
170
+ readonly protectRoute: <AuthReturn, AuthFailReturn>(handleAuth: (user: UserType) => AuthReturn | Promise<AuthReturn>, handleAuthFail?: ((error: {
171
+ readonly code: "Bad Request";
172
+ readonly message: "Cookies are missing";
173
+ } | {
174
+ readonly code: "Unauthorized";
175
+ readonly message: "User is not authenticated";
176
+ }) => AuthFailReturn) | undefined) => Promise<import("elysia").ElysiaCustomStatusResponse<"Bad Request", "Cookies are missing", 400> | import("elysia").ElysiaCustomStatusResponse<"Unauthorized", "User is not authenticated", 401> | AuthReturn | NonNullable<AuthFailReturn>>;
177
+ }>;
178
+ } & {
179
+ schema: import("elysia").UnwrapRoute<{
180
+ cookie: import("@sinclair/typebox").TObject<{
181
+ user_session_id: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TTemplateLiteralSyntax<"${string}-${string}-${string}-${string}-${string}">>;
182
+ }>;
183
+ }, {}, "">;
184
+ standaloneSchema: {};
185
+ macro: {};
186
+ macroFn: {};
187
+ parser: {};
188
+ response: import("elysia").ExtractErrorFromHandle<{
189
+ readonly requireRecentAuth: <AuthReturn, AuthFailReturn_1>(maxAgeMs: number, handleAuth: (user: UserType) => AuthReturn | Promise<AuthReturn>, handleAuthFail?: ((error: {
190
+ readonly code: "Unauthorized";
191
+ readonly message: "Recent authentication required";
192
+ }) => AuthFailReturn_1) | undefined) => Promise<import("elysia").ElysiaCustomStatusResponse<"Unauthorized", "Recent authentication required", 401> | AuthReturn | NonNullable<AuthFailReturn_1>>;
193
+ }>;
194
+ } & {
195
+ schema: {};
196
+ standaloneSchema: {};
197
+ macro: {};
198
+ macroFn: {};
199
+ parser: {};
200
+ response: import("elysia").ExtractErrorFromHandle<{
201
+ readonly protectAgent: <AuthReturn, AuthFailReturn_2>(requiredScopes: string[], handleAuth: (principal: import(".").AgentPrincipal) => AuthReturn | Promise<AuthReturn>, handleAuthFail?: (error: {
202
+ code: "Forbidden" | "Unauthorized";
203
+ message: "Agent is not authenticated" | "Insufficient agent scopes";
204
+ }) => AuthFailReturn_2 | Promise<AuthFailReturn_2>) => Promise<Response | AuthReturn | NonNullable<Awaited<AuthFailReturn_2>>>;
205
+ }>;
206
+ }, {
207
+ [x: string]: {
208
+ get: {
209
+ body: unknown;
210
+ params: {};
211
+ query: unknown;
212
+ headers: unknown;
213
+ response: {
214
+ 200: {
215
+ resource: string;
216
+ scopes_supported: string[];
217
+ resource_name?: string | undefined;
218
+ resource_logo_uri?: string | undefined;
219
+ authorization_servers: string[];
220
+ bearer_methods_supported: string[];
221
+ };
222
+ };
223
+ };
224
+ };
225
+ }, {
226
+ derive: {};
227
+ resolve: {};
228
+ schema: {};
229
+ standaloneSchema: {};
230
+ response: {};
231
+ }, {
232
+ derive: {};
233
+ resolve: {};
234
+ schema: {};
235
+ standaloneSchema: {};
236
+ response: {};
94
237
  }>>;
95
238
  export * from './actions';
96
239
  export * from './types';
@@ -210,6 +353,13 @@ export { createNeonScimTokenStore, createPostgresScimTokenStore, scimTokensTable
210
353
  export * from './apikeys/config';
211
354
  export * from './apikeys/types';
212
355
  export { apiKeysRoutes } from './apikeys/routes';
356
+ export * from './agents/config';
357
+ export * from './agents/types';
358
+ export { agentAuthPlugin, agentAuthChallenge } from './agents/routes';
359
+ export { resolveAgentPrincipal, agentHasScopes } from './agents/principal';
360
+ export { createOidcAgentCredentialVerifier } from './agents/oidcAdapter';
361
+ export { createInMemoryAgentDelegationStore, createInMemoryAgentRegistrationStore } from './agents/inMemoryStores';
362
+ export { agentDelegationsTable, agentRegistrationsTable, createNeonAgentDelegationStore, createNeonAgentRegistrationStore, createPostgresAgentDelegationStore, createPostgresAgentRegistrationStore } from './agents/postgresStores';
213
363
  export { createInMemoryAccessTokenStore, createInMemoryApiClientStore, createInMemoryApiKeyStore } from './apikeys/inMemoryStores';
214
364
  export { accessTokensTable, apiClientsTable, apiKeysTable, createNeonAccessTokenStore, createNeonApiClientStore, createNeonApiKeyStore, createPostgresAccessTokenStore, createPostgresApiClientStore, createPostgresApiKeyStore } from './apikeys/postgresStores';
215
365
  export * from './oidc/config';