pdf-lite 1.0.3 → 1.0.4
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/README.md +3 -0
- package/dist/core/index.d.ts +48 -0
- package/dist/core/index.js +48 -0
- package/dist/core/objects/pdf-array.d.ts +1 -1
- package/dist/core/objects/pdf-indirect-object.d.ts +1 -1
- package/dist/core/objects/pdf-start-xref.d.ts +1 -1
- package/dist/core/objects/pdf-xref-table.d.ts +1 -1
- package/dist/crypto/index.d.ts +11 -0
- package/dist/crypto/index.js +11 -0
- package/dist/crypto/key-derivation/key-derivation.d.ts +0 -14
- package/dist/crypto/key-derivation/key-derivation.js +1 -26
- package/dist/crypto/key-gen/key-gen-rc4-128.js +1 -2
- package/dist/crypto/key-gen/key-gen-rc4-40.js +1 -2
- package/dist/filters/index.d.ts +7 -0
- package/dist/filters/index.js +7 -0
- package/dist/index.d.ts +5 -1
- package/dist/index.js +5 -1
- package/dist/pdf/index.d.ts +5 -4
- package/dist/pdf/index.js +5 -4
- package/dist/security/index.d.ts +13 -0
- package/dist/security/index.js +13 -0
- package/dist/signing/index.d.ts +5 -4
- package/dist/signing/index.js +5 -4
- package/dist/utils/index.d.ts +17 -0
- package/dist/utils/index.js +17 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -8,6 +8,9 @@ A low-level, minimal-dependency, type-safe PDF library that works in the browser
|
|
|
8
8
|
|
|
9
9
|
PRs and issues are welcome!
|
|
10
10
|
|
|
11
|
+
[](https://www.npmjs.com/package/pdf-lite)
|
|
12
|
+
[](https://opensource.org/licenses/MIT)
|
|
13
|
+
|
|
11
14
|
## Features
|
|
12
15
|
|
|
13
16
|
- **Zero dependencies**: No external libraries are required, making it lightweight and easy to integrate.
|
package/dist/core/index.d.ts
CHANGED
|
@@ -1,2 +1,50 @@
|
|
|
1
1
|
export * from './decoder.js';
|
|
2
|
+
export * from './generators.js';
|
|
3
|
+
export * from './incremental-parser.js';
|
|
4
|
+
export * from './objects/pdf-array.js';
|
|
5
|
+
export * from './objects/pdf-boolean.js';
|
|
6
|
+
export * from './objects/pdf-comment.js';
|
|
7
|
+
export * from './objects/pdf-date.js';
|
|
8
|
+
export * from './objects/pdf-dictionary.js';
|
|
9
|
+
export * from './objects/pdf-hexadecimal.js';
|
|
10
|
+
export * from './objects/pdf-indirect-object.js';
|
|
11
|
+
export * from './objects/pdf-name.js';
|
|
12
|
+
export * from './objects/pdf-null.js';
|
|
13
|
+
export * from './objects/pdf-number.js';
|
|
14
|
+
export * from './objects/pdf-object-reference.js';
|
|
15
|
+
export * from './objects/pdf-object.js';
|
|
16
|
+
export * from './objects/pdf-start-xref.js';
|
|
17
|
+
export * from './objects/pdf-stream.js';
|
|
18
|
+
export * from './objects/pdf-string.js';
|
|
19
|
+
export * from './objects/pdf-trailer.js';
|
|
20
|
+
export * from './objects/pdf-xref-table.js';
|
|
21
|
+
export * from './parser.js';
|
|
22
|
+
export * from './ref.js';
|
|
23
|
+
export * from './serializer.js';
|
|
24
|
+
export * from './streams/object-stream.js';
|
|
2
25
|
export * from './tokeniser.js';
|
|
26
|
+
export * from './tokens/boolean-token.js';
|
|
27
|
+
export * from './tokens/byte-offset-token.js';
|
|
28
|
+
export * from './tokens/comment-token.js';
|
|
29
|
+
export * from './tokens/end-array-token.js';
|
|
30
|
+
export * from './tokens/end-dictionary-token.js';
|
|
31
|
+
export * from './tokens/end-object-token.js';
|
|
32
|
+
export * from './tokens/end-stream-token.js';
|
|
33
|
+
export * from './tokens/hexadecimal-token.js';
|
|
34
|
+
export * from './tokens/name-token.js';
|
|
35
|
+
export * from './tokens/null-token.js';
|
|
36
|
+
export * from './tokens/number-token.js';
|
|
37
|
+
export * from './tokens/object-reference-token.js';
|
|
38
|
+
export * from './tokens/start-array-token.js';
|
|
39
|
+
export * from './tokens/start-dictionary-token.js';
|
|
40
|
+
export * from './tokens/start-object-token.js';
|
|
41
|
+
export * from './tokens/start-stream-token.js';
|
|
42
|
+
export * from './tokens/start-xref-token.js';
|
|
43
|
+
export * from './tokens/stream-chunk-token.js';
|
|
44
|
+
export * from './tokens/string-token.js';
|
|
45
|
+
export * from './tokens/token.js';
|
|
46
|
+
export * from './tokens/trailer-token.js';
|
|
47
|
+
export * from './tokens/whitespace-token.js';
|
|
48
|
+
export * from './tokens/xref-table-entry-token.js';
|
|
49
|
+
export * from './tokens/xref-table-section-start-token.js';
|
|
50
|
+
export * from './tokens/xref-table-start-token.js';
|
package/dist/core/index.js
CHANGED
|
@@ -1,2 +1,50 @@
|
|
|
1
1
|
export * from './decoder.js';
|
|
2
|
+
export * from './generators.js';
|
|
3
|
+
export * from './incremental-parser.js';
|
|
4
|
+
export * from './objects/pdf-array.js';
|
|
5
|
+
export * from './objects/pdf-boolean.js';
|
|
6
|
+
export * from './objects/pdf-comment.js';
|
|
7
|
+
export * from './objects/pdf-date.js';
|
|
8
|
+
export * from './objects/pdf-dictionary.js';
|
|
9
|
+
export * from './objects/pdf-hexadecimal.js';
|
|
10
|
+
export * from './objects/pdf-indirect-object.js';
|
|
11
|
+
export * from './objects/pdf-name.js';
|
|
12
|
+
export * from './objects/pdf-null.js';
|
|
13
|
+
export * from './objects/pdf-number.js';
|
|
14
|
+
export * from './objects/pdf-object-reference.js';
|
|
15
|
+
export * from './objects/pdf-object.js';
|
|
16
|
+
export * from './objects/pdf-start-xref.js';
|
|
17
|
+
export * from './objects/pdf-stream.js';
|
|
18
|
+
export * from './objects/pdf-string.js';
|
|
19
|
+
export * from './objects/pdf-trailer.js';
|
|
20
|
+
export * from './objects/pdf-xref-table.js';
|
|
21
|
+
export * from './parser.js';
|
|
22
|
+
export * from './ref.js';
|
|
23
|
+
export * from './serializer.js';
|
|
24
|
+
export * from './streams/object-stream.js';
|
|
2
25
|
export * from './tokeniser.js';
|
|
26
|
+
export * from './tokens/boolean-token.js';
|
|
27
|
+
export * from './tokens/byte-offset-token.js';
|
|
28
|
+
export * from './tokens/comment-token.js';
|
|
29
|
+
export * from './tokens/end-array-token.js';
|
|
30
|
+
export * from './tokens/end-dictionary-token.js';
|
|
31
|
+
export * from './tokens/end-object-token.js';
|
|
32
|
+
export * from './tokens/end-stream-token.js';
|
|
33
|
+
export * from './tokens/hexadecimal-token.js';
|
|
34
|
+
export * from './tokens/name-token.js';
|
|
35
|
+
export * from './tokens/null-token.js';
|
|
36
|
+
export * from './tokens/number-token.js';
|
|
37
|
+
export * from './tokens/object-reference-token.js';
|
|
38
|
+
export * from './tokens/start-array-token.js';
|
|
39
|
+
export * from './tokens/start-dictionary-token.js';
|
|
40
|
+
export * from './tokens/start-object-token.js';
|
|
41
|
+
export * from './tokens/start-stream-token.js';
|
|
42
|
+
export * from './tokens/start-xref-token.js';
|
|
43
|
+
export * from './tokens/stream-chunk-token.js';
|
|
44
|
+
export * from './tokens/string-token.js';
|
|
45
|
+
export * from './tokens/token.js';
|
|
46
|
+
export * from './tokens/trailer-token.js';
|
|
47
|
+
export * from './tokens/whitespace-token.js';
|
|
48
|
+
export * from './tokens/xref-table-entry-token.js';
|
|
49
|
+
export * from './tokens/xref-table-section-start-token.js';
|
|
50
|
+
export * from './tokens/xref-table-start-token.js';
|
|
@@ -6,7 +6,7 @@ export declare class PdfArray<T extends PdfObject = PdfObject> extends PdfObject
|
|
|
6
6
|
constructor(items?: T[]);
|
|
7
7
|
get length(): number;
|
|
8
8
|
push(item: T): void;
|
|
9
|
-
protected tokenize(): import("
|
|
9
|
+
protected tokenize(): import("..").PdfToken[];
|
|
10
10
|
clone(): this;
|
|
11
11
|
isModified(): boolean;
|
|
12
12
|
}
|
|
@@ -20,7 +20,7 @@ export declare class PdfIndirectObject<T extends PdfObject = PdfObject> extends
|
|
|
20
20
|
static createPlaceholder<T extends PdfObject>(objectNumber?: number, generationNumber?: number, content?: T): PdfIndirectObject<T extends unknown ? PdfNull : T>;
|
|
21
21
|
inPdf(): boolean;
|
|
22
22
|
matchesReference(ref?: PdfObjectReference): boolean;
|
|
23
|
-
protected tokenize(): import("
|
|
23
|
+
protected tokenize(): import("..").PdfToken[];
|
|
24
24
|
clone(): this;
|
|
25
25
|
order(): number;
|
|
26
26
|
isModified(): boolean;
|
|
@@ -4,7 +4,7 @@ import { PdfObject } from './pdf-object';
|
|
|
4
4
|
export declare class PdfStartXRef extends PdfObject {
|
|
5
5
|
offset: PdfNumber;
|
|
6
6
|
constructor(offset?: number | PdfNumber | Ref<number>);
|
|
7
|
-
protected tokenize(): import("
|
|
7
|
+
protected tokenize(): import("..").PdfToken[];
|
|
8
8
|
clone(): this;
|
|
9
9
|
isModified(): boolean;
|
|
10
10
|
}
|
|
@@ -42,7 +42,7 @@ export declare class PdfXRefTable extends PdfObject {
|
|
|
42
42
|
addEntryForObject(obj: PdfIndirectObject): void;
|
|
43
43
|
getEntry(objectNumber: number): PdfXRefTableEntry | undefined;
|
|
44
44
|
get lastSection(): PdfXRefTableSectionHeader | null;
|
|
45
|
-
protected tokenize(): import("
|
|
45
|
+
protected tokenize(): import("..").PdfToken[];
|
|
46
46
|
private sortEntriesIntoSections;
|
|
47
47
|
clone(): this;
|
|
48
48
|
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export * from './ciphers/aes128.js';
|
|
2
|
+
export * from './ciphers/aes256.js';
|
|
3
|
+
export * from './ciphers/rc4.js';
|
|
4
|
+
export * from './constants.js';
|
|
5
|
+
export * from './key-derivation/key-derivation-aes256.js';
|
|
6
|
+
export * from './key-derivation/key-derivation.js';
|
|
7
|
+
export * from './key-gen/key-gen-aes256.js';
|
|
8
|
+
export * from './key-gen/key-gen-rc4-128.js';
|
|
9
|
+
export * from './key-gen/key-gen-rc4-40.js';
|
|
10
|
+
export * from './types.js';
|
|
11
|
+
export * from './utils.js';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export * from './ciphers/aes128.js';
|
|
2
|
+
export * from './ciphers/aes256.js';
|
|
3
|
+
export * from './ciphers/rc4.js';
|
|
4
|
+
export * from './constants.js';
|
|
5
|
+
export * from './key-derivation/key-derivation-aes256.js';
|
|
6
|
+
export * from './key-derivation/key-derivation.js';
|
|
7
|
+
export * from './key-gen/key-gen-aes256.js';
|
|
8
|
+
export * from './key-gen/key-gen-rc4-128.js';
|
|
9
|
+
export * from './key-gen/key-gen-rc4-40.js';
|
|
10
|
+
export * from './types.js';
|
|
11
|
+
export * from './utils.js';
|
|
@@ -1,18 +1,4 @@
|
|
|
1
1
|
import { ByteArray } from '../../types.js';
|
|
2
|
-
/**
|
|
3
|
-
* Pads a password to exactly 32 bytes using the PDF standard padding.
|
|
4
|
-
* If the password is shorter than 32 bytes, it is padded with bytes from DEFAULT_PADDING.
|
|
5
|
-
* If the password is 32 bytes or longer, only the first 32 bytes are used.
|
|
6
|
-
*
|
|
7
|
-
* @param password - The password to pad.
|
|
8
|
-
* @returns A 32-byte padded password.
|
|
9
|
-
*
|
|
10
|
-
* @example
|
|
11
|
-
* ```typescript
|
|
12
|
-
* const padded = padPassword(new Uint8Array([1, 2, 3])) // Returns 32-byte array
|
|
13
|
-
* ```
|
|
14
|
-
*/
|
|
15
|
-
export declare function padPassword(password: ByteArray): ByteArray;
|
|
16
2
|
/**
|
|
17
3
|
* Compute the master encryption key for a PDF file.
|
|
18
4
|
*
|
|
@@ -1,31 +1,6 @@
|
|
|
1
|
-
import { DEFAULT_PADDING } from '../constants.js';
|
|
2
1
|
import { md5 } from '../../utils/algos.js';
|
|
3
|
-
import { int32ToLittleEndianBytes } from '../utils.js';
|
|
2
|
+
import { int32ToLittleEndianBytes, padPassword } from '../utils.js';
|
|
4
3
|
import { concatUint8Arrays } from '../../utils/concatUint8Arrays.js';
|
|
5
|
-
/**
|
|
6
|
-
* Pads a password to exactly 32 bytes using the PDF standard padding.
|
|
7
|
-
* If the password is shorter than 32 bytes, it is padded with bytes from DEFAULT_PADDING.
|
|
8
|
-
* If the password is 32 bytes or longer, only the first 32 bytes are used.
|
|
9
|
-
*
|
|
10
|
-
* @param password - The password to pad.
|
|
11
|
-
* @returns A 32-byte padded password.
|
|
12
|
-
*
|
|
13
|
-
* @example
|
|
14
|
-
* ```typescript
|
|
15
|
-
* const padded = padPassword(new Uint8Array([1, 2, 3])) // Returns 32-byte array
|
|
16
|
-
* ```
|
|
17
|
-
*/
|
|
18
|
-
export function padPassword(password) {
|
|
19
|
-
const padded = new Uint8Array(32);
|
|
20
|
-
if (password.length >= 32) {
|
|
21
|
-
padded.set(password.subarray(0, 32));
|
|
22
|
-
}
|
|
23
|
-
else {
|
|
24
|
-
padded.set(password);
|
|
25
|
-
padded.set(DEFAULT_PADDING.subarray(0, 32 - password.length), password.length);
|
|
26
|
-
}
|
|
27
|
-
return padded;
|
|
28
|
-
}
|
|
29
4
|
/**
|
|
30
5
|
* Compute the master encryption key for a PDF file.
|
|
31
6
|
*
|
|
@@ -2,8 +2,7 @@ import { md5 } from '../../utils/algos';
|
|
|
2
2
|
import { concatUint8Arrays } from '../../utils/concatUint8Arrays';
|
|
3
3
|
import { rc4 } from '../ciphers/rc4';
|
|
4
4
|
import { DEFAULT_PADDING } from '../constants';
|
|
5
|
-
import { padPassword } from '../
|
|
6
|
-
import { int32ToLittleEndianBytes, removePdfPasswordPadding } from '../utils';
|
|
5
|
+
import { int32ToLittleEndianBytes, padPassword, removePdfPasswordPadding, } from '../utils';
|
|
7
6
|
/**
|
|
8
7
|
* Encrypts data with RC4 using the provided key.
|
|
9
8
|
*
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { padPassword } from '../key-derivation/key-derivation.js';
|
|
2
1
|
import { rc4 } from '../ciphers/rc4.js';
|
|
3
2
|
import { DEFAULT_PADDING } from '../constants.js';
|
|
4
|
-
import { int32ToLittleEndianBytes, removePdfPasswordPadding } from '../utils.js';
|
|
3
|
+
import { int32ToLittleEndianBytes, padPassword, removePdfPasswordPadding, } from '../utils.js';
|
|
5
4
|
import { md5 } from '../../utils/algos.js';
|
|
6
5
|
import { concatUint8Arrays } from '../../utils/concatUint8Arrays.js';
|
|
7
6
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
export * from './types.js';
|
|
2
|
-
export * from './pdf/index.js';
|
|
3
2
|
export * from './core/index.js';
|
|
3
|
+
export * from './crypto/index.js';
|
|
4
|
+
export * from './filters/index.js';
|
|
5
|
+
export * from './pdf/index.js';
|
|
6
|
+
export * from './security/index.js';
|
|
4
7
|
export * from './signing/index.js';
|
|
8
|
+
export * from './utils/index.js';
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
export * from './types.js';
|
|
2
|
-
export * from './pdf/index.js';
|
|
3
2
|
export * from './core/index.js';
|
|
3
|
+
export * from './crypto/index.js';
|
|
4
|
+
export * from './filters/index.js';
|
|
5
|
+
export * from './pdf/index.js';
|
|
6
|
+
export * from './security/index.js';
|
|
4
7
|
export * from './signing/index.js';
|
|
8
|
+
export * from './utils/index.js';
|
package/dist/pdf/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
export * from './
|
|
2
|
-
export * from './pdf-
|
|
3
|
-
export * from './pdf-
|
|
4
|
-
export * from './pdf-
|
|
1
|
+
export * from './errors.js';
|
|
2
|
+
export * from './pdf-document.js';
|
|
3
|
+
export * from './pdf-reader.js';
|
|
4
|
+
export * from './pdf-revision.js';
|
|
5
|
+
export * from './pdf-xref-lookup.js';
|
package/dist/pdf/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
export * from './
|
|
2
|
-
export * from './pdf-
|
|
3
|
-
export * from './pdf-
|
|
4
|
-
export * from './pdf-
|
|
1
|
+
export * from './errors.js';
|
|
2
|
+
export * from './pdf-document.js';
|
|
3
|
+
export * from './pdf-reader.js';
|
|
4
|
+
export * from './pdf-revision.js';
|
|
5
|
+
export * from './pdf-xref-lookup.js';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export * from './crypt-filters/aesv2.js';
|
|
2
|
+
export * from './crypt-filters/aesv3.js';
|
|
3
|
+
export * from './crypt-filters/base.js';
|
|
4
|
+
export * from './crypt-filters/identity.js';
|
|
5
|
+
export * from './crypt-filters/v2.js';
|
|
6
|
+
export * from './handlers/base.js';
|
|
7
|
+
export * from './handlers/pubSec.js';
|
|
8
|
+
export * from './handlers/utils.js';
|
|
9
|
+
export * from './handlers/v1.js';
|
|
10
|
+
export * from './handlers/v2.js';
|
|
11
|
+
export * from './handlers/v4.js';
|
|
12
|
+
export * from './handlers/v5.js';
|
|
13
|
+
export * from './types.js';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export * from './crypt-filters/aesv2.js';
|
|
2
|
+
export * from './crypt-filters/aesv3.js';
|
|
3
|
+
export * from './crypt-filters/base.js';
|
|
4
|
+
export * from './crypt-filters/identity.js';
|
|
5
|
+
export * from './crypt-filters/v2.js';
|
|
6
|
+
export * from './handlers/base.js';
|
|
7
|
+
export * from './handlers/pubSec.js';
|
|
8
|
+
export * from './handlers/utils.js';
|
|
9
|
+
export * from './handlers/v1.js';
|
|
10
|
+
export * from './handlers/v2.js';
|
|
11
|
+
export * from './handlers/v4.js';
|
|
12
|
+
export * from './handlers/v5.js';
|
|
13
|
+
export * from './types.js';
|
package/dist/signing/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
export * from './
|
|
2
|
-
export * from './
|
|
3
|
-
export * from './
|
|
4
|
-
export * from './
|
|
1
|
+
export * from './document-security-store.js';
|
|
2
|
+
export * from './signatures/index.js';
|
|
3
|
+
export * from './signer.js';
|
|
4
|
+
export * from './types.js';
|
|
5
|
+
export * from './utils.js';
|
package/dist/signing/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
export * from './
|
|
2
|
-
export * from './
|
|
3
|
-
export * from './
|
|
4
|
-
export * from './
|
|
1
|
+
export * from './document-security-store.js';
|
|
2
|
+
export * from './signatures/index.js';
|
|
3
|
+
export * from './signer.js';
|
|
4
|
+
export * from './types.js';
|
|
5
|
+
export * from './utils.js';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export * from './IterableReadableStream.js';
|
|
2
|
+
export * from './algos.js';
|
|
3
|
+
export * from './assert.js';
|
|
4
|
+
export * from './bytesToHex.js';
|
|
5
|
+
export * from './bytesToHexBytes.js';
|
|
6
|
+
export * from './bytesToString.js';
|
|
7
|
+
export * from './concatUint8Arrays.js';
|
|
8
|
+
export * from './escapeString.js';
|
|
9
|
+
export * from './hexBytesToBytes.js';
|
|
10
|
+
export * from './hexBytesToString.js';
|
|
11
|
+
export * from './hexToBytes.js';
|
|
12
|
+
export * from './padBytes.js';
|
|
13
|
+
export * from './predictors.js';
|
|
14
|
+
export * from './replaceInBuffer.js';
|
|
15
|
+
export * from './stringToBytes.js';
|
|
16
|
+
export * from './stringToHexBytes.js';
|
|
17
|
+
export * from './unescapeString.js';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export * from './IterableReadableStream.js';
|
|
2
|
+
export * from './algos.js';
|
|
3
|
+
export * from './assert.js';
|
|
4
|
+
export * from './bytesToHex.js';
|
|
5
|
+
export * from './bytesToHexBytes.js';
|
|
6
|
+
export * from './bytesToString.js';
|
|
7
|
+
export * from './concatUint8Arrays.js';
|
|
8
|
+
export * from './escapeString.js';
|
|
9
|
+
export * from './hexBytesToBytes.js';
|
|
10
|
+
export * from './hexBytesToString.js';
|
|
11
|
+
export * from './hexToBytes.js';
|
|
12
|
+
export * from './padBytes.js';
|
|
13
|
+
export * from './predictors.js';
|
|
14
|
+
export * from './replaceInBuffer.js';
|
|
15
|
+
export * from './stringToBytes.js';
|
|
16
|
+
export * from './stringToHexBytes.js';
|
|
17
|
+
export * from './unescapeString.js';
|