| | | 1 | | namespace ArturRios.Output; |
| | | 2 | | |
| | | 3 | | /// <summary> |
| | | 4 | | /// Settings for issuing and checking the signed page tokens used by token pagination. Build one instance — typically |
| | | 5 | | /// a singleton from configuration — and pass it to every call that walks the same listing. |
| | | 6 | | /// </summary> |
| | | 7 | | public sealed record PageTokenOptions |
| | | 8 | | { |
| | | 9 | | /// <summary> |
| | | 10 | | /// The minimum length, in bytes, of <see cref="SigningKey"/>. |
| | | 11 | | /// </summary> |
| | | 12 | | public const int MinimumSigningKeyLength = 32; |
| | | 13 | | |
| | | 14 | | /// <summary> |
| | | 15 | | /// Secret HMAC-SHA256 key that signs every token, at least <see cref="MinimumSigningKeyLength"/> bytes long. A |
| | | 16 | | /// token signed with another key is rejected, so every instance serving the same listing must share it. |
| | | 17 | | /// </summary> |
| | 530 | 18 | | public required byte[] SigningKey { get; init; } |
| | | 19 | | |
| | | 20 | | /// <summary> |
| | | 21 | | /// How long a token stays valid after it is issued, or <c>null</c> for tokens that never expire. |
| | | 22 | | /// </summary> |
| | 140 | 23 | | public TimeSpan? Lifetime { get; init; } |
| | | 24 | | |
| | | 25 | | /// <summary> |
| | | 26 | | /// Optional caller-defined string that binds tokens to one listing — for example <c>"orders:customer=42"</c> — so |
| | | 27 | | /// a token issued under one scope is rejected under another. It is hashed into the token, never stored in it. |
| | | 28 | | /// </summary> |
| | 140 | 29 | | public string? Scope { get; init; } |
| | | 30 | | |
| | | 31 | | /// <summary> |
| | | 32 | | /// Clock used to stamp tokens and check their <see cref="Lifetime"/>. |
| | | 33 | | /// </summary> |
| | 208 | 34 | | public TimeProvider TimeProvider { get; init; } = TimeProvider.System; |
| | | 35 | | } |