solid-logic 1.3.17-2bf19bb6 → 1.3.17-2d62034f
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/lib/acl/aclLogic.d.ts +12 -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/authn/SolidAuthnLogic.d.ts.map +1 -1
- package/lib/authn/SolidAuthnLogic.js +3 -3
- package/lib/authn/SolidAuthnLogic.js.map +1 -1
- package/lib/chat/chatLogic.d.ts +16 -0
- package/lib/chat/chatLogic.d.ts.map +1 -0
- package/lib/chat/{ChatLogic.js → chatLogic.js} +82 -87
- package/lib/chat/chatLogic.js.map +1 -0
- package/lib/inbox/inboxLogic.d.ts +7 -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 +18 -9
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +76 -22
- package/lib/index.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 +8 -34
- package/lib/logic/SolidLogic.d.ts.map +1 -1
- package/lib/logic/SolidLogic.js +16 -250
- package/lib/logic/SolidLogic.js.map +1 -1
- package/lib/logic/solidLogicSingleton.js +1 -1
- package/lib/logic/solidLogicSingleton.js.map +1 -1
- package/lib/logic/solidLogicSingletonNew.d.ts +67 -0
- package/lib/logic/solidLogicSingletonNew.d.ts.map +1 -0
- package/lib/logic/solidLogicSingletonNew.js +219 -0
- package/lib/logic/solidLogicSingletonNew.js.map +1 -0
- package/lib/profile/profileLogic.d.ts +11 -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 +18 -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 +17 -0
- package/lib/types.d.ts.map +1 -1
- 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/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 +3 -1
- package/src/acl/aclLogic.ts +136 -118
- package/src/authn/SolidAuthnLogic.ts +8 -7
- package/src/chat/chatLogic.ts +225 -0
- package/src/inbox/inboxLogic.ts +57 -0
- package/src/index.ts +124 -20
- package/src/logic/CustomError.ts +5 -1
- package/src/logic/SolidLogic.ts +30 -211
- package/src/logic/solidLogicSingleton.ts +1 -1
- package/src/logic/solidLogicSingletonNew.ts +210 -0
- package/src/profile/profileLogic.ts +125 -0
- package/src/typeIndex/typeIndexLogic.ts +175 -182
- package/src/types.ts +7 -3
- package/src/util/containerLogic.ts +54 -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/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/typeIndexLogic.test.ts +488 -30
- package/test/utilityLogic.test.ts +172 -126
- package/test/utils.test.ts +32 -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/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/profile/ProfileLogic.ts +0 -44
- package/src/util/UtilityLogic.ts +0 -161
- package/src/util/uri.ts +0 -5
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { NamedNode, LiveStore } from "rdflib";
|
|
2
|
-
import { ProfileLogic } from "../profile/ProfileLogic";
|
|
3
|
-
import { SolidNamespace } from "../types";
|
|
4
|
-
import { UtilityLogic } from "../util/UtilityLogic";
|
|
5
|
-
/**
|
|
6
|
-
* Inbox-related logic
|
|
7
|
-
*/
|
|
8
|
-
export declare class InboxLogic {
|
|
9
|
-
store: LiveStore;
|
|
10
|
-
ns: SolidNamespace;
|
|
11
|
-
profile: ProfileLogic;
|
|
12
|
-
util: UtilityLogic;
|
|
13
|
-
constructor(store: LiveStore, ns: SolidNamespace, profile: ProfileLogic, util: UtilityLogic);
|
|
14
|
-
getNewMessages(user?: NamedNode): Promise<string[]>;
|
|
15
|
-
createInboxFor(peerWebId: string, nick: string): Promise<string>;
|
|
16
|
-
markAsRead(url: string, date: Date): Promise<void>;
|
|
17
|
-
}
|
|
18
|
-
//# sourceMappingURL=InboxLogic.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"InboxLogic.d.ts","sourceRoot":"","sources":["../../src/inbox/InboxLogic.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAC1C,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAEpD;;GAEG;AACH,qBAAa,UAAU;IACrB,KAAK,EAAE,SAAS,CAAC;IACjB,EAAE,EAAE,cAAc,CAAC;IACnB,OAAO,EAAE,YAAY,CAAC;IACtB,IAAI,EAAE,YAAY,CAAC;gBAEP,KAAK,EAAE,SAAS,EAAE,EAAE,EAAE,cAAc,EAAE,OAAO,EAAE,YAAY,EAAE,IAAI,EAAE,YAAY;IAOrF,cAAc,CAClB,IAAI,CAAC,EAAE,SAAS,GACf,OAAO,CAAC,MAAM,EAAE,CAAC;IAQd,cAAc,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM;IAc9C,UAAU,C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wBAArE,QAAQ,GAAG,SAA0D;6BACvE,CAAA,QAAQ,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,KAAK,GAAG,CAAA,EAArC,wBAAqC;wBACvC,qBAAM,CAAA,MAAA,IAAI,CAAC,KAAK,CAAC,OAAO,0CAAE,MAAM,CAAC,GAAG,EAAE;gCACpC,MAAM,EAAE,QAAQ;6BACjB,CAAC,CAAA,EAAA;;wBAFF,SAEE,CAAC;;;;;;KAEN;IACH,iBAAC;AAAD,CAAC,AAzDD,IAyDC;AAzDY,gCAAU"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { NamedNode, LiveStore } from "rdflib";
|
|
2
|
-
import { AuthnLogic, SolidNamespace } from "../types";
|
|
3
|
-
export declare class ProfileLogic {
|
|
4
|
-
store: LiveStore;
|
|
5
|
-
ns: SolidNamespace;
|
|
6
|
-
authn: AuthnLogic;
|
|
7
|
-
constructor(store: LiveStore, ns: SolidNamespace, authn: AuthnLogic);
|
|
8
|
-
loadMe(): Promise<NamedNode>;
|
|
9
|
-
getPodRoot(user: NamedNode): NamedNode;
|
|
10
|
-
getMainInbox(user: NamedNode): Promise<NamedNode>;
|
|
11
|
-
private findStorage;
|
|
12
|
-
}
|
|
13
|
-
//# sourceMappingURL=ProfileLogic.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ProfileLogic.d.ts","sourceRoot":"","sources":["../../src/profile/ProfileLogic.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAEtD,qBAAa,YAAY;IACvB,KAAK,EAAE,SAAS,CAAC;IACjB,EAAE,EAAE,cAAc,CAAC;IACnB,KAAK,EAAE,UAAU,CAAC;gBAEN,KAAK,EAAE,SAAS,EAAE,EAAE,EAAE,cAAc,EAAE,KAAK,EAAE,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AAI,CAAC,IAAI,CAAC,CAAA,EAAA;;wBAApC,SAAoC,CAAC;wBAC/B,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,EAAE,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC;wBACpF,IAAI,CAAC,SAAS,EAAE;4BACd,MAAM,IAAI,KAAK,CAAC,4BAA4B,CAAC,CAAC;yBAC/C;wBACD,sBAAO,SAAsB,EAAC;;;;KAC/B;IAEO,kCAAW,GAAnB,UAAoB,EAAa;QAC/B,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,EAAE,IAAI,CAAC,EAAE,CAAC,KAAK,CAAC,SAAS,CAAC,EAAE,SAAS,EAAE,EAAE,CAAC,GAAG,EAAE,CAAC,CAAC;IAC3E,CAAC;IACH,mBAAC;AAAD,CAAC,AAxCD,IAwCC;AAxCY,oCAAY"}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { NamedNode, LiveStore } from "rdflib";
|
|
2
|
-
import { SolidNamespace } from "../types";
|
|
3
|
-
export declare const ACL_LINK: NamedNode;
|
|
4
|
-
/**
|
|
5
|
-
* Utility-related logic
|
|
6
|
-
*/
|
|
7
|
-
export declare class UtilityLogic {
|
|
8
|
-
store: LiveStore;
|
|
9
|
-
ns: SolidNamespace;
|
|
10
|
-
underlyingFetch: {
|
|
11
|
-
fetch: (url: string, options?: any) => any;
|
|
12
|
-
};
|
|
13
|
-
constructor(store: LiveStore, ns: SolidNamespace, underlyingFetch: {
|
|
14
|
-
fetch: (url: string, options?: any) => any;
|
|
15
|
-
});
|
|
16
|
-
findAclDocUrl(url: string): Promise<string>;
|
|
17
|
-
setSinglePeerAccess(options: {
|
|
18
|
-
ownerWebId: string;
|
|
19
|
-
peerWebId: string;
|
|
20
|
-
accessToModes?: string;
|
|
21
|
-
defaultModes?: string;
|
|
22
|
-
target: string;
|
|
23
|
-
}): Promise<any>;
|
|
24
|
-
loadDoc(doc: NamedNode): Promise<void>;
|
|
25
|
-
isContainer(url: string): boolean;
|
|
26
|
-
createContainer(url: string): Promise<void>;
|
|
27
|
-
getContainerElements(containerNode: NamedNode): NamedNode[];
|
|
28
|
-
getContainerMembers(containerUrl: string): Promise<string[]>;
|
|
29
|
-
recursiveDelete(url: string): Promise<any>;
|
|
30
|
-
clearStore(): void;
|
|
31
|
-
getArchiveUrl(baseUrl: string, date: Date): string;
|
|
32
|
-
}
|
|
33
|
-
//# sourceMappingURL=UtilityLogic.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"UtilityLogic.d.ts","sourceRoot":"","sources":["../../src/util/UtilityLogic.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAkB,SAAS,EAAE,MAAM,QAAQ,CAAC;AAC9D,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAE1C,eAAO,MAAM,QAAQ,WAEpB,CAAC;AAEF;;GAEG;AACH,qBAAa,YAAY;IACvB,KAAK,EAAE,SAAS,CAAC;IACjB,EAAE,EAAE,cAAc,CAAC;IACnB,eAAe,EAAE;QAAE,KAAK,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,GAAG,KAAK,GAAG,CAAA;KAAE,CAAC;gBAEpD,KAAK,EAAE,SAAS,EAAE,EAAE,EAAE,cAAc,EAAE,eAAe,EAAE;QAAE,KAAK,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,GAAG,KAAK,GAAG,CAAA;KAAE;IAM3G,aAAa,CAAC,GAAG,EAAE,MAAM;IAWzB,mBAAmB,CAAC,OAAO,EAAE;QACjC,UAAU,EAAE,MAAM,CAAC;QACnB,SAAS,EAAE,MAAM,CAAC;QAClB,aAAa,CAAC,EAAE,MAAM,CAAC;QACvB,YAAY,CAAC,EAAE,MAAM,CAAC;QACtB,MAAM,EAAE,MAAM,CAAA;KACf;IAsCK,OAAO,CAAC,GAAG,EAAE,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC;IAe5C,WAAW,CAAC,GAAG,EAAE,MAAM;IAIjB,eAAe,CAAC,GAAG,EAAE,MAAM;IAmBjC,oBAAoB,CAAC,aAAa,EAAE,SAAS,GAAG,SAAS,EAAE;IAWrD,mBAAmB,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IAO5D,eAAe,CAAC,GAAG,EAAE,MAAM;IAgBjC,UAAU;IAIV,aAAa,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI;CAQ1C"}
|
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,IAAA,YAAG,EACzB,oDAAoD,CACrD,CAAC;AAEF;;GAEG;AACH;IAKE,sBAAY,KAAgB,EAAE,EAAkB,EAAE,eAA+D;QAC/G,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;QACb,IAAI,CAAC,eAAe,GAAG,eAAe,CAAC;IACzC,CAAC;IAEK,oCAAa,GAAnB,UAAoB,GAAW;;;;;;;wBACvB,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC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}
|
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
|
-
}
|