couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gar...@apache.org
Subject [22/52] [partial] couchdb-nmo git commit: prepare for release
Date Wed, 14 Oct 2015 10:09:19 GMT
http://git-wip-us.apache.org/repos/asf/couchdb-nmo/blob/753f1767/node_modules/couchbulkimporter/node_modules/mongodb/node_modules/mongodb-core/node_modules/kerberos/lib/win32/wrappers/security_buffer_descriptor.cc
----------------------------------------------------------------------
diff --git a/node_modules/couchbulkimporter/node_modules/mongodb/node_modules/mongodb-core/node_modules/kerberos/lib/win32/wrappers/security_buffer_descriptor.cc b/node_modules/couchbulkimporter/node_modules/mongodb/node_modules/mongodb-core/node_modules/kerberos/lib/win32/wrappers/security_buffer_descriptor.cc
new file mode 100644
index 0000000..fce0d81
--- /dev/null
+++ b/node_modules/couchbulkimporter/node_modules/mongodb/node_modules/mongodb-core/node_modules/kerberos/lib/win32/wrappers/security_buffer_descriptor.cc
@@ -0,0 +1,182 @@
+#include <node.h>
+#include <assert.h>
+#include <string.h>
+#include <stdlib.h>
+#include <v8.h>
+#include <node_buffer.h>
+#include <cstring>
+#include <cmath>
+#include <cstdlib>
+#include <iostream>
+#include <limits>
+
+#define SECURITY_WIN32 1
+
+#include "security_buffer_descriptor.h"
+#include "security_buffer.h"
+
+Nan::Persistent<FunctionTemplate> SecurityBufferDescriptor::constructor_template;
+
+SecurityBufferDescriptor::SecurityBufferDescriptor() : Nan::ObjectWrap() {
+}
+
+SecurityBufferDescriptor::SecurityBufferDescriptor(const Nan::Persistent<Array>& arrayObjectPersistent) : Nan::ObjectWrap() {
+  SecurityBuffer *security_obj = NULL;
+  // Get the Local value
+  Local<Array> arrayObject = Nan::New(arrayObjectPersistent);
+
+  // Safe reference to array
+  this->arrayObject = arrayObject;
+
+  // Unpack the array and ensure we have a valid descriptor
+  this->secBufferDesc.cBuffers = arrayObject->Length();
+  this->secBufferDesc.ulVersion = SECBUFFER_VERSION;
+
+  if(arrayObject->Length() == 1) {
+    // Unwrap  the buffer
+    security_obj = Nan::ObjectWrap::Unwrap<SecurityBuffer>(arrayObject->Get(0)->ToObject());
+    // Assign the buffer
+    this->secBufferDesc.pBuffers = &security_obj->sec_buffer;
+  } else {
+    this->secBufferDesc.pBuffers = new SecBuffer[arrayObject->Length()];
+    this->secBufferDesc.cBuffers = arrayObject->Length();
+
+    // Assign the buffers
+    for(uint32_t i = 0; i < arrayObject->Length(); i++) {
+      security_obj = Nan::ObjectWrap::Unwrap<SecurityBuffer>(arrayObject->Get(i)->ToObject());
+      this->secBufferDesc.pBuffers[i].BufferType = security_obj->sec_buffer.BufferType;
+      this->secBufferDesc.pBuffers[i].pvBuffer = security_obj->sec_buffer.pvBuffer;
+      this->secBufferDesc.pBuffers[i].cbBuffer = security_obj->sec_buffer.cbBuffer;
+    }
+  }
+}
+
+SecurityBufferDescriptor::~SecurityBufferDescriptor() {
+}
+
+size_t SecurityBufferDescriptor::bufferSize() {
+  SecurityBuffer *security_obj = NULL;
+
+  if(this->secBufferDesc.cBuffers == 1) {
+    security_obj = Nan::ObjectWrap::Unwrap<SecurityBuffer>(arrayObject->Get(0)->ToObject());
+    return security_obj->size;
+  } else {
+    int bytesToAllocate = 0;
+
+    for(unsigned int i = 0; i < this->secBufferDesc.cBuffers; i++) {
+      bytesToAllocate += this->secBufferDesc.pBuffers[i].cbBuffer;
+    }
+
+    // Return total size
+    return bytesToAllocate;
+  }
+}
+
+char *SecurityBufferDescriptor::toBuffer() {
+  SecurityBuffer *security_obj = NULL;
+  char *data = NULL;
+
+  if(this->secBufferDesc.cBuffers == 1) {
+    security_obj = Nan::ObjectWrap::Unwrap<SecurityBuffer>(arrayObject->Get(0)->ToObject());
+    data = (char *)malloc(security_obj->size * sizeof(char));
+    memcpy(data, security_obj->data, security_obj->size);
+  } else {
+    size_t bytesToAllocate = this->bufferSize();
+    char *data = (char *)calloc(bytesToAllocate, sizeof(char));
+    int offset = 0;
+
+    for(unsigned int i = 0; i < this->secBufferDesc.cBuffers; i++) {
+      memcpy((data + offset), this->secBufferDesc.pBuffers[i].pvBuffer, this->secBufferDesc.pBuffers[i].cbBuffer);
+      offset +=this->secBufferDesc.pBuffers[i].cbBuffer;
+    }
+
+    // Return the data
+    return data;
+  }
+
+  return data;
+}
+
+NAN_METHOD(SecurityBufferDescriptor::New) {
+  SecurityBufferDescriptor *security_obj;
+  Nan::Persistent<Array> arrayObject;
+
+  if(info.Length() != 1)
+    return Nan::ThrowError("There must be 1 argument passed in where the first argument is a [int32 or an Array of SecurityBuffers]");
+
+  if(!info[0]->IsInt32() && !info[0]->IsArray())
+    return Nan::ThrowError("There must be 1 argument passed in where the first argument is a [int32 or an Array of SecurityBuffers]");
+
+  if(info[0]->IsArray()) {
+    Local<Array> array = Local<Array>::Cast(info[0]);
+    // Iterate over all items and ensure we the right type
+    for(uint32_t i = 0; i < array->Length(); i++) {
+      if(!SecurityBuffer::HasInstance(array->Get(i))) {
+        return Nan::ThrowError("There must be 1 argument passed in where the first argument is a [int32 or an Array of SecurityBuffers]");
+      }
+    }
+  }
+
+  // We have a single integer
+  if(info[0]->IsInt32()) {
+    // Create new SecurityBuffer instance
+    Local<Value> argv[] = {Nan::New<Int32>(0x02), info[0]};
+    Local<Value> security_buffer = Nan::New(SecurityBuffer::constructor_template)->GetFunction()->NewInstance(2, argv);
+    // Create a new array
+    Local<Array> array = Nan::New<Array>(1);
+    // Set the first value
+    array->Set(0, security_buffer);
+
+    // Create persistent handle
+    Nan::Persistent<Array> persistenHandler;
+    persistenHandler.Reset(array);
+
+    // Create descriptor
+    security_obj = new SecurityBufferDescriptor(persistenHandler);
+  } else {
+    // Create a persistent handler
+    Nan::Persistent<Array> persistenHandler;
+    persistenHandler.Reset(Local<Array>::Cast(info[0]));
+    // Create a descriptor
+    security_obj = new SecurityBufferDescriptor(persistenHandler);
+  }
+
+  // Wrap it
+  security_obj->Wrap(info.This());
+  // Return the object
+  info.GetReturnValue().Set(info.This());
+}
+
+NAN_METHOD(SecurityBufferDescriptor::ToBuffer) {
+  // Unpack the Security Buffer object
+  SecurityBufferDescriptor *security_obj = Nan::ObjectWrap::Unwrap<SecurityBufferDescriptor>(info.This());
+
+  // Get the buffer
+  char *buffer_data = security_obj->toBuffer();
+  size_t buffer_size = security_obj->bufferSize();
+
+  // Create a Buffer
+  Local<Object> buffer = Nan::CopyBuffer(buffer_data, (uint32_t)buffer_size).ToLocalChecked();
+
+  // Return the buffer
+  info.GetReturnValue().Set(buffer);
+}
+
+void SecurityBufferDescriptor::Initialize(Nan::ADDON_REGISTER_FUNCTION_ARGS_TYPE target) {
+  // Grab the scope of the call from Node
+  Nan::HandleScope scope;
+
+  // Define a new function template
+  Local<FunctionTemplate> t = Nan::New<FunctionTemplate>(New);
+  t->InstanceTemplate()->SetInternalFieldCount(1);
+  t->SetClassName(Nan::New<String>("SecurityBufferDescriptor").ToLocalChecked());
+
+  // Class methods
+  Nan::SetPrototypeMethod(t, "toBuffer", ToBuffer);
+
+  // Set persistent
+  constructor_template.Reset(t);
+
+  // Set the symbol
+  target->ForceSet(Nan::New<String>("SecurityBufferDescriptor").ToLocalChecked(), t->GetFunction());
+}

