Skip to content

Commit

Permalink
Re-generated the distribution
Browse files Browse the repository at this point in the history
  • Loading branch information
iherman committed Mar 8, 2024
1 parent bd64275 commit c9a3b83
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 22 deletions.
5 changes: 3 additions & 2 deletions dist/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@
*/
import * as rdf from '@rdfjs/types';
import { KeyData, VerificationResult } from './lib/types';
export { KeyData, VerificationResult, KeyMetadata, Cryptosuites } from './lib/types';
export { generateKey, KeyDetails } from './lib/crypto_utils';
export type { KeyData, VerificationResult, KeyMetadata, Cryptosuites } from './lib/types';
export type { KeyDetails } from './lib/crypto_utils';
export { generateKey } from './lib/crypto_utils';
/**
* Generate a (separate) proof graph (or graphs), per the DI spec. The signature is stored in
* multibase format, using base64url encoding. Keys are accepted, and stored in JWK format.
Expand Down
5 changes: 1 addition & 4 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,11 @@
* @packageDocumentation
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.verifyEmbeddedProofGraph = exports.embedProofGraph = exports.verifyProofGraph = exports.generateProofGraph = exports.generateKey = exports.Cryptosuites = void 0;
exports.verifyEmbeddedProofGraph = exports.embedProofGraph = exports.verifyProofGraph = exports.generateProofGraph = exports.generateKey = void 0;
const n3 = require("n3");
const types = require("./lib/types");
const utils_1 = require("./lib/utils");
const proof_utils_1 = require("./lib/proof_utils");
/* This file is also the "top level", so a number of exports are put here to be more friendly to users */
var types_1 = require("./lib/types");
Object.defineProperty(exports, "Cryptosuites", { enumerable: true, get: function () { return types_1.Cryptosuites; } });
var crypto_utils_1 = require("./lib/crypto_utils");
Object.defineProperty(exports, "generateKey", { enumerable: true, get: function () { return crypto_utils_1.generateKey; } });
// n3.DataFactory is a namespace with some functions...
Expand Down
34 changes: 20 additions & 14 deletions dist/lib/crypto_utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,6 @@ const RsaAlgs = {
*/
function algorithmData(report, key) {
switch (key.kty) {
case "EC": {
return {
name: "ECDSA",
namedCurve: key.crv,
hash: DEFAULT_HASH
};
}
case "RSA": {
try {
return RsaAlgs[key.alg];
Expand All @@ -63,6 +56,14 @@ function algorithmData(report, key) {
return null;
}
}
case "EC":
default: {
return {
name: "ECDSA",
namedCurve: key.crv,
hash: DEFAULT_HASH
};
}
}
}
/**
Expand Down Expand Up @@ -221,13 +222,18 @@ function cryptosuiteId(report, keyPair) {
return null;
}
const alg = algorithmData(report, keyPair.public);
switch (alg.name) {
case "ECDSA": return types_1.Cryptosuites.ecdsa;
case "RSA-PSS": return types_1.Cryptosuites.rsa_pss;
case "RSASSA-PKCS1-v1_5": return types_1.Cryptosuites.rsa_ssa;
default: {
report.errors.push(new types.Invalid_Verification_Method(`Unknown alg (${alg.name} in:\n ${JSON.stringify(keyPair, null, 4)})`));
return null;
if (alg === null) {
return null;
}
else {
switch (alg.name) {
case "ECDSA": return types_1.Cryptosuites.ecdsa;
case "RSA-PSS": return types_1.Cryptosuites.rsa_pss;
case "RSASSA-PKCS1-v1_5": return types_1.Cryptosuites.rsa_ssa;
default: {
report.errors.push(new types.Invalid_Verification_Method(`Unknown alg (${alg.name} in:\n ${JSON.stringify(keyPair, null, 4)})`));
return null;
}
}
}
}
Expand Down
11 changes: 10 additions & 1 deletion dist/lib/proof_utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,15 @@ async function generateAProofGraph(report, hashValue, keyData) {
retval.add(quad(keyResource, exports.sec_revoked, literal(keyData.revoked, exports.xsd_datetime)));
return retval;
};
return createProofGraph(await (0, crypto_utils_1.sign)(report, hashValue, keyData.private));
const signature = await (0, crypto_utils_1.sign)(report, hashValue, keyData.private);
if (signature === null) {
// An error has occurred during signature; details are in the report.
// No proof graph is generated
return new n3.Store();
}
else {
return createProofGraph(signature);
}
}
exports.generateAProofGraph = generateAProofGraph;
;
Expand Down Expand Up @@ -230,6 +238,7 @@ async function verifyAProofGraph(report, hash, proof, proofId) {
*/
async function verifyProofGraphs(report, hash, proofs) {
const allErrors = [];
// deno-lint-ignore require-await
const singleVerification = async (pr) => {
const singleReport = { errors: [], warnings: [] };
allErrors.push(singleReport);
Expand Down
5 changes: 4 additions & 1 deletion dist/lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ exports.DatasetMap = DatasetMap;
* @param obj
* @returns
*/
// deno-lint-ignore no-explicit-any
function isDatasetCore(obj) {
return obj.add !== undefined &&
obj.delete !== undefined &&
Expand All @@ -119,6 +120,7 @@ exports.isDatasetCore = isDatasetCore;
* @param obj
* @returns
*/
// deno-lint-ignore no-explicit-any
function isKeyData(obj) {
return obj.public !== undefined && obj.private !== undefined;
}
Expand Down Expand Up @@ -180,6 +182,7 @@ function write_quads(dataset) {
const writer = new n3.Writer({ prefixes: prefixes });
for (const q of dataset)
writer.addQuad(q);
writer.end((error, result) => console.log(result));
// deno-lint-ignore no-explicit-any
writer.end((_error, result) => console.log(result));
}
exports.write_quads = write_quads;

0 comments on commit c9a3b83

Please sign in to comment.