node-posh
Version:
PKIX Over Secure HTTP (POSH) tools for node.js
228 lines (173 loc) • 7.74 kB
HTML
<!-- Documentation generated by [CoffeeDoc](http://github.com/omarkhan/coffeedoc) -->
<html>
<head>
<title>CoffeeDoc | index.coffee</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" media="all" href="../resources/base.css" />
</head>
<body>
<header>
<h1>index.coffee</h1>
</header>
<div class="container">
<div class="sidebar column">
<h4>Classes</h4>
<ul class="classlist">
<li><a href="#POSH">POSH</a></li>
</ul>
<h4>Functions</h4>
<ul class="functionlist">
<li><a href="#exports.create">exports.create</a></li>
<li><a href="#exports.write">exports.write</a></li>
</ul>
</div>
<div class="content column">
<div id="module-docstring">
<h1>node-posh</h1>
<p>See <a href="http://tools.ietf.org/html/draft-miller-posh-00">draft-miller-posh</a>
for more details on PKIX over Secure HTTP (POSH).</p>
</div>
<div id="classes">
<h2>Classes</h2>
<div class="class">
<div class="header">
<a id="POSH"><h3>POSH</h3></a>
<a class="parent" href="#events.EventEmitter"><h3>extends events.EventEmitter</h3></a>
</div>
<div class="class-content">
<p>Make a POSH-verified connection to a given domain on a given service.</p>
<p>Events:</p>
<ul>
<li><code>'posh request', url</code> about to request a POSH document at the given URL</li>
<li><code>'no posh', er</code> No POSH document could be retrieved. Not really an error.</li>
<li><code>'connecting', host, port, tls</code> Connecting on the given host and port. If
<code>tls</code> is true, a TLS handshake will start as soon as the connection
finishes.</li>
<li><code>'error', er</code> an error was detected.</li>
<li><code>'connect', socket</code> the given socket was connected</li>
<li><code>'secure', service_cert, posh_document</code> the connection is secure
either by RFC 6125 or POSH. The posh_document is null if the service_cert
was valid via RFC 6125.</li>
<li><code>'insecure', service_cert, posh_document</code> the connection could not be
determined to be secure. The posh_document is null if it could not be
retrieved.</li>
</ul>
<div class="methods">
<div class="instancemethods">
<h3>Instance Methods</h3>
<div class="method">
<h4>constructor(@dns_domain, @dns_srv, options)</h4>
<p>Create a POSH connection object</p>
<ul>
<li><code>dns_domain</code> connect to the given domain</li>
<li><code>dns_srv</code> the DNS SRV protocol name to connect with.
For example, "_xmpp-server._tcp"</li>
<li><code>options</code> a configuration object<ul>
<li><code>fallback_port</code> The port to fall back on if SRV fails. If -1, use
the port for the given SRV protocol name from /etc/services. Defaults
to -1.</li>
<li><code>start_tls</code> Don't do TLS immediately after connecting. Instead, wait
for a listener for the <code>connect</code> event to call <code>start_tls()</code>.</li>
<li><code>ca</code> An array of zero or more certificate authority (CA) certs to trust
when making HTTPS calls for POSH certs.</li>
</ul>
</li>
</ul>
</div>
<div class="method">
<h4>get_posh()</h4>
<p>Attempt to get the POSH assertion for the domain and SRV protocol
given in the constructor</p>
<ul>
<li><strong>returns</strong> a <a href="https://github.com/kriskowal/q">Q</a> promise that will be
fulfilled with the POSH object when/if it is retrieved. Rejections of
this promise usually shouldn't be treated as an error.</li>
</ul>
</div>
<div class="method">
<h4>resolve()</h4>
<p>Do the SRV resolution.</p>
<ul>
<li><strong>returns</strong> a <a href="https://github.com/kriskowal/q">Q</a> promise that will be
fulfilled with <code>host</code>, <code>port</code> when complete. Ignores DNS errors, returning
the original domain and fallback port.</li>
</ul>
</div>
<div class="method">
<h4>connect_plain()</h4>
<p>Connect without starting TLS. Wait for the <code>connect</code> event, then call
<code>start_tls</code>.</p>
<ul>
<li><strong>returns</strong> a <a href="https://github.com/kriskowal/q">Q</a> promise that will be
fulfilled with the connected socket.</li>
</ul>
</div>
<div class="method">
<h4>connect_tls()</h4>
<p>Connect to the given serice, and start TLS immediately.</p>
<ul>
<li><strong>returns</strong> a <a href="https://github.com/kriskowal/q">Q</a> promise that will be
fulfilled with the connected socket.</li>
</ul>
</div>
<div class="method">
<h4>start_tls()</h4>
<p>On the already-connected socket, start a TLS handshake. This MUST occur
after the 'connect' event has been called.</p>
</div>
<div class="method">
<h4>connect()</h4>
<p>Connect to the domain on the specified service, using either an initially-
plaintext approach (options.start_tls=true), or an initially-encrypted
approach (options.start_tls=false).</p>
<ul>
<li><strong>returns</strong> a <a href="https://github.com/kriskowal/q">Q</a> promise that will be
fulfilled with the connected socket.</li>
</ul>
</div>
</div>
</div>
</div>
</div>
</div>
<div id="functions">
<h2>Functions</h2>
<div class="function">
<div class="header">
<a id="exports.create"><h3>exports.create(certs, maxdepth)</h3></a>
</div>
<div>
<p>Create a POSH document from a list of certificates.</p>
<ul>
<li><code>certs</code> an array of PEM-encoded certificate chains. The first certificate
in each chain will be extracted into the POSH public key information.</li>
<li><code>maxdepth</code> the maxiumum number of certificates to use from each chain.</li>
<li><strong>returns</strong> a <a href="https://github.com/kriskowal/q">Q</a> promise that will be
fulfilled with a JavaScript representation (not a JSON string!) of the
POSH document.</li>
</ul>
</div>
</div>
<div class="function">
<div class="header">
<a id="exports.write"><h3>exports.write(dir, service, posh)</h3></a>
</div>
<div>
<p>Write a file with the given POSH object in a file with the correct name
for the given service.</p>
<ul>
<li><code>dir</code> the directory to write into</li>
<li><code>service</code> the SRV record name for the target service.
Example: "_xmpp-server._tcp"</li>
<li><strong>returns</strong> a <a href="https://github.com/kriskowal/q">Q</a> promise that will be
fulfilled when the file is finished writing</li>
</ul>
</div>
</div>
</div>
</div>
</div>
</body>
</html>