solid-logic 5.0.0 → 6.0.0-0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (183) hide show
  1. package/README.md +3 -4
  2. package/dist/_virtual/_rolldown/runtime.cjs.js +1 -0
  3. package/dist/acl/aclLogic.cjs.js +2 -0
  4. package/dist/acl/aclLogic.cjs.js.map +1 -0
  5. package/dist/acl/aclLogic.esm.js +56 -0
  6. package/dist/acl/aclLogic.esm.js.map +1 -0
  7. package/dist/authSession/authSession.cjs.js +2 -0
  8. package/dist/authSession/authSession.cjs.js.map +1 -0
  9. package/dist/authSession/authSession.esm.js +22 -0
  10. package/dist/authSession/authSession.esm.js.map +1 -0
  11. package/dist/authSession/events.cjs.js +2 -0
  12. package/dist/authSession/events.cjs.js.map +1 -0
  13. package/dist/authSession/events.esm.js +19 -0
  14. package/dist/authSession/events.esm.js.map +1 -0
  15. package/dist/authSession/issuer.cjs.js +2 -0
  16. package/dist/authSession/issuer.cjs.js.map +1 -0
  17. package/dist/authSession/issuer.esm.js +18 -0
  18. package/dist/authSession/issuer.esm.js.map +1 -0
  19. package/dist/authSession/session.cjs.js +2 -0
  20. package/dist/authSession/session.cjs.js.map +1 -0
  21. package/dist/authSession/session.esm.js +102 -0
  22. package/dist/authSession/session.esm.js.map +1 -0
  23. package/dist/authn/SolidAuthnLogic.cjs.js +2 -0
  24. package/dist/authn/SolidAuthnLogic.cjs.js.map +1 -0
  25. package/dist/authn/SolidAuthnLogic.esm.js +116 -0
  26. package/dist/authn/SolidAuthnLogic.esm.js.map +1 -0
  27. package/dist/authn/authUtil.cjs.js +2 -0
  28. package/dist/authn/authUtil.cjs.js.map +1 -0
  29. package/dist/authn/authUtil.esm.js +33 -0
  30. package/dist/authn/authUtil.esm.js.map +1 -0
  31. package/dist/authn/serverLogout.cjs.js +2 -0
  32. package/dist/authn/serverLogout.cjs.js.map +1 -0
  33. package/dist/authn/serverLogout.esm.js +25 -0
  34. package/dist/authn/serverLogout.esm.js.map +1 -0
  35. package/dist/chat/chatLogic.cjs.js +21 -0
  36. package/dist/chat/chatLogic.cjs.js.map +1 -0
  37. package/dist/chat/chatLogic.esm.js +116 -0
  38. package/dist/chat/chatLogic.esm.js.map +1 -0
  39. package/dist/inbox/inboxLogic.cjs.js +2 -0
  40. package/dist/inbox/inboxLogic.cjs.js.map +1 -0
  41. package/dist/inbox/inboxLogic.esm.js +37 -0
  42. package/dist/inbox/inboxLogic.esm.js.map +1 -0
  43. package/dist/index.cjs.js +2 -0
  44. package/dist/index.cjs.js.map +1 -0
  45. package/dist/index.esm.js +13 -0
  46. package/dist/index.esm.js.map +1 -0
  47. package/dist/issuer/issuerLogic.cjs.js +2 -0
  48. package/dist/issuer/issuerLogic.cjs.js.map +1 -0
  49. package/dist/issuer/issuerLogic.esm.js +30 -0
  50. package/dist/issuer/issuerLogic.esm.js.map +1 -0
  51. package/dist/logic/CustomError.cjs.js +2 -0
  52. package/dist/logic/CustomError.cjs.js.map +1 -0
  53. package/dist/logic/CustomError.esm.js +14 -0
  54. package/dist/logic/CustomError.esm.js.map +1 -0
  55. package/dist/logic/solidLogic.cjs.js +2 -0
  56. package/dist/logic/solidLogic.cjs.js.map +1 -0
  57. package/dist/logic/solidLogic.esm.js +49 -0
  58. package/dist/logic/solidLogic.esm.js.map +1 -0
  59. package/dist/logic/solidLogicSingleton.cjs.js +2 -0
  60. package/dist/logic/solidLogicSingleton.cjs.js.map +1 -0
  61. package/dist/logic/solidLogicSingleton.esm.js +19 -0
  62. package/dist/logic/solidLogicSingleton.esm.js.map +1 -0
  63. package/dist/profile/profileAclDocuments.cjs.js +3 -0
  64. package/dist/profile/profileAclDocuments.cjs.js.map +1 -0
  65. package/dist/profile/profileAclDocuments.esm.js +17 -0
  66. package/dist/profile/profileAclDocuments.esm.js.map +1 -0
  67. package/dist/profile/profileDocuments.cjs.js +3 -0
  68. package/dist/profile/profileDocuments.cjs.js.map +1 -0
  69. package/dist/profile/profileDocuments.esm.js +15 -0
  70. package/dist/profile/profileDocuments.esm.js.map +1 -0
  71. package/dist/profile/profileLogic.cjs.js +2 -0
  72. package/dist/profile/profileLogic.cjs.js.map +1 -0
  73. package/dist/profile/profileLogic.esm.js +184 -0
  74. package/dist/profile/profileLogic.esm.js.map +1 -0
  75. package/dist/resource/resourceHttp.cjs.js +2 -0
  76. package/dist/resource/resourceHttp.cjs.js.map +1 -0
  77. package/dist/resource/resourceHttp.esm.js +21 -0
  78. package/dist/resource/resourceHttp.esm.js.map +1 -0
  79. package/dist/resource/resourceLogic.cjs.js +2 -0
  80. package/dist/resource/resourceLogic.cjs.js.map +1 -0
  81. package/dist/resource/resourceLogic.esm.js +130 -0
  82. package/dist/resource/resourceLogic.esm.js.map +1 -0
  83. package/dist/resource/resourceMetadata.cjs.js +2 -0
  84. package/dist/resource/resourceMetadata.cjs.js.map +1 -0
  85. package/dist/resource/resourceMetadata.esm.js +28 -0
  86. package/dist/resource/resourceMetadata.esm.js.map +1 -0
  87. package/dist/typeIndex/typeIndexAclDocuments.cjs.js +3 -0
  88. package/dist/typeIndex/typeIndexAclDocuments.cjs.js.map +1 -0
  89. package/dist/typeIndex/typeIndexAclDocuments.esm.js +35 -0
  90. package/dist/typeIndex/typeIndexAclDocuments.esm.js.map +1 -0
  91. package/dist/typeIndex/typeIndexDocuments.cjs.js +4 -0
  92. package/dist/typeIndex/typeIndexDocuments.cjs.js.map +1 -0
  93. package/dist/typeIndex/typeIndexDocuments.esm.js +21 -0
  94. package/dist/typeIndex/typeIndexDocuments.esm.js.map +1 -0
  95. package/dist/typeIndex/typeIndexLogic.cjs.js +2 -0
  96. package/dist/typeIndex/typeIndexLogic.cjs.js.map +1 -0
  97. package/dist/typeIndex/typeIndexLogic.esm.js +210 -0
  98. package/dist/typeIndex/typeIndexLogic.esm.js.map +1 -0
  99. package/dist/util/containerLogic.cjs.js +2 -0
  100. package/dist/util/containerLogic.cjs.js.map +1 -0
  101. package/dist/util/containerLogic.esm.js +42 -0
  102. package/dist/util/containerLogic.esm.js.map +1 -0
  103. package/dist/util/debug.cjs.js +2 -0
  104. package/dist/util/debug.cjs.js.map +1 -0
  105. package/dist/util/debug.esm.js +11 -0
  106. package/dist/util/debug.esm.js.map +1 -0
  107. package/dist/util/ns.cjs.js +2 -0
  108. package/dist/util/ns.cjs.js.map +1 -0
  109. package/dist/util/ns.esm.js +8 -0
  110. package/dist/util/ns.esm.js.map +1 -0
  111. package/dist/util/utilityLogic.cjs.js +6 -0
  112. package/dist/util/utilityLogic.cjs.js.map +1 -0
  113. package/dist/util/utilityLogic.esm.js +135 -0
  114. package/dist/util/utilityLogic.esm.js.map +1 -0
  115. package/dist/util/utils.cjs.js +2 -0
  116. package/dist/util/utils.cjs.js.map +1 -0
  117. package/dist/util/utils.esm.js +22 -0
  118. package/dist/util/utils.esm.js.map +1 -0
  119. package/package.json +27 -33
  120. package/dist/2729812e0bfc062ee77a.js +0 -1
  121. package/dist/a9c30b64ceaae48b72f0.js +0 -2045
  122. package/dist/acl/aclLogic.d.ts +0 -5
  123. package/dist/acl/aclLogic.d.ts.map +0 -1
  124. package/dist/authSession/authSession.d.ts +0 -42
  125. package/dist/authSession/authSession.d.ts.map +0 -1
  126. package/dist/authSession/events.d.ts +0 -24
  127. package/dist/authSession/events.d.ts.map +0 -1
  128. package/dist/authSession/issuer.d.ts +0 -8
  129. package/dist/authSession/issuer.d.ts.map +0 -1
  130. package/dist/authSession/session.d.ts +0 -45
  131. package/dist/authSession/session.d.ts.map +0 -1
  132. package/dist/authn/SolidAuthnLogic.d.ts +0 -42
  133. package/dist/authn/SolidAuthnLogic.d.ts.map +0 -1
  134. package/dist/authn/authUtil.d.ts +0 -17
  135. package/dist/authn/authUtil.d.ts.map +0 -1
  136. package/dist/authn/serverLogout.d.ts +0 -6
  137. package/dist/authn/serverLogout.d.ts.map +0 -1
  138. package/dist/chat/chatLogic.d.ts +0 -3
  139. package/dist/chat/chatLogic.d.ts.map +0 -1
  140. package/dist/inbox/inboxLogic.d.ts +0 -3
  141. package/dist/inbox/inboxLogic.d.ts.map +0 -1
  142. package/dist/index.d.ts +0 -14
  143. package/dist/index.d.ts.map +0 -1
  144. package/dist/issuer/issuerLogic.d.ts +0 -8
  145. package/dist/issuer/issuerLogic.d.ts.map +0 -1
  146. package/dist/logic/CustomError.d.ts +0 -21
  147. package/dist/logic/CustomError.d.ts.map +0 -1
  148. package/dist/logic/solidLogic.d.ts +0 -6
  149. package/dist/logic/solidLogic.d.ts.map +0 -1
  150. package/dist/logic/solidLogicSingleton.d.ts +0 -4
  151. package/dist/logic/solidLogicSingleton.d.ts.map +0 -1
  152. package/dist/profile/profileAclDocuments.d.ts +0 -2
  153. package/dist/profile/profileAclDocuments.d.ts.map +0 -1
  154. package/dist/profile/profileDocuments.d.ts +0 -2
  155. package/dist/profile/profileDocuments.d.ts.map +0 -1
  156. package/dist/profile/profileLogic.d.ts +0 -3
  157. package/dist/profile/profileLogic.d.ts.map +0 -1
  158. package/dist/solid-logic.esm.js +0 -2358
  159. package/dist/solid-logic.esm.js.map +0 -1
  160. package/dist/solid-logic.esm.min.js +0 -2
  161. package/dist/solid-logic.esm.min.js.map +0 -1
  162. package/dist/solid-logic.js +0 -7548
  163. package/dist/solid-logic.js.map +0 -1
  164. package/dist/solid-logic.min.js +0 -2
  165. package/dist/solid-logic.min.js.map +0 -1
  166. package/dist/typeIndex/typeIndexAclDocuments.d.ts +0 -2
  167. package/dist/typeIndex/typeIndexAclDocuments.d.ts.map +0 -1
  168. package/dist/typeIndex/typeIndexDocuments.d.ts +0 -3
  169. package/dist/typeIndex/typeIndexDocuments.d.ts.map +0 -1
  170. package/dist/typeIndex/typeIndexLogic.d.ts +0 -3
  171. package/dist/typeIndex/typeIndexLogic.d.ts.map +0 -1
  172. package/dist/types.d.ts +0 -113
  173. package/dist/types.d.ts.map +0 -1
  174. package/dist/util/containerLogic.d.ts +0 -11
  175. package/dist/util/containerLogic.d.ts.map +0 -1
  176. package/dist/util/debug.d.ts +0 -5
  177. package/dist/util/debug.d.ts.map +0 -1
  178. package/dist/util/ns.d.ts +0 -2
  179. package/dist/util/ns.d.ts.map +0 -1
  180. package/dist/util/utilityLogic.d.ts +0 -17
  181. package/dist/util/utilityLogic.d.ts.map +0 -1
  182. package/dist/util/utils.d.ts +0 -8
  183. package/dist/util/utils.d.ts.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SolidAuthnLogic.esm.js","names":[],"sources":["../../src/authn/SolidAuthnLogic.ts"],"sourcesContent":["import { namedNode, NamedNode, sym } from 'rdflib'\nimport { appContext, offlineTestID } from './authUtil'\nimport * as debug from '../util/debug'\nimport type { SessionWithLegacyEvents } from '../authSession/authSession'\nimport type { AuthenticationContext, AuthnLogic } from '../types'\n\n// Some auth clients (uvdsl worker-backed session) only settle restore() on\n// a worker message; a missing/unreachable RefreshWorker asset makes it hang\n// forever. This caps the wait so the login UI can never spin indefinitely.\nconst SESSION_RESTORE_TIMEOUT_MS = 5000\n\n/**\n * Await a session restore promise, but give up after\n * SESSION_RESTORE_TIMEOUT_MS and resolve with undefined so callers can\n * treat a stalled restore as \"no previous session\".\n */\nasync function withRestoreTimeout<T> (promise: Promise<T> | null): Promise<T | undefined> {\n if (promise === null) return undefined\n let timer: ReturnType<typeof setTimeout> | undefined\n const timeout = new Promise<undefined>(resolve => {\n timer = setTimeout(() => resolve(undefined), SESSION_RESTORE_TIMEOUT_MS)\n })\n try {\n return await Promise.race([promise, timeout])\n } finally {\n if (timer !== undefined) clearTimeout(timer)\n }\n}\n\nexport class SolidAuthnLogic implements AuthnLogic {\n private session: SessionWithLegacyEvents\n private checkUserInFlight: Promise<NamedNode | null> | null = null\n private sessionRestoreHookAttached = false\n private fallbackWebId: string | null = null\n\n constructor(solidAuthSession: SessionWithLegacyEvents) {\n this.session = solidAuthSession\n }\n\n // we created authSession getter because we want to access it as authn.authSession externally\n get authSession(): SessionWithLegacyEvents { return this.session }\n\n currentUser(): NamedNode | null {\n const app = appContext()\n if (app.viewingNoAuthPage) {\n return sym(app.webId)\n }\n const sessionAny = this.session as any\n const infoWebId = sessionAny?.info?.webId\n const sessionWebId = sessionAny?.webId\n const webId = infoWebId || sessionWebId || this.fallbackWebId\n const infoLoggedIn = sessionAny?.info?.isLoggedIn\n const sessionActive = sessionAny?.isActive\n const isLoggedIn = infoLoggedIn === true || sessionActive === true ||\n ((infoLoggedIn == null && sessionActive == null) ? Boolean(webId) : false) ||\n Boolean(this.fallbackWebId)\n if (this && this.session && webId && isLoggedIn) {\n return sym(webId)\n }\n return offlineTestID() // null unless testing\n }\n\n /**\n * Retrieves currently logged in webId from either\n * defaultTestUser or SolidAuth\n * Also activates a session after login\n * @param [setUserCallback] Optional callback\n * @returns Resolves with webId uri, if no callback provided\n */\n async checkUser<T> (\n setUserCallback?: (me: NamedNode | null) => T\n ): Promise<NamedNode | T | null> {\n // Save hash for \"restorePreviousSession\"\n const preLoginRedirectHash = new URL(window.location.href).hash\n if (preLoginRedirectHash) {\n window.localStorage.setItem('preLoginRedirectHash', preLoginRedirectHash)\n }\n const sessionAny = this.session as any\n if (!this.sessionRestoreHookAttached && typeof sessionAny?.events?.on === 'function') {\n // Backward-compatible hook for auth clients exposing an EventEmitter-style API.\n sessionAny.events.on('sessionRestore', (url: string) => {\n debug.log(`Session restored to ${url}`)\n if (document.location.toString() !== url) history.replaceState(null, '', url)\n })\n this.sessionRestoreHookAttached = true\n }\n\n if (!this.checkUserInFlight) {\n this.checkUserInFlight = this.resolveCurrentUser()\n }\n\n const inFlight = this.checkUserInFlight\n let me: NamedNode | null\n try {\n me = await inFlight\n } finally {\n if (this.checkUserInFlight === inFlight) {\n this.checkUserInFlight = null\n }\n }\n\n return Promise.resolve(setUserCallback ? setUserCallback(me) : me)\n }\n\n private async resolveCurrentUser (): Promise<NamedNode | null> {\n const sessionAny = this.session as any\n\n /**\n * Handle a successful authentication redirect\n */\n const redirectUrl = new URL(window.location.href)\n redirectUrl.hash = ''\n if (typeof sessionAny?.handleIncomingRedirect === 'function') {\n await sessionAny.handleIncomingRedirect({\n restorePreviousSession: true,\n url: redirectUrl.href\n })\n } else {\n // uvdsl-style session (no handleIncomingRedirect): restore then handle redirect.\n //\n // The worker-backed session (WebWorkerSession) resolves restore() ONLY\n // when the SharedWorker posts a message back. If the worker asset can't\n // be fetched — local/dev servers that don't serve the RefreshWorker\n // chunk at the resolved URL, wrong MIME type, CSP, or a worker that\n // fails before `onconnect` — the promise never settles and the login\n // UI would spin forever. Race it against a timeout and treat a stall\n // as \"no previous session\" so the page can render the login button.\n const wasActive = sessionAny?.isActive ?? Boolean(sessionAny?.webId)\n if (typeof sessionAny?.restore === 'function') {\n try {\n await withRestoreTimeout(sessionAny.restore())\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error)\n // A failed restore on an inactive session just means \"no usable\n // session to restore\" — whether that's \"No session to restore.\",\n // a stale refresh token / dead client_id returning HTTP 400, or a\n // missing session database. Never let it block the login UI: log\n // and continue as logged-out so the page renders the login button.\n // Only re-throw when the session actually became active, which is\n // an unexpected refresh failure worth surfacing.\n const isNowActive = sessionAny?.isActive ?? Boolean(sessionAny?.webId)\n if (isNowActive && !/no session to restore/i.test(message)) {\n throw error\n }\n debug.log(`Session restore failed, continuing logged-out: ${message}`)\n }\n const isNowActive = sessionAny?.isActive ?? Boolean(sessionAny?.webId)\n if (!wasActive && isNowActive) {\n sessionAny.events?.emit('sessionRestore', window.location.href)\n }\n }\n if (typeof sessionAny?.handleRedirectFromLogin === 'function') {\n const wasActive = sessionAny?.isActive ?? Boolean(sessionAny?.webId)\n await sessionAny.handleRedirectFromLogin()\n const isNowActive = sessionAny?.isActive ?? Boolean(sessionAny?.webId)\n if (!wasActive && isNowActive) {\n sessionAny.events?.emit('login')\n }\n }\n }\n\n // Check to see if a hash was stored in local storage\n const postLoginRedirectHash = window.localStorage.getItem('preLoginRedirectHash')\n if (postLoginRedirectHash) {\n const curUrl = new URL(window.location.href)\n if (curUrl.hash !== postLoginRedirectHash) {\n if (history.pushState) {\n // debug.log('Setting window.location.has using pushState')\n history.pushState(null, document.title, postLoginRedirectHash)\n } else {\n // debug.warn('Setting window.location.has using location.hash')\n location.hash = postLoginRedirectHash\n }\n curUrl.hash = postLoginRedirectHash\n }\n // See https://stackoverflow.com/questions/3870057/how-can-i-update-window-location-hash-without-jumping-the-document\n // window.location.href = curUrl.toString()// @@ See https://developer.mozilla.org/en-US/docs/Web/API/Window/location\n window.localStorage.setItem('preLoginRedirectHash', '')\n }\n\n // Check to see if already logged in / have the WebID\n let me = offlineTestID()\n if (me) {\n return me\n }\n\n let webId = this.webIdFromSession(sessionAny?.info, sessionAny)\n if (!webId) {\n // NSS-specific fallback: recover WebID from NSS cookie session when client restore is empty.\n webId = await this.probeNssCookieBackedWebId()\n }\n\n if (webId) {\n this.fallbackWebId = webId\n } else {\n this.fallbackWebId = null\n }\n\n if (webId) {\n me = this.saveUser(webId)\n }\n\n if (me) {\n debug.log(`(Logged in as ${me} by authentication)`)\n }\n\n return me\n }\n\n private async probeNssCookieBackedWebId (): Promise<string | null> {\n if (typeof window === 'undefined') {\n return null\n }\n\n const { hostname, port, protocol } = window.location\n const localhostSuffix = '.localhost'\n // NSS local pods use subdomains like alice.localhost.\n if (!hostname.endsWith(localhostSuffix)) {\n return null\n }\n\n const podName = hostname.slice(0, -localhostSuffix.length)\n if (!podName || podName === 'localhost' || podName.includes('.')) {\n return null\n }\n\n try {\n // NSS returns 403 on this account page when the cookie session is valid.\n const probeResponse = await fetch('/account/password/change', {\n credentials: 'include',\n redirect: 'manual',\n cache: 'no-store'\n })\n if (probeResponse.status !== 403) {\n return null\n }\n const origin = `${protocol}//${hostname}${port ? `:${port}` : ''}`\n return `${origin}/profile/card#me`\n } catch (_error) {\n return null\n }\n }\n\n /**\n * Saves `webId` in `context.me`\n * @param webId\n * @param context\n *\n * @returns Returns the WebID, after setting it\n */\n saveUser (\n webId: NamedNode | string | null,\n context?: AuthenticationContext\n ): NamedNode | null {\n let webIdUri: string\n if (webId) {\n webIdUri = (typeof webId === 'string') ? webId : webId.uri\n const me = namedNode(webIdUri)\n if (context) {\n context.me = me\n }\n return me\n }\n return null\n }\n\n /**\n * @returns {Promise<string|null>} Resolves with WebID URI or null\n */\n webIdFromSession (\n sessionInfo?: { webId?: string, isLoggedIn?: boolean },\n sessionRoot?: { webId?: string, isLoggedIn?: boolean, isActive?: boolean }\n ): string | null {\n const webId = sessionInfo?.webId || sessionRoot?.webId\n if (!webId) {\n return null\n }\n const infoLoggedIn = sessionInfo?.isLoggedIn\n const rootLoggedIn = sessionRoot?.isLoggedIn\n const rootActive = sessionRoot?.isActive\n if (infoLoggedIn === true || rootLoggedIn === true || rootActive === true) {\n return webId\n }\n if (infoLoggedIn === false && rootLoggedIn === false && rootActive === false) {\n return null\n }\n return webId\n }\n\n}\n"],"mappings":";;;;AASA,IAAM,IAA6B;AAOnC,eAAe,EAAuB,GAAoD;CACxF,IAAI,MAAY,MAAM;CACtB,IAAI,GACE,IAAU,IAAI,SAAmB,MAAW;EAChD,IAAQ,iBAAiB,EAAQ,KAAA,CAAS,GAAG,CAA0B;CACzE,CAAC;CACD,IAAI;EACF,OAAO,MAAM,QAAQ,KAAK,CAAC,GAAS,CAAO,CAAC;CAC9C,UAAU;EACR,AAAI,MAAU,KAAA,KAAW,aAAa,CAAK;CAC7C;AACF;AAEA,IAAa,IAAb,MAAmD;CAMjD,YAAY,GAA2C;EACrD,yBAL4D,wCACzB,yBACE,MAGrC,KAAK,UAAU;CACjB;CAGA,IAAI,cAAuC;EAAE,OAAO,KAAK;CAAQ;CAEjE,cAAgC;EAC9B,IAAM,IAAM,EAAW;EACvB,IAAI,EAAI,mBACN,OAAO,EAAI,EAAI,KAAK;EAEtB,IAAM,IAAa,KAAK,SAClB,IAAY,GAAY,MAAM,OAC9B,IAAe,GAAY,OAC3B,IAAQ,KAAa,KAAgB,KAAK,eAC1C,IAAe,GAAY,MAAM,YACjC,IAAgB,GAAY,UAC5B,IAAa,MAAiB,MAAQ,MAAkB,OAC1D,KAA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AGT,IAAI;GAWF,QAJI,MALwB,MAAM,4BAA4B;IAC5D,aAAa;IACb,UAAU;IACV,OAAO;GACT,CAAC,EAAA,CACiB,WAAW,MAItB,GAAG,GADQ,EAAS,IAAI,IAAW,IAAO,IAAI,MAAS,KAC7C,oBAHR;EAIX,QAAiB;GACf,OAAO;EACT;CACF;CASA,SACE,GACA,GACkB;EAClB,IAAI;EACJ,IAAI,GAAO;GACT,IAAY,OAAO,KAAU,WAAY,IAAQ,EAAM;GACvD,IAAM,IAAK,EAAU,CAAQ;GAI7B,OAHI,MACF,EAAQ,KAAK,IAER;EACT;EACA,OAAO;CACT;CAKA,iBACE,GACA,GACe;EACf,IAAM,IAAQ,GAAa,SAAS,GAAa;EACjD,IAAI,CAAC,GACH,OAAO;EAET,IAAM,IAAe,GAAa,YAC5B,IAAe,GAAa,YAC5B,IAAa,GAAa;EAOhC,OANI,MAAiB,MAAQ,MAAiB,MAAQ,MAAe,KAC5D,IAEL,MAAiB,MAAS,MAAiB,MAAS,MAAe,KAC9D,OAEF;CACT;AAEF"}
