{"_id":"@ai-provenance-protocol/sdk","name":"@ai-provenance-protocol/sdk","dist-tags":{"latest":"1.0.0"},"versions":{"1.0.0":{"name":"@ai-provenance-protocol/sdk","version":"1.0.0","description":"Official TypeScript/JavaScript SDK for the AI Provenance Protocol","keywords":["ai-provenance","ai-provenance-protocol","app","eu-ai-act","provenance","ai-transparency"],"homepage":"https://aiprovenanceprotocol.io/docs/sdk","repository":{"type":"git","url":"git+https://github.com/AI-Provenance-Protocol/ai-provenance-protocol.git","directory":"sdks/typescript"},"license":"Apache-2.0","type":"module","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","require":"./dist/index.cjs"}},"main":"./dist/index.cjs","module":"./dist/index.js","types":"./dist/index.d.ts","scripts":{"build":"tsup","dev":"tsup --watch","typecheck":"tsc --noEmit"},"dependencies":{"ajv":"^8.17.1","ajv-formats":"^3.0.1"},"devDependencies":{"@types/node":"^22.0.0","tsup":"^8.0.0","typescript":"^5.5.0"},"engines":{"node":">=18.0.0"},"_id":"@ai-provenance-protocol/sdk@1.0.0","gitHead":"01febd849690703acfcca6e4f89358b7563aeee9","bugs":{"url":"https://github.com/AI-Provenance-Protocol/ai-provenance-protocol/issues"},"_nodeVersion":"22.14.0","_npmVersion":"10.9.2","dist":{"integrity":"sha512-Ieuir6v1n6QHrDNMvjzsCcpjv3nC0x+G9iHL9tnzrikEVPGAdUf+jGvNRyHqYY4IbRkb+fDufVANNUlwCJvusg==","shasum":"3fce183dd9864d1dceabcde2dea29107ca18984e","tarball":"https://registry.npmjs.org/@ai-provenance-protocol/sdk/-/sdk-1.0.0.tgz","fileCount":8,"unpackedSize":87693,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQCNt4X2rLH6cSEdPF5CymzzdnZSxORYlBBwiU57q87AnAIhALD7YFvCSPh7eQiY4KNxxxc+hxnafPMYxLJLjGmRYqjW"}]},"_npmUser":{"name":"r0ssdab0ss","email":"ross@merchi.ai"},"directories":{},"maintainers":[{"name":"r0ssdab0ss","email":"ross@merchi.ai"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/sdk_1.0.0_1776699557156_0.4520132734642286"},"_hasShrinkwrap":false}},"time":{"created":"2026-04-20T15:39:17.044Z","1.0.0":"2026-04-20T15:39:17.315Z","modified":"2026-04-20T15:39:17.518Z"},"maintainers":[{"name":"r0ssdab0ss","email":"ross@merchi.ai"}],"description":"Official TypeScript/JavaScript SDK for the AI Provenance Protocol","homepage":"https://aiprovenanceprotocol.io/docs/sdk","keywords":["ai-provenance","ai-provenance-protocol","app","eu-ai-act","provenance","ai-transparency"],"repository":{"type":"git","url":"git+https://github.com/AI-Provenance-Protocol/ai-provenance-protocol.git","directory":"sdks/typescript"},"bugs":{"url":"https://github.com/AI-Provenance-Protocol/ai-provenance-protocol/issues"},"license":"Apache-2.0","readme":"# @ai-provenance-protocol/sdk\n\nOfficial TypeScript/JavaScript SDK for the [AI Provenance Protocol](https://aiprovenanceprotocol.io).\n\n## Installation\n\n```bash\nnpm install @ai-provenance-protocol/sdk\n```\n\n## Quick start\n\n```typescript\nimport { APP } from '@ai-provenance-protocol/sdk'\n\n// Create metadata for a generation event\nconst metadata = APP.create({\n  generator: {\n    platform: 'my-platform',\n    model: 'anthropic/claude-sonnet-4',\n  },\n})\n\n// Embed in your JSON output\nconst output = APP.embed(\n  { title: 'Premium Leather Wallet', description: 'Handcrafted from full-grain leather...' },\n  metadata\n)\n// { title: '...', description: '...', _ai_provenance: { ... } }\n\n// Extract from received output\nconst { content, app } = APP.extract(output)\n\n// Validate metadata\nconst result = APP.validate(metadata)\n// { valid: true, errors: [] }\n\n// Record a human review\nconst reviewed = APP.review(metadata, {\n  human_reviewed: true,\n  reviewer_role: 'editor',\n  review_type: 'approved_without_changes',\n})\n\n// Add a content hash for integrity verification\nconst hash = APP.hashContent({ title: 'Premium Leather Wallet', description: '...' })\n// 'sha256:e3b0c44...'\n\n// Verify a generation against a platform endpoint\nconst verification = await APP.verify(metadata.generation_id, 'https://verify.example.com/v1/verify')\n// { found: true, ai_generated: true, generator: { ... }, ... }\n```\n\n## API\n\n### `APP.create(options)` / `create(options)`\n\nCreates a new APP metadata object. Automatically sets `app_version`, `generated_at` (current UTC time), and `generation_id` (UUID v4).\n\n```typescript\nconst metadata = APP.create({\n  generator: { platform: 'my-platform', model: 'openai/gpt-4o' },\n  verification_uri: 'https://verify.example.com/v1/verify',\n})\n```\n\n### `APP.embed(content, metadata)` / `embed(content, metadata)`\n\nEmbeds APP metadata into a JSON object under the `_ai_provenance` key.\n\n```typescript\nconst output = APP.embed({ text: 'Hello world' }, metadata)\n// { text: 'Hello world', _ai_provenance: { ... } }\n```\n\n### `APP.extract(output)` / `extract(output)`\n\nExtracts APP metadata from an embedded JSON object, returning content and metadata separately.\n\n```typescript\nconst { content, app } = APP.extract(output)\n// content: { text: 'Hello world' }\n// app: AppMetadata | null\n```\n\n### `APP.validate(metadata)` / `validate(metadata)`\n\nValidates APP metadata against the v1.0 JSON Schema. Useful for validating metadata received from external systems.\n\n```typescript\nconst result = APP.validate(unknownData)\nif (!result.valid) {\n  result.errors.forEach(e => console.error(`${e.field}: ${e.message}`))\n}\n```\n\n### `APP.review(metadata, options)` / `review(metadata, options)`\n\nRecords a human review on an existing metadata object. Returns a new object — does not mutate the original.\n\n```typescript\nconst reviewed = APP.review(metadata, {\n  human_reviewed: true,\n  reviewer_role: 'editor',\n  review_type: 'edited',\n  review_notes: 'Adjusted tone for brand guidelines.',\n})\n```\n\n### `APP.hashContent(content, algorithm?)` / `hashContent(content, algorithm?)`\n\nComputes a content hash for integrity verification. For JSON objects, uses canonical form (sorted keys, `_ai_provenance` excluded). Default algorithm is `sha256`.\n\n```typescript\nconst hash = APP.hashContent({ title: 'My Article', body: '...' })\n// 'sha256:e3b0c44298fc...'\n\nconst sha512Hash = APP.hashContent('plain text content', 'sha512')\n// 'sha512:cf83e135...'\n```\n\n### `APP.verify(generationId, verificationUri)` / `verify(generationId, verificationUri)`\n\nLevel 1 verification: look up a generation ID at the platform's verification endpoint.\n\n```typescript\nconst result = await APP.verify(\n  'a1b2c3d4-e5f6-7890-abcd-ef1234567890',\n  'https://verify.example.com/v1/verify'\n)\nif (result.found) {\n  console.log('Verified:', result.generator?.model)\n}\n```\n\n### `APP.match(contentHash, verificationUri, contentType?)` / `match(...)`\n\nLevel 2 verification: find generations matching a content hash.\n\n```typescript\nconst result = await APP.match(\n  'sha256:e3b0c44298fc...',\n  'https://verify.example.com/v1/verify',\n  'application/json'\n)\nconsole.log(`${result.matches.length} matching generation(s) found`)\n```\n\n## Named exports\n\nAll functions are also available as named exports for tree-shaking:\n\n```typescript\nimport { create, embed, extract, validate, review, hashContent, verify, match } from '@ai-provenance-protocol/sdk'\n```\n\n## Types\n\nAll TypeScript types are exported:\n\n```typescript\nimport type { AppMetadata, Generator, Review, ValidationResult } from '@ai-provenance-protocol/sdk'\n```\n\n## License\n\nApache 2.0 — see [LICENSE](../../LICENSE)\n","readmeFilename":"README.md","_rev":"1-e026d2f58bf2397a22d8b141eb2b3df6"}