VeriPDF API Reference
Complete type and function reference for all VeriPDF packages. The SDK is at version 0.3.0 for @trexolab/verifykit-core (Rust/WASM engine) and 0.2.0 for the remaining packages. For practical usage examples, see the Examples guide.
@trexolab/verifykit-core
The headless PDF signature verification engine. All cryptographic operations run in Rust/WASM with built-in crypto -- no Web Crypto API or external crypto library dependency.
Functions
createVerifier(config?)
Creates a configured verifier instance for repeated use. Initializes the WASM module on first call.
function createVerifier(config?: VeriPdfCoreConfig): Promise<VeriPdfVerifier>Important: This function is async as of v0.3.0. It returns a
Promise<VeriPdfVerifier>, not a synchronousVeriPdfVerifier.
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
config | VeriPdfCoreConfig | No | Trust store and plugin configuration |
Returns: Promise<VeriPdfVerifier>
Example:
const verifier = await createVerifier({
trustStore: { certificates: [pemString], mode: 'merge' },
plugins: [revocationPlugin()],
})
const result = await verifier.verify(buffer, 'doc.pdf')
verifier.dispose()verifyPdf(input, fileName?)
One-shot verification using default configuration. Initializes the WASM module if not already loaded.
function verifyPdf(input: PdfInput, fileName?: string): Promise<VerificationResult>Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
input | PdfInput | Yes | PDF data as ArrayBuffer, Uint8Array, File, or URL string |
fileName | string | No | Display name for the file |
Returns: Promise<VerificationResult>
Errors: Rejects the returned promise if the input cannot be parsed as a PDF or if an internal verification operation fails. Never throws synchronously.
extractPdfMetadata(input)
Extracts document metadata and permissions without performing signature verification.
function extractPdfMetadata(input: PdfInput): Promise<{
metadata: DocumentMetadata
permissions: DocumentPermissions
}>Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
input | PdfInput | Yes | PDF data |
Returns: Promise<{ metadata: DocumentMetadata; permissions: DocumentPermissions }>
extractSignaturesFromPdf(buffer)
Low-level function that extracts raw signature data from a PDF without verification.
function extractSignaturesFromPdf(buffer: ArrayBuffer): Promise<any[]>sha256hex(data)
Computes the SHA-256 hash of a byte array and returns it as a hex string.
function sha256hex(data: Uint8Array): Promise<string>buf2hex(buf)
Converts an ArrayBuffer to a hex string. Requires the WASM module to be initialized.
function buf2hex(buf: ArrayBuffer): stringoidToName(oid)
Maps a dotted OID string to a human-readable algorithm name.
function oidToName(oid: string): stringExamples:
oidToName('1.2.840.113549.1.1.11') // "SHA-256 with RSA"
oidToName('1.2.840.10045.4.3.2') // "SHA-256 with ECDSA"
oidToName('1.3.101.112') // "Ed25519"Supported OIDs:
| OID | Name |
|---|---|
1.2.840.113549.1.1.1 | RSA |
1.2.840.113549.1.1.5 | SHA-1 with RSA |
1.2.840.113549.1.1.10 | RSA-PSS |
1.2.840.113549.1.1.11 | SHA-256 with RSA |
1.2.840.113549.1.1.12 | SHA-384 with RSA |
1.2.840.113549.1.1.13 | SHA-512 with RSA |
1.2.840.10045.2.1 | EC |
1.2.840.10045.4.3.1 | SHA-1 with ECDSA |
1.2.840.10045.4.3.2 | SHA-256 with ECDSA |
1.2.840.10045.4.3.3 | SHA-384 with ECDSA |
1.2.840.10045.4.3.4 | SHA-512 with ECDSA |
1.3.101.112 | Ed25519 |
1.3.101.113 | Ed448 |
1.3.14.3.2.26 | SHA-1 |
2.16.840.1.101.3.4.2.1 | SHA-256 |
2.16.840.1.101.3.4.2.2 | SHA-384 |
2.16.840.1.101.3.4.2.3 | SHA-512 |
1.2.840.113549.2.5 | MD5 |
1.2.840.113549.2.2 | MD2 |
Unknown OIDs are returned as-is.
parseDn(dn)
Formats a distinguished name string by normalizing comma spacing.
function parseDn(dn: string): stringcomputeUnsignedFields(signatures, detectedFields?)
Returns a list of unsigned signature fields in the document.
function computeUnsignedFields(
signatures: PdfSignature[],
detectedFields?: Array<{ fieldName: string; pageNum: number }>,
): UnsignedSigField[]decompressFlate(data)
Decompresses Flate-encoded data using the DecompressionStream API.
function decompressFlate(data: Uint8Array): Promise<Uint8Array | null>Returns null if decompression fails.
Trust Store Functions
function setTrustStoreConfig(config: TrustStoreConfig): Promise<void>
function resetTrustStore(): Promise<void>
function ensureTrustStoreReady(): Promise<void>
function getTrustStore(): TrustStore| Function | Description |
|---|---|
setTrustStoreConfig | Configures the trust store with custom certificates |
resetTrustStore | Resets the trust store to the default embedded AATL certificates |
ensureTrustStoreReady | Initializes the WASM module (and thereby the trust store) |
getTrustStore | Returns the current trust store contents |
WASM Lifecycle
function initWasm(): Promise<any>
function isWasmReady(): boolean| Function | Description |
|---|---|
initWasm | Initializes the WASM module. Safe to call multiple times (deduplicates). |
isWasmReady | Returns true if the WASM module is loaded and ready. |
Platform Detection
const isNode: boolean
function ensureCryptoEngine(): Promise<void>| Export | Description |
|---|---|
isNode | true when running in a Node.js environment |
ensureCryptoEngine | No-op in the WASM engine (retained for API compatibility) |
Types
PdfInput
All functions that accept PDF data accept these input types:
type PdfInput = ArrayBuffer | Uint8Array | File | stringWhen a string is provided, it is treated as a URL and fetched via fetch().
VeriPdfCoreConfig
interface VeriPdfCoreConfig {
trustStore?: TrustStoreConfig
plugins?: VeriPdfPlugin[]
}TrustStoreConfig
interface TrustStoreConfig {
certificates?: string[] // PEM-encoded root certificates
mode?: 'merge' | 'replace' // merge with or replace built-in store (default: 'merge')
url?: string // URL to fetch additional certificates
refreshInterval?: number // Refresh interval in ms for URL-based certificates
}VeriPdfVerifier
interface VeriPdfVerifier {
verify(input: PdfInput, fileName?: string): Promise<VerificationResult>
extractMetadata(input: PdfInput): Promise<{
metadata: DocumentMetadata
permissions: DocumentPermissions
}>
dispose(): void
}Always call dispose() when finished to release WASM resources.
VerificationResult
interface VerificationResult {
fileName?: string
fileSize: number
fileHash: string // SHA-256 hex digest of the file
signatures: PdfSignature[]
error?: string
}PdfSignature
interface PdfSignature {
index: number
name: string
fieldName: string
subFilter: string
byteRangeCoverage: boolean
byteRangeCoversWholeFile: boolean
integrityCheck: SignatureCheckResult
signatureCheck: SignatureCheckResult
certificateChainCheck: SignatureCheckResult
expiryCheck: SignatureCheckResult
timestampCheck: SignatureCheckResult
revocationCheck: SignatureCheckResult
algorithmCheck: SignatureCheckResult
ekuCheck: SignatureCheckResult
signerCertificate: CertificateInfo | null
certificateChain: CertificateInfo[]
timestamp: TimestampInfo | null
reason: string
location: string
contactInfo: string
signingTime: Date | null
overallStatus: VerificationStatus
overallMessage: string
mdpPermission: number | null
isVisible: boolean
padesLevel: PAdESLevel
notYetVerified?: boolean
isDeleted?: boolean
deletedAtRevision?: number
}SignatureCheckResult
Each of the 8 verification checks returns this structure:
interface SignatureCheckResult {
label: string
status: VerificationStatus
detail: string
}VerificationStatus
type VerificationStatus = 'valid' | 'invalid' | 'warning' | 'unknown' | 'pending'| Value | Meaning |
|---|---|
valid | Check passed |
invalid | Check failed -- signature is broken, certificate untrusted, or document tampered |
warning | Minor issue -- no timestamp, weak algorithm, etc. |
unknown | Could not determine -- missing data or not checked |
pending | Verification in progress |
PAdESLevel
type PAdESLevel = 'B-B' | 'B-T' | 'B-LT' | 'B-LTA'| Level | Description |
|---|---|
B-B | Basic signature (CMS signed data) |
B-T | With trusted timestamp |
B-LT | With long-term validation data (embedded CRL/OCSP) |
B-LTA | With archive timestamp for long-term archival |
CertificateInfo
interface CertificateInfo {
subject: string
issuer: string
serialNumber: string
notBefore: Date
notAfter: Date
isExpired: boolean
isCA: boolean
subjectAltNames: string[]
fingerprint: string // SHA-256 fingerprint
sha1Fingerprint?: string
keyAlgorithm: string
signatureAlgorithm: string
keySize?: number
keyUsage?: string[]
extKeyUsage?: string[]
subjectKeyId?: string
authorityKeyId?: string
crlDistributionPoints?: string[]
ocspUrls?: string[]
caIssuersUrls?: string[]
policies?: string[]
rawDer?: ArrayBuffer // Raw DER-encoded certificate bytes
}TimestampInfo
interface TimestampInfo {
time: Date
tsaName: string
hashAlgorithm: string
verified: boolean
tsaCertificates?: CertificateInfo[]
}DocumentMetadata
interface DocumentMetadata {
title: string
author: string
subject: string
keywords: string
creator: string
producer: string
creationDate: Date | null
modDate: Date | null
pdfVersion: string
pageCount: number
}DocumentPermissions
interface DocumentPermissions {
encrypted: boolean
encryptionMethod: string
permissionFlags: number | null
printing: 'allowed' | 'low-res' | 'not-allowed'
modification: boolean
copying: boolean
annotations: boolean
formFilling: boolean
accessibility: boolean
assembly: boolean
}UnsignedSigField
interface UnsignedSigField {
fieldName: string
pageNum: number
}VeriPdfPlugin
The core plugin interface for extending the verification engine:
interface VeriPdfPlugin {
name: string
setup?: (ctx: PluginContext) => void | Promise<void>
trustStore?: TrustStoreConfig
revocation?: {
checkCRL?: (cert: CertificateInfo, urls: string[]) => Promise<RevocationCheckResult>
checkOCSP?: (cert: CertificateInfo, issuer: CertificateInfo, urls: string[]) => Promise<RevocationCheckResult>
}
inputResolver?: (input: PdfInput) => Promise<ArrayBuffer | null>
}| Property | Description |
|---|---|
name | Unique identifier for the plugin |
setup | Called during verifier initialization |
trustStore | Additional trust store certificates to merge or replace |
revocation.checkCRL | Online CRL checking callback |
revocation.checkOCSP | Online OCSP checking callback |
inputResolver | Custom input resolver (e.g., fetch from cloud storage) |
PluginContext
interface PluginContext {
config: VeriPdfCoreConfig
}RevocationCheckResult
interface RevocationCheckResult {
status: 'revoked' | 'revokedAfterSigning' | 'revokedNoTimestamp' | 'good' | 'unknown'
revocationDate?: Date
reason?: string
source?: string
}TrustStore
interface TrustStore {
roots: ArrayBuffer[]
intermediates: ArrayBuffer[]
all: ArrayBuffer[]
}@trexolab/verifykit-react
React PDF viewer with plugin-based architecture. Depends on @trexolab/verifykit-core and pdfjs-dist 5.5.207.
Provider
VeriPdfProvider
Context provider that initializes the WASM engine, sets the theme, and configures verification defaults.
<VeriPdfProvider config={config}>
{children}
</VeriPdfProvider>Props:
| Prop | Type | Required | Description |
|---|---|---|---|
config | VeriPdfConfig | No | Provider configuration |
children | ReactNode | Yes | Child components |
VeriPdfConfig
interface VeriPdfConfig {
trustStore?: TrustStoreConfig
plugins?: VeriPdfPlugin[]
theme?: ThemeConfig
worker?: WorkerConfig
locale?: string
translations?: Partial<TranslationStrings>
}
interface ThemeConfig {
mode?: 'light' | 'dark' | 'system'
overrides?: Record<string, string> // CSS variable overrides
}
interface WorkerConfig {
src?: string // Explicit PDF.js worker URL
}Hooks
useVerification()
Main verification state hook. Must be used inside a VeriPdfProvider.
function useVerification(): VerificationState
interface VerificationState {
load(input: PdfInput, fileName?: string): Promise<VerificationResult>
reset(): void
fileBuffer: ArrayBuffer | null
fileName: string
signatures: PdfSignature[]
unsignedFields: UnsignedSigField[]
status: VerificationStatus | null
result: VerificationResult | null
metadata: DocumentMetadata | null
permissions: DocumentPermissions | null
isLoading: boolean
error: string | null
}useVeriPdfConfig()
Accesses the provider configuration and theme setter.
function useVeriPdfConfig(): {
config: VeriPdfConfig
setThemeMode(mode: 'light' | 'dark'): void
}useViewerStore(selector)
Subscribes to the viewer store with a selector. Re-renders only when the selected value changes.
function useViewerStore<T>(selector: (state: ViewerStoreState) => T): TuseViewerStoreKey(key)
Subscribes to a single key in the viewer store.
function useViewerStoreKey<K extends keyof ViewerStoreState>(key: K): ViewerStoreState[K]useViewerStoreUpdate()
Returns a function to dispatch partial state updates to the viewer store.
function useViewerStoreUpdate(): (partial: Partial<ViewerStoreState>) => voiduseStore()
Returns the raw ViewerStore instance for advanced use (batch updates, direct subscriptions).
function useStore(): ViewerStoreuseContainerSize(ref)
Responsive breakpoint hook that reports the container dimensions.
function useContainerSize(ref: React.RefObject<HTMLElement>): { width: number; height: number }usePinchZoom(ref, onZoom)
Touch pinch-zoom gesture handler.
function usePinchZoom(
ref: React.RefObject<HTMLElement>,
onZoom: (scaleDelta: number) => void,
): voidViewer Components
Viewer
The primary plugin-based PDF viewer component.
<Viewer
ref={viewerRef}
fileBuffer={buffer}
fileName="document.pdf"
plugins={[layout.plugin]}
onOpenFile={handleFile}
initialState={{ signatures, verificationStatus }}
onDocumentLoaded={(doc) => console.log(doc.numPages)}
/>Props:
| Prop | Type | Required | Description |
|---|---|---|---|
fileBuffer | ArrayBuffer | No | PDF file data |
fileName | string | No | Display file name |
plugins | ViewerPlugin[] | No | Array of viewer plugins |
onOpenFile | (file: File) => void | No | File open callback |
initialState | Partial<ViewerStoreState> | No | Initial store state (signatures, status) |
onDocumentLoaded | (doc) => void | No | Called when the PDF document loads |
signatures | PdfSignature[] | No | Signature data for direct binding |
unsignedFields | UnsignedSigField[] | No | Unsigned field data |
verificationStatus | VerificationStatus | No | Overall verification status |
Ref (ViewerHandle):
interface ViewerHandle {
getStore(): ViewerStore | null
}CoreViewer
Lower-level viewer component without the Viewer wrapper. For advanced use cases where you need direct control over the plugin host.
PageRenderer
Renders a single PDF page (canvas, text layer, annotations). Used internally by CoreViewer.
WelcomeScreen
A drop-target screen for when no file is loaded.
<WelcomeScreen
onOpenFile={(file: File) => { ... }}
title="My PDF Viewer"
subtitle="Drag and drop a PDF here"
/>Props:
| Prop | Type | Required | Description |
|---|---|---|---|
onOpenFile | (file: File) => void | Yes | Called when a file is dropped or selected |
title | string | No | Heading text |
subtitle | string | No | Subheading text |
PdfViewer (Legacy)
The original monolithic viewer component. Still supported for backward compatibility but not recommended for new projects. Use Viewer with the plugin system instead.
Signature Components
| Component | Description |
|---|---|
SignatureListPanel | Panel listing all signatures with status icons |
SignaturePropertiesModal | Modal with full signature details and certificate chain |
SignatureDetailsTab | Tab content showing signature properties |
ValidityChecklist | Checklist of all 8 verification checks |
SignatureStatusIcon | Status icon (checkmark, cross, warning) |
DocumentMessageBar | Colored status bar displayed above the viewer |
VerificationFloater | Floating verification badge |
Certificate Components
| Component | Description |
|---|---|
CertificateViewer | Interactive certificate chain viewer |
UI Primitives
| Component | Description |
|---|---|
Tooltip | Tooltip component with flicker-free positioning |
Dialog, DialogOverlay, DialogContent, DialogTitle, DialogHeader, DialogClose | Radix-based accessible dialog |
ViewerDialog, ViewerDialogOverlay, ViewerDialogContent, ViewerDialogTitle | Viewer-scoped dialog variant |
DocumentPropertiesModal | Document properties display |
KeyboardShortcutHelp | Keyboard shortcuts reference panel |
PdfViewerErrorBoundary | Error boundary for the viewer |
UI Helpers
Status Helpers
const STATUS_LABEL: Record<VerificationStatus, string>
const STATUS_COLOR: Record<VerificationStatus, string>
const STATUS_BG: Record<VerificationStatus, string>
const STATUS_STRIPE: Record<VerificationStatus, string>
const STATUS_CFG: Record<VerificationStatus, StatusCfg>
const AVATAR_RING: Record<VerificationStatus, string>
const PANEL_STRIPE: Record<VerificationStatus, string>
function statusTextColor(status: VerificationStatus): string
function getStatusSentence(status: VerificationStatus): string
function getInvalidSub(sig: PdfSignature): string
function getPillLabel(status: VerificationStatus): string
function getInitials(name: string): string
function overallStatus(signatures: PdfSignature[]): VerificationStatusCheck Builders
function buildChecks(sig: PdfSignature): CheckItem[]
function buildMiniChecks(sig: PdfSignature): MiniCheckItem[]
function buildSummaryLines(sig: PdfSignature): SummaryLine[]
function isLtvEnabled(sig: PdfSignature): booleanCertificate Utilities
function getCN(dn: string): string // Extract Common Name
function getO(dn: string): string // Extract Organization
function getField(dn: string, field: string): stringDate Formatters
function fmtDateLong(date: Date): string // "March 15, 2026, 2:30:00 PM"
function fmtDateShort(date: Date): string // "Mar 15, 2026"
function fmtDateCompact(date: Date): string // "2026-03-15"
function fmtDatePanel(date: Date): string // Panel-optimized formatDownload Utilities
function uint8ToBase64(bytes: Uint8Array): string
function downloadBlob(blob: Blob, filename: string): void
function exportCertAsPem(cert: CertificateInfo): string
function exportCertAsDer(cert: CertificateInfo): Uint8Array
function safeName(name: string): stringAppearance Swapping
function swapSignatureAppearances(buffer: ArrayBuffer, signatures: PdfSignature[]): Promise<ArrayBuffer>
function hasAcro6Appearances(buffer: ArrayBuffer): Promise<boolean>i18n
function t(key: string): string
function setLocale(locale: string): void
function getLocale(): string
function registerLocale(locale: string, translations: TranslationStrings): void
function getAvailableLocales(): string[]Store Actions
Shared helpers for plugins and menus:
function downloadPdf(store: ViewerStore): void
function rotateCW(store: ViewerStore): void
function rotateCCW(store: ViewerStore): void
function toggleFullscreen(store: ViewerStore): voidWorker Utilities
function getWorkerUrl(config?: WorkerConfig): Promise<string>
function resolveWorkerUrl(config?: WorkerConfig): string
function createPolyfillWorkerUrl(url: string): string
function revokeWorkerBlobUrls(): voidViewerStore
A lightweight pub-sub reactive store that drives the viewer state.
function createViewerStore(initial?: Partial<ViewerStoreState>): ViewerStore
interface ViewerStore {
get<K extends keyof ViewerStoreState>(key: K): ViewerStoreState[K]
update(partial: Partial<ViewerStoreState>): void
subscribe<K extends keyof ViewerStoreState>(
key: K,
listener: (newVal: ViewerStoreState[K], oldVal: ViewerStoreState[K]) => void,
): () => void
batch(fn: () => void): void
}State shape:
| Category | Keys |
|---|---|
| Document | document, fileBuffer, fileName, loadState, errorMessage |
| Navigation | currentPage, totalPages |
| Zoom | scale, fitMode |
| Rotation | rotation |
| Layout | scrollMode, spreadMode, cursorTool |
| Theme | themeMode |
| Fullscreen | isFullscreen |
| Verification | signatures, unsignedFields, verificationStatus |
| UI panels | sidebarOpen, sidebarTab, sigPanelOpen, findOpen |
| Password | passwordNeeded, passwordError |
Plugin System
ViewerPlugin Interface
interface ViewerPlugin {
name: string
dependencies?: string[]
composedPlugins?: ViewerPlugin[]
// Lifecycle hooks
install?(ctx: PluginContext): void
onDocumentLoad?(e: DocumentLoadEvent): void
onDocumentUnload?(): void
onPageChange?(e: PageChangeEvent): void
onZoomChange?(e: ZoomChangeEvent): void
onRotationChange?(e: RotationChangeEvent): void
destroy?(): void
// UI contributions
renderToolbarSlot?: Partial<ToolbarSlots>
sidebarTabs?: SidebarTabDefinition[]
renderOverlay?: (props: OverlayRenderProps) => React.ReactNode
renderRightPanel?: (props: RightPanelRenderProps) => React.ReactNode
renderPageOverlay?: (props: PageOverlayRenderProps) => React.ReactNode
}PluginContext (Viewer)
interface PluginContext {
store: ViewerStore
getDocument(): PDFDocumentProxy | null
scrollToPage(pageNum: number): void
getScrollContainer(): HTMLElement | null
getViewerContainer(): HTMLElement | null
registerShortcut(shortcut: KeyboardShortcut): () => void
t(key: string): string
}Plugin Host Utilities
function resolvePlugins(plugins: ViewerPlugin[]): ViewerPlugin[]
function collectToolbarSlots(plugins: ViewerPlugin[]): ToolbarSlots
function collectSidebarTabs(plugins: ViewerPlugin[]): SidebarTabDefinition[]Individual Plugins
defaultLayoutPlugin(options?)
Meta-plugin composing all 22+ plugins into a batteries-included experience.
function defaultLayoutPlugin(options?: DefaultLayoutPluginOptions): DefaultLayoutPluginResultOptions:
interface DefaultLayoutPluginOptions {
disable?: {
search?: boolean
print?: boolean
download?: boolean
fullscreen?: boolean
theme?: boolean
rotation?: boolean
selection?: boolean
sidebar?: boolean
signatures?: boolean
highlights?: boolean
openFile?: boolean
properties?: boolean
shortcuts?: boolean
contextMenu?: boolean
}
toolbar?: ToolbarPluginOptions
}Result:
interface DefaultLayoutPluginResult {
plugin: ViewerPlugin
zoom: ZoomPluginApi
navigation: PageNavigationPluginApi
rotation: RotationPluginApi
search: SearchPluginApi
print: PrintPluginApi
download: DownloadPluginApi
theme: ThemePluginApi
fullscreen: FullscreenPluginApi
selection: SelectionPluginApi
scrollMode: ScrollModePluginApi
spreadMode: SpreadModePluginApi
signature: SignaturePluginApi
sidebar: SidebarPluginApi
}Individual Plugin APIs
| Plugin Factory | API Type | Key Methods |
|---|---|---|
zoomPlugin() | ZoomPluginApi | zoomIn(), zoomOut(), zoomTo(scale), setFitMode(mode) |
pageNavigationPlugin() | PageNavigationPluginApi | goToPage(n), goToNextPage(), goToPreviousPage(), goToFirstPage(), goToLastPage() |
rotationPlugin() | RotationPluginApi | rotateCW(), rotateCCW() |
searchPlugin() | SearchPluginApi | open(), close() |
printPlugin() | PrintPluginApi | print() |
downloadPlugin() | DownloadPluginApi | download() |
themePlugin() | ThemePluginApi | toggleTheme(), setTheme(mode), getTheme() |
fullscreenPlugin() | FullscreenPluginApi | enterFullscreen(), exitFullscreen(), toggleFullscreen() |
selectionPlugin() | SelectionPluginApi | setCursorTool(tool) |
scrollModePlugin() | ScrollModePluginApi | setScrollMode(mode) |
spreadModePlugin() | SpreadModePluginApi | setSpreadMode(mode) |
signaturePlugin() | SignaturePluginApi | openPanel(), closePanel(), togglePanel() |
sidebarPlugin() | SidebarPluginApi | toggle(tab?), open(tab), close() |
Plugins without a public API (UI-only contributions):
| Plugin Factory | Description |
|---|---|
toolbarPlugin() | Toolbar with slot system |
thumbnailPlugin() | Thumbnail sidebar tab |
bookmarkPlugin() | Bookmark/outline sidebar tab |
attachmentPlugin() | Attachment sidebar tab |
highlightPlugin() | Text highlighting |
openFilePlugin() | File open and drag-drop |
propertiesPlugin() | Document properties modal |
shortcutHelpPlugin() | Keyboard shortcuts help panel |
contextMenuPlugin() | Right-click context menu |
moreMenuPlugin() | Overflow menu for toolbar items |
Toolbar Components
import { Toolbar, ToolbarButton, ToolbarDivider } from '@trexolab/verifykit-react'| Component | Description |
|---|---|
Toolbar | Toolbar container with 3-section grid layout |
ToolbarButton | Standard toolbar button primitive |
ToolbarDivider | Visual divider between toolbar groups |
@trexolab/verifykit-vanilla
Zero-build PDF viewer for vanilla JavaScript, CDN, and non-React environments. Bundles React 19 internally.
VeriPdf.create(container, options?)
Creates a viewer instance on a DOM element.
function create(container: HTMLElement, options?: VeriPdfOptions): VeriPdfInstanceAlso available as VeriPdf.create() (UMD global) or import { create } from '@trexolab/verifykit-vanilla' (ESM).
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
container | HTMLElement | Yes | The DOM element to mount the viewer in |
options | VeriPdfOptions | No | Configuration options |
Throws: If container is not a valid HTMLElement.
VeriPdfOptions
interface VeriPdfOptions {
theme?: { mode?: 'light' | 'dark' | 'system'; overrides?: Record<string, string> }
workerSrc?: string
features?: VeriPdfFeatures
trustStore?: TrustStoreConfig
plugins?: VeriPdfPlugin[]
locale?: string
translations?: Partial<TranslationStrings>
onVerified?: (result: VerificationResult) => void
onError?: (error: string) => void
onDocumentLoaded?: (info: { pageCount: number; fileName: string }) => void
onPageChange?: (page: number) => void
onZoomChange?: (scale: number) => void
onThemeChange?: (mode: 'light' | 'dark') => void
}VeriPdfFeatures
interface VeriPdfFeatures {
search?: boolean // default: true
print?: boolean // default: true
download?: boolean // default: false
signatures?: boolean // default: true
thumbnails?: boolean // default: true
fullscreen?: boolean // default: true
themeToggle?: boolean // default: true
openFile?: boolean // default: false
rotation?: boolean // default: true
contextMenu?: boolean // default: true
properties?: boolean // default: true
shortcuts?: boolean // default: true
highlights?: boolean // default: true
}VeriPdfInstance
The object returned by VeriPdf.create():
Document Methods
| Method | Signature | Description |
|---|---|---|
load | (input: PdfInput, fileName?: string) => Promise<VerificationResult> | Load and verify a PDF |
destroy | () => void | Destroy the viewer and clean up all resources |
Theme
| Method | Signature | Description |
|---|---|---|
setTheme | (mode: 'light' | 'dark' | 'system') => void | Change the theme |
Navigation
| Method | Signature | Description |
|---|---|---|
goToPage | (page: number) => void | Navigate to a specific page |
goToPreviousPage | () => void | Go to the previous page |
goToNextPage | () => void | Go to the next page |
goToFirstPage | () => void | Go to the first page |
goToLastPage | () => void | Go to the last page |
getCurrentPage | () => number | Get the current page number |
getPageCount | () => number | Get the total page count |
Zoom
| Method | Signature | Description |
|---|---|---|
zoomIn | () => void | Increase zoom level |
zoomOut | () => void | Decrease zoom level |
zoomTo | (scale: number) => void | Set zoom to a specific scale |
setFitMode | (mode: 'none' | 'width' | 'page') => void | Set the fit mode |
getZoom | () => number | Get the current zoom scale |
Rotation
| Method | Signature | Description |
|---|---|---|
rotateCW | () => void | Rotate clockwise 90 degrees |
rotateCCW | () => void | Rotate counter-clockwise 90 degrees |
getRotation | () => number | Get the current rotation in degrees |
Search
| Method | Signature | Description |
|---|---|---|
openSearch | () => void | Open the search bar |
closeSearch | () => void | Close the search bar |
Print and Download
| Method | Signature | Description |
|---|---|---|
print | () => void | Print the document |
download | () => void | Download the document |
Fullscreen
| Method | Signature | Description |
|---|---|---|
enterFullscreen | () => void | Enter fullscreen mode |
exitFullscreen | () => void | Exit fullscreen mode |
toggleFullscreen | () => void | Toggle fullscreen mode |
Signature Panel
| Method | Signature | Description |
|---|---|---|
openSignaturePanel | () => void | Open the signature panel |
closeSignaturePanel | () => void | Close the signature panel |
Events
| Method | Signature | Description |
|---|---|---|
on | (event: string, handler: (...args: unknown[]) => void) => () => void | Subscribe to events; returns an unsubscribe function |
Supported events:
| Event | Payload | Description |
|---|---|---|
pageChange | number | Current page changed |
zoomChange | number | Zoom scale changed |
themeChange | 'light' | 'dark' | Theme mode changed |
rotationChange | number | Rotation changed |
fullscreenChange | boolean | Fullscreen state changed |
documentLoaded | { pageCount: number; fileName: string } | Document finished loading |
verified | VerificationResult | Verification completed |
error | string | Error occurred |
State
| Method | Signature | Description |
|---|---|---|
getVerificationResult | () => VerificationResult | null | Get the last verification result |
getSignatures | () => PdfSignature[] | Get the current signature list |
@trexolab/verifykit-plugin-revocation
Online CRL and OCSP revocation checking plugin for @trexolab/verifykit-core.
revocationPlugin(options?)
Creates a revocation checking plugin.
function revocationPlugin(options?: RevocationPluginOptions): VeriPdfPluginOptions:
interface RevocationPluginOptions {
timeout?: number // Request timeout in ms (default: 10000)
crl?: boolean // Enable CRL checking (default: true)
ocsp?: boolean // Enable OCSP checking (default: true)
maxCrlSize?: number // Maximum CRL download size in bytes (default: 10 MB)
}Usage with createVerifier():
import { createVerifier } from '@trexolab/verifykit-core'
import { revocationPlugin } from '@trexolab/verifykit-plugin-revocation'
const verifier = await createVerifier({
plugins: [revocationPlugin({ timeout: 15_000 })],
})Usage with vanilla API:
import { create } from '@trexolab/verifykit-vanilla'
import { revocationPlugin } from '@trexolab/verifykit-plugin-revocation'
const viewer = create(container, {
plugins: [revocationPlugin()],
})Behavior:
Without the plugin, revocationCheck.status is "unknown" with a detail like "Not checked (offline)." With the plugin installed, the engine performs live CRL and OCSP lookups for each signer certificate:
- OCSP is attempted first (if
ocspistrueand the certificate has OCSP URLs). - CRL is attempted as a fallback (if
crlistrueand the certificate has CRL distribution points). - If both methods fail or are disabled, the check remains
"unknown".
The plugin respects the signing timestamp: if a certificate was revoked after the signing time (and the signature has a valid timestamp), the status is "revokedAfterSigning" which resolves as "valid" -- the signature was valid at the time it was created.