solid-ui 2.6.1-b49f2e14 → 2.6.1-c6fc7fe

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.
Files changed (366) hide show
  1. package/LICENSE.md +3 -1
  2. package/README.md +84 -25
  3. package/dist/acl/access-controller.js +293 -0
  4. package/dist/acl/access-controller.js.map +1 -0
  5. package/dist/acl/access-groups.js +372 -0
  6. package/dist/acl/access-groups.js.map +1 -0
  7. package/dist/acl/acl-control.js +217 -0
  8. package/dist/acl/acl-control.js.map +1 -0
  9. package/dist/acl/acl.js +550 -0
  10. package/dist/acl/acl.js.map +1 -0
  11. package/dist/acl/add-agent-buttons.js +260 -0
  12. package/dist/acl/add-agent-buttons.js.map +1 -0
  13. package/dist/acl/index.js +35 -0
  14. package/dist/acl/index.js.map +1 -0
  15. package/dist/acl/types.js +7 -0
  16. package/dist/acl/types.js.map +1 -0
  17. package/{lib → dist}/chat/keys.d.ts +1 -1
  18. package/{lib → dist}/chat/keys.d.ts.map +1 -1
  19. package/dist/chat/keys.js +148 -0
  20. package/dist/chat/keys.js.map +1 -0
  21. package/dist/chat/signature.js +71 -0
  22. package/dist/chat/signature.js.map +1 -0
  23. package/dist/create/create.js +288 -0
  24. package/dist/create/create.js.map +1 -0
  25. package/dist/create/index.js +8 -0
  26. package/dist/create/index.js.map +1 -0
  27. package/dist/create/types.js +3 -0
  28. package/dist/create/types.js.map +1 -0
  29. package/dist/debug.js +23 -0
  30. package/dist/debug.js.map +1 -0
  31. package/dist/footer/index.js +72 -0
  32. package/dist/footer/index.js.map +1 -0
  33. package/dist/header/empty-profile.js +14 -0
  34. package/dist/header/empty-profile.js.map +1 -0
  35. package/dist/header/index.js +305 -0
  36. package/dist/header/index.js.map +1 -0
  37. package/dist/iconBase.js +40 -0
  38. package/dist/iconBase.js.map +1 -0
  39. package/dist/icons/solid_logo.js.map +1 -0
  40. package/{lib → dist}/index.d.ts +7 -9
  41. package/dist/index.d.ts.map +1 -0
  42. package/dist/index.js +162 -0
  43. package/dist/index.js.map +1 -0
  44. package/{lib → dist}/log.js +85 -99
  45. package/dist/log.js.map +1 -0
  46. package/dist/login/login.js +910 -0
  47. package/dist/login/login.js.map +1 -0
  48. package/dist/matrix/index.js +8 -0
  49. package/dist/matrix/index.js.map +1 -0
  50. package/dist/matrix/matrix.js +253 -0
  51. package/dist/matrix/matrix.js.map +1 -0
  52. package/dist/matrix/types.js +3 -0
  53. package/dist/matrix/types.js.map +1 -0
  54. package/dist/media/index.js +9 -0
  55. package/dist/media/index.js.map +1 -0
  56. package/dist/media/media-capture.js +198 -0
  57. package/dist/media/media-capture.js.map +1 -0
  58. package/dist/pad.js +795 -0
  59. package/dist/pad.js.map +1 -0
  60. package/dist/participation.js +228 -0
  61. package/dist/participation.js.map +1 -0
  62. package/dist/solid-ui.esm.js +25542 -0
  63. package/dist/solid-ui.esm.js.map +1 -0
  64. package/dist/solid-ui.esm.min.js +43 -0
  65. package/dist/solid-ui.esm.min.js.map +1 -0
  66. package/dist/solid-ui.js +23485 -68926
  67. package/dist/solid-ui.js.map +1 -1
  68. package/dist/solid-ui.min.js +40 -2
  69. package/dist/solid-ui.min.js.map +1 -1
  70. package/dist/tabs.js +398 -0
  71. package/dist/tabs.js.map +1 -0
  72. package/dist/utils/headerFooterHelpers.js +122 -0
  73. package/dist/utils/headerFooterHelpers.js.map +1 -0
  74. package/{lib → dist}/utils/keyHelpers/accessData.d.ts +3 -3
  75. package/{lib → dist}/utils/keyHelpers/accessData.d.ts.map +1 -1
  76. package/dist/utils/keyHelpers/accessData.js +108 -0
  77. package/dist/utils/keyHelpers/accessData.js.map +1 -0
  78. package/dist/utils/keyHelpers/acl.js +112 -0
  79. package/dist/utils/keyHelpers/acl.js.map +1 -0
  80. package/{lib → dist}/utils/keyHelpers/otherHelpers.d.ts +1 -1
  81. package/{lib → dist}/utils/keyHelpers/otherHelpers.d.ts.map +1 -1
  82. package/dist/utils/keyHelpers/otherHelpers.js +19 -0
  83. package/dist/utils/keyHelpers/otherHelpers.js.map +1 -0
  84. package/dist/utils/label.js +150 -0
  85. package/dist/utils/label.js.map +1 -0
  86. package/dist/versionInfo.js +33 -0
  87. package/dist/versionInfo.js.map +1 -0
  88. package/dist/widgets/buttons/iconLinks.js +49 -0
  89. package/dist/widgets/buttons/iconLinks.js.map +1 -0
  90. package/dist/widgets/buttons.js +1355 -0
  91. package/dist/widgets/buttons.js.map +1 -0
  92. package/dist/widgets/error.js +42 -0
  93. package/dist/widgets/error.js.map +1 -0
  94. package/dist/widgets/forms/autocomplete/autocompleteBar.js +162 -0
  95. package/dist/widgets/forms/autocomplete/autocompleteBar.js.map +1 -0
  96. package/dist/widgets/forms/autocomplete/autocompleteField.js +235 -0
  97. package/dist/widgets/forms/autocomplete/autocompleteField.js.map +1 -0
  98. package/dist/widgets/forms/autocomplete/autocompletePicker.js +296 -0
  99. package/dist/widgets/forms/autocomplete/autocompletePicker.js.map +1 -0
  100. package/dist/widgets/forms/autocomplete/language.js +147 -0
  101. package/dist/widgets/forms/autocomplete/language.js.map +1 -0
  102. package/{lib → dist}/widgets/forms/autocomplete/publicData.d.ts +3 -3
  103. package/dist/widgets/forms/autocomplete/publicData.d.ts.map +1 -0
  104. package/dist/widgets/forms/autocomplete/publicData.js +507 -0
  105. package/dist/widgets/forms/autocomplete/publicData.js.map +1 -0
  106. package/dist/widgets/forms/basic.js +250 -0
  107. package/dist/widgets/forms/basic.js.map +1 -0
  108. package/dist/widgets/forms/comment.js +52 -0
  109. package/dist/widgets/forms/comment.js.map +1 -0
  110. package/dist/widgets/forms/fieldFunction.js +49 -0
  111. package/dist/widgets/forms/fieldFunction.js.map +1 -0
  112. package/dist/widgets/forms/fieldParams.js +95 -0
  113. package/dist/widgets/forms/fieldParams.js.map +1 -0
  114. package/dist/widgets/forms/formStyle.js +43 -0
  115. package/dist/widgets/forms/formStyle.js.map +1 -0
  116. package/{lib → dist}/widgets/widgetHelpers.d.ts.map +1 -1
  117. package/{lib → dist}/widgets/widgetHelpers.js +19 -24
  118. package/dist/widgets/widgetHelpers.js.map +1 -0
  119. package/package.json +44 -47
  120. package/dist/789.solid-ui.min.js +0 -1
  121. package/dist/841.solid-ui.min.js +0 -3
  122. package/dist/841.solid-ui.min.js.LICENSE.txt +0 -58
  123. package/dist/841.solid-ui.min.js.map +0 -1
  124. package/dist/_2b19.solid-ui.js +0 -14
  125. package/dist/_2b19.solid-ui.js.map +0 -1
  126. package/dist/index.html +0 -1
  127. package/dist/solid-ui.min.js.LICENSE.txt +0 -57
  128. package/dist/vendors-node_modules_jsonld_lib_jsonld_js.solid-ui.js +0 -12247
  129. package/dist/vendors-node_modules_jsonld_lib_jsonld_js.solid-ui.js.map +0 -1
  130. package/lib/acl/access-controller.js +0 -391
  131. package/lib/acl/access-controller.js.map +0 -1
  132. package/lib/acl/access-groups.js +0 -507
  133. package/lib/acl/access-groups.js.map +0 -1
  134. package/lib/acl/acl-control.js +0 -237
  135. package/lib/acl/acl-control.js.map +0 -1
  136. package/lib/acl/acl.js +0 -517
  137. package/lib/acl/acl.js.map +0 -1
  138. package/lib/acl/add-agent-buttons.js +0 -434
  139. package/lib/acl/add-agent-buttons.js.map +0 -1
  140. package/lib/acl/index.js +0 -39
  141. package/lib/acl/index.js.map +0 -1
  142. package/lib/acl/types.js +0 -6
  143. package/lib/acl/types.js.map +0 -1
  144. package/lib/chat/bookmarks.js +0 -303
  145. package/lib/chat/bookmarks.js.map +0 -1
  146. package/lib/chat/chatLogic.js +0 -420
  147. package/lib/chat/chatLogic.js.map +0 -1
  148. package/lib/chat/dateFolder.js +0 -328
  149. package/lib/chat/dateFolder.js.map +0 -1
  150. package/lib/chat/infinite.js +0 -994
  151. package/lib/chat/infinite.js.map +0 -1
  152. package/lib/chat/keys.js +0 -232
  153. package/lib/chat/keys.js.map +0 -1
  154. package/lib/chat/message.js +0 -715
  155. package/lib/chat/message.js.map +0 -1
  156. package/lib/chat/messageTools.js +0 -538
  157. package/lib/chat/messageTools.js.map +0 -1
  158. package/lib/chat/signature.js +0 -109
  159. package/lib/chat/signature.js.map +0 -1
  160. package/lib/chat/thread.js +0 -535
  161. package/lib/chat/thread.js.map +0 -1
  162. package/lib/create/create.js +0 -242
  163. package/lib/create/create.js.map +0 -1
  164. package/lib/create/index.js +0 -11
  165. package/lib/create/index.js.map +0 -1
  166. package/lib/create/types.js +0 -6
  167. package/lib/create/types.js.map +0 -1
  168. package/lib/debug.js +0 -30
  169. package/lib/debug.js.map +0 -1
  170. package/lib/folders.js +0 -132
  171. package/lib/folders.js.map +0 -1
  172. package/lib/footer/index.js +0 -123
  173. package/lib/footer/index.js.map +0 -1
  174. package/lib/header/empty-profile.js +0 -8
  175. package/lib/header/empty-profile.js.map +0 -1
  176. package/lib/header/index.js +0 -375
  177. package/lib/header/index.js.map +0 -1
  178. package/lib/iconBase.js +0 -44
  179. package/lib/iconBase.js.map +0 -1
  180. package/lib/icons/solid_logo.js.map +0 -1
  181. package/lib/index.d.ts.map +0 -1
  182. package/lib/index.js +0 -223
  183. package/lib/index.js.map +0 -1
  184. package/lib/log.js.map +0 -1
  185. package/lib/login/login.js +0 -1241
  186. package/lib/login/login.js.map +0 -1
  187. package/lib/matrix/index.js +0 -11
  188. package/lib/matrix/index.js.map +0 -1
  189. package/lib/matrix/matrix.js +0 -216
  190. package/lib/matrix/matrix.js.map +0 -1
  191. package/lib/matrix/types.js +0 -6
  192. package/lib/matrix/types.js.map +0 -1
  193. package/lib/media/index.js +0 -12
  194. package/lib/media/index.js.map +0 -1
  195. package/lib/media/media-capture.js +0 -194
  196. package/lib/media/media-capture.js.map +0 -1
  197. package/lib/messageArea.js +0 -319
  198. package/lib/messageArea.js.map +0 -1
  199. package/lib/noun_Camera_1618446_000000.js +0 -8
  200. package/lib/noun_Camera_1618446_000000.js.map +0 -1
  201. package/lib/ns.js +0 -17
  202. package/lib/ns.js.map +0 -1
  203. package/lib/pad.js +0 -805
  204. package/lib/pad.js.map +0 -1
  205. package/lib/participation.js +0 -219
  206. package/lib/participation.js.map +0 -1
  207. package/lib/preferences.js +0 -215
  208. package/lib/preferences.js.map +0 -1
  209. package/lib/signup/config-default.js +0 -43
  210. package/lib/signup/config-default.js.map +0 -1
  211. package/lib/signup/signup.js +0 -74
  212. package/lib/signup/signup.js.map +0 -1
  213. package/lib/stories/decorators.js +0 -10
  214. package/lib/stories/decorators.js.map +0 -1
  215. package/lib/style.js +0 -158
  216. package/lib/style.js.map +0 -1
  217. package/lib/styleConstants.js +0 -35
  218. package/lib/styleConstants.js.map +0 -1
  219. package/lib/style_multiSelect.js +0 -62
  220. package/lib/style_multiSelect.js.map +0 -1
  221. package/lib/table.js +0 -1573
  222. package/lib/table.js.map +0 -1
  223. package/lib/tabs.js +0 -448
  224. package/lib/tabs.js.map +0 -1
  225. package/lib/typings.d.js +0 -2
  226. package/lib/typings.d.js.map +0 -1
  227. package/lib/utils/headerFooterHelpers.js +0 -165
  228. package/lib/utils/headerFooterHelpers.js.map +0 -1
  229. package/lib/utils/index.js +0 -527
  230. package/lib/utils/index.js.map +0 -1
  231. package/lib/utils/keyHelpers/accessData.js +0 -131
  232. package/lib/utils/keyHelpers/accessData.js.map +0 -1
  233. package/lib/utils/keyHelpers/acl.js +0 -90
  234. package/lib/utils/keyHelpers/acl.js.map +0 -1
  235. package/lib/utils/keyHelpers/otherHelpers.js +0 -21
  236. package/lib/utils/keyHelpers/otherHelpers.js.map +0 -1
  237. package/lib/utils/label.js +0 -103
  238. package/lib/utils/label.js.map +0 -1
  239. package/lib/versionInfo.d.ts +0 -32
  240. package/lib/versionInfo.d.ts.map +0 -1
  241. package/lib/versionInfo.js +0 -37
  242. package/lib/versionInfo.js.map +0 -1
  243. package/lib/widgets/buttons/iconLinks.js +0 -53
  244. package/lib/widgets/buttons/iconLinks.js.map +0 -1
  245. package/lib/widgets/buttons.js +0 -1306
  246. package/lib/widgets/buttons.js.map +0 -1
  247. package/lib/widgets/dragAndDrop.js +0 -194
  248. package/lib/widgets/dragAndDrop.js.map +0 -1
  249. package/lib/widgets/error.js +0 -46
  250. package/lib/widgets/error.js.map +0 -1
  251. package/lib/widgets/forms/autocomplete/autocompleteBar.js +0 -271
  252. package/lib/widgets/forms/autocomplete/autocompleteBar.js.map +0 -1
  253. package/lib/widgets/forms/autocomplete/autocompleteField.js +0 -258
  254. package/lib/widgets/forms/autocomplete/autocompleteField.js.map +0 -1
  255. package/lib/widgets/forms/autocomplete/autocompletePicker.js +0 -436
  256. package/lib/widgets/forms/autocomplete/autocompletePicker.js.map +0 -1
  257. package/lib/widgets/forms/autocomplete/language.js +0 -189
  258. package/lib/widgets/forms/autocomplete/language.js.map +0 -1
  259. package/lib/widgets/forms/autocomplete/publicData.d.ts.map +0 -1
  260. package/lib/widgets/forms/autocomplete/publicData.js +0 -636
  261. package/lib/widgets/forms/autocomplete/publicData.js.map +0 -1
  262. package/lib/widgets/forms/basic.js +0 -254
  263. package/lib/widgets/forms/basic.js.map +0 -1
  264. package/lib/widgets/forms/comment.js +0 -54
  265. package/lib/widgets/forms/comment.js.map +0 -1
  266. package/lib/widgets/forms/fieldFunction.js +0 -52
  267. package/lib/widgets/forms/fieldFunction.js.map +0 -1
  268. package/lib/widgets/forms/fieldParams.js +0 -77
  269. package/lib/widgets/forms/fieldParams.js.map +0 -1
  270. package/lib/widgets/forms/formStyle.js +0 -44
  271. package/lib/widgets/forms/formStyle.js.map +0 -1
  272. package/lib/widgets/forms.js +0 -2045
  273. package/lib/widgets/forms.js.map +0 -1
  274. package/lib/widgets/index.js +0 -110
  275. package/lib/widgets/index.js.map +0 -1
  276. package/lib/widgets/multiSelect.js +0 -658
  277. package/lib/widgets/multiSelect.js.map +0 -1
  278. package/lib/widgets/peoplePicker.js +0 -467
  279. package/lib/widgets/peoplePicker.js.map +0 -1
  280. package/lib/widgets/widgetHelpers.js.map +0 -1
  281. /package/{lib → dist}/acl/access-controller.d.ts +0 -0
  282. /package/{lib → dist}/acl/access-controller.d.ts.map +0 -0
  283. /package/{lib → dist}/acl/access-groups.d.ts +0 -0
  284. /package/{lib → dist}/acl/access-groups.d.ts.map +0 -0
  285. /package/{lib → dist}/acl/acl-control.d.ts +0 -0
  286. /package/{lib → dist}/acl/acl-control.d.ts.map +0 -0
  287. /package/{lib → dist}/acl/acl.d.ts +0 -0
  288. /package/{lib → dist}/acl/acl.d.ts.map +0 -0
  289. /package/{lib → dist}/acl/add-agent-buttons.d.ts +0 -0
  290. /package/{lib → dist}/acl/add-agent-buttons.d.ts.map +0 -0
  291. /package/{lib → dist}/acl/index.d.ts +0 -0
  292. /package/{lib → dist}/acl/index.d.ts.map +0 -0
  293. /package/{lib → dist}/acl/types.d.ts +0 -0
  294. /package/{lib → dist}/acl/types.d.ts.map +0 -0
  295. /package/{lib → dist}/chat/signature.d.ts +0 -0
  296. /package/{lib → dist}/chat/signature.d.ts.map +0 -0
  297. /package/{lib → dist}/create/create.d.ts +0 -0
  298. /package/{lib → dist}/create/create.d.ts.map +0 -0
  299. /package/{lib → dist}/create/index.d.ts +0 -0
  300. /package/{lib → dist}/create/index.d.ts.map +0 -0
  301. /package/{lib → dist}/create/types.d.ts +0 -0
  302. /package/{lib → dist}/create/types.d.ts.map +0 -0
  303. /package/{lib → dist}/debug.d.ts +0 -0
  304. /package/{lib → dist}/debug.d.ts.map +0 -0
  305. /package/{lib → dist}/footer/index.d.ts +0 -0
  306. /package/{lib → dist}/footer/index.d.ts.map +0 -0
  307. /package/{lib → dist}/header/empty-profile.d.ts +0 -0
  308. /package/{lib → dist}/header/empty-profile.d.ts.map +0 -0
  309. /package/{lib → dist}/header/index.d.ts +0 -0
  310. /package/{lib → dist}/header/index.d.ts.map +0 -0
  311. /package/{lib → dist}/iconBase.d.ts +0 -0
  312. /package/{lib → dist}/iconBase.d.ts.map +0 -0
  313. /package/{lib → dist}/icons/solid_logo.d.ts +0 -0
  314. /package/{lib → dist}/icons/solid_logo.d.ts.map +0 -0
  315. /package/{lib → dist}/icons/solid_logo.js +0 -0
  316. /package/{lib → dist}/log.d.ts +0 -0
  317. /package/{lib → dist}/log.d.ts.map +0 -0
  318. /package/{lib → dist}/login/login.d.ts +0 -0
  319. /package/{lib → dist}/login/login.d.ts.map +0 -0
  320. /package/{lib → dist}/matrix/index.d.ts +0 -0
  321. /package/{lib → dist}/matrix/index.d.ts.map +0 -0
  322. /package/{lib → dist}/matrix/matrix.d.ts +0 -0
  323. /package/{lib → dist}/matrix/matrix.d.ts.map +0 -0
  324. /package/{lib → dist}/matrix/types.d.ts +0 -0
  325. /package/{lib → dist}/matrix/types.d.ts.map +0 -0
  326. /package/{lib → dist}/media/index.d.ts +0 -0
  327. /package/{lib → dist}/media/index.d.ts.map +0 -0
  328. /package/{lib → dist}/media/media-capture.d.ts +0 -0
  329. /package/{lib → dist}/media/media-capture.d.ts.map +0 -0
  330. /package/{lib → dist}/pad.d.ts +0 -0
  331. /package/{lib → dist}/pad.d.ts.map +0 -0
  332. /package/{lib → dist}/participation.d.ts +0 -0
  333. /package/{lib → dist}/participation.d.ts.map +0 -0
  334. /package/{lib → dist}/tabs.d.ts +0 -0
  335. /package/{lib → dist}/tabs.d.ts.map +0 -0
  336. /package/{lib → dist}/utils/headerFooterHelpers.d.ts +0 -0
  337. /package/{lib → dist}/utils/headerFooterHelpers.d.ts.map +0 -0
  338. /package/{lib → dist}/utils/keyHelpers/acl.d.ts +0 -0
  339. /package/{lib → dist}/utils/keyHelpers/acl.d.ts.map +0 -0
  340. /package/{lib → dist}/utils/label.d.ts +0 -0
  341. /package/{lib → dist}/utils/label.d.ts.map +0 -0
  342. /package/{lib → dist}/widgets/buttons/iconLinks.d.ts +0 -0
  343. /package/{lib → dist}/widgets/buttons/iconLinks.d.ts.map +0 -0
  344. /package/{lib → dist}/widgets/buttons.d.ts +0 -0
  345. /package/{lib → dist}/widgets/buttons.d.ts.map +0 -0
  346. /package/{lib → dist}/widgets/error.d.ts +0 -0
  347. /package/{lib → dist}/widgets/error.d.ts.map +0 -0
  348. /package/{lib → dist}/widgets/forms/autocomplete/autocompleteBar.d.ts +0 -0
  349. /package/{lib → dist}/widgets/forms/autocomplete/autocompleteBar.d.ts.map +0 -0
  350. /package/{lib → dist}/widgets/forms/autocomplete/autocompleteField.d.ts +0 -0
  351. /package/{lib → dist}/widgets/forms/autocomplete/autocompleteField.d.ts.map +0 -0
  352. /package/{lib → dist}/widgets/forms/autocomplete/autocompletePicker.d.ts +0 -0
  353. /package/{lib → dist}/widgets/forms/autocomplete/autocompletePicker.d.ts.map +0 -0
  354. /package/{lib → dist}/widgets/forms/autocomplete/language.d.ts +0 -0
  355. /package/{lib → dist}/widgets/forms/autocomplete/language.d.ts.map +0 -0
  356. /package/{lib → dist}/widgets/forms/basic.d.ts +0 -0
  357. /package/{lib → dist}/widgets/forms/basic.d.ts.map +0 -0
  358. /package/{lib → dist}/widgets/forms/comment.d.ts +0 -0
  359. /package/{lib → dist}/widgets/forms/comment.d.ts.map +0 -0
  360. /package/{lib → dist}/widgets/forms/fieldFunction.d.ts +0 -0
  361. /package/{lib → dist}/widgets/forms/fieldFunction.d.ts.map +0 -0
  362. /package/{lib → dist}/widgets/forms/fieldParams.d.ts +0 -0
  363. /package/{lib → dist}/widgets/forms/fieldParams.d.ts.map +0 -0
  364. /package/{lib → dist}/widgets/forms/formStyle.d.ts +0 -0
  365. /package/{lib → dist}/widgets/forms/formStyle.d.ts.map +0 -0
  366. /package/{lib → dist}/widgets/widgetHelpers.d.ts +0 -0
