TypeScript SDK

Official TypeScript SDK for TruthMark invisible watermarking with full type safety.

Installation

npm install @truthmark/sdk-typescript

Quick Example

import { TruthMarkClient } from '@truthmark/sdk-typescript';

// Initialize
const client = new TruthMarkClient();

// Encode watermark
const result = await client.encode(
    './image.png',
    'My secret message'
);
console.log(`Download: ${result.download_url}`);

// Decode watermark
const decoded = await client.decode('./watermarked.png');
if (decoded.found) {
    console.log(`Message: ${decoded.message}`);
}

API Reference

encode(imagePath, message)

Embed an invisible watermark into an image.

// Returns Promise<EncodeResult>
interface EncodeResult {
    status: string;
    metadata: {
        psnr: number;
        bits_embedded: number;
    };
    download_url: string;
}

decode(imagePath)

Extract watermark from an image.

// Returns Promise<DecodeResult>
interface DecodeResult {
    found: boolean;
    message: string | null;
    confidence: number;
}