mirror of
https://github.com/openpgpjs/openpgpjs.git
synced 2026-02-27 21:43:24 +00:00
Add config parameter to top-level functions (#1241)
Refactor functions to take the configuration as a parameter.
This allows setting a config option for a single function call, whereas
setting `openpgp.config` could lead to concurrency-related issues when
multiple async function calls are made at the same time.
`openpgp.config` is used as default for unset config values in top-level
functions.
`openpgp.config` is used as default config object in low-level functions
(i.e., when calling a low-level function, it may be required to pass
`{ ...openpgp.config, modifiedConfig: modifiedValue }`).
Also,
- remove `config.rsaBlinding`: blinding is now always applied to RSA decryption
- remove `config.debug`: debugging mode can be enabled by setting
`process.env.NODE_ENV = 'development'`
- remove `config.useNative`: native crypto is always used when available
This commit is contained in:
@@ -6,16 +6,18 @@
|
||||
* - if it fails to run, edit this file to match the actual library API, then edit the definitions file (openpgp.d.ts) accordingly.
|
||||
*/
|
||||
|
||||
import { generateKey, readKey, readKeys, Key, readMessage, Message, CleartextMessage, encrypt, decrypt, sign, verify } from '../..';
|
||||
import { generateKey, readKey, readKeys, Key, readMessage, Message, CleartextMessage, encrypt, decrypt, sign, verify, config } from '../..';
|
||||
|
||||
import { expect } from 'chai';
|
||||
|
||||
(async () => {
|
||||
|
||||
// Generate keys
|
||||
const { publicKeyArmored, key } = await generateKey({ userIds: [{ email: "user@corp.co" }] });
|
||||
const { publicKeyArmored, key } = await generateKey({ userIds: [{ email: "user@corp.co" }], config: { v5Keys: true } });
|
||||
expect(key).to.be.instanceOf(Key);
|
||||
const privateKeys = [key];
|
||||
const publicKeys = [key.toPublic()];
|
||||
expect(key.toPublic().armor(config)).to.equal(publicKeyArmored);
|
||||
|
||||
// Parse keys
|
||||
expect(await readKey({ armoredKey: publicKeyArmored })).to.be.instanceOf(Key);
|
||||
|
||||
Reference in New Issue
Block a user