npm package: @sharddog/approve
Description: ShardDog Approve — on-chain human-in-the-loop approval stamps for AI-generated content
Latest version: 0.1.0

# @sharddog/approve

On-chain human-in-the-loop approval stamps for AI-generated content. Built on [ShardDog](https://shard.dog) + NEAR Protocol.

## Install

```bash
npm install @sharddog/approve
```

## Quick Start

```typescript
import { SharddogApprove } from '@sharddog/approve'

const approve = new SharddogApprove({ apiKey: 'your_api_key' })

// Stamp approval on AI-generated content
const stamp = await approve.stamp({
  content: 'The full text of your AI report...',
  label: 'Q1 Financial Summary',
  reviewer: 'alice.near',
  metadata: {
    ai_model: 'claude-opus-4',
    category: 'report',
  }
})

console.log(stamp.verification_url) // https://shard.dog/approve/abc123...
console.log(stamp.status)           // 'minted' (on-chain) or 'stamped' (DB only)

// Verify content was approved
const result = await approve.verify('abc123...')
if (result.approved) {
  console.log(`Approved by ${result.stamps[0].reviewer} at ${result.stamps[0].timestamp}`)
}

// Get reviewer's history
const history = await approve.history('alice.near')
console.log(`${history.total} approvals`)
```

## API

### `new SharddogApprove(config?)`

| Option | Type | Default | Description |
|--------|------|---------|-------------|
| `apiKey` | string | — | API key for authenticated requests |
| `baseUrl` | string | `https://shard.dog` | API base URL |

### `approve.stamp(options)`

Create an approval stamp.

| Option | Type | Required | Description |
|--------|------|----------|-------------|
| `content` | string | * | Raw content to hash and approve |
| `contentHash` | string | * | Pre-computed SHA-256 hex hash |
| `label` | string | ✅ | Human-readable description (max 256 chars) |
| `reviewer` | string | ✅ | NEAR wallet or email of reviewer |
| `metadata` | object | — | Optional: `ai_model`, `source_system`, `category` |

\* Either `content` or `contentHash` is required.

### `approve.verify(hashOrContent, reviewer?)`

Verify if content has been approved. Pass a SHA-256 hash or raw content string.

### `approve.history(reviewer, options?)`

Get approval history for a reviewer.

### `sha256(text)`

Utility to compute SHA-256 hash. Works in browser and Node.js.

## Widget

Drop-in web component — no build step required:

```html
<script src="https://shard.dog/approve-widget.js"></script>

<sharddog-approve
  api-key="your_key"
  content-hash="abc123..."
  label="AI Report Review"
  reviewer="alice.near"
  ai-model="claude-opus-4"
></sharddog-approve>
```

Or with raw content (auto-hashed):

```html
<sharddog-approve
  api-key="your_key"
  content="The full AI-generated text..."
  label="Blog Post Review"
  reviewer="bob.near"
></sharddog-approve>
```

### Events

```javascript
document.querySelector('sharddog-approve')
  .addEventListener('sharddog:approved', (e) => {
    console.log('Stamp created:', e.detail)
  })
```

## How It Works

1. AI generates content (report, code, article)
2. Human reviews and clicks "Approve"
3. Content is SHA-256 hashed, approval stamp stored in DB + minted on NEAR as an NFT
4. Anyone can verify by checking the content hash against the on-chain record

## Links

- [ShardDog](https://shard.dog)
- [Verification Page](https://shard.dog/approve)
- Built on [NEAR Protocol](https://near.org)