@nestjs-kit/better-auth 2.1.0 → 2.1.2

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 (133) hide show
  1. package/README.md +3 -3
  2. package/dist/admin.cjs +3 -4
  3. package/dist/admin.d.cts +1 -3
  4. package/dist/admin.d.cts.map +1 -1
  5. package/dist/admin.d.mts +1 -3
  6. package/dist/admin.d.mts.map +1 -1
  7. package/dist/admin.mjs +3 -4
  8. package/dist/api-key.cjs +4 -5
  9. package/dist/api-key.d.cts +1 -3
  10. package/dist/api-key.d.cts.map +1 -1
  11. package/dist/api-key.d.mts +1 -3
  12. package/dist/api-key.d.mts.map +1 -1
  13. package/dist/api-key.mjs +4 -5
  14. package/dist/{auth-contracts-Brh_Qko9.d.cts → auth-contracts-CADGyI0O.d.mts} +3 -53
  15. package/dist/auth-contracts-CADGyI0O.d.mts.map +1 -0
  16. package/dist/{auth-contracts-Cz7C4_Ch.d.mts → auth-contracts-zvt8ysoZ.d.cts} +3 -53
  17. package/dist/auth-contracts-zvt8ysoZ.d.cts.map +1 -0
  18. package/dist/{auth-decorators-Cu_nxWnF.cjs → auth-decorators-CJKE9wlT.cjs} +8 -10
  19. package/dist/{auth-decorators-Cu_nxWnF.cjs.map → auth-decorators-CJKE9wlT.cjs.map} +1 -1
  20. package/dist/{auth-decorators-B1mFnGJ6.mjs → auth-decorators-CkNkLNpU.mjs} +8 -10
  21. package/dist/{auth-decorators-B1mFnGJ6.mjs.map → auth-decorators-CkNkLNpU.mjs.map} +1 -1
  22. package/dist/{auth-errors-C3rbTV9p.mjs → auth-errors-JjxGDVSt.mjs} +3 -5
  23. package/dist/{auth-errors-C3rbTV9p.mjs.map → auth-errors-JjxGDVSt.mjs.map} +1 -1
  24. package/dist/{auth-errors-DmiKl0L_.cjs → auth-errors-RW7hOVI-.cjs} +3 -5
  25. package/dist/{auth-errors-DmiKl0L_.cjs.map → auth-errors-RW7hOVI-.cjs.map} +1 -1
  26. package/dist/{auth-guard-h9QB_l11.mjs → auth-guard-Da92QEK5.mjs} +4 -5
  27. package/dist/{auth-guard-h9QB_l11.mjs.map → auth-guard-Da92QEK5.mjs.map} +1 -1
  28. package/dist/{auth-guard-CLyhAEEj.cjs → auth-guard-wapEh_M_.cjs} +4 -5
  29. package/dist/{auth-guard-CLyhAEEj.cjs.map → auth-guard-wapEh_M_.cjs.map} +1 -1
  30. package/dist/{auth-module-BgcY2HpA.cjs → auth-module-ab60-WJZ.cjs} +28 -47
  31. package/dist/auth-module-ab60-WJZ.cjs.map +1 -0
  32. package/dist/{auth-module-CtHx3gRU.mjs → auth-module-uy3BBWwR.mjs} +28 -47
  33. package/dist/auth-module-uy3BBWwR.mjs.map +1 -0
  34. package/dist/{auth-scope-interceptor-BjxAL1-S.cjs → auth-scope-interceptor-Bui20-Ps.cjs} +5 -7
  35. package/dist/{auth-scope-interceptor-BjxAL1-S.cjs.map → auth-scope-interceptor-Bui20-Ps.cjs.map} +1 -1
  36. package/dist/{auth-scope-interceptor-DYPn3b8M.mjs → auth-scope-interceptor-CvCQ52dV.mjs} +5 -7
  37. package/dist/{auth-scope-interceptor-DYPn3b8M.mjs.map → auth-scope-interceptor-CvCQ52dV.mjs.map} +1 -1
  38. package/dist/{bridge-protocol-c66aEkr5.mjs → bridge-protocol-CmRsff2P.mjs} +2 -3
  39. package/dist/{bridge-protocol-BDw8opAG.cjs.map → bridge-protocol-CmRsff2P.mjs.map} +1 -1
  40. package/dist/{bridge-protocol-BDw8opAG.cjs → bridge-protocol-DNFhIKdo.cjs} +2 -3
  41. package/dist/{bridge-protocol-c66aEkr5.mjs.map → bridge-protocol-DNFhIKdo.cjs.map} +1 -1
  42. package/dist/{decorate-Dt0e9K6R.mjs → decorate-bO-rBn-G.mjs} +5 -9
  43. package/dist/{decorate-Dt0e9K6R.mjs.map → decorate-bO-rBn-G.mjs.map} +1 -1
  44. package/dist/{decorate-Cr4Q7bNE.cjs → decorate-fMNf0caZ.cjs} +5 -9
  45. package/dist/{decorate-Cr4Q7bNE.cjs.map → decorate-fMNf0caZ.cjs.map} +1 -1
  46. package/dist/express.cjs +3 -4
  47. package/dist/express.d.cts +1 -3
  48. package/dist/express.d.cts.map +1 -1
  49. package/dist/express.d.mts +1 -3
  50. package/dist/express.d.mts.map +1 -1
  51. package/dist/express.mjs +3 -4
  52. package/dist/fastify.cjs +2 -3
  53. package/dist/fastify.d.cts +1 -3
  54. package/dist/fastify.d.cts.map +1 -1
  55. package/dist/fastify.d.mts +1 -3
  56. package/dist/fastify.d.mts.map +1 -1
  57. package/dist/fastify.mjs +2 -3
  58. package/dist/graphql.cjs +7 -9
  59. package/dist/graphql.cjs.map +1 -1
  60. package/dist/graphql.d.cts +1 -3
  61. package/dist/graphql.d.cts.map +1 -1
  62. package/dist/graphql.d.mts +1 -3
  63. package/dist/graphql.d.mts.map +1 -1
  64. package/dist/graphql.mjs +7 -9
  65. package/dist/graphql.mjs.map +1 -1
  66. package/dist/index.cjs +7 -7
  67. package/dist/index.d.cts +1 -1
  68. package/dist/index.d.mts +1 -1
  69. package/dist/index.mjs +7 -7
  70. package/dist/microservices.cjs +4 -6
  71. package/dist/microservices.cjs.map +1 -1
  72. package/dist/microservices.d.cts +1 -5
  73. package/dist/microservices.d.cts.map +1 -1
  74. package/dist/microservices.d.mts +1 -5
  75. package/dist/microservices.d.mts.map +1 -1
  76. package/dist/microservices.mjs +3 -5
  77. package/dist/microservices.mjs.map +1 -1
  78. package/dist/organization.cjs +3 -4
  79. package/dist/organization.d.cts +1 -3
  80. package/dist/organization.d.cts.map +1 -1
  81. package/dist/organization.d.mts +1 -3
  82. package/dist/organization.d.mts.map +1 -1
  83. package/dist/organization.mjs +3 -4
  84. package/dist/{platform-CZl7TY8j.mjs → platform-BKYVzAv1.mjs} +3 -5
  85. package/dist/{platform-CZl7TY8j.mjs.map → platform-BKYVzAv1.mjs.map} +1 -1
  86. package/dist/{platform-YICqqYv6.cjs → platform-C67dxSls.cjs} +3 -5
  87. package/dist/{platform-YICqqYv6.cjs.map → platform-C67dxSls.cjs.map} +1 -1
  88. package/dist/platform.cjs +1 -1
  89. package/dist/platform.d.cts +0 -2
  90. package/dist/platform.d.cts.map +1 -1
  91. package/dist/platform.d.mts +0 -2
  92. package/dist/platform.d.mts.map +1 -1
  93. package/dist/platform.mjs +1 -1
  94. package/dist/plugin.cjs +4 -8
  95. package/dist/plugin.cjs.map +1 -1
  96. package/dist/plugin.d.cts +0 -4
  97. package/dist/plugin.d.cts.map +1 -1
  98. package/dist/plugin.d.mts +0 -4
  99. package/dist/plugin.d.mts.map +1 -1
  100. package/dist/plugin.mjs +4 -8
  101. package/dist/plugin.mjs.map +1 -1
  102. package/dist/{principal-readings-Ied2staw.mjs → principal-readings-BuXTU0-2.mjs} +3 -4
  103. package/dist/{principal-readings-Ied2staw.mjs.map → principal-readings-BuXTU0-2.mjs.map} +1 -1
  104. package/dist/{principal-readings-Chmt6rQV.cjs → principal-readings-JLNT58k0.cjs} +3 -4
  105. package/dist/{principal-readings-Chmt6rQV.cjs.map → principal-readings-JLNT58k0.cjs.map} +1 -1
  106. package/dist/{rolldown-runtime-VH7oDXx4.cjs → rolldown-runtime-CmQyd0Gu.cjs} +1 -2
  107. package/dist/testing/conformance.cjs +24 -31
  108. package/dist/testing/conformance.cjs.map +1 -1
  109. package/dist/testing/conformance.d.cts +4 -14
  110. package/dist/testing/conformance.d.cts.map +1 -1
  111. package/dist/testing/conformance.d.mts +4 -14
  112. package/dist/testing/conformance.d.mts.map +1 -1
  113. package/dist/testing/conformance.mjs +23 -30
  114. package/dist/testing/conformance.mjs.map +1 -1
  115. package/dist/testing.cjs +6 -7
  116. package/dist/testing.d.cts +1 -3
  117. package/dist/testing.d.cts.map +1 -1
  118. package/dist/testing.d.mts +1 -3
  119. package/dist/testing.d.mts.map +1 -1
  120. package/dist/testing.mjs +6 -7
  121. package/dist/websockets.cjs +7 -10
  122. package/dist/websockets.cjs.map +1 -1
  123. package/dist/websockets.d.cts +1 -7
  124. package/dist/websockets.d.cts.map +1 -1
  125. package/dist/websockets.d.mts +1 -7
  126. package/dist/websockets.d.mts.map +1 -1
  127. package/dist/websockets.mjs +7 -10
  128. package/dist/websockets.mjs.map +1 -1
  129. package/package.json +24 -24
  130. package/dist/auth-contracts-Brh_Qko9.d.cts.map +0 -1
  131. package/dist/auth-contracts-Cz7C4_Ch.d.mts.map +0 -1
  132. package/dist/auth-module-BgcY2HpA.cjs.map +0 -1
  133. package/dist/auth-module-CtHx3gRU.mjs.map +0 -1
@@ -1,8 +1,8 @@
1
- const require_auth_errors = require("./auth-errors-DmiKl0L_.cjs");
2
- const require_decorate = require("./decorate-Cr4Q7bNE.cjs");
1
+ const require_decorate = require("./decorate-fMNf0caZ.cjs");
2
+ const require_auth_errors = require("./auth-errors-RW7hOVI-.cjs");
3
3
  let _nestjs_common = require("@nestjs/common");
4
4
  let rxjs = require("rxjs");
5
- //#region src/principal-resolver.ts
5
+ // src/principal-resolver.ts
6
6
  const definePrincipalSource = (source) => source;
7
7
  const authenticated = (principal) => ({
8
8
  outcome: "authenticated",
@@ -118,8 +118,7 @@ var ChainPrincipalResolver = class {
118
118
  }, compute);
119
119
  }
120
120
  };
121
- //#endregion
122
- //#region src/auth-scope-interceptor.ts
121
+ // src/auth-scope-interceptor.ts
123
122
  let BetterAuthScopeInterceptor = class BetterAuthScopeInterceptor {
124
123
  core;
125
124
  static [require_decorate.AUTH_ENHANCER] = "scope";
@@ -225,7 +224,6 @@ var ScopeCore = class {
225
224
  }));
226
225
  }
227
226
  };
