@absolutejs/auth 0.74.0 → 0.75.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 (39) hide show
  1. package/README.md +8 -6
  2. package/dist/apikeys/routes.d.ts +1 -1
  3. package/dist/compliance/routes.d.ts +1 -1
  4. package/dist/credentials/emailVerification.d.ts +1 -1
  5. package/dist/credentials/login.d.ts +1 -1
  6. package/dist/credentials/passwordReset.d.ts +1 -1
  7. package/dist/credentials/register.d.ts +1 -1
  8. package/dist/htmx/configuredRoutes.d.ts +1 -1
  9. package/dist/htmx/routes.d.ts +1 -1
  10. package/dist/index.js +116 -57
  11. package/dist/index.js.map +5 -5
  12. package/dist/mfa/challenge.d.ts +1 -1
  13. package/dist/mfa/management.d.ts +1 -1
  14. package/dist/mfa/sms.d.ts +1 -1
  15. package/dist/mfa/totp.d.ts +1 -1
  16. package/dist/nativePush.d.ts +500 -20
  17. package/dist/organizations/routes.d.ts +1 -1
  18. package/dist/portal/routes.d.ts +1 -1
  19. package/dist/roles/routes.d.ts +1 -1
  20. package/dist/routes/authorize.d.ts +1 -1
  21. package/dist/routes/callback.d.ts +1 -1
  22. package/dist/routes/profile.d.ts +1 -1
  23. package/dist/routes/refresh.d.ts +1 -1
  24. package/dist/routes/revoke.d.ts +1 -1
  25. package/dist/routes/sessions.d.ts +1 -1
  26. package/dist/routes/signout.d.ts +1 -1
  27. package/dist/routes/userStatus.d.ts +1 -1
  28. package/dist/scim/routes.d.ts +1 -1
  29. package/dist/server.js +114 -57
  30. package/dist/server.js.map +5 -5
  31. package/dist/sso/discoveryRoute.d.ts +1 -1
  32. package/dist/sso/oidcRoutes.d.ts +1 -1
  33. package/dist/sso/samlIdpRoutes.d.ts +1 -1
  34. package/dist/sso/samlRoutes.d.ts +1 -1
  35. package/dist/types.d.ts +3 -1
  36. package/dist/vc/statusListRoutes.d.ts +1 -1
  37. package/dist/vc/vpRoutes.d.ts +1 -1
  38. package/dist/webauthn/routes.d.ts +1 -1
  39. package/package.json +1 -1
