Skip to content
This repository has been archived by the owner on Nov 14, 2023. It is now read-only.

Commit

Permalink
Merge branch 'release/1.1.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
vsund committed Feb 5, 2018
2 parents e8b7c52 + 68bea6d commit 12cb0e4
Show file tree
Hide file tree
Showing 27 changed files with 967 additions and 277 deletions.
55 changes: 26 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,52 +16,49 @@
</table>
<br />

`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

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

Expand Down
4 changes: 2 additions & 2 deletions docs/code/assets/js/search.js

Large diffs are not rendered by default.

313 changes: 313 additions & 0 deletions docs/code/classes/_errors_.nokeyfounderror.html

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,10 @@
<a href="../globals.html">Globals</a>
</li>
<li>
<a href="../modules/_parseerror_.html">&quot;ParseError&quot;</a>
<a href="../modules/_errors_.html">&quot;Errors&quot;</a>
</li>
<li>
<a href="_parseerror_.parseerror.html">ParseError</a>
<a href="_errors_.parseerror.html">ParseError</a>
</li>
</ul>
<h1>Class ParseError</h1>
Expand Down Expand Up @@ -96,16 +96,16 @@ <h2>Index</h2>
<section class="tsd-index-section ">
<h3>Constructors</h3>
<ul class="tsd-index-list">
<li class="tsd-kind-constructor tsd-parent-kind-class"><a href="_parseerror_.parseerror.html#constructor" class="tsd-kind-icon">constructor</a></li>
<li class="tsd-kind-constructor tsd-parent-kind-class"><a href="_errors_.parseerror.html#constructor" class="tsd-kind-icon">constructor</a></li>
</ul>
</section>
<section class="tsd-index-section ">
<h3>Properties</h3>
<ul class="tsd-index-list">
<li class="tsd-kind-property tsd-parent-kind-class tsd-is-static"><a href="_parseerror_.parseerror.html#error" class="tsd-kind-icon">Error</a></li>
<li class="tsd-kind-property tsd-parent-kind-class tsd-is-inherited tsd-is-static"><a href="_parseerror_.parseerror.html#message" class="tsd-kind-icon">message</a></li>
<li class="tsd-kind-property tsd-parent-kind-class tsd-is-inherited tsd-is-static"><a href="_parseerror_.parseerror.html#name" class="tsd-kind-icon">name</a></li>
<li class="tsd-kind-property tsd-parent-kind-class tsd-is-overwrite tsd-is-inherited tsd-is-static"><a href="_parseerror_.parseerror.html#stack" class="tsd-kind-icon">stack</a></li>
<li class="tsd-kind-property tsd-parent-kind-class tsd-is-static"><a href="_errors_.parseerror.html#error" class="tsd-kind-icon">Error</a></li>
<li class="tsd-kind-property tsd-parent-kind-class tsd-is-inherited tsd-is-static"><a href="_errors_.parseerror.html#message" class="tsd-kind-icon">message</a></li>
<li class="tsd-kind-property tsd-parent-kind-class tsd-is-inherited tsd-is-static"><a href="_errors_.parseerror.html#name" class="tsd-kind-icon">name</a></li>
<li class="tsd-kind-property tsd-parent-kind-class tsd-is-overwrite tsd-is-inherited tsd-is-static"><a href="_errors_.parseerror.html#stack" class="tsd-kind-icon">stack</a></li>
</ul>
</section>
</div>
Expand All @@ -117,13 +117,13 @@ <h2>Constructors</h2>
<a name="constructor" class="tsd-anchor"></a>
<h3>constructor</h3>
<ul class="tsd-signatures tsd-kind-constructor tsd-parent-kind-class">
<li class="tsd-signature tsd-kind-icon">new <wbr>Parse<wbr>Error<span class="tsd-signature-symbol">(</span>attribute<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">undefined</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><a href="_parseerror_.parseerror.html" class="tsd-signature-type">ParseError</a></li>
<li class="tsd-signature tsd-kind-icon">new <wbr>Parse<wbr>Error<span class="tsd-signature-symbol">(</span>attribute<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">undefined</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><a href="_errors_.parseerror.html" class="tsd-signature-type">ParseError</a></li>
</ul>
<ul class="tsd-descriptions">
<li class="tsd-description">
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/ntzwrk/sks-lib/blob/master/lib/ParseError.ts#L4">ParseError.ts:4</a></li>
<li>Defined in <a href="https://github.com/ntzwrk/sks-lib/blob/master/lib/Errors.ts#L17">Errors.ts:17</a></li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
Expand All @@ -137,7 +137,7 @@ <h4 class="tsd-parameters-title">Parameters</h4>
<h5><span class="tsd-flag ts-flagOptional">Optional</span> attribute: <span class="tsd-signature-type">undefined</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">string</span></h5>
</li>
</ul>
<h4 class="tsd-returns-title">Returns <a href="_parseerror_.parseerror.html" class="tsd-signature-type">ParseError</a></h4>
<h4 class="tsd-returns-title">Returns <a href="_errors_.parseerror.html" class="tsd-signature-type">ParseError</a></h4>
</li>
</ul>
</section>
Expand All @@ -150,7 +150,7 @@ <h3><span class="tsd-flag ts-flagStatic">Static</span> Error</h3>
<div class="tsd-signature tsd-kind-icon">Error<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">ErrorConstructor</span></div>
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/ntzwrk/sks-lib/blob/master/lib//home/me/Code/sks/sks-lib/node_modules/typedoc/node_modules/typescript/lib/lib.es5.d.ts#L884">/home/me/Code/sks/sks-lib/node_modules/typedoc/node_modules/typescript/lib/lib.es5.d.ts:884</a></li>
<li>Defined in <a href="https://github.com/ntzwrk/sks-lib/blob/master/lib//home/me/Code/sks/sks-lib/node_modules/typescript/lib/lib.es5.d.ts#L896">/home/me/Code/sks/sks-lib/node_modules/typescript/lib/lib.es5.d.ts:896</a></li>
</ul>
</aside>
</section>
Expand All @@ -161,7 +161,7 @@ <h3><span class="tsd-flag ts-flagStatic">Static</span> message</h3>
<aside class="tsd-sources">
<p>Inherited from Error.message</p>
<ul>
<li>Defined in <a href="https://github.com/ntzwrk/sks-lib/blob/master/lib//home/me/Code/sks/sks-lib/node_modules/typedoc/node_modules/typescript/lib/lib.es5.d.ts#L874">/home/me/Code/sks/sks-lib/node_modules/typedoc/node_modules/typescript/lib/lib.es5.d.ts:874</a></li>
<li>Defined in <a href="https://github.com/ntzwrk/sks-lib/blob/master/lib//home/me/Code/sks/sks-lib/node_modules/typescript/lib/lib.es5.d.ts#L886">/home/me/Code/sks/sks-lib/node_modules/typescript/lib/lib.es5.d.ts:886</a></li>
</ul>
</aside>
</section>
Expand All @@ -172,7 +172,7 @@ <h3><span class="tsd-flag ts-flagStatic">Static</span> name</h3>
<aside class="tsd-sources">
<p>Inherited from Error.name</p>
<ul>
<li>Defined in <a href="https://github.com/ntzwrk/sks-lib/blob/master/lib//home/me/Code/sks/sks-lib/node_modules/typedoc/node_modules/typescript/lib/lib.es5.d.ts#L873">/home/me/Code/sks/sks-lib/node_modules/typedoc/node_modules/typescript/lib/lib.es5.d.ts:873</a></li>
<li>Defined in <a href="https://github.com/ntzwrk/sks-lib/blob/master/lib//home/me/Code/sks/sks-lib/node_modules/typescript/lib/lib.es5.d.ts#L885">/home/me/Code/sks/sks-lib/node_modules/typescript/lib/lib.es5.d.ts:885</a></li>
</ul>
</aside>
</section>
Expand All @@ -184,7 +184,7 @@ <h3><span class="tsd-flag ts-flagStatic">Static</span> <span class="tsd-flag ts-
<p>Inherited from Error.stack</p>
<p>Overrides Error.stack</p>
<ul>
<li>Defined in <a href="https://github.com/ntzwrk/sks-lib/blob/master/lib//home/me/Code/sks/sks-lib/node_modules/typedoc/node_modules/typescript/lib/lib.es5.d.ts#L875">/home/me/Code/sks/sks-lib/node_modules/typedoc/node_modules/typescript/lib/lib.es5.d.ts:875</a></li>
<li>Defined in <a href="https://github.com/ntzwrk/sks-lib/blob/master/lib//home/me/Code/sks/sks-lib/node_modules/typescript/lib/lib.es5.d.ts#L887">/home/me/Code/sks/sks-lib/node_modules/typescript/lib/lib.es5.d.ts:887</a></li>
</ul>
</aside>
</section>
Expand All @@ -196,15 +196,15 @@ <h3><span class="tsd-flag ts-flagStatic">Static</span> <span class="tsd-flag ts-
<li class="globals ">
<a href="../globals.html"><em>Globals</em></a>
</li>
<li class="current tsd-kind-external-module">
<a href="../modules/_errors_.html">"<wbr>Errors"</a>
</li>
<li class=" tsd-kind-external-module">
<a href="../modules/_keystats_.html">"<wbr>Key<wbr>Stats"</a>
</li>
<li class=" tsd-kind-external-module">
<a href="../modules/_keyserver_.html">"<wbr>Keyserver"</a>
</li>
<li class="current tsd-kind-external-module">
<a href="../modules/_parseerror_.html">"<wbr>Parse<wbr>Error"</a>
</li>
<li class=" tsd-kind-external-module">
<a href="../modules/_peer_.html">"<wbr>Peer"</a>
</li>
Expand All @@ -218,25 +218,28 @@ <h3><span class="tsd-flag ts-flagStatic">Static</span> <span class="tsd-flag ts-
</nav>
<nav class="tsd-navigation secondary menu-sticky">
<ul class="before-current">
<li class=" tsd-kind-class tsd-parent-kind-external-module">
<a href="_errors_.nokeyfounderror.html" class="tsd-kind-icon">No<wbr>Key<wbr>Found<wbr>Error</a>
</li>
</ul>
<ul class="current">
<li class="current tsd-kind-class tsd-parent-kind-external-module">
<a href="_parseerror_.parseerror.html" class="tsd-kind-icon">Parse<wbr>Error</a>
<a href="_errors_.parseerror.html" class="tsd-kind-icon">Parse<wbr>Error</a>
<ul>
<li class=" tsd-kind-constructor tsd-parent-kind-class">
<a href="_parseerror_.parseerror.html#constructor" class="tsd-kind-icon">constructor</a>
<a href="_errors_.parseerror.html#constructor" class="tsd-kind-icon">constructor</a>
</li>
<li class=" tsd-kind-property tsd-parent-kind-class tsd-is-static">
<a href="_parseerror_.parseerror.html#error" class="tsd-kind-icon">Error</a>
<a href="_errors_.parseerror.html#error" class="tsd-kind-icon">Error</a>
</li>
<li class=" tsd-kind-property tsd-parent-kind-class tsd-is-inherited tsd-is-static">
<a href="_parseerror_.parseerror.html#message" class="tsd-kind-icon">message</a>
<a href="_errors_.parseerror.html#message" class="tsd-kind-icon">message</a>
</li>
<li class=" tsd-kind-property tsd-parent-kind-class tsd-is-inherited tsd-is-static">
<a href="_parseerror_.parseerror.html#name" class="tsd-kind-icon">name</a>
<a href="_errors_.parseerror.html#name" class="tsd-kind-icon">name</a>
</li>
<li class=" tsd-kind-property tsd-parent-kind-class tsd-is-overwrite tsd-is-inherited tsd-is-static">
<a href="_parseerror_.parseerror.html#stack" class="tsd-kind-icon">stack</a>
<a href="_errors_.parseerror.html#stack" class="tsd-kind-icon">stack</a>
</li>
</ul>
</li>
Expand Down
Loading

0 comments on commit 12cb0e4

Please sign in to comment.