# NexusAuthenticationStateProvider

- File ID: file:i7as8l:nexusauthenticationstateprovider-cs
- Path: NexusReader.UI.Shared/Services/NexusAuthenticationStateProvider.cs
- Role: service
- Layer: frontend

## Purpose

Provides Blazor AuthenticationStateProvider implementation that reads persisted user authentication info (token, email, tenant, roles) from a native secure storage service, caches the computed AuthenticationState, and notifies consumers about authentication changes.

## Key Details

Caches computed AuthenticationState in-memory; reads token/email/tenant/roles from INativeStorageService; three main paths in GetAuthenticationStateAsync: token-based, cookie-indicator-based, anonymous fallback; includes security note about storing roles in local storage (line 13-15).

## Symbols

- NexusAuthenticationStateProvider: Provides Blazor AuthenticationStateProvider implementation that reads persisted user authentication info (token, email, tenant, roles) from a native secure storage service, caches the computed AuthenticationState, and notifies consumers about authentication changes.
- NexusAuthenticationStateProvider(): Constructor that captures the native secure storage service dependency.
- ClearCache(): Clears any cached AuthenticationState and triggers Notification of authentication state change.
- GetAuthenticationStateAsync(): Asynchronously obtains the current AuthenticationState by reading persisted token/email/tenant/roles from secure storage, with caching, multi-path branching (token, cookie, fallback), and exception-safe anonymous fallback.
- CreateState(): Builds an AuthenticationState from provided email, tenantId, authType and a comma-separated roles string.
- NotifyUserAuthentication(): Updates cached AuthenticationState to an authenticated state and notifies consumers (used after successful login).
- NotifyUserLogout(): Clears cached authentication and notifies consumers that the user is logged out (returns anonymous principal).
- NexusAuthenticationStateProvider: Authentication state provider that derives authentication information from secure native storage and exposes state changes to Blazor components.

## Dependencies

- No resolved dependencies.

## Calls

- No resolved calls.

## Unresolved References

- dependency-target: NexusReader.Application.Abstractions.Services/INativeStorageService.cs
- dependency-target: NexusReader.Application.Constants/StorageKeys.cs
- call-target: NexusReader.Application.Abstractions.Services/INativeStorageService.cs
- call-target: NexusReader.Application.Abstractions.Services/INativeStorageService.cs
- call-target: NexusReader.Application.Abstractions.Services/INativeStorageService.cs
- call-target: NexusReader.Application.Abstractions.Services/INativeStorageService.cs
- call-target: self
- call-target: NexusReader.Application.Abstractions.Services/INativeStorageService.cs
- call-target: NexusReader.Application.Abstractions.Services/INativeStorageService.cs
- call-target: NexusReader.Application.Abstractions.Services/INativeStorageService.cs
- call-target: self
- call-target: self
- interaction-target: await _storageService.GetSecureString(TokenKey)
- interaction-target: await _storageService.GetSecureString for UserEmail, UserTenant, UserRoles
- interaction-target: await _storageService.GetSecureString for UserEmail, UserTenant, UserRoles

## Coverage

- Symbols: 8
- Executable symbols: 6
- Executable symbols with control flow: 6
- Grounded edges: 8
- Unresolved references: 15
- Control-flow fragments: 6
- Unresolved jumps: 7
- Unsupported constructs: 0
- Control-flow coverage: 100%
- Required diagrams: 2
- Generated diagrams: 4

## Control Flow Fragments

- NexusAuthenticationStateProvider: 3 nodes, 2 edges, 0 jumps, 0 unsupported constructs
- ClearCache: 5 nodes, 4 edges, 0 jumps, 0 unsupported constructs
- GetAuthenticationStateAsync: 65 nodes, 73 edges, 9 jumps, 0 unsupported constructs
- CreateState: 19 nodes, 22 edges, 0 jumps, 0 unsupported constructs
- NotifyUserAuthentication: 7 nodes, 6 edges, 1 jumps, 0 unsupported constructs
- NotifyUserLogout: 7 nodes, 6 edges, 0 jumps, 0 unsupported constructs

## Diagrams

### NexusAuthenticationStateProvider Neighborhood

```mermaid
flowchart LR
    class_1yjf0sw_nexusauthenticationstateprovider("NexusAuthenticationStateProvider")
    file_i7as8l_nexusauthenticationstateprovider_cs("NexusAuthenticationStateProvider")
    method_13yeu7e_getauthenticationstateasync[["GetAuthenticationStateAsync()"]]
    method_15b2jq7_nexusauthenticationstateprovider[["NexusAuthenticationStateProvider()"]]
    method_16ct380_createstate[["CreateState()"]]
    method_1csperg_notifyuserauthentication[["NotifyUserAuthentication()"]]
    method_1r8a5jx_clearcache[["ClearCache()"]]
    method_ppivt7_notifyuserlogout[["NotifyUserLogout()"]]
    type_1rcw5yd_nexusauthenticationstateprovider[/"NexusAuthenticationStateProvider"/]
```

