solid-ui 2.4.14-alpha → 2.4.14-bbf45639-aade069c

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 (257) hide show
  1. package/LICENSE.md +0 -0
  2. package/README.md +0 -0
  3. package/lib/acl/access-controller.d.ts +0 -0
  4. package/lib/acl/access-controller.d.ts.map +0 -0
  5. package/lib/acl/access-controller.js +441 -334
  6. package/lib/acl/access-controller.js.map +1 -1
  7. package/lib/acl/access-groups.d.ts +1 -2
  8. package/lib/acl/access-groups.d.ts.map +1 -1
  9. package/lib/acl/access-groups.js +495 -347
  10. package/lib/acl/access-groups.js.map +1 -1
  11. package/lib/acl/acl-control.d.ts +0 -0
  12. package/lib/acl/acl-control.d.ts.map +0 -0
  13. package/lib/acl/acl-control.js +198 -168
  14. package/lib/acl/acl-control.js.map +1 -1
  15. package/lib/acl/acl.d.ts +1 -2
  16. package/lib/acl/acl.d.ts.map +1 -1
  17. package/lib/acl/acl.js +463 -444
  18. package/lib/acl/acl.js.map +1 -1
  19. package/lib/acl/add-agent-buttons.d.ts +0 -0
  20. package/lib/acl/add-agent-buttons.d.ts.map +0 -0
  21. package/lib/acl/add-agent-buttons.js +515 -318
  22. package/lib/acl/add-agent-buttons.js.map +1 -1
  23. package/lib/acl/index.d.ts +0 -0
  24. package/lib/acl/index.d.ts.map +0 -0
  25. package/lib/acl/index.js +35 -27
  26. package/lib/acl/index.js.map +1 -1
  27. package/lib/acl/styles.d.ts +0 -0
  28. package/lib/acl/styles.d.ts.map +0 -0
  29. package/lib/acl/styles.js +90 -84
  30. package/lib/acl/styles.js.map +1 -1
  31. package/lib/acl/types.d.ts +0 -0
  32. package/lib/acl/types.d.ts.map +0 -0
  33. package/lib/acl/types.js +4 -5
  34. package/lib/acl/types.js.map +1 -1
  35. package/lib/authn/authSession.d.ts +0 -0
  36. package/lib/authn/authSession.d.ts.map +0 -0
  37. package/lib/authn/authSession.js +21 -14
  38. package/lib/authn/authSession.js.map +1 -1
  39. package/lib/authn/authn.d.ts +0 -0
  40. package/lib/authn/authn.d.ts.map +0 -0
  41. package/lib/authn/authn.js +1935 -1391
  42. package/lib/authn/authn.js.map +1 -1
  43. package/lib/authn/config-default.js +0 -0
  44. package/lib/authn/config-default.js.map +0 -0
  45. package/lib/authn/index.d.ts +0 -0
  46. package/lib/authn/index.d.ts.map +0 -0
  47. package/lib/authn/index.js +37 -26
  48. package/lib/authn/index.js.map +1 -1
  49. package/lib/authn/signup.js +0 -0
  50. package/lib/authn/signup.js.map +0 -0
  51. package/lib/authn/types.d.ts +0 -0
  52. package/lib/authn/types.d.ts.map +0 -0
  53. package/lib/authn/types.js +4 -1
  54. package/lib/authn/types.js.map +1 -1
  55. package/lib/chat/bookmarks.js +0 -0
  56. package/lib/chat/bookmarks.js.map +0 -0
  57. package/lib/chat/dateFolder.js +0 -0
  58. package/lib/chat/dateFolder.js.map +0 -0
  59. package/lib/chat/infinite.js +0 -0
  60. package/lib/chat/infinite.js.map +0 -0
  61. package/lib/chat/message.js +0 -0
  62. package/lib/chat/message.js.map +0 -0
  63. package/lib/chat/messageTools.js +0 -0
  64. package/lib/chat/messageTools.js.map +0 -0
  65. package/lib/chat/thread.js +0 -0
  66. package/lib/chat/thread.js.map +0 -0
  67. package/lib/create/create.d.ts +0 -0
  68. package/lib/create/create.d.ts.map +0 -0
  69. package/lib/create/create.js +214 -209
  70. package/lib/create/create.js.map +1 -1
  71. package/lib/create/index.d.ts +0 -0
  72. package/lib/create/index.d.ts.map +0 -0
  73. package/lib/create/index.js +10 -4
  74. package/lib/create/index.js.map +1 -1
  75. package/lib/create/types.d.ts +0 -0
  76. package/lib/create/types.d.ts.map +0 -0
  77. package/lib/create/types.js +4 -1
  78. package/lib/create/types.js.map +1 -1
  79. package/lib/debug.d.ts +0 -0
  80. package/lib/debug.d.ts.map +0 -0
  81. package/lib/debug.js +28 -30
  82. package/lib/debug.js.map +1 -1
  83. package/lib/folders.js +0 -0
  84. package/lib/folders.js.map +0 -0
  85. package/lib/footer/index.d.ts +0 -0
  86. package/lib/footer/index.d.ts.map +0 -0
  87. package/lib/footer/index.js +126 -109
  88. package/lib/footer/index.js.map +1 -1
  89. package/lib/footer/styleMap.d.ts +0 -0
  90. package/lib/footer/styleMap.d.ts.map +0 -0
  91. package/lib/footer/styleMap.js +11 -7
  92. package/lib/footer/styleMap.js.map +1 -1
  93. package/lib/header/empty-profile.d.ts +0 -0
  94. package/lib/header/empty-profile.d.ts.map +0 -0
  95. package/lib/header/empty-profile.js +6 -2
  96. package/lib/header/empty-profile.js.map +1 -1
  97. package/lib/header/index.d.ts +0 -0
  98. package/lib/header/index.d.ts.map +0 -0
  99. package/lib/header/index.js +361 -285
  100. package/lib/header/index.js.map +1 -1
  101. package/lib/header/styleMap.d.ts +0 -0
  102. package/lib/header/styleMap.d.ts.map +0 -0
  103. package/lib/header/styleMap.js +132 -116
  104. package/lib/header/styleMap.js.map +1 -1
  105. package/lib/iconBase.d.ts +0 -0
  106. package/lib/iconBase.d.ts.map +0 -0
  107. package/lib/iconBase.js +30 -23
  108. package/lib/iconBase.js.map +1 -1
  109. package/lib/icons/solid_logo.d.ts +0 -0
  110. package/lib/icons/solid_logo.d.ts.map +0 -0
  111. package/lib/icons/solid_logo.js +0 -0
  112. package/lib/icons/solid_logo.js.map +1 -1
  113. package/lib/index.d.ts +1 -1
  114. package/lib/index.d.ts.map +1 -1
  115. package/lib/index.js +207 -103
  116. package/lib/index.js.map +1 -1
  117. package/lib/jss/index.d.ts +0 -0
  118. package/lib/jss/index.d.ts.map +0 -0
  119. package/lib/jss/index.js +30 -21
  120. package/lib/jss/index.js.map +1 -1
  121. package/lib/log.d.ts +0 -0
  122. package/lib/log.d.ts.map +0 -0
  123. package/lib/log.js +131 -83
  124. package/lib/log.js.map +1 -1
  125. package/lib/logic.d.ts +2 -2
  126. package/lib/logic.d.ts.map +1 -1
  127. package/lib/logic.js +73 -82
  128. package/lib/logic.js.map +1 -1
  129. package/lib/matrix/index.d.ts +0 -0
  130. package/lib/matrix/index.d.ts.map +0 -0
  131. package/lib/matrix/index.js +10 -4
  132. package/lib/matrix/index.js.map +1 -1
  133. package/lib/matrix/matrix.d.ts +0 -0
  134. package/lib/matrix/matrix.d.ts.map +0 -0
  135. package/lib/matrix/matrix.js +237 -210
  136. package/lib/matrix/matrix.js.map +1 -1
  137. package/lib/matrix/types.d.ts +0 -0
  138. package/lib/matrix/types.d.ts.map +0 -0
  139. package/lib/matrix/types.js +4 -1
  140. package/lib/matrix/types.js.map +1 -1
  141. package/lib/media/index.d.ts +0 -0
  142. package/lib/media/index.d.ts.map +0 -0
  143. package/lib/media/index.js +11 -5
  144. package/lib/media/index.js.map +1 -1
  145. package/lib/media/media-capture.d.ts +0 -0
  146. package/lib/media/media-capture.d.ts.map +0 -0
  147. package/lib/media/media-capture.js +181 -187
  148. package/lib/media/media-capture.js.map +1 -1
  149. package/lib/messageArea.js +0 -0
  150. package/lib/messageArea.js.map +0 -0
  151. package/lib/noun_Camera_1618446_000000.js +0 -0
  152. package/lib/noun_Camera_1618446_000000.js.map +0 -0
  153. package/lib/ns.js +0 -0
  154. package/lib/ns.js.map +0 -0
  155. package/lib/pad.d.ts +0 -0
  156. package/lib/pad.d.ts.map +0 -0
  157. package/lib/pad.js +954 -794
  158. package/lib/pad.js.map +1 -1
  159. package/lib/participation.d.ts +0 -0
  160. package/lib/participation.d.ts.map +0 -0
  161. package/lib/participation.js +199 -170
  162. package/lib/participation.js.map +1 -1
  163. package/lib/preferences.js +0 -0
  164. package/lib/preferences.js.map +0 -0
  165. package/lib/stories/decorators.js +0 -0
  166. package/lib/stories/decorators.js.map +0 -0
  167. package/lib/style.js +0 -0
  168. package/lib/style.js.map +0 -0
  169. package/lib/table.js +0 -0
  170. package/lib/table.js.map +0 -0
  171. package/lib/tabs.d.ts +0 -0
  172. package/lib/tabs.d.ts.map +0 -0
  173. package/lib/tabs.js +342 -235
  174. package/lib/tabs.js.map +1 -1
  175. package/lib/typings.d.js +0 -0
  176. package/lib/typings.d.js.map +0 -0
  177. package/lib/utils/headerFooterHelpers.d.ts +0 -0
  178. package/lib/utils/headerFooterHelpers.d.ts.map +0 -0
  179. package/lib/utils/headerFooterHelpers.js +155 -130
  180. package/lib/utils/headerFooterHelpers.js.map +1 -1
  181. package/lib/utils/index.js +0 -0
  182. package/lib/utils/index.js.map +0 -0
  183. package/lib/utils/label.d.ts +0 -0
  184. package/lib/utils/label.d.ts.map +0 -0
  185. package/lib/utils/label.js +113 -121
  186. package/lib/utils/label.js.map +1 -1
  187. package/lib/versionInfo.d.ts +0 -0
  188. package/lib/versionInfo.d.ts.map +0 -0
  189. package/lib/versionInfo.js +28 -23
  190. package/lib/versionInfo.js.map +1 -1
  191. package/lib/webpack-bundle.js +264 -175
  192. package/lib/webpack-bundle.js.map +1 -1
  193. package/lib/widgets/buttons/iconLinks.d.ts +0 -0
  194. package/lib/widgets/buttons/iconLinks.d.ts.map +0 -0
  195. package/lib/widgets/buttons/iconLinks.js +30 -19
  196. package/lib/widgets/buttons/iconLinks.js.map +1 -1
  197. package/lib/widgets/buttons.d.ts +0 -0
  198. package/lib/widgets/buttons.d.ts.map +0 -0
  199. package/lib/widgets/buttons.js +1113 -935
  200. package/lib/widgets/buttons.js.map +1 -1
  201. package/lib/widgets/dragAndDrop.js +0 -0
  202. package/lib/widgets/dragAndDrop.js.map +0 -0
  203. package/lib/widgets/error.d.ts +0 -0
  204. package/lib/widgets/error.d.ts.map +0 -0
  205. package/lib/widgets/error.js +24 -18
  206. package/lib/widgets/error.js.map +1 -1
  207. package/lib/widgets/forms/autocomplete/autocompleteBar.d.ts +0 -0
  208. package/lib/widgets/forms/autocomplete/autocompleteBar.d.ts.map +0 -0
  209. package/lib/widgets/forms/autocomplete/autocompleteBar.js +325 -234
  210. package/lib/widgets/forms/autocomplete/autocompleteBar.js.map +1 -1
  211. package/lib/widgets/forms/autocomplete/autocompleteField.d.ts +0 -0
  212. package/lib/widgets/forms/autocomplete/autocompleteField.d.ts.map +0 -0
  213. package/lib/widgets/forms/autocomplete/autocompleteField.js +280 -246
  214. package/lib/widgets/forms/autocomplete/autocompleteField.js.map +1 -1
  215. package/lib/widgets/forms/autocomplete/autocompletePicker.d.ts +0 -0
  216. package/lib/widgets/forms/autocomplete/autocompletePicker.d.ts.map +0 -0
  217. package/lib/widgets/forms/autocomplete/autocompletePicker.js +497 -317
  218. package/lib/widgets/forms/autocomplete/autocompletePicker.js.map +1 -1
  219. package/lib/widgets/forms/autocomplete/language.d.ts +0 -0
  220. package/lib/widgets/forms/autocomplete/language.d.ts.map +0 -0
  221. package/lib/widgets/forms/autocomplete/language.js +214 -159
  222. package/lib/widgets/forms/autocomplete/language.js.map +1 -1
  223. package/lib/widgets/forms/autocomplete/publicData.d.ts +0 -0
  224. package/lib/widgets/forms/autocomplete/publicData.d.ts.map +0 -0
  225. package/lib/widgets/forms/autocomplete/publicData.js +725 -485
  226. package/lib/widgets/forms/autocomplete/publicData.js.map +1 -1
  227. package/lib/widgets/forms/basic.d.ts +0 -0
  228. package/lib/widgets/forms/basic.d.ts.map +0 -0
  229. package/lib/widgets/forms/basic.js +239 -208
  230. package/lib/widgets/forms/basic.js.map +1 -1
  231. package/lib/widgets/forms/comment.d.ts +0 -0
  232. package/lib/widgets/forms/comment.d.ts.map +0 -0
  233. package/lib/widgets/forms/comment.js +48 -48
  234. package/lib/widgets/forms/comment.js.map +1 -1
  235. package/lib/widgets/forms/fieldFunction.d.ts +0 -0
  236. package/lib/widgets/forms/fieldFunction.d.ts.map +0 -0
  237. package/lib/widgets/forms/fieldFunction.js +50 -31
  238. package/lib/widgets/forms/fieldFunction.js.map +1 -1
  239. package/lib/widgets/forms/fieldParams.d.ts +0 -0
  240. package/lib/widgets/forms/fieldParams.d.ts.map +0 -0
  241. package/lib/widgets/forms/fieldParams.js +81 -102
  242. package/lib/widgets/forms/fieldParams.js.map +1 -1
  243. package/lib/widgets/forms/formStyle.d.ts +0 -0
  244. package/lib/widgets/forms/formStyle.d.ts.map +0 -0
  245. package/lib/widgets/forms/formStyle.js +50 -52
  246. package/lib/widgets/forms/formStyle.js.map +1 -1
  247. package/lib/widgets/forms.js +0 -0
  248. package/lib/widgets/forms.js.map +0 -0
  249. package/lib/widgets/index.js +0 -0
  250. package/lib/widgets/index.js.map +0 -0
  251. package/lib/widgets/peoplePicker.js +0 -0
  252. package/lib/widgets/peoplePicker.js.map +0 -0
  253. package/lib/widgets/widgetHelpers.d.ts +0 -0
  254. package/lib/widgets/widgetHelpers.d.ts.map +0 -0
  255. package/lib/widgets/widgetHelpers.js +30 -18
  256. package/lib/widgets/widgetHelpers.js.map +1 -1
  257. package/package.json +7 -7
