Skip to content

Commit

Permalink
Audit fixes, RDF library upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
cykoder committed Nov 29, 2024
1 parent 6077491 commit 923252f
Show file tree
Hide file tree
Showing 6 changed files with 3,337 additions and 2,480 deletions.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@
],
"dependencies": {},
"devDependencies": {
"turbo": "2.0.5",
"@changesets/cli": "^2.x.x",
"@babel/cli": "^7.24.1",
"@babel/core": "^7.24.3",
"@babel/node": "^7.23.9",
"@babel/plugin-transform-modules-commonjs": "^7.24.1",
"@babel/preset-env": "^7.24.3"
"@babel/preset-env": "^7.24.3",
"@changesets/cli": "^2.x.x",
"turbo": "2.0.5"
},
"packageManager": "[email protected]",
"scripts": {
Expand Down
4 changes: 2 additions & 2 deletions packages/credential-sdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@
"node": ">=18.0.0"
},
"dependencies": {
"@comunica/actor-init-sparql-rdfjs": "^1.22.3",
"@comunica/query-sparql-rdfjs": "^4.0.2",
"@digitalcredentials/vc-status-list": "^8.0.0",
"@docknetwork/crypto-wasm-ts": "^0.63.0",
"@juanelas/base64": "^1.1.5",
"@sphereon/ssi-sdk-ext.did-resolver-jwk": "^0.25.0",
"@sphereon/ssi-sdk-ext.did-resolver-jwk": "^0.26.0",
"@stablelib/ed25519": "^1.0.0",
"@subsquid/ss58-codec": "latest",
"@transmute/json-web-signature": "^0.7.0-unstable.82",
Expand Down
10 changes: 5 additions & 5 deletions packages/credential-sdk/src/rdf-and-cd/rdf.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,17 +66,17 @@ export async function queryNextLookup(claimgraph, query, engine) {

// Query the engine, if querying multiple times user should
// pass engine parameter for optimal performance
const result = await engine.query(query, { sources: [store] });
const bindingsStream = await engine.queryBindings(query, { sources: [store] });

// Get bindings from query
const bindings = await result.bindings();
const bindings = await bindingsStream.toArray();

// Convert bindings to claimgraph format using lookupNext variable
bindings.forEach((b) => assert(
b.get('?lookupNext') !== undefined,
"Query for next lookup must always bind '?lookupNext'",
b.get('lookupNext') !== undefined,
"Query for next lookup must always bind 'lookupNext'",
));
return bindings.map((binding) => fromJsonldjsNode(binding.get('?lookupNext')));
return bindings.map((binding) => fromJsonldjsNode(binding.get('lookupNext')));
}

/**
Expand Down
4 changes: 2 additions & 2 deletions packages/credential-sdk/tests/crawl.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { newEngine } from "@comunica/actor-init-sparql-rdfjs";
import { QueryEngine } from "@comunica/query-sparql-rdfjs";

import { crawl } from "../src/rdf-and-cd";
import { ANYCLAIM, MAYCLAIM, MAYCLAIM_DEF_1 } from "../src/rdf-and-cd";
Expand Down Expand Up @@ -72,7 +72,7 @@ describe("Crawler unit tests", () => {
RULES,
CURIOSITY,
resolveGraph,
newEngine()
new QueryEngine()
);
expect(allFacts).toEqual([
[
Expand Down
6 changes: 3 additions & 3 deletions packages/credential-sdk/tests/rdf-turtle.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { newEngine } from "@comunica/actor-init-sparql-rdfjs";
import { QueryEngine } from "@comunica/query-sparql-rdfjs";
import { parseRDFDocument, queryNextLookup } from "../src/rdf-and-cd";

const rdfInputs = [
Expand Down Expand Up @@ -48,15 +48,15 @@ const claimgraph = [

describe("RDF SPARQL", () => {
test("Can query an RDF source (dbpedia)", async () => {
const engine = newEngine();
const engine = new QueryEngine();
const query =
"SELECT * { ?s ?p <http://dbpedia.org/resource/Belgium>. ?s ?p ?lookupNext } LIMIT 2";
const newGraph = await queryNextLookup(dbpediaSource, query, engine);
expect(newGraph).toEqual([{ Iri: "http://dbpedia.org/resource/Belgium" }]);
});

test("Can query a claimgraph", async () => {
const engine = newEngine();
const engine = new QueryEngine();
const query = `prefix dockalpha: <http://rdf.dock.io/alpha/2021#>
select * {
?root dockalpha:mayClaim dockalpha:ANYCLAIM .
Expand Down
Loading

0 comments on commit 923252f

Please sign in to comment.