Skip to content

Commit ae6755d

Browse files
committed
fix: add support for node 12
NODE-1984
1 parent 28fd17b commit ae6755d

File tree

6 files changed

+49
-27
lines changed

6 files changed

+49
-27
lines changed

.travis.yml

+6-4
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,19 @@ services:
77

88
matrix:
99
include:
10-
- env: NODE_LTS=argon
11-
- env: NODE_LTS=boron
12-
- env: NODE_LTS=carbon
10+
- env: NODE_VERSION=4
11+
- env: NODE_VERSION=6
12+
- env: NODE_VERSION=8
13+
- env: NODE_VERSION=10
14+
- env: NODE_VERSION=12
1315

1416
script:
1517
- >
1618
docker run
1719
-i
1820
-v $(pwd):/app
1921
-w /app
20-
-e NODE_LTS=$NODE_LTS
22+
-e NODE_VERSION=$NODE_VERSION
2123
-e KERBEROS_USERNAME=administrator
2224
-e KERBEROS_PASSWORD=Password01
2325
-e KERBEROS_REALM=example.com

package.json

+9-9
Original file line numberDiff line numberDiff line change
@@ -13,25 +13,25 @@
1313
"authentication"
1414
],
1515
"dependencies": {
16-
"bindings": "^1.3.0",
17-
"nan": "^2.10.0",
18-
"prebuild-install": "^5.0.0"
16+
"bindings": "^1.5.0",
17+
"nan": "^2.14.0",
18+
"prebuild-install": "^5.3.0"
1919
},
2020
"devDependencies": {
21-
"chai": "^4.1.2",
22-
"chai-string": "^1.4.0",
21+
"chai": "^4.2.0",
22+
"chai-string": "^1.5.0",
2323
"clang-format": "^1.2.4",
2424
"dmd-clear": "^0.1.2",
25-
"eslint": "^5.3.0",
25+
"eslint": "^5.16.0",
2626
"eslint-plugin-prettier": "^2.6.2",
2727
"jsdoc-to-markdown": "^4.0.1",
2828
"mocha": "^5.2.0",
29-
"mongodb": "^3.1.3",
29+
"mongodb": "^3.2.5",
3030
"prebuild": "^7.6.2",
3131
"prebuild-ci": "^2.2.3",
32-
"prettier": "^1.14.2",
32+
"prettier": "^1.17.1",
3333
"request": "^2.88.0",
34-
"segfault-handler": "^1.0.1",
34+
"segfault-handler": "^1.2.0",
3535
"standard-version": "^4.4.0"
3636
},
3737
"scripts": {

src/kerberos.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ NAN_GETTER(KerberosServer::ContextCompleteGetter) {
131131

132132
NAN_METHOD(TestMethod) {
133133
std::string string(*Nan::Utf8String(info[0]));
134-
bool shouldError = info[1]->BooleanValue();
134+
bool shouldError = Nan::To<bool>(info[1]).FromJust();
135135

136136
std::string optionalString;
137137
Nan::Callback* callback;

src/kerberos_common.h

+20-6
Original file line numberDiff line numberDiff line change
@@ -26,19 +26,33 @@ inline void ResultDeleter(krb_result* result) {
2626
NAN_INLINE std::string StringOptionValue(v8::Local<v8::Object> options, const char* _key) {
2727
Nan::HandleScope scope;
2828
v8::Local<v8::String> key = Nan::New(_key).ToLocalChecked();
29-
return !options.IsEmpty() && options->Has(key) && options->Get(key)->IsString()
30-
? std::string(*(Nan::Utf8String(options->Get(key))))
31-
: std::string();
29+
if (options.IsEmpty() || !Nan::Has(options, key).FromMaybe(false)) {
30+
return std::string();
31+
}
32+
33+
v8::Local<v8::Value> value = Nan::Get(options, key).ToLocalChecked();
34+
if (!value->IsString()) {
35+
return std::string();
36+
}
37+
38+
return std::string(*(Nan::Utf8String(value)));
3239
}
3340

3441
NAN_INLINE uint32_t UInt32OptionValue(v8::Local<v8::Object> options,
3542
const char* _key,
3643
uint32_t def) {
3744
Nan::HandleScope scope;
3845
v8::Local<v8::String> key = Nan::New(_key).ToLocalChecked();
39-
return !options.IsEmpty() && options->Has(key) && options->Get(key)->IsNumber()
40-
? options->Get(key)->Uint32Value()
41-
: def;
46+
if (options.IsEmpty() || !Nan::Has(options, key).FromMaybe(false)) {
47+
return def;
48+
}
49+
50+
v8::Local<v8::Value> value = Nan::Get(options, key).ToLocalChecked();
51+
if (!value->IsNumber()) {
52+
return def;
53+
}
54+
55+
return value->Uint32Value(Nan::GetCurrentContext()).FromJust();
4256
}
4357

4458
#endif

src/win32/kerberos_win32.cc

+12-6
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@
1212
#define GSS_C_REPLAY_FLAG 4
1313
#define GSS_C_SEQUENCE_FLAG 8
1414

15-
const wchar_t* to_wstring(const v8::String::Utf8Value& str) {
16-
const char *bytes = *str;
15+
const wchar_t* to_wstring(const char *bytes) {
1716
unsigned int sizeOfStr = MultiByteToWideChar(CP_UTF8, 0, bytes, -1, NULL, 0);
1817
wchar_t *output = new wchar_t[sizeOfStr];
1918
MultiByteToWideChar(CP_UTF8, 0, bytes, -1, output, sizeOfStr);
@@ -23,9 +22,16 @@ const wchar_t* to_wstring(const v8::String::Utf8Value& str) {
2322
NAN_INLINE std::wstring WStringOptionValue(v8::Local<v8::Object> options, const char* _key) {
2423
Nan::HandleScope scope;
2524
v8::Local<v8::String> key = Nan::New(_key).ToLocalChecked();
26-
return !options.IsEmpty() && options->Has(key) && options->Get(key)->IsString()
27-
? std::wstring(to_wstring(v8::String::Utf8Value(options->Get(key)->ToString())))
28-
: std::wstring();
25+
if (options.IsEmpty() || !Nan::Has(options, key).FromMaybe(false)) {
26+
return std::wstring();
27+
}
28+
29+
v8::Local<v8::Value> value = Nan::Get(options, key).ToLocalChecked();
30+
if (!value->IsString()) {
31+
return std::wstring();
32+
}
33+
34+
return std::wstring(to_wstring(*(Nan::Utf8String(value))));
2935
}
3036

3137
/// KerberosClient
@@ -131,7 +137,7 @@ NAN_METHOD(KerberosServer::Step) {
131137

132138
/// Global Methods
133139
NAN_METHOD(InitializeClient) {
134-
std::wstring service(to_wstring(v8::String::Utf8Value(info[0]->ToString())));
140+
std::wstring service(to_wstring(*(Nan::Utf8String(info[0]))));
135141
v8::Local<v8::Object> options = Nan::To<v8::Object>(info[1]).ToLocalChecked();
136142
Nan::Callback* callback = new Nan::Callback(Nan::To<v8::Function>(info[2]).ToLocalChecked());
137143

test/scripts/travis.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ echo "Installing Node.js"
120120
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash
121121
export NVM_DIR="$HOME/.nvm"
122122
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
123-
nvm install --lts=$NODE_LTS
123+
nvm install $NODE_VERSION
124124

125125
echo "Installing dependencies and running test"
126126
npm install --unsafe-perm

0 commit comments

Comments
 (0)