-
Notifications
You must be signed in to change notification settings - Fork 5
/
setup.js
31 lines (27 loc) · 1.14 KB
/
setup.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
const fetch = require('node-fetch');
const { getAuthFetcher, getNodeSolidServerCookie } = require('solid-auth-fetcher');
const oidcIssuer = 'https://solidcommunity.net';
const nssUsername = 'solidtestsuite';
const nssPassword = 'Testing123';
const origin = 'https://tester';
const webId = 'https://solidtestsuite.solidcommunity.net/profile/card#me';
async function run(url) {
console.log('Getting cookie', { oidcIssuer, nssUsername, nssPassword });
const cookie = await getNodeSolidServerCookie(oidcIssuer, nssUsername, nssPassword);
console.log('Getting fetcher', { oidcIssuer, cookie, origin });
const fetcher = await getAuthFetcher(oidcIssuer, cookie, origin);
console.log('Fetching', { url });
const rootAclDoc = '@prefix acl: <http://www.w3.org/ns/auth/acl#>. ' +
`<#owner> a acl:Authorization ; acl:agent <${webId}> ; ` +
'acl:accessTo </>; acl:default </>; acl:mode acl:Read, acl:Write, acl:Control .';
const result = await fetcher.fetch(url, {
method : 'PUT',
body: rootAclDoc,
headers: {
'Content-Type': 'text/turtle'
}
});
console.log(result.status, await result.text());
}
// ...
run(process.argv[2]);