#ifndef ODIN_NODEJS_ODINCIPHER_H
#define ODIN_NODEJS_ODINCIPHER_H

#include <napi.h>
#include <odin_crypto.h>

class OdinCipherWrapper : public Napi::ObjectWrap<OdinCipherWrapper> {
public:
    OdinCipherWrapper(const Napi::CallbackInfo& info);
    static Napi::Object Init(Napi::Env env, Napi::Object exports);
    static Napi::Value CreateNewItem(const Napi::CallbackInfo& info);

    struct OdinCipher* GetCipher() const { return _cipher; }
    
    /**
     * Transfer ownership of the cipher to the room.
     * After calling this, the wrapper will no longer try to free the cipher
     * in its destructor (the room now owns it).
     */
    void TransferOwnership() { _cipher = nullptr; }
    
    void Finalize(Napi::Env env) override;

private:
    static Napi::FunctionReference *constructor;
    struct OdinCipher* _cipher;

    void SetPassword(const Napi::CallbackInfo& info);
    Napi::Value GetPeerStatus(const Napi::CallbackInfo& info);
};

#endif //ODIN_NODEJS_ODINCIPHER_H
