nestjs-slightly-better-auth 1.4.0 → 1.5.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.
Files changed (74) hide show
  1. package/README.md +15 -10
  2. package/dist/admin.cjs +1 -1
  3. package/dist/admin.d.cts +1 -1
  4. package/dist/admin.d.mts +1 -1
  5. package/dist/admin.mjs +1 -1
  6. package/dist/api-key.cjs +2 -2
  7. package/dist/api-key.d.cts +1 -1
  8. package/dist/api-key.d.mts +1 -1
  9. package/dist/api-key.mjs +2 -2
  10. package/dist/{auth-contracts-CL8TEt5t.d.cts → auth-contracts-B2SAVlKT.d.mts} +9 -7
  11. package/dist/auth-contracts-B2SAVlKT.d.mts.map +1 -0
  12. package/dist/{auth-contracts-CnGaBzlg.d.mts → auth-contracts-mejJfv9d.d.cts} +9 -7
  13. package/dist/auth-contracts-mejJfv9d.d.cts.map +1 -0
  14. package/dist/{auth-decorators-B7xasVk_.cjs → auth-decorators-9L-UO_T3.cjs} +4 -4
  15. package/dist/{auth-decorators-B7xasVk_.cjs.map → auth-decorators-9L-UO_T3.cjs.map} +1 -1
  16. package/dist/{auth-decorators-DUmQ-n_w.mjs → auth-decorators-CQYu3gaF.mjs} +4 -4
  17. package/dist/{auth-decorators-DUmQ-n_w.mjs.map → auth-decorators-CQYu3gaF.mjs.map} +1 -1
  18. package/dist/{auth-guard-D4tzhp9u.mjs → auth-guard-CXsQR7Zd.mjs} +2 -2
  19. package/dist/{auth-guard-D4tzhp9u.mjs.map → auth-guard-CXsQR7Zd.mjs.map} +1 -1
  20. package/dist/{auth-guard-CdV9G47g.cjs → auth-guard-Dh9SWsXf.cjs} +2 -2
  21. package/dist/{auth-guard-CdV9G47g.cjs.map → auth-guard-Dh9SWsXf.cjs.map} +1 -1
  22. package/dist/{auth-module-CfCGtasi.mjs → auth-module-DOPDpu-z.mjs} +5 -5
  23. package/dist/{auth-module-CfCGtasi.mjs.map → auth-module-DOPDpu-z.mjs.map} +1 -1
  24. package/dist/{auth-module-CbGPeq4K.cjs → auth-module-Ky8OzEJu.cjs} +5 -5
  25. package/dist/{auth-module-CbGPeq4K.cjs.map → auth-module-Ky8OzEJu.cjs.map} +1 -1
  26. package/dist/{auth-scope-interceptor-ctnmljij.mjs → auth-scope-interceptor-C0NRu4uy.mjs} +2 -2
  27. package/dist/{auth-scope-interceptor-ctnmljij.mjs.map → auth-scope-interceptor-C0NRu4uy.mjs.map} +1 -1
  28. package/dist/{auth-scope-interceptor-DU57SvDf.cjs → auth-scope-interceptor-DJTO9RVP.cjs} +2 -2
  29. package/dist/{auth-scope-interceptor-DU57SvDf.cjs.map → auth-scope-interceptor-DJTO9RVP.cjs.map} +1 -1
  30. package/dist/{decorate-Bvg21vkL.cjs → decorate-DdRSPs9e.cjs} +9 -1
  31. package/dist/{decorate-Bvg21vkL.cjs.map → decorate-DdRSPs9e.cjs.map} +1 -1
  32. package/dist/{decorate-YZjmlv7t.mjs → decorate-DqI1OKmL.mjs} +4 -2
  33. package/dist/{decorate-YZjmlv7t.mjs.map → decorate-DqI1OKmL.mjs.map} +1 -1
  34. package/dist/express.d.cts +1 -1
  35. package/dist/express.d.mts +1 -1
  36. package/dist/fastify.d.cts +1 -1
  37. package/dist/fastify.d.mts +1 -1
  38. package/dist/graphql.cjs +3 -3
  39. package/dist/graphql.d.cts +1 -1
  40. package/dist/graphql.d.mts +1 -1
  41. package/dist/graphql.mjs +3 -3
  42. package/dist/index.cjs +5 -5
  43. package/dist/index.d.cts +1 -1
  44. package/dist/index.d.mts +1 -1
  45. package/dist/index.mjs +5 -5
  46. package/dist/microservices.d.cts +1 -1
  47. package/dist/microservices.d.mts +1 -1
  48. package/dist/organization.cjs +1 -1
  49. package/dist/organization.d.cts +1 -1
  50. package/dist/organization.d.mts +1 -1
  51. package/dist/organization.mjs +1 -1
  52. package/dist/testing/conformance.cjs +245 -26
  53. package/dist/testing/conformance.cjs.map +1 -1
  54. package/dist/testing/conformance.d.cts +26 -3
  55. package/dist/testing/conformance.d.cts.map +1 -1
  56. package/dist/testing/conformance.d.mts +26 -3
  57. package/dist/testing/conformance.d.mts.map +1 -1
  58. package/dist/testing/conformance.mjs +245 -26
  59. package/dist/testing/conformance.mjs.map +1 -1
  60. package/dist/testing.cjs +2 -2
  61. package/dist/testing.d.cts +1 -1
  62. package/dist/testing.d.mts +1 -1
  63. package/dist/testing.mjs +2 -2
  64. package/dist/websockets.cjs +4 -5
  65. package/dist/websockets.cjs.map +1 -1
  66. package/dist/websockets.d.cts +2 -3
  67. package/dist/websockets.d.cts.map +1 -1
  68. package/dist/websockets.d.mts +2 -3
  69. package/dist/websockets.d.mts.map +1 -1
  70. package/dist/websockets.mjs +1 -2
  71. package/dist/websockets.mjs.map +1 -1
  72. package/package.json +1 -1
  73. package/dist/auth-contracts-CL8TEt5t.d.cts.map +0 -1
  74. package/dist/auth-contracts-CnGaBzlg.d.mts.map +0 -1
