// Copyright (c) The NodeRT Contributors
// All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the ""License""); you may
// not use this file except in compliance with the License. You may obtain a
// copy of the License at http://www.apache.org/licenses/LICENSE-2.0
//
// THIS CODE IS PROVIDED ON AN  *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS
// OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY
// IMPLIED WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
// MERCHANTABLITY OR NON-INFRINGEMENT.
//
// See the Apache Version 2.0 License for specific language governing permissions
// and limitations under the License.

// TODO: Verify that this is is still needed..
#define NTDDI_VERSION 0x06010000

#include <v8.h>
#include "nan.h"
#include <string>
#include <ppltasks.h>
#include "CollectionsConverter.h"
#include "CollectionsWrap.h"
#include "node-async.h"
#include "NodeRtUtils.h"
#include "OpaqueWrapper.h"
#include "WrapperBase.h"

#using <Windows.WinMD>

// this undefs fixes the issues of compiling Windows.Data.Json, Windows.Storag.FileProperties, and Windows.Stroage.Search
// Some of the node header files brings windows definitions with the same names as some of the WinRT methods
#undef DocumentProperties
#undef GetObject
#undef CreateEvent
#undef FindText
#undef SendMessage

const char* REGISTRATION_TOKEN_MAP_PROPERTY_NAME = "__registrationTokenMap__";

using v8::Array;
using v8::String;
using v8::Value;
using v8::Boolean;
using v8::Integer;
using v8::FunctionTemplate;
using v8::Object;
using v8::Local;
using v8::Function;
using v8::Date;
using v8::Number;
using v8::PropertyAttribute;
using v8::Primitive;
using Nan::HandleScope;
using Nan::Persistent;
using Nan::Undefined;
using Nan::True;
using Nan::False;
using Nan::Null;
using Nan::MaybeLocal;
using Nan::EscapableHandleScope;
using Nan::HandleScope;
using Nan::TryCatch;
using namespace concurrency;

namespace NodeRT { namespace Windows { namespace Security { namespace Authentication { namespace OnlineId { 
  v8::Local<v8::Value> WrapOnlineIdAuthenticator(::Windows::Security::Authentication::OnlineId::OnlineIdAuthenticator^ wintRtInstance);
  ::Windows::Security::Authentication::OnlineId::OnlineIdAuthenticator^ UnwrapOnlineIdAuthenticator(Local<Value> value);
  
  v8::Local<v8::Value> WrapOnlineIdServiceTicket(::Windows::Security::Authentication::OnlineId::OnlineIdServiceTicket^ wintRtInstance);
  ::Windows::Security::Authentication::OnlineId::OnlineIdServiceTicket^ UnwrapOnlineIdServiceTicket(Local<Value> value);
  
  v8::Local<v8::Value> WrapOnlineIdServiceTicketRequest(::Windows::Security::Authentication::OnlineId::OnlineIdServiceTicketRequest^ wintRtInstance);
  ::Windows::Security::Authentication::OnlineId::OnlineIdServiceTicketRequest^ UnwrapOnlineIdServiceTicketRequest(Local<Value> value);
  
  v8::Local<v8::Value> WrapOnlineIdSystemAuthenticator(::Windows::Security::Authentication::OnlineId::OnlineIdSystemAuthenticator^ wintRtInstance);
  ::Windows::Security::Authentication::OnlineId::OnlineIdSystemAuthenticator^ UnwrapOnlineIdSystemAuthenticator(Local<Value> value);
  
  v8::Local<v8::Value> WrapOnlineIdSystemAuthenticatorForUser(::Windows::Security::Authentication::OnlineId::OnlineIdSystemAuthenticatorForUser^ wintRtInstance);
  ::Windows::Security::Authentication::OnlineId::OnlineIdSystemAuthenticatorForUser^ UnwrapOnlineIdSystemAuthenticatorForUser(Local<Value> value);
  
  v8::Local<v8::Value> WrapOnlineIdSystemIdentity(::Windows::Security::Authentication::OnlineId::OnlineIdSystemIdentity^ wintRtInstance);
  ::Windows::Security::Authentication::OnlineId::OnlineIdSystemIdentity^ UnwrapOnlineIdSystemIdentity(Local<Value> value);
  
  v8::Local<v8::Value> WrapOnlineIdSystemTicketResult(::Windows::Security::Authentication::OnlineId::OnlineIdSystemTicketResult^ wintRtInstance);
  ::Windows::Security::Authentication::OnlineId::OnlineIdSystemTicketResult^ UnwrapOnlineIdSystemTicketResult(Local<Value> value);
  
  v8::Local<v8::Value> WrapSignOutUserOperation(::Windows::Security::Authentication::OnlineId::SignOutUserOperation^ wintRtInstance);
  ::Windows::Security::Authentication::OnlineId::SignOutUserOperation^ UnwrapSignOutUserOperation(Local<Value> value);
  
  v8::Local<v8::Value> WrapUserAuthenticationOperation(::Windows::Security::Authentication::OnlineId::UserAuthenticationOperation^ wintRtInstance);
  ::Windows::Security::Authentication::OnlineId::UserAuthenticationOperation^ UnwrapUserAuthenticationOperation(Local<Value> value);
  
  v8::Local<v8::Value> WrapUserIdentity(::Windows::Security::Authentication::OnlineId::UserIdentity^ wintRtInstance);
  ::Windows::Security::Authentication::OnlineId::UserIdentity^ UnwrapUserIdentity(Local<Value> value);
  



