@embedpdf/plugin-signature 2.15.1 → 3.0.0-next.14

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.
Files changed (92) hide show
  1. package/LICENSE +192 -21
  2. package/README.md +38 -0
  3. package/dist/contract-BvHa9Zl_.d.cts +176 -0
  4. package/dist/contract-C3nQtwGf.js +14 -0
  5. package/dist/contract-C3nQtwGf.js.map +1 -0
  6. package/dist/contract-CojqGdMH.cjs +43 -0
  7. package/dist/contract-CojqGdMH.cjs.map +1 -0
  8. package/dist/contract-Dg50puf7.d.ts +176 -0
  9. package/dist/contract.cjs +7 -0
  10. package/dist/contract.d.cts +2 -0
  11. package/dist/contract.d.ts +2 -0
  12. package/dist/contract.js +2 -0
  13. package/dist/index.cjs +498 -2
  14. package/dist/index.cjs.map +1 -1
  15. package/dist/index.d.cts +35 -0
  16. package/dist/index.d.ts +35 -1
  17. package/dist/index.js +450 -511
  18. package/dist/index.js.map +1 -1
  19. package/package.json +28 -58
  20. package/dist/lib/actions.d.ts +0 -14
  21. package/dist/lib/handlers/signature-ink.handler.d.ts +0 -4
  22. package/dist/lib/handlers/signature-stamp.handler.d.ts +0 -4
  23. package/dist/lib/index.d.ts +0 -12
  24. package/dist/lib/manifest.d.ts +0 -4
  25. package/dist/lib/reducer.d.ts +0 -5
  26. package/dist/lib/serialization.d.ts +0 -30
  27. package/dist/lib/signature-plugin.d.ts +0 -27
  28. package/dist/lib/tools.d.ts +0 -113
  29. package/dist/lib/types.d.ts +0 -114
  30. package/dist/preact/adapter.d.ts +0 -5
  31. package/dist/preact/annotation.d.ts +0 -1
  32. package/dist/preact/core.d.ts +0 -1
  33. package/dist/preact/index.cjs +0 -2
  34. package/dist/preact/index.cjs.map +0 -1
  35. package/dist/preact/index.d.ts +0 -1
  36. package/dist/preact/index.js +0 -464
  37. package/dist/preact/index.js.map +0 -1
  38. package/dist/react/adapter.d.ts +0 -2
  39. package/dist/react/annotation.d.ts +0 -1
  40. package/dist/react/core.d.ts +0 -1
  41. package/dist/react/index.cjs +0 -2
  42. package/dist/react/index.cjs.map +0 -1
  43. package/dist/react/index.d.ts +0 -1
  44. package/dist/react/index.js +0 -463
  45. package/dist/react/index.js.map +0 -1
  46. package/dist/shared/components/crop-canvas.d.ts +0 -14
  47. package/dist/shared/components/index.d.ts +0 -2
  48. package/dist/shared/components/signature-draw-pad.d.ts +0 -12
  49. package/dist/shared/components/signature-type-pad.d.ts +0 -14
  50. package/dist/shared/hooks/index.d.ts +0 -2
  51. package/dist/shared/hooks/use-signature-upload.d.ts +0 -21
  52. package/dist/shared/hooks/use-signature.d.ts +0 -16
  53. package/dist/shared/index.d.ts +0 -4
  54. package/dist/shared-preact/components/crop-canvas.d.ts +0 -14
  55. package/dist/shared-preact/components/index.d.ts +0 -2
  56. package/dist/shared-preact/components/signature-draw-pad.d.ts +0 -12
  57. package/dist/shared-preact/components/signature-type-pad.d.ts +0 -14
  58. package/dist/shared-preact/hooks/index.d.ts +0 -2
  59. package/dist/shared-preact/hooks/use-signature-upload.d.ts +0 -21
  60. package/dist/shared-preact/hooks/use-signature.d.ts +0 -16
  61. package/dist/shared-preact/index.d.ts +0 -4
  62. package/dist/shared-react/components/crop-canvas.d.ts +0 -14
  63. package/dist/shared-react/components/index.d.ts +0 -2
  64. package/dist/shared-react/components/signature-draw-pad.d.ts +0 -12
  65. package/dist/shared-react/components/signature-type-pad.d.ts +0 -14
  66. package/dist/shared-react/hooks/index.d.ts +0 -2
  67. package/dist/shared-react/hooks/use-signature-upload.d.ts +0 -21
  68. package/dist/shared-react/hooks/use-signature.d.ts +0 -16
  69. package/dist/shared-react/index.d.ts +0 -4
  70. package/dist/shared-vue/components/crop-canvas.d.ts +0 -14
  71. package/dist/svelte/components/SignatureDrawPad.svelte.d.ts +0 -12
  72. package/dist/svelte/components/SignatureTypePad.svelte.d.ts +0 -14
  73. package/dist/svelte/components/index.d.ts +0 -2
  74. package/dist/svelte/hooks/index.d.ts +0 -2
  75. package/dist/svelte/hooks/use-signature-upload.svelte.d.ts +0 -21
  76. package/dist/svelte/hooks/use-signature.svelte.d.ts +0 -17
  77. package/dist/svelte/index.cjs +0 -2
  78. package/dist/svelte/index.cjs.map +0 -1
  79. package/dist/svelte/index.d.ts +0 -4
  80. package/dist/svelte/index.js +0 -415
  81. package/dist/svelte/index.js.map +0 -1
  82. package/dist/vue/components/SignatureDrawPad.vue.d.ts +0 -15
  83. package/dist/vue/components/SignatureTypePad.vue.d.ts +0 -19
  84. package/dist/vue/components/index.d.ts +0 -2
  85. package/dist/vue/hooks/index.d.ts +0 -2
  86. package/dist/vue/hooks/use-signature-upload.d.ts +0 -20
  87. package/dist/vue/hooks/use-signature.d.ts +0 -176
  88. package/dist/vue/index.cjs +0 -2
  89. package/dist/vue/index.cjs.map +0 -1
  90. package/dist/vue/index.d.ts +0 -4
  91. package/dist/vue/index.js +0 -453
  92. package/dist/vue/index.js.map +0 -1
