solid-ui 2.4.14-46ae8b5d → 2.4.14-alpha

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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 +334 -441
  6. package/lib/acl/access-controller.js.map +1 -1
  7. package/lib/acl/access-groups.d.ts +1 -1
  8. package/lib/acl/access-groups.d.ts.map +1 -1
  9. package/lib/acl/access-groups.js +347 -492
  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 +168 -198
  14. package/lib/acl/acl-control.js.map +1 -1
  15. package/lib/acl/acl.d.ts +1 -1
  16. package/lib/acl/acl.d.ts.map +1 -1
  17. package/lib/acl/acl.js +444 -459
  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 +318 -515
  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 +27 -35
  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 +84 -90
  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 +5 -4
  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 +14 -21
  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 +1391 -1935
  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 +26 -37
  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 +1 -4
  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 +209 -214
  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 +4 -10
  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 +1 -4
  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 +30 -28
  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 +109 -126
  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 +7 -11
  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 +2 -6
  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 +285 -361
  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 +116 -132
  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 +23 -30
  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 +0 -0
  114. package/lib/index.d.ts.map +0 -0
  115. package/lib/index.js +103 -207
  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 +21 -30
  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 +83 -131
  124. package/lib/log.js.map +1 -1
  125. package/lib/logic.d.ts +0 -0
  126. package/lib/logic.d.ts.map +0 -0
  127. package/lib/logic.js +82 -69
  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 +4 -10
  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 +210 -237
  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 +1 -4
  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 +5 -11
  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 +187 -181
  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 +794 -954
  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 +170 -199
  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 +235 -342
  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 +130 -155
  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 +121 -113
  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 +23 -28
  190. package/lib/versionInfo.js.map +1 -1
  191. package/lib/webpack-bundle.js +9 -9
  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 +19 -30
  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 +935 -1113
  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 +18 -24
  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 +234 -325
  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 +246 -276
  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 +317 -497
  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 +159 -212
  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 +485 -718
  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 +208 -239
  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 +31 -50
  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 +102 -81
  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 +52 -50
  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 +18 -30
  256. package/lib/widgets/widgetHelpers.js.map +1 -1
  257. package/package.json +5 -4
package/lib/acl/acl.js CHANGED
@@ -1,451 +1,457 @@
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
-
50
2
  /**
51
3
  * Non-UI functions for access control.
52
4
  * See https://github.com/solid/web-access-control-spec
53
5
  * for the spec that defines how ACL documents work.
54
6
  * @packageDocumentation
55
7
  */
56
- var kb = _logic.solidLogicSingleton.store;
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;
57
72
  /**
58
73
  * Take the "default" ACL and convert it into the equivlent ACL
59
74
  * which the resource would have had. Return it as a new separate store.
60
75
  * The "defaultForNew" predicate is also accepted, as a deprecated
61
76
  * synonym for "default".
62
77
  */
63
-
64
78
  function adoptACLDefault(doc, aclDoc, defaultResource, defaultACLDoc) {
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
- }
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
+ }
84
103
  }
104
+ exports.adoptACLDefault = adoptACLDefault;
85
105
  /**
86
106
  * Read and canonicalize the ACL for x in aclDoc
87
107
  *
88
108
  * Accumulate the access rights which each agent or class has
89
109
  */
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
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
+ });
110
132
  });
111
- });
112
133
  });
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
- }
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
+ }
119
140
  }
141
+ exports.readACL = readACL;
120
142
  /**
121
143
  * Compare two ACLs
122
144
  */
123
-
124
-
125
145
  function sameACL(a, b) {
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;
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
+ }
139
162
  }
140
- }
141
163
  }
142
- }
143
- }
144
-
145
- return true;
146
- };
147
-
148
- return contains(a, b) && contains(b, a);
164
+ return true;
165
+ };
166
+ return contains(a, b) && contains(b, a);
149
167
  }
168
+ exports.sameACL = sameACL;
150
169
  /**
151
170
  * Union N ACLs
152
171
  */
153
-
154
-
155
172
  function ACLunion(list) {
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;
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;
180
194
  }
181
-
195
+ exports.ACLunion = ACLunion;
182
196
  /**
183
197
  * Merge ACLs lists from things to form union
184
198
  */
185
199
  function loadUnionACL(subjectList, callbackFunction) {
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);
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);
205
221
  }
222
+ exports.loadUnionACL = loadUnionACL;
206
223
  /**
207
224
  * Represents these as an RDF graph by combination of modes
208
225
  *
209
226
  * Each agent can only be in one place in this model, one combination of modes.
210
227
  * Combos are like full control, read append, read only etc.
211
228
  */
212
-
213
-
214
229
  function ACLbyCombination(ac) {
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;
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;
231
245
  }
246
+ exports.ACLbyCombination = ACLbyCombination;
232
247
  /**
233
248
  * Write ACL graph to store from AC
234
249
  */
