> ## Documentation Index
> Fetch the complete documentation index at: https://docs.magic.link/llms.txt
> Use this file to discover all available pages before exploring further.

# TypeScript Types

## Overview

Below are the most common types in Magic's TypeScript SDK, separated by module.

To view all supported types, feel free to explore the [Magic SDK repo](https://github.com/magiclabs/magic-js/tree/master/packages/%40magic-sdk/types/src).

## User Module

### `MagicUserMetadata`

```typescript TypeScript icon="square-js" theme={null}

export interface MagicUserMetadata {
  issuer: string | null;
  publicAddress: string | null;
  email: string | null;
  phoneNumber: string | null;
  isMfaEnabled: boolean;
  recoveryFactors: [RecoveryFactor];
}
```

### `RecoveryMethodType`

```typescript TypeScript icon="square-js" theme={null}
export enum RecoveryMethodType {
  PhoneNumber = 'phone_number',
}
```

### `RecoveryFactor`

```typescript TypeScript icon="square-js" theme={null}
type RecoveryFactor = {
  type: RecoveryMethodType;
  value: string;
};
```

### `GetIdTokenConfiguration`

```typescript TypeScript icon="square-js" theme={null}
export interface GetIdTokenConfiguration {
  /*
   * The number of seconds until the generated ID token will expire.
   */
  lifespan?: number;
}
```

### `GenerateIdTokenConfiguration`

```typescript TypeScript icon="square-js" theme={null}
export interface GenerateIdTokenConfiguration extends GetIdTokenConfiguration {
  /*
   * An optional piece of data to sign with the token. Note, however, that the
   * unsigned data _will not_ be encoded in the token, only an encrypted
   * signature of the data.
   */
  attachment?: string;
}
```

### `UpdateEmailConfiguration`

```typescript TypeScript icon="square-js" theme={null}
export interface UpdateEmailConfiguration {
  /*
   * The new email address to update to
   */
  email: string;

  /*
   * When `true`, a pre-built pending modal interface will
   * guide the user to check their new, followed by old emails
   * for confirmation emails.
  */
  showUI?: boolean;
  }
```

### `RecoverAccountConfiguration`

```typescript TypeScript icon="square-js" theme={null}
export interface RecoverAccountConfiguration {
  /*
   * The email to recover
   */
  email: string;
}
```

### `ShowSettingsConfiguration`

```typescript TypeScript icon="square-js" theme={null}
export interface ShowSettingsConfiguration {
  /*
   * deep linking destination
   */
  page: DeepLinkPage;
}
```

## Wallet Module

### `GasApiResponse`

```typescript TypeScript icon="square-js" theme={null}
export type GasApiResponse = {
  request_id: string;
  state: string;
  success: boolean;
};
```

### `AccessListEntry`

```typescript TypeScript icon="square-js" theme={null}
export type AccessListEntry = { address: string; storageKeys: Array<string> };
```

### `AccessList`

```typescript TypeScript icon="square-js" theme={null}
export type AccessList = Array<AccessListEntry>;
```

## Auth Module

### `LoginWithSmsConfiguration`

```typescript TypeScript icon="square-js" theme={null}
export interface LoginWithSmsConfiguration {
  /*
   * Specify the phone number of the user attempting to login.
   */
  phoneNumber: string;
}
```

### `LoginWithEmailOTPConfiguration`

```typescript TypeScript icon="square-js" theme={null}
export interface LoginWithEmailOTPConfiguration {
  /*
   * Specify the email address of the user attempting to login.
   */
  email: string;

  /*
  * When `true`, a pre-built modal interface will show to the user, directing
  * them to check their email for the one time passcode (OTP) to complete their
  * authentication.
  *
  * When `false`, developers will be able to implement their own custom UI to
  * continue the email OTP flow.
  */
  showUI?: boolean;

  /*
  * Device Unrecognized UI will enforce showing up to secure user's login
  *
  * When set to true (default), an improved device recognition UI will be displayed to the user,
  * prompting them to verify their login by checking their email for device approval. This feature
  * enhances authentication security.
  *
  * This param will only be affect if showUI is false. When set to false,
  * developers have the flexibility to implement their own customized UI to
  * handle device check events, providing a more tailored user experience.
  */
  deviceCheckUI?: boolean;

  /*
  * Enterprise users with a custom SMTP can create custom email templates
  * from their dashboard. The default Magic loginWithOTP email will be
  * overriden when a variation is passed here.
  */
  overrides?: {
  variation?: string;
  };
}
```

### EventHandlers

```typescript TypeScript icon="square-js" theme={null}
export type LoginWithMagicLinkEventHandlers = {
  // Event Received
  [LoginWithMagicLinkEventOnReceived.EmailSent]: () => void;
  [LoginWithMagicLinkEventOnReceived.EmailNotDeliverable]: () => void;

  // Event sent
  [LoginWithMagicLinkEventEmit.Retry]: () => void;
} & DeviceVerificationEventHandlers;

export type LoginWithEmailOTPEventHandlers = {
  // Event Received
  [LoginWithEmailOTPEventOnReceived.EmailOTPSent]: () => void;
  [LoginWithEmailOTPEventOnReceived.InvalidEmailOtp]: () => void;
  [LoginWithEmailOTPEventOnReceived.ExpiredEmailOtp]: () => void;

  // Event sent
  [LoginWithEmailOTPEventEmit.VerifyEmailOtp]: (otp: string) => void;
  [LoginWithEmailOTPEventEmit.Cancel]: () => void;
} & DeviceVerificationEventHandlers;

type DeviceVerificationEventHandlers = {
  // Event Received
  [DeviceVerificationEventOnReceived.DeviceNeedsApproval]: () => void;
  [DeviceVerificationEventOnReceived.DeviceVerificationEmailSent]: () => void;
  [DeviceVerificationEventOnReceived.DeviceVerificationLinkExpired]: () => void;
  [DeviceVerificationEventOnReceived.DeviceApproved]: () => void;

  // Event sent
  [DeviceVerificationEventEmit.Retry]: () => void;
};
```

### Auth Events Enum

```typescript TypeScript icon="square-js" theme={null}
export enum LoginWithMagicLinkEventEmit {
  Retry = 'retry',
}

export enum LoginWithMagicLinkEventOnReceived {
  EmailSent = 'email-sent',
  EmailNotDeliverable = 'email-not-deliverable',
}

export enum LoginWithEmailOTPEventEmit {
  VerifyEmailOtp = 'verify-email-otp',
  Cancel = 'cancel',
}

export enum LoginWithEmailOTPEventOnReceived {
  EmailOTPSent = 'email-otp-sent',
  InvalidEmailOtp = 'invalid-email-otp',
  ExpiredEmailOtp = 'expired-email-otp',
}

export enum DeviceVerificationEventEmit {
  Retry = 'device-retry',
}

export enum DeviceVerificationEventOnReceived {
  DeviceApproved = 'device-approved',
  DeviceNeedsApproval = 'device-needs-approval',
  DeviceVerificationLinkExpired = 'device-verification-link-expired',
  DeviceVerificationEmailSent = 'device-verification-email-sent',
}
```

## NFT Module

### `NFTPurchaseRequest`

```typescript TypeScript icon="square-js" theme={null}
export interface NFTPurchaseRequest {
  nft: {
    name: string;
    imageUrl: string;
    blockchainNftId: string;
    contractAddress: string;
    network: string;
    platform: string;
    type: string;
  };
  identityPrefill: {
    firstName: string;
    lastName: string;
    dateOfBirth: string; // YYYY-MM-DD
    emailAddress: string;
    phone: string;
    address: {
      street1: string;
      street2: string;
      city: string;
      regionCode: string;
      postalCode: string;
      countryCode: string;
    };
  };
}
```

### `NFTCheckoutRequest`

```typescript TypeScript icon="square-js" theme={null}
export interface NFTCheckoutRequest {
  // given by magic / found in the developer dashboard in future
  contractId: string;
  // in contract, if ERC1155… for ERC721, use token ID = 0
  tokenId: string;
  name: string;
  imageUrl: string;
  quantity?: number; // default is 1
  walletAddress?: string; // default is user's wallet address
}
```

### `NFTTransferRequest`

```typescript TypeScript icon="square-js" theme={null}
export interface NFTTransferRequest {
  tokenId: string;
  contractAddress: string;
  quantity?: number;
  recipient?: string;
}
```

### Responses and `ResponseStatus`

```typescript TypeScript icon="square-js" theme={null}
export type NFTResponseStatus = 'cancelled' | 'processed' | 'declined' | 'expired';

export type NFTResponse = {
  status: NFTResponseStatus;
};

export type NFTPurchaseResponse = NFTResponse & {
  errorMessage?: string;
};

export type NFTCheckoutResponse = NFTResponse;

export type NFTTransferResponse = NFTResponse;
```

## Resources

* [Magic Types](https://github.com/magiclabs/magic-js/tree/master/packages/%40magic-sdk/types/src)
