solid-logic 4.0.8-3 → 5.0.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 +4 -3
- package/dist/2729812e0bfc062ee77a.js +1 -0
- package/dist/a9c30b64ceaae48b72f0.js +2045 -0
- package/dist/acl/aclLogic.d.ts +5 -0
- package/dist/acl/aclLogic.d.ts.map +1 -0
- package/dist/authSession/authSession.d.ts +42 -0
- package/dist/authSession/authSession.d.ts.map +1 -0
- 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 +42 -0
- package/dist/authn/SolidAuthnLogic.d.ts.map +1 -0
- package/dist/authn/authUtil.d.ts +17 -0
- package/dist/authn/authUtil.d.ts.map +1 -0
- package/dist/authn/serverLogout.d.ts +6 -0
- package/dist/authn/serverLogout.d.ts.map +1 -0
- package/dist/chat/chatLogic.d.ts +3 -0
- package/dist/chat/chatLogic.d.ts.map +1 -0
- package/dist/inbox/inboxLogic.d.ts +3 -0
- package/dist/inbox/inboxLogic.d.ts.map +1 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/issuer/issuerLogic.d.ts +8 -0
- package/dist/issuer/issuerLogic.d.ts.map +1 -0
- package/dist/logic/CustomError.d.ts +21 -0
- package/dist/logic/CustomError.d.ts.map +1 -0
- package/dist/logic/solidLogic.d.ts +6 -0
- package/dist/logic/solidLogic.d.ts.map +1 -0
- package/dist/logic/solidLogicSingleton.d.ts +4 -0
- package/dist/logic/solidLogicSingleton.d.ts.map +1 -0
- 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 +3 -0
- package/dist/profile/profileLogic.d.ts.map +1 -0
- package/dist/solid-logic.esm.js +2358 -0
- package/dist/solid-logic.esm.js.map +1 -0
- package/dist/solid-logic.esm.min.js +2 -0
- package/dist/solid-logic.esm.min.js.map +1 -0
- package/dist/solid-logic.js +7548 -0
- package/dist/solid-logic.js.map +1 -0
- package/dist/solid-logic.min.js +2 -0
- package/dist/solid-logic.min.js.map +1 -0
- 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 +3 -0
- package/dist/typeIndex/typeIndexLogic.d.ts.map +1 -0
- package/dist/types.d.ts +113 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/util/containerLogic.d.ts +11 -0
- package/dist/util/containerLogic.d.ts.map +1 -0
- package/dist/util/debug.d.ts +5 -0
- package/dist/util/debug.d.ts.map +1 -0
- package/dist/util/ns.d.ts +2 -0
- package/dist/util/ns.d.ts.map +1 -0
- package/dist/util/utilityLogic.d.ts +17 -0
- package/dist/util/utilityLogic.d.ts.map +1 -0
- package/dist/util/utils.d.ts +8 -0
- package/dist/util/utils.d.ts.map +1 -0
- package/package.json +33 -27
- package/dist/_virtual/_rolldown/runtime.cjs.js +0 -1
- package/dist/acl/aclLogic.cjs.js +0 -2
- package/dist/acl/aclLogic.cjs.js.map +0 -1
- package/dist/acl/aclLogic.esm.js +0 -56
- package/dist/acl/aclLogic.esm.js.map +0 -1
- package/dist/authSession/authSession.cjs.js +0 -2
- package/dist/authSession/authSession.cjs.js.map +0 -1
- package/dist/authSession/authSession.esm.js +0 -22
- package/dist/authSession/authSession.esm.js.map +0 -1
- package/dist/authSession/events.cjs.js +0 -2
- package/dist/authSession/events.cjs.js.map +0 -1
- package/dist/authSession/events.esm.js +0 -19
- package/dist/authSession/events.esm.js.map +0 -1
- package/dist/authSession/issuer.cjs.js +0 -2
- package/dist/authSession/issuer.cjs.js.map +0 -1
- package/dist/authSession/issuer.esm.js +0 -18
- package/dist/authSession/issuer.esm.js.map +0 -1
- package/dist/authSession/session.cjs.js +0 -2
- package/dist/authSession/session.cjs.js.map +0 -1
- package/dist/authSession/session.esm.js +0 -102
- package/dist/authSession/session.esm.js.map +0 -1
- package/dist/authn/SolidAuthnLogic.cjs.js +0 -2
- package/dist/authn/SolidAuthnLogic.cjs.js.map +0 -1
- package/dist/authn/SolidAuthnLogic.esm.js +0 -116
- package/dist/authn/SolidAuthnLogic.esm.js.map +0 -1
- package/dist/authn/authUtil.cjs.js +0 -2
- package/dist/authn/authUtil.cjs.js.map +0 -1
- package/dist/authn/authUtil.esm.js +0 -33
- package/dist/authn/authUtil.esm.js.map +0 -1
- package/dist/authn/serverLogout.cjs.js +0 -2
- package/dist/authn/serverLogout.cjs.js.map +0 -1
- package/dist/authn/serverLogout.esm.js +0 -25
- package/dist/authn/serverLogout.esm.js.map +0 -1
- package/dist/chat/chatLogic.cjs.js +0 -21
- package/dist/chat/chatLogic.cjs.js.map +0 -1
- package/dist/chat/chatLogic.esm.js +0 -116
- package/dist/chat/chatLogic.esm.js.map +0 -1
- package/dist/inbox/inboxLogic.cjs.js +0 -2
- package/dist/inbox/inboxLogic.cjs.js.map +0 -1
- package/dist/inbox/inboxLogic.esm.js +0 -37
- package/dist/inbox/inboxLogic.esm.js.map +0 -1
- package/dist/index.cjs.js +0 -2
- package/dist/index.cjs.js.map +0 -1
- package/dist/index.esm.js +0 -13
- package/dist/index.esm.js.map +0 -1
- package/dist/issuer/issuerLogic.cjs.js +0 -2
- package/dist/issuer/issuerLogic.cjs.js.map +0 -1
- package/dist/issuer/issuerLogic.esm.js +0 -30
- package/dist/issuer/issuerLogic.esm.js.map +0 -1
- package/dist/logic/CustomError.cjs.js +0 -2
- package/dist/logic/CustomError.cjs.js.map +0 -1
- package/dist/logic/CustomError.esm.js +0 -14
- package/dist/logic/CustomError.esm.js.map +0 -1
- package/dist/logic/solidLogic.cjs.js +0 -2
- package/dist/logic/solidLogic.cjs.js.map +0 -1
- package/dist/logic/solidLogic.esm.js +0 -47
- package/dist/logic/solidLogic.esm.js.map +0 -1
- package/dist/logic/solidLogicSingleton.cjs.js +0 -2
- package/dist/logic/solidLogicSingleton.cjs.js.map +0 -1
- package/dist/logic/solidLogicSingleton.esm.js +0 -19
- package/dist/logic/solidLogicSingleton.esm.js.map +0 -1
- package/dist/profile/profileAclDocuments.cjs.js +0 -3
- package/dist/profile/profileAclDocuments.cjs.js.map +0 -1
- package/dist/profile/profileAclDocuments.esm.js +0 -17
- package/dist/profile/profileAclDocuments.esm.js.map +0 -1
- package/dist/profile/profileDocuments.cjs.js +0 -3
- package/dist/profile/profileDocuments.cjs.js.map +0 -1
- package/dist/profile/profileDocuments.esm.js +0 -15
- package/dist/profile/profileDocuments.esm.js.map +0 -1
- package/dist/profile/profileLogic.cjs.js +0 -2
- package/dist/profile/profileLogic.cjs.js.map +0 -1
- package/dist/profile/profileLogic.esm.js +0 -184
- package/dist/profile/profileLogic.esm.js.map +0 -1
- package/dist/typeIndex/typeIndexAclDocuments.cjs.js +0 -3
- package/dist/typeIndex/typeIndexAclDocuments.cjs.js.map +0 -1
- package/dist/typeIndex/typeIndexAclDocuments.esm.js +0 -35
- package/dist/typeIndex/typeIndexAclDocuments.esm.js.map +0 -1
- package/dist/typeIndex/typeIndexDocuments.cjs.js +0 -4
- package/dist/typeIndex/typeIndexDocuments.cjs.js.map +0 -1
- package/dist/typeIndex/typeIndexDocuments.esm.js +0 -21
- package/dist/typeIndex/typeIndexDocuments.esm.js.map +0 -1
- package/dist/typeIndex/typeIndexLogic.cjs.js +0 -2
- package/dist/typeIndex/typeIndexLogic.cjs.js.map +0 -1
- package/dist/typeIndex/typeIndexLogic.esm.js +0 -185
- package/dist/typeIndex/typeIndexLogic.esm.js.map +0 -1
- package/dist/util/containerLogic.cjs.js +0 -2
- package/dist/util/containerLogic.cjs.js.map +0 -1
- package/dist/util/containerLogic.esm.js +0 -37
- package/dist/util/containerLogic.esm.js.map +0 -1
- package/dist/util/debug.cjs.js +0 -2
- package/dist/util/debug.cjs.js.map +0 -1
- package/dist/util/debug.esm.js +0 -11
- package/dist/util/debug.esm.js.map +0 -1
- package/dist/util/ns.cjs.js +0 -2
- package/dist/util/ns.cjs.js.map +0 -1
- package/dist/util/ns.esm.js +0 -8
- package/dist/util/ns.esm.js.map +0 -1
- package/dist/util/utilityLogic.cjs.js +0 -6
- package/dist/util/utilityLogic.cjs.js.map +0 -1
- package/dist/util/utilityLogic.esm.js +0 -149
- package/dist/util/utilityLogic.esm.js.map +0 -1
- package/dist/util/utils.cjs.js +0 -2
- package/dist/util/utils.cjs.js.map +0 -1
- package/dist/util/utils.esm.js +0 -22
- package/dist/util/utils.esm.js.map +0 -1
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
const e=require("../util/utils.cjs.js");function t(t,n,r,i,a){async function o(e,t){let a=await n.loadMe(),o=`${(await n.getPodRoot(a)).value}p2p-inboxes/${encodeURIComponent(t)}/`;return await i.createContainer(o),await r.setSinglePeerAccess({ownerWebId:a.value,peerWebId:e,accessToModes:`acl:Append`,target:o}),o}async function s(e){e||=await n.loadMe();let t=await n.getMainInbox(e);return(await i.getContainerMembers(t)).filter(e=>!i.isContainer(e))}async function c(n,r){let i=await t.fetcher._fetch(n);if(i.status!==200)throw Error(`Not OK! ${n}`);let a=e.getArchiveUrl(n,r),o={method:`PUT`,body:await i.text(),headers:[[`Content-Type`,i.headers.get(`Content-Type`)||`application/octet-stream`]]};(await t.fetcher._fetch(a,o)).status.toString()[0]===`2`&&await t.fetcher._fetch(n,{method:`DELETE`})}return{createInboxFor:o,getNewMessages:s,markAsRead:c}}exports.createInboxLogic=t;
|
|
2
|
-
//# sourceMappingURL=inboxLogic.cjs.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"inboxLogic.cjs.js","names":[],"sources":["../../src/inbox/inboxLogic.ts"],"sourcesContent":["import { NamedNode } from 'rdflib'\nimport { InboxLogic } from '../types'\nimport { getArchiveUrl } from '../util/utils'\n\nexport function createInboxLogic(store, profileLogic, utilityLogic, containerLogic, aclLogic): InboxLogic {\n\n async function createInboxFor(peerWebId: string, nick: string) {\n const myWebId: NamedNode = await profileLogic.loadMe()\n const podRoot: NamedNode = await profileLogic.getPodRoot(myWebId)\n const ourInbox = `${podRoot.value}p2p-inboxes/${encodeURIComponent(nick)}/`\n await containerLogic.createContainer(ourInbox)\n // const aclDocUrl = await aclLogic.findAclDocUrl(ourInbox);\n await utilityLogic.setSinglePeerAccess({\n ownerWebId: myWebId.value,\n peerWebId,\n accessToModes: 'acl:Append',\n target: ourInbox\n })\n return ourInbox\n }\n\n async function getNewMessages(\n user?: NamedNode\n ): Promise<NamedNode[]> {\n if (!user) {\n user = await profileLogic.loadMe()\n }\n const inbox = await profileLogic.getMainInbox(user)\n const urls = await containerLogic.getContainerMembers(inbox)\n return urls.filter(url => !containerLogic.isContainer(url))\n }\n\n async function markAsRead(url: string, date: Date) {\n const downloaded = await store.fetcher._fetch(url)\n if (downloaded.status !== 200) {\n throw new Error(`Not OK! ${url}`)\n }\n const archiveUrl = getArchiveUrl(url, date)\n const options = {\n method: 'PUT',\n body: await downloaded.text(),\n headers: [\n ['Content-Type', downloaded.headers.get('Content-Type') || 'application/octet-stream']\n ]\n }\n const uploaded = await store.fetcher._fetch(archiveUrl, options)\n if (uploaded.status.toString()[0] === '2') {\n await store.fetcher._fetch(url, {\n method: 'DELETE'\n })\n }\n }\n return {\n createInboxFor,\n getNewMessages,\n markAsRead\n }\n}\n"],"mappings":"wCAIA,SAAgB,EAAiB,EAAO,EAAc,EAAc,EAAgB,EAAsB,CAEtG,eAAe,EAAe,EAAmB,EAAc,CAC7D,IAAM,EAAqB,MAAM,EAAa,OAAO,EAE/C,EAAW,IAAG,MADa,EAAa,WAAW,CAAO,EAAA,CACpC,MAAM,cAAc,mBAAmB,CAAI,EAAE,GASzE,OARA,MAAM,EAAe,gBAAgB,CAAQ,EAE7C,MAAM,EAAa,oBAAoB,CACrC,WAAY,EAAQ,MACpB,YACA,cAAe,aACf,OAAQ,CACV,CAAC,EACM,CACX,CAEA,eAAe,EACX,EACsB,CACtB,AACE,IAAO,MAAM,EAAa,OAAO,EAEnC,IAAM,EAAQ,MAAM,EAAa,aAAa,CAAI,EAElD,OAAO,MADY,EAAe,oBAAoB,CAAK,EAAA,CAC/C,OAAO,GAAO,CAAC,EAAe,YAAY,CAAG,CAAC,CAC9D,CAEA,eAAe,EAAW,EAAa,EAAY,CACjD,IAAM,EAAa,MAAM,EAAM,QAAQ,OAAO,CAAG,EACjD,GAAI,EAAW,SAAW,IACxB,MAAU,MAAM,WAAW,GAAK,EAElC,IAAM,EAAa,EAAA,cAAc,EAAK,CAAI,EACpC,EAAU,CACd,OAAQ,MACR,KAAM,MAAM,EAAW,KAAK,EAC5B,QAAS,CACP,CAAC,eAAgB,EAAW,QAAQ,IAAI,cAAc,GAAK,0BAA0B,CACvF,CACF,GAEI,MADmB,EAAM,QAAQ,OAAO,EAAY,CAAO,EAAA,CAClD,OAAO,SAAS,CAAC,CAAC,KAAO,KACpC,MAAM,EAAM,QAAQ,OAAO,EAAK,CAC9B,OAAQ,QACV,CAAC,CAEL,CACA,MAAO,CACL,iBACA,iBACA,YACF,CACF"}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { getArchiveUrl as e } from "../util/utils.esm.js";
|
|
2
|
-
//#region src/inbox/inboxLogic.ts
|
|
3
|
-
function t(t, n, r, i, a) {
|
|
4
|
-
async function o(e, t) {
|
|
5
|
-
let a = await n.loadMe(), o = `${(await n.getPodRoot(a)).value}p2p-inboxes/${encodeURIComponent(t)}/`;
|
|
6
|
-
return await i.createContainer(o), await r.setSinglePeerAccess({
|
|
7
|
-
ownerWebId: a.value,
|
|
8
|
-
peerWebId: e,
|
|
9
|
-
accessToModes: "acl:Append",
|
|
10
|
-
target: o
|
|
11
|
-
}), o;
|
|
12
|
-
}
|
|
13
|
-
async function s(e) {
|
|
14
|
-
e ||= await n.loadMe();
|
|
15
|
-
let t = await n.getMainInbox(e);
|
|
16
|
-
return (await i.getContainerMembers(t)).filter((e) => !i.isContainer(e));
|
|
17
|
-
}
|
|
18
|
-
async function c(n, r) {
|
|
19
|
-
let i = await t.fetcher._fetch(n);
|
|
20
|
-
if (i.status !== 200) throw Error(`Not OK! ${n}`);
|
|
21
|
-
let a = e(n, r), o = {
|
|
22
|
-
method: "PUT",
|
|
23
|
-
body: await i.text(),
|
|
24
|
-
headers: [["Content-Type", i.headers.get("Content-Type") || "application/octet-stream"]]
|
|
25
|
-
};
|
|
26
|
-
(await t.fetcher._fetch(a, o)).status.toString()[0] === "2" && await t.fetcher._fetch(n, { method: "DELETE" });
|
|
27
|
-
}
|
|
28
|
-
return {
|
|
29
|
-
createInboxFor: o,
|
|
30
|
-
getNewMessages: s,
|
|
31
|
-
markAsRead: c
|
|
32
|
-
};
|
|
33
|
-
}
|
|
34
|
-
//#endregion
|
|
35
|
-
export { t as createInboxLogic };
|
|
36
|
-
|
|
37
|
-
//# sourceMappingURL=inboxLogic.esm.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"inboxLogic.esm.js","names":[],"sources":["../../src/inbox/inboxLogic.ts"],"sourcesContent":["import { NamedNode } from 'rdflib'\nimport { InboxLogic } from '../types'\nimport { getArchiveUrl } from '../util/utils'\n\nexport function createInboxLogic(store, profileLogic, utilityLogic, containerLogic, aclLogic): InboxLogic {\n\n async function createInboxFor(peerWebId: string, nick: string) {\n const myWebId: NamedNode = await profileLogic.loadMe()\n const podRoot: NamedNode = await profileLogic.getPodRoot(myWebId)\n const ourInbox = `${podRoot.value}p2p-inboxes/${encodeURIComponent(nick)}/`\n await containerLogic.createContainer(ourInbox)\n // const aclDocUrl = await aclLogic.findAclDocUrl(ourInbox);\n await utilityLogic.setSinglePeerAccess({\n ownerWebId: myWebId.value,\n peerWebId,\n accessToModes: 'acl:Append',\n target: ourInbox\n })\n return ourInbox\n }\n\n async function getNewMessages(\n user?: NamedNode\n ): Promise<NamedNode[]> {\n if (!user) {\n user = await profileLogic.loadMe()\n }\n const inbox = await profileLogic.getMainInbox(user)\n const urls = await containerLogic.getContainerMembers(inbox)\n return urls.filter(url => !containerLogic.isContainer(url))\n }\n\n async function markAsRead(url: string, date: Date) {\n const downloaded = await store.fetcher._fetch(url)\n if (downloaded.status !== 200) {\n throw new Error(`Not OK! ${url}`)\n }\n const archiveUrl = getArchiveUrl(url, date)\n const options = {\n method: 'PUT',\n body: await downloaded.text(),\n headers: [\n ['Content-Type', downloaded.headers.get('Content-Type') || 'application/octet-stream']\n ]\n }\n const uploaded = await store.fetcher._fetch(archiveUrl, options)\n if (uploaded.status.toString()[0] === '2') {\n await store.fetcher._fetch(url, {\n method: 'DELETE'\n })\n }\n }\n return {\n createInboxFor,\n getNewMessages,\n markAsRead\n }\n}\n"],"mappings":";;AAIA,SAAgB,EAAiB,GAAO,GAAc,GAAc,GAAgB,GAAsB;CAEtG,eAAe,EAAe,GAAmB,GAAc;EAC7D,IAAM,IAAqB,MAAM,EAAa,OAAO,GAE/C,IAAW,IAAG,MADa,EAAa,WAAW,CAAO,EAAA,CACpC,MAAM,cAAc,mBAAmB,CAAI,EAAE;EASzE,OARA,MAAM,EAAe,gBAAgB,CAAQ,GAE7C,MAAM,EAAa,oBAAoB;GACrC,YAAY,EAAQ;GACpB;GACA,eAAe;GACf,QAAQ;EACV,CAAC,GACM;CACX;CAEA,eAAe,EACX,GACsB;EACtB,AACE,MAAO,MAAM,EAAa,OAAO;EAEnC,IAAM,IAAQ,MAAM,EAAa,aAAa,CAAI;EAElD,QAAO,MADY,EAAe,oBAAoB,CAAK,EAAA,CAC/C,QAAO,MAAO,CAAC,EAAe,YAAY,CAAG,CAAC;CAC9D;CAEA,eAAe,EAAW,GAAa,GAAY;EACjD,IAAM,IAAa,MAAM,EAAM,QAAQ,OAAO,CAAG;EACjD,IAAI,EAAW,WAAW,KACxB,MAAU,MAAM,WAAW,GAAK;EAElC,IAAM,IAAa,EAAc,GAAK,CAAI,GACpC,IAAU;GACd,QAAQ;GACR,MAAM,MAAM,EAAW,KAAK;GAC5B,SAAS,CACP,CAAC,gBAAgB,EAAW,QAAQ,IAAI,cAAc,KAAK,0BAA0B,CACvF;EACF;EAEA,CAAI,MADmB,EAAM,QAAQ,OAAO,GAAY,CAAO,EAAA,CAClD,OAAO,SAAS,CAAC,CAAC,OAAO,OACpC,MAAM,EAAM,QAAQ,OAAO,GAAK,EAC9B,QAAQ,SACV,CAAC;CAEL;CACA,OAAO;EACL;EACA;EACA;CACF;AACF"}
|
package/dist/index.cjs.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./acl/aclLogic.cjs.js"),t=require("./authn/authUtil.cjs.js"),n=require("./logic/CustomError.cjs.js"),r=require("./typeIndex/typeIndexLogic.cjs.js"),i=require("./logic/solidLogicSingleton.cjs.js"),a=require("./authn/serverLogout.cjs.js"),o=require("./issuer/issuerLogic.cjs.js");var s=i.solidLogicSingleton.authn,c=i.solidLogicSingleton.authn.authSession,l=i.solidLogicSingleton.store;exports.ACL_LINK=e.ACL_LINK,exports.CrossOriginForbiddenError=n.CrossOriginForbiddenError,exports.FetchError=n.FetchError,exports.NotEditableError=n.NotEditableError,exports.NotFoundError=n.NotFoundError,exports.SameOriginForbiddenError=n.SameOriginForbiddenError,exports.UnauthorizedError=n.UnauthorizedError,exports.WebOperationError=n.WebOperationError,exports.appContext=t.appContext,exports.authSession=c,exports.authn=s,exports.createTypeIndexLogic=r.createTypeIndexLogic,exports.getSuggestedIssuers=o.getSuggestedIssuers,exports.offlineTestID=t.offlineTestID,exports.performServerSideLogout=a.performServerSideLogout,exports.solidLogicSingleton=i.solidLogicSingleton,exports.store=l;
|
|
2
|
-
//# sourceMappingURL=index.cjs.js.map
|
package/dist/index.cjs.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["// Make these variables directly accessible as it is what you need most of the time\n// This also makes these variable globaly accesible in mashlib\nimport { solidLogicSingleton } from './logic/solidLogicSingleton'\n\nconst authn = solidLogicSingleton.authn\nconst authSession = solidLogicSingleton.authn.authSession\nconst store = solidLogicSingleton.store\n\nexport { ACL_LINK } from './acl/aclLogic'\nexport { offlineTestID, appContext } from './authn/authUtil'\nexport { performServerSideLogout } from './authn/serverLogout'\nexport { getSuggestedIssuers } from './issuer/issuerLogic'\nexport { createTypeIndexLogic } from './typeIndex/typeIndexLogic'\nexport type { AppDetails, SolidNamespace, AuthenticationContext, SolidLogic, ChatLogic } from './types'\nexport { UnauthorizedError, CrossOriginForbiddenError, SameOriginForbiddenError, NotFoundError, FetchError, NotEditableError, WebOperationError } from './logic/CustomError'\n\nexport {\n solidLogicSingleton, // solidLogicSingleton is exported entirely because it is used in solid-panes\n store,\n authn,\n authSession\n}\n\n"],"mappings":"0WAIA,IAAM,EAAQ,EAAA,oBAAoB,MAC5B,EAAc,EAAA,oBAAoB,MAAM,YACxC,EAAQ,EAAA,oBAAoB"}
|
package/dist/index.esm.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { ACL_LINK as e } from "./acl/aclLogic.esm.js";
|
|
2
|
-
import { appContext as t, offlineTestID as n } from "./authn/authUtil.esm.js";
|
|
3
|
-
import { CrossOriginForbiddenError as r, FetchError as i, NotEditableError as a, NotFoundError as o, SameOriginForbiddenError as s, UnauthorizedError as c, WebOperationError as l } from "./logic/CustomError.esm.js";
|
|
4
|
-
import { createTypeIndexLogic as u } from "./typeIndex/typeIndexLogic.esm.js";
|
|
5
|
-
import { solidLogicSingleton as d } from "./logic/solidLogicSingleton.esm.js";
|
|
6
|
-
import { performServerSideLogout as f } from "./authn/serverLogout.esm.js";
|
|
7
|
-
import { getSuggestedIssuers as p } from "./issuer/issuerLogic.esm.js";
|
|
8
|
-
//#region src/index.ts
|
|
9
|
-
var m = d.authn, h = d.authn.authSession, g = d.store;
|
|
10
|
-
//#endregion
|
|
11
|
-
export { e as ACL_LINK, r as CrossOriginForbiddenError, i as FetchError, a as NotEditableError, o as NotFoundError, s as SameOriginForbiddenError, c as UnauthorizedError, l as WebOperationError, t as appContext, h as authSession, m as authn, u as createTypeIndexLogic, p as getSuggestedIssuers, n as offlineTestID, f as performServerSideLogout, d as solidLogicSingleton, g as store };
|
|
12
|
-
|
|
13
|
-
//# sourceMappingURL=index.esm.js.map
|
package/dist/index.esm.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.esm.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["// Make these variables directly accessible as it is what you need most of the time\n// This also makes these variable globaly accesible in mashlib\nimport { solidLogicSingleton } from './logic/solidLogicSingleton'\n\nconst authn = solidLogicSingleton.authn\nconst authSession = solidLogicSingleton.authn.authSession\nconst store = solidLogicSingleton.store\n\nexport { ACL_LINK } from './acl/aclLogic'\nexport { offlineTestID, appContext } from './authn/authUtil'\nexport { performServerSideLogout } from './authn/serverLogout'\nexport { getSuggestedIssuers } from './issuer/issuerLogic'\nexport { createTypeIndexLogic } from './typeIndex/typeIndexLogic'\nexport type { AppDetails, SolidNamespace, AuthenticationContext, SolidLogic, ChatLogic } from './types'\nexport { UnauthorizedError, CrossOriginForbiddenError, SameOriginForbiddenError, NotFoundError, FetchError, NotEditableError, WebOperationError } from './logic/CustomError'\n\nexport {\n solidLogicSingleton, // solidLogicSingleton is exported entirely because it is used in solid-panes\n store,\n authn,\n authSession\n}\n\n"],"mappings":";;;;;;;;AAIA,IAAM,IAAQ,EAAoB,OAC5B,IAAc,EAAoB,MAAM,aACxC,IAAQ,EAAoB"}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
var e=[{name:`Solid Community`,uri:`https://solidcommunity.net`},{name:`Solid Web`,uri:`https://solidweb.org`},{name:`Solid Web ME`,uri:`https://solidweb.me`},{name:`Inrupt.com`,uri:`https://login.inrupt.com`}];function t(){let t=[...e],{host:n,origin:r}=new URL(location.href);return t.map(({uri:e})=>new URL(e).host).includes(n)||t.unshift({name:n,uri:r}),t}exports.getSuggestedIssuers=t;
|
|
2
|
-
//# sourceMappingURL=issuerLogic.cjs.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"issuerLogic.cjs.js","names":[],"sources":["../../src/issuer/issuerLogic.ts"],"sourcesContent":["const DEFAULT_ISSUERS = [\n {\n name: 'Solid Community',\n uri: 'https://solidcommunity.net'\n },\n {\n name: 'Solid Web',\n uri: 'https://solidweb.org'\n },\n {\n name: 'Solid Web ME',\n uri: 'https://solidweb.me'\n },\n {\n name: 'Inrupt.com',\n uri: 'https://login.inrupt.com'\n }\n]\n\n/**\n * @returns - A list of suggested OIDC issuers\n */\nexport function getSuggestedIssuers (): { name: string, uri: string }[] {\n // Suggest a default list of OIDC issuers\n const issuers = [...DEFAULT_ISSUERS]\n \n // Suggest the current host if not already included\n const { host, origin } = new URL(location.href)\n const hosts = issuers.map(({ uri }) => new URL(uri).host)\n if (!hosts.includes(host)) {\n issuers.unshift({ name: host, uri: origin })\n }\n \n return issuers\n }"],"mappings":"AAAA,IAAM,EAAkB,CACtB,CACE,KAAM,kBACN,IAAK,4BACP,EACA,CACE,KAAM,YACN,IAAK,sBACP,EACA,CACE,KAAM,eACN,IAAK,qBACP,EACA,CACE,KAAM,aACN,IAAK,0BACP,CACF,EAKA,SAAgB,GAAwD,CAEpE,IAAM,EAAU,CAAC,GAAG,CAAe,EAG7B,CAAE,OAAM,UAAW,IAAI,IAAI,SAAS,IAAI,EAM9C,OALc,EAAQ,KAAK,CAAE,SAAU,IAAI,IAAI,CAAG,CAAC,CAAC,IAC/C,CAAA,CAAM,SAAS,CAAI,GACtB,EAAQ,QAAQ,CAAE,KAAM,EAAM,IAAK,CAAO,CAAC,EAGtC,CACT"}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
//#region src/issuer/issuerLogic.ts
|
|
2
|
-
var e = [
|
|
3
|
-
{
|
|
4
|
-
name: "Solid Community",
|
|
5
|
-
uri: "https://solidcommunity.net"
|
|
6
|
-
},
|
|
7
|
-
{
|
|
8
|
-
name: "Solid Web",
|
|
9
|
-
uri: "https://solidweb.org"
|
|
10
|
-
},
|
|
11
|
-
{
|
|
12
|
-
name: "Solid Web ME",
|
|
13
|
-
uri: "https://solidweb.me"
|
|
14
|
-
},
|
|
15
|
-
{
|
|
16
|
-
name: "Inrupt.com",
|
|
17
|
-
uri: "https://login.inrupt.com"
|
|
18
|
-
}
|
|
19
|
-
];
|
|
20
|
-
function t() {
|
|
21
|
-
let t = [...e], { host: n, origin: r } = new URL(location.href);
|
|
22
|
-
return t.map(({ uri: e }) => new URL(e).host).includes(n) || t.unshift({
|
|
23
|
-
name: n,
|
|
24
|
-
uri: r
|
|
25
|
-
}), t;
|
|
26
|
-
}
|
|
27
|
-
//#endregion
|
|
28
|
-
export { t as getSuggestedIssuers };
|
|
29
|
-
|
|
30
|
-
//# sourceMappingURL=issuerLogic.esm.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"issuerLogic.esm.js","names":[],"sources":["../../src/issuer/issuerLogic.ts"],"sourcesContent":["const DEFAULT_ISSUERS = [\n {\n name: 'Solid Community',\n uri: 'https://solidcommunity.net'\n },\n {\n name: 'Solid Web',\n uri: 'https://solidweb.org'\n },\n {\n name: 'Solid Web ME',\n uri: 'https://solidweb.me'\n },\n {\n name: 'Inrupt.com',\n uri: 'https://login.inrupt.com'\n }\n]\n\n/**\n * @returns - A list of suggested OIDC issuers\n */\nexport function getSuggestedIssuers (): { name: string, uri: string }[] {\n // Suggest a default list of OIDC issuers\n const issuers = [...DEFAULT_ISSUERS]\n \n // Suggest the current host if not already included\n const { host, origin } = new URL(location.href)\n const hosts = issuers.map(({ uri }) => new URL(uri).host)\n if (!hosts.includes(host)) {\n issuers.unshift({ name: host, uri: origin })\n }\n \n return issuers\n }"],"mappings":";AAAA,IAAM,IAAkB;CACtB;EACE,MAAM;EACN,KAAK;CACP;CACA;EACE,MAAM;EACN,KAAK;CACP;CACA;EACE,MAAM;EACN,KAAK;CACP;CACA;EACE,MAAM;EACN,KAAK;CACP;AACF;AAKA,SAAgB,IAAwD;CAEpE,IAAM,IAAU,CAAC,GAAG,CAAe,GAG7B,EAAE,SAAM,cAAW,IAAI,IAAI,SAAS,IAAI;CAM9C,OALc,EAAQ,KAAK,EAAE,aAAU,IAAI,IAAI,CAAG,CAAC,CAAC,IAC/C,CAAA,CAAM,SAAS,CAAI,KACtB,EAAQ,QAAQ;EAAE,MAAM;EAAM,KAAK;CAAO,CAAC,GAGtC;AACT"}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
var e=class extends Error{constructor(e){super(e),Object.setPrototypeOf(this,new.target.prototype),this.name=new.target.name}},t=class extends e{},n=class extends e{},r=class extends e{},i=class extends e{},a=class extends e{},o=class extends e{},s=class extends e{constructor(e,t){super(t),this.status=e}};exports.CrossOriginForbiddenError=n,exports.FetchError=s,exports.NotEditableError=a,exports.NotFoundError=i,exports.SameOriginForbiddenError=r,exports.UnauthorizedError=t,exports.WebOperationError=o;
|
|
2
|
-
//# sourceMappingURL=CustomError.cjs.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"CustomError.cjs.js","names":[],"sources":["../../src/logic/CustomError.ts"],"sourcesContent":["class CustomError extends Error {\n constructor(message?: string) {\n super(message)\n // see: typescriptlang.org/docs/handbook/release-notes/typescript-2-2.html\n Object.setPrototypeOf(this, new.target.prototype) // restore prototype chain\n this.name = new.target.name // stack traces display correctly now\n }\n}\n\nexport class UnauthorizedError extends CustomError {}\n\nexport class CrossOriginForbiddenError extends CustomError {}\n\nexport class SameOriginForbiddenError extends CustomError {}\n\nexport class NotFoundError extends CustomError {}\n\nexport class NotEditableError extends CustomError { }\n\nexport class WebOperationError extends CustomError {}\n\nexport class FetchError extends CustomError {\n status: number\n\n constructor(status: number, message?: string) {\n super(message)\n this.status = status\n }\n}"],"mappings":"AAAA,IAAM,EAAN,cAA0B,KAAM,CAC5B,YAAY,EAAkB,CAC1B,MAAM,CAAO,EAEb,OAAO,eAAe,KAAM,IAAI,OAAO,SAAS,EAChD,KAAK,KAAO,IAAI,OAAO,IAC3B,CACJ,EAEa,EAAb,cAAuC,CAAY,CAAC,EAEvC,EAAb,cAA+C,CAAY,CAAC,EAE/C,EAAb,cAA8C,CAAY,CAAC,EAE9C,EAAb,cAAmC,CAAY,CAAC,EAEnC,EAAb,cAAsC,CAAY,CAAE,EAEvC,EAAb,cAAuC,CAAY,CAAC,EAEvC,EAAb,cAAgC,CAAY,CAGxC,YAAY,EAAgB,EAAkB,CAC1C,MAAM,CAAO,EACb,KAAK,OAAS,CAClB,CACJ"}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
//#region src/logic/CustomError.ts
|
|
2
|
-
var e = class extends Error {
|
|
3
|
-
constructor(e) {
|
|
4
|
-
super(e), Object.setPrototypeOf(this, new.target.prototype), this.name = new.target.name;
|
|
5
|
-
}
|
|
6
|
-
}, t = class extends e {}, n = class extends e {}, r = class extends e {}, i = class extends e {}, a = class extends e {}, o = class extends e {}, s = class extends e {
|
|
7
|
-
constructor(e, t) {
|
|
8
|
-
super(t), this.status = e;
|
|
9
|
-
}
|
|
10
|
-
};
|
|
11
|
-
//#endregion
|
|
12
|
-
export { n as CrossOriginForbiddenError, s as FetchError, a as NotEditableError, i as NotFoundError, r as SameOriginForbiddenError, t as UnauthorizedError, o as WebOperationError };
|
|
13
|
-
|
|
14
|
-
//# sourceMappingURL=CustomError.esm.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"CustomError.esm.js","names":[],"sources":["../../src/logic/CustomError.ts"],"sourcesContent":["class CustomError extends Error {\n constructor(message?: string) {\n super(message)\n // see: typescriptlang.org/docs/handbook/release-notes/typescript-2-2.html\n Object.setPrototypeOf(this, new.target.prototype) // restore prototype chain\n this.name = new.target.name // stack traces display correctly now\n }\n}\n\nexport class UnauthorizedError extends CustomError {}\n\nexport class CrossOriginForbiddenError extends CustomError {}\n\nexport class SameOriginForbiddenError extends CustomError {}\n\nexport class NotFoundError extends CustomError {}\n\nexport class NotEditableError extends CustomError { }\n\nexport class WebOperationError extends CustomError {}\n\nexport class FetchError extends CustomError {\n status: number\n\n constructor(status: number, message?: string) {\n super(message)\n this.status = status\n }\n}"],"mappings":";AAAA,IAAM,IAAN,cAA0B,MAAM;CAC5B,YAAY,GAAkB;EAI1B,AAHA,MAAM,CAAO,GAEb,OAAO,eAAe,MAAM,IAAI,OAAO,SAAS,GAChD,KAAK,OAAO,IAAI,OAAO;CAC3B;AACJ,GAEa,IAAb,cAAuC,EAAY,CAAC,GAEvC,IAAb,cAA+C,EAAY,CAAC,GAE/C,IAAb,cAA8C,EAAY,CAAC,GAE9C,IAAb,cAAmC,EAAY,CAAC,GAEnC,IAAb,cAAsC,EAAY,CAAE,GAEvC,IAAb,cAAuC,EAAY,CAAC,GAEvC,IAAb,cAAgC,EAAY;CAGxC,YAAY,GAAgB,GAAkB;EAE1C,AADA,MAAM,CAAO,GACb,KAAK,SAAS;CAClB;AACJ"}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
const e=require("../_virtual/_rolldown/runtime.cjs.js"),t=require("../util/debug.cjs.js"),n=require("../acl/aclLogic.cjs.js"),r=require("../authn/SolidAuthnLogic.cjs.js"),i=require("../chat/chatLogic.cjs.js"),a=require("../inbox/inboxLogic.cjs.js"),o=require("../util/containerLogic.cjs.js"),s=require("../profile/profileLogic.cjs.js"),c=require("../typeIndex/typeIndexLogic.cjs.js"),l=require("../util/utilityLogic.cjs.js");let u=require("rdflib");u=e.__toESM(u);function d(e,d){t.log(`SolidLogic: Unique instance created. There should only be one of these.`);let f=u.graph();u.fetcher(f,{fetch:e.fetch}),f.updater=new u.UpdateManager(f),f.features=[];let p=new r.SolidAuthnLogic(d),m=n.createAclLogic(f),h=o.createContainerLogic(f),g=l.createUtilityLogic(f,m,h),_=s.createProfileLogic(f,p,g),v=i.createChatLogic(f,_),y=a.createInboxLogic(f,_,g,h,m),b=c.createTypeIndexLogic(f,p,_,g);t.log(`SolidAuthnLogic initialized`);function x(e){return f.fetcher.load(e)}function S(e,t=[]){return new Promise((n,r)=>{f.updater.update(e,t,function(e,t,i){t?n():r(Error(i))})})}function C(){f.statements.slice().forEach(f.remove.bind(f))}return{store:f,authn:p,acl:m,inbox:y,chat:v,profile:_,typeIndex:b,load:x,updatePromise:S,clearStore:C}}exports.createSolidLogic=d;
|
|
2
|
-
//# sourceMappingURL=solidLogic.cjs.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"solidLogic.cjs.js","names":[],"sources":["../../src/logic/solidLogic.ts"],"sourcesContent":["import * as rdf from 'rdflib'\nimport { LiveStore, NamedNode, Statement } from 'rdflib'\nimport { createAclLogic } from '../acl/aclLogic'\nimport { SolidAuthnLogic } from '../authn/SolidAuthnLogic'\nimport type { SessionWithLegacyEvents } from '../authSession/authSession'\nimport { createChatLogic } from '../chat/chatLogic'\nimport { createInboxLogic } from '../inbox/inboxLogic'\nimport { createProfileLogic } from '../profile/profileLogic'\nimport { createTypeIndexLogic } from '../typeIndex/typeIndexLogic'\nimport { createContainerLogic } from '../util/containerLogic'\nimport { createUtilityLogic } from '../util/utilityLogic'\nimport type { AuthnLogic, SolidLogic } from '../types'\nimport * as debug from '../util/debug'\n/*\n** It is important to distinquish `fetch`, a function provided by the browser\n** and `Fetcher`, a helper object for the rdflib Store which turns it\n** into a `ConnectedStore` or a `LiveStore`. A Fetcher object is\n** available at store.fetcher, and `fetch` function at `store.fetcher._fetch`,\n*/\nexport function createSolidLogic(specialFetch: { fetch: (url: any, requestInit: any) => any }, session: SessionWithLegacyEvents): SolidLogic {\n\n debug.log('SolidLogic: Unique instance created. There should only be one of these.')\n const store: LiveStore = rdf.graph() as LiveStore\n rdf.fetcher(store, {fetch: specialFetch.fetch}) // Attach a web I/O module, store.fetcher\n store.updater = new rdf.UpdateManager(store) // Add real-time live updates store.updater\n store.features = [] // disable automatic node merging on store load\n\n const authn: AuthnLogic = new SolidAuthnLogic(session)\n \n const acl = createAclLogic(store)\n const containerLogic = createContainerLogic(store)\n const utilityLogic = createUtilityLogic(store, acl, containerLogic)\n const profile = createProfileLogic(store, authn, utilityLogic)\n const chat = createChatLogic(store, profile)\n const inbox = createInboxLogic(store, profile, utilityLogic, containerLogic, acl)\n const typeIndex = createTypeIndexLogic(store, authn, profile, utilityLogic)\n debug.log('SolidAuthnLogic initialized')\n\n function load(doc: NamedNode | NamedNode[] | string) {\n return store.fetcher.load(doc)\n }\n\n // @@@@ use the one in rdflib.js when it is available and delete this\n function updatePromise(\n del: Array<Statement>,\n ins: Array<Statement> = []\n ): Promise<void> {\n return new Promise((resolve, reject) => {\n store.updater.update(del, ins, function (_uri, ok, errorBody) {\n if (!ok) {\n reject(new Error(errorBody))\n } else {\n resolve()\n }\n }) // callback\n }) // promise\n }\n\n function clearStore() {\n store.statements.slice().forEach(store.remove.bind(store))\n }\n\n return {\n store,\n authn,\n acl,\n inbox,\n chat,\n profile,\n typeIndex,\n load,\n updatePromise,\n clearStore\n }\n}\n"],"mappings":"gdAmBA,SAAgB,EAAiB,EAA8D,EAA8C,CAEzI,EAAA,IAAU,0EAA0E,EACpF,IAAM,EAAmB,EAAI,MAAM,EACnC,EAAI,QAAQ,EAAO,CAAC,MAAO,EAAa,KAAK,CAAC,EAC9C,EAAM,QAAU,IAAI,EAAI,cAAc,CAAK,EAC3C,EAAM,SAAW,CAAC,EAElB,IAAM,EAAoB,IAAI,EAAA,gBAAgB,CAAO,EAE/C,EAAM,EAAA,eAAe,CAAK,EAC1B,EAAiB,EAAA,qBAAqB,CAAK,EAC3C,EAAe,EAAA,mBAAmB,EAAO,EAAK,CAAc,EAC5D,EAAU,EAAA,mBAAmB,EAAO,EAAO,CAAY,EACvD,EAAO,EAAA,gBAAgB,EAAO,CAAO,EACrC,EAAQ,EAAA,iBAAiB,EAAO,EAAS,EAAc,EAAgB,CAAG,EAC1E,EAAY,EAAA,qBAAqB,EAAO,EAAO,EAAS,CAAY,EAC1E,EAAA,IAAU,6BAA6B,EAEvC,SAAS,EAAK,EAAuC,CACjD,OAAO,EAAM,QAAQ,KAAK,CAAG,CACjC,CAGA,SAAS,EACL,EACA,EAAwB,CAAC,EACZ,CACb,OAAO,IAAI,SAAS,EAAS,IAAW,CACxC,EAAM,QAAQ,OAAO,EAAK,EAAK,SAAU,EAAM,EAAI,EAAW,CACrD,EAGL,EAAQ,EAFR,EAAW,MAAM,CAAS,CAAC,CAI/B,CAAC,CACD,CAAC,CACL,CAEA,SAAS,GAAa,CAClB,EAAM,WAAW,MAAM,CAAC,CAAC,QAAQ,EAAM,OAAO,KAAK,CAAK,CAAC,CAC7D,CAEA,MAAO,CACH,QACA,QACA,MACA,QACA,OACA,UACA,YACA,OACA,gBACA,YACJ,CACJ"}
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { log as e } from "../util/debug.esm.js";
|
|
2
|
-
import { createAclLogic as t } from "../acl/aclLogic.esm.js";
|
|
3
|
-
import { SolidAuthnLogic as n } from "../authn/SolidAuthnLogic.esm.js";
|
|
4
|
-
import { createChatLogic as r } from "../chat/chatLogic.esm.js";
|
|
5
|
-
import { createInboxLogic as i } from "../inbox/inboxLogic.esm.js";
|
|
6
|
-
import { createContainerLogic as a } from "../util/containerLogic.esm.js";
|
|
7
|
-
import { createProfileLogic as o } from "../profile/profileLogic.esm.js";
|
|
8
|
-
import { createTypeIndexLogic as s } from "../typeIndex/typeIndexLogic.esm.js";
|
|
9
|
-
import { createUtilityLogic as c } from "../util/utilityLogic.esm.js";
|
|
10
|
-
import * as l from "rdflib";
|
|
11
|
-
//#region src/logic/solidLogic.ts
|
|
12
|
-
function u(u, d) {
|
|
13
|
-
e("SolidLogic: Unique instance created. There should only be one of these.");
|
|
14
|
-
let f = l.graph();
|
|
15
|
-
l.fetcher(f, { fetch: u.fetch }), f.updater = new l.UpdateManager(f), f.features = [];
|
|
16
|
-
let p = new n(d), m = t(f), h = a(f), g = c(f, m, h), _ = o(f, p, g), v = r(f, _), y = i(f, _, g, h, m), b = s(f, p, _, g);
|
|
17
|
-
e("SolidAuthnLogic initialized");
|
|
18
|
-
function x(e) {
|
|
19
|
-
return f.fetcher.load(e);
|
|
20
|
-
}
|
|
21
|
-
function S(e, t = []) {
|
|
22
|
-
return new Promise((n, r) => {
|
|
23
|
-
f.updater.update(e, t, function(e, t, i) {
|
|
24
|
-
t ? n() : r(Error(i));
|
|
25
|
-
});
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
function C() {
|
|
29
|
-
f.statements.slice().forEach(f.remove.bind(f));
|
|
30
|
-
}
|
|
31
|
-
return {
|
|
32
|
-
store: f,
|
|
33
|
-
authn: p,
|
|
34
|
-
acl: m,
|
|
35
|
-
inbox: y,
|
|
36
|
-
chat: v,
|
|
37
|
-
profile: _,
|
|
38
|
-
typeIndex: b,
|
|
39
|
-
load: x,
|
|
40
|
-
updatePromise: S,
|
|
41
|
-
clearStore: C
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
//#endregion
|
|
45
|
-
export { u as createSolidLogic };
|
|
46
|
-
|
|
47
|
-
//# sourceMappingURL=solidLogic.esm.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"solidLogic.esm.js","names":[],"sources":["../../src/logic/solidLogic.ts"],"sourcesContent":["import * as rdf from 'rdflib'\nimport { LiveStore, NamedNode, Statement } from 'rdflib'\nimport { createAclLogic } from '../acl/aclLogic'\nimport { SolidAuthnLogic } from '../authn/SolidAuthnLogic'\nimport type { SessionWithLegacyEvents } from '../authSession/authSession'\nimport { createChatLogic } from '../chat/chatLogic'\nimport { createInboxLogic } from '../inbox/inboxLogic'\nimport { createProfileLogic } from '../profile/profileLogic'\nimport { createTypeIndexLogic } from '../typeIndex/typeIndexLogic'\nimport { createContainerLogic } from '../util/containerLogic'\nimport { createUtilityLogic } from '../util/utilityLogic'\nimport type { AuthnLogic, SolidLogic } from '../types'\nimport * as debug from '../util/debug'\n/*\n** It is important to distinquish `fetch`, a function provided by the browser\n** and `Fetcher`, a helper object for the rdflib Store which turns it\n** into a `ConnectedStore` or a `LiveStore`. A Fetcher object is\n** available at store.fetcher, and `fetch` function at `store.fetcher._fetch`,\n*/\nexport function createSolidLogic(specialFetch: { fetch: (url: any, requestInit: any) => any }, session: SessionWithLegacyEvents): SolidLogic {\n\n debug.log('SolidLogic: Unique instance created. There should only be one of these.')\n const store: LiveStore = rdf.graph() as LiveStore\n rdf.fetcher(store, {fetch: specialFetch.fetch}) // Attach a web I/O module, store.fetcher\n store.updater = new rdf.UpdateManager(store) // Add real-time live updates store.updater\n store.features = [] // disable automatic node merging on store load\n\n const authn: AuthnLogic = new SolidAuthnLogic(session)\n \n const acl = createAclLogic(store)\n const containerLogic = createContainerLogic(store)\n const utilityLogic = createUtilityLogic(store, acl, containerLogic)\n const profile = createProfileLogic(store, authn, utilityLogic)\n const chat = createChatLogic(store, profile)\n const inbox = createInboxLogic(store, profile, utilityLogic, containerLogic, acl)\n const typeIndex = createTypeIndexLogic(store, authn, profile, utilityLogic)\n debug.log('SolidAuthnLogic initialized')\n\n function load(doc: NamedNode | NamedNode[] | string) {\n return store.fetcher.load(doc)\n }\n\n // @@@@ use the one in rdflib.js when it is available and delete this\n function updatePromise(\n del: Array<Statement>,\n ins: Array<Statement> = []\n ): Promise<void> {\n return new Promise((resolve, reject) => {\n store.updater.update(del, ins, function (_uri, ok, errorBody) {\n if (!ok) {\n reject(new Error(errorBody))\n } else {\n resolve()\n }\n }) // callback\n }) // promise\n }\n\n function clearStore() {\n store.statements.slice().forEach(store.remove.bind(store))\n }\n\n return {\n store,\n authn,\n acl,\n inbox,\n chat,\n profile,\n typeIndex,\n load,\n updatePromise,\n clearStore\n }\n}\n"],"mappings":";;;;;;;;;;;AAmBA,SAAgB,EAAiB,GAA8D,GAA8C;CAEzI,EAAU,0EAA0E;CACpF,IAAM,IAAmB,EAAI,MAAM;CAGnC,AAFA,EAAI,QAAQ,GAAO,EAAC,OAAO,EAAa,MAAK,CAAC,GAC9C,EAAM,UAAU,IAAI,EAAI,cAAc,CAAK,GAC3C,EAAM,WAAW,CAAC;CAElB,IAAM,IAAoB,IAAI,EAAgB,CAAO,GAE/C,IAAM,EAAe,CAAK,GAC1B,IAAiB,EAAqB,CAAK,GAC3C,IAAe,EAAmB,GAAO,GAAK,CAAc,GAC5D,IAAU,EAAmB,GAAO,GAAO,CAAY,GACvD,IAAO,EAAgB,GAAO,CAAO,GACrC,IAAQ,EAAiB,GAAO,GAAS,GAAc,GAAgB,CAAG,GAC1E,IAAY,EAAqB,GAAO,GAAO,GAAS,CAAY;CAC1E,EAAU,6BAA6B;CAEvC,SAAS,EAAK,GAAuC;EACjD,OAAO,EAAM,QAAQ,KAAK,CAAG;CACjC;CAGA,SAAS,EACL,GACA,IAAwB,CAAC,GACZ;EACb,OAAO,IAAI,SAAS,GAAS,MAAW;GACxC,EAAM,QAAQ,OAAO,GAAK,GAAK,SAAU,GAAM,GAAI,GAAW;IAC1D,AAAK,IAGL,EAAQ,IAFR,EAAW,MAAM,CAAS,CAAC;GAI/B,CAAC;EACD,CAAC;CACL;CAEA,SAAS,IAAa;EAClB,EAAM,WAAW,MAAM,CAAC,CAAC,QAAQ,EAAM,OAAO,KAAK,CAAK,CAAC;CAC7D;CAEA,OAAO;EACH;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACJ;AACJ"}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
const e=require("../util/debug.cjs.js"),t=require("../authSession/authSession.cjs.js"),n=require("./solidLogic.cjs.js");var r=async(e,n)=>{let r=n&&n.credentials&&n.credentials==`omit`,i=t.authSession;if((i?.info?.webId||i?.webId)&&!r){let t=typeof i.fetch==`function`?i.fetch.bind(i):typeof i.authFetch==`function`?i.authFetch.bind(i):null;return t?t(e,n):window.fetch(e,n)}else return window.fetch(e,n)},i=Symbol.for(`solid-logic-singleton`),a=typeof window<`u`?window:global;function o(){return a[i]?e.log(`SolidLogic: Using existing global singleton instance.`):(e.log(`SolidLogic: Creating new global singleton instance.`),a[i]=n.createSolidLogic({fetch:r},t.authSession),e.log(`Unique quadstore initialized.`)),a[i]}var s=o();exports.solidLogicSingleton=s;
|
|
2
|
-
//# sourceMappingURL=solidLogicSingleton.cjs.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"solidLogicSingleton.cjs.js","names":[],"sources":["../../src/logic/solidLogicSingleton.ts"],"sourcesContent":["import * as debug from '../util/debug'\nimport { authSession } from '../authSession/authSession'\nimport { createSolidLogic } from './solidLogic'\nimport { SolidLogic } from '../types'\n\nconst _fetch = async (url, requestInit) => {\n const omitCreds = requestInit && requestInit.credentials && requestInit.credentials == 'omit'\n const sessionAny = authSession as any\n const sessionWebId = sessionAny?.info?.webId || sessionAny?.webId\n if (sessionWebId && !omitCreds) { // see https://github.com/solidos/solidos/issues/114\n // In fact fetch should respect credentials omit itself\n const authenticatedFetch = (typeof sessionAny.fetch === 'function')\n ? sessionAny.fetch.bind(sessionAny)\n : (typeof sessionAny.authFetch === 'function' ? sessionAny.authFetch.bind(sessionAny) : null)\n if (authenticatedFetch) {\n return authenticatedFetch(url, requestInit)\n }\n return window.fetch(url, requestInit)\n } else {\n return window.fetch(url, requestInit)\n }\n}\n\n// Global singleton pattern to ensure unique store across library versions\nconst SINGLETON_SYMBOL = Symbol.for('solid-logic-singleton')\n\n// Type the global object properly with the singleton\ninterface GlobalWithSingleton {\n [SINGLETON_SYMBOL]?: SolidLogic\n}\n\nconst globalTarget = (typeof window !== 'undefined' ? window : global) as GlobalWithSingleton\n\nfunction getOrCreateSingleton(): SolidLogic {\n if (!globalTarget[SINGLETON_SYMBOL]) {\n debug.log('SolidLogic: Creating new global singleton instance.')\n globalTarget[SINGLETON_SYMBOL] = createSolidLogic({ fetch: _fetch }, authSession)\n debug.log('Unique quadstore initialized.')\n } else {\n debug.log('SolidLogic: Using existing global singleton instance.')\n }\n return globalTarget[SINGLETON_SYMBOL]!\n}\n//this const makes solidLogicSingleton global accessible in mashlib\nconst solidLogicSingleton = getOrCreateSingleton()\n\nexport { solidLogicSingleton }"],"mappings":"wHAKA,IAAM,EAAS,MAAO,EAAK,IAAgB,CACvC,IAAM,EAAY,GAAe,EAAY,aAAe,EAAY,aAAe,OACjF,EAAa,EAAA,YAEnB,IADqB,GAAY,MAAM,OAAS,GAAY,QACxC,CAAC,EAAW,CAE5B,IAAM,EAAsB,OAAO,EAAW,OAAU,WAClD,EAAW,MAAM,KAAK,CAAU,EAC/B,OAAO,EAAW,WAAc,WAAa,EAAW,UAAU,KAAK,CAAU,EAAI,KAI5F,OAHI,EACO,EAAmB,EAAK,CAAW,EAEvC,OAAO,MAAM,EAAK,CAAW,CACxC,MACI,OAAO,OAAO,MAAM,EAAK,CAAW,CAE5C,EAGM,EAAmB,OAAO,IAAI,uBAAuB,EAOrD,EAAgB,OAAO,OAAW,IAAc,OAAS,OAE/D,SAAS,GAAmC,CAQxC,OAPK,EAAa,GAKd,EAAA,IAAU,uDAAuD,GAJjE,EAAA,IAAU,qDAAqD,EAC/D,EAAa,GAAoB,EAAA,iBAAiB,CAAE,MAAO,CAAO,EAAG,EAAA,WAAW,EAChF,EAAA,IAAU,+BAA+B,GAItC,EAAa,EACxB,CAEA,IAAM,EAAsB,EAAqB"}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { log as e } from "../util/debug.esm.js";
|
|
2
|
-
import { authSession as t } from "../authSession/authSession.esm.js";
|
|
3
|
-
import { createSolidLogic as n } from "./solidLogic.esm.js";
|
|
4
|
-
//#region src/logic/solidLogicSingleton.ts
|
|
5
|
-
var r = async (e, n) => {
|
|
6
|
-
let r = n && n.credentials && n.credentials == "omit", i = t;
|
|
7
|
-
if ((i?.info?.webId || i?.webId) && !r) {
|
|
8
|
-
let t = typeof i.fetch == "function" ? i.fetch.bind(i) : typeof i.authFetch == "function" ? i.authFetch.bind(i) : null;
|
|
9
|
-
return t ? t(e, n) : window.fetch(e, n);
|
|
10
|
-
} else return window.fetch(e, n);
|
|
11
|
-
}, i = Symbol.for("solid-logic-singleton"), a = typeof window < "u" ? window : global;
|
|
12
|
-
function o() {
|
|
13
|
-
return a[i] ? e("SolidLogic: Using existing global singleton instance.") : (e("SolidLogic: Creating new global singleton instance."), a[i] = n({ fetch: r }, t), e("Unique quadstore initialized.")), a[i];
|
|
14
|
-
}
|
|
15
|
-
var s = o();
|
|
16
|
-
//#endregion
|
|
17
|
-
export { s as solidLogicSingleton };
|
|
18
|
-
|
|
19
|
-
//# sourceMappingURL=solidLogicSingleton.esm.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"solidLogicSingleton.esm.js","names":[],"sources":["../../src/logic/solidLogicSingleton.ts"],"sourcesContent":["import * as debug from '../util/debug'\nimport { authSession } from '../authSession/authSession'\nimport { createSolidLogic } from './solidLogic'\nimport { SolidLogic } from '../types'\n\nconst _fetch = async (url, requestInit) => {\n const omitCreds = requestInit && requestInit.credentials && requestInit.credentials == 'omit'\n const sessionAny = authSession as any\n const sessionWebId = sessionAny?.info?.webId || sessionAny?.webId\n if (sessionWebId && !omitCreds) { // see https://github.com/solidos/solidos/issues/114\n // In fact fetch should respect credentials omit itself\n const authenticatedFetch = (typeof sessionAny.fetch === 'function')\n ? sessionAny.fetch.bind(sessionAny)\n : (typeof sessionAny.authFetch === 'function' ? sessionAny.authFetch.bind(sessionAny) : null)\n if (authenticatedFetch) {\n return authenticatedFetch(url, requestInit)\n }\n return window.fetch(url, requestInit)\n } else {\n return window.fetch(url, requestInit)\n }\n}\n\n// Global singleton pattern to ensure unique store across library versions\nconst SINGLETON_SYMBOL = Symbol.for('solid-logic-singleton')\n\n// Type the global object properly with the singleton\ninterface GlobalWithSingleton {\n [SINGLETON_SYMBOL]?: SolidLogic\n}\n\nconst globalTarget = (typeof window !== 'undefined' ? window : global) as GlobalWithSingleton\n\nfunction getOrCreateSingleton(): SolidLogic {\n if (!globalTarget[SINGLETON_SYMBOL]) {\n debug.log('SolidLogic: Creating new global singleton instance.')\n globalTarget[SINGLETON_SYMBOL] = createSolidLogic({ fetch: _fetch }, authSession)\n debug.log('Unique quadstore initialized.')\n } else {\n debug.log('SolidLogic: Using existing global singleton instance.')\n }\n return globalTarget[SINGLETON_SYMBOL]!\n}\n//this const makes solidLogicSingleton global accessible in mashlib\nconst solidLogicSingleton = getOrCreateSingleton()\n\nexport { solidLogicSingleton }"],"mappings":";;;;AAKA,IAAM,IAAS,OAAO,GAAK,MAAgB;CACvC,IAAM,IAAY,KAAe,EAAY,eAAe,EAAY,eAAe,QACjF,IAAa;CAEnB,KADqB,GAAY,MAAM,SAAS,GAAY,UACxC,CAAC,GAAW;EAE5B,IAAM,IAAsB,OAAO,EAAW,SAAU,aAClD,EAAW,MAAM,KAAK,CAAU,IAC/B,OAAO,EAAW,aAAc,aAAa,EAAW,UAAU,KAAK,CAAU,IAAI;EAI5F,OAHI,IACO,EAAmB,GAAK,CAAW,IAEvC,OAAO,MAAM,GAAK,CAAW;CACxC,OACI,OAAO,OAAO,MAAM,GAAK,CAAW;AAE5C,GAGM,IAAmB,OAAO,IAAI,uBAAuB,GAOrD,IAAgB,OAAO,SAAW,MAAc,SAAS;AAE/D,SAAS,IAAmC;CAQxC,OAPK,EAAa,KAKd,EAAU,uDAAuD,KAJjE,EAAU,qDAAqD,GAC/D,EAAa,KAAoB,EAAiB,EAAE,OAAO,EAAO,GAAG,CAAW,GAChF,EAAU,+BAA+B,IAItC,EAAa;AACxB;AAEA,IAAM,IAAsB,EAAqB"}
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
function e(e){return[`@prefix acl: <http://www.w3.org/ns/auth/acl#>.`,``,`<#owner>`,`a acl:Authorization;`,`acl:agent <${e}>;`,`acl:accessTo <./>;`,`acl:default <./>;`,`acl:mode acl:Read, acl:Write, acl:Control.`].join(`
|
|
2
|
-
`)}exports.ownerOnlyContainerAclDocument=e;
|
|
3
|
-
//# sourceMappingURL=profileAclDocuments.cjs.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"profileAclDocuments.cjs.js","names":[],"sources":["../../src/profile/profileAclDocuments.ts"],"sourcesContent":["export function ownerOnlyContainerAclDocument(webId: string): string {\n return [\n '@prefix acl: <http://www.w3.org/ns/auth/acl#>.',\n '',\n '<#owner>',\n 'a acl:Authorization;',\n `acl:agent <${webId}>;`,\n 'acl:accessTo <./>;',\n 'acl:default <./>;',\n 'acl:mode acl:Read, acl:Write, acl:Control.'\n ].join('\\n')\n}\n"],"mappings":"AAAA,SAAgB,EAA8B,EAAuB,CACjE,MAAO,CACH,iDACA,GACA,WACA,uBACA,cAAc,EAAM,IACpB,qBACA,oBACA,4CACJ,CAAC,CAAC,KAAK;CAAI,CACf"}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
//#region src/profile/profileAclDocuments.ts
|
|
2
|
-
function e(e) {
|
|
3
|
-
return [
|
|
4
|
-
"@prefix acl: <http://www.w3.org/ns/auth/acl#>.",
|
|
5
|
-
"",
|
|
6
|
-
"<#owner>",
|
|
7
|
-
"a acl:Authorization;",
|
|
8
|
-
`acl:agent <${e}>;`,
|
|
9
|
-
"acl:accessTo <./>;",
|
|
10
|
-
"acl:default <./>;",
|
|
11
|
-
"acl:mode acl:Read, acl:Write, acl:Control."
|
|
12
|
-
].join("\n");
|
|
13
|
-
}
|
|
14
|
-
//#endregion
|
|
15
|
-
export { e as ownerOnlyContainerAclDocument };
|
|
16
|
-
|
|
17
|
-
//# sourceMappingURL=profileAclDocuments.esm.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"profileAclDocuments.esm.js","names":[],"sources":["../../src/profile/profileAclDocuments.ts"],"sourcesContent":["export function ownerOnlyContainerAclDocument(webId: string): string {\n return [\n '@prefix acl: <http://www.w3.org/ns/auth/acl#>.',\n '',\n '<#owner>',\n 'a acl:Authorization;',\n `acl:agent <${webId}>;`,\n 'acl:accessTo <./>;',\n 'acl:default <./>;',\n 'acl:mode acl:Read, acl:Write, acl:Control.'\n ].join('\\n')\n}\n"],"mappings":";AAAA,SAAgB,EAA8B,GAAuB;CACjE,OAAO;EACH;EACA;EACA;EACA;EACA,cAAc,EAAM;EACpB;EACA;EACA;CACJ,CAAC,CAAC,KAAK,IAAI;AACf"}
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
function e(){return[`@prefix dct: <http://purl.org/dc/terms/>.`,`@prefix pim: <http://www.w3.org/ns/pim/space#>.`,`@prefix solid: <http://www.w3.org/ns/solid/terms#>.`,`<>`,` a pim:ConfigurationFile ;`,` dct:title "Preferences file".`].join(`
|
|
2
|
-
`)}exports.preferencesFileDocument=e;
|
|
3
|
-
//# sourceMappingURL=profileDocuments.cjs.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"profileDocuments.cjs.js","names":[],"sources":["../../src/profile/profileDocuments.ts"],"sourcesContent":["export function preferencesFileDocument(): string {\n return [\n '@prefix dct: <http://purl.org/dc/terms/>.',\n '@prefix pim: <http://www.w3.org/ns/pim/space#>.',\n '@prefix solid: <http://www.w3.org/ns/solid/terms#>.',\n '<>',\n ' a pim:ConfigurationFile ;',\n ' dct:title \"Preferences file\".'\n ].join('\\n')\n}\n"],"mappings":"AAAA,SAAgB,GAAkC,CAC9C,MAAO,CACH,4CACA,kDACA,sDACA,KACA,gCACA,mCACJ,CAAC,CAAC,KAAK;CAAI,CACf"}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
//#region src/profile/profileDocuments.ts
|
|
2
|
-
function e() {
|
|
3
|
-
return [
|
|
4
|
-
"@prefix dct: <http://purl.org/dc/terms/>.",
|
|
5
|
-
"@prefix pim: <http://www.w3.org/ns/pim/space#>.",
|
|
6
|
-
"@prefix solid: <http://www.w3.org/ns/solid/terms#>.",
|
|
7
|
-
"<>",
|
|
8
|
-
" a pim:ConfigurationFile ;",
|
|
9
|
-
" dct:title \"Preferences file\"."
|
|
10
|
-
].join("\n");
|
|
11
|
-
}
|
|
12
|
-
//#endregion
|
|
13
|
-
export { e as preferencesFileDocument };
|
|
14
|
-
|
|
15
|
-
//# sourceMappingURL=profileDocuments.esm.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"profileDocuments.esm.js","names":[],"sources":["../../src/profile/profileDocuments.ts"],"sourcesContent":["export function preferencesFileDocument(): string {\n return [\n '@prefix dct: <http://purl.org/dc/terms/>.',\n '@prefix pim: <http://www.w3.org/ns/pim/space#>.',\n '@prefix solid: <http://www.w3.org/ns/solid/terms#>.',\n '<>',\n ' a pim:ConfigurationFile ;',\n ' dct:title \"Preferences file\".'\n ].join('\\n')\n}\n"],"mappings":";AAAA,SAAgB,IAAkC;CAC9C,OAAO;EACH;EACA;EACA;EACA;EACA;EACA;CACJ,CAAC,CAAC,KAAK,IAAI;AACf"}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
const e=require("../util/debug.cjs.js"),t=require("../util/ns.cjs.js"),n=require("../acl/aclLogic.cjs.js"),r=require("../util/utils.cjs.js"),i=require("../logic/CustomError.cjs.js"),a=require("../typeIndex/typeIndexDocuments.cjs.js"),o=require("../typeIndex/typeIndexAclDocuments.cjs.js"),s=require("./profileDocuments.cjs.js"),c=require("./profileAclDocuments.cjs.js"),l=require("../util/containerLogic.cjs.js");let u=require("rdflib");function d(d,f,p){let m=t.ns,h=l.createContainerLogic(d),g=new Map,_=new Map;function v(e){return!!e&&(e.startsWith(`https://`)||e.startsWith(`http://`))}function y(e){let t=e.doc(),n=t.dir();if(n?.uri&&v(n.uri))return n.uri;let r=t.uri;if(!r||!v(r))return null;let i=r.split(`#`)[0],a=i.lastIndexOf(`/`);return a===-1?null:i.slice(0,a+1)}function b(e,t){let n=y(e);if(!n)throw Error(`Cannot derive directory for preferences file ${e.uri}`);return(0,u.sym)(n+t)}function x(e){if(e?.response?.status===404)return!0;let t=`${e?.message||e||``}`;return t.includes(`404`)||t.includes(`Not Found`)}async function S(e){let t=(0,u.sym)(e);try{await d.fetcher.load(t);return}catch(e){if(!x(e))throw e}await h.createContainer(e)}async function C(e,t){let r=y(t);if(!r)throw Error(`Cannot derive settings directory from ${t.uri}`);await S(r);let i=(0,u.sym)(r),a;try{await d.fetcher.load(i),a=d.any(i,n.ACL_LINK)?.value}catch(e){if(!x(e))throw e}a||=`${r}.acl`;let o=(0,u.sym)(a);try{await d.fetcher.load(o);return}catch(e){if(!x(e))throw e}await d.fetcher.webOperation(`PUT`,o.uri,{data:c.ownerOnlyContainerAclDocument(e.uri),contentType:`text/turtle`})}async function w(e,t,r=!1){if(!await p.loadOrCreateWithContentOnCreate(t,a.publicTypeIndexDocument())&&!r)return;let i;try{await d.fetcher.load(t),i=d.any(t,n.ACL_LINK)?.value}catch(e){if(!x(e))throw e}i||=`${t.uri}.acl`;let s=(0,u.sym)(i);try{await d.fetcher.webOperation(`PUT`,s.uri,{data:o.publicTypeIndexAclDocument(e.uri,t.uri),contentType:`text/turtle`,headers:{"If-None-Match":`*`}})}catch(e){if((e?.response?.status??e?.status)!==412)throw e}}async function T(e){await p.loadOrCreateWithContentOnCreate(e,a.privateTypeIndexDocument())}async function E(e,t){let n=t.doc(),r=e.doc();await d.fetcher.load(n);let i=d.any(e,m.solid(`publicTypeIndex`),null,r),o=d.any(e,m.solid(`publicTypeIndex`),null,n),s=i||o||b(t,`publicTypeIndex.ttl`),c=d.any(e,m.solid(`privateTypeIndex`),null,n)||b(t,`privateTypeIndex.ttl`),l=!i;l&&await p.followOrCreateLinkWithContentOnCreate(e,m.solid(`publicTypeIndex`),s,r,a.publicTypeIndexDocument());let f=[];d.holds(n,m.rdf(`type`),m.space(`ConfigurationFile`),n)||f.push((0,u.st)(n,m.rdf(`type`),m.space(`ConfigurationFile`),n)),d.holds(n,m.dct(`title`),void 0,n)||f.push((0,u.st)(n,m.dct(`title`),(0,u.literal)(`Preferences file`),n)),d.holds(e,m.solid(`publicTypeIndex`),s,n)||f.push((0,u.st)(e,m.solid(`publicTypeIndex`),s,n)),d.holds(e,m.solid(`privateTypeIndex`),c,n)||f.push((0,u.st)(e,m.solid(`privateTypeIndex`),c,n)),f.length>0&&(await d.updater.update([],f),await d.fetcher.load(n)),await w(e,s,l),await T(c)}async function D(e){try{return!!await p.loadOrCreateWithContentOnCreate(e,s.preferencesFileDocument())}catch(t){throw t.response?.status===401?new i.UnauthorizedError:t.response?.status===403?r.differentOrigin(e)?new i.CrossOriginForbiddenError:new i.SameOriginForbiddenError:t}}async function O(e){try{return await k(e)}catch{return}}async function k(t){let n=_.get(t.uri);if(n)return n;let a=g.get(t.uri);if(a)return a;let o=(async()=>{await A(t);let n=r.suggestPreferencesFile(t),a;try{a=d.any(t,m.space(`preferencesFile`),null,t.doc())||await p.followOrCreateLink(t,m.space(`preferencesFile`),n,t.doc()),await C(t,a),await D(a),await E(t,a)}catch(n){let r=`User ${t} has no pointer in profile to preferences file.`;throw e.warn(r),n instanceof i.NotEditableError||n instanceof i.WebOperationError||n instanceof i.UnauthorizedError||n instanceof i.CrossOriginForbiddenError||n instanceof i.SameOriginForbiddenError||n instanceof i.FetchError,n}try{await d.fetcher.load(a)}catch(n){let o=`Unable to load preference of user ${t}: ${n}`;if(n.response?.status===404)return await C(t,a),await D(a),await E(t,a),await d.fetcher.load(a),a;throw e.warn(o),n.response.status===401?new i.UnauthorizedError:n.response.status===403?r.differentOrigin(a)?new i.CrossOriginForbiddenError:new i.SameOriginForbiddenError:Error(o)}return _.set(t.uri,a),a})();g.set(t.uri,o);try{return await o}finally{g.get(t.uri)===o&&g.delete(t.uri)}}async function A(e){if(!e)throw Error(`loadProfile: no user given.`);try{await d.fetcher.load(e.doc())}catch(t){throw Error(`Unable to load profile of user ${e}: ${t}`)}return e.doc()}async function j(){let e=f.currentUser();if(e===null)throw Error(`Current user not found! Not logged in?`);return await d.fetcher.load(e.doc()),e}function M(e){let t=P(e);if(!t)throw Error(`User pod root not found!`);return t}async function N(e){await d.fetcher.load(e);let t=d.any(e,m.ldp(`inbox`),void 0,e.doc());if(!t)throw Error(`User main inbox not found!`);return t}function P(e){return d.any(e,m.space(`storage`),void 0,e.doc())}return{loadMe:j,getPodRoot:M,getMainInbox:N,findStorage:P,loadPreferences:k,loadProfile:A,silencedLoadPreferences:O}}exports.createProfileLogic=d;
|
|
2
|
-
//# sourceMappingURL=profileLogic.cjs.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"profileLogic.cjs.js","names":[],"sources":["../../src/profile/profileLogic.ts"],"sourcesContent":["import { literal, NamedNode, st, sym } from 'rdflib'\nimport { ACL_LINK } from '../acl/aclLogic'\nimport { CrossOriginForbiddenError, FetchError, NotEditableError, SameOriginForbiddenError, UnauthorizedError, WebOperationError } from '../logic/CustomError'\nimport * as debug from '../util/debug'\nimport { ns as namespace } from '../util/ns'\nimport { privateTypeIndexDocument, publicTypeIndexDocument } from '../typeIndex/typeIndexDocuments'\nimport { publicTypeIndexAclDocument } from '../typeIndex/typeIndexAclDocuments'\nimport { preferencesFileDocument } from './profileDocuments'\nimport { ownerOnlyContainerAclDocument } from './profileAclDocuments'\nimport { createContainerLogic } from '../util/containerLogic'\nimport { differentOrigin, suggestPreferencesFile } from '../util/utils'\nimport { ProfileLogic } from '../types'\n\nexport function createProfileLogic(store, authn, utilityLogic): ProfileLogic {\n const ns = namespace\n const containerLogic = createContainerLogic(store)\n const loadPreferencesInFlight = new Map<string, Promise<NamedNode>>()\n const cachedPreferencesFileByWebId = new Map<string, NamedNode>()\n\n function isAbsoluteHttpUri(uri: string | null | undefined): boolean {\n return !!uri && (uri.startsWith('https://') || uri.startsWith('http://'))\n }\n\n function docDirUri(node: NamedNode): string | null {\n const doc = node.doc()\n const dir = doc.dir()\n if (dir?.uri && isAbsoluteHttpUri(dir.uri)) return dir.uri\n const docUri = doc.uri\n if (!docUri || !isAbsoluteHttpUri(docUri)) return null\n const withoutFragment = docUri.split('#')[0]\n const lastSlash = withoutFragment.lastIndexOf('/')\n if (lastSlash === -1) return null\n return withoutFragment.slice(0, lastSlash + 1)\n }\n\n function suggestTypeIndexInPreferences(preferencesFile: NamedNode, filename: string): NamedNode {\n const dirUri = docDirUri(preferencesFile)\n if (!dirUri) throw new Error(`Cannot derive directory for preferences file ${preferencesFile.uri}`)\n return sym(dirUri + filename)\n }\n\n function isNotFoundError(err: any): boolean {\n if (err?.response?.status === 404) return true\n const text = `${err?.message || err || ''}`\n return text.includes('404') || text.includes('Not Found')\n }\n\n async function ensureContainerExists(containerUri: string): Promise<void> {\n const containerNode = sym(containerUri)\n try {\n await store.fetcher.load(containerNode)\n return\n } catch (err) {\n if (!isNotFoundError(err)) throw err\n }\n await containerLogic.createContainer(containerUri)\n }\n\n async function ensureOwnerOnlyAclForSettings(user: NamedNode, preferencesFile: NamedNode): Promise<void> {\n const dirUri = docDirUri(preferencesFile)\n if (!dirUri) throw new Error(`Cannot derive settings directory from ${preferencesFile.uri}`)\n await ensureContainerExists(dirUri)\n\n const containerNode = sym(dirUri)\n let aclDocUri: string | undefined\n try {\n await store.fetcher.load(containerNode)\n aclDocUri = store.any(containerNode, ACL_LINK)?.value\n } catch (err) {\n if (!isNotFoundError(err)) throw err\n }\n if (!aclDocUri) {\n // Fallback for servers/tests where rel=acl is not exposed in mocked headers.\n aclDocUri = `${dirUri}.acl`\n }\n const aclDoc = sym(aclDocUri)\n try {\n await store.fetcher.load(aclDoc)\n return\n } catch (err) {\n if (!isNotFoundError(err)) throw err\n }\n\n await store.fetcher.webOperation('PUT', aclDoc.uri, {\n data: ownerOnlyContainerAclDocument(user.uri),\n contentType: 'text/turtle'\n })\n }\n\n async function ensurePublicTypeIndexAclOnCreate(user: NamedNode, publicTypeIndex: NamedNode, ensureAcl = false): Promise<void> {\n const created = await utilityLogic.loadOrCreateWithContentOnCreate(publicTypeIndex, publicTypeIndexDocument())\n if (!created && !ensureAcl) return\n\n let aclDocUri: string | undefined\n try {\n await store.fetcher.load(publicTypeIndex)\n aclDocUri = store.any(publicTypeIndex, ACL_LINK)?.value\n } catch (err) {\n if (!isNotFoundError(err)) throw err\n }\n if (!aclDocUri) {\n aclDocUri = `${publicTypeIndex.uri}.acl`\n }\n\n const aclDoc = sym(aclDocUri)\n try {\n await store.fetcher.webOperation('PUT', aclDoc.uri, {\n data: publicTypeIndexAclDocument(user.uri, publicTypeIndex.uri),\n contentType: 'text/turtle',\n headers: { 'If-None-Match': '*' }\n })\n } catch (err: any) {\n const status = err?.response?.status ?? err?.status\n if (status !== 412) throw err\n }\n }\n\n async function ensurePrivateTypeIndexOnCreate(privateTypeIndex: NamedNode): Promise<void> {\n await utilityLogic.loadOrCreateWithContentOnCreate(privateTypeIndex, privateTypeIndexDocument())\n }\n\n async function initializePreferencesDefaults(user: NamedNode, preferencesFile: NamedNode): Promise<void> {\n const preferencesDoc = preferencesFile.doc() as NamedNode\n const profileDoc = user.doc() as NamedNode\n await store.fetcher.load(preferencesDoc)\n\n const profilePublicTypeIndex =\n (store.any(user, ns.solid('publicTypeIndex'), null, profileDoc) as NamedNode | null)\n const preferencesPublicTypeIndex =\n (store.any(user, ns.solid('publicTypeIndex'), null, preferencesDoc) as NamedNode | null)\n const publicTypeIndex =\n profilePublicTypeIndex ||\n preferencesPublicTypeIndex ||\n suggestTypeIndexInPreferences(preferencesFile, 'publicTypeIndex.ttl')\n const privateTypeIndex =\n (store.any(user, ns.solid('privateTypeIndex'), null, preferencesDoc) as NamedNode | null) ||\n suggestTypeIndexInPreferences(preferencesFile, 'privateTypeIndex.ttl')\n\n // Keep discovery consistent with typeIndexLogic, which resolves publicTypeIndex from the profile doc.\n const createdProfilePublicTypeIndexLink = !profilePublicTypeIndex\n if (createdProfilePublicTypeIndexLink) {\n await utilityLogic.followOrCreateLinkWithContentOnCreate(\n user,\n ns.solid('publicTypeIndex') as NamedNode,\n publicTypeIndex,\n profileDoc,\n publicTypeIndexDocument()\n )\n }\n\n const toInsert: any[] = []\n if (!store.holds(preferencesDoc, ns.rdf('type'), ns.space('ConfigurationFile'), preferencesDoc)) {\n toInsert.push(st(preferencesDoc, ns.rdf('type'), ns.space('ConfigurationFile'), preferencesDoc))\n }\n if (!store.holds(preferencesDoc, ns.dct('title'), undefined, preferencesDoc)) {\n toInsert.push(st(preferencesDoc, ns.dct('title'), literal('Preferences file'), preferencesDoc))\n }\n if (!store.holds(user, ns.solid('publicTypeIndex'), publicTypeIndex, preferencesDoc)) {\n toInsert.push(st(user, ns.solid('publicTypeIndex'), publicTypeIndex, preferencesDoc))\n }\n if (!store.holds(user, ns.solid('privateTypeIndex'), privateTypeIndex, preferencesDoc)) {\n toInsert.push(st(user, ns.solid('privateTypeIndex'), privateTypeIndex, preferencesDoc))\n }\n\n if (toInsert.length > 0) {\n await store.updater.update([], toInsert)\n await store.fetcher.load(preferencesDoc)\n }\n\n await ensurePublicTypeIndexAclOnCreate(user, publicTypeIndex, createdProfilePublicTypeIndexLink)\n await ensurePrivateTypeIndexOnCreate(privateTypeIndex)\n }\n\n async function ensurePreferencesDocExists(preferencesFile: NamedNode): Promise<boolean> {\n try {\n const created = await utilityLogic.loadOrCreateWithContentOnCreate(preferencesFile, preferencesFileDocument())\n if (created) {\n return true\n }\n return false\n } catch (err) {\n if (err.response?.status === 401) {\n throw new UnauthorizedError()\n }\n if (err.response?.status === 403) {\n if (differentOrigin(preferencesFile)) {\n throw new CrossOriginForbiddenError()\n }\n throw new SameOriginForbiddenError()\n }\n throw err\n }\n }\n\n /**\n * loads the preference without throwing errors - if it can create it it does so.\n * remark: it still throws error if it cannot load profile.\n * @param user\n * @returns undefined if preferenceFile cannot be returned or NamedNode if it can find it or create it\n */\n async function silencedLoadPreferences(user: NamedNode): Promise <NamedNode | undefined> {\n try {\n return await loadPreferences(user)\n } catch (err) {\n return undefined\n }\n }\n\n /**\n * loads the preference without returning different errors if it cannot create or load it.\n * remark: it also throws error if it cannot load profile.\n * @param user\n * @returns undefined if preferenceFile cannot be an Error or NamedNode if it can find it or create it\n */\n async function loadPreferences (user: NamedNode): Promise <NamedNode> {\n const cachedPreferencesFile = cachedPreferencesFileByWebId.get(user.uri)\n if (cachedPreferencesFile) {\n return cachedPreferencesFile\n }\n\n const inFlight = loadPreferencesInFlight.get(user.uri)\n if (inFlight) {\n return inFlight\n }\n\n const run = (async (): Promise<NamedNode> => {\n await loadProfile(user)\n\n const possiblePreferencesFile = suggestPreferencesFile(user)\n let preferencesFile\n try {\n const existingPreferencesFile = store.any(user, ns.space('preferencesFile'), null, user.doc()) as NamedNode | null\n if (existingPreferencesFile) {\n preferencesFile = existingPreferencesFile\n } else {\n preferencesFile = await utilityLogic.followOrCreateLink(user, ns.space('preferencesFile') as NamedNode, possiblePreferencesFile, user.doc())\n }\n\n await ensureOwnerOnlyAclForSettings(user, preferencesFile as NamedNode)\n await ensurePreferencesDocExists(preferencesFile as NamedNode)\n await initializePreferencesDefaults(user, preferencesFile as NamedNode)\n } catch (err) {\n const message = `User ${user} has no pointer in profile to preferences file.`\n debug.warn(message)\n // we are listing the possible errors\n if (err instanceof NotEditableError) { throw err }\n if (err instanceof WebOperationError) { throw err }\n if (err instanceof UnauthorizedError) { throw err }\n if (err instanceof CrossOriginForbiddenError) { throw err }\n if (err instanceof SameOriginForbiddenError) { throw err }\n if (err instanceof FetchError) { throw err }\n throw err\n }\n\n try {\n await store.fetcher.load(preferencesFile as NamedNode)\n } catch (err) { // Maybe a permission problem or origin problem\n const msg = `Unable to load preference of user ${user}: ${err}`\n if (err.response?.status === 404) {\n // Self-heal when a stale profile pointer references a missing preferences file.\n await ensureOwnerOnlyAclForSettings(user, preferencesFile as NamedNode)\n await ensurePreferencesDocExists(preferencesFile as NamedNode)\n await initializePreferencesDefaults(user, preferencesFile as NamedNode)\n await store.fetcher.load(preferencesFile as NamedNode)\n return preferencesFile as NamedNode\n }\n debug.warn(msg)\n if (err.response.status === 401) {\n throw new UnauthorizedError()\n }\n if (err.response.status === 403) {\n if (differentOrigin(preferencesFile)) {\n throw new CrossOriginForbiddenError()\n }\n throw new SameOriginForbiddenError()\n }\n /*if (err.response.status === 404) {\n throw new NotFoundError();\n }*/\n throw new Error(msg)\n }\n cachedPreferencesFileByWebId.set(user.uri, preferencesFile as NamedNode)\n return preferencesFile as NamedNode\n })()\n\n loadPreferencesInFlight.set(user.uri, run)\n try {\n return await run\n } finally {\n if (loadPreferencesInFlight.get(user.uri) === run) {\n loadPreferencesInFlight.delete(user.uri)\n }\n }\n }\n\n async function loadProfile (user: NamedNode):Promise <NamedNode> {\n if (!user) {\n throw new Error('loadProfile: no user given.')\n }\n try {\n await store.fetcher.load(user.doc())\n } catch (err) {\n throw new Error(`Unable to load profile of user ${user}: ${err}`)\n }\n return user.doc()\n }\n\n async function loadMe(): Promise<NamedNode> {\n const me = authn.currentUser()\n if (me === null) {\n throw new Error('Current user not found! Not logged in?')\n }\n await store.fetcher.load(me.doc())\n return me\n }\n\n function getPodRoot(user: NamedNode): NamedNode {\n const podRoot = findStorage(user)\n if (!podRoot) {\n throw new Error('User pod root not found!')\n }\n return podRoot as NamedNode\n }\n\n async function getMainInbox(user: NamedNode): Promise<NamedNode> {\n await store.fetcher.load(user)\n const mainInbox = store.any(user, ns.ldp('inbox'), undefined, user.doc())\n if (!mainInbox) {\n throw new Error('User main inbox not found!')\n }\n return mainInbox as NamedNode\n }\n\n function findStorage(me: NamedNode) {\n return store.any(me, ns.space('storage'), undefined, me.doc())\n }\n\n return {\n loadMe,\n getPodRoot,\n getMainInbox,\n findStorage,\n loadPreferences,\n loadProfile,\n silencedLoadPreferences\n }\n}\n"],"mappings":"qbAaA,SAAgB,EAAmB,EAAO,EAAO,EAA4B,CACzE,IAAM,EAAK,EAAA,GACL,EAAiB,EAAA,qBAAqB,CAAK,EAC3C,E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AC,EAC1B,CACX,CAEA,SAAS,EAAW,EAA4B,CAC5C,IAAM,EAAU,EAAY,CAAI,EAChC,GAAI,CAAC,EACD,MAAU,MAAM,0BAA0B,EAE9C,OAAO,CACX,CAEA,eAAe,EAAa,EAAqC,CAC7D,MAAM,EAAM,QAAQ,KAAK,CAAI,EAC7B,IAAM,EAAY,EAAM,IAAI,EAAM,EAAG,IAAI,OAAO,EAAG,IAAA,GAAW,EAAK,IAAI,CAAC,EACxE,GAAI,CAAC,EACD,MAAU,MAAM,4BAA4B,EAEhD,OAAO,CACX,CAEA,SAAS,EAAY,EAAe,CAChC,OAAO,EAAM,IAAI,EAAI,EAAG,MAAM,SAAS,EAAG,IAAA,GAAW,EAAG,IAAI,CAAC,CACjE,CAEA,MAAO,CACH,SACA,aACA,eACA,cACA,kBACA,cACA,yBACJ,CACJ"}
|
|
@@ -1,184 +0,0 @@
|
|
|
1
|
-
import { warn as e } from "../util/debug.esm.js";
|
|
2
|
-
import { ns as t } from "../util/ns.esm.js";
|
|
3
|
-
import { ACL_LINK as n } from "../acl/aclLogic.esm.js";
|
|
4
|
-
import { differentOrigin as r, suggestPreferencesFile as i } from "../util/utils.esm.js";
|
|
5
|
-
import { CrossOriginForbiddenError as a, FetchError as o, NotEditableError as s, SameOriginForbiddenError as c, UnauthorizedError as l, WebOperationError as u } from "../logic/CustomError.esm.js";
|
|
6
|
-
import { privateTypeIndexDocument as d, publicTypeIndexDocument as f } from "../typeIndex/typeIndexDocuments.esm.js";
|
|
7
|
-
import { publicTypeIndexAclDocument as p } from "../typeIndex/typeIndexAclDocuments.esm.js";
|
|
8
|
-
import { preferencesFileDocument as m } from "./profileDocuments.esm.js";
|
|
9
|
-
import { ownerOnlyContainerAclDocument as h } from "./profileAclDocuments.esm.js";
|
|
10
|
-
import { createContainerLogic as g } from "../util/containerLogic.esm.js";
|
|
11
|
-
import { literal as _, st as v, sym as y } from "rdflib";
|
|
12
|
-
//#region src/profile/profileLogic.ts
|
|
13
|
-
function b(b, x, S) {
|
|
14
|
-
let C = t, w = g(b), T = /* @__PURE__ */ new Map(), E = /* @__PURE__ */ new Map();
|
|
15
|
-
function D(e) {
|
|
16
|
-
return !!e && (e.startsWith("https://") || e.startsWith("http://"));
|
|
17
|
-
}
|
|
18
|
-
function O(e) {
|
|
19
|
-
let t = e.doc(), n = t.dir();
|
|
20
|
-
if (n?.uri && D(n.uri)) return n.uri;
|
|
21
|
-
let r = t.uri;
|
|
22
|
-
if (!r || !D(r)) return null;
|
|
23
|
-
let i = r.split("#")[0], a = i.lastIndexOf("/");
|
|
24
|
-
return a === -1 ? null : i.slice(0, a + 1);
|
|
25
|
-
}
|
|
26
|
-
function k(e, t) {
|
|
27
|
-
let n = O(e);
|
|
28
|
-
if (!n) throw Error(`Cannot derive directory for preferences file ${e.uri}`);
|
|
29
|
-
return y(n + t);
|
|
30
|
-
}
|
|
31
|
-
function A(e) {
|
|
32
|
-
if (e?.response?.status === 404) return !0;
|
|
33
|
-
let t = `${e?.message || e || ""}`;
|
|
34
|
-
return t.includes("404") || t.includes("Not Found");
|
|
35
|
-
}
|
|
36
|
-
async function j(e) {
|
|
37
|
-
let t = y(e);
|
|
38
|
-
try {
|
|
39
|
-
await b.fetcher.load(t);
|
|
40
|
-
return;
|
|
41
|
-
} catch (e) {
|
|
42
|
-
if (!A(e)) throw e;
|
|
43
|
-
}
|
|
44
|
-
await w.createContainer(e);
|
|
45
|
-
}
|
|
46
|
-
async function M(e, t) {
|
|
47
|
-
let r = O(t);
|
|
48
|
-
if (!r) throw Error(`Cannot derive settings directory from ${t.uri}`);
|
|
49
|
-
await j(r);
|
|
50
|
-
let i = y(r), a;
|
|
51
|
-
try {
|
|
52
|
-
await b.fetcher.load(i), a = b.any(i, n)?.value;
|
|
53
|
-
} catch (e) {
|
|
54
|
-
if (!A(e)) throw e;
|
|
55
|
-
}
|
|
56
|
-
a ||= `${r}.acl`;
|
|
57
|
-
let o = y(a);
|
|
58
|
-
try {
|
|
59
|
-
await b.fetcher.load(o);
|
|
60
|
-
return;
|
|
61
|
-
} catch (e) {
|
|
62
|
-
if (!A(e)) throw e;
|
|
63
|
-
}
|
|
64
|
-
await b.fetcher.webOperation("PUT", o.uri, {
|
|
65
|
-
data: h(e.uri),
|
|
66
|
-
contentType: "text/turtle"
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
async function N(e, t, r = !1) {
|
|
70
|
-
if (!await S.loadOrCreateWithContentOnCreate(t, f()) && !r) return;
|
|
71
|
-
let i;
|
|
72
|
-
try {
|
|
73
|
-
await b.fetcher.load(t), i = b.any(t, n)?.value;
|
|
74
|
-
} catch (e) {
|
|
75
|
-
if (!A(e)) throw e;
|
|
76
|
-
}
|
|
77
|
-
i ||= `${t.uri}.acl`;
|
|
78
|
-
let a = y(i);
|
|
79
|
-
try {
|
|
80
|
-
await b.fetcher.webOperation("PUT", a.uri, {
|
|
81
|
-
data: p(e.uri, t.uri),
|
|
82
|
-
contentType: "text/turtle",
|
|
83
|
-
headers: { "If-None-Match": "*" }
|
|
84
|
-
});
|
|
85
|
-
} catch (e) {
|
|
86
|
-
if ((e?.response?.status ?? e?.status) !== 412) throw e;
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
async function P(e) {
|
|
90
|
-
await S.loadOrCreateWithContentOnCreate(e, d());
|
|
91
|
-
}
|
|
92
|
-
async function F(e, t) {
|
|
93
|
-
let n = t.doc(), r = e.doc();
|
|
94
|
-
await b.fetcher.load(n);
|
|
95
|
-
let i = b.any(e, C.solid("publicTypeIndex"), null, r), a = b.any(e, C.solid("publicTypeIndex"), null, n), o = i || a || k(t, "publicTypeIndex.ttl"), s = b.any(e, C.solid("privateTypeIndex"), null, n) || k(t, "privateTypeIndex.ttl"), c = !i;
|
|
96
|
-
c && await S.followOrCreateLinkWithContentOnCreate(e, C.solid("publicTypeIndex"), o, r, f());
|
|
97
|
-
let l = [];
|
|
98
|
-
b.holds(n, C.rdf("type"), C.space("ConfigurationFile"), n) || l.push(v(n, C.rdf("type"), C.space("ConfigurationFile"), n)), b.holds(n, C.dct("title"), void 0, n) || l.push(v(n, C.dct("title"), _("Preferences file"), n)), b.holds(e, C.solid("publicTypeIndex"), o, n) || l.push(v(e, C.solid("publicTypeIndex"), o, n)), b.holds(e, C.solid("privateTypeIndex"), s, n) || l.push(v(e, C.solid("privateTypeIndex"), s, n)), l.length > 0 && (await b.updater.update([], l), await b.fetcher.load(n)), await N(e, o, c), await P(s);
|
|
99
|
-
}
|
|
100
|
-
async function I(e) {
|
|
101
|
-
try {
|
|
102
|
-
return !!await S.loadOrCreateWithContentOnCreate(e, m());
|
|
103
|
-
} catch (t) {
|
|
104
|
-
throw t.response?.status === 401 ? new l() : t.response?.status === 403 ? r(e) ? new a() : new c() : t;
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
async function L(e) {
|
|
108
|
-
try {
|
|
109
|
-
return await R(e);
|
|
110
|
-
} catch {
|
|
111
|
-
return;
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
async function R(t) {
|
|
115
|
-
let n = E.get(t.uri);
|
|
116
|
-
if (n) return n;
|
|
117
|
-
let d = T.get(t.uri);
|
|
118
|
-
if (d) return d;
|
|
119
|
-
let f = (async () => {
|
|
120
|
-
await z(t);
|
|
121
|
-
let n = i(t), d;
|
|
122
|
-
try {
|
|
123
|
-
d = b.any(t, C.space("preferencesFile"), null, t.doc()) || await S.followOrCreateLink(t, C.space("preferencesFile"), n, t.doc()), await M(t, d), await I(d), await F(t, d);
|
|
124
|
-
} catch (n) {
|
|
125
|
-
throw e(`User ${t} has no pointer in profile to preferences file.`), n instanceof s || n instanceof u || n instanceof l || n instanceof a || n instanceof c || n instanceof o, n;
|
|
126
|
-
}
|
|
127
|
-
try {
|
|
128
|
-
await b.fetcher.load(d);
|
|
129
|
-
} catch (n) {
|
|
130
|
-
let i = `Unable to load preference of user ${t}: ${n}`;
|
|
131
|
-
if (n.response?.status === 404) return await M(t, d), await I(d), await F(t, d), await b.fetcher.load(d), d;
|
|
132
|
-
throw e(i), n.response.status === 401 ? new l() : n.response.status === 403 ? r(d) ? new a() : new c() : Error(i);
|
|
133
|
-
}
|
|
134
|
-
return E.set(t.uri, d), d;
|
|
135
|
-
})();
|
|
136
|
-
T.set(t.uri, f);
|
|
137
|
-
try {
|
|
138
|
-
return await f;
|
|
139
|
-
} finally {
|
|
140
|
-
T.get(t.uri) === f && T.delete(t.uri);
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
async function z(e) {
|
|
144
|
-
if (!e) throw Error("loadProfile: no user given.");
|
|
145
|
-
try {
|
|
146
|
-
await b.fetcher.load(e.doc());
|
|
147
|
-
} catch (t) {
|
|
148
|
-
throw Error(`Unable to load profile of user ${e}: ${t}`);
|
|
149
|
-
}
|
|
150
|
-
return e.doc();
|
|
151
|
-
}
|
|
152
|
-
async function B() {
|
|
153
|
-
let e = x.currentUser();
|
|
154
|
-
if (e === null) throw Error("Current user not found! Not logged in?");
|
|
155
|
-
return await b.fetcher.load(e.doc()), e;
|
|
156
|
-
}
|
|
157
|
-
function V(e) {
|
|
158
|
-
let t = U(e);
|
|
159
|
-
if (!t) throw Error("User pod root not found!");
|
|
160
|
-
return t;
|
|
161
|
-
}
|
|
162
|
-
async function H(e) {
|
|
163
|
-
await b.fetcher.load(e);
|
|
164
|
-
let t = b.any(e, C.ldp("inbox"), void 0, e.doc());
|
|
165
|
-
if (!t) throw Error("User main inbox not found!");
|
|
166
|
-
return t;
|
|
167
|
-
}
|
|
168
|
-
function U(e) {
|
|
169
|
-
return b.any(e, C.space("storage"), void 0, e.doc());
|
|
170
|
-
}
|
|
171
|
-
return {
|
|
172
|
-
loadMe: B,
|
|
173
|
-
getPodRoot: V,
|
|
174
|
-
getMainInbox: H,
|
|
175
|
-
findStorage: U,
|
|
176
|
-
loadPreferences: R,
|
|
177
|
-
loadProfile: z,
|
|
178
|
-
silencedLoadPreferences: L
|
|
179
|
-
};
|
|
180
|
-
}
|
|
181
|
-
//#endregion
|
|
182
|
-
export { b as createProfileLogic };
|
|
183
|
-
|
|
184
|
-
//# sourceMappingURL=profileLogic.esm.js.map
|