@@ -0,0 +1,2 @@
1
+ const e=require("../util/debug.cjs.js");let t=require("rdflib");var n=()=>{let{SolidAppContext:e}=window;if(e||={},e.viewingNoAuthPage=!1,e.noAuth&&window.document&&window.document.location.href.startsWith(e.noAuth)){e.viewingNoAuthPage=!0;let t=new URLSearchParams(window.document.location.search);if(t){let n=e.viewedPage=t.get(`uri`)||null;if(n&&(n=decodeURI(n),!n.startsWith(e.noAuth))){let t=n.split(/\//);e.idp=t[0]+`//`+t[2],e.viewingNoAuthPage=!1}}}return e};function r(){let{$SolidTestEnvironment:n}=window;if(n!==void 0&&n.username)return e.log(`Assuming the user is `+n.username),(0,t.sym)(n.username);if(typeof document<`u`&&document.location&&(``+document.location).slice(0,16)===`http://localhost`){let n=document.getElementById(`appTarget`);if(!n)return null;let r=n.getAttribute(`testID`);return r?(e.log(`Assuming user is `+r),(0,t.sym)(r)):null}return null}exports.appContext=n,exports.offlineTestID=r;
2
+ //# sourceMappingURL=authUtil.cjs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"authUtil.cjs.js","names":[],"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,IAAa,MAAuB,CAChC,GAAI,CAAE,mBAAyB,OAG/B,GAFA,IAAoB,CAAC,EACrB,EAAgB,kBAAoB,GAChC,EAAgB,QAAU,OAAO,UACb,OAAO,SAAS,SAAS,KAC7B,WAAW,EAAgB,MAAM,EAAG,CACpD,EAAgB,kBAAoB,GACpC,IAAM,EAAS,IAAI,gBAAgB,OAAO,SAAS,SAAS,MAAM,EAClE,GAAI,EAAQ,CACR,IAAI,EAAa,EAAgB,WAAa,EAAO,IAAI,KAAK,GAAK,KACnE,GAAI,IACJ,EAAa,UAAU,CAAU,EAC7B,CAAC,EAAW,WAAW,EAAgB,MAAM,GAAG,CAChD,IAAM,EAAM,EAAW,MAAM,IAAI,EACjC,EAAgB,IAAM,EAAI,GAAK,KAAO,EAAI,GAC1C,EAAgB,kBAAoB,EACxC,CAEJ,CACA,CAEJ,OAAO,CACX,EASA,SAAgB,GAAmC,CAC/C,GAAM,CAAE,yBAA+B,OACvC,GACS,IAA0B,QACjC,EAAsB,SAItB,OADA,EAAA,IAAU,wBAA0B,EAAsB,QAAQ,GAClE,EAAA,EAAA,IAAA,CAAW,EAAsB,QAAQ,EAI3C,GACE,OAAO,SAAa,KACpB,SAAS,WACR,GAAK,SAAS,SAAA,CAAU,MAAM,EAAG,EAAE,IAAM,mBAC1C,CACA,IAAM,EAAM,SAAS,eAAe,WAAW,EAC/C,GAAI,CAAC,EAAK,OAAO,KACjB,IAAM,EAAK,EAAI,aAAa,QAAQ,EAGpC,OAFK,GACL,EAAA,IAAU,oBAAsB,CAAE,GAClC,EAAA,EAAA,IAAA,CAAW,CAAE,GAFG,IAGlB,CACA,OAAO,IACX"}
@@ -0,0 +1,33 @@
1
+ import { log as e } from "../util/debug.esm.js";
2
+ import { sym as t } from "rdflib";
3
+ //#region src/authn/authUtil.ts
4
+ var n = () => {
5
+ let { SolidAppContext: e } = window;
6
+ if (e ||= {}, e.viewingNoAuthPage = !1, e.noAuth && window.document && window.document.location.href.startsWith(e.noAuth)) {
7
+ e.viewingNoAuthPage = !0;
8
+ let t = new URLSearchParams(window.document.location.search);
9
+ if (t) {
10
+ let n = e.viewedPage = t.get("uri") || null;
11
+ if (n && (n = decodeURI(n), !n.startsWith(e.noAuth))) {
12
+ let t = n.split(/\//);
13
+ e.idp = t[0] + "//" + t[2], e.viewingNoAuthPage = !1;
14
+ }
15
+ }
16
+ }
17
+ return e;
18
+ };
19
+ function r() {
20
+ let { $SolidTestEnvironment: n } = window;
21
+ if (n !== void 0 && n.username) return e("Assuming the user is " + n.username), t(n.username);
22
+ if (typeof document < "u" && document.location && ("" + document.location).slice(0, 16) === "http://localhost") {
23
+ let n = document.getElementById("appTarget");
24
+ if (!n) return null;
25
+ let r = n.getAttribute("testID");
26
+ return r ? (e("Assuming user is " + r), t(r)) : null;
27
+ }
28
+ return null;
29
+ }
30
+ //#endregion
31
+ export { n as appContext, r as offlineTestID };
32
+
33
+ //# sourceMappingURL=authUtil.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"authUtil.esm.js","names":[],"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":";;;AASA,IAAa,UAAuB;CAChC,IAAI,EAAE,uBAAyB;CAG/B,IAFA,MAAoB,CAAC,GACrB,EAAgB,oBAAoB,IAChC,EAAgB,UAAU,OAAO,YACb,OAAO,SAAS,SAAS,KAC7B,WAAW,EAAgB,MAAM,GAAG;EACpD,EAAgB,oBAAoB;EACpC,IAAM,IAAS,IAAI,gBAAgB,OAAO,SAAS,SAAS,MAAM;EAClE,IAAI,GAAQ;GACR,IAAI,IAAa,EAAgB,aAAa,EAAO,IAAI,KAAK,KAAK;GACnE,IAAI,MACJ,IAAa,UAAU,CAAU,GAC7B,CAAC,EAAW,WAAW,EAAgB,MAAM,IAAG;IAChD,IAAM,IAAM,EAAW,MAAM,IAAI;IAEjC,AADA,EAAgB,MAAM,EAAI,KAAK,OAAO,EAAI,IAC1C,EAAgB,oBAAoB;GACxC;EAEJ;CACA;CAEJ,OAAO;AACX;AASA,SAAgB,IAAmC;CAC/C,IAAM,EAAE,6BAA+B;CACvC,IACS,MAA0B,UACjC,EAAsB,UAItB,OADA,EAAU,0BAA0B,EAAsB,QAAQ,GAC3D,EAAI,EAAsB,QAAQ;CAI3C,IACE,OAAO,WAAa,OACpB,SAAS,aACR,KAAK,SAAS,SAAA,CAAU,MAAM,GAAG,EAAE,MAAM,oBAC1C;EACA,IAAM,IAAM,SAAS,eAAe,WAAW;EAC/C,IAAI,CAAC,GAAK,OAAO;EACjB,IAAM,IAAK,EAAI,aAAa,QAAQ;EAGpC,OAFK,KACL,EAAU,sBAAsB,CAAE,GAC3B,EAAI,CAAE,KAFG;CAGlB;CACA,OAAO;AACX"}
@@ -0,0 +1,2 @@
1
+ async function e(e={}){if(typeof window>`u`)return!1;let t=e.issuer||``,n=e.postLogoutRedirectPath||`/`;try{if(t){let e=new URL(t);e.pathname=`/.well-known/openid-configuration`;let n=await fetch(e.toString(),{credentials:`include`});if(n.status===200){let e=await n.json();e&&e.end_session_endpoint&&await fetch(e.end_session_endpoint,{credentials:`include`})}}}catch{}try{let e=await fetch(`/.well-known/solid/logout`,{credentials:`include`});if(e.ok||e.redirected)return window.location.assign(n),!0}catch{}return!1}exports.performServerSideLogout=e;
2
+ //# sourceMappingURL=serverLogout.cjs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"serverLogout.cjs.js","names":[],"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,eAAsB,EAAyB,EAA+B,CAAC,EAAqB,CAClG,GAAI,OAAO,OAAW,IACpB,MAAO,GAET,IAAM,EAAS,EAAQ,QAAU,GAC3B,EAAyB,EAAQ,wBAA0B,IAGjE,GAAI,CACF,GAAI,EAAQ,CACV,IAAM,EAAe,IAAI,IAAI,CAAM,EACnC,EAAa,SAAW,oCACxB,IAAM,EAAkB,MAAM,MAAM,EAAa,SAAS,EAAG,CAAE,YAAa,SAAU,CAAC,EAEvF,GAAI,EAAgB,SAAW,IAAK,CAClC,IAAM,EAAsB,MAAM,EAAgB,KAAK,EACnD,GAAuB,EAAoB,sBAC7C,MAAM,MAAM,EAAoB,qBAAsB,CAAE,YAAa,SAAU,CAAC,CAEpF,CACF,CACF,MAAe,CAEf,CAGA,GAAI,CACF,IAAM,EAAiB,MAAM,MAAM,4BAA6B,CAAE,YAAa,SAAU,CAAC,EAC1F,GAAI,EAAe,IAAM,EAAe,WAEtC,OADA,OAAO,SAAS,OAAO,CAAsB,EACtC,EAEX,MAAe,CAEf,CAEA,MAAO,EACT"}
@@ -0,0 +1,25 @@
1
+ //#region src/authn/serverLogout.ts
2
+ async function e(e = {}) {
3
+ if (typeof window > "u") return !1;
4
+ let t = e.issuer || "", n = e.postLogoutRedirectPath || "/";
5
+ try {
6
+ if (t) {
7
+ let e = new URL(t);
8
+ e.pathname = "/.well-known/openid-configuration";
9
+ let n = await fetch(e.toString(), { credentials: "include" });
10
+ if (n.status === 200) {
11
+ let e = await n.json();
12
+ e && e.end_session_endpoint && await fetch(e.end_session_endpoint, { credentials: "include" });
13
+ }
14
+ }
15
+ } catch {}
16
+ try {
17
+ let e = await fetch("/.well-known/solid/logout", { credentials: "include" });
18
+ if (e.ok || e.redirected) return window.location.assign(n), !0;
19
+ } catch {}
20
+ return !1;
21
+ }
22
+ //#endregion
23
+ export { e as performServerSideLogout };
24
+
25
+ //# sourceMappingURL=serverLogout.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"serverLogout.esm.js","names":[],"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,eAAsB,EAAyB,IAA+B,CAAC,GAAqB;CAClG,IAAI,OAAO,SAAW,KACpB,OAAO;CAET,IAAM,IAAS,EAAQ,UAAU,IAC3B,IAAyB,EAAQ,0BAA0B;CAGjE,IAAI;EACF,IAAI,GAAQ;GACV,IAAM,IAAe,IAAI,IAAI,CAAM;GACnC,EAAa,WAAW;GACxB,IAAM,IAAkB,MAAM,MAAM,EAAa,SAAS,GAAG,EAAE,aAAa,UAAU,CAAC;GAEvF,IAAI,EAAgB,WAAW,KAAK;IAClC,IAAM,IAAsB,MAAM,EAAgB,KAAK;IACvD,AAAI,KAAuB,EAAoB,wBAC7C,MAAM,MAAM,EAAoB,sBAAsB,EAAE,aAAa,UAAU,CAAC;GAEpF;EACF;CACF,QAAe,CAEf;CAGA,IAAI;EACF,IAAM,IAAiB,MAAM,MAAM,6BAA6B,EAAE,aAAa,UAAU,CAAC;EAC1F,IAAI,EAAe,MAAM,EAAe,YAEtC,OADA,OAAO,SAAS,OAAO,CAAsB,GACtC;CAEX,QAAe,CAEf;CAEA,OAAO;AACT"}
@@ -0,0 +1,21 @@
1
+ const e=require("../util/ns.cjs.js"),t=require("../util/utils.cjs.js");let n=require("rdflib");var r=`index.ttl#this`;function i(i,a){let o=e.ns;async function s(e,t,r){await i.fetcher.load(e);let a=i.any(e,new n.NamedNode(`http://www.iana.org/assignments/link-relations/acl`));if(!a)throw Error(`Chat ACL doc not found!`);let o=`
2
+ @prefix acl: <http://www.w3.org/ns/auth/acl#>.
3
+ <#owner>
4
+ a acl:Authorization;
5
+ acl:agent <${t.value}>;
6
+ acl:accessTo <.>;
7
+ acl:default <.>;
8
+ acl:mode
9
+ acl:Read, acl:Write, acl:Control.
10
+ <#invitee>
11
+ a acl:Authorization;
12
+ acl:agent <${r.value}>;
13
+ acl:accessTo <.>;
14
+ acl:default <.>;
15
+ acl:mode
16
+ acl:Read, acl:Append.
17
+ `;await i.fetcher.webOperation(`PUT`,a.value,{data:o,contentType:`text/turtle`})}async function c(e,r){let a=i.any(r,o.solid(`privateTypeIndex`));if(!a)throw Error(`Private type index not found!`);await i.fetcher.load(a);let s=t.newThing(a),c=[(0,n.st)(s,o.rdf(`type`),o.solid(`TypeRegistration`),a.doc()),(0,n.st)(s,o.solid(`forClass`),o.meeting(`LongChat`),a.doc()),(0,n.st)(s,o.solid(`instance`),e,a.doc())];await new Promise((e,t)=>{i.updater.update([],c,function(n,r,i){r?e(null):t(Error(i))})})}async function l(e){let r=await a.loadMe(),o=t.determineChatContainer(e,await a.getPodRoot(r)),s=!0;try{await i.fetcher.load(new n.NamedNode(o.value+`index.ttl#this`))}catch{s=!1}return{me:r,chatContainer:o,exists:s}}async function u(e,t){return(await d({me:t,newBase:e.value})).newInstance}function d(e){let t=i,a=t.updater;if(e.me&&!e.me.uri)throw Error(`chat mintNew: Invalid userid `+e.me);let s=e.newInstance=e.newInstance||t.sym(e.newBase+r),c=s.doc();return t.add(s,o.rdf(`type`),o.meeting(`LongChat`),c),t.add(s,o.dc(`title`),`Chat channel`,c),t.add(s,o.dc(`created`),(0,n.term)(new Date(Date.now())),c),e.me&&t.add(s,o.dc(`author`),e.me,c),new Promise(function(n,r){a?.put(c,t.statementsMatching(void 0,void 0,void 0,c),`text/turtle`,function(t,i,a){i?n({...e,newInstance:s}):r(Error(`FAILED to save new chat channel at: `+t+` : `+a))})})}async function f(e,t=!0){let{me:i,chatContainer:a,exists:o}=await l(e);if(o)return new n.NamedNode(a.value+r);if(t){let t=await u(a,i);return await p(e,t),await s(a,i,e),await c(t,i),t}return null}async function p(e,t){await i.fetcher.load(e.doc());let n=i.any(e,o.ldp(`inbox`),void 0,e.doc());if(!n)throw Error(`Invitee inbox not found! ${e.value}`);let r=`
18
+ <> a <http://www.w3.org/ns/pim/meeting#LongChatInvite> ;
19
+ ${o.rdf(`seeAlso`)} <${t.value}> .
20
+ `,a=await i.fetcher?.webOperation(`POST`,n.value,{data:r,contentType:`text/turtle`});if(!a?.headers.get(`location`))throw Error(`Invite sending returned a ${a?.status}`)}return{setAcl:s,addToPrivateTypeIndex:c,findChat:l,createChatThing:u,getChat:f,sendInvite:p,mintNew:d}}exports.createChatLogic=i;
21
+ //# sourceMappingURL=chatLogic.cjs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chatLogic.cjs.js","names":[],"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,IAAM,EAA6B,iBAEnC,SAAgB,EAAgB,EAAO,EAAyB,CAC5D,IAAM,EAAK,EAAA,GAEX,eAAe,EACX,EACA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AAM,EAAW,EAAS,CAAS,EACnC,MAAM,EAAO,EAAe,EAAI,CAAO,EACvC,MAAM,EAAsB,EAAW,CAAE,EAClC,CACX,CACA,OAAO,IACX,CAEA,eAAe,EAAW,EAAoB,EAAsB,CAChE,MAAM,EAAM,QAAQ,KAAK,EAAQ,IAAI,CAAC,EACtC,IAAM,EAAe,EAAM,IACvB,EACA,EAAG,IAAI,OAAO,EACd,IAAA,GACA,EAAQ,IAAI,CAChB,EACA,GAAI,CAAC,EACD,MAAU,MAAM,4BAA4B,EAAQ,OAAO,EAE/D,IAAM,EAAa;;UAEjB,EAAG,IAAI,SAAS,EAAE,IAAI,EAAU,MAAM;UAGlC,EAAiB,MAAM,EAAM,SAAS,aACxC,OACA,EAAa,MACb,CACI,KAAM,EACN,YAAa,aACjB,CACJ,EAEA,GAAI,CADgB,GAAgB,QAAQ,IAAI,UAAU,EAEtD,MAAU,MAAM,6BAA6B,GAAgB,QAAQ,CAE7E,CACA,MAAO,CACH,SAAQ,wBAAuB,WAAU,kBAAiB,UAAS,aAAY,SACnF,CACJ"}
@@ -0,0 +1,116 @@
1
+ import { ns as e } from "../util/ns.esm.js";
2
+ import { determineChatContainer as t, newThing as n } from "../util/utils.esm.js";
3
+ import { NamedNode as r, st as i, term as a } from "rdflib";
4
+ //#region src/chat/chatLogic.ts
5
+ var o = "index.ttl#this";
6
+ function s(s, c) {
7
+ let l = e;
8
+ async function u(e, t, n) {
9
+ await s.fetcher.load(e);
10
+ let i = s.any(e, new r("http://www.iana.org/assignments/link-relations/acl"));
11
+ if (!i) throw Error("Chat ACL doc not found!");
12
+ let a = `
13
+ @prefix acl: <http://www.w3.org/ns/auth/acl#>.
14
+ <#owner>
15
+ a acl:Authorization;
16
+ acl:agent <${t.value}>;
17
+ acl:accessTo <.>;
18
+ acl:default <.>;
19
+ acl:mode
20
+ acl:Read, acl:Write, acl:Control.
21
+ <#invitee>
22
+ a acl:Authorization;
23
+ acl:agent <${n.value}>;
24
+ acl:accessTo <.>;
25
+ acl:default <.>;
26
+ acl:mode
27
+ acl:Read, acl:Append.
28
+ `;
29
+ await s.fetcher.webOperation("PUT", i.value, {
30
+ data: a,
31
+ contentType: "text/turtle"
32
+ });
33
+ }
34
+ async function d(e, t) {
35
+ let r = s.any(t, l.solid("privateTypeIndex"));
36
+ if (!r) throw Error("Private type index not found!");
37
+ await s.fetcher.load(r);
38
+ let a = n(r), o = [
39
+ i(a, l.rdf("type"), l.solid("TypeRegistration"), r.doc()),
40
+ i(a, l.solid("forClass"), l.meeting("LongChat"), r.doc()),
41
+ i(a, l.solid("instance"), e, r.doc())
42
+ ];
43
+ await new Promise((e, t) => {
44
+ s.updater.update([], o, function(n, r, i) {
45
+ r ? e(null) : t(Error(i));
46
+ });
47
+ });
48
+ }
49
+ async function f(e) {
50
+ let n = await c.loadMe(), i = t(e, await c.getPodRoot(n)), a = !0;
51
+ try {
52
+ await s.fetcher.load(new r(i.value + "index.ttl#this"));
53
+ } catch {
54
+ a = !1;
55
+ }
56
+ return {
57
+ me: n,
58
+ chatContainer: i,
59
+ exists: a
60
+ };
61
+ }
62
+ async function p(e, t) {
63
+ return (await m({
64
+ me: t,
65
+ newBase: e.value
66
+ })).newInstance;
67
+ }
68
+ function m(e) {
69
+ let t = s, n = t.updater;
70
+ if (e.me && !e.me.uri) throw Error("chat mintNew: Invalid userid " + e.me);
71
+ let r = e.newInstance = e.newInstance || t.sym(e.newBase + o), i = r.doc();
72
+ return t.add(r, l.rdf("type"), l.meeting("LongChat"), i), t.add(r, l.dc("title"), "Chat channel", i), t.add(r, l.dc("created"), a(new Date(Date.now())), i), e.me && t.add(r, l.dc("author"), e.me, i), new Promise(function(a, o) {
73
+ n?.put(i, t.statementsMatching(void 0, void 0, void 0, i), "text/turtle", function(t, n, i) {
74
+ n ? a({
75
+ ...e,
76
+ newInstance: r
77
+ }) : o(/* @__PURE__ */ Error("FAILED to save new chat channel at: " + t + " : " + i));
78
+ });
79
+ });
80
+ }
81
+ async function h(e, t = !0) {
82
+ let { me: n, chatContainer: i, exists: a } = await f(e);
83
+ if (a) return new r(i.value + o);
84
+ if (t) {
85
+ let t = await p(i, n);
86
+ return await g(e, t), await u(i, n, e), await d(t, n), t;
87
+ }
88
+ return null;
89
+ }
90
+ async function g(e, t) {
91
+ await s.fetcher.load(e.doc());
92
+ let n = s.any(e, l.ldp("inbox"), void 0, e.doc());
93
+ if (!n) throw Error(`Invitee inbox not found! ${e.value}`);
94
+ let r = `
95
+ <> a <http://www.w3.org/ns/pim/meeting#LongChatInvite> ;
96
+ ${l.rdf("seeAlso")} <${t.value}> .
97
+ `, i = await s.fetcher?.webOperation("POST", n.value, {
98
+ data: r,
99
+ contentType: "text/turtle"
100
+ });
101
+ if (!i?.headers.get("location")) throw Error(`Invite sending returned a ${i?.status}`);
102
+ }
103
+ return {
104
+ setAcl: u,
105
+ addToPrivateTypeIndex: d,
106
+ findChat: f,
107
+ createChatThing: p,
108
+ getChat: h,
109
+ sendInvite: g,
110
+ mintNew: m
111
+ };
112
+ }
113
+ //#endregion
114
+ export { s as createChatLogic };
115
+
116
+ //# sourceMappingURL=chatLogic.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chatLogic.esm.js","names":[],"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":";;;;AAKA,IAAM,IAA6B;AAEnC,SAAgB,EAAgB,GAAO,GAAyB;CAC5D,IAAM,IAAK;CAEX,eAAe,EACX,GACA,GACA,GACa;EAIb,MAAM,EAAM,QAAQ,KAAK,CAAa;EAGtC,IAAM,IAAa,EAAM,IACrB,GACA,IAAI,EAAU,oDAAoD,CACtE;EACA,IAAI,CAAC,GACD,MAAU,MAAM,yBAAyB;EAG7C,IAAM,IAAU;;;;yBAIC,EAAG,MAAM;;;;;;;yBAOT,EAAQ,MAAM;;;;;;EAM/B,MAAM,EAAM,QAAQ,aAAa,OAAO,EAAW,OAAO;GACtD,MAAM;GACN,aAAa;EACjB,CAAC;CACL;CAEA,eAAe,EAAsB,GAAW,GAAI;EAEhD,IAAM,IAAmB,EAAM,IAC3B,GACA,EAAG,MAAM,kBAAkB,CAC/B;EACA,IAAI,CAAC,GACD,MAAU,MAAM,+BAA+B;EAEnD,MAAM,EAAM,QAAQ,KAAK,CAAgB;EACzC,IAAM,IAAM,EAAS,CAAgB,GAC/B,IAAM;GACR,EACI,GACA,EAAG,IAAI,MAAM,GACb,EAAG,MAAM,kBAAkB,GAC3B,EAAiB,IAAI,CACzB;GACA,EACI,GACA,EAAG,MAAM,UAAU,GACnB,EAAG,QAAQ,UAAU,GACrB,EAAiB,IA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,a){async function o(e,t){let a=await n.loadMe(),o=`${(await n.getPodRoot(a)).value}p2p-inboxes/${encodeURIComponent(t)}/`;return await i.createContainer(o),await r.setSinglePeerAccess({ownerWebId:a.value,peerWebId:e,accessToModes:`acl:Append`,target:o}),o}async function s(e){e||=await n.loadMe();let t=await n.getMainInbox(e);return(await i.getContainerMembers(t)).filter(e=>!i.isContainer(e))}async function c(n,r){let i=await t.fetcher._fetch(n);if(i.status!==200)throw Error(`Not OK! ${n}`);let a=e.getArchiveUrl(n,r),o={method:`PUT`,body:await i.text(),headers:[[`Content-Type`,i.headers.get(`Content-Type`)||`application/octet-stream`]]};(await t.fetcher._fetch(a,o)).status.toString()[0]===`2`&&await t.fetcher._fetch(n,{method:`DELETE`})}return{createInboxFor:o,getNewMessages:s,markAsRead:c}}exports.createInboxLogic=t;
2
+ //# sourceMappingURL=inboxLogic.cjs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"inboxLogic.cjs.js","names":[],"sources":["../../src/inbox/inboxLogic.ts"],"sourcesContent":["import { NamedNode } from 'rdflib'\nimport { InboxLogic } from '../types'\nimport { getArchiveUrl } from '../util/utils'\n\nexport function createInboxLogic(store, profileLogic, utilityLogic, containerLogic, aclLogic): InboxLogic {\n\n async function createInboxFor(peerWebId: string, nick: string) {\n const myWebId: NamedNode = await profileLogic.loadMe()\n const podRoot: NamedNode = await profileLogic.getPodRoot(myWebId)\n const ourInbox = `${podRoot.value}p2p-inboxes/${encodeURIComponent(nick)}/`\n await containerLogic.createContainer(ourInbox)\n // const aclDocUrl = await aclLogic.findAclDocUrl(ourInbox);\n await utilityLogic.setSinglePeerAccess({\n ownerWebId: myWebId.value,\n peerWebId,\n accessToModes: 'acl:Append',\n target: ourInbox\n })\n return ourInbox\n }\n\n async function getNewMessages(\n user?: NamedNode\n ): Promise<NamedNode[]> {\n if (!user) {\n user = await profileLogic.loadMe()\n }\n const inbox = await profileLogic.getMainInbox(user)\n const urls = await containerLogic.getContainerMembers(inbox)\n return urls.filter(url => !containerLogic.isContainer(url))\n }\n\n async function markAsRead(url: string, date: Date) {\n const downloaded = await store.fetcher._fetch(url)\n if (downloaded.status !== 200) {\n throw new Error(`Not OK! ${url}`)\n }\n const archiveUrl = getArchiveUrl(url, date)\n const options = {\n method: 'PUT',\n body: await downloaded.text(),\n headers: [\n ['Content-Type', downloaded.headers.get('Content-Type') || 'application/octet-stream']\n ]\n }\n const uploaded = await store.fetcher._fetch(archiveUrl, options)\n if (uploaded.status.toString()[0] === '2') {\n await store.fetcher._fetch(url, {\n method: 'DELETE'\n })\n }\n }\n return {\n createInboxFor,\n getNewMessages,\n markAsRead\n }\n}\n"],"mappings":"wCAIA,SAAgB,EAAiB,EAAO,EAAc,EAAc,EAAgB,EAAsB,CAEtG,eAAe,EAAe,EAAmB,EAAc,CAC7D,IAAM,EAAqB,MAAM,EAAa,OAAO,EAE/C,EAAW,IAAG,MADa,EAAa,WAAW,CAAO,EAAA,CACpC,MAAM,cAAc,mBAAmB,CAAI,EAAE,GASzE,OARA,MAAM,EAAe,gBAAgB,CAAQ,EAE7C,MAAM,EAAa,oBAAoB,CACrC,WAAY,EAAQ,MACpB,YACA,cAAe,aACf,OAAQ,CACV,CAAC,EACM,CACX,CAEA,eAAe,EACX,EACsB,CACtB,AACE,IAAO,MAAM,EAAa,OAAO,EAEnC,IAAM,EAAQ,MAAM,EAAa,aAAa,CAAI,EAElD,OAAO,MADY,EAAe,oBAAoB,CAAK,EAAA,CAC/C,OAAO,GAAO,CAAC,EAAe,YAAY,CAAG,CAAC,CAC9D,CAEA,eAAe,EAAW,EAAa,EAAY,CACjD,IAAM,EAAa,MAAM,EAAM,QAAQ,OAAO,CAAG,EACjD,GAAI,EAAW,SAAW,IACxB,MAAU,MAAM,WAAW,GAAK,EAElC,IAAM,EAAa,EAAA,cAAc,EAAK,CAAI,EACpC,EAAU,CACd,OAAQ,MACR,KAAM,MAAM,EAAW,KAAK,EAC5B,QAAS,CACP,CAAC,eAAgB,EAAW,QAAQ,IAAI,cAAc,GAAK,0BAA0B,CACvF,CACF,GAEI,MADmB,EAAM,QAAQ,OAAO,EAAY,CAAO,EAAA,CAClD,OAAO,SAAS,CAAC,CAAC,KAAO,KACpC,MAAM,EAAM,QAAQ,OAAO,EAAK,CAC9B,OAAQ,QACV,CAAC,CAEL,CACA,MAAO,CACL,iBACA,iBACA,YACF,CACF"}
@@ -0,0 +1,37 @@
1
+ import { getArchiveUrl as e } from "../util/utils.esm.js";
2
+ //#region src/inbox/inboxLogic.ts
3
+ function t(t, n, r, i, a) {
4
+ async function o(e, t) {
5
+ let a = await n.loadMe(), o = `${(await n.getPodRoot(a)).value}p2p-inboxes/${encodeURIComponent(t)}/`;
6
+ return await i.createContainer(o), await r.setSinglePeerAccess({
7
+ ownerWebId: a.value,
8
+ peerWebId: e,
9
+ accessToModes: "acl:Append",
10
+ target: o
11
+ }), o;
12
+ }
13
+ async function s(e) {
14
+ e ||= await n.loadMe();
15
+ let t = await n.getMainInbox(e);
16
+ return (await i.getContainerMembers(t)).filter((e) => !i.isContainer(e));
17
+ }
18
+ async function c(n, r) {
19
+ let i = await t.fetcher._fetch(n);
20
+ if (i.status !== 200) throw Error(`Not OK! ${n}`);
21
+ let a = e(n, r), o = {
22
+ method: "PUT",
23
+ body: await i.text(),
24
+ headers: [["Content-Type", i.headers.get("Content-Type") || "application/octet-stream"]]
25
+ };
26
+ (await t.fetcher._fetch(a, o)).status.toString()[0] === "2" && await t.fetcher._fetch(n, { method: "DELETE" });
27
+ }
28
+ return {
29
+ createInboxFor: o,
30
+ getNewMessages: s,
31
+ markAsRead: c
32
+ };
33
+ }
34
+ //#endregion
35
+ export { t as createInboxLogic };
36
+
37
+ //# sourceMappingURL=inboxLogic.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"inboxLogic.esm.js","names":[],"sources":["../../src/inbox/inboxLogic.ts"],"sourcesContent":["import { NamedNode } from 'rdflib'\nimport { InboxLogic } from '../types'\nimport { getArchiveUrl } from '../util/utils'\n\nexport function createInboxLogic(store, profileLogic, utilityLogic, containerLogic, aclLogic): InboxLogic {\n\n async function createInboxFor(peerWebId: string, nick: string) {\n const myWebId: NamedNode = await profileLogic.loadMe()\n const podRoot: NamedNode = await profileLogic.getPodRoot(myWebId)\n const ourInbox = `${podRoot.value}p2p-inboxes/${encodeURIComponent(nick)}/`\n await containerLogic.createContainer(ourInbox)\n // const aclDocUrl = await aclLogic.findAclDocUrl(ourInbox);\n await utilityLogic.setSinglePeerAccess({\n ownerWebId: myWebId.value,\n peerWebId,\n accessToModes: 'acl:Append',\n target: ourInbox\n })\n return ourInbox\n }\n\n async function getNewMessages(\n user?: NamedNode\n ): Promise<NamedNode[]> {\n if (!user) {\n user = await profileLogic.loadMe()\n }\n const inbox = await profileLogic.getMainInbox(user)\n const urls = await containerLogic.getContainerMembers(inbox)\n return urls.filter(url => !containerLogic.isContainer(url))\n }\n\n async function markAsRead(url: string, date: Date) {\n const downloaded = await store.fetcher._fetch(url)\n if (downloaded.status !== 200) {\n throw new Error(`Not OK! ${url}`)\n }\n const archiveUrl = getArchiveUrl(url, date)\n const options = {\n method: 'PUT',\n body: await downloaded.text(),\n headers: [\n ['Content-Type', downloaded.headers.get('Content-Type') || 'application/octet-stream']\n ]\n }\n const uploaded = await store.fetcher._fetch(archiveUrl, options)\n if (uploaded.status.toString()[0] === '2') {\n await store.fetcher._fetch(url, {\n method: 'DELETE'\n })\n }\n }\n return {\n createInboxFor,\n getNewMessages,\n markAsRead\n }\n}\n"],"mappings":";;AAIA,SAAgB,EAAiB,GAAO,GAAc,GAAc,GAAgB,GAAsB;CAEtG,eAAe,EAAe,GAAmB,GAAc;EAC7D,IAAM,IAAqB,MAAM,EAAa,OAAO,GAE/C,IAAW,IAAG,MADa,EAAa,WAAW,CAAO,EAAA,CACpC,MAAM,cAAc,mBAAmB,CAAI,EAAE;EASzE,OARA,MAAM,EAAe,gBAAgB,CAAQ,GAE7C,MAAM,EAAa,oBAAoB;GACrC,YAAY,EAAQ;GACpB;GACA,eAAe;GACf,QAAQ;EACV,CAAC,GACM;CACX;CAEA,eAAe,EACX,GACsB;EACtB,AACE,MAAO,MAAM,EAAa,OAAO;EAEnC,IAAM,IAAQ,MAAM,EAAa,aAAa,CAAI;EAElD,QAAO,MADY,EAAe,oBAAoB,CAAK,EAAA,CAC/C,QAAO,MAAO,CAAC,EAAe,YAAY,CAAG,CAAC;CAC9D;CAEA,eAAe,EAAW,GAAa,GAAY;EACjD,IAAM,IAAa,MAAM,EAAM,QAAQ,OAAO,CAAG;EACjD,IAAI,EAAW,WAAW,KACxB,MAAU,MAAM,WAAW,GAAK;EAElC,IAAM,IAAa,EAAc,GAAK,CAAI,GACpC,IAAU;GACd,QAAQ;GACR,MAAM,MAAM,EAAW,KAAK;GAC5B,SAAS,CACP,CAAC,gBAAgB,EAAW,QAAQ,IAAI,cAAc,KAAK,0BAA0B,CACvF;EACF;EAEA,CAAI,MADmB,EAAM,QAAQ,OAAO,GAAY,CAAO,EAAA,CAClD,OAAO,SAAS,CAAC,CAAC,OAAO,OACpC,MAAM,EAAM,QAAQ,OAAO,GAAK,EAC9B,QAAQ,SACV,CAAC;CAEL;CACA,OAAO;EACL;EACA;EACA;CACF;AACF"}
@@ -0,0 +1,2 @@
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./acl/aclLogic.cjs.js"),t=require("./authn/authUtil.cjs.js"),n=require("./logic/CustomError.cjs.js"),r=require("./typeIndex/typeIndexLogic.cjs.js"),i=require("./logic/solidLogicSingleton.cjs.js"),a=require("./authn/serverLogout.cjs.js"),o=require("./issuer/issuerLogic.cjs.js");var s=i.solidLogicSingleton.authn,c=i.solidLogicSingleton.authn.authSession,l=i.solidLogicSingleton.store;exports.ACL_LINK=e.ACL_LINK,exports.CrossOriginForbiddenError=n.CrossOriginForbiddenError,exports.FetchError=n.FetchError,exports.NotEditableError=n.NotEditableError,exports.NotFoundError=n.NotFoundError,exports.SameOriginForbiddenError=n.SameOriginForbiddenError,exports.UnauthorizedError=n.UnauthorizedError,exports.WebOperationError=n.WebOperationError,exports.appContext=t.appContext,exports.authSession=c,exports.authn=s,exports.createTypeIndexLogic=r.createTypeIndexLogic,exports.getSuggestedIssuers=o.getSuggestedIssuers,exports.offlineTestID=t.offlineTestID,exports.performServerSideLogout=a.performServerSideLogout,exports.solidLogicSingleton=i.solidLogicSingleton,exports.store=l;
2
+ //# sourceMappingURL=index.cjs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["// Make these variables directly accessible as it is what you need most of the time\n// This also makes these variable globaly accesible in mashlib\nimport { solidLogicSingleton } from './logic/solidLogicSingleton'\n\nconst authn = solidLogicSingleton.authn\nconst authSession = solidLogicSingleton.authn.authSession\nconst store = solidLogicSingleton.store\n\nexport { ACL_LINK } from './acl/aclLogic'\nexport { offlineTestID, appContext } from './authn/authUtil'\nexport { performServerSideLogout } from './authn/serverLogout'\nexport { getSuggestedIssuers } from './issuer/issuerLogic'\nexport { createTypeIndexLogic } from './typeIndex/typeIndexLogic'\nexport type { AppDetails, SolidNamespace, AuthenticationContext, SolidLogic, ChatLogic } from './types'\nexport { UnauthorizedError, CrossOriginForbiddenError, SameOriginForbiddenError, NotFoundError, FetchError, NotEditableError, WebOperationError } from './logic/CustomError'\n\nexport {\n solidLogicSingleton, // solidLogicSingleton is exported entirely because it is used in solid-panes\n store,\n authn,\n authSession\n}\n\n"],"mappings":"0WAIA,IAAM,EAAQ,EAAA,oBAAoB,MAC5B,EAAc,EAAA,oBAAoB,MAAM,YACxC,EAAQ,EAAA,oBAAoB"}
@@ -0,0 +1,13 @@
1
+ import { ACL_LINK as e } from "./acl/aclLogic.esm.js";
2
+ import { appContext as t, offlineTestID as n } from "./authn/authUtil.esm.js";
3
+ import { CrossOriginForbiddenError as r, FetchError as i, NotEditableError as a, NotFoundError as o, SameOriginForbiddenError as s, UnauthorizedError as c, WebOperationError as l } from "./logic/CustomError.esm.js";
4
+ import { createTypeIndexLogic as u } from "./typeIndex/typeIndexLogic.esm.js";
5
+ import { solidLogicSingleton as d } from "./logic/solidLogicSingleton.esm.js";
6
+ import { performServerSideLogout as f } from "./authn/serverLogout.esm.js";
7
+ import { getSuggestedIssuers as p } from "./issuer/issuerLogic.esm.js";
8
+ //#region src/index.ts
9
+ var m = d.authn, h = d.authn.authSession, g = d.store;
10
+ //#endregion
11
+ export { e as ACL_LINK, r as CrossOriginForbiddenError, i as FetchError, a as NotEditableError, o as NotFoundError, s as SameOriginForbiddenError, c as UnauthorizedError, l as WebOperationError, t as appContext, h as authSession, m as authn, u as createTypeIndexLogic, p as getSuggestedIssuers, n as offlineTestID, f as performServerSideLogout, d as solidLogicSingleton, g as store };
12
+
13
+ //# sourceMappingURL=index.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.esm.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["// Make these variables directly accessible as it is what you need most of the time\n// This also makes these variable globaly accesible in mashlib\nimport { solidLogicSingleton } from './logic/solidLogicSingleton'\n\nconst authn = solidLogicSingleton.authn\nconst authSession = solidLogicSingleton.authn.authSession\nconst store = solidLogicSingleton.store\n\nexport { ACL_LINK } from './acl/aclLogic'\nexport { offlineTestID, appContext } from './authn/authUtil'\nexport { performServerSideLogout } from './authn/serverLogout'\nexport { getSuggestedIssuers } from './issuer/issuerLogic'\nexport { createTypeIndexLogic } from './typeIndex/typeIndexLogic'\nexport type { AppDetails, SolidNamespace, AuthenticationContext, SolidLogic, ChatLogic } from './types'\nexport { UnauthorizedError, CrossOriginForbiddenError, SameOriginForbiddenError, NotFoundError, FetchError, NotEditableError, WebOperationError } from './logic/CustomError'\n\nexport {\n solidLogicSingleton, // solidLogicSingleton is exported entirely because it is used in solid-panes\n store,\n authn,\n authSession\n}\n\n"],"mappings":";;;;;;;;AAIA,IAAM,IAAQ,EAAoB,OAC5B,IAAc,EAAoB,MAAM,aACxC,IAAQ,EAAoB"}
@@ -0,0 +1,2 @@
1
+ var e=[{name:`Solid Community`,uri:`https://solidcommunity.net`},{name:`Solid Web`,uri:`https://solidweb.org`},{name:`Solid Web ME`,uri:`https://solidweb.me`},{name:`Inrupt.com`,uri:`https://login.inrupt.com`}];function t(){let t=[...e],{host:n,origin:r}=new URL(location.href);return t.map(({uri:e})=>new URL(e).host).includes(n)||t.unshift({name:n,uri:r}),t}exports.getSuggestedIssuers=t;
2
+ //# sourceMappingURL=issuerLogic.cjs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"issuerLogic.cjs.js","names":[],"sources":["../../src/issuer/issuerLogic.ts"],"sourcesContent":["const DEFAULT_ISSUERS = [\n {\n name: 'Solid Community',\n uri: 'https://solidcommunity.net'\n },\n {\n name: 'Solid Web',\n uri: 'https://solidweb.org'\n },\n {\n name: 'Solid Web ME',\n uri: 'https://solidweb.me'\n },\n {\n name: 'Inrupt.com',\n uri: 'https://login.inrupt.com'\n }\n]\n\n/**\n * @returns - A list of suggested OIDC issuers\n */\nexport function getSuggestedIssuers (): { name: string, uri: string }[] {\n // Suggest a default list of OIDC issuers\n const issuers = [...DEFAULT_ISSUERS]\n \n // Suggest the current host if not already included\n const { host, origin } = new URL(location.href)\n const hosts = issuers.map(({ uri }) => new URL(uri).host)\n if (!hosts.includes(host)) {\n issuers.unshift({ name: host, uri: origin })\n }\n \n return issuers\n }"],"mappings":"AAAA,IAAM,EAAkB,CACtB,CACE,KAAM,kBACN,IAAK,4BACP,EACA,CACE,KAAM,YACN,IAAK,sBACP,EACA,CACE,KAAM,eACN,IAAK,qBACP,EACA,CACE,KAAM,aACN,IAAK,0BACP,CACF,EAKA,SAAgB,GAAwD,CAEpE,IAAM,EAAU,CAAC,GAAG,CAAe,EAG7B,CAAE,OAAM,UAAW,IAAI,IAAI,SAAS,IAAI,EAM9C,OALc,EAAQ,KAAK,CAAE,SAAU,IAAI,IAAI,CAAG,CAAC,CAAC,IAC/C,CAAA,CAAM,SAAS,CAAI,GACtB,EAAQ,QAAQ,CAAE,KAAM,EAAM,IAAK,CAAO,CAAC,EAGtC,CACT"}
@@ -0,0 +1,30 @@
1
+ //#region src/issuer/issuerLogic.ts
2
+ var e = [
3
+ {
4
+ name: "Solid Community",
5
+ uri: "https://solidcommunity.net"
6
+ },
7
+ {
8
+ name: "Solid Web",
9
+ uri: "https://solidweb.org"
10
+ },
11
+ {
12
+ name: "Solid Web ME",
13
+ uri: "https://solidweb.me"
14
+ },
15
+ {
16
+ name: "Inrupt.com",
17
+ uri: "https://login.inrupt.com"
18
+ }
19
+ ];
20
+ function t() {
21
+ let t = [...e], { host: n, origin: r } = new URL(location.href);
22
+ return t.map(({ uri: e }) => new URL(e).host).includes(n) || t.unshift({
23
+ name: n,
24
+ uri: r
25
+ }), t;
26
+ }
27
+ //#endregion
28
+ export { t as getSuggestedIssuers };
29
+
30
+ //# sourceMappingURL=issuerLogic.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"issuerLogic.esm.js","names":[],"sources":["../../src/issuer/issuerLogic.ts"],"sourcesContent":["const DEFAULT_ISSUERS = [\n {\n name: 'Solid Community',\n uri: 'https://solidcommunity.net'\n },\n {\n name: 'Solid Web',\n uri: 'https://solidweb.org'\n },\n {\n name: 'Solid Web ME',\n uri: 'https://solidweb.me'\n },\n {\n name: 'Inrupt.com',\n uri: 'https://login.inrupt.com'\n }\n]\n\n/**\n * @returns - A list of suggested OIDC issuers\n */\nexport function getSuggestedIssuers (): { name: string, uri: string }[] {\n // Suggest a default list of OIDC issuers\n const issuers = [...DEFAULT_ISSUERS]\n \n // Suggest the current host if not already included\n const { host, origin } = new URL(location.href)\n const hosts = issuers.map(({ uri }) => new URL(uri).host)\n if (!hosts.includes(host)) {\n issuers.unshift({ name: host, uri: origin })\n }\n \n return issuers\n }"],"mappings":";AAAA,IAAM,IAAkB;CACtB;EACE,MAAM;EACN,KAAK;CACP;CACA;EACE,MAAM;EACN,KAAK;CACP;CACA;EACE,MAAM;EACN,KAAK;CACP;CACA;EACE,MAAM;EACN,KAAK;CACP;AACF;AAKA,SAAgB,IAAwD;CAEpE,IAAM,IAAU,CAAC,GAAG,CAAe,GAG7B,EAAE,SAAM,cAAW,IAAI,IAAI,SAAS,IAAI;CAM9C,OALc,EAAQ,KAAK,EAAE,aAAU,IAAI,IAAI,CAAG,CAAC,CAAC,IAC/C,CAAA,CAAM,SAAS,CAAI,KACtB,EAAQ,QAAQ;EAAE,MAAM;EAAM,KAAK;CAAO,CAAC,GAGtC;AACT"}
@@ -0,0 +1,2 @@
1
+ var e=class extends Error{constructor(e){super(e),Object.setPrototypeOf(this,new.target.prototype),this.name=new.target.name}},t=class extends e{},n=class extends e{},r=class extends e{},i=class extends e{},a=class extends e{},o=class extends e{},s=class extends e{constructor(e,t){super(t),this.status=e}};exports.CrossOriginForbiddenError=n,exports.FetchError=s,exports.NotEditableError=a,exports.NotFoundError=i,exports.SameOriginForbiddenError=r,exports.UnauthorizedError=t,exports.WebOperationError=o;
2
+ //# sourceMappingURL=CustomError.cjs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CustomError.cjs.js","names":[],"sources":["../../src/logic/CustomError.ts"],"sourcesContent":["class CustomError extends Error {\n constructor(message?: string) {\n super(message)\n // see: typescriptlang.org/docs/handbook/release-notes/typescript-2-2.html\n Object.setPrototypeOf(this, new.target.prototype) // restore prototype chain\n this.name = new.target.name // stack traces display correctly now\n }\n}\n\nexport class UnauthorizedError extends CustomError {}\n\nexport class CrossOriginForbiddenError extends CustomError {}\n\nexport class SameOriginForbiddenError extends CustomError {}\n\nexport class NotFoundError extends CustomError {}\n\nexport class NotEditableError extends CustomError { }\n\nexport class WebOperationError extends CustomError {}\n\nexport class FetchError extends CustomError {\n status: number\n\n constructor(status: number, message?: string) {\n super(message)\n this.status = status\n }\n}"],"mappings":"AAAA,IAAM,EAAN,cAA0B,KAAM,CAC5B,YAAY,EAAkB,CAC1B,MAAM,CAAO,EAEb,OAAO,eAAe,KAAM,IAAI,OAAO,SAAS,EAChD,KAAK,KAAO,IAAI,OAAO,IAC3B,CACJ,EAEa,EAAb,cAAuC,CAAY,CAAC,EAEvC,EAAb,cAA+C,CAAY,CAAC,EAE/C,EAAb,cAA8C,CAAY,CAAC,EAE9C,EAAb,cAAmC,CAAY,CAAC,EAEnC,EAAb,cAAsC,CAAY,CAAE,EAEvC,EAAb,cAAuC,CAAY,CAAC,EAEvC,EAAb,cAAgC,CAAY,CAGxC,YAAY,EAAgB,EAAkB,CAC1C,MAAM,CAAO,EACb,KAAK,OAAS,CAClB,CACJ"}
@@ -0,0 +1,14 @@
1
+ //#region src/logic/CustomError.ts
2
+ var e = class extends Error {
3
+ constructor(e) {
4
+ super(e), Object.setPrototypeOf(this, new.target.prototype), this.name = new.target.name;
5
+ }
6
+ }, t = class extends e {}, n = class extends e {}, r = class extends e {}, i = class extends e {}, a = class extends e {}, o = class extends e {}, s = class extends e {
7
+ constructor(e, t) {
8
+ super(t), this.status = e;
9
+ }
10
+ };
11
+ //#endregion
12
+ export { n as CrossOriginForbiddenError, s as FetchError, a as NotEditableError, i as NotFoundError, r as SameOriginForbiddenError, t as UnauthorizedError, o as WebOperationError };
13
+
14
+ //# sourceMappingURL=CustomError.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CustomError.esm.js","names":[],"sources":["../../src/logic/CustomError.ts"],"sourcesContent":["class CustomError extends Error {\n constructor(message?: string) {\n super(message)\n // see: typescriptlang.org/docs/handbook/release-notes/typescript-2-2.html\n Object.setPrototypeOf(this, new.target.prototype) // restore prototype chain\n this.name = new.target.name // stack traces display correctly now\n }\n}\n\nexport class UnauthorizedError extends CustomError {}\n\nexport class CrossOriginForbiddenError extends CustomError {}\n\nexport class SameOriginForbiddenError extends CustomError {}\n\nexport class NotFoundError extends CustomError {}\n\nexport class NotEditableError extends CustomError { }\n\nexport class WebOperationError extends CustomError {}\n\nexport class FetchError extends CustomError {\n status: number\n\n constructor(status: number, message?: string) {\n super(message)\n this.status = status\n }\n}"],"mappings":";AAAA,IAAM,IAAN,cAA0B,MAAM;CAC5B,YAAY,GAAkB;EAI1B,AAHA,MAAM,CAAO,GAEb,OAAO,eAAe,MAAM,IAAI,OAAO,SAAS,GAChD,KAAK,OAAO,IAAI,OAAO;CAC3B;AACJ,GAEa,IAAb,cAAuC,EAAY,CAAC,GAEvC,IAAb,cAA+C,EAAY,CAAC,GAE/C,IAAb,cAA8C,EAAY,CAAC,GAE9C,IAAb,cAAmC,EAAY,CAAC,GAEnC,IAAb,cAAsC,EAAY,CAAE,GAEvC,IAAb,cAAuC,EAAY,CAAC,GAEvC,IAAb,cAAgC,EAAY;CAGxC,YAAY,GAAgB,GAAkB;EAE1C,AADA,MAAM,CAAO,GACb,KAAK,SAAS;CAClB;AACJ"}
@@ -0,0 +1,2 @@
1
+ const e=require("../_virtual/_rolldown/runtime.cjs.js"),t=require("../util/debug.cjs.js"),n=require("../acl/aclLogic.cjs.js"),r=require("../authn/SolidAuthnLogic.cjs.js"),i=require("../chat/chatLogic.cjs.js"),a=require("../inbox/inboxLogic.cjs.js"),o=require("../resource/resourceLogic.cjs.js"),s=require("../util/containerLogic.cjs.js"),c=require("../profile/profileLogic.cjs.js"),l=require("../typeIndex/typeIndexLogic.cjs.js"),u=require("../util/utilityLogic.cjs.js");let d=require("rdflib");d=e.__toESM(d);function f(e,f){t.log(`SolidLogic: Unique instance created. There should only be one of these.`);let p=d.graph();d.fetcher(p,{fetch:e.fetch}),p.updater=new d.UpdateManager(p),p.features=[];let m=new r.SolidAuthnLogic(f),h=n.createAclLogic(p),g=s.createContainerLogic(p),_=u.createUtilityLogic(p,h,g),v=c.createProfileLogic(p,m,_),y=i.createChatLogic(p,v),b=a.createInboxLogic(p,v,_,g,h),x=l.createTypeIndexLogic(p,m,v,_),S=o.createResourceLogic(p,h,g,x);t.log(`SolidAuthnLogic initialized`);function C(e){return p.fetcher.load(e)}function w(e,t=[]){return new Promise((n,r)=>{p.updater.update(e,t,function(e,t,i){t?n():r(Error(i))})})}function T(){p.statements.slice().forEach(p.remove.bind(p))}return{store:p,authn:m,acl:h,resource:S,inbox:b,chat:y,profile:v,typeIndex:x,load:C,updatePromise:w,clearStore:T}}exports.createSolidLogic=f;
2
+ //# sourceMappingURL=solidLogic.cjs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"solidLogic.cjs.js","names":[],"sources":["../../src/logic/solidLogic.ts"],"sourcesContent":["import * as rdf from 'rdflib'\nimport { LiveStore, NamedNode, Statement } from 'rdflib'\nimport { createAclLogic } from '../acl/aclLogic'\nimport { SolidAuthnLogic } from '../authn/SolidAuthnLogic'\nimport type { SessionWithLegacyEvents } from '../authSession/authSession'\nimport { createChatLogic } from '../chat/chatLogic'\nimport { createInboxLogic } from '../inbox/inboxLogic'\nimport { createResourceLogic } from '../resource/resourceLogic'\nimport { createProfileLogic } from '../profile/profileLogic'\nimport { createTypeIndexLogic } from '../typeIndex/typeIndexLogic'\nimport { createContainerLogic } from '../util/containerLogic'\nimport { createUtilityLogic } from '../util/utilityLogic'\nimport type { AuthnLogic, SolidLogic } from '../types'\nimport * as debug from '../util/debug'\n/*\n** It is important to distinquish `fetch`, a function provided by the browser\n** and `Fetcher`, a helper object for the rdflib Store which turns it\n** into a `ConnectedStore` or a `LiveStore`. A Fetcher object is\n** available at store.fetcher, and `fetch` function at `store.fetcher._fetch`,\n*/\nexport function createSolidLogic(specialFetch: { fetch: (url: any, requestInit: any) => any }, session: SessionWithLegacyEvents): SolidLogic {\n\n debug.log('SolidLogic: Unique instance created. There should only be one of these.')\n const store: LiveStore = rdf.graph() as LiveStore\n rdf.fetcher(store, {fetch: specialFetch.fetch}) // Attach a web I/O module, store.fetcher\n store.updater = new rdf.UpdateManager(store) // Add real-time live updates store.updater\n store.features = [] // disable automatic node merging on store load\n\n const authn: AuthnLogic = new SolidAuthnLogic(session)\n \n const acl = createAclLogic(store)\n const containerLogic = createContainerLogic(store)\n const utilityLogic = createUtilityLogic(store, acl, containerLogic)\n const profile = createProfileLogic(store, authn, utilityLogic)\n const chat = createChatLogic(store, profile)\n const inbox = createInboxLogic(store, profile, utilityLogic, containerLogic, acl)\n const typeIndex = createTypeIndexLogic(store, authn, profile, utilityLogic)\n const resource = createResourceLogic(store, acl, containerLogic, typeIndex)\n debug.log('SolidAuthnLogic initialized')\n\n function load(doc: NamedNode | NamedNode[] | string) {\n return store.fetcher.load(doc)\n }\n\n // @@@@ use the one in rdflib.js when it is available and delete this\n function updatePromise(\n del: Array<Statement>,\n ins: Array<Statement> = []\n ): Promise<void> {\n return new Promise((resolve, reject) => {\n store.updater.update(del, ins, function (_uri, ok, errorBody) {\n if (!ok) {\n reject(new Error(errorBody))\n } else {\n resolve()\n }\n }) // callback\n }) // promise\n }\n\n function clearStore() {\n store.statements.slice().forEach(store.remove.bind(store))\n }\n\n return {\n store,\n authn,\n acl,\n resource,\n inbox,\n chat,\n profile,\n typeIndex,\n load,\n updatePromise,\n clearStore\n }\n}\n"],"mappings":"8fAoBA,SAAgB,EAAiB,EAA8D,EAA8C,CAEzI,EAAA,IAAU,0EAA0E,EACpF,IAAM,EAAmB,EAAI,MAAM,EACnC,EAAI,QAAQ,EAAO,CAAC,MAAO,EAAa,KAAK,CAAC,EAC9C,EAAM,QAAU,IAAI,EAAI,cAAc,CAAK,EAC3C,EAAM,SAAW,CAAC,EAElB,IAAM,EAAoB,IAAI,EAAA,gBAAgB,CAAO,EAE/C,EAAM,EAAA,eAAe,CAAK,EAC1B,EAAiB,EAAA,qBAAqB,CAAK,EAC3C,EAAe,EAAA,mBAAmB,EAAO,EAAK,CAAc,EAC5D,EAAU,EAAA,mBAAmB,EAAO,EAAO,CAAY,EACvD,EAAO,EAAA,gBAAgB,EAAO,CAAO,EACrC,EAAQ,EAAA,iBAAiB,EAAO,EAAS,EAAc,EAAgB,CAAG,EAC1E,EAAY,EAAA,qBAAqB,EAAO,EAAO,EAAS,CAAY,EACpE,EAAW,EAAA,oBAAoB,EAAO,EAAK,EAAgB,CAAS,EAC1E,EAAA,IAAU,6BAA6B,EAEvC,SAAS,EAAK,EAAuC,CACjD,OAAO,EAAM,QAAQ,KAAK,CAAG,CACjC,CAGA,SAAS,EACL,EACA,EAAwB,CAAC,EACZ,CACb,OAAO,IAAI,SAAS,EAAS,IAAW,CACxC,EAAM,QAAQ,OAAO,EAAK,EAAK,SAAU,EAAM,EAAI,EAAW,CACrD,EAGL,EAAQ,EAFR,EAAW,MAAM,CAAS,CAAC,CAI/B,CAAC,CACD,CAAC,CACL,CAEA,SAAS,GAAa,CAClB,EAAM,WAAW,MAAM,CAAC,CAAC,QAAQ,EAAM,OAAO,KAAK,CAAK,CAAC,CAC7D,CAEA,MAAO,CACH,QACA,QACA,MACA,WACA,QACA,OACA,UACA,YACA,OACA,gBACA,YACJ,CACJ"}
@@ -0,0 +1,49 @@
1
+ import { log as e } from "../util/debug.esm.js";
2
+ import { createAclLogic as t } from "../acl/aclLogic.esm.js";
3
+ import { SolidAuthnLogic as n } from "../authn/SolidAuthnLogic.esm.js";
4
+ import { createChatLogic as r } from "../chat/chatLogic.esm.js";
5
+ import { createInboxLogic as i } from "../inbox/inboxLogic.esm.js";
6
+ import { createResourceLogic as a } from "../resource/resourceLogic.esm.js";
7
+ import { createContainerLogic as o } from "../util/containerLogic.esm.js";
8
+ import { createProfileLogic as s } from "../profile/profileLogic.esm.js";
9
+ import { createTypeIndexLogic as c } from "../typeIndex/typeIndexLogic.esm.js";
10
+ import { createUtilityLogic as l } from "../util/utilityLogic.esm.js";
11
+ import * as u from "rdflib";
12
+ //#region src/logic/solidLogic.ts
13
+ function d(d, f) {
14
+ e("SolidLogic: Unique instance created. There should only be one of these.");
15
+ let p = u.graph();
16
+ u.fetcher(p, { fetch: d.fetch }), p.updater = new u.UpdateManager(p), p.features = [];
17
+ let m = new n(f), h = t(p), g = o(p), _ = l(p, h, g), v = s(p, m, _), y = r(p, v), b = i(p, v, _, g, h), x = c(p, m, v, _), S = a(p, h, g, x);
18
+ e("SolidAuthnLogic initialized");
19
+ function C(e) {
20
+ return p.fetcher.load(e);
21
+ }
22
+ function w(e, t = []) {
23
+ return new Promise((n, r) => {
24
+ p.updater.update(e, t, function(e, t, i) {
25
+ t ? n() : r(Error(i));
26
+ });
27
+ });
28
+ }
29
+ function T() {
30
+ p.statements.slice().forEach(p.remove.bind(p));
31
+ }
32
+ return {
33
+ store: p,
34
+ authn: m,
35
+ acl: h,
36
+ resource: S,
37
+ inbox: b,
38
+ chat: y,
39
+ profile: v,
40
+ typeIndex: x,
41
+ load: C,
42
+ updatePromise: w,
43
+ clearStore: T
44
+ };
45
+ }
46
+ //#endregion
47
+ export { d as createSolidLogic };
48
+
49
+ //# sourceMappingURL=solidLogic.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"solidLogic.esm.js","names":[],"sources":["../../src/logic/solidLogic.ts"],"sourcesContent":["import * as rdf from 'rdflib'\nimport { LiveStore, NamedNode, Statement } from 'rdflib'\nimport { createAclLogic } from '../acl/aclLogic'\nimport { SolidAuthnLogic } from '../authn/SolidAuthnLogic'\nimport type { SessionWithLegacyEvents } from '../authSession/authSession'\nimport { createChatLogic } from '../chat/chatLogic'\nimport { createInboxLogic } from '../inbox/inboxLogic'\nimport { createResourceLogic } from '../resource/resourceLogic'\nimport { createProfileLogic } from '../profile/profileLogic'\nimport { createTypeIndexLogic } from '../typeIndex/typeIndexLogic'\nimport { createContainerLogic } from '../util/containerLogic'\nimport { createUtilityLogic } from '../util/utilityLogic'\nimport type { AuthnLogic, SolidLogic } from '../types'\nimport * as debug from '../util/debug'\n/*\n** It is important to distinquish `fetch`, a function provided by the browser\n** and `Fetcher`, a helper object for the rdflib Store which turns it\n** into a `ConnectedStore` or a `LiveStore`. A Fetcher object is\n** available at store.fetcher, and `fetch` function at `store.fetcher._fetch`,\n*/\nexport function createSolidLogic(specialFetch: { fetch: (url: any, requestInit: any) => any }, session: SessionWithLegacyEvents): SolidLogic {\n\n debug.log('SolidLogic: Unique instance created. There should only be one of these.')\n const store: LiveStore = rdf.graph() as LiveStore\n rdf.fetcher(store, {fetch: specialFetch.fetch}) // Attach a web I/O module, store.fetcher\n store.updater = new rdf.UpdateManager(store) // Add real-time live updates store.updater\n store.features = [] // disable automatic node merging on store load\n\n const authn: AuthnLogic = new SolidAuthnLogic(session)\n \n const acl = createAclLogic(store)\n const containerLogic = createContainerLogic(store)\n const utilityLogic = createUtilityLogic(store, acl, containerLogic)\n const profile = createProfileLogic(store, authn, utilityLogic)\n const chat = createChatLogic(store, profile)\n const inbox = createInboxLogic(store, profile, utilityLogic, containerLogic, acl)\n const typeIndex = createTypeIndexLogic(store, authn, profile, utilityLogic)\n const resource = createResourceLogic(store, acl, containerLogic, typeIndex)\n debug.log('SolidAuthnLogic initialized')\n\n function load(doc: NamedNode | NamedNode[] | string) {\n return store.fetcher.load(doc)\n }\n\n // @@@@ use the one in rdflib.js when it is available and delete this\n function updatePromise(\n del: Array<Statement>,\n ins: Array<Statement> = []\n ): Promise<void> {\n return new Promise((resolve, reject) => {\n store.updater.update(del, ins, function (_uri, ok, errorBody) {\n if (!ok) {\n reject(new Error(errorBody))\n } else {\n resolve()\n }\n }) // callback\n }) // promise\n }\n\n function clearStore() {\n store.statements.slice().forEach(store.remove.bind(store))\n }\n\n return {\n store,\n authn,\n acl,\n resource,\n inbox,\n chat,\n profile,\n typeIndex,\n load,\n updatePromise,\n clearStore\n }\n}\n"],"mappings":";;;;;;;;;;;;AAoBA,SAAgB,EAAiB,GAA8D,GAA8C;CAEzI,EAAU,0EAA0E;CACpF,IAAM,IAAmB,EAAI,MAAM;CAGnC,AAFA,EAAI,QAAQ,GAAO,EAAC,OAAO,EAAa,MAAK,CAAC,GAC9C,EAAM,UAAU,IAAI,EAAI,cAAc,CAAK,GAC3C,EAAM,WAAW,CAAC;CAElB,IAAM,IAAoB,IAAI,EAAgB,CAAO,GAE/C,IAAM,EAAe,CAAK,GAC1B,IAAiB,EAAqB,CAAK,GAC3C,IAAe,EAAmB,GAAO,GAAK,CAAc,GAC5D,IAAU,EAAmB,GAAO,GAAO,CAAY,GACvD,IAAO,EAAgB,GAAO,CAAO,GACrC,IAAQ,EAAiB,GAAO,GAAS,GAAc,GAAgB,CAAG,GAC1E,IAAY,EAAqB,GAAO,GAAO,GAAS,CAAY,GACpE,IAAW,EAAoB,GAAO,GAAK,GAAgB,CAAS;CAC1E,EAAU,6BAA6B;CAEvC,SAAS,EAAK,GAAuC;EACjD,OAAO,EAAM,QAAQ,KAAK,CAAG;CACjC;CAGA,SAAS,EACL,GACA,IAAwB,CAAC,GACZ;EACb,OAAO,IAAI,SAAS,GAAS,MAAW;GACxC,EAAM,QAAQ,OAAO,GAAK,GAAK,SAAU,GAAM,GAAI,GAAW;IAC1D,AAAK,IAGL,EAAQ,IAFR,EAAW,MAAM,CAAS,CAAC;GAI/B,CAAC;EACD,CAAC;CACL;CAEA,SAAS,IAAa;EAClB,EAAM,WAAW,MAAM,CAAC,CAAC,QAAQ,EAAM,OAAO,KAAK,CAAK,CAAC;CAC7D;CAEA,OAAO;EACH;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACJ;AACJ"}
@@ -0,0 +1,2 @@
1
+ const e=require("../util/debug.cjs.js"),t=require("../authSession/authSession.cjs.js"),n=require("./solidLogic.cjs.js");var r=async(e,n)=>{let r=n&&n.credentials&&n.credentials==`omit`,i=t.authSession;if((i?.info?.webId||i?.webId)&&!r){let t=typeof i.fetch==`function`?i.fetch.bind(i):typeof i.authFetch==`function`?i.authFetch.bind(i):null;return t?t(e,n):window.fetch(e,n)}else return window.fetch(e,n)},i=Symbol.for(`solid-logic-singleton`),a=typeof window<`u`?window:global;function o(){return a[i]?e.log(`SolidLogic: Using existing global singleton instance.`):(e.log(`SolidLogic: Creating new global singleton instance.`),a[i]=n.createSolidLogic({fetch:r},t.authSession),e.log(`Unique quadstore initialized.`)),a[i]}var s=o();exports.solidLogicSingleton=s;
2
+ //# sourceMappingURL=solidLogicSingleton.cjs.js.map