blockstack
Version:
The Blockstack Javascript library for authentication, identity, and storage.
842 lines • 60.5 kB
HTML
<!doctype html>
<html class="default no-js">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>UserSession | blockstack</title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="../assets/css/main.css">
</head>
<body>
<header>
<div class="tsd-page-toolbar">
<div class="container">
<div class="table-wrap">
<div class="table-cell" id="tsd-search" data-index="../assets/js/search.js" data-base="..">
<div class="field">
<label for="tsd-search-field" class="tsd-widget search no-caption">Search</label>
<input id="tsd-search-field" type="text" />
</div>
<ul class="results">
<li class="state loading">Preparing search index...</li>
<li class="state failure">The search index is not available</li>
</ul>
<a href="../index.html" class="title">blockstack</a>
</div>
<div class="table-cell" id="tsd-widgets">
<div id="tsd-filter">
<a href="#" class="tsd-widget options no-caption" data-toggle="options">Options</a>
<div class="tsd-filter-group">
<div class="tsd-select" id="tsd-filter-visibility">
<span class="tsd-select-label">All</span>
<ul class="tsd-select-list">
<li data-value="public">Public</li>
<li data-value="protected">Public/Protected</li>
<li data-value="private" class="selected">All</li>
</ul>
</div>
<input type="checkbox" id="tsd-filter-inherited" checked />
<label class="tsd-widget" for="tsd-filter-inherited">Inherited</label>
<input type="checkbox" id="tsd-filter-only-exported" />
<label class="tsd-widget" for="tsd-filter-only-exported">Only exported</label>
</div>
</div>
<a href="#" class="tsd-widget menu no-caption" data-toggle="menu">Menu</a>
</div>
</div>
</div>
</div>
<div class="tsd-page-title">
<div class="container">
<ul class="tsd-breadcrumb">
<li>
<a href="../globals.html">Globals</a>
</li>
<li>
<a href="usersession.html">UserSession</a>
</li>
</ul>
<h1>Class UserSession</h1>
</div>
</div>
</header>
<div class="container container-main">
<div class="row">
<div class="col-8 col-content">
<section class="tsd-panel tsd-comment">
<div class="tsd-comment tsd-typography">
<div class="lead">
<p>Represents an instance of a signed in user for a particular app.</p>
</div>
<p>A signed in user has access to two major pieces of information
about the user, the user's private key for that app and the location
of the user's gaia storage bucket for the app.</p>
<p>A user can be signed in either directly through the interactive
sign in process or by directly providing the app private key.</p>
</div>
</section>
<section class="tsd-panel tsd-hierarchy">
<h3>Hierarchy</h3>
<ul class="tsd-hierarchy">
<li>
<span class="target">UserSession</span>
</li>
</ul>
</section>
<section class="tsd-panel-group tsd-index-group">
<h2>Index</h2>
<section class="tsd-panel tsd-index-panel">
<div class="tsd-index-content">
<section class="tsd-index-section ">
<h3>Constructors</h3>
<ul class="tsd-index-list">
<li class="tsd-kind-constructor tsd-parent-kind-class"><a href="usersession.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"><a href="usersession.html#appconfig" class="tsd-kind-icon">app<wbr>Config</a></li>
<li class="tsd-kind-property tsd-parent-kind-class"><a href="usersession.html#store" class="tsd-kind-icon">store</a></li>
</ul>
</section>
<section class="tsd-index-section ">
<h3>Methods</h3>
<ul class="tsd-index-list">
<li class="tsd-kind-method tsd-parent-kind-class"><a href="usersession.html#decryptcontent" class="tsd-kind-icon">decrypt<wbr>Content</a></li>
<li class="tsd-kind-method tsd-parent-kind-class"><a href="usersession.html#deletefile" class="tsd-kind-icon">delete<wbr>File</a></li>
<li class="tsd-kind-method tsd-parent-kind-class"><a href="usersession.html#encryptcontent" class="tsd-kind-icon">encrypt<wbr>Content</a></li>
<li class="tsd-kind-method tsd-parent-kind-class"><a href="usersession.html#generateandstoretransitkey" class="tsd-kind-icon">generate<wbr>And<wbr>Store<wbr>Transit<wbr>Key</a></li>
<li class="tsd-kind-method tsd-parent-kind-class"><a href="usersession.html#getauthresponsetoken" class="tsd-kind-icon">get<wbr>Auth<wbr>Response<wbr>Token</a></li>
<li class="tsd-kind-method tsd-parent-kind-class"><a href="usersession.html#getfile" class="tsd-kind-icon">get<wbr>File</a></li>
<li class="tsd-kind-method tsd-parent-kind-class"><a href="usersession.html#getfileurl" class="tsd-kind-icon">get<wbr>File<wbr>Url</a></li>
<li class="tsd-kind-method tsd-parent-kind-class"><a href="usersession.html#getorsetlocalgaiahubconnection" class="tsd-kind-icon">get<wbr>OrSet<wbr>Local<wbr>Gaia<wbr>Hub<wbr>Connection</a></li>
<li class="tsd-kind-method tsd-parent-kind-class"><a href="usersession.html#handlependingsignin" class="tsd-kind-icon">handle<wbr>Pending<wbr>Sign<wbr>In</a></li>
<li class="tsd-kind-method tsd-parent-kind-class"><a href="usersession.html#issigninpending" class="tsd-kind-icon">is<wbr>Sign<wbr>InPending</a></li>
<li class="tsd-kind-method tsd-parent-kind-class"><a href="usersession.html#isusersignedin" class="tsd-kind-icon">is<wbr>User<wbr>Signed<wbr>In</a></li>
<li class="tsd-kind-method tsd-parent-kind-class"><a href="usersession.html#listfiles" class="tsd-kind-icon">list<wbr>Files</a></li>
<li class="tsd-kind-method tsd-parent-kind-class"><a href="usersession.html#loaduserdata" class="tsd-kind-icon">load<wbr>User<wbr>Data</a></li>
<li class="tsd-kind-method tsd-parent-kind-class"><a href="usersession.html#makeauthrequest" class="tsd-kind-icon">make<wbr>Auth<wbr>Request</a></li>
<li class="tsd-kind-method tsd-parent-kind-class"><a href="usersession.html#putfile" class="tsd-kind-icon">put<wbr>File</a></li>
<li class="tsd-kind-method tsd-parent-kind-class"><a href="usersession.html#redirecttosignin" class="tsd-kind-icon">redirect<wbr>ToSign<wbr>In</a></li>
<li class="tsd-kind-method tsd-parent-kind-class"><a href="usersession.html#redirecttosigninwithauthrequest" class="tsd-kind-icon">redirect<wbr>ToSign<wbr>InWith<wbr>Auth<wbr>Request</a></li>
<li class="tsd-kind-method tsd-parent-kind-class tsd-is-private"><a href="usersession.html#setlocalgaiahubconnection" class="tsd-kind-icon">set<wbr>Local<wbr>Gaia<wbr>Hub<wbr>Connection</a></li>
<li class="tsd-kind-method tsd-parent-kind-class"><a href="usersession.html#signuserout" class="tsd-kind-icon">sign<wbr>User<wbr>Out</a></li>
</ul>
</section>
</div>
</section>
</section>
<section class="tsd-panel-group tsd-member-group ">
<h2>Constructors</h2>
<section class="tsd-panel tsd-member tsd-kind-constructor tsd-parent-kind-class">
<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>User<wbr>Session<span class="tsd-signature-symbol">(</span>options<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">object</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><a href="usersession.html" class="tsd-signature-type">UserSession</a></li>
</ul>
<ul class="tsd-descriptions">
<li class="tsd-description">
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/blockstack/blockstack.js/blob/master/src/auth/userSession.ts#L38">auth/userSession.ts:38</a></li>
</ul>
</aside>
<h4 class="tsd-parameters-title">Parameters</h4>
<ul class="tsd-parameters">
<li>
<h5><span class="tsd-flag ts-flagOptional">Optional</span> options: <span class="tsd-signature-type">object</span></h5>
<ul class="tsd-parameters">
<li class="tsd-parameter">
<h5><span class="tsd-flag ts-flagOptional">Optional</span> app<wbr>Config<span class="tsd-signature-symbol">?: </span><a href="appconfig.html" class="tsd-signature-type">AppConfig</a></h5>
</li>
<li class="tsd-parameter">
<h5><span class="tsd-flag ts-flagOptional">Optional</span> session<wbr>Options<span class="tsd-signature-symbol">?: </span><a href="../globals.html#sessionoptions" class="tsd-signature-type">SessionOptions</a></h5>
</li>
<li class="tsd-parameter">
<h5><span class="tsd-flag ts-flagOptional">Optional</span> session<wbr>Store<span class="tsd-signature-symbol">?: </span><a href="sessiondatastore.html" class="tsd-signature-type">SessionDataStore</a></h5>
</li>
</ul>
</li>
</ul>
<h4 class="tsd-returns-title">Returns <a href="usersession.html" class="tsd-signature-type">UserSession</a></h4>
</li>
</ul>
</section>
</section>
<section class="tsd-panel-group tsd-member-group ">
<h2>Properties</h2>
<section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-class">
<a name="appconfig" class="tsd-anchor"></a>
<h3>app<wbr>Config</h3>
<div class="tsd-signature tsd-kind-icon">app<wbr>Config<span class="tsd-signature-symbol">:</span> <a href="appconfig.html" class="tsd-signature-type">AppConfig</a></div>
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/blockstack/blockstack.js/blob/master/src/auth/userSession.ts#L36">auth/userSession.ts:36</a></li>
</ul>
</aside>
</section>
<section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-class">
<a name="store" class="tsd-anchor"></a>
<h3>store</h3>
<div class="tsd-signature tsd-kind-icon">store<span class="tsd-signature-symbol">:</span> <a href="sessiondatastore.html" class="tsd-signature-type">SessionDataStore</a></div>
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/blockstack/blockstack.js/blob/master/src/auth/userSession.ts#L38">auth/userSession.ts:38</a></li>
</ul>
</aside>
</section>
</section>
<section class="tsd-panel-group tsd-member-group ">
<h2>Methods</h2>
<section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class">
<a name="decryptcontent" class="tsd-anchor"></a>
<h3>decrypt<wbr>Content</h3>
<ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class">
<li class="tsd-signature tsd-kind-icon">decrypt<wbr>Content<span class="tsd-signature-symbol">(</span>content<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span>, options<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">object</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">Buffer</span></li>
</ul>
<ul class="tsd-descriptions">
<li class="tsd-description">
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/blockstack/blockstack.js/blob/master/src/auth/userSession.ts#L275">auth/userSession.ts:275</a></li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
<div class="lead">
<p>Decrypts data encrypted with <code>encryptContent</code> with the
transit private key.</p>
</div>
</div>
<h4 class="tsd-parameters-title">Parameters</h4>
<ul class="tsd-parameters">
<li>
<h5>content: <span class="tsd-signature-type">string</span></h5>
<div class="tsd-comment tsd-typography">
<p>encrypted content.</p>
</div>
</li>
<li>
<h5><span class="tsd-flag ts-flagOptional">Optional</span> options: <span class="tsd-signature-type">object</span></h5>
<ul class="tsd-parameters">
<li class="tsd-parameter">
<h5><span class="tsd-flag ts-flagOptional">Optional</span> private<wbr>Key<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">string</span></h5>
<div class="tsd-comment tsd-typography">
<p>the hex string of the ECDSA private
key to use for decryption. If not provided, will use user's appPrivateKey.</p>
</div>
</li>
</ul>
</li>
</ul>
<h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">string</span>
<span class="tsd-signature-symbol"> | </span>
<span class="tsd-signature-type">Buffer</span>
</h4>
<p>decrypted content.</p>
</li>
</ul>
</section>
<section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class">
<a name="deletefile" class="tsd-anchor"></a>
<h3>delete<wbr>File</h3>
<ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class">
<li class="tsd-signature tsd-kind-icon">delete<wbr>File<span class="tsd-signature-symbol">(</span>path<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><span class="tsd-signature-type">void</span></li>
</ul>
<ul class="tsd-descriptions">
<li class="tsd-description">
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/blockstack/blockstack.js/blob/master/src/auth/userSession.ts#L351">auth/userSession.ts:351</a></li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
<div class="lead">
<p>Deletes the specified file from the app's data store. Currently not implemented.</p>
</div>
</div>
<h4 class="tsd-parameters-title">Parameters</h4>
<ul class="tsd-parameters">
<li>
<h5>path: <span class="tsd-signature-type">string</span></h5>
<div class="tsd-comment tsd-typography">
<p>the path to the file to delete</p>
</div>
</li>
</ul>
<h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">void</span></h4>
<p>that resolves when the file has been removed
or rejects with an error</p>
</li>
</ul>
</section>
<section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class">
<a name="encryptcontent" class="tsd-anchor"></a>
<h3>encrypt<wbr>Content</h3>
<ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class">
<li class="tsd-signature tsd-kind-icon">encrypt<wbr>Content<span class="tsd-signature-symbol">(</span>content<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">Buffer</span>, options<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">object</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span></li>
</ul>
<ul class="tsd-descriptions">
<li class="tsd-description">
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/blockstack/blockstack.js/blob/master/src/auth/userSession.ts#L259">auth/userSession.ts:259</a></li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
<div class="lead">
<p>Encrypts the data provided with the app public key.</p>
</div>
</div>
<h4 class="tsd-parameters-title">Parameters</h4>
<ul class="tsd-parameters">
<li>
<h5>content: <span class="tsd-signature-type">string</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">Buffer</span></h5>
<div class="tsd-comment tsd-typography">
<p>data to encrypt</p>
</div>
</li>
<li>
<h5><span class="tsd-flag ts-flagOptional">Optional</span> options: <span class="tsd-signature-type">object</span></h5>
<ul class="tsd-parameters">
<li class="tsd-parameter">
<h5><span class="tsd-flag ts-flagOptional">Optional</span> public<wbr>Key<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">string</span></h5>
<div class="tsd-comment tsd-typography">
<p>the hex string of the ECDSA public
key to use for encryption. If not provided, will use user's appPrivateKey.</p>
</div>
</li>
</ul>
</li>
</ul>
<h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">string</span></h4>
<p>Stringified ciphertext object</p>
</li>
</ul>
</section>
<section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class">
<a name="generateandstoretransitkey" class="tsd-anchor"></a>
<h3>generate<wbr>And<wbr>Store<wbr>Transit<wbr>Key</h3>
<ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class">
<li class="tsd-signature tsd-kind-icon">generate<wbr>And<wbr>Store<wbr>Transit<wbr>Key<span class="tsd-signature-symbol">(</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span></li>
</ul>
<ul class="tsd-descriptions">
<li class="tsd-description">
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/blockstack/blockstack.js/blob/master/src/auth/userSession.ts#L169">auth/userSession.ts:169</a></li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
<div class="lead">
<p>Generates a ECDSA keypair to
use as the ephemeral app transit private key
and store in the session</p>
</div>
</div>
<h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">string</span></h4>
<p>the hex encoded private key</p>
</li>
</ul>
</section>
<section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class">
<a name="getauthresponsetoken" class="tsd-anchor"></a>
<h3>get<wbr>Auth<wbr>Response<wbr>Token</h3>
<ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class">
<li class="tsd-signature tsd-kind-icon">get<wbr>Auth<wbr>Response<wbr>Token<span class="tsd-signature-symbol">(</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span></li>
</ul>
<ul class="tsd-descriptions">
<li class="tsd-description">
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/blockstack/blockstack.js/blob/master/src/auth/userSession.ts#L181">auth/userSession.ts:181</a></li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
<div class="lead">
<p>Retrieve the authentication token from the URL query</p>
</div>
</div>
<h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">string</span></h4>
<p>the authentication token if it exists otherwise <code>null</code></p>
</li>
</ul>
</section>
<section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class">
<a name="getfile" class="tsd-anchor"></a>
<h3>get<wbr>File</h3>
<ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class">
<li class="tsd-signature tsd-kind-icon">get<wbr>File<span class="tsd-signature-symbol">(</span>path<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span>, options<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">storage.GetFileOptions</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol"><</span><span class="tsd-signature-type">string</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">ArrayBuffer</span><span class="tsd-signature-symbol">></span></li>
</ul>
<ul class="tsd-descriptions">
<li class="tsd-description">
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/blockstack/blockstack.js/blob/master/src/auth/userSession.ts#L311">auth/userSession.ts:311</a></li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
<div class="lead">
<p>Retrieves the specified file from the app's data store.</p>
</div>
</div>
<h4 class="tsd-parameters-title">Parameters</h4>
<ul class="tsd-parameters">
<li>
<h5>path: <span class="tsd-signature-type">string</span></h5>
<div class="tsd-comment tsd-typography">
<p>the path to the file to read</p>
</div>
</li>
<li>
<h5><span class="tsd-flag ts-flagOptional">Optional</span> options: <span class="tsd-signature-type">storage.GetFileOptions</span></h5>
</li>
</ul>
<h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol"><</span><span class="tsd-signature-type">string</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">ArrayBuffer</span><span class="tsd-signature-symbol">></span></h4>
<p>that resolves to the raw data in the file
or rejects with an error</p>
</li>
</ul>
</section>
<section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class">
<a name="getfileurl" class="tsd-anchor"></a>
<h3>get<wbr>File<wbr>Url</h3>
<ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class">
<li class="tsd-signature tsd-kind-icon">get<wbr>File<wbr>Url<span class="tsd-signature-symbol">(</span>path<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span>, options<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">object</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol"><</span><span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">></span></li>
</ul>
<ul class="tsd-descriptions">
<li class="tsd-description">
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/blockstack/blockstack.js/blob/master/src/auth/userSession.ts#L327">auth/userSession.ts:327</a></li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
<div class="lead">
<p>Get the URL for reading a file from an app's data store.</p>
</div>
</div>
<h4 class="tsd-parameters-title">Parameters</h4>
<ul class="tsd-parameters">
<li>
<h5>path: <span class="tsd-signature-type">string</span></h5>
<div class="tsd-comment tsd-typography">
<p>the path to the file to read</p>
</div>
</li>
<li>
<h5><span class="tsd-flag ts-flagOptional">Optional</span> options: <span class="tsd-signature-type">object</span></h5>
<ul class="tsd-parameters">
<li class="tsd-parameter">
<h5><span class="tsd-flag ts-flagOptional">Optional</span> app<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">string</span></h5>
<div class="tsd-comment tsd-typography">
<p>the app to lookup for multi-player storage -
defaults to current origin</p>
</div>
</li>
<li class="tsd-parameter">
<h5><span class="tsd-flag ts-flagOptional">Optional</span> username<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">string</span></h5>
<div class="tsd-comment tsd-typography">
<p>the Blockstack ID to lookup for multi-player storage</p>
</div>
</li>
<li class="tsd-parameter">
<h5><span class="tsd-flag ts-flagOptional">Optional</span> zone<wbr>File<wbr>LookupURL<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">string</span></h5>
</li>
</ul>
</li>
</ul>
<h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol"><</span><span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">></span></h4>
<p>that resolves to the URL or rejects with an error</p>
</li>
</ul>
</section>
<section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class">
<a name="getorsetlocalgaiahubconnection" class="tsd-anchor"></a>
<h3>get<wbr>OrSet<wbr>Local<wbr>Gaia<wbr>Hub<wbr>Connection</h3>
<ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class">
<li class="tsd-signature tsd-kind-icon">get<wbr>OrSet<wbr>Local<wbr>Gaia<wbr>Hub<wbr>Connection<span class="tsd-signature-symbol">(</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol"><</span><a href="../globals.html#gaiahubconfig" class="tsd-signature-type">GaiaHubConfig</a><span class="tsd-signature-symbol">></span></li>
</ul>
<ul class="tsd-descriptions">
<li class="tsd-description">
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/blockstack/blockstack.js/blob/master/src/auth/userSession.ts#L356">auth/userSession.ts:356</a></li>
</ul>
</aside>
<h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol"><</span><a href="../globals.html#gaiahubconfig" class="tsd-signature-type">GaiaHubConfig</a><span class="tsd-signature-symbol">></span></h4>
</li>
</ul>
</section>
<section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class">
<a name="handlependingsignin" class="tsd-anchor"></a>
<h3>handle<wbr>Pending<wbr>Sign<wbr>In</h3>
<ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class">
<li class="tsd-signature tsd-kind-icon">handle<wbr>Pending<wbr>Sign<wbr>In<span class="tsd-signature-symbol">(</span>authResponseToken<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><span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol"><</span><a href="../interfaces/userdata.html" class="tsd-signature-type">UserData</a><span class="tsd-signature-symbol">></span></li>
</ul>
<ul class="tsd-descriptions">
<li class="tsd-description">
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/blockstack/blockstack.js/blob/master/src/auth/userSession.ts#L209">auth/userSession.ts:209</a></li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
<div class="lead">
<p>Try to process any pending sign in request by returning a <code>Promise</code> that resolves
to the user data object if the sign in succeeds.</p>
</div>
</div>
<h4 class="tsd-parameters-title">Parameters</h4>
<ul class="tsd-parameters">
<li>
<h5><span class="tsd-flag ts-flagDefault value">Default value</span> authResponseToken: <span class="tsd-signature-type">string</span><span class="tsd-signature-symbol"> = this.getAuthResponseToken()</span></h5>
<div class="tsd-comment tsd-typography">
<p>the signed authentication response token</p>
</div>
</li>
</ul>
<h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol"><</span><a href="../interfaces/userdata.html" class="tsd-signature-type">UserData</a><span class="tsd-signature-symbol">></span></h4>
<p>that resolves to the user data object if successful and rejects
if handling the sign in request fails or there was no pending sign in request.</p>
</li>
</ul>
</section>
<section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class">
<a name="issigninpending" class="tsd-anchor"></a>
<h3>is<wbr>Sign<wbr>InPending</h3>
<ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class">
<li class="tsd-signature tsd-kind-icon">is<wbr>Sign<wbr>InPending<span class="tsd-signature-symbol">(</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">boolean</span></li>
</ul>
<ul class="tsd-descriptions">
<li class="tsd-description">
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/blockstack/blockstack.js/blob/master/src/auth/userSession.ts#L189">auth/userSession.ts:189</a></li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
<div class="lead">
<p>Check if there is a authentication request that hasn't been handled.</p>
</div>
</div>
<h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">boolean</span></h4>
<p><code>true</code> if there is a pending sign in, otherwise <code>false</code></p>
</li>
</ul>
</section>
<section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class">
<a name="isusersignedin" class="tsd-anchor"></a>
<h3>is<wbr>User<wbr>Signed<wbr>In</h3>
<ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class">
<li class="tsd-signature tsd-kind-icon">is<wbr>User<wbr>Signed<wbr>In<span class="tsd-signature-symbol">(</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">boolean</span></li>
</ul>
<ul class="tsd-descriptions">
<li class="tsd-description">
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/blockstack/blockstack.js/blob/master/src/auth/userSession.ts#L197">auth/userSession.ts:197</a></li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
<div class="lead">
<p>Check if a user is currently signed in.</p>
</div>
</div>
<h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">boolean</span></h4>
<p><code>true</code> if the user is signed in, <code>false</code> if not.</p>
</li>
</ul>
</section>
<section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class">
<a name="listfiles" class="tsd-anchor"></a>
<h3>list<wbr>Files</h3>
<ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class">
<li class="tsd-signature tsd-kind-icon">list<wbr>Files<span class="tsd-signature-symbol">(</span>callback<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">function</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol"><</span><span class="tsd-signature-type">number</span><span class="tsd-signature-symbol">></span></li>
</ul>
<ul class="tsd-descriptions">
<li class="tsd-description">
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/blockstack/blockstack.js/blob/master/src/auth/userSession.ts#L341">auth/userSession.ts:341</a></li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
<div class="lead">
<p>List the set of files in this application's Gaia storage bucket.</p>
</div>
</div>
<h4 class="tsd-parameters-title">Parameters</h4>
<ul class="tsd-parameters">
<li>
<h5>callback: <span class="tsd-signature-type">function</span></h5>
<div class="tsd-comment tsd-typography">
<p>a callback to invoke on each named file that
returns <code>true</code> to continue the listing operation or <code>false</code> to end it</p>
</div>
<ul class="tsd-parameters">
<li class="tsd-parameter-siganture">
<ul class="tsd-signatures tsd-kind-type-literal tsd-is-not-exported">
<li class="tsd-signature tsd-kind-icon"><span class="tsd-signature-symbol">(</span>name<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><span class="tsd-signature-type">boolean</span></li>
</ul>
<ul class="tsd-descriptions">
<li class="tsd-description">
<h4 class="tsd-parameters-title">Parameters</h4>
<ul class="tsd-parameters">
<li>
<h5>name: <span class="tsd-signature-type">string</span></h5>
</li>
</ul>
<h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">boolean</span></h4>
</li>
</ul>
</li>
</ul>
</li>
</ul>
<h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol"><</span><span class="tsd-signature-type">number</span><span class="tsd-signature-symbol">></span></h4>
<p>that resolves to the number of files listed</p>
</li>
</ul>
</section>
<section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class">
<a name="loaduserdata" class="tsd-anchor"></a>
<h3>load<wbr>User<wbr>Data</h3>
<ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class">
<li class="tsd-signature tsd-kind-icon">load<wbr>User<wbr>Data<span class="tsd-signature-symbol">(</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><a href="../interfaces/userdata.html" class="tsd-signature-type">UserData</a></li>
</ul>
<ul class="tsd-descriptions">
<li class="tsd-description">
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/blockstack/blockstack.js/blob/master/src/auth/userSession.ts#L219">auth/userSession.ts:219</a></li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
<div class="lead">
<p>Retrieves the user data object. The user's profile is stored in the key <code>profile</code>.</p>
</div>
</div>
<h4 class="tsd-returns-title">Returns <a href="../interfaces/userdata.html" class="tsd-signature-type">UserData</a></h4>
<p>User data object.</p>
</li>
</ul>
</section>
<section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class">
<a name="makeauthrequest" class="tsd-anchor"></a>
<h3>make<wbr>Auth<wbr>Request</h3>
<ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class">
<li class="tsd-signature tsd-kind-icon">make<wbr>Auth<wbr>Request<span class="tsd-signature-symbol">(</span>transitKey<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">string</span>, redirectURI<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">string</span>, manifestURI<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">string</span>, scopes<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">[]</span>, appDomain<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">string</span>, expiresAt<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">number</span>, extraParams<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span></li>
</ul>
<ul class="tsd-descriptions">
<li class="tsd-description">
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/blockstack/blockstack.js/blob/master/src/auth/userSession.ts#L139">auth/userSession.ts:139</a></li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
<div class="lead">
<p>Generates an authentication request that can be sent to the Blockstack
browser for the user to approve sign in. This authentication request can
then be used for sign in by passing it to the <code>redirectToSignInWithAuthRequest</code>
method.</p>
</div>
<p><em>Note: This method should only be used if you want to roll your own authentication
flow. Typically you'd use <code>redirectToSignIn</code> which takes care of this
under the hood.</em></p>
</div>
<h4 class="tsd-parameters-title">Parameters</h4>
<ul class="tsd-parameters">
<li>
<h5><span class="tsd-flag ts-flagOptional">Optional</span> transitKey: <span class="tsd-signature-type">string</span></h5>
<div class="tsd-comment tsd-typography">
<p>hex-encoded transit key</p>
</div>
</li>
<li>
<h5><span class="tsd-flag ts-flagOptional">Optional</span> redirectURI: <span class="tsd-signature-type">string</span></h5>
</li>
<li>
<h5><span class="tsd-flag ts-flagOptional">Optional</span> manifestURI: <span class="tsd-signature-type">string</span></h5>
</li>
<li>
<h5><span class="tsd-flag ts-flagOptional">Optional</span> scopes: <span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">[]</span></h5>
</li>
<li>
<h5><span class="tsd-flag ts-flagOptional">Optional</span> appDomain: <span class="tsd-signature-type">string</span></h5>
</li>
<li>
<h5><span class="tsd-flag ts-flagDefault value">Default value</span> expiresAt: <span class="tsd-signature-type">number</span><span class="tsd-signature-symbol"> = nextHour().getTime()</span></h5>
<div class="tsd-comment tsd-typography">
<p>the time at which this request is no longer valid</p>
</div>
</li>
<li>
<h5><span class="tsd-flag ts-flagDefault value">Default value</span> extraParams: <span class="tsd-signature-type">any</span><span class="tsd-signature-symbol"> = {}</span></h5>
<div class="tsd-comment tsd-typography">
<p>Any extra parameters you'd like to pass to the authenticator.
Use this to pass options that aren't part of the Blockstack auth spec, but might be supported
by special authenticators.</p>
</div>
</li>
</ul>
<h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">string</span></h4>
<p>the authentication request</p>
</li>
</ul>
</section>
<section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class">
<a name="putfile" class="tsd-anchor"></a>
<h3>put<wbr>File</h3>
<ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class">
<li class="tsd-signature tsd-kind-icon">put<wbr>File<span class="tsd-signature-symbol">(</span>path<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span>, content<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">Buffer</span>, options<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">storage.PutFileOptions</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol"><</span><span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">></span></li>
</ul>
<ul class="tsd-descriptions">
<li class="tsd-description">
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/blockstack/blockstack.js/blob/master/src/auth/userSession.ts#L291">auth/userSession.ts:291</a></li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
<div class="lead">
<p>Stores the data provided in the app's data store to to the file specified.</p>
</div>
</div>
<h4 class="tsd-parameters-title">Parameters</h4>
<ul class="tsd-parameters">
<li>
<h5>path: <span class="tsd-signature-type">string</span></h5>
<div class="tsd-comment tsd-typography">
<p>the path to store the data in</p>
</div>
</li>
<li>
<h5>content: <span class="tsd-signature-type">string</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">Buffer</span></h5>
<div class="tsd-comment tsd-typography">
<p>the data to store in the file</p>
</div>
</li>
<li>
<h5><span class="tsd-flag ts-flagOptional">Optional</span> options: <span class="tsd-signature-type">storage.PutFileOptions</span></h5>
</li>
</ul>
<h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol"><</span><span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">></span></h4>
<p>that resolves if the operation succeed and rejects
if it failed</p>
</li>
</ul>
</section>
<section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class">
<a name="redirecttosignin" class="tsd-anchor"></a>
<h3>redirect<wbr>ToSign<wbr>In</h3>
<ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class">
<li class="tsd-signature tsd-kind-icon">redirect<wbr>ToSign<wbr>In<span class="tsd-signature-symbol">(</span>redirectURI<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">string</span>, manifestURI<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">string</span>, scopes<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><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">void</span></li>
</ul>
<ul class="tsd-descriptions">
<li class="tsd-description">
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/blockstack/blockstack.js/blob/master/src/auth/userSession.ts#L91">auth/userSession.ts:91</a></li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
<div class="lead">
<p>Generates an authentication request and redirects the user to the Blockstack
browser to approve the sign in request.</p>
</div>
<p>Please note that this requires that the web browser properly handles the
<code>blockstack:</code> URL protocol handler.</p>
<p>Most applications should use this
method for sign in unless they require more fine grained control over how the
authentication request is generated. If your app falls into this category,
use <code>generateAndStoreTransitKey</code>, <code>makeAuthRequest</code>,
and <code>redirectToSignInWithAuthRequest</code> to build your own sign in process.</p>
</div>
<h4 class="tsd-parameters-title">Parameters</h4>
<ul class="tsd-parameters">
<li>
<h5><span class="tsd-flag ts-flagOptional">Optional</span> redirectURI: <span class="tsd-signature-type">string</span></h5>
</li>
<li>
<h5><span class="tsd-flag ts-flagOptional">Optional</span> manifestURI: <span class="tsd-signature-type">string</span></h5>
</li>
<li>
<h5><span class="tsd-flag ts-flagOptional">Optional</span> scopes: <span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">[]</span></h5>
</li>
</ul>
<h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">void</span></h4>
</li>
</ul>
</section>
<section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class">
<a name="redirecttosigninwithauthrequest" class="tsd-anchor"></a>
<h3>redirect<wbr>ToSign<wbr>InWith<wbr>Auth<wbr>Request</h3>
<ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class">
<li class="tsd-signature tsd-kind-icon">redirect<wbr>ToSign<wbr>InWith<wbr>Auth<wbr>Request<span class="tsd-signature-symbol">(</span>authRequest<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">string</span>, blockstackIDHost<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><span class="tsd-signature-type">void</span></li>
</ul>
<ul class="tsd-descriptions">
<li class="tsd-description">
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/blockstack/blockstack.js/blob/master/src/auth/userSession.ts#L113">auth/userSession.ts:113</a></li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
<div class="lead">
<p>Redirects the user to the Blockstack browser to approve the sign in request
given.</p>
</div>
<p>The user is redirected to the authenticator URL specified in the <code>AppConfig</code>
if the <code>blockstack:</code> protocol handler is not detected.
Please note that the protocol handler detection
does not work on all browsers.</p>
</div>
<h4 class="tsd-parameters-title">Parameters</h4>
<ul class="tsd-parameters">
<li>
<h5><span class="tsd-flag ts-flagOptional">Optional</span> authRequest: <span class="tsd-signature-type">string</span></h5>
<div class="tsd-comment tsd-typography">
<p>the authentication request generated by <code>makeAuthRequest</code></p>
</div>
</li>
<li>
<h5><span class="tsd-flag ts-flagOptional">Optional</span> blockstackIDHost: <span class="tsd-signature-type">string</span></h5>
</li>
</ul>
<h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">void</span></h4>
</li>
</ul>
</section>
<section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class tsd-is-private">
<a name="setlocalgaiahubconnection" class="tsd-anchor"></a>
<h3><span class="tsd-flag ts-flagPrivate">Private</span> set<wbr>Local<wbr>Gaia<wbr>Hub<wbr>Connection</h3>
<ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class tsd-is-private">
<li class="tsd-signature tsd-kind-icon">set<wbr>Local<wbr>Gaia<wbr>Hub<wbr>Connection<span class="tsd-signature-symbol">(</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol"><</span><a href="../globals.html#gaiahubconfig" class="tsd-signature-type">GaiaHubConfig</a><span class="tsd-signature-symbol">></span></li>
</ul>
<ul class="tsd-descriptions">
<li class="tsd-description">
<aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/blockstack/blockstack.js/blob/master/src/auth/userSession.ts#L376">auth/userSession.ts:376</a></li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
<div class="lead">
<p>These two functions are app-specific connections to gaia hub,
they read the user data object for information on setting up
a hub connection, and store the hub config to localstorage</p>
</div>
</div>
<h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol"><</span><a href="../globals.html#gaiahubconfig" class="tsd-signature-type">GaiaHubConfig</a><span class="tsd-signature-symbol">></span></h4>
<p>that resolves to the new gaia hub connection</p>
</li>
</ul>
</section>
<section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class">
<a name="signuserout" class="tsd-anchor"></a>
<h3>sign<wbr>User<wbr>Out</h3>
<ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class">
<li class="tsd-signature tsd-kind-icon">sign<wbr>User<wbr>Out<span class="tsd-signature-symbol">(</span>redirectURL<span class="tsd-signature-symbol">?: </s