@absolutejs/auth 0.55.4 → 0.55.6

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 (52) hide show
  1. package/README.md +6 -1
  2. package/dist/agents/context.d.ts +8 -8
  3. package/dist/agents/index.js +36 -6
  4. package/dist/agents/index.js.map +6 -5
  5. package/dist/agents/routes.d.ts +134 -27
  6. package/dist/apikeys/routes.d.ts +2 -2
  7. package/dist/authContext.d.ts +193 -0
  8. package/dist/authorization/protectPermission.d.ts +4 -4
  9. package/dist/compliance/routes.d.ts +2 -2
  10. package/dist/credentials/login.d.ts +6 -6
  11. package/dist/credentials/register.d.ts +2 -2
  12. package/dist/credentials/routes.d.ts +6 -6
  13. package/dist/htmx/configuredRoutes.d.ts +542 -0
  14. package/dist/htmx/routes.d.ts +4 -4
  15. package/dist/index.d.ts +3399 -8
  16. package/dist/index.js +658 -508
  17. package/dist/index.js.map +15 -12
  18. package/dist/mfa/challenge.d.ts +2 -2
  19. package/dist/mfa/management.d.ts +2 -2
  20. package/dist/mfa/routes.d.ts +4 -4
  21. package/dist/mfa/sms.d.ts +4 -4
  22. package/dist/mfa/totp.d.ts +2 -2
  23. package/dist/oidc/routes.d.ts +14 -14
  24. package/dist/organizations/routes.d.ts +4 -3
  25. package/dist/passwordless/routes.d.ts +7 -6
  26. package/dist/pluginIdentity.d.ts +2 -0
  27. package/dist/portal/routes.d.ts +3 -3
  28. package/dist/roles/routes.d.ts +4 -3
  29. package/dist/routes/callback.d.ts +2 -2
  30. package/dist/routes/profile.d.ts +2 -2
  31. package/dist/routes/protectRoute.d.ts +6 -6
  32. package/dist/routes/refresh.d.ts +3 -3
  33. package/dist/routes/revoke.d.ts +3 -3
  34. package/dist/routes/sessions.d.ts +5 -5
  35. package/dist/routes/signout.d.ts +3 -3
  36. package/dist/routes/stepUp.d.ts +4 -4
  37. package/dist/routes/userStatus.d.ts +2 -2
  38. package/dist/server.d.ts +4 -3
  39. package/dist/server.js +657 -508
  40. package/dist/server.js.map +16 -13
  41. package/dist/session/access.d.ts +3 -3
  42. package/dist/session/cleanup.d.ts +3 -3
  43. package/dist/session/state.d.ts +3 -3
  44. package/dist/session/types.d.ts +1 -0
  45. package/dist/sso/discoveryRoute.d.ts +1 -1
  46. package/dist/sso/oidcRoutes.d.ts +4 -4
  47. package/dist/sso/samlIdpRoutes.d.ts +3 -3
  48. package/dist/sso/samlRoutes.d.ts +7 -6
  49. package/dist/webauthn/routes.d.ts +2 -2
  50. package/package.json +1 -1
  51. package/dist/authInstance.d.ts +0 -7
  52. package/dist/session/internalData.d.ts +0 -34
package/README.md CHANGED
@@ -5,7 +5,12 @@ Server applications should import the primary authentication contract from
5
5
  session types, route protection, provider configuration, and the other core
6
6
  server utilities without loading declarations for every optional Auth feature.
7
7
  The root entry point remains available for applications that need the complete
8
- feature export surface.
8
+ feature export surface. `auth()` exposes the complete reusable request context
9
+ (`protectRoute`, `requireRecentAuth`, optional `protectPermission`, and
10
+ `protectAgent`) while keeping its declaration bounded. Consumers that need the
11
+ typed configurable route applications themselves can call
12
+ `createAuthApplications()` from the root entry point and compose its
13
+ `coreRoutes`, `featureRoutes`, and `authContext` applications independently.
9
14
 
10
15
  ## Overview
11
16
 
@@ -14,7 +14,9 @@ export declare const agentResourceMetadataUrl: (config: AgentAuthConfig) => stri
14
14
  export declare const agentAuthContextPlugin: (config?: AgentAuthConfig) => Elysia<"", {
15
15
  decorator: {};
16
16
  store: {};
17
- derive: {};
17
+ derive: {
18
+ readonly protectAgent: <AuthReturn, AuthFailReturn>(requiredScopes: string[], handleAuth: (principal: AgentPrincipal) => AuthReturn | Promise<AuthReturn>, handleAuthFail?: (error: AgentAuthFailure) => AuthFailReturn | Promise<AuthFailReturn>) => Promise<Response | AuthReturn | NonNullable<Awaited<AuthFailReturn>>>;
19
+ };
18
20
  resolve: {};
19
21
  }, {
20
22
  typebox: {};
@@ -25,7 +27,9 @@ export declare const agentAuthContextPlugin: (config?: AgentAuthConfig) => Elysi
25
27
  macro: {};
26
28
  macroFn: {};
27
29
  parser: {};
28
- response: {};
30
+ response: import("elysia").ExtractErrorFromHandle<{
31
+ readonly protectAgent: <AuthReturn, AuthFailReturn>(requiredScopes: string[], handleAuth: (principal: AgentPrincipal) => AuthReturn | Promise<AuthReturn>, handleAuthFail?: (error: AgentAuthFailure) => AuthFailReturn | Promise<AuthFailReturn>) => Promise<Response | AuthReturn | NonNullable<Awaited<AuthFailReturn>>>;
32
+ }>;
29
33
  }, {}, {
30
34
  derive: {};
31
35
  resolve: {};
@@ -33,14 +37,10 @@ export declare const agentAuthContextPlugin: (config?: AgentAuthConfig) => Elysi
33
37
  standaloneSchema: {};
34
38
  response: {};
35
39
  }, {
36
- derive: {
37
- readonly protectAgent: <AuthReturn, AuthFailReturn>(requiredScopes: string[], handleAuth: (principal: AgentPrincipal) => AuthReturn | Promise<AuthReturn>, handleAuthFail?: (error: AgentAuthFailure) => AuthFailReturn | Promise<AuthFailReturn>) => Promise<Response | AuthReturn | NonNullable<Awaited<AuthFailReturn>>>;
38
- };
40
+ derive: {};
39
41
  resolve: {};
40
42
  schema: {};
41
43
  standaloneSchema: {};
42
- response: import("elysia").ExtractErrorFromHandle<{
43
- readonly protectAgent: <AuthReturn, AuthFailReturn>(requiredScopes: string[], handleAuth: (principal: AgentPrincipal) => AuthReturn | Promise<AuthReturn>, handleAuthFail?: (error: AgentAuthFailure) => AuthFailReturn | Promise<AuthFailReturn>) => Promise<Response | AuthReturn | NonNullable<Awaited<AuthFailReturn>>>;
44
- }>;
44
+ response: {};
45
45
  }>;
