import {Meta} from '@storybook/addon-docs/blocks'

<Meta title='@dxtmisha/en/figma/Classes/FigmaPostCode - Message Verification'/>

# FigmaPostCode Class

A utility class for managing a unique verification code used for message integrity between the Figma plugin (backend) and its UI (frontend). This ensures that messages received by one side were indeed sent by the other side of the same plugin session.

## Key Features

- **Security** — Prevents cross-plugin message interference.
- **Session Locking** — The code can only be set once per session, ensuring consistency.
- **Auto-generation** — A random code is generated by default (e.g., `figma-123456`) if not set manually.

## Static Methods

- `is(code: string): boolean` — Checks if the provided code matches the current post code.
- `get(): string` — Returns the current post code.
- `set(code: string): void` — Sets a new post code. Can only be successfully called once.

## Recommendation

For stable and unique verification, it is recommended to use the `id` from your plugin's `manifest.json`.

```typescript
import manifest from '../manifest.json'
import { FigmaPostCode } from '@dxtmisha/figma'

// Set the post code using the plugin's unique ID from manifest
FigmaPostCode.set(manifest.id)
```
