solid-logic 1.3.13 → 1.3.14
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/.github/workflows/ci.yml +39 -5
- package/jest.config.js +4 -1
- package/lib/acl/aclLogic.d.ts +32 -0
- package/lib/acl/aclLogic.d.ts.map +1 -0
- package/lib/acl/aclLogic.js +132 -0
- package/lib/acl/aclLogic.js.map +1 -0
- package/lib/authSession/authSession.d.ts +3 -0
- package/lib/authSession/authSession.d.ts.map +1 -0
- package/lib/authSession/authSession.js +8 -0
- package/lib/authSession/authSession.js.map +1 -0
- package/lib/authn/SolidAuthnLogic.d.ts +26 -5
- package/lib/authn/SolidAuthnLogic.d.ts.map +1 -1
- package/lib/authn/SolidAuthnLogic.js +167 -5
- package/lib/authn/SolidAuthnLogic.js.map +1 -1
- package/lib/authn/authUtil.d.ts +17 -0
- package/lib/authn/authUtil.d.ts.map +1 -0
- package/lib/authn/authUtil.js +88 -0
- package/lib/authn/authUtil.js.map +1 -0
- package/lib/chat/ChatLogic.d.ts +2 -2
- package/lib/chat/ChatLogic.d.ts.map +1 -1
- package/lib/chat/ChatLogic.js +2 -2
- package/lib/chat/ChatLogic.js.map +1 -1
- package/lib/inbox/InboxLogic.d.ts +2 -2
- package/lib/inbox/InboxLogic.d.ts.map +1 -1
- package/lib/inbox/InboxLogic.js.map +1 -1
- package/lib/index.d.ts +14 -67
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +39 -387
- package/lib/index.js.map +1 -1
- package/lib/issuer/issuerLogic.d.ts +8 -0
- package/lib/issuer/issuerLogic.d.ts.map +1 -0
- package/lib/issuer/issuerLogic.js +53 -0
- package/lib/issuer/issuerLogic.js.map +1 -0
- package/lib/logic/CustomError.d.ts +17 -0
- package/lib/logic/CustomError.d.ts.map +1 -0
- package/lib/logic/CustomError.js +73 -0
- package/lib/logic/CustomError.js.map +1 -0
- package/lib/logic/SolidLogic.d.ts +49 -0
- package/lib/logic/SolidLogic.d.ts.map +1 -0
- package/lib/logic/SolidLogic.js +317 -0
- package/lib/logic/SolidLogic.js.map +1 -0
- package/lib/logic/solidLogicSingleton.d.ts +4 -0
- package/lib/logic/solidLogicSingleton.d.ts.map +1 -0
- package/lib/logic/solidLogicSingleton.js +77 -0
- package/lib/logic/solidLogicSingleton.js.map +1 -0
- package/lib/profile/ProfileLogic.d.ts +2 -3
- package/lib/profile/ProfileLogic.d.ts.map +1 -1
- package/lib/profile/ProfileLogic.js.map +1 -1
- package/lib/typeIndex/typeIndexLogic.d.ts +22 -0
- package/lib/typeIndex/typeIndexLogic.d.ts.map +1 -0
- package/lib/typeIndex/typeIndexLogic.js +302 -0
- package/lib/typeIndex/typeIndexLogic.js.map +1 -0
- package/lib/types.d.ts +31 -0
- package/lib/types.d.ts.map +1 -0
- package/lib/{authn/index.js → types.js} +1 -1
- package/lib/types.js.map +1 -0
- package/lib/util/UtilityLogic.d.ts +2 -2
- package/lib/util/UtilityLogic.d.ts.map +1 -1
- package/lib/util/UtilityLogic.js.map +1 -1
- package/lib/{debug.d.ts → util/debug.d.ts} +0 -0
- package/lib/util/debug.d.ts.map +1 -0
- package/lib/{debug.js → util/debug.js} +0 -0
- package/lib/util/debug.js.map +1 -0
- package/lib/{uri.d.ts → util/uri.d.ts} +0 -0
- package/lib/util/uri.d.ts.map +1 -0
- package/lib/{uri.js → util/uri.js} +0 -0
- package/lib/util/uri.js.map +1 -0
- package/package.json +5 -3
- package/src/acl/aclLogic.ts +137 -0
- package/src/authSession/authSession.ts +13 -0
- package/src/authn/SolidAuthnLogic.ts +114 -9
- package/src/authn/authUtil.ts +67 -0
- package/src/chat/ChatLogic.ts +4 -4
- package/src/inbox/InboxLogic.ts +2 -14
- package/src/index.ts +29 -308
- package/src/issuer/issuerLogic.ts +40 -0
- package/src/logic/CustomError.ts +25 -0
- package/src/logic/SolidLogic.ts +265 -0
- package/src/logic/solidLogicSingleton.ts +18 -0
- package/src/profile/ProfileLogic.ts +2 -3
- package/src/typeIndex/typeIndexLogic.ts +170 -0
- package/src/types.ts +43 -0
- package/src/util/UtilityLogic.ts +2 -14
- package/src/{debug.ts → util/debug.ts} +0 -0
- package/src/{uri.ts → util/uri.ts} +0 -0
- package/test/aclLogic.test.ts +15 -0
- package/test/authUtil.test.ts +23 -0
- package/{src/chat/integration.test.ts → test/chatLogic.test.ts} +7 -9
- package/test/helpers/setup.ts +13 -0
- package/{src/inbox/unit.test.ts → test/inboxLogic.test.ts} +5 -6
- package/test/logic.test.ts +28 -0
- package/test/solidAuthLogic.test.ts +49 -0
- package/test/typeIndexLogic.test.ts +26 -0
- package/{src/util/unit.test.ts → test/utilityLogic.test.ts} +3 -4
- package/jest.setup.ts +0 -2
- package/lib/authn/NoAuthnLogic.d.ts +0 -9
- package/lib/authn/NoAuthnLogic.d.ts.map +0 -1
- package/lib/authn/NoAuthnLogic.js +0 -17
- package/lib/authn/NoAuthnLogic.js.map +0 -1
- package/lib/authn/index.d.ts +0 -5
- package/lib/authn/index.d.ts.map +0 -1
- package/lib/authn/index.js.map +0 -1
- package/lib/chat/integration.test.d.ts +0 -2
- package/lib/chat/integration.test.d.ts.map +0 -1
- package/lib/chat/integration.test.js +0 -318
- package/lib/chat/integration.test.js.map +0 -1
- package/lib/debug.d.ts.map +0 -1
- package/lib/debug.js.map +0 -1
- package/lib/inbox/unit.test.d.ts +0 -2
- package/lib/inbox/unit.test.d.ts.map +0 -1
- package/lib/inbox/unit.test.js +0 -264
- package/lib/inbox/unit.test.js.map +0 -1
- package/lib/uri.d.ts.map +0 -1
- package/lib/uri.js.map +0 -1
- package/lib/util/unit.test.d.ts +0 -2
- package/lib/util/unit.test.d.ts.map +0 -1
- package/lib/util/unit.test.js +0 -200
- package/lib/util/unit.test.js.map +0 -1
- package/src/authn/NoAuthnLogic.ts +0 -16
- package/src/authn/index.ts +0 -5
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import { NamedNode, st, sym } from "rdflib"
|
|
2
|
+
import * as debug from '../util/debug'
|
|
3
|
+
import solidNamespace from 'solid-namespace'
|
|
4
|
+
import * as $rdf from 'rdflib'
|
|
5
|
+
import { newThing } from "../util/uri"
|
|
6
|
+
import { AuthenticationContext } from "../types"
|
|
7
|
+
import { solidLogicSingleton } from "../logic/solidLogicSingleton"
|
|
8
|
+
|
|
9
|
+
export const ns = solidNamespace($rdf)
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Resolves with the same context, outputting
|
|
13
|
+
* output: index.public, index.private
|
|
14
|
+
*
|
|
15
|
+
* @see https://github.com/solid/solid/blob/main/proposals/data-discovery.md#discoverability
|
|
16
|
+
*/
|
|
17
|
+
export async function loadIndex (
|
|
18
|
+
context: AuthenticationContext,
|
|
19
|
+
isPublic: boolean
|
|
20
|
+
): Promise<AuthenticationContext> {
|
|
21
|
+
const indexes = await solidLogicSingleton.loadIndexes(
|
|
22
|
+
context.me as NamedNode,
|
|
23
|
+
(isPublic ? context.publicProfile || null : null),
|
|
24
|
+
(isPublic ? null : context.preferencesFile || null),
|
|
25
|
+
// async (err: Error) => widgets.complain(context, err.message)
|
|
26
|
+
async (err: Error) => debug.error(err.message) as undefined
|
|
27
|
+
)
|
|
28
|
+
context.index = context.index || {}
|
|
29
|
+
context.index.private = indexes.private || context.index.private
|
|
30
|
+
context.index.public = indexes.public || context.index.public
|
|
31
|
+
return context
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export async function loadTypeIndexes (context: AuthenticationContext) {
|
|
35
|
+
const indexes = await solidLogicSingleton.loadIndexes(
|
|
36
|
+
context.me as NamedNode,
|
|
37
|
+
context.publicProfile || null,
|
|
38
|
+
context.preferencesFile || null,
|
|
39
|
+
// async (err: Error) => widgets.complain(context, err.message)
|
|
40
|
+
async (err: Error) => debug.warn(err.message) as undefined
|
|
41
|
+
)
|
|
42
|
+
context.index = context.index || {}
|
|
43
|
+
context.index.private = indexes.private || context.index.private
|
|
44
|
+
context.index.public = indexes.public || context.index.public
|
|
45
|
+
return context
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Resolves with the same context, outputting
|
|
50
|
+
* @see https://github.com/solid/solid/blob/main/proposals/data-discovery.md#discoverability
|
|
51
|
+
*/
|
|
52
|
+
export async function ensureTypeIndexes (context: AuthenticationContext): Promise<AuthenticationContext> {
|
|
53
|
+
await ensureOneTypeIndex(context, true)
|
|
54
|
+
await ensureOneTypeIndex(context, false)
|
|
55
|
+
return context
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Load or create ONE type index
|
|
60
|
+
* Find one or make one or fail
|
|
61
|
+
* Many reasons for failing including script not having permission etc
|
|
62
|
+
*
|
|
63
|
+
* Adds its output to the context
|
|
64
|
+
* @see https://github.com/solid/solid/blob/main/proposals/data-discovery.md#discoverability
|
|
65
|
+
*/
|
|
66
|
+
async function ensureOneTypeIndex (context: AuthenticationContext, isPublic: boolean): Promise<AuthenticationContext | void> {
|
|
67
|
+
async function makeIndexIfNecessary (context, isPublic) {
|
|
68
|
+
const relevant = isPublic ? context.publicProfile : context.preferencesFile
|
|
69
|
+
const visibility = isPublic ? 'public' : 'private'
|
|
70
|
+
|
|
71
|
+
async function putIndex (newIndex) {
|
|
72
|
+
try {
|
|
73
|
+
await solidLogicSingleton.createEmptyRdfDoc(newIndex, 'Blank initial Type index')
|
|
74
|
+
return context
|
|
75
|
+
} catch (e) {
|
|
76
|
+
const msg = `Error creating new index ${e}`
|
|
77
|
+
// widgets.complain(context, msg)
|
|
78
|
+
debug.warn(msg)
|
|
79
|
+
}
|
|
80
|
+
} // putIndex
|
|
81
|
+
|
|
82
|
+
context.index = context.index || {}
|
|
83
|
+
context.index[visibility] = context.index[visibility] || []
|
|
84
|
+
let newIndex
|
|
85
|
+
if (context.index[visibility].length === 0) {
|
|
86
|
+
newIndex = sym(`${relevant.dir().uri + visibility}TypeIndex.ttl`)
|
|
87
|
+
debug.log(`Linking to new fresh type index ${newIndex}`)
|
|
88
|
+
if (!confirm(`OK to create a new empty index file at ${newIndex}, overwriting anything that is now there?`)) {
|
|
89
|
+
throw new Error('cancelled by user')
|
|
90
|
+
}
|
|
91
|
+
debug.log(`Linking to new fresh type index ${newIndex}`)
|
|
92
|
+
const addMe = [
|
|
93
|
+
st(context.me, ns.solid(`${visibility}TypeIndex`), newIndex, relevant)
|
|
94
|
+
]
|
|
95
|
+
try {
|
|
96
|
+
await solidLogicSingleton.updatePromise([], addMe)
|
|
97
|
+
} catch (err) {
|
|
98
|
+
const msg = `Error saving type index link saving back ${newIndex}: ${err}`
|
|
99
|
+
//widgets.complain(context, msg)
|
|
100
|
+
debug.warn(msg)
|
|
101
|
+
return context
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
debug.log(`Creating new fresh type index file${newIndex}`)
|
|
105
|
+
await putIndex(newIndex)
|
|
106
|
+
context.index[visibility].push(newIndex) // @@ wait
|
|
107
|
+
} else {
|
|
108
|
+
// officially exists
|
|
109
|
+
const ixs = context.index[visibility]
|
|
110
|
+
try {
|
|
111
|
+
await solidLogicSingleton.load(ixs)
|
|
112
|
+
} catch (err) {
|
|
113
|
+
const msg = `ensureOneTypeIndex: loading indexes ${err}`
|
|
114
|
+
debug.warn(msg)
|
|
115
|
+
// widgets.complain(context, `ensureOneTypeIndex: loading indexes ${err}`)
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
} // makeIndexIfNecessary
|
|
119
|
+
|
|
120
|
+
try {
|
|
121
|
+
await loadIndex(context, isPublic)
|
|
122
|
+
if (context.index) {
|
|
123
|
+
debug.log(
|
|
124
|
+
`ensureOneTypeIndex: Type index exists already ${isPublic
|
|
125
|
+
? context.index.public[0]
|
|
126
|
+
: context.index.private[0]
|
|
127
|
+
}`
|
|
128
|
+
)
|
|
129
|
+
}
|
|
130
|
+
return context
|
|
131
|
+
} catch (error) {
|
|
132
|
+
await makeIndexIfNecessary(context, isPublic)
|
|
133
|
+
// widgets.complain(context, 'calling loadIndex:' + error)
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* Register a new app in a type index
|
|
139
|
+
* used in chat in bookmark.js (solid-ui)
|
|
140
|
+
*/
|
|
141
|
+
export async function registerInTypeIndex (
|
|
142
|
+
context: AuthenticationContext,
|
|
143
|
+
instance: NamedNode,
|
|
144
|
+
theClass: NamedNode,
|
|
145
|
+
isPublic: boolean
|
|
146
|
+
): Promise<AuthenticationContext> {
|
|
147
|
+
await ensureOneTypeIndex(context, isPublic)
|
|
148
|
+
if (!context.index) {
|
|
149
|
+
throw new Error('registerInTypeIndex: No type index found')
|
|
150
|
+
}
|
|
151
|
+
const indexes = isPublic ? context.index.public : context.index.private
|
|
152
|
+
if (!indexes.length) {
|
|
153
|
+
throw new Error('registerInTypeIndex: What no type index?')
|
|
154
|
+
}
|
|
155
|
+
const index = indexes[0]
|
|
156
|
+
const registration = newThing(index)
|
|
157
|
+
const ins = [
|
|
158
|
+
// See https://github.com/solid/solid/blob/main/proposals/data-discovery.md
|
|
159
|
+
st(registration, ns.rdf('type'), ns.solid('TypeRegistration'), index),
|
|
160
|
+
st(registration, ns.solid('forClass'), theClass, index),
|
|
161
|
+
st(registration, ns.solid('instance'), instance, index)
|
|
162
|
+
]
|
|
163
|
+
try {
|
|
164
|
+
await solidLogicSingleton.updatePromise([], ins)
|
|
165
|
+
} catch (e) {
|
|
166
|
+
debug.log(e)
|
|
167
|
+
alert(e)
|
|
168
|
+
}
|
|
169
|
+
return context
|
|
170
|
+
}
|
package/src/types.ts
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { Session } from "@inrupt/solid-client-authn-browser"
|
|
2
|
+
import { NamedNode } from "rdflib"
|
|
3
|
+
|
|
4
|
+
export type AppDetails = {
|
|
5
|
+
noun: string
|
|
6
|
+
appPathSegment: string
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export type AuthenticationContext = {
|
|
10
|
+
containers?: Array<NamedNode>
|
|
11
|
+
div?: HTMLElement
|
|
12
|
+
dom?: HTMLDocument
|
|
13
|
+
index?: { [key: string]: Array<NamedNode> }
|
|
14
|
+
instances?: Array<NamedNode>
|
|
15
|
+
me?: NamedNode | null
|
|
16
|
+
noun?: string
|
|
17
|
+
preferencesFile?: NamedNode
|
|
18
|
+
preferencesFileError?: string
|
|
19
|
+
publicProfile?: NamedNode
|
|
20
|
+
statusArea?: HTMLElement
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export interface AuthnLogic {
|
|
24
|
+
authSession: Session //this needs to be deprecated in the future. Is only here to allow imports like panes.UI.authn.authSession prior to moving authn from ui to logic
|
|
25
|
+
currentUser: () => NamedNode | null
|
|
26
|
+
checkUser: <T>(setUserCallback?: (me: NamedNode | null) => T) => Promise<NamedNode | T | null>
|
|
27
|
+
saveUser: (webId: NamedNode | string | null,
|
|
28
|
+
context?: AuthenticationContext) => NamedNode | null
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export interface SolidNamespace {
|
|
32
|
+
[key: string]: (term: string) => NamedNode
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
interface NewPaneOptions {
|
|
36
|
+
me?: NamedNode;
|
|
37
|
+
newInstance?: NamedNode;
|
|
38
|
+
newBase: string;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
interface CreatedPaneOptions {
|
|
42
|
+
newInstance: NamedNode;
|
|
43
|
+
}
|
package/src/util/UtilityLogic.ts
CHANGED
|
@@ -1,22 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { SolidNamespace } from "../
|
|
3
|
-
import { ProfileLogic } from "../profile/ProfileLogic";
|
|
4
|
-
import { newThing } from "../uri";
|
|
1
|
+
import { NamedNode, Statement, sym, LiveStore } from "rdflib";
|
|
2
|
+
import { SolidNamespace } from "../types";
|
|
5
3
|
|
|
6
4
|
export const ACL_LINK = sym(
|
|
7
5
|
"http://www.iana.org/assignments/link-relations/acl"
|
|
8
6
|
);
|
|
9
7
|
|
|
10
|
-
interface NewPaneOptions {
|
|
11
|
-
me?: NamedNode;
|
|
12
|
-
newInstance?: NamedNode;
|
|
13
|
-
newBase: string;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
interface CreatedPaneOptions {
|
|
17
|
-
newInstance: NamedNode;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
8
|
/**
|
|
21
9
|
* Utility-related logic
|
|
22
10
|
*/
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { sym } from 'rdflib'
|
|
2
|
+
import { setACLUserPublic } from '../src/acl/aclLogic'
|
|
3
|
+
|
|
4
|
+
describe('setACLUserPublic', () => {
|
|
5
|
+
it('exists', () => {
|
|
6
|
+
expect(setACLUserPublic).toBeInstanceOf(Function)
|
|
7
|
+
})
|
|
8
|
+
it.skip('runs', async () => {
|
|
9
|
+
expect(await setACLUserPublic(
|
|
10
|
+
'https://test.test#',
|
|
11
|
+
sym('https://test.test#'),
|
|
12
|
+
{}
|
|
13
|
+
)).toEqual({})
|
|
14
|
+
})
|
|
15
|
+
})
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @jest-environment jsdom
|
|
3
|
+
*
|
|
4
|
+
*/
|
|
5
|
+
import * as authUtil from '../src/authn/authUtil'
|
|
6
|
+
|
|
7
|
+
describe('offlineTestID', () => {
|
|
8
|
+
it('exists', () => {
|
|
9
|
+
expect(authUtil.offlineTestID).toBeInstanceOf(Function)
|
|
10
|
+
})
|
|
11
|
+
it('runs', () => {
|
|
12
|
+
expect(authUtil.offlineTestID()).toEqual(null)
|
|
13
|
+
})
|
|
14
|
+
})
|
|
15
|
+
|
|
16
|
+
describe('appContext', () => {
|
|
17
|
+
it('exists', () => {
|
|
18
|
+
expect(authUtil.appContext).toBeInstanceOf(Function)
|
|
19
|
+
})
|
|
20
|
+
it('runs', () => {
|
|
21
|
+
expect(authUtil.appContext()).toEqual({"viewingNoAuthPage": false,})
|
|
22
|
+
})
|
|
23
|
+
})
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-non-null-assertion */
|
|
2
|
-
import { ChatLogic } from "
|
|
2
|
+
import { ChatLogic } from "../src/chat/ChatLogic";
|
|
3
3
|
import solidNamespace from "solid-namespace";
|
|
4
|
-
|
|
5
4
|
import * as rdf from "rdflib";
|
|
6
|
-
import { ProfileLogic } from "../profile/ProfileLogic";
|
|
7
|
-
import fetchMock from "jest-fetch-mock";
|
|
5
|
+
import { ProfileLogic } from "../src/profile/ProfileLogic";
|
|
8
6
|
import { UpdateManager } from "rdflib";
|
|
7
|
+
import { SolidNamespace } from "../src/types";
|
|
9
8
|
|
|
10
|
-
const ns = solidNamespace(rdf);
|
|
9
|
+
const ns: SolidNamespace = solidNamespace(rdf);
|
|
11
10
|
|
|
12
11
|
const alice = rdf.sym("https://alice.example/profile/card#me");
|
|
13
12
|
const bob = rdf.sym("https://bob.example/profile/card#me");
|
|
@@ -125,11 +124,10 @@ describe("Chat logic", () => {
|
|
|
125
124
|
});
|
|
126
125
|
it("sent an invitation to invitee inbox", () => {
|
|
127
126
|
const request = getRequestTo("POST", "https://bob.example/inbox");
|
|
128
|
-
expect(request.body).
|
|
127
|
+
expect(request.body).toContain(`
|
|
129
128
|
<> a <http://www.w3.org/ns/pim/meeting#LongChatInvite> ;
|
|
130
|
-
<http://www.w3.org/1999/02/22-rdf-syntax-ns#seeAlso> <https://alice.example/IndividualChats/bob.example/index.ttl#this> .
|
|
131
|
-
`);
|
|
132
|
-
});
|
|
129
|
+
<http://www.w3.org/1999/02/22-rdf-syntax-ns#seeAlso> <https://alice.example/IndividualChats/bob.example/index.ttl#this> .
|
|
130
|
+
`);});
|
|
133
131
|
it("added the new chat to private type index", () => {
|
|
134
132
|
const request = getRequestTo(
|
|
135
133
|
"PATCH",
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { error, log, trace, warn } from '../../src/util/debug'
|
|
2
|
+
import fetchMock from "jest-fetch-mock";
|
|
3
|
+
|
|
4
|
+
fetchMock.enableMocks();
|
|
5
|
+
// We don't want to output debug messages to console as part of the tests
|
|
6
|
+
jest.mock('../../src/util/debug')
|
|
7
|
+
|
|
8
|
+
export function silenceDebugMessages () {
|
|
9
|
+
(log as any).mockImplementation(() => null)
|
|
10
|
+
;(warn as any).mockImplementation(() => null)
|
|
11
|
+
;(error as any).mockImplementation(() => null)
|
|
12
|
+
;(trace as any).mockImplementation(() => null)
|
|
13
|
+
}
|
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-non-null-assertion */
|
|
2
|
-
import { UtilityLogic } from "../util/UtilityLogic";
|
|
3
2
|
import solidNamespace from "solid-namespace";
|
|
4
|
-
|
|
5
3
|
import * as rdf from "rdflib";
|
|
6
|
-
import { ProfileLogic } from "../profile/ProfileLogic";
|
|
7
|
-
import fetchMock from "jest-fetch-mock";
|
|
8
4
|
import { UpdateManager } from "rdflib";
|
|
9
|
-
import {
|
|
5
|
+
import { ProfileLogic } from "../src/profile/ProfileLogic";
|
|
6
|
+
import { UtilityLogic } from "../src/util/UtilityLogic";
|
|
7
|
+
import { InboxLogic } from "../src/inbox/InboxLogic";
|
|
8
|
+
import { SolidNamespace } from "../src/types";
|
|
10
9
|
|
|
11
|
-
const ns = solidNamespace(rdf);
|
|
10
|
+
const ns: SolidNamespace = solidNamespace(rdf);
|
|
12
11
|
|
|
13
12
|
const alice = rdf.sym("https://alice.example/profile/card#me");
|
|
14
13
|
const bob = rdf.sym("https://bob.example/profile/card#me");
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { solidLogicSingleton } from "../src/index"
|
|
2
|
+
import { silenceDebugMessages } from "./helpers/setup"
|
|
3
|
+
|
|
4
|
+
silenceDebugMessages()
|
|
5
|
+
|
|
6
|
+
describe('solidLogicSingleton (main global SolidLogic instance)', () => {
|
|
7
|
+
it('exists', () => {
|
|
8
|
+
expect(solidLogicSingleton).toBeInstanceOf(Object)
|
|
9
|
+
})
|
|
10
|
+
})
|
|
11
|
+
|
|
12
|
+
describe('solidLogicSingleton.store', () => {
|
|
13
|
+
it('exists', () => {
|
|
14
|
+
expect(solidLogicSingleton.store).toBeInstanceOf(Object)
|
|
15
|
+
})
|
|
16
|
+
})
|
|
17
|
+
|
|
18
|
+
describe('solidLogicSingleton.store.fetcher', () => {
|
|
19
|
+
it('exists', () => {
|
|
20
|
+
expect(solidLogicSingleton.store.fetcher).toBeInstanceOf(Object)
|
|
21
|
+
})
|
|
22
|
+
})
|
|
23
|
+
|
|
24
|
+
describe('solidLogicSingleton.store.updater', () => {
|
|
25
|
+
it('exists', () => {
|
|
26
|
+
expect(solidLogicSingleton.store.updater).toBeInstanceOf(Object)
|
|
27
|
+
})
|
|
28
|
+
})
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @jest-environment jsdom
|
|
3
|
+
*
|
|
4
|
+
*/
|
|
5
|
+
import { SolidAuthnLogic } from '../src/authn/SolidAuthnLogic'
|
|
6
|
+
import { silenceDebugMessages } from './helpers/setup'
|
|
7
|
+
import { authSession } from '../src/authSession/authSession'
|
|
8
|
+
import { AuthenticationContext } from '../src/types'
|
|
9
|
+
|
|
10
|
+
silenceDebugMessages()
|
|
11
|
+
let solidAuthnLogic
|
|
12
|
+
|
|
13
|
+
describe("SolidAuthnLogic", () => {
|
|
14
|
+
|
|
15
|
+
beforeEach(() => {
|
|
16
|
+
solidAuthnLogic = new SolidAuthnLogic(authSession)
|
|
17
|
+
})
|
|
18
|
+
|
|
19
|
+
describe('checkUser', () => {
|
|
20
|
+
it('exists', () => {
|
|
21
|
+
expect(solidAuthnLogic.checkUser).toBeInstanceOf(Function)
|
|
22
|
+
})
|
|
23
|
+
it('runs', async () => {
|
|
24
|
+
expect(await solidAuthnLogic.checkUser()).toEqual(null)
|
|
25
|
+
})
|
|
26
|
+
})
|
|
27
|
+
|
|
28
|
+
describe('currentUser', () => {
|
|
29
|
+
it('exists', () => {
|
|
30
|
+
expect(solidAuthnLogic.currentUser).toBeInstanceOf(Function)
|
|
31
|
+
})
|
|
32
|
+
it('runs', async () => {
|
|
33
|
+
expect(await solidAuthnLogic.currentUser()).toEqual(null)
|
|
34
|
+
})
|
|
35
|
+
})
|
|
36
|
+
|
|
37
|
+
describe('saveUser', () => {
|
|
38
|
+
it('exists', () => {
|
|
39
|
+
expect(solidAuthnLogic.saveUser).toBeInstanceOf(Function)
|
|
40
|
+
})
|
|
41
|
+
it('runs', () => {
|
|
42
|
+
expect(solidAuthnLogic.saveUser(
|
|
43
|
+
'',
|
|
44
|
+
{} as AuthenticationContext
|
|
45
|
+
)).toEqual(null)
|
|
46
|
+
})
|
|
47
|
+
})
|
|
48
|
+
|
|
49
|
+
})
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { sym } from 'rdflib'
|
|
2
|
+
import { AuthenticationContext } from '../src/types'
|
|
3
|
+
import * as typeIndexLogic from '../src/typeIndex/typeIndexLogic'
|
|
4
|
+
|
|
5
|
+
describe('loadTypeIndexes', () => {
|
|
6
|
+
it('exists', () => {
|
|
7
|
+
expect(typeIndexLogic.loadTypeIndexes).toBeInstanceOf(Function)
|
|
8
|
+
})
|
|
9
|
+
it('runs', () => {
|
|
10
|
+
expect(typeIndexLogic.loadTypeIndexes({})).toBeInstanceOf(Object)
|
|
11
|
+
})
|
|
12
|
+
})
|
|
13
|
+
|
|
14
|
+
describe('registerInTypeIndex', () => {
|
|
15
|
+
it('exists', () => {
|
|
16
|
+
expect(typeIndexLogic.registerInTypeIndex).toBeInstanceOf(Function)
|
|
17
|
+
})
|
|
18
|
+
it.skip('runs', async () => {
|
|
19
|
+
expect(await typeIndexLogic.registerInTypeIndex(
|
|
20
|
+
{} as AuthenticationContext,
|
|
21
|
+
sym('https://test.test#'),
|
|
22
|
+
sym('https://test.test#'),
|
|
23
|
+
false
|
|
24
|
+
)).toEqual(undefined)
|
|
25
|
+
})
|
|
26
|
+
})
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-non-null-assertion */
|
|
2
|
-
import { UtilityLogic } from "
|
|
2
|
+
import { UtilityLogic } from "../src/util/UtilityLogic";
|
|
3
3
|
import solidNamespace from "solid-namespace";
|
|
4
|
-
|
|
5
4
|
import * as rdf from "rdflib";
|
|
6
|
-
import { ProfileLogic } from "../profile/ProfileLogic";
|
|
7
5
|
import fetchMock from "jest-fetch-mock";
|
|
8
6
|
import { UpdateManager } from "rdflib";
|
|
7
|
+
import { SolidNamespace } from "../src/types";
|
|
9
8
|
|
|
10
|
-
const ns = solidNamespace(rdf);
|
|
9
|
+
const ns: SolidNamespace = solidNamespace(rdf);
|
|
11
10
|
|
|
12
11
|
const alice = rdf.sym("https://alice.example/profile/card#me");
|
|
13
12
|
const bob = rdf.sym("https://bob.example/profile/card#me");
|
package/jest.setup.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"NoAuthnLogic.d.ts","sourceRoot":"","sources":["../../src/authn/NoAuthnLogic.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAErC;;GAEG;AACH,qBAAa,YAAa,YAAW,UAAU;;IAO7C,WAAW,IAAI,IAAI;CAGpB"}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.NoAuthnLogic = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* Fallback, if no auth client has been provided to solid-logic
|
|
6
|
-
*/
|
|
7
|
-
var NoAuthnLogic = /** @class */ (function () {
|
|
8
|
-
function NoAuthnLogic() {
|
|
9
|
-
console.warn("no auth client passed to solid-logic, logic that relies on auth is not available");
|
|
10
|
-
}
|
|
11
|
-
NoAuthnLogic.prototype.currentUser = function () {
|
|
12
|
-
return null;
|
|
13
|
-
};
|
|
14
|
-
return NoAuthnLogic;
|
|
15
|
-
}());
|
|
16
|
-
exports.NoAuthnLogic = NoAuthnLogic;
|
|
17
|
-
//# sourceMappingURL=NoAuthnLogic.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"NoAuthnLogic.js","sourceRoot":"","sources":["../../src/authn/NoAuthnLogic.ts"],"names":[],"mappings":";;;AAEA;;GAEG;AACH;IACE;QACE,OAAO,CAAC,IAAI,CACV,kFAAkF,CACnF,CAAC;IACJ,CAAC;IAED,kCAAW,GAAX;QACE,OAAO,IAAI,CAAC;IACd,CAAC;IACH,mBAAC;AAAD,CAAC,AAVD,IAUC;AAVY,oCAAY"}
|
package/lib/authn/index.d.ts
DELETED
package/lib/authn/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/authn/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AAEnC,MAAM,WAAW,UAAU;IACzB,WAAW,EAAE,MAAM,SAAS,GAAG,IAAI,CAAC;CACrC"}
|
package/lib/authn/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/authn/index.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"integration.test.d.ts","sourceRoot":"","sources":["../../src/chat/integration.test.ts"],"names":[],"mappings":""}
|