Files
stacks.js/docs/index.html

2833 lines
69 KiB
HTML

<!doctype html>
<html>
<head>
<meta charset='utf-8' />
<title>blockstack 18.0.4 | Documentation</title>
<meta name='viewport' content='width=device-width,initial-scale=1'>
<link href='assets/bass.css' type='text/css' rel='stylesheet' />
<link href='assets/style.css' type='text/css' rel='stylesheet' />
<link href='assets/github.css' type='text/css' rel='stylesheet' />
<link href='assets/split.css' type='text/css' rel='stylesheet' />
</head>
<body class='documentation m0'>
<div class='flex'>
<div id='split-left' class='overflow-auto fs0 height-viewport-100'>
<div class='py1 px2'>
<h3 class='mb0 no-anchor'>blockstack</h3>
<div class='mb1'><code>18.0.4</code></div>
<input
placeholder='Filter'
id='filter-input'
class='col12 block input'
type='text' />
<div id='toc'>
<ul class='list-reset h5 py1-ul'>
<li><a
href='#authentication'
class="h5 bold black caps">
Authentication
</a>
</li>
<li><a
href='#appconfig'
class=" toggle-sibling">
AppConfig
<span class='icon'></span>
</a>
<div class='toggle-target display-none'>
<ul class='list-reset py1-ul pl1'>
<li class='h5'><span>Instance members</span></li>
<li><a
href='#appconfigappdomain'
class='regular pre-open'>
#appDomain
</a></li>
<li><a
href='#appconfigscopes'
class='regular pre-open'>
#scopes
</a></li>
<li><a
href='#appconfigredirectpath'
class='regular pre-open'>
#redirectPath
</a></li>
<li><a
href='#appconfigmanifestpath'
class='regular pre-open'>
#manifestPath
</a></li>
<li><a
href='#appconfigcorenode'
class='regular pre-open'>
#coreNode
</a></li>
<li><a
href='#appconfigauthenticatorurl'
class='regular pre-open'>
#authenticatorURL
</a></li>
<li><a
href='#appconfigredirecturi'
class='regular pre-open'>
#redirectURI
</a></li>
<li><a
href='#appconfigmanifesturi'
class='regular pre-open'>
#manifestURI
</a></li>
</ul>
</div>
</li>
<li><a
href='#usersession'
class=" toggle-sibling">
UserSession
<span class='icon'></span>
</a>
<div class='toggle-target display-none'>
<ul class='list-reset py1-ul pl1'>
<li class='h5'><span>Instance members</span></li>
<li><a
href='#usersessionredirecttosignin'
class='regular pre-open'>
#redirectToSignIn
</a></li>
<li><a
href='#usersessionredirecttosigninwithauthrequest'
class='regular pre-open'>
#redirectToSignInWithAuthRequest
</a></li>
<li><a
href='#usersessiongenerateandstoretransitkey'
class='regular pre-open'>
#generateAndStoreTransitKey
</a></li>
<li><a
href='#usersessiongetauthresponsetoken'
class='regular pre-open'>
#getAuthResponseToken
</a></li>
<li><a
href='#usersessionissigninpending'
class='regular pre-open'>
#isSignInPending
</a></li>
<li><a
href='#usersessionisusersignedin'
class='regular pre-open'>
#isUserSignedIn
</a></li>
<li><a
href='#usersessionhandlependingsignin'
class='regular pre-open'>
#handlePendingSignIn
</a></li>
<li><a
href='#usersessionloaduserdata'
class='regular pre-open'>
#loadUserData
</a></li>
<li><a
href='#usersessionsignuserout'
class='regular pre-open'>
#signUserOut
</a></li>
<li><a
href='#usersessionencryptcontent'
class='regular pre-open'>
#encryptContent
</a></li>
<li><a
href='#usersessiondecryptcontent'
class='regular pre-open'>
#decryptContent
</a></li>
<li><a
href='#usersessionputfile'
class='regular pre-open'>
#putFile
</a></li>
<li><a
href='#usersessiongetfile'
class='regular pre-open'>
#getFile
</a></li>
<li><a
href='#usersessionlistfiles'
class='regular pre-open'>
#listFiles
</a></li>
</ul>
</div>
</li>
<li><a
href='#profiles'
class="h5 bold black caps">
Profiles
</a>
</li>
<li><a
href='#extractprofile'
class="">
extractProfile
</a>
</li>
<li><a
href='#wrapprofiletoken'
class="">
wrapProfileToken
</a>
</li>
<li><a
href='#signprofiletoken'
class="">
signProfileToken
</a>
</li>
<li><a
href='#verifyprofiletoken'
class="">
verifyProfileToken
</a>
</li>
<li><a
href='#validateproofs'
class="">
validateProofs
</a>
</li>
<li><a
href='#lookupprofile'
class="">
lookupProfile
</a>
</li>
<li><a
href='#storage'
class="h5 bold black caps">
Storage
</a>
</li>
<li><a
href='#getappbucketurl'
class="">
getAppBucketUrl
</a>
</li>
<li><a
href='#getuserappfileurl'
class="">
getUserAppFileUrl
</a>
</li>
</ul>
</div>
<div class='mt1 h6 quiet'>
<a href='http://documentation.js.org/reading-documentation.html'>Need help reading this?</a>
</div>
</div>
</div>
<div id='split-right' class='relative overflow-auto height-viewport-100'>
<div class='keyline-top-not py2'><section class='py2 clearfix'>
<h2 id='authentication' class='mt0'>
Authentication
</h2>
<p>Single sign on and authentication without third parties or remote servers.</p>
<p><a href="https://github.com/blockstack/blockstack.js/blob/master/src/auth/README.md">Read more about authentication</a></p>
</section>
</div>
<section class='p2 mb2 clearfix bg-white minishadow'>
<div class='clearfix'>
<h3 class='fl m0' id='appconfig'>
AppConfig
</h3>
</div>
<p>Configuration data for the current app.</p>
<p>On browser platforms, creating an instance of this
class without any arguments will use
<code>window.location.origin</code> as the app domain.
On non-browser platforms, you need to
specify an app domain as the first argument.</p>
<div class='pre p1 fill-light mt0'>new AppConfig(appDomain: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>, scopes: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array">Array</a>&#x3C;<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>>, redirectPath: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>, manifestPath: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>, coreNode: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>, authenticatorURL: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>)</div>
<p>
Type:
<a href="#appconfig">AppConfig</a>
</p>
<div class='py1 quiet mt1 prose-big'>Parameters</div>
<div class='prose'>
<div class='space-bottom0'>
<div>
<span class='code bold'>appDomain</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>
= <code>window.location.origin</code>)</code>
the app domain
</div>
</div>
<div class='space-bottom0'>
<div>
<span class='code bold'>scopes</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array">Array</a>&#x3C;<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>>
= <code>DEFAULT_SCOPE.slice()</code>)</code>
permissions this app is requesting
</div>
</div>
<div class='space-bottom0'>
<div>
<span class='code bold'>redirectPath</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>
= <code>&#39;&#39;</code>)</code>
path on app domain to redirect users to after authentication
</div>
</div>
<div class='space-bottom0'>
<div>
<span class='code bold'>manifestPath</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>
= <code>&#39;/manifest.json&#39;</code>)</code>
path relative to app domain of app's manifest file
</div>
</div>
<div class='space-bottom0'>
<div>
<span class='code bold'>coreNode</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>
= <code>null</code>)</code>
override the default or user selected core node
</div>
</div>
<div class='space-bottom0'>
<div>
<span class='code bold'>authenticatorURL</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>
= <code>DEFAULT_BLOCKSTACK_HOST</code>)</code>
the web-based fall back authenticator
</div>
</div>
</div>
<div class='py1 quiet mt1 prose-big'>Instance Members</div>
<div class="clearfix">
<div class='border-bottom' id='appconfigappdomain'>
<div class="clearfix small pointer toggle-sibling">
<div class="py1 contain">
<a class='icon pin-right py1 dark-link caret-right'></a>
<span class='code strong strong truncate'>appDomain</span>
</div>
</div>
<div class="clearfix display-none toggle-target">
<section class='p2 mb2 clearfix bg-white minishadow'>
<p>Blockstack apps are uniquely identified by their app domain.</p>
<div class='pre p1 fill-light mt0'>appDomain</div>
<p>
Type:
<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>
</p>
</section>
</div>
</div>
<div class='border-bottom' id='appconfigscopes'>
<div class="clearfix small pointer toggle-sibling">
<div class="py1 contain">
<a class='icon pin-right py1 dark-link caret-right'></a>
<span class='code strong strong truncate'>scopes</span>
</div>
</div>
<div class="clearfix display-none toggle-target">
<section class='p2 mb2 clearfix bg-white minishadow'>
<p>An array of string representing permissions requested by the app.</p>
<div class='pre p1 fill-light mt0'>scopes</div>
<p>
Type:
<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array">Array</a>&#x3C;<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>>
</p>
</section>
</div>
</div>
<div class='border-bottom' id='appconfigredirectpath'>
<div class="clearfix small pointer toggle-sibling">
<div class="py1 contain">
<a class='icon pin-right py1 dark-link caret-right'></a>
<span class='code strong strong truncate'>redirectPath</span>
</div>
</div>
<div class="clearfix display-none toggle-target">
<section class='p2 mb2 clearfix bg-white minishadow'>
<p>Path on app domain to redirect users to after authentication. The
authentication response token will be postpended in a query.</p>
<div class='pre p1 fill-light mt0'>redirectPath</div>
<p>
Type:
<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>
</p>
</section>
</div>
</div>
<div class='border-bottom' id='appconfigmanifestpath'>
<div class="clearfix small pointer toggle-sibling">
<div class="py1 contain">
<a class='icon pin-right py1 dark-link caret-right'></a>
<span class='code strong strong truncate'>manifestPath</span>
</div>
</div>
<div class="clearfix display-none toggle-target">
<section class='p2 mb2 clearfix bg-white minishadow'>
<p>Path relative to app domain of app's manifest file.</p>
<p>This file needs to have CORS headers set so that it can be fetched
from any origin. Typically this means return the header <code>Access-Control-Allow-Origin: *</code>.</p>
<div class='pre p1 fill-light mt0'>manifestPath</div>
<p>
Type:
<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>
</p>
</section>
</div>
</div>
<div class='border-bottom' id='appconfigcorenode'>
<div class="clearfix small pointer toggle-sibling">
<div class="py1 contain">
<a class='icon pin-right py1 dark-link caret-right'></a>
<span class='code strong strong truncate'>coreNode</span>
</div>
</div>
<div class="clearfix display-none toggle-target">
<section class='p2 mb2 clearfix bg-white minishadow'>
<p>The URL of Blockstack core node to use for this app. If this is
<code>null</code>, the core node specified by the user or default core node
will be used.</p>
<div class='pre p1 fill-light mt0'>coreNode</div>
<p>
Type:
<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>
</p>
</section>
</div>
</div>
<div class='border-bottom' id='appconfigauthenticatorurl'>
<div class="clearfix small pointer toggle-sibling">
<div class="py1 contain">
<a class='icon pin-right py1 dark-link caret-right'></a>
<span class='code strong strong truncate'>authenticatorURL</span>
</div>
</div>
<div class="clearfix display-none toggle-target">
<section class='p2 mb2 clearfix bg-white minishadow'>
<p>The URL of a web-based Blockstack Authenticator to use in the event
the user doesn't have Blockstack installed on their machine. If this
is not specified, the current default in this library will be used.</p>
<div class='pre p1 fill-light mt0'>authenticatorURL</div>
<p>
Type:
<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>
</p>
</section>
</div>
</div>
<div class='border-bottom' id='appconfigredirecturi'>
<div class="clearfix small pointer toggle-sibling">
<div class="py1 contain">
<a class='icon pin-right py1 dark-link caret-right'></a>
<span class='code strong strong truncate'>redirectURI()</span>
</div>
</div>
<div class="clearfix display-none toggle-target">
<section class='p2 mb2 clearfix bg-white minishadow'>
<p>The location to which the authenticator should
redirect the user.</p>
<div class='pre p1 fill-light mt0'>redirectURI(): <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></div>
<div class='py1 quiet mt1 prose-big'>Returns</div>
<code><a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code>:
URI
</section>
</div>
</div>
<div class='border-bottom' id='appconfigmanifesturi'>
<div class="clearfix small pointer toggle-sibling">
<div class="py1 contain">
<a class='icon pin-right py1 dark-link caret-right'></a>
<span class='code strong strong truncate'>manifestURI()</span>
</div>
</div>
<div class="clearfix display-none toggle-target">
<section class='p2 mb2 clearfix bg-white minishadow'>
<p>The location of the app's manifest file.</p>
<div class='pre p1 fill-light mt0'>manifestURI(): <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></div>
<div class='py1 quiet mt1 prose-big'>Returns</div>
<code><a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code>:
URI
</section>
</div>
</div>
</div>
</section>
<section class='p2 mb2 clearfix bg-white minishadow'>
<div class='clearfix'>
<h3 class='fl m0' id='usersession'>
UserSession
</h3>
</div>
<p>Represents an instance of a signed in user for a particular app.</p>
<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 class='pre p1 fill-light mt0'>new UserSession(options: {appConfig: <a href="#appconfig">AppConfig</a>?, sessionStore: SessionDataStore?, sessionOptions: SessionOptions?})</div>
<p>
Type:
<a href="#usersession">UserSession</a>
</p>
<div class='py1 quiet mt1 prose-big'>Parameters</div>
<div class='prose'>
<div class='space-bottom0'>
<div>
<span class='code bold'>options</span> <code class='quiet'>({appConfig: <a href="#appconfig">AppConfig</a>?, sessionStore: SessionDataStore?, sessionOptions: SessionOptions?})</code>
</div>
</div>
</div>
<div class='py1 quiet mt1 prose-big'>Instance Members</div>
<div class="clearfix">
<div class='border-bottom' id='usersessionredirecttosignin'>
<div class="clearfix small pointer toggle-sibling">
<div class="py1 contain">
<a class='icon pin-right py1 dark-link caret-right'></a>
<span class='code strong strong truncate'>redirectToSignIn()</span>
</div>
</div>
<div class="clearfix display-none toggle-target">
<section class='p2 mb2 clearfix bg-white minishadow'>
<p>Generates an authentication request and redirects the user to the Blockstack
browser to approve the sign in request.</p>
<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 class='pre p1 fill-light mt0'>redirectToSignIn(): void</div>
<div class='py1 quiet mt1 prose-big'>Returns</div>
<code>void</code>:
</section>
</div>
</div>
<div class='border-bottom' id='usersessionredirecttosigninwithauthrequest'>
<div class="clearfix small pointer toggle-sibling">
<div class="py1 contain">
<a class='icon pin-right py1 dark-link caret-right'></a>
<span class='code strong strong truncate'>redirectToSignInWithAuthRequest(authRequest)</span>
</div>
</div>
<div class="clearfix display-none toggle-target">
<section class='p2 mb2 clearfix bg-white minishadow'>
<p>Redirects the user to the Blockstack browser to approve the sign in request
given.</p>
<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 class='pre p1 fill-light mt0'>redirectToSignInWithAuthRequest(authRequest: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">String</a>): void</div>
<div class='py1 quiet mt1 prose-big'>Parameters</div>
<div class='prose'>
<div class='space-bottom0'>
<div>
<span class='code bold'>authRequest</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">String</a>)</code>
the authentication request generated by
<code>makeAuthRequest</code>
</div>
</div>
</div>
<div class='py1 quiet mt1 prose-big'>Returns</div>
<code>void</code>:
</section>
</div>
</div>
<div class='border-bottom' id='usersessiongenerateandstoretransitkey'>
<div class="clearfix small pointer toggle-sibling">
<div class="py1 contain">
<a class='icon pin-right py1 dark-link caret-right'></a>
<span class='code strong strong truncate'>generateAndStoreTransitKey()</span>
</div>
</div>
<div class="clearfix display-none toggle-target">
<section class='p2 mb2 clearfix bg-white minishadow'>
<p>Generates a ECDSA keypair to
use as the ephemeral app transit private key
and store in the session</p>
<div class='pre p1 fill-light mt0'>generateAndStoreTransitKey(): <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">String</a></div>
<div class='py1 quiet mt1 prose-big'>Returns</div>
<code><a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">String</a></code>:
the hex encoded private key
</section>
</div>
</div>
<div class='border-bottom' id='usersessiongetauthresponsetoken'>
<div class="clearfix small pointer toggle-sibling">
<div class="py1 contain">
<a class='icon pin-right py1 dark-link caret-right'></a>
<span class='code strong strong truncate'>getAuthResponseToken()</span>
</div>
</div>
<div class="clearfix display-none toggle-target">
<section class='p2 mb2 clearfix bg-white minishadow'>
<p>Retrieve the authentication token from the URL query</p>
<div class='pre p1 fill-light mt0'>getAuthResponseToken(): <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">String</a></div>
<div class='py1 quiet mt1 prose-big'>Returns</div>
<code><a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">String</a></code>:
the authentication token if it exists otherwise
<code>null</code>
</section>
</div>
</div>
<div class='border-bottom' id='usersessionissigninpending'>
<div class="clearfix small pointer toggle-sibling">
<div class="py1 contain">
<a class='icon pin-right py1 dark-link caret-right'></a>
<span class='code strong strong truncate'>isSignInPending()</span>
</div>
</div>
<div class="clearfix display-none toggle-target">
<section class='p2 mb2 clearfix bg-white minishadow'>
<p>Check if there is a authentication request that hasn't been handled.</p>
<div class='pre p1 fill-light mt0'>isSignInPending(): <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean">Boolean</a></div>
<div class='py1 quiet mt1 prose-big'>Returns</div>
<code><a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean">Boolean</a></code>:
<code>true</code>
if there is a pending sign in, otherwise
<code>false</code>
</section>
</div>
</div>
<div class='border-bottom' id='usersessionisusersignedin'>
<div class="clearfix small pointer toggle-sibling">
<div class="py1 contain">
<a class='icon pin-right py1 dark-link caret-right'></a>
<span class='code strong strong truncate'>isUserSignedIn()</span>
</div>
</div>
<div class="clearfix display-none toggle-target">
<section class='p2 mb2 clearfix bg-white minishadow'>
<p>Check if a user is currently signed in.</p>
<div class='pre p1 fill-light mt0'>isUserSignedIn(): <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean">Boolean</a></div>
<div class='py1 quiet mt1 prose-big'>Returns</div>
<code><a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean">Boolean</a></code>:
<code>true</code>
if the user is signed in,
<code>false</code>
if not.
</section>
</div>
</div>
<div class='border-bottom' id='usersessionhandlependingsignin'>
<div class="clearfix small pointer toggle-sibling">
<div class="py1 contain">
<a class='icon pin-right py1 dark-link caret-right'></a>
<span class='code strong strong truncate'>handlePendingSignIn(authResponseToken)</span>
</div>
</div>
<div class="clearfix display-none toggle-target">
<section class='p2 mb2 clearfix bg-white minishadow'>
<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 class='pre p1 fill-light mt0'>handlePendingSignIn(authResponseToken: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">String</a>): <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a></div>
<div class='py1 quiet mt1 prose-big'>Parameters</div>
<div class='prose'>
<div class='space-bottom0'>
<div>
<span class='code bold'>authResponseToken</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">String</a>
= <code>this.getAuthResponseToken()</code>)</code>
the signed authentication response token
</div>
</div>
</div>
<div class='py1 quiet mt1 prose-big'>Returns</div>
<code><a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a></code>:
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.
</section>
</div>
</div>
<div class='border-bottom' id='usersessionloaduserdata'>
<div class="clearfix small pointer toggle-sibling">
<div class="py1 contain">
<a class='icon pin-right py1 dark-link caret-right'></a>
<span class='code strong strong truncate'>loadUserData()</span>
</div>
</div>
<div class="clearfix display-none toggle-target">
<section class='p2 mb2 clearfix bg-white minishadow'>
<p>Retrieves the user data object. The user's profile is stored in the key <code>profile</code>.</p>
<div class='pre p1 fill-light mt0'>loadUserData(): <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">Object</a></div>
<div class='py1 quiet mt1 prose-big'>Returns</div>
<code><a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">Object</a></code>:
User data object.
</section>
</div>
</div>
<div class='border-bottom' id='usersessionsignuserout'>
<div class="clearfix small pointer toggle-sibling">
<div class="py1 contain">
<a class='icon pin-right py1 dark-link caret-right'></a>
<span class='code strong strong truncate'>signUserOut()</span>
</div>
</div>
<div class="clearfix display-none toggle-target">
<section class='p2 mb2 clearfix bg-white minishadow'>
<p>Sign the user out</p>
<div class='pre p1 fill-light mt0'>signUserOut(): void</div>
<div class='py1 quiet mt1 prose-big'>Returns</div>
<code>void</code>:
</section>
</div>
</div>
<div class='border-bottom' id='usersessionencryptcontent'>
<div class="clearfix small pointer toggle-sibling">
<div class="py1 contain">
<a class='icon pin-right py1 dark-link caret-right'></a>
<span class='code strong strong truncate'>encryptContent(content, options)</span>
</div>
</div>
<div class="clearfix display-none toggle-target">
<section class='p2 mb2 clearfix bg-white minishadow'>
<p>Encrypts the data provided with the app public key.</p>
<div class='pre p1 fill-light mt0'>encryptContent(content: (<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">String</a> | <a href="https://nodejs.org/api/buffer.html">Buffer</a>), options: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">Object</a>): <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">String</a></div>
<div class='py1 quiet mt1 prose-big'>Parameters</div>
<div class='prose'>
<div class='space-bottom0'>
<div>
<span class='code bold'>content</span> <code class='quiet'>((<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">String</a> | <a href="https://nodejs.org/api/buffer.html">Buffer</a>))</code>
data to encrypt
</div>
</div>
<div class='space-bottom0'>
<div>
<span class='code bold'>options</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">Object</a>
= <code>null</code>)</code>
options object
</div>
<table class='mt1 mb2 fixed-table h5 col-12'>
<colgroup>
<col width='30%' />
<col width='70%' />
</colgroup>
<thead>
<tr class='bold fill-light'>
<th>Name</th>
<th>Description</th>
</tr>
</thead>
<tbody class='mt1'>
<tr>
<td class='break-word'><span class='code bold'>options.publicKey</span> <code class='quiet'><a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">String</a></code>
</td>
<td class='break-word'><span>the hex string of the ECDSA public
key to use for encryption. If not provided, will use user's appPrivateKey.
</span></td>
</tr>
</tbody>
</table>
</div>
</div>
<div class='py1 quiet mt1 prose-big'>Returns</div>
<code><a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">String</a></code>:
Stringified ciphertext object
</section>
</div>
</div>
<div class='border-bottom' id='usersessiondecryptcontent'>
<div class="clearfix small pointer toggle-sibling">
<div class="py1 contain">
<a class='icon pin-right py1 dark-link caret-right'></a>
<span class='code strong strong truncate'>decryptContent(content, options)</span>
</div>
</div>
<div class="clearfix display-none toggle-target">
<section class='p2 mb2 clearfix bg-white minishadow'>
<p>Decrypts data encrypted with <code>encryptContent</code> with the
transit private key.</p>
<div class='pre p1 fill-light mt0'>decryptContent(content: (<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">String</a> | <a href="https://nodejs.org/api/buffer.html">Buffer</a>), options: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">Object</a>): (<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">String</a> | <a href="https://nodejs.org/api/buffer.html">Buffer</a>)</div>
<div class='py1 quiet mt1 prose-big'>Parameters</div>
<div class='prose'>
<div class='space-bottom0'>
<div>
<span class='code bold'>content</span> <code class='quiet'>((<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">String</a> | <a href="https://nodejs.org/api/buffer.html">Buffer</a>))</code>
encrypted content.
</div>
</div>
<div class='space-bottom0'>
<div>
<span class='code bold'>options</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">Object</a>
= <code>null</code>)</code>
options object
</div>
<table class='mt1 mb2 fixed-table h5 col-12'>
<colgroup>
<col width='30%' />
<col width='70%' />
</colgroup>
<thead>
<tr class='bold fill-light'>
<th>Name</th>
<th>Description</th>
</tr>
</thead>
<tbody class='mt1'>
<tr>
<td class='break-word'><span class='code bold'>options.privateKey</span> <code class='quiet'><a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">String</a></code>
</td>
<td class='break-word'><span>the hex string of the ECDSA private
key to use for decryption. If not provided, will use user's appPrivateKey.
</span></td>
</tr>
</tbody>
</table>
</div>
</div>
<div class='py1 quiet mt1 prose-big'>Returns</div>
<code>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">String</a> | <a href="https://nodejs.org/api/buffer.html">Buffer</a>)</code>:
decrypted content.
</section>
</div>
</div>
<div class='border-bottom' id='usersessionputfile'>
<div class="clearfix small pointer toggle-sibling">
<div class="py1 contain">
<a class='icon pin-right py1 dark-link caret-right'></a>
<span class='code strong strong truncate'>putFile(path, content, options)</span>
</div>
</div>
<div class="clearfix display-none toggle-target">
<section class='p2 mb2 clearfix bg-white minishadow'>
<p>Stores the data provided in the app's data store to to the file specified.</p>
<div class='pre p1 fill-light mt0'>putFile(path: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">String</a>, content: (<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">String</a> | <a href="https://nodejs.org/api/buffer.html">Buffer</a>), options: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">Object</a>): <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a></div>
<div class='py1 quiet mt1 prose-big'>Parameters</div>
<div class='prose'>
<div class='space-bottom0'>
<div>
<span class='code bold'>path</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">String</a>)</code>
the path to store the data in
</div>
</div>
<div class='space-bottom0'>
<div>
<span class='code bold'>content</span> <code class='quiet'>((<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">String</a> | <a href="https://nodejs.org/api/buffer.html">Buffer</a>))</code>
the data to store in the file
</div>
</div>
<div class='space-bottom0'>
<div>
<span class='code bold'>options</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">Object</a>
= <code>null</code>)</code>
options object
</div>
<table class='mt1 mb2 fixed-table h5 col-12'>
<colgroup>
<col width='30%' />
<col width='70%' />
</colgroup>
<thead>
<tr class='bold fill-light'>
<th>Name</th>
<th>Description</th>
</tr>
</thead>
<tbody class='mt1'>
<tr>
<td class='break-word'><span class='code bold'>options.encrypt</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean">Boolean</a> | <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">String</a>)</code>
(default <code>true</code>)
</td>
<td class='break-word'><span>encrypt the data with the app private key
or the provided public key
</span></td>
</tr>
<tr>
<td class='break-word'><span class='code bold'>options.sign</span> <code class='quiet'><a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean">Boolean</a></code>
(default <code>false</code>)
</td>
<td class='break-word'><span>sign the data using ECDSA on SHA256 hashes with
the app private key
</span></td>
</tr>
</tbody>
</table>
</div>
</div>
<div class='py1 quiet mt1 prose-big'>Returns</div>
<code><a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a></code>:
that resolves if the operation succeed and rejects
if it failed
</section>
</div>
</div>
<div class='border-bottom' id='usersessiongetfile'>
<div class="clearfix small pointer toggle-sibling">
<div class="py1 contain">
<a class='icon pin-right py1 dark-link caret-right'></a>
<span class='code strong strong truncate'>getFile(path, options)</span>
</div>
</div>
<div class="clearfix display-none toggle-target">
<section class='p2 mb2 clearfix bg-white minishadow'>
<p>Retrieves the specified file from the app's data store.</p>
<div class='pre p1 fill-light mt0'>getFile(path: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">String</a>, options: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">Object</a>): <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a></div>
<div class='py1 quiet mt1 prose-big'>Parameters</div>
<div class='prose'>
<div class='space-bottom0'>
<div>
<span class='code bold'>path</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">String</a>)</code>
the path to the file to read
</div>
</div>
<div class='space-bottom0'>
<div>
<span class='code bold'>options</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">Object</a>
= <code>null</code>)</code>
options object
</div>
<table class='mt1 mb2 fixed-table h5 col-12'>
<colgroup>
<col width='30%' />
<col width='70%' />
</colgroup>
<thead>
<tr class='bold fill-light'>
<th>Name</th>
<th>Description</th>
</tr>
</thead>
<tbody class='mt1'>
<tr>
<td class='break-word'><span class='code bold'>options.decrypt</span> <code class='quiet'><a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean">Boolean</a></code>
(default <code>true</code>)
</td>
<td class='break-word'><span>try to decrypt the data with the app private key
</span></td>
</tr>
<tr>
<td class='break-word'><span class='code bold'>options.username</span> <code class='quiet'><a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">String</a></code>
</td>
<td class='break-word'><span>the Blockstack ID to lookup for multi-player storage
</span></td>
</tr>
<tr>
<td class='break-word'><span class='code bold'>options.verify</span> <code class='quiet'><a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean">Boolean</a></code>
</td>
<td class='break-word'><span>Whether the content should be verified, only to be used
when
<code>putFile</code>
was set to
<code>sign = true</code>
</span></td>
</tr>
<tr>
<td class='break-word'><span class='code bold'>options.app</span> <code class='quiet'><a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">String</a></code>
</td>
<td class='break-word'><span>the app to lookup for multi-player storage -
defaults to current origin
</span></td>
</tr>
<tr>
<td class='break-word'><span class='code bold'>options.zoneFileLookupURL</span> <code class='quiet'><a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">String</a></code>
(default <code>null</code>)
</td>
<td class='break-word'><span>The URL
to use for zonefile lookup. If falsey, this will use the
blockstack.js's getNameInfo function instead.
</span></td>
</tr>
</tbody>
</table>
</div>
</div>
<div class='py1 quiet mt1 prose-big'>Returns</div>
<code><a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a></code>:
that resolves to the raw data in the file
or rejects with an error
</section>
</div>
</div>
<div class='border-bottom' id='usersessionlistfiles'>
<div class="clearfix small pointer toggle-sibling">
<div class="py1 contain">
<a class='icon pin-right py1 dark-link caret-right'></a>
<span class='code strong strong truncate'>listFiles(callback)</span>
</div>
</div>
<div class="clearfix display-none toggle-target">
<section class='p2 mb2 clearfix bg-white minishadow'>
<p>List the set of files in this application's Gaia storage bucket.</p>
<div class='pre p1 fill-light mt0'>listFiles(callback: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function">function</a>): <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a></div>
<div class='py1 quiet mt1 prose-big'>Parameters</div>
<div class='prose'>
<div class='space-bottom0'>
<div>
<span class='code bold'>callback</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function">function</a>)</code>
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
</div>
</div>
</div>
<div class='py1 quiet mt1 prose-big'>Returns</div>
<code><a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a></code>:
that resolves to the number of files listed
</section>
</div>
</div>
</div>
</section>
<div class='keyline-top-not py2'><section class='py2 clearfix'>
<h2 id='profiles' class='mt0'>
Profiles
</h2>
<p>Identity you own and control.</p>
<p><a href="https://github.com/blockstack/blockstack.js/blob/master/src/profiles/README.md">Read more about profiles</a></p>
</section>
</div>
<section class='p2 mb2 clearfix bg-white minishadow'>
<div class='clearfix'>
<h3 class='fl m0' id='extractprofile'>
extractProfile
</h3>
</div>
<p>Extracts a profile from an encoded token and optionally verifies it,
if <code>publicKeyOrAddress</code> is provided.</p>
<div class='pre p1 fill-light mt0'>extractProfile(token: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">String</a>, publicKeyOrAddress: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">String</a>): <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">Object</a></div>
<div class='py1 quiet mt1 prose-big'>Parameters</div>
<div class='prose'>
<div class='space-bottom0'>
<div>
<span class='code bold'>token</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">String</a>)</code>
the token to be extracted
</div>
</div>
<div class='space-bottom0'>
<div>
<span class='code bold'>publicKeyOrAddress</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">String</a>
= <code>null</code>)</code>
the public key or address of the
keypair that is thought to have signed the token
</div>
</div>
</div>
<div class='py1 quiet mt1 prose-big'>Returns</div>
<code><a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">Object</a></code>:
the profile extracted from the encoded token
<div class='py1 quiet mt1 prose-big'>Throws</div>
<ul>
<li><a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error">Error</a>: if the token isn't signed by the provided
<code>publicKeyOrAddress</code>
</li>
</ul>
</section>
<section class='p2 mb2 clearfix bg-white minishadow'>
<div class='clearfix'>
<h3 class='fl m0' id='wrapprofiletoken'>
wrapProfileToken
</h3>
</div>
<p>Wraps a token for a profile token file</p>
<div class='pre p1 fill-light mt0'>wrapProfileToken(token: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">String</a>): <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">Object</a></div>
<div class='py1 quiet mt1 prose-big'>Parameters</div>
<div class='prose'>
<div class='space-bottom0'>
<div>
<span class='code bold'>token</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">String</a>)</code>
the token to be wrapped
</div>
</div>
</div>
<div class='py1 quiet mt1 prose-big'>Returns</div>
<code><a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">Object</a></code>:
including
<code>token</code>
and
<code>decodedToken</code>
</section>
<section class='p2 mb2 clearfix bg-white minishadow'>
<div class='clearfix'>
<h3 class='fl m0' id='signprofiletoken'>
signProfileToken
</h3>
</div>
<p>Signs a profile token</p>
<div class='pre p1 fill-light mt0'>signProfileToken(profile: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">Object</a>, privateKey: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">String</a>, subject: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">Object</a>, issuer: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">Object</a>, signingAlgorithm: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">String</a>, issuedAt: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date">Date</a>, expiresAt: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date">Date</a>): <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">Object</a></div>
<div class='py1 quiet mt1 prose-big'>Parameters</div>
<div class='prose'>
<div class='space-bottom0'>
<div>
<span class='code bold'>profile</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">Object</a>)</code>
the JSON of the profile to be signed
</div>
</div>
<div class='space-bottom0'>
<div>
<span class='code bold'>privateKey</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">String</a>)</code>
the signing private key
</div>
</div>
<div class='space-bottom0'>
<div>
<span class='code bold'>subject</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">Object</a>
= <code>null</code>)</code>
the entity that the information is about
</div>
</div>
<div class='space-bottom0'>
<div>
<span class='code bold'>issuer</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">Object</a>
= <code>null</code>)</code>
the entity that is issuing the token
</div>
</div>
<div class='space-bottom0'>
<div>
<span class='code bold'>signingAlgorithm</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">String</a>
= <code>&#39;ES256K&#39;</code>)</code>
the signing algorithm to use
</div>
</div>
<div class='space-bottom0'>
<div>
<span class='code bold'>issuedAt</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date">Date</a>
= <code>new Date()</code>)</code>
the time of issuance of the token
</div>
</div>
<div class='space-bottom0'>
<div>
<span class='code bold'>expiresAt</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date">Date</a>
= <code>nextYear()</code>)</code>
the time of expiration of the token
</div>
</div>
</div>
<div class='py1 quiet mt1 prose-big'>Returns</div>
<code><a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">Object</a></code>:
the signed profile token
</section>
<section class='p2 mb2 clearfix bg-white minishadow'>
<div class='clearfix'>
<h3 class='fl m0' id='verifyprofiletoken'>
verifyProfileToken
</h3>
</div>
<p>Verifies a profile token</p>
<div class='pre p1 fill-light mt0'>verifyProfileToken(token: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">String</a>, publicKeyOrAddress: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">String</a>): <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">Object</a></div>
<div class='py1 quiet mt1 prose-big'>Parameters</div>
<div class='prose'>
<div class='space-bottom0'>
<div>
<span class='code bold'>token</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">String</a>)</code>
the token to be verified
</div>
</div>
<div class='space-bottom0'>
<div>
<span class='code bold'>publicKeyOrAddress</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">String</a>)</code>
the public key or address of the
keypair that is thought to have signed the token
</div>
</div>
</div>
<div class='py1 quiet mt1 prose-big'>Returns</div>
<code><a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">Object</a></code>:
the verified, decoded profile token
<div class='py1 quiet mt1 prose-big'>Throws</div>
<ul>
<li><a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error">Error</a>: throws an error if token verification fails
</li>
</ul>
</section>
<section class='p2 mb2 clearfix bg-white minishadow'>
<div class='clearfix'>
<h3 class='fl m0' id='validateproofs'>
validateProofs
</h3>
</div>
<p>Validates the social proofs in a user's profile. Currently supports validation of
Facebook, Twitter, GitHub, Instagram, LinkedIn and HackerNews accounts.</p>
<div class='pre p1 fill-light mt0'>validateProofs(profile: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">Object</a>, ownerAddress: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>, name: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>): <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a></div>
<div class='py1 quiet mt1 prose-big'>Parameters</div>
<div class='prose'>
<div class='space-bottom0'>
<div>
<span class='code bold'>profile</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">Object</a>)</code>
The JSON of the profile to be validated
</div>
</div>
<div class='space-bottom0'>
<div>
<span class='code bold'>ownerAddress</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>)</code>
The owner bitcoin address to be validated
</div>
</div>
<div class='space-bottom0'>
<div>
<span class='code bold'>name</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>
= <code>null</code>)</code>
The Blockstack name to be validated
</div>
</div>
</div>
<div class='py1 quiet mt1 prose-big'>Returns</div>
<code><a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a></code>:
that resolves to an array of validated proof objects
</section>
<section class='p2 mb2 clearfix bg-white minishadow'>
<div class='clearfix'>
<h3 class='fl m0' id='lookupprofile'>
lookupProfile
</h3>
</div>
<p>Look up a user profile by blockstack ID</p>
<div class='pre p1 fill-light mt0'>lookupProfile(username: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>, zoneFileLookupURL: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>): <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a></div>
<div class='py1 quiet mt1 prose-big'>Parameters</div>
<div class='prose'>
<div class='space-bottom0'>
<div>
<span class='code bold'>username</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>)</code>
The Blockstack ID of the profile to look up
</div>
</div>
<div class='space-bottom0'>
<div>
<span class='code bold'>zoneFileLookupURL</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>
= <code>null</code>)</code>
The URL
to use for zonefile lookup. If falsey, lookupProfile will use the
blockstack.js getNameInfo function.
</div>
</div>
</div>
<div class='py1 quiet mt1 prose-big'>Returns</div>
<code><a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a></code>:
that resolves to a profile object
</section>
<div class='keyline-top-not py2'><section class='py2 clearfix'>
<h2 id='storage' class='mt0'>
Storage
</h2>
<p>Store your app's data without servers in storage your user controls.</p>
<p><em>Note: Blockstack Gaia Storage APIs and on-disk format will change in
upcoming pre-releases breaking backward compatibility. File encryption is currently
opt-in on a file by file basis.</em></p>
<p><em>Certain storage features such as and collections are not implemented in the current
version. These features will be rolled out in future updates.</em></p>
<p><a href="https://github.com/blockstack/blockstack.js/blob/master/src/storage/README.md">Read more about storage</a></p>
</section>
</div>
<section class='p2 mb2 clearfix bg-white minishadow'>
<div class='clearfix'>
<h3 class='fl m0' id='getappbucketurl'>
getAppBucketUrl
</h3>
</div>
<p>Get the app storage bucket URL</p>
<div class='pre p1 fill-light mt0'>getAppBucketUrl(gaiaHubUrl: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">String</a>, appPrivateKey: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">String</a>): <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a></div>
<div class='py1 quiet mt1 prose-big'>Parameters</div>
<div class='prose'>
<div class='space-bottom0'>
<div>
<span class='code bold'>gaiaHubUrl</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">String</a>)</code>
the gaia hub URL
</div>
</div>
<div class='space-bottom0'>
<div>
<span class='code bold'>appPrivateKey</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">String</a>)</code>
the app private key used to generate the app address
</div>
</div>
</div>
<div class='py1 quiet mt1 prose-big'>Returns</div>
<code><a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a></code>:
That resolves to the URL of the app index file
or rejects if it fails
</section>
<section class='p2 mb2 clearfix bg-white minishadow'>
<div class='clearfix'>
<h3 class='fl m0' id='getuserappfileurl'>
getUserAppFileUrl
</h3>
</div>
<p>Fetch the public read URL of a user file for the specified app.</p>
<div class='pre p1 fill-light mt0'>getUserAppFileUrl(path: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">String</a>, username: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">String</a>, appOrigin: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">String</a>, zoneFileLookupURL: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">String</a>): <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a></div>
<div class='py1 quiet mt1 prose-big'>Parameters</div>
<div class='prose'>
<div class='space-bottom0'>
<div>
<span class='code bold'>path</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">String</a>)</code>
the path to the file to read
</div>
</div>
<div class='space-bottom0'>
<div>
<span class='code bold'>username</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">String</a>)</code>
The Blockstack ID of the user to look up
</div>
</div>
<div class='space-bottom0'>
<div>
<span class='code bold'>appOrigin</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">String</a>)</code>
The app origin
</div>
</div>
<div class='space-bottom0'>
<div>
<span class='code bold'>zoneFileLookupURL</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">String</a>
= <code>null</code>)</code>
The URL
to use for zonefile lookup. If falsey, this will use the
blockstack.js's getNameInfo function instead.
</div>
</div>
</div>
<div class='py1 quiet mt1 prose-big'>Returns</div>
<code><a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a></code>:
that resolves to the public read URL of the file
or rejects with an error
</section>
</div>
</div>
<script src='assets/anchor.js'></script>
<script src='assets/split.js'></script>
<script src='assets/site.js'></script>
</body>
</html>