solid-ui 2.6.1-05fb7cc → 2.6.1-07db096
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 +4 -4
- package/dist/acl/access-controller.js +38 -93
- package/dist/acl/access-controller.js.map +1 -1
- package/dist/acl/access-groups.d.ts +2 -2
- package/dist/acl/access-groups.d.ts.map +1 -1
- package/dist/acl/access-groups.js +62 -111
- package/dist/acl/access-groups.js.map +1 -1
- package/dist/acl/acl-control.js +22 -66
- package/dist/acl/acl-control.js.map +1 -1
- package/dist/acl/acl.js +53 -108
- package/dist/acl/acl.js.map +1 -1
- package/dist/acl/add-agent-buttons.js +29 -72
- package/dist/acl/add-agent-buttons.js.map +1 -1
- package/dist/acl/index.js +25 -28
- package/dist/acl/index.js.map +1 -1
- package/dist/acl/types.js +1 -2
- package/dist/acl/types.js.map +1 -1
- package/dist/chat/keys.js +36 -78
- package/dist/chat/keys.js.map +1 -1
- package/dist/chat/signature.js +15 -23
- package/dist/chat/signature.js.map +1 -1
- package/dist/create/create.js +15 -54
- package/dist/create/create.js.map +1 -1
- package/dist/create/index.js +3 -6
- package/dist/create/index.js.map +1 -1
- package/dist/create/types.js +1 -2
- package/dist/debug.d.ts.map +1 -1
- package/dist/debug.js +4 -14
- package/dist/debug.js.map +1 -1
- package/dist/footer/index.js +13 -18
- package/dist/footer/index.js.map +1 -1
- package/dist/header/empty-profile.js +1 -4
- package/dist/header/empty-profile.js.map +1 -1
- package/dist/header/index.js +54 -99
- package/dist/header/index.js.map +1 -1
- package/dist/iconBase.js +5 -8
- package/dist/iconBase.js.map +1 -1
- package/dist/index.d.ts +4 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +40 -108
- package/dist/index.js.map +1 -1
- package/dist/log.d.ts.map +1 -1
- package/dist/log.js +19 -36
- package/dist/log.js.map +1 -1
- package/dist/login/login.js +92 -144
- package/dist/login/login.js.map +1 -1
- package/dist/matrix/index.js +3 -6
- package/dist/matrix/index.js.map +1 -1
- package/dist/matrix/matrix.js +5 -41
- package/dist/matrix/matrix.js.map +1 -1
- package/dist/matrix/types.js +1 -2
- package/dist/media/index.js +4 -7
- package/dist/media/index.js.map +1 -1
- package/dist/media/media-capture.js +13 -50
- package/dist/media/media-capture.js.map +1 -1
- package/dist/pad.js +80 -100
- package/dist/pad.js.map +1 -1
- package/dist/participation.d.ts.map +1 -1
- package/dist/participation.js +43 -87
- package/dist/participation.js.map +1 -1
- package/dist/solid-ui.esm.js +24 -42
- package/dist/solid-ui.esm.js.map +1 -1
- package/dist/solid-ui.esm.min.js +3 -3
- package/dist/solid-ui.esm.min.js.map +1 -1
- package/dist/solid-ui.js +23 -44
- package/dist/solid-ui.js.map +1 -1
- package/dist/solid-ui.min.js +8 -8
- package/dist/solid-ui.min.js.map +1 -1
- package/dist/tabs.js +18 -28
- package/dist/tabs.js.map +1 -1
- package/dist/utils/headerFooterHelpers.d.ts.map +1 -1
- package/dist/utils/headerFooterHelpers.js +19 -27
- package/dist/utils/headerFooterHelpers.js.map +1 -1
- package/dist/utils/keyHelpers/accessData.js +16 -60
- package/dist/utils/keyHelpers/accessData.js.map +1 -1
- package/dist/utils/keyHelpers/acl.js +11 -49
- package/dist/utils/keyHelpers/acl.js.map +1 -1
- package/dist/utils/keyHelpers/otherHelpers.js +6 -12
- package/dist/utils/keyHelpers/otherHelpers.js.map +1 -1
- package/dist/utils/label.js +22 -61
- package/dist/utils/label.js.map +1 -1
- package/dist/versionInfo.js +3 -5
- package/dist/versionInfo.js.map +1 -1
- package/dist/widgets/buttons/iconLinks.js +4 -9
- package/dist/widgets/buttons/iconLinks.js.map +1 -1
- package/dist/widgets/buttons.js +146 -221
- package/dist/widgets/buttons.js.map +1 -1
- package/dist/widgets/error.d.ts +12 -0
- package/dist/widgets/error.d.ts.map +1 -1
- package/dist/widgets/error.js +8 -15
- package/dist/widgets/error.js.map +1 -1
- package/dist/widgets/forms/autocomplete/autocompleteBar.js +21 -60
- package/dist/widgets/forms/autocomplete/autocompleteBar.js.map +1 -1
- package/dist/widgets/forms/autocomplete/autocompleteField.js +33 -69
- package/dist/widgets/forms/autocomplete/autocompleteField.js.map +1 -1
- package/dist/widgets/forms/autocomplete/autocompletePicker.js +22 -62
- package/dist/widgets/forms/autocomplete/autocompletePicker.js.map +1 -1
- package/dist/widgets/forms/autocomplete/language.js +21 -64
- package/dist/widgets/forms/autocomplete/language.js.map +1 -1
- package/dist/widgets/forms/autocomplete/publicData.js +81 -128
- package/dist/widgets/forms/autocomplete/publicData.js.map +1 -1
- package/dist/widgets/forms/basic.js +37 -46
- package/dist/widgets/forms/basic.js.map +1 -1
- package/dist/widgets/forms/comment.js +10 -16
- package/dist/widgets/forms/comment.js.map +1 -1
- package/dist/widgets/forms/fieldFunction.js +10 -15
- package/dist/widgets/forms/fieldFunction.js.map +1 -1
- package/dist/widgets/forms/fieldParams.js +21 -27
- package/dist/widgets/forms/fieldParams.js.map +1 -1
- package/dist/widgets/forms/formStyle.d.ts.map +1 -1
- package/dist/widgets/forms/formStyle.js +10 -17
- package/dist/widgets/forms/formStyle.js.map +1 -1
- package/dist/widgets/widgetHelpers.js +5 -11
- package/dist/widgets/widgetHelpers.js.map +1 -1
- package/package.json +7 -8
package/dist/login/login.js
CHANGED
|
@@ -1,81 +1,29 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
-
};
|
|
38
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.ensureLoggedIn = ensureLoggedIn;
|
|
40
|
-
exports.ensureLoadedPreferences = ensureLoadedPreferences;
|
|
41
|
-
exports.ensureLoadedProfile = ensureLoadedProfile;
|
|
42
|
-
exports.findAppInstances = findAppInstances;
|
|
43
|
-
exports.scopeLabel = scopeLabel;
|
|
44
|
-
exports.registrationControl = registrationControl;
|
|
45
|
-
exports.renderScopeHeadingRow = renderScopeHeadingRow;
|
|
46
|
-
exports.registrationList = registrationList;
|
|
47
|
-
exports.renderSignInPopup = renderSignInPopup;
|
|
48
|
-
exports.loginStatusBox = loginStatusBox;
|
|
49
|
-
exports.selectWorkspace = selectWorkspace;
|
|
50
|
-
exports.newAppInstance = newAppInstance;
|
|
51
|
-
exports.getUserRoles = getUserRoles;
|
|
52
|
-
exports.filterAvailablePanes = filterAvailablePanes;
|
|
53
|
-
const rdflib_1 = require("rdflib");
|
|
54
|
-
const solid_logic_1 = require("solid-logic");
|
|
55
|
-
const debug = __importStar(require("../debug"));
|
|
56
|
-
const style_1 = require("../style");
|
|
57
|
-
const log_1 = require("../log");
|
|
58
|
-
const ns_1 = __importDefault(require("../ns"));
|
|
59
|
-
const signup_js_1 = require("../signup/signup.js");
|
|
60
|
-
const utils = __importStar(require("../utils"));
|
|
61
|
-
const widgets = __importStar(require("../widgets"));
|
|
62
|
-
const store = solid_logic_1.solidLogicSingleton.store;
|
|
63
|
-
const { loadPreferences, loadProfile } = solid_logic_1.solidLogicSingleton.profile;
|
|
64
|
-
const { getScopedAppInstances, getRegistrations, loadAllTypeIndexes, getScopedAppsFromIndex, deleteTypeIndexRegistration } = solid_logic_1.solidLogicSingleton.typeIndex;
|
|
1
|
+
import { BlankNode, st } from 'rdflib';
|
|
2
|
+
import { authn, authSession, CrossOriginForbiddenError, FetchError, getSuggestedIssuers, NotEditableError, offlineTestID, SameOriginForbiddenError, solidLogicSingleton, UnauthorizedError, WebOperationError } from 'solid-logic';
|
|
3
|
+
import * as debug from '../debug';
|
|
4
|
+
import { style } from '../style';
|
|
5
|
+
import { alert } from '../log';
|
|
6
|
+
import ns from '../ns';
|
|
7
|
+
import { Signup } from '../signup/signup.js';
|
|
8
|
+
import * as utils from '../utils';
|
|
9
|
+
import * as widgets from '../widgets';
|
|
10
|
+
const store = solidLogicSingleton.store;
|
|
11
|
+
const { loadPreferences, loadProfile } = solidLogicSingleton.profile;
|
|
12
|
+
const { getScopedAppInstances, getRegistrations, loadAllTypeIndexes, getScopedAppsFromIndex, deleteTypeIndexRegistration } = solidLogicSingleton.typeIndex;
|
|
65
13
|
/**
|
|
66
14
|
* Resolves with the logged in user's WebID
|
|
67
15
|
*
|
|
68
16
|
* @param context
|
|
69
17
|
*/
|
|
70
18
|
// used to be logIn
|
|
71
|
-
function ensureLoggedIn(context) {
|
|
72
|
-
const me =
|
|
19
|
+
export function ensureLoggedIn(context) {
|
|
20
|
+
const me = authn.currentUser();
|
|
73
21
|
if (me) {
|
|
74
|
-
|
|
22
|
+
authn.saveUser(me, context);
|
|
75
23
|
return Promise.resolve(context);
|
|
76
24
|
}
|
|
77
25
|
return new Promise((resolve) => {
|
|
78
|
-
|
|
26
|
+
authn.checkUser().then((webId) => {
|
|
79
27
|
// Already logged in?
|
|
80
28
|
if (webId) {
|
|
81
29
|
debug.log(`logIn: Already logged in as ${webId}`);
|
|
@@ -85,7 +33,7 @@ function ensureLoggedIn(context) {
|
|
|
85
33
|
return resolve(context);
|
|
86
34
|
}
|
|
87
35
|
const box = loginStatusBox(context.dom, (webIdUri) => {
|
|
88
|
-
|
|
36
|
+
authn.saveUser(webIdUri, context);
|
|
89
37
|
resolve(context); // always pass growing context
|
|
90
38
|
});
|
|
91
39
|
context.div.appendChild(box);
|
|
@@ -101,7 +49,7 @@ function ensureLoggedIn(context) {
|
|
|
101
49
|
* @param context
|
|
102
50
|
*/
|
|
103
51
|
// used to be logInLoadPreferences
|
|
104
|
-
async function ensureLoadedPreferences(context) {
|
|
52
|
+
export async function ensureLoadedPreferences(context) {
|
|
105
53
|
if (context.preferencesFile)
|
|
106
54
|
return Promise.resolve(context); // already done
|
|
107
55
|
// const statusArea = context.statusArea || context.div || null
|
|
@@ -127,36 +75,36 @@ async function ensureLoadedPreferences(context) {
|
|
|
127
75
|
}
|
|
128
76
|
catch (err) {
|
|
129
77
|
let m2;
|
|
130
|
-
if (err instanceof
|
|
78
|
+
if (err instanceof UnauthorizedError) {
|
|
131
79
|
m2 =
|
|
132
80
|
'Oops — you are not authenticated (properly logged in), so SolidOS cannot read your preferences file. Try logging out and then logging back in.';
|
|
133
|
-
|
|
81
|
+
alert(m2);
|
|
134
82
|
}
|
|
135
|
-
else if (err instanceof
|
|
83
|
+
else if (err instanceof CrossOriginForbiddenError) {
|
|
136
84
|
m2 = `Unauthorized: Assuming preference file blocked for origin ${window.location.origin}`;
|
|
137
85
|
context.preferencesFileError = m2;
|
|
138
86
|
return context;
|
|
139
87
|
}
|
|
140
|
-
else if (err instanceof
|
|
88
|
+
else if (err instanceof SameOriginForbiddenError) {
|
|
141
89
|
m2 =
|
|
142
90
|
'You are not authorized to read your preference file. This may be because you are using an untrusted web app.';
|
|
143
91
|
debug.warn(m2);
|
|
144
92
|
return context;
|
|
145
93
|
}
|
|
146
|
-
else if (err instanceof
|
|
94
|
+
else if (err instanceof NotEditableError) {
|
|
147
95
|
m2 =
|
|
148
96
|
'You are not authorized to edit your preference file. This may be because you are using an untrusted web app.';
|
|
149
97
|
debug.warn(m2);
|
|
150
98
|
return context;
|
|
151
99
|
}
|
|
152
|
-
else if (err instanceof
|
|
100
|
+
else if (err instanceof WebOperationError) {
|
|
153
101
|
m2 =
|
|
154
102
|
'You are not authorized to edit your preference file. This may be because you are using an untrusted web app.';
|
|
155
103
|
debug.warn(m2);
|
|
156
104
|
}
|
|
157
|
-
else if (err instanceof
|
|
105
|
+
else if (err instanceof FetchError) {
|
|
158
106
|
m2 = `Strange: Error ${err.status} trying to read your preference file.${err.message}`;
|
|
159
|
-
|
|
107
|
+
alert(m2);
|
|
160
108
|
}
|
|
161
109
|
else {
|
|
162
110
|
throw new Error(`(via loadPrefs) ${err}`);
|
|
@@ -172,7 +120,7 @@ async function ensureLoadedPreferences(context) {
|
|
|
172
120
|
* @returns Resolves with the context after login / fetch
|
|
173
121
|
*/
|
|
174
122
|
// used to be logInLoadProfile
|
|
175
|
-
async function ensureLoadedProfile(context) {
|
|
123
|
+
export async function ensureLoadedProfile(context) {
|
|
176
124
|
if (context.publicProfile) {
|
|
177
125
|
return context;
|
|
178
126
|
} // already done
|
|
@@ -196,7 +144,7 @@ async function ensureLoadedProfile(context) {
|
|
|
196
144
|
*
|
|
197
145
|
* leaving the `isPublic` param undefined will bring in community index things, too
|
|
198
146
|
*/
|
|
199
|
-
async function findAppInstances(context, theClass, isPublic) {
|
|
147
|
+
export async function findAppInstances(context, theClass, isPublic) {
|
|
200
148
|
let items = context.me ? await getScopedAppInstances(theClass, context.me) : [];
|
|
201
149
|
if (isPublic === true) { // old API - not recommended!
|
|
202
150
|
items = items.filter(item => item.scope.label === 'public');
|
|
@@ -207,7 +155,7 @@ async function findAppInstances(context, theClass, isPublic) {
|
|
|
207
155
|
context.instances = items.map(item => item.instance);
|
|
208
156
|
return context;
|
|
209
157
|
}
|
|
210
|
-
function scopeLabel(context, scope) {
|
|
158
|
+
export function scopeLabel(context, scope) {
|
|
211
159
|
const mine = context.me && context.me.sameTerm(scope.agent);
|
|
212
160
|
const name = mine ? '' : utils.label(scope.agent) + ' ';
|
|
213
161
|
return `${name}${scope.label}`;
|
|
@@ -215,20 +163,20 @@ function scopeLabel(context, scope) {
|
|
|
215
163
|
/**
|
|
216
164
|
* UI to control registration of instance
|
|
217
165
|
*/
|
|
218
|
-
async function registrationControl(context, instance, theClass) {
|
|
166
|
+
export async function registrationControl(context, instance, theClass) {
|
|
219
167
|
function registrationStatements(index) {
|
|
220
168
|
const registrations = getRegistrations(instance, theClass);
|
|
221
169
|
const reg = registrations.length ? registrations[0] : widgets.newThing(index);
|
|
222
170
|
return [
|
|
223
|
-
|
|
224
|
-
|
|
171
|
+
st(reg, ns.solid('instance'), instance, index),
|
|
172
|
+
st(reg, ns.solid('forClass'), theClass, index)
|
|
225
173
|
];
|
|
226
174
|
}
|
|
227
175
|
function renderScopeCheckbox(scope) {
|
|
228
176
|
const statements = registrationStatements(scope.index);
|
|
229
177
|
const name = scopeLabel(context, scope);
|
|
230
178
|
const label = `${name} link to this ${context.noun}`;
|
|
231
|
-
return widgets.buildCheckboxForm(context.dom,
|
|
179
|
+
return widgets.buildCheckboxForm(context.dom, solidLogicSingleton.store, label, null, statements, form, scope.index);
|
|
232
180
|
}
|
|
233
181
|
/// / body of registrationControl
|
|
234
182
|
const dom = context.dom;
|
|
@@ -237,7 +185,7 @@ async function registrationControl(context, instance, theClass) {
|
|
|
237
185
|
}
|
|
238
186
|
const box = dom.createElement('div');
|
|
239
187
|
context.div.appendChild(box);
|
|
240
|
-
context.me =
|
|
188
|
+
context.me = authn.currentUser(); // @@
|
|
241
189
|
const me = context.me;
|
|
242
190
|
if (!me) {
|
|
243
191
|
box.innerHTML = '<p style="margin:2em;">(Log in to save a link to this)</p>';
|
|
@@ -263,14 +211,14 @@ async function registrationControl(context, instance, theClass) {
|
|
|
263
211
|
box.innerHTML = '<table><tbody></tbody></table>'; // tbody will be inserted anyway
|
|
264
212
|
box.setAttribute('style', 'font-size: 120%; text-align: right; padding: 1em; border: solid gray 0.05em;');
|
|
265
213
|
const tbody = box.children[0].children[0];
|
|
266
|
-
const form = new
|
|
214
|
+
const form = new BlankNode(); // @@ say for now
|
|
267
215
|
for (const scope of scopes) {
|
|
268
216
|
const row = tbody.appendChild(dom.createElement('tr'));
|
|
269
217
|
row.appendChild(renderScopeCheckbox(scope)); // @@ index
|
|
270
218
|
}
|
|
271
219
|
return context;
|
|
272
220
|
}
|
|
273
|
-
function renderScopeHeadingRow(context, store, scope) {
|
|
221
|
+
export function renderScopeHeadingRow(context, store, scope) {
|
|
274
222
|
const backgroundColor = { private: '#fee', public: '#efe' };
|
|
275
223
|
const { dom } = context;
|
|
276
224
|
const name = scopeLabel(context, scope);
|
|
@@ -286,12 +234,12 @@ function renderScopeHeadingRow(context, store, scope) {
|
|
|
286
234
|
/**
|
|
287
235
|
* UI to List at all registered things
|
|
288
236
|
*/
|
|
289
|
-
async function registrationList(context, options) {
|
|
237
|
+
export async function registrationList(context, options) {
|
|
290
238
|
const dom = context.dom;
|
|
291
239
|
const div = context.div;
|
|
292
240
|
const box = dom.createElement('div');
|
|
293
241
|
div.appendChild(box);
|
|
294
|
-
context.me =
|
|
242
|
+
context.me = authn.currentUser(); // @@
|
|
295
243
|
if (!context.me) {
|
|
296
244
|
box.innerHTML = '<p style="margin:2em;">(Log in list your stuff)</p>';
|
|
297
245
|
return context;
|
|
@@ -310,7 +258,7 @@ async function registrationList(context, options) {
|
|
|
310
258
|
headingRow.style.display = 'none';
|
|
311
259
|
// console.log(`registrationList: @@ instance items for class ${options.type || 'undefined' }:`, items)
|
|
312
260
|
for (const item of items) {
|
|
313
|
-
const row = widgets.personTR(dom,
|
|
261
|
+
const row = widgets.personTR(dom, ns.solid('instance'), item.instance, {
|
|
314
262
|
deleteFunction: async () => {
|
|
315
263
|
await deleteTypeIndexRegistration(item);
|
|
316
264
|
tbody.removeChild(row);
|
|
@@ -333,7 +281,7 @@ async function registrationList(context, options) {
|
|
|
333
281
|
*/
|
|
334
282
|
function signInOrSignUpBox(dom, setUserCallback, options = {}) {
|
|
335
283
|
options = options || {};
|
|
336
|
-
const signInButtonStyle = options.buttonStyle ||
|
|
284
|
+
const signInButtonStyle = options.buttonStyle || style.signInAndUpButtonStyle;
|
|
337
285
|
const box = dom.createElement('div');
|
|
338
286
|
const magicClassName = 'SolidSignInOrSignUpBox';
|
|
339
287
|
debug.log('widgets.signInOrSignUpBox');
|
|
@@ -345,9 +293,9 @@ function signInOrSignUpBox(dom, setUserCallback, options = {}) {
|
|
|
345
293
|
box.appendChild(signInPopUpButton);
|
|
346
294
|
signInPopUpButton.setAttribute('type', 'button');
|
|
347
295
|
signInPopUpButton.setAttribute('value', 'Log in');
|
|
348
|
-
signInPopUpButton.setAttribute('style', `${signInButtonStyle}${
|
|
349
|
-
|
|
350
|
-
const me =
|
|
296
|
+
signInPopUpButton.setAttribute('style', `${signInButtonStyle}${style.headerBannerLoginInput}` + style.signUpBackground);
|
|
297
|
+
authSession.events.on('login', () => {
|
|
298
|
+
const me = authn.currentUser();
|
|
351
299
|
// const sessionInfo = authSession.info
|
|
352
300
|
// if (sessionInfo && sessionInfo.isLoggedIn) {
|
|
353
301
|
if (me) {
|
|
@@ -377,7 +325,7 @@ function signInOrSignUpBox(dom, setUserCallback, options = {}) {
|
|
|
377
325
|
}
|
|
378
326
|
});
|
|
379
327
|
signInPopUpButton.addEventListener('click', () => {
|
|
380
|
-
const offline =
|
|
328
|
+
const offline = offlineTestID();
|
|
381
329
|
if (offline)
|
|
382
330
|
return setUserCallback(offline.uri);
|
|
383
331
|
renderSignInPopup(dom);
|
|
@@ -387,9 +335,9 @@ function signInOrSignUpBox(dom, setUserCallback, options = {}) {
|
|
|
387
335
|
box.appendChild(signupButton);
|
|
388
336
|
signupButton.setAttribute('type', 'button');
|
|
389
337
|
signupButton.setAttribute('value', 'Sign Up for Solid');
|
|
390
|
-
signupButton.setAttribute('style', `${signInButtonStyle}${
|
|
338
|
+
signupButton.setAttribute('style', `${signInButtonStyle}${style.headerBannerLoginInput}` + style.signInBackground);
|
|
391
339
|
signupButton.addEventListener('click', function (_event) {
|
|
392
|
-
const signupMgr = new
|
|
340
|
+
const signupMgr = new Signup();
|
|
393
341
|
signupMgr.signup().then(function (uri) {
|
|
394
342
|
debug.log('signInOrSignUpBox signed up ' + uri);
|
|
395
343
|
setUserCallback(uri);
|
|
@@ -397,7 +345,7 @@ function signInOrSignUpBox(dom, setUserCallback, options = {}) {
|
|
|
397
345
|
}, false);
|
|
398
346
|
return box;
|
|
399
347
|
}
|
|
400
|
-
function renderSignInPopup(dom) {
|
|
348
|
+
export function renderSignInPopup(dom) {
|
|
401
349
|
/**
|
|
402
350
|
* Issuer Menu
|
|
403
351
|
*/
|
|
@@ -441,7 +389,7 @@ function renderSignInPopup(dom) {
|
|
|
441
389
|
const loginToIssuer = async (issuerUri) => {
|
|
442
390
|
try {
|
|
443
391
|
// clear authorization metadata from store
|
|
444
|
-
|
|
392
|
+
solidLogicSingleton.store.updater.flagAuthorizationMetadata();
|
|
445
393
|
// Save hash
|
|
446
394
|
const preLoginRedirectHash = new URL(window.location.href).hash;
|
|
447
395
|
if (preLoginRedirectHash) {
|
|
@@ -451,13 +399,13 @@ function renderSignInPopup(dom) {
|
|
|
451
399
|
// Login
|
|
452
400
|
const locationUrl = new URL(window.location.href);
|
|
453
401
|
locationUrl.hash = ''; // remove hash part
|
|
454
|
-
await
|
|
402
|
+
await authSession.login({
|
|
455
403
|
redirectUrl: locationUrl.href,
|
|
456
404
|
oidcIssuer: issuerUri
|
|
457
405
|
});
|
|
458
406
|
}
|
|
459
407
|
catch (err) {
|
|
460
|
-
|
|
408
|
+
alert(err.message);
|
|
461
409
|
}
|
|
462
410
|
};
|
|
463
411
|
/**
|
|
@@ -507,7 +455,7 @@ function renderSignInPopup(dom) {
|
|
|
507
455
|
issuerBottonLabel.innerText = 'Or pick an identity provider from the list below:';
|
|
508
456
|
issuerBottonLabel.setAttribute('style', 'color: #888');
|
|
509
457
|
issuerButtonContainer.appendChild(issuerBottonLabel);
|
|
510
|
-
|
|
458
|
+
getSuggestedIssuers().forEach((issuerInfo) => {
|
|
511
459
|
const issuerButton = dom.createElement('button');
|
|
512
460
|
issuerButton.innerText = issuerInfo.name;
|
|
513
461
|
issuerButton.setAttribute('style', 'height: 38px; margin-top: 10px');
|
|
@@ -528,9 +476,9 @@ function renderSignInPopup(dom) {
|
|
|
528
476
|
*
|
|
529
477
|
* @returns
|
|
530
478
|
*/
|
|
531
|
-
function loginStatusBox(dom, listener = null, options = {}) {
|
|
479
|
+
export function loginStatusBox(dom, listener = null, options = {}) {
|
|
532
480
|
// 20190630
|
|
533
|
-
let me =
|
|
481
|
+
let me = offlineTestID();
|
|
534
482
|
// @@ TODO Remove the need to cast HTML element to any
|
|
535
483
|
const box = dom.createElement('div');
|
|
536
484
|
function setIt(newidURI) {
|
|
@@ -539,35 +487,35 @@ function loginStatusBox(dom, listener = null, options = {}) {
|
|
|
539
487
|
}
|
|
540
488
|
// const uri = newidURI.uri || newidURI
|
|
541
489
|
// me = sym(uri)
|
|
542
|
-
me =
|
|
490
|
+
me = authn.saveUser(newidURI);
|
|
543
491
|
box.refresh();
|
|
544
492
|
if (listener)
|
|
545
493
|
listener(me.uri);
|
|
546
494
|
}
|
|
547
495
|
function logoutButtonHandler(_event) {
|
|
548
496
|
const oldMe = me;
|
|
549
|
-
|
|
497
|
+
authSession.logout().then(function () {
|
|
550
498
|
const message = `Your WebID was ${oldMe}. It has been forgotten.`;
|
|
551
499
|
me = null;
|
|
552
500
|
try {
|
|
553
|
-
|
|
501
|
+
alert(message);
|
|
554
502
|
}
|
|
555
|
-
catch (
|
|
503
|
+
catch (_e) {
|
|
556
504
|
window.alert(message);
|
|
557
505
|
}
|
|
558
506
|
box.refresh();
|
|
559
507
|
if (listener)
|
|
560
508
|
listener(null);
|
|
561
509
|
}, (err) => {
|
|
562
|
-
|
|
510
|
+
alert('Fail to log out:' + err);
|
|
563
511
|
});
|
|
564
512
|
}
|
|
565
513
|
function logoutButton(me, options) {
|
|
566
|
-
const signInButtonStyle = options.buttonStyle ||
|
|
514
|
+
const signInButtonStyle = options.buttonStyle || style.signInAndUpButtonStyle;
|
|
567
515
|
let logoutLabel = 'WebID logout';
|
|
568
516
|
if (me) {
|
|
569
|
-
const nick =
|
|
570
|
-
|
|
517
|
+
const nick = solidLogicSingleton.store.any(me, ns.foaf('nick')) ||
|
|
518
|
+
solidLogicSingleton.store.any(me, ns.foaf('name'));
|
|
571
519
|
if (nick) {
|
|
572
520
|
logoutLabel = 'Logout ' + nick.value;
|
|
573
521
|
}
|
|
@@ -581,9 +529,9 @@ function loginStatusBox(dom, listener = null, options = {}) {
|
|
|
581
529
|
return signOutButton;
|
|
582
530
|
}
|
|
583
531
|
box.refresh = function () {
|
|
584
|
-
const sessionInfo =
|
|
532
|
+
const sessionInfo = authSession.info;
|
|
585
533
|
if (sessionInfo && sessionInfo.webId && sessionInfo.isLoggedIn) {
|
|
586
|
-
me =
|
|
534
|
+
me = solidLogicSingleton.store.sym(sessionInfo.webId);
|
|
587
535
|
}
|
|
588
536
|
else {
|
|
589
537
|
me = null;
|
|
@@ -601,22 +549,22 @@ function loginStatusBox(dom, listener = null, options = {}) {
|
|
|
601
549
|
};
|
|
602
550
|
box.refresh();
|
|
603
551
|
function trackSession() {
|
|
604
|
-
me =
|
|
552
|
+
me = authn.currentUser();
|
|
605
553
|
box.refresh();
|
|
606
554
|
}
|
|
607
555
|
trackSession();
|
|
608
|
-
|
|
609
|
-
|
|
556
|
+
authSession.events.on('login', trackSession);
|
|
557
|
+
authSession.events.on('logout', trackSession);
|
|
610
558
|
box.me = '99999'; // Force refresh
|
|
611
559
|
box.refresh();
|
|
612
560
|
return box;
|
|
613
561
|
}
|
|
614
|
-
|
|
562
|
+
authSession.events.on('logout', async () => {
|
|
615
563
|
const issuer = window.localStorage.getItem('loginIssuer');
|
|
616
564
|
if (issuer) {
|
|
617
565
|
try {
|
|
618
566
|
// clear authorization metadata from store
|
|
619
|
-
|
|
567
|
+
solidLogicSingleton.store.updater.flagAuthorizationMetadata();
|
|
620
568
|
const wellKnownUri = new URL(issuer);
|
|
621
569
|
wellKnownUri.pathname = '/.well-known/openid-configuration';
|
|
622
570
|
const wellKnownResult = await fetch(wellKnownUri.toString());
|
|
@@ -627,7 +575,7 @@ solid_logic_1.authSession.events.on('logout', async () => {
|
|
|
627
575
|
}
|
|
628
576
|
}
|
|
629
577
|
}
|
|
630
|
-
catch (
|
|
578
|
+
catch (_err) {
|
|
631
579
|
// Do nothing
|
|
632
580
|
}
|
|
633
581
|
}
|
|
@@ -655,17 +603,17 @@ solid_logic_1.authSession.events.on('logout', async () => {
|
|
|
655
603
|
* @param appDetails
|
|
656
604
|
* @param callbackWS
|
|
657
605
|
*/
|
|
658
|
-
function selectWorkspace(dom, appDetails, callbackWS) {
|
|
606
|
+
export function selectWorkspace(dom, appDetails, callbackWS) {
|
|
659
607
|
const noun = appDetails.noun;
|
|
660
608
|
const appPathSegment = appDetails.appPathSegment;
|
|
661
|
-
const me =
|
|
609
|
+
const me = offlineTestID();
|
|
662
610
|
const box = dom.createElement('div');
|
|
663
611
|
const context = { me, dom, div: box };
|
|
664
612
|
function say(s, background) {
|
|
665
613
|
box.appendChild(widgets.errorMessageBlock(dom, s, background));
|
|
666
614
|
}
|
|
667
615
|
function figureOutBase(ws) {
|
|
668
|
-
const newBaseNode =
|
|
616
|
+
const newBaseNode = solidLogicSingleton.store.any(ws, ns.space('uriPrefix'));
|
|
669
617
|
let newBaseString;
|
|
670
618
|
if (!newBaseNode) {
|
|
671
619
|
newBaseString = ws.uri.split('#')[0];
|
|
@@ -688,16 +636,16 @@ function selectWorkspace(dom, appDetails, callbackWS) {
|
|
|
688
636
|
const cell = row.appendChild(dom.createElement('td'));
|
|
689
637
|
cell.setAttribute('colspan', '3');
|
|
690
638
|
cell.style.padding = '0.5em';
|
|
691
|
-
const newBase = encodeURI(await widgets.askName(dom,
|
|
639
|
+
const newBase = encodeURI(await widgets.askName(dom, solidLogicSingleton.store, cell, ns.solid('URL'), ns.space('Workspace'), 'Workspace'));
|
|
692
640
|
const newWs = widgets.newThing(context.preferencesFile);
|
|
693
641
|
const newData = [
|
|
694
|
-
|
|
695
|
-
|
|
642
|
+
st(context.me, ns.space('workspace'), newWs, context.preferencesFile),
|
|
643
|
+
st(newWs, ns.space('uriPrefix'), newBase, context.preferencesFile)
|
|
696
644
|
];
|
|
697
|
-
if (!
|
|
645
|
+
if (!solidLogicSingleton.store.updater) {
|
|
698
646
|
throw new Error('store has no updater');
|
|
699
647
|
}
|
|
700
|
-
await
|
|
648
|
+
await solidLogicSingleton.store.updater.update([], newData);
|
|
701
649
|
// @@ now refresh list of workspaces
|
|
702
650
|
}
|
|
703
651
|
// const status = ''
|
|
@@ -705,14 +653,14 @@ function selectWorkspace(dom, appDetails, callbackWS) {
|
|
|
705
653
|
const preferencesFile = context.preferencesFile;
|
|
706
654
|
let newBase = null;
|
|
707
655
|
// A workspace specifically defined in the private preference file:
|
|
708
|
-
let w =
|
|
656
|
+
let w = solidLogicSingleton.store.each(id, ns.space('workspace'), undefined, preferencesFile); // Only trust preference file here
|
|
709
657
|
// A workspace in a storage in the public profile:
|
|
710
|
-
const storages =
|
|
658
|
+
const storages = solidLogicSingleton.store.each(id, ns.space('storage')); // @@ No provenance requirement at the moment
|
|
711
659
|
if (w.length === 0 && storages) {
|
|
712
660
|
say(`You don't seem to have any workspaces. You have ${storages.length} storage spaces.`, 'white');
|
|
713
661
|
storages
|
|
714
662
|
.map(function (s) {
|
|
715
|
-
w = w.concat(
|
|
663
|
+
w = w.concat(solidLogicSingleton.store.each(s, ns.ldp('contains')));
|
|
716
664
|
return w;
|
|
717
665
|
})
|
|
718
666
|
.filter((file) => {
|
|
@@ -735,14 +683,14 @@ function selectWorkspace(dom, appDetails, callbackWS) {
|
|
|
735
683
|
// const hr = box.appendChild(dom.createElement('hr')) // @@
|
|
736
684
|
box.appendChild(dom.createElement('hr')); // @@
|
|
737
685
|
const p = box.appendChild(dom.createElement('p'));
|
|
738
|
-
p.setAttribute('style',
|
|
686
|
+
p.setAttribute('style', style.commentStyle);
|
|
739
687
|
p.textContent = `Where would you like to store the data for the ${noun}?
|
|
740
688
|
Give the URL of the folder where you would like the data stored.
|
|
741
689
|
It can be anywhere in solid world - this URI is just an idea.`;
|
|
742
690
|
// @@ TODO Remove the need to cast baseField to any
|
|
743
691
|
const baseField = box.appendChild(dom.createElement('input'));
|
|
744
692
|
baseField.setAttribute('type', 'text');
|
|
745
|
-
baseField.setAttribute('style',
|
|
693
|
+
baseField.setAttribute('style', style.textInputStyle);
|
|
746
694
|
baseField.size = 80; // really a string
|
|
747
695
|
baseField.label = 'base URL';
|
|
748
696
|
baseField.autocomplete = 'on';
|
|
@@ -753,7 +701,7 @@ function selectWorkspace(dom, appDetails, callbackWS) {
|
|
|
753
701
|
context.baseField = baseField;
|
|
754
702
|
box.appendChild(dom.createElement('br')); // @@
|
|
755
703
|
const button = box.appendChild(dom.createElement('button'));
|
|
756
|
-
button.setAttribute('style',
|
|
704
|
+
button.setAttribute('style', style.buttonStyle);
|
|
757
705
|
button.textContent = `Start new ${noun} at this URI`;
|
|
758
706
|
button.addEventListener('click', function (_event) {
|
|
759
707
|
let newBase = baseField.value.replace(' ', '%20'); // do not re-encode in general, as % encodings may exist
|
|
@@ -765,8 +713,8 @@ function selectWorkspace(dom, appDetails, callbackWS) {
|
|
|
765
713
|
// Now go set up the table of spaces
|
|
766
714
|
// const row = 0
|
|
767
715
|
w = w.filter(function (x) {
|
|
768
|
-
return !
|
|
769
|
-
|
|
716
|
+
return !solidLogicSingleton.store.holds(x, ns.rdf('type'), // Ignore master workspaces
|
|
717
|
+
ns.space('MasterWorkspace'));
|
|
770
718
|
});
|
|
771
719
|
let col1, col2, col3, tr, ws, localStyle, comment;
|
|
772
720
|
const cellStyle = 'height: 3em; margin: 1em; padding: 1em white; border-radius: 0.3em;';
|
|
@@ -783,7 +731,7 @@ function selectWorkspace(dom, appDetails, callbackWS) {
|
|
|
783
731
|
tr.appendChild(col1);
|
|
784
732
|
}
|
|
785
733
|
col2 = dom.createElement('td');
|
|
786
|
-
localStyle =
|
|
734
|
+
localStyle = solidLogicSingleton.store.anyValue(ws, ns.ui('style'));
|
|
787
735
|
if (!localStyle) {
|
|
788
736
|
// Otherwise make up arbitrary colour
|
|
789
737
|
const hash = function (x) {
|
|
@@ -797,7 +745,7 @@ function selectWorkspace(dom, appDetails, callbackWS) {
|
|
|
797
745
|
}
|
|
798
746
|
col2.setAttribute('style', deselectedStyle + localStyle);
|
|
799
747
|
tr.target = ws.uri;
|
|
800
|
-
let label =
|
|
748
|
+
let label = solidLogicSingleton.store.any(ws, ns.rdfs('label'));
|
|
801
749
|
if (!label) {
|
|
802
750
|
label = ws.uri.split('/').slice(-1)[0] || ws.uri.split('/').slice(-2)[0];
|
|
803
751
|
}
|
|
@@ -811,7 +759,7 @@ function selectWorkspace(dom, appDetails, callbackWS) {
|
|
|
811
759
|
tr.appendChild(col3);
|
|
812
760
|
}
|
|
813
761
|
table.appendChild(tr);
|
|
814
|
-
comment =
|
|
762
|
+
comment = solidLogicSingleton.store.any(ws, ns.rdfs('comment'));
|
|
815
763
|
comment = comment ? comment.value : 'Use this workspace';
|
|
816
764
|
col2.addEventListener('click', function (_event) {
|
|
817
765
|
col3.textContent = comment ? comment.value : '';
|
|
@@ -863,7 +811,7 @@ function selectWorkspace(dom, appDetails, callbackWS) {
|
|
|
863
811
|
*
|
|
864
812
|
* @returns A div with a button in it for making a new app instance
|
|
865
813
|
*/
|
|
866
|
-
function newAppInstance(dom, appDetails, callback) {
|
|
814
|
+
export function newAppInstance(dom, appDetails, callback) {
|
|
867
815
|
const gotWS = function (ws, base) {
|
|
868
816
|
// log.debug("newAppInstance: Selected workspace = " + (ws? ws.uri : 'none'))
|
|
869
817
|
callback(ws, base);
|
|
@@ -883,13 +831,13 @@ function newAppInstance(dom, appDetails, callback) {
|
|
|
883
831
|
* Retrieves whether the currently logged in user is a power user
|
|
884
832
|
* and/or a developer
|
|
885
833
|
*/
|
|
886
|
-
async function getUserRoles() {
|
|
834
|
+
export async function getUserRoles() {
|
|
887
835
|
try {
|
|
888
836
|
const { me, preferencesFile, preferencesFileError } = await ensureLoadedPreferences({});
|
|
889
837
|
if (!preferencesFile || preferencesFileError) {
|
|
890
838
|
throw new Error(preferencesFileError);
|
|
891
839
|
}
|
|
892
|
-
return
|
|
840
|
+
return solidLogicSingleton.store.each(me, ns.rdf('type'), null, preferencesFile.doc());
|
|
893
841
|
}
|
|
894
842
|
catch (error) {
|
|
895
843
|
debug.warn('Unable to fetch your preferences - this was the error: ', error);
|
|
@@ -899,7 +847,7 @@ async function getUserRoles() {
|
|
|
899
847
|
/**
|
|
900
848
|
* Filters which panes should be available, based on the result of [[getUserRoles]]
|
|
901
849
|
*/
|
|
902
|
-
async function filterAvailablePanes(panes) {
|
|
850
|
+
export async function filterAvailablePanes(panes) {
|
|
903
851
|
const userRoles = await getUserRoles();
|
|
904
852
|
return panes.filter((pane) => isMatchingAudience(pane, userRoles));
|
|
905
853
|
}
|