@absolutejs/auth 0.22.7 → 0.24.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 (93) hide show
  1. package/README.md +6 -13
  2. package/dist/htmxRoutes.d.ts +514 -0
  3. package/dist/index.d.ts +752 -1
  4. package/dist/index.js +207 -40
  5. package/dist/index.js.map +8 -6
  6. package/dist/{src/types.d.ts → types.d.ts} +6 -0
  7. package/dist/ui/index.d.ts +2 -0
  8. package/dist/ui/index.js +2212 -0
  9. package/dist/ui/index.js.map +11 -0
  10. package/dist/ui/renderers.d.ts +8 -0
  11. package/dist/ui/types.d.ts +129 -0
  12. package/package.json +71 -86
  13. package/dist/example/components/auth/AuthContainer.d.ts +0 -1
  14. package/dist/example/components/auth/OAuthButton.d.ts +0 -7
  15. package/dist/example/components/auth/OAuthButtons.d.ts +0 -5
  16. package/dist/example/components/hamburger/HamburgerDropdown.d.ts +0 -10
  17. package/dist/example/components/hamburger/HamburgerHeader.d.ts +0 -5
  18. package/dist/example/components/hamburger/HamburgerMenu.d.ts +0 -14
  19. package/dist/example/components/hamburger/HamburgerUserButtons.d.ts +0 -8
  20. package/dist/example/components/navbar/DropdownContainer.d.ts +0 -17
  21. package/dist/example/components/navbar/Navbar.d.ts +0 -7
  22. package/dist/example/components/navbar/NavbarDropdown.d.ts +0 -10
  23. package/dist/example/components/navbar/NavbarLink.d.ts +0 -8
  24. package/dist/example/components/navbar/NavbarLinks.d.ts +0 -6
  25. package/dist/example/components/navbar/NavbarUserButtons.d.ts +0 -7
  26. package/dist/example/components/page/Head.d.ts +0 -6
  27. package/dist/example/components/protected/AccountOverview.d.ts +0 -6
  28. package/dist/example/components/protected/DeleteAccountSection.d.ts +0 -5
  29. package/dist/example/components/protected/LinkedAuthIdentitiesPanel.d.ts +0 -1
  30. package/dist/example/components/protected/LinkedProvidersPanel.d.ts +0 -1
  31. package/dist/example/components/protected/ProviderButtons.d.ts +0 -1
  32. package/dist/example/components/protected/SettingsNoticeToast.d.ts +0 -1
  33. package/dist/example/components/protected/UserInfo.d.ts +0 -7
  34. package/dist/example/components/utils/AnimatedComponents.d.ts +0 -1
  35. package/dist/example/components/utils/Divider.d.ts +0 -7
  36. package/dist/example/components/utils/HighlightedJson.d.ts +0 -5
  37. package/dist/example/components/utils/JsonLine.d.ts +0 -6
  38. package/dist/example/components/utils/Modal.d.ts +0 -9
  39. package/dist/example/components/utils/ProfilePicture.d.ts +0 -8
  40. package/dist/example/components/utils/ProviderDropdown.d.ts +0 -8
  41. package/dist/example/components/utils/Toast.d.ts +0 -14
  42. package/dist/example/components/utils/ToastProvider.d.ts +0 -30
  43. package/dist/example/db/schema.d.ts +0 -2570
  44. package/dist/example/eden/treaty.d.ts +0 -1
  45. package/dist/example/handlers/userHandlers.d.ts +0 -254
  46. package/dist/example/hooks/useAuthIdentityPayload.d.ts +0 -37
  47. package/dist/example/hooks/useAuthStatus.d.ts +0 -19
  48. package/dist/example/hooks/useContainerQuery.d.ts +0 -10
  49. package/dist/example/hooks/useMediaQuery.d.ts +0 -11
  50. package/dist/example/linkedProviders/persistCallbackAuthorization.d.ts +0 -30
  51. package/dist/example/linkedProviders/resolver.d.ts +0 -1
  52. package/dist/example/linkedProviders/stores.d.ts +0 -9
  53. package/dist/example/pages/Connectors.d.ts +0 -1
  54. package/dist/example/pages/Home.d.ts +0 -1
  55. package/dist/example/pages/NotAuthorized.d.ts +0 -1
  56. package/dist/example/pages/Protected.d.ts +0 -1
  57. package/dist/example/pages/Settings.d.ts +0 -1
  58. package/dist/example/server.d.ts +0 -902
  59. package/dist/example/styles/authModalStyles.d.ts +0 -22
  60. package/dist/example/styles/navbarStyles.d.ts +0 -15
  61. package/dist/example/styles/styles.d.ts +0 -15
  62. package/dist/example/utils/absoluteAuthConfig.d.ts +0 -4
  63. package/dist/example/utils/constants.d.ts +0 -1
  64. package/dist/example/utils/navbarData.d.ts +0 -2
  65. package/dist/example/utils/providerData.d.ts +0 -9
  66. package/dist/example/utils/providersConfiguration.d.ts +0 -1
  67. package/dist/example/utils/typeGuards.d.ts +0 -1
  68. package/dist/example/utils/types.d.ts +0 -26
  69. package/dist/src/index.d.ts +0 -300
  70. /package/dist/{src/authSessionStores.d.ts → authSessionStores.d.ts} +0 -0
  71. /package/dist/{src/authorize.d.ts → authorize.d.ts} +0 -0
  72. /package/dist/{src/callback.d.ts → callback.d.ts} +0 -0
  73. /package/dist/{src/constants.d.ts → constants.d.ts} +0 -0
  74. /package/dist/{src/errors.d.ts → errors.d.ts} +0 -0
  75. /package/dist/{src/linkedProviderResolver.d.ts → linkedProviderResolver.d.ts} +0 -0
  76. /package/dist/{src/linkedProviderStores.d.ts → linkedProviderStores.d.ts} +0 -0
  77. /package/dist/{src/neonAuthSessionStore.d.ts → neonAuthSessionStore.d.ts} +0 -0
  78. /package/dist/{src/neonLinkedProviders.d.ts → neonLinkedProviders.d.ts} +0 -0
  79. /package/dist/{src/oauthLinkedProviderResolver.d.ts → oauthLinkedProviderResolver.d.ts} +0 -0
  80. /package/dist/{src/profile.d.ts → profile.d.ts} +0 -0
  81. /package/dist/{src/protectRoute.d.ts → protectRoute.d.ts} +0 -0
  82. /package/dist/{src/providerClients.d.ts → providerClients.d.ts} +0 -0
  83. /package/dist/{src/refresh.d.ts → refresh.d.ts} +0 -0
  84. /package/dist/{src/revoke.d.ts → revoke.d.ts} +0 -0
  85. /package/dist/{src/sessionAccess.d.ts → sessionAccess.d.ts} +0 -0
  86. /package/dist/{src/sessionCleanup.d.ts → sessionCleanup.d.ts} +0 -0
  87. /package/dist/{src/sessionStore.d.ts → sessionStore.d.ts} +0 -0
  88. /package/dist/{src/sessionTypes.d.ts → sessionTypes.d.ts} +0 -0
  89. /package/dist/{src/signout.d.ts → signout.d.ts} +0 -0
  90. /package/dist/{src/typeGuards.d.ts → typeGuards.d.ts} +0 -0
  91. /package/dist/{src/typebox.d.ts → typebox.d.ts} +0 -0
  92. /package/dist/{src/userStatus.d.ts → userStatus.d.ts} +0 -0
  93. /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.
