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