chat-pane 2.4.15-e26ee52d → 2.4.16
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/LICENSE.md +0 -0
- package/README.md +0 -0
- package/dist/chat.bundle.js +10423 -10680
- package/dist/chat.bundle.js.map +1 -1
- package/dist/index.html +0 -0
- package/dist/longChatPane.js +10525 -10792
- package/dist/longChatPane.js.map +1 -1
- package/dist/shortChatPane.js +10520 -10787
- package/dist/shortChatPane.js.map +1 -1
- package/lib/create.js +409 -0
- package/lib/create.js.map +1 -0
- package/lib/index.js +351 -0
- package/lib/index.js.map +1 -0
- package/lib/longChatPane.js +496 -0
- package/lib/longChatPane.js.map +1 -0
- package/lib/main.js +8 -0
- package/lib/main.js.map +1 -0
- package/lib/shortChatPane.js +151 -0
- package/lib/shortChatPane.js.map +1 -0
- package/package.json +7 -6
- package/src/create.ts +2 -1
- package/src/index.html +0 -0
- package/src/index.js +14 -13
- package/src/longChatPane.js +7 -7
- package/src/main.js +0 -0
- package/src/shortChatPane.js +2 -2
package/lib/create.js
ADDED
|
@@ -0,0 +1,409 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.findChat = findChat;
|
|
9
|
+
exports.getChat = getChat;
|
|
10
|
+
|
|
11
|
+
var _solidUi = require("solid-ui");
|
|
12
|
+
|
|
13
|
+
var _solidLogic = require("solid-logic");
|
|
14
|
+
|
|
15
|
+
var _rdflib = require("rdflib");
|
|
16
|
+
|
|
17
|
+
var _longChatPane = _interopRequireWildcard(require("./longChatPane"));
|
|
18
|
+
|
|
19
|
+
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); }
|
|
20
|
+
|
|
21
|
+
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; }
|
|
22
|
+
|
|
23
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
24
|
+
|
|
25
|
+
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
26
|
+
|
|
27
|
+
function getMe() {
|
|
28
|
+
return _getMe.apply(this, arguments);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function _getMe() {
|
|
32
|
+
_getMe = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
|
|
33
|
+
var me;
|
|
34
|
+
return regeneratorRuntime.wrap(function _callee$(_context) {
|
|
35
|
+
while (1) {
|
|
36
|
+
switch (_context.prev = _context.next) {
|
|
37
|
+
case 0:
|
|
38
|
+
me = _solidLogic.authn.currentUser();
|
|
39
|
+
|
|
40
|
+
if (!(me === null)) {
|
|
41
|
+
_context.next = 3;
|
|
42
|
+
break;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
throw new Error('Current user not found! Not logged in?');
|
|
46
|
+
|
|
47
|
+
case 3:
|
|
48
|
+
_context.next = 5;
|
|
49
|
+
return _solidLogic.store.fetcher.load(me.doc());
|
|
50
|
+
|
|
51
|
+
case 5:
|
|
52
|
+
return _context.abrupt("return", me);
|
|
53
|
+
|
|
54
|
+
case 6:
|
|
55
|
+
case "end":
|
|
56
|
+
return _context.stop();
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}, _callee);
|
|
60
|
+
}));
|
|
61
|
+
return _getMe.apply(this, arguments);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function getPodRoot(_x) {
|
|
65
|
+
return _getPodRoot.apply(this, arguments);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function _getPodRoot() {
|
|
69
|
+
_getPodRoot = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2(me) {
|
|
70
|
+
var podRoot;
|
|
71
|
+
return regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
72
|
+
while (1) {
|
|
73
|
+
switch (_context2.prev = _context2.next) {
|
|
74
|
+
case 0:
|
|
75
|
+
podRoot = _solidLogic.store.any(me, _solidUi.ns.space('storage'), undefined, me.doc());
|
|
76
|
+
|
|
77
|
+
if (podRoot) {
|
|
78
|
+
_context2.next = 3;
|
|
79
|
+
break;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
throw new Error('Current user pod root not found!');
|
|
83
|
+
|
|
84
|
+
case 3:
|
|
85
|
+
return _context2.abrupt("return", podRoot);
|
|
86
|
+
|
|
87
|
+
case 4:
|
|
88
|
+
case "end":
|
|
89
|
+
return _context2.stop();
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}, _callee2);
|
|
93
|
+
}));
|
|
94
|
+
return _getPodRoot.apply(this, arguments);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
function sendInvite(_x2, _x3) {
|
|
98
|
+
return _sendInvite.apply(this, arguments);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
function _sendInvite() {
|
|
102
|
+
_sendInvite = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee3(invitee, chatThing) {
|
|
103
|
+
var inviteeInbox, inviteBody, inviteResponse, locationStr;
|
|
104
|
+
return regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
105
|
+
while (1) {
|
|
106
|
+
switch (_context3.prev = _context3.next) {
|
|
107
|
+
case 0:
|
|
108
|
+
_context3.next = 2;
|
|
109
|
+
return _solidLogic.store.fetcher.load(invitee.doc());
|
|
110
|
+
|
|
111
|
+
case 2:
|
|
112
|
+
inviteeInbox = _solidLogic.store.any(invitee, _solidUi.ns.ldp('inbox'), undefined, invitee.doc());
|
|
113
|
+
|
|
114
|
+
if (inviteeInbox) {
|
|
115
|
+
_context3.next = 5;
|
|
116
|
+
break;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
throw new Error("Invitee inbox not found! ".concat(invitee.value));
|
|
120
|
+
|
|
121
|
+
case 5:
|
|
122
|
+
inviteBody = "\n<> a <http://www.w3.org/ns/pim/meeting#LongChatInvite> ;\n".concat(_solidUi.ns.rdf('seeAlso'), " <").concat(chatThing.value, "> . \n ");
|
|
123
|
+
_context3.next = 8;
|
|
124
|
+
return _solidLogic.store.fetcher.webOperation('POST', inviteeInbox.value, {
|
|
125
|
+
data: inviteBody,
|
|
126
|
+
contentType: 'text/turtle'
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
case 8:
|
|
130
|
+
inviteResponse = _context3.sent;
|
|
131
|
+
locationStr = inviteResponse.headers.get('location');
|
|
132
|
+
|
|
133
|
+
if (locationStr) {
|
|
134
|
+
_context3.next = 12;
|
|
135
|
+
break;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
throw new Error("Invite sending returned a ".concat(inviteResponse.status));
|
|
139
|
+
|
|
140
|
+
case 12:
|
|
141
|
+
case "end":
|
|
142
|
+
return _context3.stop();
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}, _callee3);
|
|
146
|
+
}));
|
|
147
|
+
return _sendInvite.apply(this, arguments);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
function determineChatContainer(invitee, podRoot) {
|
|
151
|
+
// Create chat
|
|
152
|
+
// See https://gitter.im/solid/chat-app?at=5f3c800f855be416a23ae74a
|
|
153
|
+
var chatContainerStr = new URL("IndividualChats/".concat(new URL(invitee.value).host, "/"), podRoot.value).toString();
|
|
154
|
+
return new _rdflib.NamedNode(chatContainerStr);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
function createChatThing(_x4, _x5) {
|
|
158
|
+
return _createChatThing.apply(this, arguments);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
function _createChatThing() {
|
|
162
|
+
_createChatThing = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee4(chatContainer, me) {
|
|
163
|
+
var created;
|
|
164
|
+
return regeneratorRuntime.wrap(function _callee4$(_context4) {
|
|
165
|
+
while (1) {
|
|
166
|
+
switch (_context4.prev = _context4.next) {
|
|
167
|
+
case 0:
|
|
168
|
+
_context4.next = 2;
|
|
169
|
+
return _longChatPane["default"].mintNew({
|
|
170
|
+
session: {
|
|
171
|
+
store: _solidLogic.store
|
|
172
|
+
}
|
|
173
|
+
}, {
|
|
174
|
+
me: me,
|
|
175
|
+
newBase: chatContainer.value
|
|
176
|
+
});
|
|
177
|
+
|
|
178
|
+
case 2:
|
|
179
|
+
created = _context4.sent;
|
|
180
|
+
return _context4.abrupt("return", created.newInstance);
|
|
181
|
+
|
|
182
|
+
case 4:
|
|
183
|
+
case "end":
|
|
184
|
+
return _context4.stop();
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
}, _callee4);
|
|
188
|
+
}));
|
|
189
|
+
return _createChatThing.apply(this, arguments);
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
function setAcl(_x6, _x7, _x8) {
|
|
193
|
+
return _setAcl.apply(this, arguments);
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
function _setAcl() {
|
|
197
|
+
_setAcl = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee5(chatContainer, me, invitee) {
|
|
198
|
+
var chatAclDoc, aclBody, aclResponse;
|
|
199
|
+
return regeneratorRuntime.wrap(function _callee5$(_context5) {
|
|
200
|
+
while (1) {
|
|
201
|
+
switch (_context5.prev = _context5.next) {
|
|
202
|
+
case 0:
|
|
203
|
+
_context5.next = 2;
|
|
204
|
+
return _solidLogic.store.fetcher.load(chatContainer);
|
|
205
|
+
|
|
206
|
+
case 2:
|
|
207
|
+
// FIXME: check the Why value on this quad:
|
|
208
|
+
chatAclDoc = _solidLogic.store.any(chatContainer, new _rdflib.NamedNode('http://www.iana.org/assignments/link-relations/acl'));
|
|
209
|
+
|
|
210
|
+
if (chatAclDoc) {
|
|
211
|
+
_context5.next = 5;
|
|
212
|
+
break;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
throw new Error('Chat ACL doc not found!');
|
|
216
|
+
|
|
217
|
+
case 5:
|
|
218
|
+
aclBody = "\n@prefix acl: <http://www.w3.org/ns/auth/acl#>.\n<#owner>\n a acl:Authorization;\n acl:agent <".concat(me.value, ">;\n acl:accessTo <.>;\n acl:default <.>;\n acl:mode\n acl:Read, acl:Write, acl:Control.\n<#invitee>\n a acl:Authorization;\n acl:agent <").concat(invitee.value, ">;\n acl:accessTo <.>;\n acl:default <.>;\n acl:mode\n acl:Read, acl:Append.\n");
|
|
219
|
+
_context5.next = 8;
|
|
220
|
+
return _solidLogic.store.fetcher.webOperation('PUT', chatAclDoc.value, {
|
|
221
|
+
data: aclBody,
|
|
222
|
+
contentType: 'text/turtle'
|
|
223
|
+
});
|
|
224
|
+
|
|
225
|
+
case 8:
|
|
226
|
+
aclResponse = _context5.sent;
|
|
227
|
+
|
|
228
|
+
case 9:
|
|
229
|
+
case "end":
|
|
230
|
+
return _context5.stop();
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
}, _callee5);
|
|
234
|
+
}));
|
|
235
|
+
return _setAcl.apply(this, arguments);
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
function addToPrivateTypeIndex(_x9, _x10) {
|
|
239
|
+
return _addToPrivateTypeIndex.apply(this, arguments);
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
function _addToPrivateTypeIndex() {
|
|
243
|
+
_addToPrivateTypeIndex = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee6(chatThing, me) {
|
|
244
|
+
var privateTypeIndex, reg, ins;
|
|
245
|
+
return regeneratorRuntime.wrap(function _callee6$(_context6) {
|
|
246
|
+
while (1) {
|
|
247
|
+
switch (_context6.prev = _context6.next) {
|
|
248
|
+
case 0:
|
|
249
|
+
// Add to private type index
|
|
250
|
+
privateTypeIndex = _solidLogic.store.any(me, _solidUi.ns.solid('privateTypeIndex'));
|
|
251
|
+
|
|
252
|
+
if (privateTypeIndex) {
|
|
253
|
+
_context6.next = 3;
|
|
254
|
+
break;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
throw new Error('Private type index not found!');
|
|
258
|
+
|
|
259
|
+
case 3:
|
|
260
|
+
_context6.next = 5;
|
|
261
|
+
return _solidLogic.store.fetcher.load(privateTypeIndex);
|
|
262
|
+
|
|
263
|
+
case 5:
|
|
264
|
+
reg = _solidUi.widgets.newThing(privateTypeIndex);
|
|
265
|
+
ins = [(0, _rdflib.st)(reg, _solidUi.ns.rdf('type'), _solidUi.ns.solid('TypeRegistration'), privateTypeIndex.doc()), (0, _rdflib.st)(reg, _solidUi.ns.solid('forClass'), _solidUi.ns.meeting('LongChat'), privateTypeIndex.doc()), (0, _rdflib.st)(reg, _solidUi.ns.solid('instance'), chatThing, privateTypeIndex.doc())];
|
|
266
|
+
_context6.next = 9;
|
|
267
|
+
return new Promise(function (resolve, reject) {
|
|
268
|
+
_solidLogic.store.updater.update([], ins, function (_uri, ok, errm) {
|
|
269
|
+
if (!ok) {
|
|
270
|
+
reject(new Error(errm));
|
|
271
|
+
} else {
|
|
272
|
+
resolve();
|
|
273
|
+
}
|
|
274
|
+
});
|
|
275
|
+
});
|
|
276
|
+
|
|
277
|
+
case 9:
|
|
278
|
+
case "end":
|
|
279
|
+
return _context6.stop();
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
}, _callee6);
|
|
283
|
+
}));
|
|
284
|
+
return _addToPrivateTypeIndex.apply(this, arguments);
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
function findChat(_x11) {
|
|
288
|
+
return _findChat.apply(this, arguments);
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
function _findChat() {
|
|
292
|
+
_findChat = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee7(invitee) {
|
|
293
|
+
var me, podRoot, chatContainer, exists;
|
|
294
|
+
return regeneratorRuntime.wrap(function _callee7$(_context7) {
|
|
295
|
+
while (1) {
|
|
296
|
+
switch (_context7.prev = _context7.next) {
|
|
297
|
+
case 0:
|
|
298
|
+
_context7.next = 2;
|
|
299
|
+
return getMe();
|
|
300
|
+
|
|
301
|
+
case 2:
|
|
302
|
+
me = _context7.sent;
|
|
303
|
+
_context7.next = 5;
|
|
304
|
+
return getPodRoot(me);
|
|
305
|
+
|
|
306
|
+
case 5:
|
|
307
|
+
podRoot = _context7.sent;
|
|
308
|
+
chatContainer = determineChatContainer(invitee, podRoot);
|
|
309
|
+
exists = true;
|
|
310
|
+
_context7.prev = 8;
|
|
311
|
+
_context7.next = 11;
|
|
312
|
+
return _solidLogic.store.fetcher.load(new _rdflib.NamedNode(chatContainer.value + _longChatPane.CHAT_LOCATION_IN_CONTAINER));
|
|
313
|
+
|
|
314
|
+
case 11:
|
|
315
|
+
_context7.next = 16;
|
|
316
|
+
break;
|
|
317
|
+
|
|
318
|
+
case 13:
|
|
319
|
+
_context7.prev = 13;
|
|
320
|
+
_context7.t0 = _context7["catch"](8);
|
|
321
|
+
exists = false;
|
|
322
|
+
|
|
323
|
+
case 16:
|
|
324
|
+
return _context7.abrupt("return", {
|
|
325
|
+
me: me,
|
|
326
|
+
chatContainer: chatContainer,
|
|
327
|
+
exists: exists
|
|
328
|
+
});
|
|
329
|
+
|
|
330
|
+
case 17:
|
|
331
|
+
case "end":
|
|
332
|
+
return _context7.stop();
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
}, _callee7, null, [[8, 13]]);
|
|
336
|
+
}));
|
|
337
|
+
return _findChat.apply(this, arguments);
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
function getChat(_x12) {
|
|
341
|
+
return _getChat.apply(this, arguments);
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
function _getChat() {
|
|
345
|
+
_getChat = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee8(invitee) {
|
|
346
|
+
var createIfMissing,
|
|
347
|
+
_yield$findChat,
|
|
348
|
+
me,
|
|
349
|
+
chatContainer,
|
|
350
|
+
exists,
|
|
351
|
+
chatThing,
|
|
352
|
+
_args8 = arguments;
|
|
353
|
+
|
|
354
|
+
return regeneratorRuntime.wrap(function _callee8$(_context8) {
|
|
355
|
+
while (1) {
|
|
356
|
+
switch (_context8.prev = _context8.next) {
|
|
357
|
+
case 0:
|
|
358
|
+
createIfMissing = _args8.length > 1 && _args8[1] !== undefined ? _args8[1] : true;
|
|
359
|
+
_context8.next = 3;
|
|
360
|
+
return findChat(invitee);
|
|
361
|
+
|
|
362
|
+
case 3:
|
|
363
|
+
_yield$findChat = _context8.sent;
|
|
364
|
+
me = _yield$findChat.me;
|
|
365
|
+
chatContainer = _yield$findChat.chatContainer;
|
|
366
|
+
exists = _yield$findChat.exists;
|
|
367
|
+
|
|
368
|
+
if (!exists) {
|
|
369
|
+
_context8.next = 9;
|
|
370
|
+
break;
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
return _context8.abrupt("return", new _rdflib.NamedNode(chatContainer.value + _longChatPane.CHAT_LOCATION_IN_CONTAINER));
|
|
374
|
+
|
|
375
|
+
case 9:
|
|
376
|
+
if (!createIfMissing) {
|
|
377
|
+
_context8.next = 20;
|
|
378
|
+
break;
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
_context8.next = 12;
|
|
382
|
+
return createChatThing(chatContainer, me);
|
|
383
|
+
|
|
384
|
+
case 12:
|
|
385
|
+
chatThing = _context8.sent;
|
|
386
|
+
_context8.next = 15;
|
|
387
|
+
return sendInvite(invitee, chatThing);
|
|
388
|
+
|
|
389
|
+
case 15:
|
|
390
|
+
_context8.next = 17;
|
|
391
|
+
return setAcl(chatContainer, me, invitee);
|
|
392
|
+
|
|
393
|
+
case 17:
|
|
394
|
+
_context8.next = 19;
|
|
395
|
+
return addToPrivateTypeIndex(chatThing, me);
|
|
396
|
+
|
|
397
|
+
case 19:
|
|
398
|
+
return _context8.abrupt("return", chatThing);
|
|
399
|
+
|
|
400
|
+
case 20:
|
|
401
|
+
case "end":
|
|
402
|
+
return _context8.stop();
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
}, _callee8);
|
|
406
|
+
}));
|
|
407
|
+
return _getChat.apply(this, arguments);
|
|
408
|
+
}
|
|
409
|
+
//# sourceMappingURL=create.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/create.ts"],"names":["getMe","me","authn","currentUser","Error","store","fetcher","load","doc","getPodRoot","podRoot","any","ns","space","undefined","sendInvite","invitee","chatThing","inviteeInbox","ldp","value","inviteBody","rdf","webOperation","data","contentType","inviteResponse","locationStr","headers","get","status","determineChatContainer","chatContainerStr","URL","host","toString","NamedNode","createChatThing","chatContainer","longChatPane","mintNew","session","newBase","created","newInstance","setAcl","chatAclDoc","aclBody","aclResponse","addToPrivateTypeIndex","privateTypeIndex","solid","reg","widgets","newThing","ins","meeting","Promise","resolve","reject","updater","update","_uri","ok","errm","findChat","exists","CHAT_LOCATION_IN_CONTAINER","getChat","createIfMissing"],"mappings":";;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;;;;;;;;;SAEeA,K;;;;;mEAAf;AAAA;AAAA;AAAA;AAAA;AAAA;AACQC,YAAAA,EADR,GACaC,kBAAMC,WAAN,EADb;;AAAA,kBAEMF,EAAE,KAAK,IAFb;AAAA;AAAA;AAAA;;AAAA,kBAGU,IAAIG,KAAJ,CAAU,wCAAV,CAHV;;AAAA;AAAA;AAAA,mBAKQC,kBAAMC,OAAN,CAAcC,IAAd,CAAmBN,EAAE,CAACO,GAAH,EAAnB,CALR;;AAAA;AAAA,6CAMSP,EANT;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,G;;;;SASeQ,U;;;;;wEAAf,kBAA2BR,EAA3B;AAAA;AAAA;AAAA;AAAA;AAAA;AACQS,YAAAA,OADR,GACkBL,kBAAMM,GAAN,CAAUV,EAAV,EAAcW,YAAGC,KAAH,CAAS,SAAT,CAAd,EAAmCC,SAAnC,EAA8Cb,EAAE,CAACO,GAAH,EAA9C,CADlB;;AAAA,gBAEOE,OAFP;AAAA;AAAA;AAAA;;AAAA,kBAGU,IAAIN,KAAJ,CAAU,kCAAV,CAHV;;AAAA;AAAA,8CAKSM,OALT;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,G;;;;SAQeK,U;;;;;wEAAf,kBAA2BC,OAA3B,EAA+CC,SAA/C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBACQZ,kBAAMC,OAAN,CAAcC,IAAd,CAAmBS,OAAO,CAACR,GAAR,EAAnB,CADR;;AAAA;AAE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,EAAhB,EAAoBe,OAApB,CATT;;AAAA;AAAA;AAAA,mBAUGiC,qBAAqB,CAAChC,SAAD,EAAYhB,EAAZ,CAVxB;;AAAA;AAAA,8CAWIgB,SAXJ;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,G","sourcesContent":["import { ns, widgets } from 'solid-ui'\nimport { authn, store } from 'solid-logic'\nimport { NamedNode, st } from 'rdflib'\nimport longChatPane, { CHAT_LOCATION_IN_CONTAINER } from './longChatPane'\n\nasync function getMe () {\n const me = authn.currentUser()\n if (me === null) {\n throw new Error('Current user not found! Not logged in?')\n }\n await store.fetcher.load(me.doc())\n return me\n}\n\nasync function getPodRoot (me): Promise<NamedNode> {\n const podRoot = store.any(me, ns.space('storage'), undefined, me.doc())\n if (!podRoot) {\n throw new Error('Current user pod root not found!')\n }\n return podRoot\n}\n\nasync function sendInvite (invitee: NamedNode, chatThing: NamedNode) {\n await store.fetcher.load(invitee.doc())\n const inviteeInbox = store.any(invitee, ns.ldp('inbox'), undefined, invitee.doc())\n if (!inviteeInbox) {\n throw new Error(`Invitee inbox not found! ${invitee.value}`)\n }\n const inviteBody = `\n<> a <http://www.w3.org/ns/pim/meeting#LongChatInvite> ;\n${ns.rdf('seeAlso')} <${chatThing.value}> . \n `\n \n const inviteResponse = await store.fetcher.webOperation('POST', inviteeInbox.value, {\n data: inviteBody,\n contentType: 'text/turtle'\n })\n const locationStr = inviteResponse.headers.get('location')\n if (!locationStr) {\n throw new Error(`Invite sending returned a ${inviteResponse.status}`)\n }\n}\n\nfunction determineChatContainer (invitee, podRoot) {\n // Create chat\n // See https://gitter.im/solid/chat-app?at=5f3c800f855be416a23ae74a\n const chatContainerStr = new URL(`IndividualChats/${new URL(invitee.value).host}/`, podRoot.value).toString()\n return new NamedNode(chatContainerStr)\n}\n\nasync function createChatThing (chatContainer, me) {\n const created = await longChatPane.mintNew({\n session: {\n store\n }\n },\n {\n me,\n newBase: chatContainer.value\n })\n return created.newInstance\n}\n\nasync function setAcl(chatContainer, me, invitee) {\n // Some servers don't present a Link http response header\n // if the container doesn't exist yet, so refetch the container\n // now that it has been created:\n await store.fetcher.load(chatContainer)\n\n // FIXME: check the Why value on this quad:\n const chatAclDoc = store.any(chatContainer, new NamedNode('http://www.iana.org/assignments/link-relations/acl'))\n if (!chatAclDoc) {\n throw new Error('Chat ACL doc not found!')\n }\n\n const aclBody = `\n@prefix acl: <http://www.w3.org/ns/auth/acl#>.\n<#owner>\n a acl:Authorization;\n acl:agent <${me.value}>;\n acl:accessTo <.>;\n acl:default <.>;\n acl:mode\n acl:Read, acl:Write, acl:Control.\n<#invitee>\n a acl:Authorization;\n acl:agent <${invitee.value}>;\n acl:accessTo <.>;\n acl:default <.>;\n acl:mode\n acl:Read, acl:Append.\n`\n const aclResponse = await store.fetcher.webOperation('PUT', chatAclDoc.value, {\n data: aclBody,\n contentType: 'text/turtle'\n })\n}\nasync function addToPrivateTypeIndex(chatThing, me) {\n // Add to private type index\n const privateTypeIndex = store.any(me, ns.solid('privateTypeIndex')) as NamedNode | null\n if (!privateTypeIndex) {\n throw new Error('Private type index not found!')\n }\n await store.fetcher.load(privateTypeIndex)\n const reg = widgets.newThing(privateTypeIndex)\n const ins = [\n st(reg, ns.rdf('type'), ns.solid('TypeRegistration'), privateTypeIndex.doc()),\n st(reg, ns.solid('forClass'), ns.meeting('LongChat'), privateTypeIndex.doc()),\n st(reg, ns.solid('instance'), chatThing, privateTypeIndex.doc())\n ]\n await new Promise((resolve, reject) => {\n store.updater.update([], ins, function (_uri, ok, errm) {\n if (!ok) {\n reject(new Error(errm))\n } else {\n resolve()\n }\n })\n })\n}\n\nexport async function findChat (invitee: NamedNode) {\n const me = await getMe()\n const podRoot = await getPodRoot(me)\n const chatContainer = determineChatContainer(invitee, podRoot)\n let exists = true\n try {\n await store.fetcher.load(new NamedNode(chatContainer.value + CHAT_LOCATION_IN_CONTAINER))\n } catch (e) {\n exists = false\n }\n return { me, chatContainer, exists}\n}\n\nexport async function getChat (invitee: NamedNode, createIfMissing = true): Promise<NamedNode> {\n const { me, chatContainer, exists } = await findChat (invitee)\n if (exists) {\n return new NamedNode(chatContainer.value + CHAT_LOCATION_IN_CONTAINER)\n }\n\n if (createIfMissing) {\n const chatThing = await createChatThing(chatContainer, me)\n await sendInvite(invitee, chatThing)\n await setAcl(chatContainer, me, invitee)\n await addToPrivateTypeIndex(chatThing, me)\n return chatThing\n }\n}\n"],"file":"create.js"}
|