@protontech/openpgp 5.11.1-0 → 5.11.2-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/dist/openpgp.mjs CHANGED
@@ -1,4 +1,4 @@
1
- /*! OpenPGP.js v5.11.1-0 - 2024-02-14 - this is LGPL licensed code, see LICENSE/our website https://openpgpjs.org/ for more information. */
1
+ /*! OpenPGP.js v5.11.2-0 - 2024-04-12 - this is LGPL licensed code, see LICENSE/our website https://openpgpjs.org/ for more information. */
2
2
  const globalThis = typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
3
3
 
4
4
  const doneWritingPromise = Symbol('doneWritingPromise');
@@ -2950,7 +2950,7 @@ var config = {
2950
2950
  * @memberof module:config
2951
2951
  * @property {String} versionString A version string to be included in armored messages
2952
2952
  */
2953
- versionString: 'OpenPGP.js 5.11.1-0',
2953
+ versionString: 'OpenPGP.js 5.11.2-0',
2954
2954
  /**
2955
2955
  * @memberof module:config
2956
2956
  * @property {String} commentString A comment string to be included in armored messages
@@ -12570,8 +12570,15 @@ async function encrypt$1(data, n, e) {
12570
12570
  * @async
12571
12571
  */
12572
12572
  async function decrypt$1(data, n, e, d, p, q, u, randomPayload) {
12573
- if (util.getNodeCrypto()) {
12574
- return nodeDecrypt$1(data, n, e, d, p, q, u, randomPayload);
12573
+ // Node v18.19.1, 20.11.1 and 21.6.2 have disabled support for PKCS#1 decryption,
12574
+ // and we want to avoid checking the error type to decide if the random payload
12575
+ // should indeed be returned.
12576
+ if (util.getNodeCrypto() && !randomPayload) {
12577
+ try {
12578
+ return await nodeDecrypt$1(data, n, e, d, p, q, u);
12579
+ } catch (err) {
12580
+ util.printDebugError(err);
12581
+ }
12575
12582
  }
12576
12583
  return bnDecrypt(data, n, e, d, p, q, u, randomPayload);
12577
12584
  }
@@ -12873,7 +12880,7 @@ async function bnEncrypt(data, n, e) {
12873
12880
  return data.modExp(e, n).toUint8Array('be', n.byteLength());
12874
12881
  }
12875
12882
 
12876
- async function nodeDecrypt$1(data, n, e, d, p, q, u, randomPayload) {
12883
+ async function nodeDecrypt$1(data, n, e, d, p, q, u) {
12877
12884
  const { default: BN } = await Promise.resolve().then(function () { return bn$1; });
12878
12885
 
12879
12886
  const pBNum = new BN(p);
@@ -12907,9 +12914,6 @@ async function nodeDecrypt$1(data, n, e, d, p, q, u, randomPayload) {
12907
12914
  try {
12908
12915
  return new Uint8Array(nodeCrypto$6.privateDecrypt(key, data));
12909
12916
  } catch (err) {
12910
- if (randomPayload) {
12911
- return randomPayload;
12912
- }
12913
12917
  throw new Error('Decryption error');
12914
12918
  }
12915
12919
  }
@@ -16425,9 +16429,26 @@ class Argon2OutOfMemoryError extends Error {
16425
16429
  let loadArgonWasmModule;
16426
16430
  let argon2Promise;
16427
16431
  // reload wasm module above this treshold, to deallocated used memory
16428
- const ARGON2_WASM_MEMORY_THRESHOLD_RELOAD = 2 << 19;
16432
+ // (cannot be declared as a simple `static` field as its not supported by Safari 14)
16433
+ let ARGON2_WASM_MEMORY_THRESHOLD_RELOAD = 2 << 19;
16429
16434
 
16430
16435
  class Argon2S2K {
16436
+ static get ARGON2_WASM_MEMORY_THRESHOLD_RELOAD() {
16437
+ return ARGON2_WASM_MEMORY_THRESHOLD_RELOAD;
16438
+ }
16439
+
16440
+ static set ARGON2_WASM_MEMORY_THRESHOLD_RELOAD(memoryThreshold) {
16441
+ ARGON2_WASM_MEMORY_THRESHOLD_RELOAD = memoryThreshold;
16442
+ }
16443
+
16444
+ static reloadWasmModule() {
16445
+ if (!loadArgonWasmModule) return;
16446
+
16447
+ // it will be awaited if needed at the next `produceKey` invocation
16448
+ argon2Promise = loadArgonWasmModule();
16449
+ argon2Promise.catch(() => {});
16450
+ }
16451
+
16431
16452
  /**
16432
16453
  * @param {Object} [config] - Full configuration, defaults to openpgp.config
16433
16454
  */
@@ -16515,10 +16536,8 @@ class Argon2S2K {
16515
16536
  });
16516
16537
 
16517
16538
  // a lot of memory was used, reload to deallocate
16518
- if (decodedM > ARGON2_WASM_MEMORY_THRESHOLD_RELOAD) {
16519
- // it will be awaited if needed at the next `produceKey` invocation
16520
- argon2Promise = loadArgonWasmModule();
16521
- argon2Promise.catch(() => {});
16539
+ if (decodedM > Argon2S2K.ARGON2_WASM_MEMORY_THRESHOLD_RELOAD) {
16540
+ Argon2S2K.reloadWasmModule();
16522
16541
  }
16523
16542
  return hash;
16524
16543
  } catch (e) {
package/openpgp.d.ts CHANGED
@@ -925,6 +925,8 @@ export namespace enums {
925
925
  }
926
926
 
927
927
  export declare class Argon2S2K {
928
+ static reloadWasmModule(): void;
929
+ static ARGON2_WASM_MEMORY_THRESHOLD_RELOAD: number;
928
930
  constructor(config: Config);
929
931
  salt: Uint8Array;
930
932
  /** @throws Argon2OutOfMemoryError */
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@protontech/openpgp",
3
3
  "description": "OpenPGP.js is a Javascript implementation of the OpenPGP protocol. This is defined in RFC 4880.",
4
- "version": "5.11.1-0",
4
+ "version": "5.11.2-0",
5
5
  "license": "LGPL-3.0+",
6
6
  "homepage": "https://openpgpjs.org/",
7
7
  "engines": {