UNPKG

copious-transitions

Version:
2,202 lines (589 loc) 31.2 kB
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>JSDoc: Class: SessionManager</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: SessionManager</h1> <section> <header> <h2><span class="attribs"><span class="type-signature"></span></span> <span class="ancestors"><a href="base.html">base</a>.</span>SessionManager<span class="signature">()</span><span class="type-signature"></span></h2> </header> <article> <div class="container-overview"> <h4 class="name" id="SessionManager"><span class="type-signature"></span>new SessionManager<span class="signature">()</span><span class="type-signature"></span></h4> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="lib_general_auth.js.html">lib/general_auth.js</a>, <a href="lib_general_auth.js.html#line19">line 19</a> </li></ul></dd> </dl> </div> <h3 class="subsection-title">Extends</h3> <ul> <li>SessionManager_Lite</li> </ul> <h3 class="subsection-title">Methods</h3> <h4 class="name" id="app_set_user_cookie"><span class="type-signature"></span>app_set_user_cookie<span class="signature">(res, session_token)</span><span class="type-signature"></span></h4> <div class="description"> <p>Applications will want to override this method in order to work with cookies used by the authorization process.</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>res</code></td> <td class="type"> <span class="param-type">object</span> </td> <td class="description last"><p>this is the HTTP request response object</p></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"></td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="lib_general_auth.js.html">lib/general_auth.js</a>, <a href="lib_general_auth.js.html#line349">line 349</a> </li></ul></dd> </dl> <h4 class="name" id="app_user_release_cookie"><span class="type-signature"></span>app_user_release_cookie<span class="signature">(res)</span><span class="type-signature"></span></h4> <div class="description"> <p>Applications will want to override this method in order to work with cookies used by the authorization process.</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>res</code></td> <td class="type"> <span class="param-type">object</span> </td> <td class="description last"><p>this is the HTTP request response object</p></td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="lib_general_auth.js.html">lib/general_auth.js</a>, <a href="lib_general_auth.js.html#line358">line 358</a> </li></ul></dd> </dl> <h4 class="name" id="hash_pass"><span class="type-signature"></span>hash_pass<span class="signature">(password)</span><span class="type-signature"> &rarr; {string}</span></h4> <div class="description"> <p>By default, this method returns the parameter untouched. Applications may hash the password or may encrypt or decrypt in order to find a string for comparison.</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>password</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_general_auth.js.html">lib/general_auth.js</a>, <a href="lib_general_auth.js.html#line75">line 75</a> </li></ul></dd> </dl> <h5>Returns:</h5> <div class="param-desc"> <ul> <li>the hash of the password</li> </ul> </div> <dl> <dt> Type </dt> <dd> <span class="param-type">string</span> </dd> </dl> <h4 class="name" id="initialize_session_state"><span class="type-signature">(async) </span>initialize_session_state<span class="signature">(transition, session_token, transtionObj, res)</span><span class="type-signature"> &rarr; {object|undefined}</span></h4> <div class="description"> <p>This method will start a user's session, enabling calls to asset delivery and to processess state transitions. This method is called only after the session has been authorized and a session token has been created for it. Also, this method only handles transition objects that have a <code>user_op</code> set to <code>login</code>.</p> <p>Given the user object is still in the DB, the user <code>logged_in</code> field will be set to true. And, this state change will be stored in the DB for reference by this and other processes.</p> <p>Finally, the session for this user will be recorded in the session tables, and data created for the session will be released.</p> <p>Only available in the general_auth which should only be used in processes that are processing users. This is not in the auth_session_lite, which is used by processes checking user ownership and permissions, but those processes do not initiate user sessions or offer processing for new entries....</p> <p>if the user session state can be initialized, this returns the elements map required by the cached 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>transition</code></td> <td class="type"> <span class="param-type">string</span> </td> <td class="description last"></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"></td> </tr> <tr> <td class="name"><code>transtionObj</code></td> <td class="type"> <span class="param-type">object</span> </td> <td class="description last"></td> </tr> <tr> <td class="name"><code>res</code></td> <td class="type"> <span class="param-type">object</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_general_auth.js.html">lib/general_auth.js</a>, <a href="lib_general_auth.js.html#line385">line 385</a> </li></ul></dd> </dl> <h5>Returns:</h5> <dl> <dt> Type </dt> <dd> <span class="param-type">object</span> | <span class="param-type">undefined</span> </dd> </dl> <h4 class="name" id="loginTransitionFields"><span class="type-signature"></span>loginTransitionFields<span class="signature">(transtion_object, post_body, user)</span><span class="type-signature"></span></h4> <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>transtion_object</code></td> <td class="type"> <span class="param-type">object</span> </td> <td class="description last"></td> </tr> <tr> <td class="name"><code>post_body</code></td> <td class="type"> <span class="param-type">object</span> </td> <td class="description last"></td> </tr> <tr> <td class="name"><code>user</code></td> <td class="type"> <span class="param-type">object</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_general_auth.js.html">lib/general_auth.js</a>, <a href="lib_general_auth.js.html#line86">line 86</a> </li></ul></dd> </dl> <h4 class="name" id="login_transition"><span class="type-signature">(async) </span>login_transition<span class="signature">(user, transtion_object, post_body)</span><span class="type-signature"> &rarr; {boolean}</span></h4> <div class="description"> <p>This method first checks the DB user password against password data obtained from the client. Given the password check works, the transition object is flagged for a secondary action.</p> <p>The <code>loginTransitionFields</code> is called in order to create the session identifier and store it in local in-memory hash tables.</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"></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"></td> </tr> <tr> <td class="name"><code>post_body</code></td> <td class="type"> <span class="param-type">object</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_general_auth.js.html">lib/general_auth.js</a>, <a href="lib_general_auth.js.html#line114">line 114</a> </li></ul></dd> </dl> <h5>Returns:</h5> <div class="param-desc"> <ul> <li>true if failed indicating that a corretive action must be done - false indicating no required action</li> </ul> </div> <dl> <dt> Type </dt> <dd> <span class="param-type">boolean</span> </dd> </dl> <h4 class="name" id="ok_forgetfulness"><span class="type-signature"></span>ok_forgetfulness<span class="signature">(boolVal, transtion_object)</span><span class="type-signature"></span></h4> <div class="description"> <p>Set the <code>forgetfulness_proceed</code> for the applications that handle forgotten passwords.</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>boolVal</code></td> <td class="type"> <span class="param-type">boolean</span> </td> <td class="description last"></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"></td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="lib_general_auth.js.html">lib/general_auth.js</a>, <a href="lib_general_auth.js.html#line339">line 339</a> </li></ul></dd> </dl> <h4 class="name" id="password_check"><span class="type-signature">(async) </span>password_check<span class="signature">(db_password, client_password)</span><span class="type-signature"> &rarr; {boolean}</span></h4> <div class="description"> <p>By default this method just checks to see if two strings are equal. Applications will want to do something more sophisticated, e.g. checking a signature.</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>db_password</code></td> <td class="type"> <span class="param-type">string</span> </td> <td class="description last"></td> </tr> <tr> <td class="name"><code>client_password</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_general_auth.js.html">lib/general_auth.js</a>, <a href="lib_general_auth.js.html#line62">line 62</a> </li></ul></dd> </dl> <h5>Returns:</h5> <div class="param-desc"> <ul> <li>true if the comparison passes</li> </ul> </div> <dl> <dt> Type </dt> <dd> <span class="param-type">boolean</span> </dd> </dl> <h4 class="name" id="process_user"><span class="type-signature">(async) </span>process_user<span class="signature">(user_op, post_body, res, primary_key)</span><span class="type-signature"> &rarr; {object}</span></h4> <div class="description"> <p>This method is the target of user processing classes, that can be found in the contractual directory.</p> <p>The user processing classes help with the existence of users and the management of their sessions.</p> <p>There operations that this method handles are <code>login</code>, <code>logout</code> and <code>registration</code>.</p> <p>Handling <code>forgot</code>, for forgotten passwords is deprecated and may become be handled by transition processing at a later date.</p> <p>The <code>logout</code> operation leads to a call to <code>destroySession</code>.</p> <p>The operations <code>login</code> and <code>register</code> lead to calls to their <code>transition</code></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_op</code></td> <td class="type"> <span class="param-type">string</span> </td> <td class="description last"></td> </tr> <tr> <td class="name"><code>post_body</code></td> <td class="type"> <span class="param-type">object</span> </td> <td class="description last"></td> </tr> <tr> <td class="name"><code>res</code></td> <td class="type"> <span class="param-type">object</span> </td> <td class="description last"></td> </tr> <tr> <td class="name"><code>primary_key</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_general_auth.js.html">lib/general_auth.js</a>, <a href="lib_general_auth.js.html#line189">line 189</a> </li></ul></dd> </dl> <h5>Returns:</h5> <div class="param-desc"> <ul> <li>the transition object made for continuing the requested operation</li> </ul> </div> <dl> <dt> Type </dt> <dd> <span class="param-type">object</span> </dd> </dl> <h4 class="name" id="registration_transition"><span class="type-signature">(async) </span>registration_transition<span class="signature">(post_body, transtion_object)</span><span class="type-signature"> &rarr; {boolean}</span></h4> <div class="description"> <p>This method stores a user in the data base for the first time.</p> <p>In some applications this storing of the user is something perpetual. In other applications, the user is stored newly each time with permanent identity storage happening elsewhere.</p> <p>The registration can also create a session by calling <code>generate_session_token</code> This also creates an elements map with a <code>match</code> field for the session.</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"></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"></td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="lib_general_auth.js.html">lib/general_auth.js</a>, <a href="lib_general_auth.js.html#line146">line 146</a> </li></ul></dd> </dl> <h5>Returns:</h5> <div class="param-desc"> <p>The result is true if the user can be stored in the DB, false otherwise.</p> </div> <dl> <dt> Type </dt> <dd> <span class="param-type">boolean</span> </dd> </dl> <h4 class="name" id="update_user_password"><span class="type-signature">(async) </span>update_user_password<span class="signature">(post_body)</span><span class="type-signature"> &rarr; {object}</span></h4> <div class="description"> <p>This method responds to a client request by upd</p> <p><code>finalize_transition</code> in some applications use this method. The invokation of <code>finalize_transition</code> is typically during a secondary action and part of an active session. The token, from the stached transition object is expected in the client request data.</p> <p>The token will map, via DB query on the key-value DB to a value to be used in the query for the user object in the user table of the DB. If the keyed value and the user can be found, then the password introduced by the client request's post body will be hashed and stored if the user object has the field <code>updates</code> set to an object containing the desired password. The update password and the post body password must check.</p> <p>If the passwords check out, then the user password can be updated and stored in the DB for future transactions.</p> <p>The value this returns may be passed onto a business process, if the application is so condigured.</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"></td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="lib_general_auth.js.html">lib/general_auth.js</a>, <a href="lib_general_auth.js.html#line299">line 299</a> </li></ul></dd> </dl> <h5>Returns:</h5> <div class="param-desc"> <ul> <li>the value <code>keyed_val</code> retrieved form the DB and that is mapped to the <code>token</code>.</li> </ul> </div> <dl> <dt> Type </dt> <dd> <span class="param-type">object</span> </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>