muhammara 2.5.0 → 2.6.0

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/CHANGELOG.md CHANGED
@@ -7,6 +7,15 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [2.6.0] - 2022-06-30
11
+
12
+ ### Changed
13
+
14
+ - Fixes hard crash to exception when creating a stream with null object and calling createWriter with it
15
+ - Fixes missing buffer information for recrypt typescript definition
16
+ - Fixes missing options for append pdf pages
17
+ - Fixes NPE when stream is not readable in write stream object (PDFDocumentHandler)
18
+
10
19
  ## [2.5.0] - 2022-06-23
11
20
 
12
21
  ### Added
@@ -232,7 +241,8 @@ with the following changes.
232
241
 
233
242
  * Initial release
234
243
 
235
- [Unreleased]: https://github.com/julianhille/MuhammaraJS/compare/2.5.0...HEAD
244
+ [Unreleased]: https://github.com/julianhille/MuhammaraJS/compare/2.6.0...HEAD
245
+ [2.6.0]: https://github.com/julianhille/MuhammaraJS/compare/2.5.0...2.6.0
236
246
  [2.5.0]: https://github.com/julianhille/MuhammaraJS/compare/2.4.0...2.5.0
237
247
  [2.4.0]: https://github.com/julianhille/MuhammaraJS/compare/2.3.0...2.4.0
238
248
  [2.3.0]: https://github.com/julianhille/MuhammaraJS/compare/2.2.0...2.3.0
package/muhammara.d.ts CHANGED
@@ -40,8 +40,8 @@ declare module 'muhammara' {
40
40
  options?: PDFRecryptOptions,
41
41
  ): void;
42
42
  export function recrypt(
43
- originalPdfStream: PDFRStreamForFile,
44
- newPdfStream: PDFWStreamForFile,
43
+ originalPdfStream: PDFRStreamForFile | PDFRStreamForBuffer,
44
+ newPdfStream: PDFWStreamForFile | PDFWStreamForBuffer,
45
45
  options?: PDFRecryptOptions,
46
46
  ): void;
47
47
 
@@ -652,6 +652,8 @@ declare module 'muhammara' {
652
652
  specificRanges?: [[number, number]];
653
653
  }
654
654
 
655
+ export interface AppendOptions extends MergeOptions {}
656
+
655
657
  export type inInterPagesCallback = () => {}
656
658
 
657
659
 