228
- //#endregion
229
227
  Object.defineProperty(exports, "BetterAuthScopeInterceptor", {
230
228
  enumerable: true,
231
229
  get: function() {
@@ -287,4 +285,4 @@ Object.defineProperty(exports, "requestHeaders", {
287
285
  }
288
286
  });
289
287
 
290
- //# sourceMappingURL=auth-scope-interceptor-BjxAL1-S.cjs.map
288
+ //# sourceMappingURL=auth-scope-interceptor-Bui20-Ps.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"auth-scope-interceptor-BjxAL1-S.cjs","names":["normalizeThrown","isConfigurationError","isInfrastructureError","redactForRequest","createInfrastructureError","isAuthFailure","AUTH_ENHANCER","Injectable","Inject","SCOPE_CORE","READER_CONTEXT","Observable"],"sources":["../src/principal-resolver.ts","../src/auth-scope-interceptor.ts"],"sourcesContent":["import type {\n AuthPrincipalBase,\n PrincipalResolver,\n PrincipalResult,\n PrincipalSource,\n ResolutionRequest,\n TransportCall,\n} from \"./auth-contracts.js\";\nimport {\n type AuthFailure,\n isAuthFailure,\n normalizeThrown,\n createInfrastructureError,\n isConfigurationError,\n isInfrastructureError,\n redactForRequest,\n} from \"./auth-errors.js\";\nimport type { InstanceEntry, InstanceLookup } from \"./instance-registry.js\";\nimport type { TransportRegistry } from \"./transport-registry.js\";\nimport type { RequestScope } from \"./request-scope.js\";\n\nexport const definePrincipalSource = <P extends AuthPrincipalBase>(\n source: PrincipalSource<P>,\n): PrincipalSource<P> => source;\nexport const authenticated = <P extends AuthPrincipalBase>(\n principal: P,\n): PrincipalResult<P> => ({ outcome: \"authenticated\", principal });\nexport const absent = (): PrincipalResult<never> => ({ outcome: \"absent\" });\nexport const rejected = (failure: AuthFailure): PrincipalResult<never> => ({\n outcome: \"rejected\",\n failure,\n});\n\nexport class MemoKeys {\n private readonly owners = new WeakMap<\n object,\n {\n objects: WeakMap<object, number>;\n symbols: Map<symbol, number>;\n next: number;\n }\n >();\n\n key(\n owner: object,\n namespace: string,\n value: string | object | symbol,\n ): string {\n if (typeof value === \"string\") {\n return JSON.stringify([namespace, \"string\", value]);\n }\n let identities = this.owners.get(owner);\n if (!identities) {\n identities = { objects: new WeakMap(), symbols: new Map(), next: 0 };\n this.owners.set(owner, identities);\n }\n let id =\n typeof value === \"symbol\"\n ? identities.symbols.get(value)\n : identities.objects.get(value);\n if (id === undefined) {\n id = ++identities.next;\n if (typeof value === \"symbol\") {\n identities.symbols.set(value, id);\n } else {\n identities.objects.set(value, id);\n }\n }\n return JSON.stringify([namespace, typeof value, id]);\n }\n}\nexport function requestHeaders(\n call: TransportCall,\n entry: InstanceEntry,\n): Headers {\n const headers = new Headers(call.headers());\n for (const name of [...headers.keys()]) {\n if (\n name.startsWith(\":\") ||\n name.startsWith(\"x-nestjs-kit-better-auth-ip-\") ||\n name === entry.bridge.clientIpHeader\n ) {\n headers.delete(name);\n }\n }\n if (entry.bridge.clientIpHeader && call.clientIp) {\n headers.set(entry.bridge.clientIpHeader, call.clientIp);\n }\n return headers;\n}\nexport function normalizeForRequest(\n error: unknown,\n where: \"source\" | \"policy\",\n site: string,\n entry: InstanceEntry,\n headers: Headers,\n) {\n try {\n return normalizeThrown(error, where, site, [], entry.options.errors);\n } catch (normalized) {\n if (isConfigurationError(normalized)) {\n throw normalized;\n }\n if (isInfrastructureError(error) && normalized === error) {\n // A source or policy classified this failure itself, redacting only what it knew.\n throw redactForRequest(error, {\n headers,\n credentialHeaders: entry.credentialHeaders,\n exposeRawCause: entry.options.errors?.exposeRawCause,\n });\n }\n throw createInfrastructureError(error, {\n headers,\n credentialHeaders: entry.credentialHeaders,\n exposeRawCause: entry.options.errors?.exposeRawCause,\n });\n }\n}\nexport class ChainPrincipalResolver implements PrincipalResolver {\n private readonly keys = new MemoKeys();\n\n constructor(\n private readonly instances: InstanceLookup,\n private readonly scope: RequestScope,\n private readonly transports: TransportRegistry,\n ) {}\n\n resolve(\n call: TransportCall,\n request: ResolutionRequest,\n ): Promise<PrincipalResult> {\n const entry = this.instances.get(request.auth.name);\n const compute = async (): Promise<PrincipalResult> => {\n const headers = requestHeaders(call, entry);\n const sources = request.reclassify\n ? entry.sources.filter(\n (source) =>\n source.id === request.reclassify!.sourceId &&\n source.sessionBacked,\n )\n : entry.sources.filter((source) =>\n source.kinds.some((kind) => request.accepts.has(kind)),\n );\n return request.auth.run(\n {\n cookies: call.cookies,\n forward: \"same-credential\",\n inbound: () => headers,\n internal: true,\n },\n async () => {\n for (const source of sources) {\n const input = {\n headers,\n cookies: call.cookies,\n transport: this.transports.idOf(call),\n request: call.request,\n freshness: request.freshness,\n auth: request.auth,\n memo: <T>(\n key: string | object | symbol,\n fn: () => Promise<T>,\n ): Promise<T> =>\n this.scope.memoPolicyIo(\n call.key,\n entry.name,\n this.keys.key(call.key, `source:${source.id}`, key),\n fn,\n entry.options.limits?.maxAuthorizationCallsPerRequest,\n ),\n };\n try {\n if (source.appliesTo && !source.appliesTo(input)) {\n continue;\n }\n const result = await source.resolve(input);\n if (\n result.outcome === \"authenticated\" &&\n (!source.kinds.includes(result.principal.kind) ||\n result.principal.source !== source.id ||\n Boolean(result.principal.delegation) !==\n Boolean(source.delegates))\n ) {\n throw new Error(\n `Principal source ${source.id} violated its declared principal contract`,\n );\n }\n if (result.outcome !== \"absent\") {\n return result;\n }\n } catch (error) {\n const failure = normalizeForRequest(\n error,\n \"source\",\n source.id,\n entry,\n headers,\n );\n if (isAuthFailure(failure)) {\n return rejected(failure);\n }\n throw error;\n }\n }\n return absent();\n },\n );\n };\n return request.reclassify\n ? compute()\n : this.scope.memoPrincipal(\n call,\n {\n instance: entry.name,\n freshness: request.freshness,\n sourceSet: request.sourceSet,\n },\n compute,\n );\n }\n}\n","import {\n Inject,\n Injectable,\n type CallHandler,\n type ExecutionContext,\n type NestInterceptor,\n} from \"@nestjs/common\";\nimport { Observable } from \"rxjs\";\nimport type { PrincipalReading, TransportCall } from \"./auth-contracts.js\";\nimport { AUTH_ENHANCER, READER_CONTEXT, SCOPE_CORE } from \"./auth-tokens.js\";\nimport type { ScopeView } from \"./bridge-protocol.js\";\nimport type { InstanceLookup } from \"./instance-registry.js\";\nimport type { PrincipalReadings } from \"./principal-readings.js\";\nimport { requestHeaders } from \"./principal-resolver.js\";\nimport type { RequestScope, ScopeState } from \"./request-scope.js\";\nimport type { RoutePlanner } from \"./route-planner.js\";\nimport type { TransportRegistry } from \"./transport-registry.js\";\n\n@Injectable()\nexport class BetterAuthScopeInterceptor implements NestInterceptor {\n static readonly [AUTH_ENHANCER] = \"scope\";\n readonly [AUTH_ENHANCER] = \"scope\";\n\n constructor(\n @Inject(SCOPE_CORE) private readonly core: Pick<ScopeCore, \"intercept\">,\n ) {}\n\n intercept(context: ExecutionContext, next: CallHandler): Observable<unknown> {\n return this.core.intercept(context, next);\n }\n}\nexport class ScopeCore implements NestInterceptor {\n constructor(\n private readonly instances: InstanceLookup,\n private readonly planner: RoutePlanner,\n private readonly transports: TransportRegistry,\n private readonly scope: RequestScope,\n private readonly readings: PrincipalReadings,\n ) {}\n\n intercept(context: ExecutionContext, next: CallHandler): Observable<unknown> {\n const plan = this.planner.forContext(context);\n const entry = this.instances.get(plan.instance);\n let described = false;\n let call: TransportCall | undefined;\n const getCall = (): TransportCall | undefined => {\n if (!described) {\n const transport = this.transports.find(context);\n call = transport\n ? this.transports.describe(context, transport)\n : undefined;\n described = true;\n }\n return call;\n };\n let reading: PrincipalReading | undefined;\n const read = (): PrincipalReading => {\n if (reading) {\n return reading;\n }\n const lineage = this.transports.find(context)?.lineage?.(context);\n reading = this.readings.read({\n args: context.getArgs(),\n plan,\n lineage,\n ...(plan.access === \"public\" || plan.access === \"inherit\"\n ? {}\n : { call: getCall() }),\n });\n return reading;\n };\n const instances = this.instances;\n const view: ScopeView = {\n get cookies() {\n return getCall()?.cookies ?? null;\n },\n forward: plan.forwardDirectCalls ? \"same-credential\" : \"none\",\n internal: false,\n get inbound() {\n return () => {\n const call = getCall();\n return call ? requestHeaders(call, entry) : new Headers();\n };\n },\n get browserHeaders() {\n const browser = getCall()?.browser;\n return browser ? () => browser.headers() : undefined;\n },\n get checkCallerSession() {\n if (plan.originCheck === \"off\") {\n return undefined;\n }\n const browser = getCall()?.browser;\n return browser\n ? (path: string, instance: string) =>\n instances\n .get(instance)\n .origin.assertCallerSession(browser, path, instance)\n : undefined;\n },\n };\n const state: ScopeState = {\n view,\n plan,\n reading: read,\n get call() {\n return getCall();\n },\n };\n const args = context.getArgs();\n const bridge = {\n args: [...args],\n reading: read,\n scope: this.scope,\n readings: this.readings,\n };\n for (const arg of [args, ...args]) {\n if (\n arg &&\n (typeof arg === \"object\" || typeof arg === \"function\") &&\n Object.isExtensible(arg)\n ) {\n Object.defineProperty(arg, READER_CONTEXT, {\n value: bridge,\n configurable: true,\n });\n }\n }\n return new Observable((subscriber) =>\n this.scope.run(state, () => {\n const subscription = next.handle().subscribe({\n next: (value) => this.scope.run(state, () => subscriber.next(value)),\n error: (error) =>\n this.scope.run(state, () => subscriber.error(error)),\n complete: () => this.scope.run(state, () => subscriber.complete()),\n });\n return () => this.scope.run(state, () => subscription.unsubscribe());\n }),\n );\n }\n}\n"],"mappings":";;;;;AAqBA,MAAa,yBACX,WACuB;AACzB,MAAa,iBACX,eACwB;CAAE,SAAS;CAAiB;AAAU;AAChE,MAAa,gBAAwC,EAAE,SAAS,SAAS;AACzE,MAAa,YAAY,aAAkD;CACzE,SAAS;CACT;AACF;AAEA,IAAa,WAAb,MAAsB;CACpB,yBAA0B,IAAI,QAO5B;CAEF,IACE,OACA,WACA,OACQ;EACR,IAAI,OAAO,UAAU,UACnB,OAAO,KAAK,UAAU;GAAC;GAAW;GAAU;EAAK,CAAC;EAEpD,IAAI,aAAa,KAAK,OAAO,IAAI,KAAK;EACtC,IAAI,CAAC,YAAY;GACf,aAAa;IAAE,yBAAS,IAAI,QAAQ;IAAG,yBAAS,IAAI,IAAI;IAAG,MAAM;GAAE;GACnE,KAAK,OAAO,IAAI,OAAO,UAAU;EACnC;EACA,IAAI,KACF,OAAO,UAAU,WACb,WAAW,QAAQ,IAAI,KAAK,IAC5B,WAAW,QAAQ,IAAI,KAAK;EAClC,IAAI,OAAO,KAAA,GAAW;GACpB,KAAK,EAAE,WAAW;GAClB,IAAI,OAAO,UAAU,UACnB,WAAW,QAAQ,IAAI,OAAO,EAAE;QAEhC,WAAW,QAAQ,IAAI,OAAO,EAAE;EAEpC;EACA,OAAO,KAAK,UAAU;GAAC;GAAW,OAAO;GAAO;EAAE,CAAC;CACrD;AACF;AACA,SAAgB,eACd,MACA,OACS;CAC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 {"version":3,"file":"auth-scope-interceptor-Bui20-Ps.cjs","names":["normalizeThrown","isConfigurationError","isInfrastructureError","redactForRequest","createInfrastructureError","isAuthFailure","AUTH_ENHANCER","Injectable","Inject","SCOPE_CORE","READER_CONTEXT","Observable"],"sources":["../src/principal-resolver.ts","../src/auth-scope-interceptor.ts"],"sourcesContent":["import type {\n AuthPrincipalBase,\n PrincipalResolver,\n PrincipalResult,\n PrincipalSource,\n ResolutionRequest,\n TransportCall,\n} from \"./auth-contracts.js\";\nimport {\n type AuthFailure,\n isAuthFailure,\n normalizeThrown,\n createInfrastructureError,\n isConfigurationError,\n isInfrastructureError,\n redactForRequest,\n} from \"./auth-errors.js\";\nimport type { InstanceEntry, InstanceLookup } from \"./instance-registry.js\";\nimport type { TransportRegistry } from \"./transport-registry.js\";\nimport type { RequestScope } from \"./request-scope.js\";\n\nexport const definePrincipalSource = <P extends AuthPrincipalBase>(\n source: PrincipalSource<P>,\n): PrincipalSource<P> => source;\nexport const authenticated = <P extends AuthPrincipalBase>(\n principal: P,\n): PrincipalResult<P> => ({ outcome: \"authenticated\", principal });\nexport const absent = (): PrincipalResult<never> => ({ outcome: \"absent\" });\nexport const rejected = (failure: AuthFailure): PrincipalResult<never> => ({\n outcome: \"rejected\",\n failure,\n});\n\nexport class MemoKeys {\n private readonly owners = new WeakMap<\n object,\n {\n objects: WeakMap<object, number>;\n symbols: Map<symbol, number>;\n next: number;\n }\n >();\n\n key(\n owner: object,\n namespace: string,\n value: string | object | symbol,\n ): string {\n if (typeof value === \"string\") {\n return JSON.stringify([namespace, \"string\", value]);\n }\n let identities = this.owners.get(owner);\n if (!identities) {\n identities = { objects: new WeakMap(), symbols: new Map(), next: 0 };\n this.owners.set(owner, identities);\n }\n let id =\n typeof value === \"symbol\"\n ? identities.symbols.get(value)\n : identities.objects.get(value);\n if (id === undefined) {\n id = ++identities.next;\n if (typeof value === \"symbol\") {\n identities.symbols.set(value, id);\n } else {\n identities.objects.set(value, id);\n }\n }\n return JSON.stringify([namespace, typeof value, id]);\n }\n}\nexport function requestHeaders(\n call: TransportCall,\n entry: InstanceEntry,\n): Headers {\n const headers = new Headers(call.headers());\n for (const name of [...headers.keys()]) {\n if (\n name.startsWith(\":\") ||\n name.startsWith(\"x-nestjs-kit-better-auth-ip-\") ||\n name === entry.bridge.clientIpHeader\n ) {\n headers.delete(name);\n }\n }\n if (entry.bridge.clientIpHeader && call.clientIp) {\n headers.set(entry.bridge.clientIpHeader, call.clientIp);\n }\n return headers;\n}\nexport function normalizeForRequest(\n error: unknown,\n where: \"source\" | \"policy\",\n site: string,\n entry: InstanceEntry,\n headers: Headers,\n) {\n try {\n return normalizeThrown(error, where, site, [], entry.options.errors);\n } catch (normalized) {\n if (isConfigurationError(normalized)) {\n throw normalized;\n }\n if (isInfrastructureError(error) && normalized === error) {\n // A source or policy classified this failure itself, redacting only what it knew.\n throw redactForRequest(error, {\n headers,\n credentialHeaders: entry.credentialHeaders,\n exposeRawCause: entry.options.errors?.exposeRawCause,\n });\n }\n throw createInfrastructureError(error, {\n headers,\n credentialHeaders: entry.credentialHeaders,\n exposeRawCause: entry.options.errors?.exposeRawCause,\n });\n }\n}\nexport class ChainPrincipalResolver implements PrincipalResolver {\n private readonly keys = new MemoKeys();\n\n constructor(\n private readonly instances: InstanceLookup,\n private readonly scope: RequestScope,\n private readonly transports: TransportRegistry,\n ) {}\n\n resolve(\n call: TransportCall,\n request: ResolutionRequest,\n ): Promise<PrincipalResult> {\n const entry = this.instances.get(request.auth.name);\n const compute = async (): Promise<PrincipalResult> => {\n const headers = requestHeaders(call, entry);\n const sources = request.reclassify\n ? entry.sources.filter(\n (source) =>\n source.id === request.reclassify!.sourceId &&\n source.sessionBacked,\n )\n : entry.sources.filter((source) =>\n source.kinds.some((kind) => request.accepts.has(kind)),\n );\n return request.auth.run(\n {\n cookies: call.cookies,\n forward: \"same-credential\",\n inbound: () => headers,\n internal: true,\n },\n async () => {\n for (const source of sources) {\n const input = {\n headers,\n cookies: call.cookies,\n transport: this.transports.idOf(call),\n request: call.request,\n freshness: request.freshness,\n auth: request.auth,\n memo: <T>(\n key: string | object | symbol,\n fn: () => Promise<T>,\n ): Promise<T> =>\n this.scope.memoPolicyIo(\n call.key,\n entry.name,\n this.keys.key(call.key, `source:${source.id}`, key),\n fn,\n entry.options.limits?.maxAuthorizationCallsPerRequest,\n ),\n };\n try {\n if (source.appliesTo && !source.appliesTo(input)) {\n continue;\n }\n const result = await source.resolve(input);\n if (\n result.outcome === \"authenticated\" &&\n (!source.kinds.includes(result.principal.kind) ||\n result.principal.source !== source.id ||\n Boolean(result.principal.delegation) !==\n Boolean(source.delegates))\n ) {\n throw new Error(\n `Principal source ${source.id} violated its declared principal contract`,\n );\n }\n if (result.outcome !== \"absent\") {\n return result;\n }\n } catch (error) {\n const failure = normalizeForRequest(\n error,\n \"source\",\n source.id,\n entry,\n headers,\n );\n if (isAuthFailure(failure)) {\n return rejected(failure);\n }\n throw error;\n }\n }\n return absent();\n },\n );\n };\n return request.reclassify\n ? compute()\n : this.scope.memoPrincipal(\n call,\n {\n instance: entry.name,\n freshness: request.freshness,\n sourceSet: request.sourceSet,\n },\n compute,\n );\n }\n}\n","import {\n Inject,\n Injectable,\n type CallHandler,\n type ExecutionContext,\n type NestInterceptor,\n} from \"@nestjs/common\";\nimport { Observable } from \"rxjs\";\nimport type { PrincipalReading, TransportCall } from \"./auth-contracts.js\";\nimport { AUTH_ENHANCER, READER_CONTEXT, SCOPE_CORE } from \"./auth-tokens.js\";\nimport type { ScopeView } from \"./bridge-protocol.js\";\nimport type { InstanceLookup } from \"./instance-registry.js\";\nimport type { PrincipalReadings } from \"./principal-readings.js\";\nimport { requestHeaders } from \"./principal-resolver.js\";\nimport type { RequestScope, ScopeState } from \"./request-scope.js\";\nimport type { RoutePlanner } from \"./route-planner.js\";\nimport type { TransportRegistry } from \"./transport-registry.js\";\n\n@Injectable()\nexport class BetterAuthScopeInterceptor implements NestInterceptor {\n static readonly [AUTH_ENHANCER] = \"scope\";\n readonly [AUTH_ENHANCER] = \"scope\";\n\n constructor(\n @Inject(SCOPE_CORE) private readonly core: Pick<ScopeCore, \"intercept\">,\n ) {}\n\n intercept(context: ExecutionContext, next: CallHandler): Observable<unknown> {\n return this.core.intercept(context, next);\n }\n}\nexport class ScopeCore implements NestInterceptor {\n constructor(\n private readonly instances: InstanceLookup,\n private readonly planner: RoutePlanner,\n private readonly transports: TransportRegistry,\n private readonly scope: RequestScope,\n private readonly readings: PrincipalReadings,\n ) {}\n\n intercept(context: ExecutionContext, next: CallHandler): Observable<unknown> {\n const plan = this.planner.forContext(context);\n const entry = this.instances.get(plan.instance);\n let described = false;\n let call: TransportCall | undefined;\n const getCall = (): TransportCall | undefined => {\n if (!described) {\n const transport = this.transports.find(context);\n call = transport\n ? this.transports.describe(context, transport)\n : undefined;\n described = true;\n }\n return call;\n };\n let reading: PrincipalReading | undefined;\n const read = (): PrincipalReading => {\n if (reading) {\n return reading;\n }\n const lineage = this.transports.find(context)?.lineage?.(context);\n reading = this.readings.read({\n args: context.getArgs(),\n plan,\n lineage,\n ...(plan.access === \"public\" || plan.access === \"inherit\"\n ? {}\n : { call: getCall() }),\n });\n return reading;\n };\n const instances = this.instances;\n const view: ScopeView = {\n get cookies() {\n return getCall()?.cookies ?? null;\n },\n forward: plan.forwardDirectCalls ? \"same-credential\" : \"none\",\n internal: false,\n get inbound() {\n return () => {\n const call = getCall();\n return call ? requestHeaders(call, entry) : new Headers();\n };\n },\n get browserHeaders() {\n const browser = getCall()?.browser;\n return browser ? () => browser.headers() : undefined;\n },\n get checkCallerSession() {\n if (plan.originCheck === \"off\") {\n return undefined;\n }\n const browser = getCall()?.browser;\n return browser\n ? (path: string, instance: string) =>\n instances\n .get(instance)\n .origin.assertCallerSession(browser, path, instance)\n : undefined;\n },\n };\n const state: ScopeState = {\n view,\n plan,\n reading: read,\n get call() {\n return getCall();\n },\n };\n const args = context.getArgs();\n const bridge = {\n args: [...args],\n reading: read,\n scope: this.scope,\n readings: this.readings,\n };\n for (const arg of [args, ...args]) {\n if (\n arg &&\n (typeof arg === \"object\" || typeof arg === \"function\") &&\n Object.isExtensible(arg)\n ) {\n Object.defineProperty(arg, READER_CONTEXT, {\n value: bridge,\n configurable: true,\n });\n }\n }\n return new Observable((subscriber) =>\n this.scope.run(state, () => {\n const subscription = next.handle().subscribe({\n next: (value) => this.scope.run(state, () => subscriber.next(value)),\n error: (error) =>\n this.scope.run(state, () => subscriber.error(error)),\n complete: () => this.scope.run(state, () => subscriber.complete()),\n });\n return () => this.scope.run(state, () => subscription.unsubscribe());\n }),\n );\n }\n}\n"],"mappings":";;;;;AAqBA,MAAa,yBACX,WACuB;AACzB,MAAa,iBACX,eACwB;CAAE,SAAS;CAAiB;AAAU;AAChE,MAAa,gBAAwC,EAAE,SAAS,SAAS;AACzE,MAAa,YAAY,aAAkD;CACzE,SAAS;CACT;AACF;AAEA,IAAa,WAAb,MAAsB;CACpB,yBAA0B,IAAI,QAO5B;CAEF,IACE,OACA,WACA,OACQ;EACR,IAAI,OAAO,UAAU,UACnB,OAAO,KAAK,UAAU;GAAC;GAAW;GAAU;EAAK,CAAC;EAEpD,IAAI,aAAa,KAAK,OAAO,IAAI,KAAK;EACtC,IAAI,CAAC,YAAY;GACf,aAAa;IAAE,yBAAS,IAAI,QAAQ;IAAG,yBAAS,IAAI,IAAI;IAAG,MAAM;GAAE;GACnE,KAAK,OAAO,IAAI,OAAO,UAAU;EACnC;EACA,IAAI,KACF,OAAO,UAAU,WACb,WAAW,QAAQ,IAAI,KAAK,IAC5B,WAAW,QAAQ,IAAI,KAAK;EAClC,IAAI,OAAO,KAAA,GAAW;GACpB,KAAK,EAAE,WAAW;GAClB,IAAI,OAAO,UAAU,UACnB,WAAW,QAAQ,IAAI,OAAO,EAAE;QAEhC,WAAW,QAAQ,IAAI,OAAO,EAAE;EAEpC;EACA,OAAO,KAAK,UAAU;GAAC;GAAW,OAAO;GAAO;EAAE,CAAC;CACrD;AACF;AACA,SAAgB,eACd,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AACF"}
@@ -1,8 +1,8 @@
1
- import { c as isConfigurationError, d as redactForRequest, i as createInfrastructureError, l as isInfrastructureError, s as isAuthFailure, u as normalizeThrown } from "./auth-errors-C3rbTV9p.mjs";
2
- import { O as SCOPE_CORE, n as __decorateParam, r as __decorateMetadata, s as AUTH_ENHANCER, t as __decorate, w as READER_CONTEXT } from "./decorate-Dt0e9K6R.mjs";
1
+ import { O as SCOPE_CORE, n as __decorateParam, r as __decorateMetadata, s as AUTH_ENHANCER, t as __decorate, w as READER_CONTEXT } from "./decorate-bO-rBn-G.mjs";
2
+ import { c as isConfigurationError, d as redactForRequest, i as createInfrastructureError, l as isInfrastructureError, s as isAuthFailure, u as normalizeThrown } from "./auth-errors-JjxGDVSt.mjs";
3
3
  import { Inject, Injectable } from "@nestjs/common";
4
4
  import { Observable } from "rxjs";
5
- //#region src/principal-resolver.ts
5
+ // src/principal-resolver.ts
6
6
  const definePrincipalSource = (source) => source;
7
7
  const authenticated = (principal) => ({
8
8
  outcome: "authenticated",
@@ -118,8 +118,7 @@ var ChainPrincipalResolver = class {
118
118
  }, compute);
119
119
  }
120
120
  };
121
- //#endregion
122
- //#region src/auth-scope-interceptor.ts
121
+ // src/auth-scope-interceptor.ts
123
122
  let BetterAuthScopeInterceptor = class BetterAuthScopeInterceptor {
124
123
  core;
125
124
  static [AUTH_ENHANCER] = "scope";
@@ -225,7 +224,6 @@ var ScopeCore = class {
225
224
  }));
