solid-ui 2.4.27-d81bf225 → 2.4.27-ddcbbf49
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -1
- package/dist/670.solid-ui.min.js +1 -0
- package/dist/805.solid-ui.min.js +3 -0
- package/dist/805.solid-ui.min.js.LICENSE.txt +58 -0
- package/dist/805.solid-ui.min.js.map +1 -0
- package/dist/_2b19.solid-ui.js +14 -0
- package/dist/_2b19.solid-ui.js.map +1 -0
- package/dist/solid-ui.js +8345 -16517
- package/dist/solid-ui.js.map +1 -1
- package/dist/solid-ui.min.js +1 -1
- package/dist/solid-ui.min.js.LICENSE.txt +4 -59
- package/dist/solid-ui.min.js.map +1 -1
- package/dist/vendors-node_modules_jsonld_lib_jsonld_js.solid-ui.js +12134 -0
- package/dist/vendors-node_modules_jsonld_lib_jsonld_js.solid-ui.js.map +1 -0
- package/lib/chat/bookmarks.js +7 -6
- package/lib/chat/bookmarks.js.map +1 -1
- package/lib/chat/chatLogic.js +96 -248
- package/lib/chat/chatLogic.js.map +1 -1
- package/lib/chat/infinite.js +426 -604
- package/lib/chat/infinite.js.map +1 -1
- package/lib/chat/keys.d.ts +13 -0
- package/lib/chat/keys.d.ts.map +1 -0
- package/lib/chat/keys.js +233 -0
- package/lib/chat/keys.js.map +1 -0
- package/lib/chat/message.js +221 -290
- package/lib/chat/message.js.map +1 -1
- package/lib/chat/messageTools.js +276 -464
- package/lib/chat/messageTools.js.map +1 -1
- package/lib/chat/signature.d.ts +24 -0
- package/lib/chat/signature.d.ts.map +1 -0
- package/lib/chat/signature.js +112 -0
- package/lib/chat/signature.js.map +1 -0
- package/lib/chat/thread.js +144 -166
- package/lib/chat/thread.js.map +1 -1
- package/lib/preferences.js +0 -4
- package/lib/preferences.js.map +1 -1
- package/lib/utils/keyHelpers/accessData.d.ts +10 -0
- package/lib/utils/keyHelpers/accessData.d.ts.map +1 -0
- package/lib/utils/keyHelpers/accessData.js +232 -0
- package/lib/utils/keyHelpers/accessData.js.map +1 -0
- package/lib/utils/keyHelpers/acl.d.ts +20 -0
- package/lib/utils/keyHelpers/acl.d.ts.map +1 -0
- package/lib/utils/keyHelpers/acl.js +93 -0
- package/lib/utils/keyHelpers/acl.js.map +1 -0
- package/lib/versionInfo.js +2 -2
- package/lib/versionInfo.js.map +1 -1
- package/package.json +9 -6
package/lib/chat/message.js
CHANGED
|
@@ -12,7 +12,6 @@ exports.renderMessageEditor = renderMessageEditor;
|
|
|
12
12
|
exports.renderMessageRow = renderMessageRow;
|
|
13
13
|
exports.switchToEditor = switchToEditor;
|
|
14
14
|
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
15
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
16
15
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
17
16
|
var _infinite = require("./infinite");
|
|
18
17
|
var _messageTools = require("./messageTools");
|
|
@@ -28,11 +27,11 @@ var pad = _interopRequireWildcard(require("../pad"));
|
|
|
28
27
|
var style = _interopRequireWildcard(require("../style"));
|
|
29
28
|
var utils = _interopRequireWildcard(require("../utils"));
|
|
30
29
|
var widgets = _interopRequireWildcard(require("../widgets"));
|
|
30
|
+
var _signature = require("./signature");
|
|
31
|
+
var _keys = require("./keys");
|
|
31
32
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
32
33
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
33
|
-
function
|
|
34
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
35
|
-
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e2) { throw _e2; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e3) { didErr = true; err = _e3; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
|
|
34
|
+
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
|
|
36
35
|
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
37
36
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
38
37
|
var dom = window.document;
|
|
@@ -40,7 +39,11 @@ var messageBodyStyle = style.messageBodyStyle;
|
|
|
40
39
|
var label = utils.label;
|
|
41
40
|
|
|
42
41
|
/**
|
|
42
|
+
* elementForImageURI
|
|
43
43
|
* HTML component for an image
|
|
44
|
+
* @param imageUri
|
|
45
|
+
* @param options { inlineImageHeightEms }
|
|
46
|
+
* @returns HTMLAnchorElement For Image
|
|
44
47
|
*/
|
|
45
48
|
function elementForImageURI(imageUri, options) {
|
|
46
49
|
var img = dom.createElement('img');
|
|
@@ -70,21 +73,27 @@ var anchor = function anchor(text, term) {
|
|
|
70
73
|
a.textContent = text;
|
|
71
74
|
return a;
|
|
72
75
|
};
|
|
73
|
-
function
|
|
76
|
+
function nickname(person) {
|
|
74
77
|
var s = _solidLogic.store.any(person, ns.foaf('nick'));
|
|
75
78
|
if (s) return '' + s.value;
|
|
76
79
|
return '' + label(person);
|
|
77
80
|
}
|
|
78
81
|
|
|
79
82
|
/**
|
|
83
|
+
* creatorAndDate
|
|
80
84
|
* Displays creator and date for a chat message
|
|
81
85
|
* inside the `td1` element
|
|
86
|
+
* @param td1
|
|
87
|
+
* @param creator
|
|
88
|
+
* @param date
|
|
89
|
+
* @param message
|
|
90
|
+
* @returns HTMLAnchorElement For Image
|
|
82
91
|
*/
|
|
83
92
|
function creatorAndDate(td1, creator, date, message) {
|
|
84
|
-
var nickAnchor = td1.appendChild(anchor(
|
|
93
|
+
var nickAnchor = td1.appendChild(anchor(nickname(creator), creator));
|
|
85
94
|
if (creator.uri) {
|
|
86
95
|
_solidLogic.store.fetcher.nowOrWhenFetched(creator.doc(), undefined, function (_ok, _body) {
|
|
87
|
-
nickAnchor.textContent =
|
|
96
|
+
nickAnchor.textContent = nickname(creator);
|
|
88
97
|
});
|
|
89
98
|
}
|
|
90
99
|
td1.appendChild(dom.createElement('br'));
|
|
@@ -92,14 +101,20 @@ function creatorAndDate(td1, creator, date, message) {
|
|
|
92
101
|
}
|
|
93
102
|
|
|
94
103
|
/**
|
|
104
|
+
* creatorAndDateHorizontal
|
|
95
105
|
* Horizontally displays creator and date for a chat message
|
|
96
106
|
* inside the `td1` element
|
|
107
|
+
* @param td1
|
|
108
|
+
* @param creator
|
|
109
|
+
* @param date
|
|
110
|
+
* @param message
|
|
111
|
+
* @returns HTMLAnchorElement For Image
|
|
97
112
|
*/
|
|
98
113
|
function creatorAndDateHorizontal(td1, creator, date, message) {
|
|
99
114
|
var nickAnchor = td1.appendChild(anchor(label(creator), creator));
|
|
100
115
|
if (creator.uri) {
|
|
101
116
|
_solidLogic.store.fetcher.nowOrWhenFetched(creator.doc(), undefined, function (_ok, _body) {
|
|
102
|
-
nickAnchor.textContent =
|
|
117
|
+
nickAnchor.textContent = nickname(creator);
|
|
103
118
|
});
|
|
104
119
|
}
|
|
105
120
|
var dateBit = td1.appendChild(anchor(date, message));
|
|
@@ -109,234 +124,167 @@ function creatorAndDateHorizontal(td1, creator, date, message) {
|
|
|
109
124
|
}
|
|
110
125
|
|
|
111
126
|
/**
|
|
127
|
+
* renderMessageRow
|
|
112
128
|
* Renders a chat message, read-only mode
|
|
129
|
+
* @param channelObject
|
|
130
|
+
* @param message
|
|
131
|
+
* @param fresh
|
|
132
|
+
* @param options
|
|
133
|
+
* @param userContext
|
|
134
|
+
* @returns Message Row HTML Table Element
|
|
113
135
|
*/
|
|
114
|
-
function renderMessageRow(
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
while (1) switch (_context10.prev = _context10.next) {
|
|
122
|
-
case 0:
|
|
123
|
-
getBgColor = function _getBgColor(fresh) {
|
|
124
|
-
return fresh ? '#e8ffe8' : 'white';
|
|
125
|
-
};
|
|
126
|
-
colorizeByAuthor = options.colorizeByAuthor === '1' || options.colorizeByAuthor === true;
|
|
127
|
-
creator = _solidLogic.store.any(message, ns.foaf('maker'));
|
|
128
|
-
date = _solidLogic.store.any(message, ns.dct('created'));
|
|
129
|
-
_context10.next = 6;
|
|
130
|
-
return (0, _chatLogic.mostRecentVersion)(message);
|
|
131
|
-
case 6:
|
|
132
|
-
latestVersion = _context10.sent;
|
|
133
|
-
content = _solidLogic.store.any(latestVersion, ns.sioc('content')); // const id = store.any(latestVersion, ns.sioc('id'))
|
|
134
|
-
// const replies = store.each(latestVersion, ns.sioc('has_reply'))
|
|
135
|
-
_context10.next = 10;
|
|
136
|
-
return (0, _chatLogic.allVersions)(message);
|
|
137
|
-
case 10:
|
|
138
|
-
versions = _context10.sent;
|
|
139
|
-
if (versions.length > 1) {
|
|
140
|
-
debug.log('renderMessageRow versions: ', versions.join(', '));
|
|
141
|
-
}
|
|
142
|
-
// be tolerant in accepting replies on any version of a message
|
|
143
|
-
replies = versions.map(function (version) {
|
|
144
|
-
return _solidLogic.store.each(version, ns.sioc('has_reply'));
|
|
145
|
-
}).flat();
|
|
146
|
-
thread = null;
|
|
147
|
-
straightReplies = [];
|
|
148
|
-
_iterator2 = _createForOfIteratorHelper(replies);
|
|
149
|
-
try {
|
|
150
|
-
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
151
|
-
reply = _step2.value;
|
|
152
|
-
if (_solidLogic.store.holds(reply, ns.rdf('type'), ns.sioc('Thread'))) {
|
|
153
|
-
thread = reply;
|
|
154
|
-
debug.log('renderMessageRow: found thread: ' + thread);
|
|
155
|
-
} else {
|
|
156
|
-
straightReplies.push(reply);
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
} catch (err) {
|
|
160
|
-
_iterator2.e(err);
|
|
161
|
-
} finally {
|
|
162
|
-
_iterator2.f();
|
|
163
|
-
}
|
|
164
|
-
if (straightReplies.length > 1) {
|
|
165
|
-
debug.log('renderMessageRow: found normal replies: ', straightReplies);
|
|
166
|
-
}
|
|
167
|
-
_context10.next = 20;
|
|
168
|
-
return (0, _chatLogic.originalVersion)(message);
|
|
169
|
-
case 20:
|
|
170
|
-
originalMessage = _context10.sent;
|
|
171
|
-
edited = !message.sameTerm(originalMessage); // @@ load it first @@ Or display the new data at the old date.
|
|
172
|
-
// @@@ kludge!
|
|
173
|
-
sortDate = _solidLogic.store.the(originalMessage, ns.dct('created'), null, originalMessage.doc()) || _solidLogic.store.the(message, ns.dct('created'), null, message.doc()); // In message
|
|
174
|
-
messageRow = dom.createElement('tr');
|
|
175
|
-
messageRow.AJAR_date = sortDate.value;
|
|
176
|
-
messageRow.AJAR_subject = message;
|
|
177
|
-
td1 = dom.createElement('td');
|
|
178
|
-
messageRow.appendChild(td1);
|
|
179
|
-
if (!options.authorDateOnLeft) {
|
|
180
|
-
img = dom.createElement('img');
|
|
181
|
-
img.setAttribute('style', 'max-height: 2.5em; max-width: 2.5em; border-radius: 0.5em; margin: auto;');
|
|
182
|
-
widgets.setImage(img, creator);
|
|
183
|
-
td1.appendChild(img);
|
|
184
|
-
} else {
|
|
185
|
-
creatorAndDate(td1, creator, widgets.shortDate(sortDate.value), message);
|
|
186
|
-
}
|
|
187
|
-
bothDates = widgets.shortDate(sortDate.value);
|
|
188
|
-
if (edited) {
|
|
189
|
-
bothDates += ' ... ' + widgets.shortDate(date.value);
|
|
190
|
-
}
|
|
136
|
+
function renderMessageRow(channelObject, message, fresh, options, userContext) {
|
|
137
|
+
var unsignedMessage = false;
|
|
138
|
+
var colorizeByAuthor = options.colorizeByAuthor === '1' || options.colorizeByAuthor === true;
|
|
139
|
+
var creator = _solidLogic.store.any(message, ns.foaf('maker'));
|
|
140
|
+
var date = _solidLogic.store.any(message, ns.dct('created'));
|
|
141
|
+
var latestVersion = (0, _chatLogic.mostRecentVersion)(message);
|
|
142
|
+
var latestVersionCreator = _solidLogic.store.any(latestVersion, ns.foaf('maker'));
|
|
191
143
|
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
// widgets.shortDate(dateString)
|
|
197
|
-
message);
|
|
198
|
-
}
|
|
199
|
-
text = content ? content.value.trim() : '??? no content?';
|
|
200
|
-
isURI = /^https?:\/[^ <>]*$/i.test(text);
|
|
201
|
-
para = null;
|
|
202
|
-
if (isURI) {
|
|
203
|
-
isImage = /\.(gif|jpg|jpeg|tiff|png|svg)$/i.test(text); // @@ Should use content-type not URI
|
|
204
|
-
if (isImage && options.expandImagesInline) {
|
|
205
|
-
_img = elementForImageURI(text, options);
|
|
206
|
-
td2.appendChild(_img);
|
|
207
|
-
} else {
|
|
208
|
-
// Link but not Image
|
|
209
|
-
anc = td2.appendChild(dom.createElement('a'));
|
|
210
|
-
para = anc.appendChild(dom.createElement('p'));
|
|
211
|
-
anc.href = text;
|
|
212
|
-
para.textContent = text;
|
|
213
|
-
td2.appendChild(anc);
|
|
214
|
-
}
|
|
215
|
-
} else {
|
|
216
|
-
// text
|
|
217
|
-
para = dom.createElement('p');
|
|
218
|
-
td2.appendChild(para);
|
|
219
|
-
para.textContent = text;
|
|
220
|
-
}
|
|
221
|
-
if (para) {
|
|
222
|
-
bgcolor = colorizeByAuthor ? pad.lightColorHash(creator) : getBgColor(fresh);
|
|
223
|
-
para.setAttribute('style', messageBodyStyle + 'background-color: ' + bgcolor + ';');
|
|
224
|
-
}
|
|
225
|
-
_context10.next = 40;
|
|
226
|
-
return (0, _messageTools.sentimentStripLinked)(message, message.doc());
|
|
227
|
-
case 40:
|
|
228
|
-
strip = _context10.sent;
|
|
229
|
-
if (strip.children.length) {
|
|
230
|
-
td2.appendChild(dom.createElement('br'));
|
|
231
|
-
td2.appendChild(strip);
|
|
232
|
-
}
|
|
144
|
+
// use latest content if same owner, else use original
|
|
145
|
+
var msgId = creator.uri === latestVersionCreator.uri ? latestVersion : message;
|
|
146
|
+
var content = _solidLogic.store.any(msgId, ns.sioc('content'));
|
|
147
|
+
var signature = _solidLogic.store.any(msgId, $rdf.sym("".concat(_signature.SEC, "proofValue")));
|
|
233
148
|
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
case 4:
|
|
254
|
-
toolsTR = dom.createElement('tr');
|
|
255
|
-
_context9.next = 7;
|
|
256
|
-
return (0, _messageTools.messageToolbar)(message, messageRow, _objectSpread(_objectSpread({}, userContext), {}, {
|
|
257
|
-
chatOptions: options
|
|
258
|
-
}), channelObject);
|
|
259
|
-
case 7:
|
|
260
|
-
tools = _context9.sent;
|
|
261
|
-
tools.style = 'border: 0.05em solid #888; border-radius: 0 0 0.7em 0.7em; border-top: 0; height:3.5em; background-color: #fff;'; // @@ fix
|
|
262
|
-
if (messageRow.nextSibling) {
|
|
263
|
-
messageRow.parentElement.insertBefore(toolsTR, messageRow.nextSibling);
|
|
264
|
-
} else {
|
|
265
|
-
messageRow.parentElement.appendChild(toolsTR);
|
|
266
|
-
}
|
|
267
|
-
messageRow.toolTR = toolsTR;
|
|
268
|
-
toolsTR.appendChild(dom.createElement('td')); // left
|
|
269
|
-
toolsTD = toolsTR.appendChild(dom.createElement('td'));
|
|
270
|
-
toolsTR.appendChild(dom.createElement('td')); // right
|
|
271
|
-
toolsTD.appendChild(tools);
|
|
272
|
-
case 15:
|
|
273
|
-
case "end":
|
|
274
|
-
return _context9.stop();
|
|
275
|
-
}
|
|
276
|
-
}, _callee8);
|
|
277
|
-
}));
|
|
278
|
-
return function (_x20) {
|
|
279
|
-
return _ref4.apply(this, arguments);
|
|
280
|
-
};
|
|
281
|
-
}());
|
|
282
|
-
if (thread && options.showThread) {
|
|
283
|
-
debug.log(' message has thread ' + thread);
|
|
284
|
-
td3.appendChild(widgets.button(dom, _iconBase.icons.iconBase + 'noun_1180164.svg',
|
|
285
|
-
// right arrow .. @@ think of stg better
|
|
286
|
-
'see thread', function (_e) {
|
|
287
|
-
debug.log('@@@@ Calling showThread thread ' + thread);
|
|
288
|
-
options.showThread(thread, options);
|
|
289
|
-
}));
|
|
290
|
-
}
|
|
291
|
-
return _context10.abrupt("return", messageRow);
|
|
292
|
-
case 49:
|
|
293
|
-
case "end":
|
|
294
|
-
return _context10.stop();
|
|
149
|
+
// set message object
|
|
150
|
+
var msg = (0, _signature.getBlankMsg)();
|
|
151
|
+
msg.id = msgId.uri;
|
|
152
|
+
msg.created = _solidLogic.store.any(msgId, ns.dct('created')).value;
|
|
153
|
+
msg.content = content.value;
|
|
154
|
+
msg.maker = creator.uri;
|
|
155
|
+
|
|
156
|
+
// unsigned message
|
|
157
|
+
if (!(signature !== null && signature !== void 0 && signature.value)) {
|
|
158
|
+
unsignedMessage = true;
|
|
159
|
+
debug.warn(msgId.uri + ' is unsigned'); // TODO replace with UI (colored message ?)
|
|
160
|
+
} else {
|
|
161
|
+
// signed message, get public key and check signature
|
|
162
|
+
(0, _keys.getPublicKey)(creator).then(function (publicKey) {
|
|
163
|
+
debug.log(creator.uri + '\n' + msg.created + '\n' + msg.id + '\n' + publicKey);
|
|
164
|
+
if (!publicKey) {
|
|
165
|
+
// TODO try to recreate the publicKey
|
|
166
|
+
// if(me.uri === creator.uri) await getPrivateKey(creator)
|
|
167
|
+
debug.warn('message is signed but ' + creator.uri + ' is missing publicKey');
|
|
295
168
|
}
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
169
|
+
// check that publicKey is a valid hex string
|
|
170
|
+
var regex = /[0-9A-Fa-f]{6}/g;
|
|
171
|
+
if (!(publicKey !== null && publicKey !== void 0 && publicKey.match(regex))) debug.warn('invalid publicKey hex string\n' + creator.uri + '\n' + publicKey);
|
|
172
|
+
// verify signature
|
|
173
|
+
else if (signature !== null && signature !== void 0 && signature.value && !(0, _signature.verifySignature)(signature === null || signature === void 0 ? void 0 : signature.value, msg, publicKey)) debug.warn('invalid signature\n' + msg.id);
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
var originalMessage = (0, _chatLogic.originalVersion)(message);
|
|
177
|
+
var edited = !message.sameTerm(originalMessage);
|
|
178
|
+
var sortDate = _solidLogic.store.the(originalMessage, ns.dct('created'), null, originalMessage.doc()); // In message
|
|
179
|
+
|
|
180
|
+
var messageRow = dom.createElement('tr');
|
|
181
|
+
if (unsignedMessage) messageRow.setAttribute('style', 'background-color: red');
|
|
182
|
+
messageRow.AJAR_date = sortDate.value;
|
|
183
|
+
messageRow.AJAR_subject = message;
|
|
184
|
+
var td1 = dom.createElement('td');
|
|
185
|
+
messageRow.appendChild(td1);
|
|
186
|
+
if (!options.authorDateOnLeft) {
|
|
187
|
+
var img = dom.createElement('img');
|
|
188
|
+
img.setAttribute('style', 'max-height: 2.5em; max-width: 2.5em; border-radius: 0.5em; margin: auto;');
|
|
189
|
+
widgets.setImage(img, creator);
|
|
190
|
+
td1.appendChild(img);
|
|
191
|
+
} else {
|
|
192
|
+
creatorAndDate(td1, creator, widgets.shortDate(sortDate.value), message);
|
|
193
|
+
}
|
|
194
|
+
var bothDates = widgets.shortDate(sortDate.value);
|
|
195
|
+
if (edited) {
|
|
196
|
+
bothDates += ' ... ' + widgets.shortDate(date.value);
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
// Render the content ot the message itself
|
|
200
|
+
var td2 = messageRow.appendChild(dom.createElement('td'));
|
|
201
|
+
if (!options.authorDateOnLeft) {
|
|
202
|
+
creatorAndDateHorizontal(td2, creator, bothDates,
|
|
203
|
+
// widgets.shortDate(dateString)
|
|
204
|
+
message);
|
|
205
|
+
}
|
|
206
|
+
var text = content.value.trim();
|
|
207
|
+
var isURI = /^https?:\/[^ <>]*$/i.test(text);
|
|
208
|
+
var para = null;
|
|
209
|
+
if (isURI) {
|
|
210
|
+
var isImage = /\.(gif|jpg|jpeg|tiff|png|svg)$/i.test(text); // @@ Should use content-type not URI
|
|
211
|
+
if (isImage && options.expandImagesInline) {
|
|
212
|
+
var _img = elementForImageURI(text, options);
|
|
213
|
+
td2.appendChild(_img);
|
|
214
|
+
} else {
|
|
215
|
+
// Link but not Image
|
|
216
|
+
var anc = td2.appendChild(dom.createElement('a'));
|
|
217
|
+
para = anc.appendChild(dom.createElement('p'));
|
|
218
|
+
anc.href = text;
|
|
219
|
+
para.textContent = text;
|
|
220
|
+
td2.appendChild(anc);
|
|
221
|
+
}
|
|
222
|
+
} else {
|
|
223
|
+
// text
|
|
224
|
+
para = dom.createElement('p');
|
|
225
|
+
td2.appendChild(para);
|
|
226
|
+
para.textContent = text;
|
|
227
|
+
}
|
|
228
|
+
if (para) {
|
|
229
|
+
var bgcolor = colorizeByAuthor ? pad.lightColorHash(creator) : getBgColor(fresh);
|
|
230
|
+
para.setAttribute('style', messageBodyStyle + 'background-color: ' + bgcolor + ';');
|
|
231
|
+
}
|
|
232
|
+
function getBgColor(fresh) {
|
|
233
|
+
return fresh ? '#e8ffe8' : 'white';
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
// Sentiment strip
|
|
237
|
+
var strip = (0, _messageTools.sentimentStripLinked)(message, message.doc());
|
|
238
|
+
if (strip.children.length) {
|
|
239
|
+
td2.appendChild(dom.createElement('br'));
|
|
240
|
+
td2.appendChild(strip);
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
// Message tool bar button
|
|
244
|
+
var td3 = dom.createElement('td');
|
|
245
|
+
messageRow.appendChild(td3);
|
|
246
|
+
var toolsButton = widgets.button(dom, _iconBase.icons.iconBase + 'noun_243787.svg', '...');
|
|
247
|
+
td3.appendChild(toolsButton);
|
|
248
|
+
toolsButton.addEventListener('click', function (_event) {
|
|
249
|
+
if (messageRow.toolTR) {
|
|
250
|
+
// already got a toolbar? Toogle
|
|
251
|
+
messageRow.parentNode.removeChild(messageRow.toolTR);
|
|
252
|
+
delete messageRow.toolTR;
|
|
253
|
+
return;
|
|
254
|
+
}
|
|
255
|
+
var toolsTR = dom.createElement('tr');
|
|
256
|
+
var tools = (0, _messageTools.messageToolbar)(message, messageRow, userContext, channelObject);
|
|
257
|
+
tools.style = 'border: 0.05em solid #888; border-radius: 0 0 0.7em 0.7em; border-top: 0; height:3.5em; background-color: #fff;'; // @@ fix
|
|
258
|
+
if (messageRow.nextSibling) {
|
|
259
|
+
messageRow.parentElement.insertBefore(toolsTR, messageRow.nextSibling);
|
|
260
|
+
} else {
|
|
261
|
+
messageRow.parentElement.appendChild(toolsTR);
|
|
262
|
+
}
|
|
263
|
+
messageRow.toolTR = toolsTR;
|
|
264
|
+
toolsTR.appendChild(dom.createElement('td')); // left
|
|
265
|
+
var toolsTD = toolsTR.appendChild(dom.createElement('td'));
|
|
266
|
+
toolsTR.appendChild(dom.createElement('td')); // right
|
|
267
|
+
toolsTD.appendChild(tools);
|
|
268
|
+
});
|
|
269
|
+
return messageRow;
|
|
270
|
+
} // END OF RENDERMESSAGE
|
|
271
|
+
|
|
272
|
+
function switchToEditor(messageRow, message, channelObject, userContext) {
|
|
273
|
+
var messageTable = messageRow.parentNode;
|
|
274
|
+
var editRow = renderMessageEditor(channelObject, messageTable, userContext, channelObject.options, (0, _chatLogic.mostRecentVersion)(message));
|
|
275
|
+
messageTable.insertBefore(editRow, messageRow);
|
|
276
|
+
editRow.originalRow = messageRow;
|
|
277
|
+
messageRow.style.visibility = 'hidden'; // Hide the original message. unhide if user cancels edit
|
|
302
278
|
}
|
|
303
279
|
/* Control for a new message -- or editing an old message ***************
|
|
304
280
|
*
|
|
305
281
|
*/
|
|
306
|
-
function _switchToEditor() {
|
|
307
|
-
_switchToEditor = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee10(messageRow, message, channelObject, userContext) {
|
|
308
|
-
var messageTable, editRow;
|
|
309
|
-
return _regenerator["default"].wrap(function _callee10$(_context11) {
|
|
310
|
-
while (1) switch (_context11.prev = _context11.next) {
|
|
311
|
-
case 0:
|
|
312
|
-
messageTable = messageRow.parentNode;
|
|
313
|
-
_context11.t0 = renderMessageEditor;
|
|
314
|
-
_context11.t1 = channelObject;
|
|
315
|
-
_context11.t2 = messageTable;
|
|
316
|
-
_context11.t3 = userContext;
|
|
317
|
-
_context11.t4 = channelObject.options;
|
|
318
|
-
_context11.next = 8;
|
|
319
|
-
return (0, _chatLogic.mostRecentVersion)(message);
|
|
320
|
-
case 8:
|
|
321
|
-
_context11.t5 = _context11.sent;
|
|
322
|
-
editRow = (0, _context11.t0)(_context11.t1, _context11.t2, _context11.t3, _context11.t4, _context11.t5);
|
|
323
|
-
messageTable.insertBefore(editRow, messageRow);
|
|
324
|
-
editRow.originalRow = messageRow;
|
|
325
|
-
messageRow.style.visibility = 'hidden'; // Hide the original message. unhide if user cancels edit
|
|
326
|
-
case 13:
|
|
327
|
-
case "end":
|
|
328
|
-
return _context11.stop();
|
|
329
|
-
}
|
|
330
|
-
}, _callee10);
|
|
331
|
-
}));
|
|
332
|
-
return _switchToEditor.apply(this, arguments);
|
|
333
|
-
}
|
|
334
282
|
function renderMessageEditor(channelObject, messageTable, userContext, options, originalMessage) {
|
|
335
283
|
function revertEditing(messageEditor) {
|
|
336
284
|
messageEditor.originalRow.style.visibility = 'visible'; // restore read-only version
|
|
337
285
|
messageEditor.parentNode.removeChild(messageEditor);
|
|
338
286
|
}
|
|
339
|
-
function handleFieldInput(
|
|
287
|
+
function handleFieldInput(_x) {
|
|
340
288
|
return _handleFieldInput.apply(this, arguments);
|
|
341
289
|
}
|
|
342
290
|
function _handleFieldInput() {
|
|
@@ -354,87 +302,70 @@ function renderMessageEditor(channelObject, messageTable, userContext, options,
|
|
|
354
302
|
}));
|
|
355
303
|
return _handleFieldInput.apply(this, arguments);
|
|
356
304
|
}
|
|
357
|
-
function sendMessage(
|
|
305
|
+
function sendMessage(_x2, _x3) {
|
|
358
306
|
return _sendMessage.apply(this, arguments);
|
|
359
307
|
} // sendMessage
|
|
360
308
|
// DRAG AND DROP
|
|
361
309
|
function _sendMessage() {
|
|
362
|
-
_sendMessage = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function
|
|
363
|
-
var sendComplete,
|
|
364
|
-
return _regenerator["default"].wrap(function
|
|
365
|
-
while (1) switch (
|
|
310
|
+
_sendMessage = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee6(text, fromMainField) {
|
|
311
|
+
var sendComplete, message, statusArea;
|
|
312
|
+
return _regenerator["default"].wrap(function _callee6$(_context7) {
|
|
313
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
366
314
|
case 0:
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
var oldRow;
|
|
370
|
-
return _regenerator["default"].wrap(function _callee6$(_context7) {
|
|
371
|
-
while (1) switch (_context7.prev = _context7.next) {
|
|
372
|
-
case 0:
|
|
373
|
-
_context7.next = 2;
|
|
374
|
-
return (0, _infinite.insertMessageIntoTable)(channelObject, messageTable, message, false, options, userContext);
|
|
375
|
-
case 2:
|
|
376
|
-
// not green
|
|
315
|
+
sendComplete = function _sendComplete(message, _text2) {
|
|
316
|
+
(0, _infinite.insertMessageIntoTable)(channelObject, messageTable, message, false, options, userContext); // not green
|
|
377
317
|
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
318
|
+
if (originalMessage) {
|
|
319
|
+
// editing another message
|
|
320
|
+
var oldRow = messageEditor.originalRow;
|
|
321
|
+
// oldRow.style.display = '' // restore read-only version, re-attack
|
|
322
|
+
if (oldRow.parentNode) {
|
|
323
|
+
oldRow.parentNode.removeChild(oldRow); // No longer needed old version
|
|
324
|
+
} else {
|
|
325
|
+
debug.warn('No parentNode on old message ' + oldRow.textContent);
|
|
326
|
+
oldRow.style.backgroundColor = '#fee';
|
|
327
|
+
oldRow.style.visibility = 'hidden'; // @@ FIX THIS AND REMOVE FROM DOM INSTEAD
|
|
328
|
+
}
|
|
388
329
|
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
case 3:
|
|
402
|
-
case "end":
|
|
403
|
-
return _context7.stop();
|
|
404
|
-
}
|
|
405
|
-
}, _callee6);
|
|
406
|
-
}));
|
|
407
|
-
return _sendComplete.apply(this, arguments);
|
|
408
|
-
};
|
|
409
|
-
sendComplete = function _sendComplete2(_x18, _x19) {
|
|
410
|
-
return _sendComplete.apply(this, arguments);
|
|
330
|
+
messageEditor.parentNode.removeChild(messageEditor); // no longer need editor
|
|
331
|
+
} else {
|
|
332
|
+
if (fromMainField) {
|
|
333
|
+
field.value = ''; // clear from out for reuse
|
|
334
|
+
field.setAttribute('style', messageBodyStyle);
|
|
335
|
+
field.disabled = false;
|
|
336
|
+
field.scrollIntoView(options.newestFirst); // allign bottom (top)
|
|
337
|
+
field.focus(); // Start typing next line immediately
|
|
338
|
+
field.select();
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
// await channelObject.div.refresh() // Add new day if nec @@ add back
|
|
411
342
|
};
|
|
343
|
+
|
|
412
344
|
// const me = authn.currentUser() // Must be logged on or wuld have got login button
|
|
413
345
|
if (fromMainField) {
|
|
414
346
|
field.setAttribute('style', messageBodyStyle + 'color: #bbb;'); // pendingedit
|
|
415
347
|
field.disabled = true;
|
|
416
348
|
}
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
return channelObject.updateMessage(text, originalMessage
|
|
420
|
-
case
|
|
421
|
-
message =
|
|
422
|
-
|
|
349
|
+
_context7.prev = 2;
|
|
350
|
+
_context7.next = 5;
|
|
351
|
+
return channelObject.updateMessage(text, originalMessage);
|
|
352
|
+
case 5:
|
|
353
|
+
message = _context7.sent;
|
|
354
|
+
_context7.next = 13;
|
|
423
355
|
break;
|
|
424
|
-
case
|
|
425
|
-
|
|
426
|
-
|
|
356
|
+
case 8:
|
|
357
|
+
_context7.prev = 8;
|
|
358
|
+
_context7.t0 = _context7["catch"](2);
|
|
427
359
|
statusArea = userContext.statusArea || messageEditor;
|
|
428
|
-
statusArea.appendChild(widgets.errorMessageBlock(dom, 'Error writing message: ' +
|
|
429
|
-
return
|
|
360
|
+
statusArea.appendChild(widgets.errorMessageBlock(dom, 'Error writing message: ' + _context7.t0));
|
|
361
|
+
return _context7.abrupt("return");
|
|
362
|
+
case 13:
|
|
363
|
+
sendComplete(message, text);
|
|
430
364
|
case 14:
|
|
431
|
-
_context8.next = 16;
|
|
432
|
-
return sendComplete(message, text);
|
|
433
|
-
case 16:
|
|
434
365
|
case "end":
|
|
435
|
-
return
|
|
366
|
+
return _context7.stop();
|
|
436
367
|
}
|
|
437
|
-
},
|
|
368
|
+
}, _callee6, null, [[2, 8]]);
|
|
438
369
|
}));
|
|
439
370
|
return _sendMessage.apply(this, arguments);
|
|
440
371
|
}
|
|
@@ -453,7 +384,7 @@ function renderMessageEditor(channelObject, messageTable, userContext, options,
|
|
|
453
384
|
}
|
|
454
385
|
}, _callee);
|
|
455
386
|
}));
|
|
456
|
-
return function (
|
|
387
|
+
return function (_x4, _x5) {
|
|
457
388
|
return _ref.apply(this, arguments);
|
|
458
389
|
};
|
|
459
390
|
}());
|
|
@@ -497,7 +428,7 @@ function renderMessageEditor(channelObject, messageTable, userContext, options,
|
|
|
497
428
|
}
|
|
498
429
|
}, _callee2, null, [[1, 11, 14, 17]]);
|
|
499
430
|
}));
|
|
500
|
-
return function droppedURIHandler(
|
|
431
|
+
return function droppedURIHandler(_x6) {
|
|
501
432
|
return _ref2.apply(this, arguments);
|
|
502
433
|
};
|
|
503
434
|
}();
|
|
@@ -508,7 +439,7 @@ function renderMessageEditor(channelObject, messageTable, userContext, options,
|
|
|
508
439
|
imageDoc = $rdf.sym(chatDocument.dir().uri + 'Image_' + Date.now() + '.png');
|
|
509
440
|
return imageDoc;
|
|
510
441
|
}
|
|
511
|
-
function tookPicture(
|
|
442
|
+
function tookPicture(_x7) {
|
|
512
443
|
return _tookPicture.apply(this, arguments);
|
|
513
444
|
} // Body of turnOnInput
|
|
514
445
|
function _tookPicture() {
|
|
@@ -585,7 +516,7 @@ function renderMessageEditor(channelObject, messageTable, userContext, options,
|
|
|
585
516
|
}
|
|
586
517
|
}, _callee3);
|
|
587
518
|
}));
|
|
588
|
-
return function (
|
|
519
|
+
return function (_x8) {
|
|
589
520
|
return _ref3.apply(this, arguments);
|
|
590
521
|
};
|
|
591
522
|
}(), false);
|
|
@@ -647,7 +578,7 @@ function renderMessageEditor(channelObject, messageTable, userContext, options,
|
|
|
647
578
|
turnOnInput();
|
|
648
579
|
Object.assign(context, userContext);
|
|
649
580
|
(0, _bookmarks.findBookmarkDocument)(context).then(function (_context) {
|
|
650
|
-
//
|
|
581
|
+
// console.log('Bookmark file: ' + context.bookmarkDocument)
|
|
651
582
|
});
|
|
652
583
|
});
|
|
653
584
|
return messageEditor;
|