'use strict';
const { common } = require('@squeep/api-dingus');
+const { randomBytes } = require('node:crypto');
+const { promisify } = require('node:util');
+const randomBytesAsync = promisify(randomBytes);
/**
* Recursively freeze an object.
- * @param {Object} o
- * @returns {Object}
+ * @param {object} o object to freeze
+ * @returns {object} frozen object
*/
const freezeDeep = (o) => {
Object.freeze(o);
/**
* Return a new object duplicating `o`, without the properties specified.
- * @param {Object} o
- * @param {String[]} props
- * @returns {Object}
+ * @param {object} o source object
+ * @param {string[]} props list of property names to omit
+ * @returns {object} pruned object
*/
const omit = (o, props) => {
return Object.fromEntries(Object.entries(o).filter(([k]) => !props.includes(k)));
/**
* Helper to log mystery-box statistics.
- * @param {ConsoleLike} logger
- * @param {String} scope
- * @returns {Function}
+ * @param {object} logger logger
+ * @param {Function} logger.debug log debug
+ * @param {string} scope scope
+ * @returns {Function} stats log decorator
*/
const mysteryBoxLogger = (logger, scope) => {
return (s) => {
/**
* Hide sensitive part of an Authorization header.
- * @param {String} authHeader
- * @returns {String}
+ * @param {string} authHeader header value
+ * @returns {string} scrubbed header value
*/
const obscureAuthorizationHeader = (authHeader) => {
if (!authHeader) {
mysteryBoxLogger,
obscureAuthorizationHeader,
omit,
-});
\ No newline at end of file
+ randomBytesAsync,
+});