This is a prerelease of v5.0.0. The full changelog since OpenPGP.js v4 can be found here. The changelog since v5.0.0-3 is:
- Fix various signature verification issues (#1302)
- Uniform casing of subkey(s): rename the
SubKey
class toSubkey
, andkey.subKeys
tokey.subkeys
(#1310) - CI: Check that JSDoc comments are valid (#1328)
- CI: Detect unhandled rejections in browser tests (#1333) except in Safari 14.1 (#1371)
- Require keys in
openpgp.sign
and make all top-level functions fully async (#1318) - Remove
primaryKey
argument fromUser
methods, and renameUser.sign
toUser.certify
(#1329) - Always generate RSA keys of exact bit length (#1336)
- Drop
capabilities
,keyID
args inkey.getExpirationTime()
and consider direct-key signatures (#1319) - Add
Signature#getSigningKeyIDs
method to get Issuer Key IDs from aSignature
(#1331) - Always throw on unexpected packets, but ignore
Trust
andMarker
packets on parsing (#1340) - TypeScript: make the
packets
,keyPacket
andmainKey
propertiesreadonly
(#1337) - Simplify return value of
generateKey
,reformatKey
andrevokeKey
and add support for binary output (#1345) - Support passing a non-array value to
encryption/signingKeyIDs
in top-level functions (#1342) - Support using
key.isPrivate()
for type inference, removekey.isPublic()
(#1347) - Lint: enforce single quotes and do not error on class methods without
this
(#1341) - Remove
valid
anderror
from the verification result ofopenpgp.verify
anddecrypt
, in favor ofawait verified
(#1348) - Update README to use
openpgp.readPrivateKey()
where applicable (#1362) - Extend
BaseStream<>
fromAsyncIterable<>
, to enable the use offor await (chunk of result)
on returned streams in TypeScript (#1373) - Replace
armor
option withformat
inopenpgp.encrypt
,sign
andencryptSessionKey
(#1354, #1377)- If
format: 'armor'
is passed (the default), an armored signed/encrypted message is returned (same asarmor: true
) - If
format: 'binary'
is passed, a binary signed/encrypted message is returned (same asarmor: false
in previous v5 prereleases) - If
format: 'object'
is passed, aMessage
orSignature
object is returned (same asarmor: false
in v4)
- If
- Github: add issue templates (#1369)
- Export
Subkey
class (#1381) - Update web-stream-tools, web-streams-polyfill and web-streams-adapter dependencies
Examples
Generate an armored key pair
v5.0.0-3:
import { generateKey } from 'openpgp';
const { privateKeyArmored, publicKeyArmored, revocationCertificate } = await generateKey({ userIDs: [{ name: 'Test', email: 'test@email' }] });
v5.0.0-4:
import { generateKey } from 'openpgp';
const { privateKey, publicKey, revocationCertificate } = await generateKey({ userIDs: [{ name: 'Test', email: 'test@email' }] });
Generate a private key object
v5.0.0-3:
import { generateKey } from 'openpgp';
const { key } = await generateKey({ userIDs: [{ name: 'Test', email: 'test@email' }] });
v5.0.0-4:
import { generateKey } from 'openpgp';
const { key: privateKey } = await generateKey({ userIDs: [{ name: 'Test', email: 'test@email' }], format: 'object' });
Encrypt and sign binary message (binary output)
v5.0.0-3:
import { createMessage, encrypt } from 'openpgp';
const message = await createMessage({ binary: data });
const encrypted = await encrypt({ encryptionKeys: publicKeys, signingKeys: privateKeys, message, armor: false });
console.log(encrypted); // Uint8Array
v5.0.0-4:
import { createMessage, encrypt } from 'openpgp';
const message = await createMessage({ binary: data });
const encrypted = await encrypt({ encryptionKeys: publicKeys, signingKeys: privateKeys, message, format: 'binary' });
console.log(encrypted); // Uint8Array