Skip to content

fix(auth): route helpers through selected providers - #5

Closed
Upd4ting wants to merge 1 commit into
mainfrom
fix/resolver-interface-facades
Closed

fix(auth): route helpers through selected providers#5
Upd4ting wants to merge 1 commit into
mainfrom
fix/resolver-interface-facades

Conversation

@Upd4ting

@Upd4ting Upd4ting commented Aug 25, 2026

Copy link
Copy Markdown
Member

Summary

  • add an interface facade builder for Auth's derived helpers
  • rebuild ValidateRaw, SignRaw, SignServerResponse, CreateAuthDecorator, and Authentication from the consumer's automatically bound internal.Verify and internal.Sign
  • preserve the existing application API and decorator syntax
  • ensure an Authentication() parameter provider invoked later by API keeps the Auth provider selected for the declaring consumer
  • require the interface-core release that provides resolver facades

Bug reproduced

With two Auth providers, the canonical Auth module cannot choose a provider when called outside an active consumer context. The old architecture could therefore pass direct lifecycle calls while failing later:

class Controller {
  handler(@Authentication() user: User) {}
}

Authentication() stores a parameter provider during module evaluation. API invokes it later under API's provider context. Before this change, the default authenticator closed over canonical ValidateRaw, which reached an ambiguous internal.Verify when two Auth providers existed.

The facade builder now creates the same public helpers from the consumer-bound Verify/Sign functions. No HTTP callback or parameter provider is wrapped in an async context.

Validation

  • pnpm lint
  • pnpm build
  • focused Auth facade regression passing
  • Core end-to-end integration with two real consumer modules, two Auth providers, real Auth/API decorators, an async boundary, and deferred parameter-provider invocation passing
  • canonical Auth call in that same regression still fails with AmbiguousProviderError, proving the test exercises provider selection rather than a single-provider side effect
  • registered HTTP callbacks remain strict-equal
  • git diff --check

Release ordering

Publish interface-core and Core first, then release this package alongside/after interface-api #17. No package is published by this PR.

Greptile Summary

The PR adds an Auth interface-facade builder so derived signing, verification, response, and decorator helpers retain the provider selected for each consumer.

  • Rebuilds public authentication helpers from consumer-bound internal.Verify and internal.Sign.
  • Preserves the existing authentication pipeline while injecting the bound request-time authentication handler into deferred parameter providers.
  • Raises the minimum Interface Core version to the release providing resolver facades.
  • Adds a two-provider regression test covering deferred authentication after an async boundary.

Confidence Score: 5/5

The PR appears safe to merge with no concrete blocking or independently actionable non-blocking issue identified.

The rebuilt helpers consistently close over the consumer-bound Verify and Sign functions, preserve the source-verifier-validator pipeline, and are covered by a deferred two-provider regression.

Important Files Changed

Filename Overview
src/index.ts Adds the facade builder and factors helper construction so signing, verification, and deferred decorator providers use consumer-bound interface functions.
src/tests/interface-facade.test.ts Adds regression coverage for two Auth providers, deferred API parameter-provider execution, an async boundary, and preservation of callback identity.
package.json Raises the Interface Core development and peer dependency floor to 0.0.13 for resolver-facade support.
pnpm-lock.yaml Updates the resolved Interface Core dependency and Interface API peer snapshot to 0.0.13.

Sequence Diagram

sequenceDiagram
    participant Consumer
    participant Core as Interface Core
    participant Facade as Auth Facade
    participant API as Deferred API Provider
    participant Auth as Selected Auth Provider
    Consumer->>Core: CreateInterfaceFacade(Auth, context)
    Core->>Facade: BuildInterfaceFacade(scope, bound exports)
    Consumer->>Facade: Authentication()
    Facade->>API: Register parameter provider
    API->>Facade: Invoke provider during request
    Facade->>Auth: Bound Verify(token, options)
    Auth-->>Facade: Verified payload
    Facade-->>API: Authenticated handler value
Loading

Reviews (1): Last reviewed commit: "fix(auth): route helpers through selecte..." | Re-trigger Greptile

Co-authored-by: Upd4ting <upd4ting@gmail.com>

Copy link
Copy Markdown
Member Author

Closed at Upd4ting's request: the Core 1.5 / multi-provider train is deferred and will be restarted manually later. This PR contains only work for that train; no independent fix is being retained. Do not merge or publish artifacts from this branch. Any future implementation should start from the then-current main branches and released package graph.

@Upd4ting Upd4ting closed this Aug 27, 2026
@Upd4ting
Upd4ting deleted the fix/resolver-interface-facades branch August 27, 2026 21:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants