solid-logic 3.1.1-f0ed025 → 3.1.1-f480b7d

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 (153) hide show
  1. package/README.md +105 -2
  2. package/dist/acl/aclLogic.d.ts +5 -0
  3. package/{lib → dist}/acl/aclLogic.d.ts.map +1 -1
  4. package/dist/acl/aclLogic.js +122 -0
  5. package/dist/acl/aclLogic.js.map +1 -0
  6. package/{lib → dist}/authSession/authSession.js +1 -1
  7. package/{lib → dist}/authSession/authSession.js.map +1 -1
  8. package/{lib → dist}/authn/SolidAuthnLogic.d.ts +3 -3
  9. package/{lib → dist}/authn/SolidAuthnLogic.d.ts.map +1 -1
  10. package/dist/authn/SolidAuthnLogic.js +147 -0
  11. package/dist/authn/SolidAuthnLogic.js.map +1 -0
  12. package/{lib → dist}/authn/authUtil.d.ts +1 -1
  13. package/{lib → dist}/authn/authUtil.js +12 -12
  14. package/dist/authn/authUtil.js.map +1 -0
  15. package/{lib → dist}/chat/chatLogic.d.ts +1 -1
  16. package/dist/chat/chatLogic.js +160 -0
  17. package/dist/chat/chatLogic.js.map +1 -0
  18. package/{lib → dist}/inbox/inboxLogic.d.ts +1 -1
  19. package/{lib → dist}/inbox/inboxLogic.d.ts.map +1 -1
  20. package/dist/inbox/inboxLogic.js +55 -0
  21. package/dist/inbox/inboxLogic.js.map +1 -0
  22. package/{lib → dist}/index.d.ts +1 -1
  23. package/{lib → dist}/index.d.ts.map +1 -1
  24. package/{lib → dist}/index.js +4 -4
  25. package/{lib → dist}/index.js.map +1 -1
  26. package/dist/issuer/issuerLogic.js +40 -0
  27. package/dist/issuer/issuerLogic.js.map +1 -0
  28. package/{lib → dist}/logic/CustomError.d.ts.map +1 -1
  29. package/dist/logic/CustomError.js +38 -0
  30. package/dist/logic/CustomError.js.map +1 -0
  31. package/dist/logic/solidLogic.d.ts +6 -0
  32. package/{lib → dist}/logic/solidLogic.d.ts.map +1 -1
  33. package/{lib → dist}/logic/solidLogic.js +32 -33
  34. package/dist/logic/solidLogic.js.map +1 -0
  35. package/dist/logic/solidLogicSingleton.js +54 -0
  36. package/dist/logic/solidLogicSingleton.js.map +1 -0
  37. package/{lib → dist}/profile/profileLogic.d.ts +1 -1
  38. package/dist/profile/profileLogic.js +165 -0
  39. package/dist/profile/profileLogic.js.map +1 -0
  40. package/dist/solid-logic.esm.external.js +12725 -0
  41. package/dist/solid-logic.esm.external.js.map +1 -0
  42. package/dist/solid-logic.esm.external.min.js +32 -0
  43. package/dist/solid-logic.esm.external.min.js.map +1 -0
  44. package/dist/solid-logic.js +12802 -0
  45. package/dist/solid-logic.js.map +1 -0
  46. package/dist/solid-logic.min.js +32 -0
  47. package/dist/solid-logic.min.js.map +1 -0
  48. package/dist/typeIndex/typeIndexLogic.js +222 -0
  49. package/dist/typeIndex/typeIndexLogic.js.map +1 -0
  50. package/{lib → dist}/types.d.ts +2 -2
  51. package/{lib → dist}/util/containerLogic.d.ts +1 -1
  52. package/{lib → dist}/util/containerLogic.d.ts.map +1 -1
  53. package/{src/util/containerLogic.ts → dist/util/containerLogic.js} +20 -25
  54. package/dist/util/containerLogic.js.map +1 -0
  55. package/dist/util/debug.d.ts.map +1 -0
  56. package/dist/util/debug.js +20 -0
  57. package/dist/util/debug.js.map +1 -0
  58. package/{lib → dist}/util/ns.js +2 -2
  59. package/{lib → dist}/util/ns.js.map +1 -1
  60. package/{lib → dist}/util/utilityLogic.d.ts +1 -1
  61. package/{lib → dist}/util/utilityLogic.d.ts.map +1 -1
  62. package/dist/util/utilityLogic.js +180 -0
  63. package/dist/util/utilityLogic.js.map +1 -0
  64. package/{lib → dist}/util/utils.d.ts +1 -1
  65. package/{lib → dist}/util/utils.d.ts.map +1 -1
  66. package/dist/util/utils.js +47 -0
  67. package/dist/util/utils.js.map +1 -0
  68. package/dist/versionInfo.js +33 -0
  69. package/dist/versionInfo.js.map +1 -0
  70. package/package.json +50 -22
  71. package/eslint.config.js +0 -29
  72. package/jest.config.js +0 -10
  73. package/lib/acl/aclLogic.d.ts +0 -5
  74. package/lib/acl/aclLogic.js +0 -168
  75. package/lib/acl/aclLogic.js.map +0 -1
  76. package/lib/authn/SolidAuthnLogic.js +0 -193
  77. package/lib/authn/SolidAuthnLogic.js.map +0 -1
  78. package/lib/authn/authUtil.js.map +0 -1
  79. package/lib/chat/chatLogic.js +0 -272
  80. package/lib/chat/chatLogic.js.map +0 -1
  81. package/lib/inbox/inboxLogic.js +0 -139
  82. package/lib/inbox/inboxLogic.js.map +0 -1
  83. package/lib/issuer/issuerLogic.js +0 -52
  84. package/lib/issuer/issuerLogic.js.map +0 -1
  85. package/lib/logic/CustomError.js +0 -89
  86. package/lib/logic/CustomError.js.map +0 -1
  87. package/lib/logic/solidLogic.d.ts +0 -6
  88. package/lib/logic/solidLogic.js.map +0 -1
  89. package/lib/logic/solidLogicSingleton.js +0 -94
  90. package/lib/logic/solidLogicSingleton.js.map +0 -1
  91. package/lib/profile/profileLogic.js +0 -259
  92. package/lib/profile/profileLogic.js.map +0 -1
  93. package/lib/typeIndex/typeIndexLogic.js +0 -399
  94. package/lib/typeIndex/typeIndexLogic.js.map +0 -1
  95. package/lib/util/containerLogic.js +0 -102
  96. package/lib/util/containerLogic.js.map +0 -1
  97. package/lib/util/debug.d.ts.map +0 -1
  98. package/lib/util/debug.js +0 -40
  99. package/lib/util/debug.js.map +0 -1
  100. package/lib/util/utilityLogic.js +0 -284
  101. package/lib/util/utilityLogic.js.map +0 -1
  102. package/lib/util/utils.js +0 -47
  103. package/lib/util/utils.js.map +0 -1
  104. package/src/acl/aclLogic.ts +0 -156
  105. package/src/authSession/authSession.ts +0 -7
  106. package/src/authn/SolidAuthnLogic.ts +0 -127
  107. package/src/authn/authUtil.ts +0 -70
  108. package/src/chat/chatLogic.ts +0 -226
  109. package/src/inbox/inboxLogic.ts +0 -59
  110. package/src/index.ts +0 -22
  111. package/src/issuer/issuerLogic.ts +0 -40
  112. package/src/logic/CustomError.ts +0 -29
  113. package/src/logic/solidLogic.ts +0 -76
  114. package/src/logic/solidLogicSingleton.ts +0 -20
  115. package/src/profile/profileLogic.ts +0 -125
  116. package/src/typeIndex/typeIndexLogic.ts +0 -198
  117. package/src/types.ts +0 -122
  118. package/src/util/debug.ts +0 -20
  119. package/src/util/ns.ts +0 -5
  120. package/src/util/utilityLogic.ts +0 -156
  121. package/src/util/utils.ts +0 -52
  122. package/test/aclLogic.test.ts +0 -24
  123. package/test/authUtil.test.ts +0 -23
  124. package/test/chatLogic.test.ts +0 -316
  125. package/test/container.test.ts +0 -58
  126. package/test/helpers/dataSetup.ts +0 -134
  127. package/test/helpers/setup.ts +0 -17
  128. package/test/inboxLogic.test.ts +0 -218
  129. package/test/logic.test.ts +0 -29
  130. package/test/profileLogic.test.ts +0 -246
  131. package/test/solidAuthLogic.test.ts +0 -49
  132. package/test/typeIndexLogic.test.ts +0 -255
  133. package/test/utilityLogic.test.ts +0 -179
  134. package/test/utils.test.ts +0 -32
  135. package/tsconfig.json +0 -75
  136. /package/{lib → dist}/authSession/authSession.d.ts +0 -0
  137. /package/{lib → dist}/authSession/authSession.d.ts.map +0 -0
  138. /package/{lib → dist}/authn/authUtil.d.ts.map +0 -0
  139. /package/{lib → dist}/chat/chatLogic.d.ts.map +0 -0
  140. /package/{lib → dist}/issuer/issuerLogic.d.ts +0 -0
  141. /package/{lib → dist}/issuer/issuerLogic.d.ts.map +0 -0
  142. /package/{lib → dist}/logic/CustomError.d.ts +0 -0
  143. /package/{lib → dist}/logic/solidLogicSingleton.d.ts +0 -0
  144. /package/{lib → dist}/logic/solidLogicSingleton.d.ts.map +0 -0
  145. /package/{lib → dist}/profile/profileLogic.d.ts.map +0 -0
  146. /package/{lib → dist}/typeIndex/typeIndexLogic.d.ts +0 -0
  147. /package/{lib → dist}/typeIndex/typeIndexLogic.d.ts.map +0 -0
  148. /package/{lib → dist}/types.d.ts.map +0 -0
  149. /package/{lib → dist}/types.js +0 -0
  150. /package/{lib → dist}/types.js.map +0 -0
  151. /package/{lib → dist}/util/debug.d.ts +0 -0
  152. /package/{lib → dist}/util/ns.d.ts +0 -0
  153. /package/{lib → dist}/util/ns.d.ts.map +0 -0
