Line data Source code
1 : /*
2 : * Copyright (C) 2004-2026 Savoir-faire Linux Inc.
3 : *
4 : * This program is free software: you can redistribute it and/or modify
5 : * it under the terms of the GNU General Public License as published by
6 : * the Free Software Foundation, either version 3 of the License, or
7 : * (at your option) any later version.
8 : *
9 : * This program is distributed in the hope that it will be useful,
10 : * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 : * GNU General Public License for more details.
13 : *
14 : * You should have received a copy of the GNU General Public License
15 : * along with this program. If not, see <https://www.gnu.org/licenses/>.
16 : */
17 :
18 : #include "swarm_protocol.h"
19 :
20 : namespace jami {
21 : namespace swarm_protocol {
22 :
23 : static constexpr std::string_view MOBILE_LEASE_SIGNATURE_DOMAIN {"DRT-MOBILE"};
24 :
25 : dht::Blob
26 30 : mobileLeasePayload(const MobileLease& lease)
27 : {
28 : // The fixed-schema array makes field order and scalar encodings deterministic.
29 30 : msgpack::sbuffer buffer;
30 30 : msgpack::packer<msgpack::sbuffer> packer(&buffer);
31 30 : packer.pack_array(7);
32 30 : packer.pack(MOBILE_LEASE_SIGNATURE_DOMAIN);
33 30 : packer.pack(lease.format_version);
34 30 : packer.pack(lease.conversation_id);
35 30 : packer.pack(lease.issuer_id);
36 30 : packer.pack(lease.device_id.toString());
37 30 : packer.pack(lease.issued_at);
38 30 : packer.pack(lease.expires_at);
39 90 : return {buffer.data(), buffer.data() + buffer.size()};
40 30 : }
41 :
42 : } // namespace swarm_protocol
43 :
44 : } // namespace jami
|