package/LICENSE CHANGED
@@ -1,21 +1,192 @@
1
- MIT License
2
-
3
- Copyright (c) 2025 CloudPDF
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ Copyright 2026 CloudPDF LTD
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use files in this distribution except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+
7
+ https://www.apache.org/licenses/LICENSE-2.0
8
+
9
+ Unless required by applicable law or agreed to in writing, software
10
+ distributed under the License is distributed on an "AS IS" BASIS,
11
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ See the License for the specific language governing permissions and
13
+ limitations under the License.
14
+
15
+ -----------------------------------------------------------------------
16
+
17
+ Apache License
18
+ Version 2.0, January 2004
19
+ http://www.apache.org/licenses/
20
+
21
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
22
+
23
+ 1. Definitions.
24
+
25
+ "License" shall mean the terms and conditions for use, reproduction,
26
+ and distribution as defined by Sections 1 through 9 of this document.
27
+
28
+ "Licensor" shall mean the copyright owner or entity authorized by
29
+ the copyright owner that is granting the License.
30
+
31
+ "Legal Entity" shall mean the union of the acting entity and all
32
+ other entities that control, are controlled by, or are under common
33
+ control with that entity. For the purposes of this definition,
34
+ "control" means (i) the power, direct or indirect, to cause the
35
+ direction or management of such entity, whether by contract or
36
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
37
+ outstanding shares, or (iii) beneficial ownership of such entity.
38
+
39
+ "You" (or "Your") shall mean an individual or Legal Entity
40
+ exercising permissions granted by this License.
41
+
42
+ "Source" form shall mean the preferred form for making modifications,
43
+ including but not limited to software source code, documentation
44
+ source, and configuration files.
45
+
46
+ "Object" form shall mean any form resulting from mechanical
47
+ transformation or translation of a Source form, including but
48
+ not limited to compiled object code, generated documentation,
49
+ and conversions to other media types.
50
+
51
+ "Work" shall mean the work of authorship, whether in Source or
52
+ Object form, made available under the License, as indicated by a
53
+ copyright notice that is included in or attached to the work
54
+ (an example is provided in the Appendix below).
55
+
56
+ "Derivative Works" shall mean any work, whether in Source or Object
57
+ form, that is based on (or derived from) the Work and for which the
58
+ editorial revisions, annotations, elaborations, or other modifications
59
+ represent, as a whole, an original work of authorship. For the purposes
60
+ of this License, Derivative Works shall not include works that remain
61
+ separable from, or merely link (or bind by name) to the interfaces of,
62
+ the Work and Derivative Works thereof.
63
+
64
+ "Contribution" shall mean any work of authorship, including
65
+ the original version of the Work and any modifications or additions
66
+ to that Work or Derivative Works thereof, that is intentionally
67
+ submitted to Licensor for inclusion in the Work by the copyright owner
68
+ or by an individual or Legal Entity authorized to submit on behalf of
69
+ the copyright owner. For the purposes of this definition, "submitted"
70
+ means any form of electronic, verbal, or written communication sent
71
+ to the Licensor or its representatives, including but not limited to
72
+ communication on electronic mailing lists, source code control systems,
73
+ and issue tracking systems that are managed by, or on behalf of, the
74
+ Licensor for the purpose of discussing and improving the Work, but
75
+ excluding communication that is conspicuously marked or otherwise
76
+ designated in writing by the copyright owner as "Not a Contribution."
77
+
78
+ "Contributor" shall mean Licensor and any individual or Legal Entity
79
+ on behalf of whom a Contribution has been received by Licensor and
80
+ subsequently incorporated within the Work.
81
+
82
+ 2. Grant of Copyright License. Subject to the terms and conditions of
83
+ this License, each Contributor hereby grants to You a perpetual,
84
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
85
+ copyright license to reproduce, prepare Derivative Works of,
86
+ publicly display, publicly perform, sublicense, and distribute the
87
+ Work and such Derivative Works in Source or Object form.
88
+
89
+ 3. Grant of Patent License. Subject to the terms and conditions of
90
+ this License, each Contributor hereby grants to You a perpetual,
91
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
92
+ (except as stated in this section) patent license to make, have made,
93
+ use, offer to sell, sell, import, and otherwise transfer the Work,
94
+ where such license applies only to those patent claims licensable
95
+ by such Contributor that are necessarily infringed by their
96
+ Contribution(s) alone or by combination of their Contribution(s)
97
+ with the Work to which such Contribution(s) was submitted. If You
98
+ institute patent litigation against any entity (including a
99
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
100
+ or a Contribution incorporated within the Work constitutes direct
101
+ or contributory patent infringement, then any patent licenses
102
+ granted to You under this License for that Work shall terminate
103
+ as of the date such litigation is filed.
104
+
105
+ 4. Redistribution. You may reproduce and distribute copies of the
106
+ Work or Derivative Works thereof in any medium, with or without
107
+ modifications, and in Source or Object form, provided that You
108
+ meet the following conditions:
109
+
110
+ (a) You must give any other recipients of the Work or
111
+ Derivative Works a copy of this License; and
112
+
113
+ (b) You must cause any modified files to carry prominent notices
114
+ stating that You changed the files; and
115
+
116
+ (c) You must retain, in the Source form of any Derivative Works
117
+ that You distribute, all copyright, patent, trademark, and
118
+ attribution notices from the Source form of the Work,
119
+ excluding those notices that do not pertain to any part of
120
+ the Derivative Works; and
121
+
122
+ (d) If the Work includes a "NOTICE" text file as part of its
123
+ distribution, then any Derivative Works that You distribute must
124
+ include a readable copy of the attribution notices contained
125
+ within such NOTICE file, excluding those notices that do not
126
+ pertain to any part of the Derivative Works, in at least one
127
+ of the following places: within a NOTICE text file distributed
128
+ as part of the Derivative Works; within the Source form or
129
+ documentation, if provided along with the Derivative Works; or,
130
+ within a display generated by the Derivative Works, if and
131
+ wherever such third-party notices normally appear. The contents
132
+ of the NOTICE file are for informational purposes only and
133
+ do not modify the License. You may add Your own attribution
134
+ notices within Derivative Works that You distribute, alongside
135
+ or as an addendum to the NOTICE text from the Work, provided
136
+ that such additional attribution notices cannot be construed
137
+ as modifying the License.
138
+
139
+ You may add Your own copyright statement to Your modifications and
140
+ may provide additional or different license terms and conditions
141
+ for use, reproduction, or distribution of Your modifications, or
142
+ for any such Derivative Works as a whole, provided Your use,
143
+ reproduction, and distribution of the Work otherwise complies with
144
+ the conditions stated in this License.
145
+
146
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
147
+ any Contribution intentionally submitted for inclusion in the Work
148
+ by You to the Licensor shall be under the terms and conditions of
149
+ this License, without any additional terms or conditions.
150
+ Notwithstanding the above, nothing herein shall supersede or modify
151
+ the terms of any separate license agreement you may have executed
152
+ with Licensor regarding such Contributions.
153
+
154
+ 6. Trademarks. This License does not grant permission to use the trade
155
+ names, trademarks, service marks, or product names of the Licensor,
156
+ except as required for reasonable and customary use in describing the
157
+ origin of the Work and reproducing the content of the NOTICE file.
158
+
159
+ 7. Disclaimer of Warranty. Unless required by applicable law or
160
+ agreed to in writing, Licensor provides the Work (and each
161
+ Contributor provides its Contributions) on an "AS IS" BASIS,
162
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
163
+ implied, including, without limitation, any warranties or conditions
164
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
165
+ PARTICULAR PURPOSE. You are solely responsible for determining the
166
+ appropriateness of using or redistributing the Work and assume any
167
+ risks associated with Your exercise of permissions under this License.
168
+
169
+ 8. Limitation of Liability. In no event and under no legal theory,
170
+ whether in tort (including negligence), contract, or otherwise,
171
+ unless required by applicable law (such as deliberate and grossly
172
+ negligent acts) or agreed to in writing, shall any Contributor be
173
+ liable to You for damages, including any direct, indirect, special,
174
+ incidental, or consequential damages of any character arising as a
175
+ result of this License or out of the use or inability to use the
176
+ Work (including but not limited to damages for loss of goodwill,
177
+ work stoppage, computer failure or malfunction, or any and all
178
+ other commercial damages or losses), even if such Contributor
179
+ has been advised of the possibility of such damages.
180
+
181
+ 9. Accepting Warranty or Additional Liability. While redistributing
182
+ the Work or Derivative Works thereof, You may choose to offer,
183
+ and charge a fee for, acceptance of support, warranty, indemnity,
184
+ or other liability obligations and/or rights consistent with this
185
+ License. However, in accepting such obligations, You may act only
186
+ on Your own behalf and on Your sole responsibility, not on behalf
187
+ of any other Contributor, and only if You agree to indemnify,
188
+ defend, and hold each Contributor harmless for any liability
189
+ incurred by, or claims asserted against, such Contributor by reason
190
+ of your accepting any such warranty or additional liability.
191
+
192
+ END OF TERMS AND CONDITIONS
package/README.md ADDED
@@ -0,0 +1,38 @@
1
+ # @embedpdf/plugin-signature
2
+
3
+ Document-scoped digital signing for EmbedPDF v3: sign a signature field with a
4
+ **mark** (a stamp-library asset — drawn, typed, uploaded — or bytes you bring)
5
+ through a **signer port** you configure; fill a field visually without
6
+ sealing; validate what is signed; and drop an armed mark onto a field.
7
+
8
+ The plugin owns the act and nothing else:
9
+
10
+ - marks are the stamp plugin's (`@embedpdf/plugin-stamp`) — one library of kind
11
+ `signatures` per person, holding a `signature` asset and optional `initials`;
12
+ - the key is a `SignerPort` from `@embedpdf/core-signature` (`webCryptoSigner`,
13
+ `remoteSigner`, `personalSigner`), resolved per signing;
14
+ - the engine draws the mark's page into the field and seals the bytes
15
+ (`doc.signatures.prepare` → CMS → `complete`); on the cloud the server
16
+ publishes the new version.
17
+
18
+ ```ts
19
+ import { signaturePlugin, personalSigner, indexedDbKeyStore } from '@embedpdf/plugin-signature';
20
+
21
+ signaturePlugin({
22
+ signer: () => personalSigner({ subject: 'Ada Lovelace', store: indexedDbKeyStore('keys') }),
23
+ trust: { anchors: async () => [rootCertificateDer] },
24
+ mode: 'sign', // 'sign' (default with a signer) | 'visual' (default without) | 'ask'
25
+ });
26
+
27
+ const signature = ctx.get(SignatureToken);
28
+ await signature.placeMark({ assetId }, { field: { kind: 'fqn', name: 'sig' } }); // sign / fill / ask, by mode
29
+ await signature.placeMark({ assetId }, { pageObjectNumber, at: { x: 120, y: 90 } }); // elsewhere: a stamp
30
+ ```
31
+
32
+ With the interaction hub and the stamp plugin present, a mark armed from a
33
+ `signatures` library and clicked over an unsigned signature field goes into
34
+ the field; anywhere else it is placed as a stamp.
35
+
36
+ Requires `@embedpdf/plugin-form`; optional `@embedpdf/plugin-stamp`,
37
+ `@embedpdf/plugin-annotation`, `@embedpdf/plugin-interaction`. See the docs
38
+ page `headless/plugins/signature` for the full contract.
@@ -0,0 +1,176 @@
1
+ import { EventHook } from "@embedpdf/core";
2
+ import { SignatureVerdict, SignatureVerdict as SignatureVerdict$1, SignerPort, SignerPort as SignerPort$1, TrustPort, TrustPort as TrustPort$1, ValidationTime, ValidationTime as ValidationTime$1 } from "@embedpdf/core-signature";
3
+ import { AnalyzeInput, AnalyzeInput as AnalyzeInput$1, BinarySource, ChangeAnalysis, ChangeAnalysis as ChangeAnalysis$1, DocMdpPermission, DocMdpPermission as DocMdpPermission$1, DocumentProtection, DocumentProtection as DocumentProtection$1, FieldLockSpec, FieldLockSpec as FieldLockSpec$1, FormFieldRef, FormFieldRef as FormFieldRef$1, SignatureCompleteResult, SignatureCompleteResult as SignatureCompleteResult$1, SignatureDTO, SignatureDTO as SignatureDTO$1, SignatureSnapshot, SignatureSnapshot as SignatureSnapshot$1 } from "@embedpdf/engine-core/runtime";
4
+ import { StampPlacement } from "@embedpdf/plugin-annotation/contract";
5
+ import { StampAsset } from "@embedpdf/plugin-stamp/contract";
6
+ //#region src/types.d.ts
7
+ /**
8
+ * What placing a mark on a signature field does:
9
+ * - `sign` seal the field with the configured signer (the mark is the appearance);
10
+ * - `visual` draw the mark into the field without sealing (Preview's "signature");
11
+ * - `ask` neither — emit `ask` so the chrome can open its dialog and decide.
12
+ * Default `sign` when a signer is configured, else `visual`.
13
+ */
14
+ type SignatureMode = 'sign' | 'visual' | 'ask';
15
+ interface SignatureConfig {
16
+ mode?: SignatureMode;
17
+ /** The key holder: a raw signer (the CMS is built here) or a CMS signer (a service builds it). A thunk resolves per signing. */
18
+ signer?: SignerPort | (() => Promise<SignerPort>);
19
+ /** Trust anchors for validation. None → every verdict tops out at `valid-untrusted`. */
20
+ trust?: TrustPort;
21
+ /** Let the UI offer a certification (still needs `doc.sign.certify`). Default false. */
22
+ allowCertify?: boolean;
23
+ }
24
+ /** The mark: a stamp-plugin asset, or bytes the embedder brings (PNG, JPEG, or a one-page PDF). */
25
+ type Mark = {
26
+ assetId: string;
27
+ } | {
28
+ source: BinarySource;
29
+ };
30
+ interface SignFieldInput {
31
+ field: FormFieldRef;
32
+ mark: Mark;
33
+ /** What the signature dictionary says (`/Name` `/Reason` `/Location` `/ContactInfo`); the name defaults to the certificate's subject. */
34
+ attribution?: {
35
+ name?: string;
36
+ reason?: string;
37
+ location?: string;
38
+ contactInfo?: string;
39
+ };
40
+ /** Instead of the mark: a ready one-page appearance PDF the embedder composed itself. */
41
+ appearance?: BinarySource;
42
+ certify?: {
43
+ permission: DocMdpPermission;
44
+ };
45
+ lock?: FieldLockSpec;
46
+ }
47
+ /** The stamp-library kind that holds people's marks: one library per person. */
48
+ declare const SIGNATURES_LIBRARY_KIND = "signatures";
49
+ /** The asset identifiers inside a signatures library: the full signature and the initials. */
50
+ declare const SIGNATURE_MARK_NAME = "signature";
51
+ declare const INITIALS_MARK_NAME = "initials";
52
+ type MarkRole = 'signature' | 'initials';
53
+ /** Which mark an asset of a signatures library is (anything not named `initials` is a signature). */
54
+ declare const markRoleOf: (asset: Pick<StampAsset, "name">) => MarkRole;
55
+ interface SignaturePending {
56
+ signingId: string;
57
+ field: FormFieldRef;
58
+ }
59
+ interface SignatureState {
60
+ snapshot: SignatureSnapshot | null;
61
+ verdicts: SignatureVerdict[] | null;
62
+ /** The field the user chose to sign next ("select the field, then pick a mark"). */
63
+ target: FormFieldRef | null;
64
+ /** A signing candidate is parked (here or, on the cloud, elsewhere): the document is read-only. */
65
+ pending: SignaturePending | null;
66
+ /** A sign/fill call is in flight. */
67
+ busy: boolean;
68
+ }
69
+ type SignatureAction = {
70
+ type: 'SNAPSHOT';
71
+ snapshot: SignatureSnapshot | null;
72
+ } | {
73
+ type: 'VERDICTS';
74
+ verdicts: SignatureVerdict[] | null;
75
+ } | {
76
+ type: 'TARGET';
77
+ field: FormFieldRef | null;
78
+ } | {
79
+ type: 'PENDING';
80
+ pending: SignaturePending | null;
81
+ } | {
82
+ type: 'BUSY';
83
+ busy: boolean;
84
+ };
85
+ type SignatureChange = {
86
+ type: 'signed';
87
+ field: FormFieldRef;
88
+ result: SignatureCompleteResult;
89
+ } | {
90
+ type: 'filled';
91
+ field: FormFieldRef;
92
+ } | {
93
+ type: 'cleared';
94
+ field: FormFieldRef;
95
+ } |
96
+ /** Mode `ask`: a mark met a field and the chrome decides (open its dialog, then `signField`/`fillField`). */
97
+ {
98
+ type: 'ask';
99
+ field: FormFieldRef;
100
+ mark: Mark;
101
+ } |
102
+ /** A signed field was activated: show what its signature says. */
103
+ {
104
+ type: 'inspect';
105
+ field: FormFieldRef;
106
+ } | {
107
+ type: 'target';
108
+ field: FormFieldRef | null;
109
+ } | {
110
+ type: 'validated';
111
+ verdicts: SignatureVerdict[];
112
+ } |
113
+ /** An unsaved edit just turned a signature that held into one a save would invalidate. Once per edge. */
114
+ {
115
+ type: 'invalidating';
116
+ field: FormFieldRef;
117
+ detail: string;
118
+ } | {
119
+ type: 'protectionChanged';
120
+ protection: DocumentProtection;
121
+ };
122
+ interface SignatureCapability {
123
+ snapshot(): SignatureSnapshot | null;
124
+ verdicts(): SignatureVerdict[] | null;
125
+ protection(): DocumentProtection | null;
126
+ pending(): SignaturePending | null;
127
+ target(): FormFieldRef | null;
128
+ busy(): boolean;
129
+ mode(): SignatureMode;
130
+ /** The signature facts of one field, by ref or by widget, from the last snapshot. */
131
+ signatureOf(field: FormFieldRef | {
132
+ annotObjectNumber: number;
133
+ }): SignatureDTO | null;
134
+ /** The verdict of one signed field from the last validation. */
135
+ verdictOf(field: FormFieldRef | {
136
+ annotObjectNumber: number;
137
+ }): SignatureVerdict | null;
138
+ /** `doc.sign` is granted and a signer is configured (or resolvable). */
139
+ canSign(): boolean;
140
+ /** Visual fills ride `doc.forms.fill`. */
141
+ canFill(): boolean;
142
+ /** `allowCertify` and `doc.sign.certify`. */
143
+ canCertify(): boolean;
144
+ /** Seal the field: the mark's page becomes the widget's appearance, the configured signer signs. */
145
+ signField(input: SignFieldInput): Promise<SignatureCompleteResult>;
146
+ /** Visual only: the mark becomes the widget's appearance; nothing is sealed. Refused on a signed field. */
147
+ fillField(field: FormFieldRef, mark: Mark): Promise<void>;
148
+ /** Undo a visual fill (a blank appearance). Refused on a signed field. */
149
+ clearField(field: FormFieldRef): Promise<void>;
150
+ /** The destination rule in one call: a field (sign, fill, or ask by mode) or a free placement (a stamp). */
151
+ placeMark(mark: Mark, target: {
152
+ field: FormFieldRef;
153
+ } | StampPlacement): Promise<void>;
154
+ /** Name the field the next picked mark goes to (the chrome's "Sign here"); null clears. */
155
+ setTarget(field: FormFieldRef | null): void;
156
+ /** Ask the chrome to show a signed field's facts (`inspect`). */
157
+ inspect(field: FormFieldRef): void;
158
+ refresh(): Promise<SignatureSnapshot | null>;
159
+ /**
160
+ * Judge every signature. The viewer's default is the WORKING COPY: unsaved
161
+ * edits count, so the verdict is the one the file a save produces will get.
162
+ * `until: 'persisted'` judges the loaded bytes only.
163
+ */
164
+ validate(opts?: {
165
+ at?: ValidationTime;
166
+ until?: 'persisted' | 'working-copy';
167
+ }): Promise<SignatureVerdict[]>;
168
+ analyze(input: AnalyzeInput): Promise<ChangeAnalysis>;
169
+ /** The exact bytes a signature's revision covers (`doc.signatures.revisionBytes`) — rides `doc.download`. */
170
+ revisionBytes(revisionIndex: number): Promise<Uint8Array>;
171
+ onChanged: EventHook<SignatureChange>;
172
+ }
173
+ declare const SignatureToken: import("@embedpdf/core").CapabilityToken<SignatureCapability>;
174
+ //#endregion
175
+ export { SignatureConfig as C, SignatureToken as D, SignatureState as E, markRoleOf as O, SignatureChange as S, SignaturePending as T, SIGNATURES_LIBRARY_KIND as _, FieldLockSpec$1 as a, SignatureAction as b, SignatureDTO$1 as c, SignerPort$1 as d, TrustPort$1 as f, MarkRole as g, Mark as h, DocumentProtection$1 as i, SignatureSnapshot$1 as l, INITIALS_MARK_NAME as m, ChangeAnalysis$1 as n, FormFieldRef$1 as o, ValidationTime$1 as p, DocMdpPermission$1 as r, SignatureCompleteResult$1 as s, AnalyzeInput$1 as t, SignatureVerdict$1 as u, SIGNATURE_MARK_NAME as v, SignatureMode as w, SignatureCapability as x, SignFieldInput as y };
176
+ //# sourceMappingURL=contract-BvHa9Zl_.d.cts.map
@@ -0,0 +1,14 @@
1
+ import { createCapabilityToken } from "@embedpdf/core";
2
+ //#region src/types.ts
3
+ /** The stamp-library kind that holds people's marks: one library per person. */
4
+ const SIGNATURES_LIBRARY_KIND = "signatures";
5
+ /** The asset identifiers inside a signatures library: the full signature and the initials. */
6
+ const SIGNATURE_MARK_NAME = "signature";
7
+ const INITIALS_MARK_NAME = "initials";
8
+ /** Which mark an asset of a signatures library is (anything not named `initials` is a signature). */
9
+ const markRoleOf = (asset) => asset.name === "initials" ? "initials" : "signature";
10
+ const SignatureToken = createCapabilityToken("signature");
11
+ //#endregion
12
+ export { markRoleOf as a, SignatureToken as i, SIGNATURES_LIBRARY_KIND as n, SIGNATURE_MARK_NAME as r, INITIALS_MARK_NAME as t };
13
+
14
+ //# sourceMappingURL=contract-C3nQtwGf.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contract-C3nQtwGf.js","names":[],"sources":["../src/types.ts"],"sourcesContent":["import { createCapabilityToken, type EventHook } from '@embedpdf/core';\nimport type {\n SignatureVerdict,\n SignerPort,\n TrustPort,\n ValidationTime,\n} from '@embedpdf/core-signature';\nimport type {\n AnalyzeInput,\n BinarySource,\n ChangeAnalysis,\n DocMdpPermission,\n DocumentProtection,\n FieldLockSpec,\n FormFieldRef,\n SignatureCompleteResult,\n SignatureDTO,\n SignatureSnapshot,\n} from '@embedpdf/engine-core/runtime';\nimport type { StampPlacement } from '@embedpdf/plugin-annotation/contract';\nimport type { StampAsset } from '@embedpdf/plugin-stamp/contract';\n\n/**\n * What placing a mark on a signature field does:\n * - `sign` seal the field with the configured signer (the mark is the appearance);\n * - `visual` draw the mark into the field without sealing (Preview's \"signature\");\n * - `ask` neither — emit `ask` so the chrome can open its dialog and decide.\n * Default `sign` when a signer is configured, else `visual`.\n */\nexport type SignatureMode = 'sign' | 'visual' | 'ask';\n\nexport interface SignatureConfig {\n mode?: SignatureMode;\n /** The key holder: a raw signer (the CMS is built here) or a CMS signer (a service builds it). A thunk resolves per signing. */\n signer?: SignerPort | (() => Promise<SignerPort>);\n /** Trust anchors for validation. None → every verdict tops out at `valid-untrusted`. */\n trust?: TrustPort;\n /** Let the UI offer a certification (still needs `doc.sign.certify`). Default false. */\n allowCertify?: boolean;\n}\n\n/** The mark: a stamp-plugin asset, or bytes the embedder brings (PNG, JPEG, or a one-page PDF). */\nexport type Mark = { assetId: string } | { source: BinarySource };\n\nexport interface SignFieldInput {\n field: FormFieldRef;\n mark: Mark;\n /** What the signature dictionary says (`/Name` `/Reason` `/Location` `/ContactInfo`); the name defaults to the certificate's subject. */\n attribution?: { name?: string; reason?: string; location?: string; contactInfo?: string };\n /** Instead of the mark: a ready one-page appearance PDF the embedder composed itself. */\n appearance?: BinarySource;\n certify?: { permission: DocMdpPermission };\n lock?: FieldLockSpec;\n}\n\n/** The stamp-library kind that holds people's marks: one library per person. */\nexport const SIGNATURES_LIBRARY_KIND = 'signatures';\n/** The asset identifiers inside a signatures library: the full signature and the initials. */\nexport const SIGNATURE_MARK_NAME = 'signature';\nexport const INITIALS_MARK_NAME = 'initials';\nexport type MarkRole = 'signature' | 'initials';\n/** Which mark an asset of a signatures library is (anything not named `initials` is a signature). */\nexport const markRoleOf = (asset: Pick<StampAsset, 'name'>): MarkRole =>\n asset.name === INITIALS_MARK_NAME ? 'initials' : 'signature';\n\nexport interface SignaturePending {\n signingId: string;\n field: FormFieldRef;\n}\n\nexport interface SignatureState {\n snapshot: SignatureSnapshot | null;\n verdicts: SignatureVerdict[] | null;\n /** The field the user chose to sign next (\"select the field, then pick a mark\"). */\n target: FormFieldRef | null;\n /** A signing candidate is parked (here or, on the cloud, elsewhere): the document is read-only. */\n pending: SignaturePending | null;\n /** A sign/fill call is in flight. */\n busy: boolean;\n}\n\nexport type SignatureAction =\n | { type: 'SNAPSHOT'; snapshot: SignatureSnapshot | null }\n | { type: 'VERDICTS'; verdicts: SignatureVerdict[] | null }\n | { type: 'TARGET'; field: FormFieldRef | null }\n | { type: 'PENDING'; pending: SignaturePending | null }\n | { type: 'BUSY'; busy: boolean };\n\nexport type SignatureChange =\n | { type: 'signed'; field: FormFieldRef; result: SignatureCompleteResult }\n | { type: 'filled'; field: FormFieldRef }\n | { type: 'cleared'; field: FormFieldRef }\n /** Mode `ask`: a mark met a field and the chrome decides (open its dialog, then `signField`/`fillField`). */\n | { type: 'ask'; field: FormFieldRef; mark: Mark }\n /** A signed field was activated: show what its signature says. */\n | { type: 'inspect'; field: FormFieldRef }\n | { type: 'target'; field: FormFieldRef | null }\n | { type: 'validated'; verdicts: SignatureVerdict[] }\n /** An unsaved edit just turned a signature that held into one a save would invalidate. Once per edge. */\n | { type: 'invalidating'; field: FormFieldRef; detail: string }\n | { type: 'protectionChanged'; protection: DocumentProtection };\n\nexport interface SignatureCapability {\n // ── selectors ──\n snapshot(): SignatureSnapshot | null;\n verdicts(): SignatureVerdict[] | null;\n protection(): DocumentProtection | null;\n pending(): SignaturePending | null;\n target(): FormFieldRef | null;\n busy(): boolean;\n mode(): SignatureMode;\n /** The signature facts of one field, by ref or by widget, from the last snapshot. */\n signatureOf(field: FormFieldRef | { annotObjectNumber: number }): SignatureDTO | null;\n /** The verdict of one signed field from the last validation. */\n verdictOf(field: FormFieldRef | { annotObjectNumber: number }): SignatureVerdict | null;\n /** `doc.sign` is granted and a signer is configured (or resolvable). */\n canSign(): boolean;\n /** Visual fills ride `doc.forms.fill`. */\n canFill(): boolean;\n /** `allowCertify` and `doc.sign.certify`. */\n canCertify(): boolean;\n // ── the act ──\n /** Seal the field: the mark's page becomes the widget's appearance, the configured signer signs. */\n signField(input: SignFieldInput): Promise<SignatureCompleteResult>;\n /** Visual only: the mark becomes the widget's appearance; nothing is sealed. Refused on a signed field. */\n fillField(field: FormFieldRef, mark: Mark): Promise<void>;\n /** Undo a visual fill (a blank appearance). Refused on a signed field. */\n clearField(field: FormFieldRef): Promise<void>;\n /** The destination rule in one call: a field (sign, fill, or ask by mode) or a free placement (a stamp). */\n placeMark(mark: Mark, target: { field: FormFieldRef } | StampPlacement): Promise<void>;\n /** Name the field the next picked mark goes to (the chrome's \"Sign here\"); null clears. */\n setTarget(field: FormFieldRef | null): void;\n /** Ask the chrome to show a signed field's facts (`inspect`). */\n inspect(field: FormFieldRef): void;\n // ── reading ──\n refresh(): Promise<SignatureSnapshot | null>;\n /**\n * Judge every signature. The viewer's default is the WORKING COPY: unsaved\n * edits count, so the verdict is the one the file a save produces will get.\n * `until: 'persisted'` judges the loaded bytes only.\n */\n validate(opts?: {\n at?: ValidationTime;\n until?: 'persisted' | 'working-copy';\n }): Promise<SignatureVerdict[]>;\n analyze(input: AnalyzeInput): Promise<ChangeAnalysis>;\n /** The exact bytes a signature's revision covers (`doc.signatures.revisionBytes`) — rides `doc.download`. */\n revisionBytes(revisionIndex: number): Promise<Uint8Array>;\n onChanged: EventHook<SignatureChange>;\n}\n\nexport const SignatureToken = createCapabilityToken<SignatureCapability>('signature');\n"],"mappings":";;;AAwDA,MAAa,0BAA0B;;AAEvC,MAAa,sBAAsB;AACnC,MAAa,qBAAqB;;AAGlC,MAAa,cAAc,UACzB,MAAM,SAAA,aAA8B,aAAa;AAwFnD,MAAa,iBAAiB,sBAA2C,WAAW"}
@@ -0,0 +1,43 @@
1
+ let _embedpdf_core = require("@embedpdf/core");
2
+ //#region src/types.ts
3
+ /** The stamp-library kind that holds people's marks: one library per person. */
4
+ const SIGNATURES_LIBRARY_KIND = "signatures";
5
+ /** The asset identifiers inside a signatures library: the full signature and the initials. */
6
+ const SIGNATURE_MARK_NAME = "signature";
7
+ const INITIALS_MARK_NAME = "initials";
8
+ /** Which mark an asset of a signatures library is (anything not named `initials` is a signature). */
9
+ const markRoleOf = (asset) => asset.name === "initials" ? "initials" : "signature";
10
+ const SignatureToken = (0, _embedpdf_core.createCapabilityToken)("signature");
11
+ //#endregion
12
+ Object.defineProperty(exports, "INITIALS_MARK_NAME", {
13
+ enumerable: true,
14
+ get: function() {
15
+ return INITIALS_MARK_NAME;
16
+ }
17
+ });
18
+ Object.defineProperty(exports, "SIGNATURES_LIBRARY_KIND", {
19
+ enumerable: true,
20
+ get: function() {
21
+ return SIGNATURES_LIBRARY_KIND;
22
+ }
23
+ });
24
+ Object.defineProperty(exports, "SIGNATURE_MARK_NAME", {
25
+ enumerable: true,
26
+ get: function() {
27
+ return SIGNATURE_MARK_NAME;
28
+ }
29
+ });
30
+ Object.defineProperty(exports, "SignatureToken", {
31
+ enumerable: true,
32
+ get: function() {
33
+ return SignatureToken;
34
+ }
35
+ });
36
+ Object.defineProperty(exports, "markRoleOf", {
37
+ enumerable: true,
38
+ get: function() {
39
+ return markRoleOf;
40
+ }
41
+ });
42
+
43
+ //# sourceMappingURL=contract-CojqGdMH.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contract-CojqGdMH.cjs","names":[],"sources":["../src/types.ts"],"sourcesContent":["import { createCapabilityToken, type EventHook } from '@embedpdf/core';\nimport type {\n SignatureVerdict,\n SignerPort,\n TrustPort,\n ValidationTime,\n} from '@embedpdf/core-signature';\nimport type {\n AnalyzeInput,\n BinarySource,\n ChangeAnalysis,\n DocMdpPermission,\n DocumentProtection,\n FieldLockSpec,\n FormFieldRef,\n SignatureCompleteResult,\n SignatureDTO,\n SignatureSnapshot,\n} from '@embedpdf/engine-core/runtime';\nimport type { StampPlacement } from '@embedpdf/plugin-annotation/contract';\nimport type { StampAsset } from '@embedpdf/plugin-stamp/contract';\n\n/**\n * What placing a mark on a signature field does:\n * - `sign` seal the field with the configured signer (the mark is the appearance);\n * - `visual` draw the mark into the field without sealing (Preview's \"signature\");\n * - `ask` neither — emit `ask` so the chrome can open its dialog and decide.\n * Default `sign` when a signer is configured, else `visual`.\n */\nexport type SignatureMode = 'sign' | 'visual' | 'ask';\n\nexport interface SignatureConfig {\n mode?: SignatureMode;\n /** The key holder: a raw signer (the CMS is built here) or a CMS signer (a service builds it). A thunk resolves per signing. */\n signer?: SignerPort | (() => Promise<SignerPort>);\n /** Trust anchors for validation. None → every verdict tops out at `valid-untrusted`. */\n trust?: TrustPort;\n /** Let the UI offer a certification (still needs `doc.sign.certify`). Default false. */\n allowCertify?: boolean;\n}\n\n/** The mark: a stamp-plugin asset, or bytes the embedder brings (PNG, JPEG, or a one-page PDF). */\nexport type Mark = { assetId: string } | { source: BinarySource };\n\nexport interface SignFieldInput {\n field: FormFieldRef;\n mark: Mark;\n /** What the signature dictionary says (`/Name` `/Reason` `/Location` `/ContactInfo`); the name defaults to the certificate's subject. */\n attribution?: { name?: string; reason?: string; location?: string; contactInfo?: string };\n /** Instead of the mark: a ready one-page appearance PDF the embedder composed itself. */\n appearance?: BinarySource;\n certify?: { permission: DocMdpPermission };\n lock?: FieldLockSpec;\n}\n\n/** The stamp-library kind that holds people's marks: one library per person. */\nexport const SIGNATURES_LIBRARY_KIND = 'signatures';\n/** The asset identifiers inside a signatures library: the full signature and the initials. */\nexport const SIGNATURE_MARK_NAME = 'signature';\nexport const INITIALS_MARK_NAME = 'initials';\nexport type MarkRole = 'signature' | 'initials';\n/** Which mark an asset of a signatures library is (anything not named `initials` is a signature). */\nexport const markRoleOf = (asset: Pick<StampAsset, 'name'>): MarkRole =>\n asset.name === INITIALS_MARK_NAME ? 'initials' : 'signature';\n\nexport interface SignaturePending {\n signingId: string;\n field: FormFieldRef;\n}\n\nexport interface SignatureState {\n snapshot: SignatureSnapshot | null;\n verdicts: SignatureVerdict[] | null;\n /** The field the user chose to sign next (\"select the field, then pick a mark\"). */\n target: FormFieldRef | null;\n /** A signing candidate is parked (here or, on the cloud, elsewhere): the document is read-only. */\n pending: SignaturePending | null;\n /** A sign/fill call is in flight. */\n busy: boolean;\n}\n\nexport type SignatureAction =\n | { type: 'SNAPSHOT'; snapshot: SignatureSnapshot | null }\n | { type: 'VERDICTS'; verdicts: SignatureVerdict[] | null }\n | { type: 'TARGET'; field: FormFieldRef | null }\n | { type: 'PENDING'; pending: SignaturePending | null }\n | { type: 'BUSY'; busy: boolean };\n\nexport type SignatureChange =\n | { type: 'signed'; field: FormFieldRef; result: SignatureCompleteResult }\n | { type: 'filled'; field: FormFieldRef }\n | { type: 'cleared'; field: FormFieldRef }\n /** Mode `ask`: a mark met a field and the chrome decides (open its dialog, then `signField`/`fillField`). */\n | { type: 'ask'; field: FormFieldRef; mark: Mark }\n /** A signed field was activated: show what its signature says. */\n | { type: 'inspect'; field: FormFieldRef }\n | { type: 'target'; field: FormFieldRef | null }\n | { type: 'validated'; verdicts: SignatureVerdict[] }\n /** An unsaved edit just turned a signature that held into one a save would invalidate. Once per edge. */\n | { type: 'invalidating'; field: FormFieldRef; detail: string }\n | { type: 'protectionChanged'; protection: DocumentProtection };\n\nexport interface SignatureCapability {\n // ── selectors ──\n snapshot(): SignatureSnapshot | null;\n verdicts(): SignatureVerdict[] | null;\n protection(): DocumentProtection | null;\n pending(): SignaturePending | null;\n target(): FormFieldRef | null;\n busy(): boolean;\n mode(): SignatureMode;\n /** The signature facts of one field, by ref or by widget, from the last snapshot. */\n signatureOf(field: FormFieldRef | { annotObjectNumber: number }): SignatureDTO | null;\n /** The verdict of one signed field from the last validation. */\n verdictOf(field: FormFieldRef | { annotObjectNumber: number }): SignatureVerdict | null;\n /** `doc.sign` is granted and a signer is configured (or resolvable). */\n canSign(): boolean;\n /** Visual fills ride `doc.forms.fill`. */\n canFill(): boolean;\n /** `allowCertify` and `doc.sign.certify`. */\n canCertify(): boolean;\n // ── the act ──\n /** Seal the field: the mark's page becomes the widget's appearance, the configured signer signs. */\n signField(input: SignFieldInput): Promise<SignatureCompleteResult>;\n /** Visual only: the mark becomes the widget's appearance; nothing is sealed. Refused on a signed field. */\n fillField(field: FormFieldRef, mark: Mark): Promise<void>;\n /** Undo a visual fill (a blank appearance). Refused on a signed field. */\n clearField(field: FormFieldRef): Promise<void>;\n /** The destination rule in one call: a field (sign, fill, or ask by mode) or a free placement (a stamp). */\n placeMark(mark: Mark, target: { field: FormFieldRef } | StampPlacement): Promise<void>;\n /** Name the field the next picked mark goes to (the chrome's \"Sign here\"); null clears. */\n setTarget(field: FormFieldRef | null): void;\n /** Ask the chrome to show a signed field's facts (`inspect`). */\n inspect(field: FormFieldRef): void;\n // ── reading ──\n refresh(): Promise<SignatureSnapshot | null>;\n /**\n * Judge every signature. The viewer's default is the WORKING COPY: unsaved\n * edits count, so the verdict is the one the file a save produces will get.\n * `until: 'persisted'` judges the loaded bytes only.\n */\n validate(opts?: {\n at?: ValidationTime;\n until?: 'persisted' | 'working-copy';\n }): Promise<SignatureVerdict[]>;\n analyze(input: AnalyzeInput): Promise<ChangeAnalysis>;\n /** The exact bytes a signature's revision covers (`doc.signatures.revisionBytes`) — rides `doc.download`. */\n revisionBytes(revisionIndex: number): Promise<Uint8Array>;\n onChanged: EventHook<SignatureChange>;\n}\n\nexport const SignatureToken = createCapabilityToken<SignatureCapability>('signature');\n"],"mappings":";;;AAwDA,MAAa,0BAA0B;;AAEvC,MAAa,sBAAsB;AACnC,MAAa,qBAAqB;;AAGlC,MAAa,cAAc,UACzB,MAAM,SAAA,aAA8B,aAAa;AAwFnD,MAAa,kBAAA,GAAA,eAAA,sBAAA,CAA4D,WAAW"}