Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
baseNode(uri, writer, title, description, nodeType, centerNode) {
if (!writer || !nodeType || !uri) {
throw new Error('baseNode: not enough arguments')
}
if (title) {
writer.addTriple($rdf.sym(uri), PRED.title, $rdf.literal(title))
}
if (description) {
writer.addTriple(
$rdf.sym(uri),
PRED.description,
$rdf.literal(description)
)
}
writer.addTriple($rdf.sym(uri), PRED.storage, $rdf.sym(centerNode.storage))
writer.addTriple($rdf.sym(uri), PRED.maker, $rdf.sym(centerNode.uri))
// TODO
if (nodeType === 'image') {
writer.addTriple($rdf.sym(uri), PRED.type, PRED.Image)
} else {
writer.addTriple($rdf.sym(uri), PRED.type, PRED.Document)
}
return writer
}
var $rdf = require("rdflib");
var rdfquery = require("./rdfquery");
var T = rdfquery.T;
var errorHandler = require("debug")("rdflib-graph::error");
// Monkey Patching rdflib, Literals, BlankNodes and NamedNodes
var exLiteral = $rdf.literal("a", "de");
Object.defineProperty(Object.getPrototypeOf(exLiteral), "lex", { get: function () { return this.value } });
Object.getPrototypeOf(exLiteral).isBlankNode = function () { return false };
Object.getPrototypeOf(exLiteral).isLiteral = function () { return true };
Object.getPrototypeOf(exLiteral).isURI = function () { return false };
var exBlankNode = $rdf.blankNode();
Object.getPrototypeOf(exBlankNode).isBlankNode = function () { return true };
Object.getPrototypeOf(exBlankNode).isLiteral = function () { return false };
Object.getPrototypeOf(exBlankNode).isURI = function () { return false };
var exNamedNode = $rdf.namedNode("urn:x-dummy");
Object.getPrototypeOf(exNamedNode).isBlankNode = function () { return false };
Object.getPrototypeOf(exNamedNode).isLiteral = function () { return false };
Object.getPrototypeOf(exNamedNode).isURI = function () { return true };
setSubject(uri, oldSubject, newSubject) {
const oldTriple = $rdf.st('', PRED.title, $rdf.literal(oldSubject))
const newTriple = $rdf.st('', PRED.title, $rdf.literal(newSubject))
return this.http.patch(uri, [oldTriple], [newTriple])
}
addCertKeyToGraph (certificate, graph) {
let webId = rdf.namedNode(certificate.webId)
let key = rdf.namedNode(certificate.keyUri)
let timeCreated = rdf.literal(certificate.date.toISOString(), ns.xsd('dateTime'))
let modulus = rdf.literal(certificate.modulus, ns.xsd('hexBinary'))
let exponent = rdf.literal(certificate.exponent, ns.xsd('int'))
let title = rdf.literal('Created by solid-server')
let label = rdf.literal(certificate.commonName)
graph.add(webId, ns.cert('key'), key)
graph.add(key, ns.rdf('type'), ns.cert('RSAPublicKey'))
graph.add(key, ns.dct('title'), title)
graph.add(key, ns.rdfs('label'), label)
graph.add(key, ns.dct('created'), timeCreated)
graph.add(key, ns.cert('modulus'), modulus)
graph.add(key, ns.cert('exponent'), exponent)
return graph
}
addCertKeyToGraph (certificate, graph) {
let webId = rdf.namedNode(certificate.webId)
let key = rdf.namedNode(certificate.keyUri)
let timeCreated = rdf.literal(certificate.date.toISOString(), ns.xsd('dateTime'))
let modulus = rdf.literal(certificate.modulus, ns.xsd('hexBinary'))
let exponent = rdf.literal(certificate.exponent, ns.xsd('int'))
let title = rdf.literal('Created by solid-server')
let label = rdf.literal(certificate.commonName)
graph.add(webId, ns.cert('key'), key)
graph.add(key, ns.rdf('type'), ns.cert('RSAPublicKey'))
graph.add(key, ns.dct('title'), title)
graph.add(key, ns.rdfs('label'), label)
graph.add(key, ns.dct('created'), timeCreated)
graph.add(key, ns.cert('modulus'), modulus)
graph.add(key, ns.cert('exponent'), exponent)
return graph
}
addCertKeyToGraph (certificate, graph) {
let webId = rdf.namedNode(certificate.webId)
let key = rdf.namedNode(certificate.keyUri)
let timeCreated = rdf.literal(certificate.date.toISOString(), ns.xsd('dateTime'))
let modulus = rdf.literal(certificate.modulus, ns.xsd('hexBinary'))
let exponent = rdf.literal(certificate.exponent, ns.xsd('int'))
let title = rdf.literal('Created by solid-server')
let label = rdf.literal(certificate.commonName)
graph.add(webId, ns.cert('key'), key)
graph.add(key, ns.rdf('type'), ns.cert('RSAPublicKey'))
graph.add(key, ns.dct('title'), title)
graph.add(key, ns.rdfs('label'), label)
graph.add(key, ns.dct('created'), timeCreated)
graph.add(key, ns.cert('modulus'), modulus)
graph.add(key, ns.cert('exponent'), exponent)
return graph
}
const updatePromises = [this.group.doc(), groupIndex].map(namedGraph => {
const oldNameStatements = kb.match(
this.group,
ns.vcard('fn'),
null,
namedGraph
)
const newNameStatement = rdf.st(
this.group,
ns.vcard('fn'),
rdf.literal(name)
)
return patch(namedGraph.value, {
toDel: oldNameStatements,
toIns: [newNameStatement]
}).then(_solidResponse => {
kb.removeStatements(oldNameStatements)
newNameStatement.why = namedGraph
kb.add(newNameStatement)
})
})
return Promise.all(updatePromises)
addCertKeyToGraph (certificate, graph) {
let webId = rdf.namedNode(certificate.webId)
let key = rdf.namedNode(certificate.keyUri)
let timeCreated = rdf.literal(certificate.date.toISOString(), ns.xsd('dateTime'))
let modulus = rdf.literal(certificate.modulus, ns.xsd('hexBinary'))
let exponent = rdf.literal(certificate.exponent, ns.xsd('int'))
let title = rdf.literal('Created by solid-server')
let label = rdf.literal(certificate.commonName)
graph.add(webId, ns.cert('key'), key)
graph.add(key, ns.rdf('type'), ns.cert('RSAPublicKey'))
graph.add(key, ns.dct('title'), title)
graph.add(key, ns.rdfs('label'), label)
graph.add(key, ns.dct('created'), timeCreated)
graph.add(key, ns.cert('modulus'), modulus)
graph.add(key, ns.cert('exponent'), exponent)
return graph
}