235
-
236
-
237
250
  function makeACLGraph(kb, x, ac, aclDoc) {
238
- var byCombo = ACLbyCombination(ac);
239
- return makeACLGraphbyCombo(kb, x, byCombo, aclDoc);
251
+ var byCombo = ACLbyCombination(ac);
252
+ return makeACLGraphbyCombo(kb, x, byCombo, aclDoc);
240
253
  }
254
+ exports.makeACLGraph = makeACLGraph;
241
255
  /**
242
256
  * Write ACL graph to store from combo
243
257
  */
244
-
245
-
246
258
  function makeACLGraphbyCombo(kb, x, byCombo, aclDoc, main, defa) {
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);
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
+ }
281
288
  }
282
- }
283
289
  }
290
+ exports.makeACLGraphbyCombo = makeACLGraphbyCombo;
284
291
  /**
285
292
  * Debugging short strings for dumping ACL
286
293
  * and possibly in the UI
287
294
  */
288
-
289
-
290
295
  function ACLToString(ac) {
291
- return comboToString(ACLbyCombination(ac));
296
+ return comboToString(ACLbyCombination(ac));
292
297
  }
298
+ exports.ACLToString = ACLToString;
293
299
  /**
294
300
  * Convert a [[ComboList]] to a string
295
301
  */
296
-
297
-
298
302
  function comboToString(byCombo) {
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 += ',';
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 += ';';
315
322
  }
316
-
317
- str += ';';
318
- }
319
-
320
- return '{' + str.slice(0, -1) + '}'; // drop extra semicolon
323
+ return '{' + str.slice(0, -1) + '}'; // drop extra semicolon
321
324
  }
325
+ exports.comboToString = comboToString;
322
326
  /**
323
327
  * Write ACL graph as Turtle
324
328
  */
325
-
326
-
327
329
  function makeACLString(x, ac, aclDoc) {
328
- var kb2 = (0, _rdflib.graph)();
329
- makeACLGraph(kb2, x, ac, aclDoc);
330
- return (0, _rdflib.serialize)(aclDoc, kb2, aclDoc.uri, 'text/turtle') || '';
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') || '';
331
333
  }
334
+ exports.makeACLString = makeACLString;
332
335
  /**
333
336
  * Write ACL graph to web
334
337
  */
335
-
336
-
337
338
  function putACLObject(kb, x, ac, aclDoc, callbackFunction) {
338
- var byCombo = ACLbyCombination(ac);
339
- return putACLbyCombo(kb, x, byCombo, aclDoc, callbackFunction);
339
+ var byCombo = ACLbyCombination(ac);
340
+ return putACLbyCombo(kb, x, byCombo, aclDoc, callbackFunction);
340
341
  }
342
+ exports.putACLObject = putACLObject;
341
343
  /**
342
344
  * Write ACL graph to web from a [[ComboList]]
343
345
  */
344
-
345
-
346
346
  function putACLbyCombo(kb, x, byCombo, aclDoc, callbackFunction) {
347
- var kb2 = (0, _rdflib.graph)();
348
- makeACLGraphbyCombo(kb2, x, byCombo, aclDoc, true); // const str = makeACLString = function(x, ac, aclDoc)
349
-
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
- } else {
354
- kb.fetcher.unload(aclDoc);
355
- makeACLGraphbyCombo(kb, x, byCombo, aclDoc, true);
356
- kb.fetcher.requested[aclDoc.uri] = 'done'; // missing: save headers
357
-
358
- callbackFunction(ok);
359
- }
360
- });
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
+ });
361
361
  }
362
-
362
+ exports.putACLbyCombo = putACLbyCombo;
363
363
  /**
364
364
  * Fix the ACl for an individual card as a function of the groups it is in
365
365
  *
366
366
  * All group files must be loaded first
367
367
  */
368
368
  function fixIndividualCardACL(person, log, callbackFunction) {
369
- var groups = kb.each(undefined, ns.vcard('hasMember'), person); // const doc = person.doc()
370
-
371
- if (groups) {
372
- fixIndividualACL(person, groups, log, callbackFunction);
373
- } else {
374
- log('This card is in no groups');
375
- callbackFunction(true); // fine, no requirements to access. default should be ok
376
- } // @@ if no groups, then use default for People container or the book top container.?
377
-
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.?
378
379
  }
380
+ exports.fixIndividualCardACL = fixIndividualCardACL;
379
381
  /**
380
382
  * This function is used by [[fixIndividualCardACL]]
381
383
  */
382
-
383
-
384
384
  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) return callbackFunction(false, targetACLDoc); // ie message
