Creates and connects a wallet and authenticates the user with the Treasure Connect login system.

Usage

import { logIn } from "@treasure-dev/tdk-core";

// const client = ...

const { user, tdk } = await logIn({
  client,
  ecosystemPartnerId: "...",
  method: "email",
  email: "example@treasure.lol",
  verificationCode: "123456",
});

Props

client

TreasureConnectClient

apiUri

string | undefined

  • The TDK API URI to use for all HTTP requests.
  • Defaults to "https://tdk-api.treasure.lol".
  • Development environment value is "https://tdk-api.spellcaster.lol".

chainId

number | undefined

  • The chain ID to use for initial connection.
  • Defaults to 42161 (Arbitrum One).

ecosystemId

string | undefined

  • The ecosystem ID for the ecosystem wallets.
  • Defaults to "ecosystem.treasure".

ecosystemPartnerId

string

  • The ecosystem partner ID for the ecosystem wallets.

method

"email" | "passkey" | "auth_endpoint" | "google" | "apple" | "discord" | "telegram" | "x"

  • Desired login method.

authMode

"popup" | "redirect" | "window" | undefined

  • Determines the authentication mode for SSO login methods.
  • Defaults to "popup".

redirectUrl

string | undefined

  • Optional URL to redirect to after SSO login.

email

string | undefined

  • Email address to use for login.
  • Required if mode is "email".

verificationCode

string | undefined

passkeyName

string | undefined

  • Optional name of the passkey to create.
  • Defaults to a generated name

passkeyDomain

string | undefined

  • The domain of the passkey to use for authentication.

payload

string | undefined

  • JSON stringified payload to send to the custom auth endpoint.
  • Required if mode is "auth_endpoint".

sessionOptions

SessionOptions | undefined

  • Options for creating user sessions, if using account abstraction.