Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// This module of solid-ui has a main quadstore for the app to use
//
var rdf = require('rdflib')
var store = (module.exports = rdf.graph()) // Make a Quad store
rdf.fetcher(store) // Attach a web I/O module, store.fetcher
store.updater = new rdf.UpdateManager(store) // Add real-time live updates store.updater
console.log('Unique quadstore initialized.')
// ends
async function showLatestAuthor (authorContainer: HTMLElement) {
const latestAuthor = getLatestAuthor(store, subject)
if (latestAuthor) {
const fetcher = $rdf.fetcher(store, {})
await fetcher.load(latestAuthor.uri)
const [nameStatement] = store.statementsMatching(latestAuthor, ns.vcard('fn'), null, null, true)
authorContainer.appendChild(document.createTextNode('Latest author: '))
const authorLink = document.createElement('a')
authorLink.href = latestAuthor.uri
const name = (nameStatement) ? nameStatement.object.value : latestAuthor.uri
authorLink.textContent = name
authorLink.title = `View the profile of ${name}`
authorLink.addEventListener('click', (event) => {
event.preventDefault()
visitNode(latestAuthor)
})
authorContainer.appendChild(authorLink)
}
}
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
latestAuthor = data_1.getLatestAuthor(store, subject);
if (!latestAuthor) return [3 /*break*/, 2];
fetcher = $rdf.fetcher(store, {});
return [4 /*yield*/, fetcher.load(latestAuthor.uri)];
case 1:
_a.sent();
nameStatement = store.statementsMatching(latestAuthor, ns.vcard('fn'), null, null, true)[0];
authorContainer.appendChild(document.createTextNode('Latest author: '));
authorLink = document.createElement('a');
authorLink.href = latestAuthor.uri;
name_1 = (nameStatement) ? nameStatement.object.value : latestAuthor.uri;
authorLink.textContent = name_1;
authorLink.title = "View the profile of " + name_1;
authorLink.addEventListener('click', function (event) {
event.preventDefault();
visitNode(latestAuthor);
});
authorContainer.appendChild(authorLink);
_a.label = 2;
function discoverFromProfile (webId) {
const store = rdf.graph()
const fetcher = rdf.fetcher(store)
return fetcher.load(webId, { force: true })
.then(response => {
let providerTerm = rdf.namedNode('http://www.w3.org/ns/solid/terms#oidcIssuer')
let providerUri = store.anyValue(rdf.namedNode(webId), providerTerm)
return providerUri
}, err => {
let error = new Error(`Could not reach Web ID ${webId} to discover provider`)
error.cause = err
error.statusCode = 400
throw error
})
}
return new Promise((resolve, reject)=>{
let fetcher = new $rdf.fetcher( $rdf.graph() );
try {
fetcher.load(url).then( response => {
resolve( response.responseText )
})
} catch(err) { reject(err) }
})
}