solid-logic 6.0.1-3 → 6.0.1-5

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 (99) hide show
  1. package/dist/acl/accessControlSubjects.cjs.js +1 -1
  2. package/dist/acl/accessControlSubjects.cjs.js.map +1 -1
  3. package/dist/acl/accessControlSubjects.d.ts.map +1 -1
  4. package/dist/acl/accessControlSubjects.esm.js +38 -37
  5. package/dist/acl/accessControlSubjects.esm.js.map +1 -1
  6. package/dist/acl/aclLogic.cjs.js +1 -1
  7. package/dist/acl/aclLogic.cjs.js.map +1 -1
  8. package/dist/acl/aclLogic.esm.js +2 -6
  9. package/dist/acl/aclLogic.esm.js.map +1 -1
  10. package/dist/authSession/authSession.cjs.js.map +1 -1
  11. package/dist/authSession/authSession.esm.js.map +1 -1
  12. package/dist/authSession/events.cjs.js.map +1 -1
  13. package/dist/authSession/events.esm.js.map +1 -1
  14. package/dist/authSession/flagAuthorizationOnTransitions.cjs.js.map +1 -1
  15. package/dist/authSession/flagAuthorizationOnTransitions.esm.js.map +1 -1
  16. package/dist/authSession/identityState.cjs.js +1 -1
  17. package/dist/authSession/identityState.cjs.js.map +1 -1
  18. package/dist/authSession/identityState.esm.js +3 -17
  19. package/dist/authSession/identityState.esm.js.map +1 -1
  20. package/dist/authSession/issuer.cjs.js.map +1 -1
  21. package/dist/authSession/issuer.esm.js.map +1 -1
  22. package/dist/authSession/session.cjs.js.map +1 -1
  23. package/dist/authSession/session.esm.js.map +1 -1
  24. package/dist/authn/SolidAuthnLogic.cjs.js.map +1 -1
  25. package/dist/authn/SolidAuthnLogic.esm.js.map +1 -1
  26. package/dist/authn/authUtil.cjs.js.map +1 -1
  27. package/dist/authn/authUtil.esm.js.map +1 -1
  28. package/dist/authn/serverLogout.cjs.js.map +1 -1
  29. package/dist/authn/serverLogout.esm.js.map +1 -1
  30. package/dist/chat/chatLogic.cjs.js.map +1 -1
  31. package/dist/chat/chatLogic.esm.js.map +1 -1
  32. package/dist/directory/catalogDirectory.cjs.js.map +1 -1
  33. package/dist/directory/catalogDirectory.esm.js.map +1 -1
  34. package/dist/directory/contactsDirectory.cjs.js.map +1 -1
  35. package/dist/directory/contactsDirectory.esm.js.map +1 -1
  36. package/dist/directory/directoryHelpers.cjs.js.map +1 -1
  37. package/dist/directory/directoryHelpers.esm.js.map +1 -1
  38. package/dist/directory/directoryLogic.cjs.js.map +1 -1
  39. package/dist/directory/directoryLogic.esm.js.map +1 -1
  40. package/dist/directory/friendsDirectory.cjs.js.map +1 -1
  41. package/dist/directory/friendsDirectory.esm.js.map +1 -1
  42. package/dist/inbox/inboxLogic.cjs.js.map +1 -1
  43. package/dist/inbox/inboxLogic.esm.js.map +1 -1
  44. package/dist/index.cjs.js.map +1 -1
  45. package/dist/index.d.ts +1 -1
  46. package/dist/index.d.ts.map +1 -1
  47. package/dist/index.esm.js.map +1 -1
  48. package/dist/issuer/issuerLogic.cjs.js.map +1 -1
  49. package/dist/issuer/issuerLogic.esm.js.map +1 -1
  50. package/dist/logic/CustomError.cjs.js.map +1 -1
  51. package/dist/logic/CustomError.esm.js.map +1 -1
  52. package/dist/logic/solidLogic.cjs.js.map +1 -1
  53. package/dist/logic/solidLogic.esm.js.map +1 -1
  54. package/dist/logic/solidLogicSingleton.cjs.js +1 -1
  55. package/dist/logic/solidLogicSingleton.cjs.js.map +1 -1
  56. package/dist/logic/solidLogicSingleton.esm.js +1 -1
  57. package/dist/logic/solidLogicSingleton.esm.js.map +1 -1
  58. package/dist/profile/profileAclDocuments.cjs.js.map +1 -1
  59. package/dist/profile/profileAclDocuments.esm.js.map +1 -1
  60. package/dist/profile/profileDocuments.cjs.js.map +1 -1
  61. package/dist/profile/profileDocuments.esm.js.map +1 -1
  62. package/dist/profile/profileLogic.cjs.js.map +1 -1
  63. package/dist/profile/profileLogic.esm.js.map +1 -1
  64. package/dist/resource/resourceHttp.cjs.js.map +1 -1
  65. package/dist/resource/resourceHttp.esm.js.map +1 -1
  66. package/dist/resource/resourceLogic.cjs.js +1 -1
  67. package/dist/resource/resourceLogic.cjs.js.map +1 -1
  68. package/dist/resource/resourceLogic.d.ts.map +1 -1
  69. package/dist/resource/resourceLogic.esm.js +124 -57
  70. package/dist/resource/resourceLogic.esm.js.map +1 -1
  71. package/dist/resource/resourceMetadata.cjs.js +1 -1
  72. package/dist/resource/resourceMetadata.cjs.js.map +1 -1
  73. package/dist/resource/resourceMetadata.d.ts +2 -0
  74. package/dist/resource/resourceMetadata.d.ts.map +1 -1
  75. package/dist/resource/resourceMetadata.esm.js +6 -2
  76. package/dist/resource/resourceMetadata.esm.js.map +1 -1
  77. package/dist/typeIndex/typeIndexAclDocuments.cjs.js.map +1 -1
  78. package/dist/typeIndex/typeIndexAclDocuments.esm.js.map +1 -1
  79. package/dist/typeIndex/typeIndexDocuments.cjs.js.map +1 -1
  80. package/dist/typeIndex/typeIndexDocuments.esm.js.map +1 -1
  81. package/dist/typeIndex/typeIndexLogic.cjs.js +1 -1
  82. package/dist/typeIndex/typeIndexLogic.cjs.js.map +1 -1
  83. package/dist/typeIndex/typeIndexLogic.esm.js +5 -10
  84. package/dist/typeIndex/typeIndexLogic.esm.js.map +1 -1
  85. package/dist/types.d.ts +17 -0
  86. package/dist/types.d.ts.map +1 -1
  87. package/dist/util/containerLogic.cjs.js.map +1 -1
  88. package/dist/util/containerLogic.esm.js.map +1 -1
  89. package/dist/util/debug.cjs.js +1 -1
  90. package/dist/util/debug.cjs.js.map +1 -1
  91. package/dist/util/debug.esm.js +4 -1
  92. package/dist/util/debug.esm.js.map +1 -1
  93. package/dist/util/ns.cjs.js.map +1 -1
  94. package/dist/util/ns.esm.js.map +1 -1
  95. package/dist/util/utilityLogic.cjs.js.map +1 -1
  96. package/dist/util/utilityLogic.esm.js.map +1 -1
  97. package/dist/util/utils.cjs.js.map +1 -1
  98. package/dist/util/utils.esm.js.map +1 -1
  99. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"debug.esm.js","names":[],"sources":["../../src/util/debug.ts"],"sourcesContent":["\nexport function log(...args: any[]): void {\n console.log(...args)\n}\n\nexport function warn(...args: any[]): void {\n console.warn(...args)\n}\n\nexport function error(...args: any[]): void {\n console.error(...args)\n}\n\nexport function trace(...args: any[]): void {\n console.trace(...args)\n}\n"],"mappings":";AACA,SAAgB,EAAI,GAAG,GAAmB;CACxC,QAAQ,IAAI,GAAG,CAAI;AACrB;AAEA,SAAgB,EAAK,GAAG,GAAmB;CACzC,QAAQ,KAAK,GAAG,CAAI;AACtB"}
