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

# Result Types

> TypeScript result types for MagenX404

## X404AuthResult

All authentication features return an `X404AuthResult`:

```typescript theme={null}
interface X404AuthResult {
  success: boolean;
  alreadyAuthenticated?: boolean;
  token?: string;
  data?: unknown;
  error?:
    | "NONCE_ERROR"
    | "SIGNING_ERROR"
    | "LOCATION_ERROR"
    | "LOCATION_DENIED"
    | "HOLDS_BANNED_TOKEN"
    | "EXCEEDS_MAX_HOLDING"
    | "INSUFFICIENT_HOLD_DURATION"
    | "INSUFFICIENT_TOKENS"
    | "INSUFFICIENT_ACTIVITY"
    | "HAS_DEBT"
    | "WALLET_TOO_NEW"
    | "WALLET_CANCELLED"
    | "UNKNOWN_ERROR";
  message?: string;
  tier?: "bronze" | "silver" | "gold";
}
```

## Field Descriptions

<ResponseField name="success" type="boolean" required>
  Whether authentication was successful
</ResponseField>

<ResponseField name="alreadyAuthenticated" type="boolean">
  Whether user was already authenticated (token exists in localStorage)
</ResponseField>

<ResponseField name="token" type="string">
  JWT token (if successful). Automatically stored in localStorage
</ResponseField>

<ResponseField name="data" type="unknown">
  Additional data returned from the server
</ResponseField>

<ResponseField name="error" type="string">
  Error type if authentication failed
</ResponseField>

<ResponseField name="message" type="string">
  Human-readable error message
</ResponseField>

<ResponseField name="tier" type="'bronze' | 'silver' | 'gold'">
  User's tier (only for X404Tier feature)
</ResponseField>

## Success Example

```typescript theme={null}
{
  success: true,
  token: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
  alreadyAuthenticated: false
}
```

## Error Example

```typescript theme={null}
{
  success: false,
  error: "HOLDS_BANNED_TOKEN",
  message: "Wallet holds excluded token: token_address"
}
```

## Usage

```typescript theme={null}
import { X404Blacklist } from "magenx404";

const result = await X404Blacklist({
  excluded_mints: ["token_address"],
  max_holdings: {},
  geo_code: "false",
  geo_code_locs: "",
  coords: { latitude: null, longitude: null },
});

if (result.success) {
  console.log("Token:", result.token);
} else {
  console.error("Error:", result.error, result.message);
}
```

## Error Types

All authentication functions can return the following error types:

<ErrorField name="NONCE_ERROR">Failed to get nonce from server</ErrorField>

<ErrorField name="SIGNING_ERROR">
  Failed to sign authentication challenge
</ErrorField>

<ErrorField name="WALLET_CANCELLED">User cancelled wallet selection</ErrorField>

<ErrorField name="LOCATION_ERROR">Geolocation access error</ErrorField>

<ErrorField name="LOCATION_DENIED">Access denied for location</ErrorField>

<ErrorField name="INSUFFICIENT_TOKENS">
  User doesn't meet token requirements
</ErrorField>

<ErrorField name="INSUFFICIENT_HOLD_DURATION">
  Tokens not held long enough
</ErrorField>

<ErrorField name="INSUFFICIENT_ACTIVITY">
  User doesn't meet activity requirements
</ErrorField>

<ErrorField name="HOLDS_BANNED_TOKEN">User holds excluded tokens</ErrorField>

<ErrorField name="EXCEEDS_MAX_HOLDING">User exceeds max holdings</ErrorField>

<ErrorField name="HAS_DEBT">User has outstanding debts</ErrorField>

<ErrorField name="WALLET_TOO_NEW">
  Wallet doesn't meet age requirements
</ErrorField>

<ErrorField name="UNKNOWN_ERROR">Unexpected error</ErrorField>

## Token Storage

Each feature automatically stores its JWT token in localStorage with the following keys:

* `sjwt404_timelock` - Timelock feature
* `sjwt404_blacklist` - Blacklist feature
* `sjwt404_multitoken` - MultiToken feature
* `sjwt404_activity` - Activity feature
* `sjwt404_tier` - Tier feature
* `sjwt404_nodebt` - NoDebt feature
* `sjwt404_age` - Age feature

Tokens persist across sessions and are automatically checked on subsequent authentication attempts.
