solid-ui 2.4.21 → 2.4.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -8
- package/dist/main.js +215 -167
- package/dist/main.js.map +1 -1
- package/lib/acl/access-controller.js +2 -2
- package/lib/acl/access-controller.js.map +1 -1
- package/lib/acl/access-groups.d.ts +1 -1
- package/lib/acl/access-groups.js +1 -1
- package/lib/acl/access-groups.js.map +1 -1
- package/lib/acl/acl-control.d.ts +2 -2
- package/lib/acl/acl-control.js +5 -5
- package/lib/acl/acl-control.js.map +1 -1
- package/lib/acl/acl.d.ts +1 -1
- package/lib/acl/acl.js +1 -1
- package/lib/acl/acl.js.map +1 -1
- package/lib/acl/add-agent-buttons.d.ts +1 -1
- package/lib/acl/add-agent-buttons.js +1 -1
- package/lib/acl/add-agent-buttons.js.map +1 -1
- package/lib/acl/styles.d.ts +1 -1
- package/lib/acl/styles.js +1 -1
- package/lib/acl/styles.js.map +1 -1
- package/lib/chat/infinite.js.map +1 -1
- package/lib/iconBase.d.ts.map +1 -1
- package/lib/iconBase.js +2 -2
- package/lib/iconBase.js.map +1 -1
- package/lib/index.js +1 -1
- package/lib/index.js.map +1 -1
- package/lib/jss/index.d.ts +2 -2
- package/lib/jss/index.js +2 -2
- package/lib/jss/index.js.map +1 -1
- package/lib/login/login.d.ts +57 -57
- package/lib/login/login.d.ts.map +1 -1
- package/lib/login/login.js +74 -72
- package/lib/login/login.js.map +1 -1
- package/lib/participation.js +1 -1
- package/lib/participation.js.map +1 -1
- package/lib/tabs.d.ts +1 -1
- package/lib/tabs.d.ts.map +1 -1
- package/lib/tabs.js +5 -3
- package/lib/tabs.js.map +1 -1
- package/lib/utils/headerFooterHelpers.d.ts.map +1 -1
- package/lib/utils/headerFooterHelpers.js +51 -30
- package/lib/utils/headerFooterHelpers.js.map +1 -1
- package/lib/versionInfo.d.ts +9 -11
- package/lib/versionInfo.d.ts.map +1 -1
- package/lib/versionInfo.js +16 -18
- package/lib/versionInfo.js.map +1 -1
- package/lib/widgets/forms/autocomplete/language.js.map +1 -1
- package/lib/widgets/forms/autocomplete/publicData.js +1 -1
- package/lib/widgets/forms/autocomplete/publicData.js.map +1 -1
- package/package.json +7 -6
package/lib/login/login.js
CHANGED
|
@@ -46,6 +46,8 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
|
|
|
46
46
|
|
|
47
47
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
48
48
|
|
|
49
|
+
/* eslint-disable camelcase */
|
|
50
|
+
|
|
49
51
|
/**
|
|
50
52
|
* Signing in, signing up, profile and preferences reloading
|
|
51
53
|
* Type index management
|
|
@@ -72,10 +74,10 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
|
|
|
72
74
|
*/
|
|
73
75
|
|
|
74
76
|
/**
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
77
|
+
* Resolves with the logged in user's WebID
|
|
78
|
+
*
|
|
79
|
+
* @param context
|
|
80
|
+
*/
|
|
79
81
|
// used to be logIn
|
|
80
82
|
function ensureLoggedIn(context) {
|
|
81
83
|
var me = _solidLogic.authn.currentUser();
|
|
@@ -269,11 +271,11 @@ function ensureLoadedProfile(_x3) {
|
|
|
269
271
|
return _ensureLoadedProfile.apply(this, arguments);
|
|
270
272
|
}
|
|
271
273
|
/**
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
274
|
+
* Returns promise of context with arrays of symbols
|
|
275
|
+
*
|
|
276
|
+
* 2016-12-11 change to include forClass arc a la
|
|
277
|
+
* https://github.com/solid/solid/blob/main/proposals/data-discovery.md
|
|
278
|
+
*/
|
|
277
279
|
|
|
278
280
|
|
|
279
281
|
function _ensureLoadedProfile() {
|
|
@@ -341,8 +343,8 @@ function findAppInstances(_x4, _x5, _x6) {
|
|
|
341
343
|
return _findAppInstances.apply(this, arguments);
|
|
342
344
|
}
|
|
343
345
|
/**
|
|
344
|
-
|
|
345
|
-
|
|
346
|
+
* UI to control registration of instance
|
|
347
|
+
*/
|
|
346
348
|
|
|
347
349
|
|
|
348
350
|
function _findAppInstances() {
|
|
@@ -491,8 +493,8 @@ function registrationControl(_x7, _x8, _x9) {
|
|
|
491
493
|
return _registrationControl.apply(this, arguments);
|
|
492
494
|
}
|
|
493
495
|
/**
|
|
494
|
-
|
|
495
|
-
|
|
496
|
+
* UI to List at all registered things
|
|
497
|
+
*/
|
|
496
498
|
|
|
497
499
|
|
|
498
500
|
function _registrationControl() {
|
|
@@ -718,14 +720,14 @@ function getDefaultSignInButtonStyle() {
|
|
|
718
720
|
return 'padding: 1em; border-radius:0.5em; font-size: 100%;';
|
|
719
721
|
}
|
|
720
722
|
/**
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
723
|
+
* Bootstrapping identity
|
|
724
|
+
* (Called by `loginStatusBox()`)
|
|
725
|
+
*
|
|
726
|
+
* @param dom
|
|
727
|
+
* @param setUserCallback
|
|
728
|
+
*
|
|
729
|
+
* @returns
|
|
730
|
+
*/
|
|
729
731
|
|
|
730
732
|
|
|
731
733
|
function signInOrSignUpBox(dom, setUserCallback) {
|
|
@@ -803,8 +805,8 @@ function signInOrSignUpBox(dom, setUserCallback) {
|
|
|
803
805
|
|
|
804
806
|
function renderSignInPopup(dom) {
|
|
805
807
|
/**
|
|
806
|
-
|
|
807
|
-
|
|
808
|
+
* Issuer Menu
|
|
809
|
+
*/
|
|
808
810
|
var issuerPopup = dom.createElement('div');
|
|
809
811
|
issuerPopup.setAttribute('style', 'position: fixed; top: 0; left: 0; right: 0; bottom: 0; display: flex; justify-content: center; align-items: center;');
|
|
810
812
|
dom.body.appendChild(issuerPopup);
|
|
@@ -818,7 +820,7 @@ function renderSignInPopup(dom) {
|
|
|
818
820
|
issuerPopupBoxLabel.setAttribute('style', 'margin-right: 5px; font-weight: 800');
|
|
819
821
|
issuerPopupBoxLabel.innerText = 'Select an identity provider';
|
|
820
822
|
var issuerPopupBoxCloseButton = dom.createElement('button');
|
|
821
|
-
issuerPopupBoxCloseButton.innerHTML = '<img src="https://
|
|
823
|
+
issuerPopupBoxCloseButton.innerHTML = '<img src="https://solidos.github.io/solid-ui/src/icons/noun_1180156.svg" style="width: 2em; height: 2em;" title="Cancel">';
|
|
822
824
|
issuerPopupBoxCloseButton.setAttribute('style', 'background-color: transparent; border: none;');
|
|
823
825
|
issuerPopupBoxCloseButton.addEventListener('click', function () {
|
|
824
826
|
issuerPopup.remove();
|
|
@@ -871,8 +873,8 @@ function renderSignInPopup(dom) {
|
|
|
871
873
|
};
|
|
872
874
|
}();
|
|
873
875
|
/**
|
|
874
|
-
|
|
875
|
-
|
|
876
|
+
* Text-based idp selection
|
|
877
|
+
*/
|
|
876
878
|
|
|
877
879
|
|
|
878
880
|
var issuerTextContainer = dom.createElement('div');
|
|
@@ -899,8 +901,8 @@ function renderSignInPopup(dom) {
|
|
|
899
901
|
issuerTextContainer.appendChild(issuerTextInputContainer);
|
|
900
902
|
issuerPopupBox.appendChild(issuerTextContainer);
|
|
901
903
|
/**
|
|
902
|
-
|
|
903
|
-
|
|
904
|
+
* Button-based idp selection
|
|
905
|
+
*/
|
|
904
906
|
|
|
905
907
|
var issuerButtonContainer = dom.createElement('div');
|
|
906
908
|
issuerButtonContainer.setAttribute('style', "\n display: flex;\n flex-direction: column;\n padding-top: 10px;\n ");
|
|
@@ -920,15 +922,15 @@ function renderSignInPopup(dom) {
|
|
|
920
922
|
issuerPopupBox.appendChild(issuerButtonContainer);
|
|
921
923
|
}
|
|
922
924
|
/**
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
925
|
+
* Login status box
|
|
926
|
+
*
|
|
927
|
+
* A big sign-up/sign in box or a logout box depending on the state
|
|
928
|
+
*
|
|
929
|
+
* @param dom
|
|
930
|
+
* @param listener
|
|
931
|
+
*
|
|
932
|
+
* @returns
|
|
933
|
+
*/
|
|
932
934
|
|
|
933
935
|
|
|
934
936
|
function loginStatusBox(dom) {
|
|
@@ -1089,28 +1091,28 @@ _solidLogic.authSession.onLogout( /*#__PURE__*/(0, _asyncToGenerator2["default"]
|
|
|
1089
1091
|
}, _callee2, null, [[2, 17]]);
|
|
1090
1092
|
})));
|
|
1091
1093
|
/**
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1094
|
+
* Workspace selection etc
|
|
1095
|
+
* See https://github.com/solidos/userguide/issues/16
|
|
1096
|
+
*/
|
|
1095
1097
|
|
|
1096
1098
|
/**
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1099
|
+
* Returns a UI object which, if it selects a workspace,
|
|
1100
|
+
* will callback(workspace, newBase).
|
|
1101
|
+
* See https://github.com/solidos/userguide/issues/16 for more info on workspaces.
|
|
1102
|
+
*
|
|
1103
|
+
* If necessary, will get an account, preference file, etc. In sequence:
|
|
1104
|
+
*
|
|
1105
|
+
* - If not logged in, log in.
|
|
1106
|
+
* - Load preference file
|
|
1107
|
+
* - Prompt user for workspaces
|
|
1108
|
+
* - Allows the user to just type in a URI by hand
|
|
1109
|
+
*
|
|
1110
|
+
* Calls back with the workspace and the base URI
|
|
1111
|
+
*
|
|
1112
|
+
* @param dom
|
|
1113
|
+
* @param appDetails
|
|
1114
|
+
* @param callbackWS
|
|
1115
|
+
*/
|
|
1114
1116
|
|
|
1115
1117
|
|
|
1116
1118
|
function selectWorkspace(dom, appDetails, callbackWS) {
|
|
@@ -1373,21 +1375,21 @@ function selectWorkspace(dom, appDetails, callbackWS) {
|
|
|
1373
1375
|
} // selectWorkspace
|
|
1374
1376
|
|
|
1375
1377
|
/**
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1378
|
+
* Creates a new instance of an app.
|
|
1379
|
+
*
|
|
1380
|
+
* An instance of an app could be e.g. an issue tracker for a given project,
|
|
1381
|
+
* or a chess game, or calendar, or a health/fitness record for a person.
|
|
1382
|
+
*
|
|
1383
|
+
* Note that this use of the term 'app' refers more to entries in the user's
|
|
1384
|
+
* type index than to actual software applications that use the personal data
|
|
1385
|
+
* to which these entries point.
|
|
1386
|
+
*
|
|
1387
|
+
* @param dom
|
|
1388
|
+
* @param appDetails
|
|
1389
|
+
* @param callback
|
|
1390
|
+
*
|
|
1391
|
+
* @returns A div with a button in it for making a new app instance
|
|
1392
|
+
*/
|
|
1391
1393
|
|
|
1392
1394
|
|
|
1393
1395
|
function newAppInstance(dom, appDetails, callback) {
|
package/lib/login/login.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/login/login.ts"],"names":["ensureLoggedIn","context","me","authn","currentUser","saveUser","Promise","resolve","checkUser","then","webId","debug","log","div","dom","box","loginStatusBox","webIdUri","appendChild","ensureLoadedPreferences","complain","message","statusArea","widgets","errorMessageBlock","preferencesFile","ensureLoadedProfile","solidLogicSingleton","loadPreferences","progressDisplay","parentNode","removeChild","UnauthorizedError","m2","CrossOriginForbiddenError","window","location","origin","preferencesFileError","SameOriginForbiddenError","warn","NotFoundError","confirm","Error","FetchError","status","publicProfile","logInContext","loadProfile","findAppInstances","theClass","isPublic","unique","arr","Array","from","Set","undefined","visibility","error","index","thisIndex","registrations","map","ix","store","each","ns","solid","reduce","acc","curr","concat","instances","reg","containers","length","load","e","utils","label","i","cont","getContainerMembers","value","uri","sym","registrationControl","instance","createElement","innerHTML","context2","msg","textContent","setAttribute","tbody","children","form","BlankNode","registrationStatements","getRegistrations","newThing","statements","buildCheckboxForm","noun","registrationList","context0","options","table","firstChild","sts","vs","forEach","statementsMatching","statement","type","holds","subject","why","inst","object","personTR","deleteFunction","_x","updater","update","ok","errorBody","getDefaultSignInButtonStyle","signInOrSignUpBox","setUserCallback","signInButtonStyle","buttonStyle","magicClassName","style","signInPopUpButton","authSession","onLogin","webIdURI","divs","getElementsByClassName","parent","addEventListener","offline","renderSignInPopup","signupButton","_event","signupMgr","Signup","signup","issuerPopup","body","issuerPopupBox","issuerPopupBoxTopMenu","issuerPopupBoxLabel","innerText","issuerPopupBoxCloseButton","remove","loginToIssuer","issuerUri","preLoginRedirectHash","URL","href","hash","localStorage","setItem","login","redirectUrl","oidcIssuer","issuerTextContainer","issuerTextInputContainer","issuerTextLabel","issuerTextInput","getItem","issuerTextGoButton","issuerButtonContainer","issuerBottonLabel","issuerInfo","issuerButton","name","listener","setIt","newidURI","refresh","logoutButtonHandler","oldMe","logout","alert","err","logoutButton","logoutLabel","nick","any","foaf","signOutButton","clearElement","trackSession","onLogout","issuer","wellKnownUri","pathname","fetch","toString","wellKnownResult","json","openidConfiguration","end_session_endpoint","credentials","reload","selectWorkspace","appDetails","callbackWS","appPathSegment","say","s","background","figureOutBase","ws","newBaseNode","space","newBaseString","split","slice","now","Date","getTime","displayOptions","makeNewWorkspace","row","cell","padding","encodeURI","askName","newBase","newWs","newData","id","w","storages","ldp","filter","file","includes","toLowerCase","p","commentStyle","baseField","textInputStyle","size","autocomplete","button","replace","x","rdf","col1","col2","col3","tr","comment","cellStyle","deselectedStyle","anyValue","ui","a","b","charCodeAt","bgcolor","target","rdfs","disabled","trLast","newAppInstance","callback","gotWS","base","getUserRoles","doc","filterAvailablePanes","panes","userRoles","pane","isMatchingAudience","audience","isMatch","audienceRole","find","role","equals"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAyBA;;AAGA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;AAnCA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAcA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,cAAT,CAAyBC,OAAzB,EAAyF;AAC9F,MAAMC,EAAE,GAAGC,kBAAMC,WAAN,EAAX;;AACA,MAAIF,EAAJ,EAAQ;AACNC,sBAAME,QAAN,CAAeH,EAAf,EAAmBD,OAAnB;;AACA,WAAOK,OAAO,CAACC,OAAR,CAAgBN,OAAhB,CAAP;AACD;;AAED,SAAO,IAAIK,OAAJ,CAAY,UAAAC,OAAO,EAAI;AAC5BJ,sBAAMK,SAAN,GAAkBC,IAAlB,CAAuB,UAAAC,KAAK,EAAI;AAC9B;AACA,UAAIA,KAAJ,EAAW;AACTC,QAAAA,KAAK,CAACC,GAAN,uCAAyCF,KAAzC;AACA,eAAOH,OAAO,CAACN,OAAD,CAAd;AACD;;AACD,UAAI,CAACA,OAAO,CAACY,GAAT,IAAgB,CAACZ,OAAO,CAACa,GAA7B,EAAkC;AAChC,eAAOP,O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,CAACD,IAAD,EAAOD,SAAP,CAAtB;AAAA,aAAjB,CAFF;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,G;;;;AAKP,SAASE,kBAAT,CAA6BD,IAA7B,EAAmDD,SAAnD,EAAyF;AACvF,MAAMG,QAAQ,GAAGF,IAAI,CAACE,QAAL,IAAiB,EAAlC;AACA,SAAOA,QAAQ,CAACrN,MAAT,CACL,UAACsN,OAAD,EAAUC,YAAV;AAAA,WAA2BD,OAAO,IAAI,CAAC,CAACJ,SAAS,CAACM,IAAV,CAAe,UAAAC,IAAI;AAAA,aAAIA,IAAI,CAACC,MAAL,CAAYH,YAAZ,CAAJ;AAAA,KAAnB,CAAxC;AAAA,GADK,EAEL,IAFK,CAAP;AAID","sourcesContent":["/**\n * Signing in, signing up, profile and preferences reloading\n * Type index management\n *\n * Many functions in this module take a context object which\n * holds various RDF symbols, add to it, and return a promise of it.\n *\n * * `me` RDF symbol for the user's WebID\n * * `publicProfile` The user's public profile, iff loaded\n * * `preferencesFile` The user's personal preference file, iff loaded\n * * `index.public` The user's public type index file\n * * `index.private` The user's private type index file\n *\n * Not RDF symbols:\n * * `noun` A string in english for the type of thing -- like \"address book\"\n * * `instance` An array of nodes which are existing instances\n * * `containers` An array of nodes of containers of instances\n * * `div` A DOM element where UI can be displayed\n * * `statusArea` A DOM element (opt) progress stuff can be displayed, or error messages\n * *\n * * Vocabulary: \"load\" loads a file if it exists;\n * * 'Ensure\" CREATES the file if it does not exist (if it can) and then loads it.\n * @packageDocumentation\n */\nimport { PaneDefinition } from 'pane-registry'\nimport { BlankNode, NamedNode, st, Statement } from 'rdflib'\n// eslint-disable-next-line camelcase\nimport { Quad_Object } from 'rdflib/lib/tf-types'\nimport { AppDetails, AuthenticationContext, loadIndex, authn, authSession, CrossOriginForbiddenError, ensureTypeIndexes, FetchError, getSuggestedIssuers, NotFoundError, offlineTestID, SameOriginForbiddenError, solidLogicSingleton, UnauthorizedError } from 'solid-logic'\nimport * as debug from '../debug'\nimport { alert } from '../log'\nimport * as ns from '../ns.js'\nimport { Signup } from '../signup/signup.js'\nimport { buttonStyle, commentStyle, textInputStyle } from '../style'\nimport { utils } from '../utils/index'\nimport * as widgets from '../widgets'\n\n/**\n * Resolves with the logged in user's WebID\n *\n * @param context\n */\n// used to be logIn\nexport function ensureLoggedIn (context: AuthenticationContext): Promise<AuthenticationContext> {\n const me = authn.currentUser()\n if (me) {\n authn.saveUser(me, context)\n return Promise.resolve(context)\n }\n\n return new Promise(resolve => {\n authn.checkUser().then(webId => {\n // Already logged in?\n if (webId) {\n debug.log(`logIn: Already logged in as ${webId}`)\n return resolve(context)\n }\n if (!context.div || !context.dom) {\n return resolve(context)\n }\n const box = loginStatusBox(context.dom, webIdUri => {\n authn.saveUser(webIdUri, context)\n resolve(context) // always pass growing context\n })\n context.div.appendChild(box)\n })\n })\n}\n\n/**\n * Loads preference file\n * Do this after having done log in and load profile\n *\n * @private\n *\n * @param context\n */\n// used to be logInLoadPreferences\nexport async function ensureLoadedPreferences (context: AuthenticationContext): Promise<AuthenticationContext> {\n if (context.preferencesFile) return Promise.resolve(context) // already done\n\n const statusArea = context.statusArea || context.div || null\n let progressDisplay\n function complain (message) {\n message = `ensureLoadedPreferences: ${message}`\n if (statusArea) {\n // statusArea.innerHTML = ''\n statusArea.appendChild(\n widgets.errorMessageBlock(context.dom, message)\n )\n }\n debug.log(message)\n // reject(new Error(message))\n }\n try {\n context = await ensureLoadedProfile(context)\n\n // console.log('back in Solid UI after logInLoadProfile', context)\n const preferencesFile = await solidLogicSingleton.loadPreferences(context.me as NamedNode)\n if (progressDisplay) {\n progressDisplay.parentNode.removeChild(progressDisplay)\n }\n context.preferencesFile = preferencesFile\n } catch (err) {\n let m2: string\n if (err instanceof UnauthorizedError) {\n m2 = 'Ooops - you are not authenticated (properly logged in) to for me to read your preference file. Try loggin out and logging in?'\n alert(m2)\n } else if (err instanceof CrossOriginForbiddenError) {\n m2 = `Unauthorized: Assuming preference file blocked for origin ${window.location.origin}`\n context.preferencesFileError = m2\n return context\n } else if (err instanceof SameOriginForbiddenError) {\n m2 = 'You are not authorized to read your preference file. This may be because you are using an untrusted web app.'\n debug.warn(m2)\n } else if (err instanceof NotFoundError) {\n if (\n confirm(`You do not currently have a preference file. OK for me to create an empty one? ${(err as any).preferencesFile || ''}`)\n ) {\n // @@@ code me ... weird to have a name of the file but no file\n alert(`Sorry; I am not prepared to do this. Please create an empty file at ${(err as any).preferencesFile || '(?)'}`)\n complain(\n new Error('Sorry; no code yet to create a preference file at ')\n )\n } else {\n throw (\n new Error(`User declined to create a preference file at ${(err as any).preferencesFile || '(?)'}`)\n )\n }\n } else if (err instanceof FetchError) {\n m2 = `Strange: Error ${err.status} trying to read your preference file.${err.message}`\n alert(m2)\n } else {\n throw new Error(`(via loadPrefs) ${err}`)\n }\n }\n return context\n}\n\n/**\n * Logs the user in and loads their WebID profile document into the store\n *\n * @param context\n *\n * @returns Resolves with the context after login / fetch\n */\n// used to be logInLoadProfile\nexport async function ensureLoadedProfile (context: AuthenticationContext): Promise<AuthenticationContext> {\n if (context.publicProfile) {\n return context\n } // already done\n try {\n const logInContext = await ensureLoggedIn(context)\n if (!logInContext.me) {\n throw new Error('Could not log in')\n }\n context.publicProfile = await solidLogicSingleton.loadProfile(logInContext.me)\n } catch (err) {\n if (context.div && context.dom) {\n context.div.appendChild(\n widgets.errorMessageBlock(context.dom, err.message)\n )\n }\n throw new Error(`Can't log in: ${err}`)\n }\n return context\n}\n\n/**\n * Returns promise of context with arrays of symbols\n *\n * 2016-12-11 change to include forClass arc a la\n * https://github.com/solid/solid/blob/main/proposals/data-discovery.md\n */\nexport async function findAppInstances (\n context: AuthenticationContext,\n theClass: NamedNode,\n isPublic?: boolean\n): Promise<AuthenticationContext> {\n // console.log('findAppInstances', { context, theClass, isPublic })\n if (isPublic === undefined) {\n // Then both public and private\n // console.log('finding public app instance')\n await findAppInstances(context, theClass, true)\n // console.log('finding private app instance')\n await findAppInstances(context, theClass, false)\n // console.log('found public & private app instance', context)\n return context\n }\n\n // Loading preferences is more than loading profile\n try {\n // console.log('calling logInLoad', isPublic)\n await (isPublic\n ? ensureLoadedProfile(context)\n : ensureLoadedPreferences(context))\n // console.log('called logInLoad', isPublic)\n } catch (err) {\n widgets.complain(context, `loadIndex: login and load problem ${err}`)\n }\n // console.log('awaited LogInLoad!', context)\n const visibility = isPublic ? 'public' : 'private'\n try {\n await loadIndex(context, isPublic)\n } catch (err) {\n debug.error(err)\n }\n const index = context.index as { [key: string]: Array<NamedNode> }\n const thisIndex = index[visibility]\n const registrations = thisIndex\n .map(ix => solidLogicSingleton.store.each(undefined, ns.solid('forClass'), theClass, ix))\n .reduce((acc, curr) => acc.concat(curr), [])\n const instances = registrations\n .map(reg => solidLogicSingleton.store.each(reg as NamedNode, ns.solid('instance')))\n .reduce((acc, curr) => acc.concat(curr), [])\n const containers = registrations\n .map(reg => solidLogicSingleton.store.each(reg as NamedNode, ns.solid('instanceContainer')))\n .reduce((acc, curr) => acc.concat(curr), [])\n\n function unique (arr: NamedNode[]): NamedNode[] {\n return Array.from(new Set(arr))\n }\n context.instances = context.instances || []\n context.instances = unique(context.instances.concat(instances as NamedNode[]))\n\n context.containers = context.containers || []\n context.containers = unique(context.containers.concat(containers as NamedNode[]))\n if (!containers.length) {\n return context\n }\n // If the index gives containers, then look up all things within them\n try {\n await solidLogicSingleton.load(containers as NamedNode[])\n } catch (err) {\n const e = new Error(`[FAI] Unable to load containers${err}`)\n debug.log(e) // complain\n widgets.complain(context, `Error looking for ${utils.label(theClass)}: ${err}`)\n // but then ignore it\n // throw new Error(e)\n }\n for (let i = 0; i < containers.length; i++) {\n const cont = containers[i]\n context.instances = context.instances.concat(\n (await solidLogicSingleton.getContainerMembers(cont.value)).map(uri => solidLogicSingleton.store.sym(uri)) // @@ warning: uses strings not NN\n )\n }\n return context\n}\n\n/**\n * UI to control registration of instance\n */\nexport async function registrationControl (\n context: AuthenticationContext,\n instance,\n theClass\n): Promise<AuthenticationContext | void> {\n const dom = context.dom\n if (!dom || !context.div) {\n return context\n }\n const box = dom.createElement('div')\n context.div.appendChild(box)\n context.me = authn.currentUser() // @@\n if (!context.me) {\n box.innerHTML = '<p style=\"margin:2em;\">(Log in to save a link to this)</p>'\n return context\n }\n\n let context2 // @@ const\n try {\n context2 = await ensureTypeIndexes(context)\n } catch (e) {\n let msg\n if (context.div && context.preferencesFileError) {\n msg = '(Preferences not available)'\n context.div.appendChild(dom.createElement('p')).textContent = msg\n } else if (context.div) {\n msg = `registrationControl: Type indexes not available: ${e}`\n context.div.appendChild(widgets.errorMessageBlock(context.dom, e))\n }\n debug.log(msg)\n }\n\n box.innerHTML = '<table><tbody><tr></tr><tr></tr></tbody></table>' // tbody will be inserted anyway\n box.setAttribute('style', 'font-size: 120%; text-align: right; padding: 1em; border: solid gray 0.05em;')\n const tbody = box.children[0].children[0]\n const form = new BlankNode() // @@ say for now\n\n const registrationStatements = function (index) {\n const registrations = solidLogicSingleton.getRegistrations(instance, theClass)\n const reg = registrations.length\n ? registrations[0]\n : widgets.newThing(index)\n return [\n st(reg, ns.solid('instance'), instance, index),\n st(reg, ns.solid('forClass'), theClass, index)\n ]\n }\n\n let index, statements\n\n try {\n if (context2.index && context2.index.public && context2.index.public.length > 0) {\n index = context2.index.public[0]\n statements = registrationStatements(index)\n tbody.children[0].appendChild(\n widgets.buildCheckboxForm(\n context2.dom,\n solidLogicSingleton.store,\n `Public link to this ${context2.noun}`,\n null,\n statements,\n form,\n index\n )\n )\n }\n\n if (context2.index && context2.index.private && context2.index.private.length > 0) {\n index = context2.index.private[0]\n statements = registrationStatements(index)\n tbody.children[1].appendChild(\n widgets.buildCheckboxForm(\n context2.dom,\n solidLogicSingleton.store,\n `Personal note of this ${context2.noun}`,\n null,\n statements,\n form,\n index\n )\n )\n }\n } catch (e) {\n const msg = `registrationControl: Error making panel: ${e}`\n if (context.div) {\n context.div.appendChild(widgets.errorMessageBlock(context.dom, e))\n }\n debug.log(msg)\n }\n return context2\n}\n\n/**\n * UI to List at all registered things\n */\nexport async function registrationList (context0: AuthenticationContext, options: {\n private?: boolean\n public?: boolean\n type?: NamedNode\n }): Promise<AuthenticationContext> {\n const dom = context0.dom as HTMLDocument\n const div = context0.div as HTMLElement\n\n const box = dom.createElement('div')\n div.appendChild(box)\n context0.me = authn.currentUser() // @@\n if (!context0.me) {\n box.innerHTML = '<p style=\"margin:2em;\">(Log in list your stuff)</p>'\n return context0\n }\n\n return ensureTypeIndexes(context0).then(context => {\n box.innerHTML = '<table><tbody></tbody></table>' // tbody will be inserted anyway\n box.setAttribute('style', 'font-size: 120%; text-align: right; padding: 1em; border: solid #eee 0.5em;')\n const table = box.firstChild as HTMLElement\n\n let ix: Array<NamedNode> = []\n let sts: Statement[] = []\n const vs = ['private', 'public']\n vs.forEach(function (visibility) {\n if (context.index && context.index[visibility].length > 0 && options[visibility]) {\n ix = ix.concat(context.index[visibility][0])\n sts = sts.concat(\n solidLogicSingleton.store.statementsMatching(\n undefined,\n ns.solid('instance'),\n undefined,\n context.index[visibility][0]\n )\n )\n }\n })\n\n for (let i = 0; i < sts.length; i++) {\n const statement: Statement = sts[i]\n if (options.type) { // now check terms:forClass\n if (!solidLogicSingleton.store.holds(statement.subject, ns.solid('forClass'), options.type, statement.why)) {\n continue // skip irrelevant ones\n }\n }\n // const cla = statement.subject\n const inst = statement.object\n table.appendChild(widgets.personTR(dom, ns.solid('instance'), inst, {\n deleteFunction: function (_x) {\n if (!solidLogicSingleton.store.updater) {\n throw new Error('Cannot delete this, store has no updater')\n }\n solidLogicSingleton.store.updater.update([statement], [], function (uri, ok, errorBody) {\n if (ok) {\n debug.log(`Removed from index: ${statement.subject}`)\n } else {\n debug.log(`Error: Cannot delete ${statement}: ${errorBody}`)\n }\n })\n }\n }))\n } // registrationList\n\n /*\n //const containers = solidLogicSingleton.store.each(theClass, ns.solid('instanceContainer'));\n if (containers.length) {\n fetcher.load(containers).then(function(xhrs){\n for (const i=0; i<containers.length; i++) {\n const cont = containers[i];\n instances = instances.concat(solidLogicSingleton.store.each(cont, ns.ldp('contains')));\n }\n });\n }\n */\n\n return context\n })\n}\n\nfunction getDefaultSignInButtonStyle (): string {\n return 'padding: 1em; border-radius:0.5em; font-size: 100%;'\n}\n\n/**\n * Bootstrapping identity\n * (Called by `loginStatusBox()`)\n *\n * @param dom\n * @param setUserCallback\n *\n * @returns\n */\nfunction signInOrSignUpBox (\n dom: HTMLDocument,\n setUserCallback: (user: string) => void,\n options: {\n buttonStyle?: string\n } = {}\n): HTMLElement {\n options = options || {}\n const signInButtonStyle = options.buttonStyle || getDefaultSignInButtonStyle()\n\n // @@ TODO Remove the need to cast HTML element to any\n const box: any = dom.createElement('div')\n const magicClassName = 'SolidSignInOrSignUpBox'\n debug.log('widgets.signInOrSignUpBox')\n box.setUserCallback = setUserCallback\n box.setAttribute('class', magicClassName)\n ;(box as any).style = 'display:flex;' // @@ fix all typecasts like this\n\n // Sign in button with PopUP\n const signInPopUpButton = dom.createElement('input') // multi\n box.appendChild(signInPopUpButton)\n signInPopUpButton.setAttribute('type', 'button')\n signInPopUpButton.setAttribute('value', 'Log in')\n signInPopUpButton.setAttribute('style', `${signInButtonStyle}background-color: #eef;`)\n\n authSession.onLogin(() => {\n const me = authn.currentUser()\n // const sessionInfo = authSession.info\n // if (sessionInfo && sessionInfo.isLoggedIn) {\n if (me) {\n // const webIdURI = sessionInfo.webId\n const webIdURI = me.uri\n // setUserCallback(webIdURI)\n const divs = dom.getElementsByClassName(magicClassName)\n debug.log(`Logged in, ${divs.length} panels to be serviced`)\n // At the same time, satisfy all the other login boxes\n for (let i = 0; i < divs.length; i++) {\n const div: any = divs[i]\n // @@ TODO Remove the need to manipulate HTML elements\n if (div.setUserCallback) {\n try {\n div.setUserCallback(webIdURI)\n const parent = div.parentNode\n if (parent) {\n parent.removeChild(div)\n }\n } catch (e) {\n debug.log(`## Error satisfying login box: ${e}`)\n div.appendChild(widgets.errorMessageBlock(dom, e))\n }\n }\n }\n }\n })\n\n signInPopUpButton.addEventListener('click', () => {\n const offline = offlineTestID()\n if (offline) return setUserCallback(offline.uri)\n\n renderSignInPopup(dom)\n }, false)\n\n // Sign up button\n const signupButton = dom.createElement('input')\n box.appendChild(signupButton)\n signupButton.setAttribute('type', 'button')\n signupButton.setAttribute('value', 'Sign Up for Solid')\n signupButton.setAttribute('style', `${signInButtonStyle}background-color: #efe;`)\n\n signupButton.addEventListener('click', function (_event) {\n const signupMgr = new Signup()\n signupMgr.signup().then(function (uri) {\n debug.log('signInOrSignUpBox signed up ' + uri)\n setUserCallback(uri)\n })\n }, false)\n return box\n}\n\nexport function renderSignInPopup (dom: HTMLDocument) {\n /**\n * Issuer Menu\n */\n const issuerPopup = dom.createElement('div')\n issuerPopup.setAttribute('style', 'position: fixed; top: 0; left: 0; right: 0; bottom: 0; display: flex; justify-content: center; align-items: center;')\n dom.body.appendChild(issuerPopup)\n const issuerPopupBox = dom.createElement('div')\n 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 `)\n issuerPopup.appendChild(issuerPopupBox)\n const issuerPopupBoxTopMenu = dom.createElement('div')\n 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 `)\n issuerPopupBox.appendChild(issuerPopupBoxTopMenu)\n const issuerPopupBoxLabel = dom.createElement('label')\n issuerPopupBoxLabel.setAttribute('style', 'margin-right: 5px; font-weight: 800')\n issuerPopupBoxLabel.innerText = 'Select an identity provider'\n const issuerPopupBoxCloseButton = dom.createElement('button')\n issuerPopupBoxCloseButton.innerHTML = '<img src=\"https://solid.github.io/solid-ui/src/icons/noun_1180156.svg\" style=\"width: 2em; height: 2em;\" title=\"Cancel\">'\n issuerPopupBoxCloseButton.setAttribute('style', 'background-color: transparent; border: none;')\n issuerPopupBoxCloseButton.addEventListener('click', () => {\n issuerPopup.remove()\n })\n issuerPopupBoxTopMenu.appendChild(issuerPopupBoxLabel)\n issuerPopupBoxTopMenu.appendChild(issuerPopupBoxCloseButton)\n\n const loginToIssuer = async (issuerUri: string) => {\n try {\n // Save hash\n const preLoginRedirectHash = new URL(window.location.href).hash\n if (preLoginRedirectHash) {\n window.localStorage.setItem('preLoginRedirectHash', preLoginRedirectHash)\n }\n window.localStorage.setItem('loginIssuer', issuerUri)\n // Login\n await authSession.login({\n redirectUrl: window.location.href,\n oidcIssuer: issuerUri\n })\n } catch (err) {\n alert(err.message)\n }\n }\n\n /**\n * Text-based idp selection\n */\n const issuerTextContainer = dom.createElement('div')\n issuerTextContainer.setAttribute('style', `\n border-bottom: 1px solid #DDD;\n display: flex;\n flex-direction: column;\n padding-top: 10px;\n `)\n const issuerTextInputContainer = dom.createElement('div')\n issuerTextInputContainer.setAttribute('style', `\n display: flex;\n flex-direction: row;\n `)\n const issuerTextLabel = dom.createElement('label')\n issuerTextLabel.innerText = 'Enter the URL of your identity provider:'\n issuerTextLabel.setAttribute('style', 'color: #888')\n const issuerTextInput = dom.createElement('input')\n issuerTextInput.setAttribute('type', 'text')\n issuerTextInput.setAttribute('style', 'margin-left: 0 !important; flex: 1; margin-right: 5px !important')\n issuerTextInput.setAttribute('placeholder', 'https://example.com')\n issuerTextInput.value = localStorage.getItem('loginIssuer') || ''\n const issuerTextGoButton = dom.createElement('button')\n issuerTextGoButton.innerText = 'Go'\n issuerTextGoButton.setAttribute('style', 'margin-top: 12px; margin-bottom: 12px;')\n issuerTextGoButton.addEventListener('click', () => {\n loginToIssuer(issuerTextInput.value)\n })\n issuerTextContainer.appendChild(issuerTextLabel)\n issuerTextInputContainer.appendChild(issuerTextInput)\n issuerTextInputContainer.appendChild(issuerTextGoButton)\n issuerTextContainer.appendChild(issuerTextInputContainer)\n issuerPopupBox.appendChild(issuerTextContainer)\n\n /**\n * Button-based idp selection\n */\n const issuerButtonContainer = dom.createElement('div')\n issuerButtonContainer.setAttribute('style', `\n display: flex;\n flex-direction: column;\n padding-top: 10px;\n `)\n const issuerBottonLabel = dom.createElement('label')\n issuerBottonLabel.innerText = 'Or pick an identity provider from the list below:'\n issuerBottonLabel.setAttribute('style', 'color: #888')\n issuerButtonContainer.appendChild(issuerBottonLabel)\n getSuggestedIssuers().forEach((issuerInfo) => {\n const issuerButton = dom.createElement('button')\n issuerButton.innerText = issuerInfo.name\n issuerButton.setAttribute('style', 'height: 38px; margin-top: 10px')\n issuerButton.addEventListener('click', () => {\n loginToIssuer(issuerInfo.uri)\n })\n issuerButtonContainer.appendChild(issuerButton)\n })\n issuerPopupBox.appendChild(issuerButtonContainer)\n}\n\n/**\n * Login status box\n *\n * A big sign-up/sign in box or a logout box depending on the state\n *\n * @param dom\n * @param listener\n *\n * @returns\n */\nexport function loginStatusBox (\n dom: HTMLDocument,\n listener: ((uri: string | null) => void) | null = null,\n options: {\n buttonStyle?: string\n } = {}\n): HTMLElement {\n // 20190630\n let me = offlineTestID()\n // @@ TODO Remove the need to cast HTML element to any\n const box: any = dom.createElement('div')\n\n function setIt (newidURI) {\n if (!newidURI) {\n return\n }\n\n // const uri = newidURI.uri || newidURI\n // me = sym(uri)\n me = authn.saveUser(newidURI)\n box.refresh()\n if (listener) listener(me!.uri)\n }\n\n function logoutButtonHandler (_event) {\n const oldMe = me\n authSession.logout().then(\n function () {\n const message = `Your WebID was ${oldMe}. It has been forgotten.`\n me = null\n try {\n alert(message)\n } catch (e) {\n window.alert(message)\n }\n box.refresh()\n if (listener) listener(null)\n },\n err => {\n alert('Fail to log out:' + err)\n }\n )\n }\n\n function logoutButton (me, options) {\n const signInButtonStyle = options.buttonStyle || getDefaultSignInButtonStyle()\n let logoutLabel = 'WebID logout'\n if (me) {\n const nick =\n solidLogicSingleton.store.any(me, ns.foaf('nick')) ||\n solidLogicSingleton.store.any(me, ns.foaf('name'))\n if (nick) {\n logoutLabel = 'Logout ' + nick.value\n }\n }\n const signOutButton = dom.createElement('input')\n // signOutButton.className = 'WebIDCancelButton'\n signOutButton.setAttribute('type', 'button')\n signOutButton.setAttribute('value', logoutLabel)\n signOutButton.setAttribute('style', `${signInButtonStyle}background-color: #eee;`)\n signOutButton.addEventListener('click', logoutButtonHandler, false)\n return signOutButton\n }\n\n box.refresh = function () {\n me = authn.currentUser()\n if ((me && box.me !== me.uri) || (!me && box.me)) {\n widgets.clearElement(box)\n if (me) {\n box.appendChild(logoutButton(me, options))\n } else {\n box.appendChild(signInOrSignUpBox(dom, setIt, options))\n }\n }\n box.me = me ? me.uri : null\n }\n box.refresh()\n\n function trackSession () {\n me = authn.currentUser()\n box.refresh()\n }\n trackSession()\n\n authSession.onLogin(trackSession)\n authSession.onLogout(trackSession)\n box.me = '99999' // Force refresh\n box.refresh()\n return box\n}\n\nauthSession.onLogout(async () => {\n const issuer = window.localStorage.getItem('loginIssuer')\n if (issuer) {\n try {\n const wellKnownUri = new URL(issuer)\n wellKnownUri.pathname = '/.well-known/openid-configuration'\n const wellKnownResult = await fetch(wellKnownUri.toString())\n if (wellKnownResult.status === 200) {\n const openidConfiguration = await wellKnownResult.json()\n if (openidConfiguration && openidConfiguration.end_session_endpoint) {\n await fetch(openidConfiguration.end_session_endpoint, { credentials: 'include' })\n }\n }\n } catch (err) {\n // Do nothing\n }\n }\n window.location.reload()\n})\n\n/**\n * Workspace selection etc\n * See https://github.com/solid/userguide/issues/16\n */\n\n/**\n * Returns a UI object which, if it selects a workspace,\n * will callback(workspace, newBase).\n * See https://github.com/solid/userguide/issues/16 for more info on workspaces.\n *\n * If necessary, will get an account, preference file, etc. In sequence:\n *\n * - If not logged in, log in.\n * - Load preference file\n * - Prompt user for workspaces\n * - Allows the user to just type in a URI by hand\n *\n * Calls back with the workspace and the base URI\n *\n * @param dom\n * @param appDetails\n * @param callbackWS\n */\nexport function selectWorkspace (\n dom: HTMLDocument,\n appDetails: AppDetails,\n callbackWS: (workspace: string | null, newBase: string) => void\n): HTMLElement {\n const noun = appDetails.noun\n const appPathSegment = appDetails.appPathSegment\n\n const me = offlineTestID()\n const box = dom.createElement('div')\n const context: AuthenticationContext = { me, dom, div: box }\n\n function say (s, background) {\n box.appendChild(widgets.errorMessageBlock(dom, s, background))\n }\n\n function figureOutBase (ws) {\n const newBaseNode: NamedNode = solidLogicSingleton.store.any(ws, ns.space('uriPrefix')) as NamedNode\n let newBaseString: string\n if (!newBaseNode) {\n newBaseString = ws.uri.split('#')[0]\n } else {\n newBaseString = newBaseNode.value\n }\n if (newBaseString.slice(-1) !== '/') {\n debug.log(`${appPathSegment}: No / at end of uriPrefix ${newBaseString}`) // @@ paramater?\n newBaseString = `${newBaseString}/`\n }\n const now = new Date()\n newBaseString += `${appPathSegment}/id${now.getTime()}/` // unique id\n return newBaseString\n }\n\n function displayOptions (context) {\n // console.log('displayOptions!', context)\n async function makeNewWorkspace (_event) {\n const row = table.appendChild(dom.createElement('tr'))\n const cell = row.appendChild(dom.createElement('td'))\n cell.setAttribute('colspan', '3')\n cell.style.padding = '0.5em'\n const newBase = encodeURI(await widgets.askName(dom, solidLogicSingleton.store, cell, ns.solid('URL'), ns.space('Workspace'), 'Workspace'))\n const newWs = widgets.newThing(context.preferencesFile)\n const newData = [st(context.me, ns.space('workspace'), newWs, context.preferencesFile),\n // eslint-disable-next-line camelcase\n st(newWs, ns.space('uriPrefix'), newBase as unknown as Quad_Object, context.preferencesFile)]\n if (!solidLogicSingleton.store.updater) {\n throw new Error('store has no updater')\n }\n await solidLogicSingleton.store.updater.update([], newData)\n // @@ now refresh list of workspaces\n }\n\n // const status = ''\n const id = context.me\n const preferencesFile = context.preferencesFile\n let newBase: any = null\n\n // A workspace specifically defined in the private preference file:\n let w: any = solidLogicSingleton.store.each(id, ns.space('workspace'), undefined, preferencesFile) // Only trust preference file here\n\n // A workspace in a storage in the public profile:\n const storages = solidLogicSingleton.store.each(id, ns.space('storage')) // @@ No provenance requirement at the moment\n if (w.length === 0 && storages) {\n say(`You don't seem to have any workspaces. You have ${storages.length} storage spaces.`, 'white')\n storages.map(function (s: any) {\n w = w.concat(solidLogicSingleton.store.each(s, ns.ldp('contains')))\n return w\n }).filter(file => {\n return (file.id) ? ['public', 'private'].includes(file.id().toLowerCase()) : ''\n })\n }\n\n if (w.length === 1) {\n say(`Workspace used: ${w[0].uri}`, 'white') // @@ allow user to see URI\n newBase = figureOutBase(w[0])\n // callbackWS(w[0], newBase)\n // } else if (w.length === 0) {\n }\n\n // Prompt for ws selection or creation\n // say( w.length + \" workspaces for \" + id + \"Choose one.\");\n const table = dom.createElement('table')\n table.setAttribute('style', 'border-collapse:separate; border-spacing: 0.5em;')\n\n // const popup = window.open(undefined, '_blank', { height: 300, width:400 }, false)\n box.appendChild(table)\n\n // Add a field for directly adding the URI yourself\n\n // const hr = box.appendChild(dom.createElement('hr')) // @@\n box.appendChild(dom.createElement('hr')) // @@\n\n const p = box.appendChild(dom.createElement('p'))\n ;(p as any).style = commentStyle\n p.textContent = `Where would you like to store the data for the ${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.`\n // @@ TODO Remove the need to cast baseField to any\n const baseField: any = box.appendChild(dom.createElement('input'))\n baseField.setAttribute('type', 'text')\n ;(baseField as any).style = textInputStyle\n baseField.size = 80 // really a string\n baseField.label = 'base URL'\n baseField.autocomplete = 'on'\n if (newBase) {\n // set to default\n baseField.value = newBase\n }\n\n context.baseField = baseField\n\n box.appendChild(dom.createElement('br')) // @@\n\n const button = box.appendChild(dom.createElement('button'))\n ;(button as any).style = buttonStyle\n button.textContent = `Start new ${noun} at this URI`\n button.addEventListener('click', function (_event) {\n let newBase = baseField.value.replace(' ', '%20') // do not re-encode in general, as % encodings may exist\n if (newBase.slice(-1) !== '/') {\n newBase += '/'\n }\n callbackWS(null, newBase)\n })\n\n // Now go set up the table of spaces\n\n // const row = 0\n w = w.filter(function (x) {\n return !solidLogicSingleton.store.holds(\n x,\n ns.rdf('type'), // Ignore master workspaces\n ns.space('MasterWorkspace')\n )\n })\n let col1, col2, col3, tr, ws, style, comment\n const cellStyle = 'height: 3em; margin: 1em; padding: 1em white; border-radius: 0.3em;'\n const deselectedStyle = `${cellStyle}border: 0px;`\n // const selectedStyle = cellStyle + 'border: 1px solid black;'\n for (let i = 0; i < w.length; i++) {\n ws = w[i]\n tr = dom.createElement('tr')\n if (i === 0) {\n col1 = dom.createElement('td')\n col1.setAttribute('rowspan', `${w.length}`)\n col1.textContent = 'Choose a workspace for this:'\n col1.setAttribute('style', 'vertical-align:middle;')\n tr.appendChild(col1)\n }\n col2 = dom.createElement('td')\n style = solidLogicSingleton.store.anyValue(ws, ns.ui('style'))\n if (!style) {\n // Otherwise make up arbitrary colour\n const hash = function (x) {\n return x.split('').reduce(function (a, b) {\n a = (a << 5) - a + b.charCodeAt(0)\n return a & a\n }, 0)\n }\n const bgcolor = `#${((hash(ws.uri) & 0xffffff) | 0xc0c0c0).toString(16)}` // c0c0c0 forces pale\n style = `color: black ; background-color: ${bgcolor};`\n }\n col2.setAttribute('style', deselectedStyle + style)\n tr.target = ws.uri\n let label = solidLogicSingleton.store.any(ws, ns.rdfs('label'))\n if (!label) {\n label = ws.uri.split('/').slice(-1)[0] || ws.uri.split('/').slice(-2)[0]\n }\n col2.textContent = label || '???'\n tr.appendChild(col2)\n if (i === 0) {\n col3 = dom.createElement('td')\n col3.setAttribute('rowspan', `${w.length}1`)\n // col3.textContent = '@@@@@ remove';\n col3.setAttribute('style', 'width:50%;')\n tr.appendChild(col3)\n }\n table.appendChild(tr)\n\n comment = solidLogicSingleton.store.any(ws, ns.rdfs('comment'))\n comment = comment ? comment.value : 'Use this workspace'\n col2.addEventListener('click', function (_event) {\n col3.textContent = comment ? comment.value : ''\n col3.setAttribute('style', deselectedStyle + style)\n const button = dom.createElement('button')\n button.textContent = 'Continue'\n // button.setAttribute('style', style);\n const newBase = figureOutBase(ws)\n baseField.value = newBase // show user proposed URI\n\n button.addEventListener('click', function (_event) {\n button.disabled = true\n callbackWS(ws, newBase)\n button.textContent = '---->'\n }, true) // capture vs bubble\n col3.appendChild(button)\n }, true) // capture vs bubble\n }\n\n // last line with \"Make new workspace\"\n const trLast = dom.createElement('tr')\n col2 = dom.createElement('td')\n col2.setAttribute('style', cellStyle)\n col2.textContent = '+ Make a new workspace'\n col2.addEventListener('click', makeNewWorkspace)\n trLast.appendChild(col2)\n table.appendChild(trLast)\n } // displayOptions\n\n // console.log('kicking off async operation')\n ensureLoadedPreferences(context) // kick off async operation\n .then(displayOptions)\n .catch(err => {\n // console.log(\"err from async op\")\n box.appendChild(widgets.errorMessageBlock(context.dom, err))\n })\n\n return box // return the box element, while login proceeds\n} // selectWorkspace\n\n/**\n * Creates a new instance of an app.\n *\n * An instance of an app could be e.g. an issue tracker for a given project,\n * or a chess game, or calendar, or a health/fitness record for a person.\n *\n * Note that this use of the term 'app' refers more to entries in the user's\n * type index than to actual software applications that use the personal data\n * to which these entries point.\n *\n * @param dom\n * @param appDetails\n * @param callback\n *\n * @returns A div with a button in it for making a new app instance\n */\nexport function newAppInstance (\n dom: HTMLDocument,\n appDetails: AppDetails,\n callback: (workspace: string | null, newBase: string) => void\n): HTMLElement {\n const gotWS = function (ws, base) {\n // log.debug(\"newAppInstance: Selected workspace = \" + (ws? ws.uri : 'none'))\n callback(ws, base)\n }\n const div = dom.createElement('div')\n const b = dom.createElement('button')\n b.setAttribute('type', 'button')\n div.appendChild(b)\n b.innerHTML = `Make new ${appDetails.noun}`\n b.addEventListener('click', _event => {\n div.appendChild(selectWorkspace(dom, appDetails, gotWS))\n }, false)\n div.appendChild(b)\n return div\n}\n/**\n * Retrieves whether the currently logged in user is a power user\n * and/or a developer\n */\nexport async function getUserRoles (): Promise<Array<NamedNode>> {\n try {\n const {\n me,\n preferencesFile,\n preferencesFileError\n } = await ensureLoadedPreferences({})\n if (!preferencesFile || preferencesFileError) {\n throw new Error(preferencesFileError)\n }\n return solidLogicSingleton.store.each(me, ns.rdf('type'), null, preferencesFile.doc()) as NamedNode[]\n } catch (error) {\n debug.warn('Unable to fetch your preferences - this was the error: ', error)\n }\n return []\n}\n\n/**\n * Filters which panes should be available, based on the result of [[getUserRoles]]\n */\nexport async function filterAvailablePanes (panes: Array<PaneDefinition>): Promise<Array<PaneDefinition>> {\n const userRoles = await getUserRoles()\n return panes.filter(pane => isMatchingAudience(pane, userRoles))\n}\n\nfunction isMatchingAudience (pane: PaneDefinition, userRoles: Array<NamedNode>): boolean {\n const audience = pane.audience || []\n return audience.reduce(\n (isMatch, audienceRole) => isMatch && !!userRoles.find(role => role.equals(audienceRole)),\n true as boolean\n )\n}\n"],"file":"login.js"}
|
|
1
|
+
{"version":3,"sources":["../../src/login/login.ts"],"names":["ensureLoggedIn","context","me","authn","currentUser","saveUser","Promise","resolve","checkUser","then","webId","debug","log","div","dom","box","loginStatusBox","webIdUri","appendChild","ensureLoadedPreferences","complain","message","statusArea","widgets","errorMessageBlock","preferencesFile","ensureLoadedProfile","solidLogicSingleton","loadPreferences","progressDisplay","parentNode","removeChild","UnauthorizedError","m2","CrossOriginForbiddenError","window","location","origin","preferencesFileError","SameOriginForbiddenError","warn","NotFoundError","confirm","Error","FetchError","status","publicProfile","logInContext","loadProfile","findAppInstances","theClass","isPublic","unique","arr","Array","from","Set","undefined","visibility","error","index","thisIndex","registrations","map","ix","store","each","ns","solid","reduce","acc","curr","concat","instances","reg","containers","length","load","e","utils","label","i","cont","getContainerMembers","value","uri","sym","registrationControl","instance","createElement","innerHTML","context2","msg","textContent","setAttribute","tbody","children","form","BlankNode","registrationStatements","getRegistrations","newThing","statements","buildCheckboxForm","noun","registrationList","context0","options","table","firstChild","sts","vs","forEach","statementsMatching","statement","type","holds","subject","why","inst","object","personTR","deleteFunction","_x","updater","update","ok","errorBody","getDefaultSignInButtonStyle","signInOrSignUpBox","setUserCallback","signInButtonStyle","buttonStyle","magicClassName","style","signInPopUpButton","authSession","onLogin","webIdURI","divs","getElementsByClassName","parent","addEventListener","offline","renderSignInPopup","signupButton","_event","signupMgr","Signup","signup","issuerPopup","body","issuerPopupBox","issuerPopupBoxTopMenu","issuerPopupBoxLabel","innerText","issuerPopupBoxCloseButton","remove","loginToIssuer","issuerUri","preLoginRedirectHash","URL","href","hash","localStorage","setItem","login","redirectUrl","oidcIssuer","issuerTextContainer","issuerTextInputContainer","issuerTextLabel","issuerTextInput","getItem","issuerTextGoButton","issuerButtonContainer","issuerBottonLabel","issuerInfo","issuerButton","name","listener","setIt","newidURI","refresh","logoutButtonHandler","oldMe","logout","alert","err","logoutButton","logoutLabel","nick","any","foaf","signOutButton","clearElement","trackSession","onLogout","issuer","wellKnownUri","pathname","fetch","toString","wellKnownResult","json","openidConfiguration","end_session_endpoint","credentials","reload","selectWorkspace","appDetails","callbackWS","appPathSegment","say","s","background","figureOutBase","ws","newBaseNode","space","newBaseString","split","slice","now","Date","getTime","displayOptions","makeNewWorkspace","row","cell","padding","encodeURI","askName","newBase","newWs","newData","id","w","storages","ldp","filter","file","includes","toLowerCase","p","commentStyle","baseField","textInputStyle","size","autocomplete","button","replace","x","rdf","col1","col2","col3","tr","comment","cellStyle","deselectedStyle","anyValue","ui","a","b","charCodeAt","bgcolor","target","rdfs","disabled","trLast","newAppInstance","callback","gotWS","base","getUserRoles","doc","filterAvailablePanes","panes","userRoles","pane","isMatchingAudience","audience","isMatch","audienceRole","find","role","equals"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AA0BA;;AAGA;;AAgBA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;AAnDA;;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AA6BA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,cAAT,CAAyBC,OAAzB,EAAyF;AAC9F,MAA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;AAAA;AAaHzQ,YAAAA,KAAK,CAAC6B,IAAN,CAAW,yDAAX;;AAbG;AAAA,8CAeE,EAfF;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,G;;;;SAqBe6O,oB;;;;;wGAAf,mBACLC,KADK;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAGmBH,YAAY,EAH/B;;AAAA;AAGCI,YAAAA,SAHD;AAAA,+CAIED,KAAK,CAACtC,MAAN,CAAa,UAACwC,IAAD;AAAA,qBAAUC,kBAAkB,CAACD,IAAD,EAAOD,SAAP,CAA5B;AAAA,aAAb,CAJF;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,G;;;;AAOP,SAASE,kBAAT,CAA6BD,IAA7B,EAAmDD,SAAnD,EAAyF;AACvF,MAAMG,QAAQ,GAAGF,IAAI,CAACE,QAAL,IAAiB,EAAlC;AACA,SAAOA,QAAQ,CAACrN,MAAT,CACL,UAACsN,OAAD,EAAUC,YAAV;AAAA,WAA2BD,OAAO,IAAI,CAAC,CAACJ,SAAS,CAACM,IAAV,CAAe,UAACC,IAAD;AAAA,aAAUA,IAAI,CAACC,MAAL,CAAYH,YAAZ,CAAV;AAAA,KAAf,CAAxC;AAAA,GADK,EAEL,IAFK,CAAP;AAID","sourcesContent":["/* eslint-disable camelcase */\n/**\n * Signing in, signing up, profile and preferences reloading\n * Type index management\n *\n * Many functions in this module take a context object which\n * holds various RDF symbols, add to it, and return a promise of it.\n *\n * * `me` RDF symbol for the user's WebID\n * * `publicProfile` The user's public profile, iff loaded\n * * `preferencesFile` The user's personal preference file, iff loaded\n * * `index.public` The user's public type index file\n * * `index.private` The user's private type index file\n *\n * Not RDF symbols:\n * * `noun` A string in english for the type of thing -- like \"address book\"\n * * `instance` An array of nodes which are existing instances\n * * `containers` An array of nodes of containers of instances\n * * `div` A DOM element where UI can be displayed\n * * `statusArea` A DOM element (opt) progress stuff can be displayed, or error messages\n * *\n * * Vocabulary: \"load\" loads a file if it exists;\n * * 'Ensure\" CREATES the file if it does not exist (if it can) and then loads it.\n * @packageDocumentation\n */\nimport { PaneDefinition } from 'pane-registry'\nimport { BlankNode, NamedNode, st, Statement } from 'rdflib'\n// eslint-disable-next-line camelcase\nimport { Quad_Object } from 'rdflib/lib/tf-types'\nimport {\n AppDetails,\n AuthenticationContext,\n loadIndex,\n authn,\n authSession,\n CrossOriginForbiddenError,\n ensureTypeIndexes,\n FetchError,\n getSuggestedIssuers,\n NotFoundError,\n offlineTestID,\n SameOriginForbiddenError,\n solidLogicSingleton,\n UnauthorizedError\n} from 'solid-logic'\nimport * as debug from '../debug'\nimport { alert } from '../log'\nimport * as ns from '../ns.js'\nimport { Signup } from '../signup/signup.js'\nimport { buttonStyle, commentStyle, textInputStyle } from '../style'\nimport { utils } from '../utils/index'\nimport * as widgets from '../widgets'\n\n/**\n * Resolves with the logged in user's WebID\n *\n * @param context\n */\n// used to be logIn\nexport function ensureLoggedIn (context: AuthenticationContext): Promise<AuthenticationContext> {\n const me = authn.currentUser()\n if (me) {\n authn.saveUser(me, context)\n return Promise.resolve(context)\n }\n\n return new Promise((resolve) => {\n authn.checkUser().then((webId) => {\n // Already logged in?\n if (webId) {\n debug.log(`logIn: Already logged in as ${webId}`)\n return resolve(context)\n }\n if (!context.div || !context.dom) {\n return resolve(context)\n }\n const box = loginStatusBox(context.dom, (webIdUri) => {\n authn.saveUser(webIdUri, context)\n resolve(context) // always pass growing context\n })\n context.div.appendChild(box)\n })\n })\n}\n\n/**\n * Loads preference file\n * Do this after having done log in and load profile\n *\n * @private\n *\n * @param context\n */\n// used to be logInLoadPreferences\nexport async function ensureLoadedPreferences (\n context: AuthenticationContext\n): Promise<AuthenticationContext> {\n if (context.preferencesFile) return Promise.resolve(context) // already done\n\n const statusArea = context.statusArea || context.div || null\n let progressDisplay\n function complain (message) {\n message = `ensureLoadedPreferences: ${message}`\n if (statusArea) {\n // statusArea.innerHTML = ''\n statusArea.appendChild(widgets.errorMessageBlock(context.dom, message))\n }\n debug.log(message)\n // reject(new Error(message))\n }\n try {\n context = await ensureLoadedProfile(context)\n\n // console.log('back in Solid UI after logInLoadProfile', context)\n const preferencesFile = await solidLogicSingleton.loadPreferences(context.me as NamedNode)\n if (progressDisplay) {\n progressDisplay.parentNode.removeChild(progressDisplay)\n }\n context.preferencesFile = preferencesFile\n } catch (err) {\n let m2: string\n if (err instanceof UnauthorizedError) {\n m2 =\n 'Ooops - you are not authenticated (properly logged in) to for me to read your preference file. Try loggin out and logging in?'\n alert(m2)\n } else if (err instanceof CrossOriginForbiddenError) {\n m2 = `Unauthorized: Assuming preference file blocked for origin ${window.location.origin}`\n context.preferencesFileError = m2\n return context\n } else if (err instanceof SameOriginForbiddenError) {\n m2 =\n 'You are not authorized to read your preference file. This may be because you are using an untrusted web app.'\n debug.warn(m2)\n } else if (err instanceof NotFoundError) {\n if (\n confirm(\n `You do not currently have a preference file. OK for me to create an empty one? ${\n (err as any).preferencesFile || ''\n }`\n )\n ) {\n // @@@ code me ... weird to have a name of the file but no file\n alert(\n `Sorry; I am not prepared to do this. Please create an empty file at ${\n (err as any).preferencesFile || '(?)'\n }`\n )\n complain(new Error('Sorry; no code yet to create a preference file at '))\n } else {\n throw new Error(\n `User declined to create a preference file at ${(err as any).preferencesFile || '(?)'}`\n )\n }\n } else if (err instanceof FetchError) {\n m2 = `Strange: Error ${err.status} trying to read your preference file.${err.message}`\n alert(m2)\n } else {\n throw new Error(`(via loadPrefs) ${err}`)\n }\n }\n return context\n}\n\n/**\n * Logs the user in and loads their WebID profile document into the store\n *\n * @param context\n *\n * @returns Resolves with the context after login / fetch\n */\n// used to be logInLoadProfile\nexport async function ensureLoadedProfile (\n context: AuthenticationContext\n): Promise<AuthenticationContext> {\n if (context.publicProfile) {\n return context\n } // already done\n try {\n const logInContext = await ensureLoggedIn(context)\n if (!logInContext.me) {\n throw new Error('Could not log in')\n }\n context.publicProfile = await solidLogicSingleton.loadProfile(logInContext.me)\n } catch (err) {\n if (context.div && context.dom) {\n context.div.appendChild(widgets.errorMessageBlock(context.dom, err.message))\n }\n throw new Error(`Can't log in: ${err}`)\n }\n return context\n}\n\n/**\n * Returns promise of context with arrays of symbols\n *\n * 2016-12-11 change to include forClass arc a la\n * https://github.com/solid/solid/blob/main/proposals/data-discovery.md\n */\nexport async function findAppInstances (\n context: AuthenticationContext,\n theClass: NamedNode,\n isPublic?: boolean\n): Promise<AuthenticationContext> {\n // console.log('findAppInstances', { context, theClass, isPublic })\n if (isPublic === undefined) {\n // Then both public and private\n // console.log('finding public app instance')\n await findAppInstances(context, theClass, true)\n // console.log('finding private app instance')\n await findAppInstances(context, theClass, false)\n // console.log('found public & private app instance', context)\n return context\n }\n\n // Loading preferences is more than loading profile\n try {\n // console.log('calling logInLoad', isPublic)\n await (isPublic ? ensureLoadedProfile(context) : ensureLoadedPreferences(context))\n // console.log('called logInLoad', isPublic)\n } catch (err) {\n widgets.complain(context, `loadIndex: login and load problem ${err}`)\n }\n // console.log('awaited LogInLoad!', context)\n const visibility = isPublic ? 'public' : 'private'\n try {\n await loadIndex(context, isPublic)\n } catch (err) {\n debug.error(err)\n }\n const index = context.index as { [key: string]: Array<NamedNode> }\n const thisIndex = index[visibility]\n const registrations = thisIndex\n .map((ix) => solidLogicSingleton.store.each(undefined, ns.solid('forClass'), theClass, ix))\n .reduce((acc, curr) => acc.concat(curr), [])\n const instances = registrations\n .map((reg) => solidLogicSingleton.store.each(reg as NamedNode, ns.solid('instance')))\n .reduce((acc, curr) => acc.concat(curr), [])\n const containers = registrations\n .map((reg) => solidLogicSingleton.store.each(reg as NamedNode, ns.solid('instanceContainer')))\n .reduce((acc, curr) => acc.concat(curr), [])\n\n function unique (arr: NamedNode[]): NamedNode[] {\n return Array.from(new Set(arr))\n }\n context.instances = context.instances || []\n context.instances = unique(context.instances.concat(instances as NamedNode[]))\n\n context.containers = context.containers || []\n context.containers = unique(context.containers.concat(containers as NamedNode[]))\n if (!containers.length) {\n return context\n }\n // If the index gives containers, then look up all things within them\n try {\n await solidLogicSingleton.load(containers as NamedNode[])\n } catch (err) {\n const e = new Error(`[FAI] Unable to load containers${err}`)\n debug.log(e) // complain\n widgets.complain(context, `Error looking for ${utils.label(theClass)}: ${err}`)\n // but then ignore it\n // throw new Error(e)\n }\n for (let i = 0; i < containers.length; i++) {\n const cont = containers[i]\n context.instances = context.instances.concat(\n (await solidLogicSingleton.getContainerMembers(cont.value)).map((uri) =>\n solidLogicSingleton.store.sym(uri)\n ) // @@ warning: uses strings not NN\n )\n }\n return context\n}\n\n/**\n * UI to control registration of instance\n */\nexport async function registrationControl (\n context: AuthenticationContext,\n instance,\n theClass\n): Promise<AuthenticationContext | void> {\n const dom = context.dom\n if (!dom || !context.div) {\n return context\n }\n const box = dom.createElement('div')\n context.div.appendChild(box)\n context.me = authn.currentUser() // @@\n if (!context.me) {\n box.innerHTML = '<p style=\"margin:2em;\">(Log in to save a link to this)</p>'\n return context\n }\n\n let context2 // @@ const\n try {\n context2 = await ensureTypeIndexes(context)\n } catch (e) {\n let msg\n if (context.div && context.preferencesFileError) {\n msg = '(Preferences not available)'\n context.div.appendChild(dom.createElement('p')).textContent = msg\n } else if (context.div) {\n msg = `registrationControl: Type indexes not available: ${e}`\n context.div.appendChild(widgets.errorMessageBlock(context.dom, e))\n }\n debug.log(msg)\n }\n\n box.innerHTML = '<table><tbody><tr></tr><tr></tr></tbody></table>' // tbody will be inserted anyway\n box.setAttribute(\n 'style',\n 'font-size: 120%; text-align: right; padding: 1em; border: solid gray 0.05em;'\n )\n const tbody = box.children[0].children[0]\n const form = new BlankNode() // @@ say for now\n\n const registrationStatements = function (index) {\n const registrations = solidLogicSingleton.getRegistrations(instance, theClass)\n const reg = registrations.length ? registrations[0] : widgets.newThing(index)\n return [\n st(reg, ns.solid('instance'), instance, index),\n st(reg, ns.solid('forClass'), theClass, index)\n ]\n }\n\n let index, statements\n\n try {\n if (context2.index && context2.index.public && context2.index.public.length > 0) {\n index = context2.index.public[0]\n statements = registrationStatements(index)\n tbody.children[0].appendChild(\n widgets.buildCheckboxForm(\n context2.dom,\n solidLogicSingleton.store,\n `Public link to this ${context2.noun}`,\n null,\n statements,\n form,\n index\n )\n )\n }\n\n if (context2.index && context2.index.private && context2.index.private.length > 0) {\n index = context2.index.private[0]\n statements = registrationStatements(index)\n tbody.children[1].appendChild(\n widgets.buildCheckboxForm(\n context2.dom,\n solidLogicSingleton.store,\n `Personal note of this ${context2.noun}`,\n null,\n statements,\n form,\n index\n )\n )\n }\n } catch (e) {\n const msg = `registrationControl: Error making panel: ${e}`\n if (context.div) {\n context.div.appendChild(widgets.errorMessageBlock(context.dom, e))\n }\n debug.log(msg)\n }\n return context2\n}\n\n/**\n * UI to List at all registered things\n */\nexport async function registrationList (\n context0: AuthenticationContext,\n options: {\n private?: boolean;\n public?: boolean;\n type?: NamedNode;\n }\n): Promise<AuthenticationContext> {\n const dom = context0.dom as HTMLDocument\n const div = context0.div as HTMLElement\n\n const box = dom.createElement('div')\n div.appendChild(box)\n context0.me = authn.currentUser() // @@\n if (!context0.me) {\n box.innerHTML = '<p style=\"margin:2em;\">(Log in list your stuff)</p>'\n return context0\n }\n\n return ensureTypeIndexes(context0).then((context) => {\n box.innerHTML = '<table><tbody></tbody></table>' // tbody will be inserted anyway\n box.setAttribute(\n 'style',\n 'font-size: 120%; text-align: right; padding: 1em; border: solid #eee 0.5em;'\n )\n const table = box.firstChild as HTMLElement\n\n let ix: Array<NamedNode> = []\n let sts: Statement[] = []\n const vs = ['private', 'public']\n vs.forEach(function (visibility) {\n if (context.index && context.index[visibility].length > 0 && options[visibility]) {\n ix = ix.concat(context.index[visibility][0])\n sts = sts.concat(\n solidLogicSingleton.store.statementsMatching(\n undefined,\n ns.solid('instance'),\n undefined,\n context.index[visibility][0]\n )\n )\n }\n })\n\n for (let i = 0; i < sts.length; i++) {\n const statement: Statement = sts[i]\n if (options.type) {\n // now check terms:forClass\n if (\n !solidLogicSingleton.store.holds(\n statement.subject,\n ns.solid('forClass'),\n options.type,\n statement.why\n )\n ) {\n continue // skip irrelevant ones\n }\n }\n // const cla = statement.subject\n const inst = statement.object\n table.appendChild(\n widgets.personTR(dom, ns.solid('instance'), inst, {\n deleteFunction: function (_x) {\n if (!solidLogicSingleton.store.updater) {\n throw new Error('Cannot delete this, store has no updater')\n }\n solidLogicSingleton.store.updater.update(\n [statement],\n [],\n function (uri, ok, errorBody) {\n if (ok) {\n debug.log(`Removed from index: ${statement.subject}`)\n } else {\n debug.log(`Error: Cannot delete ${statement}: ${errorBody}`)\n }\n }\n )\n }\n })\n )\n } // registrationList\n\n /*\n //const containers = solidLogicSingleton.store.each(theClass, ns.solid('instanceContainer'));\n if (containers.length) {\n fetcher.load(containers).then(function(xhrs){\n for (const i=0; i<containers.length; i++) {\n const cont = containers[i];\n instances = instances.concat(solidLogicSingleton.store.each(cont, ns.ldp('contains')));\n }\n });\n }\n */\n\n return context\n })\n}\n\nfunction getDefaultSignInButtonStyle (): string {\n return 'padding: 1em; border-radius:0.5em; font-size: 100%;'\n}\n\n/**\n * Bootstrapping identity\n * (Called by `loginStatusBox()`)\n *\n * @param dom\n * @param setUserCallback\n *\n * @returns\n */\nfunction signInOrSignUpBox (\n dom: HTMLDocument,\n setUserCallback: (user: string) => void,\n options: {\n buttonStyle?: string;\n } = {}\n): HTMLElement {\n options = options || {}\n const signInButtonStyle = options.buttonStyle || getDefaultSignInButtonStyle()\n\n // @@ TODO Remove the need to cast HTML element to any\n const box: any = dom.createElement('div')\n const magicClassName = 'SolidSignInOrSignUpBox'\n debug.log('widgets.signInOrSignUpBox')\n box.setUserCallback = setUserCallback\n box.setAttribute('class', magicClassName);\n (box as any).style = 'display:flex;' // @@ fix all typecasts like this\n\n // Sign in button with PopUP\n const signInPopUpButton = dom.createElement('input') // multi\n box.appendChild(signInPopUpButton)\n signInPopUpButton.setAttribute('type', 'button')\n signInPopUpButton.setAttribute('value', 'Log in')\n signInPopUpButton.setAttribute('style', `${signInButtonStyle}background-color: #eef;`)\n\n authSession.onLogin(() => {\n const me = authn.currentUser()\n // const sessionInfo = authSession.info\n // if (sessionInfo && sessionInfo.isLoggedIn) {\n if (me) {\n // const webIdURI = sessionInfo.webId\n const webIdURI = me.uri\n // setUserCallback(webIdURI)\n const divs = dom.getElementsByClassName(magicClassName)\n debug.log(`Logged in, ${divs.length} panels to be serviced`)\n // At the same time, satisfy all the other login boxes\n for (let i = 0; i < divs.length; i++) {\n const div: any = divs[i]\n // @@ TODO Remove the need to manipulate HTML elements\n if (div.setUserCallback) {\n try {\n div.setUserCallback(webIdURI)\n const parent = div.parentNode\n if (parent) {\n parent.removeChild(div)\n }\n } catch (e) {\n debug.log(`## Error satisfying login box: ${e}`)\n div.appendChild(widgets.errorMessageBlock(dom, e))\n }\n }\n }\n }\n })\n\n signInPopUpButton.addEventListener(\n 'click',\n () => {\n const offline = offlineTestID()\n if (offline) return setUserCallback(offline.uri)\n\n renderSignInPopup(dom)\n },\n false\n )\n\n // Sign up button\n const signupButton = dom.createElement('input')\n box.appendChild(signupButton)\n signupButton.setAttribute('type', 'button')\n signupButton.setAttribute('value', 'Sign Up for Solid')\n signupButton.setAttribute('style', `${signInButtonStyle}background-color: #efe;`)\n\n signupButton.addEventListener(\n 'click',\n function (_event) {\n const signupMgr = new Signup()\n signupMgr.signup().then(function (uri) {\n debug.log('signInOrSignUpBox signed up ' + uri)\n setUserCallback(uri)\n })\n },\n false\n )\n return box\n}\n\nexport function renderSignInPopup (dom: HTMLDocument) {\n /**\n * Issuer Menu\n */\n const issuerPopup = dom.createElement('div')\n issuerPopup.setAttribute(\n 'style',\n 'position: fixed; top: 0; left: 0; right: 0; bottom: 0; display: flex; justify-content: center; align-items: center;'\n )\n dom.body.appendChild(issuerPopup)\n const issuerPopupBox = dom.createElement('div')\n issuerPopupBox.setAttribute(\n 'style',\n `\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 `\n )\n issuerPopup.appendChild(issuerPopupBox)\n const issuerPopupBoxTopMenu = dom.createElement('div')\n issuerPopupBoxTopMenu.setAttribute(\n 'style',\n `\n border-bottom: 1px solid #DDD;\n display: flex;\n flex-direction: row;\n align-items: center;\n justify-content: space-between;\n `\n )\n issuerPopupBox.appendChild(issuerPopupBoxTopMenu)\n const issuerPopupBoxLabel = dom.createElement('label')\n issuerPopupBoxLabel.setAttribute('style', 'margin-right: 5px; font-weight: 800')\n issuerPopupBoxLabel.innerText = 'Select an identity provider'\n const issuerPopupBoxCloseButton = dom.createElement('button')\n issuerPopupBoxCloseButton.innerHTML =\n '<img src=\"https://solidos.github.io/solid-ui/src/icons/noun_1180156.svg\" style=\"width: 2em; height: 2em;\" title=\"Cancel\">'\n issuerPopupBoxCloseButton.setAttribute('style', 'background-color: transparent; border: none;')\n issuerPopupBoxCloseButton.addEventListener('click', () => {\n issuerPopup.remove()\n })\n issuerPopupBoxTopMenu.appendChild(issuerPopupBoxLabel)\n issuerPopupBoxTopMenu.appendChild(issuerPopupBoxCloseButton)\n\n const loginToIssuer = async (issuerUri: string) => {\n try {\n // Save hash\n const preLoginRedirectHash = new URL(window.location.href).hash\n if (preLoginRedirectHash) {\n window.localStorage.setItem('preLoginRedirectHash', preLoginRedirectHash)\n }\n window.localStorage.setItem('loginIssuer', issuerUri)\n // Login\n await authSession.login({\n redirectUrl: window.location.href,\n oidcIssuer: issuerUri\n })\n } catch (err) {\n alert(err.message)\n }\n }\n\n /**\n * Text-based idp selection\n */\n const issuerTextContainer = dom.createElement('div')\n issuerTextContainer.setAttribute(\n 'style',\n `\n border-bottom: 1px solid #DDD;\n display: flex;\n flex-direction: column;\n padding-top: 10px;\n `\n )\n const issuerTextInputContainer = dom.createElement('div')\n issuerTextInputContainer.setAttribute(\n 'style',\n `\n display: flex;\n flex-direction: row;\n `\n )\n const issuerTextLabel = dom.createElement('label')\n issuerTextLabel.innerText = 'Enter the URL of your identity provider:'\n issuerTextLabel.setAttribute('style', 'color: #888')\n const issuerTextInput = dom.createElement('input')\n issuerTextInput.setAttribute('type', 'text')\n issuerTextInput.setAttribute(\n 'style',\n 'margin-left: 0 !important; flex: 1; margin-right: 5px !important'\n )\n issuerTextInput.setAttribute('placeholder', 'https://example.com')\n issuerTextInput.value = localStorage.getItem('loginIssuer') || ''\n const issuerTextGoButton = dom.createElement('button')\n issuerTextGoButton.innerText = 'Go'\n issuerTextGoButton.setAttribute('style', 'margin-top: 12px; margin-bottom: 12px;')\n issuerTextGoButton.addEventListener('click', () => {\n loginToIssuer(issuerTextInput.value)\n })\n issuerTextContainer.appendChild(issuerTextLabel)\n issuerTextInputContainer.appendChild(issuerTextInput)\n issuerTextInputContainer.appendChild(issuerTextGoButton)\n issuerTextContainer.appendChild(issuerTextInputContainer)\n issuerPopupBox.appendChild(issuerTextContainer)\n\n /**\n * Button-based idp selection\n */\n const issuerButtonContainer = dom.createElement('div')\n issuerButtonContainer.setAttribute(\n 'style',\n `\n display: flex;\n flex-direction: column;\n padding-top: 10px;\n `\n )\n const issuerBottonLabel = dom.createElement('label')\n issuerBottonLabel.innerText = 'Or pick an identity provider from the list below:'\n issuerBottonLabel.setAttribute('style', 'color: #888')\n issuerButtonContainer.appendChild(issuerBottonLabel)\n getSuggestedIssuers().forEach((issuerInfo) => {\n const issuerButton = dom.createElement('button')\n issuerButton.innerText = issuerInfo.name\n issuerButton.setAttribute('style', 'height: 38px; margin-top: 10px')\n issuerButton.addEventListener('click', () => {\n loginToIssuer(issuerInfo.uri)\n })\n issuerButtonContainer.appendChild(issuerButton)\n })\n issuerPopupBox.appendChild(issuerButtonContainer)\n}\n\n/**\n * Login status box\n *\n * A big sign-up/sign in box or a logout box depending on the state\n *\n * @param dom\n * @param listener\n *\n * @returns\n */\nexport function loginStatusBox (\n dom: HTMLDocument,\n listener: ((uri: string | null) => void) | null = null,\n options: {\n buttonStyle?: string;\n } = {}\n): HTMLElement {\n // 20190630\n let me = offlineTestID()\n // @@ TODO Remove the need to cast HTML element to any\n const box: any = dom.createElement('div')\n\n function setIt (newidURI) {\n if (!newidURI) {\n return\n }\n\n // const uri = newidURI.uri || newidURI\n // me = sym(uri)\n me = authn.saveUser(newidURI)\n box.refresh()\n if (listener) listener(me!.uri)\n }\n\n function logoutButtonHandler (_event) {\n const oldMe = me\n authSession.logout().then(\n function () {\n const message = `Your WebID was ${oldMe}. It has been forgotten.`\n me = null\n try {\n alert(message)\n } catch (e) {\n window.alert(message)\n }\n box.refresh()\n if (listener) listener(null)\n },\n (err) => {\n alert('Fail to log out:' + err)\n }\n )\n }\n\n function logoutButton (me, options) {\n const signInButtonStyle = options.buttonStyle || getDefaultSignInButtonStyle()\n let logoutLabel = 'WebID logout'\n if (me) {\n const nick =\n solidLogicSingleton.store.any(me, ns.foaf('nick')) ||\n solidLogicSingleton.store.any(me, ns.foaf('name'))\n if (nick) {\n logoutLabel = 'Logout ' + nick.value\n }\n }\n const signOutButton = dom.createElement('input')\n // signOutButton.className = 'WebIDCancelButton'\n signOutButton.setAttribute('type', 'button')\n signOutButton.setAttribute('value', logoutLabel)\n signOutButton.setAttribute('style', `${signInButtonStyle}background-color: #eee;`)\n signOutButton.addEventListener('click', logoutButtonHandler, false)\n return signOutButton\n }\n\n box.refresh = function () {\n me = authn.currentUser()\n if ((me && box.me !== me.uri) || (!me && box.me)) {\n widgets.clearElement(box)\n if (me) {\n box.appendChild(logoutButton(me, options))\n } else {\n box.appendChild(signInOrSignUpBox(dom, setIt, options))\n }\n }\n box.me = me ? me.uri : null\n }\n box.refresh()\n\n function trackSession () {\n me = authn.currentUser()\n box.refresh()\n }\n trackSession()\n\n authSession.onLogin(trackSession)\n authSession.onLogout(trackSession)\n box.me = '99999' // Force refresh\n box.refresh()\n return box\n}\n\nauthSession.onLogout(async () => {\n const issuer = window.localStorage.getItem('loginIssuer')\n if (issuer) {\n try {\n const wellKnownUri = new URL(issuer)\n wellKnownUri.pathname = '/.well-known/openid-configuration'\n const wellKnownResult = await fetch(wellKnownUri.toString())\n if (wellKnownResult.status === 200) {\n const openidConfiguration = await wellKnownResult.json()\n if (openidConfiguration && openidConfiguration.end_session_endpoint) {\n await fetch(openidConfiguration.end_session_endpoint, { credentials: 'include' })\n }\n }\n } catch (err) {\n // Do nothing\n }\n }\n window.location.reload()\n})\n\n/**\n * Workspace selection etc\n * See https://github.com/solidos/userguide/issues/16\n */\n\n/**\n * Returns a UI object which, if it selects a workspace,\n * will callback(workspace, newBase).\n * See https://github.com/solidos/userguide/issues/16 for more info on workspaces.\n *\n * If necessary, will get an account, preference file, etc. In sequence:\n *\n * - If not logged in, log in.\n * - Load preference file\n * - Prompt user for workspaces\n * - Allows the user to just type in a URI by hand\n *\n * Calls back with the workspace and the base URI\n *\n * @param dom\n * @param appDetails\n * @param callbackWS\n */\nexport function selectWorkspace (\n dom: HTMLDocument,\n appDetails: AppDetails,\n callbackWS: (workspace: string | null, newBase: string) => void\n): HTMLElement {\n const noun = appDetails.noun\n const appPathSegment = appDetails.appPathSegment\n\n const me = offlineTestID()\n const box = dom.createElement('div')\n const context: AuthenticationContext = { me, dom, div: box }\n\n function say (s, background) {\n box.appendChild(widgets.errorMessageBlock(dom, s, background))\n }\n\n function figureOutBase (ws) {\n const newBaseNode: NamedNode = solidLogicSingleton.store.any(\n ws,\n ns.space('uriPrefix')\n ) as NamedNode\n let newBaseString: string\n if (!newBaseNode) {\n newBaseString = ws.uri.split('#')[0]\n } else {\n newBaseString = newBaseNode.value\n }\n if (newBaseString.slice(-1) !== '/') {\n debug.log(`${appPathSegment}: No / at end of uriPrefix ${newBaseString}`) // @@ paramater?\n newBaseString = `${newBaseString}/`\n }\n const now = new Date()\n newBaseString += `${appPathSegment}/id${now.getTime()}/` // unique id\n return newBaseString\n }\n\n function displayOptions (context) {\n // console.log('displayOptions!', context)\n async function makeNewWorkspace (_event) {\n const row = table.appendChild(dom.createElement('tr'))\n const cell = row.appendChild(dom.createElement('td'))\n cell.setAttribute('colspan', '3')\n cell.style.padding = '0.5em'\n const newBase = encodeURI(\n await widgets.askName(\n dom,\n solidLogicSingleton.store,\n cell,\n ns.solid('URL'),\n ns.space('Workspace'),\n 'Workspace'\n )\n )\n const newWs = widgets.newThing(context.preferencesFile)\n const newData = [\n st(context.me, ns.space('workspace'), newWs, context.preferencesFile),\n // eslint-disable-next-line camelcase\n st(\n newWs,\n ns.space('uriPrefix'),\n newBase as unknown as Quad_Object,\n context.preferencesFile\n )\n ]\n if (!solidLogicSingleton.store.updater) {\n throw new Error('store has no updater')\n }\n await solidLogicSingleton.store.updater.update([], newData)\n // @@ now refresh list of workspaces\n }\n\n // const status = ''\n const id = context.me\n const preferencesFile = context.preferencesFile\n let newBase: any = null\n\n // A workspace specifically defined in the private preference file:\n let w: any = solidLogicSingleton.store.each(\n id,\n ns.space('workspace'),\n undefined,\n preferencesFile\n ) // Only trust preference file here\n\n // A workspace in a storage in the public profile:\n const storages = solidLogicSingleton.store.each(id, ns.space('storage')) // @@ No provenance requirement at the moment\n if (w.length === 0 && storages) {\n say(\n `You don't seem to have any workspaces. You have ${storages.length} storage spaces.`,\n 'white'\n )\n storages\n .map(function (s: any) {\n w = w.concat(solidLogicSingleton.store.each(s, ns.ldp('contains')))\n return w\n })\n .filter((file) => {\n return file.id ? ['public', 'private'].includes(file.id().toLowerCase()) : ''\n })\n }\n\n if (w.length === 1) {\n say(`Workspace used: ${w[0].uri}`, 'white') // @@ allow user to see URI\n newBase = figureOutBase(w[0])\n // callbackWS(w[0], newBase)\n // } else if (w.length === 0) {\n }\n\n // Prompt for ws selection or creation\n // say( w.length + \" workspaces for \" + id + \"Choose one.\");\n const table = dom.createElement('table')\n table.setAttribute('style', 'border-collapse:separate; border-spacing: 0.5em;')\n\n // const popup = window.open(undefined, '_blank', { height: 300, width:400 }, false)\n box.appendChild(table)\n\n // Add a field for directly adding the URI yourself\n\n // const hr = box.appendChild(dom.createElement('hr')) // @@\n box.appendChild(dom.createElement('hr')) // @@\n\n const p = box.appendChild(dom.createElement('p'));\n (p as any).style = commentStyle\n p.textContent = `Where would you like to store the data for the ${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.`\n // @@ TODO Remove the need to cast baseField to any\n const baseField: any = box.appendChild(dom.createElement('input'))\n baseField.setAttribute('type', 'text');\n (baseField as any).style = textInputStyle\n baseField.size = 80 // really a string\n baseField.label = 'base URL'\n baseField.autocomplete = 'on'\n if (newBase) {\n // set to default\n baseField.value = newBase\n }\n\n context.baseField = baseField\n\n box.appendChild(dom.createElement('br')) // @@\n\n const button = box.appendChild(dom.createElement('button'));\n (button as any).style = buttonStyle\n button.textContent = `Start new ${noun} at this URI`\n button.addEventListener('click', function (_event) {\n let newBase = baseField.value.replace(' ', '%20') // do not re-encode in general, as % encodings may exist\n if (newBase.slice(-1) !== '/') {\n newBase += '/'\n }\n callbackWS(null, newBase)\n })\n\n // Now go set up the table of spaces\n\n // const row = 0\n w = w.filter(function (x) {\n return !solidLogicSingleton.store.holds(\n x,\n ns.rdf('type'), // Ignore master workspaces\n ns.space('MasterWorkspace')\n )\n })\n let col1, col2, col3, tr, ws, style, comment\n const cellStyle = 'height: 3em; margin: 1em; padding: 1em white; border-radius: 0.3em;'\n const deselectedStyle = `${cellStyle}border: 0px;`\n // const selectedStyle = cellStyle + 'border: 1px solid black;'\n for (let i = 0; i < w.length; i++) {\n ws = w[i]\n tr = dom.createElement('tr')\n if (i === 0) {\n col1 = dom.createElement('td')\n col1.setAttribute('rowspan', `${w.length}`)\n col1.textContent = 'Choose a workspace for this:'\n col1.setAttribute('style', 'vertical-align:middle;')\n tr.appendChild(col1)\n }\n col2 = dom.createElement('td')\n style = solidLogicSingleton.store.anyValue(ws, ns.ui('style'))\n if (!style) {\n // Otherwise make up arbitrary colour\n const hash = function (x) {\n return x.split('').reduce(function (a, b) {\n a = (a << 5) - a + b.charCodeAt(0)\n return a & a\n }, 0)\n }\n const bgcolor = `#${((hash(ws.uri) & 0xffffff) | 0xc0c0c0).toString(16)}` // c0c0c0 forces pale\n style = `color: black ; background-color: ${bgcolor};`\n }\n col2.setAttribute('style', deselectedStyle + style)\n tr.target = ws.uri\n let label = solidLogicSingleton.store.any(ws, ns.rdfs('label'))\n if (!label) {\n label = ws.uri.split('/').slice(-1)[0] || ws.uri.split('/').slice(-2)[0]\n }\n col2.textContent = label || '???'\n tr.appendChild(col2)\n if (i === 0) {\n col3 = dom.createElement('td')\n col3.setAttribute('rowspan', `${w.length}1`)\n // col3.textContent = '@@@@@ remove';\n col3.setAttribute('style', 'width:50%;')\n tr.appendChild(col3)\n }\n table.appendChild(tr)\n\n comment = solidLogicSingleton.store.any(ws, ns.rdfs('comment'))\n comment = comment ? comment.value : 'Use this workspace'\n col2.addEventListener(\n 'click',\n function (_event) {\n col3.textContent = comment ? comment.value : ''\n col3.setAttribute('style', deselectedStyle + style)\n const button = dom.createElement('button')\n button.textContent = 'Continue'\n // button.setAttribute('style', style);\n const newBase = figureOutBase(ws)\n baseField.value = newBase // show user proposed URI\n\n button.addEventListener(\n 'click',\n function (_event) {\n button.disabled = true\n callbackWS(ws, newBase)\n button.textContent = '---->'\n },\n true\n ) // capture vs bubble\n col3.appendChild(button)\n },\n true\n ) // capture vs bubble\n }\n\n // last line with \"Make new workspace\"\n const trLast = dom.createElement('tr')\n col2 = dom.createElement('td')\n col2.setAttribute('style', cellStyle)\n col2.textContent = '+ Make a new workspace'\n col2.addEventListener('click', makeNewWorkspace)\n trLast.appendChild(col2)\n table.appendChild(trLast)\n } // displayOptions\n\n // console.log('kicking off async operation')\n ensureLoadedPreferences(context) // kick off async operation\n .then(displayOptions)\n .catch((err) => {\n // console.log(\"err from async op\")\n box.appendChild(widgets.errorMessageBlock(context.dom, err))\n })\n\n return box // return the box element, while login proceeds\n} // selectWorkspace\n\n/**\n * Creates a new instance of an app.\n *\n * An instance of an app could be e.g. an issue tracker for a given project,\n * or a chess game, or calendar, or a health/fitness record for a person.\n *\n * Note that this use of the term 'app' refers more to entries in the user's\n * type index than to actual software applications that use the personal data\n * to which these entries point.\n *\n * @param dom\n * @param appDetails\n * @param callback\n *\n * @returns A div with a button in it for making a new app instance\n */\nexport function newAppInstance (\n dom: HTMLDocument,\n appDetails: AppDetails,\n callback: (workspace: string | null, newBase: string) => void\n): HTMLElement {\n const gotWS = function (ws, base) {\n // log.debug(\"newAppInstance: Selected workspace = \" + (ws? ws.uri : 'none'))\n callback(ws, base)\n }\n const div = dom.createElement('div')\n const b = dom.createElement('button')\n b.setAttribute('type', 'button')\n div.appendChild(b)\n b.innerHTML = `Make new ${appDetails.noun}`\n b.addEventListener(\n 'click',\n (_event) => {\n div.appendChild(selectWorkspace(dom, appDetails, gotWS))\n },\n false\n )\n div.appendChild(b)\n return div\n}\n/**\n * Retrieves whether the currently logged in user is a power user\n * and/or a developer\n */\nexport async function getUserRoles (): Promise<Array<NamedNode>> {\n try {\n const { me, preferencesFile, preferencesFileError } = await ensureLoadedPreferences({})\n if (!preferencesFile || preferencesFileError) {\n throw new Error(preferencesFileError)\n }\n return solidLogicSingleton.store.each(\n me,\n ns.rdf('type'),\n null,\n preferencesFile.doc()\n ) as NamedNode[]\n } catch (error) {\n debug.warn('Unable to fetch your preferences - this was the error: ', error)\n }\n return []\n}\n\n/**\n * Filters which panes should be available, based on the result of [[getUserRoles]]\n */\nexport async function filterAvailablePanes (\n panes: Array<PaneDefinition>\n): Promise<Array<PaneDefinition>> {\n const userRoles = await getUserRoles()\n return panes.filter((pane) => isMatchingAudience(pane, userRoles))\n}\n\nfunction isMatchingAudience (pane: PaneDefinition, userRoles: Array<NamedNode>): boolean {\n const audience = pane.audience || []\n return audience.reduce(\n (isMatch, audienceRole) => isMatch && !!userRoles.find((role) => role.equals(audienceRole)),\n true as boolean\n )\n}\n"],"file":"login.js"}
|