1
+ {"version":3,"file":"debug.esm.js","names":["log","args","warn","error"],"sources":["../../src/util/debug.ts"],"sourcesContent":["\nexport function log(...args: any[]): void {\n console.log(...args)\n}\n\nexport function warn(...args: any[]): void {\n console.warn(...args)\n}\n\nexport function error(...args: any[]): void {\n console.error(...args)\n}\n\nexport function trace(...args: any[]): void {\n console.trace(...args)\n}\n"],"mappings":";AACA,SAAgBA,EAAI,GAAGC,GAAmB;CACxC,QAAQ,IAAI,GAAGA,CAAI;AACrB;AAEA,SAAgBC,EAAK,GAAGD,GAAmB;CACzC,QAAQ,KAAK,GAAGA,CAAI;AACtB;AAEA,SAAgBE,EAAM,GAAGF,GAAmB;CAC1C,QAAQ,MAAM,GAAGA,CAAI;AACvB"}
@@ -1 +1 @@
1
- {"version":3,"file":"ns.cjs.js","names":[],"sources":["../../src/util/ns.ts"],"sourcesContent":["// Namespaces we commonly use and have common prefixes for around Solid\nimport solidNamespace from 'solid-namespace' // Delegate to this which takes RDFlib as param.\nimport * as $rdf from 'rdflib'\n\nexport const ns = solidNamespace($rdf)"],"mappings":"+IAIA,IAAa,GAAA,EAAK,EAAA,QAAA,CAAe,CAAI"}
1
+ {"version":3,"file":"ns.cjs.js","names":["solidNamespace","$rdf","require_runtime","rdflib","solid_namespace","ns"],"sources":["../../src/util/ns.ts"],"sourcesContent":["// Namespaces we commonly use and have common prefixes for around Solid\nimport solidNamespace from 'solid-namespace' // Delegate to this which takes RDFlib as param.\nimport * as $rdf from 'rdflib'\n\nexport const ns = solidNamespace($rdf)"],"mappings":"+IAIA,IAAaK,GAAA,EAAKL,EAAAA,QAAAA,CAAeC,CAAI"}
@@ -1 +1 @@
1
- {"version":3,"file":"ns.esm.js","names":[],"sources":["../../src/util/ns.ts"],"sourcesContent":["// Namespaces we commonly use and have common prefixes for around Solid\nimport solidNamespace from 'solid-namespace' // Delegate to this which takes RDFlib as param.\nimport * as $rdf from 'rdflib'\n\nexport const ns = solidNamespace($rdf)"],"mappings":";;;AAIA,IAAa,IAAK,EAAe,CAAI"}
1
+ {"version":3,"file":"ns.esm.js","names":["$rdf","solidNamespace","ns"],"sources":["../../src/util/ns.ts"],"sourcesContent":["// Namespaces we commonly use and have common prefixes for around Solid\nimport solidNamespace from 'solid-namespace' // Delegate to this which takes RDFlib as param.\nimport * as $rdf from 'rdflib'\n\nexport const ns = solidNamespace($rdf)"],"mappings":";;;AAIA,IAAaE,IAAKD,EAAeD,CAAI"}
@@ -1 +1 @@
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,IAAK,CAClB,IAAM,EAAM,kCAAkC,EAAI,IAAI,IACtD,MAAM,IAAI,EAAA,kBAAkB,CAAG,CACjC,CACF,CACA,OAAO,MAAM,EAAM,QAA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EAAQ,OAAO,IACjC,+CACA,EACF,CAAC,CAAC,KAAK;CAAI,EAEP,EAAQ,gBACV,GAAO,CACL,sCACA,gBAAgB,EAAQ,UAAU,IAClC,mBAAmB,EAAQ,OAAO,IAClC,cAAc,EAAQ,cAAc,GACpC,EACF,CAAC,CAAC,KAAK;CAAI,GAGT,EAAQ,eACV,GAAO,CACL,qCACA,gBAAgB,EAAQ,UAAU,IAClC,kBAAkB,EAAQ,OAAO,IACjC,cAAc,EAAQ,aAAa,GACnC,EACF,CAAC,CAAC,KAAK;CAAI,GAGb,IAAM,EAAY,MAAM,EAAS,eAAA,EAAc,EAAA,IAAA,CAAI,EAAQ,MAAM,CAAC,EAClE,OAAO,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
+ {"version":3,"file":"utilityLogic.cjs.js","names":["WebOperationError","UnauthorizedError","differentOrigin","CrossOriginForbiddenError","SameOriginForbiddenError","FetchError","loadAuthorizedDocument","NotEditableError","st","sym","require_debug","require_flagAuthorizationOnTransitions","require_utils","require_CustomError","rdflib","createUtilityLogic","loadOrCreateIfNotExists","store","doc","err","putErr","msg","loadOrCreateWithContentOnCreate","followOrCreateLink","result","subject","predicate","object","followOrCreateLinkWithContentOnCreate","data","setSinglePeerAccess","str","options","aclDocUrl","aclLogic","createEmptyRdfDoc","comment"],"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,SAAgBe,EAAmB,EAAO,EAAU,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AgB,EAAiB,CAChE,MAAMlB,EAAM,QAAQ,aAAa,MAAOC,EAAI,IAAK,CAC/C,KAAM,KAAK,IAAI,KAAO,GAAGkB,EAAQ,IACjC,YAAa,aACf,CAAC,CACH,CAEA,MAAO,CACL,sBACA,oBACA,qBACA,wCACA,0BACA,iCACF,CACF"}
@@ -1 +1 @@
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,KAAK;MAClB,IAAM,IAAM,kCAAkC,EAAI,IAAI;MACtD,MAAM,IAAI,EAAkB,CAAG;KACjC;IACF;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;GAEj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iB;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":["createUtilityLogic","loadOrCreateIfNotExists","store","doc","err","putErr","msg","WebOperationError","UnauthorizedError","differentOrigin","CrossOriginForbiddenError","SameOriginForbiddenError","FetchError","loadOrCreateWithContentOnCreate","followOrCreateLink","loadAuthorizedDocument","warn","NotEditableError","result","subject","predicate","st","object","followOrCreateLinkWithContentOnCreate","data","setSinglePeerAccess","str","options","aclDocUrl","aclLogic","sym","createEmptyRdfDoc","comment"],"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,SAAgBA,EAAmB,GAAO,GAAU,GAAgB;CAOlE,eAAeC,EAAwB,GAAgB;EACrD,IAAI;GACF,OAAO,MAAMC,EAAM,QAAQ,KAAKC,CAAG;EACrC,SAASC,GAAU;GACjB,IAAIA,GAAK,UAAU,WAAW,KAAK;IACjC,IAAI;KACF,MAAMF,EAAM,QAAQ,aAAa,OAAOC,EAAI,KAAK;MAC/C,MAAM;MACN,aAAa;MACb,SAAS,EAAE,iBAAiB,IAAI;KAClC,CAAC;IACH,SAASE,GAAa;KAEpB,KADeA,GAAQ,UAAU,UAAUA,GAAQ,YACpC,KAAK;MAClB,IAAMC,IAAM,kCAAkCH,EAAI,IAAIE;MACtD,MAAM,IAAIE,EAAkBD,CAAG;KACjC;IACF;IACA,OAAO,MAAMJ,EAAM,QAAQ,KAAKC,CAAG;GACrC;GACA,IAAIC,GAAK,UAAU,WAAW,KAC5B,MAAM,IAAII,EAAkB;GAE9B,IAAIJ,GAAK,UAAU,WAAW,KAI5B,MAHIK,EAAgBN,CAAG,IACf,IAAI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AClC,cAAcA,EAAQ,cAAc;GACpC;EACF,CAAC,CAAC,KAAK,IAAI,IAGTA,EAAQ,iBACV,KAAO;GACL;GACA,gBAAgBA,EAAQ,UAAU;GAClC,kBAAkBA,EAAQ,OAAO;GACjC,cAAcA,EAAQ,aAAa;GACnC;EACF,CAAC,CAAC,KAAK,IAAI;EAGb,IAAMC,IAAY,MAAMC,EAAS,cAAcC,EAAIH,EAAQ,MAAM,CAAC;EAClE,OAAOzB,EAAM,QAAQ,OAAO0B,GAAW;GACrC,QAAQ;GACR,MAAMF;GACN,SAAS,CAAC,CAAC,gBAAgB,aAAa,CAAC;EAC3C,CAAC;CACH;CAEA,eAAeK,EAAkB,GAAgB,GAAiB;EAChE,MAAM7B,EAAM,QAAQ,aAAa,OAAOC,EAAI,KAAK;GAC/C,MAAM,qBAAK,IAAI,KAAK,EAAE,GAAG6B,EAAQ;GACjC,aAAa;EACf,CAAC;CACH;CAEA,OAAO;EACL;EACA;EACA;EACA;EACA;EACA;CACF;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"utils.cjs.js","names":[],"sources":["../../src/util/utils.ts"],"sourcesContent":["import { NamedNode, sym } from 'rdflib'\n\nexport function newThing(doc: NamedNode): NamedNode {\n return sym(doc.uri + '#' + 'id' + ('' + Date.now()))\n}\n\nexport function uniqueNodes (arr: NamedNode[]): NamedNode[] {\n const uris = arr.map(x => x.uri)\n const set = new Set(uris)\n const uris2 = Array.from(set)\n const arr2 = uris2.map(u => new NamedNode(u))\n return arr2 // Array.from(new Set(arr.map(x => x.uri))).map(u => sym(u))\n}\n\nexport function getArchiveUrl(baseUrl: string, date: Date) {\n const year = date.getUTCFullYear()\n const month = ('0' + (date.getUTCMonth()+1)).slice(-2)\n const day = ('0' + (date.getUTCDate())).slice(-2)\n const parts = baseUrl.split('/')\n const filename = parts[parts.length -1 ]\n return new URL(`./archive/${year}/${month}/${day}/${filename}`, baseUrl).toString()\n}\n\nexport function differentOrigin(doc): boolean {\n if (!doc) {\n return true\n }\n return (\n `${window.location.origin}/` !== new URL(doc.value).origin\n )\n}\n\nexport function suggestPreferencesFile (me:NamedNode) {\n const stripped = me.uri.replace('/profile/', '/').replace('/public/', '/')\n // const stripped = me.uri.replace(\\/[p|P]rofile/\\g, '/').replace(\\/[p|P]ublic/\\g, '/')\n const folderURI = stripped.split('/').slice(0,-1).join('/') + '/settings/'\n const fileURI = folderURI + 'prefs.ttl'\n return sym(fileURI)\n}\n\nexport function determineChatContainer(\n invitee: NamedNode,\n podRoot: NamedNode\n): NamedNode {\n // Create chat\n // See https://gitter.im/solid/chat-app?at=5f3c800f855be416a23ae74a\n const chatContainerStr = new URL(\n `IndividualChats/${new URL(invitee.value).host}/`,\n podRoot.value\n ).toString()\n return new NamedNode(chatContainerStr)\n}\n"],"mappings":"wBAEA,SAAgB,EAAS,EAA2B,CAChD,OAAA,EAAO,EAAA,IAAA,CAAI,EAAI,IAAM,OAAc,GAAK,KAAK,IAAI,EAAE,CACvD,CAUA,SAAgB,EAAc,EAAiB,EAAY,CACvD,IAAM,EAAO,EAAK,eAAe,EAC3B,GAAS,KAAO,EAAK,YAAY,EAAE,GAAA,CAAI,MAAM,EAAE,EAC/C,GAAO,IAAO,EAAK,WAAW,EAAA,CAAI,MAAM,EAAE,EAC1C,EAAQ,EAAQ,MAAM,GAAG,EACzB,EAAW,EAAM,EAAM,OAAQ,GACrC,OAAO,IAAI,IAAI,aAAa,EAAK,GAAG,EAAM,GAAG,EAAI,GAAG,IAAY,CAAO,CAAC,CAAC,SAAS,CACtF,CAEA,SAAgB,EAAgB,EAAc,CAI1C,MAHA,CAAK,GAID,GAAG,OAAO,SAAS,OAAO,KAAO,IAAI,IAAI,EAAI,KAAK,CAAC,CAAC,MAE5D,CAEA,SAAgB,EAAwB,EAAc,CAIlD,IAAM,EAHW,EAAG,IAAI,QAAQ,YAAa,GAAG,CAAC,CAAC,QAAQ,WAAY,GAEpD,CAAA,CAAS,MAAM,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,KAAK,GAAG,EAAA,sBAE1D,OAAA,EAAO,EAAA,IAAA,CAAI,CAAO,CACtB,CAEA,SAAgB,EACZ,EACA,EACS,CAGT,IAAM,EAAmB,IAAI,IACzB,mBAAmB,IAAI,IAAI,EAAQ,KAAK,CAAC,CAAC,KAAK,GAC/C,EAAQ,KACZ,CAAC,CAAC,SAAS,EACX,OAAO,IAAI,EAAA,UAAU,CAAgB,CACzC"}
1
+ {"version":3,"file":"utils.cjs.js","names":["sym","NamedNode","rdflib","newThing","doc","getArchiveUrl","year","date","month","day","parts","baseUrl","filename","differentOrigin","suggestPreferencesFile","fileURI","me","determineChatContainer","chatContainerStr","invitee","podRoot"],"sources":["../../src/util/utils.ts"],"sourcesContent":["import { NamedNode, sym } from 'rdflib'\n\nexport function newThing(doc: NamedNode): NamedNode {\n return sym(doc.uri + '#' + 'id' + ('' + Date.now()))\n}\n\nexport function uniqueNodes (arr: NamedNode[]): NamedNode[] {\n const uris = arr.map(x => x.uri)\n const set = new Set(uris)\n const uris2 = Array.from(set)\n const arr2 = uris2.map(u => new NamedNode(u))\n return arr2 // Array.from(new Set(arr.map(x => x.uri))).map(u => sym(u))\n}\n\nexport function getArchiveUrl(baseUrl: string, date: Date) {\n const year = date.getUTCFullYear()\n const month = ('0' + (date.getUTCMonth()+1)).slice(-2)\n const day = ('0' + (date.getUTCDate())).slice(-2)\n const parts = baseUrl.split('/')\n const filename = parts[parts.length -1 ]\n return new URL(`./archive/${year}/${month}/${day}/${filename}`, baseUrl).toString()\n}\n\nexport function differentOrigin(doc): boolean {\n if (!doc) {\n return true\n }\n return (\n `${window.location.origin}/` !== new URL(doc.value).origin\n )\n}\n\nexport function suggestPreferencesFile (me:NamedNode) {\n const stripped = me.uri.replace('/profile/', '/').replace('/public/', '/')\n // const stripped = me.uri.replace(\\/[p|P]rofile/\\g, '/').replace(\\/[p|P]ublic/\\g, '/')\n const folderURI = stripped.split('/').slice(0,-1).join('/') + '/settings/'\n const fileURI = folderURI + 'prefs.ttl'\n return sym(fileURI)\n}\n\nexport function determineChatContainer(\n invitee: NamedNode,\n podRoot: NamedNode\n): NamedNode {\n // Create chat\n // See https://gitter.im/solid/chat-app?at=5f3c800f855be416a23ae74a\n const chatContainerStr = new URL(\n `IndividualChats/${new URL(invitee.value).host}/`,\n podRoot.value\n ).toString()\n return new NamedNode(chatContainerStr)\n}\n"],"mappings":"wBAEA,SAAgBG,EAAS,EAA2B,CAChD,OAAA,EAAOH,EAAAA,IAAAA,CAAII,EAAI,IAAM,OAAc,GAAK,KAAK,IAAI,EAAE,CACvD,CAUA,SAAgBC,EAAc,EAAiB,EAAY,CACvD,IAAMC,EAAOC,EAAK,eAAe,EAC3BC,GAAS,KAAOD,EAAK,YAAY,EAAE,GAAA,CAAI,MAAM,EAAE,EAC/CE,GAAO,IAAOF,EAAK,WAAW,EAAA,CAAI,MAAM,EAAE,EAC1CG,EAAQC,EAAQ,MAAM,GAAG,EACzBC,EAAWF,EAAMA,EAAM,OAAQ,GACrC,OAAO,IAAI,IAAI,aAAaJ,EAAK,GAAGE,EAAM,GAAGC,EAAI,GAAGG,IAAYD,CAAO,CAAC,CAAC,SAAS,CACtF,CAEA,SAAgBE,EAAgB,EAAc,CAI1C,MAHA,CAAKT,GAID,GAAG,OAAO,SAAS,OAAO,KAAO,IAAI,IAAIA,EAAI,KAAK,CAAC,CAAC,MAE5D,CAEA,SAAgBU,EAAwB,EAAc,CAIlD,IAAMC,EAHWC,EAAG,IAAI,QAAQ,YAAa,GAAG,CAAC,CAAC,QAAQ,WAAY,GAEpD,CAAA,CAAS,MAAM,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,KAAK,GAAG,EAAA,sBAE1D,OAAA,EAAOhB,EAAAA,IAAAA,CAAIe,CAAO,CACtB,CAEA,SAAgBE,EACZ,EACA,EACS,CAGT,IAAMC,EAAmB,IAAI,IACzB,mBAAmB,IAAI,IAAIC,EAAQ,KAAK,CAAC,CAAC,KAAK,GAC/CC,EAAQ,KACZ,CAAC,CAAC,SAAS,EACX,OAAO,IAAInB,EAAAA,UAAUiB,CAAgB,CACzC"}
@@ -1 +1 @@
1
- {"version":3,"file":"utils.esm.js","names":[],"sources":["../../src/util/utils.ts"],"sourcesContent":["import { NamedNode, sym } from 'rdflib'\n\nexport function newThing(doc: NamedNode): NamedNode {\n return sym(doc.uri + '#' + 'id' + ('' + Date.now()))\n}\n\nexport function uniqueNodes (arr: NamedNode[]): NamedNode[] {\n const uris = arr.map(x => x.uri)\n const set = new Set(uris)\n const uris2 = Array.from(set)\n const arr2 = uris2.map(u => new NamedNode(u))\n return arr2 // Array.from(new Set(arr.map(x => x.uri))).map(u => sym(u))\n}\n\nexport function getArchiveUrl(baseUrl: string, date: Date) {\n const year = date.getUTCFullYear()\n const month = ('0' + (date.getUTCMonth()+1)).slice(-2)\n const day = ('0' + (date.getUTCDate())).slice(-2)\n const parts = baseUrl.split('/')\n const filename = parts[parts.length -1 ]\n return new URL(`./archive/${year}/${month}/${day}/${filename}`, baseUrl).toString()\n}\n\nexport function differentOrigin(doc): boolean {\n if (!doc) {\n return true\n }\n return (\n `${window.location.origin}/` !== new URL(doc.value).origin\n )\n}\n\nexport function suggestPreferencesFile (me:NamedNode) {\n const stripped = me.uri.replace('/profile/', '/').replace('/public/', '/')\n // const stripped = me.uri.replace(\\/[p|P]rofile/\\g, '/').replace(\\/[p|P]ublic/\\g, '/')\n const folderURI = stripped.split('/').slice(0,-1).join('/') + '/settings/'\n const fileURI = folderURI + 'prefs.ttl'\n return sym(fileURI)\n}\n\nexport function determineChatContainer(\n invitee: NamedNode,\n podRoot: NamedNode\n): NamedNode {\n // Create chat\n // See https://gitter.im/solid/chat-app?at=5f3c800f855be416a23ae74a\n const chatContainerStr = new URL(\n `IndividualChats/${new URL(invitee.value).host}/`,\n podRoot.value\n ).toString()\n return new NamedNode(chatContainerStr)\n}\n"],"mappings":";;AAEA,SAAgB,EAAS,GAA2B;CAChD,OAAO,EAAI,EAAI,MAAM,SAAc,KAAK,KAAK,IAAI,EAAE;AACvD;AAUA,SAAgB,EAAc,GAAiB,GAAY;CACvD,IAAM,IAAO,EAAK,eAAe,GAC3B,KAAS,OAAO,EAAK,YAAY,IAAE,GAAA,CAAI,MAAM,EAAE,GAC/C,KAAO,MAAO,EAAK,WAAW,EAAA,CAAI,MAAM,EAAE,GAC1C,IAAQ,EAAQ,MAAM,GAAG,GACzB,IAAW,EAAM,EAAM,SAAQ;CACrC,OAAO,IAAI,IAAI,aAAa,EAAK,GAAG,EAAM,GAAG,EAAI,GAAG,KAAY,CAAO,CAAC,CAAC,SAAS;AACtF;AAEA,SAAgB,EAAgB,GAAc;CAI1C,OAHA,CAAK,KAID,GAAG,OAAO,SAAS,OAAO,OAAO,IAAI,IAAI,EAAI,KAAK,CAAC,CAAC;AAE5D;AAEA,SAAgB,EAAwB,GAAc;CAIlD,IAAM,IAHW,EAAG,IAAI,QAAQ,aAAa,GAAG,CAAC,CAAC,QAAQ,YAAY,GAEpD,CAAA,CAAS,MAAM,GAAG,CAAC,CAAC,MAAM,GAAE,EAAE,CAAC,CAAC,KAAK,GAAG,IAAA;CAE1D,OAAO,EAAI,CAAO;AACtB;AAEA,SAAgB,EACZ,GACA,GACS;CAGT,IAAM,IAAmB,IAAI,IACzB,mBAAmB,IAAI,IAAI,EAAQ,KAAK,CAAC,CAAC,KAAK,IAC/C,EAAQ,KACZ,CAAC,CAAC,SAAS;CACX,OAAO,IAAI,EAAU,CAAgB;AACzC"}
1
+ {"version":3,"file":"utils.esm.js","names":["newThing","sym","doc","getArchiveUrl","year","date","month","day","parts","baseUrl","filename","differentOrigin","suggestPreferencesFile","fileURI","me","determineChatContainer","chatContainerStr","invitee","podRoot","NamedNode"],"sources":["../../src/util/utils.ts"],"sourcesContent":["import { NamedNode, sym } from 'rdflib'\n\nexport function newThing(doc: NamedNode): NamedNode {\n return sym(doc.uri + '#' + 'id' + ('' + Date.now()))\n}\n\nexport function uniqueNodes (arr: NamedNode[]): NamedNode[] {\n const uris = arr.map(x => x.uri)\n const set = new Set(uris)\n const uris2 = Array.from(set)\n const arr2 = uris2.map(u => new NamedNode(u))\n return arr2 // Array.from(new Set(arr.map(x => x.uri))).map(u => sym(u))\n}\n\nexport function getArchiveUrl(baseUrl: string, date: Date) {\n const year = date.getUTCFullYear()\n const month = ('0' + (date.getUTCMonth()+1)).slice(-2)\n const day = ('0' + (date.getUTCDate())).slice(-2)\n const parts = baseUrl.split('/')\n const filename = parts[parts.length -1 ]\n return new URL(`./archive/${year}/${month}/${day}/${filename}`, baseUrl).toString()\n}\n\nexport function differentOrigin(doc): boolean {\n if (!doc) {\n return true\n }\n return (\n `${window.location.origin}/` !== new URL(doc.value).origin\n )\n}\n\nexport function suggestPreferencesFile (me:NamedNode) {\n const stripped = me.uri.replace('/profile/', '/').replace('/public/', '/')\n // const stripped = me.uri.replace(\\/[p|P]rofile/\\g, '/').replace(\\/[p|P]ublic/\\g, '/')\n const folderURI = stripped.split('/').slice(0,-1).join('/') + '/settings/'\n const fileURI = folderURI + 'prefs.ttl'\n return sym(fileURI)\n}\n\nexport function determineChatContainer(\n invitee: NamedNode,\n podRoot: NamedNode\n): NamedNode {\n // Create chat\n // See https://gitter.im/solid/chat-app?at=5f3c800f855be416a23ae74a\n const chatContainerStr = new URL(\n `IndividualChats/${new URL(invitee.value).host}/`,\n podRoot.value\n ).toString()\n return new NamedNode(chatContainerStr)\n}\n"],"mappings":";;AAEA,SAAgBA,EAAS,GAA2B;CAChD,OAAOC,EAAIC,EAAI,MAAM,SAAc,KAAK,KAAK,IAAI,EAAE;AACvD;AAUA,SAAgBC,EAAc,GAAiB,GAAY;CACvD,IAAMC,IAAOC,EAAK,eAAe,GAC3BC,KAAS,OAAOD,EAAK,YAAY,IAAE,GAAA,CAAI,MAAM,EAAE,GAC/CE,KAAO,MAAOF,EAAK,WAAW,EAAA,CAAI,MAAM,EAAE,GAC1CG,IAAQC,EAAQ,MAAM,GAAG,GACzBC,IAAWF,EAAMA,EAAM,SAAQ;CACrC,OAAO,IAAI,IAAI,aAAaJ,EAAK,GAAGE,EAAM,GAAGC,EAAI,GAAGG,KAAYD,CAAO,CAAC,CAAC,SAAS;AACtF;AAEA,SAAgBE,EAAgB,GAAc;CAI1C,OAHA,CAAKT,KAID,GAAG,OAAO,SAAS,OAAO,OAAO,IAAI,IAAIA,EAAI,KAAK,CAAC,CAAC;AAE5D;AAEA,SAAgBU,EAAwB,GAAc;CAIlD,IAAMC,IAHWC,EAAG,IAAI,QAAQ,aAAa,GAAG,CAAC,CAAC,QAAQ,YAAY,GAEpD,CAAA,CAAS,MAAM,GAAG,CAAC,CAAC,MAAM,GAAE,EAAE,CAAC,CAAC,KAAK,GAAG,IAAA;CAE1D,OAAOb,EAAIY,CAAO;AACtB;AAEA,SAAgBE,EACZ,GACA,GACS;CAGT,IAAMC,IAAmB,IAAI,IACzB,mBAAmB,IAAI,IAAIC,EAAQ,KAAK,CAAC,CAAC,KAAK,IAC/CC,EAAQ,KACZ,CAAC,CAAC,SAAS;CACX,OAAO,IAAIC,EAAUH,CAAgB;AACzC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "solid-logic",
3
- "version": "6.0.1-3",
3
+ "version": "6.0.1-5",
4
4
  "description": "Core business logic of SolidOS",
5
5
  "main": "dist/index.cjs.js",
6
6
  "module": "dist/index.esm.js",