diff --git a/.travis.yml b/.travis.yml index c45c402..cb4c789 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,13 +12,11 @@ language: node_js node_js: - "stable" - "4.0" - - "0.12" - - "0.10" install: - export CXX=g++-4.8 - $CXX --version - - npm i + - npm i before_install: - npm install -g node-gyp diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..309e58c --- /dev/null +++ b/package-lock.json @@ -0,0 +1,13 @@ +{ + "name": "x509", + "version": "0.3.4", + "lockfileVersion": 1, + "requires": true, + "dependencies": { + "nan": { + "version": "2.14.0", + "resolved": "https://registry.npmjs.org/nan/-/nan-2.14.0.tgz", + "integrity": "sha512-INOFj37C7k3AfaNTtX8RhsTw7qRy7eLET14cROi9+5HAVbbHuIWUHEauBv5qT4Av2tWasiTY1Jw6puUNqRJXQg==" + } + } +} diff --git a/package.json b/package.json index cc6ee44..343ea01 100644 --- a/package.json +++ b/package.json @@ -13,6 +13,6 @@ }, "license": "MIT", "dependencies": { - "nan": "2.12.0" + "nan": "2.14.0" } } diff --git a/src/addon.cc b/src/addon.cc index f0aab0c..a9da123 100644 --- a/src/addon.cc +++ b/src/addon.cc @@ -13,20 +13,20 @@ void init(Local exports) { Nan::Set(exports, Nan::New("verify").ToLocalChecked(), - Nan::New(verify)->GetFunction()); + Nan::New(verify)->GetFunction(Nan::GetCurrentContext()).ToLocalChecked()); Nan::Set(exports, Nan::New("getAltNames").ToLocalChecked(), - Nan::New(get_altnames)->GetFunction()); + Nan::New(get_altnames)->GetFunction(Nan::GetCurrentContext()).ToLocalChecked()); Nan::Set(exports, Nan::New("getSubject").ToLocalChecked(), - Nan::New(get_subject)->GetFunction()); + Nan::New(get_subject)->GetFunction(Nan::GetCurrentContext()).ToLocalChecked()); Nan::Set(exports, Nan::New("getIssuer").ToLocalChecked(), - Nan::New(get_issuer)->GetFunction()); + Nan::New(get_issuer)->GetFunction(Nan::GetCurrentContext()).ToLocalChecked()); Nan::Set(exports, Nan::New("parseCert").ToLocalChecked(), - Nan::New(parse_cert)->GetFunction()); + Nan::New(parse_cert)->GetFunction(Nan::GetCurrentContext()).ToLocalChecked()); } NODE_MODULE(x509, init) diff --git a/src/x509.cc b/src/x509.cc index 00e02ae..44ee132 100644 --- a/src/x509.cc +++ b/src/x509.cc @@ -37,13 +37,13 @@ std::string parse_args(const Nan::FunctionCallbackInfo& info) { Nan::ThrowTypeError("Certificate must be a string."); return std::string(); } - - if (info[0]->ToString()->Length() == 0) { + std::string val = *Nan::Utf8String(info[0]); + if (val.length() == 0) { Nan::ThrowTypeError("Certificate argument provided, but left blank."); return std::string(); } - return *Nan::Utf8String(info[0]->ToString()); + return val; } @@ -52,8 +52,8 @@ NAN_METHOD(verify) { Nan::HandleScope scope; OpenSSL_add_all_algorithms(); - std::string cert_path = *String::Utf8Value(info[0]->ToString()); - std::string ca_bundlestr = *String::Utf8Value(info[1]->ToString()); + std::string cert_path = *Nan::Utf8String(info[0]); + std::string ca_bundlestr = *Nan::Utf8String(info[1]); X509_STORE *store = NULL; X509_STORE_CTX *verify_ctx = NULL; @@ -115,7 +115,7 @@ NAN_METHOD(get_altnames) { if(parsed_arg.size() == 0) { info.GetReturnValue().SetUndefined(); } - Local exports(try_parse(parsed_arg)->ToObject()); + Local exports(try_parse(parsed_arg)->ToObject(Nan::GetCurrentContext()).ToLocalChecked()); Local key = Nan::New("altNames").ToLocalChecked(); info.GetReturnValue().Set( Nan::Get(exports, key).ToLocalChecked()); @@ -128,7 +128,7 @@ NAN_METHOD(get_subject) { if(parsed_arg.size() == 0) { info.GetReturnValue().SetUndefined(); } - Local exports(try_parse(parsed_arg)->ToObject()); + Local exports(try_parse(parsed_arg)->ToObject(Nan::GetCurrentContext()).ToLocalChecked()); Local key = Nan::New("subject").ToLocalChecked(); info.GetReturnValue().Set( Nan::Get(exports, key).ToLocalChecked()); @@ -141,7 +141,7 @@ NAN_METHOD(get_issuer) { if(parsed_arg.size() == 0) { info.GetReturnValue().SetUndefined(); } - Local exports(try_parse(parsed_arg)->ToObject()); + Local exports(try_parse(parsed_arg)->ToObject(Nan::GetCurrentContext()).ToLocalChecked()); Local key = Nan::New("issuer").ToLocalChecked(); info.GetReturnValue().Set( Nan::Get(exports, key).ToLocalChecked()); @@ -154,7 +154,7 @@ NAN_METHOD(parse_cert) { if(parsed_arg.size() == 0) { info.GetReturnValue().SetUndefined(); } - Local exports(try_parse(parsed_arg)->ToObject()); + Local exports(try_parse(parsed_arg)->ToObject(Nan::GetCurrentContext()).ToLocalChecked()); info.GetReturnValue().Set(exports); ERR_clear_error(); } @@ -459,7 +459,8 @@ Local parse_date(ASN1_TIME *date) { Local global = Nan::GetCurrentContext()->Global(); Local DateObject = Nan::Get(global, - Nan::New("Date").ToLocalChecked()).ToLocalChecked()->ToObject(); + Nan::New("Date").ToLocalChecked()).ToLocalChecked() + ->ToObject(Nan::GetCurrentContext()).ToLocalChecked(); return scope.Escape(Nan::CallAsConstructor(DateObject, 1, args).ToLocalChecked()); }