@signiphi/pdf-signer 0.1.1

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 (192) hide show
  1. package/INSTALLING_LOCALLY.md +184 -0
  2. package/LICENSE +2 -0
  3. package/README.md +1093 -0
  4. package/assets/viewer.html +314 -0
  5. package/dist/__tests__/helpers/fixtures.d.ts +43 -0
  6. package/dist/__tests__/helpers/fixtures.d.ts.map +1 -0
  7. package/dist/__tests__/helpers/mocks.d.ts +333 -0
  8. package/dist/__tests__/helpers/mocks.d.ts.map +1 -0
  9. package/dist/__tests__/setup.d.ts +6 -0
  10. package/dist/__tests__/setup.d.ts.map +1 -0
  11. package/dist/components/AttachmentUpload.d.ts +17 -0
  12. package/dist/components/AttachmentUpload.d.ts.map +1 -0
  13. package/dist/components/EditableFieldsPanel.d.ts +30 -0
  14. package/dist/components/EditableFieldsPanel.d.ts.map +1 -0
  15. package/dist/components/ErrorBoundary.d.ts +67 -0
  16. package/dist/components/ErrorBoundary.d.ts.map +1 -0
  17. package/dist/components/FormFieldsView.d.ts +42 -0
  18. package/dist/components/FormFieldsView.d.ts.map +1 -0
  19. package/dist/components/PdfViewerStyled.d.ts +16 -0
  20. package/dist/components/PdfViewerStyled.d.ts.map +1 -0
  21. package/dist/components/PoweredBySigniphi.d.ts +11 -0
  22. package/dist/components/PoweredBySigniphi.d.ts.map +1 -0
  23. package/dist/components/SignatureCanvas.d.ts +12 -0
  24. package/dist/components/SignatureCanvas.d.ts.map +1 -0
  25. package/dist/components/SignatureInitialsBox.d.ts +23 -0
  26. package/dist/components/SignatureInitialsBox.d.ts.map +1 -0
  27. package/dist/components/SignatureModal.d.ts +22 -0
  28. package/dist/components/SignatureModal.d.ts.map +1 -0
  29. package/dist/components/SigningInstructions.d.ts +12 -0
  30. package/dist/components/SigningInstructions.d.ts.map +1 -0
  31. package/dist/components/SubmissionForm.d.ts +52 -0
  32. package/dist/components/SubmissionForm.d.ts.map +1 -0
  33. package/dist/components/ViewToggleToolbar.d.ts +30 -0
  34. package/dist/components/ViewToggleToolbar.d.ts.map +1 -0
  35. package/dist/components/form-fields/CheckboxRenderer.d.ts +10 -0
  36. package/dist/components/form-fields/CheckboxRenderer.d.ts.map +1 -0
  37. package/dist/components/form-fields/DateFieldRenderer.d.ts +14 -0
  38. package/dist/components/form-fields/DateFieldRenderer.d.ts.map +1 -0
  39. package/dist/components/form-fields/DropdownRenderer.d.ts +14 -0
  40. package/dist/components/form-fields/DropdownRenderer.d.ts.map +1 -0
  41. package/dist/components/form-fields/FormFieldRenderer.d.ts +20 -0
  42. package/dist/components/form-fields/FormFieldRenderer.d.ts.map +1 -0
  43. package/dist/components/form-fields/InitialsFieldRenderer.d.ts +14 -0
  44. package/dist/components/form-fields/InitialsFieldRenderer.d.ts.map +1 -0
  45. package/dist/components/form-fields/RadioGroupRenderer.d.ts +10 -0
  46. package/dist/components/form-fields/RadioGroupRenderer.d.ts.map +1 -0
  47. package/dist/components/form-fields/SignatureFieldRenderer.d.ts +16 -0
  48. package/dist/components/form-fields/SignatureFieldRenderer.d.ts.map +1 -0
  49. package/dist/components/form-fields/TextFieldRenderer.d.ts +14 -0
  50. package/dist/components/form-fields/TextFieldRenderer.d.ts.map +1 -0
  51. package/dist/components/form-fields/TextLabelRenderer.d.ts +14 -0
  52. package/dist/components/form-fields/TextLabelRenderer.d.ts.map +1 -0
  53. package/dist/components/form-fields/index.d.ts +14 -0
  54. package/dist/components/form-fields/index.d.ts.map +1 -0
  55. package/dist/components/index.d.ts +14 -0
  56. package/dist/components/index.d.ts.map +1 -0
  57. package/dist/components/index.js +6297 -0
  58. package/dist/components/index.js.map +1 -0
  59. package/dist/components/index.mjs +6248 -0
  60. package/dist/components/index.mjs.map +1 -0
  61. package/dist/core/PdfViewerCore.d.ts +19 -0
  62. package/dist/core/PdfViewerCore.d.ts.map +1 -0
  63. package/dist/core/SignatureCaptureCore.d.ts +37 -0
  64. package/dist/core/SignatureCaptureCore.d.ts.map +1 -0
  65. package/dist/core/index.d.ts +3 -0
  66. package/dist/core/index.d.ts.map +1 -0
  67. package/dist/core/index.js +907 -0
  68. package/dist/core/index.js.map +1 -0
  69. package/dist/core/index.mjs +884 -0
  70. package/dist/core/index.mjs.map +1 -0
  71. package/dist/hooks/index.d.ts +8 -0
  72. package/dist/hooks/index.d.ts.map +1 -0
  73. package/dist/hooks/index.js +2167 -0
  74. package/dist/hooks/index.js.map +1 -0
  75. package/dist/hooks/index.mjs +2139 -0
  76. package/dist/hooks/index.mjs.map +1 -0
  77. package/dist/hooks/useAttachments.d.ts +25 -0
  78. package/dist/hooks/useAttachments.d.ts.map +1 -0
  79. package/dist/hooks/useFieldFiltering.d.ts +29 -0
  80. package/dist/hooks/useFieldFiltering.d.ts.map +1 -0
  81. package/dist/hooks/useFormFields.d.ts +23 -0
  82. package/dist/hooks/useFormFields.d.ts.map +1 -0
  83. package/dist/hooks/useMultiSignerContext.d.ts +25 -0
  84. package/dist/hooks/useMultiSignerContext.d.ts.map +1 -0
  85. package/dist/hooks/usePdfViewer.d.ts +52 -0
  86. package/dist/hooks/usePdfViewer.d.ts.map +1 -0
  87. package/dist/hooks/useSignatureCapture.d.ts +17 -0
  88. package/dist/hooks/useSignatureCapture.d.ts.map +1 -0
  89. package/dist/hooks/useSignatures.d.ts +25 -0
  90. package/dist/hooks/useSignatures.d.ts.map +1 -0
  91. package/dist/index.css +4929 -0
  92. package/dist/index.css.map +1 -0
  93. package/dist/index.d.ts +17 -0
  94. package/dist/index.d.ts.map +1 -0
  95. package/dist/index.js +7220 -0
  96. package/dist/index.js.map +1 -0
  97. package/dist/index.mjs +7093 -0
  98. package/dist/index.mjs.map +1 -0
  99. package/dist/integrations/index.d.ts +6 -0
  100. package/dist/integrations/index.d.ts.map +1 -0
  101. package/dist/integrations/index.js +242 -0
  102. package/dist/integrations/index.js.map +1 -0
  103. package/dist/integrations/index.mjs +218 -0
  104. package/dist/integrations/index.mjs.map +1 -0
  105. package/dist/integrations/next-config.d.ts +46 -0
  106. package/dist/integrations/next-config.d.ts.map +1 -0
  107. package/dist/integrations/vite-plugin.d.ts +48 -0
  108. package/dist/integrations/vite-plugin.d.ts.map +1 -0
  109. package/dist/lib/index.d.ts +3 -0
  110. package/dist/lib/index.d.ts.map +1 -0
  111. package/dist/lib/ui/alert.d.ts +9 -0
  112. package/dist/lib/ui/alert.d.ts.map +1 -0
  113. package/dist/lib/ui/button.d.ts +12 -0
  114. package/dist/lib/ui/button.d.ts.map +1 -0
  115. package/dist/lib/ui/calendar.d.ts +10 -0
  116. package/dist/lib/ui/calendar.d.ts.map +1 -0
  117. package/dist/lib/ui/card.d.ts +9 -0
  118. package/dist/lib/ui/card.d.ts.map +1 -0
  119. package/dist/lib/ui/checkbox.d.ts +5 -0
  120. package/dist/lib/ui/checkbox.d.ts.map +1 -0
  121. package/dist/lib/ui/dialog.d.ts +20 -0
  122. package/dist/lib/ui/dialog.d.ts.map +1 -0
  123. package/dist/lib/ui/index.d.ts +12 -0
  124. package/dist/lib/ui/index.d.ts.map +1 -0
  125. package/dist/lib/ui/input.d.ts +6 -0
  126. package/dist/lib/ui/input.d.ts.map +1 -0
  127. package/dist/lib/ui/label.d.ts +6 -0
  128. package/dist/lib/ui/label.d.ts.map +1 -0
  129. package/dist/lib/ui/popover.d.ts +7 -0
  130. package/dist/lib/ui/popover.d.ts.map +1 -0
  131. package/dist/lib/ui/radio-group.d.ts +6 -0
  132. package/dist/lib/ui/radio-group.d.ts.map +1 -0
  133. package/dist/lib/ui/select.d.ts +14 -0
  134. package/dist/lib/ui/select.d.ts.map +1 -0
  135. package/dist/lib/utils.d.ts +7 -0
  136. package/dist/lib/utils.d.ts.map +1 -0
  137. package/dist/styles/index.css +5004 -0
  138. package/dist/types/index.d.ts +265 -0
  139. package/dist/types/index.d.ts.map +1 -0
  140. package/dist/types/index.js +26 -0
  141. package/dist/types/index.js.map +1 -0
  142. package/dist/types/index.mjs +23 -0
  143. package/dist/types/index.mjs.map +1 -0
  144. package/dist/utils/attachment-validators.d.ts +118 -0
  145. package/dist/utils/attachment-validators.d.ts.map +1 -0
  146. package/dist/utils/audit-trail.d.ts +27 -0
  147. package/dist/utils/audit-trail.d.ts.map +1 -0
  148. package/dist/utils/date-validation.d.ts +30 -0
  149. package/dist/utils/date-validation.d.ts.map +1 -0
  150. package/dist/utils/errors.d.ts +106 -0
  151. package/dist/utils/errors.d.ts.map +1 -0
  152. package/dist/utils/field-extraction.d.ts +27 -0
  153. package/dist/utils/field-extraction.d.ts.map +1 -0
  154. package/dist/utils/field-visibility.d.ts +104 -0
  155. package/dist/utils/field-visibility.d.ts.map +1 -0
  156. package/dist/utils/index.d.ts +17 -0
  157. package/dist/utils/index.d.ts.map +1 -0
  158. package/dist/utils/index.js +2501 -0
  159. package/dist/utils/index.js.map +1 -0
  160. package/dist/utils/index.mjs +2404 -0
  161. package/dist/utils/index.mjs.map +1 -0
  162. package/dist/utils/logger.d.ts +16 -0
  163. package/dist/utils/logger.d.ts.map +1 -0
  164. package/dist/utils/pdf-field-type-helpers.d.ts +78 -0
  165. package/dist/utils/pdf-field-type-helpers.d.ts.map +1 -0
  166. package/dist/utils/pdf-helpers.d.ts +38 -0
  167. package/dist/utils/pdf-helpers.d.ts.map +1 -0
  168. package/dist/utils/pdf-lib-loader.d.ts +45 -0
  169. package/dist/utils/pdf-lib-loader.d.ts.map +1 -0
  170. package/dist/utils/pdf-manipulation.d.ts +93 -0
  171. package/dist/utils/pdf-manipulation.d.ts.map +1 -0
  172. package/dist/utils/pdf-validators.d.ts +149 -0
  173. package/dist/utils/pdf-validators.d.ts.map +1 -0
  174. package/dist/utils/pdf-viewer-filter.d.ts +35 -0
  175. package/dist/utils/pdf-viewer-filter.d.ts.map +1 -0
  176. package/dist/utils/pdf-widget-helpers.d.ts +98 -0
  177. package/dist/utils/pdf-widget-helpers.d.ts.map +1 -0
  178. package/dist/utils/pdfjs-config.d.ts +56 -0
  179. package/dist/utils/pdfjs-config.d.ts.map +1 -0
  180. package/dist/utils/pdfjs-version-check.d.ts +28 -0
  181. package/dist/utils/pdfjs-version-check.d.ts.map +1 -0
  182. package/dist/utils/performance-monitor.d.ts +172 -0
  183. package/dist/utils/performance-monitor.d.ts.map +1 -0
  184. package/dist/utils/tracking.d.ts +89 -0
  185. package/dist/utils/tracking.d.ts.map +1 -0
  186. package/package.json +180 -0
  187. package/scripts/analyze-bundle.js +271 -0
  188. package/scripts/copy-utils.js +227 -0
  189. package/scripts/copy-utils.test.js +164 -0
  190. package/scripts/postinstall.js +109 -0
  191. package/scripts/setup.js +108 -0
  192. package/src/styles/index.css +139 -0