package/lib/acl/acl.js CHANGED
@@ -1,457 +1,455 @@
1
1
  "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ var _typeof = require("@babel/runtime/helpers/typeof");
6
+
7
+ Object.defineProperty(exports, "__esModule", {
8
+ value: true
9
+ });
10
+ exports.ACLToString = ACLToString;
11
+ exports.ACLbyCombination = ACLbyCombination;
12
+ exports.ACLunion = ACLunion;
13
+ exports.adoptACLDefault = adoptACLDefault;
14
+ exports.comboToString = comboToString;
15
+ exports.fixIndividualACL = fixIndividualACL;
16
+ exports.fixIndividualCardACL = fixIndividualCardACL;
17
+ exports.getACL = getACL;
18
+ exports.getACLorDefault = getACLorDefault;
19
+ exports.getProspectiveHolder = getProspectiveHolder;
20
+ exports.loadUnionACL = loadUnionACL;
21
+ exports.makeACLGraph = makeACLGraph;
22
+ exports.makeACLGraphbyCombo = makeACLGraphbyCombo;
23
+ exports.makeACLString = makeACLString;
24
+ exports.putACLObject = putACLObject;
25
+ exports.putACLbyCombo = putACLbyCombo;
26
+ exports.readACL = readACL;
27
+ exports.sameACL = sameACL;
28
+ exports.setACL = setACL;
29
+
30
+ var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
31
+
32
+ var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
33
+
34
+ var ns = _interopRequireWildcard(require("../ns"));
35
+
36
+ var _logic = require("../logic");
37
+
38
+ var utils = _interopRequireWildcard(require("../utils"));
39
+
40
+ var debug = _interopRequireWildcard(require("../debug"));
41
+
42
+ var _rdflib = require("rdflib");
43
+
44
+ var _solidLogic = require("solid-logic");
45
+
46
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
47
+
48
+ 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; }
49
+
2
50
  /**
3
51
  * Non-UI functions for access control.
4
52
  * See https://github.com/solid/web-access-control-spec
5
53
  * for the spec that defines how ACL documents work.
6
54
  * @packageDocumentation
7
55
  */
