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

# Browser / WASM

> Browser WebAssembly initialization, stateless operations, and provider-backed limitations.

## Initialize the module

Call `init` once before using another operation.

```javascript theme={null}
import { init, scan, scanAndTransform, transform } from "@datafog/wasm";

await init();
```

## Operations

```typescript theme={null}
scan(text: string, config?: ScanConfig): Finding[]
transform(
  text: string,
  findings: FindingInput[],
  config: TransformationConfig,
): TransformResult
scanAndTransform(text: string, config: ScanAndTransformConfig): TransformResult
```

The browser binding supports the stateless `redact`, `mask`, and `remove`
strategies.

## JavaScript-native ranges

Findings contain `utf16Range`. Transformation records contain
`sourceUtf16Range` and `outputUtf16Range`. These zero-based, end-exclusive
ranges work directly with `String.prototype.slice`.

## Unsupported provider operations

Browser/WASM does not accept key or token providers. It returns
`unsupported_strategy` when pseudonymization or tokenization is selected and
for every restoration call.

This is an intentional security boundary, not a missing fallback. Provider
credentials and key custody require a separately designed host integration.

## Errors

The JavaScript wrapper throws `DataFogError` with the same stable fields as the
Node.js binding. See [Errors](/reference/errors).

## Structured JSON and PERSON fields

Use `discoverFields(data, config?)`, `scanStructured(data, config?)`,
`transformStructured(data, findings, config)`, and
`scanAndTransformStructured(data, config)`. Scan returns `{ mappings, findings }`;
transformation returns `{ data, transformations }`. Located findings contain
`path` and `finding`; located records contain `path` and `transformation`.
Call `await init()` first. Selected provider-backed strategies and
`restoreStructured` reject with `unsupported_strategy`.

Paths are JSON Pointers. All ranges, including JavaScript UTF-16 ranges,
address the decoded string at that path. See [person-field discovery](/guides/person-discovery)
for aliases, policy configuration, input limits, and examples.