  static void InitCredentialPromptTypeEnum(const Local<Object> exports) {
    HandleScope scope;

    Local<Object> enumObject = Nan::New<Object>();

    Nan::Set(exports, Nan::New<String>("CredentialPromptType").ToLocalChecked(), enumObject);
    Nan::Set(enumObject, Nan::New<String>("promptIfNeeded").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Security::Authentication::OnlineId::CredentialPromptType::PromptIfNeeded)));
    Nan::Set(enumObject, Nan::New<String>("retypeCredentials").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Security::Authentication::OnlineId::CredentialPromptType::RetypeCredentials)));
    Nan::Set(enumObject, Nan::New<String>("doNotPrompt").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Security::Authentication::OnlineId::CredentialPromptType::DoNotPrompt)));
  }

  static void InitOnlineIdSystemTicketStatusEnum(const Local<Object> exports) {
    HandleScope scope;

    Local<Object> enumObject = Nan::New<Object>();

    Nan::Set(exports, Nan::New<String>("OnlineIdSystemTicketStatus").ToLocalChecked(), enumObject);
    Nan::Set(enumObject, Nan::New<String>("success").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Security::Authentication::OnlineId::OnlineIdSystemTicketStatus::Success)));
    Nan::Set(enumObject, Nan::New<String>("error").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Security::Authentication::OnlineId::OnlineIdSystemTicketStatus::Error)));
    Nan::Set(enumObject, Nan::New<String>("serviceConnectionError").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Security::Authentication::OnlineId::OnlineIdSystemTicketStatus::ServiceConnectionError)));
  }



  class OnlineIdAuthenticator : public WrapperBase {
    public:
      
      static void Init(const Local<Object> exports) {
        HandleScope scope;

        Local<FunctionTemplate> localRef = Nan::New<FunctionTemplate>(New);
        s_constructorTemplate.Reset(localRef);
        localRef->SetClassName(Nan::New<String>("OnlineIdAuthenticator").ToLocalChecked());
        localRef->InstanceTemplate()->SetInternalFieldCount(1);

        Local<Function> func;
        Local<FunctionTemplate> funcTemplate;


          
            Nan::SetPrototypeMethod(localRef, "authenticateUserAsync", AuthenticateUserAsync);
            Nan::SetPrototypeMethod(localRef, "signOutUserAsync", SignOutUserAsync);
          


          
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("applicationId").ToLocalChecked(), ApplicationIdGetter, ApplicationIdSetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("authenticatedSafeCustomerId").ToLocalChecked(), AuthenticatedSafeCustomerIdGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("canSignOut").ToLocalChecked(), CanSignOutGetter);

        Local<Object> constructor = Nan::To<Object>(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked();
        Nan::SetMethod(constructor, "castFrom", CastFrom);



        Nan::Set(exports, Nan::New<String>("OnlineIdAuthenticator").ToLocalChecked(), constructor);
      }

      virtual ::Platform::Object^ GetObjectInstance() const override {
        return _instance;
      }

    private:

      OnlineIdAuthenticator(::Windows::Security::Authentication::OnlineId::OnlineIdAuthenticator^ instance) {
        _instance = instance;
      }

      
    static void New(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      Local<FunctionTemplate> localRef = Nan::New<FunctionTemplate>(s_constructorTemplate);

      // in case the constructor was called without the new operator
      if (!localRef->HasInstance(info.This())) {
        if (info.Length() > 0) {
          std::unique_ptr<Local<Value> []> constructorArgs(new Local<Value>[info.Length()]);

          Local<Value> *argsPtr = constructorArgs.get();
          for (int i = 0; i < info.Length(); i++) {
            argsPtr[i] = info[i];
          }

          MaybeLocal<Object> res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), constructorArgs.get());
          if (res.IsEmpty()) {
            return;
          }

          info.GetReturnValue().Set(res.ToLocalChecked());
          return;
        } else {
          MaybeLocal<Object> res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), nullptr);

          if (res.IsEmpty()) {
            return;
          }

          info.GetReturnValue().Set(res.ToLocalChecked());
          return;
        }
      }

      ::Windows::Security::Authentication::OnlineId::OnlineIdAuthenticator^ winRtInstance;


      if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) &&
        NodeRT::Utils::IsWinRtWrapperOf<::Windows::Security::Authentication::OnlineId::OnlineIdAuthenticator^>(info[0])) {
        try {
          winRtInstance = (::Windows::Security::Authentication::OnlineId::OnlineIdAuthenticator^) NodeRT::Utils::GetObjectInstance(info[0]);
        } catch (Platform::Exception ^exception) {
          NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
          return;
        }
      }
      else if (info.Length() == 0)
      {
        try {
          winRtInstance = ref new ::Windows::Security::Authentication::OnlineId::OnlineIdAuthenticator();
        } catch (Platform::Exception ^exception) {
          NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
          return;
        }
      }
 else {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no suitable constructor found")));
        return;
      }

      NodeRT::Utils::SetHiddenValue(info.This(), Nan::New<String>("__winRtInstance__").ToLocalChecked(), True());

      OnlineIdAuthenticator *wrapperInstance = new OnlineIdAuthenticator(winRtInstance);
      wrapperInstance->Wrap(info.This());

      info.GetReturnValue().Set(info.This());
    }


      
    static void CastFrom(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;
      if (info.Length() < 1 || !NodeRT::Utils::IsWinRtWrapperOf<::Windows::Security::Authentication::OnlineId::OnlineIdAuthenticator^>(info[0])) {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no object provided, or given object could not be casted to requested type")));
        return;
      }

      ::Windows::Security::Authentication::OnlineId::OnlineIdAuthenticator^ winRtInstance;
      try {
        winRtInstance = (::Windows::Security::Authentication::OnlineId::OnlineIdAuthenticator^) NodeRT::Utils::GetObjectInstance(info[0]);
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }

      info.GetReturnValue().Set(WrapOnlineIdAuthenticator(winRtInstance));
    }

    static void AuthenticateUserAsync(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Security::Authentication::OnlineId::OnlineIdAuthenticator^>(info.This())) {
        return;
      }

      if (info.Length() == 0 || !info[info.Length() -1]->IsFunction()) {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: No callback was given")));
        return;
      }

      OnlineIdAuthenticator *wrapper = OnlineIdAuthenticator::Unwrap<OnlineIdAuthenticator>(info.This());

      ::Windows::Security::Authentication::OnlineId::UserAuthenticationOperation^ op;


      if (info.Length() == 2
        && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Security::Authentication::OnlineId::OnlineIdServiceTicketRequest^>(info[0]))
      {
        try
        {
          ::Windows::Security::Authentication::OnlineId::OnlineIdServiceTicketRequest^ arg0 = UnwrapOnlineIdServiceTicketRequest(info[0]);
          
          op = wrapper->_instance->AuthenticateUserAsync(arg0);
        }
        catch (Platform::Exception ^exception)
        {
          NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
          return;
        }
      }
      else if (info.Length() == 3
        && (NodeRT::Utils::IsWinRtWrapperOf<::Windows::Foundation::Collections::IIterable<::Windows::Security::Authentication::OnlineId::OnlineIdServiceTicketRequest^>^>(info[0]) || info[0]->IsArray())
        && info[1]->IsInt32())
      {
        try
        {
          ::Windows::Foundation::Collections::IIterable<::Windows::Security::Authentication::OnlineId::OnlineIdServiceTicketRequest^>^ arg0 = 
            [] (v8::Local<v8::Value> value) -> ::Windows::Foundation::Collections::IIterable<::Windows::Security::Authentication::OnlineId::OnlineIdServiceTicketRequest^>^
            {
              if (value->IsArray())
              {
                return NodeRT::Collections::JsArrayToWinrtVector<::Windows::Security::Authentication::OnlineId::OnlineIdServiceTicketRequest^>(value.As<Array>(), 
                 [](Local<Value> value) -> bool {
                   return NodeRT::Utils::IsWinRtWrapperOf<::Windows::Security::Authentication::OnlineId::OnlineIdServiceTicketRequest^>(value);
                 },
                 [](Local<Value> value) -> ::Windows::Security::Authentication::OnlineId::OnlineIdServiceTicketRequest^ {
                   return UnwrapOnlineIdServiceTicketRequest(value);
                 }
                );
              }
              else
              {
                return dynamic_cast<::Windows::Foundation::Collections::IIterable<::Windows::Security::Authentication::OnlineId::OnlineIdServiceTicketRequest^>^>(NodeRT::Utils::GetObjectInstance(value));
              }
            } (info[0]);
          ::Windows::Security::Authentication::OnlineId::CredentialPromptType arg1 = static_cast<::Windows::Security::Authentication::OnlineId::CredentialPromptType>(Nan::To<int32_t>(info[1]).FromMaybe(0));
          
          op = wrapper->_instance->AuthenticateUserAsync(arg0,arg1);
        }
        catch (Platform::Exception ^exception)
        {
          NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
          return;
        }
      }
 else {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found")));
        return;
      }

      auto opTask = create_task(op);
      uv_async_t* asyncToken = NodeUtils::Async::GetAsyncToken(info[info.Length() -1].As<Function>());

      opTask.then( [asyncToken] (task<::Windows::Security::Authentication::OnlineId::UserIdentity^> t) {
        try {
          auto result = t.get();
          NodeUtils::Async::RunCallbackOnMain(asyncToken, [result](NodeUtils::InvokeCallbackDelegate invokeCallback) {


            Local<Value> error;
            Local<Value> arg1;
            {
              TryCatch tryCatch;
              arg1 = WrapUserIdentity(result);
              if (tryCatch.HasCaught())
              {
                error = Nan::To<Object>(tryCatch.Exception()).ToLocalChecked();
              }
              else
              {
                error = Undefined();
              }
              if (arg1.IsEmpty()) arg1 = Undefined();
            }
            Local<Value> args[] = {error, arg1};


            invokeCallback(_countof(args), args);
          });
        } catch (Platform::Exception^ exception) {
          NodeUtils::Async::RunCallbackOnMain(asyncToken, [exception](NodeUtils::InvokeCallbackDelegate invokeCallback) {
            Local<Value> error = NodeRT::Utils::WinRtExceptionToJsError(exception);

            Local<Value> args[] = {error};
            invokeCallback(_countof(args), args);
          });
        }
      });
    }
    static void SignOutUserAsync(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Security::Authentication::OnlineId::OnlineIdAuthenticator^>(info.This())) {
        return;
      }

      if (info.Length() == 0 || !info[info.Length() -1]->IsFunction()) {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: No callback was given")));
        return;
      }

      OnlineIdAuthenticator *wrapper = OnlineIdAuthenticator::Unwrap<OnlineIdAuthenticator>(info.This());

      ::Windows::Security::Authentication::OnlineId::SignOutUserOperation^ op;


      if (info.Length() == 1)
      {
        try
        {
          op = wrapper->_instance->SignOutUserAsync();
        }
        catch (Platform::Exception ^exception)
        {
          NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
          return;
        }
      }
 else {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found")));
        return;
      }

      auto opTask = create_task(op);
      uv_async_t* asyncToken = NodeUtils::Async::GetAsyncToken(info[info.Length() -1].As<Function>());

      opTask.then( [asyncToken] (task<void> t) {
        try {
          t.get();
          NodeUtils::Async::RunCallbackOnMain(asyncToken, [](NodeUtils::InvokeCallbackDelegate invokeCallback) {


            Local<Value> args[] = {Undefined()};


            invokeCallback(_countof(args), args);
          });
        } catch (Platform::Exception^ exception) {
          NodeUtils::Async::RunCallbackOnMain(asyncToken, [exception](NodeUtils::InvokeCallbackDelegate invokeCallback) {
            Local<Value> error = NodeRT::Utils::WinRtExceptionToJsError(exception);

            Local<Value> args[] = {error};
            invokeCallback(_countof(args), args);
          });
        }
      });
    }




    static void ApplicationIdGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Security::Authentication::OnlineId::OnlineIdAuthenticator^>(info.This())) {
        return;
      }

      OnlineIdAuthenticator *wrapper = OnlineIdAuthenticator::Unwrap<OnlineIdAuthenticator>(info.This());

      try  {
        ::Platform::Guid result = wrapper->_instance->ApplicationId;
        info.GetReturnValue().Set(NodeRT::Utils::GuidToJs(result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void ApplicationIdSetter(Local<String> property, Local<Value> value, const Nan::PropertyCallbackInfo<void> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsGuid(value)) {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type")));
        return;
      }

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Security::Authentication::OnlineId::OnlineIdAuthenticator^>(info.This())) {
        return;
      }

      OnlineIdAuthenticator *wrapper = OnlineIdAuthenticator::Unwrap<OnlineIdAuthenticator>(info.This());

      try {

        ::Platform::Guid winRtValue = NodeRT::Utils::GuidFromJs(value);

        wrapper->_instance->ApplicationId = winRtValue;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
      }
    }
      
    static void AuthenticatedSafeCustomerIdGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Security::Authentication::OnlineId::OnlineIdAuthenticator^>(info.This())) {
        return;
      }

      OnlineIdAuthenticator *wrapper = OnlineIdAuthenticator::Unwrap<OnlineIdAuthenticator>(info.This());

      try  {
        Platform::String^ result = wrapper->_instance->AuthenticatedSafeCustomerId;
        info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data()));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void CanSignOutGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Security::Authentication::OnlineId::OnlineIdAuthenticator^>(info.This())) {
        return;
      }

      OnlineIdAuthenticator *wrapper = OnlineIdAuthenticator::Unwrap<OnlineIdAuthenticator>(info.This());

      try  {
        bool result = wrapper->_instance->CanSignOut;
        info.GetReturnValue().Set(Nan::New<Boolean>(result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      


    private:
      ::Windows::Security::Authentication::OnlineId::OnlineIdAuthenticator^ _instance;
      static Persistent<FunctionTemplate> s_constructorTemplate;

      friend v8::Local<v8::Value> WrapOnlineIdAuthenticator(::Windows::Security::Authentication::OnlineId::OnlineIdAuthenticator^ wintRtInstance);
      friend ::Windows::Security::Authentication::OnlineId::OnlineIdAuthenticator^ UnwrapOnlineIdAuthenticator(Local<Value> value);
  };

  Persistent<FunctionTemplate> OnlineIdAuthenticator::s_constructorTemplate;

  v8::Local<v8::Value> WrapOnlineIdAuthenticator(::Windows::Security::Authentication::OnlineId::OnlineIdAuthenticator^ winRtInstance) {
    EscapableHandleScope scope;

    if (winRtInstance == nullptr) {
      return scope.Escape(Undefined());
    }

    Local<Value> opaqueWrapper = CreateOpaqueWrapper(winRtInstance);
    Local<Value> args[] = {opaqueWrapper};
    Local<FunctionTemplate> localRef = Nan::New<FunctionTemplate>(OnlineIdAuthenticator::s_constructorTemplate);
    return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked());
  }

  ::Windows::Security::Authentication::OnlineId::OnlineIdAuthenticator^ UnwrapOnlineIdAuthenticator(Local<Value> value) {
     return OnlineIdAuthenticator::Unwrap<OnlineIdAuthenticator>(Nan::To<Object>(value).ToLocalChecked())->_instance;
  }

  void InitOnlineIdAuthenticator(Local<Object> exports) {
    OnlineIdAuthenticator::Init(exports);
  }

  class OnlineIdServiceTicket : public WrapperBase {
    public:
      
      static void Init(const Local<Object> exports) {
        HandleScope scope;

        Local<FunctionTemplate> localRef = Nan::New<FunctionTemplate>(New);
        s_constructorTemplate.Reset(localRef);
        localRef->SetClassName(Nan::New<String>("OnlineIdServiceTicket").ToLocalChecked());
        localRef->InstanceTemplate()->SetInternalFieldCount(1);





          
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("errorCode").ToLocalChecked(), ErrorCodeGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("request").ToLocalChecked(), RequestGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("value").ToLocalChecked(), ValueGetter);

        Local<Object> constructor = Nan::To<Object>(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked();
        Nan::SetMethod(constructor, "castFrom", CastFrom);



        Nan::Set(exports, Nan::New<String>("OnlineIdServiceTicket").ToLocalChecked(), constructor);
      }

      virtual ::Platform::Object^ GetObjectInstance() const override {
        return _instance;
      }

    private:

      OnlineIdServiceTicket(::Windows::Security::Authentication::OnlineId::OnlineIdServiceTicket^ instance) {
        _instance = instance;
      }

      
    static void New(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      Local<FunctionTemplate> localRef = Nan::New<FunctionTemplate>(s_constructorTemplate);

      // in case the constructor was called without the new operator
      if (!localRef->HasInstance(info.This())) {
        if (info.Length() > 0) {
          std::unique_ptr<Local<Value> []> constructorArgs(new Local<Value>[info.Length()]);

          Local<Value> *argsPtr = constructorArgs.get();
          for (int i = 0; i < info.Length(); i++) {
            argsPtr[i] = info[i];
          }

          MaybeLocal<Object> res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), constructorArgs.get());
          if (res.IsEmpty()) {
            return;
          }

          info.GetReturnValue().Set(res.ToLocalChecked());
          return;
        } else {
          MaybeLocal<Object> res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), nullptr);

          if (res.IsEmpty()) {
            return;
          }

          info.GetReturnValue().Set(res.ToLocalChecked());
          return;
        }
      }

      ::Windows::Security::Authentication::OnlineId::OnlineIdServiceTicket^ winRtInstance;


      if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) &&
        NodeRT::Utils::IsWinRtWrapperOf<::Windows::Security::Authentication::OnlineId::OnlineIdServiceTicket^>(info[0])) {
        try {
          winRtInstance = (::Windows::Security::Authentication::OnlineId::OnlineIdServiceTicket^) NodeRT::Utils::GetObjectInstance(info[0]);
        } catch (Platform::Exception ^exception) {
          NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
          return;
        }
      }
 else {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no suitable constructor found")));
        return;
      }

      NodeRT::Utils::SetHiddenValue(info.This(), Nan::New<String>("__winRtInstance__").ToLocalChecked(), True());

      OnlineIdServiceTicket *wrapperInstance = new OnlineIdServiceTicket(winRtInstance);
      wrapperInstance->Wrap(info.This());

      info.GetReturnValue().Set(info.This());
    }


      
    static void CastFrom(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;
      if (info.Length() < 1 || !NodeRT::Utils::IsWinRtWrapperOf<::Windows::Security::Authentication::OnlineId::OnlineIdServiceTicket^>(info[0])) {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no object provided, or given object could not be casted to requested type")));
        return;
      }

      ::Windows::Security::Authentication::OnlineId::OnlineIdServiceTicket^ winRtInstance;
      try {
        winRtInstance = (::Windows::Security::Authentication::OnlineId::OnlineIdServiceTicket^) NodeRT::Utils::GetObjectInstance(info[0]);
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }

      info.GetReturnValue().Set(WrapOnlineIdServiceTicket(winRtInstance));
    }





    static void ErrorCodeGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Security::Authentication::OnlineId::OnlineIdServiceTicket^>(info.This())) {
        return;
      }

      OnlineIdServiceTicket *wrapper = OnlineIdServiceTicket::Unwrap<OnlineIdServiceTicket>(info.This());

      try  {
        int result = wrapper->_instance->ErrorCode;
        info.GetReturnValue().Set(Nan::New<Integer>(result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void RequestGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Security::Authentication::OnlineId::OnlineIdServiceTicket^>(info.This())) {
        return;
      }

      OnlineIdServiceTicket *wrapper = OnlineIdServiceTicket::Unwrap<OnlineIdServiceTicket>(info.This());

      try  {
        ::Windows::Security::Authentication::OnlineId::OnlineIdServiceTicketRequest^ result = wrapper->_instance->Request;
        info.GetReturnValue().Set(WrapOnlineIdServiceTicketRequest(result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void ValueGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Security::Authentication::OnlineId::OnlineIdServiceTicket^>(info.This())) {
        return;
      }

      OnlineIdServiceTicket *wrapper = OnlineIdServiceTicket::Unwrap<OnlineIdServiceTicket>(info.This());

      try  {
        Platform::String^ result = wrapper->_instance->Value;
        info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data()));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      


    private:
      ::Windows::Security::Authentication::OnlineId::OnlineIdServiceTicket^ _instance;
      static Persistent<FunctionTemplate> s_constructorTemplate;

      friend v8::Local<v8::Value> WrapOnlineIdServiceTicket(::Windows::Security::Authentication::OnlineId::OnlineIdServiceTicket^ wintRtInstance);
      friend ::Windows::Security::Authentication::OnlineId::OnlineIdServiceTicket^ UnwrapOnlineIdServiceTicket(Local<Value> value);
  };

  Persistent<FunctionTemplate> OnlineIdServiceTicket::s_constructorTemplate;

  v8::Local<v8::Value> WrapOnlineIdServiceTicket(::Windows::Security::Authentication::OnlineId::OnlineIdServiceTicket^ winRtInstance) {
    EscapableHandleScope scope;

    if (winRtInstance == nullptr) {
      return scope.Escape(Undefined());
    }

    Local<Value> opaqueWrapper = CreateOpaqueWrapper(winRtInstance);
    Local<Value> args[] = {opaqueWrapper};
    Local<FunctionTemplate> localRef = Nan::New<FunctionTemplate>(OnlineIdServiceTicket::s_constructorTemplate);
    return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked());
  }

  ::Windows::Security::Authentication::OnlineId::OnlineIdServiceTicket^ UnwrapOnlineIdServiceTicket(Local<Value> value) {
     return OnlineIdServiceTicket::Unwrap<OnlineIdServiceTicket>(Nan::To<Object>(value).ToLocalChecked())->_instance;
  }

  void InitOnlineIdServiceTicket(Local<Object> exports) {
    OnlineIdServiceTicket::Init(exports);
  }

  class OnlineIdServiceTicketRequest : public WrapperBase {
    public:
      
      static void Init(const Local<Object> exports) {
        HandleScope scope;

        Local<FunctionTemplate> localRef = Nan::New<FunctionTemplate>(New);
        s_constructorTemplate.Reset(localRef);
        localRef->SetClassName(Nan::New<String>("OnlineIdServiceTicketRequest").ToLocalChecked());
        localRef->InstanceTemplate()->SetInternalFieldCount(1);





          
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("policy").ToLocalChecked(), PolicyGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("service").ToLocalChecked(), ServiceGetter);

        Local<Object> constructor = Nan::To<Object>(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked();
        Nan::SetMethod(constructor, "castFrom", CastFrom);



        Nan::Set(exports, Nan::New<String>("OnlineIdServiceTicketRequest").ToLocalChecked(), constructor);
      }

      virtual ::Platform::Object^ GetObjectInstance() const override {
        return _instance;
      }

    private:

      OnlineIdServiceTicketRequest(::Windows::Security::Authentication::OnlineId::OnlineIdServiceTicketRequest^ instance) {
        _instance = instance;
      }

      
    static void New(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      Local<FunctionTemplate> localRef = Nan::New<FunctionTemplate>(s_constructorTemplate);

      // in case the constructor was called without the new operator
      if (!localRef->HasInstance(info.This())) {
        if (info.Length() > 0) {
          std::unique_ptr<Local<Value> []> constructorArgs(new Local<Value>[info.Length()]);

          Local<Value> *argsPtr = constructorArgs.get();
          for (int i = 0; i < info.Length(); i++) {
            argsPtr[i] = info[i];
          }

          MaybeLocal<Object> res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), constructorArgs.get());
          if (res.IsEmpty()) {
            return;
          }

          info.GetReturnValue().Set(res.ToLocalChecked());
          return;
        } else {
          MaybeLocal<Object> res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), nullptr);

          if (res.IsEmpty()) {
            return;
          }

          info.GetReturnValue().Set(res.ToLocalChecked());
          return;
        }
      }

      ::Windows::Security::Authentication::OnlineId::OnlineIdServiceTicketRequest^ winRtInstance;


      if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) &&
        NodeRT::Utils::IsWinRtWrapperOf<::Windows::Security::Authentication::OnlineId::OnlineIdServiceTicketRequest^>(info[0])) {
        try {
          winRtInstance = (::Windows::Security::Authentication::OnlineId::OnlineIdServiceTicketRequest^) NodeRT::Utils::GetObjectInstance(info[0]);
        } catch (Platform::Exception ^exception) {
          NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
          return;
        }
      }
      else if (info.Length() == 2
        && info[0]->IsString()
        && info[1]->IsString())
      {
        try {
          Platform::String^ arg0 = ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(v8::Isolate::GetCurrent(), info[0])));
          Platform::String^ arg1 = ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(v8::Isolate::GetCurrent(), info[1])));
          
          winRtInstance = ref new ::Windows::Security::Authentication::OnlineId::OnlineIdServiceTicketRequest(arg0,arg1);
        } catch (Platform::Exception ^exception) {
          NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
          return;
        }
      }
      else if (info.Length() == 1
        && info[0]->IsString())
      {
        try {
          Platform::String^ arg0 = ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(v8::Isolate::GetCurrent(), info[0])));
          
          winRtInstance = ref new ::Windows::Security::Authentication::OnlineId::OnlineIdServiceTicketRequest(arg0);
        } catch (Platform::Exception ^exception) {
          NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
          return;
        }
      }
 else {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no suitable constructor found")));
        return;
      }

      NodeRT::Utils::SetHiddenValue(info.This(), Nan::New<String>("__winRtInstance__").ToLocalChecked(), True());

      OnlineIdServiceTicketRequest *wrapperInstance = new OnlineIdServiceTicketRequest(winRtInstance);
      wrapperInstance->Wrap(info.This());

      info.GetReturnValue().Set(info.This());
    }


      
    static void CastFrom(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;
      if (info.Length() < 1 || !NodeRT::Utils::IsWinRtWrapperOf<::Windows::Security::Authentication::OnlineId::OnlineIdServiceTicketRequest^>(info[0])) {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no object provided, or given object could not be casted to requested type")));
        return;
      }

      ::Windows::Security::Authentication::OnlineId::OnlineIdServiceTicketRequest^ winRtInstance;
      try {
        winRtInstance = (::Windows::Security::Authentication::OnlineId::OnlineIdServiceTicketRequest^) NodeRT::Utils::GetObjectInstance(info[0]);
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }

      info.GetReturnValue().Set(WrapOnlineIdServiceTicketRequest(winRtInstance));
    }





    static void PolicyGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Security::Authentication::OnlineId::OnlineIdServiceTicketRequest^>(info.This())) {
        return;
      }

      OnlineIdServiceTicketRequest *wrapper = OnlineIdServiceTicketRequest::Unwrap<OnlineIdServiceTicketRequest>(info.This());

      try  {
        Platform::String^ result = wrapper->_instance->Policy;
        info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data()));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void ServiceGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Security::Authentication::OnlineId::OnlineIdServiceTicketRequest^>(info.This())) {
        return;
      }

      OnlineIdServiceTicketRequest *wrapper = OnlineIdServiceTicketRequest::Unwrap<OnlineIdServiceTicketRequest>(info.This());

      try  {
        Platform::String^ result = wrapper->_instance->Service;
        info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data()));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      


    private:
      ::Windows::Security::Authentication::OnlineId::OnlineIdServiceTicketRequest^ _instance;
      static Persistent<FunctionTemplate> s_constructorTemplate;

      friend v8::Local<v8::Value> WrapOnlineIdServiceTicketRequest(::Windows::Security::Authentication::OnlineId::OnlineIdServiceTicketRequest^ wintRtInstance);
      friend ::Windows::Security::Authentication::OnlineId::OnlineIdServiceTicketRequest^ UnwrapOnlineIdServiceTicketRequest(Local<Value> value);
  };

  Persistent<FunctionTemplate> OnlineIdServiceTicketRequest::s_constructorTemplate;

  v8::Local<v8::Value> WrapOnlineIdServiceTicketRequest(::Windows::Security::Authentication::OnlineId::OnlineIdServiceTicketRequest^ winRtInstance) {
    EscapableHandleScope scope;

    if (winRtInstance == nullptr) {
      return scope.Escape(Undefined());
    }

    Local<Value> opaqueWrapper = CreateOpaqueWrapper(winRtInstance);
    Local<Value> args[] = {opaqueWrapper};
    Local<FunctionTemplate> localRef = Nan::New<FunctionTemplate>(OnlineIdServiceTicketRequest::s_constructorTemplate);
    return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked());
  }

  ::Windows::Security::Authentication::OnlineId::OnlineIdServiceTicketRequest^ UnwrapOnlineIdServiceTicketRequest(Local<Value> value) {
     return OnlineIdServiceTicketRequest::Unwrap<OnlineIdServiceTicketRequest>(Nan::To<Object>(value).ToLocalChecked())->_instance;
  }

  void InitOnlineIdServiceTicketRequest(Local<Object> exports) {
    OnlineIdServiceTicketRequest::Init(exports);
  }

  class OnlineIdSystemAuthenticator : public WrapperBase {
    public:
      
      static void Init(const Local<Object> exports) {
        HandleScope scope;

        Local<FunctionTemplate> localRef = Nan::New<FunctionTemplate>(New);
        s_constructorTemplate.Reset(localRef);
        localRef->SetClassName(Nan::New<String>("OnlineIdSystemAuthenticator").ToLocalChecked());
        localRef->InstanceTemplate()->SetInternalFieldCount(1);






        Local<Object> constructor = Nan::To<Object>(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked();
        Nan::SetMethod(constructor, "castFrom", CastFrom);

        Nan::SetMethod(constructor, "getForUser", GetForUser);
        Nan::SetAccessor(constructor, Nan::New<String>("default").ToLocalChecked(), DefaultGetter);


        Nan::Set(exports, Nan::New<String>("OnlineIdSystemAuthenticator").ToLocalChecked(), constructor);
      }

      virtual ::Platform::Object^ GetObjectInstance() const override {
        return _instance;
      }

    private:

      OnlineIdSystemAuthenticator(::Windows::Security::Authentication::OnlineId::OnlineIdSystemAuthenticator^ instance) {
        _instance = instance;
      }

      
    static void New(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      Local<FunctionTemplate> localRef = Nan::New<FunctionTemplate>(s_constructorTemplate);

      // in case the constructor was called without the new operator
      if (!localRef->HasInstance(info.This())) {
        if (info.Length() > 0) {
          std::unique_ptr<Local<Value> []> constructorArgs(new Local<Value>[info.Length()]);

          Local<Value> *argsPtr = constructorArgs.get();
          for (int i = 0; i < info.Length(); i++) {
            argsPtr[i] = info[i];
          }

          MaybeLocal<Object> res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), constructorArgs.get());
          if (res.IsEmpty()) {
            return;
          }

          info.GetReturnValue().Set(res.ToLocalChecked());
          return;
        } else {
          MaybeLocal<Object> res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), nullptr);

          if (res.IsEmpty()) {
            return;
          }

          info.GetReturnValue().Set(res.ToLocalChecked());
          return;
        }
      }

      ::Windows::Security::Authentication::OnlineId::OnlineIdSystemAuthenticator^ winRtInstance;


      if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) &&
        NodeRT::Utils::IsWinRtWrapperOf<::Windows::Security::Authentication::OnlineId::OnlineIdSystemAuthenticator^>(info[0])) {
        try {
          winRtInstance = (::Windows::Security::Authentication::OnlineId::OnlineIdSystemAuthenticator^) NodeRT::Utils::GetObjectInstance(info[0]);
        } catch (Platform::Exception ^exception) {
          NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
          return;
        }
      }
 else {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no suitable constructor found")));
        return;
      }

      NodeRT::Utils::SetHiddenValue(info.This(), Nan::New<String>("__winRtInstance__").ToLocalChecked(), True());

      OnlineIdSystemAuthenticator *wrapperInstance = new OnlineIdSystemAuthenticator(winRtInstance);
      wrapperInstance->Wrap(info.This());

      info.GetReturnValue().Set(info.This());
    }


      
    static void CastFrom(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;
      if (info.Length() < 1 || !NodeRT::Utils::IsWinRtWrapperOf<::Windows::Security::Authentication::OnlineId::OnlineIdSystemAuthenticator^>(info[0])) {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no object provided, or given object could not be casted to requested type")));
        return;
      }

      ::Windows::Security::Authentication::OnlineId::OnlineIdSystemAuthenticator^ winRtInstance;
      try {
        winRtInstance = (::Windows::Security::Authentication::OnlineId::OnlineIdSystemAuthenticator^) NodeRT::Utils::GetObjectInstance(info[0]);
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }

      info.GetReturnValue().Set(WrapOnlineIdSystemAuthenticator(winRtInstance));
    }





    static void GetForUser(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      if (info.Length() == 1
        && NodeRT::Utils::IsWinRtWrapperOf<::Windows::System::User^>(info[0]))
      {
        try
        {
          ::Windows::System::User^ arg0 = dynamic_cast<::Windows::System::User^>(NodeRT::Utils::GetObjectInstance(info[0]));
          
          ::Windows::Security::Authentication::OnlineId::OnlineIdSystemAuthenticatorForUser^ result;
          result = ::Windows::Security::Authentication::OnlineId::OnlineIdSystemAuthenticator::GetForUser(arg0);
          info.GetReturnValue().Set(WrapOnlineIdSystemAuthenticatorForUser(result));
          return;
        }
        catch (Platform::Exception ^exception)
        {
          NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
          return;
        }
      }
 else  {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found")));
        return;
      }
    }



    static void DefaultGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      try
      {
        ::Windows::Security::Authentication::OnlineId::OnlineIdSystemAuthenticatorForUser^ result = ::Windows::Security::Authentication::OnlineId::OnlineIdSystemAuthenticator::Default;
        info.GetReturnValue().Set(WrapOnlineIdSystemAuthenticatorForUser(result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      

    private:
      ::Windows::Security::Authentication::OnlineId::OnlineIdSystemAuthenticator^ _instance;
      static Persistent<FunctionTemplate> s_constructorTemplate;

      friend v8::Local<v8::Value> WrapOnlineIdSystemAuthenticator(::Windows::Security::Authentication::OnlineId::OnlineIdSystemAuthenticator^ wintRtInstance);
      friend ::Windows::Security::Authentication::OnlineId::OnlineIdSystemAuthenticator^ UnwrapOnlineIdSystemAuthenticator(Local<Value> value);
  };

  Persistent<FunctionTemplate> OnlineIdSystemAuthenticator::s_constructorTemplate;

  v8::Local<v8::Value> WrapOnlineIdSystemAuthenticator(::Windows::Security::Authentication::OnlineId::OnlineIdSystemAuthenticator^ winRtInstance) {
    EscapableHandleScope scope;

    if (winRtInstance == nullptr) {
      return scope.Escape(Undefined());
    }

    Local<Value> opaqueWrapper = CreateOpaqueWrapper(winRtInstance);
    Local<Value> args[] = {opaqueWrapper};
    Local<FunctionTemplate> localRef = Nan::New<FunctionTemplate>(OnlineIdSystemAuthenticator::s_constructorTemplate);
    return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked());
  }

  ::Windows::Security::Authentication::OnlineId::OnlineIdSystemAuthenticator^ UnwrapOnlineIdSystemAuthenticator(Local<Value> value) {
     return OnlineIdSystemAuthenticator::Unwrap<OnlineIdSystemAuthenticator>(Nan::To<Object>(value).ToLocalChecked())->_instance;
  }

  void InitOnlineIdSystemAuthenticator(Local<Object> exports) {
    OnlineIdSystemAuthenticator::Init(exports);
  }

  class OnlineIdSystemAuthenticatorForUser : public WrapperBase {
    public:
      
      static void Init(const Local<Object> exports) {
        HandleScope scope;

        Local<FunctionTemplate> localRef = Nan::New<FunctionTemplate>(New);
        s_constructorTemplate.Reset(localRef);
        localRef->SetClassName(Nan::New<String>("OnlineIdSystemAuthenticatorForUser").ToLocalChecked());
        localRef->InstanceTemplate()->SetInternalFieldCount(1);

        Local<Function> func;
        Local<FunctionTemplate> funcTemplate;


          
            Nan::SetPrototypeMethod(localRef, "getTicketAsync", GetTicketAsync);
          


          
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("applicationId").ToLocalChecked(), ApplicationIdGetter, ApplicationIdSetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("user").ToLocalChecked(), UserGetter);

        Local<Object> constructor = Nan::To<Object>(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked();
        Nan::SetMethod(constructor, "castFrom", CastFrom);



        Nan::Set(exports, Nan::New<String>("OnlineIdSystemAuthenticatorForUser").ToLocalChecked(), constructor);
      }

      virtual ::Platform::Object^ GetObjectInstance() const override {
        return _instance;
      }

    private:

      OnlineIdSystemAuthenticatorForUser(::Windows::Security::Authentication::OnlineId::OnlineIdSystemAuthenticatorForUser^ instance) {
        _instance = instance;
      }

      
    static void New(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      Local<FunctionTemplate> localRef = Nan::New<FunctionTemplate>(s_constructorTemplate);

      // in case the constructor was called without the new operator
      if (!localRef->HasInstance(info.This())) {
        if (info.Length() > 0) {
          std::unique_ptr<Local<Value> []> constructorArgs(new Local<Value>[info.Length()]);

          Local<Value> *argsPtr = constructorArgs.get();
          for (int i = 0; i < info.Length(); i++) {
            argsPtr[i] = info[i];
          }

          MaybeLocal<Object> res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), constructorArgs.get());
          if (res.IsEmpty()) {
            return;
          }

          info.GetReturnValue().Set(res.ToLocalChecked());
          return;
        } else {
          MaybeLocal<Object> res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), nullptr);

          if (res.IsEmpty()) {
            return;
          }

          info.GetReturnValue().Set(res.ToLocalChecked());
          return;
        }
      }

      ::Windows::Security::Authentication::OnlineId::OnlineIdSystemAuthenticatorForUser^ winRtInstance;


      if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) &&
        NodeRT::Utils::IsWinRtWrapperOf<::Windows::Security::Authentication::OnlineId::OnlineIdSystemAuthenticatorForUser^>(info[0])) {
        try {
          winRtInstance = (::Windows::Security::Authentication::OnlineId::OnlineIdSystemAuthenticatorForUser^) NodeRT::Utils::GetObjectInstance(info[0]);
        } catch (Platform::Exception ^exception) {
          NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
          return;
        }
      }
 else {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no suitable constructor found")));
        return;
      }

      NodeRT::Utils::SetHiddenValue(info.This(), Nan::New<String>("__winRtInstance__").ToLocalChecked(), True());

      OnlineIdSystemAuthenticatorForUser *wrapperInstance = new OnlineIdSystemAuthenticatorForUser(winRtInstance);
      wrapperInstance->Wrap(info.This());

      info.GetReturnValue().Set(info.This());
    }


      
    static void CastFrom(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;
      if (info.Length() < 1 || !NodeRT::Utils::IsWinRtWrapperOf<::Windows::Security::Authentication::OnlineId::OnlineIdSystemAuthenticatorForUser^>(info[0])) {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no object provided, or given object could not be casted to requested type")));
        return;
      }

      ::Windows::Security::Authentication::OnlineId::OnlineIdSystemAuthenticatorForUser^ winRtInstance;
      try {
        winRtInstance = (::Windows::Security::Authentication::OnlineId::OnlineIdSystemAuthenticatorForUser^) NodeRT::Utils::GetObjectInstance(info[0]);
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }

      info.GetReturnValue().Set(WrapOnlineIdSystemAuthenticatorForUser(winRtInstance));
    }

    static void GetTicketAsync(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Security::Authentication::OnlineId::OnlineIdSystemAuthenticatorForUser^>(info.This())) {
        return;
      }

      if (info.Length() == 0 || !info[info.Length() -1]->IsFunction()) {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: No callback was given")));
        return;
      }

      OnlineIdSystemAuthenticatorForUser *wrapper = OnlineIdSystemAuthenticatorForUser::Unwrap<OnlineIdSystemAuthenticatorForUser>(info.This());

      ::Windows::Foundation::IAsyncOperation<::Windows::Security::Authentication::OnlineId::OnlineIdSystemTicketResult^>^ op;


      if (info.Length() == 2
        && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Security::Authentication::OnlineId::OnlineIdServiceTicketRequest^>(info[0]))
      {
        try
        {
          ::Windows::Security::Authentication::OnlineId::OnlineIdServiceTicketRequest^ arg0 = UnwrapOnlineIdServiceTicketRequest(info[0]);
          
          op = wrapper->_instance->GetTicketAsync(arg0);
        }
        catch (Platform::Exception ^exception)
        {
          NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
          return;
        }
      }
 else {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found")));
        return;
      }

      auto opTask = create_task(op);
      uv_async_t* asyncToken = NodeUtils::Async::GetAsyncToken(info[info.Length() -1].As<Function>());

      opTask.then( [asyncToken] (task<::Windows::Security::Authentication::OnlineId::OnlineIdSystemTicketResult^> t) {
        try {
          auto result = t.get();
          NodeUtils::Async::RunCallbackOnMain(asyncToken, [result](NodeUtils::InvokeCallbackDelegate invokeCallback) {


            Local<Value> error;
            Local<Value> arg1;
            {
              TryCatch tryCatch;
              arg1 = WrapOnlineIdSystemTicketResult(result);
              if (tryCatch.HasCaught())
              {
                error = Nan::To<Object>(tryCatch.Exception()).ToLocalChecked();
              }
              else
              {
                error = Undefined();
              }
              if (arg1.IsEmpty()) arg1 = Undefined();
            }
            Local<Value> args[] = {error, arg1};


            invokeCallback(_countof(args), args);
          });
        } catch (Platform::Exception^ exception) {
          NodeUtils::Async::RunCallbackOnMain(asyncToken, [exception](NodeUtils::InvokeCallbackDelegate invokeCallback) {
            Local<Value> error = NodeRT::Utils::WinRtExceptionToJsError(exception);

            Local<Value> args[] = {error};
            invokeCallback(_countof(args), args);
          });
        }
      });
    }




    static void ApplicationIdGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Security::Authentication::OnlineId::OnlineIdSystemAuthenticatorForUser^>(info.This())) {
        return;
      }

      OnlineIdSystemAuthenticatorForUser *wrapper = OnlineIdSystemAuthenticatorForUser::Unwrap<OnlineIdSystemAuthenticatorForUser>(info.This());

      try  {
        ::Platform::Guid result = wrapper->_instance->ApplicationId;
        info.GetReturnValue().Set(NodeRT::Utils::GuidToJs(result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void ApplicationIdSetter(Local<String> property, Local<Value> value, const Nan::PropertyCallbackInfo<void> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsGuid(value)) {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type")));
        return;
      }

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Security::Authentication::OnlineId::OnlineIdSystemAuthenticatorForUser^>(info.This())) {
        return;
      }

      OnlineIdSystemAuthenticatorForUser *wrapper = OnlineIdSystemAuthenticatorForUser::Unwrap<OnlineIdSystemAuthenticatorForUser>(info.This());

      try {

        ::Platform::Guid winRtValue = NodeRT::Utils::GuidFromJs(value);

        wrapper->_instance->ApplicationId = winRtValue;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
      }
    }
      
    static void UserGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Security::Authentication::OnlineId::OnlineIdSystemAuthenticatorForUser^>(info.This())) {
        return;
      }

      OnlineIdSystemAuthenticatorForUser *wrapper = OnlineIdSystemAuthenticatorForUser::Unwrap<OnlineIdSystemAuthenticatorForUser>(info.This());

      try  {
        ::Windows::System::User^ result = wrapper->_instance->User;
        info.GetReturnValue().Set(NodeRT::Utils::CreateExternalWinRTObject("Windows.System", "User", result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      


    private:
      ::Windows::Security::Authentication::OnlineId::OnlineIdSystemAuthenticatorForUser^ _instance;
      static Persistent<FunctionTemplate> s_constructorTemplate;

      friend v8::Local<v8::Value> WrapOnlineIdSystemAuthenticatorForUser(::Windows::Security::Authentication::OnlineId::OnlineIdSystemAuthenticatorForUser^ wintRtInstance);
      friend ::Windows::Security::Authentication::OnlineId::OnlineIdSystemAuthenticatorForUser^ UnwrapOnlineIdSystemAuthenticatorForUser(Local<Value> value);
  };

  Persistent<FunctionTemplate> OnlineIdSystemAuthenticatorForUser::s_constructorTemplate;

  v8::Local<v8::Value> WrapOnlineIdSystemAuthenticatorForUser(::Windows::Security::Authentication::OnlineId::OnlineIdSystemAuthenticatorForUser^ winRtInstance) {
    EscapableHandleScope scope;

    if (winRtInstance == nullptr) {
      return scope.Escape(Undefined());
    }

    Local<Value> opaqueWrapper = CreateOpaqueWrapper(winRtInstance);
    Local<Value> args[] = {opaqueWrapper};
    Local<FunctionTemplate> localRef = Nan::New<FunctionTemplate>(OnlineIdSystemAuthenticatorForUser::s_constructorTemplate);
    return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked());
  }

  ::Windows::Security::Authentication::OnlineId::OnlineIdSystemAuthenticatorForUser^ UnwrapOnlineIdSystemAuthenticatorForUser(Local<Value> value) {
     return OnlineIdSystemAuthenticatorForUser::Unwrap<OnlineIdSystemAuthenticatorForUser>(Nan::To<Object>(value).ToLocalChecked())->_instance;
  }

  void InitOnlineIdSystemAuthenticatorForUser(Local<Object> exports) {
    OnlineIdSystemAuthenticatorForUser::Init(exports);
  }

  class OnlineIdSystemIdentity : public WrapperBase {
    public:
      
      static void Init(const Local<Object> exports) {
        HandleScope scope;

        Local<FunctionTemplate> localRef = Nan::New<FunctionTemplate>(New);
        s_constructorTemplate.Reset(localRef);
        localRef->SetClassName(Nan::New<String>("OnlineIdSystemIdentity").ToLocalChecked());
        localRef->InstanceTemplate()->SetInternalFieldCount(1);





          
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("id").ToLocalChecked(), IdGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("ticket").ToLocalChecked(), TicketGetter);

        Local<Object> constructor = Nan::To<Object>(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked();
        Nan::SetMethod(constructor, "castFrom", CastFrom);



        Nan::Set(exports, Nan::New<String>("OnlineIdSystemIdentity").ToLocalChecked(), constructor);
      }

      virtual ::Platform::Object^ GetObjectInstance() const override {
        return _instance;
      }

    private:

      OnlineIdSystemIdentity(::Windows::Security::Authentication::OnlineId::OnlineIdSystemIdentity^ instance) {
        _instance = instance;
      }

      
    static void New(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      Local<FunctionTemplate> localRef = Nan::New<FunctionTemplate>(s_constructorTemplate);

      // in case the constructor was called without the new operator
      if (!localRef->HasInstance(info.This())) {
        if (info.Length() > 0) {
          std::unique_ptr<Local<Value> []> constructorArgs(new Local<Value>[info.Length()]);

          Local<Value> *argsPtr = constructorArgs.get();
          for (int i = 0; i < info.Length(); i++) {
            argsPtr[i] = info[i];
          }

          MaybeLocal<Object> res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), constructorArgs.get());
          if (res.IsEmpty()) {
            return;
          }

          info.GetReturnValue().Set(res.ToLocalChecked());
          return;
        } else {
          MaybeLocal<Object> res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), nullptr);

          if (res.IsEmpty()) {
            return;
          }

          info.GetReturnValue().Set(res.ToLocalChecked());
          return;
        }
      }

      ::Windows::Security::Authentication::OnlineId::OnlineIdSystemIdentity^ winRtInstance;


      if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) &&
        NodeRT::Utils::IsWinRtWrapperOf<::Windows::Security::Authentication::OnlineId::OnlineIdSystemIdentity^>(info[0])) {
        try {
          winRtInstance = (::Windows::Security::Authentication::OnlineId::OnlineIdSystemIdentity^) NodeRT::Utils::GetObjectInstance(info[0]);
        } catch (Platform::Exception ^exception) {
          NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
          return;
        }
      }
 else {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no suitable constructor found")));
        return;
      }

      NodeRT::Utils::SetHiddenValue(info.This(), Nan::New<String>("__winRtInstance__").ToLocalChecked(), True());

      OnlineIdSystemIdentity *wrapperInstance = new OnlineIdSystemIdentity(winRtInstance);
      wrapperInstance->Wrap(info.This());

      info.GetReturnValue().Set(info.This());
    }


      
    static void CastFrom(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;
      if (info.Length() < 1 || !NodeRT::Utils::IsWinRtWrapperOf<::Windows::Security::Authentication::OnlineId::OnlineIdSystemIdentity^>(info[0])) {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no object provided, or given object could not be casted to requested type")));
        return;
      }

      ::Windows::Security::Authentication::OnlineId::OnlineIdSystemIdentity^ winRtInstance;
      try {
        winRtInstance = (::Windows::Security::Authentication::OnlineId::OnlineIdSystemIdentity^) NodeRT::Utils::GetObjectInstance(info[0]);
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }

      info.GetReturnValue().Set(WrapOnlineIdSystemIdentity(winRtInstance));
    }





    static void IdGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Security::Authentication::OnlineId::OnlineIdSystemIdentity^>(info.This())) {
        return;
      }

      OnlineIdSystemIdentity *wrapper = OnlineIdSystemIdentity::Unwrap<OnlineIdSystemIdentity>(info.This());

      try  {
        Platform::String^ result = wrapper->_instance->Id;
        info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data()));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void TicketGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Security::Authentication::OnlineId::OnlineIdSystemIdentity^>(info.This())) {
        return;
      }

      OnlineIdSystemIdentity *wrapper = OnlineIdSystemIdentity::Unwrap<OnlineIdSystemIdentity>(info.This());

      try  {
        ::Windows::Security::Authentication::OnlineId::OnlineIdServiceTicket^ result = wrapper->_instance->Ticket;
        info.GetReturnValue().Set(WrapOnlineIdServiceTicket(result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      


    private:
      ::Windows::Security::Authentication::OnlineId::OnlineIdSystemIdentity^ _instance;
      static Persistent<FunctionTemplate> s_constructorTemplate;

      friend v8::Local<v8::Value> WrapOnlineIdSystemIdentity(::Windows::Security::Authentication::OnlineId::OnlineIdSystemIdentity^ wintRtInstance);
      friend ::Windows::Security::Authentication::OnlineId::OnlineIdSystemIdentity^ UnwrapOnlineIdSystemIdentity(Local<Value> value);
  };

  Persistent<FunctionTemplate> OnlineIdSystemIdentity::s_constructorTemplate;

  v8::Local<v8::Value> WrapOnlineIdSystemIdentity(::Windows::Security::Authentication::OnlineId::OnlineIdSystemIdentity^ winRtInstance) {
    EscapableHandleScope scope;

    if (winRtInstance == nullptr) {
      return scope.Escape(Undefined());
    }

    Local<Value> opaqueWrapper = CreateOpaqueWrapper(winRtInstance);
    Local<Value> args[] = {opaqueWrapper};
    Local<FunctionTemplate> localRef = Nan::New<FunctionTemplate>(OnlineIdSystemIdentity::s_constructorTemplate);
    return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked());
  }

  ::Windows::Security::Authentication::OnlineId::OnlineIdSystemIdentity^ UnwrapOnlineIdSystemIdentity(Local<Value> value) {
     return OnlineIdSystemIdentity::Unwrap<OnlineIdSystemIdentity>(Nan::To<Object>(value).ToLocalChecked())->_instance;
  }

  void InitOnlineIdSystemIdentity(Local<Object> exports) {
    OnlineIdSystemIdentity::Init(exports);
  }

  class OnlineIdSystemTicketResult : public WrapperBase {
    public:
      
      static void Init(const Local<Object> exports) {
        HandleScope scope;

        Local<FunctionTemplate> localRef = Nan::New<FunctionTemplate>(New);
        s_constructorTemplate.Reset(localRef);
        localRef->SetClassName(Nan::New<String>("OnlineIdSystemTicketResult").ToLocalChecked());
        localRef->InstanceTemplate()->SetInternalFieldCount(1);





          
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("extendedError").ToLocalChecked(), ExtendedErrorGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("identity").ToLocalChecked(), IdentityGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("status").ToLocalChecked(), StatusGetter);

        Local<Object> constructor = Nan::To<Object>(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked();
        Nan::SetMethod(constructor, "castFrom", CastFrom);



        Nan::Set(exports, Nan::New<String>("OnlineIdSystemTicketResult").ToLocalChecked(), constructor);
      }

      virtual ::Platform::Object^ GetObjectInstance() const override {
        return _instance;
      }

    private:

      OnlineIdSystemTicketResult(::Windows::Security::Authentication::OnlineId::OnlineIdSystemTicketResult^ instance) {
        _instance = instance;
      }

      
    static void New(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      Local<FunctionTemplate> localRef = Nan::New<FunctionTemplate>(s_constructorTemplate);

      // in case the constructor was called without the new operator
      if (!localRef->HasInstance(info.This())) {
        if (info.Length() > 0) {
          std::unique_ptr<Local<Value> []> constructorArgs(new Local<Value>[info.Length()]);

          Local<Value> *argsPtr = constructorArgs.get();
          for (int i = 0; i < info.Length(); i++) {
            argsPtr[i] = info[i];
          }

          MaybeLocal<Object> res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), constructorArgs.get());
          if (res.IsEmpty()) {
            return;
          }

          info.GetReturnValue().Set(res.ToLocalChecked());
          return;
        } else {
          MaybeLocal<Object> res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), nullptr);

          if (res.IsEmpty()) {
            return;
          }

          info.GetReturnValue().Set(res.ToLocalChecked());
          return;
        }
      }

      ::Windows::Security::Authentication::OnlineId::OnlineIdSystemTicketResult^ winRtInstance;


      if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) &&
        NodeRT::Utils::IsWinRtWrapperOf<::Windows::Security::Authentication::OnlineId::OnlineIdSystemTicketResult^>(info[0])) {
        try {
          winRtInstance = (::Windows::Security::Authentication::OnlineId::OnlineIdSystemTicketResult^) NodeRT::Utils::GetObjectInstance(info[0]);
        } catch (Platform::Exception ^exception) {
          NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
          return;
        }
      }
 else {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no suitable constructor found")));
        return;
      }

      NodeRT::Utils::SetHiddenValue(info.This(), Nan::New<String>("__winRtInstance__").ToLocalChecked(), True());

      OnlineIdSystemTicketResult *wrapperInstance = new OnlineIdSystemTicketResult(winRtInstance);
      wrapperInstance->Wrap(info.This());

      info.GetReturnValue().Set(info.This());
    }


      
    static void CastFrom(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;
      if (info.Length() < 1 || !NodeRT::Utils::IsWinRtWrapperOf<::Windows::Security::Authentication::OnlineId::OnlineIdSystemTicketResult^>(info[0])) {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no object provided, or given object could not be casted to requested type")));
        return;
      }

      ::Windows::Security::Authentication::OnlineId::OnlineIdSystemTicketResult^ winRtInstance;
      try {
        winRtInstance = (::Windows::Security::Authentication::OnlineId::OnlineIdSystemTicketResult^) NodeRT::Utils::GetObjectInstance(info[0]);
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }

      info.GetReturnValue().Set(WrapOnlineIdSystemTicketResult(winRtInstance));
    }





    static void ExtendedErrorGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Security::Authentication::OnlineId::OnlineIdSystemTicketResult^>(info.This())) {
        return;
      }

      OnlineIdSystemTicketResult *wrapper = OnlineIdSystemTicketResult::Unwrap<OnlineIdSystemTicketResult>(info.This());

      try  {
        ::Windows::Foundation::HResult result = wrapper->_instance->ExtendedError;
        info.GetReturnValue().Set(Nan::New<Integer>(result.Value));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void IdentityGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Security::Authentication::OnlineId::OnlineIdSystemTicketResult^>(info.This())) {
        return;
      }

      OnlineIdSystemTicketResult *wrapper = OnlineIdSystemTicketResult::Unwrap<OnlineIdSystemTicketResult>(info.This());

      try  {
        ::Windows::Security::Authentication::OnlineId::OnlineIdSystemIdentity^ result = wrapper->_instance->Identity;
        info.GetReturnValue().Set(WrapOnlineIdSystemIdentity(result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void StatusGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Security::Authentication::OnlineId::OnlineIdSystemTicketResult^>(info.This())) {
        return;
      }

      OnlineIdSystemTicketResult *wrapper = OnlineIdSystemTicketResult::Unwrap<OnlineIdSystemTicketResult>(info.This());

      try  {
        ::Windows::Security::Authentication::OnlineId::OnlineIdSystemTicketStatus result = wrapper->_instance->Status;
        info.GetReturnValue().Set(Nan::New<Integer>(static_cast<int>(result)));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      


    private:
      ::Windows::Security::Authentication::OnlineId::OnlineIdSystemTicketResult^ _instance;
      static Persistent<FunctionTemplate> s_constructorTemplate;

      friend v8::Local<v8::Value> WrapOnlineIdSystemTicketResult(::Windows::Security::Authentication::OnlineId::OnlineIdSystemTicketResult^ wintRtInstance);
      friend ::Windows::Security::Authentication::OnlineId::OnlineIdSystemTicketResult^ UnwrapOnlineIdSystemTicketResult(Local<Value> value);
  };

  Persistent<FunctionTemplate> OnlineIdSystemTicketResult::s_constructorTemplate;

  v8::Local<v8::Value> WrapOnlineIdSystemTicketResult(::Windows::Security::Authentication::OnlineId::OnlineIdSystemTicketResult^ winRtInstance) {
    EscapableHandleScope scope;

    if (winRtInstance == nullptr) {
      return scope.Escape(Undefined());
    }

    Local<Value> opaqueWrapper = CreateOpaqueWrapper(winRtInstance);
    Local<Value> args[] = {opaqueWrapper};
    Local<FunctionTemplate> localRef = Nan::New<FunctionTemplate>(OnlineIdSystemTicketResult::s_constructorTemplate);
    return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked());
  }

  ::Windows::Security::Authentication::OnlineId::OnlineIdSystemTicketResult^ UnwrapOnlineIdSystemTicketResult(Local<Value> value) {
     return OnlineIdSystemTicketResult::Unwrap<OnlineIdSystemTicketResult>(Nan::To<Object>(value).ToLocalChecked())->_instance;
  }

  void InitOnlineIdSystemTicketResult(Local<Object> exports) {
    OnlineIdSystemTicketResult::Init(exports);
  }

  class SignOutUserOperation : public WrapperBase {
    public:
      
      static void Init(const Local<Object> exports) {
        HandleScope scope;

        Local<FunctionTemplate> localRef = Nan::New<FunctionTemplate>(New);
        s_constructorTemplate.Reset(localRef);
        localRef->SetClassName(Nan::New<String>("SignOutUserOperation").ToLocalChecked());
        localRef->InstanceTemplate()->SetInternalFieldCount(1);


          
            Nan::SetPrototypeMethod(localRef, "getResults", GetResults);
            Nan::SetPrototypeMethod(localRef, "cancel", Cancel);
            Nan::SetPrototypeMethod(localRef, "close", Close);
          



          
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("errorCode").ToLocalChecked(), ErrorCodeGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("id").ToLocalChecked(), IdGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("status").ToLocalChecked(), StatusGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("completed").ToLocalChecked(), CompletedGetter, CompletedSetter);

        Local<Object> constructor = Nan::To<Object>(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked();
        Nan::SetMethod(constructor, "castFrom", CastFrom);



        Nan::Set(exports, Nan::New<String>("SignOutUserOperation").ToLocalChecked(), constructor);
      }

      virtual ::Platform::Object^ GetObjectInstance() const override {
        return _instance;
      }

    private:

      SignOutUserOperation(::Windows::Security::Authentication::OnlineId::SignOutUserOperation^ instance) {
        _instance = instance;
      }

      
    static void New(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      Local<FunctionTemplate> localRef = Nan::New<FunctionTemplate>(s_constructorTemplate);

      // in case the constructor was called without the new operator
      if (!localRef->HasInstance(info.This())) {
        if (info.Length() > 0) {
          std::unique_ptr<Local<Value> []> constructorArgs(new Local<Value>[info.Length()]);

          Local<Value> *argsPtr = constructorArgs.get();
          for (int i = 0; i < info.Length(); i++) {
            argsPtr[i] = info[i];
          }

          MaybeLocal<Object> res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), constructorArgs.get());
          if (res.IsEmpty()) {
            return;
          }

          info.GetReturnValue().Set(res.ToLocalChecked());
          return;
        } else {
          MaybeLocal<Object> res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), nullptr);

          if (res.IsEmpty()) {
            return;
          }

          info.GetReturnValue().Set(res.ToLocalChecked());
          return;
        }
      }

      ::Windows::Security::Authentication::OnlineId::SignOutUserOperation^ winRtInstance;


      if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) &&
        NodeRT::Utils::IsWinRtWrapperOf<::Windows::Security::Authentication::OnlineId::SignOutUserOperation^>(info[0])) {
        try {
          winRtInstance = (::Windows::Security::Authentication::OnlineId::SignOutUserOperation^) NodeRT::Utils::GetObjectInstance(info[0]);
        } catch (Platform::Exception ^exception) {
          NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
          return;
        }
      }
 else {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no suitable constructor found")));
        return;
      }

      NodeRT::Utils::SetHiddenValue(info.This(), Nan::New<String>("__winRtInstance__").ToLocalChecked(), True());

      SignOutUserOperation *wrapperInstance = new SignOutUserOperation(winRtInstance);
      wrapperInstance->Wrap(info.This());

      info.GetReturnValue().Set(info.This());
    }


      
    static void CastFrom(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;
      if (info.Length() < 1 || !NodeRT::Utils::IsWinRtWrapperOf<::Windows::Security::Authentication::OnlineId::SignOutUserOperation^>(info[0])) {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no object provided, or given object could not be casted to requested type")));
        return;
      }

      ::Windows::Security::Authentication::OnlineId::SignOutUserOperation^ winRtInstance;
      try {
        winRtInstance = (::Windows::Security::Authentication::OnlineId::SignOutUserOperation^) NodeRT::Utils::GetObjectInstance(info[0]);
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }

      info.GetReturnValue().Set(WrapSignOutUserOperation(winRtInstance));
    }


    static void GetResults(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Security::Authentication::OnlineId::SignOutUserOperation^>(info.This())) {
        return;
      }

      SignOutUserOperation *wrapper = SignOutUserOperation::Unwrap<SignOutUserOperation>(info.This());

      if (info.Length() == 0)
      {
        try
        {
          wrapper->_instance->GetResults();
          return;
        } catch (Platform::Exception ^exception) {
          NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
          return;
        }
      }
 else {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found")));
        return;
      }
    }
    static void Cancel(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Security::Authentication::OnlineId::SignOutUserOperation^>(info.This())) {
        return;
      }

      SignOutUserOperation *wrapper = SignOutUserOperation::Unwrap<SignOutUserOperation>(info.This());

      if (info.Length() == 0)
      {
        try
        {
          wrapper->_instance->Cancel();
          return;
        } catch (Platform::Exception ^exception) {
          NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
          return;
        }
      }
 else {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found")));
        return;
      }
    }
    static void Close(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Security::Authentication::OnlineId::SignOutUserOperation^>(info.This())) {
        return;
      }

      SignOutUserOperation *wrapper = SignOutUserOperation::Unwrap<SignOutUserOperation>(info.This());

      if (info.Length() == 0)
      {
        try
        {
          wrapper->_instance->Close();
          return;
        } catch (Platform::Exception ^exception) {
          NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
          return;
        }
      }
 else {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found")));
        return;
      }
    }



    static void ErrorCodeGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Security::Authentication::OnlineId::SignOutUserOperation^>(info.This())) {
        return;
      }

      SignOutUserOperation *wrapper = SignOutUserOperation::Unwrap<SignOutUserOperation>(info.This());

      try  {
        ::Windows::Foundation::HResult result = wrapper->_instance->ErrorCode;
        info.GetReturnValue().Set(Nan::New<Integer>(result.Value));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void IdGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Security::Authentication::OnlineId::SignOutUserOperation^>(info.This())) {
        return;
      }

      SignOutUserOperation *wrapper = SignOutUserOperation::Unwrap<SignOutUserOperation>(info.This());

      try  {
        unsigned int result = wrapper->_instance->Id;
        info.GetReturnValue().Set(Nan::New<Integer>(result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void StatusGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Security::Authentication::OnlineId::SignOutUserOperation^>(info.This())) {
        return;
      }

      SignOutUserOperation *wrapper = SignOutUserOperation::Unwrap<SignOutUserOperation>(info.This());

      try  {
        ::Windows::Foundation::AsyncStatus result = wrapper->_instance->Status;
        info.GetReturnValue().Set(Nan::New<Integer>(static_cast<int>(result)));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void CompletedGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Security::Authentication::OnlineId::SignOutUserOperation^>(info.This())) {
        return;
      }

      SignOutUserOperation *wrapper = SignOutUserOperation::Unwrap<SignOutUserOperation>(info.This());

      try  {
        ::Windows::Foundation::AsyncActionCompletedHandler^ result = wrapper->_instance->Completed;
        info.GetReturnValue().Set(NodeRT::Utils::CreateExternalWinRTObject("Windows.Foundation", "AsyncActionCompletedHandler", result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void CompletedSetter(Local<String> property, Local<Value> value, const Nan::PropertyCallbackInfo<void> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Foundation::AsyncActionCompletedHandler^>(value)) {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type")));
        return;
      }

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Security::Authentication::OnlineId::SignOutUserOperation^>(info.This())) {
        return;
      }

      SignOutUserOperation *wrapper = SignOutUserOperation::Unwrap<SignOutUserOperation>(info.This());

      try {

        ::Windows::Foundation::AsyncActionCompletedHandler^ winRtValue = dynamic_cast<::Windows::Foundation::AsyncActionCompletedHandler^>(NodeRT::Utils::GetObjectInstance(value));

        wrapper->_instance->Completed = winRtValue;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
      }
    }
      


    private:
      ::Windows::Security::Authentication::OnlineId::SignOutUserOperation^ _instance;
      static Persistent<FunctionTemplate> s_constructorTemplate;

      friend v8::Local<v8::Value> WrapSignOutUserOperation(::Windows::Security::Authentication::OnlineId::SignOutUserOperation^ wintRtInstance);
      friend ::Windows::Security::Authentication::OnlineId::SignOutUserOperation^ UnwrapSignOutUserOperation(Local<Value> value);
  };

  Persistent<FunctionTemplate> SignOutUserOperation::s_constructorTemplate;

  v8::Local<v8::Value> WrapSignOutUserOperation(::Windows::Security::Authentication::OnlineId::SignOutUserOperation^ winRtInstance) {
    EscapableHandleScope scope;

    if (winRtInstance == nullptr) {
      return scope.Escape(Undefined());
    }

    Local<Value> opaqueWrapper = CreateOpaqueWrapper(winRtInstance);
    Local<Value> args[] = {opaqueWrapper};
    Local<FunctionTemplate> localRef = Nan::New<FunctionTemplate>(SignOutUserOperation::s_constructorTemplate);
    return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked());
  }

  ::Windows::Security::Authentication::OnlineId::SignOutUserOperation^ UnwrapSignOutUserOperation(Local<Value> value) {
     return SignOutUserOperation::Unwrap<SignOutUserOperation>(Nan::To<Object>(value).ToLocalChecked())->_instance;
  }

  void InitSignOutUserOperation(Local<Object> exports) {
    SignOutUserOperation::Init(exports);
  }

  class UserAuthenticationOperation : public WrapperBase {
    public:
      
      static void Init(const Local<Object> exports) {
        HandleScope scope;

        Local<FunctionTemplate> localRef = Nan::New<FunctionTemplate>(New);
        s_constructorTemplate.Reset(localRef);
        localRef->SetClassName(Nan::New<String>("UserAuthenticationOperation").ToLocalChecked());
        localRef->InstanceTemplate()->SetInternalFieldCount(1);


          
            Nan::SetPrototypeMethod(localRef, "getResults", GetResults);
            Nan::SetPrototypeMethod(localRef, "cancel", Cancel);
            Nan::SetPrototypeMethod(localRef, "close", Close);
          



          
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("errorCode").ToLocalChecked(), ErrorCodeGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("id").ToLocalChecked(), IdGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("status").ToLocalChecked(), StatusGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("completed").ToLocalChecked(), CompletedGetter, CompletedSetter);

        Local<Object> constructor = Nan::To<Object>(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked();
        Nan::SetMethod(constructor, "castFrom", CastFrom);



        Nan::Set(exports, Nan::New<String>("UserAuthenticationOperation").ToLocalChecked(), constructor);
      }

      virtual ::Platform::Object^ GetObjectInstance() const override {
        return _instance;
      }

    private:

      UserAuthenticationOperation(::Windows::Security::Authentication::OnlineId::UserAuthenticationOperation^ instance) {
        _instance = instance;
      }

      
    static void New(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      Local<FunctionTemplate> localRef = Nan::New<FunctionTemplate>(s_constructorTemplate);

      // in case the constructor was called without the new operator
      if (!localRef->HasInstance(info.This())) {
        if (info.Length() > 0) {
          std::unique_ptr<Local<Value> []> constructorArgs(new Local<Value>[info.Length()]);

          Local<Value> *argsPtr = constructorArgs.get();
          for (int i = 0; i < info.Length(); i++) {
            argsPtr[i] = info[i];
          }

          MaybeLocal<Object> res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), constructorArgs.get());
          if (res.IsEmpty()) {
            return;
          }

          info.GetReturnValue().Set(res.ToLocalChecked());
          return;
        } else {
          MaybeLocal<Object> res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), nullptr);

          if (res.IsEmpty()) {
            return;
          }

          info.GetReturnValue().Set(res.ToLocalChecked());
          return;
        }
      }

      ::Windows::Security::Authentication::OnlineId::UserAuthenticationOperation^ winRtInstance;


      if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) &&
        NodeRT::Utils::IsWinRtWrapperOf<::Windows::Security::Authentication::OnlineId::UserAuthenticationOperation^>(info[0])) {
        try {
          winRtInstance = (::Windows::Security::Authentication::OnlineId::UserAuthenticationOperation^) NodeRT::Utils::GetObjectInstance(info[0]);
        } catch (Platform::Exception ^exception) {
          NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
          return;
        }
      }
 else {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no suitable constructor found")));
        return;
      }

      NodeRT::Utils::SetHiddenValue(info.This(), Nan::New<String>("__winRtInstance__").ToLocalChecked(), True());

      UserAuthenticationOperation *wrapperInstance = new UserAuthenticationOperation(winRtInstance);
      wrapperInstance->Wrap(info.This());

      info.GetReturnValue().Set(info.This());
    }


      
    static void CastFrom(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;
      if (info.Length() < 1 || !NodeRT::Utils::IsWinRtWrapperOf<::Windows::Security::Authentication::OnlineId::UserAuthenticationOperation^>(info[0])) {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no object provided, or given object could not be casted to requested type")));
        return;
      }

      ::Windows::Security::Authentication::OnlineId::UserAuthenticationOperation^ winRtInstance;
      try {
        winRtInstance = (::Windows::Security::Authentication::OnlineId::UserAuthenticationOperation^) NodeRT::Utils::GetObjectInstance(info[0]);
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }

      info.GetReturnValue().Set(WrapUserAuthenticationOperation(winRtInstance));
    }


    static void GetResults(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Security::Authentication::OnlineId::UserAuthenticationOperation^>(info.This())) {
        return;
      }

      UserAuthenticationOperation *wrapper = UserAuthenticationOperation::Unwrap<UserAuthenticationOperation>(info.This());

      if (info.Length() == 0)
      {
        try
        {
          ::Windows::Security::Authentication::OnlineId::UserIdentity^ result;
          result = wrapper->_instance->GetResults();
          info.GetReturnValue().Set(WrapUserIdentity(result));
          return;
        } catch (Platform::Exception ^exception) {
          NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
          return;
        }
      }
 else {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found")));
        return;
      }
    }
    static void Cancel(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Security::Authentication::OnlineId::UserAuthenticationOperation^>(info.This())) {
        return;
      }

      UserAuthenticationOperation *wrapper = UserAuthenticationOperation::Unwrap<UserAuthenticationOperation>(info.This());

      if (info.Length() == 0)
      {
        try
        {
          wrapper->_instance->Cancel();
          return;
        } catch (Platform::Exception ^exception) {
          NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
          return;
        }
      }
 else {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found")));
        return;
      }
    }
    static void Close(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Security::Authentication::OnlineId::UserAuthenticationOperation^>(info.This())) {
        return;
      }

      UserAuthenticationOperation *wrapper = UserAuthenticationOperation::Unwrap<UserAuthenticationOperation>(info.This());

      if (info.Length() == 0)
      {
        try
        {
          wrapper->_instance->Close();
          return;
        } catch (Platform::Exception ^exception) {
          NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
          return;
        }
      }
 else {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found")));
        return;
      }
    }



    static void ErrorCodeGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Security::Authentication::OnlineId::UserAuthenticationOperation^>(info.This())) {
        return;
      }

      UserAuthenticationOperation *wrapper = UserAuthenticationOperation::Unwrap<UserAuthenticationOperation>(info.This());

      try  {
        ::Windows::Foundation::HResult result = wrapper->_instance->ErrorCode;
        info.GetReturnValue().Set(Nan::New<Integer>(result.Value));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void IdGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Security::Authentication::OnlineId::UserAuthenticationOperation^>(info.This())) {
        return;
      }

      UserAuthenticationOperation *wrapper = UserAuthenticationOperation::Unwrap<UserAuthenticationOperation>(info.This());

      try  {
        unsigned int result = wrapper->_instance->Id;
        info.GetReturnValue().Set(Nan::New<Integer>(result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void StatusGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Security::Authentication::OnlineId::UserAuthenticationOperation^>(info.This())) {
        return;
      }

      UserAuthenticationOperation *wrapper = UserAuthenticationOperation::Unwrap<UserAuthenticationOperation>(info.This());

      try  {
        ::Windows::Foundation::AsyncStatus result = wrapper->_instance->Status;
        info.GetReturnValue().Set(Nan::New<Integer>(static_cast<int>(result)));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void CompletedGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Security::Authentication::OnlineId::UserAuthenticationOperation^>(info.This())) {
        return;
      }

      UserAuthenticationOperation *wrapper = UserAuthenticationOperation::Unwrap<UserAuthenticationOperation>(info.This());

      try  {
        ::Windows::Foundation::AsyncOperationCompletedHandler<::Windows::Security::Authentication::OnlineId::UserIdentity^>^ result = wrapper->_instance->Completed;
        info.GetReturnValue().Set(NodeRT::Utils::CreateExternalWinRTObject("Windows.Foundation", "AsyncOperationCompletedHandler`1", result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void CompletedSetter(Local<String> property, Local<Value> value, const Nan::PropertyCallbackInfo<void> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Foundation::AsyncOperationCompletedHandler<::Windows::Security::Authentication::OnlineId::UserIdentity^>^>(value)) {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type")));
        return;
      }

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Security::Authentication::OnlineId::UserAuthenticationOperation^>(info.This())) {
        return;
      }

      UserAuthenticationOperation *wrapper = UserAuthenticationOperation::Unwrap<UserAuthenticationOperation>(info.This());

      try {

        ::Windows::Foundation::AsyncOperationCompletedHandler<::Windows::Security::Authentication::OnlineId::UserIdentity^>^ winRtValue = dynamic_cast<::Windows::Foundation::AsyncOperationCompletedHandler<::Windows::Security::Authentication::OnlineId::UserIdentity^>^>(NodeRT::Utils::GetObjectInstance(value));

        wrapper->_instance->Completed = winRtValue;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
      }
    }
      


    private:
      ::Windows::Security::Authentication::OnlineId::UserAuthenticationOperation^ _instance;
      static Persistent<FunctionTemplate> s_constructorTemplate;

      friend v8::Local<v8::Value> WrapUserAuthenticationOperation(::Windows::Security::Authentication::OnlineId::UserAuthenticationOperation^ wintRtInstance);
      friend ::Windows::Security::Authentication::OnlineId::UserAuthenticationOperation^ UnwrapUserAuthenticationOperation(Local<Value> value);
  };

  Persistent<FunctionTemplate> UserAuthenticationOperation::s_constructorTemplate;

  v8::Local<v8::Value> WrapUserAuthenticationOperation(::Windows::Security::Authentication::OnlineId::UserAuthenticationOperation^ winRtInstance) {
    EscapableHandleScope scope;

    if (winRtInstance == nullptr) {
      return scope.Escape(Undefined());
    }

    Local<Value> opaqueWrapper = CreateOpaqueWrapper(winRtInstance);
    Local<Value> args[] = {opaqueWrapper};
    Local<FunctionTemplate> localRef = Nan::New<FunctionTemplate>(UserAuthenticationOperation::s_constructorTemplate);
    return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked());
  }

  ::Windows::Security::Authentication::OnlineId::UserAuthenticationOperation^ UnwrapUserAuthenticationOperation(Local<Value> value) {
     return UserAuthenticationOperation::Unwrap<UserAuthenticationOperation>(Nan::To<Object>(value).ToLocalChecked())->_instance;
  }

  void InitUserAuthenticationOperation(Local<Object> exports) {
    UserAuthenticationOperation::Init(exports);
  }

  class UserIdentity : public WrapperBase {
    public:
      
      static void Init(const Local<Object> exports) {
        HandleScope scope;

        Local<FunctionTemplate> localRef = Nan::New<FunctionTemplate>(New);
        s_constructorTemplate.Reset(localRef);
        localRef->SetClassName(Nan::New<String>("UserIdentity").ToLocalChecked());
        localRef->InstanceTemplate()->SetInternalFieldCount(1);





          
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("firstName").ToLocalChecked(), FirstNameGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("id").ToLocalChecked(), IdGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("isBetaAccount").ToLocalChecked(), IsBetaAccountGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("isConfirmedPC").ToLocalChecked(), IsConfirmedPCGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("lastName").ToLocalChecked(), LastNameGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("safeCustomerId").ToLocalChecked(), SafeCustomerIdGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("signInName").ToLocalChecked(), SignInNameGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("tickets").ToLocalChecked(), TicketsGetter);

        Local<Object> constructor = Nan::To<Object>(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked();
        Nan::SetMethod(constructor, "castFrom", CastFrom);



        Nan::Set(exports, Nan::New<String>("UserIdentity").ToLocalChecked(), constructor);
      }

      virtual ::Platform::Object^ GetObjectInstance() const override {
        return _instance;
      }

    private:

      UserIdentity(::Windows::Security::Authentication::OnlineId::UserIdentity^ instance) {
        _instance = instance;
      }

      
    static void New(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      Local<FunctionTemplate> localRef = Nan::New<FunctionTemplate>(s_constructorTemplate);

      // in case the constructor was called without the new operator
      if (!localRef->HasInstance(info.This())) {
        if (info.Length() > 0) {
          std::unique_ptr<Local<Value> []> constructorArgs(new Local<Value>[info.Length()]);

          Local<Value> *argsPtr = constructorArgs.get();
          for (int i = 0; i < info.Length(); i++) {
            argsPtr[i] = info[i];
          }

          MaybeLocal<Object> res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), constructorArgs.get());
          if (res.IsEmpty()) {
            return;
          }

          info.GetReturnValue().Set(res.ToLocalChecked());
          return;
        } else {
          MaybeLocal<Object> res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), nullptr);

          if (res.IsEmpty()) {
            return;
          }

          info.GetReturnValue().Set(res.ToLocalChecked());
          return;
        }
      }

      ::Windows::Security::Authentication::OnlineId::UserIdentity^ winRtInstance;


      if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) &&
        NodeRT::Utils::IsWinRtWrapperOf<::Windows::Security::Authentication::OnlineId::UserIdentity^>(info[0])) {
        try {
          winRtInstance = (::Windows::Security::Authentication::OnlineId::UserIdentity^) NodeRT::Utils::GetObjectInstance(info[0]);
        } catch (Platform::Exception ^exception) {
          NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
          return;
        }
      }
 else {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no suitable constructor found")));
        return;
      }

      NodeRT::Utils::SetHiddenValue(info.This(), Nan::New<String>("__winRtInstance__").ToLocalChecked(), True());

      UserIdentity *wrapperInstance = new UserIdentity(winRtInstance);
      wrapperInstance->Wrap(info.This());

      info.GetReturnValue().Set(info.This());
    }


      
    static void CastFrom(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;
      if (info.Length() < 1 || !NodeRT::Utils::IsWinRtWrapperOf<::Windows::Security::Authentication::OnlineId::UserIdentity^>(info[0])) {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no object provided, or given object could not be casted to requested type")));
        return;
      }

      ::Windows::Security::Authentication::OnlineId::UserIdentity^ winRtInstance;
      try {
        winRtInstance = (::Windows::Security::Authentication::OnlineId::UserIdentity^) NodeRT::Utils::GetObjectInstance(info[0]);
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }

      info.GetReturnValue().Set(WrapUserIdentity(winRtInstance));
    }





    static void FirstNameGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Security::Authentication::OnlineId::UserIdentity^>(info.This())) {
        return;
      }

      UserIdentity *wrapper = UserIdentity::Unwrap<UserIdentity>(info.This());

      try  {
        Platform::String^ result = wrapper->_instance->FirstName;
        info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data()));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void IdGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Security::Authentication::OnlineId::UserIdentity^>(info.This())) {
        return;
      }

      UserIdentity *wrapper = UserIdentity::Unwrap<UserIdentity>(info.This());

      try  {
        Platform::String^ result = wrapper->_instance->Id;
        info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data()));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void IsBetaAccountGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Security::Authentication::OnlineId::UserIdentity^>(info.This())) {
        return;
      }

      UserIdentity *wrapper = UserIdentity::Unwrap<UserIdentity>(info.This());

      try  {
        bool result = wrapper->_instance->IsBetaAccount;
        info.GetReturnValue().Set(Nan::New<Boolean>(result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void IsConfirmedPCGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Security::Authentication::OnlineId::UserIdentity^>(info.This())) {
        return;
      }

      UserIdentity *wrapper = UserIdentity::Unwrap<UserIdentity>(info.This());

      try  {
        bool result = wrapper->_instance->IsConfirmedPC;
        info.GetReturnValue().Set(Nan::New<Boolean>(result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void LastNameGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Security::Authentication::OnlineId::UserIdentity^>(info.This())) {
        return;
      }

      UserIdentity *wrapper = UserIdentity::Unwrap<UserIdentity>(info.This());

      try  {
        Platform::String^ result = wrapper->_instance->LastName;
        info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data()));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void SafeCustomerIdGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Security::Authentication::OnlineId::UserIdentity^>(info.This())) {
        return;
      }

      UserIdentity *wrapper = UserIdentity::Unwrap<UserIdentity>(info.This());

      try  {
        Platform::String^ result = wrapper->_instance->SafeCustomerId;
        info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data()));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void SignInNameGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Security::Authentication::OnlineId::UserIdentity^>(info.This())) {
        return;
      }

      UserIdentity *wrapper = UserIdentity::Unwrap<UserIdentity>(info.This());

      try  {
        Platform::String^ result = wrapper->_instance->SignInName;
        info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data()));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void TicketsGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Security::Authentication::OnlineId::UserIdentity^>(info.This())) {
        return;
      }

      UserIdentity *wrapper = UserIdentity::Unwrap<UserIdentity>(info.This());

      try  {
        ::Windows::Foundation::Collections::IVectorView<::Windows::Security::Authentication::OnlineId::OnlineIdServiceTicket^>^ result = wrapper->_instance->Tickets;
        info.GetReturnValue().Set(NodeRT::Collections::VectorViewWrapper<::Windows::Security::Authentication::OnlineId::OnlineIdServiceTicket^>::CreateVectorViewWrapper(result, 
            [](::Windows::Security::Authentication::OnlineId::OnlineIdServiceTicket^ val) -> Local<Value> {
              return WrapOnlineIdServiceTicket(val);
            },
            [](Local<Value> value) -> bool {
              return NodeRT::Utils::IsWinRtWrapperOf<::Windows::Security::Authentication::OnlineId::OnlineIdServiceTicket^>(value);
            },
            [](Local<Value> value) -> ::Windows::Security::Authentication::OnlineId::OnlineIdServiceTicket^ {
              return UnwrapOnlineIdServiceTicket(value);
            }
          ));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      


    private:
      ::Windows::Security::Authentication::OnlineId::UserIdentity^ _instance;
      static Persistent<FunctionTemplate> s_constructorTemplate;

      friend v8::Local<v8::Value> WrapUserIdentity(::Windows::Security::Authentication::OnlineId::UserIdentity^ wintRtInstance);
      friend ::Windows::Security::Authentication::OnlineId::UserIdentity^ UnwrapUserIdentity(Local<Value> value);
  };

  Persistent<FunctionTemplate> UserIdentity::s_constructorTemplate;

  v8::Local<v8::Value> WrapUserIdentity(::Windows::Security::Authentication::OnlineId::UserIdentity^ winRtInstance) {
    EscapableHandleScope scope;

    if (winRtInstance == nullptr) {
      return scope.Escape(Undefined());
    }

    Local<Value> opaqueWrapper = CreateOpaqueWrapper(winRtInstance);
    Local<Value> args[] = {opaqueWrapper};
    Local<FunctionTemplate> localRef = Nan::New<FunctionTemplate>(UserIdentity::s_constructorTemplate);
    return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked());
  }

  ::Windows::Security::Authentication::OnlineId::UserIdentity^ UnwrapUserIdentity(Local<Value> value) {
     return UserIdentity::Unwrap<UserIdentity>(Nan::To<Object>(value).ToLocalChecked())->_instance;
  }

  void InitUserIdentity(Local<Object> exports) {
    UserIdentity::Init(exports);
  }


} } } } } 

