copious-transitions
Version:
Framework for working with frameworks
1,431 lines (358 loc) • 21.6 kB
HTML
<html lang="en">
<head>
<meta charset="utf-8">
<title>JSDoc: Class: SessionTokenManager</title>
<script src="scripts/prettify/prettify.js"> </script>
<script src="scripts/prettify/lang-css.js"> </script>
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
<link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
</head>
<body>
<div id="main">
<h1 class="page-title">Class: SessionTokenManager</h1>
<section>
<header>
<h2><span class="attribs"><span class="type-signature"></span></span>SessionTokenManager<span class="signature">(conf, db_obj, tokenStorage)</span><span class="type-signature"></span></h2>
<div class="class-description"><p>The Session Token Manager deals JSON objects arriving from some session oriented client.
The JSON object is interned and stored as in the language's data object format.
Certain fields may be expected in the data object. Methods for some default case are provided, but
it is expected the application will override these methods and provide access for fields germain to the application.</p>
<p>Provides basic methods for generating session tokens, stashing and unstashing.</p>
<p>Manages a reference to a hashing method, called by <code>do_hash</code>.</p></div>
</header>
<article>
<div class="container-overview">
<h2>Constructor</h2>
<h4 class="name" id="SessionTokenManager"><span class="type-signature"></span>new SessionTokenManager<span class="signature">(conf, db_obj, tokenStorage)</span><span class="type-signature"></span></h4>
<div class="description">
<p>The configuration may bind the field <code>forhash</code> to a hashing function that will be used throughout the runtime.</p>
<p>The db_obj is a reference to a class instance that knows how to talk to a database.</p>
<p>The tokenStorage parameter is a required class reference that can generate a instance that manages tables of tokens.</p>
<p>Initializes a table <code>release_session_data</code> for keeping data between client repsonses, where data comes from user objects,
most likely obtained from the DB. In particular, the data will have a named field provided by <code>sess_data_accessor</code>. The data
lasts until the user session is initialized by an authorization process, one that uses the general authorization (as opposed to
light authorizatoin).</p>
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>conf</code></td>
<td class="type">
<span class="param-type">object</span>
</td>
<td class="description last"></td>
</tr>
<tr>
<td class="name"><code>db_obj</code></td>
<td class="type">
<span class="param-type">object</span>
</td>
<td class="description last"></td>
</tr>
<tr>
<td class="name"><code>tokenStorage</code></td>
<td class="type">
<span class="param-type">Class</span>
</td>
<td class="description last"></td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="lib_session_token_manager.js.html">lib/session_token_manager.js</a>, <a href="lib_session_token_manager.js.html#line84">line 84</a>
</li></ul></dd>
</dl>
</div>
<h3 class="subsection-title">Extends</h3>
<ul>
<li>TokenTables</li>
</ul>
<h3 class="subsection-title">Methods</h3>
<h4 class="name" id="addSession"><span class="type-signature">(async) </span>addSession<span class="signature">(key, session_token)</span><span class="type-signature"></span></h4>
<div class="description">
<p>Calls upon token storage to save the session and the relationship to its owner.</p>
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>key</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="description last"><ul>
<li>a key, mostly likely a ucwid that identifies an owner of the session</li>
</ul></td>
</tr>
<tr>
<td class="name"><code>session_token</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="description last"><ul>
<li>a session token (should be made by generate_session_token)</li>
</ul></td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="lib_session_token_manager.js.html">lib/session_token_manager.js</a>, <a href="lib_session_token_manager.js.html#line214">line 214</a>
</li></ul></dd>
</dl>
<h4 class="name" id="destroySession"><span class="type-signature"></span>destroySession<span class="signature">(token)</span><span class="type-signature"></span></h4>
<div class="description">
<p>Calls upon token storage to termiate a session and the tokens that expire with its termination.
The parameter passed is the session's transition token, which had been created for authorization transitions.
The parameter is used to obtain the session token.</p>
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>token</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="description last"><ul>
<li>the session's authorization transition token.</li>
</ul></td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="lib_session_token_manager.js.html">lib/session_token_manager.js</a>, <a href="lib_session_token_manager.js.html#line227">line 227</a>
</li></ul></dd>
</dl>
<h4 class="name" id="do_hash"><span class="type-signature"></span>do_hash<span class="signature">(str)</span><span class="type-signature"> → {string}</span></h4>
<div class="description">
<p>Synonimic method to expose the hash function field, a configurable parameter</p>
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>str</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="description last"></td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="lib_session_token_manager.js.html">lib/session_token_manager.js</a>, <a href="lib_session_token_manager.js.html#line146">line 146</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
<ul>
<li>the hash of the string</li>
</ul>
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">string</span>
</dd>
</dl>
<h4 class="name" id="generate_session_token"><span class="type-signature"></span>generate_session_token<span class="signature">(post_body)</span><span class="type-signature"></span></h4>
<div class="description">
<p>Makes a session token and returns it as a string</p>
<blockquote>
<p>Uses access to a default hash function set globally for the application</p>
</blockquote>
<p>This method concatentates two informational parts and one nonce to make a parameter to a hash function
in order to get a key that may be used as the session identifier.</p>
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>post_body</code></td>
<td class="type">
<span class="param-type">object</span>
</td>
<td class="description last"><ul>
<li>this is the JSON post body from the web application</li>
</ul></td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="lib_session_token_manager.js.html">lib/session_token_manager.js</a>, <a href="lib_session_token_manager.js.html#line160">line 160</a>
</li></ul></dd>
</dl>
<h4 class="name" id="sess_data_accessor"><span class="type-signature"></span>sess_data_accessor<span class="signature">()</span><span class="type-signature"></span></h4>
<div class="description">
<p>Return the field name of the user object that references data that should be accessed as part of the session</p>
</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="lib_session_token_manager.js.html">lib/session_token_manager.js</a>, <a href="lib_session_token_manager.js.html#line121">line 121</a>
</li></ul></dd>
</dl>
<h4 class="name" id="sessionCurrent"><span class="type-signature">(async) </span>sessionCurrent<span class="signature">(session_token, src_key<span class="signature-attributes">opt</span>)</span><span class="type-signature"></span></h4>
<div class="description">
<p>Checks to see if a session is current.
The source key may be supplied to check on the hash of owner related data.</p>
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Attributes</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>session_token</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="attributes">
</td>
<td class="description last"><ul>
<li>a session token (should be made by generate_session_token)</li>
</ul></td>
</tr>
<tr>
<td class="name"><code>src_key</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="description last"><ul>
<li>data returned from storing the transition token</li>
</ul></td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="lib_session_token_manager.js.html">lib/session_token_manager.js</a>, <a href="lib_session_token_manager.js.html#line238">line 238</a>
</li></ul></dd>
</dl>
<h4 class="name" id="stash_session_token"><span class="type-signature"></span>stash_session_token<span class="signature">(user, transtion_object)</span><span class="type-signature"></span></h4>
<div class="description">
<p>Stashes a session in the 'elements' map of the server-side transition object</p>
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>user</code></td>
<td class="type">
<span class="param-type">object</span>
</td>
<td class="description last"><ul>
<li>The user object is most likely extracted from the DB</li>
</ul></td>
</tr>
<tr>
<td class="name"><code>transtion_object</code></td>
<td class="type">
<span class="param-type">object</span>
</td>
<td class="description last"><ul>
<li>a nascent transition object that has both server side and client side aspects, but must contain the newly generated session token</li>
</ul></td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="lib_session_token_manager.js.html">lib/session_token_manager.js</a>, <a href="lib_session_token_manager.js.html#line181">line 181</a>
</li></ul></dd>
</dl>
<h4 class="name" id="unstash_session_token"><span class="type-signature"></span>unstash_session_token<span class="signature">()</span><span class="type-signature"></span></h4>
<div class="description">
<p>given the server side transition object for an authorization transition retrieve the sesssion token
from the transition object's elements fields</p>
</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="lib_session_token_manager.js.html">lib/session_token_manager.js</a>, <a href="lib_session_token_manager.js.html#line200">line 200</a>
</li></ul></dd>
</dl>
</article>
</section>
</div>
<nav>
<h2><a href="index.html">Home</a></h2><h3>Namespaces</h3><ul><li><a href="Contractual.html">Contractual</a></li><li><a href="CopiousTransitions.html">CopiousTransitions</a></li><li><a href="DefaultDB.html">DefaultDB</a></li><li><a href="base.html">base</a></li><li><a href="field_validators.html">field_validators</a></li></ul><h3>Classes</h3><ul><li><a href="Contractual.LocalTObjectCache.html">LocalTObjectCache</a></li><li><a href="Contractual.MimeHandling.html">MimeHandling</a></li><li><a href="Contractual.TransitionHandling.html">TransitionHandling</a></li><li><a href="Contractual.UserHandling.html">UserHandling</a></li><li><a href="CopiousTransitions.CopiousTransitions.html">CopiousTransitions</a></li><li><a href="DefaultDB.CustomizationMethodsByApplication.html">CustomizationMethodsByApplication</a></li><li><a href="DefaultDB.FauxInMemStore.html">FauxInMemStore</a></li><li><a href="DefaultDB.FileMapper.html">FileMapper</a></li><li><a href="DefaultDB.FilesAndRelays.html">FilesAndRelays</a></li><li><a href="DefaultDB.FilesAndRelays_base.html">FilesAndRelays_base</a></li><li><a href="DefaultDB.LocalStaticDB.html">LocalStaticDB</a></li><li><a href="DefaultDB.LocalStorageLifeCycle.html">LocalStorageLifeCycle</a></li><li><a href="DefaultDB.LocalStorageSerialization.html">LocalStorageSerialization</a></li><li><a href="DefaultDB.PageableMemStoreElement.html">PageableMemStoreElement</a></li><li><a href="DefaultDB.PersistenceContracts.html">PersistenceContracts</a></li><li><a href="DefaultDB.RemoteMessaging.html">RemoteMessaging</a></li><li><a href="DefaultDB.StaticDBDefault.html">StaticDBDefault</a></li><li><a href="GeneralUserDBWrapperImpl.html">GeneralUserDBWrapperImpl</a></li><li><a href="SessionTokenManager.html">SessionTokenManager</a></li><li><a href="base.DBClass.html">DBClass</a></li><li><a href="base.EndpointManager.html">EndpointManager</a></li><li><a href="base.GeneralAppLifeCycle.html">GeneralAppLifeCycle</a></li><li><a href="base.GeneralAuth.html">GeneralAuth</a></li><li><a href="base.GeneralBusiness.html">GeneralBusiness</a></li><li><a href="base.GeneralDynamic.html">GeneralDynamic</a></li><li><a href="base.GeneralMiddleWare.html">GeneralMiddleWare</a></li><li><a href="base.GeneralStatic.html">GeneralStatic</a></li><li><a href="base.GeneralTransitionEngImpl.html">GeneralTransitionEngImpl</a></li><li><a href="base.SessionManager.html">SessionManager</a></li><li><a href="base.SessionManager_Lite.html">SessionManager_Lite</a></li><li><a href="base.TaggedTransition.html">TaggedTransition</a></li><li><a href="base.TokenTables.html">TokenTables</a></li><li><a href="base.UserMessageEndpoint.html">UserMessageEndpoint</a></li><li><a href="base.WebSocketManager.html">WebSocketManager</a></li><li><a href="field_validators.DataLookupField.html">DataLookupField</a></li><li><a href="field_validators.EmailField.html">EmailField</a></li><li><a href="field_validators.EmailVerifyField.html">EmailVerifyField</a></li><li><a href="field_validators.FieldTest.html">FieldTest</a></li><li><a href="field_validators.FieldValidatorTools.html">FieldValidatorTools</a></li><li><a href="field_validators.ForeignAuth.html">ForeignAuth</a></li><li><a href="field_validators.GeneralValidator.html">GeneralValidator</a></li><li><a href="field_validators.LengthyAlphabetField.html">LengthyAlphabetField</a></li><li><a href="field_validators.LengthyDigitalField.html">LengthyDigitalField</a></li><li><a href="field_validators.LengthyField.html">LengthyField</a></li><li><a href="field_validators.LengthyStringField.html">LengthyStringField</a></li><li><a href="field_validators.PasswordField.html">PasswordField</a></li><li><a href="field_validators.PasswordVerifyField.html">PasswordVerifyField</a></li><li><a href="field_validators.TypeCheckField.html">TypeCheckField</a></li></ul><h3>Global</h3><ul><li><a href="global.html#generate_password_block">generate_password_block</a></li><li><a href="global.html#load_configuration">load_configuration</a></li><li><a href="global.html#load_parameters">load_parameters</a></li><li><a href="global.html#module_top">module_top</a></li></ul>
</nav>
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 4.0.2</a> on Tue Oct 31 2023 17:32:59 GMT-0700 (Pacific Daylight Time)
</footer>
<script> prettyPrint(); </script>
<script src="scripts/linenumber.js"> </script>
</body>
</html>