@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,7 +1,7 @@
1
- import type { AbsoluteAuthSessionStore } from './sessionTypes';
1
+ import type { AuthSessionStore } from './sessionTypes';
2
2
  import type { SessionData, UnregisteredSessionData, UserSessionId } from './types';
3
3
  export type CreateInMemoryAuthSessionStoreOptions<UserType> = {
4
4
  sessions?: Record<UserSessionId, SessionData<UserType>>;
5
5
  unregisteredSessions?: Record<UserSessionId, UnregisteredSessionData>;
6
6
  };
7
- export declare const createInMemoryAuthSessionStore: <UserType>(input?: CreateInMemoryAuthSessionStoreOptions<UserType>) => AbsoluteAuthSessionStore<UserType>;
7
+ export declare const createInMemoryAuthSessionStore: <UserType>(input?: CreateInMemoryAuthSessionStoreOptions<UserType>) => AuthSessionStore<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 { ClientProviders, OnCallbackError, OnCallbackSuccess, OnLinkConnector, OnLinkIdentity, OnLinkIdentityConflict, ResolveAuthIntent, RouteString } from './types';
4
4
  type CallbackProps<UserType> = {
5
- authSessionStore?: AbsoluteAuthSessionStore<UserType>;
5
+ authSessionStore?: AuthSessionStore<UserType>;
6
6
  clientProviders: ClientProviders;
7
7
  callbackRoute?: RouteString;
8
8
  resolveAuthIntent?: ResolveAuthIntent<UserType>;
package/dist/errors.d.ts CHANGED
@@ -6,7 +6,7 @@ export type AuthIdentityConflict = {
6
6
  currentUserAuthSub?: string;
7
7
  intent?: AuthIntent;
8
8
  };
9
- export declare class AbsoluteAuthIdentityConflictError extends Error {
9
+ export declare class AuthIdentityConflictError extends Error {
10
10
  conflict: AuthIdentityConflict;
11
11
  constructor(conflict: AuthIdentityConflict);
12
12
  }
@@ -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 { AuthHtmxConfig, AuthHtmxUser } from './ui/types';
4
4
  export declare const createAuthHtmxRoutes: <UserType extends AuthHtmxUser>(config: AuthHtmxConfig & {
5
- authSessionStore?: AbsoluteAuthSessionStore<UserType>;
5
+ authSessionStore?: AuthSessionStore<UserType>;
6
6
  }) => Elysia<"", {
7
7
  decorator: {};
8
8
  store: {
package/dist/index.d.ts CHANGED
@@ -1,13 +1,13 @@
1
1
  import { Elysia } from 'elysia';
2
- import { AbsoluteAuthProps } from './types';
2
+ import { AuthConfig } from './types';
3
3
  import type { AuthHtmxUser } from './ui/types';
4
- export declare const absoluteAuth: <UserType extends AuthHtmxUser>({ providersConfiguration, authorizeRoute, callbackRoute, profileRoute, signoutRoute, statusRoute, refreshRoute, revokeRoute, cleanupIntervalMs, maxSessions, sessionDurationMs, authSessionStore, htmx, resolveAuthIntent, onAuthorizeSuccess, onAuthorizeError, onProfileSuccess, onProfileError, onCallbackSuccess, onLinkIdentity, onLinkIdentityConflict, onLinkConnector, onCallbackError, onStatus, onRefreshSuccess, onRefreshError, onSignOut, onRevocationSuccess, onRevocationError, onSessionCleanup }: AbsoluteAuthProps<UserType>) => Promise<Elysia<"", {
4
+ export declare const auth: <UserType>({ providersConfiguration, authorizeRoute, callbackRoute, profileRoute, signoutRoute, statusRoute, refreshRoute, revokeRoute, cleanupIntervalMs, maxSessions, sessionDurationMs, authSessionStore, htmx, resolveAuthIntent, onAuthorizeSuccess, onAuthorizeError, onProfileSuccess, onProfileError, onCallbackSuccess, onLinkIdentity, onLinkIdentityConflict, onLinkConnector, onCallbackError, onStatus, onRefreshSuccess, onRefreshError, onSignOut, onRevocationSuccess, onRevocationError, onSessionCleanup }: AuthConfig<UserType>) => Promise<Elysia<"", {
5
5
  decorator: {};
6
6
  store: {
7
7
  session: import("./types").SessionRecord<UserType> & import("./types").SessionRecord<unknown>;
8
8
  unregisteredSession: import("./types").UnregisteredSessionRecord;
9
9
  } | {
10
- session: import("./types").SessionRecord<UserType> & import("./types").SessionRecord<unknown>;
10
+ session: import("./types").SessionRecord<UserType> & import("./types").SessionRecord<unknown> & import("./types").SessionRecord<UserType & AuthHtmxUser>;
11
11
  unregisteredSession: import("./types").UnregisteredSessionRecord;
12
12
  };
13
13
  derive: {
@@ -20,7 +20,15 @@ export declare const absoluteAuth: <UserType extends AuthHtmxUser>({ providersCo
20
20
  readonly code: "Unauthorized";
21
21
  readonly message: "User is not authenticated";
22
22
  }) => AuthFailReturn) | undefined) => Promise<import("elysia").ElysiaCustomStatusResponse<"Bad Request", "Cookies are missing", 400> | import("elysia").ElysiaCustomStatusResponse<"Unauthorized", "User is not authenticated", 401> | AuthReturn | NonNullable<AuthFailReturn>>;
23
- };
23
+ } & ({} | {
24
+ readonly protectRoute: <AuthReturn, AuthFailReturn>(handleAuth: (user: UserType & AuthHtmxUser) => AuthReturn | Promise<AuthReturn>, handleAuthFail?: ((error: {
25
+ readonly code: "Bad Request";
26
+ readonly message: "Cookies are missing";
27
+ } | {
28
+ readonly code: "Unauthorized";
29
+ readonly message: "User is not authenticated";
30
+ }) => AuthFailReturn) | undefined) => Promise<import("elysia").ElysiaCustomStatusResponse<"Bad Request", "Cookies are missing", 400> | import("elysia").ElysiaCustomStatusResponse<"Unauthorized", "User is not authenticated", 401> | AuthReturn | NonNullable<AuthFailReturn>>;
31
+ });
24
32
  resolve: {};
25
33
  }, {
26
34
  typebox: {};
@@ -41,7 +49,7 @@ export declare const absoluteAuth: <UserType extends AuthHtmxUser>({ providersCo
41
49
  response: import("elysia").ExtractErrorFromHandle<{
42
50
  readonly cleanupSessions: () => Promise<void>;
43
51
  }>;
44
- } & {
52
+ } & ({
45
53
  schema: import("elysia").UnwrapRoute<{
46
54
  cookie: import("@sinclair/typebox").TObject<{
47
55
  user_session_id: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TTemplateLiteralSyntax<"${string}-${string}-${string}-${string}-${string}">>;
@@ -60,7 +68,40 @@ export declare const absoluteAuth: <UserType extends AuthHtmxUser>({ providersCo
60
68
  readonly message: "User is not authenticated";
61
69
  }) => AuthFailReturn) | undefined) => Promise<import("elysia").ElysiaCustomStatusResponse<"Bad Request", "Cookies are missing", 400> | import("elysia").ElysiaCustomStatusResponse<"Unauthorized", "User is not authenticated", 401> | AuthReturn | NonNullable<AuthFailReturn>>;
62
70
  }>;
63
- }, (((({
71
+ } & ({
72
+ schema: {};
73
+ standaloneSchema: {};
74
+ macro: {};
75
+ macroFn: {};
76
+ parser: {};
77
+ response: {};
78
+ } | ({
79
+ schema: {};
80
+ standaloneSchema: {};
81
+ macro: {};
82
+ macroFn: {};
83
+ parser: {};
84
+ response: {};
85
+ } & {
86
+ schema: import("elysia").UnwrapRoute<{
87
+ cookie: import("@sinclair/typebox").TObject<{
88
+ user_session_id: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TTemplateLiteralSyntax<"${string}-${string}-${string}-${string}-${string}">>;
89
+ }>;
90
+ }, {}, "">;
91
+ standaloneSchema: {};
92
+ macro: {};
93
+ macroFn: {};
94
+ parser: {};
95
+ response: import("elysia").ExtractErrorFromHandle<{
96
+ readonly protectRoute: <AuthReturn, AuthFailReturn>(handleAuth: (user: UserType & AuthHtmxUser) => AuthReturn | Promise<AuthReturn>, handleAuthFail?: ((error: {
97
+ readonly code: "Bad Request";
98
+ readonly message: "Cookies are missing";
99
+ } | {
100
+ readonly code: "Unauthorized";
101
+ readonly message: "User is not authenticated";
102
+ }) => AuthFailReturn) | undefined) => Promise<import("elysia").ElysiaCustomStatusResponse<"Bad Request", "Cookies are missing", 400> | import("elysia").ElysiaCustomStatusResponse<"Unauthorized", "User is not authenticated", 401> | AuthReturn | NonNullable<AuthFailReturn>>;
103
+ }>;
104
+ }))), (((({
64
105
  [x: string]: {
65
106
  delete: {
66
107
  body: unknown;
@@ -731,9 +772,9 @@ export declare const absoluteAuth: <UserType extends AuthHtmxUser>({ providersCo
731
772
  }>>;
732
773
  export * from './types';
733
774
  export * from './typebox';
734
- export type { AbsoluteAuthSessionStore } from './sessionTypes';
775
+ export type { AuthSessionStore } from './sessionTypes';
735
776
  export { isAuthIntent, isUserSessionId, isValidUser } from './typeGuards';
736
- export { AbsoluteAuthIdentityConflictError } from './errors';
777
+ export { AuthIdentityConflictError } from './errors';
737
778
  export { sessionStore } from './sessionStore';
738
779
  export { createInMemoryAuthSessionStore } from './authSessionStores';
739
780
  export { createNeonAuthSessionStore } from './neonAuthSessionStore';
package/dist/index.js CHANGED
@@ -2417,11 +2417,11 @@ var authorize = ({
2417
2417
  import { Elysia as Elysia3, t as t3 } from "elysia";
2418
2418
 
2419
2419
  // src/errors.ts
2420
- class AbsoluteAuthIdentityConflictError extends Error {
2420
+ class AuthIdentityConflictError extends Error {
2421
2421
  conflict;
2422
2422
  constructor(conflict) {
2423
2423
  super(`${conflict.authProvider} identity ${conflict.providerSubject} is already linked to ${conflict.existingUserAuthSub}`);
2424
- this.name = "AbsoluteAuthIdentityConflictError";
2424
+ this.name = "AuthIdentityConflictError";
2425
2425
  this.conflict = conflict;
2426
2426
  }
2427
2427
  }
@@ -2667,7 +2667,7 @@ var callback = ({
2667
2667
  try {
2668
2668
  response = authIntent === "link_identity" && onLinkIdentity ? await onLinkIdentity(callbackContext) : authIntent === "link_connector" && onLinkConnector ? await onLinkConnector(callbackContext) : await onCallbackSuccess?.(callbackContext);
2669
2669
  } catch (err) {
2670
- if (authIntent === "link_identity" && err instanceof AbsoluteAuthIdentityConflictError && onLinkIdentityConflict) {
2670
+ if (authIntent === "link_identity" && err instanceof AuthIdentityConflictError && onLinkIdentityConflict) {
2671
2671
  response = await onLinkIdentityConflict({
2672
2672
  ...callbackContext,
2673
2673
  conflict: {
@@ -13860,8 +13860,8 @@ var instantiateUserSession = async ({
13860
13860
  };
13861
13861
  return response;
13862
13862
  };
13863
- var createAuthConfiguration = (configuration) => configuration;
13864
- var createProvidersConfiguration = (providersConfiguration) => providersConfiguration;
13863
+ var defineAuthConfig = (configuration) => configuration;
13864
+ var defineProvidersConfiguration = (providersConfiguration) => providersConfiguration;
13865
13865
  var getStatus = async (session, user_session_id) => {
13866
13866
  if (user_session_id === undefined) {
13867
13867
  return {
@@ -13925,7 +13925,7 @@ var getUserSessionId = ({
13925
13925
  };
13926
13926
 
13927
13927
  // src/index.ts
13928
- var absoluteAuth = async ({
13928
+ var auth = async ({
13929
13929
  providersConfiguration,
13930
13930
  authorizeRoute,
13931
13931
  callbackRoute,
@@ -13985,18 +13985,21 @@ var absoluteAuth = async ({
13985
13985
  authSessionStore,
13986
13986
  callbackRoute,
13987
13987
  clientProviders,
13988
- resolveAuthIntent,
13989
13988
  onCallbackError,
13990
13989
  onCallbackSuccess,
13990
+ onLinkConnector,
13991
13991
  onLinkIdentity,
13992
13992
  onLinkIdentityConflict,
13993
- onLinkConnector
13993
+ resolveAuthIntent
13994
13994
  })).use(profile({
13995
13995
  clientProviders,
13996
13996
  onProfileError,
13997
13997
  onProfileSuccess,
13998
13998
  profileRoute
13999
- })).use(protectRoutePlugin({ authSessionStore })).use(htmx ? createAuthHtmxRoutes({ ...htmx, authSessionStore }) : new Elysia12);
13999
+ })).use(protectRoutePlugin({ authSessionStore })).use(htmx ? createAuthHtmxRoutes({
14000
+ ...htmx,
14001
+ authSessionStore
14002
+ }) : new Elysia12);
14000
14003
  };
14001
14004
  export {
14002
14005
  validateSession,
@@ -14030,8 +14033,9 @@ export {
14030
14033
  getUserSessionId,
14031
14034
  getStatus,
14032
14035
  extractPropFromIdentity,
14036
+ defineProvidersConfiguration,
14037
+ defineAuthConfig,
14033
14038
  decodeJWT,
14034
- createProvidersConfiguration,
14035
14039
  createOAuthLinkedProviderCredentialResolver,
14036
14040
  createNeonOAuthLinkedProviderCredentialResolver,
14037
14041
  createNeonLinkedProviderStores,
@@ -14040,14 +14044,13 @@ export {
14040
14044
  createInMemoryLinkedProviderStores,
14041
14045
  createInMemoryAuthSessionStore,
14042
14046
  createAuthHtmxRoutes,
14043
- createAuthConfiguration,
14044
14047
  buildClientProviders,
14045
14048
  authProviderOption,
14046
14049
  authIntentOption,
14047
14050
  authClientOption,
14048
- absoluteAuth,
14049
- AbsoluteAuthIdentityConflictError
14051
+ auth,
14052
+ AuthIdentityConflictError
14050
14053
  };
14051
14054
 
14052
- //# debugId=D6887201B1B4B2A864756E2164756E21
14055
+ //# debugId=26C8391A6D84F55864756E2164756E21
14053
14056
  //# sourceMappingURL=index.js.map