226
225
  }
227
226
  };
228
- //#endregion
229
227
  export { absent as a, normalizeForRequest as c, MemoKeys as i, rejected as l, ScopeCore as n, authenticated as o, ChainPrincipalResolver as r, definePrincipalSource as s, BetterAuthScopeInterceptor as t, requestHeaders as u };
230
228
 
231
- //# sourceMappingURL=auth-scope-interceptor-DYPn3b8M.mjs.map
229
+ //# sourceMappingURL=auth-scope-interceptor-CvCQ52dV.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"auth-scope-interceptor-DYPn3b8M.mjs","names":[],"sources":["../src/principal-resolver.ts","../src/auth-scope-interceptor.ts"],"sourcesContent":["import type {\n AuthPrincipalBase,\n PrincipalResolver,\n PrincipalResult,\n PrincipalSource,\n ResolutionRequest,\n TransportCall,\n} from \"./auth-contracts.js\";\nimport {\n type AuthFailure,\n isAuthFailure,\n normalizeThrown,\n createInfrastructureError,\n isConfigurationError,\n isInfrastructureError,\n redactForRequest,\n} from \"./auth-errors.js\";\nimport type { InstanceEntry, InstanceLookup } from \"./instance-registry.js\";\nimport type { TransportRegistry } from \"./transport-registry.js\";\nimport type { RequestScope } from \"./request-scope.js\";\n\nexport const definePrincipalSource = <P extends AuthPrincipalBase>(\n source: PrincipalSource<P>,\n): PrincipalSource<P> => source;\nexport const authenticated = <P extends AuthPrincipalBase>(\n principal: P,\n): PrincipalResult<P> => ({ outcome: \"authenticated\", principal });\nexport const absent = (): PrincipalResult<never> => ({ outcome: \"absent\" });\nexport const rejected = (failure: AuthFailure): PrincipalResult<never> => ({\n outcome: \"rejected\",\n failure,\n});\n\nexport class MemoKeys {\n private readonly owners = new WeakMap<\n object,\n {\n objects: WeakMap<object, number>;\n symbols: Map<symbol, number>;\n next: number;\n }\n >();\n\n key(\n owner: object,\n namespace: string,\n value: string | object | symbol,\n ): string {\n if (typeof value === \"string\") {\n return JSON.stringify([namespace, \"string\", value]);\n }\n let identities = this.owners.get(owner);\n if (!identities) {\n identities = { objects: new WeakMap(), symbols: new Map(), next: 0 };\n this.owners.set(owner, identities);\n }\n let id =\n typeof value === \"symbol\"\n ? identities.symbols.get(value)\n : identities.objects.get(value);\n if (id === undefined) {\n id = ++identities.next;\n if (typeof value === \"symbol\") {\n identities.symbols.set(value, id);\n } else {\n identities.objects.set(value, id);\n }\n }\n return JSON.stringify([namespace, typeof value, id]);\n }\n}\nexport function requestHeaders(\n call: TransportCall,\n entry: InstanceEntry,\n): Headers {\n const headers = new Headers(call.headers());\n for (const name of [...headers.keys()]) {\n if (\n name.startsWith(\":\") ||\n name.startsWith(\"x-nestjs-kit-better-auth-ip-\") ||\n name === entry.bridge.clientIpHeader\n ) {\n headers.delete(name);\n }\n }\n if (entry.bridge.clientIpHeader && call.clientIp) {\n headers.set(entry.bridge.clientIpHeader, call.clientIp);\n }\n return headers;\n}\nexport function normalizeForRequest(\n error: unknown,\n where: \"source\" | \"policy\",\n site: string,\n entry: InstanceEntry,\n headers: Headers,\n) {\n try {\n return normalizeThrown(error, where, site, [], entry.options.errors);\n } catch (normalized) {\n if (isConfigurationError(normalized)) {\n throw normalized;\n }\n if (isInfrastructureError(error) && normalized === error) {\n // A source or policy classified this failure itself, redacting only what it knew.\n throw redactForRequest(error, {\n headers,\n credentialHeaders: entry.credentialHeaders,\n exposeRawCause: entry.options.errors?.exposeRawCause,\n });\n }\n throw createInfrastructureError(error, {\n headers,\n credentialHeaders: entry.credentialHeaders,\n exposeRawCause: entry.options.errors?.exposeRawCause,\n });\n }\n}\nexport class ChainPrincipalResolver implements PrincipalResolver {\n private readonly keys = new MemoKeys();\n\n constructor(\n private readonly instances: InstanceLookup,\n private readonly scope: RequestScope,\n private readonly transports: TransportRegistry,\n ) {}\n\n resolve(\n call: TransportCall,\n request: ResolutionRequest,\n ): Promise<PrincipalResult> {\n const entry = this.instances.get(request.auth.name);\n const compute = async (): Promise<PrincipalResult> => {\n const headers = requestHeaders(call, entry);\n const sources = request.reclassify\n ? entry.sources.filter(\n (source) =>\n source.id === request.reclassify!.sourceId &&\n source.sessionBacked,\n )\n : entry.sources.filter((source) =>\n source.kinds.some((kind) => request.accepts.has(kind)),\n );\n return request.auth.run(\n {\n cookies: call.cookies,\n forward: \"same-credential\",\n inbound: () => headers,\n internal: true,\n },\n async () => {\n for (const source of sources) {\n const input = {\n headers,\n cookies: call.cookies,\n transport: this.transports.idOf(call),\n request: call.request,\n freshness: request.freshness,\n auth: request.auth,\n memo: <T>(\n key: string | object | symbol,\n fn: () => Promise<T>,\n ): Promise<T> =>\n this.scope.memoPolicyIo(\n call.key,\n entry.name,\n this.keys.key(call.key, `source:${source.id}`, key),\n fn,\n entry.options.limits?.maxAuthorizationCallsPerRequest,\n ),\n };\n try {\n if (source.appliesTo && !source.appliesTo(input)) {\n continue;\n }\n const result = await source.resolve(input);\n if (\n result.outcome === \"authenticated\" &&\n (!source.kinds.includes(result.principal.kind) ||\n result.principal.source !== source.id ||\n Boolean(result.principal.delegation) !==\n Boolean(source.delegates))\n ) {\n throw new Error(\n `Principal source ${source.id} violated its declared principal contract`,\n );\n }\n if (result.outcome !== \"absent\") {\n return result;\n }\n } catch (error) {\n const failure = normalizeForRequest(\n error,\n \"source\",\n source.id,\n entry,\n headers,\n );\n if (isAuthFailure(failure)) {\n return rejected(failure);\n }\n throw error;\n }\n }\n return absent();\n },\n );\n };\n return request.reclassify\n ? compute()\n : this.scope.memoPrincipal(\n call,\n {\n instance: entry.name,\n freshness: request.freshness,\n sourceSet: request.sourceSet,\n },\n compute,\n );\n }\n}\n","import {\n Inject,\n Injectable,\n type CallHandler,\n type ExecutionContext,\n type NestInterceptor,\n} from \"@nestjs/common\";\nimport { Observable } from \"rxjs\";\nimport type { PrincipalReading, TransportCall } from \"./auth-contracts.js\";\nimport { AUTH_ENHANCER, READER_CONTEXT, SCOPE_CORE } from \"./auth-tokens.js\";\nimport type { ScopeView } from \"./bridge-protocol.js\";\nimport type { InstanceLookup } from \"./instance-registry.js\";\nimport type { PrincipalReadings } from \"./principal-readings.js\";\nimport { requestHeaders } from \"./principal-resolver.js\";\nimport type { RequestScope, ScopeState } from \"./request-scope.js\";\nimport type { RoutePlanner } from \"./route-planner.js\";\nimport type { TransportRegistry } from \"./transport-registry.js\";\n\n@Injectable()\nexport class BetterAuthScopeInterceptor implements NestInterceptor {\n static readonly [AUTH_ENHANCER] = \"scope\";\n readonly [AUTH_ENHANCER] = \"scope\";\n\n constructor(\n @Inject(SCOPE_CORE) private readonly core: Pick<ScopeCore, \"intercept\">,\n ) {}\n\n intercept(context: ExecutionContext, next: CallHandler): Observable<unknown> {\n return this.core.intercept(context, next);\n }\n}\nexport class ScopeCore implements NestInterceptor {\n constructor(\n private readonly instances: InstanceLookup,\n private readonly planner: RoutePlanner,\n private readonly transports: TransportRegistry,\n private readonly scope: RequestScope,\n private readonly readings: PrincipalReadings,\n ) {}\n\n intercept(context: ExecutionContext, next: CallHandler): Observable<unknown> {\n const plan = this.planner.forContext(context);\n const entry = this.instances.get(plan.instance);\n let described = false;\n let call: TransportCall | undefined;\n const getCall = (): TransportCall | undefined => {\n if (!described) {\n const transport = this.transports.find(context);\n call = transport\n ? this.transports.describe(context, transport)\n : undefined;\n described = true;\n }\n return call;\n };\n let reading: PrincipalReading | undefined;\n const read = (): PrincipalReading => {\n if (reading) {\n return reading;\n }\n const lineage = this.transports.find(context)?.lineage?.(context);\n reading = this.readings.read({\n args: context.getArgs(),\n plan,\n lineage,\n ...(plan.access === \"public\" || plan.access === \"inherit\"\n ? {}\n : { call: getCall() }),\n });\n return reading;\n };\n const instances = this.instances;\n const view: ScopeView = {\n get cookies() {\n return getCall()?.cookies ?? null;\n },\n forward: plan.forwardDirectCalls ? \"same-credential\" : \"none\",\n internal: false,\n get inbound() {\n return () => {\n const call = getCall();\n return call ? requestHeaders(call, entry) : new Headers();\n };\n },\n get browserHeaders() {\n const browser = getCall()?.browser;\n return browser ? () => browser.headers() : undefined;\n },\n get checkCallerSession() {\n if (plan.originCheck === \"off\") {\n return undefined;\n }\n const browser = getCall()?.browser;\n return browser\n ? (path: string, instance: string) =>\n instances\n .get(instance)\n .origin.assertCallerSession(browser, path, instance)\n : undefined;\n },\n };\n const state: ScopeState = {\n view,\n plan,\n reading: read,\n get call() {\n return getCall();\n },\n };\n const args = context.getArgs();\n const bridge = {\n args: [...args],\n reading: read,\n scope: this.scope,\n readings: this.readings,\n };\n for (const arg of [args, ...args]) {\n if (\n arg &&\n (typeof arg === \"object\" || typeof arg === \"function\") &&\n Object.isExtensible(arg)\n ) {\n Object.defineProperty(arg, READER_CONTEXT, {\n value: bridge,\n configurable: true,\n });\n }\n }\n return new Observable((subscriber) =>\n this.scope.run(state, () => {\n const subscription = next.handle().subscribe({\n next: (value) => this.scope.run(state, () => subscriber.next(value)),\n error: (error) =>\n this.scope.run(state, () => subscriber.error(error)),\n complete: () => this.scope.run(state, () => subscriber.complete()),\n });\n return () => this.scope.run(state, () => subscription.unsubscribe());\n }),\n );\n }\n}\n"],"mappings":";;;;;AAqBA,MAAa,yBACX,WACuB;AACzB,MAAa,iBACX,eACwB;CAAE,SAAS;CAAiB;AAAU;AAChE,MAAa,gBAAwC,EAAE,SAAS,SAAS;AACzE,MAAa,YAAY,aAAkD;CACzE,SAAS;CACT;AACF;AAEA,IAAa,WAAb,MAAsB;CACpB,yBAA0B,IAAI,QAO5B;CAEF,IACE,OACA,WACA,OACQ;EACR,IAAI,OAAO,UAAU,UACnB,OAAO,KAAK,UAAU;GAAC;GAAW;GAAU;EAAK,CAAC;EAEpD,IAAI,aAAa,KAAK,OAAO,IAAI,KAAK;EACtC,IAAI,CAAC,YAAY;GACf,aAAa;IAAE,yBAAS,IAAI,QAAQ;IAAG,yBAAS,IAAI,IAAI;IAAG,MAAM;GAAE;GACnE,KAAK,OAAO,IAAI,OAAO,UAAU;EACnC;EACA,IAAI,KACF,OAAO,UAAU,WACb,WAAW,QAAQ,IAAI,KAAK,IAC5B,WAAW,QAAQ,IAAI,KAAK;EAClC,IAAI,OAAO,KAAA,GAAW;GACpB,KAAK,EAAE,WAAW;GAClB,IAAI,OAAO,UAAU,UACnB,WAAW,QAAQ,IAAI,OAAO,EAAE;QAEhC,WAAW,QAAQ,IAAI,OAAO,EAAE;EAEpC;EACA,OAAO,KAAK,UAAU;GAAC;GAAW,OAAO;GAAO;EAAE,CAAC;CACrD;AACF;AACA,SAAgB,eACd,MACA,OACS;CACT,MAAM,UAAU,IAAI,QAAQ,KAAK,QAAQ,CAAC;CAC1C,KAAK,MAAM,QAAQ,CAAC,GAAG,QAAQ,KAAK,CAAC,GACnC,IACE,KAAK,WAAW,GAAG,KACnB,KAAK,WAAW,8BAA8B,KAC9C,S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,CAAC,EAAE;KAC3B,OAAO,WACF,MAAc,aACb,UACG,IAAI,QAAQ,CAAC,CACb,OAAO,oBAAoB,SAAS,MAAM,QAAQ,IACvD,KAAA;IACN;GAGG;GACH;GACA,SAAS;GACT,IAAI,OAAO;IACT,OAAO,QAAQ;GACjB;EACF;EACA,MAAM,OAAO,QAAQ,QAAQ;EAC7B,MAAM,SAAS;GACb,MAAM,CAAC,GAAG,IAAI;GACd,SAAS;GACT,OAAO,KAAK;GACZ,UAAU,KAAK;EACjB;EACA,KAAK,MAAM,OAAO,CAAC,MAAM,GAAG,IAAI,GAC9B,IACE,QACC,OAAO,QAAQ,YAAY,OAAO,QAAQ,eAC3C,OAAO,aAAa,GAAG,GAEvB,OAAO,eAAe,KAAK,gBAAgB;GACzC,OAAO;GACP,cAAc;EAChB,CAAC;EAGL,OAAO,IAAI,YAAY,eACrB,KAAK,MAAM,IAAI,aAAa;GAC1B,MAAM,eAAe,KAAK,OAAO,CAAC,CAAC,UAAU;IAC3C,OAAO,UAAU,KAAK,MAAM,IAAI,aAAa,WAAW,KAAK,KAAK,CAAC;IACnE,QAAQ,UACN,KAAK,MAAM,IAAI,aAAa,WAAW,MAAM,KAAK,CAAC;IACrD,gBAAgB,KAAK,MAAM,IAAI,aAAa,WAAW,SAAS,CAAC;GACnE,CAAC;GACD,aAAa,KAAK,MAAM,IAAI,aAAa,aAAa,YAAY,CAAC;EACrE,CAAC,CACH;CACF;AACF"}
1
+ {"version":3,"file":"auth-scope-interceptor-CvCQ52dV.mjs","names":[],"sources":["../src/principal-resolver.ts","../src/auth-scope-interceptor.ts"],"sourcesContent":["import type {\n AuthPrincipalBase,\n PrincipalResolver,\n PrincipalResult,\n PrincipalSource,\n ResolutionRequest,\n TransportCall,\n} from \"./auth-contracts.js\";\nimport {\n type AuthFailure,\n isAuthFailure,\n normalizeThrown,\n createInfrastructureError,\n isConfigurationError,\n isInfrastructureError,\n redactForRequest,\n} from \"./auth-errors.js\";\nimport type { InstanceEntry, InstanceLookup } from \"./instance-registry.js\";\nimport type { TransportRegistry } from \"./transport-registry.js\";\nimport type { RequestScope } from \"./request-scope.js\";\n\nexport const definePrincipalSource = <P extends AuthPrincipalBase>(\n source: PrincipalSource<P>,\n): PrincipalSource<P> => source;\nexport const authenticated = <P extends AuthPrincipalBase>(\n principal: P,\n): PrincipalResult<P> => ({ outcome: \"authenticated\", principal });\nexport const absent = (): PrincipalResult<never> => ({ outcome: \"absent\" });\nexport const rejected = (failure: AuthFailure): PrincipalResult<never> => ({\n outcome: \"rejected\",\n failure,\n});\n\nexport class MemoKeys {\n private readonly owners = new WeakMap<\n object,\n {\n objects: WeakMap<object, number>;\n symbols: Map<symbol, number>;\n next: number;\n }\n >();\n\n key(\n owner: object,\n namespace: string,\n value: string | object | symbol,\n ): string {\n if (typeof value === \"string\") {\n return JSON.stringify([namespace, \"string\", value]);\n }\n let identities = this.owners.get(owner);\n if (!identities) {\n identities = { objects: new WeakMap(), symbols: new Map(), next: 0 };\n this.owners.set(owner, identities);\n }\n let id =\n typeof value === \"symbol\"\n ? identities.symbols.get(value)\n : identities.objects.get(value);\n if (id === undefined) {\n id = ++identities.next;\n if (typeof value === \"symbol\") {\n identities.symbols.set(value, id);\n } else {\n identities.objects.set(value, id);\n }\n }\n return JSON.stringify([namespace, typeof value, id]);\n }\n}\nexport function requestHeaders(\n call: TransportCall,\n entry: InstanceEntry,\n): Headers {\n const headers = new Headers(call.headers());\n for (const name of [...headers.keys()]) {\n if (\n name.startsWith(\":\") ||\n name.startsWith(\"x-nestjs-kit-better-auth-ip-\") ||\n name === entry.bridge.clientIpHeader\n ) {\n headers.delete(name);\n }\n }\n if (entry.bridge.clientIpHeader && call.clientIp) {\n headers.set(entry.bridge.clientIpHeader, call.clientIp);\n }\n return headers;\n}\nexport function normalizeForRequest(\n error: unknown,\n where: \"source\" | \"policy\",\n site: string,\n entry: InstanceEntry,\n headers: Headers,\n) {\n try {\n return normalizeThrown(error, where, site, [], entry.options.errors);\n } catch (normalized) {\n if (isConfigurationError(normalized)) {\n throw normalized;\n }\n if (isInfrastructureError(error) && normalized === error) {\n // A source or policy classified this failure itself, redacting only what it knew.\n throw redactForRequest(error, {\n headers,\n credentialHeaders: entry.credentialHeaders,\n exposeRawCause: entry.options.errors?.exposeRawCause,\n });\n }\n throw createInfrastructureError(error, {\n headers,\n credentialHeaders: entry.credentialHeaders,\n exposeRawCause: entry.options.errors?.exposeRawCause,\n });\n }\n}\nexport class ChainPrincipalResolver implements PrincipalResolver {\n private readonly keys = new MemoKeys();\n\n constructor(\n private readonly instances: InstanceLookup,\n private readonly scope: RequestScope,\n private readonly transports: TransportRegistry,\n ) {}\n\n resolve(\n call: TransportCall,\n request: ResolutionRequest,\n ): Promise<PrincipalResult> {\n const entry = this.instances.get(request.auth.name);\n const compute = async (): Promise<PrincipalResult> => {\n const headers = requestHeaders(call, entry);\n const sources = request.reclassify\n ? entry.sources.filter(\n (source) =>\n source.id === request.reclassify!.sourceId &&\n source.sessionBacked,\n )\n : entry.sources.filter((source) =>\n source.kinds.some((kind) => request.accepts.has(kind)),\n );\n return request.auth.run(\n {\n cookies: call.cookies,\n forward: \"same-credential\",\n inbound: () => headers,\n internal: true,\n },\n async () => {\n for (const source of sources) {\n const input = {\n headers,\n cookies: call.cookies,\n transport: this.transports.idOf(call),\n request: call.request,\n freshness: request.freshness,\n auth: request.auth,\n memo: <T>(\n key: string | object | symbol,\n fn: () => Promise<T>,\n ): Promise<T> =>\n this.scope.memoPolicyIo(\n call.key,\n entry.name,\n this.keys.key(call.key, `source:${source.id}`, key),\n fn,\n entry.options.limits?.maxAuthorizationCallsPerRequest,\n ),\n };\n try {\n if (source.appliesTo && !source.appliesTo(input)) {\n continue;\n }\n const result = await source.resolve(input);\n if (\n result.outcome === \"authenticated\" &&\n (!source.kinds.includes(result.principal.kind) ||\n result.principal.source !== source.id ||\n Boolean(result.principal.delegation) !==\n Boolean(source.delegates))\n ) {\n throw new Error(\n `Principal source ${source.id} violated its declared principal contract`,\n );\n }\n if (result.outcome !== \"absent\") {\n return result;\n }\n } catch (error) {\n const failure = normalizeForRequest(\n error,\n \"source\",\n source.id,\n entry,\n headers,\n );\n if (isAuthFailure(failure)) {\n return rejected(failure);\n }\n throw error;\n }\n }\n return absent();\n },\n );\n };\n return request.reclassify\n ? compute()\n : this.scope.memoPrincipal(\n call,\n {\n instance: entry.name,\n freshness: request.freshness,\n sourceSet: request.sourceSet,\n },\n compute,\n );\n }\n}\n","import {\n Inject,\n Injectable,\n type CallHandler,\n type ExecutionContext,\n type NestInterceptor,\n} from \"@nestjs/common\";\nimport { Observable } from \"rxjs\";\nimport type { PrincipalReading, TransportCall } from \"./auth-contracts.js\";\nimport { AUTH_ENHANCER, READER_CONTEXT, SCOPE_CORE } from \"./auth-tokens.js\";\nimport type { ScopeView } from \"./bridge-protocol.js\";\nimport type { InstanceLookup } from \"./instance-registry.js\";\nimport type { PrincipalReadings } from \"./principal-readings.js\";\nimport { requestHeaders } from \"./principal-resolver.js\";\nimport type { RequestScope, ScopeState } from \"./request-scope.js\";\nimport type { RoutePlanner } from \"./route-planner.js\";\nimport type { TransportRegistry } from \"./transport-registry.js\";\n\n@Injectable()\nexport class BetterAuthScopeInterceptor implements NestInterceptor {\n static readonly [AUTH_ENHANCER] = \"scope\";\n readonly [AUTH_ENHANCER] = \"scope\";\n\n constructor(\n @Inject(SCOPE_CORE) private readonly core: Pick<ScopeCore, \"intercept\">,\n ) {}\n\n intercept(context: ExecutionContext, next: CallHandler): Observable<unknown> {\n return this.core.intercept(context, next);\n }\n}\nexport class ScopeCore implements NestInterceptor {\n constructor(\n private readonly instances: InstanceLookup,\n private readonly planner: RoutePlanner,\n private readonly transports: TransportRegistry,\n private readonly scope: RequestScope,\n private readonly readings: PrincipalReadings,\n ) {}\n\n intercept(context: ExecutionContext, next: CallHandler): Observable<unknown> {\n const plan = this.planner.forContext(context);\n const entry = this.instances.get(plan.instance);\n let described = false;\n let call: TransportCall | undefined;\n const getCall = (): TransportCall | undefined => {\n if (!described) {\n const transport = this.transports.find(context);\n call = transport\n ? this.transports.describe(context, transport)\n : undefined;\n described = true;\n }\n return call;\n };\n let reading: PrincipalReading | undefined;\n const read = (): PrincipalReading => {\n if (reading) {\n return reading;\n }\n const lineage = this.transports.find(context)?.lineage?.(context);\n reading = this.readings.read({\n args: context.getArgs(),\n plan,\n lineage,\n ...(plan.access === \"public\" || plan.access === \"inherit\"\n ? {}\n : { call: getCall() }),\n });\n return reading;\n };\n const instances = this.instances;\n const view: ScopeView = {\n get cookies() {\n return getCall()?.cookies ?? null;\n },\n forward: plan.forwardDirectCalls ? \"same-credential\" : \"none\",\n internal: false,\n get inbound() {\n return () => {\n const call = getCall();\n return call ? requestHeaders(call, entry) : new Headers();\n };\n },\n get browserHeaders() {\n const browser = getCall()?.browser;\n return browser ? () => browser.headers() : undefined;\n },\n get checkCallerSession() {\n if (plan.originCheck === \"off\") {\n return undefined;\n }\n const browser = getCall()?.browser;\n return browser\n ? (path: string, instance: string) =>\n instances\n .get(instance)\n .origin.assertCallerSession(browser, path, instance)\n : undefined;\n },\n };\n const state: ScopeState = {\n view,\n plan,\n reading: read,\n get call() {\n return getCall();\n },\n };\n const args = context.getArgs();\n const bridge = {\n args: [...args],\n reading: read,\n scope: this.scope,\n readings: this.readings,\n };\n for (const arg of [args, ...args]) {\n if (\n arg &&\n (typeof arg === \"object\" || typeof arg === \"function\") &&\n Object.isExtensible(arg)\n ) {\n Object.defineProperty(arg, READER_CONTEXT, {\n value: bridge,\n configurable: true,\n });\n }\n }\n return new Observable((subscriber) =>\n this.scope.run(state, () => {\n const subscription = next.handle().subscribe({\n next: (value) => this.scope.run(state, () => subscriber.next(value)),\n error: (error) =>\n this.scope.run(state, () => subscriber.error(error)),\n complete: () => this.scope.run(state, () => subscriber.complete()),\n });\n return () => this.scope.run(state, () => subscription.unsubscribe());\n }),\n );\n }\n}\n"],"mappings":";;;;;AAqBA,MAAa,yBACX,WACuB;AACzB,MAAa,iBACX,eACwB;CAAE,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IAAI;GACd,SAAS;GACT,OAAO,KAAK;GACZ,UAAU,KAAK;EACjB;EACA,KAAK,MAAM,OAAO,CAAC,MAAM,GAAG,IAAI,GAC9B,IACE,QACC,OAAO,QAAQ,YAAY,OAAO,QAAQ,eAC3C,OAAO,aAAa,GAAG,GAEvB,OAAO,eAAe,KAAK,gBAAgB;GACzC,OAAO;GACP,cAAc;EAChB,CAAC;EAGL,OAAO,IAAI,YAAY,eACrB,KAAK,MAAM,IAAI,aAAa;GAC1B,MAAM,eAAe,KAAK,OAAO,CAAC,CAAC,UAAU;IAC3C,OAAO,UAAU,KAAK,MAAM,IAAI,aAAa,WAAW,KAAK,KAAK,CAAC;IACnE,QAAQ,UACN,KAAK,MAAM,IAAI,aAAa,WAAW,MAAM,KAAK,CAAC;IACrD,gBAAgB,KAAK,MAAM,IAAI,aAAa,WAAW,SAAS,CAAC;GACnE,CAAC;GACD,aAAa,KAAK,MAAM,IAAI,aAAa,aAAa,YAAY,CAAC;EACrE,CAAC,CACH;CACF;AACF"}
@@ -1,8 +1,7 @@
1
- //#region src/bridge-protocol.ts
1
+ // src/bridge-protocol.ts
2
2
  const BRIDGE_HANDLE = Symbol.for("@nestjs-kit/better-auth:bridge");
