Toggle navigation
Toggle navigation
This project
Loading...
Sign in
tools
/
totp-key
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
lintry
2017-06-22 15:20:55 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
3075d55316337bd3a434df41be64a53fc97b82a8
3075d553
1 parent
87bb8fc5
调整命名
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
7 deletions
lib/authenticator.js
test/authenticator.test.js
lib/authenticator.js
View file @
3075d55
...
...
@@ -41,23 +41,23 @@ const Authenticator = function (secret, options) {
};
/**
* 获取
QR显示值
* @param
title
* 获取
授权定义地址
* @param
label
* @param issuer
* @return {string}
*/
this
.
getOtpAuth
=
function
(
title
,
issuer
)
{
this
.
getOtpAuth
URL
=
function
(
label
,
issuer
)
{
return
speakeasy
.
otpauthURL
(
_
.
merge
({},
TOTP_OPTIONS
,
{
label
:
title
,
issuer
:
issuer
}));
};
/**
* 生成svg的QR图片内容
* @param
title
* @param
label
* @param issuer
* @return {*}
*/
this
.
getQR
=
function
(
title
,
issuer
)
{
return
qr
.
imageSync
(
this
.
getOtpAuth
(
title
,
issuer
),
{
type
:
'svg'
});
this
.
getQR
=
function
(
label
,
issuer
)
{
return
qr
.
imageSync
(
this
.
getOtpAuth
URL
(
label
,
issuer
),
{
type
:
'svg'
});
};
/**
...
...
test/authenticator.test.js
View file @
3075d55
...
...
@@ -45,7 +45,7 @@ fs.ensureDir(img_path, function (err, added_root) {
fs
.
writeSync
(
fd
,
authenticator
.
getQR
(
'totp@gitlab.kmlab.com'
,
'通行密钥'
));
fs
.
closeSync
(
fd
);
console
.
log
(
chalk
.
green
(
'密钥字符串'
),
chalk
.
yellow
(
authenticator
.
getOtpAuth
(
'totp@gitlab.kmlab.com'
,
'通行密钥'
)))
console
.
log
(
chalk
.
green
(
'密钥字符串'
),
chalk
.
yellow
(
authenticator
.
getOtpAuth
URL
(
'totp@gitlab.kmlab.com'
,
'通行密钥'
)))
});
console
.
log
(
'QR SVG output is'
,
img_path
,
qr
);
\ No newline at end of file
...
...
Please
register
or
login
to post a comment