Skip to content

getAuthDetails

getAuthDetails returns the details about the authenticated user, in accordance with the Magic web SDK's specifications.

This method must be called after authenticate. Otherwise, this method will throw an error with the message Not Authenticated.

Usage

ts
import { createMagicSigner } from "./magic";

const magicSigner = await createMagicSigner();

const details = await magicSigner.getAuthDetails();
ts
import { MagicSigner } from "@alchemy/aa-signers/magic";

// this is generated from the [Magic Dashboard](https://dashboard.magic.link/)
const MAGIC_API_KEY = "pk_live_...";

export const createMagicSigner = async () => {
  const magicSigner = new MagicSigner({ apiKey: MAGIC_API_KEY });

  await magicSigner.authenticate({
    authenticate: async () => {
      await magicSigner.inner.wallet.connectWithUI();
    },
  });

  return magicSigner;
};

Returns

Promise<MagicUserMetadata>

A Promise containing the MagicUserMetadata, and object with the following fields:

  • issuer: string | null -- the Decentralized ID of the user.
  • publicAddress: string | null -- the authenticated user's public address (EOA public key).
  • email: string | null -- email address of the authenticated user.
  • phoneNumber: string | null -- phone number of the authenticated user.
  • isMfaEnabled: boolean -- whether or not multi-factor authentication is enabled for the user.
  • recoveryFactors: RecoveryFactor[] -- any recovery methods that have been enabled (ex. [{ type: 'phone_number', value: '+99999999' }]).