@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.
- package/INSTALLING_LOCALLY.md +184 -0
- package/LICENSE +2 -0
- package/README.md +1093 -0
- package/assets/viewer.html +314 -0
- package/dist/__tests__/helpers/fixtures.d.ts +43 -0
- package/dist/__tests__/helpers/fixtures.d.ts.map +1 -0
- package/dist/__tests__/helpers/mocks.d.ts +333 -0
- package/dist/__tests__/helpers/mocks.d.ts.map +1 -0
- package/dist/__tests__/setup.d.ts +6 -0
- package/dist/__tests__/setup.d.ts.map +1 -0
- package/dist/components/AttachmentUpload.d.ts +17 -0
- package/dist/components/AttachmentUpload.d.ts.map +1 -0
- package/dist/components/EditableFieldsPanel.d.ts +30 -0
- package/dist/components/EditableFieldsPanel.d.ts.map +1 -0
- package/dist/components/ErrorBoundary.d.ts +67 -0
- package/dist/components/ErrorBoundary.d.ts.map +1 -0
- package/dist/components/FormFieldsView.d.ts +42 -0
- package/dist/components/FormFieldsView.d.ts.map +1 -0
- package/dist/components/PdfViewerStyled.d.ts +16 -0
- package/dist/components/PdfViewerStyled.d.ts.map +1 -0
- package/dist/components/PoweredBySigniphi.d.ts +11 -0
- package/dist/components/PoweredBySigniphi.d.ts.map +1 -0
- package/dist/components/SignatureCanvas.d.ts +12 -0
- package/dist/components/SignatureCanvas.d.ts.map +1 -0
- package/dist/components/SignatureInitialsBox.d.ts +23 -0
- package/dist/components/SignatureInitialsBox.d.ts.map +1 -0
- package/dist/components/SignatureModal.d.ts +22 -0
- package/dist/components/SignatureModal.d.ts.map +1 -0
- package/dist/components/SigningInstructions.d.ts +12 -0
- package/dist/components/SigningInstructions.d.ts.map +1 -0
- package/dist/components/SubmissionForm.d.ts +52 -0
- package/dist/components/SubmissionForm.d.ts.map +1 -0
- package/dist/components/ViewToggleToolbar.d.ts +30 -0
- package/dist/components/ViewToggleToolbar.d.ts.map +1 -0
- package/dist/components/form-fields/CheckboxRenderer.d.ts +10 -0
- package/dist/components/form-fields/CheckboxRenderer.d.ts.map +1 -0
- package/dist/components/form-fields/DateFieldRenderer.d.ts +14 -0
- package/dist/components/form-fields/DateFieldRenderer.d.ts.map +1 -0
- package/dist/components/form-fields/DropdownRenderer.d.ts +14 -0
- package/dist/components/form-fields/DropdownRenderer.d.ts.map +1 -0
- package/dist/components/form-fields/FormFieldRenderer.d.ts +20 -0
- package/dist/components/form-fields/FormFieldRenderer.d.ts.map +1 -0
- package/dist/components/form-fields/InitialsFieldRenderer.d.ts +14 -0
- package/dist/components/form-fields/InitialsFieldRenderer.d.ts.map +1 -0
- package/dist/components/form-fields/RadioGroupRenderer.d.ts +10 -0
- package/dist/components/form-fields/RadioGroupRenderer.d.ts.map +1 -0
- package/dist/components/form-fields/SignatureFieldRenderer.d.ts +16 -0
- package/dist/components/form-fields/SignatureFieldRenderer.d.ts.map +1 -0
- package/dist/components/form-fields/TextFieldRenderer.d.ts +14 -0
- package/dist/components/form-fields/TextFieldRenderer.d.ts.map +1 -0
- package/dist/components/form-fields/TextLabelRenderer.d.ts +14 -0
- package/dist/components/form-fields/TextLabelRenderer.d.ts.map +1 -0
- package/dist/components/form-fields/index.d.ts +14 -0
- package/dist/components/form-fields/index.d.ts.map +1 -0
- package/dist/components/index.d.ts +14 -0
- package/dist/components/index.d.ts.map +1 -0
- package/dist/components/index.js +6297 -0
- package/dist/components/index.js.map +1 -0
- package/dist/components/index.mjs +6248 -0
- package/dist/components/index.mjs.map +1 -0
- package/dist/core/PdfViewerCore.d.ts +19 -0
- package/dist/core/PdfViewerCore.d.ts.map +1 -0
- package/dist/core/SignatureCaptureCore.d.ts +37 -0
- package/dist/core/SignatureCaptureCore.d.ts.map +1 -0
- package/dist/core/index.d.ts +3 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/index.js +907 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/index.mjs +884 -0
- package/dist/core/index.mjs.map +1 -0
- package/dist/hooks/index.d.ts +8 -0
- package/dist/hooks/index.d.ts.map +1 -0
- package/dist/hooks/index.js +2167 -0
- package/dist/hooks/index.js.map +1 -0
- package/dist/hooks/index.mjs +2139 -0
- package/dist/hooks/index.mjs.map +1 -0
- package/dist/hooks/useAttachments.d.ts +25 -0
- package/dist/hooks/useAttachments.d.ts.map +1 -0
- package/dist/hooks/useFieldFiltering.d.ts +29 -0
- package/dist/hooks/useFieldFiltering.d.ts.map +1 -0
- package/dist/hooks/useFormFields.d.ts +23 -0
- package/dist/hooks/useFormFields.d.ts.map +1 -0
- package/dist/hooks/useMultiSignerContext.d.ts +25 -0
- package/dist/hooks/useMultiSignerContext.d.ts.map +1 -0
- package/dist/hooks/usePdfViewer.d.ts +52 -0
- package/dist/hooks/usePdfViewer.d.ts.map +1 -0
- package/dist/hooks/useSignatureCapture.d.ts +17 -0
- package/dist/hooks/useSignatureCapture.d.ts.map +1 -0
- package/dist/hooks/useSignatures.d.ts +25 -0
- package/dist/hooks/useSignatures.d.ts.map +1 -0
- package/dist/index.css +4929 -0
- package/dist/index.css.map +1 -0
- package/dist/index.d.ts +17 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +7220 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +7093 -0
- package/dist/index.mjs.map +1 -0
- package/dist/integrations/index.d.ts +6 -0
- package/dist/integrations/index.d.ts.map +1 -0
- package/dist/integrations/index.js +242 -0
- package/dist/integrations/index.js.map +1 -0
- package/dist/integrations/index.mjs +218 -0
- package/dist/integrations/index.mjs.map +1 -0
- package/dist/integrations/next-config.d.ts +46 -0
- package/dist/integrations/next-config.d.ts.map +1 -0
- package/dist/integrations/vite-plugin.d.ts +48 -0
- package/dist/integrations/vite-plugin.d.ts.map +1 -0
- package/dist/lib/index.d.ts +3 -0
- package/dist/lib/index.d.ts.map +1 -0
- package/dist/lib/ui/alert.d.ts +9 -0
- package/dist/lib/ui/alert.d.ts.map +1 -0
- package/dist/lib/ui/button.d.ts +12 -0
- package/dist/lib/ui/button.d.ts.map +1 -0
- package/dist/lib/ui/calendar.d.ts +10 -0
- package/dist/lib/ui/calendar.d.ts.map +1 -0
- package/dist/lib/ui/card.d.ts +9 -0
- package/dist/lib/ui/card.d.ts.map +1 -0
- package/dist/lib/ui/checkbox.d.ts +5 -0
- package/dist/lib/ui/checkbox.d.ts.map +1 -0
- package/dist/lib/ui/dialog.d.ts +20 -0
- package/dist/lib/ui/dialog.d.ts.map +1 -0
- package/dist/lib/ui/index.d.ts +12 -0
- package/dist/lib/ui/index.d.ts.map +1 -0
- package/dist/lib/ui/input.d.ts +6 -0
- package/dist/lib/ui/input.d.ts.map +1 -0
- package/dist/lib/ui/label.d.ts +6 -0
- package/dist/lib/ui/label.d.ts.map +1 -0
- package/dist/lib/ui/popover.d.ts +7 -0
- package/dist/lib/ui/popover.d.ts.map +1 -0
- package/dist/lib/ui/radio-group.d.ts +6 -0
- package/dist/lib/ui/radio-group.d.ts.map +1 -0
- package/dist/lib/ui/select.d.ts +14 -0
- package/dist/lib/ui/select.d.ts.map +1 -0
- package/dist/lib/utils.d.ts +7 -0
- package/dist/lib/utils.d.ts.map +1 -0
- package/dist/styles/index.css +5004 -0
- package/dist/types/index.d.ts +265 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +26 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/index.mjs +23 -0
- package/dist/types/index.mjs.map +1 -0
- package/dist/utils/attachment-validators.d.ts +118 -0
- package/dist/utils/attachment-validators.d.ts.map +1 -0
- package/dist/utils/audit-trail.d.ts +27 -0
- package/dist/utils/audit-trail.d.ts.map +1 -0
- package/dist/utils/date-validation.d.ts +30 -0
- package/dist/utils/date-validation.d.ts.map +1 -0
- package/dist/utils/errors.d.ts +106 -0
- package/dist/utils/errors.d.ts.map +1 -0
- package/dist/utils/field-extraction.d.ts +27 -0
- package/dist/utils/field-extraction.d.ts.map +1 -0
- package/dist/utils/field-visibility.d.ts +104 -0
- package/dist/utils/field-visibility.d.ts.map +1 -0
- package/dist/utils/index.d.ts +17 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +2501 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/index.mjs +2404 -0
- package/dist/utils/index.mjs.map +1 -0
- package/dist/utils/logger.d.ts +16 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/pdf-field-type-helpers.d.ts +78 -0
- package/dist/utils/pdf-field-type-helpers.d.ts.map +1 -0
- package/dist/utils/pdf-helpers.d.ts +38 -0
- package/dist/utils/pdf-helpers.d.ts.map +1 -0
- package/dist/utils/pdf-lib-loader.d.ts +45 -0
- package/dist/utils/pdf-lib-loader.d.ts.map +1 -0
- package/dist/utils/pdf-manipulation.d.ts +93 -0
- package/dist/utils/pdf-manipulation.d.ts.map +1 -0
- package/dist/utils/pdf-validators.d.ts +149 -0
- package/dist/utils/pdf-validators.d.ts.map +1 -0
- package/dist/utils/pdf-viewer-filter.d.ts +35 -0
- package/dist/utils/pdf-viewer-filter.d.ts.map +1 -0
- package/dist/utils/pdf-widget-helpers.d.ts +98 -0
- package/dist/utils/pdf-widget-helpers.d.ts.map +1 -0
- package/dist/utils/pdfjs-config.d.ts +56 -0
- package/dist/utils/pdfjs-config.d.ts.map +1 -0
- package/dist/utils/pdfjs-version-check.d.ts +28 -0
- package/dist/utils/pdfjs-version-check.d.ts.map +1 -0
- package/dist/utils/performance-monitor.d.ts +172 -0
- package/dist/utils/performance-monitor.d.ts.map +1 -0
- package/dist/utils/tracking.d.ts +89 -0
- package/dist/utils/tracking.d.ts.map +1 -0
- package/package.json +180 -0
- package/scripts/analyze-bundle.js +271 -0
- package/scripts/copy-utils.js +227 -0
- package/scripts/copy-utils.test.js +164 -0
- package/scripts/postinstall.js +109 -0
- package/scripts/setup.js +108 -0
- package/src/styles/index.css +139 -0
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Form field types supported by the PDF signer
|
|
3
|
+
*/
|
|
4
|
+
export declare enum FormFieldType {
|
|
5
|
+
TEXT = "text",
|
|
6
|
+
SIGNATURE = "signature",
|
|
7
|
+
INITIALS = "initials",
|
|
8
|
+
DATE = "date",
|
|
9
|
+
CHECKBOX = "checkbox",
|
|
10
|
+
RADIO = "radio",
|
|
11
|
+
DROPDOWN = "dropdown",
|
|
12
|
+
TEXT_LABEL = "text_label"
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Position and dimensions of a form field on a PDF page
|
|
16
|
+
*/
|
|
17
|
+
export interface FormFieldPosition {
|
|
18
|
+
x: number;
|
|
19
|
+
y: number;
|
|
20
|
+
width: number;
|
|
21
|
+
height: number;
|
|
22
|
+
page: number;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Form field definition with all properties
|
|
26
|
+
*/
|
|
27
|
+
export interface FormField {
|
|
28
|
+
id: string;
|
|
29
|
+
type: FormFieldType;
|
|
30
|
+
name: string;
|
|
31
|
+
label: string;
|
|
32
|
+
position: FormFieldPosition;
|
|
33
|
+
required: boolean;
|
|
34
|
+
placeholder?: string;
|
|
35
|
+
options?: string[];
|
|
36
|
+
radioPositions?: FormFieldPosition[];
|
|
37
|
+
defaultValue?: string;
|
|
38
|
+
value?: string;
|
|
39
|
+
fontSize?: number;
|
|
40
|
+
multiline?: boolean;
|
|
41
|
+
maxLength?: number;
|
|
42
|
+
assignedSignerEmail?: string;
|
|
43
|
+
assignedSignerRole?: string;
|
|
44
|
+
visibleToOthers?: boolean;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* PDF page information with rendered image
|
|
48
|
+
*/
|
|
49
|
+
export interface PdfPage {
|
|
50
|
+
pageNumber: number;
|
|
51
|
+
width: number;
|
|
52
|
+
height: number;
|
|
53
|
+
imageUrl: string;
|
|
54
|
+
renderWidth?: number;
|
|
55
|
+
renderHeight?: number;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* PDF viewer application interface (for PDF.js integration)
|
|
59
|
+
*/
|
|
60
|
+
export interface PDFViewerApplication {
|
|
61
|
+
initializedPromise?: Promise<void>;
|
|
62
|
+
pdfLoadingTask?: {
|
|
63
|
+
promise: Promise<void>;
|
|
64
|
+
};
|
|
65
|
+
pdfDocument?: {
|
|
66
|
+
annotationStorage?: {
|
|
67
|
+
serializable?: {
|
|
68
|
+
map?: Map<string, unknown>;
|
|
69
|
+
};
|
|
70
|
+
getAll?: () => Record<string, unknown>;
|
|
71
|
+
getValue?: (key: string) => unknown;
|
|
72
|
+
setValue?: (key: string, value: unknown) => void;
|
|
73
|
+
};
|
|
74
|
+
getFieldObjects?: () => Promise<Record<string, unknown[]>>;
|
|
75
|
+
saveDocument?: () => Promise<Uint8Array>;
|
|
76
|
+
getData?: () => Promise<Uint8Array>;
|
|
77
|
+
};
|
|
78
|
+
pdfViewer?: {
|
|
79
|
+
currentPageNumber?: number;
|
|
80
|
+
pagesCount?: number;
|
|
81
|
+
container?: HTMLElement;
|
|
82
|
+
update?: () => void;
|
|
83
|
+
increaseScale?: () => void;
|
|
84
|
+
decreaseScale?: () => void;
|
|
85
|
+
nextPage?: () => void;
|
|
86
|
+
previousPage?: () => void;
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Configuration for PDF.js worker and viewer
|
|
91
|
+
*/
|
|
92
|
+
export interface PdfJsConfig {
|
|
93
|
+
workerSrc?: string;
|
|
94
|
+
viewerBasePath?: string;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Attachment metadata
|
|
98
|
+
*/
|
|
99
|
+
export interface Attachment {
|
|
100
|
+
id: string;
|
|
101
|
+
file: File;
|
|
102
|
+
name: string;
|
|
103
|
+
size: number;
|
|
104
|
+
type: string;
|
|
105
|
+
uploadedAt: Date;
|
|
106
|
+
preview?: string;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Attachment validation constraints
|
|
110
|
+
*/
|
|
111
|
+
export interface AttachmentConstraints {
|
|
112
|
+
maxFileSize: number;
|
|
113
|
+
maxTotalSize: number;
|
|
114
|
+
maxFiles: number;
|
|
115
|
+
allowedTypes: string[];
|
|
116
|
+
allowedExtensions?: string[];
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Attachment validation result
|
|
120
|
+
*/
|
|
121
|
+
export interface AttachmentValidationResult {
|
|
122
|
+
isValid: boolean;
|
|
123
|
+
errors: string[];
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Audit trail metadata for compliance and forensics
|
|
127
|
+
*/
|
|
128
|
+
export interface AuditTrailMetadata {
|
|
129
|
+
userAgent?: string;
|
|
130
|
+
screenResolution?: string;
|
|
131
|
+
timezone?: string;
|
|
132
|
+
language?: string;
|
|
133
|
+
platform?: string;
|
|
134
|
+
ipAddress?: string;
|
|
135
|
+
geolocation?: {
|
|
136
|
+
latitude: number;
|
|
137
|
+
longitude: number;
|
|
138
|
+
accuracy?: number;
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Document metadata for PDF properties
|
|
143
|
+
*/
|
|
144
|
+
export interface DocumentMetadata {
|
|
145
|
+
submissionId?: string;
|
|
146
|
+
documentId?: string;
|
|
147
|
+
author?: string;
|
|
148
|
+
signerEmail?: string;
|
|
149
|
+
signerInitials?: string;
|
|
150
|
+
createdAt?: Date;
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Form submission data
|
|
154
|
+
*/
|
|
155
|
+
export interface SubmissionData {
|
|
156
|
+
formFieldValues: Record<string, string>;
|
|
157
|
+
signatures: Record<string, string>;
|
|
158
|
+
attachments?: Attachment[];
|
|
159
|
+
pdfBytes: Uint8Array;
|
|
160
|
+
auditTrail?: AuditTrailMetadata;
|
|
161
|
+
metadata?: DocumentMetadata;
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Validation error
|
|
165
|
+
*/
|
|
166
|
+
export interface ValidationError {
|
|
167
|
+
field: string;
|
|
168
|
+
message: string;
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* PDF viewer ref methods
|
|
172
|
+
*/
|
|
173
|
+
export interface PdfViewerRef {
|
|
174
|
+
loadPdf: (pdfUrl: string) => Promise<void>;
|
|
175
|
+
getFormFieldValues: () => Promise<Record<string, string>>;
|
|
176
|
+
setFormFieldValues: (values: Record<string, string>) => Promise<void>;
|
|
177
|
+
getAllFieldNames: () => Promise<string[]>;
|
|
178
|
+
saveDocument: () => Promise<Uint8Array | null>;
|
|
179
|
+
getPDFViewerApplication: () => PDFViewerApplication | null;
|
|
180
|
+
injectPlaceholders: (fields: Array<{
|
|
181
|
+
id: string;
|
|
182
|
+
name: string;
|
|
183
|
+
placeholder?: string;
|
|
184
|
+
}>) => void;
|
|
185
|
+
zoomIn: () => Promise<void>;
|
|
186
|
+
zoomOut: () => Promise<void>;
|
|
187
|
+
nextPage: () => Promise<void>;
|
|
188
|
+
previousPage: () => Promise<void>;
|
|
189
|
+
getCurrentPage: () => Promise<number | null>;
|
|
190
|
+
getTotalPages: () => Promise<number | null>;
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* Signature canvas ref methods
|
|
194
|
+
*/
|
|
195
|
+
export interface SignatureCanvasRef {
|
|
196
|
+
clear: () => void;
|
|
197
|
+
getSignatureDataUrl: () => string | null;
|
|
198
|
+
isEmpty: () => boolean;
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* Signer information for multi-signer documents
|
|
202
|
+
*/
|
|
203
|
+
export interface Signer {
|
|
204
|
+
id: string;
|
|
205
|
+
email: string;
|
|
206
|
+
name: string;
|
|
207
|
+
signOrder: number;
|
|
208
|
+
status: 'pending' | 'viewed' | 'signed' | 'declined';
|
|
209
|
+
signedAt?: string;
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* Multi-signer context for determining field visibility and behavior
|
|
213
|
+
* Used internally by hooks and utilities to manage multi-signer logic
|
|
214
|
+
*/
|
|
215
|
+
export interface MultiSignerContext {
|
|
216
|
+
/** Whether this is a multi-signer document */
|
|
217
|
+
isMultiSigner: boolean;
|
|
218
|
+
/** Current signer object (null for single-signer mode) */
|
|
219
|
+
currentSigner: Signer | null;
|
|
220
|
+
/** Current signer's email address */
|
|
221
|
+
currentSignerEmail: string;
|
|
222
|
+
/** Whether current signer is a primary signer (signOrder === 1) */
|
|
223
|
+
isPrimarySigner: boolean;
|
|
224
|
+
/** Whether current signer is the final signer (signOrder === totalSigners) */
|
|
225
|
+
isFinalSigner: boolean;
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* Document submission
|
|
229
|
+
*/
|
|
230
|
+
export interface Submission {
|
|
231
|
+
id: string;
|
|
232
|
+
documentId: string;
|
|
233
|
+
status: 'pending' | 'signed' | 'declined' | 'expired';
|
|
234
|
+
createdAt: string;
|
|
235
|
+
updatedAt: string;
|
|
236
|
+
formFields?: FormField[];
|
|
237
|
+
pdfUrl?: string;
|
|
238
|
+
signedAt?: string;
|
|
239
|
+
declinedAt?: string;
|
|
240
|
+
expiresAt?: string;
|
|
241
|
+
isMultipleSignature?: boolean;
|
|
242
|
+
signers?: Signer[];
|
|
243
|
+
}
|
|
244
|
+
/**
|
|
245
|
+
* Type aliases for compatibility with dm-web-frontend naming conventions
|
|
246
|
+
*/
|
|
247
|
+
export type EsignFormField = FormField;
|
|
248
|
+
export type EsignSigner = Signer;
|
|
249
|
+
/**
|
|
250
|
+
* Submission status enum
|
|
251
|
+
*/
|
|
252
|
+
export declare enum SubmissionStatus {
|
|
253
|
+
PENDING = "pending",
|
|
254
|
+
SIGNED = "signed",
|
|
255
|
+
DECLINED = "declined",
|
|
256
|
+
EXPIRED = "expired"
|
|
257
|
+
}
|
|
258
|
+
/**
|
|
259
|
+
* Field error type for validation
|
|
260
|
+
*/
|
|
261
|
+
export interface FieldError {
|
|
262
|
+
fieldName: string;
|
|
263
|
+
message: string;
|
|
264
|
+
}
|
|
265
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
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U,GAAG,SAAS,CAAC;IACtD,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,SAAS,EAAE,CAAC;IACzB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;CACpB;AAED;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG,SAAS,CAAC;AACvC,MAAM,MAAM,WAAW,GAAG,MAAM,CAAC;AAEjC;;GAEG;AACH,oBAAY,gBAAgB;IAC1B,OAAO,YAAY;IACnB,MAAM,WAAW;IACjB,QAAQ,aAAa;IACrB,OAAO,YAAY;CACpB;AAED;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;CACjB"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// src/types/index.ts
|
|
4
|
+
var FormFieldType = /* @__PURE__ */ ((FormFieldType2) => {
|
|
5
|
+
FormFieldType2["TEXT"] = "text";
|
|
6
|
+
FormFieldType2["SIGNATURE"] = "signature";
|
|
7
|
+
FormFieldType2["INITIALS"] = "initials";
|
|
8
|
+
FormFieldType2["DATE"] = "date";
|
|
9
|
+
FormFieldType2["CHECKBOX"] = "checkbox";
|
|
10
|
+
FormFieldType2["RADIO"] = "radio";
|
|
11
|
+
FormFieldType2["DROPDOWN"] = "dropdown";
|
|
12
|
+
FormFieldType2["TEXT_LABEL"] = "text_label";
|
|
13
|
+
return FormFieldType2;
|
|
14
|
+
})(FormFieldType || {});
|
|
15
|
+
var SubmissionStatus = /* @__PURE__ */ ((SubmissionStatus2) => {
|
|
16
|
+
SubmissionStatus2["PENDING"] = "pending";
|
|
17
|
+
SubmissionStatus2["SIGNED"] = "signed";
|
|
18
|
+
SubmissionStatus2["DECLINED"] = "declined";
|
|
19
|
+
SubmissionStatus2["EXPIRED"] = "expired";
|
|
20
|
+
return SubmissionStatus2;
|
|
21
|
+
})(SubmissionStatus || {});
|
|
22
|
+
|
|
23
|
+
exports.FormFieldType = FormFieldType;
|
|
24
|
+
exports.SubmissionStatus = SubmissionStatus;
|
|
25
|
+
//# sourceMappingURL=index.js.map
|
|
26
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/types/index.ts"],"names":["FormFieldType","SubmissionStatus"],"mappings":";;;AAGO,IAAK,aAAA,qBAAAA,cAAAA,KAAL;AACL,EAAAA,eAAA,MAAA,CAAA,GAAO,MAAA;AACP,EAAAA,eAAA,WAAA,CAAA,GAAY,WAAA;AACZ,EAAAA,eAAA,UAAA,CAAA,GAAW,UAAA;AACX,EAAAA,eAAA,MAAA,CAAA,GAAO,MAAA;AACP,EAAAA,eAAA,UAAA,CAAA,GAAW,UAAA;AACX,EAAAA,eAAA,OAAA,CAAA,GAAQ,OAAA;AACR,EAAAA,eAAA,UAAA,CAAA,GAAW,UAAA;AACX,EAAAA,eAAA,YAAA,CAAA,GAAa,YAAA;AARH,EAAA,OAAAA,cAAAA;AAAA,CAAA,EAAA,aAAA,IAAA,EAAA;AAuQL,IAAK,gBAAA,qBAAAC,iBAAAA,KAAL;AACL,EAAAA,kBAAA,SAAA,CAAA,GAAU,SAAA;AACV,EAAAA,kBAAA,QAAA,CAAA,GAAS,QAAA;AACT,EAAAA,kBAAA,UAAA,CAAA,GAAW,UAAA;AACX,EAAAA,kBAAA,SAAA,CAAA,GAAU,SAAA;AAJA,EAAA,OAAAA,iBAAAA;AAAA,CAAA,EAAA,gBAAA,IAAA,EAAA","file":"index.js","sourcesContent":["/**\r\n * Form field types supported by the PDF signer\r\n */\r\nexport enum FormFieldType {\r\n TEXT = 'text',\r\n SIGNATURE = 'signature',\r\n INITIALS = 'initials',\r\n DATE = 'date',\r\n CHECKBOX = 'checkbox',\r\n RADIO = 'radio',\r\n DROPDOWN = 'dropdown',\r\n TEXT_LABEL = 'text_label',\r\n}\r\n\r\n/**\r\n * Position and dimensions of a form field on a PDF page\r\n */\r\nexport interface FormFieldPosition {\r\n x: number;\r\n y: number;\r\n width: number;\r\n height: number;\r\n page: number; // 1-indexed page number\r\n}\r\n\r\n/**\r\n * Form field definition with all properties\r\n */\r\nexport interface FormField {\r\n id: string;\r\n type: FormFieldType;\r\n name: string;\r\n label: string;\r\n position: FormFieldPosition;\r\n required: boolean;\r\n placeholder?: string;\r\n options?: string[]; // For dropdown/radio fields\r\n radioPositions?: FormFieldPosition[]; // For radio fields with multiple option positions\r\n defaultValue?: string;\r\n value?: string; // For filled values\r\n fontSize?: number; // Font size for text fields (8-72 points)\r\n multiline?: boolean; // Enable multiline text input for text fields\r\n maxLength?: number; // Maximum character length for text fields\r\n\r\n // Multiple signers support\r\n assignedSignerEmail?: string; // Email of the signer this field is assigned to\r\n assignedSignerRole?: string; // Role of the signer (for display purposes)\r\n visibleToOthers?: boolean; // Whether other signers can see this field (default: false)\r\n}\r\n\r\n/**\r\n * PDF page information with rendered image\r\n */\r\nexport interface PdfPage {\r\n pageNumber: number;\r\n width: number;\r\n height: number;\r\n imageUrl: string;\r\n renderWidth?: number; // Rendered image width (for scale calculation)\r\n renderHeight?: number; // Rendered image height (for scale calculation)\r\n}\r\n\r\n/**\r\n * PDF viewer application interface (for PDF.js integration)\r\n */\r\nexport interface PDFViewerApplication {\r\n initializedPromise?: Promise<void>;\r\n pdfLoadingTask?: { promise: Promise<void> };\r\n pdfDocument?: {\r\n annotationStorage?: {\r\n serializable?: {\r\n map?: Map<string, unknown>;\r\n };\r\n getAll?: () => Record<string, unknown>;\r\n getValue?: (key: string) => unknown;\r\n setValue?: (key: string, value: unknown) => void;\r\n };\r\n getFieldObjects?: () => Promise<Record<string, unknown[]>>;\r\n saveDocument?: () => Promise<Uint8Array>;\r\n getData?: () => Promise<Uint8Array>;\r\n };\r\n pdfViewer?: {\r\n currentPageNumber?: number;\r\n pagesCount?: number;\r\n container?: HTMLElement;\r\n update?: () => void;\r\n increaseScale?: () => void;\r\n decreaseScale?: () => void;\r\n nextPage?: () => void;\r\n previousPage?: () => void;\r\n };\r\n}\r\n\r\n/**\r\n * Configuration for PDF.js worker and viewer\r\n */\r\nexport interface PdfJsConfig {\r\n workerSrc?: string;\r\n viewerBasePath?: string; // Base path for PDF.js viewer (defaults to CDN)\r\n}\r\n\r\n/**\r\n * Attachment metadata\r\n */\r\nexport interface Attachment {\r\n id: string;\r\n file: File;\r\n name: string;\r\n size: number;\r\n type: string;\r\n uploadedAt: Date;\r\n preview?: string; // Data URL for image previews\r\n}\r\n\r\n/**\r\n * Attachment validation constraints\r\n */\r\nexport interface AttachmentConstraints {\r\n maxFileSize: number; // in bytes (default: 10MB)\r\n maxTotalSize: number; // in bytes (default: 50MB)\r\n maxFiles: number; // maximum number of files (default: 10)\r\n allowedTypes: string[]; // MIME types (e.g., ['image/*', 'application/pdf'])\r\n allowedExtensions?: string[]; // File extensions (e.g., ['.pdf', '.jpg', '.png'])\r\n}\r\n\r\n/**\r\n * Attachment validation result\r\n */\r\nexport interface AttachmentValidationResult {\r\n isValid: boolean;\r\n errors: string[];\r\n}\r\n\r\n/**\r\n * Audit trail metadata for compliance and forensics\r\n */\r\nexport interface AuditTrailMetadata {\r\n userAgent?: string;\r\n screenResolution?: string;\r\n timezone?: string;\r\n language?: string;\r\n platform?: string;\r\n ipAddress?: string;\r\n geolocation?: {\r\n latitude: number;\r\n longitude: number;\r\n accuracy?: number;\r\n };\r\n}\r\n\r\n/**\r\n * Document metadata for PDF properties\r\n */\r\nexport interface DocumentMetadata {\r\n submissionId?: string;\r\n documentId?: string;\r\n author?: string;\r\n signerEmail?: string;\r\n signerInitials?: string;\r\n createdAt?: Date;\r\n}\r\n\r\n/**\r\n * Form submission data\r\n */\r\nexport interface SubmissionData {\r\n formFieldValues: Record<string, string>;\r\n signatures: Record<string, string>; // Base64 data URLs\r\n attachments?: Attachment[];\r\n pdfBytes: Uint8Array;\r\n auditTrail?: AuditTrailMetadata;\r\n metadata?: DocumentMetadata;\r\n}\r\n\r\n/**\r\n * Validation error\r\n */\r\nexport interface ValidationError {\r\n field: string;\r\n message: string;\r\n}\r\n\r\n/**\r\n * PDF viewer ref methods\r\n */\r\nexport interface PdfViewerRef {\r\n loadPdf: (pdfUrl: string) => Promise<void>;\r\n getFormFieldValues: () => Promise<Record<string, string>>;\r\n setFormFieldValues: (values: Record<string, string>) => Promise<void>;\r\n getAllFieldNames: () => Promise<string[]>;\r\n saveDocument: () => Promise<Uint8Array | null>;\r\n getPDFViewerApplication: () => PDFViewerApplication | null;\r\n injectPlaceholders: (fields: Array<{ id: string; name: string; placeholder?: string }>) => void;\r\n zoomIn: () => Promise<void>;\r\n zoomOut: () => Promise<void>;\r\n nextPage: () => Promise<void>;\r\n previousPage: () => Promise<void>;\r\n getCurrentPage: () => Promise<number | null>;\r\n getTotalPages: () => Promise<number | null>;\r\n}\r\n\r\n/**\r\n * Signature canvas ref methods\r\n */\r\nexport interface SignatureCanvasRef {\r\n clear: () => void;\r\n getSignatureDataUrl: () => string | null;\r\n isEmpty: () => boolean;\r\n}\r\n\r\n/**\r\n * Signer information for multi-signer documents\r\n */\r\nexport interface Signer {\r\n id: string;\r\n email: string;\r\n name: string;\r\n signOrder: number; // 1 = primary, 2+ = secondary\r\n status: 'pending' | 'viewed' | 'signed' | 'declined';\r\n signedAt?: string;\r\n}\r\n\r\n/**\r\n * Multi-signer context for determining field visibility and behavior\r\n * Used internally by hooks and utilities to manage multi-signer logic\r\n */\r\nexport interface MultiSignerContext {\r\n /** Whether this is a multi-signer document */\r\n isMultiSigner: boolean;\r\n /** Current signer object (null for single-signer mode) */\r\n currentSigner: Signer | null;\r\n /** Current signer's email address */\r\n currentSignerEmail: string;\r\n /** Whether current signer is a primary signer (signOrder === 1) */\r\n isPrimarySigner: boolean;\r\n /** Whether current signer is the final signer (signOrder === totalSigners) */\r\n isFinalSigner: boolean;\r\n}\r\n\r\n/**\r\n * Document submission\r\n */\r\nexport interface Submission {\r\n id: string;\r\n documentId: string;\r\n status: 'pending' | 'signed' | 'declined' | 'expired';\r\n createdAt: string;\r\n updatedAt: string;\r\n formFields?: FormField[];\r\n pdfUrl?: string;\r\n signedAt?: string;\r\n declinedAt?: string;\r\n expiresAt?: string;\r\n isMultipleSignature?: boolean;\r\n signers?: Signer[];\r\n}\r\n\r\n/**\r\n * Type aliases for compatibility with dm-web-frontend naming conventions\r\n */\r\nexport type EsignFormField = FormField;\r\nexport type EsignSigner = Signer;\r\n\r\n/**\r\n * Submission status enum\r\n */\r\nexport enum SubmissionStatus {\r\n PENDING = 'pending',\r\n SIGNED = 'signed',\r\n DECLINED = 'declined',\r\n EXPIRED = 'expired',\r\n}\r\n\r\n/**\r\n * Field error type for validation\r\n */\r\nexport interface FieldError {\r\n fieldName: string;\r\n message: string;\r\n}\r\n\r\n"]}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
// src/types/index.ts
|
|
2
|
+
var FormFieldType = /* @__PURE__ */ ((FormFieldType2) => {
|
|
3
|
+
FormFieldType2["TEXT"] = "text";
|
|
4
|
+
FormFieldType2["SIGNATURE"] = "signature";
|
|
5
|
+
FormFieldType2["INITIALS"] = "initials";
|
|
6
|
+
FormFieldType2["DATE"] = "date";
|
|
7
|
+
FormFieldType2["CHECKBOX"] = "checkbox";
|
|
8
|
+
FormFieldType2["RADIO"] = "radio";
|
|
9
|
+
FormFieldType2["DROPDOWN"] = "dropdown";
|
|
10
|
+
FormFieldType2["TEXT_LABEL"] = "text_label";
|
|
11
|
+
return FormFieldType2;
|
|
12
|
+
})(FormFieldType || {});
|
|
13
|
+
var SubmissionStatus = /* @__PURE__ */ ((SubmissionStatus2) => {
|
|
14
|
+
SubmissionStatus2["PENDING"] = "pending";
|
|
15
|
+
SubmissionStatus2["SIGNED"] = "signed";
|
|
16
|
+
SubmissionStatus2["DECLINED"] = "declined";
|
|
17
|
+
SubmissionStatus2["EXPIRED"] = "expired";
|
|
18
|
+
return SubmissionStatus2;
|
|
19
|
+
})(SubmissionStatus || {});
|
|
20
|
+
|
|
21
|
+
export { FormFieldType, SubmissionStatus };
|
|
22
|
+
//# sourceMappingURL=index.mjs.map
|
|
23
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/types/index.ts"],"names":["FormFieldType","SubmissionStatus"],"mappings":";AAGO,IAAK,aAAA,qBAAAA,cAAAA,KAAL;AACL,EAAAA,eAAA,MAAA,CAAA,GAAO,MAAA;AACP,EAAAA,eAAA,WAAA,CAAA,GAAY,WAAA;AACZ,EAAAA,eAAA,UAAA,CAAA,GAAW,UAAA;AACX,EAAAA,eAAA,MAAA,CAAA,GAAO,MAAA;AACP,EAAAA,eAAA,UAAA,CAAA,GAAW,UAAA;AACX,EAAAA,eAAA,OAAA,CAAA,GAAQ,OAAA;AACR,EAAAA,eAAA,UAAA,CAAA,GAAW,UAAA;AACX,EAAAA,eAAA,YAAA,CAAA,GAAa,YAAA;AARH,EAAA,OAAAA,cAAAA;AAAA,CAAA,EAAA,aAAA,IAAA,EAAA;AAuQL,IAAK,gBAAA,qBAAAC,iBAAAA,KAAL;AACL,EAAAA,kBAAA,SAAA,CAAA,GAAU,SAAA;AACV,EAAAA,kBAAA,QAAA,CAAA,GAAS,QAAA;AACT,EAAAA,kBAAA,UAAA,CAAA,GAAW,UAAA;AACX,EAAAA,kBAAA,SAAA,CAAA,GAAU,SAAA;AAJA,EAAA,OAAAA,iBAAAA;AAAA,CAAA,EAAA,gBAAA,IAAA,EAAA","file":"index.mjs","sourcesContent":["/**\r\n * Form field types supported by the PDF signer\r\n */\r\nexport enum FormFieldType {\r\n TEXT = 'text',\r\n SIGNATURE = 'signature',\r\n INITIALS = 'initials',\r\n DATE = 'date',\r\n CHECKBOX = 'checkbox',\r\n RADIO = 'radio',\r\n DROPDOWN = 'dropdown',\r\n TEXT_LABEL = 'text_label',\r\n}\r\n\r\n/**\r\n * Position and dimensions of a form field on a PDF page\r\n */\r\nexport interface FormFieldPosition {\r\n x: number;\r\n y: number;\r\n width: number;\r\n height: number;\r\n page: number; // 1-indexed page number\r\n}\r\n\r\n/**\r\n * Form field definition with all properties\r\n */\r\nexport interface FormField {\r\n id: string;\r\n type: FormFieldType;\r\n name: string;\r\n label: string;\r\n position: FormFieldPosition;\r\n required: boolean;\r\n placeholder?: string;\r\n options?: string[]; // For dropdown/radio fields\r\n radioPositions?: FormFieldPosition[]; // For radio fields with multiple option positions\r\n defaultValue?: string;\r\n value?: string; // For filled values\r\n fontSize?: number; // Font size for text fields (8-72 points)\r\n multiline?: boolean; // Enable multiline text input for text fields\r\n maxLength?: number; // Maximum character length for text fields\r\n\r\n // Multiple signers support\r\n assignedSignerEmail?: string; // Email of the signer this field is assigned to\r\n assignedSignerRole?: string; // Role of the signer (for display purposes)\r\n visibleToOthers?: boolean; // Whether other signers can see this field (default: false)\r\n}\r\n\r\n/**\r\n * PDF page information with rendered image\r\n */\r\nexport interface PdfPage {\r\n pageNumber: number;\r\n width: number;\r\n height: number;\r\n imageUrl: string;\r\n renderWidth?: number; // Rendered image width (for scale calculation)\r\n renderHeight?: number; // Rendered image height (for scale calculation)\r\n}\r\n\r\n/**\r\n * PDF viewer application interface (for PDF.js integration)\r\n */\r\nexport interface PDFViewerApplication {\r\n initializedPromise?: Promise<void>;\r\n pdfLoadingTask?: { promise: Promise<void> };\r\n pdfDocument?: {\r\n annotationStorage?: {\r\n serializable?: {\r\n map?: Map<string, unknown>;\r\n };\r\n getAll?: () => Record<string, unknown>;\r\n getValue?: (key: string) => unknown;\r\n setValue?: (key: string, value: unknown) => void;\r\n };\r\n getFieldObjects?: () => Promise<Record<string, unknown[]>>;\r\n saveDocument?: () => Promise<Uint8Array>;\r\n getData?: () => Promise<Uint8Array>;\r\n };\r\n pdfViewer?: {\r\n currentPageNumber?: number;\r\n pagesCount?: number;\r\n container?: HTMLElement;\r\n update?: () => void;\r\n increaseScale?: () => void;\r\n decreaseScale?: () => void;\r\n nextPage?: () => void;\r\n previousPage?: () => void;\r\n };\r\n}\r\n\r\n/**\r\n * Configuration for PDF.js worker and viewer\r\n */\r\nexport interface PdfJsConfig {\r\n workerSrc?: string;\r\n viewerBasePath?: string; // Base path for PDF.js viewer (defaults to CDN)\r\n}\r\n\r\n/**\r\n * Attachment metadata\r\n */\r\nexport interface Attachment {\r\n id: string;\r\n file: File;\r\n name: string;\r\n size: number;\r\n type: string;\r\n uploadedAt: Date;\r\n preview?: string; // Data URL for image previews\r\n}\r\n\r\n/**\r\n * Attachment validation constraints\r\n */\r\nexport interface AttachmentConstraints {\r\n maxFileSize: number; // in bytes (default: 10MB)\r\n maxTotalSize: number; // in bytes (default: 50MB)\r\n maxFiles: number; // maximum number of files (default: 10)\r\n allowedTypes: string[]; // MIME types (e.g., ['image/*', 'application/pdf'])\r\n allowedExtensions?: string[]; // File extensions (e.g., ['.pdf', '.jpg', '.png'])\r\n}\r\n\r\n/**\r\n * Attachment validation result\r\n */\r\nexport interface AttachmentValidationResult {\r\n isValid: boolean;\r\n errors: string[];\r\n}\r\n\r\n/**\r\n * Audit trail metadata for compliance and forensics\r\n */\r\nexport interface AuditTrailMetadata {\r\n userAgent?: string;\r\n screenResolution?: string;\r\n timezone?: string;\r\n language?: string;\r\n platform?: string;\r\n ipAddress?: string;\r\n geolocation?: {\r\n latitude: number;\r\n longitude: number;\r\n accuracy?: number;\r\n };\r\n}\r\n\r\n/**\r\n * Document metadata for PDF properties\r\n */\r\nexport interface DocumentMetadata {\r\n submissionId?: string;\r\n documentId?: string;\r\n author?: string;\r\n signerEmail?: string;\r\n signerInitials?: string;\r\n createdAt?: Date;\r\n}\r\n\r\n/**\r\n * Form submission data\r\n */\r\nexport interface SubmissionData {\r\n formFieldValues: Record<string, string>;\r\n signatures: Record<string, string>; // Base64 data URLs\r\n attachments?: Attachment[];\r\n pdfBytes: Uint8Array;\r\n auditTrail?: AuditTrailMetadata;\r\n metadata?: DocumentMetadata;\r\n}\r\n\r\n/**\r\n * Validation error\r\n */\r\nexport interface ValidationError {\r\n field: string;\r\n message: string;\r\n}\r\n\r\n/**\r\n * PDF viewer ref methods\r\n */\r\nexport interface PdfViewerRef {\r\n loadPdf: (pdfUrl: string) => Promise<void>;\r\n getFormFieldValues: () => Promise<Record<string, string>>;\r\n setFormFieldValues: (values: Record<string, string>) => Promise<void>;\r\n getAllFieldNames: () => Promise<string[]>;\r\n saveDocument: () => Promise<Uint8Array | null>;\r\n getPDFViewerApplication: () => PDFViewerApplication | null;\r\n injectPlaceholders: (fields: Array<{ id: string; name: string; placeholder?: string }>) => void;\r\n zoomIn: () => Promise<void>;\r\n zoomOut: () => Promise<void>;\r\n nextPage: () => Promise<void>;\r\n previousPage: () => Promise<void>;\r\n getCurrentPage: () => Promise<number | null>;\r\n getTotalPages: () => Promise<number | null>;\r\n}\r\n\r\n/**\r\n * Signature canvas ref methods\r\n */\r\nexport interface SignatureCanvasRef {\r\n clear: () => void;\r\n getSignatureDataUrl: () => string | null;\r\n isEmpty: () => boolean;\r\n}\r\n\r\n/**\r\n * Signer information for multi-signer documents\r\n */\r\nexport interface Signer {\r\n id: string;\r\n email: string;\r\n name: string;\r\n signOrder: number; // 1 = primary, 2+ = secondary\r\n status: 'pending' | 'viewed' | 'signed' | 'declined';\r\n signedAt?: string;\r\n}\r\n\r\n/**\r\n * Multi-signer context for determining field visibility and behavior\r\n * Used internally by hooks and utilities to manage multi-signer logic\r\n */\r\nexport interface MultiSignerContext {\r\n /** Whether this is a multi-signer document */\r\n isMultiSigner: boolean;\r\n /** Current signer object (null for single-signer mode) */\r\n currentSigner: Signer | null;\r\n /** Current signer's email address */\r\n currentSignerEmail: string;\r\n /** Whether current signer is a primary signer (signOrder === 1) */\r\n isPrimarySigner: boolean;\r\n /** Whether current signer is the final signer (signOrder === totalSigners) */\r\n isFinalSigner: boolean;\r\n}\r\n\r\n/**\r\n * Document submission\r\n */\r\nexport interface Submission {\r\n id: string;\r\n documentId: string;\r\n status: 'pending' | 'signed' | 'declined' | 'expired';\r\n createdAt: string;\r\n updatedAt: string;\r\n formFields?: FormField[];\r\n pdfUrl?: string;\r\n signedAt?: string;\r\n declinedAt?: string;\r\n expiresAt?: string;\r\n isMultipleSignature?: boolean;\r\n signers?: Signer[];\r\n}\r\n\r\n/**\r\n * Type aliases for compatibility with dm-web-frontend naming conventions\r\n */\r\nexport type EsignFormField = FormField;\r\nexport type EsignSigner = Signer;\r\n\r\n/**\r\n * Submission status enum\r\n */\r\nexport enum SubmissionStatus {\r\n PENDING = 'pending',\r\n SIGNED = 'signed',\r\n DECLINED = 'declined',\r\n EXPIRED = 'expired',\r\n}\r\n\r\n/**\r\n * Field error type for validation\r\n */\r\nexport interface FieldError {\r\n fieldName: string;\r\n message: string;\r\n}\r\n\r\n"]}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Attachment Validation Utilities
|
|
3
|
+
* Validation functions for file attachments
|
|
4
|
+
*/
|
|
5
|
+
import type { AttachmentConstraints, Attachment } from '../types';
|
|
6
|
+
/**
|
|
7
|
+
* Default attachment constraints
|
|
8
|
+
*/
|
|
9
|
+
export declare const DEFAULT_ATTACHMENT_CONSTRAINTS: AttachmentConstraints;
|
|
10
|
+
/**
|
|
11
|
+
* Validate a single file against constraints
|
|
12
|
+
*
|
|
13
|
+
* @param file - File to validate
|
|
14
|
+
* @param constraints - Validation constraints
|
|
15
|
+
* @returns Validation result with errors array
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```ts
|
|
19
|
+
* const result = validateFile(file, DEFAULT_ATTACHMENT_CONSTRAINTS);
|
|
20
|
+
* if (result.errors.length > 0) {
|
|
21
|
+
* console.error('File validation failed:', result.errors);
|
|
22
|
+
* }
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
export declare function validateFile(file: File, constraints?: AttachmentConstraints): {
|
|
26
|
+
valid: boolean;
|
|
27
|
+
errors: string[];
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* Validate multiple files against constraints
|
|
31
|
+
*
|
|
32
|
+
* @param files - Files to validate
|
|
33
|
+
* @param existingAttachments - Existing attachments to consider for total size/count
|
|
34
|
+
* @param constraints - Validation constraints
|
|
35
|
+
* @returns Validation result with errors array
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* ```ts
|
|
39
|
+
* const result = validateFiles(newFiles, existingAttachments, DEFAULT_ATTACHMENT_CONSTRAINTS);
|
|
40
|
+
* if (result.errors.length > 0) {
|
|
41
|
+
* alert('Some files cannot be uploaded: ' + result.errors.join(', '));
|
|
42
|
+
* }
|
|
43
|
+
* ```
|
|
44
|
+
*/
|
|
45
|
+
export declare function validateFiles(files: File[], existingAttachments?: Attachment[], constraints?: AttachmentConstraints): {
|
|
46
|
+
valid: boolean;
|
|
47
|
+
errors: string[];
|
|
48
|
+
};
|
|
49
|
+
/**
|
|
50
|
+
* Validate file and throw error if invalid
|
|
51
|
+
*
|
|
52
|
+
* Convenience function that throws AttachmentValidationError if validation fails.
|
|
53
|
+
*
|
|
54
|
+
* @param file - File to validate
|
|
55
|
+
* @param constraints - Validation constraints
|
|
56
|
+
* @throws {AttachmentValidationError} If validation fails
|
|
57
|
+
*
|
|
58
|
+
* @example
|
|
59
|
+
* ```ts
|
|
60
|
+
* try {
|
|
61
|
+
* validateFileOrThrow(file);
|
|
62
|
+
* // File is valid, proceed with upload
|
|
63
|
+
* } catch (err) {
|
|
64
|
+
* if (err instanceof AttachmentValidationError) {
|
|
65
|
+
* alert(err.message);
|
|
66
|
+
* }
|
|
67
|
+
* }
|
|
68
|
+
* ```
|
|
69
|
+
*/
|
|
70
|
+
export declare function validateFileOrThrow(file: File, constraints?: AttachmentConstraints): void;
|
|
71
|
+
/**
|
|
72
|
+
* Validate multiple files and throw error if invalid
|
|
73
|
+
*
|
|
74
|
+
* @param files - Files to validate
|
|
75
|
+
* @param existingAttachments - Existing attachments
|
|
76
|
+
* @param constraints - Validation constraints
|
|
77
|
+
* @throws {AttachmentValidationError} If validation fails
|
|
78
|
+
*
|
|
79
|
+
* @example
|
|
80
|
+
* ```ts
|
|
81
|
+
* try {
|
|
82
|
+
* validateFilesOrThrow(selectedFiles, currentAttachments);
|
|
83
|
+
* // All files are valid
|
|
84
|
+
* } catch (err) {
|
|
85
|
+
* if (err instanceof AttachmentValidationError) {
|
|
86
|
+
* alert(err.message);
|
|
87
|
+
* }
|
|
88
|
+
* }
|
|
89
|
+
* ```
|
|
90
|
+
*/
|
|
91
|
+
export declare function validateFilesOrThrow(files: File[], existingAttachments?: Attachment[], constraints?: AttachmentConstraints): void;
|
|
92
|
+
/**
|
|
93
|
+
* Check if a file type is an image
|
|
94
|
+
*
|
|
95
|
+
* @param fileType - MIME type of the file
|
|
96
|
+
* @returns true if the file is an image
|
|
97
|
+
*
|
|
98
|
+
* @example
|
|
99
|
+
* ```ts
|
|
100
|
+
* if (isImageType(file.type)) {
|
|
101
|
+
* // Generate preview
|
|
102
|
+
* }
|
|
103
|
+
* ```
|
|
104
|
+
*/
|
|
105
|
+
export declare function isImageType(fileType: string): boolean;
|
|
106
|
+
/**
|
|
107
|
+
* Format file size for display
|
|
108
|
+
*
|
|
109
|
+
* @param bytes - File size in bytes
|
|
110
|
+
* @returns Formatted size string (e.g., "1.5 MB")
|
|
111
|
+
*
|
|
112
|
+
* @example
|
|
113
|
+
* ```ts
|
|
114
|
+
* const sizeDisplay = formatFileSize(file.size); // "1.5 MB"
|
|
115
|
+
* ```
|
|
116
|
+
*/
|
|
117
|
+
export declare function formatFileSize(bytes: number): string;
|
|
118
|
+
//# sourceMappingURL=attachment-validators.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"attachment-validators.d.ts","sourceRoot":"","sources":["../../src/utils/attachment-validators.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,qBAAqB,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAGlE;;GAEG;AACH,eAAO,MAAM,8BAA8B,EAAE,qBAM5C,CAAC;AAEF;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,YAAY,CAC1B,IAAI,EAAE,IAAI,EACV,WAAW,GAAE,qBAAsD,GAClE;IACD,KAAK,EAAE,OAAO,CAAC;IACf,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB,CA4CA;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,aAAa,CAC3B,KAAK,EAAE,IAAI,EAAE,EACb,mBAAmB,GAAE,UAAU,EAAO,EACtC,WAAW,GAAE,qBAAsD,GAClE;IACD,KAAK,EAAE,OAAO,CAAC;IACf,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB,CAkCA;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,mBAAmB,CACjC,IAAI,EAAE,IAAI,EACV,WAAW,GAAE,qBAAsD,GAClE,IAAI,CASN;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,IAAI,EAAE,EACb,mBAAmB,GAAE,UAAU,EAAO,EACtC,WAAW,GAAE,qBAAsD,GAClE,IAAI,CASN;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,WAAW,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAErD;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAQpD"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Audit Trail Utilities
|
|
3
|
+
* Captures device metadata, IP address, and geolocation for compliance and forensics
|
|
4
|
+
*/
|
|
5
|
+
import type { AuditTrailMetadata } from '../types';
|
|
6
|
+
/**
|
|
7
|
+
* Synchronously capture device and browser metadata
|
|
8
|
+
*/
|
|
9
|
+
export declare function captureDeviceMetadata(): Partial<AuditTrailMetadata>;
|
|
10
|
+
/**
|
|
11
|
+
* Capture IP address using public API
|
|
12
|
+
*/
|
|
13
|
+
export declare function captureIpAddress(): Promise<string>;
|
|
14
|
+
/**
|
|
15
|
+
* Capture geolocation using browser geolocation API
|
|
16
|
+
*/
|
|
17
|
+
export declare function captureGeolocation(): Promise<{
|
|
18
|
+
latitude: number;
|
|
19
|
+
longitude: number;
|
|
20
|
+
accuracy?: number;
|
|
21
|
+
} | null>;
|
|
22
|
+
/**
|
|
23
|
+
* Capture complete audit trail metadata
|
|
24
|
+
* Combines device metadata, IP address, and geolocation
|
|
25
|
+
*/
|
|
26
|
+
export declare function captureAuditTrail(): Promise<AuditTrailMetadata>;
|
|
27
|
+
//# sourceMappingURL=audit-trail.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"audit-trail.d.ts","sourceRoot":"","sources":["../../src/utils/audit-trail.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAGnD;;GAEG;AACH,wBAAgB,qBAAqB,IAAI,OAAO,CAAC,kBAAkB,CAAC,CAsCnE;AAED;;GAEG;AACH,wBAAsB,gBAAgB,IAAI,OAAO,CAAC,MAAM,CAAC,CAuBxD;AAED;;GAEG;AACH,wBAAsB,kBAAkB,IAAI,OAAO,CAAC;IAClD,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,GAAG,IAAI,CAAC,CAiCR;AAED;;;GAGG;AACH,wBAAsB,iBAAiB,IAAI,OAAO,CAAC,kBAAkB,CAAC,CAgCrE"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Date Validation and Parsing Utility
|
|
3
|
+
* Handles parsing of various date formats and validation
|
|
4
|
+
*/
|
|
5
|
+
export interface DateValidationResult {
|
|
6
|
+
isValid: boolean;
|
|
7
|
+
date: Date | null;
|
|
8
|
+
isoString: string | null;
|
|
9
|
+
originalValue: string;
|
|
10
|
+
error?: string;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Parse and validate a date string from various formats
|
|
14
|
+
* Attempts to parse common formats: ISO, US, EU, timestamps
|
|
15
|
+
*
|
|
16
|
+
* Format priority:
|
|
17
|
+
* 1. ISO 8601 (YYYY-MM-DD)
|
|
18
|
+
* 2. US format (MM/DD/YYYY) - assumes US format for ambiguous dates
|
|
19
|
+
* 3. EU format (DD/MM/YYYY)
|
|
20
|
+
* 4. Timestamp (numeric string)
|
|
21
|
+
*
|
|
22
|
+
* @param value - The date string to parse
|
|
23
|
+
* @returns Validation result with parsed date or error
|
|
24
|
+
*/
|
|
25
|
+
export declare function parseAndValidateDate(value: string | null | undefined): DateValidationResult;
|
|
26
|
+
/**
|
|
27
|
+
* Validate if a string is a valid ISO date (YYYY-MM-DD)
|
|
28
|
+
*/
|
|
29
|
+
export declare function isValidISODate(value: string | null | undefined): boolean;
|
|
30
|
+
//# sourceMappingURL=date-validation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"date-validation.d.ts","sourceRoot":"","sources":["../../src/utils/date-validation.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,MAAM,WAAW,oBAAoB;IACnC,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,EAAE,IAAI,GAAG,IAAI,CAAC;IAClB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,aAAa,EAAE,MAAM,CAAC;IACtB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AASD;;;;;;;;;;;;GAYG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,oBAAoB,CAoJ3F;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,OAAO,CAgBxE"}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Custom Error Classes
|
|
3
|
+
* Domain-specific error types for better error handling and debugging
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Error thrown when PDF validation fails
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```ts
|
|
10
|
+
* const validation = validatePdfBytes(bytes);
|
|
11
|
+
* if (!validation.valid) {
|
|
12
|
+
* throw new PdfValidationError(validation.error || 'Invalid PDF');
|
|
13
|
+
* }
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
export declare class PdfValidationError extends Error {
|
|
17
|
+
readonly details?: unknown | undefined;
|
|
18
|
+
constructor(message: string, details?: unknown | undefined);
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Error thrown during PDF processing operations
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```ts
|
|
25
|
+
* try {
|
|
26
|
+
* const pdfDoc = await PDFDocument.load(bytes);
|
|
27
|
+
* } catch (err) {
|
|
28
|
+
* throw new PdfProcessingError('Failed to load PDF document', err);
|
|
29
|
+
* }
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
export declare class PdfProcessingError extends Error {
|
|
33
|
+
readonly details?: unknown | undefined;
|
|
34
|
+
constructor(message: string, details?: unknown | undefined);
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Error thrown for form field related issues
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* ```ts
|
|
41
|
+
* if (!field.value && field.required) {
|
|
42
|
+
* throw new FormFieldError(
|
|
43
|
+
* 'Required field is empty',
|
|
44
|
+
* field.name
|
|
45
|
+
* );
|
|
46
|
+
* }
|
|
47
|
+
* ```
|
|
48
|
+
*/
|
|
49
|
+
export declare class FormFieldError extends Error {
|
|
50
|
+
readonly fieldName?: string | undefined;
|
|
51
|
+
readonly details?: unknown | undefined;
|
|
52
|
+
constructor(message: string, fieldName?: string | undefined, details?: unknown | undefined);
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Error thrown for attachment validation failures
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* ```ts
|
|
59
|
+
* if (file.size > maxFileSize) {
|
|
60
|
+
* throw new AttachmentValidationError(
|
|
61
|
+
* `File size exceeds limit: ${file.name}`,
|
|
62
|
+
* file.name
|
|
63
|
+
* );
|
|
64
|
+
* }
|
|
65
|
+
* ```
|
|
66
|
+
*/
|
|
67
|
+
export declare class AttachmentValidationError extends Error {
|
|
68
|
+
readonly fileName?: string | undefined;
|
|
69
|
+
readonly details?: unknown | undefined;
|
|
70
|
+
constructor(message: string, fileName?: string | undefined, details?: unknown | undefined);
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Type guard to check if an error is a PdfValidationError
|
|
74
|
+
*/
|
|
75
|
+
export declare function isPdfValidationError(error: unknown): error is PdfValidationError;
|
|
76
|
+
/**
|
|
77
|
+
* Type guard to check if an error is a PdfProcessingError
|
|
78
|
+
*/
|
|
79
|
+
export declare function isPdfProcessingError(error: unknown): error is PdfProcessingError;
|
|
80
|
+
/**
|
|
81
|
+
* Type guard to check if an error is a FormFieldError
|
|
82
|
+
*/
|
|
83
|
+
export declare function isFormFieldError(error: unknown): error is FormFieldError;
|
|
84
|
+
/**
|
|
85
|
+
* Type guard to check if an error is an AttachmentValidationError
|
|
86
|
+
*/
|
|
87
|
+
export declare function isAttachmentValidationError(error: unknown): error is AttachmentValidationError;
|
|
88
|
+
/**
|
|
89
|
+
* Extract error message from unknown error type
|
|
90
|
+
*
|
|
91
|
+
* @param error - The error to extract message from
|
|
92
|
+
* @param defaultMessage - Default message if extraction fails
|
|
93
|
+
* @returns Error message string
|
|
94
|
+
*
|
|
95
|
+
* @example
|
|
96
|
+
* ```ts
|
|
97
|
+
* try {
|
|
98
|
+
* // ... operation
|
|
99
|
+
* } catch (err) {
|
|
100
|
+
* const message = getErrorMessage(err, 'Operation failed');
|
|
101
|
+
* logger.error(message);
|
|
102
|
+
* }
|
|
103
|
+
* ```
|
|
104
|
+
*/
|
|
105
|
+
export declare function getErrorMessage(error: unknown, defaultMessage?: string): string;
|
|
106
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/utils/errors.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;;;GAUG;AACH,qBAAa,kBAAmB,SAAQ,KAAK;aAGzB,OAAO,CAAC,EAAE,OAAO;gBADjC,OAAO,EAAE,MAAM,EACC,OAAO,CAAC,EAAE,OAAO,YAAA;CASpC;AAED;;;;;;;;;;;GAWG;AACH,qBAAa,kBAAmB,SAAQ,KAAK;aAGzB,OAAO,CAAC,EAAE,OAAO;gBADjC,OAAO,EAAE,MAAM,EACC,OAAO,CAAC,EAAE,OAAO,YAAA;CAQpC;AAED;;;;;;;;;;;;GAYG;AACH,qBAAa,cAAe,SAAQ,KAAK;aAGrB,SAAS,CAAC,EAAE,MAAM;aAClB,OAAO,CAAC,EAAE,OAAO;gBAFjC,OAAO,EAAE,MAAM,EACC,SAAS,CAAC,EAAE,MAAM,YAAA,EAClB,OAAO,CAAC,EAAE,OAAO,YAAA;CAQpC;AAED;;;;;;;;;;;;GAYG;AACH,qBAAa,yBAA0B,SAAQ,KAAK;aAGhC,QAAQ,CAAC,EAAE,MAAM;aACjB,OAAO,CAAC,EAAE,OAAO;gBAFjC,OAAO,EAAE,MAAM,EACC,QAAQ,CAAC,EAAE,MAAM,YAAA,EACjB,OAAO,CAAC,EAAE,OAAO,YAAA;CAQpC;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,kBAAkB,CAEhF;AAED;;GAEG;AACH,wBA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