Skip to content

Commit ca6d833

Browse files
committed
docs: jsdoc improvement
1 parent 43db149 commit ca6d833

File tree

9 files changed

+385
-108
lines changed

9 files changed

+385
-108
lines changed

docs/DemoAuthService.js.html

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ <h1 class="page-title">Source: DemoAuthService.js</h1>
2727
<section>
2828
<article>
2929
<pre class="prettyprint source linenums"><code>/**
30-
* Various reusable functions, express middlewares, strategies for authentication flow
30+
* @file Various reusable functions, express middlewares, strategies for authentication flow
3131
*/
3232

3333
exports.isAuthenticated = isAuthenticated;
@@ -36,9 +36,9 @@ <h1 class="page-title">Source: DemoAuthService.js</h1>
3636

3737
/**
3838
* Express middleware for authentication using JWT paradigm
39-
* @param {} req : Express request object
40-
* @param {} res : Express response object
41-
* @param {} next : Express next callback
39+
* @param {} req - Express request object
40+
* @param {} res - Express response object
41+
* @param {} next - Express next callback
4242
*
4343
* @example
4444
* app.get('protectedEndpoint', [isAuthenticated], function(req, res){})
@@ -100,8 +100,7 @@ <h1 class="page-title">Source: DemoAuthService.js</h1>
100100
* let tokenExchange = new TokenExchange()
101101
* // Define your own strategy(a function) to read token, let's call it MyTokenReadStrategy
102102
* tokenExchange.setTokenReadStrategy(new MyTokenReadStrategy())
103-
* tokenExchange.read(req);
104-
* returns token
103+
* tokenExchange.read(req);//returns token
105104
* @property {Function} read(req) - Function that extracts token from request object
106105
* @property {Function} setTokenReadStrategy(strategyInstance) - Set strategy for reading token
107106
*
@@ -221,10 +220,10 @@ <h1 class="page-title">Source: DemoAuthService.js</h1>
221220
}
222221

223222
/**
224-
* Default strategy for TokenExchange
223+
* @summary Default strategy for TokenExchange
225224
* @description
226-
* Default strategy when authorization header is available in request : ReadFromHeaderWithBearerScheme
227-
* Default strategy when cookies have `access_token` : ReadFromCookie
225+
* Default strategy when authorization header is available in request = `ReadFromHeaderWithBearerScheme`.
226+
* Default strategy when cookies have `access_token` = `ReadFromCookie`.
228227
* @param {*} req
229228
* @param {*} tokenExchange
230229
* @see {@link TokenExchange}
@@ -247,13 +246,13 @@ <h1 class="page-title">Source: DemoAuthService.js</h1>
247246
</div>
248247

249248
<nav>
250-
<h2><a href="index.html">Home</a></h2><h3>Global</h3><ul><li><a href="global.html#createToken">createToken</a></li><li><a href="global.html#getDefaultToken">getDefaultToken</a></li><li><a href="global.html#isAuthenticated">isAuthenticated</a></li><li><a href="global.html#ReadFromBody">ReadFromBody</a></li><li><a href="global.html#ReadFromCookies">ReadFromCookies</a></li><li><a href="global.html#ReadFromHeader">ReadFromHeader</a></li><li><a href="global.html#ReadFromHeaderWithBearerScheme">ReadFromHeaderWithBearerScheme</a></li><li><a href="global.html#ReadFromUrlParam">ReadFromUrlParam</a></li><li><a href="global.html#setDefaultStrategy">setDefaultStrategy</a></li><li><a href="global.html#TokenExchange">TokenExchange</a></li><li><a href="global.html#updateSecretMethod">updateSecretMethod</a></li><li><a href="global.html#verifyToken">verifyToken</a></li></ul>
249+
<h2><a href="index.html">Home</a></h2><h3>Global</h3><ul><li><a href="global.html#createToken">createToken</a></li><li><a href="global.html#genKeys">genKeys</a></li><li><a href="global.html#getDefaultToken">getDefaultToken</a></li><li><a href="global.html#isAuthenticated">isAuthenticated</a></li><li><a href="global.html#ReadFromBody">ReadFromBody</a></li><li><a href="global.html#ReadFromCookies">ReadFromCookies</a></li><li><a href="global.html#ReadFromHeader">ReadFromHeader</a></li><li><a href="global.html#ReadFromHeaderWithBearerScheme">ReadFromHeaderWithBearerScheme</a></li><li><a href="global.html#ReadFromUrlParam">ReadFromUrlParam</a></li><li><a href="global.html#setDefaultStrategy">setDefaultStrategy</a></li><li><a href="global.html#TokenExchange">TokenExchange</a></li><li><a href="global.html#updateSecretMethod">updateSecretMethod</a></li><li><a href="global.html#verifyToken">verifyToken</a></li></ul>
251250
</nav>
252251

253252
<br class="clear">
254253

255254
<footer>
256-
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.10</a> on Sun May 22 2022 15:06:37 GMT+0530 (India Standard Time)
255+
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.10</a> on Mon May 23 2022 09:59:20 GMT+0530 (India Standard Time)
257256
</footer>
258257

259258
<script> prettyPrint(); </script>

docs/JwtService.js.html

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,11 @@ <h1 class="page-title">Source: JwtService.js</h1>
2626

2727
<section>
2828
<article>
29-
<pre class="prettyprint source linenums"><code>const fs = require('fs');
29+
<pre class="prettyprint source linenums"><code>/**
30+
* @file Provides easy to use functions for JWT related operations
31+
*/
32+
33+
const fs = require('fs');
3034
const jwt = require('jsonwebtoken');
3135

