solid-logic 3.0.9-f51524a8 → 3.0.9-ff53d0a

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 (127) hide show
  1. package/README.md +103 -2
  2. package/dist/acl/aclLogic.js +118 -0
  3. package/dist/acl/aclLogic.js.map +1 -0
  4. package/{lib → dist}/authSession/authSession.d.ts.map +1 -1
  5. package/dist/authSession/authSession.js +3 -0
  6. package/dist/authSession/authSession.js.map +1 -0
  7. package/{lib → dist}/authn/SolidAuthnLogic.d.ts.map +1 -1
  8. package/dist/authn/SolidAuthnLogic.js +110 -0
  9. package/dist/authn/SolidAuthnLogic.js.map +1 -0
  10. package/dist/authn/authUtil.js +67 -0
  11. package/dist/authn/authUtil.js.map +1 -0
  12. package/dist/chat/chatLogic.js +157 -0
  13. package/dist/chat/chatLogic.js.map +1 -0
  14. package/dist/inbox/inboxLogic.js +52 -0
  15. package/dist/inbox/inboxLogic.js.map +1 -0
  16. package/dist/index.js +13 -0
  17. package/dist/index.js.map +1 -0
  18. package/dist/issuer/issuerLogic.js +37 -0
  19. package/dist/issuer/issuerLogic.js.map +1 -0
  20. package/dist/logic/CustomError.js +28 -0
  21. package/dist/logic/CustomError.js.map +1 -0
  22. package/dist/logic/solidLogic.js +65 -0
  23. package/dist/logic/solidLogic.js.map +1 -0
  24. package/dist/logic/solidLogicSingleton.js +18 -0
  25. package/dist/logic/solidLogicSingleton.js.map +1 -0
  26. package/dist/profile/profileLogic.js +129 -0
  27. package/dist/profile/profileLogic.js.map +1 -0
  28. package/dist/solid-logic.esm.js +8560 -0
  29. package/dist/solid-logic.esm.js.map +1 -0
  30. package/dist/solid-logic.esm.min.js +32 -0
  31. package/dist/solid-logic.esm.min.js.map +1 -0
  32. package/dist/solid-logic.umd.js +8597 -0
  33. package/dist/solid-logic.umd.js.map +1 -0
  34. package/dist/solid-logic.umd.min.js +32 -0
  35. package/dist/solid-logic.umd.min.js.map +1 -0
  36. package/dist/typeIndex/typeIndexLogic.js +186 -0
  37. package/dist/typeIndex/typeIndexLogic.js.map +1 -0
  38. package/dist/types.js +2 -0
  39. package/dist/types.js.map +1 -0
  40. package/{src/util/containerLogic.ts → dist/util/containerLogic.js} +18 -26
  41. package/dist/util/containerLogic.js.map +1 -0
  42. package/dist/util/debug.js +14 -0
  43. package/dist/util/debug.js.map +1 -0
  44. package/dist/util/ns.js +5 -0
  45. package/dist/util/ns.js.map +1 -0
  46. package/dist/util/utilityLogic.js +144 -0
  47. package/dist/util/utilityLogic.js.map +1 -0
  48. package/dist/util/utils.js +39 -0
  49. package/dist/util/utils.js.map +1 -0
  50. package/package.json +28 -9
  51. package/babel.config.js +0 -6
  52. package/eslint.config.js +0 -28
  53. package/jest.config.js +0 -17
  54. package/lib/solid-logic.js +0 -107
  55. package/lib/solid-logic.js.map +0 -1
  56. package/rollup.config.js +0 -29
  57. package/src/acl/aclLogic.ts +0 -156
  58. package/src/authSession/authSession.ts +0 -13
  59. package/src/authn/SolidAuthnLogic.ts +0 -126
  60. package/src/authn/authUtil.ts +0 -70
  61. package/src/chat/chatLogic.ts +0 -226
  62. package/src/inbox/inboxLogic.ts +0 -59
  63. package/src/index.ts +0 -21
  64. package/src/issuer/issuerLogic.ts +0 -40
  65. package/src/logic/CustomError.ts +0 -29
  66. package/src/logic/solidLogic.ts +0 -76
  67. package/src/logic/solidLogicSingleton.ts +0 -20
  68. package/src/profile/profileLogic.ts +0 -125
  69. package/src/typeIndex/typeIndexLogic.ts +0 -198
  70. package/src/types.ts +0 -122
  71. package/src/util/debug.ts +0 -16
  72. package/src/util/ns.ts +0 -5
  73. package/src/util/utilityLogic.ts +0 -156
  74. package/src/util/utils.ts +0 -52
  75. package/src/versionInfo.ts +0 -32
  76. package/test/aclLogic.test.ts +0 -24
  77. package/test/authUtil.test.ts +0 -23
  78. package/test/chatLogic.test.ts +0 -322
  79. package/test/container.test.ts +0 -58
  80. package/test/helpers/dataSetup.ts +0 -135
  81. package/test/helpers/setup.ts +0 -22
  82. package/test/inboxLogic.test.ts +0 -209
  83. package/test/logic.test.ts +0 -29
  84. package/test/profileLogic.test.ts +0 -248
  85. package/test/solidAuthLogic.test.ts +0 -49
  86. package/test/typeIndexLogic.test.ts +0 -255
  87. package/test/utilityLogic.test.ts +0 -180
  88. package/test/utils.test.ts +0 -32
  89. package/timestamp.sh +0 -13
  90. package/tsconfig.json +0 -77
  91. package/tsconfig.test.json +0 -8
  92. /package/{lib → dist}/acl/aclLogic.d.ts +0 -0
  93. /package/{lib → dist}/acl/aclLogic.d.ts.map +0 -0
  94. /package/{lib → dist}/authSession/authSession.d.ts +0 -0
  95. /package/{lib → dist}/authn/SolidAuthnLogic.d.ts +0 -0
  96. /package/{lib → dist}/authn/authUtil.d.ts +0 -0
  97. /package/{lib → dist}/authn/authUtil.d.ts.map +0 -0
  98. /package/{lib → dist}/chat/chatLogic.d.ts +0 -0
  99. /package/{lib → dist}/chat/chatLogic.d.ts.map +0 -0
  100. /package/{lib → dist}/inbox/inboxLogic.d.ts +0 -0
  101. /package/{lib → dist}/inbox/inboxLogic.d.ts.map +0 -0
  102. /package/{lib → dist}/index.d.ts +0 -0
  103. /package/{lib → dist}/index.d.ts.map +0 -0
  104. /package/{lib → dist}/issuer/issuerLogic.d.ts +0 -0
  105. /package/{lib → dist}/issuer/issuerLogic.d.ts.map +0 -0
  106. /package/{lib → dist}/logic/CustomError.d.ts +0 -0
  107. /package/{lib → dist}/logic/CustomError.d.ts.map +0 -0
  108. /package/{lib → dist}/logic/solidLogic.d.ts +0 -0
  109. /package/{lib → dist}/logic/solidLogic.d.ts.map +0 -0
  110. /package/{lib → dist}/logic/solidLogicSingleton.d.ts +0 -0
  111. /package/{lib → dist}/logic/solidLogicSingleton.d.ts.map +0 -0
  112. /package/{lib → dist}/profile/profileLogic.d.ts +0 -0
  113. /package/{lib → dist}/profile/profileLogic.d.ts.map +0 -0
  114. /package/{lib → dist}/typeIndex/typeIndexLogic.d.ts +0 -0
  115. /package/{lib → dist}/typeIndex/typeIndexLogic.d.ts.map +0 -0
  116. /package/{lib → dist}/types.d.ts +0 -0
  117. /package/{lib → dist}/types.d.ts.map +0 -0
  118. /package/{lib → dist}/util/containerLogic.d.ts +0 -0
  119. /package/{lib → dist}/util/containerLogic.d.ts.map +0 -0
  120. /package/{lib → dist}/util/debug.d.ts +0 -0
  121. /package/{lib → dist}/util/debug.d.ts.map +0 -0
  122. /package/{lib → dist}/util/ns.d.ts +0 -0
  123. /package/{lib → dist}/util/ns.d.ts.map +0 -0
  124. /package/{lib → dist}/util/utilityLogic.d.ts +0 -0
  125. /package/{lib → dist}/util/utilityLogic.d.ts.map +0 -0
  126. /package/{lib → dist}/util/utils.d.ts +0 -0
  127. /package/{lib → dist}/util/utils.d.ts.map +0 -0
