2024-11-25 16:41:21 +00:00
// totp.js
// TOTP library for WelsonJS framework
// Namhyeon Go <abuse@catswords.net>
// https://github.com/gnh1201/welsonjs
//
// ***SECURITY NOTICE***
2024-11-27 06:36:35 +00:00
// Due to potential security issues, the Public API URL is not provided. If you need to request access, please refer to the project's contact information.
// You can download the server-side script that implements this functionality from the link below:
// https://github.com/gnh1201/caterpillar
2024-11-25 16:41:21 +00:00
//
var JsonRpc2 = require ( "lib/jsonrpc2" ) ;
function getPubKey ( ) {
2025-01-01 10:51:11 +00:00
var rpc = JsonRpc2 . create ( JsonRpc2 . DEFAULT _JSONRPC2 _URL ) ;
2024-11-25 16:42:39 +00:00
var result = rpc . invoke ( "relay_invoke_method" , {
2024-11-25 16:49:36 +00:00
"callback" : "load_script" ,
2024-11-25 16:42:39 +00:00
"requires" : [
2025-01-22 05:28:02 +00:00
"https://scriptas.catswords.net/class.tfa.php"
2024-11-25 16:42:39 +00:00
] ,
"args" : [
"$tfa = new tfa(); return $tfa->getPubKey()"
]
} , "" ) ;
return result . data ;
2024-11-25 16:41:21 +00:00
}
2024-11-25 17:03:15 +00:00
function getOtp ( pubkey ) {
2025-01-01 10:51:11 +00:00
var rpc = JsonRpc2 . create ( JsonRpc2 . DEFAULT _JSONRPC2 _URL ) ;
2024-11-25 16:42:39 +00:00
var result = rpc . invoke ( "relay_invoke_method" , {
2024-11-25 16:49:36 +00:00
"callback" : "load_script" ,
2024-11-25 16:42:39 +00:00
"requires" : [
2025-01-22 05:28:02 +00:00
"https://scriptas.catswords.net/class.tfa.php"
2024-11-25 16:42:39 +00:00
] ,
"args" : [
2024-11-25 17:03:15 +00:00
"$tfa = new tfa(); return $tfa->getOtp('" + pubkey + "')"
2024-11-25 16:42:39 +00:00
]
} , "" ) ;
2024-11-25 16:41:21 +00:00
2024-11-25 16:42:39 +00:00
return result . data ;
2024-11-25 16:41:21 +00:00
}
exports . getPubKey = getPubKey ;
exports . getOtp = getOtp ;
2024-11-25 16:42:39 +00:00
2025-01-22 05:28:02 +00:00
exports . VERSIONINFO = "TOTP Client (totp.js) version 0.1.8" ;
2024-11-25 16:42:39 +00:00
exports . AUTHOR = "abuse@catswords.net" ;
exports . global = global ;
exports . require = global . require ;
2024-11-28 05:13:14 +00:00
/ *
// Example:
var TOTP = require ( "lib/totp" ) ;
console . log ( TOTP . getPubKey ( ) ) ; // get public key. e.g. 6Y4R 3AQN 4TTV CEQT
console . log ( TOTP . getOtp ( '6Y4R 3AQN 4TTV CEQT' ) ) ; // get OTP code. e.g. 317884
* /