muhammara 2.5.0 → 2.6.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/CHANGELOG.md CHANGED
@@ -7,6 +7,21 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [2.6.1] - 2022-10-23
11
+
12
+ ### Fixed
13
+
14
+ - Backport: NPE in parser when file ends before it really starts
15
+
16
+ ## [2.6.0] - 2022-06-30
17
+
18
+ ### Changed
19
+
20
+ - Fixes hard crash to exception when creating a stream with null object and calling createWriter with it
21
+ - Fixes missing buffer information for recrypt typescript definition
22
+ - Fixes missing options for append pdf pages
23
+ - Fixes NPE when stream is not readable in write stream object (PDFDocumentHandler)
24
+
10
25
  ## [2.5.0] - 2022-06-23
11
26
 
12
27
  ### Added
@@ -232,7 +247,9 @@ with the following changes.
232
247
 
233
248
  * Initial release
234
249
 
235
- [Unreleased]: https://github.com/julianhille/MuhammaraJS/compare/2.5.0...HEAD
250
+ [Unreleased]: https://github.com/julianhille/MuhammaraJS/compare/2.6.1...HEAD
251
+ [2.6.1]: https://github.com/julianhille/MuhammaraJS/compare/2.6.0...2.6.1
252
+ [2.6.0]: https://github.com/julianhille/MuhammaraJS/compare/2.5.0...2.6.0
236
253
  [2.5.0]: https://github.com/julianhille/MuhammaraJS/compare/2.4.0...2.5.0
237
254
  [2.4.0]: https://github.com/julianhille/MuhammaraJS/compare/2.3.0...2.4.0