@@ -0,0 +1,52 @@
1
+ import { getArchiveUrl } from '../util/utils';
2
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
3
+ export function createInboxLogic(store, profileLogic, utilityLogic, containerLogic, aclLogic) {
4
+ async function createInboxFor(peerWebId, nick) {
5
+ const myWebId = await profileLogic.loadMe();
6
+ const podRoot = await profileLogic.getPodRoot(myWebId);
7
+ const ourInbox = `${podRoot.value}p2p-inboxes/${encodeURIComponent(nick)}/`;
8
+ await containerLogic.createContainer(ourInbox);
9
+ // const aclDocUrl = await aclLogic.findAclDocUrl(ourInbox);
10
+ await utilityLogic.setSinglePeerAccess({
11
+ ownerWebId: myWebId.value,
12
+ peerWebId,
13
+ accessToModes: 'acl:Append',
14
+ target: ourInbox
15
+ });
16
+ return ourInbox;
17
+ }
18
+ async function getNewMessages(user) {
19
+ if (!user) {
20
+ user = await profileLogic.loadMe();
21
+ }
22
+ const inbox = await profileLogic.getMainInbox(user);
23
+ const urls = await containerLogic.getContainerMembers(inbox);
24
+ return urls.filter(url => !containerLogic.isContainer(url));
25
+ }
26
+ async function markAsRead(url, date) {
27
+ const downloaded = await store.fetcher._fetch(url);
28
+ if (downloaded.status !== 200) {
29
+ throw new Error(`Not OK! ${url}`);
30
+ }
31
+ const archiveUrl = getArchiveUrl(url, date);
32
+ const options = {
33
+ method: 'PUT',
34
+ body: await downloaded.text(),
35
+ headers: [
36
+ ['Content-Type', downloaded.headers.get('Content-Type') || 'application/octet-stream']
37
+ ]
38
+ };
39
+ const uploaded = await store.fetcher._fetch(archiveUrl, options);
40
+ if (uploaded.status.toString()[0] === '2') {
41
+ await store.fetcher._fetch(url, {
42
+ method: 'DELETE'
43
+ });
44
+ }
45
+ }
46
+ return {
47
+ createInboxFor,
48
+ getNewMessages,
49
+ markAsRead
50
+ };
51
+ }
52
+ //# sourceMappingURL=inboxLogic.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"inboxLogic.js","sourceRoot":"","sources":["../../src/inbox/inboxLogic.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA;AAE7C,6DAA6D;AAC7D,MAAM,UAAU,gBAAgB,CAAC,KAAK,EAAE,YAAY,EAAE,YAAY,EAAE,cAAc,EAAE,QAAQ;IAExF,KAAK,UAAU,cAAc,CAAC,SAAiB,EAAE,IAAY;QAC3D,MAAM,OAAO,GAAc,MAAM,YAAY,CAAC,MAAM,EAAE,CAAA;QACtD,MAAM,OAAO,GAAc,MAAM,YAAY,CAAC,UAAU,CAAC,OAAO,CAAC,CAAA;QACjE,MAAM,QAAQ,GAAG,GAAG,OAAO,CAAC,KAAK,eAAe,kBAAkB,CAAC,IAAI,CAAC,GAAG,CAAA;QAC3E,MAAM,cAAc,CAAC,eAAe,CAAC,QAAQ,CAAC,CAAA;QAC9C,4DAA4D;QAC5D,MAAM,YAAY,CAAC,mBAAmB,CAAC;YACrC,UAAU,EAAE,OAAO,CAAC,KAAK;YACzB,SAAS;YACT,aAAa,EAAE,YAAY;YAC3B,MAAM,EAAE,QAAQ;SACjB,CAAC,CAAA;QACF,OAAO,QAAQ,CAAA;IACnB,CAAC;IAED,KAAK,UAAU,cAAc,CACzB,IAAgB;QAEhB,IA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C;IACD,OAAO;QACL,cAAc;QACd,cAAc;QACd,UAAU;KACX,CAAA;AACH,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,13 @@
1
+ // Make these variables directly accessible as it is what you need most of the time
2
+ // This also makes these variable globaly accesible in mashlib
3
+ import { solidLogicSingleton } from './logic/solidLogicSingleton';
4
+ const authn = solidLogicSingleton.authn;
5
+ const authSession = solidLogicSingleton.authn.authSession;
6
+ const store = solidLogicSingleton.store;
7
+ export { ACL_LINK } from './acl/aclLogic';
8
+ export { offlineTestID, appContext } from './authn/authUtil';
9
+ export { getSuggestedIssuers } from './issuer/issuerLogic';
10
+ export { UnauthorizedError, CrossOriginForbiddenError, SameOriginForbiddenError, NotFoundError, FetchError, NotEditableError, WebOperationError } from './logic/CustomError';
11
+ export { solidLogicSingleton, // solidLogicSingleton is exported entirely because it is used in solid-panes
12
+ store, authn, authSession };
13
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,mFAAmF;AACnF,8DAA8D;AAC9D,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAA;AAEjE,MAAM,KAAK,GAAG,mBAAmB,CAAC,KAAK,CAAA;AACvC,MAAM,WAAW,GAAG,mBAAmB,CAAC,KAAK,CAAC,WAAW,CAAA;AACzD,MAAM,KAAK,GAAG,mBAAmB,CAAC,KAAK,CAAA;AAEvC,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AACzC,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAC5D,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAA;AAE1D,OAAO,EAAE,iBAAiB,EAAE,yBAAyB,EAAE,wBAAwB,EAAE,aAAa,EAAE,UAAU,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AAE5K,OAAO,EACL,mBAAmB,EAAE,6EAA6E;AAClG,KAAK,EACL,KAAK,EACL,WAAW,EACZ,CAAA"}
@@ -0,0 +1,37 @@
1
+ const DEFAULT_ISSUERS = [
2
+ {
3
+ name: 'Solid Community',
4
+ uri: 'https://solidcommunity.net'
5
+ },
6
+ {
7
+ name: 'Solid Web',
8
+ uri: 'https://solidweb.org'
9
+ },
10
+ {
11
+ name: 'Inrupt.net',
12
+ uri: 'https://inrupt.net'
13
+ },
14
+ {
15
+ name: 'pod.Inrupt.com',
16
+ uri: 'https://login.inrupt.com'
17
+ }
18
+ ];
19
+ /**
20
+ * @returns - A list of suggested OIDC issuers
21
+ */
22
+ export function getSuggestedIssuers() {
23
+ // Suggest a default list of OIDC issuers
24
+ const issuers = [...DEFAULT_ISSUERS];
25
+ // Suggest the current host if not already included
26
+ const { host, origin } = new URL(location.href);
27
+ const hosts = issuers.map(({ uri }) => new URL(uri).host);
28
+ if (!hosts.includes(host) && !hosts.some(existing => isSubdomainOf(host, existing))) {
29
+ issuers.unshift({ name: host, uri: origin });
30
+ }
31
+ return issuers;
32
+ }
33
+ function isSubdomainOf(subdomain, domain) {
34
+ const dot = subdomain.length - domain.length - 1;
35
+ return dot > 0 && subdomain[dot] === '.' && subdomain.endsWith(domain);
36
+ }
37
+ //# sourceMappingURL=issuerLogic.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"issuerLogic.js","sourceRoot":"","sources":["../../src/issuer/issuerLogic.ts"],"names":[],"mappings":"AAAA,MAAM,eAAe,GAAG;IACtB;QACE,IAAI,EAAE,iBAAiB;QACvB,GAAG,EAAE,4BAA4B;KAClC;IACD;QACE,IAAI,EAAE,WAAW;QACjB,GAAG,EAAE,sBAAsB;KAC5B;IACD;QACE,IAAI,EAAE,YAAY;QAClB,GAAG,EAAE,oBAAoB;KAC1B;IACD;QACE,IAAI,EAAE,gBAAgB;QACtB,GAAG,EAAE,0BAA0B;KAChC;CACF,CAAA;AAED;;GAEG;AACH,MAAM,UAAU,mBAAmB;IAC/B,yCAAyC;IACzC,MAAM,OAAO,GAAG,CAAC,GAAG,eAAe,CAAC,CAAA;IAEpC,mDAAmD;IACnD,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,IAAI,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAA;IAC/C,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE,CAAC,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,CAAA;IACzD,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,aAAa,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC,EAAE,CAAC;QACpF,OAAO,CAAC,OAAO,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,EAAE,CAAC,CAAA;IAC9C,CAAC;IAED,OAAO,OAAO,CAAA;AAChB,CAAC;AAEH,SAAS,aAAa,CAAE,SAAiB,EAAE,MAAc;IACrD,MAAM,GAAG,GAAG,SAAS,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,GAAG,CAAC,CAAA;IAChD,OAAO,GAAG,GAAG,CAAC,IAAI,SAAS,CAAC,GAAG,CAAC,KAAK,GAAG,IAAI,SAAS,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAA;AAC1E,CAAC"}
@@ -0,0 +1,28 @@
1
+ class CustomError extends Error {
2
+ constructor(message) {
3
+ super(message);
4
+ // see: typescriptlang.org/docs/handbook/release-notes/typescript-2-2.html
5
+ Object.setPrototypeOf(this, new.target.prototype); // restore prototype chain
6
+ this.name = new.target.name; // stack traces display correctly now
7
+ }
8
+ }
9
+ export class UnauthorizedError extends CustomError {
10
+ }
11
+ export class CrossOriginForbiddenError extends CustomError {
12
+ }
13
+ export class SameOriginForbiddenError extends CustomError {
14
+ }
15
+ export class NotFoundError extends CustomError {
16
+ }
17
+ export class NotEditableError extends CustomError {
18
+ }
19
+ export class WebOperationError extends CustomError {
20
+ }
21
+ export class FetchError extends CustomError {
22
+ status;
23
+ constructor(status, message) {
24
+ super(message);
25
+ this.status = status;
26
+ }
27
+ }
28
+ //# sourceMappingURL=CustomError.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CustomError.js","sourceRoot":"","sources":["../../src/logic/CustomError.ts"],"names":[],"mappings":"AAAA,MAAM,WAAY,SAAQ,KAAK;IAC3B,YAAY,OAAgB;QACxB,KAAK,CAAC,OAAO,CAAC,CAAA;QACd,0EAA0E;QAC1E,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC,CAAA,CAAC,0BAA0B;QAC5E,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC,MAAM,CAAC,IAAI,CAAA,CAAC,qCAAqC;IACrE,CAAC;CACJ;AAED,MAAM,OAAO,iBAAkB,SAAQ,WAAW;CAAG;AAErD,MAAM,OAAO,yBAA0B,SAAQ,WAAW;CAAG;AAE7D,MAAM,OAAO,wBAAyB,SAAQ,WAAW;CAAG;AAE5D,MAAM,OAAO,aAAc,SAAQ,WAAW;CAAG;AAEjD,MAAM,OAAO,gBAAiB,SAAQ,WAAW;CAAI;AAErD,MAAM,OAAO,iBAAkB,SAAQ,WAAW;CAAG;AAErD,MAAM,OAAO,UAAW,SAAQ,WAAW;IACvC,MAAM,CAAQ;IAEd,YAAY,MAAc,EAAE,OAAgB;QACxC,KAAK,CAAC,OAAO,CAAC,CAAA;QACd,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;IACxB,CAAC;CACJ"}
@@ -0,0 +1,65 @@
1
+ import * as rdf from 'rdflib';
2
+ import { createAclLogic } from '../acl/aclLogic';
3
+ import { SolidAuthnLogic } from '../authn/SolidAuthnLogic';
4
+ import { createChatLogic } from '../chat/chatLogic';
5
+ import { createInboxLogic } from '../inbox/inboxLogic';
6
+ import { createProfileLogic } from '../profile/profileLogic';
7
+ import { createTypeIndexLogic } from '../typeIndex/typeIndexLogic';
8
+ import { createContainerLogic } from '../util/containerLogic';
9
+ import { createUtilityLogic } from '../util/utilityLogic';
10
+ import * as debug from '../util/debug';
11
+ /*
12
+ ** It is important to distinquish `fetch`, a function provided by the browser
13
+ ** and `Fetcher`, a helper object for the rdflib Store which turns it
14
+ ** into a `ConnectedStore` or a `LiveStore`. A Fetcher object is
15
+ ** available at store.fetcher, and `fetch` function at `store.fetcher._fetch`,
16
+ */
17
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
18
+ export function createSolidLogic(specialFetch, session) {
19
+ debug.log('SolidLogic: Unique instance created. There should only be one of these.');
20
+ const store = rdf.graph();
21
+ rdf.fetcher(store, { fetch: specialFetch.fetch }); // Attach a web I/O module, store.fetcher
22
+ store.updater = new rdf.UpdateManager(store); // Add real-time live updates store.updater
23
+ store.features = []; // disable automatic node merging on store load
24
+ const authn = new SolidAuthnLogic(session);
25
+ const acl = createAclLogic(store);
26
+ const containerLogic = createContainerLogic(store);
27
+ const utilityLogic = createUtilityLogic(store, acl, containerLogic);
28
+ const profile = createProfileLogic(store, authn, utilityLogic);
29
+ const chat = createChatLogic(store, profile);
30
+ const inbox = createInboxLogic(store, profile, utilityLogic, containerLogic, acl);
31
+ const typeIndex = createTypeIndexLogic(store, authn, profile, utilityLogic);
32
+ debug.log('SolidAuthnLogic initialized');
33
+ function load(doc) {
34
+ return store.fetcher.load(doc);
35
+ }
36
+ // @@@@ use the one in rdflib.js when it is available and delete this
37
+ function updatePromise(del, ins = []) {
38
+ return new Promise((resolve, reject) => {
39
+ store.updater.update(del, ins, function (_uri, ok, errorBody) {
40
+ if (!ok) {
41
+ reject(new Error(errorBody));
42
+ }
43
+ else {
44
+ resolve();
45
+ }
46
+ }); // callback
47
+ }); // promise
48
+ }
49
+ function clearStore() {
50
+ store.statements.slice().forEach(store.remove.bind(store));
51
+ }
52
+ return {
53
+ store,
54
+ authn,
55
+ acl,
56
+ inbox,
57
+ chat,
58
+ profile,
59
+ typeIndex,
60
+ load,
61
+ updatePromise,
62
+ clearStore
63
+ };
64
+ }
65
+ //# sourceMappingURL=solidLogic.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"solidLogic.js","sourceRoot":"","sources":["../../src/logic/solidLogic.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,GAAG,MAAM,QAAQ,CAAA;AAE7B,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAA;AAChD,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAA;AAC1D,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AACnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAA;AACtD,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AAC5D,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAA;AAClE,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAA;AAC7D,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAA;AAEzD,OAAO,KAAK,KAAK,MAAM,eAAe,CAAA;AACtC;;;;;EAKE;AACF,8DAA8D;AAC9D,MAAM,UAAU,gBAAgB,CAAC,YAA4D,EAAE,OAAgB;IAE3G,KAAK,CAAC,GAAG,CAAC,0EAA0E,CAAC,CAAA;IACrF,MAAM,KAAK,GAAc,GAAG,CAAC,KAAK,EAAe,CAAA;IACjD,GAAG,CAAC,OAAO,CAAC,KAAK,EAAE,EAAC,KAAK,EAAE,YAAY,CAAC,KAAK,EAAC,CAAC,CAAA,CAAC,yCAAyC;IACzF,KAAK,CAAC,OAAO,GAAG,IAAI,GAAG,CAAC,aAAa,CAAC,KAAK,CAAC,CAAA,CAAC,2CAA2C;IACxF,KAAK,CAAC,QAAQ,GAAG,EAAE,CAAA,CAAC,+CAA+C;IAEnE,MAAM,KAAK,GAAe,IAAI,eAAe,CAAC,OAAO,CAAC,CAAA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AAE,CAAC,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAA;IAC9D,CAAC;IAED,OAAO;QACH,KAAK;QACL,KAAK;QACL,GAAG;QACH,KAAK;QACL,IAAI;QACJ,OAAO;QACP,SAAS;QACT,IAAI;QACJ,aAAa;QACb,UAAU;KACb,CAAA;AACL,CAAC"}
@@ -0,0 +1,18 @@
1
+ import * as debug from '../util/debug';
2
+ import { authSession } from '../authSession/authSession';
3
+ import { createSolidLogic } from './solidLogic';
4
+ const _fetch = async (url, requestInit) => {
5
+ const omitCreds = requestInit && requestInit.credentials && requestInit.credentials == 'omit';
6
+ if (authSession.info.webId && !omitCreds) { // see https://github.com/solidos/solidos/issues/114
7
+ // In fact fetch should respect credentials omit itself
8
+ return authSession.fetch(url, requestInit);
9
+ }
10
+ else {
11
+ return window.fetch(url, requestInit);
12
+ }
13
+ };
14
+ //this const makes solidLogicSingleton global accessible in mashlib
15
+ const solidLogicSingleton = createSolidLogic({ fetch: _fetch }, authSession);
16
+ debug.log('Unique quadstore initialized.');
17
+ export { solidLogicSingleton };
18
+ //# sourceMappingURL=solidLogicSingleton.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"solidLogicSingleton.js","sourceRoot":"","sources":["../../src/logic/solidLogicSingleton.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,eAAe,CAAA;AACtC,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAA;AACxD,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAA;AAE/C,MAAM,MAAM,GAAG,KAAK,EAAE,GAAG,EAAE,WAAW,EAAE,EAAE;IACtC,MAAM,SAAS,GAAG,WAAW,IAAI,WAAW,CAAC,WAAW,IAAI,WAAW,CAAC,WAAW,IAAI,MAAM,CAAA;IAC7F,IAAI,WAAW,CAAC,IAAI,CAAC,KAAK,IAAI,CAAC,SAAS,EAAE,CAAC,CAAC,oDAAoD;QAC5F,uDAAuD;QACvD,OAAO,WAAW,CAAC,KAAK,CAAC,GAAG,EAAE,WAAW,CAAC,CAAA;IAC9C,CAAC;SAAM,CAAC;QACJ,OAAO,MAAM,CAAC,KAAK,CAAC,GAAG,EAAE,WAAW,CAAC,CAAA;IACzC,CAAC;AACL,CAAC,CAAA;AAED,mEAAmE;AACnE,MAAM,mBAAmB,GAAG,gBAAgB,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,WAAW,CAAC,CAAA;AAE5E,KAAK,CAAC,GAAG,CAAC,+BAA+B,CAAC,CAAA;AAE1C,OAAO,EAAE,mBAAmB,EAAE,CAAA"}
@@ -0,0 +1,129 @@
1
+ import { CrossOriginForbiddenError, FetchError, NotEditableError, SameOriginForbiddenError, UnauthorizedError, WebOperationError } from '../logic/CustomError';
2
+ import * as debug from '../util/debug';
3
+ import { ns as namespace } from '../util/ns';
4
+ import { differentOrigin, suggestPreferencesFile } from '../util/utils';
5
+ export function createProfileLogic(store, authn, utilityLogic) {
6
+ const ns = namespace;
7
+ /**
8
+ * loads the preference without throwing errors - if it can create it it does so.
9
+ * remark: it still throws error if it cannot load profile.
10
+ * @param user
11
+ * @returns undefined if preferenceFile cannot be returned or NamedNode if it can find it or create it
12
+ */
13
+ async function silencedLoadPreferences(user) {
14
+ try {
15
+ return await loadPreferences(user);
16
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
17
+ }
18
+ catch (err) {
19
+ return undefined;
20
+ }
21
+ }
22
+ /**
23
+ * loads the preference without returning different errors if it cannot create or load it.
24
+ * remark: it also throws error if it cannot load profile.
25
+ * @param user
26
+ * @returns undefined if preferenceFile cannot be an Error or NamedNode if it can find it or create it
27
+ */
28
+ async function loadPreferences(user) {
29
+ await loadProfile(user);
30
+ const possiblePreferencesFile = suggestPreferencesFile(user);
31
+ let preferencesFile;
32
+ try {
33
+ preferencesFile = await utilityLogic.followOrCreateLink(user, ns.space('preferencesFile'), possiblePreferencesFile, user.doc());
34
+ }
35
+ catch (err) {
36
+ const message = `User ${user} has no pointer in profile to preferences file.`;
37
+ debug.warn(message);
38
+ // we are listing the possible errors
39
+ if (err instanceof NotEditableError) {
40
+ throw err;
41
+ }
42
+ if (err instanceof WebOperationError) {
43
+ throw err;
44
+ }
45
+ if (err instanceof UnauthorizedError) {
46
+ throw err;
47
+ }
48
+ if (err instanceof CrossOriginForbiddenError) {
49
+ throw err;
50
+ }
51
+ if (err instanceof SameOriginForbiddenError) {
52
+ throw err;
53
+ }
54
+ if (err instanceof FetchError) {
55
+ throw err;
56
+ }
57
+ throw err;
58
+ }
59
+ try {
60
+ await store.fetcher.load(preferencesFile);
61
+ }
62
+ catch (err) { // Maybe a permission problem or origin problem
63
+ const msg = `Unable to load preference of user ${user}: ${err}`;
64
+ debug.warn(msg);
65
+ if (err.response.status === 401) {
66
+ throw new UnauthorizedError();
67
+ }
68
+ if (err.response.status === 403) {
69
+ if (differentOrigin(preferencesFile)) {
70
+ throw new CrossOriginForbiddenError();
71
+ }
72
+ throw new SameOriginForbiddenError();
73
+ }
74
+ /*if (err.response.status === 404) {
75
+ throw new NotFoundError();
76
+ }*/
77
+ throw new Error(msg);
78
+ }
79
+ return preferencesFile;
80
+ }
81
+ async function loadProfile(user) {
82
+ if (!user) {
83
+ throw new Error('loadProfile: no user given.');
84
+ }
85
+ try {
86
+ await store.fetcher.load(user.doc());
87
+ }
88
+ catch (err) {
89
+ throw new Error(`Unable to load profile of user ${user}: ${err}`);
90
+ }
91
+ return user.doc();
92
+ }
93
+ async function loadMe() {
94
+ const me = authn.currentUser();
95
+ if (me === null) {
96
+ throw new Error('Current user not found! Not logged in?');
97
+ }
98
+ await store.fetcher.load(me.doc());
99
+ return me;
100
+ }
101
+ function getPodRoot(user) {
102
+ const podRoot = findStorage(user);
103
+ if (!podRoot) {
104
+ throw new Error('User pod root not found!');
105
+ }
106
+ return podRoot;
107
+ }
108
+ async function getMainInbox(user) {
109
+ await store.fetcher.load(user);
110
+ const mainInbox = store.any(user, ns.ldp('inbox'), undefined, user.doc());
111
+ if (!mainInbox) {
112
+ throw new Error('User main inbox not found!');
113
+ }
114
+ return mainInbox;
115
+ }
116
+ function findStorage(me) {
117
+ return store.any(me, ns.space('storage'), undefined, me.doc());
118
+ }
119
+ return {
120
+ loadMe,
121
+ getPodRoot,
122
+ getMainInbox,
123
+ findStorage,
124
+ loadPreferences,
125
+ loadProfile,
126
+ silencedLoadPreferences
127
+ };
128
+ }
129
+ //# sourceMappingURL=profileLogic.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"profileLogic.js","sourceRoot":"","sources":["../../src/profile/profileLogic.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,yBAAyB,EAAE,UAAU,EAAE,gBAAgB,EAAE,wBAAwB,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAA;AAC9J,OAAO,KAAK,KAAK,MAAM,eAAe,CAAA;AACtC,OAAO,EAAE,EAAE,IAAI,SAAS,EAAE,MAAM,YAAY,CAAA;AAC5C,OAAO,EAAE,eAAe,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAA;AAGvE,MAAM,UAAU,kBAAkB,CAAC,KAAK,EAAE,KAAK,EAAE,YAAY;IACzD,MAAM,EAAE,GAAG,SAAS,CAAA;IAEpB;;;;;OAKG;IACH,KAAK,UAAU,uBAAuB,CAAC,IAAe;QAClD,IAAI,CAAC;YACD,OAAO,MAAM,eAAe,CAAC,IAAI,CAAC,CAAA;YACtC,6DAA6D;QAC7D,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACX,OAAO,SAAS,CAAA;QACpB,CAAC;IACL,CAAC;IAED;;;;;OAKG;IACH,KAAK,UAAU,eAAe,CAAE,IAAe;QAC3C,MAAM,WAAW,CAAC,IAAI,CAAC,CAAA;QAEvB,MAAM,uBAAuB,GAAG,sBAAsB,CAAC,IAAI,CAAC,CAAA;QAC5D,IAAI,eAAe,CAAA;QACnB,IAAI,CAAC;YACD,eAAe,GAAG,MAAM,YAA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