Skip to content

Conversation

@tarrencev
Copy link
Contributor

Summary

  • Add headless authentication API to controller SDK that allows programmatic user signup/login without displaying the modal
  • Extend existing connect() method to infer headless mode when both username and authMethod are provided
  • Maintain full backward compatibility with existing modal-based authentication flow
  • Add infrastructure for supporting multiple auth methods (WebAuthn, MetaMask, Rabby, WalletConnect)

Key Changes

  • Controller SDK: Extended connect() method with optional ConnectOptions parameter
  • Type System: Added ConnectOptions interface and updated Keychain interface
  • Keychain: Added headless connection handling and HeadlessConnect component
  • Auto-detection: System automatically detects signup vs login by querying username existence

API Usage

// Headless authentication (inferred from parameters)
const account = await controller.connect({
  username: "alice",
  authMethod: "metamask"
});

// Traditional modal (unchanged)
const account = await controller.connect();

Test Plan

  • TypeScript compilation passes for both controller and keychain packages
  • Linting and formatting checks pass
  • Backward compatibility maintained - existing connect() calls work unchanged
  • Infrastructure in place for headless authentication flow
  • Integration testing with actual auth methods (future work)
  • End-to-end testing with example applications

Implementation Status

✅ Core infrastructure and API design complete
🚧 Individual auth method implementations need completion in HeadlessConnect component

🤖 Generated with Claude Code

@vercel
Copy link

vercel bot commented Sep 3, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Updated (UTC)
controller-example-next Ready Ready Preview Sep 18, 2025 8:29pm
controller-example-next-compat Ready Ready Preview Sep 18, 2025 8:29pm
keychain Ready Ready Preview Sep 18, 2025 8:29pm
keychain-storybook Ready Ready Preview Sep 18, 2025 8:29pm

cursor[bot]

This comment was marked as outdated.

tarrencev and others added 4 commits September 18, 2025 15:11
- Add ConnectOptions interface with username and authMethod
- Extend connect() method to infer headless mode from parameters
- Update Keychain interface to support headless connection requests
- Add HeadlessConnect component for programmatic authentication
- Modify Home component to handle headless flows
- Maintain full backward compatibility with existing modal flow
- Add comprehensive documentation and examples

This allows applications to authenticate users programmatically without
displaying the modal interface by providing username and authMethod:

  await controller.connect({
    username: 'alice',
    authMethod: 'metamask'
  });

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Implement MetaMask, Rabby, and WalletConnect headless authentication
- Add proper signup/login flow detection and handling
- Use existing authentication hooks for consistent behavior
- Add clear error messages for unsupported methods (WebAuthn, social)
- Create HeadlessAuth example component in Next.js app
- Maintain backward compatibility with existing modal flow

Supported headless methods:
- metamask: External wallet connection
- rabby: External wallet connection
- walletconnect: Cross-platform wallet protocol

Note: WebAuthn and social logins require user interaction and are
not supported in headless mode.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
….js example

- Fix incorrect @cartridge/ui component imports to use main export
- Use ControllerConnector.fromConnectors pattern for headless auth
- Remove unused connect variable to resolve linting error

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
Fixes TypeScript compilation error by importing useConnection from @/hooks/connection

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Updated HeadlessConnect component to use handleSubmit from useCreateController
- Fixed issue where controller wasn't being created after MetaMask authentication
- Removed unused imports and simplified the authentication flow
- Controller is now properly set on window object after successful auth

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
address: controller.address(),
});
}
}, [controller, context]);
Copy link

Choose a reason for hiding this comment

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

Bug: Race Condition in Context Resolution

The component has two useEffect hooks that can independently resolve the ConnectCtx promise: one for handleHeadlessAuth errors and another for controller availability. This creates a race condition, potentially resolving the context prematurely or incorrectly, bypassing the intended authentication flow.

Fix in Cursor Fix in Web

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