http://git-wip-us.apache.org/repos/asf/couchdb-nmo/blob/753f1767/node_modules/couchbulkimporter/node_modules/mongodb/node_modules/mongodb-core/node_modules/kerberos/lib/win32/wrappers/security_buffer_descriptor.h
----------------------------------------------------------------------
diff --git a/node_modules/couchbulkimporter/node_modules/mongodb/node_modules/mongodb-core/node_modules/kerberos/lib/win32/wrappers/security_buffer_descriptor.h b/node_modules/couchbulkimporter/node_modules/mongodb/node_modules/mongodb-core/node_modules/kerberos/lib/win32/wrappers/security_buffer_descriptor.h
new file mode 100644
index 0000000..dc28f7e
--- /dev/null
+++ b/node_modules/couchbulkimporter/node_modules/mongodb/node_modules/mongodb-core/node_modules/kerberos/lib/win32/wrappers/security_buffer_descriptor.h
@@ -0,0 +1,46 @@
+#ifndef SECURITY_BUFFER_DESCRIPTOR_H
+#define SECURITY_BUFFER_DESCRIPTOR_H
+
+#include <node.h>
+#include <node_object_wrap.h>
+#include <v8.h>
+
+#include <WinSock2.h>
+#include <windows.h>
+#include <sspi.h>
+#include <nan.h>
+
+using namespace v8;
+using namespace node;
+
+class SecurityBufferDescriptor : public Nan::ObjectWrap {
+  public:
+    Local<Array> arrayObject;
+    SecBufferDesc secBufferDesc;
+
+    SecurityBufferDescriptor();
+    SecurityBufferDescriptor(const Nan::Persistent<Array>& arrayObjectPersistent);
+    ~SecurityBufferDescriptor();
+
+    // Has instance check
+    static inline bool HasInstance(Local<Value> val) {
+      if (!val->IsObject()) return false;
+      Local<Object> obj = val->ToObject();
+      return Nan::New(constructor_template)->HasInstance(obj);
+    };
+
+    char *toBuffer();
+    size_t bufferSize();
+
+    // Functions available from V8
+    static void Initialize(Nan::ADDON_REGISTER_FUNCTION_ARGS_TYPE target);
+    static NAN_METHOD(ToBuffer);
+
+    // Constructor used for creating new Long objects from C++
+    static Nan::Persistent<FunctionTemplate> constructor_template;
+
+  private:
+    static NAN_METHOD(New);
+};
+
+#endif
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/couchdb-nmo/blob/753f1767/node_modules/couchbulkimporter/node_modules/mongodb/node_modules/mongodb-core/node_modules/kerberos/lib/win32/wrappers/security_buffer_descriptor.js
----------------------------------------------------------------------
diff --git a/node_modules/couchbulkimporter/node_modules/mongodb/node_modules/mongodb-core/node_modules/kerberos/lib/win32/wrappers/security_buffer_descriptor.js b/node_modules/couchbulkimporter/node_modules/mongodb/node_modules/mongodb-core/node_modules/kerberos/lib/win32/wrappers/security_buffer_descriptor.js
new file mode 100644
index 0000000..9421392
--- /dev/null
+++ b/node_modules/couchbulkimporter/node_modules/mongodb/node_modules/mongodb-core/node_modules/kerberos/lib/win32/wrappers/security_buffer_descriptor.js
@@ -0,0 +1,3 @@
+var SecurityBufferDescriptorNative = require('../../../build/Release/kerberos').SecurityBufferDescriptor;
+// Export the modified class
+exports.SecurityBufferDescriptor = SecurityBufferDescriptorNative;
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/couchdb-nmo/blob/753f1767/node_modules/couchbulkimporter/node_modules/mongodb/node_modules/mongodb-core/node_modules/kerberos/lib/win32/wrappers/security_context.cc
----------------------------------------------------------------------
diff --git a/node_modules/couchbulkimporter/node_modules/mongodb/node_modules/mongodb-core/node_modules/kerberos/lib/win32/wrappers/security_context.cc b/node_modules/couchbulkimporter/node_modules/mongodb/node_modules/mongodb-core/node_modules/kerberos/lib/win32/wrappers/security_context.cc
new file mode 100644
index 0000000..5d7ad54
--- /dev/null
+++ b/node_modules/couchbulkimporter/node_modules/mongodb/node_modules/mongodb-core/node_modules/kerberos/lib/win32/wrappers/security_context.cc
@@ -0,0 +1,856 @@
+#include <assert.h>
+#include <string.h>
+#include <stdlib.h>
+#include <node.h>
+#include <v8.h>
+#include <node_buffer.h>
+#include <cstring>
+#include <cmath>
+#include <cstdlib>
+#include <iostream>
+#include <limits>
+
+#include "security_context.h"
+#include "security_buffer_descriptor.h"
+
+#ifndef ARRAY_SIZE
+# define ARRAY_SIZE(a) (sizeof((a)) / sizeof((a)[0]))
+#endif
+
+static LPSTR DisplaySECError(DWORD ErrCode);
+
+// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+// UV Lib callbacks
+// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+static void Process(uv_work_t* work_req) {
+  // Grab the worker
+  Worker *worker = static_cast<Worker*>(work_req->data);
+  // Execute the worker code
+  worker->execute(worker);
+}
+
+static void After(uv_work_t* work_req) {
+  // Grab the scope of the call from Node
+  Nan::HandleScope scope;
+
+  // Get the worker reference
+  Worker *worker = static_cast<Worker*>(work_req->data);
+
+  // If we have an error
+  if(worker->error) {
+    Local<Value> err = v8::Exception::Error(Nan::New<String>(worker->error_message).ToLocalChecked());
+    Local<Object> obj = err->ToObject();
+    obj->Set(Nan::New<String>("code").ToLocalChecked(), Nan::New<Int32>(worker->error_code));
+    Local<Value> info[2] = { err, Nan::Null() };
+    // Execute the error
+    Nan::TryCatch try_catch;
+
+    // Call the callback
+    worker->callback->Call(ARRAY_SIZE(info), info);
+
+    // If we have an exception handle it as a fatalexception
+    if (try_catch.HasCaught()) {
+      Nan::FatalException(try_catch);
+    }
+  } else {
+    // // Map the data
+    Local<Value> result = worker->mapper(worker);
+    // Set up the callback with a null first
+    Local<Value> info[2] = { Nan::Null(), result};
+    // Wrap the callback function call in a TryCatch so that we can call
+    // node's FatalException afterwards. This makes it possible to catch
+    // the exception from JavaScript land using the
+    // process.on('uncaughtException') event.
+    Nan::TryCatch try_catch;
+
+    // Call the callback
+    worker->callback->Call(ARRAY_SIZE(info), info);
+
+    // If we have an exception handle it as a fatalexception
+    if (try_catch.HasCaught()) {
+      Nan::FatalException(try_catch);
+    }
+  }
+
+  // Clean up the memory
+  delete worker->callback;
+  delete worker;
+}
+
+Nan::Persistent<FunctionTemplate> SecurityContext::constructor_template;
+
+SecurityContext::SecurityContext() : Nan::ObjectWrap() {
+}
+
+SecurityContext::~SecurityContext() {
+  if(this->hasContext) {
+    _sspi_DeleteSecurityContext(&this->m_Context);
+  }
+}
+
+NAN_METHOD(SecurityContext::New) {
+  PSecurityFunctionTable pSecurityInterface = NULL;
+  DWORD dwNumOfPkgs;
+  SECURITY_STATUS status;
+
+  // Create code object
+  SecurityContext *security_obj = new SecurityContext();
+  // Get security table interface
+  pSecurityInterface = _ssip_InitSecurityInterface();
+  // Call the security interface
+  status = (*pSecurityInterface->EnumerateSecurityPackages)(
+                                                    &dwNumOfPkgs,
+                                                    &security_obj->m_PkgInfo);
+  if(status != SEC_E_OK) {
+    printf(TEXT("Failed in retrieving security packages, Error: %x"), GetLastError());
+    return Nan::ThrowError("Failed in retrieving security packages");
+  }
+
+  // Wrap it
+  security_obj->Wrap(info.This());
+  // Return the object
+  info.GetReturnValue().Set(info.This());
+}
+
+//
+//  Async InitializeContext
+//
+typedef struct SecurityContextStaticInitializeCall {
+  char *service_principal_name_str;
+  char *decoded_input_str;
+  int decoded_input_str_length;
+  SecurityContext *context;
+} SecurityContextStaticInitializeCall;
+
+static void _initializeContext(Worker *worker) {
+  // Status of operation
+  SECURITY_STATUS status;
+  BYTE *out_bound_data_str = NULL;
+  SecurityContextStaticInitializeCall *call = (SecurityContextStaticInitializeCall *)worker->parameters;
+
+  // Structures used for c calls
+  SecBufferDesc ibd, obd;
+  SecBuffer ib, ob;
+
+  //
+  // Prepare data structure for returned data from SSPI
+  ob.BufferType = SECBUFFER_TOKEN;
+  ob.cbBuffer = call->context->m_PkgInfo->cbMaxToken;
+  // Allocate space for return data
+  out_bound_data_str = new BYTE[ob.cbBuffer + sizeof(DWORD)];
+  ob.pvBuffer = out_bound_data_str;
+  // prepare buffer description
+  obd.cBuffers  = 1;
+  obd.ulVersion = SECBUFFER_VERSION;
+  obd.pBuffers  = &ob;
+
+  //
+  // Prepare the data we are passing to the SSPI method
+  if(call->decoded_input_str_length > 0) {
+    ib.BufferType = SECBUFFER_TOKEN;
+    ib.cbBuffer   = call->decoded_input_str_length;
+    ib.pvBuffer   = call->decoded_input_str;
+    // prepare buffer description
+    ibd.cBuffers  = 1;
+    ibd.ulVersion = SECBUFFER_VERSION;
+    ibd.pBuffers  = &ib;
+  }
+
+  // Perform initialization step
+  status = _sspi_initializeSecurityContext(
+      &call->context->security_credentials->m_Credentials
+    , NULL
+    , const_cast<TCHAR*>(call->service_principal_name_str)
+    , 0x02  // MUTUAL
+    , 0
+    , 0     // Network
+    , call->decoded_input_str_length > 0 ? &ibd : NULL
+    , 0
+    , &call->context->m_Context
+    , &obd
+    , &call->context->CtxtAttr
+    , &call->context->Expiration
+  );
+
+  // If we have a ok or continue let's prepare the result
+  if(status == SEC_E_OK
+    || status == SEC_I_COMPLETE_NEEDED
+    || status == SEC_I_CONTINUE_NEEDED
+    || status == SEC_I_COMPLETE_AND_CONTINUE
+  ) {
+    call->context->hasContext = true;
+    call->context->payload = base64_encode((const unsigned char *)ob.pvBuffer, ob.cbBuffer);
+
+    // Set the context
+    worker->return_code = status;
+    worker->return_value = call->context;
+  } else if(status == SEC_E_INSUFFICIENT_MEMORY) {
+    worker->error = TRUE;
+    worker->error_code = status;
+    worker->error_message = "SEC_E_INSUFFICIENT_MEMORY There is not enough memory available to complete the requested action.";
+  } else if(status == SEC_E_INTERNAL_ERROR) {
+    worker->error = TRUE;
+    worker->error_code = status;
+    worker->error_message = "SEC_E_INTERNAL_ERROR An error occurred that did not map to an SSPI error code.";
+  } else if(status == SEC_E_INVALID_HANDLE) {
+    worker->error = TRUE;
+    worker->error_code = status;
+    worker->error_message = "SEC_E_INVALID_HANDLE The handle passed to the function is not valid.";
+  } else if(status == SEC_E_INVALID_TOKEN) {
+    worker->error = TRUE;
+    worker->error_code = status;
+    worker->error_message = "SEC_E_INVALID_TOKEN The error is due to a malformed input token, such as a token corrupted in transit, a token of incorrect size, or a token passed into the wrong security package. Passing a token to the wrong package can happen if the client and server did not negotiate the proper security package.";
+  } else if(status == SEC_E_LOGON_DENIED) {
+    worker->error = TRUE;
+    worker->error_code = status;
+    worker->error_message = "SEC_E_LOGON_DENIED The logon failed.";
+  } else if(status == SEC_E_NO_AUTHENTICATING_AUTHORITY) {
+    worker->error = TRUE;
+    worker->error_code = status;
+    worker->error_message = "SEC_E_NO_AUTHENTICATING_AUTHORITY No authority could be contacted for authentication. The domain name of the authenticating party could be wrong, the domain could be unreachable, or there might have been a trust relationship failure.";
+  } else if(status == SEC_E_NO_CREDENTIALS) {
+    worker->error = TRUE;
+    worker->error_code = status;
+    worker->error_message = "SEC_E_NO_CREDENTIALS No credentials are available in the security package.";
+  } else if(status == SEC_E_TARGET_UNKNOWN) {
+    worker->error = TRUE;
+    worker->error_code = status;
+    worker->error_message = "SEC_E_TARGET_UNKNOWN The target was not recognized.";
+  } else if(status == SEC_E_UNSUPPORTED_FUNCTION) {
+    worker->error = TRUE;
+    worker->error_code = status;
+    worker->error_message = "SEC_E_UNSUPPORTED_FUNCTION A context attribute flag that is not valid (ISC_REQ_DELEGATE or ISC_REQ_PROMPT_FOR_CREDS) was specified in the fContextReq parameter.";
+  } else if(status == SEC_E_WRONG_PRINCIPAL) {
+    worker->error = TRUE;
+    worker->error_code = status;
+    worker->error_message = "SEC_E_WRONG_PRINCIPAL The principal that received the authentication request is not the same as the one passed into the pszTargetName parameter. This indicates a failure in mutual authentication.";
+  } else {
+    worker->error = TRUE;
+    worker->error_code = status;
+    worker->error_message = DisplaySECError(status);
+  }
+
+  // Clean up data
+  if(call->decoded_input_str != NULL) free(call->decoded_input_str);
+  if(call->service_principal_name_str != NULL) free(call->service_principal_name_str);
+}
+
+static Local<Value> _map_initializeContext(Worker *worker) {
+  // Unwrap the security context
+  SecurityContext *context = (SecurityContext *)worker->return_value;
+  // Return the value
+  return context->handle();
+}
+
+NAN_METHOD(SecurityContext::InitializeContext) {
+  char *service_principal_name_str = NULL, *input_str = NULL, *decoded_input_str = NULL;
+  int decoded_input_str_length = NULL;
+  // Store reference to security credentials
+  SecurityCredentials *security_credentials = NULL;
+
+  // We need 3 parameters
+  if(info.Length() != 4)
+    return Nan::ThrowError("Initialize must be called with [credential:SecurityCredential, servicePrincipalName:string, input:string, callback:function]");
+
+  // First parameter must be an instance of SecurityCredentials
+  if(!SecurityCredentials::HasInstance(info[0]))
+    return Nan::ThrowError("First parameter for Initialize must be an instance of SecurityCredentials");
+
+  // Second parameter must be a string
+  if(!info[1]->IsString())
+    return Nan::ThrowError("Second parameter for Initialize must be a string");
+
+  // Third parameter must be a base64 encoded string
+  if(!info[2]->IsString())
+    return Nan::ThrowError("Second parameter for Initialize must be a string");
+
+  // Third parameter must be a callback
+  if(!info[3]->IsFunction())
+    return Nan::ThrowError("Third parameter for Initialize must be a callback function");
+
+  // Let's unpack the values
+  Local<String> service_principal_name = info[1]->ToString();
+  service_principal_name_str = (char *)calloc(service_principal_name->Utf8Length() + 1, sizeof(char));
+  service_principal_name->WriteUtf8(service_principal_name_str);
+
+  // Unpack the user name
+  Local<String> input = info[2]->ToString();
+
+  if(input->Utf8Length() > 0) {
+    input_str = (char *)calloc(input->Utf8Length() + 1, sizeof(char));
+    input->WriteUtf8(input_str);
+
+    // Now let's get the base64 decoded string
+    decoded_input_str = (char *)base64_decode(input_str, &decoded_input_str_length);
+    // Free original allocation
+    free(input_str);
+  }
+
+  // Unpack the Security credentials
+  security_credentials = Nan::ObjectWrap::Unwrap<SecurityCredentials>(info[0]->ToObject());
+  // Create Security context instance
+  Local<Object> security_context_value = Nan::New(constructor_template)->GetFunction()->NewInstance();
+  // Unwrap the security context
+  SecurityContext *security_context = Nan::ObjectWrap::Unwrap<SecurityContext>(security_context_value);
+  // Add a reference to the security_credentials
+  security_context->security_credentials = security_credentials;
+
+  // Build the call function
+  SecurityContextStaticInitializeCall *call = (SecurityContextStaticInitializeCall *)calloc(1, sizeof(SecurityContextStaticInitializeCall));
+  call->context = security_context;
+  call->decoded_input_str = decoded_input_str;
+  call->decoded_input_str_length = decoded_input_str_length;
+  call->service_principal_name_str = service_principal_name_str;
+
+  // Callback
+  Local<Function> callback = Local<Function>::Cast(info[3]);
+
+  // Let's allocate some space
+  Worker *worker = new Worker();
+  worker->error = false;
+  worker->request.data = worker;
+  worker->callback = new Nan::Callback(callback);
+  worker->parameters = call;
+  worker->execute = _initializeContext;
+  worker->mapper = _map_initializeContext;
+
+  // Schedule the worker with lib_uv
+  uv_queue_work(uv_default_loop(), &worker->request, Process, (uv_after_work_cb)After);
+
+  // Return no value as it's callback based
+  info.GetReturnValue().Set(Nan::Undefined());
+}
+
+NAN_GETTER(SecurityContext::PayloadGetter) {
+  // Unpack the context object
+  SecurityContext *context = Nan::ObjectWrap::Unwrap<SecurityContext>(info.This());
+  // Return the low bits
+  info.GetReturnValue().Set(Nan::New<String>(context->payload).ToLocalChecked());
+}
+
+NAN_GETTER(SecurityContext::HasContextGetter) {
+  // Unpack the context object
+  SecurityContext *context = Nan::ObjectWrap::Unwrap<SecurityContext>(info.This());
+  // Return the low bits
+  info.GetReturnValue().Set(Nan::New<Boolean>(context->hasContext));
+}
+
+//
+//  Async InitializeContextStep
+//
+typedef struct SecurityContextStepStaticInitializeCall {
+  char *service_principal_name_str;
+  char *decoded_input_str;
+  int decoded_input_str_length;
+  SecurityContext *context;
+} SecurityContextStepStaticInitializeCall;
+
+static void _initializeContextStep(Worker *worker) {
+  // Outbound data array
+  BYTE *out_bound_data_str = NULL;
+  // Status of operation
+  SECURITY_STATUS status;
+  // Unpack data
+  SecurityContextStepStaticInitializeCall *call = (SecurityContextStepStaticInitializeCall *)worker->parameters;
+  SecurityContext *context = call->context;
+  // Structures used for c calls
+  SecBufferDesc ibd, obd;
+  SecBuffer ib, ob;
+
+  //
+  // Prepare data structure for returned data from SSPI
+  ob.BufferType = SECBUFFER_TOKEN;
+  ob.cbBuffer = context->m_PkgInfo->cbMaxToken;
+  // Allocate space for return data
+  out_bound_data_str = new BYTE[ob.cbBuffer + sizeof(DWORD)];
+  ob.pvBuffer = out_bound_data_str;
+  // prepare buffer description
+  obd.cBuffers  = 1;
+  obd.ulVersion = SECBUFFER_VERSION;
+  obd.pBuffers  = &ob;
+
+  //
+  // Prepare the data we are passing to the SSPI method
+  if(call->decoded_input_str_length > 0) {
+    ib.BufferType = SECBUFFER_TOKEN;
+    ib.cbBuffer   = call->decoded_input_str_length;
+    ib.pvBuffer   = call->decoded_input_str;
+    // prepare buffer description
+    ibd.cBuffers  = 1;
+    ibd.ulVersion = SECBUFFER_VERSION;
+    ibd.pBuffers  = &ib;
+  }
+
+  // Perform initialization step
+  status = _sspi_initializeSecurityContext(
+      &context->security_credentials->m_Credentials
+    , context->hasContext == true ? &context->m_Context : NULL
+    , const_cast<TCHAR*>(call->service_principal_name_str)
+    , 0x02  // MUTUAL
+    , 0
+    , 0     // Network
+    , call->decoded_input_str_length ? &ibd : NULL
+    , 0
+    , &context->m_Context
+    , &obd
+    , &context->CtxtAttr
+    , &context->Expiration
+  );
+
+  // If we have a ok or continue let's prepare the result
+  if(status == SEC_E_OK
+    || status == SEC_I_COMPLETE_NEEDED
+    || status == SEC_I_CONTINUE_NEEDED
+    || status == SEC_I_COMPLETE_AND_CONTINUE
+  ) {
+    // Set the new payload
+    if(context->payload != NULL) free(context->payload);
+    context->payload = base64_encode((const unsigned char *)ob.pvBuffer, ob.cbBuffer);
+    worker->return_code = status;
+    worker->return_value = context;
+  } else {
+    worker->error = TRUE;
+    worker->error_code = status;
+    worker->error_message = DisplaySECError(status);
+  }
+
+  // Clean up data
+  if(call->decoded_input_str != NULL) free(call->decoded_input_str);
+  if(call->service_principal_name_str != NULL) free(call->service_principal_name_str);
+}
+
+static Local<Value> _map_initializeContextStep(Worker *worker) {
+  // Unwrap the security context
+  SecurityContext *context = (SecurityContext *)worker->return_value;
+  // Return the value
+  return context->handle();
+}
+
+NAN_METHOD(SecurityContext::InitalizeStep) {
+  char *service_principal_name_str = NULL, *input_str = NULL, *decoded_input_str = NULL;
+  int decoded_input_str_length = NULL;
+
+  // We need 3 parameters
+  if(info.Length() != 3)
+    return Nan::ThrowError("Initialize must be called with [servicePrincipalName:string, input:string, callback:function]");
+
+  // Second parameter must be a string
+  if(!info[0]->IsString())
+    return Nan::ThrowError("First parameter for Initialize must be a string");
+
+  // Third parameter must be a base64 encoded string
+  if(!info[1]->IsString())
+    return Nan::ThrowError("Second parameter for Initialize must be a string");
+
+  // Third parameter must be a base64 encoded string
+  if(!info[2]->IsFunction())
+    return Nan::ThrowError("Third parameter for Initialize must be a callback function");
+
+  // Let's unpack the values
+  Local<String> service_principal_name = info[0]->ToString();
+  service_principal_name_str = (char *)calloc(service_principal_name->Utf8Length() + 1, sizeof(char));
+  service_principal_name->WriteUtf8(service_principal_name_str);
+
+  // Unpack the user name
+  Local<String> input = info[1]->ToString();
+
+  if(input->Utf8Length() > 0) {
+    input_str = (char *)calloc(input->Utf8Length() + 1, sizeof(char));
+    input->WriteUtf8(input_str);
+    // Now let's get the base64 decoded string
+    decoded_input_str = (char *)base64_decode(input_str, &decoded_input_str_length);
+    // Free input string
+    free(input_str);
+  }
+
+  // Unwrap the security context
+  SecurityContext *security_context = Nan::ObjectWrap::Unwrap<SecurityContext>(info.This());
+
+  // Create call structure
+  SecurityContextStepStaticInitializeCall *call = (SecurityContextStepStaticInitializeCall *)calloc(1, sizeof(SecurityContextStepStaticInitializeCall));
+  call->context = security_context;
+  call->decoded_input_str = decoded_input_str;
+  call->decoded_input_str_length = decoded_input_str_length;
+  call->service_principal_name_str = service_principal_name_str;
+
+  // Callback
+  Local<Function> callback = Local<Function>::Cast(info[2]);
+
+  // Let's allocate some space
+  Worker *worker = new Worker();
+  worker->error = false;
+  worker->request.data = worker;
+  worker->callback = new Nan::Callback(callback);
+  worker->parameters = call;
+  worker->execute = _initializeContextStep;
+  worker->mapper = _map_initializeContextStep;
+
+  // Schedule the worker with lib_uv
+  uv_queue_work(uv_default_loop(), &worker->request, Process, (uv_after_work_cb)After);
+
+  // Return no value as it's callback based
+  info.GetReturnValue().Set(Nan::Undefined());
+}
+
+//
+//  Async EncryptMessage
+//
+typedef struct SecurityContextEncryptMessageCall {
+  SecurityContext *context;
+  SecurityBufferDescriptor *descriptor;
+  unsigned long flags;
+} SecurityContextEncryptMessageCall;
+
+static void _encryptMessage(Worker *worker) {
+  SECURITY_STATUS status;
+  // Unpack call
+  SecurityContextEncryptMessageCall *call = (SecurityContextEncryptMessageCall *)worker->parameters;
+  // Unpack the security context
+  SecurityContext *context = call->context;
+  SecurityBufferDescriptor *descriptor = call->descriptor;
+
+  // Let's execute encryption
+  status = _sspi_EncryptMessage(
+      &context->m_Context
+    , call->flags
+    , &descriptor->secBufferDesc
+    , 0
+  );
+
+  // We've got ok
+  if(status == SEC_E_OK) {
+    int bytesToAllocate = (int)descriptor->bufferSize();
+    // Free up existing payload
+    if(context->payload != NULL) free(context->payload);
+    // Save the payload
+    context->payload = base64_encode((unsigned char *)descriptor->toBuffer(), bytesToAllocate);
+    // Set result
+    worker->return_code = status;
+    worker->return_value = context;
+  } else {
+    worker->error = TRUE;
+    worker->error_code = status;
+    worker->error_message = DisplaySECError(status);
+  }
+}
+
+static Local<Value> _map_encryptMessage(Worker *worker) {
+  // Unwrap the security context
+  SecurityContext *context = (SecurityContext *)worker->return_value;
+  // Return the value
+  return context->handle();
+}
+
+NAN_METHOD(SecurityContext::EncryptMessage) {
+  if(info.Length() != 3)
+    return Nan::ThrowError("EncryptMessage takes an instance of SecurityBufferDescriptor, an integer flag and a callback function");
+  if(!SecurityBufferDescriptor::HasInstance(info[0]))
+    return Nan::ThrowError("EncryptMessage takes an instance of SecurityBufferDescriptor, an integer flag and a callback function");
+  if(!info[1]->IsUint32())
+    return Nan::ThrowError("EncryptMessage takes an instance of SecurityBufferDescriptor, an integer flag and a callback function");
+  if(!info[2]->IsFunction())
+    return Nan::ThrowError("EncryptMessage takes an instance of SecurityBufferDescriptor, an integer flag and a callback function");
+
+  // Unpack the security context
+  SecurityContext *security_context = Nan::ObjectWrap::Unwrap<SecurityContext>(info.This());
+
+  // Unpack the descriptor
+  SecurityBufferDescriptor *descriptor = Nan::ObjectWrap::Unwrap<SecurityBufferDescriptor>(info[0]->ToObject());
+
+  // Create call structure
+  SecurityContextEncryptMessageCall *call = (SecurityContextEncryptMessageCall *)calloc(1, sizeof(SecurityContextEncryptMessageCall));
+  call->context = security_context;
+  call->descriptor = descriptor;
+  call->flags = (unsigned long)info[1]->ToInteger()->Value();
+
+  // Callback
+  Local<Function> callback = Local<Function>::Cast(info[2]);
+
+  // Let's allocate some space
+  Worker *worker = new Worker();
+  worker->error = false;
+  worker->request.data = worker;
+  worker->callback = new Nan::Callback(callback);
+  worker->parameters = call;
+  worker->execute = _encryptMessage;
+  worker->mapper = _map_encryptMessage;
+
+  // Schedule the worker with lib_uv
+  uv_queue_work(uv_default_loop(), &worker->request, Process, (uv_after_work_cb)After);
+
+  // Return no value as it's callback based
+  info.GetReturnValue().Set(Nan::Undefined());
+}
+
+//
+//  Async DecryptMessage
+//
+typedef struct SecurityContextDecryptMessageCall {
+  SecurityContext *context;
+  SecurityBufferDescriptor *descriptor;
+} SecurityContextDecryptMessageCall;
+
+static void _decryptMessage(Worker *worker) {
+  unsigned long quality = 0;
+  SECURITY_STATUS status;
+
+  // Unpack parameters
+  SecurityContextDecryptMessageCall *call = (SecurityContextDecryptMessageCall *)worker->parameters;
+  SecurityContext *context = call->context;
+  SecurityBufferDescriptor *descriptor = call->descriptor;
+
+  // Let's execute encryption
+  status = _sspi_DecryptMessage(
+      &context->m_Context
+    , &descriptor->secBufferDesc
+    , 0
+    , (unsigned long)&quality
+  );
+
+  // We've got ok
+  if(status == SEC_E_OK) {
+    int bytesToAllocate = (int)descriptor->bufferSize();
+    // Free up existing payload
+    if(context->payload != NULL) free(context->payload);
+    // Save the payload
+    context->payload = base64_encode((unsigned char *)descriptor->toBuffer(), bytesToAllocate);
+    // Set return values
+    worker->return_code = status;
+    worker->return_value = context;
+  } else {
+    worker->error = TRUE;
+    worker->error_code = status;
+    worker->error_message = DisplaySECError(status);
+  }
+}
+
+static Local<Value> _map_decryptMessage(Worker *worker) {
+  // Unwrap the security context
+  SecurityContext *context = (SecurityContext *)worker->return_value;
+  // Return the value
+  return context->handle();
+}
+
+NAN_METHOD(SecurityContext::DecryptMessage) {
+  if(info.Length() != 2)
+    return Nan::ThrowError("DecryptMessage takes an instance of SecurityBufferDescriptor and a callback function");
+  if(!SecurityBufferDescriptor::HasInstance(info[0]))
+    return Nan::ThrowError("DecryptMessage takes an instance of SecurityBufferDescriptor and a callback function");
+  if(!info[1]->IsFunction())
+    return Nan::ThrowError("DecryptMessage takes an instance of SecurityBufferDescriptor and a callback function");
+
+  // Unpack the security context
+  SecurityContext *security_context = Nan::ObjectWrap::Unwrap<SecurityContext>(info.This());
+  // Unpack the descriptor
+  SecurityBufferDescriptor *descriptor = Nan::ObjectWrap::Unwrap<SecurityBufferDescriptor>(info[0]->ToObject());
+  // Create call structure
+  SecurityContextDecryptMessageCall *call = (SecurityContextDecryptMessageCall *)calloc(1, sizeof(SecurityContextDecryptMessageCall));
+  call->context = security_context;
+  call->descriptor = descriptor;
+
+  // Callback
+  Local<Function> callback = Local<Function>::Cast(info[1]);
+
+  // Let's allocate some space
+  Worker *worker = new Worker();
+  worker->error = false;
+  worker->request.data = worker;
+  worker->callback = new Nan::Callback(callback);
+  worker->parameters = call;
+  worker->execute = _decryptMessage;
+  worker->mapper = _map_decryptMessage;
+
+  // Schedule the worker with lib_uv
+  uv_queue_work(uv_default_loop(), &worker->request, Process, (uv_after_work_cb)After);
+
+  // Return no value as it's callback based
+  info.GetReturnValue().Set(Nan::Undefined());
+}
+
+//
+//  Async QueryContextAttributes
+//
+typedef struct SecurityContextQueryContextAttributesCall {
+  SecurityContext *context;
+  uint32_t attribute;
+} SecurityContextQueryContextAttributesCall;
+
+static void _queryContextAttributes(Worker *worker) {
+  SECURITY_STATUS status;
+
+  // Cast to data structure
+  SecurityContextQueryContextAttributesCall *call = (SecurityContextQueryContextAttributesCall *)worker->parameters;
+
+  // Allocate some space
+  SecPkgContext_Sizes *sizes = (SecPkgContext_Sizes *)calloc(1, sizeof(SecPkgContext_Sizes));
+  // Let's grab the query context attribute
+  status = _sspi_QueryContextAttributes(
+    &call->context->m_Context,
+    call->attribute,
+    sizes
+  );
+
+  if(status == SEC_E_OK) {
+    worker->return_code = status;
+    worker->return_value = sizes;
+  } else {
+    worker->error = TRUE;
+    worker->error_code = status;
+    worker->error_message = DisplaySECError(status);
+  }
+}
+
+static Local<Value> _map_queryContextAttributes(Worker *worker) {
+  // Cast to data structure
+  SecurityContextQueryContextAttributesCall *call = (SecurityContextQueryContextAttributesCall *)worker->parameters;
+  // Unpack the attribute
+  uint32_t attribute = call->attribute;
+
+  // Convert data
+  if(attribute == SECPKG_ATTR_SIZES) {
+    SecPkgContext_Sizes *sizes = (SecPkgContext_Sizes *)worker->return_value;
+    // Create object
+    Local<Object> value = Nan::New<Object>();
+    value->Set(Nan::New<String>("maxToken").ToLocalChecked(), Nan::New<Integer>(uint32_t(sizes->cbMaxToken)));
+    value->Set(Nan::New<String>("maxSignature").ToLocalChecked(), Nan::New<Integer>(uint32_t(sizes->cbMaxSignature)));
+    value->Set(Nan::New<String>("blockSize").ToLocalChecked(), Nan::New<Integer>(uint32_t(sizes->cbBlockSize)));
+    value->Set(Nan::New<String>("securityTrailer").ToLocalChecked(), Nan::New<Integer>(uint32_t(sizes->cbSecurityTrailer)));
+    return value;
+  }
+
+  // Return the value
+  return Nan::Null();
+}
+
+NAN_METHOD(SecurityContext::QueryContextAttributes) {
+  if(info.Length() != 2)
+    return Nan::ThrowError("QueryContextAttributes method takes a an integer Attribute specifier and a callback function");
+  if(!info[0]->IsInt32())
+    return Nan::ThrowError("QueryContextAttributes method takes a an integer Attribute specifier and a callback function");
+  if(!info[1]->IsFunction())
+    return Nan::ThrowError("QueryContextAttributes method takes a an integer Attribute specifier and a callback function");
+
+  // Unpack the security context
+  SecurityContext *security_context = Nan::ObjectWrap::Unwrap<SecurityContext>(info.This());
+
+  // Unpack the int value
+  uint32_t attribute = info[0]->ToInt32()->Value();
+
+  // Check that we have a supported attribute
+  if(attribute != SECPKG_ATTR_SIZES)
+    return Nan::ThrowError("QueryContextAttributes only supports the SECPKG_ATTR_SIZES attribute");
+
+  // Create call structure
+  SecurityContextQueryContextAttributesCall *call = (SecurityContextQueryContextAttributesCall *)calloc(1, sizeof(SecurityContextQueryContextAttributesCall));
+  call->attribute = attribute;
+  call->context = security_context;
+
+  // Callback
+  Local<Function> callback = Local<Function>::Cast(info[1]);
+
+  // Let's allocate some space
+  Worker *worker = new Worker();
+  worker->error = false;
+  worker->request.data = worker;
+  worker->callback = new Nan::Callback(callback);
+  worker->parameters = call;
+  worker->execute = _queryContextAttributes;
+  worker->mapper = _map_queryContextAttributes;
+
+  // Schedule the worker with lib_uv
+  uv_queue_work(uv_default_loop(), &worker->request, Process, (uv_after_work_cb)After);
+
+  // Return no value as it's callback based
+  info.GetReturnValue().Set(Nan::Undefined());
+}
+
+void SecurityContext::Initialize(Nan::ADDON_REGISTER_FUNCTION_ARGS_TYPE target) {
+  // Grab the scope of the call from Node
+  Nan::HandleScope scope;
+
+  // Define a new function template
+  Local<FunctionTemplate> t = Nan::New<v8::FunctionTemplate>(static_cast<NAN_METHOD((*))>(SecurityContext::New));
+  t->InstanceTemplate()->SetInternalFieldCount(1);
+  t->SetClassName(Nan::New<String>("SecurityContext").ToLocalChecked());
+
+  // Class methods
+  Nan::SetMethod(t, "initialize", SecurityContext::InitializeContext);
+
+  // Set up method for the instance
+  Nan::SetPrototypeMethod(t, "initialize", SecurityContext::InitalizeStep);
+  Nan::SetPrototypeMethod(t, "decryptMessage", SecurityContext::DecryptMessage);
+  Nan::SetPrototypeMethod(t, "queryContextAttributes", SecurityContext::QueryContextAttributes);
+  Nan::SetPrototypeMethod(t, "encryptMessage", SecurityContext::EncryptMessage);
+
+  // Get prototype
+  Local<ObjectTemplate> proto = t->PrototypeTemplate();
+
+  // Getter for the response
+  Nan::SetAccessor(proto, Nan::New<String>("payload").ToLocalChecked(), SecurityContext::PayloadGetter);
+  Nan::SetAccessor(proto, Nan::New<String>("hasContext").ToLocalChecked(), SecurityContext::HasContextGetter);
+
+  // Set persistent
+  SecurityContext::constructor_template.Reset(t);
+
+  // Set the symbol
+  target->ForceSet(Nan::New<String>("SecurityContext").ToLocalChecked(), t->GetFunction());
+}
+
+static LPSTR DisplaySECError(DWORD ErrCode) {
+  LPSTR pszName = NULL; // WinError.h
+
+  switch(ErrCode) {
+    case SEC_E_BUFFER_TOO_SMALL:
+      pszName = "SEC_E_BUFFER_TOO_SMALL - The message buffer is too small. Used with the Digest SSP.";
+      break;
+
+    case SEC_E_CRYPTO_SYSTEM_INVALID:
+      pszName = "SEC_E_CRYPTO_SYSTEM_INVALID - The cipher chosen for the security context is not supported. Used with the Digest SSP.";
+      break;
+    case SEC_E_INCOMPLETE_MESSAGE:
+      pszName = "SEC_E_INCOMPLETE_MESSAGE - The data in the input buffer is incomplete. The application needs to read more data from the server and call DecryptMessageSync (General) again.";
+      break;
+
+    case SEC_E_INVALID_HANDLE:
+      pszName = "SEC_E_INVALID_HANDLE - A context handle that is not valid was specified in the phContext parameter. Used with the Digest and Schannel SSPs.";
+      break;
+
+    case SEC_E_INVALID_TOKEN:
+      pszName = "SEC_E_INVALID_TOKEN - The buffers are of the wrong type or no buffer of type SECBUFFER_DATA was found. Used with the Schannel SSP.";
+      break;
+
+    case SEC_E_MESSAGE_ALTERED:
+      pszName = "SEC_E_MESSAGE_ALTERED - The message has been altered. Used with the Digest and Schannel SSPs.";
+      break;
+
+    case SEC_E_OUT_OF_SEQUENCE:
+      pszName = "SEC_E_OUT_OF_SEQUENCE - The message was not received in the correct sequence.";
+      break;
+
+    case SEC_E_QOP_NOT_SUPPORTED:
+      pszName = "SEC_E_QOP_NOT_SUPPORTED - Neither confidentiality nor integrity are supported by the security context. Used with the Digest SSP.";
+      break;
+
+    case SEC_I_CONTEXT_EXPIRED:
+      pszName = "SEC_I_CONTEXT_EXPIRED - The message sender has finished using the connection and has initiated a shutdown.";
+      break;
+
+    case SEC_I_RENEGOTIATE:
+      pszName = "SEC_I_RENEGOTIATE - The remote party requires a new handshake sequence or the application has just initiated a shutdown.";
+      break;
+
+    case SEC_E_ENCRYPT_FAILURE:
+      pszName = "SEC_E_ENCRYPT_FAILURE - The specified data could not be encrypted.";
+      break;
+
+    case SEC_E_DECRYPT_FAILURE:
+      pszName = "SEC_E_DECRYPT_FAILURE - The specified data could not be decrypted.";
+      break;
+    case -1:
+      pszName = "Failed to load security.dll library";
+      break;
+  }
+
+  return pszName;
+}
+

