Table of Contents

Struct DataEncryptionPurpose

Namespace
MailFathom.Infrastructure.DataEncryption
Assembly
MailFathom.Infrastructure.dll

Identifies what a sealed value is, so that one key ring can protect several kinds of value safely.

[JsonConverter(typeof(DataEncryptionPurposeJsonConverter))]
public readonly record struct DataEncryptionPurpose : IEquatable<DataEncryptionPurpose>
Implements
Inherited Members

Remarks

The type is a closed enumeration rather than a C# enum because a purpose has a published identity in the strongest sense this repository has: the identity is authenticated into every value sealed under it, so it is written into the database and stays there for the life of the row. An enum member's ordinal means nothing outside the assembly and its name changes with an ordinary rename — either would make every value sealed under the previous spelling fail to open, and the failure would appear at the next read rather than at the rename.

Sharing one key ring across several kinds of value is only safe because this identity is bound in. Two values sealed under the same key for different purposes do not open as one another, so a stored refresh token cannot be replayed into a column that means something else, and a future sealed column needs no key of its own.

An identity is allocated once and never reused or respelled. Being a struct, default is reachable and names no purpose; DataEncryptionBinding is where it is rejected, because that is the last point before a value is bound to something meaningless. See ADR 0005.

Properties

All

Gets every supported purpose.

Identity

Gets the identity authenticated into every value sealed under this purpose.

IsSpecified

Gets whether this value names a supported purpose rather than the unusable struct default.

MailboxRefreshToken

Gets the purpose of the OAuth refresh token MailFathom stores for a mailbox account.

Methods

ToString()

Returns the fully qualified type name of this instance.

TryParse(string?, out DataEncryptionPurpose)

Parses a stored or configured identity.