solid-logic 3.0.9-d0d78d33 → 3.0.9-ea192f01
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/babel.config.js +6 -0
- package/eslint.config.js +23 -24
- package/jest.config.js +15 -8
- package/lib/acl/aclLogic.d.ts +2 -2
- package/lib/acl/aclLogic.d.ts.map +1 -1
- package/lib/authn/SolidAuthnLogic.d.ts +3 -3
- package/lib/authn/SolidAuthnLogic.d.ts.map +1 -1
- package/lib/authn/authUtil.d.ts +1 -1
- package/lib/chat/chatLogic.d.ts +1 -1
- package/lib/inbox/inboxLogic.d.ts +1 -1
- package/lib/inbox/inboxLogic.d.ts.map +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/logic/CustomError.d.ts.map +1 -1
- package/lib/logic/solidLogic.d.ts +2 -2
- package/lib/logic/solidLogic.d.ts.map +1 -1
- package/lib/profile/profileLogic.d.ts +1 -1
- package/lib/solid-logic.js +107 -0
- package/lib/solid-logic.js.map +1 -0
- package/lib/types.d.ts +2 -2
- package/lib/util/containerLogic.d.ts +1 -1
- package/lib/util/containerLogic.d.ts.map +1 -1
- package/lib/util/debug.d.ts.map +1 -1
- package/lib/util/utilityLogic.d.ts +1 -1
- package/lib/util/utilityLogic.d.ts.map +1 -1
- package/lib/util/utils.d.ts +1 -1
- package/lib/util/utils.d.ts.map +1 -1
- package/package.json +38 -15
- package/rollup.config.js +29 -0
- package/src/acl/aclLogic.ts +8 -8
- package/src/authn/SolidAuthnLogic.ts +6 -6
- package/src/authn/authUtil.ts +1 -1
- package/src/chat/chatLogic.ts +75 -75
- package/src/inbox/inboxLogic.ts +19 -19
- package/src/index.ts +1 -1
- package/src/logic/CustomError.ts +6 -6
- package/src/logic/solidLogic.ts +22 -22
- package/src/logic/solidLogicSingleton.ts +3 -3
- package/src/profile/profileLogic.ts +22 -22
- package/src/typeIndex/typeIndexLogic.ts +7 -7
- package/src/types.ts +2 -2
- package/src/util/containerLogic.ts +15 -15
- package/src/util/debug.ts +4 -8
- package/src/util/utilityLogic.ts +18 -18
- package/src/util/utils.ts +12 -12
- package/src/versionInfo.ts +32 -0
- package/test/aclLogic.test.ts +5 -5
- package/test/authUtil.test.ts +1 -1
- package/test/chatLogic.test.ts +160 -154
- package/test/container.test.ts +23 -23
- package/test/helpers/dataSetup.ts +2 -1
- package/test/helpers/setup.ts +8 -3
- package/test/inboxLogic.test.ts +101 -110
- package/test/logic.test.ts +2 -2
- package/test/profileLogic.test.ts +35 -33
- package/test/solidAuthLogic.test.ts +1 -1
- package/test/typeIndexLogic.test.ts +71 -71
- package/test/utilityLogic.test.ts +46 -45
- package/test/utils.test.ts +11 -11
- package/timestamp.sh +13 -0
- package/tsconfig.json +5 -3
- package/tsconfig.test.json +8 -0
- package/lib/acl/aclLogic.js +0 -168
- package/lib/acl/aclLogic.js.map +0 -1
- package/lib/authSession/authSession.js +0 -8
- package/lib/authSession/authSession.js.map +0 -1
- package/lib/authn/SolidAuthnLogic.js +0 -191
- package/lib/authn/SolidAuthnLogic.js.map +0 -1
- package/lib/authn/authUtil.js +0 -105
- package/lib/authn/authUtil.js.map +0 -1
- package/lib/chat/chatLogic.js +0 -272
- package/lib/chat/chatLogic.js.map +0 -1
- package/lib/inbox/inboxLogic.js +0 -139
- package/lib/inbox/inboxLogic.js.map +0 -1
- package/lib/index.js +0 -29
- package/lib/index.js.map +0 -1
- package/lib/issuer/issuerLogic.js +0 -52
- package/lib/issuer/issuerLogic.js.map +0 -1
- package/lib/logic/CustomError.js +0 -89
- package/lib/logic/CustomError.js.map +0 -1
- package/lib/logic/solidLogic.js +0 -102
- package/lib/logic/solidLogic.js.map +0 -1
- package/lib/logic/solidLogicSingleton.js +0 -94
- package/lib/logic/solidLogicSingleton.js.map +0 -1
- package/lib/profile/profileLogic.js +0 -259
- package/lib/profile/profileLogic.js.map +0 -1
- package/lib/typeIndex/typeIndexLogic.js +0 -399
- package/lib/typeIndex/typeIndexLogic.js.map +0 -1
- package/lib/types.js +0 -3
- package/lib/types.js.map +0 -1
- package/lib/util/containerLogic.js +0 -102
- package/lib/util/containerLogic.js.map +0 -1
- package/lib/util/debug.js +0 -40
- package/lib/util/debug.js.map +0 -1
- package/lib/util/ns.js +0 -44
- package/lib/util/ns.js.map +0 -1
- package/lib/util/utilityLogic.js +0 -284
- package/lib/util/utilityLogic.js.map +0 -1
- package/lib/util/utils.js +0 -47
- package/lib/util/utils.js.map +0 -1
package/lib/types.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Session } from
|
|
2
|
-
import { LiveStore, NamedNode, Statement } from
|
|
1
|
+
import { Session } from '@inrupt/solid-client-authn-browser';
|
|
2
|
+
import { LiveStore, NamedNode, Statement } from 'rdflib';
|
|
3
3
|
export type AppDetails = {
|
|
4
4
|
noun: string;
|
|
5
5
|
appPathSegment: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"containerLogic.d.ts","sourceRoot":"","sources":["../../src/util/containerLogic.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAkB,MAAM,QAAQ,
|
|
1
|
+
{"version":3,"file":"containerLogic.d.ts","sourceRoot":"","sources":["../../src/util/containerLogic.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAkB,MAAM,QAAQ,CAAA;AAElD;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,KAAA;uBAYZ,SAAS;2BAKC,MAAM;0CAfG,SAAS,KAAG,SAAS,EAAE;wCAmCnB,SAAS,KAAG,OAAO,CAAC,SAAS,EAAE,CAAC;EAUpF"}
|
package/lib/util/debug.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"debug.d.ts","sourceRoot":"","sources":["../../src/util/debug.ts"],"names":[],"mappings":"AACA,wBAAgB,GAAG,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI,
|
|
1
|
+
{"version":3,"file":"debug.d.ts","sourceRoot":"","sources":["../../src/util/debug.ts"],"names":[],"mappings":"AACA,wBAAgB,GAAG,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI,CAExC;AAED,wBAAgB,IAAI,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI,CAEzC;AAED,wBAAgB,KAAK,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI,CAE1C;AAED,wBAAgB,KAAK,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI,CAE1C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utilityLogic.d.ts","sourceRoot":"","sources":["../../src/util/utilityLogic.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAW,MAAM,QAAQ,
|
|
1
|
+
{"version":3,"file":"utilityLogic.d.ts","sourceRoot":"","sources":["../../src/util/utilityLogic.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAW,MAAM,QAAQ,CAAA;AAK3C,wBAAgB,kBAAkB,CAAC,KAAK,KAAA,EAAE,QAAQ,KAAA,EAAE,cAAc,KAAA;qCAElB,SAAS;mCAwFX;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;6BAsCqC,SAAS,WAAW,MAAM;kCA3ErB,SAAS,aAAa,SAAS,UAChE,SAAS,OAAO,SAAS,KAChC,OAAO,CAAC,SAAS,GAAG,IAAI,CAAC;mCApCgB,SAAS;EA4HtD"}
|
package/lib/util/utils.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { NamedNode } from
|
|
1
|
+
import { NamedNode } from 'rdflib';
|
|
2
2
|
export declare function newThing(doc: NamedNode): NamedNode;
|
|
3
3
|
export declare function uniqueNodes(arr: NamedNode[]): NamedNode[];
|
|
4
4
|
export declare function getArchiveUrl(baseUrl: string, date: Date): string;
|
package/lib/util/utils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/util/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAO,MAAM,QAAQ,
|
|
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/package.json
CHANGED
|
@@ -1,17 +1,23 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "solid-logic",
|
|
3
|
-
"
|
|
4
|
-
"
|
|
3
|
+
"type": "module",
|
|
4
|
+
"version": "3.0.9-ea192f01",
|
|
5
|
+
"description": "Core business logic of SolidOS",
|
|
5
6
|
"main": "lib/index.js",
|
|
6
7
|
"scripts": {
|
|
7
|
-
"
|
|
8
|
-
"
|
|
9
|
-
"
|
|
10
|
-
"
|
|
8
|
+
"clean": "rm -rf lib src/versionInfo.ts",
|
|
9
|
+
"build": "npm run clean && npm run build-types && npm run build-version && rollup -c",
|
|
10
|
+
"build-version": "./timestamp.sh > src/versionInfo.ts && eslint 'src/versionInfo.ts' --fix",
|
|
11
|
+
"build-types": "tsc --emitDeclarationOnly",
|
|
12
|
+
"lint": "eslint 'src/**/*.ts' 'test/**/*.ts'",
|
|
13
|
+
"typecheck": "tsc --noEmit",
|
|
14
|
+
"typecheck:test": "tsc --noEmit -p tsconfig.test.json",
|
|
15
|
+
"test": "jest --no-coverage",
|
|
16
|
+
"test:coverage": "jest --coverage",
|
|
11
17
|
"test-debug": "node --inspect-brk ./node_modules/.bin/jest -i --env jest-environment-node-debug",
|
|
12
|
-
"preversion": "npm test",
|
|
13
|
-
"postversion": "git push --follow-tags",
|
|
14
18
|
"ignore:prepublishOnly": "npm run build && npm run test",
|
|
19
|
+
"preversion": "npm run lint && npm run typecheck && npm test",
|
|
20
|
+
"postversion": "git push --follow-tags",
|
|
15
21
|
"watch": "tsc --watch"
|
|
16
22
|
},
|
|
17
23
|
"repository": {
|
|
@@ -25,26 +31,43 @@
|
|
|
25
31
|
},
|
|
26
32
|
"homepage": "https://github.com/solidos/solid-logic#readme",
|
|
27
33
|
"devDependencies": {
|
|
28
|
-
"@babel/
|
|
29
|
-
"@babel/
|
|
30
|
-
"@babel/plugin-transform-async-to-generator": "^7.27.1",
|
|
31
|
-
"@babel/plugin-transform-runtime": "^7.28.0",
|
|
32
|
-
"@babel/preset-env": "^7.28.0",
|
|
34
|
+
"@babel/core": "^7.28.3",
|
|
35
|
+
"@babel/preset-env": "^7.28.3",
|
|
33
36
|
"@babel/preset-typescript": "^7.27.1",
|
|
37
|
+
"@rollup/plugin-commonjs": "^28.0.6",
|
|
38
|
+
"@rollup/plugin-json": "^6.1.0",
|
|
39
|
+
"@rollup/plugin-node-resolve": "^16.0.1",
|
|
40
|
+
"@rollup/plugin-typescript": "^12.1.4",
|
|
34
41
|
"@types/jest": "^30.0.0",
|
|
35
42
|
"@typescript-eslint/eslint-plugin": "^8.34.0",
|
|
36
43
|
"@typescript-eslint/parser": "^8.34.0",
|
|
37
44
|
"eslint": "^9.28.0",
|
|
45
|
+
"eslint-config-prettier": "^10.1.8",
|
|
46
|
+
"eslint-plugin-import": "^2.32.0",
|
|
47
|
+
"husky": "^9.1.7",
|
|
38
48
|
"jest": "^30.0.2",
|
|
39
49
|
"jest-environment-jsdom": "^30.0.2",
|
|
40
50
|
"jest-environment-node-debug": "^2.0.0",
|
|
41
51
|
"jest-fetch-mock": "^3.0.3",
|
|
42
|
-
"
|
|
52
|
+
"lint-staged": "^16.1.5",
|
|
53
|
+
"rollup": "^2.79.2",
|
|
54
|
+
"rollup-plugin-terser": "^7.0.2",
|
|
55
|
+
"ts-loader": "^9.5.4",
|
|
56
|
+
"tslib": "^2.8.1",
|
|
57
|
+
"typescript": "^5.9.2"
|
|
43
58
|
},
|
|
44
59
|
"dependencies": {
|
|
45
60
|
"@inrupt/solid-client-authn-browser": "1.17",
|
|
46
|
-
"lint-staged": "^15.4.3",
|
|
47
61
|
"rdflib": "^2.2.37",
|
|
48
62
|
"solid-namespace": "^0.5.4"
|
|
63
|
+
},
|
|
64
|
+
"husky": {
|
|
65
|
+
"hooks": {
|
|
66
|
+
"pre-commit": "lint-staged",
|
|
67
|
+
"pre-push": "npm test"
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
"lint-staged": {
|
|
71
|
+
"*.ts": "eslint --fix"
|
|
49
72
|
}
|
|
50
73
|
}
|
package/rollup.config.js
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import resolve from '@rollup/plugin-node-resolve'
|
|
2
|
+
import commonjs from '@rollup/plugin-commonjs'
|
|
3
|
+
import typescript from '@rollup/plugin-typescript'
|
|
4
|
+
import { terser } from 'rollup-plugin-terser'
|
|
5
|
+
import fs from 'fs'
|
|
6
|
+
import json from '@rollup/plugin-json'
|
|
7
|
+
|
|
8
|
+
const license = fs.readFileSync('./LICENSE', 'utf8')
|
|
9
|
+
|
|
10
|
+
export default {
|
|
11
|
+
input: 'src/index.ts',
|
|
12
|
+
output: {
|
|
13
|
+
file: 'lib/solid-logic.js',
|
|
14
|
+
format: 'esm',
|
|
15
|
+
banner: `/*!\n${license}\n*/`,
|
|
16
|
+
sourcemap: true
|
|
17
|
+
},
|
|
18
|
+
plugins: [
|
|
19
|
+
resolve({ preferBuiltins: true }), // best practice to be true, chooses node.js buildins
|
|
20
|
+
commonjs(),
|
|
21
|
+
typescript({
|
|
22
|
+
declaration: false, // this is false so it does not generate types for the versionInfo file
|
|
23
|
+
declarationMap: false
|
|
24
|
+
}),
|
|
25
|
+
json(),
|
|
26
|
+
terser()
|
|
27
|
+
],
|
|
28
|
+
inlineDynamicImports: true // dissables multiple chunk creation, why we use rollup in the first place
|
|
29
|
+
}
|
package/src/acl/aclLogic.ts
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
import { graph, NamedNode, Namespace, serialize, sym } from
|
|
2
|
-
import { AclLogic } from
|
|
1
|
+
import { graph, NamedNode, Namespace, serialize, sym } from 'rdflib'
|
|
2
|
+
import { AclLogic } from '../types'
|
|
3
3
|
import { ns as namespace } from '../util/ns'
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
export const ACL_LINK = sym(
|
|
7
|
-
|
|
8
|
-
)
|
|
7
|
+
'http://www.iana.org/assignments/link-relations/acl'
|
|
8
|
+
)
|
|
9
9
|
|
|
10
10
|
export function createAclLogic(store): AclLogic {
|
|
11
11
|
|
|
12
12
|
const ns = namespace
|
|
13
13
|
|
|
14
14
|
async function findAclDocUrl(url: NamedNode) {
|
|
15
|
-
await store.fetcher.load(url)
|
|
16
|
-
const docNode = store.any(url, ACL_LINK)
|
|
15
|
+
await store.fetcher.load(url)
|
|
16
|
+
const docNode = store.any(url, ACL_LINK)
|
|
17
17
|
if (!docNode) {
|
|
18
|
-
throw new Error(`No ACL link discovered for ${url}`)
|
|
18
|
+
throw new Error(`No ACL link discovered for ${url}`)
|
|
19
19
|
}
|
|
20
|
-
return docNode.value
|
|
20
|
+
return docNode.value
|
|
21
21
|
}
|
|
22
22
|
/**
|
|
23
23
|
* Simple Access Control
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { namedNode, NamedNode, sym } from
|
|
2
|
-
import { appContext, offlineTestID } from
|
|
1
|
+
import { namedNode, NamedNode, sym } from 'rdflib'
|
|
2
|
+
import { appContext, offlineTestID } from './authUtil'
|
|
3
3
|
import * as debug from '../util/debug'
|
|
4
|
-
import { Session } from
|
|
5
|
-
import { AuthenticationContext, AuthnLogic } from
|
|
4
|
+
import { Session } from '@inrupt/solid-client-authn-browser'
|
|
5
|
+
import { AuthenticationContext, AuthnLogic } from '../types'
|
|
6
6
|
|
|
7
7
|
export class SolidAuthnLogic implements AuthnLogic {
|
|
8
|
-
private session: Session
|
|
8
|
+
private session: Session
|
|
9
9
|
|
|
10
10
|
constructor(solidAuthSession: Session) {
|
|
11
|
-
this.session = solidAuthSession
|
|
11
|
+
this.session = solidAuthSession
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
// we created authSession getter because we want to access it as authn.authSession externally
|
package/src/authn/authUtil.ts
CHANGED
package/src/chat/chatLogic.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { NamedNode, Node, st, term } from
|
|
2
|
-
import { ChatLogic, CreatedPaneOptions, NewPaneOptions, Chat } from
|
|
3
|
-
import { ns as namespace } from
|
|
4
|
-
import { determineChatContainer, newThing } from
|
|
1
|
+
import { NamedNode, Node, st, term } from 'rdflib'
|
|
2
|
+
import { ChatLogic, CreatedPaneOptions, NewPaneOptions, Chat } from '../types'
|
|
3
|
+
import { ns as namespace } from '../util/ns'
|
|
4
|
+
import { determineChatContainer, newThing } from '../util/utils'
|
|
5
5
|
|
|
6
|
-
const CHAT_LOCATION_IN_CONTAINER =
|
|
6
|
+
const CHAT_LOCATION_IN_CONTAINER = 'index.ttl#this'
|
|
7
7
|
|
|
8
8
|
export function createChatLogic(store, profileLogic): ChatLogic {
|
|
9
9
|
const ns = namespace
|
|
@@ -16,15 +16,15 @@ export function createChatLogic(store, profileLogic): ChatLogic {
|
|
|
16
16
|
// Some servers don't present a Link http response header
|
|
17
17
|
// if the container doesn't exist yet, so refetch the container
|
|
18
18
|
// now that it has been created:
|
|
19
|
-
await store.fetcher.load(chatContainer)
|
|
19
|
+
await store.fetcher.load(chatContainer)
|
|
20
20
|
|
|
21
21
|
// FIXME: check the Why value on this quad:
|
|
22
22
|
const chatAclDoc = store.any(
|
|
23
23
|
chatContainer,
|
|
24
|
-
new NamedNode(
|
|
25
|
-
)
|
|
24
|
+
new NamedNode('http://www.iana.org/assignments/link-relations/acl')
|
|
25
|
+
)
|
|
26
26
|
if (!chatAclDoc) {
|
|
27
|
-
throw new Error(
|
|
27
|
+
throw new Error('Chat ACL doc not found!')
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
const aclBody = `
|
|
@@ -43,64 +43,64 @@ export function createChatLogic(store, profileLogic): ChatLogic {
|
|
|
43
43
|
acl:default <.>;
|
|
44
44
|
acl:mode
|
|
45
45
|
acl:Read, acl:Append.
|
|
46
|
-
|
|
47
|
-
await store.fetcher.webOperation(
|
|
46
|
+
`
|
|
47
|
+
await store.fetcher.webOperation('PUT', chatAclDoc.value, {
|
|
48
48
|
data: aclBody,
|
|
49
|
-
contentType:
|
|
50
|
-
})
|
|
49
|
+
contentType: 'text/turtle',
|
|
50
|
+
})
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
async function addToPrivateTypeIndex(chatThing, me) {
|
|
54
54
|
// Add to private type index
|
|
55
55
|
const privateTypeIndex = store.any(
|
|
56
56
|
me,
|
|
57
|
-
ns.solid(
|
|
58
|
-
) as NamedNode | null
|
|
57
|
+
ns.solid('privateTypeIndex')
|
|
58
|
+
) as NamedNode | null
|
|
59
59
|
if (!privateTypeIndex) {
|
|
60
|
-
throw new Error(
|
|
60
|
+
throw new Error('Private type index not found!')
|
|
61
61
|
}
|
|
62
|
-
await store.fetcher.load(privateTypeIndex)
|
|
63
|
-
const reg = newThing(privateTypeIndex)
|
|
62
|
+
await store.fetcher.load(privateTypeIndex)
|
|
63
|
+
const reg = newThing(privateTypeIndex)
|
|
64
64
|
const ins = [
|
|
65
65
|
st(
|
|
66
66
|
reg,
|
|
67
|
-
ns.rdf(
|
|
68
|
-
ns.solid(
|
|
67
|
+
ns.rdf('type'),
|
|
68
|
+
ns.solid('TypeRegistration'),
|
|
69
69
|
privateTypeIndex.doc()
|
|
70
70
|
),
|
|
71
71
|
st(
|
|
72
72
|
reg,
|
|
73
|
-
ns.solid(
|
|
74
|
-
ns.meeting(
|
|
73
|
+
ns.solid('forClass'),
|
|
74
|
+
ns.meeting('LongChat'),
|
|
75
75
|
privateTypeIndex.doc()
|
|
76
76
|
),
|
|
77
|
-
st(reg, ns.solid(
|
|
78
|
-
]
|
|
77
|
+
st(reg, ns.solid('instance'), chatThing, privateTypeIndex.doc()),
|
|
78
|
+
]
|
|
79
79
|
await new Promise((resolve, reject) => {
|
|
80
80
|
store.updater.update([], ins, function (_uri, ok, errm) {
|
|
81
81
|
if (!ok) {
|
|
82
|
-
reject(new Error(errm))
|
|
82
|
+
reject(new Error(errm))
|
|
83
83
|
} else {
|
|
84
|
-
resolve(null)
|
|
84
|
+
resolve(null)
|
|
85
85
|
}
|
|
86
|
-
})
|
|
87
|
-
})
|
|
86
|
+
})
|
|
87
|
+
})
|
|
88
88
|
}
|
|
89
89
|
|
|
90
90
|
async function findChat(invitee: NamedNode): Promise<Chat> {
|
|
91
|
-
const me = await profileLogic.loadMe()
|
|
92
|
-
const podRoot = await profileLogic.getPodRoot(me)
|
|
93
|
-
const chatContainer = determineChatContainer(invitee, podRoot)
|
|
94
|
-
let exists = true
|
|
91
|
+
const me = await profileLogic.loadMe()
|
|
92
|
+
const podRoot = await profileLogic.getPodRoot(me)
|
|
93
|
+
const chatContainer = determineChatContainer(invitee, podRoot)
|
|
94
|
+
let exists = true
|
|
95
95
|
try {
|
|
96
96
|
await store.fetcher.load(
|
|
97
|
-
new NamedNode(chatContainer.value +
|
|
98
|
-
)
|
|
97
|
+
new NamedNode(chatContainer.value + 'index.ttl#this')
|
|
98
|
+
)
|
|
99
99
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
100
100
|
} catch (e) {
|
|
101
|
-
exists = false
|
|
101
|
+
exists = false
|
|
102
102
|
}
|
|
103
|
-
return { me, chatContainer, exists }
|
|
103
|
+
return { me, chatContainer, exists }
|
|
104
104
|
}
|
|
105
105
|
|
|
106
106
|
async function createChatThing(
|
|
@@ -110,60 +110,60 @@ export function createChatLogic(store, profileLogic): ChatLogic {
|
|
|
110
110
|
const created = await mintNew({
|
|
111
111
|
me,
|
|
112
112
|
newBase: chatContainer.value,
|
|
113
|
-
})
|
|
114
|
-
return created.newInstance
|
|
113
|
+
})
|
|
114
|
+
return created.newInstance
|
|
115
115
|
}
|
|
116
116
|
|
|
117
117
|
function mintNew(newPaneOptions: NewPaneOptions): Promise<CreatedPaneOptions> {
|
|
118
|
-
const kb = store
|
|
119
|
-
const updater = kb.updater
|
|
118
|
+
const kb = store
|
|
119
|
+
const updater = kb.updater
|
|
120
120
|
if (newPaneOptions.me && !newPaneOptions.me.uri) {
|
|
121
|
-
throw new Error(
|
|
121
|
+
throw new Error('chat mintNew: Invalid userid ' + newPaneOptions.me)
|
|
122
122
|
}
|
|
123
123
|
|
|
124
124
|
const newInstance = (newPaneOptions.newInstance =
|
|
125
125
|
newPaneOptions.newInstance ||
|
|
126
|
-
kb.sym(newPaneOptions.newBase + CHAT_LOCATION_IN_CONTAINER))
|
|
127
|
-
const newChatDoc = newInstance.doc()
|
|
126
|
+
kb.sym(newPaneOptions.newBase + CHAT_LOCATION_IN_CONTAINER))
|
|
127
|
+
const newChatDoc = newInstance.doc()
|
|
128
128
|
|
|
129
129
|
kb.add(
|
|
130
130
|
newInstance,
|
|
131
|
-
ns.rdf(
|
|
132
|
-
ns.meeting(
|
|
131
|
+
ns.rdf('type'),
|
|
132
|
+
ns.meeting('LongChat'),
|
|
133
133
|
newChatDoc
|
|
134
|
-
)
|
|
135
|
-
kb.add(newInstance, ns.dc(
|
|
134
|
+
)
|
|
135
|
+
kb.add(newInstance, ns.dc('title'), 'Chat channel', newChatDoc)
|
|
136
136
|
kb.add(
|
|
137
137
|
newInstance,
|
|
138
|
-
ns.dc(
|
|
138
|
+
ns.dc('created'),
|
|
139
139
|
term<Node>(new Date(Date.now())),
|
|
140
140
|
newChatDoc
|
|
141
|
-
)
|
|
141
|
+
)
|
|
142
142
|
if (newPaneOptions.me) {
|
|
143
|
-
kb.add(newInstance, ns.dc(
|
|
143
|
+
kb.add(newInstance, ns.dc('author'), newPaneOptions.me, newChatDoc)
|
|
144
144
|
}
|
|
145
145
|
|
|
146
146
|
return new Promise(function (resolve, reject) {
|
|
147
147
|
updater?.put(
|
|
148
148
|
newChatDoc,
|
|
149
149
|
kb.statementsMatching(undefined, undefined, undefined, newChatDoc),
|
|
150
|
-
|
|
150
|
+
'text/turtle',
|
|
151
151
|
function (uri2, ok, message) {
|
|
152
152
|
if (ok) {
|
|
153
153
|
resolve({
|
|
154
154
|
...newPaneOptions,
|
|
155
155
|
newInstance,
|
|
156
|
-
})
|
|
156
|
+
})
|
|
157
157
|
} else {
|
|
158
158
|
reject(
|
|
159
159
|
new Error(
|
|
160
|
-
|
|
160
|
+
'FAILED to save new chat channel at: ' + uri2 + ' : ' + message
|
|
161
161
|
)
|
|
162
|
-
)
|
|
162
|
+
)
|
|
163
163
|
}
|
|
164
164
|
}
|
|
165
|
-
)
|
|
166
|
-
})
|
|
165
|
+
)
|
|
166
|
+
})
|
|
167
167
|
}
|
|
168
168
|
|
|
169
169
|
/**
|
|
@@ -176,48 +176,48 @@ export function createChatLogic(store, profileLogic): ChatLogic {
|
|
|
176
176
|
invitee: NamedNode,
|
|
177
177
|
createIfMissing = true
|
|
178
178
|
): Promise<NamedNode | null> {
|
|
179
|
-
const { me, chatContainer, exists } = await findChat(invitee)
|
|
179
|
+
const { me, chatContainer, exists } = await findChat(invitee)
|
|
180
180
|
if (exists) {
|
|
181
|
-
return new NamedNode(chatContainer.value + CHAT_LOCATION_IN_CONTAINER)
|
|
181
|
+
return new NamedNode(chatContainer.value + CHAT_LOCATION_IN_CONTAINER)
|
|
182
182
|
}
|
|
183
183
|
|
|
184
184
|
if (createIfMissing) {
|
|
185
|
-
const chatThing = await createChatThing(chatContainer, me)
|
|
186
|
-
await sendInvite(invitee, chatThing)
|
|
187
|
-
await setAcl(chatContainer, me, invitee)
|
|
188
|
-
await addToPrivateTypeIndex(chatThing, me)
|
|
189
|
-
return chatThing
|
|
185
|
+
const chatThing = await createChatThing(chatContainer, me)
|
|
186
|
+
await sendInvite(invitee, chatThing)
|
|
187
|
+
await setAcl(chatContainer, me, invitee)
|
|
188
|
+
await addToPrivateTypeIndex(chatThing, me)
|
|
189
|
+
return chatThing
|
|
190
190
|
}
|
|
191
|
-
return null
|
|
191
|
+
return null
|
|
192
192
|
}
|
|
193
193
|
|
|
194
194
|
async function sendInvite(invitee: NamedNode, chatThing: NamedNode) {
|
|
195
|
-
await store.fetcher.load(invitee.doc())
|
|
195
|
+
await store.fetcher.load(invitee.doc())
|
|
196
196
|
const inviteeInbox = store.any(
|
|
197
197
|
invitee,
|
|
198
|
-
ns.ldp(
|
|
198
|
+
ns.ldp('inbox'),
|
|
199
199
|
undefined,
|
|
200
200
|
invitee.doc()
|
|
201
|
-
)
|
|
201
|
+
)
|
|
202
202
|
if (!inviteeInbox) {
|
|
203
|
-
throw new Error(`Invitee inbox not found! ${invitee.value}`)
|
|
203
|
+
throw new Error(`Invitee inbox not found! ${invitee.value}`)
|
|
204
204
|
}
|
|
205
205
|
const inviteBody = `
|
|
206
206
|
<> a <http://www.w3.org/ns/pim/meeting#LongChatInvite> ;
|
|
207
|
-
${ns.rdf(
|
|
208
|
-
|
|
207
|
+
${ns.rdf('seeAlso')} <${chatThing.value}> .
|
|
208
|
+
`
|
|
209
209
|
|
|
210
210
|
const inviteResponse = await store.fetcher?.webOperation(
|
|
211
|
-
|
|
211
|
+
'POST',
|
|
212
212
|
inviteeInbox.value,
|
|
213
213
|
{
|
|
214
214
|
data: inviteBody,
|
|
215
|
-
contentType:
|
|
215
|
+
contentType: 'text/turtle',
|
|
216
216
|
}
|
|
217
|
-
)
|
|
218
|
-
const locationStr = inviteResponse?.headers.get(
|
|
217
|
+
)
|
|
218
|
+
const locationStr = inviteResponse?.headers.get('location')
|
|
219
219
|
if (!locationStr) {
|
|
220
|
-
throw new Error(`Invite sending returned a ${inviteResponse?.status}`)
|
|
220
|
+
throw new Error(`Invite sending returned a ${inviteResponse?.status}`)
|
|
221
221
|
}
|
|
222
222
|
}
|
|
223
223
|
return {
|
package/src/inbox/inboxLogic.ts
CHANGED
|
@@ -1,54 +1,54 @@
|
|
|
1
|
-
import { NamedNode } from
|
|
2
|
-
import { InboxLogic } from
|
|
3
|
-
import { getArchiveUrl } from
|
|
1
|
+
import { NamedNode } from 'rdflib'
|
|
2
|
+
import { InboxLogic } from '../types'
|
|
3
|
+
import { getArchiveUrl } from '../util/utils'
|
|
4
4
|
|
|
5
5
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
6
6
|
export function createInboxLogic(store, profileLogic, utilityLogic, containerLogic, aclLogic): InboxLogic {
|
|
7
7
|
|
|
8
8
|
async function createInboxFor(peerWebId: string, nick: string) {
|
|
9
|
-
const myWebId: NamedNode = await profileLogic.loadMe()
|
|
10
|
-
const podRoot: NamedNode = await profileLogic.getPodRoot(myWebId)
|
|
11
|
-
const ourInbox = `${podRoot.value}p2p-inboxes/${encodeURIComponent(nick)}
|
|
12
|
-
await containerLogic.createContainer(ourInbox)
|
|
9
|
+
const myWebId: NamedNode = await profileLogic.loadMe()
|
|
10
|
+
const podRoot: NamedNode = await profileLogic.getPodRoot(myWebId)
|
|
11
|
+
const ourInbox = `${podRoot.value}p2p-inboxes/${encodeURIComponent(nick)}/`
|
|
12
|
+
await containerLogic.createContainer(ourInbox)
|
|
13
13
|
// const aclDocUrl = await aclLogic.findAclDocUrl(ourInbox);
|
|
14
14
|
await utilityLogic.setSinglePeerAccess({
|
|
15
15
|
ownerWebId: myWebId.value,
|
|
16
16
|
peerWebId,
|
|
17
17
|
accessToModes: 'acl:Append',
|
|
18
18
|
target: ourInbox
|
|
19
|
-
})
|
|
20
|
-
return ourInbox
|
|
19
|
+
})
|
|
20
|
+
return ourInbox
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
async function getNewMessages(
|
|
24
24
|
user?: NamedNode
|
|
25
25
|
): Promise<NamedNode[]> {
|
|
26
26
|
if (!user) {
|
|
27
|
-
user = await profileLogic.loadMe()
|
|
27
|
+
user = await profileLogic.loadMe()
|
|
28
28
|
}
|
|
29
|
-
const inbox = await profileLogic.getMainInbox(user)
|
|
30
|
-
const urls = await containerLogic.getContainerMembers(inbox)
|
|
31
|
-
return urls.filter(url => !containerLogic.isContainer(url))
|
|
29
|
+
const inbox = await profileLogic.getMainInbox(user)
|
|
30
|
+
const urls = await containerLogic.getContainerMembers(inbox)
|
|
31
|
+
return urls.filter(url => !containerLogic.isContainer(url))
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
async function markAsRead(url: string, date: Date) {
|
|
35
|
-
const downloaded = await store.fetcher._fetch(url)
|
|
35
|
+
const downloaded = await store.fetcher._fetch(url)
|
|
36
36
|
if (downloaded.status !== 200) {
|
|
37
|
-
throw new Error(`Not OK! ${url}`)
|
|
37
|
+
throw new Error(`Not OK! ${url}`)
|
|
38
38
|
}
|
|
39
|
-
const archiveUrl = getArchiveUrl(url, date)
|
|
39
|
+
const archiveUrl = getArchiveUrl(url, date)
|
|
40
40
|
const options = {
|
|
41
41
|
method: 'PUT',
|
|
42
42
|
body: await downloaded.text(),
|
|
43
43
|
headers: [
|
|
44
44
|
['Content-Type', downloaded.headers.get('Content-Type') || 'application/octet-stream']
|
|
45
45
|
]
|
|
46
|
-
}
|
|
47
|
-
const uploaded = await store.fetcher._fetch(archiveUrl, options)
|
|
46
|
+
}
|
|
47
|
+
const uploaded = await store.fetcher._fetch(archiveUrl, options)
|
|
48
48
|
if (uploaded.status.toString()[0] === '2') {
|
|
49
49
|
await store.fetcher._fetch(url, {
|
|
50
50
|
method: 'DELETE'
|
|
51
|
-
})
|
|
51
|
+
})
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
54
|
return {
|
package/src/index.ts
CHANGED
|
@@ -9,7 +9,7 @@ const store = solidLogicSingleton.store
|
|
|
9
9
|
export { ACL_LINK } from './acl/aclLogic'
|
|
10
10
|
export { offlineTestID, appContext } from './authn/authUtil'
|
|
11
11
|
export { getSuggestedIssuers } from './issuer/issuerLogic'
|
|
12
|
-
export { AppDetails, SolidNamespace, AuthenticationContext, SolidLogic } from './types'
|
|
12
|
+
export type { AppDetails, SolidNamespace, AuthenticationContext, SolidLogic } from './types'
|
|
13
13
|
export { UnauthorizedError, CrossOriginForbiddenError, SameOriginForbiddenError, NotFoundError, FetchError, NotEditableError, WebOperationError } from './logic/CustomError'
|
|
14
14
|
|
|
15
15
|
export {
|
package/src/logic/CustomError.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
class CustomError extends Error {
|
|
2
2
|
constructor(message?: string) {
|
|
3
|
-
super(message)
|
|
3
|
+
super(message)
|
|
4
4
|
// see: typescriptlang.org/docs/handbook/release-notes/typescript-2-2.html
|
|
5
|
-
Object.setPrototypeOf(this, new.target.prototype)
|
|
6
|
-
this.name = new.target.name
|
|
5
|
+
Object.setPrototypeOf(this, new.target.prototype) // restore prototype chain
|
|
6
|
+
this.name = new.target.name // stack traces display correctly now
|
|
7
7
|
}
|
|
8
8
|
}
|
|
9
9
|
|
|
@@ -20,10 +20,10 @@ export class NotEditableError extends CustomError { }
|
|
|
20
20
|
export class WebOperationError extends CustomError {}
|
|
21
21
|
|
|
22
22
|
export class FetchError extends CustomError {
|
|
23
|
-
status: number
|
|
23
|
+
status: number
|
|
24
24
|
|
|
25
25
|
constructor(status: number, message?: string) {
|
|
26
|
-
super(message)
|
|
27
|
-
this.status = status
|
|
26
|
+
super(message)
|
|
27
|
+
this.status = status
|
|
28
28
|
}
|
|
29
29
|
}
|