389
-
390
- var ac = exists ? readACL(targetDoc, targetACLDoc) : readACL(defaultHolder, defaultACLDoc);
391
- loadUnionACL(subjects, function (ok, union) {
392
- if (!ok) return callbackFunction(false, union);
393
-
394
- if (sameACL(union, ac)) {
395
- log('Nice - same ACL. no change ' + utils.label(item) + ' ' + doc);
396
- } else {
397
- log('Group ACLs differ for ' + utils.label(item) + ' ' + doc); // log("Group ACLs: " + makeACLString(targetDoc, union, targetACLDoc))
398
- // log((exists ? "Previous set" : "Default") + " ACLs: " +
399
- // makeACLString(targetDoc, ac, targetACLDoc))
400
-
401
- putACLObject(kb, targetDoc, union, targetACLDoc, callbackFunction);
402
- }
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
+ });
403
407
  });
404
- });
405
408
  }
409
+ exports.fixIndividualACL = fixIndividualACL;
406
410
  /**
407
411
  * Set an ACL
408
412
  */
409
-
410
-
411
413
  function setACL(docURI, aclText, callbackFunction) {
412
- var aclDoc = kb.any(docURI, _solidLogic.ACL_LINK); // @@ check that this get set by web.js
413
-
414
- if (!kb.fetcher) {
415
- throw new Error('Store has no fetcher');
416
- }
417
-
418
- if (aclDoc) {
419
- // Great we already know where it is
420
- kb.fetcher.webOperation('PUT', aclDoc.value, {
421
- data: aclText,
422
- contentType: 'text/turtle'
423
- }).then(function (res) {
424
- callbackFunction(res.ok, res.error || '');
425
- }); // @@@ check params
426
- } else {
427
- kb.fetcher.nowOrWhenFetched(docURI, undefined, function (ok, body) {
428
- if (!ok) return callbackFunction(ok, 'Gettting headers for ACL: ' + body);
429
- var aclDoc = kb.any(docURI, _solidLogic.ACL_LINK); // @@ check that this get set by web.js
430
-
431
- if (!aclDoc) {
432
- // complainIfBad(false, "No Link rel=ACL header for " + docURI)
433
- callbackFunction(false, 'No Link rel=ACL header for ' + docURI);
434
- } else {
435
- if (!kb.fetcher) {
436
- throw new Error('Store has no fetcher');
437
- }
438
-
439
- kb.fetcher.webOperation('PUT', aclDoc.value, {
440
- data: aclText,
441
- contentType: 'text/turtle'
442
- }).then(function (res) {
443
- callbackFunction(res.ok, res.error || '');
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
+ }
444
451
  });
445
- }
446
- });
447
- }
452
+ }
448
453
  }
454
+ exports.setACL = setACL;
449
455
  /**
450
456
  * Get ACL file or default if necessary
451
457
  *
@@ -455,66 +461,67 @@ function setACL(docURI, aclText, callbackFunction) {
455
461
  * * `callbackFunction(false, false, status, message)` when there was an error getting the original
456
462
  * * `callbackFunction(false, true, status, message)` when there was an error getting the default
457
463
  */
458
-
459
-
460
464
  function getACLorDefault(doc, callbackFunction) {
461
- getACL(doc, function (ok, status, aclDoc, message) {
462
- var ACL = ns.acl;
463
- if (!ok) return callbackFunction(false, false, status, message); // Recursively search for the ACL file which gives default access
464
-
465
- var tryParent = function tryParent(uri) {
466
- if (uri.slice(-1) === '/') {
467
- uri = uri.slice(0, -1);
468
- }
469
-
470
- var right = uri.lastIndexOf('/');
471
- var left = uri.indexOf('/', uri.indexOf('//') + 2);
472
-
473
- if (left > right) {
474
- return callbackFunction(false, true, 404, 'Found no ACL resource');
475
- }
476
-
477
- uri = uri.slice(0, right + 1);
478
- var doc2 = (0, _rdflib.sym)(uri);
479
- getACL(doc2, function (ok, status, defaultACLDoc) {
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
480
506
  if (!ok) {
481
- return callbackFunction(false, true, status, "( No ACL pointer ".concat(uri, " ").concat(status, ")").concat(defaultACLDoc));
482
- } else if (status === 403) {
483
- return callbackFunction(false, true, status, "( default ACL file FORBIDDEN. Stop.".concat(uri, ")"));
484
- } else if (status === 404) {
485
- return tryParent(uri);
486
- } else if (status !== 200) {
487
- return callbackFunction(false, true, status, "Error status '".concat(status, "' searching for default for ").concat(doc2));
488
- } // 200
489
- // statusBlock.textContent += (" ACCESS set at " + uri + ". End search.")
490
-
491
-
492
- var defaults = kb.each(undefined, ACL('default'), kb.sym(uri), defaultACLDoc).concat(kb.each(undefined, ACL('defaultForNew'), kb.sym(uri), defaultACLDoc));
493
-
494
- if (!defaults.length) {
495
- return tryParent(uri); // Keep searching
507
+ return callbackFunction(false, false, status, "Error accessing Access Control information for ".concat(doc, ") ").concat(message));
496
508
  }
497
-
498
- var defaultHolder = kb.sym(uri);
499
- return callbackFunction(true, false, doc, aclDoc, defaultHolder, defaultACLDoc);
500
- });
501
- }; // tryParent
502
-
503
-
504
- if (!ok) {
505
- return callbackFunction(false, false, status, "Error accessing Access Control information for ".concat(doc, ") ").concat(message));
506
- } else if (status === 404) {
507
- tryParent(doc.uri); // @@ construct default one - the server should do that
508
- } else if (status === 403) {
509
- return callbackFunction(false, false, status, "(Sharing not available to you)".concat(message));
510
- } else if (status !== 200) {
511
- return callbackFunction(false, false, status, "Error ".concat(status, " accessing Access Control information for ").concat(doc, ": ").concat(message));
512
- } else {
513
- // 200
514
- return callbackFunction(true, true, doc, aclDoc);
515
- }
516
- }); // Call to getACL
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));
514
+ }
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
517
523
  }
