Dynamic SF|Extension registration, handle 000 decode
This commit is contained in:
@@ -22,4 +22,13 @@ function getParameterByName(name, url) {
|
|||||||
return decodeURIComponent(results[2].replace(/\+/g, " "));
|
return decodeURIComponent(results[2].replace(/\+/g, " "));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function parametersFromURL(url) {
|
||||||
|
url = url.split("?").slice(-1)[0];
|
||||||
|
var obj = {};
|
||||||
|
url.replace(/([^=&]+)=([^&]*)/g, function(m, key, value) {
|
||||||
|
obj[decodeURIComponent(key)] = decodeURIComponent(value);
|
||||||
|
});
|
||||||
|
return obj;
|
||||||
|
}
|
||||||
|
|
||||||
angular.module('app.frontend').controller('BaseCtrl', BaseCtrl);
|
angular.module('app.frontend').controller('BaseCtrl', BaseCtrl);
|
||||||
|
|||||||
@@ -10,10 +10,7 @@ class SyncAdapter extends Item {
|
|||||||
}
|
}
|
||||||
|
|
||||||
structureParams() {
|
structureParams() {
|
||||||
var params = {
|
var params = this.content || {};
|
||||||
url: this.url,
|
|
||||||
};
|
|
||||||
|
|
||||||
_.merge(params, super.structureParams());
|
_.merge(params, super.structureParams());
|
||||||
return params;
|
return params;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -120,7 +120,8 @@ class GlobalExtensionsMenu {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$scope.handleSyncAdapterLink = function(link, completion) {
|
$scope.handleSyncAdapterLink = function(link, completion) {
|
||||||
var ext = new SyncAdapter({url: link});
|
var params = parametersFromURL(link);
|
||||||
|
var ext = new SyncAdapter({content: params});
|
||||||
ext.setDirty(true);
|
ext.setDirty(true);
|
||||||
modelManager.addItem(ext);
|
modelManager.addItem(ext);
|
||||||
syncManager.sync();
|
syncManager.sync();
|
||||||
|
|||||||
@@ -68,6 +68,15 @@ class EncryptionHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static decryptItem(item, keys) {
|
static decryptItem(item, keys) {
|
||||||
|
|
||||||
|
if((item.content.startsWith("001") || item.content.startsWith("002")) && item.enc_item_key) {
|
||||||
|
// is encrypted, continue to below
|
||||||
|
} else {
|
||||||
|
// is base64 encoded
|
||||||
|
item.content = Neeto.crypto.base64Decode(item.content.substring(3, item.content.length))
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// decrypt encrypted key
|
// decrypt encrypted key
|
||||||
var encryptedItemKey = item.enc_item_key;
|
var encryptedItemKey = item.enc_item_key;
|
||||||
var requiresAuth = true;
|
var requiresAuth = true;
|
||||||
@@ -123,19 +132,13 @@ class EncryptionHelper {
|
|||||||
var isString = typeof item.content === 'string' || item.content instanceof String;
|
var isString = typeof item.content === 'string' || item.content instanceof String;
|
||||||
if(isString) {
|
if(isString) {
|
||||||
try {
|
try {
|
||||||
if((item.content.startsWith("001") || item.content.startsWith("002")) && item.enc_item_key) {
|
this.decryptItem(item, keys);
|
||||||
// is encrypted
|
|
||||||
this.decryptItem(item, keys);
|
|
||||||
} else {
|
|
||||||
// is base64 encoded
|
|
||||||
item.content = Neeto.crypto.base64Decode(item.content.substring(3, item.content.length))
|
|
||||||
}
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
item.errorDecrypting = true;
|
item.errorDecrypting = true;
|
||||||
if(throws) {
|
if(throws) {
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
console.log("Error decrypting item", item, e);
|
console.error("Error decrypting item", item, e);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user