solid-logic 6.0.0-1 → 6.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 (39) hide show
  1. package/dist/authSession/authSession.cjs.js +1 -1
  2. package/dist/authSession/authSession.cjs.js.map +1 -1
  3. package/dist/authSession/authSession.esm.js +25 -10
  4. package/dist/authSession/authSession.esm.js.map +1 -1
  5. package/dist/authSession/events.cjs.js.map +1 -1
  6. package/dist/authSession/events.esm.js.map +1 -1
  7. package/dist/authSession/flagAuthorizationOnTransitions.cjs.js +2 -0
  8. package/dist/authSession/flagAuthorizationOnTransitions.cjs.js.map +1 -0
  9. package/dist/authSession/flagAuthorizationOnTransitions.esm.js +59 -0
  10. package/dist/authSession/flagAuthorizationOnTransitions.esm.js.map +1 -0
  11. package/dist/authSession/identityState.cjs.js +2 -0
  12. package/dist/authSession/identityState.cjs.js.map +1 -0
  13. package/dist/authSession/identityState.esm.js +198 -0
  14. package/dist/authSession/identityState.esm.js.map +1 -0
  15. package/dist/authn/SolidAuthnLogic.cjs.js +1 -1
  16. package/dist/authn/SolidAuthnLogic.cjs.js.map +1 -1
  17. package/dist/authn/SolidAuthnLogic.esm.js +47 -40
  18. package/dist/authn/SolidAuthnLogic.esm.js.map +1 -1
  19. package/dist/index.cjs.js +1 -1
  20. package/dist/index.cjs.js.map +1 -1
  21. package/dist/index.esm.js +10 -9
  22. package/dist/index.esm.js.map +1 -1
  23. package/dist/logic/solidLogic.cjs.js +1 -1
  24. package/dist/logic/solidLogic.cjs.js.map +1 -1
  25. package/dist/logic/solidLogic.esm.js +35 -30
  26. package/dist/logic/solidLogic.esm.js.map +1 -1
  27. package/dist/logic/solidLogicSingleton.cjs.js +1 -1
  28. package/dist/logic/solidLogicSingleton.cjs.js.map +1 -1
  29. package/dist/logic/solidLogicSingleton.esm.js +14 -13
  30. package/dist/logic/solidLogicSingleton.esm.js.map +1 -1
  31. package/dist/resource/resourceLogic.cjs.js +1 -1
  32. package/dist/resource/resourceLogic.cjs.js.map +1 -1
  33. package/dist/resource/resourceLogic.esm.js +0 -15
  34. package/dist/resource/resourceLogic.esm.js.map +1 -1
  35. package/dist/util/utilityLogic.cjs.js +2 -2
  36. package/dist/util/utilityLogic.cjs.js.map +1 -1
  37. package/dist/util/utilityLogic.esm.js +62 -55
  38. package/dist/util/utilityLogic.esm.js.map +1 -1
  39. package/package.json +2 -2
@@ -1 +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"}
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 { flagAuthorizationOnSessionTransitions } from '../authSession/flagAuthorizationOnTransitions'\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 // Whose credentials a request would carry changed: mark every recorded\n // response out-of-date so editability answers \"unknown\" instead of the\n // previous identity's access. Decision points repair with\n // ensureDocumentAuthorization() (see flagAuthorizationOnTransitions.ts).\n const unsubscribeAuthorization = flagAuthorizationOnSessionTransitions(store, session)\n\n const authn: AuthnLogic = new SolidAuthnLogic(session)\n\n // The subscription is released with the auth logic: both belong to this\n // instance's lifetime, so replacing a SolidLogic instance does not leave\n // the old store subscribed to the session.\n const disposeAuthn = authn.dispose?.bind(authn)\n authn.dispose = (): void => {\n unsubscribeAuthorization()\n disposeAuthn?.()\n }\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,\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A;EACA;EACA;EACA;EACA;EACA;EACA;CACJ;AACJ"}
@@ -1,2 +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;
1
+ const e=require("../util/debug.cjs.js"),t=require("../authSession/identityState.cjs.js"),n=require("../authSession/authSession.cjs.js"),r=require("./solidLogic.cjs.js");var i=async(e,r)=>{let i=r&&r.credentials&&r.credentials==`omit`,a=n.authSession;if(!t.sessionExplicitlyInactive(a)&&(a?.info?.webId||a?.webId)&&!i){let t=typeof a.fetch==`function`?a.fetch.bind(a):typeof a.authFetch==`function`?a.authFetch.bind(a):null;return t?t(e,r):window.fetch(e,r)}else return window.fetch(e,r)},a=Symbol.for(`solid-logic-singleton`),o=typeof window<`u`?window:global;function s(){return o[a]?e.log(`SolidLogic: Using existing global singleton instance.`):(e.log(`SolidLogic: Creating new global singleton instance.`),o[a]=r.createSolidLogic({fetch:i},n.authSession),e.log(`Unique quadstore initialized.`)),o[a]}var c=s();exports.solidLogicSingleton=c;
2
2
  //# sourceMappingURL=solidLogicSingleton.cjs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"solidLogicSingleton.cjs.js","names":[],"sources":["../../src/logic/solidLogicSingleton.ts"],"sourcesContent":["import * as debug from '../util/debug'\nimport { authSession } from '../authSession/authSession'\nimport { createSolidLogic } from './solidLogic'\nimport { SolidLogic } from '../types'\n\nconst _fetch = async (url, requestInit) => {\n const omitCreds = requestInit && requestInit.credentials && requestInit.credentials == 'omit'\n const sessionAny = authSession as any\n const sessionWebId = sessionAny?.info?.webId || sessionAny?.webId\n if (sessionWebId && !omitCreds) { // see https://github.com/solidos/solidos/issues/114\n // In fact fetch should respect credentials omit itself\n const authenticatedFetch = (typeof sessionAny.fetch === 'function')\n ? sessionAny.fetch.bind(sessionAny)\n : (typeof sessionAny.authFetch === 'function' ? sessionAny.authFetch.bind(sessionAny) : null)\n if (authenticatedFetch) {\n return authenticatedFetch(url, requestInit)\n }\n return window.fetch(url, requestInit)\n } else {\n return window.fetch(url, requestInit)\n }\n}\n\n// Global singleton pattern to ensure unique store across library versions\nconst SINGLETON_SYMBOL = Symbol.for('solid-logic-singleton')\n\n// Type the global object properly with the singleton\ninterface GlobalWithSingleton {\n [SINGLETON_SYMBOL]?: SolidLogic\n}\n\nconst globalTarget = (typeof window !== 'undefined' ? window : global) as GlobalWithSingleton\n\nfunction getOrCreateSingleton(): SolidLogic {\n if (!globalTarget[SINGLETON_SYMBOL]) {\n debug.log('SolidLogic: Creating new global singleton instance.')\n globalTarget[SINGLETON_SYMBOL] = createSolidLogic({ fetch: _fetch }, authSession)\n debug.log('Unique quadstore initialized.')\n } else {\n debug.log('SolidLogic: Using existing global singleton instance.')\n }\n return globalTarget[SINGLETON_SYMBOL]!\n}\n//this const makes solidLogicSingleton global accessible in mashlib\nconst solidLogicSingleton = getOrCreateSingleton()\n\nexport { solidLogicSingleton }"],"mappings":"wHAKA,IAAM,EAAS,MAAO,EAAK,IAAgB,CACvC,IAAM,EAAY,GAAe,EAAY,aAAe,EAAY,aAAe,OACjF,EAAa,EAAA,YAEnB,IADqB,GAAY,MAAM,OAAS,GAAY,QACxC,CAAC,EAAW,CAE5B,IAAM,EAAsB,OAAO,EAAW,OAAU,WAClD,EAAW,MAAM,KAAK,CAAU,EAC/B,OAAO,EAAW,WAAc,WAAa,EAAW,UAAU,KAAK,CAAU,EAAI,KAI5F,OAHI,EACO,EAAmB,EAAK,CAAW,EAEvC,OAAO,MAAM,EAAK,CAAW,CACxC,MACI,OAAO,OAAO,MAAM,EAAK,CAAW,CAE5C,EAGM,EAAmB,OAAO,IAAI,uBAAuB,EAOrD,EAAgB,OAAO,OAAW,IAAc,OAAS,OAE/D,SAAS,GAAmC,CAQxC,OAPK,EAAa,GAKd,EAAA,IAAU,uDAAuD,GAJjE,EAAA,IAAU,qDAAqD,EAC/D,EAAa,GAAoB,EAAA,iBAAiB,CAAE,MAAO,CAAO,EAAG,EAAA,WAAW,EAChF,EAAA,IAAU,+BAA+B,GAItC,EAAa,EACxB,CAEA,IAAM,EAAsB,EAAqB"}
1
+ {"version":3,"file":"solidLogicSingleton.cjs.js","names":[],"sources":["../../src/logic/solidLogicSingleton.ts"],"sourcesContent":["import * as debug from '../util/debug'\nimport { authSession } from '../authSession/authSession'\nimport { sessionExplicitlyInactive } from '../authSession/identityState'\nimport { createSolidLogic } from './solidLogic'\nimport { SolidLogic } from '../types'\n\nconst _fetch = async (url, requestInit) => {\n const omitCreds = requestInit && requestInit.credentials && requestInit.credentials == 'omit'\n const sessionAny = authSession as any\n // A session that explicitly reports itself inactive must not keep\n // identifying the last user: with a retained WebID, choosing the\n // authenticated fetch would send the previous identity's credentials.\n const sessionWebId = sessionExplicitlyInactive(sessionAny)\n ? undefined\n : (sessionAny?.info?.webId || sessionAny?.webId)\n if (sessionWebId && !omitCreds) { // see https://github.com/solidos/solidos/issues/114\n // In fact fetch should respect credentials omit itself\n const authenticatedFetch = (typeof sessionAny.fetch === 'function')\n ? sessionAny.fetch.bind(sessionAny)\n : (typeof sessionAny.authFetch === 'function' ? sessionAny.authFetch.bind(sessionAny) : null)\n if (authenticatedFetch) {\n return authenticatedFetch(url, requestInit)\n }\n return window.fetch(url, requestInit)\n } else {\n return window.fetch(url, requestInit)\n }\n}\n\n// Global singleton pattern to ensure unique store across library versions\nconst SINGLETON_SYMBOL = Symbol.for('solid-logic-singleton')\n\n// Type the global object properly with the singleton\ninterface GlobalWithSingleton {\n [SINGLETON_SYMBOL]?: SolidLogic\n}\n\nconst globalTarget = (typeof window !== 'undefined' ? window : global) as GlobalWithSingleton\n\nfunction getOrCreateSingleton(): SolidLogic {\n if (!globalTarget[SINGLETON_SYMBOL]) {\n debug.log('SolidLogic: Creating new global singleton instance.')\n globalTarget[SINGLETON_SYMBOL] = createSolidLogic({ fetch: _fetch }, authSession)\n debug.log('Unique quadstore initialized.')\n } else {\n debug.log('SolidLogic: Using existing global singleton instance.')\n }\n return globalTarget[SINGLETON_SYMBOL]!\n}\n//this const makes solidLogicSingleton global accessible in mashlib\nconst solidLogicSingleton = getOrCreateSingleton()\n\nexport { solidLogicSingleton }"],"mappings":"yKAMA,IAAM,EAAS,MAAO,EAAK,IAAgB,CACvC,IAAM,EAAY,GAAe,EAAY,aAAe,EAAY,aAAe,OACjF,EAAa,EAAA,YAOnB,GAHqB,GAAA,0BAA0B,CAAU,IAElD,GAAY,MAAM,OAAS,GAAY,QAC1B,CAAC,EAAW,CAE5B,IAAM,EAAsB,OAAO,EAAW,OAAU,WAClD,EAAW,MAAM,KAAK,CAAU,EAC/B,OAAO,EAAW,WAAc,WAAa,EAAW,UAAU,KAAK,CAAU,EAAI,KAI5F,OAHI,EACO,EAAmB,EAAK,CAAW,EAEvC,OAAO,MAAM,EAAK,CAAW,CACxC,MACI,OAAO,OAAO,MAAM,EAAK,CAAW,CAE5C,EAGM,EAAmB,OAAO,IAAI,uBAAuB,EAOrD,EAAgB,OAAO,OAAW,IAAc,OAAS,OAE/D,SAAS,GAAmC,CAQxC,OAPK,EAAa,GAKd,EAAA,IAAU,uDAAuD,GAJjE,EAAA,IAAU,qDAAqD,EAC/D,EAAa,GAAoB,EAAA,iBAAiB,CAAE,MAAO,CAAO,EAAG,EAAA,WAAW,EAChF,EAAA,IAAU,+BAA+B,GAItC,EAAa,EACxB,CAEA,IAAM,EAAsB,EAAqB"}
@@ -1,19 +1,20 @@
1
1
  import { log as e } from "../util/debug.esm.js";
2
- import { authSession as t } from "../authSession/authSession.esm.js";
3
- import { createSolidLogic as n } from "./solidLogic.esm.js";
2
+ import { sessionExplicitlyInactive as t } from "../authSession/identityState.esm.js";
3
+ import { authSession as n } from "../authSession/authSession.esm.js";
4
+ import { createSolidLogic as r } from "./solidLogic.esm.js";
4
5
  //#region src/logic/solidLogicSingleton.ts