http://git-wip-us.apache.org/repos/asf/couchdb-nmo/blob/753f1767/node_modules/couchbulkimporter/node_modules/mongodb/node_modules/mongodb-core/node_modules/kerberos/lib/win32/wrappers/security_context.h
----------------------------------------------------------------------
diff --git a/node_modules/couchbulkimporter/node_modules/mongodb/node_modules/mongodb-core/node_modules/kerberos/lib/win32/wrappers/security_context.h b/node_modules/couchbulkimporter/node_modules/mongodb/node_modules/mongodb-core/node_modules/kerberos/lib/win32/wrappers/security_context.h
new file mode 100644
index 0000000..1d9387d
--- /dev/null
+++ b/node_modules/couchbulkimporter/node_modules/mongodb/node_modules/mongodb-core/node_modules/kerberos/lib/win32/wrappers/security_context.h
@@ -0,0 +1,74 @@
+#ifndef SECURITY_CONTEXT_H
+#define SECURITY_CONTEXT_H
+
+#include <node.h>
+#include <node_object_wrap.h>
+#include <v8.h>
+
+#define SECURITY_WIN32 1
+
+#include <winsock2.h>
+#include <windows.h>
+#include <sspi.h>
+#include <tchar.h>
+#include "security_credentials.h"
+#include "../worker.h"
+#include <nan.h>
+
+extern "C" {
+  #include "../kerberos_sspi.h"
+  #include "../base64.h"
+}
+
+using namespace v8;
+using namespace node;
+
+class SecurityContext : public Nan::ObjectWrap {
+  public:
+    SecurityContext();
+    ~SecurityContext();
+
+    // Security info package
+    PSecPkgInfo m_PkgInfo;
+    // Do we have a context
+    bool hasContext;
+    // Reference to security credentials
+    SecurityCredentials *security_credentials;
+    // Security context
+    CtxtHandle m_Context;
+    // Attributes
+    DWORD CtxtAttr;
+    // Expiry time for ticket
+    TimeStamp Expiration;
+    // Payload
+    char *payload;
+
+    // Has instance check
+    static inline bool HasInstance(Local<Value> val) {
+      if (!val->IsObject()) return false;
+      Local<Object> obj = val->ToObject();
+      return Nan::New(constructor_template)->HasInstance(obj);
+    };
+
+    // Functions available from V8
+    static void Initialize(Nan::ADDON_REGISTER_FUNCTION_ARGS_TYPE target);
+    static NAN_METHOD(InitializeContext);
+    static NAN_METHOD(InitalizeStep);
+    static NAN_METHOD(DecryptMessage);
+    static NAN_METHOD(QueryContextAttributes);
+    static NAN_METHOD(EncryptMessage);
+
+    // Payload getter
+    static NAN_GETTER(PayloadGetter);
+    // hasContext getter
+    static NAN_GETTER(HasContextGetter);
+
+    // Constructor used for creating new Long objects from C++
+    static Nan::Persistent<FunctionTemplate> constructor_template;
+
+ // private:
+    // Create a new instance
+    static NAN_METHOD(New);
+};
+
+#endif