@@ -0,0 +1,514 @@
1
+ import { Elysia } from 'elysia';
2
+ import type { AbsoluteAuthSessionStore } from './sessionTypes';
3
+ import type { AuthHtmxConfig, AuthHtmxUser } from './ui/types';
4
+ export declare const createAuthHtmxRoutes: <UserType extends AuthHtmxUser>(config: AuthHtmxConfig & {
5
+ authSessionStore?: AbsoluteAuthSessionStore<UserType>;
6
+ }) => Elysia<"", {
7
+ decorator: {};
8
+ store: {
9
+ session: import("./types").SessionRecord<UserType>;
10
+ unregisteredSession: import("./types").UnregisteredSessionRecord;
11
+ };
12
+ derive: {
13
+ readonly protectRoute: <AuthReturn, AuthFailReturn>(handleAuth: (user: UserType) => AuthReturn | Promise<AuthReturn>, handleAuthFail?: ((error: {
14
+ readonly code: "Bad Request";
15
+ readonly message: "Cookies are missing";
16
+ } | {
17
+ readonly code: "Unauthorized";
18
+ readonly message: "User is not authenticated";
19
+ }) => AuthFailReturn) | undefined) => Promise<import("elysia").ElysiaCustomStatusResponse<"Bad Request", "Cookies are missing", 400> | import("elysia").ElysiaCustomStatusResponse<"Unauthorized", "User is not authenticated", 401> | AuthReturn | NonNullable<AuthFailReturn>>;
20
+ };
21
+ resolve: {};
22
+ }, {
23
+ typebox: {};
24
+ error: {};
25
+ }, {
26
+ schema: {};
27
+ standaloneSchema: {};
28
+ macro: {};
29
+ macroFn: {};
30
+ parser: {};
31
+ response: {};
32
+ } & {
33
+ schema: import("elysia").UnwrapRoute<{
34
+ cookie: import("@sinclair/typebox").TObject<{
35
+ user_session_id: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TTemplateLiteralSyntax<"${string}-${string}-${string}-${string}-${string}">>;
36
+ }>;
37
+ }, {}, "">;
38
+ standaloneSchema: {};
39
+ macro: {};
40
+ macroFn: {};
41
+ parser: {};
42
+ response: import("elysia").ExtractErrorFromHandle<{
43
+ readonly protectRoute: <AuthReturn, AuthFailReturn>(handleAuth: (user: UserType) => AuthReturn | Promise<AuthReturn>, handleAuthFail?: ((error: {
44
+ readonly code: "Bad Request";
45
+ readonly message: "Cookies are missing";
46
+ } | {
47
+ readonly code: "Unauthorized";
48
+ readonly message: "User is not authenticated";
49
+ }) => AuthFailReturn) | undefined) => Promise<import("elysia").ElysiaCustomStatusResponse<"Bad Request", "Cookies are missing", 400> | import("elysia").ElysiaCustomStatusResponse<"Unauthorized", "User is not authenticated", 401> | AuthReturn | NonNullable<AuthFailReturn>>;
50
+ }>;
51
+ }, {
52
+ htmx: {
53
+ login: {
54
+ get: {
55
+ body: unknown;
56
+ params: {};
57
+ query: unknown;
58
+ headers: unknown;
59
+ response: {
60
+ 200: Response;
61
+ 422: {
62
+ type: "validation";
63
+ on: string;
64
+ summary?: string;
65
+ message?: string;
66
+ found?: unknown;
67
+ property?: string;
68
+ expected?: string;
69
+ };
70
+ };
71
+ };
72
+ };
73
+ };
74
+ } & {
75
+ htmx: {
76
+ link: {
77
+ get: {
78
+ body: unknown;
79
+ params: {};
80
+ query: unknown;
81
+ headers: unknown;
82
+ response: {
83
+ 200: Response;
84
+ 422: {
85
+ type: "validation";
86
+ on: string;
87
+ summary?: string;
88
+ message?: string;
89
+ found?: unknown;
90
+ property?: string;
91
+ expected?: string;
92
+ };
93
+ };
94
+ };
95
+ };
96
+ };
97
+ } & {
98
+ htmx: {
99
+ "connector-links": {
100
+ get: {
101
+ body: unknown;
102
+ params: {};
103
+ query: unknown;
104
+ headers: unknown;
105
+ response: {
106
+ 200: Response;
107
+ 422: {
108
+ type: "validation";
109
+ on: string;
110
+ summary?: string;
111
+ message?: string;
112
+ found?: unknown;
113
+ property?: string;
114
+ expected?: string;
115
+ };
116
+ };
117
+ };
118
+ };
119
+ };
120
+ } & {
121
+ htmx: {
122
+ "auth-menu": {
123
+ get: {
124
+ body: unknown;
125
+ params: {};
126
+ query: unknown;
127
+ headers: unknown;
128
+ response: {
129
+ 200: Response;
130
+ 400: "Cookies are missing";
131
+ 401: "User is not authenticated";
132
+ 422: {
133
+ type: "validation";
134
+ on: string;
135
+ summary?: string;
136
+ message?: string;
137
+ found?: unknown;
138
+ property?: string;
139
+ expected?: string;
140
+ };
141
+ };
142
+ };
143
+ };
144
+ };
145
+ } & {
146
+ htmx: {
147
+ me: {
148
+ get: {
149
+ body: unknown;
150
+ params: {};
151
+ query: unknown;
152
+ headers: unknown;
153
+ response: {
154
+ 200: Response;
155
+ 400: "Cookies are missing";
156
+ 401: "User is not authenticated";
157
+ 422: {
158
+ type: "validation";
159
+ on: string;
160
+ summary?: string;
161
+ message?: string;
162
+ found?: unknown;
163
+ property?: string;
164
+ expected?: string;
165
+ };
166
+ };
167
+ };
168
+ };
169
+ };
170
+ } & {
171
+ htmx: {
172
+ account: {
173
+ get: {
174
+ body: unknown;
175
+ params: {};
176
+ query: unknown;
177
+ headers: unknown;
178
+ response: {
179
+ 200: Response;
180
+ 400: "Cookies are missing";
181
+ 401: "User is not authenticated";
182
+ 422: {
183
+ type: "validation";
184
+ on: string;
185
+ summary?: string;
186
+ message?: string;
187
+ found?: unknown;
188
+ property?: string;
189
+ expected?: string;
190
+ };
191
+ };
192
+ };
193
+ };
194
+ };
195
+ } & {
196
+ htmx: {
197
+ identities: {
198
+ get: {
199
+ body: unknown;
200
+ params: {};
201
+ query: unknown;
202
+ headers: unknown;
203
+ response: {
204
+ 200: {} | Response;
205
+ 400: "Cookies are missing";
206
+ 401: "User is not authenticated";
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
+ };
217
+ };
218
+ };
219
+ };
220
+ } & {
221
+ htmx: {
222
+ identities: {
223
+ ":id": {
224
+ primary: {
225
+ post: {
226
+ body: unknown;
227
+ params: {
228
+ id: string;
229
+ } & {};
230
+ query: unknown;
231
+ headers: unknown;
232
+ response: {
233
+ 200: {} | Response;
234
+ 400: "Cookies are missing";
235
+ 401: "User is not authenticated";
236
+ 422: {
237
+ type: "validation";
238
+ on: string;
239
+ summary?: string;
240
+ message?: string;
241
+ found?: unknown;
242
+ property?: string;
243
+ expected?: string;
244
+ };
245
+ };
246
+ };
247
+ };
248
+ };
249
+ };
250
+ };
251
+ } & {
252
+ htmx: {
253
+ identities: {
254
+ ":id": {
255
+ delete: {
256
+ body: unknown;
257
+ params: {
258
+ id: string;
259
+ } & {};
260
+ query: unknown;
261
+ headers: unknown;
262
+ response: {
263
+ 200: {} | Response;
264
+ 400: "Cookies are missing";
265
+ 401: "User is not authenticated";
266
+ 422: {
267
+ type: "validation";
268
+ on: string;
269
+ summary?: string;
270
+ message?: string;
271
+ found?: unknown;
272
+ property?: string;
273
+ expected?: string;
274
+ };
275
+ };
276
+ };
277
+ };
278
+ };
279
+ };
280
+ } & {
281
+ htmx: {
282
+ merge: {
283
+ ":id": {
284
+ post: {
285
+ body: unknown;
286
+ params: {
287
+ id: string;
288
+ } & {};
289
+ query: unknown;
290
+ headers: unknown;
291
+ response: {
292
+ 200: {} | Response;
293
+ 400: "Cookies are missing";
294
+ 401: "User is not authenticated";
295
+ 422: {
296
+ type: "validation";
297
+ on: string;
298
+ summary?: string;
299
+ message?: string;
300
+ found?: unknown;
301
+ property?: string;
302
+ expected?: string;
303
+ };
304
+ };
305
+ };
306
+ };
307
+ };
308
+ };
309
+ } & {
310
+ htmx: {
311
+ merge: {
312
+ ":id": {
313
+ delete: {
314
+ body: unknown;
315
+ params: {
316
+ id: string;
317
+ } & {};
318
+ query: unknown;
319
+ headers: unknown;
320
+ response: {
321
+ 200: {} | Response;
322
+ 400: "Cookies are missing";
323
+ 401: "User is not authenticated";
324
+ 422: {
325
+ type: "validation";
326
+ on: string;
327
+ summary?: string;
328
+ message?: string;
329
+ found?: unknown;
330
+ property?: string;
331
+ expected?: string;
332
+ };
333
+ };
334
+ };
335
+ };
336
+ };
337
+ };
338
+ } & {
339
+ htmx: {
340
+ "connector-list": {
341
+ get: {
342
+ body: unknown;
343
+ params: {};
344
+ query: unknown;
345
+ headers: unknown;
346
+ response: {
347
+ 200: Response;
348
+ 400: "Cookies are missing";
349
+ 401: "User is not authenticated";
350
+ 422: {
351
+ type: "validation";
352
+ on: string;
353
+ summary?: string;
354
+ message?: string;
355
+ found?: unknown;
356
+ property?: string;
357
+ expected?: string;
358
+ };
359
+ };
360
+ };
361
+ };
362
+ };
363
+ } & {
364
+ htmx: {
365
+ connectors: {
366
+ grants: {
367
+ ":id": {
368
+ delete: {
369
+ body: unknown;
370
+ params: {
371
+ id: string;
372
+ } & {};
373
+ query: unknown;
374
+ headers: unknown;
375
+ response: {
376
+ 200: {} | Response;
377
+ 400: "Cookies are missing";
378
+ 401: "User is not authenticated";
379
+ 422: {
380
+ type: "validation";
381
+ on: string;
382
+ summary?: string;
383
+ message?: string;
384
+ found?: unknown;
385
+ property?: string;
386
+ expected?: string;
387
+ };
388
+ };
389
+ };
390
+ };
391
+ };
392
+ };
393
+ };
394
+ } & {
395
+ htmx: {
396
+ connectors: {
397
+ bindings: {
398
+ ":id": {
399
+ delete: {
400
+ body: unknown;
401
+ params: {
402
+ id: string;
403
+ } & {};
404
+ query: unknown;
405
+ headers: unknown;
406
+ response: {
407
+ 200: {} | Response;
408
+ 400: "Cookies are missing";
409
+ 401: "User is not authenticated";
410
+ 422: {
411
+ type: "validation";
412
+ on: string;
413
+ summary?: string;
414
+ message?: string;
415
+ found?: unknown;
416
+ property?: string;
417
+ expected?: string;
418
+ };
419
+ };
420
+ };
421
+ };
422
+ };
423
+ };
424
+ };
425
+ } & {
426
+ htmx: {
427
+ "login-redirect": {
428
+ get: {
429
+ body: unknown;
430
+ params: {};
431
+ query: unknown;
432
+ headers: unknown;
433
+ response: {
434
+ 200: Response;
435
+ 422: {
436
+ type: "validation";
437
+ on: string;
438
+ summary?: string;
439
+ message?: string;
440
+ found?: unknown;
441
+ property?: string;
442
+ expected?: string;
443
+ };
444
+ };
445
+ };
446
+ };
447
+ };
448
+ } & {
449
+ htmx: {
450
+ "delete-account": {
451
+ post: {
452
+ body: unknown;
453
+ params: {};
454
+ query: unknown;
455
+ headers: unknown;
456
+ response: {
457
+ 200: {} | Response;
458
+ 400: "Cookies are missing";
459
+ 401: "User is not authenticated";
460
+ 422: {
461
+ type: "validation";
462
+ on: string;
463
+ summary?: string;
464
+ message?: string;
465
+ found?: unknown;
466
+ property?: string;
467
+ expected?: string;
468
+ };
469
+ };
470
+ };
471
+ };
472
+ };
473
+ } & {
474
+ htmx: {
475
+ signout: {
476
+ get: {
477
+ body: unknown;
478
+ params: {};
479
+ query: unknown;
480
+ headers: unknown;
481
+ response: {
482
+ 200: Response;
483
+ 422: {
484
+ type: "validation";
485
+ on: string;
486
+ summary?: string;
487
+ message?: string;
488
+ found?: unknown;
489
+ property?: string;
490
+ expected?: string;
491
+ };
492
+ };
493
+ };
494
+ };
495
+ };
496
+ }, {
497
+ derive: {};
498
+ resolve: {};
499
+ schema: {};
500
+ standaloneSchema: {};
501
+ response: {};
502
+ }, {
503
+ derive: {};
504
+ resolve: {};
505
+ schema: {};
506
+ standaloneSchema: {};
507
+ response: {};
508
+ } & {
509
+ derive: {};
510
+ resolve: {};
511
+ schema: {};
512
+ standaloneSchema: {};
513
+ response: {};
514
+ }>;