5
- var r = async (e, n) => {
6
- let r = n && n.credentials && n.credentials == "omit", i = t;
7
- if ((i?.info?.webId || i?.webId) && !r) {
8
- let t = typeof i.fetch == "function" ? i.fetch.bind(i) : typeof i.authFetch == "function" ? i.authFetch.bind(i) : null;
9
- return t ? t(e, n) : window.fetch(e, n);
10
- } else return window.fetch(e, n);
11
- }, i = Symbol.for("solid-logic-singleton"), a = typeof window < "u" ? window : global;
12
- function o() {
13
- return a[i] ? e("SolidLogic: Using existing global singleton instance.") : (e("SolidLogic: Creating new global singleton instance."), a[i] = n({ fetch: r }, t), e("Unique quadstore initialized.")), a[i];
6
+ var i = async (e, r) => {
7
+ let i = r && r.credentials && r.credentials == "omit", a = n;
8
+ if (!t(a) && (a?.info?.webId || a?.webId) && !i) {
9
+ let t = typeof a.fetch == "function" ? a.fetch.bind(a) : typeof a.authFetch == "function" ? a.authFetch.bind(a) : null;
10
+ return t ? t(e, r) : window.fetch(e, r);
11
+ } else return window.fetch(e, r);
12
+ }, a = Symbol.for("solid-logic-singleton"), o = typeof window < "u" ? window : global;
13
+ function s() {
14
+ return o[a] ? e("SolidLogic: Using existing global singleton instance.") : (e("SolidLogic: Creating new global singleton instance."), o[a] = r({ fetch: i }, n), e("Unique quadstore initialized.")), o[a];
14
15
  }
15
- var s = o();
16
+ var c = s();
16
17
  //#endregion
17
- export { s as solidLogicSingleton };
18
+ export { c as solidLogicSingleton };
18
19
 
19
20
  //# sourceMappingURL=solidLogicSingleton.esm.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"solidLogicSingleton.esm.js","names":[],"sources":["../../src/logic/solidLogicSingleton.ts"],"sourcesContent":["import * as debug from '../util/debug'\nimport { authSession } from '../authSession/authSession'\nimport { createSolidLogic } from './solidLogic'\nimport { SolidLogic } from '../types'\n\nconst _fetch = async (url, requestInit) => {\n const omitCreds = requestInit && requestInit.credentials && requestInit.credentials == 'omit'\n const sessionAny = authSession as any\n const sessionWebId = sessionAny?.info?.webId || sessionAny?.webId\n if (sessionWebId && !omitCreds) { // see https://github.com/solidos/solidos/issues/114\n // In fact fetch should respect credentials omit itself\n const authenticatedFetch = (typeof sessionAny.fetch === 'function')\n ? sessionAny.fetch.bind(sessionAny)\n : (typeof sessionAny.authFetch === 'function' ? sessionAny.authFetch.bind(sessionAny) : null)\n if (authenticatedFetch) {\n return authenticatedFetch(url, requestInit)\n }\n return window.fetch(url, requestInit)\n } else {\n return window.fetch(url, requestInit)\n }\n}\n\n// Global singleton pattern to ensure unique store across library versions\nconst SINGLETON_SYMBOL = Symbol.for('solid-logic-singleton')\n\n// Type the global object properly with the singleton\ninterface GlobalWithSingleton {\n [SINGLETON_SYMBOL]?: SolidLogic\n}\n\nconst globalTarget = (typeof window !== 'undefined' ? window : global) as GlobalWithSingleton\n\nfunction getOrCreateSingleton(): SolidLogic {\n if (!globalTarget[SINGLETON_SYMBOL]) {\n debug.log('SolidLogic: Creating new global singleton instance.')\n globalTarget[SINGLETON_SYMBOL] = createSolidLogic({ fetch: _fetch }, authSession)\n debug.log('Unique quadstore initialized.')\n } else {\n debug.log('SolidLogic: Using existing global singleton instance.')\n }\n return globalTarget[SINGLETON_SYMBOL]!\n}\n//this const makes solidLogicSingleton global accessible in mashlib\nconst solidLogicSingleton = getOrCreateSingleton()\n\nexport { solidLogicSingleton }"],"mappings":";;;;AAKA,IAAM,IAAS,OAAO,GAAK,MAAgB;CACvC,IAAM,IAAY,KAAe,EAAY,eAAe,EAAY,eAAe,QACjF,IAAa;CAEnB,KADqB,GAAY,MAAM,SAAS,GAAY,UACxC,CAAC,GAAW;EAE5B,IAAM,IAAsB,OAAO,EAAW,SAAU,aAClD,EAAW,MAAM,KAAK,CAAU,IAC/B,OAAO,EAAW,aAAc,aAAa,EAAW,UAAU,KAAK,CAAU,IAAI;EAI5F,OAHI,IACO,EAAmB,GAAK,CAAW,IAEvC,OAAO,MAAM,GAAK,CAAW;CACxC,OACI,OAAO,OAAO,MAAM,GAAK,CAAW;AAE5C,GAGM,IAAmB,OAAO,IAAI,uBAAuB,GAOrD,IAAgB,OAAO,SAAW,MAAc,SAAS;AAE/D,SAAS,IAAmC;CAQxC,OAPK,EAAa,KAKd,EAAU,uDAAuD,KAJjE,EAAU,qDAAqD,GAC/D,EAAa,KAAoB,EAAiB,EAAE,OAAO,EAAO,GAAG,CAAW,GAChF,EAAU,+BAA+B,IAItC,EAAa;AACxB;AAEA,IAAM,IAAsB,EAAqB"}
1
+ {"version":3,"file":"solidLogicSingleton.esm.js","names":[],"sources":["../../src/logic/solidLogicSingleton.ts"],"sourcesContent":["import * as debug from '../util/debug'\nimport { authSession } from '../authSession/authSession'\nimport { sessionExplicitlyInactive } from '../authSession/identityState'\nimport { createSolidLogic } from './solidLogic'\nimport { SolidLogic } from '../types'\n\nconst _fetch = async (url, requestInit) => {\n const omitCreds = requestInit && requestInit.credentials && requestInit.credentials == 'omit'\n const sessionAny = authSession as any\n // A session that explicitly reports itself inactive must not keep\n // identifying the last user: with a retained WebID, choosing the\n // authenticated fetch would send the previous identity's credentials.\n const sessionWebId = sessionExplicitlyInactive(sessionAny)\n ? undefined\n : (sessionAny?.info?.webId || sessionAny?.webId)\n if (sessionWebId && !omitCreds) { // see https://github.com/solidos/solidos/issues/114\n // In fact fetch should respect credentials omit itself\n const authenticatedFetch = (typeof sessionAny.fetch === 'function')\n ? sessionAny.fetch.bind(sessionAny)\n : (typeof sessionAny.authFetch === 'function' ? sessionAny.authFetch.bind(sessionAny) : null)\n if (authenticatedFetch) {\n return authenticatedFetch(url, requestInit)\n }\n return window.fetch(url, requestInit)\n } else {\n return window.fetch(url, requestInit)\n }\n}\n\n// Global singleton pattern to ensure unique store across library versions\nconst SINGLETON_SYMBOL = Symbol.for('solid-logic-singleton')\n\n// Type the global object properly with the singleton\ninterface GlobalWithSingleton {\n [SINGLETON_SYMBOL]?: SolidLogic\n}\n\nconst globalTarget = (typeof window !== 'undefined' ? window : global) as GlobalWithSingleton\n\nfunction getOrCreateSingleton(): SolidLogic {\n if (!globalTarget[SINGLETON_SYMBOL]) {\n debug.log('SolidLogic: Creating new global singleton instance.')\n globalTarget[SINGLETON_SYMBOL] = createSolidLogic({ fetch: _fetch }, authSession)\n debug.log('Unique quadstore initialized.')\n } else {\n debug.log('SolidLogic: Using existing global singleton instance.')\n }\n return globalTarget[SINGLETON_SYMBOL]!\n}\n//this const makes solidLogicSingleton global accessible in mashlib\nconst solidLogicSingleton = getOrCreateSingleton()\n\nexport { solidLogicSingleton }"],"mappings":";;;;;AAMA,IAAM,IAAS,OAAO,GAAK,MAAgB;CACvC,IAAM,IAAY,KAAe,EAAY,eAAe,EAAY,eAAe,QACjF,IAAa;CAOnB,IAHqB,GAA0B,CAAU,MAElD,GAAY,MAAM,SAAS,GAAY,UAC1B,CAAC,GAAW;EAE5B,IAAM,IAAsB,OAAO,EAAW,SAAU,aAClD,EAAW,MAAM,KAAK,CAAU,IAC/B,OAAO,EAAW,aAAc,aAAa,EAAW,UAAU,KAAK,CAAU,IAAI;EAI5F,OAHI,IACO,EAAmB,GAAK,CAAW,IAEvC,OAAO,MAAM,GAAK,CAAW;CACxC,OACI,OAAO,OAAO,MAAM,GAAK,CAAW;AAE5C,GAGM,IAAmB,OAAO,IAAI,uBAAuB,GAOrD,IAAgB,OAAO,SAAW,MAAc,SAAS;AAE/D,SAAS,IAAmC;CAQxC,OAPK,EAAa,KAKd,EAAU,uDAAuD,KAJjE,EAAU,qDAAqD,GAC/D,EAAa,KAAoB,EAAiB,EAAE,OAAO,EAAO,GAAG,CAAW,GAChF,EAAU,+BAA+B,IAItC,EAAa;AACxB;AAEA,IAAM,IAAsB,EAAqB"}
@@ -1,2 +1,2 @@
1
- const e=require("../util/ns.cjs.js"),t=require("../acl/aclLogic.cjs.js"),n=require("./resourceHttp.cjs.js"),r=require("./resourceMetadata.cjs.js");let i=require("rdflib");function a(a,o,s,c){function l(e){return s.createContainer(e)}function u(e){return s.isContainer(e)}function d(e){return s.getContainerMemberCount(e)}function f(n,i){let o,s=!1,c=!1,l,u;if(i.headers){o=i.headers.get(`content-type`)?.split(`;`)[0]??void 0;let t=r.readWacAccessInfo(i.headers.get(`wac-allow`));s=t.canEdit,c=t.isPublic,l=i.headers.get(`etag`)??void 0,u=a.anyValue(n,e.ns.dct(`modified`))||a.anyValue(n,e.ns.dc(`modified`))||void 0}(!i.headers||!i.headers.get(`content-type`))&&(!i.headers||!i.headers.get(`wac-allow`)||!i.headers.get(`etag`))&&a.each(null,a.sym(`http://www.w3.org/2007/ont/link#requestedURI`),n).map(t=>{let i=a.any(t,a.sym(`http://www.w3.org/2007/ont/link#response`));if(i&&i.termType===`NamedNode`){let t=a.anyValue(i,e.ns.httph(`content-type`))||void 0;o===void 0&&(o=t);let d=r.readWacAccessInfo(a.anyValue(i,e.ns.httph(`wac-allow`))||a.anyValue(i,e.ns.httph(`WAC-Allow`)));s||=d.canEdit,c||=d.isPublic;let f=a.anyValue(i,e.ns.httph(`etag`))||void 0;l===void 0&&(l=f),u=a.anyValue(n,e.ns.dct(`modified`))||a.anyValue(n,e.ns.dc(`modified`))||void 0}});let d=a.any(n,t.ACL_LINK)?.value||void 0;return{contentType:o,access:{canEdit:s,isPublic:c},aclUri:d,eTag:l,modified:u}}async function p(e){let t=await a.fetcher.webOperation(`HEAD`,e.uri);return n.assertSuccessfulHttpResponse(t,`HEAD`),f(e,t)}async function m(t){let n=a.any(t,e.ns.ldp(`contains`))||t.dir();if(!n||n.termType!==`NamedNode`)return!1;try{return(await p(n)).access.canEdit}catch{return!1}}async function h(e){return m(e)}async function g(e){return p(e)}async function _(e){let t;try{t=await p(e)}catch{t={contentType:void 0,access:{canEdit:!1,isPublic:!1},aclUri:void 0,eTag:void 0,modified:void 0}}let n=await h(e),r={canEdit:t.access?.canEdit??!1,isPublic:t.access?.isPublic??!1,canDelete:n};return{...t,access:r}}async function v(e,t){if(t)try{await c.deleteTypeIndexRegistrationForResource(e,t)}catch{}}async function y(t,r={}){let o=t.dir();if(u(t)){let e=await s.getContainerMembers(t);await Promise.all(e.map(e=>y((0,i.sym)(e),r)))}let c;try{c=await a.fetcher._fetch(t.value,{method:`DELETE`}),n.assertSuccessfulHttpResponse(c,`DELETE`,{allowNotFound:!0})}catch(e){if(!n.isMissingError(e))throw e}return r.deleteTypeIndexes&&await v(t,r.user),o&&a.removeMatches(o,e.ns.ldp(`contains`),t,o.doc()),a.removeDocument(t),a.fetcher.unload(t.doc()),c}async function b(e,t){await y(e,{deleteTypeIndexes:!0,user:t})}async function x(e){if(!e||!a.updater||!a.fetcher||typeof a.fetcher.refresh!=`function`)return!1;let t=e.uri||e.value||``;if(!t)return!1;let n=a.updater.editable(t,a);if(n!==!1&&n!==void 0)return!0;try{await a.fetcher.refresh(e)}catch(e){throw e instanceof Error?e:Error(`Failed to refresh <${t}>`)}let r=a.updater.editable(t,a);return r!==!1&&r!==void 0}return{recursiveDelete:y,deleteResourceAndTypeIndexIfExists:b,fetchMetadata:g,fetchMetadataWithDelete:_,checkAndRefreshEditable:x,createContainer:l,isContainer:u,getContainerMemberCount:d}}exports.createResourceLogic=a;
1
+ const e=require("../util/ns.cjs.js"),t=require("../acl/aclLogic.cjs.js"),n=require("./resourceHttp.cjs.js"),r=require("./resourceMetadata.cjs.js");let i=require("rdflib");function a(a,o,s,c){function l(e){return s.createContainer(e)}function u(e){return s.isContainer(e)}function d(e){return s.getContainerMemberCount(e)}function f(n,i){let o,s=!1,c=!1,l,u;if(i.headers){o=i.headers.get(`content-type`)?.split(`;`)[0]??void 0;let t=r.readWacAccessInfo(i.headers.get(`wac-allow`));s=t.canEdit,c=t.isPublic,l=i.headers.get(`etag`)??void 0,u=a.anyValue(n,e.ns.dct(`modified`))||a.anyValue(n,e.ns.dc(`modified`))||void 0}(!i.headers||!i.headers.get(`content-type`))&&(!i.headers||!i.headers.get(`wac-allow`)||!i.headers.get(`etag`))&&a.each(null,a.sym(`http://www.w3.org/2007/ont/link#requestedURI`),n).map(t=>{let i=a.any(t,a.sym(`http://www.w3.org/2007/ont/link#response`));if(i&&i.termType===`NamedNode`){let t=a.anyValue(i,e.ns.httph(`content-type`))||void 0;o===void 0&&(o=t);let d=r.readWacAccessInfo(a.anyValue(i,e.ns.httph(`wac-allow`))||a.anyValue(i,e.ns.httph(`WAC-Allow`)));s||=d.canEdit,c||=d.isPublic;let f=a.anyValue(i,e.ns.httph(`etag`))||void 0;l===void 0&&(l=f),u=a.anyValue(n,e.ns.dct(`modified`))||a.anyValue(n,e.ns.dc(`modified`))||void 0}});let d=a.any(n,t.ACL_LINK)?.value||void 0;return{contentType:o,access:{canEdit:s,isPublic:c},aclUri:d,eTag:l,modified:u}}async function p(e){let t=await a.fetcher.webOperation(`HEAD`,e.uri);return n.assertSuccessfulHttpResponse(t,`HEAD`),f(e,t)}async function m(t){let n=a.any(t,e.ns.ldp(`contains`))||t.dir();if(!n||n.termType!==`NamedNode`)return!1;try{return(await p(n)).access.canEdit}catch{return!1}}async function h(e){return m(e)}async function g(e){return p(e)}async function _(e){let t;try{t=await p(e)}catch{t={contentType:void 0,access:{canEdit:!1,isPublic:!1},aclUri:void 0,eTag:void 0,modified:void 0}}let n=await h(e),r={canEdit:t.access?.canEdit??!1,isPublic:t.access?.isPublic??!1,canDelete:n};return{...t,access:r}}async function v(e,t){if(t)try{await c.deleteTypeIndexRegistrationForResource(e,t)}catch{}}async function y(t,r={}){let o=t.dir();if(u(t)){let e=await s.getContainerMembers(t);await Promise.all(e.map(e=>y((0,i.sym)(e),r)))}let c;try{c=await a.fetcher._fetch(t.value,{method:`DELETE`}),n.assertSuccessfulHttpResponse(c,`DELETE`,{allowNotFound:!0})}catch(e){if(!n.isMissingError(e))throw e}return r.deleteTypeIndexes&&await v(t,r.user),o&&a.removeMatches(o,e.ns.ldp(`contains`),t,o.doc()),a.removeDocument(t),a.fetcher.unload(t.doc()),c}async function b(e,t){await y(e,{deleteTypeIndexes:!0,user:t})}return{recursiveDelete:y,deleteResourceAndTypeIndexIfExists:b,fetchMetadata:g,fetchMetadataWithDelete:_,createContainer:l,isContainer:u,getContainerMemberCount:d}}exports.createResourceLogic=a;
2
2
  //# sourceMappingURL=resourceLogic.cjs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"resourceLogic.cjs.js","names":[],"sources":["../../src/resource/resourceLogic.ts"],"sourcesContent":["import { NamedNode, sym, LiveStore } from 'rdflib'\nimport { ACL_LINK } from '../acl/aclLogic'\nimport { ns } from '../util/ns'\nimport { assertSuccessfulHttpResponse, isMissingError } from './resourceHttp'\nimport { readWacAccessInfo } from './resourceMetadata'\nimport { type AclLogic, type ResourceAccess, type ResourceAccessWithDelete, type ResourceDeleteOptions, type ResourceLogic, type ResourceMetadata, type ResourceMetadataWithDelete, type TypeIndexLogic } from '../types'\n\nexport function createResourceLogic(store: LiveStore, aclLogic: AclLogic, containerLogic, typeIndexLogic: TypeIndexLogic): ResourceLogic {\n function createContainer(url: string) {\n return containerLogic.createContainer(url)\n }\n\n function isContainer(resourceNode: NamedNode) {\n return containerLogic.isContainer(resourceNode)\n }\n\n function getContainerMemberCount(resourceNode: NamedNode) {\n return containerLogic.getContainerMemberCount(resourceNode)\n }\n\n function readMetadata(subject: NamedNode, response: Response): ResourceMetadata {\n let contentType: string | undefined\n let canEdit = false\n let isPublic = false\n let eTag: string | undefined\n let modified: string | undefined\n\n if (response.headers) {\n const contentTypeHeader = response.headers.get('content-type')\n contentType = contentTypeHeader?.split(';')[0] ?? undefined\n\n const accessFlags = readWacAccessInfo(response.headers.get('wac-allow'))\n canEdit = accessFlags.canEdit\n isPublic = accessFlags.isPublic\n eTag = response.headers.get('etag') ?? undefined\n modified = store.anyValue(subject as any, ns.dct('modified')) || store.anyValue(subject as any, ns.dc('modified')) || undefined\n }\n\n if ((!response.headers || !response.headers.get('content-type')) && (!response.headers || !response.headers.get('wac-allow') || !response.headers.get('etag'))) {\n const reqs = store.each(\n null,\n store.sym('http://www.w3.org/2007/ont/link#requestedURI'),\n subject\n )\n reqs.map((req: any) => {\n const responseNode = store.any(\n req as any,\n store.sym('http://www.w3.org/2007/ont/link#response')\n )\n if (responseNode && responseNode.termType === 'NamedNode') {\n const responseContentType = store.anyValue(responseNode as any, ns.httph('content-type')) || undefined\n if (contentType === undefined) {\n contentType = responseContentType\n }\n const wacAllow = (store.anyValue(responseNode as any, ns.httph('wac-allow')) as string | undefined) ||\n (store.anyValue(responseNode as any, ns.httph('WAC-Allow')) as string | undefined)\n const accessFlags = readWacAccessInfo(wacAllow)\n canEdit = canEdit || accessFlags.canEdit\n isPublic = isPublic || accessFlags.isPublic\n const responseETag = store.anyValue(responseNode as any, ns.httph('etag')) || undefined\n if (eTag === undefined) {\n eTag = responseETag\n }\n modified = store.anyValue(subject as any, ns.dct('modified')) || store.anyValue(subject as any, ns.dc('modified')) || undefined\n }\n })\n }\n\n const aclUri = store.any(subject, ACL_LINK)?.value || undefined\n const access: ResourceAccess = { canEdit, isPublic }\n return { contentType, access, aclUri, eTag, modified }\n }\n\n async function fetchHeadMetadata(subject: NamedNode): Promise<ResourceMetadata> {\n const response = await store.fetcher.webOperation('HEAD', subject.uri)\n assertSuccessfulHttpResponse(response, 'HEAD')\n return readMetadata(subject, response)\n }\n\n async function userCanWriteToContainingContainer(resourceNode: NamedNode): Promise<boolean> {\n const containerNode = store.any(resourceNode, ns.ldp('contains')) || resourceNode.dir()\n if (!containerNode || containerNode.termType !== 'NamedNode') {\n return false\n }\n\n try {\n const containerMetadata = await fetchHeadMetadata(containerNode as NamedNode)\n return containerMetadata.access.canEdit\n } catch (_error) {\n return false\n }\n }\n\n async function userCanDeleteResource(resourceNode: NamedNode): Promise<boolean> {\n return userCanWriteToContainingContainer(resourceNode)\n }\n\n async function fetchMetadata(subject: NamedNode): Promise<ResourceMetadata> {\n return fetchHeadMetadata(subject)\n }\n\n async function fetchMetadataWithDelete(subject: NamedNode): Promise<ResourceMetadataWithDelete> {\n let resourceMetadata: ResourceMetadata\n\n try {\n resourceMetadata = await fetchHeadMetadata(subject)\n } catch (_error) {\n resourceMetadata = {\n contentType: undefined,\n access: { canEdit: false, isPublic: false },\n aclUri: undefined,\n eTag: undefined,\n modified: undefined\n }\n }\n\n const canDelete = await userCanDeleteResource(subject)\n const access: ResourceAccessWithDelete = {\n canEdit: resourceMetadata.access?.canEdit ?? false,\n isPublic: resourceMetadata.access?.isPublic ?? false,\n canDelete\n }\n return { ...resourceMetadata, access }\n }\n\n async function deleteTypeIndexesForResource(resourceNode: NamedNode, user?: NamedNode | null) {\n if (!user) return\n\n try {\n await typeIndexLogic.deleteTypeIndexRegistrationForResource(resourceNode, user)\n } catch (_error) {\n // Keep resource deletion best-effort even if type-index cleanup fails.\n }\n }\n\n async function recursiveDelete(resourceNode: NamedNode, options: ResourceDeleteOptions = {}) {\n const resourceParent = resourceNode.dir()\n\n if (isContainer(resourceNode)) {\n const containerMembers = await containerLogic.getContainerMembers(resourceNode)\n await Promise.all(containerMembers.map((url) => recursiveDelete(sym(url), options)))\n }\n\n let deleted\n try {\n deleted = await store.fetcher._fetch(resourceNode.value, { method: 'DELETE' })\n assertSuccessfulHttpResponse(deleted, 'DELETE', { allowNotFound: true })\n } catch (error) {\n if (!isMissingError(error)) {\n throw error\n }\n }\n\n if (options.deleteTypeIndexes) {\n await deleteTypeIndexesForResource(resourceNode, options.user)\n }\n\n if (resourceParent) {\n store.removeMatches(resourceParent, ns.ldp('contains'), resourceNode, resourceParent.doc())\n }\n\n store.removeDocument(resourceNode)\n store.fetcher.unload(resourceNode.doc())\n return deleted\n }\n\n async function deleteResourceAndTypeIndexIfExists(resourceNode: NamedNode, user?: NamedNode | null) {\n await recursiveDelete(resourceNode, { deleteTypeIndexes: true, user })\n }\n\n async function checkAndRefreshEditable(resourceNode: NamedNode | null | undefined): Promise<boolean> {\n if (!resourceNode || !store.updater || !store.fetcher || typeof store.fetcher.refresh !== 'function') return false\n\n const resourceUri = resourceNode.uri || resourceNode.value || ''\n if (!resourceUri) return false\n\n const editable = store.updater.editable(resourceUri, store)\n if (editable !== false && editable !== undefined) {\n return true\n }\n\n try {\n await store.fetcher.refresh(resourceNode)\n } catch (error) {\n throw error instanceof Error ? error : new Error(`Failed to refresh <${resourceUri}>`)\n }\n\n const editableAfterRefresh = store.updater.editable(resourceUri, store)\n return editableAfterRefresh !== false && editableAfterRefresh !== undefined\n }\n\n return {\n recursiveDelete,\n deleteResourceAndTypeIndexIfExists,\n fetchMetadata,\n fetchMetadataWithDelete,\n checkAndRefreshEditable,\n createContainer,\n isContainer,\n getContainerMemberCount\n }\n}\n"],"mappings":"2KAOA,SAAgB,EAAoB,EAAkB,EAAoB,EAAgB,EAA+C,CACvI,SAAS,EAAgB,EAAa,CACpC,OAAO,EAAe,gBAAgB,CAAG,CAC3C,CAEA,SAAS,EAAY,EAAyB,CAC5C,OAAO,EAAe,YAAY,CAAY,CAChD,CAEA,SAAS,EAAwB,EAAyB,CACxD,OAAO,EAAe,wBAAwB,CAAY,CAC5D,CAEA,SAAS,EAAa,EAAoB,EAAsC,CAC9E,IAAI,EACA,EAAU,GACV,EAAW,GACX,EACA,EAEJ,GAAI,EAAS,QAAS,CAEpB,EAD0B,EAAS,QAAQ,IAAI,cACjC,CAAA,EAAmB,MAAM,GAAG,CAAC,CAAC,IAAM,IAAA,GAElD,IAAM,EAAc,EAAA,kBAAkB,EAAS,QAAQ,IAAI,WAAW,CAAC,EACvE,EAAU,EAAY,QACtB,EAAW,EAAY,SACvB,EAAO,EAAS,QAAQ,IAAI,MAAM,GAAK,IAAA,GACvC,EAAW,EAAM,SAAS,EAAgB,EAAA,GAAG,IAAI,UAAU,CAAC,GAAK,EAAM,SAAS,EAAgB,EAAA,GAAG,GAAG,UAAU,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QAAS,CAAC,EAC7E,EAAA,6BAA6B,EAAS,SAAU,CAAE,cAAe,EAAK,CAAC,CACzE,OAAS,EAAO,CACd,GAAI,CAAC,EAAA,eAAe,CAAK,EACvB,MAAM,CAEV,CAYA,OAVI,EAAQ,mBACV,MAAM,EAA6B,EAAc,EAAQ,IAAI,EAG3D,GACF,EAAM,cAAc,EAAgB,EAAA,GAAG,IAAI,UAAU,EAAG,EAAc,EAAe,IAAI,CAAC,EAG5F,EAAM,eAAe,CAAY,EACjC,EAAM,QAAQ,OAAO,EAAa,IAAI,CAAC,EAChC,CACT,CAEA,eAAe,EAAmC,EAAyB,EAAyB,CAClG,MAAM,EAAgB,EAAc,CAAE,kBAAmB,GAAM,MAAK,CAAC,CACvE,CAEA,eAAe,EAAwB,EAA8D,CACnG,GAAI,CAAC,GAAgB,CAAC,EAAM,SAAW,CAAC,EAAM,SAAW,OAAO,EAAM,QAAQ,SAAY,WAAY,MAAO,GAE7G,IAAM,EAAc,EAAa,KAAO,EAAa,OAAS,GAC9D,GAAI,CAAC,EAAa,MAAO,GAEzB,IAAM,EAAW,EAAM,QAAQ,SAAS,EAAa,CAAK,EAC1D,GAAI,IAAa,IAAS,IAAa,IAAA,GACrC,MAAO,GAGT,GAAI,CACF,MAAM,EAAM,QAAQ,QAAQ,CAAY,CAC1C,OAAS,EAAO,CACd,MAAM,aAAiB,MAAQ,EAAY,MAAM,sBAAsB,EAAY,EAAE,CACvF,CAEA,IAAM,EAAuB,EAAM,QAAQ,SAAS,EAAa,CAAK,EACtE,OAAO,IAAyB,IAAS,IAAyB,IAAA,EACpE,CAEA,MAAO,CACL,kBACA,qCACA,gBACA,0BACA,0BACA,kBACA,cACA,yBACF,CACF"}
1
+ {"version":3,"file":"resourceLogic.cjs.js","names":[],"sources":["../../src/resource/resourceLogic.ts"],"sourcesContent":["import { NamedNode, sym } from 'rdflib'\nimport { ACL_LINK } from '../acl/aclLogic'\nimport { ns } from '../util/ns'\nimport { assertSuccessfulHttpResponse, isMissingError } from './resourceHttp'\nimport { readWacAccessInfo } from './resourceMetadata'\nimport { type AclLogic, type ResourceAccess, type ResourceAccessWithDelete, type ResourceDeleteOptions, type ResourceLogic, type ResourceMetadata, type ResourceMetadataWithDelete, type TypeIndexLogic } from '../types'\n\nexport function createResourceLogic(store, aclLogic: AclLogic, containerLogic, typeIndexLogic: TypeIndexLogic): ResourceLogic {\n function createContainer(url: string) {\n return containerLogic.createContainer(url)\n }\n\n function isContainer(resourceNode: NamedNode) {\n return containerLogic.isContainer(resourceNode)\n }\n\n function getContainerMemberCount(resourceNode: NamedNode) {\n return containerLogic.getContainerMemberCount(resourceNode)\n }\n\n function readMetadata(subject: NamedNode, response: Response): ResourceMetadata {\n let contentType: string | undefined\n let canEdit = false\n let isPublic = false\n let eTag: string | undefined\n let modified: string | undefined\n\n if (response.headers) {\n const contentTypeHeader = response.headers.get('content-type')\n contentType = contentTypeHeader?.split(';')[0] ?? undefined\n\n const accessFlags = readWacAccessInfo(response.headers.get('wac-allow'))\n canEdit = accessFlags.canEdit\n isPublic = accessFlags.isPublic\n eTag = response.headers.get('etag') ?? undefined\n modified = store.anyValue(subject as any, ns.dct('modified')) || store.anyValue(subject as any, ns.dc('modified')) || undefined\n }\n\n if ((!response.headers || !response.headers.get('content-type')) && (!response.headers || !response.headers.get('wac-allow') || !response.headers.get('etag'))) {\n const reqs = store.each(\n null,\n store.sym('http://www.w3.org/2007/ont/link#requestedURI'),\n subject\n )\n reqs.map((req: any) => {\n const responseNode = store.any(\n req as any,\n store.sym('http://www.w3.org/2007/ont/link#response')\n )\n if (responseNode && responseNode.termType === 'NamedNode') {\n const responseContentType = store.anyValue(responseNode as any, ns.httph('content-type')) || undefined\n if (contentType === undefined) {\n contentType = responseContentType\n }\n const wacAllow = (store.anyValue(responseNode as any, ns.httph('wac-allow')) as string | undefined) ||\n (store.anyValue(responseNode as any, ns.httph('WAC-Allow')) as string | undefined)\n const accessFlags = readWacAccessInfo(wacAllow)\n canEdit = canEdit || accessFlags.canEdit\n isPublic = isPublic || accessFlags.isPublic\n const responseETag = store.anyValue(responseNode as any, ns.httph('etag')) || undefined\n if (eTag === undefined) {\n eTag = responseETag\n }\n modified = store.anyValue(subject as any, ns.dct('modified')) || store.anyValue(subject as any, ns.dc('modified')) || undefined\n }\n })\n }\n\n const aclUri = store.any(subject, ACL_LINK)?.value || undefined\n const access: ResourceAccess = { canEdit, isPublic }\n return { contentType, access, aclUri, eTag, modified }\n }\n\n async function fetchHeadMetadata(subject: NamedNode): Promise<ResourceMetadata> {\n const response = await store.fetcher.webOperation('HEAD', subject.uri)\n assertSuccessfulHttpResponse(response, 'HEAD')\n return readMetadata(subject, response)\n }\n\n async function userCanWriteToContainingContainer(resourceNode: NamedNode): Promise<boolean> {\n const containerNode = store.any(resourceNode, ns.ldp('contains')) || resourceNode.dir()\n if (!containerNode || containerNode.termType !== 'NamedNode') {\n return false\n }\n\n try {\n const containerMetadata = await fetchHeadMetadata(containerNode as NamedNode)\n return containerMetadata.access.canEdit\n } catch (_error) {\n return false\n }\n }\n\n async function userCanDeleteResource(resourceNode: NamedNode): Promise<boolean> {\n return userCanWriteToContainingContainer(resourceNode)\n }\n\n async function fetchMetadata(subject: NamedNode): Promise<ResourceMetadata> {\n return fetchHeadMetadata(subject)\n }\n\n async function fetchMetadataWithDelete(subject: NamedNode): Promise<ResourceMetadataWithDelete> {\n let resourceMetadata: ResourceMetadata\n\n try {\n resourceMetadata = await fetchHeadMetadata(subject)\n } catch (_error) {\n resourceMetadata = {\n contentType: undefined,\n access: { canEdit: false, isPublic: false },\n aclUri: undefined,\n eTag: undefined,\n modified: undefined\n }\n }\n\n const canDelete = await userCanDeleteResource(subject)\n const access: ResourceAccessWithDelete = {\n canEdit: resourceMetadata.access?.canEdit ?? false,\n isPublic: resourceMetadata.access?.isPublic ?? false,\n canDelete\n }\n return { ...resourceMetadata, access }\n }\n\n async function deleteTypeIndexesForResource(resourceNode: NamedNode, user?: NamedNode | null) {\n if (!user) return\n\n try {\n await typeIndexLogic.deleteTypeIndexRegistrationForResource(resourceNode, user)\n } catch (_error) {\n // Keep resource deletion best-effort even if type-index cleanup fails.\n }\n }\n\n async function recursiveDelete(resourceNode: NamedNode, options: ResourceDeleteOptions = {}) {\n const resourceParent = resourceNode.dir()\n\n if (isContainer(resourceNode)) {\n const containerMembers = await containerLogic.getContainerMembers(resourceNode)\n await Promise.all(containerMembers.map((url) => recursiveDelete(sym(url), options)))\n }\n\n let deleted\n try {\n deleted = await store.fetcher._fetch(resourceNode.value, { method: 'DELETE' })\n assertSuccessfulHttpResponse(deleted, 'DELETE', { allowNotFound: true })\n } catch (error) {\n if (!isMissingError(error)) {\n throw error\n }\n }\n\n if (options.deleteTypeIndexes) {\n await deleteTypeIndexesForResource(resourceNode, options.user)\n }\n\n if (resourceParent) {\n store.removeMatches(resourceParent, ns.ldp('contains'), resourceNode, resourceParent.doc())\n }\n\n store.removeDocument(resourceNode)\n store.fetcher.unload(resourceNode.doc())\n return deleted\n }\n\n async function deleteResourceAndTypeIndexIfExists(resourceNode: NamedNode, user?: NamedNode | null) {\n await recursiveDelete(resourceNode, { deleteTypeIndexes: true, user })\n }\n\n return {\n recursiveDelete,\n deleteResourceAndTypeIndexIfExists,\n fetchMetadata,\n fetchMetadataWithDelete,\n createContainer,\n isContainer,\n getContainerMemberCount\n }\n}\n"],"mappings":"2KAOA,SAAgB,EAAoB,EAAO,EAAoB,EAAgB,EAA+C,CAC5H,SAAS,EAAgB,EAAa,CACpC,OAAO,EAAe,gBAAgB,CAAG,CAC3C,CAEA,SAAS,EAAY,EAAyB,CAC5C,OAAO,EAAe,YAAY,CAAY,CAChD,CAEA,SAAS,EAAwB,EAAyB,CACxD,OAAO,EAAe,wBAAwB,CAAY,CAC5D,CAEA,SAAS,EAAa,EAAoB,EAAsC,CAC9E,IAAI,EACA,EAAU,GACV,EAAW,GACX,EACA,EAEJ,GAAI,EAAS,QAAS,CAEpB,EAD0B,EAAS,QAAQ,IAAI,cACjC,CAAA,EA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AAM,EAAiB,EAAa,IAAI,EAExC,GAAI,EAAY,CAAY,EAAG,CAC7B,IAAM,EAAmB,MAAM,EAAe,oBAAoB,CAAY,EAC9E,MAAM,QAAQ,IAAI,EAAiB,IAAK,GAAQ,GAAA,EAAA,EAAA,IAAA,CAAoB,CAAG,EAAG,CAAO,CAAC,CAAC,CACrF,CAEA,IAAI,EACJ,GAAI,CACF,EAAU,MAAM,EAAM,QAAQ,OAAO,EAAa,MAAO,CAAE,OAAQ,QAAS,CAAC,EAC7E,EAAA,6BAA6B,EAAS,SAAU,CAAE,cAAe,EAAK,CAAC,CACzE,OAAS,EAAO,CACd,GAAI,CAAC,EAAA,eAAe,CAAK,EACvB,MAAM,CAEV,CAYA,OAVI,EAAQ,mBACV,MAAM,EAA6B,EAAc,EAAQ,IAAI,EAG3D,GACF,EAAM,cAAc,EAAgB,EAAA,GAAG,IAAI,UAAU,EAAG,EAAc,EAAe,IAAI,CAAC,EAG5F,EAAM,eAAe,CAAY,EACjC,EAAM,QAAQ,OAAO,EAAa,IAAI,CAAC,EAChC,CACT,CAEA,eAAe,EAAmC,EAAyB,EAAyB,CAClG,MAAM,EAAgB,EAAc,CAAE,kBAAmB,GAAM,MAAK,CAAC,CACvE,CAEA,MAAO,CACL,kBACA,qCACA,gBACA,0BACA,kBACA,cACA,yBACF,CACF"}
@@ -114,26 +114,11 @@ function o(o, s, c, l) {
114
114
  user: t
115
115
  });