3236
exports.getDefaultToken = getDefaultToken;
@@ -65,7 +69,10 @@ <h1 class="page-title">Source: JwtService.js</h1>
6569
var cp = require('child_process'),
6670
assert = require('assert');
6771

68-
// Genrate public and private key pair programmetically
72+
/**
73+
* Genrate public and private key pair programmetically
74+
* @param {Function} cb - callback (info)
75+
*/
6976
function genKeys(cb) {
7077
// gen private
7178
cp.exec('openssl genrsa 2048', function(err, priv, stderr) {
@@ -97,9 +104,9 @@ <h1 class="page-title">Source: JwtService.js</h1>
97104
var secret = "secret"; //ToDo: Move credentials to env
98105

99106
/**
100-
* A temporary hack to remember set the choice of user's preferred algorithm and default secret/keys accordingly
101-
* @param {*} algorithm
102-
* @param {*} isSigningRequest
107+
* A temporary hack to set the choice of user's preferred algorithm and default secret/keys accordingly
108+
* @param {String} algorithm
109+
* @param {Boolean} isSigningRequest
103110
*/
104111
function updateSecretMethod(algorithm, isSigningRequest) {
105112
//TODO: Maintain different choices for different users instead of keeping one global choice for all.
@@ -118,7 +125,7 @@ <h1 class="page-title">Source: JwtService.js</h1>
118125

119126
/**
120127
* Creates a signed JWT token with default configs and payload
121-
* @param {*} cb (err, token)
128+
* @param {Function} cb (err, token)
122129
*/
123130
function getDefaultToken(cb){
124131
updateSecretMethod(signOptions.algorithm, true);
@@ -129,8 +136,8 @@ <h1 class="page-title">Source: JwtService.js</h1>
129136

130137
/**
131138
* Verifies a JWT token and returns decoded token
132-
* @param token the JWT token string which needs to be verified
133-
* @param {*} cb (err, decodedToken)
139+
* @param {String} token - The JWT token string which needs to be verified
140+
* @param {Function} cb (err, decodedToken)
134141
*/
135142
function verifyToken(token, cb){
136143
updateSecretMethod(signOptions.algorithm, false);
@@ -140,10 +147,11 @@ <h1 class="page-title">Source: JwtService.js</h1>
140147
})
141148
}
142149

150+
143151
/**
144152
* Creates a JWT token
145-
* @param {{algorithm:string, payload: Object}} options { algorithm : 'RS256', payload : {} }
146-
* @param {*} cb (err, token)
153+
* @param {Object} options {algorithm:string, payload: Object}
154+
* @param {Function} cb (err, token)
147155
*/
148156
function createToken(options, cb){
149157
if (options.algorithm) signOptions['algorithm'] = options.algorithm;
@@ -161,13 +169,13 @@ <h1 class="page-title">Source: JwtService.js</h1>
161169
</div>
162170

163171
<nav>
164-
<h2><a href="index.html">Home</a></h2><h3>Global</h3><ul><li><a href="global.html#createToken">createToken</a></li><li><a href="global.html#getDefaultToken">getDefaultToken</a></li><li><a href="global.html#isAuthenticated">isAuthenticated</a></li><li><a href="global.html#ReadFromBody">ReadFromBody</a></li><li><a href="global.html#ReadFromCookies">ReadFromCookies</a></li><li><a href="global.html#ReadFromHeader">ReadFromHeader</a></li><li><a href="global.html#ReadFromHeaderWithBearerScheme">ReadFromHeaderWithBearerScheme</a></li><li><a href="global.html#ReadFromUrlParam">ReadFromUrlParam</a></li><li><a href="global.html#setDefaultStrategy">setDefaultStrategy</a></li><li><a href="global.html#TokenExchange">TokenExchange</a></li><li><a href="global.html#updateSecretMethod">updateSecretMethod</a></li><li><a href="global.html#verifyToken">verifyToken</a></li></ul>
172+
<h2><a href="index.html">Home</a></h2><h3>Global</h3><ul><li><a href="global.html#createToken">createToken</a></li><li><a href="global.html#genKeys">genKeys</a></li><li><a href="global.html#getDefaultToken">getDefaultToken</a></li><li><a href="global.html#isAuthenticated">isAuthenticated</a></li><li><a href="global.html#ReadFromBody">ReadFromBody</a></li><li><a href="global.html#ReadFromCookies">ReadFromCookies</a></li><li><a href="global.html#ReadFromHeader">ReadFromHeader</a></li><li><a href="global.html#ReadFromHeaderWithBearerScheme">ReadFromHeaderWithBearerScheme</a></li><li><a href="global.html#ReadFromUrlParam">ReadFromUrlParam</a></li><li><a href="global.html#setDefaultStrategy">setDefaultStrategy</a></li><li><a href="global.html#TokenExchange">TokenExchange</a></li><li><a href="global.html#updateSecretMethod">updateSecretMethod</a></li><li><a href="global.html#verifyToken">verifyToken</a></li></ul>
165173
</nav>
166174

167175
<br class="clear">
168176

169177
<footer>
170-
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.10</a> on Sun May 22 2022 15:06:37 GMT+0530 (India Standard Time)
178+
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.10</a> on Mon May 23 2022 09:59:20 GMT+0530 (India Standard Time)
171179
</footer>
172180

173181
<script> prettyPrint(); </script>

0 commit comments

Comments
 (0)