### NexusAuthenticationStateProvider Execution Overview

```mermaid
flowchart TD
    class_1yjf0sw_nexusauthenticationstateprovider("NexusAuthenticationStateProvider")
    method_13yeu7e_getauthenticationstateasync[["GetAuthenticationStateAsync()"]]
    method_15b2jq7_nexusauthenticationstateprovider[["NexusAuthenticationStateProvider()"]]
    method_16ct380_createstate[["CreateState()"]]
    method_1csperg_notifyuserauthentication[["NotifyUserAuthentication()"]]
    method_1r8a5jx_clearcache[["ClearCache()"]]
    method_ppivt7_notifyuserlogout[["NotifyUserLogout()"]]
    unresolved_unresolved_7781p2_call_target{"Unresolved: GetSecureString"}
    unresolved_unresolved_ec7s11_call_target{"Unresolved: CreateState"}
    unresolved_unresolved_ivbye2_interaction_target{"Unresolved: await _storageService.GetSecureString(TokenKey)"}
    unresolved_unresolved_k68nw4_call_target{"Unresolved: CreateState"}
    unresolved_unresolved_nkii1s_interaction_target{"Unresolved: await _storageService.GetSecureString for UserEmail, UserTenant, UserRoles"}
    class_1yjf0sw_nexusauthenticationstateprovider -->|contains| method_13yeu7e_getauthenticationstateasync
    class_1yjf0sw_nexusauthenticationstateprovider -->|contains| method_15b2jq7_nexusauthenticationstateprovider
    class_1yjf0sw_nexusauthenticationstateprovider -->|contains| method_16ct380_createstate
    class_1yjf0sw_nexusauthenticationstateprovider -->|contains| method_1csperg_notifyuserauthentication
    class_1yjf0sw_nexusauthenticationstateprovider -->|contains| method_1r8a5jx_clearcache
    class_1yjf0sw_nexusauthenticationstateprovider -->|contains| method_ppivt7_notifyuserlogout
    class_1yjf0sw_nexusauthenticationstateprovider -->|unresolved interaction| unresolved_unresolved_ivbye2_interaction_target
    class_1yjf0sw_nexusauthenticationstateprovider -->|unresolved interaction| unresolved_unresolved_nkii1s_interaction_target
    class_1yjf0sw_nexusauthenticationstateprovider -->|unresolved interaction| unresolved_unresolved_nkii1s_interaction_target
    method_13yeu7e_getauthenticationstateasync -->|unresolved call| unresolved_unresolved_7781p2_call_target
    method_13yeu7e_getauthenticationstateasync -->|unresolved call| unresolved_unresolved_7781p2_call_target
    method_13yeu7e_getauthenticationstateasync -->|unresolved call| unresolved_unresolved_7781p2_call_target
    method_13yeu7e_getauthenticationstateasync -->|unresolved call| unresolved_unresolved_7781p2_call_target
    method_13yeu7e_getauthenticationstateasync -->|unresolved call| unresolved_unresolved_7781p2_call_target
    method_13yeu7e_getauthenticationstateasync -->|unresolved call| unresolved_unresolved_7781p2_call_target
    method_13yeu7e_getauthenticationstateasync -->|unresolved call| unresolved_unresolved_7781p2_call_target
    method_13yeu7e_getauthenticationstateasync -->|unresolved call| unresolved_unresolved_ec7s11_call_target
    method_13yeu7e_getauthenticationstateasync -->|unresolved call| unresolved_unresolved_ec7s11_call_target
    method_1csperg_notifyuserauthentication -->|unresolved call| unresolved_unresolved_k68nw4_call_target
```

### GetAuthenticationStateAsync() Control Flow

_Warnings: diagram method_13yeu7e_getauthenticationstateasync__fragment_diagram exceeds preferred complexity thresholds (65 nodes, 73 edges)._