116
116
  }
117
- async function S(e) {
118
- if (!e || !o.updater || !o.fetcher || typeof o.fetcher.refresh != "function") return !1;
119
- let t = e.uri || e.value || "";
120
- if (!t) return !1;
121
- let n = o.updater.editable(t, o);
122
- if (n !== !1 && n !== void 0) return !0;
123
- try {
124
- await o.fetcher.refresh(e);
125
- } catch (e) {
126
- throw e instanceof Error ? e : /* @__PURE__ */ Error(`Failed to refresh <${t}>`);
127
- }
128
- let r = o.updater.editable(t, o);
129
- return r !== !1 && r !== void 0;
130
- }
131
117
  return {
132
118
  recursiveDelete: b,
133
119
  deleteResourceAndTypeIndexIfExists: x,
134
120
  fetchMetadata: _,
135
121
  fetchMetadataWithDelete: v,
136
- checkAndRefreshEditable: S,
137
122
  createContainer: u,
138
123
  isContainer: d,
139
124
  getContainerMemberCount: f
@@ -1 +1 @@
1
- {"version":3,"file":"resourceLogic.esm.js","names":[],"sources":["../../src/resource/resourceLogic.ts"],"sourcesContent":["import { NamedNode, sym, LiveStore } from 'rdflib'\nimport { ACL_LINK } from '../acl/aclLogic'\nimport { ns } from '../util/ns'\nimport { assertSuccessfulHttpResponse, isMissingError } from './resourceHttp'\nimport { readWacAccessInfo } from './resourceMetadata'\nimport { type AclLogic, type ResourceAccess, type ResourceAccessWithDelete, type ResourceDeleteOptions, type ResourceLogic, type ResourceMetadata, type ResourceMetadataWithDelete, type TypeIndexLogic } from '../types'\n\nexport function createResourceLogic(store: LiveStore, aclLogic: AclLogic, containerLogic, typeIndexLogic: TypeIndexLogic): ResourceLogic {\n function createContainer(url: string) {\n return containerLogic.createContainer(url)\n }\n\n function isContainer(resourceNode: NamedNode) {\n return containerLogic.isContainer(resourceNode)\n }\n\n function getContainerMemberCount(resourceNode: NamedNode) {\n return containerLogic.getContainerMemberCount(resourceNode)\n }\n\n function readMetadata(subject: NamedNode, response: Response): ResourceMetadata {\n let contentType: string | undefined\n let canEdit = false\n let isPublic = false\n let eTag: string | undefined\n let modified: string | undefined\n\n if (response.headers) {\n const contentTypeHeader = response.headers.get('content-type')\n contentType = contentTypeHeader?.split(';')[0] ?? undefined\n\n const accessFlags = readWacAccessInfo(response.headers.get('wac-allow'))\n canEdit = accessFlags.canEdit\n isPublic = accessFlags.isPublic\n eTag = response.headers.get('etag') ?? undefined\n modified = store.anyValue(subject as any, ns.dct('modified')) || store.anyValue(subject as any, ns.dc('modified')) || undefined\n }\n\n if ((!response.headers || !response.headers.get('content-type')) && (!response.headers || !response.headers.get('wac-allow') || !response.headers.get('etag'))) {\n const reqs = store.each(\n null,\n store.sym('http://www.w3.org/2007/ont/link#requestedURI'),\n subject\n )\n reqs.map((req: any) => {\n const responseNode = store.any(\n req as any,\n store.sym('http://www.w3.org/2007/ont/link#response')\n )\n if (responseNode && responseNode.termType === 'NamedNode') {\n const responseContentType = store.anyValue(responseNode as any, ns.httph('content-type')) || undefined\n if (contentType === undefined) {\n contentType = responseContentType\n }\n const wacAllow = (store.anyValue(responseNode as any, ns.httph('wac-allow')) as string | undefined) ||\n (store.anyValue(responseNode as any, ns.httph('WAC-Allow')) as string | undefined)\n const accessFlags = readWacAccessInfo(wacAllow)\n canEdit = canEdit || accessFlags.canEdit\n isPublic = isPublic || accessFlags.isPublic\n const responseETag = store.anyValue(responseNode as any, ns.httph('etag')) || undefined\n if (eTag === undefined) {\n eTag = responseETag\n }\n modified = store.anyValue(subject as any, ns.dct('modified')) || store.anyValue(subject as any, ns.dc('modified')) || undefined\n }\n })\n }\n\n const aclUri = store.any(subject, ACL_LINK)?.value || undefined\n const access: ResourceAccess = { canEdit, isPublic }\n return { contentType, access, aclUri, eTag, modified }\n }\n\n async function fetchHeadMetadata(subject: NamedNode): Promise<ResourceMetadata> {\n const response = await store.fetcher.webOperation('HEAD', subject.uri)\n assertSuccessfulHttpResponse(response, 'HEAD')\n return readMetadata(subject, response)\n }\n\n async function userCanWriteToContainingContainer(resourceNode: NamedNode): Promise<boolean> {\n const containerNode = store.any(resourceNode, ns.ldp('contains')) || resourceNode.dir()\n if (!containerNode || containerNode.termType !== 'NamedNode') {\n return false\n }\n\n try {\n const containerMetadata = await fetchHeadMetadata(containerNode as NamedNode)\n return containerMetadata.access.canEdit\n } catch (_error) {\n return false\n }\n }\n\n async function userCanDeleteResource(resourceNode: NamedNode): Promise<boolean> {\n return userCanWriteToContainingContainer(resourceNode)\n }\n\n async function fetchMetadata(subject: NamedNode): Promise<ResourceMetadata> {\n return fetchHeadMetadata(subject)\n }\n\n async function fetchMetadataWithDelete(subject: NamedNode): Promise<ResourceMetadataWithDelete> {\n let resourceMetadata: ResourceMetadata\n\n try {\n resourceMetadata = await fetchHeadMetadata(subject)\n } catch (_error) {\n resourceMetadata = {\n contentType: undefined,\n access: { canEdit: false, isPublic: false },\n aclUri: undefined,\n eTag: undefined,\n modified: undefined\n }\n }\n\n const canDelete = await userCanDeleteResource(subject)\n const access: ResourceAccessWithDelete = {\n canEdit: resourceMetadata.access?.canEdit ?? false,\n isPublic: resourceMetadata.access?.isPublic ?? false,\n canDelete\n }\n return { ...resourceMetadata, access }\n }\n\n async function deleteTypeIndexesForResource(resourceNode: NamedNode, user?: NamedNode | null) {\n if (!user) return\n\n try {\n await typeIndexLogic.deleteTypeIndexRegistrationForResource(resourceNode, user)\n } catch (_error) {\n // Keep resource deletion best-effort even if type-index cleanup fails.\n }\n }\n\n async function recursiveDelete(resourceNode: NamedNode, options: ResourceDeleteOptions = {}) {\n const resourceParent = resourceNode.dir()\n\n if (isContainer(resourceNode)) {\n const containerMembers = await containerLogic.getContainerMembers(resourceNode)\n await Promise.all(containerMembers.map((url) => recursiveDelete(sym(url), options)))\n }\n\n let deleted\n try {\n deleted = await store.fetcher._fetch(resourceNode.value, { method: 'DELETE' })\n assertSuccessfulHttpResponse(deleted, 'DELETE', { allowNotFound: true })\n } catch (error) {\n if (!isMissingError(error)) {\n throw error\n }\n }\n\n if (options.deleteTypeIndexes) {\n await deleteTypeIndexesForResource(resourceNode, options.user)\n }\n\n if (resourceParent) {\n store.removeMatches(resourceParent, ns.ldp('contains'), resourceNode, resourceParent.doc())\n }\n\n store.removeDocument(resourceNode)\n store.fetcher.unload(resourceNode.doc())\n return deleted\n }\n\n async function deleteResourceAndTypeIndexIfExists(resourceNode: NamedNode, user?: NamedNode | null) {\n await recursiveDelete(resourceNode, { deleteTypeIndexes: true, user })\n }\n\n async function checkAndRefreshEditable(resourceNode: NamedNode | null | undefined): Promise<boolean> {\n if (!resourceNode || !store.updater || !store.fetcher || typeof store.fetcher.refresh !== 'function') return false\n\n const resourceUri = resourceNode.uri || resourceNode.value || ''\n if (!resourceUri) return false\n\n const editable = store.updater.editable(resourceUri, store)\n if (editable !== false && editable !== undefined) {\n return true\n }\n\n try {\n await store.fetcher.refresh(resourceNode)\n } catch (error) {\n throw error instanceof Error ? error : new Error(`Failed to refresh <${resourceUri}>`)\n }\n\n const editableAfterRefresh = store.updater.editable(resourceUri, store)\n return editableAfterRefresh !== false && editableAfterRefresh !== undefined\n }\n\n return {\n recursiveDelete,\n deleteResourceAndTypeIndexIfExists,\n fetchMetadata,\n fetchMetadataWithDelete,\n checkAndRefreshEditable,\n createContainer,\n isContainer,\n getContainerMemberCount\n }\n}\n"],"mappings":";;;;;;AAOA,SAAgB,EAAoB,GAAkB,GAAoB,GAAgB,GAA+C;CACvI,SAAS,EAAgB,GAAa;EACpC,OAAO,EAAe,gBAAgB,CAAG;CAC3C;CAEA,SAAS,EAAY,GAAyB;EAC5C,OAAO,EAAe,YAAY,CAAY;CAChD;CAEA,SAAS,EAAwB,GAAyB;EACxD,OAAO,EAAe,wBAAwB,CAAY;CAC5D;CAEA,SAAS,EAAa,GAAoB,GAAsC;EAC9E,IAAI,GACA,IAAU,IACV,IAAW,IACX,GACA;EAEJ,IAAI,EAAS,SAAS;GAEpB,IAD0B,EAAS,QAAQ,IAAI,cACjC,CAAA,EAAmB,MAAM,GAAG,CAAC,CAAC,MAAM,KAAA;GAElD,IAAM,IAAc,EAAkB,EAAS,QAAQ,IAAI,WAAW,CAAC;GAIvE,AAHA,IAAU,EAAY,SACtB,IAAW,EAAY,UACvB,IAAO,EAAS,QAAQ,IAAI,MAAM,KAAK,KAAA,GACvC,IAAW,EAAM,SAAS,GAAgB,EAAG,IAAI,UAAU,CAAC,KAAK,EAAM,SAAS,GAAgB,EAAG,GAAG,UAAU,CAAC,KAAK,KAAA;EACxH;EAEA,CAAK,CAAC,EAAS,WAAW,CAAC,EAAS,QAAQ,IAAI,cAAc,OAAO,CAAC,EAAS,WAAW,CAAC,EAAS,QAAQ,IAAI,WAAW,KAAK,CAAC,EAAS,QAAQ,IAAI,MAAM,MAM1J,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AAG,GAAc,EAAe,IAAI,CAAC,GAG5F,EAAM,eAAe,CAAY,GACjC,EAAM,QAAQ,OAAO,EAAa,IAAI,CAAC,GAChC;CACT;CAEA,eAAe,EAAmC,GAAyB,GAAyB;EAClG,MAAM,EAAgB,GAAc;GAAE,mBAAmB;GAAM;EAAK,CAAC;CACvE;CAEA,eAAe,EAAwB,GAA8D;EACnG,IAAI,CAAC,KAAgB,CAAC,EAAM,WAAW,CAAC,EAAM,WAAW,OAAO,EAAM,QAAQ,WAAY,YAAY,OAAO;EAE7G,IAAM,IAAc,EAAa,OAAO,EAAa,SAAS;EAC9D,IAAI,CAAC,GAAa,OAAO;EAEzB,IAAM,IAAW,EAAM,QAAQ,SAAS,GAAa,CAAK;EAC1D,IAAI,MAAa,MAAS,MAAa,KAAA,GACrC,OAAO;EAGT,IAAI;GACF,MAAM,EAAM,QAAQ,QAAQ,CAAY;EAC1C,SAAS,GAAO;GACd,MAAM,aAAiB,QAAQ,IAAQ,gBAAI,MAAM,sBAAsB,EAAY,EAAE;EACvF;EAEA,IAAM,IAAuB,EAAM,QAAQ,SAAS,GAAa,CAAK;EACtE,OAAO,MAAyB,MAAS,MAAyB,KAAA;CACpE;CAEA,OAAO;EACL;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF;AACF"}
1
+ {"version":3,"file":"resourceLogic.esm.js","names":[],"sources":["../../src/resource/resourceLogic.ts"],"sourcesContent":["import { NamedNode, sym } from 'rdflib'\nimport { ACL_LINK } from '../acl/aclLogic'\nimport { ns } from '../util/ns'\nimport { assertSuccessfulHttpResponse, isMissingError } from './resourceHttp'\nimport { readWacAccessInfo } from './resourceMetadata'\nimport { type AclLogic, type ResourceAccess, type ResourceAccessWithDelete, type ResourceDeleteOptions, type ResourceLogic, type ResourceMetadata, type ResourceMetadataWithDelete, type TypeIndexLogic } from '../types'\n\nexport function createResourceLogic(store, aclLogic: AclLogic, containerLogic, typeIndexLogic: TypeIndexLogic): ResourceLogic {\n function createContainer(url: string) {\n return containerLogic.createContainer(url)\n }\n\n function isContainer(resourceNode: NamedNode) {\n return containerLogic.isContainer(resourceNode)\n }\n\n function getContainerMemberCount(resourceNode: NamedNode) {\n return containerLogic.getContainerMemberCount(resourceNode)\n }\n\n function readMetadata(subject: NamedNode, response: Response): ResourceMetadata {\n let contentType: string | undefined\n let canEdit = false\n let isPublic = false\n let eTag: string | undefined\n let modified: string | undefined\n\n if (response.headers) {\n const contentTypeHeader = response.headers.get('content-type')\n contentType = contentTypeHeader?.split(';')[0] ?? undefined\n\n const accessFlags = readWacAccessInfo(response.headers.get('wac-allow'))\n canEdit = accessFlags.canEdit\n isPublic = accessFlags.isPublic\n eTag = response.headers.get('etag') ?? undefined\n modified = store.anyValue(subject as any, ns.dct('modified')) || store.anyValue(subject as any, ns.dc('modified')) || undefined\n }\n\n if ((!response.headers || !response.headers.get('content-type')) && (!response.headers || !response.headers.get('wac-allow') || !response.headers.get('etag'))) {\n const reqs = store.each(\n null,\n store.sym('http://www.w3.org/2007/ont/link#requestedURI'),\n subject\n )\n reqs.map((req: any) => {\n const responseNode = store.any(\n req as any,\n store.sym('http://www.w3.org/2007/ont/link#response')\n )\n if (responseNode && responseNode.termType === 'NamedNode') {\n const responseContentType = store.anyValue(responseNode as any, ns.httph('content-type')) || undefined\n if (contentType === undefined) {\n contentType = responseContentType\n }\n const wacAllow = (store.anyValue(responseNode as any, ns.httph('wac-allow')) as string | undefined) ||\n (store.anyValue(responseNode as any, ns.httph('WAC-Allow')) as string | undefined)\n const accessFlags = readWacAccessInfo(wacAllow)\n canEdit = canEdit || accessFlags.canEdit\n isPublic = isPublic || accessFlags.isPublic\n const responseETag = store.anyValue(responseNode as any, ns.httph('etag')) || undefined\n if (eTag === undefined) {\n eTag = responseETag\n }\n modified = store.anyValue(subject as any, ns.dct('modified')) || store.anyValue(subject as any, ns.dc('modified')) || undefined\n }\n })\n }\n\n const aclUri = store.any(subject, ACL_LINK)?.value || undefined\n const access: ResourceAccess = { canEdit, isPublic }\n return { contentType, access, aclUri, eTag, modified }\n }\n\n async function fetchHeadMetadata(subject: NamedNode): Promise<ResourceMetadata> {\n const response = await store.fetcher.webOperation('HEAD', subject.uri)\n assertSuccessfulHttpResponse(response, 'HEAD')\n return readMetadata(subject, response)\n }\n\n async function userCanWriteToContainingContainer(resourceNode: NamedNode): Promise<boolean> {\n const containerNode = store.any(resourceNode, ns.ldp('contains')) || resourceNode.dir()\n if (!containerNode || containerNode.termType !== 'NamedNode') {\n return false\n }\n\n try {\n const containerMetadata = await fetchHeadMetadata(containerNode as NamedNode)\n return containerMetadata.access.canEdit\n } catch (_error) {\n return false\n }\n }\n\n async function userCanDeleteResource(resourceNode: NamedNode): Promise<boolean> {\n return userCanWriteToContainingContainer(resourceNode)\n }\n\n async function fetchMetadata(subject: NamedNode): Promise<ResourceMetadata> {\n return fetchHeadMetadata(subject)\n }\n\n async function fetchMetadataWithDelete(subject: NamedNode): Promise<ResourceMetadataWithDelete> {\n let resourceMetadata: ResourceMetadata\n\n try {\n resourceMetadata = await fetchHeadMetadata(subject)\n } catch (_error) {\n resourceMetadata = {\n contentType: undefined,\n access: { canEdit: false, isPublic: false },\n aclUri: undefined,\n eTag: undefined,\n modified: undefined\n }\n }\n\n const canDelete = await userCanDeleteResource(subject)\n const access: ResourceAccessWithDelete = {\n canEdit: resourceMetadata.access?.canEdit ?? false,\n isPublic: resourceMetadata.access?.isPublic ?? false,\n canDelete\n }\n return { ...resourceMetadata, access }\n }\n\n async function deleteTypeIndexesForResource(resourceNode: NamedNode, user?: NamedNode | null) {\n if (!user) return\n\n try {\n await typeIndexLogic.deleteTypeIndexRegistrationForResource(resourceNode, user)\n } catch (_error) {\n // Keep resource deletion best-effort even if type-index cleanup fails.\n }\n }\n\n async function recursiveDelete(resourceNode: NamedNode, options: ResourceDeleteOptions = {}) {\n const resourceParent = resourceNode.dir()\n\n if (isContainer(resourceNode)) {\n const containerMembers = await containerLogic.getContainerMembers(resourceNode)\n await Promise.all(containerMembers.map((url) => recursiveDelete(sym(url), options)))\n }\n\n let deleted\n try {\n deleted = await store.fetcher._fetch(resourceNode.value, { method: 'DELETE' })\n assertSuccessfulHttpResponse(deleted, 'DELETE', { allowNotFound: true })\n } catch (error) {\n if (!isMissingError(error)) {\n throw error\n }\n }\n\n if (options.deleteTypeIndexes) {\n await deleteTypeIndexesForResource(resourceNode, options.user)\n }\n\n if (resourceParent) {\n store.removeMatches(resourceParent, ns.ldp('contains'), resourceNode, resourceParent.doc())\n }\n\n store.removeDocument(resourceNode)\n store.fetcher.unload(resourceNode.doc())\n return deleted\n }\n\n async function deleteResourceAndTypeIndexIfExists(resourceNode: NamedNode, user?: NamedNode | null) {\n await recursiveDelete(resourceNode, { deleteTypeIndexes: true, user })\n }\n\n return {\n recursiveDelete,\n deleteResourceAndTypeIndexIfExists,\n fetchMetadata,\n fetchMetadataWithDelete,\n createContainer,\n isContainer,\n getContainerMemberCount\n }\n}\n"],"mappings":";;;;;;AAOA,SAAgB,EAAoB,GAAO,GAAoB,GAAgB,GAA+C;CAC5H,SAAS,EAAgB,GAAa;EACpC,OAAO,EAAe,gBAAgB,CAAG;CAC3C;CAEA,SAAS,EAAY,GAAyB;EAC5C,OAAO,EAAe,YAAY,CAAY;CAChD;CAEA,SAAS,EAAwB,GAAyB;EACxD,OAAO,EAAe,wBAAwB,CAAY;CAC5D;CAEA,SAAS,EAAa,GAAoB,GAAsC;EAC9E,IAAI,GACA,IAAU,IACV,IAAW,IACX,GACA;EAEJ,IAAI,EAAS,SAAS;GAEpB,IAD0B,EAAS,QAAQ,IAAI,cACjC,CAAA,EAAmB,MAAM,GAAG,CAAC,CAAC,MAAM,KAAA;GAElD,IAAM,IAAc,EAAkB,EAAS,QAAQ,IAAI,WAAW,CAAC;GAIvE,AAHA,IAAU,EAAY,SACtB,IAAW,EAAY,UACvB,IAAO,EAAS,QAAQ,IAAI,MAAM,KAAK,KAAA,GACvC,IAAW,EAAM,SAAS,GAAgB,EAAG,IAAI,UAAU,CAAC,KAAK,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AC7E,EAA6B,GAAS,UAAU,EAAE,eAAe,GAAK,CAAC;EACzE,SAAS,GAAO;GACd,IAAI,CAAC,EAAe,CAAK,GACvB,MAAM;EAEV;EAYA,OAVI,EAAQ,qBACV,MAAM,EAA6B,GAAc,EAAQ,IAAI,GAG3D,KACF,EAAM,cAAc,GAAgB,EAAG,IAAI,UAAU,GAAG,GAAc,EAAe,IAAI,CAAC,GAG5F,EAAM,eAAe,CAAY,GACjC,EAAM,QAAQ,OAAO,EAAa,IAAI,CAAC,GAChC;CACT;CAEA,eAAe,EAAmC,GAAyB,GAAyB;EAClG,MAAM,EAAgB,GAAc;GAAE,mBAAmB;GAAM;EAAK,CAAC;CACvE;CAEA,OAAO;EACL;EACA;EACA;EACA;EACA;EACA;EACA;CACF;AACF"}
@@ -1,6 +1,6 @@
1
- const e=require("./debug.cjs.js"),t=require("./utils.cjs.js"),n=require("../logic/CustomError.cjs.js");let r=require("rdflib");function i(i,a,o){async function s(e){try{return await i.fetcher.load(e)}catch(r){if(r?.response?.status===404){try{await i.fetcher.webOperation(`PUT`,e.uri,{data:``,contentType:`text/turtle`,headers:{"If-None-Match":`*`}})}catch(t){if((t?.response?.status??t?.status)!==412)throw new n.WebOperationError(`createIfNotExists: PUT FAILED: ${e}: ${t}`)}return await i.fetcher.load(e)}if(r?.response?.status===401)throw new n.UnauthorizedError;if(r?.response?.status===403)throw t.differentOrigin(e)?new n.CrossOriginForbiddenError:new n.SameOriginForbiddenError;let a=`createIfNotExists doc load error: ${e}: ${r}`;throw new n.FetchError(r?.status,`${r?.message||``}${a}`)}}async function c(e,t){try{return await i.fetcher.load(e),!1}catch(e){if((e?.response?.status??e?.status)!==404)throw e}try{return await i.fetcher.webOperation(`PUT`,e.uri,{data:t,contentType:`text/turtle`,headers:{"If-None-Match":`*`}}),!0}catch(e){if((e?.response?.status??e?.status)===412)return!1;throw e}}async function l(t,a,o,c){await i.fetcher.load(c);let l=i.any(t,a,null,c);if(l)return l;if(!i.updater.editable(c)){let t=`followOrCreateLink: cannot edit ${c.value}`;throw e.warn(t),new n.NotEditableError(t)}try{await i.updater.update([],[(0,r.st)(t,a,o,c)])}catch(t){let r=`followOrCreateLink: Error making link in ${c} to ${o}: ${t}`;throw e.warn(r),new n.WebOperationError(t)}try{await s(o)}catch(t){throw e.warn(`followOrCreateLink: Error loading or saving new linked document: ${o}: ${t}`),t}return o}async function u(t,a,o,s,l){await i.fetcher.load(s);let u=i.any(t,a,null,s);if(u)return u;if(!i.updater.editable(s)){let t=`followOrCreateLinkWithContentOnCreate: cannot edit ${s.value}`;throw e.warn(t),new n.NotEditableError(t)}try{await i.updater.update([],[(0,r.st)(t,a,o,s)])}catch(t){let r=`followOrCreateLinkWithContentOnCreate: Error making link in ${s} to ${o}: ${t}`;throw e.warn(r),new n.WebOperationError(r)}try{await c(o,l)}catch(t){throw e.warn(`followOrCreateLinkWithContentOnCreate: Error loading or saving new linked document: ${o}: ${t}`),t}return o}async function d(e){let t=[`@prefix acl: <http://www.w3.org/ns/auth/acl#>.`,``,`<#alice> a acl:Authorization;
1
+ const e=require("./debug.cjs.js"),t=require("../authSession/flagAuthorizationOnTransitions.cjs.js"),n=require("./utils.cjs.js"),r=require("../logic/CustomError.cjs.js");let i=require("rdflib");function a(a,o,s){async function c(e){try{return await a.fetcher.load(e)}catch(t){if(t?.response?.status===404){try{await a.fetcher.webOperation(`PUT`,e.uri,{data:``,contentType:`text/turtle`,headers:{"If-None-Match":`*`}})}catch(t){if((t?.response?.status??t?.status)!==412)throw new r.WebOperationError(`createIfNotExists: PUT FAILED: ${e}: ${t}`)}return await a.fetcher.load(e)}if(t?.response?.status===401)throw new r.UnauthorizedError;if(t?.response?.status===403)throw n.differentOrigin(e)?new r.CrossOriginForbiddenError:new r.SameOriginForbiddenError;let i=`createIfNotExists doc load error: ${e}: ${t}`;throw new r.FetchError(t?.status,`${t?.message||``}${i}`)}}async function l(e,t){try{return await a.fetcher.load(e),!1}catch(e){if((e?.response?.status??e?.status)!==404)throw e}try{return await a.fetcher.webOperation(`PUT`,e.uri,{data:t,contentType:`text/turtle`,headers:{"If-None-Match":`*`}}),!0}catch(e){if((e?.response?.status??e?.status)===412)return!1;throw e}}async function u(n,o,s,l){if(!await t.loadAuthorizedDocument(a,l)){let t=`followOrCreateLink: cannot establish the authorization of ${l.value}`;throw e.warn(t),new r.NotEditableError(t)}let u=a.any(n,o,null,l);if(u)return u;if(!a.updater.editable(l)){let t=`followOrCreateLink: cannot edit ${l.value}`;throw e.warn(t),new r.NotEditableError(t)}try{await a.updater.update([],[(0,i.st)(n,o,s,l)])}catch(t){let n=`followOrCreateLink: Error making link in ${l} to ${s}: ${t}`;throw e.warn(n),new r.WebOperationError(t)}try{await c(s)}catch(t){throw e.warn(`followOrCreateLink: Error loading or saving new linked document: ${s}: ${t}`),t}return s}async function d(n,o,s,c,u){if(!await t.loadAuthorizedDocument(a,c)){let t=`followOrCreateLinkWithContentOnCreate: cannot establish the authorization of ${c.value}`;throw e.warn(t),new r.NotEditableError(t)}let d=a.any(n,o,null,c);if(d)return d;if(!a.updater.editable(c)){let t=`followOrCreateLinkWithContentOnCreate: cannot edit ${c.value}`;throw e.warn(t),new r.NotEditableError(t)}try{await a.updater.update([],[(0,i.st)(n,o,s,c)])}catch(t){let n=`followOrCreateLinkWithContentOnCreate: Error making link in ${c} to ${s}: ${t}`;throw e.warn(n),new r.WebOperationError(n)}try{await l(s,u)}catch(t){throw e.warn(`followOrCreateLinkWithContentOnCreate: Error loading or saving new linked document: ${s}: ${t}`),t}return s}async function f(e){let t=[`@prefix acl: <http://www.w3.org/ns/auth/acl#>.`,``,`<#alice> a acl:Authorization;
2
2
  acl:agent <`+e.ownerWebId+`>;`,` acl:accessTo <${e.target}>;`,` acl:default <${e.target}>;`,` acl:mode acl:Read, acl:Write, acl:Control.`,``].join(`
3
3
  `);e.accessToModes&&(t+=[`<#bobAccessTo> a acl:Authorization;`,` acl:agent <${e.peerWebId}>;`,` acl:accessTo <${e.target}>;`,` acl:mode ${e.accessToModes}.`,``].join(`
4
4
  `)),e.defaultModes&&(t+=[`<#bobDefault> a acl:Authorization;`,` acl:agent <${e.peerWebId}>;`,` acl:default <${e.target}>;`,` acl:mode ${e.defaultModes}.`,``].join(`
5
- `));let n=await a.findAclDocUrl((0,r.sym)(e.target));return i.fetcher._fetch(n,{method:`PUT`,body:t,headers:[[`Content-Type`,`text/turtle`]]})}async function f(e,t){await i.fetcher.webOperation(`PUT`,e.uri,{data:`# ${new Date} ${t}\n`,contentType:`text/turtle`})}return{setSinglePeerAccess:d,createEmptyRdfDoc:f,followOrCreateLink:l,followOrCreateLinkWithContentOnCreate:u,loadOrCreateIfNotExists:s,loadOrCreateWithContentOnCreate:c}}exports.createUtilityLogic=i;
5
+ `));let n=await o.findAclDocUrl((0,i.sym)(e.target));return a.fetcher._fetch(n,{method:`PUT`,body:t,headers:[[`Content-Type`,`text/turtle`]]})}async function p(e,t){await a.fetcher.webOperation(`PUT`,e.uri,{data:`# ${new Date} ${t}\n`,contentType:`text/turtle`})}return{setSinglePeerAccess:f,createEmptyRdfDoc:p,followOrCreateLink:u,followOrCreateLinkWithContentOnCreate:d,loadOrCreateIfNotExists:c,loadOrCreateWithContentOnCreate:l}}exports.createUtilityLogic=a;
6
6
  //# sourceMappingURL=utilityLogic.cjs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"utilityLogic.cjs.js","names":[],"sources":["../../src/util/utilityLogic.ts"],"sourcesContent":["import { NamedNode, st, sym } from 'rdflib'\nimport {\n CrossOriginForbiddenError,\n FetchError,\n NotEditableError,\n SameOriginForbiddenError,\n UnauthorizedError,\n WebOperationError\n} from '../logic/CustomError'\nimport * as debug from '../util/debug'\nimport { differentOrigin } from './utils'\n\nexport function createUtilityLogic(store, aclLogic, containerLogic) {\n\n /**\n * Create a resource if it really does not exist.\n * Be absolutely sure something does not exist before creating a new empty file,\n * as otherwise existing content could be deleted.\n */\n async function loadOrCreateIfNotExists(doc: NamedNode) {\n try {\n return await store.fetcher.load(doc)\n } catch (err: any) {\n if (err?.response?.status === 404) {\n try {\n await store.fetcher.webOperation('PUT', doc.uri, {\n data: '',\n contentType: 'text/turtle',\n headers: { 'If-None-Match': '*' }\n })\n } catch (putErr: any) {\n const status = putErr?.response?.status ?? putErr?.status\n if (status !== 412) {\n const msg = `createIfNotExists: PUT FAILED: ${doc}: ${putErr}`\n throw new WebOperationError(msg)\n }\n }\n return await store.fetcher.load(doc)\n }\n if (err?.response?.status === 401) {\n throw new UnauthorizedError()\n }\n if (err?.response?.status === 403) {\n if (differentOrigin(doc)) {\n throw new CrossOriginForbiddenError()\n }\n throw new SameOriginForbiddenError()\n }\n const msg = `createIfNotExists doc load error: ${doc}: ${err}`\n throw new FetchError(err?.status, `${err?.message || ''}${msg}`)\n }\n }\n\n async function loadOrCreateWithContentOnCreate(doc: NamedNode, data: string): Promise<boolean> {\n try {\n await store.fetcher.load(doc)\n return false\n } catch (err: any) {\n const status = err?.response?.status ?? err?.status\n if (status !== 404) {\n throw err\n }\n }\n\n try {\n await store.fetcher.webOperation('PUT', doc.uri, {\n data,\n contentType: 'text/turtle',\n headers: { 'If-None-Match': '*' }\n })\n return true\n } catch (err: any) {\n const status = err?.response?.status ?? err?.status\n if (status === 412) {\n // Another client created the resource between our 404 check and PUT.\n return false\n }\n throw err\n }\n }\n\n /*\n * Follow link from this doc to another thing, or else make a new link.\n * Returns existing object, or creates it if non-existent.\n */\n async function followOrCreateLink(\n subject: NamedNode,\n predicate: NamedNode,\n object: NamedNode,\n doc: NamedNode\n ): Promise<NamedNode | null> {\n await store.fetcher.load(doc)\n const result = store.any(subject, predicate, null, doc)\n\n if (result) return result as NamedNode\n if (!store.updater.editable(doc)) {\n const msg = `followOrCreateLink: cannot edit ${doc.value}`\n debug.warn(msg)\n throw new NotEditableError(msg)\n }\n\n try {\n await store.updater.update([], [st(subject, predicate, object, doc)])\n } catch (err) {\n const msg = `followOrCreateLink: Error making link in ${doc} to ${object}: ${err}`\n debug.warn(msg)\n throw new WebOperationError(err)\n }\n\n try {\n await loadOrCreateIfNotExists(object)\n } catch (err) {\n debug.warn(`followOrCreateLink: Error loading or saving new linked document: ${object}: ${err}`)\n throw err\n }\n return object\n }\n\n async function followOrCreateLinkWithContentOnCreate(\n subject: NamedNode,\n predicate: NamedNode,\n object: NamedNode,\n doc: NamedNode,\n data: string\n ): Promise<NamedNode | null> {\n await store.fetcher.load(doc)\n const result = store.any(subject, predicate, null, doc)\n\n if (result) return result as NamedNode\n if (!store.updater.editable(doc)) {\n const msg = `followOrCreateLinkWithContentOnCreate: cannot edit ${doc.value}`\n debug.warn(msg)\n throw new NotEditableError(msg)\n }\n\n try {\n await store.updater.update([], [st(subject, predicate, object, doc)])\n } catch (err) {\n const msg = `followOrCreateLinkWithContentOnCreate: Error making link in ${doc} to ${object}: ${err}`\n debug.warn(msg)\n throw new WebOperationError(msg)\n }\n\n try {\n await loadOrCreateWithContentOnCreate(object, data)\n } catch (err) {\n debug.warn(`followOrCreateLinkWithContentOnCreate: Error loading or saving new linked document: ${object}: ${err}`)\n throw err\n }\n return object\n }\n\n // Copied from\n // https://github.com/solidos/web-access-control-tests/blob/v3.0.0/test/surface/delete.test.ts#L5\n async function setSinglePeerAccess(options: {\n ownerWebId: string,\n peerWebId: string,\n accessToModes?: string,\n defaultModes?: string,\n target: string\n }) {\n let str = [\n '@prefix acl: <http://www.w3.org/ns/auth/acl#>.',\n '',\n '<#alice> a acl:Authorization;\\n acl:agent <' + options.ownerWebId + '>;',\n ` acl:accessTo <${options.target}>;`,\n ` acl:default <${options.target}>;`,\n ' acl:mode acl:Read, acl:Write, acl:Control.',\n ''\n ].join('\\n')\n\n if (options.accessToModes) {\n str += [\n '<#bobAccessTo> a acl:Authorization;',\n ` acl:agent <${options.peerWebId}>;`,\n ` acl:accessTo <${options.target}>;`,\n ` acl:mode ${options.accessToModes}.`,\n ''\n ].join('\\n')\n }\n\n if (options.defaultModes) {\n str += [\n '<#bobDefault> a acl:Authorization;',\n ` acl:agent <${options.peerWebId}>;`,\n ` acl:default <${options.target}>;`,\n ` acl:mode ${options.defaultModes}.`,\n ''\n ].join('\\n')\n }\n\n const aclDocUrl = await aclLogic.findAclDocUrl(sym(options.target))\n return store.fetcher._fetch(aclDocUrl, {\n method: 'PUT',\n body: str,\n headers: [['Content-Type', 'text/turtle']]\n })\n }\n\n async function createEmptyRdfDoc(doc: NamedNode, comment: string) {\n await store.fetcher.webOperation('PUT', doc.uri, {\n data: `# ${new Date()} ${comment}\\n`,\n contentType: 'text/turtle'\n })\n }\n\n return {\n setSinglePeerAccess,\n createEmptyRdfDoc,\n followOrCreateLink,\n followOrCreateLinkWithContentOnCreate,\n loadOrCreateIfNotExists,\n loadOrCreateWithContentOnCreate\n }\n}\n"],"mappings":"+HAYA,SAAgB,EAAmB,EAAO,EAAU,EAAgB,CAOlE,eAAe,EAAwB,EAAgB,CACrD,GAAI,CACF,OAAO,MAAM,EAAM,QAAQ,KAAK,CAAG,CACrC,OAAS,EAAU,CACjB,GAAI,GAAK,UAAU,SAAW,IAAK,CACjC,GAAI,CACF,MAAM,EAAM,QAAQ,aAAa,MAAO,EAAI,IAAK,CAC/C,KAAM,GACN,YAAa,cACb,QAAS,CAAE,gBAAiB,GAAI,CAClC,CAAC,CACH,OAAS,EAAa,CAEpB,IADe,GAAQ,UAAU,QAAU,GAAQ,UACpC,IAEb,MAAM,IAAI,EAAA,kBAAkB,kCADkB,EAAI,IAAI,GACvB,CAEnC,CACA,OAAO,MAAM,EAAM,QAAQ,KAAK,CAAG,CACrC,CACA,GAAI,GAAK,UAAU,SAAW,IAC5B,MAAM,IAAI,EAAA,kBAEZ,GAAI,GAAK,UAAU,SAAW,IAI5B,MAHI,EAAA,gBAAgB,CAAG,EACf,IAAI,EAAA,0BAEN,IAAI,EAAA,yBAEZ,IAAM,EAAM,qCAAqC,EAAI,IAAI,IACzD,MAAM,IAAI,EAAA,WAAW,GAAK,OAAQ,GAAG,GAAK,SAAW,KAAK,GAAK,CACjE,CACF,CAEA,eAAe,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,eAAe,EAAkB,EAAgB,EAAiB,CAChE,MAAM,EAAM,QAAQ,aAAa,MAAO,EAAI,IAAK,CAC/C,KAAM,KAAK,IAAI,KAAO,GAAG,EAAQ,IACjC,YAAa,aACf,CAAC,CACH,CAEA,MAAO,CACL,sBACA,oBACA,qBACA,wCACA,0BACA,iCACF,CACF"}
1
+ {"version":3,"file":"utilityLogic.cjs.js","names":[],"sources":["../../src/util/utilityLogic.ts"],"sourcesContent":["import { NamedNode, st, sym } from 'rdflib'\nimport { loadAuthorizedDocument } from '../authSession/flagAuthorizationOnTransitions'\nimport {\n CrossOriginForbiddenError,\n FetchError,\n NotEditableError,\n SameOriginForbiddenError,\n UnauthorizedError,\n WebOperationError\n} from '../logic/CustomError'\nimport * as debug from '../util/debug'\nimport { differentOrigin } from './utils'\n\nexport function createUtilityLogic(store, aclLogic, containerLogic) {\n\n /**\n * Create a resource if it really does not exist.\n * Be absolutely sure something does not exist before creating a new empty file,\n * as otherwise existing content could be deleted.\n */\n async function loadOrCreateIfNotExists(doc: NamedNode) {\n try {\n return await store.fetcher.load(doc)\n } catch (err: any) {\n if (err?.response?.status === 404) {\n try {\n await store.fetcher.webOperation('PUT', doc.uri, {\n data: '',\n contentType: 'text/turtle',\n headers: { 'If-None-Match': '*' }\n })\n } catch (putErr: any) {\n const status = putErr?.response?.status ?? putErr?.status\n if (status !== 412) {\n const msg = `createIfNotExists: PUT FAILED: ${doc}: ${putErr}`\n throw new WebOperationError(msg)\n }\n }\n return await store.fetcher.load(doc)\n }\n if (err?.response?.status === 401) {\n throw new UnauthorizedError()\n }\n if (err?.response?.status === 403) {\n if (differentOrigin(doc)) {\n throw new CrossOriginForbiddenError()\n }\n throw new SameOriginForbiddenError()\n }\n const msg = `createIfNotExists doc load error: ${doc}: ${err}`\n throw new FetchError(err?.status, `${err?.message || ''}${msg}`)\n }\n }\n\n async function loadOrCreateWithContentOnCreate(doc: NamedNode, data: string): Promise<boolean> {\n try {\n await store.fetcher.load(doc)\n return false\n } catch (err: any) {\n const status = err?.response?.status ?? err?.status\n if (status !== 404) {\n throw err\n }\n }\n\n try {\n await store.fetcher.webOperation('PUT', doc.uri, {\n data,\n contentType: 'text/turtle',\n headers: { 'If-None-Match': '*' }\n })\n return true\n } catch (err: any) {\n const status = err?.response?.status ?? err?.status\n if (status === 412) {\n // Another client created the resource between our 404 check and PUT.\n return false\n }\n throw err\n }\n }\n\n /*\n * Follow link from this doc to another thing, or else make a new link.\n * Returns existing object, or creates it if non-existent.\n */\n async function followOrCreateLink(\n subject: NamedNode,\n predicate: NamedNode,\n object: NamedNode,\n doc: NamedNode\n ): Promise<NamedNode | null> {\n // A response begun before an identity transition can be recorded after it,\n // and on rdflib 2.4.0 a plain load does not refetch a flagged document: the\n // helper owns the load, checks it was not overtaken and repairs before\n // anything is read (see flagAuthorizationOnTransitions.ts).\n if (!(await loadAuthorizedDocument(store, doc))) {\n const msg = `followOrCreateLink: cannot establish the authorization of ${doc.value}`\n debug.warn(msg)\n throw new NotEditableError(msg)\n }\n const result = store.any(subject, predicate, null, doc)\n\n if (result) return result as NamedNode\n if (!store.updater.editable(doc)) {\n const msg = `followOrCreateLink: cannot edit ${doc.value}`\n debug.warn(msg)\n throw new NotEditableError(msg)\n }\n\n try {\n await store.updater.update([], [st(subject, predicate, object, doc)])\n } catch (err) {\n const msg = `followOrCreateLink: Error making link in ${doc} to ${object}: ${err}`\n debug.warn(msg)\n throw new WebOperationError(err)\n }\n\n try {\n await loadOrCreateIfNotExists(object)\n } catch (err) {\n debug.warn(`followOrCreateLink: Error loading or saving new linked document: ${object}: ${err}`)\n throw err\n }\n return object\n }\n\n async function followOrCreateLinkWithContentOnCreate(\n subject: NamedNode,\n predicate: NamedNode,\n object: NamedNode,\n doc: NamedNode,\n data: string\n ): Promise<NamedNode | null> {\n // A response begun before an identity transition can be recorded after it,\n // and on rdflib 2.4.0 a plain load does not refetch a flagged document: the\n // helper owns the load, checks it was not overtaken and repairs before\n // anything is read (see flagAuthorizationOnTransitions.ts).\n if (!(await loadAuthorizedDocument(store, doc))) {\n const msg = `followOrCreateLinkWithContentOnCreate: cannot establish the authorization of ${doc.value}`\n debug.warn(msg)\n throw new NotEditableError(msg)\n }\n const result = store.any(subject, predicate, null, doc)\n\n if (result) return result as NamedNode\n if (!store.updater.editable(doc)) {\n const msg = `followOrCreateLinkWithContentOnCreate: cannot edit ${doc.value}`\n debug.warn(msg)\n throw new NotEditableError(msg)\n }\n\n try {\n await store.updater.update([], [st(subject, predicate, object, doc)])\n } catch (err) {\n const msg = `followOrCreateLinkWithContentOnCreate: Error making link in ${doc} to ${object}: ${err}`\n debug.warn(msg)\n throw new WebOperationError(msg)\n }\n\n try {\n await loadOrCreateWithContentOnCreate(object, data)\n } catch (err) {\n debug.warn(`followOrCreateLinkWithContentOnCreate: Error loading or saving new linked document: ${object}: ${err}`)\n throw err\n }\n return object\n }\n\n // Copied from\n // https://github.com/solidos/web-access-control-tests/blob/v3.0.0/test/surface/delete.test.ts#L5\n async function setSinglePeerAccess(options: {\n ownerWebId: string,\n peerWebId: string,\n accessToModes?: string,\n defaultModes?: string,\n target: string\n }) {\n let str = [\n '@prefix acl: <http://www.w3.org/ns/auth/acl#>.',\n '',\n '<#alice> a acl:Authorization;\\n acl:agent <' + options.ownerWebId + '>;',\n ` acl:accessTo <${options.target}>;`,\n ` acl:default <${options.target}>;`,\n ' acl:mode acl:Read, acl:Write, acl:Control.',\n ''\n ].join('\\n')\n\n if (options.accessToModes) {\n str += [\n '<#bobAccessTo> a acl:Authorization;',\n ` acl:agent <${options.peerWebId}>;`,\n ` acl:accessTo <${options.target}>;`,\n ` acl:mode ${options.accessToModes}.`,\n ''\n ].join('\\n')\n }\n\n if (options.defaultModes) {\n str += [\n '<#bobDefault> a acl:Authorization;',\n ` acl:agent <${options.peerWebId}>;`,\n ` acl:default <${options.target}>;`,\n ` acl:mode ${options.defaultModes}.`,\n ''\n ].join('\\n')\n }\n\n const aclDocUrl = await aclLogic.findAclDocUrl(sym(options.target))\n return store.fetcher._fetch(aclDocUrl, {\n method: 'PUT',\n body: str,\n headers: [['Content-Type', 'text/turtle']]\n })\n }\n\n async function createEmptyRdfDoc(doc: NamedNode, comment: string) {\n await store.fetcher.webOperation('PUT', doc.uri, {\n data: `# ${new Date()} ${comment}\\n`,\n contentType: 'text/turtle'\n })\n }\n\n return {\n setSinglePeerAccess,\n createEmptyRdfDoc,\n followOrCreateLink,\n followOrCreateLinkWithContentOnCreate,\n loadOrCreateIfNotExists,\n loadOrCreateWithContentOnCreate\n }\n}\n"],"mappings":"iMAaA,SAAgB,EAAmB,EAAO,EAAU,EAAgB,CAOlE,eAAe,EAAwB,EAAgB,CACrD,GAAI,CACF,OAAO,MAAM,EAAM,QAAQ,KAAK,CAAG,CACrC,OAAS,EAAU,CACjB,GAAI,GAAK,UAAU,SAAW,IAAK,CACjC,GAAI,CACF,MAAM,EAAM,QAAQ,aAAa,MAAO,EAAI,IAAK,CAC/C,KAAM,GACN,YAAa,cACb,QAAS,CAAE,gBAAiB,GAAI,CAClC,CAAC,CACH,OAAS,EAAa,CAEpB,IADe,GAAQ,UAAU,QAAU,GAAQ,UACpC,IAEb,MAAM,IAAI,EAAA,kBAAkB,kCADkB,EAAI,IAAI,GACvB,CAEnC,CACA,OAAO,MAAM,EAAM,QAAQ,KAAK,CAAG,CACrC,CACA,GAAI,GAAK,UAAU,SAAW,IAC5B,MAAM,IAAI,EAAA,kBAEZ,GAAI,GAAK,UAAU,SAAW,IAI5B,MAHI,EAAA,gBAAgB,CAAG,EACf,IAAI,EAAA,0BAEN,IAAI,EAAA,yBAEZ,IAAM,EAAM,qCAAqC,EAAI,IAAI,IACzD,MAAM,IAAI,EAAA,WAAW,GAAK,OAAQ,GAAG,GAAK,SAAW,KAAK,GAAK,CACjE,CACF,CAEA,eAAe,EAAgC,EAAgB,EAAgC,CAC7F,GAAI,CAEF,OADA,MAAM,EAAM,QAAQ,KAAK,CAAG,EACrB,EACT,OAAS,EAAU,CAEjB,IADe,GAAK,U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O,EAAM,QAAQ,OAAO,EAAW,CACrC,OAAQ,MACR,KAAM,EACN,QAAS,CAAC,CAAC,eAAgB,aAAa,CAAC,CAC3C,CAAC,CACH,CAEA,eAAe,EAAkB,EAAgB,EAAiB,CAChE,MAAM,EAAM,QAAQ,aAAa,MAAO,EAAI,IAAK,CAC/C,KAAM,KAAK,IAAI,KAAO,GAAG,EAAQ,IACjC,YAAa,aACf,CAAC,CACH,CAEA,MAAO,CACL,sBACA,oBACA,qBACA,wCACA,0BACA,iCACF,CACF"}
@@ -1,39 +1,40 @@
1
1
  import { warn as e } from "./debug.esm.js";
2
- import { differentOrigin as t } from "./utils.esm.js";
3
- import { CrossOriginForbiddenError as n, FetchError as r, NotEditableError as i, SameOriginForbiddenError as a, UnauthorizedError as o, WebOperationError as s } from "../logic/CustomError.esm.js";
4
- import { st as c, sym as l } from "rdflib";
2
+ import { loadAuthorizedDocument as t } from "../authSession/flagAuthorizationOnTransitions.esm.js";
3
+ import { differentOrigin as n } from "./utils.esm.js";
4
+ import { CrossOriginForbiddenError as r, FetchError as i, NotEditableError as a, SameOriginForbiddenError as o, UnauthorizedError as s, WebOperationError as c } from "../logic/CustomError.esm.js";
5
+ import { st as l, sym as u } from "rdflib";
5
6
  //#region src/util/utilityLogic.ts
6
- function u(u, d, f) {
7
- async function p(e) {
7
+ function d(d, f, p) {
8
+ async function m(e) {
8
9
  try {
9
- return await u.fetcher.load(e);
10
- } catch (i) {
11
- if (i?.response?.status === 404) {
10
+ return await d.fetcher.load(e);
11
+ } catch (t) {
12
+ if (t?.response?.status === 404) {
12
13
  try {
13
- await u.fetcher.webOperation("PUT", e.uri, {
14
+ await d.fetcher.webOperation("PUT", e.uri, {
14
15
  data: "",
15
16
  contentType: "text/turtle",
16
17
  headers: { "If-None-Match": "*" }
17
18
  });
18
19
  } catch (t) {
19
- if ((t?.response?.status ?? t?.status) !== 412) throw new s(`createIfNotExists: PUT FAILED: ${e}: ${t}`);
20
+ if ((t?.response?.status ?? t?.status) !== 412) throw new c(`createIfNotExists: PUT FAILED: ${e}: ${t}`);
20
21
  }
21
- return await u.fetcher.load(e);
22
+ return await d.fetcher.load(e);
22
23
  }
23
- if (i?.response?.status === 401) throw new o();
24
- if (i?.response?.status === 403) throw t(e) ? new n() : new a();
25
- let c = `createIfNotExists doc load error: ${e}: ${i}`;
26
- throw new r(i?.status, `${i?.message || ""}${c}`);
24
+ if (t?.response?.status === 401) throw new s();
25
+ if (t?.response?.status === 403) throw n(e) ? new r() : new o();
26
+ let a = `createIfNotExists doc load error: ${e}: ${t}`;
27
+ throw new i(t?.status, `${t?.message || ""}${a}`);
27
28
  }
28
29
  }
29
- async function m(e, t) {
30
+ async function h(e, t) {
30
31
  try {
31
- return await u.fetcher.load(e), !1;
32
+ return await d.fetcher.load(e), !1;
32
33
  } catch (e) {
33
34
  if ((e?.response?.status ?? e?.status) !== 404) throw e;
34
35
  }
35
36
  try {
36
- return await u.fetcher.webOperation("PUT", e.uri, {
37
+ return await d.fetcher.webOperation("PUT", e.uri, {
37
38
  data: t,
38
39
  contentType: "text/turtle",
39
40
  headers: { "If-None-Match": "*" }
@@ -43,48 +44,54 @@ function u(u, d, f) {
43
44
  throw e;
44
45
  }
45
46
  }
46
- async function h(t, n, r, a) {
47
- await u.fetcher.load(a);
48
- let o = u.any(t, n, null, a);
49
- if (o) return o;
50
- if (!u.updater.editable(a)) {
51
- let t = `followOrCreateLink: cannot edit ${a.value}`;
52
- throw e(t), new i(t);
47
+ async function g(n, r, i, o) {
48
+ if (!await t(d, o)) {
49
+ let t = `followOrCreateLink: cannot establish the authorization of ${o.value}`;
50
+ throw e(t), new a(t);
51
+ }
52
+ let s = d.any(n, r, null, o);
53
+ if (s) return s;
54
+ if (!d.updater.editable(o)) {
55
+ let t = `followOrCreateLink: cannot edit ${o.value}`;
56
+ throw e(t), new a(t);
53
57
  }
54
58
  try {
55
- await u.updater.update([], [c(t, n, r, a)]);
59
+ await d.updater.update([], [l(n, r, i, o)]);
56
60
  } catch (t) {
57
- throw e(`followOrCreateLink: Error making link in ${a} to ${r}: ${t}`), new s(t);
61
+ throw e(`followOrCreateLink: Error making link in ${o} to ${i}: ${t}`), new c(t);
58
62
  }
59
63
  try {
60
- await p(r);
64
+ await m(i);
61
65
  } catch (t) {
62
- throw e(`followOrCreateLink: Error loading or saving new linked document: ${r}: ${t}`), t;
66
+ throw e(`followOrCreateLink: Error loading or saving new linked document: ${i}: ${t}`), t;
63
67
  }
64
- return r;
68
+ return i;
65
69
  }
66
- async function g(t, n, r, a, o) {
67
- await u.fetcher.load(a);
68
- let l = u.any(t, n, null, a);
69
- if (l) return l;
70
- if (!u.updater.editable(a)) {
71
- let t = `followOrCreateLinkWithContentOnCreate: cannot edit ${a.value}`;
72
- throw e(t), new i(t);
70
+ async function _(n, r, i, o, s) {
71
+ if (!await t(d, o)) {
72
+ let t = `followOrCreateLinkWithContentOnCreate: cannot establish the authorization of ${o.value}`;
73
+ throw e(t), new a(t);
74
+ }
75
+ let u = d.any(n, r, null, o);
76
+ if (u) return u;
77
+ if (!d.updater.editable(o)) {
78
+ let t = `followOrCreateLinkWithContentOnCreate: cannot edit ${o.value}`;
79
+ throw e(t), new a(t);
73
80
  }
74
81
  try {
75
- await u.updater.update([], [c(t, n, r, a)]);
82
+ await d.updater.update([], [l(n, r, i, o)]);
76
83
  } catch (t) {
77
- let n = `followOrCreateLinkWithContentOnCreate: Error making link in ${a} to ${r}: ${t}`;
78
- throw e(n), new s(n);
84
+ let n = `followOrCreateLinkWithContentOnCreate: Error making link in ${o} to ${i}: ${t}`;
85
+ throw e(n), new c(n);
79
86
  }
80
87
  try {
81
- await m(r, o);
88
+ await h(i, s);
82
89
  } catch (t) {
83
- throw e(`followOrCreateLinkWithContentOnCreate: Error loading or saving new linked document: ${r}: ${t}`), t;
90
+ throw e(`followOrCreateLinkWithContentOnCreate: Error loading or saving new linked document: ${i}: ${t}`), t;
84
91
  }
85
- return r;
92
+ return i;
86
93
  }
87
- async function _(e) {
94
+ async function v(e) {
88
95
  let t = [
89
96
  "@prefix acl: <http://www.w3.org/ns/auth/acl#>.",
90
97
  "",
@@ -107,29 +114,29 @@ function u(u, d, f) {
107
114
  ` acl:mode ${e.defaultModes}.`,
108
115
  ""
109
116
  ].join("\n"));
110
- let n = await d.findAclDocUrl(l(e.target));
111
- return u.fetcher._fetch(n, {
117
+ let n = await f.findAclDocUrl(u(e.target));
118
+ return d.fetcher._fetch(n, {
112
119
  method: "PUT",
113
120
  body: t,
114
121
  headers: [["Content-Type", "text/turtle"]]
115
122
  });
116
123
  }
117
- async function v(e, t) {
118
- await u.fetcher.webOperation("PUT", e.uri, {
124
+ async function y(e, t) {
125
+ await d.fetcher.webOperation("PUT", e.uri, {
119
126
  data: `# ${/* @__PURE__ */ new Date()} ${t}\n`,
120
127
  contentType: "text/turtle"
121
128
  });
122
129
  }
123
130
  return {
124
- setSinglePeerAccess: _,
125
- createEmptyRdfDoc: v,
126
- followOrCreateLink: h,
127
- followOrCreateLinkWithContentOnCreate: g,
128
- loadOrCreateIfNotExists: p,
129
- loadOrCreateWithContentOnCreate: m
131
+ setSinglePeerAccess: v,
132
+ createEmptyRdfDoc: y,
133
+ followOrCreateLink: g,
134
+ followOrCreateLinkWithContentOnCreate: _,
135
+ loadOrCreateIfNotExists: m,
136
+ loadOrCreateWithContentOnCreate: h
130
137
  };
131
138
  }
132
139
  //#endregion
133
- export { u as createUtilityLogic };
140
+ export { d as createUtilityLogic };
134
141
 
135
142
  //# sourceMappingURL=utilityLogic.esm.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"utilityLogic.esm.js","names":[],"sources":["../../src/util/utilityLogic.ts"],"sourcesContent":["import { NamedNode, st, sym } from 'rdflib'\nimport {\n CrossOriginForbiddenError,\n FetchError,\n NotEditableError,\n SameOriginForbiddenError,\n UnauthorizedError,\n WebOperationError\n} from '../logic/CustomError'\nimport * as debug from '../util/debug'\nimport { differentOrigin } from './utils'\n\nexport function createUtilityLogic(store, aclLogic, containerLogic) {\n\n /**\n * Create a resource if it really does not exist.\n * Be absolutely sure something does not exist before creating a new empty file,\n * as otherwise existing content could be deleted.\n */\n async function loadOrCreateIfNotExists(doc: NamedNode) {\n try {\n return await store.fetcher.load(doc)\n } catch (err: any) {\n if (err?.response?.status === 404) {\n try {\n await store.fetcher.webOperation('PUT', doc.uri, {\n data: '',\n contentType: 'text/turtle',\n headers: { 'If-None-Match': '*' }\n })\n } catch (putErr: any) {\n const status = putErr?.response?.status ?? putErr?.status\n if (status !== 412) {\n const msg = `createIfNotExists: PUT FAILED: ${doc}: ${putErr}`\n throw new WebOperationError(msg)\n }\n }\n return await store.fetcher.load(doc)\n }\n if (err?.response?.status === 401) {\n throw new UnauthorizedError()\n }\n if (err?.response?.status === 403) {\n if (differentOrigin(doc)) {\n throw new CrossOriginForbiddenError()\n }\n throw new SameOriginForbiddenError()\n }\n const msg = `createIfNotExists doc load error: ${doc}: ${err}`\n throw new FetchError(err?.status, `${err?.message || ''}${msg}`)\n }\n }\n\n async function loadOrCreateWithContentOnCreate(doc: NamedNode, data: string): Promise<boolean> {\n try {\n await store.fetcher.load(doc)\n return false\n } catch (err: any) {\n const status = err?.response?.status ?? err?.status\n if (status !== 404) {\n throw err\n }\n }\n\n try {\n await store.fetcher.webOperation('PUT', doc.uri, {\n data,\n contentType: 'text/turtle',\n headers: { 'If-None-Match': '*' }\n })\n return true\n } catch (err: any) {\n const status = err?.response?.status ?? err?.status\n if (status === 412) {\n // Another client created the resource between our 404 check and PUT.\n return false\n }\n throw err\n }\n }\n\n /*\n * Follow link from this doc to another thing, or else make a new link.\n * Returns existing object, or creates it if non-existent.\n */\n async function followOrCreateLink(\n subject: NamedNode,\n predicate: NamedNode,\n object: NamedNode,\n doc: NamedNode\n ): Promise<NamedNode | null> {\n await store.fetcher.load(doc)\n const result = store.any(subject, predicate, null, doc)\n\n if (result) return result as NamedNode\n if (!store.updater.editable(doc)) {\n const msg = `followOrCreateLink: cannot edit ${doc.value}`\n debug.warn(msg)\n throw new NotEditableError(msg)\n }\n\n try {\n await store.updater.update([], [st(subject, predicate, object, doc)])\n } catch (err) {\n const msg = `followOrCreateLink: Error making link in ${doc} to ${object}: ${err}`\n debug.warn(msg)\n throw new WebOperationError(err)\n }\n\n try {\n await loadOrCreateIfNotExists(object)\n } catch (err) {\n debug.warn(`followOrCreateLink: Error loading or saving new linked document: ${object}: ${err}`)\n throw err\n }\n return object\n }\n\n async function followOrCreateLinkWithContentOnCreate(\n subject: NamedNode,\n predicate: NamedNode,\n object: NamedNode,\n doc: NamedNode,\n data: string\n ): Promise<NamedNode | null> {\n await store.fetcher.load(doc)\n const result = store.any(subject, predicate, null, doc)\n\n if (result) return result as NamedNode\n if (!store.updater.editable(doc)) {\n const msg = `followOrCreateLinkWithContentOnCreate: cannot edit ${doc.value}`\n debug.warn(msg)\n throw new NotEditableError(msg)\n }\n\n try {\n await store.updater.update([], [st(subject, predicate, object, doc)])\n } catch (err) {\n const msg = `followOrCreateLinkWithContentOnCreate: Error making link in ${doc} to ${object}: ${err}`\n debug.warn(msg)\n throw new WebOperationError(msg)\n }\n\n try {\n await loadOrCreateWithContentOnCreate(object, data)\n } catch (err) {\n debug.warn(`followOrCreateLinkWithContentOnCreate: Error loading or saving new linked document: ${object}: ${err}`)\n throw err\n }\n return object\n }\n\n // Copied from\n // https://github.com/solidos/web-access-control-tests/blob/v3.0.0/test/surface/delete.test.ts#L5\n async function setSinglePeerAccess(options: {\n ownerWebId: string,\n peerWebId: string,\n accessToModes?: string,\n defaultModes?: string,\n target: string\n }) {\n let str = [\n '@prefix acl: <http://www.w3.org/ns/auth/acl#>.',\n '',\n '<#alice> a acl:Authorization;\\n acl:agent <' + options.ownerWebId + '>;',\n ` acl:accessTo <${options.target}>;`,\n ` acl:default <${options.target}>;`,\n ' acl:mode acl:Read, acl:Write, acl:Control.',\n ''\n ].join('\\n')\n\n if (options.accessToModes) {\n str += [\n '<#bobAccessTo> a acl:Authorization;',\n ` acl:agent <${options.peerWebId}>;`,\n ` acl:accessTo <${options.target}>;`,\n ` acl:mode ${options.accessToModes}.`,\n ''\n ].join('\\n')\n }\n\n if (options.defaultModes) {\n str += [\n '<#bobDefault> a acl:Authorization;',\n ` acl:agent <${options.peerWebId}>;`,\n ` acl:default <${options.target}>;`,\n ` acl:mode ${options.defaultModes}.`,\n ''\n ].join('\\n')\n }\n\n const aclDocUrl = await aclLogic.findAclDocUrl(sym(options.target))\n return store.fetcher._fetch(aclDocUrl, {\n method: 'PUT',\n body: str,\n headers: [['Content-Type', 'text/turtle']]\n })\n }\n\n async function createEmptyRdfDoc(doc: NamedNode, comment: string) {\n await store.fetcher.webOperation('PUT', doc.uri, {\n data: `# ${new Date()} ${comment}\\n`,\n contentType: 'text/turtle'\n })\n }\n\n return {\n setSinglePeerAccess,\n createEmptyRdfDoc,\n followOrCreateLink,\n followOrCreateLinkWithContentOnCreate,\n loadOrCreateIfNotExists,\n loadOrCreateWithContentOnCreate\n }\n}\n"],"mappings":";;;;;AAYA,SAAgB,EAAmB,GAAO,GAAU,GAAgB;CAOlE,eAAe,EAAwB,GAAgB;EACrD,IAAI;GACF,OAAO,MAAM,EAAM,QAAQ,KAAK,CAAG;EACrC,SAAS,GAAU;GACjB,IAAI,GAAK,UAAU,WAAW,KAAK;IACjC,IAAI;KACF,MAAM,EAAM,QAAQ,aAAa,OAAO,EAAI,KAAK;MAC/C,MAAM;MACN,aAAa;MACb,SAAS,EAAE,iBAAiB,IAAI;KAClC,CAAC;IACH,SAAS,GAAa;KAEpB,KADe,GAAQ,UAAU,UAAU,GAAQ,YACpC,KAEb,MAAM,IAAI,EAAkB,kCADkB,EAAI,IAAI,GACvB;IAEnC;IACA,OAAO,MAAM,EAAM,QAAQ,KAAK,CAAG;GACrC;GACA,IAAI,GAAK,UAAU,WAAW,KAC5B,MAAM,IAAI,EAAkB;GAE9B,IAAI,GAAK,UAAU,WAAW,KAI5B,MAHI,EAAgB,CAAG,IACf,IAAI,EAA0B,IAEhC,IAAI,EAAyB;GAErC,IAAM,I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AgB,GAAiB;EAChE,MAAM,EAAM,QAAQ,aAAa,OAAO,EAAI,KAAK;GAC/C,MAAM,qBAAK,IAAI,KAAK,EAAE,GAAG,EAAQ;GACjC,aAAa;EACf,CAAC;CACH;CAEA,OAAO;EACL;EACA;EACA;EACA;EACA;EACA;CACF;AACF"}
1
+ {"version":3,"file":"utilityLogic.esm.js","names":[],"sources":["../../src/util/utilityLogic.ts"],"sourcesContent":["import { NamedNode, st, sym } from 'rdflib'\nimport { loadAuthorizedDocument } from '../authSession/flagAuthorizationOnTransitions'\nimport {\n CrossOriginForbiddenError,\n FetchError,\n NotEditableError,\n SameOriginForbiddenError,\n UnauthorizedError,\n WebOperationError\n} from '../logic/CustomError'\nimport * as debug from '../util/debug'\nimport { differentOrigin } from './utils'\n\nexport function createUtilityLogic(store, aclLogic, containerLogic) {\n\n /**\n * Create a resource if it really does not exist.\n * Be absolutely sure something does not exist before creating a new empty file,\n * as otherwise existing content could be deleted.\n */\n async function loadOrCreateIfNotExists(doc: NamedNode) {\n try {\n return await store.fetcher.load(doc)\n } catch (err: any) {\n if (err?.response?.status === 404) {\n try {\n await store.fetcher.webOperation('PUT', doc.uri, {\n data: '',\n contentType: 'text/turtle',\n headers: { 'If-None-Match': '*' }\n })\n } catch (putErr: any) {\n const status = putErr?.response?.status ?? putErr?.status\n if (status !== 412) {\n const msg = `createIfNotExists: PUT FAILED: ${doc}: ${putErr}`\n throw new WebOperationError(msg)\n }\n }\n return await store.fetcher.load(doc)\n }\n if (err?.response?.status === 401) {\n throw new UnauthorizedError()\n }\n if (err?.response?.status === 403) {\n if (differentOrigin(doc)) {\n throw new CrossOriginForbiddenError()\n }\n throw new SameOriginForbiddenError()\n }\n const msg = `createIfNotExists doc load error: ${doc}: ${err}`\n throw new FetchError(err?.status, `${err?.message || ''}${msg}`)\n }\n }\n\n async function loadOrCreateWithContentOnCreate(doc: NamedNode, data: string): Promise<boolean> {\n try {\n await store.fetcher.load(doc)\n return false\n } catch (err: any) {\n const status = err?.response?.status ?? err?.status\n if (status !== 404) {\n throw err\n }\n }\n\n try {\n await store.fetcher.webOperation('PUT', doc.uri, {\n data,\n contentType: 'text/turtle',\n headers: { 'If-None-Match': '*' }\n })\n return true\n } catch (err: any) {\n const status = err?.response?.status ?? err?.status\n if (status === 412) {\n // Another client created the resource between our 404 check and PUT.\n return false\n }\n throw err\n }\n }\n\n /*\n * Follow link from this doc to another thing, or else make a new link.\n * Returns existing object, or creates it if non-existent.\n */\n async function followOrCreateLink(\n subject: NamedNode,\n predicate: NamedNode,\n object: NamedNode,\n doc: NamedNode\n ): Promise<NamedNode | null> {\n // A response begun before an identity transition can be recorded after it,\n // and on rdflib 2.4.0 a plain load does not refetch a flagged document: the\n // helper owns the load, checks it was not overtaken and repairs before\n // anything is read (see flagAuthorizationOnTransitions.ts).\n if (!(await loadAuthorizedDocument(store, doc))) {\n const msg = `followOrCreateLink: cannot establish the authorization of ${doc.value}`\n debug.warn(msg)\n throw new NotEditableError(msg)\n }\n const result = store.any(subject, predicate, null, doc)\n\n if (result) return result as NamedNode\n if (!store.updater.editable(doc)) {\n const msg = `followOrCreateLink: cannot edit ${doc.value}`\n debug.warn(msg)\n throw new NotEditableError(msg)\n }\n\n try {\n await store.updater.update([], [st(subject, predicate, object, doc)])\n } catch (err) {\n const msg = `followOrCreateLink: Error making link in ${doc} to ${object}: ${err}`\n debug.warn(msg)\n throw new WebOperationError(err)\n }\n\n try {\n await loadOrCreateIfNotExists(object)\n } catch (err) {\n debug.warn(`followOrCreateLink: Error loading or saving new linked document: ${object}: ${err}`)\n throw err\n }\n return object\n }\n\n async function followOrCreateLinkWithContentOnCreate(\n subject: NamedNode,\n predicate: NamedNode,\n object: NamedNode,\n doc: NamedNode,\n data: string\n ): Promise<NamedNode | null> {\n // A response begun before an identity transition can be recorded after it,\n // and on rdflib 2.4.0 a plain load does not refetch a flagged document: the\n // helper owns the load, checks it was not overtaken and repairs before\n // anything is read (see flagAuthorizationOnTransitions.ts).\n if (!(await loadAuthorizedDocument(store, doc))) {\n const msg = `followOrCreateLinkWithContentOnCreate: cannot establish the authorization of ${doc.value}`\n debug.warn(msg)\n throw new NotEditableError(msg)\n }\n const result = store.any(subject, predicate, null, doc)\n\n if (result) return result as NamedNode\n if (!store.updater.editable(doc)) {\n const msg = `followOrCreateLinkWithContentOnCreate: cannot edit ${doc.value}`\n debug.warn(msg)\n throw new NotEditableError(msg)\n }\n\n try {\n await store.updater.update([], [st(subject, predicate, object, doc)])\n } catch (err) {\n const msg = `followOrCreateLinkWithContentOnCreate: Error making link in ${doc} to ${object}: ${err}`\n debug.warn(msg)\n throw new WebOperationError(msg)\n }\n\n try {\n await loadOrCreateWithContentOnCreate(object, data)\n } catch (err) {\n debug.warn(`followOrCreateLinkWithContentOnCreate: Error loading or saving new linked document: ${object}: ${err}`)\n throw err\n }\n return object\n }\n\n // Copied from\n // https://github.com/solidos/web-access-control-tests/blob/v3.0.0/test/surface/delete.test.ts#L5\n async function setSinglePeerAccess(options: {\n ownerWebId: string,\n peerWebId: string,\n accessToModes?: string,\n defaultModes?: string,\n target: string\n }) {\n let str = [\n '@prefix acl: <http://www.w3.org/ns/auth/acl#>.',\n '',\n '<#alice> a acl:Authorization;\\n acl:agent <' + options.ownerWebId + '>;',\n ` acl:accessTo <${options.target}>;`,\n ` acl:default <${options.target}>;`,\n ' acl:mode acl:Read, acl:Write, acl:Control.',\n ''\n ].join('\\n')\n\n if (options.accessToModes) {\n str += [\n '<#bobAccessTo> a acl:Authorization;',\n ` acl:agent <${options.peerWebId}>;`,\n ` acl:accessTo <${options.target}>;`,\n ` acl:mode ${options.accessToModes}.`,\n ''\n ].join('\\n')\n }\n\n if (options.defaultModes) {\n str += [\n '<#bobDefault> a acl:Authorization;',\n ` acl:agent <${options.peerWebId}>;`,\n ` acl:default <${options.target}>;`,\n ` acl:mode ${options.defaultModes}.`,\n ''\n ].join('\\n')\n }\n\n const aclDocUrl = await aclLogic.findAclDocUrl(sym(options.target))\n return store.fetcher._fetch(aclDocUrl, {\n method: 'PUT',\n body: str,\n headers: [['Content-Type', 'text/turtle']]\n })\n }\n\n async function createEmptyRdfDoc(doc: NamedNode, comment: string) {\n await store.fetcher.webOperation('PUT', doc.uri, {\n data: `# ${new Date()} ${comment}\\n`,\n contentType: 'text/turtle'\n })\n }\n\n return {\n setSinglePeerAccess,\n createEmptyRdfDoc,\n followOrCreateLink,\n followOrCreateLinkWithContentOnCreate,\n loadOrCreateIfNotExists,\n loadOrCreateWithContentOnCreate\n }\n}\n"],"mappings":";;;;;;AAaA,SAAgB,EAAmB,GAAO,GAAU,GAAgB;CAOlE,eAAe,EAAwB,GAAgB;EACrD,IAAI;GACF,OAAO,MAAM,EAAM,QAAQ,KAAK,CAAG;EACrC,SAAS,GAAU;GACjB,IAAI,GAAK,UAAU,WAAW,KAAK;IACjC,IAAI;KACF,MAAM,EAAM,QAAQ,aAAa,OAAO,EAAI,KAAK;MAC/C,MAAM;MACN,aAAa;MACb,SAAS,EAAE,iBAAiB,IAAI;KAClC,CAAC;IACH,SAAS,GAAa;KAEpB,KADe,GAAQ,UAAU,UAAU,GAAQ,YACpC,KAEb,MAAM,IAAI,EAAkB,kCADkB,EAAI,IAAI,GACvB;IAEnC;IACA,OAAO,MAAM,EAAM,QAAQ,KAAK,CAAG;GACrC;GACA,IAAI,GAAK,UAAU,WAAW,KAC5B,MAAM,IAAI,EAAkB;GAE9B,IAAI,GAAK,UAAU,WAAW,KAI5B,MAHI,EAAgB,CAAG,IACf,IAAI,EAA0B,IAEhC,IAAI,EAAyB;GAErC,IAAM,IAAM,qCAAqC,EAAI,IAAI;GACzD,MAAM,IAAI,EAAW,GAAK,QAAQ,GAAG,GAAK,WAAW,KAAK,GAAK;EACjE;CACF;CAEA,eAAe,EAAgC,GAAgB,GAAgC;EAC7F,IAAI;GAEF,OADA,MAAM,EAAM,QAAQ,KAAK,CAAG,GACrB;EACT,SAAS,GAAU;GAEjB,KADe,GAAK,UAAU,UAAU,GAAK,YAC9B,KACb,MAAM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,qBAAK,IAAI,KAAK,EAAE,GAAG,EAAQ;GACjC,aAAa;EACf,CAAC;CACH;CAEA,OAAO;EACL;EACA;EACA;EACA;EACA;EACA;CACF;AACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "solid-logic",
3
- "version": "6.0.0-1",
3
+ "version": "6.0.0",
4
4
  "description": "Core business logic of SolidOS",
5
5
  "main": "dist/index.cjs.js",
6
6
  "module": "dist/index.esm.js",
@@ -55,7 +55,7 @@
55
55
  "eslint-plugin-import": "^2.32.0",
56
56
  "vitest": "^4.1.9",
57
57
  "jsdom": "^21.1.0",
58
- "rdflib": "^2.4.0",
58
+ "rdflib": "^2.4.1",
59
59
  "ts-loader": "^9.6.1",
60
60
  "tslib": "^2.8.1",
61
61
  "typescript": "^5.9.3",