@toruslabs/eccrypto
Advanced tools
Comparing version 5.0.2 to 5.0.3
@@ -103,5 +103,10 @@ /******/ (() => { // webpackBootstrap | ||
async function sha512(msg) { | ||
const hash = await subtle.digest("SHA-512", msg); | ||
const result = new Uint8Array(hash); | ||
return result; | ||
if (!browserCrypto.createHash) { | ||
const hash = await subtle.digest("SHA-512", msg); | ||
const result = new Uint8Array(hash); | ||
return result; | ||
} | ||
const hash = browserCrypto.createHash("sha512"); | ||
const result = hash.update(msg).digest(); | ||
return new Uint8Array(result); | ||
} | ||
@@ -140,11 +145,17 @@ function getAes(op) { | ||
async function hmacSha256Sign(key, msg) { | ||
const importAlgorithm = { | ||
name: "HMAC", | ||
hash: { | ||
name: "SHA-256" | ||
} | ||
}; | ||
const cryptoKey = await subtle.importKey("raw", new Uint8Array(key), importAlgorithm, false, ["sign", "verify"]); | ||
const sig = await subtle.sign("HMAC", cryptoKey, msg); | ||
const result = Buffer.from(new Uint8Array(sig)); | ||
if (!browserCrypto.createHmac) { | ||
const importAlgorithm = { | ||
name: "HMAC", | ||
hash: { | ||
name: "SHA-256" | ||
} | ||
}; | ||
const cryptoKey = await subtle.importKey("raw", new Uint8Array(key), importAlgorithm, false, ["sign", "verify"]); | ||
const sig = await subtle.sign("HMAC", cryptoKey, msg); | ||
const result = Buffer.from(new Uint8Array(sig)); | ||
return result; | ||
} | ||
const hmac = browserCrypto.createHmac("sha256", Buffer.from(key)); | ||
hmac.update(msg); | ||
const result = hmac.digest(); | ||
return result; | ||
@@ -151,0 +162,0 @@ } |
@@ -48,5 +48,10 @@ import { ec as ec$1 } from 'elliptic'; | ||
async function sha512(msg) { | ||
const hash = await subtle.digest("SHA-512", msg); | ||
const result = new Uint8Array(hash); | ||
return result; | ||
if (!browserCrypto.createHash) { | ||
const hash = await subtle.digest("SHA-512", msg); | ||
const result = new Uint8Array(hash); | ||
return result; | ||
} | ||
const hash = browserCrypto.createHash("sha512"); | ||
const result = hash.update(msg).digest(); | ||
return new Uint8Array(result); | ||
} | ||
@@ -85,11 +90,17 @@ function getAes(op) { | ||
async function hmacSha256Sign(key, msg) { | ||
const importAlgorithm = { | ||
name: "HMAC", | ||
hash: { | ||
name: "SHA-256" | ||
} | ||
}; | ||
const cryptoKey = await subtle.importKey("raw", new Uint8Array(key), importAlgorithm, false, ["sign", "verify"]); | ||
const sig = await subtle.sign("HMAC", cryptoKey, msg); | ||
const result = Buffer.from(new Uint8Array(sig)); | ||
if (!browserCrypto.createHmac) { | ||
const importAlgorithm = { | ||
name: "HMAC", | ||
hash: { | ||
name: "SHA-256" | ||
} | ||
}; | ||
const cryptoKey = await subtle.importKey("raw", new Uint8Array(key), importAlgorithm, false, ["sign", "verify"]); | ||
const sig = await subtle.sign("HMAC", cryptoKey, msg); | ||
const result = Buffer.from(new Uint8Array(sig)); | ||
return result; | ||
} | ||
const hmac = browserCrypto.createHmac("sha256", Buffer.from(key)); | ||
hmac.update(msg); | ||
const result = hmac.digest(); | ||
return result; | ||
@@ -96,0 +107,0 @@ } |
@@ -50,5 +50,10 @@ 'use strict'; | ||
async function sha512(msg) { | ||
const hash = await subtle.digest("SHA-512", msg); | ||
const result = new Uint8Array(hash); | ||
return result; | ||
if (!browserCrypto.createHash) { | ||
const hash = await subtle.digest("SHA-512", msg); | ||
const result = new Uint8Array(hash); | ||
return result; | ||
} | ||
const hash = browserCrypto.createHash("sha512"); | ||
const result = hash.update(msg).digest(); | ||
return new Uint8Array(result); | ||
} | ||
@@ -87,11 +92,17 @@ function getAes(op) { | ||
async function hmacSha256Sign(key, msg) { | ||
const importAlgorithm = { | ||
name: "HMAC", | ||
hash: { | ||
name: "SHA-256" | ||
} | ||
}; | ||
const cryptoKey = await subtle.importKey("raw", new Uint8Array(key), importAlgorithm, false, ["sign", "verify"]); | ||
const sig = await subtle.sign("HMAC", cryptoKey, msg); | ||
const result = Buffer.from(new Uint8Array(sig)); | ||
if (!browserCrypto.createHmac) { | ||
const importAlgorithm = { | ||
name: "HMAC", | ||
hash: { | ||
name: "SHA-256" | ||
} | ||
}; | ||
const cryptoKey = await subtle.importKey("raw", new Uint8Array(key), importAlgorithm, false, ["sign", "verify"]); | ||
const sig = await subtle.sign("HMAC", cryptoKey, msg); | ||
const result = Buffer.from(new Uint8Array(sig)); | ||
return result; | ||
} | ||
const hmac = browserCrypto.createHmac("sha256", Buffer.from(key)); | ||
hmac.update(msg); | ||
const result = hmac.digest(); | ||
return result; | ||
@@ -98,0 +109,0 @@ } |
@@ -48,5 +48,10 @@ import { ec as ec$1 } from 'elliptic'; | ||
async function sha512(msg) { | ||
const hash = await subtle.digest("SHA-512", msg); | ||
const result = new Uint8Array(hash); | ||
return result; | ||
if (!browserCrypto.createHash) { | ||
const hash = await subtle.digest("SHA-512", msg); | ||
const result = new Uint8Array(hash); | ||
return result; | ||
} | ||
const hash = browserCrypto.createHash("sha512"); | ||
const result = hash.update(msg).digest(); | ||
return new Uint8Array(result); | ||
} | ||
@@ -85,11 +90,17 @@ function getAes(op) { | ||
async function hmacSha256Sign(key, msg) { | ||
const importAlgorithm = { | ||
name: "HMAC", | ||
hash: { | ||
name: "SHA-256" | ||
} | ||
}; | ||
const cryptoKey = await subtle.importKey("raw", new Uint8Array(key), importAlgorithm, false, ["sign", "verify"]); | ||
const sig = await subtle.sign("HMAC", cryptoKey, msg); | ||
const result = Buffer.from(new Uint8Array(sig)); | ||
if (!browserCrypto.createHmac) { | ||
const importAlgorithm = { | ||
name: "HMAC", | ||
hash: { | ||
name: "SHA-256" | ||
} | ||
}; | ||
const cryptoKey = await subtle.importKey("raw", new Uint8Array(key), importAlgorithm, false, ["sign", "verify"]); | ||
const sig = await subtle.sign("HMAC", cryptoKey, msg); | ||
const result = Buffer.from(new Uint8Array(sig)); | ||
return result; | ||
} | ||
const hmac = browserCrypto.createHmac("sha256", Buffer.from(key)); | ||
hmac.update(msg); | ||
const result = hmac.digest(); | ||
return result; | ||
@@ -96,0 +107,0 @@ } |
@@ -1,2 +0,1 @@ | ||
/// <reference types="node" /> | ||
export interface Ecies { | ||
@@ -3,0 +2,0 @@ iv: Buffer; |
{ | ||
"name": "@toruslabs/eccrypto", | ||
"version": "5.0.2", | ||
"version": "5.0.3", | ||
"description": "JavaScript Elliptic curve cryptography library, includes fix to browser.js so that encrypt/decrypt works", | ||
@@ -67,6 +67,6 @@ "main": "./dist/lib.cjs/index.js", | ||
"karma-mocha-reporter": "^2.2.5", | ||
"karma-safari-launcher": "^1.0.0", | ||
"mocha": "^10.4.0", | ||
"playwright": "^1.44.1", | ||
"typescript": "^5.4.5" | ||
"karma-webkit-launcher": "^2.4.0", | ||
"mocha": "^10.6.0", | ||
"playwright": "^1.45.1", | ||
"typescript": "^5.5.3" | ||
}, | ||
@@ -73,0 +73,0 @@ "dependencies": { |
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
216688
1059