@pdfme/pdf-lib 6.1.11 → 6.1.12

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/dist/index.js CHANGED
@@ -5,7 +5,7 @@ import ColorParser from "color";
5
5
  import { NodeType, parse } from "node-html-better-parser";
6
6
  //#region src/utils/base64.ts
7
7
  var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
8
- var lookup = new Uint8Array(256);
8
+ var lookup = /* @__PURE__ */ new Uint8Array(256);
9
9
  for (let i = 0; i < 64; i++) lookup[chars.charCodeAt(i)] = i;
10
10
  var encodeToBase64 = (bytes) => {
11
11
  let base64 = "";
@@ -756,7 +756,7 @@ var assertPositive = (value, valueName) => {
756
756
  };
757
757
  //#endregion
758
758
  //#region src/utils/pdfDocEncoding.ts
759
- var pdfDocEncodingToUnicode = new Uint16Array(256);
759
+ var pdfDocEncodingToUnicode = /* @__PURE__ */ new Uint16Array(256);
760
760
  for (let idx = 0; idx < 256; idx++) pdfDocEncodingToUnicode[idx] = idx;
761
761
  pdfDocEncodingToUnicode[22] = toCharCode("");
762
762
  pdfDocEncodingToUnicode[24] = toCharCode("˘");
@@ -814,7 +814,7 @@ var pdfDocEncodingDecode = (bytes) => {
814
814
  return String.fromCodePoint(...codePoints);
815
815
  };
816
816
  //#endregion
817
- //#region \0@oxc-project+runtime@0.132.0/helpers/typeof.js
817
+ //#region \0@oxc-project+runtime@0.137.0/helpers/esm/typeof.js
818
818
  function _typeof(o) {
819
819
  "@babel/helpers - typeof";
820
820
  return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
@@ -824,7 +824,7 @@ function _typeof(o) {
824
824
  }, _typeof(o);
825
825
  }
826
826
  //#endregion
827
- //#region \0@oxc-project+runtime@0.132.0/helpers/toPrimitive.js
827
+ //#region \0@oxc-project+runtime@0.137.0/helpers/esm/toPrimitive.js
828
828
  function toPrimitive(t, r) {
829
829
  if ("object" != _typeof(t) || !t) return t;
830
830
  var e = t[Symbol.toPrimitive];
@@ -836,13 +836,13 @@ function toPrimitive(t, r) {
836
836
  return ("string" === r ? String : Number)(t);
837
837
  }
838
838
  //#endregion
839
- //#region \0@oxc-project+runtime@0.132.0/helpers/toPropertyKey.js
839
+ //#region \0@oxc-project+runtime@0.137.0/helpers/esm/toPropertyKey.js
840
840
  function toPropertyKey(t) {
841
841
  var i = toPrimitive(t, "string");
842
842
  return "symbol" == _typeof(i) ? i : i + "";
843
843
  }
844
844
  //#endregion
845
- //#region \0@oxc-project+runtime@0.132.0/helpers/defineProperty.js
845
+ //#region \0@oxc-project+runtime@0.137.0/helpers/esm/defineProperty.js
846
846
  function _defineProperty(e, r, t) {
847
847
  return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
848
848
  value: t,
@@ -1335,7 +1335,7 @@ _defineProperty(PDFBool, "True", new _PDFBool(ENFORCER$2, true));
1335
1335
  _defineProperty(PDFBool, "False", new _PDFBool(ENFORCER$2, false));
1336
1336
  //#endregion
1337
1337
  //#region src/core/syntax/Delimiters.ts
1338
- var IsDelimiter = new Uint8Array(256);
1338
+ var IsDelimiter = /* @__PURE__ */ new Uint8Array(256);
1339
1339
  IsDelimiter[CharCodes.LeftParen] = 1;
1340
1340
  IsDelimiter[CharCodes.RightParen] = 1;
1341
1341
  IsDelimiter[CharCodes.LessThan] = 1;
@@ -1348,7 +1348,7 @@ IsDelimiter[CharCodes.ForwardSlash] = 1;
1348
1348
  IsDelimiter[CharCodes.Percent] = 1;
1349
1349
  //#endregion
1350
1350
  //#region src/core/syntax/Whitespace.ts
1351
- var IsWhitespace = new Uint8Array(256);
1351
+ var IsWhitespace = /* @__PURE__ */ new Uint8Array(256);
1352
1352
  IsWhitespace[CharCodes.Null] = 1;
1353
1353
  IsWhitespace[CharCodes.Tab] = 1;
1354
1354
  IsWhitespace[CharCodes.Newline] = 1;
@@ -1357,7 +1357,7 @@ IsWhitespace[CharCodes.CarriageReturn] = 1;
1357
1357
  IsWhitespace[CharCodes.Space] = 1;
1358
1358
  //#endregion
1359
1359
  //#region src/core/syntax/Irregular.ts
1360
- var IsIrregular = new Uint8Array(256);
1360
+ var IsIrregular = /* @__PURE__ */ new Uint8Array(256);
1361
1361
  for (let idx = 0, len = 256; idx < len; idx++) IsIrregular[idx] = IsWhitespace[idx] || IsDelimiter[idx] ? 1 : 0;
1362
1362
  IsIrregular[CharCodes.Hash] = 1;
1363
1363
  //#endregion
@@ -3849,7 +3849,7 @@ var Stream = class Stream {
3849
3849
  };
3850
3850
  //#endregion
3851
3851
  //#region src/core/streams/DecodeStream.ts
3852
- var emptyBuffer = new Uint8Array(0);
3852
+ var emptyBuffer = /* @__PURE__ */ new Uint8Array(0);
3853
3853
  /**
3854
3854
  * Maximum allowed decoded buffer size (100 MB).
3855
3855
  * Prevents decompression bomb attacks from consuming unbounded memory.
@@ -3970,7 +3970,7 @@ var Ascii85Stream = class extends DecodeStream {
3970
3970
  _defineProperty(this, "stream", void 0);
3971
3971
  _defineProperty(this, "input", void 0);
3972
3972
  this.stream = stream;
3973
- this.input = new Uint8Array(5);
3973
+ this.input = /* @__PURE__ */ new Uint8Array(5);
3974
3974
  if (maybeLength) maybeLength = .8 * maybeLength;
3975
3975
  }
3976
3976
  readBlock() {
@@ -6860,7 +6860,7 @@ _defineProperty(PDFPageTree, "withContext", (context, parent) => {
6860
6860
  _defineProperty(PDFPageTree, "fromMapWithContext", (map, context) => new _PDFPageTree(map, context));
6861
6861
  //#endregion
6862
6862
  //#region src/core/syntax/Numeric.ts
6863
- var IsDigit = new Uint8Array(256);
6863
+ var IsDigit = /* @__PURE__ */ new Uint8Array(256);
6864
6864
  IsDigit[CharCodes.Zero] = 1;
6865
6865
  IsDigit[CharCodes.One] = 1;
6866
6866
  IsDigit[CharCodes.Two] = 1;
@@ -6871,11 +6871,11 @@ IsDigit[CharCodes.Six] = 1;
6871
6871
  IsDigit[CharCodes.Seven] = 1;
6872
6872
  IsDigit[CharCodes.Eight] = 1;
6873
6873
  IsDigit[CharCodes.Nine] = 1;
6874
- var IsNumericPrefix = new Uint8Array(256);
6874
+ var IsNumericPrefix = /* @__PURE__ */ new Uint8Array(256);
6875
6875
  IsNumericPrefix[CharCodes.Period] = 1;
6876
6876
  IsNumericPrefix[CharCodes.Plus] = 1;
6877
6877
  IsNumericPrefix[CharCodes.Minus] = 1;
6878
- var IsNumeric = new Uint8Array(256);
6878
+ var IsNumeric = /* @__PURE__ */ new Uint8Array(256);
6879
6879
  for (let idx = 0, len = 256; idx < len; idx++) IsNumeric[idx] = IsDigit[idx] || IsNumericPrefix[idx] ? 1 : 0;
6880
6880
  //#endregion
6881
6881
  //#region src/core/parser/BaseParser.ts
@@ -8010,7 +8010,7 @@ var px = 0;
8010
8010
  var py = 0;
8011
8011
  var sx = 0;
8012
8012
  var sy = 0;
8013
- var parameters = new Map([
8013
+ var parameters = /* @__PURE__ */ new Map([
8014
8014
  ["A", 7],
8015
8015
  ["a", 7],
8016
8016
  ["C", 6],
@@ -13287,7 +13287,7 @@ var ARCFourCipher = class {
13287
13287
  _defineProperty(this, "b", void 0);
13288
13288
  this.a = 0;
13289
13289
  this.b = 0;
13290
- const s = new Uint8Array(256);
13290
+ const s = /* @__PURE__ */ new Uint8Array(256);
13291
13291
  const keyLength = key.length;
13292
13292
  for (let i = 0; i < 256; ++i) s[i] = i;
13293
13293
  for (let i = 0, j = 0; i < 256; ++i) {
@@ -13473,7 +13473,7 @@ var calculateMD5 = (function calculateMD5Closure() {
13473
13473
  padded[i++] = 0;
13474
13474
  padded[i++] = 0;
13475
13475
  padded[i++] = 0;
13476
- const w = new Int32Array(16);
13476
+ const w = /* @__PURE__ */ new Int32Array(16);
13477
13477
  for (i = 0; i < paddedLength;) {
13478
13478
  for (j = 0; j < 16; ++j, i += 4) w[j] = padded[i] | padded[i + 1] << 8 | padded[i + 2] << 16 | padded[i + 3] << 24;
13479
13479
  let a = h0, b = h1, c = h2, d = h3, f, g;
@@ -13704,7 +13704,7 @@ var calculateSHA256 = (function calculateSHA256Closure() {
13704
13704
  padded[i++] = length >> 13 & 255;
13705
13705
  padded[i++] = length >> 5 & 255;
13706
13706
  padded[i++] = length << 3 & 255;
13707
- const w = new Uint32Array(64);
13707
+ const w = /* @__PURE__ */ new Uint32Array(64);
13708
13708
  for (i = 0; i < paddedLength;) {
13709
13709
  for (j = 0; j < 16; ++j) {
13710
13710
  w[j] = padded[i] << 24 | padded[i + 1] << 16 | padded[i + 2] << 8 | padded[i + 3];
@@ -14020,7 +14020,7 @@ var calculateSHA512 = (function calculateSHA512Closure() {
14020
14020
  }
14021
14021
  let result;
14022
14022
  if (!mode384) {
14023
- result = new Uint8Array(64);
14023
+ result = /* @__PURE__ */ new Uint8Array(64);
14024
14024
  h0.copyTo(result, 0);
14025
14025
  h1.copyTo(result, 8);
14026
14026
  h2.copyTo(result, 16);
@@ -14030,7 +14030,7 @@ var calculateSHA512 = (function calculateSHA512Closure() {
14030
14030
  h6.copyTo(result, 48);
14031
14031
  h7.copyTo(result, 56);
14032
14032
  } else {
14033
- result = new Uint8Array(48);
14033
+ result = /* @__PURE__ */ new Uint8Array(48);
14034
14034
  h0.copyTo(result, 0);
14035
14035
  h1.copyTo(result, 8);
14036
14036
  h2.copyTo(result, 16);
@@ -14841,10 +14841,10 @@ var AESBaseCipher = class AESBaseCipher {
14841
14841
  2203032232,
14842
14842
  2370213795
14843
14843
  ]);
14844
- this._mixCol = new Uint8Array(256);
14844
+ this._mixCol = /* @__PURE__ */ new Uint8Array(256);
14845
14845
  for (let i = 0; i < 256; i++) if (i < 128) this._mixCol[i] = i << 1;
14846
14846
  else this._mixCol[i] = i << 1 ^ 27;
14847
- this.buffer = new Uint8Array(16);
14847
+ this.buffer = /* @__PURE__ */ new Uint8Array(16);
14848
14848
  this.bufferPosition = 0;
14849
14849
  }
14850
14850
  _expandKey(_cipherKey) {
@@ -14852,7 +14852,7 @@ var AESBaseCipher = class AESBaseCipher {
14852
14852
  }
14853
14853
  _decrypt(input, key) {
14854
14854
  let t, u, v;
14855
- const state = new Uint8Array(16);
14855
+ const state = /* @__PURE__ */ new Uint8Array(16);
14856
14856
  state.set(input);
14857
14857
  for (let j = 0, k = this._keySize; j < 16; ++j, ++k) state[j] ^= key[k];
14858
14858
  for (let i = this._cyclesOfRepetition - 1; i >= 1; --i) {
@@ -14915,7 +14915,7 @@ var AESBaseCipher = class AESBaseCipher {
14915
14915
  _encrypt(input, key) {
14916
14916
  const s = this._s;
14917
14917
  let t, u, v;
14918
- const state = new Uint8Array(16);
14918
+ const state = /* @__PURE__ */ new Uint8Array(16);
14919
14919
  state.set(input);
14920
14920
  for (let j = 0; j < 16; ++j) state[j] ^= key[j];
14921
14921
  for (let i = 1; i < this._cyclesOfRepetition; i++) {
@@ -14986,13 +14986,13 @@ var AESBaseCipher = class AESBaseCipher {
14986
14986
  for (let j = 0; j < 16; ++j) plain[j] ^= iv[j];
14987
14987
  iv = buffer;
14988
14988
  result.push(plain);
14989
- buffer = new Uint8Array(16);
14989
+ buffer = /* @__PURE__ */ new Uint8Array(16);
14990
14990
  bufferLength = 0;
14991
14991
  }
14992
14992
  this.buffer = buffer;
14993
14993
  this.bufferLength = bufferLength;
14994
14994
  this.iv = iv;
14995
- if (result.length === 0) return new Uint8Array(0);
14995
+ if (result.length === 0) return /* @__PURE__ */ new Uint8Array(0);
14996
14996
  let outputLength = 16 * result.length;
14997
14997
  if (finalize) {
14998
14998
  const lastBlock = result[result.length - 1];
@@ -15019,12 +15019,12 @@ var AESBaseCipher = class AESBaseCipher {
15019
15019
  for (let i = 0; bufferLength < 16 && i < sourceLength; ++i, ++bufferLength) buffer[bufferLength] = data[i];
15020
15020
  if (bufferLength < 16) {
15021
15021
  this.bufferLength = bufferLength;
15022
- return new Uint8Array(0);
15022
+ return /* @__PURE__ */ new Uint8Array(0);
15023
15023
  }
15024
15024
  this.iv = buffer;
15025
15025
  data = data.subarray(16);
15026
15026
  }
15027
- this.buffer = new Uint8Array(16);
15027
+ this.buffer = /* @__PURE__ */ new Uint8Array(16);
15028
15028
  this.bufferLength = 0;
15029
15029
  this.decryptBlock = this._decryptBlock2;
15030
15030
  return this.decryptBlock(data, finalize);
@@ -15033,7 +15033,7 @@ var AESBaseCipher = class AESBaseCipher {
15033
15033
  const sourceLength = data.length;
15034
15034
  let buffer = this.buffer, bufferLength = this.bufferPosition;
15035
15035
  const result = [];
15036
- if (!iv) iv = new Uint8Array(16);
15036
+ if (!iv) iv = /* @__PURE__ */ new Uint8Array(16);
15037
15037
  for (let i = 0; i < sourceLength; ++i) {
15038
15038
  buffer[bufferLength] = data[i];
15039
15039
  ++bufferLength;
@@ -15042,13 +15042,13 @@ var AESBaseCipher = class AESBaseCipher {
15042
15042
  const cipher = this._encrypt(buffer, this._key);
15043
15043
  iv = cipher;
15044
15044
  result.push(cipher);
15045
- buffer = new Uint8Array(16);
15045
+ buffer = /* @__PURE__ */ new Uint8Array(16);
15046
15046
  bufferLength = 0;
15047
15047
  }
15048
15048
  this.buffer = buffer;
15049
15049
  this.bufferLength = bufferLength;
15050
15050
  this.iv = iv;
15051
- if (result.length === 0) return new Uint8Array(0);
15051
+ if (result.length === 0) return /* @__PURE__ */ new Uint8Array(0);
15052
15052
  const outputLength = 16 * result.length;
15053
15053
  const output = new Uint8Array(outputLength);
15054
15054
  for (let i = 0, j = 0, ii = result.length; i < ii; ++i, j += 16) output.set(result[i], j);
@@ -15416,13 +15416,13 @@ var PDF17 = class {
15416
15416
  hashData.set(password, 0);
15417
15417
  hashData.set(ownerKeySalt, password.length);
15418
15418
  hashData.set(userBytes, password.length + ownerKeySalt.length);
15419
- return new AES256Cipher(calculateSHA256(hashData, 0, hashData.length)).decryptBlock(ownerEncryption, false, new Uint8Array(16));
15419
+ return new AES256Cipher(calculateSHA256(hashData, 0, hashData.length)).decryptBlock(ownerEncryption, false, /* @__PURE__ */ new Uint8Array(16));
15420
15420
  }
15421
15421
  getUserKey(password, userKeySalt, userEncryption) {
15422
15422
  const hashData = new Uint8Array(password.length + 8);
15423
15423
  hashData.set(password, 0);
15424
15424
  hashData.set(userKeySalt, password.length);
15425
- return new AES256Cipher(calculateSHA256(hashData, 0, hashData.length)).decryptBlock(userEncryption, false, new Uint8Array(16));
15425
+ return new AES256Cipher(calculateSHA256(hashData, 0, hashData.length)).decryptBlock(userEncryption, false, /* @__PURE__ */ new Uint8Array(16));
15426
15426
  }
15427
15427
  };
15428
15428
  var PDF20 = class {
@@ -15463,20 +15463,20 @@ var PDF20 = class {
15463
15463
  const hashData = new Uint8Array(password.length + 8);
15464
15464
  hashData.set(password, 0);
15465
15465
  hashData.set(userValidationSalt, password.length);
15466
- return isArrayEqual(this.calculatePDF20Hash(password, hashData, new Uint8Array()), userPassword);
15466
+ return isArrayEqual(this.calculatePDF20Hash(password, hashData, /* @__PURE__ */ new Uint8Array()), userPassword);
15467
15467
  }
15468
15468
  getOwnerKey(password, ownerKeySalt, userBytes, ownerEncryption) {
15469
15469
  const hashData = new Uint8Array(password.length + 56);
15470
15470
  hashData.set(password, 0);
15471
15471
  hashData.set(ownerKeySalt, password.length);
15472
15472
  hashData.set(userBytes, password.length + ownerKeySalt.length);
15473
- return new AES256Cipher(this.calculatePDF20Hash(password, hashData, userBytes)).decryptBlock(ownerEncryption, false, new Uint8Array(16));
15473
+ return new AES256Cipher(this.calculatePDF20Hash(password, hashData, userBytes)).decryptBlock(ownerEncryption, false, /* @__PURE__ */ new Uint8Array(16));
15474
15474
  }
15475
15475
  getUserKey(password, userKeySalt, userEncryption) {
15476
15476
  const hashData = new Uint8Array(password.length + 8);
15477
15477
  hashData.set(password, 0);
15478
15478
  hashData.set(userKeySalt, password.length);
15479
- return new AES256Cipher(this.calculatePDF20Hash(password, hashData, new Uint8Array())).decryptBlock(userEncryption, false, new Uint8Array(16));
15479
+ return new AES256Cipher(this.calculatePDF20Hash(password, hashData, /* @__PURE__ */ new Uint8Array())).decryptBlock(userEncryption, false, /* @__PURE__ */ new Uint8Array(16));
15480
15480
  }
15481
15481
  };
15482
15482
  var CipherTransform = class {
@@ -15506,7 +15506,7 @@ var CipherTransform = class {
15506
15506
  if (cipher instanceof AESBaseCipher) {
15507
15507
  const pad = 16 - s.length % 16;
15508
15508
  s += String.fromCharCode(pad).repeat(pad);
15509
- const iv = new Uint8Array(16);
15509
+ const iv = /* @__PURE__ */ new Uint8Array(16);
15510
15510
  if (typeof crypto !== "undefined") crypto.getRandomValues(iv);
15511
15511
  else for (let i = 0; i < 16; i++) iv[i] = Math.floor(256 * Math.random());
15512
15512
  let data = stringAsByteArray(s);
@@ -15647,7 +15647,7 @@ var CipherTransformFactory = class {
15647
15647
  if (password) {
15648
15648
  const passwordLength = Math.min(127, password.length);
15649
15649
  password = password.subarray(0, passwordLength);
15650
- } else password = new Uint8Array();
15650
+ } else password = /* @__PURE__ */ new Uint8Array();
15651
15651
  let pdfAlgorithm;
15652
15652
  if (revision === 6) pdfAlgorithm = new PDF20();
15653
15653
  else pdfAlgorithm = new PDF17();
@@ -15703,7 +15703,7 @@ var CipherTransformFactory = class {
15703
15703
  return encryptionKey;
15704
15704
  }
15705
15705
  decodeUserPassword(password, ownerPassword, revision, keyLength) {
15706
- const hashData = new Uint8Array(32);
15706
+ const hashData = /* @__PURE__ */ new Uint8Array(32);
15707
15707
  let i = 0;
15708
15708
  const n = Math.min(32, password.length);
15709
15709
  for (; i < n; ++i) hashData[i] = password[i];