cpp
This commit is contained in:
33
jtlsrv-cpp/src/pairing.hpp
Normal file
33
jtlsrv-cpp/src/pairing.hpp
Normal file
@@ -0,0 +1,33 @@
|
||||
#pragma once
|
||||
|
||||
// In-memory pairing store - trivial port of src/pairing.js
|
||||
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
#include <cstdint>
|
||||
|
||||
struct PairingEntry {
|
||||
std::string code;
|
||||
std::string name;
|
||||
uint64_t created_at;
|
||||
};
|
||||
|
||||
struct DeviceEntry {
|
||||
std::string name;
|
||||
std::string token;
|
||||
uint64_t created_at;
|
||||
};
|
||||
|
||||
class PairingStore {
|
||||
public:
|
||||
void set_pairing_code(const std::string& code, const std::string& name = "JTL-POS");
|
||||
void revoke_pairing_code(const std::string& code);
|
||||
bool has_pairing_code(const std::string& code) const;
|
||||
|
||||
void register_device(const std::string& token, const std::string& name = "JTL-POS");
|
||||
const std::unordered_map<std::string, DeviceEntry>& get_paired_devices() const;
|
||||
|
||||
private:
|
||||
std::unordered_map<std::string, PairingEntry> auth_codes_;
|
||||
std::unordered_map<std::string, DeviceEntry> paired_devices_;
|
||||
};
|
||||
Reference in New Issue
Block a user