@@ -127,7 +127,7 @@ export declare const portalRoutes: ({ emit, onScimTokenCreated, onSsoConnectionC
127
127
  status?: number | keyof import("elysia").StatusMap;
128
128
  cookie?: Record<string, import("elysia").BaseCookie>;
129
129
  };
130
- status: <const Code extends number | keyof import("elysia").StatusMap, const T = Code extends 400 | 401 | 403 | 501 | 204 | 404 | 200 | 301 | 302 | 303 | 307 | 308 | 100 | 101 | 102 | 103 | 201 | 202 | 203 | 205 | 206 | 207 | 208 | 300 | 304 | 402 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 420 | 421 | 422 | 423 | 424 | 425 | 426 | 428 | 429 | 431 | 451 | 500 | 502 | 503 | 504 | 505 | 506 | 507 | 508 | 510 | 511 ? {
130
+ status: <const Code extends number | keyof import("elysia").StatusMap, const T = Code extends 400 | 401 | 403 | 501 | 204 | 404 | 200 | 301 | 302 | 303 | 307 | 308 | 409 | 100 | 101 | 102 | 103 | 201 | 202 | 203 | 205 | 206 | 207 | 208 | 300 | 304 | 402 | 405 | 406 | 407 | 408 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 420 | 421 | 422 | 423 | 424 | 425 | 426 | 428 | 429 | 431 | 451 | 500 | 502 | 503 | 504 | 505 | 506 | 507 | 508 | 510 | 511 ? {
131
131
  readonly 100: "Continue";
132
132
  readonly 101: "Switching Protocols";
133
133
  readonly 102: "Processing";
@@ -78,7 +78,7 @@ export declare const roleRoutes: <UserType>({ authSessionStore, canManageRoles,
78
78
  status?: number | keyof import("elysia").StatusMap;
79
79
  cookie?: Record<string, import("elysia").BaseCookie>;
80
80
  };
81
- status: <const Code extends number | keyof import("elysia").StatusMap, const T = Code extends 400 | 401 | 403 | 501 | 204 | 404 | 200 | 301 | 302 | 303 | 307 | 308 | 100 | 101 | 102 | 103 | 201 | 202 | 203 | 205 | 206 | 207 | 208 | 300 | 304 | 402 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 420 | 421 | 422 | 423 | 424 | 425 | 426 | 428 | 429 | 431 | 451 | 500 | 502 | 503 | 504 | 505 | 506 | 507 | 508 | 510 | 511 ? {
81
+ status: <const Code extends number | keyof import("elysia").StatusMap, const T = Code extends 400 | 401 | 403 | 501 | 204 | 404 | 200 | 301 | 302 | 303 | 307 | 308 | 409 | 100 | 101 | 102 | 103 | 201 | 202 | 203 | 205 | 206 | 207 | 208 | 300 | 304 | 402 | 405 | 406 | 407 | 408 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 420 | 421 | 422 | 423 | 424 | 425 | 426 | 428 | 429 | 431 | 451 | 500 | 502 | 503 | 504 | 505 | 506 | 507 | 508 | 510 | 511 ? {
82
82
  readonly 100: "Continue";
83
83
  readonly 101: "Switching Protocols";
84
84
  readonly 102: "Processing";
@@ -44,7 +44,7 @@ export declare const authorize: ({ clientProviders, authorizeRoute, cookieSecure
44
44
  status?: number | keyof import("elysia").StatusMap;
45
45
  cookie?: Record<string, import("elysia").BaseCookie>;
46
46
  };
47
- status: <const Code extends number | keyof import("elysia").StatusMap, const T = Code extends 400 | 401 | 403 | 501 | 204 | 404 | 200 | 301 | 302 | 303 | 307 | 308 | 100 | 101 | 102 | 103 | 201 | 202 | 203 | 205 | 206 | 207 | 208 | 300 | 304 | 402 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 420 | 421 | 422 | 423 | 424 | 425 | 426 | 428 | 429 | 431 | 451 | 500 | 502 | 503 | 504 | 505 | 506 | 507 | 508 | 510 | 511 ? {
47
+ status: <const Code extends number | keyof import("elysia").StatusMap, const T = Code extends 400 | 401 | 403 | 501 | 204 | 404 | 200 | 301 | 302 | 303 | 307 | 308 | 409 | 100 | 101 | 102 | 103 | 201 | 202 | 203 | 205 | 206 | 207 | 208 | 300 | 304 | 402 | 405 | 406 | 407 | 408 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 420 | 421 | 422 | 423 | 424 | 425 | 426 | 428 | 429 | 431 | 451 | 500 | 502 | 503 | 504 | 505 | 506 | 507 | 508 | 510 | 511 ? {
48
48
  readonly 100: "Continue";
49
49
  readonly 101: "Switching Protocols";
50
50
  readonly 102: "Processing";
@@ -58,7 +58,7 @@ export declare const callback: <UserType>({ authSessionStore, clientProviders, c
58
58
  status?: number | keyof import("elysia").StatusMap;
59
59
  cookie?: Record<string, import("elysia").BaseCookie>;
60
60
  };
61
- status: <const Code extends number | keyof import("elysia").StatusMap, const T = Code extends 400 | 401 | 403 | 501 | 204 | 404 | 200 | 301 | 302 | 303 | 307 | 308 | 100 | 101 | 102 | 103 | 201 | 202 | 203 | 205 | 206 | 207 | 208 | 300 | 304 | 402 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 420 | 421 | 422 | 423 | 424 | 425 | 426 | 428 | 429 | 431 | 451 | 500 | 502 | 503 | 504 | 505 | 506 | 507 | 508 | 510 | 511 ? {
61
+ status: <const Code extends number | keyof import("elysia").StatusMap, const T = Code extends 400 | 401 | 403 | 501 | 204 | 404 | 200 | 301 | 302 | 303 | 307 | 308 | 409 | 100 | 101 | 102 | 103 | 201 | 202 | 203 | 205 | 206 | 207 | 208 | 300 | 304 | 402 | 405 | 406 | 407 | 408 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 420 | 421 | 422 | 423 | 424 | 425 | 426 | 428 | 429 | 431 | 451 | 500 | 502 | 503 | 504 | 505 | 506 | 507 | 508 | 510 | 511 ? {
62
62
  readonly 100: "Continue";
63
63
  readonly 101: "Switching Protocols";
64
64
  readonly 102: "Processing";
@@ -46,7 +46,7 @@ export declare const profile: <UserType>({ authSessionStore, clientProviders, pr
46
46
  status?: number | keyof import("elysia").StatusMap;
47
47
  cookie?: Record<string, import("elysia").BaseCookie>;
48
48
  };
49
- status: <const Code extends number | keyof import("elysia").StatusMap, const T = Code extends 400 | 401 | 403 | 501 | 204 | 404 | 200 | 301 | 302 | 303 | 307 | 308 | 100 | 101 | 102 | 103 | 201 | 202 | 203 | 205 | 206 | 207 | 208 | 300 | 304 | 402 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 420 | 421 | 422 | 423 | 424 | 425 | 426 | 428 | 429 | 431 | 451 | 500 | 502 | 503 | 504 | 505 | 506 | 507 | 508 | 510 | 511 ? {
49
+ status: <const Code extends number | keyof import("elysia").StatusMap, const T = Code extends 400 | 401 | 403 | 501 | 204 | 404 | 200 | 301 | 302 | 303 | 307 | 308 | 409 | 100 | 101 | 102 | 103 | 201 | 202 | 203 | 205 | 206 | 207 | 208 | 300 | 304 | 402 | 405 | 406 | 407 | 408 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 420 | 421 | 422 | 423 | 424 | 425 | 426 | 428 | 429 | 431 | 451 | 500 | 502 | 503 | 504 | 505 | 506 | 507 | 508 | 510 | 511 ? {
50
50
  readonly 100: "Continue";
51
51
  readonly 101: "Switching Protocols";
52
52
  readonly 102: "Processing";
@@ -47,7 +47,7 @@ export declare const refresh: <UserType>({ authSessionStore, clientProviders, re
47
47
  status?: number | keyof import("elysia").StatusMap;
48
48
  cookie?: Record<string, import("elysia").BaseCookie>;
49
49
  };
50
- status: <const Code extends number | keyof import("elysia").StatusMap, const T = Code extends 400 | 401 | 403 | 501 | 204 | 404 | 200 | 301 | 302 | 303 | 307 | 308 | 100 | 101 | 102 | 103 | 201 | 202 | 203 | 205 | 206 | 207 | 208 | 300 | 304 | 402 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 420 | 421 | 422 | 423 | 424 | 425 | 426 | 428 | 429 | 431 | 451 | 500 | 502 | 503 | 504 | 505 | 506 | 507 | 508 | 510 | 511 ? {
50
+ status: <const Code extends number | keyof import("elysia").StatusMap, const T = Code extends 400 | 401 | 403 | 501 | 204 | 404 | 200 | 301 | 302 | 303 | 307 | 308 | 409 | 100 | 101 | 102 | 103 | 201 | 202 | 203 | 205 | 206 | 207 | 208 | 300 | 304 | 402 | 405 | 406 | 407 | 408 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 420 | 421 | 422 | 423 | 424 | 425 | 426 | 428 | 429 | 431 | 451 | 500 | 502 | 503 | 504 | 505 | 506 | 507 | 508 | 510 | 511 ? {
51
51
  readonly 100: "Continue";
52
52
  readonly 101: "Switching Protocols";
53
53
  readonly 102: "Processing";
@@ -46,7 +46,7 @@ export declare const revoke: <UserType>({ authSessionStore, clientProviders, rev
46
46
  status?: number | keyof import("elysia").StatusMap;
47
47
  cookie?: Record<string, import("elysia").BaseCookie>;
48
48
  };
49
- status: <const Code extends number | keyof import("elysia").StatusMap, const T = Code extends 400 | 401 | 403 | 501 | 204 | 404 | 200 | 301 | 302 | 303 | 307 | 308 | 100 | 101 | 102 | 103 | 201 | 202 | 203 | 205 | 206 | 207 | 208 | 300 | 304 | 402 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 420 | 421 | 422 | 423 | 424 | 425 | 426 | 428 | 429 | 431 | 451 | 500 | 502 | 503 | 504 | 505 | 506 | 507 | 508 | 510 | 511 ? {
49
+ status: <const Code extends number | keyof import("elysia").StatusMap, const T = Code extends 400 | 401 | 403 | 501 | 204 | 404 | 200 | 301 | 302 | 303 | 307 | 308 | 409 | 100 | 101 | 102 | 103 | 201 | 202 | 203 | 205 | 206 | 207 | 208 | 300 | 304 | 402 | 405 | 406 | 407 | 408 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 420 | 421 | 422 | 423 | 424 | 425 | 426 | 428 | 429 | 431 | 451 | 500 | 502 | 503 | 504 | 505 | 506 | 507 | 508 | 510 | 511 ? {
50
50
  readonly 100: "Continue";
51
51
  readonly 101: "Switching Protocols";
52
52
  readonly 102: "Processing";
@@ -73,7 +73,7 @@ export declare const sessionRoutes: <UserType>({ authSessionStore, getUserId, se
73
73
  status?: number | keyof import("elysia").StatusMap;
74
74
  cookie?: Record<string, import("elysia").BaseCookie>;
75
75
  };
76
- status: <const Code extends number | keyof import("elysia").StatusMap, const T = Code extends 400 | 401 | 403 | 501 | 204 | 404 | 200 | 301 | 302 | 303 | 307 | 308 | 100 | 101 | 102 | 103 | 201 | 202 | 203 | 205 | 206 | 207 | 208 | 300 | 304 | 402 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 420 | 421 | 422 | 423 | 424 | 425 | 426 | 428 | 429 | 431 | 451 | 500 | 502 | 503 | 504 | 505 | 506 | 507 | 508 | 510 | 511 ? {
76
+ status: <const Code extends number | keyof import("elysia").StatusMap, const T = Code extends 400 | 401 | 403 | 501 | 204 | 404 | 200 | 301 | 302 | 303 | 307 | 308 | 409 | 100 | 101 | 102 | 103 | 201 | 202 | 203 | 205 | 206 | 207 | 208 | 300 | 304 | 402 | 405 | 406 | 407 | 408 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 420 | 421 | 422 | 423 | 424 | 425 | 426 | 428 | 429 | 431 | 451 | 500 | 502 | 503 | 504 | 505 | 506 | 507 | 508 | 510 | 511 ? {
77
77
  readonly 100: "Continue";
78
78
  readonly 101: "Switching Protocols";
79
79
  readonly 102: "Processing";
@@ -42,7 +42,7 @@ export declare const signout: <UserType>({ authSessionStore, signoutRoute, onSig
42
42
  status?: number | keyof import("elysia").StatusMap;
43
43
  cookie?: Record<string, import("elysia").BaseCookie>;
44
44
  };
45
- status: <const Code extends number | keyof import("elysia").StatusMap, const T = Code extends 400 | 401 | 403 | 501 | 204 | 404 | 200 | 301 | 302 | 303 | 307 | 308 | 100 | 101 | 102 | 103 | 201 | 202 | 203 | 205 | 206 | 207 | 208 | 300 | 304 | 402 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 420 | 421 | 422 | 423 | 424 | 425 | 426 | 428 | 429 | 431 | 451 | 500 | 502 | 503 | 504 | 505 | 506 | 507 | 508 | 510 | 511 ? {
45
+ status: <const Code extends number | keyof import("elysia").StatusMap, const T = Code extends 400 | 401 | 403 | 501 | 204 | 404 | 200 | 301 | 302 | 303 | 307 | 308 | 409 | 100 | 101 | 102 | 103 | 201 | 202 | 203 | 205 | 206 | 207 | 208 | 300 | 304 | 402 | 405 | 406 | 407 | 408 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 420 | 421 | 422 | 423 | 424 | 425 | 426 | 428 | 429 | 431 | 451 | 500 | 502 | 503 | 504 | 505 | 506 | 507 | 508 | 510 | 511 ? {
46
46
  readonly 100: "Continue";
47
47
  readonly 101: "Switching Protocols";
48
48
  readonly 102: "Processing";
@@ -40,7 +40,7 @@ export declare const userStatus: <UserType>({ authSessionStore, statusRoute, onS
40
40
  status?: number | keyof import("elysia").StatusMap;
41
41
  cookie?: Record<string, import("elysia").BaseCookie>;
42
42
  };
43
- status: <const Code extends number | keyof import("elysia").StatusMap, const T = Code extends 400 | 401 | 403 | 501 | 204 | 404 | 200 | 301 | 302 | 303 | 307 | 308 | 100 | 101 | 102 | 103 | 201 | 202 | 203 | 205 | 206 | 207 | 208 | 300 | 304 | 402 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 420 | 421 | 422 | 423 | 424 | 425 | 426 | 428 | 429 | 431 | 451 | 500 | 502 | 503 | 504 | 505 | 506 | 507 | 508 | 510 | 511 ? {
43
+ status: <const Code extends number | keyof import("elysia").StatusMap, const T = Code extends 400 | 401 | 403 | 501 | 204 | 404 | 200 | 301 | 302 | 303 | 307 | 308 | 409 | 100 | 101 | 102 | 103 | 201 | 202 | 203 | 205 | 206 | 207 | 208 | 300 | 304 | 402 | 405 | 406 | 407 | 408 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 420 | 421 | 422 | 423 | 424 | 425 | 426 | 428 | 429 | 431 | 451 | 500 | 502 | 503 | 504 | 505 | 506 | 507 | 508 | 510 | 511 ? {
44
44
  readonly 100: "Continue";
45
45
  readonly 101: "Switching Protocols";
46
46
  readonly 102: "Processing";
@@ -361,7 +361,7 @@ export declare const scimRoutes: ({ customAttributes, getScimGroup, getScimUser,
361
361
  status?: number | keyof import("elysia").StatusMap;
362
362
  cookie?: Record<string, import("elysia").BaseCookie>;
363
363
  };
364
- status: <const Code extends number | keyof import("elysia").StatusMap, const T = Code extends 400 | 401 | 403 | 501 | 204 | 404 | 200 | 301 | 302 | 303 | 307 | 308 | 100 | 101 | 102 | 103 | 201 | 202 | 203 | 205 | 206 | 207 | 208 | 300 | 304 | 402 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 420 | 421 | 422 | 423 | 424 | 425 | 426 | 428 | 429 | 431 | 451 | 500 | 502 | 503 | 504 | 505 | 506 | 507 | 508 | 510 | 511 ? {
364
+ status: <const Code extends number | keyof import("elysia").StatusMap, const T = Code extends 400 | 401 | 403 | 501 | 204 | 404 | 200 | 301 | 302 | 303 | 307 | 308 | 409 | 100 | 101 | 102 | 103 | 201 | 202 | 203 | 205 | 206 | 207 | 208 | 300 | 304 | 402 | 405 | 406 | 407 | 408 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 420 | 421 | 422 | 423 | 424 | 425 | 426 | 428 | 429 | 431 | 451 | 500 | 502 | 503 | 504 | 505 | 506 | 507 | 508 | 510 | 511 ? {
365
365
  readonly 100: "Continue";
366
366
  readonly 101: "Switching Protocols";
367
367
  readonly 102: "Processing";
package/dist/server.js CHANGED
@@ -7187,24 +7187,97 @@ var createMfaGate = ({ getUserId, mfaStore }) => async (user) => isMfaEnrolled(a
7187
7187
 
7188
7188
  // src/nativePush.ts
7189
7189
  import { Elysia as Elysia17, t as t11 } from "elysia";
7190
+ var DEFAULT_PUSH_ROUTE = "/auth/push";
7190
7191
  var DEFAULT_NATIVE_PUSH_ROUTE = "/auth/mobile/push";
7191
7192
  var requireServerText = (value, field) => {
7192
7193
  const normalized = value.trim();
7193
7194
  if (!normalized)
7194
- throw new TypeError(`Native push ${field} must not be empty.`);
7195
+ throw new TypeError(`Push ${field} must not be empty.`);
7195
7196
  return normalized;
7196
7197
  };
7197
7198
  var isInstallationOwnershipError = (error) => error instanceof Error && error.name === "PushInstallationOwnershipError";
7198
- var nativePushRoutes = ({
7199
+ var pushRoutes = ({
7199
7200
  accessTokens,
7200
7201
  authSessionStore,
7201
7202
  config
7202
7203
  }) => {
7203
- const resolveTenant = async (principal) => requireServerText(typeof config.tenant === "function" ? await config.tenant(principal) : config.tenant, "native tenant");
7204
+ const resolveTenant = async (principal) => requireServerText(typeof config.tenant === "function" ? await config.tenant(principal) : config.tenant, "tenant");
7204
7205
  const resolveTopics = async (principal) => [
7205
7206
  ...new Set((await config.topics?.(principal) ?? []).map((topic) => requireServerText(topic, "topic")))
7206
7207
  ].sort();
7207
- return new Elysia17({ name: "@absolutejs/auth/native-push" }).use(sessionStore()).guard({
7208
+ const register = async (body, principal) => {
7209
+ try {
7210
+ const registration = await config.registrar.registerInstallation({
7211
+ ...body.installationId ? { installationId: body.installationId } : {},
7212
+ ...body.locale ? { locale: body.locale } : {},
7213
+ ...body.platform === "webpush" ? {
7214
+ platform: body.platform,
7215
+ subscription: body.subscription
7216
+ } : { platform: body.platform, token: body.token },
7217
+ tenant: await resolveTenant(principal),
7218
+ topics: await resolveTopics(principal),
7219
+ userId: principal.subject
7220
+ });
7221
+ return {
7222
+ installationId: requireServerText(registration.installationId, "installation id"),
7223
+ registered: true
7224
+ };
7225
+ } catch (error) {
7226
+ if (isInstallationOwnershipError(error))
7227
+ return null;
7228
+ throw error;
7229
+ }
7230
+ };
7231
+ const remove = async (installationId, principal) => {
7232
+ try {
7233
+ await config.registrar.removeInstallation({
7234
+ installationId,
7235
+ tenant: await resolveTenant(principal),
7236
+ userId: principal.subject
7237
+ });
7238
+ } catch (error) {
7239
+ if (isInstallationOwnershipError(error))
7240
+ return false;
7241
+ throw error;
7242
+ }
7243
+ return true;
7244
+ };
7245
+ const commonRegistrationFields = {
7246
+ installationId: t11.Optional(t11.String({ maxLength: 128, minLength: 1 })),
7247
+ locale: t11.Optional(t11.String({ maxLength: 64, minLength: 1 }))
7248
+ };
7249
+ const registrationBody = t11.Union([
7250
+ t11.Object({
7251
+ ...commonRegistrationFields,
7252
+ platform: t11.Union([t11.Literal("apns"), t11.Literal("fcm")]),
7253
+ token: t11.String({ maxLength: 8192, minLength: 1 })
7254
+ }),
7255
+ t11.Object({
7256
+ ...commonRegistrationFields,
7257
+ platform: t11.Literal("webpush"),
7258
+ subscription: t11.Object({
7259
+ endpoint: t11.String({ maxLength: 8192, minLength: 1 }),
7260
+ keys: t11.Object({
7261
+ auth: t11.String({ maxLength: 8192, minLength: 1 }),
7262
+ p256dh: t11.String({ maxLength: 8192, minLength: 1 })
7263
+ })
7264
+ })
7265
+ })
7266
+ ]);
7267
+ const registrationOptions = {
7268
+ body: registrationBody,
7269
+ beforeHandle: ({
7270
+ pushPrincipal,
7271
+ status
7272
+ }) => pushPrincipal ? undefined : status("Unauthorized", "User is not authenticated")
7273
+ };
7274
+ const removalOptions = {
7275
+ body: t11.Object({
7276
+ installationId: t11.String({ maxLength: 128, minLength: 1 })
7277
+ }),
7278
+ beforeHandle: registrationOptions.beforeHandle
7279
+ };
7280
+ return new Elysia17({ name: "@absolutejs/auth/push" }).use(sessionStore()).guard({
7208
7281
  cookie: t11.Cookie({ user_session_id: userSessionIdTypebox }),
7209
7282
  schema: "merge"
7210
7283
  }).derive(async ({
@@ -7225,56 +7298,36 @@ var nativePushRoutes = ({
7225
7298
  authorization: headers.authorization,
7226
7299
  config: accessTokens
7227
7300
  });
7228
- return { nativePushPrincipal: principal };
7229
- }).post(DEFAULT_NATIVE_PUSH_ROUTE, {
7230
- body: t11.Object({
7231
- installationId: t11.Optional(t11.String({ maxLength: 128, minLength: 1 })),
7232
- locale: t11.Optional(t11.String({ maxLength: 64, minLength: 1 })),
7233
- platform: t11.Union([t11.Literal("apns"), t11.Literal("fcm")]),
7234
- token: t11.String({ maxLength: 8192, minLength: 1 })
7235
- }),
7236
- beforeHandle: ({ nativePushPrincipal, status }) => nativePushPrincipal ? undefined : status("Unauthorized", "User is not authenticated")
7237
- }, async ({ body, nativePushPrincipal, status }) => {
7238
- if (!nativePushPrincipal)
7301
+ return { pushPrincipal: principal };
7302
+ }).post(DEFAULT_PUSH_ROUTE, registrationOptions, async ({ body, pushPrincipal, status }) => {
7303
+ if (!pushPrincipal)
7239
7304
  return status("Unauthorized", "User is not authenticated");
7240
- let registration;
7241
- try {
7242
- registration = await config.registrar.registerInstallation({
7243
- ...body.installationId ? { installationId: body.installationId } : {},
7244
- ...body.locale ? { locale: body.locale } : {},
7245
- platform: body.platform,
7246
- tenant: await resolveTenant(nativePushPrincipal),
7247
- token: body.token,
7248
- topics: await resolveTopics(nativePushPrincipal),
7249
- userId: nativePushPrincipal.subject
7250
- });
7251
- } catch (error) {
7252
- if (isInstallationOwnershipError(error))
7253
- return status("Conflict", {
7254
- code: "installation-ownership"
7255
- });
7256
- throw error;
7257
- }
7258
- return {
7259
- installationId: requireServerText(registration.installationId, "installation id"),
7260
- registered: true
7261
- };
7262
- }).delete(DEFAULT_NATIVE_PUSH_ROUTE, {
7263
- body: t11.Object({
7264
- installationId: t11.String({ maxLength: 128, minLength: 1 })
7265
- }),
7266
- beforeHandle: ({ nativePushPrincipal, status }) => nativePushPrincipal ? undefined : status("Unauthorized", "User is not authenticated")
7267
- }, async ({ body, nativePushPrincipal, status }) => {
7268
- if (!nativePushPrincipal)
7305
+ const result = await register(body, pushPrincipal);
7306
+ return result ?? status("Conflict", {
7307
+ code: "installation-ownership"
7308
+ });
7309
+ }).post(DEFAULT_NATIVE_PUSH_ROUTE, registrationOptions, async ({ body, pushPrincipal, status }) => {
7310
+ if (!pushPrincipal)
7311
+ return status("Unauthorized", "User is not authenticated");
7312
+ const result = await register(body, pushPrincipal);
7313
+ return result ?? status("Conflict", {
7314
+ code: "installation-ownership"
7315
+ });
7316
+ }).delete(DEFAULT_PUSH_ROUTE, removalOptions, async ({ body, pushPrincipal, status }) => {
7317
+ if (!pushPrincipal)
7318
+ return status("Unauthorized", "User is not authenticated");
7319
+ return await remove(body.installationId, pushPrincipal) ? { removed: true } : status("Conflict", {
7320
+ code: "installation-ownership"
7321
+ });
7322
+ }).delete(DEFAULT_NATIVE_PUSH_ROUTE, removalOptions, async ({ body, pushPrincipal, status }) => {
7323
+ if (!pushPrincipal)
7269
7324
  return status("Unauthorized", "User is not authenticated");
7270
- await config.registrar.removeInstallation({
7271
- installationId: body.installationId,
7272
- tenant: await resolveTenant(nativePushPrincipal),
7273
- userId: nativePushPrincipal.subject
7325
+ return await remove(body.installationId, pushPrincipal) ? { removed: true } : status("Conflict", {
7326
+ code: "installation-ownership"
7274
7327
  });
7275
- return { removed: true };
7276
7328
  });
7277
7329
  };
7330
+ var nativePushRoutes = pushRoutes;
7278
7331
 
7279
7332
  // src/mfa/routes.ts
7280
7333
  import { Elysia as Elysia22 } from "elysia";
@@ -41043,6 +41096,7 @@ var buildAuthApplications = async (configuration) => {
41043
41096
  customProviders,
41044
41097
  mfa,
41045
41098
  nativePush: nativePush2,
41099
+ push,
41046
41100
  verificationProvider,
41047
41101
  passwordless,
41048
41102
  lockout,
@@ -41079,8 +41133,11 @@ var buildAuthApplications = async (configuration) => {
41079
41133
  onRevocationError,
41080
41134
  onSessionCleanup
41081
41135
  } = configuration;
41082
- if (nativePush2 && !oidc)
41083
- throw new Error("nativePush requires the OIDC provider");
41136
+ if (push && nativePush2)
41137
+ throw new Error("Configure `push`, not both `push` and `nativePush`");
41138
+ const pushConfig = push ?? nativePush2;
41139
+ if (pushConfig && !oidc)
41140
+ throw new Error("push requires the OIDC provider");
41084
41141
  if (agentAuth?.agentRegistration !== undefined) {
41085
41142
  if (oidc === undefined) {
41086
41143
  throw new Error("agentAuth.agentRegistration requires the OIDC provider");
@@ -41324,18 +41381,18 @@ var buildAuthApplications = async (configuration) => {
41324
41381
  emit: auditEmit
41325
41382
  }) : new Elysia48
41326
41383
  ]);
41327
- const nativePushApplication = new Elysia48;
41328
- if (nativePush2 && oidcConfig)
41329
- nativePushApplication.use(nativePushRoutes({
41384
+ const pushApplication = new Elysia48;
41385
+ if (pushConfig && oidcConfig)
41386
+ pushApplication.use(pushRoutes({
41330
41387
  accessTokens: {
41331
41388
  oidc: oidcConfig,
41332
41389
  getUser: async (subject) => await getUser(subject) ?? null
41333
41390
  },
41334
41391
  authSessionStore,
41335
- config: nativePush2
41392
+ config: pushConfig
41336
41393
  }));
41337
41394
  const extendedFeatureRoutes = new Elysia48().use([
41338
- nativePushApplication,
41395
+ pushApplication,
41339
41396
  portal ? portalRoutes({ ...portal, emit: auditEmit }) : new Elysia48,
41340
41397
  webauthn ? webauthnRoutes({
41341
41398
  ...webauthn,
@@ -41562,5 +41619,5 @@ export {
41562
41619
  VerificationProviderError
41563
41620
  };
41564
41621
 
41565
- //# debugId=67A260E7AE17ECB564756E2164756E21
41622
+ //# debugId=471E09DA92BB95D564756E2164756E21
41566
41623
  //# sourceMappingURL=server.js.map