```mermaid
---
config:
  flowchart:
    defaultRenderer: "elk"
---
flowchart TD
    method_13yeu7e_getauthenticationstateasync__call_37_GetSecureString[["GetSecureString"]]
    method_13yeu7e_getauthenticationstateasync__call_43_GetSecureString[["GetSecureString"]]
    method_13yeu7e_getauthenticationstateasync__call_44_GetSecureString[["GetSecureString"]]
    method_13yeu7e_getauthenticationstateasync__call_45_GetSecureString[["GetSecureString"]]
    method_13yeu7e_getauthenticationstateasync__call_49_CreateState[["CreateState"]]
    method_13yeu7e_getauthenticationstateasync__call_59_GetSecureString[["GetSecureString"]]
    method_13yeu7e_getauthenticationstateasync__call_62_GetSecureString[["GetSecureString"]]
    method_13yeu7e_getauthenticationstateasync__call_63_GetSecureString[["GetSecureString"]]
    method_13yeu7e_getauthenticationstateasync__call_64_CreateState[["CreateState"]]
    method_13yeu7e_getauthenticationstateasync__action_33_getauthenticationstateasync_try_33_0__try("Begins protected execution")
    method_13yeu7e_getauthenticationstateasync__action_35_getauthenticationstateasync_guard_clause_35_1__condition{"_cachedState != null"}
    method_13yeu7e_getauthenticationstateasync__action_35_getauthenticationstateasync_guard_clause_35_1__false("continue")
    method_13yeu7e_getauthenticationstateasync__action_35_getauthenticationstateasync_guard_clause_35_1__merge("merge")
    method_13yeu7e_getauthenticationstateasync__action_35_getauthenticationstateasync_guard_clause_35_1__true("exit")
    method_13yeu7e_getauthenticationstateasync__action_35_guard_clause_35__condition{"_cachedState != null"}
    method_13yeu7e_getauthenticationstateasync__action_35_guard_clause_35__false("continue to storage reads")
    method_13yeu7e_getauthenticationstateasync__action_35_guard_clause_35__merge("merge")
    method_13yeu7e_getauthenticationstateasync__action_35_guard_clause_35__true("return cached AuthenticationState")
    method_13yeu7e_getauthenticationstateasync__action_37_getauthenticationstateasync_await_37_2__await[["Waits for async work"]]
    method_13yeu7e_getauthenticationstateasync__action_40_branch_40__condition{"token is not null/whitespace"}
    method_13yeu7e_getauthenticationstateasync__action_40_branch_40__false("skip token-based")
    method_13yeu7e_getauthenticationstateasync__action_40_branch_40__merge("merge")
    method_13yeu7e_getauthenticationstateasync__action_40_branch_40__true("try token-based: read email, tenant, roles")
    method_13yeu7e_getauthenticationstateasync__action_41_getauthenticationstateasync_branch_41_3__condition{"!string.IsNullOrWhiteSpace(token)"}
    method_13yeu7e_getauthenticationstateasync__action_41_getauthenticationstateasync_branch_41_3__false("false")
    method_13yeu7e_getauthenticationstateasync__action_41_getauthenticationstateasync_branch_41_3__merge("merge")
    method_13yeu7e_getauthenticationstateasync__action_41_getauthenticationstateasync_branch_41_3__true("true")
    method_13yeu7e_getauthenticationstateasync__action_43_getauthenticationstateasync_await_43_4__await[["Waits for async work"]]
    method_13yeu7e_getauthenticationstateasync__action_44_getauthenticationstateasync_await_44_5__await[["Waits for async work"]]
    method_13yeu7e_getauthenticationstateasync__action_45_getauthenticationstateasync_await_45_6__await[["Waits for async work"]]
    method_13yeu7e_getauthenticationstateasync__action_47_getauthenticationstateasync_branch_47_7__condition{"emailResult.IsSuccess && !string.IsNullOrEmpty(emailResult.Value)"}
    method_13yeu7e_getauthenticationstateasync__action_47_getauthenticationstateasync_branch_47_7__false("false")
    method_13yeu7e_getauthenticationstateasync__action_47_getauthenticationstateasync_branch_47_7__merge("merge")
    method_13yeu7e_getauthenticationstateasync__action_47_getauthenticationstateasync_branch_47_7__true("true")
    method_13yeu7e_getauthenticationstateasync__action_47_guard_clause_47__condition{"emailResult.IsSuccess && !string.IsNullOrEmpty(emailResult.Value)"}
    method_13yeu7e_getauthenticationstateasync__action_47_guard_clause_47__false("fall through")
    method_13yeu7e_getauthenticationstateasync__action_47_guard_clause_47__merge("merge")
    method_13yeu7e_getauthenticationstateasync__action_47_guard_clause_47__true("create cached state and return")
    method_13yeu7e_getauthenticationstateasync__action_58_branch_58__condition{"storedEmailResult.IsSuccess && storedEmailResult.Value not empty"}
    method_13yeu7e_getauthenticationstateasync__action_58_branch_58__false("fall through to fallback")
    method_13yeu7e_getauthenticationstateasync__action_58_branch_58__merge("merge")
    method_13yeu7e_getauthenticationstateasync__action_58_branch_58__true("create cached state from cookie-style indicators and return")
    method_13yeu7e_getauthenticationstateasync__action_59_getauthenticationstateasync_await_59_9__await[["Waits for async work"]]
    method_13yeu7e_getauthenticationstateasync__action_60_getauthenticationstateasync_branch_60_10__condition{"storedEmailResult.IsSuccess && !string.IsNullOrEmpty(storedEmailResult.Value)"}
    method_13yeu7e_getauthenticationstateasync__action_60_getauthenticationstateasync_branch_60_10__false("false")
    method_13yeu7e_getauthenticationstateasync__action_60_getauthenticationstateasync_branch_60_10__merge("merge")
    method_13yeu7e_getauthenticationstateasync__action_60_getauthenticationstateasync_branch_60_10__true("true")
    method_13yeu7e_getauthenticationstateasync__action_62_getauthenticationstateasync_await_62_11__await[["Waits for async work"]]
    method_13yeu7e_getauthenticationstateasync__action_63_getauthenticationstateasync_await_63_12__await[["Waits for async work"]]
    method_13yeu7e_getauthenticationstateasync__action_76_fallback_76__condition{"Anonymous fallback"}
    method_13yeu7e_getauthenticationstateasync__action_76_fallback_76__false("false")
    method_13yeu7e_getauthenticationstateasync__action_76_fallback_76__merge("merge")
    method_13yeu7e_getauthenticationstateasync__action_76_fallback_76__true("true")
    method_13yeu7e_getauthenticationstateasync__action_78_exception_handler_78__linear("Catch-all exception and return anonymous")
    method_13yeu7e_getauthenticationstateasync__action_78_getauthenticationstateasync_catch_78_15__catch("catch Exception")
    method_13yeu7e_getauthenticationstateasync__entry(["GetAuthenticationStateAsync entry"])
    method_13yeu7e_getauthenticationstateasync__action_37_external_call_37__linear("Read persisted auth token")
    method_13yeu7e_getauthenticationstateasync__action_43_external_call_43__linear("Read email/tenant/roles for token path")
    method_13yeu7e_getauthenticationstateasync__action_59_external_call_59__linear("Read email/tenant/roles for cookie path")
    method_13yeu7e_getauthenticationstateasync__action_54_getauthenticationstateasync_return_54_8__return(["Returns result"])
    method_13yeu7e_getauthenticationstateasync__action_54_return_54__return(["Return AuthenticationState built from token data"])
    method_13yeu7e_getauthenticationstateasync__action_69_getauthenticationstateasync_return_69_13__return(["Returns result"])
    method_13yeu7e_getauthenticationstateasync__action_69_return_69__return(["Return AuthenticationState built from cookie indicators"])
    method_13yeu7e_getauthenticationstateasync__action_76_getauthenticationstateasync_return_76_14__return(["Returns result"])
    method_13yeu7e_getauthenticationstateasync__action_80_getauthenticationstateasync_return_80_16__return(["Returns result"])
    method_13yeu7e_getauthenticationstateasync__action_33_getauthenticationstateasync_try_33_0__try -->|next| method_13yeu7e_getauthenticationstateasync__action_35_guard_clause_35__condition
    method_13yeu7e_getauthenticationstateasync__action_35_getauthenticationstateasync_guard_clause_35_1__condition -->|continue| method_13yeu7e_getauthenticationstateasync__action_35_getauthenticationstateasync_guard_clause_35_1__false
    method_13yeu7e_getauthenticationstateasync__action_35_getauthenticationstateasync_guard_clause_35_1__condition -->|exit| method_13yeu7e_getauthenticationstateasync__action_35_getauthenticationstateasync_guard_clause_35_1__true
    method_13yeu7e_getauthenticationstateasync__action_35_getauthenticationstateasync_guard_clause_35_1__false -->|next| method_13yeu7e_getauthenticationstateasync__action_35_getauthenticationstateasync_guard_clause_35_1__merge
    method_13yeu7e_getauthenticationstateasync__action_35_getauthenticationstateasync_guard_clause_35_1__merge -->|next| method_13yeu7e_getauthenticationstateasync__action_37_getauthenticationstateasync_await_37_2__await
    method_13yeu7e_getauthenticationstateasync__action_35_getauthenticationstateasync_guard_clause_35_1__true -->|next| method_13yeu7e_getauthenticationstateasync__action_35_getauthenticationstateasync_guard_clause_35_1__merge
    method_13yeu7e_getauthenticationstateasync__action_35_guard_clause_35__condition -->|continue to storage reads| method_13yeu7e_getauthenticationstateasync__action_35_guard_clause_35__false
    method_13yeu7e_getauthenticationstateasync__action_35_guard_clause_35__condition -->|return cached AuthenticationState| method_13yeu7e_getauthenticationstateasync__action_35_guard_clause_35__true
    method_13yeu7e_getauthenticationstateasync__action_35_guard_clause_35__false -->|next| method_13yeu7e_getauthenticationstateasync__action_35_guard_clause_35__merge
    method_13yeu7e_getauthenticationstateasync__action_35_guard_clause_35__merge -->|next| method_13yeu7e_getauthenticationstateasync__action_35_getauthenticationstateasync_guard_clause_35_1__condition
    method_13yeu7e_getauthenticationstateasync__action_35_guard_clause_35__true -->|next| method_13yeu7e_getauthenticationstateasync__action_35_guard_clause_35__merge
    method_13yeu7e_getauthenticationstateasync__action_37_external_call_37__linear -->|TokenKey StorageKeys.AuthToken| method_13yeu7e_getauthenticationstateasync__call_37_GetSecureString
    method_13yeu7e_getauthenticationstateasync__action_37_getauthenticationstateasync_await_37_2__await -->|next| method_13yeu7e_getauthenticationstateasync__action_37_external_call_37__linear
    method_13yeu7e_getauthenticationstateasync__action_40_branch_40__condition -->|skip token-based| method_13yeu7e_getauthenticationstateasync__action_40_branch_40__false
    method_13yeu7e_getauthenticationstateasync__action_40_branch_40__condition -->|try token-based: read email, tenant, roles| method_13yeu7e_getauthenticationstateasync__action_40_branch_40__true
    method_13yeu7e_getauthenticationstateasync__action_40_branch_40__false -->|next| method_13yeu7e_getauthenticationstateasync__action_40_branch_40__merge
    method_13yeu7e_getauthenticationstateasync__action_40_branch_40__merge -->|next| method_13yeu7e_getauthenticationstateasync__action_41_getauthenticationstateasync_branch_41_3__condition
    method_13yeu7e_getauthenticationstateasync__action_40_branch_40__true -->|next| method_13yeu7e_getauthenticationstateasync__action_40_branch_40__merge
    method_13yeu7e_getauthenticationstateasync__action_41_getauthenticationstateasync_branch_41_3__condition -->|false| method_13yeu7e_getauthenticationstateasync__action_41_getauthenticationstateasync_branch_41_3__false
    method_13yeu7e_getauthenticationstateasync__action_41_getauthenticationstateasync_branch_41_3__condition -->|true| method_13yeu7e_getauthenticationstateasync__action_41_getauthenticationstateasync_branch_41_3__true
    method_13yeu7e_getauthenticationstateasync__action_41_getauthenticationstateasync_branch_41_3__false -->|next| method_13yeu7e_getauthenticationstateasync__action_41_getauthenticationstateasync_branch_41_3__merge
    method_13yeu7e_getauthenticationstateasync__action_41_getauthenticationstateasync_branch_41_3__merge -->|next| method_13yeu7e_getauthenticationstateasync__action_43_getauthenticationstateasync_await_43_4__await
    method_13yeu7e_getauthenticationstateasync__action_41_getauthenticationstateasync_branch_41_3__true -->|next| method_13yeu7e_getauthenticationstateasync__action_41_getauthenticationstateasync_branch_41_3__merge
    method_13yeu7e_getauthenticationstateasync__action_43_external_call_43__linear -->|StorageKeys.UserEmail| method_13yeu7e_getauthenticationstateasync__call_43_GetSecureString
    method_13yeu7e_getauthenticationstateasync__action_43_getauthenticationstateasync_await_43_4__await -->|next| method_13yeu7e_getauthenticationstateasync__action_43_external_call_43__linear
    method_13yeu7e_getauthenticationstateasync__action_44_getauthenticationstateasync_await_44_5__await -->|StorageKeys.UserTenant| method_13yeu7e_getauthenticationstateasync__call_44_GetSecureString
    method_13yeu7e_getauthenticationstateasync__action_45_getauthenticationstateasync_await_45_6__await -->|StorageKeys.UserRoles| method_13yeu7e_getauthenticationstateasync__call_45_GetSecureString
    method_13yeu7e_getauthenticationstateasync__action_47_getauthenticationstateasync_branch_47_7__condition -->|false| method_13yeu7e_getauthenticationstateasync__action_47_getauthenticationstateasync_branch_47_7__false
    method_13yeu7e_getauthenticationstateasync__action_47_getauthenticationstateasync_branch_47_7__condition -->|true| method_13yeu7e_getauthenticationstateasync__action_47_getauthenticationstateasync_branch_47_7__true
    method_13yeu7e_getauthenticationstateasync__action_47_getauthenticationstateasync_branch_47_7__false -->|next| method_13yeu7e_getauthenticationstateasync__action_47_getauthenticationstateasync_branch_47_7__merge
    method_13yeu7e_getauthenticationstateasync__action_47_getauthenticationstateasync_branch_47_7__merge -->|calls| method_13yeu7e_getauthenticationstateasync__call_49_CreateState
    method_13yeu7e_getauthenticationstateasync__action_47_getauthenticationstateasync_branch_47_7__true -->|next| method_13yeu7e_getauthenticationstateasync__action_47_getauthenticationstateasync_branch_47_7__merge
    method_13yeu7e_getauthenticationstateasync__action_47_guard_clause_47__condition -->|fall through| method_13yeu7e_getauthenticationstateasync__action_47_guard_clause_47__false
    method_13yeu7e_getauthenticationstateasync__action_47_guard_clause_47__condition -->|create cached state and return| method_13yeu7e_getauthenticationstateasync__action_47_guard_clause_47__true
    method_13yeu7e_getauthenticationstateasync__action_47_guard_clause_47__false -->|next| method_13yeu7e_getauthenticationstateasync__action_47_guard_clause_47__merge
    method_13yeu7e_getauthenticationstateasync__action_47_guard_clause_47__merge -->|next| method_13yeu7e_getauthenticationstateasync__action_47_getauthenticationstateasync_branch_47_7__condition
    method_13yeu7e_getauthenticationstateasync__action_47_guard_clause_47__true -->|next| method_13yeu7e_getauthenticationstateasync__action_47_guard_clause_47__merge
    method_13yeu7e_getauthenticationstateasync__action_54_getauthenticationstateasync_return_54_8__return -->|return| method_13yeu7e_getauthenticationstateasync__action_54_return_54__return
    method_13yeu7e_getauthenticationstateasync__action_54_return_54__return -->|next| method_13yeu7e_getauthenticationstateasync__action_58_branch_58__condition
    method_13yeu7e_getauthenticationstateasync__action_58_branch_58__condition -->|fall through to fallback| method_13yeu7e_getauthenticationstateasync__action_58_branch_58__false
    method_13yeu7e_getauthenticationstateasync__action_58_branch_58__condition -->|create cached state from cookie-style indicators and return| method_13yeu7e_getauthenticationstateasync__action_58_branch_58__true
    method_13yeu7e_getauthenticationstateasync__action_58_branch_58__false -->|next| method_13yeu7e_getauthenticationstateasync__action_58_branch_58__merge
    method_13yeu7e_getauthenticationstateasync__action_58_branch_58__merge -->|next| method_13yeu7e_getauthenticationstateasync__action_59_getauthenticationstateasync_await_59_9__await
    method_13yeu7e_getauthenticationstateasync__action_58_branch_58__true -->|next| method_13yeu7e_getauthenticationstateasync__action_58_branch_58__merge
    method_13yeu7e_getauthenticationstateasync__action_59_external_call_59__linear -->|StorageKeys.UserEmail cookie fallback| method_13yeu7e_getauthenticationstateasync__call_59_GetSecureString
    method_13yeu7e_getauthenticationstateasync__action_59_getauthenticationstateasync_await_59_9__await -->|next| method_13yeu7e_getauthenticationstateasync__action_59_external_call_59__linear
    method_13yeu7e_getauthenticationstateasync__action_60_getauthenticationstateasync_branch_60_10__condition -->|false| method_13yeu7e_getauthenticationstateasync__action_60_getauthenticationstateasync_branch_60_10__false
    method_13yeu7e_getauthenticationstateasync__action_60_getauthenticationstateasync_branch_60_10__condition -->|true| method_13yeu7e_getauthenticationstateasync__action_60_getauthenticationstateasync_branch_60_10__true
    method_13yeu7e_getauthenticationstateasync__action_60_getauthenticationstateasync_branch_60_10__false -->|next| method_13yeu7e_getauthenticationstateasync__action_60_getauthenticationstateasync_branch_60_10__merge
    method_13yeu7e_getauthenticationstateasync__action_60_getauthenticationstateasync_branch_60_10__merge -->|next| method_13yeu7e_getauthenticationstateasync__action_62_getauthenticationstateasync_await_62_11__await
    method_13yeu7e_getauthenticationstateasync__action_60_getauthenticationstateasync_branch_60_10__true -->|next| method_13yeu7e_getauthenticationstateasync__action_60_getauthenticationstateasync_branch_60_10__merge
    method_13yeu7e_getauthenticationstateasync__action_62_getauthenticationstateasync_await_62_11__await -->|StorageKeys.UserTenant cookie fallback| method_13yeu7e_getauthenticationstateasync__call_62_GetSecureString
    method_13yeu7e_getauthenticationstateasync__action_63_getauthenticationstateasync_await_63_12__await -->|StorageKeys.UserRoles cookie fallback| method_13yeu7e_getauthenticationstateasync__call_63_GetSecureString
    method_13yeu7e_getauthenticationstateasync__action_69_getauthenticationstateasync_return_69_13__return -->|return| method_13yeu7e_getauthenticationstateasync__action_69_return_69__return
    method_13yeu7e_getauthenticationstateasync__action_69_return_69__return -->|return| method_13yeu7e_getauthenticationstateasync__action_76_getauthenticationstateasync_return_76_14__return
    method_13yeu7e_getauthenticationstateasync__action_76_fallback_76__condition -->|false| method_13yeu7e_getauthenticationstateasync__action_76_fallback_76__false
    method_13yeu7e_getauthenticationstateasync__action_76_fallback_76__condition -->|true| method_13yeu7e_getauthenticationstateasync__action_76_fallback_76__true
    method_13yeu7e_getauthenticationstateasync__action_76_fallback_76__false -->|next| method_13yeu7e_getauthenticationstateasync__action_76_fallback_76__merge
    method_13yeu7e_getauthenticationstateasync__action_76_fallback_76__merge -->|exception| method_13yeu7e_getauthenticationstateasync__action_78_getauthenticationstateasync_catch_78_15__catch
    method_13yeu7e_getauthenticationstateasync__action_76_fallback_76__true -->|next| method_13yeu7e_getauthenticationstateasync__action_76_fallback_76__merge
    method_13yeu7e_getauthenticationstateasync__action_76_getauthenticationstateasync_return_76_14__return -->|fallback| method_13yeu7e_getauthenticationstateasync__action_76_fallback_76__condition
    method_13yeu7e_getauthenticationstateasync__action_78_exception_handler_78__linear -->|return| method_13yeu7e_getauthenticationstateasync__action_80_getauthenticationstateasync_return_80_16__return
    method_13yeu7e_getauthenticationstateasync__action_78_getauthenticationstateasync_catch_78_15__catch -->|next| method_13yeu7e_getauthenticationstateasync__action_78_exception_handler_78__linear
    method_13yeu7e_getauthenticationstateasync__call_37_GetSecureString -->|next| method_13yeu7e_getauthenticationstateasync__action_40_branch_40__condition
    method_13yeu7e_getauthenticationstateasync__call_43_GetSecureString -->|next| method_13yeu7e_getauthenticationstateasync__action_44_getauthenticationstateasync_await_44_5__await
    method_13yeu7e_getauthenticationstateasync__call_44_GetSecureString -->|next| method_13yeu7e_getauthenticationstateasync__action_45_getauthenticationstateasync_await_45_6__await
    method_13yeu7e_getauthenticationstateasync__call_45_GetSecureString -->|next| method_13yeu7e_getauthenticationstateasync__action_47_guard_clause_47__condition
    method_13yeu7e_getauthenticationstateasync__call_49_CreateState -->|return| method_13yeu7e_getauthenticationstateasync__action_54_getauthenticationstateasync_return_54_8__return
    method_13yeu7e_getauthenticationstateasync__call_59_GetSecureString -->|next| method_13yeu7e_getauthenticationstateasync__action_60_getauthenticationstateasync_branch_60_10__condition
    method_13yeu7e_getauthenticationstateasync__call_62_GetSecureString -->|next| method_13yeu7e_getauthenticationstateasync__action_63_getauthenticationstateasync_await_63_12__await
    method_13yeu7e_getauthenticationstateasync__call_63_GetSecureString -->|calls| method_13yeu7e_getauthenticationstateasync__call_64_CreateState
    method_13yeu7e_getauthenticationstateasync__call_64_CreateState -->|return| method_13yeu7e_getauthenticationstateasync__action_69_getauthenticationstateasync_return_69_13__return
    method_13yeu7e_getauthenticationstateasync__entry -->|next| method_13yeu7e_getauthenticationstateasync__action_33_getauthenticationstateasync_try_33_0__try
```

