authsig
v1.0.0
Published
AuthSig SDK for content signing and verification. Prove authorship of any digital content with blockchain-backed signatures.
Maintainers
Readme
@authsig/sdk
AuthSig SDK for content signing and verification. Prove authorship of any digital content with blockchain-backed signatures.
Features
- Sign any content - Files, images, documents, text
- Large file support - Streaming hash for files up to 500MB+
- On-chain registry - Publish proofs to the BSV blockchain
- Public verification - Verify content without a wallet
- Framework-agnostic - Works with any JavaScript/TypeScript project
Installation
npm install @authsig/sdk @bsv/sdk hash-wasmQuick Start
Signing Content
import { AuthSigClient } from '@authsig/sdk';
// Create client and connect wallet
const client = new AuthSigClient();
await client.connect();
// Sign and publish in one call
const proof = await client.signAndPublish(fileOrContent, {
onProgress: (p) => console.log(`${p.percent.toFixed(0)}%`)
});
console.log('Published:', proof.outpoint);Verifying Content (No Wallet Required)
import { verifyContentPublic, lookupProofsPublic } from '@authsig/sdk';
// Look up proofs by content hash
const proofs = await lookupProofsPublic(contentHash);
// Or verify content directly
const result = await verifyContentPublic(content, {
signature: proof.signature,
publicKey: proof.publicKey
});API Reference
AuthSigClient
Main client for signing operations. Requires a BRC-100 compatible wallet.
const client = new AuthSigClient(options?: AuthSigOptions);
// Connect to wallet
await client.connect();
// Get signer's identity
const identity = client.getIdentity();
// Sign content (returns ProofBundle)
const proof = await client.signContent(content, options);
// Publish proof to blockchain
const receipt = await client.publishProof(proof);
// Combined sign + publish
const signedProof = await client.signAndPublish(content, options);Public Verification Functions
These functions work without a wallet connection.
// Verify a signature
const isValid = await verifySignaturePublic(hash, signature, publicKey);
// Look up proofs by content hash
const proofs = await lookupProofsPublic(contentHash);
// Verify content with proof
const result = await verifyContentPublic(content, { signature, publicKey });Hashing Utilities
// Stream hash a file (memory efficient)
const hash = await streamHashFile(file, onProgress);
// Hash content directly
const hash = await hashContent(content);
// Convert to hex
const hexHash = bytesToHex(hash);Types
interface ProofBundle {
contentHash: string; // SHA-256 hex
signature: string; // Signature hex
publicKey: string; // Signer's identity key
signedAt: string; // ISO timestamp
protocol: 'authsig-v1';
}
interface OnChainReceipt {
outpoint: string; // Blockchain transaction reference
publishedAt: string;
}
interface SignedProof extends ProofBundle {
onChain: OnChainReceipt;
}
interface HashProgress {
bytesProcessed: number;
totalBytes: number;
percent: number;
}Integration Examples
ProCreate Export Plugin
import { AuthSigClient } from '@authsig/sdk';
async function exportWithProof(artwork: Uint8Array) {
const client = new AuthSigClient();
await client.connect();
const proof = await client.signAndPublish(artwork, {
onProgress: (p) => updateExportProgress(p.percent)
});
// Embed proof in image metadata or save alongside
return { artwork, proof };
}Verification Widget
import { verifyContentPublic, lookupProofsPublic } from '@authsig/sdk';
async function checkAuthenticity(file: File) {
const hash = await streamHashFile(file);
const hashHex = bytesToHex(hash);
const proofs = await lookupProofsPublic(hashHex);
if (proofs.length === 0) {
return { verified: false, message: 'No proof found' };
}
const proof = proofs[0]; // Oldest proof (original publisher)
const isValid = await verifySignaturePublic(hash, proof.signature, proof.publicKey);
return {
verified: isValid,
signer: proof.publicKey,
signedAt: proof.signedAt
};
}License
MIT
