diff --git a/app/assets/py/idnaencode.py b/app/assets/py/idnaencode.py deleted file mode 100644 index 8c3ccfc..0000000 --- a/app/assets/py/idnaencode.py +++ /dev/null @@ -1,15 +0,0 @@ -#-*- coding: utf-8 -*- - -import sys - -def main(args): - if len(args) < 2: - print("Insufficient arguments") - sys.exit() - - encoded_domain = args[1].encode('idna').decode("utf-8") - - print(encoded_domain) - -if __name__ == "__main__": - main(sys.argv) diff --git a/lib/punycode.js b/lib/punycode.js index 18e027d..1274911 100644 --- a/lib/punycode.js +++ b/lib/punycode.js @@ -1,11 +1,39 @@ -var Py3 = require("lib/python3"); +// punycode.js +// Namhyeon Go +// 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. +// - 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"); + +var API_URL = "https://public-api.catswords.net"; function encode(s) { - return Py3.execScript("app\\assets\\py\\idnaencode.py", [s]).trim(); + var rpc = JsonRpc2.create(API_URL); + var result = rpc.invoke("relay_invoke_method", { + "callback": "idn_to_ascii", + "args": [s] + }, ""); + + return result.data; +} + +function decode(s) { + var rpc = JsonRpc2.create(API_URL); + var result = rpc.invoke("relay_invoke_method", { + "callback": "idn_to_utf8", + "args": [s] + }, ""); + + return result.data; } exports.encode = encode; +exports.decode = decode; -exports.VERSIONINFO = "Punycode Converter (punycode.js) version 0.1"; +exports.VERSIONINFO = "Punycode Public API client (punycode.js) version 0.2"; exports.global = global; exports.require = global.require;