From 8f1ffc21d1e973cae9ea193d71c01af983fa6260 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladimir=20Vrzi=C4=87?= Date: Wed, 11 Sep 2019 10:40:28 +0200 Subject: [PATCH] Version 3.0.0 Add support for node 12 Drop support for node 6 and 7 Bump minimum node engine requirement to 8.0 Drop ubuntu-toolchain-r-test PPA repo and g++-4.8 from CI Upgrade eslint to 6.3.0 --- .travis.yml | 11 +---------- README.md | 22 ++++++++++------------ package.json | 13 +++++++++---- src/binding.cpp | 17 +++++++++-------- 4 files changed, 29 insertions(+), 34 deletions(-) diff --git a/.travis.yml b/.travis.yml index 3f51f44..3605228 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,24 +4,15 @@ os: language: cpp -addons: - apt: - sources: - - ubuntu-toolchain-r-test - packages: - - g++-4.8 - env: matrix: - - TRAVIS_NODE_VERSION="6" - - TRAVIS_NODE_VERSION="7" - TRAVIS_NODE_VERSION="8" - TRAVIS_NODE_VERSION="9" - TRAVIS_NODE_VERSION="10" + - TRAVIS_NODE_VERSION="12" install: - rm -rf ~/.nvm && git clone https://github.com/creationix/nvm.git ~/.nvm && (cd ~/.nvm && git checkout `git describe --abbrev=0 --tags`) && source ~/.nvm/nvm.sh && nvm install $TRAVIS_NODE_VERSION - - if [[ $TRAVIS_OS_NAME == "linux" ]]; then export CXX=g++-4.8; fi - $CXX --version - travis_retry npm install diff --git a/README.md b/README.md index f9a3dd6..4d82872 100644 --- a/README.md +++ b/README.md @@ -10,20 +10,18 @@ SHA-1, MD5, and SHA-512 are susceptible to length-extension". [https://blake2.net/](https://blake2.net/) node-blake2 provides a [stream](https://nodejs.org/api/stream.html)-compatible -blake2b, blake2bp, blake2s, and blake2sp `Hash` and `KeyedHash` for node 6+. +blake2b, blake2bp, blake2s, and blake2sp `Hash` and `KeyedHash` for node 8+. node-blake2 was tested to work on -- Ubuntu 14.04 (g++ 4.8.2) -- Ubuntu 14.04 (clang++ 3.6.2-svn238746-1~exp1) -- Ubuntu 15.04 (g++ 4.9.2) +- GNU/Linux Ubuntu 16.04 (g++ 5.4.0) +- macOS 10.13 (Apple LLVM 9.1.0) - Windows 8.1 x64 (VS2013) -- OS X 10.10 (Apple LLVM 6.1.0) Install --- -On Windows, first install [Python 2.7.13](https://www.python.org/downloads/release/python-2713/) so that node-gyp works. +On Windows, first install [Python 2.7.16](https://www.python.org/downloads/release/python-2716/) so that node-gyp works. In your project, run: @@ -34,7 +32,7 @@ npm install blake2 --save or install from the GitHub repo: ``` -npm install ludios/node-blake2 --save +npm install vrza/node-blake2 --save ``` @@ -51,7 +49,7 @@ console.log(h.digest("hex")); ``` `blake2.createHash` works like node's -[`crypto.createHash`](https://nodejs.org/api/crypto.html#crypto_crypto_createhash_algorithm). +[`crypto.createHash`](https://nodejs.org/api/crypto.html#crypto_crypto_createhash_algorithm_options). ### Keyed BLAKE2b @@ -63,7 +61,7 @@ console.log(h.digest("hex")); ``` `blake2.createKeyedHash` takes a key argument like -[`crypto.createHmac`](https://nodejs.org/api/crypto.html#crypto_crypto_createhmac_algorithm_key). +[`crypto.createHmac`](https://nodejs.org/api/crypto.html#crypto_crypto_createhmac_algorithm_key_options). Although it is not an HMAC, a keyed hash serves the same purpose. ### Important notes @@ -76,7 +74,7 @@ Although it is not an HMAC, a keyed hash serves the same purpose. ### With streams -This works exactly like it does with [`crypto.Hash`](https://nodejs.org/api/crypto.html#crypto_crypto_createhash_algorithm). See [b2sum.js](https://github.com/ludios/node-blake2/blob/master/b2sum.js). +This works exactly like it does with [`crypto.Hash`](https://nodejs.org/api/crypto.html#crypto_crypto_createhash_algorithm_options). See [b2sum.js](https://github.com/vrza/node-blake2/blob/master/b2sum.js). ### Custom digest length @@ -130,5 +128,5 @@ Known issues [npm-image]: https://img.shields.io/npm/v/blake2.svg [npm-url]: https://npmjs.org/package/blake2 -[travis-image]: https://img.shields.io/travis/ludios/node-blake2.svg -[travis-url]: https://travis-ci.org/ludios/node-blake2 +[travis-image]: https://img.shields.io/travis/vrza/node-blake2.svg +[travis-url]: https://travis-ci.org/vrza/node-blake2 diff --git a/package.json b/package.json index e502d60..134da8e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "blake2", - "version": "2.0.2", + "version": "3.0.0", "description": "All four BLAKE2 variants (blake2b, blake2bp, blake2s, blake2sp) for node, with stream support", "keywords": [ "crypto", @@ -27,12 +27,17 @@ "nan": "^2.14.0" }, "devDependencies": { - "eslint": "^5.16.0", + "eslint": "^6.3.0", "mocha": "^6.2.0" }, - "author": "Ivan Kozik", + "contributors": [ + "Ivan Kozik (https://github.com/ivan)", + "James Bowes (https://github.com/jbowes)", + "Kannan Goundan (https://github.com/cakoose)", + "Vladimir Vrzić (https://github.com/vrza)" + ], "license": "ISC", "engines": { - "node": ">= 6.0.0" + "node": ">= 8.0.0" } } diff --git a/src/binding.cpp b/src/binding.cpp index bd54681..41efa93 100644 --- a/src/binding.cpp +++ b/src/binding.cpp @@ -38,7 +38,7 @@ class Hash: public Nan::ObjectWrap { Nan::SetPrototypeMethod(tpl, "update", Update); Nan::SetPrototypeMethod(tpl, "digest", Digest); Nan::SetPrototypeMethod(tpl, "copy", Copy); - target->Set(Nan::New("Hash").ToLocalChecked(), tpl->GetFunction()); + target->Set(Nan::New("Hash").ToLocalChecked(), Nan::GetFunction(tpl).ToLocalChecked()); } static @@ -52,7 +52,7 @@ class Hash: public Nan::ObjectWrap { if (info.Length() < 1 || !info[0]->IsString()) { return Nan::ThrowError(v8::Exception::TypeError(Nan::New("First argument must be a string with algorithm name").ToLocalChecked())); } - std::string algo = std::string(*v8::String::Utf8Value(info[0]->ToString())); + std::string algo = std::string(*v8::String::Utf8Value(v8::Isolate::GetCurrent(), info[0]->ToString(Nan::GetCurrentContext()).FromMaybe(v8::Local()))); const char *key_data = nullptr; size_t key_length; @@ -70,7 +70,7 @@ class Hash: public Nan::ObjectWrap { if (!info[2]->IsNumber()) { return Nan::ThrowError(v8::Exception::TypeError(Nan::New("digestLength must be a number").ToLocalChecked())); } - digest_length = info[2]->IntegerValue(); + digest_length = info[2]->IntegerValue(Nan::GetCurrentContext()).ToChecked(); } } @@ -187,7 +187,7 @@ class Hash: public Nan::ObjectWrap { return Nan::ThrowError(v8::Exception::TypeError(Nan::New("Bad argument; need a Buffer").ToLocalChecked())); } - v8::Local buffer_obj = info[0]->ToObject(); + v8::Local buffer_obj = info[0]->ToObject(Nan::GetCurrentContext()).ToLocalChecked(); const char *buffer_data = node::Buffer::Data(buffer_obj); size_t buffer_length = node::Buffer::Length(buffer_obj); obj->any_blake2_update( @@ -230,15 +230,16 @@ class Hash: public Nan::ObjectWrap { const unsigned argc = 1; v8::Local argv[argc] = { Nan::New("bypass").ToLocalChecked() }; - v8::Local construct = Nan::New(hash_constructor)->GetFunction(); - v8::Local inst = Nan::NewInstance(construct, argc, argv).ToLocalChecked(); + v8::Local tmpl = Nan::New(hash_constructor); + Nan::MaybeLocal construct = Nan::GetFunction(tmpl); + Nan::MaybeLocal inst = Nan::NewInstance(construct.ToLocalChecked(), argc, argv).ToLocalChecked(); // Construction may fail with a JS exception, in which case we just need // to return. if (inst.IsEmpty()) { return; } Hash *dest = new Hash(); - dest->Wrap(inst); + dest->Wrap(inst.ToLocalChecked()); dest->initialized_ = src->initialized_; dest->any_blake2_update = src->any_blake2_update; @@ -246,7 +247,7 @@ class Hash: public Nan::ObjectWrap { dest->outbytes = src->outbytes; dest->state = src->state; - info.GetReturnValue().Set(inst); + info.GetReturnValue().Set(inst.ToLocalChecked()); } };