3
3
  const EXTENSION_DEFINITION = Symbol.for("@nestjs-kit/better-auth:extension");
4
4
  const UPGRADE_REQUEST = Symbol.for("@nestjs-kit/better-auth:upgrade-request");
5
- //#endregion
6
5
  export { EXTENSION_DEFINITION as n, UPGRADE_REQUEST as r, BRIDGE_HANDLE as t };
7
6
 
8
- //# sourceMappingURL=bridge-protocol-c66aEkr5.mjs.map
7
+ //# sourceMappingURL=bridge-protocol-CmRsff2P.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"bridge-protocol-BDw8opAG.cjs","names":[],"sources":["../src/bridge-protocol.ts"],"sourcesContent":["import type { HookEndpointContext } from \"better-auth\";\nimport type { CookieSink, DatabaseHookTarget } from \"./auth-contracts.js\";\nimport type { DatabaseHookMethod } from \"./auth-types.js\";\n\nexport const BRIDGE_HANDLE = Symbol.for(\"@nestjs-kit/better-auth:bridge\");\nexport const EXTENSION_DEFINITION = Symbol.for(\n \"@nestjs-kit/better-auth:extension\",\n);\nexport const UPGRADE_REQUEST = Symbol.for(\n \"@nestjs-kit/better-auth:upgrade-request\",\n);\n\nexport interface BridgeHandle {\n readonly protocol: 4; // checked by core (B04); v5: binding state and instance, the caller-session check\n readonly clientIpHeader: string | null; // single source of truth for the header name (§6.8)\n /** 'unbound' until the first bind(); 'bound' while an application's hooks are registered; 'closed' after its shutdown, hooks still registered. */\n readonly state: \"unbound\" | \"bound\" | \"closed\";\n /** Endpoint dispatches and database-hook dispatches (writes) seen before the first binding, reset by every bind() (B26). */\n readonly unboundDispatches: number;\n /**\n * Registers the application's hooks and returns close(), which the kernel calls in onApplicationShutdown: a closed binding keeps\n * dispatching until another application binds (§10.6). A second bind() from the same owner for the same instance is a no-op that\n * returns the existing registration (NestMicroservice.init() runs lifecycle hooks twice); from the same owner for another instance it\n * throws PLUGIN_SHARED_BETWEEN_INSTANCES (B03). Throws INSTANCE_ALREADY_BOUND if another bootstrapped application is bound; takes over\n * a never-bootstrapped one (reported, B06) and a closed one (silently). A never-bootstrapped binding it takes over becomes\n * 'displaced': an application whose init() was still running when another bound fails in onApplicationBootstrap (B06).\n */\n bind(binding: BridgeBinding): { close(): void; tookOverFrom?: string };\n /** true when an endpoint returned `value` (an object) in a non-router dispatch observed while bound; false for before-hook short-circuits (LEAD-V37). */\n producedByEndpoint(value: unknown): boolean;\n}\nexport interface BridgeBinding {\n /** The application: compared by identity for the same-owner no-op; `description` goes into the B06 message. */\n readonly owner: { readonly description: string };\n /** The instance this plugin object serves; one plugin object serves one instance (B03). */\n readonly instance: string;\n /**\n * 'initialized' at bind; the kernel sets 'bootstrapped' in onApplicationBootstrap; close() sets 'closed'; bind() of another\n * application sets 'displaced' on an 'initialized' binding it takes over.\n */\n state: \"initialized\" | \"bootstrapped\" | \"closed\" | \"displaced\";\n /** View of the kernel's RequestScope; the plugin never owns an AsyncLocalStorage. [C] */\n current(): ScopeView | undefined;\n /** Credential header names declared by the instance's principal sources (credential matching, §7.5). */\n readonly credentialHeaders: readonly string[];\n readonly before: readonly CompiledHook[]; // sorted by order, then discovery order\n readonly after: readonly CompiledHook[];\n readonly database: Readonly<{\n [E in DatabaseHookTarget]: {\n readonly before: readonly DatabaseHookMethod<E, \"before\">[];\n readonly after: readonly DatabaseHookMethod<E, \"after\">[];\n };\n }>;\n /** Debug log when the bridge drops a direct call's cookies because its credential is foreign. */\n onDropped(path: string): void;\n}\nexport interface ScopeView {\n /** Cookie-capable forwarding handlers have already passed the enforcing form check on every method/operation (§7.10). */\n readonly cookies: CookieSink | null;\n readonly forward: \"none\" | \"same-credential\" | \"any\";\n readonly inbound: (() => Headers) | undefined;\n readonly internal: boolean;\n /**\n * Present in EVERY handler scope whose transport exposes a browser leg, unless the plan's origin check is 'off' — enforcing or not,\n * so safe methods and GraphQL queries are covered too (§7.5). Returns when this leg has a passing origin verdict for `instance`, or\n * the single kernel disable predicate (§7.10 item 4) holds; a guard run without a passing verdict is insufficient. Otherwise throws the kernel's\n * BetterAuthConfigurationError PUBLIC_HANDLER_USED_CALLER_SESSION.\n */\n readonly checkCallerSession?: (path: string, instance: string) => void;\n /** The browser leg's OWN headers (TransportCall.browser.headers()), before any transport credential mapping replaced them; undefined\n * when the transport exposes no browser leg. Entry 2 recognizes an ambiently carried session cookie with it. */\n readonly browserHeaders: (() => Headers) | undefined;\n}\nexport interface CompiledHook {\n /**\n * Evaluate the user predicate once and let it throw. The dispatcher logs and\n * converts before-hook matcher failures to APIError 500; after-hook matcher\n * failures cross the next fixed SDK matcher boundary unchanged, so the SDK\n * cannot recover them as handler APIErrors. Never swallow a failure as a\n * non-match or evaluate the predicate again in run().\n */\n matches(ctx: HookEndpointContext, scope: ScopeView | undefined): boolean;\n run(ctx: HookEndpointContext): Promise<unknown>;\n}\n"],"mappings":";AAIA,MAAa,gBAAgB,OAAO,IAAI,gCAAgC;AACxE,MAAa,uBAAuB,OAAO,IACzC,mCACF;AACA,MAAa,kBAAkB,OAAO,IACpC,yCACF"}
1
+ {"version":3,"file":"bridge-protocol-CmRsff2P.mjs","names":[],"sources":["../src/bridge-protocol.ts"],"sourcesContent":["import type { HookEndpointContext } from \"better-auth\";\nimport type { CookieSink, DatabaseHookTarget } from \"./auth-contracts.js\";\nimport type { DatabaseHookMethod } from \"./auth-types.js\";\n\nexport const BRIDGE_HANDLE = Symbol.for(\"@nestjs-kit/better-auth:bridge\");\nexport const EXTENSION_DEFINITION = Symbol.for(\n \"@nestjs-kit/better-auth:extension\",\n);\nexport const UPGRADE_REQUEST = Symbol.for(\n \"@nestjs-kit/better-auth:upgrade-request\",\n);\n\nexport interface BridgeHandle {\n readonly protocol: 4; // checked by core (B04); v5: binding state and instance, the caller-session check\n readonly clientIpHeader: string | null; // single source of truth for the header name (§6.8)\n /** 'unbound' until the first bind(); 'bound' while an application's hooks are registered; 'closed' after its shutdown, hooks still registered. */\n readonly state: \"unbound\" | \"bound\" | \"closed\";\n /** Endpoint dispatches and database-hook dispatches (writes) seen before the first binding, reset by every bind() (B26). */\n readonly unboundDispatches: number;\n /**\n * Registers the application's hooks and returns close(), which the kernel calls in onApplicationShutdown: a closed binding keeps\n * dispatching until another application binds (§10.6). A second bind() from the same owner for the same instance is a no-op that\n * returns the existing registration (NestMicroservice.init() runs lifecycle hooks twice); from the same owner for another instance it\n * throws PLUGIN_SHARED_BETWEEN_INSTANCES (B03). Throws INSTANCE_ALREADY_BOUND if another bootstrapped application is bound; takes over\n * a never-bootstrapped one (reported, B06) and a closed one (silently). A never-bootstrapped binding it takes over becomes\n * 'displaced': an application whose init() was still running when another bound fails in onApplicationBootstrap (B06).\n */\n bind(binding: BridgeBinding): { close(): void; tookOverFrom?: string };\n /** true when an endpoint returned `value` (an object) in a non-router dispatch observed while bound; false for before-hook short-circuits (LEAD-V37). */\n producedByEndpoint(value: unknown): boolean;\n}\nexport interface BridgeBinding {\n /** The application: compared by identity for the same-owner no-op; `description` goes into the B06 message. */\n readonly owner: { readonly description: string };\n /** The instance this plugin object serves; one plugin object serves one instance (B03). */\n readonly instance: string;\n /**\n * 'initialized' at bind; the kernel sets 'bootstrapped' in onApplicationBootstrap; close() sets 'closed'; bind() of another\n * application sets 'displaced' on an 'initialized' binding it takes over.\n */\n state: \"initialized\" | \"bootstrapped\" | \"closed\" | \"displaced\";\n /** View of the kernel's RequestScope; the plugin never owns an AsyncLocalStorage. [C] */\n current(): ScopeView | undefined;\n /** Credential header names declared by the instance's principal sources (credential matching, §7.5). */\n readonly credentialHeaders: readonly string[];\n readonly before: readonly CompiledHook[]; // sorted by order, then discovery order\n readonly after: readonly CompiledHook[];\n readonly database: Readonly<{\n [E in DatabaseHookTarget]: {\n readonly before: readonly DatabaseHookMethod<E, \"before\">[];\n readonly after: readonly DatabaseHookMethod<E, \"after\">[];\n };\n }>;\n /** Debug log when the bridge drops a direct call's cookies because its credential is foreign. */\n onDropped(path: string): void;\n}\nexport interface ScopeView {\n /** Cookie-capable forwarding handlers have already passed the enforcing form check on every method/operation (§7.10). */\n readonly cookies: CookieSink | null;\n readonly forward: \"none\" | \"same-credential\" | \"any\";\n readonly inbound: (() => Headers) | undefined;\n readonly internal: boolean;\n /**\n * Present in EVERY handler scope whose transport exposes a browser leg, unless the plan's origin check is 'off' — enforcing or not,\n * so safe methods and GraphQL queries are covered too (§7.5). Returns when this leg has a passing origin verdict for `instance`, or\n * the single kernel disable predicate (§7.10 item 4) holds; a guard run without a passing verdict is insufficient. Otherwise throws the kernel's\n * BetterAuthConfigurationError PUBLIC_HANDLER_USED_CALLER_SESSION.\n */\n readonly checkCallerSession?: (path: string, instance: string) => void;\n /** The browser leg's OWN headers (TransportCall.browser.headers()), before any transport credential mapping replaced them; undefined\n * when the transport exposes no browser leg. Entry 2 recognizes an ambiently carried session cookie with it. */\n readonly browserHeaders: (() => Headers) | undefined;\n}\nexport interface CompiledHook {\n /**\n * Evaluate the user predicate once and let it throw. The dispatcher logs and\n * converts before-hook matcher failures to APIError 500; after-hook matcher\n * failures cross the next fixed SDK matcher boundary unchanged, so the SDK\n * cannot recover them as handler APIErrors. Never swallow a failure as a\n * non-match or evaluate the predicate again in run().\n */\n matches(ctx: HookEndpointContext, scope: ScopeView | undefined): boolean;\n run(ctx: HookEndpointContext): Promise<unknown>;\n}\n"],"mappings":";AAIA,MAAa,gBAAgB,OAAO,IAAI,gCAAgC;AACxE,MAAa,uBAAuB,OAAO,IACzC,mCACF;AACA,MAAa,kBAAkB,OAAO,IACpC,yCACF"}
@@ -1,8 +1,7 @@
1
- //#region src/bridge-protocol.ts
1
+ // src/bridge-protocol.ts
2
2
  const BRIDGE_HANDLE = Symbol.for("@nestjs-kit/better-auth:bridge");
