solid-ui 2.4.18 → 2.4.19
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 +3 -2
- package/lib/acl/acl.d.ts.map +1 -1
- package/lib/acl/acl.js +2 -4
- package/lib/acl/acl.js.map +1 -1
- package/lib/acl/add-agent-buttons.d.ts.map +1 -1
- package/lib/acl/add-agent-buttons.js +5 -5
- package/lib/acl/add-agent-buttons.js.map +1 -1
- package/lib/chat/bookmarks.js +20 -22
- package/lib/chat/bookmarks.js.map +1 -1
- package/lib/chat/chatLogic.js +13 -15
- package/lib/chat/chatLogic.js.map +1 -1
- package/lib/chat/dateFolder.js +10 -10
- package/lib/chat/dateFolder.js.map +1 -1
- package/lib/chat/infinite.js +14 -16
- package/lib/chat/infinite.js.map +1 -1
- package/lib/chat/message.js +19 -23
- package/lib/chat/message.js.map +1 -1
- package/lib/chat/messageTools.js +16 -21
- package/lib/chat/messageTools.js.map +1 -1
- package/lib/chat/thread.js +24 -24
- package/lib/chat/thread.js.map +1 -1
- package/lib/create/create.d.ts.map +1 -1
- package/lib/create/create.js +9 -9
- package/lib/create/create.js.map +1 -1
- package/lib/folders.js +2 -6
- package/lib/folders.js.map +1 -1
- package/lib/footer/index.js +4 -4
- package/lib/footer/index.js.map +1 -1
- package/lib/header/index.d.ts.map +1 -1
- package/lib/header/index.js +11 -8
- package/lib/header/index.js.map +1 -1
- package/lib/index.d.ts +4 -4
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +30 -28
- package/lib/index.js.map +1 -1
- package/lib/login/login.d.ts +130 -0
- package/lib/login/login.d.ts.map +1 -0
- package/lib/login/login.js +1415 -0
- package/lib/login/login.js.map +1 -0
- package/lib/matrix/matrix.js +2 -2
- package/lib/matrix/matrix.js.map +1 -1
- package/lib/messageArea.js +9 -10
- package/lib/messageArea.js.map +1 -1
- package/lib/pad.js +2 -2
- package/lib/pad.js.map +1 -1
- package/lib/participation.d.ts.map +1 -1
- package/lib/participation.js +4 -5
- package/lib/participation.js.map +1 -1
- package/lib/preferences.js +8 -8
- package/lib/preferences.js.map +1 -1
- package/lib/{authn → signup}/config-default.js +0 -0
- package/lib/signup/config-default.js.map +1 -0
- package/lib/{authn → signup}/signup.js +0 -0
- package/lib/signup/signup.js.map +1 -0
- package/lib/table.js +2 -3
- package/lib/table.js.map +1 -1
- package/lib/tabs.js +3 -3
- package/lib/tabs.js.map +1 -1
- package/lib/utils/index.js +6 -6
- package/lib/utils/index.js.map +1 -1
- package/lib/utils/label.js +4 -5
- package/lib/utils/label.js.map +1 -1
- package/lib/versionInfo.js +2 -2
- package/lib/versionInfo.js.map +1 -1
- package/lib/webpack-bundle.js +8230 -24429
- package/lib/webpack-bundle.js.map +1 -1
- package/lib/widgets/buttons.js +16 -16
- package/lib/widgets/buttons.js.map +1 -1
- package/lib/widgets/forms/autocomplete/autocompleteBar.js +2 -2
- package/lib/widgets/forms/autocomplete/autocompleteBar.js.map +1 -1
- package/lib/widgets/forms/autocomplete/autocompleteField.js +2 -2
- package/lib/widgets/forms/autocomplete/autocompleteField.js.map +1 -1
- package/lib/widgets/forms/autocomplete/autocompletePicker.js +2 -2
- package/lib/widgets/forms/autocomplete/autocompletePicker.js.map +1 -1
- package/lib/widgets/forms/autocomplete/language.d.ts.map +1 -1
- package/lib/widgets/forms/autocomplete/language.js +7 -10
- package/lib/widgets/forms/autocomplete/language.js.map +1 -1
- package/lib/widgets/forms/autocomplete/publicData.d.ts +1 -1
- package/lib/widgets/forms/autocomplete/publicData.d.ts.map +1 -1
- package/lib/widgets/forms/autocomplete/publicData.js +15 -16
- package/lib/widgets/forms/autocomplete/publicData.js.map +1 -1
- package/lib/widgets/forms/basic.d.ts +1 -1
- package/lib/widgets/forms/basic.d.ts.map +1 -1
- package/lib/widgets/forms/basic.js +2 -2
- package/lib/widgets/forms/basic.js.map +1 -1
- package/lib/widgets/forms/comment.d.ts +1 -1
- package/lib/widgets/forms/comment.js +3 -3
- package/lib/widgets/forms/comment.js.map +1 -1
- package/lib/widgets/forms/fieldFunction.js +2 -2
- package/lib/widgets/forms/fieldFunction.js.map +1 -1
- package/lib/widgets/forms/formStyle.js +3 -3
- package/lib/widgets/forms/formStyle.js.map +1 -1
- package/lib/widgets/forms.js +10 -10
- package/lib/widgets/forms.js.map +1 -1
- package/lib/widgets/peoplePicker.js +2 -2
- package/lib/widgets/peoplePicker.js.map +1 -1
- package/package.json +12 -4
- package/lib/authn/authSession.d.ts +0 -4
- package/lib/authn/authSession.d.ts.map +0 -1
- package/lib/authn/authSession.js +0 -25
- package/lib/authn/authSession.js.map +0 -1
- package/lib/authn/authn.d.ts +0 -193
- package/lib/authn/authn.d.ts.map +0 -1
- package/lib/authn/authn.js +0 -2238
- package/lib/authn/authn.js.map +0 -1
- package/lib/authn/config-default.js.map +0 -1
- package/lib/authn/index.d.ts +0 -35
- package/lib/authn/index.d.ts.map +0 -1
- package/lib/authn/index.js +0 -44
- package/lib/authn/index.js.map +0 -1
- package/lib/authn/signup.js.map +0 -1
- package/lib/authn/types.d.ts +0 -25
- package/lib/authn/types.d.ts.map +0 -1
- package/lib/authn/types.js +0 -6
- package/lib/authn/types.js.map +0 -1
- package/lib/logic.d.ts +0 -8
- package/lib/logic.d.ts.map +0 -1
- package/lib/logic.js +0 -79
- package/lib/logic.js.map +0 -1
package/lib/authn/authn.js
DELETED
|
@@ -1,2238 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
|
-
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
6
|
-
|
|
7
|
-
Object.defineProperty(exports, "__esModule", {
|
|
8
|
-
value: true
|
|
9
|
-
});
|
|
10
|
-
exports.authSession = void 0;
|
|
11
|
-
exports.checkUser = checkUser;
|
|
12
|
-
exports.currentUser = currentUser;
|
|
13
|
-
exports.defaultTestUser = defaultTestUser;
|
|
14
|
-
exports.filterAvailablePanes = filterAvailablePanes;
|
|
15
|
-
exports.findAppInstances = findAppInstances;
|
|
16
|
-
exports.findOriginOwner = findOriginOwner;
|
|
17
|
-
exports.getUserRoles = getUserRoles;
|
|
18
|
-
exports.loadTypeIndexes = loadTypeIndexes;
|
|
19
|
-
exports.logIn = logIn;
|
|
20
|
-
exports.logInLoadPreferences = logInLoadPreferences;
|
|
21
|
-
exports.logInLoadProfile = logInLoadProfile;
|
|
22
|
-
exports.loginStatusBox = loginStatusBox;
|
|
23
|
-
exports.newAppInstance = newAppInstance;
|
|
24
|
-
exports.offlineTestID = offlineTestID;
|
|
25
|
-
exports.registerInTypeIndex = registerInTypeIndex;
|
|
26
|
-
exports.registrationControl = registrationControl;
|
|
27
|
-
exports.registrationList = registrationList;
|
|
28
|
-
exports.renderSignInPopup = renderSignInPopup;
|
|
29
|
-
exports.saveUser = saveUser;
|
|
30
|
-
exports.selectWorkspace = selectWorkspace;
|
|
31
|
-
exports.setACLUserPublic = setACLUserPublic;
|
|
32
|
-
|
|
33
|
-
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
34
|
-
|
|
35
|
-
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
36
|
-
|
|
37
|
-
var _rdflib = require("rdflib");
|
|
38
|
-
|
|
39
|
-
var _signup = require("./signup");
|
|
40
|
-
|
|
41
|
-
var widgets = _interopRequireWildcard(require("../widgets"));
|
|
42
|
-
|
|
43
|
-
var ns = _interopRequireWildcard(require("../ns.js"));
|
|
44
|
-
|
|
45
|
-
var utils = _interopRequireWildcard(require("../utils"));
|
|
46
|
-
|
|
47
|
-
var _log = require("../log");
|
|
48
|
-
|
|
49
|
-
var _authSession = _interopRequireDefault(require("./authSession"));
|
|
50
|
-
|
|
51
|
-
var debug = _interopRequireWildcard(require("../debug"));
|
|
52
|
-
|
|
53
|
-
var _style = require("../style");
|
|
54
|
-
|
|
55
|
-
var _logic = require("../logic");
|
|
56
|
-
|
|
57
|
-
var _solidLogic = require("solid-logic");
|
|
58
|
-
|
|
59
|
-
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); }
|
|
60
|
-
|
|
61
|
-
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; }
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* Signing in, signing up, profile and preferences reloading
|
|
65
|
-
* Type index management
|
|
66
|
-
*
|
|
67
|
-
* Many functions in this module take a context object which
|
|
68
|
-
* holds various RDF symbols, add to it, and return a promise of it.
|
|
69
|
-
*
|
|
70
|
-
* * `me` RDF symbol for the user's WebID
|
|
71
|
-
* * `publicProfile` The user's public profile, iff loaded
|
|
72
|
-
* * `preferencesFile` The user's personal preference file, iff loaded
|
|
73
|
-
* * `index.public` The user's public type index file
|
|
74
|
-
* * `index.private` The user's private type index file
|
|
75
|
-
*
|
|
76
|
-
* Not RDF symbols:
|
|
77
|
-
* * `noun` A string in english for the type of thing -- like "address book"
|
|
78
|
-
* * `instance` An array of nodes which are existing instances
|
|
79
|
-
* * `containers` An array of nodes of containers of instances
|
|
80
|
-
* * `div` A DOM element where UI can be displayed
|
|
81
|
-
* * `statusArea` A DOM element (opt) progress stuff can be displayed, or error messages
|
|
82
|
-
* @packageDocumentation
|
|
83
|
-
*/
|
|
84
|
-
|
|
85
|
-
/* global confirm */
|
|
86
|
-
var authSession = _authSession["default"];
|
|
87
|
-
exports.authSession = authSession;
|
|
88
|
-
var DEFAULT_ISSUERS = [{
|
|
89
|
-
name: 'Solid Community',
|
|
90
|
-
uri: 'https://solidcommunity.net'
|
|
91
|
-
}, {
|
|
92
|
-
name: 'Solid Web',
|
|
93
|
-
uri: 'https://solidweb.org'
|
|
94
|
-
}, {
|
|
95
|
-
name: 'Inrupt.net',
|
|
96
|
-
uri: 'https://inrupt.net'
|
|
97
|
-
}, {
|
|
98
|
-
name: 'pod.Inrupt.com',
|
|
99
|
-
uri: 'https://broker.pod.inrupt.com'
|
|
100
|
-
}]; // const userCheckSite = 'https://databox.me/'
|
|
101
|
-
|
|
102
|
-
/**
|
|
103
|
-
* Look for and load the User who has control over it
|
|
104
|
-
*/
|
|
105
|
-
|
|
106
|
-
function findOriginOwner(doc) {
|
|
107
|
-
var uri = typeof doc === 'string' ? doc : doc.uri;
|
|
108
|
-
var i = uri.indexOf('://');
|
|
109
|
-
if (i < 0) return false;
|
|
110
|
-
var j = uri.indexOf('/', i + 3);
|
|
111
|
-
if (j < 0) return false;
|
|
112
|
-
var origin = uri.slice(0, j + 1); // @@ TBC
|
|
113
|
-
|
|
114
|
-
return origin;
|
|
115
|
-
}
|
|
116
|
-
/**
|
|
117
|
-
* Saves `webId` in `context.me`
|
|
118
|
-
* @param webId
|
|
119
|
-
* @param context
|
|
120
|
-
*
|
|
121
|
-
* @returns Returns the WebID, after setting it
|
|
122
|
-
*/
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
function saveUser(webId, context) {
|
|
126
|
-
// @@ TODO Remove the need for having context as output argument
|
|
127
|
-
var webIdUri;
|
|
128
|
-
|
|
129
|
-
if (webId) {
|
|
130
|
-
webIdUri = typeof webId === 'string' ? webId : webId.uri;
|
|
131
|
-
var me = (0, _rdflib.namedNode)(webIdUri);
|
|
132
|
-
|
|
133
|
-
if (context) {
|
|
134
|
-
context.me = me;
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
return me;
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
return null;
|
|
141
|
-
}
|
|
142
|
-
/**
|
|
143
|
-
* Wrapper around [[offlineTestID]]
|
|
144
|
-
* @returns {NamedNode|null}
|
|
145
|
-
*/
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
function defaultTestUser() {
|
|
149
|
-
// Check for offline override
|
|
150
|
-
var offlineId = offlineTestID();
|
|
151
|
-
|
|
152
|
-
if (offlineId) {
|
|
153
|
-
return offlineId;
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
return null;
|
|
157
|
-
}
|
|
158
|
-
/**
|
|
159
|
-
* find a user or app's context as set in window.SolidAppContext
|
|
160
|
-
* @return {any} - an appContext object
|
|
161
|
-
*/
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
function appContext() {
|
|
165
|
-
var _window = window,
|
|
166
|
-
SolidAppContext = _window.SolidAppContext;
|
|
167
|
-
SolidAppContext || (SolidAppContext = {});
|
|
168
|
-
SolidAppContext.viewingNoAuthPage = false;
|
|
169
|
-
|
|
170
|
-
if (SolidAppContext.noAuth && window.document) {
|
|
171
|
-
var currentPage = window.document.location.href;
|
|
172
|
-
|
|
173
|
-
if (currentPage.startsWith(SolidAppContext.noAuth)) {
|
|
174
|
-
SolidAppContext.viewingNoAuthPage = true;
|
|
175
|
-
var params = new URLSearchParams(window.document.location.search);
|
|
176
|
-
|
|
177
|
-
if (params) {
|
|
178
|
-
var viewedPage = SolidAppContext.viewedPage = params.get('uri') || null;
|
|
179
|
-
|
|
180
|
-
if (viewedPage) {
|
|
181
|
-
viewedPage = decodeURI(viewedPage);
|
|
182
|
-
|
|
183
|
-
if (!viewedPage.startsWith(SolidAppContext.noAuth)) {
|
|
184
|
-
var ary = viewedPage.split(/\//);
|
|
185
|
-
SolidAppContext.idp = ary[0] + '//' + ary[2];
|
|
186
|
-
SolidAppContext.viewingNoAuthPage = false;
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
return SolidAppContext;
|
|
194
|
-
}
|
|
195
|
-
/**
|
|
196
|
-
* Checks synchronously whether user is logged in
|
|
197
|
-
*
|
|
198
|
-
* @returns Named Node or null
|
|
199
|
-
*/
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
function currentUser() {
|
|
203
|
-
var app = appContext();
|
|
204
|
-
|
|
205
|
-
if (app.viewingNoAuthPage) {
|
|
206
|
-
return (0, _rdflib.sym)(app.webId);
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
if (authSession.info.webId && authSession.info.isLoggedIn) {
|
|
210
|
-
return (0, _rdflib.sym)(authSession.info.webId);
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
return offlineTestID(); // null unless testing
|
|
214
|
-
// JSON.parse(localStorage['solid-auth-client']).session.webId
|
|
215
|
-
}
|
|
216
|
-
/**
|
|
217
|
-
* Resolves with the logged in user's WebID
|
|
218
|
-
*
|
|
219
|
-
* @param context
|
|
220
|
-
*/
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
function logIn(context) {
|
|
224
|
-
var app = appContext();
|
|
225
|
-
var me = app.viewingNoAuthPage ? (0, _rdflib.sym)(app.webId) : defaultTestUser(); // me is a NamedNode or null
|
|
226
|
-
|
|
227
|
-
if (me) {
|
|
228
|
-
context.me = me;
|
|
229
|
-
return Promise.resolve(context);
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
return new Promise(function (resolve) {
|
|
233
|
-
checkUser().then(function (webId) {
|
|
234
|
-
// Already logged in?
|
|
235
|
-
if (webId) {
|
|
236
|
-
context.me = (0, _rdflib.sym)(webId);
|
|
237
|
-
debug.log("logIn: Already logged in as ".concat(context.me));
|
|
238
|
-
return resolve(context);
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
if (!context.div || !context.dom) {
|
|
242
|
-
return resolve(context);
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
var box = loginStatusBox(context.dom, function (webIdUri) {
|
|
246
|
-
saveUser(webIdUri, context);
|
|
247
|
-
resolve(context); // always pass growing context
|
|
248
|
-
});
|
|
249
|
-
context.div.appendChild(box);
|
|
250
|
-
});
|
|
251
|
-
});
|
|
252
|
-
}
|
|
253
|
-
/**
|
|
254
|
-
* Logs the user in and loads their WebID profile document into the store
|
|
255
|
-
*
|
|
256
|
-
* @param context
|
|
257
|
-
*
|
|
258
|
-
* @returns Resolves with the context after login / fetch
|
|
259
|
-
*/
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
function logInLoadProfile(_x2) {
|
|
263
|
-
return _logInLoadProfile.apply(this, arguments);
|
|
264
|
-
}
|
|
265
|
-
/**
|
|
266
|
-
* Loads preference file
|
|
267
|
-
* Do this after having done log in and load profile
|
|
268
|
-
*
|
|
269
|
-
* @private
|
|
270
|
-
*
|
|
271
|
-
* @param context
|
|
272
|
-
*/
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
function _logInLoadProfile() {
|
|
276
|
-
_logInLoadProfile = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee4(context) {
|
|
277
|
-
var loggedInContext;
|
|
278
|
-
return _regenerator["default"].wrap(function _callee4$(_context4) {
|
|
279
|
-
while (1) {
|
|
280
|
-
switch (_context4.prev = _context4.next) {
|
|
281
|
-
case 0:
|
|
282
|
-
if (!context.publicProfile) {
|
|
283
|
-
_context4.next = 2;
|
|
284
|
-
break;
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
return _context4.abrupt("return", context);
|
|
288
|
-
|
|
289
|
-
case 2:
|
|
290
|
-
_context4.prev = 2;
|
|
291
|
-
_context4.next = 5;
|
|
292
|
-
return logIn(context);
|
|
293
|
-
|
|
294
|
-
case 5:
|
|
295
|
-
loggedInContext = _context4.sent;
|
|
296
|
-
|
|
297
|
-
if (loggedInContext.me) {
|
|
298
|
-
_context4.next = 8;
|
|
299
|
-
break;
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
throw new Error('Could not log in');
|
|
303
|
-
|
|
304
|
-
case 8:
|
|
305
|
-
_context4.next = 10;
|
|
306
|
-
return _logic.solidLogicSingleton.loadProfile(loggedInContext.me);
|
|
307
|
-
|
|
308
|
-
case 10:
|
|
309
|
-
context.publicProfile = _context4.sent;
|
|
310
|
-
_context4.next = 17;
|
|
311
|
-
break;
|
|
312
|
-
|
|
313
|
-
case 13:
|
|
314
|
-
_context4.prev = 13;
|
|
315
|
-
_context4.t0 = _context4["catch"](2);
|
|
316
|
-
|
|
317
|
-
if (context.div && context.dom) {
|
|
318
|
-
context.div.appendChild(widgets.errorMessageBlock(context.dom, _context4.t0.message));
|
|
319
|
-
}
|
|
320
|
-
|
|
321
|
-
throw new Error("Can't log in: ".concat(_context4.t0));
|
|
322
|
-
|
|
323
|
-
case 17:
|
|
324
|
-
return _context4.abrupt("return", context);
|
|
325
|
-
|
|
326
|
-
case 18:
|
|
327
|
-
case "end":
|
|
328
|
-
return _context4.stop();
|
|
329
|
-
}
|
|
330
|
-
}
|
|
331
|
-
}, _callee4, null, [[2, 13]]);
|
|
332
|
-
}));
|
|
333
|
-
return _logInLoadProfile.apply(this, arguments);
|
|
334
|
-
}
|
|
335
|
-
|
|
336
|
-
function logInLoadPreferences(_x3) {
|
|
337
|
-
return _logInLoadPreferences.apply(this, arguments);
|
|
338
|
-
}
|
|
339
|
-
/**
|
|
340
|
-
* Resolves with the same context, outputting
|
|
341
|
-
* output: index.public, index.private
|
|
342
|
-
*
|
|
343
|
-
* @see https://github.com/solid/solid/blob/main/proposals/data-discovery.md#discoverability
|
|
344
|
-
*/
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
function _logInLoadPreferences() {
|
|
348
|
-
_logInLoadPreferences = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee5(context) {
|
|
349
|
-
var statusArea, progressDisplay, complain, preferencesFile, m2;
|
|
350
|
-
return _regenerator["default"].wrap(function _callee5$(_context5) {
|
|
351
|
-
while (1) {
|
|
352
|
-
switch (_context5.prev = _context5.next) {
|
|
353
|
-
case 0:
|
|
354
|
-
complain = function _complain(message) {
|
|
355
|
-
message = "logInLoadPreferences: ".concat(message);
|
|
356
|
-
|
|
357
|
-
if (statusArea) {
|
|
358
|
-
// statusArea.innerHTML = ''
|
|
359
|
-
statusArea.appendChild(widgets.errorMessageBlock(context.dom, message));
|
|
360
|
-
}
|
|
361
|
-
|
|
362
|
-
debug.log(message); // reject(new Error(message))
|
|
363
|
-
};
|
|
364
|
-
|
|
365
|
-
if (!context.preferencesFile) {
|
|
366
|
-
_context5.next = 3;
|
|
367
|
-
break;
|
|
368
|
-
}
|
|
369
|
-
|
|
370
|
-
return _context5.abrupt("return", Promise.resolve(context));
|
|
371
|
-
|
|
372
|
-
case 3:
|
|
373
|
-
// already done
|
|
374
|
-
statusArea = context.statusArea || context.div || null;
|
|
375
|
-
_context5.prev = 4;
|
|
376
|
-
_context5.next = 7;
|
|
377
|
-
return logInLoadProfile(context);
|
|
378
|
-
|
|
379
|
-
case 7:
|
|
380
|
-
context = _context5.sent;
|
|
381
|
-
_context5.next = 10;
|
|
382
|
-
return _logic.solidLogicSingleton.loadPreferences(context.me);
|
|
383
|
-
|
|
384
|
-
case 10:
|
|
385
|
-
preferencesFile = _context5.sent;
|
|
386
|
-
|
|
387
|
-
if (progressDisplay) {
|
|
388
|
-
progressDisplay.parentNode.removeChild(progressDisplay);
|
|
389
|
-
}
|
|
390
|
-
|
|
391
|
-
context.preferencesFile = preferencesFile;
|
|
392
|
-
_context5.next = 48;
|
|
393
|
-
break;
|
|
394
|
-
|
|
395
|
-
case 15:
|
|
396
|
-
_context5.prev = 15;
|
|
397
|
-
_context5.t0 = _context5["catch"](4);
|
|
398
|
-
|
|
399
|
-
if (!(_context5.t0 instanceof _solidLogic.UnauthorizedError)) {
|
|
400
|
-
_context5.next = 22;
|
|
401
|
-
break;
|
|
402
|
-
}
|
|
403
|
-
|
|
404
|
-
m2 = 'Ooops - you are not authenticated (properly logged in) to for me to read your preference file. Try loggin out and logging in?';
|
|
405
|
-
(0, _log.alert)(m2);
|
|
406
|
-
_context5.next = 48;
|
|
407
|
-
break;
|
|
408
|
-
|
|
409
|
-
case 22:
|
|
410
|
-
if (!(_context5.t0 instanceof _solidLogic.CrossOriginForbiddenError)) {
|
|
411
|
-
_context5.next = 28;
|
|
412
|
-
break;
|
|
413
|
-
}
|
|
414
|
-
|
|
415
|
-
m2 = "Unauthorized: Assuming preference file blocked for origin ".concat(window.location.origin);
|
|
416
|
-
context.preferencesFileError = m2;
|
|
417
|
-
return _context5.abrupt("return", context);
|
|
418
|
-
|
|
419
|
-
case 28:
|
|
420
|
-
if (!(_context5.t0 instanceof _solidLogic.SameOriginForbiddenError)) {
|
|
421
|
-
_context5.next = 33;
|
|
422
|
-
break;
|
|
423
|
-
}
|
|
424
|
-
|
|
425
|
-
m2 = 'You are not authorized to read your preference file. This may be because you are using an untrusted web app.';
|
|
426
|
-
debug.warn(m2);
|
|
427
|
-
_context5.next = 48;
|
|
428
|
-
break;
|
|
429
|
-
|
|
430
|
-
case 33:
|
|
431
|
-
if (!(_context5.t0 instanceof _solidLogic.NotFoundError)) {
|
|
432
|
-
_context5.next = 42;
|
|
433
|
-
break;
|
|
434
|
-
}
|
|
435
|
-
|
|
436
|
-
if (!confirm("You do not currently have a preference file. OK for me to create an empty one? ".concat(_context5.t0.preferencesFile || ''))) {
|
|
437
|
-
_context5.next = 39;
|
|
438
|
-
break;
|
|
439
|
-
}
|
|
440
|
-
|
|
441
|
-
// @@@ code me ... weird to have a name of the file but no file
|
|
442
|
-
(0, _log.alert)("Sorry; I am not prepared to do this. Please create an empty file at ".concat(_context5.t0.preferencesFile || '(?)'));
|
|
443
|
-
complain(new Error('Sorry; no code yet to create a preference file at '));
|
|
444
|
-
_context5.next = 40;
|
|
445
|
-
break;
|
|
446
|
-
|
|
447
|
-
case 39:
|
|
448
|
-
throw new Error("User declined to create a preference file at ".concat(_context5.t0.preferencesFile || '(?)'));
|
|
449
|
-
|
|
450
|
-
case 40:
|
|
451
|
-
_context5.next = 48;
|
|
452
|
-
break;
|
|
453
|
-
|
|
454
|
-
case 42:
|
|
455
|
-
if (!(_context5.t0 instanceof _solidLogic.FetchError)) {
|
|
456
|
-
_context5.next = 47;
|
|
457
|
-
break;
|
|
458
|
-
}
|
|
459
|
-
|
|
460
|
-
m2 = "Strange: Error ".concat(_context5.t0.status, " trying to read your preference file.").concat(_context5.t0.message);
|
|
461
|
-
(0, _log.alert)(m2);
|
|
462
|
-
_context5.next = 48;
|
|
463
|
-
break;
|
|
464
|
-
|
|
465
|
-
case 47:
|
|
466
|
-
throw new Error("(via loadPrefs) ".concat(_context5.t0));
|
|
467
|
-
|
|
468
|
-
case 48:
|
|
469
|
-
return _context5.abrupt("return", context);
|
|
470
|
-
|
|
471
|
-
case 49:
|
|
472
|
-
case "end":
|
|
473
|
-
return _context5.stop();
|
|
474
|
-
}
|
|
475
|
-
}
|
|
476
|
-
}, _callee5, null, [[4, 15]]);
|
|
477
|
-
}));
|
|
478
|
-
return _logInLoadPreferences.apply(this, arguments);
|
|
479
|
-
}
|
|
480
|
-
|
|
481
|
-
function loadIndex(_x4, _x5) {
|
|
482
|
-
return _loadIndex.apply(this, arguments);
|
|
483
|
-
}
|
|
484
|
-
|
|
485
|
-
function _loadIndex() {
|
|
486
|
-
_loadIndex = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee7(context, isPublic) {
|
|
487
|
-
var indexes;
|
|
488
|
-
return _regenerator["default"].wrap(function _callee7$(_context7) {
|
|
489
|
-
while (1) {
|
|
490
|
-
switch (_context7.prev = _context7.next) {
|
|
491
|
-
case 0:
|
|
492
|
-
_context7.next = 2;
|
|
493
|
-
return _logic.solidLogicSingleton.loadIndexes(context.me, isPublic ? context.publicProfile || null : null, isPublic ? null : context.preferencesFile || null, /*#__PURE__*/function () {
|
|
494
|
-
var _ref4 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee6(err) {
|
|
495
|
-
return _regenerator["default"].wrap(function _callee6$(_context6) {
|
|
496
|
-
while (1) {
|
|
497
|
-
switch (_context6.prev = _context6.next) {
|
|
498
|
-
case 0:
|
|
499
|
-
return _context6.abrupt("return", widgets.complain(context, err.message));
|
|
500
|
-
|
|
501
|
-
case 1:
|
|
502
|
-
case "end":
|
|
503
|
-
return _context6.stop();
|
|
504
|
-
}
|
|
505
|
-
}
|
|
506
|
-
}, _callee6);
|
|
507
|
-
}));
|
|
508
|
-
|
|
509
|
-
return function (_x21) {
|
|
510
|
-
return _ref4.apply(this, arguments);
|
|
511
|
-
};
|
|
512
|
-
}());
|
|
513
|
-
|
|
514
|
-
case 2:
|
|
515
|
-
indexes = _context7.sent;
|
|
516
|
-
context.index = context.index || {};
|
|
517
|
-
context.index["private"] = indexes["private"] || context.index["private"];
|
|
518
|
-
context.index["public"] = indexes["public"] || context.index["public"];
|
|
519
|
-
return _context7.abrupt("return", context);
|
|
520
|
-
|
|
521
|
-
case 7:
|
|
522
|
-
case "end":
|
|
523
|
-
return _context7.stop();
|
|
524
|
-
}
|
|
525
|
-
}
|
|
526
|
-
}, _callee7);
|
|
527
|
-
}));
|
|
528
|
-
return _loadIndex.apply(this, arguments);
|
|
529
|
-
}
|
|
530
|
-
|
|
531
|
-
function loadTypeIndexes(_x6) {
|
|
532
|
-
return _loadTypeIndexes.apply(this, arguments);
|
|
533
|
-
}
|
|
534
|
-
/**
|
|
535
|
-
* Resolves with the same context, outputting
|
|
536
|
-
* @see https://github.com/solid/solid/blob/main/proposals/data-discovery.md#discoverability
|
|
537
|
-
*/
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
function _loadTypeIndexes() {
|
|
541
|
-
_loadTypeIndexes = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee9(context) {
|
|
542
|
-
var indexes;
|
|
543
|
-
return _regenerator["default"].wrap(function _callee9$(_context9) {
|
|
544
|
-
while (1) {
|
|
545
|
-
switch (_context9.prev = _context9.next) {
|
|
546
|
-
case 0:
|
|
547
|
-
_context9.next = 2;
|
|
548
|
-
return _logic.solidLogicSingleton.loadIndexes(context.me, context.publicProfile || null, context.preferencesFile || null, /*#__PURE__*/function () {
|
|
549
|
-
var _ref5 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee8(err) {
|
|
550
|
-
return _regenerator["default"].wrap(function _callee8$(_context8) {
|
|
551
|
-
while (1) {
|
|
552
|
-
switch (_context8.prev = _context8.next) {
|
|
553
|
-
case 0:
|
|
554
|
-
return _context8.abrupt("return", widgets.complain(context, err.message));
|
|
555
|
-
|
|
556
|
-
case 1:
|
|
557
|
-
case "end":
|
|
558
|
-
return _context8.stop();
|
|
559
|
-
}
|
|
560
|
-
}
|
|
561
|
-
}, _callee8);
|
|
562
|
-
}));
|
|
563
|
-
|
|
564
|
-
return function (_x22) {
|
|
565
|
-
return _ref5.apply(this, arguments);
|
|
566
|
-
};
|
|
567
|
-
}());
|
|
568
|
-
|
|
569
|
-
case 2:
|
|
570
|
-
indexes = _context9.sent;
|
|
571
|
-
context.index = context.index || {};
|
|
572
|
-
context.index["private"] = indexes["private"] || context.index["private"];
|
|
573
|
-
context.index["public"] = indexes["public"] || context.index["public"];
|
|
574
|
-
return _context9.abrupt("return", context);
|
|
575
|
-
|
|
576
|
-
case 7:
|
|
577
|
-
case "end":
|
|
578
|
-
return _context9.stop();
|
|
579
|
-
}
|
|
580
|
-
}
|
|
581
|
-
}, _callee9);
|
|
582
|
-
}));
|
|
583
|
-
return _loadTypeIndexes.apply(this, arguments);
|
|
584
|
-
}
|
|
585
|
-
|
|
586
|
-
function ensureTypeIndexes(_x7) {
|
|
587
|
-
return _ensureTypeIndexes.apply(this, arguments);
|
|
588
|
-
}
|
|
589
|
-
/**
|
|
590
|
-
* Load or create ONE type index
|
|
591
|
-
* Find one or make one or fail
|
|
592
|
-
* Many reasons for failing including script not having permission etc
|
|
593
|
-
*
|
|
594
|
-
* Adds its output to the context
|
|
595
|
-
* @see https://github.com/solid/solid/blob/main/proposals/data-discovery.md#discoverability
|
|
596
|
-
*/
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
function _ensureTypeIndexes() {
|
|
600
|
-
_ensureTypeIndexes = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee10(context) {
|
|
601
|
-
return _regenerator["default"].wrap(function _callee10$(_context10) {
|
|
602
|
-
while (1) {
|
|
603
|
-
switch (_context10.prev = _context10.next) {
|
|
604
|
-
case 0:
|
|
605
|
-
_context10.next = 2;
|
|
606
|
-
return ensureOneTypeIndex(context, true);
|
|
607
|
-
|
|
608
|
-
case 2:
|
|
609
|
-
_context10.next = 4;
|
|
610
|
-
return ensureOneTypeIndex(context, false);
|
|
611
|
-
|
|
612
|
-
case 4:
|
|
613
|
-
return _context10.abrupt("return", context);
|
|
614
|
-
|
|
615
|
-
case 5:
|
|
616
|
-
case "end":
|
|
617
|
-
return _context10.stop();
|
|
618
|
-
}
|
|
619
|
-
}
|
|
620
|
-
}, _callee10);
|
|
621
|
-
}));
|
|
622
|
-
return _ensureTypeIndexes.apply(this, arguments);
|
|
623
|
-
}
|
|
624
|
-
|
|
625
|
-
function ensureOneTypeIndex(_x8, _x9) {
|
|
626
|
-
return _ensureOneTypeIndex.apply(this, arguments);
|
|
627
|
-
}
|
|
628
|
-
/**
|
|
629
|
-
* Returns promise of context with arrays of symbols
|
|
630
|
-
*
|
|
631
|
-
* 2016-12-11 change to include forClass arc a la
|
|
632
|
-
* https://github.com/solid/solid/blob/main/proposals/data-discovery.md
|
|
633
|
-
*/
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
function _ensureOneTypeIndex() {
|
|
637
|
-
_ensureOneTypeIndex = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee13(context, isPublic) {
|
|
638
|
-
var makeIndexIfNecessary, _makeIndexIfNecessary;
|
|
639
|
-
|
|
640
|
-
return _regenerator["default"].wrap(function _callee13$(_context13) {
|
|
641
|
-
while (1) {
|
|
642
|
-
switch (_context13.prev = _context13.next) {
|
|
643
|
-
case 0:
|
|
644
|
-
_makeIndexIfNecessary = function _makeIndexIfNecessary3() {
|
|
645
|
-
_makeIndexIfNecessary = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee12(context, isPublic) {
|
|
646
|
-
var relevant, visibility, putIndex, _putIndex, newIndex, addMe, msg, ixs;
|
|
647
|
-
|
|
648
|
-
return _regenerator["default"].wrap(function _callee12$(_context12) {
|
|
649
|
-
while (1) {
|
|
650
|
-
switch (_context12.prev = _context12.next) {
|
|
651
|
-
case 0:
|
|
652
|
-
_putIndex = function _putIndex3() {
|
|
653
|
-
_putIndex = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee11(newIndex) {
|
|
654
|
-
var _msg;
|
|
655
|
-
|
|
656
|
-
return _regenerator["default"].wrap(function _callee11$(_context11) {
|
|
657
|
-
while (1) {
|
|
658
|
-
switch (_context11.prev = _context11.next) {
|
|
659
|
-
case 0:
|
|
660
|
-
_context11.prev = 0;
|
|
661
|
-
_context11.next = 3;
|
|
662
|
-
return _logic.solidLogicSingleton.createEmptyRdfDoc(newIndex, 'Blank initial Type index');
|
|
663
|
-
|
|
664
|
-
case 3:
|
|
665
|
-
return _context11.abrupt("return", context);
|
|
666
|
-
|
|
667
|
-
case 6:
|
|
668
|
-
_context11.prev = 6;
|
|
669
|
-
_context11.t0 = _context11["catch"](0);
|
|
670
|
-
_msg = "Error creating new index ".concat(_context11.t0);
|
|
671
|
-
widgets.complain(context, _msg);
|
|
672
|
-
|
|
673
|
-
case 10:
|
|
674
|
-
case "end":
|
|
675
|
-
return _context11.stop();
|
|
676
|
-
}
|
|
677
|
-
}
|
|
678
|
-
}, _callee11, null, [[0, 6]]);
|
|
679
|
-
}));
|
|
680
|
-
return _putIndex.apply(this, arguments);
|
|
681
|
-
};
|
|
682
|
-
|
|
683
|
-
putIndex = function _putIndex2(_x25) {
|
|
684
|
-
return _putIndex.apply(this, arguments);
|
|
685
|
-
};
|
|
686
|
-
|
|
687
|
-
relevant = isPublic ? context.publicProfile : context.preferencesFile;
|
|
688
|
-
visibility = isPublic ? 'public' : 'private';
|
|
689
|
-
// putIndex
|
|
690
|
-
context.index = context.index || {};
|
|
691
|
-
context.index[visibility] = context.index[visibility] || [];
|
|
692
|
-
|
|
693
|
-
if (!(context.index[visibility].length === 0)) {
|
|
694
|
-
_context12.next = 29;
|
|
695
|
-
break;
|
|
696
|
-
}
|
|
697
|
-
|
|
698
|
-
newIndex = (0, _rdflib.sym)("".concat(relevant.dir().uri + visibility, "TypeIndex.ttl"));
|
|
699
|
-
debug.log("Linking to new fresh type index ".concat(newIndex));
|
|
700
|
-
|
|
701
|
-
if (confirm("OK to create a new empty index file at ".concat(newIndex, ", overwriting anything that is now there?"))) {
|
|
702
|
-
_context12.next = 11;
|
|
703
|
-
break;
|
|
704
|
-
}
|
|
705
|
-
|
|
706
|
-
throw new Error('cancelled by user');
|
|
707
|
-
|
|
708
|
-
case 11:
|
|
709
|
-
debug.log("Linking to new fresh type index ".concat(newIndex));
|
|
710
|
-
addMe = [(0, _rdflib.st)(context.me, ns.solid("".concat(visibility, "TypeIndex")), newIndex, relevant)];
|
|
711
|
-
_context12.prev = 13;
|
|
712
|
-
_context12.next = 16;
|
|
713
|
-
return _logic.solidLogicSingleton.updatePromise([], addMe);
|
|
714
|
-
|
|
715
|
-
case 16:
|
|
716
|
-
_context12.next = 23;
|
|
717
|
-
break;
|
|
718
|
-
|
|
719
|
-
case 18:
|
|
720
|
-
_context12.prev = 18;
|
|
721
|
-
_context12.t0 = _context12["catch"](13);
|
|
722
|
-
msg = "Error saving type index link saving back ".concat(newIndex, ": ").concat(_context12.t0);
|
|
723
|
-
widgets.complain(context, msg);
|
|
724
|
-
return _context12.abrupt("return", context);
|
|
725
|
-
|
|
726
|
-
case 23:
|
|
727
|
-
debug.log("Creating new fresh type index file".concat(newIndex));
|
|
728
|
-
_context12.next = 26;
|
|
729
|
-
return putIndex(newIndex);
|
|
730
|
-
|
|
731
|
-
case 26:
|
|
732
|
-
context.index[visibility].push(newIndex); // @@ wait
|
|
733
|
-
|
|
734
|
-
_context12.next = 38;
|
|
735
|
-
break;
|
|
736
|
-
|
|
737
|
-
case 29:
|
|
738
|
-
// officially exists
|
|
739
|
-
ixs = context.index[visibility];
|
|
740
|
-
_context12.prev = 30;
|
|
741
|
-
_context12.next = 33;
|
|
742
|
-
return _logic.solidLogicSingleton.load(ixs);
|
|
743
|
-
|
|
744
|
-
case 33:
|
|
745
|
-
_context12.next = 38;
|
|
746
|
-
break;
|
|
747
|
-
|
|
748
|
-
case 35:
|
|
749
|
-
_context12.prev = 35;
|
|
750
|
-
_context12.t1 = _context12["catch"](30);
|
|
751
|
-
widgets.complain(context, "ensureOneTypeIndex: loading indexes ".concat(_context12.t1));
|
|
752
|
-
|
|
753
|
-
case 38:
|
|
754
|
-
case "end":
|
|
755
|
-
return _context12.stop();
|
|
756
|
-
}
|
|
757
|
-
}
|
|
758
|
-
}, _callee12, null, [[13, 18], [30, 35]]);
|
|
759
|
-
}));
|
|
760
|
-
return _makeIndexIfNecessary.apply(this, arguments);
|
|
761
|
-
};
|
|
762
|
-
|
|
763
|
-
makeIndexIfNecessary = function _makeIndexIfNecessary2(_x23, _x24) {
|
|
764
|
-
return _makeIndexIfNecessary.apply(this, arguments);
|
|
765
|
-
};
|
|
766
|
-
|
|
767
|
-
_context13.prev = 2;
|
|
768
|
-
_context13.next = 5;
|
|
769
|
-
return loadIndex(context, isPublic);
|
|
770
|
-
|
|
771
|
-
case 5:
|
|
772
|
-
if (context.index) {
|
|
773
|
-
debug.log("ensureOneTypeIndex: Type index exists already ".concat(isPublic ? context.index["public"][0] : context.index["private"][0]));
|
|
774
|
-
}
|
|
775
|
-
|
|
776
|
-
return _context13.abrupt("return", context);
|
|
777
|
-
|
|
778
|
-
case 9:
|
|
779
|
-
_context13.prev = 9;
|
|
780
|
-
_context13.t0 = _context13["catch"](2);
|
|
781
|
-
_context13.next = 13;
|
|
782
|
-
return makeIndexIfNecessary(context, isPublic);
|
|
783
|
-
|
|
784
|
-
case 13:
|
|
785
|
-
case "end":
|
|
786
|
-
return _context13.stop();
|
|
787
|
-
}
|
|
788
|
-
}
|
|
789
|
-
}, _callee13, null, [[2, 9]]);
|
|
790
|
-
}));
|
|
791
|
-
return _ensureOneTypeIndex.apply(this, arguments);
|
|
792
|
-
}
|
|
793
|
-
|
|
794
|
-
function findAppInstances(_x10, _x11, _x12) {
|
|
795
|
-
return _findAppInstances.apply(this, arguments);
|
|
796
|
-
}
|
|
797
|
-
/**
|
|
798
|
-
* Register a new app in a type index
|
|
799
|
-
*/
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
function _findAppInstances() {
|
|
803
|
-
_findAppInstances = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee14(context, theClass, isPublic) {
|
|
804
|
-
var visibility, index, thisIndex, registrations, instances, containers, unique, e, i, cont;
|
|
805
|
-
return _regenerator["default"].wrap(function _callee14$(_context14) {
|
|
806
|
-
while (1) {
|
|
807
|
-
switch (_context14.prev = _context14.next) {
|
|
808
|
-
case 0:
|
|
809
|
-
unique = function _unique(arr) {
|
|
810
|
-
return Array.from(new Set(arr));
|
|
811
|
-
};
|
|
812
|
-
|
|
813
|
-
if (!(isPublic === undefined)) {
|
|
814
|
-
_context14.next = 7;
|
|
815
|
-
break;
|
|
816
|
-
}
|
|
817
|
-
|
|
818
|
-
_context14.next = 4;
|
|
819
|
-
return findAppInstances(context, theClass, true);
|
|
820
|
-
|
|
821
|
-
case 4:
|
|
822
|
-
_context14.next = 6;
|
|
823
|
-
return findAppInstances(context, theClass, false);
|
|
824
|
-
|
|
825
|
-
case 6:
|
|
826
|
-
return _context14.abrupt("return", context);
|
|
827
|
-
|
|
828
|
-
case 7:
|
|
829
|
-
_context14.prev = 7;
|
|
830
|
-
_context14.next = 10;
|
|
831
|
-
return isPublic ? logInLoadProfile(context) : logInLoadPreferences(context);
|
|
832
|
-
|
|
833
|
-
case 10:
|
|
834
|
-
_context14.next = 15;
|
|
835
|
-
break;
|
|
836
|
-
|
|
837
|
-
case 12:
|
|
838
|
-
_context14.prev = 12;
|
|
839
|
-
_context14.t0 = _context14["catch"](7);
|
|
840
|
-
widgets.complain(context, "loadIndex: login and load problem ".concat(_context14.t0));
|
|
841
|
-
|
|
842
|
-
case 15:
|
|
843
|
-
// console.log('awaited LogInLoad!', context)
|
|
844
|
-
visibility = isPublic ? 'public' : 'private';
|
|
845
|
-
_context14.prev = 16;
|
|
846
|
-
_context14.next = 19;
|
|
847
|
-
return loadIndex(context, isPublic);
|
|
848
|
-
|
|
849
|
-
case 19:
|
|
850
|
-
_context14.next = 23;
|
|
851
|
-
break;
|
|
852
|
-
|
|
853
|
-
case 21:
|
|
854
|
-
_context14.prev = 21;
|
|
855
|
-
_context14.t1 = _context14["catch"](16);
|
|
856
|
-
|
|
857
|
-
case 23:
|
|
858
|
-
index = context.index;
|
|
859
|
-
thisIndex = index[visibility];
|
|
860
|
-
registrations = thisIndex.map(function (ix) {
|
|
861
|
-
return _logic.solidLogicSingleton.store.each(undefined, ns.solid('forClass'), theClass, ix);
|
|
862
|
-
}).reduce(function (acc, curr) {
|
|
863
|
-
return acc.concat(curr);
|
|
864
|
-
}, []);
|
|
865
|
-
instances = registrations.map(function (reg) {
|
|
866
|
-
return _logic.solidLogicSingleton.store.each(reg, ns.solid('instance'));
|
|
867
|
-
}).reduce(function (acc, curr) {
|
|
868
|
-
return acc.concat(curr);
|
|
869
|
-
}, []);
|
|
870
|
-
containers = registrations.map(function (reg) {
|
|
871
|
-
return _logic.solidLogicSingleton.store.each(reg, ns.solid('instanceContainer'));
|
|
872
|
-
}).reduce(function (acc, curr) {
|
|
873
|
-
return acc.concat(curr);
|
|
874
|
-
}, []);
|
|
875
|
-
context.instances = context.instances || [];
|
|
876
|
-
context.instances = unique(context.instances.concat(instances));
|
|
877
|
-
context.containers = context.containers || [];
|
|
878
|
-
context.containers = unique(context.containers.concat(containers));
|
|
879
|
-
|
|
880
|
-
if (containers.length) {
|
|
881
|
-
_context14.next = 34;
|
|
882
|
-
break;
|
|
883
|
-
}
|
|
884
|
-
|
|
885
|
-
return _context14.abrupt("return", context);
|
|
886
|
-
|
|
887
|
-
case 34:
|
|
888
|
-
_context14.prev = 34;
|
|
889
|
-
_context14.next = 37;
|
|
890
|
-
return _logic.solidLogicSingleton.load(containers);
|
|
891
|
-
|
|
892
|
-
case 37:
|
|
893
|
-
_context14.next = 44;
|
|
894
|
-
break;
|
|
895
|
-
|
|
896
|
-
case 39:
|
|
897
|
-
_context14.prev = 39;
|
|
898
|
-
_context14.t2 = _context14["catch"](34);
|
|
899
|
-
e = new Error("[FAI] Unable to load containers".concat(_context14.t2));
|
|
900
|
-
debug.log(e); // complain
|
|
901
|
-
|
|
902
|
-
widgets.complain(context, "Error looking for ".concat(utils.label(theClass), ": ").concat(_context14.t2)); // but then ignore it
|
|
903
|
-
// throw new Error(e)
|
|
904
|
-
|
|
905
|
-
case 44:
|
|
906
|
-
i = 0;
|
|
907
|
-
|
|
908
|
-
case 45:
|
|
909
|
-
if (!(i < containers.length)) {
|
|
910
|
-
_context14.next = 55;
|
|
911
|
-
break;
|
|
912
|
-
}
|
|
913
|
-
|
|
914
|
-
cont = containers[i];
|
|
915
|
-
_context14.t3 = context.instances;
|
|
916
|
-
_context14.next = 50;
|
|
917
|
-
return _logic.solidLogicSingleton.getContainerMembers(cont.value);
|
|
918
|
-
|
|
919
|
-
case 50:
|
|
920
|
-
_context14.t4 = _context14.sent.map(function (uri) {
|
|
921
|
-
return _logic.solidLogicSingleton.store.sym(uri);
|
|
922
|
-
});
|
|
923
|
-
context.instances = _context14.t3.concat.call(_context14.t3, _context14.t4);
|
|
924
|
-
|
|
925
|
-
case 52:
|
|
926
|
-
i++;
|
|
927
|
-
_context14.next = 45;
|
|
928
|
-
break;
|
|
929
|
-
|
|
930
|
-
case 55:
|
|
931
|
-
return _context14.abrupt("return", context);
|
|
932
|
-
|
|
933
|
-
case 56:
|
|
934
|
-
case "end":
|
|
935
|
-
return _context14.stop();
|
|
936
|
-
}
|
|
937
|
-
}
|
|
938
|
-
}, _callee14, null, [[7, 12], [16, 21], [34, 39]]);
|
|
939
|
-
}));
|
|
940
|
-
return _findAppInstances.apply(this, arguments);
|
|
941
|
-
}
|
|
942
|
-
|
|
943
|
-
function registerInTypeIndex(_x13, _x14, _x15, _x16) {
|
|
944
|
-
return _registerInTypeIndex.apply(this, arguments);
|
|
945
|
-
}
|
|
946
|
-
/**
|
|
947
|
-
* UI to control registration of instance
|
|
948
|
-
*/
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
function _registerInTypeIndex() {
|
|
952
|
-
_registerInTypeIndex = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee15(context, instance, theClass, isPublic) {
|
|
953
|
-
var indexes, index, registration, ins;
|
|
954
|
-
return _regenerator["default"].wrap(function _callee15$(_context15) {
|
|
955
|
-
while (1) {
|
|
956
|
-
switch (_context15.prev = _context15.next) {
|
|
957
|
-
case 0:
|
|
958
|
-
_context15.next = 2;
|
|
959
|
-
return ensureOneTypeIndex(context, isPublic);
|
|
960
|
-
|
|
961
|
-
case 2:
|
|
962
|
-
if (context.index) {
|
|
963
|
-
_context15.next = 4;
|
|
964
|
-
break;
|
|
965
|
-
}
|
|
966
|
-
|
|
967
|
-
throw new Error('registerInTypeIndex: No type index found');
|
|
968
|
-
|
|
969
|
-
case 4:
|
|
970
|
-
indexes = isPublic ? context.index["public"] : context.index["private"];
|
|
971
|
-
|
|
972
|
-
if (indexes.length) {
|
|
973
|
-
_context15.next = 7;
|
|
974
|
-
break;
|
|
975
|
-
}
|
|
976
|
-
|
|
977
|
-
throw new Error('registerInTypeIndex: What no type index?');
|
|
978
|
-
|
|
979
|
-
case 7:
|
|
980
|
-
index = indexes[0];
|
|
981
|
-
registration = widgets.newThing(index);
|
|
982
|
-
ins = [// See https://github.com/solid/solid/blob/main/proposals/data-discovery.md
|
|
983
|
-
(0, _rdflib.st)(registration, ns.rdf('type'), ns.solid('TypeRegistration'), index), (0, _rdflib.st)(registration, ns.solid('forClass'), theClass, index), (0, _rdflib.st)(registration, ns.solid('instance'), instance, index)];
|
|
984
|
-
_context15.prev = 10;
|
|
985
|
-
_context15.next = 13;
|
|
986
|
-
return _logic.solidLogicSingleton.updatePromise([], ins);
|
|
987
|
-
|
|
988
|
-
case 13:
|
|
989
|
-
_context15.next = 19;
|
|
990
|
-
break;
|
|
991
|
-
|
|
992
|
-
case 15:
|
|
993
|
-
_context15.prev = 15;
|
|
994
|
-
_context15.t0 = _context15["catch"](10);
|
|
995
|
-
debug.log(_context15.t0);
|
|
996
|
-
(0, _log.alert)(_context15.t0);
|
|
997
|
-
|
|
998
|
-
case 19:
|
|
999
|
-
return _context15.abrupt("return", context);
|
|
1000
|
-
|
|
1001
|
-
case 20:
|
|
1002
|
-
case "end":
|
|
1003
|
-
return _context15.stop();
|
|
1004
|
-
}
|
|
1005
|
-
}
|
|
1006
|
-
}, _callee15, null, [[10, 15]]);
|
|
1007
|
-
}));
|
|
1008
|
-
return _registerInTypeIndex.apply(this, arguments);
|
|
1009
|
-
}
|
|
1010
|
-
|
|
1011
|
-
function registrationControl(context, instance, theClass) {
|
|
1012
|
-
var dom = context.dom;
|
|
1013
|
-
|
|
1014
|
-
if (!dom || !context.div) {
|
|
1015
|
-
return Promise.resolve();
|
|
1016
|
-
}
|
|
1017
|
-
|
|
1018
|
-
var box = dom.createElement('div');
|
|
1019
|
-
context.div.appendChild(box);
|
|
1020
|
-
return ensureTypeIndexes(context).then(function () {
|
|
1021
|
-
box.innerHTML = '<table><tbody><tr></tr><tr></tr></tbody></table>'; // tbody will be inserted anyway
|
|
1022
|
-
|
|
1023
|
-
box.setAttribute('style', 'font-size: 120%; text-align: right; padding: 1em; border: solid gray 0.05em;');
|
|
1024
|
-
var tbody = box.children[0].children[0];
|
|
1025
|
-
var form = new _rdflib.BlankNode(); // @@ say for now
|
|
1026
|
-
|
|
1027
|
-
var registrationStatements = function registrationStatements(index) {
|
|
1028
|
-
var registrations = _logic.solidLogicSingleton.getRegistrations(instance, theClass);
|
|
1029
|
-
|
|
1030
|
-
var reg = registrations.length ? registrations[0] : widgets.newThing(index);
|
|
1031
|
-
return [(0, _rdflib.st)(reg, ns.solid('instance'), instance, index), (0, _rdflib.st)(reg, ns.solid('forClass'), theClass, index)];
|
|
1032
|
-
};
|
|
1033
|
-
|
|
1034
|
-
var index, statements;
|
|
1035
|
-
|
|
1036
|
-
if (context.index && context.index["public"] && context.index["public"].length > 0) {
|
|
1037
|
-
index = context.index["public"][0];
|
|
1038
|
-
statements = registrationStatements(index);
|
|
1039
|
-
tbody.children[0].appendChild(widgets.buildCheckBoxForm(context.dom, _logic.solidLogicSingleton.store, "Public link to this ".concat(context.noun), null, statements, form, index));
|
|
1040
|
-
}
|
|
1041
|
-
|
|
1042
|
-
if (context.index && context.index["private"] && context.index["private"].length > 0) {
|
|
1043
|
-
index = context.index["private"][0];
|
|
1044
|
-
statements = registrationStatements(index);
|
|
1045
|
-
tbody.children[1].appendChild(widgets.buildCheckBoxForm(context.dom, _logic.solidLogicSingleton.store, "Personal note of this ".concat(context.noun), null, statements, form, index));
|
|
1046
|
-
}
|
|
1047
|
-
|
|
1048
|
-
return context;
|
|
1049
|
-
}, function (e) {
|
|
1050
|
-
var msg;
|
|
1051
|
-
|
|
1052
|
-
if (context.div && context.preferencesFileError) {
|
|
1053
|
-
msg = '(Preferences not available)';
|
|
1054
|
-
context.div.appendChild(dom.createElement('p')).textContent = msg;
|
|
1055
|
-
} else if (context.div) {
|
|
1056
|
-
msg = "registrationControl: Type indexes not available: ".concat(e);
|
|
1057
|
-
context.div.appendChild(widgets.errorMessageBlock(context.dom, e));
|
|
1058
|
-
}
|
|
1059
|
-
|
|
1060
|
-
debug.log(msg);
|
|
1061
|
-
})["catch"](function (e) {
|
|
1062
|
-
var msg = "registrationControl: Error making panel: ".concat(e);
|
|
1063
|
-
|
|
1064
|
-
if (context.div) {
|
|
1065
|
-
context.div.appendChild(widgets.errorMessageBlock(context.dom, e));
|
|
1066
|
-
}
|
|
1067
|
-
|
|
1068
|
-
debug.log(msg);
|
|
1069
|
-
});
|
|
1070
|
-
}
|
|
1071
|
-
/**
|
|
1072
|
-
* UI to List at all registered things
|
|
1073
|
-
*/
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
function registrationList(context, options) {
|
|
1077
|
-
var dom = context.dom;
|
|
1078
|
-
var div = context.div;
|
|
1079
|
-
var box = dom.createElement('div');
|
|
1080
|
-
div.appendChild(box);
|
|
1081
|
-
return ensureTypeIndexes(context).then(function (_indexes) {
|
|
1082
|
-
box.innerHTML = '<table><tbody></tbody></table>'; // tbody will be inserted anyway
|
|
1083
|
-
|
|
1084
|
-
box.setAttribute('style', 'font-size: 120%; text-align: right; padding: 1em; border: solid #eee 0.5em;');
|
|
1085
|
-
var table = box.firstChild;
|
|
1086
|
-
var ix = [];
|
|
1087
|
-
var sts = [];
|
|
1088
|
-
var vs = ['private', 'public'];
|
|
1089
|
-
vs.forEach(function (visibility) {
|
|
1090
|
-
if (context.index && options[visibility]) {
|
|
1091
|
-
ix = ix.concat(context.index[visibility][0]);
|
|
1092
|
-
sts = sts.concat(_logic.solidLogicSingleton.store.statementsMatching(undefined, ns.solid('instance'), undefined, context.index[visibility][0]));
|
|
1093
|
-
}
|
|
1094
|
-
});
|
|
1095
|
-
|
|
1096
|
-
var _loop = function _loop(i) {
|
|
1097
|
-
var statement = sts[i];
|
|
1098
|
-
|
|
1099
|
-
if (options.type) {
|
|
1100
|
-
// now check terms:forClass
|
|
1101
|
-
if (!_logic.solidLogicSingleton.store.holds(statement.subject, ns.solid('forClass'), options.type, statement.why)) {
|
|
1102
|
-
return "continue"; // skip irrelevant ones
|
|
1103
|
-
}
|
|
1104
|
-
} // const cla = statement.subject
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
var inst = statement.object;
|
|
1108
|
-
table.appendChild(widgets.personTR(dom, ns.solid('instance'), inst, {
|
|
1109
|
-
deleteFunction: function deleteFunction(_x) {
|
|
1110
|
-
if (!_logic.solidLogicSingleton.store.updater) {
|
|
1111
|
-
throw new Error('Cannot delete this, store has no updater');
|
|
1112
|
-
}
|
|
1113
|
-
|
|
1114
|
-
_logic.solidLogicSingleton.store.updater.update([statement], [], function (uri, ok, errorBody) {
|
|
1115
|
-
if (ok) {
|
|
1116
|
-
debug.log("Removed from index: ".concat(statement.subject));
|
|
1117
|
-
} else {
|
|
1118
|
-
debug.log("Error: Cannot delete ".concat(statement, ": ").concat(errorBody));
|
|
1119
|
-
}
|
|
1120
|
-
});
|
|
1121
|
-
}
|
|
1122
|
-
}));
|
|
1123
|
-
};
|
|
1124
|
-
|
|
1125
|
-
for (var i = 0; i < sts.length; i++) {
|
|
1126
|
-
var _ret = _loop(i);
|
|
1127
|
-
|
|
1128
|
-
if (_ret === "continue") continue;
|
|
1129
|
-
} // registrationList
|
|
1130
|
-
|
|
1131
|
-
/*
|
|
1132
|
-
//const containers = solidLogicSingleton.store.each(theClass, ns.solid('instanceContainer'));
|
|
1133
|
-
if (containers.length) {
|
|
1134
|
-
fetcher.load(containers).then(function(xhrs){
|
|
1135
|
-
for (const i=0; i<containers.length; i++) {
|
|
1136
|
-
const cont = containers[i];
|
|
1137
|
-
instances = instances.concat(solidLogicSingleton.store.each(cont, ns.ldp('contains')));
|
|
1138
|
-
}
|
|
1139
|
-
});
|
|
1140
|
-
}
|
|
1141
|
-
*/
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
return context;
|
|
1145
|
-
});
|
|
1146
|
-
}
|
|
1147
|
-
/**
|
|
1148
|
-
* Simple Access Control
|
|
1149
|
-
*
|
|
1150
|
-
* This function sets up a simple default ACL for a resource, with
|
|
1151
|
-
* RWC for the owner, and a specified access (default none) for the public.
|
|
1152
|
-
* In all cases owner has read write control.
|
|
1153
|
-
* Parameter lists modes allowed to public
|
|
1154
|
-
*
|
|
1155
|
-
* @param options
|
|
1156
|
-
* @param options.public eg ['Read', 'Write']
|
|
1157
|
-
*
|
|
1158
|
-
* @returns Resolves with aclDoc uri on successful write
|
|
1159
|
-
*/
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
function setACLUserPublic(docURI, me, options) {
|
|
1163
|
-
var aclDoc = _logic.solidLogicSingleton.store.any(_logic.solidLogicSingleton.store.sym(docURI), _solidLogic.ACL_LINK);
|
|
1164
|
-
|
|
1165
|
-
return Promise.resolve().then(function () {
|
|
1166
|
-
if (aclDoc) {
|
|
1167
|
-
return aclDoc;
|
|
1168
|
-
}
|
|
1169
|
-
|
|
1170
|
-
return fetchACLRel(docURI)["catch"](function (err) {
|
|
1171
|
-
throw new Error("Error fetching rel=ACL header for ".concat(docURI, ": ").concat(err));
|
|
1172
|
-
});
|
|
1173
|
-
}).then(function (aclDoc) {
|
|
1174
|
-
var aclText = genACLText(docURI, me, aclDoc.uri, options);
|
|
1175
|
-
|
|
1176
|
-
if (!_logic.solidLogicSingleton.store.fetcher) {
|
|
1177
|
-
throw new Error('Cannot PUT this, store has no fetcher');
|
|
1178
|
-
}
|
|
1179
|
-
|
|
1180
|
-
return _logic.solidLogicSingleton.store.fetcher.webOperation('PUT', aclDoc.uri, {
|
|
1181
|
-
data: aclText,
|
|
1182
|
-
contentType: 'text/turtle'
|
|
1183
|
-
}).then(function (result) {
|
|
1184
|
-
if (!result.ok) {
|
|
1185
|
-
throw new Error('Error writing ACL text: ' + result.error);
|
|
1186
|
-
}
|
|
1187
|
-
|
|
1188
|
-
return aclDoc;
|
|
1189
|
-
});
|
|
1190
|
-
});
|
|
1191
|
-
}
|
|
1192
|
-
/**
|
|
1193
|
-
* @param docURI
|
|
1194
|
-
* @returns
|
|
1195
|
-
*/
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
function fetchACLRel(docURI) {
|
|
1199
|
-
var fetcher = _logic.solidLogicSingleton.store.fetcher;
|
|
1200
|
-
|
|
1201
|
-
if (!fetcher) {
|
|
1202
|
-
throw new Error('Cannot fetch ACL rel, store has no fetcher');
|
|
1203
|
-
}
|
|
1204
|
-
|
|
1205
|
-
return fetcher.load(docURI).then(function (result) {
|
|
1206
|
-
if (!result.ok) {
|
|
1207
|
-
throw new Error('fetchACLRel: While loading:' + result.error);
|
|
1208
|
-
}
|
|
1209
|
-
|
|
1210
|
-
var aclDoc = _logic.solidLogicSingleton.store.any(_logic.solidLogicSingleton.store.sym(docURI), _solidLogic.ACL_LINK);
|
|
1211
|
-
|
|
1212
|
-
if (!aclDoc) {
|
|
1213
|
-
throw new Error('fetchACLRel: No Link rel=ACL header for ' + docURI);
|
|
1214
|
-
}
|
|
1215
|
-
|
|
1216
|
-
return aclDoc;
|
|
1217
|
-
});
|
|
1218
|
-
}
|
|
1219
|
-
/**
|
|
1220
|
-
* @param docURI
|
|
1221
|
-
* @param me
|
|
1222
|
-
* @param aclURI
|
|
1223
|
-
* @param options
|
|
1224
|
-
*
|
|
1225
|
-
* @returns Serialized ACL
|
|
1226
|
-
*/
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
function genACLText(docURI, me, aclURI) {
|
|
1230
|
-
var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
1231
|
-
var optPublic = options["public"] || [];
|
|
1232
|
-
var g = (0, _rdflib.graph)();
|
|
1233
|
-
var auth = (0, _rdflib.Namespace)('http://www.w3.org/ns/auth/acl#');
|
|
1234
|
-
var a = g.sym("".concat(aclURI, "#a1"));
|
|
1235
|
-
var acl = g.sym(aclURI);
|
|
1236
|
-
var doc = g.sym(docURI);
|
|
1237
|
-
g.add(a, ns.rdf('type'), auth('Authorization'), acl);
|
|
1238
|
-
g.add(a, auth('accessTo'), doc, acl);
|
|
1239
|
-
|
|
1240
|
-
if (options.defaultForNew) {
|
|
1241
|
-
g.add(a, auth('default'), doc, acl);
|
|
1242
|
-
}
|
|
1243
|
-
|
|
1244
|
-
g.add(a, auth('agent'), me, acl);
|
|
1245
|
-
g.add(a, auth('mode'), auth('Read'), acl);
|
|
1246
|
-
g.add(a, auth('mode'), auth('Write'), acl);
|
|
1247
|
-
g.add(a, auth('mode'), auth('Control'), acl);
|
|
1248
|
-
|
|
1249
|
-
if (optPublic.length) {
|
|
1250
|
-
a = g.sym("".concat(aclURI, "#a2"));
|
|
1251
|
-
g.add(a, ns.rdf('type'), auth('Authorization'), acl);
|
|
1252
|
-
g.add(a, auth('accessTo'), doc, acl);
|
|
1253
|
-
g.add(a, auth('agentClass'), ns.foaf('Agent'), acl);
|
|
1254
|
-
|
|
1255
|
-
for (var p = 0; p < optPublic.length; p++) {
|
|
1256
|
-
g.add(a, auth('mode'), auth(optPublic[p]), acl); // Like 'Read' etc
|
|
1257
|
-
}
|
|
1258
|
-
}
|
|
1259
|
-
|
|
1260
|
-
return (0, _rdflib.serialize)(acl, g, aclURI);
|
|
1261
|
-
}
|
|
1262
|
-
/**
|
|
1263
|
-
* Returns `sym($SolidTestEnvironment.username)` if
|
|
1264
|
-
* `$SolidTestEnvironment.username` is defined as a global
|
|
1265
|
-
* @returns {NamedNode|null}
|
|
1266
|
-
*/
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
function offlineTestID() {
|
|
1270
|
-
var _window2 = window,
|
|
1271
|
-
$SolidTestEnvironment = _window2.$SolidTestEnvironment;
|
|
1272
|
-
|
|
1273
|
-
if (typeof $SolidTestEnvironment !== 'undefined' && $SolidTestEnvironment.username) {
|
|
1274
|
-
// Test setup
|
|
1275
|
-
debug.log('Assuming the user is ' + $SolidTestEnvironment.username);
|
|
1276
|
-
return (0, _rdflib.sym)($SolidTestEnvironment.username);
|
|
1277
|
-
}
|
|
1278
|
-
|
|
1279
|
-
if (typeof document !== 'undefined' && document.location && ('' + document.location).slice(0, 16) === 'http://localhost') {
|
|
1280
|
-
var div = document.getElementById('appTarget');
|
|
1281
|
-
if (!div) return null;
|
|
1282
|
-
var id = div.getAttribute('testID');
|
|
1283
|
-
if (!id) return null;
|
|
1284
|
-
/* me = solidLogicSingleton.store.any(subject, ns.acl('owner')); // when testing on plane with no WebID
|
|
1285
|
-
*/
|
|
1286
|
-
|
|
1287
|
-
debug.log('Assuming user is ' + id);
|
|
1288
|
-
return (0, _rdflib.sym)(id);
|
|
1289
|
-
}
|
|
1290
|
-
|
|
1291
|
-
return null;
|
|
1292
|
-
}
|
|
1293
|
-
|
|
1294
|
-
function getDefaultSignInButtonStyle() {
|
|
1295
|
-
return 'padding: 1em; border-radius:0.5em; font-size: 100%;';
|
|
1296
|
-
}
|
|
1297
|
-
/**
|
|
1298
|
-
* Bootstrapping identity
|
|
1299
|
-
* (Called by `loginStatusBox()`)
|
|
1300
|
-
*
|
|
1301
|
-
* @param dom
|
|
1302
|
-
* @param setUserCallback
|
|
1303
|
-
*
|
|
1304
|
-
* @returns
|
|
1305
|
-
*/
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
function signInOrSignUpBox(dom, setUserCallback) {
|
|
1309
|
-
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
1310
|
-
options = options || {};
|
|
1311
|
-
var signInButtonStyle = options.buttonStyle || getDefaultSignInButtonStyle(); // @@ TODO Remove the need to cast HTML element to any
|
|
1312
|
-
|
|
1313
|
-
var box = dom.createElement('div');
|
|
1314
|
-
var magicClassName = 'SolidSignInOrSignUpBox';
|
|
1315
|
-
debug.log('widgets.signInOrSignUpBox');
|
|
1316
|
-
box.setUserCallback = setUserCallback;
|
|
1317
|
-
box.setAttribute('class', magicClassName);
|
|
1318
|
-
box.style = 'display:flex;'; // @@ fix all typecasts like this
|
|
1319
|
-
// Sign in button with PopUP
|
|
1320
|
-
|
|
1321
|
-
var signInPopUpButton = dom.createElement('input'); // multi
|
|
1322
|
-
|
|
1323
|
-
box.appendChild(signInPopUpButton);
|
|
1324
|
-
signInPopUpButton.setAttribute('type', 'button');
|
|
1325
|
-
signInPopUpButton.setAttribute('value', 'Log in');
|
|
1326
|
-
signInPopUpButton.setAttribute('style', "".concat(signInButtonStyle, "background-color: #eef;"));
|
|
1327
|
-
authSession.onLogin(function () {
|
|
1328
|
-
var sessionInfo = authSession.info;
|
|
1329
|
-
|
|
1330
|
-
if (sessionInfo && sessionInfo.isLoggedIn) {
|
|
1331
|
-
var webIdURI = sessionInfo.webId; // setUserCallback(webIdURI)
|
|
1332
|
-
|
|
1333
|
-
var divs = dom.getElementsByClassName(magicClassName);
|
|
1334
|
-
debug.log("Logged in, ".concat(divs.length, " panels to be serviced")); // At the same time, satisfy all the other login boxes
|
|
1335
|
-
|
|
1336
|
-
for (var i = 0; i < divs.length; i++) {
|
|
1337
|
-
var div = divs[i]; // @@ TODO Remove the need to manipulate HTML elements
|
|
1338
|
-
|
|
1339
|
-
if (div.setUserCallback) {
|
|
1340
|
-
try {
|
|
1341
|
-
div.setUserCallback(webIdURI);
|
|
1342
|
-
var parent = div.parentNode;
|
|
1343
|
-
|
|
1344
|
-
if (parent) {
|
|
1345
|
-
parent.removeChild(div);
|
|
1346
|
-
}
|
|
1347
|
-
} catch (e) {
|
|
1348
|
-
debug.log("## Error satisfying login box: ".concat(e));
|
|
1349
|
-
div.appendChild(widgets.errorMessageBlock(dom, e));
|
|
1350
|
-
}
|
|
1351
|
-
}
|
|
1352
|
-
}
|
|
1353
|
-
}
|
|
1354
|
-
});
|
|
1355
|
-
signInPopUpButton.addEventListener('click', function () {
|
|
1356
|
-
var offline = offlineTestID();
|
|
1357
|
-
if (offline) return setUserCallback(offline.uri);
|
|
1358
|
-
renderSignInPopup(dom);
|
|
1359
|
-
}, false); // Sign up button
|
|
1360
|
-
|
|
1361
|
-
var signupButton = dom.createElement('input');
|
|
1362
|
-
box.appendChild(signupButton);
|
|
1363
|
-
signupButton.setAttribute('type', 'button');
|
|
1364
|
-
signupButton.setAttribute('value', 'Sign Up for Solid');
|
|
1365
|
-
signupButton.setAttribute('style', "".concat(signInButtonStyle, "background-color: #efe;"));
|
|
1366
|
-
signupButton.addEventListener('click', function (_event) {
|
|
1367
|
-
var signupMgr = new _signup.Signup();
|
|
1368
|
-
signupMgr.signup().then(function (uri) {
|
|
1369
|
-
debug.log('signInOrSignUpBox signed up ' + uri);
|
|
1370
|
-
setUserCallback(uri);
|
|
1371
|
-
});
|
|
1372
|
-
}, false);
|
|
1373
|
-
return box;
|
|
1374
|
-
}
|
|
1375
|
-
|
|
1376
|
-
function renderSignInPopup(dom) {
|
|
1377
|
-
/**
|
|
1378
|
-
* Issuer Menu
|
|
1379
|
-
*/
|
|
1380
|
-
var issuerPopup = dom.createElement('div');
|
|
1381
|
-
issuerPopup.setAttribute('style', 'position: fixed; top: 0; left: 0; right: 0; bottom: 0; display: flex; justify-content: center; align-items: center;');
|
|
1382
|
-
dom.body.appendChild(issuerPopup);
|
|
1383
|
-
var issuerPopupBox = dom.createElement('div');
|
|
1384
|
-
issuerPopupBox.setAttribute('style', "\n background-color: white;\n box-shadow: 0px 1px 4px rgba(0, 0, 0, 0.2);\n -webkit-box-shadow: 0px 1px 4px rgba(0, 0, 0, 0.2);\n -moz-box-shadow: 0px 1px 4px rgba(0, 0, 0, 0.2);\n -o-box-shadow: 0px 1px 4px rgba(0, 0, 0, 0.2);\n border-radius: 4px;\n min-width: 400px;\n padding: 10px;\n ");
|
|
1385
|
-
issuerPopup.appendChild(issuerPopupBox);
|
|
1386
|
-
var issuerPopupBoxTopMenu = dom.createElement('div');
|
|
1387
|
-
issuerPopupBoxTopMenu.setAttribute('style', "\n border-bottom: 1px solid #DDD;\n display: flex;\n flex-direction: row;\n align-items: center;\n justify-content: space-between;\n ");
|
|
1388
|
-
issuerPopupBox.appendChild(issuerPopupBoxTopMenu);
|
|
1389
|
-
var issuerPopupBoxLabel = dom.createElement('label');
|
|
1390
|
-
issuerPopupBoxLabel.setAttribute('style', 'margin-right: 5px; font-weight: 800');
|
|
1391
|
-
issuerPopupBoxLabel.innerText = 'Select an identity provider';
|
|
1392
|
-
var issuerPopupBoxCloseButton = dom.createElement('button');
|
|
1393
|
-
issuerPopupBoxCloseButton.innerHTML = '<img src="https://solid.github.io/solid-ui/src/icons/noun_1180156.svg" style="width: 2em; height: 2em;" title="Cancel">';
|
|
1394
|
-
issuerPopupBoxCloseButton.setAttribute('style', 'background-color: transparent; border: none;');
|
|
1395
|
-
issuerPopupBoxCloseButton.addEventListener('click', function () {
|
|
1396
|
-
issuerPopup.remove();
|
|
1397
|
-
});
|
|
1398
|
-
issuerPopupBoxTopMenu.appendChild(issuerPopupBoxLabel);
|
|
1399
|
-
issuerPopupBoxTopMenu.appendChild(issuerPopupBoxCloseButton);
|
|
1400
|
-
|
|
1401
|
-
var loginToIssuer = /*#__PURE__*/function () {
|
|
1402
|
-
var _ref = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(issuerUri) {
|
|
1403
|
-
var preLoginRedirectHash;
|
|
1404
|
-
return _regenerator["default"].wrap(function _callee$(_context) {
|
|
1405
|
-
while (1) {
|
|
1406
|
-
switch (_context.prev = _context.next) {
|
|
1407
|
-
case 0:
|
|
1408
|
-
_context.prev = 0;
|
|
1409
|
-
// Save hash
|
|
1410
|
-
preLoginRedirectHash = new URL(window.location.href).hash;
|
|
1411
|
-
|
|
1412
|
-
if (preLoginRedirectHash) {
|
|
1413
|
-
window.localStorage.setItem('preLoginRedirectHash', preLoginRedirectHash);
|
|
1414
|
-
}
|
|
1415
|
-
|
|
1416
|
-
window.localStorage.setItem('loginIssuer', issuerUri); // Login
|
|
1417
|
-
|
|
1418
|
-
_context.next = 6;
|
|
1419
|
-
return authSession.login({
|
|
1420
|
-
redirectUrl: window.location.href,
|
|
1421
|
-
oidcIssuer: issuerUri
|
|
1422
|
-
});
|
|
1423
|
-
|
|
1424
|
-
case 6:
|
|
1425
|
-
_context.next = 11;
|
|
1426
|
-
break;
|
|
1427
|
-
|
|
1428
|
-
case 8:
|
|
1429
|
-
_context.prev = 8;
|
|
1430
|
-
_context.t0 = _context["catch"](0);
|
|
1431
|
-
(0, _log.alert)(_context.t0.message);
|
|
1432
|
-
|
|
1433
|
-
case 11:
|
|
1434
|
-
case "end":
|
|
1435
|
-
return _context.stop();
|
|
1436
|
-
}
|
|
1437
|
-
}
|
|
1438
|
-
}, _callee, null, [[0, 8]]);
|
|
1439
|
-
}));
|
|
1440
|
-
|
|
1441
|
-
return function loginToIssuer(_x17) {
|
|
1442
|
-
return _ref.apply(this, arguments);
|
|
1443
|
-
};
|
|
1444
|
-
}();
|
|
1445
|
-
/**
|
|
1446
|
-
* Text-based idp selection
|
|
1447
|
-
*/
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
var issuerTextContainer = dom.createElement('div');
|
|
1451
|
-
issuerTextContainer.setAttribute('style', "\n border-bottom: 1px solid #DDD;\n display: flex;\n flex-direction: column;\n padding-top: 10px;\n ");
|
|
1452
|
-
var issuerTextInputContainer = dom.createElement('div');
|
|
1453
|
-
issuerTextInputContainer.setAttribute('style', "\n display: flex;\n flex-direction: row;\n ");
|
|
1454
|
-
var issuerTextLabel = dom.createElement('label');
|
|
1455
|
-
issuerTextLabel.innerText = 'Enter the URL of your identity provider:';
|
|
1456
|
-
issuerTextLabel.setAttribute('style', 'color: #888');
|
|
1457
|
-
var issuerTextInput = dom.createElement('input');
|
|
1458
|
-
issuerTextInput.setAttribute('type', 'text');
|
|
1459
|
-
issuerTextInput.setAttribute('style', 'margin-left: 0 !important; flex: 1; margin-right: 5px !important');
|
|
1460
|
-
issuerTextInput.setAttribute('placeholder', 'https://example.com');
|
|
1461
|
-
issuerTextInput.value = localStorage.getItem('loginIssuer') || '';
|
|
1462
|
-
var issuerTextGoButton = dom.createElement('button');
|
|
1463
|
-
issuerTextGoButton.innerText = 'Go';
|
|
1464
|
-
issuerTextGoButton.setAttribute('style', 'margin-top: 12px; margin-bottom: 12px;');
|
|
1465
|
-
issuerTextGoButton.addEventListener('click', function () {
|
|
1466
|
-
loginToIssuer(issuerTextInput.value);
|
|
1467
|
-
});
|
|
1468
|
-
issuerTextContainer.appendChild(issuerTextLabel);
|
|
1469
|
-
issuerTextInputContainer.appendChild(issuerTextInput);
|
|
1470
|
-
issuerTextInputContainer.appendChild(issuerTextGoButton);
|
|
1471
|
-
issuerTextContainer.appendChild(issuerTextInputContainer);
|
|
1472
|
-
issuerPopupBox.appendChild(issuerTextContainer);
|
|
1473
|
-
/**
|
|
1474
|
-
* Button-based idp selection
|
|
1475
|
-
*/
|
|
1476
|
-
|
|
1477
|
-
var issuerButtonContainer = dom.createElement('div');
|
|
1478
|
-
issuerButtonContainer.setAttribute('style', "\n display: flex;\n flex-direction: column;\n padding-top: 10px;\n ");
|
|
1479
|
-
var issuerBottonLabel = dom.createElement('label');
|
|
1480
|
-
issuerBottonLabel.innerText = 'Or pick an identity provider from the list below:';
|
|
1481
|
-
issuerBottonLabel.setAttribute('style', 'color: #888');
|
|
1482
|
-
issuerButtonContainer.appendChild(issuerBottonLabel);
|
|
1483
|
-
getSuggestedIssuers().forEach(function (issuerInfo) {
|
|
1484
|
-
var issuerButton = dom.createElement('button');
|
|
1485
|
-
issuerButton.innerText = issuerInfo.name;
|
|
1486
|
-
issuerButton.setAttribute('style', 'height: 38px; margin-top: 10px');
|
|
1487
|
-
issuerButton.addEventListener('click', function () {
|
|
1488
|
-
loginToIssuer(issuerInfo.uri);
|
|
1489
|
-
});
|
|
1490
|
-
issuerButtonContainer.appendChild(issuerButton);
|
|
1491
|
-
});
|
|
1492
|
-
issuerPopupBox.appendChild(issuerButtonContainer);
|
|
1493
|
-
}
|
|
1494
|
-
/**
|
|
1495
|
-
* @returns - A list of suggested OIDC issuers
|
|
1496
|
-
*/
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
function getSuggestedIssuers() {
|
|
1500
|
-
// Suggest a default list of OIDC issuers
|
|
1501
|
-
var issuers = [].concat(DEFAULT_ISSUERS); // Suggest the current host if not already included
|
|
1502
|
-
|
|
1503
|
-
var _URL = new URL(location.href),
|
|
1504
|
-
host = _URL.host,
|
|
1505
|
-
origin = _URL.origin;
|
|
1506
|
-
|
|
1507
|
-
var hosts = issuers.map(function (_ref2) {
|
|
1508
|
-
var uri = _ref2.uri;
|
|
1509
|
-
return new URL(uri).host;
|
|
1510
|
-
});
|
|
1511
|
-
|
|
1512
|
-
if (!hosts.includes(host) && !hosts.some(function (existing) {
|
|
1513
|
-
return isSubdomainOf(host, existing);
|
|
1514
|
-
})) {
|
|
1515
|
-
issuers.unshift({
|
|
1516
|
-
name: host,
|
|
1517
|
-
uri: origin
|
|
1518
|
-
});
|
|
1519
|
-
}
|
|
1520
|
-
|
|
1521
|
-
return issuers;
|
|
1522
|
-
}
|
|
1523
|
-
|
|
1524
|
-
function isSubdomainOf(subdomain, domain) {
|
|
1525
|
-
var dot = subdomain.length - domain.length - 1;
|
|
1526
|
-
return dot > 0 && subdomain[dot] === '.' && subdomain.endsWith(domain);
|
|
1527
|
-
}
|
|
1528
|
-
/**
|
|
1529
|
-
* @returns {Promise<string|null>} Resolves with WebID URI or null
|
|
1530
|
-
*/
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
function webIdFromSession(session) {
|
|
1534
|
-
var webId = session !== null && session !== void 0 && session.webId && session.isLoggedIn ? session.webId : null;
|
|
1535
|
-
|
|
1536
|
-
if (webId) {
|
|
1537
|
-
saveUser(webId);
|
|
1538
|
-
}
|
|
1539
|
-
|
|
1540
|
-
return webId;
|
|
1541
|
-
}
|
|
1542
|
-
/**
|
|
1543
|
-
* @returns {Promise<string|null>} Resolves with WebID URI or null
|
|
1544
|
-
*/
|
|
1545
|
-
|
|
1546
|
-
/*
|
|
1547
|
-
function checkCurrentUser () {
|
|
1548
|
-
return checkUser()
|
|
1549
|
-
}
|
|
1550
|
-
*/
|
|
1551
|
-
|
|
1552
|
-
/**
|
|
1553
|
-
* Retrieves currently logged in webId from either
|
|
1554
|
-
* defaultTestUser or SolidAuth
|
|
1555
|
-
* @param [setUserCallback] Optional callback
|
|
1556
|
-
*
|
|
1557
|
-
* @returns Resolves with webId uri, if no callback provided
|
|
1558
|
-
*/
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
function checkUser(_x18) {
|
|
1562
|
-
return _checkUser.apply(this, arguments);
|
|
1563
|
-
}
|
|
1564
|
-
/**
|
|
1565
|
-
* Login status box
|
|
1566
|
-
*
|
|
1567
|
-
* A big sign-up/sign in box or a logout box depending on the state
|
|
1568
|
-
*
|
|
1569
|
-
* @param dom
|
|
1570
|
-
* @param listener
|
|
1571
|
-
*
|
|
1572
|
-
* @returns
|
|
1573
|
-
*/
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
function _checkUser() {
|
|
1577
|
-
_checkUser = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee16(setUserCallback) {
|
|
1578
|
-
var preLoginRedirectHash, postLoginRedirectHash, curUrl, me, webId;
|
|
1579
|
-
return _regenerator["default"].wrap(function _callee16$(_context16) {
|
|
1580
|
-
while (1) {
|
|
1581
|
-
switch (_context16.prev = _context16.next) {
|
|
1582
|
-
case 0:
|
|
1583
|
-
// Save hash for "restorePreviousSession"
|
|
1584
|
-
preLoginRedirectHash = new URL(window.location.href).hash;
|
|
1585
|
-
|
|
1586
|
-
if (preLoginRedirectHash) {
|
|
1587
|
-
window.localStorage.setItem('preLoginRedirectHash', preLoginRedirectHash);
|
|
1588
|
-
}
|
|
1589
|
-
|
|
1590
|
-
authSession.onSessionRestore(function (url) {
|
|
1591
|
-
if (document.location.toString() !== url) history.replaceState(null, '', url);
|
|
1592
|
-
});
|
|
1593
|
-
/**
|
|
1594
|
-
* Handle a successful authentication redirect
|
|
1595
|
-
*/
|
|
1596
|
-
|
|
1597
|
-
_context16.next = 5;
|
|
1598
|
-
return authSession.handleIncomingRedirect({
|
|
1599
|
-
restorePreviousSession: true,
|
|
1600
|
-
url: window.location.href
|
|
1601
|
-
});
|
|
1602
|
-
|
|
1603
|
-
case 5:
|
|
1604
|
-
// Check to see if a hash was stored in local storage
|
|
1605
|
-
postLoginRedirectHash = window.localStorage.getItem('preLoginRedirectHash');
|
|
1606
|
-
|
|
1607
|
-
if (postLoginRedirectHash) {
|
|
1608
|
-
curUrl = new URL(window.location.href);
|
|
1609
|
-
|
|
1610
|
-
if (curUrl.hash !== postLoginRedirectHash) {
|
|
1611
|
-
if (history.pushState) {
|
|
1612
|
-
// console.log('Setting window.location.has using pushState')
|
|
1613
|
-
history.pushState(null, document.title, postLoginRedirectHash);
|
|
1614
|
-
} else {
|
|
1615
|
-
// console.warn('Setting window.location.has using location.hash')
|
|
1616
|
-
location.hash = postLoginRedirectHash;
|
|
1617
|
-
}
|
|
1618
|
-
|
|
1619
|
-
curUrl.hash = postLoginRedirectHash;
|
|
1620
|
-
} // See https://stackoverflow.com/questions/3870057/how-can-i-update-window-location-hash-without-jumping-the-document
|
|
1621
|
-
// indow.location.href = curUrl.toString()// @@ See https://developer.mozilla.org/en-US/docs/Web/API/Window/location
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
window.localStorage.setItem('preLoginRedirectHash', '');
|
|
1625
|
-
} // Check to see if already logged in / have the WebID
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
me = defaultTestUser();
|
|
1629
|
-
|
|
1630
|
-
if (!me) {
|
|
1631
|
-
_context16.next = 10;
|
|
1632
|
-
break;
|
|
1633
|
-
}
|
|
1634
|
-
|
|
1635
|
-
return _context16.abrupt("return", Promise.resolve(setUserCallback ? setUserCallback(me) : me));
|
|
1636
|
-
|
|
1637
|
-
case 10:
|
|
1638
|
-
// doc = solidLogicSingleton.store.any(doc, ns.link('userMirror')) || doc
|
|
1639
|
-
webId = webIdFromSession(authSession.info);
|
|
1640
|
-
me = saveUser(webId);
|
|
1641
|
-
|
|
1642
|
-
if (me) {
|
|
1643
|
-
debug.log("(Logged in as ".concat(me, " by authentication)"));
|
|
1644
|
-
}
|
|
1645
|
-
|
|
1646
|
-
return _context16.abrupt("return", Promise.resolve(setUserCallback ? setUserCallback(me) : me));
|
|
1647
|
-
|
|
1648
|
-
case 14:
|
|
1649
|
-
case "end":
|
|
1650
|
-
return _context16.stop();
|
|
1651
|
-
}
|
|
1652
|
-
}
|
|
1653
|
-
}, _callee16);
|
|
1654
|
-
}));
|
|
1655
|
-
return _checkUser.apply(this, arguments);
|
|
1656
|
-
}
|
|
1657
|
-
|
|
1658
|
-
function loginStatusBox(dom) {
|
|
1659
|
-
var listener = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
1660
|
-
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
1661
|
-
// 20190630
|
|
1662
|
-
var me = defaultTestUser(); // @@ TODO Remove the need to cast HTML element to any
|
|
1663
|
-
|
|
1664
|
-
var box = dom.createElement('div');
|
|
1665
|
-
|
|
1666
|
-
function setIt(newidURI) {
|
|
1667
|
-
if (!newidURI) {
|
|
1668
|
-
return;
|
|
1669
|
-
}
|
|
1670
|
-
|
|
1671
|
-
var uri = newidURI.uri || newidURI; // UI.preferences.set('me', uri)
|
|
1672
|
-
|
|
1673
|
-
me = (0, _rdflib.sym)(uri);
|
|
1674
|
-
box.refresh();
|
|
1675
|
-
if (listener) listener(me.uri);
|
|
1676
|
-
}
|
|
1677
|
-
|
|
1678
|
-
function logoutButtonHandler(_event) {
|
|
1679
|
-
// UI.preferences.set('me', '')
|
|
1680
|
-
authSession.logout().then(function () {
|
|
1681
|
-
var message = "Your WebID was ".concat(me, ". It has been forgotten.");
|
|
1682
|
-
me = null;
|
|
1683
|
-
|
|
1684
|
-
try {
|
|
1685
|
-
(0, _log.alert)(message);
|
|
1686
|
-
} catch (e) {
|
|
1687
|
-
window.alert(message);
|
|
1688
|
-
}
|
|
1689
|
-
|
|
1690
|
-
box.refresh();
|
|
1691
|
-
if (listener) listener(null);
|
|
1692
|
-
}, function (err) {
|
|
1693
|
-
(0, _log.alert)('Fail to log out:' + err);
|
|
1694
|
-
});
|
|
1695
|
-
}
|
|
1696
|
-
|
|
1697
|
-
function logoutButton(me, options) {
|
|
1698
|
-
var signInButtonStyle = options.buttonStyle || getDefaultSignInButtonStyle();
|
|
1699
|
-
var logoutLabel = 'WebID logout';
|
|
1700
|
-
|
|
1701
|
-
if (me) {
|
|
1702
|
-
var nick = _logic.solidLogicSingleton.store.any(me, ns.foaf('nick')) || _logic.solidLogicSingleton.store.any(me, ns.foaf('name'));
|
|
1703
|
-
|
|
1704
|
-
if (nick) {
|
|
1705
|
-
logoutLabel = 'Logout ' + nick.value;
|
|
1706
|
-
}
|
|
1707
|
-
}
|
|
1708
|
-
|
|
1709
|
-
var signOutButton = dom.createElement('input'); // signOutButton.className = 'WebIDCancelButton'
|
|
1710
|
-
|
|
1711
|
-
signOutButton.setAttribute('type', 'button');
|
|
1712
|
-
signOutButton.setAttribute('value', logoutLabel);
|
|
1713
|
-
signOutButton.setAttribute('style', "".concat(signInButtonStyle, "background-color: #eee;"));
|
|
1714
|
-
signOutButton.addEventListener('click', logoutButtonHandler, false);
|
|
1715
|
-
return signOutButton;
|
|
1716
|
-
}
|
|
1717
|
-
|
|
1718
|
-
box.refresh = function () {
|
|
1719
|
-
var sessionInfo = authSession.info;
|
|
1720
|
-
|
|
1721
|
-
if (sessionInfo && sessionInfo.webId && sessionInfo.isLoggedIn) {
|
|
1722
|
-
me = (0, _rdflib.sym)(sessionInfo.webId);
|
|
1723
|
-
} else {
|
|
1724
|
-
me = null;
|
|
1725
|
-
}
|
|
1726
|
-
|
|
1727
|
-
if (me && box.me !== me.uri || !me && box.me) {
|
|
1728
|
-
widgets.clearElement(box);
|
|
1729
|
-
|
|
1730
|
-
if (me) {
|
|
1731
|
-
box.appendChild(logoutButton(me, options));
|
|
1732
|
-
} else {
|
|
1733
|
-
box.appendChild(signInOrSignUpBox(dom, setIt, options));
|
|
1734
|
-
}
|
|
1735
|
-
}
|
|
1736
|
-
|
|
1737
|
-
box.me = me ? me.uri : null;
|
|
1738
|
-
};
|
|
1739
|
-
|
|
1740
|
-
function trackSession() {
|
|
1741
|
-
var sessionInfo = authSession.info;
|
|
1742
|
-
|
|
1743
|
-
if (sessionInfo && sessionInfo.webId && sessionInfo.isLoggedIn) {
|
|
1744
|
-
me = (0, _rdflib.sym)(sessionInfo.webId);
|
|
1745
|
-
} else {
|
|
1746
|
-
me = null;
|
|
1747
|
-
}
|
|
1748
|
-
|
|
1749
|
-
box.refresh();
|
|
1750
|
-
}
|
|
1751
|
-
|
|
1752
|
-
trackSession();
|
|
1753
|
-
authSession.onLogin(trackSession);
|
|
1754
|
-
authSession.onLogout(trackSession);
|
|
1755
|
-
box.me = '99999'; // Force refresh
|
|
1756
|
-
|
|
1757
|
-
box.refresh();
|
|
1758
|
-
return box;
|
|
1759
|
-
}
|
|
1760
|
-
|
|
1761
|
-
authSession.onLogout( /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2() {
|
|
1762
|
-
var issuer, wellKnownUri, wellKnownResult, openidConfiguration;
|
|
1763
|
-
return _regenerator["default"].wrap(function _callee2$(_context2) {
|
|
1764
|
-
while (1) {
|
|
1765
|
-
switch (_context2.prev = _context2.next) {
|
|
1766
|
-
case 0:
|
|
1767
|
-
issuer = window.localStorage.getItem('loginIssuer');
|
|
1768
|
-
|
|
1769
|
-
if (!issuer) {
|
|
1770
|
-
_context2.next = 19;
|
|
1771
|
-
break;
|
|
1772
|
-
}
|
|
1773
|
-
|
|
1774
|
-
_context2.prev = 2;
|
|
1775
|
-
wellKnownUri = new URL(issuer);
|
|
1776
|
-
wellKnownUri.pathname = '/.well-known/openid-configuration';
|
|
1777
|
-
_context2.next = 7;
|
|
1778
|
-
return fetch(wellKnownUri.toString());
|
|
1779
|
-
|
|
1780
|
-
case 7:
|
|
1781
|
-
wellKnownResult = _context2.sent;
|
|
1782
|
-
|
|
1783
|
-
if (!(wellKnownResult.status === 200)) {
|
|
1784
|
-
_context2.next = 15;
|
|
1785
|
-
break;
|
|
1786
|
-
}
|
|
1787
|
-
|
|
1788
|
-
_context2.next = 11;
|
|
1789
|
-
return wellKnownResult.json();
|
|
1790
|
-
|
|
1791
|
-
case 11:
|
|
1792
|
-
openidConfiguration = _context2.sent;
|
|
1793
|
-
|
|
1794
|
-
if (!(openidConfiguration && openidConfiguration.end_session_endpoint)) {
|
|
1795
|
-
_context2.next = 15;
|
|
1796
|
-
break;
|
|
1797
|
-
}
|
|
1798
|
-
|
|
1799
|
-
_context2.next = 15;
|
|
1800
|
-
return fetch(openidConfiguration.end_session_endpoint, {
|
|
1801
|
-
credentials: 'include'
|
|
1802
|
-
});
|
|
1803
|
-
|
|
1804
|
-
case 15:
|
|
1805
|
-
_context2.next = 19;
|
|
1806
|
-
break;
|
|
1807
|
-
|
|
1808
|
-
case 17:
|
|
1809
|
-
_context2.prev = 17;
|
|
1810
|
-
_context2.t0 = _context2["catch"](2);
|
|
1811
|
-
|
|
1812
|
-
case 19:
|
|
1813
|
-
window.location.reload();
|
|
1814
|
-
|
|
1815
|
-
case 20:
|
|
1816
|
-
case "end":
|
|
1817
|
-
return _context2.stop();
|
|
1818
|
-
}
|
|
1819
|
-
}
|
|
1820
|
-
}, _callee2, null, [[2, 17]]);
|
|
1821
|
-
})));
|
|
1822
|
-
/**
|
|
1823
|
-
* Workspace selection etc
|
|
1824
|
-
* See https://github.com/solid/userguide/issues/16
|
|
1825
|
-
*/
|
|
1826
|
-
|
|
1827
|
-
/**
|
|
1828
|
-
* Returns a UI object which, if it selects a workspace,
|
|
1829
|
-
* will callback(workspace, newBase).
|
|
1830
|
-
* See https://github.com/solid/userguide/issues/16 for more info on workspaces.
|
|
1831
|
-
*
|
|
1832
|
-
* If necessary, will get an account, preference file, etc. In sequence:
|
|
1833
|
-
*
|
|
1834
|
-
* - If not logged in, log in.
|
|
1835
|
-
* - Load preference file
|
|
1836
|
-
* - Prompt user for workspaces
|
|
1837
|
-
* - Allows the user to just type in a URI by hand
|
|
1838
|
-
*
|
|
1839
|
-
* Calls back with the workspace and the base URI
|
|
1840
|
-
*
|
|
1841
|
-
* @param dom
|
|
1842
|
-
* @param appDetails
|
|
1843
|
-
* @param callbackWS
|
|
1844
|
-
*/
|
|
1845
|
-
|
|
1846
|
-
function selectWorkspace(dom, appDetails, callbackWS) {
|
|
1847
|
-
var noun = appDetails.noun;
|
|
1848
|
-
var appPathSegment = appDetails.appPathSegment;
|
|
1849
|
-
var me = defaultTestUser();
|
|
1850
|
-
var box = dom.createElement('div');
|
|
1851
|
-
var context = {
|
|
1852
|
-
me: me,
|
|
1853
|
-
dom: dom,
|
|
1854
|
-
div: box
|
|
1855
|
-
};
|
|
1856
|
-
|
|
1857
|
-
function say(s, background) {
|
|
1858
|
-
box.appendChild(widgets.errorMessageBlock(dom, s, background));
|
|
1859
|
-
}
|
|
1860
|
-
|
|
1861
|
-
function figureOutBase(ws) {
|
|
1862
|
-
var newBaseNode = _logic.solidLogicSingleton.store.any(ws, ns.space('uriPrefix'));
|
|
1863
|
-
|
|
1864
|
-
var newBaseString;
|
|
1865
|
-
|
|
1866
|
-
if (!newBaseNode) {
|
|
1867
|
-
newBaseString = ws.uri.split('#')[0];
|
|
1868
|
-
} else {
|
|
1869
|
-
newBaseString = newBaseNode.value;
|
|
1870
|
-
}
|
|
1871
|
-
|
|
1872
|
-
if (newBaseString.slice(-1) !== '/') {
|
|
1873
|
-
debug.log("".concat(appPathSegment, ": No / at end of uriPrefix ").concat(newBaseString)); // @@ paramater?
|
|
1874
|
-
|
|
1875
|
-
newBaseString = "".concat(newBaseString, "/");
|
|
1876
|
-
}
|
|
1877
|
-
|
|
1878
|
-
var now = new Date();
|
|
1879
|
-
newBaseString += "".concat(appPathSegment, "/id").concat(now.getTime(), "/"); // unique id
|
|
1880
|
-
|
|
1881
|
-
return newBaseString;
|
|
1882
|
-
}
|
|
1883
|
-
|
|
1884
|
-
function displayOptions(context) {
|
|
1885
|
-
// console.log('displayOptions!', context)
|
|
1886
|
-
function makeNewWorkspace(_x19) {
|
|
1887
|
-
return _makeNewWorkspace.apply(this, arguments);
|
|
1888
|
-
} // const status = ''
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
function _makeNewWorkspace() {
|
|
1892
|
-
_makeNewWorkspace = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee3(_event) {
|
|
1893
|
-
var row, cell, newBase, newWs, newData;
|
|
1894
|
-
return _regenerator["default"].wrap(function _callee3$(_context3) {
|
|
1895
|
-
while (1) {
|
|
1896
|
-
switch (_context3.prev = _context3.next) {
|
|
1897
|
-
case 0:
|
|
1898
|
-
row = table.appendChild(dom.createElement('tr'));
|
|
1899
|
-
cell = row.appendChild(dom.createElement('td'));
|
|
1900
|
-
cell.setAttribute('colspan', '3');
|
|
1901
|
-
cell.style.padding = '0.5em';
|
|
1902
|
-
_context3.t0 = encodeURI;
|
|
1903
|
-
_context3.next = 7;
|
|
1904
|
-
return widgets.askName(dom, _logic.solidLogicSingleton.store, cell, ns.solid('URL'), ns.space('Workspace'), 'Workspace');
|
|
1905
|
-
|
|
1906
|
-
case 7:
|
|
1907
|
-
_context3.t1 = _context3.sent;
|
|
1908
|
-
newBase = (0, _context3.t0)(_context3.t1);
|
|
1909
|
-
newWs = widgets.newThing(context.preferencesFile);
|
|
1910
|
-
newData = [(0, _rdflib.st)(context.me, ns.space('workspace'), newWs, context.preferencesFile), // eslint-disable-next-line camelcase
|
|
1911
|
-
(0, _rdflib.st)(newWs, ns.space('uriPrefix'), newBase, context.preferencesFile)];
|
|
1912
|
-
|
|
1913
|
-
if (_logic.solidLogicSingleton.store.updater) {
|
|
1914
|
-
_context3.next = 13;
|
|
1915
|
-
break;
|
|
1916
|
-
}
|
|
1917
|
-
|
|
1918
|
-
throw new Error('store has no updater');
|
|
1919
|
-
|
|
1920
|
-
case 13:
|
|
1921
|
-
_context3.next = 15;
|
|
1922
|
-
return _logic.solidLogicSingleton.store.updater.update([], newData);
|
|
1923
|
-
|
|
1924
|
-
case 15:
|
|
1925
|
-
case "end":
|
|
1926
|
-
return _context3.stop();
|
|
1927
|
-
}
|
|
1928
|
-
}
|
|
1929
|
-
}, _callee3);
|
|
1930
|
-
}));
|
|
1931
|
-
return _makeNewWorkspace.apply(this, arguments);
|
|
1932
|
-
}
|
|
1933
|
-
|
|
1934
|
-
var id = context.me;
|
|
1935
|
-
var preferencesFile = context.preferencesFile;
|
|
1936
|
-
var newBase = null; // A workspace specifically defined in the private preference file:
|
|
1937
|
-
|
|
1938
|
-
var w = _logic.solidLogicSingleton.store.each(id, ns.space('workspace'), undefined, preferencesFile); // Only trust preference file here
|
|
1939
|
-
// A workspace in a storage in the public profile:
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
var storages = _logic.solidLogicSingleton.store.each(id, ns.space('storage')); // @@ No provenance requirement at the moment
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
if (w.length === 0 && storages) {
|
|
1946
|
-
say("You don't seem to have any workspaces. You have ".concat(storages.length, " storage spaces."), 'white');
|
|
1947
|
-
storages.map(function (s) {
|
|
1948
|
-
w = w.concat(_logic.solidLogicSingleton.store.each(s, ns.ldp('contains')));
|
|
1949
|
-
return w;
|
|
1950
|
-
}).filter(function (file) {
|
|
1951
|
-
return file.id ? ['public', 'private'].includes(file.id().toLowerCase()) : '';
|
|
1952
|
-
});
|
|
1953
|
-
}
|
|
1954
|
-
|
|
1955
|
-
if (w.length === 1) {
|
|
1956
|
-
say("Workspace used: ".concat(w[0].uri), 'white'); // @@ allow user to see URI
|
|
1957
|
-
|
|
1958
|
-
newBase = figureOutBase(w[0]); // callbackWS(w[0], newBase)
|
|
1959
|
-
// } else if (w.length === 0) {
|
|
1960
|
-
} // Prompt for ws selection or creation
|
|
1961
|
-
// say( w.length + " workspaces for " + id + "Choose one.");
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
var table = dom.createElement('table');
|
|
1965
|
-
table.setAttribute('style', 'border-collapse:separate; border-spacing: 0.5em;'); // const popup = window.open(undefined, '_blank', { height: 300, width:400 }, false)
|
|
1966
|
-
|
|
1967
|
-
box.appendChild(table); // Add a field for directly adding the URI yourself
|
|
1968
|
-
// const hr = box.appendChild(dom.createElement('hr')) // @@
|
|
1969
|
-
|
|
1970
|
-
box.appendChild(dom.createElement('hr')); // @@
|
|
1971
|
-
|
|
1972
|
-
var p = box.appendChild(dom.createElement('p'));
|
|
1973
|
-
p.style = _style.commentStyle;
|
|
1974
|
-
p.textContent = "Where would you like to store the data for the ".concat(noun, "?\n Give the URL of the folder where you would like the data stored.\n It can be anywhere in solid world - this URI is just an idea."); // @@ TODO Remove the need to cast baseField to any
|
|
1975
|
-
|
|
1976
|
-
var baseField = box.appendChild(dom.createElement('input'));
|
|
1977
|
-
baseField.setAttribute('type', 'text');
|
|
1978
|
-
baseField.style = _style.textInputStyle;
|
|
1979
|
-
baseField.size = 80; // really a string
|
|
1980
|
-
|
|
1981
|
-
baseField.label = 'base URL';
|
|
1982
|
-
baseField.autocomplete = 'on';
|
|
1983
|
-
|
|
1984
|
-
if (newBase) {
|
|
1985
|
-
// set to default
|
|
1986
|
-
baseField.value = newBase;
|
|
1987
|
-
}
|
|
1988
|
-
|
|
1989
|
-
context.baseField = baseField;
|
|
1990
|
-
box.appendChild(dom.createElement('br')); // @@
|
|
1991
|
-
|
|
1992
|
-
var button = box.appendChild(dom.createElement('button'));
|
|
1993
|
-
button.style = _style.buttonStyle;
|
|
1994
|
-
button.textContent = "Start new ".concat(noun, " at this URI");
|
|
1995
|
-
button.addEventListener('click', function (_event) {
|
|
1996
|
-
var newBase = baseField.value.replace(' ', '%20'); // do not re-encode in general, as % encodings may exist
|
|
1997
|
-
|
|
1998
|
-
if (newBase.slice(-1) !== '/') {
|
|
1999
|
-
newBase += '/';
|
|
2000
|
-
}
|
|
2001
|
-
|
|
2002
|
-
callbackWS(null, newBase);
|
|
2003
|
-
}); // Now go set up the table of spaces
|
|
2004
|
-
// const row = 0
|
|
2005
|
-
|
|
2006
|
-
w = w.filter(function (x) {
|
|
2007
|
-
return !_logic.solidLogicSingleton.store.holds(x, ns.rdf('type'), // Ignore master workspaces
|
|
2008
|
-
ns.space('MasterWorkspace'));
|
|
2009
|
-
});
|
|
2010
|
-
var col1, col2, col3, tr, ws, style, comment;
|
|
2011
|
-
var cellStyle = 'height: 3em; margin: 1em; padding: 1em white; border-radius: 0.3em;';
|
|
2012
|
-
var deselectedStyle = "".concat(cellStyle, "border: 0px;"); // const selectedStyle = cellStyle + 'border: 1px solid black;'
|
|
2013
|
-
|
|
2014
|
-
for (var i = 0; i < w.length; i++) {
|
|
2015
|
-
ws = w[i];
|
|
2016
|
-
tr = dom.createElement('tr');
|
|
2017
|
-
|
|
2018
|
-
if (i === 0) {
|
|
2019
|
-
col1 = dom.createElement('td');
|
|
2020
|
-
col1.setAttribute('rowspan', "".concat(w.length));
|
|
2021
|
-
col1.textContent = 'Choose a workspace for this:';
|
|
2022
|
-
col1.setAttribute('style', 'vertical-align:middle;');
|
|
2023
|
-
tr.appendChild(col1);
|
|
2024
|
-
}
|
|
2025
|
-
|
|
2026
|
-
col2 = dom.createElement('td');
|
|
2027
|
-
style = _logic.solidLogicSingleton.store.anyValue(ws, ns.ui('style'));
|
|
2028
|
-
|
|
2029
|
-
if (!style) {
|
|
2030
|
-
// Otherwise make up arbitrary colour
|
|
2031
|
-
var hash = function hash(x) {
|
|
2032
|
-
return x.split('').reduce(function (a, b) {
|
|
2033
|
-
a = (a << 5) - a + b.charCodeAt(0);
|
|
2034
|
-
return a & a;
|
|
2035
|
-
}, 0);
|
|
2036
|
-
};
|
|
2037
|
-
|
|
2038
|
-
var bgcolor = "#".concat((hash(ws.uri) & 0xffffff | 0xc0c0c0).toString(16)); // c0c0c0 forces pale
|
|
2039
|
-
|
|
2040
|
-
style = "color: black ; background-color: ".concat(bgcolor, ";");
|
|
2041
|
-
}
|
|
2042
|
-
|
|
2043
|
-
col2.setAttribute('style', deselectedStyle + style);
|
|
2044
|
-
tr.target = ws.uri;
|
|
2045
|
-
|
|
2046
|
-
var label = _logic.solidLogicSingleton.store.any(ws, ns.rdfs('label'));
|
|
2047
|
-
|
|
2048
|
-
if (!label) {
|
|
2049
|
-
label = ws.uri.split('/').slice(-1)[0] || ws.uri.split('/').slice(-2)[0];
|
|
2050
|
-
}
|
|
2051
|
-
|
|
2052
|
-
col2.textContent = label || '???';
|
|
2053
|
-
tr.appendChild(col2);
|
|
2054
|
-
|
|
2055
|
-
if (i === 0) {
|
|
2056
|
-
col3 = dom.createElement('td');
|
|
2057
|
-
col3.setAttribute('rowspan', "".concat(w.length, "1")); // col3.textContent = '@@@@@ remove';
|
|
2058
|
-
|
|
2059
|
-
col3.setAttribute('style', 'width:50%;');
|
|
2060
|
-
tr.appendChild(col3);
|
|
2061
|
-
}
|
|
2062
|
-
|
|
2063
|
-
table.appendChild(tr);
|
|
2064
|
-
comment = _logic.solidLogicSingleton.store.any(ws, ns.rdfs('comment'));
|
|
2065
|
-
comment = comment ? comment.value : 'Use this workspace';
|
|
2066
|
-
col2.addEventListener('click', function (_event) {
|
|
2067
|
-
col3.textContent = comment ? comment.value : '';
|
|
2068
|
-
col3.setAttribute('style', deselectedStyle + style);
|
|
2069
|
-
var button = dom.createElement('button');
|
|
2070
|
-
button.textContent = 'Continue'; // button.setAttribute('style', style);
|
|
2071
|
-
|
|
2072
|
-
var newBase = figureOutBase(ws);
|
|
2073
|
-
baseField.value = newBase; // show user proposed URI
|
|
2074
|
-
|
|
2075
|
-
button.addEventListener('click', function (_event) {
|
|
2076
|
-
button.disabled = true;
|
|
2077
|
-
callbackWS(ws, newBase);
|
|
2078
|
-
button.textContent = '---->';
|
|
2079
|
-
}, true); // capture vs bubble
|
|
2080
|
-
|
|
2081
|
-
col3.appendChild(button);
|
|
2082
|
-
}, true); // capture vs bubble
|
|
2083
|
-
} // last line with "Make new workspace"
|
|
2084
|
-
|
|
2085
|
-
|
|
2086
|
-
var trLast = dom.createElement('tr');
|
|
2087
|
-
col2 = dom.createElement('td');
|
|
2088
|
-
col2.setAttribute('style', cellStyle);
|
|
2089
|
-
col2.textContent = '+ Make a new workspace';
|
|
2090
|
-
col2.addEventListener('click', makeNewWorkspace);
|
|
2091
|
-
trLast.appendChild(col2);
|
|
2092
|
-
table.appendChild(trLast);
|
|
2093
|
-
} // displayOptions
|
|
2094
|
-
// console.log('kicking off async operation')
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
logInLoadPreferences(context) // kick off async operation
|
|
2098
|
-
.then(displayOptions)["catch"](function (err) {
|
|
2099
|
-
// console.log("err from async op")
|
|
2100
|
-
box.appendChild(widgets.errorMessageBlock(context.dom, err));
|
|
2101
|
-
});
|
|
2102
|
-
return box; // return the box element, while login proceeds
|
|
2103
|
-
} // selectWorkspace
|
|
2104
|
-
|
|
2105
|
-
/**
|
|
2106
|
-
* Creates a new instance of an app.
|
|
2107
|
-
*
|
|
2108
|
-
* An instance of an app could be e.g. an issue tracker for a given project,
|
|
2109
|
-
* or a chess game, or calendar, or a health/fitness record for a person.
|
|
2110
|
-
*
|
|
2111
|
-
* Note that this use of the term 'app' refers more to entries in the user's
|
|
2112
|
-
* type index than to actual software applications that use the personal data
|
|
2113
|
-
* to which these entries point.
|
|
2114
|
-
*
|
|
2115
|
-
* @param dom
|
|
2116
|
-
* @param appDetails
|
|
2117
|
-
* @param callback
|
|
2118
|
-
*
|
|
2119
|
-
* @returns A div with a button in it for making a new app instance
|
|
2120
|
-
*/
|
|
2121
|
-
|
|
2122
|
-
|
|
2123
|
-
function newAppInstance(dom, appDetails, callback) {
|
|
2124
|
-
var gotWS = function gotWS(ws, base) {
|
|
2125
|
-
// log.debug("newAppInstance: Selected workspace = " + (ws? ws.uri : 'none'))
|
|
2126
|
-
callback(ws, base);
|
|
2127
|
-
};
|
|
2128
|
-
|
|
2129
|
-
var div = dom.createElement('div');
|
|
2130
|
-
var b = dom.createElement('button');
|
|
2131
|
-
b.setAttribute('type', 'button');
|
|
2132
|
-
div.appendChild(b);
|
|
2133
|
-
b.innerHTML = "Make new ".concat(appDetails.noun);
|
|
2134
|
-
b.addEventListener('click', function (_event) {
|
|
2135
|
-
div.appendChild(selectWorkspace(dom, appDetails, gotWS));
|
|
2136
|
-
}, false);
|
|
2137
|
-
div.appendChild(b);
|
|
2138
|
-
return div;
|
|
2139
|
-
}
|
|
2140
|
-
/**
|
|
2141
|
-
* Retrieves whether the currently logged in user is a power user
|
|
2142
|
-
* and/or a developer
|
|
2143
|
-
*/
|
|
2144
|
-
|
|
2145
|
-
|
|
2146
|
-
function getUserRoles() {
|
|
2147
|
-
return _getUserRoles.apply(this, arguments);
|
|
2148
|
-
}
|
|
2149
|
-
/**
|
|
2150
|
-
* Filters which panes should be available, based on the result of [[getUserRoles]]
|
|
2151
|
-
*/
|
|
2152
|
-
|
|
2153
|
-
|
|
2154
|
-
function _getUserRoles() {
|
|
2155
|
-
_getUserRoles = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee17() {
|
|
2156
|
-
var _yield$logInLoadPrefe, me, preferencesFile, preferencesFileError;
|
|
2157
|
-
|
|
2158
|
-
return _regenerator["default"].wrap(function _callee17$(_context17) {
|
|
2159
|
-
while (1) {
|
|
2160
|
-
switch (_context17.prev = _context17.next) {
|
|
2161
|
-
case 0:
|
|
2162
|
-
_context17.prev = 0;
|
|
2163
|
-
_context17.next = 3;
|
|
2164
|
-
return logInLoadPreferences({});
|
|
2165
|
-
|
|
2166
|
-
case 3:
|
|
2167
|
-
_yield$logInLoadPrefe = _context17.sent;
|
|
2168
|
-
me = _yield$logInLoadPrefe.me;
|
|
2169
|
-
preferencesFile = _yield$logInLoadPrefe.preferencesFile;
|
|
2170
|
-
preferencesFileError = _yield$logInLoadPrefe.preferencesFileError;
|
|
2171
|
-
|
|
2172
|
-
if (!(!preferencesFile || preferencesFileError)) {
|
|
2173
|
-
_context17.next = 9;
|
|
2174
|
-
break;
|
|
2175
|
-
}
|
|
2176
|
-
|
|
2177
|
-
throw new Error(preferencesFileError);
|
|
2178
|
-
|
|
2179
|
-
case 9:
|
|
2180
|
-
return _context17.abrupt("return", _logic.solidLogicSingleton.store.each(me, ns.rdf('type'), null, preferencesFile.doc()));
|
|
2181
|
-
|
|
2182
|
-
case 12:
|
|
2183
|
-
_context17.prev = 12;
|
|
2184
|
-
_context17.t0 = _context17["catch"](0);
|
|
2185
|
-
debug.warn('Unable to fetch your preferences - this was the error: ', _context17.t0);
|
|
2186
|
-
|
|
2187
|
-
case 15:
|
|
2188
|
-
return _context17.abrupt("return", []);
|
|
2189
|
-
|
|
2190
|
-
case 16:
|
|
2191
|
-
case "end":
|
|
2192
|
-
return _context17.stop();
|
|
2193
|
-
}
|
|
2194
|
-
}
|
|
2195
|
-
}, _callee17, null, [[0, 12]]);
|
|
2196
|
-
}));
|
|
2197
|
-
return _getUserRoles.apply(this, arguments);
|
|
2198
|
-
}
|
|
2199
|
-
|
|
2200
|
-
function filterAvailablePanes(_x20) {
|
|
2201
|
-
return _filterAvailablePanes.apply(this, arguments);
|
|
2202
|
-
}
|
|
2203
|
-
|
|
2204
|
-
function _filterAvailablePanes() {
|
|
2205
|
-
_filterAvailablePanes = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee18(panes) {
|
|
2206
|
-
var userRoles;
|
|
2207
|
-
return _regenerator["default"].wrap(function _callee18$(_context18) {
|
|
2208
|
-
while (1) {
|
|
2209
|
-
switch (_context18.prev = _context18.next) {
|
|
2210
|
-
case 0:
|
|
2211
|
-
_context18.next = 2;
|
|
2212
|
-
return getUserRoles();
|
|
2213
|
-
|
|
2214
|
-
case 2:
|
|
2215
|
-
userRoles = _context18.sent;
|
|
2216
|
-
return _context18.abrupt("return", panes.filter(function (pane) {
|
|
2217
|
-
return isMatchingAudience(pane, userRoles);
|
|
2218
|
-
}));
|
|
2219
|
-
|
|
2220
|
-
case 4:
|
|
2221
|
-
case "end":
|
|
2222
|
-
return _context18.stop();
|
|
2223
|
-
}
|
|
2224
|
-
}
|
|
2225
|
-
}, _callee18);
|
|
2226
|
-
}));
|
|
2227
|
-
return _filterAvailablePanes.apply(this, arguments);
|
|
2228
|
-
}
|
|
2229
|
-
|
|
2230
|
-
function isMatchingAudience(pane, userRoles) {
|
|
2231
|
-
var audience = pane.audience || [];
|
|
2232
|
-
return audience.reduce(function (isMatch, audienceRole) {
|
|
2233
|
-
return isMatch && !!userRoles.find(function (role) {
|
|
2234
|
-
return role.equals(audienceRole);
|
|
2235
|
-
});
|
|
2236
|
-
}, true);
|
|
2237
|
-
}
|
|
2238
|
-
//# sourceMappingURL=authn.js.map
|