@@ -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');
3034const jwt = require('jsonwebtoken');
3135
3236exports.getDefaultToken = getDefaultToken;
@@ -65,7 +69,10 @@ <h1 class="page-title">Source: JwtService.js</h1>
6569var 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+ */
6976function 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>
97104var 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 */
104111function 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 */
123130function 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 */
135142function 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 */
148156function 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