package/README.md CHANGED
@@ -343,7 +343,7 @@ Better Auth treats a process with `NODE_ENV=test` or a truthy `TEST` variable (V
343
343
 
344
344
  The kits verify extension units against the invariants of the [reviewed specification](docs/design/design-v7.md) (§4 and §14.1). Each kit returns `ConformanceCase[]` (`{ id, title, skip?, run() }`) that `runConformance(cases, { describe, it })` registers with Vitest, Jest or `node:test`. Assertions use `node:assert/strict`; the kits import no test runner.
345
345
 
346
- Applicability comes from the unit, not from the options a harness passes. A platform that declares `capabilities.http2` needs the `http2` option. A transport with a lineage needs `invokeTwice`, one that nests handlers (`defaultAccessFor`) needs `invokeGraph`, and one that claims the kit's federation reference resolver needs `invokeEntities`. Such a case fails when the helper is missing. A case whose optional capability is absent is skipped with the reason. The kits read these members from unit objects before running; for classes and `defineExtension()` definitions they boot once and read the resolved unit. A case known to be inapplicable registers with its reason in the test name. A case that finds out at run time resolves with `{ skipped: reason }`, which `runConformance` reports through the runner's `context.skip(reason)` (Vitest, `node:test`; Jest has no runtime skip, so the test passes).
346
+ Applicability comes from the unit, not from the options a harness passes. A platform that declares `capabilities.http2` needs the `http2` option. A transport with a lineage needs `invokeTwice`, one that nests handlers (`defaultAccessFor`) needs `invokeGraph`, and one that claims the kit's federation reference resolver needs `invokeEntities`. A transport whose browser leg is a connection's handshake, shared by the connection's messages (the WebSocket transports), runs the `T-ws-origin-*` cases instead of the `T-csrf-*` cases and needs `invokeConnection`, plus `authenticateConnection` when the app provides `WS_CONNECTION_AUTH`. Such a case fails when the helper is missing, and `T-selection` fails `expectBrowserLeg: false` for a transport that describes a browser leg. A case whose optional capability is absent is skipped with the reason. The kits read these members from unit objects before running; for classes and `defineExtension()` definitions they boot once and read the resolved unit. A case known to be inapplicable registers with its reason in the test name. A case that finds out at run time resolves with `{ skipped: reason }`, which `runConformance` reports through the runner's `context.skip(reason)` (Vitest, `node:test`; Jest has no runtime skip, so the test passes).
347
347
 
348
348
  ```ts
349
349
  import { ExpressAdapter } from "@nestjs/platform-express";
@@ -378,16 +378,16 @@ runConformance(
378
378
  );
379
379
  ```
380
380
 
381
- | Kit | Unit | Covers |
382
- | ---------------------------- | --------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
383
- | `httpPlatformConformance` | `HttpPlatform` | Mounting, byte-exact bodies, limits with host CORS, URL and header facts, client IP, HTTP/2, write-back, request accessors, error delivery, lifecycle (no adapter, late adapter, reused `TestingModule`, double `forRoot`), diagnostics and log hygiene |
384
- | `transportConformance` | `AuthTransport` | Selection, credentials, per-request memoization, per-invocation decisions, acceptance, cookie forwarding or refresh suppression, origin and form-CSRF rules including forwarding on safe operations, error shapes and logging, the exact coverage report of the transport's claims, `globalScope: false`, mixed-kind session reads, lazy scope construction and fail-closed extraction |
385
- | `principalSourceConformance` | `PrincipalSource` | Rejection without throwing, storage outages, delivery of every own-credential `Set-Cookie` exactly once, refresh suppression, clean absence, principal shape, declared credential headers, `sessionBacked` and `delegates` declarations |
386
- | `policyConformance` | `AuthorizationPolicy` | Deny values, storage outages, APIError mapping and re-classification, delegation scope, unnamed-kind gating, per-invocation decisions with shared I/O and plugin prerequisites; requirements name policy objects (construct a DI policy with its dependencies) |
381
+ | Kit | Unit | Covers |
382
+ | ---------------------------- | --------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
383
+ | `httpPlatformConformance` | `HttpPlatform` | Mounting, byte-exact bodies, limits with host CORS, URL and header facts, client IP, HTTP/2, write-back, request accessors, error delivery, lifecycle (no adapter, late adapter, reused `TestingModule`, double `forRoot`), diagnostics and log hygiene |
384
+ | `transportConformance` | `AuthTransport` | Selection, credentials, per-request memoization, per-invocation decisions, acceptance, cookie forwarding or refresh suppression, origin and form-CSRF rules including forwarding on safe operations, WebSocket handshake origins on every message and at connection time (untrusted, missing and forwarded origins, junk tokens, dynamic base URLs, function-valued `trustedOrigins`), error shapes and logging, the exact coverage report of the transport's claims, `globalScope: false`, mixed-kind session reads, lazy scope construction and fail-closed extraction |
385
+ | `principalSourceConformance` | `PrincipalSource` | Rejection without throwing, storage outages, delivery of every own-credential `Set-Cookie` exactly once, refresh suppression, clean absence, principal shape, declared credential headers, `sessionBacked` and `delegates` declarations |
386
+ | `policyConformance` | `AuthorizationPolicy` | Deny values, storage outages, APIError mapping and re-classification, delegation scope, unnamed-kind gating, per-invocation decisions with shared I/O and plugin prerequisites; requirements name policy objects (construct a DI policy with its dependencies) |
387
387
 
388
- Every case boots real Nest applications or modules with a real Better Auth instance that includes `conformanceProbePlugin()`. The probe counts and faults every operation of the instance's database adapter, so storage outages reach endpoints that would swallow them, and records the `Set-Cookie` lines each call produces. `createConformanceAuth({ plugins })` builds such an instance: memory adapter, `testUtils()`, `bearer()`, the probe plugin, `nestjs()` last, and `session.updateAge: 0` and origin checks on, whatever `options` says. The principal-source and policy kits take that instance as `auth`; the principal-source kit rejects an instance without `session.updateAge: 0`. The transport kit creates its own instance and passes it to your `createApp` harness together with the kit's API-key source in `principals`, a `logger` to boot with, and the `globalScope`, `appEnhancers`, `fieldResolverEnhancers` and `federation` settings of each boot. Apply every fixture decorator, including the kit's `SetMetadata()` marker, which maps the transport's claims to fixtures.
388
+ Every case boots real Nest applications or modules with a real Better Auth instance that includes `conformanceProbePlugin()`. The probe counts and faults every operation of the instance's database adapter, so storage outages reach endpoints that would swallow them, and records the `Set-Cookie` lines each call produces. `createConformanceAuth({ plugins })` builds such an instance: memory adapter, `testUtils()`, `bearer()`, the probe plugin, `nestjs()` last, and `session.updateAge: 0` and origin checks on, whatever `options` says. The principal-source and policy kits take that instance as `auth`; the principal-source kit rejects an instance without `session.updateAge: 0`. The transport kit creates its own instance and passes it to your `createApp` harness together with the kit's API-key source in `principals`, a `logger` to boot with, and the `globalScope`, `appEnhancers`, `fieldResolverEnhancers` and `federation` settings of each boot. Apply every fixture decorator, including the kit's `SetMetadata()` marker, which maps the transport's claims to fixtures. On a connection-shaped browser leg, the kit's cookie credential carries the instance's base URL, `http://localhost:3000`, as `Origin`, as a browser page of that origin does; the `T-ws-origin-*` cases pass their own `Origin`, `Host` and forwarding headers, which the harness sends in the handshake.
389
389
 
390
- This repository runs the platform kit against Express and Fastify, the transport kit against the built-in HTTP transport and an in-process reference transport, the principal-source kit against the session and API-key sources, and the policy kit against the admin, organization, API-key and fresh-session policies. Mutation tests confirm that each of these defects fails the intended case: a platform merging `Set-Cookie`, a transport sharing invocation state across aliases, a transport without a browser leg on safe operations, a `defineExtension()` transport with a lineage or nesting and no helper, a source throwing its denial, a source dropping its refresh cookie, a source turning a storage outage into a 401, and a policy widening delegated principals.
390
+ This repository runs the platform kit against Express and Fastify; the transport kit against the built-in HTTP transport, an in-process reference transport, Socket.IO and `ws` (each with and without a principal TTL), the RPC transport over TCP (standalone and hybrid), gRPC, NATS, RabbitMQ, MQTT, Redis and Kafka, and the Apollo (Express and Fastify) and Mercurius transports over HTTP and over graphql-ws (with and without a subscription principal TTL; Mercurius also without `mercuriusSubscriptionContext()`), with federation 2 subgraphs and a federation 1 run of `T-reference-resolver`; the principal-source kit against the session and API-key sources; and the policy kit against the admin, organization, API-key and fresh-session policies. gRPC skips `T-error-shape`, because it delivers only a status and a message. The kit reads each call's browser leg while its invocation runs, because the GraphQL transports reject a completed request. Mutation tests confirm that each of these defects fails the intended case: a platform merging `Set-Cookie`, a transport sharing invocation state across aliases, a transport without a browser leg on safe operations, a `defineExtension()` transport with a lineage or nesting and no helper, a WebSocket transport that enforces its handshake like a safe read, exempts handshakes that carry a token, builds its leg URL from the bare handshake path or from forwarded headers, or answers internal errors with their cause, a GraphQL transport whose aliases share one invocation, whose lineage gives every field of an operation one position, whose field resolvers do not inherit their root's access, or that serves reference resolvers without field guards, a GraphQL harness that omits `invokeGraph`, `invokeEntities` or `invokeConnection`, a source throwing its denial, a source dropping its refresh cookie, a source turning a storage outage into a 401, and a policy widening delegated principals.
391
391
 
392
392
  ## Develop in this monorepo
393
393
 
@@ -407,7 +407,12 @@ The shared toolchain uses Node.js LTS, pnpm, tsdown, TypeScript and Vitest. Buil
407
407
 
408
408
  ## Examples
409
409
 
410
- The [Express](../../examples/better-auth-express/README.md) and [Fastify](../../examples/better-auth-fastify/README.md) example applications register a default and a named instance, guard routes and read the signed-in user through a principal parameter. They start without external services.
410
+ Each example application registers a default and a named instance, reads the signed-in user through the `@CurrentUser()` principal parameter and starts without external services:
411
+
412
+ - [Express](../../examples/better-auth-express/README.md) and [Fastify](../../examples/better-auth-fastify/README.md) guard HTTP routes on their platforms.
413
+ - [Apollo GraphQL](../../examples/better-auth-graphql/README.md) authenticates queries and mutations over HTTP and every graphql-ws operation, with the named instance bound to its own resolver.
414
+ - [Socket.IO](../../examples/better-auth-websockets/README.md) authenticates gateway connections and every message, with the named instance on its own namespace.
415
+ - [TCP microservice](../../examples/better-auth-rpc/README.md) authenticates the messages of a hybrid application through the payload credential carrier.
411
416
 
412
417
  ## Releases
413
418
 
package/dist/admin.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_auth_errors = require("./auth-errors-1EdQ36D8.cjs");
3
- const require_auth_decorators = require("./auth-decorators-B7xasVk_.cjs");
3
+ const require_auth_decorators = require("./auth-decorators-9L-UO_T3.cjs");
4
4
  let better_auth_api = require("better-auth/api");
5
5
  //#region src/admin.ts
6
6
  const adminPermissionPolicy = {
package/dist/admin.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import { Ct as AuthPrincipal, Nt as PrincipalKind, f as AuthorizationPolicy, ot as Requirement, vt as AdminPermissions } from "./auth-contracts-CL8TEt5t.cjs";
1
+ import { Ct as AuthPrincipal, Nt as PrincipalKind, f as AuthorizationPolicy, ot as Requirement, vt as AdminPermissions } from "./auth-contracts-mejJfv9d.cjs";
2
2
  //#region src/admin.d.ts
3
3
  export interface PermissionOptions {
4
4
  principals?: readonly PrincipalKind[];
package/dist/admin.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { Ct as AuthPrincipal, Nt as PrincipalKind, f as AuthorizationPolicy, ot as Requirement, vt as AdminPermissions } from "./auth-contracts-CnGaBzlg.mjs";
1
+ import { Ct as AuthPrincipal, Nt as PrincipalKind, f as AuthorizationPolicy, ot as Requirement, vt as AdminPermissions } from "./auth-contracts-B2SAVlKT.mjs";
2
2
  //#region src/admin.d.ts
3
3
  export interface PermissionOptions {
4
4
  principals?: readonly PrincipalKind[];
package/dist/admin.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import { n as BetterAuthConfigurationError } from "./auth-errors-B6jLBpQu.mjs";
2
- import { u as Require } from "./auth-decorators-DUmQ-n_w.mjs";
2
+ import { u as Require } from "./auth-decorators-CQYu3gaF.mjs";
3
3
  import { isAPIError } from "better-auth/api";
4
4
  //#region src/admin.ts
5
5
  const adminPermissionPolicy = {
package/dist/api-key.cjs CHANGED
@@ -1,7 +1,7 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_auth_errors = require("./auth-errors-1EdQ36D8.cjs");
3
- const require_auth_scope_interceptor = require("./auth-scope-interceptor-DU57SvDf.cjs");
4
- const require_auth_decorators = require("./auth-decorators-B7xasVk_.cjs");
3
+ const require_auth_scope_interceptor = require("./auth-scope-interceptor-DJTO9RVP.cjs");
4
+ const require_auth_decorators = require("./auth-decorators-9L-UO_T3.cjs");
5
5
  let better_auth_plugins_access = require("better-auth/plugins/access");
6
6
  //#region src/api-key.ts
7
7
  const API_KEY_PRINCIPAL_KIND = "api-key";
@@ -1,4 +1,4 @@
1
- import { $ as PrincipalDelegation, it as PrincipalSource, o as AuthPrincipalBase, ot as Requirement } from "./auth-contracts-CL8TEt5t.cjs";
1
+ import { $ as PrincipalDelegation, it as PrincipalSource, o as AuthPrincipalBase, ot as Requirement } from "./auth-contracts-mejJfv9d.cjs";
2
2
  //#region src/api-key.d.ts
3
3
  export declare const API_KEY_PRINCIPAL_KIND: "api-key";
4
4
  export interface ApiKeyPrincipal extends AuthPrincipalBase {
@@ -1,4 +1,4 @@
1
- import { $ as PrincipalDelegation, it as PrincipalSource, o as AuthPrincipalBase, ot as Requirement } from "./auth-contracts-CnGaBzlg.mjs";
1
+ import { $ as PrincipalDelegation, it as PrincipalSource, o as AuthPrincipalBase, ot as Requirement } from "./auth-contracts-B2SAVlKT.mjs";
2
2
  //#region src/api-key.d.ts
3
3
  export declare const API_KEY_PRINCIPAL_KIND: "api-key";
4
4
  export interface ApiKeyPrincipal extends AuthPrincipalBase {
package/dist/api-key.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import { n as BetterAuthConfigurationError, r as BetterAuthInfrastructureError, t as AuthFailures, u as normalizeThrown } from "./auth-errors-B6jLBpQu.mjs";
2
- import { a as absent, l as rejected, o as authenticated } from "./auth-scope-interceptor-ctnmljij.mjs";
3
- import { u as Require } from "./auth-decorators-DUmQ-n_w.mjs";
2
+ import { a as absent, l as rejected, o as authenticated } from "./auth-scope-interceptor-C0NRu4uy.mjs";
3
+ import { u as Require } from "./auth-decorators-CQYu3gaF.mjs";
4
4
  import { role } from "better-auth/plugins/access";
5
5
  //#region src/api-key.ts
6
6
  const API_KEY_PRINCIPAL_KIND = "api-key";
@@ -1,10 +1,10 @@
1
- import { IncomingHttpHeaders, IncomingMessage } from "node:http";
2
1
  import { CallHandler, CanActivate, DynamicModule, ExecutionContext, InjectionToken, Logger, LoggerService, ModuleMetadata, NestInterceptor, OptionalFactoryDependency, Provider, Type } from "@nestjs/common";
3
2
  import { AbstractHttpAdapter, DiscoveryService, HttpAdapterHost, ModuleRef, Reflector } from "@nestjs/core";
4
- import "@nestjs/core/injector/instance-wrapper.js";
5
- import { HookEndpointContext } from "better-auth";
6
- import { IntrinsicException } from "@nestjs/common/exceptions/intrinsic.exception.js";
7
3
  import { Observable } from "rxjs";
4
+ import { IntrinsicException } from "@nestjs/common/exceptions/intrinsic.exception.js";
5
+ import { IncomingHttpHeaders, IncomingMessage } from "node:http";
6
+ import { HookEndpointContext } from "better-auth";
7
+ import "@nestjs/core/injector/instance-wrapper.js";
8
8
  //#endregion
9
9
  //#region src/auth-errors.d.ts
10
10
  type AuthErrorCode = "UNAUTHENTICATED" | "FORBIDDEN" | "RATE_LIMITED";
@@ -87,7 +87,7 @@ declare class BetterAuthInfrastructureError extends Error {
87
87
  }
88
88
  declare function getRawCause(error: BetterAuthInfrastructureError): unknown;
89
89
  declare namespace auth_tokens_d_exports {
90
- export { ACCEPT_PRINCIPALS_METADATA, ACCESS_METADATA, AUTH_ENHANCER, AUTH_INSTANCE_METADATA, DB_HOOK_METADATA, FORWARD_COOKIES_METADATA, FRESHNESS_METADATA, GUARD_CORE, HOOK_METADATA, INSTANCE_REGISTRY, INVOCATION_PARAMS_METADATA, INVOCATION_VALUES, MOUNT_COORDINATOR, PLATFORMS, POLICY_INVOKER, POLICY_RESOLVER, PRINCIPAL_PARAMS_METADATA, PRINCIPAL_READINGS, PRINCIPAL_RESOLVER, READER_CONTEXT, REQUEST_SCOPE, REQUIREMENTS_METADATA, ROUTE_PLANNER, SCOPE_CORE, SKIP_DEFAULT_REQUIREMENTS_METADATA, SKIP_ORIGIN_CHECK_METADATA, TRANSPORTS, TRANSPORT_REGISTRY, USE_BETTER_AUTH_METADATA, getBetterAuthHandleToken, getBetterAuthInstanceToken, getBetterAuthOptionsToken, getBetterAuthServiceToken, getExtensionToken, getPrincipalSourcesToken };
90
+ export { ACCEPT_PRINCIPALS_METADATA, ACCESS_METADATA, AUTH_ENHANCER, AUTH_INSTANCE_METADATA, DB_HOOK_METADATA, FORWARD_COOKIES_METADATA, FRESHNESS_METADATA, GUARD_CORE, HOOK_METADATA, INSTANCE_REGISTRY, INVOCATION_PARAMS_METADATA, INVOCATION_VALUES, MOUNT_COORDINATOR, PLATFORMS, POLICY_INVOKER, POLICY_RESOLVER, PRINCIPAL_PARAMS_METADATA, PRINCIPAL_READINGS, PRINCIPAL_RESOLVER, READER_CONTEXT, REQUEST_SCOPE, REQUIREMENTS_METADATA, ROUTE_PLANNER, SCOPE_CORE, SKIP_DEFAULT_REQUIREMENTS_METADATA, SKIP_ORIGIN_CHECK_METADATA, TRANSPORTS, TRANSPORT_REGISTRY, USE_BETTER_AUTH_METADATA, WS_CONNECTION_AUTH, getBetterAuthHandleToken, getBetterAuthInstanceToken, getBetterAuthOptionsToken, getBetterAuthServiceToken, getExtensionToken, getPrincipalSourcesToken };
91
91
  }
92
92
  declare function getBetterAuthInstanceToken(alias?: string): string;
93
93
  declare function getBetterAuthOptionsToken(alias?: string): string;
@@ -120,6 +120,8 @@ declare const USE_BETTER_AUTH_METADATA: unique symbol;
120
120
  declare const HOOK_METADATA: unique symbol;
121
121
  declare const DB_HOOK_METADATA: unique symbol;
122
122
  declare const AUTH_ENHANCER: unique symbol;
123
+ /** Connection-time WebSocket authentication, provided by the socket.io and ws transport definitions. */
124
+ declare const WS_CONNECTION_AUTH: unique symbol;
123
125
  declare function getPrincipalSourcesToken(instance: string): symbol;
124
126
  declare function getExtensionToken(point: "platforms" | "transports" | "principals", instance: string, index: number): symbol;
125
127
  declare const READER_CONTEXT: unique symbol;
@@ -1657,5 +1659,5 @@ interface PolicyBootContext {
1657
1659
  readonly site: string;
1658
1660
  }
1659
1661
  //#endregion
1660
- export { PrincipalDelegation as $, getRawCause as $n, SESSION_PRINCIPAL_KIND as $t, DatabaseHookTarget as A, BetterAuthService as An, GetSessionWithHeaders as At, HookOptions as B, getBetterAuthHandleToken as Bn, UnvalidatedBody as Bt, ConformanceCase as C, defineHttpPlatform as Cn, AuthPrincipal as Ct, CookieForwardingOptions as D, allow as Dn, DatabaseHookMethod as Dt, ConformanceSkip as E, BetterAuthGuard as En, DatabaseHookData as Et, ExtensionDefinition as F, BetterAuthModule as Fn, Register as Ft, InboundAuthRequest as G, AuthErrorCode as Gn, betterAuthCorsOrigin as Gt, HttpMountOptions as H, getBetterAuthOptionsToken as Hn, WithActiveOrganization as Ht, ExtensionRef as I, GUARD_CORE as In, RegisteredAuth as It, PlatformMountContext as J, AuthGraphqlExtensions as Jn, definePrincipalSource as Jt, InvocationLineage as K, AuthFailure as Kn, absent as Kt, FastifyPlatformOptions as L, POLICY_INVOKER as Ln, RegisteredInstances as Lt, DbHookOptions as M, InstanceLookup as Mn, OrgPermissions as Mt, DefaultInstanceCheck as N, EXTENSION_DEFINITION as Nn, PrincipalKind as Nt, CookieSink as O, definePolicy as On, DatabaseHookResult as Ot, ExpressPlatformOptions as P, UPGRADE_REQUEST as Pn, PrincipalOfKind as Pt, PolicyRef as Q, ErrorMappingOptions as Qn, RequireFreshSession as Qt, GuardReach as R, PRINCIPAL_RESOLVER as Rn, SessionOf as Rt, ClaimOptions as S, defineExtension as Sn, AuthOf as St, ConformanceRunner as T, BetterAuthScopeInterceptor as Tn, AuthUser as Tt, HttpPlatform as U, getBetterAuthServiceToken as Un, PrincipalKinds as Ut, HookPredicate as V, getBetterAuthInstanceToken as Vn, UserOf as Vt, HttpRequestAccessor as W, AuthErrorBody as Wn, httpTransport as Wt, PolicyBootContext as X, BetterAuthConfigurationError as Xn, CurrentSession as Xt, PlatformPrepareContext as Y, AuthTransportErrorPayload as Yn, rejected as Yt, PolicyInvoker as Z, BetterAuthInfrastructureError as Zn, CurrentUser as Zt, BetterAuthRuntimeOptions as _, allOf as _n, TransportValidationContext as _t, AuthHandlerInterceptor as a, BeforeAuth as an, ProxyTrust as at, BootAdviceContext as b, definePrincipalParam as bn, AuthHookContext as bt, AuthTransport as c, ForwardAuthCookies as cn, RequirementOptions as ct, AuthorizationLimits as d, Require as dn, ScopeInit as dt, freshSession as en, isAuthFailure as er, PrincipalReading as et, AuthorizationPolicy as f, RequireAuth as fn, SessionOption as ft, BetterAuthModuleOptions as g, UseBetterAuth as gn, TransportKit as gt, BetterAuthModuleAsyncOptions as h, UseAuthInstance as hn, TransportCall as ht, AuthHandle as i, AfterDatabase as in, PrincipalSource as it, DbHookMethodDecorator as j, TransportRegistry as jn, IsRegistered as jt, CorsOriginOptions as k, deny as kn, EndpointPath as kt, AuthorizationContext as l, OptionalAuth as ln, ResolutionRequest as lt, BetterAuthFactoryResult as m, SkipOriginCheck as mn, StaticOptionMustBePassedToForRootAsync as mt, ApplicationRouteDescriptor as n, AcceptPrincipals as nn, isInfrastructureError as nr, PrincipalResolver as nt, AuthPrincipalBase as o, BeforeDatabase as on, Requirement as ot, BetterAuthAppOptions as p, SkipDefaultRequirements as pn, SessionPrincipalOptions as pt, OriginCheckOptions as q, AuthFailures as qn, authenticated as qt, AuthContextView as r, AfterAuth as rn, PrincipalResult as rt, AuthRouteBinding as s, CurrentPrincipal as sn, RequirementExpr as st, AdvisedHandler as t, sessionPrincipal as tn, isConfigurationError as tr, PrincipalRequest as tt, AuthorizationDecision as u, Public as un, RoutePlan as ut, BetterAuthStaticOptions as v, anyOf as vn, AdminPermissions as vt, ConformanceOutcome as w, defineTransport as wn, AuthSession as wt, BrowserExposure as x, requirement as xn, AuthLike as xt, BootAdvice as y, defineInvocationParam as yn, AuthAfterHookContext as yt, HookMethodDecorator as z, SCOPE_CORE as zn, SessionPrincipal as zt };
1661
- //# sourceMappingURL=auth-contracts-CL8TEt5t.d.cts.map
1662
+ export { PrincipalDelegation as $, ErrorMappingOptions as $n, SESSION_PRINCIPAL_KIND as $t, DatabaseHookTarget as A, BetterAuthService as An, GetSessionWithHeaders as At, HookOptions as B, WS_CONNECTION_AUTH as Bn, UnvalidatedBody as Bt, ConformanceCase as C, defineHttpPlatform as Cn, AuthPrincipal as Ct, CookieForwardingOptions as D, allow as Dn, DatabaseHookMethod as Dt, ConformanceSkip as E, BetterAuthGuard as En, DatabaseHookData as Et, ExtensionDefinition as F, BetterAuthModule as Fn, Register as Ft, InboundAuthRequest as G, AuthErrorBody as Gn, betterAuthCorsOrigin as Gt, HttpMountOptions as H, getBetterAuthInstanceToken as Hn, WithActiveOrganization as Ht, ExtensionRef as I, GUARD_CORE as In, RegisteredAuth as It, PlatformMountContext as J, AuthFailures as Jn, definePrincipalSource as Jt, InvocationLineage as K, AuthErrorCode as Kn, absent as Kt, FastifyPlatformOptions as L, POLICY_INVOKER as Ln, RegisteredInstances as Lt, DbHookOptions as M, InstanceLookup as Mn, OrgPermissions as Mt, DefaultInstanceCheck as N, EXTENSION_DEFINITION as Nn, PrincipalKind as Nt, CookieSink as O, definePolicy as On, DatabaseHookResult as Ot, ExpressPlatformOptions as P, UPGRADE_REQUEST as Pn, PrincipalOfKind as Pt, PolicyRef as Q, BetterAuthInfrastructureError as Qn, RequireFreshSession as Qt, GuardReach as R, PRINCIPAL_RESOLVER as Rn, SessionOf as Rt, ClaimOptions as S, defineExtension as Sn, AuthOf as St, ConformanceRunner as T, BetterAuthScopeInterceptor as Tn, AuthUser as Tt, HttpPlatform as U, getBetterAuthOptionsToken as Un, PrincipalKinds as Ut, HookPredicate as V, getBetterAuthHandleToken as Vn, UserOf as Vt, HttpRequestAccessor as W, getBetterAuthServiceToken as Wn, httpTransport as Wt, PolicyBootContext as X, AuthTransportErrorPayload as Xn, CurrentSession as Xt, PlatformPrepareContext as Y, AuthGraphqlExtensions as Yn, rejected as Yt, PolicyInvoker as Z, BetterAuthConfigurationError as Zn, CurrentUser as Zt, BetterAuthRuntimeOptions as _, allOf as _n, TransportValidationContext as _t, AuthHandlerInterceptor as a, BeforeAuth as an, ProxyTrust as at, BootAdviceContext as b, definePrincipalParam as bn, AuthHookContext as bt, AuthTransport as c, ForwardAuthCookies as cn, RequirementOptions as ct, AuthorizationLimits as d, Require as dn, ScopeInit as dt, freshSession as en, getRawCause as er, PrincipalReading as et, AuthorizationPolicy as f, RequireAuth as fn, SessionOption as ft, BetterAuthModuleOptions as g, UseBetterAuth as gn, TransportKit as gt, BetterAuthModuleAsyncOptions as h, UseAuthInstance as hn, TransportCall as ht, AuthHandle as i, AfterDatabase as in, PrincipalSource as it, DbHookMethodDecorator as j, TransportRegistry as jn, IsRegistered as jt, CorsOriginOptions as k, deny as kn, EndpointPath as kt, AuthorizationContext as l, OptionalAuth as ln, ResolutionRequest as lt, BetterAuthFactoryResult as m, SkipOriginCheck as mn, StaticOptionMustBePassedToForRootAsync as mt, ApplicationRouteDescriptor as n, AcceptPrincipals as nn, isConfigurationError as nr, PrincipalResolver as nt, AuthPrincipalBase as o, BeforeDatabase as on, Requirement as ot, BetterAuthAppOptions as p, SkipDefaultRequirements as pn, SessionPrincipalOptions as pt, OriginCheckOptions as q, AuthFailure as qn, authenticated as qt, AuthContextView as r, AfterAuth as rn, isInfrastructureError as rr, PrincipalResult as rt, AuthRouteBinding as s, CurrentPrincipal as sn, RequirementExpr as st, AdvisedHandler as t, sessionPrincipal as tn, isAuthFailure as tr, PrincipalRequest as tt, AuthorizationDecision as u, Public as un, RoutePlan as ut, BetterAuthStaticOptions as v, anyOf as vn, AdminPermissions as vt, ConformanceOutcome as w, defineTransport as wn, AuthSession as wt, BrowserExposure as x, requirement as xn, AuthLike as xt, BootAdvice as y, defineInvocationParam as yn, AuthAfterHookContext as yt, HookMethodDecorator as z, SCOPE_CORE as zn, SessionPrincipal as zt };
1663
+ //# sourceMappingURL=auth-contracts-B2SAVlKT.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth-contracts-B2SAVlKT.d.mts","names":[],"sources":["../src/auth-errors.ts","../src/auth-tokens.ts","../src/auth-module.ts","../src/bridge-protocol.ts","../src/request-scope.ts","../src/origin-check.ts","../src/instance-registry.ts","../src/mount-coordinator.ts","../src/principal-readings.ts","../src/policy-resolver.ts","../src/transport-registry.ts","../src/route-planner.ts","../src/auth-service.ts","../src/authorization-evaluator.ts","../src/auth-guard.ts","../src/auth-scope-interceptor.ts","../src/auth-module-definition.ts","../src/auth-decorators.ts","../src/session-principal.ts","../src/principal-resolver.ts","../src/auth-exchange.ts","../src/http-transport.ts","../src/index.ts","../src/auth-types.ts","../src/auth-contracts.ts"],"mappings":";;;;;;;;;KAkBY;;UAGK;WACN;WACA,MAAM;WACN;WACA;WACA;WACA,UAAU;;UAGJ;EACf;EACA;EACA,MAAM;EACN;EACA;;UAGe;EACf,MAAM;EACN;EACA;;UAGe;EACf;EACA;EACA,MAAM;EACN;EACA;;UAGe;EACf,OACE,SAAS,aACT,SAAS,kBACT;EAEF;;iBAQc,cAAc,iBAAiB,SAAS;iBAIxC,sBACd,iBACC,SAAS;iBAII,qBACd,iBACC,SAAS;iBAqDH,UAAU;EACjB;EACA;EACA;EACA;EACA;IACE;cA6BS;EACX,gBAAe,mBAAoB;EAGnC,iBAAQ;EACR,UAAS,gBAAe,mBAAqB;EAG7C,aAAY,iBAAkB;;cA4BnB,qCAAqC;WACvC;WACA;WACA;WACA;WACA;WACA;aACP;aACA;aACA;;WAEO,kBAAkB;EAE3B,YAAY,cAAc,gBAAgB;SAUnC,UACL,cACA,gBACA;IAAY;IAAe;MAC1B;;cAeQ,sCAAsC;WACxC,OAAO;WACP;aACP;aACA;aACA;;EAGF,YAAY,gBAAgB;IAAY;;;iBAwB1B,YAAY,OAAO;;;;iBC7QnB,2BAA2B;iBAI3B,0BAA0B;iBAI1B,0BAA0B;iBAI1B,yBAAyB;cAK5B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ACA;aACA;;WAEF;IACP,QAAQ;MACN;MACA;QAAkB;QAAe;;QAC/B;IACJ,WAAW;MACT;MACA;QAAkB;QAAe;;MACjC,QAAQ;QACN;;EAEN,UAAU;EACV,UAAU;EACV,gBACE,aACA;IAAa;;;UAIA,oBACf,kBACA,UAAU,oBAAoB;;WAGrB;WACA;;aAEE;;;;;;;aAOA,sBAAsB;;aAEtB;;aAEA;;aAEA;;;EAGX,SACE,QAAQ,QACR,SAAS,qBAAqB,KAC7B,wBAAwB,QAAQ;;EAEnC,UAAU,QAAQ,QAAQ,MAAM,2BAA2B;;EAE3D,QACE,KAAK,6BACK,eAAe,iBAAiB;;;;;;KAOlC,UAAU,UAClB,oBAAoB,eACpB,KAAK,oBAAoB,gBACzB;UAEa,YAAY;WAClB,QAAQ,UAAU;WAClB,QAAQ;WACR;;WAEA;;WAEA;;KAEC,kBACR;WACW,gBAAgB;;WAChB,gBAAgB;;KAEnB;WACG;;WAEA;WACA;WACA;WACA;WACA;;UAGE,qBACf,UAAU,oBAAoB;WAErB,WAAW;WACX;WACA;WACA,SAAS;WACT,SAAS;WACT;aAAqB;aAAyB;;EACvD,MAAM;WACG;aAAoB,OAAO;aAAe;;WAC1C,MAAM;;;;;EAKf,KAAK,GAAG,+BAA+B,eAAe,QAAQ,KAAK,QAAQ;;EAE3E,QAAQ,cAAc;WACb,WAAW;;UAGL;WACN,MAAM;WACN,SAAS;WACT"}
@@ -1,10 +1,10 @@
1
+ import { IncomingHttpHeaders, IncomingMessage } from "node:http";
1
2
  import { CallHandler, CanActivate, DynamicModule, ExecutionContext, InjectionToken, Logger, LoggerService, ModuleMetadata, NestInterceptor, OptionalFactoryDependency, Provider, Type } from "@nestjs/common";
2
3
  import { AbstractHttpAdapter, DiscoveryService, HttpAdapterHost, ModuleRef, Reflector } from "@nestjs/core";
3
- import { Observable } from "rxjs";
4
- import { IntrinsicException } from "@nestjs/common/exceptions/intrinsic.exception.js";
5
- import { IncomingHttpHeaders, IncomingMessage } from "node:http";
6
- import { HookEndpointContext } from "better-auth";
7
4
  import "@nestjs/core/injector/instance-wrapper.js";
5
+ import { HookEndpointContext } from "better-auth";
6
+ import { IntrinsicException } from "@nestjs/common/exceptions/intrinsic.exception.js";
7
+ import { Observable } from "rxjs";
8
8
  //#endregion
9
9
  //#region src/auth-errors.d.ts
10
10
  type AuthErrorCode = "UNAUTHENTICATED" | "FORBIDDEN" | "RATE_LIMITED";
@@ -87,7 +87,7 @@ declare class BetterAuthInfrastructureError extends Error {
87
87
  }
88
88
  declare function getRawCause(error: BetterAuthInfrastructureError): unknown;
89
89
  declare namespace auth_tokens_d_exports {
90
- export { ACCEPT_PRINCIPALS_METADATA, ACCESS_METADATA, AUTH_ENHANCER, AUTH_INSTANCE_METADATA, DB_HOOK_METADATA, FORWARD_COOKIES_METADATA, FRESHNESS_METADATA, GUARD_CORE, HOOK_METADATA, INSTANCE_REGISTRY, INVOCATION_PARAMS_METADATA, INVOCATION_VALUES, MOUNT_COORDINATOR, PLATFORMS, POLICY_INVOKER, POLICY_RESOLVER, PRINCIPAL_PARAMS_METADATA, PRINCIPAL_READINGS, PRINCIPAL_RESOLVER, READER_CONTEXT, REQUEST_SCOPE, REQUIREMENTS_METADATA, ROUTE_PLANNER, SCOPE_CORE, SKIP_DEFAULT_REQUIREMENTS_METADATA, SKIP_ORIGIN_CHECK_METADATA, TRANSPORTS, TRANSPORT_REGISTRY, USE_BETTER_AUTH_METADATA, getBetterAuthHandleToken, getBetterAuthInstanceToken, getBetterAuthOptionsToken, getBetterAuthServiceToken, getExtensionToken, getPrincipalSourcesToken };
90
+ export { ACCEPT_PRINCIPALS_METADATA, ACCESS_METADATA, AUTH_ENHANCER, AUTH_INSTANCE_METADATA, DB_HOOK_METADATA, FORWARD_COOKIES_METADATA, FRESHNESS_METADATA, GUARD_CORE, HOOK_METADATA, INSTANCE_REGISTRY, INVOCATION_PARAMS_METADATA, INVOCATION_VALUES, MOUNT_COORDINATOR, PLATFORMS, POLICY_INVOKER, POLICY_RESOLVER, PRINCIPAL_PARAMS_METADATA, PRINCIPAL_READINGS, PRINCIPAL_RESOLVER, READER_CONTEXT, REQUEST_SCOPE, REQUIREMENTS_METADATA, ROUTE_PLANNER, SCOPE_CORE, SKIP_DEFAULT_REQUIREMENTS_METADATA, SKIP_ORIGIN_CHECK_METADATA, TRANSPORTS, TRANSPORT_REGISTRY, USE_BETTER_AUTH_METADATA, WS_CONNECTION_AUTH, getBetterAuthHandleToken, getBetterAuthInstanceToken, getBetterAuthOptionsToken, getBetterAuthServiceToken, getExtensionToken, getPrincipalSourcesToken };
91
91
  }
92
92
  declare function getBetterAuthInstanceToken(alias?: string): string;
93
93
  declare function getBetterAuthOptionsToken(alias?: string): string;
@@ -120,6 +120,8 @@ declare const USE_BETTER_AUTH_METADATA: unique symbol;
120
120
  declare const HOOK_METADATA: unique symbol;
121
121
  declare const DB_HOOK_METADATA: unique symbol;
122
122
  declare const AUTH_ENHANCER: unique symbol;
123
+ /** Connection-time WebSocket authentication, provided by the socket.io and ws transport definitions. */
124
+ declare const WS_CONNECTION_AUTH: unique symbol;
123
125
  declare function getPrincipalSourcesToken(instance: string): symbol;
124
126
  declare function getExtensionToken(point: "platforms" | "transports" | "principals", instance: string, index: number): symbol;
125
127
  declare const READER_CONTEXT: unique symbol;
@@ -1657,5 +1659,5 @@ interface PolicyBootContext {
1657
1659
  readonly site: string;
1658
1660
  }
1659
1661
  //#endregion
1660
- export { PrincipalDelegation as $, getRawCause as $n, SESSION_PRINCIPAL_KIND as $t, DatabaseHookTarget as A, BetterAuthService as An, GetSessionWithHeaders as At, HookOptions as B, getBetterAuthHandleToken as Bn, UnvalidatedBody as Bt, ConformanceCase as C, defineHttpPlatform as Cn, AuthPrincipal as Ct, CookieForwardingOptions as D, allow as Dn, DatabaseHookMethod as Dt, ConformanceSkip as E, BetterAuthGuard as En, DatabaseHookData as Et, ExtensionDefinition as F, BetterAuthModule as Fn, Register as Ft, InboundAuthRequest as G, AuthErrorCode as Gn, betterAuthCorsOrigin as Gt, HttpMountOptions as H, getBetterAuthOptionsToken as Hn, WithActiveOrganization as Ht, ExtensionRef as I, GUARD_CORE as In, RegisteredAuth as It, PlatformMountContext as J, AuthGraphqlExtensions as Jn, definePrincipalSource as Jt, InvocationLineage as K, AuthFailure as Kn, absent as Kt, FastifyPlatformOptions as L, POLICY_INVOKER as Ln, RegisteredInstances as Lt, DbHookOptions as M, InstanceLookup as Mn, OrgPermissions as Mt, DefaultInstanceCheck as N, EXTENSION_DEFINITION as Nn, PrincipalKind as Nt, CookieSink as O, definePolicy as On, DatabaseHookResult as Ot, ExpressPlatformOptions as P, UPGRADE_REQUEST as Pn, PrincipalOfKind as Pt, PolicyRef as Q, ErrorMappingOptions as Qn, RequireFreshSession as Qt, GuardReach as R, PRINCIPAL_RESOLVER as Rn, SessionOf as Rt, ClaimOptions as S, defineExtension as Sn, AuthOf as St, ConformanceRunner as T, BetterAuthScopeInterceptor as Tn, AuthUser as Tt, HttpPlatform as U, getBetterAuthServiceToken as Un, PrincipalKinds as Ut, HookPredicate as V, getBetterAuthInstanceToken as Vn, UserOf as Vt, HttpRequestAccessor as W, AuthErrorBody as Wn, httpTransport as Wt, PolicyBootContext as X, BetterAuthConfigurationError as Xn, CurrentSession as Xt, PlatformPrepareContext as Y, AuthTransportErrorPayload as Yn, rejected as Yt, PolicyInvoker as Z, BetterAuthInfrastructureError as Zn, CurrentUser as Zt, BetterAuthRuntimeOptions as _, allOf as _n, TransportValidationContext as _t, AuthHandlerInterceptor as a, BeforeAuth as an, ProxyTrust as at, BootAdviceContext as b, definePrincipalParam as bn, AuthHookContext as bt, AuthTransport as c, ForwardAuthCookies as cn, RequirementOptions as ct, AuthorizationLimits as d, Require as dn, ScopeInit as dt, freshSession as en, isAuthFailure as er, PrincipalReading as et, AuthorizationPolicy as f, RequireAuth as fn, SessionOption as ft, BetterAuthModuleOptions as g, UseBetterAuth as gn, TransportKit as gt, BetterAuthModuleAsyncOptions as h, UseAuthInstance as hn, TransportCall as ht, AuthHandle as i, AfterDatabase as in, PrincipalSource as it, DbHookMethodDecorator as j, TransportRegistry as jn, IsRegistered as jt, CorsOriginOptions as k, deny as kn, EndpointPath as kt, AuthorizationContext as l, OptionalAuth as ln, ResolutionRequest as lt, BetterAuthFactoryResult as m, SkipOriginCheck as mn, StaticOptionMustBePassedToForRootAsync as mt, ApplicationRouteDescriptor as n, AcceptPrincipals as nn, isInfrastructureError as nr, PrincipalResolver as nt, AuthPrincipalBase as o, BeforeDatabase as on, Requirement as ot, BetterAuthAppOptions as p, SkipDefaultRequirements as pn, SessionPrincipalOptions as pt, OriginCheckOptions as q, AuthFailures as qn, authenticated as qt, AuthContextView as r, AfterAuth as rn, PrincipalResult as rt, AuthRouteBinding as s, CurrentPrincipal as sn, RequirementExpr as st, AdvisedHandler as t, sessionPrincipal as tn, isConfigurationError as tr, PrincipalRequest as tt, AuthorizationDecision as u, Public as un, RoutePlan as ut, BetterAuthStaticOptions as v, anyOf as vn, AdminPermissions as vt, ConformanceOutcome as w, defineTransport as wn, AuthSession as wt, BrowserExposure as x, requirement as xn, AuthLike as xt, BootAdvice as y, defineInvocationParam as yn, AuthAfterHookContext as yt, HookMethodDecorator as z, SCOPE_CORE as zn, SessionPrincipal as zt };
1661
- //# sourceMappingURL=auth-contracts-CnGaBzlg.d.mts.map
1662
+ export { PrincipalDelegation as $, ErrorMappingOptions as $n, SESSION_PRINCIPAL_KIND as $t, DatabaseHookTarget as A, BetterAuthService as An, GetSessionWithHeaders as At, HookOptions as B, WS_CONNECTION_AUTH as Bn, UnvalidatedBody as Bt, ConformanceCase as C, defineHttpPlatform as Cn, AuthPrincipal as Ct, CookieForwardingOptions as D, allow as Dn, DatabaseHookMethod as Dt, ConformanceSkip as E, BetterAuthGuard as En, DatabaseHookData as Et, ExtensionDefinition as F, BetterAuthModule as Fn, Register as Ft, InboundAuthRequest as G, AuthErrorBody as Gn, betterAuthCorsOrigin as Gt, HttpMountOptions as H, getBetterAuthInstanceToken as Hn, WithActiveOrganization as Ht, ExtensionRef as I, GUARD_CORE as In, RegisteredAuth as It, PlatformMountContext as J, AuthFailures as Jn, definePrincipalSource as Jt, InvocationLineage as K, AuthErrorCode as Kn, absent as Kt, FastifyPlatformOptions as L, POLICY_INVOKER as Ln, RegisteredInstances as Lt, DbHookOptions as M, InstanceLookup as Mn, OrgPermissions as Mt, DefaultInstanceCheck as N, EXTENSION_DEFINITION as Nn, PrincipalKind as Nt, CookieSink as O, definePolicy as On, DatabaseHookResult as Ot, ExpressPlatformOptions as P, UPGRADE_REQUEST as Pn, PrincipalOfKind as Pt, PolicyRef as Q, BetterAuthInfrastructureError as Qn, RequireFreshSession as Qt, GuardReach as R, PRINCIPAL_RESOLVER as Rn, SessionOf as Rt, ClaimOptions as S, defineExtension as Sn, AuthOf as St, ConformanceRunner as T, BetterAuthScopeInterceptor as Tn, AuthUser as Tt, HttpPlatform as U, getBetterAuthOptionsToken as Un, PrincipalKinds as Ut, HookPredicate as V, getBetterAuthHandleToken as Vn, UserOf as Vt, HttpRequestAccessor as W, getBetterAuthServiceToken as Wn, httpTransport as Wt, PolicyBootContext as X, AuthTransportErrorPayload as Xn, CurrentSession as Xt, PlatformPrepareContext as Y, AuthGraphqlExtensions as Yn, rejected as Yt, PolicyInvoker as Z, BetterAuthConfigurationError as Zn, CurrentUser as Zt, BetterAuthRuntimeOptions as _, allOf as _n, TransportValidationContext as _t, AuthHandlerInterceptor as a, BeforeAuth as an, ProxyTrust as at, BootAdviceContext as b, definePrincipalParam as bn, AuthHookContext as bt, AuthTransport as c, ForwardAuthCookies as cn, RequirementOptions as ct, AuthorizationLimits as d, Require as dn, ScopeInit as dt, freshSession as en, getRawCause as er, PrincipalReading as et, AuthorizationPolicy as f, RequireAuth as fn, SessionOption as ft, BetterAuthModuleOptions as g, UseBetterAuth as gn, TransportKit as gt, BetterAuthModuleAsyncOptions as h, UseAuthInstance as hn, TransportCall as ht, AuthHandle as i, AfterDatabase as in, PrincipalSource as it, DbHookMethodDecorator as j, TransportRegistry as jn, IsRegistered as jt, CorsOriginOptions as k, deny as kn, EndpointPath as kt, AuthorizationContext as l, OptionalAuth as ln, ResolutionRequest as lt, BetterAuthFactoryResult as m, SkipOriginCheck as mn, StaticOptionMustBePassedToForRootAsync as mt, ApplicationRouteDescriptor as n, AcceptPrincipals as nn, isConfigurationError as nr, PrincipalResolver as nt, AuthPrincipalBase as o, BeforeDatabase as on, Requirement as ot, BetterAuthAppOptions as p, SkipDefaultRequirements as pn, SessionPrincipalOptions as pt, OriginCheckOptions as q, AuthFailure as qn, authenticated as qt, AuthContextView as r, AfterAuth as rn, isInfrastructureError as rr, PrincipalResult as rt, AuthRouteBinding as s, CurrentPrincipal as sn, RequirementExpr as st, AdvisedHandler as t, sessionPrincipal as tn, isAuthFailure as tr, PrincipalRequest as tt, AuthorizationDecision as u, Public as un, RoutePlan as ut, BetterAuthStaticOptions as v, anyOf as vn, AdminPermissions as vt, ConformanceOutcome as w, defineTransport as wn, AuthSession as wt, BrowserExposure as x, requirement as xn, AuthLike as xt, BootAdvice as y, defineInvocationParam as yn, AuthAfterHookContext as yt, HookMethodDecorator as z, SCOPE_CORE as zn, SessionPrincipal as zt };
1663
+ //# sourceMappingURL=auth-contracts-mejJfv9d.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth-contracts-mejJfv9d.d.cts","names":[],"sources":["../src/auth-errors.ts","../src/auth-tokens.ts","../src/auth-module.ts","../src/bridge-protocol.ts","../src/request-scope.ts","../src/origin-check.ts","../src/instance-registry.ts","../src/mount-coordinator.ts","../src/principal-readings.ts","../src/policy-resolver.ts","../src/transport-registry.ts","../src/route-planner.ts","../src/auth-service.ts","../src/authorization-evaluator.ts","../src/auth-guard.ts","../src/auth-scope-interceptor.ts","../src/auth-module-definition.ts","../src/auth-decorators.ts","../src/session-principal.ts","../src/principal-resolver.ts","../src/auth-exchange.ts","../src/http-transport.ts","../src/index.ts","../src/auth-types.ts","../src/auth-contracts.ts"],"mappings":";;;;;;;;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AAQ,UAAU;WAClB,QAAQ;WACR;;WAEA;;WAEA;;KAEC,kBACR;WACW,gBAAgB;;WAChB,gBAAgB;;KAEnB;WACG;;WAEA;WACA;WACA;WACA;WACA;;UAGE,qBACf,UAAU,oBAAoB;WAErB,WAAW;WACX;WACA;WACA,SAAS;WACT,SAAS;WACT;aAAqB;aAAyB;;EACvD,MAAM;WACG;aAAoB,OAAO;aAAe;;WAC1C,MAAM;;;;;EAKf,KAAK,GAAG,+BAA+B,eAAe,QAAQ,KAAK,QAAQ;;EAE3E,QAAQ,cAAc;WACb,WAAW;;UAGL;WACN,MAAM;WACN,SAAS;WACT"}
@@ -1,7 +1,7 @@
1
1
  const require_auth_errors = require("./auth-errors-1EdQ36D8.cjs");
2
- const require_decorate = require("./decorate-Bvg21vkL.cjs");
3
- const require_auth_scope_interceptor = require("./auth-scope-interceptor-DU57SvDf.cjs");
4
- const require_auth_guard = require("./auth-guard-CdV9G47g.cjs");
2
+ const require_decorate = require("./decorate-DdRSPs9e.cjs");
3
+ const require_auth_scope_interceptor = require("./auth-scope-interceptor-DJTO9RVP.cjs");
4
+ const require_auth_guard = require("./auth-guard-Dh9SWsXf.cjs");
5
5
  const require_principal_readings = require("./principal-readings-K8zeZbEl.cjs");
6
6
  let _nestjs_common = require("@nestjs/common");
7
7
  let node_async_hooks = require("node:async_hooks");
@@ -411,4 +411,4 @@ Object.defineProperty(exports, "requirement", {
411
411
  }
412
412
  });
413
413
 
414
- //# sourceMappingURL=auth-decorators-B7xasVk_.cjs.map
414
+ //# sourceMappingURL=auth-decorators-9L-UO_T3.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"auth-decorators-B7xasVk_.cjs","names":["AsyncLocalStorage","AuthFailures","isConfigurationError","SetMetadata","applyDecorators","UseGuards","BetterAuthGuard","UseInterceptors","BetterAuthScopeInterceptor","PrincipalReadings","createParamDecorator","BetterAuthConfigurationError"],"sources":["../src/request-scope.ts","../src/auth-decorators.ts"],"sourcesContent":["import { AsyncLocalStorage } from \"node:async_hooks\";\nimport type {\n AuthorizationDecision,\n InvocationLineage,\n PrincipalReading,\n PrincipalResult,\n RoutePlan,\n TransportCall,\n} from \"./auth-contracts.js\";\nimport {\n AuthFailures,\n type AuthFailure,\n isConfigurationError,\n} from \"./auth-errors.js\";\nimport type { ScopeView } from \"./bridge-protocol.js\";\n\nexport interface ScopeState {\n readonly view: ScopeView;\n readonly call?: TransportCall;\n readonly plan?: RoutePlan;\n readonly reading?: () => PrincipalReading;\n}\nexport interface RequestState {\n readonly principal: Map<string, Promise<PrincipalResult>>;\n readonly policyIo: Map<string, Promise<unknown>>;\n readonly decisions: Map<string, Promise<AuthorizationDecision>>;\n readonly values: Map<symbol, unknown>;\n readonly authorizationCalls: Set<string>;\n readonly origins: Map<string, Promise<AuthFailure | null>>;\n readonly surfaced: Set<string>;\n readonly connections: Map<\n string,\n {\n value: Extract<PrincipalResult, { outcome: \"authenticated\" | \"absent\" }>;\n expiresAt: number;\n }\n >;\n}\n\nconst SURFACED = Symbol.for(\"nestjs-slightly-better-auth:surfaced\");\nexport function memoKey(\n instance: string,\n ...inputs: readonly unknown[]\n): string {\n return JSON.stringify([instance, ...inputs]);\n}\n\n/** Shared by guards and readers that have only the transport's structural lineage. */\nexport function surfacedRecord(\n key: object,\n lineage?: InvocationLineage,\n): Set<string> {\n const carrier = lineage?.carrier ?? key;\n const partition = lineage ? lineage.position.split(\":\", 1)[0]! : \"\";\n let records = Reflect.get(carrier, SURFACED) as\n | Map<string, Set<string>>\n | undefined;\n if (!records) {\n records = new Map();\n Object.defineProperty(carrier, SURFACED, { value: records });\n }\n let record = records.get(partition);\n if (!record) {\n record = new Set();\n records.set(partition, record);\n }\n return record;\n}\n\nexport class RequestScope {\n readonly #storage = new AsyncLocalStorage<ScopeState>();\n readonly #states = new WeakMap<object, RequestState>();\n readonly #valueKeys = new Map<string, Map<symbol, symbol>>();\n readonly #errorIds = new WeakMap<object, number>();\n #nextError = 0;\n\n run<T>(state: ScopeState, fn: () => T): T {\n return this.#storage.run(state, fn);\n }\n\n exit<T>(fn: () => T): T {\n return this.#storage.exit(fn);\n }\n\n current(): ScopeState | undefined {\n return this.#storage.getStore();\n }\n\n stateFor(key: object): RequestState {\n let state = this.#states.get(key);\n if (!state) {\n state = {\n principal: new Map(),\n policyIo: new Map(),\n decisions: new Map(),\n values: new Map(),\n authorizationCalls: new Set(),\n origins: new Map(),\n surfaced: new Set(),\n connections: new Map(),\n };\n this.#states.set(key, state);\n }\n return state;\n }\n\n memoPrincipal(\n call: Pick<TransportCall, \"key\" | \"connection\" | \"principalTtlMs\">,\n input: {\n instance: string;\n freshness: \"default\" | \"authoritative\";\n sourceSet: string;\n },\n compute: () => Promise<PrincipalResult>,\n ): Promise<PrincipalResult> {\n const key = memoKey(input.instance, input.freshness, input.sourceSet);\n const state = this.stateFor(call.key);\n const existing = state.principal.get(key);\n if (existing) {\n return existing;\n }\n const connection =\n call.connection &&\n input.freshness !== \"authoritative\" &&\n (call.principalTtlMs ?? 0) > 0\n ? this.stateFor(call.connection).connections\n : undefined;\n const cached = connection?.get(key);\n const promise = Promise.resolve().then(async () => {\n if (cached && cached.expiresAt > Date.now()) {\n return cached.value;\n }\n connection?.delete(key);\n try {\n const value = await compute();\n if (value.outcome !== \"rejected\") {\n connection?.set(key, {\n value,\n expiresAt: Date.now() + (call.principalTtlMs ?? 0),\n });\n }\n return value;\n } catch (error) {\n connection?.delete(key);\n throw error;\n }\n });\n state.principal.set(key, promise);\n return promise;\n }\n\n memoPolicyIo<T>(\n request: object,\n instance: string,\n concreteKey: string,\n compute: () => Promise<T>,\n limit: number | false = 100,\n ): Promise<T> {\n const state = this.stateFor(request);\n const key = memoKey(instance, concreteKey);\n const existing = state.policyIo.get(key);\n if (existing) {\n return existing as Promise<T>;\n }\n if (\n limit !== false &&\n [...state.authorizationCalls].filter(\n (entry) => JSON.parse(entry)[0] === instance,\n ).length >= limit\n ) {\n return Promise.reject(\n AuthFailures.rejected({\n status: 429,\n reason: \"TOO_MANY_AUTHORIZATION_CHECKS\",\n }),\n );\n }\n state.authorizationCalls.add(key);\n const promise = Promise.resolve().then(compute);\n state.policyIo.set(key, promise);\n return promise;\n }\n\n memoDecision(\n invocation: object,\n instance: string,\n concreteKey: string,\n compute: () => Promise<AuthorizationDecision>,\n ): Promise<AuthorizationDecision> {\n const decisions = this.stateFor(invocation).decisions;\n const key = memoKey(instance, concreteKey);\n let promise = decisions.get(key);\n if (!promise) {\n promise = Promise.resolve().then(compute);\n decisions.set(key, promise);\n }\n return promise;\n }\n\n valueKey(instance: string, key: symbol): symbol {\n let keys = this.#valueKeys.get(instance);\n if (!keys) {\n keys = new Map();\n this.#valueKeys.set(instance, keys);\n }\n let namespaced = keys.get(key);\n if (!namespaced) {\n namespaced = Symbol(key.description);\n keys.set(key, namespaced);\n }\n return namespaced;\n }\n\n surfaced(\n key: object,\n error: object,\n context: { instance: string; site: string; lineage?: InvocationLineage },\n ): boolean {\n let id = this.#errorIds.get(error);\n if (!id) {\n id = ++this.#nextError;\n this.#errorIds.set(error, id);\n }\n const reason = isConfigurationError(error)\n ? memoKey(context.instance, error.code, context.site)\n : `error:${id}`;\n const carrier = surfacedRecord(key, context.lineage);\n const state =\n key === context.lineage?.carrier ? carrier : this.stateFor(key).surfaced;\n const repeated = state.has(reason) || carrier.has(reason);\n state.add(reason);\n carrier.add(reason);\n return repeated;\n }\n}\n","import {\n applyDecorators,\n createParamDecorator,\n SetMetadata,\n UseGuards,\n UseInterceptors,\n type ExecutionContext,\n} from \"@nestjs/common\";\nimport type {\n DatabaseHookTarget,\n DbHookMethodDecorator,\n DbHookOptions,\n HookMethodDecorator,\n HookOptions,\n HookPredicate,\n PolicyRef,\n PrincipalReading,\n Requirement,\n RequirementExpr,\n RequirementOptions,\n} from \"./auth-contracts.js\";\nimport type {\n EndpointPath,\n PrincipalKind,\n PrincipalOfKind,\n} from \"./auth-types.js\";\nimport { BetterAuthConfigurationError } from \"./auth-errors.js\";\nimport * as tokens from \"./auth-tokens.js\";\nimport { BetterAuthGuard } from \"./auth-guard.js\";\nimport { BetterAuthScopeInterceptor } from \"./auth-scope-interceptor.js\";\nimport { PrincipalReadings } from \"./principal-readings.js\";\nimport { RequestScope } from \"./request-scope.js\";\n\nfunction append(target: object, key: symbol, value: unknown): void {\n Reflect.defineMetadata(\n key,\n Object.freeze([...(Reflect.getOwnMetadata(key, target) ?? []), value]),\n target,\n );\n}\nexport const Public = () => SetMetadata(tokens.ACCESS_METADATA, \"public\");\nexport const OptionalAuth = () =>\n SetMetadata(tokens.ACCESS_METADATA, \"optional\");\nexport const RequireAuth = (options?: { authoritative?: boolean }) =>\n applyDecorators(\n SetMetadata(tokens.ACCESS_METADATA, \"required\"),\n SetMetadata(tokens.FRESHNESS_METADATA, options?.authoritative === true),\n );\nexport const UseAuthInstance = (name: string) =>\n SetMetadata(tokens.AUTH_INSTANCE_METADATA, name);\nexport const AcceptPrincipals = (\n ...kinds: readonly [PrincipalKind, ...PrincipalKind[]]\n) => SetMetadata(tokens.ACCEPT_PRINCIPALS_METADATA, Object.freeze([...kinds]));\nexport const SkipDefaultRequirements = () =>\n SetMetadata(tokens.SKIP_DEFAULT_REQUIREMENTS_METADATA, true);\nexport const ForwardAuthCookies = (enabled = true) =>\n SetMetadata(tokens.FORWARD_COOKIES_METADATA, enabled);\nexport const SkipOriginCheck = () =>\n SetMetadata(tokens.SKIP_ORIGIN_CHECK_METADATA, true);\nexport const UseBetterAuth = () =>\n applyDecorators(\n SetMetadata(tokens.USE_BETTER_AUTH_METADATA, true),\n UseGuards(BetterAuthGuard),\n UseInterceptors(BetterAuthScopeInterceptor),\n );\nexport function Require(\n ...requirements: readonly RequirementExpr[]\n): ClassDecorator & MethodDecorator {\n return (\n target: object,\n _key?: string | symbol,\n descriptor?: PropertyDescriptor,\n ) => {\n for (const expression of requirements) {\n append(\n descriptor?.value ?? target,\n tokens.REQUIREMENTS_METADATA,\n expression,\n );\n }\n };\n}\nexport const anyOf = (\n ...requirements: readonly RequirementExpr[]\n): RequirementExpr => ({ anyOf: requirements });\nexport const allOf = (\n ...requirements: readonly RequirementExpr[]\n): RequirementExpr => ({ allOf: requirements });\nexport const requirement = <P>(\n policy: PolicyRef<P>,\n params: P,\n options?: RequirementOptions,\n): Requirement<P> => ({ policy, params, ...options });\n\nexport interface ReaderContext {\n readonly args: readonly unknown[];\n readonly readings: PrincipalReadings;\n readonly scope: RequestScope;\n readonly reading?: () => PrincipalReading;\n}\nexport function readerContext(context: ExecutionContext): ReaderContext {\n const args = context.getArgs();\n for (const arg of [args, ...args]) {\n if (\n (typeof arg !== \"object\" || arg === null) &&\n typeof arg !== \"function\"\n ) {\n continue;\n }\n const bridge = Reflect.get(arg, tokens.READER_CONTEXT) as\n | ReaderContext\n | undefined;\n if (\n bridge &&\n bridge.args.length === args.length &&\n bridge.args.every((value, index) => value === args[index]) &&\n bridge.reading !== undefined &&\n bridge.scope.current()?.reading === bridge.reading\n ) {\n return bridge;\n }\n }\n // No application state is created or retained by a DI-free lineage-only reader.\n const scope = new RequestScope();\n return { args, scope, readings: new PrincipalReadings(scope) };\n}\nfunction principalParam(spec?: {\n kind: string;\n reason: string;\n project: (p: any) => unknown;\n}): ParameterDecorator {\n const decorator = createParamDecorator(\n (_data: unknown, context: ExecutionContext) => {\n const bridge = readerContext(context);\n const input = {\n args: context.getArgs(),\n site: `${context.getClass().name}.${context.getHandler().name}`,\n };\n const reading =\n bridge.reading !== undefined &&\n bridge.scope.current()?.reading === bridge.reading\n ? bridge.readings.current()\n : bridge.readings.read(input);\n return bridge.readings.project(\n reading,\n { ...spec, site: input.site, project: spec?.project ?? ((p) => p) },\n input,\n );\n },\n )();\n return (target, propertyKey, index) => {\n if (propertyKey === undefined) {\n throw new BetterAuthConfigurationError(\n \"PRINCIPAL_PARAM_TARGET\",\n \"Principal parameters require a handler method\",\n );\n }\n const handler = Reflect.get(target, propertyKey);\n append(handler, tokens.PRINCIPAL_PARAMS_METADATA, {\n index,\n ...(spec ? { kind: spec.kind, reason: spec.reason } : {}),\n });\n decorator(target, propertyKey, index);\n };\n}\nexport const CurrentPrincipal = (): ParameterDecorator => principalParam();\nexport function definePrincipalParam<K extends PrincipalKind, R>(spec: {\n readonly kind: K;\n readonly reason: string;\n readonly project: (principal: PrincipalOfKind<K>) => R;\n}): () => ParameterDecorator {\n return () => principalParam(spec);\n}\nexport function defineInvocationParam(\n slot: symbol,\n spec: { readonly missing: string },\n): () => ParameterDecorator {\n return () => {\n const decorator = createParamDecorator(\n (_data: unknown, context: ExecutionContext) => {\n const bridge = readerContext(context);\n const state = bridge.scope.current();\n const input = {\n args: context.getArgs(),\n site: `${context.getClass().name}.${context.getHandler().name}`,\n };\n const reading = state?.reading\n ? bridge.readings.current()\n : bridge.readings.read(input);\n const candidates = state?.call\n ? [state.call.invocation]\n : [input.args, ...input.args];\n for (const candidate of candidates) {\n if (\n !candidate ||\n (typeof candidate !== \"object\" && typeof candidate !== \"function\")\n ) {\n continue;\n }\n const values = Reflect.get(candidate, tokens.INVOCATION_VALUES) as\n | Map<string, Map<symbol, unknown>>\n | undefined;\n if (values?.get(reading.instance)?.has(slot)) {\n return values.get(reading.instance)!.get(slot);\n }\n }\n throw bridge.readings.deliver(\n BetterAuthConfigurationError.atRequest(\n \"NO_INVOCATION_VALUE\",\n spec.missing,\n { site: input.site },\n ),\n input,\n reading.instance,\n );\n },\n )();\n return (target, key, index) => {\n if (key === undefined) {\n throw new BetterAuthConfigurationError(\n \"INVOCATION_PARAM_TARGET\",\n \"Invocation parameters require a handler method\",\n );\n }\n append(Reflect.get(target, key), tokens.INVOCATION_PARAMS_METADATA, {\n index,\n slot,\n missing: spec.missing,\n });\n decorator(target, key, index);\n };\n };\n}\nexport interface EndpointHookDeclaration {\n readonly phase: \"before\" | \"after\";\n readonly match: string | readonly string[] | HookPredicate | undefined;\n readonly options: Readonly<HookOptions>;\n readonly method: string | symbol;\n // biome-ignore lint/complexity/noBannedTypes: Nest handler metadata preserves the framework function identity.\n readonly handler: Function;\n readonly declarationOrder: number;\n}\nexport interface DatabaseHookDeclaration {\n readonly phase: \"before\" | \"after\";\n readonly target: DatabaseHookTarget;\n readonly options: Readonly<DbHookOptions>;\n readonly method: string | symbol;\n // biome-ignore lint/complexity/noBannedTypes: Nest handler metadata preserves the framework function identity.\n readonly handler: Function;\n readonly declarationOrder: number;\n}\n// biome-ignore lint/complexity/noBannedTypes: Nest handler metadata preserves the framework function identity.\nexport function readHookMetadata(handler: Function): {\n readonly hooks: readonly EndpointHookDeclaration[];\n readonly databaseHooks: readonly DatabaseHookDeclaration[];\n} {\n return {\n hooks: Reflect.getOwnMetadata(tokens.HOOK_METADATA, handler) ?? [],\n databaseHooks:\n Reflect.getOwnMetadata(tokens.DB_HOOK_METADATA, handler) ?? [],\n };\n}\nfunction hook<P extends string>(\n phase: \"before\" | \"after\",\n match?: P | readonly P[] | HookPredicate,\n options?: HookOptions,\n): HookMethodDecorator<P> {\n return (_target, method, descriptor) => {\n const handler = descriptor.value!;\n const records = readHookMetadata(handler).hooks;\n append(\n handler,\n tokens.HOOK_METADATA,\n Object.freeze({\n phase,\n match: Array.isArray(match) ? Object.freeze([...match]) : match,\n options: Object.freeze({ ...options }),\n method,\n handler,\n declarationOrder: records.length,\n }),\n );\n };\n}\nexport const BeforeAuth = <const P extends EndpointPath | (string & {})>(\n match?: P | readonly P[] | HookPredicate,\n options?: HookOptions,\n): HookMethodDecorator<P> => hook(\"before\", match, options);\nexport const AfterAuth = <const P extends EndpointPath | (string & {})>(\n match?: P | readonly P[] | HookPredicate,\n options?: HookOptions,\n): HookMethodDecorator<P> => hook(\"after\", match, options);\nfunction databaseHook<\n E extends DatabaseHookTarget,\n Ph extends \"before\" | \"after\",\n>(phase: Ph, target: E, options?: DbHookOptions): DbHookMethodDecorator<E, Ph> {\n return (_prototype, method, descriptor) => {\n const handler = descriptor.value!;\n append(\n handler,\n tokens.DB_HOOK_METADATA,\n Object.freeze({\n phase,\n target,\n options: Object.freeze({ ...options }),\n method,\n handler,\n declarationOrder: readHookMetadata(handler).databaseHooks.length,\n }),\n );\n };\n}\nexport const BeforeDatabase = <E extends DatabaseHookTarget>(\n target: E,\n options?: DbHookOptions,\n): DbHookMethodDecorator<E, \"before\"> =>\n databaseHook(\"before\", target, options);\nexport const AfterDatabase = <E extends DatabaseHookTarget>(\n target: E,\n options?: DbHookOptions,\n): DbHookMethodDecorator<E, \"after\"> => databaseHook(\"after\", target, options);\n"],"mappings":";;;;;;;;AAuCA,MAAM,WAAW,OAAO,IAAI,sCAAsC;AAClE,SAAgB,QACd,UACA,GAAG,QACK;CACR,OAAO,KAAK,UAAU,CAAC,UAAU,GAAG,MAAM,CAAC;AAC7C;;AAGA,SAAgB,eACd,KACA,SACa;CACb,MAAM,UAAU,SAAS,WAAW;CACpC,MAAM,YAAY,UAAU,QAAQ,SAAS,MAAM,KAAK,CAAC,CAAC,CAAC,KAAM;CACjE,IAAI,UAAU,QAAQ,IAAI,SAAS,QAAQ;CAG3C,IAAI,CAAC,SAAS;EACZ,0BAAU,IAAI,IAAI;EAClB,OAAO,eAAe,SAAS,UAAU,EAAE,OAAO,QAAQ,CAAC;CAC7D;CACA,IAAI,SAAS,QAAQ,IAAI,SAAS;CAClC,IAAI,CAAC,QAAQ;EACX,yBAAS,IAAI,IAAI;EACjB,QAAQ,IAAI,WAAW,MAAM;CAC/B;CACA,OAAO;AACT;AAEA,IAAa,eAAb,MAA0B;CACxB,WAAoB,IAAIA,iBAAAA,kBAA8B;CACtD,0BAAmB,IAAI,QAA8B;CACrD,6BAAsB,IAAI,IAAiC;CAC3D,4BAAqB,IAAI,QAAwB;CACjD,aAAa;CAEb,IAAO,OAAmB,IAAgB;EACxC,OAAO,KAAK,SAAS,IAAI,OAAO,EAAE;CACpC;CAEA,KAAQ,IAAgB;EACtB,OAAO,KAAK,SAAS,KAAK,EAAE;CAC9B;CAEA,UAAkC;EAChC,OAAO,KAAK,SAAS,SAAS;CAChC;CAEA,SAAS,KAA2B;EAClC,IAAI,QAAQ,KAAK,QA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AAO;AACzD,SAAS,aAGP,OAAW,QAAW,SAAuD;CAC7E,QAAQ,YAAY,QAAQ,eAAe;EACzC,MAAM,UAAU,WAAW;EAC3B,OACE,SAAA,iBAAA,kBAEA,OAAO,OAAO;GACZ;GACA;GACA,SAAS,OAAO,OAAO,EAAE,GAAG,QAAQ,CAAC;GACrC;GACA;GACA,kBAAkB,iBAAiB,OAAO,CAAC,CAAC,cAAc;EAC5D,CAAC,CACH;CACF;AACF;AACA,MAAa,kBACX,QACA,YAEA,aAAa,UAAU,QAAQ,OAAO;AACxC,MAAa,iBACX,QACA,YACsC,aAAa,SAAS,QAAQ,OAAO"}
1
+ {"version":3,"file":"auth-decorators-9L-UO_T3.cjs","names":["AsyncLocalStorage","AuthFailures","isConfigurationError","SetMetadata","applyDecorators","UseGuards","BetterAuthGuard","UseInterceptors","BetterAuthScopeInterceptor","PrincipalReadings","createParamDecorator","BetterAuthConfigurationError"],"sources":["../src/request-scope.ts","../src/auth-decorators.ts"],"sourcesContent":["import { AsyncLocalStorage } from \"node:async_hooks\";\nimport type {\n AuthorizationDecision,\n InvocationLineage,\n PrincipalReading,\n PrincipalResult,\n RoutePlan,\n TransportCall,\n} from \"./auth-contracts.js\";\nimport {\n AuthFailures,\n type AuthFailure,\n isConfigurationError,\n} from \"./auth-errors.js\";\nimport type { ScopeView } from \"./bridge-protocol.js\";\n\nexport interface ScopeState {\n readonly view: ScopeView;\n readonly call?: TransportCall;\n readonly plan?: RoutePlan;\n readonly reading?: () => PrincipalReading;\n}\nexport interface RequestState {\n readonly principal: Map<string, Promise<PrincipalResult>>;\n readonly policyIo: Map<string, Promise<unknown>>;\n readonly decisions: Map<string, Promise<AuthorizationDecision>>;\n readonly values: Map<symbol, unknown>;\n readonly authorizationCalls: Set<string>;\n readonly origins: Map<string, Promise<AuthFailure | null>>;\n readonly surfaced: Set<string>;\n readonly connections: Map<\n string,\n {\n value: Extract<PrincipalResult, { outcome: \"authenticated\" | \"absent\" }>;\n expiresAt: number;\n }\n >;\n}\n\nconst SURFACED = Symbol.for(\"nestjs-slightly-better-auth:surfaced\");\nexport function memoKey(\n instance: string,\n ...inputs: readonly unknown[]\n): string {\n return JSON.stringify([instance, ...inputs]);\n}\n\n/** Shared by guards and readers that have only the transport's structural lineage. */\nexport function surfacedRecord(\n key: object,\n lineage?: InvocationLineage,\n): Set<string> {\n const carrier = lineage?.carrier ?? key;\n const partition = lineage ? lineage.position.split(\":\", 1)[0]! : \"\";\n let records = Reflect.get(carrier, SURFACED) as\n | Map<string, Set<string>>\n | undefined;\n if (!records) {\n records = new Map();\n Object.defineProperty(carrier, SURFACED, { value: records });\n }\n let record = records.get(partition);\n if (!record) {\n record = new Set();\n records.set(partition, record);\n }\n return record;\n}\n\nexport class RequestScope {\n readonly #storage = new AsyncLocalStorage<ScopeState>();\n readonly #states = new WeakMap<object, RequestState>();\n readonly #valueKeys = new Map<string, Map<symbol, symbol>>();\n readonly #errorIds = new WeakMap<object, number>();\n #nextError = 0;\n\n run<T>(state: ScopeState, fn: () => T): T {\n return this.#storage.run(state, fn);\n }\n\n exit<T>(fn: () => T): T {\n return this.#storage.exit(fn);\n }\n\n current(): ScopeState | undefined {\n return this.#storage.getStore();\n }\n\n stateFor(key: object): RequestState {\n let state = this.#states.get(key);\n if (!state) {\n state = {\n principal: new Map(),\n policyIo: new Map(),\n decisions: new Map(),\n values: new Map(),\n authorizationCalls: new Set(),\n origins: new Map(),\n surfaced: new Set(),\n connections: new Map(),\n };\n this.#states.set(key, state);\n }\n return state;\n }\n\n memoPrincipal(\n call: Pick<TransportCall, \"key\" | \"connection\" | \"principalTtlMs\">,\n input: {\n instance: string;\n freshness: \"default\" | \"authoritative\";\n sourceSet: string;\n },\n compute: () => Promise<PrincipalResult>,\n ): Promise<PrincipalResult> {\n const key = memoKey(input.instance, input.freshness, input.sourceSet);\n const state = this.stateFor(call.key);\n const existing = state.principal.get(key);\n if (existing) {\n return existing;\n }\n const connection =\n call.connection &&\n input.freshness !== \"authoritative\" &&\n (call.principalTtlMs ?? 0) > 0\n ? this.stateFor(call.connection).connections\n : undefined;\n const cached = connection?.get(key);\n const promise = Promise.resolve().then(async () => {\n if (cached && cached.expiresAt > Date.now()) {\n return cached.value;\n }\n connection?.delete(key);\n try {\n const value = await compute();\n if (value.outcome !== \"rejected\") {\n connection?.set(key, {\n value,\n expiresAt: Date.now() + (call.principalTtlMs ?? 0),\n });\n }\n return value;\n } catch (error) {\n connection?.delete(key);\n throw error;\n }\n });\n state.principal.set(key, promise);\n return promise;\n }\n\n memoPolicyIo<T>(\n request: object,\n instance: string,\n concreteKey: string,\n compute: () => Promise<T>,\n limit: number | false = 100,\n ): Promise<T> {\n const state = this.stateFor(request);\n const key = memoKey(instance, concreteKey);\n const existing = state.policyIo.get(key);\n if (existing) {\n return existing as Promise<T>;\n }\n if (\n limit !== false &&\n [...state.authorizationCalls].filter(\n (entry) => JSON.parse(entry)[0] === instance,\n ).length >= limit\n ) {\n return Promise.reject(\n AuthFailures.rejected({\n status: 429,\n reason: \"TOO_MANY_AUTHORIZATION_CHECKS\",\n }),\n );\n }\n state.authorizationCalls.add(key);\n const promise = Promise.resolve().then(compute);\n state.policyIo.set(key, promise);\n return promise;\n }\n\n memoDecision(\n invocation: object,\n instance: string,\n concreteKey: string,\n compute: () => Promise<AuthorizationDecision>,\n ): Promise<AuthorizationDecision> {\n const decisions = this.stateFor(invocation).decisions;\n const key = memoKey(instance, concreteKey);\n let promise = decisions.get(key);\n if (!promise) {\n promise = Promise.resolve().then(compute);\n decisions.set(key, promise);\n }\n return promise;\n }\n\n valueKey(instance: string, key: symbol): symbol {\n let keys = this.#valueKeys.get(instance);\n if (!keys) {\n keys = new Map();\n this.#valueKeys.set(instance, keys);\n }\n let namespaced = keys.get(key);\n if (!namespaced) {\n namespaced = Symbol(key.description);\n keys.set(key, namespaced);\n }\n return namespaced;\n }\n\n surfaced(\n key: object,\n error: object,\n context: { instance: string; site: string; lineage?: InvocationLineage },\n ): boolean {\n let id = this.#errorIds.get(error);\n if (!id) {\n id = ++this.#nextError;\n this.#errorIds.set(error, id);\n }\n const reason = isConfigurationError(error)\n ? memoKey(context.instance, error.code, context.site)\n : `error:${id}`;\n const carrier = surfacedRecord(key, context.lineage);\n const state =\n key === context.lineage?.carrier ? carrier : this.stateFor(key).surfaced;\n const repeated = state.has(reason) || carrier.has(reason);\n state.add(reason);\n carrier.add(reason);\n return repeated;\n }\n}\n","import {\n applyDecorators,\n createParamDecorator,\n SetMetadata,\n UseGuards,\n UseInterceptors,\n type ExecutionContext,\n} from \"@nestjs/common\";\nimport type {\n DatabaseHookTarget,\n DbHookMethodDecorator,\n DbHookOptions,\n HookMethodDecorator,\n HookOptions,\n HookPredicate,\n PolicyRef,\n PrincipalReading,\n Requirement,\n RequirementExpr,\n RequirementOptions,\n} from \"./auth-contracts.js\";\nimport type {\n EndpointPath,\n PrincipalKind,\n PrincipalOfKind,\n} from \"./auth-types.js\";\nimport { BetterAuthConfigurationError } from \"./auth-errors.js\";\nimport * as tokens from \"./auth-tokens.js\";\nimport { BetterAuthGuard } from \"./auth-guard.js\";\nimport { BetterAuthScopeInterceptor } from \"./auth-scope-interceptor.js\";\nimport { PrincipalReadings } from \"./principal-readings.js\";\nimport { RequestScope } from \"./request-scope.js\";\n\nfunction append(target: object, key: symbol, value: unknown): void {\n Reflect.defineMetadata(\n key,\n Object.freeze([...(Reflect.getOwnMetadata(key, target) ?? []), value]),\n target,\n );\n}\nexport const Public = () => SetMetadata(tokens.ACCESS_METADATA, \"public\");\nexport const OptionalAuth = () =>\n SetMetadata(tokens.ACCESS_METADATA, \"optional\");\nexport const RequireAuth = (options?: { authoritative?: boolean }) =>\n applyDecorators(\n SetMetadata(tokens.ACCESS_METADATA, \"required\"),\n SetMetadata(tokens.FRESHNESS_METADATA, options?.authoritative === true),\n );\nexport const UseAuthInstance = (name: string) =>\n SetMetadata(tokens.AUTH_INSTANCE_METADATA, name);\nexport const AcceptPrincipals = (\n ...kinds: readonly [PrincipalKind, ...PrincipalKind[]]\n) => SetMetadata(tokens.ACCEPT_PRINCIPALS_METADATA, Object.freeze([...kinds]));\nexport const SkipDefaultRequirements = () =>\n SetMetadata(tokens.SKIP_DEFAULT_REQUIREMENTS_METADATA, true);\nexport const ForwardAuthCookies = (enabled = true) =>\n SetMetadata(tokens.FORWARD_COOKIES_METADATA, enabled);\nexport const SkipOriginCheck = () =>\n SetMetadata(tokens.SKIP_ORIGIN_CHECK_METADATA, true);\nexport const UseBetterAuth = () =>\n applyDecorators(\n SetMetadata(tokens.USE_BETTER_AUTH_METADATA, true),\n UseGuards(BetterAuthGuard),\n UseInterceptors(BetterAuthScopeInterceptor),\n );\nexport function Require(\n ...requirements: readonly RequirementExpr[]\n): ClassDecorator & MethodDecorator {\n return (\n target: object,\n _key?: string | symbol,\n descriptor?: PropertyDescriptor,\n ) => {\n for (const expression of requirements) {\n append(\n descriptor?.value ?? target,\n tokens.REQUIREMENTS_METADATA,\n expression,\n );\n }\n };\n}\nexport const anyOf = (\n ...requirements: readonly RequirementExpr[]\n): RequirementExpr => ({ anyOf: requirements });\nexport const allOf = (\n ...requirements: readonly RequirementExpr[]\n): RequirementExpr => ({ allOf: requirements });\nexport const requirement = <P>(\n policy: PolicyRef<P>,\n params: P,\n options?: RequirementOptions,\n): Requirement<P> => ({ policy, params, ...options });\n\nexport interface ReaderContext {\n readonly args: readonly unknown[];\n readonly readings: PrincipalReadings;\n readonly scope: RequestScope;\n readonly reading?: () => PrincipalReading;\n}\nexport function readerContext(context: ExecutionContext): ReaderContext {\n const args = context.getArgs();\n for (const arg of [args, ...args]) {\n if (\n (typeof arg !== \"object\" || arg === null) &&\n typeof arg !== \"function\"\n ) {\n continue;\n }\n const bridge = Reflect.get(arg, tokens.READER_CONTEXT) as\n | ReaderContext\n | undefined;\n if (\n bridge &&\n bridge.args.length === args.length &&\n bridge.args.every((value, index) => value === args[index]) &&\n bridge.reading !== undefined &&\n bridge.scope.current()?.reading === bridge.reading\n ) {\n return bridge;\n }\n }\n // No application state is created or retained by a DI-free lineage-only reader.\n const scope = new RequestScope();\n return { args, scope, readings: new PrincipalReadings(scope) };\n}\nfunction principalParam(spec?: {\n kind: string;\n reason: string;\n project: (p: any) => unknown;\n}): ParameterDecorator {\n const decorator = createParamDecorator(\n (_data: unknown, context: ExecutionContext) => {\n const bridge = readerContext(context);\n const input = {\n args: context.getArgs(),\n site: `${context.getClass().name}.${context.getHandler().name}`,\n };\n const reading =\n bridge.reading !== undefined &&\n bridge.scope.current()?.reading === bridge.reading\n ? bridge.readings.current()\n : bridge.readings.read(input);\n return bridge.readings.project(\n reading,\n { ...spec, site: input.site, project: spec?.project ?? ((p) => p) },\n input,\n );\n },\n )();\n return (target, propertyKey, index) => {\n if (propertyKey === undefined) {\n throw new BetterAuthConfigurationError(\n \"PRINCIPAL_PARAM_TARGET\",\n \"Principal parameters require a handler method\",\n );\n }\n const handler = Reflect.get(target, propertyKey);\n append(handler, tokens.PRINCIPAL_PARAMS_METADATA, {\n index,\n ...(spec ? { kind: spec.kind, reason: spec.reason } : {}),\n });\n decorator(target, propertyKey, index);\n };\n}\nexport const CurrentPrincipal = (): ParameterDecorator => principalParam();\nexport function definePrincipalParam<K extends PrincipalKind, R>(spec: {\n readonly kind: K;\n readonly reason: string;\n readonly project: (principal: PrincipalOfKind<K>) => R;\n}): () => ParameterDecorator {\n return () => principalParam(spec);\n}\nexport function defineInvocationParam(\n slot: symbol,\n spec: { readonly missing: string },\n): () => ParameterDecorator {\n return () => {\n const decorator = createParamDecorator(\n (_data: unknown, context: ExecutionContext) => {\n const bridge = readerContext(context);\n const state = bridge.scope.current();\n const input = {\n args: context.getArgs(),\n site: `${context.getClass().name}.${context.getHandler().name}`,\n };\n const reading = state?.reading\n ? bridge.readings.current()\n : bridge.readings.read(input);\n const candidates = state?.call\n ? [state.call.invocation]\n : [input.args, ...input.args];\n for (const candidate of candidates) {\n if (\n !candidate ||\n (typeof candidate !== \"object\" && typeof candidate !== \"function\")\n ) {\n continue;\n }\n const values = Reflect.get(candidate, tokens.INVOCATION_VALUES) as\n | Map<string, Map<symbol, unknown>>\n | undefined;\n if (values?.get(reading.instance)?.has(slot)) {\n return values.get(reading.instance)!.get(slot);\n }\n }\n throw bridge.readings.deliver(\n BetterAuthConfigurationError.atRequest(\n \"NO_INVOCATION_VALUE\",\n spec.missing,\n { site: input.site },\n ),\n input,\n reading.instance,\n );\n },\n )();\n return (target, key, index) => {\n if (key === undefined) {\n throw new BetterAuthConfigurationError(\n \"INVOCATION_PARAM_TARGET\",\n \"Invocation parameters require a handler method\",\n );\n }\n append(Reflect.get(target, key), tokens.INVOCATION_PARAMS_METADATA, {\n index,\n slot,\n missing: spec.missing,\n });\n decorator(target, key, index);\n };\n };\n}\nexport interface EndpointHookDeclaration {\n readonly phase: \"before\" | \"after\";\n readonly match: string | readonly string[] | HookPredicate | undefined;\n readonly options: Readonly<HookOptions>;\n readonly method: string | symbol;\n // biome-ignore lint/complexity/noBannedTypes: Nest handler metadata preserves the framework function identity.\n readonly handler: Function;\n readonly declarationOrder: number;\n}\nexport interface DatabaseHookDeclaration {\n readonly phase: \"before\" | \"after\";\n readonly target: DatabaseHookTarget;\n readonly options: Readonly<DbHookOptions>;\n readonly method: string | symbol;\n // biome-ignore lint/complexity/noBannedTypes: Nest handler metadata preserves the framework function identity.\n readonly handler: Function;\n readonly declarationOrder: number;\n}\n// biome-ignore lint/complexity/noBannedTypes: Nest handler metadata preserves the framework function identity.\nexport function readHookMetadata(handler: Function): {\n readonly hooks: readonly EndpointHookDeclaration[];\n readonly databaseHooks: readonly DatabaseHookDeclaration[];\n} {\n return {\n hooks: Reflect.getOwnMetadata(tokens.HOOK_METADATA, handler) ?? [],\n databaseHooks:\n Reflect.getOwnMetadata(tokens.DB_HOOK_METADATA, handler) ?? [],\n };\n}\nfunction hook<P extends string>(\n phase: \"before\" | \"after\",\n match?: P | readonly P[] | HookPredicate,\n options?: HookOptions,\n): HookMethodDecorator<P> {\n return (_target, method, descriptor) => {\n const handler = descriptor.value!;\n const records = readHookMetadata(handler).hooks;\n append(\n handler,\n tokens.HOOK_METADATA,\n Object.freeze({\n phase,\n match: Array.isArray(match) ? Object.freeze([...match]) : match,\n options: Object.freeze({ ...options }),\n method,\n handler,\n declarationOrder: records.length,\n }),\n );\n };\n}\nexport const BeforeAuth = <const P extends EndpointPath | (string & {})>(\n match?: P | readonly P[] | HookPredicate,\n options?: HookOptions,\n): HookMethodDecorator<P> => hook(\"before\", match, options);\nexport const AfterAuth = <const P extends EndpointPath | (string & {})>(\n match?: P | readonly P[] | HookPredicate,\n options?: HookOptions,\n): HookMethodDecorator<P> => hook(\"after\", match, options);\nfunction databaseHook<\n E extends DatabaseHookTarget,\n Ph extends \"before\" | \"after\",\n>(phase: Ph, target: E, options?: DbHookOptions): DbHookMethodDecorator<E, Ph> {\n return (_prototype, method, descriptor) => {\n const handler = descriptor.value!;\n append(\n handler,\n tokens.DB_HOOK_METADATA,\n Object.freeze({\n phase,\n target,\n options: Object.freeze({ ...options }),\n method,\n handler,\n declarationOrder: readHookMetadata(handler).databaseHooks.length,\n }),\n );\n };\n}\nexport const BeforeDatabase = <E extends DatabaseHookTarget>(\n target: E,\n options?: DbHookOptions,\n): DbHookMethodDecorator<E, \"before\"> =>\n databaseHook(\"before\", target, options);\nexport const AfterDatabase = <E extends DatabaseHookTarget>(\n target: E,\n options?: DbHookOptions,\n): DbHookMethodDecorator<E, \"after\"> => databaseHook(\"after\", target, options);\n"],"mappings":";;;;;;;;AAuCA,MAAM,WAAW,OAAO,IAAI,sCAAsC;AAClE,SAAgB,QACd,UACA,GAAG,QACK;CACR,OAAO,KAAK,UAAU,CAAC,UAAU,GAAG,MAAM,CAAC;AAC7C;;AAGA,SAAgB,eACd,KACA,SACa;CACb,MAAM,UAAU,SAAS,WAAW;CACpC,MAAM,YAAY,UAAU,QAAQ,SAAS,MAAM,KAAK,CAAC,CAAC,CAAC,KAAM;CACjE,IAAI,UAAU,QAAQ,IAAI,SAAS,QAAQ;CAG3C,IAAI,C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,SAAgB,iBAAiB,SAG/B;CACA,OAAO;EACL,OAAO,QAAQ,eAAA,iBAAA,eAAqC,OAAO,KAAK,CAAC;EACjE,eACE,QAAQ,eAAA,iBAAA,kBAAwC,OAAO,KAAK,CAAC;CACjE;AACF;AACA,SAAS,KACP,OACA,OACA,SACwB;CACxB,QAAQ,SAAS,QAAQ,eAAe;EACtC,MAAM,UAAU,WAAW;EAC3B,MAAM,UAAU,iBAAiB,OAAO,CAAC,CAAC;EAC1C,OACE,SAAA,iBAAA,eAEA,OAAO,OAAO;GACZ;GACA,OAAO,MAAM,QAAQ,KAAK,IAAI,OAAO,OAAO,CAAC,GAAG,KAAK,CAAC,IAAI;GAC1D,SAAS,OAAO,OAAO,EAAE,GAAG,QAAQ,CAAC;GACrC;GACA;GACA,kBAAkB,QAAQ;EAC5B,CAAC,CACH;CACF;AACF;AACA,MAAa,cACX,OACA,YAC2B,KAAK,UAAU,OAAO,OAAO;AAC1D,MAAa,aACX,OACA,YAC2B,KAAK,SAAS,OAAO,OAAO;AACzD,SAAS,aAGP,OAAW,QAAW,SAAuD;CAC7E,QAAQ,YAAY,QAAQ,eAAe;EACzC,MAAM,UAAU,WAAW;EAC3B,OACE,SAAA,iBAAA,kBAEA,OAAO,OAAO;GACZ;GACA;GACA,SAAS,OAAO,OAAO,EAAE,GAAG,QAAQ,CAAC;GACrC;GACA;GACA,kBAAkB,iBAAiB,OAAO,CAAC,CAAC,cAAc;EAC5D,CAAC,CACH;CACF;AACF;AACA,MAAa,kBACX,QACA,YAEA,aAAa,UAAU,QAAQ,OAAO;AACxC,MAAa,iBACX,QACA,YACsC,aAAa,SAAS,QAAQ,OAAO"}
@@ -1,7 +1,7 @@
1
1
  import { c as isConfigurationError, n as BetterAuthConfigurationError, t as AuthFailures } from "./auth-errors-B6jLBpQu.mjs";
2
- import { C as READER_CONTEXT, M as USE_BETTER_AUTH_METADATA, O as SKIP_DEFAULT_REQUIREMENTS_METADATA, T as REQUIREMENTS_METADATA, a as ACCESS_METADATA, b as PRINCIPAL_PARAMS_METADATA, c as DB_HOOK_METADATA, f as HOOK_METADATA, h as INVOCATION_VALUES, i as ACCEPT_PRINCIPALS_METADATA, k as SKIP_ORIGIN_CHECK_METADATA, l as FORWARD_COOKIES_METADATA, m as INVOCATION_PARAMS_METADATA, s as AUTH_INSTANCE_METADATA, u as FRESHNESS_METADATA } from "./decorate-YZjmlv7t.mjs";
3
- import { t as BetterAuthScopeInterceptor } from "./auth-scope-interceptor-ctnmljij.mjs";
4
- import { t as BetterAuthGuard } from "./auth-guard-D4tzhp9u.mjs";
2
+ import { C as READER_CONTEXT, M as USE_BETTER_AUTH_METADATA, O as SKIP_DEFAULT_REQUIREMENTS_METADATA, T as REQUIREMENTS_METADATA, a as ACCESS_METADATA, b as PRINCIPAL_PARAMS_METADATA, c as DB_HOOK_METADATA, f as HOOK_METADATA, h as INVOCATION_VALUES, i as ACCEPT_PRINCIPALS_METADATA, k as SKIP_ORIGIN_CHECK_METADATA, l as FORWARD_COOKIES_METADATA, m as INVOCATION_PARAMS_METADATA, s as AUTH_INSTANCE_METADATA, u as FRESHNESS_METADATA } from "./decorate-DqI1OKmL.mjs";
3
+ import { t as BetterAuthScopeInterceptor } from "./auth-scope-interceptor-C0NRu4uy.mjs";
4
+ import { t as BetterAuthGuard } from "./auth-guard-CXsQR7Zd.mjs";
5
5
  import { t as PrincipalReadings } from "./principal-readings-O66hlCdW.mjs";
6
6
  import { SetMetadata, UseGuards, UseInterceptors, applyDecorators, createParamDecorator } from "@nestjs/common";
7
7
  import { AsyncLocalStorage } from "node:async_hooks";
@@ -274,4 +274,4 @@ const AfterDatabase = (target, options) => databaseHook("after", target, options
274
274
  //#endregion
275
275
  export { memoKey as C, RequestScope as S, anyOf as _, BeforeDatabase as a, readHookMetadata as b, OptionalAuth as c, RequireAuth as d, SkipDefaultRequirements as f, allOf as g, UseBetterAuth as h, BeforeAuth as i, Public as l, UseAuthInstance as m, AfterAuth as n, CurrentPrincipal as o, SkipOriginCheck as p, AfterDatabase as r, ForwardAuthCookies as s, AcceptPrincipals as t, Require as u, defineInvocationParam as v, requirement as x, definePrincipalParam as y };
276
276
 
277
- //# sourceMappingURL=auth-decorators-DUmQ-n_w.mjs.map
277
+ //# sourceMappingURL=auth-decorators-CQYu3gaF.mjs.map