@embedpdf/plugin-signature 3.0.0-next.13 → 3.0.0-next.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","names":["FormToken","StampToken","AnnotationToken","ANNOTATION_EDIT_PRIORITY","ARMED_STAMP_TOOL_ID","SignatureToken","FormToken","InteractionToken","StampToken","AnnotationToken"],"sources":["../src/blank-page.ts","../src/capability.ts","../src/handler.ts","../src/reducer.ts","../src/signature.plugin.ts"],"sourcesContent":["/** A one-page blank PDF: the appearance that clears a visual fill. */\n// A content stream that draws NOTHING but is not empty (`q Q`): the engine\n// turns the page into a form XObject, and a page with no content at all has\n// nothing to turn — it refuses; a saved/restored state passes and paints\n// nothing.\nconst CONTENT = 'q Q';\nconst OBJECTS = [\n '<< /Type /Catalog /Pages 2 0 R >>',\n '<< /Type /Pages /Kids [3 0 R] /Count 1 >>',\n '<< /Type /Page /Parent 2 0 R /MediaBox [0 0 200 60] /Contents 4 0 R /Resources << >> >>',\n `<< /Length ${CONTENT.length} >>\\nstream\\n${CONTENT}\\nendstream`,\n];\n\nlet cached: Uint8Array | null = null;\n\nexport function blankPagePdf(): Uint8Array {\n if (cached) return new Uint8Array(cached);\n let body = '%PDF-1.7\\n';\n const offsets: number[] = [];\n OBJECTS.forEach((object, index) => {\n offsets.push(body.length);\n body += `${index + 1} 0 obj\\n${object}\\nendobj\\n`;\n });\n const xref = body.length;\n body += `xref\\n0 ${OBJECTS.length + 1}\\n0000000000 65535 f \\n`;\n for (const offset of offsets) body += `${String(offset).padStart(10, '0')} 00000 n \\n`;\n body += `trailer\\n<< /Size ${OBJECTS.length + 1} /Root 1 0 R >>\\nstartxref\\n${xref}\\n%%EOF\\n`;\n cached = new TextEncoder().encode(body);\n return new Uint8Array(cached);\n}\n","import { createEventHook, type PluginContext } from '@embedpdf/core';\nimport {\n certificateCommonName,\n sign,\n validateSignatures,\n type SignatureVerdict,\n type SignerPort,\n type ValidationTime,\n} from '@embedpdf/core-signature';\nimport {\n resolveBinarySource,\n type AnalyzeInput,\n type BinarySource,\n type ChangeAnalysis,\n type DocumentEvent,\n type DocumentProtection,\n type FormFieldRef,\n type SignatureCompleteResult,\n type SignatureDTO,\n type SignatureSnapshot,\n} from '@embedpdf/engine-core/runtime';\nimport { AnnotationToken, type StampPlacement } from '@embedpdf/plugin-annotation/contract';\nimport { FormToken } from '@embedpdf/plugin-form/contract';\nimport { StampToken } from '@embedpdf/plugin-stamp/contract';\n\nimport { blankPagePdf } from './blank-page';\nimport type {\n Mark,\n SignatureAction,\n SignatureCapability,\n SignatureChange,\n SignatureConfig,\n SignatureMode,\n SignatureState,\n SignFieldInput,\n} from './types';\n\nconst sameRef = (a: FormFieldRef, b: FormFieldRef): boolean =>\n a.kind === 'objectNumber' && b.kind === 'objectNumber'\n ? a.fieldObjectNumber === b.fieldObjectNumber\n : a.kind === 'fqn' && b.kind === 'fqn'\n ? a.name === b.name\n : false;\n\nconst sameProtection = (a: DocumentProtection | null, b: DocumentProtection | null): boolean =>\n JSON.stringify(a) === JSON.stringify(b);\n\nexport function createSignatureCapability(\n ctx: PluginContext<SignatureState, SignatureAction>,\n config: SignatureConfig = {},\n): SignatureCapability {\n const form = ctx.get(FormToken);\n const changed = createEventHook<SignatureChange>((error) =>\n globalThis.console?.error('[signature] listener failed:', error),\n );\n ctx.cleanup(() => changed.dispose());\n\n const state = () => ctx.getState();\n const requireDoc = () => {\n const doc = ctx.doc;\n if (!doc) throw new Error('[signature] no document bound');\n return doc;\n };\n const requireSignatures = () => {\n const doc = requireDoc();\n if (!doc.signatures) throw new Error('[signature] this engine does not implement signatures');\n return { doc, signatures: doc.signatures };\n };\n const stamp = () => ctx.tryGet(StampToken);\n const documentId = () => {\n const id = ctx.documentId;\n if (!id) throw new Error('[signature] no document id');\n return id;\n };\n\n // ── mode and signer ─────────────────────────────────────────────────────\n const mode = (): SignatureMode => config.mode ?? (config.signer ? 'sign' : 'visual');\n const resolveSigner = async (): Promise<SignerPort> => {\n const signer = config.signer;\n if (!signer) throw new Error('[signature] no signer configured (mode \"sign\" needs one)');\n return typeof signer === 'function' ? signer() : signer;\n };\n const allows = (cap: 'doc.sign' | 'doc.sign.certify' | 'doc.forms.fill'): boolean =>\n ctx.doc?.security.allows(cap) ?? false;\n\n // ── snapshot + verdicts ─────────────────────────────────────────────────\n const refresh = async (): Promise<SignatureSnapshot | null> => {\n const doc = ctx.doc;\n if (!doc?.signatures) {\n ctx.dispatch({ type: 'SNAPSHOT', snapshot: null });\n return null;\n }\n const before = state().snapshot?.protection ?? null;\n const snapshot = await doc.signatures.list();\n ctx.dispatch({ type: 'SNAPSHOT', snapshot });\n if (!sameProtection(before, snapshot.protection)) {\n changed.emit({ type: 'protectionChanged', protection: snapshot.protection });\n }\n return snapshot;\n };\n\n const validate = async (opts?: {\n at?: ValidationTime;\n until?: 'persisted' | 'working-copy';\n }): Promise<SignatureVerdict[]> => {\n const doc = ctx.doc;\n if (!doc?.signatures) return [];\n const verdicts = await validateSignatures(doc, {\n trust: config.trust ?? null,\n at: opts?.at,\n until: opts?.until ?? 'working-copy',\n });\n const before = state().verdicts;\n ctx.dispatch({ type: 'VERDICTS', verdicts });\n changed.emit({ type: 'validated', verdicts });\n // Acrobat's warning, after the fact and only on the edge: a signature that\n // held (or was never judged) now reads invalid because of unsaved edits.\n for (const v of verdicts) {\n if (v.modifications.basis !== 'working-copy' || v.summary !== 'invalid') continue;\n const was = before?.find((b) => b.signature.index === v.signature.index);\n if (was && was.summary === 'invalid') continue;\n changed.emit({\n type: 'invalidating',\n field: v.signature.field,\n detail: v.modifications.detail ?? '',\n });\n }\n return verdicts;\n };\n\n // Every edit that could count as a modification re-judges the working copy.\n // Coalesced: a pen stroke is many events, one analysis.\n let revalidateTimer: ReturnType<typeof setTimeout> | null = null;\n const revalidateSoon = (): void => {\n if (!state().snapshot?.signatures.some((s) => s.signed)) return;\n if (revalidateTimer) clearTimeout(revalidateTimer);\n revalidateTimer = setTimeout(() => {\n revalidateTimer = null;\n void validate().catch((error) =>\n globalThis.console?.error('[signature] re-validation failed:', error),\n );\n }, 300);\n };\n ctx.cleanup(() => {\n if (revalidateTimer) clearTimeout(revalidateTimer);\n });\n\n const analyze = (input: AnalyzeInput): Promise<ChangeAnalysis> =>\n requireSignatures().signatures.analyze(input);\n\n const signatureOf = (\n field: FormFieldRef | { annotObjectNumber: number },\n ): SignatureDTO | null => {\n const snapshot = state().snapshot;\n if (!snapshot) return null;\n if ('annotObjectNumber' in field) {\n const byWidget = snapshot.signatures.find(\n (s) => s.widget?.annotObjectNumber === field.annotObjectNumber,\n );\n if (byWidget) return byWidget;\n const owner = form.fieldForWidget(field.annotObjectNumber);\n return owner ? signatureOf(owner.ref) : null;\n }\n return (\n snapshot.signatures.find((s) =>\n field.kind === 'fqn' ? s.fieldName === field.name : sameRef(s.field, field),\n ) ?? null\n );\n };\n const verdictOf = (\n field: FormFieldRef | { annotObjectNumber: number },\n ): SignatureVerdict | null => {\n const signature = signatureOf(field);\n if (!signature) return null;\n return state().verdicts?.find((v) => v.signature.index === signature.index) ?? null;\n };\n\n // ── marks → bytes ───────────────────────────────────────────────────────\n const bytesOf = async (source: BinarySource): Promise<Uint8Array> =>\n new Uint8Array((await resolveBinarySource(source)).bytes);\n const markBytes = async (mark: Mark): Promise<Uint8Array> => {\n if ('assetId' in mark) {\n const bytes = stamp()?.assetBytes(mark.assetId);\n if (!bytes) throw new Error(`[signature] unknown mark '${mark.assetId}'`);\n return bytes;\n }\n return bytesOf(mark.source);\n };\n\n const withBusy = async <T>(work: () => Promise<T>): Promise<T> => {\n ctx.dispatch({ type: 'BUSY', busy: true });\n try {\n return await work();\n } finally {\n ctx.dispatch({ type: 'BUSY', busy: false });\n }\n };\n\n // ── the act ─────────────────────────────────────────────────────────────\n const signField = (input: SignFieldInput): Promise<SignatureCompleteResult> =>\n withBusy(async () => {\n const { doc } = requireSignatures();\n const signer = await resolveSigner();\n // The certificate's subject is the default /Name; the caller's facts win.\n const subject =\n signer.kind === 'raw' && signer.certificateChain[0]\n ? certificateCommonName(signer.certificateChain[0])\n : null;\n const attribution = { ...(subject ? { name: subject } : {}), ...input.attribution };\n // The appearance IS the mark: its page is drawn into the widget by the engine.\n const appearance = input.appearance\n ? await bytesOf(input.appearance)\n : await markBytes(input.mark);\n const result = await sign(doc, {\n field: input.field,\n signer,\n attribution,\n certify: input.certify,\n lock: input.lock,\n appearance: { pdf: appearance, pageIndex: 0 },\n });\n if (state().target && sameRef(state().target!, input.field)) setTarget(null);\n await refresh();\n void validate().catch((error) =>\n globalThis.console?.error('[signature] validation after signing failed:', error),\n );\n changed.emit({ type: 'signed', field: input.field, result });\n return result;\n });\n\n const setAppearance = async (field: FormFieldRef, pdf: Uint8Array): Promise<void> => {\n const doc = requireDoc();\n if (!doc.forms.setSignatureAppearance) {\n throw new Error('[signature] this engine cannot draw into a signature field');\n }\n const signature = signatureOf(field);\n if (signature?.signed) throw new Error(`[signature] '${signature.fieldName}' is signed`);\n await doc.forms.setSignatureAppearance(field, { pdf, pageIndex: 0 });\n await form.refresh();\n };\n\n const fillField = (field: FormFieldRef, mark: Mark): Promise<void> =>\n withBusy(async () => {\n await setAppearance(field, await markBytes(mark));\n if (state().target && sameRef(state().target!, field)) setTarget(null);\n changed.emit({ type: 'filled', field });\n });\n\n const clearField = (field: FormFieldRef): Promise<void> =>\n withBusy(async () => {\n await setAppearance(field, blankPagePdf());\n changed.emit({ type: 'cleared', field });\n });\n\n const placeMark = async (\n mark: Mark,\n target: { field: FormFieldRef } | StampPlacement,\n ): Promise<void> => {\n if (!('field' in target)) {\n // Free placement: a stamp, as in Preview — one placement law, the stamp plugin's.\n if ('assetId' in mark) {\n const library = stamp();\n if (!library) throw new Error('[signature] no stamp plugin to place an asset');\n await library.placeAsset(documentId(), mark.assetId, target);\n } else {\n await ctx.get(AnnotationToken).placeStamp({ source: mark.source }, target);\n }\n return;\n }\n switch (mode()) {\n case 'sign':\n // The first signature is the one that can certify: when the config\n // allows a certification, let the chrome offer the choice (its sign\n // dialog) instead of sealing a plain approval on the spot.\n if (config.allowCertify && !state().snapshot?.signatures.some((s) => s.signed)) {\n changed.emit({ type: 'ask', field: target.field, mark });\n return;\n }\n await signField({ field: target.field, mark });\n return;\n case 'visual':\n await fillField(target.field, mark);\n return;\n case 'ask':\n changed.emit({ type: 'ask', field: target.field, mark });\n return;\n }\n };\n\n const setTarget = (field: FormFieldRef | null): void => {\n const current = state().target;\n if (current === field || (current && field && sameRef(current, field))) return;\n ctx.dispatch({ type: 'TARGET', field });\n changed.emit({ type: 'target', field });\n };\n\n // ── live: pendings, versions, remote signings ───────────────────────────\n const doc = ctx.doc;\n if (doc) {\n const unsubscribe = doc.events.subscribe((event: DocumentEvent) => {\n switch (event.type) {\n case 'signature.prepared':\n ctx.dispatch({\n type: 'PENDING',\n pending: { signingId: event.signingId, field: event.field },\n });\n return;\n case 'signature.aborted':\n ctx.dispatch({ type: 'PENDING', pending: null });\n return;\n case 'signature.completed':\n ctx.dispatch({ type: 'PENDING', pending: null });\n return;\n case 'document.versioned':\n case 'stream.desynced':\n // Byte-level facts moved: re-read them and re-judge.\n void refresh()\n .then(() => validate())\n .catch((error) => globalThis.console?.error('[signature] refresh failed:', error));\n return;\n case 'form.fieldCreated':\n case 'form.fieldDeleted':\n case 'form.widgetAttached':\n case 'form.widgetDetached':\n case 'form.imported':\n case 'form.repaired':\n // The field set changed (a signature field authored or removed, here\n // or remotely): the snapshot lists fields, so re-read it — and the\n // change is a modification of the working copy, so re-judge.\n void refresh()\n .then(() => revalidateSoon())\n .catch((error) => globalThis.console?.error('[signature] refresh failed:', error));\n return;\n case 'annotation.created':\n case 'annotation.updated':\n case 'annotation.deleted':\n case 'annotation.moved':\n case 'form.valueChanged':\n case 'form.fieldUpdated':\n case 'form.effectsApplied':\n // An edit of the working copy: what a save would write changed, so\n // what a validator would say about it may have too.\n revalidateSoon();\n return;\n default:\n return;\n }\n });\n ctx.cleanup(unsubscribe);\n }\n\n return {\n snapshot: () => state().snapshot,\n verdicts: () => state().verdicts,\n protection: () => state().snapshot?.protection ?? null,\n pending: () => state().pending,\n target: () => state().target,\n busy: () => state().busy,\n mode,\n signatureOf,\n verdictOf,\n canSign: () => allows('doc.sign') && config.signer != null,\n canFill: () => allows('doc.forms.fill') && ctx.doc?.forms.setSignatureAppearance != null,\n canCertify: () => config.allowCertify === true && allows('doc.sign.certify'),\n signField,\n fillField,\n clearField,\n placeMark,\n setTarget,\n inspect: (field) => changed.emit({ type: 'inspect', field }),\n refresh,\n validate,\n analyze,\n revisionBytes: (revisionIndex) => requireSignatures().signatures.revisionBytes(revisionIndex),\n onChanged: changed.on,\n };\n}\n","import type { InteractionHandler } from '@embedpdf/plugin-interaction/contract';\nimport {\n ANNOTATION_EDIT_PRIORITY,\n ARMED_STAMP_TOOL_ID,\n} from '@embedpdf/plugin-annotation/contract';\nimport type { FormCapability } from '@embedpdf/plugin-form/contract';\nimport type { StampCapability } from '@embedpdf/plugin-stamp/contract';\n\nimport { SIGNATURES_LIBRARY_KIND, type SignatureCapability } from './types';\n\n/**\n * The armed mark over a field. The annotation plugin places an armed stamp\n * on click (`annotation-place`, priority 95) and selects an existing\n * annotation under the pointer before that (`annotation-edit`, 100 — a\n * widget is an annotation). This handler sits above BOTH, enabled for the\n * armed stamp's tool only, and captures exactly when the armed asset is a\n * person's mark (a library of kind `signatures`) and the pointer is over a\n * signature field: then the destination decides — the mark goes INTO the\n * field (`placeMark` by mode) instead of onto the page. Everywhere else it\n * declines and the click stays a stamp placement, as in Preview.\n */\nexport function createArmedMarkHandler(\n documentId: string,\n signature: SignatureCapability,\n form: FormCapability,\n stamp: StampCapability,\n): InteractionHandler {\n return {\n id: 'signature:armed-mark-on-field',\n priority: ANNOTATION_EDIT_PRIORITY + 1,\n enabledFor: (tool) => tool.id === ARMED_STAMP_TOOL_ID,\n onDown: (sample) => {\n if (!sample.page) return false;\n const armed = stamp.armedAsset(documentId);\n if (!armed || stamp.library(armed.libraryId)?.kind !== SIGNATURES_LIBRARY_KIND) return false;\n const hit = form.widgetAt(sample.page.pon, sample.page.point);\n if (!hit || hit.field.family !== 'signature') return false;\n // A signed field is final: consume the click (no stamp lands on it) and do nothing.\n if (signature.signatureOf(hit.field.ref)?.signed || hit.field.valueEntry.kind !== 'none') {\n return true;\n }\n stamp.disarm(documentId);\n void signature\n .placeMark({ assetId: armed.id }, { field: hit.field.ref })\n .catch((error) => globalThis.console?.error('[signature] placing the mark failed:', error));\n return true;\n },\n };\n}\n","import type { SignatureAction, SignatureState } from './types';\n\nexport const initialSignatureState = (): SignatureState => ({\n snapshot: null,\n verdicts: null,\n target: null,\n pending: null,\n busy: false,\n});\n\nexport function signatureReducer(state: SignatureState, action: SignatureAction): SignatureState {\n switch (action.type) {\n case 'SNAPSHOT':\n return { ...state, snapshot: action.snapshot };\n case 'VERDICTS':\n return { ...state, verdicts: action.verdicts };\n case 'TARGET':\n return { ...state, target: action.field };\n case 'PENDING':\n return { ...state, pending: action.pending };\n case 'BUSY':\n return { ...state, busy: action.busy };\n default:\n return state;\n }\n}\n","import { definePlugin } from '@embedpdf/core';\nimport { FormToken } from '@embedpdf/plugin-form/contract';\nimport { InteractionToken } from '@embedpdf/plugin-interaction/contract';\nimport { StampToken } from '@embedpdf/plugin-stamp/contract';\nimport { AnnotationToken } from '@embedpdf/plugin-annotation/contract';\n\nimport { createSignatureCapability } from './capability';\nimport { createArmedMarkHandler } from './handler';\nimport { initialSignatureState, signatureReducer } from './reducer';\nimport { SignatureToken } from './types';\nimport type {\n SignatureAction,\n SignatureCapability,\n SignatureConfig,\n SignatureState,\n} from './types';\n\n/**\n * The signature plugin — the ACT of signing, document-scoped. It owns no\n * mark: marks are stamp-library assets (or bytes the embedder brings), and\n * the mark IS the appearance the engine draws into the field. Signing goes\n * through `@embedpdf/core-signature` with the configured signer port; the\n * engine seals; on the cloud the server publishes the new version.\n *\n * With the interaction hub and the stamp plugin present, an armed mark from\n * a `signatures` library dropped over an unsigned signature field goes into\n * the field (sign / visual fill / ask, by mode) instead of onto the page.\n */\nexport const signaturePlugin = (config: SignatureConfig = {}) =>\n definePlugin<SignatureState, SignatureAction, SignatureCapability>({\n id: 'signature',\n token: SignatureToken,\n scope: 'document',\n requires: [FormToken],\n optional: [InteractionToken, StampToken, AnnotationToken],\n initialState: initialSignatureState,\n reduce: signatureReducer,\n capability: (ctx) => createSignatureCapability(ctx, config),\n init: (ctx) => {\n const signature = ctx.get(SignatureToken);\n void signature\n .refresh()\n .then((snapshot) =>\n snapshot?.signatures.some((s) => s.signed) ? signature.validate() : null,\n )\n .catch((error) => globalThis.console?.error('[signature] initial read failed:', error));\n const interaction = ctx.tryGet(InteractionToken);\n const stamp = ctx.tryGet(StampToken);\n if (interaction && stamp && ctx.documentId) {\n ctx.cleanup(\n interaction.registerHandler(\n createArmedMarkHandler(ctx.documentId, signature, ctx.get(FormToken), stamp),\n ),\n );\n }\n },\n });\n"],"mappings":";;;;;;;;;;AAMA,MAAM,UAAU;CACd;CACA;CACA;CACA;AACF;AAEA,IAAI,SAA4B;AAEhC,SAAgB,eAA2B;CACzC,IAAI,QAAQ,OAAO,IAAI,WAAW,MAAM;CACxC,IAAI,OAAO;CACX,MAAM,UAAoB,CAAC;CAC3B,QAAQ,SAAS,QAAQ,UAAU;EACjC,QAAQ,KAAK,KAAK,MAAM;EACxB,QAAQ,GAAG,QAAQ,EAAE,UAAU,OAAO;CACxC,CAAC;CACD,MAAM,OAAO,KAAK;CAClB,QAAQ,WAAW,QAAQ,SAAS,EAAE;CACtC,KAAK,MAAM,UAAU,SAAS,QAAQ,GAAG,OAAO,MAAM,CAAC,CAAC,SAAS,IAAI,GAAG,EAAE;CAC1E,QAAQ,qBAAqB,QAAQ,SAAS,EAAE,8BAA8B,KAAK;CACnF,SAAS,IAAI,YAAY,CAAC,CAAC,OAAO,IAAI;CACtC,OAAO,IAAI,WAAW,MAAM;AAC9B;;;ACQA,MAAM,WAAW,GAAiB,MAChC,EAA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AAO;EAAS;EAC/C,KAAK,YACH,OAAO;GAAE,GAAG;GAAO,UAAU,OAAO;EAAS;EAC/C,KAAK,UACH,OAAO;GAAE,GAAG;GAAO,QAAQ,OAAO;EAAM;EAC1C,KAAK,WACH,OAAO;GAAE,GAAG;GAAO,SAAS,OAAO;EAAQ;EAC7C,KAAK,QACH,OAAO;GAAE,GAAG;GAAO,MAAM,OAAO;EAAK;EACvC,SACE,OAAO;CACX;AACF;;;;;;;;;;;;;;ACGA,MAAa,mBAAmB,SAA0B,CAAC,OAAA,GAAA,eAAA,aAAA,CACU;CACjE,IAAI;CACJ,OAAOC,iBAAAA;CACP,OAAO;CACP,UAAU,CAACC,+BAAAA,SAAS;CACpB,UAAU;EAACC,sCAAAA;EAAkBC,gCAAAA;EAAYC,qCAAAA;CAAe;CACxD,cAAc;CACd,QAAQ;CACR,aAAa,QAAQ,0BAA0B,KAAK,MAAM;CAC1D,OAAO,QAAQ;EACb,MAAM,YAAY,IAAI,IAAIJ,iBAAAA,cAAc;EACxC,UACG,QAAQ,CAAC,CACT,MAAM,aACL,UAAU,WAAW,MAAM,MAAM,EAAE,MAAM,IAAI,UAAU,SAAS,IAAI,IACtE,CAAC,CACA,OAAO,UAAU,WAAW,SAAS,MAAM,oCAAoC,KAAK,CAAC;EACxF,MAAM,cAAc,IAAI,OAAOE,sCAAAA,gBAAgB;EAC/C,MAAM,QAAQ,IAAI,OAAOC,gCAAAA,UAAU;EACnC,IAAI,eAAe,SAAS,IAAI,YAC9B,IAAI,QACF,YAAY,gBACV,uBAAuB,IAAI,YAAY,WAAW,IAAI,IAAIF,+BAAAA,SAAS,GAAG,KAAK,CAC7E,CACF;CAEJ;AACF,CAAC"}
1
+ {"version":3,"file":"index.cjs","names":["ANNOTATION_EDIT_PRIORITY","ARMED_STAMP_TOOL_ID","InteractionToken","StampToken","FormToken","PluginError","PluginError","PluginError","FormToken","StampToken","AnnotationToken","PluginError","PluginError","PluginError","PluginError","SignatureToken","FormToken","InteractionToken","StampToken","AnnotationToken","SIGNATURE_DEFAULTS","SignatureToken"],"sources":["../src/tools/armed-mark.ts","../src/connect.ts","../src/services/errors.ts","../src/read/judging.ts","../src/model.ts","../src/read/signatures.ts","../src/services/authority.ts","../src/services/events.ts","../src/services/marks.ts","../src/services/siblings.ts","../src/services/store.ts","../src/services/index.ts","../src/sync/signatures.ts","../src/sync/validation.ts","../src/blank-page.ts","../src/write/fill.ts","../src/write/place.ts","../src/write/sign.ts","../src/controller.ts","../src/signature.plugin.ts","../src/state.ts"],"sourcesContent":["import type { InteractionHandler } from '@embedpdf/plugin-interaction/contract/host';\nimport {\n ANNOTATION_EDIT_PRIORITY,\n ARMED_STAMP_TOOL_ID,\n} from '@embedpdf/plugin-annotation/contract/host';\nimport type { FormCapability } from '@embedpdf/plugin-form/contract';\nimport type { StampCapability } from '@embedpdf/plugin-stamp/contract';\n\nimport { SIGNATURES_LIBRARY_KIND, type SignatureCapability } from '../contract';\n\n/**\n * The armed mark over a field. The annotation plugin places an armed stamp\n * on click (`annotation-place`, priority 95) and selects an existing\n * annotation under the pointer before that (`annotation-edit`, 100; a\n * widget is an annotation). This handler sits above both, enabled for the\n * armed stamp's tool only, and captures exactly when the armed asset is a\n * person's mark (a library of kind `signatures`) and the pointer is over a\n * signature field: then the destination decides, and the mark goes into the\n * field (`placeMark` by mode) instead of onto the page. Everywhere else it\n * declines and the click stays a stamp placement, as in Preview.\n */\nexport function createArmedMarkHandler(\n documentId: string,\n signature: SignatureCapability,\n form: FormCapability,\n stamp: StampCapability,\n): InteractionHandler {\n return {\n id: 'signature:armed-mark-on-field',\n priority: ANNOTATION_EDIT_PRIORITY + 1,\n enabledFor: (tool) => tool.id === ARMED_STAMP_TOOL_ID,\n onDown: (sample) => {\n if (!sample.page) return false;\n const armed = stamp.getArmedAsset(documentId);\n if (!armed || stamp.getLibrary(armed.libraryId)?.kind !== SIGNATURES_LIBRARY_KIND)\n return false;\n const hit = form.getWidgetAt(sample.page.ref, sample.page.point);\n if (!hit || hit.field.family !== 'signature') return false;\n // A signed field is final: consume the click (no stamp lands on it) and do nothing.\n if (signature.getSignature(hit.field.ref)?.signed || hit.field.valueEntry.kind !== 'none') {\n return true;\n }\n stamp.disarm(documentId);\n void signature\n .placeMark({ assetId: armed.id }, { field: hit.field.ref })\n .catch((error) => globalThis.console?.error('[signature] placing the mark failed:', error));\n return true;\n },\n };\n}\n","/**\n * Wiring to sibling plugins. With the interaction hub and the stamp plugin\n * present, an armed mark from a `signatures` library dropped over an\n * unsigned signature field goes into the field instead of onto the page.\n */\nimport { FormToken } from '@embedpdf/plugin-form/contract';\nimport { InteractionToken } from '@embedpdf/plugin-interaction/contract/host';\nimport { StampToken } from '@embedpdf/plugin-stamp/contract';\n\nimport type { SignatureCapability } from './contract';\nimport type { SignatureContext } from './services';\nimport { createArmedMarkHandler } from './tools/armed-mark';\n\nexport function connectSiblings(ctx: SignatureContext, signature: SignatureCapability): void {\n const interaction = ctx.tryGet(InteractionToken);\n const stamp = ctx.tryGet(StampToken);\n const documentId = ctx.documentId;\n if (!interaction || !stamp || !documentId) return;\n ctx.cleanup(\n interaction.registerHandler(\n createArmedMarkHandler(documentId, signature, ctx.get(FormToken), stamp),\n ),\n );\n}\n","import { toPluginError } from '@embedpdf/core';\n\n/**\n * A capability verb: whatever the engine, a signer port or the validator\n * rejects with reaches the caller as a `PluginError`.\n */\nexport const verb =\n <Args extends unknown[], Result>(run: (...args: Args) => Promise<Result>) =>\n async (...args: Args): Promise<Result> => {\n try {\n return await run(...args);\n } catch (error) {\n throw toPluginError('signature', error);\n }\n };\n","/**\n * The judging verbs: re-reading the facts, validating, and the byte-level\n * questions a verdict rests on (what changed after a signature, the exact\n * revision it covers).\n */\nimport { PluginError, type Mirror, type OperationOptions } from '@embedpdf/core';\nimport type { AnalyzeInput } from '@embedpdf/engine-core/runtime';\n\nimport type {\n SignatureCapability,\n SignatureFieldAddress,\n SignatureValidateOptions,\n} from '../contract';\nimport type { SignatureRecord } from '../model';\nimport type { SignatureContext, SignatureServices } from '../services';\nimport { verb } from '../services/errors';\nimport type { SignatureValidation } from '../sync/validation';\nimport type { SignatureReads } from './signatures';\n\nexport function createJudging(\n ctx: SignatureContext,\n { store }: Pick<SignatureServices, 'store'>,\n { validate }: Pick<SignatureValidation, 'validate'>,\n signatures: Mirror<SignatureRecord>,\n { getSignature, getVerdict }: Pick<SignatureReads, 'getSignature' | 'getVerdict'>,\n) {\n const { requireSignatures } = store;\n\n return {\n api: {\n refresh: verb(async (options?: OperationOptions) => {\n await ctx.cancellable(options?.signal, signatures.refresh());\n return signatures.get().snapshot;\n }),\n validate: verb(validate),\n validateField: verb(async (field: SignatureFieldAddress, options?: SignatureValidateOptions) => {\n await validate(options);\n const verdict = getVerdict(field);\n if (!verdict) {\n throw new PluginError('not-found', 'signature', 'no signed field at that address');\n }\n return verdict;\n }),\n analyzeChanges: verb(async (input: AnalyzeInput, options?: OperationOptions) =>\n ctx.cancellable(options?.signal, requireSignatures().analyze(input)),\n ),\n readRevision: verb(\n async (\n target: SignatureFieldAddress | { revisionIndex: number },\n options?: OperationOptions,\n ) => {\n ctx.assertAllowed('doc.download', 'signature.readRevision');\n const service = requireSignatures();\n let revisionIndex: number;\n if ('revisionIndex' in target) {\n revisionIndex = target.revisionIndex;\n } else {\n const signature = getSignature(target);\n if (!signature?.signed || signature.revisionIndex === null) {\n throw new PluginError('not-found', 'signature', 'no signed revision at that address');\n }\n revisionIndex = signature.revisionIndex;\n }\n return ctx.cancellable(options?.signal, service.downloadRevision(revisionIndex));\n },\n ),\n } satisfies Partial<SignatureCapability>,\n };\n}\n","/**\n * The signature plugin's state, in two kinds. Session state (the last\n * validation, the sign-here target, the busy flag) changes only through the\n * pure transitions below. The signature facts (the snapshot and the parked\n * two-phase signing) are engine data: a mirror folds them from confirmed\n * document events with {@link foldSignatureEvent}.\n */\nimport { reload, type MirrorReload } from '@embedpdf/core';\nimport type { SignatureVerdict } from '@embedpdf/core-signature';\nimport type {\n DocumentEvent,\n FormFieldRef,\n SignatureCompleteResult,\n SignatureSnapshot,\n} from '@embedpdf/engine-core/runtime';\n\nimport type { SignaturePending } from './contract';\n\nexport interface SignatureState {\n /** The last validation; null until one ran. */\n readonly verdicts: readonly SignatureVerdict[] | null;\n /** The field the user chose to sign next (\"select the field, then pick a mark\"). */\n readonly target: FormFieldRef | null;\n /** A sign or fill call is in flight. */\n readonly busy: boolean;\n}\n\nexport const initialSignatureState = (): SignatureState => ({\n verdicts: null,\n target: null,\n busy: false,\n});\n\nexport const sameFieldRef = (left: FormFieldRef, right: FormFieldRef): boolean =>\n left.kind === 'objectNumber' && right.kind === 'objectNumber'\n ? left.objectNumber === right.objectNumber\n : left.kind === 'fqn' && right.kind === 'fqn'\n ? left.name === right.name\n : false;\n\n// ── transitions ──\n\nexport function setVerdicts(\n state: SignatureState,\n verdicts: readonly SignatureVerdict[] | null,\n): SignatureState {\n return state.verdicts === verdicts ? state : { ...state, verdicts };\n}\n\n/** Name the sign-here target; the same field (by ref) changes nothing. */\nexport function setTarget(state: SignatureState, field: FormFieldRef | null): SignatureState {\n const current = state.target;\n if (current === field || (current && field && sameFieldRef(current, field))) return state;\n return { ...state, target: field };\n}\n\nexport function setBusy(state: SignatureState, busy: boolean): SignatureState {\n return state.busy === busy ? state : { ...state, busy };\n}\n\n// ── projections ──\n\n/**\n * The verdicts that turned invalid because of unsaved edits: judged on the\n * working copy, invalid now, and not already invalid in the previous\n * validation (a signature that held, or was never judged).\n */\nexport function newlyInvalidated(\n previous: readonly SignatureVerdict[] | null,\n next: readonly SignatureVerdict[],\n): SignatureVerdict[] {\n return next.filter((verdict) => {\n if (verdict.modifications.basis !== 'working-copy' || verdict.summary !== 'invalid') {\n return false;\n }\n const before = previous?.find((earlier) => earlier.signature.index === verdict.signature.index);\n return !before || before.summary !== 'invalid';\n });\n}\n\n// ── the signatures mirror ──\n\n/** The mirrored signature facts: every signature field, and the parked signing. */\nexport interface SignatureRecord {\n /** Every signature field and its facts; null until the first load, or without engine support. */\n readonly snapshot: SignatureSnapshot | null;\n /** A signing candidate is parked (here or, on the cloud, elsewhere): the document is read-only. */\n readonly pending: SignaturePending | null;\n}\n\nexport const emptySignatureRecord = (): SignatureRecord => ({ snapshot: null, pending: null });\n\nexport const hasSignedField = (snapshot: SignatureSnapshot | null): boolean =>\n snapshot?.signatures.some((signature) => signature.signed) ?? false;\n\ntype SignatureCompletedEvent = Extract<DocumentEvent, { type: 'signatures.completed' }>;\n\n/** The result a `signatures.completed` event carries, without the event envelope. */\nexport const completeResultOf = (event: SignatureCompletedEvent): SignatureCompleteResult => ({\n status: event.status,\n signature: event.signature,\n version: event.version,\n previous: event.previous,\n protection: event.protection,\n meta: event.meta,\n});\n\n/**\n * A completed signing, applied to the snapshot: the sealed field's facts and\n * the protection now in force. The revisions change as well; the\n * `document.versioned` event that follows every completion reloads them.\n */\nfunction withCompletedSignature(\n snapshot: SignatureSnapshot | null,\n event: SignatureCompletedEvent,\n): SignatureSnapshot | null {\n if (!snapshot) return null;\n const sealed = event.signature;\n return {\n ...snapshot,\n signatures: snapshot.signatures.map((signature) =>\n sameFieldRef(signature.field, sealed.field) ? sealed : signature,\n ),\n protection: event.protection,\n };\n}\n\n/** Events that change which signature fields exist; the snapshot lists fields, so it is re-read. */\nconst FIELD_SET_EVENTS: ReadonlySet<DocumentEvent['type']> = new Set([\n 'forms.created',\n 'forms.deleted',\n 'forms.widgetAdded',\n 'forms.widgetRemoved',\n 'forms.repaired',\n]);\n\n/** Apply one confirmed document event to the signature facts. Pure, the same for every origin. */\nexport function foldSignatureEvent(\n record: SignatureRecord,\n event: DocumentEvent,\n): SignatureRecord | MirrorReload {\n switch (event.type) {\n case 'signatures.prepared':\n return { ...record, pending: { signingId: event.signingId, field: event.field } };\n case 'signatures.cancelled':\n return record.pending ? { ...record, pending: null } : record;\n case 'signatures.completed':\n return { snapshot: withCompletedSignature(record.snapshot, event), pending: null };\n default:\n return FIELD_SET_EVENTS.has(event.type) ? reload() : record;\n }\n}\n","/** Reads over the signature facts and the last validation. The lists are\n * memoized per snapshot so they stay reference-stable for selectors. */\nimport { memo, type Mirror } from '@embedpdf/core';\nimport type { SignatureVerdict } from '@embedpdf/core-signature';\nimport type {\n AnnotationRef,\n FormFieldRef,\n FormWidget,\n SignatureDTO,\n} from '@embedpdf/engine-core/runtime';\n\nimport type { SignatureCapability, SignatureFieldAddress, SignatureInfo } from '../contract';\nimport { sameFieldRef, type SignatureRecord } from '../model';\nimport type { SignatureContext, SignatureServices } from '../services';\n\nconst EMPTY_SIGNATURES: readonly SignatureInfo[] = [];\nconst EMPTY_FIELDS: readonly FormFieldRef[] = [];\n\n/** The widget an address names, or null for a field ref. */\nconst widgetOf = (\n field: SignatureFieldAddress,\n): Extract<AnnotationRef, { kind: 'objectNumber' }> | FormWidget | null => {\n if (!('kind' in field)) return field;\n // An annotation ref names its page; a field ref doesn't.\n if (field.kind === 'objectNumber' && 'page' in field) return field;\n return null;\n};\n\nconst isFieldRef = (field: SignatureFieldAddress): field is FormFieldRef =>\n 'kind' in field &&\n (field.kind === 'fqn' || (field.kind === 'objectNumber' && !('page' in field)));\n\nexport function createSignatureReads(\n ctx: SignatureContext,\n { authority, siblings }: Pick<SignatureServices, 'authority' | 'siblings'>,\n signatures: Mirror<SignatureRecord>,\n) {\n const { form } = siblings;\n const snapshot = () => signatures.get().snapshot;\n\n const lists = memo(\n () => [snapshot(), ctx.state.get().verdicts],\n (current, verdicts) => {\n if (!current) return { signed: EMPTY_SIGNATURES, unsigned: EMPTY_FIELDS };\n const verdictOf = (signature: SignatureDTO): SignatureVerdict | null =>\n verdicts?.find((verdict) => verdict.signature.index === signature.index) ?? null;\n return {\n signed: current.signatures\n .filter((signature) => signature.signed)\n .map((signature): SignatureInfo => ({ ...signature, verdict: verdictOf(signature) })),\n unsigned: current.signatures\n .filter((signature) => !signature.signed)\n .map((signature) => signature.field),\n };\n },\n );\n\n const getSignature = (field: SignatureFieldAddress): SignatureDTO | null => {\n const current = snapshot();\n if (!current) return null;\n const widget = widgetOf(field);\n if (widget) {\n const byWidget = current.signatures.find(\n (signature) => signature.widget?.objectNumber === widget.objectNumber,\n );\n if (byWidget) return byWidget;\n const owner = form.getFieldForWidget(widget);\n return owner ? getSignature(owner.ref) : null;\n }\n if (!isFieldRef(field)) return null;\n return (\n current.signatures.find((signature) =>\n field.kind === 'fqn'\n ? signature.fieldName === field.name\n : sameFieldRef(signature.field, field),\n ) ?? null\n );\n };\n const getVerdict = (field: SignatureFieldAddress): SignatureVerdict | null => {\n const signature = getSignature(field);\n if (!signature) return null;\n return (\n ctx.state.get().verdicts?.find((verdict) => verdict.signature.index === signature.index) ??\n null\n );\n };\n\n return {\n snapshot,\n getSignature,\n getVerdict,\n api: {\n getSnapshot: snapshot,\n getStatus: signatures.getStatus,\n listSignatures: () => lists().signed,\n listUnsignedFields: () => lists().unsigned,\n getSignature,\n listVerdicts: () => ctx.state.get().verdicts,\n getVerdict,\n getProtection: () => snapshot()?.protection ?? null,\n getPending: () => signatures.get().pending,\n isBusy: () => ctx.state.get().busy,\n getMode: authority.mode,\n getTarget: () => ctx.state.get().target,\n } satisfies Partial<SignatureCapability>,\n };\n}\nexport type SignatureReads = ReturnType<typeof createSignatureReads>;\n","/**\n * The mode and the key, read from the settings where they're used, so a change\n * applies at once; and who may sign or fill in which field, by the field's\n * group (`ctx.allowsField`), as the engine checks it.\n */\nimport { PluginError } from '@embedpdf/core';\nimport type { SignerPort } from '@embedpdf/core-signature';\nimport type { FormFieldRef } from '@embedpdf/engine-core/runtime';\n\nimport type { SignatureKey, SignatureMode } from '../contract';\nimport type { SignatureContext } from './context';\nimport type { SignatureSiblings } from './siblings';\n\nexport function createAuthority(ctx: SignatureContext, { form }: Pick<SignatureSiblings, 'form'>) {\n const settings = ctx.settings();\n const mode = (): SignatureMode => {\n const { mode: chosen, key } = settings.get();\n return chosen ?? (key ? 'sign' : 'visual');\n };\n const resolveKey = async (override?: SignatureKey): Promise<SignerPort> => {\n const key = override ?? settings.get().key;\n if (!key) {\n throw new PluginError(\n 'invalid-input',\n 'signature',\n 'no key: set the `key` setting or pass one with the call',\n );\n }\n return typeof key === 'function' ? key() : key;\n };\n /** Whether the session may `action` this field; `false` for a field the form doesn't have. */\n const allowsField = (action: 'fill' | 'sign', ref: FormFieldRef): boolean => {\n const field = form.get(ref);\n return field !== null && ctx.allowsField(action, field);\n };\n /** Refuse a write to this field the session may not make, before anything starts. */\n const assertAllowedField = (action: 'fill' | 'sign', ref: FormFieldRef, operation: string) => {\n const field = form.get(ref);\n // A field the form doesn't show yet is the engine's to answer (`not-found`).\n if (field) ctx.assertAllowedField(action, field, operation);\n };\n return {\n mode,\n resolveKey,\n assertAllowedField,\n canSign: (field: FormFieldRef) => allowsField('sign', field),\n canFill: (field: FormFieldRef) => allowsField('fill', field),\n canCertify: () => settings.get().allowCertify && ctx.allows('doc.sign.certify'),\n canReadRevision: () => ctx.allows('doc.download'),\n };\n}\nexport type SignatureAuthority = ReturnType<typeof createAuthority>;\n","/**\n * The capability's events, minted on the instance so they are disposed with\n * it. The state-change events (`onTargetChanged`, `onInvalidationPredicted`)\n * are derived here, in one place, from each committed state change.\n */\nimport type {\n SignatureClearedEvent,\n SignatureFilledEvent,\n SignatureInspectionRequestedEvent,\n SignatureInvalidationPredictedEvent,\n SignatureProtectionChangedEvent,\n SignatureSignedEvent,\n SignatureSignRequestedEvent,\n SignatureTargetChangedEvent,\n SignatureValidatedEvent,\n} from '../contract';\nimport { newlyInvalidated } from '../model';\nimport type { SignatureContext } from './context';\n\nexport function createEvents(ctx: SignatureContext) {\n const events = {\n signed: ctx.events.source<SignatureSignedEvent>(),\n filled: ctx.events.source<SignatureFilledEvent>(),\n cleared: ctx.events.source<SignatureClearedEvent>(),\n validated: ctx.events.source<SignatureValidatedEvent>(),\n protectionChanged: ctx.events.source<SignatureProtectionChangedEvent>(),\n invalidationPredicted: ctx.events.source<SignatureInvalidationPredictedEvent>(),\n targetChanged: ctx.events.source<SignatureTargetChangedEvent>(),\n signRequested: ctx.events.source<SignatureSignRequestedEvent>(),\n inspectionRequested: ctx.events.source<SignatureInspectionRequestedEvent>(),\n };\n\n ctx.state.onChange(({ previous, next }) => {\n if (previous.target !== next.target) events.targetChanged.emit({ field: next.target });\n if (previous.verdicts !== next.verdicts && next.verdicts) {\n // Acrobat's warning, after the fact and only on the edge: a signature\n // that held (or was never judged) now reads invalid because of unsaved edits.\n for (const verdict of newlyInvalidated(previous.verdicts, next.verdicts)) {\n events.invalidationPredicted.emit({\n field: verdict.signature.field,\n detail: verdict.modifications.detail ?? '',\n });\n }\n }\n });\n\n return events;\n}\nexport type SignatureEvents = ReturnType<typeof createEvents>;\n","/** Marks → the one-page appearance bytes the engine draws into a field. */\nimport { PluginError } from '@embedpdf/core';\nimport { resolveBinarySource, type BinarySource } from '@embedpdf/engine-core/runtime';\n\nimport type { Mark } from '../contract';\nimport type { SignatureSiblings } from './siblings';\n\nexport function createMarks({ stamp }: Pick<SignatureSiblings, 'stamp'>) {\n const bytesOf = async (source: BinarySource): Promise<Uint8Array> =>\n new Uint8Array((await resolveBinarySource(source)).bytes);\n const markBytes = async (mark: Mark): Promise<Uint8Array> => {\n if ('assetId' in mark) {\n const bytes = stamp()?.readAssetBytes(mark.assetId);\n if (!bytes) throw new PluginError('not-found', 'signature', `unknown mark '${mark.assetId}'`);\n return bytes;\n }\n return bytesOf(mark.source);\n };\n return { bytesOf, markBytes };\n}\nexport type SignatureMarks = ReturnType<typeof createMarks>;\n","/** The sibling planes: the form plugin (required), the stamp and annotation plugins (optional). */\nimport { AnnotationToken } from '@embedpdf/plugin-annotation/contract';\nimport { FormToken } from '@embedpdf/plugin-form/contract';\nimport { StampToken } from '@embedpdf/plugin-stamp/contract';\n\nimport type { SignatureContext } from './context';\n\nexport function resolveSiblings(ctx: SignatureContext) {\n return {\n form: ctx.get(FormToken),\n stamp: () => ctx.tryGet(StampToken),\n annotation: () => ctx.tryGet(AnnotationToken),\n };\n}\nexport type SignatureSiblings = ReturnType<typeof resolveSiblings>;\n","/** The busy bracket and the engine doors every area needs. */\nimport { PluginError } from '@embedpdf/core';\n\nimport { setBusy } from '../model';\nimport type { SignatureContext } from './context';\n\nexport function createStore(ctx: SignatureContext) {\n const withBusy = async <T>(work: () => Promise<T>): Promise<T> => {\n ctx.state.update(setBusy, true);\n try {\n return await work();\n } finally {\n ctx.state.update(setBusy, false);\n }\n };\n const requireSignatures = () => {\n const signatures = ctx.doc.signatures;\n if (!signatures) {\n throw new PluginError(\n 'unsupported',\n 'signature',\n 'this engine does not implement signatures',\n );\n }\n return signatures;\n };\n const documentId = () => {\n const id = ctx.documentId;\n if (!id) throw new PluginError('not-ready', 'signature', 'no document id');\n return id;\n };\n return { withBusy, requireSignatures, documentId };\n}\nexport type SignatureStore = ReturnType<typeof createStore>;\n","/**\n * Plugin-private services every area is built on (not the kernel): the\n * events, the busy bracket and engine doors, authority, the sibling plugins\n * and mark resolution.\n */\nimport { createAuthority, type SignatureAuthority } from './authority';\nimport type { SignatureContext } from './context';\nimport { createEvents, type SignatureEvents } from './events';\nimport { createMarks, type SignatureMarks } from './marks';\nimport { resolveSiblings, type SignatureSiblings } from './siblings';\nimport { createStore, type SignatureStore } from './store';\n\nexport type { SignatureContext } from './context';\n\nexport interface SignatureServices {\n readonly events: SignatureEvents;\n readonly store: SignatureStore;\n readonly authority: SignatureAuthority;\n readonly siblings: SignatureSiblings;\n readonly marks: SignatureMarks;\n}\n\nexport function createServices(ctx: SignatureContext): SignatureServices {\n const siblings = resolveSiblings(ctx);\n return {\n events: createEvents(ctx),\n store: createStore(ctx),\n authority: createAuthority(ctx, siblings),\n siblings,\n marks: createMarks(siblings),\n };\n}\n","/**\n * The signature facts, mirrored from the engine: every signature field with\n * its signed state, the protection in force, and the parked two-phase\n * signing. They change only by loads and by confirmed document events,\n * whoever caused them, and this is the one place the fact events fire\n * (`onSigned`, `onProtectionChanged`). The judgement reacts here too: a\n * load re-judges at once when anything is signed; a changed snapshot and\n * every edit of the working copy re-judge once the edits pause.\n */\nimport type { Mirror } from '@embedpdf/core';\nimport type { DocumentEvent, DocumentProtection } from '@embedpdf/engine-core/runtime';\n\nimport {\n completeResultOf,\n emptySignatureRecord,\n foldSignatureEvent,\n hasSignedField,\n type SignatureRecord,\n} from '../model';\nimport type { SignatureContext, SignatureServices } from '../services';\nimport type { SignatureValidation } from './validation';\n\n/** Edits of the working copy: what a save would write changed, so a verdict may have too. */\nconst WORKING_COPY_EDITS: ReadonlySet<DocumentEvent['type']> = new Set([\n 'annotations.created',\n 'annotations.updated',\n 'annotations.deleted',\n 'annotations.reordered',\n 'forms.valueSet',\n 'forms.updated',\n]);\n\nconst sameProtection = (\n left: DocumentProtection | null,\n right: DocumentProtection | null,\n): boolean => JSON.stringify(left) === JSON.stringify(right);\n\nexport function createSignaturesMirror(\n ctx: SignatureContext,\n { events }: Pick<SignatureServices, 'events'>,\n { validateNow, revalidateSoon }: Pick<SignatureValidation, 'validateNow' | 'revalidateSoon'>,\n) {\n const { signed, protectionChanged } = events;\n\n /** Parked signings the engine answered it does not know: no event will clear them. */\n const disowned = new Set<string>();\n\n const mirror: Mirror<SignatureRecord> = ctx.mirror<SignatureRecord>({\n name: 'signatures',\n initial: emptySignatureRecord,\n // The engine's snapshot says nothing about a parked signing: a load\n // keeps the one the events announced, unless the engine disowned it.\n load: async (doc) => {\n const snapshot = doc.signatures ? await doc.signatures.list() : null;\n const pending = mirror.get().pending;\n return {\n value: {\n snapshot,\n pending: pending && !disowned.has(pending.signingId) ? pending : null,\n },\n };\n },\n fold: foldSignatureEvent,\n changed: ({ cause, event, previous, next }) => {\n const protection = next.snapshot?.protection ?? null;\n if (protection && !sameProtection(previous.snapshot?.protection ?? null, protection)) {\n protectionChanged.emit({ protection });\n }\n if (event?.type === 'signatures.completed') {\n signed.emit({\n field: event.signature.field,\n result: completeResultOf(event),\n origin: event.origin,\n });\n }\n if (!hasSignedField(next.snapshot)) return;\n if (cause === 'load') validateNow();\n else if (previous.snapshot !== next.snapshot) revalidateSoon();\n },\n });\n\n return {\n mirror,\n /**\n * The engine does not know this parked signing (its cancel answered\n * `unknown`), so no event will ever clear it: reload without it.\n */\n disown(signingId: string): Promise<void> {\n disowned.add(signingId);\n return mirror.refresh();\n },\n connect(): void {\n ctx.listen(ctx.doc.events, (event) => {\n if (WORKING_COPY_EDITS.has(event.type) && hasSignedField(mirror.get().snapshot)) {\n revalidateSoon();\n }\n });\n },\n };\n}\nexport type SignaturesMirror = ReturnType<typeof createSignaturesMirror>;\n","/**\n * Judging the signatures. The viewer judges the working copy by default\n * (unsaved edits count), so the verdict is the one the file a save produces\n * will get. Verdicts are session state: each validation commits its own, and\n * `onValidated` fires where one completes. Re-judging after an edit waits\n * for a pause: a pen stroke is many events, one analysis.\n */\nimport type { SignatureVerdict } from '@embedpdf/core-signature';\n\nimport type { SignatureValidateOptions } from '../contract';\nimport { setVerdicts } from '../model';\nimport type { SignatureContext, SignatureServices } from '../services';\n\nconst REVALIDATE_DELAY_MS = 300;\n\nexport function createValidation(\n ctx: SignatureContext,\n { events }: Pick<SignatureServices, 'events'>,\n) {\n const { validated } = events;\n const settings = ctx.settings();\n\n const validate = async (\n options?: SignatureValidateOptions,\n ): Promise<readonly SignatureVerdict[]> => {\n if (!ctx.doc.signatures) return [];\n // The cryptography loads the first time a signature is checked.\n const { validateSignatures } = await ctx.cancellable(\n options?.signal,\n import('@embedpdf/core-signature'),\n );\n const verdicts = await ctx.cancellable(\n options?.signal,\n validateSignatures(ctx.doc, {\n trust: settings.get().trust,\n at: options?.at,\n until: options?.until ?? 'working-copy',\n }),\n );\n ctx.state.update(setVerdicts, verdicts);\n validated.emit({ verdicts });\n return verdicts;\n };\n\n let cancelRevalidate: (() => void) | null = null;\n const cancelScheduled = (): void => {\n cancelRevalidate?.();\n cancelRevalidate = null;\n };\n const validateInBackground = (): void => {\n void validate().catch((error) =>\n globalThis.console?.error('[signature] validation failed:', error),\n );\n };\n\n return {\n validate,\n /** Judge now; a scheduled re-judgement is superseded. */\n validateNow: (): void => {\n cancelScheduled();\n validateInBackground();\n },\n /** Judge once the edits pause. */\n revalidateSoon: (): void => {\n cancelScheduled();\n cancelRevalidate = ctx.clock.after(REVALIDATE_DELAY_MS, () => {\n cancelRevalidate = null;\n validateInBackground();\n });\n },\n };\n}\nexport type SignatureValidation = ReturnType<typeof createValidation>;\n","/** A one-page blank PDF: the appearance that clears a visual fill. */\n// A content stream that draws nothing but is not empty (`q Q`): the engine\n// turns the page into a form XObject, and refuses a page with no content at\n// all; a saved and restored state passes and paints nothing.\nconst CONTENT = 'q Q';\nconst OBJECTS = [\n '<< /Type /Catalog /Pages 2 0 R >>',\n '<< /Type /Pages /Kids [3 0 R] /Count 1 >>',\n '<< /Type /Page /Parent 2 0 R /MediaBox [0 0 200 60] /Contents 4 0 R /Resources << >> >>',\n `<< /Length ${CONTENT.length} >>\\nstream\\n${CONTENT}\\nendstream`,\n];\n\nlet cached: Uint8Array | null = null;\n\nexport function blankPagePdf(): Uint8Array {\n if (cached) return new Uint8Array(cached);\n let body = '%PDF-1.7\\n';\n const offsets: number[] = [];\n OBJECTS.forEach((object, index) => {\n offsets.push(body.length);\n body += `${index + 1} 0 obj\\n${object}\\nendobj\\n`;\n });\n const xref = body.length;\n body += `xref\\n0 ${OBJECTS.length + 1}\\n0000000000 65535 f \\n`;\n for (const offset of offsets) body += `${String(offset).padStart(10, '0')} 00000 n \\n`;\n body += `trailer\\n<< /Size ${OBJECTS.length + 1} /Root 1 0 R >>\\nstartxref\\n${xref}\\n%%EOF\\n`;\n cached = new TextEncoder().encode(body);\n return new Uint8Array(cached);\n}\n","/** Visual fills: the mark becomes the widget's appearance, nothing is sealed. */\nimport { PluginError, type OperationOptions } from '@embedpdf/core';\nimport type { FormFieldRef } from '@embedpdf/engine-core/runtime';\n\nimport { blankPagePdf } from '../blank-page';\nimport type { Mark, SignatureCapability } from '../contract';\nimport type { SignatureReads } from '../read/signatures';\nimport type { SignatureContext, SignatureServices } from '../services';\nimport { verb } from '../services/errors';\n\nexport function createFills(\n ctx: SignatureContext,\n {\n events,\n store,\n marks,\n authority,\n }: Pick<SignatureServices, 'events' | 'store' | 'marks' | 'authority'>,\n { getSignature }: Pick<SignatureReads, 'getSignature'>,\n target: { clearIfTarget(field: FormFieldRef): void },\n) {\n const { filled, cleared } = events;\n const { withBusy } = store;\n const { markBytes } = marks;\n\n const setAppearance = async (\n field: FormFieldRef,\n pdf: Uint8Array,\n options?: OperationOptions,\n ): Promise<void> => {\n const forms = ctx.doc.forms;\n if (!forms.setSignatureAppearance) {\n throw new PluginError(\n 'unsupported',\n 'signature',\n 'this engine cannot draw into a signature field',\n );\n }\n const signature = getSignature(field);\n if (signature?.signed) {\n throw new PluginError('conflict', 'signature', `'${signature.fieldName}' is signed`);\n }\n await ctx.cancellable(options?.signal, forms.setSignatureAppearance(field, { pdf }));\n };\n\n const fillField = async (\n field: FormFieldRef,\n mark: Mark,\n options?: OperationOptions,\n ): Promise<void> => {\n authority.assertAllowedField('fill', field, 'signature.fillField');\n return withBusy(async () => {\n await setAppearance(field, await markBytes(mark), options);\n target.clearIfTarget(field);\n filled.emit({ field });\n });\n };\n\n const clearField = async (field: FormFieldRef, options?: OperationOptions): Promise<void> => {\n authority.assertAllowedField('fill', field, 'signature.clearField');\n return withBusy(async () => {\n await setAppearance(field, blankPagePdf(), options);\n cleared.emit({ field });\n });\n };\n\n return {\n fillField,\n api: {\n fillField: verb(fillField),\n clearField: verb(clearField),\n } satisfies Partial<SignatureCapability>,\n };\n}\nexport type SignatureFills = ReturnType<typeof createFills>;\n","/**\n * The destination rule and the sign-here flow: a mark over a field is\n * signed, drawn, or handed to the chrome by mode; a free placement is a\n * stamp (one placement law, the stamp plugin's).\n */\nimport { PluginError, type OperationOptions } from '@embedpdf/core';\nimport type { FormFieldRef, SignatureCompleteResult } from '@embedpdf/engine-core/runtime';\nimport type { StampPlacement } from '@embedpdf/plugin-annotation/contract';\n\nimport type { Mark, PlaceMarkResult, SignatureCapability, SignFieldInput } from '../contract';\nimport { hasSignedField, sameFieldRef, setTarget } from '../model';\nimport type { SignatureReads } from '../read/signatures';\nimport type { SignatureContext, SignatureServices } from '../services';\nimport { verb } from '../services/errors';\n\nexport function createTarget(\n ctx: SignatureContext,\n { events }: Pick<SignatureServices, 'events'>,\n { getSignature }: Pick<SignatureReads, 'getSignature'>,\n) {\n const { inspectionRequested } = events;\n /** One field, whether a ref names it by object number or by name. */\n const sameField = (left: FormFieldRef, right: FormFieldRef): boolean => {\n if (sameFieldRef(left, right)) return true;\n const signature = getSignature(left);\n return signature !== null && signature.index === getSignature(right)?.index;\n };\n /** A field that was just signed or filled is no longer the target. */\n const clearIfTarget = (field: FormFieldRef): void => {\n const current = ctx.state.get().target;\n if (current && sameField(current, field)) ctx.state.update(setTarget, null);\n };\n return {\n clearIfTarget,\n api: {\n setTarget: (field) => ctx.state.update(setTarget, field),\n requestInspection: (field) => inspectionRequested.emit({ field }),\n } satisfies Partial<SignatureCapability>,\n };\n}\nexport type SignatureTarget = ReturnType<typeof createTarget>;\n\nexport function createPlacement(\n ctx: SignatureContext,\n {\n events,\n store,\n authority,\n siblings,\n }: Pick<SignatureServices, 'events' | 'store' | 'authority' | 'siblings'>,\n { snapshot }: Pick<SignatureReads, 'snapshot'>,\n {\n sign,\n }: { sign(input: SignFieldInput, options?: OperationOptions): Promise<SignatureCompleteResult> },\n {\n fillField,\n }: { fillField(field: FormFieldRef, mark: Mark, options?: OperationOptions): Promise<void> },\n) {\n const { signRequested } = events;\n const { documentId } = store;\n const { mode } = authority;\n const { stamp, annotation } = siblings;\n const settings = ctx.settings();\n\n const placeMark = async (\n mark: Mark,\n target: { field: FormFieldRef } | StampPlacement,\n options?: OperationOptions,\n ): Promise<PlaceMarkResult> => {\n if (!('field' in target)) {\n // Free placement: a stamp, as in Preview; one placement law, the stamp plugin's.\n if ('assetId' in mark) {\n const library = stamp();\n if (!library) {\n throw new PluginError('unsupported', 'signature', 'no stamp plugin to place an asset');\n }\n const placed = await library.placeAsset(mark.assetId, target, {\n documentId: documentId(),\n signal: options?.signal,\n });\n return { kind: 'placed', annotation: placed.annotation.ref };\n }\n const annotations = annotation();\n if (!annotations) {\n throw new PluginError('unsupported', 'signature', 'no annotation plugin to place a mark');\n }\n const placed = await annotations.stamps.place({ source: mark.source }, target, options);\n return { kind: 'placed', annotation: placed.annotation.ref };\n }\n switch (mode()) {\n case 'sign':\n // The first signature is the one that can certify: when the settings\n // allow a certification, let the chrome offer the choice (its sign\n // dialog) instead of sealing a plain approval on the spot.\n if (settings.get().allowCertify && !hasSignedField(snapshot())) {\n signRequested.emit({ field: target.field, mark });\n return { kind: 'requested', field: target.field };\n }\n return {\n kind: 'signed',\n field: target.field,\n result: await sign({ field: target.field, mark }, options),\n };\n case 'visual':\n await fillField(target.field, mark, options);\n return { kind: 'filled', field: target.field };\n case 'ask':\n signRequested.emit({ field: target.field, mark });\n return { kind: 'requested', field: target.field };\n }\n };\n\n return { api: { placeMark: verb(placeMark) } satisfies Partial<SignatureCapability> };\n}\n","/**\n * The act of sealing. One-shot: `sign` (prepare, the key, complete,\n * through `@embedpdf/core-signature`). Two-phase: `prepareSignature` parks\n * the signing and hands out the digest; `completeSignature` seals it with a\n * detached CMS; `cancelPending` cancels. The parked signing, the sealed\n * field's facts and `onSigned` come from the confirmed events the engine\n * publishes for each step (`sync/signatures.ts`), for every session alike.\n */\nimport { PluginError, type OperationOptions } from '@embedpdf/core';\nimport type {\n DocumentHandle,\n FormFieldRef,\n SignatureCompleteResult,\n SignaturePrepared,\n} from '@embedpdf/engine-core/runtime';\n\nimport type { PrepareSignatureInput, SignatureCapability, SignFieldInput } from '../contract';\nimport type { SignatureReads } from '../read/signatures';\nimport type { SignatureContext, SignatureServices } from '../services';\nimport { verb } from '../services/errors';\nimport type { SignaturesMirror } from '../sync/signatures';\n\nexport function createSigning(\n ctx: SignatureContext,\n { store, authority, marks }: Pick<SignatureServices, 'store' | 'authority' | 'marks'>,\n { api: reads }: Pick<SignatureReads, 'api'>,\n target: { clearIfTarget(field: FormFieldRef): void },\n signatures: Pick<SignaturesMirror, 'disown'>,\n) {\n const { withBusy, requireSignatures } = store;\n const { resolveKey, assertAllowedField } = authority;\n const { bytesOf, markBytes } = marks;\n\n /** Two-phase signings this session prepared: the version each one must complete against. */\n const prepared = new Map<string, SignaturePrepared>();\n\n const cancelled = (signal: AbortSignal): PluginError =>\n new PluginError('operation-cancelled', 'signature', 'signing cancelled', {\n cause: signal.reason,\n });\n\n /**\n * The document as one-shot signing sees it, with the caller's signal checked\n * right before the seal: a signal that fired by then leaves nothing signed\n * (the signing gives the prepared candidate up), and after it the seal is\n * done.\n */\n const sealUnlessCancelled = (signal: AbortSignal | undefined): DocumentHandle => {\n const signatures = requireSignatures();\n if (!signal) return ctx.doc;\n return {\n signatures: {\n prepare: (input: Parameters<typeof signatures.prepare>[0]) => signatures.prepare(input),\n cancel: (signingId: string) => signatures.cancel(signingId),\n complete: (input: Parameters<typeof signatures.complete>[0]) => {\n if (signal.aborted) return Promise.reject(cancelled(signal));\n return signatures.complete(input);\n },\n },\n } as unknown as DocumentHandle;\n };\n\n /**\n * Refused before anything starts: signing the field (`doc.sign`, or\n * `fields:sign` for its group), and `doc.sign.certify` for a certification.\n */\n const assertMaySign = (\n input: { field: FormFieldRef; certify?: unknown },\n operation: string,\n ): void => {\n assertAllowedField('sign', input.field, operation);\n if (input.certify) ctx.assertAllowed('doc.sign.certify', operation);\n };\n\n const appearanceOf = async (input: {\n mark?: SignFieldInput['mark'];\n appearance?: SignFieldInput['appearance'];\n }) => {\n if (input.appearance) return bytesOf(input.appearance);\n if (input.mark) return markBytes(input.mark);\n return null;\n };\n\n const sign = async (\n input: SignFieldInput,\n options?: OperationOptions,\n ): Promise<SignatureCompleteResult> => {\n assertMaySign(input, 'signature.sign');\n if (options?.signal?.aborted) throw cancelled(options.signal);\n return withBusy(async () => {\n const doc = sealUnlessCancelled(options?.signal);\n // The cryptography loads the first time someone signs.\n const { certificateCommonName, sign: signDocument } =\n await import('@embedpdf/core-signature');\n const key = await resolveKey(input.key);\n // The certificate's subject is the default /Name; the caller's facts win.\n const subject =\n key.kind === 'raw' && key.certificateChain[0]\n ? certificateCommonName(key.certificateChain[0])\n : null;\n const signer = { ...(subject ? { name: subject } : {}), ...input.signer };\n // The appearance is the mark: its page is drawn into the widget by the engine.\n const appearance = (await appearanceOf(input))!;\n const result = await signDocument(doc, {\n field: input.field,\n key,\n signer,\n certify: input.certify,\n lock: input.lock,\n appearance: { pdf: appearance },\n });\n target.clearIfTarget(input.field);\n return result;\n });\n };\n\n const prepareSignature = async (\n input: PrepareSignatureInput,\n options?: OperationOptions,\n ): Promise<SignaturePrepared> => {\n assertMaySign(input, 'signature.prepareSignature');\n return withBusy(async () => {\n const signatures = requireSignatures();\n const appearance = await appearanceOf(input);\n const pending = signatures.prepare({\n field: input.field,\n signer: input.signer,\n certify: input.certify,\n lock: input.lock,\n subFilter: input.subFilter,\n digest: input.digest,\n ...(appearance ? { appearance: { pdf: appearance } } : {}),\n });\n const result = await ctx.cancellable(options?.signal, pending);\n prepared.set(result.signingId, result);\n return result;\n });\n };\n\n const completeSignature = async (\n signingId: string,\n cms: Uint8Array,\n options?: OperationOptions,\n ): Promise<SignatureCompleteResult> => {\n // Its field was checked when it was prepared; the engine checks it again.\n if (options?.signal?.aborted) throw cancelled(options.signal);\n return withBusy(async () => {\n const signatures = requireSignatures();\n const parked = prepared.get(signingId);\n if (!parked) {\n throw new PluginError(\n 'not-found',\n 'signature',\n `no signing '${signingId}' was prepared in this session`,\n );\n }\n const result = await signatures.complete({\n signingId,\n cms,\n expectedVersion: parked.expectedVersion,\n });\n prepared.delete(signingId);\n target.clearIfTarget(result.signature.field);\n return result;\n });\n };\n\n const cancelPending = async (options?: OperationOptions): Promise<void> => {\n const pending = reads.getPending();\n if (!pending) return;\n assertAllowedField('sign', pending.field, 'signature.cancelPending');\n const { status } = await ctx.cancellable(\n options?.signal,\n requireSignatures().cancel(pending.signingId),\n );\n prepared.delete(pending.signingId);\n // A cancel or a completion clears the signing through its event; an\n // unknown signing has none.\n if (status === 'unknown') await signatures.disown(pending.signingId);\n };\n\n return {\n sign,\n api: {\n sign: verb(sign),\n prepareSignature: verb(prepareSignature),\n completeSignature: verb(completeSignature),\n cancelPending: verb(cancelPending),\n } satisfies Partial<SignatureCapability>,\n };\n}\nexport type SignatureSigning = ReturnType<typeof createSigning>;\n","/**\n * The signature controller: the composition root. It builds the plugin's\n * services once, wires each area with the services it declares, and\n * assembles the capability from the areas' API slices. No behavior lives\n * here: every verb and read has a home in `read/`, `write/` or `sync/`.\n */\nimport { composeApi } from '@embedpdf/core';\n\nimport { connectSiblings } from './connect';\nimport type { SignatureCapability } from './contract';\nimport { createJudging } from './read/judging';\nimport { createSignatureReads } from './read/signatures';\nimport { createServices, type SignatureContext } from './services';\nimport { createSignaturesMirror } from './sync/signatures';\nimport { createValidation } from './sync/validation';\nimport { createFills } from './write/fill';\nimport { createPlacement, createTarget } from './write/place';\nimport { createSigning } from './write/sign';\n\nexport function createSignatureController(ctx: SignatureContext) {\n const services = createServices(ctx);\n const { events, authority } = services;\n const settings = ctx.settings();\n\n // Sync: the engine's facts, mirrored, and the judgement that reacts to them.\n const validation = createValidation(ctx, services);\n const signatures = createSignaturesMirror(ctx, services, validation);\n\n // Reads: projections of the mirror and the session state.\n const reads = createSignatureReads(ctx, services, signatures.mirror);\n const judging = createJudging(ctx, services, validation, signatures.mirror, reads);\n\n // Writes: the sign-here target, sealing, visual fills, the destination rule.\n const target = createTarget(ctx, services, reads);\n const signing = createSigning(ctx, services, reads, target, signatures);\n const fills = createFills(ctx, services, reads, target);\n const placement = createPlacement(ctx, services, reads, signing, fills);\n\n const api: SignatureCapability = composeApi('signature', [\n settings.api,\n reads.api,\n judging.api,\n target.api,\n signing.api,\n fills.api,\n placement.api,\n {\n // Authority twins and the events are services, not areas.\n canSign: authority.canSign,\n canFill: authority.canFill,\n canCertify: authority.canCertify,\n canReadRevision: authority.canReadRevision,\n onSigned: events.signed.on,\n onFilled: events.filled.on,\n onCleared: events.cleared.on,\n onValidated: events.validated.on,\n onProtectionChanged: events.protectionChanged.on,\n onInvalidationPredicted: events.invalidationPredicted.on,\n onTargetChanged: events.targetChanged.on,\n onSignRequested: events.signRequested.on,\n onInspectionRequested: events.inspectionRequested.on,\n },\n ]);\n\n return {\n api,\n connect(): void {\n signatures.connect();\n connectSiblings(ctx, api);\n },\n };\n}\n","import { definePlugin } from '@embedpdf/core';\nimport { AnnotationToken } from '@embedpdf/plugin-annotation/contract';\nimport { FormToken } from '@embedpdf/plugin-form/contract';\nimport { InteractionToken } from '@embedpdf/plugin-interaction/contract/host';\nimport { StampToken } from '@embedpdf/plugin-stamp/contract';\n\nimport { SIGNATURE_DEFAULTS, SignatureToken, type SignatureConfig } from './contract';\nimport { createSignatureController } from './controller';\nimport { initialSignatureState } from './model';\n\n/**\n * The signature plugin: the act of signing, document-scoped. It owns no\n * mark: marks are stamp-library assets (or bytes the embedder brings), and\n * the mark is the appearance the engine draws into the field. Signing goes\n * through `@embedpdf/core-signature` with the `key` setting's signer port;\n * the engine seals; on the cloud the server publishes the new version.\n *\n * With the interaction hub and the stamp plugin present, an armed mark from\n * a `signatures` library dropped over an unsigned signature field goes into\n * the field (sign, visual fill or ask, by mode) instead of onto the page.\n * `config` is the settings the app registers, over {@link SIGNATURE_DEFAULTS}.\n */\nexport const signaturePlugin = (config?: SignatureConfig) =>\n definePlugin({\n id: 'signature',\n token: SignatureToken,\n scope: 'document',\n requires: [FormToken],\n optional: [InteractionToken, StampToken, AnnotationToken],\n state: initialSignatureState,\n // A key and a trust port are one value each: a change replaces them, never merges into them.\n settings: { defaults: SIGNATURE_DEFAULTS, registered: config, whole: ['key', 'trust'] },\n create: createSignatureController,\n });\n","/**\n * The signatures page's State table as code: what `useSignatureState()`\n * returns, and the same fields in every other framework.\n */\nimport { defineState } from '@embedpdf/core';\n\nimport { SignatureToken, type SignatureInfo } from './contract';\n\nconst NO_SIGNATURES: readonly SignatureInfo[] = Object.freeze([]);\n\nexport const signatureState = defineState(SignatureToken, {\n read: (signature) => ({\n signatures: signature.listSignatures(),\n protection: signature.getProtection(),\n target: signature.getTarget(),\n busy: signature.isBusy(),\n pending: signature.getPending(),\n status: signature.getStatus(),\n }),\n empty: {\n signatures: NO_SIGNATURES,\n protection: null,\n target: null,\n busy: false,\n pending: null,\n status: 'idle',\n },\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAqBA,SAAgB,uBACd,YACA,WACA,MACA,OACoB;CACpB,OAAO;EACL,IAAI;EACJ,UAAUA,0CAAAA,2BAA2B;EACrC,aAAa,SAAS,KAAK,OAAOC,0CAAAA;EAClC,SAAS,WAAW;GAClB,IAAI,CAAC,OAAO,MAAM,OAAO;GACzB,MAAM,QAAQ,MAAM,cAAc,UAAU;GAC5C,IAAI,CAAC,SAAS,MAAM,WAAW,MAAM,SAAS,CAAC,EAAE,SAAA,cAC/C,OAAO;GACT,MAAM,MAAM,KAAK,YAAY,OAAO,KAAK,KAAK,OAAO,KAAK,KAAK;GAC/D,IAAI,CAAC,OAAO,IAAI,MAAM,WAAW,aAAa,OAAO;GAErD,IAAI,UAAU,aAAa,IAAI,MAAM,GAAG,CAAC,EAAE,UAAU,IAAI,MAAM,WAAW,SAAS,QACjF,OAAO;GAET,MAAM,OAAO,UAAU;GACvB,UACG,UAAU,EAAE,SAAS,MAAM,GAAG,GAAG,EAAE,OAAO,IAAI,MAAM,IAAI,CAAC,CAAC,CAC1D,OAAO,UAAU,WAAW,SAAS,MAAM,wCAAwC,KAAK,CAAC;GAC5F,OAAO;EACT;CACF;AACF;;;;;;;;ACpCA,SAAgB,gBAAgB,KAAuB,WAAsC;CAC3F,MAAM,cAAc,IAAI,OAAOC,2CAAAA,gBAAgB;CAC/C,MAAM,QAAQ,IAAI,OAAOC,gCAAAA,UAAU;CACnC,MAAM,aAAa,IAAI;CACvB,IAAI,CAAC,eAAe,CAAC,SAAS,CAAC,YAAY;CAC3C,IAAI,QACF,YAAY,gBACV,uBAAuB,YAAY,WA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
@@ -1,35 +1,41 @@
1
- import { C as SignatureConfig, D as SignatureToken, E as SignatureState, O as markRoleOf, S as SignatureChange, T as SignaturePending, _ as SIGNATURES_LIBRARY_KIND, a as FieldLockSpec, b as SignatureAction, c as SignatureDTO, d as SignerPort, f as TrustPort, g as MarkRole, h as Mark, i as DocumentProtection, l as SignatureSnapshot, m as INITIALS_MARK_NAME, n as ChangeAnalysis, o as FormFieldRef, p as ValidationTime, r as DocMdpPermission, s as SignatureCompleteResult, t as AnalyzeInput, u as SignatureVerdict, v as SIGNATURE_MARK_NAME, w as SignatureMode, x as SignatureCapability, y as SignFieldInput } from "./contract-BvHa9Zl_.cjs";
2
- import { PersonalKeyStore, PersonalSigner, TestSigner, createTestSigner, indexedDbKeyStore, memoryKeyStore, personalSigner, remoteSigner, webCryptoSigner } from "@embedpdf/core-signature";
3
- import { StampCapability } from "@embedpdf/plugin-stamp/contract";
4
- import { InteractionHandler } from "@embedpdf/plugin-interaction/contract";
5
- import { FormCapability } from "@embedpdf/plugin-form/contract";
1
+ import { A as SignaturePrepared, B as SignerPort, C as SignatureFilledEvent, D as SignatureKey, E as SignatureInvalidationPredictedEvent, F as SignatureSnapshot, G as signerRowsOf, H as TrustPort, I as SignatureTargetChangedEvent, K as SignatureToken, L as SignatureValidateOptions, M as SignatureSettings, N as SignatureSignRequestedEvent, O as SignatureMode, P as SignatureSignedEvent, R as SignatureValidatedEvent, S as SignatureFieldAddress, T as SignatureInspectionRequestedEvent, U as ValidationTime, V as SignerRow, W as markRoleOf, _ as SignatureCapability, a as FieldLockSpec, b as SignatureConfig, c as Mark, d as PrepareSignatureInput, f as PreparedSignature, g as SignFieldInput, h as SIGNATURE_MARK_NAME, i as DocumentProtection, j as SignatureProtectionChangedEvent, k as SignaturePending, l as MarkRole, m as SIGNATURE_DEFAULTS, n as ChangeAnalysis, o as FormFieldRef, p as SIGNATURES_LIBRARY_KIND, r as DocMdpPermission, s as INITIALS_MARK_NAME, t as AnalyzeInput, u as PlaceMarkResult, v as SignatureClearedEvent, w as SignatureInfo, x as SignatureDTO, y as SignatureCompleteResult, z as SignatureVerdict } from "./contract-c89MSPDK.cjs";
2
+ import "@embedpdf/core";
3
+ import { PersonalKeyStore, PersonalSigner, SignatureVerdict as SignatureVerdict$1, TestSigner, createTestSigner, indexedDbKeyStore, memoryKeyStore, personalSigner, remoteSigner, webCryptoSigner } from "@embedpdf/core-signature";
4
+ import { FormFieldRef as FormFieldRef$1, SignatureCompleteResult as SignatureCompleteResult$1, SignatureSnapshot as SignatureSnapshot$1 } from "@embedpdf/engine-core/runtime";
5
+ //#region src/model.d.ts
6
+ interface SignatureState {
7
+ /** The last validation; null until one ran. */
8
+ readonly verdicts: readonly SignatureVerdict$1[] | null;
9
+ /** The field the user chose to sign next ("select the field, then pick a mark"). */
10
+ readonly target: FormFieldRef$1 | null;
11
+ /** A sign or fill call is in flight. */
12
+ readonly busy: boolean;
13
+ }
14
+ //#endregion
6
15
  //#region src/signature.plugin.d.ts
7
16
  /**
8
- * The signature plugin — the ACT of signing, document-scoped. It owns no
17
+ * The signature plugin: the act of signing, document-scoped. It owns no
9
18
  * mark: marks are stamp-library assets (or bytes the embedder brings), and
10
- * the mark IS the appearance the engine draws into the field. Signing goes
11
- * through `@embedpdf/core-signature` with the configured signer port; the
12
- * engine seals; on the cloud the server publishes the new version.
19
+ * the mark is the appearance the engine draws into the field. Signing goes
20
+ * through `@embedpdf/core-signature` with the `key` setting's signer port;
21
+ * the engine seals; on the cloud the server publishes the new version.
13
22
  *
14
23
  * With the interaction hub and the stamp plugin present, an armed mark from
15
24
  * a `signatures` library dropped over an unsigned signature field goes into
16
- * the field (sign / visual fill / ask, by mode) instead of onto the page.
25
+ * the field (sign, visual fill or ask, by mode) instead of onto the page.
26
+ * `config` is the settings the app registers, over {@link SIGNATURE_DEFAULTS}.
17
27
  */
18
- declare const signaturePlugin: (config?: SignatureConfig) => import("@embedpdf/core").PluginDef<SignatureState, SignatureAction, SignatureCapability>;
28
+ declare const signaturePlugin: (config?: SignatureConfig) => import("@embedpdf/core").PluginDef<SignatureState, SignatureCapability, SignatureSettings>;
19
29
  //#endregion
20
- //#region src/handler.d.ts
21
- /**
22
- * The armed mark over a field. The annotation plugin places an armed stamp
23
- * on click (`annotation-place`, priority 95) and selects an existing
24
- * annotation under the pointer before that (`annotation-edit`, 100 — a
25
- * widget is an annotation). This handler sits above BOTH, enabled for the
26
- * armed stamp's tool only, and captures exactly when the armed asset is a
27
- * person's mark (a library of kind `signatures`) and the pointer is over a
28
- * signature field: then the destination decides — the mark goes INTO the
29
- * field (`placeMark` by mode) instead of onto the page. Everywhere else it
30
- * declines and the click stays a stamp placement, as in Preview.
31
- */
32
- declare function createArmedMarkHandler(documentId: string, signature: SignatureCapability, form: FormCapability, stamp: StampCapability): InteractionHandler;
30
+ //#region src/state.d.ts
31
+ declare const signatureState: import("@embedpdf/core").StateDeclaration<SignatureCapability, {
32
+ signatures: readonly SignatureInfo[];
33
+ protection: import("@embedpdf/engine-core/runtime").DocumentProtection | null;
34
+ target: import("@embedpdf/engine-core/runtime").FormFieldRef | null;
35
+ busy: boolean;
36
+ pending: SignaturePending | null;
37
+ status: import("@embedpdf/core").ResourceStatus;
38
+ }>;
33
39
  //#endregion
34
- export { type AnalyzeInput, type ChangeAnalysis, type DocMdpPermission, type DocumentProtection, type FieldLockSpec, type FormFieldRef, INITIALS_MARK_NAME, type Mark, type MarkRole, type PersonalKeyStore, type PersonalSigner, SIGNATURES_LIBRARY_KIND, SIGNATURE_MARK_NAME, type SignFieldInput, type SignatureAction, type SignatureCapability, type SignatureChange, type SignatureCompleteResult, type SignatureConfig, type SignatureDTO, type SignatureMode, type SignaturePending, type SignatureSnapshot, type SignatureState, SignatureToken, type SignatureVerdict, type SignerPort, type TestSigner, type TrustPort, type ValidationTime, createArmedMarkHandler, createTestSigner, indexedDbKeyStore, markRoleOf, memoryKeyStore, personalSigner, remoteSigner, signaturePlugin, webCryptoSigner };
40
+ export { type AnalyzeInput, type ChangeAnalysis, type DocMdpPermission, type DocumentProtection, type FieldLockSpec, type FormFieldRef, INITIALS_MARK_NAME, Mark, MarkRole, type PersonalKeyStore, type PersonalSigner, PlaceMarkResult, PrepareSignatureInput, PreparedSignature, SIGNATURES_LIBRARY_KIND, SIGNATURE_DEFAULTS, SIGNATURE_MARK_NAME, SignFieldInput, SignatureCapability, SignatureClearedEvent, type SignatureCompleteResult, SignatureConfig, type SignatureDTO, SignatureFieldAddress, SignatureFilledEvent, SignatureInfo, SignatureInspectionRequestedEvent, SignatureInvalidationPredictedEvent, SignatureKey, SignatureMode, SignaturePending, type SignaturePrepared, SignatureProtectionChangedEvent, SignatureSettings, SignatureSignRequestedEvent, SignatureSignedEvent, type SignatureSnapshot, SignatureTargetChangedEvent, SignatureToken, SignatureValidateOptions, SignatureValidatedEvent, type SignatureVerdict, type SignerPort, SignerRow, type TestSigner, type TrustPort, type ValidationTime, createTestSigner, indexedDbKeyStore, markRoleOf, memoryKeyStore, personalSigner, remoteSigner, signaturePlugin, signatureState, signerRowsOf, webCryptoSigner };
35
41
  //# sourceMappingURL=index.d.cts.map
package/dist/index.d.ts CHANGED
@@ -1,35 +1,41 @@
1
- import { C as SignatureConfig, D as SignatureToken, E as SignatureState, O as markRoleOf, S as SignatureChange, T as SignaturePending, _ as SIGNATURES_LIBRARY_KIND, a as FieldLockSpec, b as SignatureAction, c as SignatureDTO, d as SignerPort, f as TrustPort, g as MarkRole, h as Mark, i as DocumentProtection, l as SignatureSnapshot, m as INITIALS_MARK_NAME, n as ChangeAnalysis, o as FormFieldRef, p as ValidationTime, r as DocMdpPermission, s as SignatureCompleteResult, t as AnalyzeInput, u as SignatureVerdict, v as SIGNATURE_MARK_NAME, w as SignatureMode, x as SignatureCapability, y as SignFieldInput } from "./contract-Dg50puf7.js";
2
- import { FormCapability } from "@embedpdf/plugin-form/contract";
3
- import { InteractionHandler } from "@embedpdf/plugin-interaction/contract";
4
- import { StampCapability } from "@embedpdf/plugin-stamp/contract";
5
- import { PersonalKeyStore, PersonalSigner, TestSigner, createTestSigner, indexedDbKeyStore, memoryKeyStore, personalSigner, remoteSigner, webCryptoSigner } from "@embedpdf/core-signature";
1
+ import { A as SignaturePrepared, B as SignerPort, C as SignatureFilledEvent, D as SignatureKey, E as SignatureInvalidationPredictedEvent, F as SignatureSnapshot, G as signerRowsOf, H as TrustPort, I as SignatureTargetChangedEvent, K as SignatureToken, L as SignatureValidateOptions, M as SignatureSettings, N as SignatureSignRequestedEvent, O as SignatureMode, P as SignatureSignedEvent, R as SignatureValidatedEvent, S as SignatureFieldAddress, T as SignatureInspectionRequestedEvent, U as ValidationTime, V as SignerRow, W as markRoleOf, _ as SignatureCapability, a as FieldLockSpec, b as SignatureConfig, c as Mark, d as PrepareSignatureInput, f as PreparedSignature, g as SignFieldInput, h as SIGNATURE_MARK_NAME, i as DocumentProtection, j as SignatureProtectionChangedEvent, k as SignaturePending, l as MarkRole, m as SIGNATURE_DEFAULTS, n as ChangeAnalysis, o as FormFieldRef, p as SIGNATURES_LIBRARY_KIND, r as DocMdpPermission, s as INITIALS_MARK_NAME, t as AnalyzeInput, u as PlaceMarkResult, v as SignatureClearedEvent, w as SignatureInfo, x as SignatureDTO, y as SignatureCompleteResult, z as SignatureVerdict } from "./contract-GUWa_aBY.js";
2
+ import "@embedpdf/core";
3
+ import { FormFieldRef as FormFieldRef$1, SignatureCompleteResult as SignatureCompleteResult$1, SignatureSnapshot as SignatureSnapshot$1 } from "@embedpdf/engine-core/runtime";
4
+ import { PersonalKeyStore, PersonalSigner, SignatureVerdict as SignatureVerdict$1, TestSigner, createTestSigner, indexedDbKeyStore, memoryKeyStore, personalSigner, remoteSigner, webCryptoSigner } from "@embedpdf/core-signature";
5
+ //#region src/model.d.ts
6
+ interface SignatureState {
7
+ /** The last validation; null until one ran. */
8
+ readonly verdicts: readonly SignatureVerdict$1[] | null;
9
+ /** The field the user chose to sign next ("select the field, then pick a mark"). */
10
+ readonly target: FormFieldRef$1 | null;
11
+ /** A sign or fill call is in flight. */
12
+ readonly busy: boolean;
13
+ }
14
+ //#endregion
6
15
  //#region src/signature.plugin.d.ts
7
16
  /**
8
- * The signature plugin — the ACT of signing, document-scoped. It owns no
17
+ * The signature plugin: the act of signing, document-scoped. It owns no
9
18
  * mark: marks are stamp-library assets (or bytes the embedder brings), and
10
- * the mark IS the appearance the engine draws into the field. Signing goes
11
- * through `@embedpdf/core-signature` with the configured signer port; the
12
- * engine seals; on the cloud the server publishes the new version.
19
+ * the mark is the appearance the engine draws into the field. Signing goes
20
+ * through `@embedpdf/core-signature` with the `key` setting's signer port;
21
+ * the engine seals; on the cloud the server publishes the new version.
13
22
  *
14
23
  * With the interaction hub and the stamp plugin present, an armed mark from
15
24
  * a `signatures` library dropped over an unsigned signature field goes into
16
- * the field (sign / visual fill / ask, by mode) instead of onto the page.
25
+ * the field (sign, visual fill or ask, by mode) instead of onto the page.
26
+ * `config` is the settings the app registers, over {@link SIGNATURE_DEFAULTS}.
17
27
  */
18
- declare const signaturePlugin: (config?: SignatureConfig) => import("@embedpdf/core").PluginDef<SignatureState, SignatureAction, SignatureCapability>;
28
+ declare const signaturePlugin: (config?: SignatureConfig) => import("@embedpdf/core").PluginDef<SignatureState, SignatureCapability, SignatureSettings>;
19
29
  //#endregion
20
- //#region src/handler.d.ts
21
- /**
22
- * The armed mark over a field. The annotation plugin places an armed stamp
23
- * on click (`annotation-place`, priority 95) and selects an existing
24
- * annotation under the pointer before that (`annotation-edit`, 100 — a
25
- * widget is an annotation). This handler sits above BOTH, enabled for the
26
- * armed stamp's tool only, and captures exactly when the armed asset is a
27
- * person's mark (a library of kind `signatures`) and the pointer is over a
28
- * signature field: then the destination decides — the mark goes INTO the
29
- * field (`placeMark` by mode) instead of onto the page. Everywhere else it
30
- * declines and the click stays a stamp placement, as in Preview.
31
- */
32
- declare function createArmedMarkHandler(documentId: string, signature: SignatureCapability, form: FormCapability, stamp: StampCapability): InteractionHandler;
30
+ //#region src/state.d.ts
31
+ declare const signatureState: import("@embedpdf/core").StateDeclaration<SignatureCapability, {
32
+ signatures: readonly SignatureInfo[];
33
+ protection: import("@embedpdf/engine-core/runtime").DocumentProtection | null;
34
+ target: import("@embedpdf/engine-core/runtime").FormFieldRef | null;
35
+ busy: boolean;
36
+ pending: SignaturePending | null;
37
+ status: import("@embedpdf/core").ResourceStatus;
38
+ }>;
33
39
  //#endregion
34
- export { type AnalyzeInput, type ChangeAnalysis, type DocMdpPermission, type DocumentProtection, type FieldLockSpec, type FormFieldRef, INITIALS_MARK_NAME, type Mark, type MarkRole, type PersonalKeyStore, type PersonalSigner, SIGNATURES_LIBRARY_KIND, SIGNATURE_MARK_NAME, type SignFieldInput, type SignatureAction, type SignatureCapability, type SignatureChange, type SignatureCompleteResult, type SignatureConfig, type SignatureDTO, type SignatureMode, type SignaturePending, type SignatureSnapshot, type SignatureState, SignatureToken, type SignatureVerdict, type SignerPort, type TestSigner, type TrustPort, type ValidationTime, createArmedMarkHandler, createTestSigner, indexedDbKeyStore, markRoleOf, memoryKeyStore, personalSigner, remoteSigner, signaturePlugin, webCryptoSigner };
40
+ export { type AnalyzeInput, type ChangeAnalysis, type DocMdpPermission, type DocumentProtection, type FieldLockSpec, type FormFieldRef, INITIALS_MARK_NAME, Mark, MarkRole, type PersonalKeyStore, type PersonalSigner, PlaceMarkResult, PrepareSignatureInput, PreparedSignature, SIGNATURES_LIBRARY_KIND, SIGNATURE_DEFAULTS, SIGNATURE_MARK_NAME, SignFieldInput, SignatureCapability, SignatureClearedEvent, type SignatureCompleteResult, SignatureConfig, type SignatureDTO, SignatureFieldAddress, SignatureFilledEvent, SignatureInfo, SignatureInspectionRequestedEvent, SignatureInvalidationPredictedEvent, SignatureKey, SignatureMode, SignaturePending, type SignaturePrepared, SignatureProtectionChangedEvent, SignatureSettings, SignatureSignRequestedEvent, SignatureSignedEvent, type SignatureSnapshot, SignatureTargetChangedEvent, SignatureToken, SignatureValidateOptions, SignatureValidatedEvent, type SignatureVerdict, type SignerPort, SignerRow, type TestSigner, type TrustPort, type ValidationTime, createTestSigner, indexedDbKeyStore, markRoleOf, memoryKeyStore, personalSigner, remoteSigner, signaturePlugin, signatureState, signerRowsOf, webCryptoSigner };
35
41
  //# sourceMappingURL=index.d.ts.map