Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

node-webcrypto-ossl

Package Overview
Dependencies
Maintainers
2
Versions
60
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-webcrypto-ossl - npm Package Compare versions

Comparing version 1.0.36 to 1.0.37

buildjs/crypto.js

122

buildjs/crypto/aes.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var webcrypto_core_1 = require("webcrypto-core");
var key_1 = require("../key");
var native = require("../native");
const webcrypto_core_1 = require("webcrypto-core");
const key_1 = require("../key");
const native = require("../native");
function b64_decode(b64url) {
return new Buffer(webcrypto_core_1.Base64Url.decode(b64url));
}
var AesCrypto = (function (_super) {
tslib_1.__extends(AesCrypto, _super);
function AesCrypto() {
return _super !== null && _super.apply(this, arguments) || this;
}
AesCrypto.generateKey = function (algorithm, extractable, keyUsages) {
return new Promise(function (resolve, reject) {
native.AesKey.generate(algorithm.length / 8, function (err, key) {
class AesCrypto extends webcrypto_core_1.BaseCrypto {
static generateKey(algorithm, extractable, keyUsages) {
return new Promise((resolve, reject) => {
native.AesKey.generate(algorithm.length / 8, (err, key) => {
if (err) {

@@ -22,3 +17,3 @@ reject(err);

else {
var aes = new key_1.CryptoKey(key, algorithm, "secret", extractable, keyUsages);
const aes = new key_1.CryptoKey(key, algorithm, "secret", extractable, keyUsages);
resolve(aes);

@@ -28,7 +23,7 @@ }

});
};
AesCrypto.importKey = function (format, keyData, algorithm, extractable, keyUsages) {
return new Promise(function (resolve, reject) {
var formatLC = format.toLocaleLowerCase();
var raw;
}
static importKey(format, keyData, algorithm, extractable, keyUsages) {
return new Promise((resolve, reject) => {
const formatLC = format.toLocaleLowerCase();
let raw;
switch (formatLC) {

@@ -42,6 +37,6 @@ case "jwk":

default:
throw new webcrypto_core_1.WebCryptoError("ImportKey: Wrong format value '" + format + "'");
throw new webcrypto_core_1.WebCryptoError(`ImportKey: Wrong format value '${format}'`);
}
algorithm.length = raw.byteLength * 8;
native.AesKey.import(raw, function (err, key) {
native.AesKey.import(raw, (err, key) => {
if (err) {

@@ -55,9 +50,9 @@ reject(err);

});
};
AesCrypto.exportKey = function (format, key) {
return new Promise(function (resolve, reject) {
var nativeKey = key.native;
}
static exportKey(format, key) {
return new Promise((resolve, reject) => {
const nativeKey = key.native;
switch (format.toLocaleLowerCase()) {
case "jwk":
var jwk_1 = {
const jwk = {
kty: "oct",

@@ -69,4 +64,4 @@ alg: "",

};
jwk_1.alg = "A" + key.algorithm.length + /-(\w+)$/.exec(key.algorithm.name)[1].toUpperCase();
nativeKey.export(function (err, data) {
jwk.alg = "A" + key.algorithm.length + /-(\w+)$/.exec(key.algorithm.name)[1].toUpperCase();
nativeKey.export((err, data) => {
if (err) {

@@ -76,4 +71,4 @@ reject(err);

else {
jwk_1.k = webcrypto_core_1.Base64Url.encode(data);
resolve(jwk_1);
jwk.k = webcrypto_core_1.Base64Url.encode(data);
resolve(jwk);
}

@@ -83,3 +78,3 @@ });

case "raw":
nativeKey.export(function (err, data) {
nativeKey.export((err, data) => {
if (err) {

@@ -93,7 +88,7 @@ reject(err);

break;
default: throw new webcrypto_core_1.WebCryptoError("ExportKey: Unknown export format '" + format + "'");
default: throw new webcrypto_core_1.WebCryptoError(`ExportKey: Unknown export format '${format}'`);
}
});
};
AesCrypto.encrypt = function (algorithm, key, data) {
}
static encrypt(algorithm, key, data) {
if (algorithm.name.toUpperCase() === webcrypto_core_1.AlgorithmNames.AesKW) {

@@ -105,4 +100,4 @@ return this.WrapUnwrap(key.native, data, true);

}
};
AesCrypto.decrypt = function (algorithm, key, data) {
}
static decrypt(algorithm, key, data) {
if (algorithm.name.toUpperCase() === webcrypto_core_1.AlgorithmNames.AesKW) {

@@ -114,14 +109,14 @@ return this.WrapUnwrap(key.native, data, false);

}
};
AesCrypto.EncryptDecrypt = function (algorithm, key, data, type) {
return new Promise(function (resolve, reject) {
var nativeKey = key.native;
}
static EncryptDecrypt(algorithm, key, data, type) {
return new Promise((resolve, reject) => {
const nativeKey = key.native;
switch (algorithm.name.toLowerCase()) {
case webcrypto_core_1.AlgorithmNames.AesGCM.toLowerCase(): {
var algGCM = algorithm;
var iv = new Buffer(algorithm.iv);
var aad = algGCM.additionalData ? new Buffer(algGCM.additionalData) : new Buffer(0);
var tagLength = algGCM.tagLength || 128;
const algGCM = algorithm;
const iv = new Buffer(algorithm.iv);
const aad = algGCM.additionalData ? new Buffer(algGCM.additionalData) : new Buffer(0);
const tagLength = algGCM.tagLength || 128;
if (type) {
nativeKey.encryptGcm(iv, data, aad || new Buffer(0), tagLength / 8, function (err, data2) {
nativeKey.encryptGcm(iv, data, aad || new Buffer(0), tagLength / 8, (err, data2) => {
if (err) {

@@ -136,3 +131,3 @@ reject(err);

else {
nativeKey.decryptGcm(iv, data, aad || new Buffer(0), tagLength / 8, function (err, data2) {
nativeKey.decryptGcm(iv, data, aad || new Buffer(0), tagLength / 8, (err, data2) => {
if (err) {

@@ -149,6 +144,6 @@ reject(err);

case webcrypto_core_1.AlgorithmNames.AesCBC.toLowerCase(): {
var algCBC = "CBC";
var iv = new Buffer(algorithm.iv);
const algCBC = "CBC";
const iv = new Buffer(algorithm.iv);
if (type) {
nativeKey.encrypt(algCBC, iv, data, function (err, data2) {
nativeKey.encrypt(algCBC, iv, data, (err, data2) => {
if (err) {

@@ -163,3 +158,3 @@ reject(err);

else {
nativeKey.decrypt(algCBC, iv, data, function (err, data2) {
nativeKey.decrypt(algCBC, iv, data, (err, data2) => {
if (err) {

@@ -176,6 +171,6 @@ reject(err);

case webcrypto_core_1.AlgorithmNames.AesCTR.toLowerCase(): {
var alg = algorithm;
var counter = new Buffer(alg.counter);
const alg = algorithm;
const counter = new Buffer(alg.counter);
if (type) {
nativeKey.encryptCtr(data, counter, alg.length, function (err, data2) {
nativeKey.encryptCtr(data, counter, alg.length, (err, data2) => {
if (err) {

@@ -190,3 +185,3 @@ reject(err);

else {
nativeKey.decryptCtr(data, counter, alg.length, function (err, data2) {
nativeKey.decryptCtr(data, counter, alg.length, (err, data2) => {
if (err) {

@@ -204,3 +199,3 @@ reject(err);

if (type) {
nativeKey.encryptEcb(data, function (err, data2) {
nativeKey.encryptEcb(data, (err, data2) => {
if (err) {

@@ -215,3 +210,3 @@ reject(err);

else {
nativeKey.decryptEcb(data, function (err, data2) {
nativeKey.decryptEcb(data, (err, data2) => {
if (err) {

@@ -230,7 +225,7 @@ reject(err);

});
};
AesCrypto.WrapUnwrap = function (key, data, enc) {
return new Promise(function (resolve, reject) {
var fn = enc ? key.wrapKey : key.unwrapKey;
fn.call(key, data, function (err, data2) {
}
static WrapUnwrap(key, data, enc) {
return new Promise((resolve, reject) => {
const fn = enc ? key.wrapKey : key.unwrapKey;
fn.call(key, data, (err, data2) => {
if (err) {

@@ -240,9 +235,8 @@ reject(err);

else {
resolve(data2);
resolve(new Uint8Array(data2).buffer);
}
});
});
};
return AesCrypto;
}(webcrypto_core_1.BaseCrypto));
}
}
exports.AesCrypto = AesCrypto;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var webcrypto = require("webcrypto-core");
var AlgorithmError = webcrypto.AlgorithmError;
var WebCryptoError = webcrypto.WebCryptoError;
var AlgorithmNames = webcrypto.AlgorithmNames;
var BaseCrypto = webcrypto.BaseCrypto;
var Base64Url = webcrypto.Base64Url;
var key_1 = require("../key");
var native = require("../native");
var aes = require("./aes");
const webcrypto = require("webcrypto-core");
const AlgorithmError = webcrypto.AlgorithmError;
const WebCryptoError = webcrypto.WebCryptoError;
const AlgorithmNames = webcrypto.AlgorithmNames;
const BaseCrypto = webcrypto.BaseCrypto;
const Base64Url = webcrypto.Base64Url;
const key_1 = require("../key");
const native = require("../native");
const aes = require("./aes");
function nc2ssl(nc) {
var namedCurve = "";
let namedCurve = "";
switch (nc.toUpperCase()) {

@@ -39,6 +38,5 @@ case "P-192":

}
function buf_pad(buf, padSize) {
if (padSize === void 0) { padSize = 0; }
function buf_pad(buf, padSize = 0) {
if (padSize && Buffer.length < padSize) {
var pad = new Buffer(new Uint8Array(padSize - buf.length).map(function (v) { return 0; }));
const pad = new Buffer(new Uint8Array(padSize - buf.length).map((v) => 0));
return Buffer.concat([pad, buf]);

@@ -48,12 +46,8 @@ }

}
var EcCrypto = (function (_super) {
tslib_1.__extends(EcCrypto, _super);
function EcCrypto() {
return _super !== null && _super.apply(this, arguments) || this;
}
EcCrypto.generateKey = function (algorithm, extractable, keyUsages) {
return new Promise(function (resolve, reject) {
var alg = algorithm;
var namedCurve = nc2ssl(alg.namedCurve);
native.Key.generateEc(namedCurve, function (err, key) {
class EcCrypto extends BaseCrypto {
static generateKey(algorithm, extractable, keyUsages) {
return new Promise((resolve, reject) => {
const alg = algorithm;
const namedCurve = nc2ssl(alg.namedCurve);
native.Key.generateEc(namedCurve, (err, key) => {
if (err) {

@@ -63,6 +57,6 @@ reject(err);

else {
var prvUsages = ["sign", "deriveKey", "deriveBits"]
.filter(function (usage) { return keyUsages.some(function (keyUsage) { return keyUsage === usage; }); });
var pubUsages = ["verify"]
.filter(function (usage) { return keyUsages.some(function (keyUsage) { return keyUsage === usage; }); });
const prvUsages = ["sign", "deriveKey", "deriveBits"]
.filter((usage) => keyUsages.some((keyUsage) => keyUsage === usage));
const pubUsages = ["verify"]
.filter((usage) => keyUsages.some((keyUsage) => keyUsage === usage));
resolve({

@@ -75,9 +69,9 @@ privateKey: new key_1.CryptoKey(key, algorithm, "private", extractable, prvUsages),

});
};
EcCrypto.importKey = function (format, keyData, algorithm, extractable, keyUsages) {
return new Promise(function (resolve, reject) {
var formatLC = format.toLocaleLowerCase();
var alg = algorithm;
var data = {};
var keyType = native.KeyType.PUBLIC;
}
static importKey(format, keyData, algorithm, extractable, keyUsages) {
return new Promise((resolve, reject) => {
const formatLC = format.toLocaleLowerCase();
const alg = algorithm;
const data = {};
let keyType = native.KeyType.PUBLIC;
switch (formatLC) {

@@ -91,3 +85,3 @@ case "raw":

}
var keyLength = 0;
let keyLength = 0;
if (keyData.length === 65) {

@@ -102,4 +96,4 @@ keyLength = 32;

}
var x = keyData.slice(1, keyLength + 1);
var y = keyData.slice(keyLength + 1, (keyLength * 2) + 1);
const x = keyData.slice(1, keyLength + 1);
const y = keyData.slice(keyLength + 1, (keyLength * 2) + 1);
data["kty"] = new Buffer("EC", "utf-8");

@@ -109,9 +103,9 @@ data["crv"] = nc2ssl(alg.namedCurve.toUpperCase());

data["y"] = b64_decode(Base64Url.encode(buf_pad(y, keyLength)));
native.Key.importJwk(data, keyType, function (err, key) {
native.Key.importJwk(data, keyType, (err, key) => {
try {
if (err) {
reject(new WebCryptoError("ImportKey: Cannot import key from JWK\n" + err));
reject(new WebCryptoError(`ImportKey: Cannot import key from JWK\n${err}`));
}
else {
var ec = new key_1.CryptoKey(key, alg, keyType ? "private" : "public", extractable, keyUsages);
const ec = new key_1.CryptoKey(key, alg, keyType ? "private" : "public", extractable, keyUsages);
resolve(ec);

@@ -126,3 +120,3 @@ }

case "jwk":
var jwk = keyData;
const jwk = keyData;
data["kty"] = jwk.kty;

@@ -136,9 +130,9 @@ data["crv"] = nc2ssl(jwk.crv);

}
native.Key.importJwk(data, keyType, function (err, key) {
native.Key.importJwk(data, keyType, (err, key) => {
try {
if (err) {
reject(new WebCryptoError("ImportKey: Cannot import key from JWK\n" + err));
reject(new WebCryptoError(`ImportKey: Cannot import key from JWK\n${err}`));
}
else {
var ec = new key_1.CryptoKey(key, alg, keyType ? "private" : "public", extractable, keyUsages);
const ec = new key_1.CryptoKey(key, alg, keyType ? "private" : "public", extractable, keyUsages);
resolve(ec);

@@ -157,13 +151,13 @@ }

}
var importFunction = native.Key.importPkcs8;
let importFunction = native.Key.importPkcs8;
if (formatLC === "spki") {
importFunction = native.Key.importSpki;
}
importFunction(keyData, function (err, key) {
importFunction(keyData, (err, key) => {
try {
if (err) {
reject(new WebCryptoError("ImportKey: Can not import key for " + format + "\n" + err.message));
reject(new WebCryptoError(`ImportKey: Can not import key for ${format}\n${err.message}`));
}
else {
var ec = new key_1.CryptoKey(key, alg, format.toLocaleLowerCase() === "spki" ? "public" : "private", extractable, keyUsages);
const ec = new key_1.CryptoKey(key, alg, format.toLocaleLowerCase() === "spki" ? "public" : "private", extractable, keyUsages);
resolve(ec);

@@ -178,18 +172,18 @@ }

default:
throw new WebCryptoError("ImportKey: Wrong format value '" + format + "'");
throw new WebCryptoError(`ImportKey: Wrong format value '${format}'`);
}
});
};
EcCrypto.exportKey = function (format, key) {
return new Promise(function (resolve, reject) {
var nativeKey = key.native;
var type = key.type === "public" ? native.KeyType.PUBLIC : native.KeyType.PRIVATE;
}
static exportKey(format, key) {
return new Promise((resolve, reject) => {
const nativeKey = key.native;
const type = key.type === "public" ? native.KeyType.PUBLIC : native.KeyType.PRIVATE;
switch (format.toLocaleLowerCase()) {
case "jwk":
nativeKey.exportJwk(type, function (err, data) {
nativeKey.exportJwk(type, (err, data) => {
try {
var jwk = { kty: "EC" };
const jwk = { kty: "EC" };
jwk.crv = key.algorithm.namedCurve;
jwk.key_ops = key.usages;
var padSize = 0;
let padSize = 0;
switch (jwk.crv) {

@@ -207,3 +201,3 @@ case "P-256":

default:
throw new Error("Unsupported named curve '" + jwk.crv + "'");
throw new Error(`Unsupported named curve '${jwk.crv}'`);
}

@@ -223,3 +217,3 @@ jwk.x = Base64Url.encode(buf_pad(data.x, padSize));

case "spki":
nativeKey.exportSpki(function (err, raw) {
nativeKey.exportSpki((err, raw) => {
if (err) {

@@ -234,3 +228,3 @@ reject(err);

case "pkcs8":
nativeKey.exportPkcs8(function (err, raw) {
nativeKey.exportPkcs8((err, raw) => {
if (err) {

@@ -245,3 +239,3 @@ reject(err);

case "raw":
nativeKey.exportJwk(type, function (err, data) {
nativeKey.exportJwk(type, (err, data) => {
if (err) {

@@ -251,4 +245,4 @@ reject(err);

else {
var padSize = 0;
var crv = key.algorithm.namedCurve;
let padSize = 0;
const crv = key.algorithm.namedCurve;
switch (crv) {

@@ -266,7 +260,7 @@ case "P-256":

default:
throw new Error("Unsupported named curve '" + crv + "'");
throw new Error(`Unsupported named curve '${crv}'`);
}
var x = Base64Url.decode(Base64Url.encode(buf_pad(data.x, padSize)));
var y = Base64Url.decode(Base64Url.encode(buf_pad(data.y, padSize)));
var rawKey = new Uint8Array(1 + x.length + y.length);
const x = Base64Url.decode(Base64Url.encode(buf_pad(data.x, padSize)));
const y = Base64Url.decode(Base64Url.encode(buf_pad(data.y, padSize)));
const rawKey = new Uint8Array(1 + x.length + y.length);
rawKey.set([4]);

@@ -280,12 +274,11 @@ rawKey.set(x, 1);

default:
throw new WebCryptoError("ExportKey: Unknown export format '" + format + "'");
throw new WebCryptoError(`ExportKey: Unknown export format '${format}'`);
}
});
};
EcCrypto.sign = function (algorithm, key, data) {
var _this = this;
return new Promise(function (resolve, reject) {
var alg = _this.wc2ssl(algorithm);
var nativeKey = key.native;
nativeKey.sign(alg, data, function (err, signature) {
}
static sign(algorithm, key, data) {
return new Promise((resolve, reject) => {
const alg = this.wc2ssl(algorithm);
const nativeKey = key.native;
nativeKey.sign(alg, data, (err, signature) => {
if (err) {

@@ -299,9 +292,8 @@ reject(new WebCryptoError("NativeError: " + err.message));

});
};
EcCrypto.verify = function (algorithm, key, signature, data) {
var _this = this;
return new Promise(function (resolve, reject) {
var alg = _this.wc2ssl(algorithm);
var nativeKey = key.native;
nativeKey.verify(alg, data, signature, function (err, res) {
}
static verify(algorithm, key, signature, data) {
return new Promise((resolve, reject) => {
const alg = this.wc2ssl(algorithm);
const nativeKey = key.native;
nativeKey.verify(alg, data, signature, (err, res) => {
if (err) {

@@ -315,8 +307,8 @@ reject(new WebCryptoError("NativeError: " + err.message));

});
};
EcCrypto.deriveKey = function (algorithm, baseKey, derivedKeyType, extractable, keyUsages) {
return new Promise(function (resolve, reject) {
var algDerivedKeyType = derivedKeyType;
var alg = algorithm;
var AesClass;
}
static deriveKey(algorithm, baseKey, derivedKeyType, extractable, keyUsages) {
return new Promise((resolve, reject) => {
const algDerivedKeyType = derivedKeyType;
const alg = algorithm;
let AesClass;
switch (algDerivedKeyType.name.toLowerCase()) {

@@ -331,3 +323,3 @@ case AlgorithmNames.AesCBC.toLowerCase():

}
baseKey.native.EcdhDeriveKey(alg.public.native, algDerivedKeyType.length / 8, function (err, raw) {
baseKey.native.EcdhDeriveKey(alg.public.native, algDerivedKeyType.length / 8, (err, raw) => {
if (err) {

@@ -342,8 +334,8 @@ reject(err);

});
};
EcCrypto.deriveBits = function (algorithm, baseKey, length) {
return new Promise(function (resolve, reject) {
var alg = algorithm;
var nativeKey = baseKey.native;
nativeKey.EcdhDeriveBits(alg.public.native, length, function (err, raw) {
}
static deriveBits(algorithm, baseKey, length) {
return new Promise((resolve, reject) => {
const alg = algorithm;
const nativeKey = baseKey.native;
nativeKey.EcdhDeriveBits(alg.public.native, length, (err, raw) => {
if (err) {

@@ -357,9 +349,8 @@ reject(err);

});
};
EcCrypto.wc2ssl = function (algorithm) {
var alg = algorithm.hash.name.toUpperCase().replace("-", "");
}
static wc2ssl(algorithm) {
const alg = algorithm.hash.name.toUpperCase().replace("-", "");
return alg;
};
return EcCrypto;
}(BaseCrypto));
}
}
exports.EcCrypto = EcCrypto;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var webcrypto = require("webcrypto-core");
var AlgorithmError = webcrypto.AlgorithmError;
var WebCryptoError = webcrypto.WebCryptoError;
var AlgorithmNames = webcrypto.AlgorithmNames;
var BaseCrypto = webcrypto.BaseCrypto;
var Base64Url = webcrypto.Base64Url;
var key_1 = require("../key");
var native = require("../native");
const webcrypto = require("webcrypto-core");
const AlgorithmError = webcrypto.AlgorithmError;
const WebCryptoError = webcrypto.WebCryptoError;
const AlgorithmNames = webcrypto.AlgorithmNames;
const BaseCrypto = webcrypto.BaseCrypto;
const Base64Url = webcrypto.Base64Url;
const key_1 = require("../key");
const native = require("../native");
function b64_decode(b64url) {
return new Buffer(Base64Url.decode(b64url));
}
var HmacCrypto = (function (_super) {
tslib_1.__extends(HmacCrypto, _super);
function HmacCrypto() {
return _super !== null && _super.apply(this, arguments) || this;
}
HmacCrypto.generateKey = function (algorithm, extractable, keyUsages) {
var _this = this;
return new Promise(function (resolve, reject) {
var length = algorithm.length || _this.getHashSize(algorithm.hash.name);
native.HmacKey.generate(length, function (err, key) {
class HmacCrypto extends BaseCrypto {
static generateKey(algorithm, extractable, keyUsages) {
return new Promise((resolve, reject) => {
const length = algorithm.length || this.getHashSize(algorithm.hash.name);
native.HmacKey.generate(length, (err, key) => {
if (err) {

@@ -33,7 +27,7 @@ reject(err);

});
};
HmacCrypto.importKey = function (format, keyData, algorithm, extractable, keyUsages) {
return new Promise(function (resolve, reject) {
var formatLC = format.toLocaleLowerCase();
var raw;
}
static importKey(format, keyData, algorithm, extractable, keyUsages) {
return new Promise((resolve, reject) => {
const formatLC = format.toLocaleLowerCase();
let raw;
switch (formatLC) {

@@ -47,5 +41,5 @@ case "jwk":

default:
throw new WebCryptoError("ImportKey: Wrong format value '" + format + "'");
throw new WebCryptoError(`ImportKey: Wrong format value '${format}'`);
}
native.HmacKey.import(raw, function (err, key) {
native.HmacKey.import(raw, (err, key) => {
if (err) {

@@ -59,9 +53,9 @@ reject(err);

});
};
HmacCrypto.exportKey = function (format, key) {
return new Promise(function (resolve, reject) {
var nativeKey = key.native;
}
static exportKey(format, key) {
return new Promise((resolve, reject) => {
const nativeKey = key.native;
switch (format.toLocaleLowerCase()) {
case "jwk":
var jwk_1 = {
const jwk = {
kty: "oct",

@@ -73,4 +67,4 @@ alg: "",

};
jwk_1.alg = "HS" + /-(\d+)$/.exec(key.algorithm.hash.name)[1];
nativeKey.export(function (err, data) {
jwk.alg = "HS" + /-(\d+)$/.exec(key.algorithm.hash.name)[1];
nativeKey.export((err, data) => {
if (err) {

@@ -80,4 +74,4 @@ reject(err);

else {
jwk_1.k = Base64Url.encode(data);
resolve(jwk_1);
jwk.k = Base64Url.encode(data);
resolve(jwk);
}

@@ -87,3 +81,3 @@ });

case "raw":
nativeKey.export(function (err, data) {
nativeKey.export((err, data) => {
if (err) {

@@ -97,12 +91,11 @@ reject(err);

break;
default: throw new WebCryptoError("ExportKey: Unknown export format '" + format + "'");
default: throw new WebCryptoError(`ExportKey: Unknown export format '${format}'`);
}
});
};
HmacCrypto.sign = function (algorithm, key, data) {
var _this = this;
return new Promise(function (resolve, reject) {
var alg = _this.wc2ssl(key.algorithm);
var nativeKey = key.native;
nativeKey.sign(alg, data, function (err, signature) {
}
static sign(algorithm, key, data) {
return new Promise((resolve, reject) => {
const alg = this.wc2ssl(key.algorithm);
const nativeKey = key.native;
nativeKey.sign(alg, data, (err, signature) => {
if (err) {

@@ -116,9 +109,8 @@ reject(new WebCryptoError("NativeError: " + err.message));

});
};
HmacCrypto.verify = function (algorithm, key, signature, data) {
var _this = this;
return new Promise(function (resolve, reject) {
var alg = _this.wc2ssl(key.algorithm);
var nativeKey = key.native;
nativeKey.verify(alg, data, signature, function (err, res) {
}
static verify(algorithm, key, signature, data) {
return new Promise((resolve, reject) => {
const alg = this.wc2ssl(key.algorithm);
const nativeKey = key.native;
nativeKey.verify(alg, data, signature, (err, res) => {
if (err) {

@@ -132,8 +124,8 @@ reject(new WebCryptoError("NativeError: " + err.message));

});
};
HmacCrypto.wc2ssl = function (algorithm) {
var alg = algorithm.hash.name.toUpperCase().replace("-", "");
}
static wc2ssl(algorithm) {
const alg = algorithm.hash.name.toUpperCase().replace("-", "");
return alg;
};
HmacCrypto.getHashSize = function (hashName) {
}
static getHashSize(hashName) {
switch (hashName) {

@@ -151,5 +143,4 @@ case AlgorithmNames.Sha1:

}
};
return HmacCrypto;
}(BaseCrypto));
}
}
exports.HmacCrypto = HmacCrypto;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var Core = require("webcrypto-core");
var key_1 = require("../key");
var native = require("../native");
var aes_1 = require("./aes");
var hmac_1 = require("./hmac");
const Core = require("webcrypto-core");
const key_1 = require("../key");
const native = require("../native");
const aes_1 = require("./aes");
const hmac_1 = require("./hmac");
function b64_decode(b64url) {
return new Buffer(Core.Base64Url.decode(b64url));
}
var Pbkdf2Crypto = (function (_super) {
tslib_1.__extends(Pbkdf2Crypto, _super);
function Pbkdf2Crypto() {
return _super !== null && _super.apply(this, arguments) || this;
}
Pbkdf2Crypto.importKey = function (format, keyData, algorithm, extractable, keyUsages) {
return new Promise(function (resolve, reject) {
var formatLC = format.toLocaleLowerCase();
var alg = algorithm;
class Pbkdf2Crypto extends Core.BaseCrypto {
static importKey(format, keyData, algorithm, extractable, keyUsages) {
return new Promise((resolve, reject) => {
const formatLC = format.toLocaleLowerCase();
const alg = algorithm;
alg.name = alg.name.toUpperCase();
var raw;
let raw;
switch (formatLC) {

@@ -31,6 +26,6 @@ case "jwk":

default:
throw new Core.WebCryptoError("ImportKey: Wrong format value '" + format + "'");
throw new Core.WebCryptoError(`ImportKey: Wrong format value '${format}'`);
}
alg.length = raw.byteLength * 8;
native.Pbkdf2Key.importKey(raw, function (err, key) {
native.Pbkdf2Key.importKey(raw, (err, key) => {
if (err) {

@@ -44,11 +39,10 @@ reject(err);

});
};
Pbkdf2Crypto.deriveKey = function (algorithm, baseKey, derivedKeyType, extractable, keyUsages) {
var _this = this;
}
static deriveKey(algorithm, baseKey, derivedKeyType, extractable, keyUsages) {
return Promise.resolve()
.then(function () {
return _this.deriveBits(algorithm, baseKey, derivedKeyType.length);
.then(() => {
return this.deriveBits(algorithm, baseKey, derivedKeyType.length);
})
.then(function (raw) {
var CryptoClass;
.then((raw) => {
let CryptoClass;
switch (derivedKeyType.name.toUpperCase()) {

@@ -68,11 +62,10 @@ case Core.AlgorithmNames.AesCBC:

});
};
Pbkdf2Crypto.deriveBits = function (algorithm, baseKey, length) {
var _this = this;
return new Promise(function (resolve, reject) {
var alg = algorithm;
var nativeKey = baseKey.native;
var hash = Core.PrepareAlgorithm(alg.hash);
var salt = new Buffer(Core.PrepareData(alg.salt, "salt"));
nativeKey.deriveBits(_this.wc2ssl(hash), salt, alg.iterations, length, function (err, raw) {
}
static deriveBits(algorithm, baseKey, length) {
return new Promise((resolve, reject) => {
const alg = algorithm;
const nativeKey = baseKey.native;
const hash = Core.PrepareAlgorithm(alg.hash);
const salt = new Buffer(Core.PrepareData(alg.salt, "salt"));
nativeKey.deriveBits(this.wc2ssl(hash), salt, alg.iterations, length, (err, raw) => {
if (err) {

@@ -86,9 +79,8 @@ reject(err);

});
};
Pbkdf2Crypto.wc2ssl = function (algorithm) {
var alg = algorithm.name.toUpperCase().replace("-", "");
}
static wc2ssl(algorithm) {
const alg = algorithm.name.toUpperCase().replace("-", "");
return alg;
};
return Pbkdf2Crypto;
}(Core.BaseCrypto));
}
}
exports.Pbkdf2Crypto = Pbkdf2Crypto;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var webcrypto = require("webcrypto-core");
var WebCryptoError = webcrypto.WebCryptoError;
var BaseCrypto = webcrypto.BaseCrypto;
var Base64Url = webcrypto.Base64Url;
var key_1 = require("../key");
var native = require("../native");
const webcrypto_core_1 = require("webcrypto-core");
const key_1 = require("../key");
const native = require("../native");
function b64_decode(b64url) {
return new Buffer(Base64Url.decode(b64url));
return new Buffer(webcrypto_core_1.Base64Url.decode(b64url));
}
var RsaCrypto = (function (_super) {
tslib_1.__extends(RsaCrypto, _super);
function RsaCrypto() {
return _super !== null && _super.apply(this, arguments) || this;
}
RsaCrypto.generateKey = function (algorithm, extractable, keyUsages) {
return new Promise(function (resolve, reject) {
var size = algorithm.modulusLength;
var exp = new Buffer(algorithm.publicExponent);
var nExp = 0;
class RsaCrypto extends webcrypto_core_1.BaseCrypto {
static generateKey(algorithm, extractable, keyUsages) {
return new Promise((resolve, reject) => {
const size = algorithm.modulusLength;
const exp = new Buffer(algorithm.publicExponent);
let nExp = 0;
if (exp.length === 3) {
nExp = 1;
}
native.Key.generateRsa(size, nExp, function (err, key) {
native.Key.generateRsa(size, nExp, (err, key) => {
try {
if (err) {
reject(new WebCryptoError("Rsa: Can not generate new key\n" + err.message));
reject(new webcrypto_core_1.WebCryptoError(`Rsa: Can not generate new key\n${err.message}`));
}
else {
var prvUsages = ["sign", "decrypt", "unwrapKey"]
.filter(function (usage) { return keyUsages.some(function (keyUsage) { return keyUsage === usage; }); });
var pubUsages = ["verify", "encrypt", "wrapKey"]
.filter(function (usage) { return keyUsages.some(function (keyUsage) { return keyUsage === usage; }); });
const prvUsages = ["sign", "decrypt", "unwrapKey"]
.filter((usage) => keyUsages.some((keyUsage) => keyUsage === usage));
const pubUsages = ["verify", "encrypt", "wrapKey"]
.filter((usage) => keyUsages.some((keyUsage) => keyUsage === usage));
resolve({

@@ -47,12 +39,12 @@ privateKey: new key_1.CryptoKey(key, algorithm, "private", extractable, prvUsages),

});
};
RsaCrypto.importKey = function (format, keyData, algorithm, extractable, keyUsages) {
var keyType = native.KeyType.PUBLIC;
var alg = algorithm;
return new Promise(function (resolve, reject) {
var formatLC = format.toLocaleLowerCase();
}
static importKey(format, keyData, algorithm, extractable, keyUsages) {
let keyType = native.KeyType.PUBLIC;
const alg = algorithm;
return new Promise((resolve, reject) => {
const formatLC = format.toLocaleLowerCase();
switch (formatLC) {
case "jwk":
var jwk = keyData;
var data = {};
const jwk = keyData;
const data = {};
data["kty"] = jwk.kty;

@@ -70,6 +62,6 @@ data["n"] = b64_decode(jwk.n);

}
native.Key.importJwk(data, keyType, function (err, key) {
native.Key.importJwk(data, keyType, (err, key) => {
try {
if (err) {
reject(new WebCryptoError("ImportKey: Cannot import key from JWK\n" + err));
reject(new webcrypto_core_1.WebCryptoError(`ImportKey: Cannot import key from JWK\n${err}`));
}

@@ -88,5 +80,5 @@ else {

if (!Buffer.isBuffer(keyData)) {
throw new WebCryptoError("ImportKey: keyData is not a Buffer");
throw new webcrypto_core_1.WebCryptoError("ImportKey: keyData is not a Buffer");
}
var importFunction = native.Key.importSpki;
let importFunction = native.Key.importSpki;
if (formatLC === "pkcs8") {

@@ -96,6 +88,6 @@ keyType = native.KeyType.PRIVATE;

}
importFunction(keyData, function (err, key) {
importFunction(keyData, (err, key) => {
try {
if (err) {
reject(new WebCryptoError("ImportKey: Can not import key for " + format + "\n" + err.message));
reject(new webcrypto_core_1.WebCryptoError(`ImportKey: Can not import key for ${format}\n${err.message}`));
}

@@ -112,6 +104,6 @@ else {

default:
throw new WebCryptoError("ImportKey: Wrong format value '" + format + "'");
throw new webcrypto_core_1.WebCryptoError(`ImportKey: Wrong format value '${format}'`);
}
})
.then(function (key) {
.then((key) => {
alg.modulusLength = key.modulusLength() << 3;

@@ -121,22 +113,22 @@ alg.publicExponent = new Uint8Array(key.publicExponent());

});
};
RsaCrypto.exportKey = function (format, key) {
return new Promise(function (resolve, reject) {
var nativeKey = key.native;
var type = key.type === "public" ? native.KeyType.PUBLIC : native.KeyType.PRIVATE;
}
static exportKey(format, key) {
return new Promise((resolve, reject) => {
const nativeKey = key.native;
const type = key.type === "public" ? native.KeyType.PUBLIC : native.KeyType.PRIVATE;
switch (format.toLocaleLowerCase()) {
case "jwk":
nativeKey.exportJwk(type, function (err, data) {
nativeKey.exportJwk(type, (err, data) => {
try {
var jwk = { kty: "RSA" };
const jwk = { kty: "RSA" };
jwk.key_ops = key.usages;
jwk.e = Base64Url.encode(data.e);
jwk.n = Base64Url.encode(data.n);
jwk.e = webcrypto_core_1.Base64Url.encode(data.e);
jwk.n = webcrypto_core_1.Base64Url.encode(data.n);
if (key.type === "private") {
jwk.d = Base64Url.encode(data.d);
jwk.p = Base64Url.encode(data.p);
jwk.q = Base64Url.encode(data.q);
jwk.dp = Base64Url.encode(data.dp);
jwk.dq = Base64Url.encode(data.dq);
jwk.qi = Base64Url.encode(data.qi);
jwk.d = webcrypto_core_1.Base64Url.encode(data.d);
jwk.p = webcrypto_core_1.Base64Url.encode(data.p);
jwk.q = webcrypto_core_1.Base64Url.encode(data.q);
jwk.dp = webcrypto_core_1.Base64Url.encode(data.dp);
jwk.dq = webcrypto_core_1.Base64Url.encode(data.dq);
jwk.qi = webcrypto_core_1.Base64Url.encode(data.qi);
}

@@ -151,3 +143,3 @@ resolve(jwk);

case "spki":
nativeKey.exportSpki(function (err, raw) {
nativeKey.exportSpki((err, raw) => {
if (err) {

@@ -162,3 +154,3 @@ reject(err);

case "pkcs8":
nativeKey.exportPkcs8(function (err, raw) {
nativeKey.exportPkcs8((err, raw) => {
if (err) {

@@ -173,23 +165,18 @@ reject(err);

default:
throw new WebCryptoError("ExportKey: Unknown export format '" + format + "'");
throw new webcrypto_core_1.WebCryptoError(`ExportKey: Unknown export format '${format}'`);
}
});
};
RsaCrypto.wc2ssl = function (algorithm) {
var alg = algorithm.hash.name.toUpperCase().replace("-", "");
}
static wc2ssl(algorithm) {
const alg = algorithm.hash.name.toUpperCase().replace("-", "");
return alg;
};
return RsaCrypto;
}(BaseCrypto));
}
}
exports.RsaCrypto = RsaCrypto;
var RsaPKCS1 = (function (_super) {
tslib_1.__extends(RsaPKCS1, _super);
function RsaPKCS1() {
return _super !== null && _super.apply(this, arguments) || this;
}
RsaPKCS1.exportKey = function (format, key) {
return _super.exportKey.call(this, format, key)
.then(function (jwk) {
class RsaPKCS1 extends RsaCrypto {
static exportKey(format, key) {
return super.exportKey(format, key)
.then((jwk) => {
if (format === "jwk") {
var reg = /(\d+)$/;
const reg = /(\d+)$/;
jwk.alg = "RS" + reg.exec(key.algorithm.hash.name)[1];

@@ -203,11 +190,10 @@ jwk.ext = true;

});
};
RsaPKCS1.sign = function (algorithm, key, data) {
var _this = this;
return new Promise(function (resolve, reject) {
var alg = _this.wc2ssl(key.algorithm);
var nativeKey = key.native;
nativeKey.sign(alg, data, function (err, signature) {
}
static sign(algorithm, key, data) {
return new Promise((resolve, reject) => {
const alg = this.wc2ssl(key.algorithm);
const nativeKey = key.native;
nativeKey.sign(alg, data, (err, signature) => {
if (err) {
reject(new WebCryptoError("NativeError: " + err.message));
reject(new webcrypto_core_1.WebCryptoError("NativeError: " + err.message));
}

@@ -219,11 +205,10 @@ else {

});
};
RsaPKCS1.verify = function (algorithm, key, signature, data) {
var _this = this;
return new Promise(function (resolve, reject) {
var alg = _this.wc2ssl(key.algorithm);
var nativeKey = key.native;
nativeKey.verify(alg, data, signature, function (err, res) {
}
static verify(algorithm, key, signature, data) {
return new Promise((resolve, reject) => {
const alg = this.wc2ssl(key.algorithm);
const nativeKey = key.native;
nativeKey.verify(alg, data, signature, (err, res) => {
if (err) {
reject(new WebCryptoError("NativeError: " + err.message));
reject(new webcrypto_core_1.WebCryptoError("NativeError: " + err.message));
}

@@ -235,19 +220,13 @@ else {

});
};
return RsaPKCS1;
}(RsaCrypto));
}
}
exports.RsaPKCS1 = RsaPKCS1;
var RsaPSS = (function (_super) {
tslib_1.__extends(RsaPSS, _super);
function RsaPSS() {
return _super !== null && _super.apply(this, arguments) || this;
}
RsaPSS.sign = function (algorithm, key, data) {
var _this = this;
return new Promise(function (resolve, reject) {
var alg = _this.wc2ssl(key.algorithm);
var nativeKey = key.native;
nativeKey.RsaPssSign(alg, algorithm.saltLength, data, function (err, signature) {
class RsaPSS extends RsaCrypto {
static sign(algorithm, key, data) {
return new Promise((resolve, reject) => {
const alg = this.wc2ssl(key.algorithm);
const nativeKey = key.native;
nativeKey.RsaPssSign(alg, algorithm.saltLength, data, (err, signature) => {
if (err) {
reject(new WebCryptoError("NativeError: " + err.message));
reject(new webcrypto_core_1.WebCryptoError("NativeError: " + err.message));
}

@@ -259,11 +238,10 @@ else {

});
};
RsaPSS.verify = function (algorithm, key, signature, data) {
var _this = this;
return new Promise(function (resolve, reject) {
var alg = _this.wc2ssl(key.algorithm);
var nativeKey = key.native;
nativeKey.RsaPssVerify(alg, algorithm.saltLength, data, signature, function (err, res) {
}
static verify(algorithm, key, signature, data) {
return new Promise((resolve, reject) => {
const alg = this.wc2ssl(key.algorithm);
const nativeKey = key.native;
nativeKey.RsaPssVerify(alg, algorithm.saltLength, data, signature, (err, res) => {
if (err) {
reject(new WebCryptoError("NativeError: " + err.message));
reject(new webcrypto_core_1.WebCryptoError("NativeError: " + err.message));
}

@@ -275,8 +253,8 @@ else {

});
};
RsaPSS.exportKey = function (format, key) {
return _super.exportKey.call(this, format, key)
.then(function (jwk) {
}
static exportKey(format, key) {
return super.exportKey(format, key)
.then((jwk) => {
if (format === "jwk") {
var reg = /(\d+)$/;
const reg = /(\d+)$/;
jwk.alg = "PS" + reg.exec(key.algorithm.hash.name)[1];

@@ -290,17 +268,12 @@ jwk.ext = true;

});
};
return RsaPSS;
}(RsaCrypto));
}
}
exports.RsaPSS = RsaPSS;
var RsaOAEP = (function (_super) {
tslib_1.__extends(RsaOAEP, _super);
function RsaOAEP() {
return _super !== null && _super.apply(this, arguments) || this;
}
RsaOAEP.exportKey = function (format, key) {
return _super.exportKey.call(this, format, key)
.then(function (jwk) {
class RsaOAEP extends RsaCrypto {
static exportKey(format, key) {
return super.exportKey(format, key)
.then((jwk) => {
if (format === "jwk") {
jwk.alg = "RSA-OAEP";
var mdSize = /(\d+)$/.exec(key.algorithm.hash.name)[1];
const mdSize = /(\d+)$/.exec(key.algorithm.hash.name)[1];
if (mdSize !== "1") {

@@ -319,21 +292,20 @@ jwk.alg += "-" + mdSize;

});
};
RsaOAEP.encrypt = function (algorithm, key, data) {
}
static encrypt(algorithm, key, data) {
return this.EncryptDecrypt(algorithm, key, data, false);
};
RsaOAEP.decrypt = function (algorithm, key, data) {
}
static decrypt(algorithm, key, data) {
return this.EncryptDecrypt(algorithm, key, data, true);
};
RsaOAEP.EncryptDecrypt = function (algorithm, key, data, type) {
var _this = this;
return new Promise(function (resolve, reject) {
var alg = _this.wc2ssl(key.algorithm);
var nativeKey = key.native;
var label = null;
}
static EncryptDecrypt(algorithm, key, data, type) {
return new Promise((resolve, reject) => {
const alg = this.wc2ssl(key.algorithm);
const nativeKey = key.native;
let label = null;
if (algorithm.label) {
label = new Buffer(algorithm.label);
}
nativeKey.RsaOaepEncDec(alg, data, label, type, function (err, res) {
nativeKey.RsaOaepEncDec(alg, data, label, type, (err, res) => {
if (err) {
reject(new WebCryptoError("NativeError: " + err));
reject(new webcrypto_core_1.WebCryptoError("NativeError: " + err));
}

@@ -345,5 +317,4 @@ else {

});
};
return RsaOAEP;
}(RsaCrypto));
}
}
exports.RsaOAEP = RsaOAEP;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var fs = require("fs");
var mkdirp = require("mkdirp");
var path = require("path");
var core = require("webcrypto-core");
var key_1 = require("./key");
var native = require("./native");
var JSON_FILE_EXT = ".json";
var KeyStorageError = (function (_super) {
tslib_1.__extends(KeyStorageError, _super);
function KeyStorageError() {
return _super !== null && _super.apply(this, arguments) || this;
}
return KeyStorageError;
}(core.WebCryptoError));
const fs = require("fs");
const mkdirp = require("mkdirp");
const path = require("path");
const core = require("webcrypto-core");
const key_1 = require("./key");
const native = require("./native");
const JSON_FILE_EXT = ".json";
class KeyStorageError extends core.WebCryptoError {
}
function jwkBufferToBase64(jwk) {
var cpyJwk = jwk.keyJwk;
for (var i in cpyJwk) {
var attr = cpyJwk[i];
const cpyJwk = jwk.keyJwk;
for (const i in cpyJwk) {
const attr = cpyJwk[i];
if (Buffer.isBuffer(attr)) {

@@ -29,9 +23,9 @@ cpyJwk[i] = attr.toString("base64");

function jwkBase64ToBuffer(jwk) {
var cpyJwk = jwk.keyJwk;
var reserved = ["kty", "usage", "alg", "crv", "ext", "alg", "name"];
for (var i in cpyJwk) {
var attr = cpyJwk[i];
const cpyJwk = jwk.keyJwk;
const reserved = ["kty", "usage", "alg", "crv", "ext", "alg", "name"];
for (const i in cpyJwk) {
const attr = cpyJwk[i];
if (reserved.indexOf(i) === -1 && typeof attr === "string") {
try {
var buf = new Buffer(attr, "base64");
const buf = new Buffer(attr, "base64");
cpyJwk[i] = buf;

@@ -45,4 +39,4 @@ }

}
var KeyStorage = (function () {
function KeyStorage(directory) {
class KeyStorage {
constructor(directory) {
this.directory = "";

@@ -56,4 +50,3 @@ this.keys = {};

}
KeyStorage.prototype.clear = function () {
var _this = this;
clear() {
if (!this.directory) {

@@ -63,7 +56,7 @@ return;

this.keys = {};
var items = fs.readdirSync(this.directory);
items.forEach(function (item) {
const items = fs.readdirSync(this.directory);
items.forEach((item) => {
if (item !== "." && item !== "..") {
var file = path.join(_this.directory, item);
var stat = fs.statSync(file);
const file = path.join(this.directory, item);
const stat = fs.statSync(file);
if (stat.isFile) {

@@ -74,5 +67,5 @@ fs.unlinkSync(file);

});
};
KeyStorage.prototype.getItem = function (key) {
var item = this.getItemById(key);
}
getItem(key) {
let item = this.getItemById(key);
if (!item) {

@@ -82,4 +75,4 @@ return null;

item = jwkBase64ToBuffer(item);
var res;
var nativeKey;
let res;
let nativeKey;
switch (item.type.toLowerCase()) {

@@ -95,12 +88,12 @@ case "public":

default:
throw new Error("Unknown type '" + item.type + "'");
throw new Error(`Unknown type '${item.type}'`);
}
res = new key_1.CryptoKey(nativeKey, item.algorithm, item.type, item.extractable, item.usages);
return res;
};
KeyStorage.prototype.key = function (index) {
}
key(index) {
throw new Error("Not implemented yet");
};
KeyStorage.prototype.removeItem = function (key) {
var item = this.getItemById(key);
}
removeItem(key) {
const item = this.getItemById(key);
if (item) {

@@ -110,6 +103,6 @@ this.removeFile(item);

}
};
KeyStorage.prototype.setItem = function (key, data) {
var nativeKey = data.native;
var jwk = null;
}
setItem(key, data) {
const nativeKey = data.native;
let jwk = null;
switch (data.type.toLowerCase()) {

@@ -125,6 +118,6 @@ case "public":

default:
throw new Error("Unsupported key type '" + data.type + "'");
throw new Error(`Unsupported key type '${data.type}'`);
}
if (jwk) {
var item = {
let item = {
algorithm: data.algorithm,

@@ -141,12 +134,12 @@ usages: data.usages,

}
};
KeyStorage.prototype.createDirectory = function (directory, flags) {
}
createDirectory(directory, flags) {
mkdirp.sync(directory, flags);
};
KeyStorage.prototype.readFile = function (file) {
}
readFile(file) {
if (!fs.existsSync(file)) {
throw new KeyStorageError("File '" + file + "' is not exists");
throw new KeyStorageError(`File '${file}' is not exists`);
}
var fText = fs.readFileSync(file, "utf8");
var json;
const fText = fs.readFileSync(file, "utf8");
let json;
try {

@@ -163,5 +156,4 @@ json = JSON.parse(fText);

return null;
};
KeyStorage.prototype.readDirectory = function () {
var _this = this;
}
readDirectory() {
if (!this.directory) {

@@ -171,11 +163,11 @@ throw new KeyStorageError("KeyStorage directory is not set");

this.keys = {};
var items = fs.readdirSync(this.directory);
items.forEach(function (item) {
const items = fs.readdirSync(this.directory);
items.forEach((item) => {
if (item !== "." && item !== "..") {
var file = path.join(_this.directory, item);
var stat = fs.statSync(file);
const file = path.join(this.directory, item);
const stat = fs.statSync(file);
if (stat.isFile) {
var key = _this.readFile(file);
const key = this.readFile(file);
if (key) {
_this.keys[key.name] = key;
this.keys[key.name] = key;
}

@@ -185,5 +177,5 @@ }

});
};
KeyStorage.prototype.saveFile = function (key) {
var json = JSON.stringify(key);
}
saveFile(key) {
const json = JSON.stringify(key);
fs.writeFileSync(path.join(this.directory, key.name + JSON_FILE_EXT), json, {

@@ -193,5 +185,5 @@ encoding: "utf8",

});
};
KeyStorage.prototype.removeFile = function (key) {
var file = key.file;
}
removeFile(key) {
let file = key.file;
if (!file) {

@@ -203,15 +195,10 @@ file = path.join(this.directory, key.name + JSON_FILE_EXT);

}
};
Object.defineProperty(KeyStorage.prototype, "length", {
get: function () {
return Object.keys(this.keys).length;
},
enumerable: true,
configurable: true
});
KeyStorage.prototype.getItemById = function (id) {
}
get length() {
return Object.keys(this.keys).length;
}
getItemById(id) {
return this.keys[id] || null;
};
return KeyStorage;
}());
}
}
exports.KeyStorage = KeyStorage;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var CryptoKey = (function () {
function CryptoKey(key, alg, type, extractable, keyUsages) {
class CryptoKey {
constructor(key, alg, type, extractable, keyUsages) {
this.usages = [];

@@ -12,11 +12,6 @@ this.native_ = key;

}
Object.defineProperty(CryptoKey.prototype, "native", {
get: function () {
return this.native_;
},
enumerable: true,
configurable: true
});
return CryptoKey;
}());
get native() {
return this.native_;
}
}
exports.CryptoKey = CryptoKey;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var native = require("../build/Release/nodessl.node");
const native = require("../build/Release/nodessl.node");
module.exports = native;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var webcrypto = require("webcrypto-core");
var AlgorithmError = webcrypto.AlgorithmError;
var PrepareAlgorithm = webcrypto.PrepareAlgorithm;
var BaseCrypto = webcrypto.BaseCrypto;
var AlgorithmNames = webcrypto.AlgorithmNames;
var aes = require("./crypto/aes");
var ec = require("./crypto/ec");
var hmac = require("./crypto/hmac");
var pbkdf2 = require("./crypto/pbkdf2");
var rsa = require("./crypto/rsa");
var native = require("./native");
const webcrypto = require("webcrypto-core");
const AlgorithmError = webcrypto.AlgorithmError;
const PrepareAlgorithm = webcrypto.PrepareAlgorithm;
const BaseCrypto = webcrypto.BaseCrypto;
const AlgorithmNames = webcrypto.AlgorithmNames;
const aes = require("./crypto/aes");
const ec = require("./crypto/ec");
const hmac = require("./crypto/hmac");
const pbkdf2 = require("./crypto/pbkdf2");
const rsa = require("./crypto/rsa");
const native = require("./native");
function PrepareData(data) {

@@ -29,14 +28,10 @@ return ab2b(data);

}
var SubtleCrypto = (function (_super) {
tslib_1.__extends(SubtleCrypto, _super);
function SubtleCrypto() {
return _super !== null && _super.apply(this, arguments) || this;
}
SubtleCrypto.prototype.digest = function (algorithm, data) {
return _super.prototype.digest.apply(this, arguments)
.then(function () {
return new Promise(function (resolve, reject) {
var alg = PrepareAlgorithm(algorithm);
var dataBytes = PrepareData(data);
var algName = alg.name.toLowerCase();
class SubtleCrypto extends webcrypto.SubtleCrypto {
digest(algorithm, data) {
return super.digest.apply(this, arguments)
.then(() => {
return new Promise((resolve, reject) => {
const alg = PrepareAlgorithm(algorithm);
const dataBytes = PrepareData(data);
const algName = alg.name.toLowerCase();
switch (algName) {

@@ -48,3 +43,3 @@ case "sha-1":

case "sha-512":
native.Core.digest(algName.replace("-", ""), dataBytes, function (err, digest) {
native.Core.digest(algName.replace("-", ""), dataBytes, (err, digest) => {
if (err) {

@@ -63,8 +58,8 @@ reject(err);

});
};
SubtleCrypto.prototype.generateKey = function (algorithm, extractable, keyUsages) {
return _super.prototype.generateKey.apply(this, arguments)
.then(function () {
var alg = PrepareAlgorithm(algorithm);
var AlgClass;
}
generateKey(algorithm, extractable, keyUsages) {
return super.generateKey.apply(this, arguments)
.then(() => {
const alg = PrepareAlgorithm(algorithm);
let AlgClass;
switch (alg.name.toLowerCase()) {

@@ -100,9 +95,9 @@ case AlgorithmNames.RsaSSA.toLowerCase():

});
};
SubtleCrypto.prototype.sign = function (algorithm, key, data) {
return _super.prototype.sign.apply(this, arguments)
.then(function () {
var alg = PrepareAlgorithm(algorithm);
var dataBytes = PrepareData(data);
var AlgClass;
}
sign(algorithm, key, data) {
return super.sign.apply(this, arguments)
.then(() => {
const alg = PrepareAlgorithm(algorithm);
const dataBytes = PrepareData(data);
let AlgClass;
switch (alg.name.toLowerCase()) {

@@ -126,10 +121,10 @@ case AlgorithmNames.RsaSSA.toLowerCase():

});
};
SubtleCrypto.prototype.verify = function (algorithm, key, signature, data) {
return _super.prototype.verify.apply(this, arguments)
.then(function () {
var alg = PrepareAlgorithm(algorithm);
var signatureBytes = PrepareData(signature);
var dataBytes = PrepareData(data);
var AlgClass;
}
verify(algorithm, key, signature, data) {
return super.verify.apply(this, arguments)
.then(() => {
const alg = PrepareAlgorithm(algorithm);
const signatureBytes = PrepareData(signature);
const dataBytes = PrepareData(data);
let AlgClass;
switch (alg.name.toLowerCase()) {

@@ -153,9 +148,9 @@ case AlgorithmNames.RsaSSA.toLowerCase():

});
};
SubtleCrypto.prototype.encrypt = function (algorithm, key, data) {
return _super.prototype.encrypt.apply(this, arguments)
.then(function () {
var alg = PrepareAlgorithm(algorithm);
var dataBytes = PrepareData(data);
var AlgClass;
}
encrypt(algorithm, key, data) {
return super.encrypt.apply(this, arguments)
.then(() => {
const alg = PrepareAlgorithm(algorithm);
const dataBytes = PrepareData(data);
let AlgClass;
switch (alg.name.toLowerCase()) {

@@ -177,9 +172,9 @@ case AlgorithmNames.RsaOAEP.toLowerCase():

});
};
SubtleCrypto.prototype.decrypt = function (algorithm, key, data) {
return _super.prototype.decrypt.apply(this, arguments)
.then(function () {
var alg = PrepareAlgorithm(algorithm);
var dataBytes = PrepareData(data);
var AlgClass;
}
decrypt(algorithm, key, data) {
return super.decrypt.apply(this, arguments)
.then(() => {
const alg = PrepareAlgorithm(algorithm);
const dataBytes = PrepareData(data);
let AlgClass;
switch (alg.name.toLowerCase()) {

@@ -201,11 +196,10 @@ case AlgorithmNames.RsaOAEP.toLowerCase():

});
};
SubtleCrypto.prototype.wrapKey = function (format, key, wrappingKey, wrapAlgorithm) {
var _this = this;
return _super.prototype.wrapKey.apply(this, arguments)
.then(function () {
return _this.exportKey(format, key)
.then(function (exportedKey) {
var alg = webcrypto.PrepareAlgorithm(wrapAlgorithm);
var dataBytes;
}
wrapKey(format, key, wrappingKey, wrapAlgorithm) {
return super.wrapKey.apply(this, arguments)
.then(() => {
return this.exportKey(format, key)
.then((exportedKey) => {
const alg = webcrypto.PrepareAlgorithm(wrapAlgorithm);
let dataBytes;
if (!(exportedKey instanceof ArrayBuffer)) {

@@ -217,3 +211,3 @@ dataBytes = new Buffer(JSON.stringify(exportedKey));

}
var CryptoClass;
let CryptoClass;
if (alg.name.toUpperCase() === webcrypto.AlgorithmNames.AesKW) {

@@ -226,16 +220,15 @@ CryptoClass = aes.AesCrypto;

else {
return _this.encrypt(alg, wrappingKey, dataBytes);
return this.encrypt(alg, wrappingKey, dataBytes);
}
});
});
};
SubtleCrypto.prototype.unwrapKey = function (format, wrappedKey, unwrappingKey, unwrapAlgorithm, unwrappedKeyAlgorithm, extractable, keyUsages) {
var _this = this;
return _super.prototype.unwrapKey.apply(this, arguments)
.then(function () {
}
unwrapKey(format, wrappedKey, unwrappingKey, unwrapAlgorithm, unwrappedKeyAlgorithm, extractable, keyUsages) {
return super.unwrapKey.apply(this, arguments)
.then(() => {
return Promise.resolve()
.then(function () {
var alg = webcrypto.PrepareAlgorithm(unwrapAlgorithm);
var dataBytes = PrepareData(wrappedKey);
var CryptoClass;
.then(() => {
const alg = webcrypto.PrepareAlgorithm(unwrapAlgorithm);
const dataBytes = PrepareData(wrappedKey);
let CryptoClass;
if (alg.name.toUpperCase() === webcrypto.AlgorithmNames.AesKW) {

@@ -248,7 +241,7 @@ CryptoClass = aes.AesCrypto;

else {
return _this.decrypt(alg, unwrappingKey, dataBytes);
return this.decrypt(alg, unwrappingKey, dataBytes);
}
})
.then(function (decryptedKey) {
var keyData;
.then((decryptedKey) => {
let keyData;
if (format === "jwk") {

@@ -260,12 +253,12 @@ keyData = JSON.parse(new Buffer(decryptedKey).toString());

}
return _this.importKey(format, keyData, unwrappedKeyAlgorithm, extractable, keyUsages);
return this.importKey(format, keyData, unwrappedKeyAlgorithm, extractable, keyUsages);
});
});
};
SubtleCrypto.prototype.deriveKey = function (algorithm, baseKey, derivedKeyType, extractable, keyUsages) {
return _super.prototype.deriveKey.apply(this, arguments)
.then(function () {
var alg = PrepareAlgorithm(algorithm);
var algDerivedKeyType = PrepareAlgorithm(derivedKeyType);
var AlgClass;
}
deriveKey(algorithm, baseKey, derivedKeyType, extractable, keyUsages) {
return super.deriveKey.apply(this, arguments)
.then(() => {
const alg = PrepareAlgorithm(algorithm);
const algDerivedKeyType = PrepareAlgorithm(derivedKeyType);
let AlgClass;
switch (alg.name.toLowerCase()) {

@@ -283,8 +276,8 @@ case AlgorithmNames.EcDH.toLowerCase():

});
};
SubtleCrypto.prototype.deriveBits = function (algorithm, baseKey, length) {
return _super.prototype.deriveBits.apply(this, arguments)
.then(function () {
var alg = PrepareAlgorithm(algorithm);
var AlgClass;
}
deriveBits(algorithm, baseKey, length) {
return super.deriveBits.apply(this, arguments)
.then(() => {
const alg = PrepareAlgorithm(algorithm);
let AlgClass;
switch (alg.name.toLowerCase()) {

@@ -302,7 +295,7 @@ case AlgorithmNames.EcDH.toLowerCase():

});
};
SubtleCrypto.prototype.exportKey = function (format, key) {
return _super.prototype.exportKey.apply(this, arguments)
.then(function () {
var AlgClass;
}
exportKey(format, key) {
return super.exportKey.apply(this, arguments)
.then(() => {
let AlgClass;
switch (key.algorithm.name.toLowerCase()) {

@@ -337,12 +330,12 @@ case AlgorithmNames.RsaSSA.toLowerCase():

});
};
SubtleCrypto.prototype.importKey = function (format, keyData, algorithm, extractable, keyUsages) {
return _super.prototype.importKey.apply(this, arguments)
.then(function () {
var alg = PrepareAlgorithm(algorithm);
var dataAny = keyData;
}
importKey(format, keyData, algorithm, extractable, keyUsages) {
return super.importKey.apply(this, arguments)
.then(() => {
const alg = PrepareAlgorithm(algorithm);
let dataAny = keyData;
if (format !== "jwk") {
dataAny = PrepareData(dataAny);
}
var AlgClass;
let AlgClass;
switch (alg.name.toLowerCase()) {

@@ -380,5 +373,4 @@ case AlgorithmNames.RsaSSA.toLowerCase():

});
};
return SubtleCrypto;
}(webcrypto.SubtleCrypto));
}
}
exports.SubtleCrypto = SubtleCrypto;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var crypto = require("crypto");
var webcrypto = require("webcrypto-core");
var key_storage_1 = require("./key_storage");
var subtle = require("./subtle");
var ERR_RANDOM_VALUE_LENGTH = "Failed to execute 'getRandomValues' on 'Crypto': The ArrayBufferView's byte length (%1) exceeds the number of bytes of entropy available via this API (65536).";
var WebCrypto = (function () {
function WebCrypto(options) {
const crypto = require("crypto");
const webcrypto = require("webcrypto-core");
const key_storage_1 = require("./key_storage");
const subtle = require("./subtle");
const ERR_RANDOM_VALUE_LENGTH = "Failed to execute 'getRandomValues' on 'Crypto': The ArrayBufferView's byte length (%1) exceeds the number of bytes of entropy available via this API (65536).";
class WebCrypto {
constructor(options) {
this.subtle = new subtle.SubtleCrypto();

@@ -15,14 +15,16 @@ if (options && options.directory) {

}
WebCrypto.prototype.getRandomValues = function (array) {
if (array.byteLength > 65536) {
var error = new webcrypto.WebCryptoError(ERR_RANDOM_VALUE_LENGTH, array.byteLength);
error.code = 22;
throw error;
getRandomValues(array) {
if (array) {
if (array.byteLength > 65536) {
const error = new webcrypto.WebCryptoError(ERR_RANDOM_VALUE_LENGTH, array.byteLength);
error.code = 22;
throw error;
}
const bytes = crypto.randomBytes(array.byteLength);
array.set(new array.constructor(bytes.buffer));
return array;
}
var bytes = crypto.randomBytes(array.byteLength);
array.set(new array.constructor(bytes.buffer));
return array;
};
return WebCrypto;
}());
return null;
}
}
module.exports = WebCrypto;

@@ -55,38 +55,38 @@ /// <reference types="node" />

class Key {
type: number;
modulusLength(): number;
publicExponent(): Buffer;
exportJwk(keyType: KeyType, callback: (err: Error, jwk: any) => void): void;
exportJwk(keyType: KeyType): any;
exportSpki(callback: (err: Error, raw: Buffer) => void): void;
exportPkcs8(callback: (err: Error, raw: Buffer) => void): void;
sign(digestName: string, message: Buffer, callback: (err: Error, signature: Buffer) => void): void;
verify(digestName: string, message: Buffer, signature: Buffer, callback: (err: Error, valid: boolean) => void): void;
RsaOaepEncDec(digestName: string, data: Buffer, label: Buffer | null, decrypt: boolean, callback: (err: Error, raw: Buffer) => void): void;
RsaPssSign(digestName: string, saltLength: number, data: Buffer, cb: (err: Error, signature: Buffer) => void): void;
RsaPssVerify(digestName: string, saltLength: number, data: Buffer, signature: Buffer, cb: (err: Error, verified: boolean) => void): void;
EcdhDeriveKey(pubkey: Key, derivedLen: number, callback: (err: Error, raw: Buffer) => void): void;
EcdhDeriveBits(pubkey: Key, lengthBits: number, callback: (err: Error, raw: Buffer) => void): void;
static generateRsa(modulus: number, publicExponent: RsaPublicExponent, callback: (err: Error, key: Key) => void): void;
static generateEc(namedCurve: EcNamedCurves, callback: (err: Error, key: Key) => void): void;
static importJwk(jwk: Object, keyType: KeyType, callback: (err: Error, key: Key) => void): void;
static importJwk(jwk: {
[key: string]: Buffer;
}, keyType: KeyType): any;
static importSpki(raw: Buffer, callback: (err: Error, key: Key) => void): void;
static importPkcs8(raw: Buffer, callback: (err: Error, key: Key) => void): void;
public static generateRsa(modulus: number, publicExponent: RsaPublicExponent, callback: (err: Error, key: Key) => void): void;
public static generateEc(namedCurve: EcNamedCurves, callback: (err: Error, key: Key) => void): void;
public static importJwk(jwk: Object, keyType: KeyType, callback: (err: Error, key: Key) => void): void;
public static importJwk(jwk: { [key: string]: Buffer; }, keyType: KeyType): any;
public static importSpki(raw: Buffer, callback: (err: Error, key: Key) => void): void;
public static importPkcs8(raw: Buffer, callback: (err: Error, key: Key) => void): void;
public type: number;
public modulusLength(): number;
public publicExponent(): Buffer;
public exportJwk(keyType: KeyType, callback: (err: Error, jwk: any) => void): void;
public exportJwk(keyType: KeyType): any;
public exportSpki(callback: (err: Error, raw: Buffer) => void): void;
public exportPkcs8(callback: (err: Error, raw: Buffer) => void): void;
public sign(digestName: string, message: Buffer, callback: (err: Error, signature: Buffer) => void): void;
public verify(digestName: string, message: Buffer, signature: Buffer, callback: (err: Error, valid: boolean) => void): void;
public RsaOaepEncDec(digestName: string, data: Buffer, label: Buffer | null, decrypt: boolean, callback: (err: Error, raw: Buffer) => void): void;
public RsaPssSign(digestName: string, saltLength: number, data: Buffer, cb: (err: Error, signature: Buffer) => void): void;
public RsaPssVerify(digestName: string, saltLength: number, data: Buffer, signature: Buffer, cb: (err: Error, verified: boolean) => void): void;
public EcdhDeriveKey(pubkey: Key, derivedLen: number, callback: (err: Error, raw: Buffer) => void): void;
public EcdhDeriveBits(pubkey: Key, lengthBits: number, callback: (err: Error, raw: Buffer) => void): void;
}
class AesKey {
static generate(keySize: number, callback: (err: Error, key: AesKey) => void): void;
encrypt(cipher: string, iv: Buffer, input: Buffer, callback: (err: Error, data: Buffer) => void): void;
encryptGcm(iv: Buffer, input: Buffer, aad: Buffer | undefined, tag: number, callback: (err: Error, data: Buffer) => void): void;
decrypt(cipher: string, iv: Buffer, input: Buffer, callback: (err: Error, data: Buffer) => void): void;
decryptGcm(iv: Buffer, input: Buffer, aad: Buffer | undefined, tag: number, callback: (err: Error, data: Buffer) => void): void;
export(callback: (err: Error, raw: Buffer) => void): void;
static import(raw: Buffer, callback: (err: Error, key: AesKey) => void): void;
public static generate(keySize: number, callback: (err: Error, key: AesKey) => void): void;
public static import(raw: Buffer, callback: (err: Error, key: AesKey) => void): void;
public encrypt(cipher: string, iv: Buffer, input: Buffer, callback: (err: Error, data: Buffer) => void): void;
public encryptGcm(iv: Buffer, input: Buffer, aad: Buffer | undefined, tag: number, callback: (err: Error, data: Buffer) => void): void;
public decrypt(cipher: string, iv: Buffer, input: Buffer, callback: (err: Error, data: Buffer) => void): void;
public decryptGcm(iv: Buffer, input: Buffer, aad: Buffer | undefined, tag: number, callback: (err: Error, data: Buffer) => void): void;
public export(callback: (err: Error, raw: Buffer) => void): void;
}
class Core {
static digest(digestName: string, messgae: Buffer, callback: (err: Error, digest: Buffer) => void): void;
public static digest(digestName: string, messgae: Buffer, callback: (err: Error, digest: Buffer) => void): void;
}

@@ -100,8 +100,8 @@

class CryptoKey implements NativeCryptoKey {
type: string;
extractable: boolean;
algorithm: Algorithm;
usages: string[];
public type: string;
public extractable: boolean;
public algorithm: Algorithm;
public usages: string[];
public readonly native: AesKey | Key;
private native_: AesKey | Key;
readonly native: AesKey | Key;
constructor(key: AesKey | Key, alg: Algorithm, type: string, extractable: boolean, keyUsages: string[]);

@@ -117,2 +117,3 @@ }

class KeyStorage {
public readonly length: number;
protected directory: string;

@@ -123,2 +124,8 @@ protected keys: {

constructor(directory: string);
public clear(): void;
public getItem(key: string): CryptoKey | null;
public key(index: number): string;
public removeItem(key: string): void;
public setItem(key: string, data: CryptoKey): void;
protected getItemById(id: string): IKeyStorageItem;
protected createDirectory(directory: string, flags?: any): void;

@@ -129,9 +136,2 @@ protected readFile(file: string): IKeyStorageItem | null;

protected removeFile(key: IKeyStorageItem): void;
readonly length: number;
clear(): void;
protected getItemById(id: string): IKeyStorageItem;
getItem(key: string): CryptoKey | null;
key(index: number): string;
removeItem(key: string): void;
setItem(key: string, data: CryptoKey): void;
}

@@ -144,20 +144,20 @@

class SubtleCrypto extends WebcryptoCore.SubtleCrypto {
digest(algorithm: AlgorithmIdentifier, data: NodeBufferSource): PromiseLike<ArrayBuffer>;
generateKey(algorithm: string, extractable: boolean, keyUsages: string[]): PromiseLike<CryptoKeyPair | CryptoKey>;
generateKey(algorithm: RsaHashedKeyGenParams | EcKeyGenParams | DhKeyGenParams, extractable: boolean, keyUsages: string[]): PromiseLike<CryptoKeyPair>;
generateKey(algorithm: AesKeyGenParams | HmacKeyGenParams | Pbkdf2Params, extractable: boolean, keyUsages: string[]): PromiseLike<CryptoKey>;
sign(algorithm: string | RsaPssParams | EcdsaParams | AesCmacParams, key: CryptoKey, data: NodeBufferSource): PromiseLike<ArrayBuffer>;
verify(algorithm: string | RsaPssParams | EcdsaParams | AesCmacParams, key: CryptoKey, signature: NodeBufferSource, data: NodeBufferSource): PromiseLike<boolean>;
encrypt(algorithm: string | RsaOaepParams | AesCtrParams | AesCbcParams | AesCmacParams | AesGcmParams | AesCfbParams, key: CryptoKey, data: NodeBufferSource): PromiseLike<ArrayBuffer>;
decrypt(algorithm: string | RsaOaepParams | AesCtrParams | AesCbcParams | AesCmacParams | AesGcmParams | AesCfbParams, key: CryptoKey, data: NodeBufferSource): PromiseLike<ArrayBuffer>;
wrapKey(format: string, key: CryptoKey, wrappingKey: CryptoKey, wrapAlgorithm: AlgorithmIdentifier): PromiseLike<ArrayBuffer>;
unwrapKey(format: string, wrappedKey: NodeBufferSource, unwrappingKey: CryptoKey, unwrapAlgorithm: AlgorithmIdentifier, unwrappedKeyAlgorithm: AlgorithmIdentifier, extractable: boolean, keyUsages: string[]): PromiseLike<CryptoKey>;
deriveKey(algorithm: string | EcdhKeyDeriveParams | DhKeyDeriveParams | ConcatParams | HkdfCtrParams | Pbkdf2Params, baseKey: CryptoKey, derivedKeyType: string | AesDerivedKeyParams | HmacImportParams | ConcatParams | HkdfCtrParams | Pbkdf2Params, extractable: boolean, keyUsages: string[]): PromiseLike<CryptoKey>;
deriveBits(algorithm: string | EcdhKeyDeriveParams | DhKeyDeriveParams | ConcatParams | HkdfCtrParams | Pbkdf2Params, baseKey: CryptoKey, length: number): PromiseLike<ArrayBuffer>;
exportKey(format: "jwk", key: CryptoKey): PromiseLike<JsonWebKey>;
exportKey(format: "raw" | "pkcs8" | "spki", key: CryptoKey): PromiseLike<ArrayBuffer>;
exportKey(format: string, key: CryptoKey): PromiseLike<JsonWebKey | ArrayBuffer>;
importKey(format: "jwk", keyData: JsonWebKey, algorithm: string | RsaHashedImportParams | EcKeyImportParams | HmacImportParams | DhImportKeyParams, extractable: boolean, keyUsages: string[]): PromiseLike<CryptoKey>;
importKey(format: "raw" | "pkcs8" | "spki", keyData: NodeBufferSource, algorithm: string | RsaHashedImportParams | EcKeyImportParams | HmacImportParams | DhImportKeyParams, extractable: boolean, keyUsages: string[]): PromiseLike<CryptoKey>;
importKey(format: string, keyData: JsonWebKey | NodeBufferSource, algorithm: string | RsaHashedImportParams | EcKeyImportParams | HmacImportParams | DhImportKeyParams, extractable: boolean, keyUsages: string[]): PromiseLike<CryptoKey>;
public digest(algorithm: AlgorithmIdentifier, data: NodeBufferSource): PromiseLike<ArrayBuffer>;
public generateKey(algorithm: string, extractable: boolean, keyUsages: string[]): PromiseLike<CryptoKeyPair | CryptoKey>;
public generateKey(algorithm: RsaHashedKeyGenParams | EcKeyGenParams | DhKeyGenParams, extractable: boolean, keyUsages: string[]): PromiseLike<CryptoKeyPair>;
public generateKey(algorithm: AesKeyGenParams | HmacKeyGenParams | Pbkdf2Params, extractable: boolean, keyUsages: string[]): PromiseLike<CryptoKey>;
public sign(algorithm: string | RsaPssParams | EcdsaParams | AesCmacParams, key: CryptoKey, data: NodeBufferSource): PromiseLike<ArrayBuffer>;
public verify(algorithm: string | RsaPssParams | EcdsaParams | AesCmacParams, key: CryptoKey, signature: NodeBufferSource, data: NodeBufferSource): PromiseLike<boolean>;
public encrypt(algorithm: string | RsaOaepParams | AesCtrParams | AesCbcParams | AesCmacParams | AesGcmParams | AesCfbParams, key: CryptoKey, data: NodeBufferSource): PromiseLike<ArrayBuffer>;
public decrypt(algorithm: string | RsaOaepParams | AesCtrParams | AesCbcParams | AesCmacParams | AesGcmParams | AesCfbParams, key: CryptoKey, data: NodeBufferSource): PromiseLike<ArrayBuffer>;
public wrapKey(format: string, key: CryptoKey, wrappingKey: CryptoKey, wrapAlgorithm: AlgorithmIdentifier): PromiseLike<ArrayBuffer>;
public unwrapKey(format: string, wrappedKey: NodeBufferSource, unwrappingKey: CryptoKey, unwrapAlgorithm: AlgorithmIdentifier, unwrappedKeyAlgorithm: AlgorithmIdentifier, extractable: boolean, keyUsages: string[]): PromiseLike<CryptoKey>;
public deriveKey(algorithm: string | EcdhKeyDeriveParams | DhKeyDeriveParams | ConcatParams | HkdfCtrParams | Pbkdf2Params, baseKey: CryptoKey, derivedKeyType: string | AesDerivedKeyParams | HmacImportParams | ConcatParams | HkdfCtrParams | Pbkdf2Params, extractable: boolean, keyUsages: string[]): PromiseLike<CryptoKey>;
public deriveBits(algorithm: string | EcdhKeyDeriveParams | DhKeyDeriveParams | ConcatParams | HkdfCtrParams | Pbkdf2Params, baseKey: CryptoKey, length: number): PromiseLike<ArrayBuffer>;
public exportKey(format: "jwk", key: CryptoKey): PromiseLike<JsonWebKey>;
public exportKey(format: "raw" | "pkcs8" | "spki", key: CryptoKey): PromiseLike<ArrayBuffer>;
public exportKey(format: string, key: CryptoKey): PromiseLike<JsonWebKey | ArrayBuffer>;
public importKey(format: "jwk", keyData: JsonWebKey, algorithm: string | RsaHashedImportParams | EcKeyImportParams | HmacImportParams | DhImportKeyParams, extractable: boolean, keyUsages: string[]): PromiseLike<CryptoKey>;
public importKey(format: "raw" | "pkcs8" | "spki", keyData: NodeBufferSource, algorithm: string | RsaHashedImportParams | EcKeyImportParams | HmacImportParams | DhImportKeyParams, extractable: boolean, keyUsages: string[]): PromiseLike<CryptoKey>;
public importKey(format: string, keyData: JsonWebKey | NodeBufferSource, algorithm: string | RsaHashedImportParams | EcKeyImportParams | HmacImportParams | DhImportKeyParams, extractable: boolean, keyUsages: string[]): PromiseLike<CryptoKey>;
}

@@ -182,4 +182,3 @@

*/
public getRandomValues(array: NodeBufferSource): NodeBufferSource;
public getRandomValues(array: ArrayBufferView): ArrayBufferView;
public getRandomValues(array: Int8Array | Int16Array | Int32Array | Uint8Array | Uint16Array | Uint32Array | Uint8ClampedArray | Float32Array | Float64Array | DataView | null): Int8Array | Int16Array | Int32Array | Uint8Array | Uint16Array | Uint32Array | Uint8ClampedArray | Float32Array | Float64Array | DataView | null;

@@ -186,0 +185,0 @@ }

{
"name": "node-webcrypto-ossl",
"version": "1.0.36",
"version": "1.0.37",
"repository": {

@@ -44,13 +44,13 @@ "type": "git",

"tslib": "^1.9.0",
"webcrypto-core": "^0.1.19"
"webcrypto-core": "^0.1.22"
},
"devDependencies": {
"@types/mkdirp": "^0.3.29",
"@types/node": "^8.9.5",
"coveralls": "^2.13.3",
"mocha": "^3.5.3",
"nyc": "^10.1.2",
"@types/mkdirp": "^0.5.2",
"@types/node": "^10.0.8",
"coveralls": "^3.0.1",
"mocha": "^5.1.1",
"nyc": "^11.7.3",
"pvtsutils": "^1.0.2",
"typescript": "^2.7.2"
"typescript": "^2.8.3"
}
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc