UNPKG

wowok

Version:

Wowok Blockchain TypeScript API

136 lines (135 loc) 4.16 kB
export type TextFormat = "plain" | "markdown" | "html"; export type ImageMimeType = "image/png" | "image/jpeg" | "image/gif" | "image/webp"; export type HashAlgorithm = "sha256"; export type SignatureAlgorithm = "Falcon512"; export interface WipContent { text: string; format: TextFormat; } export interface WipMedia { id: string; type: ImageMimeType; data: string; filename?: string; } export interface WipPayload { content: WipContent; media: WipMedia[]; } export interface WipSignature { value: string; publicKey: string; algorithm: SignatureAlgorithm; address?: string; } export interface WipMeta { type: "wip"; version: string; created: string; hash: string; algorithm: HashAlgorithm; signature?: WipSignature | WipSignature[]; } export interface WipFile { wip: string; payload: WipPayload; meta: WipMeta; } export interface ImageSource { source: string; id?: string; filename?: string; } export interface WipCreateOptions { text: string; textFormat?: TextFormat; images?: ImageSource[]; signKeyPair?: { publicKey: string; privateKey: string; }; signAlgorithm?: SignatureAlgorithm; } export interface WipLimits { maxImageSize: number; maxTotalSize: number; maxImageCount: number; maxTextLength: number; } export declare const DEFAULT_LIMITS: WipLimits; export declare class WipError extends Error { constructor(message: string); } export declare class WipValidationError extends WipError { constructor(message: string); } export declare class WipSizeError extends WipError { constructor(message: string); } export declare class WIP { private limits; private resourceLoader; constructor(limits?: Partial<WipLimits>); create(options: WipCreateOptions): Promise<WipFile>; private processImage; private sign; verify(wipFile: WipFile): Promise<{ valid: boolean; error?: string; signatures?: { address?: string; valid: boolean; }[]; }>; private verifySignature; toHtml(wipFile: WipFile, options?: { title?: string; theme?: "light" | "dark"; }): Promise<string>; stringify(wipFile: WipFile, pretty?: boolean): string; parse(jsonString: string): WipFile; load(source: string): Promise<WipFile>; getHash(wipFile: WipFile): string; extractImages(wipFile: WipFile, outputDir: string): string[]; save(wipFile: WipFile, filePath: string, pretty?: boolean): void; getLimits(): WipLimits; setLimits(limits: Partial<WipLimits>): void; } export declare function createWip(options: WipCreateOptions, limits?: Partial<WipLimits>): Promise<WipFile>; export declare function verifyWip(wipFile: WipFile, hash_equal?: string): Promise<{ valid: boolean; error?: string; }>; export declare function wipToHtml(wipFile: WipFile, options?: { title?: string; theme?: "light" | "dark"; }): Promise<string>; export declare function loadWip(source: string, limits?: Partial<WipLimits>): Promise<WipFile>; export interface WipGenerationOptions { markdown_text: string; images?: ImageSource[]; account?: string; } export interface WipSignatureVerification { publicKey: string; address?: string; valid: boolean; } export interface WipVerificationResult { valid: boolean; error?: string; hashValid: boolean; signatureValid?: boolean; hasSignature: boolean; signatures?: WipSignatureVerification[]; } export interface WipToHtmlOptions { title?: string; theme?: "light" | "dark"; outputPath?: string; } export declare function generate_wip(options: WipGenerationOptions, outputPath: string): Promise<string>; export declare function verify_wip(wipFilePath: string, hash_equal?: string, requireSignature?: boolean): Promise<WipVerificationResult>; export declare function sign_wip(wipFilePath: string, account: string | undefined | null, outputPath?: string): Promise<string>; export declare function wip2html(wipPath: string, options?: WipToHtmlOptions): Promise<string | string[]>; export default WIP;