Version 0.3.4, Rev656, CryptMessage plugin for AES and ECIES encryption, Added pyelliptic lib for OpenSSSL based encryption methods, Test CryptMessage plugin, Force reload content.json before signing and after write, Escaped Sql IN queries support, Test Sql parameter escaping, ui_websocket Test fixture, Plugin testing support, Always return websocket errors as dict, Wait for file on weboscket fileGet command if its already in bad_files queue, PushState and ReplaceState url manipulation support in wrapper API, Per auth-address localstorage, Longer timeout for udp tracker query

This commit is contained in:
HelloZeroNet 2015-12-10 21:36:20 +01:00
parent 675bd46255
commit ee70e2f022
25 changed files with 2415 additions and 43 deletions

View file

@ -92,12 +92,26 @@ class Wrapper
@actionGetLocalStorage(message)
else if cmd == "wrapperSetLocalStorage"
@actionSetLocalStorage(message)
else if cmd == "wrapperPushState"
query = @toRelativeQuery(message.params[2])
window.history.pushState(message.params[0], message.params[1], query)
else if cmd == "wrapperReplaceState"
query = @toRelativeQuery(message.params[2])
window.history.replaceState(message.params[0], message.params[1], query)
else # Send to websocket
if message.id < 1000000
@ws.send(message) # Pass message to websocket
else
@log "Invalid inner message id"
toRelativeQuery: (query) ->
back = window.location.pathname
if back.slice(-1) != "/"
back += "/"
if query.replace("?", "")
back += "?"+query.replace("?", "")
return back
# - Actions -
@ -178,13 +192,19 @@ class Wrapper
actionGetLocalStorage: (message) ->
$.when(@event_site_info).done =>
data = localStorage.getItem "site.#{@site_info.address}"
data = localStorage.getItem "site.#{@site_info.address}.#{@site_info.auth_address}"
if not data # Migrate from non auth_address based local storage
data = localStorage.getItem "site.#{@site_info.address}"
if data
localStorage.setItem "site.#{@site_info.address}.#{@site_info.auth_address}", data
localStorage.removeItem "site.#{@site_info.address}"
@log "Migrated LocalStorage from global to auth_address based"
if data then data = JSON.parse(data)
@sendInner {"cmd": "response", "to": message.id, "result": data}
actionSetLocalStorage: (message) ->
back = localStorage.setItem "site.#{@site_info.address}", JSON.stringify(message.params)
back = localStorage.setItem "site.#{@site_info.address}.#{@site_info.auth_address}", JSON.stringify(message.params)
# EOF actions

View file

@ -834,7 +834,7 @@ jQuery.extend( jQuery.easing,
};
Wrapper.prototype.onMessageInner = function(e) {
var cmd, message;
var cmd, message, query;
message = e.data;
cmd = message.cmd;
if (cmd === "innerReady") {
@ -864,6 +864,12 @@ jQuery.extend( jQuery.easing,
return this.actionGetLocalStorage(message);
} else if (cmd === "wrapperSetLocalStorage") {
return this.actionSetLocalStorage(message);
} else if (cmd === "wrapperPushState") {
query = this.toRelativeQuery(message.params[2]);
return window.history.pushState(message.params[0], message.params[1], query);
} else if (cmd === "wrapperReplaceState") {
query = this.toRelativeQuery(message.params[2]);
return window.history.replaceState(message.params[0], message.params[1], query);
} else {
if (message.id < 1000000) {
return this.ws.send(message);
@ -873,6 +879,18 @@ jQuery.extend( jQuery.easing,
}
};
Wrapper.prototype.toRelativeQuery = function(query) {
var back;
back = window.location.pathname;
if (back.slice(-1) !== "/") {
back += "/";
}
if (query.replace("?", "")) {
back += "?" + query.replace("?", "");
}
return back;
};
Wrapper.prototype.actionNotification = function(message) {
var body;
message.params = this.toHtmlSafe(message.params);
@ -987,7 +1005,15 @@ jQuery.extend( jQuery.easing,
return $.when(this.event_site_info).done((function(_this) {
return function() {
var data;
data = localStorage.getItem("site." + _this.site_info.address);
data = localStorage.getItem("site." + _this.site_info.address + "." + _this.site_info.auth_address);
if (!data) {
data = localStorage.getItem("site." + _this.site_info.address);
if (data) {
localStorage.setItem("site." + _this.site_info.address + "." + _this.site_info.auth_address, data);
localStorage.removeItem("site." + _this.site_info.address);
_this.log("Migrated LocalStorage from global to auth_address based");
}
}
if (data) {
data = JSON.parse(data);
}
@ -1002,7 +1028,7 @@ jQuery.extend( jQuery.easing,
Wrapper.prototype.actionSetLocalStorage = function(message) {
var back;
return back = localStorage.setItem("site." + this.site_info.address, JSON.stringify(message.params));
return back = localStorage.setItem("site." + this.site_info.address + "." + this.site_info.auth_address, JSON.stringify(message.params));
};
Wrapper.prototype.onOpenWebsocket = function(e) {