Add support for ownerKey in the hash (version 1 and 2)

This commit is contained in:
yflory
2020-01-09 11:20:35 +01:00
parent 8ccafbc821
commit d4d07f3332
2 changed files with 42 additions and 0 deletions

View File

@@ -158,9 +158,17 @@ Version 1
options = hashArr.slice(5);
parsed.present = options.indexOf('present') !== -1;
parsed.embed = options.indexOf('embed') !== -1;
// Check if we have an ownerKey for this pad
hashArr.some(function (data) {
if (data.length === 86) { // XXX 88 characters - 2 trailing "="...
parsed.ownerKey = data;
return true;
}
});
parsed.getHash = function (opts) {
var hash = hashArr.slice(0, 5).join('/') + '/';
if (parsed.ownerKey) { hash += parsed.ownerKey + '/'; }
if (opts.embed) { hash += 'embed/'; }
if (opts.present) { hash += 'present/'; }
return hash;
@@ -177,9 +185,17 @@ Version 1
parsed.password = options.indexOf('p') !== -1;
parsed.present = options.indexOf('present') !== -1;
parsed.embed = options.indexOf('embed') !== -1;
// Check if we have a ownerKey for this pad
hashArr.some(function (data) {
if (data.length === 86) { // XXX 88 characters - 2 trailing "="...
parsed.ownerKey = data;
return true;
}
});
parsed.getHash = function (opts) {
var hash = hashArr.slice(0, 5).join('/') + '/';
if (parsed.ownerKey) { hash += parsed.ownerKey + '/'; }
if (parsed.password) { hash += 'p/'; }
if (opts.embed) { hash += 'embed/'; }
if (opts.present) { hash += 'present/'; }