Skip to content

Commit 1d8bcf4

Browse files
committed
style: jsdoc param spacing
1 parent 50aa580 commit 1d8bcf4

File tree

2 files changed

+58
-49
lines changed

2 files changed

+58
-49
lines changed

lib/Auth/index.js

Lines changed: 45 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,28 @@ const CoreError = require('./../CoreError');
44
const Token = require('./token');
55

66
/**
7-
* Cayenne Core Auth Class
7+
* Auth provides the client credential token handling for the Cayenne Core services
88
*/
99
class Auth {
1010
/**
1111
* Constructs the Cayenne Core authenticator
1212
*
13-
* @param {String} clientId
14-
* @param {String} clientSecret
15-
* @param {String} [authorizationUrl]
16-
* @param {Object} options
17-
* @param {Function | Object | Boolean} [options.logger]
18-
* @param {Boolean} [options.isOffline=true]
13+
* @param {String} clientId Cayenne Core client id
14+
* @param {String} clientSecret Cayenne Core client secret
15+
* @param {String} [authorizationUrl] Authorization URL to authenticate against
16+
* @param {Object} [options={}] Additional options
17+
* @param {Function | Object | Boolean} [options.logger] Debug, info, and error logger to use
18+
* @param {Boolean} [options.isOffline=true] Provides a session that can be used indefinitely by refreshing
1919
*/
20-
constructor(clientId, clientSecret, authorizationUrl, options) {
20+
constructor(clientId, clientSecret, authorizationUrl, options = {}) {
2121
/**
2222
* Constants
2323
*/
24+
/** @private @contant */
2425
this.OFFLINE_SCOPE = 'offline_access';
26+
/** @private @contant */
2527
this.MAX_RETRIES = 1;
28+
/** @private @contant */
2629
this.DEFAULT_AUTHORIZATION_URL =
2730
'https://accounts.mydevices.com/auth/realms/cayenne-core/protocol/openid-connect/token';
2831

@@ -38,18 +41,19 @@ class Auth {
3841
this.logger = options.logger;
3942
this.isOffline = options.isOffline;
4043

44+
/** @type CoreError */
4145
this.invalidCredentials;
4246
this.access = new Token();
4347
}
4448

4549
/**
46-
* @function
47-
* @private
48-
*
4950
* Get authorization token
5051
*
52+
* @private
53+
*
5154
* @param {Number} [retry] Current retry count
52-
* @returns {Promise} Valid access token
55+
*
56+
* @returns {Promise<String>} Valid access token
5357
*/
5458
async getApplicationToken(retry = 0) {
5559
if (retry > this.MAX_RETRIES) {
@@ -115,20 +119,23 @@ class Auth {
115119
}
116120

117121
/**
118-
* @function
119-
* @public
120-
*
121122
* Send a request to Core service
122123
*
123-
* @param {String} service Core service being requested
124-
* @param {String} method ReST method to use
125-
* @param {String} url Endpoint
126-
* @param {Object} opts Additional options
127-
* @param {Object} [opts.headers={}] Headers to send
128-
* @param {Object} [opts.query] Query to send
129-
* @param {Object} [opts.payload] Payload to send
124+
* @public
125+
*
126+
* @param {String} service Core service being requested
127+
* @param {String} method ReST method to use
128+
* @param {String} url Full cayenne core path
129+
* @param {Object} opts Additional options
130+
* @param {Object} [opts.headers={}] Headers to send
131+
* @param {Object} [opts.query] Query to send
132+
* @param {Object} [opts.payload] Payload to send
130133
* @param {boolean} [opts.isPublic=false] If this request should include authorization
131-
* @param {Number} retry Allow retries in case of expired token
134+
* @param {Number} retry Allow retries in case of expired token
135+
*
136+
* @returns {Promise<{} | Array<{}>>}
137+
*
138+
* @throws {CoreError} Returns erroror max authenticated request limit reached
132139
*/
133140
async send(service, method, url, opts, retry = 0) {
134141
if (this.invalidCredentials) {
@@ -190,17 +197,18 @@ class Auth {
190197
}
191198

192199
/**
193-
* @function
200+
* Create the Core Error and log it
201+
*
194202
* @private
195203
*
196-
* Create the Core Error and log it
204+
* @param {typeof Error} error Error returned
205+
* @param {String} url Endpoint
206+
* @param {String} service Core service requested
207+
* @param {String} method REST method used
208+
* @param {Number} tDelta Request time in ms
209+
* @param {Object} query The query sent
197210
*
198-
* @param {typeof Error} error Error returned
199-
* @param {String} url Endpoint
200-
* @param {String} service Core service requested
201-
* @param {String} method REST method used
202-
* @param {Number} tDelta Request time in ms
203-
* @param {Object} query The query sent
211+
* @returns {CoreError}
204212
*/
205213
getError(error, url, service, method, tDelta, query) {
206214
const log = () => {
@@ -229,22 +237,23 @@ class Auth {
229237
}
230238

231239
/**
232-
* @function
233-
* @private
234-
*
235240
* Returns timedelta in ms
236241
*
242+
* @private
243+
*
237244
* @param {Number} begin ms
245+
*
246+
* @returns {Number}
238247
*/
239248
timeDelta(begin) {
240249
return new Date().getTime() - begin;
241250
}
242251

243252
/**
244-
* @function
253+
* Log the message if enabled and with applicable log level
254+
*
245255
* @public
246256
*
247-
* Log the message if enabled and with applicable log level
248257
* @param {String} message
249258
* @param {String} level
250259
*/

lib/index.js

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,19 @@ class Core {
1414
/**
1515
* Constructs a new Cayenne Core API class
1616
*
17-
* @param {String} clientId Client ID for application
18-
* @param {String} clientSecret Client Secret for application
19-
* @param {String} authorizationUrl Client Authorization URL
20-
* @param {Object} options Additional options
21-
* @param {String} options.cayenneBaseUrl Things URL
22-
* @param {String} options.deloreanBaseUrl History URL
23-
* @param {String} options.executorBaseUrl Jobs URL
24-
* @param {String} options.hermesBaseUrl Notifications URL
25-
* @param {String} options.prometheusBaseUrl Lora URL
26-
* @param {String} options.streamingBaseUrl Streaming URL
27-
* @param {String} options.timekeeperBaseUrl Jobs URL
28-
* @param {Function | Object | Boolean} [options.logger=false] Optional logger
29-
* @param {Boolean} [options.isOffline=true] Whether to request offline access
17+
* @param {String} clientId Client ID for application
18+
* @param {String} clientSecret Client Secret for application
19+
* @param {String} authorizationUrl Client Authorization URL
20+
* @param {Object} options Additional options
21+
* @param {String} options.cayenneBaseUrl Things URL
22+
* @param {String} options.deloreanBaseUrl History URL
23+
* @param {String} options.executorBaseUrl Jobs URL
24+
* @param {String} options.hermesBaseUrl Notifications URL
25+
* @param {String} options.prometheusBaseUrl Lora URL
26+
* @param {String} options.streamingBaseUrl Streaming URL
27+
* @param {String} options.timekeeperBaseUrl Jobs URL
28+
* @param {Function | Object | Boolean} [options.logger=false] Optional logger
29+
* @param {Boolean} [options.isOffline=true] Whether to request offline access
3030
*/
3131
constructor(clientId, clientSecret, authorizationUrl, options) {
3232
options = Object.assign({ logger: false, isOffline: true }, options);

0 commit comments

Comments
 (0)