Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated to use nan v2.14 #87

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 13 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@
},
"license": "MIT",
"dependencies": {
"nan": "2.12.0"
"nan": "2.14.0"
}
}
10 changes: 5 additions & 5 deletions src/addon.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,20 @@ void init(Local<Object> exports) {

Nan::Set(exports,
Nan::New<String>("verify").ToLocalChecked(),
Nan::New<FunctionTemplate>(verify)->GetFunction());
Nan::New<FunctionTemplate>(verify)->GetFunction(Nan::GetCurrentContext()).ToLocalChecked());

Nan::Set(exports,
Nan::New<String>("getAltNames").ToLocalChecked(),
Nan::New<FunctionTemplate>(get_altnames)->GetFunction());
Nan::New<FunctionTemplate>(get_altnames)->GetFunction(Nan::GetCurrentContext()).ToLocalChecked());
Nan::Set(exports,
Nan::New<String>("getSubject").ToLocalChecked(),
Nan::New<FunctionTemplate>(get_subject)->GetFunction());
Nan::New<FunctionTemplate>(get_subject)->GetFunction(Nan::GetCurrentContext()).ToLocalChecked());
Nan::Set(exports,
Nan::New<String>("getIssuer").ToLocalChecked(),
Nan::New<FunctionTemplate>(get_issuer)->GetFunction());
Nan::New<FunctionTemplate>(get_issuer)->GetFunction(Nan::GetCurrentContext()).ToLocalChecked());
Nan::Set(exports,
Nan::New<String>("parseCert").ToLocalChecked(),
Nan::New<FunctionTemplate>(parse_cert)->GetFunction());
Nan::New<FunctionTemplate>(parse_cert)->GetFunction(Nan::GetCurrentContext()).ToLocalChecked());
}

NODE_MODULE(x509, init)
21 changes: 11 additions & 10 deletions src/x509.cc
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,13 @@ std::string parse_args(const Nan::FunctionCallbackInfo<v8::Value>& 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;
}


Expand All @@ -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;
Expand Down Expand Up @@ -115,7 +115,7 @@ NAN_METHOD(get_altnames) {
if(parsed_arg.size() == 0) {
info.GetReturnValue().SetUndefined();
}
Local<Object> exports(try_parse(parsed_arg)->ToObject());
Local<Object> exports(try_parse(parsed_arg)->ToObject(Nan::GetCurrentContext()).ToLocalChecked());
Local<Value> key = Nan::New<String>("altNames").ToLocalChecked();
info.GetReturnValue().Set(
Nan::Get(exports, key).ToLocalChecked());
Expand All @@ -128,7 +128,7 @@ NAN_METHOD(get_subject) {
if(parsed_arg.size() == 0) {
info.GetReturnValue().SetUndefined();
}
Local<Object> exports(try_parse(parsed_arg)->ToObject());
Local<Object> exports(try_parse(parsed_arg)->ToObject(Nan::GetCurrentContext()).ToLocalChecked());
Local<Value> key = Nan::New<String>("subject").ToLocalChecked();
info.GetReturnValue().Set(
Nan::Get(exports, key).ToLocalChecked());
Expand All @@ -141,7 +141,7 @@ NAN_METHOD(get_issuer) {
if(parsed_arg.size() == 0) {
info.GetReturnValue().SetUndefined();
}
Local<Object> exports(try_parse(parsed_arg)->ToObject());
Local<Object> exports(try_parse(parsed_arg)->ToObject(Nan::GetCurrentContext()).ToLocalChecked());
Local<Value> key = Nan::New<String>("issuer").ToLocalChecked();
info.GetReturnValue().Set(
Nan::Get(exports, key).ToLocalChecked());
Expand All @@ -154,7 +154,7 @@ NAN_METHOD(parse_cert) {
if(parsed_arg.size() == 0) {
info.GetReturnValue().SetUndefined();
}
Local<Object> exports(try_parse(parsed_arg)->ToObject());
Local<Object> exports(try_parse(parsed_arg)->ToObject(Nan::GetCurrentContext()).ToLocalChecked());
info.GetReturnValue().Set(exports);
ERR_clear_error();
}
Expand Down Expand Up @@ -459,7 +459,8 @@ Local<Value> parse_date(ASN1_TIME *date) {

Local<Object> global = Nan::GetCurrentContext()->Global();
Local<Object> DateObject = Nan::Get(global,
Nan::New<String>("Date").ToLocalChecked()).ToLocalChecked()->ToObject();
Nan::New<String>("Date").ToLocalChecked()).ToLocalChecked()
->ToObject(Nan::GetCurrentContext()).ToLocalChecked();
return scope.Escape(Nan::CallAsConstructor(DateObject, 1, args).ToLocalChecked());
}

Expand Down