security_buffer.h 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. #ifndef SECURITY_BUFFER_H
  2. #define SECURITY_BUFFER_H
  3. #include <node.h>
  4. #include <node_object_wrap.h>
  5. #include <v8.h>
  6. #define SECURITY_WIN32 1
  7. #include <winsock2.h>
  8. #include <windows.h>
  9. #include <sspi.h>
  10. #include <nan.h>
  11. using namespace v8;
  12. using namespace node;
  13. class SecurityBuffer : public Nan::ObjectWrap {
  14. public:
  15. SecurityBuffer(uint32_t security_type, size_t size);
  16. SecurityBuffer(uint32_t security_type, size_t size, void *data);
  17. ~SecurityBuffer();
  18. // Internal values
  19. void *data;
  20. size_t size;
  21. uint32_t security_type;
  22. SecBuffer sec_buffer;
  23. // Has instance check
  24. static inline bool HasInstance(Local<Value> val) {
  25. if (!val->IsObject()) return false;
  26. Local<Object> obj = val->ToObject();
  27. return Nan::New(constructor_template)->HasInstance(obj);
  28. };
  29. // Functions available from V8
  30. static void Initialize(Nan::ADDON_REGISTER_FUNCTION_ARGS_TYPE target);
  31. static NAN_METHOD(ToBuffer);
  32. // Constructor used for creating new Long objects from C++
  33. static Nan::Persistent<FunctionTemplate> constructor_template;
  34. private:
  35. static NAN_METHOD(New);
  36. };
  37. #endif