solid-logic 1.3.17-8a332867 → 1.3.17-a27c1702
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/jest.config.js +1 -1
- package/lib/acl/aclLogic.d.ts +12 -30
- package/lib/acl/aclLogic.d.ts.map +1 -1
- package/lib/acl/aclLogic.js +152 -119
- package/lib/acl/aclLogic.js.map +1 -1
- package/lib/authn/SolidAuthnLogic.d.ts.map +1 -1
- package/lib/authn/SolidAuthnLogic.js +2 -2
- package/lib/authn/SolidAuthnLogic.js.map +1 -1
- package/lib/chat/chatLogic.d.ts +16 -0
- package/lib/chat/chatLogic.d.ts.map +1 -0
- package/lib/chat/{ChatLogic.js → chatLogic.js} +82 -87
- package/lib/chat/chatLogic.js.map +1 -0
- package/lib/inbox/inboxLogic.d.ts +7 -0
- package/lib/inbox/inboxLogic.d.ts.map +1 -0
- package/lib/inbox/{InboxLogic.js → inboxLogic.js} +58 -64
- package/lib/inbox/inboxLogic.js.map +1 -0
- package/lib/index.d.ts +18 -9
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +86 -34
- package/lib/index.js.map +1 -1
- package/lib/logic/CustomError.d.ts +4 -0
- package/lib/logic/CustomError.d.ts.map +1 -1
- package/lib/logic/CustomError.js +17 -1
- package/lib/logic/CustomError.js.map +1 -1
- package/lib/logic/SolidLogic.d.ts +8 -34
- package/lib/logic/SolidLogic.d.ts.map +1 -1
- package/lib/logic/SolidLogic.js +16 -250
- package/lib/logic/SolidLogic.js.map +1 -1
- package/lib/logic/solidLogicSingleton.js +1 -1
- package/lib/logic/solidLogicSingleton.js.map +1 -1
- package/lib/logic/solidLogicSingletonNew.d.ts +80 -0
- package/lib/logic/solidLogicSingletonNew.d.ts.map +1 -0
- package/lib/logic/solidLogicSingletonNew.js +238 -0
- package/lib/logic/solidLogicSingletonNew.js.map +1 -0
- package/lib/profile/profileLogic.d.ts +13 -0
- package/lib/profile/profileLogic.d.ts.map +1 -0
- package/lib/profile/profileLogic.js +268 -0
- package/lib/profile/profileLogic.js.map +1 -0
- package/lib/typeIndex/typeIndexLogic.d.ts +31 -21
- package/lib/typeIndex/typeIndexLogic.d.ts.map +1 -1
- package/lib/typeIndex/typeIndexLogic.js +650 -295
- package/lib/typeIndex/typeIndexLogic.js.map +1 -1
- package/lib/types.d.ts +17 -0
- package/lib/types.d.ts.map +1 -1
- package/lib/util/containerLogic.d.ts +11 -0
- package/lib/util/containerLogic.d.ts.map +1 -0
- package/lib/{profile/ProfileLogic.js → util/containerLogic.js} +53 -44
- package/lib/util/containerLogic.js.map +1 -0
- package/lib/util/ns.d.ts +2 -0
- package/lib/util/ns.d.ts.map +1 -0
- package/lib/util/ns.js +34 -0
- package/lib/util/ns.js.map +1 -0
- package/lib/util/utilityLogic.d.ts +15 -0
- package/lib/util/utilityLogic.d.ts.map +1 -0
- package/lib/util/utilityLogic.js +272 -0
- package/lib/util/utilityLogic.js.map +1 -0
- package/lib/util/utils.d.ts +8 -0
- package/lib/util/utils.d.ts.map +1 -0
- package/lib/util/utils.js +48 -0
- package/lib/util/utils.js.map +1 -0
- package/package.json +3 -1
- package/src/acl/aclLogic.ts +136 -118
- package/src/authn/SolidAuthnLogic.ts +3 -2
- package/src/chat/chatLogic.ts +225 -0
- package/src/inbox/inboxLogic.ts +57 -0
- package/src/index.ts +139 -27
- package/src/logic/CustomError.ts +5 -1
- package/src/logic/SolidLogic.ts +30 -211
- package/src/logic/solidLogicSingleton.ts +1 -1
- package/src/logic/solidLogicSingletonNew.ts +239 -0
- package/src/profile/profileLogic.ts +134 -0
- package/src/typeIndex/typeIndexLogic.ts +417 -153
- package/src/types.ts +7 -3
- package/src/util/containerLogic.ts +54 -0
- package/src/util/ns.ts +5 -0
- package/src/util/utilityLogic.ts +155 -0
- package/src/util/utils.ts +52 -0
- package/test/aclLogic.test.ts +13 -4
- package/test/chatLogic.test.ts +70 -71
- package/test/container.test.ts +56 -0
- package/test/helpers/dataSetup.ts +134 -0
- package/test/helpers/setup.ts +1 -0
- package/test/inboxLogic.test.ts +39 -38
- package/test/logic.test.ts +10 -9
- package/test/profileLogic.test.ts +246 -0
- package/test/typeIndexLogic.test.ts +49 -22
- package/test/typeIndexLogicPart2.test.ts +485 -0
- package/test/utilityLogic.test.ts +172 -126
- package/test/utils.test.ts +32 -0
- package/lib/chat/ChatLogic.d.ts +0 -26
- package/lib/chat/ChatLogic.d.ts.map +0 -1
- package/lib/chat/ChatLogic.js.map +0 -1
- package/lib/chat/determineChatContainer.d.ts +0 -3
- package/lib/chat/determineChatContainer.d.ts.map +0 -1
- package/lib/chat/determineChatContainer.js +0 -12
- package/lib/chat/determineChatContainer.js.map +0 -1
- package/lib/discovery/discoveryLogic.d.ts +0 -40
- package/lib/discovery/discoveryLogic.d.ts.map +0 -1
- package/lib/discovery/discoveryLogic.js +0 -494
- package/lib/discovery/discoveryLogic.js.map +0 -1
- package/lib/inbox/InboxLogic.d.ts +0 -18
- package/lib/inbox/InboxLogic.d.ts.map +0 -1
- package/lib/inbox/InboxLogic.js.map +0 -1
- package/lib/profile/ProfileLogic.d.ts +0 -13
- package/lib/profile/ProfileLogic.d.ts.map +0 -1
- package/lib/profile/ProfileLogic.js.map +0 -1
- package/lib/util/UtilityLogic.d.ts +0 -33
- package/lib/util/UtilityLogic.d.ts.map +0 -1
- package/lib/util/UtilityLogic.js +0 -240
- package/lib/util/UtilityLogic.js.map +0 -1
- package/lib/util/uri.d.ts +0 -3
- package/lib/util/uri.d.ts.map +0 -1
- package/lib/util/uri.js +0 -9
- package/lib/util/uri.js.map +0 -1
- package/src/chat/ChatLogic.ts +0 -244
- package/src/chat/determineChatContainer.ts +0 -14
- package/src/discovery/discoveryLogic.ts +0 -310
- package/src/inbox/InboxLogic.ts +0 -66
- package/src/profile/ProfileLogic.ts +0 -44
- package/src/util/UtilityLogic.ts +0 -161
- package/src/util/uri.ts +0 -5
- package/test/discoveryLogic.test.ts +0 -740
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
import * as rdf from "rdflib"
|
|
2
|
+
import { SolidAuthnLogic } from "../authn/SolidAuthnLogic"
|
|
3
|
+
import { authSession } from "../authSession/authSession"
|
|
4
|
+
import { createContainerLogic } from "../util/containerLogic"
|
|
5
|
+
import { createTypeIndexLogic } from "../typeIndex/typeIndexLogic"
|
|
6
|
+
import * as debug from "../util/debug"
|
|
7
|
+
import { createUtilityLogic } from "../util/utilityLogic"
|
|
8
|
+
import { createProfileLogic } from "../profile/profileLogic"
|
|
9
|
+
import { createInboxLogic } from "../inbox/inboxLogic"
|
|
10
|
+
import { createChatLogic } from "../chat/chatLogic"
|
|
11
|
+
import { createAclLogic } from "../acl/aclLogic"
|
|
12
|
+
|
|
13
|
+
export function solidLogicSingleton() {
|
|
14
|
+
|
|
15
|
+
const _fetch = async (url, requestInit) => {
|
|
16
|
+
const omitCreds = requestInit && requestInit.credentials && requestInit.credentials == 'omit'
|
|
17
|
+
if (authSession.info.webId && !omitCreds) { // see https://github.com/solidos/solidos/issues/114
|
|
18
|
+
// In fact fetch should respect credentials omit itself
|
|
19
|
+
return authSession.fetch(url, requestInit)
|
|
20
|
+
} else {
|
|
21
|
+
return window.fetch(url, requestInit)
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
debug.log("SolidLogicSingleton: Unique instance created. There should only be one of these.")
|
|
26
|
+
|
|
27
|
+
const store = rdf.graph() as rdf.LiveStore; // Make a Quad store
|
|
28
|
+
rdf.fetcher(store, { fetch: _fetch }); // Attach a web I/O module, store.fetcher
|
|
29
|
+
store.updater = new rdf.UpdateManager(store); // Add real-time live updates store.updater
|
|
30
|
+
store.features = [] // disable automatic node merging on store load
|
|
31
|
+
|
|
32
|
+
debug.log('SolidAuthnLogic initialized')
|
|
33
|
+
const authn = new SolidAuthnLogic(authSession)
|
|
34
|
+
|
|
35
|
+
const aclLogic = createAclLogic(store)
|
|
36
|
+
const {
|
|
37
|
+
findAclDocUrl,
|
|
38
|
+
setACLUserPublic,
|
|
39
|
+
genACLText
|
|
40
|
+
} = aclLogic
|
|
41
|
+
|
|
42
|
+
const containerLogic = createContainerLogic(store)
|
|
43
|
+
const {
|
|
44
|
+
isContainer,
|
|
45
|
+
createContainer,
|
|
46
|
+
getContainerElements,
|
|
47
|
+
getContainerMembers
|
|
48
|
+
} = containerLogic
|
|
49
|
+
|
|
50
|
+
const utilityLogic = createUtilityLogic(store, aclLogic, containerLogic)
|
|
51
|
+
const {
|
|
52
|
+
recursiveDelete,
|
|
53
|
+
setSinglePeerAccess,
|
|
54
|
+
createEmptyRdfDoc,
|
|
55
|
+
followOrCreateLink,
|
|
56
|
+
loadOrCreateIfNotExists
|
|
57
|
+
} = utilityLogic
|
|
58
|
+
|
|
59
|
+
const profileLogic = createProfileLogic(store, authn, utilityLogic)
|
|
60
|
+
const {
|
|
61
|
+
ensureLoadedPreferences,
|
|
62
|
+
loadMe,
|
|
63
|
+
getPodRoot,
|
|
64
|
+
getMainInbox,
|
|
65
|
+
findStorage,
|
|
66
|
+
loadPreferences,
|
|
67
|
+
loadProfile,
|
|
68
|
+
silencedLoadPreferences
|
|
69
|
+
} = profileLogic
|
|
70
|
+
|
|
71
|
+
const chatLogic = createChatLogic(store, profileLogic)
|
|
72
|
+
const {
|
|
73
|
+
setAcl,
|
|
74
|
+
addToPrivateTypeIndex,
|
|
75
|
+
findChat,
|
|
76
|
+
createChatThing,
|
|
77
|
+
getChat,
|
|
78
|
+
sendInvite,
|
|
79
|
+
mintNew
|
|
80
|
+
} = chatLogic
|
|
81
|
+
|
|
82
|
+
const inboxLogic = createInboxLogic(store, profileLogic, utilityLogic, containerLogic, aclLogic)
|
|
83
|
+
const {
|
|
84
|
+
createInboxFor,
|
|
85
|
+
getNewMessages,
|
|
86
|
+
markAsRead
|
|
87
|
+
} = inboxLogic
|
|
88
|
+
|
|
89
|
+
const typeIndexLogic = createTypeIndexLogic(store, authn, profileLogic, utilityLogic)
|
|
90
|
+
const {
|
|
91
|
+
ensureTypeIndexes,
|
|
92
|
+
loadTypeIndexes,
|
|
93
|
+
registerInTypeIndex,
|
|
94
|
+
loadIndex,
|
|
95
|
+
ensureOneTypeIndex,
|
|
96
|
+
putIndex,
|
|
97
|
+
makeIndexIfNecessary,
|
|
98
|
+
loadIndexes,
|
|
99
|
+
getTypeIndex,
|
|
100
|
+
getRegistrations,
|
|
101
|
+
loadTypeIndexesFor,
|
|
102
|
+
loadCommunityTypeIndexes,
|
|
103
|
+
loadAllTypeIndexes,
|
|
104
|
+
getScopedAppInstances,
|
|
105
|
+
getAppInstances,
|
|
106
|
+
suggestPublicTypeIndex,
|
|
107
|
+
suggestPrivateTypeIndex,
|
|
108
|
+
registerInstanceInTypeIndex,
|
|
109
|
+
deleteTypeIndexRegistration,
|
|
110
|
+
getScopedAppsFromIndex
|
|
111
|
+
} = typeIndexLogic
|
|
112
|
+
|
|
113
|
+
return {
|
|
114
|
+
store,
|
|
115
|
+
authn,
|
|
116
|
+
authSession,
|
|
117
|
+
//unilityLogic
|
|
118
|
+
recursiveDelete,
|
|
119
|
+
setSinglePeerAccess,
|
|
120
|
+
createEmptyRdfDoc,
|
|
121
|
+
followOrCreateLink,
|
|
122
|
+
loadOrCreateIfNotExists,
|
|
123
|
+
//containerLogic
|
|
124
|
+
isContainer,
|
|
125
|
+
createContainer,
|
|
126
|
+
getContainerElements,
|
|
127
|
+
getContainerMembers,
|
|
128
|
+
//typeIndexLogic
|
|
129
|
+
ensureTypeIndexes,
|
|
130
|
+
loadTypeIndexes,
|
|
131
|
+
registerInTypeIndex,
|
|
132
|
+
loadIndex,
|
|
133
|
+
ensureOneTypeIndex,
|
|
134
|
+
putIndex,
|
|
135
|
+
makeIndexIfNecessary,
|
|
136
|
+
loadIndexes,
|
|
137
|
+
getTypeIndex,
|
|
138
|
+
getRegistrations,
|
|
139
|
+
loadTypeIndexesFor,
|
|
140
|
+
loadCommunityTypeIndexes,
|
|
141
|
+
loadAllTypeIndexes,
|
|
142
|
+
getScopedAppInstances,
|
|
143
|
+
getAppInstances,
|
|
144
|
+
suggestPublicTypeIndex,
|
|
145
|
+
suggestPrivateTypeIndex,
|
|
146
|
+
registerInstanceInTypeIndex,
|
|
147
|
+
deleteTypeIndexRegistration,
|
|
148
|
+
getScopedAppsFromIndex,
|
|
149
|
+
//profileLogic
|
|
150
|
+
ensureLoadedPreferences,
|
|
151
|
+
loadMe,
|
|
152
|
+
getPodRoot,
|
|
153
|
+
getMainInbox,
|
|
154
|
+
findStorage,
|
|
155
|
+
loadPreferences,
|
|
156
|
+
loadProfile,
|
|
157
|
+
silencedLoadPreferences,
|
|
158
|
+
//inboxLogic
|
|
159
|
+
createInboxFor,
|
|
160
|
+
getNewMessages,
|
|
161
|
+
markAsRead,
|
|
162
|
+
//chatLogic
|
|
163
|
+
setAcl,
|
|
164
|
+
addToPrivateTypeIndex,
|
|
165
|
+
findChat,
|
|
166
|
+
createChatThing,
|
|
167
|
+
getChat,
|
|
168
|
+
sendInvite,
|
|
169
|
+
mintNew,
|
|
170
|
+
//aclLogic
|
|
171
|
+
findAclDocUrl,
|
|
172
|
+
setACLUserPublic,
|
|
173
|
+
genACLText
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/*export {
|
|
178
|
+
store,
|
|
179
|
+
authn,
|
|
180
|
+
authSession,
|
|
181
|
+
//unilityLogic
|
|
182
|
+
recursiveDelete,
|
|
183
|
+
setSinglePeerAccess,
|
|
184
|
+
createEmptyRdfDoc,
|
|
185
|
+
followOrCreateLink,
|
|
186
|
+
loadOrCreateIfNotExists,
|
|
187
|
+
//containerLogic
|
|
188
|
+
isContainer,
|
|
189
|
+
createContainer,
|
|
190
|
+
getContainerElements,
|
|
191
|
+
getContainerMembers,
|
|
192
|
+
//typeIndexLogic
|
|
193
|
+
ensureTypeIndexes,
|
|
194
|
+
loadTypeIndexes,
|
|
195
|
+
registerInTypeIndex,
|
|
196
|
+
loadIndex,
|
|
197
|
+
ensureOneTypeIndex,
|
|
198
|
+
putIndex,
|
|
199
|
+
makeIndexIfNecessary,
|
|
200
|
+
loadIndexes,
|
|
201
|
+
getTypeIndex,
|
|
202
|
+
getRegistrations,
|
|
203
|
+
loadTypeIndexesFor,
|
|
204
|
+
loadCommunityTypeIndexes,
|
|
205
|
+
loadAllTypeIndexes,
|
|
206
|
+
getScopedAppInstances,
|
|
207
|
+
getAppInstances,
|
|
208
|
+
suggestPublicTypeIndex,
|
|
209
|
+
suggestPrivateTypeIndex,
|
|
210
|
+
registerInstanceInTypeIndex,
|
|
211
|
+
deleteTypeIndexRegistration,
|
|
212
|
+
getScopedAppsFromIndex,
|
|
213
|
+
//profileLogic
|
|
214
|
+
ensureLoadedPreferences,
|
|
215
|
+
loadMe,
|
|
216
|
+
getPodRoot,
|
|
217
|
+
getMainInbox,
|
|
218
|
+
findStorage,
|
|
219
|
+
loadPreferences,
|
|
220
|
+
loadProfile,
|
|
221
|
+
silencedLoadPreferences,
|
|
222
|
+
//inboxLogic
|
|
223
|
+
createInboxFor,
|
|
224
|
+
getNewMessages,
|
|
225
|
+
markAsRead,
|
|
226
|
+
//chatLogic
|
|
227
|
+
setAcl,
|
|
228
|
+
addToPrivateTypeIndex,
|
|
229
|
+
findChat,
|
|
230
|
+
createChatThing,
|
|
231
|
+
getChat,
|
|
232
|
+
sendInvite,
|
|
233
|
+
mintNew,
|
|
234
|
+
//aclLogic
|
|
235
|
+
findAclDocUrl,
|
|
236
|
+
setACLUserPublic,
|
|
237
|
+
genACLText
|
|
238
|
+
}
|
|
239
|
+
*/
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { NamedNode } from "rdflib";
|
|
2
|
+
import { CrossOriginForbiddenError, FetchError, NotEditableError, SameOriginForbiddenError, UnauthorizedError, WebOperationError } from "../logic/CustomError";
|
|
3
|
+
import { AuthenticationContext } from "../types";
|
|
4
|
+
import * as debug from "../util/debug";
|
|
5
|
+
import { differentOrigin, suggestPreferencesFile } from "../util/utils";
|
|
6
|
+
import { ns as namespace } from '../util/ns'
|
|
7
|
+
|
|
8
|
+
export function createProfileLogic(store, authn, utilityLogic) {
|
|
9
|
+
const ns = namespace
|
|
10
|
+
|
|
11
|
+
async function ensureLoadedPreferences (context: AuthenticationContext) {
|
|
12
|
+
if (!context.me) throw new Error('@@ ensureLoadedPreferences: no user specified')
|
|
13
|
+
context.publicProfile = await loadProfile(context.me)
|
|
14
|
+
context.preferencesFile = await silencedLoadPreferences(context.me)
|
|
15
|
+
return context
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* loads the preference without throwing errors - if it can create it it does so.
|
|
20
|
+
* remark: it still throws error if it cannot load profile.
|
|
21
|
+
* @param user
|
|
22
|
+
* @returns undefined if preferenceFile cannot be returned or NamedNode if it can find it or create it
|
|
23
|
+
*/
|
|
24
|
+
async function silencedLoadPreferences(user: NamedNode): Promise <NamedNode | undefined> {
|
|
25
|
+
try {
|
|
26
|
+
return await loadPreferences(user)
|
|
27
|
+
} catch (err) {
|
|
28
|
+
return undefined
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* loads the preference without returning different errors if it cannot create or load it.
|
|
34
|
+
* remark: it also throws error if it cannot load profile.
|
|
35
|
+
* @param user
|
|
36
|
+
* @returns undefined if preferenceFile cannot be an Error or NamedNode if it can find it or create it
|
|
37
|
+
*/
|
|
38
|
+
async function loadPreferences (user: NamedNode): Promise <NamedNode> {
|
|
39
|
+
await loadProfile(user)
|
|
40
|
+
|
|
41
|
+
const possiblePreferencesFile = suggestPreferencesFile(user)
|
|
42
|
+
let preferencesFile
|
|
43
|
+
try {
|
|
44
|
+
preferencesFile = await utilityLogic.followOrCreateLink(user, ns.space('preferencesFile') as NamedNode, possiblePreferencesFile, user.doc())
|
|
45
|
+
} catch (err) {
|
|
46
|
+
const message = `User ${user} has no pointer in profile to preferences file.`
|
|
47
|
+
debug.warn(message)
|
|
48
|
+
// we are listing the possible errors
|
|
49
|
+
if (err instanceof NotEditableError) { throw err }
|
|
50
|
+
if (err instanceof WebOperationError) { throw err }
|
|
51
|
+
if (err instanceof UnauthorizedError) { throw err }
|
|
52
|
+
if (err instanceof CrossOriginForbiddenError) { throw err }
|
|
53
|
+
if (err instanceof SameOriginForbiddenError) { throw err }
|
|
54
|
+
if (err instanceof FetchError) { throw err }
|
|
55
|
+
throw err
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
let response
|
|
59
|
+
try {
|
|
60
|
+
response = await store.fetcher.load(preferencesFile as NamedNode)
|
|
61
|
+
} catch (err) { // Maybe a permission problem or origin problem
|
|
62
|
+
const msg = `Unable to load preference of user ${user}: ${err}`
|
|
63
|
+
debug.warn(msg)
|
|
64
|
+
if (err.response.status === 401) {
|
|
65
|
+
throw new UnauthorizedError();
|
|
66
|
+
}
|
|
67
|
+
if (err.response.status === 403) {
|
|
68
|
+
if (differentOrigin(preferencesFile)) {
|
|
69
|
+
throw new CrossOriginForbiddenError();
|
|
70
|
+
}
|
|
71
|
+
throw new SameOriginForbiddenError();
|
|
72
|
+
}
|
|
73
|
+
/*if (err.response.status === 404) {
|
|
74
|
+
throw new NotFoundError();
|
|
75
|
+
}*/
|
|
76
|
+
throw new Error(msg)
|
|
77
|
+
}
|
|
78
|
+
return preferencesFile as NamedNode
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
async function loadProfile (user: NamedNode):Promise <NamedNode> {
|
|
82
|
+
if (!user) {
|
|
83
|
+
throw new Error(`loadProfile: no user given.`)
|
|
84
|
+
}
|
|
85
|
+
try {
|
|
86
|
+
await store.fetcher.load(user.doc())
|
|
87
|
+
} catch (err) {
|
|
88
|
+
throw new Error(`Unable to load profile of user ${user}: ${err}`)
|
|
89
|
+
}
|
|
90
|
+
return user.doc()
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
async function loadMe(): Promise<NamedNode> {
|
|
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
|
+
|
|
102
|
+
function getPodRoot(user: NamedNode): NamedNode {
|
|
103
|
+
const podRoot = findStorage(user);
|
|
104
|
+
if (!podRoot) {
|
|
105
|
+
throw new Error("User pod root not found!");
|
|
106
|
+
}
|
|
107
|
+
return podRoot as NamedNode;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
async function getMainInbox(user: NamedNode): Promise<NamedNode> {
|
|
111
|
+
await store.fetcher.load(user);
|
|
112
|
+
const mainInbox = store.any(user, ns.ldp("inbox"), undefined, user.doc());
|
|
113
|
+
if (!mainInbox) {
|
|
114
|
+
throw new Error("User main inbox not found!");
|
|
115
|
+
}
|
|
116
|
+
return mainInbox as NamedNode;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
function findStorage(me: NamedNode) {
|
|
120
|
+
return store.any(me, ns.space("storage"), undefined, me.doc());
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
return {
|
|
124
|
+
ensureLoadedPreferences,
|
|
125
|
+
loadMe,
|
|
126
|
+
getPodRoot,
|
|
127
|
+
getMainInbox,
|
|
128
|
+
findStorage,
|
|
129
|
+
loadPreferences,
|
|
130
|
+
loadProfile,
|
|
131
|
+
silencedLoadPreferences
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|