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

fix for node 12 #6

Merged
merged 3 commits into from
Dec 12, 2019
Merged
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
6 changes: 4 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
language: node_js
node_js:
- "4.0.0"
- "3.0.0"
- "8.0.0"
- "10.0.0"
- "12.0.0"
- "13.0.0"
env:
- CC=clang CXX=clang++ npm_config_clang=1
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"devDependencies": {
"chacha": "^1.1.2",
"tap-spec": "^2.2.2",
"tape": "^3.5.0"
"tape": "^4.11.0"
},
"repository": {
"type": "git",
Expand Down
8 changes: 4 additions & 4 deletions src/aead.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Nan::Persistent<v8::Function> AEAD::constructor;
AEAD::AEAD() {};
AEAD::~AEAD() {};
void AEAD::Init(v8::Local<v8::Object> exports) {
v8::Local<v8::Context> context = exports->CreationContext();
Nan::HandleScope scope;

// Prepare constructor template
Expand All @@ -19,12 +20,11 @@ void AEAD::Init(v8::Local<v8::Object> exports) {
Nan::SetPrototypeMethod(tpl, "setAAD", UpdateAad);
Nan::SetPrototypeMethod(tpl, "finish", Finish);

constructor.Reset(tpl->GetFunction());
exports->Set(Nan::New("AEAD").ToLocalChecked(), tpl->GetFunction());
constructor.Reset(tpl->GetFunction(context).ToLocalChecked());
(void) exports->Set(context, Nan::New("AEAD").ToLocalChecked(), tpl->GetFunction(context).ToLocalChecked());
}

void AEAD::New(const Nan::FunctionCallbackInfo<v8::Value>& args) {

if (args.IsConstructCall()) {
if (args.Length() < 3 ||
!Buffer::HasInstance(args[0]) ||
Expand All @@ -33,7 +33,7 @@ void AEAD::New(const Nan::FunctionCallbackInfo<v8::Value>& args) {
}
unsigned char* key = reinterpret_cast<unsigned char*>(Buffer::Data(args[0]));
unsigned char* iv = reinterpret_cast<unsigned char*>(Buffer::Data(args[1]));
bool decrypt = args[2]->IsUndefined() ? false : args[2]->BooleanValue();
bool decrypt = args[2]->IsUndefined() ? false : Nan::To<bool>(args[2]).FromJust();
size_t len = Buffer::Length(args[0]);
size_t ivlen = Buffer::Length(args[1]);
if (len != 32) {
Expand Down
2 changes: 1 addition & 1 deletion src/aead.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

class AEAD : public node::ObjectWrap {
public:
static void Init(v8::Handle<v8::Object> exports);
static void Init(v8::Local<v8::Object> exports);

private:
AEAD();
Expand Down
5 changes: 3 additions & 2 deletions src/chacha.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Nan::Persistent<v8::Function> Chacha::constructor;
Chacha::Chacha() {};
Chacha::~Chacha() {};
void Chacha::Init(v8::Local<v8::Object> exports) {
v8::Local<v8::Context> context = exports->CreationContext();
Nan::HandleScope scope;

// Prepare constructor template
Expand All @@ -16,8 +17,8 @@ void Chacha::Init(v8::Local<v8::Object> exports) {
// Prototype
Nan::SetPrototypeMethod(tpl, "update", Update);

constructor.Reset(tpl->GetFunction());
exports->Set(Nan::New("Chacha").ToLocalChecked(), tpl->GetFunction());
constructor.Reset(tpl->GetFunction(context).ToLocalChecked());
(void) exports->Set(context, Nan::New("Chacha").ToLocalChecked(), tpl->GetFunction(context).ToLocalChecked());
}

void Chacha::New(const Nan::FunctionCallbackInfo<v8::Value>& info) {
Expand Down
2 changes: 1 addition & 1 deletion src/chacha.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

class Chacha : public node::ObjectWrap {
public:
static void Init(v8::Handle<v8::Object> exports);
static void Init(v8::Local<v8::Object> exports);

private:
Chacha();
Expand Down
2 changes: 1 addition & 1 deletion src/chacha20poly1305.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include "legacy.h"
using namespace v8;

void InitAll(Handle<Object> exports) {
void InitAll(Local<Object> exports) {
Chacha::Init(exports);
Poly::Init(exports);
AEAD::Init(exports);
Expand Down
7 changes: 4 additions & 3 deletions src/legacy.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Nan::Persistent<v8::Function> Legacy::constructor;
Legacy::Legacy() {};
Legacy::~Legacy() {};
void Legacy::Init(v8::Local<v8::Object> exports) {
v8::Local<v8::Context> context = exports->CreationContext();
Nan::HandleScope scope;

// Prepare constructor template
Expand All @@ -19,8 +20,8 @@ void Legacy::Init(v8::Local<v8::Object> exports) {
Nan::SetPrototypeMethod(tpl, "setAAD", UpdateAad);
Nan::SetPrototypeMethod(tpl, "finish", Finish);

constructor.Reset(tpl->GetFunction());
exports->Set(Nan::New("Legacy").ToLocalChecked(), tpl->GetFunction());
constructor.Reset(tpl->GetFunction(context).ToLocalChecked());
(void) exports->Set(context, Nan::New("Legacy").ToLocalChecked(), tpl->GetFunction(context).ToLocalChecked());
}
void Legacy::New(const Nan::FunctionCallbackInfo<v8::Value>& args) {

Expand All @@ -32,7 +33,7 @@ void Legacy::New(const Nan::FunctionCallbackInfo<v8::Value>& args) {
}
unsigned char* key = reinterpret_cast<unsigned char*>(Buffer::Data(args[0]));
unsigned char* iv = reinterpret_cast<unsigned char*>(Buffer::Data(args[1]));
bool decrypt = args[2]->IsUndefined() ? false : args[2]->BooleanValue();
bool decrypt = args[2]->IsUndefined() ? false : Nan::To<bool>(args[2]).FromJust();
size_t len = Buffer::Length(args[0]);
size_t ivlen = Buffer::Length(args[1]);
if (len != 32) {
Expand Down
2 changes: 1 addition & 1 deletion src/legacy.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

class Legacy : public node::ObjectWrap {
public:
static void Init(v8::Handle<v8::Object> exports);
static void Init(v8::Local<v8::Object> exports);

private:
Legacy();
Expand Down
5 changes: 3 additions & 2 deletions src/poly.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Nan::Persistent<v8::Function> Poly::constructor;
Poly::Poly() {};
Poly::~Poly() {};
void Poly::Init(v8::Local<v8::Object> exports) {
v8::Local<v8::Context> context = exports->CreationContext();
Nan::HandleScope scope;

// Prepare constructor template
Expand All @@ -18,8 +19,8 @@ void Poly::Init(v8::Local<v8::Object> exports) {
Nan::SetPrototypeMethod(tpl, "update", Update);
Nan::SetPrototypeMethod(tpl, "finish", Finish);

constructor.Reset(tpl->GetFunction());
exports->Set(Nan::New("Poly").ToLocalChecked(), tpl->GetFunction());
constructor.Reset(tpl->GetFunction(context).ToLocalChecked());
(void) exports->Set(context, Nan::New("Poly").ToLocalChecked(), tpl->GetFunction(context).ToLocalChecked());
}

void Poly::New(const Nan::FunctionCallbackInfo<v8::Value>& args) {
Expand Down
2 changes: 1 addition & 1 deletion src/poly.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

class Poly : public node::ObjectWrap {
public:
static void Init(v8::Handle<v8::Object> exports);
static void Init(v8::Local<v8::Object> exports);

private:
Poly();
Expand Down