@@ -0,0 +1,165 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.createProfileLogic = createProfileLogic;
37
+ const CustomError_1 = require("../logic/CustomError");
38
+ const debug = __importStar(require("../util/debug"));
39
+ const ns_1 = require("../util/ns");
40
+ const utils_1 = require("../util/utils");
41
+ function createProfileLogic(store, authn, utilityLogic) {
42
+ const ns = ns_1.ns;
43
+ /**
44
+ * loads the preference without throwing errors - if it can create it it does so.
45
+ * remark: it still throws error if it cannot load profile.
46
+ * @param user
47
+ * @returns undefined if preferenceFile cannot be returned or NamedNode if it can find it or create it
48
+ */
49
+ async function silencedLoadPreferences(user) {
50
+ try {
51
+ return await loadPreferences(user);
52
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
53
+ }
54
+ catch (err) {
55
+ return undefined;
56
+ }
57
+ }
58
+ /**
59
+ * loads the preference without returning different errors if it cannot create or load it.
60
+ * remark: it also throws error if it cannot load profile.
61
+ * @param user
62
+ * @returns undefined if preferenceFile cannot be an Error or NamedNode if it can find it or create it
63
+ */
64
+ async function loadPreferences(user) {
65
+ await loadProfile(user);
66
+ const possiblePreferencesFile = (0, utils_1.suggestPreferencesFile)(user);
67
+ let preferencesFile;
68
+ try {
69
+ preferencesFile = await utilityLogic.followOrCreateLink(user, ns.space('preferencesFile'), possiblePreferencesFile, user.doc());
70
+ }
71
+ catch (err) {
72
+ const message = `User ${user} has no pointer in profile to preferences file.`;
73
+ debug.warn(message);
74
+ // we are listing the possible errors
75
+ if (err instanceof CustomError_1.NotEditableError) {
76
+ throw err;
77
+ }
78
+ if (err instanceof CustomError_1.WebOperationError) {
79
+ throw err;
80
+ }
81
+ if (err instanceof CustomError_1.UnauthorizedError) {
82
+ throw err;
83
+ }
84
+ if (err instanceof CustomError_1.CrossOriginForbiddenError) {
85
+ throw err;
86
+ }
87
+ if (err instanceof CustomError_1.SameOriginForbiddenError) {
88
+ throw err;
89
+ }
90
+ if (err instanceof CustomError_1.FetchError) {
91
+ throw err;
92
+ }
93
+ throw err;
94
+ }
95
+ try {
96
+ await store.fetcher.load(preferencesFile);
97
+ }
98
+ catch (err) { // Maybe a permission problem or origin problem
99
+ const msg = `Unable to load preference of user ${user}: ${err}`;
100
+ debug.warn(msg);
101
+ if (err.response.status === 401) {
102
+ throw new CustomError_1.UnauthorizedError();
103
+ }
104
+ if (err.response.status === 403) {
105
+ if ((0, utils_1.differentOrigin)(preferencesFile)) {
106
+ throw new CustomError_1.CrossOriginForbiddenError();
107
+ }
108
+ throw new CustomError_1.SameOriginForbiddenError();
109
+ }
110
+ /*if (err.response.status === 404) {
111
+ throw new NotFoundError();
112
+ }*/
113
+ throw new Error(msg);
114
+ }
115
+ return preferencesFile;
116
+ }
117
+ async function loadProfile(user) {
118
+ if (!user) {
119
+ throw new Error('loadProfile: no user given.');
120
+ }
121
+ try {
122
+ await store.fetcher.load(user.doc());
123
+ }
124
+ catch (err) {
125
+ throw new Error(`Unable to load profile of user ${user}: ${err}`);
126
+ }
127
+ return user.doc();
128
+ }
129
+ async function loadMe() {
130
+ const me = authn.currentUser();
131
+ if (me === null) {
132
+ throw new Error('Current user not found! Not logged in?');
133
+ }
134
+ await store.fetcher.load(me.doc());
135
+ return me;
136
+ }
137
+ function getPodRoot(user) {
138
+ const podRoot = findStorage(user);
139
+ if (!podRoot) {
140
+ throw new Error('User pod root not found!');
141
+ }
142
+ return podRoot;
143
+ }
144
+ async function getMainInbox(user) {
145
+ await store.fetcher.load(user);
146
+ const mainInbox = store.any(user, ns.ldp('inbox'), undefined, user.doc());
147
+ if (!mainInbox) {
148
+ throw new Error('User main inbox not found!');
149
+ }
150
+ return mainInbox;
151
+ }
152
+ function findStorage(me) {
153
+ return store.any(me, ns.space('storage'), undefined, me.doc());
154
+ }
155
+ return {
156
+ loadMe,
157
+ getPodRoot,
158
+ getMainInbox,
159
+ findStorage,
160
+ loadPreferences,
161
+ loadProfile,
162
+ silencedLoadPreferences
163
+ };
164
+ }
165
+ //# sourceMappingURL=profileLogic.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"profileLogic.js","sourceRoot":"","sources":["../../src/profile/profileLogic.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAOA,gDAqHC;AA3HD,sDAA8J;AAC9J,qDAAsC;AACtC,mCAA4C;AAC5C,yCAAuE;AAGvE,SAAgB,kBAAkB,CAAC,KAAK,EAAE,KAAK,EAAE,YAAY;IACzD,MAAM,EAA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