diff --git a/README.md b/README.md
index d40a24a..d2b2de9 100644
--- a/README.md
+++ b/README.md
@@ -16,7 +16,9 @@
-`sks-lib` is a Typescript library for interacting with SKS keyservers. Currently there's only support for retrieving a keyserver's stats.
+`sks-lib` is a Typescript library for interacting with SKS keyservers. Currently there's support for looking up keys, uploading keys and retrieving statistics of a keyserver.
+
+*Please note that keyservers never return verified data. Do **not** trust the retrieved keys and **always verify** them.*
## Installation
@@ -24,44 +26,39 @@
Just add it with `yarn install sks-lib` (or `npm install sks-lib`) to your project. It ships the generated Javascript code along with Typescript's declaration files. The Typescript code itself lives in `lib/`.
-## Example usage
+## Usage
```ts
-import {Keyserver} from 'sks-lib';
-import {Moment} from 'moment';
+// Create a new keyserver object to query on
+var keyserver = new Keyserver('keyserver.ntzwrk.org');
+var somePublicKey: string;
-var keyserver = new Keyserver('keyserver.ntzwrk.org');
+// Lookup the key for "vsund" and then print it
+keyserver.lookup('vsund').then(
+ (key) => {
+ somePublicKey = key;
+ console.log(key);
+ }
+);
+// Upload the previously fetched key and print the server's response
+keyserver.upload(publicKey).then(
+ (response) => {
+ console.log(response);
+ }
+);
+
+// Get stats and then print some information
keyserver.getStats().then(
(stats) => {
- var hostName = stats.hostName;
- var software = stats.software;
- var version = stats.version;
- var peerCount = stats.gossipPeerCount;
-
- console.log('"%s" is a %s %s keyserver with %s gossip peers.', hostName, software, version, peerCount);
+ console.log('"%s" is a %s keyserver on version %s.', stats.hostName, stats.software, stats.version);
}
-).catch((reason: Error) => {
- console.log('Could not connect to "%s:11371"', keyserver.hostName);
- console.log('%s: %s', reason.name, reason.message);
-});
-
-keyserver.getKeyStats().then(
- (keyStats) => {
- var hostName = keyserver.hostName;
- var totalKeys = keyStats.totalKeys;
- var newKeys = keyStats.dailyKeys[11].newKeys;
- var date = keyStats.dailyKeys[11].dateTime.format('MMMM Do YYYY');
-
- console.log('"%s" has %s total keys and saw %s new keys on %s.', hostName, totalKeys, newKeys, date);
- }
-).catch((reason: Error) => {
- console.log('Could not connect to "%s:11371"', keyserver.hostName);
- console.log('%s: %s', reason.name, reason.message);
-});
+);
```
+See [`examples/`](examples/) for some more examples.
+
## Documentation
diff --git a/docs/code/assets/js/search.js b/docs/code/assets/js/search.js
index cb547be..4e1a928 100644
--- a/docs/code/assets/js/search.js
+++ b/docs/code/assets/js/search.js
@@ -1,3 +1,3 @@
-var typedoc = typedoc || {};
+var typedoc = typedoc || {};
typedoc.search = typedoc.search || {};
- typedoc.search.data = {"kinds":{"1":"External module","128":"Class","512":"Constructor","1024":"Property","2048":"Method"},"rows":[{"id":0,"kind":1,"name":"\"KeyStats\"","url":"modules/_keystats_.html","classes":"tsd-kind-external-module"},{"id":1,"kind":128,"name":"KeyStats","url":"classes/_keystats_.keystats.html","classes":"tsd-kind-class tsd-parent-kind-external-module","parent":"\"KeyStats\""},{"id":2,"kind":1024,"name":"totalKeys","url":"classes/_keystats_.keystats.html#totalkeys","classes":"tsd-kind-property tsd-parent-kind-class","parent":"\"KeyStats\".KeyStats"},{"id":3,"kind":1024,"name":"dailyKeys","url":"classes/_keystats_.keystats.html#dailykeys","classes":"tsd-kind-property tsd-parent-kind-class","parent":"\"KeyStats\".KeyStats"},{"id":4,"kind":1024,"name":"hourlyKeys","url":"classes/_keystats_.keystats.html#hourlykeys","classes":"tsd-kind-property tsd-parent-kind-class","parent":"\"KeyStats\".KeyStats"},{"id":5,"kind":512,"name":"constructor","url":"classes/_keystats_.keystats.html#constructor","classes":"tsd-kind-constructor tsd-parent-kind-class","parent":"\"KeyStats\".KeyStats"},{"id":6,"kind":128,"name":"KeyStatsEntry","url":"classes/_keystats_.keystatsentry.html","classes":"tsd-kind-class tsd-parent-kind-external-module","parent":"\"KeyStats\""},{"id":7,"kind":1024,"name":"dateTime","url":"classes/_keystats_.keystatsentry.html#datetime","classes":"tsd-kind-property tsd-parent-kind-class","parent":"\"KeyStats\".KeyStatsEntry"},{"id":8,"kind":1024,"name":"newKeys","url":"classes/_keystats_.keystatsentry.html#newkeys","classes":"tsd-kind-property tsd-parent-kind-class","parent":"\"KeyStats\".KeyStatsEntry"},{"id":9,"kind":1024,"name":"updatedKeys","url":"classes/_keystats_.keystatsentry.html#updatedkeys","classes":"tsd-kind-property tsd-parent-kind-class","parent":"\"KeyStats\".KeyStatsEntry"},{"id":10,"kind":512,"name":"constructor","url":"classes/_keystats_.keystatsentry.html#constructor","classes":"tsd-kind-constructor tsd-parent-kind-class","parent":"\"KeyStats\".KeyStatsEntry"},{"id":11,"kind":1,"name":"\"ParseError\"","url":"modules/_parseerror_.html","classes":"tsd-kind-external-module"},{"id":12,"kind":128,"name":"ParseError","url":"classes/_parseerror_.parseerror.html","classes":"tsd-kind-class tsd-parent-kind-external-module","parent":"\"ParseError\""},{"id":13,"kind":512,"name":"constructor","url":"classes/_parseerror_.parseerror.html#constructor","classes":"tsd-kind-constructor tsd-parent-kind-class","parent":"\"ParseError\".ParseError"},{"id":14,"kind":1024,"name":"name","url":"classes/_parseerror_.parseerror.html#name","classes":"tsd-kind-property tsd-parent-kind-class tsd-is-inherited tsd-is-static","parent":"\"ParseError\".ParseError"},{"id":15,"kind":1024,"name":"message","url":"classes/_parseerror_.parseerror.html#message","classes":"tsd-kind-property tsd-parent-kind-class tsd-is-inherited tsd-is-static","parent":"\"ParseError\".ParseError"},{"id":16,"kind":1024,"name":"stack","url":"classes/_parseerror_.parseerror.html#stack","classes":"tsd-kind-property tsd-parent-kind-class tsd-is-overwrite tsd-is-inherited tsd-is-static","parent":"\"ParseError\".ParseError"},{"id":17,"kind":1024,"name":"Error","url":"classes/_parseerror_.parseerror.html#error","classes":"tsd-kind-property tsd-parent-kind-class tsd-is-static","parent":"\"ParseError\".ParseError"},{"id":18,"kind":1,"name":"\"Peer\"","url":"modules/_peer_.html","classes":"tsd-kind-external-module"},{"id":19,"kind":128,"name":"GossipPeer","url":"classes/_peer_.gossippeer.html","classes":"tsd-kind-class tsd-parent-kind-external-module","parent":"\"Peer\""},{"id":20,"kind":1024,"name":"host","url":"classes/_peer_.gossippeer.html#host","classes":"tsd-kind-property tsd-parent-kind-class","parent":"\"Peer\".GossipPeer"},{"id":21,"kind":1024,"name":"port","url":"classes/_peer_.gossippeer.html#port","classes":"tsd-kind-property tsd-parent-kind-class","parent":"\"Peer\".GossipPeer"},{"id":22,"kind":512,"name":"constructor","url":"classes/_peer_.gossippeer.html#constructor","classes":"tsd-kind-constructor tsd-parent-kind-class","parent":"\"Peer\".GossipPeer"},{"id":23,"kind":128,"name":"MailsyncPeer","url":"classes/_peer_.mailsyncpeer.html","classes":"tsd-kind-class tsd-parent-kind-external-module","parent":"\"Peer\""},{"id":24,"kind":1024,"name":"address","url":"classes/_peer_.mailsyncpeer.html#address","classes":"tsd-kind-property tsd-parent-kind-class","parent":"\"Peer\".MailsyncPeer"},{"id":25,"kind":512,"name":"constructor","url":"classes/_peer_.mailsyncpeer.html#constructor","classes":"tsd-kind-constructor tsd-parent-kind-class","parent":"\"Peer\".MailsyncPeer"},{"id":26,"kind":1,"name":"\"Stats\"","url":"modules/_stats_.html","classes":"tsd-kind-external-module"},{"id":27,"kind":128,"name":"Stats","url":"classes/_stats_.stats.html","classes":"tsd-kind-class tsd-parent-kind-external-module","parent":"\"Stats\""},{"id":28,"kind":1024,"name":"software","url":"classes/_stats_.stats.html#software","classes":"tsd-kind-property tsd-parent-kind-class","parent":"\"Stats\".Stats"},{"id":29,"kind":1024,"name":"version","url":"classes/_stats_.stats.html#version","classes":"tsd-kind-property tsd-parent-kind-class","parent":"\"Stats\".Stats"},{"id":30,"kind":1024,"name":"hostName","url":"classes/_stats_.stats.html#hostname","classes":"tsd-kind-property tsd-parent-kind-class","parent":"\"Stats\".Stats"},{"id":31,"kind":1024,"name":"nodeName","url":"classes/_stats_.stats.html#nodename","classes":"tsd-kind-property tsd-parent-kind-class","parent":"\"Stats\".Stats"},{"id":32,"kind":1024,"name":"serverContact","url":"classes/_stats_.stats.html#servercontact","classes":"tsd-kind-property tsd-parent-kind-class","parent":"\"Stats\".Stats"},{"id":33,"kind":1024,"name":"httpPort","url":"classes/_stats_.stats.html#httpport","classes":"tsd-kind-property tsd-parent-kind-class","parent":"\"Stats\".Stats"},{"id":34,"kind":1024,"name":"reconPort","url":"classes/_stats_.stats.html#reconport","classes":"tsd-kind-property tsd-parent-kind-class","parent":"\"Stats\".Stats"},{"id":35,"kind":1024,"name":"debugLevel","url":"classes/_stats_.stats.html#debuglevel","classes":"tsd-kind-property tsd-parent-kind-class","parent":"\"Stats\".Stats"},{"id":36,"kind":1024,"name":"keys","url":"classes/_stats_.stats.html#keys","classes":"tsd-kind-property tsd-parent-kind-class","parent":"\"Stats\".Stats"},{"id":37,"kind":1024,"name":"statsTime","url":"classes/_stats_.stats.html#statstime","classes":"tsd-kind-property tsd-parent-kind-class","parent":"\"Stats\".Stats"},{"id":38,"kind":1024,"name":"gossipPeers","url":"classes/_stats_.stats.html#gossippeers","classes":"tsd-kind-property tsd-parent-kind-class","parent":"\"Stats\".Stats"},{"id":39,"kind":1024,"name":"gossipPeerCount","url":"classes/_stats_.stats.html#gossippeercount","classes":"tsd-kind-property tsd-parent-kind-class","parent":"\"Stats\".Stats"},{"id":40,"kind":1024,"name":"mailsyncPeers","url":"classes/_stats_.stats.html#mailsyncpeers","classes":"tsd-kind-property tsd-parent-kind-class","parent":"\"Stats\".Stats"},{"id":41,"kind":1024,"name":"mailsyncPeerCount","url":"classes/_stats_.stats.html#mailsyncpeercount","classes":"tsd-kind-property tsd-parent-kind-class","parent":"\"Stats\".Stats"},{"id":42,"kind":512,"name":"constructor","url":"classes/_stats_.stats.html#constructor","classes":"tsd-kind-constructor tsd-parent-kind-class","parent":"\"Stats\".Stats"},{"id":43,"kind":1,"name":"\"Keyserver\"","url":"modules/_keyserver_.html","classes":"tsd-kind-external-module"},{"id":44,"kind":128,"name":"Keyserver","url":"classes/_keyserver_.keyserver.html","classes":"tsd-kind-class tsd-parent-kind-external-module","parent":"\"Keyserver\""},{"id":45,"kind":1024,"name":"hostName","url":"classes/_keyserver_.keyserver.html#hostname","classes":"tsd-kind-property tsd-parent-kind-class","parent":"\"Keyserver\".Keyserver"},{"id":46,"kind":1024,"name":"port","url":"classes/_keyserver_.keyserver.html#port","classes":"tsd-kind-property tsd-parent-kind-class","parent":"\"Keyserver\".Keyserver"},{"id":47,"kind":1024,"name":"statsHtml","url":"classes/_keyserver_.keyserver.html#statshtml","classes":"tsd-kind-property tsd-parent-kind-class tsd-is-private","parent":"\"Keyserver\".Keyserver"},{"id":48,"kind":512,"name":"constructor","url":"classes/_keyserver_.keyserver.html#constructor","classes":"tsd-kind-constructor tsd-parent-kind-class","parent":"\"Keyserver\".Keyserver"},{"id":49,"kind":2048,"name":"getStatsHtml","url":"classes/_keyserver_.keyserver.html#getstatshtml","classes":"tsd-kind-method tsd-parent-kind-class tsd-is-private","parent":"\"Keyserver\".Keyserver"},{"id":50,"kind":2048,"name":"mapToView","url":"classes/_keyserver_.keyserver.html#maptoview","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter","parent":"\"Keyserver\".Keyserver"},{"id":51,"kind":2048,"name":"getStats","url":"classes/_keyserver_.keyserver.html#getstats","classes":"tsd-kind-method tsd-parent-kind-class","parent":"\"Keyserver\".Keyserver"},{"id":52,"kind":2048,"name":"getKeyStats","url":"classes/_keyserver_.keyserver.html#getkeystats","classes":"tsd-kind-method tsd-parent-kind-class","parent":"\"Keyserver\".Keyserver"},{"id":53,"kind":2048,"name":"parseStatsHtml","url":"classes/_keyserver_.keyserver.html#parsestatshtml","classes":"tsd-kind-method tsd-parent-kind-class tsd-is-static","parent":"\"Keyserver\".Keyserver"},{"id":54,"kind":2048,"name":"parseKeyStatsHtml","url":"classes/_keyserver_.keyserver.html#parsekeystatshtml","classes":"tsd-kind-method tsd-parent-kind-class tsd-is-static","parent":"\"Keyserver\".Keyserver"},{"id":55,"kind":1,"name":"\"index\"","url":"modules/_index_.html","classes":"tsd-kind-external-module"}]};
\ No newline at end of file
+ typedoc.search.data = {"kinds":{"1":"External module","128":"Class","512":"Constructor","1024":"Property","2048":"Method"},"rows":[{"id":0,"kind":1,"name":"\"Errors\"","url":"modules/_errors_.html","classes":"tsd-kind-external-module"},{"id":1,"kind":128,"name":"NoKeyFoundError","url":"classes/_errors_.nokeyfounderror.html","classes":"tsd-kind-class tsd-parent-kind-external-module","parent":"\"Errors\""},{"id":2,"kind":512,"name":"constructor","url":"classes/_errors_.nokeyfounderror.html#constructor","classes":"tsd-kind-constructor tsd-parent-kind-class","parent":"\"Errors\".NoKeyFoundError"},{"id":3,"kind":1024,"name":"name","url":"classes/_errors_.nokeyfounderror.html#name","classes":"tsd-kind-property tsd-parent-kind-class tsd-is-inherited tsd-is-static","parent":"\"Errors\".NoKeyFoundError"},{"id":4,"kind":1024,"name":"message","url":"classes/_errors_.nokeyfounderror.html#message","classes":"tsd-kind-property tsd-parent-kind-class tsd-is-inherited tsd-is-static","parent":"\"Errors\".NoKeyFoundError"},{"id":5,"kind":1024,"name":"stack","url":"classes/_errors_.nokeyfounderror.html#stack","classes":"tsd-kind-property tsd-parent-kind-class tsd-is-overwrite tsd-is-inherited tsd-is-static","parent":"\"Errors\".NoKeyFoundError"},{"id":6,"kind":1024,"name":"Error","url":"classes/_errors_.nokeyfounderror.html#error","classes":"tsd-kind-property tsd-parent-kind-class tsd-is-static","parent":"\"Errors\".NoKeyFoundError"},{"id":7,"kind":128,"name":"ParseError","url":"classes/_errors_.parseerror.html","classes":"tsd-kind-class tsd-parent-kind-external-module","parent":"\"Errors\""},{"id":8,"kind":512,"name":"constructor","url":"classes/_errors_.parseerror.html#constructor","classes":"tsd-kind-constructor tsd-parent-kind-class","parent":"\"Errors\".ParseError"},{"id":9,"kind":1024,"name":"name","url":"classes/_errors_.parseerror.html#name","classes":"tsd-kind-property tsd-parent-kind-class tsd-is-inherited tsd-is-static","parent":"\"Errors\".ParseError"},{"id":10,"kind":1024,"name":"message","url":"classes/_errors_.parseerror.html#message","classes":"tsd-kind-property tsd-parent-kind-class tsd-is-inherited tsd-is-static","parent":"\"Errors\".ParseError"},{"id":11,"kind":1024,"name":"stack","url":"classes/_errors_.parseerror.html#stack","classes":"tsd-kind-property tsd-parent-kind-class tsd-is-overwrite tsd-is-inherited tsd-is-static","parent":"\"Errors\".ParseError"},{"id":12,"kind":1024,"name":"Error","url":"classes/_errors_.parseerror.html#error","classes":"tsd-kind-property tsd-parent-kind-class tsd-is-static","parent":"\"Errors\".ParseError"},{"id":13,"kind":1,"name":"\"KeyStats\"","url":"modules/_keystats_.html","classes":"tsd-kind-external-module"},{"id":14,"kind":128,"name":"KeyStats","url":"classes/_keystats_.keystats.html","classes":"tsd-kind-class tsd-parent-kind-external-module","parent":"\"KeyStats\""},{"id":15,"kind":1024,"name":"totalKeys","url":"classes/_keystats_.keystats.html#totalkeys","classes":"tsd-kind-property tsd-parent-kind-class","parent":"\"KeyStats\".KeyStats"},{"id":16,"kind":1024,"name":"dailyKeys","url":"classes/_keystats_.keystats.html#dailykeys","classes":"tsd-kind-property tsd-parent-kind-class","parent":"\"KeyStats\".KeyStats"},{"id":17,"kind":1024,"name":"hourlyKeys","url":"classes/_keystats_.keystats.html#hourlykeys","classes":"tsd-kind-property tsd-parent-kind-class","parent":"\"KeyStats\".KeyStats"},{"id":18,"kind":512,"name":"constructor","url":"classes/_keystats_.keystats.html#constructor","classes":"tsd-kind-constructor tsd-parent-kind-class","parent":"\"KeyStats\".KeyStats"},{"id":19,"kind":128,"name":"KeyStatsEntry","url":"classes/_keystats_.keystatsentry.html","classes":"tsd-kind-class tsd-parent-kind-external-module","parent":"\"KeyStats\""},{"id":20,"kind":1024,"name":"dateTime","url":"classes/_keystats_.keystatsentry.html#datetime","classes":"tsd-kind-property tsd-parent-kind-class","parent":"\"KeyStats\".KeyStatsEntry"},{"id":21,"kind":1024,"name":"newKeys","url":"classes/_keystats_.keystatsentry.html#newkeys","classes":"tsd-kind-property tsd-parent-kind-class","parent":"\"KeyStats\".KeyStatsEntry"},{"id":22,"kind":1024,"name":"updatedKeys","url":"classes/_keystats_.keystatsentry.html#updatedkeys","classes":"tsd-kind-property tsd-parent-kind-class","parent":"\"KeyStats\".KeyStatsEntry"},{"id":23,"kind":512,"name":"constructor","url":"classes/_keystats_.keystatsentry.html#constructor","classes":"tsd-kind-constructor tsd-parent-kind-class","parent":"\"KeyStats\".KeyStatsEntry"},{"id":24,"kind":1,"name":"\"Peer\"","url":"modules/_peer_.html","classes":"tsd-kind-external-module"},{"id":25,"kind":128,"name":"GossipPeer","url":"classes/_peer_.gossippeer.html","classes":"tsd-kind-class tsd-parent-kind-external-module","parent":"\"Peer\""},{"id":26,"kind":1024,"name":"host","url":"classes/_peer_.gossippeer.html#host","classes":"tsd-kind-property tsd-parent-kind-class","parent":"\"Peer\".GossipPeer"},{"id":27,"kind":1024,"name":"port","url":"classes/_peer_.gossippeer.html#port","classes":"tsd-kind-property tsd-parent-kind-class","parent":"\"Peer\".GossipPeer"},{"id":28,"kind":512,"name":"constructor","url":"classes/_peer_.gossippeer.html#constructor","classes":"tsd-kind-constructor tsd-parent-kind-class","parent":"\"Peer\".GossipPeer"},{"id":29,"kind":128,"name":"MailsyncPeer","url":"classes/_peer_.mailsyncpeer.html","classes":"tsd-kind-class tsd-parent-kind-external-module","parent":"\"Peer\""},{"id":30,"kind":1024,"name":"address","url":"classes/_peer_.mailsyncpeer.html#address","classes":"tsd-kind-property tsd-parent-kind-class","parent":"\"Peer\".MailsyncPeer"},{"id":31,"kind":512,"name":"constructor","url":"classes/_peer_.mailsyncpeer.html#constructor","classes":"tsd-kind-constructor tsd-parent-kind-class","parent":"\"Peer\".MailsyncPeer"},{"id":32,"kind":1,"name":"\"Stats\"","url":"modules/_stats_.html","classes":"tsd-kind-external-module"},{"id":33,"kind":128,"name":"Stats","url":"classes/_stats_.stats.html","classes":"tsd-kind-class tsd-parent-kind-external-module","parent":"\"Stats\""},{"id":34,"kind":1024,"name":"software","url":"classes/_stats_.stats.html#software","classes":"tsd-kind-property tsd-parent-kind-class","parent":"\"Stats\".Stats"},{"id":35,"kind":1024,"name":"version","url":"classes/_stats_.stats.html#version","classes":"tsd-kind-property tsd-parent-kind-class","parent":"\"Stats\".Stats"},{"id":36,"kind":1024,"name":"hostName","url":"classes/_stats_.stats.html#hostname","classes":"tsd-kind-property tsd-parent-kind-class","parent":"\"Stats\".Stats"},{"id":37,"kind":1024,"name":"nodeName","url":"classes/_stats_.stats.html#nodename","classes":"tsd-kind-property tsd-parent-kind-class","parent":"\"Stats\".Stats"},{"id":38,"kind":1024,"name":"serverContact","url":"classes/_stats_.stats.html#servercontact","classes":"tsd-kind-property tsd-parent-kind-class","parent":"\"Stats\".Stats"},{"id":39,"kind":1024,"name":"httpPort","url":"classes/_stats_.stats.html#httpport","classes":"tsd-kind-property tsd-parent-kind-class","parent":"\"Stats\".Stats"},{"id":40,"kind":1024,"name":"reconPort","url":"classes/_stats_.stats.html#reconport","classes":"tsd-kind-property tsd-parent-kind-class","parent":"\"Stats\".Stats"},{"id":41,"kind":1024,"name":"debugLevel","url":"classes/_stats_.stats.html#debuglevel","classes":"tsd-kind-property tsd-parent-kind-class","parent":"\"Stats\".Stats"},{"id":42,"kind":1024,"name":"keys","url":"classes/_stats_.stats.html#keys","classes":"tsd-kind-property tsd-parent-kind-class","parent":"\"Stats\".Stats"},{"id":43,"kind":1024,"name":"statsTime","url":"classes/_stats_.stats.html#statstime","classes":"tsd-kind-property tsd-parent-kind-class","parent":"\"Stats\".Stats"},{"id":44,"kind":1024,"name":"gossipPeers","url":"classes/_stats_.stats.html#gossippeers","classes":"tsd-kind-property tsd-parent-kind-class","parent":"\"Stats\".Stats"},{"id":45,"kind":1024,"name":"gossipPeerCount","url":"classes/_stats_.stats.html#gossippeercount","classes":"tsd-kind-property tsd-parent-kind-class","parent":"\"Stats\".Stats"},{"id":46,"kind":1024,"name":"mailsyncPeers","url":"classes/_stats_.stats.html#mailsyncpeers","classes":"tsd-kind-property tsd-parent-kind-class","parent":"\"Stats\".Stats"},{"id":47,"kind":1024,"name":"mailsyncPeerCount","url":"classes/_stats_.stats.html#mailsyncpeercount","classes":"tsd-kind-property tsd-parent-kind-class","parent":"\"Stats\".Stats"},{"id":48,"kind":512,"name":"constructor","url":"classes/_stats_.stats.html#constructor","classes":"tsd-kind-constructor tsd-parent-kind-class","parent":"\"Stats\".Stats"},{"id":49,"kind":1,"name":"\"Keyserver\"","url":"modules/_keyserver_.html","classes":"tsd-kind-external-module"},{"id":50,"kind":128,"name":"Keyserver","url":"classes/_keyserver_.keyserver.html","classes":"tsd-kind-class tsd-parent-kind-external-module","parent":"\"Keyserver\""},{"id":51,"kind":1024,"name":"hostName","url":"classes/_keyserver_.keyserver.html#hostname","classes":"tsd-kind-property tsd-parent-kind-class","parent":"\"Keyserver\".Keyserver"},{"id":52,"kind":1024,"name":"port","url":"classes/_keyserver_.keyserver.html#port","classes":"tsd-kind-property tsd-parent-kind-class","parent":"\"Keyserver\".Keyserver"},{"id":53,"kind":1024,"name":"basePath","url":"classes/_keyserver_.keyserver.html#basepath","classes":"tsd-kind-property tsd-parent-kind-class","parent":"\"Keyserver\".Keyserver"},{"id":54,"kind":1024,"name":"requestOptions","url":"classes/_keyserver_.keyserver.html#requestoptions","classes":"tsd-kind-property tsd-parent-kind-class tsd-is-private","parent":"\"Keyserver\".Keyserver"},{"id":55,"kind":512,"name":"constructor","url":"classes/_keyserver_.keyserver.html#constructor","classes":"tsd-kind-constructor tsd-parent-kind-class","parent":"\"Keyserver\".Keyserver"},{"id":56,"kind":2048,"name":"getKeyserverHtml","url":"classes/_keyserver_.keyserver.html#getkeyserverhtml","classes":"tsd-kind-method tsd-parent-kind-class tsd-is-private","parent":"\"Keyserver\".Keyserver"},{"id":57,"kind":2048,"name":"lookup","url":"classes/_keyserver_.keyserver.html#lookup","classes":"tsd-kind-method tsd-parent-kind-class","parent":"\"Keyserver\".Keyserver"},{"id":58,"kind":2048,"name":"isPgpKey","url":"classes/_keyserver_.keyserver.html#ispgpkey","classes":"tsd-kind-method tsd-parent-kind-class tsd-is-private tsd-is-static","parent":"\"Keyserver\".Keyserver"},{"id":59,"kind":2048,"name":"upload","url":"classes/_keyserver_.keyserver.html#upload","classes":"tsd-kind-method tsd-parent-kind-class","parent":"\"Keyserver\".Keyserver"},{"id":60,"kind":2048,"name":"getStatsHtml","url":"classes/_keyserver_.keyserver.html#getstatshtml","classes":"tsd-kind-method tsd-parent-kind-class tsd-is-private","parent":"\"Keyserver\".Keyserver"},{"id":61,"kind":2048,"name":"mapStatsToView","url":"classes/_keyserver_.keyserver.html#mapstatstoview","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter","parent":"\"Keyserver\".Keyserver"},{"id":62,"kind":2048,"name":"getStats","url":"classes/_keyserver_.keyserver.html#getstats","classes":"tsd-kind-method tsd-parent-kind-class","parent":"\"Keyserver\".Keyserver"},{"id":63,"kind":2048,"name":"getKeyStats","url":"classes/_keyserver_.keyserver.html#getkeystats","classes":"tsd-kind-method tsd-parent-kind-class","parent":"\"Keyserver\".Keyserver"},{"id":64,"kind":2048,"name":"parseStatsHtml","url":"classes/_keyserver_.keyserver.html#parsestatshtml","classes":"tsd-kind-method tsd-parent-kind-class tsd-is-static","parent":"\"Keyserver\".Keyserver"},{"id":65,"kind":2048,"name":"parseKeyStatsHtml","url":"classes/_keyserver_.keyserver.html#parsekeystatshtml","classes":"tsd-kind-method tsd-parent-kind-class tsd-is-static","parent":"\"Keyserver\".Keyserver"},{"id":66,"kind":1,"name":"\"index\"","url":"modules/_index_.html","classes":"tsd-kind-external-module"}]};
\ No newline at end of file
diff --git a/docs/code/classes/_errors_.nokeyfounderror.html b/docs/code/classes/_errors_.nokeyfounderror.html
new file mode 100644
index 0000000..9a97551
--- /dev/null
+++ b/docs/code/classes/_errors_.nokeyfounderror.html
@@ -0,0 +1,313 @@
+
+
+
Constructor for creating a new no key found error
+Generated using TypeDoc
+hostname of the keyserver
+port of the keyserver
+base path where to find the keyserver (the path before /pks
, usually nothing)
Base path for the keyserver (where the /pks
paths start), (default: '')
The keyserver's raw stats html
+Request options for a query to the keyserver
Retrieves the server's key stats and returns a PromiseparseKeyStatsHtml
).
Retrieves the server's key stats and returns a PromiseparseKeyStatsHtml
)
Retrieves the keyserver's html and returns it as Promise
relative path to request, usually starts with /pks
Retrieves the server's stats and returns a PromiseparseStatsHtml
).
Retrieves the server's stats and returns a PromiseparseStatsHtml
)
Retrieves the keyserver's stats html if necessary and then returns it as Promise
Retrieves the keyserver's stats html and returns it as Promise
Retrieves a key by a given query, throws NoKeyFoundError
+query to look up
+Maps the keyserver's html to a generic promise.
+Maps the keyserver's html to a generic promise
function to transform HTML into a generic object
+Uploads a public key onto a keyserver
+public key to upload
+Checks whether a given input is a PGP key
+input to check
+Parses given html into a KeyStats object, throws ParseError.
+Parses given html into a KeyStats object, throws ParseError
HTML to parse, usually from a keyserver's stats page
+Parses given html into a Stats object, throws ParseError.
+Parses given html into a Stats object, throws ParseError
HTML to parse, usually from a keyserver's stats page
+sks-lib
is a Typescript library for interacting with SKS keyservers. Currently there's only support for retrieving a keyserver's stats.
sks-lib
is a Typescript library for interacting with SKS keyservers. Currently there's only support for retrieving statistics of a keyserver.
Please note that keyservers never return verified data. Do not trust the retrieved keys and always verify them.
Just add it with yarn install sks-lib
(or npm install sks-lib
) to your project. It ships the generated Javascript code along with Typescript's declaration files. The Typescript code itself lives in lib/
.
import {Keyserver} from 'sks-lib';
-import {Moment} from 'moment';
-
-
+ Usage
+ // Create a new keyserver object to query on
var keyserver = new Keyserver('keyserver.ntzwrk.org');
-keyserver.getStats().then(
- (stats) => {
- var hostName = stats.hostName;
- var software = stats.software;
- var version = stats.version;
- var peerCount = stats.gossipPeerCount;
+var somePublicKey: string;
- console.log('"%s" is a %s %s keyserver with %s gossip peers.', hostName, software, version, peerCount);
+// Lookup the key for "vsund" and then print it
+keyserver.lookup('vsund').then(
+ (key) => {
+ somePublicKey = key;
+ console.log(key);
}
-).catch((reason: Error) => {
- console.log('Could not connect to "%s:11371"', keyserver.hostName);
- console.log('%s: %s', reason.name, reason.message);
-});
+);
-keyserver.getKeyStats().then(
- (keyStats) => {
- var hostName = keyserver.hostName;
- var totalKeys = keyStats.totalKeys;
- var newKeys = keyStats.dailyKeys[11].newKeys;
- var date = keyStats.dailyKeys[11].dateTime.format('MMMM Do YYYY');
+// Upload the previously fetched key and print the server's response
+keyserver.upload(publicKey).then(
+ (response) => {
+ console.log(response);
+ }
+);
- console.log('"%s" has %s total keys and saw %s new keys on %s.', hostName, totalKeys, newKeys, date);
+// Get stats and then print some information
+keyserver.getStats().then(
+ (stats) => {
+ console.log('"%s" is a %s keyserver on version %s.', stats.hostName, stats.software, stats.version);
}
-).catch((reason: Error) => {
- console.log('Could not connect to "%s:11371"', keyserver.hostName);
- console.log('%s: %s', reason.name, reason.message);
-});
+);
+ See examples/
for some more examples.
Documentation
Code documentation lives in docs/code/
, the generated HTML version is available at https://ntzwrk.github.io/sks-lib/code/.
Development
@@ -137,13 +132,13 @@ License
Globals
Class representing an error that no key could been found
+