46
46
  export {};
@@ -1425,6 +1425,23 @@ var resolveAgentPrincipal = async (request, config) => {
1425
1425
  };
1426
1426
  // src/agents/context.ts
1427
1427
  import { Elysia } from "elysia";
1428
+
1429
+ // src/pluginIdentity.ts
1430
+ var dependencyIds = new WeakMap;
1431
+ var nextDependencyId = 1;
1432
+ var pluginDependencySeed = (dependency) => {
1433
+ if (dependency === undefined)
1434
+ return "default";
1435
+ const existing = dependencyIds.get(dependency);
1436
+ if (existing !== undefined)
1437
+ return existing;
1438
+ const identity = nextDependencyId;
1439
+ nextDependencyId += 1;
1440
+ dependencyIds.set(dependency, identity);
1441
+ return identity;
1442
+ };
1443
+
1444
+ // src/agents/context.ts
1428
1445
  var DELETE_CODE_POINT = 127;
1429
1446
  var HTTP_FORBIDDEN = 403;
1430
1447
  var HTTP_UNAUTHORIZED = 401;
@@ -1467,14 +1484,19 @@ var failureResponse = (config, failure, requiredScopes) => new Response(JSON.str
1467
1484
  },
1468
1485
  status: failure.code === "Forbidden" ? HTTP_FORBIDDEN : HTTP_UNAUTHORIZED
1469
1486
  });
1470
- var agentAuthContextPlugin = (config) => new Elysia().derive(({ request }) => ({
1487
+ var agentAuthContextPlugin = (config) => new Elysia({
1488
+ name: "@absolutejs/auth/agent-context",
1489
+ seed: pluginDependencySeed(config)
1490
+ }).derive(({ request }) => ({
1471
1491
  protectAgent: async (requiredScopes, handleAuth, handleAuthFail) => {
1472
1492
  if (config === undefined) {
1473
1493
  const failure = {
1474
1494
  code: "Unauthorized",
1475
1495
  message: "Agent is not authenticated"
1476
1496
  };
1477
- return await handleAuthFail?.(failure) ?? new Response(failure.message, { status: HTTP_UNAUTHORIZED });
1497
+ return await handleAuthFail?.(failure) ?? new Response(failure.message, {
1498
+ status: HTTP_UNAUTHORIZED
1499
+ });
1478
1500
  }
1479
1501
  const principal = await resolveAgentPrincipal(request, config);
1480
1502
  if (principal === undefined) {
@@ -1493,8 +1515,9 @@ var agentAuthContextPlugin = (config) => new Elysia().derive(({ request }) => ({
1493
1515
  }
1494
1516
  return handleAuth(principal);
1495
1517
  }
1496
- }));
1518
+ })).as("global");
1497
1519
  // src/agents/routes.ts
1520
+ import { Elysia as Elysia2 } from "elysia";
1498
1521
  var HTTP_BAD_REQUEST = 400;
1499
1522
  var HTTP_OK = 200;
1500
1523
  var HTTP_UNAUTHORIZED2 = 401;
@@ -1559,8 +1582,15 @@ var parseRegistrationInput = (value) => {
1559
1582
  return input;
1560
1583
  };
1561
1584
  var escapeHtml = (value) => value.replaceAll("&", "&amp;").replaceAll("<", "&lt;").replaceAll(">", "&gt;").replaceAll('"', "&quot;");
1562
- var agentAuthPlugin = (config) => {
1563
- const plugin = agentAuthContextPlugin(config);
1585
+ var agentAuthPlugin = (config) => new Elysia2({
1586
+ name: "@absolutejs/auth/agent",
1587
+ seed: pluginDependencySeed(config)
1588
+ }).use(agentAuthContextPlugin(config)).use(agentAuthRoutes(config)).as("global");
1589
+ var agentAuthRoutes = (config) => {
1590
+ const plugin = new Elysia2({
1591
+ name: "@absolutejs/auth/agent-routes",
1592
+ seed: pluginDependencySeed(config)
1593
+ });
1564
1594
  if (config === undefined)
1565
1595
  return plugin.as("global");
1566
1596
  if (config.agentRegistration === undefined) {
@@ -12836,5 +12866,5 @@ export {
12836
12866
  AGENT_CLAIM_GRANT_TYPE
12837
12867
  };
12838
12868
 
12839
- //# debugId=35BBF77DF315307D64756E2164756E21
12869
+ //# debugId=0C42692E8F64E63E64756E2164756E21
12840
12870
  //# sourceMappingURL=index.js.map