mirror of
https://github.com/openpgpjs/openpgpjs.git
synced 2026-02-28 14:03:26 +00:00
This limit is applied both on encryption (if `config.s2kType` is set to `enums.s2k.argon2`) and decryption. If the input memory exponent exceeds this value, the library will not attempt the argon2 key derivation and instead directly throw an `Argon2OutOfMemoryError` error.
27 lines
810 B
JavaScript
27 lines
810 B
JavaScript
/**
|
|
* This module centralises the openpgp import and ensures that the module is initialised
|
|
* at the top of the test bundle, and that the config is initialised before the tests code runs (incl. that outside of `describe`).
|
|
*/
|
|
|
|
import * as openpgp from 'openpgp';
|
|
import * as webStreamsPonyfill from 'web-streams-polyfill';
|
|
|
|
if (typeof window !== 'undefined') {
|
|
window.openpgp = openpgp;
|
|
}
|
|
|
|
openpgp.config.s2kIterationCountByte = 0;
|
|
|
|
if (typeof window !== 'undefined' &&
|
|
/** Mobile Safari 26 reloads the page if Argon2 tries to allocate memory above 1GB */
|
|
window.navigator.userAgent.match(/Version\/26\.\d(\.\d)* (Mobile\/\w+ )Safari/)) {
|
|
|
|
openpgp.config.maxArgon2MemoryExponent = 20;
|
|
}
|
|
|
|
if (!globalThis.TransformStream) {
|
|
Object.assign(globalThis, webStreamsPonyfill);
|
|
}
|
|
|
|
export default openpgp;
|