solid-logic 4.0.6 → 4.0.8-test.0
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 +3 -1
- package/dist/2729812e0bfc062ee77a.js +1 -0
- package/dist/a9c30b64ceaae48b72f0.js +2045 -0
- package/dist/authSession/authSession.d.ts +41 -2
- package/dist/authSession/authSession.d.ts.map +1 -1
- package/dist/authSession/events.d.ts +24 -0
- package/dist/authSession/events.d.ts.map +1 -0
- package/dist/authSession/issuer.d.ts +8 -0
- package/dist/authSession/issuer.d.ts.map +1 -0
- package/dist/authSession/session.d.ts +45 -0
- package/dist/authSession/session.d.ts.map +1 -0
- package/dist/authn/SolidAuthnLogic.d.ts +15 -6
- package/dist/authn/SolidAuthnLogic.d.ts.map +1 -1
- package/dist/authn/serverLogout.d.ts +6 -0
- package/dist/authn/serverLogout.d.ts.map +1 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/logic/solidLogic.d.ts +3 -3
- package/dist/logic/solidLogic.d.ts.map +1 -1
- package/dist/logic/solidLogicSingleton.d.ts.map +1 -1
- package/dist/profile/profileAclDocuments.d.ts +2 -0
- package/dist/profile/profileAclDocuments.d.ts.map +1 -0
- package/dist/profile/profileDocuments.d.ts +2 -0
- package/dist/profile/profileDocuments.d.ts.map +1 -0
- package/dist/profile/profileLogic.d.ts.map +1 -1
- package/dist/solid-logic.esm.js +1037 -6119
- package/dist/solid-logic.esm.js.map +1 -1
- package/dist/solid-logic.esm.min.js +1 -31
- package/dist/solid-logic.esm.min.js.map +1 -1
- package/dist/solid-logic.js +4662 -4613
- package/dist/solid-logic.js.map +1 -1
- package/dist/solid-logic.min.js +1 -31
- package/dist/solid-logic.min.js.map +1 -1
- package/dist/typeIndex/typeIndexAclDocuments.d.ts +2 -0
- package/dist/typeIndex/typeIndexAclDocuments.d.ts.map +1 -0
- package/dist/typeIndex/typeIndexDocuments.d.ts +3 -0
- package/dist/typeIndex/typeIndexDocuments.d.ts.map +1 -0
- package/dist/typeIndex/typeIndexLogic.d.ts.map +1 -1
- package/dist/types.d.ts +2 -2
- package/dist/types.d.ts.map +1 -1
- package/dist/util/containerLogic.d.ts.map +1 -1
- package/dist/util/utilityLogic.d.ts +2 -0
- package/dist/util/utilityLogic.d.ts.map +1 -1
- package/package.json +21 -19
- package/dist/acl/aclLogic.js +0 -117
- package/dist/acl/aclLogic.js.map +0 -1
- package/dist/authSession/authSession.js +0 -3
- package/dist/authSession/authSession.js.map +0 -1
- package/dist/authn/SolidAuthnLogic.js +0 -109
- package/dist/authn/SolidAuthnLogic.js.map +0 -1
- package/dist/authn/authUtil.js +0 -64
- package/dist/authn/authUtil.js.map +0 -1
- package/dist/chat/chatLogic.js +0 -157
- package/dist/chat/chatLogic.js.map +0 -1
- package/dist/inbox/inboxLogic.js +0 -51
- package/dist/inbox/inboxLogic.js.map +0 -1
- package/dist/index.js +0 -14
- package/dist/index.js.map +0 -1
- package/dist/issuer/issuerLogic.js +0 -37
- package/dist/issuer/issuerLogic.js.map +0 -1
- package/dist/logic/CustomError.js +0 -27
- package/dist/logic/CustomError.js.map +0 -1
- package/dist/logic/solidLogic.js +0 -64
- package/dist/logic/solidLogic.js.map +0 -1
- package/dist/logic/solidLogicSingleton.js +0 -31
- package/dist/logic/solidLogicSingleton.js.map +0 -1
- package/dist/profile/profileLogic.js +0 -128
- package/dist/profile/profileLogic.js.map +0 -1
- package/dist/typeIndex/typeIndexLogic.js +0 -236
- package/dist/typeIndex/typeIndexLogic.js.map +0 -1
- package/dist/types.js +0 -2
- package/dist/types.js.map +0 -1
- package/dist/util/containerLogic.js +0 -45
- package/dist/util/containerLogic.js.map +0 -1
- package/dist/util/debug.js +0 -13
- package/dist/util/debug.js.map +0 -1
- package/dist/util/ns.js +0 -5
- package/dist/util/ns.js.map +0 -1
- package/dist/util/utilityLogic.js +0 -144
- package/dist/util/utilityLogic.js.map +0 -1
- package/dist/util/utils.js +0 -39
- package/dist/util/utils.js.map +0 -1
- package/dist/versionInfo.js +0 -36
- package/dist/versionInfo.js.map +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"chatLogic.js","sourceRoot":"","sources":["../../src/chat/chatLogic.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAQ,EAAE,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA;AAElD,OAAO,EAAE,EAAE,IAAI,SAAS,EAAE,MAAM,YAAY,CAAA;AAC5C,OAAO,EAAE,sBAAsB,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAEhE,MAAM,0BAA0B,GAAG,gBAAgB,CAAA;AAEnD,MAAM,UAAU,eAAe,CAAC,KAAK,EAAE,YAAY;IAC/C,MAAM,EAAE,GAAG,SAAS,CAAA;IAEpB,KAAK,UAAU,MAAM,CACjB,aAAwB,EACxB,EAAa,EACb,OAAkB;QAElB,yDAAyD;QACzD,+DAA+D;QAC/D,gCAAgC;QAChC,MAAM,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,aAAa,CAAC,CAAA;QAEvC,2CAA2C;QAC3C,MAAM,UAAU,GAAG,KAAK,CAAC,GAAG,CACxB,aAAa,EACb,IAAI,SAAS,CAAC,oDAAoD,CAAC,CACtE,CAAA;QACD,IAAI,CAAC,UAAU,EAAE,CAAC;YACd,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAA;QAC9C,CAAC;QAED,MAAM,OAAO,GAAG;;;;yBAIC,EAAE,CAAC,KAAK;;;;;;;yBAOR,OAAO,CAAC,KAAK;;;;;aAKzB,CAAA;QACL,MAAM,KAAK,CAAC,OAAO,CAAC,YAAY,CAAC,KAAK,EAAE,UAAU,CAAC,KAAK,EAAE;YACtD,IAAI,EAAE,OAAO;YACb,WAAW,EAAE,aAAa;SAC7B,CAAC,CAAA;IACN,CAAC;IAED,KAAK,UAAU,qBAAqB,CAAC,SAAS,EAAE,EAAE;QAC9C,4BAA4B;QAC5B,MAAM,gBA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AAG,cAAc,aAAd,cAAc,uBAAd,cAAc,CAAE,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,CAAA;QAC3D,IAAI,CAAC,WAAW,EAAE,CAAC;YACf,MAAM,IAAI,KAAK,CAAC,6BAA6B,cAAc,aAAd,cAAc,uBAAd,cAAc,CAAE,MAAM,EAAE,CAAC,CAAA;QAC1E,CAAC;IACL,CAAC;IACD,OAAO;QACH,MAAM,EAAE,qBAAqB,EAAE,QAAQ,EAAE,eAAe,EAAE,OAAO,EAAE,UAAU,EAAE,OAAO;KACzF,CAAA;AACL,CAAC"}
|
package/dist/inbox/inboxLogic.js
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import { getArchiveUrl } from '../util/utils';
|
|
2
|
-
export function createInboxLogic(store, profileLogic, utilityLogic, containerLogic, aclLogic) {
|
|
3
|
-
async function createInboxFor(peerWebId, nick) {
|
|
4
|
-
const myWebId = await profileLogic.loadMe();
|
|
5
|
-
const podRoot = await profileLogic.getPodRoot(myWebId);
|
|
6
|
-
const ourInbox = `${podRoot.value}p2p-inboxes/${encodeURIComponent(nick)}/`;
|
|
7
|
-
await containerLogic.createContainer(ourInbox);
|
|
8
|
-
// const aclDocUrl = await aclLogic.findAclDocUrl(ourInbox);
|
|
9
|
-
await utilityLogic.setSinglePeerAccess({
|
|
10
|
-
ownerWebId: myWebId.value,
|
|
11
|
-
peerWebId,
|
|
12
|
-
accessToModes: 'acl:Append',
|
|
13
|
-
target: ourInbox
|
|
14
|
-
});
|
|
15
|
-
return ourInbox;
|
|
16
|
-
}
|
|
17
|
-
async function getNewMessages(user) {
|
|
18
|
-
if (!user) {
|
|
19
|
-
user = await profileLogic.loadMe();
|
|
20
|
-
}
|
|
21
|
-
const inbox = await profileLogic.getMainInbox(user);
|
|
22
|
-
const urls = await containerLogic.getContainerMembers(inbox);
|
|
23
|
-
return urls.filter(url => !containerLogic.isContainer(url));
|
|
24
|
-
}
|
|
25
|
-
async function markAsRead(url, date) {
|
|
26
|
-
const downloaded = await store.fetcher._fetch(url);
|
|
27
|
-
if (downloaded.status !== 200) {
|
|
28
|
-
throw new Error(`Not OK! ${url}`);
|
|
29
|
-
}
|
|
30
|
-
const archiveUrl = getArchiveUrl(url, date);
|
|
31
|
-
const options = {
|
|
32
|
-
method: 'PUT',
|
|
33
|
-
body: await downloaded.text(),
|
|
34
|
-
headers: [
|
|
35
|
-
['Content-Type', downloaded.headers.get('Content-Type') || 'application/octet-stream']
|
|
36
|
-
]
|
|
37
|
-
};
|
|
38
|
-
const uploaded = await store.fetcher._fetch(archiveUrl, options);
|
|
39
|
-
if (uploaded.status.toString()[0] === '2') {
|
|
40
|
-
await store.fetcher._fetch(url, {
|
|
41
|
-
method: 'DELETE'
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
return {
|
|
46
|
-
createInboxFor,
|
|
47
|
-
getNewMessages,
|
|
48
|
-
markAsRead
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
//# sourceMappingURL=inboxLogic.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"inboxLogic.js","sourceRoot":"","sources":["../../src/inbox/inboxLogic.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA;AAE7C,MAAM,UAAU,gBAAgB,CAAC,KAAK,EAAE,YAAY,EAAE,YAAY,EAAE,cAAc,EAAE,QAAQ;IAExF,KAAK,UAAU,cAAc,CAAC,SAAiB,EAAE,IAAY;QAC3D,MAAM,OAAO,GAAc,MAAM,YAAY,CAAC,MAAM,EAAE,CAAA;QACtD,MAAM,OAAO,GAAc,MAAM,YAAY,CAAC,UAAU,CAAC,OAAO,CAAC,CAAA;QACjE,MAAM,QAAQ,GAAG,GAAG,OAAO,CAAC,KAAK,eAAe,kBAAkB,CAAC,IAAI,CAAC,GAAG,CAAA;QAC3E,MAAM,cAAc,CAAC,eAAe,CAAC,QAAQ,CAAC,CAAA;QAC9C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U,EAAE,OAAO,CAAC,CAAA;QAChE,IAAI,QAAQ,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,KAAK,GAAG,EAAE,CAAC;YAC1C,MAAM,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,GAAG,EAAE;gBAC9B,MAAM,EAAE,QAAQ;aACjB,CAAC,CAAA;QACJ,CAAC;IACH,CAAC;IACD,OAAO;QACL,cAAc;QACd,cAAc;QACd,UAAU;KACX,CAAA;AACH,CAAC"}
|
package/dist/index.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
// Make these variables directly accessible as it is what you need most of the time
|
|
2
|
-
// This also makes these variable globaly accesible in mashlib
|
|
3
|
-
import { solidLogicSingleton } from './logic/solidLogicSingleton';
|
|
4
|
-
const authn = solidLogicSingleton.authn;
|
|
5
|
-
const authSession = solidLogicSingleton.authn.authSession;
|
|
6
|
-
const store = solidLogicSingleton.store;
|
|
7
|
-
export { ACL_LINK } from './acl/aclLogic';
|
|
8
|
-
export { offlineTestID, appContext } from './authn/authUtil';
|
|
9
|
-
export { getSuggestedIssuers } from './issuer/issuerLogic';
|
|
10
|
-
export { createTypeIndexLogic } from './typeIndex/typeIndexLogic';
|
|
11
|
-
export { UnauthorizedError, CrossOriginForbiddenError, SameOriginForbiddenError, NotFoundError, FetchError, NotEditableError, WebOperationError } from './logic/CustomError';
|
|
12
|
-
export { solidLogicSingleton, // solidLogicSingleton is exported entirely because it is used in solid-panes
|
|
13
|
-
store, authn, authSession };
|
|
14
|
-
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,mFAAmF;AACnF,8DAA8D;AAC9D,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAA;AAEjE,MAAM,KAAK,GAAG,mBAAmB,CAAC,KAAK,CAAA;AACvC,MAAM,WAAW,GAAG,mBAAmB,CAAC,KAAK,CAAC,WAAW,CAAA;AACzD,MAAM,KAAK,GAAG,mBAAmB,CAAC,KAAK,CAAA;AAEvC,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AACzC,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAC5D,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAA;AAC1D,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAA;AAEjE,OAAO,EAAE,iBAAiB,EAAE,yBAAyB,EAAE,wBAAwB,EAAE,aAAa,EAAE,UAAU,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AAE5K,OAAO,EACL,mBAAmB,EAAE,6EAA6E;AAClG,KAAK,EACL,KAAK,EACL,WAAW,EACZ,CAAA"}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
const DEFAULT_ISSUERS = [
|
|
2
|
-
{
|
|
3
|
-
name: 'Solid Community',
|
|
4
|
-
uri: 'https://solidcommunity.net'
|
|
5
|
-
},
|
|
6
|
-
{
|
|
7
|
-
name: 'Solid Web',
|
|
8
|
-
uri: 'https://solidweb.org'
|
|
9
|
-
},
|
|
10
|
-
{
|
|
11
|
-
name: 'Solid Web ME',
|
|
12
|
-
uri: 'https://solidweb.me'
|
|
13
|
-
},
|
|
14
|
-
{
|
|
15
|
-
name: 'Inrupt.com',
|
|
16
|
-
uri: 'https://login.inrupt.com'
|
|
17
|
-
}
|
|
18
|
-
];
|
|
19
|
-
/**
|
|
20
|
-
* @returns - A list of suggested OIDC issuers
|
|
21
|
-
*/
|
|
22
|
-
export function getSuggestedIssuers() {
|
|
23
|
-
// Suggest a default list of OIDC issuers
|
|
24
|
-
const issuers = [...DEFAULT_ISSUERS];
|
|
25
|
-
// Suggest the current host if not already included
|
|
26
|
-
const { host, origin } = new URL(location.href);
|
|
27
|
-
const hosts = issuers.map(({ uri }) => new URL(uri).host);
|
|
28
|
-
if (!hosts.includes(host) && !hosts.some(existing => isSubdomainOf(host, existing))) {
|
|
29
|
-
issuers.unshift({ name: host, uri: origin });
|
|
30
|
-
}
|
|
31
|
-
return issuers;
|
|
32
|
-
}
|
|
33
|
-
function isSubdomainOf(subdomain, domain) {
|
|
34
|
-
const dot = subdomain.length - domain.length - 1;
|
|
35
|
-
return dot > 0 && subdomain[dot] === '.' && subdomain.endsWith(domain);
|
|
36
|
-
}
|
|
37
|
-
//# sourceMappingURL=issuerLogic.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"issuerLogic.js","sourceRoot":"","sources":["../../src/issuer/issuerLogic.ts"],"names":[],"mappings":"AAAA,MAAM,eAAe,GAAG;IACtB;QACE,IAAI,EAAE,iBAAiB;QACvB,GAAG,EAAE,4BAA4B;KAClC;IACD;QACE,IAAI,EAAE,WAAW;QACjB,GAAG,EAAE,sBAAsB;KAC5B;IACD;QACE,IAAI,EAAE,cAAc;QACpB,GAAG,EAAE,qBAAqB;KAC3B;IACD;QACE,IAAI,EAAE,YAAY;QAClB,GAAG,EAAE,0BAA0B;KAChC;CACF,CAAA;AAED;;GAEG;AACH,MAAM,UAAU,mBAAmB;IAC/B,yCAAyC;IACzC,MAAM,OAAO,GAAG,CAAC,GAAG,eAAe,CAAC,CAAA;IAEpC,mDAAmD;IACnD,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,IAAI,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAA;IAC/C,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE,CAAC,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,CAAA;IACzD,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,aAAa,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC,EAAE,CAAC;QACpF,OAAO,CAAC,OAAO,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,EAAE,CAAC,CAAA;IAC9C,CAAC;IAED,OAAO,OAAO,CAAA;AAChB,CAAC;AAEH,SAAS,aAAa,CAAE,SAAiB,EAAE,MAAc;IACrD,MAAM,GAAG,GAAG,SAAS,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,GAAG,CAAC,CAAA;IAChD,OAAO,GAAG,GAAG,CAAC,IAAI,SAAS,CAAC,GAAG,CAAC,KAAK,GAAG,IAAI,SAAS,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAA;AAC1E,CAAC"}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
class CustomError extends Error {
|
|
2
|
-
constructor(message) {
|
|
3
|
-
super(message);
|
|
4
|
-
// see: typescriptlang.org/docs/handbook/release-notes/typescript-2-2.html
|
|
5
|
-
Object.setPrototypeOf(this, new.target.prototype); // restore prototype chain
|
|
6
|
-
this.name = new.target.name; // stack traces display correctly now
|
|
7
|
-
}
|
|
8
|
-
}
|
|
9
|
-
export class UnauthorizedError extends CustomError {
|
|
10
|
-
}
|
|
11
|
-
export class CrossOriginForbiddenError extends CustomError {
|
|
12
|
-
}
|
|
13
|
-
export class SameOriginForbiddenError extends CustomError {
|
|
14
|
-
}
|
|
15
|
-
export class NotFoundError extends CustomError {
|
|
16
|
-
}
|
|
17
|
-
export class NotEditableError extends CustomError {
|
|
18
|
-
}
|
|
19
|
-
export class WebOperationError extends CustomError {
|
|
20
|
-
}
|
|
21
|
-
export class FetchError extends CustomError {
|
|
22
|
-
constructor(status, message) {
|
|
23
|
-
super(message);
|
|
24
|
-
this.status = status;
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
//# sourceMappingURL=CustomError.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"CustomError.js","sourceRoot":"","sources":["../../src/logic/CustomError.ts"],"names":[],"mappings":"AAAA,MAAM,WAAY,SAAQ,KAAK;IAC3B,YAAY,OAAgB;QACxB,KAAK,CAAC,OAAO,CAAC,CAAA;QACd,0EAA0E;QAC1E,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC,CAAA,CAAC,0BAA0B;QAC5E,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC,MAAM,CAAC,IAAI,CAAA,CAAC,qCAAqC;IACrE,CAAC;CACJ;AAED,MAAM,OAAO,iBAAkB,SAAQ,WAAW;CAAG;AAErD,MAAM,OAAO,yBAA0B,SAAQ,WAAW;CAAG;AAE7D,MAAM,OAAO,wBAAyB,SAAQ,WAAW;CAAG;AAE5D,MAAM,OAAO,aAAc,SAAQ,WAAW;CAAG;AAEjD,MAAM,OAAO,gBAAiB,SAAQ,WAAW;CAAI;AAErD,MAAM,OAAO,iBAAkB,SAAQ,WAAW;CAAG;AAErD,MAAM,OAAO,UAAW,SAAQ,WAAW;IAGvC,YAAY,MAAc,EAAE,OAAgB;QACxC,KAAK,CAAC,OAAO,CAAC,CAAA;QACd,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;IACxB,CAAC;CACJ"}
|
package/dist/logic/solidLogic.js
DELETED
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import * as rdf from 'rdflib';
|
|
2
|
-
import { createAclLogic } from '../acl/aclLogic';
|
|
3
|
-
import { SolidAuthnLogic } from '../authn/SolidAuthnLogic';
|
|
4
|
-
import { createChatLogic } from '../chat/chatLogic';
|
|
5
|
-
import { createInboxLogic } from '../inbox/inboxLogic';
|
|
6
|
-
import { createProfileLogic } from '../profile/profileLogic';
|
|
7
|
-
import { createTypeIndexLogic } from '../typeIndex/typeIndexLogic';
|
|
8
|
-
import { createContainerLogic } from '../util/containerLogic';
|
|
9
|
-
import { createUtilityLogic } from '../util/utilityLogic';
|
|
10
|
-
import * as debug from '../util/debug';
|
|
11
|
-
/*
|
|
12
|
-
** It is important to distinquish `fetch`, a function provided by the browser
|
|
13
|
-
** and `Fetcher`, a helper object for the rdflib Store which turns it
|
|
14
|
-
** into a `ConnectedStore` or a `LiveStore`. A Fetcher object is
|
|
15
|
-
** available at store.fetcher, and `fetch` function at `store.fetcher._fetch`,
|
|
16
|
-
*/
|
|
17
|
-
export function createSolidLogic(specialFetch, session) {
|
|
18
|
-
debug.log('SolidLogic: Unique instance created. There should only be one of these.');
|
|
19
|
-
const store = rdf.graph();
|
|
20
|
-
rdf.fetcher(store, { fetch: specialFetch.fetch }); // Attach a web I/O module, store.fetcher
|
|
21
|
-
store.updater = new rdf.UpdateManager(store); // Add real-time live updates store.updater
|
|
22
|
-
store.features = []; // disable automatic node merging on store load
|
|
23
|
-
const authn = new SolidAuthnLogic(session);
|
|
24
|
-
const acl = createAclLogic(store);
|
|
25
|
-
const containerLogic = createContainerLogic(store);
|
|
26
|
-
const utilityLogic = createUtilityLogic(store, acl, containerLogic);
|
|
27
|
-
const profile = createProfileLogic(store, authn, utilityLogic);
|
|
28
|
-
const chat = createChatLogic(store, profile);
|
|
29
|
-
const inbox = createInboxLogic(store, profile, utilityLogic, containerLogic, acl);
|
|
30
|
-
const typeIndex = createTypeIndexLogic(store, authn, profile, utilityLogic);
|
|
31
|
-
debug.log('SolidAuthnLogic initialized');
|
|
32
|
-
function load(doc) {
|
|
33
|
-
return store.fetcher.load(doc);
|
|
34
|
-
}
|
|
35
|
-
// @@@@ use the one in rdflib.js when it is available and delete this
|
|
36
|
-
function updatePromise(del, ins = []) {
|
|
37
|
-
return new Promise((resolve, reject) => {
|
|
38
|
-
store.updater.update(del, ins, function (_uri, ok, errorBody) {
|
|
39
|
-
if (!ok) {
|
|
40
|
-
reject(new Error(errorBody));
|
|
41
|
-
}
|
|
42
|
-
else {
|
|
43
|
-
resolve();
|
|
44
|
-
}
|
|
45
|
-
}); // callback
|
|
46
|
-
}); // promise
|
|
47
|
-
}
|
|
48
|
-
function clearStore() {
|
|
49
|
-
store.statements.slice().forEach(store.remove.bind(store));
|
|
50
|
-
}
|
|
51
|
-
return {
|
|
52
|
-
store,
|
|
53
|
-
authn,
|
|
54
|
-
acl,
|
|
55
|
-
inbox,
|
|
56
|
-
chat,
|
|
57
|
-
profile,
|
|
58
|
-
typeIndex,
|
|
59
|
-
load,
|
|
60
|
-
updatePromise,
|
|
61
|
-
clearStore
|
|
62
|
-
};
|
|
63
|
-
}
|
|
64
|
-
//# sourceMappingURL=solidLogic.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"solidLogic.js","sourceRoot":"","sources":["../../src/logic/solidLogic.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,GAAG,MAAM,QAAQ,CAAA;AAE7B,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAA;AAChD,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAA;AAC1D,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AACnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAA;AACtD,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AAC5D,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAA;AAClE,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAA;AAC7D,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAA;AAEzD,OAAO,KAAK,KAAK,MAAM,eAAe,CAAA;AACtC;;;;;EAKE;AACF,MAAM,UAAU,gBAAgB,CAAC,YAA4D,EAAE,OAAgB;IAE3G,KAAK,CAAC,GAAG,CAAC,0EAA0E,CAAC,CAAA;IACrF,MAAM,KAAK,GAAc,GAAG,CAAC,KAAK,EAAe,CAAA;IACjD,GAAG,CAAC,OAAO,CAAC,KAAK,EAAE,EAAC,KAAK,EAAE,YAAY,CAAC,KAAK,EAAC,CAAC,CAAA,CAAC,yCAAyC;IACzF,KAAK,CAAC,OAAO,GAAG,IA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,CAAC;oBACR,OAAO,EAAE,CAAA;gBACT,CAAC;YACL,CAAC,CAAC,CAAA,CAAC,WAAW;QACd,CAAC,CAAC,CAAA,CAAC,UAAU;IACjB,CAAC;IAED,SAAS,UAAU;QACf,KAAK,CAAC,UAAU,CAAC,KAAK,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAA;IAC9D,CAAC;IAED,OAAO;QACH,KAAK;QACL,KAAK;QACL,GAAG;QACH,KAAK;QACL,IAAI;QACJ,OAAO;QACP,SAAS;QACT,IAAI;QACJ,aAAa;QACb,UAAU;KACb,CAAA;AACL,CAAC"}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import * as debug from '../util/debug';
|
|
2
|
-
import { authSession } from '../authSession/authSession';
|
|
3
|
-
import { createSolidLogic } from './solidLogic';
|
|
4
|
-
const _fetch = async (url, requestInit) => {
|
|
5
|
-
const omitCreds = requestInit && requestInit.credentials && requestInit.credentials == 'omit';
|
|
6
|
-
if (authSession.info.webId && !omitCreds) { // see https://github.com/solidos/solidos/issues/114
|
|
7
|
-
// In fact fetch should respect credentials omit itself
|
|
8
|
-
return authSession.fetch(url, requestInit);
|
|
9
|
-
}
|
|
10
|
-
else {
|
|
11
|
-
return window.fetch(url, requestInit);
|
|
12
|
-
}
|
|
13
|
-
};
|
|
14
|
-
// Global singleton pattern to ensure unique store across library versions
|
|
15
|
-
const SINGLETON_SYMBOL = Symbol.for('solid-logic-singleton');
|
|
16
|
-
const globalTarget = (typeof window !== 'undefined' ? window : global);
|
|
17
|
-
function getOrCreateSingleton() {
|
|
18
|
-
if (!globalTarget[SINGLETON_SYMBOL]) {
|
|
19
|
-
debug.log('SolidLogic: Creating new global singleton instance.');
|
|
20
|
-
globalTarget[SINGLETON_SYMBOL] = createSolidLogic({ fetch: _fetch }, authSession);
|
|
21
|
-
debug.log('Unique quadstore initialized.');
|
|
22
|
-
}
|
|
23
|
-
else {
|
|
24
|
-
debug.log('SolidLogic: Using existing global singleton instance.');
|
|
25
|
-
}
|
|
26
|
-
return globalTarget[SINGLETON_SYMBOL];
|
|
27
|
-
}
|
|
28
|
-
//this const makes solidLogicSingleton global accessible in mashlib
|
|
29
|
-
const solidLogicSingleton = getOrCreateSingleton();
|
|
30
|
-
export { solidLogicSingleton };
|
|
31
|
-
//# sourceMappingURL=solidLogicSingleton.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"solidLogicSingleton.js","sourceRoot":"","sources":["../../src/logic/solidLogicSingleton.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,eAAe,CAAA;AACtC,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAA;AACxD,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAA;AAG/C,MAAM,MAAM,GAAG,KAAK,EAAE,GAAG,EAAE,WAAW,EAAE,EAAE;IACtC,MAAM,SAAS,GAAG,WAAW,IAAI,WAAW,CAAC,WAAW,IAAI,WAAW,CAAC,WAAW,IAAI,MAAM,CAAA;IAC7F,IAAI,WAAW,CAAC,IAAI,CAAC,KAAK,IAAI,CAAC,SAAS,EAAE,CAAC,CAAC,oDAAoD;QAC5F,uDAAuD;QACvD,OAAO,WAAW,CAAC,KAAK,CAAC,GAAG,EAAE,WAAW,CAAC,CAAA;IAC9C,CAAC;SAAM,CAAC;QACJ,OAAO,MAAM,CAAC,KAAK,CAAC,GAAG,EAAE,WAAW,CAAC,CAAA;IACzC,CAAC;AACL,CAAC,CAAA;AAED,0EAA0E;AAC1E,MAAM,gBAAgB,GAAG,MAAM,CAAC,GAAG,CAAC,uBAAuB,CAAC,CAAA;AAO5D,MAAM,YAAY,GAAG,CAAC,OAAO,MAAM,KAAK,WAAW,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAwB,CAAA;AAE7F,SAAS,oBAAoB;IACzB,IAAI,CAAC,YAAY,CAAC,gBAAgB,CAAC,EAAE,CAAC;QAClC,KAAK,CAAC,GAAG,CAAC,qDAAqD,CAAC,CAAA;QAChE,YAAY,CAAC,gBAAgB,CAAC,GAAG,gBAAgB,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,WAAW,CAAC,CAAA;QACjF,KAAK,CAAC,GAAG,CAAC,+BAA+B,CAAC,CAAA;IAC9C,CAAC;SAAM,CAAC;QACJ,KAAK,CAAC,GAAG,CAAC,uDAAuD,CAAC,CAAA;IACtE,CAAC;IACD,OAAO,YAAY,CAAC,gBAAgB,CAAE,CAAA;AAC1C,CAAC;AACD,mEAAmE;AACnE,MAAM,mBAAmB,GAAG,oBAAoB,EAAE,CAAA;AAElD,OAAO,EAAE,mBAAmB,EAAE,CAAA"}
|
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
import { CrossOriginForbiddenError, FetchError, NotEditableError, SameOriginForbiddenError, UnauthorizedError, WebOperationError } from '../logic/CustomError';
|
|
2
|
-
import * as debug from '../util/debug';
|
|
3
|
-
import { ns as namespace } from '../util/ns';
|
|
4
|
-
import { differentOrigin, suggestPreferencesFile } from '../util/utils';
|
|
5
|
-
export function createProfileLogic(store, authn, utilityLogic) {
|
|
6
|
-
const ns = namespace;
|
|
7
|
-
/**
|
|
8
|
-
* loads the preference without throwing errors - if it can create it it does so.
|
|
9
|
-
* remark: it still throws error if it cannot load profile.
|
|
10
|
-
* @param user
|
|
11
|
-
* @returns undefined if preferenceFile cannot be returned or NamedNode if it can find it or create it
|
|
12
|
-
*/
|
|
13
|
-
async function silencedLoadPreferences(user) {
|
|
14
|
-
try {
|
|
15
|
-
return await loadPreferences(user);
|
|
16
|
-
}
|
|
17
|
-
catch (err) {
|
|
18
|
-
return undefined;
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* loads the preference without returning different errors if it cannot create or load it.
|
|
23
|
-
* remark: it also throws error if it cannot load profile.
|
|
24
|
-
* @param user
|
|
25
|
-
* @returns undefined if preferenceFile cannot be an Error or NamedNode if it can find it or create it
|
|
26
|
-
*/
|
|
27
|
-
async function loadPreferences(user) {
|
|
28
|
-
await loadProfile(user);
|
|
29
|
-
const possiblePreferencesFile = suggestPreferencesFile(user);
|
|
30
|
-
let preferencesFile;
|
|
31
|
-
try {
|
|
32
|
-
preferencesFile = await utilityLogic.followOrCreateLink(user, ns.space('preferencesFile'), possiblePreferencesFile, user.doc());
|
|
33
|
-
}
|
|
34
|
-
catch (err) {
|
|
35
|
-
const message = `User ${user} has no pointer in profile to preferences file.`;
|
|
36
|
-
debug.warn(message);
|
|
37
|
-
// we are listing the possible errors
|
|
38
|
-
if (err instanceof NotEditableError) {
|
|
39
|
-
throw err;
|
|
40
|
-
}
|
|
41
|
-
if (err instanceof WebOperationError) {
|
|
42
|
-
throw err;
|
|
43
|
-
}
|
|
44
|
-
if (err instanceof UnauthorizedError) {
|
|
45
|
-
throw err;
|
|
46
|
-
}
|
|
47
|
-
if (err instanceof CrossOriginForbiddenError) {
|
|
48
|
-
throw err;
|
|
49
|
-
}
|
|
50
|
-
if (err instanceof SameOriginForbiddenError) {
|
|
51
|
-
throw err;
|
|
52
|
-
}
|
|
53
|
-
if (err instanceof FetchError) {
|
|
54
|
-
throw err;
|
|
55
|
-
}
|
|
56
|
-
throw err;
|
|
57
|
-
}
|
|
58
|
-
try {
|
|
59
|
-
await store.fetcher.load(preferencesFile);
|
|
60
|
-
}
|
|
61
|
-
catch (err) { // Maybe a permission problem or origin problem
|
|
62
|
-
const msg = `Unable to load preference of user ${user}: ${err}`;
|
|
63
|
-
debug.warn(msg);
|
|
64
|
-
if (err.response.status === 401) {
|
|
65
|
-
throw new UnauthorizedError();
|
|
66
|
-
}
|
|
67
|
-
if (err.response.status === 403) {
|
|
68
|
-
if (differentOrigin(preferencesFile)) {
|
|
69
|
-
throw new CrossOriginForbiddenError();
|
|
70
|
-
}
|
|
71
|
-
throw new SameOriginForbiddenError();
|
|
72
|
-
}
|
|
73
|
-
/*if (err.response.status === 404) {
|
|
74
|
-
throw new NotFoundError();
|
|
75
|
-
}*/
|
|
76
|
-
throw new Error(msg);
|
|
77
|
-
}
|
|
78
|
-
return preferencesFile;
|
|
79
|
-
}
|
|
80
|
-
async function loadProfile(user) {
|
|
81
|
-
if (!user) {
|
|
82
|
-
throw new Error('loadProfile: no user given.');
|
|
83
|
-
}
|
|
84
|
-
try {
|
|
85
|
-
await store.fetcher.load(user.doc());
|
|
86
|
-
}
|
|
87
|
-
catch (err) {
|
|
88
|
-
throw new Error(`Unable to load profile of user ${user}: ${err}`);
|
|
89
|
-
}
|
|
90
|
-
return user.doc();
|
|
91
|
-
}
|
|
92
|
-
async function loadMe() {
|
|
93
|
-
const me = authn.currentUser();
|
|
94
|
-
if (me === null) {
|
|
95
|
-
throw new Error('Current user not found! Not logged in?');
|
|
96
|
-
}
|
|
97
|
-
await store.fetcher.load(me.doc());
|
|
98
|
-
return me;
|
|
99
|
-
}
|
|
100
|
-
function getPodRoot(user) {
|
|
101
|
-
const podRoot = findStorage(user);
|
|
102
|
-
if (!podRoot) {
|
|
103
|
-
throw new Error('User pod root not found!');
|
|
104
|
-
}
|
|
105
|
-
return podRoot;
|
|
106
|
-
}
|
|
107
|
-
async function getMainInbox(user) {
|
|
108
|
-
await store.fetcher.load(user);
|
|
109
|
-
const mainInbox = store.any(user, ns.ldp('inbox'), undefined, user.doc());
|
|
110
|
-
if (!mainInbox) {
|
|
111
|
-
throw new Error('User main inbox not found!');
|
|
112
|
-
}
|
|
113
|
-
return mainInbox;
|
|
114
|
-
}
|
|
115
|
-
function findStorage(me) {
|
|
116
|
-
return store.any(me, ns.space('storage'), undefined, me.doc());
|
|
117
|
-
}
|
|
118
|
-
return {
|
|
119
|
-
loadMe,
|
|
120
|
-
getPodRoot,
|
|
121
|
-
getMainInbox,
|
|
122
|
-
findStorage,
|
|
123
|
-
loadPreferences,
|
|
124
|
-
loadProfile,
|
|
125
|
-
silencedLoadPreferences
|
|
126
|
-
};
|
|
127
|
-
}
|
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AC;YACb,MAAM,IAAI,KAAK,CAAC,4BAA4B,CAAC,CAAA;QACjD,CAAC;QACD,OAAO,SAAsB,CAAA;IACjC,CAAC;IAED,SAAS,WAAW,CAAC,EAAa;QAC9B,OAAO,KAAK,CAAC,GAAG,CAAC,EAAE,EAAE,EAAE,CAAC,KAAK,CAAC,SAAS,CAAC,EAAE,SAAS,EAAE,EAAE,CAAC,GAAG,EAAE,CAAC,CAAA;IAClE,CAAC;IAED,OAAO;QACH,MAAM;QACN,UAAU;QACV,YAAY;QACZ,WAAW;QACX,eAAe;QACf,WAAW;QACX,uBAAuB;KAC1B,CAAA;AACL,CAAC"}
|
|
@@ -1,236 +0,0 @@
|
|
|
1
|
-
import { st, sym } from 'rdflib';
|
|
2
|
-
import * as debug from '../util/debug';
|
|
3
|
-
import { ns as namespace } from '../util/ns';
|
|
4
|
-
import { newThing } from '../util/utils';
|
|
5
|
-
export function createTypeIndexLogic(store, authn, profileLogic, utilityLogic) {
|
|
6
|
-
const ns = namespace;
|
|
7
|
-
function isAbsoluteHttpUri(uri) {
|
|
8
|
-
return !!uri && (uri.startsWith('https://') || uri.startsWith('http://'));
|
|
9
|
-
}
|
|
10
|
-
function getRegistrations(instance, theClass) {
|
|
11
|
-
return store
|
|
12
|
-
.each(undefined, ns.solid('instance'), instance)
|
|
13
|
-
.filter((r) => {
|
|
14
|
-
return store.holds(r, ns.solid('forClass'), theClass);
|
|
15
|
-
});
|
|
16
|
-
}
|
|
17
|
-
async function loadTypeIndexesFor(user) {
|
|
18
|
-
if (!user)
|
|
19
|
-
throw new Error('loadTypeIndexesFor: No user given');
|
|
20
|
-
const profile = await profileLogic.loadProfile(user);
|
|
21
|
-
let suggestion = null;
|
|
22
|
-
try {
|
|
23
|
-
suggestion = suggestPublicTypeIndex(user);
|
|
24
|
-
}
|
|
25
|
-
catch (err) {
|
|
26
|
-
const message = `User ${user} has no usable profile document directory for publicTypeIndex.`;
|
|
27
|
-
debug.warn(message);
|
|
28
|
-
}
|
|
29
|
-
let publicTypeIndex;
|
|
30
|
-
try {
|
|
31
|
-
publicTypeIndex =
|
|
32
|
-
store.any(user, ns.solid('publicTypeIndex'), undefined, profile) ||
|
|
33
|
-
(suggestion
|
|
34
|
-
? await utilityLogic.followOrCreateLink(user, ns.solid('publicTypeIndex'), suggestion, profile)
|
|
35
|
-
: null);
|
|
36
|
-
}
|
|
37
|
-
catch (err) {
|
|
38
|
-
const message = `User ${user} has no pointer in profile to publicTypeIndex file: ${err}`;
|
|
39
|
-
debug.warn(message);
|
|
40
|
-
}
|
|
41
|
-
const publicScopes = publicTypeIndex ? [{ label: 'public', index: publicTypeIndex, agent: user }] : [];
|
|
42
|
-
let preferencesFile;
|
|
43
|
-
try {
|
|
44
|
-
preferencesFile = await profileLogic.silencedLoadPreferences(user);
|
|
45
|
-
}
|
|
46
|
-
catch (err) {
|
|
47
|
-
preferencesFile = null;
|
|
48
|
-
}
|
|
49
|
-
let privateScopes;
|
|
50
|
-
if (preferencesFile) { // watch out - can be in either as spec was not clear. Legacy is profile.
|
|
51
|
-
// If there is a legacy one linked from the profile, use that.
|
|
52
|
-
// Otherwiae use or make one linked from Preferences
|
|
53
|
-
let suggestedPrivateTypeIndex = null;
|
|
54
|
-
try {
|
|
55
|
-
suggestedPrivateTypeIndex = suggestPrivateTypeIndex(preferencesFile);
|
|
56
|
-
}
|
|
57
|
-
catch (err) {
|
|
58
|
-
const message = `User ${user} has no usable preferences document directory for privateTypeIndex.`;
|
|
59
|
-
debug.warn(message);
|
|
60
|
-
}
|
|
61
|
-
let privateTypeIndex;
|
|
62
|
-
try {
|
|
63
|
-
privateTypeIndex = store.any(user, ns.solid('privateTypeIndex'), undefined, profile) ||
|
|
64
|
-
(suggestedPrivateTypeIndex
|
|
65
|
-
? await utilityLogic.followOrCreateLink(user, ns.solid('privateTypeIndex'), suggestedPrivateTypeIndex, preferencesFile)
|
|
66
|
-
: null);
|
|
67
|
-
}
|
|
68
|
-
catch (err) {
|
|
69
|
-
const message = `User ${user} has no pointer in preference file to privateTypeIndex file: ${err}`;
|
|
70
|
-
debug.warn(message);
|
|
71
|
-
}
|
|
72
|
-
privateScopes = privateTypeIndex ? [{ label: 'private', index: privateTypeIndex, agent: user }] : [];
|
|
73
|
-
}
|
|
74
|
-
else {
|
|
75
|
-
privateScopes = [];
|
|
76
|
-
}
|
|
77
|
-
const scopes = publicScopes.concat(privateScopes);
|
|
78
|
-
if (scopes.length === 0)
|
|
79
|
-
return scopes;
|
|
80
|
-
const files = scopes.map(scope => scope.index);
|
|
81
|
-
try {
|
|
82
|
-
await store.fetcher.load(files);
|
|
83
|
-
}
|
|
84
|
-
catch (err) {
|
|
85
|
-
debug.warn('Problems loading type index: ', err);
|
|
86
|
-
}
|
|
87
|
-
return scopes;
|
|
88
|
-
}
|
|
89
|
-
async function loadCommunityTypeIndexes(user) {
|
|
90
|
-
let preferencesFile;
|
|
91
|
-
try {
|
|
92
|
-
preferencesFile = await profileLogic.silencedLoadPreferences(user);
|
|
93
|
-
}
|
|
94
|
-
catch (err) {
|
|
95
|
-
const message = `User ${user} has no pointer in profile to preferences file.`;
|
|
96
|
-
debug.warn(message);
|
|
97
|
-
}
|
|
98
|
-
if (preferencesFile) { // For now, pick up communities as simple links from the preferences file.
|
|
99
|
-
const communities = store.each(user, ns.solid('community'), undefined, preferencesFile).concat(store.each(user, ns.solid('community'), undefined, user.doc()));
|
|
100
|
-
let result = [];
|
|
101
|
-
for (const org of communities) {
|
|
102
|
-
if (org.termType !== 'NamedNode' || !isAbsoluteHttpUri(org.uri)) {
|
|
103
|
-
debug.warn(`Skipping malformed community node for ${user}: ${org}`);
|
|
104
|
-
continue;
|
|
105
|
-
}
|
|
106
|
-
try {
|
|
107
|
-
result = result.concat(await loadTypeIndexesFor(org));
|
|
108
|
-
}
|
|
109
|
-
catch (err) {
|
|
110
|
-
debug.warn(`Skipping community type indexes for ${org.uri}: ${err}`);
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
return result;
|
|
114
|
-
}
|
|
115
|
-
return []; // No communities
|
|
116
|
-
}
|
|
117
|
-
async function loadAllTypeIndexes(user) {
|
|
118
|
-
return (await loadTypeIndexesFor(user)).concat(await loadCommunityTypeIndexes(user));
|
|
119
|
-
}
|
|
120
|
-
async function getScopedAppInstances(klass, user) {
|
|
121
|
-
const scopes = await loadAllTypeIndexes(user);
|
|
122
|
-
let scopedApps = [];
|
|
123
|
-
for (const scope of scopes) {
|
|
124
|
-
const scopedApps0 = await getScopedAppsFromIndex(scope, klass);
|
|
125
|
-
scopedApps = scopedApps.concat(scopedApps0);
|
|
126
|
-
}
|
|
127
|
-
return scopedApps;
|
|
128
|
-
}
|
|
129
|
-
// This is the function signature which used to be in solid-ui/logic
|
|
130
|
-
// Recommended to use getScopedAppInstances instead as it provides more information.
|
|
131
|
-
//
|
|
132
|
-
async function getAppInstances(klass) {
|
|
133
|
-
const user = authn.currentUser();
|
|
134
|
-
if (!user)
|
|
135
|
-
throw new Error('getAppInstances: Must be logged in to find apps.');
|
|
136
|
-
const scopedAppInstances = await getScopedAppInstances(klass, user);
|
|
137
|
-
return scopedAppInstances.map(scoped => scoped.instance);
|
|
138
|
-
}
|
|
139
|
-
function docDirUri(node) {
|
|
140
|
-
const doc = node.doc();
|
|
141
|
-
const dir = doc.dir();
|
|
142
|
-
if ((dir === null || dir === void 0 ? void 0 : dir.uri) && isAbsoluteHttpUri(dir.uri))
|
|
143
|
-
return dir.uri;
|
|
144
|
-
const docUri = doc.uri;
|
|
145
|
-
if (!docUri || !isAbsoluteHttpUri(docUri)) {
|
|
146
|
-
debug.log(`docDirUri: missing or non-http(s) doc uri for ${node === null || node === void 0 ? void 0 : node.uri}`);
|
|
147
|
-
return null;
|
|
148
|
-
}
|
|
149
|
-
const withoutFragment = docUri.split('#')[0];
|
|
150
|
-
const lastSlash = withoutFragment.lastIndexOf('/');
|
|
151
|
-
if (lastSlash === -1) {
|
|
152
|
-
debug.log(`docDirUri: no slash in doc uri ${docUri}`);
|
|
153
|
-
return null;
|
|
154
|
-
}
|
|
155
|
-
return withoutFragment.slice(0, lastSlash + 1);
|
|
156
|
-
}
|
|
157
|
-
function suggestPublicTypeIndex(me) {
|
|
158
|
-
const dirUri = docDirUri(me);
|
|
159
|
-
if (!dirUri)
|
|
160
|
-
throw new Error(`suggestPublicTypeIndex: Cannot derive directory for ${me.uri}`);
|
|
161
|
-
return sym(dirUri + 'publicTypeIndex.ttl');
|
|
162
|
-
}
|
|
163
|
-
// Note this one is based off the pref file not the profile
|
|
164
|
-
function suggestPrivateTypeIndex(preferencesFile) {
|
|
165
|
-
const dirUri = docDirUri(preferencesFile);
|
|
166
|
-
if (!dirUri)
|
|
167
|
-
throw new Error(`suggestPrivateTypeIndex: Cannot derive directory for ${preferencesFile.uri}`);
|
|
168
|
-
return sym(dirUri + 'privateTypeIndex.ttl');
|
|
169
|
-
}
|
|
170
|
-
/*
|
|
171
|
-
* Register a new app in a type index
|
|
172
|
-
* used in chat in bookmark.js (solid-ui)
|
|
173
|
-
* Returns the registration object if successful else null
|
|
174
|
-
*/
|
|
175
|
-
async function registerInTypeIndex(instance, index, theClass) {
|
|
176
|
-
const registration = newThing(index);
|
|
177
|
-
const ins = [
|
|
178
|
-
// See https://github.com/solid/solid/blob/main/proposals/data-discovery.md
|
|
179
|
-
st(registration, ns.rdf('type'), ns.solid('TypeRegistration'), index),
|
|
180
|
-
st(registration, ns.solid('forClass'), theClass, index),
|
|
181
|
-
st(registration, ns.solid('instance'), instance, index)
|
|
182
|
-
];
|
|
183
|
-
try {
|
|
184
|
-
await store.updater.update([], ins);
|
|
185
|
-
}
|
|
186
|
-
catch (err) {
|
|
187
|
-
const msg = `Unable to register ${instance} in index ${index}: ${err}`;
|
|
188
|
-
console.warn(msg);
|
|
189
|
-
return null;
|
|
190
|
-
}
|
|
191
|
-
return registration;
|
|
192
|
-
}
|
|
193
|
-
async function deleteTypeIndexRegistration(item) {
|
|
194
|
-
const reg = store.the(null, ns.solid('instance'), item.instance, item.scope.index);
|
|
195
|
-
if (!reg)
|
|
196
|
-
throw new Error(`deleteTypeIndexRegistration: No registration found for ${item.instance}`);
|
|
197
|
-
const statements = store.statementsMatching(reg, null, null, item.scope.index);
|
|
198
|
-
await store.updater.update(statements, []);
|
|
199
|
-
}
|
|
200
|
-
async function getScopedAppsFromIndex(scope, theClass) {
|
|
201
|
-
const index = scope.index;
|
|
202
|
-
const results = [];
|
|
203
|
-
const registrations = store.statementsMatching(null, ns.solid('instance'), null, index)
|
|
204
|
-
.concat(store.statementsMatching(null, ns.solid('instanceContainer'), null, index))
|
|
205
|
-
.map(st => st.subject);
|
|
206
|
-
for (const reg of registrations) {
|
|
207
|
-
const klass = store.any(reg, ns.solid('forClass'), null, index);
|
|
208
|
-
if (!theClass || klass.sameTerm(theClass)) {
|
|
209
|
-
const instances = store.each(reg, ns.solid('instance'), null, index);
|
|
210
|
-
for (const instance of instances) {
|
|
211
|
-
results.push({ instance, type: klass, scope });
|
|
212
|
-
}
|
|
213
|
-
const containers = store.each(reg, ns.solid('instanceContainer'), null, index);
|
|
214
|
-
for (const instance of containers) {
|
|
215
|
-
await store.fetcher.load(instance);
|
|
216
|
-
results.push({ instance: sym(instance.value), type: klass, scope });
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
return results;
|
|
221
|
-
}
|
|
222
|
-
return {
|
|
223
|
-
registerInTypeIndex,
|
|
224
|
-
getRegistrations,
|
|
225
|
-
loadTypeIndexesFor,
|
|
226
|
-
loadCommunityTypeIndexes,
|
|
227
|
-
loadAllTypeIndexes,
|
|
228
|
-
getScopedAppInstances,
|
|
229
|
-
getAppInstances,
|
|
230
|
-
suggestPublicTypeIndex,
|
|
231
|
-
suggestPrivateTypeIndex,
|
|
232
|
-
deleteTypeIndexRegistration,
|
|
233
|
-
getScopedAppsFromIndex
|
|
234
|
-
};
|
|
235
|
-
}
|
|
236
|
-
//# sourceMappingURL=typeIndexLogic.js.map
|