SignatureKit
A1 signing

Browser PDF flow

Read a PDF, build the A1 signature placement template, and sign with the browser helpers.

The browser helpers are the typed bridge between a file input and the PDF builder state. They keep byte handling in Effect, produce a validated placement template, and sign the selected field with the provided A1 layer.

Steps

readPdfBlobBytes(file) turns a browser Blob into Uint8Array inside the typed error channel.
createPdfSignatureBuilderStateFromBytes(...) reads page dimensions, creates the template, and optionally auto-places a draft field.
Create a PdfSignatureBuilderStore once and let your app subscribe to it with its own React/Vue/Svelte boundary.
signPdfSignatureField(...) turns the selected field into a PDF appearance and delegates cryptography to Signatures.
browser-a1-flow.ts
import { a1SignaturesLayer } from "@signature-kit/a1/signer"
import {
  createPdfSignatureBuilderStateFromBytes,
  readPdfBlobBytes,
  signPdfSignatureField,
} from "@signature-kit/pdf/workflow"
import { createPdfSignatureBuilderStore } from "@signature-kit/pdf/builder-store"
import { Effect, Redacted } from "effect"

const pdf = await Effect.runPromise(readPdfBlobBytes(file))
const state = await Effect.runPromise(
  createPdfSignatureBuilderStateFromBytes({
    id: "contract-a1",
    name: file.name,
    documentId: "contract",
    documentName: file.name,
    pdf,
    role: { id: "signer", label: "Signer A1", required: true },
    draft: { id: "sig", type: "signature", roleId: "signer", width: 156, height: 42 },
    autoPlacement: { page: "last", slot: "bottom-right", margin: 24 },
  }),
)

const store = createPdfSignatureBuilderStore(state)

const signedPdf = await Effect.runPromise(
  signPdfSignatureField({
    pdf,
    template: store.getSnapshot().template,
    fieldId: "sig",
    reason: "Signed locally with A1",
    signatureLength: 16384,
  }).pipe(
    Effect.provide(a1SignaturesLayer({ pfx, password: Redacted.make(password) })),
  ),
)

Batch signing

Use signPdfSignatureBatch(items, callbacks) when one A1 certificate signs many PDFs. It runs sequentially, captures per-document failures as result values, and keeps one bad document from aborting the batch.

Prepare in a Web Worker

PdfWorker prepares documents and renders stamp previews in a worker using native Effect RPC. The browser layer terminates the worker when its scope closes; interrupting the Effect cancels the session. Progress callbacks run on the page, and callers retain their original bytes. Certificates and passwords are outside this protocol: provide the A1 layer at the signing boundary.

import type { PdfSigningBatchPreparationInput } from "@signature-kit/pdf/config"
import { PdfWorker } from "@signature-kit/pdf/worker"
import { pdfWorkerBrowserLayer } from "@signature-kit/pdf/worker-browser"
import { Effect } from "effect"

const prepare = (input: PdfSigningBatchPreparationInput) =>
  Effect.gen(function* () {
    const worker = yield* PdfWorker
    return yield* worker.prepare(input)
  }).pipe(Effect.provide(pdfWorkerBrowserLayer()))

How is this guide?

On this page