pdf-oxide-fips 0.3.47

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 (127) hide show
  1. package/LICENSE-APACHE +176 -0
  2. package/LICENSE-MIT +25 -0
  3. package/README.md +218 -0
  4. package/lib/builders/annotation-builder.d.ts +198 -0
  5. package/lib/builders/annotation-builder.js +317 -0
  6. package/lib/builders/conversion-options-builder.d.ts +106 -0
  7. package/lib/builders/conversion-options-builder.js +214 -0
  8. package/lib/builders/document-builder.d.ts +381 -0
  9. package/lib/builders/document-builder.js +770 -0
  10. package/lib/builders/index.d.ts +13 -0
  11. package/lib/builders/index.js +13 -0
  12. package/lib/builders/metadata-builder.d.ts +201 -0
  13. package/lib/builders/metadata-builder.js +285 -0
  14. package/lib/builders/pdf-builder.d.ts +216 -0
  15. package/lib/builders/pdf-builder.js +350 -0
  16. package/lib/builders/search-options-builder.d.ts +73 -0
  17. package/lib/builders/search-options-builder.js +129 -0
  18. package/lib/builders/streaming-table.d.ts +64 -0
  19. package/lib/builders/streaming-table.js +140 -0
  20. package/lib/document-editor-manager.d.ts +139 -0
  21. package/lib/document-editor-manager.js +256 -0
  22. package/lib/document-editor.d.ts +124 -0
  23. package/lib/document-editor.js +318 -0
  24. package/lib/errors.d.ts +382 -0
  25. package/lib/errors.js +1115 -0
  26. package/lib/form-field-manager.d.ts +299 -0
  27. package/lib/form-field-manager.js +568 -0
  28. package/lib/hybrid-ml-manager.d.ts +142 -0
  29. package/lib/hybrid-ml-manager.js +208 -0
  30. package/lib/index.d.ts +205 -0
  31. package/lib/index.js +693 -0
  32. package/lib/managers/accessibility-manager.d.ts +148 -0
  33. package/lib/managers/accessibility-manager.js +234 -0
  34. package/lib/managers/annotation-manager.d.ts +219 -0
  35. package/lib/managers/annotation-manager.js +359 -0
  36. package/lib/managers/barcode-manager.d.ts +82 -0
  37. package/lib/managers/barcode-manager.js +263 -0
  38. package/lib/managers/batch-manager.d.ts +185 -0
  39. package/lib/managers/batch-manager.js +385 -0
  40. package/lib/managers/cache-manager.d.ts +181 -0
  41. package/lib/managers/cache-manager.js +384 -0
  42. package/lib/managers/compliance-manager.d.ts +103 -0
  43. package/lib/managers/compliance-manager.js +453 -0
  44. package/lib/managers/content-manager.d.ts +120 -0
  45. package/lib/managers/content-manager.js +294 -0
  46. package/lib/managers/document-utility-manager.d.ts +369 -0
  47. package/lib/managers/document-utility-manager.js +730 -0
  48. package/lib/managers/dom-pdf-creator.d.ts +104 -0
  49. package/lib/managers/dom-pdf-creator.js +299 -0
  50. package/lib/managers/editing-manager.d.ts +248 -0
  51. package/lib/managers/editing-manager.js +387 -0
  52. package/lib/managers/enterprise-manager.d.ts +192 -0
  53. package/lib/managers/enterprise-manager.js +307 -0
  54. package/lib/managers/extended-managers.d.ts +122 -0
  55. package/lib/managers/extended-managers.js +664 -0
  56. package/lib/managers/extraction-manager.d.ts +246 -0
  57. package/lib/managers/extraction-manager.js +482 -0
  58. package/lib/managers/final-utilities.d.ts +127 -0
  59. package/lib/managers/final-utilities.js +657 -0
  60. package/lib/managers/hybrid-ml-advanced.d.ts +136 -0
  61. package/lib/managers/hybrid-ml-advanced.js +722 -0
  62. package/lib/managers/index.d.ts +64 -0
  63. package/lib/managers/index.js +69 -0
  64. package/lib/managers/layer-manager.d.ts +203 -0
  65. package/lib/managers/layer-manager.js +401 -0
  66. package/lib/managers/metadata-manager.d.ts +148 -0
  67. package/lib/managers/metadata-manager.js +280 -0
  68. package/lib/managers/ocr-manager.d.ts +194 -0
  69. package/lib/managers/ocr-manager.js +582 -0
  70. package/lib/managers/optimization-manager.d.ts +102 -0
  71. package/lib/managers/optimization-manager.js +213 -0
  72. package/lib/managers/outline-manager.d.ts +101 -0
  73. package/lib/managers/outline-manager.js +169 -0
  74. package/lib/managers/page-manager.d.ts +142 -0
  75. package/lib/managers/page-manager.js +235 -0
  76. package/lib/managers/pattern-detection.d.ts +169 -0
  77. package/lib/managers/pattern-detection.js +322 -0
  78. package/lib/managers/rendering-manager.d.ts +353 -0
  79. package/lib/managers/rendering-manager.js +679 -0
  80. package/lib/managers/search-manager.d.ts +235 -0
  81. package/lib/managers/search-manager.js +329 -0
  82. package/lib/managers/security-manager.d.ts +161 -0
  83. package/lib/managers/security-manager.js +292 -0
  84. package/lib/managers/signature-manager.d.ts +738 -0
  85. package/lib/managers/signature-manager.js +1509 -0
  86. package/lib/managers/streams.d.ts +262 -0
  87. package/lib/managers/streams.js +477 -0
  88. package/lib/managers/xfa-manager.d.ts +227 -0
  89. package/lib/managers/xfa-manager.js +539 -0
  90. package/lib/native-loader.d.ts +7 -0
  91. package/lib/native-loader.js +62 -0
  92. package/lib/native.d.ts +16 -0
  93. package/lib/native.js +69 -0
  94. package/lib/pdf-creator-manager.d.ts +200 -0
  95. package/lib/pdf-creator-manager.js +381 -0
  96. package/lib/properties.d.ts +79 -0
  97. package/lib/properties.js +454 -0
  98. package/lib/result-accessors-manager.d.ts +346 -0
  99. package/lib/result-accessors-manager.js +706 -0
  100. package/lib/thumbnail-manager.d.ts +121 -0
  101. package/lib/thumbnail-manager.js +205 -0
  102. package/lib/timestamp.d.ts +54 -0
  103. package/lib/timestamp.js +115 -0
  104. package/lib/tsa-client.d.ts +44 -0
  105. package/lib/tsa-client.js +67 -0
  106. package/lib/types/common.d.ts +189 -0
  107. package/lib/types/common.js +17 -0
  108. package/lib/types/document-types.d.ts +352 -0
  109. package/lib/types/document-types.js +82 -0
  110. package/lib/types/index.d.ts +5 -0
  111. package/lib/types/index.js +5 -0
  112. package/lib/types/manager-types.d.ts +179 -0
  113. package/lib/types/manager-types.js +100 -0
  114. package/lib/types/native-bindings.d.ts +439 -0
  115. package/lib/types/native-bindings.js +7 -0
  116. package/lib/workers/index.d.ts +6 -0
  117. package/lib/workers/index.js +5 -0
  118. package/lib/workers/pool.d.ts +64 -0
  119. package/lib/workers/pool.js +192 -0
  120. package/lib/workers/worker.d.ts +5 -0
  121. package/lib/workers/worker.js +99 -0
  122. package/package.json +79 -0
  123. package/prebuilds/darwin-arm64/pdf_oxide.node +0 -0
  124. package/prebuilds/darwin-x64/pdf_oxide.node +0 -0
  125. package/prebuilds/linux-arm64/pdf_oxide.node +0 -0
  126. package/prebuilds/linux-x64/pdf_oxide.node +0 -0
  127. package/prebuilds/win32-x64/pdf_oxide.node +0 -0
