solid-logic 1.3.17 → 2.0.0-30dbc72f
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/.babelrc +0 -0
- package/.eslintrc.js +0 -0
- package/.github/workflows/ci.yml +0 -0
- package/.github/workflows/release.yml +0 -0
- package/.nvmrc +0 -0
- package/LICENSE +0 -0
- package/README.md +0 -0
- package/jest.config.js +0 -0
- package/lib/acl/aclLogic.d.ts +3 -30
- package/lib/acl/aclLogic.d.ts.map +1 -1
- package/lib/acl/aclLogic.js +152 -119
- package/lib/acl/aclLogic.js.map +1 -1
- package/lib/authSession/authSession.d.ts +0 -0
- package/lib/authSession/authSession.d.ts.map +0 -0
- package/lib/authSession/authSession.js +0 -0
- package/lib/authSession/authSession.js.map +0 -0
- package/lib/authn/SolidAuthnLogic.d.ts +0 -0
- package/lib/authn/SolidAuthnLogic.d.ts.map +1 -1
- package/lib/authn/SolidAuthnLogic.js +3 -3
- package/lib/authn/SolidAuthnLogic.js.map +1 -1
- package/lib/authn/authUtil.d.ts +0 -0
- package/lib/authn/authUtil.d.ts.map +0 -0
- package/lib/authn/authUtil.js +0 -0
- package/lib/authn/authUtil.js.map +0 -0
- package/lib/chat/chatLogic.d.ts +3 -0
- package/lib/chat/chatLogic.d.ts.map +1 -0
- package/lib/chat/{ChatLogic.js → chatLogic.js} +82 -86
- package/lib/chat/chatLogic.js.map +1 -0
- package/lib/inbox/inboxLogic.d.ts +3 -0
- package/lib/inbox/inboxLogic.d.ts.map +1 -0
- package/lib/inbox/{InboxLogic.js → inboxLogic.js} +58 -64
- package/lib/inbox/inboxLogic.js.map +1 -0
- package/lib/index.d.ts +6 -11
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +5 -25
- package/lib/index.js.map +1 -1
- package/lib/issuer/issuerLogic.d.ts +0 -0
- package/lib/issuer/issuerLogic.d.ts.map +0 -0
- package/lib/issuer/issuerLogic.js +1 -1
- package/lib/issuer/issuerLogic.js.map +1 -1
- package/lib/logic/CustomError.d.ts +4 -0
- package/lib/logic/CustomError.d.ts.map +1 -1
- package/lib/logic/CustomError.js +17 -1
- package/lib/logic/CustomError.js.map +1 -1
- package/lib/logic/solidLogic.d.ts +6 -0
- package/lib/logic/solidLogic.d.ts.map +1 -0
- package/lib/logic/solidLogic.js +92 -0
- package/lib/logic/solidLogic.js.map +1 -0
- package/lib/logic/solidLogicSingleton.d.ts +1 -2
- package/lib/logic/solidLogicSingleton.d.ts.map +1 -1
- package/lib/logic/solidLogicSingleton.js +3 -3
- package/lib/logic/solidLogicSingleton.js.map +1 -1
- package/lib/profile/profileLogic.d.ts +3 -0
- package/lib/profile/profileLogic.d.ts.map +1 -0
- package/lib/profile/profileLogic.js +246 -0
- package/lib/profile/profileLogic.js.map +1 -0
- package/lib/typeIndex/typeIndexLogic.d.ts +2 -21
- package/lib/typeIndex/typeIndexLogic.d.ts.map +1 -1
- package/lib/typeIndex/typeIndexLogic.js +304 -296
- package/lib/typeIndex/typeIndexLogic.js.map +1 -1
- package/lib/types.d.ts +82 -1
- package/lib/types.d.ts.map +1 -1
- package/lib/types.js +0 -0
- package/lib/types.js.map +0 -0
- package/lib/util/containerLogic.d.ts +11 -0
- package/lib/util/containerLogic.d.ts.map +1 -0
- package/lib/{profile/ProfileLogic.js → util/containerLogic.js} +53 -44
- package/lib/util/containerLogic.js.map +1 -0
- package/lib/util/debug.d.ts +0 -0
- package/lib/util/debug.d.ts.map +0 -0
- package/lib/util/debug.js +0 -0
- package/lib/util/debug.js.map +0 -0
- package/lib/util/ns.d.ts +2 -0
- package/lib/util/ns.d.ts.map +1 -0
- package/lib/util/ns.js +34 -0
- package/lib/util/ns.js.map +1 -0
- package/lib/util/utilityLogic.d.ts +15 -0
- package/lib/util/utilityLogic.d.ts.map +1 -0
- package/lib/util/utilityLogic.js +272 -0
- package/lib/util/utilityLogic.js.map +1 -0
- package/lib/util/utils.d.ts +8 -0
- package/lib/util/utils.d.ts.map +1 -0
- package/lib/util/utils.js +48 -0
- package/lib/util/utils.js.map +1 -0
- package/package.json +17 -15
- package/src/acl/aclLogic.ts +137 -118
- package/src/authSession/authSession.ts +0 -0
- package/src/authn/SolidAuthnLogic.ts +8 -7
- package/src/authn/authUtil.ts +0 -0
- package/src/chat/chatLogic.ts +225 -0
- package/src/inbox/inboxLogic.ts +58 -0
- package/src/index.ts +11 -29
- package/src/issuer/issuerLogic.ts +1 -1
- package/src/logic/CustomError.ts +5 -1
- package/src/logic/solidLogic.ts +75 -0
- package/src/logic/solidLogicSingleton.ts +3 -3
- package/src/profile/profileLogic.ts +126 -0
- package/src/typeIndex/typeIndexLogic.ts +175 -182
- package/src/types.ts +83 -4
- package/src/util/containerLogic.ts +54 -0
- package/src/util/debug.ts +0 -0
- package/src/util/ns.ts +5 -0
- package/src/util/utilityLogic.ts +155 -0
- package/src/util/utils.ts +52 -0
- package/test/aclLogic.test.ts +13 -4
- package/test/authUtil.test.ts +0 -0
- package/test/chatLogic.test.ts +70 -71
- package/test/container.test.ts +56 -0
- package/test/helpers/dataSetup.ts +134 -0
- package/test/helpers/setup.ts +4 -0
- package/test/inboxLogic.test.ts +39 -38
- package/test/logic.test.ts +10 -9
- package/test/profileLogic.test.ts +246 -0
- package/test/solidAuthLogic.test.ts +0 -0
- package/test/typeIndexLogic.test.ts +488 -30
- package/test/utilityLogic.test.ts +172 -126
- package/test/utils.test.ts +32 -0
- package/tsconfig.json +0 -0
- package/lib/chat/ChatLogic.d.ts +0 -26
- package/lib/chat/ChatLogic.d.ts.map +0 -1
- package/lib/chat/ChatLogic.js.map +0 -1
- package/lib/chat/determineChatContainer.d.ts +0 -3
- package/lib/chat/determineChatContainer.d.ts.map +0 -1
- package/lib/chat/determineChatContainer.js +0 -12
- package/lib/chat/determineChatContainer.js.map +0 -1
- package/lib/discovery/discoveryLogic.d.ts +0 -13
- package/lib/discovery/discoveryLogic.d.ts.map +0 -1
- package/lib/discovery/discoveryLogic.js +0 -203
- package/lib/discovery/discoveryLogic.js.map +0 -1
- package/lib/inbox/InboxLogic.d.ts +0 -18
- package/lib/inbox/InboxLogic.d.ts.map +0 -1
- package/lib/inbox/InboxLogic.js.map +0 -1
- package/lib/logic/SolidLogic.d.ts +0 -48
- package/lib/logic/SolidLogic.d.ts.map +0 -1
- package/lib/logic/SolidLogic.js +0 -321
- package/lib/logic/SolidLogic.js.map +0 -1
- package/lib/profile/ProfileLogic.d.ts +0 -13
- package/lib/profile/ProfileLogic.d.ts.map +0 -1
- package/lib/profile/ProfileLogic.js.map +0 -1
- package/lib/util/UtilityLogic.d.ts +0 -33
- package/lib/util/UtilityLogic.d.ts.map +0 -1
- package/lib/util/UtilityLogic.js +0 -240
- package/lib/util/UtilityLogic.js.map +0 -1
- package/lib/util/uri.d.ts +0 -3
- package/lib/util/uri.d.ts.map +0 -1
- package/lib/util/uri.js +0 -9
- package/lib/util/uri.js.map +0 -1
- package/src/chat/ChatLogic.ts +0 -244
- package/src/chat/determineChatContainer.ts +0 -14
- package/src/discovery/discoveryLogic.ts +0 -90
- package/src/inbox/InboxLogic.ts +0 -66
- package/src/logic/SolidLogic.ts +0 -262
- package/src/profile/ProfileLogic.ts +0 -44
- package/src/util/UtilityLogic.ts +0 -161
- package/src/util/uri.ts +0 -5
package/lib/util/UtilityLogic.js
DELETED
|
@@ -1,240 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
-
function step(op) {
|
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (_) try {
|
|
18
|
-
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;
|
|
19
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
-
switch (op[0]) {
|
|
21
|
-
case 0: case 1: t = op; break;
|
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
-
default:
|
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
-
if (t[2]) _.ops.pop();
|
|
31
|
-
_.trys.pop(); continue;
|
|
32
|
-
}
|
|
33
|
-
op = body.call(thisArg, _);
|
|
34
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.UtilityLogic = exports.ACL_LINK = void 0;
|
|
40
|
-
var rdflib_1 = require("rdflib");
|
|
41
|
-
exports.ACL_LINK = (0, rdflib_1.sym)("http://www.iana.org/assignments/link-relations/acl");
|
|
42
|
-
/**
|
|
43
|
-
* Utility-related logic
|
|
44
|
-
*/
|
|
45
|
-
var UtilityLogic = /** @class */ (function () {
|
|
46
|
-
function UtilityLogic(store, ns, underlyingFetch) {
|
|
47
|
-
this.store = store;
|
|
48
|
-
this.ns = ns;
|
|
49
|
-
this.underlyingFetch = underlyingFetch;
|
|
50
|
-
}
|
|
51
|
-
UtilityLogic.prototype.findAclDocUrl = function (url) {
|
|
52
|
-
var _a;
|
|
53
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
54
|
-
var doc, docNode;
|
|
55
|
-
return __generator(this, function (_b) {
|
|
56
|
-
switch (_b.label) {
|
|
57
|
-
case 0:
|
|
58
|
-
doc = this.store.sym(url);
|
|
59
|
-
return [4 /*yield*/, ((_a = this.store.fetcher) === null || _a === void 0 ? void 0 : _a.load(doc))];
|
|
60
|
-
case 1:
|
|
61
|
-
_b.sent();
|
|
62
|
-
docNode = this.store.any(doc, exports.ACL_LINK);
|
|
63
|
-
if (!docNode) {
|
|
64
|
-
throw new Error("No ACL link discovered for ".concat(url));
|
|
65
|
-
}
|
|
66
|
-
return [2 /*return*/, docNode.value];
|
|
67
|
-
}
|
|
68
|
-
});
|
|
69
|
-
});
|
|
70
|
-
};
|
|
71
|
-
// Copied from https://github.com/solidos/web-access-control-tests/blob/v3.0.0/test/surface/delete.test.ts#L5
|
|
72
|
-
UtilityLogic.prototype.setSinglePeerAccess = function (options) {
|
|
73
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
74
|
-
var str, aclDocUrl;
|
|
75
|
-
return __generator(this, function (_a) {
|
|
76
|
-
switch (_a.label) {
|
|
77
|
-
case 0:
|
|
78
|
-
str = [
|
|
79
|
-
'@prefix acl: <http://www.w3.org/ns/auth/acl#>.',
|
|
80
|
-
'',
|
|
81
|
-
"<#alice> a acl:Authorization;\n acl:agent <".concat(options.ownerWebId, ">;"),
|
|
82
|
-
" acl:accessTo <".concat(options.target, ">;"),
|
|
83
|
-
" acl:default <".concat(options.target, ">;"),
|
|
84
|
-
' acl:mode acl:Read, acl:Write, acl:Control.',
|
|
85
|
-
''
|
|
86
|
-
].join('\n');
|
|
87
|
-
if (options.accessToModes) {
|
|
88
|
-
str += [
|
|
89
|
-
'<#bobAccessTo> a acl:Authorization;',
|
|
90
|
-
" acl:agent <".concat(options.peerWebId, ">;"),
|
|
91
|
-
" acl:accessTo <".concat(options.target, ">;"),
|
|
92
|
-
" acl:mode ".concat(options.accessToModes, "."),
|
|
93
|
-
''
|
|
94
|
-
].join('\n');
|
|
95
|
-
}
|
|
96
|
-
if (options.defaultModes) {
|
|
97
|
-
str += [
|
|
98
|
-
'<#bobDefault> a acl:Authorization;',
|
|
99
|
-
" acl:agent <".concat(options.peerWebId, ">;"),
|
|
100
|
-
" acl:default <".concat(options.target, ">;"),
|
|
101
|
-
" acl:mode ".concat(options.defaultModes, "."),
|
|
102
|
-
''
|
|
103
|
-
].join('\n');
|
|
104
|
-
}
|
|
105
|
-
return [4 /*yield*/, this.findAclDocUrl(options.target)];
|
|
106
|
-
case 1:
|
|
107
|
-
aclDocUrl = _a.sent();
|
|
108
|
-
return [2 /*return*/, this.underlyingFetch.fetch(aclDocUrl, {
|
|
109
|
-
method: 'PUT',
|
|
110
|
-
body: str,
|
|
111
|
-
headers: [
|
|
112
|
-
['Content-Type', 'text/turtle']
|
|
113
|
-
]
|
|
114
|
-
})];
|
|
115
|
-
}
|
|
116
|
-
});
|
|
117
|
-
});
|
|
118
|
-
};
|
|
119
|
-
UtilityLogic.prototype.loadDoc = function (doc) {
|
|
120
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
121
|
-
return __generator(this, function (_a) {
|
|
122
|
-
switch (_a.label) {
|
|
123
|
-
case 0:
|
|
124
|
-
// Load a document into the knowledge base (fetcher.store)
|
|
125
|
-
// withCredentials: Web arch should let us just load by turning off creds helps CORS
|
|
126
|
-
// reload: Gets around a specific old Chrome bug caching/origin/cors
|
|
127
|
-
// console.log('loading', profileDocument)
|
|
128
|
-
if (!this.store.fetcher) {
|
|
129
|
-
throw new Error("Cannot load doc, have no fetcher");
|
|
130
|
-
}
|
|
131
|
-
return [4 /*yield*/, this.store.fetcher.load(doc, {
|
|
132
|
-
withCredentials: false,
|
|
133
|
-
cache: "reload",
|
|
134
|
-
})];
|
|
135
|
-
case 1:
|
|
136
|
-
_a.sent();
|
|
137
|
-
return [2 /*return*/];
|
|
138
|
-
}
|
|
139
|
-
});
|
|
140
|
-
});
|
|
141
|
-
};
|
|
142
|
-
UtilityLogic.prototype.isContainer = function (url) {
|
|
143
|
-
return url.substr(-1) === "/";
|
|
144
|
-
};
|
|
145
|
-
UtilityLogic.prototype.createContainer = function (url) {
|
|
146
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
147
|
-
var result;
|
|
148
|
-
return __generator(this, function (_a) {
|
|
149
|
-
switch (_a.label) {
|
|
150
|
-
case 0:
|
|
151
|
-
if (!this.isContainer(url)) {
|
|
152
|
-
throw new Error("Not a container URL ".concat(url));
|
|
153
|
-
}
|
|
154
|
-
return [4 /*yield*/, this.underlyingFetch.fetch(url, {
|
|
155
|
-
method: "PUT",
|
|
156
|
-
headers: {
|
|
157
|
-
"Content-Type": "text/turtle",
|
|
158
|
-
"If-None-Match": "*",
|
|
159
|
-
Link: '<http://www.w3.org/ns/ldp#BasicContainer>; rel="type"', // See https://github.com/solidos/node-solid-server/issues/1465
|
|
160
|
-
},
|
|
161
|
-
body: " ", // work around https://github.com/michielbdejong/community-server/issues/4#issuecomment-776222863
|
|
162
|
-
})];
|
|
163
|
-
case 1:
|
|
164
|
-
result = _a.sent();
|
|
165
|
-
if (result.status.toString()[0] !== '2') {
|
|
166
|
-
throw new Error("Not OK: got ".concat(result.status, " response while creating container at ").concat(url));
|
|
167
|
-
}
|
|
168
|
-
return [2 /*return*/];
|
|
169
|
-
}
|
|
170
|
-
});
|
|
171
|
-
});
|
|
172
|
-
};
|
|
173
|
-
UtilityLogic.prototype.getContainerElements = function (containerNode) {
|
|
174
|
-
return this.store
|
|
175
|
-
.statementsMatching(containerNode, this.store.sym("http://www.w3.org/ns/ldp#contains"), undefined, containerNode.doc())
|
|
176
|
-
.map(function (st) { return st.object; });
|
|
177
|
-
};
|
|
178
|
-
UtilityLogic.prototype.getContainerMembers = function (containerUrl) {
|
|
179
|
-
var _a;
|
|
180
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
181
|
-
var containerNode, nodes;
|
|
182
|
-
return __generator(this, function (_b) {
|
|
183
|
-
switch (_b.label) {
|
|
184
|
-
case 0:
|
|
185
|
-
containerNode = this.store.sym(containerUrl);
|
|
186
|
-
return [4 /*yield*/, ((_a = this.store.fetcher) === null || _a === void 0 ? void 0 : _a.load(containerNode))];
|
|
187
|
-
case 1:
|
|
188
|
-
_b.sent();
|
|
189
|
-
nodes = this.getContainerElements(containerNode);
|
|
190
|
-
return [2 /*return*/, nodes.map(function (node) { return node.value; })];
|
|
191
|
-
}
|
|
192
|
-
});
|
|
193
|
-
});
|
|
194
|
-
};
|
|
195
|
-
UtilityLogic.prototype.recursiveDelete = function (url) {
|
|
196
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
197
|
-
var aclDocUrl, containerMembers, e_1;
|
|
198
|
-
var _this = this;
|
|
199
|
-
return __generator(this, function (_a) {
|
|
200
|
-
switch (_a.label) {
|
|
201
|
-
case 0:
|
|
202
|
-
_a.trys.push([0, 6, , 7]);
|
|
203
|
-
if (!this.isContainer(url)) return [3 /*break*/, 5];
|
|
204
|
-
return [4 /*yield*/, this.findAclDocUrl(url)];
|
|
205
|
-
case 1:
|
|
206
|
-
aclDocUrl = _a.sent();
|
|
207
|
-
return [4 /*yield*/, this.underlyingFetch.fetch(aclDocUrl, { method: "DELETE" })];
|
|
208
|
-
case 2:
|
|
209
|
-
_a.sent();
|
|
210
|
-
return [4 /*yield*/, this.getContainerMembers(url)];
|
|
211
|
-
case 3:
|
|
212
|
-
containerMembers = _a.sent();
|
|
213
|
-
return [4 /*yield*/, Promise.all(containerMembers.map(function (url) { return _this.recursiveDelete(url); }))];
|
|
214
|
-
case 4:
|
|
215
|
-
_a.sent();
|
|
216
|
-
_a.label = 5;
|
|
217
|
-
case 5: return [2 /*return*/, this.underlyingFetch.fetch(url, { method: "DELETE" })];
|
|
218
|
-
case 6:
|
|
219
|
-
e_1 = _a.sent();
|
|
220
|
-
return [3 /*break*/, 7];
|
|
221
|
-
case 7: return [2 /*return*/];
|
|
222
|
-
}
|
|
223
|
-
});
|
|
224
|
-
});
|
|
225
|
-
};
|
|
226
|
-
UtilityLogic.prototype.clearStore = function () {
|
|
227
|
-
this.store.statements.slice().forEach(this.store.remove.bind(this.store));
|
|
228
|
-
};
|
|
229
|
-
UtilityLogic.prototype.getArchiveUrl = function (baseUrl, date) {
|
|
230
|
-
var year = date.getUTCFullYear();
|
|
231
|
-
var month = ('0' + (date.getUTCMonth() + 1)).slice(-2);
|
|
232
|
-
var day = ('0' + (date.getUTCDate())).slice(-2);
|
|
233
|
-
var parts = baseUrl.split('/');
|
|
234
|
-
var filename = parts[parts.length - 1];
|
|
235
|
-
return new URL("./archive/".concat(year, "/").concat(month, "/").concat(day, "/").concat(filename), baseUrl).toString();
|
|
236
|
-
};
|
|
237
|
-
return UtilityLogic;
|
|
238
|
-
}());
|
|
239
|
-
exports.UtilityLogic = UtilityLogic;
|
|
240
|
-
//# sourceMappingURL=UtilityLogic.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"UtilityLogic.js","sourceRoot":"","sources":["../../src/util/UtilityLogic.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iCAA8D;AAGjD,QAAA,QAAQ,GAAG,I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,CAAC;QAClD,IAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QACjC,IAAM,QAAQ,GAAG,KAAK,CAAC,KAAK,CAAC,MAAM,GAAE,CAAC,CAAE,CAAC;QACzC,OAAO,IAAI,GAAG,CAAC,oBAAa,IAAI,cAAI,KAAK,cAAI,GAAG,cAAI,QAAQ,CAAE,EAAE,OAAO,CAAC,CAAC,QAAQ,EAAE,CAAC;IACtF,CAAC;IACH,mBAAC;AAAD,CAAC,AAtJD,IAsJC;AAtJY,oCAAY"}
|
package/lib/util/uri.d.ts
DELETED
package/lib/util/uri.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"uri.d.ts","sourceRoot":"","sources":["../../src/util/uri.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAO,MAAM,QAAQ,CAAC;AAExC,wBAAgB,QAAQ,CAAC,GAAG,EAAE,SAAS,GAAG,SAAS,CAElD"}
|
package/lib/util/uri.js
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.newThing = void 0;
|
|
4
|
-
var rdflib_1 = require("rdflib");
|
|
5
|
-
function newThing(doc) {
|
|
6
|
-
return (0, rdflib_1.sym)(doc.uri + "#" + "id" + ("" + Date.now()));
|
|
7
|
-
}
|
|
8
|
-
exports.newThing = newThing;
|
|
9
|
-
//# sourceMappingURL=uri.js.map
|
package/lib/util/uri.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"uri.js","sourceRoot":"","sources":["../../src/util/uri.ts"],"names":[],"mappings":";;;AAAA,iCAAwC;AAExC,SAAgB,QAAQ,CAAC,GAAc;IACrC,OAAO,IAAA,YAAG,EAAC,GAAG,CAAC,GAAG,GAAG,GAAG,GAAG,IAAI,GAAG,CAAC,EAAE,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;AACvD,CAAC;AAFD,4BAEC"}
|
package/src/chat/ChatLogic.ts
DELETED
|
@@ -1,244 +0,0 @@
|
|
|
1
|
-
import { NamedNode, Node, st, term, LiveStore } from "rdflib";
|
|
2
|
-
import { ProfileLogic } from "../profile/ProfileLogic";
|
|
3
|
-
import { SolidNamespace } from "../types";
|
|
4
|
-
import { newThing } from "../util/uri";
|
|
5
|
-
import { determineChatContainer } from "./determineChatContainer";
|
|
6
|
-
|
|
7
|
-
const CHAT_LOCATION_IN_CONTAINER = "index.ttl#this";
|
|
8
|
-
|
|
9
|
-
interface NewPaneOptions {
|
|
10
|
-
me?: NamedNode;
|
|
11
|
-
newInstance?: NamedNode;
|
|
12
|
-
newBase: string;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
interface CreatedPaneOptions {
|
|
16
|
-
newInstance: NamedNode;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Chat-related logic
|
|
21
|
-
*/
|
|
22
|
-
export class ChatLogic {
|
|
23
|
-
store: LiveStore;
|
|
24
|
-
ns: SolidNamespace;
|
|
25
|
-
profile: ProfileLogic;
|
|
26
|
-
|
|
27
|
-
constructor(store: LiveStore, ns: SolidNamespace, profile: ProfileLogic) {
|
|
28
|
-
this.store = store;
|
|
29
|
-
this.ns = ns;
|
|
30
|
-
this.profile = profile;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
async setAcl(
|
|
34
|
-
chatContainer: NamedNode,
|
|
35
|
-
me: NamedNode,
|
|
36
|
-
invitee: NamedNode
|
|
37
|
-
): Promise<void> {
|
|
38
|
-
// Some servers don't present a Link http response header
|
|
39
|
-
// if the container doesn't exist yet, so refetch the container
|
|
40
|
-
// now that it has been created:
|
|
41
|
-
await this.store.fetcher?.load(chatContainer);
|
|
42
|
-
|
|
43
|
-
// FIXME: check the Why value on this quad:
|
|
44
|
-
const chatAclDoc = this.store.any(
|
|
45
|
-
chatContainer,
|
|
46
|
-
new NamedNode("http://www.iana.org/assignments/link-relations/acl")
|
|
47
|
-
);
|
|
48
|
-
if (!chatAclDoc) {
|
|
49
|
-
throw new Error("Chat ACL doc not found!");
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
const aclBody = `
|
|
53
|
-
@prefix acl: <http://www.w3.org/ns/auth/acl#>.
|
|
54
|
-
<#owner>
|
|
55
|
-
a acl:Authorization;
|
|
56
|
-
acl:agent <${me.value}>;
|
|
57
|
-
acl:accessTo <.>;
|
|
58
|
-
acl:default <.>;
|
|
59
|
-
acl:mode
|
|
60
|
-
acl:Read, acl:Write, acl:Control.
|
|
61
|
-
<#invitee>
|
|
62
|
-
a acl:Authorization;
|
|
63
|
-
acl:agent <${invitee.value}>;
|
|
64
|
-
acl:accessTo <.>;
|
|
65
|
-
acl:default <.>;
|
|
66
|
-
acl:mode
|
|
67
|
-
acl:Read, acl:Append.
|
|
68
|
-
`;
|
|
69
|
-
await this.store.fetcher?.webOperation("PUT", chatAclDoc.value, {
|
|
70
|
-
data: aclBody,
|
|
71
|
-
contentType: "text/turtle",
|
|
72
|
-
});
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
private async addToPrivateTypeIndex(chatThing, me) {
|
|
76
|
-
// Add to private type index
|
|
77
|
-
const privateTypeIndex = this.store.any(
|
|
78
|
-
me,
|
|
79
|
-
this.ns.solid("privateTypeIndex")
|
|
80
|
-
) as NamedNode | null;
|
|
81
|
-
if (!privateTypeIndex) {
|
|
82
|
-
throw new Error("Private type index not found!");
|
|
83
|
-
}
|
|
84
|
-
await this.store.fetcher?.load(privateTypeIndex);
|
|
85
|
-
const reg = newThing(privateTypeIndex);
|
|
86
|
-
const ins = [
|
|
87
|
-
st(
|
|
88
|
-
reg,
|
|
89
|
-
this.ns.rdf("type"),
|
|
90
|
-
this.ns.solid("TypeRegistration"),
|
|
91
|
-
privateTypeIndex.doc()
|
|
92
|
-
),
|
|
93
|
-
st(
|
|
94
|
-
reg,
|
|
95
|
-
this.ns.solid("forClass"),
|
|
96
|
-
this.ns.meeting("LongChat"),
|
|
97
|
-
privateTypeIndex.doc()
|
|
98
|
-
),
|
|
99
|
-
st(reg, this.ns.solid("instance"), chatThing, privateTypeIndex.doc()),
|
|
100
|
-
];
|
|
101
|
-
await new Promise((resolve, reject) => {
|
|
102
|
-
this.store.updater?.update([], ins, function (_uri, ok, errm) {
|
|
103
|
-
if (!ok) {
|
|
104
|
-
reject(new Error(errm));
|
|
105
|
-
} else {
|
|
106
|
-
resolve(null);
|
|
107
|
-
}
|
|
108
|
-
});
|
|
109
|
-
});
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
private async findChat(invitee: NamedNode) {
|
|
113
|
-
const me = await this.profile.loadMe();
|
|
114
|
-
const podRoot = await this.profile.getPodRoot(me);
|
|
115
|
-
const chatContainer = determineChatContainer(invitee, podRoot);
|
|
116
|
-
let exists = true;
|
|
117
|
-
try {
|
|
118
|
-
await this.store.fetcher?.load(
|
|
119
|
-
new NamedNode(chatContainer.value + "index.ttl#this")
|
|
120
|
-
);
|
|
121
|
-
} catch (e) {
|
|
122
|
-
exists = false;
|
|
123
|
-
}
|
|
124
|
-
return { me, chatContainer, exists };
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
private async createChatThing(
|
|
128
|
-
chatContainer: NamedNode,
|
|
129
|
-
me: NamedNode
|
|
130
|
-
): Promise<NamedNode> {
|
|
131
|
-
const created = await this.mintNew({
|
|
132
|
-
me,
|
|
133
|
-
newBase: chatContainer.value,
|
|
134
|
-
});
|
|
135
|
-
return created.newInstance;
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
private mintNew(newPaneOptions: NewPaneOptions): Promise<CreatedPaneOptions> {
|
|
139
|
-
const kb = this.store;
|
|
140
|
-
const updater = kb.updater;
|
|
141
|
-
if (newPaneOptions.me && !newPaneOptions.me.uri) {
|
|
142
|
-
throw new Error("chat mintNew: Invalid userid " + newPaneOptions.me);
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
const newInstance = (newPaneOptions.newInstance =
|
|
146
|
-
newPaneOptions.newInstance ||
|
|
147
|
-
kb.sym(newPaneOptions.newBase + CHAT_LOCATION_IN_CONTAINER));
|
|
148
|
-
const newChatDoc = newInstance.doc();
|
|
149
|
-
|
|
150
|
-
kb.add(
|
|
151
|
-
newInstance,
|
|
152
|
-
this.ns.rdf("type"),
|
|
153
|
-
this.ns.meeting("LongChat"),
|
|
154
|
-
newChatDoc
|
|
155
|
-
);
|
|
156
|
-
kb.add(newInstance, this.ns.dc("title"), "Chat channel", newChatDoc);
|
|
157
|
-
kb.add(
|
|
158
|
-
newInstance,
|
|
159
|
-
this.ns.dc("created"),
|
|
160
|
-
term<Node>(new Date(Date.now())),
|
|
161
|
-
newChatDoc
|
|
162
|
-
);
|
|
163
|
-
if (newPaneOptions.me) {
|
|
164
|
-
kb.add(newInstance, this.ns.dc("author"), newPaneOptions.me, newChatDoc);
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
return new Promise(function (resolve, reject) {
|
|
168
|
-
updater?.put(
|
|
169
|
-
newChatDoc,
|
|
170
|
-
kb.statementsMatching(undefined, undefined, undefined, newChatDoc),
|
|
171
|
-
"text/turtle",
|
|
172
|
-
function (uri2, ok, message) {
|
|
173
|
-
if (ok) {
|
|
174
|
-
resolve({
|
|
175
|
-
...newPaneOptions,
|
|
176
|
-
newInstance,
|
|
177
|
-
});
|
|
178
|
-
} else {
|
|
179
|
-
reject(
|
|
180
|
-
new Error(
|
|
181
|
-
"FAILED to save new chat channel at: " + uri2 + " : " + message
|
|
182
|
-
)
|
|
183
|
-
);
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
);
|
|
187
|
-
});
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
/**
|
|
191
|
-
* Find (and optionally create) an individual chat between the current user and the given invitee
|
|
192
|
-
* @param invitee - The person to chat with
|
|
193
|
-
* @param createIfMissing - Whether the chat should be created, if missing
|
|
194
|
-
* @returns null if missing, or a node referring to an already existing chat, or the newly created chat
|
|
195
|
-
*/
|
|
196
|
-
async getChat(
|
|
197
|
-
invitee: NamedNode,
|
|
198
|
-
createIfMissing = true
|
|
199
|
-
): Promise<NamedNode | null> {
|
|
200
|
-
const { me, chatContainer, exists } = await this.findChat(invitee);
|
|
201
|
-
if (exists) {
|
|
202
|
-
return new NamedNode(chatContainer.value + CHAT_LOCATION_IN_CONTAINER);
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
if (createIfMissing) {
|
|
206
|
-
const chatThing = await this.createChatThing(chatContainer, me);
|
|
207
|
-
await this.sendInvite(invitee, chatThing);
|
|
208
|
-
await this.setAcl(chatContainer, me, invitee);
|
|
209
|
-
await this.addToPrivateTypeIndex(chatThing, me);
|
|
210
|
-
return chatThing;
|
|
211
|
-
}
|
|
212
|
-
return null;
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
private async sendInvite(invitee: NamedNode, chatThing: NamedNode) {
|
|
216
|
-
await this.store.fetcher?.load(invitee.doc());
|
|
217
|
-
const inviteeInbox = this.store.any(
|
|
218
|
-
invitee,
|
|
219
|
-
this.ns.ldp("inbox"),
|
|
220
|
-
undefined,
|
|
221
|
-
invitee.doc()
|
|
222
|
-
);
|
|
223
|
-
if (!inviteeInbox) {
|
|
224
|
-
throw new Error(`Invitee inbox not found! ${invitee.value}`);
|
|
225
|
-
}
|
|
226
|
-
const inviteBody = `
|
|
227
|
-
<> a <http://www.w3.org/ns/pim/meeting#LongChatInvite> ;
|
|
228
|
-
${this.ns.rdf("seeAlso")} <${chatThing.value}> .
|
|
229
|
-
`;
|
|
230
|
-
|
|
231
|
-
const inviteResponse = await this.store.fetcher?.webOperation(
|
|
232
|
-
"POST",
|
|
233
|
-
inviteeInbox.value,
|
|
234
|
-
{
|
|
235
|
-
data: inviteBody,
|
|
236
|
-
contentType: "text/turtle",
|
|
237
|
-
}
|
|
238
|
-
);
|
|
239
|
-
const locationStr = inviteResponse?.headers.get("location");
|
|
240
|
-
if (!locationStr) {
|
|
241
|
-
throw new Error(`Invite sending returned a ${inviteResponse?.status}`);
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { NamedNode } from "rdflib";
|
|
2
|
-
|
|
3
|
-
export function determineChatContainer(
|
|
4
|
-
invitee: NamedNode,
|
|
5
|
-
podRoot: NamedNode
|
|
6
|
-
): NamedNode {
|
|
7
|
-
// Create chat
|
|
8
|
-
// See https://gitter.im/solid/chat-app?at=5f3c800f855be416a23ae74a
|
|
9
|
-
const chatContainerStr = new URL(
|
|
10
|
-
`IndividualChats/${new URL(invitee.value).host}/`,
|
|
11
|
-
podRoot.value
|
|
12
|
-
).toString();
|
|
13
|
-
return new NamedNode(chatContainerStr);
|
|
14
|
-
}
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
import { NamedNode, Namespace, LiveStore } from "rdflib";
|
|
2
|
-
|
|
3
|
-
type TypeIndex = { label: string, index: NamedNode, agent: NamedNode } ;
|
|
4
|
-
|
|
5
|
-
const ns ={
|
|
6
|
-
solid: Namespace('http://www.w3.org/ns/solid/terms#'),
|
|
7
|
-
space: Namespace('http://www.w3.org/ns/pim/space#')
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export async function loadProfile(store: LiveStore, user) {
|
|
11
|
-
if (!user) {
|
|
12
|
-
throw new Error(`loadProfile: no user given.`)
|
|
13
|
-
}
|
|
14
|
-
try {
|
|
15
|
-
await store.fetcher.load(user.doc())
|
|
16
|
-
} catch (err) {
|
|
17
|
-
throw new Error(`Unable to load profile of user <${user}>: ${err}`)
|
|
18
|
-
}
|
|
19
|
-
return user.doc()
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export async function loadPreferences(store: LiveStore, user): Promise <NamedNode | undefined > {
|
|
23
|
-
const profile = await loadProfile(store as LiveStore, user)
|
|
24
|
-
const preferencesFile = store.any(user, ns.space('preferencesFile'), undefined, profile)
|
|
25
|
-
if (!preferencesFile) {
|
|
26
|
-
// throw new Error(`USer ${user} has no pointer in profile to preferences file.`)
|
|
27
|
-
return undefined
|
|
28
|
-
}
|
|
29
|
-
try {
|
|
30
|
-
store.fetcher.load(preferencesFile as NamedNode)
|
|
31
|
-
} catch (err) { // Mabeb a permission propblem or origin problem
|
|
32
|
-
return undefined
|
|
33
|
-
// throw new Error(`Unable to load preferences file ${preferencesFile} of user <${user}>: ${err}`)
|
|
34
|
-
}
|
|
35
|
-
return preferencesFile as NamedNode
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export async function loadTypeIndexesFor(store: LiveStore, user:NamedNode): Promise<Array<TypeIndex>> {
|
|
39
|
-
if (!user) throw new Error(`loadTypeIndexesFor: No user given`)
|
|
40
|
-
const profile = await loadProfile(store, user)
|
|
41
|
-
const publicTypeIndex = store.any(user, ns.solid('publicTypeIndex'), undefined, profile)
|
|
42
|
-
if (publicTypeIndex) {
|
|
43
|
-
try {
|
|
44
|
-
await store.fetcher.load(publicTypeIndex as NamedNode)
|
|
45
|
-
} catch {
|
|
46
|
-
// never mind
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
const pub = publicTypeIndex ? [ { label: 'public', index: publicTypeIndex as NamedNode, agent: user } ] : []
|
|
50
|
-
|
|
51
|
-
const preferencesFile = await loadPreferences(store, user)
|
|
52
|
-
if (preferencesFile) { // watch out - can be in either as spec was not clear
|
|
53
|
-
const privateTypeIndexes = store.each(user, ns.solid('privateTypeIndex'), undefined, preferencesFile as NamedNode)
|
|
54
|
-
.concat(store.each(user, ns.solid('privateTypeIndex'), undefined, profile))
|
|
55
|
-
const priv = privateTypeIndexes.length > 0 ? [ { label: 'priSo @@@@@vate', index: privateTypeIndexes[0] as NamedNode, agent: user } ] : []
|
|
56
|
-
return pub.concat(priv)
|
|
57
|
-
}
|
|
58
|
-
return pub
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
export async function loadCommunityTypeIndexes (store:LiveStore, user:NamedNode): Promise<TypeIndex[][]> {
|
|
62
|
-
const preferencesFile = await loadPreferences(store, user)
|
|
63
|
-
if (preferencesFile) {
|
|
64
|
-
const communities = store.each(user, ns.solid('community'), undefined, preferencesFile as NamedNode)
|
|
65
|
-
const communityTypeIndexesPromise = communities.map(async community => await loadTypeIndexesFor(store, community as NamedNode))
|
|
66
|
-
const result1 = Promise.all(communityTypeIndexesPromise)
|
|
67
|
-
// const result2 = Promise.all(result1)
|
|
68
|
-
// const flat = result2.flat()
|
|
69
|
-
return result1
|
|
70
|
-
// const communityTypeIndexes = await Promise.all(communityTypeIndexesPromise)
|
|
71
|
-
/*
|
|
72
|
-
let result = [] as TypeIndex[]
|
|
73
|
-
for(const community of communities) {
|
|
74
|
-
result = result.concat(await loadTypeIndexesFor(store, community as NamedNode)) as TypeIndex[] // @@ how oto make functional with async?
|
|
75
|
-
}
|
|
76
|
-
*/
|
|
77
|
-
// return communityTypeIndexesPromise.resolve()
|
|
78
|
-
}
|
|
79
|
-
return []
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
export async function loadAllTypeIndexes (store:LiveStore, user:NamedNode) {
|
|
83
|
-
return (await loadTypeIndexesFor(store, user)).concat((await loadCommunityTypeIndexes(store, user)).flat())
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
/*
|
|
87
|
-
export async function getAppInstances (store:LiveStore, klass: NamedNode) {
|
|
88
|
-
|
|
89
|
-
}
|
|
90
|
-
*/
|