@waves/ts-lib-crypto
Advanced tools
Comparing version 1.3.1 to 1.4.1
"use strict"; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
// import * as CryptoJS from 'crypto-js' | ||
var forge = require("node-forge"); | ||
var base58_1 = require("../libs/base58"); | ||
//@ts-ignore | ||
var util_1 = require("node-forge/lib/util"); | ||
var base58_1 = __importDefault(require("../libs/base58")); | ||
var param_1 = require("./param"); | ||
var string_bytes_1 = require("./string-bytes"); | ||
exports.base64Decode = function (input) { | ||
return string_bytes_1.stringToBytes(forge.util.decode64(input), 'raw'); | ||
return string_bytes_1.stringToBytes(util_1.decode64(input), 'raw'); | ||
}; | ||
exports.base64Encode = function (input) { | ||
return forge.util.encode64(string_bytes_1.bytesToString(param_1._fromIn(input), 'raw')); | ||
return util_1.encode64(string_bytes_1.bytesToString(param_1._fromIn(input), 'raw')); | ||
}; | ||
@@ -21,5 +24,5 @@ exports.base58Decode = function (input) { | ||
exports.base16Decode = function (input) { | ||
return string_bytes_1.stringToBytes(forge.util.hexToBytes(input), 'raw'); | ||
return string_bytes_1.stringToBytes(util_1.hexToBytes(input), 'raw'); | ||
}; | ||
exports.base16Encode = function (input) { return forge.util.bytesToHex(string_bytes_1.bytesToString(param_1._fromIn(input), 'raw')); }; | ||
exports.base16Encode = function (input) { return util_1.bytesToHex(string_bytes_1.bytesToString(param_1._fromIn(input), 'raw')); }; | ||
//# sourceMappingURL=base-xx.js.map |
"use strict"; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -9,3 +12,3 @@ var interface_1 = require("./interface"); | ||
var util_1 = require("./util"); | ||
var axlsign_1 = require("../libs/axlsign"); | ||
var axlsign_1 = __importDefault(require("../libs/axlsign")); | ||
exports.seedWithNonce = function (seed, nonce) { return ({ seed: seed_1.Seed.toBinary(seed).seed, nonce: nonce }); }; | ||
@@ -12,0 +15,0 @@ var buildAddress = function (publicKeyBytes, chainId) { |
@@ -18,4 +18,17 @@ "use strict"; | ||
}; | ||
var __importStar = (this && this.__importStar) || function (mod) { | ||
if (mod && mod.__esModule) return mod; | ||
var result = {}; | ||
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; | ||
result["default"] = mod; | ||
return result; | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var forge = require("node-forge"); | ||
// @ts-ignore | ||
var forgeCipher = __importStar(require("node-forge/lib/cipher")); | ||
// @ts-ignore | ||
var util = __importStar(require("node-forge/lib/util")); | ||
var random_1 = require("./random"); | ||
@@ -25,9 +38,9 @@ var param_1 = require("../conversions/param"); | ||
var concat_split_1 = require("./concat-split"); | ||
var axlsign_1 = require("../libs/axlsign"); | ||
var axlsign_1 = __importDefault(require("../libs/axlsign")); | ||
var string_bytes_1 = require("../conversions/string-bytes"); | ||
exports.aesEncrypt = function (data, key, mode, iv) { | ||
if (mode === void 0) { mode = 'CBC'; } | ||
var cipher = forge.cipher.createCipher("AES-" + mode, string_bytes_1.bytesToString(param_1._fromIn(key), 'raw')); | ||
cipher.start({ iv: iv && forge.util.createBuffer(string_bytes_1.bytesToString(param_1._fromIn(iv), 'raw')) }); | ||
cipher.update(forge.util.createBuffer(string_bytes_1.bytesToString(data, 'raw'))); | ||
var cipher = forgeCipher.createCipher("AES-" + mode, string_bytes_1.bytesToString(param_1._fromIn(key), 'raw')); | ||
cipher.start({ iv: iv && util.createBuffer(string_bytes_1.bytesToString(param_1._fromIn(iv), 'raw')) }); | ||
cipher.update(util.createBuffer(string_bytes_1.bytesToString(data, 'raw'))); | ||
cipher.finish(); | ||
@@ -38,5 +51,5 @@ return string_bytes_1.stringToBytes(cipher.output.getBytes(), 'raw'); | ||
if (mode === void 0) { mode = 'CBC'; } | ||
var decipher = forge.cipher.createDecipher("AES-" + mode, string_bytes_1.bytesToString(param_1._fromIn(key), 'raw')); | ||
decipher.start({ iv: iv && forge.util.createBuffer(string_bytes_1.bytesToString(param_1._fromIn(iv), 'raw')) }); | ||
var encbuf = forge.util.createBuffer(string_bytes_1.bytesToString(param_1._fromIn(encryptedData), 'raw')); | ||
var decipher = forgeCipher.createDecipher("AES-" + mode, string_bytes_1.bytesToString(param_1._fromIn(key), 'raw')); | ||
decipher.start({ iv: iv && util.createBuffer(string_bytes_1.bytesToString(param_1._fromIn(iv), 'raw')) }); | ||
var encbuf = util.createBuffer(string_bytes_1.bytesToString(param_1._fromIn(encryptedData), 'raw')); | ||
decipher.update(encbuf); | ||
@@ -43,0 +56,0 @@ if (!decipher.finish()) { |
"use strict"; | ||
var __importStar = (this && this.__importStar) || function (mod) { | ||
if (mod && mod.__esModule) return mod; | ||
var result = {}; | ||
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; | ||
result["default"] = mod; | ||
return result; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var param_1 = require("../conversions/param"); | ||
var sha3_1 = require("../libs/sha3"); | ||
var forge = require("node-forge"); | ||
var blake = require("../libs/blake2b"); | ||
// @ts-ignore | ||
var forgeHmac = __importStar(require("node-forge/lib/hmac")); | ||
// @ts-ignore | ||
var forgeMd = __importStar(require("node-forge/lib/md")); | ||
var blake = __importStar(require("../libs/blake2b")); | ||
var string_bytes_1 = require("../conversions/string-bytes"); | ||
@@ -12,3 +22,3 @@ exports._hashChain = function (input) { | ||
exports.sha256 = function (input) { | ||
var md = forge.md.sha256.create(); | ||
var md = forgeMd.algorithms.sha256.create(); | ||
md.update(string_bytes_1.bytesToString(input, 'raw')); | ||
@@ -24,3 +34,3 @@ return string_bytes_1.stringToBytes(md.digest().getBytes(), 'raw'); | ||
exports.hmacSHA256 = function (message, key) { | ||
var hmac = forge.hmac.create(); | ||
var hmac = forgeHmac.create(); | ||
hmac.start('sha256', string_bytes_1.bytesToString(param_1._fromIn(key), 'raw')); | ||
@@ -27,0 +37,0 @@ hmac.update(string_bytes_1.bytesToString(param_1._fromIn(message), 'raw')); |
"use strict"; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var forge = require("node-forge"); | ||
// @ts-ignore | ||
var random_1 = __importDefault(require("node-forge/lib/random")); | ||
var seed_words_list_1 = require("./seed-words-list"); | ||
var string_bytes_1 = require("../conversions/string-bytes"); | ||
var _random = function (count) { return string_bytes_1.stringToBytes(forge.random.getBytesSync(count), 'raw'); }; | ||
var _random = function (count) { return string_bytes_1.stringToBytes(random_1.default.getBytesSync(count), 'raw'); }; | ||
var ensureBuffer = function () { | ||
@@ -8,0 +12,0 @@ try { |
@@ -37,19 +37,33 @@ "use strict"; | ||
}; | ||
var __importStar = (this && this.__importStar) || function (mod) { | ||
if (mod && mod.__esModule) return mod; | ||
var result = {}; | ||
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; | ||
result["default"] = mod; | ||
return result; | ||
}; | ||
var _this = this; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var node_forge_1 = require("node-forge"); | ||
// @ts-ignore | ||
var pki = __importStar(require("node-forge/lib/pki")); | ||
// @ts-ignore | ||
var md = __importStar(require("node-forge/lib/md")); | ||
// @ts-ignore | ||
var md5 = __importStar(require("node-forge/lib/md5")); | ||
// @ts-ignore | ||
var util = __importStar(require("node-forge/lib/util")); | ||
var base_xx_1 = require("../conversions/base-xx"); | ||
var string_bytes_1 = require("../conversions/string-bytes"); | ||
var sha3 = require("js-sha3"); | ||
var sha3 = __importStar(require("js-sha3")); | ||
// HACK. Monkey patch node-forge library to provide oids for missing hash algorithms | ||
node_forge_1.pki.oids['sha224'] = '2.16.840.1.101.3.4.2.4'; | ||
node_forge_1.pki.oids['2.16.840.1.101.3.4.2.4'] = 'sha224'; | ||
node_forge_1.pki.oids['sha3-224'] = '2.16.840.1.101.3.4.2.7'; | ||
node_forge_1.pki.oids['2.16.840.1.101.3.4.2.7'] = 'sha3-224'; | ||
node_forge_1.pki.oids['sha3-256'] = '2.16.840.1.101.3.4.2.8'; | ||
node_forge_1.pki.oids['2.16.840.1.101.3.4.2.8'] = 'sha3-256'; | ||
node_forge_1.pki.oids['sha3-384'] = '2.16.840.1.101.3.4.2.9'; | ||
node_forge_1.pki.oids['2.16.840.1.101.3.4.2.9'] = 'sha3-384'; | ||
node_forge_1.pki.oids['sha3-512'] = '2.16.840.1.101.3.4.2.10'; | ||
node_forge_1.pki.oids['2.16.840.1.101.3.4.2.10'] = 'sha3-512'; | ||
pki.oids['sha224'] = '2.16.840.1.101.3.4.2.4'; | ||
pki.oids['2.16.840.1.101.3.4.2.4'] = 'sha224'; | ||
pki.oids['sha3-224'] = '2.16.840.1.101.3.4.2.7'; | ||
pki.oids['2.16.840.1.101.3.4.2.7'] = 'sha3-224'; | ||
pki.oids['sha3-256'] = '2.16.840.1.101.3.4.2.8'; | ||
pki.oids['2.16.840.1.101.3.4.2.8'] = 'sha3-256'; | ||
pki.oids['sha3-384'] = '2.16.840.1.101.3.4.2.9'; | ||
pki.oids['2.16.840.1.101.3.4.2.9'] = 'sha3-384'; | ||
pki.oids['sha3-512'] = '2.16.840.1.101.3.4.2.10'; | ||
pki.oids['2.16.840.1.101.3.4.2.10'] = 'sha3-512'; | ||
exports.pemToBytes = function (pem) { return base_xx_1.base64Decode(pem.trim() | ||
@@ -78,6 +92,6 @@ .split(/\r\n|\n/) | ||
exports.rsaKeyPairSync = function (bits, e) { | ||
var kp = node_forge_1.pki.rsa.generateKeyPair(bits, e); | ||
var kp = pki.rsa.generateKeyPair(bits, e); | ||
return { | ||
rsaPrivate: exports.pemToBytes(node_forge_1.pki.privateKeyToPem(kp.privateKey)), | ||
rsaPublic: exports.pemToBytes(node_forge_1.pki.publicKeyToPem(kp.publicKey)), | ||
rsaPrivate: exports.pemToBytes(pki.privateKeyToPem(kp.privateKey)), | ||
rsaPublic: exports.pemToBytes(pki.publicKeyToPem(kp.publicKey)), | ||
}; | ||
@@ -88,8 +102,8 @@ }; | ||
return [2 /*return*/, new Promise(function (resolve, reject) { | ||
node_forge_1.pki.rsa.generateKeyPair(bits, e, function (err, kp) { | ||
pki.rsa.generateKeyPair(bits, e, function (err, kp) { | ||
if (err) | ||
reject(err); | ||
resolve({ | ||
rsaPrivate: exports.pemToBytes(node_forge_1.pki.privateKeyToPem(kp.privateKey)), | ||
rsaPublic: exports.pemToBytes(node_forge_1.pki.publicKeyToPem(kp.publicKey)), | ||
rsaPrivate: exports.pemToBytes(pki.privateKeyToPem(kp.privateKey)), | ||
rsaPublic: exports.pemToBytes(pki.publicKeyToPem(kp.publicKey)), | ||
}); | ||
@@ -117,3 +131,3 @@ }); | ||
var bytes = Uint8Array.from(this.sha3Digest.digest()); | ||
return node_forge_1.util.createBuffer(string_bytes_1.bytesToString(bytes, 'raw')); | ||
return util.createBuffer(string_bytes_1.bytesToString(bytes, 'raw')); | ||
}; | ||
@@ -123,8 +137,8 @@ return MessageDigestAdapter; | ||
var digestMap = { | ||
'MD5': node_forge_1.md.md5, | ||
'SHA1': node_forge_1.md.sha1, | ||
'MD5': md5, | ||
'SHA1': md.algorithms.sha1, | ||
'SHA224': digestCreatorPlaceHolder('SHA224'), | ||
'SHA256': node_forge_1.md.sha256, | ||
'SHA384': node_forge_1.md.sha384, | ||
'SHA512': node_forge_1.md.sha512, | ||
'SHA256': md.algorithms.sha256, | ||
'SHA384': md.algorithms.sha384, | ||
'SHA512': md.algorithms.sha512, | ||
'SHA3-224': MessageDigestAdapter.makeCreator(sha3.sha3_224, 'sha3-224'), | ||
@@ -138,3 +152,3 @@ 'SHA3-256': MessageDigestAdapter.makeCreator(sha3.sha3_256, 'sha3-256'), | ||
var s = exports.bytesToPem(rsaPrivateKey, 'rsaPrivateNonEncrypted'); | ||
var sk = node_forge_1.pki.privateKeyFromPem(s); | ||
var sk = pki.privateKeyFromPem(s); | ||
var _digest = digestMap[digest].create(); | ||
@@ -146,3 +160,3 @@ _digest.update(string_bytes_1.bytesToString(message, 'raw')); | ||
if (digest === void 0) { digest = 'SHA256'; } | ||
var pk = node_forge_1.pki.publicKeyFromPem(exports.bytesToPem(rsaPublicKey, 'rsaPublic')); | ||
var pk = pki.publicKeyFromPem(exports.bytesToPem(rsaPublicKey, 'rsaPublic')); | ||
var _digest = digestMap[digest].create(); | ||
@@ -149,0 +163,0 @@ _digest.update(string_bytes_1.bytesToString(message), 'raw'); |
"use strict"; | ||
var __importStar = (this && this.__importStar) || function (mod) { | ||
if (mod && mod.__esModule) return mod; | ||
var result = {}; | ||
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; | ||
result["default"] = mod; | ||
return result; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var string_bytes_1 = require("../conversions/string-bytes"); | ||
var forge = require("node-forge"); | ||
// @ts-ignore | ||
var forgeMd5 = __importStar(require("node-forge/lib/md5")); | ||
var concat_split_1 = require("./concat-split"); | ||
@@ -24,3 +32,3 @@ var encryption_1 = require("./encryption"); | ||
while (final_key.length < output) { | ||
key = forge.md.md5.create().update(key + passPlusSalt).digest().getBytes(); | ||
key = forgeMd5.create().update(key + passPlusSalt).digest().getBytes(); | ||
final_key += key; | ||
@@ -27,0 +35,0 @@ } |
"use strict"; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var axlsign_1 = require("../libs/axlsign"); | ||
var axlsign_1 = __importDefault(require("../libs/axlsign")); | ||
var param_1 = require("../conversions/param"); | ||
@@ -5,0 +8,0 @@ var util_1 = require("./util"); |
"use strict"; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -8,3 +11,3 @@ var interface_1 = require("./interface"); | ||
var address_keys_seed_1 = require("./address-keys-seed"); | ||
var axlsign_1 = require("../libs/axlsign"); | ||
var axlsign_1 = __importDefault(require("../libs/axlsign")); | ||
exports.verifyAddress = function (addr, optional) { | ||
@@ -11,0 +14,0 @@ var chainId = optional ? optional.chainId : undefined; |
{ | ||
"name": "@waves/ts-lib-crypto", | ||
"version": "1.3.1", | ||
"version": "1.4.1", | ||
"description": "This library contains all algorithm implementations like signature verification and protocol entries like address used in Waves.", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
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 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
532461
4789