npm package: @percent20/misuto-react-native-sdk
Description: React Native SDK for AirVaults location-based vault system
Latest version: 0.2.0

# @percent20/misuto-react-native-sdk

React Native SDK for AirVaults location-based vault system.

## Install

```bash
npm install @percent20/misuto-react-native-sdk
# or
yarn add @percent20/misuto-react-native-sdk
```

## Quick Start

Wrap your app with `MisutoProvider`:

```tsx
import { MisutoProvider } from '@percent20/misuto-react-native-sdk';

function App() {
  return (
    <MisutoProvider
      apiKey="em_live_abc123..."
      config={{ baseUrl: 'https://api.percent-20.com/api/v2' }}
    >
      <YourApp />
    </MisutoProvider>
  );
}
```

Discover nearby vaults:

```tsx
import { useVaultDiscovery } from '@percent20/misuto-react-native-sdk';

function VaultList() {
  const { vaults, isPolling, start, stop } = useVaultDiscovery();

  return <FlatList data={vaults} renderItem={({ item }) => <Text>{item.name}</Text>} />;
}
```

## V3: Client-Side Vault Hashing

V3 moves hash computation to the client. Raw signals never leave the device.

### Generate hashes

```typescript
import { buildVaultHashes } from '@percent20/misuto-react-native-sdk';

const hashes = buildVaultHashes({
  geohash: 'sv8wrqpg5',
  radius: 100,
  altitude: 42,
  heading: 180,
  hourRange: [9, 17],
  salt: 'hashed-device-salt',
  pepper: 'hashed-device-pepper',
  wifiSsids: ['OfficeWiFi', 'GuestNet'],
  bleDeviceNames: ['Beacon-A'],
  objectDetection: ['laptop'],
  freeText: 'secret-phrase',
  nfcTagIds: ['TAG-001'],
});
```

### Create vault via V3

```typescript
import { MisutoClient } from '@percent20/misuto-react-native-sdk';

const client = MisutoClient.init({ apiKey: 'em_live_abc123...' });

const result = await client.vaults.createV3({
  name: 'My Private Vault',
  engine: 'storage',
  vault_hashes: hashes,
  radius: 100,
  payload: { description: 'Docs vault' },
});

console.log('Created vault:', result.uid);
```

### V2 vs V3

|                  | V2                            | V3                            |
| ---------------- | ----------------------------- | ----------------------------- |
| Hash computation | Server                        | Client (SDK)                  |
| Data sent        | Raw signals                   | SHA256 hashes only            |
| Endpoint         | `POST /api/v2/clients/vaults` | `POST /api/v3/clients/vaults` |
| Discovery        | Unchanged                     | Unchanged                     |

### Geohash utilities

The SDK includes a full `Geohash` class for advanced use:

```typescript
import { Geohash, encodeGeohash } from '@percent20/misuto-react-native-sdk';

// Encode coordinates to geohash
const hash = encodeGeohash(32.0853, 34.7818, 9);

// Generate optimized geohashes for a radius
const cells = Geohash.generateOptimizedGeohashes('sv8wrqpg5', 100);

// Distance between two points (meters)
const dist = Geohash.distanceBetween(32.08, 34.78, 32.09, 34.79);
```

## API Reference

### Vault Operations

```typescript
// List vaults
const { vaults, pagination } = await client.vaults.list({ page: 1, per_page: 25 });

// Get vault details
const vault = await client.vaults.get('vault-uid');

// Create vault (V2 - server-side hashing)
const v2Result = await client.vaults.create({
  name: 'My Vault',
  engine: 'storage',
  geohash: 'sv8wrqpg5',
  radius: 100,
});

// Create vault (V3 - client-side hashing)
const v3Result = await client.vaults.createV3({
  name: 'My Vault',
  engine: 'storage',
  vault_hashes: buildVaultHashes({ geohash: 'sv8wrqpg5', radius: 100 }),
  radius: 100,
});

// Delete vault
await client.vaults.delete('vault-uid');
```

### Beacon Operations

```typescript
// List beacons for a vault
const { beacons } = await client.beacons.list('vault-uid');

// Create beacon
const beacon = await client.beacons.create('vault-uid', {
  type: 'wormhole',
  name: 'Access Link',
});
```

## Documentation

Full documentation: [https://docs.airvaults.io](https://docs.airvaults.io)