mirror of
https://github.com/LanceGin/jsotp.git
synced 2026-05-24 00:00:05 +08:00
upd: finish url_gen function
This commit is contained in:
+13
@@ -56,4 +56,17 @@ export class HOTP extends OTP {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate a url with HOTP instance.
|
||||
*
|
||||
* @param {issuer}
|
||||
* @type {String}
|
||||
* @desc maybe it is the Service name
|
||||
*
|
||||
* @return {String}
|
||||
*/
|
||||
url_gen(issuer="") {
|
||||
return super.url_gen(issuer, "hotp");
|
||||
}
|
||||
}
|
||||
+16
@@ -77,5 +77,21 @@ export class OTP {
|
||||
return str_code;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate a url with TOTP or HOTP instance.
|
||||
*
|
||||
* @param {issuer}
|
||||
* @type {String}
|
||||
* @desc maybe it is the Service name
|
||||
*
|
||||
* @param {type}
|
||||
* @type {String}
|
||||
* @desc type of OTP instance
|
||||
*
|
||||
* @return {String}
|
||||
*/
|
||||
url_gen(issuer, type) {
|
||||
return `otpauth://${type}/SK?secret=${this.secret}&issuer=${issuer}`;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+13
@@ -81,4 +81,17 @@ export class TOTP extends OTP {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate a url with TOTP instance.
|
||||
*
|
||||
* @param {issuer}
|
||||
* @type {String}
|
||||
* @desc maybe it is the Service name
|
||||
*
|
||||
* @return {String}
|
||||
*/
|
||||
url_gen(issuer="") {
|
||||
return super.url_gen(issuer, "totp");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user