mirror of
https://github.com/openpgpjs/openpgpjs.git
synced 2026-03-13 11:55:01 +00:00
Replace Key with PrivateKey and PublicKey classes (#1300)
- Add `PrivateKey` and `PublicKey` classes. A `PrivateKey` can always be passed where a `PublicKey` key is expected, but not vice versa. - Unexport `Key`, and export `PrivateKey` and `PublicKey`. - Rename `Key.packetlist2structure` to `Key.packetListToStructure`. - Change `Key.update` to return a new updated key, rather than modifying the destination one in place. - Add `openpgp.readPrivateKey` and `openpgp.readPrivateKeys` to avoid having to downcast the result of `readKey(s)` in TypeScript.
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
const openpgp = typeof window !== 'undefined' && window.openpgp ? window.openpgp : require('../..');
|
||||
|
||||
const { readKey, Key, createMessage, enums, PacketList, SignaturePacket } = openpgp;
|
||||
const { readKey, PrivateKey, createMessage, enums, PacketList, SignaturePacket } = openpgp;
|
||||
|
||||
const chai = require('chai');
|
||||
chai.use(require('chai-as-promised'));
|
||||
@@ -82,7 +82,7 @@ async function makeKeyValid() {
|
||||
// reconstruct the modified key
|
||||
const newlist = new PacketList();
|
||||
newlist.push(pubkey, puser, pusersig);
|
||||
let modifiedkey = new Key(newlist);
|
||||
let modifiedkey = new PrivateKey(newlist);
|
||||
// re-read the message to eliminate any
|
||||
// behaviour due to cached values.
|
||||
modifiedkey = await readKey({ armoredKey: await modifiedkey.armor() });
|
||||
|
||||
Reference in New Issue
Block a user