solid-logic 3.1.1-dbb83f7 → 3.1.1-e3eba68
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -105
- package/eslint.config.js +29 -0
- package/jest.config.js +10 -0
- package/lib/acl/aclLogic.d.ts +5 -0
- package/{dist → lib}/acl/aclLogic.d.ts.map +1 -1
- package/lib/acl/aclLogic.js +168 -0
- package/lib/acl/aclLogic.js.map +1 -0
- package/{dist → lib}/authSession/authSession.js +1 -1
- package/{dist → lib}/authSession/authSession.js.map +1 -1
- package/{dist → lib}/authn/SolidAuthnLogic.d.ts +3 -3
- package/{dist → lib}/authn/SolidAuthnLogic.d.ts.map +1 -1
- package/lib/authn/SolidAuthnLogic.js +193 -0
- package/lib/authn/SolidAuthnLogic.js.map +1 -0
- package/{dist → lib}/authn/authUtil.d.ts +1 -1
- package/{dist → lib}/authn/authUtil.js +12 -12
- package/lib/authn/authUtil.js.map +1 -0
- package/{dist → lib}/chat/chatLogic.d.ts +1 -1
- package/lib/chat/chatLogic.js +272 -0
- package/lib/chat/chatLogic.js.map +1 -0
- package/{dist → lib}/inbox/inboxLogic.d.ts +1 -1
- package/{dist → lib}/inbox/inboxLogic.d.ts.map +1 -1
- package/lib/inbox/inboxLogic.js +139 -0
- package/lib/inbox/inboxLogic.js.map +1 -0
- package/{dist → lib}/index.d.ts +1 -1
- package/{dist → lib}/index.d.ts.map +1 -1
- package/{dist → lib}/index.js +4 -4
- package/{dist → lib}/index.js.map +1 -1
- package/lib/issuer/issuerLogic.js +52 -0
- package/lib/issuer/issuerLogic.js.map +1 -0
- package/{dist → lib}/logic/CustomError.d.ts.map +1 -1
- package/lib/logic/CustomError.js +89 -0
- package/lib/logic/CustomError.js.map +1 -0
- package/lib/logic/solidLogic.d.ts +6 -0
- package/{dist → lib}/logic/solidLogic.d.ts.map +1 -1
- package/{dist → lib}/logic/solidLogic.js +33 -32
- package/lib/logic/solidLogic.js.map +1 -0
- package/lib/logic/solidLogicSingleton.js +94 -0
- package/lib/logic/solidLogicSingleton.js.map +1 -0
- package/{dist → lib}/profile/profileLogic.d.ts +1 -1
- package/lib/profile/profileLogic.js +259 -0
- package/lib/profile/profileLogic.js.map +1 -0
- package/lib/typeIndex/typeIndexLogic.js +399 -0
- package/lib/typeIndex/typeIndexLogic.js.map +1 -0
- package/{dist → lib}/types.d.ts +2 -2
- package/{dist → lib}/util/containerLogic.d.ts +1 -1
- package/{dist → lib}/util/containerLogic.d.ts.map +1 -1
- package/lib/util/containerLogic.js +102 -0
- package/lib/util/containerLogic.js.map +1 -0
- package/lib/util/debug.d.ts.map +1 -0
- package/lib/util/debug.js +40 -0
- package/lib/util/debug.js.map +1 -0
- package/{dist → lib}/util/ns.js +2 -2
- package/{dist → lib}/util/ns.js.map +1 -1
- package/{dist → lib}/util/utilityLogic.d.ts +1 -1
- package/{dist → lib}/util/utilityLogic.d.ts.map +1 -1
- package/lib/util/utilityLogic.js +284 -0
- package/lib/util/utilityLogic.js.map +1 -0
- package/{dist → lib}/util/utils.d.ts +1 -1
- package/{dist → lib}/util/utils.d.ts.map +1 -1
- package/lib/util/utils.js +47 -0
- package/lib/util/utils.js.map +1 -0
- package/package.json +22 -50
- package/src/acl/aclLogic.ts +156 -0
- package/src/authSession/authSession.ts +7 -0
- package/src/authn/SolidAuthnLogic.ts +127 -0
- package/src/authn/authUtil.ts +70 -0
- package/src/chat/chatLogic.ts +226 -0
- package/src/inbox/inboxLogic.ts +59 -0
- package/src/index.ts +22 -0
- package/src/issuer/issuerLogic.ts +40 -0
- package/src/logic/CustomError.ts +29 -0
- package/src/logic/solidLogic.ts +76 -0
- package/src/logic/solidLogicSingleton.ts +20 -0
- package/src/profile/profileLogic.ts +125 -0
- package/src/typeIndex/typeIndexLogic.ts +198 -0
- package/src/types.ts +122 -0
- package/{dist/util/containerLogic.js → src/util/containerLogic.ts} +25 -20
- package/src/util/debug.ts +20 -0
- package/src/util/ns.ts +5 -0
- package/src/util/utilityLogic.ts +156 -0
- package/src/util/utils.ts +52 -0
- package/test/aclLogic.test.ts +24 -0
- package/test/authUtil.test.ts +23 -0
- package/test/chatLogic.test.ts +316 -0
- package/test/container.test.ts +58 -0
- package/test/helpers/dataSetup.ts +134 -0
- package/test/helpers/setup.ts +17 -0
- package/test/inboxLogic.test.ts +218 -0
- package/test/logic.test.ts +29 -0
- package/test/profileLogic.test.ts +246 -0
- package/test/solidAuthLogic.test.ts +49 -0
- package/test/typeIndexLogic.test.ts +255 -0
- package/test/utilityLogic.test.ts +179 -0
- package/test/utils.test.ts +32 -0
- package/tsconfig.json +75 -0
- package/dist/acl/aclLogic.d.ts +0 -5
- package/dist/acl/aclLogic.js +0 -122
- package/dist/acl/aclLogic.js.map +0 -1
- package/dist/authn/SolidAuthnLogic.js +0 -147
- package/dist/authn/SolidAuthnLogic.js.map +0 -1
- package/dist/authn/authUtil.js.map +0 -1
- package/dist/chat/chatLogic.js +0 -160
- package/dist/chat/chatLogic.js.map +0 -1
- package/dist/inbox/inboxLogic.js +0 -55
- package/dist/inbox/inboxLogic.js.map +0 -1
- package/dist/issuer/issuerLogic.js +0 -40
- package/dist/issuer/issuerLogic.js.map +0 -1
- package/dist/logic/CustomError.js +0 -38
- package/dist/logic/CustomError.js.map +0 -1
- package/dist/logic/solidLogic.d.ts +0 -6
- package/dist/logic/solidLogic.js.map +0 -1
- package/dist/logic/solidLogicSingleton.js +0 -54
- package/dist/logic/solidLogicSingleton.js.map +0 -1
- package/dist/profile/profileLogic.js +0 -165
- package/dist/profile/profileLogic.js.map +0 -1
- package/dist/solid-logic.esm.external.js +0 -12725
- package/dist/solid-logic.esm.external.js.map +0 -1
- package/dist/solid-logic.esm.external.min.js +0 -32
- package/dist/solid-logic.esm.external.min.js.map +0 -1
- package/dist/solid-logic.js +0 -12802
- package/dist/solid-logic.js.map +0 -1
- package/dist/solid-logic.min.js +0 -32
- package/dist/solid-logic.min.js.map +0 -1
- package/dist/typeIndex/typeIndexLogic.js +0 -222
- package/dist/typeIndex/typeIndexLogic.js.map +0 -1
- package/dist/util/containerLogic.js.map +0 -1
- package/dist/util/debug.d.ts.map +0 -1
- package/dist/util/debug.js +0 -20
- package/dist/util/debug.js.map +0 -1
- package/dist/util/utilityLogic.js +0 -180
- package/dist/util/utilityLogic.js.map +0 -1
- package/dist/util/utils.js +0 -47
- package/dist/util/utils.js.map +0 -1
- package/dist/versionInfo.js +0 -33
- package/dist/versionInfo.js.map +0 -1
- /package/{dist → lib}/authSession/authSession.d.ts +0 -0
- /package/{dist → lib}/authSession/authSession.d.ts.map +0 -0
- /package/{dist → lib}/authn/authUtil.d.ts.map +0 -0
- /package/{dist → lib}/chat/chatLogic.d.ts.map +0 -0
- /package/{dist → lib}/issuer/issuerLogic.d.ts +0 -0
- /package/{dist → lib}/issuer/issuerLogic.d.ts.map +0 -0
- /package/{dist → lib}/logic/CustomError.d.ts +0 -0
- /package/{dist → lib}/logic/solidLogicSingleton.d.ts +0 -0
- /package/{dist → lib}/logic/solidLogicSingleton.d.ts.map +0 -0
- /package/{dist → lib}/profile/profileLogic.d.ts.map +0 -0
- /package/{dist → lib}/typeIndex/typeIndexLogic.d.ts +0 -0
- /package/{dist → lib}/typeIndex/typeIndexLogic.d.ts.map +0 -0
- /package/{dist → lib}/types.d.ts.map +0 -0
- /package/{dist → lib}/types.js +0 -0
- /package/{dist → lib}/types.js.map +0 -0
- /package/{dist → lib}/util/debug.d.ts +0 -0
- /package/{dist → lib}/util/ns.d.ts +0 -0
- /package/{dist → lib}/util/ns.d.ts.map +0 -0
|
@@ -0,0 +1,284 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
36
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
37
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
38
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
39
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
40
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
41
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
42
|
+
});
|
|
43
|
+
};
|
|
44
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
45
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
46
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
47
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
48
|
+
function step(op) {
|
|
49
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
50
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
51
|
+
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;
|
|
52
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
53
|
+
switch (op[0]) {
|
|
54
|
+
case 0: case 1: t = op; break;
|
|
55
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
56
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
57
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
58
|
+
default:
|
|
59
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
60
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
61
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
62
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
63
|
+
if (t[2]) _.ops.pop();
|
|
64
|
+
_.trys.pop(); continue;
|
|
65
|
+
}
|
|
66
|
+
op = body.call(thisArg, _);
|
|
67
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
68
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
72
|
+
exports.createUtilityLogic = createUtilityLogic;
|
|
73
|
+
var rdflib_1 = require("rdflib");
|
|
74
|
+
var CustomError_1 = require("../logic/CustomError");
|
|
75
|
+
var debug = __importStar(require("../util/debug"));
|
|
76
|
+
var utils_1 = require("./utils");
|
|
77
|
+
function createUtilityLogic(store, aclLogic, containerLogic) {
|
|
78
|
+
function recursiveDelete(containerNode) {
|
|
79
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
80
|
+
var aclDocUrl, containerMembers, nodeToStringHere, e_1;
|
|
81
|
+
return __generator(this, function (_a) {
|
|
82
|
+
switch (_a.label) {
|
|
83
|
+
case 0:
|
|
84
|
+
_a.trys.push([0, 6, , 7]);
|
|
85
|
+
if (!containerLogic.isContainer(containerNode)) return [3 /*break*/, 5];
|
|
86
|
+
return [4 /*yield*/, aclLogic.findAclDocUrl(containerNode)];
|
|
87
|
+
case 1:
|
|
88
|
+
aclDocUrl = _a.sent();
|
|
89
|
+
return [4 /*yield*/, store.fetcher._fetch(aclDocUrl, { method: "DELETE" })];
|
|
90
|
+
case 2:
|
|
91
|
+
_a.sent();
|
|
92
|
+
return [4 /*yield*/, containerLogic.getContainerMembers(containerNode)];
|
|
93
|
+
case 3:
|
|
94
|
+
containerMembers = _a.sent();
|
|
95
|
+
return [4 /*yield*/, Promise.all(containerMembers.map(function (url) { return recursiveDelete(url); }))];
|
|
96
|
+
case 4:
|
|
97
|
+
_a.sent();
|
|
98
|
+
_a.label = 5;
|
|
99
|
+
case 5:
|
|
100
|
+
nodeToStringHere = containerNode.value;
|
|
101
|
+
return [2 /*return*/, store.fetcher._fetch(nodeToStringHere, { method: "DELETE" })];
|
|
102
|
+
case 6:
|
|
103
|
+
e_1 = _a.sent();
|
|
104
|
+
debug.log("Please manually remove ".concat(containerNode.value, " from your system."), e_1);
|
|
105
|
+
return [3 /*break*/, 7];
|
|
106
|
+
case 7: return [2 /*return*/];
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Create a resource if it really does not exist
|
|
113
|
+
* Be absolutely sure something does not exist before creating a new empty file
|
|
114
|
+
* as otherwise existing could be deleted.
|
|
115
|
+
* @param doc {NamedNode} - The resource
|
|
116
|
+
*/
|
|
117
|
+
function loadOrCreateIfNotExists(doc) {
|
|
118
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
119
|
+
var response, err_1, err_2, msg, msg;
|
|
120
|
+
return __generator(this, function (_a) {
|
|
121
|
+
switch (_a.label) {
|
|
122
|
+
case 0:
|
|
123
|
+
_a.trys.push([0, 2, , 10]);
|
|
124
|
+
return [4 /*yield*/, store.fetcher.load(doc)];
|
|
125
|
+
case 1:
|
|
126
|
+
response = _a.sent();
|
|
127
|
+
return [3 /*break*/, 10];
|
|
128
|
+
case 2:
|
|
129
|
+
err_1 = _a.sent();
|
|
130
|
+
if (!(err_1.response.status === 404)) return [3 /*break*/, 8];
|
|
131
|
+
_a.label = 3;
|
|
132
|
+
case 3:
|
|
133
|
+
_a.trys.push([3, 5, , 6]);
|
|
134
|
+
return [4 /*yield*/, store.fetcher.webOperation('PUT', doc, { data: '', contentType: 'text/turtle' })];
|
|
135
|
+
case 4:
|
|
136
|
+
_a.sent();
|
|
137
|
+
return [3 /*break*/, 6];
|
|
138
|
+
case 5:
|
|
139
|
+
err_2 = _a.sent();
|
|
140
|
+
msg = 'createIfNotExists: PUT FAILED: ' + doc + ': ' + err_2;
|
|
141
|
+
throw new CustomError_1.WebOperationError(msg);
|
|
142
|
+
case 6: return [4 /*yield*/, store.fetcher.load(doc)];
|
|
143
|
+
case 7:
|
|
144
|
+
_a.sent();
|
|
145
|
+
return [3 /*break*/, 9];
|
|
146
|
+
case 8:
|
|
147
|
+
if (err_1.response.status === 401) {
|
|
148
|
+
throw new CustomError_1.UnauthorizedError();
|
|
149
|
+
}
|
|
150
|
+
if (err_1.response.status === 403) {
|
|
151
|
+
if ((0, utils_1.differentOrigin)(doc)) {
|
|
152
|
+
throw new CustomError_1.CrossOriginForbiddenError();
|
|
153
|
+
}
|
|
154
|
+
throw new CustomError_1.SameOriginForbiddenError();
|
|
155
|
+
}
|
|
156
|
+
msg = 'createIfNotExists doc load error NOT 404: ' + doc + ': ' + err_1;
|
|
157
|
+
throw new CustomError_1.FetchError(err_1.status, err_1.message + msg);
|
|
158
|
+
case 9: return [3 /*break*/, 10];
|
|
159
|
+
case 10: return [2 /*return*/, response];
|
|
160
|
+
}
|
|
161
|
+
});
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
/* Follow link from this doc to another thing, or else make a new link
|
|
165
|
+
**
|
|
166
|
+
** @returns existing object, or creates it if non existent
|
|
167
|
+
*/
|
|
168
|
+
function followOrCreateLink(subject, predicate, object, doc) {
|
|
169
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
170
|
+
var result, msg, err_3, msg, err_4;
|
|
171
|
+
return __generator(this, function (_a) {
|
|
172
|
+
switch (_a.label) {
|
|
173
|
+
case 0: return [4 /*yield*/, store.fetcher.load(doc)];
|
|
174
|
+
case 1:
|
|
175
|
+
_a.sent();
|
|
176
|
+
result = store.any(subject, predicate, null, doc);
|
|
177
|
+
if (result)
|
|
178
|
+
return [2 /*return*/, result];
|
|
179
|
+
if (!store.updater.editable(doc)) {
|
|
180
|
+
msg = "followOrCreateLink: cannot edit ".concat(doc.value);
|
|
181
|
+
debug.warn(msg);
|
|
182
|
+
throw new CustomError_1.NotEditableError(msg);
|
|
183
|
+
}
|
|
184
|
+
_a.label = 2;
|
|
185
|
+
case 2:
|
|
186
|
+
_a.trys.push([2, 4, , 5]);
|
|
187
|
+
return [4 /*yield*/, store.updater.update([], [(0, rdflib_1.st)(subject, predicate, object, doc)])];
|
|
188
|
+
case 3:
|
|
189
|
+
_a.sent();
|
|
190
|
+
return [3 /*break*/, 5];
|
|
191
|
+
case 4:
|
|
192
|
+
err_3 = _a.sent();
|
|
193
|
+
msg = "followOrCreateLink: Error making link in ".concat(doc, " to ").concat(object, ": ").concat(err_3);
|
|
194
|
+
debug.warn(msg);
|
|
195
|
+
throw new CustomError_1.WebOperationError(err_3);
|
|
196
|
+
case 5:
|
|
197
|
+
_a.trys.push([5, 7, , 8]);
|
|
198
|
+
return [4 /*yield*/, loadOrCreateIfNotExists(object)
|
|
199
|
+
// store.fetcher.webOperation('PUT', object, { data: '', contentType: 'text/turtle'})
|
|
200
|
+
];
|
|
201
|
+
case 6:
|
|
202
|
+
_a.sent();
|
|
203
|
+
return [3 /*break*/, 8];
|
|
204
|
+
case 7:
|
|
205
|
+
err_4 = _a.sent();
|
|
206
|
+
debug.warn("followOrCreateLink: Error loading or saving new linked document: ".concat(object, ": ").concat(err_4));
|
|
207
|
+
throw err_4;
|
|
208
|
+
case 8: return [2 /*return*/, object];
|
|
209
|
+
}
|
|
210
|
+
});
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
// Copied from https://github.com/solidos/web-access-control-tests/blob/v3.0.0/test/surface/delete.test.ts#L5
|
|
214
|
+
function setSinglePeerAccess(options) {
|
|
215
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
216
|
+
var str, aclDocUrl;
|
|
217
|
+
return __generator(this, function (_a) {
|
|
218
|
+
switch (_a.label) {
|
|
219
|
+
case 0:
|
|
220
|
+
str = [
|
|
221
|
+
'@prefix acl: <http://www.w3.org/ns/auth/acl#>.',
|
|
222
|
+
'',
|
|
223
|
+
"<#alice> a acl:Authorization;\n acl:agent <".concat(options.ownerWebId, ">;"),
|
|
224
|
+
" acl:accessTo <".concat(options.target, ">;"),
|
|
225
|
+
" acl:default <".concat(options.target, ">;"),
|
|
226
|
+
' acl:mode acl:Read, acl:Write, acl:Control.',
|
|
227
|
+
''
|
|
228
|
+
].join('\n');
|
|
229
|
+
if (options.accessToModes) {
|
|
230
|
+
str += [
|
|
231
|
+
'<#bobAccessTo> a acl:Authorization;',
|
|
232
|
+
" acl:agent <".concat(options.peerWebId, ">;"),
|
|
233
|
+
" acl:accessTo <".concat(options.target, ">;"),
|
|
234
|
+
" acl:mode ".concat(options.accessToModes, "."),
|
|
235
|
+
''
|
|
236
|
+
].join('\n');
|
|
237
|
+
}
|
|
238
|
+
if (options.defaultModes) {
|
|
239
|
+
str += [
|
|
240
|
+
'<#bobDefault> a acl:Authorization;',
|
|
241
|
+
" acl:agent <".concat(options.peerWebId, ">;"),
|
|
242
|
+
" acl:default <".concat(options.target, ">;"),
|
|
243
|
+
" acl:mode ".concat(options.defaultModes, "."),
|
|
244
|
+
''
|
|
245
|
+
].join('\n');
|
|
246
|
+
}
|
|
247
|
+
return [4 /*yield*/, aclLogic.findAclDocUrl((0, rdflib_1.sym)(options.target))];
|
|
248
|
+
case 1:
|
|
249
|
+
aclDocUrl = _a.sent();
|
|
250
|
+
return [2 /*return*/, store.fetcher._fetch(aclDocUrl, {
|
|
251
|
+
method: 'PUT',
|
|
252
|
+
body: str,
|
|
253
|
+
headers: [
|
|
254
|
+
['Content-Type', 'text/turtle']
|
|
255
|
+
]
|
|
256
|
+
})];
|
|
257
|
+
}
|
|
258
|
+
});
|
|
259
|
+
});
|
|
260
|
+
}
|
|
261
|
+
function createEmptyRdfDoc(doc, comment) {
|
|
262
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
263
|
+
return __generator(this, function (_a) {
|
|
264
|
+
switch (_a.label) {
|
|
265
|
+
case 0: return [4 /*yield*/, store.fetcher.webOperation("PUT", doc.uri, {
|
|
266
|
+
data: "# ".concat(new Date(), " ").concat(comment, "\n "),
|
|
267
|
+
contentType: "text/turtle",
|
|
268
|
+
})];
|
|
269
|
+
case 1:
|
|
270
|
+
_a.sent();
|
|
271
|
+
return [2 /*return*/];
|
|
272
|
+
}
|
|
273
|
+
});
|
|
274
|
+
});
|
|
275
|
+
}
|
|
276
|
+
return {
|
|
277
|
+
recursiveDelete: recursiveDelete,
|
|
278
|
+
setSinglePeerAccess: setSinglePeerAccess,
|
|
279
|
+
createEmptyRdfDoc: createEmptyRdfDoc,
|
|
280
|
+
followOrCreateLink: followOrCreateLink,
|
|
281
|
+
loadOrCreateIfNotExists: loadOrCreateIfNotExists
|
|
282
|
+
};
|
|
283
|
+
}
|
|
284
|
+
//# sourceMappingURL=utilityLogic.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utilityLogic.js","sourceRoot":"","sources":["../../src/util/utilityLogic.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAKA,gDAqJC;AA1JD,iCAA4C;AAC5C,oDAA+J;AAC/J,mDAAuC;AACvC,iCAA0C;AAE1C,SAAgB,kBAAkB,CAAC,KAAK,EAAE,QAAQ,EAAE,cAAc;IAEhE,SAAe,eAAe,CAAC,aAAwB;;;;;;;6BAE7C,cAAc,CAAC,WAAW,CAAC,aAAa,CAAC,EAAzC,wBAAyC;wBACzB,qBAAM,QAAQ,CAAC,aAAa,CAAC,aAAa,CAAC,EAAA;;wBAAvD,SAAS,GAAG,SAA2C;wBAC7D,qBAAM,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,SAAS,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,EAAA;;wBAA3D,SAA2D,CAAC;wBACnC,qBAAM,cAAc,CAAC,mBAAmB,CAAC,aAAa,CAAC,EAAA;;wBAA1E,gBAAgB,GAAG,SAAuD;wBAChF,qBAAM,OAAO,CAAC,GAAG,CACf,gBAAgB,CAAC,GAAG,CAAC,UAAC,GAAG,IAAK,OAAA,eAAe,CAAC,GAAG,CAAC,EAApB,CAAoB,CAAC,CACpD,EAAA;;wBAFD,SAEC,CAAC;;;wBAEE,gBAAgB,GAAG,aAAa,CAAC,KAAK,CAAC;wBAC7C,sBAAO,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC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,OAAe;;;;4BAC9D,qBAAM,KAAK,CAAC,OAAO,CAAC,YAAY,CAAC,KAAK,EAAE,GAAG,CAAC,GAAG,EAAE;4BAC/C,IAAI,EAAE,YAAK,IAAI,IAAI,EAAE,cAAI,OAAO,SACnC;4BACG,WAAW,EAAE,aAAa;yBAC3B,CAAC,EAAA;;wBAJF,SAIE,CAAC;;;;;KACJ;IAED,OAAO;QACL,eAAe,iBAAA;QACf,mBAAmB,qBAAA;QACnB,iBAAiB,mBAAA;QACjB,kBAAkB,oBAAA;QAClB,uBAAuB,yBAAA;KACxB,CAAA;AACH,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { NamedNode } from
|
|
1
|
+
import { NamedNode } from "rdflib";
|
|
2
2
|
export declare function newThing(doc: NamedNode): NamedNode;
|
|
3
3
|
export declare function uniqueNodes(arr: NamedNode[]): NamedNode[];
|
|
4
4
|
export declare function getArchiveUrl(baseUrl: string, date: Date): string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/util/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAO,MAAM,QAAQ,
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/util/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAO,MAAM,QAAQ,CAAC;AAExC,wBAAgB,QAAQ,CAAC,GAAG,EAAE,SAAS,GAAG,SAAS,CAElD;AAED,wBAAgB,WAAW,CAAE,GAAG,EAAE,SAAS,EAAE,GAAG,SAAS,EAAE,CAM1D;AAED,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,UAOxD;AAED,wBAAgB,eAAe,CAAC,GAAG,KAAA,GAAG,OAAO,CAO5C;AAED,wBAAgB,sBAAsB,CAAE,EAAE,EAAC,SAAS,aAMnD;AAED,wBAAgB,sBAAsB,CAClC,OAAO,EAAE,SAAS,EAClB,OAAO,EAAE,SAAS,GACnB,SAAS,CAQX"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.newThing = newThing;
|
|
4
|
+
exports.uniqueNodes = uniqueNodes;
|
|
5
|
+
exports.getArchiveUrl = getArchiveUrl;
|
|
6
|
+
exports.differentOrigin = differentOrigin;
|
|
7
|
+
exports.suggestPreferencesFile = suggestPreferencesFile;
|
|
8
|
+
exports.determineChatContainer = determineChatContainer;
|
|
9
|
+
var rdflib_1 = require("rdflib");
|
|
10
|
+
function newThing(doc) {
|
|
11
|
+
return (0, rdflib_1.sym)(doc.uri + "#" + "id" + ("" + Date.now()));
|
|
12
|
+
}
|
|
13
|
+
function uniqueNodes(arr) {
|
|
14
|
+
var uris = arr.map(function (x) { return x.uri; });
|
|
15
|
+
var set = new Set(uris);
|
|
16
|
+
var uris2 = Array.from(set);
|
|
17
|
+
var arr2 = uris2.map(function (u) { return new rdflib_1.NamedNode(u); });
|
|
18
|
+
return arr2; // Array.from(new Set(arr.map(x => x.uri))).map(u => sym(u))
|
|
19
|
+
}
|
|
20
|
+
function getArchiveUrl(baseUrl, date) {
|
|
21
|
+
var year = date.getUTCFullYear();
|
|
22
|
+
var month = ('0' + (date.getUTCMonth() + 1)).slice(-2);
|
|
23
|
+
var day = ('0' + (date.getUTCDate())).slice(-2);
|
|
24
|
+
var parts = baseUrl.split('/');
|
|
25
|
+
var filename = parts[parts.length - 1];
|
|
26
|
+
return new URL("./archive/".concat(year, "/").concat(month, "/").concat(day, "/").concat(filename), baseUrl).toString();
|
|
27
|
+
}
|
|
28
|
+
function differentOrigin(doc) {
|
|
29
|
+
if (!doc) {
|
|
30
|
+
return true;
|
|
31
|
+
}
|
|
32
|
+
return ("".concat(window.location.origin, "/") !== new URL(doc.value).origin);
|
|
33
|
+
}
|
|
34
|
+
function suggestPreferencesFile(me) {
|
|
35
|
+
var stripped = me.uri.replace('/profile/', '/').replace('/public/', '/');
|
|
36
|
+
// const stripped = me.uri.replace(\/[p|P]rofile/\g, '/').replace(\/[p|P]ublic/\g, '/')
|
|
37
|
+
var folderURI = stripped.split('/').slice(0, -1).join('/') + '/Settings/';
|
|
38
|
+
var fileURI = folderURI + 'Preferences.ttl';
|
|
39
|
+
return (0, rdflib_1.sym)(fileURI);
|
|
40
|
+
}
|
|
41
|
+
function determineChatContainer(invitee, podRoot) {
|
|
42
|
+
// Create chat
|
|
43
|
+
// See https://gitter.im/solid/chat-app?at=5f3c800f855be416a23ae74a
|
|
44
|
+
var chatContainerStr = new URL("IndividualChats/".concat(new URL(invitee.value).host, "/"), podRoot.value).toString();
|
|
45
|
+
return new rdflib_1.NamedNode(chatContainerStr);
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/util/utils.ts"],"names":[],"mappings":";;AAEA,4BAEC;AAED,kCAMC;AAED,sCAOC;AAED,0CAOC;AAED,wDAMC;AAED,wDAWC;AAnDD,iCAAwC;AAExC,SAAgB,QAAQ,CAAC,GAAc;IACnC,OAAO,IAAA,YAAG,EAAC,GAAG,CAAC,GAAG,GAAG,GAAG,GAAG,IAAI,GAAG,CAAC,EAAE,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;AACzD,CAAC;AAED,SAAgB,WAAW,CAAE,GAAgB;IACzC,IAAM,IAAI,GAAG,GAAG,CAAC,GAAG,CAAC,UAAA,CAAC,IAAI,OAAA,CAAC,CAAC,GAAG,EAAL,CAAK,CAAC,CAAA;IAChC,IAAM,GAAG,GAAG,IAAI,GAAG,CAAC,IAAI,CAAC,CAAA;IACzB,IAAM,KAAK,GAAG,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;IAC7B,IAAM,IAAI,GAAG,KAAK,CAAC,GAAG,CAAC,UAAA,CAAC,IA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,KAAK,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,EAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,YAAY,CAAA;IAC1E,IAAM,OAAO,GAAG,SAAS,GAAG,iBAAiB,CAAA;IAC7C,OAAO,IAAA,YAAG,EAAC,OAAO,CAAC,CAAA;AACvB,CAAC;AAED,SAAgB,sBAAsB,CAClC,OAAkB,EAClB,OAAkB;IAElB,cAAc;IACd,mEAAmE;IACnE,IAAM,gBAAgB,GAAG,IAAI,GAAG,CAC5B,0BAAmB,IAAI,GAAG,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,IAAI,MAAG,EACjD,OAAO,CAAC,KAAK,CAChB,CAAC,QAAQ,EAAE,CAAC;IACb,OAAO,IAAI,kBAAS,CAAC,gBAAgB,CAAC,CAAC;AAC3C,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,40 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "solid-logic",
|
|
3
|
-
"version": "3.1.1-
|
|
4
|
-
"description": "Core business logic of
|
|
5
|
-
"main": "
|
|
6
|
-
"module": "dist/solid-logic.esm.external.js",
|
|
7
|
-
"types": "dist/index.d.ts",
|
|
8
|
-
"exports": {
|
|
9
|
-
".": {
|
|
10
|
-
"import": "./dist/solid-logic.esm.external.js",
|
|
11
|
-
"require": "./dist/solid-logic.js",
|
|
12
|
-
"types": "./dist/index.d.ts"
|
|
13
|
-
}
|
|
14
|
-
},
|
|
15
|
-
"sideEffects": false,
|
|
16
|
-
"files": [
|
|
17
|
-
"dist/",
|
|
18
|
-
"README.md",
|
|
19
|
-
"LICENSE"
|
|
20
|
-
],
|
|
3
|
+
"version": "3.1.1-e3eba68",
|
|
4
|
+
"description": "Core business logic of Solid OS",
|
|
5
|
+
"main": "lib/index.js",
|
|
21
6
|
"scripts": {
|
|
22
|
-
"
|
|
23
|
-
"
|
|
24
|
-
"
|
|
25
|
-
"
|
|
26
|
-
"postbuild-js": "rm -f dist/versionInfo.d.ts dist/versionInfo.d.ts.map",
|
|
27
|
-
"build-dist": "webpack --progress",
|
|
28
|
-
"lint": "eslint",
|
|
29
|
-
"typecheck": "tsc --noEmit",
|
|
30
|
-
"typecheck-test": "tsc --noEmit -p tsconfig.test.json",
|
|
31
|
-
"test": "jest --no-coverage",
|
|
32
|
-
"test-coverage": "jest --coverage",
|
|
7
|
+
"build": "npm run clean && tsc",
|
|
8
|
+
"clean": "rm -rf lib",
|
|
9
|
+
"lint": "eslint ./src",
|
|
10
|
+
"test": "jest",
|
|
33
11
|
"test-debug": "node --inspect-brk ./node_modules/.bin/jest -i --env jest-environment-node-debug",
|
|
34
|
-
"
|
|
35
|
-
"
|
|
36
|
-
"
|
|
37
|
-
"watch": "
|
|
12
|
+
"preversion": "npm test",
|
|
13
|
+
"postversion": "git push --follow-tags",
|
|
14
|
+
"ignore:prepublishOnly": "npm run build && npm run test",
|
|
15
|
+
"watch": "tsc --watch"
|
|
38
16
|
},
|
|
39
17
|
"repository": {
|
|
40
18
|
"type": "git",
|
|
@@ -47,32 +25,26 @@
|
|
|
47
25
|
},
|
|
48
26
|
"homepage": "https://github.com/solidos/solid-logic#readme",
|
|
49
27
|
"devDependencies": {
|
|
50
|
-
"@babel/
|
|
51
|
-
"@babel/
|
|
28
|
+
"@babel/plugin-transform-async-to-generator": "^7.27.1",
|
|
29
|
+
"@babel/plugin-transform-class-properties": "^7.27.1",
|
|
30
|
+
"@babel/plugin-transform-optional-chaining": "^7.27.1",
|
|
31
|
+
"@babel/plugin-transform-runtime": "^7.28.0",
|
|
32
|
+
"@babel/preset-env": "^7.28.0",
|
|
52
33
|
"@babel/preset-typescript": "^7.27.1",
|
|
53
34
|
"@types/jest": "^30.0.0",
|
|
54
|
-
"@typescript-eslint/eslint-plugin": "^8.
|
|
35
|
+
"@typescript-eslint/eslint-plugin": "^8.34.0",
|
|
55
36
|
"@typescript-eslint/parser": "^8.34.0",
|
|
56
|
-
"
|
|
57
|
-
"babel-loader": "^10.0.0",
|
|
58
|
-
"eslint": "^9.38.0",
|
|
59
|
-
"eslint-config-prettier": "^10.1.8",
|
|
60
|
-
"eslint-plugin-import": "^2.32.0",
|
|
37
|
+
"eslint": "^9.28.0",
|
|
61
38
|
"jest": "^30.0.2",
|
|
62
39
|
"jest-environment-jsdom": "^30.0.2",
|
|
40
|
+
"jest-environment-node-debug": "^2.0.0",
|
|
63
41
|
"jest-fetch-mock": "^3.0.3",
|
|
64
|
-
"
|
|
65
|
-
"ts-loader": "^9.5.4",
|
|
66
|
-
"tslib": "^2.8.1",
|
|
67
|
-
"typescript": "^5.9.2",
|
|
68
|
-
"webpack": "^5.101.3",
|
|
69
|
-
"webpack-cli": "^6.0.1"
|
|
42
|
+
"typescript": "^5.7.3"
|
|
70
43
|
},
|
|
71
44
|
"dependencies": {
|
|
72
45
|
"@inrupt/solid-client-authn-browser": "^3.1.0",
|
|
46
|
+
"lint-staged": "^16.1.5",
|
|
47
|
+
"rdflib": "^2.2.37",
|
|
73
48
|
"solid-namespace": "^0.5.4"
|
|
74
|
-
},
|
|
75
|
-
"peerDependencies": {
|
|
76
|
-
"rdflib": "^2.2.37"
|
|
77
49
|
}
|
|
78
50
|
}
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import { graph, NamedNode, Namespace, serialize, sym } from "rdflib"
|
|
2
|
+
import { AclLogic } from "../types";
|
|
3
|
+
import { ns as namespace } from '../util/ns'
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
export const ACL_LINK = sym(
|
|
7
|
+
"http://www.iana.org/assignments/link-relations/acl"
|
|
8
|
+
);
|
|
9
|
+
|
|
10
|
+
export function createAclLogic(store): AclLogic {
|
|
11
|
+
|
|
12
|
+
const ns = namespace
|
|
13
|
+
|
|
14
|
+
async function findAclDocUrl(url: NamedNode) {
|
|
15
|
+
await store.fetcher.load(url);
|
|
16
|
+
const docNode = store.any(url, ACL_LINK);
|
|
17
|
+
if (!docNode) {
|
|
18
|
+
throw new Error(`No ACL link discovered for ${url}`);
|
|
19
|
+
}
|
|
20
|
+
return docNode.value;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Simple Access Control
|
|
24
|
+
*
|
|
25
|
+
* This function sets up a simple default ACL for a resource, with
|
|
26
|
+
* RWC for the owner, and a specified access (default none) for the public.
|
|
27
|
+
* In all cases owner has read write control.
|
|
28
|
+
* Parameter lists modes allowed to public
|
|
29
|
+
*
|
|
30
|
+
* @param options
|
|
31
|
+
* @param options.public eg ['Read', 'Write']
|
|
32
|
+
*
|
|
33
|
+
* @returns Resolves with aclDoc uri on successful write
|
|
34
|
+
*/
|
|
35
|
+
function setACLUserPublic (
|
|
36
|
+
docURI: string,
|
|
37
|
+
me: NamedNode,
|
|
38
|
+
options: {
|
|
39
|
+
defaultForNew?: boolean,
|
|
40
|
+
public?: []
|
|
41
|
+
}
|
|
42
|
+
): Promise<NamedNode> {
|
|
43
|
+
const aclDoc = store.any(
|
|
44
|
+
store.sym(docURI),
|
|
45
|
+
ACL_LINK
|
|
46
|
+
)
|
|
47
|
+
|
|
48
|
+
return Promise.resolve()
|
|
49
|
+
.then(() => {
|
|
50
|
+
if (aclDoc) {
|
|
51
|
+
return aclDoc as NamedNode
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return fetchACLRel(docURI).catch(err => {
|
|
55
|
+
throw new Error(`Error fetching rel=ACL header for ${docURI}: ${err}`)
|
|
56
|
+
})
|
|
57
|
+
})
|
|
58
|
+
.then(aclDoc => {
|
|
59
|
+
const aclText = genACLText(docURI, me, aclDoc.uri, options)
|
|
60
|
+
if (!store.fetcher) {
|
|
61
|
+
throw new Error('Cannot PUT this, store has no fetcher')
|
|
62
|
+
}
|
|
63
|
+
return store.fetcher
|
|
64
|
+
.webOperation('PUT', aclDoc.uri, {
|
|
65
|
+
data: aclText,
|
|
66
|
+
contentType: 'text/turtle'
|
|
67
|
+
})
|
|
68
|
+
.then(result => {
|
|
69
|
+
if (!result.ok) {
|
|
70
|
+
throw new Error('Error writing ACL text: ' + result.error)
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
return aclDoc
|
|
74
|
+
})
|
|
75
|
+
})
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* @param docURI
|
|
80
|
+
* @returns
|
|
81
|
+
*/
|
|
82
|
+
function fetchACLRel (docURI: string): Promise<NamedNode> {
|
|
83
|
+
const fetcher = store.fetcher
|
|
84
|
+
if (!fetcher) {
|
|
85
|
+
throw new Error('Cannot fetch ACL rel, store has no fetcher')
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
return fetcher.load(docURI).then(result => {
|
|
89
|
+
if (!result.ok) {
|
|
90
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
91
|
+
throw new Error('fetchACLRel: While loading:' + (result as any).error)
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
const aclDoc = store.any(
|
|
95
|
+
store.sym(docURI),
|
|
96
|
+
ACL_LINK
|
|
97
|
+
)
|
|
98
|
+
|
|
99
|
+
if (!aclDoc) {
|
|
100
|
+
throw new Error('fetchACLRel: No Link rel=ACL header for ' + docURI)
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
return aclDoc as NamedNode
|
|
104
|
+
})
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* @param docURI
|
|
109
|
+
* @param me
|
|
110
|
+
* @param aclURI
|
|
111
|
+
* @param options
|
|
112
|
+
*
|
|
113
|
+
* @returns Serialized ACL
|
|
114
|
+
*/
|
|
115
|
+
function genACLText (
|
|
116
|
+
docURI: string,
|
|
117
|
+
me: NamedNode,
|
|
118
|
+
aclURI: string,
|
|
119
|
+
options: {
|
|
120
|
+
defaultForNew?: boolean,
|
|
121
|
+
public?: []
|
|
122
|
+
} = {}
|
|
123
|
+
): string | undefined {
|
|
124
|
+
const optPublic = options.public || []
|
|
125
|
+
const g = graph()
|
|
126
|
+
const auth = Namespace('http://www.w3.org/ns/auth/acl#')
|
|
127
|
+
let a = g.sym(`${aclURI}#a1`)
|
|
128
|
+
const acl = g.sym(aclURI)
|
|
129
|
+
const doc = g.sym(docURI)
|
|
130
|
+
g.add(a, ns.rdf('type'), auth('Authorization'), acl)
|
|
131
|
+
g.add(a, auth('accessTo'), doc, acl)
|
|
132
|
+
if (options.defaultForNew) {
|
|
133
|
+
g.add(a, auth('default'), doc, acl)
|
|
134
|
+
}
|
|
135
|
+
g.add(a, auth('agent'), me, acl)
|
|
136
|
+
g.add(a, auth('mode'), auth('Read'), acl)
|
|
137
|
+
g.add(a, auth('mode'), auth('Write'), acl)
|
|
138
|
+
g.add(a, auth('mode'), auth('Control'), acl)
|
|
139
|
+
|
|
140
|
+
if (optPublic.length) {
|
|
141
|
+
a = g.sym(`${aclURI}#a2`)
|
|
142
|
+
g.add(a, ns.rdf('type'), auth('Authorization'), acl)
|
|
143
|
+
g.add(a, auth('accessTo'), doc, acl)
|
|
144
|
+
g.add(a, auth('agentClass'), ns.foaf('Agent'), acl)
|
|
145
|
+
for (let p = 0; p < optPublic.length; p++) {
|
|
146
|
+
g.add(a, auth('mode'), auth(optPublic[p]), acl) // Like 'Read' etc
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
return serialize(acl, g, aclURI)
|
|
150
|
+
}
|
|
151
|
+
return {
|
|
152
|
+
findAclDocUrl,
|
|
153
|
+
setACLUserPublic,
|
|
154
|
+
genACLText
|
|
155
|
+
}
|
|
156
|
+
}
|