Files
stacks.js/docs/modules/profile.html
2021-06-28 10:27:07 -07:00

444 lines
20 KiB
HTML
Vendored

<!doctype html>
<html class="default no-js">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>profile | Stacks.js 1.4.1 Library Reference</title>
<meta name="description" content="Documentation for Stacks.js 1.4.1 Library Reference">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="../assets/css/main.css">
<script async src="../assets/js/search.js" id="search-script"></script>
</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.json" 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">Stacks.js 1.4.1 Library Reference</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-externals" checked />
<label class="tsd-widget" for="tsd-filter-externals">Externals</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="../modules.html">Stacks.js 1.4.1 Library Reference</a>
</li>
<li>
<a href="profile.html">profile</a>
</li>
</ul>
<h1>Module profile</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">
<a href="#stacksprofile" id="stacksprofile" style="color: inherit; text-decoration: none;">
<h1>@stacks/profile</h1>
</a>
<p>Functions for manipulating user profiles.</p>
<a href="#installation" id="installation" style="color: inherit; text-decoration: none;">
<h2>Installation</h2>
</a>
<pre><code><span style="color: #001080">npm</span><span style="color: #000000"> </span><span style="color: #001080">install</span><span style="color: #000000"> @</span><span style="color: #001080">stacks</span><span style="color: #000000">/</span><span style="color: #001080">profile</span>
</code></pre>
</div>
</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>Classes</h3>
<ul class="tsd-index-list">
<li class="tsd-kind-class tsd-parent-kind-module"><a href="../classes/profile.profile-1.html" class="tsd-kind-icon">Profile</a></li>
</ul>
</section>
<section class="tsd-index-section ">
<h3>Functions</h3>
<ul class="tsd-index-list">
<li class="tsd-kind-function tsd-parent-kind-module"><a href="profile.html#extractprofile" class="tsd-kind-icon">extract<wbr>Profile</a></li>
<li class="tsd-kind-function tsd-parent-kind-module"><a href="profile.html#signprofiletoken" class="tsd-kind-icon">sign<wbr>Profile<wbr>Token</a></li>
<li class="tsd-kind-function tsd-parent-kind-module"><a href="profile.html#verifyprofiletoken" class="tsd-kind-icon">verify<wbr>Profile<wbr>Token</a></li>
<li class="tsd-kind-function tsd-parent-kind-module"><a href="profile.html#wrapprofiletoken" class="tsd-kind-icon">wrap<wbr>Profile<wbr>Token</a></li>
</ul>
</section>
</div>
</section>
</section>
<section class="tsd-panel-group tsd-member-group ">
<h2>Functions</h2>
<section class="tsd-panel tsd-member tsd-kind-function tsd-parent-kind-module">
<a name="extractprofile" class="tsd-anchor"></a>
<h3>extract<wbr>Profile</h3>
<ul class="tsd-signatures tsd-kind-function tsd-parent-kind-module">
<li class="tsd-signature tsd-kind-icon">extract<wbr>Profile<span class="tsd-signature-symbol">(</span>token<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span>, publicKeyOrAddress<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">string</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">null</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">Record</span><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">, </span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">&gt;</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/stacks.js/blob/master/packages/profile/src/profileTokens.ts#L138">packages/profile/src/profileTokens.ts:138</a></li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
<div class="lead">
<p>Extracts a profile from an encoded token and optionally verifies it,
if <code>publicKeyOrAddress</code> is provided.</p>
</div>
<dl class="tsd-comment-tags">
<dt>throws</dt>
<dd><p>{Error} - if the token isn&#39;t signed by the provided <code>publicKeyOrAddress</code></p>
</dd>
</dl>
</div>
<h4 class="tsd-parameters-title">Parameters</h4>
<ul class="tsd-parameters">
<li>
<h5>token: <span class="tsd-signature-type">string</span></h5>
<div class="tsd-comment tsd-typography">
<p>the token to be extracted</p>
</div>
</li>
<li>
<h5>publicKeyOrAddress: <span class="tsd-signature-type">string</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">null</span><span class="tsd-signature-symbol"> = null</span></h5>
<div class="tsd-comment tsd-typography">
<p>the public key or address of the
keypair that is thought to have signed the token</p>
</div>
</li>
</ul>
<h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">Record</span><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">, </span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">&gt;</span></h4>
<ul>
<li>the profile extracted from the encoded token</li>
</ul>
</li>
</ul>
</section>
<section class="tsd-panel tsd-member tsd-kind-function tsd-parent-kind-module">
<a name="signprofiletoken" class="tsd-anchor"></a>
<h3>sign<wbr>Profile<wbr>Token</h3>
<ul class="tsd-signatures tsd-kind-function tsd-parent-kind-module">
<li class="tsd-signature tsd-kind-icon">sign<wbr>Profile<wbr>Token<span class="tsd-signature-symbol">(</span>profile<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">any</span>, privateKey<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span>, subject<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">any</span>, issuer<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">any</span>, signingAlgorithm<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">string</span>, issuedAt<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">Date</span>, expiresAt<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">Date</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/stacks.js/blob/master/packages/profile/src/profileTokens.ts#L18">packages/profile/src/profileTokens.ts:18</a></li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
<div class="lead">
<p>Signs a profile token</p>
</div>
</div>
<h4 class="tsd-parameters-title">Parameters</h4>
<ul class="tsd-parameters">
<li>
<h5>profile: <span class="tsd-signature-type">any</span></h5>
<div class="tsd-comment tsd-typography">
<p>the JSON of the profile to be signed</p>
</div>
</li>
<li>
<h5>privateKey: <span class="tsd-signature-type">string</span></h5>
<div class="tsd-comment tsd-typography">
<p>the signing private key</p>
</div>
</li>
<li>
<h5><span class="tsd-flag ts-flagOptional">Optional</span> subject: <span class="tsd-signature-type">any</span></h5>
<div class="tsd-comment tsd-typography">
<p>the entity that the information is about</p>
</div>
</li>
<li>
<h5><span class="tsd-flag ts-flagOptional">Optional</span> issuer: <span class="tsd-signature-type">any</span></h5>
<div class="tsd-comment tsd-typography">
<p>the entity that is issuing the token</p>
</div>
</li>
<li>
<h5>signingAlgorithm: <span class="tsd-signature-type">string</span><span class="tsd-signature-symbol"> = &#x27;ES256K&#x27;</span></h5>
<div class="tsd-comment tsd-typography">
<p>the signing algorithm to use</p>
</div>
</li>
<li>
<h5>issuedAt: <span class="tsd-signature-type">Date</span><span class="tsd-signature-symbol"> = ...</span></h5>
<div class="tsd-comment tsd-typography">
<p>the time of issuance of the token</p>
</div>
</li>
<li>
<h5>expiresAt: <span class="tsd-signature-type">Date</span><span class="tsd-signature-symbol"> = ...</span></h5>
<div class="tsd-comment tsd-typography">
<p>the time of expiration of the token</p>
</div>
</li>
</ul>
<h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">string</span></h4>
<ul>
<li>the signed profile token</li>
</ul>
</li>
</ul>
</section>
<section class="tsd-panel tsd-member tsd-kind-function tsd-parent-kind-module">
<a name="verifyprofiletoken" class="tsd-anchor"></a>
<h3>verify<wbr>Profile<wbr>Token</h3>
<ul class="tsd-signatures tsd-kind-function tsd-parent-kind-module">
<li class="tsd-signature tsd-kind-icon">verify<wbr>Profile<wbr>Token<span class="tsd-signature-symbol">(</span>token<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span>, publicKeyOrAddress<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">TokenInterface</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/stacks.js/blob/master/packages/profile/src/profileTokens.ts#L75">packages/profile/src/profileTokens.ts:75</a></li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
<div class="lead">
<p>Verifies a profile token</p>
</div>
<dl class="tsd-comment-tags">
<dt>throws</dt>
<dd><p>{Error} - throws an error if token verification fails</p>
</dd>
</dl>
</div>
<h4 class="tsd-parameters-title">Parameters</h4>
<ul class="tsd-parameters">
<li>
<h5>token: <span class="tsd-signature-type">string</span></h5>
<div class="tsd-comment tsd-typography">
<p>the token to be verified</p>
</div>
</li>
<li>
<h5>publicKeyOrAddress: <span class="tsd-signature-type">string</span></h5>
<div class="tsd-comment tsd-typography">
<p>the public key or address of the
keypair that is thought to have signed the token</p>
</div>
</li>
</ul>
<h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">TokenInterface</span></h4>
<ul>
<li>the verified, decoded profile token</li>
</ul>
</li>
</ul>
</section>
<section class="tsd-panel tsd-member tsd-kind-function tsd-parent-kind-module">
<a name="wrapprofiletoken" class="tsd-anchor"></a>
<h3>wrap<wbr>Profile<wbr>Token</h3>
<ul class="tsd-signatures tsd-kind-function tsd-parent-kind-module">
<li class="tsd-signature tsd-kind-icon">wrap<wbr>Profile<wbr>Token<span class="tsd-signature-symbol">(</span>token<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>decodedToken<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">TokenInterface</span><span class="tsd-signature-symbol">; </span>token<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/stacks.js/blob/master/packages/profile/src/profileTokens.ts#L60">packages/profile/src/profileTokens.ts:60</a></li>
</ul>
</aside>
<div class="tsd-comment tsd-typography">
<div class="lead">
<p>Wraps a token for a profile token file</p>
</div>
</div>
<h4 class="tsd-parameters-title">Parameters</h4>
<ul class="tsd-parameters">
<li>
<h5>token: <span class="tsd-signature-type">string</span></h5>
<div class="tsd-comment tsd-typography">
<p>the token to be wrapped</p>
</div>
</li>
</ul>
<h4 class="tsd-returns-title">Returns <span class="tsd-signature-symbol">{ </span>decodedToken<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">TokenInterface</span><span class="tsd-signature-symbol">; </span>token<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span><span class="tsd-signature-symbol"> }</span></h4>
<ul>
<li>including <code>token</code> and <code>decodedToken</code></li>
</ul>
<ul class="tsd-parameters">
<li class="tsd-parameter">
<h5>decoded<wbr>Token<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">TokenInterface</span></h5>
</li>
<li class="tsd-parameter">
<h5>token<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span></h5>
</li>
</ul>
</li>
</ul>
</section>
</section>
</div>
<div class="col-4 col-menu menu-sticky-wrap menu-highlight">
<nav class="tsd-navigation primary">
<ul>
<li class=" ">
<a href="../modules.html">Modules</a>
</li>
<li class=" tsd-kind-module">
<a href="auth.html">auth</a>
</li>
<li class=" tsd-kind-module">
<a href="bns.html">bns</a>
</li>
<li class=" tsd-kind-module">
<a href="cli.html">cli</a>
</li>
<li class=" tsd-kind-module">
<a href="common.html">common</a>
</li>
<li class=" tsd-kind-module">
<a href="encryption.html">encryption</a>
</li>
<li class=" tsd-kind-module">
<a href="keychain.html">keychain</a>
</li>
<li class=" tsd-kind-module">
<a href="network.html">network</a>
</li>
<li class="current tsd-kind-module">
<a href="profile.html">profile</a>
</li>
<li class=" tsd-kind-module">
<a href="stacking.html">stacking</a>
</li>
<li class=" tsd-kind-module">
<a href="storage.html">storage</a>
</li>
<li class=" tsd-kind-module">
<a href="transactions.html">transactions</a>
</li>
</ul>
</nav>
<nav class="tsd-navigation secondary menu-sticky">
<ul class="before-current">
<li class=" tsd-kind-module">
<a href="auth.html" class="tsd-kind-icon">auth</a>
</li>
<li class=" tsd-kind-module">
<a href="bns.html" class="tsd-kind-icon">bns</a>
</li>
<li class=" tsd-kind-module">
<a href="cli.html" class="tsd-kind-icon">cli</a>
</li>
<li class=" tsd-kind-module">
<a href="common.html" class="tsd-kind-icon">common</a>
</li>
<li class=" tsd-kind-module">
<a href="encryption.html" class="tsd-kind-icon">encryption</a>
</li>
<li class=" tsd-kind-module">
<a href="keychain.html" class="tsd-kind-icon">keychain</a>
</li>
<li class=" tsd-kind-module">
<a href="network.html" class="tsd-kind-icon">network</a>
</li>
</ul>
<ul class="current">
<li class="current tsd-kind-module">
<a href="profile.html" class="tsd-kind-icon">profile</a>
<ul>
<li class=" tsd-kind-class tsd-parent-kind-module">
<a href="../classes/profile.profile-1.html" class="tsd-kind-icon">Profile</a>
</li>
<li class=" tsd-kind-function tsd-parent-kind-module">
<a href="profile.html#extractprofile" class="tsd-kind-icon">extract<wbr>Profile</a>
</li>
<li class=" tsd-kind-function tsd-parent-kind-module">
<a href="profile.html#signprofiletoken" class="tsd-kind-icon">sign<wbr>Profile<wbr>Token</a>
</li>
<li class=" tsd-kind-function tsd-parent-kind-module">
<a href="profile.html#verifyprofiletoken" class="tsd-kind-icon">verify<wbr>Profile<wbr>Token</a>
</li>
<li class=" tsd-kind-function tsd-parent-kind-module">
<a href="profile.html#wrapprofiletoken" class="tsd-kind-icon">wrap<wbr>Profile<wbr>Token</a>
</li>
</ul>
</li>
</ul>
<ul class="after-current">
<li class=" tsd-kind-module">
<a href="stacking.html" class="tsd-kind-icon">stacking</a>
</li>
<li class=" tsd-kind-module">
<a href="storage.html" class="tsd-kind-icon">storage</a>
</li>
<li class=" tsd-kind-module">
<a href="transactions.html" class="tsd-kind-icon">transactions</a>
</li>
</ul>
</nav>
</div>
</div>
</div>
<footer class="with-border-bottom">
<div class="container">
<h2>Legend</h2>
<div class="tsd-legend-group">
<ul class="tsd-legend">
<li class="tsd-kind-variable"><span class="tsd-kind-icon">Variable</span></li>
<li class="tsd-kind-function"><span class="tsd-kind-icon">Function</span></li>
<li class="tsd-kind-function tsd-has-type-parameter"><span class="tsd-kind-icon">Function with type parameter</span></li>
<li class="tsd-kind-type-alias"><span class="tsd-kind-icon">Type alias</span></li>
<li class="tsd-kind-type-alias tsd-has-type-parameter"><span class="tsd-kind-icon">Type alias with type parameter</span></li>
</ul>
<ul class="tsd-legend">
<li class="tsd-kind-interface"><span class="tsd-kind-icon">Interface</span></li>
<li class="tsd-kind-interface tsd-has-type-parameter"><span class="tsd-kind-icon">Interface with type parameter</span></li>
</ul>
<ul class="tsd-legend">
<li class="tsd-kind-enum"><span class="tsd-kind-icon">Enumeration</span></li>
</ul>
<ul class="tsd-legend">
<li class="tsd-kind-class"><span class="tsd-kind-icon">Class</span></li>
</ul>
</div>
</div>
</footer>
<div class="container tsd-generator">
<p>Generated using <a href="https://typedoc.org/" target="_blank">TypeDoc</a></p>
</div>
<div class="overlay"></div>
<script src="../assets/js/main.js"></script>
</body>
</html>