solid-logic 6.0.1-5 → 6.0.1-6

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 (102) hide show
  1. package/dist/acl/accessControlSubjects.cjs.js +1 -1
  2. package/dist/acl/accessControlSubjects.cjs.js.map +1 -1
  3. package/dist/acl/accessControlSubjects.esm.js +16 -17
  4. package/dist/acl/aclLogic.cjs.js.map +1 -1
  5. package/dist/acl/aclLogic.esm.js +1 -2
  6. package/dist/authSession/authSession.cjs.js.map +1 -1
  7. package/dist/authSession/authSession.esm.js +1 -2
  8. package/dist/authSession/events.cjs.js.map +1 -1
  9. package/dist/authSession/events.esm.js +1 -2
  10. package/dist/authSession/flagAuthorizationOnTransitions.cjs.js.map +1 -1
  11. package/dist/authSession/flagAuthorizationOnTransitions.esm.js +1 -2
  12. package/dist/authSession/identityState.cjs.js.map +1 -1
  13. package/dist/authSession/identityState.esm.js +1 -2
  14. package/dist/authSession/issuer.cjs.js.map +1 -1
  15. package/dist/authSession/issuer.esm.js +1 -2
  16. package/dist/authSession/session.cjs.js +1 -1
  17. package/dist/authSession/session.cjs.js.map +1 -1
  18. package/dist/authSession/session.esm.js +2 -3
  19. package/dist/authSession/session.esm.js.map +1 -1
  20. package/dist/authn/SolidAuthnLogic.cjs.js +1 -1
  21. package/dist/authn/SolidAuthnLogic.cjs.js.map +1 -1
  22. package/dist/authn/SolidAuthnLogic.esm.js +41 -42
  23. package/dist/authn/authUtil.cjs.js.map +1 -1
  24. package/dist/authn/authUtil.esm.js +1 -2
  25. package/dist/authn/serverLogout.cjs.js.map +1 -1
  26. package/dist/authn/serverLogout.esm.js +1 -2
  27. package/dist/chat/chatLogic.cjs.js.map +1 -1
  28. package/dist/chat/chatLogic.esm.js +1 -2
  29. package/dist/directory/catalogDirectory.cjs.js +1 -1
  30. package/dist/directory/catalogDirectory.cjs.js.map +1 -1
  31. package/dist/directory/catalogDirectory.esm.js +15 -16
  32. package/dist/directory/contactsDirectory.cjs.js.map +1 -1
  33. package/dist/directory/contactsDirectory.esm.js +1 -2
  34. package/dist/directory/directoryHelpers.cjs.js.map +1 -1
  35. package/dist/directory/directoryHelpers.esm.js +1 -2
  36. package/dist/directory/directoryLogic.cjs.js +1 -1
  37. package/dist/directory/directoryLogic.cjs.js.map +1 -1
  38. package/dist/directory/directoryLogic.esm.js +14 -15
  39. package/dist/directory/friendsDirectory.cjs.js.map +1 -1
  40. package/dist/directory/friendsDirectory.esm.js +1 -2
  41. package/dist/inbox/inboxLogic.cjs.js.map +1 -1
  42. package/dist/inbox/inboxLogic.esm.js +1 -2
  43. package/dist/index.cjs.js +1 -1
  44. package/dist/index.cjs.js.map +1 -1
  45. package/dist/index.d.ts +2 -1
  46. package/dist/index.d.ts.map +1 -1
  47. package/dist/index.esm.js +11 -11
  48. package/dist/index.esm.js.map +1 -1
  49. package/dist/issuer/issuerLogic.cjs.js.map +1 -1
  50. package/dist/issuer/issuerLogic.esm.js +1 -2
  51. package/dist/logic/CustomError.cjs.js.map +1 -1
  52. package/dist/logic/CustomError.esm.js +1 -2
  53. package/dist/logic/solidLogic.cjs.js +1 -1
  54. package/dist/logic/solidLogic.cjs.js.map +1 -1
  55. package/dist/logic/solidLogic.esm.js +17 -18
  56. package/dist/logic/solidLogicSingleton.cjs.js +1 -1
  57. package/dist/logic/solidLogicSingleton.cjs.js.map +1 -1
  58. package/dist/logic/solidLogicSingleton.esm.js +6 -7
  59. package/dist/profile/profileAclDocuments.cjs.js.map +1 -1
  60. package/dist/profile/profileAclDocuments.esm.js +1 -2
  61. package/dist/profile/profileDocuments.cjs.js +6 -2
  62. package/dist/profile/profileDocuments.cjs.js.map +1 -1
  63. package/dist/profile/profileDocuments.esm.js +2 -10
  64. package/dist/profile/profileDocuments.esm.js.map +1 -1
  65. package/dist/profile/profileLogic.cjs.js +1 -1
  66. package/dist/profile/profileLogic.cjs.js.map +1 -1
  67. package/dist/profile/profileLogic.esm.js +47 -48
  68. package/dist/resource/resourceHttp.cjs.js.map +1 -1
  69. package/dist/resource/resourceHttp.esm.js +1 -2
  70. package/dist/resource/resourceLogic.cjs.js +1 -1
  71. package/dist/resource/resourceLogic.cjs.js.map +1 -1
  72. package/dist/resource/resourceLogic.d.ts.map +1 -1
  73. package/dist/resource/resourceLogic.esm.js +177 -93
  74. package/dist/resource/resourceLogic.esm.js.map +1 -1
  75. package/dist/resource/resourceMetadata.cjs.js.map +1 -1
  76. package/dist/resource/resourceMetadata.esm.js +1 -2
  77. package/dist/typeIndex/typeIndexAclDocuments.cjs.js.map +1 -1
  78. package/dist/typeIndex/typeIndexAclDocuments.esm.js +1 -2
  79. package/dist/typeIndex/typeIndexDocuments.cjs.js +7 -3
  80. package/dist/typeIndex/typeIndexDocuments.cjs.js.map +1 -1
  81. package/dist/typeIndex/typeIndexDocuments.esm.js +3 -14
  82. package/dist/typeIndex/typeIndexDocuments.esm.js.map +1 -1
  83. package/dist/typeIndex/typeIndexLogic.cjs.js.map +1 -1
  84. package/dist/typeIndex/typeIndexLogic.esm.js +1 -2
  85. package/dist/types.cjs.js +2 -0
  86. package/dist/types.cjs.js.map +1 -0
  87. package/dist/types.d.ts +15 -0
  88. package/dist/types.d.ts.map +1 -1
  89. package/dist/types.esm.js +9 -0
  90. package/dist/types.esm.js.map +1 -0
  91. package/dist/util/containerLogic.cjs.js.map +1 -1
  92. package/dist/util/containerLogic.esm.js +1 -2
  93. package/dist/util/debug.cjs.js.map +1 -1
  94. package/dist/util/debug.esm.js +1 -2
  95. package/dist/util/ns.cjs.js.map +1 -1
  96. package/dist/util/ns.esm.js +1 -2
  97. package/dist/util/utilityLogic.cjs.js +1 -1
  98. package/dist/util/utilityLogic.cjs.js.map +1 -1
  99. package/dist/util/utilityLogic.esm.js +42 -43
  100. package/dist/util/utils.cjs.js.map +1 -1
  101. package/dist/util/utils.esm.js +1 -2
  102. package/package.json +5 -5
@@ -1,8 +1,8 @@
1
- import { log as e } from "../util/debug.esm.js";
2
- import { effectiveIdentity as t, restoreSession as n, sessionOwnsIdentity as r, sessionWasCleared as i, subscribeIdentity as a } from "../authSession/identityState.esm.js";
3
- import { appContext as o, offlineTestID as s } from "./authUtil.esm.js";
1
+ import { appContext as e, offlineTestID as t } from "./authUtil.esm.js";
2
+ import { log as n } from "../util/debug.esm.js";
3
+ import { effectiveIdentity as r, restoreSession as i, sessionOwnsIdentity as a, sessionWasCleared as o, subscribeIdentity as s } from "../authSession/identityState.esm.js";
4
4
  import { namedNode as c, sym as l } from "rdflib";
5
- //#region src/authn/SolidAuthnLogic.ts
5
+ // src/authn/SolidAuthnLogic.ts
6
6
  var u = 5e3;