8
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
9
- if (k2 === undefined) k2 = k;
10
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
11
- }) : (function(o, m, k, k2) {
12
- if (k2 === undefined) k2 = k;
13
- o[k2] = m[k];
14
- }));
15
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
16
- Object.defineProperty(o, "default", { enumerable: true, value: v });
17
- }) : function(o, v) {
18
- o["default"] = v;
19
- });
20
- var __importStar = (this && this.__importStar) || function (mod) {
21
- if (mod && mod.__esModule) return mod;
22
- var result = {};
23
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
24
- __setModuleDefault(result, mod);
25
- return result;
26
- };
27
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
28
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
29
- return new (P || (P = Promise))(function (resolve, reject) {
30
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
31
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
32
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
33
- step((generator = generator.apply(thisArg, _arguments || [])).next());
34
- });
35
- };
36
- var __generator = (this && this.__generator) || function (thisArg, body) {
37
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
38
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
39
- function verb(n) { return function (v) { return step([n, v]); }; }
40
- function step(op) {
41
- if (f) throw new TypeError("Generator is already executing.");
42
- while (_) try {
43
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
44
- if (y = 0, t) op = [op[0] & 2, t.value];
45
- switch (op[0]) {
46
- case 0: case 1: t = op; break;
47
- case 4: _.label++; return { value: op[1], done: false };
48
- case 5: _.label++; y = op[1]; op = [0]; continue;
49
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
50
- default:
51
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
52
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
53
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
54
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
55
- if (t[2]) _.ops.pop();
56
- _.trys.pop(); continue;
57
- }
58
- op = body.call(thisArg, _);
59
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
60
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
61
- }
62
- };
63
- Object.defineProperty(exports, "__esModule", { value: true });
64
- exports.getProspectiveHolder = exports.getACL = exports.getACLorDefault = exports.setACL = exports.fixIndividualACL = exports.fixIndividualCardACL = exports.putACLbyCombo = exports.putACLObject = exports.makeACLString = exports.comboToString = exports.ACLToString = exports.makeACLGraphbyCombo = exports.makeACLGraph = exports.ACLbyCombination = exports.loadUnionACL = exports.ACLunion = exports.sameACL = exports.readACL = exports.adoptACLDefault = void 0;
65
- var ns = __importStar(require("../ns"));
66
- var logic_1 = require("../logic");
67
- var utils = __importStar(require("../utils"));
68
- var debug = __importStar(require("../debug"));
69
- var rdflib_1 = require("rdflib");
70
- var solid_logic_1 = require("solid-logic");
71
- var kb = logic_1.solidLogicSingleton.store;
56
+ var kb = _logic.solidLogicSingleton.store;
72
57
  /**
73
58
  * Take the "default" ACL and convert it into the equivlent ACL
74
59
  * which the resource would have had. Return it as a new separate store.
75
60
  * The "defaultForNew" predicate is also accepted, as a deprecated
76
61
  * synonym for "default".
77
62
  */
63
+
78
64
  function adoptACLDefault(doc, aclDoc, defaultResource, defaultACLDoc) {
79
- var ACL = ns.acl;
80
- var isContainer = doc.uri.slice(-1) === '/'; // Give default for all directories
81
- var defaults = kb
82
- .each(undefined, ACL('default'), defaultResource, defaultACLDoc)
83
- .concat(kb.each(undefined, ACL('defaultForNew'), defaultResource, defaultACLDoc));
84
- var proposed = defaults.reduce(function (accumulatedStatements, da) { return accumulatedStatements
85
- .concat(kb.statementsMatching(da, ns.rdf('type'), ACL('Authorization'), defaultACLDoc))
86
- .concat(kb.statementsMatching(da, ACL('agent'), undefined, defaultACLDoc))
87
- .concat(kb.statementsMatching(da, ACL('agentClass'), undefined, defaultACLDoc))
88
- .concat(kb.statementsMatching(da, ACL('agentGroup'), undefined, defaultACLDoc))
89
- .concat(kb.statementsMatching(da, ACL('origin'), undefined, defaultACLDoc))
90
- .concat(kb.statementsMatching(da, ACL('originClass'), undefined, defaultACLDoc))
91
- .concat(kb.statementsMatching(da, ACL('mode'), undefined, defaultACLDoc))
92
- .concat((0, rdflib_1.st)(da, ACL('accessTo'), doc, defaultACLDoc))
93
- .concat(isContainer ? (0, rdflib_1.st)(da, ACL('default'), doc, defaultACLDoc) : []); }, []);
94
- var kb2 = (0, rdflib_1.graph)(); // Potential - derived is kept apart
95
- proposed.forEach(function (st) { return kb2.add(move(st.subject), move(st.predicate), move(st.object), (0, rdflib_1.sym)(aclDoc.uri)); });
96
- return kb2;
97
- function move(symbol) {
98
- var y = defaultACLDoc.uri.length; // The default ACL file
99
- return (0, rdflib_1.sym)(symbol.uri.slice(0, y) === defaultACLDoc.uri
100
- ? aclDoc.uri + symbol.uri.slice(y)
101
- : symbol.uri);
102
- }
65
+ var ACL = ns.acl;
66
+ var isContainer = doc.uri.slice(-1) === '/'; // Give default for all directories
67
+
68
+ var defaults = kb.each(undefined, ACL('default'), defaultResource, defaultACLDoc).concat(kb.each(undefined, ACL('defaultForNew'), defaultResource, defaultACLDoc));
69
+ var proposed = defaults.reduce(function (accumulatedStatements, da) {
70
+ return accumulatedStatements.concat(kb.statementsMatching(da, ns.rdf('type'), ACL('Authorization'), defaultACLDoc)).concat(kb.statementsMatching(da, ACL('agent'), undefined, defaultACLDoc)).concat(kb.statementsMatching(da, ACL('agentClass'), undefined, defaultACLDoc)).concat(kb.statementsMatching(da, ACL('agentGroup'), undefined, defaultACLDoc)).concat(kb.statementsMatching(da, ACL('origin'), undefined, defaultACLDoc)).concat(kb.statementsMatching(da, ACL('originClass'), undefined, defaultACLDoc)).concat(kb.statementsMatching(da, ACL('mode'), undefined, defaultACLDoc)).concat((0, _rdflib.st)(da, ACL('accessTo'), doc, defaultACLDoc)).concat(isContainer ? (0, _rdflib.st)(da, ACL('default'), doc, defaultACLDoc) : []);
71
+ }, []);
72
+ var kb2 = (0, _rdflib.graph)(); // Potential - derived is kept apart
73
+
74
+ proposed.forEach(function (st) {
75
+ return kb2.add(move(st.subject), move(st.predicate), move(st.object), (0, _rdflib.sym)(aclDoc.uri));
76
+ });
77
+ return kb2;
78
+
79
+ function move(symbol) {
80
+ var y = defaultACLDoc.uri.length; // The default ACL file
81
+
82
+ return (0, _rdflib.sym)(symbol.uri.slice(0, y) === defaultACLDoc.uri ? aclDoc.uri + symbol.uri.slice(y) : symbol.uri);
83
+ }
103
84
  }
104
- exports.adoptACLDefault = adoptACLDefault;
105
85
  /**
106
86
  * Read and canonicalize the ACL for x in aclDoc
107
87
  *
108
88
  * Accumulate the access rights which each agent or class has
109
89
  */
110
- function readACL(doc, aclDoc, kb2, getDefaults) {
111
- if (kb2 === void 0) { kb2 = kb; }
112
- if (getDefaults === void 0) { getDefaults = false; }
113
- var auths = getDefaults
114
- ? getDefaultsFallback(kb2, ns)
115
- : kb2.each(undefined, ns.acl('accessTo'), doc);
116
- var ACL = ns.acl;
117
- var ac = {
118
- agent: {},
119
- agentClass: {},
120
- agentGroup: {},
121
- origin: {},
122
- originClass: {}
123
- };
124
- Object.keys(ac).forEach(function (pred) {
125
- auths.forEach(function (a) {
126
- kb2.each(a, ACL('mode')).forEach(function (mode) {
127
- kb2.each(a, ACL(pred)).forEach(function (agent) {
128
- ac[pred][agent.uri] = ac[pred][agent.uri] || {};
129
- ac[pred][agent.uri][mode.uri] = a; // could be "true" but leave pointer just in case
130
- });
131
- });
90
+
91
+
92
+ function readACL(doc, aclDoc) {
93
+ var kb2 = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : kb;
94
+ var getDefaults = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
95
+ var auths = getDefaults ? getDefaultsFallback(kb2, ns) : kb2.each(undefined, ns.acl('accessTo'), doc);
96
+ var ACL = ns.acl;
97
+ var ac = {
98
+ agent: {},
99
+ agentClass: {},
100
+ agentGroup: {},
101
+ origin: {},
102
+ originClass: {}
103
+ };
104
+ Object.keys(ac).forEach(function (pred) {
105
+ auths.forEach(function (a) {
106
+ kb2.each(a, ACL('mode')).forEach(function (mode) {
107
+ kb2.each(a, ACL(pred)).forEach(function (agent) {
108
+ ac[pred][agent.uri] = ac[pred][agent.uri] || {};
109
+ ac[pred][agent.uri][mode.uri] = a; // could be "true" but leave pointer just in case
132
110
  });
111
+ });
133
112
  });
134
- return ac;
135
- function getDefaultsFallback(kb, ns) {
136
- return kb
137
- .each(undefined, ns.acl('default'), doc)
138
- .concat(kb.each(undefined, ns.acl('defaultForNew'), doc));
139
- }
113
+ });
114
+ return ac;
115
+
116
+ function getDefaultsFallback(kb, ns) {
117
+ return kb.each(undefined, ns.acl('default'), doc).concat(kb.each(undefined, ns.acl('defaultForNew'), doc));
118
+ }
140
119
  }
141
- exports.readACL = readACL;
142
120
  /**
143
121
  * Compare two ACLs
144
122
  */
123
+
124
+
145
125
  function sameACL(a, b) {
146
- var contains = function (a, b) {
147
- for (var pred in {
148
- agent: true,
149
- agentClass: true,
150
- agentGroup: true,
151
- origin: true,
152
- originClass: true
153
- }) {
154
- if (a[pred]) {
155
- for (var agent in a[pred]) {
156
- for (var mode in a[pred][agent]) {
157
- if (!b[pred][agent] || !b[pred][agent][mode]) {
158
- return false;
159
- }
160
- }
161
- }
126
+ var contains = function contains(a, b) {
127
+ for (var pred in {
128
+ agent: true,
129
+ agentClass: true,
130
+ agentGroup: true,
131
+ origin: true,
132
+ originClass: true
133
+ }) {
134
+ if (a[pred]) {
135
+ for (var agent in a[pred]) {
136
+ for (var mode in a[pred][agent]) {
137
+ if (!b[pred][agent] || !b[pred][agent][mode]) {
138
+ return false;
162
139
  }
140
+ }
163
141
  }
164
- return true;
165
- };
166
- return contains(a, b) && contains(b, a);
142
+ }
143
+ }
144
+
145
+ return true;
146
+ };
147
+
148
+ return contains(a, b) && contains(b, a);
167
149
  }
168
- exports.sameACL = sameACL;
169
150
  /**
170
151
  * Union N ACLs
171
152
  */
153
+
154
+
172
155
  function ACLunion(list) {
173
- var b = list[0];
174
- var a, ag;
175
- var _loop_1 = function (k) {
176
- ;
177
- ['agent', 'agentClass', 'agentGroup', 'origin', 'originClass'].forEach(function (pred) {
178
- a = list[k];
179
- if (a[pred]) {
180
- for (ag in a[pred]) {
181
- for (var mode in a[pred][ag]) {
182
- if (!b[pred][ag])
183
- b[pred][ag] = [];
184
- b[pred][ag][mode] = true;
185
- }
186
- }
187
- }
188
- });
189
- };
190
- for (var k = 1; k < list.length; k++) {
191
- _loop_1(k);
192
- }
193
- return b;
156
+ var b = list[0];
157
+ var a, ag;
158
+
159
+ var _loop = function _loop(k) {
160
+ ;
161
+ ['agent', 'agentClass', 'agentGroup', 'origin', 'originClass'].forEach(function (pred) {
162
+ a = list[k];
163
+
164
+ if (a[pred]) {
165
+ for (ag in a[pred]) {
166
+ for (var mode in a[pred][ag]) {
167
+ if (!b[pred][ag]) b[pred][ag] = [];
168
+ b[pred][ag][mode] = true;
169
+ }
170
+ }
171
+ }
172
+ });
173
+ };
174
+
175
+ for (var k = 1; k < list.length; k++) {
176
+ _loop(k);
177
+ }
178
+
179
+ return b;
194
180
  }
195
- exports.ACLunion = ACLunion;
181
+
196
182
  /**
197
183
  * Merge ACLs lists from things to form union
198
184
  */
199
185
  function loadUnionACL(subjectList, callbackFunction) {
200
- var aclList = [];
201
- var doList = function (list) {
202
- if (list.length) {
203
- var doc = list.shift().doc();
204
- getACLorDefault(doc, function (ok, p2, targetDoc, targetACLDoc, defaultHolder, defaultACLDoc) {
205
- var defa = !p2;
206
- if (!ok || !defaultHolder || !defaultACLDoc)
207
- return callbackFunction(ok, targetACLDoc);
208
- var acl = defa
209
- ? readACL(defaultHolder, defaultACLDoc)
210
- : readACL(targetDoc, targetACLDoc);
211
- aclList.push(acl);
212
- doList(list.slice(1));
213
- });
214
- }
215
- else {
216
- // all gone
217
- callbackFunction(true, ACLunion(aclList));
218
- }
219
- };
220
- doList(subjectList);
186
+ var aclList = [];
187
+
188
+ var doList = function doList(list) {
189
+ if (list.length) {
190
+ var doc = list.shift().doc();
191
+ getACLorDefault(doc, function (ok, p2, targetDoc, targetACLDoc, defaultHolder, defaultACLDoc) {
192
+ var defa = !p2;
193
+ if (!ok || !defaultHolder || !defaultACLDoc) return callbackFunction(ok, targetACLDoc);
194
+ var acl = defa ? readACL(defaultHolder, defaultACLDoc) : readACL(targetDoc, targetACLDoc);
195
+ aclList.push(acl);
196
+ doList(list.slice(1));
197
+ });
198
+ } else {
199
+ // all gone
200
+ callbackFunction(true, ACLunion(aclList));
201
+ }
202
+ };
203
+
204
+ doList(subjectList);
221
205
  }
222
- exports.loadUnionACL = loadUnionACL;
223
206
  /**
224
207
  * Represents these as an RDF graph by combination of modes
225
208
  *
226
209
  * Each agent can only be in one place in this model, one combination of modes.
227
210
  * Combos are like full control, read append, read only etc.
228
211
  */
212
+
213
+
229
214
  function ACLbyCombination(ac) {
230
- var byCombo = {};
231
- ['agent', 'agentClass', 'agentGroup', 'origin', 'originClass'].forEach(function (pred) {
232
- for (var agent in ac[pred]) {
233
- var combo = [];
234
- for (var mode in ac[pred][agent]) {
235
- combo.push(mode);
236
- }
237
- combo.sort();
238
- var combo2 = combo.join('\n');
239
- if (!byCombo[combo2])
240
- byCombo[combo2] = [];
241
- byCombo[combo2].push([pred, agent]);
242
- }
243
- });
244
- return byCombo;
215
+ var byCombo = {};
216
+ ['agent', 'agentClass', 'agentGroup', 'origin', 'originClass'].forEach(function (pred) {
217
+ for (var agent in ac[pred]) {
218
+ var combo = [];
219
+
220
+ for (var mode in ac[pred][agent]) {
221
+ combo.push(mode);
222
+ }
223
+
224
+ combo.sort();
225
+ var combo2 = combo.join('\n');
226
+ if (!byCombo[combo2]) byCombo[combo2] = [];
227
+ byCombo[combo2].push([pred, agent]);
228
+ }
229
+ });
230
+ return byCombo;
245
231
  }
246
- exports.ACLbyCombination = ACLbyCombination;
247
232
  /**
248
233
  * Write ACL graph to store from AC
249
234
  */
235
+
236
+
250
237
  function makeACLGraph(kb, x, ac, aclDoc) {
251
- var byCombo = ACLbyCombination(ac);
252
- return makeACLGraphbyCombo(kb, x, byCombo, aclDoc);
238
+ var byCombo = ACLbyCombination(ac);
239
+ return makeACLGraphbyCombo(kb, x, byCombo, aclDoc);
253
240
  }
254
- exports.makeACLGraph = makeACLGraph;
255
241
  /**
256
242
  * Write ACL graph to store from combo
257
243
  */
244
+
245
+
258
246
  function makeACLGraphbyCombo(kb, x, byCombo, aclDoc, main, defa) {
259
- var ACL = ns.acl;
260
- for (var combo in byCombo) {
261
- var pairs = byCombo[combo];
262
- if (!pairs.length)
263
- continue; // do not add to store when no agent
264
- var modeURIs = combo.split('\n');
265
- var short = modeURIs
266
- .map(function (u) {
267
- return u.split('#')[1];
268
- })
269
- .join('');
270
- if (defa && !main)
271
- short += 'Default'; // don't muddle authorizations
272
- var a = kb.sym(aclDoc.uri + '#' + short);
273
- kb.add(a, ns.rdf('type'), ACL('Authorization'), aclDoc);
274
- if (main) {
275
- kb.add(a, ACL('accessTo'), x, aclDoc);
276
- }
277
- if (defa) {
278
- kb.add(a, ACL('default'), x, aclDoc);
279
- }
280
- for (var i = 0; i < modeURIs.length; i++) {
281
- kb.add(a, ACL('mode'), kb.sym(modeURIs[i]), aclDoc);
282
- }
283
- for (var i = 0; i < pairs.length; i++) {
284
- var pred = pairs[i][0];
285
- var ag = pairs[i][1];
286
- kb.add(a, ACL(pred), kb.sym(ag), aclDoc);
287
- }
247
+ var ACL = ns.acl;
248
+
249
+ for (var combo in byCombo) {
250
+ var pairs = byCombo[combo];
251
+ if (!pairs.length) continue; // do not add to store when no agent
252
+
253
+ var modeURIs = combo.split('\n');
254
+
255
+ var _short = modeURIs.map(function (u) {
256
+ return u.split('#')[1];
257
+ }).join('');
258
+
259
+ if (defa && !main) _short += 'Default'; // don't muddle authorizations
260
+
261
+ var _a = kb.sym(aclDoc.uri + '#' + _short);
262
+
263
+ kb.add(_a, ns.rdf('type'), ACL('Authorization'), aclDoc);
264
+
265
+ if (main) {
266
+ kb.add(_a, ACL('accessTo'), x, aclDoc);
267
+ }
268
+
269
+ if (defa) {
270
+ kb.add(_a, ACL('default'), x, aclDoc);
271
+ }
272
+
273
+ for (var i = 0; i < modeURIs.length; i++) {
274
+ kb.add(_a, ACL('mode'), kb.sym(modeURIs[i]), aclDoc);
275
+ }
276
+
277
+ for (var _i = 0; _i < pairs.length; _i++) {
278
+ var pred = pairs[_i][0];
279
+ var ag = pairs[_i][1];
280
+ kb.add(_a, ACL(pred), kb.sym(ag), aclDoc);
288
281
  }
282
+ }
289
283
  }
290
- exports.makeACLGraphbyCombo = makeACLGraphbyCombo;
291
284
  /**
292
285
  * Debugging short strings for dumping ACL
293
286
  * and possibly in the UI
294
287
  */
288
+
289
+
295
290
  function ACLToString(ac) {
296
- return comboToString(ACLbyCombination(ac));
291
+ return comboToString(ACLbyCombination(ac));
297
292
  }
298
- exports.ACLToString = ACLToString;
299
293
  /**
300
294
  * Convert a [[ComboList]] to a string
301
295
  */
296
+
297
+
302
298
  function comboToString(byCombo) {
303
- var str = '';
304
- for (var combo in byCombo) {
305
- var modeURIs = combo.split('\n');
306
- var initials = modeURIs
307
- .map(function (u) {
308
- return u.split('#')[1][0];
309
- })
310
- .join('');
311
- str += initials + ':';
312
- var pairs = byCombo[combo];
313
- for (var i = 0; i < pairs.length; i++) {
314
- var pred = pairs[i][0];
315
- var ag = (0, rdflib_1.sym)(pairs[i][1]);
316
- str += pred === 'agent' ? '@' : '';
317
- str += ag.sameTerm(ns.foaf('Agent')) ? '*' : utils.label(ag);
318
- if (i < pairs.length - 1)
319
- str += ',';
320
- }
321
- str += ';';
299
+ var str = '';
300
+
301
+ for (var combo in byCombo) {
302
+ var modeURIs = combo.split('\n');
303
+ var initials = modeURIs.map(function (u) {
304
+ return u.split('#')[1][0];
305
+ }).join('');
306
+ str += initials + ':';
307
+ var pairs = byCombo[combo];
308
+
309
+ for (var i = 0; i < pairs.length; i++) {
310
+ var pred = pairs[i][0];
311
+ var ag = (0, _rdflib.sym)(pairs[i][1]);
312
+ str += pred === 'agent' ? '@' : '';
313
+ str += ag.sameTerm(ns.foaf('Agent')) ? '*' : utils.label(ag);
314
+ if (i < pairs.length - 1) str += ',';
322
315
  }
323
- return '{' + str.slice(0, -1) + '}'; // drop extra semicolon
316
+
317
+ str += ';';
318
+ }
319
+
320
+ return '{' + str.slice(0, -1) + '}'; // drop extra semicolon
324
321
  }
325
- exports.comboToString = comboToString;
326
322
  /**
327
323
  * Write ACL graph as Turtle
328
324
  */
325
+
326
+
329
327
  function makeACLString(x, ac, aclDoc) {
330
- var kb2 = (0, rdflib_1.graph)();
331
- makeACLGraph(kb2, x, ac, aclDoc);
332
- return (0, rdflib_1.serialize)(aclDoc, kb2, aclDoc.uri, 'text/turtle') || '';
328
+ var kb2 = (0, _rdflib.graph)();
329
+ makeACLGraph(kb2, x, ac, aclDoc);
330
+ return (0, _rdflib.serialize)(aclDoc, kb2, aclDoc.uri, 'text/turtle') || '';
333
331
  }
334
- exports.makeACLString = makeACLString;
335
332
  /**
336
333
  * Write ACL graph to web
337
334
  */
335
+
336
+
338
337
  function putACLObject(kb, x, ac, aclDoc, callbackFunction) {
339
- var byCombo = ACLbyCombination(ac);
340
- return putACLbyCombo(kb, x, byCombo, aclDoc, callbackFunction);
338
+ var byCombo = ACLbyCombination(ac);
339
+ return putACLbyCombo(kb, x, byCombo, aclDoc, callbackFunction);
341
340
  }
342
- exports.putACLObject = putACLObject;
343
341
  /**
344
342
  * Write ACL graph to web from a [[ComboList]]
345
343
  */
344
+
345
+
346
346
  function putACLbyCombo(kb, x, byCombo, aclDoc, callbackFunction) {
347
- var kb2 = (0, rdflib_1.graph)();
348
- makeACLGraphbyCombo(kb2, x, byCombo, aclDoc, true);
349
- // const str = makeACLString = function(x, ac, aclDoc)
350
- kb.updater.put(aclDoc, kb2.statementsMatching(undefined, undefined, undefined, aclDoc), 'text/turtle', function (uri, ok, message) {
351
- if (!ok) {
352
- callbackFunction(ok, message);
353
- }
354
- else {
355
- kb.fetcher.unload(aclDoc);
356
- makeACLGraphbyCombo(kb, x, byCombo, aclDoc, true);
357
- kb.fetcher.requested[aclDoc.uri] = 'done'; // missing: save headers
358
- callbackFunction(ok);
359
- }
360
- });
347
+ var _kb$updater;
348
+
349
+ var kb2 = (0, _rdflib.graph)();
350
+ makeACLGraphbyCombo(kb2, x, byCombo, aclDoc, true); // const str = makeACLString = function(x, ac, aclDoc)
351
+
352
+ (_kb$updater = kb.updater) === null || _kb$updater === void 0 ? void 0 : _kb$updater.put(aclDoc, kb2.statementsMatching(undefined, undefined, undefined, aclDoc), 'text/turtle', function (uri, ok, message) {
353
+ if (!ok) {
354
+ callbackFunction(ok, message);
355
+ } else {
356
+ var _kb$fetcher;
357
+
358
+ (_kb$fetcher = kb.fetcher) === null || _kb$fetcher === void 0 ? void 0 : _kb$fetcher.unload(aclDoc);
359
+ makeACLGraphbyCombo(kb, x, byCombo, aclDoc, true);
360
+ kb.fetcher.requested[aclDoc.uri] = 'done'; // missing: save headers
361
+
362
+ callbackFunction(ok);
363
+ }
364
+ });
361
365
  }
362
- exports.putACLbyCombo = putACLbyCombo;
366
+
363
367
  /**
364
368
  * Fix the ACl for an individual card as a function of the groups it is in
365
369
  *
366
370
  * All group files must be loaded first
367
371
  */
368
372
  function fixIndividualCardACL(person, log, callbackFunction) {
369
- var groups = kb.each(undefined, ns.vcard('hasMember'), person);
370
- // const doc = person.doc()
371
- if (groups) {
372
- fixIndividualACL(person, groups, log, callbackFunction);
373
- }
374
- else {
375
- log('This card is in no groups');
376
- callbackFunction(true); // fine, no requirements to access. default should be ok
377
- }
378
- // @@ if no groups, then use default for People container or the book top container.?
373
+ var groups = kb.each(undefined, ns.vcard('hasMember'), person); // const doc = person.doc()
374
+
375
+ if (groups) {
376
+ fixIndividualACL(person, groups, log, callbackFunction);
377
+ } else {
378
+ log('This card is in no groups');
379
+ callbackFunction(true); // fine, no requirements to access. default should be ok
380
+ } // @@ if no groups, then use default for People container or the book top container.?
381
+
379
382
  }
380
- exports.fixIndividualCardACL = fixIndividualCardACL;
381
383
  /**
382
384
  * This function is used by [[fixIndividualCardACL]]
383
385
  */
386
+
387
+
384
388
  function fixIndividualACL(item, subjects, log, callbackFunction) {
385
- log = log || debug.log;
386
- var doc = item.doc();
387
- getACLorDefault(doc, function (ok, exists, targetDoc, targetACLDoc, defaultHolder, defaultACLDoc) {
388
- if (!ok || !defaultHolder || !defaultACLDoc)
389
- return callbackFunction(false, targetACLDoc); // ie message
390
- var ac = exists
391
- ? readACL(targetDoc, targetACLDoc)
392
- : readACL(defaultHolder, defaultACLDoc);
393
- loadUnionACL(subjects, function (ok, union) {
394
- if (!ok)
395
- return callbackFunction(false, union);
396
- if (sameACL(union, ac)) {
397
- log('Nice - same ACL. no change ' + utils.label(item) + ' ' + doc);
398
- }
399
- else {
400
- log('Group ACLs differ for ' + utils.label(item) + ' ' + doc);
401
- // log("Group ACLs: " + makeACLString(targetDoc, union, targetACLDoc))
402
- // log((exists ? "Previous set" : "Default") + " ACLs: " +
403
- // makeACLString(targetDoc, ac, targetACLDoc))
404
- putACLObject(kb, targetDoc, union, targetACLDoc, callbackFunction);
405
- }
406
- });
389
+ log = log || debug.log;
390
+ var doc = item.doc();
391
+ getACLorDefault(doc, function (ok, exists, targetDoc, targetACLDoc, defaultHolder, defaultACLDoc) {
392
+ if (!ok || !defaultHolder || !defaultACLDoc) return callbackFunction(false, targetACLDoc); // ie message
393
+
394
+ var ac = exists ? readACL(targetDoc, targetACLDoc) : readACL(defaultHolder, defaultACLDoc);
395
+ loadUnionACL(subjects, function (ok, union) {
396
+ if (!ok) return callbackFunction(false, union);
397
+
398
+ if (sameACL(union, ac)) {
399
+ log('Nice - same ACL. no change ' + utils.label(item) + ' ' + doc);
400
+ } else {
401
+ log('Group ACLs differ for ' + utils.label(item) + ' ' + doc); // log("Group ACLs: " + makeACLString(targetDoc, union, targetACLDoc))
402
+ // log((exists ? "Previous set" : "Default") + " ACLs: " +
403
+ // makeACLString(targetDoc, ac, targetACLDoc))
404
+
405
+ putACLObject(kb, targetDoc, union, targetACLDoc, callbackFunction);
406
+ }
407
407
  });
408
+ });
408
409
  }
409
- exports.fixIndividualACL = fixIndividualACL;
410
410
  /**
411
411
  * Set an ACL
412
412
  */
413
+
414
+
413
415
  function setACL(docURI, aclText, callbackFunction) {
414
- var aclDoc = kb.any(docURI, solid_logic_1.ACL_LINK); // @@ check that this get set by web.js
415
- if (!kb.fetcher) {
416
- throw new Error('Store has no fetcher');
417
- }
418
- if (aclDoc) {
419
- // Great we already know where it is
420
- kb.fetcher
421
- .webOperation('PUT', aclDoc.value, {
422
- data: aclText,
423
- contentType: 'text/turtle'
424
- })
425
- .then(function (res) {
426
- callbackFunction(res.ok, res.error || '');
427
- }); // @@@ check params
428
- }
429
- else {
430
- kb.fetcher.nowOrWhenFetched(docURI, undefined, function (ok, body) {
431
- if (!ok)
432
- return callbackFunction(ok, 'Gettting headers for ACL: ' + body);
433
- var aclDoc = kb.any(docURI, solid_logic_1.ACL_LINK); // @@ check that this get set by web.js
434
- if (!aclDoc) {
435
- // complainIfBad(false, "No Link rel=ACL header for " + docURI)
436
- callbackFunction(false, 'No Link rel=ACL header for ' + docURI);
437
- }
438
- else {
439
- if (!kb.fetcher) {
440
- throw new Error('Store has no fetcher');
441
- }
442
- kb.fetcher
443
- .webOperation('PUT', aclDoc.value, {
444
- data: aclText,
445
- contentType: 'text/turtle'
446
- })
447
- .then(function (res) {
448
- callbackFunction(res.ok, res.error || '');
449
- });
450
- }
416
+ var aclDoc = kb.any(docURI, _solidLogic.ACL_LINK); // @@ check that this get set by web.js
417
+
418
+ if (!kb.fetcher) {
419
+ throw new Error('Store has no fetcher');
420
+ }
421
+
422
+ if (aclDoc) {
423
+ // Great we already know where it is
424
+ kb.fetcher.webOperation('PUT', aclDoc.value, {
425
+ data: aclText,
426
+ contentType: 'text/turtle'
427
+ }).then(function (res) {
428
+ callbackFunction(res.ok, res.error || '');
429
+ }); // @@@ check params
430
+ } else {
431
+ kb.fetcher.nowOrWhenFetched(docURI, undefined, function (ok, body) {
432
+ if (!ok) return callbackFunction(ok, 'Gettting headers for ACL: ' + body);
433
+ var aclDoc = kb.any(docURI, _solidLogic.ACL_LINK); // @@ check that this get set by web.js
434
+
435
+ if (!aclDoc) {
436
+ // complainIfBad(false, "No Link rel=ACL header for " + docURI)
437
+ callbackFunction(false, 'No Link rel=ACL header for ' + docURI);
438
+ } else {
439
+ if (!kb.fetcher) {
440
+ throw new Error('Store has no fetcher');
441
+ }
442
+
443
+ kb.fetcher.webOperation('PUT', aclDoc.value, {
444
+ data: aclText,
445
+ contentType: 'text/turtle'
446
+ }).then(function (res) {
447
+ callbackFunction(res.ok, res.error || '');
451
448
  });
452
- }
449
+ }
450
+ });
451
+ }
453
452
  }
454
- exports.setACL = setACL;
455
453
  /**
456
454
  * Get ACL file or default if necessary
457
455
  *
@@ -461,67 +459,66 @@ exports.setACL = setACL;
461
459
  * * `callbackFunction(false, false, status, message)` when there was an error getting the original
462
460
  * * `callbackFunction(false, true, status, message)` when there was an error getting the default
463
461
  */
462
+
463
+
464
464
  function getACLorDefault(doc, callbackFunction) {
465
- getACL(doc, function (ok, status, aclDoc, message) {
466
- var ACL = ns.acl;
467
- if (!ok)
468
- return callbackFunction(false, false, status, message);
469
- // Recursively search for the ACL file which gives default access
470
- var tryParent = function (uri) {
471
- if (uri.slice(-1) === '/') {
472
- uri = uri.slice(0, -1);
473
- }
474
- var right = uri.lastIndexOf('/');
475
- var left = uri.indexOf('/', uri.indexOf('//') + 2);
476
- if (left > right) {
477
- return callbackFunction(false, true, 404, 'Found no ACL resource');
478
- }
479
- uri = uri.slice(0, right + 1);
480
- var doc2 = (0, rdflib_1.sym)(uri);
481
- getACL(doc2, function (ok, status, defaultACLDoc) {
482
- if (!ok) {
483
- return callbackFunction(false, true, status, "( No ACL pointer ".concat(uri, " ").concat(status, ")").concat(defaultACLDoc));
484
- }
485
- else if (status === 403) {
486
- return callbackFunction(false, true, status, "( default ACL file FORBIDDEN. Stop.".concat(uri, ")"));
487
- }
488
- else if (status === 404) {
489
- return tryParent(uri);
490
- }
491
- else if (status !== 200) {
492
- return callbackFunction(false, true, status, "Error status '".concat(status, "' searching for default for ").concat(doc2));
493
- }
494
- // 200
495
- // statusBlock.textContent += (" ACCESS set at " + uri + ". End search.")
496
- var defaults = kb
497
- .each(undefined, ACL('default'), kb.sym(uri), defaultACLDoc)
498
- .concat(kb.each(undefined, ACL('defaultForNew'), kb.sym(uri), defaultACLDoc));
499
- if (!defaults.length) {
500
- return tryParent(uri); // Keep searching
501
- }
502
- var defaultHolder = kb.sym(uri);
503
- return callbackFunction(true, false, doc, aclDoc, defaultHolder, defaultACLDoc);
504
- });
505
- }; // tryParent
465
+ getACL(doc, function (ok, status, aclDoc, message) {
466
+ var ACL = ns.acl;
467
+ if (!ok) return callbackFunction(false, false, status, message); // Recursively search for the ACL file which gives default access
468
+
469
+ var tryParent = function tryParent(uri) {
470
+ if (uri.slice(-1) === '/') {
471
+ uri = uri.slice(0, -1);
472
+ }
473
+
474
+ var right = uri.lastIndexOf('/');
475
+ var left = uri.indexOf('/', uri.indexOf('//') + 2);
476
+
477
+ if (left > right) {
478
+ return callbackFunction(false, true, 404, 'Found no ACL resource');
479
+ }
480
+
481
+ uri = uri.slice(0, right + 1);
482
+ var doc2 = (0, _rdflib.sym)(uri);
483
+ getACL(doc2, function (ok, status, defaultACLDoc) {
506
484
  if (!ok) {
507
- return callbackFunction(false, false, status, "Error accessing Access Control information for ".concat(doc, ") ").concat(message));
508
- }
509
- else if (status === 404) {
510
- tryParent(doc.uri); // @@ construct default one - the server should do that
511
- }
512
- else if (status === 403) {
513
- return callbackFunction(false, false, status, "(Sharing not available to you)".concat(message));
485
+ return callbackFunction(false, true, status, "( No ACL pointer ".concat(uri, " ").concat(status, ")").concat(defaultACLDoc));
486
+ } else if (status === 403) {
487
+ return callbackFunction(false, true, status, "( default ACL file FORBIDDEN. Stop.".concat(uri, ")"));
488
+ } else if (status === 404) {
489
+ return tryParent(uri);
490
+ } else if (status !== 200) {
491
+ return callbackFunction(false, true, status, "Error status '".concat(status, "' searching for default for ").concat(doc2));
492
+ } // 200
493
+ // statusBlock.textContent += (" ACCESS set at " + uri + ". End search.")
494
+
495
+
496
+ var defaults = kb.each(undefined, ACL('default'), kb.sym(uri), defaultACLDoc).concat(kb.each(undefined, ACL('defaultForNew'), kb.sym(uri), defaultACLDoc));
497
+
498
+ if (!defaults.length) {
499
+ return tryParent(uri); // Keep searching
514
500
  }
515
- else if (status !== 200) {
516
- return callbackFunction(false, false, status, "Error ".concat(status, " accessing Access Control information for ").concat(doc, ": ").concat(message));
517
- }
518
- else {
519
- // 200
520
- return callbackFunction(true, true, doc, aclDoc);
521
- }
522
- }); // Call to getACL
501
+
502
+ var defaultHolder = kb.sym(uri);
503
+ return callbackFunction(true, false, doc, aclDoc, defaultHolder, defaultACLDoc);
504
+ });
505
+ }; // tryParent
506
+
507
+
508
+ if (!ok) {
509
+ return callbackFunction(false, false, status, "Error accessing Access Control information for ".concat(doc, ") ").concat(message));
510
+ } else if (status === 404) {
511
+ tryParent(doc.uri); // @@ construct default one - the server should do that
512
+ } else if (status === 403) {
513
+ return callbackFunction(false, false, status, "(Sharing not available to you)".concat(message));
514
+ } else if (status !== 200) {
515
+ return callbackFunction(false, false, status, "Error ".concat(status, " accessing Access Control information for ").concat(doc, ": ").concat(message));
516
+ } else {
517
+ // 200
518
+ return callbackFunction(true, true, doc, aclDoc);
519
+ }
520
+ }); // Call to getACL
523
521
  }
524
- exports.getACLorDefault = getACLorDefault;
525
522
  /**
526
523
  * Calls back `(ok, status, acldoc, message)` as follows
527
524
  *
@@ -530,51 +527,73 @@ exports.getACLorDefault = getACLorDefault;
530
527
  * * `(true, 404, documentSymbol, fileaccesserror)` if does not exist
531
528
  * * `(true, 200, documentSymbol)` if file exists and read OK
532
529
  */
530
+
531
+
533
532
  function getACL(doc, callbackFunction) {
534
- if (!kb.fetcher) {
535
- throw new Error('kb has no fetcher');
533
+ if (!kb.fetcher) {
534
+ throw new Error('kb has no fetcher');
535
+ }
536
+
537
+ kb.fetcher.nowOrWhenFetched(doc, undefined, function (ok, body) {
538
+ if (!ok) {
539
+ return callbackFunction(ok, "Can't get headers to find ACL for ".concat(doc, ": ").concat(body));
536
540
  }
537
- kb.fetcher.nowOrWhenFetched(doc, undefined, function (ok, body) {
541
+
542
+ var aclDoc = kb.any(doc, _solidLogic.ACL_LINK); // @@ check that this get set by web.js
543
+
544
+ if (!aclDoc) {
545
+ callbackFunction(false, 900, "No Link rel=ACL header for ".concat(doc));
546
+ } else {
547
+ if (!kb.fetcher) {
548
+ throw new Error('kb has no fetcher');
549
+ }
550
+
551
+ if (kb.fetcher.nonexistent[aclDoc.value]) {
552
+ return callbackFunction(true, 404, aclDoc, "ACL file ".concat(aclDoc, " does not exist."));
553
+ }
554
+
555
+ kb.fetcher.nowOrWhenFetched(aclDoc, undefined, function (ok, message, response) {
538
556
  if (!ok) {
539
- return callbackFunction(ok, "Can't get headers to find ACL for ".concat(doc, ": ").concat(body));
540
- }
541
- var aclDoc = kb.any(doc, solid_logic_1.ACL_LINK); // @@ check that this get set by web.js
542
- if (!aclDoc) {
543
- callbackFunction(false, 900, "No Link rel=ACL header for ".concat(doc));
557
+ callbackFunction(true, response.status, aclDoc, "Can't read Access Control File ".concat(aclDoc, ": ").concat(message));
558
+ } else {
559
+ callbackFunction(true, 200, aclDoc);
544
560
  }
545
- else {
546
- if (!kb.fetcher) {
547
- throw new Error('kb has no fetcher');
548
- }
549
- if (kb.fetcher.nonexistent[aclDoc.value]) {
550
- return callbackFunction(true, 404, aclDoc, "ACL file ".concat(aclDoc, " does not exist."));
551
- }
552
- kb.fetcher.nowOrWhenFetched(aclDoc, undefined, function (ok, message, response) {
553
- if (!ok) {
554
- callbackFunction(true, response.status, aclDoc, "Can't read Access Control File ".concat(aclDoc, ": ").concat(message));
555
- }
556
- else {
557
- callbackFunction(true, 200, aclDoc);
558
- }
559
- });
560
- }
561
- });
561
+ });
562
+ }
563
+ });
562
564
  }
563
- exports.getACL = getACL;
564
565
  /**
565
566
  * Calls [[getACLorDefault]] and then (?)
566
567
  */
567
- function getProspectiveHolder(targetDirectory) {
568
- return __awaiter(this, void 0, void 0, function () {
569
- return __generator(this, function (_a) {
570
- return [2 /*return*/, new Promise(function (resolve, reject) { return getACLorDefault((0, rdflib_1.sym)(targetDirectory), function (ok, isDirectACL, targetDoc, targetACLDoc, defaultHolder) {
571
- if (ok) {
572
- return resolve((isDirectACL ? targetDoc : defaultHolder));
573
- }
574
- return reject(new Error("Error loading ".concat(targetDirectory)));
575
- }); })];
576
- });
577
- });
568
+
569
+
570
+ function getProspectiveHolder(_x) {
571
+ return _getProspectiveHolder.apply(this, arguments);
572
+ }
573
+
574
+ function _getProspectiveHolder() {
575
+ _getProspectiveHolder = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(targetDirectory) {
576
+ return _regenerator["default"].wrap(function _callee$(_context) {
577
+ while (1) {
578
+ switch (_context.prev = _context.next) {
579
+ case 0:
580
+ return _context.abrupt("return", new Promise(function (resolve, reject) {
581
+ return getACLorDefault((0, _rdflib.sym)(targetDirectory), function (ok, isDirectACL, targetDoc, targetACLDoc, defaultHolder) {
582
+ if (ok) {
583
+ return resolve(isDirectACL ? targetDoc : defaultHolder);
584
+ }
585
+
586
+ return reject(new Error("Error loading ".concat(targetDirectory)));
587
+ });
588
+ }));
589
+
590
+ case 1:
591
+ case "end":
592
+ return _context.stop();
593
+ }
594
+ }
595
+ }, _callee);
596
+ }));
597
+ return _getProspectiveHolder.apply(this, arguments);
578
598
  }
579
- exports.getProspectiveHolder = getProspectiveHolder;
580
599
  //# sourceMappingURL=acl.js.map