From 2551de233f2f9d73c0bc34c3df32fe86926e82aa Mon Sep 17 00:00:00 2001 From: TekH Date: Fri, 29 May 2026 09:50:10 +0200 Subject: [PATCH] Refactor cookie handling and bump version to 1.0.1 Refactored `CookieNames.cs` to replace the `GetEnvelopeReceiverCookieName(string key)` method with new methods for extracting envelope receiver keys from cookie names: - Added `GetEnvelopeReceiverKeyOrDefault` to extract keys or return `null` if the format is invalid. - Added `TryGetEnvelopeReceiverKey` to attempt key extraction with a success flag. Updated `DigitalData.Auth.Claims.csproj` to increment `Version`, `AssemblyVersion`, and `FileVersion` from 1.0.0 to 1.0.1, reflecting the new functionality. --- DigitalData.Auth.Claims/CookieNames.cs | 29 +++++++++++++++---- .../DigitalData.Auth.Claims.csproj | 6 ++-- 2 files changed, 27 insertions(+), 8 deletions(-) diff --git a/DigitalData.Auth.Claims/CookieNames.cs b/DigitalData.Auth.Claims/CookieNames.cs index 8efcdce..140440f 100644 --- a/DigitalData.Auth.Claims/CookieNames.cs +++ b/DigitalData.Auth.Claims/CookieNames.cs @@ -17,11 +17,30 @@ namespace DigitalData.Auth.Claims => defaultCookieName + ReceiverSuffix + key; /// - /// Builds the cookie name for an envelope receiver token. This overload assumes a default cookie name of "AuthToken". + /// Extracts the envelope receiver key from a cookie name, or returns if the cookie name does not match the expected format. /// - /// The unique envelope receiver key. - /// A cookie name in the format {defaultCookieName}SignFLOWReceiver.{key}. - public static string GetEnvelopeReceiverCookieName(string key) - => "AuthToken" + ReceiverSuffix + key; + /// The full cookie name in the format {defaultCookieName}SignFLOWReceiver.{key}. + /// The base cookie name configured in AuthApiParams. + /// The envelope receiver key, or if the cookie name does not match the expected format. + public static string? GetEnvelopeReceiverKeyOrDefault(string cookieName, string defaultCookieName) + { + var prefix = defaultCookieName + ReceiverSuffix; + return cookieName.StartsWith(prefix, StringComparison.Ordinal) + ? cookieName[prefix.Length..] + : null; + } + + /// + /// Tries to extract the envelope receiver key from a cookie name. + /// + /// The full cookie name in the format {defaultCookieName}SignFLOWReceiver.{key}. + /// The base cookie name configured in AuthApiParams. + /// The extracted envelope receiver key if the cookie name matches the expected format; otherwise . + /// if the key was successfully extracted; otherwise . + public static bool TryGetEnvelopeReceiverKey(string cookieName, string defaultCookieName, out string? key) + { + key = GetEnvelopeReceiverKeyOrDefault(cookieName, defaultCookieName); + return key is not null; + } } } diff --git a/DigitalData.Auth.Claims/DigitalData.Auth.Claims.csproj b/DigitalData.Auth.Claims/DigitalData.Auth.Claims.csproj index 327398d..0363609 100644 --- a/DigitalData.Auth.Claims/DigitalData.Auth.Claims.csproj +++ b/DigitalData.Auth.Claims/DigitalData.Auth.Claims.csproj @@ -19,9 +19,9 @@ https://git.dd/AppStd/DigitalData.Auth digital data auth claims jwt constants false - 1.0.0 - 1.0.0 - 1.0.0 + 1.0.1 + 1.0.1 + 1.0.1 false