using Baya.Application.Contracts.Common; using Microsoft.Extensions.Logging; namespace Baya.Infrastructure.CrossCutting.Seams; /// /// Mock : "delivers" by logging. The OTP code is never logged (refinement-phase-9 /// §9.3 — no secrets/PII in logs, in any environment): a developer retrieves it from the Development-only /// GET /api/v1/dev/last_otp/{phone} helper (the DevCapturingSmsSender decorator), never the log. /// The phone number is logged only as its last four digits. The real implementation swaps to an Iranian SMS /// gateway (Kavenegar/Ghasedak/SMS.ir) behind the same interface via a registration change. /// public sealed class LoggingSmsSender(ILogger logger) : ISmsSender { public Task SendOtpAsync(string phone, string code, CancellationToken cancellationToken = default) { // Deliberately does NOT log the OTP code — it is a login secret. Retrieve it via /dev/last_otp in Development. logger.LogInformation("MOCK SMS — OTP issued to phone ending in {PhoneTail}", Tail(phone)); return Task.CompletedTask; } public Task SendAsync(string phone, string message, CancellationToken cancellationToken = default) { logger.LogInformation("MOCK SMS — message to phone ending in {PhoneTail}: {Message}", Tail(phone), message); return Task.CompletedTask; } private static string Tail(string phone) => string.IsNullOrEmpty(phone) ? "????" : phone[^Math.Min(4, phone.Length)..]; }