solid-logic 3.0.9-15abc0b → 3.0.9-22c8d8a
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/README.md +23 -2
- package/dist/solid-logic.js +35 -0
- package/dist/solid-logic.js.map +1 -0
- package/package.json +11 -4
- package/babel.config.js +0 -6
- package/eslint.config.js +0 -28
- package/jest.config.js +0 -17
- package/lib/solid-logic.js +0 -107
- package/lib/solid-logic.js.map +0 -1
- package/rollup.config.js +0 -29
- package/src/acl/aclLogic.ts +0 -156
- package/src/authSession/authSession.ts +0 -13
- package/src/authn/SolidAuthnLogic.ts +0 -126
- package/src/authn/authUtil.ts +0 -70
- package/src/chat/chatLogic.ts +0 -226
- package/src/inbox/inboxLogic.ts +0 -59
- package/src/index.ts +0 -21
- package/src/issuer/issuerLogic.ts +0 -40
- package/src/logic/CustomError.ts +0 -29
- package/src/logic/solidLogic.ts +0 -76
- package/src/logic/solidLogicSingleton.ts +0 -20
- package/src/profile/profileLogic.ts +0 -125
- package/src/typeIndex/typeIndexLogic.ts +0 -198
- package/src/types.ts +0 -122
- package/src/util/containerLogic.ts +0 -53
- package/src/util/debug.ts +0 -16
- package/src/util/ns.ts +0 -5
- package/src/util/utilityLogic.ts +0 -156
- package/src/util/utils.ts +0 -52
- package/src/versionInfo.ts +0 -32
- package/test/aclLogic.test.ts +0 -24
- package/test/authUtil.test.ts +0 -23
- package/test/chatLogic.test.ts +0 -322
- package/test/container.test.ts +0 -58
- package/test/helpers/dataSetup.ts +0 -135
- package/test/helpers/setup.ts +0 -22
- package/test/inboxLogic.test.ts +0 -209
- package/test/logic.test.ts +0 -29
- package/test/profileLogic.test.ts +0 -248
- package/test/solidAuthLogic.test.ts +0 -49
- package/test/typeIndexLogic.test.ts +0 -255
- package/test/utilityLogic.test.ts +0 -180
- package/test/utils.test.ts +0 -32
- package/timestamp.sh +0 -13
- package/tsconfig.json +0 -77
- package/tsconfig.test.json +0 -8
- /package/{lib → dist}/acl/aclLogic.d.ts +0 -0
- /package/{lib → dist}/acl/aclLogic.d.ts.map +0 -0
- /package/{lib → dist}/authSession/authSession.d.ts +0 -0
- /package/{lib → dist}/authSession/authSession.d.ts.map +0 -0
- /package/{lib → dist}/authn/SolidAuthnLogic.d.ts +0 -0
- /package/{lib → dist}/authn/SolidAuthnLogic.d.ts.map +0 -0
- /package/{lib → dist}/authn/authUtil.d.ts +0 -0
- /package/{lib → dist}/authn/authUtil.d.ts.map +0 -0
- /package/{lib → dist}/chat/chatLogic.d.ts +0 -0
- /package/{lib → dist}/chat/chatLogic.d.ts.map +0 -0
- /package/{lib → dist}/inbox/inboxLogic.d.ts +0 -0
- /package/{lib → dist}/inbox/inboxLogic.d.ts.map +0 -0
- /package/{lib → dist}/index.d.ts +0 -0
- /package/{lib → dist}/index.d.ts.map +0 -0
- /package/{lib → dist}/issuer/issuerLogic.d.ts +0 -0
- /package/{lib → dist}/issuer/issuerLogic.d.ts.map +0 -0
- /package/{lib → dist}/logic/CustomError.d.ts +0 -0
- /package/{lib → dist}/logic/CustomError.d.ts.map +0 -0
- /package/{lib → dist}/logic/solidLogic.d.ts +0 -0
- /package/{lib → dist}/logic/solidLogic.d.ts.map +0 -0
- /package/{lib → dist}/logic/solidLogicSingleton.d.ts +0 -0
- /package/{lib → dist}/logic/solidLogicSingleton.d.ts.map +0 -0
- /package/{lib → dist}/profile/profileLogic.d.ts +0 -0
- /package/{lib → dist}/profile/profileLogic.d.ts.map +0 -0
- /package/{lib → dist}/typeIndex/typeIndexLogic.d.ts +0 -0
- /package/{lib → dist}/typeIndex/typeIndexLogic.d.ts.map +0 -0
- /package/{lib → dist}/types.d.ts +0 -0
- /package/{lib → dist}/types.d.ts.map +0 -0
- /package/{lib → dist}/util/containerLogic.d.ts +0 -0
- /package/{lib → dist}/util/containerLogic.d.ts.map +0 -0
- /package/{lib → dist}/util/debug.d.ts +0 -0
- /package/{lib → dist}/util/debug.d.ts.map +0 -0
- /package/{lib → dist}/util/ns.d.ts +0 -0
- /package/{lib → dist}/util/ns.d.ts.map +0 -0
- /package/{lib → dist}/util/utilityLogic.d.ts +0 -0
- /package/{lib → dist}/util/utilityLogic.d.ts.map +0 -0
- /package/{lib → dist}/util/utils.d.ts +0 -0
- /package/{lib → dist}/util/utils.d.ts.map +0 -0
package/test/container.test.ts
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @jest-environment jsdom
|
|
3
|
-
*
|
|
4
|
-
*/
|
|
5
|
-
import { UpdateManager, Store, Fetcher, sym } from 'rdflib'
|
|
6
|
-
import { createContainerLogic } from '../src/util/containerLogic'
|
|
7
|
-
import { alice } from './helpers/dataSetup'
|
|
8
|
-
|
|
9
|
-
window.$SolidTestEnvironment = { username: alice.uri }
|
|
10
|
-
|
|
11
|
-
describe('Container', () => {
|
|
12
|
-
let store
|
|
13
|
-
let containerLogic
|
|
14
|
-
beforeEach(() => {
|
|
15
|
-
fetchMock.resetMocks()
|
|
16
|
-
store = new Store()
|
|
17
|
-
store.fetcher = new Fetcher(store, { fetch: fetch })
|
|
18
|
-
store.updater = new UpdateManager(store)
|
|
19
|
-
containerLogic = createContainerLogic(store)
|
|
20
|
-
})
|
|
21
|
-
|
|
22
|
-
it('getContainerMembers - When container has some containment triples', async () => {
|
|
23
|
-
containerHasSomeContainmentTriples()
|
|
24
|
-
const containerMembers = await containerLogic.getContainerMembers(sym('https://container.com/'))
|
|
25
|
-
const result = containerMembers.map(oneResult => oneResult.value)
|
|
26
|
-
expect(result.sort()).toEqual([
|
|
27
|
-
'https://container.com/foo.txt',
|
|
28
|
-
'https://container.com/bar/'
|
|
29
|
-
].sort())
|
|
30
|
-
})
|
|
31
|
-
it.skip('getContainerMembers- When container is empty - Resolves to an empty array', async () => {
|
|
32
|
-
jest.setTimeout(2000)
|
|
33
|
-
containerIsEmpty()
|
|
34
|
-
const result = await containerLogic.getContainerMembers(sym('https://container.com/'))
|
|
35
|
-
expect(result).toEqual([])
|
|
36
|
-
})
|
|
37
|
-
|
|
38
|
-
function containerIsEmpty() {
|
|
39
|
-
fetchMock.mockOnceIf(
|
|
40
|
-
'https://com/',
|
|
41
|
-
'', // FIXME: https://github.com/jefflau/jest-fetch-mock/issues/189
|
|
42
|
-
{
|
|
43
|
-
headers: { 'Content-Type': 'text/turtle' },
|
|
44
|
-
}
|
|
45
|
-
)
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
function containerHasSomeContainmentTriples() {
|
|
49
|
-
fetchMock.mockOnceIf(
|
|
50
|
-
'https://container.com/',
|
|
51
|
-
'<.> <http://www.w3.org/ns/ldp#contains> <./foo.txt>, <./bar/> .',
|
|
52
|
-
{
|
|
53
|
-
headers: { 'Content-Type': 'text/turtle' },
|
|
54
|
-
}
|
|
55
|
-
)
|
|
56
|
-
|
|
57
|
-
}
|
|
58
|
-
})
|
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
import { sym } from 'rdflib'
|
|
2
|
-
import * as rdf from "rdflib";
|
|
3
|
-
import solidNamespace from "solid-namespace";
|
|
4
|
-
import { SolidNamespace } from '../../src/types';
|
|
5
|
-
const ns: SolidNamespace = solidNamespace(rdf);
|
|
6
|
-
|
|
7
|
-
//------ Club -------------------------------------------------------
|
|
8
|
-
const club = sym('https://club.example.com/profile/card.ttl#it')
|
|
9
|
-
const ClubPreferencesFile = sym('https://club.example.com/settings/prefs.ttl')
|
|
10
|
-
const ClubPublicTypeIndex = sym('https://club.example.com/profile/public-type-index.ttl')
|
|
11
|
-
const ClubPrivateTypeIndex = sym('https://club.example.com/settings/private-type-index.ttl')
|
|
12
|
-
|
|
13
|
-
const ClubProfile = `
|
|
14
|
-
|
|
15
|
-
<#it> a vcard:Organization;
|
|
16
|
-
space:preferencesFile ${ClubPreferencesFile};
|
|
17
|
-
solid:publicTypeIndex ${ClubPublicTypeIndex};
|
|
18
|
-
vcard:fn "Card Club" .
|
|
19
|
-
`
|
|
20
|
-
const ClubPreferences = `
|
|
21
|
-
${club} solid:privateTypeIndex ${ClubPrivateTypeIndex} .
|
|
22
|
-
`
|
|
23
|
-
const ClubPublicTypes = `
|
|
24
|
-
|
|
25
|
-
:chat1 solid:forClass meeting:LongChat; solid:instance <../publicStuff/ourChat.ttl#this> .
|
|
26
|
-
|
|
27
|
-
:todo solid:forClass wf:Tracker; solid:instance <../publicStuff/actionItems.ttl#this>.
|
|
28
|
-
|
|
29
|
-
:issues solid:forClass wf:Tracker; solid:instance <../project4/clubIssues.ttl#this>.
|
|
30
|
-
`;
|
|
31
|
-
|
|
32
|
-
const ClubPrivateTypes = `
|
|
33
|
-
:id1592319218311 solid:forClass wf:Tracker; solid:instance <../privateStuff/ToDo.ttl#this>.
|
|
34
|
-
|
|
35
|
-
:id1592319391415 solid:forClass wf:Tracker; solid:instance <../privateStuff/Goals.ttl#this>.
|
|
36
|
-
|
|
37
|
-
:id1595595377864 solid:forClass wf:Tracker; solid:instance <../privateStuff/tasks.ttl#this>.
|
|
38
|
-
|
|
39
|
-
:id1596123375929 solid:forClass meeting:Meeting; solid:instance <../project4/clubMeeting.ttl#this>.
|
|
40
|
-
|
|
41
|
-
`;
|
|
42
|
-
|
|
43
|
-
//------ Alice -------------------------------------------------------
|
|
44
|
-
const alice = sym("https://alice.example.com/profile/card.ttl#me")
|
|
45
|
-
const AliceProfileFile = alice.doc()
|
|
46
|
-
const AlicePreferencesFile = sym('https://alice.example.com/settings/prefs.ttl')
|
|
47
|
-
const AlicePublicTypeIndex = sym('https://alice.example.com/profile/public-type-index.ttl')
|
|
48
|
-
const AlicePrivateTypeIndex = sym('https://alice.example.com/settings/private-type-index.ttl')
|
|
49
|
-
const aliceDir = alice.dir();
|
|
50
|
-
const AlicePhotoFolder = sym((aliceDir && aliceDir.uri ? aliceDir.uri : "") + "Photos/")
|
|
51
|
-
const AliceProfile = `
|
|
52
|
-
<#me> a vcard:Individual;
|
|
53
|
-
space:preferencesFile ${AlicePreferencesFile};
|
|
54
|
-
solid:publicTypeIndex ${AlicePublicTypeIndex};
|
|
55
|
-
vcard:fn "Alice" .
|
|
56
|
-
`
|
|
57
|
-
const AlicePreferences = `
|
|
58
|
-
${alice} solid:privateTypeIndex ${AlicePrivateTypeIndex};
|
|
59
|
-
solid:community ${club} .
|
|
60
|
-
`
|
|
61
|
-
const AlicePublicTypes = `
|
|
62
|
-
|
|
63
|
-
:chat1 solid:forClass meeting:LongChat; solid:instance <../publicStuff/myChat.ttl#this> .
|
|
64
|
-
|
|
65
|
-
:todo solid:forClass wf:Tracker; solid:instance <../publicStuff/actionItems.ttl#this>.
|
|
66
|
-
|
|
67
|
-
:issues solid:forClass wf:Tracker; solid:instance <../project4/issues.ttl#this>.
|
|
68
|
-
|
|
69
|
-
:photos solid:forClass schema:Image; solid:instanceContainer ${AlicePhotoFolder} .
|
|
70
|
-
`;
|
|
71
|
-
|
|
72
|
-
const AlicePrivateTypes = `
|
|
73
|
-
:id1592319218311 solid:forClass wf:Tracker; solid:instance <../privateStuff/ToDo.ttl#this>.
|
|
74
|
-
|
|
75
|
-
:id1592319391415 solid:forClass wf:Tracker; solid:instance <../privateStuff/Goals.ttl#this>.
|
|
76
|
-
|
|
77
|
-
:id1595595377864 solid:forClass wf:Tracker; solid:instance <../privateStuff/workingOn.ttl#this>.
|
|
78
|
-
|
|
79
|
-
:id1596123375929 solid:forClass meeting:Meeting; solid:instance <../project4/meeting1.ttl#this>.
|
|
80
|
-
|
|
81
|
-
`;
|
|
82
|
-
|
|
83
|
-
const AlicePhotos = `
|
|
84
|
-
<>
|
|
85
|
-
a ldp:BasicContainer, ldp:Container;
|
|
86
|
-
dct:modified "2021-04-26T05:34:16Z"^^xsd:dateTime;
|
|
87
|
-
ldp:contains
|
|
88
|
-
<photo1.png>, <photo2.png>, <photo3.png> ;
|
|
89
|
-
stat:mtime 1619415256.541;
|
|
90
|
-
stat:size 4096 .
|
|
91
|
-
`
|
|
92
|
-
|
|
93
|
-
//------ Bob -------------------------------------------------------
|
|
94
|
-
const bob = sym('https://bob.example.com/profile/card.ttl#me')
|
|
95
|
-
|
|
96
|
-
const BobProfile = `
|
|
97
|
-
<#me> a vcard:Individual;
|
|
98
|
-
vcard:fn "Bob" .
|
|
99
|
-
`
|
|
100
|
-
|
|
101
|
-
//------ Boby -------------------------------------------------------
|
|
102
|
-
const boby = sym('https://boby.example.com/profile/card.ttl#me')
|
|
103
|
-
|
|
104
|
-
const BobyProfile = `
|
|
105
|
-
<#me> a vcard:Individual;
|
|
106
|
-
vcard:fn "Boby" .
|
|
107
|
-
`
|
|
108
|
-
export function loadWebObject() {
|
|
109
|
-
const web = {}
|
|
110
|
-
web[alice.doc().uri] = AliceProfile
|
|
111
|
-
web[AlicePreferencesFile.uri] = AlicePreferences
|
|
112
|
-
web[AlicePrivateTypeIndex.uri] = AlicePrivateTypes
|
|
113
|
-
web[AlicePublicTypeIndex.uri] = AlicePublicTypes
|
|
114
|
-
web[AlicePhotoFolder.uri] = AlicePhotos
|
|
115
|
-
web[bob.doc().uri] = BobProfile
|
|
116
|
-
web[boby.doc().uri] = BobyProfile
|
|
117
|
-
|
|
118
|
-
web[club.doc().uri] = ClubProfile
|
|
119
|
-
web[ClubPreferencesFile.uri] = ClubPreferences
|
|
120
|
-
web[ClubPrivateTypeIndex.uri] = ClubPrivateTypes
|
|
121
|
-
web[ClubPublicTypeIndex.uri] = ClubPublicTypes
|
|
122
|
-
return web
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
function clearLocalStore(store) {
|
|
126
|
-
store.statements.slice().forEach(store.remove.bind(store))
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
export {
|
|
130
|
-
alice, bob, boby, club,
|
|
131
|
-
AlicePhotoFolder, AlicePreferences, AlicePhotos, AlicePreferencesFile, AlicePrivateTypeIndex, AlicePrivateTypes, AliceProfile, AliceProfileFile, AlicePublicTypeIndex, AlicePublicTypes,
|
|
132
|
-
BobProfile,
|
|
133
|
-
ClubPreferences, ClubPreferencesFile, ClubPrivateTypeIndex, ClubPrivateTypes, ClubProfile, ClubPublicTypeIndex, ClubPublicTypes,
|
|
134
|
-
clearLocalStore
|
|
135
|
-
}
|
package/test/helpers/setup.ts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { error, log, trace, warn } from '../../src/util/debug'
|
|
2
|
-
import fetchMock from "jest-fetch-mock";
|
|
3
|
-
import { TextEncoder as UtilTextEncoder, TextDecoder as UtilTextDecoder } from 'util'
|
|
4
|
-
|
|
5
|
-
if (typeof global.TextEncoder === 'undefined') {
|
|
6
|
-
global.TextEncoder = UtilTextEncoder as unknown as { new (): TextEncoder; prototype: TextEncoder }
|
|
7
|
-
}
|
|
8
|
-
if (typeof global.TextDecoder === 'undefined') {
|
|
9
|
-
global.TextDecoder = UtilTextDecoder as unknown as { new (): TextDecoder; prototype: TextDecoder }
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
fetchMock.enableMocks();
|
|
14
|
-
// We don't want to output debug messages to console as part of the tests
|
|
15
|
-
jest.mock('../../src/util/debug')
|
|
16
|
-
|
|
17
|
-
export function silenceDebugMessages () {
|
|
18
|
-
(log as any).mockImplementation(() => null)
|
|
19
|
-
;(warn as any).mockImplementation(() => null)
|
|
20
|
-
;(error as any).mockImplementation(() => null)
|
|
21
|
-
;(trace as any).mockImplementation(() => null)
|
|
22
|
-
}
|
package/test/inboxLogic.test.ts
DELETED
|
@@ -1,209 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @jest-environment jsdom
|
|
3
|
-
*
|
|
4
|
-
*/
|
|
5
|
-
import { UpdateManager, Store, Fetcher, sym } from 'rdflib'
|
|
6
|
-
import { createAclLogic } from '../src/acl/aclLogic'
|
|
7
|
-
import { createInboxLogic } from '../src/inbox/inboxLogic'
|
|
8
|
-
import { createProfileLogic } from '../src/profile/profileLogic'
|
|
9
|
-
import { createContainerLogic } from '../src/util/containerLogic'
|
|
10
|
-
import { createUtilityLogic } from '../src/util/utilityLogic'
|
|
11
|
-
|
|
12
|
-
const alice = sym('https://alice.example.com/profile/card#me')
|
|
13
|
-
const bob = sym('https://bob.example.com/profile/card#me')
|
|
14
|
-
|
|
15
|
-
describe('Inbox logic', () => {
|
|
16
|
-
let store
|
|
17
|
-
let inboxLogic
|
|
18
|
-
beforeEach(() => {
|
|
19
|
-
fetchMock.resetMocks()
|
|
20
|
-
fetchMock.mockResponse('Not Found', {
|
|
21
|
-
status: 404,
|
|
22
|
-
})
|
|
23
|
-
store = new Store()
|
|
24
|
-
store.fetcher = new Fetcher(store, { fetch: fetch })
|
|
25
|
-
store.updater = new UpdateManager(store)
|
|
26
|
-
const authn = {
|
|
27
|
-
currentUser: () => {
|
|
28
|
-
return alice
|
|
29
|
-
},
|
|
30
|
-
}
|
|
31
|
-
const containerLogic = createContainerLogic(store)
|
|
32
|
-
const aclLogic = createAclLogic(store)
|
|
33
|
-
const util = createUtilityLogic(store, aclLogic, containerLogic)
|
|
34
|
-
const profile = createProfileLogic(store, authn, util)
|
|
35
|
-
inboxLogic = createInboxLogic(store, profile, util, containerLogic, aclLogic)
|
|
36
|
-
})
|
|
37
|
-
|
|
38
|
-
describe('getNewMessages', () => {
|
|
39
|
-
describe('When inbox is empty', () => {
|
|
40
|
-
let result
|
|
41
|
-
beforeEach(async () => {
|
|
42
|
-
bobHasAnInbox()
|
|
43
|
-
inboxIsEmpty()
|
|
44
|
-
result = await inboxLogic.getNewMessages(bob)
|
|
45
|
-
})
|
|
46
|
-
it('Resolves to an empty array', () => {
|
|
47
|
-
expect(result).toEqual([])
|
|
48
|
-
})
|
|
49
|
-
})
|
|
50
|
-
describe('When container has some containment triples', () => {
|
|
51
|
-
let result
|
|
52
|
-
beforeEach(async () => {
|
|
53
|
-
bobHasAnInbox()
|
|
54
|
-
inboxHasSomeContainmentTriples()
|
|
55
|
-
const messages = await inboxLogic.getNewMessages(bob)
|
|
56
|
-
result = messages.map(oneMessage => oneMessage.value)
|
|
57
|
-
})
|
|
58
|
-
it('Resolves to an array with URLs of non-container resources in inbox', () => {
|
|
59
|
-
expect(result.sort()).toEqual([
|
|
60
|
-
'https://container.com/foo.txt'
|
|
61
|
-
].sort())
|
|
62
|
-
})
|
|
63
|
-
})
|
|
64
|
-
})
|
|
65
|
-
describe('createInboxFor', () => {
|
|
66
|
-
beforeEach(async () => {
|
|
67
|
-
aliceHasValidProfile()
|
|
68
|
-
// First for the PUT:
|
|
69
|
-
fetchMock.mockOnceIf(
|
|
70
|
-
'https://alice.example.com/p2p-inboxes/Peer%20Person/',
|
|
71
|
-
'Created', {
|
|
72
|
-
status: 201
|
|
73
|
-
}
|
|
74
|
-
)
|
|
75
|
-
// Then for the GET to read the ACL link:
|
|
76
|
-
fetchMock.mockOnceIf(
|
|
77
|
-
'https://alice.example.com/p2p-inboxes/Peer%20Person/',
|
|
78
|
-
' ', {
|
|
79
|
-
status: 200,
|
|
80
|
-
headers: {
|
|
81
|
-
Link: '<https://some/acl>; rel="acl"',
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
)
|
|
85
|
-
fetchMock.mockIf('https://some/acl', 'Created', { status: 201 })
|
|
86
|
-
|
|
87
|
-
await inboxLogic.createInboxFor('https://peer.com/#me', 'Peer Person')
|
|
88
|
-
})
|
|
89
|
-
it('creates the inbox', () => {
|
|
90
|
-
expect(fetchMock.mock.calls).toEqual([
|
|
91
|
-
[ 'https://alice.example.com/profile/card', fetchMock.mock.calls[0][1] ],
|
|
92
|
-
[ 'https://alice.example.com/p2p-inboxes/Peer%20Person/', {
|
|
93
|
-
body: ' ',
|
|
94
|
-
headers: {
|
|
95
|
-
'Content-Type': 'text/turtle',
|
|
96
|
-
'If-None-Match': '*',
|
|
97
|
-
Link: '<http://www.w3.org/ns/ldp#BasicContainer>; rel="type"',
|
|
98
|
-
},
|
|
99
|
-
method: 'PUT'
|
|
100
|
-
}],
|
|
101
|
-
[ 'https://alice.example.com/p2p-inboxes/Peer%20Person/', fetchMock.mock.calls[2][1] ],
|
|
102
|
-
[ 'https://some/acl', {
|
|
103
|
-
body: '@prefix acl: <http://www.w3.org/ns/auth/acl#>.\n' +
|
|
104
|
-
'\n' +
|
|
105
|
-
'<#alice> a acl:Authorization;\n' +
|
|
106
|
-
' acl:agent <https://alice.example.com/profile/card#me>;\n' +
|
|
107
|
-
' acl:accessTo <https://alice.example.com/p2p-inboxes/Peer%20Person/>;\n' +
|
|
108
|
-
' acl:default <https://alice.example.com/p2p-inboxes/Peer%20Person/>;\n' +
|
|
109
|
-
' acl:mode acl:Read, acl:Write, acl:Control.\n' +
|
|
110
|
-
'<#bobAccessTo> a acl:Authorization;\n' +
|
|
111
|
-
' acl:agent <https://peer.com/#me>;\n' +
|
|
112
|
-
' acl:accessTo <https://alice.example.com/p2p-inboxes/Peer%20Person/>;\n' +
|
|
113
|
-
' acl:mode acl:Append.\n',
|
|
114
|
-
headers: [
|
|
115
|
-
[ 'Content-Type', 'text/turtle' ]
|
|
116
|
-
],
|
|
117
|
-
method: 'PUT'
|
|
118
|
-
}]
|
|
119
|
-
])
|
|
120
|
-
})
|
|
121
|
-
|
|
122
|
-
})
|
|
123
|
-
describe('markAsRead', () => {
|
|
124
|
-
beforeEach(async () => {
|
|
125
|
-
fetchMock.mockOnceIf(
|
|
126
|
-
'https://container.com/item.ttl',
|
|
127
|
-
'<#some> <#inbox> <#item> .',
|
|
128
|
-
{
|
|
129
|
-
headers: { 'Content-Type': 'text/turtle' },
|
|
130
|
-
}
|
|
131
|
-
)
|
|
132
|
-
fetchMock.mockOnceIf(
|
|
133
|
-
'https://container.com/archive/2111/03/31/item.ttl',
|
|
134
|
-
'Created',
|
|
135
|
-
{
|
|
136
|
-
status: 201,
|
|
137
|
-
headers: { 'Content-Type': 'text/turtle' },
|
|
138
|
-
}
|
|
139
|
-
)
|
|
140
|
-
await inboxLogic.markAsRead('https://container.com/item.ttl', new Date('31 March 2111 UTC'))
|
|
141
|
-
})
|
|
142
|
-
it('moves the item to archive', async () => {
|
|
143
|
-
expect(fetchMock.mock.calls).toEqual([
|
|
144
|
-
[ 'https://container.com/item.ttl' ],
|
|
145
|
-
[
|
|
146
|
-
'https://container.com/archive/2111/03/31/item.ttl',
|
|
147
|
-
{
|
|
148
|
-
'body': '<#some> <#inbox> <#item> .',
|
|
149
|
-
'headers': [
|
|
150
|
-
[
|
|
151
|
-
'Content-Type',
|
|
152
|
-
'text/turtle',
|
|
153
|
-
],
|
|
154
|
-
],
|
|
155
|
-
'method': 'PUT',
|
|
156
|
-
},
|
|
157
|
-
],
|
|
158
|
-
[ 'https://container.com/item.ttl', { method: 'DELETE' } ],
|
|
159
|
-
])
|
|
160
|
-
})
|
|
161
|
-
})
|
|
162
|
-
|
|
163
|
-
function aliceHasValidProfile() {
|
|
164
|
-
fetchMock.mockOnceIf(
|
|
165
|
-
'https://alice.example.com/profile/card',
|
|
166
|
-
`
|
|
167
|
-
<https://alice.example.com/profile/card#me>
|
|
168
|
-
<http://www.w3.org/ns/pim/space#storage> <https://alice.example.com/> ;
|
|
169
|
-
<http://www.w3.org/ns/solid/terms#privateTypeIndex> <https://alice.example.com/settings/privateTypeIndex.ttl> ;
|
|
170
|
-
.`,
|
|
171
|
-
{
|
|
172
|
-
headers: {
|
|
173
|
-
'Content-Type': 'text/turtle',
|
|
174
|
-
},
|
|
175
|
-
}
|
|
176
|
-
)
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
function bobHasAnInbox() {
|
|
180
|
-
fetchMock.mockOnceIf(
|
|
181
|
-
'https://bob.example.com/profile/card',
|
|
182
|
-
'<https://bob.example.com/profile/card#me><http://www.w3.org/ns/ldp#inbox><https://container.com/>.',
|
|
183
|
-
{
|
|
184
|
-
headers: { 'Content-Type': 'text/turtle' },
|
|
185
|
-
}
|
|
186
|
-
)
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
function inboxIsEmpty() {
|
|
190
|
-
fetchMock.mockOnceIf(
|
|
191
|
-
'https://container.com/',
|
|
192
|
-
' ', // FIXME: https://github.com/jefflau/jest-fetch-mock/issues/189
|
|
193
|
-
{
|
|
194
|
-
headers: { 'Content-Type': 'text/turtle' },
|
|
195
|
-
}
|
|
196
|
-
)
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
function inboxHasSomeContainmentTriples() {
|
|
200
|
-
fetchMock.mockOnceIf(
|
|
201
|
-
'https://container.com/',
|
|
202
|
-
'<.> <http://www.w3.org/ns/ldp#contains> <./foo.txt>, <./bar/> .',
|
|
203
|
-
{
|
|
204
|
-
headers: { 'Content-Type': 'text/turtle' },
|
|
205
|
-
}
|
|
206
|
-
)
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
})
|
package/test/logic.test.ts
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { solidLogicSingleton } from '../src/logic/solidLogicSingleton'
|
|
2
|
-
import { silenceDebugMessages } from './helpers/setup'
|
|
3
|
-
|
|
4
|
-
silenceDebugMessages()
|
|
5
|
-
|
|
6
|
-
describe('store', () => {
|
|
7
|
-
it('exists', () => {
|
|
8
|
-
expect(solidLogicSingleton.store).toBeInstanceOf(Object)
|
|
9
|
-
})
|
|
10
|
-
})
|
|
11
|
-
|
|
12
|
-
describe('store.fetcher', () => {
|
|
13
|
-
it('exists', () => {
|
|
14
|
-
expect(solidLogicSingleton.store.fetcher).toBeInstanceOf(Object)
|
|
15
|
-
})
|
|
16
|
-
})
|
|
17
|
-
|
|
18
|
-
describe('store.updater', () => {
|
|
19
|
-
it('exists', () => {
|
|
20
|
-
expect(solidLogicSingleton.store.updater).toBeInstanceOf(Object)
|
|
21
|
-
})
|
|
22
|
-
})
|
|
23
|
-
|
|
24
|
-
describe('authn', () => {
|
|
25
|
-
it('exists', () => {
|
|
26
|
-
expect(solidLogicSingleton.authn).toBeInstanceOf(Object)
|
|
27
|
-
})
|
|
28
|
-
})
|
|
29
|
-
|