http://git-wip-us.apache.org/repos/asf/couchdb-nmo/blob/753f1767/node_modules/couchbulkimporter/node_modules/mongodb/node_modules/mongodb-core/node_modules/kerberos/lib/win32/wrappers/security_context.js
----------------------------------------------------------------------
diff --git a/node_modules/couchbulkimporter/node_modules/mongodb/node_modules/mongodb-core/node_modules/kerberos/lib/win32/wrappers/security_context.js b/node_modules/couchbulkimporter/node_modules/mongodb/node_modules/mongodb-core/node_modules/kerberos/lib/win32/wrappers/security_context.js
new file mode 100644
index 0000000..ef04e92
--- /dev/null
+++ b/node_modules/couchbulkimporter/node_modules/mongodb/node_modules/mongodb-core/node_modules/kerberos/lib/win32/wrappers/security_context.js
@@ -0,0 +1,3 @@
+var SecurityContextNative = require('../../../build/Release/kerberos').SecurityContext;
+// Export the modified class
+exports.SecurityContext = SecurityContextNative;
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/couchdb-nmo/blob/753f1767/node_modules/couchbulkimporter/node_modules/mongodb/node_modules/mongodb-core/node_modules/kerberos/lib/win32/wrappers/security_credentials.cc
----------------------------------------------------------------------
diff --git a/node_modules/couchbulkimporter/node_modules/mongodb/node_modules/mongodb-core/node_modules/kerberos/lib/win32/wrappers/security_credentials.cc b/node_modules/couchbulkimporter/node_modules/mongodb/node_modules/mongodb-core/node_modules/kerberos/lib/win32/wrappers/security_credentials.cc
new file mode 100644
index 0000000..732af3f
--- /dev/null
+++ b/node_modules/couchbulkimporter/node_modules/mongodb/node_modules/mongodb-core/node_modules/kerberos/lib/win32/wrappers/security_credentials.cc
@@ -0,0 +1,348 @@
+#include <node.h>
+#include <assert.h>
+#include <string.h>
+#include <stdlib.h>
+#include <v8.h>
+#include <node_buffer.h>
+#include <cstring>
+#include <cmath>
+#include <cstdlib>
+#include <iostream>
+#include <limits>
+
+#include "security_credentials.h"
+
+#ifndef ARRAY_SIZE
+# define ARRAY_SIZE(a) (sizeof((a)) / sizeof((a)[0]))
+#endif
+
+static LPSTR DisplaySECError(DWORD ErrCode);
+
+Nan::Persistent<FunctionTemplate> SecurityCredentials::constructor_template;
+
+SecurityCredentials::SecurityCredentials() : Nan::ObjectWrap() {
+}
+
+SecurityCredentials::~SecurityCredentials() {
+}
+
+NAN_METHOD(SecurityCredentials::New) {
+  // Create security credentials instance
+  SecurityCredentials *security_credentials = new SecurityCredentials();
+  // Wrap it
+  security_credentials->Wrap(info.This());
+  // Return the object
+  info.GetReturnValue().Set(info.This());
+}
+
+// Call structs
+typedef struct SecurityCredentialCall {
+  char *package_str;
+  char *username_str;
+  char *password_str;
+  char *domain_str;
+  SecurityCredentials *credentials;
+} SecurityCredentialCall;
+
+// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+// authGSSClientInit
+// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+static void _authSSPIAquire(Worker *worker) {
+  // Status of operation
+  SECURITY_STATUS status;
+
+  // Unpack data
+  SecurityCredentialCall *call = (SecurityCredentialCall *)worker->parameters;
+
+  // // Unwrap the credentials
+  // SecurityCredentials *security_credentials = (SecurityCredentials *)call->credentials;
+  SecurityCredentials *security_credentials = new SecurityCredentials();
+
+  // If we have domain string
+  if(call->domain_str != NULL) {
+    security_credentials->m_Identity.Domain = USTR(_tcsdup(call->domain_str));
+    security_credentials->m_Identity.DomainLength = (unsigned long)_tcslen(call->domain_str);
+  } else {
+    security_credentials->m_Identity.Domain = NULL;
+    security_credentials->m_Identity.DomainLength = 0;
+  }
+
+  // Set up the user
+  security_credentials->m_Identity.User = USTR(_tcsdup(call->username_str));
+  security_credentials->m_Identity.UserLength = (unsigned long)_tcslen(call->username_str);
+
+  // If we have a password string
+  if(call->password_str != NULL) {
+    // Set up the password
+    security_credentials->m_Identity.Password = USTR(_tcsdup(call->password_str));
+    security_credentials->m_Identity.PasswordLength = (unsigned long)_tcslen(call->password_str);
+  }
+
+  #ifdef _UNICODE
+    security_credentials->m_Identity.Flags = SEC_WINNT_AUTH_IDENTITY_UNICODE;
+  #else
+    security_credentials->m_Identity.Flags = SEC_WINNT_AUTH_IDENTITY_ANSI;
+  #endif
+
+  // Attempt to acquire credentials
+  status = _sspi_AcquireCredentialsHandle(
+    NULL,
+    call->package_str,
+    SECPKG_CRED_OUTBOUND,
+    NULL,
+    call->password_str != NULL ? &security_credentials->m_Identity : NULL,
+    NULL, NULL,
+    &security_credentials->m_Credentials,
+    &security_credentials->Expiration
+  );
+
+  // We have an error
+  if(status != SEC_E_OK) {
+    worker->error = TRUE;
+    worker->error_code = status;
+    worker->error_message = DisplaySECError(status);
+  } else {
+    worker->return_code = status;
+    worker->return_value = security_credentials;
+  }
+
+  // Free up parameter structure
+  if(call->package_str != NULL) free(call->package_str);
+  if(call->domain_str != NULL) free(call->domain_str);
+  if(call->password_str != NULL) free(call->password_str);
+  if(call->username_str != NULL) free(call->username_str);
+  free(call);
+}
+
+static Local<Value> _map_authSSPIAquire(Worker *worker) {
+  return Nan::Null();
+}
+
+NAN_METHOD(SecurityCredentials::Aquire) {
+  char *package_str = NULL, *username_str = NULL, *password_str = NULL, *domain_str = NULL;
+  // Unpack the variables
+  if(info.Length() != 2 && info.Length() != 3 && info.Length() != 4 && info.Length() != 5)
+    return Nan::ThrowError("Aquire must be called with either [package:string, username:string, [password:string, domain:string], callback:function]");
+
+  if(!info[0]->IsString())
+    return Nan::ThrowError("Aquire must be called with either [package:string, username:string, [password:string, domain:string], callback:function]");
+
+  if(!info[1]->IsString())
+    return Nan::ThrowError("Aquire must be called with either [package:string, username:string, [password:string, domain:string], callback:function]");
+
+  if(info.Length() == 3 && (!info[2]->IsString() && !info[2]->IsFunction()))
+    return Nan::ThrowError("Aquire must be called with either [package:string, username:string, [password:string, domain:string], callback:function]");
+
+  if(info.Length() == 4 && (!info[3]->IsString() && !info[3]->IsUndefined() && !info[3]->IsNull()) && !info[3]->IsFunction())
+    return Nan::ThrowError("Aquire must be called with either [package:string, username:string, [password:string, domain:string], callback:function]");
+
+  if(info.Length() == 5 && !info[4]->IsFunction())
+    return Nan::ThrowError("Aquire must be called with either [package:string, username:string, [password:string, domain:string], callback:function]");
+
+  Local<Function> callbackHandle;
+
+  // Figure out which parameter is the callback
+  if(info.Length() == 5) {
+    callbackHandle = Local<Function>::Cast(info[4]);
+  } else if(info.Length() == 4) {
+    callbackHandle = Local<Function>::Cast(info[3]);
+  } else if(info.Length() == 3) {
+    callbackHandle = Local<Function>::Cast(info[2]);
+  }
+
+  // Unpack the package
+  Local<String> package = info[0]->ToString();
+  package_str = (char *)calloc(package->Utf8Length() + 1, sizeof(char));
+  package->WriteUtf8(package_str);
+
+  // Unpack the user name
+  Local<String> username = info[1]->ToString();
+  username_str = (char *)calloc(username->Utf8Length() + 1, sizeof(char));
+  username->WriteUtf8(username_str);
+
+  // If we have a password
+  if(info.Length() == 3 || info.Length() == 4 || info.Length() == 5) {
+    Local<String> password = info[2]->ToString();
+    password_str = (char *)calloc(password->Utf8Length() + 1, sizeof(char));
+    password->WriteUtf8(password_str);
+  }
+
+  // If we have a domain
+  if((info.Length() == 4 || info.Length() == 5) && info[3]->IsString()) {
+    Local<String> domain = info[3]->ToString();
+    domain_str = (char *)calloc(domain->Utf8Length() + 1, sizeof(char));
+    domain->WriteUtf8(domain_str);
+  }
+
+  // Allocate call structure
+  SecurityCredentialCall *call = (SecurityCredentialCall *)calloc(1, sizeof(SecurityCredentialCall));
+  call->domain_str = domain_str;
+  call->package_str = package_str;
+  call->password_str = password_str;
+  call->username_str = username_str;
+
+  // Unpack the callback
+  Nan::Callback *callback = new Nan::Callback(callbackHandle);
+
+  // Let's allocate some space
+  Worker *worker = new Worker();
+  worker->error = false;
+  worker->request.data = worker;
+  worker->callback = callback;
+  worker->parameters = call;
+  worker->execute = _authSSPIAquire;
+  worker->mapper = _map_authSSPIAquire;
+
+  // Schedule the worker with lib_uv
+  uv_queue_work(uv_default_loop(), &worker->request, SecurityCredentials::Process, (uv_after_work_cb)SecurityCredentials::After);
+
+  // Return no value as it's callback based
+  info.GetReturnValue().Set(Nan::Undefined());
+}
+
+void SecurityCredentials::Initialize(Nan::ADDON_REGISTER_FUNCTION_ARGS_TYPE target) {
+  // Grab the scope of the call from Node
+  Nan::HandleScope scope;
+
+  // Define a new function template
+  Local<FunctionTemplate> t = Nan::New<FunctionTemplate>(New);
+  t->InstanceTemplate()->SetInternalFieldCount(1);
+  t->SetClassName(Nan::New<String>("SecurityCredentials").ToLocalChecked());
+
+  // Class methods
+  Nan::SetMethod(t, "aquire", Aquire);
+
+  // Set persistent
+  constructor_template.Reset(t);
+
+  // Set the symbol
+  target->ForceSet(Nan::New<String>("SecurityCredentials").ToLocalChecked(), t->GetFunction());
+
+  // Attempt to load the security.dll library
+  load_library();
+}
+
+static LPSTR DisplaySECError(DWORD ErrCode) {
+  LPSTR pszName = NULL; // WinError.h
+
+  switch(ErrCode) {
+    case SEC_E_BUFFER_TOO_SMALL:
+      pszName = "SEC_E_BUFFER_TOO_SMALL - The message buffer is too small. Used with the Digest SSP.";
+      break;
+
+    case SEC_E_CRYPTO_SYSTEM_INVALID:
+      pszName = "SEC_E_CRYPTO_SYSTEM_INVALID - The cipher chosen for the security context is not supported. Used with the Digest SSP.";
+      break;
+    case SEC_E_INCOMPLETE_MESSAGE:
+      pszName = "SEC_E_INCOMPLETE_MESSAGE - The data in the input buffer is incomplete. The application needs to read more data from the server and call DecryptMessage (General) again.";
+      break;
+
+    case SEC_E_INVALID_HANDLE:
+      pszName = "SEC_E_INVALID_HANDLE - A context handle that is not valid was specified in the phContext parameter. Used with the Digest and Schannel SSPs.";
+      break;
+
+    case SEC_E_INVALID_TOKEN:
+      pszName = "SEC_E_INVALID_TOKEN - The buffers are of the wrong type or no buffer of type SECBUFFER_DATA was found. Used with the Schannel SSP.";
+      break;
+
+    case SEC_E_MESSAGE_ALTERED:
+      pszName = "SEC_E_MESSAGE_ALTERED - The message has been altered. Used with the Digest and Schannel SSPs.";
+      break;
+
+    case SEC_E_OUT_OF_SEQUENCE:
+      pszName = "SEC_E_OUT_OF_SEQUENCE - The message was not received in the correct sequence.";
+      break;
+
+    case SEC_E_QOP_NOT_SUPPORTED:
+      pszName = "SEC_E_QOP_NOT_SUPPORTED - Neither confidentiality nor integrity are supported by the security context. Used with the Digest SSP.";
+      break;
+
+    case SEC_I_CONTEXT_EXPIRED:
+      pszName = "SEC_I_CONTEXT_EXPIRED - The message sender has finished using the connection and has initiated a shutdown.";
+      break;
+
+    case SEC_I_RENEGOTIATE:
+      pszName = "SEC_I_RENEGOTIATE - The remote party requires a new handshake sequence or the application has just initiated a shutdown.";
+      break;
+
+    case SEC_E_ENCRYPT_FAILURE:
+      pszName = "SEC_E_ENCRYPT_FAILURE - The specified data could not be encrypted.";
+      break;
+
+    case SEC_E_DECRYPT_FAILURE:
+      pszName = "SEC_E_DECRYPT_FAILURE - The specified data could not be decrypted.";
+      break;
+    case -1:
+      pszName = "Failed to load security.dll library";
+      break;
+
+  }
+
+  return pszName;
+}
+
+// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+// UV Lib callbacks
+// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+void SecurityCredentials::Process(uv_work_t* work_req) {
+  // Grab the worker
+  Worker *worker = static_cast<Worker*>(work_req->data);
+  // Execute the worker code
+  worker->execute(worker);
+}
+
+void SecurityCredentials::After(uv_work_t* work_req) {
+  // Grab the scope of the call from Node
+  Nan::HandleScope scope;
+
+  // Get the worker reference
+  Worker *worker = static_cast<Worker*>(work_req->data);
+
+  // If we have an error
+  if(worker->error) {
+    Local<Value> err = v8::Exception::Error(Nan::New<String>(worker->error_message).ToLocalChecked());
+    Local<Object> obj = err->ToObject();
+    obj->Set(Nan::New<String>("code").ToLocalChecked(), Nan::New<Int32>(worker->error_code));
+    Local<Value> info[2] = { err, Nan::Null() };
+    // Execute the error
+    Nan::TryCatch try_catch;
+
+    // Call the callback
+    worker->callback->Call(ARRAY_SIZE(info), info);
+
+    // If we have an exception handle it as a fatalexception
+    if (try_catch.HasCaught()) {
+      Nan::FatalException(try_catch);
+    }
+  } else {
+    SecurityCredentials *return_value = (SecurityCredentials *)worker->return_value;
+    // Create a new instance
+    Local<Object> result = Nan::New(constructor_template)->GetFunction()->NewInstance();
+    // Unwrap the credentials
+    SecurityCredentials *security_credentials = Nan::ObjectWrap::Unwrap<SecurityCredentials>(result);
+    // Set the values
+    security_credentials->m_Identity = return_value->m_Identity;
+    security_credentials->m_Credentials = return_value->m_Credentials;
+    security_credentials->Expiration = return_value->Expiration;
+    // Set up the callback with a null first
+    Local<Value> info[2] = { Nan::Null(), result};
+    // Wrap the callback function call in a TryCatch so that we can call
+    // node's FatalException afterwards. This makes it possible to catch
+    // the exception from JavaScript land using the
+    // process.on('uncaughtException') event.
+    Nan::TryCatch try_catch;
+
+    // Call the callback
+    worker->callback->Call(ARRAY_SIZE(info), info);
+
+    // If we have an exception handle it as a fatalexception
+    if (try_catch.HasCaught()) {
+      Nan::FatalException(try_catch);
+    }
+  }
+
+  // Clean up the memory
+  delete worker->callback;
+  delete worker;
+}
+

