@absolutejs/auth 0.24.0 → 0.25.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- import type { AbsoluteAuthSessionStore } from './sessionTypes';
1
+ import type { AuthSessionStore } from './sessionTypes';
2
2
  export declare const authSessionsTable: import("drizzle-orm/pg-core").PgTableWithColumns<{
3
3
  name: "auth_sessions";
4
4
  schema: undefined;
@@ -560,4 +560,4 @@ export declare const authSessionSchema: {
560
560
  }>;
561
561
  };
562
562
  export type AuthSessionSchema = typeof authSessionSchema;
563
- export declare const createNeonAuthSessionStore: <UserType>(databaseUrl: string) => AbsoluteAuthSessionStore<UserType>;
563
+ export declare const createNeonAuthSessionStore: <UserType>(databaseUrl: string) => AuthSessionStore<UserType>;
@@ -1,5 +1,5 @@
1
1
  import { Elysia } from 'elysia';
2
- import type { AbsoluteAuthSessionStore } from './sessionTypes';
2
+ import type { AuthSessionStore } from './sessionTypes';
3
3
  type AuthFailError = {
4
4
  readonly code: 'Bad Request';
5
5
  readonly message: 'Cookies are missing';
@@ -8,7 +8,7 @@ type AuthFailError = {
8
8
  readonly message: 'User is not authenticated';
9
9
  };
10
10
  export declare const protectRoutePlugin: <UserType>({ authSessionStore }?: {
11
- authSessionStore?: AbsoluteAuthSessionStore<UserType>;
11
+ authSessionStore?: AuthSessionStore<UserType>;
12
12
  }) => Elysia<"", {
13
13
  decorator: {};
14
14
  store: {
package/dist/refresh.d.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  import { Elysia } from 'elysia';
2
- import type { AbsoluteAuthSessionStore } from './sessionTypes';
2
+ import type { AuthSessionStore } from './sessionTypes';
3
3
  import { ClientProviders, OnRefreshError, OnRefreshSuccess, RouteString } from './types';
4
4
  type RefreshProps<UserType> = {
5
- authSessionStore?: AbsoluteAuthSessionStore<UserType>;
5
+ authSessionStore?: AuthSessionStore<UserType>;
6
6
  clientProviders: ClientProviders;
7
7
  refreshRoute?: RouteString;
8
8
  onRefreshSuccess: OnRefreshSuccess;
package/dist/revoke.d.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  import { Elysia } from 'elysia';
2
- import type { AbsoluteAuthSessionStore } from './sessionTypes';
2
+ import type { AuthSessionStore } from './sessionTypes';
3
3
  import { ClientProviders, OnRevocationError, OnRevocationSuccess, RouteString } from './types';
4
4
  type RevokeProps<UserType> = {
5
- authSessionStore?: AbsoluteAuthSessionStore<UserType>;
5
+ authSessionStore?: AuthSessionStore<UserType>;
6
6
  clientProviders: ClientProviders;
7
7
  revokeRoute?: RouteString;
8
8
  onRevocationSuccess: OnRevocationSuccess;
@@ -1,14 +1,14 @@
1
1
  import type { Cookie } from 'elysia';
2
- import type { AbsoluteAuthSessionStore } from './sessionTypes';
2
+ import type { AuthSessionStore } from './sessionTypes';
3
3
  import type { SessionData, SessionRecord, UnregisteredSessionRecord, UserSessionId } from './types';
4
4
  export declare const loadSessionFromSource: <UserType>({ authSessionStore, session, userSessionId, removeExpired }: {
5
- authSessionStore?: AbsoluteAuthSessionStore<UserType>;
5
+ authSessionStore?: AuthSessionStore<UserType>;
6
6
  session?: SessionRecord<UserType>;
7
7
  userSessionId?: UserSessionId;
8
8
  removeExpired?: boolean;
9
9
  }) => Promise<SessionData<UserType> | undefined>;
10
10
  export declare const getStatusFromSource: <UserType>({ authSessionStore, session, user_session_id }: {
11
- authSessionStore?: AbsoluteAuthSessionStore<UserType>;
11
+ authSessionStore?: AuthSessionStore<UserType>;
12
12
  session?: SessionRecord<UserType>;
13
13
  user_session_id: Cookie<UserSessionId | undefined>;
14
14
  }) => Promise<{
@@ -22,7 +22,7 @@ export declare const getStatusFromSource: <UserType>({ authSessionStore, session
22
22
  user: NonNullable<UserType> | null;
23
23
  }>;
24
24
  export declare const createSessionCompatibilityLayer: <UserType>({ authSessionStore, userSessionId }: {
25
- authSessionStore?: AbsoluteAuthSessionStore<UserType>;
25
+ authSessionStore?: AuthSessionStore<UserType>;
26
26
  userSessionId?: UserSessionId;
27
27
  }) => Promise<{
28
28
  session: SessionRecord<UserType>;
@@ -1,8 +1,8 @@
1
1
  import { Elysia } from 'elysia';
2
- import type { AbsoluteAuthSessionStore } from './sessionTypes';
2
+ import type { AuthSessionStore } from './sessionTypes';
3
3
  import type { OnSessionCleanup, SessionRecord, UnregisteredSessionRecord } from './types';
4
4
  type SessionCleanupProps<UserType> = {
5
- authSessionStore?: AbsoluteAuthSessionStore<UserType>;
5
+ authSessionStore?: AuthSessionStore<UserType>;
6
6
  cleanupIntervalMs?: number;
7
7
  maxSessions?: number;
8
8
  onSessionCleanup?: OnSessionCleanup<UserType>;
@@ -1,5 +1,5 @@
1
1
  import type { SessionData, UnregisteredSessionData, UserSessionId } from './types';
2
- export type AbsoluteAuthSessionStore<UserType> = {
2
+ export type AuthSessionStore<UserType> = {
3
3
  getSession: (id: UserSessionId) => Promise<SessionData<UserType> | undefined>;
4
4
  setSession: (id: UserSessionId, value: SessionData<UserType>) => Promise<void>;
5
5
  removeSession: (id: UserSessionId) => Promise<void>;
package/dist/signout.d.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  import { Elysia } from 'elysia';
2
- import type { AbsoluteAuthSessionStore } from './sessionTypes';
2
+ import type { AuthSessionStore } from './sessionTypes';
3
3
  import { OnSignOut, RouteString } from './types';
4
4
  type SignOutProps<UserType> = {
5
- authSessionStore?: AbsoluteAuthSessionStore<UserType>;
5
+ authSessionStore?: AuthSessionStore<UserType>;
6
6
  signoutRoute?: RouteString;
7
7
  onSignOut: OnSignOut<UserType>;
8
8
  };
package/dist/types.d.ts CHANGED
@@ -2,8 +2,8 @@ import { CredentialsFor, NonEmptyArray, OAuth2Client, OAuth2TokenResponse, Provi
2
2
  import { Cookie, status as statusType, redirect as redirectType } from 'elysia';
3
3
  import { ElysiaCustomStatusResponse } from 'elysia/error';
4
4
  import type { AuthIdentityConflict } from './errors';
5
- import type { AbsoluteAuthSessionStore } from './sessionTypes';
6
- import type { AuthHtmxConfig } from './ui/types';
5
+ import type { AuthSessionStore } from './sessionTypes';
6
+ import type { AuthHtmxConfig, AuthHtmxUser } from './ui/types';
7
7
  export type AuthIntent = 'login' | 'link_identity' | 'link_connector';
8
8
  export type OAuth2ProviderClientConfiguration<Provider extends ProviderOption> = {
9
9
  credentials: CredentialsFor<Provider>;
@@ -138,7 +138,7 @@ export type OnSessionCleanup<UserType> = (({ removedSessions, removedUnregistere
138
138
  }) => void | Promise<void>) | undefined;
139
139
  export type RouteString = `/${string}`;
140
140
  export type AuthorizeRoute = `${string}/:provider${'' | `/${string}`}`;
141
- export type AbsoluteAuthProps<UserType> = {
141
+ export type AuthConfig<UserType> = {
142
142
  providersConfiguration: OAuth2ConfigurationOptions;
143
143
  authorizeRoute?: AuthorizeRoute;
144
144
  profileRoute?: RouteString;
@@ -150,12 +150,16 @@ export type AbsoluteAuthProps<UserType> = {
150
150
  cleanupIntervalMs?: number;
151
151
  maxSessions?: number;
152
152
  sessionDurationMs?: number;
153
- authSessionStore?: AbsoluteAuthSessionStore<UserType>;
153
+ authSessionStore?: AuthSessionStore<UserType>;
154
154
  /** Enable the built-in HTMX fragment routes (login, identities, connectors,
155
155
  * account, signout, delete-account). Supply provider display data + the
156
156
  * identity/connector data actions; the package owns the route wiring and
157
- * renderers. See @absolutejs/auth/ui to override individual fragments. */
158
- htmx?: AuthHtmxConfig;
157
+ * renderers. See @absolutejs/auth/ui to override individual fragments.
158
+ *
159
+ * Only available when `UserType` has the fields the fragments render
160
+ * (`sub` + optional email/name); users that don't enable HTMX are never
161
+ * constrained. */
162
+ htmx?: UserType extends AuthHtmxUser ? AuthHtmxConfig : never;
159
163
  unregisteredSessionDurationMs?: number;
160
164
  resolveAuthIntent?: ResolveAuthIntent<UserType>;
161
165
  onAuthorizeSuccess?: OnAuthorizeSuccess;
@@ -83,7 +83,7 @@ export type AuthHtmxRenderersConfig = {
83
83
  export type ResolvedAuthHtmxRenderers = Required<AuthHtmxRenderOverrides> & {
84
84
  escapeHtml: (value: string) => string;
85
85
  };
86
- /** Config for the `htmx` option on `absoluteAuth`. Extends the renderers
86
+ /** Config for the `htmx` option on `auth`. Extends the renderers
87
87
  * config with the data actions the fragment routes call — keeping the auth
88
88
  * package agnostic of your identity schema while it owns the route wiring
89
89
  * (protectRoute gating, payload re-rendering, signout, delete-account flow). */
@@ -1,8 +1,8 @@
1
1
  import { Elysia } from 'elysia';
2
- import type { AbsoluteAuthSessionStore } from './sessionTypes';
2
+ import type { AuthSessionStore } from './sessionTypes';
3
3
  import { OnStatus, RouteString } from './types';
4
4
  type StatusProps<UserType> = {
5
- authSessionStore?: AbsoluteAuthSessionStore<UserType>;
5
+ authSessionStore?: AuthSessionStore<UserType>;
6
6
  statusRoute?: RouteString;
7
7
  onStatus: OnStatus<UserType>;
8
8
  };
package/dist/utils.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { OAuth2Client, OAuth2TokenResponse, ProviderOption } from 'citra';
2
2
  import { Cookie } from 'elysia';
3
- import { AbsoluteAuthProps, InsantiateUserSessionProps, OAuth2ConfigurationOptions, ResolvedOAuthAuthorization, SessionRecord, UnregisteredSessionRecord, UserSessionId } from './types';
3
+ import { AuthConfig, InsantiateUserSessionProps, OAuth2ConfigurationOptions, ResolvedOAuthAuthorization, SessionRecord, UnregisteredSessionRecord, UserSessionId } from './types';
4
4
  export declare const resolveOAuthTokenExpiresAt: (tokenResponse: OAuth2TokenResponse, now?: number) => number | undefined;
5
5
  export declare const resolveOAuthAuthorization: ({ authProvider, providerInstance, tokenResponse, now }: {
6
6
  authProvider: ProviderOption;
@@ -9,8 +9,8 @@ export declare const resolveOAuthAuthorization: ({ authProvider, providerInstanc
9
9
  now?: number;
10
10
  }) => Promise<ResolvedOAuthAuthorization>;
11
11
  export declare const instantiateUserSession: <UserType>({ authProvider, session, user_session_id, unregisteredSession, tokenResponse, providerInstance, getUser, onNewUser, resolvedAuthorization, sessionDurationMs, unregisteredSessionDurationMs }: InsantiateUserSessionProps<UserType>) => Promise<import("./types").StatusReturn | Response | undefined>;
12
- export declare const createAuthConfiguration: <UserType>(configuration: AbsoluteAuthProps<UserType>) => AbsoluteAuthProps<UserType>;
13
- export declare const createProvidersConfiguration: (providersConfiguration: OAuth2ConfigurationOptions) => OAuth2ConfigurationOptions;
12
+ export declare const defineAuthConfig: <UserType>(configuration: AuthConfig<UserType>) => AuthConfig<UserType>;
13
+ export declare const defineProvidersConfiguration: (providersConfiguration: OAuth2ConfigurationOptions) => OAuth2ConfigurationOptions;
14
14
  export declare const getStatus: <UserType>(session: SessionRecord<UserType>, user_session_id: Cookie<UserSessionId | undefined>) => Promise<{
15
15
  error: {
16
16
  readonly code: "Bad Request";
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.24.0",
2
+ "version": "0.25.0",
3
3
  "name": "@absolutejs/auth",
4
4
  "description": "An authorization library for absolutejs",
5
5
  "repository": {