Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

rdfjs-di

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rdfjs-di - npm Package Compare versions

Comparing version 0.1.2 to 0.1.3

24

dist/lib/crypto_utils.js

@@ -19,3 +19,3 @@ "use strict";

const types_1 = require("./types");
const base58 = require("./encodings/base58/index");
const base_1 = require("@scure/base");
/***********************************************************************************

@@ -32,3 +32,3 @@ *

/**
* Mapping between the "alg values in the JWK instance and the necessary
* Mapping between the "alg" values in the JWK instance and the necessary
* terms for the WebCrypto API

@@ -45,3 +45,2 @@ */

*
* @param report
* @param key

@@ -78,7 +77,6 @@ * @returns

*
* @param report
* @param key
* @returns
*/
function algorithmDataCR(report, key) {
function algorithmDataCR(key) {
const alg = key.algorithm;

@@ -155,3 +153,3 @@ switch (alg.name) {

// The crypto algorithm to be used with this key:
const algorithm = algorithmDataCR(report, privateKey);
const algorithm = algorithmDataCR(privateKey);
if (algorithm === null) {

@@ -163,4 +161,4 @@ return null;

const rawSignature = await crypto.subtle.sign(algorithm, privateKey, rawMessage);
// Turn the the signature into Base64URL, and then into multicode
return `z${base58.encode(new Uint8Array(rawSignature))}`;
// Turn the signature into Base64URL, and then into multicode
return `z${base_1.base58.encode(new Uint8Array(rawSignature))}`;
// return `u${arrayBufferToBase64Url(rawSignature)}`;

@@ -192,6 +190,6 @@ }

}
const rawSignature = base58.decode(signature.slice(1));
const rawSignature = base_1.base58.decode(signature.slice(1));
// const rawSignature: ArrayBuffer = base64UrlToArrayBuffer(signature.slice(1));
// get the algorithm details
const algorithm = algorithmDataCR(report, publicKey);
const algorithm = algorithmDataCR(publicKey);
if (algorithm === null) {

@@ -202,7 +200,7 @@ return false;

try {
const retval = await crypto.subtle.verify(algorithm, publicKey, rawSignature, rawMessage);
if (retval === false) {
const output = await crypto.subtle.verify(algorithm, publicKey, rawSignature, rawMessage);
if (output === false) {
report.errors.push(new types.Proof_Verification_Error(`Signature ${signature} is invalid`));
}
return retval;
return output;
}

@@ -209,0 +207,0 @@ catch (e) {

@@ -36,11 +36,11 @@ "use strict";

const quad_to_nquad = (quad) => {
const retval = n3Writer.quadToString(quad.subject, quad.predicate, quad.object, quad.graph);
const output = n3Writer.quadToString(quad.subject, quad.predicate, quad.object, quad.graph);
// deno-lint-ignore no-regex-spaces
return retval.endsWith(' .') ? retval.replace(/ .$/, ' .') : retval;
return output.endsWith(' .') ? output.replace(/ {2}.$/, ' .') : output;
};
const retval = [];
const output = [];
for (const quad of quads) {
retval.push(quad_to_nquad(quad));
output.push(quad_to_nquad(quad));
}
return retval;
return output;
}

@@ -47,0 +47,0 @@ /**

@@ -55,2 +55,3 @@ "use strict";

* @param proofGraph
* @param key
* @returns

@@ -65,3 +66,2 @@ */

if (q.predicate.value === exports.sec_proofValue.value) {
continue;
}

@@ -95,7 +95,7 @@ else if (q.predicate.value === exports.sec_publicKeyJwk.value) {

const addKeyResource = async (cryptoKey, proofGraph, keyResource) => {
let retval = [];
let output;
if (cryptoKey.algorithm.name === "ECDSA" || cryptoKey.algorithm.name === "Ed25519") {
// We are in multikey land...
const multikey = await mkwc.cryptoToMultikey(cryptoKey);
retval = [
output = [
quad(proofGraph, (0, exports.sec_prefix)('cryptosuite'), literal(cryptosuite)),

@@ -108,3 +108,3 @@ quad(keyResource, exports.rdf_type, (0, exports.sec_prefix)('Multikey')),

const jwkKey = await crypto.subtle.exportKey("jwk", cryptoKey);
retval = [
output = [
quad(proofGraph, (0, exports.sec_prefix)('cryptosuite'), literal(cryptosuite)),

@@ -115,3 +115,3 @@ quad(keyResource, exports.rdf_type, (0, exports.sec_prefix)('JsonWebKey')),

}
return retval;
return output;
};

@@ -164,3 +164,2 @@ // Create a proof graph. Just a boring set of quad generations...

exports.generateAProofGraph = generateAProofGraph;
;
/**

@@ -183,3 +182,3 @@ * Check a single proof graph, ie, whether the included signature corresponds to the hash value.

* @param proof - the proof graph
* @param proofId - Id of the proof graph, if known; used in the error reports only
* @param proofId - id of the proof graph, if known; used in the error reports only
* @returns

@@ -208,3 +207,2 @@ */

}
;
// Retrieve the proof value

@@ -211,0 +209,0 @@ const proofValue = ((store) => {

@@ -18,3 +18,3 @@ /**

/**
* Some additional meta data that can be stored with the keys, and then re-appear as part of the proof graphs
* Some additional metadata that can be stored with the keys, and then re-appear as part of the proof graphs
*/

@@ -43,3 +43,3 @@ export interface KeyMetadata {

detail: string;
constructor(detail: string, title: string, code: number);
protected constructor(detail: string, title: string, code: number);
}

@@ -46,0 +46,0 @@ export interface Errors {

@@ -18,3 +18,3 @@ /**

/**
* A simple namespace handler; I was not sure I fully understood the n3 version, and
* A simple namespace handler; I was not sure that I fully understood the n3 version, and
* I found no reliable documentation (...)

@@ -50,4 +50,4 @@ *

/**
* The general structure for a Proof using n3.Store specifically; it also has a `perviousProof` key.
* This subclass is used when key chains or sets are extracted from an embedded proof.
* The general structure for a Proof using n3.Store specifically; it also has a `previousProof` key.
* This subclass is used when keychains or sets are extracted from an embedded proof.
*/

@@ -141,3 +141,3 @@ export interface ProofStore extends Proof {

* If the key belongs to an ECDSA key, and the corresponding curve is P-384, then
* SHA-384 must be used by the algorithm. Hence the presence of the second
* SHA-384 must be used by the algorithm. That is the reason for the presence of the second
* argument in the call.

@@ -144,0 +144,0 @@ *

@@ -17,2 +17,3 @@ "use strict";

const n3 = require("n3");
// import * as debug from './debug';
const { namedNode, quad } = n3.DataFactory;

@@ -23,3 +24,3 @@ /***************************************************************************************

/**
* A simple namespace handler; I was not sure I fully understood the n3 version, and
* A simple namespace handler; I was not sure that I fully understood the n3 version, and
* I found no reliable documentation (...)

@@ -44,5 +45,5 @@ *

else {
const retval = namedNode(`${this._base}${local}`);
this._mapping[local] = retval;
return retval;
const output = namedNode(`${this._base}${local}`);
this._mapping[local] = output;
return output;
}

@@ -52,6 +53,5 @@ }

const mapping = new prefix(uri);
const get_value = (local) => {
return (local) => {
return mapping.value(local);
};
return get_value;
}

@@ -212,3 +212,3 @@ exports.createPrefix = createPrefix;

* If the key belongs to an ECDSA key, and the corresponding curve is P-384, then
* SHA-384 must be used by the algorithm. Hence the presence of the second
* SHA-384 must be used by the algorithm. That is the reason for the presence of the second
* argument in the call.

@@ -227,4 +227,3 @@ *

const canonical_quads = await rdfc10.canonicalize(dataset);
const datasetHash = await rdfc10.hash(canonical_quads);
return datasetHash;
return await rdfc10.hash(canonical_quads);
}

@@ -243,6 +242,6 @@ exports.calculateDatasetHash = calculateDatasetHash;

function copyToStore(dataset) {
const retval = new n3.Store();
const output = new n3.Store();
for (const q of dataset)
retval.add(q);
return retval;
output.add(q);
return output;
}

@@ -287,3 +286,3 @@ exports.copyToStore = copyToStore;

};
const retval = new n3.Store();
const output = new n3.Store();
for (const q of toTransform) {

@@ -293,5 +292,5 @@ let subject = newTerm(q.subject);

let object = newTerm(q.object);
retval.add(quad(subject, predicate, object));
output.add(quad(subject, predicate, object));
}
return retval;
return output;
}

@@ -298,0 +297,0 @@ exports.refactorBnodes = refactorBnodes;

{
"name": "rdfjs-di",
"version": "0.1.2",
"date": "2024-11-12",
"version": "0.1.3",
"date": "2024-11-19",
"description": "Secure an RDF Dataset through VC's Data Integrity",

@@ -9,2 +9,3 @@ "main": "dist/index.js",

"test": "./node_modules/.bin/ts-node testing/run/main.ts",
"full_test": "./node_modules/.bin/ts-node testing/run/main.ts -vcea",
"crkey": "./node_modules/.bin/ts-node testing/run/createKeys.ts",

@@ -11,0 +12,0 @@ "crypto": "./node_modules/.bin/ts-node testing/run/testCrypto.ts",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc