Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sessions #1

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

Sessions #1

wants to merge 4 commits into from

Conversation

haycarlitos
Copy link
Collaborator

Session Management Implementation for Argent Wallets

Overview

This PR implements session management for Argent wallets to enable gasless transactions using AVNU paymaster. The implementation allows users to create and manage sessions that persist across browser sessions, reducing the need for repeated password entry while maintaining security.

Changes

1. wallet.tsx

  • Added session creation during Argent wallet deployment
  • Integrated SessionService to create initial session after successful wallet creation
  • Added storage of session-related data in localStorage
  • Enhanced error handling and logging for session creation
  • Maintained AVNU paymaster integration for deployment

2. SessionService.ts

  • Implemented core session management functionality:
    • createArgentSession: Creates new sessions with 24-hour expiry
    • getArgentSessionAccount: Retrieves and validates existing sessions
    • isSessionExpired: Checks session validity
    • clearSession: Handles session cleanup
  • Added proper private key handling:
    • Conversion between Uint8Array and numeric object format for storage
    • Secure storage of session keys in localStorage
  • Implemented session parameter management:
    • Allowed methods configuration
    • Expiry time handling
    • DappKey generation and storage

3. transactions.tsx

  • Implemented session-based transaction flow:
    • Prioritizes session-based transactions over password-based ones
    • Falls back to password authentication if no valid session exists
  • Enhanced transaction execution:
    • Added AVNU paymaster integration for gasless transactions
    • Improved error handling and logging
    • Added session validation checks
  • Maintained backward compatibility with non-session transactions

Technical Details

  • Session Duration: 24 hours
  • Key Storage: Private keys stored as numeric objects in localStorage
  • Security: Implements proper key conversion and validation
  • Integration: Works with AVNU paymaster for gasless transactions

Testing

  • Tested session creation during wallet deployment
  • Verified session persistence across page reloads
  • Confirmed proper expiry handling

Security Considerations

  • Sessions expire after 24 hours
  • Private keys are properly formatted and stored
  • Maintains compatibility with existing security measures
  • Implements proper validation checks

Next Steps

  • Add session renewal functionality
  • Implement session revocation
  • Add more comprehensive error handling
  • Enhance session security measures

@haycarlitos
Copy link
Collaborator Author

The code does not work at execute increase_counter transaction. I'm getting same error as:
argentlabs/session-keys-example-dapp#8

Perhaps it could be solved using ARGENT_SESSION_SERVICE_BASE_URL like the example:
https://github.com/argentlabs/session-keys-example-dapp/blob/main/src/components/SessionKeysExecute.tsx

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.

1 participant