3
3
  const EXTENSION_DEFINITION = Symbol.for("@nestjs-kit/better-auth:extension");
4
4
  const UPGRADE_REQUEST = Symbol.for("@nestjs-kit/better-auth:upgrade-request");
5
- //#endregion
6
5
  Object.defineProperty(exports, "BRIDGE_HANDLE", {
7
6
  enumerable: true,
8
7
  get: function() {
@@ -22,4 +21,4 @@ Object.defineProperty(exports, "UPGRADE_REQUEST", {
22
21
  }
23
22
  });
24
23
 
25
- //# sourceMappingURL=bridge-protocol-BDw8opAG.cjs.map
24
+ //# sourceMappingURL=bridge-protocol-DNFhIKdo.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"bridge-protocol-c66aEkr5.mjs","names":[],"sources":["../src/bridge-protocol.ts"],"sourcesContent":["import type { HookEndpointContext } from \"better-auth\";\nimport type { CookieSink, DatabaseHookTarget } from \"./auth-contracts.js\";\nimport type { DatabaseHookMethod } from \"./auth-types.js\";\n\nexport const BRIDGE_HANDLE = Symbol.for(\"@nestjs-kit/better-auth:bridge\");\nexport const EXTENSION_DEFINITION = Symbol.for(\n \"@nestjs-kit/better-auth:extension\",\n);\nexport const UPGRADE_REQUEST = Symbol.for(\n \"@nestjs-kit/better-auth:upgrade-request\",\n);\n\nexport interface BridgeHandle {\n readonly protocol: 4; // checked by core (B04); v5: binding state and instance, the caller-session check\n readonly clientIpHeader: string | null; // single source of truth for the header name (§6.8)\n /** 'unbound' until the first bind(); 'bound' while an application's hooks are registered; 'closed' after its shutdown, hooks still registered. */\n readonly state: \"unbound\" | \"bound\" | \"closed\";\n /** Endpoint dispatches and database-hook dispatches (writes) seen before the first binding, reset by every bind() (B26). */\n readonly unboundDispatches: number;\n /**\n * Registers the application's hooks and returns close(), which the kernel calls in onApplicationShutdown: a closed binding keeps\n * dispatching until another application binds (§10.6). A second bind() from the same owner for the same instance is a no-op that\n * returns the existing registration (NestMicroservice.init() runs lifecycle hooks twice); from the same owner for another instance it\n * throws PLUGIN_SHARED_BETWEEN_INSTANCES (B03). Throws INSTANCE_ALREADY_BOUND if another bootstrapped application is bound; takes over\n * a never-bootstrapped one (reported, B06) and a closed one (silently). A never-bootstrapped binding it takes over becomes\n * 'displaced': an application whose init() was still running when another bound fails in onApplicationBootstrap (B06).\n */\n bind(binding: BridgeBinding): { close(): void; tookOverFrom?: string };\n /** true when an endpoint returned `value` (an object) in a non-router dispatch observed while bound; false for before-hook short-circuits (LEAD-V37). */\n producedByEndpoint(value: unknown): boolean;\n}\nexport interface BridgeBinding {\n /** The application: compared by identity for the same-owner no-op; `description` goes into the B06 message. */\n readonly owner: { readonly description: string };\n /** The instance this plugin object serves; one plugin object serves one instance (B03). */\n readonly instance: string;\n /**\n * 'initialized' at bind; the kernel sets 'bootstrapped' in onApplicationBootstrap; close() sets 'closed'; bind() of another\n * application sets 'displaced' on an 'initialized' binding it takes over.\n */\n state: \"initialized\" | \"bootstrapped\" | \"closed\" | \"displaced\";\n /** View of the kernel's RequestScope; the plugin never owns an AsyncLocalStorage. [C] */\n current(): ScopeView | undefined;\n /** Credential header names declared by the instance's principal sources (credential matching, §7.5). */\n readonly credentialHeaders: readonly string[];\n readonly before: readonly CompiledHook[]; // sorted by order, then discovery order\n readonly after: readonly CompiledHook[];\n readonly database: Readonly<{\n [E in DatabaseHookTarget]: {\n readonly before: readonly DatabaseHookMethod<E, \"before\">[];\n readonly after: readonly DatabaseHookMethod<E, \"after\">[];\n };\n }>;\n /** Debug log when the bridge drops a direct call's cookies because its credential is foreign. */\n onDropped(path: string): void;\n}\nexport interface ScopeView {\n /** Cookie-capable forwarding handlers have already passed the enforcing form check on every method/operation (§7.10). */\n readonly cookies: CookieSink | null;\n readonly forward: \"none\" | \"same-credential\" | \"any\";\n readonly inbound: (() => Headers) | undefined;\n readonly internal: boolean;\n /**\n * Present in EVERY handler scope whose transport exposes a browser leg, unless the plan's origin check is 'off' — enforcing or not,\n * so safe methods and GraphQL queries are covered too (§7.5). Returns when this leg has a passing origin verdict for `instance`, or\n * the single kernel disable predicate (§7.10 item 4) holds; a guard run without a passing verdict is insufficient. Otherwise throws the kernel's\n * BetterAuthConfigurationError PUBLIC_HANDLER_USED_CALLER_SESSION.\n */\n readonly checkCallerSession?: (path: string, instance: string) => void;\n /** The browser leg's OWN headers (TransportCall.browser.headers()), before any transport credential mapping replaced them; undefined\n * when the transport exposes no browser leg. Entry 2 recognizes an ambiently carried session cookie with it. */\n readonly browserHeaders: (() => Headers) | undefined;\n}\nexport interface CompiledHook {\n /**\n * Evaluate the user predicate once and let it throw. The dispatcher logs and\n * converts before-hook matcher failures to APIError 500; after-hook matcher\n * failures cross the next fixed SDK matcher boundary unchanged, so the SDK\n * cannot recover them as handler APIErrors. Never swallow a failure as a\n * non-match or evaluate the predicate again in run().\n */\n matches(ctx: HookEndpointContext, scope: ScopeView | undefined): boolean;\n run(ctx: HookEndpointContext): Promise<unknown>;\n}\n"],"mappings":";AAIA,MAAa,gBAAgB,OAAO,IAAI,gCAAgC;AACxE,MAAa,uBAAuB,OAAO,IACzC,mCACF;AACA,MAAa,kBAAkB,OAAO,IACpC,yCACF"}
1
+ {"version":3,"file":"bridge-protocol-DNFhIKdo.cjs","names":[],"sources":["../src/bridge-protocol.ts"],"sourcesContent":["import type { HookEndpointContext } from \"better-auth\";\nimport type { CookieSink, DatabaseHookTarget } from \"./auth-contracts.js\";\nimport type { DatabaseHookMethod } from \"./auth-types.js\";\n\nexport const BRIDGE_HANDLE = Symbol.for(\"@nestjs-kit/better-auth:bridge\");\nexport const EXTENSION_DEFINITION = Symbol.for(\n \"@nestjs-kit/better-auth:extension\",\n);\nexport const UPGRADE_REQUEST = Symbol.for(\n \"@nestjs-kit/better-auth:upgrade-request\",\n);\n\nexport interface BridgeHandle {\n readonly protocol: 4; // checked by core (B04); v5: binding state and instance, the caller-session check\n readonly clientIpHeader: string | null; // single source of truth for the header name (§6.8)\n /** 'unbound' until the first bind(); 'bound' while an application's hooks are registered; 'closed' after its shutdown, hooks still registered. */\n readonly state: \"unbound\" | \"bound\" | \"closed\";\n /** Endpoint dispatches and database-hook dispatches (writes) seen before the first binding, reset by every bind() (B26). */\n readonly unboundDispatches: number;\n /**\n * Registers the application's hooks and returns close(), which the kernel calls in onApplicationShutdown: a closed binding keeps\n * dispatching until another application binds (§10.6). A second bind() from the same owner for the same instance is a no-op that\n * returns the existing registration (NestMicroservice.init() runs lifecycle hooks twice); from the same owner for another instance it\n * throws PLUGIN_SHARED_BETWEEN_INSTANCES (B03). Throws INSTANCE_ALREADY_BOUND if another bootstrapped application is bound; takes over\n * a never-bootstrapped one (reported, B06) and a closed one (silently). A never-bootstrapped binding it takes over becomes\n * 'displaced': an application whose init() was still running when another bound fails in onApplicationBootstrap (B06).\n */\n bind(binding: BridgeBinding): { close(): void; tookOverFrom?: string };\n /** true when an endpoint returned `value` (an object) in a non-router dispatch observed while bound; false for before-hook short-circuits (LEAD-V37). */\n producedByEndpoint(value: unknown): boolean;\n}\nexport interface BridgeBinding {\n /** The application: compared by identity for the same-owner no-op; `description` goes into the B06 message. */\n readonly owner: { readonly description: string };\n /** The instance this plugin object serves; one plugin object serves one instance (B03). */\n readonly instance: string;\n /**\n * 'initialized' at bind; the kernel sets 'bootstrapped' in onApplicationBootstrap; close() sets 'closed'; bind() of another\n * application sets 'displaced' on an 'initialized' binding it takes over.\n */\n state: \"initialized\" | \"bootstrapped\" | \"closed\" | \"displaced\";\n /** View of the kernel's RequestScope; the plugin never owns an AsyncLocalStorage. [C] */\n current(): ScopeView | undefined;\n /** Credential header names declared by the instance's principal sources (credential matching, §7.5). */\n readonly credentialHeaders: readonly string[];\n readonly before: readonly CompiledHook[]; // sorted by order, then discovery order\n readonly after: readonly CompiledHook[];\n readonly database: Readonly<{\n [E in DatabaseHookTarget]: {\n readonly before: readonly DatabaseHookMethod<E, \"before\">[];\n readonly after: readonly DatabaseHookMethod<E, \"after\">[];\n };\n }>;\n /** Debug log when the bridge drops a direct call's cookies because its credential is foreign. */\n onDropped(path: string): void;\n}\nexport interface ScopeView {\n /** Cookie-capable forwarding handlers have already passed the enforcing form check on every method/operation (§7.10). */\n readonly cookies: CookieSink | null;\n readonly forward: \"none\" | \"same-credential\" | \"any\";\n readonly inbound: (() => Headers) | undefined;\n readonly internal: boolean;\n /**\n * Present in EVERY handler scope whose transport exposes a browser leg, unless the plan's origin check is 'off' — enforcing or not,\n * so safe methods and GraphQL queries are covered too (§7.5). Returns when this leg has a passing origin verdict for `instance`, or\n * the single kernel disable predicate (§7.10 item 4) holds; a guard run without a passing verdict is insufficient. Otherwise throws the kernel's\n * BetterAuthConfigurationError PUBLIC_HANDLER_USED_CALLER_SESSION.\n */\n readonly checkCallerSession?: (path: string, instance: string) => void;\n /** The browser leg's OWN headers (TransportCall.browser.headers()), before any transport credential mapping replaced them; undefined\n * when the transport exposes no browser leg. Entry 2 recognizes an ambiently carried session cookie with it. */\n readonly browserHeaders: (() => Headers) | undefined;\n}\nexport interface CompiledHook {\n /**\n * Evaluate the user predicate once and let it throw. The dispatcher logs and\n * converts before-hook matcher failures to APIError 500; after-hook matcher\n * failures cross the next fixed SDK matcher boundary unchanged, so the SDK\n * cannot recover them as handler APIErrors. Never swallow a failure as a\n * non-match or evaluate the predicate again in run().\n */\n matches(ctx: HookEndpointContext, scope: ScopeView | undefined): boolean;\n run(ctx: HookEndpointContext): Promise<unknown>;\n}\n"],"mappings":";AAIA,MAAa,gBAAgB,OAAO,IAAI,gCAAgC;AACxE,MAAa,uBAAuB,OAAO,IACzC,mCACF;AACA,MAAa,kBAAkB,OAAO,IACpC,yCACF"}
@@ -1,4 +1,4 @@
1
- //#region src/auth-tokens.ts
1
+ // src/auth-tokens.ts
2
2
  /** Stable Nest injection tokens shared by every package copy and module format. */
3
3
  function instanceToken(base, alias) {
4
4
  return alias === void 0 || alias === "" || alias === "default" ? base : `${base}_${alias}`;
@@ -54,27 +54,23 @@ const READER_CONTEXT = Symbol.for("@nestjs-kit/better-auth:reader-context");
54
54
  const INVOCATION_VALUES = Symbol.for("@nestjs-kit/better-auth:invocation");
55
55
  /** Stored in place of an invocation value that two contributing policy runs published differently. */
56
56
  const AMBIGUOUS_INVOCATION_VALUE = Symbol.for("@nestjs-kit/better-auth:ambiguous-invocation-value");
57
- //#endregion
58
- //#region \0@oxc-project+runtime@0.153.0/helpers/esm/decorateMetadata.js
57
+ // \0@oxc-project+runtime@0.156.0/helpers/esm/decorateMetadata.js
59
58
  function __decorateMetadata(k, v) {
60
59
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
61
60
  }
62
- //#endregion
63
- //#region \0@oxc-project+runtime@0.153.0/helpers/esm/decorateParam.js
61
+ // \0@oxc-project+runtime@0.156.0/helpers/esm/decorateParam.js
64
62
  function __decorateParam(paramIndex, decorator) {
65
63
  return function(target, key) {
66
64
  decorator(target, key, paramIndex);
67
65
  };
68
66
  }
69
- //#endregion
70
- //#region \0@oxc-project+runtime@0.153.0/helpers/esm/decorate.js
67
+ // \0@oxc-project+runtime@0.156.0/helpers/esm/decorate.js
71
68
  function __decorate(decorators, target, key, desc) {
72
69
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
73
70
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
74
71
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
75
72
  return c > 3 && r && Object.defineProperty(target, key, r), r;
76
73
  }
77
- //#endregion
78
74
  export { SKIP_ORIGIN_CHECK_METADATA as A, getPrincipalSourcesToken as B, PRINCIPAL_RESOLVER as C, ROUTE_PLANNER as D, REQUIREMENTS_METADATA as E, getBetterAuthHandleToken as F, getBetterAuthInstanceToken as I, getBetterAuthOptionsToken as L, TRANSPORT_REGISTRY as M, USE_BETTER_AUTH_METADATA as N, SCOPE_CORE as O, WS_CONNECTION_AUTH as P, getBetterAuthServiceToken as R, PRINCIPAL_READINGS as S, REQUEST_SCOPE as T, MOUNT_COORDINATOR as _, ACCESS_METADATA as a, POLICY_RESOLVER as b, AUTH_INSTANCE_METADATA as c, FRESHNESS_METADATA as d, GUARD_CORE as f, INVOCATION_VALUES as g, INVOCATION_PARAMS_METADATA as h, ACCEPT_PRINCIPALS_METADATA as i, TRANSPORTS as j, SKIP_DEFAULT_REQUIREMENTS_METADATA as k, DB_HOOK_METADATA as l, INSTANCE_REGISTRY as m, __decorateParam as n, AMBIGUOUS_INVOCATION_VALUE as o, HOOK_METADATA as p, __decorateMetadata as r, AUTH_ENHANCER as s, __decorate as t, FORWARD_COOKIES_METADATA as u, PLATFORMS as v, READER_CONTEXT as w, PRINCIPAL_PARAMS_METADATA as x, POLICY_INVOKER as y, getExtensionToken as z };
79
75
 
80
- //# sourceMappingURL=decorate-Dt0e9K6R.mjs.map
76
+ //# sourceMappingURL=decorate-bO-rBn-G.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"decorate-Dt0e9K6R.mjs","names":[],"sources":["../src/auth-tokens.ts"],"sourcesContent":["/** Stable Nest injection tokens shared by every package copy and module format. */\nfunction instanceToken(base: string, alias?: string): string {\n return alias === undefined || alias === \"\" || alias === \"default\"\n ? base\n : `${base}_${alias}`;\n}\n\nexport function getBetterAuthInstanceToken(alias?: string): string {\n return instanceToken(\"NESTJS_KIT_BETTER_AUTH_INSTANCE\", alias);\n}\n\nexport function getBetterAuthOptionsToken(alias?: string): string {\n return instanceToken(\"NESTJS_KIT_BETTER_AUTH_OPTIONS\", alias);\n}\n\nexport function getBetterAuthServiceToken(alias?: string): string {\n return instanceToken(\"NESTJS_KIT_BETTER_AUTH_SERVICE\", alias);\n}\n\nexport function getBetterAuthHandleToken(alias?: string): string {\n return instanceToken(\"NESTJS_KIT_BETTER_AUTH_HANDLE\", alias);\n}\n\n// Shared application collaborators and metadata must also survive duplicate copies.\nexport const INSTANCE_REGISTRY = Symbol.for(\n \"@nestjs-kit/better-auth:instance-registry\",\n);\nexport const REQUEST_SCOPE = Symbol.for(\n \"@nestjs-kit/better-auth:request-scope\",\n);\nexport const PRINCIPAL_READINGS = Symbol.for(\n \"@nestjs-kit/better-auth:principal-readings\",\n);\nexport const ROUTE_PLANNER = Symbol.for(\n \"@nestjs-kit/better-auth:route-planner\",\n);\nexport const TRANSPORT_REGISTRY = Symbol.for(\n \"@nestjs-kit/better-auth:transport-registry\",\n);\nexport const POLICY_RESOLVER = Symbol.for(\n \"@nestjs-kit/better-auth:policy-resolver\",\n);\nexport const MOUNT_COORDINATOR = Symbol.for(\n \"@nestjs-kit/better-auth:mount-coordinator\",\n);\nexport const GUARD_CORE = Symbol.for(\"@nestjs-kit/better-auth:guard-core\");\nexport const SCOPE_CORE = Symbol.for(\"@nestjs-kit/better-auth:scope-core\");\nexport const PRINCIPAL_RESOLVER = Symbol.for(\n \"@nestjs-kit/better-auth:principal-resolver\",\n);\nexport const POLICY_INVOKER = Symbol.for(\n \"@nestjs-kit/better-auth:policy-invoker\",\n);\nexport const PLATFORMS = Symbol.for(\"@nestjs-kit/better-auth:platforms\");\nexport const TRANSPORTS = Symbol.for(\"@nestjs-kit/better-auth:transports\");\nexport const ACCESS_METADATA = Symbol.for(\"@nestjs-kit/better-auth:access\");\nexport const ACCEPT_PRINCIPALS_METADATA = Symbol.for(\n \"@nestjs-kit/better-auth:accept-principals\",\n);\nexport const REQUIREMENTS_METADATA = Symbol.for(\n \"@nestjs-kit/better-auth:requirements\",\n);\nexport const SKIP_DEFAULT_REQUIREMENTS_METADATA = Symbol.for(\n \"@nestjs-kit/better-auth:skip-default-requirements\",\n);\nexport const FRESHNESS_METADATA = Symbol.for(\n \"@nestjs-kit/better-auth:freshness\",\n);\nexport const AUTH_INSTANCE_METADATA = Symbol.for(\n \"@nestjs-kit/better-auth:auth-instance\",\n);\nexport const PRINCIPAL_PARAMS_METADATA = Symbol.for(\n \"@nestjs-kit/better-auth:principal-params\",\n);\nexport const INVOCATION_PARAMS_METADATA = Symbol.for(\n \"@nestjs-kit/better-auth:invocation-params\",\n);\nexport const FORWARD_COOKIES_METADATA = Symbol.for(\n \"@nestjs-kit/better-auth:forward-cookies\",\n);\nexport const SKIP_ORIGIN_CHECK_METADATA = Symbol.for(\n \"@nestjs-kit/better-auth:skip-origin-check\",\n);\nexport const USE_BETTER_AUTH_METADATA = Symbol.for(\n \"@nestjs-kit/better-auth:use-better-auth\",\n);\nexport const HOOK_METADATA = Symbol.for(\"@nestjs-kit/better-auth:hook\");\nexport const DB_HOOK_METADATA = Symbol.for(\"@nestjs-kit/better-auth:db-hook\");\nexport const AUTH_ENHANCER = Symbol.for(\"@nestjs-kit/better-auth:enhancer\");\n/** Connection-time WebSocket authentication, provided by the socket.io and ws transport definitions. */\nexport const WS_CONNECTION_AUTH: unique symbol = Symbol.for(\n \"@nestjs-kit/better-auth:ws-connection-auth\",\n);\n\nexport function getPrincipalSourcesToken(instance: string): symbol {\n return Symbol.for(`@nestjs-kit/better-auth:principal-sources:${instance}`);\n}\n\nexport function getExtensionToken(\n point: \"platforms\" | \"transports\" | \"principals\",\n instance: string,\n index: number,\n): symbol {\n return Symbol.for(\n `@nestjs-kit/better-auth:ext:${point}:${instance}:${index}`,\n );\n}\n\nexport const READER_CONTEXT = Symbol.for(\n \"@nestjs-kit/better-auth:reader-context\",\n);\nexport const INVOCATION_VALUES = Symbol.for(\n \"@nestjs-kit/better-auth:invocation\",\n);\n/** Stored in place of an invocation value that two contributing policy runs published differently. */\nexport const AMBIGUOUS_INVOCATION_VALUE = Symbol.for(\n \"@nestjs-kit/better-auth:ambiguous-invocation-value\",\n);\n"],"mappings":";;AACA,SAAS,cAAc,MAAc,OAAwB;CAC3D,OAAO,UAAU,KAAA,KAAa,UAAU,MAAM,UAAU,YACpD,OACA,GAAG,KAAK,GAAG;AACjB;AAEA,SAAgB,2BAA2B,OAAwB;CACjE,OAAO,cAAc,mCAAmC,KAAK;AAC/D;AAEA,SAAgB,0BAA0B,OAAwB;CAChE,OAAO,cAAc,kCAAkC,KAAK;AAC9D;AAEA,SAAgB,0BAA0B,OAAwB;CAChE,OAAO,cAAc,kCAAkC,KAAK;AAC9D;AAEA,SAAgB,yBAAyB,OAAwB;CAC/D,OAAO,cAAc,iCAAiC,KAAK;AAC7D;AAGA,MAAa,oBAAoB,OAAO,IACtC,2CACF;AACA,MAAa,gBAAgB,OAAO,IAClC,uCACF;AACA,MAAa,qBAAqB,OAAO,IACvC,4CACF;AACA,MAAa,gBAAgB,OAAO,IAClC,uCACF;AACA,MAAa,qBAAqB,OAAO,IACvC,4CACF;AACA,MAAa,kBAAkB,OAAO,IACpC,yCACF;AACA,MAAa,oBAAoB,OAAO,IACtC,2CACF;AACA,MAAa,aAAa,OAAO,IAAI,oCAAoC;AACzE,MAAa,aAAa,OAAO,IAAI,oCAAoC;AACzE,MAAa,qBAAqB,OAAO,IACvC,4CACF;AACA,MAAa,iBAAiB,OAAO,IACnC,wCACF;AACA,MAAa,YAAY,OAAO,IAAI,mCAAmC;AACvE,MAAa,aAAa,OAAO,IAAI,oCAAoC;AACzE,MAAa,kBAAkB,OAAO,IAAI,gCAAgC;AAC1E,MAAa,6BAA6B,OAAO,IAC/C,2CACF;AACA,MAAa,wBAAwB,OAAO,IAC1C,sCACF;AACA,MAAa,qCAAqC,OAAO,IACvD,mDACF;AACA,MAAa,qBAAqB,OAAO,IACvC,mCACF;AACA,MAAa,yBAAyB,OAAO,IAC3C,uCACF;AACA,MAAa,4BAA4B,OAAO,IAC9C,0CACF;AACA,MAAa,6BAA6B,OAAO,IAC/C,2CACF;AACA,MAAa,2BAA2B,OAAO,IAC7C,yCACF;AACA,MAAa,6BAA6B,OAAO,IAC/C,2CACF;AACA,MAAa,2BAA2B,OAAO,IAC7C,yCACF;AACA,MAAa,gBAAgB,OAAO,IAAI,8BAA8B;AACtE,MAAa,mBAAmB,OAAO,IAAI,iCAAiC;AAC5E,MAAa,gBAAgB,OAAO,IAAI,kCAAkC;;AAE1E,MAAa,qBAAoC,OAAO,IACtD,4CACF;AAEA,SAAgB,yBAAyB,UAA0B;CACjE,OAAO,OAAO,IAAI,6CAA6C,UAAU;AAC3E;AAEA,SAAgB,kBACd,OACA,UACA,OACQ;CACR,OAAO,OAAO,IACZ,+BAA+B,MAAM,GAAG,SAAS,GAAG,OACtD;AACF;AAEA,MAAa,iBAAiB,OAAO,IACnC,wCACF;AACA,MAAa,oBAAoB,OAAO,IACtC,oCACF;;AAEA,MAAa,6BAA6B,OAAO,IAC/C,oDACF"}
1
+ {"version":3,"file":"decorate-bO-rBn-G.mjs","names":[],"sources":["../src/auth-tokens.ts"],"sourcesContent":["/** Stable Nest injection tokens shared by every package copy and module format. */\nfunction instanceToken(base: string, alias?: string): string {\n return alias === undefined || alias === \"\" || alias === \"default\"\n ? base\n : `${base}_${alias}`;\n}\n\nexport function getBetterAuthInstanceToken(alias?: string): string {\n return instanceToken(\"NESTJS_KIT_BETTER_AUTH_INSTANCE\", alias);\n}\n\nexport function getBetterAuthOptionsToken(alias?: string): string {\n return instanceToken(\"NESTJS_KIT_BETTER_AUTH_OPTIONS\", alias);\n}\n\nexport function getBetterAuthServiceToken(alias?: string): string {\n return instanceToken(\"NESTJS_KIT_BETTER_AUTH_SERVICE\", alias);\n}\n\nexport function getBetterAuthHandleToken(alias?: string): string {\n return instanceToken(\"NESTJS_KIT_BETTER_AUTH_HANDLE\", alias);\n}\n\n// Shared application collaborators and metadata must also survive duplicate copies.\nexport const INSTANCE_REGISTRY = Symbol.for(\n \"@nestjs-kit/better-auth:instance-registry\",\n);\nexport const REQUEST_SCOPE = Symbol.for(\n \"@nestjs-kit/better-auth:request-scope\",\n);\nexport const PRINCIPAL_READINGS = Symbol.for(\n \"@nestjs-kit/better-auth:principal-readings\",\n);\nexport const ROUTE_PLANNER = Symbol.for(\n \"@nestjs-kit/better-auth:route-planner\",\n);\nexport const TRANSPORT_REGISTRY = Symbol.for(\n \"@nestjs-kit/better-auth:transport-registry\",\n);\nexport const POLICY_RESOLVER = Symbol.for(\n \"@nestjs-kit/better-auth:policy-resolver\",\n);\nexport const MOUNT_COORDINATOR = Symbol.for(\n \"@nestjs-kit/better-auth:mount-coordinator\",\n);\nexport const GUARD_CORE = Symbol.for(\"@nestjs-kit/better-auth:guard-core\");\nexport const SCOPE_CORE = Symbol.for(\"@nestjs-kit/better-auth:scope-core\");\nexport const PRINCIPAL_RESOLVER = Symbol.for(\n \"@nestjs-kit/better-auth:principal-resolver\",\n);\nexport const POLICY_INVOKER = Symbol.for(\n \"@nestjs-kit/better-auth:policy-invoker\",\n);\nexport const PLATFORMS = Symbol.for(\"@nestjs-kit/better-auth:platforms\");\nexport const TRANSPORTS = Symbol.for(\"@nestjs-kit/better-auth:transports\");\nexport const ACCESS_METADATA = Symbol.for(\"@nestjs-kit/better-auth:access\");\nexport const ACCEPT_PRINCIPALS_METADATA = Symbol.for(\n \"@nestjs-kit/better-auth:accept-principals\",\n);\nexport const REQUIREMENTS_METADATA = Symbol.for(\n \"@nestjs-kit/better-auth:requirements\",\n);\nexport const SKIP_DEFAULT_REQUIREMENTS_METADATA = Symbol.for(\n \"@nestjs-kit/better-auth:skip-default-requirements\",\n);\nexport const FRESHNESS_METADATA = Symbol.for(\n \"@nestjs-kit/better-auth:freshness\",\n);\nexport const AUTH_INSTANCE_METADATA = Symbol.for(\n \"@nestjs-kit/better-auth:auth-instance\",\n);\nexport const PRINCIPAL_PARAMS_METADATA = Symbol.for(\n \"@nestjs-kit/better-auth:principal-params\",\n);\nexport const INVOCATION_PARAMS_METADATA = Symbol.for(\n \"@nestjs-kit/better-auth:invocation-params\",\n);\nexport const FORWARD_COOKIES_METADATA = Symbol.for(\n \"@nestjs-kit/better-auth:forward-cookies\",\n);\nexport const SKIP_ORIGIN_CHECK_METADATA = Symbol.for(\n \"@nestjs-kit/better-auth:skip-origin-check\",\n);\nexport const USE_BETTER_AUTH_METADATA = Symbol.for(\n \"@nestjs-kit/better-auth:use-better-auth\",\n);\nexport const HOOK_METADATA = Symbol.for(\"@nestjs-kit/better-auth:hook\");\nexport const DB_HOOK_METADATA = Symbol.for(\"@nestjs-kit/better-auth:db-hook\");\nexport const AUTH_ENHANCER = Symbol.for(\"@nestjs-kit/better-auth:enhancer\");\n/** Connection-time WebSocket authentication, provided by the socket.io and ws transport definitions. */\nexport const WS_CONNECTION_AUTH: unique symbol = Symbol.for(\n \"@nestjs-kit/better-auth:ws-connection-auth\",\n);\n\nexport function getPrincipalSourcesToken(instance: string): symbol {\n return Symbol.for(`@nestjs-kit/better-auth:principal-sources:${instance}`);\n}\n\nexport function getExtensionToken(\n point: \"platforms\" | \"transports\" | \"principals\",\n instance: string,\n index: number,\n): symbol {\n return Symbol.for(\n `@nestjs-kit/better-auth:ext:${point}:${instance}:${index}`,\n );\n}\n\nexport const READER_CONTEXT = Symbol.for(\n \"@nestjs-kit/better-auth:reader-context\",\n);\nexport const INVOCATION_VALUES = Symbol.for(\n \"@nestjs-kit/better-auth:invocation\",\n);\n/** Stored in place of an invocation value that two contributing policy runs published differently. */\nexport const AMBIGUOUS_INVOCATION_VALUE = Symbol.for(\n \"@nestjs-kit/better-auth:ambiguous-invocation-value\",\n);\n"],"mappings":";;AACA,SAAS,cAAc,MAAc,OAAwB;CAC3D,OAAO,UAAU,KAAA,KAAa,UAAU,MAAM,UAAU,YACpD,OACA,GA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OAAO,IAAI,8BAA8B;AACtE,MAAa,mBAAmB,OAAO,IAAI,iCAAiC;AAC5E,MAAa,gBAAgB,OAAO,IAAI,kCAAkC;;AAE1E,MAAa,qBAAoC,OAAO,IACtD,4CACF;AAEA,SAAgB,yBAAyB,UAA0B;CACjE,OAAO,OAAO,IAAI,6CAA6C,UAAU;AAC3E;AAEA,SAAgB,kBACd,OACA,UACA,OACQ;CACR,OAAO,OAAO,IACZ,+BAA+B,MAAM,GAAG,SAAS,GAAG,OACtD;AACF;AAEA,MAAa,iBAAiB,OAAO,IACnC,wCACF;AACA,MAAa,oBAAoB,OAAO,IACtC,oCACF;;AAEA,MAAa,6BAA6B,OAAO,IAC/C,oDACF"}
@@ -1,4 +1,4 @@
1
- //#region src/auth-tokens.ts
1
+ // src/auth-tokens.ts
2
2
  /** Stable Nest injection tokens shared by every package copy and module format. */
3
3
  function instanceToken(base, alias) {
4
4
  return alias === void 0 || alias === "" || alias === "default" ? base : `${base}_${alias}`;
@@ -54,27 +54,23 @@ const READER_CONTEXT = Symbol.for("@nestjs-kit/better-auth:reader-context");
54
54
  const INVOCATION_VALUES = Symbol.for("@nestjs-kit/better-auth:invocation");
55
55
  /** Stored in place of an invocation value that two contributing policy runs published differently. */
56
56
  const AMBIGUOUS_INVOCATION_VALUE = Symbol.for("@nestjs-kit/better-auth:ambiguous-invocation-value");
57
- //#endregion
58
- //#region \0@oxc-project+runtime@0.153.0/helpers/esm/decorateMetadata.js
57
+ // \0@oxc-project+runtime@0.156.0/helpers/esm/decorateMetadata.js
59
58
  function __decorateMetadata(k, v) {
60
59
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
61
60
  }
62
- //#endregion
63
- //#region \0@oxc-project+runtime@0.153.0/helpers/esm/decorateParam.js
61
+ // \0@oxc-project+runtime@0.156.0/helpers/esm/decorateParam.js
64
62
  function __decorateParam(paramIndex, decorator) {
65
63
  return function(target, key) {
66
64
  decorator(target, key, paramIndex);
67
65
  };
68
66
  }
69
- //#endregion
70
- //#region \0@oxc-project+runtime@0.153.0/helpers/esm/decorate.js
67
+ // \0@oxc-project+runtime@0.156.0/helpers/esm/decorate.js
71
68
  function __decorate(decorators, target, key, desc) {
72
69
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
73
70
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
74
71
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
75
72
  return c > 3 && r && Object.defineProperty(target, key, r), r;
76
73
  }
77
- //#endregion
78
74
  Object.defineProperty(exports, "ACCEPT_PRINCIPALS_METADATA", {
79
75
  enumerable: true,
80
76
  get: function() {
@@ -316,4 +312,4 @@ Object.defineProperty(exports, "getPrincipalSourcesToken", {
316
312
  }
317
313
  });
318
314
 
319
- //# sourceMappingURL=decorate-Cr4Q7bNE.cjs.map
315
+ //# sourceMappingURL=decorate-fMNf0caZ.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"decorate-Cr4Q7bNE.cjs","names":[],"sources":["../src/auth-tokens.ts"],"sourcesContent":["/** Stable Nest injection tokens shared by every package copy and module format. */\nfunction instanceToken(base: string, alias?: string): string {\n return alias === undefined || alias === \"\" || alias === \"default\"\n ? base\n : `${base}_${alias}`;\n}\n\nexport function getBetterAuthInstanceToken(alias?: string): string {\n return instanceToken(\"NESTJS_KIT_BETTER_AUTH_INSTANCE\", alias);\n}\n\nexport function getBetterAuthOptionsToken(alias?: string): string {\n return instanceToken(\"NESTJS_KIT_BETTER_AUTH_OPTIONS\", alias);\n}\n\nexport function getBetterAuthServiceToken(alias?: string): string {\n return instanceToken(\"NESTJS_KIT_BETTER_AUTH_SERVICE\", alias);\n}\n\nexport function getBetterAuthHandleToken(alias?: string): string {\n return instanceToken(\"NESTJS_KIT_BETTER_AUTH_HANDLE\", alias);\n}\n\n// Shared application collaborators and metadata must also survive duplicate copies.\nexport const INSTANCE_REGISTRY = Symbol.for(\n \"@nestjs-kit/better-auth:instance-registry\",\n);\nexport const REQUEST_SCOPE = Symbol.for(\n \"@nestjs-kit/better-auth:request-scope\",\n);\nexport const PRINCIPAL_READINGS = Symbol.for(\n \"@nestjs-kit/better-auth:principal-readings\",\n);\nexport const ROUTE_PLANNER = Symbol.for(\n \"@nestjs-kit/better-auth:route-planner\",\n);\nexport const TRANSPORT_REGISTRY = Symbol.for(\n \"@nestjs-kit/better-auth:transport-registry\",\n);\nexport const POLICY_RESOLVER = Symbol.for(\n \"@nestjs-kit/better-auth:policy-resolver\",\n);\nexport const MOUNT_COORDINATOR = Symbol.for(\n \"@nestjs-kit/better-auth:mount-coordinator\",\n);\nexport const GUARD_CORE = Symbol.for(\"@nestjs-kit/better-auth:guard-core\");\nexport const SCOPE_CORE = Symbol.for(\"@nestjs-kit/better-auth:scope-core\");\nexport const PRINCIPAL_RESOLVER = Symbol.for(\n \"@nestjs-kit/better-auth:principal-resolver\",\n);\nexport const POLICY_INVOKER = Symbol.for(\n \"@nestjs-kit/better-auth:policy-invoker\",\n);\nexport const PLATFORMS = Symbol.for(\"@nestjs-kit/better-auth:platforms\");\nexport const TRANSPORTS = Symbol.for(\"@nestjs-kit/better-auth:transports\");\nexport const ACCESS_METADATA = Symbol.for(\"@nestjs-kit/better-auth:access\");\nexport const ACCEPT_PRINCIPALS_METADATA = Symbol.for(\n \"@nestjs-kit/better-auth:accept-principals\",\n);\nexport const REQUIREMENTS_METADATA = Symbol.for(\n \"@nestjs-kit/better-auth:requirements\",\n);\nexport const SKIP_DEFAULT_REQUIREMENTS_METADATA = Symbol.for(\n \"@nestjs-kit/better-auth:skip-default-requirements\",\n);\nexport const FRESHNESS_METADATA = Symbol.for(\n \"@nestjs-kit/better-auth:freshness\",\n);\nexport const AUTH_INSTANCE_METADATA = Symbol.for(\n \"@nestjs-kit/better-auth:auth-instance\",\n);\nexport const PRINCIPAL_PARAMS_METADATA = Symbol.for(\n \"@nestjs-kit/better-auth:principal-params\",\n);\nexport const INVOCATION_PARAMS_METADATA = Symbol.for(\n \"@nestjs-kit/better-auth:invocation-params\",\n);\nexport const FORWARD_COOKIES_METADATA = Symbol.for(\n \"@nestjs-kit/better-auth:forward-cookies\",\n);\nexport const SKIP_ORIGIN_CHECK_METADATA = Symbol.for(\n \"@nestjs-kit/better-auth:skip-origin-check\",\n);\nexport const USE_BETTER_AUTH_METADATA = Symbol.for(\n \"@nestjs-kit/better-auth:use-better-auth\",\n);\nexport const HOOK_METADATA = Symbol.for(\"@nestjs-kit/better-auth:hook\");\nexport const DB_HOOK_METADATA = Symbol.for(\"@nestjs-kit/better-auth:db-hook\");\nexport const AUTH_ENHANCER = Symbol.for(\"@nestjs-kit/better-auth:enhancer\");\n/** Connection-time WebSocket authentication, provided by the socket.io and ws transport definitions. */\nexport const WS_CONNECTION_AUTH: unique symbol = Symbol.for(\n \"@nestjs-kit/better-auth:ws-connection-auth\",\n);\n\nexport function getPrincipalSourcesToken(instance: string): symbol {\n return Symbol.for(`@nestjs-kit/better-auth:principal-sources:${instance}`);\n}\n\nexport function getExtensionToken(\n point: \"platforms\" | \"transports\" | \"principals\",\n instance: string,\n index: number,\n): symbol {\n return Symbol.for(\n `@nestjs-kit/better-auth:ext:${point}:${instance}:${index}`,\n );\n}\n\nexport const READER_CONTEXT = Symbol.for(\n \"@nestjs-kit/better-auth:reader-context\",\n);\nexport const INVOCATION_VALUES = Symbol.for(\n \"@nestjs-kit/better-auth:invocation\",\n);\n/** Stored in place of an invocation value that two contributing policy runs published differently. */\nexport const AMBIGUOUS_INVOCATION_VALUE = Symbol.for(\n \"@nestjs-kit/better-auth:ambiguous-invocation-value\",\n);\n"],"mappings":";;AACA,SAAS,cAAc,MAAc,OAAwB;CAC3D,OAAO,UAAU,KAAA,KAAa,UAAU,MAAM,UAAU,YACpD,OACA,GAAG,KAAK,GAAG;AACjB;AAEA,SAAgB,2BAA2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OAAO,IAAI,iCAAiC;AAC5E,MAAa,gBAAgB,OAAO,IAAI,kCAAkC;;AAE1E,MAAa,qBAAoC,OAAO,IACtD,4CACF;AAEA,SAAgB,yBAAyB,UAA0B;CACjE,OAAO,OAAO,IAAI,6CAA6C,UAAU;AAC3E;AAEA,SAAgB,kBACd,OACA,UACA,OACQ;CACR,OAAO,OAAO,IACZ,+BAA+B,MAAM,GAAG,SAAS,GAAG,OACtD;AACF;AAEA,MAAa,iBAAiB,OAAO,IACnC,wCACF;AACA,MAAa,oBAAoB,OAAO,IACtC,oCACF;;AAEA,MAAa,6BAA6B,OAAO,IAC/C,oDACF"}
1
+ {"version":3,"file":"decorate-fMNf0caZ.cjs","names":[],"sources":["../src/auth-tokens.ts"],"sourcesContent":["/** Stable Nest injection tokens shared by every package copy and module format. */\nfunction instanceToken(base: string, alias?: string): string {\n return alias === undefined || alias === \"\" || alias === \"default\"\n ? base\n : `${base}_${alias}`;\n}\n\nexport function getBetterAuthInstanceToken(alias?: string): string {\n return instanceToken(\"NESTJS_KIT_BETTER_AUTH_INSTANCE\", alias);\n}\n\nexport function getBetterAuthOptionsToken(alias?: string): string {\n return instanceToken(\"NESTJS_KIT_BETTER_AUTH_OPTIONS\", alias);\n}\n\nexport function getBetterAuthServiceToken(alias?: string): string {\n return instanceToken(\"NESTJS_KIT_BETTER_AUTH_SERVICE\", alias);\n}\n\nexport function getBetterAuthHandleToken(alias?: string): string {\n return instanceToken(\"NESTJS_KIT_BETTER_AUTH_HANDLE\", alias);\n}\n\n// Shared application collaborators and metadata must also survive duplicate copies.\nexport const INSTANCE_REGISTRY = Symbol.for(\n \"@nestjs-kit/better-auth:instance-registry\",\n);\nexport const REQUEST_SCOPE = Symbol.for(\n \"@nestjs-kit/better-auth:request-scope\",\n);\nexport const PRINCIPAL_READINGS = Symbol.for(\n \"@nestjs-kit/better-auth:principal-readings\",\n);\nexport const ROUTE_PLANNER = Symbol.for(\n \"@nestjs-kit/better-auth:route-planner\",\n);\nexport const TRANSPORT_REGISTRY = Symbol.for(\n \"@nestjs-kit/better-auth:transport-registry\",\n);\nexport const POLICY_RESOLVER = Symbol.for(\n \"@nestjs-kit/better-auth:policy-resolver\",\n);\nexport const MOUNT_COORDINATOR = Symbol.for(\n \"@nestjs-kit/better-auth:mount-coordinator\",\n);\nexport const GUARD_CORE = Symbol.for(\"@nestjs-kit/better-auth:guard-core\");\nexport const SCOPE_CORE = Symbol.for(\"@nestjs-kit/better-auth:scope-core\");\nexport const PRINCIPAL_RESOLVER = Symbol.for(\n \"@nestjs-kit/better-auth:principal-resolver\",\n);\nexport const POLICY_INVOKER = Symbol.for(\n \"@nestjs-kit/better-auth:policy-invoker\",\n);\nexport const PLATFORMS = Symbol.for(\"@nestjs-kit/better-auth:platforms\");\nexport const TRANSPORTS = Symbol.for(\"@nestjs-kit/better-auth:transports\");\nexport const ACCESS_METADATA = Symbol.for(\"@nestjs-kit/better-auth:access\");\nexport const ACCEPT_PRINCIPALS_METADATA = Symbol.for(\n \"@nestjs-kit/better-auth:accept-principals\",\n);\nexport const REQUIREMENTS_METADATA = Symbol.for(\n \"@nestjs-kit/better-auth:requirements\",\n);\nexport const SKIP_DEFAULT_REQUIREMENTS_METADATA = Symbol.for(\n \"@nestjs-kit/better-auth:skip-default-requirements\",\n);\nexport const FRESHNESS_METADATA = Symbol.for(\n \"@nestjs-kit/better-auth:freshness\",\n);\nexport const AUTH_INSTANCE_METADATA = Symbol.for(\n \"@nestjs-kit/better-auth:auth-instance\",\n);\nexport const PRINCIPAL_PARAMS_METADATA = Symbol.for(\n \"@nestjs-kit/better-auth:principal-params\",\n);\nexport const INVOCATION_PARAMS_METADATA = Symbol.for(\n \"@nestjs-kit/better-auth:invocation-params\",\n);\nexport const FORWARD_COOKIES_METADATA = Symbol.for(\n \"@nestjs-kit/better-auth:forward-cookies\",\n);\nexport const SKIP_ORIGIN_CHECK_METADATA = Symbol.for(\n \"@nestjs-kit/better-auth:skip-origin-check\",\n);\nexport const USE_BETTER_AUTH_METADATA = Symbol.for(\n \"@nestjs-kit/better-auth:use-better-auth\",\n);\nexport const HOOK_METADATA = Symbol.for(\"@nestjs-kit/better-auth:hook\");\nexport const DB_HOOK_METADATA = Symbol.for(\"@nestjs-kit/better-auth:db-hook\");\nexport const AUTH_ENHANCER = Symbol.for(\"@nestjs-kit/better-auth:enhancer\");\n/** Connection-time WebSocket authentication, provided by the socket.io and ws transport definitions. */\nexport const WS_CONNECTION_AUTH: unique symbol = Symbol.for(\n \"@nestjs-kit/better-auth:ws-connection-auth\",\n);\n\nexport function getPrincipalSourcesToken(instance: string): symbol {\n return Symbol.for(`@nestjs-kit/better-auth:principal-sources:${instance}`);\n}\n\nexport function getExtensionToken(\n point: \"platforms\" | \"transports\" | \"principals\",\n instance: string,\n index: number,\n): symbol {\n return Symbol.for(\n `@nestjs-kit/better-auth:ext:${point}:${instance}:${index}`,\n );\n}\n\nexport const READER_CONTEXT = Symbol.for(\n \"@nestjs-kit/better-auth:reader-context\",\n);\nexport const INVOCATION_VALUES = Symbol.for(\n \"@nestjs-kit/better-auth:invocation\",\n);\n/** Stored in place of an invocation value that two contributing policy runs published differently. */\nexport const AMBIGUOUS_INVOCATION_VALUE = Symbol.for(\n \"@nestjs-kit/better-auth:ambiguous-invocation-value\",\n);\n"],"mappings":";;AACA,SAAS,cAAc,MAAc,OAAwB;CAC3D,OAAO,UAAU,KAAA,KAAa,UAAU,MAAM,UAAU,YACpD,OACA,GAAG,KAAK,GAAG;AACjB;AAEA,SAAgB,2BAA2B,OAAwB;CACjE,OAAO,cAAc,mCAAmC,KAAK;AAC/D;AAEA,SAAgB,0BAA0B,OAAwB;CAChE,OAAO,cAAc,kCAAkC,KAAK;AAC9D;AAEA,SAAgB,0BAA0B,OAAwB;CAChE,OAAO,cAAc,kCAAkC,KAAK;AAC9D;AAEA,SAAgB,yBAAyB,OAAwB;CAC/D,OAAO,cAAc,iCAAiC,KAAK;AAC7D;AAGA,MAAa,oBAAoB,OAAO,IACtC,2CACF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AAiB,OAAO,IACnC,wCACF;AACA,MAAa,oBAAoB,OAAO,IACtC,oCACF;;AAEA,MAAa,6BAA6B,OAAO,IAC/C,oDACF"}
package/dist/express.cjs CHANGED
@@ -1,10 +1,10 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_auth_errors = require("./auth-errors-DmiKl0L_.cjs");
3
- const require_platform = require("./platform-YICqqYv6.cjs");
2
+ const require_auth_errors = require("./auth-errors-RW7hOVI-.cjs");
3
+ const require_platform = require("./platform-C67dxSls.cjs");
4
4
  let node_http = require("node:http");
5
5
  let node_stream = require("node:stream");
6
6
  let path_to_regexp = require("path-to-regexp");
7
- //#region src/express-platform.ts
7
+ // src/express-platform.ts
8
8
  const RAW_BODY = Symbol.for("@nestjs-kit/better-auth:raw-body");
9
9
  function application(adapter) {
10
10
  return adapter.getInstance();
@@ -249,7 +249,6 @@ var ExpressPlatform = class {
249
249
  function expressPlatform(options) {
250
250
  return new ExpressPlatform(options);
251
251
  }
252
- //#endregion
253
252
  exports.ExpressPlatform = ExpressPlatform;
254
253
  exports.expressPlatform = expressPlatform;
255
254
 
@@ -1,6 +1,5 @@
1
- import { J as PlatformMountContext, P as ExpressPlatformOptions, U as HttpPlatform, Y as PlatformPrepareContext, at as ProxyTrust, n as ApplicationRouteDescriptor, s as AuthRouteBinding } from "./auth-contracts-Brh_Qko9.cjs";
1
+ import { J as PlatformMountContext, P as ExpressPlatformOptions, U as HttpPlatform, Y as PlatformPrepareContext, at as ProxyTrust, n as ApplicationRouteDescriptor, s as AuthRouteBinding } from "./auth-contracts-zvt8ysoZ.cjs";
2
2
  import { AbstractHttpAdapter } from "@nestjs/core";
3
- //#region src/express-platform.d.ts
4
3
  /** Express-specific two-phase HTTP integration. */
5
4
  export declare class ExpressPlatform implements HttpPlatform {
6
5
  #private;
@@ -32,6 +31,5 @@ export declare class ExpressPlatform implements HttpPlatform {
32
31
  private dispatch;
33
32
  }
34
33
  export declare function expressPlatform(options?: ExpressPlatformOptions): ExpressPlatform;
35
- //#endregion
36
34
  export type { ExpressPlatformOptions };
37
35
  //# sourceMappingURL=express.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"express.d.cts","names":[],"sources":["../src/express-platform.ts"],"mappings":";;;;qBAuNa,2BAA2B;;mBAMT;WALpB;EAKT,YAA6B,UAAS;WAE7B;IACP,YAAS;IACT,SAAM;IAEN,MAAG;IACH,UAAO,mBAAoB;IAE3B,UAAO;MAEI;MAA6B;;IAExC,WAAQ;IAER,QAAK,gBAAiB;IAItB,aAAU,kBAAmB;MAMH,SAAA;;;EAM5B,SAAS,SAAS;EAIlB,QAAQ,KAAK;EAkDb,kBACE,iBAAiB,8BACjB,mBAAmB;EAwCrB,MAAM,KAAK;EAmBX,WAAW,SAAS,sBAAsB;UAIlC;UAOA;UAQM;;wBAmCA,gBACd,UAAU,yBACT"}
1
+ {"version":3,"file":"express.d.cts","names":[],"sources":["../src/express-platform.ts"],"mappings":";;;qBAuNa,2BAA2B;;mBAMT;WALpB;EAKoB,YAAA,UAAS;WAE7B;IACY,YAAA;IACH,SAAA;IAEH,MAAA;IACI,UAAA,mBAAU;IAEV,UAAA;;;;IAIC,WAAA;IAEH,QAAA,gBAAO;IAIA,aAAA,kBAAO;MAMH,SAAA;;;EAM5B,SAAS,SAAS;EAIlB,QAAQ,KAAK;EAkDb,kBACE,iBAAiB,8BACjB,mBAAmB;EAwCrB,MAAM,KAAK;EAmBX,WAAW,SAAS,sBAAsB;UAIlC;UAOA;UAQM;;wBAmCA,gBACd,UAAU,yBACT"}
@@ -1,6 +1,5 @@
1
- import { J as PlatformMountContext, P as ExpressPlatformOptions, U as HttpPlatform, Y as PlatformPrepareContext, at as ProxyTrust, n as ApplicationRouteDescriptor, s as AuthRouteBinding } from "./auth-contracts-Cz7C4_Ch.mjs";
1
+ import { J as PlatformMountContext, P as ExpressPlatformOptions, U as HttpPlatform, Y as PlatformPrepareContext, at as ProxyTrust, n as ApplicationRouteDescriptor, s as AuthRouteBinding } from "./auth-contracts-CADGyI0O.mjs";
2
2
  import { AbstractHttpAdapter } from "@nestjs/core";
3
- //#region src/express-platform.d.ts
4
3
  /** Express-specific two-phase HTTP integration. */
5
4
  export declare class ExpressPlatform implements HttpPlatform {
6
5
  #private;
@@ -32,6 +31,5 @@ export declare class ExpressPlatform implements HttpPlatform {
32
31
  private dispatch;
33
32
  }
34
33
  export declare function expressPlatform(options?: ExpressPlatformOptions): ExpressPlatform;
35
- //#endregion
36
34
  export type { ExpressPlatformOptions };
37
35
  //# sourceMappingURL=express.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"express.d.mts","names":[],"sources":["../src/express-platform.ts"],"mappings":";;;;qBAuNa,2BAA2B;;mBAMT;WALpB;EAKT,YAA6B,UAAS;WAE7B;IACP,YAAS;IACT,SAAM;IAEN,MAAG;IACH,UAAO,mBAAoB;IAE3B,UAAO;MAEI;MAA6B;;IAExC,WAAQ;IAER,QAAK,gBAAiB;IAItB,aAAU,kBAAmB;MAMH,SAAA;;;EAM5B,SAAS,SAAS;EAIlB,QAAQ,KAAK;EAkDb,kBACE,iBAAiB,8BACjB,mBAAmB;EAwCrB,MAAM,KAAK;EAmBX,WAAW,SAAS,sBAAsB;UAIlC;UAOA;UAQM;;wBAmCA,gBACd,UAAU,yBACT"}
1
+ {"version":3,"file":"express.d.mts","names":[],"sources":["../src/express-platform.ts"],"mappings":";;;qBAuNa,2BAA2B;;mBAMT;WALpB;EAKoB,YAAA,UAAS;WAE7B;IACY,YAAA;IACH,SAAA;IAEH,MAAA;IACI,UAAA,mBAAU;IAEV,UAAA;;;;IAIC,WAAA;IAEH,QAAA,gBAAO;IAIA,aAAA,kBAAO;MAMH,SAAA;;;EAM5B,SAAS,SAAS;EAIlB,QAAQ,KAAK;EAkDb,kBACE,iBAAiB,8BACjB,mBAAmB;EAwCrB,MAAM,KAAK;EAmBX,WAAW,SAAS,sBAAsB;UAIlC;UAOA;UAQM;;wBAmCA,gBACd,UAAU,yBACT"}
package/dist/express.mjs CHANGED
@@ -1,9 +1,9 @@
1
- import { n as BetterAuthConfigurationError } from "./auth-errors-C3rbTV9p.mjs";
2
- import { a as recoverConsumedBody, c as writeWebResponse, i as readBoundedBody, n as bindAsyncContext, o as toWebHeaders, r as mayHaveBody, t as appendSetCookie } from "./platform-CZl7TY8j.mjs";
1
+ import { n as BetterAuthConfigurationError } from "./auth-errors-JjxGDVSt.mjs";
2
+ import { a as recoverConsumedBody, c as writeWebResponse, i as readBoundedBody, n as bindAsyncContext, o as toWebHeaders, r as mayHaveBody, t as appendSetCookie } from "./platform-BKYVzAv1.mjs";
3
3
  import { IncomingMessage, ServerResponse } from "node:http";
4
4
  import { Readable } from "node:stream";
5
5
  import { parse, pathToRegexp } from "path-to-regexp";
6
- //#region src/express-platform.ts
6
+ // src/express-platform.ts
7
7
  const RAW_BODY = Symbol.for("@nestjs-kit/better-auth:raw-body");
8
8
  function application(adapter) {
9
9
  return adapter.getInstance();
@@ -248,7 +248,6 @@ var ExpressPlatform = class {
248
248
  function expressPlatform(options) {
249
249
  return new ExpressPlatform(options);
250
250
  }
251
- //#endregion
252
251
  export { ExpressPlatform, expressPlatform };
253
252
 
254
253
  //# sourceMappingURL=express.mjs.map
package/dist/fastify.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_platform = require("./platform-YICqqYv6.cjs");
3
- //#region src/fastify-platform.ts
2
+ const require_platform = require("./platform-C67dxSls.cjs");
3
+ // src/fastify-platform.ts
4
4
  function instanceOf(adapter) {
5
5
  return adapter.getInstance();
6
6
  }
@@ -211,7 +211,6 @@ var FastifyPlatform = class {
211
211
  function fastifyPlatform(options) {
212
212
  return new FastifyPlatform(options);
213
213
  }
214
- //#endregion
215
214
  exports.FastifyPlatform = FastifyPlatform;
216
215
  exports.fastifyPlatform = fastifyPlatform;
217
216
 
@@ -1,6 +1,5 @@
1
- import { I as ExtensionRef, J as PlatformMountContext, L as FastifyPlatformOptions, U as HttpPlatform, W as HttpRequestAccessor, Y as PlatformPrepareContext } from "./auth-contracts-Brh_Qko9.cjs";
1
+ import { I as ExtensionRef, J as PlatformMountContext, L as FastifyPlatformOptions, U as HttpPlatform, W as HttpRequestAccessor, Y as PlatformPrepareContext } from "./auth-contracts-zvt8ysoZ.cjs";
2
2
  import { AbstractHttpAdapter } from "@nestjs/core";
3
- //#region src/fastify-platform.d.ts
4
3
  /**
5
4
  * Fastify's encapsulated auth-route platform adapter.
6
5
  *
@@ -23,6 +22,5 @@ export declare class FastifyPlatform implements HttpPlatform {
23
22
  mount(context: PlatformMountContext): Promise<void>;
24
23
  }
25
24
  export declare function fastifyPlatform(options?: FastifyPlatformOptions): ExtensionRef<HttpPlatform>;
26
- //#endregion
27
25
  export type { FastifyPlatformOptions };
28
26
  //# sourceMappingURL=fastify.d.cts.map