fix default key encoding for constructor arguments to align with default key creation...
[squeep-totp] / lib / hotp.js
index e93f7203c41ce04ce38ba4d84182471913db00a5..90942cc4b4691af0cd05bd9e3c379b92a650caca 100644 (file)
@@ -48,7 +48,7 @@ class HMACBasedOneTimePassword {
     return {
       codeLength: 6,
       counter: 0n,
-      keyEncoding: 'ascii',
+      keyEncoding: 'hex',
       algorithm: 'sha1',
     };
   }
@@ -134,7 +134,7 @@ class HMACBasedOneTimePassword {
    * Make a new key, of the assigned encoding.
    * @param {String=} encoding
    * @param {String=} algorithm
-   * @returns {String|Buffer}
+   * @returns {Promise<String|Buffer>}
    */
   static async createKey(algorithm = 'sha1', encoding = 'hex') {
     const key = await randomBytesAsync(this._algorithmKeyLength(algorithm));
@@ -172,6 +172,9 @@ class HMACBasedOneTimePassword {
    * @param {String=} options.svgFg
    * @param {String=} options.svgBg
    * @param {String=} options.svgEcl
+   * @param {Boolean=} options.join
+   * @param {Boolean=} options.xmlDeclaration
+   * @param {String=} options.container
    * @param {String|Buffer} key
    * @param {String=} keyEncoding
    * @returns {OtpAuthData}
@@ -206,6 +209,9 @@ class HMACBasedOneTimePassword {
       color: options.svgFg || '#000000',
       background: options.svgBg || '#ffffff',
       ecl: options.svgEcl || 'M',
+      join: options.join ?? true,
+      xmlDeclaration: options.xmlDeclaration ?? false,
+      container: options.container || 'svg-viewbox',
     });
 
     return {
@@ -271,6 +277,7 @@ class HMACBasedOneTimePassword {
 
   static get _qrURIDefaultOptions() {
     return {
+      issuer: '',
       scheme: 'otpauth',
       type: this._type,
     };
@@ -278,4 +285,4 @@ class HMACBasedOneTimePassword {
 
 }
 
-module.exports = HMACBasedOneTimePassword;
\ No newline at end of file
+module.exports = HMACBasedOneTimePassword;