@trust/webcrypto
Advanced tools
Comparing version 0.5.0 to 0.6.0
{ | ||
"name": "@trust/webcrypto", | ||
"version": "0.5.0", | ||
"version": "0.6.0", | ||
"description": "WebCrypto API for Node.js", | ||
@@ -10,4 +10,5 @@ "main": "src/index.js", | ||
"scripts": { | ||
"test": "mocha -w", | ||
"jsdoc": "jsdoc -c jsdoc.json -r" | ||
"test": "nyc _mocha test", | ||
"jsdoc": "jsdoc -c jsdoc.json -r", | ||
"coverage": "nyc --reporter=lcov _mocha test" | ||
}, | ||
@@ -28,3 +29,3 @@ "repository": { | ||
"dependencies": { | ||
"@trust/keyto": "^0.3.0", | ||
"@trust/keyto": "^0.3.1", | ||
"base64url": "^2.0.0", | ||
@@ -36,5 +37,7 @@ "node-rsa": "^0.4.0", | ||
"chai": "^3.5.0", | ||
"codecov": "^2.3.0", | ||
"jsdoc": "^3.4.3", | ||
"mocha": "^3.2.0" | ||
"mocha": "^3.2.0", | ||
"nyc": "^11.2.1" | ||
} | ||
} |
# W3C Web Cryptography API _(@trust/webcrypto)_ | ||
[![standard-readme compliant](https://img.shields.io/badge/readme%20style-standard-brightgreen.svg?style=flat-square)](https://github.com/RichardLitt/standard-readme) | ||
[![Build Status](https://travis-ci.org/anvilresearch/webcrypto.svg?branch=master)](https://travis-ci.org/anvilresearch/webcrypto) | ||
@@ -89,3 +90,3 @@ > W3C Web Cryptography API for Node.js | ||
|AES-GCM | ✔ | ✔ | | | | ✔ | | | ✔ | ✔ | ✔ | ✔ | | ||
|AES-KW | | | | | | _ | | | _ | _ | _ | _ | | ||
|AES-KW | | | | | | ✔ | | | ✔ | ✔ | ✔ | ✔ | | ||
|HMAC | | | ✔ | ✔ | | ✔ | | | ✔ | ✔ | | | | ||
@@ -92,0 +93,0 @@ |SHA-1 | | | | | ✔ | | | | | | | | |
@@ -86,3 +86,3 @@ /** | ||
//supportedAlgorithms.define('AES-CFB', 'generateKey', ) | ||
//supportedAlgorithms.define('AES-KW', 'generateKey', ) | ||
supportedAlgorithms.define('AES-KW', 'generateKey', '../algorithms/AES-KW') | ||
supportedAlgorithms.define('HMAC', 'generateKey', '../algorithms/HMAC') | ||
@@ -105,3 +105,3 @@ //supportedAlgorithms.define('DH', 'generateKey', ) | ||
//supportedAlgorithms.define('AES-CFB', 'importKey', ) | ||
//supportedAlgorithms.define('AES-KW', 'importKey', ) | ||
supportedAlgorithms.define('AES-KW', 'importKey', '../algorithms/AES-KW') | ||
supportedAlgorithms.define('HMAC', 'importKey', '../algorithms/HMAC') | ||
@@ -126,3 +126,3 @@ //supportedAlgorithms.define('DH', 'importKey', ) | ||
//supportedAlgorithms.define('AES-CFB', 'exportKey', ) | ||
//supportedAlgorithms.define('AES-KW', 'exportKey', ) | ||
supportedAlgorithms.define('AES-KW', 'exportKey', '../algorithms/AES-KW') | ||
supportedAlgorithms.define('HMAC', 'exportKey', '../algorithms/HMAC') | ||
@@ -139,3 +139,3 @@ //supportedAlgorithms.define('DH', 'exportKey', ) | ||
//supportedAlgorithms.define('AES-CFB', 'wrapKey', ) | ||
//supportedAlgorithms.define('AES-KW', 'wrapKey', ) | ||
supportedAlgorithms.define('AES-KW', 'wrapKey', '../algorithms/AES-KW') | ||
@@ -150,3 +150,3 @@ /** | ||
//supportedAlgorithms.define('AES-CFB', 'unwrapKey', ) | ||
//supportedAlgorithms.define('AES-KW', 'unwrapKey', ) | ||
supportedAlgorithms.define('AES-KW', 'unwrapKey', '../algorithms/AES-KW') | ||
@@ -156,2 +156,2 @@ /** | ||
*/ | ||
module.exports = supportedAlgorithms | ||
module.exports = supportedAlgorithms |
@@ -419,3 +419,3 @@ /** | ||
if (normalizedAlgorithm['wrapKey']){ | ||
return normalizedAlgorithm.wrapKey(wrapAlgorithm,wrappingKey,new Uint8Array(bytes)) | ||
return normalizedAlgorithm.wrapKey(format,bytes,wrappingKey,wrapAlgorithm) | ||
} | ||
@@ -492,6 +492,6 @@ // 14.2. Otherwise try with encrypt | ||
let keyPromise | ||
let key | ||
// 13.1. If the normalizedAlgorithm supports unwrapKey then use it | ||
if (normalizedAlgorithm['unwrapKey']){ | ||
keyPromise = this.unwrapKey(unwrapAlgorithm,unwrappingKey,wrappedKey) | ||
key = normalizedAlgorithm.unwrapKey(format,wrappedKey,unwrappingKey,unwrapAlgorithm,unwrappedKeyAlgorithm,extractable,keyUsages) | ||
} | ||
@@ -501,3 +501,3 @@ | ||
else if (normalizedAlgorithm['decrypt']){ | ||
keyPromise = this.decrypt(unwrapAlgorithm,unwrappingKey,wrappedKey) | ||
key = normalizedAlgorithm.decrypt(unwrapAlgorithm,unwrappingKey,wrappedKey) | ||
} | ||
@@ -509,37 +509,23 @@ | ||
} | ||
let bytes | ||
// 14.1. If format is "raw", "pkcs8", or "spki": | ||
if (["raw", "pkcs8","spki"].includes(format)) { | ||
bytes = key | ||
} | ||
return keyPromise.then( key => { | ||
let bytes | ||
// 14.1. If format is "raw", "pkcs8", or "spki": | ||
if (["raw", "pkcs8","spki"].includes(format)) { | ||
bytes = key | ||
} | ||
// 14.2. If format is "jwk" | ||
else if (format === "jwk"){ | ||
bytes = JSON.parse(new TextDecoder().decode(key)) | ||
} | ||
// 14.2. If format is "jwk" | ||
else if (format === "jwk"){ | ||
bytes = JSON.parse(new TextDecoder().decode(key)) | ||
} | ||
// 15. Import the resulting unwrapped content | ||
// importKey (format, keyData, algorithm, extractable, keyUsages) | ||
return normalizedKeyAlgorithm.importKey(format, | ||
bytes, | ||
unwrappedKeyAlgorithm, | ||
extractable, | ||
keyUsages) | ||
}).then(result => { | ||
// 16. Validate type parameters and usage length | ||
if ((result.type === "secret" || result.type === "private") && result.usages.length === 0){ | ||
throw new SyntaxError("Usages cannot be empty") | ||
} | ||
// 17. Set extractable | ||
result.extractable = extractable | ||
// 18. Set usages | ||
result.usages = keyUsages | ||
// 19. Resolve promise | ||
return resolve(result) | ||
}).catch(console.log) | ||
// 15. Import the resulting unwrapped content | ||
// 16-18. Ommitted because it is handled by importKey interface | ||
let result = normalizedKeyAlgorithm.importKey(format, | ||
bytes, | ||
unwrappedKeyAlgorithm, | ||
extractable, | ||
keyUsages) | ||
// 19. Resolve the result | ||
return resolve(result) | ||
} catch (error) { | ||
@@ -546,0 +532,0 @@ return reject(error) |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
311785
93
9507
174
4
5
Updated@trust/keyto@^0.3.1