@@ -0,0 +1,910 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ var __importDefault = (this && this.__importDefault) || function (mod) {
36
+ return (mod && mod.__esModule) ? mod : { "default": mod };
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.ensureLoggedIn = ensureLoggedIn;
40
+ exports.ensureLoadedPreferences = ensureLoadedPreferences;
41
+ exports.ensureLoadedProfile = ensureLoadedProfile;
42
+ exports.findAppInstances = findAppInstances;
43
+ exports.scopeLabel = scopeLabel;
44
+ exports.registrationControl = registrationControl;
45
+ exports.renderScopeHeadingRow = renderScopeHeadingRow;
46
+ exports.registrationList = registrationList;
47
+ exports.renderSignInPopup = renderSignInPopup;
48
+ exports.loginStatusBox = loginStatusBox;
49
+ exports.selectWorkspace = selectWorkspace;
50
+ exports.newAppInstance = newAppInstance;
51
+ exports.getUserRoles = getUserRoles;
52
+ exports.filterAvailablePanes = filterAvailablePanes;
53
+ const rdflib_1 = require("rdflib");
54
+ const solid_logic_1 = require("solid-logic");
55
+ const debug = __importStar(require("../debug"));
56
+ const style_1 = require("../style");
57
+ const log_1 = require("../log");
58
+ const ns_1 = __importDefault(require("../ns"));
59
+ const signup_js_1 = require("../signup/signup.js");
60
+ const utils = __importStar(require("../utils"));
61
+ const widgets = __importStar(require("../widgets"));
62
+ const store = solid_logic_1.solidLogicSingleton.store;
63
+ const { loadPreferences, loadProfile } = solid_logic_1.solidLogicSingleton.profile;
64
+ const { getScopedAppInstances, getRegistrations, loadAllTypeIndexes, getScopedAppsFromIndex, deleteTypeIndexRegistration } = solid_logic_1.solidLogicSingleton.typeIndex;
65
+ /**
66
+ * Resolves with the logged in user's WebID
67
+ *
68
+ * @param context
69
+ */
70
+ // used to be logIn
71
+ function ensureLoggedIn(context) {
72
+ const me = solid_logic_1.authn.currentUser();
73
+ if (me) {
74
+ solid_logic_1.authn.saveUser(me, context);
75
+ return Promise.resolve(context);
76
+ }
77
+ return new Promise((resolve) => {
78
+ solid_logic_1.authn.checkUser().then((webId) => {
79
+ // Already logged in?
80
+ if (webId) {
81
+ debug.log(`logIn: Already logged in as ${webId}`);
82
+ return resolve(context);
83
+ }
84
+ if (!context.div || !context.dom) {
85
+ return resolve(context);
86
+ }
87
+ const box = loginStatusBox(context.dom, (webIdUri) => {
88
+ solid_logic_1.authn.saveUser(webIdUri, context);
89
+ resolve(context); // always pass growing context
90
+ });
91
+ context.div.appendChild(box);
92
+ });
93
+ });
94
+ }
95
+ /**
96
+ * Loads preference file
97
+ * Do this after having done log in and load profile
98
+ *
99
+ * @private
100
+ *
101
+ * @param context
102
+ */
103
+ // used to be logInLoadPreferences
104
+ async function ensureLoadedPreferences(context) {
105
+ if (context.preferencesFile)
106
+ return Promise.resolve(context); // already done
107
+ // const statusArea = context.statusArea || context.div || null
108
+ let progressDisplay;
109
+ /* COMPLAIN FUNCTION NOT USED/TAKING IT OUT FOR NOW
110
+ function complain (message) {
111
+ message = `ensureLoadedPreferences: ${message}`
112
+ if (statusArea) {
113
+ // statusArea.innerHTML = ''
114
+ statusArea.appendChild(widgets.errorMessageBlock(context.dom, message))
115
+ }
116
+ debug.log(message)
117
+ // reject(new Error(message))
118
+ } */
119
+ try {
120
+ context = await ensureLoadedProfile(context);
121
+ // console.log('back in Solid UI after logInLoadProfile', context)
122
+ const preferencesFile = await loadPreferences(context.me);
123
+ if (progressDisplay) {
124
+ progressDisplay.parentNode.removeChild(progressDisplay);
125
+ }
126
+ context.preferencesFile = preferencesFile;
127
+ }
128
+ catch (err) {
129
+ let m2;
130
+ if (err instanceof solid_logic_1.UnauthorizedError) {
131
+ m2 =
132
+ 'Oops — you are not authenticated (properly logged in), so SolidOS cannot read your preferences file. Try logging out and then logging back in.';
133
+ (0, log_1.alert)(m2);
134
+ }
135
+ else if (err instanceof solid_logic_1.CrossOriginForbiddenError) {
136
+ m2 = `Unauthorized: Assuming preference file blocked for origin ${window.location.origin}`;
137
+ context.preferencesFileError = m2;
138
+ return context;
139
+ }
140
+ else if (err instanceof solid_logic_1.SameOriginForbiddenError) {
141
+ m2 =
142
+ 'You are not authorized to read your preference file. This may be because you are using an untrusted web app.';
143
+ debug.warn(m2);
144
+ return context;
145
+ }
146
+ else if (err instanceof solid_logic_1.NotEditableError) {
147
+ m2 =
148
+ 'You are not authorized to edit your preference file. This may be because you are using an untrusted web app.';
149
+ debug.warn(m2);
150
+ return context;
151
+ }
152
+ else if (err instanceof solid_logic_1.WebOperationError) {
153
+ m2 =
154
+ 'You are not authorized to edit your preference file. This may be because you are using an untrusted web app.';
155
+ debug.warn(m2);
156
+ }
157
+ else if (err instanceof solid_logic_1.FetchError) {
158
+ m2 = `Strange: Error ${err.status} trying to read your preference file.${err.message}`;
159
+ (0, log_1.alert)(m2);
160
+ }
161
+ else {
162
+ throw new Error(`(via loadPrefs) ${err}`);
163
+ }
164
+ }
165
+ return context;
166
+ }
167
+ /**
168
+ * Logs the user in and loads their WebID profile document into the store
169
+ *
170
+ * @param context
171
+ *
172
+ * @returns Resolves with the context after login / fetch
173
+ */
174
+ // used to be logInLoadProfile
175
+ async function ensureLoadedProfile(context) {
176
+ if (context.publicProfile) {
177
+ return context;
178
+ } // already done
179
+ try {
180
+ const logInContext = await ensureLoggedIn(context);
181
+ if (!logInContext.me) {
182
+ throw new Error('Could not log in');
183
+ }
184
+ context.publicProfile = await loadProfile(logInContext.me);
185
+ }
186
+ catch (err) {
187
+ if (context.div && context.dom) {
188
+ context.div.appendChild(widgets.errorMessageBlock(context.dom, err.message));
189
+ }
190
+ throw new Error(`Can't log in: ${err}`);
191
+ }
192
+ return context;
193
+ }
194
+ /**
195
+ * Returns promise of context with arrays of symbols
196
+ *
197
+ * leaving the `isPublic` param undefined will bring in community index things, too
198
+ */
199
+ async function findAppInstances(context, theClass, isPublic) {
200
+ let items = context.me ? await getScopedAppInstances(theClass, context.me) : [];
201
+ if (isPublic === true) { // old API - not recommended!
202
+ items = items.filter(item => item.scope.label === 'public');
203
+ }
204
+ else if (isPublic === false) {
205
+ items = items.filter(item => item.scope.label === 'private');
206
+ }
207
+ context.instances = items.map(item => item.instance);
208
+ return context;
209
+ }
210
+ function scopeLabel(context, scope) {
211
+ const mine = context.me && context.me.sameTerm(scope.agent);
212
+ const name = mine ? '' : utils.label(scope.agent) + ' ';
213
+ return `${name}${scope.label}`;
214
+ }
215
+ /**
216
+ * UI to control registration of instance
217
+ */
218
+ async function registrationControl(context, instance, theClass) {
219
+ function registrationStatements(index) {
220
+ const registrations = getRegistrations(instance, theClass);
221
+ const reg = registrations.length ? registrations[0] : widgets.newThing(index);
222
+ return [
223
+ (0, rdflib_1.st)(reg, ns_1.default.solid('instance'), instance, index),
224
+ (0, rdflib_1.st)(reg, ns_1.default.solid('forClass'), theClass, index)
225
+ ];
226
+ }
227
+ function renderScopeCheckbox(scope) {
228
+ const statements = registrationStatements(scope.index);
229
+ const name = scopeLabel(context, scope);
230
+ const label = `${name} link to this ${context.noun}`;
231
+ return widgets.buildCheckboxForm(context.dom, solid_logic_1.solidLogicSingleton.store, label, null, statements, form, scope.index);
232
+ }
233
+ /// / body of registrationControl
234
+ const dom = context.dom;
235
+ if (!dom || !context.div) {
236
+ throw new Error('registrationControl: need dom and div');
237
+ }
238
+ const box = dom.createElement('div');
239
+ context.div.appendChild(box);
240
+ context.me = solid_logic_1.authn.currentUser(); // @@
241
+ const me = context.me;
242
+ if (!me) {
243
+ box.innerHTML = '<p style="margin:2em;">(Log in to save a link to this)</p>';
244
+ return context;
245
+ }
246
+ let scopes; // @@ const
247
+ try {
248
+ scopes = await loadAllTypeIndexes(me);
249
+ }
250
+ catch (e) {
251
+ let msg;
252
+ if (context.div && context.preferencesFileError) {
253
+ msg = '(Lists of stuff not available)';
254
+ context.div.appendChild(dom.createElement('p')).textContent = msg;
255
+ }
256
+ else if (context.div) {
257
+ msg = `registrationControl: Type indexes not available: ${e}`;
258
+ context.div.appendChild(widgets.errorMessageBlock(context.dom, e));
259
+ }
260
+ debug.log(msg);
261
+ return context;
262
+ }
263
+ box.innerHTML = '<table><tbody></tbody></table>'; // tbody will be inserted anyway
264
+ box.setAttribute('style', 'font-size: 120%; text-align: right; padding: 1em; border: solid gray 0.05em;');
265
+ const tbody = box.children[0].children[0];
266
+ const form = new rdflib_1.BlankNode(); // @@ say for now
267
+ for (const scope of scopes) {
268
+ const row = tbody.appendChild(dom.createElement('tr'));
269
+ row.appendChild(renderScopeCheckbox(scope)); // @@ index
270
+ }
271
+ return context;
272
+ }
273
+ function renderScopeHeadingRow(context, store, scope) {
274
+ const backgroundColor = { private: '#fee', public: '#efe' };
275
+ const { dom } = context;
276
+ const name = scopeLabel(context, scope);
277
+ const row = dom.createElement('tr');
278
+ const cell = row.appendChild(dom.createElement('td'));
279
+ cell.setAttribute('colspan', '3');
280
+ cell.style.backgoundColor = backgroundColor[scope.label] || 'white';
281
+ const header = cell.appendChild(dom.createElement('h3'));
282
+ header.textContent = name + ' links';
283
+ header.style.textAlign = 'left';
284
+ return row;
285
+ }
286
+ /**
287
+ * UI to List at all registered things
288
+ */
289
+ async function registrationList(context, options) {
290
+ const dom = context.dom;
291
+ const div = context.div;
292
+ const box = dom.createElement('div');
293
+ div.appendChild(box);
294
+ context.me = solid_logic_1.authn.currentUser(); // @@
295
+ if (!context.me) {
296
+ box.innerHTML = '<p style="margin:2em;">(Log in list your stuff)</p>';
297
+ return context;
298
+ }
299
+ const scopes = await loadAllTypeIndexes(context.me); // includes community indexes
300
+ // console.log('@@ registrationList ', scopes)
301
+ box.innerHTML = '<table><tbody></tbody></table>'; // tbody will be inserted anyway
302
+ box.setAttribute('style', 'font-size: 120%; text-align: right; padding: 1em; border: solid #eee 0.5em;');
303
+ const table = box.firstChild;
304
+ const tbody = table.firstChild;
305
+ for (const scope of scopes) { // need some predicate for listing/adding agents
306
+ const headingRow = renderScopeHeadingRow(context, store, scope);
307
+ tbody.appendChild(headingRow);
308
+ const items = await getScopedAppsFromIndex(scope, options.type || null); // any class
309
+ if (items.length === 0)
310
+ headingRow.style.display = 'none';
311
+ // console.log(`registrationList: @@ instance items for class ${options.type || 'undefined' }:`, items)
312
+ for (const item of items) {
313
+ const row = widgets.personTR(dom, ns_1.default.solid('instance'), item.instance, {
314
+ deleteFunction: async () => {
315
+ await deleteTypeIndexRegistration(item);
316
+ tbody.removeChild(row);
317
+ }
318
+ });
319
+ row.children[0].style.paddingLeft = '3em';
320
+ tbody.appendChild(row);
321
+ }
322
+ }
323
+ return context;
324
+ } // registrationList
325
+ /**
326
+ * Bootstrapping identity
327
+ * (Called by `loginStatusBox()`)
328
+ *
329
+ * @param dom
330
+ * @param setUserCallback
331
+ *
332
+ * @returns
333
+ */
334
+ function signInOrSignUpBox(dom, setUserCallback, options = {}) {
335
+ options = options || {};
336
+ const signInButtonStyle = options.buttonStyle || style_1.style.signInAndUpButtonStyle;
337
+ const box = dom.createElement('div');
338
+ const magicClassName = 'SolidSignInOrSignUpBox';
339
+ debug.log('widgets.signInOrSignUpBox');
340
+ box.setUserCallback = setUserCallback;
341
+ box.setAttribute('class', magicClassName);
342
+ box.setAttribute('style', 'display:flex;');
343
+ // Sign in button with PopUP
344
+ const signInPopUpButton = dom.createElement('input'); // multi
345
+ box.appendChild(signInPopUpButton);
346
+ signInPopUpButton.setAttribute('type', 'button');
347
+ signInPopUpButton.setAttribute('value', 'Log in');
348
+ signInPopUpButton.setAttribute('style', `${signInButtonStyle}${style_1.style.headerBannerLoginInput}` + style_1.style.signUpBackground);
349
+ solid_logic_1.authSession.events.on('login', () => {
350
+ const me = solid_logic_1.authn.currentUser();
351
+ // const sessionInfo = authSession.info
352
+ // if (sessionInfo && sessionInfo.isLoggedIn) {
353
+ if (me) {
354
+ // const webIdURI = sessionInfo.webId
355
+ const webIdURI = me.uri;
356
+ // setUserCallback(webIdURI)
357
+ const divs = dom.getElementsByClassName(magicClassName);
358
+ debug.log(`Logged in, ${divs.length} panels to be serviced`);
359
+ // At the same time, satisfy all the other login boxes
360
+ for (let i = 0; i < divs.length; i++) {
361
+ const div = divs[i];
362
+ // @@ TODO Remove the need to manipulate HTML elements
363
+ if (div.setUserCallback) {
364
+ try {
365
+ div.setUserCallback(webIdURI);
366
+ const parent = div.parentNode;
367
+ if (parent) {
368
+ parent.removeChild(div);
369
+ }
370
+ }
371
+ catch (e) {
372
+ debug.log(`## Error satisfying login box: ${e}`);
373
+ div.appendChild(widgets.errorMessageBlock(dom, e));
374
+ }
375
+ }
376
+ }
377
+ }
378
+ });
379
+ signInPopUpButton.addEventListener('click', () => {
380
+ const offline = (0, solid_logic_1.offlineTestID)();
381
+ if (offline)
382
+ return setUserCallback(offline.uri);
383
+ renderSignInPopup(dom);
384
+ }, false);
385
+ // Sign up button
386
+ const signupButton = dom.createElement('input');
387
+ box.appendChild(signupButton);
388
+ signupButton.setAttribute('type', 'button');
389
+ signupButton.setAttribute('value', 'Sign Up for Solid');
390
+ signupButton.setAttribute('style', `${signInButtonStyle}${style_1.style.headerBannerLoginInput}` + style_1.style.signInBackground);
391
+ signupButton.addEventListener('click', function (_event) {
392
+ const signupMgr = new signup_js_1.Signup();
393
+ signupMgr.signup().then(function (uri) {
394
+ debug.log('signInOrSignUpBox signed up ' + uri);
395
+ setUserCallback(uri);
396
+ });
397
+ }, false);
398
+ return box;
399
+ }
400
+ function renderSignInPopup(dom) {
401
+ /**
402
+ * Issuer Menu
403
+ */
404
+ const issuerPopup = dom.createElement('div');
405
+ issuerPopup.setAttribute('style', 'position: fixed; top: 0; left: 0; right: 0; bottom: 0; display: flex; justify-content: center; align-items: center;');
406
+ dom.body.appendChild(issuerPopup);
407
+ const issuerPopupBox = dom.createElement('div');
408
+ issuerPopupBox.setAttribute('style', `
409
+ background-color: white;
410
+ box-shadow: 0px 1px 4px rgba(0, 0, 0, 0.2);
411
+ -webkit-box-shadow: 0px 1px 4px rgba(0, 0, 0, 0.2);
412
+ -moz-box-shadow: 0px 1px 4px rgba(0, 0, 0, 0.2);
413
+ -o-box-shadow: 0px 1px 4px rgba(0, 0, 0, 0.2);
414
+ border-radius: 4px;
415
+ min-width: 400px;
416
+ padding: 10px;
417
+ z-index : 10;
418
+ `);
419
+ issuerPopup.appendChild(issuerPopupBox);
420
+ const issuerPopupBoxTopMenu = dom.createElement('div');
421
+ issuerPopupBoxTopMenu.setAttribute('style', `
422
+ border-bottom: 1px solid #DDD;
423
+ display: flex;
424
+ flex-direction: row;
425
+ align-items: center;
426
+ justify-content: space-between;
427
+ `);
428
+ issuerPopupBox.appendChild(issuerPopupBoxTopMenu);
429
+ const issuerPopupBoxLabel = dom.createElement('label');
430
+ issuerPopupBoxLabel.setAttribute('style', 'margin-right: 5px; font-weight: 800');
431
+ issuerPopupBoxLabel.innerText = 'Select an identity provider';
432
+ const issuerPopupBoxCloseButton = dom.createElement('button');
433
+ issuerPopupBoxCloseButton.innerHTML =
434
+ '<img src="https://solidos.github.io/solid-ui/src/icons/noun_1180156.svg" style="width: 2em; height: 2em;" title="Cancel">';
435
+ issuerPopupBoxCloseButton.setAttribute('style', 'background-color: transparent; border: none;');
436
+ issuerPopupBoxCloseButton.addEventListener('click', () => {
437
+ issuerPopup.remove();
438
+ });
439
+ issuerPopupBoxTopMenu.appendChild(issuerPopupBoxLabel);
440
+ issuerPopupBoxTopMenu.appendChild(issuerPopupBoxCloseButton);
441
+ const loginToIssuer = async (issuerUri) => {
442
+ try {
443
+ // clear authorization metadata from store
444
+ solid_logic_1.solidLogicSingleton.store.updater.flagAuthorizationMetadata();
445
+ // Save hash
446
+ const preLoginRedirectHash = new URL(window.location.href).hash;
447
+ if (preLoginRedirectHash) {
448
+ window.localStorage.setItem('preLoginRedirectHash', preLoginRedirectHash);
449
+ }
450
+ window.localStorage.setItem('loginIssuer', issuerUri);
451
+ // Login
452
+ const locationUrl = new URL(window.location.href);
453
+ locationUrl.hash = ''; // remove hash part
454
+ await solid_logic_1.authSession.login({
455
+ redirectUrl: locationUrl.href,
456
+ oidcIssuer: issuerUri
457
+ });
458
+ }
459
+ catch (err) {
460
+ (0, log_1.alert)(err.message);
461
+ }
462
+ };
463
+ /**
464
+ * Text-based idp selection
465
+ */
466
+ const issuerTextContainer = dom.createElement('div');
467
+ issuerTextContainer.setAttribute('style', `
468
+ border-bottom: 1px solid #DDD;
469
+ display: flex;
470
+ flex-direction: column;
471
+ padding-top: 10px;
472
+ `);
473
+ const issuerTextInputContainer = dom.createElement('div');
474
+ issuerTextInputContainer.setAttribute('style', `
475
+ display: flex;
476
+ flex-direction: row;
477
+ `);
478
+ const issuerTextLabel = dom.createElement('label');
479
+ issuerTextLabel.innerText = 'Enter the URL of your identity provider:';
480
+ issuerTextLabel.setAttribute('style', 'color: #888');
481
+ const issuerTextInput = dom.createElement('input');
482
+ issuerTextInput.setAttribute('type', 'text');
483
+ issuerTextInput.setAttribute('style', 'margin-left: 0 !important; flex: 1; margin-right: 5px !important');
484
+ issuerTextInput.setAttribute('placeholder', 'https://example.com');
485
+ issuerTextInput.value = localStorage.getItem('loginIssuer') || '';
486
+ const issuerTextGoButton = dom.createElement('button');
487
+ issuerTextGoButton.innerText = 'Go';
488
+ issuerTextGoButton.setAttribute('style', 'margin-top: 12px; margin-bottom: 12px;');
489
+ issuerTextGoButton.addEventListener('click', () => {
490
+ loginToIssuer(issuerTextInput.value);
491
+ });
492
+ issuerTextContainer.appendChild(issuerTextLabel);
493
+ issuerTextInputContainer.appendChild(issuerTextInput);
494
+ issuerTextInputContainer.appendChild(issuerTextGoButton);
495
+ issuerTextContainer.appendChild(issuerTextInputContainer);
496
+ issuerPopupBox.appendChild(issuerTextContainer);
497
+ /**
498
+ * Button-based idp selection
499
+ */
500
+ const issuerButtonContainer = dom.createElement('div');
501
+ issuerButtonContainer.setAttribute('style', `
502
+ display: flex;
503
+ flex-direction: column;
504
+ padding-top: 10px;
505
+ `);
506
+ const issuerBottonLabel = dom.createElement('label');
507
+ issuerBottonLabel.innerText = 'Or pick an identity provider from the list below:';
508
+ issuerBottonLabel.setAttribute('style', 'color: #888');
509
+ issuerButtonContainer.appendChild(issuerBottonLabel);
510
+ (0, solid_logic_1.getSuggestedIssuers)().forEach((issuerInfo) => {
511
+ const issuerButton = dom.createElement('button');
512
+ issuerButton.innerText = issuerInfo.name;
513
+ issuerButton.setAttribute('style', 'height: 38px; margin-top: 10px');
514
+ issuerButton.addEventListener('click', () => {
515
+ loginToIssuer(issuerInfo.uri);
516
+ });
517
+ issuerButtonContainer.appendChild(issuerButton);
518
+ });
519
+ issuerPopupBox.appendChild(issuerButtonContainer);
520
+ }
521
+ /**
522
+ * Login status box
523
+ *
524
+ * A big sign-up/sign in box or a logout box depending on the state
525
+ *
526
+ * @param dom
527
+ * @param listener
528
+ *
529
+ * @returns
530
+ */
531
+ function loginStatusBox(dom, listener = null, options = {}) {
532
+ // 20190630
533
+ let me = (0, solid_logic_1.offlineTestID)();
534
+ // @@ TODO Remove the need to cast HTML element to any
535
+ const box = dom.createElement('div');
536
+ function setIt(newidURI) {
537
+ if (!newidURI) {
538
+ return;
539
+ }
540
+ // const uri = newidURI.uri || newidURI
541
+ // me = sym(uri)
542
+ me = solid_logic_1.authn.saveUser(newidURI);
543
+ box.refresh();
544
+ if (listener)
545
+ listener(me.uri);
546
+ }
547
+ function logoutButtonHandler(_event) {
548
+ const oldMe = me;
549
+ solid_logic_1.authSession.logout().then(function () {
550
+ const message = `Your WebID was ${oldMe}. It has been forgotten.`;
551
+ me = null;
552
+ try {
553
+ (0, log_1.alert)(message);
554
+ }
555
+ catch (e) {
556
+ window.alert(message);
557
+ }
558
+ box.refresh();
559
+ if (listener)
560
+ listener(null);
561
+ }, (err) => {
562
+ (0, log_1.alert)('Fail to log out:' + err);
563
+ });
564
+ }
565
+ function logoutButton(me, options) {
566
+ const signInButtonStyle = options.buttonStyle || style_1.style.signInAndUpButtonStyle;
567
+ let logoutLabel = 'WebID logout';
568
+ if (me) {
569
+ const nick = solid_logic_1.solidLogicSingleton.store.any(me, ns_1.default.foaf('nick')) ||
570
+ solid_logic_1.solidLogicSingleton.store.any(me, ns_1.default.foaf('name'));
571
+ if (nick) {
572
+ logoutLabel = 'Logout ' + nick.value;
573
+ }
574
+ }
575
+ const signOutButton = dom.createElement('input');
576
+ // signOutButton.className = 'WebIDCancelButton'
577
+ signOutButton.setAttribute('type', 'button');
578
+ signOutButton.setAttribute('value', logoutLabel);
579
+ signOutButton.setAttribute('style', `${signInButtonStyle}`);
580
+ signOutButton.addEventListener('click', logoutButtonHandler, false);
581
+ return signOutButton;
582
+ }
583
+ box.refresh = function () {
584
+ const sessionInfo = solid_logic_1.authSession.info;
585
+ if (sessionInfo && sessionInfo.webId && sessionInfo.isLoggedIn) {
586
+ me = solid_logic_1.solidLogicSingleton.store.sym(sessionInfo.webId);
587
+ }
588
+ else {
589
+ me = null;
590
+ }
591
+ if ((me && box.me !== me.uri) || (!me && box.me)) {
592
+ widgets.clearElement(box);
593
+ if (me) {
594
+ box.appendChild(logoutButton(me, options));
595
+ }
596
+ else {
597
+ box.appendChild(signInOrSignUpBox(dom, setIt, options));
598
+ }
599
+ }
600
+ box.me = me ? me.uri : null;
601
+ };
602
+ box.refresh();
603
+ function trackSession() {
604
+ me = solid_logic_1.authn.currentUser();
605
+ box.refresh();
606
+ }
607
+ trackSession();
608
+ solid_logic_1.authSession.events.on('login', trackSession);
609
+ solid_logic_1.authSession.events.on('logout', trackSession);
610
+ box.me = '99999'; // Force refresh
611
+ box.refresh();
612
+ return box;
613
+ }
614
+ solid_logic_1.authSession.events.on('logout', async () => {
615
+ const issuer = window.localStorage.getItem('loginIssuer');
616
+ if (issuer) {
617
+ try {
618
+ // clear authorization metadata from store
619
+ solid_logic_1.solidLogicSingleton.store.updater.flagAuthorizationMetadata();
620
+ const wellKnownUri = new URL(issuer);
621
+ wellKnownUri.pathname = '/.well-known/openid-configuration';
622
+ const wellKnownResult = await fetch(wellKnownUri.toString());
623
+ if (wellKnownResult.status === 200) {
624
+ const openidConfiguration = await wellKnownResult.json();
625
+ if (openidConfiguration && openidConfiguration.end_session_endpoint) {
626
+ await fetch(openidConfiguration.end_session_endpoint, { credentials: 'include' });
627
+ }
628
+ }
629
+ }
630
+ catch (err) {
631
+ // Do nothing
632
+ }
633
+ }
634
+ window.location.reload();
635
+ });
636
+ /**
637
+ * Workspace selection etc
638
+ * See https://github.com/solidos/userguide/issues/16
639
+ */
640
+ /**
641
+ * Returns a UI object which, if it selects a workspace,
642
+ * will callback(workspace, newBase).
643
+ * See https://github.com/solidos/userguide/issues/16 for more info on workspaces.
644
+ *
645
+ * If necessary, will get an account, preference file, etc. In sequence:
646
+ *
647
+ * - If not logged in, log in.
648
+ * - Load preference file
649
+ * - Prompt user for workspaces
650
+ * - Allows the user to just type in a URI by hand
651
+ *
652
+ * Calls back with the workspace and the base URI
653
+ *
654
+ * @param dom
655
+ * @param appDetails
656
+ * @param callbackWS
657
+ */
658
+ function selectWorkspace(dom, appDetails, callbackWS) {
659
+ const noun = appDetails.noun;
660
+ const appPathSegment = appDetails.appPathSegment;
661
+ const me = (0, solid_logic_1.offlineTestID)();
662
+ const box = dom.createElement('div');
663
+ const context = { me, dom, div: box };
664
+ function say(s, background) {
665
+ box.appendChild(widgets.errorMessageBlock(dom, s, background));
666
+ }
667
+ function figureOutBase(ws) {
668
+ const newBaseNode = solid_logic_1.solidLogicSingleton.store.any(ws, ns_1.default.space('uriPrefix'));
669
+ let newBaseString;
670
+ if (!newBaseNode) {
671
+ newBaseString = ws.uri.split('#')[0];
672
+ }
673
+ else {
674
+ newBaseString = newBaseNode.value;
675
+ }
676
+ if (newBaseString.slice(-1) !== '/') {
677
+ debug.log(`${appPathSegment}: No / at end of uriPrefix ${newBaseString}`); // @@ paramater?
678
+ newBaseString = `${newBaseString}/`;
679
+ }
680
+ const now = new Date();
681
+ newBaseString += `${appPathSegment}/id${now.getTime()}/`; // unique id
682
+ return newBaseString;
683
+ }
684
+ function displayOptions(context) {
685
+ // console.log('displayOptions!', context)
686
+ async function makeNewWorkspace(_event) {
687
+ const row = table.appendChild(dom.createElement('tr'));
688
+ const cell = row.appendChild(dom.createElement('td'));
689
+ cell.setAttribute('colspan', '3');
690
+ cell.style.padding = '0.5em';
691
+ const newBase = encodeURI(await widgets.askName(dom, solid_logic_1.solidLogicSingleton.store, cell, ns_1.default.solid('URL'), ns_1.default.space('Workspace'), 'Workspace'));
692
+ const newWs = widgets.newThing(context.preferencesFile);
693
+ const newData = [
694
+ (0, rdflib_1.st)(context.me, ns_1.default.space('workspace'), newWs, context.preferencesFile),
695
+ (0, rdflib_1.st)(newWs, ns_1.default.space('uriPrefix'), newBase, context.preferencesFile)
696
+ ];
697
+ if (!solid_logic_1.solidLogicSingleton.store.updater) {
698
+ throw new Error('store has no updater');
699
+ }
700
+ await solid_logic_1.solidLogicSingleton.store.updater.update([], newData);
701
+ // @@ now refresh list of workspaces
702
+ }
703
+ // const status = ''
704
+ const id = context.me;
705
+ const preferencesFile = context.preferencesFile;
706
+ let newBase = null;
707
+ // A workspace specifically defined in the private preference file:
708
+ let w = solid_logic_1.solidLogicSingleton.store.each(id, ns_1.default.space('workspace'), undefined, preferencesFile); // Only trust preference file here
709
+ // A workspace in a storage in the public profile:
710
+ const storages = solid_logic_1.solidLogicSingleton.store.each(id, ns_1.default.space('storage')); // @@ No provenance requirement at the moment
711
+ if (w.length === 0 && storages) {
712
+ say(`You don't seem to have any workspaces. You have ${storages.length} storage spaces.`, 'white');
713
+ storages
714
+ .map(function (s) {
715
+ w = w.concat(solid_logic_1.solidLogicSingleton.store.each(s, ns_1.default.ldp('contains')));
716
+ return w;
717
+ })
718
+ .filter((file) => {
719
+ return file.id ? ['public', 'private'].includes(file.id().toLowerCase()) : '';
720
+ });
721
+ }
722
+ if (w.length === 1) {
723
+ say(`Workspace used: ${w[0].uri}`, 'white'); // @@ allow user to see URI
724
+ newBase = figureOutBase(w[0]);
725
+ // callbackWS(w[0], newBase)
726
+ // } else if (w.length === 0) {
727
+ }
728
+ // Prompt for ws selection or creation
729
+ // say( w.length + " workspaces for " + id + "Choose one.");
730
+ const table = dom.createElement('table');
731
+ table.setAttribute('style', 'border-collapse:separate; border-spacing: 0.5em;');
732
+ // const popup = window.open(undefined, '_blank', { height: 300, width:400 }, false)
733
+ box.appendChild(table);
734
+ // Add a field for directly adding the URI yourself
735
+ // const hr = box.appendChild(dom.createElement('hr')) // @@
736
+ box.appendChild(dom.createElement('hr')); // @@
737
+ const p = box.appendChild(dom.createElement('p'));
738
+ p.setAttribute('style', style_1.style.commentStyle);
739
+ p.textContent = `Where would you like to store the data for the ${noun}?
740
+ Give the URL of the folder where you would like the data stored.
741
+ It can be anywhere in solid world - this URI is just an idea.`;
742
+ // @@ TODO Remove the need to cast baseField to any
743
+ const baseField = box.appendChild(dom.createElement('input'));
744
+ baseField.setAttribute('type', 'text');
745
+ baseField.setAttribute('style', style_1.style.textInputStyle);
746
+ baseField.size = 80; // really a string
747
+ baseField.label = 'base URL';
748
+ baseField.autocomplete = 'on';
749
+ if (newBase) {
750
+ // set to default
751
+ baseField.value = newBase;
752
+ }
753
+ context.baseField = baseField;
754
+ box.appendChild(dom.createElement('br')); // @@
755
+ const button = box.appendChild(dom.createElement('button'));
756
+ button.setAttribute('style', style_1.style.buttonStyle);
757
+ button.textContent = `Start new ${noun} at this URI`;
758
+ button.addEventListener('click', function (_event) {
759
+ let newBase = baseField.value.replace(' ', '%20'); // do not re-encode in general, as % encodings may exist
760
+ if (newBase.slice(-1) !== '/') {
761
+ newBase += '/';
762
+ }
763
+ callbackWS(null, newBase);
764
+ });
765
+ // Now go set up the table of spaces
766
+ // const row = 0
767
+ w = w.filter(function (x) {
768
+ return !solid_logic_1.solidLogicSingleton.store.holds(x, ns_1.default.rdf('type'), // Ignore master workspaces
769
+ ns_1.default.space('MasterWorkspace'));
770
+ });
771
+ let col1, col2, col3, tr, ws, localStyle, comment;
772
+ const cellStyle = 'height: 3em; margin: 1em; padding: 1em white; border-radius: 0.3em;';
773
+ const deselectedStyle = `${cellStyle}border: 0px;`;
774
+ // const selectedStyle = cellStyle + 'border: 1px solid black;'
775
+ for (let i = 0; i < w.length; i++) {
776
+ ws = w[i];
777
+ tr = dom.createElement('tr');
778
+ if (i === 0) {
779
+ col1 = dom.createElement('td');
780
+ col1.setAttribute('rowspan', `${w.length}`);
781
+ col1.textContent = 'Choose a workspace for this:';
782
+ col1.setAttribute('style', 'vertical-align:middle;');
783
+ tr.appendChild(col1);
784
+ }
785
+ col2 = dom.createElement('td');
786
+ localStyle = solid_logic_1.solidLogicSingleton.store.anyValue(ws, ns_1.default.ui('style'));
787
+ if (!localStyle) {
788
+ // Otherwise make up arbitrary colour
789
+ const hash = function (x) {
790
+ return x.split('').reduce(function (a, b) {
791
+ a = (a << 5) - a + b.charCodeAt(0);
792
+ return a & a;
793
+ }, 0);
794
+ };
795
+ const bgcolor = `#${((hash(ws.uri) & 0xffffff) | 0xc0c0c0).toString(16)}`; // c0c0c0 forces pale
796
+ localStyle = `color: black ; background-color: ${bgcolor};`;
797
+ }
798
+ col2.setAttribute('style', deselectedStyle + localStyle);
799
+ tr.target = ws.uri;
800
+ let label = solid_logic_1.solidLogicSingleton.store.any(ws, ns_1.default.rdfs('label'));
801
+ if (!label) {
802
+ label = ws.uri.split('/').slice(-1)[0] || ws.uri.split('/').slice(-2)[0];
803
+ }
804
+ col2.textContent = label || '???';
805
+ tr.appendChild(col2);
806
+ if (i === 0) {
807
+ col3 = dom.createElement('td');
808
+ col3.setAttribute('rowspan', `${w.length}1`);
809
+ // col3.textContent = '@@@@@ remove';
810
+ col3.setAttribute('style', 'width:50%;');
811
+ tr.appendChild(col3);
812
+ }
813
+ table.appendChild(tr);
814
+ comment = solid_logic_1.solidLogicSingleton.store.any(ws, ns_1.default.rdfs('comment'));
815
+ comment = comment ? comment.value : 'Use this workspace';
816
+ col2.addEventListener('click', function (_event) {
817
+ col3.textContent = comment ? comment.value : '';
818
+ col3.setAttribute('style', deselectedStyle + localStyle);
819
+ const button = dom.createElement('button');
820
+ button.textContent = 'Continue';
821
+ // button.setAttribute('style', style);
822
+ const newBase = figureOutBase(ws);
823
+ baseField.value = newBase; // show user proposed URI
824
+ button.addEventListener('click', function (_event) {
825
+ button.disabled = true;
826
+ callbackWS(ws, newBase);
827
+ button.textContent = '---->';
828
+ }, true); // capture vs bubble
829
+ col3.appendChild(button);
830
+ }, true); // capture vs bubble
831
+ }
832
+ // last line with "Make new workspace"
833
+ const trLast = dom.createElement('tr');
834
+ col2 = dom.createElement('td');
835
+ col2.setAttribute('style', cellStyle);
836
+ col2.textContent = '+ Make a new workspace';
837
+ col2.addEventListener('click', makeNewWorkspace);
838
+ trLast.appendChild(col2);
839
+ table.appendChild(trLast);
840
+ } // displayOptions
841
+ // console.log('kicking off async operation')
842
+ ensureLoadedPreferences(context) // kick off async operation
843
+ .then(displayOptions)
844
+ .catch((err) => {
845
+ // console.log("err from async op")
846
+ box.appendChild(widgets.errorMessageBlock(context.dom, err));
847
+ });
848
+ return box; // return the box element, while login proceeds
849
+ } // selectWorkspace
850
+ /**
851
+ * Creates a new instance of an app.
852
+ *
853
+ * An instance of an app could be e.g. an issue tracker for a given project,
854
+ * or a chess game, or calendar, or a health/fitness record for a person.
855
+ *
856
+ * Note that this use of the term 'app' refers more to entries in the user's
857
+ * type index than to actual software applications that use the personal data
858
+ * to which these entries point.
859
+ *
860
+ * @param dom
861
+ * @param appDetails
862
+ * @param callback
863
+ *
864
+ * @returns A div with a button in it for making a new app instance
865
+ */
866
+ function newAppInstance(dom, appDetails, callback) {
867
+ const gotWS = function (ws, base) {
868
+ // log.debug("newAppInstance: Selected workspace = " + (ws? ws.uri : 'none'))
869
+ callback(ws, base);
870
+ };
871
+ const div = dom.createElement('div');
872
+ const b = dom.createElement('button');
873
+ b.setAttribute('type', 'button');
874
+ div.appendChild(b);
875
+ b.innerHTML = `Make new ${appDetails.noun}`;
876
+ b.addEventListener('click', (_event) => {
877
+ div.appendChild(selectWorkspace(dom, appDetails, gotWS));
878
+ }, false);
879
+ div.appendChild(b);
880
+ return div;
881
+ }
882
+ /**
883
+ * Retrieves whether the currently logged in user is a power user
884
+ * and/or a developer
885
+ */
886
+ async function getUserRoles() {
887
+ try {
888
+ const { me, preferencesFile, preferencesFileError } = await ensureLoadedPreferences({});
889
+ if (!preferencesFile || preferencesFileError) {
890
+ throw new Error(preferencesFileError);
891
+ }
892
+ return solid_logic_1.solidLogicSingleton.store.each(me, ns_1.default.rdf('type'), null, preferencesFile.doc());
893
+ }
894
+ catch (error) {
895
+ debug.warn('Unable to fetch your preferences - this was the error: ', error);
896
+ }
897
+ return [];
898
+ }
899
+ /**
900
+ * Filters which panes should be available, based on the result of [[getUserRoles]]
901
+ */
902
+ async function filterAvailablePanes(panes) {
903
+ const userRoles = await getUserRoles();
904
+ return panes.filter((pane) => isMatchingAudience(pane, userRoles));
905
+ }
906
+ function isMatchingAudience(pane, userRoles) {
907
+ const audience = pane.audience || [];
908
+ return audience.reduce((isMatch, audienceRole) => isMatch && !!userRoles.find((role) => role.equals(audienceRole)), true);
909
+ }
910
+ //# sourceMappingURL=login.js.map