Updates to swshop part 1

Updated URL to new krist node
Form now validates if address own provided domain
Support for third-party sync nodes
Update k.lua and w.lua

Closes #60
This commit is contained in:
xAnavrins
2022-07-18 00:07:55 -04:00
parent aa3cd6d08d
commit 2461d060e0
5 changed files with 105 additions and 43 deletions

View File

@@ -4,9 +4,9 @@ local jua
local json
local await
local endpoint = "krist.ceriat.net"
local wsEndpoint = "ws://"..endpoint
local httpEndpoint = "http://"..endpoint
local endpoint = "krist.dev"
local wsEndpoint = "wss://"..endpoint
local httpEndpoint = "https://"..endpoint
local function asserttype(var, name, vartype, optional)
if not (type(var) == vartype or optional and type(var) == "nil") then
@@ -14,6 +14,12 @@ local function asserttype(var, name, vartype, optional)
end
end
function setNodeUrl(url)
endpoint = url
wsEndpoint = "wss://"..endpoint
httpEndpoint = "https://"..endpoint
end
function init(juai, jsoni, wi, ri)
asserttype(juai, "jua", "table")
asserttype(jsoni, "json", "table")
@@ -53,7 +59,7 @@ local function authorize_websocket(cb, privatekey)
asserttype(privatekey, "privatekey", "string", true)
api_request(function(success, data)
cb(success and data and data.ok, data.url and data.url:gsub("wss:", "ws:") or data)
cb(success and data and data.ok, data.url and data.url:gsub("ws:", "wss:") or data)
end, "/ws/start", {
privatekey = privatekey
})
@@ -175,7 +181,7 @@ local wsEventNameLookup = {
ownNames = "name",
ownWebhooks = "webhook",
motd = "motd",
keepalive = "keepalive",
keepalive = "keepalive"
}
local wsEvents = {}
@@ -367,6 +373,7 @@ function parseMeta(meta)
end
return {
setNodeUrl = setNodeUrl,
init = init,
address = address,
addressTransactions = addressTransactions,