524
+ exports.getACLorDefault = getACLorDefault;
518
525
  /**
519
526
  * Calls back `(ok, status, acldoc, message)` as follows
520
527
  *
@@ -523,73 +530,51 @@ function getACLorDefault(doc, callbackFunction) {
523
530
  * * `(true, 404, documentSymbol, fileaccesserror)` if does not exist
524
531
  * * `(true, 200, documentSymbol)` if file exists and read OK
525
532
  */
526
-
527
-
528
533
  function getACL(doc, callbackFunction) {
529
- if (!kb.fetcher) {
530
- throw new Error('kb has no fetcher');
531
- }
532
-
533
- kb.fetcher.nowOrWhenFetched(doc, undefined, function (ok, body) {
534
- if (!ok) {
535
- return callbackFunction(ok, "Can't get headers to find ACL for ".concat(doc, ": ").concat(body));
536
- }
537
-
538
- var aclDoc = kb.any(doc, _solidLogic.ACL_LINK); // @@ check that this get set by web.js
539
-
540
- if (!aclDoc) {
541
- callbackFunction(false, 900, "No Link rel=ACL header for ".concat(doc));
542
- } else {
543
- if (!kb.fetcher) {
534
+ if (!kb.fetcher) {
544
535
  throw new Error('kb has no fetcher');
545
- }
546
-
547
- if (kb.fetcher.nonexistent[aclDoc.value]) {
548
- return callbackFunction(true, 404, aclDoc, "ACL file ".concat(aclDoc, " does not exist."));
549
- }
550
-
551
- kb.fetcher.nowOrWhenFetched(aclDoc, undefined, function (ok, message, response) {
536
+ }
537
+ kb.fetcher.nowOrWhenFetched(doc, undefined, function (ok, body) {
552
538
  if (!ok) {
553
- callbackFunction(true, response.status, aclDoc, "Can't read Access Control File ".concat(aclDoc, ": ").concat(message));
554
- } else {
555
- callbackFunction(true, 200, aclDoc);
539
+ return callbackFunction(ok, "Can't get headers to find ACL for ".concat(doc, ": ").concat(body));
556
540
  }
557
- });
558
- }
559
- });
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));
544
+ }
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
+ });
560
562
  }
563
+ exports.getACL = getACL;
561
564
  /**
562
565
  * Calls [[getACLorDefault]] and then (?)
563
566
  */
564
-
565
-
566
- function getProspectiveHolder(_x) {
567
- return _getProspectiveHolder.apply(this, arguments);
568
- }
569
-
570
- function _getProspectiveHolder() {
571
- _getProspectiveHolder = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(targetDirectory) {
572
- return _regenerator["default"].wrap(function _callee$(_context) {
573
- while (1) {
574
- switch (_context.prev = _context.next) {
575
- case 0:
576
- return _context.abrupt("return", new Promise(function (resolve, reject) {
577
- return getACLorDefault((0, _rdflib.sym)(targetDirectory), function (ok, isDirectACL, targetDoc, targetACLDoc, defaultHolder) {
578
- if (ok) {
579
- return resolve(isDirectACL ? targetDoc : defaultHolder);
580
- }
581
-
582
- return reject(new Error("Error loading ".concat(targetDirectory)));
583
- });
584
- }));
585
-
586
- case 1:
587
- case "end":
588
- return _context.stop();
589
- }
590
- }
591
- }, _callee);
592
- }));
593
- return _getProspectiveHolder.apply(this, arguments);
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
+ });
594
578
  }
579
+ exports.getProspectiveHolder = getProspectiveHolder;
595
580
  //# sourceMappingURL=acl.js.map