238
255
  [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;
@@ -1,5 +1,8 @@
1
1
  # node-pre-gyp changelog
2
2
 
3
+ ## 1.0.10
4
+ - Upgraded minimist to 1.2.6 to address dependabot alert [CVE-2021-44906](https://nvd.nist.gov/vuln/detail/CVE-2021-44906)
5
+
3
6
  ## 1.0.9
4
7
  - Upgraded node-fetch to 2.6.7 to address [CVE-2022-0235](https://www.cve.org/CVERecord?id=CVE-2022-0235)
5
8
  - Upgraded detect-libc to 2.0.0 to use non-blocking NodeJS(>=12) Report API
@@ -81,7 +81,7 @@ Options include:
81
81
  - `--runtime=node-webkit`: customize the runtime: `node`, `electron` and `node-webkit` are the valid options
82
82
  - `--fallback-to-build`: fallback to building from source if pre-built binary is not available
83
83
  - `--target=0.4.0`: Pass the target node or node-webkit version to compile against
84
- - `--target_arch=ia32`: Pass the target arch and override the host `arch`. Valid values are 'ia32','x64', or `arm`.
84
+ - `--target_arch=ia32`: Pass the target arch and override the host `arch`. Any value that is [supported by Node.js](https://nodejs.org/api/os.html#osarch) is valid.
85
85
  - `--target_platform=win32`: Pass the target platform and override the host `platform`. Valid values are `linux`, `darwin`, `win32`, `sunos`, `freebsd`, `openbsd`, and `aix`.
86
86
 
87
87
  Both `--build-from-source` and `--fallback-to-build` can be passed alone or they can provide values. You can pass `--fallback-to-build=false` to override the option as declared in package.json. In addition to being able to pass `--build-from-source` you can also pass `--build-from-source=myapp` where `myapp` is the name of your module.
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "_from": "@mapbox/node-pre-gyp@^1.0.5",
3
- "_id": "@mapbox/node-pre-gyp@1.0.9",
3
+ "_id": "@mapbox/node-pre-gyp@1.0.10",
4
4
  "_inBundle": false,
5
- "_integrity": "sha512-aDF3S3rK9Q2gey/WAttUlISduDItz5BU3306M9Eyv6/oS40aMprnopshtlKTykxRNIBEZuRMaZAnbrQ4QtKGyw==",
5
+ "_integrity": "sha512-4ySo4CjzStuprMwk35H5pPbkymjv1SF3jGLj6rAHp/xT/RF7TL7bd9CTm1xDY49K2qF7jmR/g7k+SkLETP6opA==",
6
6
  "_location": "/@mapbox/node-pre-gyp",
7
7
  "_phantomChildren": {},
8
8
  "_requested": {
@@ -19,8 +19,8 @@
19
19
  "_requiredBy": [
20
20
  "/"
21
21
  ],
22
- "_resolved": "https://registry.npmjs.org/@mapbox/node-pre-gyp/-/node-pre-gyp-1.0.9.tgz",
23
- "_shasum": "09a8781a3a036151cdebbe8719d6f8b25d4058bc",
22
+ "_resolved": "https://registry.npmjs.org/@mapbox/node-pre-gyp/-/node-pre-gyp-1.0.10.tgz",
23
+ "_shasum": "8e6735ccebbb1581e5a7e652244cadc8a844d03c",
24
24
  "_spec": "@mapbox/node-pre-gyp@^1.0.5",
25
25
  "_where": "/home/runner/work/MuhammaraJS/MuhammaraJS",
26
26
  "author": {
@@ -93,5 +93,5 @@
93
93
  "update-crosswalk": "node scripts/abi_crosswalk.js",
94
94
  "upload-coverage": "nyc report --reporter json && codecov --clear --flags=unit --file=./coverage/coverage-final.json"
95
95
  },
96
- "version": "1.0.9"
96
+ "version": "1.0.10"
97
97
  }
@@ -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
  }
@@ -252,6 +252,7 @@ const isX = id => !id || id.toLowerCase() === 'x' || id === '*'
252
252
  // ~1.2, ~1.2.x, ~>1.2, ~>1.2.x --> >=1.2.0 <1.3.0-0
253
253
  // ~1.2.3, ~>1.2.3 --> >=1.2.3 <1.3.0-0
254
254
  // ~1.2.0, ~>1.2.0 --> >=1.2.0 <1.3.0-0
255
+ // ~0.0.1 --> >=0.0.1 <0.1.0-0
255
256
  const replaceTildes = (comp, options) =>
256
257
  comp.trim().split(/\s+/).map((c) => {
257
258
  return replaceTilde(c, options)
@@ -291,6 +292,8 @@ const replaceTilde = (comp, options) => {
291
292
  // ^1.2, ^1.2.x --> >=1.2.0 <2.0.0-0
292
293
  // ^1.2.3 --> >=1.2.3 <2.0.0-0
293
294
  // ^1.2.0 --> >=1.2.0 <2.0.0-0
295
+ // ^0.0.1 --> >=0.0.1 <0.0.2-0
296
+ // ^0.1.0 --> >=0.1.0 <0.2.0-0
294
297
  const replaceCarets = (comp, options) =>
295
298
  comp.trim().split(/\s+/).map((c) => {
296
299
  return replaceCaret(c, options)
@@ -1,48 +1,88 @@
1
1
  // just pre-load all the stuff that index.js lazily exports
2
2
  const internalRe = require('./internal/re')
3
+ const constants = require('./internal/constants')
4
+ const SemVer = require('./classes/semver')
5
+ const identifiers = require('./internal/identifiers')
6
+ const parse = require('./functions/parse')
7
+ const valid = require('./functions/valid')
8
+ const clean = require('./functions/clean')
9
+ const inc = require('./functions/inc')
10
+ const diff = require('./functions/diff')
11
+ const major = require('./functions/major')
12
+ const minor = require('./functions/minor')
13
+ const patch = require('./functions/patch')
14
+ const prerelease = require('./functions/prerelease')
15
+ const compare = require('./functions/compare')
16
+ const rcompare = require('./functions/rcompare')
17
+ const compareLoose = require('./functions/compare-loose')
18
+ const compareBuild = require('./functions/compare-build')
19
+ const sort = require('./functions/sort')
20
+ const rsort = require('./functions/rsort')
21
+ const gt = require('./functions/gt')
22
+ const lt = require('./functions/lt')
23
+ const eq = require('./functions/eq')
24
+ const neq = require('./functions/neq')
25
+ const gte = require('./functions/gte')
26
+ const lte = require('./functions/lte')
27
+ const cmp = require('./functions/cmp')
28
+ const coerce = require('./functions/coerce')
29
+ const Comparator = require('./classes/comparator')
30
+ const Range = require('./classes/range')
31
+ const satisfies = require('./functions/satisfies')
32
+ const toComparators = require('./ranges/to-comparators')
33
+ const maxSatisfying = require('./ranges/max-satisfying')
34
+ const minSatisfying = require('./ranges/min-satisfying')
35
+ const minVersion = require('./ranges/min-version')
36
+ const validRange = require('./ranges/valid')
37
+ const outside = require('./ranges/outside')
38
+ const gtr = require('./ranges/gtr')
39
+ const ltr = require('./ranges/ltr')
40
+ const intersects = require('./ranges/intersects')
41
+ const simplifyRange = require('./ranges/simplify')
42
+ const subset = require('./ranges/subset')
3
43
  module.exports = {
44
+ parse,
45
+ valid,
46
+ clean,
47
+ inc,
48
+ diff,
49
+ major,
50
+ minor,
51
+ patch,
52
+ prerelease,
53
+ compare,
54
+ rcompare,
55
+ compareLoose,
56
+ compareBuild,
57
+ sort,
58
+ rsort,
59
+ gt,
60
+ lt,
61
+ eq,
62
+ neq,
63
+ gte,
64
+ lte,
65
+ cmp,
66
+ coerce,
67
+ Comparator,
68
+ Range,
69
+ satisfies,
70
+ toComparators,
71
+ maxSatisfying,
72
+ minSatisfying,
73
+ minVersion,
74
+ validRange,
75
+ outside,
76
+ gtr,
77
+ ltr,
78
+ intersects,
79
+ simplifyRange,
80
+ subset,
81
+ SemVer,
4
82
  re: internalRe.re,
5
83
  src: internalRe.src,
6
84
  tokens: internalRe.t,
7
- SEMVER_SPEC_VERSION: require('./internal/constants').SEMVER_SPEC_VERSION,
8
- SemVer: require('./classes/semver'),
9
- compareIdentifiers: require('./internal/identifiers').compareIdentifiers,
10
- rcompareIdentifiers: require('./internal/identifiers').rcompareIdentifiers,
11
- parse: require('./functions/parse'),
12
- valid: require('./functions/valid'),
13
- clean: require('./functions/clean'),
14
- inc: require('./functions/inc'),
15
- diff: require('./functions/diff'),
16
- major: require('./functions/major'),
17
- minor: require('./functions/minor'),
18
- patch: require('./functions/patch'),
19
- prerelease: require('./functions/prerelease'),
20
- compare: require('./functions/compare'),
21
- rcompare: require('./functions/rcompare'),
22
- compareLoose: require('./functions/compare-loose'),
23
- compareBuild: require('./functions/compare-build'),
24
- sort: require('./functions/sort'),
25
- rsort: require('./functions/rsort'),
26
- gt: require('./functions/gt'),
27
- lt: require('./functions/lt'),
28
- eq: require('./functions/eq'),
29
- neq: require('./functions/neq'),
30
- gte: require('./functions/gte'),
31
- lte: require('./functions/lte'),
32
- cmp: require('./functions/cmp'),
33
- coerce: require('./functions/coerce'),
34
- Comparator: require('./classes/comparator'),
35
- Range: require('./classes/range'),
36
- satisfies: require('./functions/satisfies'),
37
- toComparators: require('./ranges/to-comparators'),
38
- maxSatisfying: require('./ranges/max-satisfying'),
39
- minSatisfying: require('./ranges/min-satisfying'),
40
- minVersion: require('./ranges/min-version'),
41
- validRange: require('./ranges/valid'),
42
- outside: require('./ranges/outside'),
43
- gtr: require('./ranges/gtr'),
44
- ltr: require('./ranges/ltr'),
45
- intersects: require('./ranges/intersects'),
46
- simplifyRange: require('./ranges/simplify'),
47
- subset: require('./ranges/subset'),
85
+ SEMVER_SPEC_VERSION: constants.SEMVER_SPEC_VERSION,
86
+ compareIdentifiers: identifiers.compareIdentifiers,
87
+ rcompareIdentifiers: identifiers.rcompareIdentifiers,
48
88
  }
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "_from": "semver@^7.3.5",
3
- "_id": "semver@7.3.7",
3
+ "_id": "semver@7.3.8",
4
4
  "_inBundle": false,
5
- "_integrity": "sha512-QlYTucUYOews+WeEujDoEGziz4K6c47V/Bd+LjSSYcA94p+DmINdf7ncaUinThfvZyu13lN9OY1XDxt8C0Tw0g==",
5
+ "_integrity": "sha512-NB1ctGL5rlHrPJtFDVIVzTyQylMLu9N9VICA6HSFJo8MCGVTMW6gfpicwKmmK/dAjTOrqu5l63JJOpDSrAis3A==",
6
6
  "_location": "/semver",
7
7
  "_phantomChildren": {},
8
8
  "_requested": {
@@ -18,8 +18,8 @@
18
18
  "_requiredBy": [
19
19
  "/@mapbox/node-pre-gyp"
20
20
  ],
21
- "_resolved": "https://registry.npmjs.org/semver/-/semver-7.3.7.tgz",
22
- "_shasum": "12c5b649afdbf9049707796e22a4028814ce523f",
21
+ "_resolved": "https://registry.npmjs.org/semver/-/semver-7.3.8.tgz",
22
+ "_shasum": "07a78feafb3f7b32347d725e33de7e2a2df67798",
23
23
  "_spec": "semver@^7.3.5",
24
24
  "_where": "/home/runner/work/MuhammaraJS/MuhammaraJS/node_modules/@mapbox/node-pre-gyp",
25
25
  "author": {
@@ -39,7 +39,7 @@
39
39
  "description": "The semantic version parser used by npm.",
40
40
  "devDependencies": {
41
41
  "@npmcli/eslint-config": "^3.0.1",
42
- "@npmcli/template-oss": "3.3.2",
42
+ "@npmcli/template-oss": "4.4.4",
43
43
  "tap": "^16.0.0"
44
44
  },
45
45
  "engines": {
@@ -47,6 +47,7 @@
47
47
  },
48
48
  "files": [
49
49
  "bin/",
50
+ "lib/",
50
51
  "classes/",
51
52
  "functions/",
52
53
  "internal/",
@@ -67,32 +68,33 @@
67
68
  "lint": "eslint \"**/*.js\"",
68
69
  "lintfix": "npm run lint -- --fix",
69
70
  "postlint": "template-oss-check",
70
- "postpublish": "git push origin --follow-tags",
71
71
  "posttest": "npm run lint",
72
- "postversion": "npm publish",
73
- "prepublishOnly": "git push origin --follow-tags",
74
- "preversion": "npm test",
75
72
  "snap": "tap",
76
73
  "template-oss-apply": "template-oss-apply --force",
77
74
  "test": "tap"
78
75
  },
79
76
  "tap": {
80
77
  "check-coverage": true,
81
- "coverage-map": "map.js"
78
+ "coverage-map": "map.js",
79
+ "nyc-arg": [
80
+ "--exclude",
81
+ "tap-snapshots/**"
82
+ ]
82
83
  },
83
84
  "templateOSS": {
84
85
  "//@npmcli/template-oss": "This file is partially managed by @npmcli/template-oss. Edits may be overwritten.",
85
- "version": "3.3.2",
86
+ "version": "4.4.4",
86
87
  "engines": ">=10",
88
+ "content": "./scripts",
87
89
  "ciVersions": [
88
90
  "10.0.0",
89
91
  "10.x",
90
92
  "12.x",
91
93
  "14.x",
92
- "16.x"
94
+ "16.x",
95
+ "18.x"
93
96
  ],
94
97
  "distPaths": [
95
- "bin/",
96
98
  "classes/",
97
99
  "functions/",
98
100
  "internal/",
@@ -100,7 +102,16 @@
100
102
  "index.js",
101
103
  "preload.js",
102
104
  "range.bnf"
105
+ ],
106
+ "allowPaths": [
107
+ "/classes/",
108
+ "/functions/",
109
+ "/internal/",
110
+ "/ranges/",
111
+ "/index.js",
112
+ "/preload.js",
113
+ "/range.bnf"
103
114
  ]
104
115
  },
105
- "version": "7.3.7"
116
+ "version": "7.3.8"
106
117
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "muhammara",
3
- "version": "2.5.0",
3
+ "version": "2.6.1",
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
  {
@@ -352,6 +352,12 @@ EStatusCode PDFParser::ParseLastXrefPosition()
352
352
  mObjectParser.ResetReadState();
353
353
  RefCountPtr<PDFObject> anObject(mObjectParser.ParseNewObject());
354
354
 
355
+ if (!anObject) {
356
+ status = PDFHummus::eFailure;
357
+ TRACE_LOG("PDFParser::ParseXrefPosition: Unable to find any object");
358
+ break;
359
+ }
360
+
355
361
  if(anObject->GetType() == PDFObject::ePDFObjectInteger)
356
362
  {
357
363
  mLastXrefPosition = (LongFilePositionType)((PDFInteger*)anObject.GetPtr())->GetValue();