# Types

This page lists every TypeScript interface the package exports.

## AuthData

The user data signed into tokens and stored in refresh data.

```typescript
interface AuthData {
  id: string;
  name: string;
  email: string;
  thumbnail?: string;
  level?: number;
  role?: string;
  scope?: string[];
}
```

`id` is passed to `checkUserExists()`. The whole object is serialized into Redis and returned unchanged as `VerifyResult.data` after a refresh.

## VerifyResult

The return value of `VerifyJWT()`; see [Verification Results](/verify-results) for the flags.

```typescript
interface VerifyResult {
  data?: AuthData;
  isAuth: boolean;
  isError: boolean;
  isGuest: boolean;
}
```

## TokenResult

The return value of `CreateJWT()`.

```typescript
interface TokenResult {
  token: string;
  refresh_id: string;
}
```

## RefreshData

The JSON stored at `refresh:<refresh_id>`.

```typescript
interface RefreshData {
  data: AuthData;
  version: number;
  fp: string;
  expires_at: Date;
  issued_at: Date;
}
```

## JWTPayload

The fields of a decoded Access Token: `AuthData` plus `fp` and `refresh_id`. Tokens issued by a refresh also carry `version`.

```typescript
interface JWTPayload {
  id: string;
  name: string;
  email: string;
  thumbnail?: string;
  level?: number;
  role?: string;
  scope?: string[];
  fp: string;
  refresh_id: string;
}
```

## Config

The `init()` argument; see [Configuration](/configuration) for each field and its default.

```typescript
interface Config {
  publicKeyPath?: string;
  privateKeyPath?: string;
  publicKey?: string;
  privateKey?: string;
  accessTokenExpires: number;
  refreshTokenExpires: number;
  isProd: boolean;
  domain?: string;
  redis: {
    host: string;
    port: number;
    password?: string;
    db?: number;
  };
  checkUserExists: (userId: string) => Promise<boolean>;
  AccessTokenCookieKey: string;
  RefreshTokenCookieKey: string;
}
```