@@ -0,0 +1,161 @@
1
+ /**
2
+ * Manager for PDF document security and encryption
3
+ *
4
+ * Provides methods to check document encryption status, access permissions,
5
+ * and security properties.
6
+ *
7
+ * @example
8
+ * ```typescript
9
+ * import { SecurityManager } from 'pdf_oxide';
10
+ *
11
+ * const doc = PdfDocument.open('document.pdf');
12
+ * const securityManager = new SecurityManager(doc);
13
+ *
14
+ * if (securityManager.isEncrypted()) {
15
+ * console.log('Document is encrypted');
16
+ * console.log(`Can print: ${securityManager.canPrint()}`);
17
+ * console.log(`Can modify: ${securityManager.canModify()}`);
18
+ * }
19
+ * ```
20
+ */
21
+ export interface PermissionsSummary {
22
+ canPrint: boolean;
23
+ canCopy: boolean;
24
+ canModify: boolean;
25
+ canAnnotate: boolean;
26
+ canFillForms: boolean;
27
+ isViewOnly: boolean;
28
+ isEncrypted: boolean;
29
+ requiresPassword: boolean;
30
+ encryptionAlgorithm: string | null;
31
+ }
32
+ export interface SecurityLevel {
33
+ level: 'high' | 'medium' | 'low' | 'none';
34
+ description: string;
35
+ isEncrypted: boolean;
36
+ algorithm: string | null;
37
+ restrictedAccess: boolean;
38
+ }
39
+ export interface AccessibilityValidation {
40
+ canExtractText: boolean;
41
+ canExtractImages: boolean;
42
+ canAnalyzeContent: boolean;
43
+ canSearch: boolean;
44
+ canViewContent: boolean;
45
+ isAccessible: boolean;
46
+ issues: string[];
47
+ }
48
+ export declare class SecurityManager {
49
+ private _document;
50
+ /**
51
+ * Creates a new SecurityManager for the given document
52
+ * @param document - The PDF document
53
+ * @throws Error if document is null or undefined
54
+ */
55
+ constructor(document: any);
56
+ /**
57
+ * Checks if the document is encrypted
58
+ * @returns True if document is encrypted
59
+ */
60
+ isEncrypted(): boolean;
61
+ /**
62
+ * Checks if document requires a password
63
+ * @returns True if password is required to open
64
+ */
65
+ requiresPassword(): boolean;
66
+ /**
67
+ * Gets encryption algorithm used
68
+ * @returns Encryption algorithm (e.g., 'RC4', 'AES-128', 'AES-256') or null
69
+ */
70
+ getEncryptionAlgorithm(): string | null;
71
+ /**
72
+ * Checks if user can print the document
73
+ * @returns True if printing is allowed
74
+ */
75
+ canPrint(): boolean;
76
+ /**
77
+ * Checks if user can copy text from document
78
+ * @returns True if copying is allowed
79
+ */
80
+ canCopy(): boolean;
81
+ /**
82
+ * Checks if user can modify the document
83
+ * @returns True if modification is allowed
84
+ */
85
+ canModify(): boolean;
86
+ /**
87
+ * Checks if user can add or modify annotations
88
+ * @returns True if annotation modification is allowed
89
+ */
90
+ canAnnotate(): boolean;
91
+ /**
92
+ * Checks if user can fill form fields
93
+ * @returns True if form filling is allowed
94
+ */
95
+ canFillForms(): boolean;
96
+ /**
97
+ * Checks if document is view-only
98
+ * @returns True if no modifications are allowed
99
+ */
100
+ isViewOnly(): boolean;
101
+ /**
102
+ * Gets all permissions as a summary object
103
+ * @returns Permissions summary
104
+ *
105
+ * @example
106
+ * ```typescript
107
+ * const perms = manager.getPermissionsSummary();
108
+ * console.log(JSON.stringify(perms, null, 2));
109
+ * // {
110
+ * // canPrint: true,
111
+ * // canCopy: true,
112
+ * // canModify: false,
113
+ * // canAnnotate: true,
114
+ * // canFillForms: true,
115
+ * // isViewOnly: false,
116
+ * // isEncrypted: true
117
+ * // }
118
+ * ```
119
+ */
120
+ getPermissionsSummary(): PermissionsSummary;
121
+ /**
122
+ * Gets security level information
123
+ * @returns Security level details
124
+ *
125
+ * @example
126
+ * ```typescript
127
+ * const secLevel = manager.getSecurityLevel();
128
+ * console.log(`Security level: ${secLevel.level}`); // 'high', 'medium', 'low', 'none'
129
+ * ```
130
+ */
131
+ getSecurityLevel(): SecurityLevel;
132
+ /**
133
+ * Validates document accessibility based on security settings
134
+ * @returns Accessibility validation result
135
+ *
136
+ * @example
137
+ * ```typescript
138
+ * const validation = manager.validateAccessibility();
139
+ * if (!validation.canExtractText) {
140
+ * console.log('Warning: Document does not allow text extraction');
141
+ * }
142
+ * ```
143
+ */
144
+ validateAccessibility(): AccessibilityValidation;
145
+ /**
146
+ * Gets list of accessibility issues
147
+ * @returns Array of accessibility issues
148
+ * @private
149
+ */
150
+ private getAccessibilityIssues;
151
+ /**
152
+ * Generates security report
153
+ * @returns Human-readable security report
154
+ *
155
+ * @example
156
+ * ```typescript
157
+ * console.log(manager.generateSecurityReport());
158
+ * ```
159
+ */
160
+ generateSecurityReport(): string;
161
+ }
@@ -0,0 +1,292 @@
1
+ /**
2
+ * Manager for PDF document security and encryption
3
+ *
4
+ * Provides methods to check document encryption status, access permissions,
5
+ * and security properties.
6
+ *
7
+ * @example
8
+ * ```typescript
9
+ * import { SecurityManager } from 'pdf_oxide';
10
+ *
11
+ * const doc = PdfDocument.open('document.pdf');
12
+ * const securityManager = new SecurityManager(doc);
13
+ *
14
+ * if (securityManager.isEncrypted()) {
15
+ * console.log('Document is encrypted');
16
+ * console.log(`Can print: ${securityManager.canPrint()}`);
17
+ * console.log(`Can modify: ${securityManager.canModify()}`);
18
+ * }
19
+ * ```
20
+ */
21
+ export class SecurityManager {
22
+ /**
23
+ * Creates a new SecurityManager for the given document
24
+ * @param document - The PDF document
25
+ * @throws Error if document is null or undefined
26
+ */
27
+ constructor(document) {
28
+ if (!document) {
29
+ throw new Error('Document is required');
30
+ }
31
+ this._document = document;
32
+ }
33
+ /**
34
+ * Checks if the document is encrypted
35
+ * @returns True if document is encrypted
36
+ */
37
+ isEncrypted() {
38
+ try {
39
+ return this._document.isEncrypted();
40
+ }
41
+ catch (error) {
42
+ return false;
43
+ }
44
+ }
45
+ /**
46
+ * Checks if document requires a password
47
+ * @returns True if password is required to open
48
+ */
49
+ requiresPassword() {
50
+ return this.isEncrypted();
51
+ }
52
+ /**
53
+ * Gets encryption algorithm used
54
+ * @returns Encryption algorithm (e.g., 'RC4', 'AES-128', 'AES-256') or null
55
+ */
56
+ getEncryptionAlgorithm() {
57
+ try {
58
+ if (!this.isEncrypted())
59
+ return null;
60
+ return this._document.getEncryptionAlgorithm() || null;
61
+ }
62
+ catch (error) {
63
+ return null;
64
+ }
65
+ }
66
+ /**
67
+ * Checks if user can print the document
68
+ * @returns True if printing is allowed
69
+ */
70
+ canPrint() {
71
+ try {
72
+ return this._document.canPrint();
73
+ }
74
+ catch (error) {
75
+ return true;
76
+ }
77
+ }
78
+ /**
79
+ * Checks if user can copy text from document
80
+ * @returns True if copying is allowed
81
+ */
82
+ canCopy() {
83
+ try {
84
+ return this._document.canCopy();
85
+ }
86
+ catch (error) {
87
+ return true;
88
+ }
89
+ }
90
+ /**
91
+ * Checks if user can modify the document
92
+ * @returns True if modification is allowed
93
+ */
94
+ canModify() {
95
+ try {
96
+ return this._document.canModify();
97
+ }
98
+ catch (error) {
99
+ return true;
100
+ }
101
+ }
102
+ /**
103
+ * Checks if user can add or modify annotations
104
+ * @returns True if annotation modification is allowed
105
+ */
106
+ canAnnotate() {
107
+ try {
108
+ return this._document.canAnnotate();
109
+ }
110
+ catch (error) {
111
+ return true;
112
+ }
113
+ }
114
+ /**
115
+ * Checks if user can fill form fields
116
+ * @returns True if form filling is allowed
117
+ */
118
+ canFillForms() {
119
+ try {
120
+ return this._document.canFillForms();
121
+ }
122
+ catch (error) {
123
+ return true;
124
+ }
125
+ }
126
+ /**
127
+ * Checks if document is view-only
128
+ * @returns True if no modifications are allowed
129
+ */
130
+ isViewOnly() {
131
+ return !this.canModify() && !this.canCopy() && !this.canAnnotate();
132
+ }
133
+ /**
134
+ * Gets all permissions as a summary object
135
+ * @returns Permissions summary
136
+ *
137
+ * @example
138
+ * ```typescript
139
+ * const perms = manager.getPermissionsSummary();
140
+ * console.log(JSON.stringify(perms, null, 2));
141
+ * // {
142
+ * // canPrint: true,
143
+ * // canCopy: true,
144
+ * // canModify: false,
145
+ * // canAnnotate: true,
146
+ * // canFillForms: true,
147
+ * // isViewOnly: false,
148
+ * // isEncrypted: true
149
+ * // }
150
+ * ```
151
+ */
152
+ getPermissionsSummary() {
153
+ return {
154
+ canPrint: this.canPrint(),
155
+ canCopy: this.canCopy(),
156
+ canModify: this.canModify(),
157
+ canAnnotate: this.canAnnotate(),
158
+ canFillForms: this.canFillForms(),
159
+ isViewOnly: this.isViewOnly(),
160
+ isEncrypted: this.isEncrypted(),
161
+ requiresPassword: this.requiresPassword(),
162
+ encryptionAlgorithm: this.getEncryptionAlgorithm(),
163
+ };
164
+ }
165
+ /**
166
+ * Gets security level information
167
+ * @returns Security level details
168
+ *
169
+ * @example
170
+ * ```typescript
171
+ * const secLevel = manager.getSecurityLevel();
172
+ * console.log(`Security level: ${secLevel.level}`); // 'high', 'medium', 'low', 'none'
173
+ * ```
174
+ */
175
+ getSecurityLevel() {
176
+ const isEncrypted = this.isEncrypted();
177
+ const algorithm = this.getEncryptionAlgorithm();
178
+ let level = 'none';
179
+ let description = 'No encryption';
180
+ if (isEncrypted) {
181
+ if (algorithm === 'AES-256') {
182
+ level = 'high';
183
+ description = 'AES-256 encryption';
184
+ }
185
+ else if (algorithm === 'AES-128') {
186
+ level = 'medium';
187
+ description = 'AES-128 encryption';
188
+ }
189
+ else if (algorithm === 'RC4') {
190
+ level = 'low';
191
+ description = 'RC4 encryption (deprecated)';
192
+ }
193
+ else {
194
+ level = 'medium';
195
+ description = 'Encrypted with unknown algorithm';
196
+ }
197
+ // Reduce level if permissions are very restrictive
198
+ if (this.isViewOnly()) {
199
+ description += ' (read-only)';
200
+ }
201
+ }
202
+ return {
203
+ level,
204
+ description,
205
+ isEncrypted,
206
+ algorithm,
207
+ restrictedAccess: !this.canModify() && !this.canCopy(),
208
+ };
209
+ }
210
+ /**
211
+ * Validates document accessibility based on security settings
212
+ * @returns Accessibility validation result
213
+ *
214
+ * @example
215
+ * ```typescript
216
+ * const validation = manager.validateAccessibility();
217
+ * if (!validation.canExtractText) {
218
+ * console.log('Warning: Document does not allow text extraction');
219
+ * }
220
+ * ```
221
+ */
222
+ validateAccessibility() {
223
+ return {
224
+ canExtractText: this.canCopy(),
225
+ canExtractImages: this.canCopy(),
226
+ canAnalyzeContent: this.canCopy(),
227
+ canSearch: true, // Always allowed
228
+ canViewContent: true, // Always allowed
229
+ isAccessible: this.canCopy(),
230
+ issues: this.getAccessibilityIssues(),
231
+ };
232
+ }
233
+ /**
234
+ * Gets list of accessibility issues
235
+ * @returns Array of accessibility issues
236
+ * @private
237
+ */
238
+ getAccessibilityIssues() {
239
+ const issues = [];
240
+ if (this.isEncrypted()) {
241
+ issues.push('Document is encrypted');
242
+ }
243
+ if (this.requiresPassword()) {
244
+ issues.push('Document requires password');
245
+ }
246
+ if (!this.canCopy()) {
247
+ issues.push('Text extraction is restricted');
248
+ }
249
+ if (!this.canModify()) {
250
+ issues.push('Document modification is restricted');
251
+ }
252
+ if (!this.canPrint()) {
253
+ issues.push('Printing is restricted');
254
+ }
255
+ if (!this.canAnnotate()) {
256
+ issues.push('Annotation is restricted');
257
+ }
258
+ return issues;
259
+ }
260
+ /**
261
+ * Generates security report
262
+ * @returns Human-readable security report
263
+ *
264
+ * @example
265
+ * ```typescript
266
+ * console.log(manager.generateSecurityReport());
267
+ * ```
268
+ */
269
+ generateSecurityReport() {
270
+ const lines = [];
271
+ const perms = this.getPermissionsSummary();
272
+ const secLevel = this.getSecurityLevel();
273
+ lines.push('=== PDF Security Report ===\n');
274
+ lines.push(`Encryption Status: ${perms.isEncrypted ? 'Encrypted' : 'Not encrypted'}`);
275
+ if (perms.isEncrypted) {
276
+ lines.push(` Algorithm: ${perms.encryptionAlgorithm || 'Unknown'}`);
277
+ lines.push(` Requires Password: ${perms.requiresPassword}`);
278
+ }
279
+ lines.push(`\nSecurity Level: ${secLevel.level.toUpperCase()}`);
280
+ lines.push(` Description: ${secLevel.description}`);
281
+ lines.push('\nAccess Permissions:');
282
+ lines.push(` Print: ${perms.canPrint ? 'Allowed' : 'Restricted'}`);
283
+ lines.push(` Copy: ${perms.canCopy ? 'Allowed' : 'Restricted'}`);
284
+ lines.push(` Modify: ${perms.canModify ? 'Allowed' : 'Restricted'}`);
285
+ lines.push(` Annotate: ${perms.canAnnotate ? 'Allowed' : 'Restricted'}`);
286
+ lines.push(` Fill Forms: ${perms.canFillForms ? 'Allowed' : 'Restricted'}`);
287
+ if (perms.isViewOnly) {
288
+ lines.push('\n⚠️ WARNING: Document is VIEW-ONLY');
289
+ }
290
+ return lines.join('\n');
291
+ }
292
+ }