webcrypto-liner
Advanced tools
Comparing version 0.1.17 to 0.1.18
{ | ||
"name": "webcrypto-liner", | ||
"version": "0.1.17", | ||
"version": "0.1.18", | ||
"description": "A WebCrypto pollyfill that \"smooths out\" the rough-edges in existing User Agent implementations.", | ||
@@ -24,7 +24,8 @@ "main": "build/index.js", | ||
"elliptic": "*", | ||
"webcrypto-core": "^0.1.12" | ||
"webcrypto-core": "^0.1.13" | ||
}, | ||
"devDependencies": { | ||
"ts-loader": "^0.9.5", | ||
"typescript": "*" | ||
"typescript": "*", | ||
"webpack": "^1.14" | ||
}, | ||
@@ -31,0 +32,0 @@ "author": "PeculiarVentures", |
# webcrypto-liner | ||
[![license](https://img.shields.io/badge/license-MIT-green.svg?style=flat)](https://raw.githubusercontent.com/PeculiarVentures/webcrypto-liner/master/LICENSE) | ||
[![npm version](https://badge.fury.io/js/webcrypto-liner.svg)](https://badge.fury.io/js/webcrypto-liner) | ||
[![Build Status](https://travis-ci.org/PeculiarVentures/webcrypto-liner.svg?branch=master)](https://travis-ci.org/PeculiarVentures/webcrypto-liner) | ||
@@ -5,0 +6,0 @@ [![NPM](https://nodei.co/npm-dl/webcrypto-liner.png?months=2&height=2)](https://nodei.co/npm/webcrypto-liner/) |
@@ -116,3 +116,8 @@ import { AlgorithmError, AlgorithmNames, Base64Url, BaseCrypto, PrepareData } from "webcrypto-core"; | ||
} | ||
return verify(signature, data, key.key); | ||
try { | ||
return verify(signature, data, key.key); | ||
} catch (err) { | ||
console.warn(`Verify error: ${err.message}`); | ||
return false; | ||
} | ||
} | ||
@@ -133,3 +138,8 @@ case AlgorithmNames.RsaPSS.toLowerCase(): | ||
} | ||
return verify(signature, data, key.key, rsaAlg.saltLength); | ||
try { | ||
return verify(signature, data, key.key, rsaAlg.saltLength); | ||
} catch (err) { | ||
console.warn(`Verify error: ${err.message}`); | ||
return false; | ||
} | ||
default: | ||
@@ -239,3 +249,3 @@ throw new LinerError(LinerError.UNSUPPORTED_ALGORITHM, algorithm.name); | ||
const hash = (alg as any).hash as Algorithm; | ||
const hashSize = /(\d+)/.exec(hash.name) ![1]; | ||
const hashSize = /(\d+)/.exec(hash.name)![1]; | ||
switch (alg.name!.toUpperCase()) { | ||
@@ -242,0 +252,0 @@ case AlgorithmNames.RsaOAEP.toUpperCase(): |
@@ -32,3 +32,9 @@ // Core | ||
return crypto.subtle.exportKey("jwk", key) | ||
.then((jwk: any) => subtle.importKey("jwk", jwk, key.algorithm as Algorithm, true, key.usages)); | ||
.then((jwk: any) => { | ||
let alg = GetHashAlgorithm(key); | ||
if (alg) { | ||
alg = assign(alg, key.algorithm); | ||
} | ||
return subtle.importKey("jwk", jwk, alg as any, true, key.usages); | ||
}); | ||
} | ||
@@ -197,3 +203,3 @@ } else { | ||
return PrepareKey(key, Class) | ||
.then((preparedKey) => Class.verify(alg, key, signatureBytes, dataBytes)); | ||
.then((preparedKey) => Class.verify(alg, preparedKey, signatureBytes, dataBytes)); | ||
}); | ||
@@ -559,3 +565,3 @@ } | ||
// fix hash alg for rsa key | ||
function GetHashAlgorithm(key: CryptoKey) { | ||
function GetHashAlgorithm(key: CryptoKey): Algorithm | null { | ||
let alg: Algorithm | null = null; | ||
@@ -562,0 +568,0 @@ keys.some((item) => { |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
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
301920
3908
124
3
Updatedwebcrypto-core@^0.1.13