openpgpjs/openpgpjs — pull request #121 by toberndo (2013-10-23 15:35:23+00:00)
Title: devel branch: work on key and message class

List of changes:

- move modules in `src/crypto` to namespace `openpgp.crypto`
- add namespace `openpgp.key`, `openpgp.keyring`, `openpgp.message`
- add parameter `packetlist` to constructor of `key` class. New key objects are created like:
```
var newKey = new openpgp.key(packetlist);
```
- rename key methods `getKey` to `getKeyPacket`. Same for `getSubkey`, `getAllKeys` etc.
- add methods `getKeyIds` and `getKeyIdsHex` to `key`
- new `key` method `getKeyPacketByIds` to find the first key packet that matches list of keyIds
- new `key` method `isPublic` and `isPrivate`
- add static method `readArmored` to `key`. New key objects from armored key text are created like:
```
var newKey = openpgp.key.readArmored(armoredText);
```
- `src/openpgp.keyring.js → src/keyring.js`
- `src/openpgp.msg.message.js → src/message.js`
- add parameter `packetlist` to constructor of `message` class. New message objects are created like:
```
var msgObj = new openpgp.message(packetlist);
```
- remove `generic_decrypt` from message class. I think if we want this kind of high-level function (to derypt messages directly from keys in keyring) it should be in src/openpgp.js
- add methods `getKeyIds` and `getKeyIdsHex` to `message`. Returns the key IDs of the public keys to which the session key is encrypted
- implement `message.decrypt(privateKeyPacket)`
- add static method `readArmored` to `message`. New message objects from armored message text are created like:
```
var newMsg = openpgp.message.readArmored(armoredText);
```
- remove `readArmoredPackets` from `src/openpgp.js` this functionality is already provided in the key and message classes. Access to packetlists via `key.packets` or `message.packets`
- remove `getKeyFromPacketlist` from `src/openpgp.js`. This would be done with `new openpgp.key(packetlist)`
- add `filter`, `filterByType` and `forEach` method to packetlist
- add `toHex` and `equals` method to `keyid`
- fix tests after refactoring
- see `test/general/openpgp.basic.js` for examples