Add TOTP library

This commit is contained in:
Namhyeon Go 2024-11-26 01:41:21 +09:00
parent 8ddff1cf94
commit 2ac75fd24e
5 changed files with 48 additions and 4 deletions

View File

@ -3,7 +3,7 @@
// https://github.com/gnh1201/welsonjs
//
// ***SECURITY NOTICE***
// Anthropic/Claude requires an internet connection. Data may be transmitted externally. Users must also comply with the terms of use and the privacy policy.
// Anthropic/Claude requires an internet connection, and data may be transmitted externally. Users must adhere to the terms of use and privacy policy.
// - Privacy Policy: https://www.anthropic.com/legal/privacy
//
var FILE = require("lib/file");

View File

@ -3,7 +3,7 @@
// https://github.com/gnh1201/welsonjs
//
// ***SECURITY NOTICE***
// ChatGPT requires an internet connection. Data may be transmitted externally. Users must also comply with the terms of use and the privacy policy.
// ChatGPT requires an internet connection, and data may be transmitted externally. Users must adhere to the terms of use and privacy policy.
// - Privacy Policy: https://openai.com/policies/row-privacy-policy/
//
var FILE = require("lib/file");

View File

@ -3,7 +3,7 @@
// https://github.com/gnh1201/welsonjs
//
// ***SECURITY NOTICE***
// Groq requires an internet connection. Data may be transmitted externally. Users must also comply with the terms of use and the privacy policy.
// Groq requires an internet connection, and data may be transmitted externally. Users must adhere to the terms of use and privacy policy.
// - Privacy Policy: https://groq.com/privacy-policy/
//
var FILE = require("lib/file");

View File

@ -3,7 +3,7 @@
// https://github.com/gnh1201/welsonjs
//
// ***SECURITY NOTICE***
// The Punycode (IDN) library requires an internet connection. Data may be transmitted externally. Users must also comply with the terms of use.
// The Punycode (IDN) library requires an active internet connection. Data may be transmitted externally, and users must adhere to the terms of use.
// - Privacy Policy: https://policy.catswords.social/site_terms.html
// - Terms of Service: https://policy.catswords.social/site_extended_description.html
//

44
lib/totp.js Normal file
View File

@ -0,0 +1,44 @@
// totp.js
// TOTP library for WelsonJS framework
// Namhyeon Go <abuse@catswords.net>
// https://github.com/gnh1201/welsonjs
//
// ***SECURITY NOTICE***
// The TOTP library requires an internet connection, and data may be transmitted externally. Users must adhere to the terms of use and privacy policy.
// - Privacy Policy: https://policy.catswords.social/site_terms.html
// - Terms of Service: https://policy.catswords.social/site_extended_description.html
//
var JsonRpc2 = require("lib/jsonrpc2");
function getPubKey() {
var rpc = JsonRpc2.create("https://public-api.catswords.net");
var result = rpc.invoke("relay_invoke_method", {
"method": "load_script",
"requires": [
"https://raw.githubusercontent.com/dimamedia/PHP-Simple-TOTP-and-PubKey/refs/heads/master/class.tfa.php"
],
"args": [
"$tfa = new tfa(); return $tfa->getPubKey()"
]
}, "");
return result.data;
}
function getOtp() {
var rpc = JsonRpc2.create("https://public-api.catswords.net");
var result = rpc.invoke("relay_invoke_method", {
"method": "load_script",
"requires": [
"https://raw.githubusercontent.com/dimamedia/PHP-Simple-TOTP-and-PubKey/refs/heads/master/class.tfa.php"
],
"args": [
"$tfa = new tfa(); return $tfa->getOtp()"
]
}, "");
return result.data;
}
exports.getPubKey = getPubKey;
exports.getOtp = getOtp;