7
7
  async function d(e) {
8
8
  if (e === null) return;
@@ -17,29 +17,29 @@ async function d(e) {
17
17
  }
18
18
  var f = class {
19
19
  constructor(e) {
20
- this.checkUserInFlight = null, this.sessionRestoreHookAttached = !1, this.session = e, this.identity = a(e, { onRefocus: () => this.refreshCookieBackedFallback() });
20
+ this.checkUserInFlight = null, this.sessionRestoreHookAttached = !1, this.session = e, this.identity = s(e, { onRefocus: () => this.refreshCookieBackedFallback() });
21
21
  }
22
22
  dispose() {
23
23
  this.identity.unsubscribe();
24
24
  }
25
25
  async refreshCookieBackedFallback() {
26
- r(this.session) || this.identity.reportCookieIdentity(await this.probeNssCookieBackedWebId());
26
+ a(this.session) || this.identity.reportCookieIdentity(await this.probeNssCookieBackedWebId());
27
27
  }
28
28
  get authSession() {
29
29
  return this.session;
30
30
  }
31
31
  currentUser() {
32
- let e = o();
33
- if (e.viewingNoAuthPage) return l(e.webId);
34
- let { webId: n } = t(this.session);
35
- return n ? l(n) : s();
32
+ let n = e();
33
+ if (n.viewingNoAuthPage) return l(n.webId);
34
+ let { webId: i } = r(this.session);
35
+ return i ? l(i) : t();
36
36
  }
37
- async checkUser(t) {
38
- let n = new URL(window.location.href).hash;
39
- n && window.localStorage.setItem("preLoginRedirectHash", n);
37
+ async checkUser(e) {
38
+ let t = new URL(window.location.href).hash;
39
+ t && window.localStorage.setItem("preLoginRedirectHash", t);
40
40
  let r = this.session;
41
- !this.sessionRestoreHookAttached && typeof r?.events?.on == "function" && (r.events.on("sessionRestore", (t) => {
42
- e(`Session restored to ${t}`), document.location.toString() !== t && history.replaceState(null, "", t);
41
+ !this.sessionRestoreHookAttached && typeof r?.events?.on == "function" && (r.events.on("sessionRestore", (e) => {
42
+ n(`Session restored to ${e}`), document.location.toString() !== e && history.replaceState(null, "", e);
43
43
  }), this.sessionRestoreHookAttached = !0), this.checkUserInFlight ||= this.resolveCurrentUser();
44
44
  let i = this.checkUserInFlight, a;
45
45
  try {
@@ -47,43 +47,43 @@ var f = class {
47
47
  } finally {
48
48
  this.checkUserInFlight === i && (this.checkUserInFlight = null);
49
49
  }
50
- return Promise.resolve(t ? t(a) : a);
50
+ return Promise.resolve(e ? e(a) : a);
51
51
  }
52
52
  async resolveCurrentUser() {
53
- let r = this.session, i = new URL(window.location.href);
54
- if (i.hash = "", typeof r?.handleIncomingRedirect == "function") await r.handleIncomingRedirect({
53
+ let e = this.session, a = new URL(window.location.href);
54
+ if (a.hash = "", typeof e?.handleIncomingRedirect == "function") await e.handleIncomingRedirect({
55
55
  restorePreviousSession: !0,
56
- url: i.href
56
+ url: a.href
57
57
  });
58
58
  else {
59
- let t = r?.isActive ?? !!r?.webId, i = n(r);
60
- if (i) {
59
+ let t = e?.isActive ?? !!e?.webId, r = i(e);
60
+ if (r) {
61
61
  try {
62
- await d(i);
62
+ await d(r);
63
63
  } catch (t) {
64
- let n = t instanceof Error ? t.message : String(t);
65
- if ((r?.isActive ?? !!r?.webId) && !/no session to restore/i.test(n)) throw t;
66
- e(`Session restore failed, continuing logged-out: ${n}`);
64
+ let r = t instanceof Error ? t.message : String(t);
65
+ if ((e?.isActive ?? !!e?.webId) && !/no session to restore/i.test(r)) throw t;
66
+ n(`Session restore failed, continuing logged-out: ${r}`);
67
67
  }
68
- let n = r?.isActive ?? !!r?.webId;
69
- !t && n && r.events?.emit("sessionRestore", window.location.href);
68
+ let i = e?.isActive ?? !!e?.webId;
69
+ !t && i && e.events?.emit("sessionRestore", window.location.href);
70
70
  }
71
- if (typeof r?.handleRedirectFromLogin == "function") {
72
- let e = r?.isActive ?? !!r?.webId;
73
- await r.handleRedirectFromLogin();
74
- let t = r?.isActive ?? !!r?.webId;
75
- !e && t && r.events?.emit("login");
71
+ if (typeof e?.handleRedirectFromLogin == "function") {
72
+ let t = e?.isActive ?? !!e?.webId;
73
+ await e.handleRedirectFromLogin();
74
+ let n = e?.isActive ?? !!e?.webId;
75
+ !t && n && e.events?.emit("login");
76
76
  }
77
77
  }
78
- let a = window.localStorage.getItem("preLoginRedirectHash");
79
- if (a) {
78
+ let o = window.localStorage.getItem("preLoginRedirectHash");
79
+ if (o) {
80
80
  let e = new URL(window.location.href);
81
- e.hash !== a && (history.pushState ? history.pushState(null, document.title, a) : location.hash = a, e.hash = a), window.localStorage.setItem("preLoginRedirectHash", "");
81
+ e.hash !== o && (history.pushState ? history.pushState(null, document.title, o) : location.hash = o, e.hash = o), window.localStorage.setItem("preLoginRedirectHash", "");
82
82
  }
83
- let o = s();
84
- if (o) return o;
85
- let c = this.webIdFromSession(r?.info, r);
86
- return c ||= (this.identity.reportCookieIdentity(await this.probeNssCookieBackedWebId()), t(r).webId ?? null), c && (o = this.saveUser(c)), o && e(`(Logged in as ${o} by authentication)`), o;
83
+ let s = t();
84
+ if (s) return s;
85
+ let c = this.webIdFromSession(e?.info, e);
86
+ return c ||= (this.identity.reportCookieIdentity(await this.probeNssCookieBackedWebId()), r(e).webId ?? null), c && (s = this.saveUser(c)), s && n(`(Logged in as ${s} by authentication)`), s;
87
87
  }
88
88
  async probeNssCookieBackedWebId() {
89
89
  if (typeof window > "u") return null;
@@ -113,11 +113,10 @@ var f = class {
113
113
  webIdFromSession(e, t) {
114
114
  let n = e?.webId || t?.webId;
115
115
  if (!n) return null;
116
- let r = e?.isLoggedIn, a = t?.isLoggedIn, o = t?.isActive;
117
- return i(t) || r === !1 || a === !1 || o === !1 ? null : n;
116
+ let r = e?.isLoggedIn, i = t?.isLoggedIn, a = t?.isActive;
117
+ return o(t) || r === !1 || i === !1 || a === !1 ? null : n;
118
118
  }
119
119
  };
120
- //#endregion
121
120
  export { f as SolidAuthnLogic };
122
121
 
123
122
  //# sourceMappingURL=SolidAuthnLogic.esm.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"authUtil.cjs.js","names":["sym","require_debug","rdflib","appContext","SolidAppContext","params","viewedPage","ary","offlineTestID","$SolidTestEnvironment","div","id"],"sources":["../../src/authn/authUtil.ts"],"sourcesContent":["import { NamedNode, sym } from 'rdflib'\nimport * as debug from '../util/debug'\n\n/**\n * find a user or app's context as set in window.SolidAppContext\n * this is a const, not a function, because we have problems to jest mock it otherwise\n * see: https://github.com/facebook/jest/issues/936#issuecomment-545080082 for more\n * @return {any} - an appContext object\n */\nexport const appContext = ():any => {\n let { SolidAppContext }: any = window\n SolidAppContext ||= {}\n SolidAppContext.viewingNoAuthPage = false\n if (SolidAppContext.noAuth && window.document) {\n const currentPage = window.document.location.href\n if (currentPage.startsWith(SolidAppContext.noAuth)) {\n SolidAppContext.viewingNoAuthPage = true\n const params = new URLSearchParams(window.document.location.search)\n if (params) {\n let viewedPage = SolidAppContext.viewedPage = params.get('uri') || null\n if (viewedPage) {\n viewedPage = decodeURI(viewedPage)\n if (!viewedPage.startsWith(SolidAppContext.noAuth)) {\n const ary = viewedPage.split(/\\//)\n SolidAppContext.idp = ary[0] + '//' + ary[2]\n SolidAppContext.viewingNoAuthPage = false\n }\n }\n }\n }\n }\n return SolidAppContext\n}\n\n/**\n * Returns `sym($SolidTestEnvironment.username)` if\n * `$SolidTestEnvironment.username` is defined as a global\n * or \n * returns testID defined in the HTML page\n * @returns {NamedNode|null}\n */\nexport function offlineTestID (): NamedNode | null {\n const { $SolidTestEnvironment }: any = window\n if (\n typeof $SolidTestEnvironment !== 'undefined' &&\n $SolidTestEnvironment.username\n ) {\n // Test setup\n debug.log('Assuming the user is ' + $SolidTestEnvironment.username)\n return sym($SolidTestEnvironment.username)\n }\n // hack that makes SolidOS work in offline mode by adding the webId directly in html\n // example usage: https://github.com/solidos/mashlib/blob/29b8b53c46bf02e0e219f0bacd51b0e9951001dd/test/contact/local.html#L37\n if (\n typeof document !== 'undefined' &&\n document.location &&\n ('' + document.location).slice(0, 16) === 'http://localhost'\n ) {\n const div = document.getElementById('appTarget')\n if (!div) return null\n const id = div.getAttribute('testID')\n if (!id) return null\n debug.log('Assuming user is ' + id)\n return sym(id)\n }\n return null\n}\n"],"mappings":"gEASA,IAAaG,MAAuB,CAChC,GAAI,CAAE,mBAAyB,OAG/B,GAFA,IAAoB,CAAC,EACrB,EAAgB,kBAAoB,GAChCC,EAAgB,QAAU,OAAO,UACb,OAAO,SAAS,SAAS,KAC7B,WAAWA,EAAgB,MAAM,EAAG,CACpD,EAAgB,kBAAoB,GACpC,IAAMC,EAAS,IAAI,gBAAgB,OAAO,SAAS,SAAS,MAAM,EAClE,GAAIA,EAAQ,CACR,IAAIC,EAAa,EAAgB,WAAaD,EAAO,IAAI,KAAK,GAAK,KACnE,GAAIC,IACJ,EAAa,UAAUA,CAAU,EAC7B,CAACA,EAAW,WAAWF,EAAgB,MAAM,GAAG,CAChD,IAAMG,EAAMD,EAAW,MAAM,IAAI,EACjC,EAAgB,IAAMC,EAAI,GAAK,KAAOA,EAAI,GAC1C,EAAgB,kBAAoB,EACxC,CAEJ,CACA,CAEJ,OAAOH,CACX,EASA,SAAgBI,GAAmC,CAC/C,GAAM,CAAE,yBAA+B,OACvC,GACSC,IAA0B,QACjCA,EAAsB,SAItB,OADAR,EAAA,IAAU,wBAA0BQ,EAAsB,QAAQ,GAClE,EAAOT,EAAAA,IAAAA,CAAIS,EAAsB,QAAQ,EAI3C,GACE,OAAO,SAAa,KACpB,SAAS,WACR,GAAK,SAAS,SAAA,CAAU,MAAM,EAAG,EAAE,IAAM,mBAC1C,CACA,IAAMC,EAAM,SAAS,eAAe,WAAW,EAC/C,GAAI,CAACA,EAAK,OAAO,KACjB,IAAMC,EAAKD,EAAI,aAAa,QAAQ,EAGpC,OAFKC,GACLV,EAAA,IAAU,oBAAsBU,CAAE,GAClC,EAAOX,EAAAA,IAAAA,CAAIW,CAAE,GAFG,IAGlB,CACA,OAAO,IACX"}
1
+ {"version":3,"file":"authUtil.cjs.js","names":["sym","require_debug","rdflib","appContext","SolidAppContext","params","viewedPage","ary","offlineTestID","$SolidTestEnvironment","div","id"],"sources":["../../src/authn/authUtil.ts"],"sourcesContent":["import { NamedNode, sym } from 'rdflib'\nimport * as debug from '../util/debug'\n\n/**\n * find a user or app's context as set in window.SolidAppContext\n * this is a const, not a function, because we have problems to jest mock it otherwise\n * see: https://github.com/facebook/jest/issues/936#issuecomment-545080082 for more\n * @return {any} - an appContext object\n */\nexport const appContext = ():any => {\n let { SolidAppContext }: any = window\n SolidAppContext ||= {}\n SolidAppContext.viewingNoAuthPage = false\n if (SolidAppContext.noAuth && window.document) {\n const currentPage = window.document.location.href\n if (currentPage.startsWith(SolidAppContext.noAuth)) {\n SolidAppContext.viewingNoAuthPage = true\n const params = new URLSearchParams(window.document.location.search)\n if (params) {\n let viewedPage = SolidAppContext.viewedPage = params.get('uri') || null\n if (viewedPage) {\n viewedPage = decodeURI(viewedPage)\n if (!viewedPage.startsWith(SolidAppContext.noAuth)) {\n const ary = viewedPage.split(/\\//)\n SolidAppContext.idp = ary[0] + '//' + ary[2]\n SolidAppContext.viewingNoAuthPage = false\n }\n }\n }\n }\n }\n return SolidAppContext\n}\n\n/**\n * Returns `sym($SolidTestEnvironment.username)` if\n * `$SolidTestEnvironment.username` is defined as a global\n * or \n * returns testID defined in the HTML page\n * @returns {NamedNode|null}\n */\nexport function offlineTestID (): NamedNode | null {\n const { $SolidTestEnvironment }: any = window\n if (\n typeof $SolidTestEnvironment !== 'undefined' &&\n $SolidTestEnvironment.username\n ) {\n // Test setup\n debug.log('Assuming the user is ' + $SolidTestEnvironment.username)\n return sym($SolidTestEnvironment.username)\n }\n // hack that makes SolidOS work in offline mode by adding the webId directly in html\n // example usage: https://github.com/solidos/mashlib/blob/29b8b53c46bf02e0e219f0bacd51b0e9951001dd/test/contact/local.html#L37\n if (\n typeof document !== 'undefined' &&\n document.location &&\n ('' + document.location).slice(0, 16) === 'http://localhost'\n ) {\n const div = document.getElementById('appTarget')\n if (!div) return null\n const id = div.getAttribute('testID')\n if (!id) return null\n debug.log('Assuming user is ' + id)\n return sym(id)\n }\n return null\n}\n"],"mappings":"A,gEASA,IAAaG,MAAuB,CAChC,GAAI,CAAE,mBAAyB,OAG/B,GAFA,IAAoB,CAAC,EACrB,EAAgB,kBAAoB,GAChCC,EAAgB,QAAU,OAAO,UACb,OAAO,SAAS,SAAS,KAC7B,WAAWA,EAAgB,MAAM,EAAG,CACpD,EAAgB,kBAAoB,GACpC,IAAMC,EAAS,IAAI,gBAAgB,OAAO,SAAS,SAAS,MAAM,EAClE,GAAIA,EAAQ,CACR,IAAIC,EAAa,EAAgB,WAAaD,EAAO,IAAI,KAAK,GAAK,KACnE,GAAIC,IACJ,EAAa,UAAUA,CAAU,EAC7B,CAACA,EAAW,WAAWF,EAAgB,MAAM,GAAG,CAChD,IAAMG,EAAMD,EAAW,MAAM,IAAI,EACjC,EAAgB,IAAMC,EAAI,GAAK,KAAOA,EAAI,GAC1C,EAAgB,kBAAoB,EACxC,CAEJ,CACA,CAEJ,OAAOH,CACX,EASA,SAAgBI,GAAmC,CAC/C,GAAM,CAAE,yBAA+B,OACvC,GACSC,IAA0B,QACjCA,EAAsB,SAItB,OADAR,EAAA,IAAU,wBAA0BQ,EAAsB,QAAQ,GAClE,EAAOT,EAAAA,IAAAA,CAAIS,EAAsB,QAAQ,EAI3C,GACE,OAAO,SAAa,KACpB,SAAS,WACR,GAAK,SAAS,SAAA,CAAU,MAAM,EAAG,EAAE,IAAM,mBAC1C,CACA,IAAMC,EAAM,SAAS,eAAe,WAAW,EAC/C,GAAI,CAACA,EAAK,OAAO,KACjB,IAAMC,EAAKD,EAAI,aAAa,QAAQ,EAGpC,OAFKC,GACLV,EAAA,IAAU,oBAAsBU,CAAE,GAClC,EAAOX,EAAAA,IAAAA,CAAIW,CAAE,GAFG,IAGlB,CACA,OAAO,IACX,C"}
@@ -1,6 +1,6 @@
1
1
  import { log as e } from "../util/debug.esm.js";
2
2
  import { sym as t } from "rdflib";
3
- //#region src/authn/authUtil.ts
3
+ // src/authn/authUtil.ts
4
4
  var n = () => {
5
5
  let { SolidAppContext: e } = window;
6
6
  if (e ||= {}, e.viewingNoAuthPage = !1, e.noAuth && window.document && window.document.location.href.startsWith(e.noAuth)) {
@@ -27,7 +27,6 @@ function r() {
27
27
  }
28
28
  return null;
29
29
  }
30
- //#endregion
31
30
  export { n as appContext, r as offlineTestID };
32
31
 
33
32
  //# sourceMappingURL=authUtil.esm.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"serverLogout.cjs.js","names":["performServerSideLogout","issuer","options","postLogoutRedirectPath","wellKnownUri","wellKnownResult","openidConfiguration","logoutResponse"],"sources":["../../src/authn/serverLogout.ts"],"sourcesContent":["export type ServerLogoutOptions = {\n issuer?: string\n postLogoutRedirectPath?: string\n}\n\nexport async function performServerSideLogout (options: ServerLogoutOptions = {}): Promise<boolean> {\n if (typeof window === 'undefined') {\n return false\n }\n const issuer = options.issuer || ''\n const postLogoutRedirectPath = options.postLogoutRedirectPath || '/'\n\n // Provider-specific logout endpoint discovery (OIDC end_session_endpoint).\n try {\n if (issuer) {\n const wellKnownUri = new URL(issuer)\n wellKnownUri.pathname = '/.well-known/openid-configuration'\n const wellKnownResult = await fetch(wellKnownUri.toString(), { credentials: 'include' })\n\n if (wellKnownResult.status === 200) {\n const openidConfiguration = await wellKnownResult.json()\n if (openidConfiguration && openidConfiguration.end_session_endpoint) {\n await fetch(openidConfiguration.end_session_endpoint, { credentials: 'include' })\n }\n }\n }\n } catch (_err) {\n // Continue with local logout even if provider logout is unavailable.\n }\n\n // NSS well-known logout endpoint clears cookie-backed server sessions.\n try {\n const logoutResponse = await fetch('/.well-known/solid/logout', { credentials: 'include' })\n if (logoutResponse.ok || logoutResponse.redirected) {\n window.location.assign(postLogoutRedirectPath)\n return true\n }\n } catch (_err) {\n // Not all deployments expose this endpoint.\n }\n\n return false\n}"],"mappings":"AAKA,eAAsBA,EAAyB,EAA+B,CAAC,EAAqB,CAClG,GAAI,OAAO,OAAW,IACpB,MAAO,GAET,IAAMC,EAASC,EAAQ,QAAU,GAC3BC,EAAyBD,EAAQ,wBAA0B,IAGjE,GAAI,CACF,GAAID,EAAQ,CACV,IAAMG,EAAe,IAAI,IAAIH,CAAM,EACnC,EAAa,SAAW,oCACxB,IAAMI,EAAkB,MAAM,MAAMD,EAAa,SAAS,EAAG,CAAE,YAAa,SAAU,CAAC,EAEvF,GAAIC,EAAgB,SAAW,IAAK,CAClC,IAAMC,EAAsB,MAAMD,EAAgB,KAAK,EACnDC,GAAuBA,EAAoB,sBAC7C,MAAM,MAAMA,EAAoB,qBAAsB,CAAE,YAAa,SAAU,CAAC,CAEpF,CACF,CACF,MAAe,CAEf,CAGA,GAAI,CACF,IAAMC,EAAiB,MAAM,MAAM,4BAA6B,CAAE,YAAa,SAAU,CAAC,EAC1F,GAAIA,EAAe,IAAMA,EAAe,WAEtC,OADA,OAAO,SAAS,OAAOJ,CAAsB,EACtC,EAEX,MAAe,CAEf,CAEA,MAAO,EACT"}
1
+ {"version":3,"file":"serverLogout.cjs.js","names":["performServerSideLogout","issuer","options","postLogoutRedirectPath","wellKnownUri","wellKnownResult","openidConfiguration","logoutResponse"],"sources":["../../src/authn/serverLogout.ts"],"sourcesContent":["export type ServerLogoutOptions = {\n issuer?: string\n postLogoutRedirectPath?: string\n}\n\nexport async function performServerSideLogout (options: ServerLogoutOptions = {}): Promise<boolean> {\n if (typeof window === 'undefined') {\n return false\n }\n const issuer = options.issuer || ''\n const postLogoutRedirectPath = options.postLogoutRedirectPath || '/'\n\n // Provider-specific logout endpoint discovery (OIDC end_session_endpoint).\n try {\n if (issuer) {\n const wellKnownUri = new URL(issuer)\n wellKnownUri.pathname = '/.well-known/openid-configuration'\n const wellKnownResult = await fetch(wellKnownUri.toString(), { credentials: 'include' })\n\n if (wellKnownResult.status === 200) {\n const openidConfiguration = await wellKnownResult.json()\n if (openidConfiguration && openidConfiguration.end_session_endpoint) {\n await fetch(openidConfiguration.end_session_endpoint, { credentials: 'include' })\n }\n }\n }\n } catch (_err) {\n // Continue with local logout even if provider logout is unavailable.\n }\n\n // NSS well-known logout endpoint clears cookie-backed server sessions.\n try {\n const logoutResponse = await fetch('/.well-known/solid/logout', { credentials: 'include' })\n if (logoutResponse.ok || logoutResponse.redirected) {\n window.location.assign(postLogoutRedirectPath)\n return true\n }\n } catch (_err) {\n // Not all deployments expose this endpoint.\n }\n\n return false\n}"],"mappings":"AAKA,eAAsBA,EAAyB,EAA+B,CAAC,EAAqB,CAClG,GAAI,OAAO,OAAW,IACpB,MAAO,GAET,IAAMC,EAASC,EAAQ,QAAU,GAC3BC,EAAyBD,EAAQ,wBAA0B,IAGjE,GAAI,CACF,GAAID,EAAQ,CACV,IAAMG,EAAe,IAAI,IAAIH,CAAM,EACnC,EAAa,SAAW,oCACxB,IAAMI,EAAkB,MAAM,MAAMD,EAAa,SAAS,EAAG,CAAE,YAAa,SAAU,CAAC,EAEvF,GAAIC,EAAgB,SAAW,IAAK,CAClC,IAAMC,EAAsB,MAAMD,EAAgB,KAAK,EACnDC,GAAuBA,EAAoB,sBAC7C,MAAM,MAAMA,EAAoB,qBAAsB,CAAE,YAAa,SAAU,CAAC,CAEpF,CACF,CACF,MAAe,CAEf,CAGA,GAAI,CACF,IAAMC,EAAiB,MAAM,MAAM,4BAA6B,CAAE,YAAa,SAAU,CAAC,EAC1F,GAAIA,EAAe,IAAMA,EAAe,WAEtC,OADA,OAAO,SAAS,OAAOJ,CAAsB,EACtC,EAEX,MAAe,CAEf,CAEA,MAAO,EACT,C"}
@@ -1,4 +1,4 @@
1
- //#region src/authn/serverLogout.ts
1
+ // src/authn/serverLogout.ts
2
2
  async function e(e = {}) {
3
3
  if (typeof window > "u") return !1;
4
4
  let t = e.issuer || "", n = e.postLogoutRedirectPath || "/";
@@ -19,7 +19,6 @@ async function e(e = {}) {
19
19
  } catch {}
20
20
  return !1;
21
21
  }
22
- //#endregion
23
22
  export { e as performServerSideLogout };
24
23
 
25
24
  //# sourceMappingURL=serverLogout.esm.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"chatLogic.cjs.js","names":["ns","namespace","NamedNode","newThing","st","determineChatContainer","term","require_ns","require_utils","rdflib","CHAT_LOCATION_IN_CONTAINER","createChatLogic","ns$1","setAcl","store","chatContainer","chatAclDoc","aclBody","me","invitee","addToPrivateTypeIndex","privateTypeIndex","reg","ins","chatThing","ok","resolve","reject","errm","findChat","profileLogic","podRoot","exists","createChatThing","mintNew","kb","updater","newPaneOptions","newInstance","newChatDoc","uri2","message","getChat","createIfMissing","sendInvite","inviteeInbox","inviteBody","inviteResponse"],"sources":["../../src/chat/chatLogic.ts"],"sourcesContent":["import { NamedNode, Node, st, term } from 'rdflib'\nimport { ChatLogic, CreatedPaneOptions, NewPaneOptions, Chat } from '../types'\nimport { ns as namespace } from '../util/ns'\nimport { determineChatContainer, newThing } from '../util/utils'\n\nconst CHAT_LOCATION_IN_CONTAINER = 'index.ttl#this'\n\nexport function createChatLogic(store, profileLogic): ChatLogic {\n const ns = namespace\n\n async function setAcl(\n chatContainer: NamedNode,\n me: NamedNode,\n invitee: NamedNode\n ): Promise<void> {\n // Some servers don't present a Link http response header\n // if the container doesn't exist yet, so refetch the container\n // now that it has been created:\n await store.fetcher.load(chatContainer)\n\n // FIXME: check the Why value on this quad:\n const chatAclDoc = store.any(\n chatContainer,\n new NamedNode('http://www.iana.org/assignments/link-relations/acl')\n )\n if (!chatAclDoc) {\n throw new Error('Chat ACL doc not found!')\n }\n\n const aclBody = `\n @prefix acl: <http://www.w3.org/ns/auth/acl#>.\n <#owner>\n a acl:Authorization;\n acl:agent <${me.value}>;\n acl:accessTo <.>;\n acl:default <.>;\n acl:mode\n acl:Read, acl:Write, acl:Control.\n <#invitee>\n a acl:Authorization;\n acl:agent <${invitee.value}>;\n acl:accessTo <.>;\n acl:default <.>;\n acl:mode\n acl:Read, acl:Append.\n `\n await store.fetcher.webOperation('PUT', chatAclDoc.value, {\n data: aclBody,\n contentType: 'text/turtle',\n })\n }\n\n async function addToPrivateTypeIndex(chatThing, me) {\n // Add to private type index\n const privateTypeIndex = store.any(\n me,\n ns.solid('privateTypeIndex')\n ) as NamedNode | null\n if (!privateTypeIndex) {\n throw new Error('Private type index not found!')\n }\n await store.fetcher.load(privateTypeIndex)\n const reg = newThing(privateTypeIndex)\n const ins = [\n st(\n reg,\n ns.rdf('type'),\n ns.solid('TypeRegistration'),\n privateTypeIndex.doc()\n ),\n st(\n reg,\n ns.solid('forClass'),\n ns.meeting('LongChat'),\n privateTypeIndex.doc()\n ),\n st(reg, ns.solid('instance'), chatThing, privateTypeIndex.doc()),\n ]\n await new Promise((resolve, reject) => {\n store.updater.update([], ins, function (_uri, ok, errm) {\n if (!ok) {\n reject(new Error(errm))\n } else {\n resolve(null)\n }\n })\n })\n }\n\n async function findChat(invitee: NamedNode): Promise<Chat> {\n const me = await profileLogic.loadMe()\n const podRoot = await profileLogic.getPodRoot(me)\n const chatContainer = determineChatContainer(invitee, podRoot)\n let exists = true\n try {\n await store.fetcher.load(\n new NamedNode(chatContainer.value + 'index.ttl#this')\n )\n } catch (e) {\n exists = false\n }\n return { me, chatContainer, exists }\n }\n\n async function createChatThing(\n chatContainer: NamedNode,\n me: NamedNode\n ): Promise<NamedNode> {\n const created = await mintNew({\n me,\n newBase: chatContainer.value,\n })\n return created.newInstance\n }\n\n function mintNew(newPaneOptions: NewPaneOptions): Promise<CreatedPaneOptions> {\n const kb = store\n const updater = kb.updater\n if (newPaneOptions.me && !newPaneOptions.me.uri) {\n throw new Error('chat mintNew: Invalid userid ' + newPaneOptions.me)\n }\n\n const newInstance = (newPaneOptions.newInstance =\n newPaneOptions.newInstance ||\n kb.sym(newPaneOptions.newBase + CHAT_LOCATION_IN_CONTAINER))\n const newChatDoc = newInstance.doc()\n\n kb.add(\n newInstance,\n ns.rdf('type'),\n ns.meeting('LongChat'),\n newChatDoc\n )\n kb.add(newInstance, ns.dc('title'), 'Chat channel', newChatDoc)\n kb.add(\n newInstance,\n ns.dc('created'),\n term<Node>(new Date(Date.now())),\n newChatDoc\n )\n if (newPaneOptions.me) {\n kb.add(newInstance, ns.dc('author'), newPaneOptions.me, newChatDoc)\n }\n\n return new Promise(function (resolve, reject) {\n updater?.put(\n newChatDoc,\n kb.statementsMatching(undefined, undefined, undefined, newChatDoc),\n 'text/turtle',\n function (uri2, ok, message) {\n if (ok) {\n resolve({\n ...newPaneOptions,\n newInstance,\n })\n } else {\n reject(\n new Error(\n 'FAILED to save new chat channel at: ' + uri2 + ' : ' + message\n )\n )\n }\n }\n )\n })\n }\n\n /**\n * Find (and optionally create) an individual chat between the current user and the given invitee\n * @param invitee - The person to chat with\n * @param createIfMissing - Whether the chat should be created, if missing\n * @returns null if missing, or a node referring to an already existing chat, or the newly created chat\n */\n async function getChat(\n invitee: NamedNode,\n createIfMissing = true\n ): Promise<NamedNode | null> {\n const { me, chatContainer, exists } = await findChat(invitee)\n if (exists) {\n return new NamedNode(chatContainer.value + CHAT_LOCATION_IN_CONTAINER)\n }\n\n if (createIfMissing) {\n const chatThing = await createChatThing(chatContainer, me)\n await sendInvite(invitee, chatThing)\n await setAcl(chatContainer, me, invitee)\n await addToPrivateTypeIndex(chatThing, me)\n return chatThing\n }\n return null\n }\n\n async function sendInvite(invitee: NamedNode, chatThing: NamedNode) {\n await store.fetcher.load(invitee.doc())\n const inviteeInbox = store.any(\n invitee,\n ns.ldp('inbox'),\n undefined,\n invitee.doc()\n )\n if (!inviteeInbox) {\n throw new Error(`Invitee inbox not found! ${invitee.value}`)\n }\n const inviteBody = `\n <> a <http://www.w3.org/ns/pim/meeting#LongChatInvite> ;\n ${ns.rdf('seeAlso')} <${chatThing.value}> .\n `\n\n const inviteResponse = await store.fetcher?.webOperation(\n 'POST',\n inviteeInbox.value,\n {\n data: inviteBody,\n contentType: 'text/turtle',\n }\n )\n const locationStr = inviteResponse?.headers.get('location')\n if (!locationStr) {\n throw new Error(`Invite sending returned a ${inviteResponse?.status}`)\n }\n }\n return {\n setAcl, addToPrivateTypeIndex, findChat, createChatThing, getChat, sendInvite, mintNew\n }\n}\n"],"mappings":"+FAKA,IAAMU,EAA6B,iBAEnC,SAAgBC,EAAgB,EAAO,EAAyB,CAC5D,IAAMX,EAAKC,EAAAA,GAEX,eAAeY,EACX,EACA,EACA,EACa,CAIb,MAAMC,EAAM,QAAQ,KAAKC,CAAa,EAGtC,IAAMC,EAAaF,EAAM,IACrBC,EACA,IAAIb,EAAAA,UAAU,oDAAoD,CACtE,EACA,GAAI,CAACc,EACD,MAAU,MAAM,yBAAyB,EAG7C,IAAMC,EAAU;;;;yBAICC,EAAG,MAAM;;;;;;;yBAOTC,EAAQ,MAAM;;;;;cAM/B,MAAML,EAAM,QAAQ,aAAa,MAAOE,EAAW,MAAO,CACtD,KAAMC,EACN,YAAa,aACjB,CAAC,CACL,CAEA,eAAeG,EAAsB,EAAW,EAAI,CAEhD,IAAMC,EAAmBP,EAAM,IAC3BI,EACAlB,EAAG,MAAM,kBAAkB,CAC/B,EACA,GAAI,CAACqB,EACD,MAAU,MAAM,+BAA+B,EAEnD,MAAMP,EAAM,QAAQ,KAAKO,CAAgB,EACzC,IAAMC,EAAMnB,EAAAA,SAASkB,CAAgB,EAC/BE,EAAM,EACRnB,EAAAA,EAAAA,GAAAA,CACIkB,EACAtB,EAAG,IAAI,MAAM,EACbA,EAAG,MAAM,kBAAkB,EAC3BqB,EAAiB,IAAI,CACzB,GACAjB,EAAAA,EAAAA,GAAAA,CACIkB,EACAtB,EAAG,MAAM,UAAU,EACnBA,EAAG,QAAQ,UAAU,EACrBqB,EAAiB,IAAI,CACzB,GACAjB,EAAAA,EAAAA,GAAAA,CAAGkB,E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AQ,IAAI,UAAU,EAEtD,MAAU,MAAM,6BAA6BA,GAAgB,QAAQ,CAE7E,CACA,MAAO,CACH,SAAQ,wBAAuB,WAAU,kBAAiB,UAAS,aAAY,SACnF,CACJ"}
1
+ {"version":3,"file":"chatLogic.cjs.js","names":["ns","namespace","NamedNode","newThing","st","determineChatContainer","term","require_ns","require_utils","rdflib","CHAT_LOCATION_IN_CONTAINER","createChatLogic","ns$1","setAcl","store","chatContainer","chatAclDoc","aclBody","me","invitee","addToPrivateTypeIndex","privateTypeIndex","reg","ins","chatThing","ok","resolve","reject","errm","findChat","profileLogic","podRoot","exists","createChatThing","mintNew","kb","updater","newPaneOptions","newInstance","newChatDoc","uri2","message","getChat","createIfMissing","sendInvite","inviteeInbox","inviteBody","inviteResponse"],"sources":["../../src/chat/chatLogic.ts"],"sourcesContent":["import { NamedNode, Node, st, term } from 'rdflib'\nimport { ChatLogic, CreatedPaneOptions, NewPaneOptions, Chat } from '../types'\nimport { ns as namespace } from '../util/ns'\nimport { determineChatContainer, newThing } from '../util/utils'\n\nconst CHAT_LOCATION_IN_CONTAINER = 'index.ttl#this'\n\nexport function createChatLogic(store, profileLogic): ChatLogic {\n const ns = namespace\n\n async function setAcl(\n chatContainer: NamedNode,\n me: NamedNode,\n invitee: NamedNode\n ): Promise<void> {\n // Some servers don't present a Link http response header\n // if the container doesn't exist yet, so refetch the container\n // now that it has been created:\n await store.fetcher.load(chatContainer)\n\n // FIXME: check the Why value on this quad:\n const chatAclDoc = store.any(\n chatContainer,\n new NamedNode('http://www.iana.org/assignments/link-relations/acl')\n )\n if (!chatAclDoc) {\n throw new Error('Chat ACL doc not found!')\n }\n\n const aclBody = `\n @prefix acl: <http://www.w3.org/ns/auth/acl#>.\n <#owner>\n a acl:Authorization;\n acl:agent <${me.value}>;\n acl:accessTo <.>;\n acl:default <.>;\n acl:mode\n acl:Read, acl:Write, acl:Control.\n <#invitee>\n a acl:Authorization;\n acl:agent <${invitee.value}>;\n acl:accessTo <.>;\n acl:default <.>;\n acl:mode\n acl:Read, acl:Append.\n `\n await store.fetcher.webOperation('PUT', chatAclDoc.value, {\n data: aclBody,\n contentType: 'text/turtle',\n })\n }\n\n async function addToPrivateTypeIndex(chatThing, me) {\n // Add to private type index\n const privateTypeIndex = store.any(\n me,\n ns.solid('privateTypeIndex')\n ) as NamedNode | null\n if (!privateTypeIndex) {\n throw new Error('Private type index not found!')\n }\n await store.fetcher.load(privateTypeIndex)\n const reg = newThing(privateTypeIndex)\n const ins = [\n st(\n reg,\n ns.rdf('type'),\n ns.solid('TypeRegistration'),\n privateTypeIndex.doc()\n ),\n st(\n reg,\n ns.solid('forClass'),\n ns.meeting('LongChat'),\n privateTypeIndex.doc()\n ),\n st(reg, ns.solid('instance'), chatThing, privateTypeIndex.doc()),\n ]\n await new Promise((resolve, reject) => {\n store.updater.update([], ins, function (_uri, ok, errm) {\n if (!ok) {\n reject(new Error(errm))\n } else {\n resolve(null)\n }\n })\n })\n }\n\n async function findChat(invitee: NamedNode): Promise<Chat> {\n const me = await profileLogic.loadMe()\n const podRoot = await profileLogic.getPodRoot(me)\n const chatContainer = determineChatContainer(invitee, podRoot)\n let exists = true\n try {\n await store.fetcher.load(\n new NamedNode(chatContainer.value + 'index.ttl#this')\n )\n } catch (e) {\n exists = false\n }\n return { me, chatContainer, exists }\n }\n\n async function createChatThing(\n chatContainer: NamedNode,\n me: NamedNode\n ): Promise<NamedNode> {\n const created = await mintNew({\n me,\n newBase: chatContainer.value,\n })\n return created.newInstance\n }\n\n function mintNew(newPaneOptions: NewPaneOptions): Promise<CreatedPaneOptions> {\n const kb = store\n const updater = kb.updater\n if (newPaneOptions.me && !newPaneOptions.me.uri) {\n throw new Error('chat mintNew: Invalid userid ' + newPaneOptions.me)\n }\n\n const newInstance = (newPaneOptions.newInstance =\n newPaneOptions.newInstance ||\n kb.sym(newPaneOptions.newBase + CHAT_LOCATION_IN_CONTAINER))\n const newChatDoc = newInstance.doc()\n\n kb.add(\n newInstance,\n ns.rdf('type'),\n ns.meeting('LongChat'),\n newChatDoc\n )\n kb.add(newInstance, ns.dc('title'), 'Chat channel', newChatDoc)\n kb.add(\n newInstance,\n ns.dc('created'),\n term<Node>(new Date(Date.now())),\n newChatDoc\n )\n if (newPaneOptions.me) {\n kb.add(newInstance, ns.dc('author'), newPaneOptions.me, newChatDoc)\n }\n\n return new Promise(function (resolve, reject) {\n updater?.put(\n newChatDoc,\n kb.statementsMatching(undefined, undefined, undefined, newChatDoc),\n 'text/turtle',\n function (uri2, ok, message) {\n if (ok) {\n resolve({\n ...newPaneOptions,\n newInstance,\n })\n } else {\n reject(\n new Error(\n 'FAILED to save new chat channel at: ' + uri2 + ' : ' + message\n )\n )\n }\n }\n )\n })\n }\n\n /**\n * Find (and optionally create) an individual chat between the current user and the given invitee\n * @param invitee - The person to chat with\n * @param createIfMissing - Whether the chat should be created, if missing\n * @returns null if missing, or a node referring to an already existing chat, or the newly created chat\n */\n async function getChat(\n invitee: NamedNode,\n createIfMissing = true\n ): Promise<NamedNode | null> {\n const { me, chatContainer, exists } = await findChat(invitee)\n if (exists) {\n return new NamedNode(chatContainer.value + CHAT_LOCATION_IN_CONTAINER)\n }\n\n if (createIfMissing) {\n const chatThing = await createChatThing(chatContainer, me)\n await sendInvite(invitee, chatThing)\n await setAcl(chatContainer, me, invitee)\n await addToPrivateTypeIndex(chatThing, me)\n return chatThing\n }\n return null\n }\n\n async function sendInvite(invitee: NamedNode, chatThing: NamedNode) {\n await store.fetcher.load(invitee.doc())\n const inviteeInbox = store.any(\n invitee,\n ns.ldp('inbox'),\n undefined,\n invitee.doc()\n )\n if (!inviteeInbox) {\n throw new Error(`Invitee inbox not found! ${invitee.value}`)\n }\n const inviteBody = `\n <> a <http://www.w3.org/ns/pim/meeting#LongChatInvite> ;\n ${ns.rdf('seeAlso')} <${chatThing.value}> .\n `\n\n const inviteResponse = await store.fetcher?.webOperation(\n 'POST',\n inviteeInbox.value,\n {\n data: inviteBody,\n contentType: 'text/turtle',\n }\n )\n const locationStr = inviteResponse?.headers.get('location')\n if (!locationStr) {\n throw new Error(`Invite sending returned a ${inviteResponse?.status}`)\n }\n }\n return {\n setAcl, addToPrivateTypeIndex, findChat, createChatThing, getChat, sendInvite, mintNew\n }\n}\n"],"mappings":"A,+FAKA,IAAMU,EAA6B,iBAEnC,SAAgBC,EAAgB,EAAO,EAAyB,CAC5D,IAAMX,EAAKC,EAAAA,GAEX,eAAeY,EACX,EACA,EACA,EACa,CAIb,MAAMC,EAAM,QAAQ,KAAKC,CAAa,EAGtC,IAAMC,EAAaF,EAAM,IACrBC,EACA,IAAIb,EAAAA,UAAU,oDAAoD,CACtE,EACA,GAAI,CAACc,EACD,MAAU,MAAM,yBAAyB,EAG7C,IAAMC,EAAU;;;;yBAICC,EAAG,MAAM;;;;;;;yBAOTC,EAAQ,MAAM;;;;;cAM/B,MAAML,EAAM,QAAQ,aAAa,MAAOE,EAAW,MAAO,CACtD,KAAMC,EACN,YAAa,aACjB,CAAC,CACL,CAEA,eAAeG,EAAsB,EAAW,EAAI,CAEhD,IAAMC,EAAmBP,EAAM,IAC3BI,EACAlB,EAAG,MAAM,kBAAkB,CAC/B,EACA,GAAI,CAACqB,EACD,MAAU,MAAM,+BAA+B,EAEnD,MAAMP,EAAM,QAAQ,KAAKO,CAAgB,EACzC,IAAMC,EAAMnB,EAAAA,SAASkB,CAAgB,EAC/BE,EAAM,EACRnB,EAAAA,EAAAA,GAAAA,CACIkB,EACAtB,EAAG,IAAI,MAAM,EACbA,EAAG,MAAM,kBAAkB,EAC3BqB,EAAiB,IAAI,CACzB,GACAjB,EAAAA,EAAAA,GAAAA,CACIkB,EACAtB,EAAG,MAAM,UAAU,EACnBA,EAAG,QAAQ,UAAU,EACrBqB,EAAiB,IAAI,CACzB,GACAjB,EAAAA,EAAAA,GAAAA,CAAGkB,EAAKtB,EAAG,MAAM,UAAU,EAAGwB,EAAWH,EAAiB,IAAI,CAAC,CACnE,EACA,MAAM,IAAI,SAAS,EAAS,IAAW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AAU,kBAAiB,UAAS,aAAY,SACnF,CACJ,C"}
@@ -1,7 +1,7 @@
1
1
  import { ns as e } from "../util/ns.esm.js";
2
2
  import { determineChatContainer as t, newThing as n } from "../util/utils.esm.js";
3
3
  import { NamedNode as r, st as i, term as a } from "rdflib";
4
- //#region src/chat/chatLogic.ts
4
+ // src/chat/chatLogic.ts
5
5
  var o = "index.ttl#this";
6
6
  function s(s, c) {
7
7
  let l = e;
@@ -110,7 +110,6 @@ function s(s, c) {
110
110
  mintNew: m
111
111
  };
112
112
  }
113
- //#endregion
114
113
  export { s as createChatLogic };
115
114
 
116
115
  //# sourceMappingURL=chatLogic.esm.js.map
@@ -1,2 +1,2 @@
1
- const e=require("../util/debug.cjs.js"),t=require("../util/ns.cjs.js"),n=require("./directoryHelpers.cjs.js");let r=require("rdflib");var i=`http://example.org#`;function a(){let a=new Map;async function o(e,t){let n=await s(e);for(let e of n)await t(e)}async function s(t){let n=a.get(t);if(n)return n;let r=c(t).catch(e=>{throw a.delete(t),e});a.set(t,r);try{return await r}catch(t){return e.warn(`[Directory] Error fetching directory catalog:`,t),[]}}async function c(e){if(typeof fetch!=`function`)throw Error(`Fetch API is unavailable`);let a=await fetch(e,{headers:{accept:`text/turtle`}});if(!a.ok)throw Error(`Failed to fetch ${e}: ${a.status}`);let o=await a.text(),s=(0,r.graph)();(0,r.parse)(o,s,e,`text/turtle`);let c=new r.NamedNode(`${i}Person`),l=new r.NamedNode(`${i}webid`),u=new r.NamedNode(`${i}name`),d=new Map,f=s.statementsMatching(void 0,t.ns.rdf(`type`),c);for(let e of f){let t=e.subject,r=s.any(t,l);if(r&&r.termType===`NamedNode`){let e=r.value,i=s.anyValue(t,u);n.isHttpUri(e)&&i&&d.set(e,{kind:`person`,uri:e,label:i,subjectType:`agent`,relationshipLabel:`People`,sources:[`catalog`]})}}return Array.from(d.values())}return{discoverCatalogEntries:o}}exports.createCatalogDirectoryDiscovery=a;
1
+ const e=require("../util/ns.cjs.js"),t=require("../util/debug.cjs.js"),n=require("./directoryHelpers.cjs.js");let r=require("rdflib");var i=`http://example.org#`;function a(){let a=new Map;async function o(e,t){let n=await s(e);for(let e of n)await t(e)}async function s(e){let n=a.get(e);if(n)return n;let r=c(e).catch(t=>{throw a.delete(e),t});a.set(e,r);try{return await r}catch(e){return t.warn(`[Directory] Error fetching directory catalog:`,e),[]}}async function c(t){if(typeof fetch!=`function`)throw Error(`Fetch API is unavailable`);let a=await fetch(t,{headers:{accept:`text/turtle`}});if(!a.ok)throw Error(`Failed to fetch ${t}: ${a.status}`);let o=await a.text(),s=(0,r.graph)();(0,r.parse)(o,s,t,`text/turtle`);let c=new r.NamedNode(`${i}Person`),l=new r.NamedNode(`${i}webid`),u=new r.NamedNode(`${i}name`),d=new Map,f=s.statementsMatching(void 0,e.ns.rdf(`type`),c);for(let e of f){let t=e.subject,r=s.any(t,l);if(r&&r.termType===`NamedNode`){let e=r.value,i=s.anyValue(t,u);n.isHttpUri(e)&&i&&d.set(e,{kind:`person`,uri:e,label:i,subjectType:`agent`,relationshipLabel:`People`,sources:[`catalog`]})}}return Array.from(d.values())}return{discoverCatalogEntries:o}}exports.createCatalogDirectoryDiscovery=a;
2
2
  //# sourceMappingURL=catalogDirectory.cjs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"catalogDirectory.cjs.js","names":["graph","NamedNode","ns","isHttpUri","require_debug","require_ns","require_directoryHelpers","rdflib","CATALOG_VOCAB","createCatalogDirectoryDiscovery","catalogEntriesCache","discoverCatalogEntries","entries","fetchCatalogEntries","catalogUrl","entry","onEntry","cached","promise","loadCatalogEntries","error","response","turtle","catalogStore","personType","webIdPredicate","namePredicate","catalogPeople","statements","statement","subject","webIdNode","webId","personName"],"sources":["../../src/directory/catalogDirectory.ts"],"sourcesContent":["import { type DirectoryEntry } from '../types'\nimport { graph, type LiveStore, NamedNode, parse } from 'rdflib'\nimport { ns } from '../util/ns'\nimport * as debug from '../util/debug'\nimport { isHttpUri } from './directoryHelpers'\n\nconst CATALOG_VOCAB = 'http://example.org#'\n\nexport function createCatalogDirectoryDiscovery () {\n const catalogEntriesCache = new Map<string, Promise<DirectoryEntry[]>>()\n\n async function discoverCatalogEntries (\n catalogUrl: string,\n onEntry: (entry: DirectoryEntry) => void | Promise<void>\n ): Promise<void> {\n const entries = await fetchCatalogEntries(catalogUrl)\n for (const entry of entries) {\n await onEntry(entry)\n }\n }\n\n async function fetchCatalogEntries (catalogUrl: string): Promise<DirectoryEntry[]> {\n const cached = catalogEntriesCache.get(catalogUrl)\n if (cached) {\n return cached\n }\n\n const promise = loadCatalogEntries(catalogUrl).catch(error => {\n catalogEntriesCache.delete(catalogUrl)\n throw error\n })\n\n catalogEntriesCache.set(catalogUrl, promise)\n try {\n return await promise\n } catch (error) {\n debug.warn('[Directory] Error fetching directory catalog:', error)\n return []\n }\n }\n\n async function loadCatalogEntries (catalogUrl: string): Promise<DirectoryEntry[]> {\n if (typeof fetch !== 'function') {\n throw new Error('Fetch API is unavailable')\n }\n\n const response = await fetch(catalogUrl, {\n headers: { accept: 'text/turtle' }\n })\n\n if (!response.ok) {\n throw new Error(`Failed to fetch ${catalogUrl}: ${response.status}`)\n }\n\n const turtle = await response.text()\n const catalogStore = graph() as LiveStore\n parse(turtle, catalogStore, catalogUrl, 'text/turtle')\n\n const personType = new NamedNode(`${CATALOG_VOCAB}Person`)\n const webIdPredicate = new NamedNode(`${CATALOG_VOCAB}webid`)\n const namePredicate = new NamedNode(`${CATALOG_VOCAB}name`)\n const catalogPeople = new Map<string, DirectoryEntry>()\n\n const statements = catalogStore.statementsMatching(undefined, ns.rdf('type'), personType)\n for (const statement of statements) {\n const subject = statement.subject\n const webIdNode = catalogStore.any(subject, webIdPredicate)\n if (webIdNode && webIdNode.termType === 'NamedNode') {\n const webId = webIdNode.value\n const personName = catalogStore.anyValue(subject, namePredicate)\n if (isHttpUri(webId) && personName) {\n catalogPeople.set(webId, {\n kind: 'person',\n uri: webId,\n label: personName,\n subjectType: 'agent',\n relationshipLabel: 'People',\n sources: ['catalog']\n })\n }\n }\n }\n\n return Array.from(catalogPeople.values())\n }\n\n return {\n discoverCatalogEntries\n }\n}\n"],"mappings":"sIAMA,IAAMQ,EAAgB,sBAEtB,SAAgBC,GAAmC,CACjD,IAAMC,EAAsB,IAAI,IAEhC,eAAeC,EACb,EACA,EACe,CACf,IAAMC,EAAU,MAAMC,EAAoBC,CAAU,EACpD,IAAK,IAAMC,KAASH,EAClB,MAAMI,EAAQD,CAAK,CAEvB,CAEA,eAAeF,EAAqB,EAA+C,CACjF,IAAMI,EAASP,EAAoB,IAAII,CAAU,EACjD,GAAIG,EACF,OAAOA,EAGT,IAAMC,EAAUC,EAAmBL,CAAU,CAAC,CAAC,MAAM,GAAS,CAE5D,MADAJ,EAAoB,OAAOI,CAAU,EAC/BM,CACR,CAAC,EAEDV,EAAoB,IAAII,EAAYI,CAAO,EAC3C,GAAI,CACF,OAAO,MAAMA,CACf,OAASE,EAAO,CAEd,OADAhB,EAAA,KAAW,gDAAiDgB,CAAK,EAC1D,CAAC,CACV,CACF,CAEA,eAAeD,EAAoB,EAA+C,CAChF,GAAI,OAAO,OAAU,WACnB,MAAU,MAAM,0BAA0B,EAG5C,IAAME,EAAW,MAAM,MAAMP,EAAY,CACvC,QAAS,CAAE,OAAQ,aAAc,CACnC,CAAC,EAED,GAAI,CAACO,EAAS,GACZ,MAAU,MAAM,mBAAmBP,EAAW,IAAIO,EAAS,QAAQ,EAGrE,IAAMC,EAAS,MAAMD,EAAS,KAAK,EAC7BE,GAAA,EAAevB,EAAAA,MAAAA,CAAM,GAC3B,EAAAO,EAAA,MAAA,CAAMe,EAAQC,EAAcT,EAAY,aAAa,EAErD,IAAMU,EAAa,IAAIvB,EAAAA,UAAU,GAAGO,EAAc,OAAO,EACnDiB,EAAiB,IAAIxB,EAAAA,UAAU,GAAGO,EAAc,MAAM,EACtDkB,EAAgB,IAAIzB,EAAAA,UAAU,GAAGO,EAAc,KAAK,EACpDmB,EAAgB,IAAI,IAEpBC,EAAaL,EAAa,mBAAmB,IAAA,GAAWrB,EAAAA,GAAG,IAAI,MAAM,EAAGsB,CAAU,EACxF,IAAK,IAAMK,KAAaD,EAAY,CAClC,IAAME,EAAUD,EAAU,QACpBE,EAAYR,EAAa,IAAIO,EAASL,CAAc,EAC1D,GAAIM,GAAaA,EAAU,WAAa,YAAa,CACnD,IAAMC,EAAQD,EAAU,MAClBE,EAAaV,EAAa,SAASO,EAASJ,CAAa,EAC3DvB,EAAAA,UAAU6B,CAAK,GAAKC,GACtBN,EAAc,IAAIK,EAAO,CACvB,KAAM,SACN,IAAKA,EACL,MAAOC,EACP,YAAa,QACb,kBAAmB,SACnB,QAAS,CAAC,SAAS,CACrB,CAAC,CAEL,CACF,CAEA,OAAO,MAAM,KAAKN,EAAc,OAAO,CAAC,CAC1C,CAEA,MAAO,CACL,wBACF,CACF"}
1
+ {"version":3,"file":"catalogDirectory.cjs.js","names":["graph","NamedNode","ns","isHttpUri","require_ns","require_debug","require_directoryHelpers","rdflib","CATALOG_VOCAB","createCatalogDirectoryDiscovery","catalogEntriesCache","discoverCatalogEntries","entries","fetchCatalogEntries","catalogUrl","entry","onEntry","cached","promise","loadCatalogEntries","error","response","turtle","catalogStore","personType","webIdPredicate","namePredicate","catalogPeople","statements","statement","subject","webIdNode","webId","personName"],"sources":["../../src/directory/catalogDirectory.ts"],"sourcesContent":["import { type DirectoryEntry } from '../types'\nimport { graph, type LiveStore, NamedNode, parse } from 'rdflib'\nimport { ns } from '../util/ns'\nimport * as debug from '../util/debug'\nimport { isHttpUri } from './directoryHelpers'\n\nconst CATALOG_VOCAB = 'http://example.org#'\n\nexport function createCatalogDirectoryDiscovery () {\n const catalogEntriesCache = new Map<string, Promise<DirectoryEntry[]>>()\n\n async function discoverCatalogEntries (\n catalogUrl: string,\n onEntry: (entry: DirectoryEntry) => void | Promise<void>\n ): Promise<void> {\n const entries = await fetchCatalogEntries(catalogUrl)\n for (const entry of entries) {\n await onEntry(entry)\n }\n }\n\n async function fetchCatalogEntries (catalogUrl: string): Promise<DirectoryEntry[]> {\n const cached = catalogEntriesCache.get(catalogUrl)\n if (cached) {\n return cached\n }\n\n const promise = loadCatalogEntries(catalogUrl).catch(error => {\n catalogEntriesCache.delete(catalogUrl)\n throw error\n })\n\n catalogEntriesCache.set(catalogUrl, promise)\n try {\n return await promise\n } catch (error) {\n debug.warn('[Directory] Error fetching directory catalog:', error)\n return []\n }\n }\n\n async function loadCatalogEntries (catalogUrl: string): Promise<DirectoryEntry[]> {\n if (typeof fetch !== 'function') {\n throw new Error('Fetch API is unavailable')\n }\n\n const response = await fetch(catalogUrl, {\n headers: { accept: 'text/turtle' }\n })\n\n if (!response.ok) {\n throw new Error(`Failed to fetch ${catalogUrl}: ${response.status}`)\n }\n\n const turtle = await response.text()\n const catalogStore = graph() as LiveStore\n parse(turtle, catalogStore, catalogUrl, 'text/turtle')\n\n const personType = new NamedNode(`${CATALOG_VOCAB}Person`)\n const webIdPredicate = new NamedNode(`${CATALOG_VOCAB}webid`)\n const namePredicate = new NamedNode(`${CATALOG_VOCAB}name`)\n const catalogPeople = new Map<string, DirectoryEntry>()\n\n const statements = catalogStore.statementsMatching(undefined, ns.rdf('type'), personType)\n for (const statement of statements) {\n const subject = statement.subject\n const webIdNode = catalogStore.any(subject, webIdPredicate)\n if (webIdNode && webIdNode.termType === 'NamedNode') {\n const webId = webIdNode.value\n const personName = catalogStore.anyValue(subject, namePredicate)\n if (isHttpUri(webId) && personName) {\n catalogPeople.set(webId, {\n kind: 'person',\n uri: webId,\n label: personName,\n subjectType: 'agent',\n relationshipLabel: 'People',\n sources: ['catalog']\n })\n }\n }\n }\n\n return Array.from(catalogPeople.values())\n }\n\n return {\n discoverCatalogEntries\n }\n}\n"],"mappings":"A,sIAMA,IAAMQ,EAAgB,sBAEtB,SAAgBC,GAAmC,CACjD,IAAMC,EAAsB,IAAI,IAEhC,eAAeC,EACb,EACA,EACe,CACf,IAAMC,EAAU,MAAMC,EAAoBC,CAAU,EACpD,I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AaV,EAAa,SAASO,EAASJ,CAAa,EAC3DvB,EAAAA,UAAU6B,CAAK,GAAKC,GACtBN,EAAc,IAAIK,EAAO,CACvB,KAAM,SACN,IAAKA,EACL,MAAOC,EACP,YAAa,QACb,kBAAmB,SACnB,QAAS,CAAC,SAAS,CACrB,CAAC,CAEL,CACF,CAEA,OAAO,MAAM,KAAKN,EAAc,OAAO,CAAC,CAC1C,CAEA,MAAO,CACL,wBACF,CACF,C"}
@@ -1,8 +1,8 @@
1
- import { warn as e } from "../util/debug.esm.js";
2
- import { ns as t } from "../util/ns.esm.js";
1
+ import { ns as e } from "../util/ns.esm.js";
2
+ import { warn as t } from "../util/debug.esm.js";
3
3
  import { isHttpUri as n } from "./directoryHelpers.esm.js";
4
4
  import { NamedNode as r, graph as i, parse as a } from "rdflib";
5
- //#region src/directory/catalogDirectory.ts
5
+ // src/directory/catalogDirectory.ts
6
6
  var o = "http://example.org#";
7
7
  function s() {
8
8
  let s = /* @__PURE__ */ new Map();
@@ -10,26 +10,26 @@ function s() {
10
10
  let n = await l(e);
11
11
  for (let e of n) await t(e);
12
12
  }
13
- async function l(t) {
14
- let n = s.get(t);
13
+ async function l(e) {
14
+ let n = s.get(e);
15
15
  if (n) return n;
16
- let r = u(t).catch((e) => {
17
- throw s.delete(t), e;
16
+ let r = u(e).catch((t) => {
17
+ throw s.delete(e), t;
18
18
  });
19
- s.set(t, r);
19
+ s.set(e, r);
20
20
  try {
21
21
  return await r;
22
- } catch (t) {
23
- return e("[Directory] Error fetching directory catalog:", t), [];
22
+ } catch (e) {
23
+ return t("[Directory] Error fetching directory catalog:", e), [];
24
24
  }
25
25
  }
26
- async function u(e) {
26
+ async function u(t) {
27
27
  if (typeof fetch != "function") throw Error("Fetch API is unavailable");
28
- let s = await fetch(e, { headers: { accept: "text/turtle" } });
29
- if (!s.ok) throw Error(`Failed to fetch ${e}: ${s.status}`);
28
+ let s = await fetch(t, { headers: { accept: "text/turtle" } });
29
+ if (!s.ok) throw Error(`Failed to fetch ${t}: ${s.status}`);
30
30
  let c = await s.text(), l = i();
31
- a(c, l, e, "text/turtle");
32
- let u = new r(`${o}Person`), d = new r(`${o}webid`), f = new r(`${o}name`), p = /* @__PURE__ */ new Map(), m = l.statementsMatching(void 0, t.rdf("type"), u);
31
+ a(c, l, t, "text/turtle");
32
+ let u = new r(`${o}Person`), d = new r(`${o}webid`), f = new r(`${o}name`), p = /* @__PURE__ */ new Map(), m = l.statementsMatching(void 0, e.rdf("type"), u);
33
33
  for (let e of m) {
34
34
  let t = e.subject, r = l.any(t, d);
35
35
  if (r && r.termType === "NamedNode") {
@@ -48,7 +48,6 @@ function s() {
48
48
  }
49
49
  return { discoverCatalogEntries: c };
50
50
  }
51
- //#endregion
52
51
  export { s as createCatalogDirectoryDiscovery };
53
52
 
54
53
  //# sourceMappingURL=catalogDirectory.esm.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"contactsDirectory.cjs.js","names":["ns","uniqueNamedNodes","loadDocumentSilently","isHttpUri","labelForNode","require_ns","require_directoryHelpers","CONTACT_CARD_CONCURRENCY","createContactsDirectoryDiscovery","personalAddressBooksCache","contactWebIdCache","loadPersonalAddressBooks","cached","user","promise","scopes","typeIndexLogic","scopedApps","scope","apps","app","error","webIdForAddressBookContact","contact","store","urlNodes","urlNode","webId","resolveWebIdFromAddressBookUrlNode","doc","discoverAddressBookContacts","books","book","nameEmailIndex","contacts","index","batch","entries","entry","onEntry","discoverAddressBookGroups","groupIndex","groups","group"],"sources":["../../src/directory/contactsDirectory.ts"],"sourcesContent":["import { type DirectoryEntry, type DirectorySource, type TypeIndexLogic } from '../types'\nimport { type LiveStore, NamedNode } from 'rdflib'\nimport { ns } from '../util/ns'\nimport { isHttpUri, labelForNode, loadDocumentSilently, uniqueNamedNodes } from './directoryHelpers'\n\nconst CONTACT_CARD_CONCURRENCY = 8\n\nexport function createContactsDirectoryDiscovery (\n store: LiveStore,\n typeIndexLogic: TypeIndexLogic\n) {\n const personalAddressBooksCache = new Map<string, Promise<NamedNode[]>>()\n const contactWebIdCache = new Map<string, Promise<string | null>>()\n\n async function loadPersonalAddressBooks (user: NamedNode): Promise<NamedNode[]> {\n const cached = personalAddressBooksCache.get(user.value)\n if (cached) {\n return cached\n }\n\n const promise = (async () => {\n const scopes = await typeIndexLogic.loadTypeIndexesFor(user)\n let scopedApps = [] as Awaited<ReturnType<TypeIndexLogic['getScopedAppsFromIndex']>>\n\n for (const scope of scopes) {\n const apps = await typeIndexLogic.getScopedAppsFromIndex(scope, ns.vcard('AddressBook'))\n scopedApps = scopedApps.concat(apps)\n }\n\n return uniqueNamedNodes(scopedApps.map(app => app.instance))\n })().catch(error => {\n personalAddressBooksCache.delete(user.value)\n throw error\n })\n\n personalAddressBooksCache.set(user.value, promise)\n return promise\n }\n\n async function webIdForAddressBookContact (contact: NamedNode): Promise<string | null> {\n const cached = contactWebIdCache.get(contact.value)\n if (cached) {\n return cached\n }\n\n const promise = (async () => {\n if (!await loadDocumentSilently(store, contact)) {\n return null\n }\n\n const urlNodes = store.each(contact, ns.vcard('url'), null, contact.doc()) as NamedNode[]\n for (const urlNode of urlNodes) {\n const webId = resolveWebIdFromAddressBookUrlNode(urlNode, contact.doc())\n if (webId) {\n return webId\n }\n }\n\n return null\n })().catch(error => {\n contactWebIdCache.delete(contact.value)\n throw error\n })\n\n contactWebIdCache.set(contact.value, promise)\n return promise\n }\n\n function resolveWebIdFromAddressBookUrlNode (urlNode: NamedNode, doc: NamedNode): string | null {\n if (!store.holds(urlNode, ns.rdf('type'), ns.vcard('WebID'), doc)) {\n return null\n }\n\n const valueNode = store.any(urlNode, ns.vcard('value'), null, doc)\n const webId = valueNode?.value || ''\n return isHttpUri(webId) ? webId : null\n }\n\n async function discoverAddressBookContacts (\n user: NamedNode,\n onEntry: (entry: DirectoryEntry) => void | Promise<void>\n ): Promise<void> {\n const books = await loadPersonalAddressBooks(user)\n\n for (const book of books) {\n if (await loadDocumentSilently(store, book)) {\n const nameEmailIndex = store.any(book, ns.vcard('nameEmailIndex'), null, book.doc()) as NamedNode | null\n if (nameEmailIndex) {\n if (await loadDocumentSilently(store, nameEmailIndex)) {\n const contacts = store.each(undefined, ns.vcard('inAddressBook'), book, nameEmailIndex) as NamedNode[]\n for (let index = 0; index < contacts.length; index += CONTACT_CARD_CONCURRENCY) {\n const batch = contacts.slice(index, index + CONTACT_CARD_CONCURRENCY)\n const entries = await Promise.all(batch.map(async contact => {\n const webId = await webIdForAddressBookContact(contact)\n if (!webId) {\n return null\n }\n\n return {\n kind: 'person' as const,\n uri: webId,\n label: store.anyValue(contact, ns.vcard('fn'), null, nameEmailIndex) || labelForNode(store, contact),\n subjectType: 'agent' as const,\n relationshipLabel: 'Contact' as const,\n sources: ['contacts'] as DirectorySource[]\n }\n }))\n\n for (const entry of entries.filter((entry): entry is NonNullable<typeof entry> => Boolean(entry))) {\n await onEntry(entry)\n }\n }\n }\n }\n }\n }\n }\n\n async function discoverAddressBookGroups (\n user: NamedNode,\n onEntry: (entry: DirectoryEntry) => void | Promise<void>\n ): Promise<void> {\n const books = await loadPersonalAddressBooks(user)\n\n for (const book of books) {\n if (await loadDocumentSilently(store, book)) {\n const groupIndex = store.any(book, ns.vcard('groupIndex'), null, book.doc()) as NamedNode | null\n if (groupIndex) {\n if (await loadDocumentSilently(store, groupIndex)) {\n const groups = uniqueNamedNodes([\n ...(store.each(book, ns.vcard('includesGroup'), null, groupIndex) as NamedNode[]),\n ...(store.each(book, ns.vcard('includesGroup'), null, book.doc()) as NamedNode[])\n ])\n\n for (const group of groups) {\n await loadDocumentSilently(store, group)\n\n await onEntry({\n kind: 'group',\n uri: group.value,\n label: labelForNode(store, group),\n subjectType: 'agentGroup',\n relationshipLabel: 'Group',\n sources: ['groups']\n })\n }\n }\n }\n }\n }\n }\n\n return {\n discoverAddressBookContacts,\n discoverAddressBookGroups\n }\n}\n"],"mappings":"4EAKA,IAAMO,EAA2B,EAEjC,SAAgBC,EACd,EACA,EACA,CACA,IAAMC,EAA4B,IAAI,IACh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AAQD,CAAK,CAEvB,CACF,CAEJ,CAEJ,CAEA,eAAeE,EACb,EACA,EACe,CACf,IAAMT,EAAQ,MAAMpB,EAAyBE,CAAI,EAEjD,IAAK,IAAMmB,KAAQD,EACjB,GAAI,MAAM7B,EAAAA,qBAAqBsB,EAAOQ,CAAI,EAAG,CAC3C,IAAMS,EAAajB,EAAM,IAAIQ,EAAMhC,EAAAA,GAAG,MAAM,YAAY,EAAG,KAAMgC,EAAK,IAAI,CAAC,EAC3E,GAAIS,GACE,MAAMvC,EAAAA,qBAAqBsB,EAAOiB,CAAU,EAAG,CACjD,IAAMC,EAASzC,EAAAA,iBAAiB,CAC9B,GAAIuB,EAAM,KAAKQ,EAAMhC,EAAAA,GAAG,MAAM,eAAe,EAAG,KAAMyC,CAAU,EAChE,GAAIjB,EAAM,KAAKQ,EAAMhC,EAAAA,GAAG,MAAM,eAAe,EAAG,KAAMgC,EAAK,IAAI,CAAC,CAClE,CAAC,EAED,IAAK,IAAMW,KAASD,EAClB,MAAMxC,EAAAA,qBAAqBsB,EAAOmB,CAAK,EAEvC,MAAMJ,EAAQ,CACZ,KAAM,QACN,IAAKI,EAAM,MACX,MAAOvC,EAAAA,aAAaoB,EAAOmB,CAAK,EAChC,YAAa,aACb,kBAAmB,QACnB,QAAS,CAAC,QAAQ,CACpB,CAAC,CAEL,CAEJ,CAEJ,CAEA,MAAO,CACL,8BACA,2BACF,CACF"}
1
+ {"version":3,"file":"contactsDirectory.cjs.js","names":["ns","uniqueNamedNodes","loadDocumentSilently","isHttpUri","labelForNode","require_ns","require_directoryHelpers","CONTACT_CARD_CONCURRENCY","createContactsDirectoryDiscovery","personalAddressBooksCache","contactWebIdCache","loadPersonalAddressBooks","cached","user","promise","scopes","typeIndexLogic","scopedApps","scope","apps","app","error","webIdForAddressBookContact","contact","store","urlNodes","urlNode","webId","resolveWebIdFromAddressBookUrlNode","doc","discoverAddressBookContacts","books","book","nameEmailIndex","contacts","index","batch","entries","entry","onEntry","discoverAddressBookGroups","groupIndex","groups","group"],"sources":["../../src/directory/contactsDirectory.ts"],"sourcesContent":["import { type DirectoryEntry, type DirectorySource, type TypeIndexLogic } from '../types'\nimport { type LiveStore, NamedNode } from 'rdflib'\nimport { ns } from '../util/ns'\nimport { isHttpUri, labelForNode, loadDocumentSilently, uniqueNamedNodes } from './directoryHelpers'\n\nconst CONTACT_CARD_CONCURRENCY = 8\n\nexport function createContactsDirectoryDiscovery (\n store: LiveStore,\n typeIndexLogic: TypeIndexLogic\n) {\n const personalAddressBooksCache = new Map<string, Promise<NamedNode[]>>()\n const contactWebIdCache = new Map<string, Promise<string | null>>()\n\n async function loadPersonalAddressBooks (user: NamedNode): Promise<NamedNode[]> {\n const cached = personalAddressBooksCache.get(user.value)\n if (cached) {\n return cached\n }\n\n const promise = (async () => {\n const scopes = await typeIndexLogic.loadTypeIndexesFor(user)\n let scopedApps = [] as Awaited<ReturnType<TypeIndexLogic['getScopedAppsFromIndex']>>\n\n for (const scope of scopes) {\n const apps = await typeIndexLogic.getScopedAppsFromIndex(scope, ns.vcard('AddressBook'))\n scopedApps = scopedApps.concat(apps)\n }\n\n return uniqueNamedNodes(scopedApps.map(app => app.instance))\n })().catch(error => {\n personalAddressBooksCache.delete(user.value)\n throw error\n })\n\n personalAddressBooksCache.set(user.value, promise)\n return promise\n }\n\n async function webIdForAddressBookContact (contact: NamedNode): Promise<string | null> {\n const cached = contactWebIdCache.get(contact.value)\n if (cached) {\n return cached\n }\n\n const promise = (async () => {\n if (!await loadDocumentSilently(store, contact)) {\n return null\n }\n\n const urlNodes = store.each(contact, ns.vcard('url'), null, contact.doc()) as NamedNode[]\n for (const urlNode of urlNodes) {\n const webId = resolveWebIdFromAddressBookUrlNode(urlNode, contact.doc())\n if (webId) {\n return webId\n }\n }\n\n return null\n })().catch(error => {\n contactWebIdCache.delete(contact.value)\n throw error\n })\n\n contactWebIdCache.set(contact.value, promise)\n return promise\n }\n\n function resolveWebIdFromAddressBookUrlNode (urlNode: NamedNode, doc: NamedNode): string | null {\n if (!store.holds(urlNode, ns.rdf('type'), ns.vcard('WebID'), doc)) {\n return null\n }\n\n const valueNode = store.any(urlNode, ns.vcard('value'), null, doc)\n const webId = valueNode?.value || ''\n return isHttpUri(webId) ? webId : null\n }\n\n async function discoverAddressBookContacts (\n user: NamedNode,\n onEntry: (entry: DirectoryEntry) => void | Promise<void>\n ): Promise<void> {\n const books = await loadPersonalAddressBooks(user)\n\n for (const book of books) {\n if (await loadDocumentSilently(store, book)) {\n const nameEmailIndex = store.any(book, ns.vcard('nameEmailIndex'), null, book.doc()) as NamedNode | null\n if (nameEmailIndex) {\n if (await loadDocumentSilently(store, nameEmailIndex)) {\n const contacts = store.each(undefined, ns.vcard('inAddressBook'), book, nameEmailIndex) as NamedNode[]\n for (let index = 0; index < contacts.length; index += CONTACT_CARD_CONCURRENCY) {\n const batch = contacts.slice(index, index + CONTACT_CARD_CONCURRENCY)\n const entries = await Promise.all(batch.map(async contact => {\n const webId = await webIdForAddressBookContact(contact)\n if (!webId) {\n return null\n }\n\n return {\n kind: 'person' as const,\n uri: webId,\n label: store.anyValue(contact, ns.vcard('fn'), null, nameEmailIndex) || labelForNode(store, contact),\n subjectType: 'agent' as const,\n relationshipLabel: 'Contact' as const,\n sources: ['contacts'] as DirectorySource[]\n }\n }))\n\n for (const entry of entries.filter((entry): entry is NonNullable<typeof entry> => Boolean(entry))) {\n await onEntry(entry)\n }\n }\n }\n }\n }\n }\n }\n\n async function discoverAddressBookGroups (\n user: NamedNode,\n onEntry: (entry: DirectoryEntry) => void | Promise<void>\n ): Promise<void> {\n const books = await loadPersonalAddressBooks(user)\n\n for (const book of books) {\n if (await loadDocumentSilently(store, book)) {\n const groupIndex = store.any(book, ns.vcard('groupIndex'), null, book.doc()) as NamedNode | null\n if (groupIndex) {\n if (await loadDocumentSilently(store, groupIndex)) {\n const groups = uniqueNamedNodes([\n ...(store.each(book, ns.vcard('includesGroup'), null, groupIndex) as NamedNode[]),\n ...(store.each(book, ns.vcard('includesGroup'), null, book.doc()) as NamedNode[])\n ])\n\n for (const group of groups) {\n await loadDocumentSilently(store, group)\n\n await onEntry({\n kind: 'group',\n uri: group.value,\n label: labelForNode(store, group),\n subjectType: 'agentGroup',\n relationshipLabel: 'Group',\n sources: ['groups']\n })\n }\n }\n }\n }\n }\n }\n\n return {\n discoverAddressBookContacts,\n discoverAddressBookGroups\n }\n}\n"],"mappings":"A,4EAKA,IAAMO,EAA2B,EAEjC,SAAgBC,EACd,EACA,EACA,CACA,IAAMC,EAA4B,IAAI,IAChCC,EAAoB,IAAI,IAE9B,eAAeC,EAA0B,EAAuC,CAC9E,IAAMC,EAASH,EAA0B,IAAII,EAAK,KAAK,EACvD,GAAID,EACF,OAAOA,EAGT,IAAME,GAAW,SAAY,CAC3B,IAAMC,EAAS,MAAMC,EAAe,mBAAmBH,CAAI,EACvDI,EAAa,CAAC,EAElB,IAAK,IAAMC,KAASH,EAAQ,CAC1B,IAAMI,EAAO,MAAMH,EAAe,uBAAuBE,EAAOlB,EAAAA,GAAG,MAAM,aAAa,CAAC,EACvF,EAAaiB,EAAW,OAAOE,CAAI,CACrC,CAEA,OAAOlB,EAAAA,iBAAiBgB,EAAW,IAAI,GAAOG,EAAI,QAAQ,CAAC,CAC7D,EAAA,CAAG,CAAC,CAAC,MAAM,GAAS,CAElB,MADAX,EAA0B,OAAOI,EAAK,KAAK,EACrCQ,CACR,CAAC,EAGD,OADAZ,EAA0B,IAAII,EAAK,MAAOC,CAAO,EAC1CA,CACT,CAEA,eAAeQ,EAA4B,EAA4C,CACrF,IAAMV,EAASF,EAAkB,IAAIa,EAAQ,KAAK,EAClD,GAAIX,EACF,OAAOA,EAGT,IAAME,GAAW,SAAY,CAC3B,GAAI,CAAC,MAAMZ,EAAAA,qBAAqBsB,EAAOD,CAAO,EAC5C,OAAO,KAGT,IAAME,EAAWD,EAAM,KAAKD,EAASvB,EAAAA,GAAG,MAAM,KAAK,EAAG,KAAMuB,EAAQ,IAAI,CAAC,EACzE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 @@
1
1
  import { ns as e } from "../util/ns.esm.js";
2
2
  import { isHttpUri as t, labelForNode as n, loadDocumentSilently as r, uniqueNamedNodes as i } from "./directoryHelpers.esm.js";
3
- //#region src/directory/contactsDirectory.ts
3
+ // src/directory/contactsDirectory.ts
4
4
  var a = 8;
5
5
  function o(o, s) {
6
6
  let c = /* @__PURE__ */ new Map(), l = /* @__PURE__ */ new Map();
@@ -85,7 +85,6 @@ function o(o, s) {
85
85
  discoverAddressBookGroups: m
86
86
  };
87
87
  }
88
- //#endregion
89
88
  export { o as createContactsDirectoryDiscovery };
90
89
 
91
90
  //# sourceMappingURL=contactsDirectory.esm.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"directoryHelpers.cjs.js","names":["ns","require_ns","DIRECTORY_SOURCE_PRIORITY","tokenizeQuery","query","matchesAnyLabel","queryWords","labelWords","labels","label","fallbackHaystack","labelWord","word","sortEntries","entries","left","right","mergeDirectoryEntry","key","directoryEntryKey","entry","existing","discoveredEntries","preferred","preferredDirectoryEntry","canonicalizeSearchableLabels","merged","bestRelationshipLabel","canonicalizeDirectorySources","normalized","directoryEntrySourcePriority","incoming","current","priorities","source","sources","uniqueStrings","preferredLabel","uniqueNamedNodes","seen","nodes","node","values","isHttpUri","value","fallbackLabel","withoutFragment","uri","fragment","base","storedLabelForNode","store","labelForNode","loadDocumentSilently"],"sources":["../../src/directory/directoryHelpers.ts"],"sourcesContent":["import type { LiveStore, NamedNode } from 'rdflib'\nimport type { DirectoryEntry, DirectoryRelationshipLabel, DirectorySource } from '../types'\nimport { ns } from '../util/ns'\n\nconst DIRECTORY_SOURCE_PRIORITY: DirectorySource[] = ['contacts', 'groups', 'friends', 'catalog']\n\nexport function tokenizeQuery (query: string): string[] {\n return query\n .toLowerCase()\n .trim()\n .split(/\\s+/)\n .filter(Boolean)\n}\n\nexport function matchesQuery (label: string, query: string): boolean {\n return matchesAnyLabel([label], query)\n}\n\nexport function matchesAnyLabel (labels: string[], query: string): boolean {\n const queryWords = tokenizeQuery(query)\n if (queryWords.length === 0) return true\n\n const labelWords = labels.flatMap(label => tokenizeQuery(label))\n const fallbackHaystack = labels.join(' ').toLowerCase()\n return queryWords.every(word =>\n labelWords.some(labelWord => labelWord.includes(word)) || fallbackHaystack.includes(word)\n )\n}\n\nexport function sortEntries (entries: Iterable<DirectoryEntry>): DirectoryEntry[] {\n return Array.from(entries)\n .sort((left, right) => left.label.localeCompare(right.label, undefined, { sensitivity: 'base' }))\n}\n\nexport function mergeDirectoryEntry (\n discoveredEntries: Map<string, DirectoryEntry>,\n entry: DirectoryEntry\n): DirectoryEntry {\n const key = directoryEntryKey(entry)\n const existing = discoveredEntries.get(key)\n if (existing) {\n const preferred = preferredDirectoryEntry(existing, entry)\n const labels = canonicalizeSearchableLabels(\n preferred.label,\n [...(existing.searchableLabels ?? [existing.label]), ...(entry.searchableLabels ?? [entry.label])]\n )\n const merged = {\n ...existing,\n label: preferred.label,\n relationshipLabel: bestRelationshipLabel(existing.relationshipLabel, entry.relationshipLabel),\n sources: canonicalizeDirectorySources([...existing.sources, ...entry.sources]),\n searchableLabels: labels\n }\n discoveredEntries.set(key, merged)\n return merged\n }\n\n const normalized = {\n ...entry,\n sources: canonicalizeDirectorySources(entry.sources),\n searchableLabels: entry.searchableLabels ?? [entry.label]\n }\n discoveredEntries.set(key, normalized)\n return normalized\n}\n\nfunction preferredDirectoryEntry (current: DirectoryEntry, incoming: DirectoryEntry): DirectoryEntry {\n return directoryEntrySourcePriority(incoming) < directoryEntrySourcePriority(current) ? incoming : current\n}\n\nfunction directoryEntrySourcePriority (entry: DirectoryEntry): number {\n const priorities = entry.sources.map(source => DIRECTORY_SOURCE_PRIORITY.indexOf(source))\n return priorities.length ? Math.min(...priorities) : DIRECTORY_SOURCE_PRIORITY.length\n}\n\nexport function canonicalizeDirectorySources (sources: DirectorySource[]): DirectorySource[] {\n return DIRECTORY_SOURCE_PRIORITY.filter(source => sources.includes(source))\n}\n\nfunction canonicalizeSearchableLabels (preferredLabel: string, labels: string[]): string[] {\n return uniqueStrings(labels).sort((left, right) => {\n if (left === preferredLabel) return -1\n if (right === preferredLabel) return 1\n return left.localeCompare(right, undefined, { sensitivity: 'base' })\n })\n}\n\nexport function bestRelationshipLabel (\n current: DirectoryRelationshipLabel | undefined,\n incoming: DirectoryRelationshipLabel\n): DirectoryRelationshipLabel {\n if (current === 'Contact' || incoming === 'Contact') return 'Contact'\n if (current === 'Friend' || incoming === 'Friend') return 'Friend'\n if (current === 'Group' || incoming === 'Group') return 'Group'\n return 'People'\n}\n\nexport function directoryEntryKey (entry: DirectoryEntry): string {\n return `${entry.kind}:${entry.uri}`\n}\n\nexport function uniqueNamedNodes (nodes: NamedNode[]): NamedNode[] {\n const seen = new Set<string>()\n return nodes.filter(node => {\n if (seen.has(node.value)) return false\n seen.add(node.value)\n return true\n })\n}\n\nexport function uniqueStrings<T extends string> (values: T[]): T[] {\n return [...new Set(values)]\n}\n\nexport function isHttpUri (value: string | null | undefined): boolean {\n return !!value && (value.startsWith('https://') || value.startsWith('http://'))\n}\n\nexport function fallbackLabel (uri: string): string {\n const withoutFragment = uri.split('#')[0]\n const fragment = uri.includes('#') ? uri.slice(uri.indexOf('#') + 1) : ''\n const base = fragment && fragment !== 'this' && fragment !== 'me'\n ? fragment\n : withoutFragment.slice(withoutFragment.lastIndexOf('/') + 1)\n return decodeURIComponent(base || uri).replace(/[_-]+/g, ' ')\n}\n\nexport function storedLabelForNode (store: LiveStore, node: NamedNode): string | null {\n return store.anyValue(node, ns.vcard('fn')) ||\n store.anyValue(node, ns.foaf('name')) ||\n store.anyValue(node, ns.schema('name')) ||\n store.anyValue(node, ns.rdfs('label')) ||\n null\n}\n\nexport function labelForNode (store: LiveStore, node: NamedNode): string {\n return storedLabelForNode(store, node) || fallbackLabel(node.value)\n}\n\nexport async function loadDocumentSilently (store: LiveStore, node: NamedNode): Promise<boolean> {\n try {\n await store.fetcher.load(node.doc())\n return true\n } catch (_error) {\n return false\n }\n}\n"],"mappings":"qCA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,SAAgBC,EAAW,EAA2C,CACpE,MAAO,CAAC,CAACC,IAAUA,EAAM,WAAW,UAAU,GAAKA,EAAM,WAAW,SAAS,EAC/E,CAEA,SAAgBC,EAAe,EAAqB,CAClD,IAAMC,EAAkBC,EAAI,MAAM,GAAG,CAAC,CAAC,GACjCC,EAAWD,EAAI,SAAS,GAAG,EAAIA,EAAI,MAAMA,EAAI,QAAQ,GAAG,EAAI,CAAC,EAAI,GACjEE,EAAOD,GAAYA,IAAa,QAAUA,IAAa,KACzDA,EACAF,EAAgB,MAAMA,EAAgB,YAAY,GAAG,EAAI,CAAC,EAC9D,OAAO,mBAAmBG,GAAQF,CAAG,CAAC,CAAC,QAAQ,SAAU,GAAG,CAC9D,CAEA,SAAgBG,EAAoB,EAAkB,EAAgC,CACpF,OAAOC,EAAM,SAASV,EAAMzC,EAAAA,GAAG,MAAM,IAAI,CAAC,GACxCmD,EAAM,SAASV,EAAMzC,EAAAA,GAAG,KAAK,MAAM,CAAC,GACpCmD,EAAM,SAASV,EAAMzC,EAAAA,GAAG,OAAO,MAAM,CAAC,GACtCmD,EAAM,SAASV,EAAMzC,EAAAA,GAAG,KAAK,OAAO,CAAC,GACrC,IACJ,CAEA,SAAgBoD,EAAc,EAAkB,EAAyB,CACvE,OAAOF,EAAmBC,EAAOV,CAAI,GAAKI,EAAcJ,EAAK,KAAK,CACpE,CAEA,eAAsBY,EAAsB,EAAkB,EAAmC,CAC/F,GAAI,CAEF,OADA,MAAMF,EAAM,QAAQ,KAAKV,EAAK,IAAI,CAAC,EAC5B,EACT,MAAiB,CACf,MAAO,EACT,CACF"}
1
+ {"version":3,"file":"directoryHelpers.cjs.js","names":["ns","require_ns","DIRECTORY_SOURCE_PRIORITY","tokenizeQuery","query","matchesAnyLabel","queryWords","labelWords","labels","label","fallbackHaystack","labelWord","word","sortEntries","entries","left","right","mergeDirectoryEntry","key","directoryEntryKey","entry","existing","discoveredEntries","preferred","preferredDirectoryEntry","canonicalizeSearchableLabels","merged","bestRelationshipLabel","canonicalizeDirectorySources","normalized","directoryEntrySourcePriority","incoming","current","priorities","source","sources","uniqueStrings","preferredLabel","uniqueNamedNodes","seen","nodes","node","values","isHttpUri","value","fallbackLabel","withoutFragment","uri","fragment","base","storedLabelForNode","store","labelForNode","loadDocumentSilently"],"sources":["../../src/directory/directoryHelpers.ts"],"sourcesContent":["import type { LiveStore, NamedNode } from 'rdflib'\nimport type { DirectoryEntry, DirectoryRelationshipLabel, DirectorySource } from '../types'\nimport { ns } from '../util/ns'\n\nconst DIRECTORY_SOURCE_PRIORITY: DirectorySource[] = ['contacts', 'groups', 'friends', 'catalog']\n\nexport function tokenizeQuery (query: string): string[] {\n return query\n .toLowerCase()\n .trim()\n .split(/\\s+/)\n .filter(Boolean)\n}\n\nexport function matchesQuery (label: string, query: string): boolean {\n return matchesAnyLabel([label], query)\n}\n\nexport function matchesAnyLabel (labels: string[], query: string): boolean {\n const queryWords = tokenizeQuery(query)\n if (queryWords.length === 0) return true\n\n const labelWords = labels.flatMap(label => tokenizeQuery(label))\n const fallbackHaystack = labels.join(' ').toLowerCase()\n return queryWords.every(word =>\n labelWords.some(labelWord => labelWord.includes(word)) || fallbackHaystack.includes(word)\n )\n}\n\nexport function sortEntries (entries: Iterable<DirectoryEntry>): DirectoryEntry[] {\n return Array.from(entries)\n .sort((left, right) => left.label.localeCompare(right.label, undefined, { sensitivity: 'base' }))\n}\n\nexport function mergeDirectoryEntry (\n discoveredEntries: Map<string, DirectoryEntry>,\n entry: DirectoryEntry\n): DirectoryEntry {\n const key = directoryEntryKey(entry)\n const existing = discoveredEntries.get(key)\n if (existing) {\n const preferred = preferredDirectoryEntry(existing, entry)\n const labels = canonicalizeSearchableLabels(\n preferred.label,\n [...(existing.searchableLabels ?? [existing.label]), ...(entry.searchableLabels ?? [entry.label])]\n )\n const merged = {\n ...existing,\n label: preferred.label,\n relationshipLabel: bestRelationshipLabel(existing.relationshipLabel, entry.relationshipLabel),\n sources: canonicalizeDirectorySources([...existing.sources, ...entry.sources]),\n searchableLabels: labels\n }\n discoveredEntries.set(key, merged)\n return merged\n }\n\n const normalized = {\n ...entry,\n sources: canonicalizeDirectorySources(entry.sources),\n searchableLabels: entry.searchableLabels ?? [entry.label]\n }\n discoveredEntries.set(key, normalized)\n return normalized\n}\n\nfunction preferredDirectoryEntry (current: DirectoryEntry, incoming: DirectoryEntry): DirectoryEntry {\n return directoryEntrySourcePriority(incoming) < directoryEntrySourcePriority(current) ? incoming : current\n}\n\nfunction directoryEntrySourcePriority (entry: DirectoryEntry): number {\n const priorities = entry.sources.map(source => DIRECTORY_SOURCE_PRIORITY.indexOf(source))\n return priorities.length ? Math.min(...priorities) : DIRECTORY_SOURCE_PRIORITY.length\n}\n\nexport function canonicalizeDirectorySources (sources: DirectorySource[]): DirectorySource[] {\n return DIRECTORY_SOURCE_PRIORITY.filter(source => sources.includes(source))\n}\n\nfunction canonicalizeSearchableLabels (preferredLabel: string, labels: string[]): string[] {\n return uniqueStrings(labels).sort((left, right) => {\n if (left === preferredLabel) return -1\n if (right === preferredLabel) return 1\n return left.localeCompare(right, undefined, { sensitivity: 'base' })\n })\n}\n\nexport function bestRelationshipLabel (\n current: DirectoryRelationshipLabel | undefined,\n incoming: DirectoryRelationshipLabel\n): DirectoryRelationshipLabel {\n if (current === 'Contact' || incoming === 'Contact') return 'Contact'\n if (current === 'Friend' || incoming === 'Friend') return 'Friend'\n if (current === 'Group' || incoming === 'Group') return 'Group'\n return 'People'\n}\n\nexport function directoryEntryKey (entry: DirectoryEntry): string {\n return `${entry.kind}:${entry.uri}`\n}\n\nexport function uniqueNamedNodes (nodes: NamedNode[]): NamedNode[] {\n const seen = new Set<string>()\n return nodes.filter(node => {\n if (seen.has(node.value)) return false\n seen.add(node.value)\n return true\n })\n}\n\nexport function uniqueStrings<T extends string> (values: T[]): T[] {\n return [...new Set(values)]\n}\n\nexport function isHttpUri (value: string | null | undefined): boolean {\n return !!value && (value.startsWith('https://') || value.startsWith('http://'))\n}\n\nexport function fallbackLabel (uri: string): string {\n const withoutFragment = uri.split('#')[0]\n const fragment = uri.includes('#') ? uri.slice(uri.indexOf('#') + 1) : ''\n const base = fragment && fragment !== 'this' && fragment !== 'me'\n ? fragment\n : withoutFragment.slice(withoutFragment.lastIndexOf('/') + 1)\n return decodeURIComponent(base || uri).replace(/[_-]+/g, ' ')\n}\n\nexport function storedLabelForNode (store: LiveStore, node: NamedNode): string | null {\n return store.anyValue(node, ns.vcard('fn')) ||\n store.anyValue(node, ns.foaf('name')) ||\n store.anyValue(node, ns.schema('name')) ||\n store.anyValue(node, ns.rdfs('label')) ||\n null\n}\n\nexport function labelForNode (store: LiveStore, node: NamedNode): string {\n return storedLabelForNode(store, node) || fallbackLabel(node.value)\n}\n\nexport async function loadDocumentSilently (store: LiveStore, node: NamedNode): Promise<boolean> {\n try {\n await store.fetcher.load(node.doc())\n return true\n } catch (_error) {\n return false\n }\n}\n"],"mappings":"A,qCAIA,IAAME,EAA+C,CAAC,WAAY,SAAU,UAAW,SAAS,EAEhG,SAAgBC,EAAe,EAAyB,CACtD,OAAOC,EACJ,YAAY,CAAC,CACb,KAAK,CAAC,CACN,MAAM,KAAK,CAAC,CACZ,OAAO,OAAO,CACnB,CAMA,SAAgBC,EAAiB,EAAkB,EAAwB,CACzE,IAAMC,EAAaH,EAAcC,CAAK,EACtC,GAAIE,EAAW,SAAW,EAAG,MAAO,GAEpC,IAAMC,EAAaC,EAAO,QAAQ,GAASL,EAAcM,CAAK,CAAC,EACzDC,EAAmBF,EAAO,KAAK,GAAG,CAAC,CAAC,YAAY,EACtD,OAAOF,EAAW,MAAM,GACtBC,EAAW,KAAK,GAAaI,EAAU,SAASC,CAAI,CAAC,GAAKF,EAAiB,SAASE,CAAI,CAC1F,CACF,CAEA,SAAgBC,EAAa,EAAqD,CAChF,OAAO,MAAM,KAAKC,CAAO,CAAC,CACvB,MAAM,EAAM,IAAUC,EAAK,MAAM,cAAcC,EAAM,MAAO,IAAA,GAAW,CAAE,YAAa,MA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OAAO,MAAM,CAAC,GACtCmD,EAAM,SAASV,EAAMzC,EAAAA,GAAG,KAAK,OAAO,CAAC,GACrC,IACJ,CAEA,SAAgBoD,EAAc,EAAkB,EAAyB,CACvE,OAAOF,EAAmBC,EAAOV,CAAI,GAAKI,EAAcJ,EAAK,KAAK,CACpE,CAEA,eAAsBY,EAAsB,EAAkB,EAAmC,CAC/F,GAAI,CAEF,OADA,MAAMF,EAAM,QAAQ,KAAKV,EAAK,IAAI,CAAC,EAC5B,EACT,MAAiB,CACf,MAAO,EACT,CACF,C"}
@@ -1,5 +1,5 @@
1
1
  import { ns as e } from "../util/ns.esm.js";
2
- //#region src/directory/directoryHelpers.ts
2
+ // src/directory/directoryHelpers.ts
3
3
  var t = [
4
4
  "contacts",
5
5
  "groups",
@@ -83,7 +83,6 @@ async function v(e, t) {
83
83
  return !1;
84
84
  }
85
85
  }
86
- //#endregion
87
86
  export { u as bestRelationshipLabel, c as canonicalizeDirectorySources, d as directoryEntryKey, h as fallbackLabel, m as isHttpUri, _ as labelForNode, v as loadDocumentSilently, r as matchesAnyLabel, a as mergeDirectoryEntry, i as sortEntries, g as storedLabelForNode, n as tokenizeQuery, f as uniqueNamedNodes, p as uniqueStrings };
88
87
 
89
88
  //# sourceMappingURL=directoryHelpers.esm.js.map
@@ -1,2 +1,2 @@
1
- const e=require("./directoryHelpers.cjs.js"),t=require("./contactsDirectory.cjs.js"),n=require("./friendsDirectory.cjs.js"),r=require("./catalogDirectory.cjs.js");var i=3,a=`https://raw.githubusercontent.com/solid/catalog/refs/heads/main/catalog-data.ttl`,o=[`contacts`,`friends`,`catalog`,`groups`];function s(a,s,c){let l=t.createContactsDirectoryDiscovery(a,c),u=n.createFriendsDirectoryDiscovery(a),d=r.createCatalogDirectoryDiscovery();async function f(t){let n=new Map,r=[],i=t=>{e.mergeDirectoryEntry(n,t)};if(t.sources.includes(`catalog`)&&r.push(d.discoverCatalogEntries(t.catalogUrl,i)),t.user&&(t.sources.includes(`contacts`)&&r.push(l.discoverAddressBookContacts(t.user,i)),t.sources.includes(`groups`)&&r.push(l.discoverAddressBookGroups(t.user,i)),t.sources.includes(`friends`)&&r.push(u.discoverFoafPeople(t.user,t.maxFoafDistance,i))),!r.length)return[];if((await Promise.allSettled(r)).every(e=>e.status===`rejected`))throw Error(`Unable to load directory entries.`);return e.sortEntries(n.values())}async function p(t={}){let n=m(t);return(await f(n)).filter(t=>e.matchesAnyLabel([t.label,...t.searchableLabels??[]],n.query))}return{search:p};function m(e={}){let t=e.sources===void 0?[...o]:[...e.sources];return{query:e.query??``,sources:t,catalogUrl:e.catalogUrl??`https://raw.githubusercontent.com/solid/catalog/refs/heads/main/catalog-data.ttl`,user:e.user??s.currentUser(),maxFoafDistance:e.maxFoafDistance??i}}}exports.DEFAULT_DIRECTORY_CATALOG_URL=a,exports.DEFAULT_DIRECTORY_SOURCES=o,exports.createDirectoryLogic=s;
1
+ const e=require("./contactsDirectory.cjs.js"),t=require("./friendsDirectory.cjs.js"),n=require("./catalogDirectory.cjs.js"),r=require("./directoryHelpers.cjs.js");var i=3,a=`https://raw.githubusercontent.com/solid/catalog/refs/heads/main/catalog-data.ttl`,o=[`contacts`,`friends`,`catalog`,`groups`];function s(a,s,c){let l=e.createContactsDirectoryDiscovery(a,c),u=t.createFriendsDirectoryDiscovery(a),d=n.createCatalogDirectoryDiscovery();async function f(e){let t=new Map,n=[],i=e=>{r.mergeDirectoryEntry(t,e)};if(e.sources.includes(`catalog`)&&n.push(d.discoverCatalogEntries(e.catalogUrl,i)),e.user&&(e.sources.includes(`contacts`)&&n.push(l.discoverAddressBookContacts(e.user,i)),e.sources.includes(`groups`)&&n.push(l.discoverAddressBookGroups(e.user,i)),e.sources.includes(`friends`)&&n.push(u.discoverFoafPeople(e.user,e.maxFoafDistance,i))),!n.length)return[];if((await Promise.allSettled(n)).every(e=>e.status===`rejected`))throw Error(`Unable to load directory entries.`);return r.sortEntries(t.values())}async function p(e={}){let t=m(e);return(await f(t)).filter(e=>r.matchesAnyLabel([e.label,...e.searchableLabels??[]],t.query))}return{search:p};function m(e={}){let t=e.sources===void 0?[...o]:[...e.sources];return{query:e.query??``,sources:t,catalogUrl:e.catalogUrl??`https://raw.githubusercontent.com/solid/catalog/refs/heads/main/catalog-data.ttl`,user:e.user??s.currentUser(),maxFoafDistance:e.maxFoafDistance??i}}}exports.DEFAULT_DIRECTORY_CATALOG_URL=a,exports.DEFAULT_DIRECTORY_SOURCES=o,exports.createDirectoryLogic=s;
2
2
  //# sourceMappingURL=directoryLogic.cjs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"directoryLogic.cjs.js","names":["createContactsDirectoryDiscovery","createFriendsDirectoryDiscovery","createCatalogDirectoryDiscovery","sortEntries","matchesAnyLabel","require_directoryHelpers","require_contactsDirectory","require_friendsDirectory","require_catalogDirectory","DEFAULT_FOAF_DISTANCE","DEFAULT_DIRECTORY_CATALOG_URL","DEFAULT_DIRECTORY_SOURCES","createDirectoryLogic","contactsDiscovery","store","typeIndexLogic","friendsDiscovery","catalogDiscovery","discoverWithNormalizedOptions","discoveredEntries","discoveryTasks","mergeEntry","entry","normalized","result","search","normalizeOptions","options","sources","authn"],"sources":["../../src/directory/directoryLogic.ts"],"sourcesContent":["import { type AuthnLogic, type DirectoryEntry, type DirectoryLogic, type DirectorySearchOptions, type DirectorySource, type TypeIndexLogic } from '../types'\nimport { type LiveStore } from 'rdflib'\nimport { createContactsDirectoryDiscovery } from './contactsDirectory'\nimport { createFriendsDirectoryDiscovery } from './friendsDirectory'\nimport { createCatalogDirectoryDiscovery } from './catalogDirectory'\nimport { matchesAnyLabel, mergeDirectoryEntry, sortEntries } from './directoryHelpers'\n\nconst DEFAULT_FOAF_DISTANCE = 3\n\nexport const DEFAULT_DIRECTORY_CATALOG_URL = 'https://raw.githubusercontent.com/solid/catalog/refs/heads/main/catalog-data.ttl'\nexport const DEFAULT_DIRECTORY_SOURCES: DirectorySource[] = ['contacts', 'friends', 'catalog', 'groups']\n\nexport function createDirectoryLogic (\n store: LiveStore,\n authn: AuthnLogic,\n typeIndexLogic: TypeIndexLogic\n): DirectoryLogic {\n const contactsDiscovery = createContactsDirectoryDiscovery(store, typeIndexLogic)\n const friendsDiscovery = createFriendsDirectoryDiscovery(store)\n const catalogDiscovery = createCatalogDirectoryDiscovery()\n\n async function discoverWithNormalizedOptions (\n normalized: ReturnType<typeof normalizeOptions>\n ): Promise<DirectoryEntry[]> {\n const discoveredEntries = new Map<string, DirectoryEntry>()\n const discoveryTasks: Promise<void>[] = []\n\n const mergeEntry = (entry: DirectoryEntry): void => {\n mergeDirectoryEntry(discoveredEntries, entry)\n }\n\n if (normalized.sources.includes('catalog')) {\n discoveryTasks.push(catalogDiscovery.discoverCatalogEntries(normalized.catalogUrl, mergeEntry))\n }\n\n if (normalized.user) {\n if (normalized.sources.includes('contacts')) {\n discoveryTasks.push(contactsDiscovery.discoverAddressBookContacts(normalized.user, mergeEntry))\n }\n\n if (normalized.sources.includes('groups')) {\n discoveryTasks.push(contactsDiscovery.discoverAddressBookGroups(normalized.user, mergeEntry))\n }\n\n if (normalized.sources.includes('friends')) {\n discoveryTasks.push(friendsDiscovery.discoverFoafPeople(normalized.user, normalized.maxFoafDistance, mergeEntry))\n }\n }\n\n if (!discoveryTasks.length) {\n return []\n }\n\n const results = await Promise.allSettled(discoveryTasks)\n if (results.every(result => result.status === 'rejected')) {\n throw new Error('Unable to load directory entries.')\n }\n\n return sortEntries(discoveredEntries.values())\n }\n\n async function search (options: DirectorySearchOptions = {}): Promise<DirectoryEntry[]> {\n const normalized = normalizeOptions(options)\n const entries = await discoverWithNormalizedOptions(normalized)\n return entries.filter(entry => matchesAnyLabel([entry.label, ...(entry.searchableLabels ?? [])], normalized.query))\n }\n\n return {\n search\n }\n\n function normalizeOptions (options: DirectorySearchOptions = {}) {\n const sources = options.sources === undefined ? [...DEFAULT_DIRECTORY_SOURCES] : [...options.sources]\n return {\n query: options.query ?? '',\n sources,\n catalogUrl: options.catalogUrl ?? DEFAULT_D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AAU,EAAA,CAC/C,OAAO,GAASnB,EAAAA,gBAAgB,CAACkB,EAAM,MAAO,GAAIA,EAAM,kBAAoB,CAAC,CAAE,EAAGC,EAAW,KAAK,CAAC,CACpH,CAEA,MAAO,CACL,QACF,EAEA,SAASG,EAAkB,EAAkC,CAAC,EAAG,CAC/D,IAAME,EAAUD,EAAQ,UAAY,IAAA,GAAY,CAAC,GAAGhB,CAAyB,EAAI,CAAC,GAAGgB,EAAQ,OAAO,EACpG,MAAO,CACL,MAAOA,EAAQ,OAAS,GACxB,UACA,WAAYA,EAAQ,YAAA,mFACpB,KAAMA,EAAQ,MAAQE,EAAM,YAAY,EACxC,gBAAiBF,EAAQ,iBAAmBlB,CAC9C,CACF,CACF"}
1
+ {"version":3,"file":"directoryLogic.cjs.js","names":["createContactsDirectoryDiscovery","createFriendsDirectoryDiscovery","createCatalogDirectoryDiscovery","sortEntries","matchesAnyLabel","require_contactsDirectory","require_friendsDirectory","require_catalogDirectory","require_directoryHelpers","DEFAULT_FOAF_DISTANCE","DEFAULT_DIRECTORY_CATALOG_URL","DEFAULT_DIRECTORY_SOURCES","createDirectoryLogic","contactsDiscovery","store","typeIndexLogic","friendsDiscovery","catalogDiscovery","discoverWithNormalizedOptions","discoveredEntries","discoveryTasks","mergeEntry","entry","normalized","result","search","normalizeOptions","options","sources","authn"],"sources":["../../src/directory/directoryLogic.ts"],"sourcesContent":["import { type AuthnLogic, type DirectoryEntry, type DirectoryLogic, type DirectorySearchOptions, type DirectorySource, type TypeIndexLogic } from '../types'\nimport { type LiveStore } from 'rdflib'\nimport { createContactsDirectoryDiscovery } from './contactsDirectory'\nimport { createFriendsDirectoryDiscovery } from './friendsDirectory'\nimport { createCatalogDirectoryDiscovery } from './catalogDirectory'\nimport { matchesAnyLabel, mergeDirectoryEntry, sortEntries } from './directoryHelpers'\n\nconst DEFAULT_FOAF_DISTANCE = 3\n\nexport const DEFAULT_DIRECTORY_CATALOG_URL = 'https://raw.githubusercontent.com/solid/catalog/refs/heads/main/catalog-data.ttl'\nexport const DEFAULT_DIRECTORY_SOURCES: DirectorySource[] = ['contacts', 'friends', 'catalog', 'groups']\n\nexport function createDirectoryLogic (\n store: LiveStore,\n authn: AuthnLogic,\n typeIndexLogic: TypeIndexLogic\n): DirectoryLogic {\n const contactsDiscovery = createContactsDirectoryDiscovery(store, typeIndexLogic)\n const friendsDiscovery = createFriendsDirectoryDiscovery(store)\n const catalogDiscovery = createCatalogDirectoryDiscovery()\n\n async function discoverWithNormalizedOptions (\n normalized: ReturnType<typeof normalizeOptions>\n ): Promise<DirectoryEntry[]> {\n const discoveredEntries = new Map<string, DirectoryEntry>()\n const discoveryTasks: Promise<void>[] = []\n\n const mergeEntry = (entry: DirectoryEntry): void => {\n mergeDirectoryEntry(discoveredEntries, entry)\n }\n\n if (normalized.sources.includes('catalog')) {\n discoveryTasks.push(catalogDiscovery.discoverCatalogEntries(normalized.catalogUrl, mergeEntry))\n }\n\n if (normalized.user) {\n if (normalized.sources.includes('contacts')) {\n discoveryTasks.push(contactsDiscovery.discoverAddressBookContacts(normalized.user, mergeEntry))\n }\n\n if (normalized.sources.includes('groups')) {\n discoveryTasks.push(contactsDiscovery.discoverAddressBookGroups(normalized.user, mergeEntry))\n }\n\n if (normalized.sources.includes('friends')) {\n discoveryTasks.push(friendsDiscovery.discoverFoafPeople(normalized.user, normalized.maxFoafDistance, mergeEntry))\n }\n }\n\n if (!discoveryTasks.length) {\n return []\n }\n\n const results = await Promise.allSettled(discoveryTasks)\n if (results.every(result => result.status === 'rejected')) {\n throw new Error('Unable to load directory entries.')\n }\n\n return sortEntries(discoveredEntries.values())\n }\n\n async function search (options: DirectorySearchOptions = {}): Promise<DirectoryEntry[]> {\n const normalized = normalizeOptions(options)\n const entries = await discoverWithNormalizedOptions(normalized)\n return entries.filter(entry => matchesAnyLabel([entry.label, ...(entry.searchableLabels ?? [])], normalized.query))\n }\n\n return {\n search\n }\n\n function normalizeOptions (options: DirectorySearchOptions = {}) {\n const sources = options.sources === undefined ? [...DEFAULT_DIRECTORY_SOURCES] : [...options.sources]\n return {\n query: options.query ?? '',\n sources,\n catalogUrl: options.catalogUrl ?? DEFAULT_DIRECTORY_CATALOG_URL,\n user: options.user ?? authn.currentUser(),\n maxFoafDistance: options.maxFoafDistance ?? DEFAULT_FOAF_DISTANCE\n }\n }\n}\n"],"mappings":"A,mKAOA,IAAMS,EAAwB,EAEjBC,EAAgC,mFAChCC,EAA+C,CAAC,WAAY,UAAW,UAAW,QAAQ,EAEvG,SAAgBC,EACd,EACA,EACA,EACgB,CAChB,IAAMC,EAAoBb,EAAAA,iCAAiCc,EAAOC,CAAc,EAC1EC,EAAmBf,EAAAA,gCAAgCa,CAAK,EACxDG,EAAmBf,EAAAA,gCAAgC,EAEzD,eAAegB,EACb,EAC2B,CAC3B,IAAMC,EAAoB,IAAI,IACxBC,EAAkC,CAAC,EAEnCC,EAAc,GAAgC,CAClDb,EAAA,oBAAoBW,EAAmBG,CAAK,CAC9C,EAoBA,GAlBIC,EAAW,QAAQ,SAAS,SAAS,GACvCH,EAAe,KAAKH,EAAiB,uBAAuBM,EAAW,WAAYF,CAAU,CAAC,EAG5FE,EAAW,OACTA,EAAW,QAAQ,SAAS,UAAU,GACxCH,EAAe,KAAKP,EAAkB,4BAA4BU,EAAW,KAAMF,CAAU,CAAC,EAG5FE,EAAW,QAAQ,SAAS,QAAQ,GACtCH,EAAe,KAAKP,EAAkB,0BAA0BU,EAAW,KAAMF,CAAU,CAAC,EAG1FE,EAAW,QAAQ,SAAS,SAAS,GACvCH,EAAe,KAAKJ,EAAiB,mBAAmBO,EAAW,KAAMA,EAAW,gBAAiBF,CAAU,CAAC,GAIhH,CAACD,EAAe,OAClB,MAAO,CAAC,EAIV,IAAI,MADkB,QAAQ,WAAWA,CAAc,EAAA,CAC3C,MAAM,GAAUI,EAAO,SAAW,UAAU,EACtD,MAAU,MAAM,mCAAmC,EAGrD,OAAOrB,EAAAA,YAAYgB,EAAkB,OAAO,CAAC,CAC/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