### CreateState() Control Flow

_Warnings: diagram method_16ct380_createstate__fragment_diagram exceeds preferred complexity thresholds (19 nodes, 22 edges)._

```mermaid
---
config:
  flowchart:
    defaultRenderer: "elk"
---
flowchart TD
    method_16ct380_createstate__action_102_creation_102__linear("Create ClaimsIdentity and AuthenticationState")
    method_16ct380_createstate__action_86_mapping_86__linear("Create base claims (Name, Email, TenantId)")
    method_16ct380_createstate__action_93_createstate_branch_93_0__condition{"!string.IsNullOrEmpty(rolesStr)"}
    method_16ct380_createstate__action_93_createstate_branch_93_0__false("false")
    method_16ct380_createstate__action_93_createstate_branch_93_0__merge("merge")
    method_16ct380_createstate__action_93_createstate_branch_93_0__true("true")
    method_16ct380_createstate__action_93_guard_clause_93__condition{"!string.IsNullOrEmpty(rolesStr)"}
    method_16ct380_createstate__action_93_guard_clause_93__false("skip roles")
    method_16ct380_createstate__action_93_guard_clause_93__merge("merge")
    method_16ct380_createstate__action_93_guard_clause_93__true("add Claims for each role")
    method_16ct380_createstate__action_96_createstate_loop_96_1__loop_body[["foreach (var role in roles)"]]
    method_16ct380_createstate__action_96_createstate_loop_96_1__loop_entry("var role in roles")
    method_16ct380_createstate__action_96_createstate_loop_96_1__loop_exit("Leaves the loop when the condition no longer holds.")
    method_16ct380_createstate__action_96_loop_96__loop_body[["foreach (var role in roles) { claims.Add(new Claim(ClaimTypes.Role, role.Trim())); }"]]
    method_16ct380_createstate__action_96_loop_96__loop_entry("Iterate roles and add claims")
    method_16ct380_createstate__action_96_loop_96__loop_exit("exit loop")
    method_16ct380_createstate__entry(["CreateState entry"])
    method_16ct380_createstate__action_103_createstate_return_103_2__return(["Returns result"])
    method_16ct380_createstate__action_103_return_103__return(["Return built AuthenticationState"])
    method_16ct380_createstate__action_102_creation_102__linear -->|return| method_16ct380_createstate__action_103_createstate_return_103_2__return
    method_16ct380_createstate__action_103_createstate_return_103_2__return -->|return| method_16ct380_createstate__action_103_return_103__return
    method_16ct380_createstate__action_86_mapping_86__linear -->|next| method_16ct380_createstate__action_93_guard_clause_93__condition
    method_16ct380_createstate__action_93_createstate_branch_93_0__condition -->|false| method_16ct380_createstate__action_93_createstate_branch_93_0__false
    method_16ct380_createstate__action_93_createstate_branch_93_0__condition -->|true| method_16ct380_createstate__action_93_createstate_branch_93_0__true
    method_16ct380_createstate__action_93_createstate_branch_93_0__false -->|next| method_16ct380_createstate__action_93_createstate_branch_93_0__merge
    method_16ct380_createstate__action_93_createstate_branch_93_0__merge -->|next| method_16ct380_createstate__action_96_createstate_loop_96_1__loop_entry
    method_16ct380_createstate__action_93_createstate_branch_93_0__true -->|next| method_16ct380_createstate__action_93_createstate_branch_93_0__merge
    method_16ct380_createstate__action_93_guard_clause_93__condition -->|skip roles| method_16ct380_createstate__action_93_guard_clause_93__false
    method_16ct380_createstate__action_93_guard_clause_93__condition -->|add Claims for each role| method_16ct380_createstate__action_93_guard_clause_93__true
    method_16ct380_createstate__action_93_guard_clause_93__false -->|next| method_16ct380_createstate__action_93_guard_clause_93__merge
    method_16ct380_createstate__action_93_guard_clause_93__merge -->|next| method_16ct380_createstate__action_93_createstate_branch_93_0__condition
    method_16ct380_createstate__action_93_guard_clause_93__true -->|next| method_16ct380_createstate__action_93_guard_clause_93__merge
    method_16ct380_createstate__action_96_createstate_loop_96_1__loop_body -->|continue| method_16ct380_createstate__action_96_createstate_loop_96_1__loop_entry
    method_16ct380_createstate__action_96_createstate_loop_96_1__loop_entry -->|var role in roles| method_16ct380_createstate__action_96_createstate_loop_96_1__loop_body
    method_16ct380_createstate__action_96_createstate_loop_96_1__loop_entry -->|Leaves the loop when the condition no longer holds.| method_16ct380_createstate__action_96_createstate_loop_96_1__loop_exit
    method_16ct380_createstate__action_96_createstate_loop_96_1__loop_exit -->|next| method_16ct380_createstate__action_96_loop_96__loop_entry
    method_16ct380_createstate__action_96_loop_96__loop_body -->|continue| method_16ct380_createstate__action_96_loop_96__loop_entry
    method_16ct380_createstate__action_96_loop_96__loop_entry -->|iterate| method_16ct380_createstate__action_96_loop_96__loop_body
    method_16ct380_createstate__action_96_loop_96__loop_entry -->|exit| method_16ct380_createstate__action_96_loop_96__loop_exit
    method_16ct380_createstate__action_96_loop_96__loop_exit -->|next| method_16ct380_createstate__action_102_creation_102__linear
    method_16ct380_createstate__entry -->|next| method_16ct380_createstate__action_86_mapping_86__linear
```

## Diagram Validation

- Status: warn
- Warning: Control-flow extraction left 7 unresolved jumps.
- Warning: control-flow: diagram method_13yeu7e_getauthenticationstateasync__fragment_diagram exceeds preferred complexity thresholds (65 nodes, 73 edges).
- Warning: control-flow: diagram method_16ct380_createstate__fragment_diagram exceeds preferred complexity thresholds (19 nodes, 22 edges).
