solid-logic 6.0.0-2 → 6.0.1-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.
- package/dist/_virtual/_rolldown/runtime.cjs.js +1 -1
- package/dist/acl/accessControlSubjects.cjs.js +2 -0
- package/dist/acl/accessControlSubjects.cjs.js.map +1 -0
- package/dist/acl/accessControlSubjects.d.ts +8 -0
- package/dist/acl/accessControlSubjects.d.ts.map +1 -0
- package/dist/acl/accessControlSubjects.esm.js +75 -0
- package/dist/acl/accessControlSubjects.esm.js.map +1 -0
- package/dist/acl/aclLogic.cjs.js +1 -1
- package/dist/acl/aclLogic.cjs.js.map +1 -1
- package/dist/acl/aclLogic.d.ts +7 -0
- package/dist/acl/aclLogic.d.ts.map +1 -0
- package/dist/acl/aclLogic.esm.js +111 -27
- package/dist/acl/aclLogic.esm.js.map +1 -1
- package/dist/authSession/authSession.cjs.js.map +1 -1
- package/dist/authSession/authSession.d.ts +42 -0
- package/dist/authSession/authSession.d.ts.map +1 -0
- package/dist/authSession/authSession.esm.js.map +1 -1
- package/dist/authSession/events.cjs.js.map +1 -1
- package/dist/authSession/events.d.ts +25 -0
- package/dist/authSession/events.d.ts.map +1 -0
- package/dist/authSession/events.esm.js.map +1 -1
- package/dist/authSession/flagAuthorizationOnTransitions.cjs.js +1 -1
- package/dist/authSession/flagAuthorizationOnTransitions.cjs.js.map +1 -1
- package/dist/authSession/flagAuthorizationOnTransitions.d.ts +76 -0
- package/dist/authSession/flagAuthorizationOnTransitions.d.ts.map +1 -0
- package/dist/authSession/flagAuthorizationOnTransitions.esm.js +1 -1
- package/dist/authSession/flagAuthorizationOnTransitions.esm.js.map +1 -1
- package/dist/authSession/identityState.cjs.js +1 -1
- package/dist/authSession/identityState.cjs.js.map +1 -1
- package/dist/authSession/identityState.d.ts +199 -0
- package/dist/authSession/identityState.d.ts.map +1 -0
- package/dist/authSession/identityState.esm.js +1 -1
- package/dist/authSession/identityState.esm.js.map +1 -1
- package/dist/authSession/issuer.d.ts +8 -0
- package/dist/authSession/issuer.d.ts.map +1 -0
- package/dist/authSession/session.cjs.js +1 -1
- package/dist/authSession/session.cjs.js.map +1 -1
- package/dist/authSession/session.d.ts +45 -0
- package/dist/authSession/session.d.ts.map +1 -0
- package/dist/authSession/session.esm.js +1 -1
- package/dist/authSession/session.esm.js.map +1 -1
- package/dist/authn/SolidAuthnLogic.cjs.js.map +1 -1
- package/dist/authn/SolidAuthnLogic.d.ts +61 -0
- package/dist/authn/SolidAuthnLogic.d.ts.map +1 -0
- package/dist/authn/SolidAuthnLogic.esm.js.map +1 -1
- package/dist/authn/authUtil.cjs.js.map +1 -1
- package/dist/authn/authUtil.d.ts +17 -0
- package/dist/authn/authUtil.d.ts.map +1 -0
- package/dist/authn/serverLogout.d.ts +6 -0
- package/dist/authn/serverLogout.d.ts.map +1 -0
- package/dist/chat/chatLogic.cjs.js +1 -1
- package/dist/chat/chatLogic.cjs.js.map +1 -1
- package/dist/chat/chatLogic.d.ts +3 -0
- package/dist/chat/chatLogic.d.ts.map +1 -0
- package/dist/chat/chatLogic.esm.js +5 -5
- package/dist/chat/chatLogic.esm.js.map +1 -1
- package/dist/directory/catalogDirectory.cjs.js +2 -0
- package/dist/directory/catalogDirectory.cjs.js.map +1 -0
- package/dist/directory/catalogDirectory.d.ts +5 -0
- package/dist/directory/catalogDirectory.d.ts.map +1 -0
- package/dist/directory/catalogDirectory.esm.js +54 -0
- package/dist/directory/catalogDirectory.esm.js.map +1 -0
- package/dist/directory/contactsDirectory.cjs.js +2 -0
- package/dist/directory/contactsDirectory.cjs.js.map +1 -0
- package/dist/directory/contactsDirectory.d.ts +7 -0
- package/dist/directory/contactsDirectory.d.ts.map +1 -0
- package/dist/directory/contactsDirectory.esm.js +91 -0
- package/dist/directory/contactsDirectory.esm.js.map +1 -0
- package/dist/directory/directoryHelpers.cjs.js +2 -0
- package/dist/directory/directoryHelpers.cjs.js.map +1 -0
- package/dist/directory/directoryHelpers.d.ts +18 -0
- package/dist/directory/directoryHelpers.d.ts.map +1 -0
- package/dist/directory/directoryHelpers.esm.js +89 -0
- package/dist/directory/directoryHelpers.esm.js.map +1 -0
- package/dist/directory/directoryLogic.cjs.js +2 -0
- package/dist/directory/directoryLogic.cjs.js.map +1 -0
- package/dist/directory/directoryLogic.d.ts +6 -0
- package/dist/directory/directoryLogic.d.ts.map +1 -0
- package/dist/directory/directoryLogic.esm.js +41 -0
- package/dist/directory/directoryLogic.esm.js.map +1 -0
- package/dist/directory/friendsDirectory.cjs.js +2 -0
- package/dist/directory/friendsDirectory.cjs.js.map +1 -0
- package/dist/directory/friendsDirectory.d.ts +6 -0
- package/dist/directory/friendsDirectory.d.ts.map +1 -0
- package/dist/directory/friendsDirectory.esm.js +58 -0
- package/dist/directory/friendsDirectory.esm.js.map +1 -0
- package/dist/inbox/inboxLogic.d.ts +3 -0
- package/dist/inbox/inboxLogic.d.ts.map +1 -0
- package/dist/index.cjs.js +1 -1
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +19 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.esm.js +10 -9
- package/dist/index.esm.js.map +1 -1
- package/dist/issuer/issuerLogic.d.ts +8 -0
- package/dist/issuer/issuerLogic.d.ts.map +1 -0
- package/dist/logic/CustomError.cjs.js.map +1 -1
- package/dist/logic/CustomError.d.ts +21 -0
- package/dist/logic/CustomError.d.ts.map +1 -0
- package/dist/logic/CustomError.esm.js.map +1 -1
- package/dist/logic/solidLogic.cjs.js +1 -1
- package/dist/logic/solidLogic.cjs.js.map +1 -1
- package/dist/logic/solidLogic.d.ts +6 -0
- package/dist/logic/solidLogic.d.ts.map +1 -0
- package/dist/logic/solidLogic.esm.js +29 -27
- package/dist/logic/solidLogic.esm.js.map +1 -1
- package/dist/logic/solidLogicSingleton.cjs.js +1 -1
- package/dist/logic/solidLogicSingleton.cjs.js.map +1 -1
- package/dist/logic/solidLogicSingleton.d.ts +4 -0
- package/dist/logic/solidLogicSingleton.d.ts.map +1 -0
- package/dist/logic/solidLogicSingleton.esm.js +2 -1
- package/dist/logic/solidLogicSingleton.esm.js.map +1 -1
- package/dist/profile/profileAclDocuments.d.ts +2 -0
- package/dist/profile/profileAclDocuments.d.ts.map +1 -0
- package/dist/profile/profileDocuments.d.ts +2 -0
- package/dist/profile/profileDocuments.d.ts.map +1 -0
- package/dist/profile/profileLogic.cjs.js.map +1 -1
- package/dist/profile/profileLogic.d.ts +3 -0
- package/dist/profile/profileLogic.d.ts.map +1 -0
- package/dist/profile/profileLogic.esm.js +2 -1
- package/dist/profile/profileLogic.esm.js.map +1 -1
- package/dist/resource/resourceHttp.d.ts +5 -0
- package/dist/resource/resourceHttp.d.ts.map +1 -0
- package/dist/resource/resourceLogic.cjs.js +1 -1
- package/dist/resource/resourceLogic.cjs.js.map +1 -1
- package/dist/resource/resourceLogic.d.ts +4 -0
- package/dist/resource/resourceLogic.d.ts.map +1 -0
- package/dist/resource/resourceLogic.esm.js +36 -26
- package/dist/resource/resourceLogic.esm.js.map +1 -1
- package/dist/resource/resourceMetadata.d.ts +5 -0
- package/dist/resource/resourceMetadata.d.ts.map +1 -0
- package/dist/typeIndex/typeIndexAclDocuments.d.ts +2 -0
- package/dist/typeIndex/typeIndexAclDocuments.d.ts.map +1 -0
- package/dist/typeIndex/typeIndexDocuments.d.ts +3 -0
- package/dist/typeIndex/typeIndexDocuments.d.ts.map +1 -0
- package/dist/typeIndex/typeIndexLogic.cjs.js.map +1 -1
- package/dist/typeIndex/typeIndexLogic.d.ts +3 -0
- package/dist/typeIndex/typeIndexLogic.d.ts.map +1 -0
- package/dist/typeIndex/typeIndexLogic.esm.js +10 -5
- package/dist/typeIndex/typeIndexLogic.esm.js.map +1 -1
- package/dist/types.d.ts +187 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/util/containerLogic.cjs.js.map +1 -1
- package/dist/util/containerLogic.d.ts +12 -0
- package/dist/util/containerLogic.d.ts.map +1 -0
- package/dist/util/containerLogic.esm.js.map +1 -1
- package/dist/util/debug.d.ts +5 -0
- package/dist/util/debug.d.ts.map +1 -0
- package/dist/util/ns.cjs.js.map +1 -1
- package/dist/util/ns.d.ts +2 -0
- package/dist/util/ns.d.ts.map +1 -0
- package/dist/util/utilityLogic.cjs.js +1 -1
- package/dist/util/utilityLogic.cjs.js.map +1 -1
- package/dist/util/utilityLogic.d.ts +16 -0
- package/dist/util/utilityLogic.d.ts.map +1 -0
- package/dist/util/utilityLogic.esm.js +6 -2
- package/dist/util/utilityLogic.esm.js.map +1 -1
- package/dist/util/utils.cjs.js +1 -1
- package/dist/util/utils.cjs.js.map +1 -1
- package/dist/util/utils.d.ts +8 -0
- package/dist/util/utils.d.ts.map +1 -0
- package/dist/util/utils.esm.js +5 -3
- package/dist/util/utils.esm.js.map +1 -1
- package/package.json +6 -4
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utilityLogic.d.ts","sourceRoot":"","sources":["../../src/util/utilityLogic.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAW,MAAM,QAAQ,CAAA;AAa3C,wBAAgB,kBAAkB,CAAC,KAAK,KAAA,EAAE,QAAQ,KAAA,EAAE,cAAc,KAAA;mCA8JpB;QAC1C,UAAU,EAAE,MAAM,CAAC;QACnB,SAAS,EAAE,MAAM,CAAC;QAClB,aAAa,CAAC,EAAE,MAAM,CAAC;QACvB,YAAY,CAAC,EAAE,MAAM,CAAC;QACtB,MAAM,EAAE,MAAM,CAAA;KACf;6BAuCqC,SAAS,WAAW,MAAM;kCAjIrD,SAAS,aACP,SAAS,UACZ,SAAS,OACZ,SAAS,KACb,OAAO,CAAC,SAAS,GAAG,IAAI,CAAC;qDAqCjB,SAAS,aACP,SAAS,UACZ,SAAS,OACZ,SAAS,QACR,MAAM,KACX,OAAO,CAAC,SAAS,GAAG,IAAI,CAAC;mCAjHgB,SAAS;2CAkCD,SAAS,QAAQ,MAAM,KAAG,OAAO,CAAC,OAAO,CAAC;EAiL/F"}
|
|
@@ -17,7 +17,10 @@ function d(d, f, p) {
|
|
|
17
17
|
headers: { "If-None-Match": "*" }
|
|
18
18
|
});
|
|
19
19
|
} catch (t) {
|
|
20
|
-
if ((t?.response?.status ?? t?.status) !== 412)
|
|
20
|
+
if ((t?.response?.status ?? t?.status) !== 412) {
|
|
21
|
+
let n = `createIfNotExists: PUT FAILED: ${e}: ${t}`;
|
|
22
|
+
throw new c(n);
|
|
23
|
+
}
|
|
21
24
|
}
|
|
22
25
|
return await d.fetcher.load(e);
|
|
23
26
|
}
|
|
@@ -58,7 +61,8 @@ function d(d, f, p) {
|
|
|
58
61
|
try {
|
|
59
62
|
await d.updater.update([], [l(n, r, i, o)]);
|
|
60
63
|
} catch (t) {
|
|
61
|
-
|
|
64
|
+
let n = `followOrCreateLink: Error making link in ${o} to ${i}: ${t}`;
|
|
65
|
+
throw e(n), new c(t);
|
|
62
66
|
}
|
|
63
67
|
try {
|
|
64
68
|
await m(i);
|
|
@@ -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,KAEb,MAAM,IAAI,EAAkB,kCADkB,EAAI,IAAI,GACvB;IAEnC;IACA,OAAO,MAAM,EAAM,QAAQ,KAAK,CAAG;GACrC;GACA,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AAI,IAGT,EAAQ,iBACV,KAAO;GACL;GACA,gBAAgB,EAAQ,UAAU;GAClC,kBAAkB,EAAQ,OAAO;GACjC,cAAc,EAAQ,aAAa;GACnC;EACF,CAAC,CAAC,KAAK,IAAI;EAGb,IAAM,IAAY,MAAM,EAAS,cAAc,EAAI,EAAQ,MAAM,CAAC;EAClE,OAAO,EAAM,QAAQ,OAAO,GAAW;GACrC,QAAQ;GACR,MAAM;GACN,SAAS,CAAC,CAAC,gBAAgB,aAAa,CAAC;EAC3C,CAAC;CACH;CAEA,eAAe,EAAkB,GAAgB,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,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,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ACV,KAAO;GACL;GACA,gBAAgB,EAAQ,UAAU;GAClC,kBAAkB,EAAQ,OAAO;GACjC,cAAc,EAAQ,aAAa;GACnC;EACF,CAAC,CAAC,KAAK,IAAI;EAGb,IAAM,IAAY,MAAM,EAAS,cAAc,EAAI,EAAQ,MAAM,CAAC;EAClE,OAAO,EAAM,QAAQ,OAAO,GAAW;GACrC,QAAQ;GACR,MAAM;GACN,SAAS,CAAC,CAAC,gBAAgB,aAAa,CAAC;EAC3C,CAAC;CACH;CAEA,eAAe,EAAkB,GAAgB,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"}
|
package/dist/util/utils.cjs.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
let e=require("rdflib");function t(t){return(0,e.sym)(t.uri+`#id`+(``+Date.now()))}function n(e,t){let n=t.getUTCFullYear(),r=(`0`+(t.getUTCMonth()+1)).slice(-2),i=(`0`+t.getUTCDate()).slice(-2),a=e.split(`/`),o=a[a.length-1];return new URL(`./archive/${n}/${r}/${i}/${o}`,e).toString()}function r(e){return
|
|
1
|
+
let e=require("rdflib");function t(t){return(0,e.sym)(t.uri+`#id`+(``+Date.now()))}function n(e,t){let n=t.getUTCFullYear(),r=(`0`+(t.getUTCMonth()+1)).slice(-2),i=(`0`+t.getUTCDate()).slice(-2),a=e.split(`/`),o=a[a.length-1];return new URL(`./archive/${n}/${r}/${i}/${o}`,e).toString()}function r(e){return!e||`${window.location.origin}/`!==new URL(e.value).origin}function i(t){let n=t.uri.replace(`/profile/`,`/`).replace(`/public/`,`/`).split(`/`).slice(0,-1).join(`/`)+`/settings/prefs.ttl`;return(0,e.sym)(n)}function a(t,n){let r=new URL(`IndividualChats/${new URL(t.value).host}/`,n.value).toString();return new e.NamedNode(r)}exports.determineChatContainer=a,exports.differentOrigin=r,exports.getArchiveUrl=n,exports.newThing=t,exports.suggestPreferencesFile=i;
|
|
2
2
|
//# sourceMappingURL=utils.cjs.js.map
|
|
@@ -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,
|
|
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"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { NamedNode } from 'rdflib';
|
|
2
|
+
export declare function newThing(doc: NamedNode): NamedNode;
|
|
3
|
+
export declare function uniqueNodes(arr: NamedNode[]): NamedNode[];
|
|
4
|
+
export declare function getArchiveUrl(baseUrl: string, date: Date): string;
|
|
5
|
+
export declare function differentOrigin(doc: any): boolean;
|
|
6
|
+
export declare function suggestPreferencesFile(me: NamedNode): NamedNode;
|
|
7
|
+
export declare function determineChatContainer(invitee: NamedNode, podRoot: NamedNode): NamedNode;
|
|
8
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/util/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAO,MAAM,QAAQ,CAAA;AAEvC,wBAAgB,QAAQ,CAAC,GAAG,EAAE,SAAS,GAAG,SAAS,CAElD;AAED,wBAAgB,WAAW,CAAE,GAAG,EAAE,SAAS,EAAE,GAAG,SAAS,EAAE,CAM1D;AAED,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,UAOxD;AAED,wBAAgB,eAAe,CAAC,GAAG,KAAA,GAAG,OAAO,CAO5C;AAED,wBAAgB,sBAAsB,CAAE,EAAE,EAAC,SAAS,aAMnD;AAED,wBAAgB,sBAAsB,CAClC,OAAO,EAAE,SAAS,EAClB,OAAO,EAAE,SAAS,GACnB,SAAS,CAQX"}
|
package/dist/util/utils.esm.js
CHANGED
|
@@ -8,13 +8,15 @@ function r(e, t) {
|
|
|
8
8
|
return new URL(`./archive/${n}/${r}/${i}/${o}`, e).toString();
|
|
9
9
|
}
|
|
10
10
|
function i(e) {
|
|
11
|
-
return e
|
|
11
|
+
return !e || `${window.location.origin}/` !== new URL(e.value).origin;
|
|
12
12
|
}
|
|
13
13
|
function a(e) {
|
|
14
|
-
|
|
14
|
+
let n = e.uri.replace("/profile/", "/").replace("/public/", "/").split("/").slice(0, -1).join("/") + "/settings/prefs.ttl";
|
|
15
|
+
return t(n);
|
|
15
16
|
}
|
|
16
17
|
function o(t, n) {
|
|
17
|
-
|
|
18
|
+
let r = new URL(`IndividualChats/${new URL(t.value).host}/`, n.value).toString();
|
|
19
|
+
return new e(r);
|
|
18
20
|
}
|
|
19
21
|
//#endregion
|
|
20
22
|
export { o as determineChatContainer, i as differentOrigin, r as getArchiveUrl, n as newThing, a as suggestPreferencesFile };
|
|
@@ -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,
|
|
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"}
|
package/package.json
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "solid-logic",
|
|
3
|
-
"version": "6.0.0
|
|
3
|
+
"version": "6.0.1-0",
|
|
4
4
|
"description": "Core business logic of SolidOS",
|
|
5
5
|
"main": "dist/index.cjs.js",
|
|
6
6
|
"module": "dist/index.esm.js",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
8
8
|
"exports": {
|
|
9
9
|
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
10
11
|
"import": "./dist/index.esm.js",
|
|
11
|
-
"require": "./dist/index.cjs.js"
|
|
12
|
-
"types": "./dist/index.d.ts"
|
|
12
|
+
"require": "./dist/index.cjs.js"
|
|
13
13
|
}
|
|
14
14
|
},
|
|
15
15
|
"sideEffects": false,
|
|
@@ -20,7 +20,8 @@
|
|
|
20
20
|
],
|
|
21
21
|
"scripts": {
|
|
22
22
|
"clean": "rm -rf dist src/versionInfo.ts",
|
|
23
|
-
"build": "npm run clean && npm run typecheck && vite build",
|
|
23
|
+
"build": "npm run clean && npm run typecheck && vite build && npm run build-types",
|
|
24
|
+
"build-types": "tsc --emitDeclarationOnly",
|
|
24
25
|
"watch": "vite build --watch",
|
|
25
26
|
"postbuild": "npm run postbuild-js",
|
|
26
27
|
"postbuild-js": "rm -f dist/versionInfo.d.ts dist/versionInfo.d.ts.map dist/index.js dist/index.js.map",
|
|
@@ -63,6 +64,7 @@
|
|
|
63
64
|
"solidos-toolkit": "dev"
|
|
64
65
|
},
|
|
65
66
|
"dependencies": {
|
|
67
|
+
"@dokieli/web-access-control": "^1.0.0",
|
|
66
68
|
"@uvdsl/solid-oidc-client-browser": "^0.2.3",
|
|
67
69
|
"solid-namespace": "^0.5.4",
|
|
68
70
|
"vite": "^8.0.16",
|