/**
* Do a little dance to cope with ESM dynamic import.
- * @param {...any} args
- * @returns {Promise<any>}
+ * @param {...any} args arguments
+ * @returns {Promise<any>} got response
*/
async _init(...args) {
if (!this.Got) {
// For some reason eslint is confused about import being supported here.
- // eslint-disable-next-line
+
this.Got = await import('got');
this.got = this.Got.got.extend({
followRedirect: false, // Outgoing API calls should not encounter redirects
/**
* Take note of transient retries.
- * @param {*} error
- * @param {*} retryCount
+ * @param {*} error error
+ * @param {*} retryCount retry count
*/
_onRetry(error, retryCount) {
const _scope = _fileScope('_onRetry');
/**
* Construct a user-agent value.
- * @param {Object} userAgentConfig
- * @param {String=} userAgentConfig.product
- * @param {String=} userAgentConfig.version
- * @param {String=} userAgentConfig.implementation
- * @returns {String}
+ * @param {object} userAgentConfig user agent config
+ * @param {string=} userAgentConfig.product product name (default package name)
+ * @param {string=} userAgentConfig.version version (default package version)
+ * @param {string=} userAgentConfig.implementation implementation (default spec supported)
+ * @returns {string} user agent string 'product/version (implementation)'
*/
static userAgentString(userAgentConfig) {
// eslint-disable-next-line security/detect-object-injection
}
+ /**
+ * @alias {number} Integer
+ */
/**
* Generate a random string.
- * @param {Integer} bytes
- * @returns {Promise<String>}
+ * @param {Integer} bytes size of challenge
+ * @returns {Promise<string>} base64 randomness
*/
static async generateChallenge(bytes = 30) {
return (await common.randomBytesAsync(bytes)).toString('base64');
/**
* Generate the signature string for content.
- * @param {Buffer} message
- * @param {Buffer} secret
- * @param {String} algorithm
- * @returns {String}
+ * @param {Buffer} message message to sign
+ * @param {Buffer} secret secret to sign with
+ * @param {string} algorithm algorithm to sign with
+ * @returns {string} signature string
*/
static signature(message, secret, algorithm) {
const hmac = crypto.createHmac(algorithm, secret)
/**
* Generate the hash for content.
- * @param {Buffer} content
- * @param {String} algorithm
- * @returns {String}
+ * @param {Buffer} content content
+ * @param {string} algorithm algorithm
+ * @returns {string} hash of content
*/
static contentHash(content, algorithm) {
return crypto.createHash(algorithm)
/**
* Attempt to verify a requested intent with client callback endpoint.
- * @param {*} dbCtx
- * @param {*} verificationId
- * @param {String} requestId
- * @returns {Boolean} whether to subsequently attempt next task if verification succeeds
+ * @param {*} dbCtx db context
+ * @param {*} verificationId verification id
+ * @param {string} requestId request id
+ * @returns {Promise<boolean>} whether to subsequently attempt next task if verification succeeds
*/
async verificationProcess(dbCtx, verificationId, requestId) {
const _scope = _fileScope('verificationProcess');
}
+ /**
+ * @alias {object} TopicData
+ * @alias {object} VerificationData
+ */
/**
* Attempt to verify a pending subscription request with publisher.
* Updates (and persists) verification.
* whether to continue verification with client.
*
* This is not defined by the spec. We opt to speak JSON here.
- * @param {*} dbCtx
- * @param {TopicData} topic
- * @param {VerificationData} verification
- * @returns {Boolean}
+ * @param {*} dbCtx db context
+ * @param {TopicData} topic topic
+ * @param {VerificationData} verification verification
+ * @returns {Promise<boolean>} true if successful contact with publisher
*/
async publisherValidate(dbCtx, topic, verification) {
const _scope = _fileScope('publisherValidate');
/**
* Retrieve content from a topic.
- * @param {*} dbCtx
- * @param {*} topicId
- * @param {String} requestId
- * @returns
+ * @param {*} dbCtx db context
+ * @param {*} topicId topic id
+ * @param {string} requestId request id
+ * @returns {Promise<void>}
*/
async topicFetchProcess(dbCtx, topicId, requestId) {
const _scope = _fileScope('topicFetchProcess');
try {
response = await this.got(updateRequestConfig);
} catch (e) {
- this.logger.error(_scope, 'update request failed', logInfoData);
+ this.logger.error(_scope, 'update request failed', { ...logInfoData, error: e });
await this.db.topicFetchIncomplete(dbCtx, topicId, this.options.communication.retryBackoffSeconds);
return;
}
/**
* Attempt to deliver a topic's content to a subscription.
- * @param {*} dbCtx
- * @param {String} callback
- * @param {*} topicId
- * @param {String} requestId
+ * @param {*} dbCtx db context
+ * @param {string} subscriptionId subscription id
+ * @param {string} requestId request id
+ * @returns {Promise<void>}
*/
async subscriptionDeliveryProcess(dbCtx, subscriptionId, requestId) {
const _scope = _fileScope('subscriptionDeliveryProcess');
/**
* Claim and work a specific topic fetch task.
- * @param {*} dbCtx
- * @param {*} id
- * @param {String} requestId
+ * @param {*} dbCtx db context
+ * @param {string} topicId topic id
+ * @param {string} requestId request id
+ * @returns {Promise<void>}
*/
async topicFetchClaimAndProcessById(dbCtx, topicId, requestId) {
const _scope = _fileScope('topicFetchClaimAndProcessById');
/**
* Claim and work a specific verification confirmation task.
- * @param {*} dbCtx
- * @param {*} verificationId
- * @param {String} requestId
- * @returns
+ * @param {*} dbCtx db context
+ * @param {*} verificationId verification id
+ * @param {string} requestId request id
+ * @returns {Promise<boolean>} whether to subsequently attempt next task if verification succeeds
*/
async verificationClaimAndProcessById(dbCtx, verificationId, requestId) {
const _scope = _fileScope('verificationClaimAndProcessById');
/**
*
- * @param {*} dbCtx
- * @param {Number} wanted maximum tasks to claim
- * @returns {Promise<void>[]}
+ * @param {*} dbCtx db context
+ * @param {number} wanted maximum tasks to claim
+ * @returns {Promise<void>[]} array of promises processing work
*/
async workFeed(dbCtx, wanted) {
const _scope = _fileScope('workFeed');