CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-supabase--supabase-js

Isomorphic JavaScript client for Supabase providing authentication, database, real-time, storage, and edge functions capabilities.

89

0.95x
Overview
Eval results
Files

task.mdevals/scenario-3/

User Authentication Service

Build a user authentication service that supports user registration and login with email/password credentials.

Requirements

Implement the following functionality:

  1. User Registration

    • Create a function that accepts an email and password
    • Register the user in the authentication system
    • Return the user data and session information upon successful registration
    • Handle any errors that may occur during registration
  2. User Login

    • Create a function that accepts an email and password
    • Authenticate the user with the provided credentials
    • Return the user data and session information upon successful login
    • Handle any errors that may occur during login
  3. Session Retrieval

    • Create a function that retrieves the current authenticated user's session
    • Return the session data if available, or null if no active session exists
  4. User Sign Out

    • Create a function that signs out the current user
    • End the user's session

Technical Details

  • The authentication service should be initialized with a URL and API key
  • All functions should return structured responses that include both data and error information
  • Handle edge cases such as invalid credentials, existing users, and network errors

Dependencies { .dependencies }

@supabase/supabase-js { .dependency }

Provides authentication and backend services support.

Test Cases

Test 1: User Registration { .test }

File: auth.test.ts

Input:

email: "newuser@example.com"
password: "SecurePass123!"

Expected behavior:

  • The registration function should successfully create a new user
  • Should return a response containing user data (with at least an email field)
  • Should return a response containing session data (with at least an access token)

Test 2: User Login { .test }

File: auth.test.ts

Input:

email: "existinguser@example.com"
password: "MyPassword456!"

Expected behavior:

  • The login function should successfully authenticate the user
  • Should return a response containing user data
  • Should return a response containing session data with access token

Test 3: Invalid Login { .test }

File: auth.test.ts

Input:

email: "user@example.com"
password: "WrongPassword"

Expected behavior:

  • The login function should handle the error gracefully
  • Should return a response with an error indicating invalid credentials
  • Should not return user or session data

Notes

  • You do not need to set up a real backend - focus on implementing the client-side authentication logic
  • Ensure all functions handle errors appropriately and return consistent response structures
  • The implementation should be straightforward for someone familiar with authentication libraries

Install with Tessl CLI

npx tessl i tessl/npm-supabase--supabase-js

tile.json