@absolutejs/auth 0.23.0 → 0.24.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,10 +1,14 @@
1
1
  import { Elysia } from 'elysia';
2
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<"", {
3
+ import type { AuthHtmxUser } from './ui/types';
4
+ export declare const absoluteAuth: <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 }: AbsoluteAuthProps<UserType>) => Promise<Elysia<"", {
4
5
  decorator: {};
5
6
  store: {
6
7
  session: import("./types").SessionRecord<UserType> & import("./types").SessionRecord<unknown>;
7
8
  unregisteredSession: import("./types").UnregisteredSessionRecord;
9
+ } | {
10
+ session: import("./types").SessionRecord<UserType> & import("./types").SessionRecord<unknown> & import("./types").SessionRecord<UserType & AuthHtmxUser>;
11
+ unregisteredSession: import("./types").UnregisteredSessionRecord;
8
12
  };
9
13
  derive: {
10
14
  readonly cleanupSessions: () => Promise<void>;
@@ -16,7 +20,15 @@ export declare const absoluteAuth: <UserType>({ providersConfiguration, authoriz
16
20
  readonly code: "Unauthorized";
17
21
  readonly message: "User is not authenticated";
18
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>>;
19
- };
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
+ });
20
32
  resolve: {};
21
33
  }, {
22
34
  typebox: {};
@@ -37,7 +49,7 @@ export declare const absoluteAuth: <UserType>({ providersConfiguration, authoriz
37
49
  response: import("elysia").ExtractErrorFromHandle<{
38
50
  readonly cleanupSessions: () => Promise<void>;
39
51
  }>;
40
- } & {
52
+ } & ({
41
53
  schema: import("elysia").UnwrapRoute<{
42
54
  cookie: import("@sinclair/typebox").TObject<{
43
55
  user_session_id: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TTemplateLiteralSyntax<"${string}-${string}-${string}-${string}-${string}">>;
@@ -56,7 +68,40 @@ export declare const absoluteAuth: <UserType>({ providersConfiguration, authoriz
56
68
  readonly message: "User is not authenticated";
57
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>>;
58
70
  }>;
59
- }, ((({
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
+ }))), (((({
60
105
  [x: string]: {
61
106
  delete: {
62
107
  body: unknown;
@@ -255,7 +300,452 @@ export declare const absoluteAuth: <UserType>({ providersConfiguration, authoriz
255
300
  };
256
301
  };
257
302
  };
258
- }) & {}, {
303
+ }) & {}) & ({} | ({
304
+ htmx: {
305
+ login: {
306
+ get: {
307
+ body: unknown;
308
+ params: {};
309
+ query: unknown;
310
+ headers: unknown;
311
+ response: {
312
+ 200: Response;
313
+ 422: {
314
+ type: "validation";
315
+ on: string;
316
+ summary?: string;
317
+ message?: string;
318
+ found?: unknown;
319
+ property?: string;
320
+ expected?: string;
321
+ };
322
+ };
323
+ };
324
+ };
325
+ };
326
+ } & {
327
+ htmx: {
328
+ link: {
329
+ get: {
330
+ body: unknown;
331
+ params: {};
332
+ query: unknown;
333
+ headers: unknown;
334
+ response: {
335
+ 200: Response;
336
+ 422: {
337
+ type: "validation";
338
+ on: string;
339
+ summary?: string;
340
+ message?: string;
341
+ found?: unknown;
342
+ property?: string;
343
+ expected?: string;
344
+ };
345
+ };
346
+ };
347
+ };
348
+ };
349
+ } & {
350
+ htmx: {
351
+ "connector-links": {
352
+ get: {
353
+ body: unknown;
354
+ params: {};
355
+ query: unknown;
356
+ headers: unknown;
357
+ response: {
358
+ 200: Response;
359
+ 422: {
360
+ type: "validation";
361
+ on: string;
362
+ summary?: string;
363
+ message?: string;
364
+ found?: unknown;
365
+ property?: string;
366
+ expected?: string;
367
+ };
368
+ };
369
+ };
370
+ };
371
+ };
372
+ } & {
373
+ htmx: {
374
+ "auth-menu": {
375
+ get: {
376
+ body: unknown;
377
+ params: {};
378
+ query: unknown;
379
+ headers: unknown;
380
+ response: {
381
+ 200: Response;
382
+ 400: "Cookies are missing";
383
+ 401: "User is not authenticated";
384
+ 422: {
385
+ type: "validation";
386
+ on: string;
387
+ summary?: string;
388
+ message?: string;
389
+ found?: unknown;
390
+ property?: string;
391
+ expected?: string;
392
+ };
393
+ };
394
+ };
395
+ };
396
+ };
397
+ } & {
398
+ htmx: {
399
+ me: {
400
+ get: {
401
+ body: unknown;
402
+ params: {};
403
+ query: unknown;
404
+ headers: unknown;
405
+ response: {
406
+ 200: Response;
407
+ 400: "Cookies are missing";
408
+ 401: "User is not authenticated";
409
+ 422: {
410
+ type: "validation";
411
+ on: string;
412
+ summary?: string;
413
+ message?: string;
414
+ found?: unknown;
415
+ property?: string;
416
+ expected?: string;
417
+ };
418
+ };
419
+ };
420
+ };
421
+ };
422
+ } & {
423
+ htmx: {
424
+ account: {
425
+ get: {
426
+ body: unknown;
427
+ params: {};
428
+ query: unknown;
429
+ headers: unknown;
430
+ response: {
431
+ 200: Response;
432
+ 400: "Cookies are missing";
433
+ 401: "User is not authenticated";
434
+ 422: {
435
+ type: "validation";
436
+ on: string;
437
+ summary?: string;
438
+ message?: string;
439
+ found?: unknown;
440
+ property?: string;
441
+ expected?: string;
442
+ };
443
+ };
444
+ };
445
+ };
446
+ };
447
+ } & {
448
+ htmx: {
449
+ identities: {
450
+ get: {
451
+ body: unknown;
452
+ params: {};
453
+ query: unknown;
454
+ headers: unknown;
455
+ response: {
456
+ 200: {} | Response;
457
+ 400: "Cookies are missing";
458
+ 401: "User is not authenticated";
459
+ 422: {
460
+ type: "validation";
461
+ on: string;
462
+ summary?: string;
463
+ message?: string;
464
+ found?: unknown;
465
+ property?: string;
466
+ expected?: string;
467
+ };
468
+ };
469
+ };
470
+ };
471
+ };
472
+ } & {
473
+ htmx: {
474
+ identities: {
475
+ ":id": {
476
+ primary: {
477
+ post: {
478
+ body: unknown;
479
+ params: {
480
+ id: string;
481
+ } & {};
482
+ query: unknown;
483
+ headers: unknown;
484
+ response: {
485
+ 200: {} | Response;
486
+ 400: "Cookies are missing";
487
+ 401: "User is not authenticated";
488
+ 422: {
489
+ type: "validation";
490
+ on: string;
491
+ summary?: string;
492
+ message?: string;
493
+ found?: unknown;
494
+ property?: string;
495
+ expected?: string;
496
+ };
497
+ };
498
+ };
499
+ };
500
+ };
501
+ };
502
+ };
503
+ } & {
504
+ htmx: {
505
+ identities: {
506
+ ":id": {
507
+ delete: {
508
+ body: unknown;
509
+ params: {
510
+ id: string;
511
+ } & {};
512
+ query: unknown;
513
+ headers: unknown;
514
+ response: {
515
+ 200: {} | Response;
516
+ 400: "Cookies are missing";
517
+ 401: "User is not authenticated";
518
+ 422: {
519
+ type: "validation";
520
+ on: string;
521
+ summary?: string;
522
+ message?: string;
523
+ found?: unknown;
524
+ property?: string;
525
+ expected?: string;
526
+ };
527
+ };
528
+ };
529
+ };
530
+ };
531
+ };
532
+ } & {
533
+ htmx: {
534
+ merge: {
535
+ ":id": {
536
+ post: {
537
+ body: unknown;
538
+ params: {
539
+ id: string;
540
+ } & {};
541
+ query: unknown;
542
+ headers: unknown;
543
+ response: {
544
+ 200: {} | Response;
545
+ 400: "Cookies are missing";
546
+ 401: "User is not authenticated";
547
+ 422: {
548
+ type: "validation";
549
+ on: string;
550
+ summary?: string;
551
+ message?: string;
552
+ found?: unknown;
553
+ property?: string;
554
+ expected?: string;
555
+ };
556
+ };
557
+ };
558
+ };
559
+ };
560
+ };
561
+ } & {
562
+ htmx: {
563
+ merge: {
564
+ ":id": {
565
+ delete: {
566
+ body: unknown;
567
+ params: {
568
+ id: string;
569
+ } & {};
570
+ query: unknown;
571
+ headers: unknown;
572
+ response: {
573
+ 200: {} | Response;
574
+ 400: "Cookies are missing";
575
+ 401: "User is not authenticated";
576
+ 422: {
577
+ type: "validation";
578
+ on: string;
579
+ summary?: string;
580
+ message?: string;
581
+ found?: unknown;
582
+ property?: string;
583
+ expected?: string;
584
+ };
585
+ };
586
+ };
587
+ };
588
+ };
589
+ };
590
+ } & {
591
+ htmx: {
592
+ "connector-list": {
593
+ get: {
594
+ body: unknown;
595
+ params: {};
596
+ query: unknown;
597
+ headers: unknown;
598
+ response: {
599
+ 200: Response;
600
+ 400: "Cookies are missing";
601
+ 401: "User is not authenticated";
602
+ 422: {
603
+ type: "validation";
604
+ on: string;
605
+ summary?: string;
606
+ message?: string;
607
+ found?: unknown;
608
+ property?: string;
609
+ expected?: string;
610
+ };
611
+ };
612
+ };
613
+ };
614
+ };
615
+ } & {
616
+ htmx: {
617
+ connectors: {
618
+ grants: {
619
+ ":id": {
620
+ delete: {
621
+ body: unknown;
622
+ params: {
623
+ id: string;
624
+ } & {};
625
+ query: unknown;
626
+ headers: unknown;
627
+ response: {
628
+ 200: {} | Response;
629
+ 400: "Cookies are missing";
630
+ 401: "User is not authenticated";
631
+ 422: {
632
+ type: "validation";
633
+ on: string;
634
+ summary?: string;
635
+ message?: string;
636
+ found?: unknown;
637
+ property?: string;
638
+ expected?: string;
639
+ };
640
+ };
641
+ };
642
+ };
643
+ };
644
+ };
645
+ };
646
+ } & {
647
+ htmx: {
648
+ connectors: {
649
+ bindings: {
650
+ ":id": {
651
+ delete: {
652
+ body: unknown;
653
+ params: {
654
+ id: string;
655
+ } & {};
656
+ query: unknown;
657
+ headers: unknown;
658
+ response: {
659
+ 200: {} | Response;
660
+ 400: "Cookies are missing";
661
+ 401: "User is not authenticated";
662
+ 422: {
663
+ type: "validation";
664
+ on: string;
665
+ summary?: string;
666
+ message?: string;
667
+ found?: unknown;
668
+ property?: string;
669
+ expected?: string;
670
+ };
671
+ };
672
+ };
673
+ };
674
+ };
675
+ };
676
+ };
677
+ } & {
678
+ htmx: {
679
+ "login-redirect": {
680
+ get: {
681
+ body: unknown;
682
+ params: {};
683
+ query: unknown;
684
+ headers: unknown;
685
+ response: {
686
+ 200: Response;
687
+ 422: {
688
+ type: "validation";
689
+ on: string;
690
+ summary?: string;
691
+ message?: string;
692
+ found?: unknown;
693
+ property?: string;
694
+ expected?: string;
695
+ };
696
+ };
697
+ };
698
+ };
699
+ };
700
+ } & {
701
+ htmx: {
702
+ "delete-account": {
703
+ post: {
704
+ body: unknown;
705
+ params: {};
706
+ query: unknown;
707
+ headers: unknown;
708
+ response: {
709
+ 200: {} | Response;
710
+ 400: "Cookies are missing";
711
+ 401: "User is not authenticated";
712
+ 422: {
713
+ type: "validation";
714
+ on: string;
715
+ summary?: string;
716
+ message?: string;
717
+ found?: unknown;
718
+ property?: string;
719
+ expected?: string;
720
+ };
721
+ };
722
+ };
723
+ };
724
+ };
725
+ } & {
726
+ htmx: {
727
+ signout: {
728
+ get: {
729
+ body: unknown;
730
+ params: {};
731
+ query: unknown;
732
+ headers: unknown;
733
+ response: {
734
+ 200: Response;
735
+ 422: {
736
+ type: "validation";
737
+ on: string;
738
+ summary?: string;
739
+ message?: string;
740
+ found?: unknown;
741
+ property?: string;
742
+ expected?: string;
743
+ };
744
+ };
745
+ };
746
+ };
747
+ };
748
+ })), {
259
749
  derive: {};
260
750
  resolve: {};
261
751
  schema: {};
@@ -294,6 +784,9 @@ export { createNeonLinkedProviderStores, createNeonOAuthLinkedProviderCredential
294
784
  export { createInMemoryLinkedProviderStores } from './linkedProviderStores';
295
785
  export { protectRoutePlugin } from './protectRoute';
296
786
  export { sessionCleanup } from './sessionCleanup';
787
+ export { createAuthHtmxRoutes } from './htmxRoutes';
788
+ export { resolveAuthHtmxRenderers } from './ui/renderers';
789
+ export type { AuthHtmxConfig, AuthHtmxConnectorTarget, AuthHtmxProviderData, AuthHtmxProviderInfo, AuthHtmxRenderOverrides, AuthHtmxRenderersConfig, AuthHtmxUser, AuthIdentityPayload, LinkedProviderPayload } from './ui/types';
297
790
  export * from './utils';
298
791
  export { buildClientProviders, resolveClientProviderEntry, resolveProviderClientConfiguration } from './providerClients';
299
792
  export type { OAuth2TokenResponse, OAuth2Client, ProviderOption, PKCEProvider, OIDCProvider, RefreshableProvider, RevocableProvider, ScopeRequiredProvider, ProvidersMap, ProviderConfiguration, CredentialsFor } from 'citra';