@absolutejs/auth 0.54.9 → 0.55.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,18 +1,5 @@
1
1
  import { Elysia } from 'elysia';
2
- import { agentAuthPlugin } from './agents/routes';
3
- import { protectRoutePlugin } from './routes/protectRoute';
4
- import { stepUpPlugin } from './routes/stepUp';
5
2
  import { AuthConfig } from './types';
6
- /** The minimal reference instance capturing ONLY the global, consumer-facing
7
- * context `auth()` contributes: the `protectRoute` + step-up derives, typed by
8
- * `UserType`. `auth()` also mounts ~28 route plugins, but their paths are
9
- * CONFIGURABLE (`authorizeRoute`, `callbackRoute`, …), so Elysia keys those
10
- * routes by `string` — there is no literal route type to expose, and inferring
11
- * the whole chain trips TS7056 / a 2^N union blow-up. This typed context is the
12
- * precise surface consumers actually use (`protectRoute((user) => …)` yields
13
- * `UserType`); the routes are reached by path at runtime / direct fetch. */
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;
15
- export type AuthInstance<UserType> = MergeAuthContext<MergeAuthContext<ReturnType<typeof protectRoutePlugin<UserType>>, ReturnType<typeof stepUpPlugin<UserType>>>, ReturnType<typeof agentAuthPlugin>>;
16
3
  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<"", {
17
4
  decorator: {};
18
5
  store: {
@@ -45,12 +32,7 @@ export declare const auth: <UserType>({ providersConfiguration, authorizeRoute,
45
32
  } & {
46
33
  decorator: {};
47
34
  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
- };
35
+ derive: {};
54
36
  resolve: {};
55
37
  }, {
56
38
  typebox: {};
@@ -96,56 +78,26 @@ export declare const auth: <UserType>({ providersConfiguration, authorizeRoute,
96
78
  macro: {};
97
79
  macroFn: {};
98
80
  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
- }>;
81
+ response: {};
105
82
  }, {}, {
106
83
  derive: {};
107
84
  resolve: {};
108
85
  schema: {};
109
86
  standaloneSchema: {};
110
87
  response: {};
111
- }, {
88
+ } & {
112
89
  derive: {};
113
90
  resolve: {};
114
91
  schema: {};
115
92
  standaloneSchema: {};
116
93
  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
- };
94
+ }, {
95
+ derive: {};
145
96
  resolve: {};
97
+ schema: {};
98
+ standaloneSchema: {};
99
+ response: {};
146
100
  } & {
147
- decorator: {};
148
- store: {};
149
101
  derive: {
150
102
  readonly protectAgent: <AuthReturn, AuthFailReturn_2>(requiredScopes: string[], handleAuth: (principal: import(".").AgentPrincipal) => AuthReturn | Promise<AuthReturn>, handleAuthFail?: (error: {
151
103
  code: "Forbidden" | "Unauthorized";
@@ -153,89 +105,17 @@ export declare const auth: <UserType>({ providersConfiguration, authorizeRoute,
153
105
  }) => AuthFailReturn_2 | Promise<AuthFailReturn_2>) => Promise<Response | AuthReturn | NonNullable<Awaited<AuthFailReturn_2>>>;
154
106
  };
155
107
  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
108
  schema: {};
196
109
  standaloneSchema: {};
197
- macro: {};
198
- macroFn: {};
199
- parser: {};
200
110
  response: import("elysia").ExtractErrorFromHandle<{
201
111
  readonly protectAgent: <AuthReturn, AuthFailReturn_2>(requiredScopes: string[], handleAuth: (principal: import(".").AgentPrincipal) => AuthReturn | Promise<AuthReturn>, handleAuthFail?: (error: {
202
112
  code: "Forbidden" | "Unauthorized";
203
113
  message: "Agent is not authenticated" | "Insufficient agent scopes";
204
114
  }) => AuthFailReturn_2 | Promise<AuthFailReturn_2>) => Promise<Response | AuthReturn | NonNullable<Awaited<AuthFailReturn_2>>>;
205
115
  }>;
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: {};
237
116
  }>>;
238
117
  export * from './actions';
118
+ export type { AuthInstance } from './authInstance';
239
119
  export * from './types';
240
120
  export * from './typebox';
241
121
  export * from './vault/config';
@@ -355,11 +235,14 @@ export * from './apikeys/types';
355
235
  export { apiKeysRoutes } from './apikeys/routes';
356
236
  export * from './agents/config';
357
237
  export * from './agents/types';
238
+ export * from './agents/registration';
239
+ export * from './agents/registrationClient';
240
+ export * from './agents/idJag';
358
241
  export { agentAuthPlugin, agentAuthChallenge } from './agents/routes';
359
242
  export { resolveAgentPrincipal, agentHasScopes } from './agents/principal';
360
243
  export { createOidcAgentCredentialVerifier } from './agents/oidcAdapter';
361
- export { createInMemoryAgentDelegationStore, createInMemoryAgentRegistrationStore } from './agents/inMemoryStores';
362
- export { agentDelegationsTable, agentRegistrationsTable, createNeonAgentDelegationStore, createNeonAgentRegistrationStore, createPostgresAgentDelegationStore, createPostgresAgentRegistrationStore } from './agents/postgresStores';
244
+ export { createInMemoryAgentDelegationStore, createInMemoryAgentIdentityRegistrationStore, createInMemoryAgentRegistrationStore } from './agents/inMemoryStores';
245
+ export { agentDelegationsTable, agentIdentityRegistrationsTable, agentRegistrationsTable, createNeonAgentDelegationStore, createNeonAgentIdentityRegistrationStore, createNeonAgentRegistrationStore, createPostgresAgentDelegationStore, createPostgresAgentIdentityRegistrationStore, createPostgresAgentRegistrationStore } from './agents/postgresStores';
363
246
  export { createInMemoryAccessTokenStore, createInMemoryApiClientStore, createInMemoryApiKeyStore } from './apikeys/inMemoryStores';
364
247
  export { accessTokensTable, apiClientsTable, apiKeysTable, createNeonAccessTokenStore, createNeonApiClientStore, createNeonApiKeyStore, createPostgresAccessTokenStore, createPostgresApiClientStore, createPostgresApiKeyStore } from './apikeys/postgresStores';
365
248
  export * from './oidc/config';