# SPDX-FileCopyrightText: 2024 Marco Ricci <software@the13thletter.info>
#
# SPDX-License-Identifier: MIT
"""Exporter for the vault "storeroom" configuration format.
The "storeroom" format is the experimental format used in alpha and beta
versions of vault beyond v0.3.0. The configuration is stored as
a separate directory, which acts like a hash table (i.e. has named
slots) and provides an impure quasi-filesystem interface. Each hash
table entry is separately encrypted and authenticated. James Coglan
designed this format to avoid concurrent write issues when updating or
synchronizing the vault configuration with e.g. a cloud service.
The public interface is the [`export_storeroom_data`][] function.
Multiple *non-public* functions are additionally documented here for
didactical and educational reasons, but they are not part of the module
API, are subject to change without notice (including removal), and
should *not* be used or relied on.
"""
from __future__ import annotations
import base64
import fnmatch
import json
import logging
import os
import os.path
import struct
from typing import TYPE_CHECKING, Any, TypedDict
from derivepassphrase import exporter
if TYPE_CHECKING:
from collections.abc import Iterator
from cryptography.hazmat.primitives import ciphers, hashes, hmac, padding
from cryptography.hazmat.primitives.ciphers import algorithms, modes
from cryptography.hazmat.primitives.kdf import pbkdf2
else:
try:
from cryptography.hazmat.primitives import (
ciphers,
hashes,
hmac,
padding,
)
from cryptography.hazmat.primitives.ciphers import algorithms, modes
from cryptography.hazmat.primitives.kdf import pbkdf2