solid-logic 4.0.8-0 → 4.0.8-2

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.
Files changed (171) hide show
  1. package/README.md +3 -4
  2. package/dist/_virtual/_rolldown/runtime.cjs.js +1 -0
  3. package/dist/acl/aclLogic.cjs.js +2 -0
  4. package/dist/acl/aclLogic.cjs.js.map +1 -0
  5. package/dist/acl/aclLogic.esm.js +56 -0
  6. package/dist/acl/aclLogic.esm.js.map +1 -0
  7. package/dist/authSession/authSession.cjs.js +2 -0
  8. package/dist/authSession/authSession.cjs.js.map +1 -0
  9. package/dist/authSession/authSession.esm.js +22 -0
  10. package/dist/authSession/authSession.esm.js.map +1 -0
  11. package/dist/authSession/events.cjs.js +2 -0
  12. package/dist/authSession/events.cjs.js.map +1 -0
  13. package/dist/authSession/events.esm.js +19 -0
  14. package/dist/authSession/events.esm.js.map +1 -0
  15. package/dist/authSession/issuer.cjs.js +2 -0
  16. package/dist/authSession/issuer.cjs.js.map +1 -0
  17. package/dist/authSession/issuer.esm.js +18 -0
  18. package/dist/authSession/issuer.esm.js.map +1 -0
  19. package/dist/authSession/session.cjs.js +2 -0
  20. package/dist/authSession/session.cjs.js.map +1 -0
  21. package/dist/authSession/session.esm.js +102 -0
  22. package/dist/authSession/session.esm.js.map +1 -0
  23. package/dist/authn/SolidAuthnLogic.cjs.js +2 -0
  24. package/dist/authn/SolidAuthnLogic.cjs.js.map +1 -0
  25. package/dist/authn/SolidAuthnLogic.esm.js +104 -0
  26. package/dist/authn/SolidAuthnLogic.esm.js.map +1 -0
  27. package/dist/authn/authUtil.cjs.js +2 -0
  28. package/dist/authn/authUtil.cjs.js.map +1 -0
  29. package/dist/authn/authUtil.esm.js +33 -0
  30. package/dist/authn/authUtil.esm.js.map +1 -0
  31. package/dist/authn/serverLogout.cjs.js +2 -0
  32. package/dist/authn/serverLogout.cjs.js.map +1 -0
  33. package/dist/authn/serverLogout.esm.js +25 -0
  34. package/dist/authn/serverLogout.esm.js.map +1 -0
  35. package/dist/chat/chatLogic.cjs.js +21 -0
  36. package/dist/chat/chatLogic.cjs.js.map +1 -0
  37. package/dist/chat/chatLogic.esm.js +116 -0
  38. package/dist/chat/chatLogic.esm.js.map +1 -0
  39. package/dist/inbox/inboxLogic.cjs.js +2 -0
  40. package/dist/inbox/inboxLogic.cjs.js.map +1 -0
  41. package/dist/inbox/inboxLogic.esm.js +37 -0
  42. package/dist/inbox/inboxLogic.esm.js.map +1 -0
  43. package/dist/index.cjs.js +2 -0
  44. package/dist/index.cjs.js.map +1 -0
  45. package/dist/index.esm.js +13 -0
  46. package/dist/index.esm.js.map +1 -0
  47. package/dist/issuer/issuerLogic.cjs.js +2 -0
  48. package/dist/issuer/issuerLogic.cjs.js.map +1 -0
  49. package/dist/issuer/issuerLogic.esm.js +30 -0
  50. package/dist/issuer/issuerLogic.esm.js.map +1 -0
  51. package/dist/logic/CustomError.cjs.js +2 -0
  52. package/dist/logic/CustomError.cjs.js.map +1 -0
  53. package/dist/logic/CustomError.esm.js +14 -0
  54. package/dist/logic/CustomError.esm.js.map +1 -0
  55. package/dist/logic/solidLogic.cjs.js +2 -0
  56. package/dist/logic/solidLogic.cjs.js.map +1 -0
  57. package/dist/logic/solidLogic.esm.js +47 -0
  58. package/dist/logic/solidLogic.esm.js.map +1 -0
  59. package/dist/logic/solidLogicSingleton.cjs.js +2 -0
  60. package/dist/logic/solidLogicSingleton.cjs.js.map +1 -0
  61. package/dist/logic/solidLogicSingleton.esm.js +19 -0
  62. package/dist/logic/solidLogicSingleton.esm.js.map +1 -0
  63. package/dist/profile/profileAclDocuments.cjs.js +3 -0
  64. package/dist/profile/profileAclDocuments.cjs.js.map +1 -0
  65. package/dist/profile/profileAclDocuments.esm.js +17 -0
  66. package/dist/profile/profileAclDocuments.esm.js.map +1 -0
  67. package/dist/profile/profileDocuments.cjs.js +3 -0
  68. package/dist/profile/profileDocuments.cjs.js.map +1 -0
  69. package/dist/profile/profileDocuments.esm.js +15 -0
  70. package/dist/profile/profileDocuments.esm.js.map +1 -0
  71. package/dist/profile/profileLogic.cjs.js +2 -0
  72. package/dist/profile/profileLogic.cjs.js.map +1 -0
  73. package/dist/profile/profileLogic.esm.js +184 -0
  74. package/dist/profile/profileLogic.esm.js.map +1 -0
  75. package/dist/typeIndex/typeIndexAclDocuments.cjs.js +3 -0
  76. package/dist/typeIndex/typeIndexAclDocuments.cjs.js.map +1 -0
  77. package/dist/typeIndex/typeIndexAclDocuments.esm.js +35 -0
  78. package/dist/typeIndex/typeIndexAclDocuments.esm.js.map +1 -0
  79. package/dist/typeIndex/typeIndexDocuments.cjs.js +4 -0
  80. package/dist/typeIndex/typeIndexDocuments.cjs.js.map +1 -0
  81. package/dist/typeIndex/typeIndexDocuments.esm.js +21 -0
  82. package/dist/typeIndex/typeIndexDocuments.esm.js.map +1 -0
  83. package/dist/typeIndex/typeIndexLogic.cjs.js +2 -0
  84. package/dist/typeIndex/typeIndexLogic.cjs.js.map +1 -0
  85. package/dist/typeIndex/typeIndexLogic.esm.js +185 -0
  86. package/dist/typeIndex/typeIndexLogic.esm.js.map +1 -0
  87. package/dist/util/containerLogic.cjs.js +2 -0
  88. package/dist/util/containerLogic.cjs.js.map +1 -0
  89. package/dist/util/containerLogic.esm.js +37 -0
  90. package/dist/util/containerLogic.esm.js.map +1 -0
  91. package/dist/util/debug.cjs.js +2 -0
  92. package/dist/util/debug.cjs.js.map +1 -0
  93. package/dist/util/debug.esm.js +11 -0
  94. package/dist/util/debug.esm.js.map +1 -0
  95. package/dist/util/ns.cjs.js +2 -0
  96. package/dist/util/ns.cjs.js.map +1 -0
  97. package/dist/util/ns.esm.js +8 -0
  98. package/dist/util/ns.esm.js.map +1 -0
  99. package/dist/util/utilityLogic.cjs.js +6 -0
  100. package/dist/util/utilityLogic.cjs.js.map +1 -0
  101. package/dist/util/utilityLogic.esm.js +149 -0
  102. package/dist/util/utilityLogic.esm.js.map +1 -0
  103. package/dist/util/utils.cjs.js +2 -0
  104. package/dist/util/utils.cjs.js.map +1 -0
  105. package/dist/util/utils.esm.js +22 -0
  106. package/dist/util/utils.esm.js.map +1 -0
  107. package/package.json +25 -31
  108. package/dist/2729812e0bfc062ee77a.js +0 -1
  109. package/dist/a9c30b64ceaae48b72f0.js +0 -2045
  110. package/dist/acl/aclLogic.d.ts +0 -5
  111. package/dist/acl/aclLogic.d.ts.map +0 -1
  112. package/dist/authSession/authSession.d.ts +0 -42
  113. package/dist/authSession/authSession.d.ts.map +0 -1
  114. package/dist/authSession/events.d.ts +0 -24
  115. package/dist/authSession/events.d.ts.map +0 -1
  116. package/dist/authSession/issuer.d.ts +0 -8
  117. package/dist/authSession/issuer.d.ts.map +0 -1
  118. package/dist/authSession/session.d.ts +0 -45
  119. package/dist/authSession/session.d.ts.map +0 -1
  120. package/dist/authn/SolidAuthnLogic.d.ts +0 -42
  121. package/dist/authn/SolidAuthnLogic.d.ts.map +0 -1
  122. package/dist/authn/authUtil.d.ts +0 -17
  123. package/dist/authn/authUtil.d.ts.map +0 -1
  124. package/dist/authn/serverLogout.d.ts +0 -6
  125. package/dist/authn/serverLogout.d.ts.map +0 -1
  126. package/dist/chat/chatLogic.d.ts +0 -3
  127. package/dist/chat/chatLogic.d.ts.map +0 -1
  128. package/dist/inbox/inboxLogic.d.ts +0 -3
  129. package/dist/inbox/inboxLogic.d.ts.map +0 -1
  130. package/dist/index.d.ts +0 -14
  131. package/dist/index.d.ts.map +0 -1
  132. package/dist/issuer/issuerLogic.d.ts +0 -8
  133. package/dist/issuer/issuerLogic.d.ts.map +0 -1
  134. package/dist/logic/CustomError.d.ts +0 -21
  135. package/dist/logic/CustomError.d.ts.map +0 -1
  136. package/dist/logic/solidLogic.d.ts +0 -6
  137. package/dist/logic/solidLogic.d.ts.map +0 -1
  138. package/dist/logic/solidLogicSingleton.d.ts +0 -4
  139. package/dist/logic/solidLogicSingleton.d.ts.map +0 -1
  140. package/dist/profile/profileAclDocuments.d.ts +0 -2
  141. package/dist/profile/profileAclDocuments.d.ts.map +0 -1
  142. package/dist/profile/profileDocuments.d.ts +0 -2
  143. package/dist/profile/profileDocuments.d.ts.map +0 -1
  144. package/dist/profile/profileLogic.d.ts +0 -3
  145. package/dist/profile/profileLogic.d.ts.map +0 -1
  146. package/dist/solid-logic.esm.js +0 -2339
  147. package/dist/solid-logic.esm.js.map +0 -1
  148. package/dist/solid-logic.esm.min.js +0 -2
  149. package/dist/solid-logic.esm.min.js.map +0 -1
  150. package/dist/solid-logic.js +0 -7529
  151. package/dist/solid-logic.js.map +0 -1
  152. package/dist/solid-logic.min.js +0 -2
  153. package/dist/solid-logic.min.js.map +0 -1
  154. package/dist/typeIndex/typeIndexAclDocuments.d.ts +0 -2
  155. package/dist/typeIndex/typeIndexAclDocuments.d.ts.map +0 -1
  156. package/dist/typeIndex/typeIndexDocuments.d.ts +0 -3
  157. package/dist/typeIndex/typeIndexDocuments.d.ts.map +0 -1
  158. package/dist/typeIndex/typeIndexLogic.d.ts +0 -3
  159. package/dist/typeIndex/typeIndexLogic.d.ts.map +0 -1
  160. package/dist/types.d.ts +0 -113
  161. package/dist/types.d.ts.map +0 -1
  162. package/dist/util/containerLogic.d.ts +0 -11
  163. package/dist/util/containerLogic.d.ts.map +0 -1
  164. package/dist/util/debug.d.ts +0 -5
  165. package/dist/util/debug.d.ts.map +0 -1
  166. package/dist/util/ns.d.ts +0 -2
  167. package/dist/util/ns.d.ts.map +0 -1
  168. package/dist/util/utilityLogic.d.ts +0 -17
  169. package/dist/util/utilityLogic.d.ts.map +0 -1
  170. package/dist/util/utils.d.ts +0 -8
  171. package/dist/util/utils.d.ts.map +0 -1
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,17 @@
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
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,3 @@
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
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,15 @@
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
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,2 @@
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
@@ -0,0 +1 @@
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,EAA0B,IAAI,IAC9B,EAA+B,IAAI,IAEzC,SAAS,EAAkB,EAAyC,CAChE,MAAO,CAAC,CAAC,IAAQ,EAAI,WAAW,UAAU,GAAK,EAAI,WAAW,SAAS,EAC3E,CAEA,SAAS,EAAU,EAAgC,CAC/C,IAAM,EAAM,EAAK,IAAI,EACf,EAAM,EAAI,IAAI,EACpB,GAAI,GAAK,KAAO,EAAkB,EAAI,GAAG,EAAG,OAAO,EAAI,IACvD,IAAM,EAAS,EAAI,IACnB,GAAI,CAAC,GAAU,CAAC,EAAkB,CAAM,EAAG,OAAO,KAClD,IAAM,EAAkB,EAAO,MAAM,GAAG,CAAC,CAAC,GACpC,EAAY,EAAgB,YAAY,GAAG,EAEjD,OADI,IAAc,GAAW,KACtB,EAAgB,MAAM,EAAG,EAAY,CAAC,CACjD,CAEA,SAAS,EAA8B,EAA4B,EAA6B,CAC5F,IAAM,EAAS,EAAU,CAAe,EACxC,GAAI,CAAC,EAAQ,MAAU,MAAM,gDAAgD,EAAgB,KAAK,EAClG,OAAA,EAAA,EAAA,IAAA,CAAW,EAAS,CAAQ,CAChC,CAEA,SAAS,EAAgB,EAAmB,CACxC,GAAI,GAAK,UAAU,SAAW,IAAK,MAAO,GAC1C,IAAM,EAAO,GAAG,GAAK,SAAW,GAAO,KACvC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G,IAAM,GAC1C,EAAwB,OAAO,EAAK,GAAG,CAE/C,CACJ,CAEA,eAAe,EAAa,EAAqC,CAC7D,GAAI,CAAC,EACD,MAAU,MAAM,6BAA6B,EAEjD,GAAI,CACA,MAAM,EAAM,QAAQ,KAAK,EAAK,IAAI,CAAC,CACvC,OAAS,EAAK,CACV,MAAU,MAAM,kCAAkC,EAAK,IAAI,GAAK,CACpE,CACA,OAAO,EAAK,IAAI,CACpB,CAEA,eAAe,GAA6B,CACxC,IAAM,EAAK,EAAM,YAAY,EAC7B,GAAI,IAAO,KACP,MAAU,MAAM,wCAAwC,EAG5D,OADA,MAAM,EAAM,QAAQ,KAAK,EAAG,IAAI,CAAC,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"}
@@ -0,0 +1,184 @@
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
@@ -0,0 +1 @@
1
+ {"version":3,"file":"profileLogic.esm.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":";;;;;;;;;;;;AAaA,SAAgB,EAAmB,GAAO,GAAO,GAA4B;CACzE,IAAM,IAAK,GACL,IAAiB,EAAqB,CAAK,GAC3C,oBAA0B,IAAI,IAAgC,GAC9D,oBAA+B,IAAI,IA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AAM,4BAA4B;EAEhD,OAAO;CACX;CAEA,SAAS,EAAY,GAAe;EAChC,OAAO,EAAM,IAAI,GAAI,EAAG,MAAM,SAAS,GAAG,KAAA,GAAW,EAAG,IAAI,CAAC;CACjE;CAEA,OAAO;EACH;EACA;EACA;EACA;EACA;EACA;EACA;CACJ;AACJ"}
@@ -0,0 +1,3 @@
1
+ function e(e,t){let n=new URL(t).pathname.split(`/`).pop()||`publicTypeIndex.ttl`;return[`# ACL resource for the Public Type Index`,``,`@prefix acl: <http://www.w3.org/ns/auth/acl#>.`,`@prefix foaf: <http://xmlns.com/foaf/0.1/>.`,``,`<#owner>`,` a acl:Authorization;`,``,` acl:agent`,` <${e}>;`,``,` acl:accessTo <./${n}>;`,``,` acl:mode`,` acl:Read, acl:Write, acl:Control.`,``,`# Public-readable`,`<#public>`,` a acl:Authorization;`,``,` acl:agentClass foaf:Agent;`,``,` acl:accessTo <./${n}>;`,``,` acl:mode acl:Read.`].join(`
2
+ `)}exports.publicTypeIndexAclDocument=e;
3
+ //# sourceMappingURL=typeIndexAclDocuments.cjs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"typeIndexAclDocuments.cjs.js","names":[],"sources":["../../src/typeIndex/typeIndexAclDocuments.ts"],"sourcesContent":["export function publicTypeIndexAclDocument(webId: string, publicTypeIndexUri: string): string {\n const fileName = new URL(publicTypeIndexUri).pathname.split('/').pop() || 'publicTypeIndex.ttl'\n return [\n '# ACL resource for the Public Type Index',\n '',\n '@prefix acl: <http://www.w3.org/ns/auth/acl#>.',\n '@prefix foaf: <http://xmlns.com/foaf/0.1/>.',\n '',\n '<#owner>',\n ' a acl:Authorization;',\n '',\n ' acl:agent',\n ` <${webId}>;`,\n '',\n ` acl:accessTo <./${fileName}>;`,\n '',\n ' acl:mode',\n ' acl:Read, acl:Write, acl:Control.',\n '',\n '# Public-readable',\n '<#public>',\n ' a acl:Authorization;',\n '',\n ' acl:agentClass foaf:Agent;',\n '',\n ` acl:accessTo <./${fileName}>;`,\n '',\n ' acl:mode acl:Read.'\n ].join('\\n')\n}\n"],"mappings":"AAAA,SAAgB,EAA2B,EAAe,EAAoC,CAC1F,IAAM,EAAW,IAAI,IAAI,CAAkB,CAAC,CAAC,SAAS,MAAM,GAAG,CAAC,CAAC,IAAI,GAAK,sBAC1E,MAAO,CACH,2CACA,GACA,iDACA,8CACA,GACA,WACA,2BACA,GACA,gBACA,YAAY,EAAM,IAClB,GACA,uBAAuB,EAAS,IAChC,GACA,eACA,4CACA,GACA,oBACA,YACA,2BACA,GACA,iCACA,GACA,uBAAuB,EAAS,IAChC,GACA,wBACJ,CAAC,CAAC,KAAK;CAAI,CACf"}
@@ -0,0 +1,35 @@
1
+ //#region src/typeIndex/typeIndexAclDocuments.ts
2
+ function e(e, t) {
3
+ let n = new URL(t).pathname.split("/").pop() || "publicTypeIndex.ttl";
4
+ return [
5
+ "# ACL resource for the Public Type Index",
6
+ "",
7
+ "@prefix acl: <http://www.w3.org/ns/auth/acl#>.",
8
+ "@prefix foaf: <http://xmlns.com/foaf/0.1/>.",
9
+ "",
10
+ "<#owner>",
11
+ " a acl:Authorization;",
12
+ "",
13
+ " acl:agent",
14
+ ` <${e}>;`,
15
+ "",
16
+ ` acl:accessTo <./${n}>;`,
17
+ "",
18
+ " acl:mode",
19
+ " acl:Read, acl:Write, acl:Control.",
20
+ "",
21
+ "# Public-readable",
22
+ "<#public>",
23
+ " a acl:Authorization;",
24
+ "",
25
+ " acl:agentClass foaf:Agent;",
26
+ "",
27
+ ` acl:accessTo <./${n}>;`,
28
+ "",
29
+ " acl:mode acl:Read."
30
+ ].join("\n");
31
+ }
32
+ //#endregion
33
+ export { e as publicTypeIndexAclDocument };
34
+
35
+ //# sourceMappingURL=typeIndexAclDocuments.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"typeIndexAclDocuments.esm.js","names":[],"sources":["../../src/typeIndex/typeIndexAclDocuments.ts"],"sourcesContent":["export function publicTypeIndexAclDocument(webId: string, publicTypeIndexUri: string): string {\n const fileName = new URL(publicTypeIndexUri).pathname.split('/').pop() || 'publicTypeIndex.ttl'\n return [\n '# ACL resource for the Public Type Index',\n '',\n '@prefix acl: <http://www.w3.org/ns/auth/acl#>.',\n '@prefix foaf: <http://xmlns.com/foaf/0.1/>.',\n '',\n '<#owner>',\n ' a acl:Authorization;',\n '',\n ' acl:agent',\n ` <${webId}>;`,\n '',\n ` acl:accessTo <./${fileName}>;`,\n '',\n ' acl:mode',\n ' acl:Read, acl:Write, acl:Control.',\n '',\n '# Public-readable',\n '<#public>',\n ' a acl:Authorization;',\n '',\n ' acl:agentClass foaf:Agent;',\n '',\n ` acl:accessTo <./${fileName}>;`,\n '',\n ' acl:mode acl:Read.'\n ].join('\\n')\n}\n"],"mappings":";AAAA,SAAgB,EAA2B,GAAe,GAAoC;CAC1F,IAAM,IAAW,IAAI,IAAI,CAAkB,CAAC,CAAC,SAAS,MAAM,GAAG,CAAC,CAAC,IAAI,KAAK;CAC1E,OAAO;EACH;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,YAAY,EAAM;EAClB;EACA,uBAAuB,EAAS;EAChC;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,uBAAuB,EAAS;EAChC;EACA;CACJ,CAAC,CAAC,KAAK,IAAI;AACf"}
@@ -0,0 +1,4 @@
1
+ function e(){return[`@prefix solid: <http://www.w3.org/ns/solid/terms#>.`,`<>`,` a solid:TypeIndex ;`,` a solid:ListedDocument.`].join(`
2
+ `)}function t(){return[`@prefix solid: <http://www.w3.org/ns/solid/terms#>.`,`<>`,` a solid:TypeIndex ;`,` a solid:UnlistedDocument.`].join(`
3
+ `)}exports.privateTypeIndexDocument=t,exports.publicTypeIndexDocument=e;
4
+ //# sourceMappingURL=typeIndexDocuments.cjs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"typeIndexDocuments.cjs.js","names":[],"sources":["../../src/typeIndex/typeIndexDocuments.ts"],"sourcesContent":["export function publicTypeIndexDocument(): string {\n return [\n '@prefix solid: <http://www.w3.org/ns/solid/terms#>.',\n '<>',\n ' a solid:TypeIndex ;',\n ' a solid:ListedDocument.'\n ].join('\\n')\n}\n\nexport function privateTypeIndexDocument(): string {\n return [\n '@prefix solid: <http://www.w3.org/ns/solid/terms#>.',\n '<>',\n ' a solid:TypeIndex ;',\n ' a solid:UnlistedDocument.'\n ].join('\\n')\n}"],"mappings":"AAAA,SAAgB,GAAkC,CAC9C,MAAO,CACH,sDACA,KACA,0BACA,6BACJ,CAAC,CAAC,KAAK;CAAI,CACf,CAEA,SAAgB,GAAmC,CAC/C,MAAO,CACH,sDACA,KACA,0BACA,+BACJ,CAAC,CAAC,KAAK;CAAI,CACf"}
@@ -0,0 +1,21 @@
1
+ //#region src/typeIndex/typeIndexDocuments.ts
2
+ function e() {
3
+ return [
4
+ "@prefix solid: <http://www.w3.org/ns/solid/terms#>.",
5
+ "<>",
6
+ " a solid:TypeIndex ;",
7
+ " a solid:ListedDocument."
8
+ ].join("\n");
9
+ }
10
+ function t() {
11
+ return [
12
+ "@prefix solid: <http://www.w3.org/ns/solid/terms#>.",
13
+ "<>",
14
+ " a solid:TypeIndex ;",
15
+ " a solid:UnlistedDocument."
16
+ ].join("\n");
17
+ }
18
+ //#endregion
19
+ export { t as privateTypeIndexDocument, e as publicTypeIndexDocument };
20
+
21
+ //# sourceMappingURL=typeIndexDocuments.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"typeIndexDocuments.esm.js","names":[],"sources":["../../src/typeIndex/typeIndexDocuments.ts"],"sourcesContent":["export function publicTypeIndexDocument(): string {\n return [\n '@prefix solid: <http://www.w3.org/ns/solid/terms#>.',\n '<>',\n ' a solid:TypeIndex ;',\n ' a solid:ListedDocument.'\n ].join('\\n')\n}\n\nexport function privateTypeIndexDocument(): string {\n return [\n '@prefix solid: <http://www.w3.org/ns/solid/terms#>.',\n '<>',\n ' a solid:TypeIndex ;',\n ' a solid:UnlistedDocument.'\n ].join('\\n')\n}"],"mappings":";AAAA,SAAgB,IAAkC;CAC9C,OAAO;EACH;EACA;EACA;EACA;CACJ,CAAC,CAAC,KAAK,IAAI;AACf;AAEA,SAAgB,IAAmC;CAC/C,OAAO;EACH;EACA;EACA;EACA;CACJ,CAAC,CAAC,KAAK,IAAI;AACf"}
@@ -0,0 +1,2 @@
1
+ const e=require("../util/debug.cjs.js"),t=require("../util/ns.cjs.js"),n=require("../util/utils.cjs.js"),r=require("./typeIndexDocuments.cjs.js");let i=require("rdflib");function a(a,o,s,c){let l=t.ns;function u(e){return!!e&&(e.startsWith(`https://`)||e.startsWith(`http://`))}function d(e,t){return a.each(void 0,l.solid(`instance`),e).filter(e=>a.holds(e,l.solid(`forClass`),t))}async function f(t){if(!t)throw Error(`loadTypeIndexesFor: No user given`);let n=await s.loadProfile(t),i=null;try{i=v(t)}catch{let n=`User ${t} has no usable profile document directory for publicTypeIndex.`;e.warn(n)}let o;try{o=a.any(t,l.solid(`publicTypeIndex`),void 0,n)||(i?await c.followOrCreateLinkWithContentOnCreate(t,l.solid(`publicTypeIndex`),i,n,r.publicTypeIndexDocument()):null)}catch(n){let r=`User ${t} has no pointer in profile to publicTypeIndex file: ${n}`;e.warn(r)}let u=o?[{label:`public`,index:o,agent:t}]:[],d;try{d=await s.silencedLoadPreferences(t)}catch{d=null}let f;if(d){let i=null;try{i=y(d)}catch{let n=`User ${t} has no usable preferences document directory for privateTypeIndex.`;e.warn(n)}let o;try{o=a.any(t,l.solid(`privateTypeIndex`),void 0,n)||(i?await c.followOrCreateLinkWithContentOnCreate(t,l.solid(`privateTypeIndex`),i,d,r.privateTypeIndexDocument()):null)}catch(n){let r=`User ${t} has no pointer in preference file to privateTypeIndex file: ${n}`;e.warn(r)}f=o?[{label:`private`,index:o,agent:t}]:[]}else f=[];let p=u.concat(f);if(p.length===0)return p;let m=p.map(e=>e.index);try{await a.fetcher.load(m)}catch(t){e.warn(`Problems loading type index: `,t)}return p}async function p(t){let n;try{n=await s.silencedLoadPreferences(t)}catch{let n=`User ${t} has no pointer in profile to preferences file.`;e.warn(n)}if(n){let r=a.each(t,l.solid(`community`),void 0,n).concat(a.each(t,l.solid(`community`),void 0,t.doc())),i=[];for(let n of r){if(n.termType!==`NamedNode`||!u(n.uri)){e.warn(`Skipping malformed community node for ${t}: ${n}`);continue}try{i=i.concat(await f(n))}catch(t){e.warn(`Skipping community type indexes for ${n.uri}: ${t}`)}}return i}return[]}async function m(e){return(await f(e)).concat(await p(e))}async function h(e,t){let n=await m(t),r=[];for(let t of n){let n=await S(t,e);r=r.concat(n)}return r}async function g(e){let t=o.currentUser();if(!t)throw Error(`getAppInstances: Must be logged in to find apps.`);return(await h(e,t)).map(e=>e.instance)}function _(t){let n=t.doc(),r=n.dir();if(r?.uri&&u(r.uri))return r.uri;let i=n.uri;if(!i||!u(i))return e.log(`docDirUri: missing or non-http(s) doc uri for ${t?.uri}`),null;let a=i.split(`#`)[0],o=a.lastIndexOf(`/`);return o===-1?(e.log(`docDirUri: no slash in doc uri ${i}`),null):a.slice(0,o+1)}function v(e){let t=_(e);if(!t)throw Error(`suggestPublicTypeIndex: Cannot derive directory for ${e.uri}`);return(0,i.sym)(t+`publicTypeIndex.ttl`)}function y(e){let t=_(e);if(!t)throw Error(`suggestPrivateTypeIndex: Cannot derive directory for ${e.uri}`);return(0,i.sym)(t+`privateTypeIndex.ttl`)}async function b(e,t,r){let o=n.newThing(t),s=[(0,i.st)(o,l.rdf(`type`),l.solid(`TypeRegistration`),t),(0,i.st)(o,l.solid(`forClass`),r,t),(0,i.st)(o,l.solid(`instance`),e,t)];try{await a.updater.update([],s)}catch(n){let r=`Unable to register ${e} in index ${t}: ${n}`;return console.warn(r),null}return o}async function x(e){let t=a.the(null,l.solid(`instance`),e.instance,e.scope.index);if(!t)throw Error(`deleteTypeIndexRegistration: No registration found for ${e.instance}`);let n=a.statementsMatching(t,null,null,e.scope.index);await a.updater.update(n,[])}async function S(e,t){let n=e.index,r=[],o=a.statementsMatching(null,l.solid(`instance`),null,n).concat(a.statementsMatching(null,l.solid(`instanceContainer`),null,n)).map(e=>e.subject);for(let s of o){let o=a.any(s,l.solid(`forClass`),null,n);if(!t||o.sameTerm(t)){let t=a.each(s,l.solid(`instance`),null,n);for(let n of t)r.push({instance:n,type:o,scope:e});let c=a.each(s,l.solid(`instanceContainer`),null,n);for(let t of c)await a.fetcher.load(t),r.push({instance:(0,i.sym)(t.value),type:o,scope:e})}}return r}return{registerInTypeIndex:b,getRegistrations:d,loadTypeIndexesFor:f,loadCommunityTypeIndexes:p,loadAllTypeIndexes:m,getScopedAppInstances:h,getAppInstances:g,suggestPublicTypeIndex:v,suggestPrivateTypeIndex:y,deleteTypeIndexRegistration:x,getScopedAppsFromIndex:S}}exports.createTypeIndexLogic=a;
2
+ //# sourceMappingURL=typeIndexLogic.cjs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"typeIndexLogic.cjs.js","names":[],"sources":["../../src/typeIndex/typeIndexLogic.ts"],"sourcesContent":["import { NamedNode, st, sym } from 'rdflib'\nimport { ScopedApp, TypeIndexLogic, TypeIndexScope } from '../types'\nimport * as debug from '../util/debug'\nimport { ns as namespace } from '../util/ns'\nimport { newThing } from '../util/utils'\nimport { privateTypeIndexDocument, publicTypeIndexDocument } from './typeIndexDocuments'\n\nexport function createTypeIndexLogic(store, authn, profileLogic, utilityLogic): TypeIndexLogic {\n const ns = namespace\n\n function isAbsoluteHttpUri(uri: string | null | undefined): boolean {\n return !!uri && (uri.startsWith('https://') || uri.startsWith('http://'))\n }\n\n function getRegistrations(instance, theClass) {\n return store\n .each(undefined, ns.solid('instance'), instance)\n .filter((r) => {\n return store.holds(r, ns.solid('forClass'), theClass)\n })\n }\n\n async function loadTypeIndexesFor(user: NamedNode): Promise<Array<TypeIndexScope>> {\n if (!user) throw new Error('loadTypeIndexesFor: No user given')\n const profile = await profileLogic.loadProfile(user)\n\n let suggestion: NamedNode | null = null\n try {\n suggestion = suggestPublicTypeIndex(user)\n } catch (err) {\n const message = `User ${user} has no usable profile document directory for publicTypeIndex.`\n debug.warn(message)\n }\n let publicTypeIndex\n try {\n const existingPublicTypeIndex = store.any(user, ns.solid('publicTypeIndex'), undefined, profile)\n if (existingPublicTypeIndex) {\n publicTypeIndex = existingPublicTypeIndex\n } else if (suggestion) {\n publicTypeIndex = await utilityLogic.followOrCreateLinkWithContentOnCreate(\n user,\n ns.solid('publicTypeIndex') as NamedNode,\n suggestion,\n profile,\n publicTypeIndexDocument()\n )\n } else {\n publicTypeIndex = null\n }\n } catch (err) {\n const message = `User ${user} has no pointer in profile to publicTypeIndex file: ${err}`\n debug.warn(message)\n }\n const publicScopes = publicTypeIndex ? [{ label: 'public', index: publicTypeIndex as NamedNode, agent: user }] : []\n\n let preferencesFile\n try {\n preferencesFile = await profileLogic.silencedLoadPreferences(user)\n } catch (err) {\n preferencesFile = null\n }\n\n let privateScopes\n if (preferencesFile) { // watch out - can be in either as spec was not clear. Legacy is profile.\n // If there is a legacy one linked from the profile, use that.\n // Otherwiae use or make one linked from Preferences\n let suggestedPrivateTypeIndex: NamedNode | null = null\n try {\n suggestedPrivateTypeIndex = suggestPrivateTypeIndex(preferencesFile)\n } catch (err) {\n const message = `User ${user} has no usable preferences document directory for privateTypeIndex.`\n debug.warn(message)\n }\n let privateTypeIndex\n try {\n const existingPrivateTypeIndex = store.any(user, ns.solid('privateTypeIndex'), undefined, profile)\n if (existingPrivateTypeIndex) {\n privateTypeIndex = existingPrivateTypeIndex\n } else if (suggestedPrivateTypeIndex) {\n privateTypeIndex = await utilityLogic.followOrCreateLinkWithContentOnCreate(\n user,\n ns.solid('privateTypeIndex') as NamedNode,\n suggestedPrivateTypeIndex,\n preferencesFile,\n privateTypeIndexDocument()\n )\n } else {\n privateTypeIndex = null\n }\n } catch (err) {\n const message = `User ${user} has no pointer in preference file to privateTypeIndex file: ${err}`\n debug.warn(message)\n }\n privateScopes = privateTypeIndex ? [{ label: 'private', index: privateTypeIndex as NamedNode, agent: user }] : []\n } else {\n privateScopes = []\n }\n const scopes = publicScopes.concat(privateScopes)\n if (scopes.length === 0) return scopes\n const files = scopes.map(scope => scope.index)\n try {\n await store.fetcher.load(files)\n } catch (err) {\n debug.warn('Problems loading type index: ', err)\n }\n return scopes\n }\n\n async function loadCommunityTypeIndexes(user: NamedNode): Promise<TypeIndexScope[]> {\n let preferencesFile\n try {\n preferencesFile = await profileLogic.silencedLoadPreferences(user)\n } catch (err) {\n const message = `User ${user} has no pointer in profile to preferences file.`\n debug.warn(message)\n }\n if (preferencesFile) { // For now, pick up communities as simple links from the preferences file.\n const communities = store.each(user, ns.solid('community'), undefined, preferencesFile as NamedNode).concat(\n store.each(user, ns.solid('community'), undefined, user.doc() as NamedNode)\n )\n let result = []\n for (const org of communities) {\n if (org.termType !== 'NamedNode' || !isAbsoluteHttpUri((org as NamedNode).uri)) {\n debug.warn(`Skipping malformed community node for ${user}: ${org}`)\n continue\n }\n try {\n result = result.concat(await loadTypeIndexesFor(org as NamedNode) as any)\n } catch (err) {\n debug.warn(`Skipping community type indexes for ${(org as NamedNode).uri}: ${err}`)\n }\n }\n return result\n }\n return [] // No communities\n }\n\n async function loadAllTypeIndexes(user: NamedNode) {\n return (await loadTypeIndexesFor(user)).concat(await loadCommunityTypeIndexes(user))\n }\n\n async function getScopedAppInstances(klass: NamedNode, user: NamedNode): Promise<ScopedApp[]> {\n const scopes = await loadAllTypeIndexes(user)\n let scopedApps = []\n for (const scope of scopes) {\n const scopedApps0 = await getScopedAppsFromIndex(scope, klass) as any\n scopedApps = scopedApps.concat(scopedApps0)\n }\n return scopedApps\n }\n\n // This is the function signature which used to be in solid-ui/logic\n // Recommended to use getScopedAppInstances instead as it provides more information.\n //\n async function getAppInstances(klass: NamedNode): Promise<NamedNode[]> {\n const user = authn.currentUser()\n if (!user) throw new Error('getAppInstances: Must be logged in to find apps.')\n const scopedAppInstances = await getScopedAppInstances(klass, user)\n return scopedAppInstances.map(scoped => scoped.instance)\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)) {\n debug.log(`docDirUri: missing or non-http(s) doc uri for ${node?.uri}`)\n return null\n }\n const withoutFragment = docUri.split('#')[0]\n const lastSlash = withoutFragment.lastIndexOf('/')\n if (lastSlash === -1) {\n debug.log(`docDirUri: no slash in doc uri ${docUri}`)\n return null\n }\n return withoutFragment.slice(0, lastSlash + 1)\n }\n\n function suggestPublicTypeIndex(me: NamedNode) {\n const dirUri = docDirUri(me)\n if (!dirUri) throw new Error(`suggestPublicTypeIndex: Cannot derive directory for ${me.uri}`)\n return sym(dirUri + 'publicTypeIndex.ttl')\n }\n // Note this one is based off the pref file not the profile\n\n function suggestPrivateTypeIndex(preferencesFile: NamedNode) {\n const dirUri = docDirUri(preferencesFile)\n if (!dirUri) throw new Error(`suggestPrivateTypeIndex: Cannot derive directory for ${preferencesFile.uri}`)\n return sym(dirUri + 'privateTypeIndex.ttl')\n }\n\n /*\n * Register a new app in a type index\n * used in chat in bookmark.js (solid-ui)\n * Returns the registration object if successful else null\n */\n async function registerInTypeIndex(\n instance: NamedNode,\n index: NamedNode,\n theClass: NamedNode,\n // agent: NamedNode\n ): Promise<NamedNode | null> {\n const registration = newThing(index)\n const ins = [\n // See https://github.com/solid/solid/blob/main/proposals/data-discovery.md\n st(registration, ns.rdf('type'), ns.solid('TypeRegistration'), index),\n st(registration, ns.solid('forClass'), theClass, index),\n st(registration, ns.solid('instance'), instance, index)\n ]\n try {\n await store.updater.update([], ins)\n } catch (err) {\n const msg = `Unable to register ${instance} in index ${index}: ${err}`\n console.warn(msg)\n return null\n }\n return registration\n }\n\n async function deleteTypeIndexRegistration(item) {\n const reg = store.the(null, ns.solid('instance'), item.instance, item.scope.index) as NamedNode\n if (!reg) throw new Error(`deleteTypeIndexRegistration: No registration found for ${item.instance}`)\n const statements = store.statementsMatching(reg, null, null, item.scope.index)\n await store.updater.update(statements, [])\n }\n\n async function getScopedAppsFromIndex(scope: TypeIndexScope, theClass: NamedNode | null): Promise<ScopedApp[]> {\n const index = scope.index\n const results: ScopedApp[] = []\n const registrations = store.statementsMatching(null, ns.solid('instance'), null, index)\n .concat(store.statementsMatching(null, ns.solid('instanceContainer'), null, index))\n .map(st => st.subject)\n for (const reg of registrations) {\n const klass = store.any(reg, ns.solid('forClass'), null, index)\n if (!theClass || klass.sameTerm(theClass)) {\n const instances = store.each(reg, ns.solid('instance'), null, index)\n for (const instance of instances) {\n results.push({ instance, type: klass, scope })\n }\n const containers = store.each(reg, ns.solid('instanceContainer'), null, index)\n for (const instance of containers) {\n await store.fetcher.load(instance)\n results.push({ instance: sym(instance.value), type: klass, scope })\n }\n }\n }\n return results\n }\n\n return {\n registerInTypeIndex,\n getRegistrations,\n loadTypeIndexesFor,\n loadCommunityTypeIndexes,\n loadAllTypeIndexes,\n getScopedAppInstances,\n getAppInstances,\n suggestPublicTypeIndex,\n suggestPrivateTypeIndex,\n deleteTypeIndexRegistration,\n getScopedAppsFromIndex\n }\n}\n"],"mappings":"0KAOA,SAAgB,EAAqB,EAAO,EAAO,EAAc,EAA8B,CAC3F,IAAM,EAAK,EAAA,GAEX,SAAS,EAAkB,EAAyC,CAChE,MAAO,CAAC,CAAC,IAAQ,EAAI,WAAW,UAAU,GAAK,EAAI,WAAW,SAAS,EAC3E,CAEA,SAAS,EAAiB,EAAU,EAAU,CAC1C,OAAO,EACF,KAAK,IAAA,GAAW,EAAG,MAAM,UAAU,EAAG,CAAQ,CAAC,CAC/C,OAAQ,GACE,EAAM,MAAM,EAAG,EAAG,MAAM,UAAU,EAAG,CAAQ,CACvD,CACT,CAEA,eAAe,EAAmB,EAAiD,CAC/E,GAAI,CAAC,EAAM,MAAU,MAAM,mCAAmC,EAC9D,IAAM,EAAU,MAAM,EAAa,YAAY,CAAI,EAE/C,EAA+B,KACnC,GAAI,CACA,EAAa,EAAuB,CAAI,CAC5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