http://git-wip-us.apache.org/repos/asf/couchdb-nmo/blob/753f1767/node_modules/couchbulkimporter/node_modules/mongodb/node_modules/mongodb-core/node_modules/kerberos/lib/win32/wrappers/security_credentials.h
----------------------------------------------------------------------
diff --git a/node_modules/couchbulkimporter/node_modules/mongodb/node_modules/mongodb-core/node_modules/kerberos/lib/win32/wrappers/security_credentials.h b/node_modules/couchbulkimporter/node_modules/mongodb/node_modules/mongodb-core/node_modules/kerberos/lib/win32/wrappers/security_credentials.h
new file mode 100644
index 0000000..71751a0
--- /dev/null
+++ b/node_modules/couchbulkimporter/node_modules/mongodb/node_modules/mongodb-core/node_modules/kerberos/lib/win32/wrappers/security_credentials.h
@@ -0,0 +1,68 @@
+#ifndef SECURITY_CREDENTIALS_H
+#define SECURITY_CREDENTIALS_H
+
+#include <node.h>
+#include <node_object_wrap.h>
+#include <v8.h>
+
+#define SECURITY_WIN32 1
+
+#include <WinSock2.h>
+#include <windows.h>
+#include <sspi.h>
+#include <tchar.h>
+#include <nan.h>
+#include "../worker.h"
+#include <uv.h>
+
+extern "C" {
+  #include "../kerberos_sspi.h"
+}
+
+// SEC_WINNT_AUTH_IDENTITY makes it unusually hard
+// to compile for both Unicode and ansi, so I use this macro:
+#ifdef _UNICODE
+#define USTR(str) (str)
+#else
+#define USTR(str) ((unsigned char*)(str))
+#endif
+
+using namespace v8;
+using namespace node;
+
+class SecurityCredentials : public Nan::ObjectWrap {
+  public:
+    SecurityCredentials();
+    ~SecurityCredentials();
+
+    // Pointer to context object
+    SEC_WINNT_AUTH_IDENTITY m_Identity;
+    // credentials
+    CredHandle m_Credentials;
+    // Expiry time for ticket
+    TimeStamp Expiration;
+
+    // Has instance check
+    static inline bool HasInstance(Local<Value> val) {
+      if (!val->IsObject()) return false;
+      Local<Object> obj = val->ToObject();
+      return Nan::New(constructor_template)->HasInstance(obj);
+    };
+
+    // Functions available from V8
+    static void Initialize(Nan::ADDON_REGISTER_FUNCTION_ARGS_TYPE target);
+    static NAN_METHOD(Aquire);
+
+    // Constructor used for creating new Long objects from C++
+    static Nan::Persistent<FunctionTemplate> constructor_template;
+
+  private:
+    // Create a new instance
+    static NAN_METHOD(New);
+    // Handles the uv calls
+    static void Process(uv_work_t* work_req);
+    // Called after work is done
+    static void After(uv_work_t* work_req);
+};
+
+#endif
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/couchdb-nmo/blob/753f1767/node_modules/couchbulkimporter/node_modules/mongodb/node_modules/mongodb-core/node_modules/kerberos/lib/win32/wrappers/security_credentials.js
----------------------------------------------------------------------
diff --git a/node_modules/couchbulkimporter/node_modules/mongodb/node_modules/mongodb-core/node_modules/kerberos/lib/win32/wrappers/security_credentials.js b/node_modules/couchbulkimporter/node_modules/mongodb/node_modules/mongodb-core/node_modules/kerberos/lib/win32/wrappers/security_credentials.js
new file mode 100644
index 0000000..4215c92
--- /dev/null
+++ b/node_modules/couchbulkimporter/node_modules/mongodb/node_modules/mongodb-core/node_modules/kerberos/lib/win32/wrappers/security_credentials.js
@@ -0,0 +1,22 @@
+var SecurityCredentialsNative = require('../../../build/Release/kerberos').SecurityCredentials;
+
+// Add simple kebros helper
+SecurityCredentialsNative.aquire_kerberos = function(username, password, domain, callback) {
+  if(typeof password == 'function') {
+    callback = password;
+    password = null;
+  } else if(typeof domain == 'function') {
+    callback = domain;
+    domain = null;
+  }
+
+  // We are going to use the async version
+  if(typeof callback == 'function') {
+    return SecurityCredentialsNative.aquire('Kerberos', username, password, domain, callback);
+  } else {
+    return SecurityCredentialsNative.aquireSync('Kerberos', username, password, domain);
+  }
+}
+
+// Export the modified class
+exports.SecurityCredentials = SecurityCredentialsNative;
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/couchdb-nmo/blob/753f1767/node_modules/couchbulkimporter/node_modules/mongodb/node_modules/mongodb-core/node_modules/kerberos/lib/worker.cc
----------------------------------------------------------------------
diff --git a/node_modules/couchbulkimporter/node_modules/mongodb/node_modules/mongodb-core/node_modules/kerberos/lib/worker.cc b/node_modules/couchbulkimporter/node_modules/mongodb/node_modules/mongodb-core/node_modules/kerberos/lib/worker.cc
new file mode 100644
index 0000000..e7a472f
--- /dev/null
+++ b/node_modules/couchbulkimporter/node_modules/mongodb/node_modules/mongodb-core/node_modules/kerberos/lib/worker.cc
@@ -0,0 +1,7 @@
+#include "worker.h"
+
+Worker::Worker() {
+}
+
+Worker::~Worker() {  
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/couchdb-nmo/blob/753f1767/node_modules/couchbulkimporter/node_modules/mongodb/node_modules/mongodb-core/node_modules/kerberos/lib/worker.h
----------------------------------------------------------------------
diff --git a/node_modules/couchbulkimporter/node_modules/mongodb/node_modules/mongodb-core/node_modules/kerberos/lib/worker.h b/node_modules/couchbulkimporter/node_modules/mongodb/node_modules/mongodb-core/node_modules/kerberos/lib/worker.h
new file mode 100644
index 0000000..1b0dced
--- /dev/null
+++ b/node_modules/couchbulkimporter/node_modules/mongodb/node_modules/mongodb-core/node_modules/kerberos/lib/worker.h
@@ -0,0 +1,38 @@
+#ifndef WORKER_H_
+#define WORKER_H_
+
+#include <node.h>
+#include <node_object_wrap.h>
+#include <nan.h>
+#include <v8.h>
+
+using namespace node;
+using namespace v8;
+
+class Worker {
+  public:
+    Worker();
+    virtual ~Worker();
+
+    // libuv's request struct.
+    uv_work_t request;
+    // Callback
+    Nan::Callback *callback;
+    // Parameters
+    void *parameters;
+    // Results
+    void *return_value;
+    // Did we raise an error
+    bool error;
+    // The error message
+    char *error_message;
+    // Error code if not message
+    int error_code;
+    // Any return code
+    int return_code;
+    // Method we are going to fire
+    void (*execute)(Worker *worker);
+    Local<Value> (*mapper)(Worker *worker);
+};
+
+#endif  // WORKER_H_

http://git-wip-us.apache.org/repos/asf/couchdb-nmo/blob/753f1767/node_modules/couchbulkimporter/node_modules/mongodb/node_modules/mongodb-core/node_modules/kerberos/node_modules/nan/.dntrc
----------------------------------------------------------------------
diff --git a/node_modules/couchbulkimporter/node_modules/mongodb/node_modules/mongodb-core/node_modules/kerberos/node_modules/nan/.dntrc b/node_modules/couchbulkimporter/node_modules/mongodb/node_modules/mongodb-core/node_modules/kerberos/node_modules/nan/.dntrc
new file mode 100644
index 0000000..47971da
--- /dev/null
+++ b/node_modules/couchbulkimporter/node_modules/mongodb/node_modules/mongodb-core/node_modules/kerberos/node_modules/nan/.dntrc
@@ -0,0 +1,30 @@
+## DNT config file
+## see https://github.com/rvagg/dnt
+
+NODE_VERSIONS="\
+  master   \
+  v0.11.13 \
+  v0.10.30 \
+  v0.10.29 \
+  v0.10.28 \
+  v0.10.26 \
+  v0.10.25 \
+  v0.10.24 \
+  v0.10.23 \
+  v0.10.22 \
+  v0.10.21 \
+  v0.10.20 \
+  v0.10.19 \
+  v0.8.28  \
+  v0.8.27  \
+  v0.8.26  \
+  v0.8.24  \
+"
+OUTPUT_PREFIX="nan-"
+TEST_CMD="                                                                        \
+  cd /dnt/ &&                                                                     \
+  npm install &&                                                                  \
+  node_modules/.bin/node-gyp --nodedir /usr/src/node/ rebuild --directory test && \
+  node_modules/.bin/tap --gc test/js/*-test.js                                    \
+"
+

http://git-wip-us.apache.org/repos/asf/couchdb-nmo/blob/753f1767/node_modules/couchbulkimporter/node_modules/mongodb/node_modules/mongodb-core/node_modules/kerberos/node_modules/nan/CHANGELOG.md
----------------------------------------------------------------------
diff --git a/node_modules/couchbulkimporter/node_modules/mongodb/node_modules/mongodb-core/node_modules/kerberos/node_modules/nan/CHANGELOG.md b/node_modules/couchbulkimporter/node_modules/mongodb/node_modules/mongodb-core/node_modules/kerberos/node_modules/nan/CHANGELOG.md
new file mode 100644
index 0000000..457e7c4
--- /dev/null
+++ b/node_modules/couchbulkimporter/node_modules/mongodb/node_modules/mongodb-core/node_modules/kerberos/node_modules/nan/CHANGELOG.md
@@ -0,0 +1,374 @@
+# NAN ChangeLog
+
+**Version 2.0.9: current Node 4.0.0, Node 12: 0.12.7, Node 10: 0.10.40, iojs: 3.2.0**
+
+### 2.0.9 Sep 8 2015
+
+  - Bugfix: EscapableHandleScope in Nan::NewBuffer for Node 0.8 and 0.10 b1654d7
+
+### 2.0.8 Aug 28 2015
+
+  - Work around duplicate linking bug in clang 11902da
+
+### 2.0.7 Aug 26 2015
+
+  - Build: Repackage
+
+### 2.0.6 Aug 26 2015
+
+  - Bugfix: Properly handle null callback in FunctionTemplate factory 6e99cb1
+  - Bugfix: Remove unused static std::map instances 525bddc
+  - Bugfix: Make better use of maybe versions of APIs bfba85b
+  - Bugfix: Fix shadowing issues with handle in ObjectWrap 0a9072d
+
+### 2.0.5 Aug 10 2015
+
+  - Bugfix: Reimplement weak callback in ObjectWrap 98d38c1
+  - Bugfix: Make sure callback classes are not assignable, copyable or movable 81f9b1d
+
+### 2.0.4 Aug 6 2015
+
+  - Build: Repackage
+
+### 2.0.3 Aug 6 2015
+
+  - Bugfix: Don't use clang++ / g++ syntax extension. 231450e
+
+### 2.0.2 Aug 6 2015
+
+  - Build: Repackage
+
+### 2.0.1 Aug 6 2015
+
+  - Bugfix: Add workaround for missing REPLACE_INVALID_UTF8 60d6687
+  - Bugfix: Reimplement ObjectWrap from scratch to prevent memory leaks 6484601
+  - Bugfix: Fix Persistent leak in FunctionCallbackInfo and PropertyCallbackInfo 641ef5f
+  - Bugfix: Add missing overload for Nan::NewInstance that takes argc/argv 29450ed
+
+### 2.0.0 Jul 31 2015
+
+  - Change: Renamed identifiers with leading underscores	b5932b4
+  - Change: Replaced NanObjectWrapHandle with class NanObjectWrap	464f1e1
+  - Change: Replace NanScope and NanEscpableScope macros with classes	47751c4
+  - Change: Rename NanNewBufferHandle to NanNewBuffer	6745f99
+  - Change: Rename NanBufferUse to NanNewBuffer	3e8b0a5
+  - Change: Rename NanNewBuffer to NanCopyBuffer	d6af78d
+  - Change: Remove Nan prefix from all names	72d1f67
+  - Change: Update Buffer API for new upstream changes	d5d3291
+  - Change: Rename Scope and EscapableScope to HandleScope and EscapableHandleScope	21a7a6a
+  - Change: Get rid of Handles	 e6c0daf
+  - Feature: Support io.js 3 with V8 4.4
+  - Feature: Introduce NanPersistent	7fed696
+  - Feature: Introduce NanGlobal	4408da1
+  - Feature: Added NanTryCatch	10f1ca4
+  - Feature: Update for V8 v4.3	4b6404a
+  - Feature: Introduce NanNewOneByteString	c543d32
+  - Feature: Introduce namespace Nan	67ed1b1
+  - Removal: Remove NanLocker and NanUnlocker	dd6e401
+  - Removal: Remove string converters, except NanUtf8String, which now follows the node implementation b5d00a9
+  - Removal: Remove NanReturn* macros	d90a25c
+  - Removal: Remove HasInstance	e8f84fe
+
+
+### 1.9.0 Jul 31 2015
+
+  - Feature: Added `NanFatalException` 81d4a2c
+  - Feature: Added more error types 4265f06
+  - Feature: Added dereference and function call operators to NanCallback c4b2ed0
+  - Feature: Added indexed GetFromPersistent and SaveToPersistent edd510c
+  - Feature: Added more overloads of SaveToPersistent and GetFromPersistent 8b1cef6
+  - Feature: Added NanErrnoException dd87d9e
+  - Correctness: Prevent assign, copy, and move for classes that do not support it 1f55c59, 4b808cb, c96d9b2, fba4a29, 3357130
+  - Deprecation: Deprecate `NanGetPointerSafe` and `NanSetPointerSafe` 81d4a2c
+  - Deprecation: Deprecate `NanBooleanOptionValue` and `NanUInt32OptionValue` 0ad254b
+
+### 1.8.4 Apr 26 2015
+
+  - Build: Repackage
+
+### 1.8.3 Apr 26 2015
+
+  - Bugfix: Include missing header 1af8648
+
+### 1.8.2 Apr 23 2015
+
+  - Build: Repackage
+
+### 1.8.1 Apr 23 2015
+
+  - Bugfix: NanObjectWrapHandle should take a pointer 155f1d3
+
+### 1.8.0 Apr 23 2015
+
+  - Feature: Allow primitives with NanReturnValue 2e4475e
+  - Feature: Added comparison operators to NanCallback 55b075e
+  - Feature: Backport thread local storage 15bb7fa
+  - Removal: Remove support for signatures with arguments 8a2069d
+  - Correcteness: Replaced NanObjectWrapHandle macro with function 0bc6d59
+
+### 1.7.0 Feb 28 2015
+
+  - Feature: Made NanCallback::Call accept optional target 8d54da7
+  - Feature: Support atom-shell 0.21 0b7f1bb
+
+### 1.6.2 Feb 6 2015
+
+  - Bugfix: NanEncode: fix argument type for node::Encode on io.js 2be8639
+
+### 1.6.1 Jan 23 2015
+
+  - Build: version bump
+
+### 1.5.3 Jan 23 2015
+
+  - Build: repackage
+
+### 1.6.0 Jan 23 2015
+
+ - Deprecated `NanNewContextHandle` in favor of `NanNew<Context>` 49259af
+ - Support utility functions moved in newer v8 versions (Node 0.11.15, io.js 1.0) a0aa179
+ - Added `NanEncode`, `NanDecodeBytes` and `NanDecodeWrite` 75e6fb9
+
+### 1.5.2 Jan 23 2015
+
+  - Bugfix: Fix non-inline definition build error with clang++ 21d96a1, 60fadd4
+  - Bugfix: Readded missing String constructors 18d828f
+  - Bugfix: Add overload handling NanNew<FunctionTemplate>(..) 5ef813b
+  - Bugfix: Fix uv_work_cb versioning 997e4ae
+  - Bugfix: Add function factory and test 4eca89c
+  - Bugfix: Add object template factory and test cdcb951
+  - Correctness: Lifted an io.js related typedef c9490be
+  - Correctness: Make explicit downcasts of String lengths 00074e6
+  - Windows: Limit the scope of disabled warning C4530 83d7deb
+
+### 1.5.1 Jan 15 2015
+
+  - Build: version bump
+
+### 1.4.3 Jan 15 2015
+
+  - Build: version bump
+
+### 1.4.2 Jan 15 2015
+
+  - Feature: Support io.js 0dbc5e8
+
+### 1.5.0 Jan 14 2015
+
+ - Feature: Support io.js b003843
+ - Correctness: Improved NanNew internals 9cd4f6a
+ - Feature: Implement progress to NanAsyncWorker 8d6a160
+
+### 1.4.1 Nov 8 2014
+
+ - Bugfix: Handle DEBUG definition correctly
+ - Bugfix: Accept int as Boolean
+
+### 1.4.0 Nov 1 2014
+
+ - Feature: Added NAN_GC_CALLBACK 6a5c245
+ - Performance: Removed unnecessary local handle creation 18a7243, 41fe2f8
+ - Correctness: Added constness to references in NanHasInstance 02c61cd
+ - Warnings: Fixed spurious warnings from -Wundef and -Wshadow, 541b122, 99d8cb6
+ - Windoze: Shut Visual Studio up when compiling 8d558c1
+ - License: Switch to plain MIT from custom hacked MIT license 11de983
+ - Build: Added test target to Makefile e232e46
+ - Performance: Removed superfluous scope in NanAsyncWorker f4b7821
+ - Sugar/Feature: Added NanReturnThis() and NanReturnHolder() shorthands 237a5ff, d697208
+ - Feature: Added suitable overload of NanNew for v8::Integer::NewFromUnsigned b27b450
+
+### 1.3.0 Aug 2 2014
+
+ - Added NanNew<v8::String, std::string>(std::string)
+ - Added NanNew<v8::String, std::string&>(std::string&)
+ - Added NanAsciiString helper class
+ - Added NanUtf8String helper class
+ - Added NanUcs2String helper class
+ - Deprecated NanRawString()
+ - Deprecated NanCString()
+ - Added NanGetIsolateData(v8::Isolate *isolate)
+ - Added NanMakeCallback(v8::Handle<v8::Object> target, v8::Handle<v8::Function> func, int argc, v8::Handle<v8::Value>* argv)
+ - Added NanMakeCallback(v8::Handle<v8::Object> target, v8::Handle<v8::String> symbol, int argc, v8::Handle<v8::Value>* argv)
+ - Added NanMakeCallback(v8::Handle<v8::Object> target, const char* method, int argc, v8::Handle<v8::Value>* argv)
+ - Added NanSetTemplate(v8::Handle<v8::Template> templ, v8::Handle<v8::String> name , v8::Handle<v8::Data> value, v8::PropertyAttribute attributes)
+ - Added NanSetPrototypeTemplate(v8::Local<v8::FunctionTemplate> templ, v8::Handle<v8::String> name, v8::Handle<v8::Data> value, v8::PropertyAttribute attributes)
+ - Added NanSetInstanceTemplate(v8::Local<v8::FunctionTemplate> templ, const char *name, v8::Handle<v8::Data> value)
+ - Added NanSetInstanceTemplate(v8::Local<v8::FunctionTemplate> templ, v8::Handle<v8::String> name, v8::Handle<v8::Data> value, v8::PropertyAttribute attributes)
+
+### 1.2.0 Jun 5 2014
+
+ - Add NanSetPrototypeTemplate
+ - Changed NAN_WEAK_CALLBACK internals, switched _NanWeakCallbackData to class,
+     introduced _NanWeakCallbackDispatcher
+ - Removed -Wno-unused-local-typedefs from test builds
+ - Made test builds Windows compatible ('Sleep()')
+
+### 1.1.2 May 28 2014
+
+ - Release to fix more stuff-ups in 1.1.1
+
+### 1.1.1 May 28 2014
+
+ - Release to fix version mismatch in nan.h and lack of changelog entry for 1.1.0
+
+### 1.1.0 May 25 2014
+
+ - Remove nan_isolate, use v8::Isolate::GetCurrent() internally instead
+ - Additional explicit overloads for NanNew(): (char*,int), (uint8_t*[,int]),
+     (uint16_t*[,int), double, int, unsigned int, bool, v8::String::ExternalStringResource*,
+     v8::String::ExternalAsciiStringResource*
+ - Deprecate NanSymbol()
+ - Added SetErrorMessage() and ErrorMessage() to NanAsyncWorker
+
+### 1.0.0 May 4 2014
+
+ - Heavy API changes for V8 3.25 / Node 0.11.13
+ - Use cpplint.py
+ - Removed NanInitPersistent
+ - Removed NanPersistentToLocal
+ - Removed NanFromV8String
+ - Removed NanMakeWeak
+ - Removed NanNewLocal
+ - Removed NAN_WEAK_CALLBACK_OBJECT
+ - Removed NAN_WEAK_CALLBACK_DATA
+ - Introduce NanNew, replaces NanNewLocal, NanPersistentToLocal, adds many overloaded typed versions
+ - Introduce NanUndefined, NanNull, NanTrue and NanFalse
+ - Introduce NanEscapableScope and NanEscapeScope
+ - Introduce NanMakeWeakPersistent (requires a special callback to work on both old and new node)
+ - Introduce NanMakeCallback for node::MakeCallback
+ - Introduce NanSetTemplate
+ - Introduce NanGetCurrentContext
+ - Introduce NanCompileScript and NanRunScript
+ - Introduce NanAdjustExternalMemory
+ - Introduce NanAddGCEpilogueCallback, NanAddGCPrologueCallback, NanRemoveGCEpilogueCallback, NanRemoveGCPrologueCallback
+ - Introduce NanGetHeapStatistics
+ - Rename NanAsyncWorker#SavePersistent() to SaveToPersistent()
+
+### 0.8.0 Jan 9 2014
+
+ - NanDispose -> NanDisposePersistent, deprecate NanDispose
+ - Extract _NAN_*_RETURN_TYPE, pull up NAN_*()
+
+### 0.7.1 Jan 9 2014
+
+ - Fixes to work against debug builds of Node
+ - Safer NanPersistentToLocal (avoid reinterpret_cast)
+ - Speed up common NanRawString case by only extracting flattened string when necessary
+
+### 0.7.0 Dec 17 2013
+
+ - New no-arg form of NanCallback() constructor.
+ - NanCallback#Call takes Handle rather than Local
+ - Removed deprecated NanCallback#Run method, use NanCallback#Call instead
+ - Split off _NAN_*_ARGS_TYPE from _NAN_*_ARGS
+ - Restore (unofficial) Node 0.6 compatibility at NanCallback#Call()
+ - Introduce NanRawString() for char* (or appropriate void*) from v8::String
+     (replacement for NanFromV8String)
+ - Introduce NanCString() for null-terminated char* from v8::String
+
+### 0.6.0 Nov 21 2013
+
+ - Introduce NanNewLocal<T>(v8::Handle<T> value) for use in place of
+     v8::Local<T>::New(...) since v8 started requiring isolate in Node 0.11.9
+
+### 0.5.2 Nov 16 2013
+
+ - Convert SavePersistent and GetFromPersistent in NanAsyncWorker from protected and public
+
+### 0.5.1 Nov 12 2013
+
+ - Use node::MakeCallback() instead of direct v8::Function::Call()
+
+### 0.5.0 Nov 11 2013
+
+ - Added @TooTallNate as collaborator
+ - New, much simpler, "include_dirs" for binding.gyp
+ - Added full range of NAN_INDEX_* macros to match NAN_PROPERTY_* macros
+
+### 0.4.4 Nov 2 2013
+
+ - Isolate argument from v8::Persistent::MakeWeak removed for 0.11.8+
+
+### 0.4.3 Nov 2 2013
+
+ - Include node_object_wrap.h, removed from node.h for Node 0.11.8.
+
+### 0.4.2 Nov 2 2013
+
+ - Handle deprecation of v8::Persistent::Dispose(v8::Isolate* isolate)) for
+     Node 0.11.8 release.
+
+### 0.4.1 Sep 16 2013
+
+ - Added explicit `#include <uv.h>` as it was removed from node.h for v0.11.8
+
+### 0.4.0 Sep 2 2013
+
+ - Added NAN_INLINE and NAN_DEPRECATED and made use of them
+ - Added NanError, NanTypeError and NanRangeError
+ - Cleaned up code
+
+### 0.3.2 Aug 30 2013
+
+ - Fix missing scope declaration in GetFromPersistent() and SaveToPersistent
+     in NanAsyncWorker
+
+### 0.3.1 Aug 20 2013
+
+ - fix "not all control paths return a value" compile warning on some platforms
+
+### 0.3.0 Aug 19 2013
+
+ - Made NAN work with NPM
+ - Lots of fixes to NanFromV8String, pulling in features from new Node core
+ - Changed node::encoding to Nan::Encoding in NanFromV8String to unify the API
+ - Added optional error number argument for NanThrowError()
+ - Added NanInitPersistent()
+ - Added NanReturnNull() and NanReturnEmptyString()
+ - Added NanLocker and NanUnlocker
+ - Added missing scopes
+ - Made sure to clear disposed Persistent handles
+ - Changed NanAsyncWorker to allocate error messages on the heap
+ - Changed NanThrowError(Local<Value>) to NanThrowError(Handle<Value>)
+ - Fixed leak in NanAsyncWorker when errmsg is used
+
+### 0.2.2 Aug 5 2013
+
+ - Fixed usage of undefined variable with node::BASE64 in NanFromV8String()
+
+### 0.2.1 Aug 5 2013
+
+ - Fixed 0.8 breakage, node::BUFFER encoding type not available in 0.8 for
+     NanFromV8String()
+
+### 0.2.0 Aug 5 2013
+
+ - Added NAN_PROPERTY_GETTER, NAN_PROPERTY_SETTER, NAN_PROPERTY_ENUMERATOR,
+     NAN_PROPERTY_DELETER, NAN_PROPERTY_QUERY
+ - Extracted _NAN_METHOD_ARGS, _NAN_GETTER_ARGS, _NAN_SETTER_ARGS,
+     _NAN_PROPERTY_GETTER_ARGS, _NAN_PROPERTY_SETTER_ARGS,
+     _NAN_PROPERTY_ENUMERATOR_ARGS, _NAN_PROPERTY_DELETER_ARGS,
+     _NAN_PROPERTY_QUERY_ARGS
+ - Added NanGetInternalFieldPointer, NanSetInternalFieldPointer
+ - Added NAN_WEAK_CALLBACK, NAN_WEAK_CALLBACK_OBJECT,
+     NAN_WEAK_CALLBACK_DATA, NanMakeWeak
+ - Renamed THROW_ERROR to _NAN_THROW_ERROR
+ - Added NanNewBufferHandle(char*, size_t, node::smalloc::FreeCallback, void*)
+ - Added NanBufferUse(char*, uint32_t)
+ - Added NanNewContextHandle(v8::ExtensionConfiguration*,
+       v8::Handle<v8::ObjectTemplate>, v8::Handle<v8::Value>)
+ - Fixed broken NanCallback#GetFunction()
+ - Added optional encoding and size arguments to NanFromV8String()
+ - Added NanGetPointerSafe() and NanSetPointerSafe()
+ - Added initial test suite (to be expanded)
+ - Allow NanUInt32OptionValue to convert any Number object
+
+### 0.1.0 Jul 21 2013
+
+ - Added `NAN_GETTER`, `NAN_SETTER`
+ - Added `NanThrowError` with single Local<Value> argument
+ - Added `NanNewBufferHandle` with single uint32_t argument
+ - Added `NanHasInstance(Persistent<FunctionTemplate>&, Handle<Value>)`
+ - Added `Local<Function> NanCallback#GetFunction()`
+ - Added `NanCallback#Call(int, Local<Value>[])`
+ - Deprecated `NanCallback#Run(int, Local<Value>[])` in favour of Call

http://git-wip-us.apache.org/repos/asf/couchdb-nmo/blob/753f1767/node_modules/couchbulkimporter/node_modules/mongodb/node_modules/mongodb-core/node_modules/kerberos/node_modules/nan/LICENSE.md
----------------------------------------------------------------------
diff --git a/node_modules/couchbulkimporter/node_modules/mongodb/node_modules/mongodb-core/node_modules/kerberos/node_modules/nan/LICENSE.md b/node_modules/couchbulkimporter/node_modules/mongodb/node_modules/mongodb-core/node_modules/kerberos/node_modules/nan/LICENSE.md
new file mode 100644
index 0000000..77666cd
--- /dev/null
+++ b/node_modules/couchbulkimporter/node_modules/mongodb/node_modules/mongodb-core/node_modules/kerberos/node_modules/nan/LICENSE.md
@@ -0,0 +1,13 @@
+The MIT License (MIT)
+=====================
+
+Copyright (c) 2015 NAN contributors
+-----------------------------------
+
+*NAN contributors listed at <https://github.com/nodejs/nan#contributors>*
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.


Mime
View raw message