mirror of
https://github.com/openpgpjs/openpgpjs.git
synced 2025-10-14 00:59:29 +00:00
Internal: avoid importing enums
in legacy_cipher chunk
To avoid issues with the lightweight build: for now it works fine, but it could mess up chunking in the future, and it already results in a circular import.
This commit is contained in:
parent
a16160fc66
commit
a5d894f514
@ -11,7 +11,8 @@ export async function getLegacyCipher(algo) {
|
|||||||
case enums.symmetric.twofish:
|
case enums.symmetric.twofish:
|
||||||
case enums.symmetric.tripledes: {
|
case enums.symmetric.tripledes: {
|
||||||
const { legacyCiphers } = await import('./legacy_ciphers');
|
const { legacyCiphers } = await import('./legacy_ciphers');
|
||||||
const cipher = legacyCiphers.get(algo);
|
const algoName = enums.read(enums.symmetric, algo);
|
||||||
|
const cipher = legacyCiphers.get(algoName);
|
||||||
if (!cipher) {
|
if (!cipher) {
|
||||||
throw new Error('Unsupported cipher algorithm');
|
throw new Error('Unsupported cipher algorithm');
|
||||||
}
|
}
|
||||||
|
@ -3,15 +3,16 @@
|
|||||||
* Separate dynamic imports are not convenient as they result in multiple chunks.
|
* Separate dynamic imports are not convenient as they result in multiple chunks.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { TripleDES } from './des';
|
import { TripleDES as tripledes } from './des';
|
||||||
import CAST5 from './cast5';
|
import cast5 from './cast5';
|
||||||
import TwoFish from './twofish';
|
import twofish from './twofish';
|
||||||
import BlowFish from './blowfish';
|
import blowfish from './blowfish';
|
||||||
import enums from '../../enums';
|
|
||||||
|
|
||||||
export const legacyCiphers = new Map([
|
// We avoid importing 'enums' as this module is lazy loaded, and doing so could mess up
|
||||||
[enums.symmetric.tripledes, TripleDES],
|
// chunking for the lightweight build
|
||||||
[enums.symmetric.cast5, CAST5],
|
export const legacyCiphers = new Map(Object.entries({
|
||||||
[enums.symmetric.blowfish, BlowFish],
|
tripledes,
|
||||||
[enums.symmetric.twofish, TwoFish]
|
cast5,
|
||||||
]);
|
twofish,
|
||||||
|
blowfish
|
||||||
|
}));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user