@absolutejs/auth 0.22.7 → 0.23.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.
Files changed (91) hide show
  1. package/README.md +6 -13
  2. package/dist/index.d.ts +300 -1
  3. package/dist/index.js.map +2 -2
  4. package/dist/ui/index.d.ts +2 -0
  5. package/dist/ui/index.js +2212 -0
  6. package/dist/ui/index.js.map +11 -0
  7. package/dist/ui/renderers.d.ts +8 -0
  8. package/dist/ui/types.d.ts +85 -0
  9. package/package.json +71 -86
  10. package/dist/example/components/auth/AuthContainer.d.ts +0 -1
  11. package/dist/example/components/auth/OAuthButton.d.ts +0 -7
  12. package/dist/example/components/auth/OAuthButtons.d.ts +0 -5
  13. package/dist/example/components/hamburger/HamburgerDropdown.d.ts +0 -10
  14. package/dist/example/components/hamburger/HamburgerHeader.d.ts +0 -5
  15. package/dist/example/components/hamburger/HamburgerMenu.d.ts +0 -14
  16. package/dist/example/components/hamburger/HamburgerUserButtons.d.ts +0 -8
  17. package/dist/example/components/navbar/DropdownContainer.d.ts +0 -17
  18. package/dist/example/components/navbar/Navbar.d.ts +0 -7
  19. package/dist/example/components/navbar/NavbarDropdown.d.ts +0 -10
  20. package/dist/example/components/navbar/NavbarLink.d.ts +0 -8
  21. package/dist/example/components/navbar/NavbarLinks.d.ts +0 -6
  22. package/dist/example/components/navbar/NavbarUserButtons.d.ts +0 -7
  23. package/dist/example/components/page/Head.d.ts +0 -6
  24. package/dist/example/components/protected/AccountOverview.d.ts +0 -6
  25. package/dist/example/components/protected/DeleteAccountSection.d.ts +0 -5
  26. package/dist/example/components/protected/LinkedAuthIdentitiesPanel.d.ts +0 -1
  27. package/dist/example/components/protected/LinkedProvidersPanel.d.ts +0 -1
  28. package/dist/example/components/protected/ProviderButtons.d.ts +0 -1
  29. package/dist/example/components/protected/SettingsNoticeToast.d.ts +0 -1
  30. package/dist/example/components/protected/UserInfo.d.ts +0 -7
  31. package/dist/example/components/utils/AnimatedComponents.d.ts +0 -1
  32. package/dist/example/components/utils/Divider.d.ts +0 -7
  33. package/dist/example/components/utils/HighlightedJson.d.ts +0 -5
  34. package/dist/example/components/utils/JsonLine.d.ts +0 -6
  35. package/dist/example/components/utils/Modal.d.ts +0 -9
  36. package/dist/example/components/utils/ProfilePicture.d.ts +0 -8
  37. package/dist/example/components/utils/ProviderDropdown.d.ts +0 -8
  38. package/dist/example/components/utils/Toast.d.ts +0 -14
  39. package/dist/example/components/utils/ToastProvider.d.ts +0 -30
  40. package/dist/example/db/schema.d.ts +0 -2570
  41. package/dist/example/eden/treaty.d.ts +0 -1
  42. package/dist/example/handlers/userHandlers.d.ts +0 -254
  43. package/dist/example/hooks/useAuthIdentityPayload.d.ts +0 -37
  44. package/dist/example/hooks/useAuthStatus.d.ts +0 -19
  45. package/dist/example/hooks/useContainerQuery.d.ts +0 -10
  46. package/dist/example/hooks/useMediaQuery.d.ts +0 -11
  47. package/dist/example/linkedProviders/persistCallbackAuthorization.d.ts +0 -30
  48. package/dist/example/linkedProviders/resolver.d.ts +0 -1
  49. package/dist/example/linkedProviders/stores.d.ts +0 -9
  50. package/dist/example/pages/Connectors.d.ts +0 -1
  51. package/dist/example/pages/Home.d.ts +0 -1
  52. package/dist/example/pages/NotAuthorized.d.ts +0 -1
  53. package/dist/example/pages/Protected.d.ts +0 -1
  54. package/dist/example/pages/Settings.d.ts +0 -1
  55. package/dist/example/server.d.ts +0 -902
  56. package/dist/example/styles/authModalStyles.d.ts +0 -22
  57. package/dist/example/styles/navbarStyles.d.ts +0 -15
  58. package/dist/example/styles/styles.d.ts +0 -15
  59. package/dist/example/utils/absoluteAuthConfig.d.ts +0 -4
  60. package/dist/example/utils/constants.d.ts +0 -1
  61. package/dist/example/utils/navbarData.d.ts +0 -2
  62. package/dist/example/utils/providerData.d.ts +0 -9
  63. package/dist/example/utils/providersConfiguration.d.ts +0 -1
  64. package/dist/example/utils/typeGuards.d.ts +0 -1
  65. package/dist/example/utils/types.d.ts +0 -26
  66. package/dist/src/index.d.ts +0 -300
  67. /package/dist/{src/authSessionStores.d.ts → authSessionStores.d.ts} +0 -0
  68. /package/dist/{src/authorize.d.ts → authorize.d.ts} +0 -0
  69. /package/dist/{src/callback.d.ts → callback.d.ts} +0 -0
  70. /package/dist/{src/constants.d.ts → constants.d.ts} +0 -0
  71. /package/dist/{src/errors.d.ts → errors.d.ts} +0 -0
  72. /package/dist/{src/linkedProviderResolver.d.ts → linkedProviderResolver.d.ts} +0 -0
  73. /package/dist/{src/linkedProviderStores.d.ts → linkedProviderStores.d.ts} +0 -0
  74. /package/dist/{src/neonAuthSessionStore.d.ts → neonAuthSessionStore.d.ts} +0 -0
  75. /package/dist/{src/neonLinkedProviders.d.ts → neonLinkedProviders.d.ts} +0 -0
  76. /package/dist/{src/oauthLinkedProviderResolver.d.ts → oauthLinkedProviderResolver.d.ts} +0 -0
  77. /package/dist/{src/profile.d.ts → profile.d.ts} +0 -0
  78. /package/dist/{src/protectRoute.d.ts → protectRoute.d.ts} +0 -0
  79. /package/dist/{src/providerClients.d.ts → providerClients.d.ts} +0 -0
  80. /package/dist/{src/refresh.d.ts → refresh.d.ts} +0 -0
  81. /package/dist/{src/revoke.d.ts → revoke.d.ts} +0 -0
  82. /package/dist/{src/sessionAccess.d.ts → sessionAccess.d.ts} +0 -0
  83. /package/dist/{src/sessionCleanup.d.ts → sessionCleanup.d.ts} +0 -0
  84. /package/dist/{src/sessionStore.d.ts → sessionStore.d.ts} +0 -0
  85. /package/dist/{src/sessionTypes.d.ts → sessionTypes.d.ts} +0 -0
  86. /package/dist/{src/signout.d.ts → signout.d.ts} +0 -0
  87. /package/dist/{src/typeGuards.d.ts → typeGuards.d.ts} +0 -0
  88. /package/dist/{src/typebox.d.ts → typebox.d.ts} +0 -0
  89. /package/dist/{src/types.d.ts → types.d.ts} +0 -0
  90. /package/dist/{src/userStatus.d.ts → userStatus.d.ts} +0 -0
  91. /package/dist/{src/utils.d.ts → utils.d.ts} +0 -0