@@ -0,0 +1,27 @@
1
+ /**
2
+ * PDF Form Field Extraction Utilities
3
+ * Functions for extracting and decoding form fields from PDFs
4
+ */
5
+ import { EsignFormField, FormFieldType } from '../types';
6
+ /**
7
+ * Extract visible form fields from a PDF document
8
+ * @param pdfBytes - The PDF bytes to extract fields from
9
+ * @param currentSignerEmail - Optional email of the current signer (for multi-signer filtering)
10
+ * @returns Array of extracted form fields
11
+ */
12
+ export declare function extractVisibleFormFields(pdfBytes: Uint8Array, currentSignerEmail?: string): Promise<EsignFormField[]>;
13
+ /**
14
+ * Decode a field name to extract label, signer email, and placeholder
15
+ * Format: fieldName__LABEL__labelText__SIGNER__email__PLACEHOLDER__placeholderText
16
+ */
17
+ export declare function decodeFieldName(fieldName: string): {
18
+ decodedFieldName: string;
19
+ displayLabel: string;
20
+ assignedSignerEmail?: string;
21
+ fieldPlaceholder: string;
22
+ };
23
+ /**
24
+ * Generate a fallback label from a decoded field name
25
+ */
26
+ export declare function generateFallbackLabel(decodedFieldName: string, fieldType: FormFieldType): string;
27
+ //# sourceMappingURL=field-extraction.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"field-extraction.d.ts","sourceRoot":"","sources":["../../src/utils/field-extraction.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAuBzD;;;;;GAKG;AACH,wBAAsB,wBAAwB,CAC5C,QAAQ,EAAE,UAAU,EACpB,kBAAkB,CAAC,EAAE,MAAM,GAC1B,OAAO,CAAC,cAAc,EAAE,CAAC,CAmL3B;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,SAAS,EAAE,MAAM,GAAG;IAClD,gBAAgB,EAAE,MAAM,CAAC;IACzB,YAAY,EAAE,MAAM,CAAC;IACrB,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,gBAAgB,EAAE,MAAM,CAAC;CAC1B,CA8DA;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,gBAAgB,EAAE,MAAM,EAAE,SAAS,EAAE,aAAa,GAAG,MAAM,CAgChG"}
@@ -0,0 +1,104 @@
1
+ /**
2
+ * Field Visibility Utilities
3
+ * Core logic for determining which fields are visible/editable in multi-signer mode
4
+ *
5
+ * CRITICAL: This logic must work identically in both flows:
6
+ * - Single-signer flow: isMultiSigner = false, all fields visible
7
+ * - Multi-signer flow: isMultiSigner = true, filtered by assignment rules
8
+ */
9
+ import type { EsignFormField, MultiSignerContext } from '../types';
10
+ /**
11
+ * Determine if a field should be visible to the current signer
12
+ *
13
+ * Implements the 5-rule visibility logic used throughout the application:
14
+ * - Rule 1: Unassigned fields → only final signer sees them
15
+ * - Rule 2: Direct assignment → show if assigned to current signer
16
+ * - Rule 3: Recipients group → only primary signers (signOrder === 1)
17
+ * - Rule 4: Signers group → only final signer
18
+ * - Rule 5: Assigned to different signer → hide
19
+ *
20
+ * @param field - The form field to check
21
+ * @param multiSignerContext - Multi-signer context with current signer info
22
+ * @returns true if field should be visible, false if hidden
23
+ *
24
+ * @example Single-signer flow
25
+ * ```ts
26
+ * const context = { isMultiSigner: false, ... };
27
+ * isFieldVisibleToSigner(anyField, context); // always returns true
28
+ * ```
29
+ *
30
+ * @example Multi-signer flow
31
+ * ```ts
32
+ * const context = {
33
+ * isMultiSigner: true,
34
+ * currentSignerEmail: 'signer1@example.com',
35
+ * isPrimarySigner: true,
36
+ * isFinalSigner: false
37
+ * };
38
+ *
39
+ * // Unassigned field - only final signer sees it
40
+ * isFieldVisibleToSigner({ assignedSignerEmail: undefined, ... }, context); // false
41
+ *
42
+ * // Direct assignment to current signer
43
+ * isFieldVisibleToSigner({ assignedSignerEmail: 'signer1@example.com', ... }, context); // true
44
+ *
45
+ * // Recipients group - primary signer sees it
46
+ * isFieldVisibleToSigner({ assignedSignerEmail: 'recipients', ... }, context); // true
47
+ * ```
48
+ */
49
+ export declare function isFieldVisibleToSigner(field: EsignFormField, multiSignerContext: MultiSignerContext): boolean;
50
+ /**
51
+ * Filter an array of fields to only those visible to the current signer
52
+ *
53
+ * @param fields - All form fields
54
+ * @param multiSignerContext - Multi-signer context
55
+ * @returns Filtered array of visible fields
56
+ *
57
+ * @example
58
+ * ```ts
59
+ * const allFields = [...]; // 10 fields
60
+ * const context = { isMultiSigner: true, isPrimarySigner: true, ... };
61
+ * const visible = filterFieldsBySigner(allFields, context); // 5 fields (only primary signer's)
62
+ * ```
63
+ */
64
+ export declare function filterFieldsBySigner(fields: EsignFormField[], multiSignerContext: MultiSignerContext): EsignFormField[];
65
+ /**
66
+ * Determine if a field should be flattened (made non-editable) by the current signer
67
+ *
68
+ * Used during PDF submission to determine which fields to flatten.
69
+ * In multi-signer mode, only flatten fields assigned to current signer.
70
+ * In single-signer mode, flatten all fields.
71
+ *
72
+ * CRITICAL: This affects PDF flattening behavior - must preserve exact logic!
73
+ *
74
+ * @param field - The form field to check
75
+ * @param multiSignerContext - Multi-signer context
76
+ * @returns true if current signer should flatten this field
77
+ *
78
+ * @example Single-signer flow
79
+ * ```ts
80
+ * const context = { isMultiSigner: false, ... };
81
+ * shouldFlattenField(anyField, context); // always returns true
82
+ * ```
83
+ *
84
+ * @example Multi-signer flow
85
+ * ```ts
86
+ * const context = {
87
+ * isMultiSigner: true,
88
+ * currentSignerEmail: 'signer1@example.com',
89
+ * isPrimarySigner: true,
90
+ * isFinalSigner: false
91
+ * };
92
+ *
93
+ * // Current signer's field - flatten it
94
+ * shouldFlattenField({ assignedSignerEmail: 'signer1@example.com', ... }, context); // true
95
+ *
96
+ * // Different signer's field - don't flatten (keep editable for them)
97
+ * shouldFlattenField({ assignedSignerEmail: 'signer2@example.com', ... }, context); // false
98
+ *
99
+ * // Unassigned field - only final signer flattens
100
+ * shouldFlattenField({ assignedSignerEmail: undefined, ... }, context); // false (not final)
101
+ * ```
102
+ */
103
+ export declare function shouldFlattenField(field: EsignFormField, multiSignerContext: MultiSignerContext): boolean;
104
+ //# sourceMappingURL=field-visibility.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"field-visibility.d.ts","sourceRoot":"","sources":["../../src/utils/field-visibility.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAEnE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,wBAAgB,sBAAsB,CACpC,KAAK,EAAE,cAAc,EACrB,kBAAkB,EAAE,kBAAkB,GACrC,OAAO,CA8BT;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,cAAc,EAAE,EACxB,kBAAkB,EAAE,kBAAkB,GACrC,cAAc,EAAE,CAQlB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH,wBAAgB,kBAAkB,CAChC,KAAK,EAAE,cAAc,EACrB,kBAAkB,EAAE,kBAAkB,GACrC,OAAO,CA8BT"}
@@ -0,0 +1,17 @@
1
+ export * from './pdf-helpers';
2
+ export * from './pdf-manipulation';
3
+ export * from './field-extraction';
4
+ export * from './pdfjs-config';
5
+ export * from './pdfjs-version-check';
6
+ export * from './audit-trail';
7
+ export * from './pdf-validators';
8
+ export * from './field-visibility';
9
+ export * from './pdf-widget-helpers';
10
+ export * from './pdf-field-type-helpers';
11
+ export * from './errors';
12
+ export * from './attachment-validators';
13
+ export { logger } from './logger';
14
+ export * from './performance-monitor';
15
+ export * from './date-validation';
16
+ export * from './tracking';
17
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,uBAAuB,CAAC;AACtC,cAAc,eAAe,CAAC;AAC9B,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,sBAAsB,CAAC;AACrC,cAAc,0BAA0B,CAAC;AACzC,cAAc,UAAU,CAAC;AACzB,cAAc,yBAAyB,CAAC;AACxC,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,cAAc,uBAAuB,CAAC;AACtC,cAAc,mBAAmB,CAAC;AAClC,cAAc,YAAY,CAAC"}