Skip to content

Commit

Permalink
MAIN: Fix warnings from dev dependencies (#156)
Browse files Browse the repository at this point in the history
* run yarn upgrade

* Update files with prettier 2.0 defaults

* Add override for karmatic minimist dependency
  • Loading branch information
Weetbix authored Mar 25, 2020
1 parent cc1526a commit 08832fd
Show file tree
Hide file tree
Showing 8 changed files with 1,669 additions and 1,772 deletions.
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
"@pika/plugin-standard-pkg": "^0.9.2",
"eslint": "^6.0.1",
"eslint-config-vivy": "^1.0.8",
"eslint-plugin-prettier": "^3.1.2",
"git-directory-deploy": "1.5.1",
"husky": "4.2.3",
"jsdoc": "^3.6.3",
Expand All @@ -54,7 +55,8 @@
},
"resolutions": {
"karmatic/karma-webpack": "^2.0.13",
"karmatic/karma/expand-braces/braces": "^2.3.2"
"karmatic/karma/expand-braces/braces": "^2.3.2",
"karmatic/karma/optimist/minimist": "^1.2.2"
},
"husky": {
"hooks": {
Expand Down
4 changes: 2 additions & 2 deletions src/lib/EHREncryption.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {
generateInitialVector,
arrayBufferToString,
stringToArrayBuffer
stringToArrayBuffer,
} from "./utilities";
import create from "./factory";

Expand Down Expand Up @@ -45,7 +45,7 @@ async function encryptKeyIv(publicKey, key, iv) {
const base64EncodedKey = transformKeyToBase64(aesExportedKey);
const jsonStringSecrets = JSON.stringify({
base64EncodedIV,
base64EncodedKey
base64EncodedKey,
});
const jsonArrayBuffer = stringToArrayBuffer(jsonStringSecrets);

Expand Down
42 changes: 21 additions & 21 deletions src/lib/factory.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import scrypt from "scrypt-async";

export default algorithm => {
export default (algorithm) => {
const types = ["aes-gcm", "rsa-oaep", "aes-cbc", "scrypt"];
const algorithmType = algorithm.toLowerCase();

Expand All @@ -15,7 +15,7 @@ export default algorithm => {
window.crypto.subtle.generateKey(
{
name: "AES-GCM",
length: 256
length: 256,
},
true,
["encrypt", "decrypt"]
Expand All @@ -25,7 +25,7 @@ export default algorithm => {
* @param key {arrayBuffer}
* @returns {PromiseLike<CryptoKey>}
*/
importKey: key =>
importKey: (key) =>
window.crypto.subtle.importKey(
"raw",
key,
Expand All @@ -38,7 +38,7 @@ export default algorithm => {
* @param key {CryptoKey}
* @returns {PromiseLike<ArrayBuffer>}
*/
exportKey: key => window.crypto.subtle.exportKey("raw", key),
exportKey: (key) => window.crypto.subtle.exportKey("raw", key),
/**
* @private
* @param key {CryptoKey}
Expand All @@ -50,7 +50,7 @@ export default algorithm => {
window.crypto.subtle.encrypt(
{
name: "AES-GCM",
iv
iv,
},
key,
data
Expand All @@ -66,11 +66,11 @@ export default algorithm => {
window.crypto.subtle.decrypt(
{
name: "AES-GCM",
iv: new Uint8Array(iv)
iv: new Uint8Array(iv),
},
key,
data
)
),
};
case "rsa-oaep":
return {
Expand All @@ -85,7 +85,7 @@ export default algorithm => {
name: "RSA-OAEP",
modulusLength: bits,
publicExponent: new Uint8Array([0x01, 0x00, 0x01]),
hash: { name: "SHA-256" }
hash: { name: "SHA-256" },
},
false,
["encrypt", "decrypt"]
Expand All @@ -95,7 +95,7 @@ export default algorithm => {
* @param key {arrayBuffer}
* @returns {PromiseLike<CryptoKey>}
*/
importKey: key =>
importKey: (key) =>
window.crypto.subtle.importKey(
"spki",
key,
Expand All @@ -108,7 +108,7 @@ export default algorithm => {
* @param publicKey {CryptoKey}
* @returns {PromiseLike<ArrayBuffer>}
*/
exportKey: publicKey =>
exportKey: (publicKey) =>
window.crypto.subtle.exportKey("spki", publicKey),
/**
* @private
Expand All @@ -129,7 +129,7 @@ export default algorithm => {
{ name: "RSA-OAEP" },
privateKey,
arrayBuffer
)
),
};
case "aes-cbc":
return {
Expand All @@ -141,7 +141,7 @@ export default algorithm => {
window.crypto.subtle.generateKey(
{
name: "AES-CBC",
length: 256
length: 256,
},
true,
["encrypt", "decrypt"]
Expand All @@ -151,7 +151,7 @@ export default algorithm => {
* @param key {arrayBuffer}
* @returns {PromiseLike<CryptoKey>}
*/
importKey: key =>
importKey: (key) =>
window.crypto.subtle.importKey(
"raw",
key,
Expand All @@ -164,7 +164,7 @@ export default algorithm => {
* @param key {CryptoKey}
* @returns {PromiseLike<ArrayBuffer>}
*/
exportKey: key => window.crypto.subtle.exportKey("raw", key),
exportKey: (key) => window.crypto.subtle.exportKey("raw", key),
/**
* @private
* @param key {CryptoKey}
Expand All @@ -176,7 +176,7 @@ export default algorithm => {
window.crypto.subtle.encrypt(
{
name: "AES-CBC",
iv
iv,
},
key,
data
Expand All @@ -192,11 +192,11 @@ export default algorithm => {
window.crypto.subtle.decrypt(
{
name: "AES-CBC",
iv: new Uint8Array(iv)
iv: new Uint8Array(iv),
},
key,
data
)
),
};
case "scrypt":
return {
Expand All @@ -217,19 +217,19 @@ export default algorithm => {
r: 8,
p: 1,
dkLen: 32,
...options
...options,
},
key => {
(key) => {
derivedKey = key;
}
);
return derivedKey;
}
},
};
default:
throw new Error(
`The algorithm you requested is not currently supported. Supported are ${types.map(
type => ` ${type}`
(type) => ` ${type}`
)}.`
);
}
Expand Down
6 changes: 3 additions & 3 deletions src/lib/utilities.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export const encode = data => btoa(data);
export const encode = (data) => btoa(data);

export const decode = data => atob(data);
export const decode = (data) => atob(data);

export function stringToArrayBuffer(data) {
const arrayLength = data.length;
Expand Down Expand Up @@ -64,7 +64,7 @@ export const concatenateUint8Arrays = (...arrays) => {
return result;
};

export const arrayBufferToHex = buffer => {
export const arrayBufferToHex = (buffer) => {
if (buffer.buffer instanceof ArrayBuffer && buffer.byteLength !== undefined) {
throw new TypeError("Expected input to be an ArrayBuffer");
}
Expand Down
4 changes: 2 additions & 2 deletions src/tests/EHREncryption.contract.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
arrayBufferToString,
base64ToArrayBuffer,
stringToArrayBuffer,
toArrayBuffer
toArrayBuffer,
} from "../lib/utilities";

describe("EHREncryption contract", () => {
Expand Down Expand Up @@ -57,7 +57,7 @@ describe("EHREncryption contract", () => {
const { cipherKey, data } = await encrypt(cryptoPublicKey, buffer);
const arrayBufferData = await decrypt(cryptoPrivateKey, {
cipherKey,
data
data,
});

expect(arrayBufferToString(arrayBufferData)).toEqual(originalString);
Expand Down
2 changes: 1 addition & 1 deletion src/tests/factory.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
stringToArrayBuffer,
generateInitialVector,
toPem,
toArrayBuffer
toArrayBuffer,
} from "../lib/utilities";

describe("aes-gcm", () => {
Expand Down
2 changes: 1 addition & 1 deletion src/tests/utilities.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {
stringToArrayBuffer,
arrayBufferToString,
arrayBufferToHex
arrayBufferToHex,
} from "../lib/utilities";

describe("basic utilities", () => {
Expand Down
Loading

0 comments on commit 08832fd

Please sign in to comment.