package/README.md CHANGED
@@ -25,14 +25,13 @@ Absolute Auth is a TypeScript-based authentication system that provides a compre
25
25
 
26
26
  ## Usage
27
27
 
28
- ### Running the Example Server
28
+ ### Example app
29
29
 
30
- Start the example server:
31
- ```bash
32
- bun dev
33
- ```
34
-
35
- 3. Open your browser and navigate to `http://localhost:3000` to test the authentication flow.
30
+ A full, runnable demo lives in the AbsoluteJS examples repo under
31
+ [`examples/auth`](https://github.com/absolutejs/examples/tree/main/auth). It
32
+ shows `@absolutejs/auth` across all six AbsoluteJS frontends (React, Vue,
33
+ Svelte, Angular, HTML, HTMX) — login, identity linking/merging, and connector
34
+ grants — against one shared Elysia server.
36
35
 
37
36
  ## Authentication System
38
37
 
@@ -51,12 +50,6 @@ Start the example server:
51
50
  - **Event Handlers**: Define custom event handlers for authorization, callback, status, refresh, signout, and revoke events.
52
51
  - **User Management**: Implement custom functions for creating and retrieving users.
53
52
 
54
- ### Example Components and Utilities in the `example` Directory
55
-
56
- - `components/Example.tsx`: A React component that demonstrates the usage of the authentication system, including login, signout, and protected routes.
57
- - `components/Navbar.tsx`: A React component that provides a navigation bar with authentication-related links and actions.
58
- - `server.ts`: The main server file that sets up the example server, handles routes, and integrates the authentication system.
59
-
60
53
  ## Note
61
54
 
62
55
  This project uses Bun and is built for Elysia.
package/dist/index.d.ts CHANGED
@@ -1 +1,300 @@
1
- export * from "./src/index";
1
+ import { Elysia } from 'elysia';
2
+ import { AbsoluteAuthProps } from './types';
3
+ export declare const absoluteAuth: <UserType>({ providersConfiguration, authorizeRoute, callbackRoute, profileRoute, signoutRoute, statusRoute, refreshRoute, revokeRoute, cleanupIntervalMs, maxSessions, sessionDurationMs, authSessionStore, resolveAuthIntent, onAuthorizeSuccess, onAuthorizeError, onProfileSuccess, onProfileError, onCallbackSuccess, onLinkIdentity, onLinkIdentityConflict, onLinkConnector, onCallbackError, onStatus, onRefreshSuccess, onRefreshError, onSignOut, onRevocationSuccess, onRevocationError, onSessionCleanup }: AbsoluteAuthProps<UserType>) => Promise<Elysia<"", {
4
+ decorator: {};
5
+ store: {
6
+ session: import("./types").SessionRecord<UserType> & import("./types").SessionRecord<unknown>;
7
+ unregisteredSession: import("./types").UnregisteredSessionRecord;
8
+ };
9
+ derive: {
10
+ readonly cleanupSessions: () => Promise<void>;
11
+ } & {
12
+ readonly protectRoute: <AuthReturn, AuthFailReturn>(handleAuth: (user: UserType) => AuthReturn | Promise<AuthReturn>, handleAuthFail?: ((error: {
13
+ readonly code: "Bad Request";
14
+ readonly message: "Cookies are missing";
15
+ } | {
16
+ readonly code: "Unauthorized";
17
+ readonly message: "User is not authenticated";
18
+ }) => AuthFailReturn) | undefined) => Promise<import("elysia").ElysiaCustomStatusResponse<"Bad Request", "Cookies are missing", 400> | import("elysia").ElysiaCustomStatusResponse<"Unauthorized", "User is not authenticated", 401> | AuthReturn | NonNullable<AuthFailReturn>>;
19
+ };
20
+ resolve: {};
21
+ }, {
22
+ typebox: {};
23
+ error: {};
24
+ }, {
25
+ schema: {};
26
+ standaloneSchema: {};
27
+ macro: {};
28
+ macroFn: {};
29
+ parser: {};
30
+ response: {};
31
+ } & {
32
+ schema: {};
33
+ standaloneSchema: {};
34
+ macro: {};
35
+ macroFn: {};
36
+ parser: {};
37
+ response: import("elysia").ExtractErrorFromHandle<{
38
+ readonly cleanupSessions: () => Promise<void>;
39
+ }>;
40
+ } & {
41
+ schema: import("elysia").UnwrapRoute<{
42
+ cookie: import("@sinclair/typebox").TObject<{
43
+ user_session_id: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TTemplateLiteralSyntax<"${string}-${string}-${string}-${string}-${string}">>;
44
+ }>;
45
+ }, {}, "">;
46
+ standaloneSchema: {};
47
+ macro: {};
48
+ macroFn: {};
49
+ parser: {};
50
+ response: import("elysia").ExtractErrorFromHandle<{
51
+ readonly protectRoute: <AuthReturn, AuthFailReturn>(handleAuth: (user: UserType) => AuthReturn | Promise<AuthReturn>, handleAuthFail?: ((error: {
52
+ readonly code: "Bad Request";
53
+ readonly message: "Cookies are missing";
54
+ } | {
55
+ readonly code: "Unauthorized";
56
+ readonly message: "User is not authenticated";
57
+ }) => AuthFailReturn) | undefined) => Promise<import("elysia").ElysiaCustomStatusResponse<"Bad Request", "Cookies are missing", 400> | import("elysia").ElysiaCustomStatusResponse<"Unauthorized", "User is not authenticated", 401> | AuthReturn | NonNullable<AuthFailReturn>>;
58
+ }>;
59
+ }, ((({
60
+ [x: string]: {
61
+ delete: {
62
+ body: unknown;
63
+ params: {};
64
+ query: unknown;
65
+ headers: unknown;
66
+ response: {
67
+ 200: Response;
68
+ 400: "Cookies are missing";
69
+ 401: "No auth provider found" | "No user session id found";
70
+ 422: {
71
+ type: "validation";
72
+ on: string;
73
+ summary?: string;
74
+ message?: string;
75
+ found?: unknown;
76
+ property?: string;
77
+ expected?: string;
78
+ };
79
+ 500: "Sign out operation failed";
80
+ };
81
+ };
82
+ };
83
+ } & {
84
+ [x: string]: {
85
+ post: {
86
+ body: unknown;
87
+ params: {};
88
+ query: unknown;
89
+ headers: unknown;
90
+ response: {
91
+ 200: Response;
92
+ 400: "Cookies are missing" | "Invalid provider";
93
+ 401: "Client provider not found" | "Client variant is required" | "Client variant not found" | "Provider is required" | "No auth provider found" | "No user session found";
94
+ 422: {
95
+ type: "validation";
96
+ on: string;
97
+ summary?: string;
98
+ message?: string;
99
+ found?: unknown;
100
+ property?: string;
101
+ expected?: string;
102
+ };
103
+ 500: "Failed to revoke token";
104
+ 501: "Provider does not support revocation";
105
+ };
106
+ };
107
+ };
108
+ } & ({
109
+ [x: string]: {
110
+ get: {
111
+ body: unknown;
112
+ params: {};
113
+ query: unknown;
114
+ headers: unknown;
115
+ response: {
116
+ 200: {
117
+ user: NonNullable<UserType> | null;
118
+ };
119
+ 400: "Cookies are missing";
120
+ 422: {
121
+ type: "validation";
122
+ on: string;
123
+ summary?: string;
124
+ message?: string;
125
+ found?: unknown;
126
+ property?: string;
127
+ expected?: string;
128
+ };
129
+ 500: `Error: ${string} - ${string}` | `Unknown Error: ${string}`;
130
+ };
131
+ };
132
+ };
133
+ } & ({
134
+ [x: string]: {
135
+ post: {
136
+ body: unknown;
137
+ params: {};
138
+ query: unknown;
139
+ headers: unknown;
140
+ response: {
141
+ 200: Response;
142
+ 400: "Cookies are missing" | "Invalid provider" | "No refresh token found";
143
+ 401: "Client provider not found" | "Client variant is required" | "Client variant not found" | "Provider is required" | "No auth provider found" | "No user session found";
144
+ 422: {
145
+ type: "validation";
146
+ on: string;
147
+ summary?: string;
148
+ message?: string;
149
+ found?: unknown;
150
+ property?: string;
151
+ expected?: string;
152
+ };
153
+ 500: "Failed to refresh token";
154
+ 501: "Provider is not refreshable";
155
+ };
156
+ };
157
+ };
158
+ } & ({
159
+ [x: string]: {
160
+ ":provider": {
161
+ get: {
162
+ body: unknown;
163
+ params: {
164
+ provider: "42" | "amazoncognito" | "anilist" | "apple" | "atlassian" | "auth0" | "authentik" | "autodesk" | "battlenet" | "bitbucket" | "box" | "bungie" | "coinbase" | "discord" | "donationalerts" | "dribbble" | "dropbox" | "epicgames" | "etsy" | "facebook" | "figma" | "gitea" | "github" | "gitlab" | "google" | "intuit" | "kakao" | "keycloak" | "kick" | "lichess" | "line" | "linear" | "linkedin" | "mastodon" | "mercadolibre" | "mercadopago" | "microsoftentraid" | "myanimelist" | "naver" | "notion" | "okta" | "osu" | "patreon" | "polar" | "polaraccesslink" | "polarteampro" | "reddit" | "roblox" | "salesforce" | "shikimori" | "slack" | "spotify" | "startgg" | "strava" | "synology" | "tiktok" | "tiltify" | "tumblr" | "twitch" | "twitter" | "vk" | "withings" | "workos" | "yahoo" | "yandex" | "zoom";
165
+ };
166
+ query: {
167
+ client?: string | undefined;
168
+ intent?: "login" | "link_identity" | "link_connector" | undefined;
169
+ };
170
+ headers: unknown;
171
+ response: {
172
+ 200: Response;
173
+ 400: "Provider is required" | "Cookies are missing";
174
+ 401: "Client provider not found" | "Client variant is required" | "Client variant not found" | "Provider is required";
175
+ 422: {
176
+ type: "validation";
177
+ on: string;
178
+ summary?: string;
179
+ message?: string;
180
+ found?: unknown;
181
+ property?: string;
182
+ expected?: string;
183
+ };
184
+ 500: "Failed to create authorization URL";
185
+ };
186
+ };
187
+ };
188
+ };
189
+ } | {
190
+ [x: string]: {
191
+ ":provider": {
192
+ [x: string]: {
193
+ get: {
194
+ body: unknown;
195
+ params: {
196
+ provider: "42" | "amazoncognito" | "anilist" | "apple" | "atlassian" | "auth0" | "authentik" | "autodesk" | "battlenet" | "bitbucket" | "box" | "bungie" | "coinbase" | "discord" | "donationalerts" | "dribbble" | "dropbox" | "epicgames" | "etsy" | "facebook" | "figma" | "gitea" | "github" | "gitlab" | "google" | "intuit" | "kakao" | "keycloak" | "kick" | "lichess" | "line" | "linear" | "linkedin" | "mastodon" | "mercadolibre" | "mercadopago" | "microsoftentraid" | "myanimelist" | "naver" | "notion" | "okta" | "osu" | "patreon" | "polar" | "polaraccesslink" | "polarteampro" | "reddit" | "roblox" | "salesforce" | "shikimori" | "slack" | "spotify" | "startgg" | "strava" | "synology" | "tiktok" | "tiltify" | "tumblr" | "twitch" | "twitter" | "vk" | "withings" | "workos" | "yahoo" | "yandex" | "zoom";
197
+ };
198
+ query: {
199
+ client?: string | undefined;
200
+ intent?: "login" | "link_identity" | "link_connector" | undefined;
201
+ };
202
+ headers: unknown;
203
+ response: {
204
+ 200: Response;
205
+ 400: "Provider is required" | "Cookies are missing";
206
+ 401: "Client provider not found" | "Client variant is required" | "Client variant not found" | "Provider is required";
207
+ 422: {
208
+ type: "validation";
209
+ on: string;
210
+ summary?: string;
211
+ message?: string;
212
+ found?: unknown;
213
+ property?: string;
214
+ expected?: string;
215
+ };
216
+ 500: "Failed to create authorization URL";
217
+ };
218
+ };
219
+ };
220
+ };
221
+ };
222
+ })))) & {
223
+ [x: string]: {
224
+ get: {
225
+ body: unknown;
226
+ params: {};
227
+ query: unknown;
228
+ headers: unknown;
229
+ response: {
230
+ [x: string]: any;
231
+ };
232
+ };
233
+ };
234
+ }) & {
235
+ [x: string]: {
236
+ get: {
237
+ body: unknown;
238
+ params: {};
239
+ query: unknown;
240
+ headers: unknown;
241
+ response: {
242
+ 200: Response;
243
+ 400: "Cookies are missing";
244
+ 401: "Client provider not found" | "Client variant is required" | "Client variant not found" | "Provider is required" | "No auth provider found" | "Invalid provider" | "No user session found";
245
+ 422: {
246
+ type: "validation";
247
+ on: string;
248
+ summary?: string;
249
+ message?: string;
250
+ found?: unknown;
251
+ property?: string;
252
+ expected?: string;
253
+ };
254
+ 500: `${string} - ${string}` | `Failed to validate authorization code: Unknown status: ${string}`;
255
+ };
256
+ };
257
+ };
258
+ }) & {}, {
259
+ derive: {};
260
+ resolve: {};
261
+ schema: {};
262
+ standaloneSchema: {};
263
+ response: {};
264
+ }, {
265
+ derive: {};
266
+ resolve: {};
267
+ schema: {};
268
+ standaloneSchema: {};
269
+ response: {};
270
+ } & {
271
+ derive: {};
272
+ resolve: {};
273
+ schema: {};
274
+ standaloneSchema: {};
275
+ response: {};
276
+ } & {
277
+ derive: {};
278
+ resolve: {};
279
+ schema: {};
280
+ standaloneSchema: {};
281
+ response: {};
282
+ }>>;
283
+ export * from './types';
284
+ export * from './typebox';
285
+ export type { AbsoluteAuthSessionStore } from './sessionTypes';
286
+ export { isAuthIntent, isUserSessionId, isValidUser } from './typeGuards';
287
+ export { AbsoluteAuthIdentityConflictError } from './errors';
288
+ export { sessionStore } from './sessionStore';
289
+ export { createInMemoryAuthSessionStore } from './authSessionStores';
290
+ export { createNeonAuthSessionStore } from './neonAuthSessionStore';
291
+ export { createLinkedProviderCredentialResolver } from './linkedProviderResolver';
292
+ export { createOAuthLinkedProviderCredentialResolver } from './oauthLinkedProviderResolver';
293
+ export { createNeonLinkedProviderStores, createNeonOAuthLinkedProviderCredentialResolver } from './neonLinkedProviders';
294
+ export { createInMemoryLinkedProviderStores } from './linkedProviderStores';
295
+ export { protectRoutePlugin } from './protectRoute';
296
+ export { sessionCleanup } from './sessionCleanup';
297
+ export * from './utils';
298
+ export { buildClientProviders, resolveClientProviderEntry, resolveProviderClientConfiguration } from './providerClients';
299
+ export type { OAuth2TokenResponse, OAuth2Client, ProviderOption, PKCEProvider, OIDCProvider, RefreshableProvider, RevocableProvider, ScopeRequiredProvider, ProvidersMap, ProviderConfiguration, CredentialsFor } from 'citra';
300
+ export { providers, providerOptions, refreshableProviderOptions, revocableProviderOptions, oidcProviderOptions, pkceProviderOptions, scopeRequiredProviderOptions, decodeJWT, extractPropFromIdentity, isValidProviderOption, isRefreshableOAuth2Client, isRefreshableProviderOption, isOIDCProviderOption, isPKCEProviderOption, isRevocableProviderOption, isRevocableOAuth2Client } from 'citra';