@protontech/openpgp 5.9.0 → 5.9.1-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/dist/openpgp.mjs CHANGED
@@ -1,4 +1,4 @@
1
- /*! OpenPGP.js v5.9.0 - 2023-05-15 - this is LGPL licensed code, see LICENSE/our website https://openpgpjs.org/ for more information. */
1
+ /*! OpenPGP.js v5.9.1-1 - 2023-09-06 - 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');
@@ -2929,7 +2929,7 @@ var config = {
2929
2929
  * @memberof module:config
2930
2930
  * @property {String} versionString A version string to be included in armored messages
2931
2931
  */
2932
- versionString: 'OpenPGP.js 5.9.0',
2932
+ versionString: 'OpenPGP.js 5.9.1-1',
2933
2933
  /**
2934
2934
  * @memberof module:config
2935
2935
  * @property {String} commentString A comment string to be included in armored messages
@@ -15997,10 +15997,12 @@ class Argon2S2K {
15997
15997
  const decodedM = 2 << (this.encodedM - 1);
15998
15998
 
15999
15999
  try {
16000
- if (!argon2Promise) { // first load
16001
- loadArgonWasmModule = loadArgonWasmModule || (await Promise.resolve().then(function () { return index; })).default;
16002
- argon2Promise = loadArgonWasmModule();
16003
- }
16000
+ // on first load, the argon2 lib is imported and the WASM module is initialized.
16001
+ // the two steps need to be atomic to avoid race conditions causing multiple wasm modules
16002
+ // being loaded when `argon2Promise` is not initialized.
16003
+ loadArgonWasmModule = loadArgonWasmModule || (await Promise.resolve().then(function () { return index; })).default;
16004
+ argon2Promise = argon2Promise || loadArgonWasmModule();
16005
+
16004
16006
  // important to keep local ref to argon2 in case the module is reloaded by another instance
16005
16007
  const argon2 = await argon2Promise;
16006
16008
 
@@ -16020,6 +16022,7 @@ class Argon2S2K {
16020
16022
  if (decodedM > ARGON2_WASM_MEMORY_THRESHOLD_RELOAD) {
16021
16023
  // it will be awaited if needed at the next `produceKey` invocation
16022
16024
  argon2Promise = loadArgonWasmModule();
16025
+ argon2Promise.catch(() => {});
16023
16026
  }
16024
16027
  return hash;
16025
16028
  } catch (e) {
@@ -27551,7 +27554,9 @@ async function createBindingSignature(subkey, primaryKey, options, config) {
27551
27554
  signatureType: enums.signature.keyBinding
27552
27555
  }, options.date, undefined, undefined, undefined, config);
27553
27556
  } else {
27554
- subkeySignaturePacket.keyFlags = [enums.keyFlags.encryptCommunication | enums.keyFlags.encryptStorage];
27557
+ subkeySignaturePacket.keyFlags = options.forwarding ?
27558
+ [enums.keyFlags.forwardedCommunication] :
27559
+ [enums.keyFlags.encryptCommunication | enums.keyFlags.encryptStorage];
27555
27560
  }
27556
27561
  if (options.keyExpirationTime > 0) {
27557
27562
  subkeySignaturePacket.keyExpirationTime = options.keyExpirationTime;
@@ -27789,6 +27794,10 @@ function sanitizeKeyOptions(options, subkeyDefaults = {}) {
27789
27794
  options.date = options.date || subkeyDefaults.date;
27790
27795
 
27791
27796
  options.sign = options.sign || false;
27797
+ options.forwarding = options.forwarding || false;
27798
+ if (options.sign && options.forwarding) {
27799
+ throw new Error('Incompatible options: "sign" and "forwarding" cannot be set together');
27800
+ }
27792
27801
 
27793
27802
  switch (options.type) {
27794
27803
  case 'ecc':
@@ -27845,7 +27854,12 @@ function isValidEncryptionKeyPacket(keyPacket, signature) {
27845
27854
  }
27846
27855
 
27847
27856
  function isValidDecryptionKeyPacket(signature, config) {
27848
- if (config.allowInsecureDecryptionWithSigningKeys) {
27857
+ const isSigningKey = !signature.keyFlags ||
27858
+ (signature.keyFlags[0] & enums.keyFlags.sign) !== 0 ||
27859
+ (signature.keyFlags[0] & enums.keyFlags.certifyKeys) !== 0 ||
27860
+ (signature.keyFlags[0] & enums.keyFlags.authentication) !== 0;
27861
+
27862
+ if (isSigningKey && config.allowInsecureDecryptionWithSigningKeys) {
27849
27863
  // This is only relevant for RSA keys, all other signing algorithms cannot decrypt
27850
27864
  return true;
27851
27865
  }
@@ -29444,7 +29458,8 @@ async function reformat(options, config) {
29444
29458
  getLatestValidSignature(subkey.bindingSignatures, secretKeyPacket, enums.signature.subkeyBinding, dataToVerify, null, config)
29445
29459
  ).catch(() => ({}));
29446
29460
  return {
29447
- sign: bindingSignature.keyFlags && (bindingSignature.keyFlags[0] & enums.keyFlags.signData)
29461
+ sign: bindingSignature.keyFlags && (bindingSignature.keyFlags[0] & enums.keyFlags.signData),
29462
+ forwarding: bindingSignature.keyFlags && (bindingSignature.keyFlags[0] & enums.keyFlags.forwardedCommunication)
29448
29463
  };
29449
29464
  }));
29450
29465
  }
@@ -44666,8 +44681,9 @@ async function wasmLoader(memory, getSIMD, getNonSIMD) {
44666
44681
  const importObject = { env: { memory } };
44667
44682
  if (isSIMDSupported === undefined) {
44668
44683
  try {
44669
- isSIMDSupported = true; // will be overwritten in the catch
44670
- return await getSIMD(importObject);
44684
+ const loaded = await getSIMD(importObject);
44685
+ isSIMDSupported = true;
44686
+ return loaded;
44671
44687
  } catch(e) {
44672
44688
  isSIMDSupported = false;
44673
44689
  }
package/openpgp.d.ts CHANGED
@@ -317,6 +317,7 @@ interface Config {
317
317
  aeadProtect: boolean;
318
318
  allowUnauthenticatedMessages: boolean;
319
319
  allowUnauthenticatedStream: boolean;
320
+ allowForwardedMessages: boolean;
320
321
  checksumRequired: boolean;
321
322
  minRSABits: number;
322
323
  passwordCollisionCheck: boolean;
@@ -706,6 +707,7 @@ interface SubkeyOptions {
706
707
  keyExpirationTime?: number;
707
708
  date?: Date;
708
709
  sign?: boolean;
710
+ forwarding?: boolean;
709
711
  config?: PartialConfig;
710
712
  }
711
713
 
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.9.0",
4
+ "version": "5.9.1-1",
5
5
  "license": "LGPL-3.0+",
6
6
  "homepage": "https://openpgpjs.org/",
7
7
  "engines": {
@@ -66,7 +66,7 @@
66
66
  "@rollup/plugin-replace": "^2.3.2",
67
67
  "@rollup/plugin-wasm": "^6.1.2",
68
68
  "@types/chai": "^4.2.14",
69
- "argon2id": "^1.0.0",
69
+ "argon2id": "^1.0.1",
70
70
  "benchmark": "^2.1.4",
71
71
  "bn.js": "^4.11.8",
72
72
  "chai": "^4.3.6",