@@ -680,7 +682,7 @@ declare module 'muhammara' {
680
682
  retrieveJPGImageInformation(filePath: FilePath): JPEGInformation;
681
683
  getObjectsContext(): ObjectsContext;
682
684
  getDocumentContext(): DocumentContext;
683
- appendPDFPagesFromPDF(source: FilePath | ReadStream): number[];
685
+ appendPDFPagesFromPDF(source: FilePath | ReadStream, options?: AppendOptions): number[];
684
686
  mergePDFPagesToPage(page: PDFPage, file: FilePath | PDFRStreamForFile, options?: MergeOptions, callback?: inInterPagesCallback): this;
685
687
  mergePDFPagesToPage(page: PDFPage, file: FilePath | PDFRStreamForFile, callback?: inInterPagesCallback) : this;
686
688
  createPDFCopyingContext(source: FilePath | ReadStream): DocumentCopyingContext;
@@ -76,8 +76,8 @@ export default class Minipass<
76
76
  // Options required if not reading buffers
77
77
  constructor(
78
78
  ...args: RType extends Buffer
79
- ? [options?: Options<RType>]
80
- : [options: Options<RType>]
79
+ ? [] | [Options<RType>]
80
+ : [Options<RType>]
81
81
  )
82
82
 
83
83
  write(chunk: WType, cb?: () => void): boolean
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "_from": "minipass@^3.0.0",
3
- "_id": "minipass@3.3.3",
3
+ "_id": "minipass@3.3.4",
4
4
  "_inBundle": false,
5
- "_integrity": "sha512-N0BOsdFAlNRfmwMhjAsLVWOk7Ljmeb39iqFlsV1At+jqRhSUP9yeof8FyJu4imaJiSUp8vQebWD/guZwGQC8iA==",
5
+ "_integrity": "sha512-I9WPbWHCGu8W+6k1ZiGpPu0GkoKBeorkfKNuAFBNS1HNFJvke82sxvI5bzcCNpWPorkOO5QQ+zomzzwRxejXiw==",
6
6
  "_location": "/minipass",
7
7
  "_phantomChildren": {},
8
8
  "_requested": {
@@ -20,8 +20,8 @@
20
20
  "/minizlib",
21
21
  "/tar"
22
22
  ],
23
- "_resolved": "https://registry.npmjs.org/minipass/-/minipass-3.3.3.tgz",
24
- "_shasum": "fd1f0e6c06449c10dadda72618b59c00f3d6378d",
23
+ "_resolved": "https://registry.npmjs.org/minipass/-/minipass-3.3.4.tgz",
24
+ "_shasum": "ca99f95dd77c43c7a76bf51e6d200025eee0ffae",
25
25
  "_spec": "minipass@^3.0.0",
26
26
  "_where": "/home/runner/work/MuhammaraJS/MuhammaraJS/node_modules/tar",
27
27
  "author": {
@@ -86,5 +86,5 @@
86
86
  "tap": {
87
87
  "check-coverage": true
88
88
  },
89
- "version": "3.3.3"
89
+ "version": "3.3.4"
90
90
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "muhammara",
3
- "version": "2.5.0",
3
+ "version": "2.6.0",
4
4
  "description": "Create, read and modify PDF files and streams. A drop in replacement for hummujs PDF library",
5
5
  "homepage": "https://github.com/julianhille/Muhammarajs",
6
6
  "license": "Apache-2.0",
@@ -52,12 +52,20 @@ IOBasicTypes::LongBufferSizeType ObjectByteWriterWithPosition::Write(const IOBas
52
52
 
53
53
  Local<Value> args[1];
54
54
  args[0] = anArray;
55
-
56
- Local<Value> result = func->Call(GET_CURRENT_CONTEXT, OBJECT_FROM_PERSISTENT(mObject), 1, args).ToLocalChecked();
55
+ MaybeLocal<Value> maybe;
56
+ TryCatch try_catch(Isolate::GetCurrent());
57
+
58
+ maybe = func->Call(GET_CURRENT_CONTEXT, OBJECT_FROM_PERSISTENT(mObject), 1, args);
59
+ Local <Value> result;
60
+
61
+ if (!maybe.ToLocal(&result)) {
62
+ try_catch.ReThrow();
63
+ return 0;
64
+ }
57
65
  if(result.IsEmpty())
58
66
  {
59
- THROW_EXCEPTION("wrong return value. it's empty. return the number of written characters");
60
- return 0;
67
+ THROW_EXCEPTION("wrong return value. it's empty. return the number of written characters");
68
+ return 0;
61
69
  }
62
70
  else if(result->IsNumber())
63
71
  {
@@ -65,8 +73,8 @@ IOBasicTypes::LongBufferSizeType ObjectByteWriterWithPosition::Write(const IOBas
65
73
  }
66
74
  else
67
75
  {
68
- THROW_EXCEPTION("wrong return value. write should return the number of written characters");
69
- return 0;
76
+ THROW_EXCEPTION("wrong return value. write should return the number of written characters");
77
+ return 0;
70
78
  }
71
79
  }
72
80
 
@@ -81,4 +89,4 @@ IOBasicTypes::LongFilePositionType ObjectByteWriterWithPosition::GetCurrentPosit
81
89
  Local<Function> func = Local<Function>::Cast(value);
82
90
 
83
91
  return TO_NUMBER(func->Call(GET_CURRENT_CONTEXT, OBJECT_FROM_PERSISTENT(mObject), 0, NULL).ToLocalChecked())->Value();
84
- }
92
+ }
@@ -2032,6 +2032,10 @@ EStatusCode PDFDocumentHandler::WriteStreamObject(PDFStreamInput* inStream, IObj
2032
2032
  if(!readingDecrypted) {
2033
2033
  streamReader = mParser->StartReadingFromStreamForPlainCopying(inStream);
2034
2034
  }
2035
+
2036
+ if (streamReader == NULL) {
2037
+ status = PDFHummus::eFailure;
2038
+ }
2035
2039
 
2036
2040
  while (it.MoveNext() && PDFHummus::eSuccess == status)
2037
2041
  {