NAN_MODULE_INIT(init) {
  // We ignore failures for now since it probably means that
  // the initialization already happened for STA, and that's cool

  CoInitializeEx(nullptr, COINIT_MULTITHREADED);

  /*
  if (FAILED(CoInitializeEx(nullptr, COINIT_MULTITHREADED))) {
    Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"error in CoInitializeEx()")));
    return;
  }
  */

      NodeRT::Windows::Security::Authentication::OnlineId::InitCredentialPromptTypeEnum(target);
      NodeRT::Windows::Security::Authentication::OnlineId::InitOnlineIdSystemTicketStatusEnum(target);
      NodeRT::Windows::Security::Authentication::OnlineId::InitOnlineIdAuthenticator(target);
      NodeRT::Windows::Security::Authentication::OnlineId::InitOnlineIdServiceTicket(target);
      NodeRT::Windows::Security::Authentication::OnlineId::InitOnlineIdServiceTicketRequest(target);
      NodeRT::Windows::Security::Authentication::OnlineId::InitOnlineIdSystemAuthenticator(target);
      NodeRT::Windows::Security::Authentication::OnlineId::InitOnlineIdSystemAuthenticatorForUser(target);
      NodeRT::Windows::Security::Authentication::OnlineId::InitOnlineIdSystemIdentity(target);
      NodeRT::Windows::Security::Authentication::OnlineId::InitOnlineIdSystemTicketResult(target);
      NodeRT::Windows::Security::Authentication::OnlineId::InitSignOutUserOperation(target);
      NodeRT::Windows::Security::Authentication::OnlineId::InitUserAuthenticationOperation(target);
      NodeRT::Windows::Security::Authentication::OnlineId::InitUserIdentity(target);


  NodeRT::Utils::RegisterNameSpace("Windows.Security.Authentication.OnlineId", target);
}



NODE_MODULE(binding, init)
