solid-logic 1.3.16-8afe9dc4 → 1.3.17-0abe2b84
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/authn/SolidAuthnLogic.js +1 -1
- package/lib/authn/SolidAuthnLogic.js.map +1 -1
- package/lib/authn/authUtil.js +1 -1
- package/lib/authn/authUtil.js.map +1 -1
- package/lib/discovery/discoveryLogic.d.ts +33 -6
- package/lib/discovery/discoveryLogic.d.ts.map +1 -1
- package/lib/discovery/discoveryLogic.js +377 -86
- package/lib/discovery/discoveryLogic.js.map +1 -1
- package/lib/logic/solidLogicSingleton.js +1 -1
- package/lib/logic/solidLogicSingleton.js.map +1 -1
- package/lib/typeIndex/typeIndexLogic.d.ts +2 -2
- package/lib/typeIndex/typeIndexLogic.js +4 -4
- package/lib/typeIndex/typeIndexLogic.js.map +1 -1
- package/lib/util/UtilityLogic.js +2 -2
- package/lib/util/UtilityLogic.js.map +1 -1
- package/package.json +7 -7
- package/src/authn/SolidAuthnLogic.ts +5 -5
- package/src/authn/authUtil.ts +1 -1
- package/src/discovery/discoveryLogic.ts +269 -48
- package/src/logic/solidLogicSingleton.ts +1 -1
- package/src/typeIndex/typeIndexLogic.ts +5 -5
- package/src/util/UtilityLogic.ts +3 -3
- package/test/discoveryLogic.test.ts +740 -0
- package/test/helpers/setup.ts +3 -0
- package/test/typeIndexLogic.test.ts +5 -4
|
@@ -98,7 +98,7 @@ function ensureLoadedPreferences(context) {
|
|
|
98
98
|
* Resolves with the same context, outputting
|
|
99
99
|
* output: index.public, index.private
|
|
100
100
|
* @@ This is a very bizare function
|
|
101
|
-
* @see https://github.com/
|
|
101
|
+
* @see https://github.com/solidos/solid/blob/main/proposals/data-discovery.md#discoverability
|
|
102
102
|
*/
|
|
103
103
|
function loadIndex(context, isPublic) {
|
|
104
104
|
return __awaiter(this, void 0, void 0, function () {
|
|
@@ -161,7 +161,7 @@ function loadTypeIndexes(context) {
|
|
|
161
161
|
exports.loadTypeIndexes = loadTypeIndexes;
|
|
162
162
|
/**
|
|
163
163
|
* Resolves with the same context, outputting
|
|
164
|
-
* @see https://github.com/
|
|
164
|
+
* @see https://github.com/solidos/solid/blob/main/proposals/data-discovery.md#discoverability
|
|
165
165
|
*/
|
|
166
166
|
function ensureTypeIndexes(context, agent) {
|
|
167
167
|
return __awaiter(this, void 0, void 0, function () {
|
|
@@ -189,7 +189,7 @@ exports.ensureTypeIndexes = ensureTypeIndexes;
|
|
|
189
189
|
* Many reasons for failing including script not having permission etc
|
|
190
190
|
*
|
|
191
191
|
* Adds its output to the context
|
|
192
|
-
* @see https://github.com/
|
|
192
|
+
* @see https://github.com/solidos/solid/blob/main/proposals/data-discovery.md#discoverability
|
|
193
193
|
*/
|
|
194
194
|
function ensureOneTypeIndex(context, isPublic, agent) {
|
|
195
195
|
return __awaiter(this, void 0, void 0, function () {
|
|
@@ -342,7 +342,7 @@ function registerInTypeIndex(context, instance, theClass, isPublic, agent // Def
|
|
|
342
342
|
index = indexes[0];
|
|
343
343
|
registration = (0, uri_1.newThing)(index);
|
|
344
344
|
ins = [
|
|
345
|
-
// See https://github.com/
|
|
345
|
+
// See https://github.com/solidos/solid/blob/main/proposals/data-discovery.md
|
|
346
346
|
(0, rdflib_1.st)(registration, exports.ns.rdf('type'), exports.ns.solid('TypeRegistration'), index),
|
|
347
347
|
(0, rdflib_1.st)(registration, exports.ns.solid('forClass'), theClass, index),
|
|
348
348
|
(0, rdflib_1.st)(registration, exports.ns.solid('instance'), instance, index)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"typeIndexLogic.js","sourceRoot":"","sources":["../../src/typeIndex/typeIndexLogic.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iCAA2C;AAC3C,mDAAsC;AACtC,oEAA4C;AAC5C,2CAA8B;AAC9B,mCAAsC;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AAK,GAAG,OAAO,CAAC,CAAC,CAAC,CAAA;oBAClB,YAAY,GAAG,IAAA,cAAQ,EAAC,KAAK,CAAC,CAAA;oBAC9B,GAAG,GAAG;wBACR,6EAA6E;wBAC7E,IAAA,WAAE,EAAC,YAAY,EAAE,UAAE,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,UAAE,CAAC,KAAK,CAAC,kBAAkB,CAAC,EAAE,KAAK,CAAC;wBACrE,IAAA,WAAE,EAAC,YAAY,EAAE,UAAE,CAAC,KAAK,CAAC,UAAU,CAAC,EAAE,QAAQ,EAAE,KAAK,CAAC;wBACvD,IAAA,WAAE,EAAC,YAAY,EAAE,UAAE,CAAC,KAAK,CAAC,UAAU,CAAC,EAAE,QAAQ,EAAE,KAAK,CAAC;qBAC1D,CAAA;;;;oBAEG,qBAAM,yCAAmB,CAAC,aAAa,CAAC,EAAE,EAAE,GAAG,CAAC,EAAA;;oBAAhD,SAAgD,CAAA;;;;oBAEhD,KAAK,CAAC,GAAG,CAAC,GAAC,CAAC,CAAA;oBACZ,KAAK,CAAC,GAAC,CAAC,CAAA;;wBAEZ,sBAAO,OAAO,EAAA;;;;CACjB;AA9BD,kDA8BC"}
|
package/lib/util/UtilityLogic.js
CHANGED
|
@@ -68,7 +68,7 @@ var UtilityLogic = /** @class */ (function () {
|
|
|
68
68
|
});
|
|
69
69
|
});
|
|
70
70
|
};
|
|
71
|
-
// Copied from https://github.com/
|
|
71
|
+
// Copied from https://github.com/solidos/web-access-control-tests/blob/v3.0.0/test/surface/delete.test.ts#L5
|
|
72
72
|
UtilityLogic.prototype.setSinglePeerAccess = function (options) {
|
|
73
73
|
return __awaiter(this, void 0, void 0, function () {
|
|
74
74
|
var str, aclDocUrl;
|
|
@@ -156,7 +156,7 @@ var UtilityLogic = /** @class */ (function () {
|
|
|
156
156
|
headers: {
|
|
157
157
|
"Content-Type": "text/turtle",
|
|
158
158
|
"If-None-Match": "*",
|
|
159
|
-
Link: '<http://www.w3.org/ns/ldp#BasicContainer>; rel="type"', // See https://github.com/
|
|
159
|
+
Link: '<http://www.w3.org/ns/ldp#BasicContainer>; rel="type"', // See https://github.com/solidos/node-solid-server/issues/1465
|
|
160
160
|
},
|
|
161
161
|
body: " ", // work around https://github.com/michielbdejong/community-server/issues/4#issuecomment-776222863
|
|
162
162
|
})];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UtilityLogic.js","sourceRoot":"","sources":["../../src/util/UtilityLogic.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iCAA8D;AAGjD,QAAA,QAAQ,GAAG,IAAA,YAAG,EACzB,oDAAoD,CACrD,CAAC;AAEF;;GAEG;AACH;IAKE,sBAAY,KAAgB,EAAE,EAAkB,EAAE,eAA+D;QAC/G,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;QACb,IAAI,CAAC,eAAe,GAAG,eAAe,CAAC;IACzC,CAAC;IAEK,oCAAa,GAAnB,UAAoB,GAAW;;;;;;;wBACvB,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;wBAChC,qBAAM,CAAA,MAAA,IAAI,CAAC,KAAK,CAAC,OAAO,0CAAE,IAAI,CAAC,GAAG,CAAC,CAAA,EAAA;;wBAAnC,SAAmC,CAAC;wBAC9B,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE,gBAAQ,CAAC,CAAC;wBAC9C,IAAI,CAAC,OAAO,EAAE;4BACZ,MAAM,IAAI,KAAK,CAAC,qCAA8B,GAAG,CAAE,CAAC,CAAC;yBACtD;wBACD,sBAAO,OAAO,CAAC,KAAK,EAAC;;;;KACtB;IAED,
|
|
1
|
+
{"version":3,"file":"UtilityLogic.js","sourceRoot":"","sources":["../../src/util/UtilityLogic.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;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AAC,UAAU,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;QAClD,IAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QACjC,IAAM,QAAQ,GAAG,KAAK,CAAC,KAAK,CAAC,MAAM,GAAE,CAAC,CAAE,CAAC;QACzC,OAAO,IAAI,GAAG,CAAC,oBAAa,IAAI,cAAI,KAAK,cAAI,GAAG,cAAI,QAAQ,CAAE,EAAE,OAAO,CAAC,CAAC,QAAQ,EAAE,CAAC;IACtF,CAAC;IACH,mBAAC;AAAD,CAAC,AAtJD,IAsJC;AAtJY,oCAAY"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "solid-logic",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.17-0abe2b84",
|
|
4
4
|
"description": "Core business logic of Solid OS",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -15,14 +15,14 @@
|
|
|
15
15
|
},
|
|
16
16
|
"repository": {
|
|
17
17
|
"type": "git",
|
|
18
|
-
"url": "git+https://github.com/
|
|
18
|
+
"url": "git+https://github.com/solidos/solid-logic.git"
|
|
19
19
|
},
|
|
20
20
|
"author": "",
|
|
21
21
|
"license": "MIT",
|
|
22
22
|
"bugs": {
|
|
23
|
-
"url": "https://github.com/
|
|
23
|
+
"url": "https://github.com/solidos/solid-logic/issues"
|
|
24
24
|
},
|
|
25
|
-
"homepage": "https://github.com/
|
|
25
|
+
"homepage": "https://github.com/solidos/solid-logic#readme",
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"@babel/plugin-proposal-class-properties": "~7.16.7",
|
|
28
28
|
"@babel/plugin-proposal-optional-chaining": "~7.16.7",
|
|
@@ -31,9 +31,9 @@
|
|
|
31
31
|
"@babel/preset-env": "~7.16.11",
|
|
32
32
|
"@babel/preset-typescript": "~7.16.7",
|
|
33
33
|
"@types/jest": "^27.4.1",
|
|
34
|
-
"@typescript-eslint/eslint-plugin": "^5.
|
|
35
|
-
"@typescript-eslint/parser": "^5.
|
|
36
|
-
"eslint": "^8.
|
|
34
|
+
"@typescript-eslint/eslint-plugin": "^5.19.0",
|
|
35
|
+
"@typescript-eslint/parser": "^5.19.0",
|
|
36
|
+
"eslint": "^8.13.0",
|
|
37
37
|
"jest": "^27.5.1",
|
|
38
38
|
"jest-fetch-mock": "^3.0.3",
|
|
39
39
|
"typescript": "^4.6.3"
|
|
@@ -4,21 +4,21 @@ import * as debug from '../util/debug'
|
|
|
4
4
|
import { Session } from "@inrupt/solid-client-authn-browser";
|
|
5
5
|
import { AuthenticationContext, AuthnLogic } from "../types";
|
|
6
6
|
export class SolidAuthnLogic implements AuthnLogic {
|
|
7
|
-
private session: Session;
|
|
7
|
+
private session: Session;
|
|
8
8
|
|
|
9
9
|
constructor(solidAuthSession: Session) {
|
|
10
10
|
this.session = solidAuthSession;
|
|
11
11
|
}
|
|
12
|
-
|
|
12
|
+
|
|
13
13
|
// we created authSession getter because we want to access it as authn.authSession externally
|
|
14
|
-
get authSession():Session { return this.session }
|
|
14
|
+
get authSession():Session { return this.session }
|
|
15
15
|
|
|
16
16
|
currentUser(): NamedNode | null {
|
|
17
17
|
const app = appContext()
|
|
18
18
|
if (app.viewingNoAuthPage) {
|
|
19
19
|
return sym(app.webId)
|
|
20
20
|
}
|
|
21
|
-
if (this.session.info.webId && this.session.info.isLoggedIn) {
|
|
21
|
+
if (this && this.session && this.session.info && this.session.info.webId && this.session.info.isLoggedIn) {
|
|
22
22
|
return sym(this.session.info.webId)
|
|
23
23
|
}
|
|
24
24
|
return offlineTestID() // null unless testing
|
|
@@ -120,4 +120,4 @@ export class SolidAuthnLogic implements AuthnLogic {
|
|
|
120
120
|
return webId
|
|
121
121
|
}
|
|
122
122
|
|
|
123
|
-
}
|
|
123
|
+
}
|
package/src/authn/authUtil.ts
CHANGED
|
@@ -50,7 +50,7 @@ export function offlineTestID (): NamedNode | null {
|
|
|
50
50
|
return sym($SolidTestEnvironment.username)
|
|
51
51
|
}
|
|
52
52
|
// hack that makes SolidOS work in offline mode by adding the webId directly in html
|
|
53
|
-
// example usage: https://github.com/
|
|
53
|
+
// example usage: https://github.com/solidos/mashlib/blob/29b8b53c46bf02e0e219f0bacd51b0e9951001dd/test/contact/local.html#L37
|
|
54
54
|
if (
|
|
55
55
|
typeof document !== 'undefined' &&
|
|
56
56
|
document.location &&
|
|
@@ -1,33 +1,144 @@
|
|
|
1
|
-
import { NamedNode, Namespace, LiveStore } from "rdflib";
|
|
1
|
+
import { NamedNode, Namespace, LiveStore, sym, st } from "rdflib";
|
|
2
|
+
// import * as debug from '../util/debug'
|
|
3
|
+
// import { getContainerMembers } from '../util/UtilityLogic'
|
|
4
|
+
import { solidLogicSingleton } from "../logic/solidLogicSingleton"
|
|
5
|
+
import { newThing } from "../util/uri"
|
|
2
6
|
|
|
3
|
-
|
|
7
|
+
const { authn } = solidLogicSingleton
|
|
8
|
+
const { currentUser } = authn
|
|
9
|
+
|
|
10
|
+
type TypeIndexScope = { label: string, index: NamedNode, agent: NamedNode } ;
|
|
11
|
+
type ScopedApp = { instance: NamedNode, scope: TypeIndexScope }
|
|
12
|
+
|
|
13
|
+
const ns = {
|
|
14
|
+
dct: Namespace('http://purl.org/dc/terms/'),
|
|
15
|
+
ldp: Namespace('http://www.w3.org/ns/ldp#'),
|
|
16
|
+
meeting: Namespace('http://www.w3.org/ns/pim/meeting#'),
|
|
17
|
+
rdf: Namespace('http://www.w3.org/1999/02/22-rdf-syntax-ns#'),
|
|
18
|
+
schema: Namespace('http://schema.org/'),
|
|
19
|
+
solid: Namespace('http://www.w3.org/ns/solid/terms#'),
|
|
20
|
+
space: Namespace('http://www.w3.org/ns/pim/space#'),
|
|
21
|
+
stat: Namespace('http://www.w3.org/ns/posix/stat#'),
|
|
22
|
+
vcard: Namespace('http://www.w3.org/2006/vcard/ns#'),
|
|
23
|
+
wf: Namespace('http://www.w3.org/2005/01/wf/flow#'),
|
|
24
|
+
xsd: Namespace('http://www.w3.org/2001/XMLSchema#')
|
|
4
25
|
|
|
5
|
-
const ns ={
|
|
6
|
-
solid: Namespace('http://www.w3.org/ns/solid/terms#'),
|
|
7
|
-
space: Namespace('http://www.w3.org/ns/pim/space#')
|
|
8
26
|
}
|
|
9
27
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
28
|
+
/** Create a resource if it really does not exist
|
|
29
|
+
* Be absolutely sure something does not exist before creating a new empty file
|
|
30
|
+
* as otherwise existing could be deleted.
|
|
31
|
+
* @param doc {NamedNode} - The resource
|
|
32
|
+
*/
|
|
33
|
+
export async function loadOrCreateIfNotExists (store: LiveStore, doc: NamedNode) {
|
|
34
|
+
let response
|
|
35
|
+
// console.log('@@ loadOrCreateIfNotExists doc ', doc)
|
|
36
|
+
try {
|
|
37
|
+
response = await store.fetcher.load(doc)
|
|
38
|
+
} catch (err) {
|
|
39
|
+
if (err.response.status === 404) {
|
|
40
|
+
// console.log('createIfNotExists doc does NOT exist, will create: ' + doc)
|
|
41
|
+
try {
|
|
42
|
+
store.fetcher.webOperation('PUT', doc, {data: '', contentType: 'text/turtle'})
|
|
43
|
+
} catch (err) {
|
|
44
|
+
const msg = 'createIfNotExists: PUT FAILED: ' + doc + ': ' + err
|
|
45
|
+
// console.log(msg)
|
|
46
|
+
throw new Error(msg)
|
|
47
|
+
}
|
|
48
|
+
delete store.fetcher.requested[doc.uri] // delete cached 404 error
|
|
49
|
+
// console.log('createIfNotExists doc created ok ' + doc)
|
|
50
|
+
} else {
|
|
51
|
+
const msg = 'createIfNotExists doc load error NOT 404: ' + doc + ': ' + err
|
|
52
|
+
// console.log(msg)
|
|
53
|
+
throw new Error(msg) // @@ add nested errors
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
// console.log('createIfNotExists doc exists, all good ' + doc)
|
|
57
|
+
return response
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export function suggestPreferencesFile (me:NamedNode) {
|
|
61
|
+
const stripped = me.uri.replace('/profile/', '/').replace('/public/', '/')
|
|
62
|
+
// const stripped = me.uri.replace(\/[p|P]rofile/\g, '/').replace(\/[p|P]ublic/\g, '/')
|
|
63
|
+
const folderURI = stripped.split('/').slice(0,-1).join('/') + '/Settings/'
|
|
64
|
+
const fileURI = folderURI + 'Preferences.ttl'
|
|
65
|
+
return sym(fileURI)
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export function suggestPublicTypeIndex (me:NamedNode) {
|
|
69
|
+
return sym(me.doc().dir()?.uri + 'publicTypeIndex.ttl')
|
|
70
|
+
}
|
|
71
|
+
// Note this one is based off the pref file not the profile
|
|
72
|
+
|
|
73
|
+
export function suggestPrivateTypeIndex (preferencesFile:NamedNode) {
|
|
74
|
+
return sym(preferencesFile.doc().dir()?.uri + 'privateTypeIndex.ttl')
|
|
75
|
+
}
|
|
76
|
+
/* Follow link from this doc to another thing, or else make a new link
|
|
77
|
+
**
|
|
78
|
+
** return: null no ld one and failed to make a new one
|
|
79
|
+
*/
|
|
80
|
+
export async function followOrCreateLink(store: LiveStore, subject: NamedNode, predicate: NamedNode,
|
|
81
|
+
object: NamedNode, doc:NamedNode):Promise<NamedNode | null> {
|
|
82
|
+
await store.fetcher.load(doc)
|
|
83
|
+
const result = store.any(subject, predicate, null, doc)
|
|
84
|
+
// console.log('@@ followOrCreateLink result ', result)
|
|
85
|
+
|
|
86
|
+
if (result) return result as NamedNode
|
|
87
|
+
if (!store.updater.editable(doc)) {
|
|
88
|
+
// console.log(`followOrCreateLink: Can't modify ${doc} so can't make new link to ${object}.`)
|
|
89
|
+
// console.log('followOrCreateLink @@ connectedStatements', store.connectedStatements(subject))
|
|
90
|
+
return null
|
|
13
91
|
}
|
|
14
92
|
try {
|
|
15
|
-
await store.
|
|
93
|
+
await store.updater.update([], [ st(subject, predicate, object, doc)])
|
|
16
94
|
} catch (err) {
|
|
17
|
-
|
|
95
|
+
console.warn(`followOrCreateLink: Error making link in ${doc} to ${object}: ${err}`)
|
|
96
|
+
return null
|
|
18
97
|
}
|
|
98
|
+
|
|
99
|
+
// console.log(`Success making link in ${doc} to ${object}` )
|
|
100
|
+
|
|
101
|
+
try {
|
|
102
|
+
await loadOrCreateIfNotExists(store, object)
|
|
103
|
+
// store.fetcher.webOperation('PUT', object, { data: '', contentType: 'text/turtle'})
|
|
104
|
+
} catch (err) {
|
|
105
|
+
console.warn(`followOrCreateLink: Error loading or saving new linked document: ${object}: ${err}`)
|
|
106
|
+
}
|
|
107
|
+
// console.log(`followOrCreateLink: Success loading or saving new linked document: ${object}.`)
|
|
108
|
+
return object
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
export async function loadProfile(store: LiveStore, user: NamedNode) {
|
|
112
|
+
// console.log(' @@ loadProfile: user', user)
|
|
113
|
+
if (!user) {
|
|
114
|
+
throw new Error(`loadProfile: no user given.`)
|
|
115
|
+
}
|
|
116
|
+
// try {
|
|
117
|
+
await store.fetcher.load(user.doc())
|
|
118
|
+
// } catch (err) {
|
|
119
|
+
// throw new Error(`Unable to load profile of user ${user}: ${err}`)
|
|
120
|
+
//}
|
|
19
121
|
return user.doc()
|
|
20
122
|
}
|
|
21
123
|
|
|
22
|
-
export async function loadPreferences(store: LiveStore, user): Promise <NamedNode | undefined > {
|
|
23
|
-
|
|
24
|
-
|
|
124
|
+
export async function loadPreferences(store: LiveStore, user: NamedNode): Promise <NamedNode | undefined > {
|
|
125
|
+
// console.log('loadPreferences @@ user', user)
|
|
126
|
+
await loadProfile(store as LiveStore, user)
|
|
127
|
+
|
|
128
|
+
const possiblePreferencesFile = suggestPreferencesFile(user)
|
|
129
|
+
|
|
130
|
+
const preferencesFile = await followOrCreateLink(store, user, ns.space('preferencesFile') as NamedNode, possiblePreferencesFile, user.doc())
|
|
131
|
+
// const preferencesFile = store.any(user, ns.space('preferencesFile'), undefined, profile)
|
|
132
|
+
|
|
133
|
+
// console.log('loadPreferences @@ pref file', preferencesFile)
|
|
25
134
|
if (!preferencesFile) {
|
|
26
|
-
|
|
135
|
+
const message = `User ${user} has no pointer in profile to preferences file.`
|
|
136
|
+
console.warn(message)
|
|
137
|
+
// throw new Error()
|
|
27
138
|
return undefined
|
|
28
139
|
}
|
|
29
140
|
try {
|
|
30
|
-
store.fetcher.load(preferencesFile as NamedNode)
|
|
141
|
+
await store.fetcher.load(preferencesFile as NamedNode)
|
|
31
142
|
} catch (err) { // Mabeb a permission propblem or origin problem
|
|
32
143
|
return undefined
|
|
33
144
|
// throw new Error(`Unable to load preferences file ${preferencesFile} of user <${user}>: ${err}`)
|
|
@@ -35,56 +146,166 @@ export async function loadPreferences(store: LiveStore, user): Promise <NamedNod
|
|
|
35
146
|
return preferencesFile as NamedNode
|
|
36
147
|
}
|
|
37
148
|
|
|
38
|
-
export async function loadTypeIndexesFor(store: LiveStore, user:NamedNode): Promise<Array<
|
|
149
|
+
export async function loadTypeIndexesFor(store: LiveStore, user:NamedNode): Promise<Array<TypeIndexScope>> {
|
|
150
|
+
// console.log('@@ loadTypeIndexesFor user', user)
|
|
39
151
|
if (!user) throw new Error(`loadTypeIndexesFor: No user given`)
|
|
40
152
|
const profile = await loadProfile(store, user)
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
153
|
+
|
|
154
|
+
const suggestion = suggestPublicTypeIndex(user)
|
|
155
|
+
|
|
156
|
+
const publicTypeIndex = await followOrCreateLink(store, user, ns.solid('publicTypeIndex') as NamedNode, suggestion, profile)
|
|
157
|
+
|
|
158
|
+
// const publicTypeIndex = store.any(user, ns.solid('publicTypeIndex'), undefined, profile)
|
|
159
|
+
// console.log('@@ loadTypeIndexesFor publicTypeIndex', publicTypeIndex)
|
|
160
|
+
|
|
161
|
+
const publicScopes = publicTypeIndex ? [ { label: 'public', index: publicTypeIndex as NamedNode, agent: user } ] : []
|
|
162
|
+
|
|
163
|
+
let preferencesFile
|
|
164
|
+
try {
|
|
165
|
+
preferencesFile = await loadPreferences(store, user)
|
|
166
|
+
} catch (err) {
|
|
167
|
+
preferencesFile = null
|
|
48
168
|
}
|
|
49
|
-
const pub = publicTypeIndex ? [ { label: 'public', index: publicTypeIndex as NamedNode, agent: user } ] : []
|
|
50
169
|
|
|
51
|
-
|
|
52
|
-
if (preferencesFile) { // watch out - can be in either as spec was not clear
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
const
|
|
56
|
-
|
|
170
|
+
let privateScopes
|
|
171
|
+
if (preferencesFile) { // watch out - can be in either as spec was not clear. Legacy is profile.
|
|
172
|
+
// If there is a legacy one linked from the profile, use that.
|
|
173
|
+
// Otherwiae use or make one linked from Preferences
|
|
174
|
+
const suggestedPrivateTypeIndex = suggestPrivateTypeIndex(preferencesFile)
|
|
175
|
+
|
|
176
|
+
const privateTypeIndex = store.any(user, ns.solid('privateTypeIndex'), undefined, profile) ||
|
|
177
|
+
|
|
178
|
+
await followOrCreateLink(store, user, ns.solid('privateTypeIndex') as NamedNode, suggestedPrivateTypeIndex, preferencesFile);
|
|
179
|
+
|
|
180
|
+
privateScopes = privateTypeIndex ? [ { label: 'private', index: privateTypeIndex as NamedNode, agent: user } ] : []
|
|
181
|
+
} else {
|
|
182
|
+
privateScopes = []
|
|
183
|
+
}
|
|
184
|
+
const scopes = publicScopes.concat(privateScopes)
|
|
185
|
+
if (scopes.length === 0) return scopes
|
|
186
|
+
const files = scopes.map(scope => scope.index)
|
|
187
|
+
// console.log('@@ loadTypeIndexesFor files ', files)
|
|
188
|
+
try {
|
|
189
|
+
await store.fetcher.load(files)
|
|
190
|
+
} catch (err) {
|
|
191
|
+
console.warn('Problems loading type index: ', err)
|
|
57
192
|
}
|
|
58
|
-
return
|
|
193
|
+
return scopes
|
|
59
194
|
}
|
|
60
195
|
|
|
61
|
-
export async function loadCommunityTypeIndexes (store:LiveStore, user:NamedNode): Promise<
|
|
196
|
+
export async function loadCommunityTypeIndexes (store:LiveStore, user:NamedNode): Promise<TypeIndexScope[][]> {
|
|
62
197
|
const preferencesFile = await loadPreferences(store, user)
|
|
63
|
-
if (preferencesFile) {
|
|
198
|
+
if (preferencesFile) { // For now, pick up communities as simple links from the preferences file.
|
|
64
199
|
const communities = store.each(user, ns.solid('community'), undefined, preferencesFile as NamedNode)
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
return result1
|
|
70
|
-
// const communityTypeIndexes = await Promise.all(communityTypeIndexesPromise)
|
|
71
|
-
/*
|
|
72
|
-
let result = [] as TypeIndex[]
|
|
73
|
-
for(const community of communities) {
|
|
74
|
-
result = result.concat(await loadTypeIndexesFor(store, community as NamedNode)) as TypeIndex[] // @@ how oto make functional with async?
|
|
200
|
+
// console.log('loadCommunityTypeIndexes communities: ',communities)
|
|
201
|
+
let result = []
|
|
202
|
+
for (const org of communities) {
|
|
203
|
+
result = result.concat(await loadTypeIndexesFor(store, org as NamedNode) as any)
|
|
75
204
|
}
|
|
76
|
-
|
|
77
|
-
//
|
|
205
|
+
// const communityTypeIndexesPromises = communities.map(async community => await loadTypeIndexesFor(store, community as NamedNode))
|
|
206
|
+
// const result1 = Promise.all(communityTypeIndexesPromises)
|
|
207
|
+
return result
|
|
78
208
|
}
|
|
79
|
-
return []
|
|
209
|
+
return [] // No communities
|
|
80
210
|
}
|
|
81
211
|
|
|
82
212
|
export async function loadAllTypeIndexes (store:LiveStore, user:NamedNode) {
|
|
83
213
|
return (await loadTypeIndexesFor(store, user)).concat((await loadCommunityTypeIndexes(store, user)).flat())
|
|
84
214
|
}
|
|
85
215
|
|
|
216
|
+
// Utility: remove duplicates from Array of NamedNodes
|
|
217
|
+
|
|
218
|
+
export function uniqueNodes (arr: NamedNode[]): NamedNode[] {
|
|
219
|
+
const uris = arr.map(x => x.uri)
|
|
220
|
+
const set = new Set(uris)
|
|
221
|
+
const uris2 = Array.from(set)
|
|
222
|
+
const arr2 = uris2.map(u => new NamedNode(u))
|
|
223
|
+
return arr2 // Array.from(new Set(arr.map(x => x.uri))).map(u => sym(u))
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
export async function getScopedAppsfromIndex (store, scope, theClass: NamedNode) {
|
|
227
|
+
// console.log(`getScopedAppsfromIndex agent ${scope.agent} index: ${scope.index}` )
|
|
228
|
+
const index = scope.index
|
|
229
|
+
const registrations = store.each(undefined, ns.solid('forClass'), theClass, index)
|
|
230
|
+
// console.log(' registrations', registrations )
|
|
231
|
+
|
|
232
|
+
const directInstances = registrations.map(reg => store.each(reg as NamedNode, ns.solid('instance'), null, index)).flat()
|
|
233
|
+
// console.log(' directInstances', directInstances )
|
|
234
|
+
let instances = uniqueNodes(directInstances)
|
|
235
|
+
|
|
86
236
|
/*
|
|
87
|
-
|
|
237
|
+
let instanceContainers = []
|
|
238
|
+
for (const reg of registrations) {
|
|
239
|
+
const cont = store.any(reg as NamedNode, ns.solid('instanceContainer'), null, index)
|
|
240
|
+
if (cont) {
|
|
241
|
+
// console.log(' @@ getScopedAppsfromIndex got one: ', cont)
|
|
242
|
+
instanceContainers.push(cont)
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
*/
|
|
246
|
+
const instanceContainers = registrations.map(
|
|
247
|
+
reg => store.each(reg as NamedNode, ns.solid('instanceContainer'), null, index)).flat()
|
|
248
|
+
|
|
249
|
+
// instanceContainers may be deprocatable if no one has used them
|
|
88
250
|
|
|
251
|
+
const containers = uniqueNodes(instanceContainers)
|
|
252
|
+
for (let i = 0; i < containers.length; i++) {
|
|
253
|
+
const cont = containers[i]
|
|
254
|
+
await store.fetcher.load(cont)
|
|
255
|
+
const contents = store.each(cont, ns.ldp('contains'), null, cont)
|
|
256
|
+
// if (contents.length) console.log('getScopedAppsfromIndex @@ instanceContainer contents:', contents)
|
|
257
|
+
instances = instances.concat(contents)
|
|
258
|
+
}
|
|
259
|
+
return instances.map(instance => { return {instance, scope}})
|
|
89
260
|
}
|
|
90
|
-
|
|
261
|
+
|
|
262
|
+
|
|
263
|
+
export async function getScopedAppInstances (store:LiveStore, klass: NamedNode, user: NamedNode):Promise<ScopedApp[]> {
|
|
264
|
+
// console.log('getScopedAppInstances @@ ' + user)
|
|
265
|
+
const scopes = await loadAllTypeIndexes(store, user)
|
|
266
|
+
let scopedApps = []
|
|
267
|
+
for (const scope of scopes) {
|
|
268
|
+
const scopedApps0 = await getScopedAppsfromIndex(store, scope, klass) as any
|
|
269
|
+
scopedApps = scopedApps.concat(scopedApps0)
|
|
270
|
+
}
|
|
271
|
+
return scopedApps
|
|
272
|
+
}
|
|
273
|
+
// This is the function signature which used to be in solid-ui/logic
|
|
274
|
+
// Recommended to use getScopedAppInstances instead as it provides more information.
|
|
275
|
+
//
|
|
276
|
+
export async function getAppInstances (store:LiveStore, klass: NamedNode): Promise<NamedNode[]> {
|
|
277
|
+
const user = currentUser()
|
|
278
|
+
if (!user) throw new Error('getAppInstances: Must be logged in to find apps.')
|
|
279
|
+
const scopedAppInstances = await getScopedAppInstances(store, klass, user)
|
|
280
|
+
return scopedAppInstances.map(scoped => scoped.instance)
|
|
281
|
+
}
|
|
282
|
+
/**
|
|
283
|
+
* Register a new app in a type index
|
|
284
|
+
* used in chat in bookmark.js (solid-ui)
|
|
285
|
+
* Returns the registration object if successful else null
|
|
286
|
+
*/
|
|
287
|
+
export async function registerInstanceInTypeIndex (
|
|
288
|
+
store:LiveStore,
|
|
289
|
+
instance: NamedNode,
|
|
290
|
+
index: NamedNode,
|
|
291
|
+
theClass: NamedNode,
|
|
292
|
+
// agent: NamedNode
|
|
293
|
+
): Promise<NamedNode | null> {
|
|
294
|
+
const registration = newThing(index)
|
|
295
|
+
const ins = [
|
|
296
|
+
// See https://github.com/solid/solid/blob/main/proposals/data-discovery.md
|
|
297
|
+
st(registration, ns.rdf('type'), ns.solid('TypeRegistration'), index),
|
|
298
|
+
st(registration, ns.solid('forClass'), theClass, index),
|
|
299
|
+
st(registration, ns.solid('instance'), instance, index)
|
|
300
|
+
]
|
|
301
|
+
try {
|
|
302
|
+
console.log('patching index', ins)
|
|
303
|
+
await store.updater.update([], ins)
|
|
304
|
+
} catch (err) {
|
|
305
|
+
const msg = `Unable to register ${instance} in index ${index}: ${err}`
|
|
306
|
+
console.warn(msg)
|
|
307
|
+
return null
|
|
308
|
+
}
|
|
309
|
+
return registration
|
|
310
|
+
}
|
|
311
|
+
// ENDS
|
|
@@ -4,7 +4,7 @@ import { SolidLogic } from "./SolidLogic"
|
|
|
4
4
|
|
|
5
5
|
const _fetch = async (url, requestInit) => {
|
|
6
6
|
const omitCreds = requestInit && requestInit.credentials && requestInit.credentials == 'omit'
|
|
7
|
-
if (authSession.info.webId && !omitCreds) { // see https://github.com/
|
|
7
|
+
if (authSession.info.webId && !omitCreds) { // see https://github.com/solidos/solidos/issues/114
|
|
8
8
|
// In fact ftech should respect crentials omit itself
|
|
9
9
|
return authSession.fetch(url, requestInit)
|
|
10
10
|
} else {
|
|
@@ -22,7 +22,7 @@ async function ensureLoadedPreferences (context:AuthenticationContext) {
|
|
|
22
22
|
* Resolves with the same context, outputting
|
|
23
23
|
* output: index.public, index.private
|
|
24
24
|
* @@ This is a very bizare function
|
|
25
|
-
* @see https://github.com/
|
|
25
|
+
* @see https://github.com/solidos/solid/blob/main/proposals/data-discovery.md#discoverability
|
|
26
26
|
*/
|
|
27
27
|
export async function loadIndex (
|
|
28
28
|
context: AuthenticationContext,
|
|
@@ -43,7 +43,7 @@ return context
|
|
|
43
43
|
|
|
44
44
|
export async function loadTypeIndexes (context: AuthenticationContext) {
|
|
45
45
|
try {
|
|
46
|
-
await loadPreferences(solidLogicSingleton.store, context.me)
|
|
46
|
+
await loadPreferences(solidLogicSingleton.store, context.me as NamedNode)
|
|
47
47
|
} catch (error) {
|
|
48
48
|
debug.warn(error.message) as undefined
|
|
49
49
|
}
|
|
@@ -66,7 +66,7 @@ export async function loadTypeIndexes (context: AuthenticationContext) {
|
|
|
66
66
|
|
|
67
67
|
/**
|
|
68
68
|
* Resolves with the same context, outputting
|
|
69
|
-
* @see https://github.com/
|
|
69
|
+
* @see https://github.com/solidos/solid/blob/main/proposals/data-discovery.md#discoverability
|
|
70
70
|
*/
|
|
71
71
|
export async function ensureTypeIndexes (context: AuthenticationContext, agent?: NamedNode): Promise<AuthenticationContext> {
|
|
72
72
|
if (!context.me) {
|
|
@@ -83,7 +83,7 @@ return context
|
|
|
83
83
|
* Many reasons for failing including script not having permission etc
|
|
84
84
|
*
|
|
85
85
|
* Adds its output to the context
|
|
86
|
-
* @see https://github.com/
|
|
86
|
+
* @see https://github.com/solidos/solid/blob/main/proposals/data-discovery.md#discoverability
|
|
87
87
|
*/
|
|
88
88
|
async function ensureOneTypeIndex (context: AuthenticationContext, isPublic: boolean, agent?: NamedNode): Promise<AuthenticationContext | void> {
|
|
89
89
|
async function makeIndexIfNecessary (context, isPublic) {
|
|
@@ -186,7 +186,7 @@ agent?: NamedNode // Defaults to current user
|
|
|
186
186
|
const index = indexes[0]
|
|
187
187
|
const registration = newThing(index)
|
|
188
188
|
const ins = [
|
|
189
|
-
// See https://github.com/
|
|
189
|
+
// See https://github.com/solidos/solid/blob/main/proposals/data-discovery.md
|
|
190
190
|
st(registration, ns.rdf('type'), ns.solid('TypeRegistration'), index),
|
|
191
191
|
st(registration, ns.solid('forClass'), theClass, index),
|
|
192
192
|
st(registration, ns.solid('instance'), instance, index)
|
package/src/util/UtilityLogic.ts
CHANGED
|
@@ -29,7 +29,7 @@ export class UtilityLogic {
|
|
|
29
29
|
return docNode.value;
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
// Copied from https://github.com/
|
|
32
|
+
// Copied from https://github.com/solidos/web-access-control-tests/blob/v3.0.0/test/surface/delete.test.ts#L5
|
|
33
33
|
async setSinglePeerAccess(options: {
|
|
34
34
|
ownerWebId: string,
|
|
35
35
|
peerWebId: string,
|
|
@@ -97,13 +97,13 @@ export class UtilityLogic {
|
|
|
97
97
|
if (!this.isContainer(url)) {
|
|
98
98
|
throw new Error(`Not a container URL ${url}`);
|
|
99
99
|
}
|
|
100
|
-
// Copied from https://github.com/
|
|
100
|
+
// Copied from https://github.com/solidos/solid-crud-tests/blob/v3.1.0/test/surface/create-container.test.ts#L56-L64
|
|
101
101
|
const result = await this.underlyingFetch.fetch(url, {
|
|
102
102
|
method: "PUT",
|
|
103
103
|
headers: {
|
|
104
104
|
"Content-Type": "text/turtle",
|
|
105
105
|
"If-None-Match": "*",
|
|
106
|
-
Link: '<http://www.w3.org/ns/ldp#BasicContainer>; rel="type"', // See https://github.com/
|
|
106
|
+
Link: '<http://www.w3.org/ns/ldp#BasicContainer>; rel="type"', // See https://github.com/solidos/node-solid-server/issues/1465
|
|
107
107
|
},
|
|
108
108
|
body: " ", // work around https://github.com/michielbdejong/community-server/issues/4#issuecomment-776222863
|
|
109
109
|
});
|