Showing
2 changed files
with
7 additions
and
7 deletions
| ... | @@ -41,23 +41,23 @@ const Authenticator = function (secret, options) { | ... | @@ -41,23 +41,23 @@ const Authenticator = function (secret, options) { |
| 41 | }; | 41 | }; |
| 42 | 42 | ||
| 43 | /** | 43 | /** |
| 44 | - * 获取QR显示值 | 44 | + * 获取授权定义地址 |
| 45 | - * @param title | 45 | + * @param label |
| 46 | * @param issuer | 46 | * @param issuer |
| 47 | * @return {string} | 47 | * @return {string} |
| 48 | */ | 48 | */ |
| 49 | - this.getOtpAuth = function (title, issuer) { | 49 | + this.getOtpAuthURL = function (label, issuer) { |
| 50 | return speakeasy.otpauthURL(_.merge({}, TOTP_OPTIONS, {label: title, issuer: issuer})); | 50 | return speakeasy.otpauthURL(_.merge({}, TOTP_OPTIONS, {label: title, issuer: issuer})); |
| 51 | }; | 51 | }; |
| 52 | 52 | ||
| 53 | /** | 53 | /** |
| 54 | * 生成svg的QR图片内容 | 54 | * 生成svg的QR图片内容 |
| 55 | - * @param title | 55 | + * @param label |
| 56 | * @param issuer | 56 | * @param issuer |
| 57 | * @return {*} | 57 | * @return {*} |
| 58 | */ | 58 | */ |
| 59 | - this.getQR = function(title, issuer) { | 59 | + this.getQR = function(label, issuer) { |
| 60 | - return qr.imageSync(this.getOtpAuth(title, issuer), { type: 'svg' }); | 60 | + return qr.imageSync(this.getOtpAuthURL(label, issuer), { type: 'svg' }); |
| 61 | }; | 61 | }; |
| 62 | 62 | ||
| 63 | /** | 63 | /** | ... | ... |
| ... | @@ -45,7 +45,7 @@ fs.ensureDir(img_path, function (err, added_root) { | ... | @@ -45,7 +45,7 @@ fs.ensureDir(img_path, function (err, added_root) { |
| 45 | fs.writeSync(fd, authenticator.getQR('totp@gitlab.kmlab.com', '通行密钥')); | 45 | fs.writeSync(fd, authenticator.getQR('totp@gitlab.kmlab.com', '通行密钥')); |
| 46 | fs.closeSync(fd); | 46 | fs.closeSync(fd); |
| 47 | 47 | ||
| 48 | - console.log(chalk.green('密钥字符串'), chalk.yellow(authenticator.getOtpAuth('totp@gitlab.kmlab.com', '通行密钥'))) | 48 | + console.log(chalk.green('密钥字符串'), chalk.yellow(authenticator.getOtpAuthURL('totp@gitlab.kmlab.com', '通行密钥'))) |
| 49 | }); | 49 | }); |
| 50 | 50 | ||
| 51 | console.log('QR SVG output is', img_path, qr); | 51 | console.log('QR SVG output is', img_path, qr); |
| ... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
-
Please register or login to post a comment