@sharekit/core
v1.1.0
Published
Core engine for the Shareable SDK -- token management, privacy engine, types
Downloads
674
Readme
@sharekit/core
Core engine for the Shareable SDK. Framework-agnostic -- contains the token engine, privacy engine, data filtering, types, and OG image renderer.
Installation
pnpm add @sharekit/coreAPI
createShareable(config)
Creates a shareable instance. This is the entry point for the SDK.
import { createShareable } from "@sharekit/core";
const shareable = createShareable({
storage: yourStorageAdapter,
auth: yourAuthAdapter,
baseUrl: "https://yourapp.com",
});instance.define(id, definition)
Registers a shareable content type with a privacy schema and data loader.
Privacy Engine
flattenSchema(schema)-- Flatten nested field schema to dot-pathsgetDefaults(schema)-- Get default visibility mapresolveDependencies(visibleFields, schema)-- Resolve field dependenciesgetDependencyWarnings(visibleFields, schema)-- Get human-readable warningsfilterData(data, visibleFields)-- Remove hidden fields from datagetToggleConfig(schema)-- Generate toggle UI configuration
Token Engine
generateToken(length?)-- Generate a cryptographically random hex tokenvalidateToken(token)-- Validate token format and minimum length
OG Image
renderOGImage(config, options?)-- Render an OG image config to SVG using satori
Interfaces
ShareableStorage-- Storage adapter interfaceShareableAuthProvider-- Auth adapter interfaceShareableDefinition-- Content type definitionFieldSchema-- Privacy field schema
