Skip to content

fix(factory): add clearPendingVerifierByName to createAuthService proxy#45

Open
nicknisi wants to merge 2 commits into
mainfrom
fix/issue-44
Open

fix(factory): add clearPendingVerifierByName to createAuthService proxy#45
nicknisi wants to merge 2 commits into
mainfrom
fix/issue-44

Conversation

@nicknisi

Copy link
Copy Markdown
Member

Summary

The proxy object returned by createAuthService() in src/service/factory.ts was missing the clearPendingVerifierByName delegation, causing the method to be undefined at runtime despite TypeScript's type assertion saying it exists. This adds the missing delegation entry so adapters can safely call clearPendingVerifierByName() as documented.

What was tested

Automated

  • Full test suite: 271 tests passing
  • Typecheck: clean
  • New assertion added in factory.spec.ts confirming typeof service.clearPendingVerifierByName is 'function'

Manual

  • Scenario script reproducing the exact minimal check from issue v0.6.0 - createAuthService() proxy does not expose clearPendingVerifierByName #44:
    • typeof service.clearPendingVerifierByName'function' (PASS with fix)
    • Reverted factory.ts to maintypeof service.clearPendingVerifierByName'undefined' (FAIL confirms the bug)
  • Verified all 14 proxy methods remain functions (no other methods inadvertently broken)

Manual reproduction steps

  1. On main, create a script that imports createAuthService and checks typeof service.clearPendingVerifierByName:

    import { createAuthService } from '@workos/authkit-session';
    
    const service = createAuthService({
      sessionStorageFactory: () => ({
        getCookie: async () => null,
        setCookie: async () => ({}),
        clearCookie: async () => ({}),
        getSession: async () => null,
        saveSession: async () => ({}),
        clearSession: async () => ({})
      })
    });
    
    console.log('typeof clearPendingVerifierByName:', typeof service.clearPendingVerifierByName);
    // On main: 'undefined' (BUG)
    // On this branch: 'function' (FIXED)
  2. Run pnpm build && node script.mjs (or tsx script.ts)

  3. On main: observe undefined — the method is missing from the proxy

  4. On fix/issue-44: observe 'function' — the delegation is present

Verification

This is a library fix (no UI). Verification was performed via automated tests and a scenario script that reproduces the exact runtime check from issue #44. The revert test confirms the bug exists on main and is resolved on this branch.

Issue

Closes #44

Follow-ups

None — the fix is a minimal 3-line addition following the identical delegation pattern used by all other methods in the proxy.

The proxy object returned by createAuthService() was missing the
clearPendingVerifierByName method, causing it to be undefined at runtime
despite TypeScript reporting it as available. This prevented adapters
from safely clearing stale PKCE verifier cookies by name.

Closes #44

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Open in Devin Review

@greptile-apps

greptile-apps Bot commented Jun 16, 2026

Copy link
Copy Markdown

Greptile Summary

  • Adds the missing clearPendingVerifierByName delegation to the lazy createAuthService() proxy.
  • Extends the factory tests to assert the proxy exposes the expected delegated methods, including clearPendingVerifierByName.

Confidence Score: 5/5

The change is a narrow factory proxy delegation fix with direct test coverage.

The modified code follows the existing delegation pattern and the added test checks that the proxy exposes the expected method.

T-Rex T-Rex Logs

What T-Rex did

  • Ran a pre-change runtime state check to inspect the typeof values for clearPendingVerifierByName, switchOrganization, and refreshSession.
  • Ran a post-change runtime state check to verify that clearPendingVerifierByName is a function and all documented proxy methods in TYPEOF_VALUES are functions.
  • Both runtime executions completed successfully with exit code 0 and logs were captured for review.

View all artifacts

T-Rex Ran code and verified through T-Rex

Reviews (2): Last reviewed commit: "Update src/service/factory.spec.ts" | Re-trigger Greptile

Comment thread src/service/factory.spec.ts
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
@nicknisi nicknisi requested a review from gjtorikian June 18, 2026 13:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

v0.6.0 - createAuthService() proxy does not expose clearPendingVerifierByName

1 participant