-
Notifications
You must be signed in to change notification settings - Fork 5
/
patch.js
29 lines (26 loc) · 1017 Bytes
/
patch.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
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';
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 result = await fetcher.fetch(url, {
method: 'PATCH',
headers: {
"Content-Type": "text/n3",
},
body:
"@prefix solid: <http://www.w3.org/ns/solid/terms#>.\n" +
"<#patch> a solid:InsertDeletePatch;\n" +
" solid:inserts { <#patch> <#to> <#create> .}.\n",
});
console.log(result.status, await result.text());
}
// ...
run(process.argv[2]);